const o=(n=[])=>[...n].sort(((n,i)=>{var l,o;return(null!==(l=null==n?void 0:n.position)&&void 0!==l?l:0)-(null!==(o=null==i?void 0:i.position)&&void 0!==o?o:0)})),n=(n,i=1)=>{const l=Math.max(Number(i)||1,1),o=Math.max(Number(null==n?void 0:n.quantity)||1,1);return Math.max(Math.round(o/l),1)},i=(i=[],l=1,o=!0,t="·")=>{const d=(t||"·").trim()||"·";return(i||[]).map((i=>{var t;const a=((null==i?void 0:i.variant_options)||[]).filter(Boolean),u=a.length?a.join(` ${d} `):((null==i?void 0:i.variant_display_options)||"").trim();if(!o&&!u)return null;const r=null===(t=null==i?void 0:i.price)||void 0===t?void 0:t.product,e=(null==r?void 0:r.name)||"";if(!e)return null;const v=n(i,l);return{id:null==i?void 0:i.id,name:e,variants:u,qty:v}})).filter(Boolean)},l=(n=[])=>o(n).map((n=>{const i=null==n?void 0:n.component_product,l=(null==i?void 0:i.name)||"",o=Math.max(Number(null==n?void 0:n.quantity)||1,1);return l?{id:null==n?void 0:n.id,name:l,variants:"",qty:o}:null})).filter(Boolean),d=(n=[])=>{const i=[],l=[],t={};return(n||[]).forEach((n=>{var d,a;if(null==n?void 0:n.component_line_item)return;const u=null===(d=null==n?void 0:n.price)||void 0===d?void 0:d.product;if(null==u?void 0:u.bundle)return l.push(n),void(t[n.id]=o((null===(a=null==n?void 0:n.component_line_items)||void 0===a?void 0:a.data)||[]));i.push(n)})),{regular:i,bundleParents:l,componentsByParent:t}},v=n=>((null==n?void 0:n.data)||[]).filter((n=>!(null==n?void 0:n.component_line_item))).map((n=>{var i;return{...(null==n?void 0:n.id)?{id:n.id}:{},price_id:n.price.id,quantity:n.quantity,variant_id:null===(i=n.variant)||void 0===i?void 0:i.id}})),t=n=>((null==n?void 0:n.data)||[]).map((n=>n.price.id)),u=(n,i)=>((null==n?void 0:n.data)||[]).find((n=>n.price.id===i)),r=(n,i)=>!!t(null==i?void 0:i.line_items).find((i=>(null==n?void 0:n.id)===i));export{d as a,u as b,v as c,n as d,l as e,i as g,r as i};