import{j as e,b as j}from"./BlockEditorTranslator-Do4trUgb.js";import{E as y,S as f,C as O}from"./Icons-DvCYCYqp.js";function P({text:a}){return e.jsxs("div",{className:"fct-pricing-block-editor-empty-block",children:[e.jsx(y,{}),e.jsx("p",{children:a})]})}const R=({placeholder:a=j("Search"),name:l,type:d="text",onClick:c,onInput:n,onBlur:m,onKeyDown:o,icon:r=!1})=>e.jsxs("div",{className:"fct-input-group",children:[r&&e.jsx("div",{className:"input-icon",children:e.jsx(f,{})}),e.jsx("input",{className:"fct-input",name:l,type:d,placeholder:a,onClick:c,onInput:n,onBlur:m,onKeyDown:o})]}),{useState:I}=wp.element,{CheckboxControl:E}=wp.components,M=window.fluent_cart_block_editor_asset.placeholder_image,N=a=>{const{variant:l,title:d,media:c,stock:n,price:m,showCollapseButton:o=!1,toggleCollapse:r=()=>{},updateSelectedVariations:i,checked:u,isOpen:s,isMultiple:t=!0}=a,[h,v]=I(u);return e.jsx(e.Fragment,{children:e.jsxs("div",{className:`fct-collapsible-item ${o?"has-collapse-item":""}`,children:[e.jsxs("div",{className:"fct-collapsible-content-wrapper",children:[o&&e.jsx("div",{className:`content-collapsible-btn ${s?"is-collapsed":""}`,onClick:r,children:e.jsx("div",{className:"icon",children:e.jsx(O,{})})}),!o&&e.jsx(e.Fragment,{children:e.jsx("div",{className:"content-checkbox",children:e.jsx(E,{checked:h&&u,onChange:b=>{i(l,b),v(b)}})})}),e.jsx("div",{className:"content-img",children:e.jsx("img",{src:c||M,alt:""})}),e.jsx("div",{className:"content-title",children:e.jsx("div",{className:"title",children:d})})]}),n&&e.jsx("div",{className:"fct-collapsible-stock-wrapper",children:n}),e.jsx("div",{className:"fct-collapsible-value-wrapper",children:e.jsx("span",{children:m})})]})})},F=a=>{const{variants:l,isOpen:d,updateSelectedVariations:c,selectedVariations:n,isMultiple:m,allow_subscription:o=!0}=a;return e.jsx(e.Fragment,{children:e.jsx("div",{className:`fct-collapsible-item-child-container ${d?"is-collapsed":""}`,children:e.jsx("ul",{className:"fct-collapsible-item-child-inner",children:Object.entries(l).map((r,i)=>{const u=l[i].available===0?j("Unlimited"):j("%d Available",l[i].available);return e.jsx("li",{children:e.jsx(N,{isMultiple:m,variant:l[i],title:l[i].variation_title,media:l[i].thumbnail,stock:u,price:l[i].item_price,updateSelectedVariations:c,checked:Object.keys(n).includes(String(l[i].id))})},i)})})})})},{useState:L}=wp.element,U=a=>{var x,g,_;const{products:l,index:d,updateSelectedVariations:c,selectedVariations:n,isMultiple:m,allow_subscription:o=!0}=a,[r,i]=L(!1),u=()=>{i(!r)},s=l[d],t={...s.variants[0],variation_type:(x=s==null?void 0:s.detail)==null?void 0:x.variation_type,variation_title:s==null?void 0:s.post_title},h=s.variants.length>1,v=h?s==null?void 0:s.post_title:t==null?void 0:t.variation_title,b=h?"":(t==null?void 0:t.manage_stock)=="1"?j("%d Available",t==null?void 0:t.available):j("Unlimited"),C=s.variants.length,w=h?(_=(g=s==null?void 0:s.detail)==null?void 0:g.featured_media)==null?void 0:_.url:t==null?void 0:t.thumbnail,S=()=>(o?s.variants:s.variants.filter(p=>(p==null?void 0:p.payment_type)!=="subscription")).map(p=>{var k;return{...p,variation_type:(k=s==null?void 0:s.detail)==null?void 0:k.variation_type,variation_title:p==null?void 0:p.variation_title}});return e.jsx(e.Fragment,{children:e.jsxs("div",{className:"fct-collapsible-list-item-inner",children:[e.jsx(N,{variant:t,title:v,media:w,stock:b,price:C,showCollapseButton:h,checked:Object.keys(n).includes(String(t==null?void 0:t.id)),toggleCollapse:u,updateSelectedVariations:c,isOpen:r,isMultiple:m}),h&&e.jsx(F,{allow_subscription:o,isMultiple:!0,variants:S(),isOpen:r,updateSelectedVariations:c,selectedVariations:n})]})})};export{P as E,R as I,N as L,U as P};
