1import{z as e,g as n,h as a,u as t,J as l,q as o,T as i,S as c}from"./2c1ab0fe.Bf8FS-kA.js";import{r,f as s,s as d,bi as m,b as p,ab as u,S as h,B as _,a1 as g,d as f,M as b,c6 as y}from"./164ad2e3.D0nOfU9-.js";import{Q as w,C as x}from"./3e6029dd.BwmLr1gv.js";import"./app.C_ntWzAC.js";import{bJ as k,c as S,v as M,bK as v}from"./4b4bc88f.DcJe9bVW.js";import"./d0bb51ec.CL_3Kdjr.js";import"./f67abd2c.CMIDVCe_.js";import"./60a453ce.0K3_0kXS.js";import"./e12db40c.B4InVJ1F.js";import"./9dba8418.CZTcH8_l.js";var z="var(--_1cm3fw00)";const C=d("Countdown");function I({duration:o=0,defaultValue:i=o,label:c,onEnd:d}){const m=r(void 0,C),[p]=e(()=>Date.now()+i),[u,h]=e(()=>Math.max(i,0)),_=n(d),g=n(!1);_.current=d,a(()=>{let e;const n=()=>{const a=Math.max(p-Date.now(),0);h(a),0!==a?e=setTimeout(n,a%1e3||1e3):g.current||(g.current=!0,_.current?.())};return n(),()=>clearTimeout(e)},[p]);const f=o>0?Math.min(Math.max((o-u)/o*100,0),100):0;return t("div",{role:c?"timer":void 0,"aria-labelledby":c?m:void 0,className:"_1cm3fw02 _1cm3fw01 _1fragem6t _1fragemzf _1fragem82",children:[t("div",{"aria-hidden":!0,className:"_1cm3fw04 _1cm3fw03 _1fragemup _1fragemv4 _1fragemzf _1fragem32",style:l({[z]:`${f}%`}),children:t("div",{className:"_1cm3fw06 _1cm3fw05 _1fragem4q"})}),c&&t(s,{id:m,accessibilityVisibility:"hidden",type:"small",textAlign:"center",color:"subdued",children:c(u)})]})}function E(e=navigator.userAgent,n){return k(e)||/Shop App\/[^/]+\/iOS\//.test(e)||null!=n&&"WEB"!==n}const R=new Set(["alipay","bancontact","blik","eps","ideal","klarna","mobilepay","multibanco","paypal","przelewy24","satispay","sofort","swish","twint","usdc","wechatpay"]);function D(e){return e.toLowerCase().replace(/[\s_-]+/gu,"")}const A=e=>{const n=Math.floor(e/36e5),a=String(Math.floor(e%36e5/6e4)).padStart(2,"0"),t=String(Math.floor(e%6e4/1e3)).padStart(2,"0");return n>0?`${n}:${a}:${t}`:`${a}:${t}`},T={bogus_app_coin:"/cdn/shopifycloud/checkout-web/assets/c1/assets/bogus.Dgqxw51f.svg",pix:"/cdn/shopifycloud/checkout-web/assets/c1/assets/pix.D3fYfWH5.svg",blik:"/cdn/shopifycloud/checkout-web/assets/c1/assets/blik.DVGmDGpj.svg",swish:"/cdn/shopifycloud/checkout-web/assets/c1/assets/swish.Bmk5gRpD.svg"},q=["wechat_pay","paynow"];function j({challengeType:l,challengeData:r,receipt:d,paymentMethod:k,onModalRender:z,challengeExpiresAt:C}){const j=((e,n)=>null!=n?Math.max(n-Date.now(),0):e&&y(e)&&e.timeout?.millisecondsRemaining||0)(d,C),[O,N]=e(!1),[$,L]=e(),[Q]=e(j),{i18n:B,client:J,embed:V}=S(),W=function(e){const{paymentMethod:n}=e,{userEvents:a,shop:{id:t},source:l}=S(),c=o(e=>a.monorailEvent({schemaId:"checkout_buyer_action_required_events/1.0",payload:{eventTriggerReason:e,paymentMethodDisplayName:n.name,checkoutSessionIdentifier:l.checkoutSessionIdentifier||"",shopId:parseInt(M(t),10)}}),[n.name,t,l.checkoutSessionIdentifier,a]);return i(()=>({onModalRendered:()=>c("modal_rendered"),onModalTimeout:()=>c("buyer_action_timeout"),onModalExit:()=>c("buyer_closes_modal"),onCopiedToClipboard:()=>c("buyer_copies_to_clipboard"),onChallengeRendered:e=>{switch(e){case"QR_CODE":c("qr_code_rendered");break;case"EXTERNAL":c("external_action_rendered")}}}),[c])}({paymentMethod:k}),F=n(null);i(()=>{O&&z&&setTimeout(()=>{z()},1e3)},[O,z]);const G=o(()=>d?(W.onModalTimeout(),N(!1),null):null,[d,W]);let X,H;a(()=>{l&&r&&Q&&(L(JSON.parse(r)),N(!0))},[l,r,Q]);let K,P,Y=!1;switch(l){case"QR_CODE":if(X=B.translate("payment_challenge_modal.qr_code.instructions",{paymentMethod:k.name}),$){const e=JSON.parse($.data);H=e?.mobile_app_universal_url,K=e?.instruction,Y=q.includes(e?.instruction),"wechat_pay"===e?.instruction?("string"==typeof e.cancellation_url&&e.cancellation_url.startsWith("https://")&&"string"==typeof e.cancellation_auth_token&&e.cancellation_auth_token&&(P={url:e.cancellation_url,token:e.cancellation_auth_token}),X=E(J.userAgent,V?.platform)?B.translate("payment_challenge_modal.qr_code.wechat_instructions_mobile"):B.translate("payment_challenge_modal.qr_code.wechat_instructions")):"paynow"===e?.instruction&&(X=E(J.userAgent,V?.platform)?B.translate("payment_challenge_modal.qr_code.paynow_instructions_mobile"):B.translate("payment_challenge_modal.qr_code.paynow_instructions"))}break;case"EXTERNAL":X=B.translate("payment_challenge_modal.external.instructions",{paymentMethod:k.name});break;default:X=B.translate("payment_challenge_modal.instructions",{paymentMethod:k.name})}a(()=>{O&&$&&W.onModalRendered()},[O,$,W]),a(()=>{$&&W.onChallengeRendered(l)},[W,$,l]);const U=B.translate("payment_challenge_modal.copy_text",{paymentMethod:k.name}),Z=B.translate("payment_challenge_modal.open_app_text",{paymentMethod:k.name}),ee=H?Z:U,ne=B.translate("payment_challenge_modal.header",{paymentMethod:k.name}),ae=B.translate("payment_challenge_modal.close"),te=(e=>{const n=v(e);return n?T[n]:null})(k),le="QR_CODE"===l?function(e){for(const n of e){if("string"!=typeof n||""===n)continue;const e=D(n);if(R.has(e))return`https://cdn.shopify.com/static/retail/lpm-icons/png/square-icons/${e}.png`}}([K,...k.paymentBrands??[]]):void 0;return d&&t(b,{open:O,blocking:!0,accessibilityLabel:ne,size:"base",children:[P&&t(m,{children:t("form",{ref:F,action:P.url,method:"POST",hidden:!0,children:t("input",{type:"hidden",name:"cancellation_auth_token",value:P.token})})}),t(p,{children:[t(u,{gridAutoFlow:"column",gridTemplateColumns:"minmax(0, 1fr) minmax(auto, max-content)",gridTemplateRows:"minmax(0, 1fr)",gap:"large-300",alignItems:"center",alignContent:"center",children:[t(s,{size:"large",textAlign:"start",children:ne}),t(h,{gap:"small-400",alignItems:"end",children:t(_,{onClick:()=>
1(W.onModalExit(),void(F.current?F.current.submit():window.location.reload())),variant:"plain",tone:"monochrome",inlineAlignment:"end",accessibilityLabel:ae,children:t(g,{type:"x"})})})]}),t(p,{children:[t(f,{blockSize:"base"}),te&&!le&&t(c,{children:[t(h,{gap:"large-300",alignItems:"center",children:t("img",{src:te,alt:k.name})}),t(f,{blockSize:"small-400"})]}),t(h,{gap:"large-300",alignItems:"center",children:t(s,{size:"base",textAlign:"center",textWrap:"pretty",children:X})}),"QR_CODE"===l&&$&&t(c,{children:[t(f,{blockSize:"base"}),t(h,{gap:"base",alignItems:"center",children:[t(h,{gap:"base",maxInlineSize:"150px",minInlineSize:"150px",alignItems:"center",children:t(w,{content:$?.code,size:"fill",logo:le},le)}),!Y&&t(c,{children:[t(f,{blockSize:"large-200"}),t(h,{gap:"base",alignItems:"center",maxInlineSize:"400px",minInlineSize:"@media (inline-size >= extraSmall) 400px, 100%",children:t(_,{commandFor:"qr-code-challenge-data-code",command:H?void 0:"--copy",inlineSize:"fill",inlineAlignment:"center",onClick:()=>{H&&(window.open(H,"_blank"),W.onChallengeRendered("QR_CODE"))},children:ee})}),!H&&t(x,{text:$?.code,id:"qr-code-challenge-data-code",onCopy:()=>W.onCopiedToClipboard()})]})]})]}),t(f,{blockSize:"large-200"}),t(h,{alignItems:"center",children:t(p,{maxInlineSize:"150px",minInlineSize:"150px",children:t(I,{duration:Q,defaultValue:j,label:e=>B.translate("payment_challenge_modal.timer_message",{timeLeft:A(e)}),onEnd:G})})}),t(f,{blockSize:"large-200"})]})]})]})}export{T as SUPPORTED_PAYMENT_METHOD_BRAND_ICONS,j as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.