JezK
Edit File: 3015.js
"use strict";(self.webpackChunk_surecart_surecart=self.webpackChunk_surecart_surecart||[]).push([[3015],{34805:function(e,t,n){n.d(t,{a:function(){return p},b:function(){return u},g:function(){return d}});var r=n(64467),i=n(3453);function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function a(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach((function(t){(0,r.A)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function s(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return c(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?c(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);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,a=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){a=!0,i=e},f:function(){try{o||null==n.return||n.return()}finally{if(a)throw i}}}}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function u(e){for(var t,n="",r=Object.entries(e);t=r.shift();){var o=t,a=(0,i.A)(o,2),c=a[0],u=a[1];if(Array.isArray(u)||u&&u.constructor===Object){var l,d=s(Object.entries(u).reverse());try{for(d.s();!(l=d.n()).done;){var p=(0,i.A)(l.value,2),h=p[0],v=p[1];r.unshift(["".concat(c,"[").concat(h,"]"),v])}}catch(e){d.e(e)}finally{d.f()}}else void 0!==u&&(null===u&&(u=""),n+="&"+[c,u].map(encodeURIComponent).join("="))}return n.substr(1)}function l(e){try{return decodeURIComponent(e)}catch(t){return e}}function d(e){return(function(e){var t;try{t=new URL(e,"http://example.com").search.substring(1)}catch(e){}if(t)return t}(e)||"").replace(/\+/g,"%20").split("&").reduce((function(e,t){var n=t.split("=").filter(Boolean).map(l),r=(0,i.A)(n,2),o=r[0],s=r[1],c=void 0===s?"":s;return o&&function(e,t,n){for(var r=t.length,i=r-1,o=0;o<r;o++){var s=t[o];!s&&Array.isArray(e)&&(s=e.length.toString()),s=["__proto__","constructor","prototype"].includes(s)?s.toUpperCase():s;var c=!isNaN(Number(t[o+1]));e[s]=o===i?n:e[s]||(c?[]:{}),Array.isArray(e[s])&&!c&&(e[s]=a({},e[s])),e=e[s]}}(e,o.replace(/\]/g,"").split("["),c),e}),Object.create(null))}function p(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1?arguments[1]:void 0;if(!t||!Object.keys(t).length)return e;var n=e,r=e.indexOf("?");return-1!==r&&(t=Object.assign(d(e),t),n=n.substr(0,r)),n+"?"+u(t)}},78095:function(e,t,n){n.d(t,{h:function(){return g}});var r,i,o,a,s,c,u,l=n(10467),d=n(89394),p=n(64467),h=n(89280),v=n.n(h),f=n(96030),m=n(34805),b=n(53506);function _(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}var y=(null===(i=null===(r=null===window||void 0===window?void 0:window.parent)||void 0===r?void 0:r.scData)||void 0===i?void 0:i.root_url)||(null===(o=null===window||void 0===window?void 0:window.scData)||void 0===o?void 0:o.root_url);y&&(f.a.fetchAllMiddleware=null,f.a.use(f.a.createRootURLMiddleware(y)),(null===(a=null===window||void 0===window?void 0:window.scData)||void 0===a?void 0:a.nonce)&&(f.a.nonceMiddleware=f.a.createNonceMiddleware(null===(s=null===window||void 0===window?void 0:window.scData)||void 0===s?void 0:s.nonce),f.a.use(f.a.nonceMiddleware)),(null===(c=null===window||void 0===window?void 0:window.scData)||void 0===c?void 0:c.nonce_endpoint)&&(f.a.nonceEndpoint=null===(u=null===window||void 0===window?void 0:window.scData)||void 0===u?void 0:u.nonce_endpoint),f.a.use((function(e,t){return e.path=(0,m.a)(e.path,{t:Date.now()}),t(e)})),f.a.use((function(e,t){return e.path=(0,m.a)(e.path,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?_(Object(n),!0).forEach((function(t){(0,p.A)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):_(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({},!!(0,b.g)(window.location.href,"currency")&&{currency:(0,b.g)(window.location.href,"currency")})),t(e)})),f.a.use((function(e,t){var n=t(e);return n.catch((function(e){var t;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,d.A)((null===(t=null==e?void 0:e.additional_errors)||void 0===t?void 0:t.length)?[]:[{code:"checkout.finalize_error",message:e.message}]),(0,d.A)(e.additional_errors||[])),e.message=wp.i18n.__("We were not able to process this order","surecart")),Promise.reject(e)})),n})));var w=function(e){var t={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 t;return e.json().catch((function(){throw t}))},g=function(){var e=(0,l.A)(v().mark((function e(t){var n;return v().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,w(t);case 2:if("rest_cookie_invalid_nonce"===(n=e.sent).code){e.next=5;break}throw n;case 5:return e.abrupt("return",window.fetch(f.a.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.a.nonceMiddleware.nonce=e})));case 6:case"end":return e.stop()}}),e)})));return function(_x){return e.apply(this,arguments)}}()},86485:function(e,t,n){n.d(t,{a:function(){return d},b:function(){return h},c:function(){return p},d:function(){return c},e:function(){return l},g:function(){return u},i:function(){return v}});var r=n(64467),i=n(89394);function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function a(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach((function(t){(0,r.A)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var s=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return(0,i.A)(e).sort((function(e,t){var n,r;return(null!==(n=null==e?void 0:e.position)&&void 0!==n?n:0)-(null!==(r=null==t?void 0:t.position)&&void 0!==r?r:0)}))},c=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=Math.max(Number(t)||1,1),r=Math.max(Number(null==e?void 0:e.quantity)||1,1);return Math.max(Math.round(r/n),1)},u=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=((arguments.length>3&&void 0!==arguments[3]?arguments[3]:"·")||"·").trim()||"·";return(e||[]).map((function(e){var i,o=((null==e?void 0:e.variant_options)||[]).filter(Boolean),a=o.length?o.join(" ".concat(r," ")):((null==e?void 0:e.variant_display_options)||"").trim();if(!n&&!a)return null;var s=null===(i=null==e?void 0:e.price)||void 0===i?void 0:i.product,u=(null==s?void 0:s.name)||"";if(!u)return null;var l=c(e,t);return{id:null==e?void 0:e.id,name:u,variants:a,qty:l}})).filter(Boolean)},l=function(){return s(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).map((function(e){var t=null==e?void 0:e.component_product,n=(null==t?void 0:t.name)||"",r=Math.max(Number(null==e?void 0:e.quantity)||1,1);return n?{id:null==e?void 0:e.id,name:n,variants:"",qty:r}:null})).filter(Boolean)},d=function(){var e=[],t=[],n={};return((arguments.length>0&&void 0!==arguments[0]?arguments[0]:[])||[]).forEach((function(r){var i,o;if(!(null==r?void 0:r.component_line_item)){var a=null===(i=null==r?void 0:r.price)||void 0===i?void 0:i.product;if(null==a?void 0:a.bundle)return t.push(r),void(n[r.id]=s((null===(o=null==r?void 0:r.component_line_items)||void 0===o?void 0:o.data)||[]));e.push(r)}})),{regular:e,bundleParents:t,componentsByParent:n}},p=function(e){return((null==e?void 0:e.data)||[]).filter((function(e){return!(null==e?void 0:e.component_line_item)})).map((function(e){var t;return a(a({},(null==e?void 0:e.id)?{id:e.id}:{}),{},{price_id:e.price.id,quantity:e.quantity,variant_id:null===(t=e.variant)||void 0===t?void 0:t.id})}))},h=function(e,t){return((null==e?void 0:e.data)||[]).find((function(e){return e.price.id===t}))},v=function(e,t){var n;return!!((null==(n=null==t?void 0:t.line_items)?void 0:n.data)||[]).map((function(e){return e.price.id})).find((function(t){return(null==e?void 0:e.id)===t}))}},96030:function(e,t,n){n.d(t,{a:function(){return R}});var r=n(10467),i=n(80045),o=n(3453),a=n(64467),s=n(89280),c=n.n(s),u=n(34805),l=n(53506),d=["rest_route"],p=["path","url"],h=["url","path","data","parse"];function v(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function f(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?v(Object(n),!0).forEach((function(t){(0,a.A)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):v(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function m(e,t){return void 0!==(0,l.g)(e,t)}function b(e){var t=e.split("?"),n=t[1],r=t[0];return n?r+"?"+n.split("&").map((function(e){return e.split("=")})).map((function(e){return e.map(decodeURIComponent)})).sort((function(e,t){return e[0].localeCompare(t[0])})).map((function(e){return e.map(encodeURIComponent)})).map((function(e){return e.join("=")})).join("&"):r}var _=function(e,t){var n,r,i=e.path;return"string"==typeof e.namespace&&"string"==typeof e.endpoint&&(n=e.namespace.replace(/^\/|\/$/g,""),i=(r=e.endpoint.replace(/^\//,""))?n+"/"+r:n),delete e.namespace,delete e.endpoint,t(f(f({},e),{},{path:i}))};function y(e,t){return Promise.resolve(t?e.body:new window.Response(JSON.stringify(e.body),{status:200,statusText:"OK",headers:e.headers}))}var w=function(e){return e.json?e.json():Promise.reject(e)},g=function(e){return function(e){if(!e)return{};var t=e.match(/<([^>]+)>; rel="next"/);return t?{next:t[1]}:{}}(e.headers.get("link")).next},O=function(e){var t=!!e.path&&-1!==e.path.indexOf("per_page=-1"),n=!!e.url&&-1!==e.url.indexOf("per_page=-1");return t||n},j=function(){var e=(0,r.A)(c().mark((function e(t,n){var r,o,a,s,l,d;return c().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!1!==t.parse){e.next=2;break}return e.abrupt("return",n(t));case 2:if(O(t)){e.next=4;break}return e.abrupt("return",n(t));case 4:return e.next=6,R(f(f({},(h={per_page:100},void 0,void 0,v=(c=t).path,m=c.url,f(f({},(0,i.A)(c,p)),{},{url:m&&(0,u.a)(m,h),path:v&&(0,u.a)(v,h)}))),{},{parse:!1}));case 6:return r=e.sent,e.next=9,w(r);case 9:if(o=e.sent,Array.isArray(o)){e.next=12;break}return e.abrupt("return",o);case 12:if(a=g(r)){e.next=15;break}return e.abrupt("return",o);case 15:s=[].concat(o);case 16:if(!a){e.next=27;break}return e.next=19,R(f(f({},t),{},{path:void 0,url:a,parse:!1}));case 19:return l=e.sent,e.next=22,w(l);case 22:d=e.sent,s=s.concat(d),a=g(l),e.next=16;break;case 27:return e.abrupt("return",s);case 28:case"end":return e.stop()}var c,h,v,m}),e)})));return function(_x,t){return e.apply(this,arguments)}}(),k=new Set(["PATCH","PUT","DELETE"]),x=function(e){var t=!(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,t)).catch((function(e){return P(e,t)}))};function P(e){if(arguments.length>1&&void 0!==arguments[1]&&!arguments[1])throw e;return function(e){var t={code:"invalid_json",message:wp.i18n.__("The response is not a valid JSON response.")};if(!e||!e.json)throw t;return e.json().catch((function(){throw t}))}(e).then((function(e){var t={code:"unknown_error",message:wp.i18n.__("An unknown error occurred.")};throw e||t}))}var A={Accept:"application/json, */*;q=0.1"},S={credentials:"include"},C=[function(e,t){return"string"!=typeof e.url||m(e.url,"_locale")||(e.url=(0,u.a)(e.url,{_locale:"user"})),"string"!=typeof e.path||m(e.path,"_locale")||(e.path=(0,u.a)(e.path,{_locale:"user"})),t(e)},_,function(e,t){var n=e.method,r=void 0===n?"GET":n;return k.has(r.toUpperCase())&&(e=f(f({},e),{},{headers:f(f({},e.headers),{},{"X-HTTP-Method-Override":r,"Content-Type":"application/json"}),method:"POST"})),t(e)},j],T=function(e){if(e.status>=200&&e.status<300)return e;throw e},D=function(e){var t=e.url,n=e.path,r=e.data,o=e.parse,a=void 0===o||o,s=(0,i.A)(e,h),c=e.body,u=e.headers;return u=f(f({},A),u),r&&(c=JSON.stringify(r),u["Content-Type"]="application/json"),window.fetch(t||n||window.location.href,f(f(f({},S),s),{},{body:c,headers:u})).then((function(e){return Promise.resolve(e).then(T).catch((function(e){return P(e,a)})).then((function(e){return x(e,a)}))}),(function(e){if(e&&"AbortError"===e.name)throw e;throw{code:"fetch_error",message:wp.i18n.__("You are probably offline.")}}))};function R(e){return C.reduceRight((function(e,t){return function(n){return t(n,e)}}),D)(e).catch((function(t){return"rest_cookie_invalid_nonce"!==t.code?Promise.reject(t):window.fetch(R.nonceEndpoint).then(T).then((function(e){return e.text()})).then((function(t){return R.nonceMiddleware.nonce=t,R(e)}))}))}R.use=function(e){C.unshift(e)},R.setFetchHandler=function(e){D=e},R.createNonceMiddleware=function(e){var t=function e(t,n){var r=t.headers,i=void 0===r?{}:r;for(var o in i)if("x-wp-nonce"===o.toLowerCase()&&i[o]===e.nonce)return n(t);return n(f(f({},t),{},{headers:f(f({},i),{},{"X-WP-Nonce":e.nonce})}))};return t.nonce=e,t},R.createPreloadingMiddleware=function(e){var t=Object.fromEntries(Object.entries(e).map((function(e){var t=(0,o.A)(e,2),n=t[0],r=t[1];return[b(n),r]})));return function(e,n){var r=e.parse,o=void 0===r||r,a=e.path;if(!a&&e.url){var s=(0,u.g)(e.url),c=s.rest_route,l=(0,i.A)(s,d);"string"==typeof c&&(a=(0,u.a)(c,l))}if("string"!=typeof a)return n(e);var p=e.method||"GET",h=b(a);if("GET"===p&&t[h]){var v=t[h];return delete t[h],y(v,!!o)}if("OPTIONS"===p&&t[p]&&t[p][h]){var f=t[p][h];return delete t[p][h],y(f,!!o)}return n(e)}},R.createRootURLMiddleware=function(e){return function(t,n){return _(t,(function(t){var r,i=t.url,o=t.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),n(f(f({},t),{},{url:i}))}))}},R.fetchAllMiddleware=j,R.mediaUploadMiddleware=function(e,t){if(!function(e){var t=!!e.method&&"POST"===e.method;return(!!e.path&&-1!==e.path.indexOf("/wp/v2/media")||!!e.url&&-1!==e.url.indexOf("/wp/v2/media"))&&t}(e))return t(e);var n=0,r=function e(r){return n++,t({path:"/wp/v2/media/".concat(r,"/post-process"),method:"POST",data:{action:"create-image-subsizes"},parse:!1}).catch((function(){return n<5?e(r):(t({path:"/wp/v2/media/".concat(r,"?force=true"),method:"DELETE"}),Promise.reject())}))};return t(f(f({},e),{},{parse:!1})).catch((function(t){var n=t.headers.get("x-wp-upload-attachment-id");return t.status>=500&&t.status<600&&n?r(n).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(t)})):P(t,e.parse)})).then((function(t){return x(t,e.parse)}))},R.createThemePreviewMiddleware=function(e){return function(t,n){if("string"==typeof t.url){var r=(0,l.g)(t.url,"wp_theme_preview");void 0===r?t.url=(0,u.a)(t.url,{wp_theme_preview:e}):""===r&&(t.url=(0,l.r)(t.url,"wp_theme_preview"))}if("string"==typeof t.path){var i=(0,l.g)(t.path,"wp_theme_preview");void 0===i?t.path=(0,u.a)(t.path,{wp_theme_preview:e}):""===i&&(t.path=(0,l.r)(t.path,"wp_theme_preview"))}return n(t)}}},53506:function(e,t,n){n.d(t,{g:function(){return i},r:function(){return o}});var r=n(34805);function i(e,t){return(0,r.g)(e)[t]}function o(e){var t=e.indexOf("?");if(-1===t)return e;for(var n=(0,r.g)(e),i=e.substr(0,t),o=arguments.length,a=new Array(o>1?o-1:0),s=1;s<o;s++)a[s-1]=arguments[s];a.forEach((function(e){return delete n[e]}));var c=(0,r.b)(n);return c?i+"?"+c:i}},43015:function(e,t,n){n.r(t),n.d(t,{sc_cancel_dialog:function(){return b},sc_subscription_next_payment:function(){return _},sc_subscription_reactivate:function(){return y}});var r=n(64467),i=n(89394),o=n(10467),a=n(23029),s=n(92901),c=n(89280),u=n.n(c),l=n(27364),d=(n(78095),n(96030)),p=n(18674),h=n(86485),v=n(34805);function f(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function m(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?f(Object(n),!0).forEach((function(t){(0,r.A)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):f(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var b=function(){return(0,s.A)((function e(t){(0,a.A)(this,e),(0,l.r)(this,t),this.scRequestClose=(0,l.c)(this,"scRequestClose",7),this.scRefresh=(0,l.c)(this,"scRefresh",7),this.open=void 0,this.protocol=void 0,this.subscription=void 0,this.reasons=void 0,this.reason=void 0,this.step="cancel",this.comment=void 0}),[{key:"close",value:function(){this.reset(),this.trackAttempt(),this.scRequestClose.emit("close-button")}},{key:"reset",value:function(){var e;this.reason=null,this.step=(null===(e=this.protocol)||void 0===e?void 0:e.preservation_enabled)?"survey":"cancel"}},{key:"trackAttempt",value:(e=(0,o.A)(u().mark((function e(){var t,n;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(t=this.protocol)||void 0===t?void 0:t.preservation_enabled){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,(0,d.a)({method:"PATCH",path:"surecart/v1/subscriptions/".concat(null===(n=this.subscription)||void 0===n?void 0:n.id,"/preserve")});case 4:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})},{key:"componentWillLoad",value:function(){this.reset()}},{key:"render",value:function(){var e=this;return(0,l.h)("sc-dialog",{key:"5ae1e6faedc83250d1534ac85cefdce852b18416",style:{"--width":"survey"===this.step?"675px":"500px","--body-spacing":"var(--sc-spacing-xxx-large)"},noHeader:!0,open:this.open,onScRequestClose:function(){return e.close()}},(0,l.h)("div",{key:"8c15f4d9e582c9abf1914990ec61efd48cc91e7c",class:{cancel:!0}},(0,l.h)("sc-button",{key:"b62d8741ac25c51e51bb3c4ec85575346da6f6ca",class:"close__button",type:"text",circle:!0,onClick:function(){return e.close()}},(0,l.h)("sc-icon",{key:"e88b2bf4fb2f97002742adfbf39e175d97b5b73b",name:"x"})),"cancel"===this.step&&(0,l.h)("sc-subscription-cancel",{key:"adf9a7b0a2f20870183c690b9bca9733c275ed89",subscription:this.subscription,protocol:this.protocol,reason:this.reason,comment:this.comment,onScAbandon:function(){return e.close()},onScCancelled:function(){e.scRefresh.emit(),e.reset(),e.scRequestClose.emit("close-button")}},(0,l.h)("slot",{key:"f16afb1cd03512b2e6231cd8e1916d909ead741c",name:"cancel-popup-content",slot:"cancel-popup-content"})),"survey"===this.step&&(0,l.h)("sc-cancel-survey",{key:"c79f59458ed389a3fcf7deaae78aae43bec090be",protocol:this.protocol,onScAbandon:function(){return e.close()},onScSubmitReason:function(t){var n=t.detail,r=n.comment,i=n.reason;e.reason=i,e.comment=r,e.step=(null==i?void 0:i.coupon_enabled)?"discount":"cancel"}}),"discount"===this.step&&(0,l.h)("sc-cancel-discount",{key:"0734bfda47e92ba941c60ace2be1a21fa6f5c07f",protocol:this.protocol,subscription:this.subscription,reason:this.reason,comment:this.comment,onScCancel:function(){return e.step="cancel"},onScPreserved:function(){e.scRefresh.emit(),e.reset(),e.scRequestClose.emit("close-button")}})))}}]);var e}();b.style=":host{display:block;font-size:var(--sc-font-size-medium)}.close__button{position:absolute;top:0;right:0;font-size:22px}";var _=function(){return(0,s.A)((function e(t){(0,a.A)(this,e),(0,l.r)(this,t),this.subscription=void 0,this.updatePaymentMethodUrl=void 0,this.period=void 0,this.loading=!0,this.error=void 0,this.details=void 0}),[{key:"componentWillLoad",value:function(){this.fetch()}},{key:"handleSubscriptionChange",value:function(){this.fetch()}},{key:"fetch",value:(e=(0,o.A)(u().mark((function e(){var t,n,r;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(null===(t=this.subscription)||void 0===t?void 0:t.cancel_at_period_end)||!this.subscription.current_period_end_at){e.next=3;break}return this.loading=!1,e.abrupt("return");case 3:if("canceled"!==(null===(n=this.subscription)||void 0===n?void 0:n.status)){e.next=6;break}return this.loading=!1,e.abrupt("return");case 6:return e.prev=6,this.loading=!0,e.next=10,(0,d.a)({method:"PATCH",path:(0,v.a)("surecart/v1/subscriptions/".concat(null===(r=this.subscription)||void 0===r?void 0:r.id,"/upcoming_period"),{skip_product_group_validation:!0,expand:["period.checkout","checkout.line_items","checkout.checkout_fees","checkout.shipping_fees","checkout.payment_method","checkout.manual_payment_method","payment_method.card","payment_method.payment_instrument","payment_method.paypal_account","payment_method.bank_account","line_item.price","line_item.fees","line_item.component_line_items","price.product","period.subscription"]}),data:{purge_pending_update:!1}});case 10:this.period=e.sent,e.next=17;break;case 13:e.prev=13,e.t0=e.catch(6),console.error(e.t0),this.error=e.t0;case 17:return e.prev=17,this.loading=!1,e.finish(17);case 20:case"end":return e.stop()}}),e,this,[[6,13,17,20]])}))),function(){return e.apply(this,arguments)})},{key:"render",value:function(){var e,t,n,r,o,a,s;if(this.loading)return(0,l.h)("sc-toggle",{borderless:!0,disabled:!0},(0,l.h)("sc-flex",{slot:"summary",flexDirection:"column"},(0,l.h)("sc-skeleton",{style:{width:"200px"}}),(0,l.h)("sc-skeleton",{style:{width:"400px"}}),(0,l.h)("sc-skeleton",{style:{width:"300px"}})));var c=null===(e=null==this?void 0:this.period)||void 0===e?void 0:e.checkout;if(!c)return(0,l.h)("div",{style:{padding:"var(--sc-spacing-medium)"}},(0,l.h)("sc-subscription-details",{slot:"summary",subscription:this.subscription}));var u=(null==c?void 0:c.manual_payment)?null==c?void 0:c.manual_payment_method:null,d=(null==this?void 0:this.subscription.payment_method)||(null==this?void 0:this.subscription.manual_payment),f=null===(t=null==c?void 0:c.checkout_fees)||void 0===t?void 0:t.data,b=null===(n=null==c?void 0:c.shipping_fees)||void 0===n?void 0:n.data;return(0,l.h)(l.H,null,(0,l.h)("sc-toggle",{borderless:!0,shady:!0},(0,l.h)("span",{slot:"summary"},(0,l.h)("sc-subscription-details",{subscription:this.subscription},(0,l.h)("div",{style:{fontSize:"var(--sc-font-size-small)"}},wp.i18n.__("Your next payment is","surecart")," ",(0,l.h)("strong",null,null==c?void 0:c.amount_due_display_amount)," ",!!(null===(r=this.subscription)||void 0===r?void 0:r.remaining_period_text)&&"— ".concat(null===(o=this.subscription)||void 0===o?void 0:o.remaining_period_text)))),(0,l.h)("sc-card",{noPadding:!0,borderless:!0},function(){var e,t=(null===(e=null==c?void 0:c.line_items)||void 0===e?void 0:e.data)||[],n=(0,h.a)(t),r=n.regular,o=n.bundleParents,a=n.componentsByParent;return[].concat((0,i.A)(o),(0,i.A)(r)).map((function(e){var t,n,r,i,o,s=null===(t=null==e?void 0:e.price)||void 0===t?void 0:t.product,c=!!(null==s?void 0:s.bundle);return(0,l.h)("sc-product-line-item",{key:e.id,image:null==s?void 0:s.line_item_image,name:null==s?void 0:s.name,price:null===(n=null==e?void 0:e.price)||void 0===n?void 0:n.name,variant:null==e?void 0:e.variant_display_options,editable:!1,removable:!1,note:null==e?void 0:e.display_note,scratchDisplayAmount:null==e?void 0:e.scratch_display_amount,displayAmount:null==e?void 0:e.subtotal_display_amount,quantity:null==e?void 0:e.quantity,amount:null==e?void 0:e.subtotal_display_amount,interval:"".concat(null===(r=null==e?void 0:e.price)||void 0===r?void 0:r.short_interval_text," ").concat(null===(i=null==e?void 0:e.price)||void 0===i?void 0:i.short_interval_count_text),purchasableStatus:null==e?void 0:e.purchasable_status_display,fees:null===(o=null==e?void 0:e.fees)||void 0===o?void 0:o.data,bundleComponents:c&&a[e.id]||[]})}))}(),(0,l.h)("sc-line-item",null,(0,l.h)("span",{slot:"description"},wp.i18n.__("Subtotal","surecart")),(0,l.h)("span",{slot:"price-description"},null==c?void 0:c.subtotal_display_amount)),!!c.proration_amount&&(0,l.h)("sc-line-item",null,(0,l.h)("span",{slot:"description"},wp.i18n.__("Proration Credit","surecart")),(0,l.h)("span",{slot:"price-description"},null==c?void 0:c.proration_display_amount)),!!c.applied_balance_amount&&(0,l.h)("sc-line-item",null,(0,l.h)("span",{slot:"description"},wp.i18n.__("Applied Balance","surecart")),(0,l.h)("span",{slot:"price-description"},null==c?void 0:c.applied_balance_display_amount)),(null==f?void 0:f.length)>0&&(0,l.h)(l.F,null,null==f?void 0:f.map((function(e){return(0,l.h)("sc-line-item",null,(0,l.h)("span",{slot:"description"},null==e?void 0:e.description),(0,l.h)("span",{slot:"price"},null==e?void 0:e.display_amount))}))),!!c.trial_amount&&(0,l.h)("sc-line-item",null,(0,l.h)("span",{slot:"description"},wp.i18n.__("Trial","surecart")),(0,l.h)("span",{slot:"price-description"},null==c?void 0:c.trial_display_amount)),!!(null==c?void 0:c.discount_amount)&&(0,l.h)("sc-line-item",null,(0,l.h)("span",{slot:"description"},wp.i18n.__("Discounts","surecart")),(0,l.h)("span",{slot:"price-description"},null==c?void 0:c.discounts_display_amount)),!!(null==c?void 0:c.shipping_amount)&&(0,l.h)(l.F,null,(0,l.h)("sc-line-item",{style:{marginTop:"var(--sc-spacing-small)"}},(0,l.h)("span",{slot:"description"},wp.i18n.__("Shipping","surecart")),(0,l.h)("span",{slot:"price-description"},null==c?void 0:c.shipping_display_amount)),(null==b?void 0:b.length)>0&&(0,l.h)(l.F,null,null==b?void 0:b.map((function(e){return(0,l.h)("sc-line-item",null,(0,l.h)("span",{slot:"description"},null==e?void 0:e.description),(0,l.h)("span",{slot:"price"},null==e?void 0:e.display_amount))})))),!!c.tax_amount&&(0,l.h)("sc-line-item",null,(0,l.h)("span",{slot:"description"},(0,p.f)(null==c?void 0:c.tax_label)),(0,l.h)("span",{slot:"price-description"},null==c?void 0:c.tax_display_amount)),(0,l.h)("sc-divider",{style:{"--spacing":"0"}}),(null===(a=null==this?void 0:this.subscription)||void 0===a?void 0:a.can_modify)&&(0,l.h)("sc-line-item",null,(0,l.h)("span",{slot:"description"},wp.i18n.__("Payment","surecart")),d&&(0,l.h)("a",{href:this.updatePaymentMethodUrl,slot:"price-description"},(0,l.h)("sc-flex",{"justify-content":"flex-start","align-items":"center",style:{"--spacing":"0.5em"}},u?(0,l.h)("sc-manual-payment-method",{paymentMethod:u}):(0,l.h)("sc-payment-method",{paymentMethod:null==c?void 0:c.payment_method}),(0,l.h)("sc-icon",{name:"edit-3"}))),!d&&(0,l.h)("a",{href:(0,v.a)(window.location.href,m({action:"create",model:"payment_method",id:null==this?void 0:this.subscription.id},!1===(null===(s=null==this?void 0:this.subscription)||void 0===s?void 0:s.live_mode)?{live_mode:!1}:{})),slot:"price-description"},wp.i18n.__("Add Payment Method","surecart"))),(0,l.h)("sc-line-item",{style:{"--price-size":"var(--sc-font-size-x-large)"}},(0,l.h)("span",{slot:"title"},wp.i18n.__("Total Due","surecart")),(0,l.h)("span",{slot:"price"},null==c?void 0:c.amount_due_display_amount),(0,l.h)("span",{slot:"currency"},c.currency)))))}}],[{key:"watchers",get:function(){return{subscription:["handleSubscriptionChange"]}}}]);var e}(),y=function(){return(0,s.A)((function e(t){(0,a.A)(this,e),(0,l.r)(this,t),this.scRequestClose=(0,l.c)(this,"scRequestClose",7),this.scRefresh=(0,l.c)(this,"scRefresh",7),this.open=void 0,this.subscription=void 0,this.busy=void 0,this.error=void 0,this.upcomingPeriod=void 0,this.loading=!1}),[{key:"openChanged",value:function(){this.open&&this.fetchUpcoming()}},{key:"fetchUpcoming",value:(t=(0,o.A)(u().mark((function e(){var t,n;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.loading=!0,e.prev=1,e.next=4,(0,d.a)({method:"PATCH",path:(0,v.a)("surecart/v1/subscriptions/".concat(null===(t=this.subscription)||void 0===t?void 0:t.id,"/upcoming_period"),{skip_product_group_validation:!0,expand:["period.checkout"]}),data:{purge_pending_update:!1}});case 4:this.upcomingPeriod=e.sent,e.next=10;break;case 7:e.prev=7,e.t0=e.catch(1),this.error=(null===(n=null===e.t0||void 0===e.t0?void 0:e.t0.additional_errors)||void 0===n?void 0:n.length)?e.t0.additional_errors.map((function(e){return e.message})).join(", "):(null===e.t0||void 0===e.t0?void 0:e.t0.message)||wp.i18n.__("Something went wrong","surecart");case 10:return e.prev=10,this.loading=!1,e.finish(10);case 13:case"end":return e.stop()}}),e,this,[[1,7,10,13]])}))),function(){return t.apply(this,arguments)})},{key:"reactivateSubscription",value:(e=(0,o.A)(u().mark((function e(){var t,n;return u().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:"surecart/v1/subscriptions/".concat(null===(t=this.subscription)||void 0===t?void 0:t.id,"/restore"),method:"PATCH"});case 5:this.scRefresh.emit(),this.scRequestClose.emit("close-button"),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(0),this.error=(null===(n=null===e.t0||void 0===e.t0?void 0:e.t0.additional_errors)||void 0===n?void 0:n.length)?e.t0.additional_errors.map((function(e){return e.message})).join(", "):(null===e.t0||void 0===e.t0?void 0:e.t0.message)||wp.i18n.__("Something went wrong","surecart");case 12:return e.prev=12,this.busy=!1,e.finish(12);case 15:case"end":return e.stop()}}),e,this,[[0,9,12,15]])}))),function(){return e.apply(this,arguments)})},{key:"renderLoading",value:function(){return(0,l.h)("sc-flex",{flexDirection:"column",style:{gap:"1em"}},(0,l.h)("sc-skeleton",{style:{width:"20%",display:"inline-block"}}),(0,l.h)("sc-skeleton",{style:{width:"60%",display:"inline-block"}}),(0,l.h)("sc-skeleton",{style:{width:"40%",display:"inline-block"}}))}},{key:"render",value:function(){var e,t,n,r=this;return(0,l.h)("sc-dialog",{key:"537bc2241418bdbd1e71d6f0284f6f029a464c78",noHeader:!0,open:this.open,style:{"--width":"600px","--body-spacing":"var(--sc-spacing-xxx-large)"}},(0,l.h)("sc-dashboard-module",{key:"a799f408b1328a6620aec4dbb448dcb0ca01dfdc",loading:this.loading,heading:wp.i18n.__("Resubscribe","surecart"),class:"subscription-reactivate",error:this.error,style:{"--sc-dashboard-module-spacing":"1em"}},this.loading?this.renderLoading():(0,l.h)(l.F,null,(0,l.h)("div",{slot:"description"},(0,l.h)("sc-alert",{open:!0,type:"warning",title:wp.i18n.__("Confirm Charge","surecart")},wp.i18n.__("You will be charged","surecart")," ",null===(t=null===(e=this.upcomingPeriod)||void 0===e?void 0:e.checkout)||void 0===t?void 0:t.amount_due_display_amount," ",wp.i18n.__("immediately for your subscription.","surecart")),(0,l.h)("sc-text",{style:{"--font-size":"var(--sc-font-size-medium)","--color":"var(--sc-input-label-color)","--line-height":"var(--sc-line-height-dense)","margin-top":"var(--sc-spacing-medium)"}},wp.i18n.__("Your subscription will be reactivated and will renew automatically on","surecart")," ",(0,l.h)("strong",null,null===(n=this.upcomingPeriod)||void 0===n?void 0:n.end_at_date))),(0,l.h)("sc-flex",{justifyContent:"flex-start"},(0,l.h)("sc-button",{type:"primary",loading:this.busy,disabled:this.busy,onClick:function(){return r.reactivateSubscription()}},wp.i18n.__("Yes, Reactivate","surecart")),(0,l.h)("sc-button",{disabled:this.busy,style:{color:"var(--sc-color-gray-500)"},type:"text",onClick:function(){return r.scRequestClose.emit()}},wp.i18n.__("No, Keep Inactive","surecart")))),this.busy&&(0,l.h)("sc-block-ui",{key:"b09af698f84efb4e8cc16af2fdbcdaa4cc1db4be"})))}}],[{key:"watchers",get:function(){return{open:["openChanged"]}}}]);var e,t}()},18674:function(e,t,n){n.d(t,{f:function(){return i},z:function(){return r}});var r={ca_gst:{label:wp.i18n.__("GST Number","surecart"),label_small:wp.i18n.__("CA GST","surecart")},au_abn:{label:wp.i18n.__("ABN Number","surecart"),label_small:wp.i18n.__("AU ABN","surecart")},gb_vat:{label:wp.i18n.__("VAT Number","surecart"),label_small:wp.i18n.__("UK VAT","surecart")},eu_vat:{label:wp.i18n.__("VAT Number","surecart"),label_small:wp.i18n.__("EU VAT","surecart")},other:{label:wp.i18n.__("Tax ID","surecart"),label_small:wp.i18n.__("Other","surecart")}},i=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1]?wp.i18n.__("Estimated Tax","surecart"):wp.i18n.__("Tax","surecart");return e?"".concat(t,": ").concat(e):t}}}]);