FileMaster
Search
Toggle Dark Mode
Home
/
.
/
wp-content
/
plugins
/
surecart
/
dist
Edit File: 8739.js
"use strict";(self.webpackChunk_surecart_surecart=self.webpackChunk_surecart_surecart||[]).push([[8739],{4805:function(e,n,t){t.d(n,{a:function(){return l},b:function(){return u},g:function(){return p}});var r=t(4467),i=t(3453);function o(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function c(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?o(Object(t),!0).forEach((function(n){(0,r.A)(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):o(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}function a(e,n){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=function(e,n){if(e){if("string"==typeof e)return s(e,n);var t={}.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?s(e,n):void 0}}(e))||n&&e&&"number"==typeof e.length){t&&(e=t);var _n=0,r=function(){};return{s:r,n:function(){return _n>=e.length?{done:!0}:{done:!1,value:e[_n++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,c=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return o=e.done,e},e:function(e){c=!0,i=e},f:function(){try{o||null==t.return||t.return()}finally{if(c)throw i}}}}function s(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=Array(n);t<n;t++)r[t]=e[t];return r}function u(e){for(var n,t="",r=Object.entries(e);n=r.shift();){var o=n,c=(0,i.A)(o,2),s=c[0],u=c[1];if(Array.isArray(u)||u&&u.constructor===Object){var d,p=a(Object.entries(u).reverse());try{for(p.s();!(d=p.n()).done;){var l=(0,i.A)(d.value,2),f=l[0],h=l[1];r.unshift(["".concat(s,"[").concat(f,"]"),h])}}catch(e){p.e(e)}finally{p.f()}}else void 0!==u&&(null===u&&(u=""),t+="&"+[s,u].map(encodeURIComponent).join("="))}return t.substr(1)}function d(e){try{return decodeURIComponent(e)}catch(n){return e}}function p(e){return(function(e){var n;try{n=new URL(e,"http://example.com").search.substring(1)}catch(e){}if(n)return n}(e)||"").replace(/\+/g,"%20").split("&").reduce((function(e,n){var t=n.split("=").filter(Boolean).map(d),r=(0,i.A)(t,2),o=r[0],a=r[1],s=void 0===a?"":a;return o&&function(e,n,t){for(var r=n.length,i=r-1,o=0;o<r;o++){var a=n[o];!a&&Array.isArray(e)&&(a=e.length.toString()),a=["__proto__","constructor","prototype"].includes(a)?a.toUpperCase():a;var s=!isNaN(Number(n[o+1]));e[a]=o===i?t:e[a]||(s?[]:{}),Array.isArray(e[a])&&!s&&(e[a]=c({},e[a])),e=e[a]}}(e,o.replace(/\]/g,"").split("["),s),e}),Object.create(null))}function l(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1?arguments[1]:void 0;if(!n||!Object.keys(n).length)return e;var t=e,r=e.indexOf("?");return-1!==r&&(n=Object.assign(p(e),n),t=t.substr(0,r)),t+"?"+u(n)}},488:function(e,n,t){t.d(n,{i:function(){return o},m:function(){return i},z:function(){return r}});var r=["bif","byr","clp","djf","gnf","isk","jpy","kmf","krw","pyg","rwf","ugx","vnd","vuv","xaf","xag","xau","xba","xbb","xbc","xbd","xdr","xof","xpd","xpf","xpt","xts"],i=function(e,n){return o(n)?e:e/100},o=function(e){var n;return r.includes(null===(n=null==e?void 0:e.toLowerCase)||void 0===n?void 0:n.call(e))}},8803:function(e,n,t){t.d(n,{a:function(){return F},h:function(){return H}});var r=t(9394),i=t(467),o=t(45),c=t(3453),a=t(4467),s=t(9280),u=t.n(s),d=t(4805),p=t(3506),l=["rest_route"],f=["path","url"],h=["url","path","data","parse"];function v(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function w(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?v(Object(t),!0).forEach((function(n){(0,a.A)(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):v(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}function b(e,n){return void 0!==(0,p.g)(e,n)}function _(e){var n=e.split("?"),t=n[1],r=n[0];return t?r+"?"+t.split("&").map((function(e){return e.split("=")})).map((function(e){return e.map(decodeURIComponent)})).sort((function(e,n){return e[0].localeCompare(n[0])})).map((function(e){return e.map(encodeURIComponent)})).map((function(e){return e.join("=")})).join("&"):r}var y=function(e,n){var t,r,i=e.path;return"string"==typeof e.namespace&&"string"==typeof e.endpoint&&(t=e.namespace.replace(/^\/|\/$/g,""),i=(r=e.endpoint.replace(/^\//,""))?t+"/"+r:t),delete e.namespace,delete e.endpoint,n(w(w({},e),{},{path:i}))};function m(e,n){return Promise.resolve(n?e.body:new window.Response(JSON.stringify(e.body),{status:200,statusText:"OK",headers:e.headers}))}var g=function(e){return e.json?e.json():Promise.reject(e)},k=function(e){return function(e){if(!e)return{};var n=e.match(/<([^>]+)>; rel="next"/);return n?{next:n[1]}:{}}(e.headers.get("link")).next},x=function(e){var n=!!e.path&&-1!==e.path.indexOf("per_page=-1"),t=!!e.url&&-1!==e.url.indexOf("per_page=-1");return n||t},O=function(){var e=(0,i.A)(u().mark((function e(n,t){var r,i,c,a,s,p;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!1!==n.parse){e.next=2;break}return e.abrupt("return",t(n));case 2:if(x(n)){e.next=4;break}return e.abrupt("return",t(n));case 4:return e.next=6,F(w(w({},(l={per_page:100},void 0,void 0,h=(u=n).path,v=u.url,w(w({},(0,o.A)(u,f)),{},{url:v&&(0,d.a)(v,l),path:h&&(0,d.a)(h,l)}))),{},{parse:!1}));case 6:return r=e.sent,e.next=9,g(r);case 9:if(i=e.sent,Array.isArray(i)){e.next=12;break}return e.abrupt("return",i);case 12:if(c=k(r)){e.next=15;break}return e.abrupt("return",i);case 15:a=[].concat(i);case 16:if(!c){e.next=27;break}return e.next=19,F(w(w({},n),{},{path:void 0,url:c,parse:!1}));case 19:return s=e.sent,e.next=22,g(s);case 22:p=e.sent,a=a.concat(p),c=k(s),e.next=16;break;case 27:return e.abrupt("return",a);case 28:case"end":return e.stop()}var u,l,h,v}),e)})));return function(_x,n){return e.apply(this,arguments)}}(),j=new Set(["PATCH","PUT","DELETE"]),P=function(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return Promise.resolve(function(e){return arguments.length>1&&void 0!==arguments[1]&&!arguments[1]?e:204===e.status?null:e.json?e.json():Promise.reject(e)}(e,n)).catch((function(e){return A(e,n)}))};function A(e){if(arguments.length>1&&void 0!==arguments[1]&&!arguments[1])throw e;return function(e){var n={code:"invalid_json",message:wp.i18n.__("The response is not a valid JSON response.")};if(!e||!e.json)throw n;return e.json().catch((function(){throw n}))}(e).then((function(e){var n={code:"unknown_error",message:wp.i18n.__("An unknown error occurred.")};throw e||n}))}var S,M,C,T,E,U,D,N={Accept:"application/json, */*;q=0.1"},R={credentials:"include"},I=[function(e,n){return"string"!=typeof e.url||b(e.url,"_locale")||(e.url=(0,d.a)(e.url,{_locale:"user"})),"string"!=typeof e.path||b(e.path,"_locale")||(e.path=(0,d.a)(e.path,{_locale:"user"})),n(e)},y,function(e,n){var t=e.method,r=void 0===t?"GET":t;return j.has(r.toUpperCase())&&(e=w(w({},e),{},{headers:w(w({},e.headers),{},{"X-HTTP-Method-Override":r,"Content-Type":"application/json"}),method:"POST"})),n(e)},O],L=function(e){if(e.status>=200&&e.status<300)return e;throw e},z=function(e){var n=e.url,t=e.path,r=e.data,i=e.parse,c=void 0===i||i,a=(0,o.A)(e,h),s=e.body,u=e.headers;return u=w(w({},N),u),r&&(s=JSON.stringify(r),u["Content-Type"]="application/json"),window.fetch(n||t||window.location.href,w(w(w({},R),a),{},{body:s,headers:u})).then((function(e){return Promise.resolve(e).then(L).catch((function(e){return A(e,c)})).then((function(e){return P(e,c)}))}),(function(e){if(e&&"AbortError"===e.name)throw e;throw{code:"fetch_error",message:wp.i18n.__("You are probably offline.")}}))};function F(e){return I.reduceRight((function(e,n){return function(t){return n(t,e)}}),z)(e).catch((function(n){return"rest_cookie_invalid_nonce"!==n.code?Promise.reject(n):window.fetch(F.nonceEndpoint).then(L).then((function(e){return e.text()})).then((function(n){return F.nonceMiddleware.nonce=n,F(e)}))}))}F.use=function(e){I.unshift(e)},F.setFetchHandler=function(e){z=e},F.createNonceMiddleware=function(e){var n=function e(n,t){var r=n.headers,i=void 0===r?{}:r;for(var o in i)if("x-wp-nonce"===o.toLowerCase()&&i[o]===e.nonce)return t(n);return t(w(w({},n),{},{headers:w(w({},i),{},{"X-WP-Nonce":e.nonce})}))};return n.nonce=e,n},F.createPreloadingMiddleware=function(e){var n=Object.fromEntries(Object.entries(e).map((function(e){var n=(0,c.A)(e,2),t=n[0],r=n[1];return[_(t),r]})));return function(e,t){var r=e.parse,i=void 0===r||r,c=e.path;if(!c&&e.url){var a=(0,d.g)(e.url),s=a.rest_route,u=(0,o.A)(a,l);"string"==typeof s&&(c=(0,d.a)(s,u))}if("string"!=typeof c)return t(e);var p=e.method||"GET",f=_(c);if("GET"===p&&n[f]){var h=n[f];return delete n[f],m(h,!!i)}if("OPTIONS"===p&&n[p]&&n[p][f]){var v=n[p][f];return delete n[p][f],m(v,!!i)}return t(e)}},F.createRootURLMiddleware=function(e){return function(n,t){return y(n,(function(n){var r,i=n.url,o=n.path;return"string"==typeof o&&(r=e,-1!==e.indexOf("?")&&(o=o.replace("?","&")),o=o.replace(/^\//,""),"string"==typeof r&&-1!==r.indexOf("?")&&(o=o.replace("?","&")),i=r+o),t(w(w({},n),{},{url:i}))}))}},F.fetchAllMiddleware=O,F.mediaUploadMiddleware=function(e,n){if(!function(e){var n=!!e.method&&"POST"===e.method;return(!!e.path&&-1!==e.path.indexOf("/wp/v2/media")||!!e.url&&-1!==e.url.indexOf("/wp/v2/media"))&&n}(e))return n(e);var t=0,r=function e(r){return t++,n({path:"/wp/v2/media/".concat(r,"/post-process"),method:"POST",data:{action:"create-image-subsizes"},parse:!1}).catch((function(){return t<5?e(r):(n({path:"/wp/v2/media/".concat(r,"?force=true"),method:"DELETE"}),Promise.reject())}))};return n(w(w({},e),{},{parse:!1})).catch((function(n){var t=n.headers.get("x-wp-upload-attachment-id");return n.status>=500&&n.status<600&&t?r(t).catch((function(){return!1!==e.parse?Promise.reject({code:"post_process",message:wp.i18n.__("Media upload failed. If this is a photo or a large image, please scale it down and try again.")}):Promise.reject(n)})):A(n,e.parse)})).then((function(n){return P(n,e.parse)}))},F.createThemePreviewMiddleware=function(e){return function(n,t){if("string"==typeof n.url){var r=(0,p.g)(n.url,"wp_theme_preview");void 0===r?n.url=(0,d.a)(n.url,{wp_theme_preview:e}):""===r&&(n.url=(0,p.r)(n.url,"wp_theme_preview"))}if("string"==typeof n.path){var i=(0,p.g)(n.path,"wp_theme_preview");void 0===i?n.path=(0,d.a)(n.path,{wp_theme_preview:e}):""===i&&(n.path=(0,p.r)(n.path,"wp_theme_preview"))}return t(n)}},F.fetchAllMiddleware=null,F.use(F.createRootURLMiddleware((null===(M=null===(S=null===window||void 0===window?void 0:window.parent)||void 0===S?void 0:S.scData)||void 0===M?void 0:M.root_url)||(null===(C=null===window||void 0===window?void 0:window.scData)||void 0===C?void 0:C.root_url))),(null===(T=null===window||void 0===window?void 0:window.scData)||void 0===T?void 0:T.nonce)&&(F.nonceMiddleware=F.createNonceMiddleware(null===(E=null===window||void 0===window?void 0:window.scData)||void 0===E?void 0:E.nonce),F.use(F.nonceMiddleware)),(null===(U=null===window||void 0===window?void 0:window.scData)||void 0===U?void 0:U.nonce_endpoint)&&(F.nonceEndpoint=null===(D=null===window||void 0===window?void 0:window.scData)||void 0===D?void 0:D.nonce_endpoint),F.use((function(e,n){return e.path=(0,d.a)(e.path,{t:Date.now()}),n(e)})),F.use((function(e,n){return e.path=(0,d.a)(e.path,w({},!!(0,p.g)(window.location.href,"currency")&&{currency:(0,p.g)(window.location.href,"currency")})),n(e)})),F.use((function(e,n){var t=n(e);return t.catch((function(e){var n;return"invalid_json"===e.code&&(e.message=wp.i18n.__("The response is not a valid JSON response.","surecart"),e.additional_errors=[{code:"invalid_json",message:wp.i18n.sprintf(/* translators: %s: URL to debug settings page */ wp.i18n.__("Please ensure that your site is not in debug mode as this may interfere with API responses. %s","surecart"),'<a href="'.concat("https://surecart.com/docs/is-not-a-valid-json-response/",'" target="_blank" rel="noopener noreferrer">').concat(wp.i18n.__("More Information","surecart"),"</a>"))}]),"checkout.finalize_error"===e.code&&(e.additional_errors=[].concat((0,r.A)((null===(n=null==e?void 0:e.additional_errors)||void 0===n?void 0:n.length)?[]:[{code:"checkout.finalize_error",message:e.message}]),(0,r.A)(e.additional_errors||[])),e.message=wp.i18n.__("We were not able to process this order","surecart")),Promise.reject(e)})),t}));var q=function(e){var n={code:"invalid_json",message:wp.i18n.__("The response is not a valid JSON response.","surecart")};if((null==e?void 0:e.code)&&(null==e?void 0:e.message))throw e;if(!e||!e.json)throw n;return e.json().catch((function(){throw n}))},H=function(){var e=(0,i.A)(u().mark((function e(n){var t;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,q(n);case 2:if("rest_cookie_invalid_nonce"===(t=e.sent).code){e.next=5;break}throw t;case 5:return e.abrupt("return",window.fetch(F.nonceEndpoint).then((function(e){if(e.status>=200&&e.status<300)return e;throw e})).then((function(e){return e.text()})).then((function(e){F.nonceMiddleware.nonce=e})));case 6:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}()},2942:function(e,n,t){t.d(n,{o:function(){return r}});var r=function(e,n){new window.IntersectionObserver((function(e,t){e[0].intersectionRatio>0&&(n(),t.unobserve(e[0].target))})).observe(e)}},57:function(e,n,t){t.d(n,{a:function(){return i},b:function(){return l},c:function(){return c},g:function(){return o},i:function(){return s},p:function(){return p},t:function(){return a}});var r=t(488),i=function(e){return(null==e?void 0:e.amount_off)&&(null==e?void 0:e.currency)?o({amount:e.amount_off,currency:e.currency}):(null==e?void 0:e.percent_off)?wp.i18n.sprintf(wp.i18n.__("%1d%% off","surecart"),0|e.percent_off):""},o=function(e){var n=e.amount,t=e.currency,i=function(e,n){return r.z.includes(n)?e:e/100}(n,t);return"".concat(new Intl.NumberFormat(void 0,{style:"currency",currency:t}).format(parseFloat(i.toFixed(2))))},c=function(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"usd";return null===(e=new Intl.NumberFormat(void 0,{style:"currency",currency:n}).formatToParts().find((function(e){return"currency"===e.type})))||void 0===e?void 0:e.value},a=function(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:wp.i18n.__("every","surecart"),r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:wp.i18n.__("once","surecart"),i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];switch(n){case"day":return"".concat(t," ").concat(wp.i18n.sprintf(i?wp.i18n._n("%d day","%d days",e,"surecart"):wp.i18n._n("day","%d days",e,"surecart"),e));case"week":return"".concat(t," ").concat(wp.i18n.sprintf(i?wp.i18n._n("%d week","%d weeks",e,"surecart"):wp.i18n._n("week","%d weeks",e,"surecart"),e));case"month":return"".concat(t," ").concat(wp.i18n.sprintf(i?wp.i18n._n("%d month","%d months",e,"surecart"):wp.i18n._n("month","%d months",e,"surecart"),e));case"year":return"".concat(t," ").concat(wp.i18n.sprintf(i?wp.i18n._n("%d year","%d years",e,"surecart"):wp.i18n._n("year","%d years",e,"surecart"),e));default:return r}},s=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e)return"";var t=n.showOnce,r=n.labels,i=n.abbreviate,o=(r||{}).interval,c=void 0===o?wp.i18n.__("every","surecart"):o;return"".concat(u(e,c,t?wp.i18n.__("once","surecart"):"",i)," ").concat(d(e,i))},u=function(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:wp.i18n.__("once","surecart"),r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return e.recurring_interval_count&&e.recurring_interval&&1!==(null==e?void 0:e.recurring_period_count)?r?function(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:wp.i18n.__("once","surecart"),r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];switch(n){case"day":return" / ".concat(wp.i18n.sprintf(r?wp.i18n._n("%d day","%d days",e,"surecart"):wp.i18n._n("day","%d days",e,"surecart"),e));case"week":return" / ".concat(wp.i18n.sprintf(r?wp.i18n._n("%d wk","%d wks",e,"surecart"):wp.i18n._n("wk","%d wks",e,"surecart"),e));case"month":return" / ".concat(wp.i18n.sprintf(r?wp.i18n._n("%d mo","%d months",e,"surecart"):wp.i18n._n("mo","%d mos",e,"surecart"),e));case"year":return" / ".concat(wp.i18n.sprintf(r?wp.i18n._n("%d yr","%d yrs",e,"surecart"):wp.i18n._n("yr","%d yrs",e,"surecart"),e));default:return t}}(e.recurring_interval_count,e.recurring_interval,t):a(e.recurring_interval_count,e.recurring_interval," ".concat(n),t):""},d=function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return(null==e?void 0:e.recurring_period_count)&&1!==(null==e?void 0:e.recurring_period_count)?n?"x ".concat(e.recurring_period_count):" (".concat(wp.i18n.sprintf(wp.i18n._n("%d payment","%d payments",e.recurring_period_count,"surecart"),e.recurring_period_count),")"):""},p=function(e){var n;return e?"".concat(null===(n=null==e?void 0:e.product)||void 0===n?void 0:n.name," ").concat((null==e?void 0:e.name)?"— ".concat(e.name):""):""},l=function(e){switch(e){case"invalid":return wp.i18n.__("Not valid","surecart");case"expired":return wp.i18n.__("Expired","surecart");case"gone":return wp.i18n.__("Not available","surecart");case"less_than_min_subtotal_amount":return wp.i18n.__("Minimum not met","surecart");case"greater_than_max_subtotal_amount":return wp.i18n.__("Order amount exceeds limit","surecart");case"not_applicable":return wp.i18n.__("Product(s) not eligible","surecart");case"not_applicable_to_customer":return wp.i18n.__("Not eligible","surecart");case"":return"";default:return wp.i18n.__("Not redeemable","surecart")}}},3506:function(e,n,t){t.d(n,{g:function(){return i},r:function(){return o}});var r=t(4805);function i(e,n){return(0,r.g)(e)[n]}function o(e){var n=e.indexOf("?");if(-1===n)return e;for(var t=(0,r.g)(e),i=e.substr(0,n),o=arguments.length,c=new Array(o>1?o-1:0),a=1;a<o;a++)c[a-1]=arguments[a];c.forEach((function(e){return delete t[e]}));var s=(0,r.b)(t);return s?i+"?"+s:i}},8739:function(e,n,t){t.r(n),t.d(n,{sc_subscription:function(){return w}});var r=t(4467),i=t(467),o=t(3029),c=t(2901),a=t(9280),s=t.n(a),u=t(1346),d=t(8803),p=t(2942),l=t(57),f=t(4805);function h(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function v(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?h(Object(t),!0).forEach((function(n){(0,r.A)(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):h(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}var w=function(){return(0,c.A)((function e(n){(0,o.A)(this,e),(0,u.r)(this,n),this.subscriptionId=void 0,this.showCancel=void 0,this.heading=void 0,this.query=void 0,this.protocol=void 0,this.subscription=void 0,this.updatePaymentMethodUrl=void 0,this.loading=void 0,this.cancelModal=void 0,this.resubscribeModal=void 0,this.busy=void 0,this.error=void 0}),[{key:"componentWillLoad",value:function(){var e=this;(0,p.o)(this.el,(function(){e.subscription||e.getSubscription()}))}},{key:"cancelPendingUpdate",value:(t=(0,i.A)(s().mark((function e(){var n;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(confirm(wp.i18n.__("Are you sure you want to cancel the pending update to your plan?","surecart"))){e.next=3;break}return e.abrupt("return");case 3:return e.prev=3,this.busy=!0,e.next=7,(0,d.a)({path:(0,f.a)("surecart/v1/subscriptions/".concat(null===(n=this.subscription)||void 0===n?void 0:n.id,"/"),{expand:["price","price.product","current_period","period.checkout","purchase","purchase.license","license.activations","discount","discount.coupon"]}),method:"PATCH",data:{purge_pending_update:!0}});case 7:this.subscription=e.sent,e.next=14;break;case 10:e.prev=10,e.t0=e.catch(3),(null===e.t0||void 0===e.t0?void 0:e.t0.message)?this.error=e.t0.message:this.error=wp.i18n.__("Something went wrong","surecart"),console.error(this.error);case 14:return e.prev=14,this.busy=!1,e.finish(14);case 17:case"end":return e.stop()}}),e,this,[[3,10,14,17]])}))),function(){return t.apply(this,arguments)})},{key:"renewSubscription",value:(n=(0,i.A)(s().mark((function e(){var n;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,this.error="",this.busy=!0,e.next=5,(0,d.a)({path:(0,f.a)("surecart/v1/subscriptions/".concat(null===(n=this.subscription)||void 0===n?void 0:n.id,"/renew"),{expand:["price","price.product","current_period","period.checkout","purchase","purchase.license","license.activations","discount","discount.coupon"]}),method:"PATCH"});case 5:this.subscription=e.sent,e.next=11;break;case 8:e.prev=8,e.t0=e.catch(0),this.error=(null===e.t0||void 0===e.t0?void 0:e.t0.message)||wp.i18n.__("Something went wrong","surecart");case 11:return e.prev=11,this.busy=!1,e.finish(11);case 14:case"end":return e.stop()}}),e,this,[[0,8,11,14]])}))),function(){return n.apply(this,arguments)})},{key:"getSubscription",value:(e=(0,i.A)(s().mark((function e(){var n;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,this.loading=!0,e.next=4,(0,d.a)({path:(0,f.a)("surecart/v1/subscriptions/".concat(this.subscriptionId||(null===(n=this.subscription)||void 0===n?void 0:n.id)),v({expand:["price","price.product","current_period"]},this.query||{}))});case 4:return e.next=6,e.sent;case 6:this.subscription=e.sent,e.next=13;break;case 9:e.prev=9,e.t0=e.catch(0),(null===e.t0||void 0===e.t0?void 0:e.t0.message)?this.error=e.t0.message:this.error=wp.i18n.__("Something went wrong","surecart"),console.error(this.error);case 13:return e.prev=13,this.loading=!1,e.finish(13);case 16:case"end":return e.stop()}}),e,this,[[0,9,13,16]])}))),function(){return e.apply(this,arguments)})},{key:"renderName",value:function(e){var n;return"string"!=typeof(null===(n=null==e?void 0:e.price)||void 0===n?void 0:n.product)?(0,l.p)(null==e?void 0:e.price):wp.i18n.__("Subscription","surecart")}},{key:"renderRenewalText",value:function(e){var n=(0,u.h)("sc-subscription-status-badge",{subscription:e});return(null==e?void 0:e.cancel_at_period_end)&&e.current_period_end_at?(0,u.h)("span",null,n," ",/* translators: %s: current period end date */ wp.i18n.sprintf(wp.i18n.__("Your plan will be canceled on %s","surecart"),e.current_period_end_at_date)):"trialing"===e.status&&e.trial_end_at?(0,u.h)("span",null,n," ",/* translators: %s: trial end date */ wp.i18n.sprintf(wp.i18n.__("Your plan begins on %s","surecart"),e.trial_end_at_date)):"active"===e.status&&e.current_period_end_at?(0,u.h)("span",null,n," ",/* translators: %s: current period end date */ wp.i18n.sprintf(wp.i18n.__("Your plan renews on %s","surecart"),e.current_period_end_at_date)):n}},{key:"renderEmpty",value:function(){return(0,u.h)("slot",{name:"empty"},wp.i18n.__("This subscription does not exist.","surecart"))}},{key:"renderLoading",value:function(){return(0,u.h)("sc-stacked-list-row",{style:{"--columns":"2"},"mobile-size":0},(0,u.h)("div",{style:{padding:"0.5em"}},(0,u.h)("sc-skeleton",{style:{width:"30%",marginBottom:"0.75em"}}),(0,u.h)("sc-skeleton",{style:{width:"20%",marginBottom:"0.75em"}}),(0,u.h)("sc-skeleton",{style:{width:"40%"}})))}},{key:"renderContent",value:function(){return this.loading?this.renderLoading():this.subscription?(0,u.h)(u.F,null,(0,u.h)("sc-subscription-next-payment",{subscription:this.subscription,updatePaymentMethodUrl:this.updatePaymentMethodUrl},(0,u.h)("sc-subscription-details",{subscription:this.subscription}))):this.renderEmpty()}},{key:"render",value:function(){var e,n,t,r,i,o,c,a,s=this,d=(null==this?void 0:this.subscription.payment_method)||(null==this?void 0:this.subscription.manual_payment);return(0,u.h)("sc-dashboard-module",{key:"41b533c4fe48a6299c339e827291c248b3cda3e9",heading:this.heading||wp.i18n.__("Current Plan","surecart"),class:"subscription",error:this.error},!!this.subscription&&(null===(e=null==this?void 0:this.subscription)||void 0===e?void 0:e.can_modify)&&(0,u.h)("sc-flex",{key:"5540b28a8d2bc8831103f0c694e6e90323e534f9",slot:"end",class:"subscription__action-buttons"},this.updatePaymentMethodUrl&&d&&(0,u.h)("sc-button",{key:"498086a691572e02bd6f9d76ceacc23a5a3befe0",type:"link",href:this.updatePaymentMethodUrl},(0,u.h)("sc-icon",{key:"122fc7153cb0d66bbb7a0a444dd49df0f876ebcc",name:"credit-card",slot:"prefix"}),wp.i18n.__("Update Payment Method","surecart")),!d&&(0,u.h)("sc-button",{key:"b9f98d824335b33c1858ef5560556f90d320b268",type:"link",href:(0,f.a)(window.location.href,v({action:"create",model:"payment_method",id:null==this?void 0:this.subscription.id},!1===(null===(n=null==this?void 0:this.subscription)||void 0===n?void 0:n.live_mode)?{live_mode:!1}:{}))},(0,u.h)("sc-icon",{key:"d9316cd6c5a70bad426a8313d68e6c3857c5db7a",name:"credit-card",slot:"prefix"}),wp.i18n.__("Add Payment Method","surecart")),!!Object.keys(null===(t=this.subscription)||void 0===t?void 0:t.pending_update).length&&(0,u.h)("sc-button",{key:"8153eb62aa38de9051e08df68c1ccc0ca1aaa8b2",type:"link",onClick:function(){return s.cancelPendingUpdate()}},(0,u.h)("sc-icon",{key:"ee83f4c17853b238ebe9087a490c7200e69e073c",name:"x-octagon",slot:"prefix"}),wp.i18n.__("Cancel Scheduled Update","surecart")),(null===(r=null==this?void 0:this.subscription)||void 0===r?void 0:r.cancel_at_period_end)?(0,u.h)("sc-button",{type:"link",onClick:function(){return s.renewSubscription()}},(0,u.h)("sc-icon",{name:"repeat",slot:"prefix"}),wp.i18n.__("Restore Plan","surecart")):"canceled"!==(null===(i=this.subscription)||void 0===i?void 0:i.status)&&(null===(o=this.subscription)||void 0===o?void 0:o.current_period_end_at)&&this.showCancel&&(0,u.h)("sc-button",{type:"link",onClick:function(){return s.cancelModal=!0}},(0,u.h)("sc-icon",{name:"x",slot:"prefix"}),wp.i18n.__("Cancel Plan","surecart")),"canceled"===(null===(c=this.subscription)||void 0===c?void 0:c.status)&&(0,u.h)("sc-button",v({key:"6497cbc56f4386c0d70f9a2dddf30a0bfe8c38fd",type:"link"},(null===(a=this.subscription)||void 0===a?void 0:a.payment_method)||(null==this?void 0:this.subscription.manual_payment)?{onClick:function(){return s.resubscribeModal=!0}}:{href:null==this?void 0:this.updatePaymentMethodUrl}),(0,u.h)("sc-icon",{key:"cb01f33008de985aa68a2b805d672fc6b28add8e",name:"repeat",slot:"prefix"}),wp.i18n.__("Resubscribe","surecart"))),(0,u.h)("sc-card",{key:"6d5b5af082c5c4d3ef920d03f9e01df220bf760f",style:{"--overflow":"hidden"},noPadding:!0},this.renderContent()),this.busy&&(0,u.h)("sc-block-ui",{key:"dbbf45e0dc55da0096a0eb70c241a370b61cd233",spinner:!0}),(0,u.h)("sc-cancel-dialog",{key:"a9a37e6ebdd3600566b70f6e1d77ae7902a4f04b",subscription:this.subscription,protocol:this.protocol,open:this.cancelModal,onScRequestClose:function(){return s.cancelModal=!1},onScRefresh:function(){return s.getSubscription()}},(0,u.h)("slot",{key:"3c020dd10acfb4d2454d4e2d59031c922d51e478",name:"cancel-popup-content",slot:"cancel-popup-content"})),(0,u.h)("sc-subscription-reactivate",{key:"2c5dd253a7d565c13e91f91737cf4e1064a54550",subscription:this.subscription,open:this.resubscribeModal,onScRequestClose:function(){return s.resubscribeModal=!1},onScRefresh:function(){return s.getSubscription()}}))}},{key:"el",get:function(){return(0,u.a)(this)}}]);var e,n,t}();w.style=":host{display:block}.subscription{display:grid;gap:0.5em}.subscription a{text-decoration:none;font-weight:var(--sc-font-weight-semibold);display:inline-flex;align-items:center;gap:0.25em;color:var(--sc-color-primary-500)}.subscription a.cancel{color:var(--sc-color-danger-500)}@media screen and (max-width: 720px){.subscription__action-buttons{--sc-flex-column-gap:var(--sc-spacing-xxx-small)}.subscription__action-buttons::part(base){flex-direction:column}.subscription__action-buttons sc-button::part(base){width:auto;height:2em}}"}}]);
Save
Back