hasting-swatchcart-module 1.0.24 → 1.0.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.cjs CHANGED
@@ -47,7 +47,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
47
47
  bg-[var(--background-grey)] rounded-2xl border-none pointer-events-none`,children:m.jsx(lr,{className:"w-[8px] h-2 stroke-[var(--svg-dark)]"})}):null]},e.assetId),Cp=e=>m.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:m.jsx("path",{d:"M2.5 6H9.5",stroke:"current",strokeLinecap:"round",strokeLinejoin:"round"})}),xp=e=>m.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:m.jsx("path",{d:"M2.5 6H9.5M6 2.5V9.5",stroke:"current",strokeLinecap:"round",strokeLinejoin:"round"})}),yp=e=>m.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:m.jsx("path",{d:"M5 5.5V8.5M7 5.5V8.5M9.5 3V10C9.5 10.2652 9.39464 10.5196 9.20711 10.7071C9.01957 10.8946 8.76522 11 8.5 11H3.5C3.23478 11 2.98043 10.8946 2.79289 10.7071C2.60536 10.5196 2.5 10.2652 2.5 10V3M1.5 3H10.5M4 3V2C4 1.73478 4.10536 1.48043 4.29289 1.29289C4.48043 1.10536 4.73478 1 5 1H7C7.26522 1 7.51957 1.10536 7.70711 1.29289C7.89464 1.48043 8 1.73478 8 2V3",stroke:"current",strokeLinecap:"round",strokeLinejoin:"round"})}),Ip=({value:e,canIncrement:t,onIncrement:n,onDecrement:r,onDelete:a})=>{const s=e<=1;return m.jsxs("div",{className:"flex flex-row items-center gap-[8px] text-sm",children:[s?m.jsx("button",{"aria-label":"Remove item",onClick:a,className:"[&_svg_path]:stroke-[var(--main-accent-color)]",children:m.jsx(yp,{})}):m.jsx("button",{"aria-label":"Decrease",onClick:r,className:"[&_svg_path]:stroke-[var(--svg-dark)]",children:m.jsx(Cp,{})}),m.jsx("span",{className:"min-w-[16px] text-center select-none",children:e}),m.jsx("button",{"aria-label":"Increase",onClick:n,disabled:!t,className:"[&_svg_path]:stroke-[var(--svg-dark)] disabled:opacity-40",children:m.jsx(xp,{})})]})},Gl=({item:e,canInc:t,onDelete:n,onIncrement:r,onDecrement:a})=>m.jsx("li",{className:`
48
48
  border-b border-[var(--border)]
49
49
  px-[var(--sm-padding)] p-[var(--sm-padding)]
50
- last:border-b-0`,children:m.jsxs("div",{className:"relative flex flex-row gap-[16px]",children:[m.jsx("div",{children:m.jsx(Tp,{val:e})}),m.jsxs("div",{className:"flex flex-col justify-between",children:[m.jsxs("div",{className:"flex flex-col",children:[m.jsx("span",{className:"mb-[4px] font-semibold text-[12px]",children:e.metadata?.label}),m.jsx("span",{className:"mb-[4px] font-bold text-[10px]",children:e.parentName})]}),m.jsx(Ip,{value:e.count,canIncrement:t,onIncrement:r,onDecrement:a,onDelete:n})]}),m.jsxs("div",{className:" absolute text-[12px] top-0 right-0 font-bold",children:["$",e.count*Vu]})]})},e.assetId),Ws=e=>m.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:m.jsx("path",{d:"M9.99984 15.8333L4.1665 9.99996M4.1665 9.99996L9.99984 4.16663M4.1665 9.99996H15.8332",stroke:"current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),wp=({totalCount:e})=>{const t=Le(),n=()=>{t(Uu(!1))};return m.jsx("header",{className:"flex flex-row p-[var(--sm-padding)] justify-between items-center border-b border-solid border-[var(--border)]",children:m.jsxs("div",{className:"flex items-center flex-row gap-[4px]",children:[m.jsxs("div",{className:"flex flex-row items-center gap-[8px]",children:[m.jsx("button",{className:"[&_svg_path]:stroke-[var(--main-accent-color)] cursor-pointer",onClick:n,children:m.jsx(Ws,{})}),m.jsx("h2",{className:"m-0 text-base leading-[1.6] font-medium ",children:"Your cart"})]}),e>=ke?m.jsxs(m.Fragment,{children:[m.jsxs("span",{className:"text-[var(--main-accent-color)] hidden text-[12px] sm:block",children:["(",ke,") You reached maximum amount of swatches"]}),m.jsxs("span",{className:"text-[var(--main-accent-color)] block sm:hidden",children:["(",ke,") Max"]})]}):null]})})},Np=({onSendData:e})=>{const t=Le(),n=oe(Tn),r=M.useMemo(()=>n.flatMap(l=>l.items),[n]),a=({item:l,assetId:c})=>{const{parentName:d,metadata:f}=l,p=f?.label;c&&p&&d&&(t(Oh({assetId:c,label:p,parentName:d})),t(ta({selectedMaterial:l})))},s=({item:l,assetId:c})=>{const{parentName:d,metadata:f}=l,p=f?.label;c&&p&&d&&t(vh({assetId:c,label:p,parentName:d}))},i=({item:l,assetId:c})=>{const{parentName:d,metadata:f}=l,p=f?.label;c&&p&&d&&t(Dh({assetId:c,label:p,parentName:d}))},o=M.useMemo(()=>r.reduce((l,c)=>l+(c.count??0),0),[r]);return m.jsxs("div",{className:"flex flex-col h-full",children:[m.jsx(wp,{totalCount:o}),m.jsxs("div",{className:"flex flex-col h-full min-h-0",children:[m.jsx("ul",{className:"flex flex-col flex-1 min-h-0 overflow-y-auto",children:n.map(l=>{const{items:c,name:d,assetId:f}=l;return c.length?m.jsxs(m.Fragment,{children:[m.jsx("div",{className:` p-[var(--sm-padding)] border-b border-[var(--border)]
50
+ last:border-b-0`,children:m.jsxs("div",{className:"relative flex flex-row gap-[16px]",children:[m.jsx("div",{children:m.jsx(Tp,{val:e})}),m.jsxs("div",{className:"flex flex-col justify-between",children:[m.jsxs("div",{className:"flex flex-col",children:[m.jsx("span",{className:"mb-[4px] font-semibold text-[12px]",children:e.metadata?.label}),m.jsx("span",{className:"mb-[4px] font-bold text-[10px]",children:e.parentName})]}),m.jsx(Ip,{value:e.count,canIncrement:t,onIncrement:r,onDecrement:a,onDelete:n})]}),m.jsxs("div",{className:" absolute text-[12px] top-0 right-0 font-bold",children:["$",e.count*Vu]})]})},e.assetId),Ws=e=>m.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:m.jsx("path",{d:"M9.99984 15.8333L4.1665 9.99996M4.1665 9.99996L9.99984 4.16663M4.1665 9.99996H15.8332",stroke:"current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),wp=({totalCount:e})=>{const t=Le(),n=()=>{t(Uu(!1))};return m.jsx("header",{className:"flex flex-row p-[var(--sm-padding)] justify-between items-center border-b border-solid border-[var(--border)]",children:m.jsxs("div",{className:"flex items-center flex-row gap-[4px]",children:[m.jsxs("div",{className:"flex flex-row items-center gap-[8px]",children:[m.jsx("button",{className:"[&_svg_path]:stroke-[var(--main-accent-color)] cursor-pointer",onClick:n,children:m.jsx(Ws,{})}),m.jsx("h2",{className:"m-0! text-base leading-[1.6] font-medium ",children:"Your cart"})]}),e>=ke?m.jsxs(m.Fragment,{children:[m.jsxs("span",{className:"text-[var(--main-accent-color)] hidden text-[12px] sm:block",children:["(",ke,") You reached maximum amount of swatches"]}),m.jsxs("span",{className:"text-[var(--main-accent-color)] block sm:hidden",children:["(",ke,") Max"]})]}):null]})})},Np=({onSendData:e})=>{const t=Le(),n=oe(Tn),r=M.useMemo(()=>n.flatMap(l=>l.items),[n]),a=({item:l,assetId:c})=>{const{parentName:d,metadata:f}=l,p=f?.label;c&&p&&d&&(t(Oh({assetId:c,label:p,parentName:d})),t(ta({selectedMaterial:l})))},s=({item:l,assetId:c})=>{const{parentName:d,metadata:f}=l,p=f?.label;c&&p&&d&&t(vh({assetId:c,label:p,parentName:d}))},i=({item:l,assetId:c})=>{const{parentName:d,metadata:f}=l,p=f?.label;c&&p&&d&&t(Dh({assetId:c,label:p,parentName:d}))},o=M.useMemo(()=>r.reduce((l,c)=>l+(c.count??0),0),[r]);return m.jsxs("div",{className:"flex flex-col h-full",children:[m.jsx(wp,{totalCount:o}),m.jsxs("div",{className:"flex flex-col h-full min-h-0",children:[m.jsx("ul",{className:"flex flex-col flex-1 min-h-0 overflow-y-auto",children:n.map(l=>{const{items:c,name:d,assetId:f}=l;return c.length?m.jsxs(m.Fragment,{children:[m.jsx("div",{className:` p-[var(--sm-padding)] border-b border-[var(--border)]
51
51
  sm:px-[var(--sm-padding)]`,children:d},l.value),m.jsx("ul",{children:c?.map(p=>m.jsx(Gl,{item:p,canInc:o<ke,onDelete:()=>{f&&a({item:p,assetId:f})},onIncrement:()=>{f&&s({item:p,assetId:f})},onDecrement:()=>{f&&i({item:p,assetId:f})}},`${p.value}/${p.parentName}`))})]}):null})}),m.jsxs("div",{className:`flex flex-col
