1import{r as i,h as e,H as t,c as o,a as s}from"./p-9add63ef.js";import{o as n,s as d,u as r}from"./p-b6a933a1.js";import{l as a,b as c,c as l}from"./p-563b9172.js";import{o as u,s as h}from"./p-e8cd31cf.js";import{c as v,d as f,e as p,f as m,g as b,h as y}from"./p-bdbb27c7.js";import{g,h as w,i as _}from"./p-c56db382.js";import{a as k,g as x}from"./p-f5865adc.js";import{c as C,a as E,f as S}from"./p-fa2e5250.js";import{d as I}from"./p-a05701be.js";import"./p-21d79146.js";import{s as T,f as j}from"./p-7cf48949.js";import{s as P}from"./p-49fdface.js";import{s as R,f as L,p as A}from"./p-1e3360a5.js";import{v as O,c as D,s as M}from"./p-9cd438cc.js";import"./p-8dccb656.js";import{a as q}from"./p-259c3935.js";import{s as F}from"./p-830ab1a3.js";import{c as H,r as z,a as U}from"./p-78468e45.js";import{a as J,g as N}from"./p-401e165e.js";import{p as V}from"./p-8b323bfb.js";import{r as Y,g as G}from"./p-d3366af3.js";import"./p-2b28ea49.js";import"./p-2f682959.js";import"./p-d15c4b50.js";import"./p-0cb2e619.js";import"./p-297962fd.js";import"./p-fb28f84f.js";import"./p-e2e1fe1f.js";const W=class{constructor(e){i(this,e)}componentWillLoad(){this.maybeApplyProfile();this.removeUserListener=u("loggedIn",(i=>{if(!i){this.appliedForCheckoutId=undefined;return}this.maybeApplyProfile()}));this.removeCheckoutListener=n("checkout",(()=>this.maybeApplyProfile()))}disconnectedCallback(){var i,e;(i=this.removeUserListener)===null||i===void 0?void 0:i.call(this);(e=this.removeCheckoutListener)===null||e===void 0?void 0:e.call(this)}async maybeApplyProfile(){var i,e,t,o,s,n,r,l;if(!h.loggedIn)return;const u=(i=d.checkout)===null||i===void 0?void 0:i.id;if(!u)return;if(this.appliedForCheckoutId===u)return;this.appliedForCheckoutId=u;try{const i=await g(d.mode);const u={};const h=i===null||i===void 0?void 0:i.shipping_address;const f=i===null||i===void 0?void 0:i.billing_address;if(w(h)&&_((e=d.checkout)===null||e===void 0?void 0:e.shipping_address)){u.shipping_address=h}if(w(f)&&_((t=d.checkout)===null||t===void 0?void 0:t.billing_address)){u.billing_address=f}if((i===null||i===void 0?void 0:i.first_name)&&!((o=d.checkout)===null||o===void 0?void 0:o.first_name)){u.first_name=i.first_name}if((i===null||i===void 0?void 0:i.last_name)&&!((s=d.checkout)===null||s===void 0?void 0:s.last_name)){u.last_name=i.last_name}if((i===null||i===void 0?void 0:i.phone)&&!((n=d.checkout)===null||n===void 0?void 0:n.phone)){u.phone=i.phone}if(typeof(i===null||i===void 0?void 0:i.billing_matches_shipping)==="boolean"&&((r=d.checkout)===null||r===void 0?void 0:r.billing_matches_shipping)!==i.billing_matches_shipping){u.billing_matches_shipping=i.billing_matches_shipping}if(!Object.keys(u).length)return;a("customer-profile-autofill");try{d.checkout=await v({id:(l=d.checkout)===null||l===void 0?void 0:l.id,data:u})}finally{c("customer-profile-autofill")}}catch(i){this.appliedForCheckoutId=undefined;console.error(i)}}render(){return e(t,{key:"ffebf9993c96bcbf74e208923c7c06d3294c708f"},e("slot",{key:"bf23b4641caaab47d68f7e9a0881ced32882b662"}))}};const Z=async()=>{try{if(!(navigator===null||navigator===void 0?void 0:navigator.geolocation)){return null}return await new Promise((i=>{navigator.geolocation.getCurrentPosition((({coords:e})=>i({latitude:e.latitude,longitude:e.longitude})),(()=>i(null)),{maximumAge:15*60*1e3,timeout:1e4})}))}catch{return null}};const B=":host{display:block}.geo-permission{--body-spacing:var(--sc-spacing-x-large);--width:460px}.geo-permission__content{line-height:1.5}.geo-permission__content p{margin:0 0 var(--sc-spacing-small)}.geo-permission__content p:first-child{margin-top:0}.geo-permission__content p:last-child{margin-bottom:0}";const Q=B;const X="sc_geo_capture_decision";const $=class{constructor(e){i(this,e);this.open=false}isReady(){var i,e,t;return!!((t=(e=(i=d.checkout)===null||i===void 0?void 0:i.line_items)===null||e===void 0?void 0:e.pagination)===null||t===void 0?void 0:t.count)&&k(d.checkout,d.geoAddressCapturableCountries)}wasDismissed(){try{return window.localStorage.getItem(X)==="declined"}catch{return false}}rememberDismissed(){try{window.localStorage.setItem(X,"declined")}catch{}}async getPermissionState(){var i,e;try{const t=await((i=navigator.permissions)===null||i===void 0?void 0:i.query({name:"geolocation"}));return(e=t===null||t===void 0?void 0:t.state)!==null&&e!==void 0?e:null}catch{return null}}async componentDidLoad(){if(!d.captureGeoAddressEnabled)return;if(!(window===null||window===void 0?void 0:window.isSecureContext)||!(navigator===null||navigator===void 0?void 0:navigator.geolocation))return;if(this.isReady()){this.maybePromptForLocation();return}this.removeCheckoutListener=n("checkout",(()=>{var i;if(!this.isReady())return;(i=this.removeCheckoutListener)===null||i===void 0?void 0:i.call(this);this.removeCheckoutListener=undefined;this.maybePromptForLocation()}))}disconnectedCallback(){var i;(i=this.removeCheckoutListener)===null||i===void 0?void 0:i.call(this)}async maybePromptForLocation(){const i=await this.getPermissionState();if(i==="granted"){this.capture();return}if(i==="denied")return;if(this.wasDismissed())return;this.open=true}async capture(){if(d.geoCoordinates)return;d.geoCoordinates=await Z()}onAllow(){this.open=false;this.capture()}onDecline(){this.rememberDismissed();this.open=false}render(){const{geoCapture:i}=d;const o=x();const s=(i===null||i===void 0?void 0:i.title)||o.title;const n=(i===null||i===void 0?void 0:i.content)||o.content;const r=(i===null||i===void 0?void 0:i.allowLabel)||o.allowLabel;const a=(i===null||i===void 0?void 0:i.declineLabel)||o.declineLabel;return e(t,{key:"0d45b5dae4c9360b480c4974804e795e248ba7c2"},e("sc-dialog",{key:"df1fe4f09f3277b6c130273eeb0583c1c1ea87d8",open:this.open,noHeader:true,onScRequestClose:()=>this.onDecline(),class:"geo-permission"},e("sc-dashboard-module",{key:"a9f984d81450c9590294b79ca2c3f8d21eccb2f9",style:{"--sc-dashboard-module-spacing":"1em"}},e("sc-flex",{key:"bd04904dcaf49bded24d7e595ce98270a20de720",slot:"heading","align-items":"center","justify-content":"flex-start"},e("sc-icon",{key:"cacf91cca40dfc1f717dcdb3a573016907322546",name:"map-pin",style:{color:"var(--sc-color-primary-500)"}}),s),e("div",{key:"c083947e2f61f38862b44f5e90ce08d781d63acd",slot:"description",class:"geo-permission__content",innerHTML:n})),e("sc-button",{key:"5d11154a47ee136a0bc199fcb7bfb1bfc55ec3a6",slot:"footer",type:"text",onClick:()=>this.onDecline()}
1,a),e("sc-button",{key:"9d95e4fc5ea72a989edee552cea41457e7b55b07",slot:"footer",type:"primary",onClick:()=>this.onAllow()},r,e("sc-icon",{key:"af6f9f5ad7cea70659b0cd4ca0422e2775283359",name:"map-pin",slot:"suffix"}))))}};$.style=Q;const K=(i,e=[])=>{const t={};(e||[]).forEach((e=>{var o,s,n;if((e===null||e===void 0?void 0:e.bundle_line_item)!==i)return;const d=(s=(o=e===null||e===void 0?void 0:e.price)===null||o===void 0?void 0:o.product)===null||s===void 0?void 0:s.id;const r=(n=e===null||e===void 0?void 0:e.variant)===null||n===void 0?void 0:n.id;if(d&&r)t[d]=r}));return t};const ii=i=>{var e,t,o;const s=(e=i===null||i===void 0?void 0:i.price)===null||e===void 0?void 0:e.product;const n=((t=i===null||i===void 0?void 0:i.variant)===null||t===void 0?void 0:t.id)?(o=i===null||i===void 0?void 0:i.variant)===null||o===void 0?void 0:o.available_stock:s===null||s===void 0?void 0:s.available_stock;return Math.max(Number(n)||0,0)};const ei=(i=[])=>(i||[]).filter((i=>(i===null||i===void 0?void 0:i.purchasable_status)==="out_of_stock"&&ii(i)<i.quantity));const ti=(i=[],e=new Map)=>{const t=new Map;ei(i).forEach((o=>{var s,n,d,r;if(!o.component_line_item||!o.bundle_line_item)return;const a=(i||[]).find((i=>i.id===o.bundle_line_item));if(!(a===null||a===void 0?void 0:a.id))return;const c=(n=(s=o.price)===null||s===void 0?void 0:s.product)===null||n===void 0?void 0:n.id;if(c&&((d=e.get(a.id))===null||d===void 0?void 0:d.has(c)))return;const l=I(o,a.quantity);const u=Math.floor(ii(o)/l);const h=(r=t.get(a.id))!==null&&r!==void 0?r:a.quantity;t.set(a.id,Math.max(Math.min(h,u),0))}));return t};const oi=(i=[],e=new Map)=>{const t=new Map(Array.from(e,(([i,e])=>[i,new Set(Object.keys(e))])));const o=ti(i,t);const s=new Map;ei(i).forEach((i=>{if(i.component_line_item||!i.id)return;s.set(i.id,ii(i))}));return(i||[]).filter((i=>!i.component_line_item)).map((i=>{var t,n,d,r;const a=i.id;const c=!!a&&e.has(a);let l=i.quantity;if(a&&o.has(a))l=(t=o.get(a))!==null&&t!==void 0?t:l;else if(a&&s.has(a))l=(n=s.get(a))!==null&&n!==void 0?n:l;return{id:a,price_id:(d=i.price)===null||d===void 0?void 0:d.id,quantity:l,...((r=i===null||i===void 0?void 0:i.variant)===null||r===void 0?void 0:r.id)?{variant:i.variant.id}:{},...a&&c?{bundle_component_variants:e.get(a)}:{}}}))};const si=(i=[])=>{const e=ti(i);const t=new Set;const o=[];ei(i).forEach((s=>{var n,d,r;if(s.component_line_item&&s.bundle_line_item){const r=(i||[]).find((i=>i.id===s.bundle_line_item));if(!(r===null||r===void 0?void 0:r.id)||t.has(r.id))return;t.add(r.id);const a=(n=r.price)===null||n===void 0?void 0:n.product;o.push({name:a===null||a===void 0?void 0:a.name,variant:r===null||r===void 0?void 0:r.variant_display_options,image:r===null||r===void 0?void 0:r.image,from:r.quantity,to:Math.max((d=e.get(r.id))!==null&&d!==void 0?d:r.quantity,0)});return}const a=(r=s.price)===null||r===void 0?void 0:r.product;o.push({name:a===null||a===void 0?void 0:a.name,variant:s===null||s===void 0?void 0:s.variant_display_options,image:s===null||s===void 0?void 0:s.image,from:s.quantity,to:ii(s)})}));return o};const ni=":host{display:block}sc-table{height:auto}h4{display:block;margin:0;font-weight:var(--sc-font-weight-bold);font-size:var(--sc-font-size-medium)}.stock-alert{--body-spacing:var(--sc-spacing-x-large);--width:500px}.stock-alert__image{width:50px;height:50px;object-fit:cover;margin-right:10px;display:block}.stock-alert__product-info{display:flex;flex-direction:column;gap:var(--sc-spacing-xx-small)}.stock-alert__variant{color:var(--sc-color-gray-500);font-size:var(--sc-font-size-small)}.stock-alert__quantity{color:var(--sc-color-gray-500);font-weight:var(--sc-font-weight-bold);display:flex;align-items:center;justify-content:flex-end;gap:var(--sc-spacing-xx-small)}";const di=ni;const ri=class{constructor(e){i(this,e);this.scUpdateLineItem=o(this,"scUpdateLineItem",7);this.stockErrors=[];this.busy=undefined;this.error=undefined}get lineItems(){var i,e;return((e=(i=d.checkout)===null||i===void 0?void 0:i.line_items)===null||e===void 0?void 0:e.data)||[]}async onSubmit(){let i=false;try{this.busy=true;this.error=null;const e=this.lineItems;const t=ti(e);const o=new Map;ei(e).forEach((i=>{var s,n,d;if(!i.component_line_item||!i.bundle_line_item)return;const r=e.find((e=>e.id===i.bundle_line_item));if(!(r===null||r===void 0?void 0:r.id)||((s=t.get(r.id))!==null&&s!==void 0?s:0)>=1)return;const a=(n=i.price)===null||n===void 0?void 0:n.product;if(!(a===null||a===void 0?void 0:a.id))return;const c=(((d=a===null||a===void 0?void 0:a.variants)===null||d===void 0?void 0:d.data)||[]).find((e=>{var t,o;return e.id!==((t=i.variant)===null||t===void 0?void 0:t.id)&&((o=e.available_stock)!==null&&o!==void 0?o:0)>0}));if(!(c===null||c===void 0?void 0:c.id))return;const l=o.get(r.id)||K(r.id,e);l[a.id]=c.id;o.set(r.id,l)}));i=o.size>0;const s=oi(e,o).filter((i=>!!i.quantity));d.checkout=await f({id:d.checkout.id,data:{line_items:s}})}catch(e){if(i){this.error=wp.i18n.__("We could not automatically update an out-of-stock bundle item. Please remove it or choose a different bundle.","surecart")}else{const i=((e===null||e===void 0?void 0:e.additional_errors)||[]).map((i=>
1i===null||i===void 0?void 0:i.message)).filter(Boolean);const t=[(e===null||e===void 0?void 0:e.message)||wp.i18n.__("Something went wrong.","surecart")];if(i.length)t.push(i.join(". "));this.error=t.join(" ")}}finally{this.busy=false}}render(){const i=si(this.lineItems);const o=i===null||i===void 0?void 0:i.some((i=>(i===null||i===void 0?void 0:i.to)<1));return e(t,{key:"acbef859b372585f275753310f0a0522d627b9ec"},e("sc-dialog",{key:"41f51f533d77c8f96c3c265aaaadee5ed2a80c90",open:!!i.length&&C()==="draft",noHeader:true,onScRequestClose:i=>i.preventDefault(),class:"stock-alert"},e("sc-dashboard-module",{key:"00ee738effe3092df20007eaed0e3ac0c4b1863b",class:"subscription-cancel",error:this.error,style:{"--sc-dashboard-module-spacing":"1em"}},e("sc-flex",{key:"54cc0304e2e6f8ce0476a05edbf1ba5222bb35a1",slot:"heading","align-items":"center","justify-content":"flex-start"},e("sc-icon",{key:"c58a11c951145aca4d0421fdc24643325b1daada",name:"alert-circle",style:{color:"var(--sc-color-primary-500"}}),o?wp.i18n.__("Out of Stock","surecart"):wp.i18n.__("Quantity Update","surecart")),e("span",{key:"9d3a9107639d100d4d815564af2714214058c190",slot:"description"},o?wp.i18n.__("Some items are no longer available. Your cart will be updated.","surecart"):wp.i18n.__("Available quantities for these items have changed. Your cart will be updated.","surecart")),e("sc-card",{key:"a01d877d96b63f948d5ae969fa414851e36127c2","no-padding":true},e("sc-table",{key:"3b432e96899754d2bd44c298a3b30bb1e8f95d5e"},e("sc-table-cell",{key:"687fa517eef975afa99dbd9ca4b820bd8228e1ad",slot:"head"},wp.i18n.__("Description","surecart")),e("sc-table-cell",{key:"2a7f0e9bb3152acbccd57ba55e07b0eec2b3cef8",slot:"head",style:{width:"100px",textAlign:"right"}},wp.i18n.__("Quantity","surecart")),i.map(((t,o)=>{const s=o===i.length-1;return e("sc-table-row",{style:{"--columns":"2",...s?{border:"none"}:{}}},e("sc-table-cell",null,e("sc-flex",{justifyContent:"flex-start",alignItems:"center"},(t===null||t===void 0?void 0:t.image)&&e("img",{...t.image,class:"stock-alert__image"}),e("div",{class:"stock-alert__product-info"},e("h4",null,t.name),(t===null||t===void 0?void 0:t.variant)&&e("span",{class:"stock-alert__variant"},t.variant)))),e("sc-table-cell",{style:{width:"100px",textAlign:"right"}},e("span",{class:"stock-alert__quantity"},e("span",null,t===null||t===void 0?void 0:t.from)," ",e("sc-icon",{name:"arrow-right"})," ",e("span",null,Math.max(t===null||t===void 0?void 0:t.to,0)))))}))))),e("sc-button",{key:"b2fc3f985615956ba887dd9243c5b4693652cd03",slot:"footer",type:"primary",loading:this.busy,onClick:()=>this.onSubmit()},wp.i18n.__("Continue","surecart"),e("sc-icon",{key:"4a8e198f3ad2374764abc70a96516b832aeda135",name:"arrow-right",slot:"suffix"})),this.busy&&e("sc-block-ui",{key:"67747c60ab6ff8e5838d8d4c30543205cbc55248",spinner:true})))}};ri.style=di;const ai=".confirm__icon{margin-bottom:var(--sc-spacing-medium);display:flex;justify-content:center}.confirm__icon-container{background:var(--sc-color-primary-500);width:55px;height:55px;border-radius:999999px;display:flex;align-items:center;justify-content:center;font-size:26px;line-height:1;color:white}sc-dialog::part(overlay){backdrop-filter:blur(4px)}";const ci=ai;const li=class{constructor(e){i(this,e);this.scOrderPaid=o(this,"scOrderPaid",7);this.scSetState=o(this,"scSetState",7);this.showSuccessModal=false;this.manualPaymentMethod=undefined;this.checkoutStatus=undefined;this.successUrl=undefined}handleConfirmOrderEvent(){if(this.checkoutStatus==="test_mode_restricted"){this.confirmOrder()}}async confirmOrder(){var i;this.manualPaymentMethod=(i=T.manualPaymentMethods||[])===null||i===void 0?void 0:i.find((i=>i.id===P.id));this.showSuccessModal=true;l()}handleSuccessModal(){if(this.showSuccessModal){setTimeout((()=>{var i;(i=this.continueButton)===null||i===void 0?void 0:i.focus()}),50)}}render(){var i,o,s,n,d;return e(t,{key:"8880988be24c475421d2b54c9dfd945684766746"},e("slot",{key:"0301cb11f3a0e1d10d60df81dc880ffc77693aaa"}),e("sc-dialog",{key:"a96eb1959b206b58dc1ada90b707963e779e62f4",open:!!this.showSuccessModal,style:{"--body-spacing":"var(--sc-spacing-xxx-large)","--width":"400px"},noHeader:true,onScRequestClose:i=>i.preventDefault()},e("div",{key:"496ecd0823810af00622b5a37748b9c2c9837b5f",class:"confirm__icon"},e("div",{key:"9677f7f47900bf129659b27a00eb90e06368a36f",class:"confirm__icon-container"},e("sc-icon",{key:"167e6fbc7a880b4092aadf657c3a780ac8136cda",name:"check"}))),e("sc-dashboard-module",{key:"ff63fb9cc9c26176ff347c9809cab0c186ecbdf1",heading:wp.i18n.__("Test checkout successful!","surecart"),style:{"--sc-dashboard-module-spacing":"var(--sc-spacing-x-large)",textAlign:"center"}},e("span",{key:"02716802dc259ae7505ab69a817e3a6da55129c9",slot:"description"}
1,wp.i18n.__("This is a simulated test checkout, and no orders were processed. To perform a test order, please contact your store administrator. ","surecart")),!!((i=this.manualPaymentMethod)===null||i===void 0?void 0:i.name)&&!!((o=this.manualPaymentMethod)===null||o===void 0?void 0:o.instructions)&&e("sc-alert",{key:"fe6f7c7134aa4a30fb9eeb04451b418018e05c13",type:"info",open:true,style:{"text-align":"left"}},e("span",{key:"c3ccaecdf4d8a9407ef333691d631c83a713b23a",slot:"title"},(s=this.manualPaymentMethod)===null||s===void 0?void 0:s.name),e("div",{key:"4881bc45861b75cd49989239a6ea074e8418f5a6",innerHTML:(n=this.manualPaymentMethod)===null||n===void 0?void 0:n.instructions})),e("sc-button",{key:"b27f7d8f4844d5c6fc05efc5915232fd2c3cf079",href:(d=window===null||window===void 0?void 0:window.scData)===null||d===void 0?void 0:d.home_url,size:"large",type:"primary",ref:i=>this.continueButton=i},wp.i18n.__("Go to Homepage","surecart"),e("sc-icon",{key:"c1ba21e3fec1994dd1d27c0207138e58428c0113",name:"arrow-right",slot:"suffix"})))))}get el(){return s(this)}static get watchers(){return{checkoutStatus:["handleConfirmOrderEvent"],showSuccessModal:["handleSuccessModal"]}}};li.style=ci;const ui=class{constructor(e){i(this,e);this.state=undefined}componentDidLoad(){window.addEventListener("beforeunload",(i=>this.warnIfUnsavedChanges(i)),{capture:true})}warnIfUnsavedChanges(i){if(["updating","finalizing","confirming"].includes(this.state)){console.log({e:i});i.preventDefault();i.returnValue=wp.i18n.__("Your payment is processing. Exiting this page could cause an error in your order. Please do not navigate away from this page.","surecart");return i.returnValue}}};const hi=class{constructor(e){i(this,e);this.phoneRequiredByShipping=false;this.disabled=undefined;this.taxProtocol=undefined;this.hasAddress=undefined;this.hasTaxIDField=undefined;this.hasBumpsField=undefined;this.hasTaxLine=undefined;this.hasBumpLine=undefined;this.hasShippingChoices=undefined;this.hasShippingAmount=undefined;this.hasInvoiceDetails=undefined;this.hasInvoiceMemo=undefined;this.hasTrialLineItem=undefined;this.hasCustomerPhone=undefined}handleOrderChange(){var i,e,t,o,s,n,r,a,c;if(this.disabled)return;if(R()){this.addAddressField()}this.handlePhoneRequiredForShipping();if((t=(e=(i=d.checkout)===null||i===void 0?void 0:i.recommended_bumps)===null||e===void 0?void 0:e.data)===null||t===void 0?void 0:t.length){this.addBumps()}if(!!((o=d.checkout)===null||o===void 0?void 0:o.tax_amount)){this.addTaxLine()}if(((s=d.checkout)===null||s===void 0?void 0:s.shipping_enabled)&&((n=d.checkout)===null||n===void 0?void 0:n.selected_shipping_choice_required)){this.addShippingChoices()}if(!!((r=d.checkout)===null||r===void 0?void 0:r.shipping_amount)){this.addShippingAmount()}if(!!((a=d.checkout)===null||a===void 0?void 0:a.invoice)){this.addInvoiceDetails();this.addInvoiceMemo()}if(!!((c=d.checkout)===null||c===void 0?void 0:c.trial_amount)){this.addTrialLineItem()}}handleHasAddressChange(){if(!this.hasAddress)return;this.handleShippingAddressRequired()}componentWillLoad(){var i,e;this.hasAddress=!!this.el.querySelector("sc-order-shipping-address");this.hasTaxIDField=!!this.el.querySelector("sc-order-tax-id-input");this.hasBumpsField=!!this.el.querySelector("sc-order-bumps");this.hasTaxLine=!!this.el.querySelector("sc-line-item-tax");this.hasShippingChoices=!!this.el.querySelector("sc-shipping-choices");this.hasShippingAmount=!!this.el.querySelector("sc-line-item-shipping");this.hasInvoiceDetails=!!this.el.querySelector("sc-invoice-details");this.hasInvoiceMemo=!!this.el.querySelector("sc-invoice-memo");this.hasTrialLineItem=!!this.el.querySelector("sc-line-item-trial");this.hasCustomerPhone=!!this.el.querySelector("sc-customer-phone");if(((i=this.taxProtocol)===null||i===void 0?void 0:i.tax_enabled)&&((e=this.taxProtocol)===null||e===void 0?void 0:e.eu_vat_required)){this.addTaxIDField()}if(j("razorpay")){this.addCustomerPhone()}this.handleOrderChange();this.removeCheckoutListener=n("checkout",(()=>this.handleOrderChange()));this.removePaymentRequiresShippingListener=n("paymentMethodRequiresShipping",(()=>this.handleOrderChange()))}disconnectedCallback(){this.removeCheckoutListener();this.removePaymentRequiresShippingListener()}handleShippingAddressRequired(){var i;if(!((i=d.checkout)===null||i===void 0?void 0:i.shipping_address_required))return;const e=this.el.querySelector("sc-order-shipping-address");if(!e)return;e.required=true;const t=this.el.querySelector("sc-customer-name");if(!!t){t.required=true;return}const o=this.el.querySelector("sc-customer-firstname");const s=this.el.querySelector("sc-customer-lastname");if(!!o){o.required=true;if(!!s){s.required=true}return}e.requireName=true;e.showName=true}addAddressField(){if(this.hasAddress){return}const i=this.el.querySelector("sc-payment");const e=document.createElement("sc-order-shipping-address");i.parentNode.insertBefore(e,i);if(L()){const e=document.createElement("sc-order-billing-address");e.label=wp.i18n.__("Billing Address","surecart");i.parentNode.insertBefore(e,i)}else{e.label=wp.i18n.__("Address","surecart")}this.hasAddress=true}addTaxIDField(){if(this.hasTaxIDField)return;const i=this.el.querySelector("sc-payment");const e=document.createElement("sc-order-tax-id-input");i.parentNode.insertBefore(e,i);this.hasTaxIDField=true}handlePhoneRequiredForShipping(){const i=this.el.querySelector("sc-customer-phone");const e=A();if(!e){if(this.phoneRequiredByShipping&&i){i.required=false;this.phoneRequiredByShipping=false}return}if(i){if(!i.required){i.required=true;this.phoneRequiredByShipping=true}return}this.addCustomerPhone();this.phoneRequiredByShipping=true}addCustomerPhone(){if(this.hasCustomerPhone)return;const i=this.el.querySelector("sc-payment");
1if(!i)return;const e=document.createElement("sc-customer-phone");e.label=wp.i18n.__("Phone","surecart");e.required=true;i.parentNode.insertBefore(e,i);this.hasCustomerPhone=true}addBumps(){if(this.hasBumpsField)return;const i=this.el.querySelector("sc-order-billing-address")||this.el.querySelector("sc-payment");const e=document.createElement("sc-order-bumps");i===null||i===void 0?void 0:i.parentNode.insertBefore(e,i.nextSibling);this.hasBumpsField=true}addTaxLine(){var i;if(this.hasTaxLine)return;const e=this.el.querySelector("sc-line-item-total[total=total]");const t=document.createElement("sc-line-item-tax");if(!e)return;if(((i=e===null||e===void 0?void 0:e.previousElementSibling)===null||i===void 0?void 0:i.tagName)==="SC-DIVIDER"){e.parentNode.insertBefore(t,e.previousElementSibling)}else{e.parentNode.insertBefore(t,e)}this.hasTaxLine=true}addShippingChoices(){if(this.hasShippingChoices)return;const i=this.el.querySelector("sc-payment");const e=document.createElement("sc-shipping-choices");i.parentNode.insertBefore(e,i);this.hasShippingChoices=true}addShippingAmount(){var i;if(this.hasShippingAmount)return;let e=this.el.querySelector("sc-line-item-tax");const t=this.el.querySelector("sc-line-item-total[total=total]");if(!t)return;if(!e){e=((i=t===null||t===void 0?void 0:t.previousElementSibling)===null||i===void 0?void 0:i.tagName)==="SC-DIVIDER"?t.previousElementSibling:t}const o=document.createElement("sc-line-item-shipping");e.parentNode.insertBefore(o,e);this.hasShippingAmount=true}addInvoiceDetails(){if(this.hasInvoiceDetails)return;let i=this.el.querySelector("sc-line-items");const e=document.createElement("sc-invoice-details");i.parentNode.insertBefore(e,i);const t=document.createElement("sc-line-item-invoice-number");e.appendChild(t);const o=document.createElement("sc-line-item-invoice-due-date");e.appendChild(o);const s=document.createElement("sc-line-item-invoice-receipt-download");e.appendChild(s);const n=document.createElement("sc-divider");e.appendChild(n);this.hasInvoiceDetails=true}addInvoiceMemo(){if(this.hasInvoiceMemo)return;const i=this.el.querySelector("sc-order-summary");const e=document.createElement("sc-invoice-details");i.parentNode.insertBefore(e,i.nextSibling);const t=document.createElement("sc-invoice-memo");e.appendChild(t);this.hasInvoiceMemo=true}addTrialLineItem(){if(this.hasTrialLineItem)return;const i=this.el.querySelector("sc-line-item-total[total=subtotal]");const e=document.createElement("sc-line-item-trial");if(!i)return;i.parentNode.insertBefore(e,i.nextSibling);this.hasTrialLineItem=true}render(){return e("slot",{key:"41960ea6ba0bc03430797a8ffe6db9d7b32b2d24"})}get el(){return s(this)}static get watchers(){return{hasAddress:["handleHasAddressChange"]}}};const vi=class{constructor(e){i(this,e)}componentWillLoad(){this.maybeAddErrorsComponent()}maybeAddErrorsComponent(){var i,e;if(!!this.el.querySelector("sc-checkout-form-errors"))return;const t=document.createElement("sc-checkout-form-errors");(e=(i=this.el.querySelector("sc-form"))===null||i===void 0?void 0:i.prepend)===null||e===void 0?void 0:e.call(i,t)}render(){return e("slot",{key:"1f35e949cd65cb4be249a43d238257923c26227d"})}get el(){return s(this)}};const fi=class{constructor(e){i(this,e);this.scSetCheckoutFormState=o(this,"scSetCheckoutFormState",7);this._stateService=O(D);this.checkoutState=D.initialState}setState(i){const{send:e}=this._stateService;r(i);return e(i)}handleCheckoutStateChange(i){this.scSetCheckoutFormState.emit(i.value)}componentWillLoad(){this._stateService.subscribe((i=>this.checkoutState=i));this._stateService.start()}disconnectedCallback(){this._stateService.stop()}handleSetStateEvent(i){this.setState(i.detail)}async handlePaid(){this.setState("PAID")}render(){if(this.checkoutState.value==="expired"){return e("sc-block-ui",null,e("div",null,wp.i18n.__("Please refresh the page.","surecart")))}return e("slot",null)}static get watchers(){return{checkoutState:["handleCheckoutStateChange"]}}};const pi=":host{display:block}";const mi=pi;const bi=class{constructor(e){i(this,e);this.scSetLoggedIn=o(this,"scSetLoggedIn",7);this.scSetCustomer=o(this,"scSetCustomer",7);this.loggedIn=undefined;this.order=undefined;this.notice=undefined;this.open=undefined;this.loading=undefined;this.error=undefined}handleLoginPrompt(){this.open=true}handleLoginDialogChange(i){if(i){setTimeout((()=>{this.loginForm.querySelector("sc-input").triggerFocus()}),100)}}handleLoggedInChange(i,e){if(e===false&&i){this.notice=true}}handleOrderChange(i,e){if((i===null||i===void 0?void 0:i.updated_at)!==(e===null||e===void 0?void 0:e.updated_at)){this.notice=false}}async handleFormSubmit(i){i.preventDefault();i.stopImmediatePropagation();this.error=null;const{login:e,password:t}=await i.target.getFormJson();try{this.loading=true;const{name:i,email:o}=await q({method:"POST",path:"surecart/v1/login",data:{login:e,password:t}});this.scSetLoggedIn.emit(true);this.scSetCustomer.emit({name:i,email:o});this.open=false}catch(i){console.error(i);this.error=(i===null||i===void 0?void 0:i.message)||wp.i18n.__("Something went wrong","surecart")}finally{this.loading=false}}render(){return e(t,{key:"02f6ec244cf0293783ab8396e8f9c99445171a6d"},e("slot",{key:"f11822dc451dd1d0d9a99b559e31573870f72522"}),!this.loggedIn&&e("sc-dialog",{key:"a56f8afd71381494a0278557f11332cec69bdc0e",label:wp.i18n.__("Login to your account","surecart"),open:this.open,onScRequestClose:()=>this.open=false},e("sc-form",{key:"1759621f060fe1d8e20b08f24ba231ea440347d8",ref:i=>this.loginForm=i,onScFormSubmit:i=>{i.preventDefault();i.stopImmediatePropagation()},onScSubmit:i=>this.handleFormSubmit(i)},!!this.error&&e("sc-alert",{key:"bdd0432ed04c16ccd60268dfd414293890d46dca",type:"danger",open:!!this.error},this.error),e("sc-input",{key:"f9168c69378aeaf17f8b6c57c2cc52024de56e6e",label:wp.i18n.__("Email or Username","surecart"),type:"text",name:"login",required:true,autofocus:this.open}),e("sc-input",{key:"780036e78c69d74518a4ca04a8734896ef98a19a",label:wp.i18n.__("Password","surecart"),type:"password",name:"password",required:true}),e("sc-button",{key:"c50335604faeefd5d56e16c8d26d6353f0b9adde",type:"primary",full:true,loading:this.loading,submit:true},wp.i18n.__("Login","surecart")))))}static get watchers(){return{open:["handleLoginDialogChange"],loggedIn:["handleLoggedInChange"],order:["handleOrderChange"]}}};bi.style=mi;const yi=".confirm__icon{margin-bottom:var(--sc-spacing-medium);display:flex;justify-content:center}.confirm__icon-container{background:var(--sc-color-primary-500);width:55px;height:55px;border-radius:999999px;display:flex;align-items:center;justify-content:center;font-size:26px;line-height:1;color:white}sc-dialog::part(overlay){backdrop-filter:blur(4px)}";const gi=yi;const wi=class{constructor(e){i(this,e);this.scOrderPaid=o(this,"scOrderPaid",7);this.scSetState=o(this,"scSetState",7);this.showSuccessModal=false;this.manualPaymentMethod=undefined;this.checkoutStatus=undefined;this.successUrl=undefined}handleConfirmOrderEvent(){if(this.checkoutStatus==="confirming"){this.confirmOrder()}else if(this.checkoutStatus==="confirmed"){F(wp.i18n.__("Order has been confirmed. Please select continue to go to the next step.","surecart"))}}async confirmOrder(){var i,e,t,o;try{d.checkout=await q({method:"PATCH",path:J(`surecart/v1/checkouts/${(i=d===null||d===void 0?void 0:d.checkout)===null||i===void 0?void 0:i.id}/confirm`,{expand:p})});this.scSetState.emit("CONFIRMED")}catch(i){console.error(i);H(i)}finally{this.manualPaymentMethod=((e=d.checkout)===null||e===void 0?void 0:e.manual_payment_method)||null;const i=d.checkout;const s=d.formId;if(!!((t=i===null||i===void 0?void 0:i.current_upsell)===null||t===void 0?void 0:t.permalink)){setTimeout((()=>{var e;return window.location.assign(J((e=i===null||i===void 0?void 0:i.current_upsell)===null||e===void 0?void 0:e.permalink,{sc_checkout_id:i===null||i===void 0?void 0:i.id,sc_form_id:s}))}),50);l();return}const n=((o=i===null||i===void 0?void 0:i.metadata)===null||o===void 0?void 0:o.success_url)||this.successUrl;if(n){this.scSetState.emit("REDIRECT");const e=J(n,{sc_order:i===null||i===void 0?void 0:i.id});setTimeout((()=>window.location.assign(e)),50)}else{this.showSuccessModal=true}l()}}getSuccessUrl(){var i,e,t,o,s;const n=((e=(i=d.checkout)===null||i===void 0?void 0:i.metadata)===null||e===void 0?void 0:e.success_url)||this.successUrl;return n?J(n,{sc_order:(t=d.checkout)===null||t===void 0?void 0:t.id}):(s=(o=window===null||window===void 0?void 0:window.scData)===null||o===void 0?void 0:o.pages)===null||s===void 0?void 0:s.dashboard}handleSuccessModal(){if(this.showSuccessModal){setTimeout((()=>{var i;(i=this.continueButton)===null||i===void 0?void 0:i.focus()}),50)}}render(){var i,o,s,n,d,r,a,c,l,u;return e(t,{key:"d994308466aeee5553b205934d4942f0367c4ca8"},e("slot",{key:"c3c95b9bea914988eeb4b067e4f48b1b94ba722a"}),e("sc-dialog",{key:"28fc222a76aca3e16b8bea444059979b6d2ca39e",open:!!this.showSuccessModal,style:{"--body-spacing":"var(--sc-spacing-xxx-large)","--width":"400px"},noHeader:true,onScRequestClose:i=>i.preventDefault()},e("div",{key:"b668fb5bb4effcfe2ef096915ebdf7ef813351a0",class:"confirm__icon"},e("div",{key:"3c51cd3be9ca89170b6115ffd7a1fcb8f791702d",class:"confirm__icon-container"},e("sc-icon",{key:"6c43b0eceedec6ec315f3d7f3603b9012b6e1d83",name:"check"}))),e("sc-dashboard-module",{key:"2979427b1de30dbb2f33c8b863e39f103f09bc8d",heading:((o=(i=M===null||M===void 0?void 0:M.text)===null||i===void 0?void 0:i.success)===null||o===void 0?void 0:o.title)||wp.i18n.__("Thanks for your order!","surecart"),style:{"--sc-dashboard-module-spacing":"var(--sc-spacing-x-large)",textAlign:"center"}},e("span",{key:"168bf1c1f41863638ef94698490086962e6b2025",slot:"description"},((n=(s=M===null||M===void 0?void 0:M.text)===null||s===void 0?void 0:s.success)===null||n===void 0?void 0:n.description)||wp.i18n.__("Your payment was successful. A receipt is on its way to your inbox.","surecart")),!!((d=this.manualPaymentMethod)===null||d===void 0?void 0:d.name)&&!!((r=this.manualPaymentMethod)===null||r===void 0?void 0:r.instructions)&&e("sc-alert",{key:"5d09a59ebc2effeda803142a05fc795d215931a8",type:"info",open:true,style:{"text-align":"left"}},e("span",{key:"f990d30cc684cdfa179f6a1b1281348f09cc94d6",slot:"title"},(a=this.manualPaymentMethod)===null||a===void 0?void 0:a.name),e("div",{key:"7c89903831e052fbd427aa9916236b27d2bc9b7a",innerHTML:(c=this.manualPaymentMethod)===null||c===void 0?void 0:c.instructions})),e("sc-button",{key:"e066dbdc86032bd54c4509ef51ef0ebad54487c8",href:this.getSuccessUrl(),size:"large",type:"primary",ref:i=>this.continueButton=i},((u=(l=M===null||M===void 0?void 0:M.text)===null||l===void 0?void 0:l.success)===null||u===void 0?void 0:u.button)||wp.i18n.__("Continue","surecart"),e("sc-icon",{key:"87b506059ba9b7ca2133508de2a4f55dca3087dc",name:"arrow-right",slot:"suffix"})))))}get el(){return s(this)}static get watchers(){return{checkoutStatus:["handleConfirmOrderEvent"],showSuccessModal:["handleSuccessModal"]}}};wi.style=gi;const _i=class{constructor(e){i(this,e);this.scUpdateOrderState=o(this,"scUpdateOrderState",7);this.scUpdateDraftState=o(this,"scUpdateDraftState",7);this.scPaid=o(this,"scPaid",7);this.scSetState=o(this,"scSetState",7);this.removeGeoListeners=[];this.prices=[];this.persist=true}
1handlePricesChange(){let i=this.addInitialPrices()||[];if(!(i===null||i===void 0?void 0:i.length)){return}return this.loadUpdate({line_items:i})}async finalize(){return await this.handleFormSubmit()}async getFormData(){let i={};const e=this.el.querySelector("sc-form");if(e){const t=await e.getFormJson();i=V(t)}return i}async handleFormSubmit(){var i,e,t,o,s,n,a,c,l,u,h,v;z();r("FINALIZE");if(((i=d===null||d===void 0?void 0:d.checkout)===null||i===void 0?void 0:i.payment_method_required)&&(P===null||P===void 0?void 0:P.id)==="stripe"&&T.config.stripe.paymentElement){if(!((e=T===null||T===void 0?void 0:T.instances)===null||e===void 0?void 0:e.stripeElements)){r("REJECT");this.handleErrorResponse({message:"Stripe Elements not found.",code:"stripe_elements_not_found"});return new Error("Stripe Elements not found.")}const{error:i}=await((t=T===null||T===void 0?void 0:T.instances)===null||t===void 0?void 0:t.stripeElements.submit());if(i){console.error({error:i});r("REJECT");H(i);return}}let f=await this.getFormData();if(((o=window===null||window===void 0?void 0:window.scData)===null||o===void 0?void 0:o.recaptcha_site_key)&&(window===null||window===void 0?void 0:window.grecaptcha)){try{f["grecaptcha"]=await window.grecaptcha.execute(window.scData.recaptcha_site_key,{action:"surecart_checkout_submit"})}catch(i){console.error(i);r("REJECT");this.handleErrorResponse(i);return new Error(i===null||i===void 0?void 0:i.message)}}try{await this.update(f)}catch(i){console.error(i);r("REJECT");this.handleErrorResponse(i)}try{d.checkout=await m({id:(s=d===null||d===void 0?void 0:d.checkout)===null||s===void 0?void 0:s.id,query:{...(P===null||P===void 0?void 0:P.method)?{payment_method_type:P===null||P===void 0?void 0:P.method}:{},return_url:J(window.location.href,{...((n=d===null||d===void 0?void 0:d.checkout)===null||n===void 0?void 0:n.id)?{checkout_id:(a=d===null||d===void 0?void 0:d.checkout)===null||a===void 0?void 0:a.id}:{},is_surecart_payment_redirect:true})},data:f,processor:{id:P.id,manual:P.manual}});if((h=(u=(l=(c=d.checkout)===null||c===void 0?void 0:c.payment_intent)===null||l===void 0?void 0:l.processor_data)===null||u===void 0?void 0:u.mollie)===null||h===void 0?void 0:h.checkout_url){r("PAYING");return setTimeout((()=>{var i,e,t,o;return window.location.assign((o=(t=(e=(i=d.checkout)===null||i===void 0?void 0:i.payment_intent)===null||e===void 0?void 0:e.processor_data)===null||t===void 0?void 0:t.mollie)===null||o===void 0?void 0:o.checkout_url)}),50)}if(["paid","processing"].includes((v=d.checkout)===null||v===void 0?void 0:v.status)){this.scPaid.emit()}setTimeout((()=>{r("PAYING")}),50);return d.checkout}catch(i){console.error(i);this.handleErrorResponse(i);return new Error(i===null||i===void 0?void 0:i.message)}}async handlePaid(){r("PAID")}async handleAbandonedCartUpdate(i){const e=i.detail;this.loadUpdate({abandoned_checkout_enabled:e})}componentDidLoad(){this.findOrCreateOrder();this.watchGeoCoordinates()}disconnectedCallback(){this.removeGeoListeners.forEach((i=>i()))}watchGeoCoordinates(){if(!d.captureGeoAddressEnabled)return;this.removeGeoListeners=[n("geoCoordinates",(()=>this.maybeRepriceForGeo())),n("checkout",(()=>this.maybeRepriceForGeo()))]}maybeRepriceForGeo(){var i;const e=d.geoCoordinates;if(!e||!((i=d.checkout)===null||i===void 0?void 0:i.id))return;if(d.checkout.latitude===e.latitude&&d.checkout.longitude===e.longitude)return;if(E()||S())return;this.loadUpdate({})}async findOrCreateOrder(){var i;const{redirect_status:e,checkout_id:t,line_items:o,coupon:s,is_surecart_payment_redirect:n}=N(window.location.href);window.history.replaceState({},document.title,Y(window.location.href,"redirect_status","coupon","line_items","confirm_checkout_id","checkout_id","no_cart","is_surecart_payment_redirect"));if(!!n&&!!t){r("FINALIZE");r("PAYING");return this.handleCheckoutIdFromUrl(t,s,{refresh_status:true})}if(!!e){return this.handleRedirectStatus(e,t)}if(!!t){return this.handleCheckoutIdFromUrl(t,s)}if(!!o){return this.handleInitialLineItems(o,s)}const a=(i=d===null||d===void 0?void 0:d.checkout)===null||i===void 0?void 0:i.id;if(a&&this.persist){return this.handleExistingCheckout(a,s)}return this.handleNewCheckout(s)}async handleRedirectStatus(i,e){var t,o;console.info("Handling payment redirect.");if(i==="failed"){H(wp.i18n.__("Payment unsuccessful. Please try again.","surecart"));return}if(!e){H(wp.i18n.__("Could not find checkout. Please contact us before attempting to purchase again.","surecart"));return}try{r("FINALIZE");d.checkout=await b({id:e,query:{refresh_status:true}});if(((t=d.checkout)===null||t===void 0?void 0:t.status)&&["paid","processing"].includes((o=d.checkout)===null||o===void 0?void 0:o.status)){setTimeout((()=>{r("PAID");this.scPaid.emit()}),100)}}catch(i){this.handleErrorResponse(i)}}async handleCheckoutIdFromUrl(i,e="",t={}){var o;console.info("Handling existing checkout from url.",e,i);if(e){return this.loadUpdate({id:i,discount:{promotion_code:e},refresh_line_items:true,...t})}try{r("FETCH");d.checkout=await b({id:i,query:{refresh_line_items:true,...t}});r("RESOLVE")}catch(i){this.handleErrorResponse(i)}switch((o=d.checkout)===null||o===void 0?void 0:o.status){case"paid":case"processing":return setTimeout((()=>{r("FINALIZE");r("PAID");this.scPaid.emit()}),100);case"payment_failed":H({message:wp.i18n.__("Payment unsuccessful.","surecart")});r("REJECT");return;case"payment_intent_canceled":r("REJECT");return;case"canceled":l();H({message:wp.i18n.__("Payment canceled. Please try again.","surecart")});r("REJECT");return}}async handleInitialLineItems(i,e){console.info("Handling initial line items.");const t=this.el.querySelector("sc-order-shipping-address");return this.loadUpdate({line_items:i,refresh_line_items:true,...e?{discount:{promotion_code:e}}:{},...(t===null||t===void 0?void 0:t.defaultCountry)?{shipping_address:{country:t===null||t===void 0?void 0:t.defaultCountry}}:{}})}async handleNewCheckout(i){var e,t,o;const s=this.getFormData();let n=d.initialLineItems||[];const a=this.el.querySelector("sc-order-shipping-address");try{r("FETCH");d.checkout=await y({data:{...s,...i?{discount:{promotion_code:i}}:{},...(a===null||a===void 0?void 0:a.defaultCountry)?{shipping_address:{country:a===null||a===void 0?void 0:a.defaultCountry}}:{},line_items:n,...((e=d.taxProtocol)===null||e===void 0?void 0:e.eu_vat_required)?{tax_identifier:{number_type:"eu_vat"}}:{}}});r("RESOLVE")}catch(i){console.error(i);this.handleErrorResponse(i);if(((o=(t=i===null||i===void 0?void 0:i.additional_errors)===null||t===void 0?void 0:t[0])===null||o===void 0?void 0:o.code)==="checkout.discount.coupon.blank"){await this.handleNewCheckout(false);H(i)}}}async handleExistingCheckout(i,e){var t,o,s;if(!i)return this.handleNewCheckout(e);console.info("Handling existing checkout.");try{r("FETCH");d.checkout=await v({id:i,data:{...e?{discount:{promotion_code:e}}:{},...((t=d.taxProtocol)===null||t===void 0?void 0:t.eu_vat_required)?{tax_identifier:{number_type:"eu_vat"}}:{},refresh_line_items:true}});r("RESOLVE")}catch(e){console.error(e);this.handleErrorResponse(e);if(((s=(o=e===null||e===void 0?void 0:e.additional_errors)===null||o===void 0?void 0:o[0])===null||s===void 0?void 0:s.code)==="checkout.discount.coupon.blank"){await this.handleExistingCheckout(i,false);H(e)}}}async handleErrorResponse(i){var e,t,o,s,n,a;if(["checkout.not_found"].includes(i===null||i===void 0?void 0:i.code)){l();return this.handleNewCheckout(false)}if(["test_mode_restricted"].includes(i===null||i===void 0?void 0:i.code)){r("TEST_MODE_RESTRICTED");return}const c=((i===null||i===void 0?void 0:i.additional_errors)||[]).some((i=>{var e,t;const o=((t=(e=i===null||i===void 0?void 0:i.data)===null||e===void 0?void 0:e.options)===null||t===void 0?void 0:t.purchasable_statuses)||[];return["price_old_version","variant_old_version"].some((i=>o.includes(i)))}));if(c){await this.loadUpdate({id:(e=d===null||d===void 0?void 0:d.checkout)===null||e===void 0?void 0:e.id,refresh_line_items:true,status:"draft"});U(((o=(t=i===null||i===void 0?void 0:i.additional_errors)===null||t===void 0?void 0:t[0])===null||o===void 0?void 0:o.message)||wp.i18n.__("Some products in your order were outdated and have been updated. Please review your order summary before proceeding to payment.","surecart"));r("REJECT");return}if(((n=(s=i===null||i===void 0?void 0:i.additional_errors)===null||s===void 0?void 0:s[0])===null||n===void 0?void 0:n.code)==="checkout.product.out_of_stock"){this.fetch();r("REJECT");return}if(["order.invalid_status_transition"].includes(i===null||i===void 0?void 0:i.code)){await this.loadUpdate({id:(a=d===null||d===void 0?void 0:d.checkout)===null||a===void 0?void 0:a.id,status:"draft"});this.handleFormSubmit();return}if((i===null||i===void 0?void 0:i.code)==="rest_cookie_invalid_nonce"){r("EXPIRE");return}if((i===null||i===void 0?void 0:i.code)==="readonly"){l();window.location.assign(Y(window.location.href,"order"));return}H(i);r("REJECT")}async initialize(i={}){let e=d.initialLineItems||[];return this.loadUpdate({...(e===null||e===void 0?void 0:e.length)?{line_items:e}:{},...i})}addInitialPrices(){var i;if(!((i=this===null||this===void 0?void 0:this.prices)===null||i===void 0?void 0:i.length))return[];if(this.prices.some((i=>!(i===null||i===void 0?void 0:i.id)))){return}return this.prices.map((i=>({price_id:i.id,quantity:i.quantity,variant:i.variant})))}getSessionId(){var i,e;const t=G(window.location.href,"checkout_id");if(!!t){return t}if((i=d===null||d===void 0?void 0:d.checkout)===null||i===void 0?void 0:i.id){return(e=d===null||d===void 0?void 0:d.checkout)===null||e===void 0?void 0:e.id}return null}async fetchCheckout(i,{query:e={},data:t={}}={}){try{r("FETCH");const o=await v({id:i,query:e,data:t});r("RESOLVE");return o}catch(i){this.handleErrorResponse(i)}}async fetch(i={}){try{r("FETCH");d.checkout=await b({id:this.getSessionId(),query:i});r("RESOLVE")}catch(i){this.handleErrorResponse(i)}}async update(i={},e={}){try{d.checkout=await v({id:(i===null||i===void 0?void 0:i.id)?i.id:this.getSessionId(),data:i,query:e})}catch(i){if(["checkout.not_found"].includes(i===null||i===void 0?void 0:i.code)){l();return this.initialize()}console.error(i);throw i}}async loadUpdate(i={}){try{r("FETCH");await this.update(i);r("RESOLVE")}catch(i){this.handleErrorResponse(i)}}render(){return e("sc-line-items-provider",{key:"2390c7744f8a1848a01bc15ede9c549c92b573e8",order:d===null||d===void 0?void 0:d.checkout,onScUpdateLineItems:i=>this.loadUpdate({line_items:i.detail})},e("slot",{key:"c95c4a4e20edf2807c812ca71cf403c8ae4173e3"}))}get el(){return s(this)}
1static get watchers(){return{prices:["handlePricesChange"]}}};export{W as sc_checkout_autofill_provider,$ as sc_checkout_geo_permission,ri as sc_checkout_stock_alert,li as sc_checkout_test_complete,ui as sc_checkout_unsaved_changes_warning,hi as sc_form_components_validator,vi as sc_form_error_provider,fi as sc_form_state_provider,bi as sc_login_provider,wi as sc_order_confirm_provider,_i as sc_session_provider}; 2//# sourceMappingURL=p-6ec415c6.entry.js.map
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.