import{u as o,s as a,c as i}from"./p-1282ed4a.js";import{c as t}from"./p-78468e45.js";import{u as d,a as s,r as c}from"./p-c1ecac8a.js";import"./p-445fd8b4.js";import{a as n}from"./p-401e165e.js";import{a as e}from"./p-259c3935.js";var r;const v=()=>{var o;i(a.formId,a.mode,null===(o=a.checkout)||void 0===o?void 0:o.id)},l=o=>a.locks=[...a.locks,o],u=(o="")=>a.locks=o?a.locks.filter((a=>a!==o)):[],p=async({id:c,data:i})=>{try{o("FETCH"),a.checkout=await d({id:c,data:i}),o("RESOLVE")}catch(a){console.error(a),t(a),o("REJECT")}},w=async i=>{try{o("FETCH"),a.checkout=await c({checkoutId:a.checkout.id,itemId:i}),o("RESOLVE")}catch(a){console.error(a),t(a),o("REJECT")}},m=async c=>{try{o("FETCH"),a.checkout=await s({checkout:a.checkout,data:c,live_mode:"live"===(null==a?void 0:a.mode)}),o("RESOLVE")}catch(a){console.error(a),t(a),o("REJECT")}},E=o=>{var c,i,t;(null===(c=a.checkout)||void 0===c?void 0:c.id)&&e({path:n(`surecart/v1/checkouts/${a.checkout.id}/offer_bump/${o}`,{t:Date.now(),...!!(null===(t=null===(i=null==a?void 0:a.checkout)||void 0===i?void 0:i.invoice)||void 0===t?void 0:t.id)&&{type:"open_invoice"}}),method:"POST",keepalive:!0})};window.sc={...(null===window||void 0===window?void 0:window.sc)||{},checkout:{...(null===(r=null===window||void 0===window?void 0:window.sc)||void 0===r?void 0:r.checkout)||{},addLineItem:m}};export{m as a,u as b,v as c,l,w as r,E as t,p as u};