52
52
  sm:flex-row sm:w-full sm:justify-between sm:items-center
53
53
  sm:border-t sm:border-[var(--border)] shadow-[0_-2px_10px_rgba(40,40,40,0.10)]
@@ -119,7 +119,7 @@ ${String(i).trim()}
119
119
  text-[10px] leading-none
120
120
  select-none pointer-events-none
121
121
  overflow-hidden
122
- `,children:g})]});if(e.length)return m.jsxs(yc,{open:d,onOpenChange:f,children:[m.jsxs(Ic,{ref:c,className:Oe("flex flex-row items-center justify-between rounded-full border border-[var(--main-accent-color)] px-2 sm:px-4 py-2 bg-white cursor-pointer hover:bg-gray-50 data-[state=open]:border-primary hover:border-primary focus:border-primary min-h-9",a),children:[m.jsx("div",{className:"w-full text-[12px] truncate text-left leading-[20px] sm:text-sm",children:I}),m.jsx(Ol,{className:Oe("h-4 w-[16px] transition-transform",d&&"rotate-180")})]}),m.jsxs(wc,{ref:p,className:Oe("bg-white border rounded-lg shadow-lg z-50 max-h-75 text-sm overflow-y-auto overscroll-behavior-y-contain touch-pan-y p-2",s||"w-[var(--radix-popover-trigger-width)]"),align:i,sideOffset:4,style:{WebkitOverflowScrolling:"touch",overscrollBehavior:"contain"},onTouchStart:E=>{E.stopPropagation()},onTouchMove:E=>{E.stopPropagation()},onWheel:E=>{E.stopPropagation()},children:[g>0&&m.jsx("div",{className:"flex flex-row gap-[8px] items-center justify-between px-2 py-1 mb-2 border-b",children:m.jsxs("button",{onClick:T,className:"text-sm text-black hover:text-primary transition-color cursor-pointer duration-200 flex flex-row items-center gap-[4px]",children:[m.jsx(Fs,{className:"h-3 w-[12px]"}),"Clear all"]})}),m.jsx("div",{className:"flex flex-col gap-[4px]",children:e.map(E=>{const C=t.includes(E.value);return m.jsxs("div",{className:"flex flex-row items-start gap-[8px] px-2 py-1 hover:bg-gray-50 rounded transition-background duration-300 cursor-pointer",onClick:()=>h(E.value,!C),children:[m.jsx(g2,{checked:C,className:"size-6",onCheckedChange:S=>h(E.value,S)}),m.jsxs("div",{className:"flex-1 flex flex-row items-center justify-between",children:[m.jsxs("div",{className:"flex flex-row items-center gap-[8px]",children:[m.jsx("span",{className:"text-sm",children:E.label}),(()=>{if(!o||!l)return null;const S=o(E.value,l);return S&&S.Description?m.jsx($d,{tooltipData:S?.Description}):null})()]}),E.count!==void 0&&m.jsx("span",{className:"text-sm text-gray-800 bg-gray-100 px-2 py-0.5 ml-2 rounded-full whitespace-nowrap",children:E.count})]})]},E.value)})})]})]})});Ar.displayName="MultiSelect";const hf=({containerStyles:e,selectStyles:t})=>{const n=Le(),r=oe(Lh),a=oe(bn),[s,i]=M.useState([]),[o,l]=M.useState([]);M.useEffect(()=>{if(!r?.length)return;const d=r.map(f=>{if(f.metadata){const{Name:p,Label:h}=f.metadata||{};return{value:p,label:h,id:p}}else{const{label:p,value:h}=f||{};return{value:h,label:p,id:h}}});i(d)},[r]);const c=(d,f)=>{if(f.length){const p=Su(f);if(p.length){const h=r.filter(I=>I.metadata?p.includes(I.metadata?.Label):p.includes(I.value));l(p);const T=Fr.mapFiltersFromValues(h,a),g=Fr.getPositiveSelectedFilers(T);g.length&&g.forEach(I=>{const{filterName:E,filterKeys:C}=I;n(ea({filterName:E,values:C}))}),n(xa({attributes:h}))}else n(xa({attributes:r}))}else l([]),n(xa({attributes:r}))};return m.jsxs("div",{className:e,children:[m.jsx("span",{children:"Product element"}),m.jsx(Ar,{options:s,values:o,onValueChange:d=>c("PanelElement",d),placeholder:"All product elements",className:t,dropdownWidth:"w-80"})]})},A2=()=>{const e=Le(),t=oe(bn),n=oe(ur),[r,a]=M.useState([]);M.useEffect(()=>{if(n?.length){const i=[...new Set(n.map(o=>o.metadata?.Finish||o.metadata?.Material))].filter(Boolean).map(o=>{const l=n.filter(c=>c.metadata?.Finish===o||c.metadata?.Material===o).length;return{value:o,label:o,count:l}});i?.length&&a(i)}},[n]);const s=(i,o)=>{e(ea({filterName:i,values:o}))};return m.jsx(Ar,{options:r,values:t.Finish,onValueChange:i=>s("Finish",i),placeholder:"Material",dropdownWidth:"w-80"})},E2=()=>{const e=Le(),t=oe(bn),n=oe(ur),[r,a]=M.useState([]);M.useEffect(()=>{if(n?.length){const i=[...new Set(n.map(o=>o?.metadata?.Color).filter(Boolean).map(o=>o.split(",").map(l=>l.trim())).flat())].map(o=>{const l=n.filter(c=>c.metadata?.Color&&c.metadata?.Color.split(",").map(d=>d.trim()).includes(o)).length;return{value:o,label:o,count:l}});i?.length&&a(i)}},[n]);const s=(i,o)=>{e(ea({filterName:i,values:o}))};return m.jsx(Ar,{options:r,values:t.Color,onValueChange:i=>s("Color",i),placeholder:"Color",dropdownWidth:"w-80"})},b2=()=>{const e=Le(),t=oe(bn),n=oe(ur),[r,a]=M.useState([]);M.useEffect(()=>{if(n?.length){const i=[...new Set(n.map(o=>o?.metadata?.Look).filter(Boolean).map(o=>o.split(",").map(l=>l.trim())).flat())].map(o=>{const l=n.filter(c=>c.metadata?.Look&&c.metadata?.Look.split(",").map(d=>d.trim()).includes(o)).length;return{value:o,label:o,count:l}});i?.length&&a(i)}},[n]);const s=(i,o)=>{e(ea({filterName:i,values:o}))};return m.jsx(Ar,{options:r,values:t.Look,onValueChange:i=>s("Look",i),placeholder:"Look",dropdownWidth:"w-80"})},mf=()=>m.jsxs("div",{className:"flex flex-row items-center gap-[16px] p-[var(--sm-padding)] border-b border-solid border-[var(--border)]",children:[m.jsx(A2,{}),m.jsx(E2,{}),m.jsx(b2,{})]}),T2=()=>m.jsxs("div",{className:`flex flex-col justify-between border-b border-[var(--border)]
122
+ `,children:g})]});if(e.length)return m.jsxs(yc,{open:d,onOpenChange:f,children:[m.jsxs(Ic,{ref:c,className:Oe("flex flex-row items-center justify-between rounded-full border border-[var(--main-accent-color)] px-2 sm:px-4 py-2 bg-white cursor-pointer hover:bg-gray-50 data-[state=open]:border-primary hover:border-primary focus:border-primary min-h-9",a),children:[m.jsx("div",{className:"w-full text-[12px] truncate text-left leading-[20px] sm:text-sm",children:I}),m.jsx(Ol,{className:Oe("h-4 w-[16px] transition-transform",d&&"rotate-180")})]}),m.jsxs(wc,{ref:p,className:Oe("bg-white border rounded-lg shadow-lg z-50 max-h-75 text-sm overflow-y-auto overscroll-behavior-y-contain touch-pan-y p-2",s||"w-[var(--radix-popover-trigger-width)]"),align:i,sideOffset:4,style:{WebkitOverflowScrolling:"touch",overscrollBehavior:"contain"},onTouchStart:E=>{E.stopPropagation()},onTouchMove:E=>{E.stopPropagation()},onWheel:E=>{E.stopPropagation()},children:[g>0&&m.jsx("div",{className:"flex flex-row gap-[8px] items-center justify-between px-2 py-1 mb-2 border-b",children:m.jsxs("button",{onClick:T,className:"text-sm text-black hover:text-primary transition-color cursor-pointer duration-200 flex flex-row items-center gap-[4px]",children:[m.jsx(Fs,{className:"h-3 w-[12px]"}),"Clear all"]})}),m.jsx("div",{className:"flex flex-col gap-[4px]",children:e.map(E=>{const C=t.includes(E.value);return m.jsxs("div",{className:"flex flex-row items-start gap-[8px] px-2 py-1 hover:bg-gray-50 rounded transition-background duration-300 cursor-pointer",onClick:()=>h(E.value,!C),children:[m.jsx(g2,{checked:C,className:"size-6",onCheckedChange:S=>h(E.value,S)}),m.jsxs("div",{className:"flex-1 flex flex-row items-center justify-between",children:[m.jsxs("div",{className:"flex flex-row items-center gap-[8px]",children:[m.jsx("span",{className:"text-sm",children:E.label}),(()=>{if(!o||!l)return null;const S=o(E.value,l);return S&&S.Description?m.jsx($d,{tooltipData:S?.Description}):null})()]}),E.count!==void 0&&m.jsx("span",{className:"text-sm text-gray-800 bg-gray-100 px-2 py-0.5 ml-2 rounded-full whitespace-nowrap",children:E.count})]})]},E.value)})})]})]})});Ar.displayName="MultiSelect";const hf=({containerStyles:e,selectStyles:t})=>{const n=Le(),r=oe(Lh),a=oe(bn),[s,i]=M.useState([]),[o,l]=M.useState([]);M.useEffect(()=>{if(!r?.length)return;const d=r.map(f=>{if(f.metadata){const{Name:p,Label:h}=f.metadata||{};return{value:p,label:h,id:p}}else{const{label:p,value:h}=f||{};return{value:h,label:p,id:h}}});i(d)},[r]);const c=(d,f)=>{if(f.length){const p=Su(f);if(p.length){const h=r.filter(I=>I.metadata?p.includes(I.metadata?.Label):p.includes(I.value));l(p);const T=Fr.mapFiltersFromValues(h,a),g=Fr.getPositiveSelectedFilers(T);g.length&&g.forEach(I=>{const{filterName:E,filterKeys:C}=I;n(ea({filterName:E,values:C}))}),n(xa({attributes:h}))}else n(xa({attributes:r}))}else l([]),n(xa({attributes:r}))};return m.jsxs("div",{className:e,children:[m.jsx("span",{children:"Product element"}),m.jsx(Ar,{options:s,values:o,onValueChange:d=>c("PanelElement",d),placeholder:"All product elements",className:t,dropdownWidth:"w-80"})]})},A2=()=>{const e=Le(),t=oe(bn),n=oe(ur),[r,a]=M.useState([]);M.useEffect(()=>{if(n?.length){const i=[...new Set(n.map(o=>o.metadata?.Finish||o.metadata?.Material))].filter(Boolean).map(o=>{const l=n.filter(c=>c.metadata?.Finish===o||c.metadata?.Material===o).length;return{value:o,label:o,count:l}});i?.length&&a(i)}},[n]);const s=(i,o)=>{e(ea({filterName:i,values:o}))};return m.jsx(Ar,{options:r,values:t.Finish,onValueChange:i=>s("Finish",i),placeholder:"Material",dropdownWidth:"w-80"})},E2=()=>{const e=Le(),t=oe(bn),n=oe(ur),[r,a]=M.useState([]);M.useEffect(()=>{if(n?.length){const i=[...new Set(n.map(o=>o?.metadata?.Color).filter(Boolean).map(o=>o.split(",").map(l=>l.trim())).flat())].map(o=>{const l=n.filter(c=>c.metadata?.Color&&c.metadata?.Color.split(",").map(d=>d.trim()).includes(o)).length;return{value:o,label:o,count:l}});i?.length&&a(i)}},[n]);const s=(i,o)=>{e(ea({filterName:i,values:o}))};return m.jsx(Ar,{options:r,values:t.Color,onValueChange:i=>s("Color",i),placeholder:"Color",dropdownWidth:"w-80"})},b2=()=>{const e=Le(),t=oe(bn),n=oe(ur),[r,a]=M.useState([]);M.useEffect(()=>{if(n?.length){const i=[...new Set(n.map(o=>o?.metadata?.Look).filter(Boolean).map(o=>o.split(",").map(l=>l.trim())).flat())].map(o=>{const l=n.filter(c=>c.metadata?.Look&&c.metadata?.Look.split(",").map(d=>d.trim()).includes(o)).length;return{value:o,label:o,count:l}});i?.length&&a(i)}},[n]);const s=(i,o)=>{e(ea({filterName:i,values:o}))};return m.jsx(Ar,{options:r,values:t.Look,onValueChange:i=>s("Look",i),placeholder:"Look",dropdownWidth:"w-80"})},mf=()=>m.jsxs("div",{className:"flex flex-row items-center gap-[16px] p-[var(--sm-padding)] ",children:[m.jsx(A2,{}),m.jsx(E2,{}),m.jsx(b2,{})]}),T2=()=>m.jsxs("div",{className:`flex flex-col justify-between border-b border-[var(--border)]
123
123
  sm:flex-row
