import{b as o,s as i}from"./p-38b12af4.js";import{t as n}from"./p-b28405ea.js";import{a as l}from"./p-efd935a6.js";import{a as t}from"./p-401e165e.js";const d=async e=>{var t,a,d,r,c,s;const u=i[e];if(u&&(null===(t=u.selectedPrice)||void 0===t?void 0:t.id)&&(!(null===(a=u.selectedPrice)||void 0===a?void 0:a.ad_hoc)||null!==u.adHocAmount&&void 0!==u.adHocAmount))try{o(e,{busy:!0}),await l({price:null===(d=u.selectedPrice)||void 0===d?void 0:d.id,quantity:Math.max((null===(r=u.selectedPrice)||void 0===r?void 0:r.ad_hoc)?1:u.quantity,1),...(null===(c=u.selectedPrice)||void 0===c?void 0:c.ad_hoc)?{ad_hoc_amount:u.adHocAmount}:{},variant:null===(s=u.selectedVariant)||void 0===s?void 0:s.id,...u.note?{note:u.note}:{},...u.bundleComponentVariants&&Object.keys(u.bundleComponentVariants).length?{bundle_component_variants:u.bundleComponentVariants}:{}}),n(!0),o(e,{dialog:null})}catch(o){throw console.error(o),i.error=o,o}finally{o(e,{busy:!1})}},a=(o,e,n={})=>{var a,d,l,r,c,s,u;const v=i[o];if(v&&(null===(a=v.selectedPrice)||void 0===a?void 0:a.id)&&(!(null===(d=v.selectedPrice)||void 0===d?void 0:d.ad_hoc)||v.adHocAmount||0===v.adHocAmount))return t(e,{line_items:[{price:null===(l=v.selectedPrice)||void 0===l?void 0:l.id,quantity:Math.max((null===(r=v.selectedPrice)||void 0===r?void 0:r.ad_hoc)?1:v.quantity,1),...(null===(c=v.selectedPrice)||void 0===c?void 0:c.ad_hoc)?{ad_hoc_amount:v.adHocAmount}:{},...(null===(s=v.selectedVariant)||void 0===s?void 0:s.id)?{variant:null===(u=v.selectedVariant)||void 0===u?void 0:u.id}:{},...v.note?{note:v.note}:{},...v.bundleComponentVariants&&Object.keys(v.bundleComponentVariants).length?{bundle_component_variants:v.bundleComponentVariants}:{}}],...n})},v=o=>((null==o?void 0:o.additional_errors)||[]).map((o=>o.message)),r=o=>{var e;return"checkout.invalid"===(null==o?void 0:o.code)&&(null===(e=v(o))||void 0===e?void 0:e.length)?"":null==o?void 0:o.message};export{r as a,v as b,a as g,d as s};