1var e,t,s,n,r,i,o,a,c,u,p,d,l,h,m,f,y,g,b=e=>{throw TypeError(e)},v=(e,t,s)=>t.has(e)||b("Cannot "+s),_=(e,t,s)=>(v(e,t,"read from private field"),s?s.call(e):t.get(e)),k=(e,t,s)=>t.has(e)?b("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),C=(e,t,s,n)=>(v(e,t,"write to private field"),n?n.call(e,s):t.set(e,s),s),w=(e,t,s)=>(v(e,t,"access private method"),s);import{v as E,ah as I,w as P}from"./2c1ab0fe.qpvfywqb.js";import{cu as R,f3 as S,y as j,f4 as A,f5 as x,cw as q,f6 as D,f7 as T,f8 as M,f9 as O}from"./4b4bc88f.DkycdxSK.js";import{U as L,E as N,D as U,b as H,O as F,a as z,R as Y,c as W,d as B,i as V,e as $,f as K,I as G,g as Z,h as J,j as Q,k as X,l as ee}from"./24dc440e.DMrYLCcz.js";import{E as te,a as se,b as ne,c as re,d as ie,e as oe}from"./5c5c2e96.BDcgz6pV.js";import{a as ae,b as ce}from"./d25d1b95.CoPrVoCi.js";import{a as ue}from"./f67abd2c.CNaB0QaR.js";import{b as pe,a as de,c as le,s as he,P as me}from"./711bf263.DLsg-PFP.js";import{B as fe}from"./7b900b08.DUY5nH3Z.js";import{g as ye}from"./500b6130.DUn4Te8e.js";import"./app.DH8n-1bp.js";import"./f1968089.BiyF2g2x.js";import"./e477f96c.Bg2MTFPd.js";import"./cadec7c0.Dr7b1Jee.js";import"./e12db40c.DhbHW8sF.js";import"./41e85f1e.BBeZocPi.js";const ge=class c{constructor(u,d){k(this,o),k(this,e),k(this,t),k(this,s),k(this,n),k(this,r),k(this,i),this.version=c.version,C(this,e,u),C(this,i,d),C(this,t,new L({context:u,toMinorUnits:He,findSelectedInstrument:e=>w(this,o,p).call(this,e)})),C(this,s,new N({extensions:[_(this,t)],getCheckout:()=>_(this,r).peek()})),C(this,n,E(()=>{const n=function(e,t){const{checkout:s,shop:n,i18n:r,embed:i,negotiationContext:o}=e,{merchandiseLines:a,runningTotal:c,subtotal:u,discountLines:p,taxes:d,ucp:l}=s.proposal.negotiated.fields,{id:h,paymentHandlers:m}=l.value??{};if(null==h)return;const f={...e.ucp.checkout.buyer.negotiated.value},y=s.latestReceipt.value,g=function(e){const t=e?.find(e=>"wallet"===e.method.type||"walletsPlatformPaymentMethod"===e.method.type&&e.method.name in Ne);if(t)return Ne[t.method.name];const s=e?.some(e=>"redeemable"===e.method.type&&"SHOP_CASH"===e.method.redemptionSource);return s?"shop_pay":void 0}("processed"===y?.status?y.purchaseOrder.paymentLines:void 0),b=o?.delegatedPaymentInstrument?.value,v=function(e,t,s,n){return e?Le(e,s,n)?[]:ce(e)?function({instrument:e,proposalBillingAddress:t}){return[{id:e.externalReferenceId,handler_id:"shopify.card",type:"card",selected:!0,display:{last_digits:e.lastDigits,brand:e.brand?.toLowerCase()},cardholder_name:e.cardHolderName,expiry_month:e.month,expiry_year:e.year,billing_address:t}]}({instrument:e,proposalBillingAddress:t}):[{...e,selected:!0,billing_address:t}]:[]}(b,qe(s.proposal.proposed.billingAddress.value),g,t),_=[];for(const O of n.merchantPolicies){const e=ve.get(O.handle);e&&_.push({type:e,url:O.url,title:r.translate("shop_policies",{scope:O.handle.replace(/-/g,"_")})})}const k="microsoft"!==i.embedder,{lineItems:C,itemsDiscountAmount:w}=function({lines:e,specCompliantDiscounts:t}){if(!e?.length)return{lineItems:[],itemsDiscountAmount:0};let s=0;return{lineItems:e.map(e=>{const n=e.itemPrice,r=n?{...n,amount:n.amount*e.quantity}:void 0,i=function(e,t){return e.reduce((e,s)=>e+s.allocations.reduce((e,{discountDetails:{discount:s},amount:n})=>t||"discountCodeTrigger"!==s.type?e+n.amount:e,0),0)}(e.lineAllocations,t),o=[];r&&o.push({type:"subtotal",amount:He(r)}),0!==i&&r&&(t&&(s+=i),o.push({type:t?"items_discount":"discount",amount:He({...r,amount:t?i:-i})}));const a=t&&r&&0!==i?{...r,amount:r.amount-i}:e.totalPrice;return o.push({type:"total",amount:He(a)}),{id:je(e),parent_id:e.parentRelationship?.parent?.id??void 0,quantity:e.quantity,item:{id:e.variantId,title:e.title,price:He(n),...e.image?.url?{image_url:e.image.url}:{}},totals:o}}),itemsDiscountAmount:s}}({lines:a.value?.lines,specCompliantDiscounts:k}),E=[],I=u.value,P=(k?(R=a.value?.lines,R?R.reduce((e,t)=>{const s=t.itemPrice;if(!s)return e;const n=s.amount*t.quantity;return e?{...e,amount:e.amount+n}:{...s,amount:n}},void 0):void 0):void 0)??I;var R;if(null!=P&&E.push({type:"subtotal",display_text:"Subtotal",amount:He(P)}),k&&null!=P&&E.push(...function({currencyCode:e,discountLines:t,itemsDiscountAmount:s}){let n=0;if(t?.lines?.length)for(const i of t.lines)if(ue(i))for(const e of i.allocations)"DELIVERYLINE"===e.target.type&&(n+=e.target.amount.amount);const r=[];return s>0&&r.push({type:"items_discount",display_text:"Discounts",amount:He({amount:s,currencyCode:e})}),n>0&&r.push({type:"discount",display_text:"Discount",amount:He({amount:n,currencyCode:e})}),r}({currencyCode:P.currencyCode,discountLines:p?.value,itemsDiscountAmount:w})),k){const e=function({checkout:e}){const{deliveryNext:t}=e.proposal.negotiated.fields,s=t.value;if("filled"!==s?.status||!s.lines)return;let n,r=0;for(const i of s.lines){if("available"!==i.status)continue;const e=i.selectedDeliveryMethodHandle;if(!e)continue;const t=i.methods.find(t=>t.handle===e);t?.costAfterDiscounts&&(r+=t.costAfterDiscounts.amount,n??=t.costAfterDiscounts.currencyCode)}return null==n?void 0:{amount:r,currencyCode:n}}({checkout:s});null!=e&&E.push({type:"fulfillment",display_text:"Shipping",amount:He(e)})}const S=d.value,j=s.proposal.facts.tax??("available_total"===S?.status?S.totalTax:void 0);null!=j&&E.push({type:"tax",display_text:"Taxes",amount:He(j)});const A=c.value;null!=A&&E.push({type:"total",display_text:"Total",amount:He(A)});const x=k,q=function({checkout:e,discountExtensionEnabled:t}){const s=new Map,n=e.proposal.negotiated.fields.allViolations.value??[];for(const r of n){if(F.has(r.__typename))continue;if(z.has(r.code))continue;let e,n;Y.has(r.__typename)?(e="requires_buyer_review",n=r.code.toLowerCase()):W.has(r.code)?(e="recoverable",n=r.code.toLowerCase()):(e="requires_buyer_input",n=B.has(r.code)?r.code.toLowerCase():"requires_buyer_input");const i="target"in r?r.target:void 0,o=r.localizedMessage||r.nonLocalizedMessage;if(t&&V(r.code)){const e=Oe.get(r.code);s.set({type:"warning",content_type:"plain",code:e??r.code.toLowerCase(),content:o,path:i},r);continue}s.set({type:"error",severity:e,content_type:"plain",code:n,content:o,path:i},r)}return s}({checkout:s,discountExtensionEnabled:x}),D=[...q.keys(),...Le(b,g,t)?[(M=g,{type:"info",path:"$.payment",code:"express_checkout",content_type:"plain",content:M})]:[]],T=x?H({discountLines:p?.value,toMinorUnits:He,hiddenCodeTitle:r.translate("order_summary.discount_title")}):void 0;var M;return{ucp:_e({embed:i,ucpPaymentHandlers:m,discountExtensionEnabled:x}),id:h,status:ke({checkout:s,violationMessageMap:q}),buyer:f,line_items:C,links:_,messages:D,currency:c.value?.currencyCode??"USD",totals:E,payment:{instruments:v},fulfillment:{methods:we({checkout:s})},order:De({checkout:s,embed:i}),...T&&{discounts:T}}}(_(this,e),_(this,t));return n?_(this,s).decorateCheckout(n):void 0})),C(this,r,E(()=>{const e=_(this,n).value;return e&&Ce(e,_(this,o,a))}))}get ucpCheckout(){return _(this,r)}get shopCash(){return _(this,t).shopCash}get shopDiscountOffer(){return _(this,t).shopDiscountOffer}
1isShopDiscountOfferUnsettled(){return _(this,t).isShopDiscountOfferUnsettled()}mapEvent(e){return _(this,s).mapEvent(e,()=>w(this,o,u).call(this,e))}mapResponse(t,s){switch(t){case"ec.ready":if(!function(e){return null!=e&&"object"==typeof e}(s))return;return w(this,o,h).call(this,s);case"ec.fulfillment.address_change_request":if(!function(e){if(!e||"object"!=typeof e)return!1;const t=e,s=t.checkout?.fulfillment;return!!s&&null!=Te(s)}(s))return;return function(e){const t=e.checkout?.fulfillment,s=t?Te(t):void 0;return s?{cart:{delivery:{addresses:[{address:(n=s,{firstName:n.first_name,lastName:n.last_name,phone:n.phone_number,address1:n.street_address,address2:n.extended_address,city:n.address_locality,countryCode:n.address_country,provinceCode:n.address_region,zip:n.postal_code}),oneTimeUse:!1,selected:!0}]}}}:{cart:void 0,errors:void 0};var n}(s,_(this,e));case"ec.payment.instruments_change_request":if(!function(e){if(!e||"object"!=typeof e)return!1;const t=e;return Array.isArray(t.checkout?.payment?.instruments)}(s))return;return w(this,o,d).call(this,s);case"ec.payment.credential_request":if(!function(e){if(!e||"object"!=typeof e)return!1;const t=e,s=t.checkout?.payment?.instruments?.find(e=>null!=e.credential);return null!=s}(s))return;return w(this,o,l).call(this,s);case"ec.window.open_request":if(!function(e){return null!=e&&"object"==typeof e}(s))return;return!0;default:return}}parseIncomingRequest(e){const t=_(this,s).parseIncomingRequest(e);if(t)return t;switch(e.method){case"ec.submit":return w(this,o,m).call(this,e);case"ec.update":return w(this,o,f).call(this,e);default:return{errorResponse:{jsonrpc:"2.0",id:e.id,error:{code:-32601,message:`Unknown method: ${e.method}`}}}}}buildSubmitResponse(e){const t=w(this,o,y).call(this);if(t?.order)return{jsonrpc:"2.0",id:e,result:{checkout:t,...w(this,o,g).call(this)}}}buildErrorResponse(e,t){if(t instanceof te)return{jsonrpc:"2.0",id:e,error:{code:R.INVALID_PARAMS,message:"Checkout not initialized"}};if(t instanceof se)return{jsonrpc:"2.0",id:e,error:{code:R.INVALID_PARAMS,message:"Invalid payment instrument credential"}};const n=_(this,s).mapError(t);return n?{jsonrpc:"2.0",id:e,error:{code:"recoverable"===n.severity?n.code:R.INTERNAL,message:n.content,data:{severity:n.severity,..."submit_blocked"===n.code?{reason:n.content}:{}}}}:{jsonrpc:"2.0",id:e,error:{code:R.INTERNAL,message:"Internal error"}}}};e=new WeakMap,t=new WeakMap,s=new WeakMap,n=new WeakMap,r=new WeakMap,i=new WeakMap,o=new WeakSet,a=function(){return pe({context:_(this,e),targetType:_(this,i)})},c=function(){return de({context:_(this,e),targetType:_(this,i)})},u=function(t){const s=_(this,r).peek();switch(t.type){case"checkout.ready":if(!s)return;return{jsonrpc:"2.0",method:"ec.ready",id:le(),params:{delegate:Array.from(_(this,e).embed.delegations.allowed)}};case"checkout.start":if(!s)return;return{jsonrpc:"2.0",method:"ec.start",params:{checkout:s}};case"checkout.error":{if(!s)return;const e={type:"error",code:t.code?.toLowerCase()??"unknown_error",content:t.message??"",content_type:"plain",severity:t.severity??"requires_buyer_input",path:t.path};return{jsonrpc:"2.0",method:"ec.messages.change",params:{checkout:{...s,messages:[...s.messages??[],e]}}}}case"checkout.addressChangeStart":if(!s)return;return{jsonrpc:"2.0",id:le(),method:"ec.fulfillment.address_change_request",params:{checkout:s}};case"checkout.paymentMethodChangeStart":if(!s)return;return{jsonrpc:"2.0",id:le(),method:"ec.payment.instruments_change_request",params:{checkout:s}};case"checkout.submitStart":if(!s)return;return{jsonrpc:"2.0",id:le(),method:"ec.payment.credential_request",params:{checkout:s}};case"checkout.windowOpen":return{jsonrpc:"2.0",id:le(),method:"ec.window.open_request",params:{url:t.url}};case"checkout.messagesChange":if(!s)return;return{jsonrpc:"2.0",method:"ec.messages.change",params:{checkout:s}};case"checkout.paymentChange":if(!s)return;return{jsonrpc:"2.0",method:"ec.payment.change",params:{checkout:s}};case"checkout.lineItemsChange":if(!s)return;return{jsonrpc:"2.0",method:"ec.line_items.change",params:{checkout:s}};case"checkout.buyerChange":if(!s)return;return{jsonrpc:"2.0",method:"ec.buyer.change",params:{checkout:s}};case"checkout.fulfillmentChange":if(!s)return;return{jsonrpc:"2.0",method:"ec.fulfillment.change",params:{checkout:s}};case"checkout.totalsChange":if(!s)return;return{jsonrpc:"2.0",method:"ec.totals.change",params:{checkout:s}};case"checkout.complete":{const e=w(this,o,y).call(this);if(!e?.order)return;return{jsonrpc:"2.0",method:"ec.complete",params:{checkout:e}}}default:return}},p=function({instruments:t,hasCredential:s}){if(!t?.length)return;const n=_(this,e).checkout.proposal.negotiated.fields.ucp.value?.paymentHandlers?.map(e=>e.id)??[];return t.find(t=>"string"!=typeof t.id||"string"!=typeof t.handler_id||!0!==t.selected||"string"!=typeof t.display?.last_digits||"string"!=typeof t.display?.brand||null==t.billing_address?(n.includes(t.handler_id)||_(this,e).observability.log("InvalidHandlerId","Payment instrument has an invali
1d handler ID",{handler_id:t.handler_id}),!1):!s||null!=t.credential&&"string"==typeof t.credential.token)},d=function(e){const{instruments:t}=e.checkout?.payment??{};return{ucpPaymentInstrument:w(this,o,p).call(this,{instruments:t})}},l=function(e){return{ucpPaymentInstrument:w(this,o,p).call(this,{instruments:e.checkout?.payment?.instruments,hasCredential:!0})}},h=function(e){if(null!=e.upgrade&&null!=e.upgrade.port&&e.upgrade.port instanceof MessagePort)return{upgrade:{port:e.upgrade.port}};const{instruments:t}=e.checkout?.payment??{};return{upgrade:void 0,ucpPaymentInstrument:w(this,o,p).call(this,{instruments:t})}},m=function(e){const t=e.params,s=t?.checkout?.payment?.instruments,n=w(this,o,p).call(this,{instruments:s,hasCredential:!0});return n?{type:"submit",instrument:n}:{errorResponse:{jsonrpc:"2.0",id:e.id,error:{code:R.INVALID_PARAMS,message:"Missing payment instrument with credential"}}}},f=function(e){const t=e.params,s=t?.checkout;if(!s||1!==Object.keys(s).length)return{errorResponse:{jsonrpc:"2.0",id:e.id,error:{code:-32602,message:"ec.update requires exactly one field"}}};const n=Object.keys(s)[0];switch(n){case"fulfillment":{const t=s.fulfillment,n=t?Te(t):void 0;return n?{type:"addressUpdate",address:n}:{errorResponse:{jsonrpc:"2.0",id:e.id,error:{code:-32602,message:"Invalid delivery address"}}}}case"payment":{const t=s.payment,n=w(this,o,p).call(this,{instruments:t?.instruments});return n?{type:"instrumentUpdate",instrument:n}:{errorResponse:{jsonrpc:"2.0",id:e.id,error:{code:-32602,message:"Invalid payment instrument"}}}}case"buyer":{const t=function(e){if(null==e||"object"!=typeof e||Array.isArray(e))return;const t=new Set(["email","phone_number"]),s=e;if(Object.keys(s).some(e=>!t.has(e)))return;const n=Object.prototype.hasOwnProperty.call(s,"email"),r=Object.prototype.hasOwnProperty.call(s,"phone_number");return n&&"string"!=typeof s.email||r&&"string"!=typeof s.phone_number||!n&&!r?void 0:{...n?{email:s.email}:{},...r?{phone_number:s.phone_number}:{}}}(s.buyer);return t?{type:"buyerUpdate",buyer:t}:{errorResponse:{jsonrpc:"2.0",id:e.id,error:{code:-32602,message:"Invalid buyer identity"}}}}default:return{errorResponse:{jsonrpc:"2.0",id:e.id,error:{code:-32602,message:`Unknown ec.update field: ${n}`}}}}},y=function(){const e=_(this,n).peek();return e&&Ce(e,_(this,o,c))},g=function(){if(!_(this,t).enabled)return{};const e=this.shopCash.peek(),s=this.shopDiscountOffer.peek();return{...e?{shop_cash:e}:{},...s?{shop_discount_offer:s}:{}}},ge.version="2026-01-23";let be=ge;const ve=new Map([["terms-of-service","terms_of_service"],["privacy-policy","privacy_policy"],["refund-policy","refund_policy"],["shipping-policy","shipping_policy"]]);function _e({embed:e,ucpPaymentHandlers:t,discountExtensionEnabled:s}){const n={};for(const r of t??[]){const{name:e}=r;e&&(n[e]??=[],n[e].push(r))}return{version:be.version,transports:{embedded:{schema:"https://ucp.dev/2026-01-23/services/shopping/embedded.json",delegations:Array.from(e.delegations.allowed)}},capabilities:s?{"dev.ucp.shopping.discount":[{version:be.version,extends:"dev.ucp.shopping.checkout",spec:"https://ucp.dev/2026-01-23/specification/discount",schema:"https://ucp.dev/2026-01-23/schemas/shopping/discount.json"}]}:{},payment_handlers:n}}function ke({checkout:e,violationMessageMap:t}){const{shippingAddress:s,isShippingRequired:n}=e.proposal.negotiated.fields,r=e.latestReceipt.value?.status;if("processed"===r)return"completed";if("processing"===r||"processing_remote_checkouts"===r||"action_required"===r)return"complete_in_progress";if(Array.from(t.entries()).some(([e,t])=>"error"===e.type&&!$.has(t.code)))return"incomplete";const i=Boolean(n?.value),o=Boolean(s?.value);return i&&!o?"incomplete":"ready_for_complete"}function Ce(e,{redactPII:t,redactIdKey:s}){const n=t?function(e){const{buyer:t,payment:s,...n}=e;return{...n,...e.fulfillment&&{fulfillment:(i=e.fulfillment,{...i,methods:i.methods.map(e=>{const{destinations:t,selected_destination_id:s,...n}=e;return n})})},...e.order&&{order:(r=e.order,{...r,permalink_url:"about:blank"})}};var r,i}(e):e;return s?{...n,id:he(n.id)}:n}function we({checkout:e}){const{merchandiseLines:{value:t},deliveryNext:{value:s},shippingAddress:{value:n}}=e.proposal.negotiated.fields;if("filled"!==s?.status||!s.lines)return function(e){const t=e?.lines?.filter(e=>e.requiresShipping)?.map(e=>je(e))??[];return 0===t.length?[]:[{id:"shipping",type:"shipping",line_item_ids:t,destinations:[],groups:[]}]}(t);const r=s.lines.filter(Ae).filter(e=>e.methods.some(e=>
1{return"SHIPPING"===(t=e.methodType)||"LOCAL"===t||"PICK_UP"===t||"PICKUP_POINT"===t;var t})&&e.targetMerchandiseLines?.some(e=>e.requiresShipping));if(!r.length)return[];const i=function(e){const t=new Set;for(const s of e){const e=Ee(s);e&&t.add(e)}return Array.from(t)}(r),o=[];for(const a of i){const e=r.filter(e=>Ee(e)===a),t=e.map(Re),s=[...new Set(t.flatMap(e=>e.line_item_ids))],i=Ie(a,e,n);o.push({id:a,type:a,line_item_ids:s,...i&&{destinations:[i]},groups:t})}return o}function Ee(e){const t=e.methods[0];var s;if(t)return"PICK_UP"===(s=t.methodType)||"PICKUP_POINT"===s?"pickup":"shipping"}function Ie(e,t,s){if("shipping"===e){if(!s)return;return{...qe(n=s),id:`shipping-${n.countryCode}-${n.postalCode}`.replace(/\s+/g,"")}}var n;for(const r of t)if(r.selectedDeliveryMethodHandle){const e=r.methods.find(e=>e.handle===r.selectedDeliveryMethodHandle);if(e)return Pe(e)}}function Pe(e){const t=e.pickupLocation;if(t)return{id:e.handle,name:t.name??"",address:qe(t.address)}}function Re(e){return{id:e.id??"",line_item_ids:xe(e),options:e.methods.map(Se),...e.selectedDeliveryMethodHandle&&{selected_option_id:e.selectedDeliveryMethodHandle}}}function Se(e){return{id:e.handle,title:e.title,...e.description&&{description:e.description},...e.carrierName&&{carrier:e.carrierName},...e.minDeliveryDateTime&&{earliest_fulfillment_time:e.minDeliveryDateTime},...e.maxDeliveryDateTime&&{latest_fulfillment_time:e.maxDeliveryDateTime},totals:[{type:"fulfillment",amount:He(e.costAfterDiscounts)}]}}function je(e){return e.id??`gid://shopify/CartLine/${e.variantId}`}function Ae(e){return"available"===e.status}function xe(e){return e.targetMerchandiseLines?.filter(e=>e.requiresShipping).map(e=>je(e))??[]}function qe(e){return{first_name:e.firstName,last_name:e.lastName,phone_number:e.phone,street_address:e.address1,extended_address:e.address2,address_locality:e.city,address_region:e.zoneCode,address_country:e.countryCode,postal_code:e.postalCode}}function De({checkout:e,embed:t}){const s=e.latestReceipt.value;if("processed"===s?.status)return{id:"microsoft"===t.embedder?s.orderIdentity.id:S("Order",j(s.orderIdentity.id)),permalink_url:s.confirmationPage.url}}function Te(e){if(Array.isArray(e.methods))for(const t of e.methods){if(!t||"object"!=typeof t)continue;const{type:e,destinations:s,selected_destination_id:n}=t;if("shipping"!==e||!Array.isArray(s))continue;const r="string"==typeof n?n:null;if(r){const e=s.find(e=>Me(e)&&"string"==typeof e.id&&e.id===r);if(e&&Me(e))return e}for(const t of s){if(!Me(t))continue;const e="string"==typeof t.id?t.id:void 0;if(null==r||e&&r===e||1===s.length)return t}}}function Me(e){if(!e||"object"!=typeof e)return!1;const t=e;return"string"==typeof t.street_address||"string"==typeof t.address_locality||"string"==typeof t.address_region||"string"==typeof t.address_country||"string"==typeof t.postal_code||"string"==typeof t.first_name||"string"==typeof t.last_name}const Oe=new Map(U);function Le(e,t,s){return!(!t||e&&(s.shouldSuppressReceiptWalletAsExpressCheckout()||ae(e)&&"gpay"===e.handler_id&&"google_pay"===t))}const Ne={APPLE_PAY:"apple_pay",GOOGLE_PAY:"google_pay",SHOP_PAY:"shop_pay",SHOPIFY_INSTALLMENTS:"shop_pay",PAYPAL_EXPRESS:"paypal",VENMO:"venmo",AMAZON_PAY:"amazon_pay",AMAZON_PAY_CLASSIC:"amazon_pay",FACEBOOK_PAY:"facebook_pay",amazon_pay:"amazon_pay",buy_with_prime:"buy_with_prime"};const Ue=new Map;function He(e){if(!e)return 0;let t=Ue.get(e.currencyCode);t||(t=new Intl.NumberFormat("en",{style:"decimal",currency:e.currencyCode,useGrouping:!1}),Ue.set(e.currencyCode,t));const s=I(e.currencyCode),[n,r=""]=t.format(e.amount).split(".");return Number(n+r.padEnd(s,"0"))}class Fe extends fe{constructor(e){super(e),this.version="2026-01-23",this.#e=!1,this.#t=!1,this.#s=null,this.#n=!1,this.#r=new K(e.ucp.checkout.buyer),this.#i=new G({observability:e.observability}),this.#o=new me({observability:e.observability}),this.#a=new be(e,this.#o.targetType),this.#c=new Z([new J({context:this.context,mapper:this.#a,transport:this.#o,resizeObserver:this.#i,incomingRequests:{submitShopPay:e=>this.#r.submitShopPay(e),applyRedemption:e=>this.#r.applyRedemption(e)},waitForPendingNegotiations:()=>this.waitForPendingNegotiations(),waitForSkeletonRemoved:()=>this.waitForSkeletonRemoved()})]),this.#o.onRequest(e=>this.#u(e)),this.observability.bridgeInitialized()}get embedderHostname(){const e=this.#o.embedderOrigin;if(e)try{return new URL(e).hostname}catch{return}}#o;#a;#r;#e;#t;#s;#p;#d;#l;#h;#n;#i;#c;unstable_providePreactContext(e){super.unstable_providePreactContext(e),this.#r.initialize({...this.context,...e,addPaymentError:e=>this.addPaymentError(e),removePaymentError:e=>this.removePaymentError(e)}).catch(e=>{this.observability.enqueuedApplyPaymentInstrumentError(e)});const t=this.context.checkout.proposal.negotiated.fields.ucp;t.value={...t.peek()}}async ready(){if(this.#o.isLoopback){if(this.context.environment.debug.logging&&this.context.client.initialRequest.url.searchParams.has("skip_ec_ready"))return void this.observability.skipEcReady();if(!(await this.#m()))return}this.#f();let e=this.#a.mapEvent({type:"checkout.ready"});if(!e)return;const t=await this.#y(e);let s=this.#a.mapResponse(e.method,t);if(s?.upgrade?.port instanceof MessagePort){if(this.observability.readyMessagePortUpgrade(),this.#o.upgrade(s.upgrade.port),e=this.#a.mapEvent({type:"checkout.ready"}),!e)return;const t=await this.#y(e);
1s=this.#a.mapResponse(e.method,t)}const n=s?.ucpPaymentInstrument;n&&(this.observability.readyPaymentInstrument(),await this.#r.applyInstrument(n)),Q(s)&&(this.observability.readyCartUpdate(Object.keys(s.cart).join(",")),this.applyCart(s.cart))}async start(){const e=this.#a.mapEvent({type:"checkout.start"});e&&(this.#o.notify(e),this.#g(),this.#c.start(),this.observability.checkoutStarted({embedder:this.context.embed.embedder,buyerEmail:this.context.checkout.proposal.proposed.email.peek(),hasPaymentInstrument:this.hasDelegatedPaymentInstrument()}),this.#b())}async resumeFromReceipt(){await this.#m()&&(this.#f(),this.#g(),this.#b())}async complete(){if(this.#v()){const e=new ne;return void this.observability.unauthenticatedIframe(e.message)}if(this.#e)return void this.observability.completedEventSkipped();if(this.#e=!0,this.observability.checkoutCompleted(),this.#s){const e=this.#a.buildSubmitResponse(this.#s);return this.#s=null,void(e&&(this.observability.submitResponseSent(e.id),this.#o.send(e)))}const e=this.#a.mapEvent({type:"checkout.complete"});e&&(this.observability.completedEventEmitted(),this.#o.notify(e))}error(e){const t=this.#a.mapEvent({type:"checkout.error",code:e.code,message:e.message,severity:e.severity,path:e.path});t&&this.#o.notify(t)}async addressChangeStart(e){const t=this.#a.mapEvent({type:"checkout.addressChangeStart",addressType:e});if(!t)return;const s=await this.#o.request(t);return this.#a.mapResponse(t.method,s)}async paymentMethodChangeStart(){this.removePaymentError(A.PaymentDelegationError);try{const e=this.#a.mapEvent({type:"checkout.paymentMethodChangeStart"});if(!e)return;const t=await this.#o.request(e),s=this.#a.mapResponse(e.method,t);return s?.ucpPaymentInstrument&&await this.#r.applyInstrument(s.ucpPaymentInstrument),s}catch(e){return this.#_(e,"payment.instruments_change")}}async submitStart(){this.removePaymentError(A.PaymentDelegationError);try{await this.waitForPendingNegotiations();const e=this.#a.mapEvent({type:"checkout.submitStart"});if(!e)return;const t=await this.#o.request(e,{timeoutMs:ye(this.context.embed.embedder)}),s=this.#a.mapResponse(e.method,t);return s?.ucpPaymentInstrument&&await this.#r.submit(s.ucpPaymentInstrument),s}catch(e){return this.#_(e,"payment.credential")}}async windowOpenRequest(e){const t=this.#a.mapEvent({type:"checkout.windowOpen",url:e});if(t)try{await this.#o.request(t)}catch(s){if(s instanceof x&&s.errorCode===q.WINDOW_OPEN_REJECTED)return void this.observability.windowOpenRejected(e,s.errorMessage);this.observability.windowOpenError(e,s)}}beforeunload(){this.#c.beforeunload()}dialogChange(e){this.#c.dialogChange(e)}showToast(e){return this.#c.showToast(e)}async requestShopPaySessionRevalidation(){return await this.#c.requestShopPaySessionRevalidation()??!0}shopPaySessionRevalidationChange(e){this.#c.shopPaySessionRevalidationChange(e)}async#y(e){try{return await this.#o.request(e,{timeoutMs:1e4})}catch(t){throw this.observability.handshakeError(D(t),T(t)),t}}cleanup(){this.#c.cleanup(),this.#o.cleanup(),this.#r.cleanup(),this.#p?.(),this.#d?.(),this.#n=!0}#_(e,t){if(!(e instanceof x&&e.isUserCancelledError))return e instanceof M?(this.observability.paymentDelegationTimeout(t,e.message),void this.addPaymentError(A.PaymentDelegationError)):e instanceof x&&e.isInternalError?(this.observability.paymentDelegationError(t,e.message),void this.addPaymentError(A.PaymentDelegationError)):void this.observability.paymentDelegationUnexpectedError(t,e instanceof Error?e.message:String(e));this.observability.paymentDelegationCancelled()}async#u(e){const{embed:t}=this.context;try{const s=this.#a.parseIncomingRequest(e);if("errorResponse"in s)return this.observability.incomingRequestValidationFailed(e.id),void this.#o.respondToRequest(e,s.errorResponse);if(await this.#c.handleIncomingRequest(s,{requestId:e.id,markSubmitPending:()=>{this.#s=e.id},onSubmitAttempt:()=>{},sendAckResponse:()=>{this.#o.send({jsonrpc:"2.0",id:e.id,result:{}})}}))return;if("submit"!==s.type&&!this.#c.canHandleIncomingRequest(s.type))throw new re(t.embedder);switch(s.type){case"submit":this.#s=e.id,await this.#r.submit(s.instrument);break;case"addressUpdate":await this.#r.applyAddress(s.address),this.#o.send({jsonrpc:"2.0",id:e.id,result:{}});break;case"buyerUpdate":await this.#r.applyBuyer(s.buyer),this.#o.send({jsonrpc:"2.0",id:e.id,result:{}});break;case"instrumentUpdate":await this.#r.applyInstrument(s.instrument),this.#o.send({jsonrpc:"2.0",id:e.id,result:{}})}}catch(s){this.#s=null,this.observability.incomingRequestError(e.id,s);try{this.#o.send(this.#a.buildErrorResponse(e.id,s))}catch{}}}#g(){let e;this.#d=P(()=>{const t=this.#a.ucpCheckout.value;if(!e)return e=t,void(this.#h=t?.totals);if(t){if(!function(e,t){return e===t||e.length===t.length&&e.every((e,s)=>{const n=t[s];return e.id===n.id&&e.quantity===n.quantity&&e.parent_id===n.parent_id&&e.item.id===n.item.id&&e.item.title===n.item.title&&e.item.image_url===n.item.image_url})}(e.line_items,t.line_items)){const e=this.#a.mapEvent({type:"checkout.lineItemsChange"});e&&this.#o.notify(e)}if(!O(e.buyer,t.buyer)){const e=this.#a.mapEvent({type:"checkout.buyerChange"});e&&this.#o.notify(e)}if(!O(e.fulfillment,t.fulfillment)){const e=this.#a.mapEvent({type:"checkout.fulfillmentChange"});e&&this.#o.notify(e)}if(!function(e,t){if(e===t)return!0;
1if(!e||!t)return!1;const s=e.instruments??[],n=t.instruments??[];return s.length===n.length&&s.every((e,t)=>{const s=n[t],r=Object.keys(e).filter(e=>"credential"!==e),i=Object.keys(s).filter(e=>"credential"!==e);return r.length===i.length&&r.every(t=>{if(!(t in s))return!1;const n=e[t],r=s[t];return n===r||"object"==typeof n&&"object"==typeof r&&O(n,r)})})}(e.payment,t.payment)){const e=this.#a.mapEvent({type:"checkout.paymentChange"});e&&this.#o.notify(e)}if(this.#c.checkoutChange(e,t),!O(e.messages,t.messages)){const e=this.context.checkout.proposal.negotiated.fields.allViolations.value??[],t=Boolean(this.context.negotiationContext?.delegatedPaymentInstrument?.peek());if(e.some(e=>X.has(e.code)||t&&ee.has(e.code))){const e=this.#a.mapEvent({type:"checkout.messagesChange"});e&&this.#o.notify(e)}}O(e.totals,t.totals)||this.#k(),"ready_for_complete"!==t.status||this.#t||(this.#t=!0,this.observability.readyForComplete()),e=t}})}#k(){this.#l||(this.#l=this.#C())}async#C(){try{await this.waitForPendingNegotiations()}finally{this.#l=void 0}if(this.#n)return;const e=this.#a.ucpCheckout.peek()?.totals;if(e&&!O(this.#h,e)){this.#h=e;const t=this.#a.mapEvent({type:"checkout.totalsChange"});t&&this.#o.notify(t)}}
1#b(){if("processed"===this.context.checkout.latestReceipt.peek()?.status)return this.complete(),void this.cleanup();let e=!0;this.#p=P(()=>{const t=this.context.checkout.latestReceipt.value;if(e)e=!1;else if("failed"===t?.status&&"payment"===t.failure.type){const e="code"in t.failure?String(t.failure.code).toLowerCase():"unknown";this.error({code:"PAYMENT_ERROR",message:e,severity:"recoverable",path:"$.payment",timestamp:Date.now()})}if("failed"===t?.status){const e="code"in t.failure?t.failure.code:"unknown";this.observability.receiptError(t.failure.type,e)}if("failed"===t?.status&&this.#s){const e=this.#s;return this.#s=null,this.observability.submitReceiptFailed(e,t.failure.type),void this.#o.send(this.#a.buildErrorResponse(e,new oe(t.failure.type)))}t&&"processed"===t.status&&(this.complete(),this.cleanup())})}async#m(){if(!this.#o.isLoopback)return!0;const e=await this.#o.waitForTarget();if(this.#o.isDisposed)return!1;if("loopback"===e){const e=new ie("No embedder transport detected. Checkout was loaded in embedded mode but no parent frame or native bridge was found.");throw this.observability.noTransportDetected(e.message,this.#o.environmentSnapshot),e}return!0}#f(){if(!this.#v())return;const e=new ne;throw this.observability.unauthenticatedIframe(e.message),e}#v(){return this.#o.isIframe&&!this.context.embed.isAuthenticated}}export{Fe as Ucp2026_01_23Client};
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.