@zippypay/checkout 1.1.10 → 1.1.11

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 CHANGED
@@ -1,5 +1,5 @@
1
- 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var Y=["COMPLETED","EXPIRED","CANCELLED","FAILED"],xe=["CREATED","AWAITING_PAYMENT"],I=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 le={production:"https://api.zippypay.io",staging:"https://staging.api.zippypay.io",development:""},we="/api/v1";function Je(n){return n in le}function Pe(n){return le[n].replace(/\/+$/,"")}function j(n){let e=n.trim().toLowerCase();if(!Je(e))throw new Error(`Zippy Pay: invalid environment "${n}". Expected one of: ${Object.keys(le).join(", ")}.`);return e}var ke=/^(?=.{3,20}$)[a-z0-9]+(?:\.[a-z0-9]+)?$/,et=/^\+[1-9]\d{7,14}$/,tt=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function V(n){return n.trim().toLowerCase()}function $(n){let e=n.trim();return e.includes("@")?e.toLowerCase():e.startsWith("+")?e:e.toLowerCase()}function _t(n){return ke.test(V(n))}function ze(n){let e=n.trim();return e.length<3||e.length>100||/\s/.test(e)||/[\x00-\x1f\x7f]/.test(e)?false:e.includes("@")?tt.test(e):e.startsWith("+")?et.test(e):ke.test(e.toLowerCase())}function Rt(){return "Enter 3\u201320 lowercase letters or digits, with at most one dot (e.g. john.doe12)."}function Ee(){return "Enter a Zippy ID, email, or phone number in E.164 format (e.g. +15551234567)."}function it(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 Ht={USD:"en-US"};function Ce(n,e){let t=Number.parseFloat(n);if(Number.isNaN(t))return `${n} ${e}`;let i=Ht[e]??"en-US";return new Intl.NumberFormat(i,{style:"currency",currency:e,minimumFractionDigits:2,maximumFractionDigits:2}).format(t)}var Ae=7;function nt(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 rt(n){switch(n){case "success":return {kind:"success",title:"Payment complete",detail:"Your payment was successful."};case "expired":return {kind:"failure",title:"Payment timed out",detail:"The time to complete this payment has ended. Return to the merchant and 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:"Checkout unavailable",detail:"This checkout link is no longer valid. Please ask the merchant for a new one."};default:return {kind:"failure",title:"Something went wrong",detail:"Please try again or contact the merchant."}}}function Me(n){let e=Math.max(0,Math.ceil(n/1e3)),t=Math.floor(e/60),i=e%60;if(t>=60){let r=Math.floor(t/60),a=t%60;return a>0?`${r}h ${a}m`:`${r}h`}return t>0?`${t}m ${i.toString().padStart(2,"0")}s`:`${i}s`}function Se(n){let e=Math.max(0,Math.ceil(n/1e3)),t=Math.floor(e/60),i=e%60;if(t>=60){let r=Math.floor(t/60),a=t%60,o=[`${r} hour${r===1?"":"s"}`];return a>0&&o.push(`${a} minute${a===1?"":"s"}`),o.join(" ")}return t>0?i>0?`${t} minute${t===1?"":"s"} ${i} second${i===1?"":"s"}`:`${t} minute${t===1?"":"s"}`:`${i} second${i===1?"":"s"}`}function ot(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 at(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 st(n){return n.replace(/\/+$/,"")}function Te(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,o]of Object.entries(e))o!=null&&o!==""&&r.searchParams.set(a,o);return t?r.toString():`${r.pathname}${r.search}${r.hash}`}var G=class{constructor(e){this.baseUrl=st(e.baseUrl),this.sessionId=e.sessionId,this.clientToken=e.clientToken;}async getSession(){return this.request("GET",this.sessionPath())}async bindCheckoutPolicy(e){return this.request("POST",`${this.sessionPath()}/checkout/bind-policy`,e)}async verifyPayer(e){return this.request("POST",`${this.sessionPath()}/payer/verify`,{query:$(e)})}async attachPayer(e){return this.request("POST",`${this.sessionPath()}/payer`,{paymentId:V(e)})}async startCheckout(e,t){let i={method:e,surface:t};return this.request("POST",`${this.sessionPath()}/checkout/start`,i)}startQrCheckout(e){return this.startCheckout("QR",e)}startMobileAppCheckout(e){return this.startCheckout("MOBILE_APP",e)}startManualCheckout(e){return this.startCheckout("MANUAL",e)}sessionPath(){return `${we}/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 I({...i,status:i.status??e.status})}return new I({status:e.status,code:"unknown",title:"Request failed",detail:e.statusText||"Request failed"})}};async function Le(n,e){try{return await n.attachPayer(e)}catch(t){if(!(t instanceof I)||t.code!=="payment-session.payer-attached")throw t;let i=await n.getSession();if(i.payer?.paymentId===V(e))return i;throw t}}var pt={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"},Ut={background:"#0f172a",surface:"#1e293b",text:"#f8fafc",textMuted:"#94a3b8",border:"#334155"};function lt(n){let e={...pt,...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,...Ut,mode:i}:{...e,mode:i}}function Ie(n,e){let t=lt(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 Dt="@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');",ct=`
2
- ${Dt}
1
+ 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var Y=["COMPLETED","EXPIRED","CANCELLED","FAILED"],xe=["CREATED","AWAITING_PAYMENT"],I=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 le={production:"https://api.zippypay.io",staging:"https://staging.api.zippypay.io",development:""},we="/api/v1";function Je(n){return n in le}function Pe(n){return le[n].replace(/\/+$/,"")}function j(n){let e=n.trim().toLowerCase();if(!Je(e))throw new Error(`Zippy Pay: invalid environment "${n}". Expected one of: ${Object.keys(le).join(", ")}.`);return e}var ke=/^(?=.{3,20}$)[a-z0-9]+(?:\.[a-z0-9]+)?$/,et=/^\+[1-9]\d{7,14}$/,tt=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function V(n){return n.trim().toLowerCase()}function $(n){let e=n.trim();return e.includes("@")?e.toLowerCase():e.startsWith("+")?e:e.toLowerCase()}function Rt(n){return ke.test(V(n))}function ze(n){let e=n.trim();return e.length<3||e.length>100||/\s/.test(e)||/[\x00-\x1f\x7f]/.test(e)?false:e.includes("@")?tt.test(e):e.startsWith("+")?et.test(e):ke.test(e.toLowerCase())}function Ht(){return "Enter 3\u201320 lowercase letters or digits, with at most one dot (e.g. john.doe12)."}function Ee(){return "Enter a Zippy ID, email, or phone number in E.164 format (e.g. +15551234567)."}function it(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 Ut={USD:"en-US"};function Ce(n,e){let t=Number.parseFloat(n);if(Number.isNaN(t))return `${n} ${e}`;let i=Ut[e]??"en-US";return new Intl.NumberFormat(i,{style:"currency",currency:e,minimumFractionDigits:2,maximumFractionDigits:2}).format(t)}var Ae=7;function nt(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 rt(n){switch(n){case "success":return {kind:"success",title:"Payment complete",detail:"Your payment was successful."};case "expired":return {kind:"failure",title:"Payment timed out",detail:"The time to complete this payment has ended. Return to the merchant and 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:"Checkout unavailable",detail:"This checkout link is no longer valid. Please ask the merchant for a new one."};default:return {kind:"failure",title:"Something went wrong",detail:"Please try again or contact the merchant."}}}function Me(n){let e=Math.max(0,Math.ceil(n/1e3)),t=Math.floor(e/60),i=e%60;if(t>=60){let r=Math.floor(t/60),a=t%60;return a>0?`${r}h ${a}m`:`${r}h`}return t>0?`${t}m ${i.toString().padStart(2,"0")}s`:`${i}s`}function Se(n){let e=Math.max(0,Math.ceil(n/1e3)),t=Math.floor(e/60),i=e%60;if(t>=60){let r=Math.floor(t/60),a=t%60,o=[`${r} hour${r===1?"":"s"}`];return a>0&&o.push(`${a} minute${a===1?"":"s"}`),o.join(" ")}return t>0?i>0?`${t} minute${t===1?"":"s"} ${i} second${i===1?"":"s"}`:`${t} minute${t===1?"":"s"}`:`${i} second${i===1?"":"s"}`}function ot(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 at(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 st(n){return n.replace(/\/+$/,"")}function Te(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,o]of Object.entries(e))o!=null&&o!==""&&r.searchParams.set(a,o);return t?r.toString():`${r.pathname}${r.search}${r.hash}`}var G=class{constructor(e){this.baseUrl=st(e.baseUrl),this.sessionId=e.sessionId,this.clientToken=e.clientToken;}async getSession(){return this.request("GET",this.sessionPath())}async bindCheckoutPolicy(e){return this.request("POST",`${this.sessionPath()}/checkout/bind-policy`,e)}async verifyPayer(e){return this.request("POST",`${this.sessionPath()}/payer/verify`,{query:$(e)})}async attachPayer(e){return this.request("POST",`${this.sessionPath()}/payer`,{paymentId:V(e)})}async startCheckout(e,t){let i={method:e,surface:t};return this.request("POST",`${this.sessionPath()}/checkout/start`,i)}startQrCheckout(e){return this.startCheckout("QR",e)}startMobileAppCheckout(e){return this.startCheckout("MOBILE_APP",e)}startManualCheckout(e){return this.startCheckout("MANUAL",e)}sessionPath(){return `${we}/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 I({...i,status:i.status??e.status})}return new I({status:e.status,code:"unknown",title:"Request failed",detail:e.statusText||"Request failed"})}};async function Le(n,e){try{return await n.attachPayer(e)}catch(t){if(!(t instanceof I)||t.code!=="payment-session.payer-attached")throw t;let i=await n.getSession();if(i.payer?.paymentId===V(e))return i;throw t}}var pt={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"},Dt={background:"#0f172a",surface:"#1e293b",text:"#f8fafc",textMuted:"#94a3b8",border:"#334155"};function lt(n){let e={...pt,...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,...Dt,mode:i}:{...e,mode:i}}function Ie(n,e){let t=lt(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 Ft="@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');",ct=`
2
+ ${Ft}
3
3
 
4
4
  :host {
5
5
  display: block;
@@ -1730,9 +1730,9 @@ input {
1730
1730
  transform: translateY(0) scale(1);
1731
1731
  }
1732
1732
  }
1733
- `;function ut(n){if((n.mode??"inline")==="modal")return Ft(n);if(!n.container)throw new Error('Zippy Pay: `container` is required when mode is "inline".');let t=at(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 Ft(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=dt,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",s=>{s.target===e&&n.onClose?.();});let o={host:r,overlay:e,escapeHandler:null,destroy:()=>{o.escapeHandler&&document.removeEventListener("keydown",o.escapeHandler),e.remove(),document.body.style.overflow="";}};return o}function ht(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 mt(n){n.overlay&&(n.overlay.style.display="none",document.body.style.overflow="",n.escapeHandler&&(document.removeEventListener("keydown",n.escapeHandler),n.escapeHandler=null));}var K=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):xe.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.scheduleNext();}}};function ce(n){return Y.includes(n)}function Zt(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"}}function yt(n){return n.phase==="PAYING"&&n.paymentExpiryAt?n.paymentExpiryAt:null}var qt=["qr-active","mobile-app-active","awaiting","manual-confirm"],$t=["loading","choose-method","manual-entry","manual-picker","success","expired","cancelled","declined","failed","invalid-session","error"];function Ne(n,e){return !n?.paymentExpiryAt||$t.includes(e)||Y.includes(n.status)||_(n.paymentExpiryAt)<=0?false:yt(n)?true:qt.includes(e)}function X(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,_(e)/r))}function Qt(n){return n.phase==="IDLE"&&n.expiresAt?n.expiresAt:null}function _(n){return Math.max(0,new Date(n).getTime()-Date.now())}function Wt(){return B()==="phone"}function ft(){if(typeof navigator>"u")return "android";let n=navigator.userAgent??"";return /iPad|iPhone|iPod/.test(n)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1?"ios":"android"}function Be(){return typeof navigator>"u"?false:/Android/i.test(navigator.userAgent??"")}function B(){if(typeof window>"u")return "desktop";let n=window.matchMedia("(max-width: 520px)").matches,e=window.matchMedia("(pointer: coarse)").matches;return n&&e?"phone":"desktop"}function Oe(n){if(typeof window>"u")return ()=>{};let e=[window.matchMedia("(max-width: 520px)"),window.matchMedia("(pointer: coarse)")],t=()=>{n(B());};for(let i of e)i.addEventListener("change",t);return window.addEventListener("orientationchange",t),window.addEventListener("resize",t),()=>{for(let i of e)i.removeEventListener("change",t);window.removeEventListener("orientationchange",t),window.removeEventListener("resize",t);}}function q(n){return n.checkoutPolicy!=null||n.mobileAppPolicy!=null}function Yt(n){return n==null}function de(n){return n==null||n==="QR"}function _e(n){return n==null||n==="MANUAL"}function ue(n,e){return e==="ENFORCE"&&(n==null||n==="QR"||n==="MANUAL")}function gt(n){return n?.policy==="enforce"?"ENFORCE":n?.policy==="option"?"OPTION":"OFF"}function he(n){let e={};(n.checkoutPolicy==="QR"||n.checkoutPolicy==="MANUAL")&&(e.checkoutPolicy=n.checkoutPolicy);let t=gt(n.mobileApp);return t!=="OFF"&&(e.mobileAppPolicy=t),e}function bt(n){return {qr:de(n),manual:_e(n)}}function vt(n,e,t){if(t==="desktop")return {qr:de(n),manual:_e(n),mobileApp:false};let i=ue(n,e);return {qr:de(n)&&!i,manual:_e(n)&&!i,mobileApp:i||e==="OPTION"&&(n==null||n==="QR"||n==="MANUAL")}}function ee(n,e,t){return t==="desktop"?n==="MANUAL"?"auto-manual":n==="QR"?"auto-qr":"chooser":ue(n,e)?"enforce-mobile-app":n==="MANUAL"&&e==="OFF"?"auto-manual":n==="QR"&&e==="OFF"?"auto-qr":"chooser"}function J(n,e,t,i){return i==="MOBILE_APP"?t==="desktop"||e==="OFF"?false:ue(n,e)?true:e==="OPTION"?n==null||n==="QR"||n==="MANUAL":false:!(!de(n)||t==="phone"&&ue(n,e))}function Re(n,e,t){let i=ee(n,e,t);return i==="enforce-mobile-app"?J(n,e,t,"MOBILE_APP")?"MOBILE_APP":null:i==="auto-qr"&&J(n,e,t,"QR")?"QR":null}function te(n,e,t=B()){return {checkoutPolicy:n,mobileAppPolicy:e,surface:t,methodAvailability:vt(n,e,t),allowManualBack:n==null}}function He(n,e=B()){if(!q(n))throw new Error("Checkout policy is not bound on the payment session.");return te(n.checkoutPolicy,n.mobileAppPolicy??"OFF",e)}function Ue(n,e,t=B()){let i=he({checkoutPolicy:n,mobileApp:e});return te(i.checkoutPolicy??null,i.mobileAppPolicy??"OFF",t)}var ie="com.zippy.pay",ne={ios:"https://apps.apple.com/",android:`https://play.google.com/store/apps/details?id=${ie}`},xt="itms-apps://apps.apple.com/",wt=`market://details?id=${ie}`;function jt(n){return ne[n]}function De(n){return n==="ios"?xt:wt}function Fe(n="zippy-app-link-icon"){return `<svg class="${n}" viewBox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path d="M16.823 12.345c-.027-2.702 2.208-3.997 2.307-4.059-1.255-1.836-3.211-2.088-3.905-2.118-1.663-.169-3.246.98-4.089.98-.844 0-2.147-.955-3.531-.929-1.818.027-3.493 1.056-4.429 2.683-1.888 3.276-.483 8.131 1.356 10.791.899 1.299 1.968 2.759 3.374 2.707 1.355-.054 1.866-.877 3.504-.877 1.637 0 2.099.877 3.527.85 1.457-.027 2.381-1.32 3.276-2.622.99-1.449 1.396-2.851 1.419-2.922-.031-.014-2.724-1.045-2.751-4.146zM14.303 4.772c.747-.907 1.249-2.164 1.111-3.422-1.075.043-2.375.717-3.147 1.623-.693.802-1.299 2.095-1.136 3.333 1.201.093 2.432-.61 3.172-1.534z"/></svg>`}function Ze(n="zippy-app-link-icon"){return `<svg class="${n} zippy-app-link-icon--play" viewBox="0 0 256 283" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path fill="#EA4335" d="M119.553 134.916 1.06 259.061c2.696 9.556 9.658 17.33 18.861 21.059 9.202 3.73 19.612 2.996 28.201-1.987l133.327-75.935-61.896-67.282z"/><path fill="#FBBC04" d="M239.371 113.814 181.714 80.791 116.816 137.742l65.162 64.279 57.216-32.669c10.332-5.409 16.806-16.107 16.806-27.769 0-11.662-6.474-22.36-16.806-27.769h.177z"/><path fill="#4285F4" d="M1.06 23.487C.344 26.135-.013 28.867 0 31.61v219.327c.008 2.742.364 5.472 1.06 8.124L123.615 138.095 1.06 23.487z"/><path fill="#34A853" d="M120.436 141.274 181.714 80.791 48.563 4.503C43.554 1.569 37.857.016 32.052 0 17.644-.028 4.978 9.534 1.06 23.399l119.376 117.875z"/></svg>`}function Pt(){return Fe("zippy-app-link-icon")}function kt(){return Ze("zippy-app-link-icon")}var Q=function(n,e){let r=n,a=re[e],o=null,s=0,p=null,d=[],g={},f=function(c,y){s=r*4+17,o=(function(l){let h=new Array(l);for(let u=0;u<l;u+=1){h[u]=new Array(l);for(let b=0;b<l;b+=1)h[u][b]=null;}return h})(s),m(0,0),m(s-7,0),m(0,s-7),P(),S(),N(c,y),r>=7&&z(c),p==null&&(p=W(r,a,d)),T(p,y);},m=function(c,y){for(let l=-1;l<=7;l+=1)if(!(c+l<=-1||s<=c+l))for(let h=-1;h<=7;h+=1)y+h<=-1||s<=y+h||(0<=l&&l<=6&&(h==0||h==6)||0<=h&&h<=6&&(l==0||l==6)||2<=l&&l<=4&&2<=h&&h<=4?o[c+l][y+h]=true:o[c+l][y+h]=false);},w=function(){let c=0,y=0;for(let l=0;l<8;l+=1){f(true,l);let h=U.getLostPoint(g);(l==0||c>h)&&(c=h,y=l);}return y},S=function(){for(let c=8;c<s-8;c+=1)o[c][6]==null&&(o[c][6]=c%2==0);for(let c=8;c<s-8;c+=1)o[6][c]==null&&(o[6][c]=c%2==0);},P=function(){let c=U.getPatternPosition(r);for(let y=0;y<c.length;y+=1)for(let l=0;l<c.length;l+=1){let h=c[y],u=c[l];if(o[h][u]==null)for(let b=-2;b<=2;b+=1)for(let v=-2;v<=2;v+=1)b==-2||b==2||v==-2||v==2||b==0&&v==0?o[h+b][u+v]=true:o[h+b][u+v]=false;}},z=function(c){let y=U.getBCHTypeNumber(r);for(let l=0;l<18;l+=1){let h=!c&&(y>>l&1)==1;o[Math.floor(l/3)][l%3+s-8-3]=h;}for(let l=0;l<18;l+=1){let h=!c&&(y>>l&1)==1;o[l%3+s-8-3][Math.floor(l/3)]=h;}},N=function(c,y){let l=a<<3|y,h=U.getBCHTypeInfo(l);for(let u=0;u<15;u+=1){let b=!c&&(h>>u&1)==1;u<6?o[u][8]=b:u<8?o[u+1][8]=b:o[s-15+u][8]=b;}for(let u=0;u<15;u+=1){let b=!c&&(h>>u&1)==1;u<8?o[8][s-u-1]=b:u<9?o[8][15-u-1+1]=b:o[8][15-u-1]=b;}o[s-8][8]=!c;},T=function(c,y){let l=-1,h=s-1,u=7,b=0,v=U.getMaskFunction(y);for(let k=s-1;k>0;k-=2)for(k==6&&(k-=1);;){for(let E=0;E<2;E+=1)if(o[h][k-E]==null){let A=false;b<c.length&&(A=(c[b]>>>u&1)==1),v(h,k-E)&&(A=!A),o[h][k-E]=A,u-=1,u==-1&&(b+=1,u=7);}if(h+=l,h<0||s<=h){h-=l,l=-l;break}}},M=function(c,y){let l=0,h=0,u=0,b=new Array(y.length),v=new Array(y.length);for(let x=0;x<y.length;x+=1){let C=y[x].dataCount,O=y[x].totalCount-C;h=Math.max(h,C),u=Math.max(u,O),b[x]=new Array(C);for(let R=0;R<b[x].length;R+=1)b[x][R]=255&c.getBuffer()[R+l];l+=C;let ve=U.getErrorCorrectPolynomial(O),Ke=oe(b[x],ve.getLength()-1).mod(ve);v[x]=new Array(ve.getLength()-1);for(let R=0;R<v[x].length;R+=1){let Xe=R+Ke.getLength()-v[x].length;v[x][R]=Xe>=0?Ke.getAt(Xe):0;}}let k=0;for(let x=0;x<y.length;x+=1)k+=y[x].totalCount;let E=new Array(k),A=0;for(let x=0;x<h;x+=1)for(let C=0;C<y.length;C+=1)x<b[C].length&&(E[A]=b[C][x],A+=1);for(let x=0;x<u;x+=1)for(let C=0;C<y.length;C+=1)x<v[C].length&&(E[A]=v[C][x],A+=1);return E},W=function(c,y,l){let h=zt.getRSBlocks(c,y),u=Et();for(let v=0;v<l.length;v+=1){let k=l[v];u.put(k.getMode(),4),u.put(k.getLength(),U.getLengthInBits(k.getMode(),c)),k.write(u);}let b=0;for(let v=0;v<h.length;v+=1)b+=h[v].dataCount;if(u.getLengthInBits()>b*8)throw "code length overflow. ("+u.getLengthInBits()+">"+b*8+")";for(u.getLengthInBits()+4<=b*8&&u.put(0,4);u.getLengthInBits()%8!=0;)u.putBit(false);for(;!(u.getLengthInBits()>=b*8||(u.put(236,8),u.getLengthInBits()>=b*8));)u.put(17,8);return M(u,h)};g.addData=function(c,y){y=y||"Byte";let l=null;switch(y){case "Numeric":l=Vt(c);break;case "Alphanumeric":l=Gt(c);break;case "Byte":l=Kt(c);break;case "Kanji":l=Xt(c);break;default:throw "mode:"+y}d.push(l),p=null;},g.isDark=function(c,y){if(c<0||s<=c||y<0||s<=y)throw c+","+y;return o[c][y]},g.getModuleCount=function(){return s},g.make=function(){if(r<1){let c=1;for(;c<40;c++){let y=zt.getRSBlocks(c,a),l=Et();for(let u=0;u<d.length;u++){let b=d[u];l.put(b.getMode(),4),l.put(b.getLength(),U.getLengthInBits(b.getMode(),c)),b.write(l);}let h=0;for(let u=0;u<y.length;u++)h+=y[u].dataCount;if(l.getLengthInBits()<=h*8)break}r=c;}f(false,w());},g.createTableTag=function(c,y){c=c||2,y=typeof y>"u"?c*4:y;let l="";l+='<table style="',l+=" border-width: 0px; border-style: none;",l+=" border-collapse: collapse;",l+=" padding: 0px; margin: "+y+"px;",l+='">',l+="<tbody>";for(let h=0;h<g.getModuleCount();h+=1){l+="<tr>";for(let u=0;u<g.getModuleCount();u+=1)l+='<td style="',l+=" border-width: 0px; border-style: none;",l+=" border-collapse: collapse;",l+=" padding: 0px; margin: 0px;",l+=" width: "+c+"px;",l+=" height: "+c+"px;",l+=" background-color: ",l+=g.isDark(h,u)?"#000000":"#ffffff",l+=";",l+='"/>';l+="</tr>";}return l+="</tbody>",l+="</table>",l},g.createSvgTag=function(c,y,l,h){let u={};typeof arguments[0]=="object"&&(u=arguments[0],c=u.cellSize,y=u.margin,l=u.alt,h=u.title),c=c||2,y=typeof y>"u"?c*4:y,l=typeof l=="string"?{text:l}:l||{},l.text=l.text||null,l.id=l.text?l.id||"qrcode-description":null,h=typeof h=="string"?{text:h}:h||{},h.text=h.text||null,h.id=h.text?h.id||"qrcode-title":null;let b=g.getModuleCount()*c+y*2,v,k,E,A,x="",C;for(C="l"+c+",0 0,"+c+" -"+c+",0 0,-"+c+"z ",x+='<svg version="1.1" xmlns="http://www.w3.org/2000/svg"',x+=u.scalable?"":' width="'+b+'px" height="'+b+'px"',x+=' viewBox="0 0 '+b+" "+b+'" ',x+=' preserveAspectRatio="xMinYMin meet"',x+=h.text||l.text?' role="img" aria-labelledby="'+F([h.id,l.id].join(" ").trim())+'"':"",x+=">",x+=h.text?'<title id="'+F(h.id)+'">'+F(h.text)+"</title>":"",x+=l.text?'<description id="'+F(l.id)+'">'+F(l.text)+"</description>":"",x+='<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>',x+='<path d="',E=0;E<g.getModuleCount();E+=1)for(A=E*c+y,v=0;v<g.getModuleCount();v+=1)g.isDark(E,v)&&(k=v*c+y,x+="M"+k+","+A+C);return x+='" stroke="transparent" fill="black"/>',x+="</svg>",x},g.createDataURL=function(c,y){c=c||2,y=typeof y>"u"?c*4:y;let l=g.getModuleCount()*c+y*2,h=y,u=l-y;return ii(l,l,function(b,v){if(h<=b&&b<u&&h<=v&&v<u){let k=Math.floor((b-h)/c),E=Math.floor((v-h)/c);return g.isDark(E,k)?0:1}else return 1})},g.createImgTag=function(c,y,l){c=c||2,y=typeof y>"u"?c*4:y;let h=g.getModuleCount()*c+y*2,u="";return u+="<img",u+=' src="',u+=g.createDataURL(c,y),u+='"',u+=' width="',u+=h,u+='"',u+=' height="',u+=h,u+='"',l&&(u+=' alt="',u+=F(l),u+='"'),u+="/>",u};let F=function(c){let y="";for(let l=0;l<c.length;l+=1){let h=c.charAt(l);switch(h){case "<":y+="&lt;";break;case ">":y+="&gt;";break;case "&":y+="&amp;";break;case '"':y+="&quot;";break;default:y+=h;break}}return y},Z=function(c){c=typeof c>"u"?2:c;let l=g.getModuleCount()*1+c*2,h=c,u=l-c,b,v,k,E,A,x={"\u2588\u2588":"\u2588","\u2588 ":"\u2580"," \u2588":"\u2584"," ":" "},C={"\u2588\u2588":"\u2580","\u2588 ":"\u2580"," \u2588":" "," ":" "},O="";for(b=0;b<l;b+=2){for(k=Math.floor((b-h)/1),E=Math.floor((b+1-h)/1),v=0;v<l;v+=1)A="\u2588",h<=v&&v<u&&h<=b&&b<u&&g.isDark(k,Math.floor((v-h)/1))&&(A=" "),h<=v&&v<u&&h<=b+1&&b+1<u&&g.isDark(E,Math.floor((v-h)/1))?A+=" ":A+="\u2588",O+=c<1&&b+1>=u?C[A]:x[A];O+=`
1733
+ `;function ut(n){if((n.mode??"inline")==="modal")return Zt(n);if(!n.container)throw new Error('Zippy Pay: `container` is required when mode is "inline".');let t=at(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 Zt(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=dt,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",s=>{s.target===e&&n.onClose?.();});let o={host:r,overlay:e,escapeHandler:null,destroy:()=>{o.escapeHandler&&document.removeEventListener("keydown",o.escapeHandler),e.remove(),document.body.style.overflow="";}};return o}function ht(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 mt(n){n.overlay&&(n.overlay.style.display="none",document.body.style.overflow="",n.escapeHandler&&(document.removeEventListener("keydown",n.escapeHandler),n.escapeHandler=null));}var K=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):xe.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.scheduleNext();}}};function ce(n){return Y.includes(n)}function qt(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"}}function yt(n){return n.phase==="PAYING"&&n.paymentExpiryAt?n.paymentExpiryAt:null}var $t=["qr-active","mobile-app-active","awaiting","manual-confirm"],Qt=["loading","choose-method","manual-entry","manual-picker","success","expired","cancelled","declined","failed","invalid-session","error"];function Ne(n,e){return !n?.paymentExpiryAt||Qt.includes(e)||Y.includes(n.status)||_(n.paymentExpiryAt)<=0?false:yt(n)?true:$t.includes(e)}function X(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,_(e)/r))}function Wt(n){return n.phase==="IDLE"&&n.expiresAt?n.expiresAt:null}function _(n){return Math.max(0,new Date(n).getTime()-Date.now())}function Yt(){return B()==="phone"}function ft(){if(typeof navigator>"u")return "android";let n=navigator.userAgent??"";return /iPad|iPhone|iPod/.test(n)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1?"ios":"android"}function Be(){return typeof navigator>"u"?false:/Android/i.test(navigator.userAgent??"")}function B(){if(typeof window>"u")return "desktop";let n=window.matchMedia("(max-width: 520px)").matches,e=window.matchMedia("(pointer: coarse)").matches;return n&&e?"phone":"desktop"}function Oe(n){if(typeof window>"u")return ()=>{};let e=[window.matchMedia("(max-width: 520px)"),window.matchMedia("(pointer: coarse)")],t=()=>{n(B());};for(let i of e)i.addEventListener("change",t);return window.addEventListener("orientationchange",t),window.addEventListener("resize",t),()=>{for(let i of e)i.removeEventListener("change",t);window.removeEventListener("orientationchange",t),window.removeEventListener("resize",t);}}function q(n){return n.checkoutPolicy!=null||n.mobileAppPolicy!=null}function jt(n){return n==null}function de(n){return n==null||n==="QR"}function _e(n){return n==null||n==="MANUAL"}function ue(n,e){return e==="ENFORCE"&&(n==null||n==="QR"||n==="MANUAL")}function gt(n){return n?.policy==="enforce"?"ENFORCE":n?.policy==="option"?"OPTION":"OFF"}function he(n){let e={};(n.checkoutPolicy==="QR"||n.checkoutPolicy==="MANUAL")&&(e.checkoutPolicy=n.checkoutPolicy);let t=gt(n.mobileApp);return t!=="OFF"&&(e.mobileAppPolicy=t),e}function bt(n){return {qr:de(n),manual:_e(n)}}function vt(n,e,t){if(t==="desktop")return {qr:de(n),manual:_e(n),mobileApp:false};let i=ue(n,e);return {qr:de(n)&&!i,manual:_e(n)&&!i,mobileApp:i||e==="OPTION"&&(n==null||n==="QR"||n==="MANUAL")}}function ee(n,e,t){return t==="desktop"?n==="MANUAL"?"auto-manual":n==="QR"?"auto-qr":"chooser":ue(n,e)?"enforce-mobile-app":n==="MANUAL"&&e==="OFF"?"auto-manual":n==="QR"&&e==="OFF"?"auto-qr":"chooser"}function J(n,e,t,i){return i==="MOBILE_APP"?t==="desktop"||e==="OFF"?false:ue(n,e)?true:e==="OPTION"?n==null||n==="QR"||n==="MANUAL":false:!(!de(n)||t==="phone"&&ue(n,e))}function Re(n,e,t){let i=ee(n,e,t);return i==="enforce-mobile-app"?J(n,e,t,"MOBILE_APP")?"MOBILE_APP":null:i==="auto-qr"&&J(n,e,t,"QR")?"QR":null}function te(n,e,t=B()){return {checkoutPolicy:n,mobileAppPolicy:e,surface:t,methodAvailability:vt(n,e,t),allowManualBack:n==null}}function He(n,e=B()){if(!q(n))throw new Error("Checkout policy is not bound on the payment session.");return te(n.checkoutPolicy,n.mobileAppPolicy??"OFF",e)}function Ue(n,e,t=B()){let i=he({checkoutPolicy:n,mobileApp:e});return te(i.checkoutPolicy??null,i.mobileAppPolicy??"OFF",t)}var ie="com.zippy.pay",xt="https://apps.apple.com/in/app/zippypay/id6806799311",ne={ios:xt,android:`https://play.google.com/store/apps/details?id=${ie}`},wt=`itms-apps://${xt.replace(/^https:\/\//,"")}`,Pt=`market://details?id=${ie}`;function Vt(n){return ne[n]}function De(n){return n==="ios"?wt:Pt}function Fe(n="zippy-app-link-icon"){return `<svg class="${n}" viewBox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path d="M16.823 12.345c-.027-2.702 2.208-3.997 2.307-4.059-1.255-1.836-3.211-2.088-3.905-2.118-1.663-.169-3.246.98-4.089.98-.844 0-2.147-.955-3.531-.929-1.818.027-3.493 1.056-4.429 2.683-1.888 3.276-.483 8.131 1.356 10.791.899 1.299 1.968 2.759 3.374 2.707 1.355-.054 1.866-.877 3.504-.877 1.637 0 2.099.877 3.527.85 1.457-.027 2.381-1.32 3.276-2.622.99-1.449 1.396-2.851 1.419-2.922-.031-.014-2.724-1.045-2.751-4.146zM14.303 4.772c.747-.907 1.249-2.164 1.111-3.422-1.075.043-2.375.717-3.147 1.623-.693.802-1.299 2.095-1.136 3.333 1.201.093 2.432-.61 3.172-1.534z"/></svg>`}function Ze(n="zippy-app-link-icon"){return `<svg class="${n} zippy-app-link-icon--play" viewBox="0 0 256 283" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path fill="#EA4335" d="M119.553 134.916 1.06 259.061c2.696 9.556 9.658 17.33 18.861 21.059 9.202 3.73 19.612 2.996 28.201-1.987l133.327-75.935-61.896-67.282z"/><path fill="#FBBC04" d="M239.371 113.814 181.714 80.791 116.816 137.742l65.162 64.279 57.216-32.669c10.332-5.409 16.806-16.107 16.806-27.769 0-11.662-6.474-22.36-16.806-27.769h.177z"/><path fill="#4285F4" d="M1.06 23.487C.344 26.135-.013 28.867 0 31.61v219.327c.008 2.742.364 5.472 1.06 8.124L123.615 138.095 1.06 23.487z"/><path fill="#34A853" d="M120.436 141.274 181.714 80.791 48.563 4.503C43.554 1.569 37.857.016 32.052 0 17.644-.028 4.978 9.534 1.06 23.399l119.376 117.875z"/></svg>`}function kt(){return Fe("zippy-app-link-icon")}function zt(){return Ze("zippy-app-link-icon")}var Q=function(n,e){let r=n,a=re[e],o=null,s=0,p=null,d=[],g={},f=function(c,y){s=r*4+17,o=(function(l){let h=new Array(l);for(let u=0;u<l;u+=1){h[u]=new Array(l);for(let b=0;b<l;b+=1)h[u][b]=null;}return h})(s),m(0,0),m(s-7,0),m(0,s-7),P(),S(),N(c,y),r>=7&&z(c),p==null&&(p=W(r,a,d)),T(p,y);},m=function(c,y){for(let l=-1;l<=7;l+=1)if(!(c+l<=-1||s<=c+l))for(let h=-1;h<=7;h+=1)y+h<=-1||s<=y+h||(0<=l&&l<=6&&(h==0||h==6)||0<=h&&h<=6&&(l==0||l==6)||2<=l&&l<=4&&2<=h&&h<=4?o[c+l][y+h]=true:o[c+l][y+h]=false);},w=function(){let c=0,y=0;for(let l=0;l<8;l+=1){f(true,l);let h=U.getLostPoint(g);(l==0||c>h)&&(c=h,y=l);}return y},S=function(){for(let c=8;c<s-8;c+=1)o[c][6]==null&&(o[c][6]=c%2==0);for(let c=8;c<s-8;c+=1)o[6][c]==null&&(o[6][c]=c%2==0);},P=function(){let c=U.getPatternPosition(r);for(let y=0;y<c.length;y+=1)for(let l=0;l<c.length;l+=1){let h=c[y],u=c[l];if(o[h][u]==null)for(let b=-2;b<=2;b+=1)for(let v=-2;v<=2;v+=1)b==-2||b==2||v==-2||v==2||b==0&&v==0?o[h+b][u+v]=true:o[h+b][u+v]=false;}},z=function(c){let y=U.getBCHTypeNumber(r);for(let l=0;l<18;l+=1){let h=!c&&(y>>l&1)==1;o[Math.floor(l/3)][l%3+s-8-3]=h;}for(let l=0;l<18;l+=1){let h=!c&&(y>>l&1)==1;o[l%3+s-8-3][Math.floor(l/3)]=h;}},N=function(c,y){let l=a<<3|y,h=U.getBCHTypeInfo(l);for(let u=0;u<15;u+=1){let b=!c&&(h>>u&1)==1;u<6?o[u][8]=b:u<8?o[u+1][8]=b:o[s-15+u][8]=b;}for(let u=0;u<15;u+=1){let b=!c&&(h>>u&1)==1;u<8?o[8][s-u-1]=b:u<9?o[8][15-u-1+1]=b:o[8][15-u-1]=b;}o[s-8][8]=!c;},T=function(c,y){let l=-1,h=s-1,u=7,b=0,v=U.getMaskFunction(y);for(let k=s-1;k>0;k-=2)for(k==6&&(k-=1);;){for(let E=0;E<2;E+=1)if(o[h][k-E]==null){let A=false;b<c.length&&(A=(c[b]>>>u&1)==1),v(h,k-E)&&(A=!A),o[h][k-E]=A,u-=1,u==-1&&(b+=1,u=7);}if(h+=l,h<0||s<=h){h-=l,l=-l;break}}},M=function(c,y){let l=0,h=0,u=0,b=new Array(y.length),v=new Array(y.length);for(let x=0;x<y.length;x+=1){let C=y[x].dataCount,O=y[x].totalCount-C;h=Math.max(h,C),u=Math.max(u,O),b[x]=new Array(C);for(let R=0;R<b[x].length;R+=1)b[x][R]=255&c.getBuffer()[R+l];l+=C;let ve=U.getErrorCorrectPolynomial(O),Ke=oe(b[x],ve.getLength()-1).mod(ve);v[x]=new Array(ve.getLength()-1);for(let R=0;R<v[x].length;R+=1){let Xe=R+Ke.getLength()-v[x].length;v[x][R]=Xe>=0?Ke.getAt(Xe):0;}}let k=0;for(let x=0;x<y.length;x+=1)k+=y[x].totalCount;let E=new Array(k),A=0;for(let x=0;x<h;x+=1)for(let C=0;C<y.length;C+=1)x<b[C].length&&(E[A]=b[C][x],A+=1);for(let x=0;x<u;x+=1)for(let C=0;C<y.length;C+=1)x<v[C].length&&(E[A]=v[C][x],A+=1);return E},W=function(c,y,l){let h=Et.getRSBlocks(c,y),u=Ct();for(let v=0;v<l.length;v+=1){let k=l[v];u.put(k.getMode(),4),u.put(k.getLength(),U.getLengthInBits(k.getMode(),c)),k.write(u);}let b=0;for(let v=0;v<h.length;v+=1)b+=h[v].dataCount;if(u.getLengthInBits()>b*8)throw "code length overflow. ("+u.getLengthInBits()+">"+b*8+")";for(u.getLengthInBits()+4<=b*8&&u.put(0,4);u.getLengthInBits()%8!=0;)u.putBit(false);for(;!(u.getLengthInBits()>=b*8||(u.put(236,8),u.getLengthInBits()>=b*8));)u.put(17,8);return M(u,h)};g.addData=function(c,y){y=y||"Byte";let l=null;switch(y){case "Numeric":l=Gt(c);break;case "Alphanumeric":l=Kt(c);break;case "Byte":l=Xt(c);break;case "Kanji":l=Jt(c);break;default:throw "mode:"+y}d.push(l),p=null;},g.isDark=function(c,y){if(c<0||s<=c||y<0||s<=y)throw c+","+y;return o[c][y]},g.getModuleCount=function(){return s},g.make=function(){if(r<1){let c=1;for(;c<40;c++){let y=Et.getRSBlocks(c,a),l=Ct();for(let u=0;u<d.length;u++){let b=d[u];l.put(b.getMode(),4),l.put(b.getLength(),U.getLengthInBits(b.getMode(),c)),b.write(l);}let h=0;for(let u=0;u<y.length;u++)h+=y[u].dataCount;if(l.getLengthInBits()<=h*8)break}r=c;}f(false,w());},g.createTableTag=function(c,y){c=c||2,y=typeof y>"u"?c*4:y;let l="";l+='<table style="',l+=" border-width: 0px; border-style: none;",l+=" border-collapse: collapse;",l+=" padding: 0px; margin: "+y+"px;",l+='">',l+="<tbody>";for(let h=0;h<g.getModuleCount();h+=1){l+="<tr>";for(let u=0;u<g.getModuleCount();u+=1)l+='<td style="',l+=" border-width: 0px; border-style: none;",l+=" border-collapse: collapse;",l+=" padding: 0px; margin: 0px;",l+=" width: "+c+"px;",l+=" height: "+c+"px;",l+=" background-color: ",l+=g.isDark(h,u)?"#000000":"#ffffff",l+=";",l+='"/>';l+="</tr>";}return l+="</tbody>",l+="</table>",l},g.createSvgTag=function(c,y,l,h){let u={};typeof arguments[0]=="object"&&(u=arguments[0],c=u.cellSize,y=u.margin,l=u.alt,h=u.title),c=c||2,y=typeof y>"u"?c*4:y,l=typeof l=="string"?{text:l}:l||{},l.text=l.text||null,l.id=l.text?l.id||"qrcode-description":null,h=typeof h=="string"?{text:h}:h||{},h.text=h.text||null,h.id=h.text?h.id||"qrcode-title":null;let b=g.getModuleCount()*c+y*2,v,k,E,A,x="",C;for(C="l"+c+",0 0,"+c+" -"+c+",0 0,-"+c+"z ",x+='<svg version="1.1" xmlns="http://www.w3.org/2000/svg"',x+=u.scalable?"":' width="'+b+'px" height="'+b+'px"',x+=' viewBox="0 0 '+b+" "+b+'" ',x+=' preserveAspectRatio="xMinYMin meet"',x+=h.text||l.text?' role="img" aria-labelledby="'+F([h.id,l.id].join(" ").trim())+'"':"",x+=">",x+=h.text?'<title id="'+F(h.id)+'">'+F(h.text)+"</title>":"",x+=l.text?'<description id="'+F(l.id)+'">'+F(l.text)+"</description>":"",x+='<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>',x+='<path d="',E=0;E<g.getModuleCount();E+=1)for(A=E*c+y,v=0;v<g.getModuleCount();v+=1)g.isDark(E,v)&&(k=v*c+y,x+="M"+k+","+A+C);return x+='" stroke="transparent" fill="black"/>',x+="</svg>",x},g.createDataURL=function(c,y){c=c||2,y=typeof y>"u"?c*4:y;let l=g.getModuleCount()*c+y*2,h=y,u=l-y;return ni(l,l,function(b,v){if(h<=b&&b<u&&h<=v&&v<u){let k=Math.floor((b-h)/c),E=Math.floor((v-h)/c);return g.isDark(E,k)?0:1}else return 1})},g.createImgTag=function(c,y,l){c=c||2,y=typeof y>"u"?c*4:y;let h=g.getModuleCount()*c+y*2,u="";return u+="<img",u+=' src="',u+=g.createDataURL(c,y),u+='"',u+=' width="',u+=h,u+='"',u+=' height="',u+=h,u+='"',l&&(u+=' alt="',u+=F(l),u+='"'),u+="/>",u};let F=function(c){let y="";for(let l=0;l<c.length;l+=1){let h=c.charAt(l);switch(h){case "<":y+="&lt;";break;case ">":y+="&gt;";break;case "&":y+="&amp;";break;case '"':y+="&quot;";break;default:y+=h;break}}return y},Z=function(c){c=typeof c>"u"?2:c;let l=g.getModuleCount()*1+c*2,h=c,u=l-c,b,v,k,E,A,x={"\u2588\u2588":"\u2588","\u2588 ":"\u2580"," \u2588":"\u2584"," ":" "},C={"\u2588\u2588":"\u2580","\u2588 ":"\u2580"," \u2588":" "," ":" "},O="";for(b=0;b<l;b+=2){for(k=Math.floor((b-h)/1),E=Math.floor((b+1-h)/1),v=0;v<l;v+=1)A="\u2588",h<=v&&v<u&&h<=b&&b<u&&g.isDark(k,Math.floor((v-h)/1))&&(A=" "),h<=v&&v<u&&h<=b+1&&b+1<u&&g.isDark(E,Math.floor((v-h)/1))?A+=" ":A+="\u2588",O+=c<1&&b+1>=u?C[A]:x[A];O+=`
1734
1734
  `;}return l%2&&c>0?O.substring(0,O.length-l-1)+Array(l+1).join("\u2580"):O.substring(0,O.length-1)};return g.createASCII=function(c,y){if(c=c||1,c<2)return Z(y);c-=1,y=typeof y>"u"?c*2:y;let l=g.getModuleCount()*c+y*2,h=y,u=l-y,b,v,k,E,A=Array(c+1).join("\u2588\u2588"),x=Array(c+1).join(" "),C="",O="";for(b=0;b<l;b+=1){for(k=Math.floor((b-h)/c),O="",v=0;v<l;v+=1)E=1,h<=v&&v<u&&h<=b&&b<u&&g.isDark(k,Math.floor((v-h)/c))&&(E=0),O+=E?A:x;for(k=0;k<c;k+=1)C+=O+`
1735
- `;}return C.substring(0,C.length-1)},g.renderTo2dContext=function(c,y){y=y||2;let l=g.getModuleCount();for(let h=0;h<l;h++)for(let u=0;u<l;u++)c.fillStyle=g.isDark(h,u)?"black":"white",c.fillRect(u*y,h*y,y,y);},g};Q.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};Q.createStringToBytes=function(n,e){let t=(function(){let r=ei(n),a=function(){let p=r.read();if(p==-1)throw "eof";return p},o=0,s={};for(;;){let p=r.read();if(p==-1)break;let d=a(),g=a(),f=a(),m=String.fromCharCode(p<<8|d),w=g<<8|f;s[m]=w,o+=1;}if(o!=e)throw o+" != "+e;return s})(),i=63;return function(r){let a=[];for(let o=0;o<r.length;o+=1){let s=r.charCodeAt(o);if(s<128)a.push(s);else {let p=t[r.charAt(o)];typeof p=="number"?(p&255)==p?a.push(p):(a.push(p>>>8),a.push(p&255)):a.push(i);}}return a}};var L={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},re={L:1,M:0,Q:3,H:2},H={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},U=(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(o){let s=0;for(;o!=0;)s+=1,o>>>=1;return s};return r.getBCHTypeInfo=function(o){let s=o<<10;for(;a(s)-a(e)>=0;)s^=e<<a(s)-a(e);return (o<<10|s)^i},r.getBCHTypeNumber=function(o){let s=o<<12;for(;a(s)-a(t)>=0;)s^=t<<a(s)-a(t);return o<<12|s},r.getPatternPosition=function(o){return n[o-1]},r.getMaskFunction=function(o){switch(o){case H.PATTERN000:return function(s,p){return (s+p)%2==0};case H.PATTERN001:return function(s,p){return s%2==0};case H.PATTERN010:return function(s,p){return p%3==0};case H.PATTERN011:return function(s,p){return (s+p)%3==0};case H.PATTERN100:return function(s,p){return (Math.floor(s/2)+Math.floor(p/3))%2==0};case H.PATTERN101:return function(s,p){return s*p%2+s*p%3==0};case H.PATTERN110:return function(s,p){return (s*p%2+s*p%3)%2==0};case H.PATTERN111:return function(s,p){return (s*p%3+(s+p)%2)%2==0};default:throw "bad maskPattern:"+o}},r.getErrorCorrectPolynomial=function(o){let s=oe([1],0);for(let p=0;p<o;p+=1)s=s.multiply(oe([1,D.gexp(p)],0));return s},r.getLengthInBits=function(o,s){if(1<=s&&s<10)switch(o){case L.MODE_NUMBER:return 10;case L.MODE_ALPHA_NUM:return 9;case L.MODE_8BIT_BYTE:return 8;case L.MODE_KANJI:return 8;default:throw "mode:"+o}else if(s<27)switch(o){case L.MODE_NUMBER:return 12;case L.MODE_ALPHA_NUM:return 11;case L.MODE_8BIT_BYTE:return 16;case L.MODE_KANJI:return 10;default:throw "mode:"+o}else if(s<41)switch(o){case L.MODE_NUMBER:return 14;case L.MODE_ALPHA_NUM:return 13;case L.MODE_8BIT_BYTE:return 16;case L.MODE_KANJI:return 12;default:throw "mode:"+o}else throw "type:"+s},r.getLostPoint=function(o){let s=o.getModuleCount(),p=0;for(let f=0;f<s;f+=1)for(let m=0;m<s;m+=1){let w=0,S=o.isDark(f,m);for(let P=-1;P<=1;P+=1)if(!(f+P<0||s<=f+P))for(let z=-1;z<=1;z+=1)m+z<0||s<=m+z||P==0&&z==0||S==o.isDark(f+P,m+z)&&(w+=1);w>5&&(p+=3+w-5);}for(let f=0;f<s-1;f+=1)for(let m=0;m<s-1;m+=1){let w=0;o.isDark(f,m)&&(w+=1),o.isDark(f+1,m)&&(w+=1),o.isDark(f,m+1)&&(w+=1),o.isDark(f+1,m+1)&&(w+=1),(w==0||w==4)&&(p+=3);}for(let f=0;f<s;f+=1)for(let m=0;m<s-6;m+=1)o.isDark(f,m)&&!o.isDark(f,m+1)&&o.isDark(f,m+2)&&o.isDark(f,m+3)&&o.isDark(f,m+4)&&!o.isDark(f,m+5)&&o.isDark(f,m+6)&&(p+=40);for(let f=0;f<s;f+=1)for(let m=0;m<s-6;m+=1)o.isDark(m,f)&&!o.isDark(m+1,f)&&o.isDark(m+2,f)&&o.isDark(m+3,f)&&o.isDark(m+4,f)&&!o.isDark(m+5,f)&&o.isDark(m+6,f)&&(p+=40);let d=0;for(let f=0;f<s;f+=1)for(let m=0;m<s;m+=1)o.isDark(m,f)&&(d+=1);let g=Math.abs(100*d/s/s-50)/5;return p+=g*10,p},r})(),D=(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})(),oe=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 o=0;o<n.length-r;o+=1)a[o]=n[o+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 o=0;o<i.getLength();o+=1)for(let s=0;s<r.getLength();s+=1)a[o+s]^=D.gexp(D.glog(i.getAt(o))+D.glog(r.getAt(s)));return oe(a,0)},i.mod=function(r){if(i.getLength()-r.getLength()<0)return i;let a=D.glog(i.getAt(0))-D.glog(r.getAt(0)),o=new Array(i.getLength());for(let s=0;s<i.getLength();s+=1)o[s]=i.getAt(s);for(let s=0;s<r.getLength();s+=1)o[s]^=D.gexp(D.glog(r.getAt(s))+a);return oe(o,0).mod(r)},i},zt=(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 o={};return o.totalCount=r,o.dataCount=a,o},t={},i=function(r,a){switch(a){case re.L:return n[(r-1)*4+0];case re.M:return n[(r-1)*4+1];case re.Q:return n[(r-1)*4+2];case re.H:return n[(r-1)*4+3];default:return}};return t.getRSBlocks=function(r,a){let o=i(r,a);if(typeof o>"u")throw "bad rs block @ typeNumber:"+r+"/errorCorrectionLevel:"+a;let s=o.length/3,p=[];for(let d=0;d<s;d+=1){let g=o[d*3+0],f=o[d*3+1],m=o[d*3+2];for(let w=0;w<g;w+=1)p.push(e(f,m));}return p},t})(),Et=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},Vt=function(n){let e=L.MODE_NUMBER,t=n,i={};i.getMode=function(){return e},i.getLength=function(o){return t.length},i.write=function(o){let s=t,p=0;for(;p+2<s.length;)o.put(r(s.substring(p,p+3)),10),p+=3;p<s.length&&(s.length-p==1?o.put(r(s.substring(p,p+1)),4):s.length-p==2&&o.put(r(s.substring(p,p+2)),7));};let r=function(o){let s=0;for(let p=0;p<o.length;p+=1)s=s*10+a(o.charAt(p));return s},a=function(o){if("0"<=o&&o<="9")return o.charCodeAt(0)-48;throw "illegal char :"+o};return i},Gt=function(n){let e=L.MODE_ALPHA_NUM,t=n,i={};i.getMode=function(){return e},i.getLength=function(a){return t.length},i.write=function(a){let o=t,s=0;for(;s+1<o.length;)a.put(r(o.charAt(s))*45+r(o.charAt(s+1)),11),s+=2;s<o.length&&a.put(r(o.charAt(s)),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},Kt=function(n){let e=L.MODE_8BIT_BYTE,i=Q.stringToBytes(n),r={};return r.getMode=function(){return e},r.getLength=function(a){return i.length},r.write=function(a){for(let o=0;o<i.length;o+=1)a.put(i[o],8);},r},Xt=function(n){let e=L.MODE_KANJI,i=Q.stringToBytes;(function(o,s){let p=i(o);if(p.length!=2||(p[0]<<8|p[1])!=s)throw "sjis not supported."})("\u53CB",38726);let r=i(n),a={};return a.getMode=function(){return e},a.getLength=function(o){return ~~(r.length/2)},a.write=function(o){let s=r,p=0;for(;p+1<s.length;){let d=(255&s[p])<<8|255&s[p+1];if(33088<=d&&d<=40956)d-=33088;else if(57408<=d&&d<=60351)d-=49472;else throw "illegal char at "+(p+1)+"/"+d;d=(d>>>8&255)*192+(d&255),o.put(d,13),p+=2;}if(p<s.length)throw "illegal char at "+(p+1)},a},Ct=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},Jt=function(){let n=0,e=0,t=0,i="",r={},a=function(s){i+=String.fromCharCode(o(s&63));},o=function(s){if(s<0)throw "n:"+s;if(s<26)return 65+s;if(s<52)return 97+(s-26);if(s<62)return 48+(s-52);if(s==62)return 43;if(s==63)return 47;throw "n:"+s};return r.writeByte=function(s){for(n=n<<8|s&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 s=3-t%3;for(let p=0;p<s;p+=1)i+="=";}},r.toString=function(){return i},r},ei=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 p=e.charAt(t);if(t+=1,p=="=")return r=0,-1;if(p.match(/^\s$/))continue;i=i<<6|o(p.charCodeAt(0)),r+=6;}let s=i>>>r-8&255;return r-=8,s};let o=function(s){if(65<=s&&s<=90)return s-65;if(97<=s&&s<=122)return s-97+26;if(48<=s&&s<=57)return s-48+52;if(s==43)return 62;if(s==47)return 63;throw "c:"+s};return a},ti=function(n,e){let t=n,i=e,r=new Array(n*e),a={};a.setPixel=function(d,g,f){r[g*t+d]=f;},a.write=function(d){d.writeString("GIF87a"),d.writeShort(t),d.writeShort(i),d.writeByte(128),d.writeByte(0),d.writeByte(0),d.writeByte(0),d.writeByte(0),d.writeByte(0),d.writeByte(255),d.writeByte(255),d.writeByte(255),d.writeString(","),d.writeShort(0),d.writeShort(0),d.writeShort(t),d.writeShort(i),d.writeByte(0);let g=2,f=s(g);d.writeByte(g);let m=0;for(;f.length-m>255;)d.writeByte(255),d.writeBytes(f,m,255),m+=255;d.writeByte(f.length-m),d.writeBytes(f,m,f.length-m),d.writeByte(0),d.writeString(";");};let o=function(d){let g=d,f=0,m=0,w={};return w.write=function(S,P){if(S>>>P)throw "length over";for(;f+P>=8;)g.writeByte(255&(S<<f|m)),P-=8-f,S>>>=8-f,m=0,f=0;m=S<<f|m,f=f+P;},w.flush=function(){f>0&&g.writeByte(m);},w},s=function(d){let g=1<<d,f=(1<<d)+1,m=d+1,w=p();for(let T=0;T<g;T+=1)w.add(String.fromCharCode(T));w.add(String.fromCharCode(g)),w.add(String.fromCharCode(f));let S=Ct(),P=o(S);P.write(g,m);let z=0,N=String.fromCharCode(r[z]);for(z+=1;z<r.length;){let T=String.fromCharCode(r[z]);z+=1,w.contains(N+T)?N=N+T:(P.write(w.indexOf(N),m),w.size()<4095&&(w.size()==1<<m&&(m+=1),w.add(N+T)),N=T);}return P.write(w.indexOf(N),m),P.write(f,m),P.flush(),S.toByteArray()},p=function(){let d={},g=0,f={};return f.add=function(m){if(f.contains(m))throw "dup key:"+m;d[m]=g,g+=1;},f.size=function(){return g},f.indexOf=function(m){return d[m]},f.contains=function(m){return typeof d[m]<"u"},f};return a},ii=function(n,e,t){let i=ti(n,e);for(let s=0;s<e;s+=1)for(let p=0;p<n;p+=1)i.setPixel(p,s,t(p,s));let r=Ct();i.write(r);let a=Jt(),o=r.toByteArray();for(let s=0;s<o.length;s+=1)a.writeByte(o[s]);return a.flush(),"data:image/gif;base64,"+a},At=Q;Q.stringToBytes;var ni="#476CEB",ri="-1 20.86 60 60",oi="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 ai(n){let e=/viewBox="0 0 ([\d.]+) [\d.]+"/.exec(n);return e?Number(e[1]):null}function si(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="${ri}">`,`<path d="${oi}" fill="${ni}"/>`,"</svg>","</g>"].join("")}function Mt(n){let e=ai(n);return e?n.replace("</svg>",`${si(e)}</svg>`):n}function St(){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 qe="merchant-payment";function me(n){return `zippy://${qe}/${n}`}function $e(n,e=4,t="H",i=2){let r=At(0,t);return r.addData(n),r.make(),r.createSvgTag(e,i)}function Tt(n,e=4,t="H"){return $e(me(n),e,t)}function Lt(n,e=4){return Mt(Tt(n,e,"H"))}function Qe(n,e=4){return `<div class="zippy-qr-stack">${Lt(n,e)}</div>`}function We(n,e=4){return `<div class="zippy-qr-stack zippy-qr-stack--plain">${$e(n,e,"M")}</div>`}function It(n){return `intent://${qe}/${n}#Intent;scheme=zippy;package=${ie};end`}function Nt(n,e){return e==="android"||e==null&&Be()?It(n):me(n)}function ae(n){if(typeof window>"u")return;let e=n??ft();window.location.assign(De(e));}function Ye(n){typeof window>"u"||typeof document>"u"||pi(Nt(n));}function pi(n){let e=document.createElement("a");e.href=n,e.style.display="none",e.setAttribute("aria-hidden","true"),document.body.appendChild(e),e.click(),e.remove();}var li={ios:{title:"Download Zippy for iPhone",lead:"Scan the code with your iPhone camera, or open the App Store directly on this device.",qrHint:"Scan to open the App Store",ctaLabel:"Open App Store",dialogLabel:"Download Zippy on the App Store",icon:Fe("zippy-app-modal-platform-icon")},android:{title:"Download Zippy for Android",lead:"Scan the code with your Android phone, or open Google Play directly on this device.",qrHint:"Scan to open Google Play",ctaLabel:"Open Google Play",dialogLabel:"Get Zippy on Google Play",icon:Ze("zippy-app-modal-platform-icon zippy-app-modal-platform-icon--play")}};function ci(){return typeof window>"u"?false:window.matchMedia("(max-width: 520px), (pointer: coarse)").matches}var ye=class{constructor(e){this.shadow=e;this.overlay=null;this.escapeHandler=null;this.focusTrapHandler=null;this.trigger=null;}open(e,t,i){this.close(),this.trigger=i;let r=li[e],a=ci(),o=document.createElement("div");o.className=`zippy-app-modal-overlay${a?" zippy-app-modal-overlay--mobile":""}`,o.setAttribute("role","dialog"),o.setAttribute("aria-modal","true"),o.setAttribute("aria-label",r.dialogLabel),o.innerHTML=`
1735
+ `;}return C.substring(0,C.length-1)},g.renderTo2dContext=function(c,y){y=y||2;let l=g.getModuleCount();for(let h=0;h<l;h++)for(let u=0;u<l;u++)c.fillStyle=g.isDark(h,u)?"black":"white",c.fillRect(u*y,h*y,y,y);},g};Q.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};Q.createStringToBytes=function(n,e){let t=(function(){let r=ti(n),a=function(){let p=r.read();if(p==-1)throw "eof";return p},o=0,s={};for(;;){let p=r.read();if(p==-1)break;let d=a(),g=a(),f=a(),m=String.fromCharCode(p<<8|d),w=g<<8|f;s[m]=w,o+=1;}if(o!=e)throw o+" != "+e;return s})(),i=63;return function(r){let a=[];for(let o=0;o<r.length;o+=1){let s=r.charCodeAt(o);if(s<128)a.push(s);else {let p=t[r.charAt(o)];typeof p=="number"?(p&255)==p?a.push(p):(a.push(p>>>8),a.push(p&255)):a.push(i);}}return a}};var L={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},re={L:1,M:0,Q:3,H:2},H={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},U=(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(o){let s=0;for(;o!=0;)s+=1,o>>>=1;return s};return r.getBCHTypeInfo=function(o){let s=o<<10;for(;a(s)-a(e)>=0;)s^=e<<a(s)-a(e);return (o<<10|s)^i},r.getBCHTypeNumber=function(o){let s=o<<12;for(;a(s)-a(t)>=0;)s^=t<<a(s)-a(t);return o<<12|s},r.getPatternPosition=function(o){return n[o-1]},r.getMaskFunction=function(o){switch(o){case H.PATTERN000:return function(s,p){return (s+p)%2==0};case H.PATTERN001:return function(s,p){return s%2==0};case H.PATTERN010:return function(s,p){return p%3==0};case H.PATTERN011:return function(s,p){return (s+p)%3==0};case H.PATTERN100:return function(s,p){return (Math.floor(s/2)+Math.floor(p/3))%2==0};case H.PATTERN101:return function(s,p){return s*p%2+s*p%3==0};case H.PATTERN110:return function(s,p){return (s*p%2+s*p%3)%2==0};case H.PATTERN111:return function(s,p){return (s*p%3+(s+p)%2)%2==0};default:throw "bad maskPattern:"+o}},r.getErrorCorrectPolynomial=function(o){let s=oe([1],0);for(let p=0;p<o;p+=1)s=s.multiply(oe([1,D.gexp(p)],0));return s},r.getLengthInBits=function(o,s){if(1<=s&&s<10)switch(o){case L.MODE_NUMBER:return 10;case L.MODE_ALPHA_NUM:return 9;case L.MODE_8BIT_BYTE:return 8;case L.MODE_KANJI:return 8;default:throw "mode:"+o}else if(s<27)switch(o){case L.MODE_NUMBER:return 12;case L.MODE_ALPHA_NUM:return 11;case L.MODE_8BIT_BYTE:return 16;case L.MODE_KANJI:return 10;default:throw "mode:"+o}else if(s<41)switch(o){case L.MODE_NUMBER:return 14;case L.MODE_ALPHA_NUM:return 13;case L.MODE_8BIT_BYTE:return 16;case L.MODE_KANJI:return 12;default:throw "mode:"+o}else throw "type:"+s},r.getLostPoint=function(o){let s=o.getModuleCount(),p=0;for(let f=0;f<s;f+=1)for(let m=0;m<s;m+=1){let w=0,S=o.isDark(f,m);for(let P=-1;P<=1;P+=1)if(!(f+P<0||s<=f+P))for(let z=-1;z<=1;z+=1)m+z<0||s<=m+z||P==0&&z==0||S==o.isDark(f+P,m+z)&&(w+=1);w>5&&(p+=3+w-5);}for(let f=0;f<s-1;f+=1)for(let m=0;m<s-1;m+=1){let w=0;o.isDark(f,m)&&(w+=1),o.isDark(f+1,m)&&(w+=1),o.isDark(f,m+1)&&(w+=1),o.isDark(f+1,m+1)&&(w+=1),(w==0||w==4)&&(p+=3);}for(let f=0;f<s;f+=1)for(let m=0;m<s-6;m+=1)o.isDark(f,m)&&!o.isDark(f,m+1)&&o.isDark(f,m+2)&&o.isDark(f,m+3)&&o.isDark(f,m+4)&&!o.isDark(f,m+5)&&o.isDark(f,m+6)&&(p+=40);for(let f=0;f<s;f+=1)for(let m=0;m<s-6;m+=1)o.isDark(m,f)&&!o.isDark(m+1,f)&&o.isDark(m+2,f)&&o.isDark(m+3,f)&&o.isDark(m+4,f)&&!o.isDark(m+5,f)&&o.isDark(m+6,f)&&(p+=40);let d=0;for(let f=0;f<s;f+=1)for(let m=0;m<s;m+=1)o.isDark(m,f)&&(d+=1);let g=Math.abs(100*d/s/s-50)/5;return p+=g*10,p},r})(),D=(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})(),oe=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 o=0;o<n.length-r;o+=1)a[o]=n[o+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 o=0;o<i.getLength();o+=1)for(let s=0;s<r.getLength();s+=1)a[o+s]^=D.gexp(D.glog(i.getAt(o))+D.glog(r.getAt(s)));return oe(a,0)},i.mod=function(r){if(i.getLength()-r.getLength()<0)return i;let a=D.glog(i.getAt(0))-D.glog(r.getAt(0)),o=new Array(i.getLength());for(let s=0;s<i.getLength();s+=1)o[s]=i.getAt(s);for(let s=0;s<r.getLength();s+=1)o[s]^=D.gexp(D.glog(r.getAt(s))+a);return oe(o,0).mod(r)},i},Et=(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 o={};return o.totalCount=r,o.dataCount=a,o},t={},i=function(r,a){switch(a){case re.L:return n[(r-1)*4+0];case re.M:return n[(r-1)*4+1];case re.Q:return n[(r-1)*4+2];case re.H:return n[(r-1)*4+3];default:return}};return t.getRSBlocks=function(r,a){let o=i(r,a);if(typeof o>"u")throw "bad rs block @ typeNumber:"+r+"/errorCorrectionLevel:"+a;let s=o.length/3,p=[];for(let d=0;d<s;d+=1){let g=o[d*3+0],f=o[d*3+1],m=o[d*3+2];for(let w=0;w<g;w+=1)p.push(e(f,m));}return p},t})(),Ct=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},Gt=function(n){let e=L.MODE_NUMBER,t=n,i={};i.getMode=function(){return e},i.getLength=function(o){return t.length},i.write=function(o){let s=t,p=0;for(;p+2<s.length;)o.put(r(s.substring(p,p+3)),10),p+=3;p<s.length&&(s.length-p==1?o.put(r(s.substring(p,p+1)),4):s.length-p==2&&o.put(r(s.substring(p,p+2)),7));};let r=function(o){let s=0;for(let p=0;p<o.length;p+=1)s=s*10+a(o.charAt(p));return s},a=function(o){if("0"<=o&&o<="9")return o.charCodeAt(0)-48;throw "illegal char :"+o};return i},Kt=function(n){let e=L.MODE_ALPHA_NUM,t=n,i={};i.getMode=function(){return e},i.getLength=function(a){return t.length},i.write=function(a){let o=t,s=0;for(;s+1<o.length;)a.put(r(o.charAt(s))*45+r(o.charAt(s+1)),11),s+=2;s<o.length&&a.put(r(o.charAt(s)),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},Xt=function(n){let e=L.MODE_8BIT_BYTE,i=Q.stringToBytes(n),r={};return r.getMode=function(){return e},r.getLength=function(a){return i.length},r.write=function(a){for(let o=0;o<i.length;o+=1)a.put(i[o],8);},r},Jt=function(n){let e=L.MODE_KANJI,i=Q.stringToBytes;(function(o,s){let p=i(o);if(p.length!=2||(p[0]<<8|p[1])!=s)throw "sjis not supported."})("\u53CB",38726);let r=i(n),a={};return a.getMode=function(){return e},a.getLength=function(o){return ~~(r.length/2)},a.write=function(o){let s=r,p=0;for(;p+1<s.length;){let d=(255&s[p])<<8|255&s[p+1];if(33088<=d&&d<=40956)d-=33088;else if(57408<=d&&d<=60351)d-=49472;else throw "illegal char at "+(p+1)+"/"+d;d=(d>>>8&255)*192+(d&255),o.put(d,13),p+=2;}if(p<s.length)throw "illegal char at "+(p+1)},a},At=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},ei=function(){let n=0,e=0,t=0,i="",r={},a=function(s){i+=String.fromCharCode(o(s&63));},o=function(s){if(s<0)throw "n:"+s;if(s<26)return 65+s;if(s<52)return 97+(s-26);if(s<62)return 48+(s-52);if(s==62)return 43;if(s==63)return 47;throw "n:"+s};return r.writeByte=function(s){for(n=n<<8|s&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 s=3-t%3;for(let p=0;p<s;p+=1)i+="=";}},r.toString=function(){return i},r},ti=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 p=e.charAt(t);if(t+=1,p=="=")return r=0,-1;if(p.match(/^\s$/))continue;i=i<<6|o(p.charCodeAt(0)),r+=6;}let s=i>>>r-8&255;return r-=8,s};let o=function(s){if(65<=s&&s<=90)return s-65;if(97<=s&&s<=122)return s-97+26;if(48<=s&&s<=57)return s-48+52;if(s==43)return 62;if(s==47)return 63;throw "c:"+s};return a},ii=function(n,e){let t=n,i=e,r=new Array(n*e),a={};a.setPixel=function(d,g,f){r[g*t+d]=f;},a.write=function(d){d.writeString("GIF87a"),d.writeShort(t),d.writeShort(i),d.writeByte(128),d.writeByte(0),d.writeByte(0),d.writeByte(0),d.writeByte(0),d.writeByte(0),d.writeByte(255),d.writeByte(255),d.writeByte(255),d.writeString(","),d.writeShort(0),d.writeShort(0),d.writeShort(t),d.writeShort(i),d.writeByte(0);let g=2,f=s(g);d.writeByte(g);let m=0;for(;f.length-m>255;)d.writeByte(255),d.writeBytes(f,m,255),m+=255;d.writeByte(f.length-m),d.writeBytes(f,m,f.length-m),d.writeByte(0),d.writeString(";");};let o=function(d){let g=d,f=0,m=0,w={};return w.write=function(S,P){if(S>>>P)throw "length over";for(;f+P>=8;)g.writeByte(255&(S<<f|m)),P-=8-f,S>>>=8-f,m=0,f=0;m=S<<f|m,f=f+P;},w.flush=function(){f>0&&g.writeByte(m);},w},s=function(d){let g=1<<d,f=(1<<d)+1,m=d+1,w=p();for(let T=0;T<g;T+=1)w.add(String.fromCharCode(T));w.add(String.fromCharCode(g)),w.add(String.fromCharCode(f));let S=At(),P=o(S);P.write(g,m);let z=0,N=String.fromCharCode(r[z]);for(z+=1;z<r.length;){let T=String.fromCharCode(r[z]);z+=1,w.contains(N+T)?N=N+T:(P.write(w.indexOf(N),m),w.size()<4095&&(w.size()==1<<m&&(m+=1),w.add(N+T)),N=T);}return P.write(w.indexOf(N),m),P.write(f,m),P.flush(),S.toByteArray()},p=function(){let d={},g=0,f={};return f.add=function(m){if(f.contains(m))throw "dup key:"+m;d[m]=g,g+=1;},f.size=function(){return g},f.indexOf=function(m){return d[m]},f.contains=function(m){return typeof d[m]<"u"},f};return a},ni=function(n,e,t){let i=ii(n,e);for(let s=0;s<e;s+=1)for(let p=0;p<n;p+=1)i.setPixel(p,s,t(p,s));let r=At();i.write(r);let a=ei(),o=r.toByteArray();for(let s=0;s<o.length;s+=1)a.writeByte(o[s]);return a.flush(),"data:image/gif;base64,"+a},Mt=Q;Q.stringToBytes;var ri="#476CEB",oi="-1 20.86 60 60",ai="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 si(n){let e=/viewBox="0 0 ([\d.]+) [\d.]+"/.exec(n);return e?Number(e[1]):null}function pi(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="${oi}">`,`<path d="${ai}" fill="${ri}"/>`,"</svg>","</g>"].join("")}function St(n){let e=si(n);return e?n.replace("</svg>",`${pi(e)}</svg>`):n}function Tt(){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 qe="merchant-payment";function me(n){return `zippy://${qe}/${n}`}function $e(n,e=4,t="H",i=2){let r=Mt(0,t);return r.addData(n),r.make(),r.createSvgTag(e,i)}function Lt(n,e=4,t="H"){return $e(me(n),e,t)}function It(n,e=4){return St(Lt(n,e,"H"))}function Qe(n,e=4){return `<div class="zippy-qr-stack">${It(n,e)}</div>`}function We(n,e=4){return `<div class="zippy-qr-stack zippy-qr-stack--plain">${$e(n,e,"M")}</div>`}function Nt(n){return `intent://${qe}/${n}#Intent;scheme=zippy;package=${ie};end`}function Bt(n,e){return e==="android"||e==null&&Be()?Nt(n):me(n)}function ae(n){if(typeof window>"u")return;let e=n??ft();window.location.assign(De(e));}function Ye(n){typeof window>"u"||typeof document>"u"||li(Bt(n));}function li(n){let e=document.createElement("a");e.href=n,e.style.display="none",e.setAttribute("aria-hidden","true"),document.body.appendChild(e),e.click(),e.remove();}var ci={ios:{title:"Download Zippy for iPhone",lead:"Scan the code with your iPhone camera, or open the App Store directly on this device.",qrHint:"Scan to open the App Store",ctaLabel:"Open App Store",dialogLabel:"Download Zippy on the App Store",icon:Fe("zippy-app-modal-platform-icon")},android:{title:"Download Zippy for Android",lead:"Scan the code with your Android phone, or open Google Play directly on this device.",qrHint:"Scan to open Google Play",ctaLabel:"Open Google Play",dialogLabel:"Get Zippy on Google Play",icon:Ze("zippy-app-modal-platform-icon zippy-app-modal-platform-icon--play")}};function di(){return typeof window>"u"?false:window.matchMedia("(max-width: 520px), (pointer: coarse)").matches}var ye=class{constructor(e){this.shadow=e;this.overlay=null;this.escapeHandler=null;this.focusTrapHandler=null;this.trigger=null;}open(e,t,i){this.close(),this.trigger=i;let r=ci[e],a=di(),o=document.createElement("div");o.className=`zippy-app-modal-overlay${a?" zippy-app-modal-overlay--mobile":""}`,o.setAttribute("role","dialog"),o.setAttribute("aria-modal","true"),o.setAttribute("aria-label",r.dialogLabel),o.innerHTML=`
1736
1736
  <div class="zippy-app-modal-panel">
