import{r as i,c as l,h as o}from"./p-dfbe004d.js";import{o as t}from"./p-d63f2554.js";import{h as e}from"./p-afcbd440.js";import{i as s}from"./p-e05449ea.js";import"./p-8415f806.js";import"./p-fd56940f.js";import"./p-9a7a47e8.js";const d=class{constructor(o){i(this,o),this.scUpdateLineItem=l(this,"scUpdateLineItem",7),this.scRemoveLineItem=l(this,"scRemoveLineItem",7),this.editLineItems=!0,this.removeLineItems=!0,this.lockedChoices=[]}updateQuantity(i,l){this.scUpdateLineItem.emit({price_id:i.price.id,quantity:l})}removeLineItem(i){this.scRemoveLineItem.emit({price_id:i.price.id,quantity:1})}getName(i){var l,o,t,e,s;let d="";return d=Object.keys(this.prices||{}).filter((l=>this.prices[l].product===i.price.product.id)).length>1?`${null===(o=null===(l=null==i?void 0:i.price)||void 0===l?void 0:l.product)||void 0===o?void 0:o.name} – ${null===(t=null==i?void 0:i.price)||void 0===t?void 0:t.name}`:null===(s=null===(e=null==i?void 0:i.price)||void 0===e?void 0:e.product)||void 0===s?void 0:s.name,d}isLocked(i){return this.lockedChoices.some((l=>l.id===i.price.id))}isEditable(i){var l;return!(null===(l=null==i?void 0:i.price)||void 0===l?void 0:l.ad_hoc)&&!(null==i?void 0:i.bump_amount)&&(null!==this.editable?this.editable:this.editLineItems)}isRemovable(){return null!==this.removable?this.removable:this.removeLineItems}render(){var i,l,t,d,n;return this.busy&&!(null===(t=null===(l=null===(i=this.order)||void 0===i?void 0:i.line_items)||void 0===l?void 0:l.data)||void 0===t?void 0:t.length)?o("sc-line-item",null,o("sc-skeleton",{style:{width:"50px",height:"50px","--border-radius":"0"},slot:"image"}),o("sc-skeleton",{slot:"title",style:{width:"120px",display:"inline-block"}}),o("sc-skeleton",{slot:"description",style:{width:"60px",display:"inline-block"}}),o("sc-skeleton",{style:{width:"120px",display:"inline-block"},slot:"price"}),o("sc-skeleton",{style:{width:"60px",display:"inline-block"},slot:"price-description"})):o("div",{class:"line-items"},((null===(n=null===(d=this.order)||void 0===d?void 0:d.line_items)||void 0===n?void 0:n.data)||[]).sort(((i,l)=>{var o,t,e,s;return(null===(o=i.price)||void 0===o?void 0:o.id)<(null===(t=l.price)||void 0===t?void 0:t.id)?-1:(null===(e=i.price)||void 0===e?void 0:e.id)>(null===(s=l.price)||void 0===s?void 0:s.id)?1:0})).map((i=>{var l,t,d,n,v,r,u,a,c,p;return o("div",{class:"line-item"},o("sc-product-line-item",{key:i.id,imageUrl:null===(t=null===(l=null==i?void 0:i.price)||void 0===l?void 0:l.product)||void 0===t?void 0:t.image_url,name:null===(n=null===(d=null==i?void 0:i.price)||void 0===d?void 0:d.product)||void 0===n?void 0:n.name,max:null===(r=null===(v=null==i?void 0:i.price)||void 0===v?void 0:v.product)||void 0===r?void 0:r.purchase_limit,editable:this.isEditable(i),removable:this.isRemovable(),quantity:i.quantity,fees:null===(u=null==i?void 0:i.fees)||void 0===u?void 0:u.data,setupFeeTrialEnabled:null===(a=null==i?void 0:i.price)||void 0===a?void 0:a.setup_fee_trial_enabled,amount:null!==i.ad_hoc_amount?i.ad_hoc_amount:i.subtotal_amount,scratchAmount:null==i.ad_hoc_amount&&(null==i?void 0:i.scratch_amount),currency:null===(c=this.order)||void 0===c?void 0:c.currency,trialDurationDays:null===(p=null==i?void 0:i.price)||void 0===p?void 0:p.trial_duration_days,interval:!!(null==i?void 0:i.price)&&s(null==i?void 0:i.price,{showOnce:e(this.order)}),onScUpdateQuantity:l=>this.updateQuantity(i,l.detail),onScRemove:()=>this.removeLineItem(i)}))})))}};t(d,["order","busy","prices","lockedChoices","editLineItems","removeLineItems"],!1),d.style=":host{display:block}:slotted(*~*){margin-top:20px}.line-items{display:grid;gap:var(--sc-form-row-spacing)}.line-item{display:grid;gap:var(--sc-spacing-small)}.fee__description{opacity:0.75}";export{d as sc_line_items}