124
124
  `,children:[m.jsx(hf,{containerStyles:`flex flex-row justify-between items-center gap-[8px] p-[var(--sm-padding)] w-full text-[12px]
125
125
  border-b border-[var(--border)]
@@ -142,9 +142,9 @@ ${String(i).trim()}
142
142
  `,style:{width:r||"auto",height:a||"auto"},children:[m.jsxs("div",{className:"flex flex-row items-center justify-between p-[var(--sm-padding)] border-b border-[var(--border)]",children:[m.jsx("span",{className:"text-base font-semibold text-[var(--text)]",children:n}),m.jsx("button",{onClick:t,className:"flex flex-row justify-center items-center p-1 rounded-full bg-[var(--border)] hover:bg-gray-100 transition [&_svg_path]:stroke-[var(--svg-dark)] w-[30px] h-[30px]",children:m.jsx(lr,{className:"text-[var(--text)] ",width:10,hanging:10})})]}),m.jsx("div",{className:"flex flex-col gap-[12px] text-[var(--text-muted)]",children:s})]})}),document.body):null},Af=({isOpen:e,onClose:t})=>m.jsx(R2,{isOpen:e,onClose:t,width:320,title:"Swatch Limit",children:m.jsxs("div",{children:[m.jsxs("div",{className:"text-sm font-medium p-[var(--sm-padding)] border-b border-[var(--border)] leading-[20px]",children:[m.jsx("p",{className:"mb-4",children:"You've reached your maximum number of swatches!"}),m.jsx("p",{children:"If you'd like to add another swatch please remove an exsiting swach from your cart"})]}),m.jsx("div",{className:"p-[var(--sm-padding)] w-full",children:m.jsx("button",{className:`
