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