import{u as o,s as a,c as i}from"./p-6c74654a.js";import{c as d}from"./p-1f60f497.js";import{u as t,a as s,r as c}from"./p-d19e982c.js";import{a as n}from"./p-dd3464cd.js";import{a as e}from"./p-401e165e.js";var v;const l=()=>{var o;i(a.formId,a.mode,null===(o=a.checkout)||void 0===o?void 0:o.id)},r=o=>a.locks=[...a.locks,o],u=(o="")=>a.locks=o?a.locks.filter((a=>a!==o)):[],w=async({id:c,data:i})=>{try{o("FETCH"),a.checkout=await t({id:c,data:i}),o("RESOLVE")}catch(a){console.error(a),d(a),o("REJECT")}},p=async i=>{try{o("FETCH"),a.checkout=await c({checkoutId:a.checkout.id,itemId:i}),o("RESOLVE")}catch(a){console.error(a),d(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),d(a),o("REJECT")}},E=o=>{var c,d,i;(null===(c=a.checkout)||void 0===c?void 0:c.id)&&n({path:e(`surecart/v1/checkouts/${a.checkout.id}/offer_bump/${o}`,{t:Date.now(),...!!(null===(i=null===(d=null==a?void 0:a.checkout)||void 0===d?void 0:d.invoice)||void 0===i?void 0:i.id)&&{type:"open_invoice"}}),method:"POST",keepalive:!0})};window.sc={...(null===window||void 0===window?void 0:window.sc)||{},checkout:{...(null===(v=null===window||void 0===window?void 0:window.sc)||void 0===v?void 0:v.checkout)||{},addLineItem:m}};export{m as a,u as b,l as c,r as l,p as r,E as t,w as u};