Files
krolewskie-miody.pl/wp-content/plugins/woocommerce-payments/dist/multi-currency-async-renderer.js
2026-04-28 15:13:50 +02:00

2 lines
20 KiB
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*! For license information please see multi-currency-async-renderer.js.LICENSE.txt */
(()=>{var e={8351:function(e,t,r){var n;!function(){"use strict";var i,o=1e9,c={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},s=!0,a="[DecimalError] ",u=a+"Invalid argument: ",l=a+"Exponent out of range: ",d=Math.floor,f=Math.pow,h=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,p=1e7,g=7,w=9007199254740991,v=d(w/g),m={};function y(e,t){var r,n,i,o,c,a,u,l,d=e.constructor,f=d.precision;if(!e.s||!t.s)return t.s||(t=new d(e)),s?O(t,f):t;if(u=e.d,l=t.d,c=e.e,i=t.e,u=u.slice(),o=c-i){for(o<0?(n=u,o=-o,a=l.length):(n=l,i=c,a=u.length),o>(a=(c=Math.ceil(f/g))>a?c+1:a+1)&&(o=a,n.length=1),n.reverse();o--;)n.push(0);n.reverse()}for((a=u.length)-(o=l.length)<0&&(o=a,n=l,l=u,u=n),r=0;o;)r=(u[--o]=u[o]+l[o]+r)/p|0,u[o]%=p;for(r&&(u.unshift(r),++i),a=u.length;0==u[--a];)u.pop();return t.d=u,t.e=i,s?O(t,f):t}function b(e,t,r){if(e!==~~e||e<t||e>r)throw Error(u+e)}function E(e){var t,r,n,i=e.length-1,o="",c=e[0];if(i>0){for(o+=c,t=1;t<i;t++)n=e[t]+"",(r=g-n.length)&&(o+=P(r)),o+=n;c=e[t],(r=g-(n=c+"").length)&&(o+=P(r))}else if(0===c)return"0";for(;c%10==0;)c/=10;return o+c}m.absoluteValue=m.abs=function(){var e=new this.constructor(this);return e.s&&(e.s=1),e},m.comparedTo=m.cmp=function(e){var t,r,n,i,o=this;if(e=new o.constructor(e),o.s!==e.s)return o.s||-e.s;if(o.e!==e.e)return o.e>e.e^o.s<0?1:-1;for(t=0,r=(n=o.d.length)<(i=e.d.length)?n:i;t<r;++t)if(o.d[t]!==e.d[t])return o.d[t]>e.d[t]^o.s<0?1:-1;return n===i?0:n>i^o.s<0?1:-1},m.decimalPlaces=m.dp=function(){var e=this,t=e.d.length-1,r=(t-e.e)*g;if(t=e.d[t])for(;t%10==0;t/=10)r--;return r<0?0:r},m.dividedBy=m.div=function(e){return N(this,new this.constructor(e))},m.dividedToIntegerBy=m.idiv=function(e){var t=this.constructor;return O(N(this,new t(e),0,1),t.precision)},m.equals=m.eq=function(e){return!this.cmp(e)},m.exponent=function(){return x(this)},m.greaterThan=m.gt=function(e){return this.cmp(e)>0},m.greaterThanOrEqualTo=m.gte=function(e){return this.cmp(e)>=0},m.isInteger=m.isint=function(){return this.e>this.d.length-2},m.isNegative=m.isneg=function(){return this.s<0},m.isPositive=m.ispos=function(){return this.s>0},m.isZero=function(){return 0===this.s},m.lessThan=m.lt=function(e){return this.cmp(e)<0},m.lessThanOrEqualTo=m.lte=function(e){return this.cmp(e)<1},m.logarithm=m.log=function(e){var t,r=this,n=r.constructor,o=n.precision,c=o+5;if(void 0===e)e=new n(10);else if((e=new n(e)).s<1||e.eq(i))throw Error(a+"NaN");if(r.s<1)throw Error(a+(r.s?"NaN":"-Infinity"));return r.eq(i)?new n(0):(s=!1,t=N(T(r,c),T(e,c),c),s=!0,O(t,o))},m.minus=m.sub=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?L(t,e):y(t,(e.s=-e.s,e))},m.modulo=m.mod=function(e){var t,r=this,n=r.constructor,i=n.precision;if(!(e=new n(e)).s)throw Error(a+"NaN");return r.s?(s=!1,t=N(r,e,0,1).times(e),s=!0,r.minus(t)):O(new n(r),i)},m.naturalExponential=m.exp=function(){return _(this)},m.naturalLogarithm=m.ln=function(){return T(this)},m.negated=m.neg=function(){var e=new this.constructor(this);return e.s=-e.s||0,e},m.plus=m.add=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?y(t,e):L(t,(e.s=-e.s,e))},m.precision=m.sd=function(e){var t,r,n,i=this;if(void 0!==e&&e!==!!e&&1!==e&&0!==e)throw Error(u+e);if(t=x(i)+1,r=(n=i.d.length-1)*g+1,n=i.d[n]){for(;n%10==0;n/=10)r--;for(n=i.d[0];n>=10;n/=10)r++}return e&&t>r?t:r},m.squareRoot=m.sqrt=function(){var e,t,r,n,i,o,c,u=this,l=u.constructor;if(u.s<1){if(!u.s)return new l(0);throw Error(a+"NaN")}for(e=x(u),s=!1,0==(i=Math.sqrt(+u))||i==1/0?(((t=E(u.d)).length+e)%2==0&&(t+="0"),i=Math.sqrt(t),e=d((e+1)/2)-(e<0||e%2),n=new l(t=i==1/0?"5e"+e:(t=i.toExponential()).slice(0,t.indexOf("e")+1)+e)):n=new l(i.toString()),i=c=(r=l.precision)+3;;)if(n=(o=n).plus(N(u,o,c+2)).times(.5),E(o.d).slice(0,c)===(t=E(n.d)).slice(0,c)){if(t=t.slice(c-3,c+1),i==c&&"4999"==t){if(O(o,r+1,0),o.times(o).eq(u)){n=o;break}}else if("9999"!=t)break;c+=4}return s=!0,O(n,r)},m.times=m.mul=function(e){var t,r,n,i,o,c,a,u,l,d=this,f=d.constructor,h=d.d,g=(e=new f(e)).d;if(!d.s||!e.s)return new f(0);for(e.s*=d.s,r=d.e+e.e,(u=h.length)<(l=g.length)&&(o=h,h=g,g=o,c=u,u=l,l=c),o=[],n=c=u+l;n--;)o.push(0);for(n=l;--n>=0;){for(t=0,i=u+n;i>n;)a=o[i]+g[n]*h[i-n-1]+t,o[i--]=a%p|0,t=a/p|0;o[i]=(o[i]+t)%p|0}for(;!o[--c];)o.pop();return t?++r:o.shift(),e.d=o,e.e=r,s?O(e,f.precision):e},m.toDecimalPlaces=m.todp=function(e,t){var r=this,n=r.constructor;return r=new n(r),void 0===e?r:(b(e,0,o),void 0===t?t=n.rounding:b(t,0,8),O(r,e+x(r)+1,t))},m.toExponential=function(e,t){var r,n=this,i=n.constructor;return void 0===e?r=S(n,!0):(b(e,0,o),void 0===t?t=i.rounding:b(t,0,8),r=S(n=O(new i(n),e+1,t),!0,e+1)),r},m.toFixed=function(e,t){var r,n,i=this,c=i.constructor;return void 0===e?S(i):(b(e,0,o),void 0===t?t=c.rounding:b(t,0,8),r=S((n=O(new c(i),e+x(i)+1,t)).abs(),!1,e+x(n)+1),i.isneg()&&!i.isZero()?"-"+r:r)},m.toInteger=m.toint=function(){var e=this,t=e.constructor;return O(new t(e),x(e)+1,t.rounding)},m.toNumber=function(){return+this},m.toPower=m.pow=function(e){var t,r,n,o,c,u,l=this,f=l.constructor,h=+(e=new f(e));if(!e.s)return new f(i);if(!(l=new f(l)).s){if(e.s<1)throw Error(a+"Infinity");return l}if(l.eq(i))return l;if(n=f.precision,e.eq(i))return O(l,n);if(u=(t=e.e)>=(r=e.d.length-1),c=l.s,u){if((r=h<0?-h:h)<=w){for(o=new f(i),t=Math.ceil(n/g+4),s=!1;r%2&&D((o=o.times(l)).d,t),0!==(r=d(r/2));)D((l=l.times(l)).d,t);return s=!0,e.s<0?new f(i).div(o):O(o,n)}}else if(c<0)throw Error(a+"NaN");return c=c<0&&1&e.d[Math.max(t,r)]?-1:1,l.s=1,s=!1,o=e.times(T(l,n+12)),s=!0,(o=_(o)).s=c,o},m.toPrecision=function(e,t){var r,n,i=this,c=i.constructor;return void 0===e?n=S(i,(r=x(i))<=c.toExpNeg||r>=c.toExpPos):(b(e,1,o),void 0===t?t=c.rounding:b(t,0,8),n=S(i=O(new c(i),e,t),e<=(r=x(i))||r<=c.toExpNeg,e)),n},m.toSignificantDigits=m.tosd=function(e,t){var r=this.constructor;return void 0===e?(e=r.precision,t=r.rounding):(b(e,1,o),void 0===t?t=r.rounding:b(t,0,8)),O(new r(this),e,t)},m.toString=m.valueOf=m.val=m.toJSON=function(){var e=this,t=x(e),r=e.constructor;return S(e,t<=r.toExpNeg||t>=r.toExpPos)};var N=function(){function e(e,t){var r,n=0,i=e.length;for(e=e.slice();i--;)r=e[i]*t+n,e[i]=r%p|0,n=r/p|0;return n&&e.unshift(n),e}function t(e,t,r,n){var i,o;if(r!=n)o=r>n?1:-1;else for(i=o=0;i<r;i++)if(e[i]!=t[i]){o=e[i]>t[i]?1:-1;break}return o}function r(e,t,r){for(var n=0;r--;)e[r]-=n,n=e[r]<t[r]?1:0,e[r]=n*p+e[r]-t[r];for(;!e[0]&&e.length>1;)e.shift()}return function(n,i,o,c){var s,u,l,d,f,h,w,v,m,y,b,E,N,_,C,P,T,A,L=n.constructor,S=n.s==i.s?1:-1,D=n.d,q=i.d;if(!n.s)return new L(n);if(!i.s)throw Error(a+"Division by zero");for(u=n.e-i.e,T=q.length,C=D.length,v=(w=new L(S)).d=[],l=0;q[l]==(D[l]||0);)++l;if(q[l]>(D[l]||0)&&--u,(E=null==o?o=L.precision:c?o+(x(n)-x(i))+1:o)<0)return new L(0);if(E=E/g+2|0,l=0,1==T)for(d=0,q=q[0],E++;(l<C||d)&&E--;l++)N=d*p+(D[l]||0),v[l]=N/q|0,d=N%q|0;else{for((d=p/(q[0]+1)|0)>1&&(q=e(q,d),D=e(D,d),T=q.length,C=D.length),_=T,y=(m=D.slice(0,T)).length;y<T;)m[y++]=0;(A=q.slice()).unshift(0),P=q[0],q[1]>=p/2&&++P;do{d=0,(s=t(q,m,T,y))<0?(b=m[0],T!=y&&(b=b*p+(m[1]||0)),(d=b/P|0)>1?(d>=p&&(d=p-1),1==(s=t(f=e(q,d),m,h=f.length,y=m.length))&&(d--,r(f,T<h?A:q,h))):(0==d&&(s=d=1),f=q.slice()),(h=f.length)<y&&f.unshift(0),r(m,f,y),-1==s&&(s=t(q,m,T,y=m.length))<1&&(d++,r(m,T<y?A:q,y)),y=m.length):0===s&&(d++,m=[0]),v[l++]=d,s&&m[0]?m[y++]=D[_]||0:(m=[D[_]],y=1)}while((_++<C||void 0!==m[0])&&E--)}return v[0]||v.shift(),w.e=u,O(w,c?o+x(w)+1:o)}}();function _(e,t){var r,n,o,c,a,u=0,d=0,h=e.constructor,p=h.precision;if(x(e)>16)throw Error(l+x(e));if(!e.s)return new h(i);for(null==t?(s=!1,a=p):a=t,c=new h(.03125);e.abs().gte(.1);)e=e.times(c),d+=5;for(a+=Math.log(f(2,d))/Math.LN10*2+5|0,r=n=o=new h(i),h.precision=a;;){if(n=O(n.times(e),a),r=r.times(++u),E((c=o.plus(N(n,r,a))).d).slice(0,a)===E(o.d).slice(0,a)){for(;d--;)o=O(o.times(o),a);return h.precision=p,null==t?(s=!0,O(o,p)):o}o=c}}function x(e){for(var t=e.e*g,r=e.d[0];r>=10;r/=10)t++;return t}function C(e,t,r){if(t>e.LN10.sd())throw s=!0,r&&(e.precision=r),Error(a+"LN10 precision limit exceeded");return O(new e(e.LN10),t)}function P(e){for(var t="";e--;)t+="0";return t}function T(e,t){var r,n,o,c,u,l,d,f,h,p=1,g=e,w=g.d,v=g.constructor,m=v.precision;if(g.s<1)throw Error(a+(g.s?"NaN":"-Infinity"));if(g.eq(i))return new v(0);if(null==t?(s=!1,f=m):f=t,g.eq(10))return null==t&&(s=!0),C(v,f);if(f+=10,v.precision=f,n=(r=E(w)).charAt(0),c=x(g),!(Math.abs(c)<15e14))return d=C(v,f+2,m).times(c+""),g=T(new v(n+"."+r.slice(1)),f-10).plus(d),v.precision=m,null==t?(s=!0,O(g,m)):g;for(;n<7&&1!=n||1==n&&r.charAt(1)>3;)n=(r=E((g=g.times(e)).d)).charAt(0),p++;for(c=x(g),n>1?(g=new v("0."+r),c++):g=new v(n+"."+r.slice(1)),l=u=g=N(g.minus(i),g.plus(i),f),h=O(g.times(g),f),o=3;;){if(u=O(u.times(h),f),E((d=l.plus(N(u,new v(o),f))).d).slice(0,f)===E(l.d).slice(0,f))return l=l.times(2),0!==c&&(l=l.plus(C(v,f+2,m).times(c+""))),l=N(l,new v(p),f),v.precision=m,null==t?(s=!0,O(l,m)):l;l=d,o+=2}}function A(e,t){var r,n,i;for((r=t.indexOf("."))>-1&&(t=t.replace(".","")),(n=t.search(/e/i))>0?(r<0&&(r=n),r+=+t.slice(n+1),t=t.substring(0,n)):r<0&&(r=t.length),n=0;48===t.charCodeAt(n);)++n;for(i=t.length;48===t.charCodeAt(i-1);)--i;if(t=t.slice(n,i)){if(i-=n,r=r-n-1,e.e=d(r/g),e.d=[],n=(r+1)%g,r<0&&(n+=g),n<i){for(n&&e.d.push(+t.slice(0,n)),i-=g;n<i;)e.d.push(+t.slice(n,n+=g));t=t.slice(n),n=g-t.length}else n-=i;for(;n--;)t+="0";if(e.d.push(+t),s&&(e.e>v||e.e<-v))throw Error(l+r)}else e.s=0,e.e=0,e.d=[0];return e}function O(e,t,r){var n,i,o,c,a,u,h,w,m=e.d;for(c=1,o=m[0];o>=10;o/=10)c++;if((n=t-c)<0)n+=g,i=t,h=m[w=0];else{if((w=Math.ceil((n+1)/g))>=(o=m.length))return e;for(h=o=m[w],c=1;o>=10;o/=10)c++;i=(n%=g)-g+c}if(void 0!==r&&(a=h/(o=f(10,c-i-1))%10|0,u=t<0||void 0!==m[w+1]||h%o,u=r<4?(a||u)&&(0==r||r==(e.s<0?3:2)):a>5||5==a&&(4==r||u||6==r&&(n>0?i>0?h/f(10,c-i):0:m[w-1])%10&1||r==(e.s<0?8:7))),t<1||!m[0])return u?(o=x(e),m.length=1,t=t-o-1,m[0]=f(10,(g-t%g)%g),e.e=d(-t/g)||0):(m.length=1,m[0]=e.e=e.s=0),e;if(0==n?(m.length=w,o=1,w--):(m.length=w+1,o=f(10,g-n),m[w]=i>0?(h/f(10,c-i)%f(10,i)|0)*o:0),u)for(;;){if(0==w){(m[0]+=o)==p&&(m[0]=1,++e.e);break}if(m[w]+=o,m[w]!=p)break;m[w--]=0,o=1}for(n=m.length;0===m[--n];)m.pop();if(s&&(e.e>v||e.e<-v))throw Error(l+x(e));return e}function L(e,t){var r,n,i,o,c,a,u,l,d,f,h=e.constructor,w=h.precision;if(!e.s||!t.s)return t.s?t.s=-t.s:t=new h(e),s?O(t,w):t;if(u=e.d,f=t.d,n=t.e,l=e.e,u=u.slice(),c=l-n){for((d=c<0)?(r=u,c=-c,a=f.length):(r=f,n=l,a=u.length),c>(i=Math.max(Math.ceil(w/g),a)+2)&&(c=i,r.length=1),r.reverse(),i=c;i--;)r.push(0);r.reverse()}else{for((d=(i=u.length)<(a=f.length))&&(a=i),i=0;i<a;i++)if(u[i]!=f[i]){d=u[i]<f[i];break}c=0}for(d&&(r=u,u=f,f=r,t.s=-t.s),a=u.length,i=f.length-a;i>0;--i)u[a++]=0;for(i=f.length;i>c;){if(u[--i]<f[i]){for(o=i;o&&0===u[--o];)u[o]=p-1;--u[o],u[i]+=p}u[i]-=f[i]}for(;0===u[--a];)u.pop();for(;0===u[0];u.shift())--n;return u[0]?(t.d=u,t.e=n,s?O(t,w):t):new h(0)}function S(e,t,r){var n,i=x(e),o=E(e.d),c=o.length;return t?(r&&(n=r-c)>0?o=o.charAt(0)+"."+o.slice(1)+P(n):c>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(i<0?"e":"e+")+i):i<0?(o="0."+P(-i-1)+o,r&&(n=r-c)>0&&(o+=P(n))):i>=c?(o+=P(i+1-c),r&&(n=r-i-1)>0&&(o=o+"."+P(n))):((n=i+1)<c&&(o=o.slice(0,n)+"."+o.slice(n)),r&&(n=r-c)>0&&(i+1===c&&(o+="."),o+=P(n))),e.s<0?"-"+o:o}function D(e,t){if(e.length>t)return e.length=t,!0}function q(e){if(!e||"object"!=typeof e)throw Error(a+"Object expected");var t,r,n,i=["precision",1,o,"rounding",0,8,"toExpNeg",-1/0,0,"toExpPos",0,1/0];for(t=0;t<i.length;t+=3)if(void 0!==(n=e[r=i[t]])){if(!(d(n)===n&&n>=i[t+1]&&n<=i[t+2]))throw Error(u+r+": "+n);this[r]=n}if(void 0!==(n=e[r="LN10"])){if(n!=Math.LN10)throw Error(u+r+": "+n);this[r]=new this(n)}return this}(c=function e(t){var r,n,i;function o(e){var t=this;if(!(t instanceof o))return new o(e);if(t.constructor=o,e instanceof o)return t.s=e.s,t.e=e.e,void(t.d=(e=e.d)?e.slice():e);if("number"==typeof e){if(0*e!=0)throw Error(u+e);if(e>0)t.s=1;else{if(!(e<0))return t.s=0,t.e=0,void(t.d=[0]);e=-e,t.s=-1}return e===~~e&&e<1e7?(t.e=0,void(t.d=[e])):A(t,e.toString())}if("string"!=typeof e)throw Error(u+e);if(45===e.charCodeAt(0)?(e=e.slice(1),t.s=-1):t.s=1,!h.test(e))throw Error(u+e);A(t,e)}if(o.prototype=m,o.ROUND_UP=0,o.ROUND_DOWN=1,o.ROUND_CEIL=2,o.ROUND_FLOOR=3,o.ROUND_HALF_UP=4,o.ROUND_HALF_DOWN=5,o.ROUND_HALF_EVEN=6,o.ROUND_HALF_CEIL=7,o.ROUND_HALF_FLOOR=8,o.clone=e,o.config=o.set=q,void 0===t&&(t={}),t)for(i=["precision","rounding","toExpNeg","toExpPos","LN10"],r=0;r<i.length;)t.hasOwnProperty(n=i[r++])||(t[n]=this[n]);return o.config(t),o}(c)).default=c.Decimal=c,i=new c(1),void 0===(n=function(){return c}.call(t,r,t,e))||(e.exports=n)}()}},t={};function r(n){var i=t[n];if(void 0!==i)return i.exports;var o=t[n]={exports:{}};return e[n].call(o.exports,o,o.exports,r),o.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e;r.g.importScripts&&(e=r.g.location+"");var t=r.g.document;if(!e&&t&&(t.currentScript&&(e=t.currentScript.src),!e)){var n=t.getElementsByTagName("script");if(n.length)for(var i=n.length-1;i>-1&&(!e||!/^http(s?):/.test(e));)e=n[i--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),r.p=e})(),r.p=window.wcpayAssets.url,(()=>{"use strict";var e=r(8351),t=r.n(e);const n="wcpay_mc_async_config";class i{constructor(){this.config=null,this.cache=new Map,this.initialized=!1,this.observer=null,this.wcEventHandler=null,this.debounceTimer=null}async init(){if(this.initialized)return;let e;this.initialized=!0;try{const t=new Promise(((t,r)=>{e=setTimeout((()=>r(new Error("Config fetch timeout"))),1e4)}));this.config=await Promise.race([this.fetchConfig(),t]),clearTimeout(e),this.convertAllPrices(),this.observeDynamicContent(),this.listenToWooCommerceEvents()}catch(t){clearTimeout(e),this.showErrorState()}}async fetchConfig(){const e=this.getCachedConfig();if(e)return e;const t=await fetch(wcpayAsyncPriceConfig.apiUrl);if(!t.ok)throw new Error(`Config fetch failed: ${t.status}`);const r=await t.json();return this.decodeCurrencySymbols(r),this.cacheConfig(r),r}getCachedConfig(){try{const e=sessionStorage.getItem(n);if(!e)return null;const t=JSON.parse(e);return Date.now()-t.timestamp>3e5?(sessionStorage.removeItem(n),null):(this.decodeCurrencySymbols(t.data),t.data)}catch{return null}}cacheConfig(e){try{const t={data:e,timestamp:Date.now()};sessionStorage.setItem(n,JSON.stringify(t))}catch{}}decodeCurrencySymbols(e){if(!e.currencies)return;const t=document.createElement("textarea");for(const r of Object.keys(e.currencies)){const n=e.currencies[r];n.symbol&&(t.innerHTML=n.symbol,n.symbol=t.value)}}convertPrice(e,r){const n=`${e}_${r}`;if(this.cache.has(n))return this.cache.get(n);const i=this.config.selected_currency,o=this.config.currencies[i];if(!o||i===this.config.default_currency){const r=this.formatPrice(new(t())(e),o||this.config.currencies[this.config.default_currency]);return this.setCacheEntry(n,r),r}let c=new(t())(e).times(new(t())(o.rate));if("product"===r||"shipping"===r){const e=new(t())(o.rounding);if(c=e.gt(0)?c.div(e).toDecimalPlaces(0,t().ROUND_CEIL).times(e):c.toDecimalPlaces(o.decimals,t().ROUND_HALF_UP),(!1!==this.config.charm_only_products?["product"]:["product","shipping"]).includes(r)){const e=new(t())(o.charm);c=c.plus(e)}}else c=c.toDecimalPlaces(o.decimals,t().ROUND_HALF_UP);c.lt(0)&&(c=new(t())(0));const s=this.formatPrice(c,o);return this.setCacheEntry(n,s),s}setCacheEntry(e,t){if(this.cache.size>=500){const e=this.cache.keys().next().value;void 0!==e&&this.cache.delete(e)}this.cache.set(e,t)}formatPrice(e,t){const r=e.toFixed(t.decimals).split("."),n=r[0],i=r[1]||"";let o=n.replace(/\B(?=(\d{3})+(?!\d))/g,t.thousand_sep);return t.decimals>0&&(o+=t.decimal_sep+i),o}buildPriceBdi(e,t){const r=document.createElement("bdi"),n=document.createElement("span");switch(n.className="woocommerce-Price-currencySymbol",n.textContent=t.symbol,t.symbol_pos){case"right":r.appendChild(document.createTextNode(e)),r.appendChild(n);break;case"right_space":r.appendChild(document.createTextNode(e)),r.appendChild(document.createTextNode(" ")),r.appendChild(n);break;case"left_space":r.appendChild(n),r.appendChild(document.createTextNode(" ")),r.appendChild(document.createTextNode(e));break;default:r.appendChild(n),r.appendChild(document.createTextNode(e))}return r}buildPriceText(e,t){switch(t.symbol_pos){case"right":return e+t.symbol;case"right_space":return e+" "+t.symbol;case"left_space":return t.symbol+" "+e;default:return t.symbol+e}}convertAllPrices(){const e=document.querySelectorAll("[data-wcpay-price]:not(.wcpay-price-converted)"),t=this.config.selected_currency,r=this.config.currencies[t],n=r&&t!==this.config.default_currency?r:this.config.currencies[this.config.default_currency];e.forEach((e=>{const t=e.getAttribute("data-wcpay-price"),r=e.getAttribute("data-wcpay-price-type")||"product",i=this.convertPrice(t,r);e.querySelector(".wcpay-price-skeleton")?.remove(),e.querySelector(".wcpay-price-placeholder")?.remove(),e.appendChild(this.buildPriceBdi(i,n)),e.classList.add("wcpay-price-converted")})),this.convertScreenReaderText()}convertScreenReaderText(){const e="undefined"!=typeof wcpayAsyncPriceConfig?wcpayAsyncPriceConfig.srText:void 0;if(!e)return;const t=this.config.selected_currency,r=this.config.currencies[t],n=r&&t!==this.config.default_currency?r:this.config.currencies[this.config.default_currency];document.querySelectorAll("[data-wcpay-sr-type]:not(.wcpay-sr-converted)").forEach((t=>{const r=t.getAttribute("data-wcpay-sr-type");if("sale_original"===r||"sale_current"===r){const i=e[r];if(!i)return;const o=t.getAttribute("data-wcpay-sr-price");if(null===o)return;const c=this.convertPrice(o,"product"),s=this.buildPriceText(c,n);t.textContent=i.replace("%1$s",s).replace("%s",s),t.classList.add("wcpay-sr-converted")}else if("range"===r){if(!e.range)return;const r=t.getAttribute("data-wcpay-sr-price-from"),i=t.getAttribute("data-wcpay-sr-price-to");if(null===r||null===i)return;const o=this.convertPrice(r,"product"),c=this.convertPrice(i,"product"),s=this.buildPriceText(o,n),a=this.buildPriceText(c,n);t.textContent=e.range.replace("%1$s",s).replace("%2$s",a),t.classList.add("wcpay-sr-converted")}}))}observeDynamicContent(){this.observer=new MutationObserver((e=>{let t=!1;for(const r of e){for(const e of r.addedNodes){if(e.nodeType!==Node.ELEMENT_NODE)continue;const r=e;if(r.matches?.("[data-wcpay-price]:not(.wcpay-price-converted)")||r.querySelector?.("[data-wcpay-price]:not(.wcpay-price-converted)")||r.matches?.("[data-wcpay-sr-type]:not(.wcpay-sr-converted)")||r.querySelector?.("[data-wcpay-sr-type]:not(.wcpay-sr-converted)")){t=!0;break}}if(t)break}t&&(clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout((()=>this.convertAllPrices()),50))})),this.observer.observe(document.body,{childList:!0,subtree:!0})}listenToWooCommerceEvents(){"undefined"!=typeof jQuery&&(this.wcEventHandler=()=>this.convertAllPrices(),["updated_cart_totals","updated_checkout","updated_wc_div"].forEach((e=>{jQuery(document.body).on(e,this.wcEventHandler)})))}showErrorState(){const e=wcpayAsyncPriceConfig.defaultCurrency;document.querySelectorAll("[data-wcpay-price]:not(.wcpay-price-converted)").forEach((r=>{const n=r.querySelector(".wcpay-price-skeleton"),i=r.getAttribute("data-wcpay-price");if(e&&null!==i)try{const o=this.formatPrice(new(t())(i),e);return n?.remove(),r.querySelector(".wcpay-price-placeholder")?.remove(),r.appendChild(this.buildPriceBdi(o,e)),void r.classList.add("wcpay-price-converted")}catch(e){}n&&(n.classList.remove("wcpay-price-skeleton"),n.classList.add("wcpay-price-error"),n.textContent="—")}))}destroy(){this.observer&&(this.observer.disconnect(),this.observer=null),this.wcEventHandler&&"undefined"!=typeof jQuery&&(jQuery(document.body).off("updated_cart_totals updated_checkout updated_wc_div",this.wcEventHandler),this.wcEventHandler=null),clearTimeout(this.debounceTimer),this.debounceTimer=null,this.cache.clear(),this.initialized=!1,this.config=null}}if("undefined"!=typeof wcpayAsyncPriceConfig){const e=new i;"loading"===document.readyState?document.addEventListener("DOMContentLoaded",(()=>e.init())):e.init()}})()})();