1import{V as m}from"./4c290a1e.FJVsH4yi.js";import{c as i}from"./2c1ab0fe.BqEHHmaW.js";const h=[{buyerCountryCode:"CA",currencyCode:"CAD",scheduledPaymentCount:3,buyerFacingPaymentCount:4},{buyerCountryCode:"GB",currencyCode:"GBP",scheduledPaymentCount:2,buyerFacingPaymentCount:3}];function g(e,{buyerCountryCode:t,currencyCode:n}){if(e.loanType!=="SPLIT_PAY"||e.apr!==0||!n)return e.installmentsCount;const o=t??(n==="GBP"?"GB":void 0);return h.find(r=>r.buyerCountryCode===o&&r.currencyCode===n&&r.scheduledPaymentCount===e.installmentsCount)?.buyerFacingPaymentCount??e.installmentsCount}function I(e,t,n){const o=window.webkit?.messageHandlers?.CheckoutSheetProtocolConsumer,a=window.CheckoutSheetProtocolConsumer,r=[o,a,n];for(const u of r)if(u&&typeof u?.postMessage=="function")try{const c={name:t.handlerId,body:JSON.stringify(t.body)};return e.log("checkout_sheet_protocol_client_message_posted","Posting message to checkout sheet protocol consumer.",{handlerId:t.handlerId}),u.postMessage(JSON.stringify(c)),e.counter({name:"checkout_sheet_protocol_event_emitted",value:1,exportImmediately:!0,attributes:{event:String(t.handlerId),status:"success"}}),!0}catch(c){return e.log("checkout_sheet_protocol_client_message_posting_failed","Error posting message to checkout sheet protocol consumer",{handlerId:t.handlerId,error:c instanceof Error?c.message:String(c)}),e.counter({name:"checkout_sheet_protocol_event_emitted",value:1,exportImmediately:!0,attributes:{event:String(t.handlerId),status:"failed"}}),console.info("Error received when posting message to checkout sheet protocol consumer",t,c),!1}return e.log("checkout_sheet_protocol_client_no_consumer_found","No checkout sheet protocol consumer found",{handlerId:t.handlerId}),e.counter({name:"checkout_sheet_protocol_event_emitted",value:1,exportImmediately:!0,attributes:{event:String(t.handlerId),status:"no_consumer"}}),!1}function S(){const e=window.opener||(window.parent===window?void 0:window.parent);return e?{postMessage(t){e.postMessage({_ecp:"2025-10",data:t},"*")}}:void 0}function M(e){const t=e??[];for(const n of t)if(n.method.type==="direct"||n.method.type===m.CreditCard){const o=n.method.creditCardInstallments;if(o&&o>0)return o}for(const n of t)if(n.method.type==="wallet"&&n.method.name==="SHOP_PAY"){const o=n.method.walletContent?.creditCardInstallments;if(o&&o>0)return o}}const s=(e,t=2)=>Math.round(e*10**t)/10**t,d=e=>({...e,amount:s(e.amount,i(e.currencyCode))}),p={USD:.5,AED:2,ARS:.5,AUD:.5,BRL:.5,CAD:.5,CHF:.5,COP:.5,CZK:15,DKK:2.5,EUR:.5,GBP:.3,HKD:4,HUF:175,IDR:.5,ILS:.5,INR:.5,JPY:50,KRW:50,MXN:10,MYR:2,NOK:3,NZD:.5,PHP:.5,PLN:2,RON:2,RUB:.5,SEK:3,SGD:.5,THB:10,ZAR:.5},l=.5,f=e=>e?p[e]??l:l;function C(e,t){if(!t)return e;const n=[];let o=t;for(const a of e){if(o.amount<=0)break;const r=a.availableBalance;if(!r||r.amount<=0)continue;const u=r.amount>=o.amount?{...a,availableBalance:o}:a;n.push(u),o=d({amount:o.amount-u.availableBalance.amount,currencyCode:o.currencyCode})}return P(n,o)}function D(e,t){return!e||!t?e:C([e],t)[0]??null}function P(e,t){const n=f(t.currencyCode);if(t.amount<=0||t.amount>=n)return e;const o=i(t.currencyCode),a=[...e];let r=s(n-t.amount,o);for(;r>0;){const u=a.pop();if(!u)break;const c=u.availableBalance;c.amount>r?(a.push({...u,availableBalance:d({amount:c.amount-r,currencyCode:c.currencyCode})}),r=0):r=s(r-c.amount,o)}return a}export{g as a,f as b,D as c,d,C as e,S as f,M as g,I as p,s as r};
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.