stripe-pwa-elements 4.0.0 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/dist/cjs/{factory-da3xAKkz.js → factory-Cd2VI_N2.js} +22 -4
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/stripe-address-element.cjs.entry.js +8 -1
  4. package/dist/cjs/stripe-card-element-modal.cjs.entry.js +1 -1
  5. package/dist/cjs/stripe-card-element_2.cjs.entry.js +24 -6
  6. package/dist/cjs/stripe-currency-selector.cjs.entry.js +8 -1
  7. package/dist/cjs/stripe-elements.cjs.js +1 -1
  8. package/dist/cjs/stripe-express-checkout-element.cjs.entry.js +8 -1
  9. package/dist/cjs/stripe-link-authentication-element.cjs.entry.js +8 -1
  10. package/dist/cjs/stripe-payment-element.cjs.entry.js +95 -38
  11. package/dist/cjs/stripe-payment-request-button.cjs.entry.js +22 -15
  12. package/dist/collection/collection-manifest.json +3 -3
  13. package/dist/collection/components/stripe-address-element/stripe-address-element.js +7 -0
  14. package/dist/collection/components/stripe-card-element/stripe-card-element.js +7 -0
  15. package/dist/collection/components/stripe-card-element-modal/stripe-card-element-modal.js +1 -1
  16. package/dist/collection/components/stripe-currency-selector/stripe-currency-selector.js +7 -0
  17. package/dist/collection/components/stripe-express-checkout-element/stripe-express-checkout-element.js +7 -0
  18. package/dist/collection/components/stripe-link-authentication-element/stripe-link-authentication-element.js +7 -0
  19. package/dist/collection/components/stripe-modal/stripe-modal.js +18 -6
  20. package/dist/collection/components/stripe-payment-element/stripe-payment-element.js +94 -37
  21. package/dist/collection/components/stripe-payment-request-button/stripe-payment-request-button.js +15 -8
  22. package/dist/collection/services/stripe-service.js +22 -4
  23. package/dist/components/factory.js +1 -1
  24. package/dist/components/stripe-address-element.js +1 -1
  25. package/dist/components/stripe-card-element-modal.js +1 -1
  26. package/dist/components/stripe-card-element2.js +1 -1
  27. package/dist/components/stripe-currency-selector.js +1 -1
  28. package/dist/components/stripe-express-checkout-element.js +1 -1
  29. package/dist/components/stripe-link-authentication-element.js +1 -1
  30. package/dist/components/stripe-modal2.js +1 -1
  31. package/dist/components/stripe-payment-element.js +1 -1
  32. package/dist/components/stripe-payment-request-button2.js +1 -1
  33. package/dist/esm/{factory-DeqoYLf_.js → factory-VTa1Gc94.js} +22 -4
  34. package/dist/esm/loader.js +1 -1
  35. package/dist/esm/stripe-address-element.entry.js +8 -1
  36. package/dist/esm/stripe-card-element-modal.entry.js +1 -1
  37. package/dist/esm/stripe-card-element_2.entry.js +24 -6
  38. package/dist/esm/stripe-currency-selector.entry.js +8 -1
  39. package/dist/esm/stripe-elements.js +1 -1
  40. package/dist/esm/stripe-express-checkout-element.entry.js +8 -1
  41. package/dist/esm/stripe-link-authentication-element.entry.js +8 -1
  42. package/dist/esm/stripe-payment-element.entry.js +95 -38
  43. package/dist/esm/stripe-payment-request-button.entry.js +17 -10
  44. package/dist/stripe-elements/p-1bd46766.entry.js +1 -0
  45. package/dist/stripe-elements/p-1c6e0a45.entry.js +1 -0
  46. package/dist/stripe-elements/p-3f42ca0c.entry.js +1 -0
  47. package/dist/stripe-elements/p-74de1556.entry.js +1 -0
  48. package/dist/stripe-elements/p-76e57d78.entry.js +1 -0
  49. package/dist/stripe-elements/p-840d499f.entry.js +1 -0
  50. package/dist/stripe-elements/{p--sA2m1ad.js → p-CrjrbGJ3.js} +1 -1
  51. package/dist/stripe-elements/{p-38e7b187.entry.js → p-ae0c336e.entry.js} +1 -1
  52. package/dist/stripe-elements/p-cfd8e081.entry.js +1 -0
  53. package/dist/stripe-elements/stripe-elements.esm.js +1 -1
  54. package/dist/types/components/stripe-address-element/stripe-address-element.d.ts +6 -0
  55. package/dist/types/components/stripe-card-element/stripe-card-element.d.ts +6 -0
  56. package/dist/types/components/stripe-currency-selector/stripe-currency-selector.d.ts +6 -0
  57. package/dist/types/components/stripe-express-checkout-element/stripe-express-checkout-element.d.ts +6 -0
  58. package/dist/types/components/stripe-link-authentication-element/stripe-link-authentication-element.d.ts +6 -0
  59. package/dist/types/components/stripe-modal/stripe-modal.d.ts +1 -0
  60. package/dist/types/components/stripe-payment-element/stripe-payment-element.d.ts +18 -0
  61. package/dist/types/components/stripe-payment-request-button/stripe-payment-request-button.d.ts +6 -1
  62. package/dist/types/services/interfaces.d.ts +1 -0
  63. package/dist/types/services/stripe-service.d.ts +6 -2
  64. package/package.json +1 -1
  65. package/readme.md +4 -4
  66. package/dist/stripe-elements/p-44495284.entry.js +0 -1
  67. package/dist/stripe-elements/p-4ba675fa.entry.js +0 -1
  68. package/dist/stripe-elements/p-c24ae181.entry.js +0 -1
  69. package/dist/stripe-elements/p-d9e86451.entry.js +0 -1
  70. package/dist/stripe-elements/p-f09c86a0.entry.js +0 -1
  71. package/dist/stripe-elements/p-f64f394d.entry.js +0 -1
  72. package/dist/stripe-elements/p-f6d2425e.entry.js +0 -1