1737
1737
  <button type="button" class="zippy-app-modal-close" aria-label="Close download dialog"><svg class="zippy-app-modal-close-icon" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path d="M7 7l10 10M17 7 7 17" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg></button>
1738
1738
  <div class="zippy-app-modal-header">
@@ -1747,11 +1747,11 @@ input {
1747
1747
  <p class="zippy-app-modal-qr-hint">${r.qrHint}</p>
1748
1748
  </div>
1749
1749
  <div class="zippy-app-modal-actions">
1750
- <a class="zippy-app-modal-cta zippy-app-modal-cta--${e}" href="${di(t)}" target="_blank" rel="noopener noreferrer">${r.ctaLabel}</a>
1750
+ <a class="zippy-app-modal-cta zippy-app-modal-cta--${e}" href="${ui(t)}" target="_blank" rel="noopener noreferrer">${r.ctaLabel}</a>
1751
1751
  ${a?'<p class="zippy-app-modal-mobile-note">On this device, use the button above to install the app.</p>':""}
1752
1752
  </div>
1753
1753
  </div>
1754
- `,o.addEventListener("click",p=>{p.target===o&&this.close();}),o.querySelector(".zippy-app-modal-panel")?.addEventListener("click",p=>{p.stopPropagation();}),o.querySelector(".zippy-app-modal-close")?.addEventListener("click",()=>{this.close();});let s=o.querySelector(".zippy-app-modal-cta");a&&s&&s.addEventListener("click",p=>{p.preventDefault(),ae(e);}),this.shadow.appendChild(o),this.overlay=o,this.escapeHandler=p=>{p.key==="Escape"&&(p.preventDefault(),this.close());},document.addEventListener("keydown",this.escapeHandler),this.focusTrapHandler=p=>{if(p.key!=="Tab"||!this.overlay)return;let d=Array.from(this.overlay.querySelectorAll('button:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(m=>m.offsetParent!==null);if(d.length===0)return;let g=d[0],f=d[d.length-1];p.shiftKey&&document.activeElement===g?(p.preventDefault(),f.focus()):!p.shiftKey&&document.activeElement===f&&(p.preventDefault(),g.focus());},document.addEventListener("keydown",this.focusTrapHandler),o.querySelector(".zippy-app-modal-close")?.focus();}close(){this.escapeHandler&&(document.removeEventListener("keydown",this.escapeHandler),this.escapeHandler=null),this.focusTrapHandler&&(document.removeEventListener("keydown",this.focusTrapHandler),this.focusTrapHandler=null),this.overlay?.remove(),this.overlay=null,this.trigger?.isConnected&&this.trigger.focus(),this.trigger=null;}destroy(){this.close();}};function di(n){return n.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var fe=class{constructor(e,t,i,r,a=""){this.expiryTimer=null;this.terminalExitTimer=null;this.callbacks=i,this.uiOptions=r,this.state=t,this.shadow=e.attachShadow({mode:"open"}),this.appStoreModal=new ye(this.shadow);let o=document.createElement("style");o.textContent=ct+a,this.shadow.appendChild(o),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();}updateUiOptions(e){this.uiOptions=e,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,appHandoffStatus:e.appHandoffStatus??"idle",mobileAppManualFallback:e.mobileAppManualFallback??false,verifiedPayer:e.verifiedPayer,verifyMatches:e.verifyMatches,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(),this.appStoreModal.destroy();}getShadowRoot(){return this.shadow}render(){let e=this.restoreFocusState();this.clearExpiryTimer(),this.clearTerminalExitTimer();let{phase:t,session:i,errorMessage:r,loading:a,verifiedPayer:o,verifyMatches:s,paymentId:p,sessionId:d,committedMethod:g,exitMode:f,mode:m,appHandoffStatus:w="idle",mobileAppManualFallback:S=false}=this.state,P=t==="success"||t==="expired"||t==="cancelled"||t==="declined"||t==="failed"||t==="invalid-session"||t==="error",z=!P&&Ne(i,t),N=t==="qr-active"||t==="awaiting"&&g==="qr",T=t==="mobile-app-active"||t==="awaiting"&&g==="mobileApp";this.root.className=z?N?"zippy-root zippy-root--paying zippy-root--qr":T?"zippy-root zippy-root--paying zippy-root--mobile-app":"zippy-root zippy-root--paying":P?"zippy-root zippy-root--terminal":"zippy-root",this.root.innerHTML="";let M=P?this.root:document.createElement("div");if(P||(M.className="zippy-root-body",this.root.appendChild(M)),t==="loading"){if(M.appendChild(this.renderLoading()),M.appendChild(this.renderBrandFooter()),z){let Z=i?X(i):null;Z!==null&&Z>0&&this.root.appendChild(this.renderPayProgress());}this.applyFocusState(e);return}i&&!P&&M.appendChild(this.renderPaymentHero(i,this.heroSubtitle(t,i)));let W=i?.paymentExpiryAt;switch(z&&t!=="qr-active"&&t!=="mobile-app-active"&&W!=null&&_(W)>0&&M.appendChild(this.renderPayTimer(W)),t){case "choose-method":M.appendChild(this.renderChooseMethod());break;case "qr-active":M.appendChild(this.renderQrActive(d,i));break;case "mobile-app-active":M.appendChild(this.renderMobileAppActive(i,w,a));break;case "manual-entry":M.appendChild(this.renderManualEntry(p,r,a,S));break;case "manual-picker":M.appendChild(this.renderPayerPicker(s??[],a));break;case "manual-confirm":M.appendChild(this.renderManualConfirm(o,r,a));break;case "awaiting":M.appendChild(this.renderAwaiting(i,g??"qr",o));break;case "success":case "expired":case "cancelled":case "declined":case "failed":case "invalid-session":M.appendChild(this.renderOutcomeScreen(t,i,f,m)),this.mountTerminalExitTimer();break;case "error":M.appendChild(this.renderTerminal("error","Something went wrong",r??"Please try again or contact the merchant."));break;}if(P?this.root.appendChild(this.renderBrandFooter()):M.appendChild(this.renderBrandFooter()),z){let Z=i?X(i):null;Z!==null&&Z>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 "mobile-app-active":return this.state.appHandoffStatus==="failed"?"Install or choose another way":t?.status==="AWAITING_PAYMENT"?"Waiting for confirmation":"Pay in the Zippy app";case "manual-entry":return "Find your Zippy account";case "manual-picker":return "Select your account";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=Ce(e.amount,e.currency),i.appendChild(r),i.appendChild(a),t){let o=document.createElement("p");o.className="zippy-payment-subtitle",o.textContent=t,i.appendChild(o);}return i}renderBrandFooter(){let e=document.createElement("div");if(e.className="zippy-brand-footer",e.setAttribute("aria-label","Zippy checkout footer"),this.uiOptions.surface!=="phone"){let o=document.createElement("div");o.className="zippy-app-links";let s=document.createElement("p");s.className="zippy-app-links-label",s.textContent="Get the Zippy Pay app";let p=document.createElement("div");p.className="zippy-app-links-badges",p.appendChild(this.renderStoreBadgeButton("ios",ne.ios,"Show App Store download options",Pt())),p.appendChild(this.renderStoreBadgeButton("android",ne.android,"Show Google Play download options",kt())),o.appendChild(s),o.appendChild(p),e.appendChild(o);}let t=document.createElement("div");t.className="zippy-brand-footer-inner";let i=document.createElement("span");i.className="zippy-brand-secure",i.innerHTML=`${St()}<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}renderStoreBadgeButton(e,t,i,r){let a=document.createElement("button");return a.type="button",a.className=`zippy-app-link zippy-app-link--icon-only zippy-app-link--${e}`,a.setAttribute("aria-label",i),a.setAttribute("aria-haspopup","dialog"),a.innerHTML=r,a.addEventListener("click",()=>{this.appStoreModal.open(e,t,a);}),a}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{appHandoffStatus:t="idle"}=this.state,i=document.createElement("div");i.className="zippy-choose-options";let{methodAvailability:r}=this.uiOptions;if(r.qr&&i.appendChild(this.renderMethodCard({method:"qr",title:"QR code",description:"Open Zippy and scan",icon:this.qrIconSvg()})),r.manual&&i.appendChild(this.renderMethodCard({method:"manual",title:"Zippy account",description:"ID, email, or phone",icon:this.idIconSvg()})),(r.qr||r.manual)&&e.appendChild(i),r.mobileApp){let a=document.createElement("div");a.className="zippy-choose-mobile-app",a.appendChild(this.renderPayWithZippyButton({opening:t==="opening",action:"choose"})),e.appendChild(a);}return 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":e.method==="mobileApp"?"Pay with the Zippy app on this phone":"Pay with your Zippy ID, email, or phone");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 o=document.createElement("span");return o.className="zippy-method-hint",o.textContent=e.description,r.appendChild(a),r.appendChild(o),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 zippy-flow--centered";let r=t?.status==="AWAITING_PAYMENT",a=document.createElement("div");a.className="zippy-qr-section";let o=document.createElement("div");return o.className="zippy-qr-frame",o.innerHTML=Qe(e),a.appendChild(o),t?.paymentExpiryAt&&_(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.renderFlowHint("Open Zippy Pay, scan the code, and complete your payment.")),i.appendChild(this.renderFootnote("Keep this page open until payment completes."))),i}renderMobileAppActive(e,t,i){let r=document.createElement("div");r.className="zippy-flow zippy-flow--centered";let a=e?.status==="AWAITING_PAYMENT",o=document.createElement("div");o.className="zippy-mobile-app-section";let s=e?.paymentExpiryAt;return s!=null&&_(s)>0&&t!=="idle"&&t!=="opening"&&o.appendChild(this.renderPayTimer(s)),t==="opening"?o.appendChild(this.renderPayWithZippyButton({opening:true})):t==="failed"?i?o.appendChild(this.renderMobileAppMethodSwitching()):o.appendChild(this.renderMobileAppHandoffFailed()):t==="opened"||a?a?o.appendChild(this.renderQrAwaitingLoader()):o.appendChild(this.renderMobileAppOpenedHint()):o.appendChild(this.renderPayWithZippyButton({disabled:a})),r.appendChild(o),a?(e?.payer&&r.appendChild(this.renderIdentityCard(e.payer)),r.appendChild(this.renderFootnote("Complete the payment in the Zippy app to finish checkout."))):t==="failed"?r.appendChild(this.renderFootnote(i?"Switching payment method\u2026":"Install Zippy or choose another payment method below.")):r.appendChild(this.renderFootnote("Keep this page open until payment completes.")),r}renderMobileAppMethodSwitching(){let e=document.createElement("div");e.className="zippy-mobile-app-method-switching",e.setAttribute("aria-live","polite"),e.setAttribute("aria-busy","true");let t=document.createElement("span");t.className="zippy-qr-awaiting-spinner",t.setAttribute("aria-hidden","true");let i=document.createElement("p");return i.className="zippy-mobile-app-method-switching-title",i.textContent="Switching payment method\u2026",e.appendChild(t),e.appendChild(i),e}renderPayWithZippyButton(e={}){let{disabled:t=false,opening:i=false,action:r="open"}=e,a=document.createElement("button");if(a.type="button",a.className="zippy-mobile-app-pay-btn",a.disabled=t||i,i){a.classList.add("zippy-mobile-app-pay-btn--opening"),a.setAttribute("aria-busy","true"),a.setAttribute("aria-live","polite"),a.setAttribute("aria-label","Opening Zippy Pay");let o=document.createElement("span");o.className="zippy-qr-awaiting-spinner zippy-mobile-app-pay-btn-spinner",o.setAttribute("aria-hidden","true");let s=document.createElement("span");s.textContent="Opening Zippy\u2026",a.appendChild(o),a.appendChild(s);}else a.textContent="Pay with Zippy",a.setAttribute("aria-label","Open Zippy Pay to complete this payment");return a.addEventListener("click",()=>{a.disabled||(r==="choose"?this.callbacks.onChooseMethod("mobileApp"):this.callbacks.onOpenMobileApp?.());}),a}renderMobileAppOpenedHint(){let e=document.createElement("p");return e.className="zippy-mobile-app-opened-hint",e.textContent="Complete your payment in the Zippy app.",e}renderMobileAppHandoffFailed(){let e=document.createElement("div");e.className="zippy-mobile-app-handoff-failed";let t=document.createElement("p");t.className="zippy-mobile-app-handoff-message",t.textContent="We couldn't open the Zippy app on this device.";let i=document.createElement("button");return i.type="button",i.className="zippy-install-zippy-btn",i.textContent="Install Zippy",i.setAttribute("aria-label","Install Zippy Pay from your app store"),i.addEventListener("click",()=>{this.callbacks.onInstallZippy?.();}),e.appendChild(t),e.appendChild(this.renderRetryMobileAppLink()),e.appendChild(this.renderMobileAppFallbackOptions()),e.appendChild(i),e}renderMobileAppFallbackOptions(){let{checkoutPolicy:e}=this.uiOptions,t=bt(e);if(!t.qr&&!t.manual)return document.createDocumentFragment();let i=document.createElement("div");i.className="zippy-mobile-app-fallback";let r=document.createElement("p");r.className="zippy-mobile-app-fallback-label",r.textContent="Or pay another way";let a=document.createElement("div");return a.className="zippy-choose-options zippy-choose-options--compact",t.qr&&a.appendChild(this.renderMethodCard({method:"qr",title:"QR code",description:"Open Zippy and scan",icon:this.qrIconSvg()})),t.manual&&a.appendChild(this.renderMethodCard({method:"manual",title:"Zippy account",description:"ID, email, or phone",icon:this.idIconSvg()})),i.appendChild(r),i.appendChild(a),i}renderRetryMobileAppLink(){let e=document.createElement("button");return e.type="button",e.className="zippy-mobile-app-retry",e.textContent="Try again",e.setAttribute("aria-label","Try opening the Zippy app again"),e.addEventListener("click",()=>{this.callbacks.onRetryMobileApp?.();}),e}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=_(e),r=document.createElement("div");r.className="zippy-pay-timer",r.setAttribute("role","timer"),r.setAttribute("aria-live","polite"),r.setAttribute("aria-label",`${Se(i)} remaining to complete payment`);let a=document.createElement("span");a.className="zippy-pay-timer-label",a.textContent="Time remaining";let o=document.createElement("span");return o.className="zippy-pay-timer-value",o.setAttribute("aria-hidden","true"),o.textContent=Me(i),r.appendChild(a),r.appendChild(o),t.appendChild(r),t}renderManualEntry(e,t,i,r){let a=document.createElement("div");a.className="zippy-flow",r&&this.callbacks.onBackToMobileAppFallback?a.appendChild(this.renderBackButton(i,{label:"Back",onClick:()=>this.callbacks.onBackToMobileAppFallback?.()})):this.uiOptions.allowManualBack&&this.callbacks.onBackToChooseMethod&&a.appendChild(this.renderBackButton(i,{label:"Back"}));let o=document.createElement("form");o.className="zippy-id-form",o.addEventListener("submit",S=>{S.preventDefault(),!i&&d.value.trim()&&this.callbacks.onVerify(d.value);});let s=document.createElement("div");s.className="zippy-input-combo";let p=document.createElement("div");p.className="zippy-input-combo-input-wrap";let d=document.createElement("input");d.id="zippy-payer-query",d.className="zippy-input-combo-field",d.type="text",d.placeholder="Zippy ID, email, or +15551234567",d.autocomplete="off",d.spellcheck=false,d.inputMode="text",d.value=e,d.disabled=i,d.setAttribute("aria-label","Zippy ID, email, or phone number");let g=document.createElement("button");g.type="button",g.className="zippy-input-combo-clear",g.setAttribute("aria-label","Clear input"),g.innerHTML='<svg class="zippy-input-combo-clear-icon" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path d="M7 7l10 10M17 7 7 17" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>';let f=document.createElement("span");f.className="zippy-input-combo-divider",f.setAttribute("aria-hidden","true");let m=document.createElement("button");m.type="button",m.className="zippy-input-combo-action",m.textContent="Find",m.setAttribute("aria-label","Find Zippy account");let w=()=>{let S=d.value.trim(),P=i,z=d.value.length>0&&!i;p.classList.toggle("zippy-input-combo-input-wrap--has-value",z),g.disabled=!z,g.tabIndex=z?0:-1,g.setAttribute("aria-hidden",z?"false":"true"),m.disabled=i||S.length===0,m.classList.toggle("zippy-input-combo-action--loading",P);let N=m.querySelector(".zippy-spinner-inline");if(P){if(m.textContent="",!N){let T=document.createElement("span");T.className="zippy-spinner-inline",T.setAttribute("aria-hidden","true"),m.appendChild(T);}m.setAttribute("aria-label","Finding account");}else N?.remove(),m.textContent="Find",m.setAttribute("aria-label","Find Zippy account");};return m.addEventListener("click",()=>{this.callbacks.onVerify(d.value);}),g.addEventListener("click",()=>{d.value="",this.state.paymentId="",this.callbacks.onPaymentIdChange?.(""),d.focus(),w();}),d.addEventListener("input",()=>{this.state.paymentId=d.value,this.callbacks.onPaymentIdChange?.(d.value),w();}),w(),t&&s.classList.add("zippy-input-combo--error"),s.appendChild(p),p.appendChild(d),p.appendChild(g),s.appendChild(f),s.appendChild(m),o.appendChild(s),t&&o.appendChild(this.renderFieldError(t)),o.appendChild(this.renderPayerQueryHint()),a.appendChild(o),a}renderPayerQueryHint(){let e=document.createElement("div");e.className="zippy-query-hint";let t=document.createElement("p");t.className="zippy-query-hint-lead",t.textContent="Find your account using any of:";let i=document.createElement("ul");i.className="zippy-query-hint-list";for(let r of [{label:"Zippy ID",example:"john.doe12"},{label:"Email",example:"you@example.com"},{label:"Phone",example:"+15551234567",note:"E.164 \u2014 include + and country code"}])i.appendChild(this.renderPayerQueryHintItem(r));return e.appendChild(t),e.appendChild(i),e}renderPayerQueryHintItem(e){let t=document.createElement("li");t.className="zippy-query-hint-item";let i=document.createElement("span");i.className="zippy-query-hint-label",i.textContent=e.label;let r=document.createElement("span");r.className="zippy-query-hint-example-wrap";let a=document.createElement("code");if(a.className="zippy-query-hint-example",a.textContent=e.example,r.appendChild(a),e.note){let o=document.createElement("span");o.className="zippy-query-hint-note",o.textContent=e.note,r.appendChild(o);}return t.appendChild(i),t.appendChild(r),t}renderPayerPicker(e,t){let i=document.createElement("div");i.className="zippy-flow",this.callbacks.onBackToManualEntry&&i.appendChild(this.renderBackButton(t,{label:"Back",onClick:()=>this.callbacks.onBackToManualEntry?.()}));let r=document.createElement("p");r.className="zippy-picker-lead",r.textContent="Multiple accounts match. Select the one paying for this checkout.",i.appendChild(r);let a=document.createElement("div");a.className="zippy-picker-list",a.setAttribute("role","listbox"),a.setAttribute("aria-label","Matching Zippy accounts");for(let o of e)a.appendChild(this.renderPayerPickerOption(o,t));return i.appendChild(a),i}renderPayerPickerOption(e,t){let i=document.createElement("button");return i.type="button",i.className="zippy-picker-option",i.disabled=t,i.setAttribute("role","option"),i.setAttribute("aria-label",`Pay as ${e.displayName}`),i.appendChild(this.renderIdentityCard(e)),i.addEventListener("click",()=>{this.callbacks.onSelectPayer?.(e);}),i}renderManualConfirm(e,t,i){let r=document.createElement("div");r.className="zippy-flow";let a=i&&!!e;e&&r.appendChild(this.renderIdentityCard(e,{dismissible:true,dismissDisabled:a,onDismiss:()=>this.callbacks.onBackToManualEntry?.()})),t&&r.appendChild(this.renderFieldError(t));let o=document.createElement("button");return o.type="button",o.className="zippy-btn zippy-btn-primary zippy-btn-block",o.textContent=a?"Processing\u2026":"Proceed",o.disabled=i||!e,o.addEventListener("click",()=>{e&&this.callbacks.onPay(e.paymentId);}),r.appendChild(o),r}renderBackButton(e,t){let i=document.createElement("button");return i.type="button",i.className="zippy-back-btn",i.disabled=e,i.setAttribute("aria-label",t?.label??"Back to payment options"),i.innerHTML=`<svg class="zippy-back-btn-icon" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path d="M14.5 6.5 9 12l5.5 5.5" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><span>${t?.label??"Back"}</span>`,i.addEventListener("click",()=>{t?.onClick?t.onClick():this.callbacks.onBackToChooseMethod?.();}),i}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,t){let i=document.createElement("div");i.className=`zippy-identity-card${t?.dismissible?" zippy-identity-card--dismissible":""}`;let r=this.renderIdentityAvatar(e),a=document.createElement("div");a.className="zippy-identity-copy";let o=document.createElement("p");o.className="zippy-identity-label",o.textContent="Paying as";let s=document.createElement("p");s.className="zippy-identity-name",s.textContent=e.displayName;let p=document.createElement("p");return p.className="zippy-identity-handle",p.textContent=e.paymentId,a.appendChild(o),a.appendChild(s),a.appendChild(p),i.appendChild(r),i.appendChild(a),t?.dismissible&&i.appendChild(this.renderCardDismissButton(t.dismissDisabled??false,t.onDismiss)),i}renderCardDismissButton(e,t){let i=document.createElement("button");return i.type="button",i.className="zippy-identity-card-dismiss",i.disabled=e,i.setAttribute("aria-label","Change account"),i.innerHTML='<svg class="zippy-identity-card-dismiss-icon" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path d="M7 7l10 10M17 7 7 17" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>',i.addEventListener("click",()=>{t?.();}),i}renderIdentityAvatar(e){let t=document.createElement("div");t.className="zippy-identity-avatar";let i=ot(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 o=e?.payer??i??null;o&&r.appendChild(this.renderIdentityCard(o));let s=document.createElement("p");return s.className="zippy-awaiting-message",s.textContent=t==="qr"||t==="mobileApp"?"Complete the payment in the Zippy app to finish checkout.":"Tap the notification in Zippy Pay to approve this payment.",r.appendChild(s),r.appendChild(this.renderFootnote("Do not close or refresh this page.")),r}renderFlowHint(e){let t=document.createElement("p");return t.className="zippy-flow-hint",t.textContent=e,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=X(r);if(a===null||a<=0){t.style.display="none",t.setAttribute("aria-valuenow","0"),this.clearExpiryTimer();return}t.style.display="";let o=Math.round(a*100);e.style.transform=`scaleX(${a})`,t.setAttribute("aria-valuenow",String(o));let s=this.shadow.querySelector(".zippy-pay-timer-value"),p=this.shadow.querySelector(".zippy-pay-timer");if(s instanceof HTMLElement&&r.paymentExpiryAt){let d=_(r.paymentExpiryAt);s.textContent=Me(d),p instanceof HTMLElement&&p.setAttribute("aria-label",`${Se(d)} remaining to complete payment`);}};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=rt(e);return this.renderOutcomeStatus(a.kind,a.title,a.detail,a.kind,i,r,t?.transactionId??null)}renderOutcomeStatus(e,t,i,r,a,o,s){let p=this.renderTerminal(e,t,i);s&&p.appendChild(this.renderTransactionReference(s));let d=a??"close",g=document.createElement("p");g.className="zippy-status-exit";let f=document.createElement("span");f.className="zippy-status-exit-lead",f.textContent=nt(d,o,r);let m=document.createElement("span");m.className="zippy-status-exit-countdown",m.textContent=String(Ae);let w=document.createElement("span");return w.className="zippy-status-exit-suffix",w.textContent=" seconds\u2026",g.appendChild(f),g.appendChild(document.createTextNode(" ")),g.appendChild(m),g.appendChild(w),p.appendChild(g),p}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 o=document.createElement("p");o.className="zippy-status-title",o.textContent=t;let s=document.createElement("p");return s.className="zippy-status-detail",s.textContent=i,r.appendChild(a),r.appendChild(o),r.appendChild(s),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">
1754
+ `,o.addEventListener("click",p=>{p.target===o&&this.close();}),o.querySelector(".zippy-app-modal-panel")?.addEventListener("click",p=>{p.stopPropagation();}),o.querySelector(".zippy-app-modal-close")?.addEventListener("click",()=>{this.close();});let s=o.querySelector(".zippy-app-modal-cta");a&&s&&s.addEventListener("click",p=>{p.preventDefault(),ae(e);}),this.shadow.appendChild(o),this.overlay=o,this.escapeHandler=p=>{p.key==="Escape"&&(p.preventDefault(),this.close());},document.addEventListener("keydown",this.escapeHandler),this.focusTrapHandler=p=>{if(p.key!=="Tab"||!this.overlay)return;let d=Array.from(this.overlay.querySelectorAll('button:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(m=>m.offsetParent!==null);if(d.length===0)return;let g=d[0],f=d[d.length-1];p.shiftKey&&document.activeElement===g?(p.preventDefault(),f.focus()):!p.shiftKey&&document.activeElement===f&&(p.preventDefault(),g.focus());},document.addEventListener("keydown",this.focusTrapHandler),o.querySelector(".zippy-app-modal-close")?.focus();}close(){this.escapeHandler&&(document.removeEventListener("keydown",this.escapeHandler),this.escapeHandler=null),this.focusTrapHandler&&(document.removeEventListener("keydown",this.focusTrapHandler),this.focusTrapHandler=null),this.overlay?.remove(),this.overlay=null,this.trigger?.isConnected&&this.trigger.focus(),this.trigger=null;}destroy(){this.close();}};function ui(n){return n.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var fe=class{constructor(e,t,i,r,a=""){this.expiryTimer=null;this.terminalExitTimer=null;this.callbacks=i,this.uiOptions=r,this.state=t,this.shadow=e.attachShadow({mode:"open"}),this.appStoreModal=new ye(this.shadow);let o=document.createElement("style");o.textContent=ct+a,this.shadow.appendChild(o),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();}updateUiOptions(e){this.uiOptions=e,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,appHandoffStatus:e.appHandoffStatus??"idle",mobileAppManualFallback:e.mobileAppManualFallback??false,verifiedPayer:e.verifiedPayer,verifyMatches:e.verifyMatches,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(),this.appStoreModal.destroy();}getShadowRoot(){return this.shadow}render(){let e=this.restoreFocusState();this.clearExpiryTimer(),this.clearTerminalExitTimer();let{phase:t,session:i,errorMessage:r,loading:a,verifiedPayer:o,verifyMatches:s,paymentId:p,sessionId:d,committedMethod:g,exitMode:f,mode:m,appHandoffStatus:w="idle",mobileAppManualFallback:S=false}=this.state,P=t==="success"||t==="expired"||t==="cancelled"||t==="declined"||t==="failed"||t==="invalid-session"||t==="error",z=!P&&Ne(i,t),N=t==="qr-active"||t==="awaiting"&&g==="qr",T=t==="mobile-app-active"||t==="awaiting"&&g==="mobileApp";this.root.className=z?N?"zippy-root zippy-root--paying zippy-root--qr":T?"zippy-root zippy-root--paying zippy-root--mobile-app":"zippy-root zippy-root--paying":P?"zippy-root zippy-root--terminal":"zippy-root",this.root.innerHTML="";let M=P?this.root:document.createElement("div");if(P||(M.className="zippy-root-body",this.root.appendChild(M)),t==="loading"){if(M.appendChild(this.renderLoading()),M.appendChild(this.renderBrandFooter()),z){let Z=i?X(i):null;Z!==null&&Z>0&&this.root.appendChild(this.renderPayProgress());}this.applyFocusState(e);return}i&&!P&&M.appendChild(this.renderPaymentHero(i,this.heroSubtitle(t,i)));let W=i?.paymentExpiryAt;switch(z&&t!=="qr-active"&&t!=="mobile-app-active"&&W!=null&&_(W)>0&&M.appendChild(this.renderPayTimer(W)),t){case "choose-method":M.appendChild(this.renderChooseMethod());break;case "qr-active":M.appendChild(this.renderQrActive(d,i));break;case "mobile-app-active":M.appendChild(this.renderMobileAppActive(i,w,a));break;case "manual-entry":M.appendChild(this.renderManualEntry(p,r,a,S));break;case "manual-picker":M.appendChild(this.renderPayerPicker(s??[],a));break;case "manual-confirm":M.appendChild(this.renderManualConfirm(o,r,a));break;case "awaiting":M.appendChild(this.renderAwaiting(i,g??"qr",o));break;case "success":case "expired":case "cancelled":case "declined":case "failed":case "invalid-session":M.appendChild(this.renderOutcomeScreen(t,i,f,m)),this.mountTerminalExitTimer();break;case "error":M.appendChild(this.renderTerminal("error","Something went wrong",r??"Please try again or contact the merchant."));break;}if(P?this.root.appendChild(this.renderBrandFooter()):M.appendChild(this.renderBrandFooter()),z){let Z=i?X(i):null;Z!==null&&Z>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 "mobile-app-active":return this.state.appHandoffStatus==="failed"?"Install or choose another way":t?.status==="AWAITING_PAYMENT"?"Waiting for confirmation":"Pay in the Zippy app";case "manual-entry":return "Find your Zippy account";case "manual-picker":return "Select your account";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=Ce(e.amount,e.currency),i.appendChild(r),i.appendChild(a),t){let o=document.createElement("p");o.className="zippy-payment-subtitle",o.textContent=t,i.appendChild(o);}return i}renderBrandFooter(){let e=document.createElement("div");if(e.className="zippy-brand-footer",e.setAttribute("aria-label","Zippy checkout footer"),this.uiOptions.surface!=="phone"){let o=document.createElement("div");o.className="zippy-app-links";let s=document.createElement("p");s.className="zippy-app-links-label",s.textContent="Get the Zippy Pay app";let p=document.createElement("div");p.className="zippy-app-links-badges",p.appendChild(this.renderStoreBadgeButton("ios",ne.ios,"Show App Store download options",kt())),p.appendChild(this.renderStoreBadgeButton("android",ne.android,"Show Google Play download options",zt())),o.appendChild(s),o.appendChild(p),e.appendChild(o);}let t=document.createElement("div");t.className="zippy-brand-footer-inner";let i=document.createElement("span");i.className="zippy-brand-secure",i.innerHTML=`${Tt()}<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}renderStoreBadgeButton(e,t,i,r){let a=document.createElement("button");return a.type="button",a.className=`zippy-app-link zippy-app-link--icon-only zippy-app-link--${e}`,a.setAttribute("aria-label",i),a.setAttribute("aria-haspopup","dialog"),a.innerHTML=r,a.addEventListener("click",()=>{this.appStoreModal.open(e,t,a);}),a}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{appHandoffStatus:t="idle"}=this.state,i=document.createElement("div");i.className="zippy-choose-options";let{methodAvailability:r}=this.uiOptions;if(r.qr&&i.appendChild(this.renderMethodCard({method:"qr",title:"QR code",description:"Open Zippy and scan",icon:this.qrIconSvg()})),r.manual&&i.appendChild(this.renderMethodCard({method:"manual",title:"Zippy account",description:"ID, email, or phone",icon:this.idIconSvg()})),(r.qr||r.manual)&&e.appendChild(i),r.mobileApp){let a=document.createElement("div");a.className="zippy-choose-mobile-app",a.appendChild(this.renderPayWithZippyButton({opening:t==="opening",action:"choose"})),e.appendChild(a);}return 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":e.method==="mobileApp"?"Pay with the Zippy app on this phone":"Pay with your Zippy ID, email, or phone");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 o=document.createElement("span");return o.className="zippy-method-hint",o.textContent=e.description,r.appendChild(a),r.appendChild(o),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 zippy-flow--centered";let r=t?.status==="AWAITING_PAYMENT",a=document.createElement("div");a.className="zippy-qr-section";let o=document.createElement("div");return o.className="zippy-qr-frame",o.innerHTML=Qe(e),a.appendChild(o),t?.paymentExpiryAt&&_(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.renderFlowHint("Open Zippy Pay, scan the code, and complete your payment.")),i.appendChild(this.renderFootnote("Keep this page open until payment completes."))),i}renderMobileAppActive(e,t,i){let r=document.createElement("div");r.className="zippy-flow zippy-flow--centered";let a=e?.status==="AWAITING_PAYMENT",o=document.createElement("div");o.className="zippy-mobile-app-section";let s=e?.paymentExpiryAt;return s!=null&&_(s)>0&&t!=="idle"&&t!=="opening"&&o.appendChild(this.renderPayTimer(s)),t==="opening"?o.appendChild(this.renderPayWithZippyButton({opening:true})):t==="failed"?i?o.appendChild(this.renderMobileAppMethodSwitching()):o.appendChild(this.renderMobileAppHandoffFailed()):t==="opened"||a?a?o.appendChild(this.renderQrAwaitingLoader()):o.appendChild(this.renderMobileAppOpenedHint()):o.appendChild(this.renderPayWithZippyButton({disabled:a})),r.appendChild(o),a?(e?.payer&&r.appendChild(this.renderIdentityCard(e.payer)),r.appendChild(this.renderFootnote("Complete the payment in the Zippy app to finish checkout."))):t==="failed"?r.appendChild(this.renderFootnote(i?"Switching payment method\u2026":"Install Zippy or choose another payment method below.")):r.appendChild(this.renderFootnote("Keep this page open until payment completes.")),r}renderMobileAppMethodSwitching(){let e=document.createElement("div");e.className="zippy-mobile-app-method-switching",e.setAttribute("aria-live","polite"),e.setAttribute("aria-busy","true");let t=document.createElement("span");t.className="zippy-qr-awaiting-spinner",t.setAttribute("aria-hidden","true");let i=document.createElement("p");return i.className="zippy-mobile-app-method-switching-title",i.textContent="Switching payment method\u2026",e.appendChild(t),e.appendChild(i),e}renderPayWithZippyButton(e={}){let{disabled:t=false,opening:i=false,action:r="open"}=e,a=document.createElement("button");if(a.type="button",a.className="zippy-mobile-app-pay-btn",a.disabled=t||i,i){a.classList.add("zippy-mobile-app-pay-btn--opening"),a.setAttribute("aria-busy","true"),a.setAttribute("aria-live","polite"),a.setAttribute("aria-label","Opening Zippy Pay");let o=document.createElement("span");o.className="zippy-qr-awaiting-spinner zippy-mobile-app-pay-btn-spinner",o.setAttribute("aria-hidden","true");let s=document.createElement("span");s.textContent="Opening Zippy\u2026",a.appendChild(o),a.appendChild(s);}else a.textContent="Pay with Zippy",a.setAttribute("aria-label","Open Zippy Pay to complete this payment");return a.addEventListener("click",()=>{a.disabled||(r==="choose"?this.callbacks.onChooseMethod("mobileApp"):this.callbacks.onOpenMobileApp?.());}),a}renderMobileAppOpenedHint(){let e=document.createElement("p");return e.className="zippy-mobile-app-opened-hint",e.textContent="Complete your payment in the Zippy app.",e}renderMobileAppHandoffFailed(){let e=document.createElement("div");e.className="zippy-mobile-app-handoff-failed";let t=document.createElement("p");t.className="zippy-mobile-app-handoff-message",t.textContent="We couldn't open the Zippy app on this device.";let i=document.createElement("button");return i.type="button",i.className="zippy-install-zippy-btn",i.textContent="Install Zippy",i.setAttribute("aria-label","Install Zippy Pay from your app store"),i.addEventListener("click",()=>{this.callbacks.onInstallZippy?.();}),e.appendChild(t),e.appendChild(this.renderRetryMobileAppLink()),e.appendChild(this.renderMobileAppFallbackOptions()),e.appendChild(i),e}renderMobileAppFallbackOptions(){let{checkoutPolicy:e}=this.uiOptions,t=bt(e);if(!t.qr&&!t.manual)return document.createDocumentFragment();let i=document.createElement("div");i.className="zippy-mobile-app-fallback";let r=document.createElement("p");r.className="zippy-mobile-app-fallback-label",r.textContent="Or pay another way";let a=document.createElement("div");return a.className="zippy-choose-options zippy-choose-options--compact",t.qr&&a.appendChild(this.renderMethodCard({method:"qr",title:"QR code",description:"Open Zippy and scan",icon:this.qrIconSvg()})),t.manual&&a.appendChild(this.renderMethodCard({method:"manual",title:"Zippy account",description:"ID, email, or phone",icon:this.idIconSvg()})),i.appendChild(r),i.appendChild(a),i}renderRetryMobileAppLink(){let e=document.createElement("button");return e.type="button",e.className="zippy-mobile-app-retry",e.textContent="Try again",e.setAttribute("aria-label","Try opening the Zippy app again"),e.addEventListener("click",()=>{this.callbacks.onRetryMobileApp?.();}),e}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=_(e),r=document.createElement("div");r.className="zippy-pay-timer",r.setAttribute("role","timer"),r.setAttribute("aria-live","polite"),r.setAttribute("aria-label",`${Se(i)} remaining to complete payment`);let a=document.createElement("span");a.className="zippy-pay-timer-label",a.textContent="Time remaining";let o=document.createElement("span");return o.className="zippy-pay-timer-value",o.setAttribute("aria-hidden","true"),o.textContent=Me(i),r.appendChild(a),r.appendChild(o),t.appendChild(r),t}renderManualEntry(e,t,i,r){let a=document.createElement("div");a.className="zippy-flow",r&&this.callbacks.onBackToMobileAppFallback?a.appendChild(this.renderBackButton(i,{label:"Back",onClick:()=>this.callbacks.onBackToMobileAppFallback?.()})):this.uiOptions.allowManualBack&&this.callbacks.onBackToChooseMethod&&a.appendChild(this.renderBackButton(i,{label:"Back"}));let o=document.createElement("form");o.className="zippy-id-form",o.addEventListener("submit",S=>{S.preventDefault(),!i&&d.value.trim()&&this.callbacks.onVerify(d.value);});let s=document.createElement("div");s.className="zippy-input-combo";let p=document.createElement("div");p.className="zippy-input-combo-input-wrap";let d=document.createElement("input");d.id="zippy-payer-query",d.className="zippy-input-combo-field",d.type="text",d.placeholder="Zippy ID, email, or +15551234567",d.autocomplete="off",d.spellcheck=false,d.inputMode="text",d.value=e,d.disabled=i,d.setAttribute("aria-label","Zippy ID, email, or phone number");let g=document.createElement("button");g.type="button",g.className="zippy-input-combo-clear",g.setAttribute("aria-label","Clear input"),g.innerHTML='<svg class="zippy-input-combo-clear-icon" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path d="M7 7l10 10M17 7 7 17" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>';let f=document.createElement("span");f.className="zippy-input-combo-divider",f.setAttribute("aria-hidden","true");let m=document.createElement("button");m.type="button",m.className="zippy-input-combo-action",m.textContent="Find",m.setAttribute("aria-label","Find Zippy account");let w=()=>{let S=d.value.trim(),P=i,z=d.value.length>0&&!i;p.classList.toggle("zippy-input-combo-input-wrap--has-value",z),g.disabled=!z,g.tabIndex=z?0:-1,g.setAttribute("aria-hidden",z?"false":"true"),m.disabled=i||S.length===0,m.classList.toggle("zippy-input-combo-action--loading",P);let N=m.querySelector(".zippy-spinner-inline");if(P){if(m.textContent="",!N){let T=document.createElement("span");T.className="zippy-spinner-inline",T.setAttribute("aria-hidden","true"),m.appendChild(T);}m.setAttribute("aria-label","Finding account");}else N?.remove(),m.textContent="Find",m.setAttribute("aria-label","Find Zippy account");};return m.addEventListener("click",()=>{this.callbacks.onVerify(d.value);}),g.addEventListener("click",()=>{d.value="",this.state.paymentId="",this.callbacks.onPaymentIdChange?.(""),d.focus(),w();}),d.addEventListener("input",()=>{this.state.paymentId=d.value,this.callbacks.onPaymentIdChange?.(d.value),w();}),w(),t&&s.classList.add("zippy-input-combo--error"),s.appendChild(p),p.appendChild(d),p.appendChild(g),s.appendChild(f),s.appendChild(m),o.appendChild(s),t&&o.appendChild(this.renderFieldError(t)),o.appendChild(this.renderPayerQueryHint()),a.appendChild(o),a}renderPayerQueryHint(){let e=document.createElement("div");e.className="zippy-query-hint";let t=document.createElement("p");t.className="zippy-query-hint-lead",t.textContent="Find your account using any of:";let i=document.createElement("ul");i.className="zippy-query-hint-list";for(let r of [{label:"Zippy ID",example:"john.doe12"},{label:"Email",example:"you@example.com"},{label:"Phone",example:"+15551234567",note:"E.164 \u2014 include + and country code"}])i.appendChild(this.renderPayerQueryHintItem(r));return e.appendChild(t),e.appendChild(i),e}renderPayerQueryHintItem(e){let t=document.createElement("li");t.className="zippy-query-hint-item";let i=document.createElement("span");i.className="zippy-query-hint-label",i.textContent=e.label;let r=document.createElement("span");r.className="zippy-query-hint-example-wrap";let a=document.createElement("code");if(a.className="zippy-query-hint-example",a.textContent=e.example,r.appendChild(a),e.note){let o=document.createElement("span");o.className="zippy-query-hint-note",o.textContent=e.note,r.appendChild(o);}return t.appendChild(i),t.appendChild(r),t}renderPayerPicker(e,t){let i=document.createElement("div");i.className="zippy-flow",this.callbacks.onBackToManualEntry&&i.appendChild(this.renderBackButton(t,{label:"Back",onClick:()=>this.callbacks.onBackToManualEntry?.()}));let r=document.createElement("p");r.className="zippy-picker-lead",r.textContent="Multiple accounts match. Select the one paying for this checkout.",i.appendChild(r);let a=document.createElement("div");a.className="zippy-picker-list",a.setAttribute("role","listbox"),a.setAttribute("aria-label","Matching Zippy accounts");for(let o of e)a.appendChild(this.renderPayerPickerOption(o,t));return i.appendChild(a),i}renderPayerPickerOption(e,t){let i=document.createElement("button");return i.type="button",i.className="zippy-picker-option",i.disabled=t,i.setAttribute("role","option"),i.setAttribute("aria-label",`Pay as ${e.displayName}`),i.appendChild(this.renderIdentityCard(e)),i.addEventListener("click",()=>{this.callbacks.onSelectPayer?.(e);}),i}renderManualConfirm(e,t,i){let r=document.createElement("div");r.className="zippy-flow";let a=i&&!!e;e&&r.appendChild(this.renderIdentityCard(e,{dismissible:true,dismissDisabled:a,onDismiss:()=>this.callbacks.onBackToManualEntry?.()})),t&&r.appendChild(this.renderFieldError(t));let o=document.createElement("button");return o.type="button",o.className="zippy-btn zippy-btn-primary zippy-btn-block",o.textContent=a?"Processing\u2026":"Proceed",o.disabled=i||!e,o.addEventListener("click",()=>{e&&this.callbacks.onPay(e.paymentId);}),r.appendChild(o),r}renderBackButton(e,t){let i=document.createElement("button");return i.type="button",i.className="zippy-back-btn",i.disabled=e,i.setAttribute("aria-label",t?.label??"Back to payment options"),i.innerHTML=`<svg class="zippy-back-btn-icon" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path d="M14.5 6.5 9 12l5.5 5.5" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><span>${t?.label??"Back"}</span>`,i.addEventListener("click",()=>{t?.onClick?t.onClick():this.callbacks.onBackToChooseMethod?.();}),i}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,t){let i=document.createElement("div");i.className=`zippy-identity-card${t?.dismissible?" zippy-identity-card--dismissible":""}`;let r=this.renderIdentityAvatar(e),a=document.createElement("div");a.className="zippy-identity-copy";let o=document.createElement("p");o.className="zippy-identity-label",o.textContent="Paying as";let s=document.createElement("p");s.className="zippy-identity-name",s.textContent=e.displayName;let p=document.createElement("p");return p.className="zippy-identity-handle",p.textContent=e.paymentId,a.appendChild(o),a.appendChild(s),a.appendChild(p),i.appendChild(r),i.appendChild(a),t?.dismissible&&i.appendChild(this.renderCardDismissButton(t.dismissDisabled??false,t.onDismiss)),i}renderCardDismissButton(e,t){let i=document.createElement("button");return i.type="button",i.className="zippy-identity-card-dismiss",i.disabled=e,i.setAttribute("aria-label","Change account"),i.innerHTML='<svg class="zippy-identity-card-dismiss-icon" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path d="M7 7l10 10M17 7 7 17" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>',i.addEventListener("click",()=>{t?.();}),i}renderIdentityAvatar(e){let t=document.createElement("div");t.className="zippy-identity-avatar";let i=ot(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 o=e?.payer??i??null;o&&r.appendChild(this.renderIdentityCard(o));let s=document.createElement("p");return s.className="zippy-awaiting-message",s.textContent=t==="qr"||t==="mobileApp"?"Complete the payment in the Zippy app to finish checkout.":"Tap the notification in Zippy Pay to approve this payment.",r.appendChild(s),r.appendChild(this.renderFootnote("Do not close or refresh this page.")),r}renderFlowHint(e){let t=document.createElement("p");return t.className="zippy-flow-hint",t.textContent=e,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=X(r);if(a===null||a<=0){t.style.display="none",t.setAttribute("aria-valuenow","0"),this.clearExpiryTimer();return}t.style.display="";let o=Math.round(a*100);e.style.transform=`scaleX(${a})`,t.setAttribute("aria-valuenow",String(o));let s=this.shadow.querySelector(".zippy-pay-timer-value"),p=this.shadow.querySelector(".zippy-pay-timer");if(s instanceof HTMLElement&&r.paymentExpiryAt){let d=_(r.paymentExpiryAt);s.textContent=Me(d),p instanceof HTMLElement&&p.setAttribute("aria-label",`${Se(d)} remaining to complete payment`);}};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=rt(e);return this.renderOutcomeStatus(a.kind,a.title,a.detail,a.kind,i,r,t?.transactionId??null)}renderOutcomeStatus(e,t,i,r,a,o,s){let p=this.renderTerminal(e,t,i);s&&p.appendChild(this.renderTransactionReference(s));let d=a??"close",g=document.createElement("p");g.className="zippy-status-exit";let f=document.createElement("span");f.className="zippy-status-exit-lead",f.textContent=nt(d,o,r);let m=document.createElement("span");m.className="zippy-status-exit-countdown",m.textContent=String(Ae);let w=document.createElement("span");return w.className="zippy-status-exit-suffix",w.textContent=" seconds\u2026",g.appendChild(f),g.appendChild(document.createTextNode(" ")),g.appendChild(m),g.appendChild(w),p.appendChild(g),p}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 o=document.createElement("p");o.className="zippy-status-title",o.textContent=t;let s=document.createElement("p");return s.className="zippy-status-detail",s.textContent=i,r.appendChild(a),r.appendChild(o),r.appendChild(s),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">
1755
1755
  <rect x="3" y="3" width="7" height="7" rx="1.25" stroke="currentColor" stroke-width="1.6"/>
