var _____WB$wombat$assign$function_____=function(name){return (globalThis._wb_wombat && globalThis._wb_wombat.local_init && globalThis._wb_wombat.local_init(name))||globalThis[name];};if(!globalThis.__WB_pmw){globalThis.__WB_pmw=function(obj){this.__WB_source=obj;return this;}}var window = _____WB$wombat$assign$function_____("window");
var self = _____WB$wombat$assign$function_____("self");
var document = _____WB$wombat$assign$function_____("document");
var location = _____WB$wombat$assign$function_____("location");
var top = _____WB$wombat$assign$function_____("top");
var parent = _____WB$wombat$assign$function_____("parent");
var frames = _____WB$wombat$assign$function_____("frames");
var opener = _____WB$wombat$assign$function_____("opener");
import{i as m,aM as d,aN as A,a as t,aI as P,aO as g,aP as E,aQ as N,aR as h,G as C,aS as R,B as S,U as v,R as B,aT as f,aU as I,aV as w,A as O,aW as M,K as U,aX as V,aY as D,a7 as L,aZ as k,a_ as Y,as as x}from"./app.ZXowmuNl.js";import{S as W}from"./ShopPayOptInDisclaimer.DFHycp8H.js";function Q(){const e=m(),{value:n}=d(),u=A()||n?.amount===0?e("review.review_and_confirm_title","Review and confirm"):e("review.review_title","Review and pay");return t(P,{level:1,autoFocus:!0,children:u})}const X=e=>t(x,{children:e});function Z(){const e=g("Checkout::Actions::RenderBefore"),n=E(),{PayButton:o}=N();return t(f,{target:"cart.paymentLines[0]",children:t(h,{impressionType:"pay_now_button",impressionFeatures:[],children:[e.length!==0&&t(C,{children:[t(R,{extensions:e,render:X}),t(S,{spacing:"base"})]}),t(v,{ref:n,children:[t(q,{}),t(B,{children:t(o,{})}),t(W,{})]})]})})}const b=new Map([["PAYMENTS_UNACCEPTABLE_PAYMENT_AMOUNT",{status:"warning",priority:-1,negotiationStage:"completion"}],["TAX_NEW_TAX_MUST_BE_ACCEPTED",{status:"warning",priority:-2,negotiationStage:"completion"}]]);function q(){const e=I(),n=F(e.value,b);return t(f,{target:"cart.paymentLines[0]",children:n.map(o=>t(w,{notice:o,errorType:O.PaymentError},o.code))})}function F(e,n){const o=M(),[u,p]=U([]),l=V(({violations:a,negotiationStage:y})=>{const r=[],T=a.some(i=>D.has(i.code));for(const i of a)if(!G(i)&&!(T&&(i.code==="PAYMENTS_UNACCEPTABLE_PAYMENT_AMOUNT"||i.code==="TAX_NEW_TAX_MUST_BE_ACCEPTED"))&&n.has(i.code)){if(T)continue;const c=n.get(i.code);y&&y===c?.negotiationStage&&r.push({...i,tone:c?.tone,priority:c?.priority})}if(r.length>=1){const c=r.map(s=>s.priority??0).reduce((s,_)=>s>_?s:_);return r.filter(s=>(s.priority??0)>=c)}return r},[n]);return L(()=>{e&&p(l({violations:e}))},[l]),k(a=>{a.type==="complete"||a.type==="invalid"||a.type==="failed"||!o.current||p(l({violations:a.violations,negotiationStage:a.negotiationStage}))}),u.filter(Y("localizedMessage"))}function G(e){return e.__typename!=="ConfirmChangeViolation"&&e.__typename!=="UnprocessableTermViolation"&&e.__typename!=="RemoveTermViolation"}export{Z as P,Q as R};