@@ -1 +1 @@
1
- import*as t from"@stencil/core/internal/client";import{l as e}from"./index2.js";const i=t=>"string"==typeof t,s=()=>{let t,e;const i=new Promise(((i,s)=>{t=i,e=s}));return i.resolve=t,i.reject=e,i},n=t=>null==t?"":""+t,r=/###/g,o=t=>t&&t.indexOf("###")>-1?t.replace(r,"."):t,a=t=>!t||i(t),h=(t,e,s)=>{const n=i(e)?e.split("."):e;let r=0;for(;r<n.length-1;){if(a(t))return{};const e=o(n[r]);!t[e]&&s&&(t[e]=new s),t=Object.prototype.hasOwnProperty.call(t,e)?t[e]:{},++r}return a(t)?{}:{obj:t,k:o(n[r])}},l=(t,e,i)=>{const{obj:s,k:n}=h(t,e,Object);if(void 0!==s||1===e.length)return void(s[n]=i);let r=e[e.length-1],o=e.slice(0,e.length-1),a=h(t,o,Object);for(;void 0===a.obj&&o.length;)r=`${o[o.length-1]}.${r}`,o=o.slice(0,o.length-1),a=h(t,o,Object),a?.obj&&void 0!==a.obj[`${a.k}.${r}`]&&(a.obj=void 0);a.obj[`${a.k}.${r}`]=i},c=(t,e)=>{const{obj:i,k:s}=h(t,e);if(i&&Object.prototype.hasOwnProperty.call(i,s))return i[s]},u=(t,e,s)=>{for(const n in e)"__proto__"!==n&&"constructor"!==n&&(n in t?i(t[n])||t[n]instanceof String||i(e[n])||e[n]instanceof String?s&&(t[n]=e[n]):u(t[n],e[n],s):t[n]=e[n]);return t},d=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var f={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const p=t=>i(t)?t.replace(/[&<>"'\/]/g,(t=>f[t])):t,g=[" ",",","?","!",";"],m=new class{constructor(t){this.capacity=t,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(t){const e=this.regExpMap.get(t);if(void 0!==e)return e;const i=new RegExp(t);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(t,i),this.regExpQueue.push(t),i}}(20),y=(t,e,i=".")=>{if(!t)return;if(t[e]){if(!Object.prototype.hasOwnProperty.call(t,e))return;return t[e]}const s=e.split(i);let n=t;for(let t=0;t<s.length;){if(!n||"object"!=typeof n)return;let e,r="";for(let o=t;o<s.length;++o)if(o!==t&&(r+=i),r+=s[o],e=n[r],void 0!==e){if(["string","number","boolean"].indexOf(typeof e)>-1&&o<s.length-1)continue;t+=o-t+1;break}n=e}return n},v=t=>t?.replace(/_/g,"-"),w={type:"logger",log(t){this.output("log",t)},warn(t){this.output("warn",t)},error(t){this.output("error",t)},output(t,e){console?.[t]?.apply?.(console,e)}};class b{constructor(t,e={}){this.init(t,e)}init(t,e={}){this.prefix=e.prefix||"i18next:",this.logger=t||w,this.options=e,this.debug=e.debug}log(...t){return this.forward(t,"log","",!0)}warn(...t){return this.forward(t,"warn","",!0)}error(...t){return this.forward(t,"error","")}deprecate(...t){return this.forward(t,"warn","WARNING DEPRECATED: ",!0)}forward(t,e,s,n){return n&&!this.debug?null:(i(t[0])&&(t[0]=`${s}${this.prefix} ${t[0]}`),this.logger[e](t))}create(t){return new b(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return(t=t||this.options).prefix=t.prefix||this.prefix,new b(this.logger,t)}}var S=new b;class ${constructor(){this.observers={}}on(t,e){return t.split(" ").forEach((t=>{this.observers[t]||(this.observers[t]=new Map);const i=this.observers[t].get(e)||0;this.observers[t].set(e,i+1)})),this}off(t,e){this.observers[t]&&(e?this.observers[t].delete(e):delete this.observers[t])}emit(t,...e){this.observers[t]&&Array.from(this.observers[t].entries()).forEach((([t,i])=>{for(let s=0;s<i;s++)t(...e)})),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach((([i,s])=>{for(let n=0;n<s;n++)i.apply(i,[t,...e])}))}}class x extends ${constructor(t,e={ns:["translation"],defaultNS:"translation"}){super(),this.data=t||{},this.options=e,void 0===this.options.keySeparator&&(this.options.keySeparator="."),void 0===this.options.ignoreJSONStructure&&(this.options.ignoreJSONStructure=!0)}addNamespaces(t){this.options.ns.indexOf(t)<0&&this.options.ns.push(t)}removeNamespaces(t){const e=this.options.ns.indexOf(t);e>-1&&this.options.ns.splice(e,1)}getResource(t,e,s,n={}){const r=void 0!==n.keySeparator?n.keySeparator:this.options.keySeparator,o=void 0!==n.ignoreJSONStructure?n.ignoreJSONStructure:this.options.ignoreJSONStructure;let a;t.indexOf(".")>-1?a=t.split("."):(a=[t,e],s&&(Array.isArray(s)?a.push(...s):i(s)&&r?a.push(...s.split(r)):a.push(s)));const h=c(this.data,a);return!h&&!e&&!s&&t.indexOf(".")>-1&&(t=a[0],e=a[1],s=a.slice(2).join(".")),!h&&o&&i(s)?y(this.data?.[t]?.[e],s,r):h}addResource(t,e,i,s,n={silent:!1}){const r=void 0!==n.keySeparator?n.keySeparator:this.options.keySeparator;let o=[t,e];i&&(o=o.concat(r?i.split(r):i)),t.indexOf(".")>-1&&(o=t.split("."),s=e,e=o[1]),this.addNamespaces(e),l(this.data,o,s),n.silent||this.emit("added",t,e,i,s)}addResources(t,e,s,n={silent:!1}){for(const n in s)(i(s[n])||Array.isArray(s[n]))&&this.addResource(t,e,n,s[n],{silent:!0});n.silent||this.emit("added",t,e,s)}addResourceBundle(t,e,i,s,n,r={silent:!1,skipCopy:!1}){let o=[t,e];t.indexOf(".")>-1&&(o=t.split("."),s=i,i=e,e=o[1]),this.addNamespaces(e);let a=c(this.data,o)||{};r.skipCopy||(i=JSON.parse(JSON.stringify(i))),s?u(a,i,n):a={...a,...i},l(this.data,o,a),r.silent||this.emit("added",t,e,i)}removeResourceBundle(t,e){this.hasResourceBundle(t,e)&&delete this.data[t][e],this.removeNamespaces(e),this.emit("removed",t,e)}hasResourceBundle(t,e){return void 0!==this.getResource(t,e)}getResourceBundle(t,e){return e||(e=this.options.defaultNS),this.getResource(t,e)}getDataByLanguage(t){return this.data[t]}hasLanguageSomeTranslations(t){const e=this.getDataByLanguage(t);return!!(e&&Object.keys(e)||[]).find((t=>e[t]&&Object.keys(e[t]).length>0))}toJSON(){return this.data}}var k={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,e,i,s,n){return t.forEach((t=>{e=this.processors[t]?.process(e,i,s,n)??e})),e}};const C=Symbol("i18next/PATH_KEY");function j(t,e){const{[C]:i}=t(function(){const t=[],e=Object.create(null);let i;return e.get=(s,n)=>(i?.revoke?.(),n===C?t:(t.push(n),i=Proxy.revocable(s,e),i.proxy)),Proxy.revocable(Object.create(null),e).proxy}()),s=e?.keySeparator??".",n=e?.nsSeparator??":";if(i.length>1&&n){const t=e?.ns,r=Array.isArray(t)?t:null;if(r&&r.length>1&&r.slice(1).includes(i[0]))return`${i[0]}${n}${i.slice(1).join(s)}`}return i.join(s)}const E={},O=t=>!i(t)&&"boolean"!=typeof t&&"number"!=typeof t;class N extends ${constructor(t,e={}){var i,s;super(),i=t,s=this,["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"].forEach((t=>{i[t]&&(s[t]=i[t])})),this.options=e,void 0===this.options.keySeparator&&(this.options.keySeparator="."),this.logger=S.create("translator")}changeLanguage(t){t&&(this.language=t)}exists(t,e={interpolation:{}}){const i={...e};if(null==t)return!1;const s=this.resolve(t,i);if(void 0===s?.res)return!1;const n=O(s.res);return!1!==i.returnObjects||!n}extractFromKey(t,e){let s=void 0!==e.nsSeparator?e.nsSeparator:this.options.nsSeparator;void 0===s&&(s=":");const n=void 0!==e.keySeparator?e.keySeparator:this.options.keySeparator;let r=e.ns||this.options.defaultNS||[];const o=s&&t.indexOf(s)>-1,a=!(this.options.userDefinedKeySeparator||e.keySeparator||this.options.userDefinedNsSeparator||e.nsSeparator||((t,e,i)=>{e=e||"",i=i||"";const s=g.filter((t=>e.indexOf(t)<0&&i.indexOf(t)<0));if(0===s.length)return!0;const n=m.getRegExp(`(${s.map((t=>"?"===t?"\\?":t)).join("|")})`);let r=!n.test(t);if(!r){const e=t.indexOf(i);e>0&&!n.test(t.substring(0,e))&&(r=!0)}return r})(t,s,n));if(o&&!a){const e=t.match(this.interpolator.nestingRegexp);if(e&&e.length>0)return{key:t,namespaces:i(r)?[r]:r};const o=t.split(s);(s!==n||s===n&&this.options.ns.indexOf(o[0])>-1)&&(r=o.shift()),t=o.join(n)}return{key:t,namespaces:i(r)?[r]:r}}translate(t,e,s){let n="object"==typeof e?{...e}:e;if("object"!=typeof n&&this.options.overloadTranslationOptionHandler&&(n=this.options.overloadTranslationOptionHandler(arguments)),"object"==typeof n&&(n={...n}),n||(n={}),null==t)return"";"function"==typeof t&&(t=j(t,{...this.options,...n})),Array.isArray(t)||(t=[String(t)]),t=t.map((t=>"function"==typeof t?j(t,{...this.options,...n}):String(t)));const r=void 0!==n.returnDetails?n.returnDetails:this.options.returnDetails,o=void 0!==n.keySeparator?n.keySeparator:this.options.keySeparator,{key:a,namespaces:h}=this.extractFromKey(t[t.length-1],n),l=h[h.length-1];let c=void 0!==n.nsSeparator?n.nsSeparator:this.options.nsSeparator;void 0===c&&(c=":");const u=n.lng||this.language,d=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if("cimode"===u?.toLowerCase())return d?r?{res:`${l}${c}${a}`,usedKey:a,exactUsedKey:a,usedLng:u,usedNS:l,usedParams:this.getUsedParamsDetails(n)}:`${l}${c}${a}`:r?{res:a,usedKey:a,exactUsedKey:a,usedLng:u,usedNS:l,usedParams:this.getUsedParamsDetails(n)}:a;const f=this.resolve(t,n);let p=f?.res;const g=f?.usedKey||a,m=f?.exactUsedKey||a,y=void 0!==n.joinArrays?n.joinArrays:this.options.joinArrays,v=!this.i18nFormat||this.i18nFormat.handleAsObject,w=void 0!==n.count&&!i(n.count),b=N.hasDefaultValue(n),S=w?this.pluralResolver.getSuffix(u,n.count,n):"",$=n.ordinal&&w?this.pluralResolver.getSuffix(u,n.count,{ordinal:!1}):"",x=w&&!n.ordinal&&0===n.count,k=x&&n[`defaultValue${this.options.pluralSeparator}zero`]||n[`defaultValue${S}`]||n[`defaultValue${$}`]||n.defaultValue;let C=p;v&&!p&&b&&(C=k);const E=O(C),L=Object.prototype.toString.apply(C);if(!(v&&C&&E&&["[object Number]","[object Function]","[object RegExp]"].indexOf(L)<0)||i(y)&&Array.isArray(C))if(v&&i(y)&&Array.isArray(p))p=p.join(y),p&&(p=this.extendTranslation(p,t,n,s));else{let e=!1,i=!1;!this.isValidLookup(p)&&b&&(e=!0,p=k),this.isValidLookup(p)||(i=!0,p=a);const r=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&i?void 0:p,h=b&&k!==p&&this.options.updateMissing;if(i||e||h){if(this.logger.log(h?"updateKey":"missingKey",u,l,a,h?k:p),o){const t=this.resolve(a,{...n,keySeparator:!1});t&&t.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let t=[];const e=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if("fallback"===this.options.saveMissingTo&&e&&e[0])for(let i=0;i<e.length;i++)t.push(e[i]);else"all"===this.options.saveMissingTo?t=this.languageUtils.toResolveHierarchy(n.lng||this.language):t.push(n.lng||this.language);const i=(t,e,i)=>{const s=b&&i!==p?i:r;this.options.missingKeyHandler?this.options.missingKeyHandler(t,l,e,s,h,n):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(t,l,e,s,h,n),this.emit("missingKey",t,l,e,p)};this.options.saveMissing&&(this.options.saveMissingPlurals&&w?t.forEach((t=>{const e=this.pluralResolver.getSuffixes(t,n);x&&n[`defaultValue${this.options.pluralSeparator}zero`]&&e.indexOf(`${this.options.pluralSeparator}zero`)<0&&e.push(`${this.options.pluralSeparator}zero`),e.forEach((e=>{i([t],a+e,n[`defaultValue${e}`]||k)}))})):i(t,a,k))}p=this.extendTranslation(p,t,n,f,s),i&&p===a&&this.options.appendNamespaceToMissingKey&&(p=`${l}${c}${a}`),(i||e)&&this.options.parseMissingKeyHandler&&(p=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}${c}${a}`:a,e?p:void 0,n))}else{if(!n.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const t=this.options.returnedObjectHandler?this.options.returnedObjectHandler(g,C,{...n,ns:h}):`key '${a} (${this.language})' returned an object instead of string.`;return r?(f.res=t,f.usedParams=this.getUsedParamsDetails(n),f):t}if(o){const t=Array.isArray(C),e=t?[]:{},i=t?m:g;for(const t in C)if(Object.prototype.hasOwnProperty.call(C,t)){const s=`${i}${o}${t}`;e[t]=this.translate(s,b&&!p?{...n,defaultValue:O(k)?k[t]:void 0,joinArrays:!1,ns:h}:{...n,joinArrays:!1,ns:h}),e[t]===s&&(e[t]=C[t])}p=e}}return r?(f.res=p,f.usedParams=this.getUsedParamsDetails(n),f):p}extendTranslation(t,e,s,n,r){if(this.i18nFormat?.parse)t=this.i18nFormat.parse(t,{...this.options.interpolation.defaultVariables,...s},s.lng||this.language||n.usedLng,n.usedNS,n.usedKey,{resolved:n});else if(!s.skipInterpolation){s.interpolation&&this.interpolator.init({...s,interpolation:{...this.options.interpolation,...s.interpolation}});const o=i(t)&&(void 0!==s?.interpolation?.skipOnVariables?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let a;if(o){const e=t.match(this.interpolator.nestingRegexp);a=e&&e.length}let h=s.replace&&!i(s.replace)?s.replace:s;if(this.options.interpolation.defaultVariables&&(h={...this.options.interpolation.defaultVariables,...h}),t=this.interpolator.interpolate(t,h,s.lng||this.language||n.usedLng,s),o){const e=t.match(this.interpolator.nestingRegexp);a<(e&&e.length)&&(s.nest=!1)}!s.lng&&n&&n.res&&(s.lng=this.language||n.usedLng),!1!==s.nest&&(t=this.interpolator.nest(t,((...t)=>r?.[0]!==t[0]||s.context?this.translate(...t,e):(this.logger.warn(`It seems you are nesting recursively key: ${t[0]} in key: ${e[0]}`),null)),s)),s.interpolation&&this.interpolator.reset()}const o=s.postProcess||this.options.postProcess,a=i(o)?[o]:o;return null!=t&&a?.length&&!1!==s.applyPostProcessor&&(t=k.handle(a,t,e,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...n,usedParams:this.getUsedParamsDetails(s)},...s}:s,this)),t}resolve(t,e={}){let s,n,r,o,a;return i(t)&&(t=[t]),Array.isArray(t)&&(t=t.map((t=>"function"==typeof t?j(t,{...this.options,...e}):t))),t.forEach((t=>{if(this.isValidLookup(s))return;const h=this.extractFromKey(t,e),l=h.key;n=l;let c=h.namespaces;this.options.fallbackNS&&(c=c.concat(this.options.fallbackNS));const u=void 0!==e.count&&!i(e.count),d=u&&!e.ordinal&&0===e.count,f=void 0!==e.context&&(i(e.context)||"number"==typeof e.context)&&""!==e.context,p=e.lngs?e.lngs:this.languageUtils.toResolveHierarchy(e.lng||this.language,e.fallbackLng);c.forEach((t=>{this.isValidLookup(s)||(a=t,E[`${p[0]}-${t}`]||!this.utils?.hasLoadedNamespace||this.utils?.hasLoadedNamespace(a)||(E[`${p[0]}-${t}`]=!0,this.logger.warn(`key "${n}" for languages "${p.join(", ")}" won't get resolved as namespace "${a}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),p.forEach((i=>{if(this.isValidLookup(s))return;o=i;const n=[l];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(n,l,i,t,e);else{let t;u&&(t=this.pluralResolver.getSuffix(i,e.count,e));const s=`${this.options.pluralSeparator}zero`,r=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(u&&(e.ordinal&&0===t.indexOf(r)&&n.push(l+t.replace(r,this.options.pluralSeparator)),n.push(l+t),d&&n.push(l+s)),f){const i=`${l}${this.options.contextSeparator||"_"}${e.context}`;n.push(i),u&&(e.ordinal&&0===t.indexOf(r)&&n.push(i+t.replace(r,this.options.pluralSeparator)),n.push(i+t),d&&n.push(i+s))}}let a;for(;a=n.pop();)this.isValidLookup(s)||(r=a,s=this.getResource(i,t,a,e))})))}))})),{res:s,usedKey:n,exactUsedKey:r,usedLng:o,usedNS:a}}isValidLookup(t){return!(void 0===t||!this.options.returnNull&&null===t||!this.options.returnEmptyString&&""===t)}getResource(t,e,i,s={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(t,e,i,s):this.resourceStore.getResource(t,e,i,s)}getUsedParamsDetails(t={}){const e=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],s=t.replace&&!i(t.replace);let n=s?t.replace:t;if(s&&void 0!==t.count&&(n.count=t.count),this.options.interpolation.defaultVariables&&(n={...this.options.interpolation.defaultVariables,...n}),!s){n={...n};for(const t of e)delete n[t]}return n}static hasDefaultValue(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e)&&"defaultValue"===e.substring(0,12)&&void 0!==t[e])return!0;return!1}}class L{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=S.create("languageUtils")}getScriptPartFromCode(t){if(!(t=v(t))||t.indexOf("-")<0)return null;const e=t.split("-");return 2===e.length?null:(e.pop(),"x"===e[e.length-1].toLowerCase()?null:this.formatLanguageCode(e.join("-")))}getLanguagePartFromCode(t){if(!(t=v(t))||t.indexOf("-")<0)return t;const e=t.split("-");return this.formatLanguageCode(e[0])}formatLanguageCode(t){if(i(t)&&t.indexOf("-")>-1){let e;try{e=Intl.getCanonicalLocales(t)[0]}catch(t){}return e&&this.options.lowerCaseLng&&(e=e.toLowerCase()),e||(this.options.lowerCaseLng?t.toLowerCase():t)}return this.options.cleanCode||this.options.lowerCaseLng?t.toLowerCase():t}isSupportedCode(t){return("languageOnly"===this.options.load||this.options.nonExplicitSupportedLngs)&&(t=this.getLanguagePartFromCode(t)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(t)>-1}getBestMatchFromCodes(t){if(!t)return null;let e;return t.forEach((t=>{if(e)return;const i=this.formatLanguageCode(t);this.options.supportedLngs&&!this.isSupportedCode(i)||(e=i)})),!e&&this.options.supportedLngs&&t.forEach((t=>{if(e)return;const i=this.getScriptPartFromCode(t);if(this.isSupportedCode(i))return e=i;const s=this.getLanguagePartFromCode(t);if(this.isSupportedCode(s))return e=s;e=this.options.supportedLngs.find((t=>t===s?t:t.indexOf("-")<0&&s.indexOf("-")<0?void 0:t.indexOf("-")>0&&s.indexOf("-")<0&&t.substring(0,t.indexOf("-"))===s||0===t.indexOf(s)&&s.length>1?t:void 0))})),e||(e=this.getFallbackCodes(this.options.fallbackLng)[0]),e}getFallbackCodes(t,e){if(!t)return[];if("function"==typeof t&&(t=t(e)),i(t)&&(t=[t]),Array.isArray(t))return t;if(!e)return t.default||[];let s=t[e];return s||(s=t[this.getScriptPartFromCode(e)]),s||(s=t[this.formatLanguageCode(e)]),s||(s=t[this.getLanguagePartFromCode(e)]),s||(s=t.default),s||[]}toResolveHierarchy(t,e){const s=this.getFallbackCodes((!1===e?[]:e)||this.options.fallbackLng||[],t),n=[],r=t=>{t&&(this.isSupportedCode(t)?n.push(t):this.logger.warn(`rejecting language code not found in supportedLngs: ${t}`))};return i(t)&&(t.indexOf("-")>-1||t.indexOf("_")>-1)?("languageOnly"!==this.options.load&&r(this.formatLanguageCode(t)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&r(this.getScriptPartFromCode(t)),"currentOnly"!==this.options.load&&r(this.getLanguagePartFromCode(t))):i(t)&&r(this.formatLanguageCode(t)),s.forEach((t=>{n.indexOf(t)<0&&r(this.formatLanguageCode(t))})),n}}const M={zero:0,one:1,two:2,few:3,many:4,other:5},P={select:t=>1===t?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class z{constructor(t,e={}){this.languageUtils=t,this.options=e,this.logger=S.create("pluralResolver"),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(t,e={}){const i=v("dev"===t?"en":t),s=e.ordinal?"ordinal":"cardinal",n=JSON.stringify({cleanedCode:i,type:s});if(n in this.pluralRulesCache)return this.pluralRulesCache[n];let r;try{r=new Intl.PluralRules(i,{type:s})}catch(i){if("undefined"==typeof Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),P;if(!t.match(/-|_/))return P;const s=this.languageUtils.getLanguagePartFromCode(t);r=this.getRule(s,e)}return this.pluralRulesCache[n]=r,r}needsPlural(t,e={}){let i=this.getRule(t,e);return i||(i=this.getRule("dev",e)),i?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(t,e,i={}){return this.getSuffixes(t,i).map((t=>`${e}${t}`))}getSuffixes(t,e={}){let i=this.getRule(t,e);return i||(i=this.getRule("dev",e)),i?i.resolvedOptions().pluralCategories.sort(((t,e)=>M[t]-M[e])).map((t=>`${this.options.prepend}${e.ordinal?`ordinal${this.options.prepend}`:""}${t}`)):[]}getSuffix(t,e,i={}){const s=this.getRule(t,i);return s?`${this.options.prepend}${i.ordinal?`ordinal${this.options.prepend}`:""}${s.select(e)}`:(this.logger.warn(`no plural rule found for: ${t}`),this.getSuffix("dev",e,i))}}const A=(t,e,s,n=".",r=!0)=>{let o=((t,e,i)=>{const s=c(t,i);return void 0!==s?s:c(e,i)})(t,e,s);return!o&&r&&i(s)&&(o=y(t,s,n),void 0===o&&(o=y(e,s,n))),o},R=t=>t.replace(/\$/g,"$$$$");class T{constructor(t={}){this.logger=S.create("interpolator"),this.options=t,this.format=t?.interpolation?.format||(t=>t),this.init(t)}init(t={}){t.interpolation||(t.interpolation={escapeValue:!0});const{escape:e,escapeValue:i,useRawValueToEscape:s,prefix:n,prefixEscaped:r,suffix:o,suffixEscaped:a,formatSeparator:h,unescapeSuffix:l,unescapePrefix:c,nestingPrefix:u,nestingPrefixEscaped:f,nestingSuffix:g,nestingSuffixEscaped:m,nestingOptionsSeparator:y,maxReplaces:v,alwaysFormat:w}=t.interpolation;this.escape=void 0!==e?e:p,this.escapeValue=void 0===i||i,this.useRawValueToEscape=void 0!==s&&s,this.prefix=n?d(n):r||"{{",this.suffix=o?d(o):a||"}}",this.formatSeparator=h||",",this.unescapePrefix=l?"":c||"-",this.unescapeSuffix=this.unescapePrefix?"":l||"",this.nestingPrefix=u?d(u):f||d("$t("),this.nestingSuffix=g?d(g):m||d(")"),this.nestingOptionsSeparator=y||",",this.maxReplaces=v||1e3,this.alwaysFormat=void 0!==w&&w,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const t=(t,e)=>t?.source===e?(t.lastIndex=0,t):new RegExp(e,"g");this.regexp=t(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=t(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=t(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(t,e,s,r){let o,a,h;const l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},c=t=>{if(t.indexOf(this.formatSeparator)<0){const i=A(e,l,t,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(i,void 0,s,{...r,...e,interpolationkey:t}):i}const i=t.split(this.formatSeparator),n=i.shift().trim(),o=i.join(this.formatSeparator).trim();return this.format(A(e,l,n,this.options.keySeparator,this.options.ignoreJSONStructure),o,s,{...r,...e,interpolationkey:n})};this.resetRegExp();const u=r?.missingInterpolationHandler||this.options.missingInterpolationHandler,d=void 0!==r?.interpolation?.skipOnVariables?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:t=>R(t)},{regex:this.regexp,safeValue:t=>R(this.escapeValue?this.escape(t):t)}].forEach((e=>{for(h=0;o=e.regex.exec(t);){const s=o[1].trim();if(a=c(s),void 0===a)if("function"==typeof u){const e=u(t,o,r);a=i(e)?e:""}else if(r&&Object.prototype.hasOwnProperty.call(r,s))a="";else{if(d){a=o[0];continue}this.logger.warn(`missed to pass in variable ${s} for interpolating ${t}`),a=""}else i(a)||this.useRawValueToEscape||(a=n(a));const l=e.safeValue(a);if(t=t.replace(o[0],l),d?(e.regex.lastIndex+=a.length,e.regex.lastIndex-=o[0].length):e.regex.lastIndex=0,h++,h>=this.maxReplaces)break}})),t}nest(t,e,s={}){let r,o,a;const h=(t,e)=>{const i=this.nestingOptionsSeparator;if(t.indexOf(i)<0)return t;const s=t.split(new RegExp(`${d(i)}[ ]*{`));let n=`{${s[1]}`;t=s[0],n=this.interpolate(n,a);const r=n.match(/'/g),o=n.match(/"/g);((r?.length??0)%2==0&&!o||(o?.length??0)%2!=0)&&(n=n.replace(/'/g,'"'));try{a=JSON.parse(n),e&&(a={...e,...a})}catch(e){return this.logger.warn(`failed parsing options string in nesting for key ${t}`,e),`${t}${i}${n}`}return a.defaultValue&&a.defaultValue.indexOf(this.prefix)>-1&&delete a.defaultValue,t};for(;r=this.nestingRegexp.exec(t);){let l=[];a={...s},a=a.replace&&!i(a.replace)?a.replace:a,a.applyPostProcessor=!1,delete a.defaultValue;const c=/{.*}/.test(r[1])?r[1].lastIndexOf("}")+1:r[1].indexOf(this.formatSeparator);if(-1!==c&&(l=r[1].slice(c).split(this.formatSeparator).map((t=>t.trim())).filter(Boolean),r[1]=r[1].slice(0,c)),o=e(h.call(this,r[1].trim(),a),a),o&&r[0]===t&&!i(o))return o;i(o)||(o=n(o)),o||(this.logger.warn(`missed to resolve ${r[1]} for nesting ${t}`),o=""),l.length&&(o=l.reduce(((t,e)=>this.format(t,e,s.lng,{...s,interpolationkey:r[1].trim()})),o.trim())),t=t.replace(r[0],o),this.regexp.lastIndex=0}return t}}const I=t=>{const e={};return(i,s,n)=>{let r=n;n&&n.interpolationkey&&n.formatParams&&n.formatParams[n.interpolationkey]&&n[n.interpolationkey]&&(r={...r,[n.interpolationkey]:void 0});const o=s+JSON.stringify(r);let a=e[o];return a||(a=t(v(s),n),e[o]=a),a(i)}},F=t=>(e,i,s)=>t(v(i),s)(e);class V{constructor(t={}){this.logger=S.create("formatter"),this.options=t,this.init(t)}init(t,e={interpolation:{}}){this.formatSeparator=e.interpolation.formatSeparator||",";const i=e.cacheInBuiltFormats?I:F;this.formats={number:i(((t,e)=>{const i=new Intl.NumberFormat(t,{...e});return t=>i.format(t)})),currency:i(((t,e)=>{const i=new Intl.NumberFormat(t,{...e,style:"currency"});return t=>i.format(t)})),datetime:i(((t,e)=>{const i=new Intl.DateTimeFormat(t,{...e});return t=>i.format(t)})),relativetime:i(((t,e)=>{const i=new Intl.RelativeTimeFormat(t,{...e});return t=>i.format(t,e.range||"day")})),list:i(((t,e)=>{const i=new Intl.ListFormat(t,{...e});return t=>i.format(t)}))}}add(t,e){this.formats[t.toLowerCase().trim()]=e}addCached(t,e){this.formats[t.toLowerCase().trim()]=I(e)}format(t,e,i,s={}){const n=e.split(this.formatSeparator);if(n.length>1&&n[0].indexOf("(")>1&&n[0].indexOf(")")<0&&n.find((t=>t.indexOf(")")>-1))){const t=n.findIndex((t=>t.indexOf(")")>-1));n[0]=[n[0],...n.splice(1,t)].join(this.formatSeparator)}return n.reduce(((t,e)=>{const{formatName:n,formatOptions:r}=(t=>{let e=t.toLowerCase().trim();const i={};if(t.indexOf("(")>-1){const s=t.split("(");e=s[0].toLowerCase().trim();const n=s[1].substring(0,s[1].length-1);"currency"===e&&n.indexOf(":")<0?i.currency||(i.currency=n.trim()):"relativetime"===e&&n.indexOf(":")<0?i.range||(i.range=n.trim()):n.split(";").forEach((t=>{if(t){const[e,...s]=t.split(":"),n=s.join(":").trim().replace(/^'+|'+$/g,""),r=e.trim();i[r]||(i[r]=n),"false"===n&&(i[r]=!1),"true"===n&&(i[r]=!0),isNaN(n)||(i[r]=parseInt(n,10))}}))}return{formatName:e,formatOptions:i}})(e);if(this.formats[n]){let e=t;try{const o=s?.formatParams?.[s.interpolationkey]||{};e=this.formats[n](t,o.locale||o.lng||s.locale||s.lng||i,{...r,...s,...o})}catch(t){this.logger.warn(t)}return e}return this.logger.warn(`there was no format function for ${n}`),t}),t)}}class D extends ${constructor(t,e,i,s={}){super(),this.backend=t,this.store=e,this.services=i,this.languageUtils=i.languageUtils,this.options=s,this.logger=S.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=s.maxParallelReads||10,this.readingCalls=0,this.maxRetries=s.maxRetries>=0?s.maxRetries:5,this.retryTimeout=s.retryTimeout>=1?s.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(i,s.backend,s)}queueLoad(t,e,i,s){const n={},r={},o={},a={};return t.forEach((t=>{let s=!0;e.forEach((e=>{const o=`${t}|${e}`;!i.reload&&this.store.hasResourceBundle(t,e)?this.state[o]=2:this.state[o]<0||(1===this.state[o]?void 0===r[o]&&(r[o]=!0):(this.state[o]=1,s=!1,void 0===r[o]&&(r[o]=!0),void 0===n[o]&&(n[o]=!0),void 0===a[e]&&(a[e]=!0)))})),s||(o[t]=!0)})),(Object.keys(n).length||Object.keys(r).length)&&this.queue.push({pending:r,pendingCount:Object.keys(r).length,loaded:{},errors:[],callback:s}),{toLoad:Object.keys(n),pending:Object.keys(r),toLoadLanguages:Object.keys(o),toLoadNamespaces:Object.keys(a)}}loaded(t,e,i){const s=t.split("|"),n=s[0],r=s[1];e&&this.emit("failedLoading",n,r,e),!e&&i&&this.store.addResourceBundle(n,r,i,void 0,void 0,{skipCopy:!0}),this.state[t]=e?-1:2,e&&i&&(this.state[t]=0);const o={};this.queue.forEach((i=>{((t,e,i)=>{const{obj:s,k:n}=h(t,e,Object);s[n]=s[n]||[],s[n].push(i)})(i.loaded,[n],r),((t,e)=>{void 0!==t.pending[e]&&(delete t.pending[e],t.pendingCount--)})(i,t),e&&i.errors.push(e),0!==i.pendingCount||i.done||(Object.keys(i.loaded).forEach((t=>{o[t]||(o[t]={});const e=i.loaded[t];e.length&&e.forEach((e=>{void 0===o[t][e]&&(o[t][e]=!0)}))})),i.done=!0,i.errors.length?i.callback(i.errors):i.callback())})),this.emit("loaded",o),this.queue=this.queue.filter((t=>!t.done))}read(t,e,i,s=0,n=this.retryTimeout,r){if(!t.length)return r(null,{});if(this.readingCalls>=this.maxParallelReads)return void this.waitingReads.push({lng:t,ns:e,fcName:i,tried:s,wait:n,callback:r});this.readingCalls++;const o=(o,a)=>{if(this.readingCalls--,this.waitingReads.length>0){const t=this.waitingReads.shift();this.read(t.lng,t.ns,t.fcName,t.tried,t.wait,t.callback)}o&&a&&s<this.maxRetries?setTimeout((()=>{this.read.call(this,t,e,i,s+1,2*n,r)}),n):r(o,a)},a=this.backend[i].bind(this.backend);if(2!==a.length)return a(t,e,o);try{const i=a(t,e);i&&"function"==typeof i.then?i.then((t=>o(null,t))).catch(o):o(null,i)}catch(t){o(t)}}prepareLoading(t,e,s={},n){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),n&&n();i(t)&&(t=this.languageUtils.toResolveHierarchy(t)),i(e)&&(e=[e]);const r=this.queueLoad(t,e,s,n);if(!r.toLoad.length)return r.pending.length||n(),null;r.toLoad.forEach((t=>{this.loadOne(t)}))}load(t,e,i){this.prepareLoading(t,e,{},i)}reload(t,e,i){this.prepareLoading(t,e,{reload:!0},i)}loadOne(t,e=""){const i=t.split("|"),s=i[0],n=i[1];this.read(s,n,"read",void 0,void 0,((i,r)=>{i&&this.logger.warn(`${e}loading namespace ${n} for language ${s} failed`,i),!i&&r&&this.logger.log(`${e}loaded namespace ${n} for language ${s}`,r),this.loaded(t,i,r)}))}saveMissing(t,e,i,s,n,r={},o=()=>{}){if(!this.services?.utils?.hasLoadedNamespace||this.services?.utils?.hasLoadedNamespace(e)){if(null!=i&&""!==i){if(this.backend?.create){const a={...r,isUpdate:n},h=this.backend.create.bind(this.backend);if(h.length<6)try{let n;n=5===h.length?h(t,e,i,s,a):h(t,e,i,s),n&&"function"==typeof n.then?n.then((t=>o(null,t))).catch(o):o(null,n)}catch(t){o(t)}else h(t,e,i,s,o,a)}t&&t[0]&&this.store.addResource(t[0],e,i,s)}}else this.logger.warn(`did not save key "${i}" as the namespace "${e}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")}}const K=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:t=>{let e={};if("object"==typeof t[1]&&(e=t[1]),i(t[1])&&(e.defaultValue=t[1]),i(t[2])&&(e.tDescription=t[2]),"object"==typeof t[2]||"object"==typeof t[3]){const i=t[3]||t[2];Object.keys(i).forEach((t=>{e[t]=i[t]}))}return e},interpolation:{escapeValue:!0,format:t=>t,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),B=t=>(i(t.ns)&&(t.ns=[t.ns]),i(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),i(t.fallbackNS)&&(t.fallbackNS=[t.fallbackNS]),t.supportedLngs?.indexOf?.("cimode")<0&&(t.supportedLngs=t.supportedLngs.concat(["cimode"])),"boolean"==typeof t.initImmediate&&(t.initAsync=t.initImmediate),t),_=()=>{},U="__i18next_supportNoticeShown";class H extends ${constructor(t={},e){var i;if(super(),this.options=B(t),this.services={},this.logger=S,this.modules={external:[]},i=this,Object.getOwnPropertyNames(Object.getPrototypeOf(i)).forEach((t=>{"function"==typeof i[t]&&(i[t]=i[t].bind(i))})),e&&!this.isInitialized&&!t.isClone){if(!this.options.initAsync)return this.init(t,e),this;setTimeout((()=>{this.init(t,e)}),0)}}init(t={},e){this.isInitializing=!0,"function"==typeof t&&(e=t,t={}),null==t.defaultNS&&t.ns&&(i(t.ns)?t.defaultNS=t.ns:t.ns.indexOf("translation")<0&&(t.defaultNS=t.ns[0]));const n=K();var r;this.options={...n,...this.options,...B(t)},this.options.interpolation={...n.interpolation,...this.options.interpolation},void 0!==t.keySeparator&&(this.options.userDefinedKeySeparator=t.keySeparator),void 0!==t.nsSeparator&&(this.options.userDefinedNsSeparator=t.nsSeparator),"function"!=typeof this.options.overloadTranslationOptionHandler&&(this.options.overloadTranslationOptionHandler=n.overloadTranslationOptionHandler),!1===this.options.showSupportNotice||(r=this,r?.modules?.backend?.name?.indexOf("Locize")>0||r?.modules?.backend?.constructor?.name?.indexOf("Locize")>0||r?.options?.backend?.backends&&r.options.backend.backends.some((t=>t?.name?.indexOf("Locize")>0||t?.constructor?.name?.indexOf("Locize")>0))||r?.options?.backend?.projectId||r?.options?.backend?.backendOptions&&r.options.backend.backendOptions.some((t=>t?.projectId)))||"undefined"!=typeof globalThis&&globalThis[U]||"undefined"!=typeof process&&process.env&&process.env.I18NEXT_NO_SUPPORT_NOTICE||"undefined"!=typeof process&&process.env||("undefined"!=typeof console&&void 0!==console.info&&console.info("🌐 i18next is made possible by our own product, Locize — consider powering your project with managed localization (AI, CDN, integrations): https://locize.com 💙"),"undefined"!=typeof globalThis&&(globalThis[U]=!0));const o=t=>t?"function"==typeof t?new t:t:null;if(!this.options.isClone){let t;S.init(this.modules.logger?o(this.modules.logger):null,this.options),t=this.modules.formatter?this.modules.formatter:V;const e=new L(this.options);this.store=new x(this.options.resources,this.options);const i=this.services;i.logger=S,i.resourceStore=this.store,i.languageUtils=e,i.pluralResolver=new z(e,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==n.interpolation.format&&this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),!t||this.options.interpolation.format&&this.options.interpolation.format!==n.interpolation.format||(i.formatter=o(t),i.formatter.init&&i.formatter.init(i,this.options),this.options.interpolation.format=i.formatter.format.bind(i.formatter)),i.interpolator=new T(this.options),i.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},i.backendConnector=new D(o(this.modules.backend),i.resourceStore,i,this.options),i.backendConnector.on("*",((t,...e)=>{this.emit(t,...e)})),this.modules.languageDetector&&(i.languageDetector=o(this.modules.languageDetector),i.languageDetector.init&&i.languageDetector.init(i,this.options.detection,this.options)),this.modules.i18nFormat&&(i.i18nFormat=o(this.modules.i18nFormat),i.i18nFormat.init&&i.i18nFormat.init(this)),this.translator=new N(this.services,this.options),this.translator.on("*",((t,...e)=>{this.emit(t,...e)})),this.modules.external.forEach((t=>{t.init&&t.init(this)}))}if(this.format=this.options.interpolation.format,e||(e=_),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const t=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);t.length>0&&"dev"!==t[0]&&(this.options.lng=t[0])}this.services.languageDetector||this.options.lng||this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach((t=>{this[t]=(...e)=>this.store[t](...e)})),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach((t=>{this[t]=(...e)=>(this.store[t](...e),this)}));const a=s(),h=()=>{const t=(t,i)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),a.resolve(i),e(t,i)};if(this.languages&&!this.isInitialized)return t(null,this.t.bind(this));this.changeLanguage(this.options.lng,t)};return this.options.resources||!this.options.initAsync?h():setTimeout(h,0),a}loadResources(t,e=_){let s=e;const n=i(t)?t:this.language;if("function"==typeof t&&(s=t),!this.options.resources||this.options.partialBundledLanguages){if("cimode"===n?.toLowerCase()&&(!this.options.preload||0===this.options.preload.length))return s();const t=[],e=e=>{e&&"cimode"!==e&&this.services.languageUtils.toResolveHierarchy(e).forEach((e=>{"cimode"!==e&&t.indexOf(e)<0&&t.push(e)}))};n?e(n):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach((t=>e(t))),this.options.preload?.forEach?.((t=>e(t))),this.services.backendConnector.load(t,this.options.ns,(t=>{t||this.resolvedLanguage||!this.language||this.setResolvedLanguage(this.language),s(t)}))}else s(null)}reloadResources(t,e,i){const n=s();return"function"==typeof t&&(i=t,t=void 0),"function"==typeof e&&(i=e,e=void 0),t||(t=this.languages),e||(e=this.options.ns),i||(i=_),this.services.backendConnector.reload(t,e,(t=>{n.resolve(),i(t)})),n}use(t){if(!t)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!t.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return"backend"===t.type&&(this.modules.backend=t),("logger"===t.type||t.log&&t.warn&&t.error)&&(this.modules.logger=t),"languageDetector"===t.type&&(this.modules.languageDetector=t),"i18nFormat"===t.type&&(this.modules.i18nFormat=t),"postProcessor"===t.type&&k.addPostProcessor(t),"formatter"===t.type&&(this.modules.formatter=t),"3rdParty"===t.type&&this.modules.external.push(t),this}setResolvedLanguage(t){if(t&&this.languages&&!(["cimode","dev"].indexOf(t)>-1)){for(let t=0;t<this.languages.length;t++){const e=this.languages[t];if(!(["cimode","dev"].indexOf(e)>-1)&&this.store.hasLanguageSomeTranslations(e)){this.resolvedLanguage=e;break}}!this.resolvedLanguage&&this.languages.indexOf(t)<0&&this.store.hasLanguageSomeTranslations(t)&&(this.resolvedLanguage=t,this.languages.unshift(t))}}changeLanguage(t,e){this.isLanguageChangingTo=t;const n=s();this.emit("languageChanging",t);const r=t=>{this.language=t,this.languages=this.services.languageUtils.toResolveHierarchy(t),this.resolvedLanguage=void 0,this.setResolvedLanguage(t)},o=(i,s)=>{s?this.isLanguageChangingTo===t&&(r(s),this.translator.changeLanguage(s),this.isLanguageChangingTo=void 0,this.emit("languageChanged",s),this.logger.log("languageChanged",s)):this.isLanguageChangingTo=void 0,n.resolve(((...t)=>this.t(...t))),e&&e(i,((...t)=>this.t(...t)))},a=e=>{t||e||!this.services.languageDetector||(e=[]);const s=i(e)?e:e&&e[0],n=this.store.hasLanguageSomeTranslations(s)?s:this.services.languageUtils.getBestMatchFromCodes(i(e)?[e]:e);n&&(this.language||r(n),this.translator.language||this.translator.changeLanguage(n),this.services.languageDetector?.cacheUserLanguage?.(n)),this.loadResources(n,(t=>{o(t,n)}))};return t||!this.services.languageDetector||this.services.languageDetector.async?!t&&this.services.languageDetector&&this.services.languageDetector.async?0===this.services.languageDetector.detect.length?this.services.languageDetector.detect().then(a):this.services.languageDetector.detect(a):a(t):a(this.services.languageDetector.detect()),n}getFixedT(t,e,s){const n=(t,e,...i)=>{let r;r="object"!=typeof e?this.options.overloadTranslationOptionHandler([t,e].concat(i)):{...e},r.lng=r.lng||n.lng,r.lngs=r.lngs||n.lngs,r.ns=r.ns||n.ns,""!==r.keyPrefix&&(r.keyPrefix=r.keyPrefix||s||n.keyPrefix);const o={...this.options,...r};"function"==typeof r.keyPrefix&&(r.keyPrefix=j(r.keyPrefix,o));const a=this.options.keySeparator||".";let h;return r.keyPrefix&&Array.isArray(t)?h=t.map((t=>("function"==typeof t&&(t=j(t,o)),`${r.keyPrefix}${a}${t}`))):("function"==typeof t&&(t=j(t,o)),h=r.keyPrefix?`${r.keyPrefix}${a}${t}`:t),this.t(h,r)};return i(t)?n.lng=t:n.lngs=t,n.ns=e,n.keyPrefix=s,n}t(...t){return this.translator?.translate(...t)}exists(...t){return this.translator?.exists(...t)}setDefaultNamespace(t){this.options.defaultNS=t}hasLoadedNamespace(t,e={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const i=e.lng||this.resolvedLanguage||this.languages[0],s=!!this.options&&this.options.fallbackLng,n=this.languages[this.languages.length-1];if("cimode"===i.toLowerCase())return!0;const r=(t,e)=>{const i=this.services.backendConnector.state[`${t}|${e}`];return-1===i||0===i||2===i};if(e.precheck){const t=e.precheck(this,r);if(void 0!==t)return t}return!(!this.hasResourceBundle(i,t)&&this.services.backendConnector.backend&&(!this.options.resources||this.options.partialBundledLanguages)&&(!r(i,t)||s&&!r(n,t)))}loadNamespaces(t,e){const n=s();return this.options.ns?(i(t)&&(t=[t]),t.forEach((t=>{this.options.ns.indexOf(t)<0&&this.options.ns.push(t)})),this.loadResources((t=>{n.resolve(),e&&e(t)})),n):(e&&e(),Promise.resolve())}loadLanguages(t,e){const n=s();i(t)&&(t=[t]);const r=this.options.preload||[],o=t.filter((t=>r.indexOf(t)<0&&this.services.languageUtils.isSupportedCode(t)));return o.length?(this.options.preload=r.concat(o),this.loadResources((t=>{n.resolve(),e&&e(t)})),n):(e&&e(),Promise.resolve())}dir(t){if(t||(t=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!t)return"rtl";try{const e=new Intl.Locale(t);if(e&&e.getTextInfo){const t=e.getTextInfo();if(t&&t.direction)return t.direction}}catch(t){}const e=this.services?.languageUtils||new L(K());return t.toLowerCase().indexOf("-latn")>1?"ltr":["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"].indexOf(e.getLanguagePartFromCode(t))>-1||t.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(t={},e){const i=new H(t,e);return i.createInstance=H.createInstance,i}cloneInstance(t={},e=_){const i=t.forkResourceStore;i&&delete t.forkResourceStore;const s={...this.options,...t,isClone:!0},n=new H(s);if(void 0===t.debug&&void 0===t.prefix||(n.logger=n.logger.clone(t)),["store","services","language"].forEach((t=>{n[t]=this[t]})),n.services={...this.services},n.services.utils={hasLoadedNamespace:n.hasLoadedNamespace.bind(n)},i){const t=Object.keys(this.store.data).reduce(((t,e)=>(t[e]={...this.store.data[e]},t[e]=Object.keys(t[e]).reduce(((i,s)=>(i[s]={...t[e][s]},i)),t[e]),t)),{});n.store=new x(t,s),n.services.resourceStore=n.store}if(t.interpolation){const e={...K().interpolation,...this.options.interpolation,...t.interpolation},i={...s,interpolation:e};n.services.interpolator=new T(i)}return n.translator=new N(n.services,s),n.translator.on("*",((t,...e)=>{n.emit(t,...e)})),n.init(s,e),n.translator.options=s,n.translator.backendConnector.services.utils={hasLoadedNamespace:n.hasLoadedNamespace.bind(n)},n}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const Y=H.createInstance(),{slice:W,forEach:J}=[],q=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,G={create(t,e,i,s){let n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{path:"/",sameSite:"strict"};i&&(n.expires=new Date,n.expires.setTime(n.expires.getTime()+60*i*1e3)),s&&(n.domain=s),document.cookie=function(t,e){const i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{path:"/"};let s=`${t}=${encodeURIComponent(e)}`;if(i.maxAge>0){const t=i.maxAge-0;if(Number.isNaN(t))throw new Error("maxAge should be a Number");s+=`; Max-Age=${Math.floor(t)}`}if(i.domain){if(!q.test(i.domain))throw new TypeError("option domain is invalid");s+=`; Domain=${i.domain}`}if(i.path){if(!q.test(i.path))throw new TypeError("option path is invalid");s+=`; Path=${i.path}`}if(i.expires){if("function"!=typeof i.expires.toUTCString)throw new TypeError("option expires is invalid");s+=`; Expires=${i.expires.toUTCString()}`}if(i.httpOnly&&(s+="; HttpOnly"),i.secure&&(s+="; Secure"),i.sameSite)switch("string"==typeof i.sameSite?i.sameSite.toLowerCase():i.sameSite){case!0:s+="; SameSite=Strict";break;case"lax":s+="; SameSite=Lax";break;case"strict":s+="; SameSite=Strict";break;case"none":s+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}return i.partitioned&&(s+="; Partitioned"),s}(t,e,n)},read(t){const e=`${t}=`,i=document.cookie.split(";");for(let t=0;t<i.length;t++){let s=i[t];for(;" "===s.charAt(0);)s=s.substring(1,s.length);if(0===s.indexOf(e))return s.substring(e.length,s.length)}return null},remove(t,e){this.create(t,"",-1,e)}};var Q={name:"cookie",lookup(t){let{lookupCookie:e}=t;if(e&&"undefined"!=typeof document)return G.read(e)||void 0},cacheUserLanguage(t,e){let{lookupCookie:i,cookieMinutes:s,cookieDomain:n,cookieOptions:r}=e;i&&"undefined"!=typeof document&&G.create(i,t,s,n,r)}},Z={name:"querystring",lookup(t){let e,{lookupQuerystring:i}=t;if("undefined"!=typeof window){let{search:t}=window.location;!window.location.search&&window.location.hash?.indexOf("?")>-1&&(t=window.location.hash.substring(window.location.hash.indexOf("?")));const s=t.substring(1).split("&");for(let t=0;t<s.length;t++){const n=s[t].indexOf("=");n>0&&s[t].substring(0,n)===i&&(e=s[t].substring(n+1))}}return e}},X={name:"hash",lookup(t){let e,{lookupHash:i,lookupFromHashIndex:s}=t;if("undefined"!=typeof window){const{hash:t}=window.location;if(t&&t.length>2){const n=t.substring(1);if(i){const t=n.split("&");for(let s=0;s<t.length;s++){const n=t[s].indexOf("=");n>0&&t[s].substring(0,n)===i&&(e=t[s].substring(n+1))}}if(e)return e;if(!e&&s>-1){const e=t.match(/\/([a-zA-Z-]*)/g);if(!Array.isArray(e))return;const i="number"==typeof s?s:0;return e[i]?.replace("/","")}}}return e}};let tt=null;const et=()=>{if(null!==tt)return tt;try{if(tt="undefined"!=typeof window&&null!==window.localStorage,!tt)return!1;const t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch(t){tt=!1}return tt};var it={name:"localStorage",lookup(t){let{lookupLocalStorage:e}=t;if(e&&et())return window.localStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupLocalStorage:i}=e;i&&et()&&window.localStorage.setItem(i,t)}};let st=null;const nt=()=>{if(null!==st)return st;try{if(st="undefined"!=typeof window&&null!==window.sessionStorage,!st)return!1;const t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch(t){st=!1}return st};var rt={name:"sessionStorage",lookup(t){let{lookupSessionStorage:e}=t;if(e&&nt())return window.sessionStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupSessionStorage:i}=e;i&&nt()&&window.sessionStorage.setItem(i,t)}},ot={name:"navigator",lookup(t){const e=[];if("undefined"!=typeof navigator){const{languages:t,userLanguage:i,language:s}=navigator;if(t)for(let i=0;i<t.length;i++)e.push(t[i]);i&&e.push(i),s&&e.push(s)}return e.length>0?e:void 0}},at={name:"htmlTag",lookup(t){let e,{htmlTag:i}=t;const s=i||("undefined"!=typeof document?document.documentElement:null);return s&&"function"==typeof s.getAttribute&&(e=s.getAttribute("lang")),e}},ht={name:"path",lookup(t){let{lookupFromPathIndex:e}=t;if("undefined"==typeof window)return;const i=window.location.pathname.match(/\/([a-zA-Z-]*)/g);if(!Array.isArray(i))return;const s="number"==typeof e?e:0;return i[s]?.replace("/","")}},lt={name:"subdomain",lookup(t){let{lookupFromSubdomainIndex:e}=t;const i="number"==typeof e?e+1:1,s="undefined"!=typeof window&&window.location?.hostname?.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i);if(s)return s[i]}};let ct=!1;try{ct=!0}catch(t){}const ut=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];ct||ut.splice(1,1);class dt{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.type="languageDetector",this.detectors={},this.init(t,e)}init(){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.services=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{languageUtils:{}},this.options=function(t){return J.call(W.call(arguments,1),(e=>{if(e)for(const i in e)void 0===t[i]&&(t[i]=e[i])})),t}(t,this.options||{},{order:ut,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:t=>t}),"string"==typeof this.options.convertDetectedLanguage&&this.options.convertDetectedLanguage.indexOf("15897")>-1&&(this.options.convertDetectedLanguage=t=>t.replace("-","_")),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=e,this.addDetector(Q),this.addDetector(Z),this.addDetector(it),this.addDetector(rt),this.addDetector(ot),this.addDetector(at),this.addDetector(ht),this.addDetector(lt),this.addDetector(X)}addDetector(t){return this.detectors[t.name]=t,this}detect(){let t=[];return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.options.order).forEach((e=>{if(this.detectors[e]){let i=this.detectors[e].lookup(this.options);i&&"string"==typeof i&&(i=[i]),i&&(t=t.concat(i))}})),t=t.filter((t=>{return null!=t&&!("string"==typeof(e=t)&&[/<\s*script.*?>/i,/<\s*\/\s*script\s*>/i,/<\s*img.*?on\w+\s*=/i,/<\s*\w+\s*on\w+\s*=.*?>/i,/javascript\s*:/i,/vbscript\s*:/i,/expression\s*\(/i,/eval\s*\(/i,/alert\s*\(/i,/document\.cookie/i,/document\.write\s*\(/i,/window\.location/i,/innerHTML/i].some((t=>t.test(e))));var e})).map((t=>this.options.convertDetectedLanguage(t))),this.services&&this.services.languageUtils&&this.services.languageUtils.getBestMatchFromCodes?t:t.length>0?t[0]:null}cacheUserLanguage(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.options.caches;e&&(this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(t)>-1||e.forEach((e=>{this.detectors[e]&&this.detectors[e].cacheUserLanguage(t,this.options)})))}}dt.type="languageDetector",Y.use(dt).init({fallbackLng:"en",debug:!1,resources:{en:{translation:{}},ja:{translation:{Pay:"支払う","Failed to load Stripe":"ライブラリの読み込みに失敗しました。","Add your payment information":"支払情報を追加","Add card":"カードを追加","Add a card":"カードを追加",Add:"追加","Card information":"カード情報","Card Number":"カード番号","MM / YY":"月 / 年",CVC:"セキュリティコード(CVC)","Country or region":"地域","Postal Code":"郵便番号"}},"pt-BR":{translation:{Pay:"Pagar","Failed to load Stripe":"Falha ao ler Stripe","Add your payment information":"Informações do seu Pagamento","Add card":"Adicionar Cartão","Add a card":"Adicionar um Cartão",Add:"Adicionar","Card information":"Informações do Cartão","Card Number":"Número do Cartão","MM / YY":"MM / AA",CVC:"Número de Segurança(CVC)","Country or region":"País ou região","Postal Code":"Cep"}}}});const ft=Y,pt=(()=>{let t;return(...e)=>{t&&clearTimeout(t),t=setTimeout((()=>{t=0,(t=>{for(let e of t.keys()){const i=t.get(e).filter((t=>{const e=t.deref();return e&&(!("isConnected"in(i=e))||i.isConnected);var i}));t.set(e,i)}})(...e)}),2e3)}})(),gt=t.forceUpdate,mt=t.getRenderingRef,yt=(t,e)=>{const i=t.indexOf(e);i>=0&&(t[i]=t[t.length-1],t.length--)},vt=(t,e)=>{const i=((t,e=(t,e)=>t!==e)=>{const i=()=>{return("function"==typeof(e=t)?e():e)??{};var e},s=i();let n=new Map(Object.entries(s));const r="undefined"!=typeof Proxy,o=r?null:{},a={dispose:[],get:[],set:[],reset:[]},h=new Map,l=()=>{n=new Map(Object.entries(i())),r||g(),a.reset.forEach((t=>t()))},c=t=>(a.get.forEach((e=>e(t))),n.get(t)),u=(t,i)=>{const s=n.get(t);e(i,s,t)&&(n.set(t,i),r||p(t),a.set.forEach((e=>e(t,i,s))))},d=r?new Proxy(s,{get:(t,e)=>c(e),ownKeys:()=>Array.from(n.keys()),getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0}),has:(t,e)=>n.has(e),set:(t,e,i)=>(u(e,i),!0)}):(g(),o),f=(t,e)=>(a[t].push(e),()=>{yt(a[t],e)});function p(t){!r&&o&&(Object.prototype.hasOwnProperty.call(o,t)||Object.defineProperty(o,t,{configurable:!0,enumerable:!0,get:()=>c(t),set(e){u(t,e)}}))}function g(){if(r||!o)return;const t=new Set(n.keys());for(const e of Object.keys(o))t.has(e)||delete o[e];for(const e of t)p(e)}return{state:d,get:c,set:u,on:f,onChange:(t,e)=>{const s=(i,s)=>{i===t&&e(s)},n=()=>{const s=i();e(s[t])},r=f("set",s),o=f("reset",n);return h.set(e,{setHandler:s,resetHandler:n,propName:t}),()=>{r(),o(),h.delete(e)}},use:(...t)=>{const e=t.reduce(((t,e)=>(e.set&&t.push(f("set",e.set)),e.get&&t.push(f("get",e.get)),e.reset&&t.push(f("reset",e.reset)),e.dispose&&t.push(f("dispose",e.dispose)),t)),[]);return()=>e.forEach((t=>t()))},dispose:()=>{a.dispose.forEach((t=>t())),l()},reset:l,forceUpdate:t=>{const e=n.get(t);a.set.forEach((i=>i(t,e,e)))},removeListener:(t,e)=>{const i=h.get(e);i&&i.propName===t&&(yt(a.set,i.setHandler),yt(a.reset,i.resetHandler),h.delete(e))}}})(t,e);return i.use((()=>{if("function"!=typeof mt||"function"!=typeof gt)return{};const t=gt,e=mt,i=new Map;return{dispose:()=>i.clear(),get:t=>{const s=e();s&&((t,e,i)=>{let s=t.get(e);s||(s=[],t.set(e,s)),s.some((t=>t.deref()===i))||s.push(new WeakRef(i))})(i,t,s)},set:e=>{const s=i.get(e);if(s){const n=s.filter((e=>{const i=e.deref();return!!i&&t(i)}));i.set(e,n)}pt(i)},reset:()=>{i.forEach((e=>{e.forEach((e=>{const i=e.deref();i&&t(i)}))})),pt(i)}}})()),i};class wt{constructor(){this.store=vt({loadStripeStatus:"",applicationName:"stripe-pwa-elements",isCheckoutSession:!1}),this.changeListeners=new Map}get state(){return this.store.state}onChange(t,e){const i=this.store.onChange(t,e);return this.changeListeners.has(t)||this.changeListeners.set(t,[]),this.changeListeners.get(t).push(i),i}async initialize(t,i){if(this.store.state.publishableKey=t,this.store.state.isCheckoutSession=!1,null!=(null==i?void 0:i.stripeAccount)&&""!==(null==i?void 0:i.stripeAccount)&&(this.store.state.stripeAccount=i.stripeAccount),null!=(null==i?void 0:i.applicationName)&&""!==(null==i?void 0:i.applicationName)&&(this.store.state.applicationName=i.applicationName),!this.store.state.stripe||this.store.state.publishableKey!==t||this.store.state.stripeAccount!==(null==i?void 0:i.stripeAccount)||this.store.state.isCheckoutSession){this.store.state.loadStripeStatus="loading";try{const s=await e(t,{stripeAccount:null==i?void 0:i.stripeAccount});s.registerAppInfo({name:this.store.state.applicationName}),this.store.state.stripe=s,this.store.state.elements=s.elements(),this.store.state.checkout=void 0,this.store.state.loadStripeStatus="success"}catch(t){console.error("Failed to load Stripe.js:",t),this.store.state.loadStripeStatus="failure"}}}async initializeWithCheckoutSession(t,i,s){this.store.state.publishableKey=t,this.store.state.isCheckoutSession=!0,null!=(null==s?void 0:s.stripeAccount)&&""!==(null==s?void 0:s.stripeAccount)&&(this.store.state.stripeAccount=s.stripeAccount),null!=(null==s?void 0:s.applicationName)&&""!==(null==s?void 0:s.applicationName)&&(this.store.state.applicationName=s.applicationName),this.store.state.loadStripeStatus="loading";try{const n=await e(t,{stripeAccount:null==s?void 0:s.stripeAccount});n.registerAppInfo({name:this.store.state.applicationName}),this.store.state.stripe=n;const r=n.initCheckoutElementsSdk({clientSecret:i,elementsOptions:null==s?void 0:s.elementsOptions});this.store.state.checkout=r,this.store.state.elements=void 0,this.store.state.loadStripeStatus="success"}catch(t){console.error("Failed to initialize Stripe Checkout:",t),this.store.state.loadStripeStatus="failure"}}getStripe(){return this.store.state.stripe}getElements(){return this.store.state.elements}getCheckout(){return this.store.state.checkout}reset(){this.store.reset()}dispose(){this.changeListeners.forEach((t=>{t.forEach((t=>t()))})),this.changeListeners.clear(),this.store.dispose()}}function bt(t,e,i=5e3){return new Promise(((s,n)=>{const r=t.querySelector(e);if(null!=r)return s(r);const o=setTimeout((()=>{a.disconnect(),n(new Error(`Element "${e}" not found within ${i}ms`))}),i),a=new MutationObserver((()=>{const i=t.querySelector(e);null!=i&&(clearTimeout(o),a.disconnect(),s(i))}));a.observe(t,{childList:!0,subtree:!0})}))}new wt;class St{constructor(t){this.stripeService=t,this.store=vt({errorMessage:"",errorSource:void 0})}getState(){return this.store.state}async initialize(t){const e=this.stripeService.getElements();if(null==e)throw new Error("StripeService not initialized. Call StripeService.initialize() first.");null!=this.cardElements&&this.unmount();const i=e.create("cardNumber",{placeholder:ft.t("Card Number")}),s=await bt(t,"#card-number");i.mount(s),i.on("change",this.handleCardError("cardNumber"));const n=e.create("cardExpiry"),r=await bt(t,"#card-expiry");n.mount(r),n.on("change",this.handleCardError("cardExpiry"));const o=e.create("cardCvc"),a=await bt(t,"#card-cvc");return o.mount(a),o.on("change",this.handleCardError("cardCvc")),this.cardElements={cardNumber:i,cardExpiry:n,cardCVC:o},this.cardElements}getElements(){return this.cardElements}setError(t){this.store.set("errorMessage",t)}clearError(){this.store.set("errorMessage",""),this.store.set("errorSource",void 0)}unmount(){var t,e,i;null!=this.cardElements&&(null===(t=this.cardElements.cardNumber)||void 0===t||t.unmount(),null===(e=this.cardElements.cardExpiry)||void 0===e||e.unmount(),null===(i=this.cardElements.cardCVC)||void 0===i||i.unmount(),this.cardElements=void 0)}handleCardError(t){return({error:e})=>{if(e)return this.store.set("errorMessage",e.message),void this.store.set("errorSource",t);this.store.state.errorSource===t&&(this.store.set("errorMessage",""),this.store.set("errorSource",void 0))}}}class $t{constructor(t){this.stripeService=t,this.store=vt({errorMessage:""})}getState(){return this.store.state}async initialize(t,e){const i=this.stripeService.state.isCheckoutSession;if(null!=this.paymentElement&&this.unmount(),i){const t=this.stripeService.getCheckout();if(null==t)throw new Error("StripeService not initialized with Checkout Session. Call StripeService.initializeWithCheckoutSession() first.");this.paymentElement=t.createPaymentElement(e)}else{const t=this.stripeService.getElements();if(null==t)throw new Error("StripeService not initialized. Call StripeService.initialize() first.");this.paymentElement=t.create("payment",e||{})}const s=await bt(t,"#payment-element");return this.paymentElement.mount(s),this.paymentElement}getElement(){return this.paymentElement}setError(t){this.store.set("errorMessage",t)}clearError(){this.store.set("errorMessage","")}unmount(){null!=this.paymentElement&&(this.paymentElement.unmount(),this.paymentElement=void 0)}}class xt{constructor(t){this.stripeService=t,this.store=vt({errorMessage:"",isComplete:!1})}getState(){return this.store.state}async initialize(t,e){const i=this.stripeService.getElements();if(null==i)throw new Error("StripeService not initialized. Call StripeService.initialize() first.");null!=this.addressElement&&this.unmount(),this.addressElement=i.create("address",e||{mode:"billing"});const s=await bt(t,"#address-element");return this.addressElement.mount(s),this.addressElement.on("change",(t=>{this.store.set("errorMessage",""),this.store.set("isComplete",t.complete)})),this.addressElement}getElement(){return this.addressElement}setError(t){this.store.set("errorMessage",t)}clearError(){this.store.set("errorMessage","")}unmount(){null!=this.addressElement&&(this.addressElement.unmount(),this.addressElement=void 0)}}class kt{constructor(t){this.stripeService=t,this.store=vt({errorMessage:"",email:void 0})}getState(){return this.store.state}onChange(t,e){return this.store.onChange(t,e)}async initialize(t,e){const i=this.stripeService.getElements();if(null==i)throw new Error("StripeService not initialized. Call StripeService.initialize() first.");null!=this.linkAuthenticationElement&&this.unmount();const s=i.create("linkAuthentication",e),n=await bt(t,"#link-authentication-element");return s.mount(n),s.on("change",(t=>{var e;this.store.set("email",null===(e=t.value)||void 0===e?void 0:e.email)})),this.linkAuthenticationElement=s,this.linkAuthenticationElement}getElement(){return this.linkAuthenticationElement}setError(t){this.store.set("errorMessage",t)}clearError(){this.store.set("errorMessage","")}unmount(){null!=this.linkAuthenticationElement&&(this.linkAuthenticationElement.unmount(),this.linkAuthenticationElement=void 0)}}class Ct{constructor(t){this.stripeService=t,this.store=vt({errorMessage:"",selectedCurrency:void 0})}getState(){return this.store.state}async initialize(t,e){const i=this.stripeService.getElements();if(null==i)throw new Error("StripeService not initialized. Call StripeService.initialize() first.");null!=this.currencySelectorElement&&this.unmount();const s=await bt(t,"#currency-selector");return this.currencySelectorElement=i.create("currencySelector",e||{}),this.currencySelectorElement.mount(s),this.currencySelectorElement.on("change",(t=>{var e;this.store.set("errorMessage",""),(null===(e=null==t?void 0:t.value)||void 0===e?void 0:e.currency)&&this.store.set("selectedCurrency",t.value.currency)})),this.currencySelectorElement}getElement(){return this.currencySelectorElement}setError(t){this.store.set("errorMessage",t)}clearError(){this.store.set("errorMessage","")}unmount(){null!=this.currencySelectorElement&&(this.currencySelectorElement.unmount(),this.currencySelectorElement=void 0)}}class jt{constructor(t){this.stripeService=t,this.store=vt({errorMessage:"",isReady:!1})}getState(){return this.store.state}async initialize(t,e,i){const s=this.stripeService.getElements();if(null==s)throw new Error("StripeService not initialized. Call StripeService.initialize() first.");null!=this.expressCheckoutElement&&this.unmount();const n=Object.assign({},e);if(n.buttonHeight&&"string"==typeof n.buttonHeight){const t=parseInt(n.buttonHeight.replace("px",""),10);isNaN(t)||(n.buttonHeight=t)}const r=s.create("expressCheckout",n),o=await bt(t,"#express-checkout-element");return null!=(null==i?void 0:i.onConfirm)&&r.on("confirm",i.onConfirm),null!=(null==i?void 0:i.onClick)&&r.on("click",i.onClick),null!=(null==i?void 0:i.onCancel)&&r.on("cancel",i.onCancel),null!=(null==i?void 0:i.onShippingAddressChange)&&r.on("shippingaddresschange",i.onShippingAddressChange),null!=(null==i?void 0:i.onShippingRateChange)&&r.on("shippingratechange",i.onShippingRateChange),r.on("ready",(()=>{this.store.set("isReady",!0)})),r.mount(o),this.expressCheckoutElement=r,this.expressCheckoutElement}getElement(){return this.expressCheckoutElement}update(t){if(null==this.expressCheckoutElement)return void console.warn("Express Checkout Element not initialized. Cannot update options.");const e=Object.assign({},t);if(e.buttonHeight&&"string"==typeof e.buttonHeight){const t=parseInt(e.buttonHeight.replace("px",""),10);isNaN(t)||(e.buttonHeight=t)}this.expressCheckoutElement.update(e)}setError(t){this.store.set("errorMessage",t)}clearError(){this.store.set("errorMessage","")}unmount(){null!=this.expressCheckoutElement&&(this.expressCheckoutElement.unmount(),this.expressCheckoutElement=void 0,this.store.set("isReady",!1))}}const Et=new class{createStripeService(){return new wt}createCardElementManager(t){return new St(t)}createPaymentElementManager(t){return new $t(t)}createAddressElementManager(t){return new xt(t)}createLinkAuthenticationElementManager(t){return new kt(t)}createCurrencySelectorElementManager(t){return new Ct(t)}createExpressCheckoutElementManager(t){return new jt(t)}};export{ft as i,Et as s}
1
+ import*as t from"@stencil/core/internal/client";import{l as e}from"./index2.js";const i=t=>"string"==typeof t,s=()=>{let t,e;const i=new Promise(((i,s)=>{t=i,e=s}));return i.resolve=t,i.reject=e,i},n=t=>null==t?"":""+t,r=/###/g,o=t=>t&&t.indexOf("###")>-1?t.replace(r,"."):t,a=t=>!t||i(t),h=(t,e,s)=>{const n=i(e)?e.split("."):e;let r=0;for(;r<n.length-1;){if(a(t))return{};const e=o(n[r]);!t[e]&&s&&(t[e]=new s),t=Object.prototype.hasOwnProperty.call(t,e)?t[e]:{},++r}return a(t)?{}:{obj:t,k:o(n[r])}},l=(t,e,i)=>{const{obj:s,k:n}=h(t,e,Object);if(void 0!==s||1===e.length)return void(s[n]=i);let r=e[e.length-1],o=e.slice(0,e.length-1),a=h(t,o,Object);for(;void 0===a.obj&&o.length;)r=`${o[o.length-1]}.${r}`,o=o.slice(0,o.length-1),a=h(t,o,Object),a?.obj&&void 0!==a.obj[`${a.k}.${r}`]&&(a.obj=void 0);a.obj[`${a.k}.${r}`]=i},c=(t,e)=>{const{obj:i,k:s}=h(t,e);if(i&&Object.prototype.hasOwnProperty.call(i,s))return i[s]},u=(t,e,s)=>{for(const n in e)"__proto__"!==n&&"constructor"!==n&&(n in t?i(t[n])||t[n]instanceof String||i(e[n])||e[n]instanceof String?s&&(t[n]=e[n]):u(t[n],e[n],s):t[n]=e[n]);return t},d=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var f={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const p=t=>i(t)?t.replace(/[&<>"'\/]/g,(t=>f[t])):t,g=[" ",",","?","!",";"],m=new class{constructor(t){this.capacity=t,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(t){const e=this.regExpMap.get(t);if(void 0!==e)return e;const i=new RegExp(t);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(t,i),this.regExpQueue.push(t),i}}(20),y=(t,e,i=".")=>{if(!t)return;if(t[e]){if(!Object.prototype.hasOwnProperty.call(t,e))return;return t[e]}const s=e.split(i);let n=t;for(let t=0;t<s.length;){if(!n||"object"!=typeof n)return;let e,r="";for(let o=t;o<s.length;++o)if(o!==t&&(r+=i),r+=s[o],e=n[r],void 0!==e){if(["string","number","boolean"].indexOf(typeof e)>-1&&o<s.length-1)continue;t+=o-t+1;break}n=e}return n},v=t=>t?.replace(/_/g,"-"),w={type:"logger",log(t){this.output("log",t)},warn(t){this.output("warn",t)},error(t){this.output("error",t)},output(t,e){console?.[t]?.apply?.(console,e)}};class b{constructor(t,e={}){this.init(t,e)}init(t,e={}){this.prefix=e.prefix||"i18next:",this.logger=t||w,this.options=e,this.debug=e.debug}log(...t){return this.forward(t,"log","",!0)}warn(...t){return this.forward(t,"warn","",!0)}error(...t){return this.forward(t,"error","")}deprecate(...t){return this.forward(t,"warn","WARNING DEPRECATED: ",!0)}forward(t,e,s,n){return n&&!this.debug?null:(i(t[0])&&(t[0]=`${s}${this.prefix} ${t[0]}`),this.logger[e](t))}create(t){return new b(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return(t=t||this.options).prefix=t.prefix||this.prefix,new b(this.logger,t)}}var S=new b;class ${constructor(){this.observers={}}on(t,e){return t.split(" ").forEach((t=>{this.observers[t]||(this.observers[t]=new Map);const i=this.observers[t].get(e)||0;this.observers[t].set(e,i+1)})),this}off(t,e){this.observers[t]&&(e?this.observers[t].delete(e):delete this.observers[t])}emit(t,...e){this.observers[t]&&Array.from(this.observers[t].entries()).forEach((([t,i])=>{for(let s=0;s<i;s++)t(...e)})),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach((([i,s])=>{for(let n=0;n<s;n++)i.apply(i,[t,...e])}))}}class x extends ${constructor(t,e={ns:["translation"],defaultNS:"translation"}){super(),this.data=t||{},this.options=e,void 0===this.options.keySeparator&&(this.options.keySeparator="."),void 0===this.options.ignoreJSONStructure&&(this.options.ignoreJSONStructure=!0)}addNamespaces(t){this.options.ns.indexOf(t)<0&&this.options.ns.push(t)}removeNamespaces(t){const e=this.options.ns.indexOf(t);e>-1&&this.options.ns.splice(e,1)}getResource(t,e,s,n={}){const r=void 0!==n.keySeparator?n.keySeparator:this.options.keySeparator,o=void 0!==n.ignoreJSONStructure?n.ignoreJSONStructure:this.options.ignoreJSONStructure;let a;t.indexOf(".")>-1?a=t.split("."):(a=[t,e],s&&(Array.isArray(s)?a.push(...s):i(s)&&r?a.push(...s.split(r)):a.push(s)));const h=c(this.data,a);return!h&&!e&&!s&&t.indexOf(".")>-1&&(t=a[0],e=a[1],s=a.slice(2).join(".")),!h&&o&&i(s)?y(this.data?.[t]?.[e],s,r):h}addResource(t,e,i,s,n={silent:!1}){const r=void 0!==n.keySeparator?n.keySeparator:this.options.keySeparator;let o=[t,e];i&&(o=o.concat(r?i.split(r):i)),t.indexOf(".")>-1&&(o=t.split("."),s=e,e=o[1]),this.addNamespaces(e),l(this.data,o,s),n.silent||this.emit("added",t,e,i,s)}addResources(t,e,s,n={silent:!1}){for(const n in s)(i(s[n])||Array.isArray(s[n]))&&this.addResource(t,e,n,s[n],{silent:!0});n.silent||this.emit("added",t,e,s)}addResourceBundle(t,e,i,s,n,r={silent:!1,skipCopy:!1}){let o=[t,e];t.indexOf(".")>-1&&(o=t.split("."),s=i,i=e,e=o[1]),this.addNamespaces(e);let a=c(this.data,o)||{};r.skipCopy||(i=JSON.parse(JSON.stringify(i))),s?u(a,i,n):a={...a,...i},l(this.data,o,a),r.silent||this.emit("added",t,e,i)}removeResourceBundle(t,e){this.hasResourceBundle(t,e)&&delete this.data[t][e],this.removeNamespaces(e),this.emit("removed",t,e)}hasResourceBundle(t,e){return void 0!==this.getResource(t,e)}getResourceBundle(t,e){return e||(e=this.options.defaultNS),this.getResource(t,e)}getDataByLanguage(t){return this.data[t]}hasLanguageSomeTranslations(t){const e=this.getDataByLanguage(t);return!!(e&&Object.keys(e)||[]).find((t=>e[t]&&Object.keys(e[t]).length>0))}toJSON(){return this.data}}var k={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,e,i,s,n){return t.forEach((t=>{e=this.processors[t]?.process(e,i,s,n)??e})),e}};const C=Symbol("i18next/PATH_KEY");function j(t,e){const{[C]:i}=t(function(){const t=[],e=Object.create(null);let i;return e.get=(s,n)=>(i?.revoke?.(),n===C?t:(t.push(n),i=Proxy.revocable(s,e),i.proxy)),Proxy.revocable(Object.create(null),e).proxy}()),s=e?.keySeparator??".",n=e?.nsSeparator??":";if(i.length>1&&n){const t=e?.ns,r=Array.isArray(t)?t:null;if(r&&r.length>1&&r.slice(1).includes(i[0]))return`${i[0]}${n}${i.slice(1).join(s)}`}return i.join(s)}const E={},O=t=>!i(t)&&"boolean"!=typeof t&&"number"!=typeof t;class N extends ${constructor(t,e={}){var i,s;super(),i=t,s=this,["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"].forEach((t=>{i[t]&&(s[t]=i[t])})),this.options=e,void 0===this.options.keySeparator&&(this.options.keySeparator="."),this.logger=S.create("translator")}changeLanguage(t){t&&(this.language=t)}exists(t,e={interpolation:{}}){const i={...e};if(null==t)return!1;const s=this.resolve(t,i);if(void 0===s?.res)return!1;const n=O(s.res);return!1!==i.returnObjects||!n}extractFromKey(t,e){let s=void 0!==e.nsSeparator?e.nsSeparator:this.options.nsSeparator;void 0===s&&(s=":");const n=void 0!==e.keySeparator?e.keySeparator:this.options.keySeparator;let r=e.ns||this.options.defaultNS||[];const o=s&&t.indexOf(s)>-1,a=!(this.options.userDefinedKeySeparator||e.keySeparator||this.options.userDefinedNsSeparator||e.nsSeparator||((t,e,i)=>{e=e||"",i=i||"";const s=g.filter((t=>e.indexOf(t)<0&&i.indexOf(t)<0));if(0===s.length)return!0;const n=m.getRegExp(`(${s.map((t=>"?"===t?"\\?":t)).join("|")})`);let r=!n.test(t);if(!r){const e=t.indexOf(i);e>0&&!n.test(t.substring(0,e))&&(r=!0)}return r})(t,s,n));if(o&&!a){const e=t.match(this.interpolator.nestingRegexp);if(e&&e.length>0)return{key:t,namespaces:i(r)?[r]:r};const o=t.split(s);(s!==n||s===n&&this.options.ns.indexOf(o[0])>-1)&&(r=o.shift()),t=o.join(n)}return{key:t,namespaces:i(r)?[r]:r}}translate(t,e,s){let n="object"==typeof e?{...e}:e;if("object"!=typeof n&&this.options.overloadTranslationOptionHandler&&(n=this.options.overloadTranslationOptionHandler(arguments)),"object"==typeof n&&(n={...n}),n||(n={}),null==t)return"";"function"==typeof t&&(t=j(t,{...this.options,...n})),Array.isArray(t)||(t=[String(t)]),t=t.map((t=>"function"==typeof t?j(t,{...this.options,...n}):String(t)));const r=void 0!==n.returnDetails?n.returnDetails:this.options.returnDetails,o=void 0!==n.keySeparator?n.keySeparator:this.options.keySeparator,{key:a,namespaces:h}=this.extractFromKey(t[t.length-1],n),l=h[h.length-1];let c=void 0!==n.nsSeparator?n.nsSeparator:this.options.nsSeparator;void 0===c&&(c=":");const u=n.lng||this.language,d=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if("cimode"===u?.toLowerCase())return d?r?{res:`${l}${c}${a}`,usedKey:a,exactUsedKey:a,usedLng:u,usedNS:l,usedParams:this.getUsedParamsDetails(n)}:`${l}${c}${a}`:r?{res:a,usedKey:a,exactUsedKey:a,usedLng:u,usedNS:l,usedParams:this.getUsedParamsDetails(n)}:a;const f=this.resolve(t,n);let p=f?.res;const g=f?.usedKey||a,m=f?.exactUsedKey||a,y=void 0!==n.joinArrays?n.joinArrays:this.options.joinArrays,v=!this.i18nFormat||this.i18nFormat.handleAsObject,w=void 0!==n.count&&!i(n.count),b=N.hasDefaultValue(n),S=w?this.pluralResolver.getSuffix(u,n.count,n):"",$=n.ordinal&&w?this.pluralResolver.getSuffix(u,n.count,{ordinal:!1}):"",x=w&&!n.ordinal&&0===n.count,k=x&&n[`defaultValue${this.options.pluralSeparator}zero`]||n[`defaultValue${S}`]||n[`defaultValue${$}`]||n.defaultValue;let C=p;v&&!p&&b&&(C=k);const E=O(C),L=Object.prototype.toString.apply(C);if(!(v&&C&&E&&["[object Number]","[object Function]","[object RegExp]"].indexOf(L)<0)||i(y)&&Array.isArray(C))if(v&&i(y)&&Array.isArray(p))p=p.join(y),p&&(p=this.extendTranslation(p,t,n,s));else{let e=!1,i=!1;!this.isValidLookup(p)&&b&&(e=!0,p=k),this.isValidLookup(p)||(i=!0,p=a);const r=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&i?void 0:p,h=b&&k!==p&&this.options.updateMissing;if(i||e||h){if(this.logger.log(h?"updateKey":"missingKey",u,l,a,h?k:p),o){const t=this.resolve(a,{...n,keySeparator:!1});t&&t.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let t=[];const e=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if("fallback"===this.options.saveMissingTo&&e&&e[0])for(let i=0;i<e.length;i++)t.push(e[i]);else"all"===this.options.saveMissingTo?t=this.languageUtils.toResolveHierarchy(n.lng||this.language):t.push(n.lng||this.language);const i=(t,e,i)=>{const s=b&&i!==p?i:r;this.options.missingKeyHandler?this.options.missingKeyHandler(t,l,e,s,h,n):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(t,l,e,s,h,n),this.emit("missingKey",t,l,e,p)};this.options.saveMissing&&(this.options.saveMissingPlurals&&w?t.forEach((t=>{const e=this.pluralResolver.getSuffixes(t,n);x&&n[`defaultValue${this.options.pluralSeparator}zero`]&&e.indexOf(`${this.options.pluralSeparator}zero`)<0&&e.push(`${this.options.pluralSeparator}zero`),e.forEach((e=>{i([t],a+e,n[`defaultValue${e}`]||k)}))})):i(t,a,k))}p=this.extendTranslation(p,t,n,f,s),i&&p===a&&this.options.appendNamespaceToMissingKey&&(p=`${l}${c}${a}`),(i||e)&&this.options.parseMissingKeyHandler&&(p=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}${c}${a}`:a,e?p:void 0,n))}else{if(!n.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const t=this.options.returnedObjectHandler?this.options.returnedObjectHandler(g,C,{...n,ns:h}):`key '${a} (${this.language})' returned an object instead of string.`;return r?(f.res=t,f.usedParams=this.getUsedParamsDetails(n),f):t}if(o){const t=Array.isArray(C),e=t?[]:{},i=t?m:g;for(const t in C)if(Object.prototype.hasOwnProperty.call(C,t)){const s=`${i}${o}${t}`;e[t]=this.translate(s,b&&!p?{...n,defaultValue:O(k)?k[t]:void 0,joinArrays:!1,ns:h}:{...n,joinArrays:!1,ns:h}),e[t]===s&&(e[t]=C[t])}p=e}}return r?(f.res=p,f.usedParams=this.getUsedParamsDetails(n),f):p}extendTranslation(t,e,s,n,r){if(this.i18nFormat?.parse)t=this.i18nFormat.parse(t,{...this.options.interpolation.defaultVariables,...s},s.lng||this.language||n.usedLng,n.usedNS,n.usedKey,{resolved:n});else if(!s.skipInterpolation){s.interpolation&&this.interpolator.init({...s,interpolation:{...this.options.interpolation,...s.interpolation}});const o=i(t)&&(void 0!==s?.interpolation?.skipOnVariables?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let a;if(o){const e=t.match(this.interpolator.nestingRegexp);a=e&&e.length}let h=s.replace&&!i(s.replace)?s.replace:s;if(this.options.interpolation.defaultVariables&&(h={...this.options.interpolation.defaultVariables,...h}),t=this.interpolator.interpolate(t,h,s.lng||this.language||n.usedLng,s),o){const e=t.match(this.interpolator.nestingRegexp);a<(e&&e.length)&&(s.nest=!1)}!s.lng&&n&&n.res&&(s.lng=this.language||n.usedLng),!1!==s.nest&&(t=this.interpolator.nest(t,((...t)=>r?.[0]!==t[0]||s.context?this.translate(...t,e):(this.logger.warn(`It seems you are nesting recursively key: ${t[0]} in key: ${e[0]}`),null)),s)),s.interpolation&&this.interpolator.reset()}const o=s.postProcess||this.options.postProcess,a=i(o)?[o]:o;return null!=t&&a?.length&&!1!==s.applyPostProcessor&&(t=k.handle(a,t,e,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...n,usedParams:this.getUsedParamsDetails(s)},...s}:s,this)),t}resolve(t,e={}){let s,n,r,o,a;return i(t)&&(t=[t]),Array.isArray(t)&&(t=t.map((t=>"function"==typeof t?j(t,{...this.options,...e}):t))),t.forEach((t=>{if(this.isValidLookup(s))return;const h=this.extractFromKey(t,e),l=h.key;n=l;let c=h.namespaces;this.options.fallbackNS&&(c=c.concat(this.options.fallbackNS));const u=void 0!==e.count&&!i(e.count),d=u&&!e.ordinal&&0===e.count,f=void 0!==e.context&&(i(e.context)||"number"==typeof e.context)&&""!==e.context,p=e.lngs?e.lngs:this.languageUtils.toResolveHierarchy(e.lng||this.language,e.fallbackLng);c.forEach((t=>{this.isValidLookup(s)||(a=t,E[`${p[0]}-${t}`]||!this.utils?.hasLoadedNamespace||this.utils?.hasLoadedNamespace(a)||(E[`${p[0]}-${t}`]=!0,this.logger.warn(`key "${n}" for languages "${p.join(", ")}" won't get resolved as namespace "${a}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),p.forEach((i=>{if(this.isValidLookup(s))return;o=i;const n=[l];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(n,l,i,t,e);else{let t;u&&(t=this.pluralResolver.getSuffix(i,e.count,e));const s=`${this.options.pluralSeparator}zero`,r=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(u&&(e.ordinal&&0===t.indexOf(r)&&n.push(l+t.replace(r,this.options.pluralSeparator)),n.push(l+t),d&&n.push(l+s)),f){const i=`${l}${this.options.contextSeparator||"_"}${e.context}`;n.push(i),u&&(e.ordinal&&0===t.indexOf(r)&&n.push(i+t.replace(r,this.options.pluralSeparator)),n.push(i+t),d&&n.push(i+s))}}let a;for(;a=n.pop();)this.isValidLookup(s)||(r=a,s=this.getResource(i,t,a,e))})))}))})),{res:s,usedKey:n,exactUsedKey:r,usedLng:o,usedNS:a}}isValidLookup(t){return!(void 0===t||!this.options.returnNull&&null===t||!this.options.returnEmptyString&&""===t)}getResource(t,e,i,s={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(t,e,i,s):this.resourceStore.getResource(t,e,i,s)}getUsedParamsDetails(t={}){const e=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],s=t.replace&&!i(t.replace);let n=s?t.replace:t;if(s&&void 0!==t.count&&(n.count=t.count),this.options.interpolation.defaultVariables&&(n={...this.options.interpolation.defaultVariables,...n}),!s){n={...n};for(const t of e)delete n[t]}return n}static hasDefaultValue(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e)&&"defaultValue"===e.substring(0,12)&&void 0!==t[e])return!0;return!1}}class L{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=S.create("languageUtils")}getScriptPartFromCode(t){if(!(t=v(t))||t.indexOf("-")<0)return null;const e=t.split("-");return 2===e.length?null:(e.pop(),"x"===e[e.length-1].toLowerCase()?null:this.formatLanguageCode(e.join("-")))}getLanguagePartFromCode(t){if(!(t=v(t))||t.indexOf("-")<0)return t;const e=t.split("-");return this.formatLanguageCode(e[0])}formatLanguageCode(t){if(i(t)&&t.indexOf("-")>-1){let e;try{e=Intl.getCanonicalLocales(t)[0]}catch(t){}return e&&this.options.lowerCaseLng&&(e=e.toLowerCase()),e||(this.options.lowerCaseLng?t.toLowerCase():t)}return this.options.cleanCode||this.options.lowerCaseLng?t.toLowerCase():t}isSupportedCode(t){return("languageOnly"===this.options.load||this.options.nonExplicitSupportedLngs)&&(t=this.getLanguagePartFromCode(t)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(t)>-1}getBestMatchFromCodes(t){if(!t)return null;let e;return t.forEach((t=>{if(e)return;const i=this.formatLanguageCode(t);this.options.supportedLngs&&!this.isSupportedCode(i)||(e=i)})),!e&&this.options.supportedLngs&&t.forEach((t=>{if(e)return;const i=this.getScriptPartFromCode(t);if(this.isSupportedCode(i))return e=i;const s=this.getLanguagePartFromCode(t);if(this.isSupportedCode(s))return e=s;e=this.options.supportedLngs.find((t=>t===s?t:t.indexOf("-")<0&&s.indexOf("-")<0?void 0:t.indexOf("-")>0&&s.indexOf("-")<0&&t.substring(0,t.indexOf("-"))===s||0===t.indexOf(s)&&s.length>1?t:void 0))})),e||(e=this.getFallbackCodes(this.options.fallbackLng)[0]),e}getFallbackCodes(t,e){if(!t)return[];if("function"==typeof t&&(t=t(e)),i(t)&&(t=[t]),Array.isArray(t))return t;if(!e)return t.default||[];let s=t[e];return s||(s=t[this.getScriptPartFromCode(e)]),s||(s=t[this.formatLanguageCode(e)]),s||(s=t[this.getLanguagePartFromCode(e)]),s||(s=t.default),s||[]}toResolveHierarchy(t,e){const s=this.getFallbackCodes((!1===e?[]:e)||this.options.fallbackLng||[],t),n=[],r=t=>{t&&(this.isSupportedCode(t)?n.push(t):this.logger.warn(`rejecting language code not found in supportedLngs: ${t}`))};return i(t)&&(t.indexOf("-")>-1||t.indexOf("_")>-1)?("languageOnly"!==this.options.load&&r(this.formatLanguageCode(t)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&r(this.getScriptPartFromCode(t)),"currentOnly"!==this.options.load&&r(this.getLanguagePartFromCode(t))):i(t)&&r(this.formatLanguageCode(t)),s.forEach((t=>{n.indexOf(t)<0&&r(this.formatLanguageCode(t))})),n}}const M={zero:0,one:1,two:2,few:3,many:4,other:5},P={select:t=>1===t?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class z{constructor(t,e={}){this.languageUtils=t,this.options=e,this.logger=S.create("pluralResolver"),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(t,e={}){const i=v("dev"===t?"en":t),s=e.ordinal?"ordinal":"cardinal",n=JSON.stringify({cleanedCode:i,type:s});if(n in this.pluralRulesCache)return this.pluralRulesCache[n];let r;try{r=new Intl.PluralRules(i,{type:s})}catch(i){if("undefined"==typeof Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),P;if(!t.match(/-|_/))return P;const s=this.languageUtils.getLanguagePartFromCode(t);r=this.getRule(s,e)}return this.pluralRulesCache[n]=r,r}needsPlural(t,e={}){let i=this.getRule(t,e);return i||(i=this.getRule("dev",e)),i?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(t,e,i={}){return this.getSuffixes(t,i).map((t=>`${e}${t}`))}getSuffixes(t,e={}){let i=this.getRule(t,e);return i||(i=this.getRule("dev",e)),i?i.resolvedOptions().pluralCategories.sort(((t,e)=>M[t]-M[e])).map((t=>`${this.options.prepend}${e.ordinal?`ordinal${this.options.prepend}`:""}${t}`)):[]}getSuffix(t,e,i={}){const s=this.getRule(t,i);return s?`${this.options.prepend}${i.ordinal?`ordinal${this.options.prepend}`:""}${s.select(e)}`:(this.logger.warn(`no plural rule found for: ${t}`),this.getSuffix("dev",e,i))}}const A=(t,e,s,n=".",r=!0)=>{let o=((t,e,i)=>{const s=c(t,i);return void 0!==s?s:c(e,i)})(t,e,s);return!o&&r&&i(s)&&(o=y(t,s,n),void 0===o&&(o=y(e,s,n))),o},R=t=>t.replace(/\$/g,"$$$$");class T{constructor(t={}){this.logger=S.create("interpolator"),this.options=t,this.format=t?.interpolation?.format||(t=>t),this.init(t)}init(t={}){t.interpolation||(t.interpolation={escapeValue:!0});const{escape:e,escapeValue:i,useRawValueToEscape:s,prefix:n,prefixEscaped:r,suffix:o,suffixEscaped:a,formatSeparator:h,unescapeSuffix:l,unescapePrefix:c,nestingPrefix:u,nestingPrefixEscaped:f,nestingSuffix:g,nestingSuffixEscaped:m,nestingOptionsSeparator:y,maxReplaces:v,alwaysFormat:w}=t.interpolation;this.escape=void 0!==e?e:p,this.escapeValue=void 0===i||i,this.useRawValueToEscape=void 0!==s&&s,this.prefix=n?d(n):r||"{{",this.suffix=o?d(o):a||"}}",this.formatSeparator=h||",",this.unescapePrefix=l?"":c||"-",this.unescapeSuffix=this.unescapePrefix?"":l||"",this.nestingPrefix=u?d(u):f||d("$t("),this.nestingSuffix=g?d(g):m||d(")"),this.nestingOptionsSeparator=y||",",this.maxReplaces=v||1e3,this.alwaysFormat=void 0!==w&&w,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const t=(t,e)=>t?.source===e?(t.lastIndex=0,t):new RegExp(e,"g");this.regexp=t(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=t(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=t(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(t,e,s,r){let o,a,h;const l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},c=t=>{if(t.indexOf(this.formatSeparator)<0){const i=A(e,l,t,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(i,void 0,s,{...r,...e,interpolationkey:t}):i}const i=t.split(this.formatSeparator),n=i.shift().trim(),o=i.join(this.formatSeparator).trim();return this.format(A(e,l,n,this.options.keySeparator,this.options.ignoreJSONStructure),o,s,{...r,...e,interpolationkey:n})};this.resetRegExp();const u=r?.missingInterpolationHandler||this.options.missingInterpolationHandler,d=void 0!==r?.interpolation?.skipOnVariables?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:t=>R(t)},{regex:this.regexp,safeValue:t=>R(this.escapeValue?this.escape(t):t)}].forEach((e=>{for(h=0;o=e.regex.exec(t);){const s=o[1].trim();if(a=c(s),void 0===a)if("function"==typeof u){const e=u(t,o,r);a=i(e)?e:""}else if(r&&Object.prototype.hasOwnProperty.call(r,s))a="";else{if(d){a=o[0];continue}this.logger.warn(`missed to pass in variable ${s} for interpolating ${t}`),a=""}else i(a)||this.useRawValueToEscape||(a=n(a));const l=e.safeValue(a);if(t=t.replace(o[0],l),d?(e.regex.lastIndex+=a.length,e.regex.lastIndex-=o[0].length):e.regex.lastIndex=0,h++,h>=this.maxReplaces)break}})),t}nest(t,e,s={}){let r,o,a;const h=(t,e)=>{const i=this.nestingOptionsSeparator;if(t.indexOf(i)<0)return t;const s=t.split(new RegExp(`${d(i)}[ ]*{`));let n=`{${s[1]}`;t=s[0],n=this.interpolate(n,a);const r=n.match(/'/g),o=n.match(/"/g);((r?.length??0)%2==0&&!o||(o?.length??0)%2!=0)&&(n=n.replace(/'/g,'"'));try{a=JSON.parse(n),e&&(a={...e,...a})}catch(e){return this.logger.warn(`failed parsing options string in nesting for key ${t}`,e),`${t}${i}${n}`}return a.defaultValue&&a.defaultValue.indexOf(this.prefix)>-1&&delete a.defaultValue,t};for(;r=this.nestingRegexp.exec(t);){let l=[];a={...s},a=a.replace&&!i(a.replace)?a.replace:a,a.applyPostProcessor=!1,delete a.defaultValue;const c=/{.*}/.test(r[1])?r[1].lastIndexOf("}")+1:r[1].indexOf(this.formatSeparator);if(-1!==c&&(l=r[1].slice(c).split(this.formatSeparator).map((t=>t.trim())).filter(Boolean),r[1]=r[1].slice(0,c)),o=e(h.call(this,r[1].trim(),a),a),o&&r[0]===t&&!i(o))return o;i(o)||(o=n(o)),o||(this.logger.warn(`missed to resolve ${r[1]} for nesting ${t}`),o=""),l.length&&(o=l.reduce(((t,e)=>this.format(t,e,s.lng,{...s,interpolationkey:r[1].trim()})),o.trim())),t=t.replace(r[0],o),this.regexp.lastIndex=0}return t}}const I=t=>{const e={};return(i,s,n)=>{let r=n;n&&n.interpolationkey&&n.formatParams&&n.formatParams[n.interpolationkey]&&n[n.interpolationkey]&&(r={...r,[n.interpolationkey]:void 0});const o=s+JSON.stringify(r);let a=e[o];return a||(a=t(v(s),n),e[o]=a),a(i)}},F=t=>(e,i,s)=>t(v(i),s)(e);class V{constructor(t={}){this.logger=S.create("formatter"),this.options=t,this.init(t)}init(t,e={interpolation:{}}){this.formatSeparator=e.interpolation.formatSeparator||",";const i=e.cacheInBuiltFormats?I:F;this.formats={number:i(((t,e)=>{const i=new Intl.NumberFormat(t,{...e});return t=>i.format(t)})),currency:i(((t,e)=>{const i=new Intl.NumberFormat(t,{...e,style:"currency"});return t=>i.format(t)})),datetime:i(((t,e)=>{const i=new Intl.DateTimeFormat(t,{...e});return t=>i.format(t)})),relativetime:i(((t,e)=>{const i=new Intl.RelativeTimeFormat(t,{...e});return t=>i.format(t,e.range||"day")})),list:i(((t,e)=>{const i=new Intl.ListFormat(t,{...e});return t=>i.format(t)}))}}add(t,e){this.formats[t.toLowerCase().trim()]=e}addCached(t,e){this.formats[t.toLowerCase().trim()]=I(e)}format(t,e,i,s={}){const n=e.split(this.formatSeparator);if(n.length>1&&n[0].indexOf("(")>1&&n[0].indexOf(")")<0&&n.find((t=>t.indexOf(")")>-1))){const t=n.findIndex((t=>t.indexOf(")")>-1));n[0]=[n[0],...n.splice(1,t)].join(this.formatSeparator)}return n.reduce(((t,e)=>{const{formatName:n,formatOptions:r}=(t=>{let e=t.toLowerCase().trim();const i={};if(t.indexOf("(")>-1){const s=t.split("(");e=s[0].toLowerCase().trim();const n=s[1].substring(0,s[1].length-1);"currency"===e&&n.indexOf(":")<0?i.currency||(i.currency=n.trim()):"relativetime"===e&&n.indexOf(":")<0?i.range||(i.range=n.trim()):n.split(";").forEach((t=>{if(t){const[e,...s]=t.split(":"),n=s.join(":").trim().replace(/^'+|'+$/g,""),r=e.trim();i[r]||(i[r]=n),"false"===n&&(i[r]=!1),"true"===n&&(i[r]=!0),isNaN(n)||(i[r]=parseInt(n,10))}}))}return{formatName:e,formatOptions:i}})(e);if(this.formats[n]){let e=t;try{const o=s?.formatParams?.[s.interpolationkey]||{};e=this.formats[n](t,o.locale||o.lng||s.locale||s.lng||i,{...r,...s,...o})}catch(t){this.logger.warn(t)}return e}return this.logger.warn(`there was no format function for ${n}`),t}),t)}}class D extends ${constructor(t,e,i,s={}){super(),this.backend=t,this.store=e,this.services=i,this.languageUtils=i.languageUtils,this.options=s,this.logger=S.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=s.maxParallelReads||10,this.readingCalls=0,this.maxRetries=s.maxRetries>=0?s.maxRetries:5,this.retryTimeout=s.retryTimeout>=1?s.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(i,s.backend,s)}queueLoad(t,e,i,s){const n={},r={},o={},a={};return t.forEach((t=>{let s=!0;e.forEach((e=>{const o=`${t}|${e}`;!i.reload&&this.store.hasResourceBundle(t,e)?this.state[o]=2:this.state[o]<0||(1===this.state[o]?void 0===r[o]&&(r[o]=!0):(this.state[o]=1,s=!1,void 0===r[o]&&(r[o]=!0),void 0===n[o]&&(n[o]=!0),void 0===a[e]&&(a[e]=!0)))})),s||(o[t]=!0)})),(Object.keys(n).length||Object.keys(r).length)&&this.queue.push({pending:r,pendingCount:Object.keys(r).length,loaded:{},errors:[],callback:s}),{toLoad:Object.keys(n),pending:Object.keys(r),toLoadLanguages:Object.keys(o),toLoadNamespaces:Object.keys(a)}}loaded(t,e,i){const s=t.split("|"),n=s[0],r=s[1];e&&this.emit("failedLoading",n,r,e),!e&&i&&this.store.addResourceBundle(n,r,i,void 0,void 0,{skipCopy:!0}),this.state[t]=e?-1:2,e&&i&&(this.state[t]=0);const o={};this.queue.forEach((i=>{((t,e,i)=>{const{obj:s,k:n}=h(t,e,Object);s[n]=s[n]||[],s[n].push(i)})(i.loaded,[n],r),((t,e)=>{void 0!==t.pending[e]&&(delete t.pending[e],t.pendingCount--)})(i,t),e&&i.errors.push(e),0!==i.pendingCount||i.done||(Object.keys(i.loaded).forEach((t=>{o[t]||(o[t]={});const e=i.loaded[t];e.length&&e.forEach((e=>{void 0===o[t][e]&&(o[t][e]=!0)}))})),i.done=!0,i.errors.length?i.callback(i.errors):i.callback())})),this.emit("loaded",o),this.queue=this.queue.filter((t=>!t.done))}read(t,e,i,s=0,n=this.retryTimeout,r){if(!t.length)return r(null,{});if(this.readingCalls>=this.maxParallelReads)return void this.waitingReads.push({lng:t,ns:e,fcName:i,tried:s,wait:n,callback:r});this.readingCalls++;const o=(o,a)=>{if(this.readingCalls--,this.waitingReads.length>0){const t=this.waitingReads.shift();this.read(t.lng,t.ns,t.fcName,t.tried,t.wait,t.callback)}o&&a&&s<this.maxRetries?setTimeout((()=>{this.read.call(this,t,e,i,s+1,2*n,r)}),n):r(o,a)},a=this.backend[i].bind(this.backend);if(2!==a.length)return a(t,e,o);try{const i=a(t,e);i&&"function"==typeof i.then?i.then((t=>o(null,t))).catch(o):o(null,i)}catch(t){o(t)}}prepareLoading(t,e,s={},n){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),n&&n();i(t)&&(t=this.languageUtils.toResolveHierarchy(t)),i(e)&&(e=[e]);const r=this.queueLoad(t,e,s,n);if(!r.toLoad.length)return r.pending.length||n(),null;r.toLoad.forEach((t=>{this.loadOne(t)}))}load(t,e,i){this.prepareLoading(t,e,{},i)}reload(t,e,i){this.prepareLoading(t,e,{reload:!0},i)}loadOne(t,e=""){const i=t.split("|"),s=i[0],n=i[1];this.read(s,n,"read",void 0,void 0,((i,r)=>{i&&this.logger.warn(`${e}loading namespace ${n} for language ${s} failed`,i),!i&&r&&this.logger.log(`${e}loaded namespace ${n} for language ${s}`,r),this.loaded(t,i,r)}))}saveMissing(t,e,i,s,n,r={},o=()=>{}){if(!this.services?.utils?.hasLoadedNamespace||this.services?.utils?.hasLoadedNamespace(e)){if(null!=i&&""!==i){if(this.backend?.create){const a={...r,isUpdate:n},h=this.backend.create.bind(this.backend);if(h.length<6)try{let n;n=5===h.length?h(t,e,i,s,a):h(t,e,i,s),n&&"function"==typeof n.then?n.then((t=>o(null,t))).catch(o):o(null,n)}catch(t){o(t)}else h(t,e,i,s,o,a)}t&&t[0]&&this.store.addResource(t[0],e,i,s)}}else this.logger.warn(`did not save key "${i}" as the namespace "${e}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")}}const K=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:t=>{let e={};if("object"==typeof t[1]&&(e=t[1]),i(t[1])&&(e.defaultValue=t[1]),i(t[2])&&(e.tDescription=t[2]),"object"==typeof t[2]||"object"==typeof t[3]){const i=t[3]||t[2];Object.keys(i).forEach((t=>{e[t]=i[t]}))}return e},interpolation:{escapeValue:!0,format:t=>t,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),B=t=>(i(t.ns)&&(t.ns=[t.ns]),i(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),i(t.fallbackNS)&&(t.fallbackNS=[t.fallbackNS]),t.supportedLngs?.indexOf?.("cimode")<0&&(t.supportedLngs=t.supportedLngs.concat(["cimode"])),"boolean"==typeof t.initImmediate&&(t.initAsync=t.initImmediate),t),_=()=>{},U="__i18next_supportNoticeShown";class H extends ${constructor(t={},e){var i;if(super(),this.options=B(t),this.services={},this.logger=S,this.modules={external:[]},i=this,Object.getOwnPropertyNames(Object.getPrototypeOf(i)).forEach((t=>{"function"==typeof i[t]&&(i[t]=i[t].bind(i))})),e&&!this.isInitialized&&!t.isClone){if(!this.options.initAsync)return this.init(t,e),this;setTimeout((()=>{this.init(t,e)}),0)}}init(t={},e){this.isInitializing=!0,"function"==typeof t&&(e=t,t={}),null==t.defaultNS&&t.ns&&(i(t.ns)?t.defaultNS=t.ns:t.ns.indexOf("translation")<0&&(t.defaultNS=t.ns[0]));const n=K();var r;this.options={...n,...this.options,...B(t)},this.options.interpolation={...n.interpolation,...this.options.interpolation},void 0!==t.keySeparator&&(this.options.userDefinedKeySeparator=t.keySeparator),void 0!==t.nsSeparator&&(this.options.userDefinedNsSeparator=t.nsSeparator),"function"!=typeof this.options.overloadTranslationOptionHandler&&(this.options.overloadTranslationOptionHandler=n.overloadTranslationOptionHandler),!1===this.options.showSupportNotice||(r=this,r?.modules?.backend?.name?.indexOf("Locize")>0||r?.modules?.backend?.constructor?.name?.indexOf("Locize")>0||r?.options?.backend?.backends&&r.options.backend.backends.some((t=>t?.name?.indexOf("Locize")>0||t?.constructor?.name?.indexOf("Locize")>0))||r?.options?.backend?.projectId||r?.options?.backend?.backendOptions&&r.options.backend.backendOptions.some((t=>t?.projectId)))||"undefined"!=typeof globalThis&&globalThis[U]||"undefined"!=typeof process&&process.env&&process.env.I18NEXT_NO_SUPPORT_NOTICE||"undefined"!=typeof process&&process.env||("undefined"!=typeof console&&void 0!==console.info&&console.info("🌐 i18next is made possible by our own product, Locize — consider powering your project with managed localization (AI, CDN, integrations): https://locize.com 💙"),"undefined"!=typeof globalThis&&(globalThis[U]=!0));const o=t=>t?"function"==typeof t?new t:t:null;if(!this.options.isClone){let t;S.init(this.modules.logger?o(this.modules.logger):null,this.options),t=this.modules.formatter?this.modules.formatter:V;const e=new L(this.options);this.store=new x(this.options.resources,this.options);const i=this.services;i.logger=S,i.resourceStore=this.store,i.languageUtils=e,i.pluralResolver=new z(e,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==n.interpolation.format&&this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),!t||this.options.interpolation.format&&this.options.interpolation.format!==n.interpolation.format||(i.formatter=o(t),i.formatter.init&&i.formatter.init(i,this.options),this.options.interpolation.format=i.formatter.format.bind(i.formatter)),i.interpolator=new T(this.options),i.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},i.backendConnector=new D(o(this.modules.backend),i.resourceStore,i,this.options),i.backendConnector.on("*",((t,...e)=>{this.emit(t,...e)})),this.modules.languageDetector&&(i.languageDetector=o(this.modules.languageDetector),i.languageDetector.init&&i.languageDetector.init(i,this.options.detection,this.options)),this.modules.i18nFormat&&(i.i18nFormat=o(this.modules.i18nFormat),i.i18nFormat.init&&i.i18nFormat.init(this)),this.translator=new N(this.services,this.options),this.translator.on("*",((t,...e)=>{this.emit(t,...e)})),this.modules.external.forEach((t=>{t.init&&t.init(this)}))}if(this.format=this.options.interpolation.format,e||(e=_),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const t=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);t.length>0&&"dev"!==t[0]&&(this.options.lng=t[0])}this.services.languageDetector||this.options.lng||this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach((t=>{this[t]=(...e)=>this.store[t](...e)})),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach((t=>{this[t]=(...e)=>(this.store[t](...e),this)}));const a=s(),h=()=>{const t=(t,i)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),a.resolve(i),e(t,i)};if(this.languages&&!this.isInitialized)return t(null,this.t.bind(this));this.changeLanguage(this.options.lng,t)};return this.options.resources||!this.options.initAsync?h():setTimeout(h,0),a}loadResources(t,e=_){let s=e;const n=i(t)?t:this.language;if("function"==typeof t&&(s=t),!this.options.resources||this.options.partialBundledLanguages){if("cimode"===n?.toLowerCase()&&(!this.options.preload||0===this.options.preload.length))return s();const t=[],e=e=>{e&&"cimode"!==e&&this.services.languageUtils.toResolveHierarchy(e).forEach((e=>{"cimode"!==e&&t.indexOf(e)<0&&t.push(e)}))};n?e(n):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach((t=>e(t))),this.options.preload?.forEach?.((t=>e(t))),this.services.backendConnector.load(t,this.options.ns,(t=>{t||this.resolvedLanguage||!this.language||this.setResolvedLanguage(this.language),s(t)}))}else s(null)}reloadResources(t,e,i){const n=s();return"function"==typeof t&&(i=t,t=void 0),"function"==typeof e&&(i=e,e=void 0),t||(t=this.languages),e||(e=this.options.ns),i||(i=_),this.services.backendConnector.reload(t,e,(t=>{n.resolve(),i(t)})),n}use(t){if(!t)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!t.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return"backend"===t.type&&(this.modules.backend=t),("logger"===t.type||t.log&&t.warn&&t.error)&&(this.modules.logger=t),"languageDetector"===t.type&&(this.modules.languageDetector=t),"i18nFormat"===t.type&&(this.modules.i18nFormat=t),"postProcessor"===t.type&&k.addPostProcessor(t),"formatter"===t.type&&(this.modules.formatter=t),"3rdParty"===t.type&&this.modules.external.push(t),this}setResolvedLanguage(t){if(t&&this.languages&&!(["cimode","dev"].indexOf(t)>-1)){for(let t=0;t<this.languages.length;t++){const e=this.languages[t];if(!(["cimode","dev"].indexOf(e)>-1)&&this.store.hasLanguageSomeTranslations(e)){this.resolvedLanguage=e;break}}!this.resolvedLanguage&&this.languages.indexOf(t)<0&&this.store.hasLanguageSomeTranslations(t)&&(this.resolvedLanguage=t,this.languages.unshift(t))}}changeLanguage(t,e){this.isLanguageChangingTo=t;const n=s();this.emit("languageChanging",t);const r=t=>{this.language=t,this.languages=this.services.languageUtils.toResolveHierarchy(t),this.resolvedLanguage=void 0,this.setResolvedLanguage(t)},o=(i,s)=>{s?this.isLanguageChangingTo===t&&(r(s),this.translator.changeLanguage(s),this.isLanguageChangingTo=void 0,this.emit("languageChanged",s),this.logger.log("languageChanged",s)):this.isLanguageChangingTo=void 0,n.resolve(((...t)=>this.t(...t))),e&&e(i,((...t)=>this.t(...t)))},a=e=>{t||e||!this.services.languageDetector||(e=[]);const s=i(e)?e:e&&e[0],n=this.store.hasLanguageSomeTranslations(s)?s:this.services.languageUtils.getBestMatchFromCodes(i(e)?[e]:e);n&&(this.language||r(n),this.translator.language||this.translator.changeLanguage(n),this.services.languageDetector?.cacheUserLanguage?.(n)),this.loadResources(n,(t=>{o(t,n)}))};return t||!this.services.languageDetector||this.services.languageDetector.async?!t&&this.services.languageDetector&&this.services.languageDetector.async?0===this.services.languageDetector.detect.length?this.services.languageDetector.detect().then(a):this.services.languageDetector.detect(a):a(t):a(this.services.languageDetector.detect()),n}getFixedT(t,e,s){const n=(t,e,...i)=>{let r;r="object"!=typeof e?this.options.overloadTranslationOptionHandler([t,e].concat(i)):{...e},r.lng=r.lng||n.lng,r.lngs=r.lngs||n.lngs,r.ns=r.ns||n.ns,""!==r.keyPrefix&&(r.keyPrefix=r.keyPrefix||s||n.keyPrefix);const o={...this.options,...r};"function"==typeof r.keyPrefix&&(r.keyPrefix=j(r.keyPrefix,o));const a=this.options.keySeparator||".";let h;return r.keyPrefix&&Array.isArray(t)?h=t.map((t=>("function"==typeof t&&(t=j(t,o)),`${r.keyPrefix}${a}${t}`))):("function"==typeof t&&(t=j(t,o)),h=r.keyPrefix?`${r.keyPrefix}${a}${t}`:t),this.t(h,r)};return i(t)?n.lng=t:n.lngs=t,n.ns=e,n.keyPrefix=s,n}t(...t){return this.translator?.translate(...t)}exists(...t){return this.translator?.exists(...t)}setDefaultNamespace(t){this.options.defaultNS=t}hasLoadedNamespace(t,e={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const i=e.lng||this.resolvedLanguage||this.languages[0],s=!!this.options&&this.options.fallbackLng,n=this.languages[this.languages.length-1];if("cimode"===i.toLowerCase())return!0;const r=(t,e)=>{const i=this.services.backendConnector.state[`${t}|${e}`];return-1===i||0===i||2===i};if(e.precheck){const t=e.precheck(this,r);if(void 0!==t)return t}return!(!this.hasResourceBundle(i,t)&&this.services.backendConnector.backend&&(!this.options.resources||this.options.partialBundledLanguages)&&(!r(i,t)||s&&!r(n,t)))}loadNamespaces(t,e){const n=s();return this.options.ns?(i(t)&&(t=[t]),t.forEach((t=>{this.options.ns.indexOf(t)<0&&this.options.ns.push(t)})),this.loadResources((t=>{n.resolve(),e&&e(t)})),n):(e&&e(),Promise.resolve())}loadLanguages(t,e){const n=s();i(t)&&(t=[t]);const r=this.options.preload||[],o=t.filter((t=>r.indexOf(t)<0&&this.services.languageUtils.isSupportedCode(t)));return o.length?(this.options.preload=r.concat(o),this.loadResources((t=>{n.resolve(),e&&e(t)})),n):(e&&e(),Promise.resolve())}dir(t){if(t||(t=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!t)return"rtl";try{const e=new Intl.Locale(t);if(e&&e.getTextInfo){const t=e.getTextInfo();if(t&&t.direction)return t.direction}}catch(t){}const e=this.services?.languageUtils||new L(K());return t.toLowerCase().indexOf("-latn")>1?"ltr":["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"].indexOf(e.getLanguagePartFromCode(t))>-1||t.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(t={},e){const i=new H(t,e);return i.createInstance=H.createInstance,i}cloneInstance(t={},e=_){const i=t.forkResourceStore;i&&delete t.forkResourceStore;const s={...this.options,...t,isClone:!0},n=new H(s);if(void 0===t.debug&&void 0===t.prefix||(n.logger=n.logger.clone(t)),["store","services","language"].forEach((t=>{n[t]=this[t]})),n.services={...this.services},n.services.utils={hasLoadedNamespace:n.hasLoadedNamespace.bind(n)},i){const t=Object.keys(this.store.data).reduce(((t,e)=>(t[e]={...this.store.data[e]},t[e]=Object.keys(t[e]).reduce(((i,s)=>(i[s]={...t[e][s]},i)),t[e]),t)),{});n.store=new x(t,s),n.services.resourceStore=n.store}if(t.interpolation){const e={...K().interpolation,...this.options.interpolation,...t.interpolation},i={...s,interpolation:e};n.services.interpolator=new T(i)}return n.translator=new N(n.services,s),n.translator.on("*",((t,...e)=>{n.emit(t,...e)})),n.init(s,e),n.translator.options=s,n.translator.backendConnector.services.utils={hasLoadedNamespace:n.hasLoadedNamespace.bind(n)},n}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const Y=H.createInstance(),{slice:W,forEach:J}=[],q=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,G={create(t,e,i,s){let n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{path:"/",sameSite:"strict"};i&&(n.expires=new Date,n.expires.setTime(n.expires.getTime()+60*i*1e3)),s&&(n.domain=s),document.cookie=function(t,e){const i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{path:"/"};let s=`${t}=${encodeURIComponent(e)}`;if(i.maxAge>0){const t=i.maxAge-0;if(Number.isNaN(t))throw new Error("maxAge should be a Number");s+=`; Max-Age=${Math.floor(t)}`}if(i.domain){if(!q.test(i.domain))throw new TypeError("option domain is invalid");s+=`; Domain=${i.domain}`}if(i.path){if(!q.test(i.path))throw new TypeError("option path is invalid");s+=`; Path=${i.path}`}if(i.expires){if("function"!=typeof i.expires.toUTCString)throw new TypeError("option expires is invalid");s+=`; Expires=${i.expires.toUTCString()}`}if(i.httpOnly&&(s+="; HttpOnly"),i.secure&&(s+="; Secure"),i.sameSite)switch("string"==typeof i.sameSite?i.sameSite.toLowerCase():i.sameSite){case!0:s+="; SameSite=Strict";break;case"lax":s+="; SameSite=Lax";break;case"strict":s+="; SameSite=Strict";break;case"none":s+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}return i.partitioned&&(s+="; Partitioned"),s}(t,e,n)},read(t){const e=`${t}=`,i=document.cookie.split(";");for(let t=0;t<i.length;t++){let s=i[t];for(;" "===s.charAt(0);)s=s.substring(1,s.length);if(0===s.indexOf(e))return s.substring(e.length,s.length)}return null},remove(t,e){this.create(t,"",-1,e)}};var Q={name:"cookie",lookup(t){let{lookupCookie:e}=t;if(e&&"undefined"!=typeof document)return G.read(e)||void 0},cacheUserLanguage(t,e){let{lookupCookie:i,cookieMinutes:s,cookieDomain:n,cookieOptions:r}=e;i&&"undefined"!=typeof document&&G.create(i,t,s,n,r)}},Z={name:"querystring",lookup(t){let e,{lookupQuerystring:i}=t;if("undefined"!=typeof window){let{search:t}=window.location;!window.location.search&&window.location.hash?.indexOf("?")>-1&&(t=window.location.hash.substring(window.location.hash.indexOf("?")));const s=t.substring(1).split("&");for(let t=0;t<s.length;t++){const n=s[t].indexOf("=");n>0&&s[t].substring(0,n)===i&&(e=s[t].substring(n+1))}}return e}},X={name:"hash",lookup(t){let e,{lookupHash:i,lookupFromHashIndex:s}=t;if("undefined"!=typeof window){const{hash:t}=window.location;if(t&&t.length>2){const n=t.substring(1);if(i){const t=n.split("&");for(let s=0;s<t.length;s++){const n=t[s].indexOf("=");n>0&&t[s].substring(0,n)===i&&(e=t[s].substring(n+1))}}if(e)return e;if(!e&&s>-1){const e=t.match(/\/([a-zA-Z-]*)/g);if(!Array.isArray(e))return;const i="number"==typeof s?s:0;return e[i]?.replace("/","")}}}return e}};let tt=null;const et=()=>{if(null!==tt)return tt;try{if(tt="undefined"!=typeof window&&null!==window.localStorage,!tt)return!1;const t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch(t){tt=!1}return tt};var it={name:"localStorage",lookup(t){let{lookupLocalStorage:e}=t;if(e&&et())return window.localStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupLocalStorage:i}=e;i&&et()&&window.localStorage.setItem(i,t)}};let st=null;const nt=()=>{if(null!==st)return st;try{if(st="undefined"!=typeof window&&null!==window.sessionStorage,!st)return!1;const t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch(t){st=!1}return st};var rt={name:"sessionStorage",lookup(t){let{lookupSessionStorage:e}=t;if(e&&nt())return window.sessionStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupSessionStorage:i}=e;i&&nt()&&window.sessionStorage.setItem(i,t)}},ot={name:"navigator",lookup(t){const e=[];if("undefined"!=typeof navigator){const{languages:t,userLanguage:i,language:s}=navigator;if(t)for(let i=0;i<t.length;i++)e.push(t[i]);i&&e.push(i),s&&e.push(s)}return e.length>0?e:void 0}},at={name:"htmlTag",lookup(t){let e,{htmlTag:i}=t;const s=i||("undefined"!=typeof document?document.documentElement:null);return s&&"function"==typeof s.getAttribute&&(e=s.getAttribute("lang")),e}},ht={name:"path",lookup(t){let{lookupFromPathIndex:e}=t;if("undefined"==typeof window)return;const i=window.location.pathname.match(/\/([a-zA-Z-]*)/g);if(!Array.isArray(i))return;const s="number"==typeof e?e:0;return i[s]?.replace("/","")}},lt={name:"subdomain",lookup(t){let{lookupFromSubdomainIndex:e}=t;const i="number"==typeof e?e+1:1,s="undefined"!=typeof window&&window.location?.hostname?.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i);if(s)return s[i]}};let ct=!1;try{ct=!0}catch(t){}const ut=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];ct||ut.splice(1,1);class dt{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.type="languageDetector",this.detectors={},this.init(t,e)}init(){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.services=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{languageUtils:{}},this.options=function(t){return J.call(W.call(arguments,1),(e=>{if(e)for(const i in e)void 0===t[i]&&(t[i]=e[i])})),t}(t,this.options||{},{order:ut,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:t=>t}),"string"==typeof this.options.convertDetectedLanguage&&this.options.convertDetectedLanguage.indexOf("15897")>-1&&(this.options.convertDetectedLanguage=t=>t.replace("-","_")),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=e,this.addDetector(Q),this.addDetector(Z),this.addDetector(it),this.addDetector(rt),this.addDetector(ot),this.addDetector(at),this.addDetector(ht),this.addDetector(lt),this.addDetector(X)}addDetector(t){return this.detectors[t.name]=t,this}detect(){let t=[];return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.options.order).forEach((e=>{if(this.detectors[e]){let i=this.detectors[e].lookup(this.options);i&&"string"==typeof i&&(i=[i]),i&&(t=t.concat(i))}})),t=t.filter((t=>{return null!=t&&!("string"==typeof(e=t)&&[/<\s*script.*?>/i,/<\s*\/\s*script\s*>/i,/<\s*img.*?on\w+\s*=/i,/<\s*\w+\s*on\w+\s*=.*?>/i,/javascript\s*:/i,/vbscript\s*:/i,/expression\s*\(/i,/eval\s*\(/i,/alert\s*\(/i,/document\.cookie/i,/document\.write\s*\(/i,/window\.location/i,/innerHTML/i].some((t=>t.test(e))));var e})).map((t=>this.options.convertDetectedLanguage(t))),this.services&&this.services.languageUtils&&this.services.languageUtils.getBestMatchFromCodes?t:t.length>0?t[0]:null}cacheUserLanguage(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.options.caches;e&&(this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(t)>-1||e.forEach((e=>{this.detectors[e]&&this.detectors[e].cacheUserLanguage(t,this.options)})))}}dt.type="languageDetector",Y.use(dt).init({fallbackLng:"en",debug:!1,resources:{en:{translation:{}},ja:{translation:{Pay:"支払う","Failed to load Stripe":"ライブラリの読み込みに失敗しました。","Add your payment information":"支払情報を追加","Add card":"カードを追加","Add a card":"カードを追加",Add:"追加","Card information":"カード情報","Card Number":"カード番号","MM / YY":"月 / 年",CVC:"セキュリティコード(CVC)","Country or region":"地域","Postal Code":"郵便番号"}},"pt-BR":{translation:{Pay:"Pagar","Failed to load Stripe":"Falha ao ler Stripe","Add your payment information":"Informações do seu Pagamento","Add card":"Adicionar Cartão","Add a card":"Adicionar um Cartão",Add:"Adicionar","Card information":"Informações do Cartão","Card Number":"Número do Cartão","MM / YY":"MM / AA",CVC:"Número de Segurança(CVC)","Country or region":"País ou região","Postal Code":"Cep"}}}});const ft=Y,pt=(()=>{let t;return(...e)=>{t&&clearTimeout(t),t=setTimeout((()=>{t=0,(t=>{for(let e of t.keys()){const i=t.get(e).filter((t=>{const e=t.deref();return e&&(!("isConnected"in(i=e))||i.isConnected);var i}));t.set(e,i)}})(...e)}),2e3)}})(),gt=t.forceUpdate,mt=t.getRenderingRef,yt=(t,e)=>{const i=t.indexOf(e);i>=0&&(t[i]=t[t.length-1],t.length--)},vt=(t,e)=>{const i=((t,e=(t,e)=>t!==e)=>{const i=()=>{return("function"==typeof(e=t)?e():e)??{};var e},s=i();let n=new Map(Object.entries(s));const r="undefined"!=typeof Proxy,o=r?null:{},a={dispose:[],get:[],set:[],reset:[]},h=new Map,l=()=>{n=new Map(Object.entries(i())),r||g(),a.reset.forEach((t=>t()))},c=t=>(a.get.forEach((e=>e(t))),n.get(t)),u=(t,i)=>{const s=n.get(t);e(i,s,t)&&(n.set(t,i),r||p(t),a.set.forEach((e=>e(t,i,s))))},d=r?new Proxy(s,{get:(t,e)=>c(e),ownKeys:()=>Array.from(n.keys()),getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0}),has:(t,e)=>n.has(e),set:(t,e,i)=>(u(e,i),!0)}):(g(),o),f=(t,e)=>(a[t].push(e),()=>{yt(a[t],e)});function p(t){!r&&o&&(Object.prototype.hasOwnProperty.call(o,t)||Object.defineProperty(o,t,{configurable:!0,enumerable:!0,get:()=>c(t),set(e){u(t,e)}}))}function g(){if(r||!o)return;const t=new Set(n.keys());for(const e of Object.keys(o))t.has(e)||delete o[e];for(const e of t)p(e)}return{state:d,get:c,set:u,on:f,onChange:(t,e)=>{const s=(i,s)=>{i===t&&e(s)},n=()=>{const s=i();e(s[t])},r=f("set",s),o=f("reset",n);return h.set(e,{setHandler:s,resetHandler:n,propName:t}),()=>{r(),o(),h.delete(e)}},use:(...t)=>{const e=t.reduce(((t,e)=>(e.set&&t.push(f("set",e.set)),e.get&&t.push(f("get",e.get)),e.reset&&t.push(f("reset",e.reset)),e.dispose&&t.push(f("dispose",e.dispose)),t)),[]);return()=>e.forEach((t=>t()))},dispose:()=>{a.dispose.forEach((t=>t())),l()},reset:l,forceUpdate:t=>{const e=n.get(t);a.set.forEach((i=>i(t,e,e)))},removeListener:(t,e)=>{const i=h.get(e);i&&i.propName===t&&(yt(a.set,i.setHandler),yt(a.reset,i.resetHandler),h.delete(e))}}})(t,e);return i.use((()=>{if("function"!=typeof mt||"function"!=typeof gt)return{};const t=gt,e=mt,i=new Map;return{dispose:()=>i.clear(),get:t=>{const s=e();s&&((t,e,i)=>{let s=t.get(e);s||(s=[],t.set(e,s)),s.some((t=>t.deref()===i))||s.push(new WeakRef(i))})(i,t,s)},set:e=>{const s=i.get(e);if(s){const n=s.filter((e=>{const i=e.deref();return!!i&&t(i)}));i.set(e,n)}pt(i)},reset:()=>{i.forEach((e=>{e.forEach((e=>{const i=e.deref();i&&t(i)}))})),pt(i)}}})()),i};class wt{constructor(){this.store=vt({loadStripeStatus:"",applicationName:"stripe-pwa-elements",isCheckoutSession:!1}),this.initGeneration=0,this.changeListeners=new Map}get state(){return this.store.state}onChange(t,e){const i=this.store.onChange(t,e);return this.changeListeners.has(t)||this.changeListeners.set(t,[]),this.changeListeners.get(t).push(i),i}async initialize(t,i){const s=++this.initGeneration,n=null!=this.store.state.stripe&&!this.store.state.isCheckoutSession&&this.store.state.publishableKey===t&&this.store.state.stripeAccount===(null==i?void 0:i.stripeAccount)&&this.intentClientSecret===(null==i?void 0:i.clientSecret);if(this.store.state.publishableKey=t,this.store.state.isCheckoutSession=!1,this.intentClientSecret=null==i?void 0:i.clientSecret,null!=(null==i?void 0:i.stripeAccount)&&""!==(null==i?void 0:i.stripeAccount)&&(this.store.state.stripeAccount=i.stripeAccount),null!=(null==i?void 0:i.applicationName)&&""!==(null==i?void 0:i.applicationName)&&(this.store.state.applicationName=i.applicationName),!n){this.store.state.loadStripeStatus="loading";try{const n=await e(t,{stripeAccount:null==i?void 0:i.stripeAccount});if(s!==this.initGeneration)return;n.registerAppInfo({name:this.store.state.applicationName}),this.store.state.stripe=n,this.store.state.elements=null!=(null==i?void 0:i.clientSecret)&&""!==i.clientSecret?n.elements({clientSecret:i.clientSecret}):n.elements(),this.store.state.checkout=void 0,this.store.state.loadStripeStatus="success"}catch(t){console.error("Failed to load Stripe.js:",t),this.store.state.loadStripeStatus="failure"}}}async initializeWithCheckoutSession(t,i,s){const n=++this.initGeneration;this.store.state.publishableKey=t,this.store.state.isCheckoutSession=!0,null!=(null==s?void 0:s.stripeAccount)&&""!==(null==s?void 0:s.stripeAccount)&&(this.store.state.stripeAccount=s.stripeAccount),null!=(null==s?void 0:s.applicationName)&&""!==(null==s?void 0:s.applicationName)&&(this.store.state.applicationName=s.applicationName),this.store.state.loadStripeStatus="loading";try{const r=await e(t,{stripeAccount:null==s?void 0:s.stripeAccount});if(n!==this.initGeneration)return;r.registerAppInfo({name:this.store.state.applicationName}),this.store.state.stripe=r;const o=r.initCheckoutElementsSdk({clientSecret:i,elementsOptions:null==s?void 0:s.elementsOptions});this.store.state.checkout=o,this.store.state.elements=void 0,this.store.state.loadStripeStatus="success"}catch(t){console.error("Failed to initialize Stripe Checkout:",t),this.store.state.loadStripeStatus="failure"}}getStripe(){return this.store.state.stripe}getElements(){return this.store.state.elements}getCheckout(){return this.store.state.checkout}reset(){this.store.reset()}dispose(){this.changeListeners.forEach((t=>{t.forEach((t=>t()))})),this.changeListeners.clear(),this.store.dispose()}}function bt(t,e,i=5e3){return new Promise(((s,n)=>{const r=t.querySelector(e);if(null!=r)return s(r);const o=setTimeout((()=>{a.disconnect(),n(new Error(`Element "${e}" not found within ${i}ms`))}),i),a=new MutationObserver((()=>{const i=t.querySelector(e);null!=i&&(clearTimeout(o),a.disconnect(),s(i))}));a.observe(t,{childList:!0,subtree:!0})}))}new wt;class St{constructor(t){this.stripeService=t,this.store=vt({errorMessage:"",errorSource:void 0})}getState(){return this.store.state}async initialize(t){const e=this.stripeService.getElements();if(null==e)throw new Error("StripeService not initialized. Call StripeService.initialize() first.");null!=this.cardElements&&this.unmount();const i=e.create("cardNumber",{placeholder:ft.t("Card Number")}),s=await bt(t,"#card-number");i.mount(s),i.on("change",this.handleCardError("cardNumber"));const n=e.create("cardExpiry"),r=await bt(t,"#card-expiry");n.mount(r),n.on("change",this.handleCardError("cardExpiry"));const o=e.create("cardCvc"),a=await bt(t,"#card-cvc");return o.mount(a),o.on("change",this.handleCardError("cardCvc")),this.cardElements={cardNumber:i,cardExpiry:n,cardCVC:o},this.cardElements}getElements(){return this.cardElements}setError(t){this.store.set("errorMessage",t)}clearError(){this.store.set("errorMessage",""),this.store.set("errorSource",void 0)}unmount(){var t,e,i;null!=this.cardElements&&(null===(t=this.cardElements.cardNumber)||void 0===t||t.unmount(),null===(e=this.cardElements.cardExpiry)||void 0===e||e.unmount(),null===(i=this.cardElements.cardCVC)||void 0===i||i.unmount(),this.cardElements=void 0)}handleCardError(t){return({error:e})=>{if(e)return this.store.set("errorMessage",e.message),void this.store.set("errorSource",t);this.store.state.errorSource===t&&(this.store.set("errorMessage",""),this.store.set("errorSource",void 0))}}}class $t{constructor(t){this.stripeService=t,this.store=vt({errorMessage:""})}getState(){return this.store.state}async initialize(t,e){const i=this.stripeService.state.isCheckoutSession;if(null!=this.paymentElement&&this.unmount(),i){const t=this.stripeService.getCheckout();if(null==t)throw new Error("StripeService not initialized with Checkout Session. Call StripeService.initializeWithCheckoutSession() first.");this.paymentElement=t.createPaymentElement(e)}else{const t=this.stripeService.getElements();if(null==t)throw new Error("StripeService not initialized. Call StripeService.initialize() first.");this.paymentElement=t.create("payment",e||{})}const s=await bt(t,"#payment-element");return this.paymentElement.mount(s),this.paymentElement}getElement(){return this.paymentElement}setError(t){this.store.set("errorMessage",t)}clearError(){this.store.set("errorMessage","")}unmount(){null!=this.paymentElement&&(this.paymentElement.unmount(),this.paymentElement=void 0)}}class xt{constructor(t){this.stripeService=t,this.store=vt({errorMessage:"",isComplete:!1})}getState(){return this.store.state}async initialize(t,e){const i=this.stripeService.getElements();if(null==i)throw new Error("StripeService not initialized. Call StripeService.initialize() first.");null!=this.addressElement&&this.unmount(),this.addressElement=i.create("address",e||{mode:"billing"});const s=await bt(t,"#address-element");return this.addressElement.mount(s),this.addressElement.on("change",(t=>{this.store.set("errorMessage",""),this.store.set("isComplete",t.complete)})),this.addressElement}getElement(){return this.addressElement}setError(t){this.store.set("errorMessage",t)}clearError(){this.store.set("errorMessage","")}unmount(){null!=this.addressElement&&(this.addressElement.unmount(),this.addressElement=void 0)}}class kt{constructor(t){this.stripeService=t,this.store=vt({errorMessage:"",email:void 0})}getState(){return this.store.state}onChange(t,e){return this.store.onChange(t,e)}async initialize(t,e){const i=this.stripeService.getElements();if(null==i)throw new Error("StripeService not initialized. Call StripeService.initialize() first.");null!=this.linkAuthenticationElement&&this.unmount();const s=i.create("linkAuthentication",e),n=await bt(t,"#link-authentication-element");return s.mount(n),s.on("change",(t=>{var e;this.store.set("email",null===(e=t.value)||void 0===e?void 0:e.email)})),this.linkAuthenticationElement=s,this.linkAuthenticationElement}getElement(){return this.linkAuthenticationElement}setError(t){this.store.set("errorMessage",t)}clearError(){this.store.set("errorMessage","")}unmount(){null!=this.linkAuthenticationElement&&(this.linkAuthenticationElement.unmount(),this.linkAuthenticationElement=void 0)}}class Ct{constructor(t){this.stripeService=t,this.store=vt({errorMessage:"",selectedCurrency:void 0})}getState(){return this.store.state}async initialize(t,e){const i=this.stripeService.getElements();if(null==i)throw new Error("StripeService not initialized. Call StripeService.initialize() first.");null!=this.currencySelectorElement&&this.unmount();const s=await bt(t,"#currency-selector");return this.currencySelectorElement=i.create("currencySelector",e||{}),this.currencySelectorElement.mount(s),this.currencySelectorElement.on("change",(t=>{var e;this.store.set("errorMessage",""),(null===(e=null==t?void 0:t.value)||void 0===e?void 0:e.currency)&&this.store.set("selectedCurrency",t.value.currency)})),this.currencySelectorElement}getElement(){return this.currencySelectorElement}setError(t){this.store.set("errorMessage",t)}clearError(){this.store.set("errorMessage","")}unmount(){null!=this.currencySelectorElement&&(this.currencySelectorElement.unmount(),this.currencySelectorElement=void 0)}}class jt{constructor(t){this.stripeService=t,this.store=vt({errorMessage:"",isReady:!1})}getState(){return this.store.state}async initialize(t,e,i){const s=this.stripeService.getElements();if(null==s)throw new Error("StripeService not initialized. Call StripeService.initialize() first.");null!=this.expressCheckoutElement&&this.unmount();const n=Object.assign({},e);if(n.buttonHeight&&"string"==typeof n.buttonHeight){const t=parseInt(n.buttonHeight.replace("px",""),10);isNaN(t)||(n.buttonHeight=t)}const r=s.create("expressCheckout",n),o=await bt(t,"#express-checkout-element");return null!=(null==i?void 0:i.onConfirm)&&r.on("confirm",i.onConfirm),null!=(null==i?void 0:i.onClick)&&r.on("click",i.onClick),null!=(null==i?void 0:i.onCancel)&&r.on("cancel",i.onCancel),null!=(null==i?void 0:i.onShippingAddressChange)&&r.on("shippingaddresschange",i.onShippingAddressChange),null!=(null==i?void 0:i.onShippingRateChange)&&r.on("shippingratechange",i.onShippingRateChange),r.on("ready",(()=>{this.store.set("isReady",!0)})),r.mount(o),this.expressCheckoutElement=r,this.expressCheckoutElement}getElement(){return this.expressCheckoutElement}update(t){if(null==this.expressCheckoutElement)return void console.warn("Express Checkout Element not initialized. Cannot update options.");const e=Object.assign({},t);if(e.buttonHeight&&"string"==typeof e.buttonHeight){const t=parseInt(e.buttonHeight.replace("px",""),10);isNaN(t)||(e.buttonHeight=t)}this.expressCheckoutElement.update(e)}setError(t){this.store.set("errorMessage",t)}clearError(){this.store.set("errorMessage","")}unmount(){null!=this.expressCheckoutElement&&(this.expressCheckoutElement.unmount(),this.expressCheckoutElement=void 0,this.store.set("isReady",!1))}}const Et=new class{createStripeService(){return new wt}createCardElementManager(t){return new St(t)}createPaymentElementManager(t){return new $t(t)}createAddressElementManager(t){return new xt(t)}createLinkAuthenticationElementManager(t){return new kt(t)}createCurrencySelectorElementManager(t){return new Ct(t)}createExpressCheckoutElementManager(t){return new jt(t)}};export{ft as i,Et as s}
@@ -1 +1 @@
1
- import{transformTag as t,proxyCustomElement as e,HTMLElement as s,createEvent as i,h as r}from"@stencil/core/internal/client";import{c as o}from"./utils.js";import{s as a,i as n}from"./factory.js";const l=e(class extends s{async initStripe(t,e){if(await this.stripeService.initialize(t,{stripeAccount:null==e?void 0:e.stripeAccount,applicationName:this.applicationName}),"success"===this.stripeService.state.loadStripeStatus)await this.initElement(),this.stripeLoadedEventHandler();else{const t=this.stripeService.onChange("loadStripeStatus",(async e=>{"success"===e&&(await this.initElement(),this.stripeLoadedEventHandler(),t())}))}}async updateProgress(t){return this.progress=t,this}async setErrorMessage(t){return this.addressElementManager.setError(t),this}async getValue(){const t=this.addressElementManager.getElement();if(null==t)throw Error("Address element not initialized");return await t.getValue({format:"localized"})}updatePublishableKey(t){const e={};null!=this.stripeAccount&&""!==this.stripeAccount&&(e.stripeAccount=this.stripeAccount),this.initStripe(t,Object.keys(e).length>0?e:void 0)}updateStripeAccountId(t){const e=this.stripeService.state.publishableKey||this.publishableKey;null!=e&&""!==e&&this.initStripe(e,{stripeAccount:t})}stripeLoadedEventHandler(){const t={stripe:this.stripeService.getStripe()};null!=this.stripeDidLoaded&&this.stripeDidLoaded(t),this.stripeLoaded.emit(t)}async formSubmitEventHandler(){const t=await this.getValue();this.formSubmit.emit({address:t})}componentWillRender(){null!=this.stripeService.state.publishableKey&&""!==this.stripeService.state.publishableKey&&(["success","loading"].includes(this.stripeService.state.loadStripeStatus)||this.initStripe(this.stripeService.state.publishableKey,{stripeAccount:this.stripeService.state.stripeAccount}))}constructor(t){super(),!1!==t&&this.__registerHost(),this.stripeLoaded=i(this,"stripeLoaded",7),this.formSubmit=i(this,"formSubmit",7),this.mode="billing",this.sheetTitle="Billing address",this.buttonLabel="Save",this.progress="",this.applicationName="stripe-pwa-elements",this.showLabel=!1,this.stripeService=a.createStripeService(),this.addressElementManager=a.createAddressElementManager(this.stripeService),null!=this.publishableKey&&""!==this.publishableKey&&this.initStripe(this.publishableKey,{stripeAccount:this.stripeAccount})}async initElement(){const t={mode:this.mode};null!=this.defaultCountry&&""!==this.defaultCountry&&(t.defaultValues={address:{country:this.defaultCountry}}),this.allowedCountries&&this.allowedCountries.length>0&&(t.allowedCountries=this.allowedCountries),await this.addressElementManager.initialize(this.el,t);const e=this.el.querySelector("#stripe-address-element-form");null!=e?(null!=this.formSubmitListener&&e.removeEventListener("submit",this.formSubmitListener),this.formSubmitListener=async t=>{if(t.preventDefault(),null!=this.addressElementManager.getElement()){this.progress="loading";try{const e=await this.getValue();null!=this.handleSubmit&&await this.handleSubmit(t,{address:e}),await this.formSubmitEventHandler(),null!=this.handleSubmit&&(this.progress="success")}catch(t){this.addressElementManager.setError(t instanceof Error?t.message:t+""),this.progress="failure"}}else console.error("Address element not initialized")},e.addEventListener("submit",this.formSubmitListener)):console.error("Form element #stripe-address-element-form not found")}componentDidLoad(){this.el.classList.add(o())}disconnectedCallback(){if(null!=this.formSubmitListener){const t=this.el.querySelector("#stripe-address-element-form");null!=t&&t.removeEventListener("submit",this.formSubmitListener),this.formSubmitListener=void 0}this.addressElementManager.unmount()}render(){const{loadStripeStatus:t}=this.stripeService.state,{errorMessage:e}=this.addressElementManager.getState();if("failure"===t)return r("p",null,n.t("Failed to load Stripe"));const s="loading"===this.progress;return r("div",{class:"stripe-payment-sheet-wrap"},r("form",{id:"stripe-address-element-form"},r("div",{class:"stripe-heading"},n.t(this.sheetTitle)),r("div",{class:"payment-info address visible"},r("div",{id:"address-element"})),r("div",{id:"address-errors",class:"stripe-element-errors"},e),r("div",{class:"submit-button-wrapper"},r("button",{type:"submit",disabled:s},n.t("loading"===this.progress?"Loading":this.buttonLabel)))))}get el(){return this}static get watchers(){return{publishableKey:[{updatePublishableKey:0}],stripeAccount:[{updateStripeAccountId:0}]}}static get style(){return':root{--color-label:#565656;--color-placeholder:#acacac;--color-heading-text:#333;--color-text-error:#ef4444;--color-input-border:#e4e4e6;--color-input-border-shadow:rgba(228, 228, 230, 0.6);--color-button-text:rgba(255, 255, 255, 0.95);--color-button-text-disabled:rgba(255, 255, 255, 0.4);--color-primary:#0074d4}.stripe-payment-sheet-wrap{box-sizing:border-box}.stripe-payment-sheet-wrap *:where(:not(iframe,canvas,img,svg,video):not(svg *)){all:unset;display:revert;background:none;border:none;font-family:"Roboto", sans-serif;box-sizing:border-box}.stripe-payment-sheet-wrap button{cursor:pointer}.stripe-payment-sheet-wrap{display:block;width:100%;background:#fff;padding:32px 16px}.stripe-payment-sheet-wrap #address-element{margin-top:16px}.stripe-payment-sheet-wrap .stripe-heading{font-size:24px;font-weight:bold;color:var(--color-heading-text);margin-bottom:24px}.stripe-payment-sheet-wrap .stripe-section-title{font-size:14px;font-weight:bold;color:var(--color-label);margin-bottom:8px}.stripe-payment-sheet-wrap .payment-info.address{margin-bottom:16px}.stripe-payment-sheet-wrap .stripe-element-errors{margin-top:8px;font-size:14px;color:var(--color-text-error)}.stripe-payment-sheet-wrap .submit-button-wrapper{margin-top:32px}.stripe-payment-sheet-wrap button{display:block;color:var(--color-button-text);background-color:var(--color-primary);width:100%;text-align:center;padding:16px 16px;font-size:18px;border-radius:6px;min-height:42px}.stripe-payment-sheet-wrap button:disabled{color:var(--color-button-text-disabled)}'}},[0,"stripe-address-element",{mode:[1],sheetTitle:[1,"sheet-title"],buttonLabel:[1,"button-label"],publishableKey:[1,"publishable-key"],stripeAccount:[1,"stripe-account"],applicationName:[1,"application-name"],showLabel:[4,"show-label"],defaultCountry:[1,"default-country"],allowedCountries:[16],handleSubmit:[1040],stripeDidLoaded:[1040],progress:[32],initStripe:[64],updateProgress:[64],setErrorMessage:[64],getValue:[64]},void 0,{publishableKey:[{updatePublishableKey:0}],stripeAccount:[{updateStripeAccountId:0}]}]);function p(){"undefined"!=typeof customElements&&["stripe-address-element"].forEach((e=>{"stripe-address-element"===e&&(customElements.get(t(e))||customElements.define(t(e),l))}))}p();const d=l,h=p;export{d as StripeAddressElement,h as defineCustomElement}
1
+ import{transformTag as t,proxyCustomElement as e,HTMLElement as s,createEvent as i,h as r}from"@stencil/core/internal/client";import{c as o}from"./utils.js";import{s as a,i as n}from"./factory.js";const l=e(class extends s{async initStripe(t,e){if(await this.stripeService.initialize(t,{stripeAccount:null==e?void 0:e.stripeAccount,applicationName:this.applicationName}),"success"===this.stripeService.state.loadStripeStatus)await this.initElement(),this.stripeLoadedEventHandler();else{const t=this.stripeService.onChange("loadStripeStatus",(async e=>{"success"===e&&(await this.initElement(),this.stripeLoadedEventHandler(),t())}))}}async updateProgress(t){return this.progress=t,this}async setErrorMessage(t){return this.addressElementManager.setError(t),this}async getValue(){const t=this.addressElementManager.getElement();if(null==t)throw Error("Address element not initialized");return await t.getValue({format:"localized"})}updatePublishableKey(t){const e={};null!=this.stripeAccount&&""!==this.stripeAccount&&(e.stripeAccount=this.stripeAccount),this.initStripe(t,Object.keys(e).length>0?e:void 0)}updateStripeAccountId(t){const e=this.stripeService.state.publishableKey||this.publishableKey;null!=e&&""!==e&&this.initStripe(e,{stripeAccount:t})}stripeLoadedEventHandler(){const t={stripe:this.stripeService.getStripe()};null!=this.stripeDidLoaded&&this.stripeDidLoaded(t),this.stripeLoaded.emit(t)}async formSubmitEventHandler(){const t=await this.getValue();this.formSubmit.emit({address:t})}componentWillRender(){null!=this.stripeService.state.publishableKey&&""!==this.stripeService.state.publishableKey&&(["success","loading"].includes(this.stripeService.state.loadStripeStatus)||this.initStripe(this.stripeService.state.publishableKey,{stripeAccount:this.stripeService.state.stripeAccount}))}constructor(t){super(),!1!==t&&this.__registerHost(),this.stripeLoaded=i(this,"stripeLoaded",7),this.formSubmit=i(this,"formSubmit",7),this.mode="billing",this.sheetTitle="Billing address",this.buttonLabel="Save",this.progress="",this.applicationName="stripe-pwa-elements",this.showLabel=!1,this.stripeService=a.createStripeService(),this.addressElementManager=a.createAddressElementManager(this.stripeService)}componentWillLoad(){null!=this.publishableKey&&""!==this.publishableKey&&this.initStripe(this.publishableKey,{stripeAccount:this.stripeAccount})}async initElement(){const t={mode:this.mode};null!=this.defaultCountry&&""!==this.defaultCountry&&(t.defaultValues={address:{country:this.defaultCountry}}),this.allowedCountries&&this.allowedCountries.length>0&&(t.allowedCountries=this.allowedCountries),await this.addressElementManager.initialize(this.el,t);const e=this.el.querySelector("#stripe-address-element-form");null!=e?(null!=this.formSubmitListener&&e.removeEventListener("submit",this.formSubmitListener),this.formSubmitListener=async t=>{if(t.preventDefault(),null!=this.addressElementManager.getElement()){this.progress="loading";try{const e=await this.getValue();null!=this.handleSubmit&&await this.handleSubmit(t,{address:e}),await this.formSubmitEventHandler(),null!=this.handleSubmit&&(this.progress="success")}catch(t){this.addressElementManager.setError(t instanceof Error?t.message:t+""),this.progress="failure"}}else console.error("Address element not initialized")},e.addEventListener("submit",this.formSubmitListener)):console.error("Form element #stripe-address-element-form not found")}componentDidLoad(){this.el.classList.add(o())}disconnectedCallback(){if(null!=this.formSubmitListener){const t=this.el.querySelector("#stripe-address-element-form");null!=t&&t.removeEventListener("submit",this.formSubmitListener),this.formSubmitListener=void 0}this.addressElementManager.unmount()}render(){const{loadStripeStatus:t}=this.stripeService.state,{errorMessage:e}=this.addressElementManager.getState();if("failure"===t)return r("p",null,n.t("Failed to load Stripe"));const s="loading"===this.progress;return r("div",{class:"stripe-payment-sheet-wrap"},r("form",{id:"stripe-address-element-form"},r("div",{class:"stripe-heading"},n.t(this.sheetTitle)),r("div",{class:"payment-info address visible"},r("div",{id:"address-element"})),r("div",{id:"address-errors",class:"stripe-element-errors"},e),r("div",{class:"submit-button-wrapper"},r("button",{type:"submit",disabled:s},n.t("loading"===this.progress?"Loading":this.buttonLabel)))))}get el(){return this}static get watchers(){return{publishableKey:[{updatePublishableKey:0}],stripeAccount:[{updateStripeAccountId:0}]}}static get style(){return':root{--color-label:#565656;--color-placeholder:#acacac;--color-heading-text:#333;--color-text-error:#ef4444;--color-input-border:#e4e4e6;--color-input-border-shadow:rgba(228, 228, 230, 0.6);--color-button-text:rgba(255, 255, 255, 0.95);--color-button-text-disabled:rgba(255, 255, 255, 0.4);--color-primary:#0074d4}.stripe-payment-sheet-wrap{box-sizing:border-box}.stripe-payment-sheet-wrap *:where(:not(iframe,canvas,img,svg,video):not(svg *)){all:unset;display:revert;background:none;border:none;font-family:"Roboto", sans-serif;box-sizing:border-box}.stripe-payment-sheet-wrap button{cursor:pointer}.stripe-payment-sheet-wrap{display:block;width:100%;background:#fff;padding:32px 16px}.stripe-payment-sheet-wrap #address-element{margin-top:16px}.stripe-payment-sheet-wrap .stripe-heading{font-size:24px;font-weight:bold;color:var(--color-heading-text);margin-bottom:24px}.stripe-payment-sheet-wrap .stripe-section-title{font-size:14px;font-weight:bold;color:var(--color-label);margin-bottom:8px}.stripe-payment-sheet-wrap .payment-info.address{margin-bottom:16px}.stripe-payment-sheet-wrap .stripe-element-errors{margin-top:8px;font-size:14px;color:var(--color-text-error)}.stripe-payment-sheet-wrap .submit-button-wrapper{margin-top:32px}.stripe-payment-sheet-wrap button{display:block;color:var(--color-button-text);background-color:var(--color-primary);width:100%;text-align:center;padding:16px 16px;font-size:18px;border-radius:6px;min-height:42px}.stripe-payment-sheet-wrap button:disabled{color:var(--color-button-text-disabled)}'}},[0,"stripe-address-element",{mode:[1],sheetTitle:[1,"sheet-title"],buttonLabel:[1,"button-label"],publishableKey:[1,"publishable-key"],stripeAccount:[1,"stripe-account"],applicationName:[1,"application-name"],showLabel:[4,"show-label"],defaultCountry:[1,"default-country"],allowedCountries:[16],handleSubmit:[1040],stripeDidLoaded:[1040],progress:[32],initStripe:[64],updateProgress:[64],setErrorMessage:[64],getValue:[64]},void 0,{publishableKey:[{updatePublishableKey:0}],stripeAccount:[{updateStripeAccountId:0}]}]);function p(){"undefined"!=typeof customElements&&["stripe-address-element"].forEach((e=>{"stripe-address-element"===e&&(customElements.get(t(e))||customElements.define(t(e),l))}))}p();const d=l,h=p;export{d as StripeAddressElement,h as defineCustomElement}
@@ -1 +1 @@
1
- import{transformTag as e,proxyCustomElement as t,HTMLElement as s,createEvent as i,h as n}from"@stencil/core/internal/client";import{d as r}from"./icon.js";import{d as o}from"./stripe-card-element2.js";import{d as a}from"./stripe-modal2.js";import{d as l}from"./stripe-payment-request-button2.js";const m=t(class extends s{constructor(e){super(),!1!==e&&this.__registerHost(),this.closed=i(this,"closed",7),this.showLabel=!1,this.shouldUseDefaultFormSubmitAction=!0,this.intentType="payment",this.showCloseButton=!0,this.zip=!0,this.open=!1}componentDidLoad(){this.el.querySelector("stripe-modal").addEventListener("close",(()=>{this.closed.emit()}))}async getStripeCardElementElement(){return this.el.querySelector("stripe-card-element")}async present(){return this.open=!0,new Promise(((e,t)=>{this.el.querySelector("stripe-card-element").addEventListener("formSubmit",(async t=>{e(t)})),this.el.addEventListener("closed",(()=>t()))}))}async updateProgress(e){return this.el.querySelector("stripe-card-element").updateProgress(e)}async destroy(){this.el.querySelector("stripe-card-element").remove(),this.el.remove()}async setPaymentRequestButton(e){const t=this.el.getElementsByTagName("stripe-card-element");if(t.length<1)return;const s=t[0];s&&(s.setAttribute("show-payment-request-button","true"),this.applicationName&&s.setAttribute("application-name",this.applicationName),s.setPaymentRequestOption(e))}render(){return n("stripe-modal",{key:"236b4910e4f2ff792def134e7726623f2a09475e",open:this.open,showCloseButton:this.showCloseButton},n("stripe-card-element",{key:"5748af4f6df67571289236435c7481d6f445fce8",showLabel:this.showLabel,publishableKey:this.publishableKey,intentClientSecret:this.intentClientSecret,shouldUseDefaultFormSubmitAction:this.shouldUseDefaultFormSubmitAction,handleSubmit:this.handleSubmit,stripeDidLoaded:this.stripeDidLoaded,intentType:this.intentType,zip:this.zip,buttonLabel:this.buttonLabel,sheetTitle:this.sheetTitle,applicationName:this.applicationName}))}get el(){return this}static get style(){return"stripe-card-element-modal{display:block}"}},[0,"stripe-card-element-modal",{publishableKey:[1,"publishable-key"],stripeAccount:[1,"stripe-account"],applicationName:[1,"application-name"],showLabel:[4,"show-label"],sheetTitle:[1,"sheet-title"],buttonLabel:[1,"button-label"],intentClientSecret:[1,"intent-client-secret"],shouldUseDefaultFormSubmitAction:[4,"should-use-default-form-submit-action"],intentType:[1,"intent-type"],handleSubmit:[1040],stripeDidLoaded:[1040],showCloseButton:[4,"show-close-button"],zip:[4],open:[4],getStripeCardElementElement:[64],present:[64],updateProgress:[64],destroy:[64],setPaymentRequestButton:[64]}]);function c(){"undefined"!=typeof customElements&&["stripe-card-element-modal","ion-icon","stripe-card-element","stripe-modal","stripe-payment-request-button"].forEach((t=>{switch(t){case"stripe-card-element-modal":customElements.get(e(t))||customElements.define(e(t),m);break;case"ion-icon":customElements.get(e(t))||r();break;case"stripe-card-element":customElements.get(e(t))||o();break;case"stripe-modal":customElements.get(e(t))||a();break;case"stripe-payment-request-button":customElements.get(e(t))||l()}}))}c();const p=m,u=c;export{p as StripeCardElementModal,u as defineCustomElement}
1
+ import{transformTag as e,proxyCustomElement as t,HTMLElement as s,createEvent as i,h as n}from"@stencil/core/internal/client";import{d as r}from"./icon.js";import{d as o}from"./stripe-card-element2.js";import{d as a}from"./stripe-modal2.js";import{d as l}from"./stripe-payment-request-button2.js";const c=t(class extends s{constructor(e){super(),!1!==e&&this.__registerHost(),this.closed=i(this,"closed",7),this.showLabel=!1,this.shouldUseDefaultFormSubmitAction=!0,this.intentType="payment",this.showCloseButton=!0,this.zip=!0,this.open=!1}componentDidLoad(){this.el.querySelector("stripe-modal").addEventListener("close",(()=>{this.closed.emit()}))}async getStripeCardElementElement(){return this.el.querySelector("stripe-card-element")}async present(){return this.open=!0,new Promise(((e,t)=>{this.el.querySelector("stripe-card-element").addEventListener("formSubmit",(async t=>{e(t)})),this.el.addEventListener("closed",(()=>t()))}))}async updateProgress(e){return this.el.querySelector("stripe-card-element").updateProgress(e)}async destroy(){this.el.querySelector("stripe-card-element").remove(),this.el.remove()}async setPaymentRequestButton(e){const t=this.el.getElementsByTagName("stripe-card-element");if(t.length<1)return;const s=t[0];s&&(s.setAttribute("show-payment-request-button","true"),this.applicationName&&s.setAttribute("application-name",this.applicationName),s.setPaymentRequestOption(e))}render(){return n("stripe-modal",{key:"a0229c55472e3c6f417086fa08d79e1ec8a8c485",open:this.open,showCloseButton:this.showCloseButton},n("stripe-card-element",{key:"799f08c781bad089cec8b1338e9a714d080abd51",showLabel:this.showLabel,publishableKey:this.publishableKey,intentClientSecret:this.intentClientSecret,shouldUseDefaultFormSubmitAction:this.shouldUseDefaultFormSubmitAction,handleSubmit:this.handleSubmit,stripeDidLoaded:this.stripeDidLoaded,intentType:this.intentType,zip:this.zip,buttonLabel:this.buttonLabel,sheetTitle:this.sheetTitle,applicationName:this.applicationName}))}get el(){return this}static get style(){return"stripe-card-element-modal{display:block}"}},[0,"stripe-card-element-modal",{publishableKey:[1,"publishable-key"],stripeAccount:[1,"stripe-account"],applicationName:[1,"application-name"],showLabel:[4,"show-label"],sheetTitle:[1,"sheet-title"],buttonLabel:[1,"button-label"],intentClientSecret:[1,"intent-client-secret"],shouldUseDefaultFormSubmitAction:[4,"should-use-default-form-submit-action"],intentType:[1,"intent-type"],handleSubmit:[1040],stripeDidLoaded:[1040],showCloseButton:[4,"show-close-button"],zip:[4],open:[4],getStripeCardElementElement:[64],present:[64],updateProgress:[64],destroy:[64],setPaymentRequestButton:[64]}]);function m(){"undefined"!=typeof customElements&&["stripe-card-element-modal","ion-icon","stripe-card-element","stripe-modal","stripe-payment-request-button"].forEach((t=>{switch(t){case"stripe-card-element-modal":customElements.get(e(t))||customElements.define(e(t),c);break;case"ion-icon":customElements.get(e(t))||r();break;case"stripe-card-element":customElements.get(e(t))||o();break;case"stripe-modal":customElements.get(e(t))||a();break;case"stripe-payment-request-button":customElements.get(e(t))||l()}}))}m();const p=c,d=m;export{p as StripeCardElementModal,d as defineCustomElement}
@@ -1 +1 @@
1
- import{transformTag as t,proxyCustomElement as e,HTMLElement as i,createEvent as s,h as n}from"@stencil/core/internal/client";import{c as r}from"./utils.js";import{s as o,i as l}from"./factory.js";import{S as a}from"./error.js";import{d as p}from"./stripe-payment-request-button2.js";const u=t=>{if(null!=t&&""!==t)return{stripeAccount:t}},d=e(class extends i{async initStripe(t,e){if(await this.stripeService.initialize(t,{stripeAccount:null==e?void 0:e.stripeAccount,applicationName:this.applicationName}),"success"===this.stripeService.state.loadStripeStatus)await this.initElement(),this.stripeLoadedEventHandler();else{const t=this.stripeService.onChange("loadStripeStatus",(async e=>{"success"===e&&(await this.initElement(),this.stripeLoadedEventHandler(),t())}))}}async updateProgress(t){return this.progress=t,this}async setErrorMessage(t){return this.cardElementManager.setError(t),this}updatePublishableKey(t){null!=t&&""!==t&&this.initStripe(t,u(this.stripeAccount))}updateStripeAccountId(t){const e=this.stripeService.state.publishableKey||this.publishableKey;null!=e&&""!==e&&this.initStripe(e,{stripeAccount:t})}async setPaymentRequestOption(t){return this.paymentRequestOption=t,this.createPaymentRequestButton(),this}stripeLoadedEventHandler(){const t={stripe:this.stripeService.getStripe()};null!=this.stripeDidLoaded&&this.stripeDidLoaded(t),this.stripeLoaded.emit(t)}async formSubmitEventHandler(){const t=this.cardElementManager.getElements(),e=this.stripeService.getStripe();null!=t?this.formSubmit.emit({cardCVCElement:t.cardCVC,cardExpiryElement:t.cardExpiry,cardNumberElement:t.cardNumber,stripe:e}):console.error("Card elements not initialized")}async defaultFormSubmitResultHandler(t){this.defaultFormSubmitResult.emit(t)}componentWillRender(){const{publishableKey:t}=this.stripeService.state;null!=t&&""!==t&&(["success","loading"].includes(this.stripeService.state.loadStripeStatus)||this.initStripe(t,u(this.stripeService.state.stripeAccount)))}async defaultFormSubmitAction(t,{stripe:e,cardNumberElement:i,intentClientSecret:s}){t.preventDefault();try{const t=await((t,e,i,s)=>"payment"===this.intentType?t.confirmCardPayment(i,{payment_method:{card:s}}):t.confirmCardSetup(i,{payment_method:{card:s}}))(e,0,s,i);if(null!=t.error)throw new a(t.error);this.defaultFormSubmitResultHandler(t)}catch(t){throw console.error(t),this.defaultFormSubmitResultHandler(t),t}}constructor(t){super(),!1!==t&&this.__registerHost(),this.stripeLoaded=s(this,"stripeLoaded",7),this.formSubmit=s(this,"formSubmit",7),this.defaultFormSubmitResult=s(this,"defaultFormSubmitResult",7),this.paymentRequestButtonCreated=!1,this.intentType="payment",this.zip=!0,this.sheetTitle="Add your payment information",this.buttonLabel="Pay",this.progress="",this.zipCode="",this.applicationName="stripe-pwa-elements",this.showLabel=!1,this.shouldUseDefaultFormSubmitAction=!0,this.stripeService=o.createStripeService(),this.cardElementManager=o.createCardElementManager(this.stripeService),null!=this.publishableKey&&""!==this.publishableKey&&this.initStripe(this.publishableKey,u(this.stripeAccount))}async initElement(){await this.cardElementManager.initialize(this.el);const t=this.el.querySelector("#stripe-card-element");null!=t?t.addEventListener("submit",(async t=>{const e=this.cardElementManager.getElements(),i=this.stripeService.getStripe(),{intentClientSecret:s}=this;if(null==e||null==i)return void console.error("Stripe not properly initialized");const n={cardCVCElement:e.cardCVC,cardExpiryElement:e.cardExpiry,cardNumberElement:e.cardNumber,stripe:i,intentClientSecret:s,zipCode:this.zipCode};this.progress="loading";try{null!=this.handleSubmit?await this.handleSubmit(t,n):!0===this.shouldUseDefaultFormSubmitAction&&null!=s&&""!==s?await this.defaultFormSubmitAction(t,n):t.preventDefault(),await this.formSubmitEventHandler(),null==this.handleSubmit&&!0!==this.shouldUseDefaultFormSubmitAction||(this.progress="success")}catch(t){this.cardElementManager.setError(t.message),this.progress="failure"}})):console.error("Form element #stripe-card-element not found")}componentDidLoad(){this.el.classList.add(r())}componentDidRender(){this.showPaymentRequestButton&&this.paymentRequestOption&&!this.paymentRequestButtonCreated&&this.createPaymentRequestButton()}disconnectedCallback(){this.cardElementManager.unmount()}createPaymentRequestButton(){const{showPaymentRequestButton:t,paymentRequestOption:e}=this;if(this.paymentRequestButtonCreated)return null;if(!t||null==e)return null;if(null==document)return null;const i=this.el.querySelector("#stripe-payment-request-button");if(null==i)return console.error("Target element #stripe-payment-request-button not found"),null;if(null!=i.querySelector("stripe-payment-request-button"))return this.paymentRequestButtonCreated=!0,null;const s=document.createElement("stripe-payment-request-button");i.appendChild(s),customElements.whenDefined("stripe-payment-request-button").then((()=>(((t,e)=>{const{paymentRequestPaymentMethodHandler:i,paymentRequestShippingOptionChangeHandler:s,paymentRequestShippingAddressChangeHandler:n}=e;t.setPaymentRequestOption(e),null!=i&&t.setPaymentMethodEventHandler(i),null!=s&&t.setPaymentRequestShippingOptionEventHandler(s),null!=n&&t.setPaymentRequestShippingAddressEventHandler(n)})(s,e),s.initStripe(this.publishableKey)))),this.paymentRequestButtonCreated=!0}render(){const{loadStripeStatus:t}=this.stripeService.state,{errorMessage:e}=this.cardElementManager.getState();if("failure"===t)return n("p",null,l.t("Failed to load Stripe"));const i="loading"===this.progress;return n("div",{class:"stripe-payment-sheet-wrap"},n("form",{id:"stripe-card-element"},n("div",{class:"stripe-heading"},l.t(this.sheetTitle)),n("div",{id:"stripe-payment-request-button"}),n("div",null,n("div",{class:"stripe-section-title"},l.t("Card information"))),n("div",{class:"payment-info card visible"},n("fieldset",{class:"stripe-input-box"},n("div",null,n("label",null,this.showLabel?n("lenged",null,l.t("Card Number")):null,n("div",{id:"card-number"}))),n("div",{class:"stripe-input-column",style:{display:"flex"}},n("label",{style:{width:"50%"}},this.showLabel?n("lenged",null,l.t("MM / YY")):null,n("div",{id:"card-expiry"})),n("label",{style:{width:"50%"}},this.showLabel?n("lenged",null,l.t("CVC")):null,n("div",{id:"card-cvc"}))))),n("div",{id:"card-errors",class:"stripe-element-errors"},e),this.zip?n("div",{style:{marginTop:"1.5rem"}},n("div",{class:"stripe-section-title"},l.t("Country or region"))):null,this.zip?n("div",{class:"payment-info card visible"},n("fieldset",{class:"stripe-input-box"},n("div",null,n("label",null,this.showLabel?n("lenged",null,l.t("Postal Code")):null,n("input",{id:"zip",name:"zip",type:"text",inputmode:"numeric",class:"StripeElement",style:{width:"100%"},placeholder:l.t("Postal Code"),value:this.zipCode,onInput:t=>{this.zipCode=t.target.value}}))))):null,n("div",{style:{marginTop:"32px"}},n("button",{type:"submit",disabled:i},l.t("loading"===this.progress?"Loading":this.buttonLabel)))))}get el(){return this}static get watchers(){return{publishableKey:[{updatePublishableKey:0}],stripeAccount:[{updateStripeAccountId:0}]}}static get style(){return':root{--color-label:#565656;--color-placeholder:#acacac;--color-heading-text:#333;--color-text-error:#ef4444;--color-input-border:#e4e4e6;--color-input-border-shadow:rgba(228, 228, 230, 0.6);--color-button-text:rgba(255, 255, 255, 0.95);--color-button-text-disabled:rgba(255, 255, 255, 0.4);--color-primary:#0074d4}.stripe-payment-sheet-wrap{box-sizing:border-box}.stripe-payment-sheet-wrap *:where(:not(iframe,canvas,img,svg,video):not(svg *)){all:unset;display:revert;background:none;border:none;font-family:"Roboto", sans-serif;box-sizing:border-box}.stripe-payment-sheet-wrap button{cursor:pointer}.stripe-payment-sheet-wrap{display:block;width:100%;background:#fff;padding:32px 16px}.stripe-payment-sheet-wrap .StripeElement{padding:8px 16px;min-height:64px;display:flex;justify-content:center;align-items:center}.stripe-payment-sheet-wrap .StripeElement>.__PrivateStripeElement{width:100%}.stripe-payment-sheet-wrap .stripe-input-box{background-color:#fff;border-radius:6px;border:1px solid var(--color-input-border);overflow:hidden;filter:drop-shadow(0 0 2px var(--color-input-border-shadow))}.stripe-payment-sheet-wrap .stripe-input-box>*{border-bottom:1px solid var(--color-input-border)}.stripe-payment-sheet-wrap .stripe-input-box>*:last-child{border-bottom:none}.stripe-payment-sheet-wrap .stripe-input-column>*{border-right:1px solid var(--color-input-border)}.stripe-payment-sheet-wrap .stripe-input-column>*:last-child{border-right:none}.stripe-payment-sheet-wrap .stripe-heading{font-size:24px;font-weight:bold;color:var(--color-heading-text);margin-bottom:24px}.stripe-payment-sheet-wrap .stripe-section-title{font-size:14px;font-weight:bold;color:var(--color-label);margin-bottom:8px}.stripe-payment-sheet-wrap .payment-info label{color:var(--color-label)}.stripe-payment-sheet-wrap .stripe-element-errors{margin-top:8px;font-size:14px;color:var(--color-text-error)}.stripe-payment-sheet-wrap button{display:block;color:var(--color-button-text);background-color:var(--color-primary);width:100%;text-align:center;padding:16px 16px;font-size:18px;border-radius:6px;min-height:42px}.stripe-payment-sheet-wrap button:disabled{color:var(--color-button-text-disabled)}'}},[0,"stripe-card-element",{intentType:[1,"intent-type"],zip:[4],sheetTitle:[1,"sheet-title"],buttonLabel:[1,"button-label"],publishableKey:[1,"publishable-key"],stripeAccount:[1,"stripe-account"],applicationName:[1,"application-name"],showLabel:[4,"show-label"],intentClientSecret:[1,"intent-client-secret"],shouldUseDefaultFormSubmitAction:[4,"should-use-default-form-submit-action"],showPaymentRequestButton:[4,"show-payment-request-button"],handleSubmit:[1040],stripeDidLoaded:[1040],progress:[32],zipCode:[32],paymentRequestOption:[32],initStripe:[64],updateProgress:[64],setErrorMessage:[64],setPaymentRequestOption:[64]},void 0,{publishableKey:[{updatePublishableKey:0}],stripeAccount:[{updateStripeAccountId:0}]}]);function c(){"undefined"!=typeof customElements&&["stripe-card-element","stripe-payment-request-button"].forEach((e=>{switch(e){case"stripe-card-element":customElements.get(t(e))||customElements.define(t(e),d);break;case"stripe-payment-request-button":customElements.get(t(e))||p()}}))}c();export{d as S,c as d}
1
+ import{transformTag as t,proxyCustomElement as e,HTMLElement as i,createEvent as s,h as n}from"@stencil/core/internal/client";import{c as r}from"./utils.js";import{s as o,i as l}from"./factory.js";import{S as a}from"./error.js";import{d as p}from"./stripe-payment-request-button2.js";const u=t=>{if(null!=t&&""!==t)return{stripeAccount:t}},d=e(class extends i{async initStripe(t,e){if(await this.stripeService.initialize(t,{stripeAccount:null==e?void 0:e.stripeAccount,applicationName:this.applicationName}),"success"===this.stripeService.state.loadStripeStatus)await this.initElement(),this.stripeLoadedEventHandler();else{const t=this.stripeService.onChange("loadStripeStatus",(async e=>{"success"===e&&(await this.initElement(),this.stripeLoadedEventHandler(),t())}))}}async updateProgress(t){return this.progress=t,this}async setErrorMessage(t){return this.cardElementManager.setError(t),this}updatePublishableKey(t){null!=t&&""!==t&&this.initStripe(t,u(this.stripeAccount))}updateStripeAccountId(t){const e=this.stripeService.state.publishableKey||this.publishableKey;null!=e&&""!==e&&this.initStripe(e,{stripeAccount:t})}async setPaymentRequestOption(t){return this.paymentRequestOption=t,this.createPaymentRequestButton(),this}stripeLoadedEventHandler(){const t={stripe:this.stripeService.getStripe()};null!=this.stripeDidLoaded&&this.stripeDidLoaded(t),this.stripeLoaded.emit(t)}async formSubmitEventHandler(){const t=this.cardElementManager.getElements(),e=this.stripeService.getStripe();null!=t?this.formSubmit.emit({cardCVCElement:t.cardCVC,cardExpiryElement:t.cardExpiry,cardNumberElement:t.cardNumber,stripe:e}):console.error("Card elements not initialized")}async defaultFormSubmitResultHandler(t){this.defaultFormSubmitResult.emit(t)}componentWillRender(){const{publishableKey:t}=this.stripeService.state;null!=t&&""!==t&&(["success","loading"].includes(this.stripeService.state.loadStripeStatus)||this.initStripe(t,u(this.stripeService.state.stripeAccount)))}async defaultFormSubmitAction(t,{stripe:e,cardNumberElement:i,intentClientSecret:s}){t.preventDefault();try{const t=await((t,e,i,s)=>"payment"===this.intentType?t.confirmCardPayment(i,{payment_method:{card:s}}):t.confirmCardSetup(i,{payment_method:{card:s}}))(e,0,s,i);if(null!=t.error)throw new a(t.error);this.defaultFormSubmitResultHandler(t)}catch(t){throw console.error(t),this.defaultFormSubmitResultHandler(t),t}}constructor(t){super(),!1!==t&&this.__registerHost(),this.stripeLoaded=s(this,"stripeLoaded",7),this.formSubmit=s(this,"formSubmit",7),this.defaultFormSubmitResult=s(this,"defaultFormSubmitResult",7),this.paymentRequestButtonCreated=!1,this.intentType="payment",this.zip=!0,this.sheetTitle="Add your payment information",this.buttonLabel="Pay",this.progress="",this.zipCode="",this.applicationName="stripe-pwa-elements",this.showLabel=!1,this.shouldUseDefaultFormSubmitAction=!0,this.stripeService=o.createStripeService(),this.cardElementManager=o.createCardElementManager(this.stripeService)}componentWillLoad(){null!=this.publishableKey&&""!==this.publishableKey&&this.initStripe(this.publishableKey,u(this.stripeAccount))}async initElement(){await this.cardElementManager.initialize(this.el);const t=this.el.querySelector("#stripe-card-element");null!=t?t.addEventListener("submit",(async t=>{const e=this.cardElementManager.getElements(),i=this.stripeService.getStripe(),{intentClientSecret:s}=this;if(null==e||null==i)return void console.error("Stripe not properly initialized");const n={cardCVCElement:e.cardCVC,cardExpiryElement:e.cardExpiry,cardNumberElement:e.cardNumber,stripe:i,intentClientSecret:s,zipCode:this.zipCode};this.progress="loading";try{null!=this.handleSubmit?await this.handleSubmit(t,n):!0===this.shouldUseDefaultFormSubmitAction&&null!=s&&""!==s?await this.defaultFormSubmitAction(t,n):t.preventDefault(),await this.formSubmitEventHandler(),null==this.handleSubmit&&!0!==this.shouldUseDefaultFormSubmitAction||(this.progress="success")}catch(t){this.cardElementManager.setError(t.message),this.progress="failure"}})):console.error("Form element #stripe-card-element not found")}componentDidLoad(){this.el.classList.add(r())}componentDidRender(){this.showPaymentRequestButton&&this.paymentRequestOption&&!this.paymentRequestButtonCreated&&this.createPaymentRequestButton()}disconnectedCallback(){this.cardElementManager.unmount()}createPaymentRequestButton(){const{showPaymentRequestButton:t,paymentRequestOption:e}=this;if(this.paymentRequestButtonCreated)return null;if(!t||null==e)return null;if(null==document)return null;const i=this.el.querySelector("#stripe-payment-request-button");if(null==i)return console.error("Target element #stripe-payment-request-button not found"),null;if(null!=i.querySelector("stripe-payment-request-button"))return this.paymentRequestButtonCreated=!0,null;const s=document.createElement("stripe-payment-request-button");i.appendChild(s),customElements.whenDefined("stripe-payment-request-button").then((()=>(((t,e)=>{const{paymentRequestPaymentMethodHandler:i,paymentRequestShippingOptionChangeHandler:s,paymentRequestShippingAddressChangeHandler:n}=e;t.setPaymentRequestOption(e),null!=i&&t.setPaymentMethodEventHandler(i),null!=s&&t.setPaymentRequestShippingOptionEventHandler(s),null!=n&&t.setPaymentRequestShippingAddressEventHandler(n)})(s,e),s.initStripe(this.publishableKey)))),this.paymentRequestButtonCreated=!0}render(){const{loadStripeStatus:t}=this.stripeService.state,{errorMessage:e}=this.cardElementManager.getState();if("failure"===t)return n("p",null,l.t("Failed to load Stripe"));const i="loading"===this.progress;return n("div",{class:"stripe-payment-sheet-wrap"},n("form",{id:"stripe-card-element"},n("div",{class:"stripe-heading"},l.t(this.sheetTitle)),n("div",{id:"stripe-payment-request-button"}),n("div",null,n("div",{class:"stripe-section-title"},l.t("Card information"))),n("div",{class:"payment-info card visible"},n("fieldset",{class:"stripe-input-box"},n("div",null,n("label",null,this.showLabel?n("lenged",null,l.t("Card Number")):null,n("div",{id:"card-number"}))),n("div",{class:"stripe-input-column",style:{display:"flex"}},n("label",{style:{width:"50%"}},this.showLabel?n("lenged",null,l.t("MM / YY")):null,n("div",{id:"card-expiry"})),n("label",{style:{width:"50%"}},this.showLabel?n("lenged",null,l.t("CVC")):null,n("div",{id:"card-cvc"}))))),n("div",{id:"card-errors",class:"stripe-element-errors"},e),this.zip?n("div",{style:{marginTop:"1.5rem"}},n("div",{class:"stripe-section-title"},l.t("Country or region"))):null,this.zip?n("div",{class:"payment-info card visible"},n("fieldset",{class:"stripe-input-box"},n("div",null,n("label",null,this.showLabel?n("lenged",null,l.t("Postal Code")):null,n("input",{id:"zip",name:"zip",type:"text",inputmode:"numeric",class:"StripeElement",style:{width:"100%"},placeholder:l.t("Postal Code"),value:this.zipCode,onInput:t=>{this.zipCode=t.target.value}}))))):null,n("div",{style:{marginTop:"32px"}},n("button",{type:"submit",disabled:i},l.t("loading"===this.progress?"Loading":this.buttonLabel)))))}get el(){return this}static get watchers(){return{publishableKey:[{updatePublishableKey:0}],stripeAccount:[{updateStripeAccountId:0}]}}static get style(){return':root{--color-label:#565656;--color-placeholder:#acacac;--color-heading-text:#333;--color-text-error:#ef4444;--color-input-border:#e4e4e6;--color-input-border-shadow:rgba(228, 228, 230, 0.6);--color-button-text:rgba(255, 255, 255, 0.95);--color-button-text-disabled:rgba(255, 255, 255, 0.4);--color-primary:#0074d4}.stripe-payment-sheet-wrap{box-sizing:border-box}.stripe-payment-sheet-wrap *:where(:not(iframe,canvas,img,svg,video):not(svg *)){all:unset;display:revert;background:none;border:none;font-family:"Roboto", sans-serif;box-sizing:border-box}.stripe-payment-sheet-wrap button{cursor:pointer}.stripe-payment-sheet-wrap{display:block;width:100%;background:#fff;padding:32px 16px}.stripe-payment-sheet-wrap .StripeElement{padding:8px 16px;min-height:64px;display:flex;justify-content:center;align-items:center}.stripe-payment-sheet-wrap .StripeElement>.__PrivateStripeElement{width:100%}.stripe-payment-sheet-wrap .stripe-input-box{background-color:#fff;border-radius:6px;border:1px solid var(--color-input-border);overflow:hidden;filter:drop-shadow(0 0 2px var(--color-input-border-shadow))}.stripe-payment-sheet-wrap .stripe-input-box>*{border-bottom:1px solid var(--color-input-border)}.stripe-payment-sheet-wrap .stripe-input-box>*:last-child{border-bottom:none}.stripe-payment-sheet-wrap .stripe-input-column>*{border-right:1px solid var(--color-input-border)}.stripe-payment-sheet-wrap .stripe-input-column>*:last-child{border-right:none}.stripe-payment-sheet-wrap .stripe-heading{font-size:24px;font-weight:bold;color:var(--color-heading-text);margin-bottom:24px}.stripe-payment-sheet-wrap .stripe-section-title{font-size:14px;font-weight:bold;color:var(--color-label);margin-bottom:8px}.stripe-payment-sheet-wrap .payment-info label{color:var(--color-label)}.stripe-payment-sheet-wrap .stripe-element-errors{margin-top:8px;font-size:14px;color:var(--color-text-error)}.stripe-payment-sheet-wrap button{display:block;color:var(--color-button-text);background-color:var(--color-primary);width:100%;text-align:center;padding:16px 16px;font-size:18px;border-radius:6px;min-height:42px}.stripe-payment-sheet-wrap button:disabled{color:var(--color-button-text-disabled)}'}},[0,"stripe-card-element",{intentType:[1,"intent-type"],zip:[4],sheetTitle:[1,"sheet-title"],buttonLabel:[1,"button-label"],publishableKey:[1,"publishable-key"],stripeAccount:[1,"stripe-account"],applicationName:[1,"application-name"],showLabel:[4,"show-label"],intentClientSecret:[1,"intent-client-secret"],shouldUseDefaultFormSubmitAction:[4,"should-use-default-form-submit-action"],showPaymentRequestButton:[4,"show-payment-request-button"],handleSubmit:[1040],stripeDidLoaded:[1040],progress:[32],zipCode:[32],paymentRequestOption:[32],initStripe:[64],updateProgress:[64],setErrorMessage:[64],setPaymentRequestOption:[64]},void 0,{publishableKey:[{updatePublishableKey:0}],stripeAccount:[{updateStripeAccountId:0}]}]);function c(){"undefined"!=typeof customElements&&["stripe-card-element","stripe-payment-request-button"].forEach((e=>{switch(e){case"stripe-card-element":customElements.get(t(e))||customElements.define(t(e),d);break;case"stripe-payment-request-button":customElements.get(t(e))||p()}}))}c();export{d as S,c as d}
@@ -1 +1 @@
1
- import{transformTag as t,proxyCustomElement as e,HTMLElement as s,createEvent as r,h as i}from"@stencil/core/internal/client";import{c}from"./utils.js";import{s as o,i as n}from"./factory.js";const a=e(class extends s{updatePublishableKey(t){this.initStripe(t,{stripeAccount:this.stripeAccount})}updateStripeAccountId(t){const e=this.stripeService.state.publishableKey||this.publishableKey;e&&this.initStripe(e,{stripeAccount:t})}async initStripe(t,e){if(await this.stripeService.initialize(t,{stripeAccount:null==e?void 0:e.stripeAccount,applicationName:this.applicationName}),"success"===this.stripeService.state.loadStripeStatus)await this.initElement(),this.stripeLoadedEventHandler();else{const t=this.stripeService.onChange("loadStripeStatus",(async e=>{"success"===e&&(await this.initElement(),this.stripeLoadedEventHandler(),t())}))}}async setErrorMessage(t){return this.currencySelectorElementManager.setError(t),this}async getSelectedCurrency(){return this.currencySelectorElementManager.getState().selectedCurrency}stripeLoadedEventHandler(){const t={stripe:this.stripeService.getStripe()};this.stripeDidLoaded&&this.stripeDidLoaded(t),this.stripeLoaded.emit(t)}async currencyChangeEventHandler(t){const e={currency:t};this.currencyChange.emit(e),this.handleCurrencyChange&&await this.handleCurrencyChange(e)}componentWillRender(){this.stripeService.state.publishableKey&&(["success","loading"].includes(this.stripeService.state.loadStripeStatus)||this.initStripe(this.stripeService.state.publishableKey,{stripeAccount:this.stripeService.state.stripeAccount}))}constructor(t){super(),!1!==t&&this.__registerHost(),this.stripeLoaded=r(this,"stripeLoaded",7),this.currencyChange=r(this,"currencyChange",7),this.applicationName="stripe-pwa-elements",this.stripeService=o.createStripeService(),this.currencySelectorElementManager=o.createCurrencySelectorElementManager(this.stripeService),this.publishableKey&&this.initStripe(this.publishableKey,{stripeAccount:this.stripeAccount})}async initElement(){const t={};this.clientSecret&&(t.clientSecret=this.clientSecret),(await this.currencySelectorElementManager.initialize(this.el,t)).on("change",(t=>{var e;(null===(e=null==t?void 0:t.value)||void 0===e?void 0:e.currency)&&this.currencyChangeEventHandler(t.value.currency)}))}componentDidLoad(){const t=c();t&&this.el.classList.add(t)}disconnectedCallback(){this.currencySelectorElementManager.unmount()}render(){const{loadStripeStatus:t}=this.stripeService.state,{errorMessage:e}=this.currencySelectorElementManager.getState();return"failure"===t?i("p",null,n.t("Failed to load Stripe")):i("div",{class:"stripe-currency-selector-wrap"},i("div",{id:"currency-selector"}),e?i("div",{id:"currency-selector-errors",class:"stripe-element-errors"},e):null)}get el(){return this}static get watchers(){return{publishableKey:[{updatePublishableKey:0}],stripeAccount:[{updateStripeAccountId:0}]}}static get style(){return':root{--color-label:#565656;--color-placeholder:#acacac;--color-heading-text:#333;--color-text-error:#ef4444;--color-input-border:#e4e4e6;--color-input-border-shadow:rgba(228, 228, 230, 0.6);--color-button-text:rgba(255, 255, 255, 0.95);--color-button-text-disabled:rgba(255, 255, 255, 0.4);--color-primary:#0074d4}:host{box-sizing:border-box}:host *:where(:not(iframe,canvas,img,svg,video):not(svg *)){all:unset;display:revert;background:none;border:none;font-family:"Roboto", sans-serif;box-sizing:border-box}:host button{cursor:pointer}:host{display:block;width:100%}.stripe-currency-selector-wrap{width:100%;padding:0;margin:0}.stripe-currency-selector-wrap #currency-selector{width:100%;min-height:40px}.stripe-currency-selector-wrap #currency-selector-errors{margin-top:8px}'}},[0,"stripe-currency-selector",{publishableKey:[1,"publishable-key"],stripeAccount:[1,"stripe-account"],applicationName:[1,"application-name"],clientSecret:[1,"client-secret"],handleCurrencyChange:[1040],stripeDidLoaded:[1040],initStripe:[64],setErrorMessage:[64],getSelectedCurrency:[64]},void 0,{publishableKey:[{updatePublishableKey:0}],stripeAccount:[{updateStripeAccountId:0}]}]);function l(){"undefined"!=typeof customElements&&["stripe-currency-selector"].forEach((e=>{"stripe-currency-selector"===e&&(customElements.get(t(e))||customElements.define(t(e),a))}))}l();const h=a,u=l;export{h as StripeCurrencySelector,u as defineCustomElement}
1
+ import{transformTag as t,proxyCustomElement as e,HTMLElement as s,createEvent as r,h as i}from"@stencil/core/internal/client";import{c}from"./utils.js";import{s as o,i as n}from"./factory.js";const a=e(class extends s{updatePublishableKey(t){this.initStripe(t,{stripeAccount:this.stripeAccount})}updateStripeAccountId(t){const e=this.stripeService.state.publishableKey||this.publishableKey;e&&this.initStripe(e,{stripeAccount:t})}async initStripe(t,e){if(await this.stripeService.initialize(t,{stripeAccount:null==e?void 0:e.stripeAccount,applicationName:this.applicationName}),"success"===this.stripeService.state.loadStripeStatus)await this.initElement(),this.stripeLoadedEventHandler();else{const t=this.stripeService.onChange("loadStripeStatus",(async e=>{"success"===e&&(await this.initElement(),this.stripeLoadedEventHandler(),t())}))}}async setErrorMessage(t){return this.currencySelectorElementManager.setError(t),this}async getSelectedCurrency(){return this.currencySelectorElementManager.getState().selectedCurrency}stripeLoadedEventHandler(){const t={stripe:this.stripeService.getStripe()};this.stripeDidLoaded&&this.stripeDidLoaded(t),this.stripeLoaded.emit(t)}async currencyChangeEventHandler(t){const e={currency:t};this.currencyChange.emit(e),this.handleCurrencyChange&&await this.handleCurrencyChange(e)}componentWillRender(){this.stripeService.state.publishableKey&&(["success","loading"].includes(this.stripeService.state.loadStripeStatus)||this.initStripe(this.stripeService.state.publishableKey,{stripeAccount:this.stripeService.state.stripeAccount}))}constructor(t){super(),!1!==t&&this.__registerHost(),this.stripeLoaded=r(this,"stripeLoaded",7),this.currencyChange=r(this,"currencyChange",7),this.applicationName="stripe-pwa-elements",this.stripeService=o.createStripeService(),this.currencySelectorElementManager=o.createCurrencySelectorElementManager(this.stripeService)}componentWillLoad(){this.publishableKey&&this.initStripe(this.publishableKey,{stripeAccount:this.stripeAccount})}async initElement(){const t={};this.clientSecret&&(t.clientSecret=this.clientSecret),(await this.currencySelectorElementManager.initialize(this.el,t)).on("change",(t=>{var e;(null===(e=null==t?void 0:t.value)||void 0===e?void 0:e.currency)&&this.currencyChangeEventHandler(t.value.currency)}))}componentDidLoad(){const t=c();t&&this.el.classList.add(t)}disconnectedCallback(){this.currencySelectorElementManager.unmount()}render(){const{loadStripeStatus:t}=this.stripeService.state,{errorMessage:e}=this.currencySelectorElementManager.getState();return"failure"===t?i("p",null,n.t("Failed to load Stripe")):i("div",{class:"stripe-currency-selector-wrap"},i("div",{id:"currency-selector"}),e?i("div",{id:"currency-selector-errors",class:"stripe-element-errors"},e):null)}get el(){return this}static get watchers(){return{publishableKey:[{updatePublishableKey:0}],stripeAccount:[{updateStripeAccountId:0}]}}static get style(){return':root{--color-label:#565656;--color-placeholder:#acacac;--color-heading-text:#333;--color-text-error:#ef4444;--color-input-border:#e4e4e6;--color-input-border-shadow:rgba(228, 228, 230, 0.6);--color-button-text:rgba(255, 255, 255, 0.95);--color-button-text-disabled:rgba(255, 255, 255, 0.4);--color-primary:#0074d4}:host{box-sizing:border-box}:host *:where(:not(iframe,canvas,img,svg,video):not(svg *)){all:unset;display:revert;background:none;border:none;font-family:"Roboto", sans-serif;box-sizing:border-box}:host button{cursor:pointer}:host{display:block;width:100%}.stripe-currency-selector-wrap{width:100%;padding:0;margin:0}.stripe-currency-selector-wrap #currency-selector{width:100%;min-height:40px}.stripe-currency-selector-wrap #currency-selector-errors{margin-top:8px}'}},[0,"stripe-currency-selector",{publishableKey:[1,"publishable-key"],stripeAccount:[1,"stripe-account"],applicationName:[1,"application-name"],clientSecret:[1,"client-secret"],handleCurrencyChange:[1040],stripeDidLoaded:[1040],initStripe:[64],setErrorMessage:[64],getSelectedCurrency:[64]},void 0,{publishableKey:[{updatePublishableKey:0}],stripeAccount:[{updateStripeAccountId:0}]}]);function l(){"undefined"!=typeof customElements&&["stripe-currency-selector"].forEach((e=>{"stripe-currency-selector"===e&&(customElements.get(t(e))||customElements.define(t(e),a))}))}l();const h=a,u=l;export{h as StripeCurrencySelector,u as defineCustomElement}
@@ -1 +1 @@
1
- import{transformTag as t,proxyCustomElement as e,HTMLElement as s,createEvent as i,h as r}from"@stencil/core/internal/client";import{c as o}from"./utils.js";import{s as n,i as c}from"./factory.js";import{S as a}from"./error.js";const l=e(class extends s{updatePublishableKey(t){const e={};e.stripeAccount=this.stripeService.state.stripeAccount;const s=Object.values(e).filter(Boolean).length>0;this.initStripe(t,s?e:void 0)}updateStripeAccountId(t){this.initStripe(this.stripeService.state.publishableKey,{stripeAccount:t})}async updateProgress(t){return this.progress=t,this}async setErrorMessage(t){return this.expressCheckoutManager.setError(t),this}async initStripe(t,e){if(await this.stripeService.initialize(t,{stripeAccount:null==e?void 0:e.stripeAccount,applicationName:this.applicationName}),"success"===this.stripeService.state.loadStripeStatus)await this.initElement(),this.stripeLoadedEventHandler();else{const t=this.stripeService.onChange("loadStripeStatus",(async e=>{"success"===e&&(await this.initElement(),this.stripeLoadedEventHandler(),t())}))}}async updateElementOptions(t){return this.expressCheckoutManager.update(t),this}stripeLoadedEventHandler(){const t={stripe:this.stripeService.getStripe()};null!=this.stripeDidLoaded&&this.stripeDidLoaded(t),this.stripeLoaded.emit(t)}async defaultConfirmResultHandler(t){this.defaultConfirmResult.emit(t)}constructor(t){super(),!1!==t&&this.__registerHost(),this.stripeLoaded=i(this,"stripeLoaded",7),this.confirm=i(this,"confirm",7),this.expressCheckoutClick=i(this,"expressCheckoutClick",7),this.cancel=i(this,"cancel",7),this.defaultConfirmResult=i(this,"defaultConfirmResult",7),this.intentType="payment",this.applicationName="stripe-pwa-elements",this.shouldUseDefaultConfirmAction=!0,this.progress="",this.stripeService=n.createStripeService(),this.expressCheckoutManager=n.createExpressCheckoutElementManager(this.stripeService),null!=this.publishableKey&&""!==this.publishableKey&&this.initStripe(this.publishableKey,{stripeAccount:this.stripeAccount})}componentWillUpdate(){null!=this.stripeService.state.publishableKey&&""!==this.stripeService.state.publishableKey&&(["success","loading"].includes(this.stripeService.state.loadStripeStatus)||this.initStripe(this.stripeService.state.publishableKey,{stripeAccount:this.stripeService.state.stripeAccount}))}async defaultConfirmAction(t){try{this.progress="loading";const e=this.stripeService.getStripe(),{intentType:s,clientSecret:i}=this;if(null==e)throw Error("Stripe not initialized");if(null==i||""===i)throw Error("Client secret is required");const r=await(()=>"payment"===s?e.confirmPayment({elements:this.stripeService.getElements(),clientSecret:i,confirmParams:{return_url:`${window.location.origin}${window.location.pathname}`},redirect:"if_required"}):e.confirmSetup({elements:this.stripeService.getElements(),clientSecret:i,confirmParams:{return_url:`${window.location.origin}${window.location.pathname}`},redirect:"if_required"}))();if(null!=r.error)throw new a(r.error);t.complete("success"),this.progress="success",this.defaultConfirmResultHandler(r)}catch(e){console.error(e),t.complete("fail"),this.expressCheckoutManager.setError(e.message),this.progress="failure",this.defaultConfirmResultHandler(e)}}async initElement(){const t={mode:"payment"===this.intentType?"payment":"setup"};if(void 0!==this.amount&&(t.amount=this.amount),null!=this.currency&&""!==this.currency&&(t.currency=this.currency),null!=this.buttonHeight&&""!==this.buttonHeight)if("string"==typeof this.buttonHeight){const e=parseInt(this.buttonHeight.replace("px",""),10);isNaN(e)||(t.buttonHeight=e)}else t.buttonHeight=this.buttonHeight;await this.expressCheckoutManager.initialize(this.el,t,{onConfirm:async t=>{this.confirm.emit(t),this.shouldUseDefaultConfirmAction&&null!=this.clientSecret&&""!==this.clientSecret&&await this.defaultConfirmAction(t)},onClick:t=>{this.expressCheckoutClick.emit(t)},onCancel:()=>{this.cancel.emit(),this.progress=""}})}componentDidLoad(){this.el.classList.add(o())}disconnectedCallback(){this.expressCheckoutManager.unmount()}render(){const{loadStripeStatus:t}=this.stripeService.state,{errorMessage:e,isReady:s}=this.expressCheckoutManager.getState();return"failure"===t?r("p",null,c.t("Failed to load Stripe")):"loading"===t?r("p",null,c.t("Loading")):r("div",{class:"stripe-express-checkout-wrap"},r("div",{id:"express-checkout-element"}),e&&r("div",{id:"express-checkout-errors",class:"stripe-element-errors"},e),!s&&"success"===t&&r("div",{class:"stripe-express-checkout-loading"},c.t("Loading")))}get el(){return this}static get watchers(){return{publishableKey:[{updatePublishableKey:0}],stripeAccount:[{updateStripeAccountId:0}]}}static get style(){return":root{--color-label:#565656;--color-placeholder:#acacac;--color-heading-text:#333;--color-text-error:#ef4444;--color-input-border:#e4e4e6;--color-input-border-shadow:rgba(228, 228, 230, 0.6);--color-button-text:rgba(255, 255, 255, 0.95);--color-button-text-disabled:rgba(255, 255, 255, 0.4);--color-primary:#0074d4}.stripe-express-checkout-wrap{width:100%;max-width:500px;margin:0 auto;padding:1rem 0}.stripe-express-checkout-wrap #express-checkout-element{margin-bottom:1rem}.stripe-express-checkout-wrap .stripe-element-errors{color:var(--stripe-error-color, #fa755a);font-size:14px;margin-top:0.5rem;padding:0.5rem;background-color:var(--stripe-error-bg, #fff5f5);border:1px solid var(--stripe-error-border, #fdd);border-radius:6px}.stripe-express-checkout-wrap .stripe-express-checkout-loading{text-align:center;padding:1rem;color:var(--stripe-loading-color, #6772e5);font-size:14px}"}},[0,"stripe-express-checkout-element",{intentType:[1,"intent-type"],publishableKey:[1,"publishable-key"],stripeAccount:[1,"stripe-account"],applicationName:[1,"application-name"],clientSecret:[1,"client-secret"],amount:[2],currency:[1],buttonHeight:[1,"button-height"],shouldUseDefaultConfirmAction:[4,"should-use-default-confirm-action"],stripeDidLoaded:[1040],progress:[32],updateProgress:[64],setErrorMessage:[64],initStripe:[64],updateElementOptions:[64]},void 0,{publishableKey:[{updatePublishableKey:0}],stripeAccount:[{updateStripeAccountId:0}]}]);function h(){"undefined"!=typeof customElements&&["stripe-express-checkout-element"].forEach((e=>{"stripe-express-checkout-element"===e&&(customElements.get(t(e))||customElements.define(t(e),l))}))}h();const p=l,u=h;export{p as StripeExpressCheckoutElement,u as defineCustomElement}
1
+ import{transformTag as t,proxyCustomElement as e,HTMLElement as s,createEvent as i,h as r}from"@stencil/core/internal/client";import{c as o}from"./utils.js";import{s as n,i as c}from"./factory.js";import{S as a}from"./error.js";const l=e(class extends s{updatePublishableKey(t){const e={};e.stripeAccount=this.stripeService.state.stripeAccount;const s=Object.values(e).filter(Boolean).length>0;this.initStripe(t,s?e:void 0)}updateStripeAccountId(t){this.initStripe(this.stripeService.state.publishableKey,{stripeAccount:t})}async updateProgress(t){return this.progress=t,this}async setErrorMessage(t){return this.expressCheckoutManager.setError(t),this}async initStripe(t,e){if(await this.stripeService.initialize(t,{stripeAccount:null==e?void 0:e.stripeAccount,applicationName:this.applicationName}),"success"===this.stripeService.state.loadStripeStatus)await this.initElement(),this.stripeLoadedEventHandler();else{const t=this.stripeService.onChange("loadStripeStatus",(async e=>{"success"===e&&(await this.initElement(),this.stripeLoadedEventHandler(),t())}))}}async updateElementOptions(t){return this.expressCheckoutManager.update(t),this}stripeLoadedEventHandler(){const t={stripe:this.stripeService.getStripe()};null!=this.stripeDidLoaded&&this.stripeDidLoaded(t),this.stripeLoaded.emit(t)}async defaultConfirmResultHandler(t){this.defaultConfirmResult.emit(t)}constructor(t){super(),!1!==t&&this.__registerHost(),this.stripeLoaded=i(this,"stripeLoaded",7),this.confirm=i(this,"confirm",7),this.expressCheckoutClick=i(this,"expressCheckoutClick",7),this.cancel=i(this,"cancel",7),this.defaultConfirmResult=i(this,"defaultConfirmResult",7),this.intentType="payment",this.applicationName="stripe-pwa-elements",this.shouldUseDefaultConfirmAction=!0,this.progress="",this.stripeService=n.createStripeService(),this.expressCheckoutManager=n.createExpressCheckoutElementManager(this.stripeService)}componentWillLoad(){null!=this.publishableKey&&""!==this.publishableKey&&this.initStripe(this.publishableKey,{stripeAccount:this.stripeAccount})}componentWillUpdate(){null!=this.stripeService.state.publishableKey&&""!==this.stripeService.state.publishableKey&&(["success","loading"].includes(this.stripeService.state.loadStripeStatus)||this.initStripe(this.stripeService.state.publishableKey,{stripeAccount:this.stripeService.state.stripeAccount}))}async defaultConfirmAction(t){try{this.progress="loading";const e=this.stripeService.getStripe(),{intentType:s,clientSecret:i}=this;if(null==e)throw Error("Stripe not initialized");if(null==i||""===i)throw Error("Client secret is required");const r=await(()=>"payment"===s?e.confirmPayment({elements:this.stripeService.getElements(),clientSecret:i,confirmParams:{return_url:`${window.location.origin}${window.location.pathname}`},redirect:"if_required"}):e.confirmSetup({elements:this.stripeService.getElements(),clientSecret:i,confirmParams:{return_url:`${window.location.origin}${window.location.pathname}`},redirect:"if_required"}))();if(null!=r.error)throw new a(r.error);t.complete("success"),this.progress="success",this.defaultConfirmResultHandler(r)}catch(e){console.error(e),t.complete("fail"),this.expressCheckoutManager.setError(e.message),this.progress="failure",this.defaultConfirmResultHandler(e)}}async initElement(){const t={mode:"payment"===this.intentType?"payment":"setup"};if(void 0!==this.amount&&(t.amount=this.amount),null!=this.currency&&""!==this.currency&&(t.currency=this.currency),null!=this.buttonHeight&&""!==this.buttonHeight)if("string"==typeof this.buttonHeight){const e=parseInt(this.buttonHeight.replace("px",""),10);isNaN(e)||(t.buttonHeight=e)}else t.buttonHeight=this.buttonHeight;await this.expressCheckoutManager.initialize(this.el,t,{onConfirm:async t=>{this.confirm.emit(t),this.shouldUseDefaultConfirmAction&&null!=this.clientSecret&&""!==this.clientSecret&&await this.defaultConfirmAction(t)},onClick:t=>{this.expressCheckoutClick.emit(t)},onCancel:()=>{this.cancel.emit(),this.progress=""}})}componentDidLoad(){this.el.classList.add(o())}disconnectedCallback(){this.expressCheckoutManager.unmount()}render(){const{loadStripeStatus:t}=this.stripeService.state,{errorMessage:e,isReady:s}=this.expressCheckoutManager.getState();return"failure"===t?r("p",null,c.t("Failed to load Stripe")):"loading"===t?r("p",null,c.t("Loading")):r("div",{class:"stripe-express-checkout-wrap"},r("div",{id:"express-checkout-element"}),e&&r("div",{id:"express-checkout-errors",class:"stripe-element-errors"},e),!s&&"success"===t&&r("div",{class:"stripe-express-checkout-loading"},c.t("Loading")))}get el(){return this}static get watchers(){return{publishableKey:[{updatePublishableKey:0}],stripeAccount:[{updateStripeAccountId:0}]}}static get style(){return":root{--color-label:#565656;--color-placeholder:#acacac;--color-heading-text:#333;--color-text-error:#ef4444;--color-input-border:#e4e4e6;--color-input-border-shadow:rgba(228, 228, 230, 0.6);--color-button-text:rgba(255, 255, 255, 0.95);--color-button-text-disabled:rgba(255, 255, 255, 0.4);--color-primary:#0074d4}.stripe-express-checkout-wrap{width:100%;max-width:500px;margin:0 auto;padding:1rem 0}.stripe-express-checkout-wrap #express-checkout-element{margin-bottom:1rem}.stripe-express-checkout-wrap .stripe-element-errors{color:var(--stripe-error-color, #fa755a);font-size:14px;margin-top:0.5rem;padding:0.5rem;background-color:var(--stripe-error-bg, #fff5f5);border:1px solid var(--stripe-error-border, #fdd);border-radius:6px}.stripe-express-checkout-wrap .stripe-express-checkout-loading{text-align:center;padding:1rem;color:var(--stripe-loading-color, #6772e5);font-size:14px}"}},[0,"stripe-express-checkout-element",{intentType:[1,"intent-type"],publishableKey:[1,"publishable-key"],stripeAccount:[1,"stripe-account"],applicationName:[1,"application-name"],clientSecret:[1,"client-secret"],amount:[2],currency:[1],buttonHeight:[1,"button-height"],shouldUseDefaultConfirmAction:[4,"should-use-default-confirm-action"],stripeDidLoaded:[1040],progress:[32],updateProgress:[64],setErrorMessage:[64],initStripe:[64],updateElementOptions:[64]},void 0,{publishableKey:[{updatePublishableKey:0}],stripeAccount:[{updateStripeAccountId:0}]}]);function h(){"undefined"!=typeof customElements&&["stripe-express-checkout-element"].forEach((e=>{"stripe-express-checkout-element"===e&&(customElements.get(t(e))||customElements.define(t(e),l))}))}h();const p=l,u=h;export{p as StripeExpressCheckoutElement,u as defineCustomElement}
@@ -1 +1 @@
1
- import{transformTag as t,proxyCustomElement as i,HTMLElement as e,createEvent as n,h as s}from"@stencil/core/internal/client";import{c as a}from"./utils.js";import{s as r,i as o}from"./factory.js";const c=i(class extends e{updatePublishableKey(t){const i={};this.stripeAccount&&(i.stripeAccount=this.stripeAccount),this.initStripe(t,Object.keys(i).length?i:void 0)}updateStripeAccountId(t){const i=this.stripeService.state.publishableKey||this.publishableKey;i&&this.initStripe(i,{stripeAccount:t})}async initStripe(t,i){if(await this.stripeService.initialize(t,{stripeAccount:null==i?void 0:i.stripeAccount,applicationName:this.applicationName}),"success"===this.stripeService.state.loadStripeStatus)await this.initElement(),this.stripeLoadedEventHandler();else{const t=this.stripeService.onChange("loadStripeStatus",(async i=>{"success"===i&&(await this.initElement(),this.stripeLoadedEventHandler(),t())}))}}async updateProgress(t){return this.progress=t,this}async setErrorMessage(t){return this.linkAuthenticationElementManager.setError(t),this}async getEmail(){return this.linkAuthenticationElementManager.getState().email}stripeLoadedEventHandler(){const t=this.stripeService.getStripe();if(!t)return void console.error("Stripe instance is not available");const i={stripe:t};this.stripeDidLoaded&&this.stripeDidLoaded(i),this.stripeLoaded.emit(i)}linkAuthenticationChangeEventHandler(t){const i=this.linkAuthenticationElementManager.getElement(),e=this.stripeService.getStripe();if(!i||!e)return void console.error("Link Authentication Element not initialized");const n={stripe:e,linkAuthenticationElement:i,email:t};this.handleChange&&this.handleChange(n),this.linkAuthenticationChange.emit(n)}componentWillRender(){this.stripeService.state.publishableKey&&(["success","loading"].includes(this.stripeService.state.loadStripeStatus)||this.initStripe(this.stripeService.state.publishableKey,{stripeAccount:this.stripeService.state.stripeAccount}))}constructor(t){super(),!1!==t&&this.__registerHost(),this.stripeLoaded=n(this,"stripeLoaded",7),this.linkAuthenticationChange=n(this,"linkAuthenticationChange",7),this.applicationName="stripe-pwa-elements",this.progress="",this.stripeService=r.createStripeService(),this.linkAuthenticationElementManager=r.createLinkAuthenticationElementManager(this.stripeService),this.publishableKey&&this.initStripe(this.publishableKey,{stripeAccount:this.stripeAccount})}async initElement(){const t={};this.defaultEmail&&(t.defaultValues={email:this.defaultEmail}),await this.linkAuthenticationElementManager.initialize(this.el,Object.keys(t).length?t:void 0),this.linkAuthenticationElementManager.onChange("email",(t=>{this.linkAuthenticationChangeEventHandler(t)}))}componentDidLoad(){const t=a();t&&this.el.classList.add(t)}disconnectedCallback(){this.linkAuthenticationElementManager.unmount()}render(){const{loadStripeStatus:t}=this.stripeService.state,{errorMessage:i}=this.linkAuthenticationElementManager.getState();return"failure"===t?s("p",null,o.t("Failed to load Stripe")):s("div",{class:"stripe-link-authentication-wrap"},s("div",{class:"stripe-link-authentication-container"},s("div",{id:"link-authentication-element"}),s("div",{id:"link-authentication-errors",class:"stripe-element-errors"},i)))}get el(){return this}static get watchers(){return{publishableKey:[{updatePublishableKey:0}],stripeAccount:[{updateStripeAccountId:0}]}}static get style(){return':root{--color-label:#565656;--color-placeholder:#acacac;--color-heading-text:#333;--color-text-error:#ef4444;--color-input-border:#e4e4e6;--color-input-border-shadow:rgba(228, 228, 230, 0.6);--color-button-text:rgba(255, 255, 255, 0.95);--color-button-text-disabled:rgba(255, 255, 255, 0.4);--color-primary:#0074d4}.stripe-link-authentication-wrap{box-sizing:border-box}.stripe-link-authentication-wrap *:where(:not(iframe,canvas,img,svg,video):not(svg *)){all:unset;display:revert;background:none;border:none;font-family:"Roboto", sans-serif;box-sizing:border-box}.stripe-link-authentication-wrap button{cursor:pointer}.stripe-link-authentication-wrap{display:block;width:100%;background:#fff;padding:16px}.stripe-link-authentication-wrap .stripe-link-authentication-container #link-authentication-element .StripeElement{padding:8px 16px;min-height:64px;border-radius:6px;display:flex;justify-content:center;align-items:center}.stripe-link-authentication-wrap .stripe-link-authentication-container #link-authentication-element .StripeElement>.__PrivateStripeElement{width:100%}.stripe-link-authentication-wrap .stripe-link-authentication-container .stripe-element-errors{margin-top:8px;font-size:14px;color:var(--color-text-error)}'}},[0,"stripe-link-authentication-element",{publishableKey:[1,"publishable-key"],stripeAccount:[1,"stripe-account"],applicationName:[1,"application-name"],defaultEmail:[1,"default-email"],handleChange:[1040],stripeDidLoaded:[1040],progress:[32],initStripe:[64],updateProgress:[64],setErrorMessage:[64],getEmail:[64]},void 0,{publishableKey:[{updatePublishableKey:0}],stripeAccount:[{updateStripeAccountId:0}]}]);function l(){"undefined"!=typeof customElements&&["stripe-link-authentication-element"].forEach((i=>{"stripe-link-authentication-element"===i&&(customElements.get(t(i))||customElements.define(t(i),c))}))}l();const h=c,p=l;export{h as StripeLinkAuthenticationElement,p as defineCustomElement}
1
+ import{transformTag as t,proxyCustomElement as i,HTMLElement as e,createEvent as n,h as s}from"@stencil/core/internal/client";import{c as a}from"./utils.js";import{s as r,i as o}from"./factory.js";const c=i(class extends e{updatePublishableKey(t){const i={};this.stripeAccount&&(i.stripeAccount=this.stripeAccount),this.initStripe(t,Object.keys(i).length?i:void 0)}updateStripeAccountId(t){const i=this.stripeService.state.publishableKey||this.publishableKey;i&&this.initStripe(i,{stripeAccount:t})}async initStripe(t,i){if(await this.stripeService.initialize(t,{stripeAccount:null==i?void 0:i.stripeAccount,applicationName:this.applicationName}),"success"===this.stripeService.state.loadStripeStatus)await this.initElement(),this.stripeLoadedEventHandler();else{const t=this.stripeService.onChange("loadStripeStatus",(async i=>{"success"===i&&(await this.initElement(),this.stripeLoadedEventHandler(),t())}))}}async updateProgress(t){return this.progress=t,this}async setErrorMessage(t){return this.linkAuthenticationElementManager.setError(t),this}async getEmail(){return this.linkAuthenticationElementManager.getState().email}stripeLoadedEventHandler(){const t=this.stripeService.getStripe();if(!t)return void console.error("Stripe instance is not available");const i={stripe:t};this.stripeDidLoaded&&this.stripeDidLoaded(i),this.stripeLoaded.emit(i)}linkAuthenticationChangeEventHandler(t){const i=this.linkAuthenticationElementManager.getElement(),e=this.stripeService.getStripe();if(!i||!e)return void console.error("Link Authentication Element not initialized");const n={stripe:e,linkAuthenticationElement:i,email:t};this.handleChange&&this.handleChange(n),this.linkAuthenticationChange.emit(n)}componentWillRender(){this.stripeService.state.publishableKey&&(["success","loading"].includes(this.stripeService.state.loadStripeStatus)||this.initStripe(this.stripeService.state.publishableKey,{stripeAccount:this.stripeService.state.stripeAccount}))}constructor(t){super(),!1!==t&&this.__registerHost(),this.stripeLoaded=n(this,"stripeLoaded",7),this.linkAuthenticationChange=n(this,"linkAuthenticationChange",7),this.applicationName="stripe-pwa-elements",this.progress="",this.stripeService=r.createStripeService(),this.linkAuthenticationElementManager=r.createLinkAuthenticationElementManager(this.stripeService)}componentWillLoad(){this.publishableKey&&this.initStripe(this.publishableKey,{stripeAccount:this.stripeAccount})}async initElement(){const t={};this.defaultEmail&&(t.defaultValues={email:this.defaultEmail}),await this.linkAuthenticationElementManager.initialize(this.el,Object.keys(t).length?t:void 0),this.linkAuthenticationElementManager.onChange("email",(t=>{this.linkAuthenticationChangeEventHandler(t)}))}componentDidLoad(){const t=a();t&&this.el.classList.add(t)}disconnectedCallback(){this.linkAuthenticationElementManager.unmount()}render(){const{loadStripeStatus:t}=this.stripeService.state,{errorMessage:i}=this.linkAuthenticationElementManager.getState();return"failure"===t?s("p",null,o.t("Failed to load Stripe")):s("div",{class:"stripe-link-authentication-wrap"},s("div",{class:"stripe-link-authentication-container"},s("div",{id:"link-authentication-element"}),s("div",{id:"link-authentication-errors",class:"stripe-element-errors"},i)))}get el(){return this}static get watchers(){return{publishableKey:[{updatePublishableKey:0}],stripeAccount:[{updateStripeAccountId:0}]}}static get style(){return':root{--color-label:#565656;--color-placeholder:#acacac;--color-heading-text:#333;--color-text-error:#ef4444;--color-input-border:#e4e4e6;--color-input-border-shadow:rgba(228, 228, 230, 0.6);--color-button-text:rgba(255, 255, 255, 0.95);--color-button-text-disabled:rgba(255, 255, 255, 0.4);--color-primary:#0074d4}.stripe-link-authentication-wrap{box-sizing:border-box}.stripe-link-authentication-wrap *:where(:not(iframe,canvas,img,svg,video):not(svg *)){all:unset;display:revert;background:none;border:none;font-family:"Roboto", sans-serif;box-sizing:border-box}.stripe-link-authentication-wrap button{cursor:pointer}.stripe-link-authentication-wrap{display:block;width:100%;background:#fff;padding:16px}.stripe-link-authentication-wrap .stripe-link-authentication-container #link-authentication-element .StripeElement{padding:8px 16px;min-height:64px;border-radius:6px;display:flex;justify-content:center;align-items:center}.stripe-link-authentication-wrap .stripe-link-authentication-container #link-authentication-element .StripeElement>.__PrivateStripeElement{width:100%}.stripe-link-authentication-wrap .stripe-link-authentication-container .stripe-element-errors{margin-top:8px;font-size:14px;color:var(--color-text-error)}'}},[0,"stripe-link-authentication-element",{publishableKey:[1,"publishable-key"],stripeAccount:[1,"stripe-account"],applicationName:[1,"application-name"],defaultEmail:[1,"default-email"],handleChange:[1040],stripeDidLoaded:[1040],progress:[32],initStripe:[64],updateProgress:[64],setErrorMessage:[64],getEmail:[64]},void 0,{publishableKey:[{updatePublishableKey:0}],stripeAccount:[{updateStripeAccountId:0}]}]);function l(){"undefined"!=typeof customElements&&["stripe-link-authentication-element"].forEach((i=>{"stripe-link-authentication-element"===i&&(customElements.get(t(i))||customElements.define(t(i),c))}))}l();const h=c,p=l;export{h as StripeLinkAuthenticationElement,p as defineCustomElement}