143
143
  w-full block py-3 rounded-full
144
144
  bg-[var(--main-accent-color)] text-white font-bold capitalize
145
- `,onClick:t,children:"OK"})})]})}),L2=({containerStyles:e="flex-1 min-h-0 overflow-y-auto p-[var(--padding)] sm:p-[var(--sm-padding)] ",gridStyles:t="grid grid-cols-1 gap-[8px] sm:grid-cols-3",desktopColumnsCount:n=3})=>{const r=Le(),a=M.useRef(null),s=oe(ur),i=oe(bn),o=oe(na),l=oe(Tn),[c,d]=M.useState(!1),f=M.useMemo(()=>l.flatMap(F=>F.items),[l]),p=M.useMemo(()=>s.filter(F=>{const X=i.Finish.length===0||i.Finish.some($=>F.metadata?.Finish===$||F.metadata?.Material===$),z=i.Color.length===0||F.metadata?.Color&&i.Color.some($=>F.metadata?.Color?.split(",").map(H=>H.trim()).includes($)),Q=F.metadata?.Look,K=!i.Look||i.Look.length===0||i.Look.some($=>Q&&Q.includes($));return X&&z&&K}),[i,s]),h=typeof window<"u"?window.matchMedia("(min-width: 640px)").matches:!1,T=h?n:1,g=Math.ceil(p.length/T),I=h?300:200,E=gf({count:g,getScrollElement:()=>a.current,estimateSize:()=>I,overscan:24,measureElement:F=>F?.getBoundingClientRect().height}),C=E.getVirtualItems(),S=E.getTotalSize(),O=C[0]?.index??0,L=C[C.length-1]?.index??-1,v=O*T,R=Math.min((L+1)*T,p.length),k=p.slice(v,R),j=C[0]?.start??0,J=S-(C[C.length-1]?.end??0),V=F=>{if(!o)return;const X=l.find(K=>o.assetId===K.assetId),z=K=>K.metadata?.label===F.metadata?.label&&K.parentName===F.parentName,Q=f.some(z);if(!Q&&f.length>=5&&d(!0),Q){const K=f.filter(ue=>!z(ue)),H={assetId:l.find(ue=>ue.items.some(w=>w.metadata?.label===F.metadata?.label&&w.parentName===F.parentName))?.assetId||o.assetId,name:o.name,items:K};r(rs(H)),r(as(H))}else if(f.length<5){const K={...F,count:1},$=X?[...X.items,K]:[K],H={assetId:o.assetId,name:o.name,items:$};r(rs(H)),r(as(H))}};return m.jsxs("div",{ref:a,className:e,children:[m.jsx(Af,{isOpen:c,onClose:()=>d(!1)}),m.jsx("div",{style:{height:j},"aria-hidden":!0}),m.jsx("div",{className:t,children:k.map((F,X)=>{const z=v+X,Q=`${F.metadata?.label||z}/${F.parentName}`;return(z+1)%T===0||z===p.length-1?m.jsx("div",{ref:E.measureElement,children:m.jsx(Kr,{val:F,onClick:V})},Q):m.jsx(Kr,{val:F,onClick:V},Q)})}),m.jsx("div",{style:{height:J},"aria-hidden":!0})]})},P2=()=>{const e=Le(),t=oe(na);M.useEffect(()=>()=>{e(Ah())},[]);const n=()=>{e(bh())};return m.jsxs("div",{className:"flex flex-col h-full ",children:[m.jsx("header",{className:"flex flex-row shrink-0 items-center justify-between border-b border-[var(--border)] p-[var(--sm-padding)]",children:m.jsxs("div",{className:"flex flex-row items-center gap-[8px]",children:[m.jsx("button",{className:"[&_svg_path]:stroke-[var(--main-accent-color)] cursor-pointer",onClick:n,children:m.jsx(Ws,{})}),m.jsx("h2",{className:"m-0 text-base font-medium leading-[1.6]",children:t?.name})]})}),m.jsxs("div",{className:"flex flex-col min-h-0 flex-1 ",children:[m.jsx("div",{className:"shrink-0",children:m.jsx(T2,{})}),m.jsx(L2,{containerStyles:"flex-1 min-h-0 overflow-y-auto overscroll-contain p-[var(--sm-padding)]",gridStyles:"grid grid-cols-2 gap-[16px] sm:grid-cols-4 lg:grid-cols-5 xl:grid-cols-7 2xl:grid-cols-9",desktopColumnsCount:6}),m.jsx(rf,{})]})]})},M2=({onSendData:e})=>{const t=oe(Ph),n=oe(na);return m.jsx(m.Fragment,{children:t?m.jsx(Np,{onSendData:e}):n?m.jsx(P2,{}):m.jsx(c2,{})})},Jr={SWATCH:"swatch",CART:"cart"},F2="_overlay_1aet8_1",H2="_panel_1aet8_10",Q2="_enter_1aet8_38",U2="_exit_1aet8_42",jn={overlay:F2,panel:H2,enter:Q2,exit:U2},Ef=({children:e,isOpen:t,setIsOpen:n})=>{const r=M.useRef(null),a=M.useRef(null),s=()=>n(!1);return M.useLayoutEffect(()=>{t&&typeof document<"u"&&(a.current=document.activeElement)},[t]),M.useEffect(()=>{t?r.current?.focus():a.current?.focus?.()},[t]),M.useEffect(()=>{if(!t)return;const i=o=>{o.key==="Escape"&&s()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[t]),M.useEffect(()=>{if(!t)return;const i=document.documentElement,o=document.body,l=i.style.overflow,c=o.style.overflow;return i.style.overflow="hidden",o.style.overflow="hidden",()=>{i.style.overflow=l,o.style.overflow=c}},[t]),t?Gt.createPortal(m.jsx("div",{className:Ct(jn.overlay),onMouseDown:s,onTouchStart:s,children:m.jsx("div",{ref:r,tabIndex:-1,className:Oe(jn.panel,jn.right,t?jn.enter:jn.exit,"bg-[var(--sidebar-bg)]"),onMouseDown:i=>i.stopPropagation(),onTouchStart:i=>i.stopPropagation(),children:e})}),document.body):null};class Y2{static getCartPreparedOption(t){return t?.length?t.map(n=>({...n,count:1})):[]}}const j2=()=>m.jsx("div",{className:["relative w-[40px] h-[40px] rounded-sm aspect-square overflow-hidden","border border-solid border-[var(--border)] bg-[var(--sidebar-b)] sm:w-[64px] sm:h-[64px]"].join(" "),"aria-hidden":!0}),z2=({selectedMaterials:e,containerStyles:t="p-[var(--sm-padding)] border-t border-solid border-[var(--border)] shrink-0 shadow-[0_-2px_10px_rgba(40,40,40,0.10)]"})=>{const n=Le(),r=s=>{n(ta({selectedMaterial:s}))},a=Math.max(0,ke-e.length);return m.jsxs("div",{className:t,children:[m.jsxs("div",{className:"flex flex-row justify-between items-center mb-[12px]",children:[m.jsxs("div",{className:"relative",children:[m.jsx("div",{className:"",children:"Swatches list"}),m.jsx("span",{className:"absolute top-0 right-[-20px] font-medium text-[var(--main-accent-color)] text-[8px] leading-none",children:"Free"})]}),m.jsxs("div",{children:[e.length,"/",ke," Selected"]})]}),m.jsxs("div",{className:"flex flex-row flex-wrap gap-[8px]",children:[e.map((s,i)=>{const o=s.metadata;return m.jsx(nf,{val:s,onDelete:r},`${o?.label||i}/${s.parentName}`)}),Array.from({length:a}).map((s,i)=>m.jsx(j2,{},`mock-${i}`))]})]})},W2=()=>{const e=oe(vs)??[];return m.jsx(z2,{selectedMaterials:e})},G2=({containerStyles:e="flex-1 min-h-0 overflow-y-auto p-[var(--sm-padding)]",gridStyles:t="grid grid-cols-2 gap-[var(--sm-padding)] sm:grid-cols-3 ",desktopColumnsCount:n=3})=>{const r=En.useDispatch(),a=M.useRef(null),s=oe(ur),i=oe(bn),[o,l]=M.useState(!1),c=M.useMemo(()=>s.filter(j=>{const J=i.Finish.length===0||i.Finish.some(z=>j.metadata?.Finish===z||j.metadata?.Material===z),V=i.Color.length===0||j.metadata?.Color&&i.Color.some(z=>j.metadata?.Color?.split(",").map(Q=>Q.trim()).includes(z)),F=j.metadata?.Look,X=!i.Look||i.Look.length===0||i.Look.some(z=>F&&F.includes(z));return J&&V&&X}),[i,s]),d=typeof window<"u"?window.matchMedia("(min-width: 640px)").matches:!1,f=d?n:1,p=Math.ceil(c.length/f),h=d?300:200,T=gf({count:p,getScrollElement:()=>a.current,estimateSize:()=>h,overscan:24,measureElement:j=>j?.getBoundingClientRect().height}),g=T.getVirtualItems(),I=T.getTotalSize(),E=g[0]?.index??0,C=g[g.length-1]?.index??-1,S=E*f,O=Math.min((C+1)*f,c.length),L=c.slice(S,O),v=g[0]?.start??0,R=I-(g[g.length-1]?.end??0),k=j=>{r(ta({selectedMaterial:j,limitCb:()=>l(!0)}))};return m.jsxs("div",{ref:a,className:e,children:[m.jsx(Af,{isOpen:o,onClose:()=>l(!1)}),m.jsx("div",{style:{height:v},"aria-hidden":!0}),m.jsx("div",{className:t,children:L.map((j,J)=>{const V=S+J,F=`${j.metadata?.label||V}/${j.parentName}`;return(V+1)%f===0||V===c.length-1?m.jsx("div",{ref:T.measureElement,children:m.jsx(Kr,{val:j,onClick:k})},F):m.jsx(Kr,{val:j,onClick:k},F)})}),m.jsx("div",{style:{height:R},"aria-hidden":!0})]})},V2=({isOpen:e,onToggleSidebar:t,onSetActiveTab:n})=>{const r=Le(),a=oe(vs)??[],s=oe(Gu),i=()=>{const o=Y2.getCartPreparedOption(a);o&&r(xh(o)),n(Jr.CART)};return m.jsxs(Ef,{isOpen:e,setIsOpen:t,children:[m.jsxs("header",{className:"flex flex-row p-[var(--sm-padding)] justify-between items-center border-b border-solid border-[var(--border)]",children:[m.jsx("h2",{className:"m-0 text-[16px] leading-[1.6] font-medium",children:"Order free swatches"}),m.jsx("button",{className:`flex flex-row justify-center items-center w-[30px] h-[30px] bg-[var(--background-grey)]
145
+ `,onClick:t,children:"OK"})})]})}),L2=({containerStyles:e="flex-1 min-h-0 overflow-y-auto p-[var(--padding)] sm:p-[var(--sm-padding)] ",gridStyles:t="grid grid-cols-1 gap-[8px] sm:grid-cols-3",desktopColumnsCount:n=3})=>{const r=Le(),a=M.useRef(null),s=oe(ur),i=oe(bn),o=oe(na),l=oe(Tn),[c,d]=M.useState(!1),f=M.useMemo(()=>l.flatMap(F=>F.items),[l]),p=M.useMemo(()=>s.filter(F=>{const X=i.Finish.length===0||i.Finish.some($=>F.metadata?.Finish===$||F.metadata?.Material===$),z=i.Color.length===0||F.metadata?.Color&&i.Color.some($=>F.metadata?.Color?.split(",").map(H=>H.trim()).includes($)),Q=F.metadata?.Look,K=!i.Look||i.Look.length===0||i.Look.some($=>Q&&Q.includes($));return X&&z&&K}),[i,s]),h=typeof window<"u"?window.matchMedia("(min-width: 640px)").matches:!1,T=h?n:1,g=Math.ceil(p.length/T),I=h?300:200,E=gf({count:g,getScrollElement:()=>a.current,estimateSize:()=>I,overscan:24,measureElement:F=>F?.getBoundingClientRect().height}),C=E.getVirtualItems(),S=E.getTotalSize(),O=C[0]?.index??0,L=C[C.length-1]?.index??-1,v=O*T,R=Math.min((L+1)*T,p.length),k=p.slice(v,R),j=C[0]?.start??0,J=S-(C[C.length-1]?.end??0),V=F=>{if(!o)return;const X=l.find(K=>o.assetId===K.assetId),z=K=>K.metadata?.label===F.metadata?.label&&K.parentName===F.parentName,Q=f.some(z);if(!Q&&f.length>=5&&d(!0),Q){const K=f.filter(ue=>!z(ue)),H={assetId:l.find(ue=>ue.items.some(w=>w.metadata?.label===F.metadata?.label&&w.parentName===F.parentName))?.assetId||o.assetId,name:o.name,items:K};r(rs(H)),r(as(H))}else if(f.length<5){const K={...F,count:1},$=X?[...X.items,K]:[K],H={assetId:o.assetId,name:o.name,items:$};r(rs(H)),r(as(H))}};return m.jsxs("div",{ref:a,className:e,children:[m.jsx(Af,{isOpen:c,onClose:()=>d(!1)}),m.jsx("div",{style:{height:j},"aria-hidden":!0}),m.jsx("div",{className:t,children:k.map((F,X)=>{const z=v+X,Q=`${F.metadata?.label||z}/${F.parentName}`;return(z+1)%T===0||z===p.length-1?m.jsx("div",{ref:E.measureElement,children:m.jsx(Kr,{val:F,onClick:V})},Q):m.jsx(Kr,{val:F,onClick:V},Q)})}),m.jsx("div",{style:{height:J},"aria-hidden":!0})]})},P2=()=>{const e=Le(),t=oe(na);M.useEffect(()=>()=>{e(Ah())},[]);const n=()=>{e(bh())};return m.jsxs("div",{className:"flex flex-col h-full ",children:[m.jsx("header",{className:"flex flex-row shrink-0 items-center justify-between border-b border-[var(--border)] p-[var(--sm-padding)]",children:m.jsxs("div",{className:"flex flex-row items-center gap-[8px]",children:[m.jsx("button",{className:"[&_svg_path]:stroke-[var(--main-accent-color)] cursor-pointer",onClick:n,children:m.jsx(Ws,{})}),m.jsx("h2",{className:"m-0! text-base font-medium leading-[1.6]",children:t?.name})]})}),m.jsxs("div",{className:"flex flex-col min-h-0 flex-1 ",children:[m.jsx("div",{className:"shrink-0",children:m.jsx(T2,{})}),m.jsx(L2,{containerStyles:"flex-1 min-h-0 overflow-y-auto overscroll-contain p-[var(--sm-padding)]",gridStyles:"grid grid-cols-2 gap-[16px] sm:grid-cols-4 lg:grid-cols-5 xl:grid-cols-7 2xl:grid-cols-9",desktopColumnsCount:6}),m.jsx(rf,{})]})]})},M2=({onSendData:e})=>{const t=oe(Ph),n=oe(na);return m.jsx(m.Fragment,{children:t?m.jsx(Np,{onSendData:e}):n?m.jsx(P2,{}):m.jsx(c2,{})})},Jr={SWATCH:"swatch",CART:"cart"},F2="_overlay_1aet8_1",H2="_panel_1aet8_10",Q2="_enter_1aet8_38",U2="_exit_1aet8_42",jn={overlay:F2,panel:H2,enter:Q2,exit:U2},Ef=({children:e,isOpen:t,setIsOpen:n})=>{const r=M.useRef(null),a=M.useRef(null),s=()=>n(!1);return M.useLayoutEffect(()=>{t&&typeof document<"u"&&(a.current=document.activeElement)},[t]),M.useEffect(()=>{t?r.current?.focus():a.current?.focus?.()},[t]),M.useEffect(()=>{if(!t)return;const i=o=>{o.key==="Escape"&&s()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[t]),M.useEffect(()=>{if(!t)return;const i=document.documentElement,o=document.body,l=i.style.overflow,c=o.style.overflow;return i.style.overflow="hidden",o.style.overflow="hidden",()=>{i.style.overflow=l,o.style.overflow=c}},[t]),t?Gt.createPortal(m.jsx("div",{className:Ct(jn.overlay),onMouseDown:s,onTouchStart:s,children:m.jsx("div",{ref:r,tabIndex:-1,className:Oe(jn.panel,jn.right,t?jn.enter:jn.exit,"bg-[var(--sidebar-bg)]"),onMouseDown:i=>i.stopPropagation(),onTouchStart:i=>i.stopPropagation(),children:e})}),document.body):null};class Y2{static getCartPreparedOption(t){return t?.length?t.map(n=>({...n,count:1})):[]}}const j2=()=>m.jsx("div",{className:["relative w-[40px] h-[40px] rounded-sm aspect-square overflow-hidden","border border-solid border-[var(--border)] bg-[var(--sidebar-b)] sm:w-[64px] sm:h-[64px]"].join(" "),"aria-hidden":!0}),z2=({selectedMaterials:e,containerStyles:t="p-[var(--sm-padding)] border-t border-solid border-[var(--border)] shrink-0 shadow-[0_-2px_10px_rgba(40,40,40,0.10)]"})=>{const n=Le(),r=s=>{n(ta({selectedMaterial:s}))},a=Math.max(0,ke-e.length);return m.jsxs("div",{className:t,children:[m.jsxs("div",{className:"flex flex-row justify-between items-center mb-[12px]",children:[m.jsxs("div",{className:"relative",children:[m.jsx("div",{className:"",children:"Swatches list"}),m.jsx("span",{className:"absolute top-0 right-[-20px] font-medium text-[var(--main-accent-color)] text-[8px] leading-none",children:"Free"})]}),m.jsxs("div",{children:[e.length,"/",ke," Selected"]})]}),m.jsxs("div",{className:"flex flex-row flex-wrap gap-[8px]",children:[e.map((s,i)=>{const o=s.metadata;return m.jsx(nf,{val:s,onDelete:r},`${o?.label||i}/${s.parentName}`)}),Array.from({length:a}).map((s,i)=>m.jsx(j2,{},`mock-${i}`))]})]})},W2=()=>{const e=oe(vs)??[];return m.jsx(z2,{selectedMaterials:e})},G2=({containerStyles:e="flex-1 min-h-0 overflow-y-auto p-[var(--sm-padding)]",gridStyles:t="grid grid-cols-2 gap-[var(--sm-padding)] sm:grid-cols-3 ",desktopColumnsCount:n=3})=>{const r=En.useDispatch(),a=M.useRef(null),s=oe(ur),i=oe(bn),[o,l]=M.useState(!1),c=M.useMemo(()=>s.filter(j=>{const J=i.Finish.length===0||i.Finish.some(z=>j.metadata?.Finish===z||j.metadata?.Material===z),V=i.Color.length===0||j.metadata?.Color&&i.Color.some(z=>j.metadata?.Color?.split(",").map(Q=>Q.trim()).includes(z)),F=j.metadata?.Look,X=!i.Look||i.Look.length===0||i.Look.some(z=>F&&F.includes(z));return J&&V&&X}),[i,s]),d=typeof window<"u"?window.matchMedia("(min-width: 640px)").matches:!1,f=d?n:1,p=Math.ceil(c.length/f),h=d?300:200,T=gf({count:p,getScrollElement:()=>a.current,estimateSize:()=>h,overscan:24,measureElement:j=>j?.getBoundingClientRect().height}),g=T.getVirtualItems(),I=T.getTotalSize(),E=g[0]?.index??0,C=g[g.length-1]?.index??-1,S=E*f,O=Math.min((C+1)*f,c.length),L=c.slice(S,O),v=g[0]?.start??0,R=I-(g[g.length-1]?.end??0),k=j=>{r(ta({selectedMaterial:j,limitCb:()=>l(!0)}))};return m.jsxs("div",{ref:a,className:e,children:[m.jsx(Af,{isOpen:o,onClose:()=>l(!1)}),m.jsx("div",{style:{height:v},"aria-hidden":!0}),m.jsx("div",{className:t,children:L.map((j,J)=>{const V=S+J,F=`${j.metadata?.label||V}/${j.parentName}`;return(V+1)%f===0||V===c.length-1?m.jsx("div",{ref:T.measureElement,children:m.jsx(Kr,{val:j,onClick:k})},F):m.jsx(Kr,{val:j,onClick:k},F)})}),m.jsx("div",{style:{height:R},"aria-hidden":!0})]})},V2=({isOpen:e,onToggleSidebar:t,onSetActiveTab:n})=>{const r=Le(),a=oe(vs)??[],s=oe(Gu),i=()=>{const o=Y2.getCartPreparedOption(a);o&&r(xh(o)),n(Jr.CART)};return m.jsxs(Ef,{isOpen:e,setIsOpen:t,children:[m.jsxs("header",{className:"flex flex-row p-[var(--sm-padding)] justify-between items-center border-b border-solid border-[var(--border)]",children:[m.jsx("h2",{className:"m-0! text-[16px] leading-[1.6] font-medium",children:"Order free swatches"}),m.jsx("button",{className:`flex flex-row justify-center items-center w-[30px] h-[30px] bg-[var(--background-grey)]
146
146
  border-none cursor-pointer rounded-full