1756
1756
  <rect x="14" y="3" width="7" height="7" rx="1.25" stroke="currentColor" stroke-width="1.6"/>
1757
1757
  <rect x="3" y="14" width="7" height="7" rx="1.25" stroke="currentColor" stroke-width="1.6"/>
@@ -1762,5 +1762,5 @@ input {
1762
1762
  </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">
1763
1763
  <circle cx="12" cy="9" r="3.5" stroke="currentColor" stroke-width="1.6"/>
1764
1764
  <path d="M5 20c0-3.87 3.13-7 7-7s7 3.13 7 7" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/>
1765
- </svg>`}};function Bt(n){let e=n.timeoutMs??8e3,t=false,i=[],r=()=>{for(let p of i)p();i.length=0;},a=p=>{t||(t=true,r(),p==="opened"?n.onOpened():n.onFailed());},o=()=>{document.hidden&&a("opened");};document.addEventListener("visibilitychange",o),i.push(()=>{document.removeEventListener("visibilitychange",o);});let s=setTimeout(()=>{document.hidden?a("opened"):a("failed");},e);return i.push(()=>{clearTimeout(s);}),r}var se=class se{constructor(e){this.ui=null;this.session=null;this.paymentId="";this.verifiedPayer=null;this.verifyMatches=null;this.lastVerifiedQuery=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;this.appHandoffStatus="idle";this.clearAppHandoffWatch=null;this.methodSwitchInProgress=false;this.entryRoutingDone=false;this.payWindowExpiryTimer=null;this.unsubscribeSurface=null;if(this.config={mode:"inline",closeOnBackdropClick:false,closeOnEscape:false,...e},!it(this.config.sessionId))throw new Error("Zippy Pay: sessionId must be a UUID v4.");j(this.config.environment),this.uiOptions=Ue(this.config.checkoutPolicy,this.config.mobileApp,B()),this.client=new G({baseUrl:Pe(this.config.environment),sessionId:this.config.sessionId,clientToken:this.config.clientToken}),this.embed=ut(this.config),Ie(this.embed.host,this.config.theme),this.poller=new K(()=>this.client.getSession(),{onUpdate:t=>this.handleSessionUpdate(t),onError:t=>this.handlePollError(t)}),this.ui=new fe(this.embed.host,this.snapshotUiState(),{onChooseMethod:t=>{this.chooseMethod(t);},onVerify:t=>this.verify(t),onPay:t=>this.attach(t),onSelectPayer:t=>this.selectPayer(t),onBackToChooseMethod:()=>this.backToChooseMethod(),onBackToManualEntry:()=>this.backToManualEntry(),onBackToMobileAppFallback:()=>this.backToMobileAppFallback(),onOpenMobileApp:()=>this.beginMobileAppHandoff(),onInstallZippy:()=>this.installZippy(),onRetryMobileApp:()=>this.beginMobileAppHandoff(),onPaymentIdChange:t=>{let i=$(t),r=false;(this.verifiedPayer||this.verifyMatches)&&this.lastVerifiedQuery!==null&&i!==this.lastVerifiedQuery&&(this.verifiedPayer=null,this.verifyMatches=null,this.lastVerifiedQuery=null,(this.phase==="manual-confirm"||this.phase==="manual-picker")&&(this.phase="manual-entry"),r=true),this.errorMessage&&(this.errorMessage=null,r=true),this.paymentId=t,r&&this.syncUi();},onTerminalExit:()=>this.executeTerminalExit()},this.uiOptions),this.bootstrap(),this.unsubscribeSurface=Oe(t=>{this.handleSurfaceChange(t);}),this.config.mode==="inline"&&(this.modalOpen=true);}open(){this.config.mode!=="modal"||this.modalOpen||(this.modalOpen=true,ht(this.embed,this.config,()=>this.close()));}close(){this.config.mode==="modal"&&(this.modalOpen=false,mt(this.embed),this.config.onClose?.());}destroy(){this.destroyed||(this.destroyed=true,this.unsubscribeSurface?.(),this.unsubscribeSurface=null,this.poller.stop(),this.clearAppHandoffWatch?.(),this.clearAppHandoffWatch=null,this.clearPayWindowExpiryWatch(),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,verifyMatches:this.verifyMatches,errorMessage:this.errorMessage,loading:this.loading,mode:this.config.mode??"inline",exitMode:this.exitMode,appHandoffStatus:this.appHandoffStatus,mobileAppManualFallback:this.isMobileAppManualFallbackActive()}}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(this.snapshotUiState()));}async bootstrap(){try{let e=await this.bindPolicy();if(this.destroyed||(this.applyBoundUiOptions(e),this.applySession(e),this.destroyed))return;this.config.onReady?.(e),ce(e.status)?this.destroyed||this.syncUi({loading:!1}):(await this.routeIdleEntry(),this.destroyed||(this.syncUi({loading:!1}),this.poller.start(e)));}catch(e){this.handleBootstrapError(e);}}async bindPolicy(){let e=he({checkoutPolicy:this.config.checkoutPolicy,mobileApp:this.config.mobileApp});try{return await this.client.bindCheckoutPolicy(e)}catch(t){if(t instanceof I&&t.code==="payment-session.checkout-policy-conflict"){let i=await this.client.getSession();if(q(i))return i}throw t}}applyBoundUiOptions(e,t=B()){this.uiOptions=He(e,t),this.ui?.updateUiOptions(this.uiOptions);}handleSurfaceChange(e){if(this.destroyed||this.committedMethod)return;let t=this.session;!t||!q(t)||this.uiOptions.surface!==e&&(this.uiOptions=te(t.checkoutPolicy,t.mobileAppPolicy??"OFF",e),this.ui?.updateUiOptions(this.uiOptions),(this.phase==="choose-method"||this.phase==="loading")&&this.syncUi());}applySession(e,t){if(this.session=e,this.config.onSessionUpdate?.(e),e.transactionStatus==="DECLINED"&&e.status!=="COMPLETED"){this.methodSwitchInProgress=false,this.handleFailure({reason:"declined",session:e});return}if(e.status==="COMPLETED"){this.methodSwitchInProgress=false,this.handleSuccess(e);return}if(e.status==="EXPIRED"){this.methodSwitchInProgress=false,this.handleFailure({reason:"expired",session:e});return}if(e.status==="FAILED"){this.methodSwitchInProgress=false,this.handleFailure({reason:"failed",session:e});return}if(e.status==="CANCELLED"){this.methodSwitchInProgress=false,this.handleFailure({reason:"cancelled",session:e});return}if(this.isMobileAppManualFallbackActive()&&!t?.fromMethodSwitch){this.schedulePayWindowExpiryWatch(),this.syncUi();return}this.committedMethod=hi(e.checkoutMethod)??this.committedMethod,this.phase=this.resolveActivePhase(e),this.schedulePayWindowExpiryWatch(),this.syncUi();}schedulePayWindowExpiryWatch(){this.clearPayWindowExpiryWatch();let e=this.session;if(!e?.paymentExpiryAt||!se.PAY_WINDOW_PHASES.includes(this.phase))return;let t=_(e.paymentExpiryAt);if(t<=0){this.handlePayWindowExpired();return}this.payWindowExpiryTimer=setTimeout(()=>{this.handlePayWindowExpired();},t+250);}clearPayWindowExpiryWatch(){this.payWindowExpiryTimer!==null&&(clearTimeout(this.payWindowExpiryTimer),this.payWindowExpiryTimer=null);}async handlePayWindowExpired(){if(!(this.destroyed||!this.session?.paymentExpiryAt)){if(_(this.session.paymentExpiryAt)>0){this.schedulePayWindowExpiryWatch();return}if(se.PAY_WINDOW_PHASES.includes(this.phase))try{let e=await this.client.getSession();if(this.destroyed)return;this.applySession(e);}catch{this.destroyed||this.handleFailure({reason:"expired",session:this.session});}}}resolveActivePhase(e){return e.status==="AWAITING_PAYMENT"?e.checkoutMethod==="MOBILE_APP"||this.committedMethod==="mobileApp"?"mobile-app-active":e.checkoutMethod==="QR"||this.committedMethod==="qr"?"qr-active":"awaiting":e.phase==="PAYING"&&e.checkoutMethod==="MOBILE_APP"?"mobile-app-active":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?"manual-confirm":this.phase==="manual-picker"&&this.verifyMatches?"manual-picker":this.phase==="manual-entry"?"manual-entry":this.phase==="choose-method"?"choose-method":this.phase==="qr-active"&&this.committedMethod==="qr"?"qr-active":this.phase==="mobile-app-active"&&this.committedMethod==="mobileApp"?"mobile-app-active":!e.checkoutMethod&&ee(this.uiOptions.checkoutPolicy,this.uiOptions.mobileAppPolicy,this.uiOptions.surface)!=="chooser"?"loading":"choose-method":this.phase}handleSessionUpdate(e){this.destroyed||this.applySession(e);}handleFailure(e){if(this.destroyed)return;this.poller.stop(),this.clearPayWindowExpiryWatch(),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"?ui(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.clearPayWindowExpiryWatch(),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(Te(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"?Te(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 I&&e.status===401){this.handleFailure({reason:"invalid-session",error:e,session:this.session});return}this.handleError(e);}handlePollError(e){let t=je(e);if(t.status===401){this.poller.stop(),this.handleFailure({reason:"invalid-session",error:t,session:this.session});return}if(t.code==="payment-session.not-attachable"){this.poller.stop(),this.handleFailure({reason:"expired",session:this.session});return}}handleError(e){let t=je(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}if(t.code==="payment-session.checkout-policy-not-bound"){(this.phase==="loading"||this.phase==="choose-method")&&(this.phase="error"),this.syncUi({errorMessage:t.detail||"Checkout is not ready yet. Please refresh and try again.",loading:false}),this.config.onError?.(t),this.poller.stop();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 routeIdleEntry(){if(this.destroyed||this.entryRoutingDone)return;let e=this.session;if(!e||ce(e.status))return;if(e.checkoutMethod){this.entryRoutingDone=true;return}if(e.phase!=="IDLE")return;let t=B(),{checkoutPolicy:i,mobileAppPolicy:r}=this.uiOptions,a=Re(i,r,t);a==="MOBILE_APP"?await this.startMobileAppFlow(false):a==="QR"?await this.chooseMethod("qr"):ee(i,r,t)==="auto-manual"?(this.phase="manual-entry",this.syncUi({loading:false})):(this.phase="choose-method",this.syncUi({loading:false})),this.entryRoutingDone=true;}openMobileApp(){Ye(this.config.sessionId);}beginMobileAppHandoff(){this.destroyed||(this.clearAppHandoffWatch?.(),this.clearAppHandoffWatch=null,this.appHandoffStatus="opening",this.syncUi(),this.openMobileApp(),this.clearAppHandoffWatch=Bt({onOpened:()=>{this.destroyed||(this.appHandoffStatus="opened",this.syncUi());},onFailed:()=>{this.destroyed||(this.appHandoffStatus="failed",this.syncUi());}}));}installZippy(){ae();}async startMobileAppFlow(e){if(this.session?.checkoutMethod==="MOBILE_APP"){this.committedMethod="mobileApp",this.phase="mobile-app-active",e&&this.beginMobileAppHandoff(),this.syncUi({loading:false});return}if(this.committedMethod&&this.committedMethod!=="mobileApp")return;let t=B();if(this.canStartAppClaim("MOBILE_APP",t)){e?(this.committedMethod="mobileApp",this.phase="mobile-app-active",this.beginMobileAppHandoff()):this.syncUi({errorMessage:null,loading:true});try{let i=await this.client.startMobileAppCheckout(t);if(this.committedMethod="mobileApp",this.applySession(i),this.destroyed)return;this.phase="mobile-app-active",this.syncUi({loading:!1});}catch(i){this.handleFlowError(i,"choose-method");}}}canStartAppClaim(e,t){if(!this.session||!q(this.session))return this.syncUi({errorMessage:"Checkout is not ready yet. Please refresh and try again.",loading:false}),false;let i=this.session.checkoutPolicy,r=this.session.mobileAppPolicy??"OFF";return J(i,r,t,e)?true:(this.syncUi({errorMessage:"This payment option is not available on your device.",loading:false}),false)}async chooseMethod(e){if(!this.methodSwitchInProgress&&!(this.committedMethod&&!(this.appHandoffStatus==="failed"&&this.committedMethod==="mobileApp"&&e!=="mobileApp"))){if(this.appHandoffStatus==="failed"&&this.committedMethod==="mobileApp"&&(e==="qr"||e==="manual")){await this.chooseFallbackMethod(e);return}if(e==="mobileApp"){await this.startMobileAppFlow(true);return}this.verifiedPayer=null,this.syncUi({errorMessage:null,loading:e==="qr"});try{if(e==="qr"){let t=B();if(!this.canStartAppClaim("QR",t))return;let i=await this.client.startQrCheckout(t);if(this.committedMethod="qr",this.applySession(i),this.destroyed)return;this.syncUi({loading:!1});}else this.phase="manual-entry",this.syncUi({loading:!1});}catch(t){this.handleFlowError(t,"choose-method");}}}async chooseFallbackMethod(e){if(!(this.appHandoffStatus!=="failed"||this.committedMethod!=="mobileApp"||this.methodSwitchInProgress)){if(this.clearAppHandoffWatch?.(),this.clearAppHandoffWatch=null,e==="manual"){this.methodSwitchInProgress=true,this.appHandoffStatus="idle",this.verifiedPayer=null,this.verifyMatches=null,this.lastVerifiedQuery=null,this.paymentId="",this.phase="manual-entry",this.syncUi({errorMessage:null,loading:false});return}this.methodSwitchInProgress=true,this.verifiedPayer=null,this.syncUi({errorMessage:null,loading:true});try{let t=B(),i=await this.client.startQrCheckout(t);if(this.destroyed)return;this.methodSwitchInProgress=!1,this.appHandoffStatus="idle",this.loading=!1,this.applySession(i,{fromMethodSwitch:!0});}catch(t){this.methodSwitchInProgress=false,this.handleFlowError(t,"mobile-app-active");}}}backToChooseMethod(){this.uiOptions.allowManualBack&&(this.committedMethod||this.loading&&this.verifiedPayer||(this.phase="choose-method",this.paymentId="",this.verifiedPayer=null,this.verifyMatches=null,this.lastVerifiedQuery=null,this.errorMessage=null,this.loading=false,this.syncUi({errorMessage:null,loading:false})));}backToManualEntry(){this.loading&&this.verifiedPayer||(this.phase="manual-entry",this.verifiedPayer=null,this.verifyMatches=null,this.lastVerifiedQuery=null,this.errorMessage=null,this.loading=false,this.syncUi({errorMessage:null,loading:false}));}backToMobileAppFallback(){this.loading&&this.verifiedPayer||this.isMobileAppManualFallbackActive()&&(this.methodSwitchInProgress=false,this.appHandoffStatus="failed",this.phase="mobile-app-active",this.paymentId="",this.verifiedPayer=null,this.verifyMatches=null,this.lastVerifiedQuery=null,this.errorMessage=null,this.loading=false,this.syncUi({errorMessage:null,loading:false}));}isMobileAppManualFallbackActive(){return this.committedMethod!=="mobileApp"?false:this.methodSwitchInProgress?true:this.session?.checkoutMethod==="MOBILE_APP"&&(this.phase==="manual-entry"||this.phase==="manual-picker"||this.phase==="manual-confirm")}selectPayer(e){this.loading||this.phase!=="manual-picker"||(this.verifiedPayer=e,this.phase="manual-confirm",this.errorMessage=null,this.syncUi({errorMessage:null,loading:false}));}async verify(e){if(this.paymentId=e,!ze(e)){this.syncUi({errorMessage:Ee(),loading:false});return}let t=$(e);this.syncUi({errorMessage:null,loading:true});try{let{items:i}=await this.client.verifyPayer(e);if(this.phase!=="manual-entry")return;this.lastVerifiedQuery=t,this.verifyMatches=null,i.length===1?(this.verifiedPayer=i[0],this.phase="manual-confirm"):(this.verifiedPayer=null,this.verifyMatches=i,this.phase="manual-picker"),this.syncUi({loading:!1});}catch(i){this.handleFlowError(i,"manual-entry");}}async attach(e){if(!this.verifiedPayer){this.syncUi({errorMessage:"Find your account before proceeding to pay.",loading:false});return}this.syncUi({errorMessage:null,loading:true});try{let t=await Le(this.client,this.verifiedPayer.paymentId);if(this.methodSwitchInProgress=!1,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=je(e),r=mi(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 if(i.code==="payment-session.checkout-policy-not-bound"){this.syncUi({errorMessage:r,loading:false}),this.config.onError?.(i);return}else if(i.code==="payment-session.checkout-policy-denied"||i.code==="payment-session.checkout-policy-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();q(e)&&this.applyBoundUiOptions(e),this.applySession(e);}catch{}}};se.PAY_WINDOW_PHASES=["qr-active","mobile-app-active","awaiting","manual-confirm"];var ge=se;function ui(n){return n==="failed"?new I({code:"payment-session.failed",status:400,title:"Payment failed",detail:"Something went wrong with this payment."}):n==="declined"?new I({code:"payment-session.declined",status:400,title:"Payment declined",detail:"Your payment was declined."}):new I({code:"payment-session.cancelled",status:400,title:"Payment cancelled",detail:"This payment was cancelled."})}function hi(n){return n==="QR"?"qr":n==="MANUAL"?"manual":n==="MOBILE_APP"?"mobileApp":null}function mi(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")?"No Zippy account found":n.detail?.trim()||"Something went wrong. Please try again."}function je(n){return n instanceof I?n:new I({code:"unknown",status:500,title:"Unexpected error",detail:n instanceof Error?n.message:"An unexpected error occurred"})}function pe(n){return new ge(n)}var Ve="zippy-pay-checkout",Ot={"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"},be=class extends HTMLElement{constructor(){super(...arguments);this.instance=null;}static get observedAttributes(){return ["mode","session-id","environment","checkout-policy","mobile-app-policy",...Object.keys(Ot)]}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=pe({...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 o;try{o=j(t);}catch{return null}let s={};for(let[p,d]of Object.entries(Ot)){let g=this.getAttribute(p);g&&(d==="mode"?s.mode=g:s[d]=g);}return {environment:o,sessionId:i,clientToken:r,mode:a,theme:s,checkoutPolicy:yi(this.getAttribute("checkout-policy")),mobileApp:fi(this.getAttribute("mobile-app-policy"))}}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 yi(n){if(n==="QR"||n==="MANUAL")return n}function fi(n){if(n==="option"||n==="enforce")return {policy:n}}function Ge(){typeof customElements>"u"||customElements.get(Ve)||customElements.define(Ve,be);}var gi={create(n){let e=pe(n);return (n.mode??"inline")==="modal"&&e.open(),e}};Ge();var Tn=gi;exports.ANDROID_APP_PACKAGE=ie;exports.ANDROID_PLAY_STORE_NATIVE_URL=wt;exports.APP_STORE_LINKS=ne;exports.CheckoutController=ge;exports.DEFAULT_THEME=pt;exports.E164_PHONE_PATTERN=et;exports.ELEMENT_TAG=Ve;exports.EMAIL_PATTERN=tt;exports.IOS_APP_STORE_NATIVE_URL=xt;exports.PAYMENT_ID_PATTERN=ke;exports.POLLABLE_STATUSES=xe;exports.PaymentSessionClient=G;exports.SessionPoller=K;exports.TERMINAL_STATUSES=Y;exports.ZIPPY_API_BASE_URLS=le;exports.ZIPPY_API_PATH_PREFIX=we;exports.ZippyPay=gi;exports.ZippyPayCheckoutElement=be;exports.ZippyPayError=I;exports.applyThemeToHost=Ie;exports.attachPayerWithRetry=Le;exports.buildAndroidPaymentIntentUrl=It;exports.buildBindPolicyRequest=he;exports.buildPaymentDeepLinkOpenUrl=Nt;exports.buildPaymentQrPayload=me;exports.createCheckout=pe;exports.default=Tn;exports.defineZippyPayCheckoutElement=Ge;exports.detectCheckoutSurface=B;exports.formatAmount=Ce;exports.getCountdownTarget=yt;exports.getPayWindowRemainingRatio=X;exports.getSoftIdleHint=Qt;exports.isAndroidDevice=Be;exports.isCheckoutPolicyBound=q;exports.isCheckoutStartAllowed=J;exports.isFullChooserPolicy=Yt;exports.isPhoneDevice=Wt;exports.isTerminalStatus=ce;exports.isValidPayerQuery=ze;exports.isValidPaymentId=_t;exports.isZippyEnvironment=Je;exports.msUntil=_;exports.normalizePayerQuery=$;exports.normalizePaymentId=V;exports.openAppStore=ae;exports.openPaymentDeepLink=Ye;exports.parseZippyEnvironment=j;exports.payerQueryValidationMessage=Ee;exports.paymentIdValidationMessage=Rt;exports.phaseFromSession=Zt;exports.renderBrandedPaymentQrSvg=Lt;exports.renderPaymentQrMarkup=Qe;exports.renderPaymentQrSvg=Tt;exports.renderQrSvg=$e;exports.renderUrlQrMarkup=We;exports.resolveApiBaseUrl=Pe;exports.resolveAppStoreOpenUrl=De;exports.resolveAppStoreUrl=jt;exports.resolveAutoStartMethod=Re;exports.resolveCheckoutUiOptions=Ue;exports.resolveCheckoutUiOptionsFromBound=te;exports.resolveCheckoutUiOptionsFromSession=He;exports.resolveEntryRouting=ee;exports.resolveMethodAvailability=vt;exports.resolveMobileAppPolicy=gt;exports.resolveTheme=lt;exports.shouldShowPayProgress=Ne;exports.subscribeCheckoutSurface=Oe;//# sourceMappingURL=index.cjs.map
1765
+ </svg>`}};function Ot(n){let e=n.timeoutMs??8e3,t=false,i=[],r=()=>{for(let p of i)p();i.length=0;},a=p=>{t||(t=true,r(),p==="opened"?n.onOpened():n.onFailed());},o=()=>{document.hidden&&a("opened");};document.addEventListener("visibilitychange",o),i.push(()=>{document.removeEventListener("visibilitychange",o);});let s=setTimeout(()=>{document.hidden?a("opened"):a("failed");},e);return i.push(()=>{clearTimeout(s);}),r}var se=class se{constructor(e){this.ui=null;this.session=null;this.paymentId="";this.verifiedPayer=null;this.verifyMatches=null;this.lastVerifiedQuery=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;this.appHandoffStatus="idle";this.clearAppHandoffWatch=null;this.methodSwitchInProgress=false;this.entryRoutingDone=false;this.payWindowExpiryTimer=null;this.unsubscribeSurface=null;if(this.config={mode:"inline",closeOnBackdropClick:false,closeOnEscape:false,...e},!it(this.config.sessionId))throw new Error("Zippy Pay: sessionId must be a UUID v4.");j(this.config.environment),this.uiOptions=Ue(this.config.checkoutPolicy,this.config.mobileApp,B()),this.client=new G({baseUrl:Pe(this.config.environment),sessionId:this.config.sessionId,clientToken:this.config.clientToken}),this.embed=ut(this.config),Ie(this.embed.host,this.config.theme),this.poller=new K(()=>this.client.getSession(),{onUpdate:t=>this.handleSessionUpdate(t),onError:t=>this.handlePollError(t)}),this.ui=new fe(this.embed.host,this.snapshotUiState(),{onChooseMethod:t=>{this.chooseMethod(t);},onVerify:t=>this.verify(t),onPay:t=>this.attach(t),onSelectPayer:t=>this.selectPayer(t),onBackToChooseMethod:()=>this.backToChooseMethod(),onBackToManualEntry:()=>this.backToManualEntry(),onBackToMobileAppFallback:()=>this.backToMobileAppFallback(),onOpenMobileApp:()=>this.beginMobileAppHandoff(),onInstallZippy:()=>this.installZippy(),onRetryMobileApp:()=>this.beginMobileAppHandoff(),onPaymentIdChange:t=>{let i=$(t),r=false;(this.verifiedPayer||this.verifyMatches)&&this.lastVerifiedQuery!==null&&i!==this.lastVerifiedQuery&&(this.verifiedPayer=null,this.verifyMatches=null,this.lastVerifiedQuery=null,(this.phase==="manual-confirm"||this.phase==="manual-picker")&&(this.phase="manual-entry"),r=true),this.errorMessage&&(this.errorMessage=null,r=true),this.paymentId=t,r&&this.syncUi();},onTerminalExit:()=>this.executeTerminalExit()},this.uiOptions),this.bootstrap(),this.unsubscribeSurface=Oe(t=>{this.handleSurfaceChange(t);}),this.config.mode==="inline"&&(this.modalOpen=true);}open(){this.config.mode!=="modal"||this.modalOpen||(this.modalOpen=true,ht(this.embed,this.config,()=>this.close()));}close(){this.config.mode==="modal"&&(this.modalOpen=false,mt(this.embed),this.config.onClose?.());}destroy(){this.destroyed||(this.destroyed=true,this.unsubscribeSurface?.(),this.unsubscribeSurface=null,this.poller.stop(),this.clearAppHandoffWatch?.(),this.clearAppHandoffWatch=null,this.clearPayWindowExpiryWatch(),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,verifyMatches:this.verifyMatches,errorMessage:this.errorMessage,loading:this.loading,mode:this.config.mode??"inline",exitMode:this.exitMode,appHandoffStatus:this.appHandoffStatus,mobileAppManualFallback:this.isMobileAppManualFallbackActive()}}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(this.snapshotUiState()));}async bootstrap(){try{let e=await this.bindPolicy();if(this.destroyed||(this.applyBoundUiOptions(e),this.applySession(e),this.destroyed))return;this.config.onReady?.(e),ce(e.status)?this.destroyed||this.syncUi({loading:!1}):(await this.routeIdleEntry(),this.destroyed||(this.syncUi({loading:!1}),this.poller.start(e)));}catch(e){this.handleBootstrapError(e);}}async bindPolicy(){let e=he({checkoutPolicy:this.config.checkoutPolicy,mobileApp:this.config.mobileApp});try{return await this.client.bindCheckoutPolicy(e)}catch(t){if(t instanceof I&&t.code==="payment-session.checkout-policy-conflict"){let i=await this.client.getSession();if(q(i))return i}throw t}}applyBoundUiOptions(e,t=B()){this.uiOptions=He(e,t),this.ui?.updateUiOptions(this.uiOptions);}handleSurfaceChange(e){if(this.destroyed||this.committedMethod)return;let t=this.session;!t||!q(t)||this.uiOptions.surface!==e&&(this.uiOptions=te(t.checkoutPolicy,t.mobileAppPolicy??"OFF",e),this.ui?.updateUiOptions(this.uiOptions),(this.phase==="choose-method"||this.phase==="loading")&&this.syncUi());}applySession(e,t){if(this.session=e,this.config.onSessionUpdate?.(e),e.transactionStatus==="DECLINED"&&e.status!=="COMPLETED"){this.methodSwitchInProgress=false,this.handleFailure({reason:"declined",session:e});return}if(e.status==="COMPLETED"){this.methodSwitchInProgress=false,this.handleSuccess(e);return}if(e.status==="EXPIRED"){this.methodSwitchInProgress=false,this.handleFailure({reason:"expired",session:e});return}if(e.status==="FAILED"){this.methodSwitchInProgress=false,this.handleFailure({reason:"failed",session:e});return}if(e.status==="CANCELLED"){this.methodSwitchInProgress=false,this.handleFailure({reason:"cancelled",session:e});return}if(this.isMobileAppManualFallbackActive()&&!t?.fromMethodSwitch){this.schedulePayWindowExpiryWatch(),this.syncUi();return}this.committedMethod=mi(e.checkoutMethod)??this.committedMethod,this.phase=this.resolveActivePhase(e),this.schedulePayWindowExpiryWatch(),this.syncUi();}schedulePayWindowExpiryWatch(){this.clearPayWindowExpiryWatch();let e=this.session;if(!e?.paymentExpiryAt||!se.PAY_WINDOW_PHASES.includes(this.phase))return;let t=_(e.paymentExpiryAt);if(t<=0){this.handlePayWindowExpired();return}this.payWindowExpiryTimer=setTimeout(()=>{this.handlePayWindowExpired();},t+250);}clearPayWindowExpiryWatch(){this.payWindowExpiryTimer!==null&&(clearTimeout(this.payWindowExpiryTimer),this.payWindowExpiryTimer=null);}async handlePayWindowExpired(){if(!(this.destroyed||!this.session?.paymentExpiryAt)){if(_(this.session.paymentExpiryAt)>0){this.schedulePayWindowExpiryWatch();return}if(se.PAY_WINDOW_PHASES.includes(this.phase))try{let e=await this.client.getSession();if(this.destroyed)return;this.applySession(e);}catch{this.destroyed||this.handleFailure({reason:"expired",session:this.session});}}}resolveActivePhase(e){return e.status==="AWAITING_PAYMENT"?e.checkoutMethod==="MOBILE_APP"||this.committedMethod==="mobileApp"?"mobile-app-active":e.checkoutMethod==="QR"||this.committedMethod==="qr"?"qr-active":"awaiting":e.phase==="PAYING"&&e.checkoutMethod==="MOBILE_APP"?"mobile-app-active":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?"manual-confirm":this.phase==="manual-picker"&&this.verifyMatches?"manual-picker":this.phase==="manual-entry"?"manual-entry":this.phase==="choose-method"?"choose-method":this.phase==="qr-active"&&this.committedMethod==="qr"?"qr-active":this.phase==="mobile-app-active"&&this.committedMethod==="mobileApp"?"mobile-app-active":!e.checkoutMethod&&ee(this.uiOptions.checkoutPolicy,this.uiOptions.mobileAppPolicy,this.uiOptions.surface)!=="chooser"?"loading":"choose-method":this.phase}handleSessionUpdate(e){this.destroyed||this.applySession(e);}handleFailure(e){if(this.destroyed)return;this.poller.stop(),this.clearPayWindowExpiryWatch(),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"?hi(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.clearPayWindowExpiryWatch(),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(Te(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"?Te(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 I&&e.status===401){this.handleFailure({reason:"invalid-session",error:e,session:this.session});return}this.handleError(e);}handlePollError(e){let t=je(e);if(t.status===401){this.poller.stop(),this.handleFailure({reason:"invalid-session",error:t,session:this.session});return}if(t.code==="payment-session.not-attachable"){this.poller.stop(),this.handleFailure({reason:"expired",session:this.session});return}}handleError(e){let t=je(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}if(t.code==="payment-session.checkout-policy-not-bound"){(this.phase==="loading"||this.phase==="choose-method")&&(this.phase="error"),this.syncUi({errorMessage:t.detail||"Checkout is not ready yet. Please refresh and try again.",loading:false}),this.config.onError?.(t),this.poller.stop();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 routeIdleEntry(){if(this.destroyed||this.entryRoutingDone)return;let e=this.session;if(!e||ce(e.status))return;if(e.checkoutMethod){this.entryRoutingDone=true;return}if(e.phase!=="IDLE")return;let t=B(),{checkoutPolicy:i,mobileAppPolicy:r}=this.uiOptions,a=Re(i,r,t);a==="MOBILE_APP"?await this.startMobileAppFlow(false):a==="QR"?await this.chooseMethod("qr"):ee(i,r,t)==="auto-manual"?(this.phase="manual-entry",this.syncUi({loading:false})):(this.phase="choose-method",this.syncUi({loading:false})),this.entryRoutingDone=true;}openMobileApp(){Ye(this.config.sessionId);}beginMobileAppHandoff(){this.destroyed||(this.clearAppHandoffWatch?.(),this.clearAppHandoffWatch=null,this.appHandoffStatus="opening",this.syncUi(),this.openMobileApp(),this.clearAppHandoffWatch=Ot({onOpened:()=>{this.destroyed||(this.appHandoffStatus="opened",this.syncUi());},onFailed:()=>{this.destroyed||(this.appHandoffStatus="failed",this.syncUi());}}));}installZippy(){ae();}async startMobileAppFlow(e){if(this.session?.checkoutMethod==="MOBILE_APP"){this.committedMethod="mobileApp",this.phase="mobile-app-active",e&&this.beginMobileAppHandoff(),this.syncUi({loading:false});return}if(this.committedMethod&&this.committedMethod!=="mobileApp")return;let t=B();if(this.canStartAppClaim("MOBILE_APP",t)){e?(this.committedMethod="mobileApp",this.phase="mobile-app-active",this.beginMobileAppHandoff()):this.syncUi({errorMessage:null,loading:true});try{let i=await this.client.startMobileAppCheckout(t);if(this.committedMethod="mobileApp",this.applySession(i),this.destroyed)return;this.phase="mobile-app-active",this.syncUi({loading:!1});}catch(i){this.handleFlowError(i,"choose-method");}}}canStartAppClaim(e,t){if(!this.session||!q(this.session))return this.syncUi({errorMessage:"Checkout is not ready yet. Please refresh and try again.",loading:false}),false;let i=this.session.checkoutPolicy,r=this.session.mobileAppPolicy??"OFF";return J(i,r,t,e)?true:(this.syncUi({errorMessage:"This payment option is not available on your device.",loading:false}),false)}async chooseMethod(e){if(!this.methodSwitchInProgress&&!(this.committedMethod&&!(this.appHandoffStatus==="failed"&&this.committedMethod==="mobileApp"&&e!=="mobileApp"))){if(this.appHandoffStatus==="failed"&&this.committedMethod==="mobileApp"&&(e==="qr"||e==="manual")){await this.chooseFallbackMethod(e);return}if(e==="mobileApp"){await this.startMobileAppFlow(true);return}this.verifiedPayer=null,this.syncUi({errorMessage:null,loading:e==="qr"});try{if(e==="qr"){let t=B();if(!this.canStartAppClaim("QR",t))return;let i=await this.client.startQrCheckout(t);if(this.committedMethod="qr",this.applySession(i),this.destroyed)return;this.syncUi({loading:!1});}else this.phase="manual-entry",this.syncUi({loading:!1});}catch(t){this.handleFlowError(t,"choose-method");}}}async chooseFallbackMethod(e){if(!(this.appHandoffStatus!=="failed"||this.committedMethod!=="mobileApp"||this.methodSwitchInProgress)){if(this.clearAppHandoffWatch?.(),this.clearAppHandoffWatch=null,e==="manual"){this.methodSwitchInProgress=true,this.appHandoffStatus="idle",this.verifiedPayer=null,this.verifyMatches=null,this.lastVerifiedQuery=null,this.paymentId="",this.phase="manual-entry",this.syncUi({errorMessage:null,loading:false});return}this.methodSwitchInProgress=true,this.verifiedPayer=null,this.syncUi({errorMessage:null,loading:true});try{let t=B(),i=await this.client.startQrCheckout(t);if(this.destroyed)return;this.methodSwitchInProgress=!1,this.appHandoffStatus="idle",this.loading=!1,this.applySession(i,{fromMethodSwitch:!0});}catch(t){this.methodSwitchInProgress=false,this.handleFlowError(t,"mobile-app-active");}}}backToChooseMethod(){this.uiOptions.allowManualBack&&(this.committedMethod||this.loading&&this.verifiedPayer||(this.phase="choose-method",this.paymentId="",this.verifiedPayer=null,this.verifyMatches=null,this.lastVerifiedQuery=null,this.errorMessage=null,this.loading=false,this.syncUi({errorMessage:null,loading:false})));}backToManualEntry(){this.loading&&this.verifiedPayer||(this.phase="manual-entry",this.verifiedPayer=null,this.verifyMatches=null,this.lastVerifiedQuery=null,this.errorMessage=null,this.loading=false,this.syncUi({errorMessage:null,loading:false}));}backToMobileAppFallback(){this.loading&&this.verifiedPayer||this.isMobileAppManualFallbackActive()&&(this.methodSwitchInProgress=false,this.appHandoffStatus="failed",this.phase="mobile-app-active",this.paymentId="",this.verifiedPayer=null,this.verifyMatches=null,this.lastVerifiedQuery=null,this.errorMessage=null,this.loading=false,this.syncUi({errorMessage:null,loading:false}));}isMobileAppManualFallbackActive(){return this.committedMethod!=="mobileApp"?false:this.methodSwitchInProgress?true:this.session?.checkoutMethod==="MOBILE_APP"&&(this.phase==="manual-entry"||this.phase==="manual-picker"||this.phase==="manual-confirm")}selectPayer(e){this.loading||this.phase!=="manual-picker"||(this.verifiedPayer=e,this.phase="manual-confirm",this.errorMessage=null,this.syncUi({errorMessage:null,loading:false}));}async verify(e){if(this.paymentId=e,!ze(e)){this.syncUi({errorMessage:Ee(),loading:false});return}let t=$(e);this.syncUi({errorMessage:null,loading:true});try{let{items:i}=await this.client.verifyPayer(e);if(this.phase!=="manual-entry")return;this.lastVerifiedQuery=t,this.verifyMatches=null,i.length===1?(this.verifiedPayer=i[0],this.phase="manual-confirm"):(this.verifiedPayer=null,this.verifyMatches=i,this.phase="manual-picker"),this.syncUi({loading:!1});}catch(i){this.handleFlowError(i,"manual-entry");}}async attach(e){if(!this.verifiedPayer){this.syncUi({errorMessage:"Find your account before proceeding to pay.",loading:false});return}this.syncUi({errorMessage:null,loading:true});try{let t=await Le(this.client,this.verifiedPayer.paymentId);if(this.methodSwitchInProgress=!1,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=je(e),r=yi(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 if(i.code==="payment-session.checkout-policy-not-bound"){this.syncUi({errorMessage:r,loading:false}),this.config.onError?.(i);return}else if(i.code==="payment-session.checkout-policy-denied"||i.code==="payment-session.checkout-policy-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();q(e)&&this.applyBoundUiOptions(e),this.applySession(e);}catch{}}};se.PAY_WINDOW_PHASES=["qr-active","mobile-app-active","awaiting","manual-confirm"];var ge=se;function hi(n){return n==="failed"?new I({code:"payment-session.failed",status:400,title:"Payment failed",detail:"Something went wrong with this payment."}):n==="declined"?new I({code:"payment-session.declined",status:400,title:"Payment declined",detail:"Your payment was declined."}):new I({code:"payment-session.cancelled",status:400,title:"Payment cancelled",detail:"This payment was cancelled."})}function mi(n){return n==="QR"?"qr":n==="MANUAL"?"manual":n==="MOBILE_APP"?"mobileApp":null}function yi(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")?"No Zippy account found":n.detail?.trim()||"Something went wrong. Please try again."}function je(n){return n instanceof I?n:new I({code:"unknown",status:500,title:"Unexpected error",detail:n instanceof Error?n.message:"An unexpected error occurred"})}function pe(n){return new ge(n)}var Ve="zippy-pay-checkout",_t={"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"},be=class extends HTMLElement{constructor(){super(...arguments);this.instance=null;}static get observedAttributes(){return ["mode","session-id","environment","checkout-policy","mobile-app-policy",...Object.keys(_t)]}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=pe({...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 o;try{o=j(t);}catch{return null}let s={};for(let[p,d]of Object.entries(_t)){let g=this.getAttribute(p);g&&(d==="mode"?s.mode=g:s[d]=g);}return {environment:o,sessionId:i,clientToken:r,mode:a,theme:s,checkoutPolicy:fi(this.getAttribute("checkout-policy")),mobileApp:gi(this.getAttribute("mobile-app-policy"))}}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 fi(n){if(n==="QR"||n==="MANUAL")return n}function gi(n){if(n==="option"||n==="enforce")return {policy:n}}function Ge(){typeof customElements>"u"||customElements.get(Ve)||customElements.define(Ve,be);}var bi={create(n){let e=pe(n);return (n.mode??"inline")==="modal"&&e.open(),e}};Ge();var Ln=bi;exports.ANDROID_APP_PACKAGE=ie;exports.ANDROID_PLAY_STORE_NATIVE_URL=Pt;exports.APP_STORE_LINKS=ne;exports.CheckoutController=ge;exports.DEFAULT_THEME=pt;exports.E164_PHONE_PATTERN=et;exports.ELEMENT_TAG=Ve;exports.EMAIL_PATTERN=tt;exports.IOS_APP_STORE_NATIVE_URL=wt;exports.PAYMENT_ID_PATTERN=ke;exports.POLLABLE_STATUSES=xe;exports.PaymentSessionClient=G;exports.SessionPoller=K;exports.TERMINAL_STATUSES=Y;exports.ZIPPY_API_BASE_URLS=le;exports.ZIPPY_API_PATH_PREFIX=we;exports.ZippyPay=bi;exports.ZippyPayCheckoutElement=be;exports.ZippyPayError=I;exports.applyThemeToHost=Ie;exports.attachPayerWithRetry=Le;exports.buildAndroidPaymentIntentUrl=Nt;exports.buildBindPolicyRequest=he;exports.buildPaymentDeepLinkOpenUrl=Bt;exports.buildPaymentQrPayload=me;exports.createCheckout=pe;exports.default=Ln;exports.defineZippyPayCheckoutElement=Ge;exports.detectCheckoutSurface=B;exports.formatAmount=Ce;exports.getCountdownTarget=yt;exports.getPayWindowRemainingRatio=X;exports.getSoftIdleHint=Wt;exports.isAndroidDevice=Be;exports.isCheckoutPolicyBound=q;exports.isCheckoutStartAllowed=J;exports.isFullChooserPolicy=jt;exports.isPhoneDevice=Yt;exports.isTerminalStatus=ce;exports.isValidPayerQuery=ze;exports.isValidPaymentId=Rt;exports.isZippyEnvironment=Je;exports.msUntil=_;exports.normalizePayerQuery=$;exports.normalizePaymentId=V;exports.openAppStore=ae;exports.openPaymentDeepLink=Ye;exports.parseZippyEnvironment=j;exports.payerQueryValidationMessage=Ee;exports.paymentIdValidationMessage=Ht;exports.phaseFromSession=qt;exports.renderBrandedPaymentQrSvg=It;exports.renderPaymentQrMarkup=Qe;exports.renderPaymentQrSvg=Lt;exports.renderQrSvg=$e;exports.renderUrlQrMarkup=We;exports.resolveApiBaseUrl=Pe;exports.resolveAppStoreOpenUrl=De;exports.resolveAppStoreUrl=Vt;exports.resolveAutoStartMethod=Re;exports.resolveCheckoutUiOptions=Ue;exports.resolveCheckoutUiOptionsFromBound=te;exports.resolveCheckoutUiOptionsFromSession=He;exports.resolveEntryRouting=ee;exports.resolveMethodAvailability=vt;exports.resolveMobileAppPolicy=gt;exports.resolveTheme=lt;exports.shouldShowPayProgress=Ne;exports.subscribeCheckoutSurface=Oe;//# sourceMappingURL=index.cjs.map
1766
1766
  //# sourceMappingURL=index.cjs.map