import{a as o}from"./p-10aa7556.js";import"./p-699b9e85.js";import{s as i}from"./p-a41f5fb3.js";import{a as d}from"./p-7393a06c.js";import{a}from"./p-1c2e2695.js";import{g as n}from"./p-4d73f82a.js";const e="surecart/v1/checkouts/",t=["line_items","line_item.price","line_item.fees","price.product","customer","customer.shipping_address","payment_intent","discount","discount.promotion","recommended_bumps","bump.price","discount.coupon","shipping_address","staged_payment_intents","tax_identifier","manual_payment_method"],l=(i={})=>{var d,a,n,e;return{live_mode:"test"!==o.mode,group_key:o.groupId,abandoned_checkout_return_url:o.abandonedCheckoutReturnUrl||null,abandoned_checkout_enabled:o.abandonedCheckoutEnabled&&!!o.abandonedCheckoutReturnUrl,metadata:{...(null==i?void 0:i.metadata)||{},...(null===(d=null===window||void 0===window?void 0:window.scData)||void 0===d?void 0:d.page_id)&&{page_id:null===(a=null===window||void 0===window?void 0:window.scData)||void 0===a?void 0:a.page_id},...(null===(n=null==o?void 0:o.product)||void 0===n?void 0:n.id)&&{buy_page_product_id:null===(e=null==o?void 0:o.product)||void 0===e?void 0:e.id},page_url:window.location.href},...i}},u=(d={})=>{var a,n;return{...!!(null==o?void 0:o.formId)&&{form_id:null==o?void 0:o.formId},...!!(null===(a=null==o?void 0:o.product)||void 0===a?void 0:a.id)&&{product_id:null===(n=null==o?void 0:o.product)||void 0===n?void 0:n.id},...!!i.config.stripe.paymentElement&&{stage_processor_type:"stripe"},...d}},r=(o,i="")=>{let d=o?`${e}${o}`:e;return d=`${d}${i}`,a(d,{expand:t})},s=async({id:o,query:i={}})=>await d({path:a(r(o),u(i))}),p=async({id:i=null,data:e={},query:t={}})=>{var s,p;return i=i||n(window.location.href,"checkout_id")||((null===(s=null==o?void 0:o.checkout)||void 0===s?void 0:s.id)?null===(p=null==o?void 0:o.checkout)||void 0===p?void 0:p.id:null),await d({method:i?"PATCH":"POST",path:a(r(i),u(t)),data:l(e)})},m=async({id:o,data:i={},query:n={}})=>await d({method:"PATCH",path:a(r(o),u(n)),data:l(i)}),v=async({id:o,data:i={},query:n={},processor:e})=>await d({method:"POST",path:a(r(o,"/finalize"),u({...(null==e?void 0:e.manual)?{manual_payment:!0,manual_payment_method_id:null==e?void 0:e.id}:{processor_type:null==e?void 0:e.id},...n})),data:l(i)});export{s as a,e as b,p as c,t as e,v as f,m as u}