147
- [&_svg_path]:stroke-[var(--svg-dark)]`,onClick:t,children:m.jsx(lr,{width:10,height:10})})]}),m.jsxs("div",{className:"flex flex-col h-full min-h-0 relative",children:[s&&m.jsx(tf,{}),m.jsx(hf,{containerStyles:"flex flex-row justify-between items-center shrink-0 p-[var(--sm-padding)] border-b border-solid border-[var(--border)]",selectStyles:"min-w-[auto] max-w-[154px] sm:max-w-[auto] sm:min-w-[250px]"}),m.jsx(mf,{}),m.jsx(G2,{}),m.jsx(W2,{}),m.jsx("div",{className:"p-[var(--sm-padding)] border-t border-solid border-[var(--border)] shrink-0",children:m.jsx("button",{className:"w-full bg-[var(--main-accent-color)] text-white py-3 rounded-full font-bold cursor-pointer",onClick:i,children:"ADD SWATCHES TO CART"})})]})]})},Xr=e=>e.cart.items,bf=Je.createSelector(Xr,e=>e.reduce((t,n)=>t+n.count,0)),q2=Je.createSelector(bf,e=>Math.max(0,ke-e)),K2=Je.createSelector(q2,e=>e>0),J2=({onSetActiveTab:e,onToggleSidebar:t})=>{const n=oe(bf);return m.jsxs("header",{className:"flex flex-row MaterialMultiProductList justify-between items-center border-b border-solid border-[var(--border)] p-[var(--sm-padding)]",children:[m.jsxs("div",{className:"flex flex-row items-center gap-[4px]",children:[m.jsxs("div",{className:"flex flex-row items-center gap-[8px]",children:[m.jsx("button",{className:"[&_svg_path]:stroke-[var(--main-accent-color)] cursor-pointer",onClick:()=>e&&e(Jr.SWATCH),children:m.jsx(Ws,{})}),m.jsx("h2",{className:"m-0 text-base leading-[1.6] font-medium ",children:"Your cart"})]}),n>=ke?m.jsxs(m.Fragment,{children:[m.jsxs("span",{className:"text-[var(--main-accent-color)] hidden text-[12px] sm:block",children:["(",ke,") You reached maximum amount of swatches"]}),m.jsxs("span",{className:"text-[var(--main-accent-color)] block sm:hidden",children:["(",ke,") Max"]})]}):null]}),m.jsx("button",{className:`flex flex-row justify-center items-center w-[30px] h-[30px] bg-[var(--background-grey)]
147
+ [&_svg_path]:stroke-[var(--svg-dark)]`,onClick:t,children:m.jsx(lr,{width:10,height:10})})]}),m.jsxs("div",{className:"flex flex-col h-full min-h-0 relative",children:[s&&m.jsx(tf,{}),m.jsx(hf,{containerStyles:"flex flex-row justify-between items-center shrink-0 p-[var(--sm-padding)] border-b border-solid border-[var(--border)]",selectStyles:"min-w-[auto] max-w-[154px] sm:max-w-[auto] sm:min-w-[250px]"}),m.jsx(mf,{}),m.jsx(G2,{}),m.jsx(W2,{}),m.jsx("div",{className:"p-[var(--sm-padding)] border-t border-solid border-[var(--border)] shrink-0",children:m.jsx("button",{className:"w-full bg-[var(--main-accent-color)] text-white py-3 rounded-full font-bold cursor-pointer",onClick:i,children:"ADD SWATCHES TO CART"})})]})]})},Xr=e=>e.cart.items,bf=Je.createSelector(Xr,e=>e.reduce((t,n)=>t+n.count,0)),q2=Je.createSelector(bf,e=>Math.max(0,ke-e)),K2=Je.createSelector(q2,e=>e>0),J2=({onSetActiveTab:e,onToggleSidebar:t})=>{const n=oe(bf);return m.jsxs("header",{className:"flex flex-row MaterialMultiProductList justify-between items-center border-b border-solid border-[var(--border)] p-[var(--sm-padding)]",children:[m.jsxs("div",{className:"flex flex-row items-center gap-[4px]",children:[m.jsxs("div",{className:"flex flex-row items-center gap-[8px]",children:[m.jsx("button",{className:"[&_svg_path]:stroke-[var(--main-accent-color)] cursor-pointer",onClick:()=>e&&e(Jr.SWATCH),children:m.jsx(Ws,{})}),m.jsx("h2",{className:"m-0! text-base leading-[1.6] font-medium ",children:"Your cart"})]}),n>=ke?m.jsxs(m.Fragment,{children:[m.jsxs("span",{className:"text-[var(--main-accent-color)] hidden text-[12px] sm:block",children:["(",ke,") You reached maximum amount of swatches"]}),m.jsxs("span",{className:"text-[var(--main-accent-color)] block sm:hidden",children:["(",ke,") Max"]})]}):null]}),m.jsx("button",{className:`flex flex-row justify-center items-center w-[30px] h-[30px] bg-[var(--background-grey)]
148
148
  border-none cursor-pointer rounded-full
