1import{g as e,q as n,z as a,T as t,h as l,u as i}from"./2c1ab0fe.XVnTovwp.js";import{r as o,bA as s,z as r,bB as c,bC as u,i as d,S as m}from"./164ad2e3.hrg71Gqs.js";import{a as p,aH as v,p as g,b8 as b,b9 as h}from"./f67abd2c.DYpmk7mw.js";import{a as _,g as f}from"./f3fe2775.DhB4E-te.js";import"./d0bb51ec.Bel_y502.js";import"./app.Bke-0Cv3.js";import"./60a453ce.Al5ISuVm.js";import"./e12db40c.D-IRYT_x.js";import"./9dba8418.C8BcPjk_.js";import"./ac5a19ff.C1LksOgD.js";import"./598fef4e.w_MKrvcK.js";import"./e77f7fe0.DoOL59j8.js";import"./22345fd4.DGbyKJ7j.js";import"./4b1c22b7.D2BMozDL.js";import"./a422df8c.5gfasMpQ.js";import"./efa0389a.BZq4PXzm.js";import"./cc6ff67d.BrToxuCX.js";import"./08a3b809.D2TiFyOY.js";import"./d25d1b95.BK5nRVN2.js";import"./bf513f9c.CtAeu42z.js";import"./e39bc11c.8KP_WUjj.js";import"./7a8217fd.Caa0VLP0.js";import"./8599b02a.CZRACGSm.js";import"./cf29e63b.Ys3W-wRm.js";function j({paymentMethod:j,isSelected:S,canEditBin:C=!0,isVaultedContext:I=!1,id:y="msiInstallmentsSelect"}){const k=C&&!I,{i18n:w,checkout:{negotiator:P}}=p(),N=w.translate("msi_installments.payment_plan_label"),{bankIdNumberSignal:x,installmentMonthsSignal:B,lastNegotiatedBinSignal:T,msiInvalidationReasonSignal:D,msiInvalidationSnapshotSignal:E,msiHadInstallmentsSignal:F}=P.context,{paymentLines:M}=P.parts,{negotiate:H}=o(),O=e(void 0),[V,z]=a(!1),L=e(null),A=D.value,R=j.installmentPlans,Y=R?.find(e=>"MSI"===e.type),q=t(()=>Y?.supportedInstallments??[],[Y?.supportedInstallments]),G=b(x.value),J=_(),K=J.value&&q.includes(J.value)?String(J.value):"",Q=n(e=>{M.value=s(M.value,e)},[M]);l(()=>{B.value=J.value},[J.value,B]);const{trackDropdownShown:U,trackDropdownOpened:W,trackPlanSelected:X}=function(a){const{userEvents:t,source:l,shop:i}=p(),o=v(),s=e(0),r=n(e=>{t.monorailEvent({schemaId:"checkout_credit_card_installment_track/1.0",payload:{eventName:e.eventName,shopId:parseInt(g(i.id),10),checkoutToken:l.checkoutSessionIdentifier??"",...null!=e.planCount&&{planCount:e.planCount},eligiblePlans:e.eligiblePlans,cartTotal:e.cartTotal,cartCurrency:e.cartCurrency}})},[t,i.id,l.checkoutSessionIdentifier]);return{trackDropdownShown:n(()=>{const e=o.value?.amount,n=o.value?.currencyCode;null!=e&&n&&r({eventName:"credit_card_installment_dropdown_shown",eligiblePlans:a.join(","),cartTotal:e.toFixed(2),cartCurrency:n})},[r,o,a]),trackDropdownOpened:n(()=>{const e=Date.now();if(e-s.current<1e3)return;s.current=e;const n=o.value?.amount,t=o.value?.currencyCode;null!=n&&t&&r({eventName:"credit_card_installment_dropdown_opened",eligiblePlans:a.join(","),cartTotal:n.toFixed(2),cartCurrency:t})},[r,o,a]),trackPlanSelected:n(e=>{const n=o.value?.amount,t=o.value?.currencyCode;null!=n&&t&&r({eventName:"credit_card_installment_plan_selected",planCount:e,eligiblePlans:a.join(","),cartTotal:n.toFixed(2),cartCurrency:t})},[r,o,a])}}(q),Z=e(!1),$=n(e=>{const n=e?parseInt(e,10):void 0;Q(n&&n>0?n:void 0),D.value=null,n&&n>0&&X(n)},[Q,D,X]);l(()=>{q.length>0&&!F.value&&(F.value=!0)},[q,F]),l(()=>{const e=J.value;e&&(q.includes(e)||(q.length>0?(D.value="some_eligible",E.value=q.join(","),Q(void 0)):F.value&&(D.value="none_eligible",E.value="",Q(void 0))))},[q,J.value,Q,D,E,F]),l(()=>{A&&q.join(",")!==E.value&&(q.length>0?D.value=null:F.value&&(D.value="none_eligible",E.value=""))},[A,q,D,E,F]),l(()=>{A&&L.current&&L.current.scrollIntoView({behavior:"smooth",block:"center"})},[A]),l(()=>{if(!Y||!S)return void Q(void 0);const e=b(x.value);e?I||(e.length<8&&k?Q(void 0):e!==T.value&&(Q(void 0),T.value=e,O.current=e,z(!0),H({legacyFiltering:{include:[]},silenceViolations:[...h]}).catch(()=>{T.value===e&&(T.value=void 0)}).finally(()=>{O.current===e&&z(!1)}))):(k||0===q.length)&&Q(void 0)},[x.value,k,Y,S,I,q.length,H,Q,T]);const ee=!I&&void 0!==G&&void 0!==T.value&&G!==T.value,ne=S&&!V&&!ee&&q.length>0;l(()=>{ne&&!Z.current&&(Z.current=!0,U())},[ne,U]);const ae=f({isSelected:Boolean(S),hasMsiPlan:Boolean(Y),isStale:ee,binPrefix:G,canEditBin:k,supportedInstallmentsCount:q.length,isNegotiating:V}),te="dropdown"===ae&&q.length>0,le=e(te);if(l(()=>{if(te&&!le.current)return le.current=!0,r({content:N})},[te,N]),"hidden"===ae)return null;if("prompt"===ae)return i(u,{id:y,name:"msiInstallments",label:N,value:"prompt",onCh
1ange:()=>{},children:i(c,{value:"prompt",children:w.translate("msi_installments.enter_card_details_prompt")})});if("loading"===ae)return i(u,{id:y,name:"msiInstallments",label:N,value:"loading",disabled:!0,onChange:()=>{},children:i(c,{value:"loading",children:w.translate("msi_installments.loading_installments")})});let ie;return A&&(ie="none_eligible"===A?w.translate("msi_installments.no_plans_available"):w.translate("msi_installments.plan_no_longer_available")),i(m,{ref:L,gap:"small-400",children:[i(u,{id:y,name:"msiInstallments",label:N,value:K,onChange:$,onFocus:W,children:[i(c,{value:"",children:w.translate("msi_installments.pay_in_full")}),q.map(e=>i(c,{value:String(e),children:w.translate("msi_installments.months_interest_free",{months:e})},e))]}),ie?i(d,{color:"subdued",accessibilityLive:"polite",children:ie}):null]})}export{j as MsiInstallmentsSelect};
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.