@zippypay/checkout 1.0.0

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.mjs ADDED
@@ -0,0 +1,951 @@
1
+ var F=["COMPLETED","EXPIRED","CANCELLED","FAILED"],te=["CREATED","AWAITING_PAYMENT"],L=class extends Error{constructor(e){let t=e.detail??e.title??"An unexpected error occurred";super(t),this.name="ZippyPayError",this.code=e.code??"unknown",this.status=e.status??500,this.detail=t,this.correlationId=e.correlationId;}};var W={production:"https://api.zippypay.io",staging:"https://staging.api.zippypay.io",development:""},ie="/api/v1";function ve(n){return n in W}function ne(n){return W[n].replace(/\/+$/,"")}function $(n){let e=n.trim().toLowerCase();if(!ve(e))throw new Error(`Zippy Pay: invalid environment "${n}". Expected one of: ${Object.keys(W).join(", ")}.`);return e}var be=/^(?=.{3,20}$)[a-z0-9]+(?:\.[a-z0-9]+)?$/;function U(n){return n.trim().toLowerCase()}function re(n){return be.test(U(n))}function oe(){return "Enter 3\u201320 lowercase letters or digits, with at most one dot (e.g. john.doe12)."}function we(n){return /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(n)}var We={USD:"en-US"};function se(n,e){let t=Number.parseFloat(n);if(Number.isNaN(t))return `${n} ${e}`;let i=We[e]??"en-US";return new Intl.NumberFormat(i,{style:"currency",currency:e,minimumFractionDigits:2,maximumFractionDigits:2}).format(t)}var ae=7;function Ee(n,e,t="success"){return n==="redirect"?t==="failure"?"You will be redirected shortly in":"You will be redirected in":e==="modal"?"This window will close automatically in":"This checkout will close automatically in"}function Pe(n){switch(n){case "success":return {kind:"success",title:"Payment complete",detail:"Your payment was successful."};case "expired":return {kind:"failure",title:"Session expired",detail:"This checkout session has expired. Please start a new checkout to try again."};case "failed":return {kind:"failure",title:"Payment failed",detail:"Your payment could not be completed. Please try again or contact the merchant."};case "cancelled":return {kind:"failure",title:"Payment cancelled",detail:"This payment was cancelled."};case "declined":return {kind:"failure",title:"Payment declined",detail:"Your payment was declined. Please try again or contact the merchant."};case "invalid-session":return {kind:"failure",title:"Session unavailable",detail:"This checkout session is no longer valid. Please ask the merchant for a new checkout link."};default:return {kind:"failure",title:"Something went wrong",detail:"Please try again or contact the merchant."}}}function pe(n){let e=Math.max(0,Math.ceil(n/1e3)),t=Math.floor(e/60),i=e%60;return `${t.toString().padStart(2,"0")}:${i.toString().padStart(2,"0")}`}function ze(n){let e=n.trim().split(/\s+/).filter(Boolean);return e.length===0?"?":e.length===1?e[0].charAt(0).toUpperCase():`${e[0].charAt(0)}${e[e.length-1].charAt(0)}`.toUpperCase()}function Ce(n){if(typeof n!="string")return n;let e=document.querySelector(n);if(!e)throw new Error(`Zippy Pay: container not found: ${n}`);return e}function ke(n){return n.replace(/\/+$/,"")}function le(n,e){let t=/^https?:\/\//i.test(n),i=typeof window<"u"?window.location.href:"https://localhost/",r=new URL(n,i);for(let[a,s]of Object.entries(e))s!=null&&s!==""&&r.searchParams.set(a,s);return t?r.toString():`${r.pathname}${r.search}${r.hash}`}var q=class{constructor(e){this.baseUrl=ke(e.baseUrl),this.sessionId=e.sessionId,this.clientToken=e.clientToken;}async getSession(){return this.request("GET",this.sessionPath())}async verifyPayer(e){return this.request("POST",`${this.sessionPath()}/payer/verify`,{paymentId:U(e)})}async attachPayer(e){return this.request("POST",`${this.sessionPath()}/payer`,{paymentId:U(e)})}async startCheckout(e){return this.request("POST",`${this.sessionPath()}/checkout/start`,{method:e})}startQrCheckout(){return this.startCheckout("QR")}startManualCheckout(){return this.startCheckout("MANUAL")}sessionPath(){return `${ie}/payment-sessions/${this.sessionId}`}headers(){return {Accept:"application/json","Content-Type":"application/json","X-Payment-Session-Token":this.clientToken}}async request(e,t,i){let r=await fetch(`${this.baseUrl}${t}`,{method:e,headers:this.headers(),body:i===void 0?void 0:JSON.stringify(i)});if(r.ok)return await r.json();throw await this.parseError(r)}async parseError(e){if((e.headers.get("content-type")??"").includes("application/problem+json")){let i=await e.json();return new L({...i,status:i.status??e.status})}return new L({status:e.status,code:"unknown",title:"Request failed",detail:e.statusText||"Request failed"})}};async function ce(n,e){try{return await n.attachPayer(e)}catch(t){if(!(t instanceof L)||t.code!=="payment-session.payer-attached")throw t;let i=await n.getSession();if(i.payer?.paymentId===U(e))return i;throw t}}var Te={primary:"#3f63f3",primaryForeground:"#ffffff",primaryGradientEnd:"#6b84ff",primaryHover:"#2f4fd1",primarySoft:"#eef2ff",background:"#ffffff",surface:"#ffffff",surfaceMuted:"#f6f8fb",text:"#0f172a",textMuted:"#64748b",border:"#e2e8f0",error:"#dc2626",success:"#059669",borderRadius:"20px",radiusButton:"24px",radiusInput:"12px",radiusCard:"20px",fontFamily:"'DM Sans', system-ui, -apple-system, sans-serif",mode:"light"},Ke={background:"#0f172a",surface:"#1e293b",text:"#f8fafc",textMuted:"#94a3b8",border:"#334155"};function Me(n){let e={...Te,...n},t=typeof window<"u"&&window.matchMedia?.("(prefers-color-scheme: dark)").matches,i=e.mode==="auto"?t?"dark":"light":e.mode??"light";return i==="dark"?{...e,...Ke,mode:i}:{...e,mode:i}}function de(n,e){let t=Me(e);n.style.setProperty("--zippy-primary",t.primary),n.style.setProperty("--zippy-primary-foreground",t.primaryForeground),n.style.setProperty("--zippy-primary-gradient-end",t.primaryGradientEnd),n.style.setProperty("--zippy-primary-hover",t.primaryHover),n.style.setProperty("--zippy-primary-soft",t.primarySoft),n.style.setProperty("--zippy-background",t.background),n.style.setProperty("--zippy-surface",t.surface),n.style.setProperty("--zippy-surface-muted",t.surfaceMuted),n.style.setProperty("--zippy-text",t.text),n.style.setProperty("--zippy-text-muted",t.textMuted),n.style.setProperty("--zippy-border",t.border),n.style.setProperty("--zippy-error",t.error),n.style.setProperty("--zippy-success",t.success),n.style.setProperty("--zippy-radius",t.borderRadius),n.style.setProperty("--zippy-radius-button",t.radiusButton),n.style.setProperty("--zippy-radius-input",t.radiusInput),n.style.setProperty("--zippy-radius-card",t.radiusCard),n.style.setProperty("--zippy-font-family",t.fontFamily);}var Xe="@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700&display=swap');",Ae=`
2
+ ${Xe}
3
+
4
+ :host {
5
+ display: block;
6
+ font-family: var(--zippy-font-family);
7
+ color: var(--zippy-text);
8
+ box-sizing: border-box;
9
+ -webkit-font-smoothing: antialiased;
10
+ }
11
+
12
+ *, *::before, *::after {
13
+ box-sizing: border-box;
14
+ }
15
+
16
+ button,
17
+ input {
18
+ font-family: inherit;
19
+ }
20
+
21
+ .zippy-root {
22
+ position: relative;
23
+ display: flex;
24
+ flex-direction: column;
25
+ background: var(--zippy-background);
26
+ border: 1px solid var(--zippy-border);
27
+ border-radius: var(--zippy-radius-card);
28
+ padding: 0;
29
+ max-width: 420px;
30
+ width: 100%;
31
+ overflow: hidden;
32
+ box-shadow:
33
+ 0 1px 2px rgba(15, 23, 42, 0.04),
34
+ 0 16px 48px -20px rgba(15, 23, 42, 0.18);
35
+ }
36
+
37
+ .zippy-root--terminal {
38
+ display: block;
39
+ padding: 32px 24px 28px;
40
+ overflow: visible;
41
+ }
42
+
43
+ .zippy-root--paying {
44
+ display: flex;
45
+ flex-direction: column;
46
+ padding: 0;
47
+ overflow: hidden;
48
+ }
49
+
50
+ .zippy-root-body {
51
+ flex: 1 1 auto;
52
+ display: flex;
53
+ flex-direction: column;
54
+ min-height: 0;
55
+ padding: 24px 24px 20px;
56
+ }
57
+
58
+ .zippy-payment-hero {
59
+ margin-bottom: 22px;
60
+ padding-bottom: 20px;
61
+ text-align: center;
62
+ border-bottom: 1px solid color-mix(in srgb, var(--zippy-border) 80%, transparent);
63
+ }
64
+
65
+ .zippy-payment-merchant {
66
+ margin: 0 0 6px;
67
+ font-size: 0.9375rem;
68
+ font-weight: 500;
69
+ color: var(--zippy-text-muted);
70
+ line-height: 1.35;
71
+ }
72
+
73
+ .zippy-payment-amount {
74
+ margin: 0;
75
+ font-size: 2rem;
76
+ font-weight: 700;
77
+ letter-spacing: -0.04em;
78
+ line-height: 1.05;
79
+ color: var(--zippy-text);
80
+ }
81
+
82
+ .zippy-payment-subtitle {
83
+ margin: 10px 0 0;
84
+ font-size: 0.875rem;
85
+ font-weight: 600;
86
+ color: var(--zippy-primary);
87
+ letter-spacing: -0.01em;
88
+ }
89
+
90
+ .zippy-choose {
91
+ margin: 0;
92
+ }
93
+
94
+ .zippy-choose-options {
95
+ display: grid;
96
+ grid-template-columns: 1fr 1fr;
97
+ gap: 10px;
98
+ }
99
+
100
+ .zippy-method-card {
101
+ display: flex;
102
+ flex-direction: column;
103
+ align-items: center;
104
+ justify-content: center;
105
+ gap: 10px;
106
+ width: 100%;
107
+ min-height: 7.5rem;
108
+ padding: 16px 10px;
109
+ border: 1px solid var(--zippy-border);
110
+ border-radius: 16px;
111
+ background: var(--zippy-surface-muted);
112
+ color: var(--zippy-text);
113
+ cursor: pointer;
114
+ text-align: center;
115
+ transition:
116
+ border-color 160ms ease,
117
+ box-shadow 160ms ease,
118
+ transform 160ms ease,
119
+ background 160ms ease;
120
+ }
121
+
122
+ .zippy-method-card:hover {
123
+ border-color: color-mix(in srgb, var(--zippy-primary) 40%, var(--zippy-border));
124
+ background: color-mix(in srgb, var(--zippy-primary-soft) 55%, white);
125
+ box-shadow: 0 10px 28px -16px rgba(63, 99, 243, 0.45);
126
+ transform: translateY(-1px);
127
+ }
128
+
129
+ .zippy-method-card:active {
130
+ transform: translateY(0) scale(0.985);
131
+ }
132
+
133
+ .zippy-method-card:focus-visible {
134
+ outline: 2px solid var(--zippy-primary);
135
+ outline-offset: 2px;
136
+ }
137
+
138
+ .zippy-method-icon {
139
+ display: flex;
140
+ align-items: center;
141
+ justify-content: center;
142
+ width: 44px;
143
+ height: 44px;
144
+ border-radius: 50%;
145
+ color: var(--zippy-primary);
146
+ background: #ffffff;
147
+ box-shadow: 0 0 0 1px color-mix(in srgb, var(--zippy-primary) 12%, var(--zippy-border));
148
+ }
149
+
150
+ .zippy-method-copy {
151
+ display: flex;
152
+ flex-direction: column;
153
+ gap: 2px;
154
+ min-width: 0;
155
+ }
156
+
157
+ .zippy-method-title {
158
+ font-size: 0.875rem;
159
+ font-weight: 700;
160
+ letter-spacing: -0.01em;
161
+ }
162
+
163
+ .zippy-method-hint {
164
+ font-size: 0.75rem;
165
+ font-weight: 500;
166
+ color: var(--zippy-text-muted);
167
+ line-height: 1.35;
168
+ }
169
+
170
+ .zippy-flow {
171
+ display: flex;
172
+ flex-direction: column;
173
+ gap: 18px;
174
+ }
175
+
176
+ .zippy-flow-awaiting {
177
+ align-items: center;
178
+ text-align: center;
179
+ padding: 8px 0 4px;
180
+ }
181
+
182
+ .zippy-flow-awaiting .zippy-identity-card {
183
+ width: 100%;
184
+ text-align: left;
185
+ }
186
+
187
+ .zippy-pay-progress {
188
+ flex-shrink: 0;
189
+ width: 100%;
190
+ height: 2px;
191
+ margin: 0;
192
+ border-radius: 0;
193
+ background: color-mix(in srgb, var(--zippy-border) 55%, transparent);
194
+ overflow: hidden;
195
+ }
196
+
197
+ .zippy-root--qr .zippy-pay-progress {
198
+ height: 4px;
199
+ }
200
+
201
+ .zippy-pay-progress-fill {
202
+ display: block;
203
+ width: 100%;
204
+ height: 100%;
205
+ transform: scaleX(1);
206
+ transform-origin: left center;
207
+ background: var(--zippy-primary);
208
+ transition: transform 1s linear;
209
+ will-change: transform;
210
+ }
211
+
212
+ .zippy-step-guide {
213
+ display: flex;
214
+ flex-direction: column;
215
+ gap: 8px;
216
+ }
217
+
218
+ .zippy-step-guide-item {
219
+ display: flex;
220
+ align-items: flex-start;
221
+ gap: 12px;
222
+ }
223
+
224
+ .zippy-step-guide-num {
225
+ flex-shrink: 0;
226
+ width: 22px;
227
+ height: 22px;
228
+ border-radius: 50%;
229
+ display: flex;
230
+ align-items: center;
231
+ justify-content: center;
232
+ font-size: 0.6875rem;
233
+ font-weight: 700;
234
+ color: var(--zippy-primary);
235
+ background: var(--zippy-primary-soft);
236
+ }
237
+
238
+ .zippy-step-guide-text {
239
+ font-size: 0.8125rem;
240
+ line-height: 1.45;
241
+ color: var(--zippy-text-muted);
242
+ padding-top: 2px;
243
+ }
244
+
245
+ .zippy-qr-section {
246
+ display: flex;
247
+ flex-direction: column;
248
+ align-items: center;
249
+ gap: 12px;
250
+ padding: 2px 0 4px;
251
+ }
252
+
253
+ .zippy-pay-timer-slot {
254
+ display: flex;
255
+ justify-content: center;
256
+ width: 100%;
257
+ min-height: 3.5rem;
258
+ margin: -6px 0 10px;
259
+ }
260
+
261
+ .zippy-qr-section .zippy-pay-timer-slot {
262
+ margin: 0;
263
+ }
264
+
265
+ .zippy-pay-timer {
266
+ display: inline-flex;
267
+ flex-direction: column;
268
+ align-items: center;
269
+ justify-content: center;
270
+ gap: 0.125rem;
271
+ min-width: 5.5rem;
272
+ padding: 0.5rem 1.125rem 0.4375rem;
273
+ border-radius: 16px;
274
+ background: var(--zippy-primary-soft);
275
+ color: var(--zippy-primary);
276
+ }
277
+
278
+ .zippy-pay-timer-value {
279
+ width: 5ch;
280
+ font-size: 1.125rem;
281
+ font-weight: 700;
282
+ font-variant-numeric: tabular-nums;
283
+ letter-spacing: 0;
284
+ text-align: center;
285
+ line-height: 1;
286
+ }
287
+
288
+ .zippy-pay-timer-label {
289
+ font-size: 0.6875rem;
290
+ font-weight: 600;
291
+ line-height: 1;
292
+ letter-spacing: 0.02em;
293
+ text-transform: uppercase;
294
+ white-space: nowrap;
295
+ color: color-mix(in srgb, var(--zippy-primary) 72%, var(--zippy-text-muted));
296
+ }
297
+
298
+ .zippy-qr-frame {
299
+ display: inline-block;
300
+ padding: 16px;
301
+ background: #ffffff;
302
+ border: 1px solid var(--zippy-border);
303
+ border-radius: 20px;
304
+ line-height: 0;
305
+ box-shadow:
306
+ 0 1px 2px rgba(15, 23, 42, 0.04),
307
+ 0 12px 32px -14px rgba(63, 99, 243, 0.22);
308
+ }
309
+
310
+ .zippy-qr-stack {
311
+ position: relative;
312
+ display: inline-block;
313
+ line-height: 0;
314
+ }
315
+
316
+ .zippy-qr-stack > svg {
317
+ display: block;
318
+ width: 196px;
319
+ height: 196px;
320
+ }
321
+
322
+ .zippy-qr-awaiting {
323
+ display: flex;
324
+ align-items: center;
325
+ justify-content: center;
326
+ padding-top: 4px;
327
+ }
328
+
329
+ .zippy-qr-awaiting-spinner {
330
+ display: block;
331
+ width: 1.25rem;
332
+ height: 1.25rem;
333
+ border: 2px solid var(--zippy-border);
334
+ border-top-color: var(--zippy-primary);
335
+ border-radius: 50%;
336
+ animation: zippy-spin 0.8s linear infinite;
337
+ }
338
+
339
+ .zippy-id-form {
340
+ display: flex;
341
+ flex-direction: column;
342
+ gap: 12px;
343
+ margin: 0;
344
+ }
345
+
346
+ .zippy-input-combo {
347
+ display: flex;
348
+ align-items: stretch;
349
+ width: 100%;
350
+ min-height: 3rem;
351
+ border: 1px solid var(--zippy-border);
352
+ border-radius: var(--zippy-radius-button);
353
+ background: var(--zippy-surface-muted);
354
+ overflow: hidden;
355
+ transition:
356
+ border-color 150ms ease,
357
+ box-shadow 150ms ease,
358
+ background 150ms ease;
359
+ }
360
+
361
+ .zippy-input-combo:focus-within {
362
+ border-color: var(--zippy-primary);
363
+ background: var(--zippy-background);
364
+ box-shadow: 0 0 0 3px color-mix(in srgb, var(--zippy-primary) 14%, transparent);
365
+ }
366
+
367
+ .zippy-input-combo--verified {
368
+ border-color: color-mix(in srgb, var(--zippy-success) 35%, var(--zippy-border));
369
+ background: color-mix(in srgb, var(--zippy-success) 6%, var(--zippy-background));
370
+ }
371
+
372
+ .zippy-input-combo--verified:focus-within {
373
+ border-color: color-mix(in srgb, var(--zippy-success) 45%, var(--zippy-primary));
374
+ box-shadow: 0 0 0 3px color-mix(in srgb, var(--zippy-success) 12%, transparent);
375
+ }
376
+
377
+ .zippy-input-combo-field {
378
+ flex: 1;
379
+ min-width: 0;
380
+ width: 100%;
381
+ padding: 0.75rem 0.875rem;
382
+ font-family: inherit;
383
+ font-size: 1rem;
384
+ line-height: 1.25;
385
+ color: var(--zippy-text);
386
+ border: none;
387
+ background: transparent;
388
+ outline: none;
389
+ }
390
+
391
+ .zippy-input-combo-field::placeholder {
392
+ color: var(--zippy-text-muted);
393
+ }
394
+
395
+ .zippy-input-combo-field:focus,
396
+ .zippy-input-combo-field:focus-visible {
397
+ outline: none;
398
+ }
399
+
400
+ .zippy-input-combo-field:disabled {
401
+ opacity: 0.6;
402
+ cursor: not-allowed;
403
+ }
404
+
405
+ .zippy-input-combo-divider {
406
+ flex-shrink: 0;
407
+ align-self: center;
408
+ width: 1px;
409
+ height: 1.375rem;
410
+ background: var(--zippy-border);
411
+ }
412
+
413
+ .zippy-input-combo--verified .zippy-input-combo-divider {
414
+ background: color-mix(in srgb, var(--zippy-success) 25%, var(--zippy-border));
415
+ }
416
+
417
+ .zippy-input-combo-action {
418
+ flex-shrink: 0;
419
+ min-width: 5.25rem;
420
+ padding: 0 1rem;
421
+ font-family: inherit;
422
+ font-size: 0.875rem;
423
+ font-weight: 600;
424
+ letter-spacing: -0.01em;
425
+ color: var(--zippy-primary);
426
+ background: transparent;
427
+ border: none;
428
+ cursor: pointer;
429
+ transition:
430
+ background 150ms ease,
431
+ color 150ms ease,
432
+ opacity 150ms ease;
433
+ }
434
+
435
+ .zippy-input-combo-action:hover:not(:disabled) {
436
+ background: color-mix(in srgb, var(--zippy-primary) 8%, transparent);
437
+ }
438
+
439
+ .zippy-input-combo-action:disabled {
440
+ color: var(--zippy-text-muted);
441
+ cursor: default;
442
+ }
443
+
444
+ .zippy-input-combo--verified .zippy-input-combo-action:disabled {
445
+ color: var(--zippy-success);
446
+ }
447
+
448
+ .zippy-input-combo-action--verified {
449
+ display: inline-flex;
450
+ align-items: center;
451
+ justify-content: center;
452
+ min-width: 3rem;
453
+ padding: 0 0.875rem;
454
+ color: var(--zippy-success);
455
+ }
456
+
457
+ .zippy-input-combo-action--verified:disabled {
458
+ opacity: 1;
459
+ }
460
+
461
+ .zippy-input-combo-check {
462
+ display: block;
463
+ width: 1.125rem;
464
+ height: 1.125rem;
465
+ }
466
+
467
+ .zippy-input-combo-action--loading {
468
+ display: inline-flex;
469
+ align-items: center;
470
+ justify-content: center;
471
+ }
472
+
473
+ .zippy-input-combo-action--loading:disabled {
474
+ opacity: 1;
475
+ color: var(--zippy-primary);
476
+ }
477
+
478
+ .zippy-spinner-inline {
479
+ width: 1rem;
480
+ height: 1rem;
481
+ border: 2px solid color-mix(in srgb, var(--zippy-primary) 18%, transparent);
482
+ border-top-color: var(--zippy-primary);
483
+ border-radius: 50%;
484
+ animation: zippy-spin 0.7s linear infinite;
485
+ }
486
+
487
+ .zippy-input-combo--error {
488
+ border-color: color-mix(in srgb, var(--zippy-error) 55%, var(--zippy-border));
489
+ background: color-mix(in srgb, var(--zippy-error) 5%, var(--zippy-background));
490
+ }
491
+
492
+ .zippy-input-combo--error:focus-within {
493
+ border-color: var(--zippy-error);
494
+ box-shadow: 0 0 0 3px color-mix(in srgb, var(--zippy-error) 14%, transparent);
495
+ }
496
+
497
+ .zippy-input-combo--error .zippy-input-combo-divider {
498
+ background: color-mix(in srgb, var(--zippy-error) 25%, var(--zippy-border));
499
+ }
500
+
501
+ .zippy-field-error {
502
+ display: flex;
503
+ align-items: center;
504
+ gap: 0.5rem;
505
+ margin: -4px 0 0;
506
+ padding: 0.5rem 0.875rem;
507
+ font-size: 0.8125rem;
508
+ line-height: 1.45;
509
+ color: var(--zippy-error);
510
+ background: color-mix(in srgb, var(--zippy-error) 8%, var(--zippy-background));
511
+ border: 1px solid color-mix(in srgb, var(--zippy-error) 18%, var(--zippy-border));
512
+ border-radius: 999px;
513
+ }
514
+
515
+ .zippy-field-error-icon {
516
+ flex-shrink: 0;
517
+ display: inline-flex;
518
+ align-items: center;
519
+ justify-content: center;
520
+ width: 1rem;
521
+ height: 1rem;
522
+ border-radius: 50%;
523
+ font-size: 0.6875rem;
524
+ font-weight: 700;
525
+ line-height: 1;
526
+ color: #fff;
527
+ background: var(--zippy-error);
528
+ }
529
+
530
+ .zippy-idle-hint {
531
+ margin: -6px 0 0;
532
+ font-size: 0.8125rem;
533
+ color: var(--zippy-text-muted);
534
+ text-align: center;
535
+ line-height: 1.45;
536
+ }
537
+
538
+ .zippy-identity-card {
539
+ display: flex;
540
+ align-items: center;
541
+ gap: 14px;
542
+ padding: 16px;
543
+ border-radius: 16px;
544
+ background: var(--zippy-surface-muted);
545
+ border: 1px solid var(--zippy-border);
546
+ }
547
+
548
+ .zippy-identity-avatar {
549
+ flex-shrink: 0;
550
+ width: 48px;
551
+ height: 48px;
552
+ border-radius: 50%;
553
+ display: flex;
554
+ align-items: center;
555
+ justify-content: center;
556
+ font-size: 1.0625rem;
557
+ font-weight: 700;
558
+ color: var(--zippy-primary);
559
+ background: #fff;
560
+ box-shadow: 0 0 0 1px color-mix(in srgb, var(--zippy-primary) 14%, var(--zippy-border));
561
+ }
562
+
563
+ .zippy-identity-avatar--photo {
564
+ padding: 0;
565
+ overflow: hidden;
566
+ color: transparent;
567
+ background: var(--zippy-surface-muted);
568
+ }
569
+
570
+ .zippy-identity-avatar-image {
571
+ display: block;
572
+ width: 100%;
573
+ height: 100%;
574
+ object-fit: cover;
575
+ }
576
+
577
+ .zippy-identity-label {
578
+ margin: 0 0 2px;
579
+ font-size: 0.6875rem;
580
+ font-weight: 600;
581
+ letter-spacing: 0.04em;
582
+ text-transform: uppercase;
583
+ color: var(--zippy-text-muted);
584
+ }
585
+
586
+ .zippy-identity-name {
587
+ margin: 0 0 2px;
588
+ font-size: 1rem;
589
+ font-weight: 700;
590
+ color: var(--zippy-text);
591
+ letter-spacing: -0.01em;
592
+ }
593
+
594
+ .zippy-identity-handle {
595
+ margin: 0;
596
+ font-size: 0.8125rem;
597
+ color: var(--zippy-text-muted);
598
+ }
599
+
600
+ .zippy-identity-chip {
601
+ padding: 0.45rem 0.875rem;
602
+ border-radius: 999px;
603
+ font-size: 0.8125rem;
604
+ font-weight: 600;
605
+ color: var(--zippy-primary);
606
+ background: var(--zippy-primary-soft);
607
+ }
608
+
609
+ .zippy-awaiting-status {
610
+ padding: 4px 0 8px;
611
+ }
612
+
613
+ .zippy-awaiting-ring {
614
+ position: relative;
615
+ width: 56px;
616
+ height: 56px;
617
+ margin: 0 auto;
618
+ }
619
+
620
+ .zippy-awaiting-ring::before,
621
+ .zippy-awaiting-ring span {
622
+ content: '';
623
+ position: absolute;
624
+ inset: 0;
625
+ border-radius: 50%;
626
+ }
627
+
628
+ .zippy-awaiting-ring::before {
629
+ border: 2px solid var(--zippy-primary-soft);
630
+ }
631
+
632
+ .zippy-awaiting-ring span {
633
+ border: 2px solid transparent;
634
+ border-top-color: var(--zippy-primary);
635
+ animation: zippy-spin 0.9s linear infinite;
636
+ }
637
+
638
+ .zippy-awaiting-message {
639
+ margin: 0;
640
+ max-width: 18rem;
641
+ font-size: 0.875rem;
642
+ line-height: 1.5;
643
+ color: var(--zippy-text-muted);
644
+ }
645
+
646
+ .zippy-footnote {
647
+ margin: 0;
648
+ font-size: 0.75rem;
649
+ line-height: 1.5;
650
+ color: var(--zippy-text-muted);
651
+ text-align: center;
652
+ }
653
+
654
+ .zippy-flow .zippy-footnote {
655
+ text-align: left;
656
+ }
657
+
658
+ .zippy-flow-awaiting .zippy-footnote {
659
+ text-align: center;
660
+ }
661
+
662
+ .zippy-brand-footer {
663
+ display: flex;
664
+ align-items: center;
665
+ justify-content: center;
666
+ margin-top: auto;
667
+ padding-top: 12px;
668
+ }
669
+
670
+ .zippy-root--terminal .zippy-brand-footer {
671
+ margin-top: 20px;
672
+ padding-top: 18px;
673
+ border-top: 1px solid color-mix(in srgb, var(--zippy-border) 80%, transparent);
674
+ }
675
+
676
+ .zippy-brand-footer-inner {
677
+ display: inline-flex;
678
+ align-items: center;
679
+ gap: 6px;
680
+ min-height: 1.375rem;
681
+ padding: 0.1875rem 0.5rem;
682
+ border-radius: 999px;
683
+ color: var(--zippy-text-muted);
684
+ background: color-mix(in srgb, var(--zippy-text-muted) 6%, transparent);
685
+ opacity: 0.72;
686
+ }
687
+
688
+ .zippy-brand-secure {
689
+ display: inline-flex;
690
+ align-items: center;
691
+ gap: 4px;
692
+ }
693
+
694
+ .zippy-brand-divider {
695
+ flex-shrink: 0;
696
+ align-self: center;
697
+ width: 1px;
698
+ height: 0.625rem;
699
+ background: color-mix(in srgb, var(--zippy-text-muted) 24%, transparent);
700
+ }
701
+
702
+ .zippy-brand-lock {
703
+ flex-shrink: 0;
704
+ display: block;
705
+ width: 0.625rem;
706
+ height: 0.625rem;
707
+ }
708
+
709
+ .zippy-brand-copy,
710
+ .zippy-brand-name {
711
+ font-size: 0.625rem;
712
+ font-weight: 500;
713
+ letter-spacing: 0.01em;
714
+ line-height: 1;
715
+ white-space: nowrap;
716
+ }
717
+
718
+ .zippy-brand-name {
719
+ font-weight: 600;
720
+ }
721
+
722
+ .zippy-label {
723
+ display: block;
724
+ font-size: 0.8125rem;
725
+ font-weight: 600;
726
+ margin: 0;
727
+ color: var(--zippy-text);
728
+ }
729
+
730
+ .zippy-input {
731
+ width: 100%;
732
+ min-height: 2.875rem;
733
+ padding: 0.6875rem 0.875rem;
734
+ font-size: 1rem;
735
+ border: 1px solid var(--zippy-border);
736
+ border-radius: var(--zippy-radius-input);
737
+ background: var(--zippy-background);
738
+ color: var(--zippy-text);
739
+ outline: none;
740
+ transition: border-color 150ms ease, box-shadow 150ms ease;
741
+ }
742
+
743
+ .zippy-input:focus {
744
+ border-color: var(--zippy-primary);
745
+ box-shadow: 0 0 0 3px color-mix(in srgb, var(--zippy-primary) 16%, transparent);
746
+ }
747
+
748
+ .zippy-input:focus-visible {
749
+ outline: 2px solid var(--zippy-primary);
750
+ outline-offset: 2px;
751
+ }
752
+
753
+ .zippy-input:disabled {
754
+ opacity: 0.55;
755
+ cursor: not-allowed;
756
+ }
757
+
758
+ .zippy-error-text {
759
+ font-size: 0.8125rem;
760
+ color: var(--zippy-error);
761
+ margin: 0;
762
+ }
763
+
764
+ .zippy-btn {
765
+ display: inline-flex;
766
+ align-items: center;
767
+ justify-content: center;
768
+ min-height: 2.875rem;
769
+ padding: 0.6875rem 1.25rem;
770
+ font-size: 0.9375rem;
771
+ font-weight: 600;
772
+ border-radius: var(--zippy-radius-button);
773
+ border: none;
774
+ cursor: pointer;
775
+ transition:
776
+ background 150ms ease,
777
+ transform 150ms ease,
778
+ box-shadow 150ms ease;
779
+ }
780
+
781
+ .zippy-btn:disabled {
782
+ opacity: 0.55;
783
+ cursor: not-allowed;
784
+ }
785
+
786
+ .zippy-btn:not(:disabled):active {
787
+ transform: scale(0.985);
788
+ }
789
+
790
+ .zippy-btn-block {
791
+ width: 100%;
792
+ }
793
+
794
+ .zippy-btn-primary {
795
+ background: linear-gradient(
796
+ 135deg,
797
+ var(--zippy-primary) 0%,
798
+ var(--zippy-primary-gradient-end) 100%
799
+ );
800
+ color: var(--zippy-primary-foreground);
801
+ box-shadow: 0 4px 14px -4px color-mix(in srgb, var(--zippy-primary) 45%, transparent);
802
+ }
803
+
804
+ .zippy-btn-primary:hover:not(:disabled) {
805
+ background: linear-gradient(
806
+ 135deg,
807
+ var(--zippy-primary-hover) 0%,
808
+ var(--zippy-primary) 100%
809
+ );
810
+ }
811
+
812
+ .zippy-status {
813
+ text-align: center;
814
+ padding: 16px 0 8px;
815
+ }
816
+
817
+ .zippy-status-icon {
818
+ width: 56px;
819
+ height: 56px;
820
+ margin: 0 auto 18px;
821
+ border-radius: 50%;
822
+ display: flex;
823
+ align-items: center;
824
+ justify-content: center;
825
+ }
826
+
827
+ .zippy-status-icon.loading {
828
+ background: var(--zippy-surface-muted);
829
+ }
830
+
831
+ .zippy-status-icon.success {
832
+ background: color-mix(in srgb, var(--zippy-success) 14%, transparent);
833
+ color: var(--zippy-success);
834
+ }
835
+
836
+ .zippy-status-icon.failure,
837
+ .zippy-status-icon.error {
838
+ background: color-mix(in srgb, var(--zippy-error) 12%, transparent);
839
+ color: var(--zippy-error);
840
+ }
841
+
842
+ .zippy-status-title {
843
+ font-size: 1.125rem;
844
+ font-weight: 700;
845
+ margin: 0 0 8px;
846
+ letter-spacing: -0.02em;
847
+ }
848
+
849
+ .zippy-status-detail {
850
+ font-size: 0.875rem;
851
+ color: var(--zippy-text-muted);
852
+ margin: 0;
853
+ line-height: 1.5;
854
+ }
855
+
856
+ .zippy-transaction-ref {
857
+ margin: 18px auto 0;
858
+ max-width: 100%;
859
+ padding: 12px 14px;
860
+ border-radius: calc(var(--zippy-radius) * 0.75);
861
+ background: var(--zippy-surface-muted);
862
+ text-align: center;
863
+ }
864
+
865
+ .zippy-transaction-ref-label {
866
+ margin: 0 0 4px;
867
+ font-size: 0.75rem;
868
+ font-weight: 500;
869
+ color: var(--zippy-text-muted);
870
+ letter-spacing: 0.04em;
871
+ text-transform: uppercase;
872
+ }
873
+
874
+ .zippy-transaction-ref-value {
875
+ margin: 0;
876
+ font-size: 0.875rem;
877
+ font-weight: 600;
878
+ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
879
+ color: var(--zippy-text);
880
+ word-break: break-all;
881
+ }
882
+
883
+ .zippy-status-exit {
884
+ margin: 20px 0 0;
885
+ font-size: 0.875rem;
886
+ color: var(--zippy-text-muted);
887
+ line-height: 1.5;
888
+ }
889
+
890
+ .zippy-status-exit-countdown {
891
+ font-weight: 700;
892
+ font-variant-numeric: tabular-nums;
893
+ color: var(--zippy-text);
894
+ }
895
+
896
+ .zippy-spinner {
897
+ width: 24px;
898
+ height: 24px;
899
+ border: 3px solid var(--zippy-border);
900
+ border-top-color: var(--zippy-primary);
901
+ border-radius: 50%;
902
+ animation: zippy-spin 0.8s linear infinite;
903
+ }
904
+
905
+ @keyframes zippy-spin {
906
+ to { transform: rotate(360deg); }
907
+ }
908
+ `,Se=`
909
+ .zippy-overlay {
910
+ position: fixed;
911
+ inset: 0;
912
+ background: rgba(15, 23, 42, 0.55);
913
+ display: flex;
914
+ align-items: center;
915
+ justify-content: center;
916
+ padding: 16px;
917
+ z-index: 2147483000;
918
+ }
919
+
920
+ .zippy-modal-panel {
921
+ max-width: 460px;
922
+ width: 100%;
923
+ animation: zippy-modal-in 0.2s ease-out;
924
+ }
925
+
926
+ @keyframes zippy-modal-in {
927
+ from {
928
+ opacity: 0;
929
+ transform: translateY(8px) scale(0.98);
930
+ }
931
+ to {
932
+ opacity: 1;
933
+ transform: translateY(0) scale(1);
934
+ }
935
+ }
936
+ `;function Ie(n){if((n.mode??"inline")==="modal")return Je(n);if(!n.container)throw new Error('Zippy Pay: `container` is required when mode is "inline".');let t=Ce(n.container);t.innerHTML="";let i=document.createElement("div");return i.className="zippy-inline-host",t.appendChild(i),{host:i,overlay:null,escapeHandler:null,destroy:()=>{i.remove();}}}function Je(n){let e=document.createElement("div");e.className="zippy-overlay",e.setAttribute("role","dialog"),e.setAttribute("aria-modal","true"),e.setAttribute("aria-label","Zippy Pay checkout"),e.style.display="none";let t=document.createElement("style");t.textContent=Se,e.appendChild(t);let i=document.createElement("div");i.className="zippy-modal-panel";let r=document.createElement("div");r.className="zippy-modal-host",i.appendChild(r),e.appendChild(i),document.body.appendChild(e),(n.closeOnBackdropClick??false)&&e.addEventListener("click",o=>{o.target===e&&n.onClose?.();});let s={host:r,overlay:e,escapeHandler:null,destroy:()=>{s.escapeHandler&&document.removeEventListener("keydown",s.escapeHandler),e.remove(),document.body.style.overflow="";}};return s}function Le(n,e,t){if(!n.overlay)return;n.overlay.style.display="flex",document.body.style.overflow="hidden",(e.closeOnEscape??false)&&!n.escapeHandler&&(n.escapeHandler=a=>{a.key==="Escape"&&t();},document.addEventListener("keydown",n.escapeHandler)),n.host.querySelector("input, button")?.focus();}function Ne(n){n.overlay&&(n.overlay.style.display="none",document.body.style.overflow="",n.escapeHandler&&(document.removeEventListener("keydown",n.escapeHandler),n.escapeHandler=null));}var Y=class{constructor(e,t){this.fetchSession=e;this.options=t;this.timer=null;this.running=false;this.stopped=false;}start(e){if(!this.running){if(this.running=true,this.stopped=false,e&&(this.options.onUpdate(e),!this.shouldContinue(e))){this.stop();return}this.tick();}}stop(){this.stopped=true,this.running=false,this.timer!==null&&(clearTimeout(this.timer),this.timer=null);}shouldContinue(e){return this.options.shouldPoll?this.options.shouldPoll(e):te.includes(e.status)}intervalMs(){let e=this.options.intervalMs??3e3,t=this.options.hiddenIntervalMs??1e4;return typeof document<"u"&&document.hidden?t:e}scheduleNext(){this.stopped||(this.timer=setTimeout(()=>{this.tick();},this.intervalMs()));}async tick(){if(!this.stopped){try{let e=await this.fetchSession();if(this.options.onUpdate(e),!this.shouldContinue(e)){this.stop();return}}catch(e){this.options.onError?.(e),this.stop();return}this.scheduleNext();}}};function ue(n){return F.includes(n)}function et(n){switch(n){case "CREATED":return "choose-method";case "AWAITING_PAYMENT":return "awaiting";case "COMPLETED":return "success";case "EXPIRED":return "expired";case "CANCELLED":return "cancelled";case "FAILED":return "failed";default:return "error"}}var O=function(n,e){let r=n,a=Q[e],s=null,o=0,l=null,g=[],y={},f=function(c,m){o=r*4+17,s=(function(p){let u=new Array(p);for(let d=0;d<p;d+=1){u[d]=new Array(p);for(let x=0;x<p;x+=1)u[d][x]=null;}return u})(o),h(0,0),h(o-7,0),h(0,o-7),E(),T(),A(c,m),r>=7&&M(c),l==null&&(l=Ve(r,a,g)),I(l,m);},h=function(c,m){for(let p=-1;p<=7;p+=1)if(!(c+p<=-1||o<=c+p))for(let u=-1;u<=7;u+=1)m+u<=-1||o<=m+u||(0<=p&&p<=6&&(u==0||u==6)||0<=u&&u<=6&&(p==0||p==6)||2<=p&&p<=4&&2<=u&&u<=4?s[c+p][m+u]=true:s[c+p][m+u]=false);},w=function(){let c=0,m=0;for(let p=0;p<8;p+=1){f(true,p);let u=D.getLostPoint(y);(p==0||c>u)&&(c=u,m=p);}return m},T=function(){for(let c=8;c<o-8;c+=1)s[c][6]==null&&(s[c][6]=c%2==0);for(let c=8;c<o-8;c+=1)s[6][c]==null&&(s[6][c]=c%2==0);},E=function(){let c=D.getPatternPosition(r);for(let m=0;m<c.length;m+=1)for(let p=0;p<c.length;p+=1){let u=c[m],d=c[p];if(s[u][d]==null)for(let x=-2;x<=2;x+=1)for(let v=-2;v<=2;v+=1)x==-2||x==2||v==-2||v==2||x==0&&v==0?s[u+x][d+v]=true:s[u+x][d+v]=false;}},M=function(c){let m=D.getBCHTypeNumber(r);for(let p=0;p<18;p+=1){let u=!c&&(m>>p&1)==1;s[Math.floor(p/3)][p%3+o-8-3]=u;}for(let p=0;p<18;p+=1){let u=!c&&(m>>p&1)==1;s[p%3+o-8-3][Math.floor(p/3)]=u;}},A=function(c,m){let p=a<<3|m,u=D.getBCHTypeInfo(p);for(let d=0;d<15;d+=1){let x=!c&&(u>>d&1)==1;d<6?s[d][8]=x:d<8?s[d+1][8]=x:s[o-15+d][8]=x;}for(let d=0;d<15;d+=1){let x=!c&&(u>>d&1)==1;d<8?s[8][o-d-1]=x:d<9?s[8][15-d-1+1]=x:s[8][15-d-1]=x;}s[o-8][8]=!c;},I=function(c,m){let p=-1,u=o-1,d=7,x=0,v=D.getMaskFunction(m);for(let P=o-1;P>0;P-=2)for(P==6&&(P-=1);;){for(let z=0;z<2;z+=1)if(s[u][P-z]==null){let k=false;x<c.length&&(k=(c[x]>>>d&1)==1),v(u,P-z)&&(k=!k),s[u][P-z]=k,d-=1,d==-1&&(x+=1,d=7);}if(u+=p,u<0||o<=u){u-=p,p=-p;break}}},je=function(c,m){let p=0,u=0,d=0,x=new Array(m.length),v=new Array(m.length);for(let b=0;b<m.length;b+=1){let C=m[b].dataCount,N=m[b].totalCount-C;u=Math.max(u,C),d=Math.max(d,N),x[b]=new Array(C);for(let _=0;_<x[b].length;_+=1)x[b][_]=255&c.getBuffer()[_+p];p+=C;let ee=D.getErrorCorrectPolynomial(N),ge=j(x[b],ee.getLength()-1).mod(ee);v[b]=new Array(ee.getLength()-1);for(let _=0;_<v[b].length;_+=1){let xe=_+ge.getLength()-v[b].length;v[b][_]=xe>=0?ge.getAt(xe):0;}}let P=0;for(let b=0;b<m.length;b+=1)P+=m[b].totalCount;let z=new Array(P),k=0;for(let b=0;b<u;b+=1)for(let C=0;C<m.length;C+=1)b<x[C].length&&(z[k]=x[C][b],k+=1);for(let b=0;b<d;b+=1)for(let C=0;C<m.length;C+=1)b<v[C].length&&(z[k]=v[C][b],k+=1);return z},Ve=function(c,m,p){let u=_e.getRSBlocks(c,m),d=Re();for(let v=0;v<p.length;v+=1){let P=p[v];d.put(P.getMode(),4),d.put(P.getLength(),D.getLengthInBits(P.getMode(),c)),P.write(d);}let x=0;for(let v=0;v<u.length;v+=1)x+=u[v].dataCount;if(d.getLengthInBits()>x*8)throw "code length overflow. ("+d.getLengthInBits()+">"+x*8+")";for(d.getLengthInBits()+4<=x*8&&d.put(0,4);d.getLengthInBits()%8!=0;)d.putBit(false);for(;!(d.getLengthInBits()>=x*8||(d.put(236,8),d.getLengthInBits()>=x*8));)d.put(17,8);return je(d,u)};y.addData=function(c,m){m=m||"Byte";let p=null;switch(m){case "Numeric":p=tt(c);break;case "Alphanumeric":p=it(c);break;case "Byte":p=nt(c);break;case "Kanji":p=rt(c);break;default:throw "mode:"+m}g.push(p),l=null;},y.isDark=function(c,m){if(c<0||o<=c||m<0||o<=m)throw c+","+m;return s[c][m]},y.getModuleCount=function(){return o},y.make=function(){if(r<1){let c=1;for(;c<40;c++){let m=_e.getRSBlocks(c,a),p=Re();for(let d=0;d<g.length;d++){let x=g[d];p.put(x.getMode(),4),p.put(x.getLength(),D.getLengthInBits(x.getMode(),c)),x.write(p);}let u=0;for(let d=0;d<m.length;d++)u+=m[d].dataCount;if(p.getLengthInBits()<=u*8)break}r=c;}f(false,w());},y.createTableTag=function(c,m){c=c||2,m=typeof m>"u"?c*4:m;let p="";p+='<table style="',p+=" border-width: 0px; border-style: none;",p+=" border-collapse: collapse;",p+=" padding: 0px; margin: "+m+"px;",p+='">',p+="<tbody>";for(let u=0;u<y.getModuleCount();u+=1){p+="<tr>";for(let d=0;d<y.getModuleCount();d+=1)p+='<td style="',p+=" border-width: 0px; border-style: none;",p+=" border-collapse: collapse;",p+=" padding: 0px; margin: 0px;",p+=" width: "+c+"px;",p+=" height: "+c+"px;",p+=" background-color: ",p+=y.isDark(u,d)?"#000000":"#ffffff",p+=";",p+='"/>';p+="</tr>";}return p+="</tbody>",p+="</table>",p},y.createSvgTag=function(c,m,p,u){let d={};typeof arguments[0]=="object"&&(d=arguments[0],c=d.cellSize,m=d.margin,p=d.alt,u=d.title),c=c||2,m=typeof m>"u"?c*4:m,p=typeof p=="string"?{text:p}:p||{},p.text=p.text||null,p.id=p.text?p.id||"qrcode-description":null,u=typeof u=="string"?{text:u}:u||{},u.text=u.text||null,u.id=u.text?u.id||"qrcode-title":null;let x=y.getModuleCount()*c+m*2,v,P,z,k,b="",C;for(C="l"+c+",0 0,"+c+" -"+c+",0 0,-"+c+"z ",b+='<svg version="1.1" xmlns="http://www.w3.org/2000/svg"',b+=d.scalable?"":' width="'+x+'px" height="'+x+'px"',b+=' viewBox="0 0 '+x+" "+x+'" ',b+=' preserveAspectRatio="xMinYMin meet"',b+=u.text||p.text?' role="img" aria-labelledby="'+Z([u.id,p.id].join(" ").trim())+'"':"",b+=">",b+=u.text?'<title id="'+Z(u.id)+'">'+Z(u.text)+"</title>":"",b+=p.text?'<description id="'+Z(p.id)+'">'+Z(p.text)+"</description>":"",b+='<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>',b+='<path d="',z=0;z<y.getModuleCount();z+=1)for(k=z*c+m,v=0;v<y.getModuleCount();v+=1)y.isDark(z,v)&&(P=v*c+m,b+="M"+P+","+k+C);return b+='" stroke="transparent" fill="black"/>',b+="</svg>",b},y.createDataURL=function(c,m){c=c||2,m=typeof m>"u"?c*4:m;let p=y.getModuleCount()*c+m*2,u=m,d=p-m;return pt(p,p,function(x,v){if(u<=x&&x<d&&u<=v&&v<d){let P=Math.floor((x-u)/c),z=Math.floor((v-u)/c);return y.isDark(z,P)?0:1}else return 1})},y.createImgTag=function(c,m,p){c=c||2,m=typeof m>"u"?c*4:m;let u=y.getModuleCount()*c+m*2,d="";return d+="<img",d+=' src="',d+=y.createDataURL(c,m),d+='"',d+=' width="',d+=u,d+='"',d+=' height="',d+=u,d+='"',p&&(d+=' alt="',d+=Z(p),d+='"'),d+="/>",d};let Z=function(c){let m="";for(let p=0;p<c.length;p+=1){let u=c.charAt(p);switch(u){case "<":m+="&lt;";break;case ">":m+="&gt;";break;case "&":m+="&amp;";break;case '"':m+="&quot;";break;default:m+=u;break}}return m},Ge=function(c){c=typeof c>"u"?2:c;let p=y.getModuleCount()*1+c*2,u=c,d=p-c,x,v,P,z,k,b={"\u2588\u2588":"\u2588","\u2588 ":"\u2580"," \u2588":"\u2584"," ":" "},C={"\u2588\u2588":"\u2580","\u2588 ":"\u2580"," \u2588":" "," ":" "},N="";for(x=0;x<p;x+=2){for(P=Math.floor((x-u)/1),z=Math.floor((x+1-u)/1),v=0;v<p;v+=1)k="\u2588",u<=v&&v<d&&u<=x&&x<d&&y.isDark(P,Math.floor((v-u)/1))&&(k=" "),u<=v&&v<d&&u<=x+1&&x+1<d&&y.isDark(z,Math.floor((v-u)/1))?k+=" ":k+="\u2588",N+=c<1&&x+1>=d?C[k]:b[k];N+=`
937
+ `;}return p%2&&c>0?N.substring(0,N.length-p-1)+Array(p+1).join("\u2580"):N.substring(0,N.length-1)};return y.createASCII=function(c,m){if(c=c||1,c<2)return Ge(m);c-=1,m=typeof m>"u"?c*2:m;let p=y.getModuleCount()*c+m*2,u=m,d=p-m,x,v,P,z,k=Array(c+1).join("\u2588\u2588"),b=Array(c+1).join(" "),C="",N="";for(x=0;x<p;x+=1){for(P=Math.floor((x-u)/c),N="",v=0;v<p;v+=1)z=1,u<=v&&v<d&&u<=x&&x<d&&y.isDark(P,Math.floor((v-u)/c))&&(z=0),N+=z?k:b;for(P=0;P<c;P+=1)C+=N+`
938
+ `;}return C.substring(0,C.length-1)},y.renderTo2dContext=function(c,m){m=m||2;let p=y.getModuleCount();for(let u=0;u<p;u++)for(let d=0;d<p;d++)c.fillStyle=y.isDark(u,d)?"black":"white",c.fillRect(d*m,u*m,m,m);},y};O.stringToBytes=function(n){let e=[];for(let t=0;t<n.length;t+=1){let i=n.charCodeAt(t);e.push(i&255);}return e};O.createStringToBytes=function(n,e){let t=(function(){let r=st(n),a=function(){let l=r.read();if(l==-1)throw "eof";return l},s=0,o={};for(;;){let l=r.read();if(l==-1)break;let g=a(),y=a(),f=a(),h=String.fromCharCode(l<<8|g),w=y<<8|f;o[h]=w,s+=1;}if(s!=e)throw s+" != "+e;return o})(),i=63;return function(r){let a=[];for(let s=0;s<r.length;s+=1){let o=r.charCodeAt(s);if(o<128)a.push(o);else {let l=t[r.charAt(s)];typeof l=="number"?(l&255)==l?a.push(l):(a.push(l>>>8),a.push(l&255)):a.push(i);}}return a}};var S={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},Q={L:1,M:0,Q:3,H:2},R={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},D=(function(){let n=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],e=1335,t=7973,i=21522,r={},a=function(s){let o=0;for(;s!=0;)o+=1,s>>>=1;return o};return r.getBCHTypeInfo=function(s){let o=s<<10;for(;a(o)-a(e)>=0;)o^=e<<a(o)-a(e);return (s<<10|o)^i},r.getBCHTypeNumber=function(s){let o=s<<12;for(;a(o)-a(t)>=0;)o^=t<<a(o)-a(t);return s<<12|o},r.getPatternPosition=function(s){return n[s-1]},r.getMaskFunction=function(s){switch(s){case R.PATTERN000:return function(o,l){return (o+l)%2==0};case R.PATTERN001:return function(o,l){return o%2==0};case R.PATTERN010:return function(o,l){return l%3==0};case R.PATTERN011:return function(o,l){return (o+l)%3==0};case R.PATTERN100:return function(o,l){return (Math.floor(o/2)+Math.floor(l/3))%2==0};case R.PATTERN101:return function(o,l){return o*l%2+o*l%3==0};case R.PATTERN110:return function(o,l){return (o*l%2+o*l%3)%2==0};case R.PATTERN111:return function(o,l){return (o*l%3+(o+l)%2)%2==0};default:throw "bad maskPattern:"+s}},r.getErrorCorrectPolynomial=function(s){let o=j([1],0);for(let l=0;l<s;l+=1)o=o.multiply(j([1,B.gexp(l)],0));return o},r.getLengthInBits=function(s,o){if(1<=o&&o<10)switch(s){case S.MODE_NUMBER:return 10;case S.MODE_ALPHA_NUM:return 9;case S.MODE_8BIT_BYTE:return 8;case S.MODE_KANJI:return 8;default:throw "mode:"+s}else if(o<27)switch(s){case S.MODE_NUMBER:return 12;case S.MODE_ALPHA_NUM:return 11;case S.MODE_8BIT_BYTE:return 16;case S.MODE_KANJI:return 10;default:throw "mode:"+s}else if(o<41)switch(s){case S.MODE_NUMBER:return 14;case S.MODE_ALPHA_NUM:return 13;case S.MODE_8BIT_BYTE:return 16;case S.MODE_KANJI:return 12;default:throw "mode:"+s}else throw "type:"+o},r.getLostPoint=function(s){let o=s.getModuleCount(),l=0;for(let f=0;f<o;f+=1)for(let h=0;h<o;h+=1){let w=0,T=s.isDark(f,h);for(let E=-1;E<=1;E+=1)if(!(f+E<0||o<=f+E))for(let M=-1;M<=1;M+=1)h+M<0||o<=h+M||E==0&&M==0||T==s.isDark(f+E,h+M)&&(w+=1);w>5&&(l+=3+w-5);}for(let f=0;f<o-1;f+=1)for(let h=0;h<o-1;h+=1){let w=0;s.isDark(f,h)&&(w+=1),s.isDark(f+1,h)&&(w+=1),s.isDark(f,h+1)&&(w+=1),s.isDark(f+1,h+1)&&(w+=1),(w==0||w==4)&&(l+=3);}for(let f=0;f<o;f+=1)for(let h=0;h<o-6;h+=1)s.isDark(f,h)&&!s.isDark(f,h+1)&&s.isDark(f,h+2)&&s.isDark(f,h+3)&&s.isDark(f,h+4)&&!s.isDark(f,h+5)&&s.isDark(f,h+6)&&(l+=40);for(let f=0;f<o;f+=1)for(let h=0;h<o-6;h+=1)s.isDark(h,f)&&!s.isDark(h+1,f)&&s.isDark(h+2,f)&&s.isDark(h+3,f)&&s.isDark(h+4,f)&&!s.isDark(h+5,f)&&s.isDark(h+6,f)&&(l+=40);let g=0;for(let f=0;f<o;f+=1)for(let h=0;h<o;h+=1)s.isDark(h,f)&&(g+=1);let y=Math.abs(100*g/o/o-50)/5;return l+=y*10,l},r})(),B=(function(){let n=new Array(256),e=new Array(256);for(let i=0;i<8;i+=1)n[i]=1<<i;for(let i=8;i<256;i+=1)n[i]=n[i-4]^n[i-5]^n[i-6]^n[i-8];for(let i=0;i<255;i+=1)e[n[i]]=i;let t={};return t.glog=function(i){if(i<1)throw "glog("+i+")";return e[i]},t.gexp=function(i){for(;i<0;)i+=255;for(;i>=256;)i-=255;return n[i]},t})(),j=function(n,e){if(typeof n.length>"u")throw n.length+"/"+e;let t=(function(){let r=0;for(;r<n.length&&n[r]==0;)r+=1;let a=new Array(n.length-r+e);for(let s=0;s<n.length-r;s+=1)a[s]=n[s+r];return a})(),i={};return i.getAt=function(r){return t[r]},i.getLength=function(){return t.length},i.multiply=function(r){let a=new Array(i.getLength()+r.getLength()-1);for(let s=0;s<i.getLength();s+=1)for(let o=0;o<r.getLength();o+=1)a[s+o]^=B.gexp(B.glog(i.getAt(s))+B.glog(r.getAt(o)));return j(a,0)},i.mod=function(r){if(i.getLength()-r.getLength()<0)return i;let a=B.glog(i.getAt(0))-B.glog(r.getAt(0)),s=new Array(i.getLength());for(let o=0;o<i.getLength();o+=1)s[o]=i.getAt(o);for(let o=0;o<r.getLength();o+=1)s[o]^=B.gexp(B.glog(r.getAt(o))+a);return j(s,0).mod(r)},i},_e=(function(){let n=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12,7,37,13],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],e=function(r,a){let s={};return s.totalCount=r,s.dataCount=a,s},t={},i=function(r,a){switch(a){case Q.L:return n[(r-1)*4+0];case Q.M:return n[(r-1)*4+1];case Q.Q:return n[(r-1)*4+2];case Q.H:return n[(r-1)*4+3];default:return}};return t.getRSBlocks=function(r,a){let s=i(r,a);if(typeof s>"u")throw "bad rs block @ typeNumber:"+r+"/errorCorrectionLevel:"+a;let o=s.length/3,l=[];for(let g=0;g<o;g+=1){let y=s[g*3+0],f=s[g*3+1],h=s[g*3+2];for(let w=0;w<y;w+=1)l.push(e(f,h));}return l},t})(),Re=function(){let n=[],e=0,t={};return t.getBuffer=function(){return n},t.getAt=function(i){let r=Math.floor(i/8);return (n[r]>>>7-i%8&1)==1},t.put=function(i,r){for(let a=0;a<r;a+=1)t.putBit((i>>>r-a-1&1)==1);},t.getLengthInBits=function(){return e},t.putBit=function(i){let r=Math.floor(e/8);n.length<=r&&n.push(0),i&&(n[r]|=128>>>e%8),e+=1;},t},tt=function(n){let e=S.MODE_NUMBER,t=n,i={};i.getMode=function(){return e},i.getLength=function(s){return t.length},i.write=function(s){let o=t,l=0;for(;l+2<o.length;)s.put(r(o.substring(l,l+3)),10),l+=3;l<o.length&&(o.length-l==1?s.put(r(o.substring(l,l+1)),4):o.length-l==2&&s.put(r(o.substring(l,l+2)),7));};let r=function(s){let o=0;for(let l=0;l<s.length;l+=1)o=o*10+a(s.charAt(l));return o},a=function(s){if("0"<=s&&s<="9")return s.charCodeAt(0)-48;throw "illegal char :"+s};return i},it=function(n){let e=S.MODE_ALPHA_NUM,t=n,i={};i.getMode=function(){return e},i.getLength=function(a){return t.length},i.write=function(a){let s=t,o=0;for(;o+1<s.length;)a.put(r(s.charAt(o))*45+r(s.charAt(o+1)),11),o+=2;o<s.length&&a.put(r(s.charAt(o)),6);};let r=function(a){if("0"<=a&&a<="9")return a.charCodeAt(0)-48;if("A"<=a&&a<="Z")return a.charCodeAt(0)-65+10;switch(a){case " ":return 36;case "$":return 37;case "%":return 38;case "*":return 39;case "+":return 40;case "-":return 41;case ".":return 42;case "/":return 43;case ":":return 44;default:throw "illegal char :"+a}};return i},nt=function(n){let e=S.MODE_8BIT_BYTE,i=O.stringToBytes(n),r={};return r.getMode=function(){return e},r.getLength=function(a){return i.length},r.write=function(a){for(let s=0;s<i.length;s+=1)a.put(i[s],8);},r},rt=function(n){let e=S.MODE_KANJI,i=O.stringToBytes;(function(s,o){let l=i(s);if(l.length!=2||(l[0]<<8|l[1])!=o)throw "sjis not supported."})("\u53CB",38726);let r=i(n),a={};return a.getMode=function(){return e},a.getLength=function(s){return ~~(r.length/2)},a.write=function(s){let o=r,l=0;for(;l+1<o.length;){let g=(255&o[l])<<8|255&o[l+1];if(33088<=g&&g<=40956)g-=33088;else if(57408<=g&&g<=60351)g-=49472;else throw "illegal char at "+(l+1)+"/"+g;g=(g>>>8&255)*192+(g&255),s.put(g,13),l+=2;}if(l<o.length)throw "illegal char at "+(l+1)},a},De=function(){let n=[],e={};return e.writeByte=function(t){n.push(t&255);},e.writeShort=function(t){e.writeByte(t),e.writeByte(t>>>8);},e.writeBytes=function(t,i,r){i=i||0,r=r||t.length;for(let a=0;a<r;a+=1)e.writeByte(t[a+i]);},e.writeString=function(t){for(let i=0;i<t.length;i+=1)e.writeByte(t.charCodeAt(i));},e.toByteArray=function(){return n},e.toString=function(){let t="";t+="[";for(let i=0;i<n.length;i+=1)i>0&&(t+=","),t+=n[i];return t+="]",t},e},ot=function(){let n=0,e=0,t=0,i="",r={},a=function(o){i+=String.fromCharCode(s(o&63));},s=function(o){if(o<0)throw "n:"+o;if(o<26)return 65+o;if(o<52)return 97+(o-26);if(o<62)return 48+(o-52);if(o==62)return 43;if(o==63)return 47;throw "n:"+o};return r.writeByte=function(o){for(n=n<<8|o&255,e+=8,t+=1;e>=6;)a(n>>>e-6),e-=6;},r.flush=function(){if(e>0&&(a(n<<6-e),n=0,e=0),t%3!=0){let o=3-t%3;for(let l=0;l<o;l+=1)i+="=";}},r.toString=function(){return i},r},st=function(n){let e=n,t=0,i=0,r=0,a={};a.read=function(){for(;r<8;){if(t>=e.length){if(r==0)return -1;throw "unexpected end of file./"+r}let l=e.charAt(t);if(t+=1,l=="=")return r=0,-1;if(l.match(/^\s$/))continue;i=i<<6|s(l.charCodeAt(0)),r+=6;}let o=i>>>r-8&255;return r-=8,o};let s=function(o){if(65<=o&&o<=90)return o-65;if(97<=o&&o<=122)return o-97+26;if(48<=o&&o<=57)return o-48+52;if(o==43)return 62;if(o==47)return 63;throw "c:"+o};return a},at=function(n,e){let t=n,i=e,r=new Array(n*e),a={};a.setPixel=function(g,y,f){r[y*t+g]=f;},a.write=function(g){g.writeString("GIF87a"),g.writeShort(t),g.writeShort(i),g.writeByte(128),g.writeByte(0),g.writeByte(0),g.writeByte(0),g.writeByte(0),g.writeByte(0),g.writeByte(255),g.writeByte(255),g.writeByte(255),g.writeString(","),g.writeShort(0),g.writeShort(0),g.writeShort(t),g.writeShort(i),g.writeByte(0);let y=2,f=o(y);g.writeByte(y);let h=0;for(;f.length-h>255;)g.writeByte(255),g.writeBytes(f,h,255),h+=255;g.writeByte(f.length-h),g.writeBytes(f,h,f.length-h),g.writeByte(0),g.writeString(";");};let s=function(g){let y=g,f=0,h=0,w={};return w.write=function(T,E){if(T>>>E)throw "length over";for(;f+E>=8;)y.writeByte(255&(T<<f|h)),E-=8-f,T>>>=8-f,h=0,f=0;h=T<<f|h,f=f+E;},w.flush=function(){f>0&&y.writeByte(h);},w},o=function(g){let y=1<<g,f=(1<<g)+1,h=g+1,w=l();for(let I=0;I<y;I+=1)w.add(String.fromCharCode(I));w.add(String.fromCharCode(y)),w.add(String.fromCharCode(f));let T=De(),E=s(T);E.write(y,h);let M=0,A=String.fromCharCode(r[M]);for(M+=1;M<r.length;){let I=String.fromCharCode(r[M]);M+=1,w.contains(A+I)?A=A+I:(E.write(w.indexOf(A),h),w.size()<4095&&(w.size()==1<<h&&(h+=1),w.add(A+I)),A=I);}return E.write(w.indexOf(A),h),E.write(f,h),E.flush(),T.toByteArray()},l=function(){let g={},y=0,f={};return f.add=function(h){if(f.contains(h))throw "dup key:"+h;g[h]=y,y+=1;},f.size=function(){return y},f.indexOf=function(h){return g[h]},f.contains=function(h){return typeof g[h]<"u"},f};return a},pt=function(n,e,t){let i=at(n,e);for(let o=0;o<e;o+=1)for(let l=0;l<n;l+=1)i.setPixel(l,o,t(l,o));let r=De();i.write(r);let a=ot(),s=r.toByteArray();for(let o=0;o<s.length;o+=1)a.writeByte(s[o]);return a.flush(),"data:image/gif;base64,"+a},Be=O;O.stringToBytes;var lt="#476CEB",ct="-1 20.86 60 60",dt="M16.8831 21.5476C16.3856 21.5476 15.9085 21.7452 15.5567 22.097L0.549704 37.104C0.0132083 37.6405 -0.147283 38.4474 0.143066 39.1483C0.433416 39.8493 1.11743 40.3063 1.87615 40.3063H26.5982L2.74743 64.1571C0.0649471 66.8395 -0.737512 70.8738 0.714236 74.3786C2.16598 77.8834 5.58604 80.1686 9.37964 80.1686H41.7385C42.236 80.1686 42.7131 79.971 43.0649 79.6192L58.0719 64.6122C58.6084 64.0757 58.7689 63.2689 58.4785 62.5679C58.1882 61.867 57.5042 61.4099 56.7455 61.4099H32.0234L55.8742 37.5592C58.5567 34.8767 59.3591 30.8425 57.9074 27.3376C56.4556 23.8328 53.0356 21.5476 49.242 21.5476H16.8831ZM5.11632 64.1759L28.3783 40.3812H30.6653L5.11632 64.1759ZM30.1464 61.4059L53.4083 37.6111L27.8594 61.4059H30.1464Z";function ut(n){let e=/viewBox="0 0 ([\d.]+) [\d.]+"/.exec(n);return e?Number(e[1]):null}function mt(n){let e=n*.24,t=(n-e)/2,i=e*1.18,r=(n-i)/2,a=e*.16;return ['<g shape-rendering="geometricPrecision">',`<rect x="${r}" y="${r}" width="${i}" height="${i}" rx="${i*.22}" fill="#ffffff"/>`,`<svg x="${t+a}" y="${t+a}" width="${e-a*2}" height="${e-a*2}" viewBox="${ct}">`,`<path d="${dt}" fill="${lt}"/>`,"</svg>","</g>"].join("")}function He(n){let e=ut(n);return e?n.replace("</svg>",`${mt(e)}</svg>`):n}function Ze(){return '<svg class="zippy-brand-lock" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path d="M7 10V8a5 5 0 0 1 10 0v2" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"/><rect x="5" y="10" width="14" height="11" rx="2.5" stroke="currentColor" stroke-width="1.75"/><circle cx="12" cy="15.5" r="1.25" fill="currentColor"/></svg>'}var ht="merchant-payment";function Ue(n){return `zippy://${ht}/${n}`}function Oe(n,e=4,t="H",i=2){let r=Be(0,t);return r.addData(n),r.make(),r.createSvgTag(e,i)}function Fe(n,e=4,t="H"){return Oe(Ue(n),e,t)}function $e(n,e=4){return He(Fe(n,e,"H"))}function me(n,e=4){return `<div class="zippy-qr-stack">${$e(n,e)}</div>`}function qe(n){return n.phase==="PAYING"&&n.paymentExpiryAt?n.paymentExpiryAt:null}var yt=["qr-active","awaiting","manual-confirm"],ft=["loading","choose-method","success","expired","cancelled","declined","failed","invalid-session","error"];function he(n,e){return !n?.paymentExpiryAt||ft.includes(e)||F.includes(n.status)||H(n.paymentExpiryAt)<=0?false:qe(n)?true:yt.includes(e)}function V(n){if(!n.paymentExpiryAt)return null;let e=n.paymentExpiryAt,t=new Date(e).getTime(),i=n.paymentStartAt?new Date(n.paymentStartAt).getTime():t-300*1e3,r=t-i;return r<=0?0:Math.min(1,Math.max(0,H(e)/r))}function gt(n){return n.phase==="IDLE"&&n.expiresAt?n.expiresAt:null}function H(n){return Math.max(0,new Date(n).getTime()-Date.now())}var K=class{constructor(e,t,i,r=""){this.expiryTimer=null;this.terminalExitTimer=null;this.callbacks=i,this.state=t,this.shadow=e.attachShadow({mode:"open"});let a=document.createElement("style");a.textContent=Ae+r,this.shadow.appendChild(a),this.root=document.createElement("div"),this.root.className="zippy-root",this.root.setAttribute("role","region"),this.root.setAttribute("aria-label","Zippy Pay checkout"),this.shadow.appendChild(this.root),this.render();}update(e){let t={...this.state,...e};if(this.shouldSkipRender(this.state,t)){this.state=t;return}this.state=t,this.render();}shouldSkipRender(e,t){return this.renderSnapshot(e)===this.renderSnapshot(t)}renderSnapshot(e){let t=e.session;return JSON.stringify({phase:e.phase,sessionId:e.sessionId,committedMethod:e.committedMethod,paymentId:e.paymentId,errorMessage:e.errorMessage,loading:e.loading,mode:e.mode,exitMode:e.exitMode??null,verifiedPayer:e.verifiedPayer,session:t?{status:t.status,phase:t.phase,amount:t.amount,currency:t.currency,businessName:t.businessName,paymentExpiryAt:t.paymentExpiryAt,paymentStartAt:t.paymentStartAt,payer:t.payer,transactionStatus:t.transactionStatus,checkoutMethod:t.checkoutMethod,expiresAt:t.expiresAt,transactionId:t.transactionId}:null})}restoreFocusState(){let e=this.shadow.activeElement;return e instanceof HTMLInputElement&&e.id?{id:e.id,selection:e.selectionStart}:{id:null,selection:null}}applyFocusState(e){if(!e.id)return;let t=this.shadow.getElementById(e.id);t instanceof HTMLInputElement&&(t.focus(),e.selection!==null&&t.setSelectionRange(e.selection,e.selection));}destroy(){this.clearExpiryTimer(),this.clearTerminalExitTimer();}getShadowRoot(){return this.shadow}render(){let e=this.restoreFocusState();this.clearExpiryTimer(),this.clearTerminalExitTimer();let{phase:t,session:i,errorMessage:r,loading:a,verifiedPayer:s,paymentId:o,sessionId:l,committedMethod:g,exitMode:y,mode:f}=this.state,h=t==="success"||t==="expired"||t==="cancelled"||t==="declined"||t==="failed"||t==="invalid-session"||t==="error",w=!h&&he(i,t),T=t==="qr-active"||t==="awaiting"&&g==="qr";this.root.className=w?T?"zippy-root zippy-root--paying zippy-root--qr":"zippy-root zippy-root--paying":h?"zippy-root zippy-root--terminal":"zippy-root",this.root.innerHTML="";let E=h?this.root:document.createElement("div");if(h||(E.className="zippy-root-body",this.root.appendChild(E)),t==="loading"){if(E.appendChild(this.renderLoading()),E.appendChild(this.renderBrandFooter()),w){let A=i?V(i):null;A!==null&&A>0&&this.root.appendChild(this.renderPayProgress());}this.applyFocusState(e);return}switch(i&&!h&&E.appendChild(this.renderPaymentHero(i,this.heroSubtitle(t,i))),w&&t!=="qr-active"&&i?.paymentExpiryAt&&H(i.paymentExpiryAt)>0&&E.appendChild(this.renderPayTimer(i.paymentExpiryAt)),t){case "choose-method":E.appendChild(this.renderChooseMethod());break;case "qr-active":E.appendChild(this.renderQrActive(l,i));break;case "manual-entry":case "manual-confirm":E.appendChild(this.renderManualFlow(o,s,r,a));break;case "awaiting":E.appendChild(this.renderAwaiting(i,g??"qr",s));break;case "success":case "expired":case "cancelled":case "declined":case "failed":case "invalid-session":E.appendChild(this.renderOutcomeScreen(t,i,y,f)),this.mountTerminalExitTimer();break;case "error":E.appendChild(this.renderTerminal("error","Something went wrong",r??"Please try again or contact the merchant."));break;}if(h?this.root.appendChild(this.renderBrandFooter()):E.appendChild(this.renderBrandFooter()),w){let A=i?V(i):null;A!==null&&A>0&&this.root.appendChild(this.renderPayProgress());}this.applyFocusState(e);}heroSubtitle(e,t){switch(e){case "choose-method":return "Choose how to pay";case "qr-active":return t?.status==="AWAITING_PAYMENT"?"Waiting for confirmation":"Scan with the Zippy app";case "manual-entry":return "Pay with your Zippy ID";case "manual-confirm":return "Review and confirm";case "awaiting":return "Waiting for confirmation";default:return ""}}renderPaymentHero(e,t){let i=document.createElement("div");i.className="zippy-payment-hero";let r=document.createElement("p");r.className="zippy-payment-merchant",r.textContent=e.businessName;let a=document.createElement("p");if(a.className="zippy-payment-amount",a.textContent=se(e.amount,e.currency),i.appendChild(r),i.appendChild(a),t){let s=document.createElement("p");s.className="zippy-payment-subtitle",s.textContent=t,i.appendChild(s);}return i}renderBrandFooter(){let e=document.createElement("div");e.className="zippy-brand-footer",e.setAttribute("aria-label","Secured by Zippy");let t=document.createElement("div");t.className="zippy-brand-footer-inner";let i=document.createElement("span");i.className="zippy-brand-secure",i.innerHTML=`${Ze()}<span class="zippy-brand-copy">Secured by</span>`;let r=document.createElement("span");r.className="zippy-brand-divider",r.setAttribute("aria-hidden","true");let a=document.createElement("span");return a.className="zippy-brand-name",a.textContent="Zippy",t.appendChild(i),t.appendChild(r),t.appendChild(a),e.appendChild(t),e}renderLoading(){let e=document.createElement("div");e.className="zippy-status";let t=document.createElement("div");t.className="zippy-status-icon loading";let i=document.createElement("div");i.className="zippy-spinner",t.appendChild(i);let r=document.createElement("p");return r.className="zippy-status-title",r.textContent="Loading checkout\u2026",e.appendChild(t),e.appendChild(r),e}renderChooseMethod(){let e=document.createElement("div");e.className="zippy-choose";let t=document.createElement("div");return t.className="zippy-choose-options",t.appendChild(this.renderMethodCard({method:"qr",title:"QR code",description:"Open Zippy and scan",icon:this.qrIconSvg()})),t.appendChild(this.renderMethodCard({method:"manual",title:"Zippy ID",description:"Enter your handle",icon:this.idIconSvg()})),e.appendChild(t),e}renderMethodCard(e){let t=document.createElement("button");t.type="button",t.className=`zippy-method-card zippy-method-card--${e.method}`,t.setAttribute("aria-label",e.method==="qr"?"Pay by scanning a QR code in the Zippy app":"Pay with your Zippy ID");let i=document.createElement("span");i.className="zippy-method-icon",i.innerHTML=e.icon;let r=document.createElement("span");r.className="zippy-method-copy";let a=document.createElement("span");a.className="zippy-method-title",a.textContent=e.title;let s=document.createElement("span");return s.className="zippy-method-hint",s.textContent=e.description,r.appendChild(a),r.appendChild(s),t.appendChild(i),t.appendChild(r),t.addEventListener("click",()=>this.callbacks.onChooseMethod(e.method)),t}renderQrActive(e,t){let i=document.createElement("div");i.className="zippy-flow";let r=t?.status==="AWAITING_PAYMENT",a=document.createElement("div");a.className="zippy-qr-section";let s=document.createElement("div");return s.className="zippy-qr-frame",s.innerHTML=me(e),a.appendChild(s),t?.paymentExpiryAt&&H(t.paymentExpiryAt)>0&&a.appendChild(this.renderPayTimer(t.paymentExpiryAt)),r&&a.appendChild(this.renderQrAwaitingLoader()),i.appendChild(a),r?(t?.payer&&i.appendChild(this.renderIdentityCard(t.payer)),i.appendChild(this.renderFootnote("Complete the payment in the Zippy app to finish checkout."))):(i.appendChild(this.renderStepGuide(["Open Zippy Pay on your phone","Tap Scan and point at the code","Confirm the amount shown"])),i.appendChild(this.renderFootnote("Keep this page open until payment completes."))),i}renderQrAwaitingLoader(){let e=document.createElement("div");e.className="zippy-qr-awaiting",e.setAttribute("aria-live","polite"),e.setAttribute("aria-label","Waiting for payment confirmation");let t=document.createElement("span");return t.className="zippy-qr-awaiting-spinner",t.setAttribute("aria-hidden","true"),e.appendChild(t),e}renderPayTimer(e){let t=document.createElement("div");t.className="zippy-pay-timer-slot";let i=document.createElement("div");i.className="zippy-pay-timer";let r=document.createElement("span");r.className="zippy-pay-timer-value",r.setAttribute("aria-live","polite"),r.textContent=pe(H(e));let a=document.createElement("span");return a.className="zippy-pay-timer-label",a.textContent="To pay",i.appendChild(r),i.appendChild(a),t.appendChild(i),t}renderManualFlow(e,t,i,r){let a=document.createElement("div");a.className="zippy-flow";let s=document.createElement("form");s.className="zippy-id-form",s.addEventListener("submit",T=>{T.preventDefault();});let o=document.createElement("div");o.className="zippy-input-combo";let l=document.createElement("input");l.id="zippy-payment-id",l.className="zippy-input-combo-field",l.type="text",l.placeholder="your.zippy.id",l.autocomplete="off",l.spellcheck=false,l.inputMode="text",l.value=e,l.disabled=r,l.setAttribute("aria-label","Zippy payment ID");let g=document.createElement("span");g.className="zippy-input-combo-divider",g.setAttribute("aria-hidden","true");let y=document.createElement("button");y.type="button",y.className="zippy-input-combo-action",y.textContent="Verify",y.setAttribute("aria-label","Verify Zippy ID");let f=document.createElement("button");f.type="button",f.className="zippy-btn zippy-btn-primary zippy-btn-block",f.textContent=r&&t?"Processing\u2026":"Proceed";let h=T=>!!(t&&t.paymentId===T.trim().toLowerCase()),w=()=>{let T=l.value.trim(),E=h(l.value),M=r&&!E;o.classList.toggle("zippy-input-combo--verified",E),y.disabled=r||T.length===0||E,y.classList.toggle("zippy-input-combo-action--loading",M);let A=y.querySelector(".zippy-spinner-inline");if(M){if(y.textContent="",!A){let I=document.createElement("span");I.className="zippy-spinner-inline",I.setAttribute("aria-hidden","true"),y.appendChild(I);}y.setAttribute("aria-label","Verifying Zippy ID");}else A?.remove(),y.classList.remove("zippy-input-combo-action--verified"),E?(y.textContent="",y.classList.add("zippy-input-combo-action--verified"),y.innerHTML=xt(),y.setAttribute("aria-label","Zippy ID verified")):(y.textContent="Verify",y.setAttribute("aria-label","Verify Zippy ID"));f.disabled=r||!E;};return y.addEventListener("click",()=>{this.callbacks.onVerify(l.value);}),f.addEventListener("click",()=>{t&&this.callbacks.onPay(e||t.paymentId);}),l.addEventListener("input",()=>{this.state.paymentId=l.value,this.callbacks.onPaymentIdChange?.(l.value),w();}),w(),i&&o.classList.add("zippy-input-combo--error"),o.appendChild(l),o.appendChild(g),o.appendChild(y),s.appendChild(o),i&&s.appendChild(this.renderFieldError(i)),t&&h(e)&&s.appendChild(this.renderIdentityCard(t)),s.appendChild(f),a.appendChild(s),a}renderFieldError(e){let t=document.createElement("p");t.className="zippy-field-error",t.setAttribute("role","alert");let i=document.createElement("span");i.className="zippy-field-error-icon",i.setAttribute("aria-hidden","true"),i.textContent="!";let r=document.createElement("span");return r.textContent=e,t.appendChild(i),t.appendChild(r),t}renderIdentityCard(e){let t=document.createElement("div");t.className="zippy-identity-card";let i=this.renderIdentityAvatar(e),r=document.createElement("div");r.className="zippy-identity-copy";let a=document.createElement("p");a.className="zippy-identity-label",a.textContent="Paying as";let s=document.createElement("p");s.className="zippy-identity-name",s.textContent=e.displayName;let o=document.createElement("p");return o.className="zippy-identity-handle",o.textContent=e.paymentId,r.appendChild(a),r.appendChild(s),r.appendChild(o),t.appendChild(i),t.appendChild(r),t}renderIdentityAvatar(e){let t=document.createElement("div");t.className="zippy-identity-avatar";let i=ze(e.displayName),r=e.profileImage?.trim();if(r){t.classList.add("zippy-identity-avatar--photo");let a=document.createElement("img");a.className="zippy-identity-avatar-image",a.src=r,a.alt="",a.addEventListener("error",()=>{t.classList.remove("zippy-identity-avatar--photo"),a.remove(),t.textContent=i;}),t.appendChild(a);}else t.textContent=i;return t}renderAwaiting(e,t,i){let r=document.createElement("div");r.className="zippy-flow zippy-flow-awaiting";let a=document.createElement("div");a.className="zippy-awaiting-status",a.innerHTML='<div class="zippy-awaiting-ring" aria-hidden="true"><span></span></div>',r.appendChild(a);let s=e?.payer??i??null;s&&r.appendChild(this.renderIdentityCard(s));let o=document.createElement("p");return o.className="zippy-awaiting-message",o.textContent=t==="qr"?"Complete the payment in the Zippy app to finish checkout.":"Tap the notification in Zippy Pay to approve this payment.",r.appendChild(o),r.appendChild(this.renderFootnote("Do not close or refresh this page.")),r}renderStepGuide(e){let t=document.createElement("div");return t.className="zippy-step-guide",e.forEach((i,r)=>{let a=document.createElement("div");a.className="zippy-step-guide-item";let s=document.createElement("span");s.className="zippy-step-guide-num",s.textContent=String(r+1);let o=document.createElement("span");o.className="zippy-step-guide-text",o.textContent=i,a.appendChild(s),a.appendChild(o),t.appendChild(a);}),t}renderPayProgress(){let e=document.createElement("div");e.className="zippy-pay-progress",e.setAttribute("role","progressbar"),e.setAttribute("aria-label","Payment time remaining"),e.setAttribute("aria-valuemin","0"),e.setAttribute("aria-valuemax","100");let t=document.createElement("div");return t.className="zippy-pay-progress-fill",e.appendChild(t),this.mountPayProgress(t,e),e}mountPayProgress(e,t){let i=()=>{let r=this.state.session;if(!r)return;let a=V(r);if(a===null||a<=0){t.style.display="none",t.setAttribute("aria-valuenow","0"),this.clearExpiryTimer();return}t.style.display="";let s=Math.round(a*100);e.style.transform=`scaleX(${a})`,t.setAttribute("aria-valuenow",String(s));let o=this.shadow.querySelector(".zippy-pay-timer-value");o instanceof HTMLElement&&r.paymentExpiryAt&&(o.textContent=pe(H(r.paymentExpiryAt)));};i(),this.expiryTimer=setInterval(i,1e3);}clearExpiryTimer(){this.expiryTimer!==null&&(clearInterval(this.expiryTimer),this.expiryTimer=null);}mountTerminalExitTimer(){this.clearTerminalExitTimer();let e=ae,t=()=>{let i=this.shadow.querySelector(".zippy-status-exit-countdown");i instanceof HTMLElement&&(i.textContent=String(e));};t(),this.terminalExitTimer=setInterval(()=>{if(e-=1,e<=0){this.clearTerminalExitTimer(),this.callbacks.onTerminalExit?.();return}t();},1e3);}clearTerminalExitTimer(){this.terminalExitTimer!==null&&(clearInterval(this.terminalExitTimer),this.terminalExitTimer=null);}renderFootnote(e){let t=document.createElement("p");return t.className="zippy-footnote",t.textContent=e,t}renderOutcomeScreen(e,t,i,r){let a=Pe(e);return this.renderOutcomeStatus(a.kind,a.title,a.detail,a.kind,i,r,t?.transactionId??null)}renderOutcomeStatus(e,t,i,r,a,s,o){let l=this.renderTerminal(e,t,i);o&&l.appendChild(this.renderTransactionReference(o));let g=a??"close",y=document.createElement("p");y.className="zippy-status-exit";let f=document.createElement("span");f.className="zippy-status-exit-lead",f.textContent=Ee(g,s,r);let h=document.createElement("span");h.className="zippy-status-exit-countdown",h.textContent=String(ae);let w=document.createElement("span");return w.className="zippy-status-exit-suffix",w.textContent=" seconds\u2026",y.appendChild(f),y.appendChild(document.createTextNode(" ")),y.appendChild(h),y.appendChild(w),l.appendChild(y),l}renderTransactionReference(e){let t=document.createElement("div");t.className="zippy-transaction-ref";let i=document.createElement("p");i.className="zippy-transaction-ref-label",i.textContent="Transaction ID";let r=document.createElement("p");return r.className="zippy-transaction-ref-value",r.textContent=e,t.appendChild(i),t.appendChild(r),t}renderTerminal(e,t,i){let r=document.createElement("div");r.className="zippy-status";let a=document.createElement("div");a.className=`zippy-status-icon ${e}`,a.innerHTML=e==="success"?'<svg width="28" height="28" viewBox="0 0 28 28" fill="none" aria-hidden="true"><path d="M7 14.5l4.5 4.5L21 9.5" stroke="currentColor" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round"/></svg>':'<svg width="28" height="28" viewBox="0 0 28 28" fill="none" aria-hidden="true"><path d="M10 10l8 8M18 10l-8 8" stroke="currentColor" stroke-width="2.25" stroke-linecap="round"/></svg>';let s=document.createElement("p");s.className="zippy-status-title",s.textContent=t;let o=document.createElement("p");return o.className="zippy-status-detail",o.textContent=i,r.appendChild(a),r.appendChild(s),r.appendChild(o),r}qrIconSvg(){return `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
939
+ <rect x="3" y="3" width="7" height="7" rx="1.25" stroke="currentColor" stroke-width="1.6"/>
940
+ <rect x="14" y="3" width="7" height="7" rx="1.25" stroke="currentColor" stroke-width="1.6"/>
941
+ <rect x="3" y="14" width="7" height="7" rx="1.25" stroke="currentColor" stroke-width="1.6"/>
942
+ <rect x="14" y="14" width="3" height="3" rx="0.5" fill="currentColor"/>
943
+ <rect x="18" y="14" width="3" height="3" rx="0.5" fill="currentColor"/>
944
+ <rect x="14" y="18" width="3" height="3" rx="0.5" fill="currentColor"/>
945
+ <rect x="18" y="18" width="3" height="3" rx="0.5" fill="currentColor"/>
946
+ </svg>`}idIconSvg(){return `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
947
+ <circle cx="12" cy="9" r="3.5" stroke="currentColor" stroke-width="1.6"/>
948
+ <path d="M5 20c0-3.87 3.13-7 7-7s7 3.13 7 7" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/>
949
+ </svg>`}};function xt(){return '<svg class="zippy-input-combo-check" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path d="M6.5 12.5 10 16l7.5-7.5" stroke="currentColor" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round"/></svg>'}var X=class{constructor(e){this.ui=null;this.session=null;this.paymentId="";this.verifiedPayer=null;this.committedMethod=null;this.phase="loading";this.errorMessage=null;this.loading=true;this.destroyed=false;this.modalOpen=false;this.exitMode=null;this.terminalFailureReason=null;if(this.config={mode:"inline",closeOnBackdropClick:false,closeOnEscape:false,...e},!we(this.config.sessionId))throw new Error("Zippy Pay: sessionId must be a UUID v4.");$(this.config.environment),this.client=new q({baseUrl:ne(this.config.environment),sessionId:this.config.sessionId,clientToken:this.config.clientToken}),this.embed=Ie(this.config),de(this.embed.host,this.config.theme),this.poller=new Y(()=>this.client.getSession(),{onUpdate:t=>this.handleSessionUpdate(t),onError:t=>this.handleError(t)}),this.ui=new K(this.embed.host,this.snapshotUiState(),{onChooseMethod:t=>{this.chooseMethod(t);},onVerify:t=>this.verify(t),onPay:t=>this.attach(t),onPaymentIdChange:t=>{let i=t.trim().toLowerCase(),r=false;this.verifiedPayer&&i!==this.verifiedPayer.paymentId.toLowerCase()&&(this.verifiedPayer=null,this.phase==="manual-confirm"&&(this.phase="manual-entry"),r=true),this.errorMessage&&(this.errorMessage=null,r=true),this.paymentId=t,r&&this.syncUi();},onTerminalExit:()=>this.executeTerminalExit()}),this.bootstrap(),this.config.mode==="inline"&&(this.modalOpen=true);}open(){this.config.mode!=="modal"||this.modalOpen||(this.modalOpen=true,Le(this.embed,this.config,()=>this.close()));}close(){this.config.mode==="modal"&&(this.modalOpen=false,Ne(this.embed),this.config.onClose?.());}destroy(){this.destroyed||(this.destroyed=true,this.poller.stop(),this.ui?.destroy(),this.embed.destroy(),this.ui=null);}snapshotUiState(){return {phase:this.phase,session:this.session,sessionId:this.config.sessionId,committedMethod:this.committedMethod,paymentId:this.paymentId,verifiedPayer:this.verifiedPayer,errorMessage:this.errorMessage,loading:this.loading,mode:this.config.mode??"inline",exitMode:this.exitMode}}syncUi(e){this.destroyed||(e&&"errorMessage"in e&&(this.errorMessage=e.errorMessage??null),e&&"loading"in e&&(this.loading=e.loading??false),e&&"exitMode"in e&&(this.exitMode=e.exitMode??null),this.ui?.update({phase:this.phase,session:this.session,sessionId:this.config.sessionId,committedMethod:this.committedMethod,paymentId:this.paymentId,verifiedPayer:this.verifiedPayer,errorMessage:this.errorMessage,loading:this.loading,mode:this.config.mode??"inline",exitMode:this.exitMode}));}async bootstrap(){try{let e=await this.client.getSession();if(this.applySession(e),this.destroyed)return;this.config.onReady?.(e),ue(e.status)||this.poller.start(e);}catch(e){this.handleBootstrapError(e);}}applySession(e){if(this.session=e,this.config.onSessionUpdate?.(e),this.committedMethod=bt(e.checkoutMethod)??this.committedMethod,e.transactionStatus==="DECLINED"&&e.status!=="COMPLETED"){this.handleFailure({reason:"declined",session:e});return}if(e.status==="COMPLETED"){this.handleSuccess(e);return}if(e.status==="EXPIRED"){this.handleFailure({reason:"expired",session:e});return}if(e.status==="FAILED"){this.handleFailure({reason:"failed",session:e});return}if(e.status==="CANCELLED"){this.handleFailure({reason:"cancelled",session:e});return}this.phase=this.resolveActivePhase(e),this.syncUi();}resolveActivePhase(e){return e.status==="AWAITING_PAYMENT"?e.checkoutMethod==="QR"||this.committedMethod==="qr"?"qr-active":"awaiting":e.phase==="PAYING"&&e.checkoutMethod==="QR"?"qr-active":e.phase==="PAYING"&&e.checkoutMethod==="MANUAL"?this.phase==="manual-confirm"&&this.verifiedPayer?"manual-confirm":"manual-entry":e.phase==="IDLE"?this.phase==="manual-confirm"&&this.verifiedPayer&&this.committedMethod==="manual"?"manual-confirm":this.phase==="manual-entry"&&this.committedMethod==="manual"?"manual-entry":this.phase==="qr-active"&&this.committedMethod==="qr"?"qr-active":"choose-method":this.phase==="loading"?"choose-method":this.phase}handleSessionUpdate(e){this.destroyed||this.applySession(e);}handleFailure(e){if(this.destroyed)return;this.poller.stop(),this.loading=false;let t=e.session??this.session;if(e.reason==="expired")t&&this.config.onExpired?.(t);else {let i=e.error??(e.reason==="failed"||e.reason==="cancelled"||e.reason==="declined"?vt(e.reason):void 0);i&&this.config.onError?.(i);}this.terminalFailureReason=e.reason,this.phase=this.failurePhaseFromReason(e.reason),this.exitMode=this.resolveExitMode("failure",t),this.syncUi();}handleSuccess(e){this.destroyed||(this.poller.stop(),this.loading=false,this.config.onComplete?.(e),this.terminalFailureReason=null,this.phase="success",this.exitMode=this.resolveExitMode("success",e),this.syncUi());}executeTerminalExit(){if(this.destroyed)return;let e=this.session;if(this.phase==="success"&&e){if(this.config.redirectOnComplete&&e.successUrl){window.location.assign(le(e.successUrl,{sessionId:e.sessionId,status:e.status,transactionId:e.transactionId}));return}}else if(this.phase==="expired"||this.phase==="failed"||this.phase==="cancelled"||this.phase==="declined"||this.phase==="invalid-session"){let t=e?.failureUrl??null;if(this.config.redirectOnFailure&&t){let i=this.terminalFailureReason==="expired"?le(t,{sessionId:e?.sessionId??this.config.sessionId,status:e?.status??"EXPIRED"}):t;window.location.assign(i);return}}this.teardownView();}resolveExitMode(e,t){return e==="success"?this.config.redirectOnComplete&&t?.successUrl?"redirect":"close":this.config.redirectOnFailure&&t?.failureUrl?"redirect":"close"}failurePhaseFromReason(e){switch(e){case "expired":return "expired";case "failed":return "failed";case "cancelled":return "cancelled";case "declined":return "declined";case "invalid-session":return "invalid-session"}}teardownView(){this.config.mode==="modal"&&this.modalOpen&&this.close(),this.destroy();}handleBootstrapError(e){if(e instanceof L&&e.status===401){this.handleFailure({reason:"invalid-session",error:e,session:this.session});return}this.handleError(e);}handleError(e){let t=Ye(e);if(t.status===401){this.handleFailure({reason:"invalid-session",error:t,session:this.session});return}if(t.code==="payment-session.not-attachable"){this.handleFailure({reason:"expired",session:this.session});return}(this.phase==="loading"||this.phase==="choose-method")&&(this.phase="error"),this.syncUi({errorMessage:t.detail,loading:false}),this.config.onError?.(t),this.poller.stop();}async chooseMethod(e){if(!this.committedMethod){this.committedMethod=e,this.verifiedPayer=null,this.syncUi({errorMessage:null,loading:true});try{if(e==="qr"){let t=await this.client.startQrCheckout();if(this.applySession(t),this.destroyed)return;this.syncUi({loading:!1});}else this.phase="manual-entry",this.syncUi({loading:!1});}catch(t){this.committedMethod=null,this.handleFlowError(t,"choose-method");}}}async verify(e){if(this.paymentId=e,!re(e)){this.syncUi({errorMessage:oe(),loading:false});return}this.syncUi({errorMessage:null,loading:true});try{let t=await this.client.verifyPayer(e);this.verifiedPayer=t,this.phase="manual-confirm",this.syncUi({loading:!1});}catch(t){this.handleFlowError(t,"manual-entry");}}async attach(e){if(!this.verifiedPayer||wt(e)!==this.verifiedPayer.paymentId){this.syncUi({errorMessage:"Verify your Zippy ID before proceeding to pay.",loading:false});return}this.syncUi({errorMessage:null,loading:true});try{let t=await ce(this.client,e);if(this.committedMethod="manual",this.applySession(t),this.destroyed)return;t.status==="AWAITING_PAYMENT"&&this.poller.start(t),this.syncUi({loading:!1});}catch(t){this.handleFlowError(t,"manual-confirm");}}handleFlowError(e,t){let i=Ye(e),r=Et(i,t);if(i.code==="payment-session.not-attachable"){this.handleFailure({reason:"expired",session:this.session});return}else if(i.code==="payment-session.checkout-method-conflict"){this.refreshAfterConflict(),this.syncUi({errorMessage:r,loading:false}),this.config.onError?.(i);return}else this.phase=t;this.syncUi({errorMessage:r,loading:false}),this.config.onError?.(i);}async refreshAfterConflict(){try{let e=await this.client.getSession();this.applySession(e);}catch{}}};function vt(n){return n==="failed"?new L({code:"payment-session.failed",status:400,title:"Payment failed",detail:"Something went wrong with this payment."}):n==="declined"?new L({code:"payment-session.declined",status:400,title:"Payment declined",detail:"Your payment was declined."}):new L({code:"payment-session.cancelled",status:400,title:"Payment cancelled",detail:"This payment was cancelled."})}function bt(n){return n==="QR"?"qr":n==="MANUAL"?"manual":null}function wt(n){return n.trim().toLowerCase()}function Et(n,e){return e==="manual-entry"&&(n.status===404||n.code.includes("not-found")||n.code.includes("payer-not-found")||n.code==="payer.not-found")?"Zippy ID not found":n.detail?.trim()||"Something went wrong. Please try again."}function Ye(n){return n instanceof L?n:new L({code:"unknown",status:500,title:"Unexpected error",detail:n instanceof Error?n.message:"An unexpected error occurred"})}function G(n){return new X(n)}var ye="zippy-pay-checkout",Qe={"theme-primary":"primary","theme-primary-foreground":"primaryForeground","theme-background":"background","theme-surface":"surface","theme-text":"text","theme-text-muted":"textMuted","theme-border":"border","theme-error":"error","theme-success":"success","theme-border-radius":"borderRadius","theme-font-family":"fontFamily","theme-mode":"mode"},J=class extends HTMLElement{constructor(){super(...arguments);this.instance=null;}static get observedAttributes(){return ["mode","session-id","environment",...Object.keys(Qe)]}connectedCallback(){this.mount();}disconnectedCallback(){this.unmount();}attributeChangedCallback(){this.isConnected&&(this.unmount(),this.mount());}set clientToken(t){this.dataset.clientToken=t,this.isConnected&&(this.unmount(),this.mount());}get clientToken(){return this.dataset.clientToken??this.getAttribute("client-token")??""}mount(){let t=this.readConfig();if(!t)return;this.innerHTML="";let i=t.mode??"inline",r;if(i==="inline"){let a=document.createElement("div");this.appendChild(a),r=a;}this.instance=G({...t,container:r,mode:i,onReady:a=>this.dispatch("zippy-ready",a),onSessionUpdate:a=>this.dispatch("zippy-session-update",a),onComplete:a=>this.dispatch("zippy-complete",a),onExpired:a=>this.dispatch("zippy-expired",a),onError:a=>this.dispatch("zippy-error",a),onClose:()=>this.dispatch("zippy-close",null)}),t.mode==="modal"&&this.instance.open();}unmount(){this.instance?.destroy(),this.instance=null,this.innerHTML="";}readConfig(){let t=this.getAttribute("environment")??"production",i=this.getAttribute("session-id")??"",r=this.clientToken,a=this.getAttribute("mode")??"inline";if(!i||!r)return null;let s;try{s=$(t);}catch{return null}let o={};for(let[l,g]of Object.entries(Qe)){let y=this.getAttribute(l);y&&(g==="mode"?o.mode=y:o[g]=y);}return {environment:s,sessionId:i,clientToken:r,mode:a,theme:o}}dispatch(t,i){this.dispatchEvent(new CustomEvent(t,{detail:i,bubbles:true,composed:true}));}open(){this.instance?.open();}close(){this.instance?.close();}destroy(){this.instance?.destroy(),this.instance=null;}};function fe(){typeof customElements>"u"||customElements.get(ye)||customElements.define(ye,J);}var Pt={create(n){let e=G(n);return (n.mode??"inline")==="modal"&&e.open(),e}};fe();var ui=Pt;
950
+ export{X as CheckoutController,Te as DEFAULT_THEME,ye as ELEMENT_TAG,be as PAYMENT_ID_PATTERN,te as POLLABLE_STATUSES,q as PaymentSessionClient,Y as SessionPoller,F as TERMINAL_STATUSES,W as ZIPPY_API_BASE_URLS,ie as ZIPPY_API_PATH_PREFIX,Pt as ZippyPay,J as ZippyPayCheckoutElement,L as ZippyPayError,de as applyThemeToHost,ce as attachPayerWithRetry,Ue as buildPaymentQrPayload,G as createCheckout,ui as default,fe as defineZippyPayCheckoutElement,se as formatAmount,qe as getCountdownTarget,V as getPayWindowRemainingRatio,gt as getSoftIdleHint,ue as isTerminalStatus,re as isValidPaymentId,ve as isZippyEnvironment,H as msUntil,U as normalizePaymentId,$ as parseZippyEnvironment,oe as paymentIdValidationMessage,et as phaseFromSession,$e as renderBrandedPaymentQrSvg,me as renderPaymentQrMarkup,Fe as renderPaymentQrSvg,Oe as renderQrSvg,ne as resolveApiBaseUrl,Me as resolveTheme,he as shouldShowPayProgress};//# sourceMappingURL=index.mjs.map
951
+ //# sourceMappingURL=index.mjs.map