149
149
  [&_svg_path]:stroke-[var(--svg-dark)]`,onClick:t,children:m.jsx(lr,{width:10,height:10})})]})},X2=()=>{const e=Le(),t=oe(Xr)??[],n=oe(K2),r=i=>{e(yh({selectedMaterial:i})),e(ta({selectedMaterial:i}))},a=i=>{e(Ih({selectedMaterial:i}))},s=i=>{e(wh({selectedMaterial:i}))};return m.jsx("ul",{className:"flex flex-col flex-1 min-h-0 overflow-y-auto",children:t?.map(i=>m.jsx(Gl,{item:i,canInc:n,onDelete:()=>r(i),onIncrement:()=>a(i),onDecrement:()=>s(i)},`${i.assetId}/${i.parentName}`))})},Z2=({isOpen:e,onToggleSidebar:t,onSetActiveTab:n,onSendData:r})=>{const a=oe(Xr),s=oe(Xr)??[];return m.jsxs(Ef,{isOpen:e,setIsOpen:t,children:[m.jsx(J2,{onSetActiveTab:n,onToggleSidebar:t}),m.jsxs("div",{className:"flex flex-col h-full min-h-0",children:[m.jsx(X2,{}),m.jsx(qu,{materials:s}),m.jsx("div",{className:"p-[var(--sm-padding)] border-t border-solid border-[var(--border)] shrink-0",children:m.jsx("button",{className:"w-full bg-[var(--main-accent-color)] text-white py-3 rounded-full font-bold cursor-pointer",onClick:()=>r(a),children:"GO TO SHIPPING"})})]})]})},_2=({isOpen:e,onToggleSidebar:t,onSendData:n})=>{const[r,a]=M.useState(Jr.SWATCH),s=i=>{a(i)};return m.jsx(m.Fragment,{children:r===Jr.SWATCH?m.jsx(V2,{isOpen:e,onToggleSidebar:t,onSetActiveTab:s}):m.jsx(Z2,{isOpen:e,onToggleSidebar:t,onSetActiveTab:s,onSendData:n})})},$2=Je.combineReducers({swatches:Qu,cart:ju,multiProductCart:Wu});let Za=null;function eI(){return Je.configureStore({reducer:$2,devTools:!1,middleware:e=>e({thunk:!0})})}const tI=()=>(Za||(Za=eI()),Za),nI=En.useDispatch.withTypes();En.useSelector.withTypes();function Tf({children:e}){return m.jsx(En.Provider,{store:tI(),children:e})}const rI=({isOpen:e,uiDataType:t,data:n,assetId:r,onToggleSidebar:a,onSendData:s})=>{const o=[tt.UI,tt.FETCH_DATA_PRODUCT].includes(t),l=nI();return M.useEffect(()=>{if(t===tt.UI){if(!n)throw new Error("SwatchCart-module: Attributes are important");const c=us.getTransformedData({dataType:tt.UI,data:n});c&&l(ns(c))}else t===tt.FETCH_DATA_PRODUCT&&r?(async()=>{try{const d=await l(Wn({assetId:r})).unwrap(),f=us.getTransformedData({dataType:tt.FETCH_DATA_PRODUCT,data:d});l(ns(f))}catch(d){console.error("Failed to load product",d)}})():t===tt.FETCH_DATA_ALL&&(async()=>{try{l(Gn()).unwrap()}catch(d){console.error("Failed to load product",d)}})()},[t,n,r]),m.jsxs(Tf,{children:[m.jsx(ph,{position:"top-center",autoClose:5e3,hideProgressBar:!0,newestOnTop:!1,closeOnClick:!1,rtl:!1,pauseOnFocusLoss:!0,draggable:!0,pauseOnHover:!0,theme:"dark",transition:Fu}),e?m.jsxs(m.Fragment,{children:[o?null:m.jsx(M2,{onSendData:s,onToggleSidebar:a}),o?m.jsx(_2,{isOpen:e,uiDataType:t,data:n,assetId:r,onToggleSidebar:a,onSendData:s}):null]}):null]})};function aI(e){const t=n=>m.jsx(Tf,{children:m.jsx(e,{...n})});return t.displayName=`withStore(${e.displayName||e.name||"Component"})`,t}const Cf=aI(rI),sI=tt;function iI(e,t){const n=Of.createRoot(e);return n.render(M.createElement(Cf,t)),()=>n.unmount()}exports.EDataInputType=sI;exports.SwatchModule=Cf;exports.mountSwatchModule=iI;
150
150
  //# sourceMappingURL=main.cjs.map