@monei-js/components 2.1.0 → 2.1.2
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.
- package/dist/index.cjs +41 -42
- package/dist/index.js +41 -42
- package/dist/monei.umd.production.min.js +2 -2
- package/dist/monei.umd.production.min.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -182,76 +182,75 @@ const validateComponentProps = ({ props }) => {
|
|
|
182
182
|
};
|
|
183
183
|
//#endregion
|
|
184
184
|
//#region src/config.ts
|
|
185
|
-
const stage =
|
|
186
|
-
const
|
|
187
|
-
const
|
|
188
|
-
const globalConfig = {
|
|
189
|
-
domain,
|
|
190
|
-
version,
|
|
191
|
-
stage,
|
|
192
|
-
isProduction: stage === "prod",
|
|
193
|
-
paymentPageUrl: `${domain}/${version}/payment-page/`,
|
|
194
|
-
cardInputUrl: `${domain}/${version}/inner-card-input/`,
|
|
195
|
-
paymentModalUrl: `${domain}/${version}/inner-payment-modal/`,
|
|
196
|
-
paypalUrl: `${domain}/${version}/inner-paypal/`,
|
|
197
|
-
bizumUrl: `${domain}/${version}/inner-bizum/`,
|
|
198
|
-
bizumButtonUrl: `${domain}/${version}/inner-bizum-button/`,
|
|
199
|
-
paymentRequestUrl: `${domain}/${version}/inner-payment-request/`
|
|
200
|
-
};
|
|
201
|
-
const stageConfig = {
|
|
185
|
+
const stage = "prod";
|
|
186
|
+
const version = "v1";
|
|
187
|
+
const sc = {
|
|
202
188
|
local: {
|
|
203
189
|
domain: "http://card-input.localhost:1355",
|
|
204
|
-
paymentPageUrl:
|
|
205
|
-
cardInputUrl:
|
|
206
|
-
paymentModalUrl:
|
|
207
|
-
paypalUrl:
|
|
208
|
-
bizumUrl:
|
|
209
|
-
bizumButtonUrl:
|
|
210
|
-
paymentRequestUrl:
|
|
190
|
+
paymentPageUrl: "http://payment-page.localhost:1355/",
|
|
191
|
+
cardInputUrl: "http://card-input.localhost:1355/",
|
|
192
|
+
paymentModalUrl: "http://payment-modal.localhost:1355/",
|
|
193
|
+
paypalUrl: "http://paypal.localhost:1355/",
|
|
194
|
+
bizumUrl: "http://bizum.localhost:1355/",
|
|
195
|
+
bizumButtonUrl: "http://bizum-button.localhost:1355/",
|
|
196
|
+
paymentRequestUrl: "http://payment-request.localhost:1355/",
|
|
211
197
|
apiUrl: "https://api.monei-dev.com/v1",
|
|
212
198
|
secureDomain: "https://secure.monei-dev.com",
|
|
213
199
|
rootDomain: "monei-dev.com"
|
|
214
200
|
},
|
|
215
201
|
"local-prod": {
|
|
216
202
|
domain: "http://card-input.localhost:1355",
|
|
217
|
-
paymentPageUrl:
|
|
218
|
-
cardInputUrl:
|
|
219
|
-
paymentModalUrl:
|
|
220
|
-
paypalUrl:
|
|
221
|
-
bizumUrl:
|
|
222
|
-
bizumButtonUrl:
|
|
223
|
-
paymentRequestUrl:
|
|
203
|
+
paymentPageUrl: "http://payment-page.localhost:1355/",
|
|
204
|
+
cardInputUrl: "http://card-input.localhost:1355/",
|
|
205
|
+
paymentModalUrl: "http://payment-modal.localhost:1355/",
|
|
206
|
+
paypalUrl: "http://paypal.localhost:1355/",
|
|
207
|
+
bizumUrl: "http://bizum.localhost:1355/",
|
|
208
|
+
bizumButtonUrl: "http://bizum-button.localhost:1355/",
|
|
209
|
+
paymentRequestUrl: "http://payment-request.localhost:1355/",
|
|
224
210
|
apiUrl: "https://api.monei.com/v1",
|
|
225
211
|
secureDomain: "https://secure.monei.com",
|
|
226
212
|
rootDomain: "monei.com"
|
|
227
213
|
},
|
|
228
214
|
tunnel: {
|
|
229
215
|
domain: "https://card-input.monei-dev-tunnel.com",
|
|
230
|
-
paymentPageUrl:
|
|
231
|
-
cardInputUrl:
|
|
232
|
-
paymentModalUrl:
|
|
233
|
-
paypalUrl:
|
|
234
|
-
bizumUrl:
|
|
235
|
-
bizumButtonUrl:
|
|
236
|
-
paymentRequestUrl:
|
|
216
|
+
paymentPageUrl: "https://payment-page.monei-dev-tunnel.com/",
|
|
217
|
+
cardInputUrl: "https://card-input.monei-dev-tunnel.com/",
|
|
218
|
+
paymentModalUrl: "https://payment-modal.monei-dev-tunnel.com/",
|
|
219
|
+
paypalUrl: "https://paypal.monei-dev-tunnel.com/",
|
|
220
|
+
bizumUrl: "https://bizum.monei-dev-tunnel.com/",
|
|
221
|
+
bizumButtonUrl: "https://bizum-button.monei-dev-tunnel.com/",
|
|
222
|
+
paymentRequestUrl: "https://payment-request.monei-dev-tunnel.com/",
|
|
237
223
|
apiUrl: "https://api.monei.com/v1",
|
|
238
224
|
secureDomain: "https://secure.monei.com",
|
|
239
225
|
rootDomain: "monei.com"
|
|
240
226
|
},
|
|
241
227
|
dev: {
|
|
228
|
+
domain: "https://js.monei-dev.com",
|
|
242
229
|
apiUrl: "https://api.monei-dev.com/v1",
|
|
243
230
|
secureDomain: "https://secure.monei-dev.com",
|
|
244
231
|
rootDomain: "monei-dev.com"
|
|
245
232
|
},
|
|
246
233
|
prod: {
|
|
234
|
+
domain: "https://js.monei.com",
|
|
247
235
|
apiUrl: "https://api.monei.com/v1",
|
|
248
236
|
secureDomain: "https://secure.monei.com",
|
|
249
237
|
rootDomain: "monei.com"
|
|
250
238
|
}
|
|
251
|
-
};
|
|
239
|
+
}[stage];
|
|
240
|
+
const domain = sc.domain;
|
|
252
241
|
const config = {
|
|
253
|
-
|
|
254
|
-
|
|
242
|
+
domain,
|
|
243
|
+
version,
|
|
244
|
+
stage,
|
|
245
|
+
isProduction: stage === "prod",
|
|
246
|
+
paymentPageUrl: sc.paymentPageUrl || `${domain}/${version}/payment-page/`,
|
|
247
|
+
cardInputUrl: sc.cardInputUrl || `${domain}/${version}/inner-card-input/`,
|
|
248
|
+
paymentModalUrl: sc.paymentModalUrl || `${domain}/${version}/inner-payment-modal/`,
|
|
249
|
+
paypalUrl: sc.paypalUrl || `${domain}/${version}/inner-paypal/`,
|
|
250
|
+
bizumUrl: sc.bizumUrl || `${domain}/${version}/inner-bizum/`,
|
|
251
|
+
bizumButtonUrl: sc.bizumButtonUrl || `${domain}/${version}/inner-bizum-button/`,
|
|
252
|
+
paymentRequestUrl: sc.paymentRequestUrl || `${domain}/${version}/inner-payment-request/`,
|
|
253
|
+
...sc
|
|
255
254
|
};
|
|
256
255
|
//#endregion
|
|
257
256
|
//#region src/api.ts
|
|
@@ -287,7 +286,7 @@ const getPaymentMethods = async ({ accountId, paymentId }) => {
|
|
|
287
286
|
else throw new Error("You need to provide paymentId or accountId");
|
|
288
287
|
const query = stringify(params);
|
|
289
288
|
if (query in pmCache) return pmCache[query];
|
|
290
|
-
const promise = request(`/payment-methods?${query}`);
|
|
289
|
+
const promise = request(`/client-payment-methods?${query}`);
|
|
291
290
|
pmCache[query] = promise;
|
|
292
291
|
promise.catch(() => delete pmCache[query]);
|
|
293
292
|
return promise;
|
package/dist/index.js
CHANGED
|
@@ -170,76 +170,75 @@ const validateComponentProps = ({ props }) => {
|
|
|
170
170
|
};
|
|
171
171
|
//#endregion
|
|
172
172
|
//#region src/config.ts
|
|
173
|
-
const stage =
|
|
174
|
-
const
|
|
175
|
-
const
|
|
176
|
-
const globalConfig = {
|
|
177
|
-
domain,
|
|
178
|
-
version,
|
|
179
|
-
stage,
|
|
180
|
-
isProduction: stage === "prod",
|
|
181
|
-
paymentPageUrl: `${domain}/${version}/payment-page/`,
|
|
182
|
-
cardInputUrl: `${domain}/${version}/inner-card-input/`,
|
|
183
|
-
paymentModalUrl: `${domain}/${version}/inner-payment-modal/`,
|
|
184
|
-
paypalUrl: `${domain}/${version}/inner-paypal/`,
|
|
185
|
-
bizumUrl: `${domain}/${version}/inner-bizum/`,
|
|
186
|
-
bizumButtonUrl: `${domain}/${version}/inner-bizum-button/`,
|
|
187
|
-
paymentRequestUrl: `${domain}/${version}/inner-payment-request/`
|
|
188
|
-
};
|
|
189
|
-
const stageConfig = {
|
|
173
|
+
const stage = "prod";
|
|
174
|
+
const version = "v1";
|
|
175
|
+
const sc = {
|
|
190
176
|
local: {
|
|
191
177
|
domain: "http://card-input.localhost:1355",
|
|
192
|
-
paymentPageUrl:
|
|
193
|
-
cardInputUrl:
|
|
194
|
-
paymentModalUrl:
|
|
195
|
-
paypalUrl:
|
|
196
|
-
bizumUrl:
|
|
197
|
-
bizumButtonUrl:
|
|
198
|
-
paymentRequestUrl:
|
|
178
|
+
paymentPageUrl: "http://payment-page.localhost:1355/",
|
|
179
|
+
cardInputUrl: "http://card-input.localhost:1355/",
|
|
180
|
+
paymentModalUrl: "http://payment-modal.localhost:1355/",
|
|
181
|
+
paypalUrl: "http://paypal.localhost:1355/",
|
|
182
|
+
bizumUrl: "http://bizum.localhost:1355/",
|
|
183
|
+
bizumButtonUrl: "http://bizum-button.localhost:1355/",
|
|
184
|
+
paymentRequestUrl: "http://payment-request.localhost:1355/",
|
|
199
185
|
apiUrl: "https://api.monei-dev.com/v1",
|
|
200
186
|
secureDomain: "https://secure.monei-dev.com",
|
|
201
187
|
rootDomain: "monei-dev.com"
|
|
202
188
|
},
|
|
203
189
|
"local-prod": {
|
|
204
190
|
domain: "http://card-input.localhost:1355",
|
|
205
|
-
paymentPageUrl:
|
|
206
|
-
cardInputUrl:
|
|
207
|
-
paymentModalUrl:
|
|
208
|
-
paypalUrl:
|
|
209
|
-
bizumUrl:
|
|
210
|
-
bizumButtonUrl:
|
|
211
|
-
paymentRequestUrl:
|
|
191
|
+
paymentPageUrl: "http://payment-page.localhost:1355/",
|
|
192
|
+
cardInputUrl: "http://card-input.localhost:1355/",
|
|
193
|
+
paymentModalUrl: "http://payment-modal.localhost:1355/",
|
|
194
|
+
paypalUrl: "http://paypal.localhost:1355/",
|
|
195
|
+
bizumUrl: "http://bizum.localhost:1355/",
|
|
196
|
+
bizumButtonUrl: "http://bizum-button.localhost:1355/",
|
|
197
|
+
paymentRequestUrl: "http://payment-request.localhost:1355/",
|
|
212
198
|
apiUrl: "https://api.monei.com/v1",
|
|
213
199
|
secureDomain: "https://secure.monei.com",
|
|
214
200
|
rootDomain: "monei.com"
|
|
215
201
|
},
|
|
216
202
|
tunnel: {
|
|
217
203
|
domain: "https://card-input.monei-dev-tunnel.com",
|
|
218
|
-
paymentPageUrl:
|
|
219
|
-
cardInputUrl:
|
|
220
|
-
paymentModalUrl:
|
|
221
|
-
paypalUrl:
|
|
222
|
-
bizumUrl:
|
|
223
|
-
bizumButtonUrl:
|
|
224
|
-
paymentRequestUrl:
|
|
204
|
+
paymentPageUrl: "https://payment-page.monei-dev-tunnel.com/",
|
|
205
|
+
cardInputUrl: "https://card-input.monei-dev-tunnel.com/",
|
|
206
|
+
paymentModalUrl: "https://payment-modal.monei-dev-tunnel.com/",
|
|
207
|
+
paypalUrl: "https://paypal.monei-dev-tunnel.com/",
|
|
208
|
+
bizumUrl: "https://bizum.monei-dev-tunnel.com/",
|
|
209
|
+
bizumButtonUrl: "https://bizum-button.monei-dev-tunnel.com/",
|
|
210
|
+
paymentRequestUrl: "https://payment-request.monei-dev-tunnel.com/",
|
|
225
211
|
apiUrl: "https://api.monei.com/v1",
|
|
226
212
|
secureDomain: "https://secure.monei.com",
|
|
227
213
|
rootDomain: "monei.com"
|
|
228
214
|
},
|
|
229
215
|
dev: {
|
|
216
|
+
domain: "https://js.monei-dev.com",
|
|
230
217
|
apiUrl: "https://api.monei-dev.com/v1",
|
|
231
218
|
secureDomain: "https://secure.monei-dev.com",
|
|
232
219
|
rootDomain: "monei-dev.com"
|
|
233
220
|
},
|
|
234
221
|
prod: {
|
|
222
|
+
domain: "https://js.monei.com",
|
|
235
223
|
apiUrl: "https://api.monei.com/v1",
|
|
236
224
|
secureDomain: "https://secure.monei.com",
|
|
237
225
|
rootDomain: "monei.com"
|
|
238
226
|
}
|
|
239
|
-
};
|
|
227
|
+
}[stage];
|
|
228
|
+
const domain = sc.domain;
|
|
240
229
|
const config = {
|
|
241
|
-
|
|
242
|
-
|
|
230
|
+
domain,
|
|
231
|
+
version,
|
|
232
|
+
stage,
|
|
233
|
+
isProduction: stage === "prod",
|
|
234
|
+
paymentPageUrl: sc.paymentPageUrl || `${domain}/${version}/payment-page/`,
|
|
235
|
+
cardInputUrl: sc.cardInputUrl || `${domain}/${version}/inner-card-input/`,
|
|
236
|
+
paymentModalUrl: sc.paymentModalUrl || `${domain}/${version}/inner-payment-modal/`,
|
|
237
|
+
paypalUrl: sc.paypalUrl || `${domain}/${version}/inner-paypal/`,
|
|
238
|
+
bizumUrl: sc.bizumUrl || `${domain}/${version}/inner-bizum/`,
|
|
239
|
+
bizumButtonUrl: sc.bizumButtonUrl || `${domain}/${version}/inner-bizum-button/`,
|
|
240
|
+
paymentRequestUrl: sc.paymentRequestUrl || `${domain}/${version}/inner-payment-request/`,
|
|
241
|
+
...sc
|
|
243
242
|
};
|
|
244
243
|
//#endregion
|
|
245
244
|
//#region src/api.ts
|
|
@@ -275,7 +274,7 @@ const getPaymentMethods = async ({ accountId, paymentId }) => {
|
|
|
275
274
|
else throw new Error("You need to provide paymentId or accountId");
|
|
276
275
|
const query = stringify(params);
|
|
277
276
|
if (query in pmCache) return pmCache[query];
|
|
278
|
-
const promise = request(`/payment-methods?${query}`);
|
|
277
|
+
const promise = request(`/client-payment-methods?${query}`);
|
|
279
278
|
pmCache[query] = promise;
|
|
280
279
|
promise.catch(() => delete pmCache[query]);
|
|
281
280
|
return promise;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
void main() {
|
|
9
9
|
gl_FragColor = vec4(0.812, 0.195, 0.553, 0.921); // Set line color
|
|
10
10
|
}
|
|
11
|
-
`),S.compileShader(e),!S.getShaderParameter(e,S.COMPILE_STATUS))throw Error(`Vertex shader compilation failed: `+S.getShaderInfoLog(e));if(S.compileShader(t),!S.getShaderParameter(t,S.COMPILE_STATUS))throw Error(`Fragment shader compilation failed: `+S.getShaderInfoLog(t));let n=S.createProgram();if(!n)throw Error(`Failed to create shader program`);if(S.attachShader(n,e),S.attachShader(n,t),S.linkProgram(n),!S.getProgramParameter(n,S.LINK_STATUS))throw Error(`Shader program linking failed: `+S.getProgramInfoLog(n));S.useProgram(n);let r=new Float32Array(548),i=2*Math.PI/137;for(let e=0;e<137;e++){let t=e*i;r[4*e]=0,r[4*e+1]=0,r[4*e+2]=Math.cos(t)*(x.width/2),r[4*e+3]=Math.sin(t)*(x.height/2)}let a=S.createBuffer();S.bindBuffer(S.ARRAY_BUFFER,a),S.bufferData(S.ARRAY_BUFFER,r,S.STATIC_DRAW);let o=S.getAttribLocation(n,`position`);S.enableVertexAttribArray(o),S.vertexAttribPointer(o,2,S.FLOAT,!1,0,0),S.viewport(0,0,x.width,x.height),S.clearColor(0,0,0,1),S.clear(S.COLOR_BUFFER_BIT),S.drawArrays(S.LINES,0,274);let s=new Uint8ClampedArray(x.width*x.height*4);return S.readPixels(0,0,x.width,x.height,S.RGBA,S.UNSIGNED_BYTE,s),new ImageData(s,x.width,x.height)}catch{return new ImageData(1,1)}finally{S&&(S.bindBuffer(S.ARRAY_BUFFER,null),S.useProgram(null),S.viewport(0,0,S.drawingBufferWidth,S.drawingBufferHeight),S.clearColor(0,0,0,0))}}())),x.width,x.height).data.toString()).toString()}}catch{return{webgl:`unsupported`}}},webrtc:async function(e){return new Promise((t=>{try{let n=window.RTCPeerConnection||window.webkitRTCPeerConnection||window.mozRTCPeerConnection;if(!n)return void t({supported:!1,error:`WebRTC not supported`});let r=new n({iceCandidatePoolSize:1,iceServers:[]});r.createDataChannel(``),(async()=>{try{let n=await r.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0});await r.setLocalDescription(n);let i=n.sdp||``,a=[...new Set((i.match(/extmap:\d+ [^\n\r]+/g)||[]).map((e=>e.replace(/extmap:\d+ /,``))))].sort(),o=e=>{let t=i.match(RegExp(`m=${e} [^\\s]+ [^\\s]+ ([^\\n\\r]+)`));return t?t[1].split(` `):[]},s=(e,t)=>t.map((t=>{let n=RegExp(`(rtpmap|fmtp|rtcp-fb):${t} (.+)`,`g`),r=[...i.matchAll(n)];if(!r.length)return null;let a={};return r.forEach((t=>{let[n,r,i]=t,o=i.split(`/`);r===`rtpmap`?(a.mimeType=`${e}/${o[0]}`,a.clockRate=+o[1],e===`audio`&&(a.channels=+o[2]||1)):r===`rtcp-fb`?(a.feedbackSupport=a.feedbackSupport||[],a.feedbackSupport.push(i)):r===`fmtp`&&(a.sdpFmtpLine=i)})),a})).filter(Boolean),c=s(`audio`,o(`audio`)),l=s(`video`,o(`video`)),u={audio:{count:c.length,hash:h(C(c))},video:{count:l.length,hash:h(C(l))},extensionsHash:h(C(a))},d=e?.timeout||5e3,f=Math.floor(.9*d),p=await new Promise((e=>{let t=setTimeout((()=>{r.removeEventListener(`icecandidate`,n),r.close(),e({supported:!0,...u,timeout:!0})}),f),n=i=>{let a=i.candidate;a&&a.candidate&&(clearTimeout(t),r.removeEventListener(`icecandidate`,n),r.close(),e({supported:!0,...u,candidateType:a.type||``}))};r.addEventListener(`icecandidate`,n)}));t({details:p,hash:h(C(p))})}catch(e){r.close(),t({supported:!0,error:`WebRTC offer failed: ${e.message}`})}})()}catch(e){t({supported:!1,error:`WebRTC error: ${e.message}`})}}))},speech:async function(){return new Promise((e=>{try{if(typeof window>`u`||!window.speechSynthesis||typeof window.speechSynthesis.getVoices!=`function`)return void e({supported:!1,error:`Speech Synthesis API not supported`});let t=!1,n=null,r=r=>{if(!t){t=!0,n&&clearTimeout(n);try{let t=r.map((e=>{let t=e=>e.replace(/\\/g,`\\\\`).replace(/,/g,`\\,`);return[t(e.voiceURI||``),t(e.name||``),t(e.lang||``),e.localService?`1`:`0`,e.default?`1`:`0`].join(`,`)}));t.sort();let n={voiceCount:r.length,voicesHash:h(C(t))};e({details:n,hash:h(C(n))})}catch(t){e({supported:!0,error:`Voice processing failed: ${t.message}`})}}},i=window.speechSynthesis.getVoices();if(i.length>0)return void r(i);n=setTimeout((()=>{r(window.speechSynthesis.getVoices())}),800);let a=()=>{window.speechSynthesis.removeEventListener(`voiceschanged`,a),r(window.speechSynthesis.getVoices())};window.speechSynthesis.addEventListener(`voiceschanged`,a)}catch(t){e({supported:!1,error:`Speech Synthesis error: ${t.message}`})}}))}},ge={mathml:async function(){return new Promise((e=>{try{g((async({iframe:t})=>{try{if(!function(e){try{let t=e.createElement(`math`);t.innerHTML=`<mrow><mi>x</mi></mrow>`,t.style.position=`absolute`,t.style.visibility=`hidden`,e.body.appendChild(t);let n=t.getBoundingClientRect();return e.body.removeChild(t),n.width>0&&n.height>0}catch{return!1}}(t))return void e({supported:!1,error:`MathML not supported`});let n=[w(`integral`,`<msubsup><mo>∫</mo><mi>a</mi><mi>b</mi></msubsup><mfrac><mrow><mi>f</mi><mo>(</mo><mi>x</mi><mo>)</mo></mrow><mrow><mi>g</mi><mo>(</mo><mi>x</mi><mo>)</mo></mrow></mfrac><mi>dx</mi>`),w(`fraction`,`<mfrac><mrow><mi>π</mi><mo>×</mo><msup><mi>r</mi><mn>2</mn></msup></mrow><mrow><mn>2</mn><mi>σ</mi></mrow></mfrac>`),w(`matrix`,`<mo>[</mo><mtable><mtr><mtd><mi>α</mi></mtd><mtd><mi>β</mi></mtd></mtr><mtr><mtd><mi>γ</mi></mtd><mtd><mi>δ</mi></mtd></mtr></mtable><mo>]</mo>`),pe(),...me()],r=[],i=``;n.forEach(((e,n)=>{let a=function(e,t){try{let n=t.createElement(`math`);n.innerHTML=e.replace(/<\/?math>/g,``),n.style.whiteSpace=`nowrap`,n.style.position=`absolute`,n.style.visibility=`hidden`,n.style.top=`-9999px`,t.body.appendChild(n);let r=n.getBoundingClientRect(),i=(t.defaultView||window).getComputedStyle(n),a={dimensions:{width:r.width,height:r.height},fontInfo:{fontFamily:i.fontFamily,fontSize:i.fontSize,fontWeight:i.fontWeight,fontStyle:i.fontStyle,lineHeight:i.lineHeight,fontVariant:i.fontVariant||`normal`,fontStretch:i.fontStretch||`normal`,fontSizeAdjust:i.fontSizeAdjust||`none`,textRendering:i.textRendering||`auto`,fontFeatureSettings:i.fontFeatureSettings||`normal`,fontVariantNumeric:i.fontVariantNumeric||`normal`,fontKerning:i.fontKerning||`auto`}};return t.body.removeChild(n),a}catch(e){return{error:e.message}}}(e,t);r.push({width:a.dimensions.width,height:a.dimensions.height}),n===0&&a.fontInfo&&(i=h(C(a.fontInfo)))}));let a={fontStyleHash:i,dimensions:r};e({details:a,hash:h(C(a))})}catch(t){e({supported:!1,error:`MathML error: ${t.message}`})}}))}catch(t){e({supported:!1,error:`MathML error: ${t.message}`})}}))}},_e={},ve={timeout:`true`};function ye(e,t){let n=ae();if(n.name===`unknown`&&t){let e=t.system?.browser;e!=null&&e.name&&(n={name:String(e.name),version:String(e.version||`unknown`)})}let r=n.name.toLowerCase(),i=parseInt(n.version.split(`.`)[0]||`0`,10),a=[...e?.exclude||[]],o=[...new Set([...e?.stabilize||[],`always`])];for(let e of o){let t=s[e];if(t)for(let e of t)`browsers`in e&&!e.browsers?.some((e=>{let t=e.match(/(.+?)(>=)(\d+)/);return t?r===t[1]&&i>=+t[3]:r===e}))||a.push(...e.exclude)}return a}function be(e,t){let n=ye(t,e),r=t?.include||[];return function e(t,i=``){let a={};for(let[o,s]of Object.entries(t)){let t=i?`${i}.${o}`:o;if(typeof s!=`object`||Array.isArray(s)||s===null){let e=n.some((e=>t.startsWith(e))),i=r.some((e=>t.startsWith(e)));e&&!i||(a[o]=s)}else{let n=e(s,t);Object.keys(n).length>0&&(a[o]=n)}}return a}(e)}let xe=`visitor_id`;function Se(e){return e.storage_property_name?e.storage_property_name:e.property_name_factory(xe)}let Ce=`${i}_${xe}`;function we(e,t){try{localStorage.setItem(Se(t),e)}catch{}}let Te=`cache`;function T(e){try{let t=localStorage.getItem(e.property_name_factory(Te));return JSON.parse(t)||{}}catch{}return{}}function Ee(e){return e.cache_lifetime_in_ms>r?Date.now()+r:Date.now()+e.cache_lifetime_in_ms}var E=class extends Error{constructor(e){super(`HTTP error! status: ${e}`),this.status=e}};let D=null,O=null;async function De(e,t,n,r){let i=await fetch(e,{method:`POST`,headers:{"x-api-key":n.api_key,Authorization:`custom-authorized`,"Content-Type":`application/json`},body:JSON.stringify(t)});if(!i.ok)throw new E(i.status);let a=await i.json();return a.visitorId&&a.visitorId!==r&&we(a.visitorId,n),O=a,function(e,t){!e.cache_api_call||!e.cache_lifetime_in_ms||(function(e,t){let n={...T(e),...t};try{localStorage.setItem(e.property_name_factory(Te),JSON.stringify(n))}catch{}})(e,{apiResponseExpiry:Ee(e),apiResponse:t})}(n,a),a}let Oe=(e,t)=>{if(e.cache_api_call){if(O)return Promise.resolve(O);let t=function(e){let t=T(e);if(t&&t.apiResponse&&t.apiResponseExpiry&&Date.now()<=t.apiResponseExpiry)return t.apiResponse}(e);if(t)return Promise.resolve(t);if(D)return D}let n=`${e.api_endpoint||a}/thumbmark`,r=function(e){try{let t=Se(e),n=localStorage.getItem(t);return n||t===Ce||(n=localStorage.getItem(Ce),n&&we(n,e)),n}catch{return null}}(e),i={components:t,options:e,clientHash:h(C(t)),version:`1.7.6`};if(r&&(i.visitorId=r),e.metadata){let t=typeof e.metadata==`function`?e.metadata():e.metadata;t&&((typeof t==`string`?t.length:JSON.stringify(t).length)>1e3?console.error(`ThumbmarkJS: Metadata exceeds 1000 characters. Skipping metadata.`):i.metadata=t)}let o=e.timeout||5e3,s=async function(e,t,n,r){for(let i=0;i<3;i++){i>0&&await new Promise((e=>setTimeout(e,200*i)));try{return await De(e,t,n,r)}catch(e){if(e instanceof E||i===2)throw e}}throw Error(`Unreachable`)}(n,i,e,r).finally((()=>{D=null})),c=new Promise((t=>{setTimeout((()=>{t(T(e)?.apiResponse||{info:{timed_out:!0},...r&&{visitorId:r}})}),o)}));return D=Promise.race([s,c]),D};async function ke(e,t={}){var n;if(typeof document>`u`||typeof window>`u`)return{thumbmark:``,components:{},info:{},version:`1.7.6`,error:[{type:`fatal`,message:`Browser environment required`}]};try{let r={...o,...e},i=[],s=r.logging&&!sessionStorage.getItem(`_tmjs_l`)&&Math.random()<1e-4,{elapsed:c,resolvedComponents:l,errors:u}=await Ae({...he,..._e,...t},r);i.push(...u);let d={},f={};if(s||r.experimental){let{elapsed:e,resolvedComponents:t,errors:n}=await Ae(ge,r);d=t,f=e,i.push(...n)}let p=r.api_key?Oe(r,l):null,m=null;if(p)try{m=await p}catch(e){if(e instanceof E&&e.status===403)return{error:[{type:`api_unauthorized`,message:`Invalid API key or quota exceeded`}],components:{},info:{},version:`1.7.6`,thumbmark:``};i.push({type:e instanceof E?`api_error`:`network_error`,message:e instanceof Error?e.message:String(e)})}(n=m?.info)!=null&&n.timed_out&&i.push({type:`api_timeout`,message:`API request timed out`});let g={...c,...f},_=r.performance?{elapsed:g}:{},ee=be(m?.components||{},r),v={...l,...ee},y=m?.info||{uniqueness:{score:`api only`}},te=m?.thumbmark??h(C(v));return s&&async function(e,t,n,r={},i=[]){let o=`${a}/log`,s={thumbmark:e,components:t,experimental:r,version:`1.7.6`,options:n,path:(window==null?void 0:window.location)?.pathname,...i.length>0&&{errors:i}};sessionStorage.setItem(`_tmjs_l`,`1`);try{await fetch(o,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(s)})}catch{}}(te,v,r,d,i).catch((()=>{})),{...m?.visitorId&&{visitorId:m.visitorId},thumbmark:te,components:v,info:y,version:`1.7.6`,..._,...i.length>0&&{error:i},...Object.keys(d).length>0&&r.experimental&&{experimental:d},...m?.requestId&&{requestId:m.requestId},...m?.metadata&&{metadata:m.metadata}}}catch(e){return{thumbmark:``,components:{},info:{},version:`1.7.6`,error:[{type:`fatal`,message:e instanceof Error?e.message:String(e)}]}}}async function Ae(e,t){let n={...o,...t},r=ye(n).filter((e=>!e.includes(`.`))),i=Object.entries(e).filter((([e])=>!(n?.exclude)?.includes(e))).filter((([e])=>!r.includes(e))).filter((([e])=>(n?.include)?.some((e=>e.includes(`.`)))?(n?.include)?.some((t=>t.startsWith(e))):n?.include?.length===0||(n?.include)?.includes(e))),a=i.map((([e])=>e)),s=await function(e,t,n){return Promise.all(e.map((e=>{let r=performance.now();return Promise.race([e.then((e=>({value:e,elapsed:performance.now()-r}))).catch((e=>({value:n,elapsed:performance.now()-r,error:e instanceof Error?e.message:String(e)}))),(i=t,a=n,new Promise((e=>{setTimeout((()=>e(a)),i)}))).then((e=>({value:e,elapsed:performance.now()-r,error:`timeout`})))]);var i,a})))}(i.map((([e,n])=>n(t))),n?.timeout||5e3,ve),c={},l={},u=[];return s.forEach(((e,t)=>{let n=a[t];c[n]=e.elapsed??0,e.error===`timeout`?u.push({type:`component_timeout`,message:`Component '${n}' timed out`,component:n}):e.error&&u.push({type:`component_error`,message:e.error,component:n}),e.value!=null&&(l[n]=e.value)})),{elapsed:c,resolvedComponents:be(l,n),errors:u}}var je=class{constructor(e){this.options={...o,...e},this.customComponents={}}async get(e){return ke({...this.options,...e},this.customComponents)}getVersion(){return`1.7.6`}includeComponent(e,t){this.customComponents[e]=t}};let k=(e,t)=>{if(e==null)return t;if(typeof e==`number`)return e;let n=parseInt(e);return isNaN(n)?t:n},Me=(e,t)=>e==null?t:typeof e==`number`?`${e}px`:e||t;var Ne=n({fixLocalstorage:()=>Ie,getClientEnv:()=>M,getClientFingerprint:()=>P,isMethodSupported:()=>Ue,loadScript:()=>Pe,parsePx:()=>k,stringify:()=>Fe,toCssPx:()=>Me,transformStyle:()=>A,validateComponentProps:()=>F,withError:()=>He});let A=e=>Object.keys(e).reduce((t,n)=>(typeof e[n]==`string`?t[n]=e[n]:t[n]=`${e[n]}px`,t),{}),Pe=(e,t,n,r)=>new Promise((i,a)=>{let o=Array.from(document.scripts).find(t=>t.src===e);if(o)if(r)o.remove();else{i(o);return}let s=document.createElement(`script`);s.src=e,s.onload=()=>i(s),s.onerror=e=>a(e),t&&s.setAttribute(`nonce`,t),n&&Object.keys(n).forEach(e=>{n[e]&&(s.dataset[e]=n[e])}),document.head.appendChild(s)}),Fe=e=>Object.keys(e).reduce((t,n)=>(e[n]!==void 0&&t.push(`${encodeURIComponent(n)}=${encodeURIComponent(e[n])}`),t),[]).join(`&`),Ie=()=>{let e;try{({localStorage:e}=window)}catch{let t=(()=>{let e=new Map;return{getItem(t){return e.get(t)},setItem:function(t,n){e.set(t,n)},clear:function(){e=new Map},removeItem:function(t){e.delete(t)}}})();Object.defineProperty(window,`localStorage`,{value:t}),e=t}return e},Le=()=>{let e,t=Ie();try{e=t.getItem(`i18nextLng`)}catch{}return e?e.split(`-`)[0]:``},j=e=>{try{return String(e()??``)}catch{return``}},M=()=>{let e=[window.screen.colorDepth,window.screen.height,window.screen.width,new Date().getTimezoneOffset(),Le(),j(()=>Intl.DateTimeFormat().resolvedOptions().timeZone),j(()=>window.devicePixelRatio),j(()=>navigator.hardwareConcurrency),j(()=>navigator.deviceMemory),j(()=>navigator.maxTouchPoints),j(()=>navigator.platform),j(()=>navigator.languages?.join(`,`))].join(`|`);return window.btoa(e)},Re=`_monei_fp`,ze=e=>{if(typeof crypto<`u`&&typeof crypto.getRandomValues==`function`){let t=new Uint8Array(e);return crypto.getRandomValues(t),Array.from(t,e=>(e%16).toString(16)).join(``)}return Array.from({length:e},()=>Math.floor(Math.random()*16).toString(16)).join(``)},N=null,Be=async()=>{if(N)return{seed:N};try{let e=Ie();if(N=e.getItem(Re),!N){N=ze(32);try{e.setItem(Re,N)}catch{}}}catch{N=ze(32)}return{seed:N}},Ve=new je({logging:!1});Ve.includeComponent(`persistent_seed`,Be);let P=async()=>{let[,e]=await He(Ve.get());return e?.thumbmark??``},He=async e=>{try{return[void 0,await e]}catch(e){return[e,void 0]}},Ue=(e,t)=>e.paymentMethods&&e.paymentMethods.includes(t),F=({props:e})=>{if(!e.paymentId&&!(e.accountId&&e.amount&&e.currency))throw Error(`You need to provide paymentId or accountId amount and currency`)},We={}.env?.STAGE||`prod`,I={}.env?.DOMAIN||`http://localhost:3001`,L={}.env?.VERSION||`v1`,Ge={domain:I,version:L,stage:We,isProduction:We===`prod`,paymentPageUrl:`${I}/${L}/payment-page/`,cardInputUrl:`${I}/${L}/inner-card-input/`,paymentModalUrl:`${I}/${L}/inner-payment-modal/`,paypalUrl:`${I}/${L}/inner-paypal/`,bizumUrl:`${I}/${L}/inner-bizum/`,bizumButtonUrl:`${I}/${L}/inner-bizum-button/`,paymentRequestUrl:`${I}/${L}/inner-payment-request/`},Ke={local:{domain:`http://card-input.localhost:1355`,paymentPageUrl:`http://payment-page.localhost:1355/`,cardInputUrl:`http://card-input.localhost:1355/`,paymentModalUrl:`http://payment-modal.localhost:1355/`,paypalUrl:`http://paypal.localhost:1355/`,bizumUrl:`http://bizum.localhost:1355/`,bizumButtonUrl:`http://bizum-button.localhost:1355/`,paymentRequestUrl:`http://payment-request.localhost:1355/`,apiUrl:`https://api.monei-dev.com/v1`,secureDomain:`https://secure.monei-dev.com`,rootDomain:`monei-dev.com`},"local-prod":{domain:`http://card-input.localhost:1355`,paymentPageUrl:`http://payment-page.localhost:1355/`,cardInputUrl:`http://card-input.localhost:1355/`,paymentModalUrl:`http://payment-modal.localhost:1355/`,paypalUrl:`http://paypal.localhost:1355/`,bizumUrl:`http://bizum.localhost:1355/`,bizumButtonUrl:`http://bizum-button.localhost:1355/`,paymentRequestUrl:`http://payment-request.localhost:1355/`,apiUrl:`https://api.monei.com/v1`,secureDomain:`https://secure.monei.com`,rootDomain:`monei.com`},tunnel:{domain:`https://card-input.monei-dev-tunnel.com`,paymentPageUrl:`https://payment-page.monei-dev-tunnel.com/`,cardInputUrl:`https://card-input.monei-dev-tunnel.com/`,paymentModalUrl:`https://payment-modal.monei-dev-tunnel.com/`,paypalUrl:`https://paypal.monei-dev-tunnel.com/`,bizumUrl:`https://bizum.monei-dev-tunnel.com/`,bizumButtonUrl:`https://bizum-button.monei-dev-tunnel.com/`,paymentRequestUrl:`https://payment-request.monei-dev-tunnel.com/`,apiUrl:`https://api.monei.com/v1`,secureDomain:`https://secure.monei.com`,rootDomain:`monei.com`},dev:{apiUrl:`https://api.monei-dev.com/v1`,secureDomain:`https://secure.monei-dev.com`,rootDomain:`monei-dev.com`},prod:{apiUrl:`https://api.monei.com/v1`,secureDomain:`https://secure.monei.com`,rootDomain:`monei.com`}},R={...Ge,...Ke[We]};var qe=n({confirmPayment:()=>Xe,createApplePaySession:()=>$e,createPayment:()=>Ze,createToken:()=>Je,getPayment:()=>Ye,getPaymentMethods:()=>V,sendPaymentReceipt:()=>Qe,validateBizumPhone:()=>et});let z=async(e,{method:t=`GET`,headers:n,body:r}={})=>{t===`POST`&&(n={"Content-Type":`application/json`,...n});let i=await fetch(`${R.apiUrl}${e}`,{method:t,headers:n,body:r?JSON.stringify(r):void 0}),[,a]=await He(i.json());if(!i.ok)throw a||Error(i.statusText);return a},B={},V=async({accountId:e,paymentId:t})=>{let n;if(t)n={paymentId:t};else if(e)n={accountId:e};else throw Error(`You need to provide paymentId or accountId`);let r=Fe(n);if(r in B)return B[r];let i=z(`/payment-methods?${r}`);return B[r]=i,i.catch(()=>delete B[r]),i},Je=async({paymentMethod:e,paymentId:t,sessionId:n,amount:r,currency:i,accountId:a,transactionType:o})=>{let s;if(t)s={paymentId:t,paymentMethod:e};else if(a)s={accountId:a,paymentMethod:e,sessionId:n,amount:r,currency:i,transactionType:o};else throw Error(`You need to provide paymentId or accountId`);let c=await z(`/tokens`,{method:`POST`,headers:{"X-Client-Env":M(),"X-Client-Fingerprint":await P()},body:s});return c.paymentToken&&!c.token&&(c.token=c.paymentToken),c},Ye=async e=>z(`/payments/${e}/client-get`),Xe=async({paymentId:e,...t})=>z(`/payments/${e}/client-confirm`,{method:`POST`,headers:{"X-Client-Env":M(),"X-Client-Fingerprint":await P()},body:t}),Ze=async({signature:e,...t})=>z(`/client-payments`,{method:`POST`,headers:{"X-Client-Env":M(),"X-Client-Fingerprint":await P(),"Client-Signature":e},body:t}),Qe=async({paymentId:e,customerEmail:t,signature:n,language:r})=>z(`/payments/${e}/client-receipt`,{method:`POST`,body:{customerEmail:t,signature:n,language:r}}),$e=async e=>z(`/apple-pay/sessions`,{method:`POST`,body:e}),et=async e=>z(`/bizum/validate-phone`,{method:`POST`,body:e});var tt=class{constructor(){this.listeners=new Map,this.destroyed=!1}on(e,t){if(this.destroyed)return{cancel:()=>{}};let n=this.listeners.get(e);return n||(n=new Set,this.listeners.set(e,n)),n.add(t),{cancel:()=>{n.delete(t)}}}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};return this.on(e,n)}trigger(e,...t){if(this.destroyed)return;let n=this.listeners.get(e);if(n)for(let e of n)try{e(...t)}catch(e){console.error(e)}}off(e,t){let n=this.listeners.get(e);n&&n.delete(t)}destroy(){this.destroyed=!0,this.listeners.clear()}};function nt(e){return({React:t})=>t.forwardRef(function(n,r){let i=t.useRef(null),a=t.useRef(null),o=t.useRef(!1),s=t.useRef({});return t.useLayoutEffect(()=>{let t=i.current;if(!t)return;let s=!1,c=new e({...n});return a.current=c,c.render(t).then(()=>{s||(rt(r,c),o.current=!0)}).catch(e=>{s||console.error(e)}),()=>{s=!0,c.destroy(),a.current=null,o.current=!1,rt(r,null)}},[]),t.useEffect(()=>{!o.current||!a.current||it(s.current,n)||(s.current={...n},a.current.updateProps({...n}).catch(at))}),t.createElement(`div`,{ref:i})})}function rt(e,t){typeof e==`function`?e(t):e&&(e.current=t)}function it(e,t){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(e[r]!==t[r])return!1;return!0}function at(){}function ot(e){return()=>({template:`<div></div>`,inheritAttrs:!1,mounted(){let t=this.$el;this.__bridgeInstance=new e({...this.$attrs}),this.__bridgeInstance.render(t).catch(console.error)},watch:{$attrs:{handler(){this.__bridgeInstance&&this.__bridgeInstance.updateProps({...this.$attrs}).catch(()=>{})},deep:!0}},unmounted(){this.__bridgeInstance&&=(this.__bridgeInstance.destroy(),null)}})}function st(e){return({Component:t,NgModule:n,ElementRef:r,NgZone:i,Inject:a})=>{class o{constructor(e,t){this.props={},this.__bridgeInstance=null,this._prevProps={},this.elementRef=e,this.zone=t}getProps(){let e={...this.props},{zone:t}=this;for(let[n,r]of Object.entries(e))typeof r==`function`&&(e[n]=function(...e){return t.run(()=>r.apply(this,e))});return e}ngOnInit(){let t=this.elementRef.nativeElement;this.__bridgeInstance=new e(this.getProps()),this.__bridgeInstance.render(t).catch(console.error)}ngDoCheck(){this.__bridgeInstance&&!ct(this._prevProps,this.props)&&(this._prevProps={...this.props},this.__bridgeInstance.updateProps(this.getProps()).catch(()=>{}))}ngOnDestroy(){this.__bridgeInstance&&=(this.__bridgeInstance.destroy(),null)}}o.parameters=[[new a(r)],[new a(i)]],o.annotations=[new t({selector:e.prototype.__options?.tag||`bridge-component`,template:`<div></div>`,inputs:[`props`]})];class s{}return s.annotations=[new n({declarations:[o],exports:[o]})],s}}function ct(e,t){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(e[r]!==t[r])return!1;return!0}let lt={react:nt,vue3:ot,angular:st};function ut(e,t,n){let r=lt[e];if(!r)throw Error(`Unknown driver: ${e}. Available: ${Object.keys(lt).join(`, `)}`);return r(t)(n)}var H=class extends Error{code;constructor(e,t){super(t),this.name=`PenpalError`,this.code=e}},dt=e=>({name:e.name,message:e.message,stack:e.stack,penpalCode:e instanceof H?e.code:void 0}),ft=({name:e,message:t,stack:n,penpalCode:r})=>{let i=r?new H(r,t):Error(t);return i.name=e,i.stack=n,i},pt=class{value;transferables;constructor(e,t){this.value=e,this.transferables=t?.transferables}},U=`penpal`,W=e=>typeof e==`object`&&!!e,mt=e=>typeof e==`function`,ht=e=>W(e)&&e.namespace===U,G=e=>e.type===`SYN`,gt=e=>e.type===`ACK1`,_t=e=>e.type===`ACK2`,vt=e=>e.type===`CALL`,yt=e=>e.type===`REPLY`,bt=e=>e.type===`DESTROY`,xt=(e,t=[])=>{let n=[];for(let r of Object.keys(e)){let i=e[r];mt(i)?n.push([...t,r]):W(i)&&n.push(...xt(i,[...t,r]))}return n},St=(e,t)=>{let n=e.reduce((e,t)=>W(e)?e[t]:void 0,t);return mt(n)?n:void 0},K=e=>e.join(`.`),Ct=(e,t,n)=>({namespace:U,channel:e,type:`REPLY`,callId:t,isError:!0,...n instanceof Error?{value:dt(n),isSerializedErrorInstance:!0}:{value:n}}),wt=(e,t,n,r)=>{let i=!1,a=async a=>{if(i||!vt(a))return;r?.(`Received ${K(a.methodPath)}() call`,a);let{methodPath:o,args:s,id:c}=a,l,u;try{let e=St(o,t);if(!e)throw new H(`METHOD_NOT_FOUND`,`Method \`${K(o)}\` is not found.`);let r=await e(...s);r instanceof pt&&(u=r.transferables,r=await r.value),l={namespace:U,channel:n,type:`REPLY`,callId:c,value:r}}catch(e){l=Ct(n,c,e)}if(!i)try{r?.(`Sending ${K(o)}() reply`,l),e.sendMessage(l,u)}catch(t){throw t.name===`DataCloneError`&&(l=Ct(n,c,t),r?.(`Sending ${K(o)}() reply`,l),e.sendMessage(l)),t}};return e.addMessageHandler(a),()=>{i=!0,e.removeMessageHandler(a)}},Tt=crypto.randomUUID?.bind(crypto)??(()=>[,,,,].fill(0).map(()=>Math.floor(Math.random()*(2**53-1)).toString(16)).join(`-`)),Et=class{transferables;timeout;constructor(e){this.transferables=e?.transferables,this.timeout=e?.timeout}},Dt=new Set([`apply`,`call`,`bind`]),Ot=(e,t,n=[])=>new Proxy(n.length?()=>{}:Object.create(null),{get(r,i){if(i!==`then`)return n.length&&Dt.has(i)?Reflect.get(r,i):Ot(e,t,[...n,i])},apply(t,r,i){return e(n,i)}}),kt=e=>new H(`CONNECTION_DESTROYED`,`Method call ${K(e)}() failed due to destroyed connection`),At=(e,t,n)=>{let r=!1,i=new Map,a=e=>{if(!yt(e))return;let{callId:t,value:r,isError:a,isSerializedErrorInstance:o}=e,s=i.get(t);s&&(i.delete(t),n?.(`Received ${K(s.methodPath)}() call`,e),a?s.reject(o?ft(r):r):s.resolve(r))};return e.addMessageHandler(a),{remoteProxy:Ot((a,o)=>{if(r)throw kt(a);let s=Tt(),c=o[o.length-1],l=c instanceof Et,{timeout:u,transferables:d}=l?c:{},f=l?o.slice(0,-1):o;return new Promise((r,o)=>{let c=u===void 0?void 0:window.setTimeout(()=>{i.delete(s),o(new H(`METHOD_CALL_TIMEOUT`,`Method call ${K(a)}() timed out after ${u}ms`))},u);i.set(s,{methodPath:a,resolve:r,reject:o,timeoutId:c});try{let r={namespace:U,channel:t,type:`CALL`,id:s,methodPath:a,args:f};n?.(`Sending ${K(a)}() call`,r),e.sendMessage(r,d)}catch(e){o(new H(`TRANSMISSION_FAILED`,e.message))}})},n),destroy:()=>{r=!0,e.removeMessageHandler(a);for(let{methodPath:e,reject:t,timeoutId:n}of i.values())clearTimeout(n),t(kt(e));i.clear()}}},jt=()=>{let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}},Mt=`deprecated-penpal`,Nt=e=>W(e)&&`penpal`in e,Pt=e=>e.split(`.`),Ft=e=>e.join(`.`),It=e=>{try{return JSON.stringify(e)}catch{return String(e)}},Lt=e=>new H(`TRANSMISSION_FAILED`,`Unexpected message to translate: ${It(e)}`),Rt=e=>{if(e.penpal===`syn`)return{namespace:U,channel:void 0,type:`SYN`,participantId:Mt};if(e.penpal===`ack`)return{namespace:U,channel:void 0,type:`ACK2`};if(e.penpal===`call`)return{namespace:U,channel:void 0,type:`CALL`,id:e.id,methodPath:Pt(e.methodName),args:e.args};if(e.penpal===`reply`)return e.resolution===`fulfilled`?{namespace:U,channel:void 0,type:`REPLY`,callId:e.id,value:e.returnValue}:{namespace:U,channel:void 0,type:`REPLY`,callId:e.id,isError:!0,...e.returnValueIsError?{value:e.returnValue,isSerializedErrorInstance:!0}:{value:e.returnValue}};throw Lt(e)},zt=e=>{if(gt(e))return{penpal:`synAck`,methodNames:e.methodPaths.map(Ft)};if(vt(e))return{penpal:`call`,id:e.id,methodName:Ft(e.methodPath),args:e.args};if(yt(e))return e.isError?{penpal:`reply`,id:e.callId,resolution:`rejected`,...e.isSerializedErrorInstance?{returnValue:e.value,returnValueIsError:!0}:{returnValue:e.value}}:{penpal:`reply`,id:e.callId,resolution:`fulfilled`,returnValue:e.value};throw Lt(e)},Bt=({messenger:e,methods:t,timeout:n,channel:r,log:i})=>{let a=Tt(),o,s=[],c=!1,l=xt(t),{promise:u,resolve:d,reject:f}=jt(),p=n===void 0?void 0:setTimeout(()=>{f(new H(`CONNECTION_TIMEOUT`,`Connection timed out after ${n}ms`))},n),m=()=>{for(let e of s)e()},h=()=>{if(c)return;s.push(wt(e,t,r,i));let{remoteProxy:n,destroy:a}=At(e,r,i);s.push(a),clearTimeout(p),c=!0,d({remoteProxy:n,destroy:m})},g=()=>{let t={namespace:U,type:`SYN`,channel:r,participantId:a};i?.(`Sending handshake SYN`,t);try{e.sendMessage(t)}catch(e){f(new H(`TRANSMISSION_FAILED`,e.message))}},_=t=>{if(i?.(`Received handshake SYN`,t),t.participantId===o&&o!==Mt||(o=t.participantId,g(),!(a>o||o===Mt)))return;let n={namespace:U,channel:r,type:`ACK1`,methodPaths:l};i?.(`Sending handshake ACK1`,n);try{e.sendMessage(n)}catch(e){f(new H(`TRANSMISSION_FAILED`,e.message));return}},ee=t=>{i?.(`Received handshake ACK1`,t);let n={namespace:U,channel:r,type:`ACK2`};i?.(`Sending handshake ACK2`,n);try{e.sendMessage(n)}catch(e){f(new H(`TRANSMISSION_FAILED`,e.message));return}h()},v=e=>{i?.(`Received handshake ACK2`,e),h()},y=e=>{G(e)&&_(e),gt(e)&&ee(e),_t(e)&&v(e)};return e.addMessageHandler(y),s.push(()=>e.removeMessageHandler(y)),g(),u},Vt=e=>{let t=!1,n;return(...r)=>(t||(t=!0,n=e(...r)),n)},Ht=new WeakSet,Ut=({messenger:e,methods:t={},timeout:n,channel:r,log:i})=>{if(!e)throw new H(`INVALID_ARGUMENT`,`messenger must be defined`);if(Ht.has(e))throw new H(`INVALID_ARGUMENT`,`A messenger can only be used for a single connection`);Ht.add(e);let a=[e.destroy],o=Vt(t=>{if(t){let t={namespace:U,channel:r,type:`DESTROY`};try{e.sendMessage(t)}catch{}}for(let e of a)e();i?.(`Connection destroyed`)}),s=e=>ht(e)&&e.channel===r;return{promise:(async()=>{try{e.initialize({log:i,validateReceivedMessage:s}),e.addMessageHandler(e=>{bt(e)&&o(!1)});let{remoteProxy:c,destroy:l}=await Bt({messenger:e,methods:t,timeout:n,channel:r,log:i});return a.push(l),c}catch(e){throw o(!0),e}})(),destroy:()=>{o(!0)}}},Wt=class{#e;#t;#n;#r;#i;#a=new Set;#o;#s=!1;constructor({remoteWindow:e,allowedOrigins:t}){if(!e)throw new H(`INVALID_ARGUMENT`,`remoteWindow must be defined`);this.#e=e,this.#t=t?.length?t:[window.origin]}initialize=({log:e,validateReceivedMessage:t})=>{this.#n=e,this.#r=t,window.addEventListener(`message`,this.#d)};sendMessage=(e,t)=>{if(G(e)){let n=this.#l(e);this.#e.postMessage(e,{targetOrigin:n,transfer:t});return}if(gt(e)||this.#s){let n=this.#s?zt(e):e,r=this.#l(e);this.#e.postMessage(n,{targetOrigin:r,transfer:t});return}if(_t(e)){let{port1:n,port2:r}=new MessageChannel;this.#o=n,n.addEventListener(`message`,this.#f),n.start();let i=[r,...t||[]],a=this.#l(e);this.#e.postMessage(e,{targetOrigin:a,transfer:i});return}if(this.#o){this.#o.postMessage(e,{transfer:t});return}throw new H(`TRANSMISSION_FAILED`,`Cannot send message because the MessagePort is not connected`)};addMessageHandler=e=>{this.#a.add(e)};removeMessageHandler=e=>{this.#a.delete(e)};destroy=()=>{window.removeEventListener(`message`,this.#d),this.#u(),this.#a.clear()};#c=e=>this.#t.some(t=>t instanceof RegExp?t.test(e):t===e||t===`*`);#l=e=>{if(G(e))return`*`;if(!this.#i)throw new H(`TRANSMISSION_FAILED`,`Cannot send message because the remote origin is not established`);return this.#i===`null`&&this.#t.includes(`*`)?`*`:this.#i};#u=()=>{this.#o?.removeEventListener(`message`,this.#f),this.#o?.close(),this.#o=void 0};#d=({source:e,origin:t,ports:n,data:r})=>{if(e===this.#e){if(Nt(r)){this.#n?.(`Please upgrade the child window to the latest version of Penpal.`),this.#s=!0;try{r=Rt(r)}catch(e){this.#n?.(`Failed to translate deprecated message: ${e.message}`);return}}if(this.#r?.(r)){if(!this.#c(t)){this.#n?.(`Received a message from origin \`${t}\` which did not match allowed origins \`[${this.#t.join(`, `)}]\``);return}if(G(r)&&(this.#u(),this.#i=t),_t(r)&&!this.#s){if(this.#o=n[0],!this.#o){this.#n?.(`Ignoring ACK2 because it did not include a MessagePort`);return}this.#o.addEventListener(`message`,this.#f),this.#o.start()}for(let e of this.#a)e(r)}}};#f=({data:e})=>{if(this.#r?.(e))for(let t of this.#a)t(e)}};let q={RENDERED:`RENDERED`,RESIZE:`RESIZE`,DESTROY:`DESTROY`,BEFORE_CLOSE:`BEFORE_CLOSE`,DISPLAY:`DISPLAY`},Gt=new Set([`onClose`,`onDestroy`,`onRendered`,`onRender`,`onDisplay`,`onResize`,`onProps`]);function J(e){e&&e.remove()}function Y(e){return typeof e==`number`?`${e}px`:e}let Kt={"monei-card-input":`allow-scripts allow-forms allow-same-origin`,"monei-bizum":`allow-scripts allow-forms allow-same-origin allow-popups allow-popups-to-escape-sandbox`,"monei-bizum-button":`allow-scripts allow-forms allow-same-origin allow-popups allow-popups-to-escape-sandbox`,"monei-paypal":`allow-scripts allow-forms allow-same-origin allow-popups allow-popups-to-escape-sandbox`,"monei-payment-request":`allow-scripts allow-forms allow-same-origin allow-popups`,"monei-payment-modal":`allow-scripts allow-forms allow-same-origin allow-popups allow-popups-to-escape-sandbox`,"monei-google-pay":`allow-scripts allow-forms allow-same-origin allow-popups`};function qt(e){if(!e)throw Error(`render() requires a container element or selector`);if(typeof e==`string`){let t=document.querySelector(e);if(!t)throw Error(`Container not found: ${e}`);return t}return e}function Jt(e){return`${e}-${Math.random().toString(36).slice(2,9)}`}function Yt(e,t){let n=[[`onClose`,q.DESTROY],[`onDestroy`,q.DESTROY],[`onRendered`,q.RENDERED],[`onResize`,q.RESIZE]];for(let[r,i]of n)t.on(i,(...t)=>{let n=e[r];typeof n==`function`&&n(...t)})}function Xt(e){let{props:t,options:n,state:r,dispatchMap:i}=e,a={},o=new Set(n.computedProps?Object.keys(n.computedProps):[]);if(n.computedProps)for(let[e,o]of Object.entries(n.computedProps)){let n=o.factory({props:t,state:r});o.type===`function`?i.set(e,n):a[e]=n}for(let[e,n]of Object.entries(t))Gt.has(e)||o.has(e)||(typeof n==`function`?i.set(e,n):a[e]=n);let s=new Set([`close`,`resize`,`show`,`hide`,`getParentDomain`,`focus`]);return{dataProps:a,functionNames:[...i.keys()].filter(e=>!s.has(e))}}function Zt(e,t){let n={dispatchMap:new Map,connection:null,remote:null,containerEl:null,frame:null,destroyed:!1,ownsContainer:!1,pendingPropsUpdate:null,pendingRemovals:new Set},r=!1,i=!1;n.dispatchMap.set(`resize`,i=>{let{autoResize:a}=t,o={};i.width!==void 0&&(!a||a.width===!0)&&(o.width=i.width),i.height!==void 0&&(!a||a.height===!0)&&(o.height=i.height),n.frame&&(o.width!==void 0&&(n.frame.style.width=Y(o.width)),o.height!==void 0&&(n.frame.style.height=Y(o.height))),r||(r=!0,e.event.trigger(q.RENDERED)),e.event.trigger(q.RESIZE,o)}),n.dispatchMap.set(`close`,()=>e.close()),n.dispatchMap.set(`show`,()=>{n.frame&&(n.frame.style.display=``)}),n.dispatchMap.set(`hide`,()=>{n.frame&&(n.frame.style.display=`none`)}),n.dispatchMap.set(`getParentDomain`,()=>window.location.origin),n.dispatchMap.set(`focus`,()=>{n.frame&&n.frame.focus()}),e.render=async a=>{if(n.destroyed)throw Error(`Component is destroyed`);if(n.frame)throw Error(`Component already rendered`);let o=qt(a),s=Jt(t.tag),c=o.ownerDocument,l=c.createElement(`iframe`);l.src=t.url,l.setAttribute(`title`,t.tag.replace(/-/g,`_`)),l.setAttribute(`allowpaymentrequest`,`true`),l.setAttribute(`allow`,`payment`),l.style.border=`none`;let u=Kt[t.tag]??`allow-scripts allow-forms allow-same-origin`;l.setAttribute(`sandbox`,u),i||=(Yt(e.props,e.event),!0);let d=[],f={on(t,n){let r=e.event.on(t,n);return d.push(r),r},once(t,n){let r=e.event.once(t,n);return d.push(r),r},trigger(t,...n){e.event.trigger(t,...n)},off(t,n){e.event.off(t,n)},destroy(){e.event.destroy()}},p,m,h={},g=[];try{t.prerenderTemplate&&(p=t.prerenderTemplate({uid:s,frame:l,placeholder:void 0,doc:c,props:e.props,event:f,dimensions:t.dimensions??{width:`100%`,height:`auto`},state:e.state,container:o})),t.containerTemplate&&(m=t.containerTemplate({uid:s,frame:l,placeholder:p,doc:c,props:e.props,event:f,dimensions:t.dimensions??{width:`100%`,height:`auto`},state:e.state,container:o})),{dataProps:h,functionNames:g}=Xt({props:e.props,options:t,state:e.state,dispatchMap:n.dispatchMap})}catch(e){for(let e of d)e.cancel();let t=new Set([`close`,`resize`,`show`,`hide`,`getParentDomain`,`focus`]);for(let e of n.dispatchMap.keys())t.has(e)||n.dispatchMap.delete(e);throw e}n.frame=l;let _=()=>{l.contentWindow&&l.contentWindow.postMessage({type:`__monei_bridge_init__`,props:h,functionNames:g},new URL(t.url).origin)};try{if(m?(o.appendChild(m),n.containerEl=m,n.ownsContainer=!0):(o.appendChild(l),n.containerEl=o),e.event.trigger(q.DISPLAY),l.addEventListener(`load`,_),l.contentWindow&&_(),!l.contentWindow)throw Error(`iframe contentWindow is not available — frame may not be in the DOM`);let i=Ut({messenger:new Wt({remoteWindow:l.contentWindow,allowedOrigins:[new URL(t.url).origin]}),methods:{callParent:(e,t)=>{let r=n.dispatchMap.get(e);if(!r)throw Error(`Unknown parent method: ${e}`);return r(...t)}}});n.connection=i;let a;try{a=await i.promise}catch(e){if(n.destroyed)return;throw e}if(n.destroyed||(n.remote=a,e.state.__callChild=a.callChild,await a.updateProps(h,g),n.destroyed))return;if(n.pendingPropsUpdate){let e=n.pendingPropsUpdate;n.pendingPropsUpdate=null;let t=new Set(e.functionNames??[]),r=new Map;for(let i of Object.keys(e.dataProps))n.dispatchMap.has(i)&&!t.has(i)&&(r.set(i,n.dispatchMap.get(i)),n.pendingRemovals.add(i));if(await n.remote.updateProps(e.dataProps,e.functionNames),n.destroyed)return;for(let[e,t]of r)n.pendingRemovals.delete(e),n.dispatchMap.get(e)===t&&n.dispatchMap.delete(e)}r||(r=!0,e.event.trigger(q.RENDERED)),l.removeEventListener(`load`,_)}catch(t){l.removeEventListener(`load`,_);for(let e of d)e.cancel();delete e.state.__callChild,n.connection&&=(n.connection.destroy(),null),n.remote=null,n.frame=null,n.ownsContainer&&n.containerEl?n.containerEl.remove():l.parentNode&&l.remove(),n.containerEl=null,n.ownsContainer=!1,n.pendingPropsUpdate=null,n.pendingRemovals.clear();let i=new Set([`close`,`resize`,`show`,`hide`,`getParentDomain`,`focus`]);for(let e of n.dispatchMap.keys())i.has(e)||n.dispatchMap.delete(e);throw r=!1,t}},e.updateProps=async r=>{if(n.destroyed)throw Error(`Component is destroyed`);let i=en(r,t.aliases);if(Object.assign(e.props,i),!n.frame)return;let a={},o=[],s=new Set(t.computedProps?Object.keys(t.computedProps):[]),c=new Map;for(let[e,t]of Object.entries(i))if(!(Gt.has(e)||s.has(e)))if(typeof t==`function`){let r=n.pendingPropsUpdate!=null&&e in n.pendingPropsUpdate.dataProps,i=n.pendingRemovals.has(e);(!n.dispatchMap.has(e)||r||i)&&o.push(e),n.dispatchMap.set(e,t)}else n.dispatchMap.has(e)&&n.remote&&(c.set(e,n.dispatchMap.get(e)),n.pendingRemovals.add(e)),a[e]=t;let l=o.length>0?o:void 0;if(n.remote){await n.remote.updateProps(a,l);for(let[e,t]of c)n.pendingRemovals.delete(e),n.dispatchMap.get(e)===t&&n.dispatchMap.delete(e)}else{if(n.pendingPropsUpdate||={dataProps:{},functionNames:void 0},Object.assign(n.pendingPropsUpdate.dataProps,a),n.pendingPropsUpdate.functionNames){let e=Object.keys(a);if(e.length>0){let t=new Set(e);n.pendingPropsUpdate.functionNames=n.pendingPropsUpdate.functionNames.filter(e=>!t.has(e)),n.pendingPropsUpdate.functionNames.length===0&&(n.pendingPropsUpdate.functionNames=void 0)}}if(l){for(let e of l)delete n.pendingPropsUpdate.dataProps[e];n.pendingPropsUpdate.functionNames=[...n.pendingPropsUpdate.functionNames??[],...l]}}},e.destroy=async()=>{n.destroyed||(n.destroyed=!0,e.event.trigger(q.DESTROY),n.connection&&=(n.connection.destroy(),null),n.remote=null,n.frame&&=(n.frame.remove(),null),n.ownsContainer&&n.containerEl&&n.containerEl.remove(),e.event.destroy(),n.dispatchMap.clear())},e.close=async()=>{await e.destroy()},e.__renderState=n}let Qt={react:`@monei-js/react-components`,vue3:`@monei-js/vue-components`,angular:`@monei-js/angular-components`};function $t(e){let t=Qt[e],n=t?`Use ${t} instead.`:``;console.warn(`[MONEI] .driver('${e}') is deprecated. ${n}`.trim())}function en(e,t){if(!t)return e;let n=new Map;for(let[e,r]of Object.entries(t))n.set(r,e);let r={};for(let[t,i]of Object.entries(e)){let e=n.get(t)??t;r[e]=i}return r}function X(e){class t{constructor(t){this.state={},this.event=new tt;let n=en(t,e.aliases);e.defaultProps?this.props={...e.defaultProps({event:this.event}),...n}:this.props={...n},e.validate&&e.validate({props:this.props}),Zt(this,e),e.submit&&(this.submit=e.submit(this))}async render(e){throw Error(`render() not attached`)}async updateProps(e){throw Error(`updateProps() not attached — call render() first`)}async close(){throw Error(`close() not attached`)}async destroy(){throw Error(`destroy() not attached`)}driver(e,n){return $t(e),ut(e,t,n)}}function n(e){return this instanceof n?new t(e):new n(e)}return n.prototype=t.prototype,n.driver=function(e,t){return $t(e),ut(e,n,t)},t.prototype.__options=e,n}let Z=function(e){return e.VISIBLE=`is-visible`,e.INVISIBLE=`is-invisible`,e}({});function tn(e={}){let{background:t=`#fff`,overflow:n,borderRadius:r,fadeOnRender:i=!0,allowTransparency:a=!1,modal:o=!1}=e;return function({uid:e,frame:s,placeholder:c,doc:l,props:u,event:d,dimensions:{width:f,height:p}}){if(!s)return;a&&(s.setAttribute(`allowtransparency`,`true`),s.style.background=`transparent`);let m=l.createElement(`div`);m.setAttribute(`id`,e);let h=l.createElement(`style`);if(u?.cspNonce&&h.setAttribute(`nonce`,u.cspNonce),o){let t=l.createElement(`div`);t.classList.add(`backdrop`),h.appendChild(l.createTextNode(`
|
|
11
|
+
`),S.compileShader(e),!S.getShaderParameter(e,S.COMPILE_STATUS))throw Error(`Vertex shader compilation failed: `+S.getShaderInfoLog(e));if(S.compileShader(t),!S.getShaderParameter(t,S.COMPILE_STATUS))throw Error(`Fragment shader compilation failed: `+S.getShaderInfoLog(t));let n=S.createProgram();if(!n)throw Error(`Failed to create shader program`);if(S.attachShader(n,e),S.attachShader(n,t),S.linkProgram(n),!S.getProgramParameter(n,S.LINK_STATUS))throw Error(`Shader program linking failed: `+S.getProgramInfoLog(n));S.useProgram(n);let r=new Float32Array(548),i=2*Math.PI/137;for(let e=0;e<137;e++){let t=e*i;r[4*e]=0,r[4*e+1]=0,r[4*e+2]=Math.cos(t)*(x.width/2),r[4*e+3]=Math.sin(t)*(x.height/2)}let a=S.createBuffer();S.bindBuffer(S.ARRAY_BUFFER,a),S.bufferData(S.ARRAY_BUFFER,r,S.STATIC_DRAW);let o=S.getAttribLocation(n,`position`);S.enableVertexAttribArray(o),S.vertexAttribPointer(o,2,S.FLOAT,!1,0,0),S.viewport(0,0,x.width,x.height),S.clearColor(0,0,0,1),S.clear(S.COLOR_BUFFER_BIT),S.drawArrays(S.LINES,0,274);let s=new Uint8ClampedArray(x.width*x.height*4);return S.readPixels(0,0,x.width,x.height,S.RGBA,S.UNSIGNED_BYTE,s),new ImageData(s,x.width,x.height)}catch{return new ImageData(1,1)}finally{S&&(S.bindBuffer(S.ARRAY_BUFFER,null),S.useProgram(null),S.viewport(0,0,S.drawingBufferWidth,S.drawingBufferHeight),S.clearColor(0,0,0,0))}}())),x.width,x.height).data.toString()).toString()}}catch{return{webgl:`unsupported`}}},webrtc:async function(e){return new Promise((t=>{try{let n=window.RTCPeerConnection||window.webkitRTCPeerConnection||window.mozRTCPeerConnection;if(!n)return void t({supported:!1,error:`WebRTC not supported`});let r=new n({iceCandidatePoolSize:1,iceServers:[]});r.createDataChannel(``),(async()=>{try{let n=await r.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0});await r.setLocalDescription(n);let i=n.sdp||``,a=[...new Set((i.match(/extmap:\d+ [^\n\r]+/g)||[]).map((e=>e.replace(/extmap:\d+ /,``))))].sort(),o=e=>{let t=i.match(RegExp(`m=${e} [^\\s]+ [^\\s]+ ([^\\n\\r]+)`));return t?t[1].split(` `):[]},s=(e,t)=>t.map((t=>{let n=RegExp(`(rtpmap|fmtp|rtcp-fb):${t} (.+)`,`g`),r=[...i.matchAll(n)];if(!r.length)return null;let a={};return r.forEach((t=>{let[n,r,i]=t,o=i.split(`/`);r===`rtpmap`?(a.mimeType=`${e}/${o[0]}`,a.clockRate=+o[1],e===`audio`&&(a.channels=+o[2]||1)):r===`rtcp-fb`?(a.feedbackSupport=a.feedbackSupport||[],a.feedbackSupport.push(i)):r===`fmtp`&&(a.sdpFmtpLine=i)})),a})).filter(Boolean),c=s(`audio`,o(`audio`)),l=s(`video`,o(`video`)),u={audio:{count:c.length,hash:h(C(c))},video:{count:l.length,hash:h(C(l))},extensionsHash:h(C(a))},d=e?.timeout||5e3,f=Math.floor(.9*d),p=await new Promise((e=>{let t=setTimeout((()=>{r.removeEventListener(`icecandidate`,n),r.close(),e({supported:!0,...u,timeout:!0})}),f),n=i=>{let a=i.candidate;a&&a.candidate&&(clearTimeout(t),r.removeEventListener(`icecandidate`,n),r.close(),e({supported:!0,...u,candidateType:a.type||``}))};r.addEventListener(`icecandidate`,n)}));t({details:p,hash:h(C(p))})}catch(e){r.close(),t({supported:!0,error:`WebRTC offer failed: ${e.message}`})}})()}catch(e){t({supported:!1,error:`WebRTC error: ${e.message}`})}}))},speech:async function(){return new Promise((e=>{try{if(typeof window>`u`||!window.speechSynthesis||typeof window.speechSynthesis.getVoices!=`function`)return void e({supported:!1,error:`Speech Synthesis API not supported`});let t=!1,n=null,r=r=>{if(!t){t=!0,n&&clearTimeout(n);try{let t=r.map((e=>{let t=e=>e.replace(/\\/g,`\\\\`).replace(/,/g,`\\,`);return[t(e.voiceURI||``),t(e.name||``),t(e.lang||``),e.localService?`1`:`0`,e.default?`1`:`0`].join(`,`)}));t.sort();let n={voiceCount:r.length,voicesHash:h(C(t))};e({details:n,hash:h(C(n))})}catch(t){e({supported:!0,error:`Voice processing failed: ${t.message}`})}}},i=window.speechSynthesis.getVoices();if(i.length>0)return void r(i);n=setTimeout((()=>{r(window.speechSynthesis.getVoices())}),800);let a=()=>{window.speechSynthesis.removeEventListener(`voiceschanged`,a),r(window.speechSynthesis.getVoices())};window.speechSynthesis.addEventListener(`voiceschanged`,a)}catch(t){e({supported:!1,error:`Speech Synthesis error: ${t.message}`})}}))}},ge={mathml:async function(){return new Promise((e=>{try{g((async({iframe:t})=>{try{if(!function(e){try{let t=e.createElement(`math`);t.innerHTML=`<mrow><mi>x</mi></mrow>`,t.style.position=`absolute`,t.style.visibility=`hidden`,e.body.appendChild(t);let n=t.getBoundingClientRect();return e.body.removeChild(t),n.width>0&&n.height>0}catch{return!1}}(t))return void e({supported:!1,error:`MathML not supported`});let n=[w(`integral`,`<msubsup><mo>∫</mo><mi>a</mi><mi>b</mi></msubsup><mfrac><mrow><mi>f</mi><mo>(</mo><mi>x</mi><mo>)</mo></mrow><mrow><mi>g</mi><mo>(</mo><mi>x</mi><mo>)</mo></mrow></mfrac><mi>dx</mi>`),w(`fraction`,`<mfrac><mrow><mi>π</mi><mo>×</mo><msup><mi>r</mi><mn>2</mn></msup></mrow><mrow><mn>2</mn><mi>σ</mi></mrow></mfrac>`),w(`matrix`,`<mo>[</mo><mtable><mtr><mtd><mi>α</mi></mtd><mtd><mi>β</mi></mtd></mtr><mtr><mtd><mi>γ</mi></mtd><mtd><mi>δ</mi></mtd></mtr></mtable><mo>]</mo>`),pe(),...me()],r=[],i=``;n.forEach(((e,n)=>{let a=function(e,t){try{let n=t.createElement(`math`);n.innerHTML=e.replace(/<\/?math>/g,``),n.style.whiteSpace=`nowrap`,n.style.position=`absolute`,n.style.visibility=`hidden`,n.style.top=`-9999px`,t.body.appendChild(n);let r=n.getBoundingClientRect(),i=(t.defaultView||window).getComputedStyle(n),a={dimensions:{width:r.width,height:r.height},fontInfo:{fontFamily:i.fontFamily,fontSize:i.fontSize,fontWeight:i.fontWeight,fontStyle:i.fontStyle,lineHeight:i.lineHeight,fontVariant:i.fontVariant||`normal`,fontStretch:i.fontStretch||`normal`,fontSizeAdjust:i.fontSizeAdjust||`none`,textRendering:i.textRendering||`auto`,fontFeatureSettings:i.fontFeatureSettings||`normal`,fontVariantNumeric:i.fontVariantNumeric||`normal`,fontKerning:i.fontKerning||`auto`}};return t.body.removeChild(n),a}catch(e){return{error:e.message}}}(e,t);r.push({width:a.dimensions.width,height:a.dimensions.height}),n===0&&a.fontInfo&&(i=h(C(a.fontInfo)))}));let a={fontStyleHash:i,dimensions:r};e({details:a,hash:h(C(a))})}catch(t){e({supported:!1,error:`MathML error: ${t.message}`})}}))}catch(t){e({supported:!1,error:`MathML error: ${t.message}`})}}))}},_e={},ve={timeout:`true`};function ye(e,t){let n=ae();if(n.name===`unknown`&&t){let e=t.system?.browser;e!=null&&e.name&&(n={name:String(e.name),version:String(e.version||`unknown`)})}let r=n.name.toLowerCase(),i=parseInt(n.version.split(`.`)[0]||`0`,10),a=[...e?.exclude||[]],o=[...new Set([...e?.stabilize||[],`always`])];for(let e of o){let t=s[e];if(t)for(let e of t)`browsers`in e&&!e.browsers?.some((e=>{let t=e.match(/(.+?)(>=)(\d+)/);return t?r===t[1]&&i>=+t[3]:r===e}))||a.push(...e.exclude)}return a}function be(e,t){let n=ye(t,e),r=t?.include||[];return function e(t,i=``){let a={};for(let[o,s]of Object.entries(t)){let t=i?`${i}.${o}`:o;if(typeof s!=`object`||Array.isArray(s)||s===null){let e=n.some((e=>t.startsWith(e))),i=r.some((e=>t.startsWith(e)));e&&!i||(a[o]=s)}else{let n=e(s,t);Object.keys(n).length>0&&(a[o]=n)}}return a}(e)}let xe=`visitor_id`;function Se(e){return e.storage_property_name?e.storage_property_name:e.property_name_factory(xe)}let Ce=`${i}_${xe}`;function we(e,t){try{localStorage.setItem(Se(t),e)}catch{}}let Te=`cache`;function T(e){try{let t=localStorage.getItem(e.property_name_factory(Te));return JSON.parse(t)||{}}catch{}return{}}function Ee(e){return e.cache_lifetime_in_ms>r?Date.now()+r:Date.now()+e.cache_lifetime_in_ms}var E=class extends Error{constructor(e){super(`HTTP error! status: ${e}`),this.status=e}};let D=null,O=null;async function De(e,t,n,r){let i=await fetch(e,{method:`POST`,headers:{"x-api-key":n.api_key,Authorization:`custom-authorized`,"Content-Type":`application/json`},body:JSON.stringify(t)});if(!i.ok)throw new E(i.status);let a=await i.json();return a.visitorId&&a.visitorId!==r&&we(a.visitorId,n),O=a,function(e,t){!e.cache_api_call||!e.cache_lifetime_in_ms||(function(e,t){let n={...T(e),...t};try{localStorage.setItem(e.property_name_factory(Te),JSON.stringify(n))}catch{}})(e,{apiResponseExpiry:Ee(e),apiResponse:t})}(n,a),a}let Oe=(e,t)=>{if(e.cache_api_call){if(O)return Promise.resolve(O);let t=function(e){let t=T(e);if(t&&t.apiResponse&&t.apiResponseExpiry&&Date.now()<=t.apiResponseExpiry)return t.apiResponse}(e);if(t)return Promise.resolve(t);if(D)return D}let n=`${e.api_endpoint||a}/thumbmark`,r=function(e){try{let t=Se(e),n=localStorage.getItem(t);return n||t===Ce||(n=localStorage.getItem(Ce),n&&we(n,e)),n}catch{return null}}(e),i={components:t,options:e,clientHash:h(C(t)),version:`1.7.6`};if(r&&(i.visitorId=r),e.metadata){let t=typeof e.metadata==`function`?e.metadata():e.metadata;t&&((typeof t==`string`?t.length:JSON.stringify(t).length)>1e3?console.error(`ThumbmarkJS: Metadata exceeds 1000 characters. Skipping metadata.`):i.metadata=t)}let o=e.timeout||5e3,s=async function(e,t,n,r){for(let i=0;i<3;i++){i>0&&await new Promise((e=>setTimeout(e,200*i)));try{return await De(e,t,n,r)}catch(e){if(e instanceof E||i===2)throw e}}throw Error(`Unreachable`)}(n,i,e,r).finally((()=>{D=null})),c=new Promise((t=>{setTimeout((()=>{t(T(e)?.apiResponse||{info:{timed_out:!0},...r&&{visitorId:r}})}),o)}));return D=Promise.race([s,c]),D};async function ke(e,t={}){var n;if(typeof document>`u`||typeof window>`u`)return{thumbmark:``,components:{},info:{},version:`1.7.6`,error:[{type:`fatal`,message:`Browser environment required`}]};try{let r={...o,...e},i=[],s=r.logging&&!sessionStorage.getItem(`_tmjs_l`)&&Math.random()<1e-4,{elapsed:c,resolvedComponents:l,errors:u}=await Ae({...he,..._e,...t},r);i.push(...u);let d={},f={};if(s||r.experimental){let{elapsed:e,resolvedComponents:t,errors:n}=await Ae(ge,r);d=t,f=e,i.push(...n)}let p=r.api_key?Oe(r,l):null,m=null;if(p)try{m=await p}catch(e){if(e instanceof E&&e.status===403)return{error:[{type:`api_unauthorized`,message:`Invalid API key or quota exceeded`}],components:{},info:{},version:`1.7.6`,thumbmark:``};i.push({type:e instanceof E?`api_error`:`network_error`,message:e instanceof Error?e.message:String(e)})}(n=m?.info)!=null&&n.timed_out&&i.push({type:`api_timeout`,message:`API request timed out`});let g={...c,...f},_=r.performance?{elapsed:g}:{},ee=be(m?.components||{},r),v={...l,...ee},y=m?.info||{uniqueness:{score:`api only`}},te=m?.thumbmark??h(C(v));return s&&async function(e,t,n,r={},i=[]){let o=`${a}/log`,s={thumbmark:e,components:t,experimental:r,version:`1.7.6`,options:n,path:(window==null?void 0:window.location)?.pathname,...i.length>0&&{errors:i}};sessionStorage.setItem(`_tmjs_l`,`1`);try{await fetch(o,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(s)})}catch{}}(te,v,r,d,i).catch((()=>{})),{...m?.visitorId&&{visitorId:m.visitorId},thumbmark:te,components:v,info:y,version:`1.7.6`,..._,...i.length>0&&{error:i},...Object.keys(d).length>0&&r.experimental&&{experimental:d},...m?.requestId&&{requestId:m.requestId},...m?.metadata&&{metadata:m.metadata}}}catch(e){return{thumbmark:``,components:{},info:{},version:`1.7.6`,error:[{type:`fatal`,message:e instanceof Error?e.message:String(e)}]}}}async function Ae(e,t){let n={...o,...t},r=ye(n).filter((e=>!e.includes(`.`))),i=Object.entries(e).filter((([e])=>!(n?.exclude)?.includes(e))).filter((([e])=>!r.includes(e))).filter((([e])=>(n?.include)?.some((e=>e.includes(`.`)))?(n?.include)?.some((t=>t.startsWith(e))):n?.include?.length===0||(n?.include)?.includes(e))),a=i.map((([e])=>e)),s=await function(e,t,n){return Promise.all(e.map((e=>{let r=performance.now();return Promise.race([e.then((e=>({value:e,elapsed:performance.now()-r}))).catch((e=>({value:n,elapsed:performance.now()-r,error:e instanceof Error?e.message:String(e)}))),(i=t,a=n,new Promise((e=>{setTimeout((()=>e(a)),i)}))).then((e=>({value:e,elapsed:performance.now()-r,error:`timeout`})))]);var i,a})))}(i.map((([e,n])=>n(t))),n?.timeout||5e3,ve),c={},l={},u=[];return s.forEach(((e,t)=>{let n=a[t];c[n]=e.elapsed??0,e.error===`timeout`?u.push({type:`component_timeout`,message:`Component '${n}' timed out`,component:n}):e.error&&u.push({type:`component_error`,message:e.error,component:n}),e.value!=null&&(l[n]=e.value)})),{elapsed:c,resolvedComponents:be(l,n),errors:u}}var je=class{constructor(e){this.options={...o,...e},this.customComponents={}}async get(e){return ke({...this.options,...e},this.customComponents)}getVersion(){return`1.7.6`}includeComponent(e,t){this.customComponents[e]=t}};let k=(e,t)=>{if(e==null)return t;if(typeof e==`number`)return e;let n=parseInt(e);return isNaN(n)?t:n},Me=(e,t)=>e==null?t:typeof e==`number`?`${e}px`:e||t;var Ne=n({fixLocalstorage:()=>Ie,getClientEnv:()=>M,getClientFingerprint:()=>P,isMethodSupported:()=>Ue,loadScript:()=>Pe,parsePx:()=>k,stringify:()=>Fe,toCssPx:()=>Me,transformStyle:()=>A,validateComponentProps:()=>F,withError:()=>He});let A=e=>Object.keys(e).reduce((t,n)=>(typeof e[n]==`string`?t[n]=e[n]:t[n]=`${e[n]}px`,t),{}),Pe=(e,t,n,r)=>new Promise((i,a)=>{let o=Array.from(document.scripts).find(t=>t.src===e);if(o)if(r)o.remove();else{i(o);return}let s=document.createElement(`script`);s.src=e,s.onload=()=>i(s),s.onerror=e=>a(e),t&&s.setAttribute(`nonce`,t),n&&Object.keys(n).forEach(e=>{n[e]&&(s.dataset[e]=n[e])}),document.head.appendChild(s)}),Fe=e=>Object.keys(e).reduce((t,n)=>(e[n]!==void 0&&t.push(`${encodeURIComponent(n)}=${encodeURIComponent(e[n])}`),t),[]).join(`&`),Ie=()=>{let e;try{({localStorage:e}=window)}catch{let t=(()=>{let e=new Map;return{getItem(t){return e.get(t)},setItem:function(t,n){e.set(t,n)},clear:function(){e=new Map},removeItem:function(t){e.delete(t)}}})();Object.defineProperty(window,`localStorage`,{value:t}),e=t}return e},Le=()=>{let e,t=Ie();try{e=t.getItem(`i18nextLng`)}catch{}return e?e.split(`-`)[0]:``},j=e=>{try{return String(e()??``)}catch{return``}},M=()=>{let e=[window.screen.colorDepth,window.screen.height,window.screen.width,new Date().getTimezoneOffset(),Le(),j(()=>Intl.DateTimeFormat().resolvedOptions().timeZone),j(()=>window.devicePixelRatio),j(()=>navigator.hardwareConcurrency),j(()=>navigator.deviceMemory),j(()=>navigator.maxTouchPoints),j(()=>navigator.platform),j(()=>navigator.languages?.join(`,`))].join(`|`);return window.btoa(e)},Re=`_monei_fp`,ze=e=>{if(typeof crypto<`u`&&typeof crypto.getRandomValues==`function`){let t=new Uint8Array(e);return crypto.getRandomValues(t),Array.from(t,e=>(e%16).toString(16)).join(``)}return Array.from({length:e},()=>Math.floor(Math.random()*16).toString(16)).join(``)},N=null,Be=async()=>{if(N)return{seed:N};try{let e=Ie();if(N=e.getItem(Re),!N){N=ze(32);try{e.setItem(Re,N)}catch{}}}catch{N=ze(32)}return{seed:N}},Ve=new je({logging:!1});Ve.includeComponent(`persistent_seed`,Be);let P=async()=>{let[,e]=await He(Ve.get());return e?.thumbmark??``},He=async e=>{try{return[void 0,await e]}catch(e){return[e,void 0]}},Ue=(e,t)=>e.paymentMethods&&e.paymentMethods.includes(t),F=({props:e})=>{if(!e.paymentId&&!(e.accountId&&e.amount&&e.currency))throw Error(`You need to provide paymentId or accountId amount and currency`)},We=`prod`,I={local:{domain:`http://card-input.localhost:1355`,paymentPageUrl:`http://payment-page.localhost:1355/`,cardInputUrl:`http://card-input.localhost:1355/`,paymentModalUrl:`http://payment-modal.localhost:1355/`,paypalUrl:`http://paypal.localhost:1355/`,bizumUrl:`http://bizum.localhost:1355/`,bizumButtonUrl:`http://bizum-button.localhost:1355/`,paymentRequestUrl:`http://payment-request.localhost:1355/`,apiUrl:`https://api.monei-dev.com/v1`,secureDomain:`https://secure.monei-dev.com`,rootDomain:`monei-dev.com`},"local-prod":{domain:`http://card-input.localhost:1355`,paymentPageUrl:`http://payment-page.localhost:1355/`,cardInputUrl:`http://card-input.localhost:1355/`,paymentModalUrl:`http://payment-modal.localhost:1355/`,paypalUrl:`http://paypal.localhost:1355/`,bizumUrl:`http://bizum.localhost:1355/`,bizumButtonUrl:`http://bizum-button.localhost:1355/`,paymentRequestUrl:`http://payment-request.localhost:1355/`,apiUrl:`https://api.monei.com/v1`,secureDomain:`https://secure.monei.com`,rootDomain:`monei.com`},tunnel:{domain:`https://card-input.monei-dev-tunnel.com`,paymentPageUrl:`https://payment-page.monei-dev-tunnel.com/`,cardInputUrl:`https://card-input.monei-dev-tunnel.com/`,paymentModalUrl:`https://payment-modal.monei-dev-tunnel.com/`,paypalUrl:`https://paypal.monei-dev-tunnel.com/`,bizumUrl:`https://bizum.monei-dev-tunnel.com/`,bizumButtonUrl:`https://bizum-button.monei-dev-tunnel.com/`,paymentRequestUrl:`https://payment-request.monei-dev-tunnel.com/`,apiUrl:`https://api.monei.com/v1`,secureDomain:`https://secure.monei.com`,rootDomain:`monei.com`},dev:{domain:`https://js.monei-dev.com`,apiUrl:`https://api.monei-dev.com/v1`,secureDomain:`https://secure.monei-dev.com`,rootDomain:`monei-dev.com`},prod:{domain:`https://js.monei.com`,apiUrl:`https://api.monei.com/v1`,secureDomain:`https://secure.monei.com`,rootDomain:`monei.com`}}[We],L=I.domain,R={domain:L,version:`v1`,stage:We,isProduction:We===`prod`,paymentPageUrl:I.paymentPageUrl||`${L}/v1/payment-page/`,cardInputUrl:I.cardInputUrl||`${L}/v1/inner-card-input/`,paymentModalUrl:I.paymentModalUrl||`${L}/v1/inner-payment-modal/`,paypalUrl:I.paypalUrl||`${L}/v1/inner-paypal/`,bizumUrl:I.bizumUrl||`${L}/v1/inner-bizum/`,bizumButtonUrl:I.bizumButtonUrl||`${L}/v1/inner-bizum-button/`,paymentRequestUrl:I.paymentRequestUrl||`${L}/v1/inner-payment-request/`,...I};var Ge=n({confirmPayment:()=>Je,createApplePaySession:()=>Ze,createPayment:()=>Ye,createToken:()=>Ke,getPayment:()=>qe,getPaymentMethods:()=>V,sendPaymentReceipt:()=>Xe,validateBizumPhone:()=>Qe});let z=async(e,{method:t=`GET`,headers:n,body:r}={})=>{t===`POST`&&(n={"Content-Type":`application/json`,...n});let i=await fetch(`${R.apiUrl}${e}`,{method:t,headers:n,body:r?JSON.stringify(r):void 0}),[,a]=await He(i.json());if(!i.ok)throw a||Error(i.statusText);return a},B={},V=async({accountId:e,paymentId:t})=>{let n;if(t)n={paymentId:t};else if(e)n={accountId:e};else throw Error(`You need to provide paymentId or accountId`);let r=Fe(n);if(r in B)return B[r];let i=z(`/client-payment-methods?${r}`);return B[r]=i,i.catch(()=>delete B[r]),i},Ke=async({paymentMethod:e,paymentId:t,sessionId:n,amount:r,currency:i,accountId:a,transactionType:o})=>{let s;if(t)s={paymentId:t,paymentMethod:e};else if(a)s={accountId:a,paymentMethod:e,sessionId:n,amount:r,currency:i,transactionType:o};else throw Error(`You need to provide paymentId or accountId`);let c=await z(`/tokens`,{method:`POST`,headers:{"X-Client-Env":M(),"X-Client-Fingerprint":await P()},body:s});return c.paymentToken&&!c.token&&(c.token=c.paymentToken),c},qe=async e=>z(`/payments/${e}/client-get`),Je=async({paymentId:e,...t})=>z(`/payments/${e}/client-confirm`,{method:`POST`,headers:{"X-Client-Env":M(),"X-Client-Fingerprint":await P()},body:t}),Ye=async({signature:e,...t})=>z(`/client-payments`,{method:`POST`,headers:{"X-Client-Env":M(),"X-Client-Fingerprint":await P(),"Client-Signature":e},body:t}),Xe=async({paymentId:e,customerEmail:t,signature:n,language:r})=>z(`/payments/${e}/client-receipt`,{method:`POST`,body:{customerEmail:t,signature:n,language:r}}),Ze=async e=>z(`/apple-pay/sessions`,{method:`POST`,body:e}),Qe=async e=>z(`/bizum/validate-phone`,{method:`POST`,body:e});var $e=class{constructor(){this.listeners=new Map,this.destroyed=!1}on(e,t){if(this.destroyed)return{cancel:()=>{}};let n=this.listeners.get(e);return n||(n=new Set,this.listeners.set(e,n)),n.add(t),{cancel:()=>{n.delete(t)}}}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};return this.on(e,n)}trigger(e,...t){if(this.destroyed)return;let n=this.listeners.get(e);if(n)for(let e of n)try{e(...t)}catch(e){console.error(e)}}off(e,t){let n=this.listeners.get(e);n&&n.delete(t)}destroy(){this.destroyed=!0,this.listeners.clear()}};function et(e){return({React:t})=>t.forwardRef(function(n,r){let i=t.useRef(null),a=t.useRef(null),o=t.useRef(!1),s=t.useRef({});return t.useLayoutEffect(()=>{let t=i.current;if(!t)return;let s=!1,c=new e({...n});return a.current=c,c.render(t).then(()=>{s||(tt(r,c),o.current=!0)}).catch(e=>{s||console.error(e)}),()=>{s=!0,c.destroy(),a.current=null,o.current=!1,tt(r,null)}},[]),t.useEffect(()=>{!o.current||!a.current||nt(s.current,n)||(s.current={...n},a.current.updateProps({...n}).catch(rt))}),t.createElement(`div`,{ref:i})})}function tt(e,t){typeof e==`function`?e(t):e&&(e.current=t)}function nt(e,t){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(e[r]!==t[r])return!1;return!0}function rt(){}function it(e){return()=>({template:`<div></div>`,inheritAttrs:!1,mounted(){let t=this.$el;this.__bridgeInstance=new e({...this.$attrs}),this.__bridgeInstance.render(t).catch(console.error)},watch:{$attrs:{handler(){this.__bridgeInstance&&this.__bridgeInstance.updateProps({...this.$attrs}).catch(()=>{})},deep:!0}},unmounted(){this.__bridgeInstance&&=(this.__bridgeInstance.destroy(),null)}})}function at(e){return({Component:t,NgModule:n,ElementRef:r,NgZone:i,Inject:a})=>{class o{constructor(e,t){this.props={},this.__bridgeInstance=null,this._prevProps={},this.elementRef=e,this.zone=t}getProps(){let e={...this.props},{zone:t}=this;for(let[n,r]of Object.entries(e))typeof r==`function`&&(e[n]=function(...e){return t.run(()=>r.apply(this,e))});return e}ngOnInit(){let t=this.elementRef.nativeElement;this.__bridgeInstance=new e(this.getProps()),this.__bridgeInstance.render(t).catch(console.error)}ngDoCheck(){this.__bridgeInstance&&!ot(this._prevProps,this.props)&&(this._prevProps={...this.props},this.__bridgeInstance.updateProps(this.getProps()).catch(()=>{}))}ngOnDestroy(){this.__bridgeInstance&&=(this.__bridgeInstance.destroy(),null)}}o.parameters=[[new a(r)],[new a(i)]],o.annotations=[new t({selector:e.prototype.__options?.tag||`bridge-component`,template:`<div></div>`,inputs:[`props`]})];class s{}return s.annotations=[new n({declarations:[o],exports:[o]})],s}}function ot(e,t){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(e[r]!==t[r])return!1;return!0}let st={react:et,vue3:it,angular:at};function ct(e,t,n){let r=st[e];if(!r)throw Error(`Unknown driver: ${e}. Available: ${Object.keys(st).join(`, `)}`);return r(t)(n)}var H=class extends Error{code;constructor(e,t){super(t),this.name=`PenpalError`,this.code=e}},lt=e=>({name:e.name,message:e.message,stack:e.stack,penpalCode:e instanceof H?e.code:void 0}),ut=({name:e,message:t,stack:n,penpalCode:r})=>{let i=r?new H(r,t):Error(t);return i.name=e,i.stack=n,i},dt=class{value;transferables;constructor(e,t){this.value=e,this.transferables=t?.transferables}},U=`penpal`,W=e=>typeof e==`object`&&!!e,ft=e=>typeof e==`function`,pt=e=>W(e)&&e.namespace===U,G=e=>e.type===`SYN`,mt=e=>e.type===`ACK1`,ht=e=>e.type===`ACK2`,gt=e=>e.type===`CALL`,_t=e=>e.type===`REPLY`,vt=e=>e.type===`DESTROY`,yt=(e,t=[])=>{let n=[];for(let r of Object.keys(e)){let i=e[r];ft(i)?n.push([...t,r]):W(i)&&n.push(...yt(i,[...t,r]))}return n},bt=(e,t)=>{let n=e.reduce((e,t)=>W(e)?e[t]:void 0,t);return ft(n)?n:void 0},K=e=>e.join(`.`),xt=(e,t,n)=>({namespace:U,channel:e,type:`REPLY`,callId:t,isError:!0,...n instanceof Error?{value:lt(n),isSerializedErrorInstance:!0}:{value:n}}),St=(e,t,n,r)=>{let i=!1,a=async a=>{if(i||!gt(a))return;r?.(`Received ${K(a.methodPath)}() call`,a);let{methodPath:o,args:s,id:c}=a,l,u;try{let e=bt(o,t);if(!e)throw new H(`METHOD_NOT_FOUND`,`Method \`${K(o)}\` is not found.`);let r=await e(...s);r instanceof dt&&(u=r.transferables,r=await r.value),l={namespace:U,channel:n,type:`REPLY`,callId:c,value:r}}catch(e){l=xt(n,c,e)}if(!i)try{r?.(`Sending ${K(o)}() reply`,l),e.sendMessage(l,u)}catch(t){throw t.name===`DataCloneError`&&(l=xt(n,c,t),r?.(`Sending ${K(o)}() reply`,l),e.sendMessage(l)),t}};return e.addMessageHandler(a),()=>{i=!0,e.removeMessageHandler(a)}},Ct=crypto.randomUUID?.bind(crypto)??(()=>[,,,,].fill(0).map(()=>Math.floor(Math.random()*(2**53-1)).toString(16)).join(`-`)),wt=class{transferables;timeout;constructor(e){this.transferables=e?.transferables,this.timeout=e?.timeout}},Tt=new Set([`apply`,`call`,`bind`]),Et=(e,t,n=[])=>new Proxy(n.length?()=>{}:Object.create(null),{get(r,i){if(i!==`then`)return n.length&&Tt.has(i)?Reflect.get(r,i):Et(e,t,[...n,i])},apply(t,r,i){return e(n,i)}}),Dt=e=>new H(`CONNECTION_DESTROYED`,`Method call ${K(e)}() failed due to destroyed connection`),Ot=(e,t,n)=>{let r=!1,i=new Map,a=e=>{if(!_t(e))return;let{callId:t,value:r,isError:a,isSerializedErrorInstance:o}=e,s=i.get(t);s&&(i.delete(t),n?.(`Received ${K(s.methodPath)}() call`,e),a?s.reject(o?ut(r):r):s.resolve(r))};return e.addMessageHandler(a),{remoteProxy:Et((a,o)=>{if(r)throw Dt(a);let s=Ct(),c=o[o.length-1],l=c instanceof wt,{timeout:u,transferables:d}=l?c:{},f=l?o.slice(0,-1):o;return new Promise((r,o)=>{let c=u===void 0?void 0:window.setTimeout(()=>{i.delete(s),o(new H(`METHOD_CALL_TIMEOUT`,`Method call ${K(a)}() timed out after ${u}ms`))},u);i.set(s,{methodPath:a,resolve:r,reject:o,timeoutId:c});try{let r={namespace:U,channel:t,type:`CALL`,id:s,methodPath:a,args:f};n?.(`Sending ${K(a)}() call`,r),e.sendMessage(r,d)}catch(e){o(new H(`TRANSMISSION_FAILED`,e.message))}})},n),destroy:()=>{r=!0,e.removeMessageHandler(a);for(let{methodPath:e,reject:t,timeoutId:n}of i.values())clearTimeout(n),t(Dt(e));i.clear()}}},kt=()=>{let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}},At=`deprecated-penpal`,jt=e=>W(e)&&`penpal`in e,Mt=e=>e.split(`.`),Nt=e=>e.join(`.`),Pt=e=>{try{return JSON.stringify(e)}catch{return String(e)}},Ft=e=>new H(`TRANSMISSION_FAILED`,`Unexpected message to translate: ${Pt(e)}`),It=e=>{if(e.penpal===`syn`)return{namespace:U,channel:void 0,type:`SYN`,participantId:At};if(e.penpal===`ack`)return{namespace:U,channel:void 0,type:`ACK2`};if(e.penpal===`call`)return{namespace:U,channel:void 0,type:`CALL`,id:e.id,methodPath:Mt(e.methodName),args:e.args};if(e.penpal===`reply`)return e.resolution===`fulfilled`?{namespace:U,channel:void 0,type:`REPLY`,callId:e.id,value:e.returnValue}:{namespace:U,channel:void 0,type:`REPLY`,callId:e.id,isError:!0,...e.returnValueIsError?{value:e.returnValue,isSerializedErrorInstance:!0}:{value:e.returnValue}};throw Ft(e)},Lt=e=>{if(mt(e))return{penpal:`synAck`,methodNames:e.methodPaths.map(Nt)};if(gt(e))return{penpal:`call`,id:e.id,methodName:Nt(e.methodPath),args:e.args};if(_t(e))return e.isError?{penpal:`reply`,id:e.callId,resolution:`rejected`,...e.isSerializedErrorInstance?{returnValue:e.value,returnValueIsError:!0}:{returnValue:e.value}}:{penpal:`reply`,id:e.callId,resolution:`fulfilled`,returnValue:e.value};throw Ft(e)},Rt=({messenger:e,methods:t,timeout:n,channel:r,log:i})=>{let a=Ct(),o,s=[],c=!1,l=yt(t),{promise:u,resolve:d,reject:f}=kt(),p=n===void 0?void 0:setTimeout(()=>{f(new H(`CONNECTION_TIMEOUT`,`Connection timed out after ${n}ms`))},n),m=()=>{for(let e of s)e()},h=()=>{if(c)return;s.push(St(e,t,r,i));let{remoteProxy:n,destroy:a}=Ot(e,r,i);s.push(a),clearTimeout(p),c=!0,d({remoteProxy:n,destroy:m})},g=()=>{let t={namespace:U,type:`SYN`,channel:r,participantId:a};i?.(`Sending handshake SYN`,t);try{e.sendMessage(t)}catch(e){f(new H(`TRANSMISSION_FAILED`,e.message))}},_=t=>{if(i?.(`Received handshake SYN`,t),t.participantId===o&&o!==At||(o=t.participantId,g(),!(a>o||o===At)))return;let n={namespace:U,channel:r,type:`ACK1`,methodPaths:l};i?.(`Sending handshake ACK1`,n);try{e.sendMessage(n)}catch(e){f(new H(`TRANSMISSION_FAILED`,e.message));return}},ee=t=>{i?.(`Received handshake ACK1`,t);let n={namespace:U,channel:r,type:`ACK2`};i?.(`Sending handshake ACK2`,n);try{e.sendMessage(n)}catch(e){f(new H(`TRANSMISSION_FAILED`,e.message));return}h()},v=e=>{i?.(`Received handshake ACK2`,e),h()},y=e=>{G(e)&&_(e),mt(e)&&ee(e),ht(e)&&v(e)};return e.addMessageHandler(y),s.push(()=>e.removeMessageHandler(y)),g(),u},zt=e=>{let t=!1,n;return(...r)=>(t||(t=!0,n=e(...r)),n)},Bt=new WeakSet,Vt=({messenger:e,methods:t={},timeout:n,channel:r,log:i})=>{if(!e)throw new H(`INVALID_ARGUMENT`,`messenger must be defined`);if(Bt.has(e))throw new H(`INVALID_ARGUMENT`,`A messenger can only be used for a single connection`);Bt.add(e);let a=[e.destroy],o=zt(t=>{if(t){let t={namespace:U,channel:r,type:`DESTROY`};try{e.sendMessage(t)}catch{}}for(let e of a)e();i?.(`Connection destroyed`)}),s=e=>pt(e)&&e.channel===r;return{promise:(async()=>{try{e.initialize({log:i,validateReceivedMessage:s}),e.addMessageHandler(e=>{vt(e)&&o(!1)});let{remoteProxy:c,destroy:l}=await Rt({messenger:e,methods:t,timeout:n,channel:r,log:i});return a.push(l),c}catch(e){throw o(!0),e}})(),destroy:()=>{o(!0)}}},Ht=class{#e;#t;#n;#r;#i;#a=new Set;#o;#s=!1;constructor({remoteWindow:e,allowedOrigins:t}){if(!e)throw new H(`INVALID_ARGUMENT`,`remoteWindow must be defined`);this.#e=e,this.#t=t?.length?t:[window.origin]}initialize=({log:e,validateReceivedMessage:t})=>{this.#n=e,this.#r=t,window.addEventListener(`message`,this.#d)};sendMessage=(e,t)=>{if(G(e)){let n=this.#l(e);this.#e.postMessage(e,{targetOrigin:n,transfer:t});return}if(mt(e)||this.#s){let n=this.#s?Lt(e):e,r=this.#l(e);this.#e.postMessage(n,{targetOrigin:r,transfer:t});return}if(ht(e)){let{port1:n,port2:r}=new MessageChannel;this.#o=n,n.addEventListener(`message`,this.#f),n.start();let i=[r,...t||[]],a=this.#l(e);this.#e.postMessage(e,{targetOrigin:a,transfer:i});return}if(this.#o){this.#o.postMessage(e,{transfer:t});return}throw new H(`TRANSMISSION_FAILED`,`Cannot send message because the MessagePort is not connected`)};addMessageHandler=e=>{this.#a.add(e)};removeMessageHandler=e=>{this.#a.delete(e)};destroy=()=>{window.removeEventListener(`message`,this.#d),this.#u(),this.#a.clear()};#c=e=>this.#t.some(t=>t instanceof RegExp?t.test(e):t===e||t===`*`);#l=e=>{if(G(e))return`*`;if(!this.#i)throw new H(`TRANSMISSION_FAILED`,`Cannot send message because the remote origin is not established`);return this.#i===`null`&&this.#t.includes(`*`)?`*`:this.#i};#u=()=>{this.#o?.removeEventListener(`message`,this.#f),this.#o?.close(),this.#o=void 0};#d=({source:e,origin:t,ports:n,data:r})=>{if(e===this.#e){if(jt(r)){this.#n?.(`Please upgrade the child window to the latest version of Penpal.`),this.#s=!0;try{r=It(r)}catch(e){this.#n?.(`Failed to translate deprecated message: ${e.message}`);return}}if(this.#r?.(r)){if(!this.#c(t)){this.#n?.(`Received a message from origin \`${t}\` which did not match allowed origins \`[${this.#t.join(`, `)}]\``);return}if(G(r)&&(this.#u(),this.#i=t),ht(r)&&!this.#s){if(this.#o=n[0],!this.#o){this.#n?.(`Ignoring ACK2 because it did not include a MessagePort`);return}this.#o.addEventListener(`message`,this.#f),this.#o.start()}for(let e of this.#a)e(r)}}};#f=({data:e})=>{if(this.#r?.(e))for(let t of this.#a)t(e)}};let q={RENDERED:`RENDERED`,RESIZE:`RESIZE`,DESTROY:`DESTROY`,BEFORE_CLOSE:`BEFORE_CLOSE`,DISPLAY:`DISPLAY`},Ut=new Set([`onClose`,`onDestroy`,`onRendered`,`onRender`,`onDisplay`,`onResize`,`onProps`]);function J(e){e&&e.remove()}function Y(e){return typeof e==`number`?`${e}px`:e}let Wt={"monei-card-input":`allow-scripts allow-forms allow-same-origin`,"monei-bizum":`allow-scripts allow-forms allow-same-origin allow-popups allow-popups-to-escape-sandbox`,"monei-bizum-button":`allow-scripts allow-forms allow-same-origin allow-popups allow-popups-to-escape-sandbox`,"monei-paypal":`allow-scripts allow-forms allow-same-origin allow-popups allow-popups-to-escape-sandbox`,"monei-payment-request":`allow-scripts allow-forms allow-same-origin allow-popups`,"monei-payment-modal":`allow-scripts allow-forms allow-same-origin allow-popups allow-popups-to-escape-sandbox`,"monei-google-pay":`allow-scripts allow-forms allow-same-origin allow-popups`};function Gt(e){if(!e)throw Error(`render() requires a container element or selector`);if(typeof e==`string`){let t=document.querySelector(e);if(!t)throw Error(`Container not found: ${e}`);return t}return e}function Kt(e){return`${e}-${Math.random().toString(36).slice(2,9)}`}function qt(e,t){let n=[[`onClose`,q.DESTROY],[`onDestroy`,q.DESTROY],[`onRendered`,q.RENDERED],[`onResize`,q.RESIZE]];for(let[r,i]of n)t.on(i,(...t)=>{let n=e[r];typeof n==`function`&&n(...t)})}function Jt(e){let{props:t,options:n,state:r,dispatchMap:i}=e,a={},o=new Set(n.computedProps?Object.keys(n.computedProps):[]);if(n.computedProps)for(let[e,o]of Object.entries(n.computedProps)){let n=o.factory({props:t,state:r});o.type===`function`?i.set(e,n):a[e]=n}for(let[e,n]of Object.entries(t))Ut.has(e)||o.has(e)||(typeof n==`function`?i.set(e,n):a[e]=n);let s=new Set([`close`,`resize`,`show`,`hide`,`getParentDomain`,`focus`]);return{dataProps:a,functionNames:[...i.keys()].filter(e=>!s.has(e))}}function Yt(e,t){let n={dispatchMap:new Map,connection:null,remote:null,containerEl:null,frame:null,destroyed:!1,ownsContainer:!1,pendingPropsUpdate:null,pendingRemovals:new Set},r=!1,i=!1;n.dispatchMap.set(`resize`,i=>{let{autoResize:a}=t,o={};i.width!==void 0&&(!a||a.width===!0)&&(o.width=i.width),i.height!==void 0&&(!a||a.height===!0)&&(o.height=i.height),n.frame&&(o.width!==void 0&&(n.frame.style.width=Y(o.width)),o.height!==void 0&&(n.frame.style.height=Y(o.height))),r||(r=!0,e.event.trigger(q.RENDERED)),e.event.trigger(q.RESIZE,o)}),n.dispatchMap.set(`close`,()=>e.close()),n.dispatchMap.set(`show`,()=>{n.frame&&(n.frame.style.display=``)}),n.dispatchMap.set(`hide`,()=>{n.frame&&(n.frame.style.display=`none`)}),n.dispatchMap.set(`getParentDomain`,()=>window.location.origin),n.dispatchMap.set(`focus`,()=>{n.frame&&n.frame.focus()}),e.render=async a=>{if(n.destroyed)throw Error(`Component is destroyed`);if(n.frame)throw Error(`Component already rendered`);let o=Gt(a),s=Kt(t.tag),c=o.ownerDocument,l=c.createElement(`iframe`);l.src=t.url,l.setAttribute(`title`,t.tag.replace(/-/g,`_`)),l.setAttribute(`allowpaymentrequest`,`true`),l.setAttribute(`allow`,`payment`),l.style.border=`none`;let u=Wt[t.tag]??`allow-scripts allow-forms allow-same-origin`;l.setAttribute(`sandbox`,u),i||=(qt(e.props,e.event),!0);let d=[],f={on(t,n){let r=e.event.on(t,n);return d.push(r),r},once(t,n){let r=e.event.once(t,n);return d.push(r),r},trigger(t,...n){e.event.trigger(t,...n)},off(t,n){e.event.off(t,n)},destroy(){e.event.destroy()}},p,m,h={},g=[];try{t.prerenderTemplate&&(p=t.prerenderTemplate({uid:s,frame:l,placeholder:void 0,doc:c,props:e.props,event:f,dimensions:t.dimensions??{width:`100%`,height:`auto`},state:e.state,container:o})),t.containerTemplate&&(m=t.containerTemplate({uid:s,frame:l,placeholder:p,doc:c,props:e.props,event:f,dimensions:t.dimensions??{width:`100%`,height:`auto`},state:e.state,container:o})),{dataProps:h,functionNames:g}=Jt({props:e.props,options:t,state:e.state,dispatchMap:n.dispatchMap})}catch(e){for(let e of d)e.cancel();let t=new Set([`close`,`resize`,`show`,`hide`,`getParentDomain`,`focus`]);for(let e of n.dispatchMap.keys())t.has(e)||n.dispatchMap.delete(e);throw e}n.frame=l;let _=()=>{l.contentWindow&&l.contentWindow.postMessage({type:`__monei_bridge_init__`,props:h,functionNames:g},new URL(t.url).origin)};try{if(m?(o.appendChild(m),n.containerEl=m,n.ownsContainer=!0):(o.appendChild(l),n.containerEl=o),e.event.trigger(q.DISPLAY),l.addEventListener(`load`,_),l.contentWindow&&_(),!l.contentWindow)throw Error(`iframe contentWindow is not available — frame may not be in the DOM`);let i=Vt({messenger:new Ht({remoteWindow:l.contentWindow,allowedOrigins:[new URL(t.url).origin]}),methods:{callParent:(e,t)=>{let r=n.dispatchMap.get(e);if(!r)throw Error(`Unknown parent method: ${e}`);return r(...t)}}});n.connection=i;let a;try{a=await i.promise}catch(e){if(n.destroyed)return;throw e}if(n.destroyed||(n.remote=a,e.state.__callChild=a.callChild,await a.updateProps(h,g),n.destroyed))return;if(n.pendingPropsUpdate){let e=n.pendingPropsUpdate;n.pendingPropsUpdate=null;let t=new Set(e.functionNames??[]),r=new Map;for(let i of Object.keys(e.dataProps))n.dispatchMap.has(i)&&!t.has(i)&&(r.set(i,n.dispatchMap.get(i)),n.pendingRemovals.add(i));if(await n.remote.updateProps(e.dataProps,e.functionNames),n.destroyed)return;for(let[e,t]of r)n.pendingRemovals.delete(e),n.dispatchMap.get(e)===t&&n.dispatchMap.delete(e)}r||(r=!0,e.event.trigger(q.RENDERED)),l.removeEventListener(`load`,_)}catch(t){l.removeEventListener(`load`,_);for(let e of d)e.cancel();delete e.state.__callChild,n.connection&&=(n.connection.destroy(),null),n.remote=null,n.frame=null,n.ownsContainer&&n.containerEl?n.containerEl.remove():l.parentNode&&l.remove(),n.containerEl=null,n.ownsContainer=!1,n.pendingPropsUpdate=null,n.pendingRemovals.clear();let i=new Set([`close`,`resize`,`show`,`hide`,`getParentDomain`,`focus`]);for(let e of n.dispatchMap.keys())i.has(e)||n.dispatchMap.delete(e);throw r=!1,t}},e.updateProps=async r=>{if(n.destroyed)throw Error(`Component is destroyed`);let i=Qt(r,t.aliases);if(Object.assign(e.props,i),!n.frame)return;let a={},o=[],s=new Set(t.computedProps?Object.keys(t.computedProps):[]),c=new Map;for(let[e,t]of Object.entries(i))if(!(Ut.has(e)||s.has(e)))if(typeof t==`function`){let r=n.pendingPropsUpdate!=null&&e in n.pendingPropsUpdate.dataProps,i=n.pendingRemovals.has(e);(!n.dispatchMap.has(e)||r||i)&&o.push(e),n.dispatchMap.set(e,t)}else n.dispatchMap.has(e)&&n.remote&&(c.set(e,n.dispatchMap.get(e)),n.pendingRemovals.add(e)),a[e]=t;let l=o.length>0?o:void 0;if(n.remote){await n.remote.updateProps(a,l);for(let[e,t]of c)n.pendingRemovals.delete(e),n.dispatchMap.get(e)===t&&n.dispatchMap.delete(e)}else{if(n.pendingPropsUpdate||={dataProps:{},functionNames:void 0},Object.assign(n.pendingPropsUpdate.dataProps,a),n.pendingPropsUpdate.functionNames){let e=Object.keys(a);if(e.length>0){let t=new Set(e);n.pendingPropsUpdate.functionNames=n.pendingPropsUpdate.functionNames.filter(e=>!t.has(e)),n.pendingPropsUpdate.functionNames.length===0&&(n.pendingPropsUpdate.functionNames=void 0)}}if(l){for(let e of l)delete n.pendingPropsUpdate.dataProps[e];n.pendingPropsUpdate.functionNames=[...n.pendingPropsUpdate.functionNames??[],...l]}}},e.destroy=async()=>{n.destroyed||(n.destroyed=!0,e.event.trigger(q.DESTROY),n.connection&&=(n.connection.destroy(),null),n.remote=null,n.frame&&=(n.frame.remove(),null),n.ownsContainer&&n.containerEl&&n.containerEl.remove(),e.event.destroy(),n.dispatchMap.clear())},e.close=async()=>{await e.destroy()},e.__renderState=n}let Xt={react:`@monei-js/react-components`,vue3:`@monei-js/vue-components`,angular:`@monei-js/angular-components`};function Zt(e){let t=Xt[e],n=t?`Use ${t} instead.`:``;console.warn(`[MONEI] .driver('${e}') is deprecated. ${n}`.trim())}function Qt(e,t){if(!t)return e;let n=new Map;for(let[e,r]of Object.entries(t))n.set(r,e);let r={};for(let[t,i]of Object.entries(e)){let e=n.get(t)??t;r[e]=i}return r}function X(e){class t{constructor(t){this.state={},this.event=new $e;let n=Qt(t,e.aliases);e.defaultProps?this.props={...e.defaultProps({event:this.event}),...n}:this.props={...n},e.validate&&e.validate({props:this.props}),Yt(this,e),e.submit&&(this.submit=e.submit(this))}async render(e){throw Error(`render() not attached`)}async updateProps(e){throw Error(`updateProps() not attached — call render() first`)}async close(){throw Error(`close() not attached`)}async destroy(){throw Error(`destroy() not attached`)}driver(e,n){return Zt(e),ct(e,t,n)}}function n(e){return this instanceof n?new t(e):new n(e)}return n.prototype=t.prototype,n.driver=function(e,t){return Zt(e),ct(e,n,t)},t.prototype.__options=e,n}let Z=function(e){return e.VISIBLE=`is-visible`,e.INVISIBLE=`is-invisible`,e}({});function $t(e={}){let{background:t=`#fff`,overflow:n,borderRadius:r,fadeOnRender:i=!0,allowTransparency:a=!1,modal:o=!1}=e;return function({uid:e,frame:s,placeholder:c,doc:l,props:u,event:d,dimensions:{width:f,height:p}}){if(!s)return;a&&(s.setAttribute(`allowtransparency`,`true`),s.style.background=`transparent`);let m=l.createElement(`div`);m.setAttribute(`id`,e);let h=l.createElement(`style`);if(u?.cspNonce&&h.setAttribute(`nonce`,u.cspNonce),o){let t=l.createElement(`div`);t.classList.add(`backdrop`),h.appendChild(l.createTextNode(`
|
|
12
12
|
#${e} {
|
|
13
13
|
position: fixed;
|
|
14
14
|
inset: 0;
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
#${e} > iframe.${Z.VISIBLE} {
|
|
61
61
|
opacity: 1;
|
|
62
62
|
}
|
|
63
|
-
`)),m.appendChild(s),c&&m.appendChild(c),m.appendChild(h),d.on(q.RESIZE,({width:e,height:t})=>{typeof e==`number`&&(m.style.width=Y(e)),typeof t==`number`&&(m.style.height=Y(t))}),c&&(s.classList.add(Z.INVISIBLE),i&&c.classList.add(Z.VISIBLE),d.on(q.RENDERED,()=>{i?(c.classList.remove(Z.VISIBLE),c.classList.add(Z.INVISIBLE),s.classList.remove(Z.INVISIBLE),s.classList.add(Z.VISIBLE),setTimeout(()=>J(c),1)):(J(c),s.style.transition=`none`,s.classList.remove(Z.INVISIBLE),s.classList.add(Z.VISIBLE))}))}return m}}let Q
|
|
63
|
+
`)),m.appendChild(s),c&&m.appendChild(c),m.appendChild(h),d.on(q.RESIZE,({width:e,height:t})=>{typeof e==`number`&&(m.style.width=Y(e)),typeof t==`number`&&(m.style.height=Y(t))}),c&&(s.classList.add(Z.INVISIBLE),i&&c.classList.add(Z.VISIBLE),d.on(q.RENDERED,()=>{i?(c.classList.remove(Z.VISIBLE),c.classList.add(Z.INVISIBLE),s.classList.remove(Z.INVISIBLE),s.classList.add(Z.VISIBLE),setTimeout(()=>J(c),1)):(J(c),s.style.transition=`none`,s.classList.remove(Z.INVISIBLE),s.classList.add(Z.VISIBLE))}))}return m}}let Q=$t({overflow:`hidden`,borderRadius:`var(--monei-radius, 4px)`}),en=$t({modal:!0}),tn=e=>{if(e.state?.__createToken)return e.state.__createToken;throw Error(`Index is not registered`)},nn=async(e,t)=>{console.warn(`[MONEI] Standalone createToken() is deprecated. Use cardInput.submit() instead.`);let{data:n}=await tn(e)(t);return n},rn=X({tag:`monei-card-input`,url:R.cardInputUrl,dimensions:{width:`100%`,height:`auto`},autoResize:{width:!1,height:!0},aliases:{sessionId:`orderId`,style:`innerStyle`},computedProps:{__getConfig:{factory:({props:e})=>V.bind(null,e),type:`function`}},validate:F,submit:e=>async t=>{let n=e.state?.__createToken;if(!n)throw Error(`CardInput is not rendered or connection is pending — call render() first`);let{data:r}=await n(t);return r},containerTemplate:e=>(e.state.__createToken=async(t={})=>{let n=e.state.__callChild;if(!n)throw Error(`CardInput instance is not registered`);return{data:await n(`createToken`,[t])}},Q(e)),prerenderTemplate:({doc:e,props:t})=>{let n=e.createElement(`html`),r=e.createElement(`body`);r.style.margin=`0`,r.style.background=`#fff`;let i=e.createElement(`div`);i.style.height=`45px`,i.style.boxSizing=`border-box`;let a=t.style||t.innerStyle;return a?.base&&Object.assign(i.style,A(a.base)),a?.loading&&Object.assign(i.style,A(a.loading)),r.appendChild(i),n.appendChild(r),n}}),an=X({tag:`monei-payment-modal`,url:R.paymentModalUrl,dimensions:{width:`100%`,height:`100%`},autoResize:{width:!1,height:!1},aliases:{style:`innerStyle`},containerTemplate:$t({background:`transparent`,fadeOnRender:!1,allowTransparency:!0})}),on=e=>{let t=document.createElement(`div`),n=document.body.style.overflow;Object.assign(document.body.style,{overflow:`hidden`}),Object.assign(t.style,{position:`fixed`,overflow:`hidden`,display:`block`,top:`0`,bottom:`0`,left:`0`,right:`0`,width:`100%`,height:`100%`,zIndex:`99999`}),document.body.appendChild(t);let r=null,i=()=>{r?.destroy(),r=null,Object.assign(document.body.style,{overflow:n}),t.parentNode&&t.parentNode.removeChild(t)};return new Promise((n,a)=>{r=new an({...e,isOpen:!0,onResult:e=>{n(e),i()},onError:e=>{a(e),i()}}),r.render(t).catch(e=>{i(),a(e)})})},$=`monei-paypal`,sn=async(e,t,n)=>{t.__scriptId=(await Pe(n,e.cspNonce,{namespace:$,cspNonce:e.cspNonce},!0)).dataset.uidAuto;let r={layout:`horizontal`,tagline:!1,height:45},i=k(e.style?.borderRadius??e.borderRadius);i&&(r.borderRadius=i);let a={...r,...e.style};a.height=k(a.height,45),e.onLoad?.(!0);let o;await window[$].Buttons({createOrder:async()=>{try{let t=await Ke({paymentId:e.paymentId,accountId:e.accountId,sessionId:e.sessionId,amount:e.amount,currency:e.currency,transactionType:e.transactionType,paymentMethod:{paypal:{}}});return{token:o}=t,t.paypal?.orderId}catch(t){e.onError?.(t);return}},onApprove:function(t){t.orderID?e.onSubmit({token:o}):e.onError?.(t)},onClick:function(t,n){let r=!0;if(e.onBeforeOpen&&(r=e.onBeforeOpen()),!r)return n.reject()},style:a}).render(t.__container)},cn=X({tag:$,url:R.paypalUrl,dimensions:{width:`100%`,height:`0`},autoResize:{width:!1,height:!1},aliases:{style:`innerStyle`},computedProps:{__getConfig:{factory:({props:e})=>V.bind(null,e),type:`function`},__onLoadPayPal:{factory:({props:e,state:t})=>sn.bind(null,e,t),type:`function`}},containerTemplate:e=>{if(e.state.__container=e.container,!e.props.accountId&&!e.props.paymentId)throw Error(`You need to provide paymentId or accountId`);let t=Q(e);return e.event.on(q.DESTROY,()=>{window[$]?.Buttons?.instances?.forEach(e=>{e.close()});let t=e.state.__scriptId;if(t){let e=document.querySelector(`script[data-uid-auto="${t}"]`);e&&e.remove()}}),t}}),ln=X({tag:`monei-bizum`,url:R.bizumUrl,autoResize:{width:!1,height:!1},containerTemplate:e=>{if(e.frame){if(e.props.isHidden){let t=e.doc.createElement(`div`);return t.setAttribute(`id`,e.uid),t.style.display=`none`,t.appendChild(e.frame),e.placeholder&&t.appendChild(e.placeholder),t}return en(e)}},defaultProps:({event:e})=>({onBeforeClose:()=>{e.trigger(q.BEFORE_CLOSE)}})}),un=X({tag:`monei-bizum-button`,url:R.bizumButtonUrl,dimensions:{width:`100%`,height:`auto`},autoResize:{width:!1,height:!0},aliases:{style:`innerStyle`},computedProps:{__getConfig:{factory:({props:e})=>V.bind(null,e),type:`function`},__onClick:{factory:({props:e,state:t})=>{let n=document.createElement(`div`);return({amount:r,currency:i})=>{if(t.isOpen)return;let a=!0;if(e.onBeforeOpen&&(a=e.onBeforeOpen()),!a)return;t.isOpen=!0,n.parentNode||document.body.appendChild(n);let o=new ln({amount:r,currency:i,...e,onClose:()=>{t.isOpen=!1,window.onpopstate=null,document.body.style.overflow=``},isOpen:!0});return window.history.pushState(null,``,window.location.href),window.onpopstate=()=>o.updateProps({isOpen:!1}),Object.assign(document.body.style,{overflow:`hidden`}),o.render(n)}},type:`function`}},validate:F,containerTemplate:Q}),dn=X({tag:`monei-google-pay`,url:R.paymentRequestUrl,dimensions:{width:`100%`,height:`0`},autoResize:{width:!1,height:!0},aliases:{style:`innerStyle`},computedProps:{__getConfig:{factory:({props:e})=>V.bind(null,e),type:`function`}},validate:F,containerTemplate:Q}),fn=X({tag:`monei-payment-request`,url:R.paymentRequestUrl,dimensions:{width:`100%`,height:`auto`},autoResize:{width:!1,height:!0},aliases:{style:`innerStyle`},computedProps:{__getConfig:{factory:({props:e})=>V.bind(null,e),type:`function`}},validate:F,containerTemplate:Q}),pn=function(e){return e.CONFIRM=`CONFIRM`,e.FRICTIONLESS_CHALLENGE=`FRICTIONLESS_CHALLENGE`,e.BIZUM_CHALLENGE=`BIZUM_CHALLENGE`,e.CHALLENGE=`CHALLENGE`,e.COMPLETE=`COMPLETE`,e}({}),mn=function(e){return e.Visa=`visa`,e.Mastercard=`mastercard`,e.Amex=`amex`,e.Discover=`discover`,e.Diners=`diners`,e.JCB=`jcb`,e.Maestro=`maestro`,e.UnionPay=`unionpay`,e.Elo=`elo`,e.Hipercard=`hipercard`,e}({}),hn=function(e){return e.AUTH=`AUTH`,e.SALE=`SALE`,e.PAYOUT=`PAYOUT`,e.VERIF=`VERIF`,e}({}),gn=Ge,_n=Ne;e.Bizum=un,e.BizumModal=ln,e.CardBrand=mn,e.CardInput=rn,e.GooglePay=dn,e.NextActionType=pn,e.PayPal=cn,e.PaymentModal=an,e.PaymentRequest=fn,e.TransactionType=hn,e.api=gn,e.config=R,e.confirmPayment=on,e.createToken=nn,e.utils=_n});
|
|
64
64
|
//# sourceMappingURL=monei.umd.production.min.js.map
|