import{y as g,q as f,u as m}from"./dist-vendor.C4_qYgK9.js";import{a as p,L,b as M}from"./approval-scopes-FullScreenBackground.BMvb4DkL.js";import{aC as C,L as S,T as w}from"./hooks-ButtonWithRegisterWebPixel.BS-QmNv3.js";function N(e){g(()=>{document.title=e},[e])}function K(e){g(()=>{let s=document.querySelector("link[rel=icon]");s?s.href=e:(s=document.createElement("link"),s.rel="icon",s.type="image/png",s.href=e,document.head.appendChild(s))},[e])}const j=()=>{const{environment:{services:{shopServer:e}},shop:{myshopifyDomain:s},source:{checkoutSessionIdentifier:n},url:t}=p();return{exchangeSessionTokenForCookie:f(async({token:o,origin:l,analytics_trace_id:d})=>{const c=new URLSearchParams({token:o,origin:l,shopify_domain:s});n&&c.set("checkout_token",n),d&&c.set("analytics_trace_id",d);const u=new URL(t.shopPaySession(),e.url);return u.search=c.toString(),fetch(u.href,{method:"POST",keepalive:!0})},[n,s,t,e.url])}},q=()=>{const{environment:{services:{shopServer:e}},shop:s}=p(),n=parseInt(L(s.id),10);return{extendBuyerIdentity:f(async()=>{await fetch(new URL(`/checkout/${n}/shopify_pay/extend_buyer_identity`,e.url),{method:"GET",keepalive:!0})},[n,e.url])}},b="shopify_pay",y=":";var a=(e=>(e.Closed="closed",e.EmailChanged="emailChanged",e.Error="error",e.Hidden="hidden",e.Loaded="loaded",e.LoggedIn="loggedIn",e.Ready="ready",e.Resized="resized",e.ShareCaptchaToken="shareCaptchaToken",e))(a||{}),F=(e=>(e.AllowNoInitialEmail="allowNoInitialEmail",e.Create="create",e.Hidden="hidden",e.OriginChanged="originChanged",e.Ready="ready",e.CheckoutQueueToken="checkoutQueueToken",e))(F||{}),U=(e=>(e.ShopifyPayUserNotFound="shopify_pay_user_not_found",e))(U||{}),D=(e=>(e.FraudGuard="fraud_guard",e.InvalidEmail="invalid_email",e.InvalidPhone="invalid_phone",e.LimitExceeded="limit_exceeded",e.PhoneBlocked="phone_blocked",e.RecordNotFound="record_not_found",e))(D||{});function B(e,s={delimiter:y,messageKey:b}){return[s.messageKey,s.delimiter,JSON.stringify(e)].join("")}function O(e){return B(e)}function H(e,s){e&&e.contentWindow?.postMessage(O(s),"*")}function J({targetId:e,onLoaded:s,onClosed:n,onHidden:t,onError:i,onLoggedIn:o,onReady:l,onResized:d,onShareCaptchaToken:c,onEmailChange:u,skip:k=!1}){const v=f(r=>{switch(r.action){case a.Closed:return n?.();case a.Hidden:return t?.();case a.Error:return i?.(r.message,r.apiError,r.email);case a.Loaded:return s?.();case a.LoggedIn:return o?.(r.token,r.shop_pay_access_token);case a.Ready:return l?.(r.phoneNumber);case a.Resized:return d?.(parseInt(r.height,10));case a.ShareCaptchaToken:return c?.(r.token);case a.EmailChanged:return u?.(r.email,r.isUserFound)}},[n,t,i,s,o,l,d,c,u]),{environment:T}=p(),x=T.services.payShopifyCom.url;g(()=>{if(k)return;const r=({data:h,origin:P})=>{if(P!==x||!h||typeof h!="string"||!h.includes(y))return;const[E,...I]=h.split(y);if(E===b)try{const _=JSON.parse(I.join(y));(e&&_.targetId===e||!e)&&v(_)}catch{}};return window.addEventListener("message",r),()=>{window.removeEventListener("message",r)}},[v,x,e,k])}function Q({hasError:e,children:s}){const{i18n:n,shop:t}=p(),i=e?`${n.translate("general.error_page_title")} - `:"",o=t?n.translate("general.full_title",{pageTitle:`${i}${s}`,shopName:t.name}):n.translate("general.loading_title");return N(o),null}function R({textProps:e}){const{i18n:s,shop:{name:n}}=p(),o=M().managedMarketsPaymentProcessor?.value==="shopify_payments"?"https://content.global-e.com/shopper-terms-v2":"https://content.global-e.com/shopper-terms",l={markets_pro_terms:m(S,{textDecoration:"none",overlay:m(C,{source:o,heading:s.translate("payment.markets_pro_disclaimer_terms_and_conditions_title")}),children:s.translate("payment.markets_pro_disclaimer_terms_and_conditions")}),privacy_policy:m(S,{textDecoration:"none",overlay:m(C,{source:"https://content.global-e.com/privacy-policy",heading:s.translate("payment.markets_pro_disclaimer_privacy_policy_title")}),children:s.translate("payment.markets_pro_disclaimer_privacy_policy")}),shop_name:n};return m(w,{...e,children:s.translate("payment.markets_pro_disclaimer_label",l)})}export{D as A,y as D,R as M,a as R,F as S,Q as T,b as a,j as b,q as c,J as d,K as e,U as f,H as p,N as u};
