@cedros/pay-react 1.1.20 → 1.1.22
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/README.md +2 -0
- package/dist/{AISettingsSection-f5K0nUoQ.js → AISettingsSection-BtOxEweU.js} +1 -1
- package/dist/{AISettingsSection-BH-RXvk1.mjs → AISettingsSection-p3iikbSw.mjs} +2 -2
- package/dist/{AutosaveIndicator-CpTVtJIz.js → AutosaveIndicator-C-CH-obR.js} +1 -1
- package/dist/{AutosaveIndicator-DTOaopUP.mjs → AutosaveIndicator-CWbb-VXf.mjs} +1 -1
- package/dist/{FAQSection-CVJ5w6cB.js → FAQSection-DQpF7hVx.js} +1 -1
- package/dist/{FAQSection-BO7ZfQMN.mjs → FAQSection-byh7zfqI.mjs} +1 -1
- package/dist/MessagingSection-B6EHvjDw.js +1 -0
- package/dist/{MessagingSection-CmFYFdaw.mjs → MessagingSection-CK208brx.mjs} +143 -96
- package/dist/{PaymentSettingsSection-VDcgpOkp.mjs → PaymentSettingsSection-B9H253x1.mjs} +1 -1
- package/dist/{PaymentSettingsSection-BKDiep-C.js → PaymentSettingsSection-Cmmuhmd4.js} +1 -1
- package/dist/{SettingsSection-B0TpaIOG.mjs → SettingsSection-DDLMaEPo.mjs} +1 -1
- package/dist/{SettingsSection-DSlW47o4.js → SettingsSection-DrzGdvHH.js} +1 -1
- package/dist/{SingleCategorySettings-Cwlehl0u.mjs → SingleCategorySettings-BU98SRFV.mjs} +19 -15
- package/dist/SingleCategorySettings-DqcXe-q4.js +3 -0
- package/dist/{StorefrontSection-DfN5yxkV.js → StorefrontSection-DTpZ_GgO.js} +1 -1
- package/dist/{StorefrontSection-BAY9V1j6.mjs → StorefrontSection-Dr2ciBVg.mjs} +2 -2
- package/dist/{SubscriptionsSection-D_RKCILr.mjs → SubscriptionsSection-CU3Ce8r9.mjs} +1 -1
- package/dist/{SubscriptionsSection-BboudRYv.js → SubscriptionsSection-CYJpArJ8.js} +1 -1
- package/dist/crypto-only.js +1 -1
- package/dist/crypto-only.mjs +133 -130
- package/dist/{index-75RhiLDq.mjs → index-CufXF9Yd.mjs} +3116 -3099
- package/dist/{index-B5ck27xb.js → index-IZ4WcMd7.js} +10 -10
- package/dist/index.js +1 -1
- package/dist/index.mjs +51 -48
- package/dist/sections-Bc6ARlND.mjs +8 -0
- package/dist/{sections-BCdzdqlG.js → sections-CR7NRsjq.js} +1 -1
- package/dist/src/admin/index.d.ts +2 -0
- package/dist/src/admin/index.d.ts.map +1 -1
- package/dist/src/admin/sectionIds.d.ts +43 -0
- package/dist/src/admin/sectionIds.d.ts.map +1 -0
- package/dist/src/components/admin/MessagingSection.d.ts.map +1 -1
- package/dist/src/components/admin/configApi.d.ts.map +1 -1
- package/dist/src/components/admin/emailProviders.d.ts +18 -0
- package/dist/src/components/admin/emailProviders.d.ts.map +1 -0
- package/dist/src/ecommerce/adapters/paywall/paywallAdapter.d.ts.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/MessagingSection-CRFtSoE8.js +0 -1
- package/dist/SingleCategorySettings-BTXR7zex.js +0 -3
- package/dist/sections-BIBMX6KS.mjs +0 -8
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";const s=require("react/jsx-runtime"),k=require("react"),$f=require("@solana/wallet-adapter-react"),Je=require("./CedrosContext-D-lnoEkR.js"),zf=require("@cedros/login-react"),oi=require("./index-WcOlBYZJ.js"),Zo=require("react-dom"),Ff=require("./styles-BWrLnaUW.js");function Tc(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const m=Tc(k),ps=Tc(Zo);function lr(e){return new Date(e).toLocaleString()}const Y={products:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M20 7.5v9l-4 2.25M4 7.5v9l4 2.25"}),s.jsx("path",{d:"m20 7.5-8-4.5-8 4.5"}),s.jsx("path",{d:"m12 12 8-4.5M12 12v9.5M12 12 4 7.5"})]}),transactions:s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M12 2v20M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"})}),coupons:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z"}),s.jsx("path",{d:"M13 5v2M13 17v2M13 11v2"})]}),refunds:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),s.jsx("path",{d:"M3 3v5h5"}),s.jsx("path",{d:"M12 7v5l4 2"})]}),settings:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),s.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),wallet:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1"}),s.jsx("path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"})]}),chevronRight:s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"m9 18 6-6-6-6"})}),loading:s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"cedros-admin__spinner",children:s.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),refresh:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"}),s.jsx("path",{d:"M21 3v5h-5"}),s.jsx("path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"}),s.jsx("path",{d:"M8 16H3v5"})]}),check:s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M20 6 9 17l-5-5"})}),subscriptions:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"}),s.jsx("circle",{cx:"12",cy:"12",r:"3"}),s.jsx("path",{d:"M12 2v2M12 20v2M2 12H4M20 12h2"})]}),trash:s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M3 6h18M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})}),plus:s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M12 5v14M5 12h14"})}),chevronDown:s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"m6 9 6 6 6-6"})}),chevronUp:s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"m18 15-6-6-6 6"})}),storefront:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M3 9h18v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V9Z"}),s.jsx("path",{d:"m3 9 2.45-4.9A2 2 0 0 1 7.24 3h9.52a2 2 0 0 1 1.8 1.1L21 9"}),s.jsx("path",{d:"M12 3v6"})]}),arrowUp:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"m5 12 7-7 7 7"}),s.jsx("path",{d:"M12 19V5"})]}),arrowDown:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"m5 12 7 7 7-7"}),s.jsx("path",{d:"M12 5v14"})]}),delete:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M3 6h18M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"}),s.jsx("path",{d:"M10 11v6M14 11v6"})]}),close:s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M18 6 6 18M6 6l12 12"})}),edit:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),s.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),faq:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"}),s.jsx("path",{d:"M12 17h.01"})]}),chat:s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"m3 21 1.9-5.7a8.5 8.5 0 1 1 3.8 3.8z"})}),globe:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"}),s.jsx("path",{d:"M2 12h20"})]}),ai:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M12 2a4 4 0 0 1 4 4v2a4 4 0 0 1-8 0V6a4 4 0 0 1 4-4Z"}),s.jsx("path",{d:"M10 10v.5"}),s.jsx("path",{d:"M14 10v.5"}),s.jsx("path",{d:"M12 14v2"}),s.jsx("path",{d:"M8 18h8"}),s.jsx("path",{d:"M6 18a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2"}),s.jsx("path",{d:"M6 12v6"}),s.jsx("path",{d:"M18 12v6"})]}),notifications:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9"}),s.jsx("path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0"})]}),eye:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"}),s.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),eyeOff:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M9.88 9.88a3 3 0 1 0 4.24 4.24"}),s.jsx("path",{d:"M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68"}),s.jsx("path",{d:"M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61"}),s.jsx("line",{x1:"2",x2:"22",y1:"2",y2:"22"})]}),creditCard:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{width:"20",height:"14",x:"2",y:"5",rx:"2"}),s.jsx("line",{x1:"2",x2:"22",y1:"10",y2:"10"})]}),mail:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{width:"20",height:"16",x:"2",y:"4",rx:"2"}),s.jsx("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]}),server:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2"}),s.jsx("rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2"}),s.jsx("line",{x1:"6",x2:"6.01",y1:"6",y2:"6"}),s.jsx("line",{x1:"6",x2:"6.01",y1:"18",y2:"18"})]}),calendarRepeat:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",ry:"2"}),s.jsx("line",{x1:"16",x2:"16",y1:"2",y2:"6"}),s.jsx("line",{x1:"8",x2:"8",y1:"2",y2:"6"}),s.jsx("line",{x1:"3",x2:"21",y1:"10",y2:"10"}),s.jsx("path",{d:"M11 14h1.5a1.5 1.5 0 0 1 0 3H11v2"}),s.jsx("path",{d:"M16 14v3a1 1 0 0 0 1 1h1"})]}),brain:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z"}),s.jsx("path",{d:"M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z"}),s.jsx("path",{d:"M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4"}),s.jsx("path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375"}),s.jsx("path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5"}),s.jsx("path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396"}),s.jsx("path",{d:"M19.938 10.5a4 4 0 0 1 .585.396"}),s.jsx("path",{d:"M6 18a4 4 0 0 1-1.967-.516"}),s.jsx("path",{d:"M19.967 17.484A4 4 0 0 1 18 18"})]})};function jr({message:e,onRetry:t}){return e?s.jsxs("div",{className:"cedros-admin__error-banner",children:[s.jsx("span",{children:e}),t&&s.jsxs("button",{type:"button",className:"cedros-admin__error-banner-retry",onClick:t,children:[Y.refresh," Retry"]})]}):null}function Sr({stats:e,isLoading:t=!1,onRefresh:n}){return s.jsxs("div",{className:"cedros-admin__stats-bar",children:[s.jsx("div",{className:"cedros-admin__stats-bar-grid",children:e.map((r,o)=>s.jsxs("div",{className:"cedros-admin__stats-bar-item",children:[s.jsx("span",{className:"cedros-admin__stats-bar-label",children:r.label}),s.jsx("span",{className:`cedros-admin__stats-bar-value ${r.variant?`cedros-admin__stats-bar-value--${r.variant}`:""}`,children:t?s.jsx("span",{className:"cedros-admin__skeleton cedros-admin__skeleton--value"}):r.value}),r.description&&s.jsx("span",{className:"cedros-admin__stats-bar-desc",children:r.description})]},o))}),n&&s.jsx("button",{type:"button",className:"cedros-admin__stats-bar-refresh",onClick:n,disabled:t,title:"Refresh stats",children:t?Y.loading:Y.refresh})]})}function Uf({serverUrl:e,productId:t,apiKey:n,authManager:r}){const[o,a]=k.useState(null),[i,c]=k.useState(!1),[l,d]=k.useState(!1),[f,u]=k.useState(null),h=k.useCallback(async()=>{if(t){c(!0),u(null);try{let x;if(r?.isAuthenticated())x=await r.fetchWithAuth(`/admin/products/${t}/variations`);else{const p={"Content-Type":"application/json"};n&&(p["X-API-Key"]=n);const v=await fetch(`${e}/admin/products/${t}/variations`,{headers:p});if(!v.ok)throw new Error(`Failed to fetch variations: ${v.status}`);x=await v.json()}x.variationConfig||(x.variationConfig={variationTypes:[]}),x.variants||(x.variants=[]),a(x)}catch(x){const p=x instanceof Error?x.message:"Failed to fetch variations";u(p),a({productId:t,variationConfig:{variationTypes:[]},variants:[]})}finally{c(!1)}}},[e,t,n,r]),g=k.useCallback(async x=>{if(!t)return null;d(!0),u(null);try{let p;if(r?.isAuthenticated())p=await r.fetchWithAuth(`/admin/products/${t}/variations`,{method:"PUT",body:JSON.stringify(x)});else{const v={"Content-Type":"application/json"};n&&(v["X-API-Key"]=n);const _=await fetch(`${e}/admin/products/${t}/variations`,{method:"PUT",headers:v,body:JSON.stringify(x)});if(!_.ok)throw new Error(`Failed to save variations: ${_.status}`);p=await _.json()}return a({productId:t,variationConfig:p.variationConfig,variants:p.variants}),{variantsCreated:p.variantsCreated}}catch(p){const v=p instanceof Error?p.message:"Failed to save variations";return u(v),null}finally{d(!1)}},[e,t,n,r]),y=k.useCallback(async x=>{if(!t||x.length===0)return!1;d(!0),u(null);try{if(r?.isAuthenticated())await r.fetchWithAuth(`/admin/products/${t}/variants/inventory`,{method:"PUT",body:JSON.stringify({updates:x})});else{const p={"Content-Type":"application/json"};n&&(p["X-API-Key"]=n);const v=await fetch(`${e}/admin/products/${t}/variants/inventory`,{method:"PUT",headers:p,body:JSON.stringify({updates:x})});if(!v.ok)throw new Error(`Failed to update inventory: ${v.status}`)}if(o){const p=new Map(x.map(v=>[v.variantId,v]));a({...o,variants:o.variants.map(v=>{const _=p.get(v.id);return _?{...v,inventoryQuantity:_.inventoryQuantity,inventoryStatus:_.inventoryStatus??v.inventoryStatus}:v})})}return!0}catch(p){const v=p instanceof Error?p.message:"Failed to update inventory";return u(v),!1}finally{d(!1)}},[e,t,n,r,o]);return{data:o,isLoading:i,error:f,fetch:h,save:g,bulkUpdateInventory:y,isSaving:l}}function ai(){return`var_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function Bf({value:e,onChange:t,maxTypes:n=5,maxValuesPerType:r=20,disabled:o=!1}){const[a,i]=k.useState(null),[c,l]=k.useState(""),[d,f]=k.useState({}),u=e.variationTypes,h=k.useCallback(()=>{if(!c.trim()||u.length>=n)return;const w={id:ai(),name:c.trim(),displayOrder:u.length,values:[]};t({variationTypes:[...u,w]}),l(""),i(w.id)},[c,u,n,t]),g=k.useCallback(w=>{t({variationTypes:u.filter(b=>b.id!==w).map((b,j)=>({...b,displayOrder:j}))}),a===w&&i(null)},[u,t,a]),y=k.useCallback((w,b)=>{t({variationTypes:u.map(j=>j.id===w?{...j,name:b}:j)})},[u,t]),x=k.useCallback((w,b)=>{const j=u.findIndex(C=>C.id===w);if(j===-1||b==="up"&&j===0||b==="down"&&j===u.length-1)return;const R=[...u],I=b==="up"?j-1:j+1;[R[j],R[I]]=[R[I],R[j]],t({variationTypes:R.map((C,E)=>({...C,displayOrder:E}))})},[u,t]),p=k.useCallback(w=>{const b=(d[w]||"").trim();if(!b)return;const j=u.find(I=>I.id===w);if(!j||j.values.length>=r)return;const R={id:ai(),label:b};t({variationTypes:u.map(I=>I.id===w?{...I,values:[...I.values,R]}:I)}),f(I=>({...I,[w]:""}))},[u,d,r,t]),v=k.useCallback((w,b)=>{t({variationTypes:u.map(j=>j.id===w?{...j,values:j.values.filter(R=>R.id!==b)}:j)})},[u,t]),_=k.useCallback((w,b,j)=>{t({variationTypes:u.map(R=>R.id===w?{...R,values:R.values.map(I=>I.id===b?{...I,label:j}:I)}:R)})},[u,t]);return s.jsxs("div",{className:"cedros-admin__variation-editor",children:[s.jsxs("div",{className:"cedros-admin__variation-editor-header",children:[s.jsx("h4",{className:"cedros-admin__field-label",style:{marginBottom:0},children:"Variation Types"}),s.jsxs("span",{style:{fontSize:12,opacity:.7},children:[u.length,"/",n," types"]})]}),u.length===0?s.jsx("div",{className:"cedros-admin__variation-empty",children:'No variation types defined. Add types like "Size" or "Color" to create product variants.'}):s.jsx("div",{className:"cedros-admin__variation-type-list",children:u.map((w,b)=>s.jsxs("div",{className:"cedros-admin__variation-type-item",children:[s.jsxs("div",{className:"cedros-admin__variation-type-header",children:[s.jsxs("div",{className:"cedros-admin__variation-type-controls",children:[s.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--icon",onClick:()=>x(w.id,"up"),disabled:o||b===0,title:"Move up",children:Y.arrowUp}),s.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--icon",onClick:()=>x(w.id,"down"),disabled:o||b===u.length-1,title:"Move down",children:Y.arrowDown})]}),s.jsx("input",{type:"text",className:"cedros-admin__input cedros-admin__variation-type-name",value:w.name,onChange:j=>y(w.id,j.target.value),disabled:o,placeholder:"Type name"}),s.jsxs("span",{className:"cedros-admin__variation-value-count",children:[w.values.length," values"]}),s.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>i(a===w.id?null:w.id),children:a===w.id?"Collapse":"Edit values"}),s.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--danger",onClick:()=>g(w.id),disabled:o,title:"Remove type",children:Y.delete})]}),a===w.id&&s.jsxs("div",{className:"cedros-admin__variation-values",children:[s.jsxs("div",{className:"cedros-admin__variation-values-header",children:[s.jsxs("span",{style:{fontSize:12,fontWeight:600},children:['Values for "',w.name,'"']}),s.jsxs("span",{style:{fontSize:11,opacity:.7},children:[w.values.length,"/",r]})]}),w.values.length===0?s.jsx("div",{className:"cedros-admin__variation-empty",style:{padding:"8px 0"},children:'No values yet. Add values like "Small", "Medium", "Large".'}):s.jsx("div",{className:"cedros-admin__variation-value-list",children:w.values.map(j=>s.jsxs("div",{className:"cedros-admin__variation-value-item",children:[s.jsx("input",{type:"text",className:"cedros-admin__input cedros-admin__input--sm",value:j.label,onChange:R=>_(w.id,j.id,R.target.value),disabled:o}),s.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--icon cedros-admin__button--danger",onClick:()=>v(w.id,j.id),disabled:o,title:"Remove value",children:Y.close})]},j.id))}),w.values.length<r&&s.jsxs("div",{className:"cedros-admin__variation-add-value",children:[s.jsx("input",{type:"text",className:"cedros-admin__input cedros-admin__input--sm",value:d[w.id]||"",onChange:j=>f(R=>({...R,[w.id]:j.target.value})),placeholder:"Add value...",disabled:o,onKeyDown:j=>{j.key==="Enter"&&(j.preventDefault(),p(w.id))}}),s.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--secondary cedros-admin__button--sm",onClick:()=>p(w.id),disabled:o||!d[w.id]?.trim(),children:"Add"})]})]})]},w.id))}),u.length<n&&s.jsxs("div",{className:"cedros-admin__variation-add-type",children:[s.jsx("input",{type:"text",className:"cedros-admin__input",value:c,onChange:w=>l(w.target.value),placeholder:"New variation type (e.g., Size, Color)",disabled:o,onKeyDown:w=>{w.key==="Enter"&&(w.preventDefault(),h())}}),s.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--secondary",onClick:h,disabled:o||!c.trim(),children:"Add Type"})]})]})}function Pc({value:e,onChange:t,options:n,placeholder:r="Filter",disabled:o}){const[a,i]=k.useState(!1),c=k.useRef(null),d=n.find(f=>f.value===e)?.label||r;return k.useEffect(()=>{const f=u=>{c.current&&!c.current.contains(u.target)&&i(!1)};if(a)return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[a]),k.useEffect(()=>{const f=u=>{u.key==="Escape"&&i(!1)};if(a)return document.addEventListener("keydown",f),()=>document.removeEventListener("keydown",f)},[a]),s.jsxs("div",{className:"cedros-admin__dropdown",ref:c,children:[s.jsxs("button",{type:"button",className:"cedros-admin__dropdown-trigger",onClick:()=>!o&&i(!a),"aria-expanded":a,"aria-haspopup":"listbox",disabled:o,children:[s.jsx("span",{children:d}),s.jsx("span",{className:`cedros-admin__dropdown-chevron ${a?"cedros-admin__dropdown-chevron--open":""}`,children:Y.chevronDown})]}),a&&s.jsx("div",{className:"cedros-admin__dropdown-menu",role:"listbox",children:n.map(f=>s.jsxs("button",{type:"button",className:`cedros-admin__dropdown-item ${f.value===e?"cedros-admin__dropdown-item--selected":""}`,onClick:()=>{f.disabled||(t(f.value),i(!1))},role:"option","aria-selected":f.value===e,disabled:f.disabled,children:[f.label,f.value===e&&s.jsx("span",{className:"cedros-admin__dropdown-check",children:Y.check})]},f.value))})]})}function Et({value:e,onChange:t,options:n,label:r,description:o,disabled:a,className:i,style:c}){const[l,d]=k.useState(!1),f=k.useRef(null),h=n.find(g=>g.value===e)?.label||"Select...";return k.useEffect(()=>{const g=y=>{f.current&&!f.current.contains(y.target)&&d(!1)};if(l)return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[l]),k.useEffect(()=>{const g=y=>{y.key==="Escape"&&d(!1)};if(l)return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[l]),s.jsxs("div",{className:`cedros-admin__field ${i||""}`,style:c,children:[s.jsx("label",{className:"cedros-admin__field-label",children:r}),s.jsxs("div",{className:"cedros-admin__dropdown cedros-admin__dropdown--form",ref:f,children:[s.jsxs("button",{type:"button",className:"cedros-admin__dropdown-trigger cedros-admin__dropdown-trigger--form",onClick:()=>!a&&d(!l),"aria-expanded":l,"aria-haspopup":"listbox",disabled:a,children:[s.jsx("span",{children:h}),s.jsx("span",{className:`cedros-admin__dropdown-chevron ${l?"cedros-admin__dropdown-chevron--open":""}`,children:Y.chevronDown})]}),l&&s.jsx("div",{className:"cedros-admin__dropdown-menu cedros-admin__dropdown-menu--form",role:"listbox",children:n.map(g=>s.jsxs("button",{type:"button",className:`cedros-admin__dropdown-item ${g.value===e?"cedros-admin__dropdown-item--selected":""}`,onClick:()=>{g.disabled||(t(g.value),d(!1))},role:"option","aria-selected":g.value===e,disabled:g.disabled,children:[g.label,g.value===e&&s.jsx("span",{className:"cedros-admin__dropdown-check",children:Y.check})]},g.value))})]}),o&&s.jsx("p",{className:"cedros-admin__field-description",children:o})]})}function ii(){return`variant_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function Vf(e){if(e.length===0)return[];const t=[...e].sort((r,o)=>r.displayOrder-o.displayOrder),n=(r,o)=>{if(r>=t.length){const c=o.valueIds.sort().join("|"),l=Object.values(o.options).join(" / ");return[{key:c,title:l,optionValueIds:[...o.valueIds],options:{...o.options}}]}const a=t[r],i=[];for(const c of a.values)i.push(...n(r+1,{valueIds:[...o.valueIds,c.id],options:{...o.options,[a.name]:c.label}}));return i};return n(0,{valueIds:[],options:{}})}function Wf(e){return e.optionValueIds?.length?[...e.optionValueIds].sort().join("|"):Object.entries(e.options).sort(([t],[n])=>t.localeCompare(n)).map(([t,n])=>`${t}:${n}`).join("|")}function Hf({variationConfig:e,variants:t,onChange:n,defaultPrice:r=0,currencySymbol:o="$",maxVariants:a=100,disabled:i=!1}){const c=k.useMemo(()=>Vf(e.variationTypes),[e.variationTypes]),l=k.useMemo(()=>{const x=new Map;for(const p of t)x.set(Wf(p),p);return x},[t]),{existingRows:d,possibleRows:f}=k.useMemo(()=>{const x=[],p=[];for(const v of c){const _=l.get(v.key);_?x.push({combo:v,variant:_}):p.push(v)}return{existingRows:x,possibleRows:p}},[c,l]),u=k.useCallback((x,p)=>{n(t.map(v=>v.id===x?{...v,...p}:v))},[t,n]),h=k.useCallback(x=>{n(t.filter(p=>p.id!==x))},[t,n]),g=k.useCallback(x=>{if(t.length>=a)return;const p={id:ii(),title:x.title,options:x.options,optionValueIds:x.optionValueIds,price:r,inventoryQuantity:0,inventoryStatus:"in_stock",autoGenerated:!1};n([...t,p])},[t,n,a,r]),y=k.useCallback(()=>{const x=a-t.length,v=f.slice(0,x).map(_=>({id:ii(),title:_.title,options:_.options,optionValueIds:_.optionValueIds,price:r,inventoryQuantity:0,inventoryStatus:"in_stock",autoGenerated:!0}));n([...t,...v])},[t,n,f,a,r]);return e.variationTypes.length===0?s.jsx("div",{className:"cedros-admin__variant-grid-empty",children:"Add variation types above to create product variants."}):c.length===0?s.jsx("div",{className:"cedros-admin__variant-grid-empty",children:"Add values to your variation types to create product variants."}):s.jsxs("div",{className:"cedros-admin__variant-grid",children:[s.jsxs("div",{className:"cedros-admin__variant-grid-header",children:[s.jsx("h4",{className:"cedros-admin__field-label",style:{marginBottom:0},children:"Variants"}),s.jsxs("span",{style:{fontSize:12,opacity:.7},children:[t.length,"/",a," variants (",c.length," ","possible)"]})]}),f.length>0&&t.length<a&&s.jsxs("div",{className:"cedros-admin__variant-grid-actions",children:[s.jsxs("button",{type:"button",className:"cedros-admin__button cedros-admin__button--secondary",onClick:y,disabled:i,children:["Generate All (",Math.min(f.length,a-t.length),")"]}),s.jsx("span",{style:{fontSize:11,opacity:.7},children:"Creates variants with default price and 0 inventory"})]}),s.jsx("div",{className:"cedros-admin__table-container",children:s.jsxs("table",{className:"cedros-admin__table cedros-admin__variant-table",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Variant"}),s.jsx("th",{style:{width:100},children:"Price"}),s.jsx("th",{style:{width:80},children:"Qty"}),s.jsx("th",{style:{width:100},children:"SKU"}),s.jsx("th",{style:{width:100},children:"Status"}),s.jsx("th",{style:{width:80},children:"Actions"})]})}),s.jsxs("tbody",{children:[d.map(({combo:x,variant:p})=>s.jsxs("tr",{children:[s.jsx("td",{children:s.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[s.jsx("span",{style:{fontWeight:600},children:x.title}),s.jsx("span",{style:{fontSize:11,opacity:.6},children:Object.entries(x.options).map(([v,_])=>`${v}: ${_}`).join(", ")})]})}),s.jsx("td",{children:s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[s.jsx("span",{children:o}),s.jsx("input",{type:"number",className:"cedros-admin__input cedros-admin__input--sm",value:p.price??"",onChange:v=>u(p.id,{price:v.target.value===""?void 0:parseFloat(v.target.value)||0}),disabled:i,min:"0",step:"0.01",style:{width:70}})]})}),s.jsx("td",{children:s.jsx("input",{type:"number",className:"cedros-admin__input cedros-admin__input--sm",value:p.inventoryQuantity??"",onChange:v=>u(p.id,{inventoryQuantity:v.target.value===""?void 0:parseInt(v.target.value)||0}),disabled:i,min:"0",style:{width:60}})}),s.jsx("td",{children:s.jsx("input",{type:"text",className:"cedros-admin__input cedros-admin__input--sm",value:p.sku??"",onChange:v=>u(p.id,{sku:v.target.value||void 0}),disabled:i,placeholder:"SKU",style:{width:80}})}),s.jsx("td",{children:s.jsx(Pc,{value:p.inventoryStatus??"in_stock",onChange:v=>u(p.id,{inventoryStatus:v}),options:[{value:"in_stock",label:"In stock"},{value:"low",label:"Low"},{value:"out_of_stock",label:"Out of stock"},{value:"backorder",label:"Backorder"}],disabled:i})}),s.jsx("td",{children:s.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--icon cedros-admin__button--danger",onClick:()=>h(p.id),disabled:i,title:"Remove variant",children:Y.trash})})]},p.id)),f.length>0&&t.length<a&&s.jsxs(s.Fragment,{children:[s.jsx("tr",{className:"cedros-admin__variant-separator",children:s.jsx("td",{colSpan:6,children:s.jsxs("span",{style:{fontSize:11,opacity:.6},children:["Uncreated combinations (",f.length,")"]})})}),f.slice(0,10).map(x=>s.jsxs("tr",{className:"cedros-admin__variant-possible",children:[s.jsx("td",{children:s.jsx("span",{style:{opacity:.6},children:x.title})}),s.jsx("td",{colSpan:4,style:{opacity:.5},children:"Not created"}),s.jsx("td",{children:s.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--icon",onClick:()=>g(x),disabled:i,title:"Create variant",children:Y.plus})})]},x.key)),f.length>10&&s.jsx("tr",{className:"cedros-admin__variant-more",children:s.jsxs("td",{colSpan:6,style:{textAlign:"center",opacity:.6},children:["+",f.length-10," more combinations"]})})]})]})]})})]})}function Zf({serverUrl:e,productId:t,productTitle:n,defaultPrice:r=0,currencySymbol:o="$",apiKey:a,authManager:i,onClose:c}){const{data:l,isLoading:d,error:f,fetch:u,save:h,isSaving:g}=Uf({serverUrl:e,productId:t,apiKey:a,authManager:i}),[y,x]=k.useState({variationTypes:[]}),[p,v]=k.useState([]),[_,w]=k.useState(!1),[b,j]=k.useState(!1);k.useEffect(()=>{u()},[u]),k.useEffect(()=>{l&&(x(l.variationConfig),v(l.variants),w(!1))},[l]);const R=k.useCallback(E=>{x(E),w(!0),j(!1)},[]),I=k.useCallback(E=>{v(E),w(!0),j(!1)},[]),C=k.useCallback(async()=>{const E=new Set((l?.variants??[]).map(D=>D.id)),O=p.filter(D=>!E.has(D.id)),F=p.filter(D=>E.has(D.id)),M=(l?.variants??[]).filter(D=>!p.some(H=>H.id===D.id)).map(D=>D.id);await h({variationConfig:y,createVariants:O.map(D=>({optionValueIds:D.optionValueIds??[],inventoryQuantity:D.inventoryQuantity,sku:D.sku,price:D.price})),updateVariants:F.map(D=>({id:D.id,inventoryQuantity:D.inventoryQuantity,sku:D.sku,price:D.price,inventoryStatus:D.inventoryStatus})),deleteVariantIds:M.length>0?M:void 0})&&(w(!1),j(!0),setTimeout(()=>j(!1),3e3))},[y,p,l?.variants,h]);return d?s.jsxs("div",{className:"cedros-admin__variations-editor",children:[s.jsxs("div",{className:"cedros-admin__variations-editor-header",children:[s.jsx("h3",{className:"cedros-admin__section-title",children:n?`Variations: ${n}`:"Product Variations"}),c&&s.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost",onClick:c,children:Y.close})]}),s.jsxs("div",{className:"cedros-admin__loading",children:[Y.loading," Loading variations..."]})]}):s.jsxs("div",{className:"cedros-admin__variations-editor",children:[s.jsxs("div",{className:"cedros-admin__variations-editor-header",children:[s.jsx("h3",{className:"cedros-admin__section-title",children:n?`Variations: ${n}`:"Product Variations"}),s.jsxs("div",{className:"cedros-admin__variations-editor-actions",children:[b&&s.jsxs("span",{className:"cedros-admin__success-text",children:[Y.check," Saved"]}),_&&s.jsx("span",{className:"cedros-admin__unsaved-text",children:"Unsaved changes"}),s.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--primary",onClick:C,disabled:g||!_,children:g?"Saving...":"Save Changes"}),c&&s.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost",onClick:c,children:Y.close})]})]}),f&&s.jsx("div",{className:"cedros-admin__error-banner",children:f}),s.jsxs("div",{className:"cedros-admin__variations-editor-content",children:[s.jsx("div",{className:"cedros-admin__variations-editor-section",children:s.jsx(Bf,{value:y,onChange:R,disabled:g})}),y.variationTypes.length>0&&s.jsx("div",{className:"cedros-admin__variations-editor-section",children:s.jsx(Hf,{variationConfig:y,variants:p,onChange:I,defaultPrice:r,currencySymbol:o,disabled:g})})]})]})}function Rc({serverUrl:e,apiKey:t,pageSize:n=20,authManager:r}){const[o,a]=k.useState([]),[i,c]=k.useState(!0),[l,d]=k.useState(!1),[f,u]=k.useState(!1),[h,g]=k.useState(null),[y,x]=k.useState(null),[p,v]=k.useState(null),[_,w]=k.useState(null),[b,j]=k.useState({id:"",title:"",slug:"",imageUrl:"",description:"",productType:"one_time",priceUsd:"",fiatCurrency:"usd",cryptoToken:"USDC",inventoryStatus:"in_stock",compareAtUsd:"",tagsCsv:"",categoryIdsCsv:"",checkoutEmail:"required",checkoutName:"optional",checkoutPhone:"none",checkoutShippingAddress:!1,checkoutBillingAddress:!1,fulfillmentType:"shipping",fulfillmentNotes:"",shippingCountriesCsv:"",inventoryQuantity:""}),R=A=>{const N=A.tagsCsv.split(",").map(q=>q.trim()).filter(Boolean),Z=A.categoryIdsCsv.split(",").map(q=>q.trim()).filter(Boolean),te={email:A.checkoutEmail,name:A.checkoutName,phone:A.checkoutPhone,shippingAddress:A.checkoutShippingAddress,billingAddress:A.checkoutBillingAddress},re=A.fulfillmentType==="shipping"?"physical":"digital",de={title:A.title,slug:A.slug||A.id,shipping_profile:re,inventory_status:A.inventoryStatus,checkout_requirements:JSON.stringify(te),fulfillment_type:A.fulfillmentType};A.imageUrl&&(de.image_url=A.imageUrl);const W=A.compareAtUsd?Math.round(Number(A.compareAtUsd)*100):0;W&&(de.compare_at_amount_cents=String(W)),N.length&&(de.tags=JSON.stringify(N)),Z.length&&(de.category_ids=JSON.stringify(Z)),A.fulfillmentNotes&&(de.fulfillment_notes=A.fulfillmentNotes);const Q=A.shippingCountriesCsv.split(",").map(q=>q.trim().toUpperCase()).filter(Boolean);return Q.length&&(de.shippingCountries=Q.join(","),de.shipping_countries=Q.join(",")),de},I=A=>A.metadata?.title||A.description||A.id,C=A=>A.metadata?.image_url,E=k.useCallback(async()=>{try{w(null);let A;if(r?.isAuthenticated())A=await r.fetchWithAuth(`/admin/products?limit=${n}`);else{const N={"Content-Type":"application/json"};t&&(N["X-API-Key"]=t);const Z=await fetch(`${e}/admin/products?limit=${n}`,{headers:N});if(!Z.ok)throw new Error(`Failed to fetch products: ${Z.status}`);A=await Z.json()}a(A.products||[])}catch{a([]),w("Failed to load products")}finally{c(!1)}},[e,t,n,r]);k.useEffect(()=>{E()},[E]);const O=async A=>{if(A.preventDefault(),!(!b.id||!b.description)){if(g(null),b.fulfillmentType==="shipping"&&b.checkoutShippingAddress&&!b.shippingCountriesCsv.split(",").map(Z=>Z.trim()).filter(Boolean).length){g("Shipping countries are required when collecting shipping address. Example: US,CA");return}u(!0);try{const{productType:N}=b,Z=b.inventoryQuantity===""?void 0:Number.isFinite(Number(b.inventoryQuantity))?Number(b.inventoryQuantity):void 0,te=Number(b.priceUsd)||0,re=Math.round(te*100),de=Math.round(te*1e6),W={id:b.id,description:b.description,fiatAmountCents:re,fiatCurrency:b.fiatCurrency,cryptoAtomicAmount:de,cryptoToken:b.cryptoToken,...Z!==void 0?{inventoryQuantity:Z}:{},metadata:{...N?{product_type:N}:{},...R(b)}};if(r?.isAuthenticated())await r.fetchWithAuth("/admin/products",{method:"POST",body:JSON.stringify(W)});else{const Q={"Content-Type":"application/json"};t&&(Q["X-API-Key"]=t);const q=await fetch(`${e}/admin/products`,{method:"POST",headers:Q,body:JSON.stringify(W)});if(!q.ok)throw new Error(`Failed to create product: ${q.status}`)}j({id:"",title:"",slug:"",imageUrl:"",description:"",productType:"one_time",priceUsd:"",fiatCurrency:"usd",cryptoToken:"USDC",inventoryStatus:"in_stock",compareAtUsd:"",tagsCsv:"",categoryIdsCsv:"",checkoutEmail:"required",checkoutName:"optional",checkoutPhone:"none",checkoutShippingAddress:!1,checkoutBillingAddress:!1,fulfillmentType:"shipping",fulfillmentNotes:"",shippingCountriesCsv:"",inventoryQuantity:""}),d(!1),E()}catch(N){g(N instanceof Error?N.message:"Failed to create product")}finally{u(!1)}}},F=A=>`$${(A/100).toFixed(2)}`,M=A=>{switch(A){case"subscription":return"Subscription";case"pay_per_access":return"Pay per access";case"one_time":return"One-time purchase";default:return"One-time purchase"}},U=k.useMemo(()=>{const A=o.filter(Z=>Z.active).length,N=o.reduce((Z,te)=>{const re=te.variations?.length??0;return Z+(re>0?re:1)},0);return{activeCount:A,totalSkus:N}},[o]),D=A=>{v(N=>!N||N.key!==A?{key:A,direction:"asc"}:{key:A,direction:N.direction==="asc"?"desc":"asc"})},H=A=>!p||p.key!==A?s.jsx("span",{className:"cedros-admin__sort-icon cedros-admin__sort-icon--idle",children:Y.chevronUp}):s.jsx("span",{className:"cedros-admin__sort-icon",children:p.direction==="asc"?Y.chevronUp:Y.chevronDown}),z=k.useMemo(()=>{if(!p)return o;const A=p.direction==="asc"?1:-1,N=Z=>{switch(p.key){case"product":return I(Z);case"type":return M(Z.metadata?.product_type);case"price":return Z.fiatAmountCents??0;case"status":return Z.active?1:0;case"id":default:return Z.id}};return[...o].sort((Z,te)=>{const re=N(Z),de=N(te);return typeof re=="number"&&typeof de=="number"?(re-de)*A:String(re).localeCompare(String(de),void 0,{sensitivity:"base"})*A})},[o,p]);return s.jsxs("div",{className:"cedros-admin__page",children:[s.jsx(jr,{message:_,onRetry:E}),s.jsx(Sr,{stats:[{label:"Total Products",value:o.length},{label:"Active",value:U.activeCount,variant:U.activeCount>0?"success":"muted"},{label:"Total SKUs",value:U.totalSkus}],isLoading:i}),s.jsxs("div",{className:"cedros-admin__section-header",children:[s.jsx("h3",{className:"cedros-admin__section-title",children:"Paywall Products"}),s.jsxs("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--action",onClick:()=>{g(null),d(!l)},children:[l?Y.close:Y.plus,l?"Cancel":"Add Product"]})]}),l&&s.jsxs("form",{onSubmit:O,className:"cedros-admin__add-form",children:[h&&s.jsx("div",{style:{marginBottom:"0.75rem",color:"#B42318",fontWeight:600},children:h}),s.jsxs("div",{className:"cedros-admin__form-row",children:[s.jsxs("div",{className:"cedros-admin__field",children:[s.jsx("label",{className:"cedros-admin__field-label",children:"Product ID"}),s.jsx("input",{type:"text",className:"cedros-admin__input",value:b.id,onChange:A=>j(N=>({...N,id:A.target.value})),placeholder:"e.g., premium-article",required:!0})]}),s.jsxs("div",{className:"cedros-admin__field",children:[s.jsx("label",{className:"cedros-admin__field-label",children:"Product name"}),s.jsx("input",{type:"text",className:"cedros-admin__input",value:b.title,onChange:A=>j(N=>({...N,title:A.target.value})),placeholder:"e.g., Cedros Hoodie"})]})]}),s.jsxs("div",{className:"cedros-admin__form-row",children:[s.jsxs("div",{className:"cedros-admin__field",children:[s.jsx("label",{className:"cedros-admin__field-label",children:"Slug"}),s.jsx("input",{type:"text",className:"cedros-admin__input",value:b.slug,onChange:A=>j(N=>({...N,slug:A.target.value})),placeholder:"e.g., cedros-hoodie (defaults to ID)"})]}),s.jsxs("div",{className:"cedros-admin__field",children:[s.jsx("label",{className:"cedros-admin__field-label",children:"Primary image URL"}),s.jsx("input",{type:"url",className:"cedros-admin__input",value:b.imageUrl,onChange:A=>j(N=>({...N,imageUrl:A.target.value})),placeholder:"https://..."})]})]}),s.jsx("div",{className:"cedros-admin__form-row",children:s.jsxs("div",{className:"cedros-admin__field",children:[s.jsx("label",{className:"cedros-admin__field-label",children:"Short description"}),s.jsx("input",{type:"text",className:"cedros-admin__input",value:b.description,onChange:A=>j(N=>({...N,description:A.target.value})),placeholder:"e.g., Midweight fleece with relaxed fit",required:!0})]})}),s.jsxs("div",{className:"cedros-admin__form-row",children:[s.jsx(Et,{value:b.productType,onChange:A=>j(N=>({...N,productType:A})),options:[{value:"one_time",label:"One-time purchase"},{value:"pay_per_access",label:"Pay per access"},{value:"subscription",label:"Subscription"}],label:"Product Type"}),s.jsx(Et,{value:b.fulfillmentType,onChange:A=>{const N=A;j(Z=>({...Z,fulfillmentType:N,checkoutShippingAddress:N==="shipping"?Z.checkoutShippingAddress:!1}))},options:[{value:"shipping",label:"Physical (shipped)"},{value:"digital_download",label:"Digital download"},{value:"service",label:"Service"}],label:"Fulfillment"})]}),b.fulfillmentType==="shipping"&&s.jsxs("div",{className:"cedros-admin__form-row",children:[s.jsx(Et,{value:b.inventoryStatus,onChange:A=>j(N=>({...N,inventoryStatus:A})),options:[{value:"in_stock",label:"In stock"},{value:"low",label:"Low"},{value:"out_of_stock",label:"Out of stock"},{value:"backorder",label:"Backorder"}],label:"Inventory status"}),s.jsxs("div",{className:"cedros-admin__field",children:[s.jsx("label",{className:"cedros-admin__field-label",children:"Inventory quantity (tracked)"}),s.jsx("input",{type:"number",className:"cedros-admin__input",value:b.inventoryQuantity,onChange:A=>j(N=>({...N,inventoryQuantity:A.target.value===""?"":parseInt(A.target.value)||0})),placeholder:"Leave blank for untracked",min:"0"})]}),s.jsxs("div",{className:"cedros-admin__field",children:[s.jsx("label",{className:"cedros-admin__field-label",children:"Compare-at price (USD)"}),s.jsx("input",{type:"number",className:"cedros-admin__input",value:b.compareAtUsd===""?"":b.compareAtUsd,onChange:A=>j(N=>({...N,compareAtUsd:A.target.value===""?"":parseFloat(A.target.value)||0})),placeholder:"e.g., 78.00",min:"0",step:"0.01"})]})]}),s.jsx("div",{className:"cedros-admin__form-row",children:s.jsxs("div",{className:"cedros-admin__field",children:[s.jsx("label",{className:"cedros-admin__field-label",children:"Price (USD)"}),s.jsx("input",{type:"number",className:"cedros-admin__input",value:b.priceUsd===""?"":b.priceUsd,onChange:A=>j(N=>({...N,priceUsd:A.target.value===""?"":parseFloat(A.target.value)||0})),placeholder:"e.g., 5.00",min:"0",step:"0.01",required:!0})]})}),s.jsxs("div",{className:"cedros-admin__form-row",children:[s.jsxs("div",{className:"cedros-admin__field",children:[s.jsx("label",{className:"cedros-admin__field-label",children:"Tags (comma-separated)"}),s.jsx("input",{type:"text",className:"cedros-admin__input",value:b.tagsCsv,onChange:A=>j(N=>({...N,tagsCsv:A.target.value})),placeholder:"e.g., core, new, gift"})]}),s.jsxs("div",{className:"cedros-admin__field",children:[s.jsx("label",{className:"cedros-admin__field-label",children:"Category IDs (comma-separated)"}),s.jsx("input",{type:"text",className:"cedros-admin__input",value:b.categoryIdsCsv,onChange:A=>j(N=>({...N,categoryIdsCsv:A.target.value})),placeholder:"e.g., cat_apparel, cat_accessories"})]})]}),s.jsxs("div",{className:"cedros-admin__form-row",children:[s.jsx(Et,{value:b.checkoutEmail,onChange:A=>j(N=>({...N,checkoutEmail:A})),options:[{value:"none",label:"None"},{value:"optional",label:"Optional"},{value:"required",label:"Required"}],label:"Checkout: Email"}),s.jsx(Et,{value:b.checkoutName,onChange:A=>j(N=>({...N,checkoutName:A})),options:[{value:"none",label:"None"},{value:"optional",label:"Optional"},{value:"required",label:"Required"}],label:"Checkout: Name"}),s.jsx(Et,{value:b.checkoutPhone,onChange:A=>j(N=>({...N,checkoutPhone:A})),options:[{value:"none",label:"None"},{value:"optional",label:"Optional"},{value:"required",label:"Required"}],label:"Checkout: Phone"})]}),s.jsxs("div",{className:"cedros-admin__form-row",children:[b.fulfillmentType==="shipping"&&s.jsxs("div",{className:"cedros-admin__field",children:[s.jsx("label",{className:"cedros-admin__field-label",children:"Checkout: Shipping address"}),s.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[s.jsx("input",{type:"checkbox",checked:b.checkoutShippingAddress,onChange:A=>j(N=>({...N,checkoutShippingAddress:A.target.checked}))}),"Collect shipping address"]})]}),s.jsxs("div",{className:"cedros-admin__field",children:[s.jsx("label",{className:"cedros-admin__field-label",children:"Checkout: Billing address"}),s.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[s.jsx("input",{type:"checkbox",checked:b.checkoutBillingAddress,onChange:A=>j(N=>({...N,checkoutBillingAddress:A.target.checked}))}),"Collect billing address"]})]})]}),s.jsx("div",{className:"cedros-admin__form-row",children:s.jsxs("div",{className:"cedros-admin__field",children:[s.jsx("label",{className:"cedros-admin__field-label",children:"Fulfillment notes"}),s.jsx("input",{type:"text",className:"cedros-admin__input",value:b.fulfillmentNotes,onChange:A=>j(N=>({...N,fulfillmentNotes:A.target.value})),placeholder:b.fulfillmentType==="shipping"?"e.g., Ships within 3-5 business days":"e.g., Downloadable from your account after purchase"})]})}),b.fulfillmentType==="shipping"&&b.checkoutShippingAddress&&s.jsx("div",{className:"cedros-admin__form-row",children:s.jsxs("div",{className:"cedros-admin__field",children:[s.jsx("label",{className:"cedros-admin__field-label",children:"Shipping countries"}),s.jsx("input",{type:"text",className:"cedros-admin__input",value:b.shippingCountriesCsv,onChange:A=>j(N=>({...N,shippingCountriesCsv:A.target.value})),placeholder:"e.g., US,CA"}),s.jsx("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:"ISO 2-letter country codes, comma-separated. Required for shipping address collection."})]})}),s.jsx("div",{className:"cedros-admin__form-actions",children:s.jsx("button",{type:"submit",className:"cedros-admin__button cedros-admin__button--primary",disabled:f,children:f?"Creating...":"Create Product"})})]}),i?s.jsxs("div",{className:"cedros-admin__loading",children:[Y.loading," Loading products..."]}):s.jsx("div",{className:"cedros-admin__table-container",children:s.jsxs("table",{className:"cedros-admin__table",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{"aria-sort":p?.key==="id"?p?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>D("id"),children:["ID",H("id")]})}),s.jsx("th",{"aria-sort":p?.key==="product"?p?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>D("product"),children:["Product",H("product")]})}),s.jsx("th",{"aria-sort":p?.key==="type"?p?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>D("type"),children:["Type",H("type")]})}),s.jsx("th",{"aria-sort":p?.key==="price"?p?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>D("price"),children:["Price",H("price")]})}),s.jsx("th",{"aria-sort":p?.key==="status"?p?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>D("status"),children:["Status",H("status")]})}),s.jsx("th",{children:"Actions"})]})}),s.jsx("tbody",{children:z.map(A=>s.jsxs("tr",{children:[s.jsx("td",{children:s.jsx("code",{children:A.id})}),s.jsx("td",{children:s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[C(A)?s.jsx("img",{src:C(A),alt:"",style:{width:28,height:28,borderRadius:6,objectFit:"cover"}}):s.jsx("div",{style:{width:28,height:28,borderRadius:6,background:"rgba(0,0,0,0.06)"}}),s.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[s.jsx("span",{style:{fontWeight:600},children:I(A)}),s.jsx("span",{style:{opacity:.8},children:A.description})]})]})}),s.jsx("td",{children:M(A.metadata?.product_type)}),s.jsx("td",{children:F(A.fiatAmountCents)}),s.jsx("td",{children:s.jsx("span",{className:`cedros-admin__badge ${A.active?"cedros-admin__badge--success":"cedros-admin__badge--muted"}`,children:A.active?"Active":"Inactive"})}),s.jsx("td",{children:s.jsx("div",{style:{display:"flex",gap:"0.25rem"},children:s.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>x(A),children:"Variations"})})})]},A.id))})]})}),y&&s.jsx("div",{className:"cedros-admin__modal-overlay",onClick:()=>x(null),children:s.jsx("div",{className:"cedros-admin__modal cedros-admin__modal--lg",onClick:A=>A.stopPropagation(),children:s.jsx(Zf,{serverUrl:e,productId:y.id,productTitle:I(y),defaultPrice:y.fiatAmountCents/100,apiKey:t,authManager:r,onClose:()=>x(null)})})})]})}function Oc({serverUrl:e,apiKey:t,pageSize:n=20,authManager:r}){const[o,a]=k.useState([]),[i,c]=k.useState(null),[l,d]=k.useState(!0),[f,u]=k.useState(!0),[h,g]=k.useState(null),[y,x]=k.useState(""),[p,v]=k.useState(null),_=k.useCallback(async()=>{u(!0);try{g(null);let C;if(r?.isAuthenticated())C=await r.fetchWithAuth("/admin/stats");else{const E={"Content-Type":"application/json"};t&&(E["X-API-Key"]=t);const O=await fetch(`${e}/admin/stats`,{headers:E});if(!O.ok)throw new Error(`Failed to fetch stats: ${O.status}`);C=await O.json()}c(C)}catch{c(null),g("Failed to load payment stats")}finally{u(!1)}},[e,t,r]);k.useEffect(()=>{_()},[_]);const w=k.useCallback(async()=>{try{g(null);let C;const E=new URLSearchParams({limit:n.toString()});y&&E.set("method",y);const O=`/admin/transactions?${E}`;if(r?.isAuthenticated())C=await r.fetchWithAuth(O);else{const F={"Content-Type":"application/json"};t&&(F["X-API-Key"]=t);const M=await fetch(`${e}${O}`,{headers:F});if(!M.ok)throw new Error(`Failed to fetch transactions: ${M.status}`);C=await M.json()}a(C.transactions||[])}catch{a([]),g("Failed to load transactions")}finally{d(!1)}},[e,t,n,y,r]);k.useEffect(()=>{w()},[w]);const b=(C,E="USD")=>new Intl.NumberFormat("en-US",{style:"currency",currency:E}).format(C),j=C=>{v(E=>!E||E.key!==C?{key:C,direction:"asc"}:{key:C,direction:E.direction==="asc"?"desc":"asc"})},R=C=>!p||p.key!==C?s.jsx("span",{className:"cedros-admin__sort-icon cedros-admin__sort-icon--idle",children:Y.chevronUp}):s.jsx("span",{className:"cedros-admin__sort-icon",children:p.direction==="asc"?Y.chevronUp:Y.chevronDown}),I=k.useMemo(()=>{if(!p)return o;const C=p.direction==="asc"?1:-1,E=O=>{switch(p.key){case"resource":return O.resourceId;case"method":return O.method;case"amount":return O.amount;case"status":return O.status;case"date":return new Date(O.paidAt).getTime();case"id":default:return O.id}};return[...o].sort((O,F)=>{const M=E(O),U=E(F);return typeof M=="number"&&typeof U=="number"?(M-U)*C:String(M).localeCompare(String(U),void 0,{sensitivity:"base"})*C})},[o,p]);return s.jsxs("div",{className:"cedros-admin__page",children:[s.jsx(jr,{message:h,onRetry:()=>{_(),w()}}),s.jsx(Sr,{stats:[{label:"Revenue",value:b(i?.totalRevenue??0)},{label:"Orders",value:i?.totalTransactions??0},{label:"Card",value:b(i?.revenueByMethod.stripe??0),description:`${i?.transactionsByMethod.stripe??0} orders`},{label:"Crypto",value:b(i?.revenueByMethod.x402??0),description:`${i?.transactionsByMethod.x402??0} orders`},{label:"Credits",value:b(i?.revenueByMethod.credits??0),description:`${i?.transactionsByMethod.credits??0} orders`}],isLoading:f,onRefresh:_}),s.jsxs("div",{className:"cedros-admin__section-header",children:[s.jsx("h3",{className:"cedros-admin__section-title",children:"Transaction History"}),s.jsx(Pc,{value:y,onChange:x,options:[{value:"",label:"All"},{value:"stripe",label:"Card"},{value:"x402",label:"Crypto"},{value:"credits",label:"Credits"}]})]}),l?s.jsxs("div",{className:"cedros-admin__loading",children:[Y.loading," Loading transactions..."]}):s.jsx("div",{className:"cedros-admin__table-container",children:s.jsxs("table",{className:"cedros-admin__table",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{"aria-sort":p?.key==="id"?p?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>j("id"),children:["ID",R("id")]})}),s.jsx("th",{"aria-sort":p?.key==="resource"?p?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>j("resource"),children:["Resource",R("resource")]})}),s.jsx("th",{"aria-sort":p?.key==="method"?p?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>j("method"),children:["Method",R("method")]})}),s.jsx("th",{"aria-sort":p?.key==="amount"?p?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>j("amount"),children:["Amount",R("amount")]})}),s.jsx("th",{"aria-sort":p?.key==="status"?p?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>j("status"),children:["Status",R("status")]})}),s.jsx("th",{"aria-sort":p?.key==="date"?p?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>j("date"),children:["Date",R("date")]})})]})}),s.jsx("tbody",{children:I.map(C=>s.jsxs("tr",{children:[s.jsx("td",{children:s.jsx("code",{children:C.id})}),s.jsx("td",{children:C.resourceId}),s.jsx("td",{children:s.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${C.method}`,children:C.method})}),s.jsxs("td",{children:["$",C.amount.toFixed(2)," ",C.currency.toUpperCase()]}),s.jsx("td",{children:s.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${C.status}`,children:C.status})}),s.jsx("td",{children:lr(C.paidAt)})]},C.id))})]})})]})}function Mc({serverUrl:e,apiKey:t,pageSize:n=20,authManager:r}){const[o,a]=k.useState([]),[i,c]=k.useState(!0),[l,d]=k.useState(!1),[f,u]=k.useState(!1),[h,g]=k.useState(null),[y,x]=k.useState(null),[p,v]=k.useState({code:"",discountType:"percentage",discountValue:0,usageLimit:void 0,expiresAt:"",scope:"all_products",productIdsCsv:"",categoryIdsCsv:"",paymentMethod:"any",autoApply:!1,appliesAt:"both",startsAt:"",minimumAmountUsd:"",usageLimitPerCustomer:void 0,firstPurchaseOnly:!1}),_=k.useCallback(async()=>{try{x(null);let E;const O=`/admin/coupons?limit=${n}`;if(r?.isAuthenticated())E=await r.fetchWithAuth(O);else{const F={"Content-Type":"application/json"};t&&(F["X-API-Key"]=t);const M=await fetch(`${e}${O}`,{headers:F});if(!M.ok)throw new Error(`Failed to fetch coupons: ${M.status}`);E=await M.json()}a(E.coupons||[])}catch(E){Je.getLogger().error("[CouponsSection] Failed to fetch coupons:",E,{serverUrl:e.slice(0,20)+"...",hasApiKey:!!t}),a([]),x("Failed to load coupons")}finally{c(!1)}},[e,t,n,r]);k.useEffect(()=>{_()},[_]);const w=async E=>{if(E.preventDefault(),!(!p.code||p.discountValue<=0)){u(!0);try{const O=p.minimumAmountUsd?Math.round(Number(p.minimumAmountUsd)*100):void 0,F=p.productIdsCsv.split(",").map(D=>D.trim()).filter(Boolean),M=p.categoryIdsCsv.split(",").map(D=>D.trim()).filter(Boolean),U={code:p.code,discountType:p.discountType,discountValue:p.discountValue,usageLimit:p.usageLimit,active:!0,usageCount:0,scope:p.scope,...F.length?{productIds:F}:{},...M.length?{categoryIds:M}:{},...p.paymentMethod!=="any"?{paymentMethod:p.paymentMethod}:{},...p.autoApply?{autoApply:!0}:{},...p.appliesAt!=="both"?{appliesAt:p.appliesAt}:{},...p.startsAt?{startsAt:p.startsAt}:{},...p.expiresAt?{expiresAt:p.expiresAt}:{},...O?{minimumAmountCents:O}:{},...p.usageLimitPerCustomer?{usageLimitPerCustomer:p.usageLimitPerCustomer}:{},...p.firstPurchaseOnly?{firstPurchaseOnly:!0}:{}};if(r?.isAuthenticated())await r.fetchWithAuth("/admin/coupons",{method:"POST",body:JSON.stringify(U)});else{const D={"Content-Type":"application/json"};t&&(D["X-API-Key"]=t);const H=await fetch(`${e}/admin/coupons`,{method:"POST",headers:D,body:JSON.stringify(U)});if(!H.ok)throw new Error(`Failed to create coupon: ${H.status}`)}v({code:"",discountType:"percentage",discountValue:0,usageLimit:void 0,expiresAt:"",scope:"all_products",productIdsCsv:"",categoryIdsCsv:"",paymentMethod:"any",autoApply:!1,appliesAt:"both",startsAt:"",minimumAmountUsd:"",usageLimitPerCustomer:void 0,firstPurchaseOnly:!1}),d(!1),_()}catch(O){Je.getLogger().error("[CouponsSection] Failed to add coupon:",O,{serverUrl:e.slice(0,20)+"...",hasApiKey:!!t}),x("Failed to create coupon")}finally{u(!1)}}},b=o.filter(E=>E.active).length,j=o.reduce((E,O)=>E+(O.usageCount??0),0),R=E=>{g(O=>!O||O.key!==E?{key:E,direction:"asc"}:{key:E,direction:O.direction==="asc"?"desc":"asc"})},I=E=>!h||h.key!==E?s.jsx("span",{className:"cedros-admin__sort-icon cedros-admin__sort-icon--idle",children:Y.chevronUp}):s.jsx("span",{className:"cedros-admin__sort-icon",children:h.direction==="asc"?Y.chevronUp:Y.chevronDown}),C=k.useMemo(()=>{if(!h)return o;const E=h.direction==="asc"?1:-1,O=F=>{switch(h.key){case"discount":return F.discountValue??0;case"usage":return F.usageCount??0;case"status":return F.active?1:0;case"code":default:return F.code}};return[...o].sort((F,M)=>{const U=O(F),D=O(M);return typeof U=="number"&&typeof D=="number"?(U-D)*E:String(U).localeCompare(String(D),void 0,{sensitivity:"base"})*E})},[o,h]);return s.jsxs("div",{className:"cedros-admin__page",children:[s.jsx(jr,{message:y,onRetry:_}),s.jsx(Sr,{stats:[{label:"Total Coupons",value:o.length},{label:"Active",value:b,variant:b>0?"success":"muted"},{label:"Redemptions",value:j}],isLoading:i}),s.jsxs("div",{className:"cedros-admin__section-header",children:[s.jsx("h3",{className:"cedros-admin__section-title",children:"Discount Coupons"}),s.jsxs("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--action",onClick:()=>d(!l),children:[l?Y.close:Y.plus,l?"Cancel":"Add Coupon"]})]}),l&&s.jsxs("form",{onSubmit:w,className:"cedros-admin__add-form",children:[s.jsxs("div",{className:"cedros-admin__form-row",children:[s.jsxs("div",{className:"cedros-admin__field",children:[s.jsx("label",{className:"cedros-admin__field-label",children:"Coupon Code"}),s.jsx("input",{type:"text",className:"cedros-admin__input",value:p.code,onChange:E=>v(O=>({...O,code:E.target.value.toUpperCase()})),placeholder:"e.g., SAVE20",required:!0})]}),s.jsx(Et,{value:p.discountType,onChange:E=>v(O=>({...O,discountType:E})),options:[{value:"percentage",label:"Percentage (%)"},{value:"fixed",label:"Fixed Amount ($)"}],label:"Discount Type"})]}),s.jsxs("div",{className:"cedros-admin__form-row",children:[s.jsxs("div",{className:"cedros-admin__field",children:[s.jsxs("label",{className:"cedros-admin__field-label",children:["Discount Value ",p.discountType==="percentage"?"(%)":"($)"]}),s.jsx("input",{type:"number",className:"cedros-admin__input",value:p.discountValue||"",onChange:E=>v(O=>({...O,discountValue:parseFloat(E.target.value)||0})),placeholder:p.discountType==="percentage"?"e.g., 20":"e.g., 10.00",min:"0",step:p.discountType==="percentage"?"1":"0.01",required:!0})]}),s.jsxs("div",{className:"cedros-admin__field",children:[s.jsx("label",{className:"cedros-admin__field-label",children:"Usage Limit (optional)"}),s.jsx("input",{type:"number",className:"cedros-admin__input",value:p.usageLimit||"",onChange:E=>v(O=>({...O,usageLimit:E.target.value?parseInt(E.target.value):void 0})),placeholder:"Leave empty for unlimited",min:"1"})]}),s.jsxs("div",{className:"cedros-admin__field",children:[s.jsx("label",{className:"cedros-admin__field-label",children:"Expiration Date (optional)"}),s.jsx("input",{type:"date",className:"cedros-admin__input",value:p.expiresAt,onChange:E=>v(O=>({...O,expiresAt:E.target.value}))})]})]}),s.jsxs("div",{className:"cedros-admin__form-row",children:[s.jsx(Et,{value:p.scope,onChange:E=>v(O=>({...O,scope:E})),options:[{value:"all_products",label:"All Products"},{value:"specific_products",label:"Specific Products"},{value:"specific_categories",label:"Specific Categories"}],label:"Scope"}),s.jsx(Et,{value:p.paymentMethod,onChange:E=>v(O=>({...O,paymentMethod:E})),options:[{value:"any",label:"Any Payment Method"},{value:"stripe",label:"Stripe (Card) Only"},{value:"x402",label:"Crypto (x402) Only"},{value:"credits",label:"Credits Only"}],label:"Payment Method"}),s.jsx(Et,{value:p.appliesAt,onChange:E=>v(O=>({...O,appliesAt:E})),options:[{value:"both",label:"Cart & Checkout"},{value:"cart",label:"Cart Only"},{value:"checkout",label:"Checkout Only"}],label:"Applies At"})]}),p.scope==="specific_products"&&s.jsx("div",{className:"cedros-admin__form-row",children:s.jsxs("div",{className:"cedros-admin__field",style:{flex:1},children:[s.jsx("label",{className:"cedros-admin__field-label",children:"Product IDs"}),s.jsx("input",{type:"text",className:"cedros-admin__input",value:p.productIdsCsv,onChange:E=>v(O=>({...O,productIdsCsv:E.target.value})),placeholder:"e.g., prod_123, prod_456"}),s.jsx("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:"Comma-separated product IDs this coupon applies to."})]})}),s.jsxs("div",{className:"cedros-admin__form-row",children:[s.jsxs("div",{className:"cedros-admin__field",children:[s.jsx("label",{className:"cedros-admin__field-label",children:"Start Date (optional)"}),s.jsx("input",{type:"date",className:"cedros-admin__input",value:p.startsAt,onChange:E=>v(O=>({...O,startsAt:E.target.value}))})]}),s.jsxs("div",{className:"cedros-admin__field",children:[s.jsx("label",{className:"cedros-admin__field-label",children:"Auto Apply"}),s.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[s.jsx("input",{type:"checkbox",checked:p.autoApply,onChange:E=>v(O=>({...O,autoApply:E.target.checked}))}),"Automatically apply when conditions met"]})]})]}),s.jsxs("div",{className:"cedros-admin__form-row",children:[s.jsxs("div",{className:"cedros-admin__field",children:[s.jsx("label",{className:"cedros-admin__field-label",children:"Minimum Purchase (USD)"}),s.jsx("input",{type:"number",className:"cedros-admin__input",value:p.minimumAmountUsd===""?"":p.minimumAmountUsd,onChange:E=>v(O=>({...O,minimumAmountUsd:E.target.value===""?"":parseFloat(E.target.value)||0})),placeholder:"e.g., 50.00",min:"0",step:"0.01"})]}),s.jsxs("div",{className:"cedros-admin__field",children:[s.jsx("label",{className:"cedros-admin__field-label",children:"Per-Customer Limit"}),s.jsx("input",{type:"number",className:"cedros-admin__input",value:p.usageLimitPerCustomer||"",onChange:E=>v(O=>({...O,usageLimitPerCustomer:E.target.value?parseInt(E.target.value):void 0})),placeholder:"Leave empty for unlimited",min:"1"})]}),s.jsxs("div",{className:"cedros-admin__field",children:[s.jsx("label",{className:"cedros-admin__field-label",children:"First Purchase Only"}),s.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[s.jsx("input",{type:"checkbox",checked:p.firstPurchaseOnly,onChange:E=>v(O=>({...O,firstPurchaseOnly:E.target.checked}))}),"New customers only"]})]})]}),p.scope==="specific_categories"&&s.jsx("div",{className:"cedros-admin__form-row",children:s.jsxs("div",{className:"cedros-admin__field",style:{flex:1},children:[s.jsx("label",{className:"cedros-admin__field-label",children:"Category IDs"}),s.jsx("input",{type:"text",className:"cedros-admin__input",value:p.categoryIdsCsv,onChange:E=>v(O=>({...O,categoryIdsCsv:E.target.value})),placeholder:"e.g., cat_apparel, cat_accessories"}),s.jsx("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:"Comma-separated category IDs this coupon applies to."})]})}),s.jsx("div",{className:"cedros-admin__form-actions",children:s.jsx("button",{type:"submit",className:"cedros-admin__button cedros-admin__button--primary",disabled:f,children:f?"Creating...":"Create Coupon"})})]}),i?s.jsxs("div",{className:"cedros-admin__loading",children:[Y.loading," Loading coupons..."]}):s.jsx("div",{className:"cedros-admin__table-container",children:s.jsxs("table",{className:"cedros-admin__table",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{"aria-sort":h?.key==="code"?h?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>R("code"),children:["Code",I("code")]})}),s.jsx("th",{"aria-sort":h?.key==="discount"?h?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>R("discount"),children:["Discount",I("discount")]})}),s.jsx("th",{"aria-sort":h?.key==="usage"?h?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>R("usage"),children:["Usage",I("usage")]})}),s.jsx("th",{"aria-sort":h?.key==="status"?h?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>R("status"),children:["Status",I("status")]})}),s.jsx("th",{children:"Actions"})]})}),s.jsx("tbody",{children:C.map(E=>s.jsxs("tr",{children:[s.jsx("td",{children:s.jsx("code",{children:E.code})}),s.jsx("td",{children:E.discountType==="percentage"?`${E.discountValue}%`:`$${E.discountValue.toFixed(2)}`}),s.jsxs("td",{children:[E.usageCount,E.usageLimit?` / ${E.usageLimit}`:""]}),s.jsx("td",{children:s.jsx("span",{className:`cedros-admin__badge ${E.active?"cedros-admin__badge--success":"cedros-admin__badge--muted"}`,children:E.active?"Active":"Inactive"})}),s.jsx("td",{children:s.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",children:"Edit"})})]},E.code))})]})})]})}function Lc({serverUrl:e,apiKey:t,pageSize:n=20,authManager:r}){const[o,a]=k.useState([]),[i,c]=k.useState(!0),[l,d]=k.useState(null),[f,u]=k.useState([]),[h,g]=k.useState(!0),[y,x]=k.useState(null),[p,v]=k.useState(null),[_,w]=k.useState([]),[b,j]=k.useState(!0),[R,I]=k.useState(null),[C,E]=k.useState(null),[O,F]=k.useState(null),[M,U]=k.useState(""),[D,H]=k.useState(null),z=k.useCallback(async()=>{try{let T;const K=`/admin/refunds?limit=${n}`;if(r?.isAuthenticated())T=await r.fetchWithAuth(K);else{const se={"Content-Type":"application/json"};t&&(se["X-API-Key"]=t);const ve=await fetch(`${e}${K}`,{headers:se});if(!ve.ok)throw new Error(`Failed to fetch x402 refunds: ${ve.status}`);T=await ve.json()}a(T.refunds||[])}catch(T){Je.getLogger().error("[RefundsSection] Failed to fetch x402 refunds:",T,{serverUrl:e.slice(0,20)+"...",hasApiKey:!!t}),a([]),H("Failed to load x402 refunds")}finally{c(!1)}},[e,t,n,r]);k.useEffect(()=>{z()},[z]);const A=k.useCallback(async()=>{try{let T;const K=`/admin/credits/refund-requests?status=pending&limit=${n}&offset=0`;if(r?.isAuthenticated())T=await r.fetchWithAuth(K);else{const ve={"Content-Type":"application/json"};t&&(ve["X-API-Key"]=t);const ye=await fetch(`${e}${K}`,{headers:ve});if(!ye.ok)throw new Error(`Failed to fetch credits refund requests: ${ye.status}`);T=await ye.json()}const se=Array.isArray(T)?T:"refundRequests"in T?T.refundRequests:T.requests||[];u(se)}catch(T){Je.getLogger().error("[RefundsSection] Failed to fetch credits refunds:",T,{serverUrl:e.slice(0,20)+"...",hasApiKey:!!t}),u([]),H("Failed to load credits refunds")}finally{g(!1)}},[e,t,n,r]);k.useEffect(()=>{A()},[A]);const N=async T=>{x(T.id);try{const K=`/admin/credits/refund-requests/${T.id}/process`,se=JSON.stringify({amountLamports:T.amountLamports,reason:T.reason});if(r?.isAuthenticated())await r.fetchWithAuth(K,{method:"POST",body:se});else{const ve={"Content-Type":"application/json"};t&&(ve["X-API-Key"]=t);const ye=await fetch(`${e}${K}`,{method:"POST",headers:ve,body:se});if(!ye.ok)throw new Error(`Failed to process credits refund: ${ye.status}`)}await A()}catch(K){Je.getLogger().error("[RefundsSection] Failed to process credits refund:",K,{serverUrl:e.slice(0,20)+"...",hasApiKey:!!t,requestId:T.id}),H("Failed to process credits refund")}finally{x(null)}},Z=T=>{U(T.reason??""),F(T)},te=()=>{F(null),U("")},re=async()=>{if(!O)return;const T=O,K=M;te(),x(T.id);try{const se=`/admin/credits/refund-requests/${T.id}/reject`,ve=JSON.stringify({reason:K});if(r?.isAuthenticated())await r.fetchWithAuth(se,{method:"POST",body:ve});else{const ye={"Content-Type":"application/json"};t&&(ye["X-API-Key"]=t);const Pe=await fetch(`${e}${se}`,{method:"POST",headers:ye,body:ve});if(!Pe.ok)throw new Error(`Failed to reject credits refund: ${Pe.status}`)}await A()}catch(se){Je.getLogger().error("[RefundsSection] Failed to reject credits refund:",se,{serverUrl:e.slice(0,20)+"...",hasApiKey:!!t,requestId:T.id}),H("Failed to reject credits refund")}finally{x(null)}},de=k.useCallback(async()=>{try{let T;const K=`/admin/stripe/refunds?limit=${n}`;if(r?.isAuthenticated())T=await r.fetchWithAuth(K);else{const se={"Content-Type":"application/json"};t&&(se["X-API-Key"]=t);const ve=await fetch(`${e}${K}`,{headers:se});if(!ve.ok)throw new Error(`Failed to fetch Stripe refunds: ${ve.status}`);T=await ve.json()}w(T.refunds||[])}catch(T){Je.getLogger().error("[RefundsSection] Failed to fetch Stripe refunds:",T,{serverUrl:e.slice(0,20)+"...",hasApiKey:!!t}),w([]),H("Failed to load Stripe refunds")}finally{j(!1)}},[e,t,n,r]);k.useEffect(()=>{de()},[de]);const W=async T=>{I(T);try{const K=`/admin/stripe/refunds/${T}/process`;if(r?.isAuthenticated())await r.fetchWithAuth(K,{method:"POST"});else{const se={"Content-Type":"application/json"};t&&(se["X-API-Key"]=t);const ve=await fetch(`${e}${K}`,{method:"POST",headers:se});if(!ve.ok)throw new Error(`Failed to process refund: ${ve.status}`)}await de()}catch(K){Je.getLogger().error("[RefundsSection] Failed to process Stripe refund:",K,{serverUrl:e.slice(0,20)+"...",hasApiKey:!!t,refundId:T}),H("Failed to process Stripe refund")}finally{I(null)}},Q=(T,K)=>new Intl.NumberFormat("en-US",{style:"currency",currency:K}).format(T/100),q=T=>T?T.replace(/_/g," ").replace(/\b\w/g,K=>K.toUpperCase()):"—",he=T=>{switch(T){case"processed":return"success";case"pending":return"pending";case"rejected":default:return"muted"}},P=(T,K)=>K?K.toLowerCase()==="usd"?`${new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(T/1e6)} (USD credits)`:`${T.toLocaleString()} ${K.toUpperCase()} (atomic)`:`${T.toLocaleString()} (atomic)`,G=T=>{switch(T){case"succeeded":return"success";case"failed":return"failed";case"pending":case"requires_action":return"pending";case"canceled":default:return"muted"}},ue=T=>T.stripeRefundId??"—",B=T=>T.chargeId??"—",ae=_.filter(T=>T.status==="pending"||T.status==="requires_action").length,ce=f.filter(T=>T.status==="pending").length,we=o.filter(T=>T.status==="pending").length,Te=ae+ce+we,Ve=_.filter(T=>T.status==="succeeded").reduce((T,K)=>T+K.amount,0),Ge=f.filter(T=>T.status==="processed").reduce((T,K)=>T+K.amountLamports,0),We=o.filter(T=>T.status==="completed").reduce((T,K)=>T+K.amount,0),_t=Ve/100+Ge/1e6+We,Ye=T=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(T),en=b||h||i,xt=T=>{E(K=>!K||K.key!==T?{key:T,direction:"asc"}:{key:T,direction:K.direction==="asc"?"desc":"asc"})},je=T=>{v(K=>!K||K.key!==T?{key:T,direction:"asc"}:{key:T,direction:K.direction==="asc"?"desc":"asc"})},Xe=T=>{d(K=>!K||K.key!==T?{key:T,direction:"asc"}:{key:T,direction:K.direction==="asc"?"desc":"asc"})},_e=(T,K)=>!T||!K?s.jsx("span",{className:"cedros-admin__sort-icon cedros-admin__sort-icon--idle",children:Y.chevronUp}):s.jsx("span",{className:"cedros-admin__sort-icon",children:K==="asc"?Y.chevronUp:Y.chevronDown}),qt=k.useMemo(()=>{if(!C)return _;const T=C.direction==="asc"?1:-1,K=se=>{switch(C.key){case"stripe":return se.stripeRefundId??"";case"charge":return se.chargeId??"";case"amount":return se.amount??0;case"reason":return se.reason??"";case"status":return se.status??"";case"date":return new Date(se.createdAt).getTime();case"id":default:return se.id}};return[..._].sort((se,ve)=>{const ye=K(se),Pe=K(ve);return typeof ye=="number"&&typeof Pe=="number"?(ye-Pe)*T:String(ye).localeCompare(String(Pe),void 0,{sensitivity:"base"})*T})},[_,C]),ft=k.useMemo(()=>{if(!p)return f;const T=p.direction==="asc"?1:-1,K=se=>{switch(p.key){case"original":return se.originalTransactionId??"";case"user":return se.userId??"";case"amount":return se.amountLamports??0;case"reason":return se.reason??"";case"status":return se.status??"";case"date":return new Date(se.createdAt).getTime();case"id":default:return se.id}};return[...f].sort((se,ve)=>{const ye=K(se),Pe=K(ve);return typeof ye=="number"&&typeof Pe=="number"?(ye-Pe)*T:String(ye).localeCompare(String(Pe),void 0,{sensitivity:"base"})*T})},[f,p]),it=k.useMemo(()=>{if(!l)return o;const T=l.direction==="asc"?1:-1,K=se=>{switch(l.key){case"transaction":return se.transactionId??"";case"amount":return se.amount??0;case"reason":return se.reason??"";case"status":return se.status??"";case"date":return new Date(se.createdAt).getTime();case"id":default:return se.id}};return[...o].sort((se,ve)=>{const ye=K(se),Pe=K(ve);return typeof ye=="number"&&typeof Pe=="number"?(ye-Pe)*T:String(ye).localeCompare(String(Pe),void 0,{sensitivity:"base"})*T})},[o,l]);return s.jsxs("div",{className:"cedros-admin__page",children:[s.jsx(jr,{message:D,onRetry:()=>{z(),A(),de()}}),s.jsx(Sr,{stats:[{label:"Pending",value:Te,variant:Te>0?"warning":"muted"},{label:"Card Pending",value:ae,description:"Stripe"},{label:"Credits Pending",value:ce},{label:"Crypto Pending",value:we,description:"x402"},{label:"Total Refunded",value:Ye(_t),variant:"success"}],isLoading:en}),s.jsx("div",{className:"cedros-admin__section-header",children:s.jsx("h3",{className:"cedros-admin__section-title",children:"Stripe Refund Requests"})}),b?s.jsxs("div",{className:"cedros-admin__loading",children:[Y.loading," Loading Stripe refunds..."]}):_.length===0?s.jsx("div",{className:"cedros-admin__empty",children:"No Stripe refund requests found."}):s.jsx("div",{className:"cedros-admin__table-container",children:s.jsxs("table",{className:"cedros-admin__table",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{"aria-sort":C?.key==="id"?C?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>xt("id"),children:["Request ID",_e(C?.key==="id",C?.direction)]})}),s.jsx("th",{"aria-sort":C?.key==="stripe"?C?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>xt("stripe"),children:["Stripe Refund ID",_e(C?.key==="stripe",C?.direction)]})}),s.jsx("th",{"aria-sort":C?.key==="charge"?C?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>xt("charge"),children:["Charge",_e(C?.key==="charge",C?.direction)]})}),s.jsx("th",{"aria-sort":C?.key==="amount"?C?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>xt("amount"),children:["Amount",_e(C?.key==="amount",C?.direction)]})}),s.jsx("th",{"aria-sort":C?.key==="reason"?C?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>xt("reason"),children:["Reason",_e(C?.key==="reason",C?.direction)]})}),s.jsx("th",{"aria-sort":C?.key==="status"?C?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>xt("status"),children:["Status",_e(C?.key==="status",C?.direction)]})}),s.jsx("th",{"aria-sort":C?.key==="date"?C?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>xt("date"),children:["Date",_e(C?.key==="date",C?.direction)]})}),s.jsx("th",{children:"Actions"})]})}),s.jsx("tbody",{children:qt.map(T=>s.jsxs("tr",{children:[s.jsx("td",{children:s.jsx("code",{children:T.id})}),s.jsx("td",{children:s.jsx("code",{children:ue(T)})}),s.jsx("td",{children:s.jsx("code",{children:B(T)})}),s.jsx("td",{children:Q(T.amount,T.currency)}),s.jsx("td",{children:q(T.reason)}),s.jsx("td",{children:s.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${G(T.status)}`,children:T.status})}),s.jsx("td",{children:lr(T.createdAt)}),s.jsx("td",{children:(T.status==="pending"||T.status==="requires_action")&&s.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--sm",onClick:()=>W(T.id),disabled:R===T.id,children:R===T.id?"Processing...":"Process"})})]},T.id))})]})}),s.jsx("div",{className:"cedros-admin__section-header",style:{marginTop:"2rem"},children:s.jsx("h3",{className:"cedros-admin__section-title",children:"Credits Refund Requests"})}),h?s.jsxs("div",{className:"cedros-admin__loading",children:[Y.loading," Loading credits refunds..."]}):f.length===0?s.jsx("div",{className:"cedros-admin__empty",children:"No credits refund requests found."}):s.jsx("div",{className:"cedros-admin__table-container",children:s.jsxs("table",{className:"cedros-admin__table",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{"aria-sort":p?.key==="id"?p?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>je("id"),children:["Request ID",_e(p?.key==="id",p?.direction)]})}),s.jsx("th",{"aria-sort":p?.key==="original"?p?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>je("original"),children:["Original Tx",_e(p?.key==="original",p?.direction)]})}),s.jsx("th",{"aria-sort":p?.key==="user"?p?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>je("user"),children:["User",_e(p?.key==="user",p?.direction)]})}),s.jsx("th",{"aria-sort":p?.key==="amount"?p?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>je("amount"),children:["Amount",_e(p?.key==="amount",p?.direction)]})}),s.jsx("th",{"aria-sort":p?.key==="reason"?p?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>je("reason"),children:["Reason",_e(p?.key==="reason",p?.direction)]})}),s.jsx("th",{"aria-sort":p?.key==="status"?p?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>je("status"),children:["Status",_e(p?.key==="status",p?.direction)]})}),s.jsx("th",{"aria-sort":p?.key==="date"?p?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>je("date"),children:["Date",_e(p?.key==="date",p?.direction)]})}),s.jsx("th",{children:"Actions"})]})}),s.jsx("tbody",{children:ft.map(T=>s.jsxs("tr",{children:[s.jsx("td",{children:s.jsx("code",{children:T.id})}),s.jsx("td",{children:s.jsx("code",{children:T.originalTransactionId})}),s.jsx("td",{children:s.jsx("code",{children:T.userId??"—"})}),s.jsx("td",{children:P(T.amountLamports,T.currency)}),s.jsx("td",{children:T.reason??"—"}),s.jsx("td",{children:s.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${he(T.status)}`,children:T.status})}),s.jsx("td",{children:lr(T.createdAt)}),s.jsx("td",{children:T.status==="pending"?s.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[s.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--sm",onClick:()=>N(T),disabled:y===T.id,children:y===T.id?"Processing...":"Process"}),s.jsx("button",{className:"cedros-admin__button cedros-admin__button--outline cedros-admin__button--danger cedros-admin__button--sm",onClick:()=>Z(T),disabled:y===T.id,children:"Reject"})]}):null})]},T.id))})]})}),s.jsx("div",{className:"cedros-admin__section-header",style:{marginTop:"2rem"},children:s.jsx("h3",{className:"cedros-admin__section-title",children:"x402 Refund Requests"})}),i?s.jsxs("div",{className:"cedros-admin__loading",children:[Y.loading," Loading x402 refunds..."]}):o.length===0?s.jsx("div",{className:"cedros-admin__empty",children:"No x402 refund requests found."}):s.jsx("div",{className:"cedros-admin__table-container",children:s.jsxs("table",{className:"cedros-admin__table",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{"aria-sort":l?.key==="id"?l?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>Xe("id"),children:["ID",_e(l?.key==="id",l?.direction)]})}),s.jsx("th",{"aria-sort":l?.key==="transaction"?l?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>Xe("transaction"),children:["Transaction",_e(l?.key==="transaction",l?.direction)]})}),s.jsx("th",{"aria-sort":l?.key==="amount"?l?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>Xe("amount"),children:["Amount",_e(l?.key==="amount",l?.direction)]})}),s.jsx("th",{"aria-sort":l?.key==="reason"?l?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>Xe("reason"),children:["Reason",_e(l?.key==="reason",l?.direction)]})}),s.jsx("th",{"aria-sort":l?.key==="status"?l?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>Xe("status"),children:["Status",_e(l?.key==="status",l?.direction)]})}),s.jsx("th",{"aria-sort":l?.key==="date"?l?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>Xe("date"),children:["Date",_e(l?.key==="date",l?.direction)]})}),s.jsx("th",{children:"Actions"})]})}),s.jsx("tbody",{children:it.map(T=>s.jsxs("tr",{children:[s.jsx("td",{children:s.jsx("code",{children:T.id})}),s.jsx("td",{children:s.jsx("code",{children:T.transactionId})}),s.jsxs("td",{children:["$",T.amount.toFixed(2)]}),s.jsx("td",{children:T.reason||"—"}),s.jsx("td",{children:s.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${T.status}`,children:T.status})}),s.jsx("td",{children:lr(T.createdAt)}),s.jsx("td",{})]},T.id))})]})}),O&&s.jsx("div",{className:"cedros-admin__modal-overlay",onClick:te,children:s.jsxs("div",{className:"cedros-admin__modal",onClick:T=>T.stopPropagation(),children:[s.jsxs("div",{className:"cedros-admin__modal-header",children:[s.jsx("h3",{className:"cedros-admin__modal-title",children:"Reject Refund Request"}),s.jsx("button",{type:"button",className:"cedros-admin__modal-close",onClick:te,"aria-label":"Close",children:Y.close})]}),s.jsxs("div",{className:"cedros-admin__modal-body",children:[s.jsxs("p",{style:{marginBottom:"1rem",color:"var(--admin-muted)"},children:["Rejecting refund request ",s.jsx("code",{children:O.id})," for ",P(O.amountLamports,O.currency),"."]}),s.jsxs("label",{className:"cedros-admin__form-field",children:[s.jsx("span",{className:"cedros-admin__form-label",children:"Reason (optional)"}),s.jsx("textarea",{className:"cedros-admin__input",value:M,onChange:T=>U(T.target.value),placeholder:"Enter rejection reason...",rows:3,style:{resize:"vertical"}})]})]}),s.jsxs("div",{className:"cedros-admin__modal-footer",children:[s.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--outline",onClick:te,children:"Cancel"}),s.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--danger",onClick:re,children:"Reject Refund"})]})]})})]})}const qf=k.lazy(()=>Promise.resolve().then(()=>require("./SettingsSection-DSlW47o4.js")).then(e=>({default:e.SettingsSection})));function Dc(e){return s.jsx(k.Suspense,{fallback:null,children:s.jsx(qf,{...e})})}class $c{serverUrl;walletSigner=null;jwtToken=null;isAdminUser=!1;constructor(t){this.serverUrl=t}getAuthMethod(){return this.walletSigner?.publicKey&&this.walletSigner.signMessage?"wallet":this.jwtToken&&this.isAdminUser?"cedros-login":"none"}isAuthenticated(){return this.getAuthMethod()!=="none"}setWalletSigner(t){this.walletSigner=t,Je.getLogger().debug("[AdminAuthManager] Wallet signer updated:",!!t?.publicKey)}setCedrosLoginAuth(t,n){this.jwtToken=t,this.isAdminUser=n??!1,Je.getLogger().debug("[AdminAuthManager] Cedros-login auth updated:",{hasToken:!!t,isAdmin:this.isAdminUser})}async createAuthHeaders(t){const n=this.getAuthMethod();if(n==="wallet")return this.createWalletAuthHeaders(t);if(n==="cedros-login")return this.createJwtAuthHeaders();throw new Error("No admin authentication configured. Connect a wallet or sign in as admin.")}async createWalletAuthHeaders(t){if(!this.walletSigner?.publicKey||!this.walletSigner.signMessage)throw new Error("Wallet not connected or does not support message signing");const n=await this.fetchNonce(t),r=new TextEncoder().encode(n.nonce_id),o=await this.walletSigner.signMessage(r),a=oi.bs58.encode(this.walletSigner.publicKey.toBytes()),i=oi.bs58.encode(o);return{"X-Signer":a,"X-Message":n.nonce_id,"X-Signature":i}}createJwtAuthHeaders(){if(!this.jwtToken)throw new Error("No JWT token available");return{Authorization:`Bearer ${this.jwtToken}`}}async fetchNonce(t){const n=`${this.serverUrl}/paywall/v1/nonce`;Je.getLogger().debug("[AdminAuthManager] Fetching nonce for purpose:",t);const r=await Je.fetchWithTimeout(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({purpose:t})});if(!r.ok){const o=await r.text();throw new Error(`Failed to fetch nonce: ${r.status} ${o}`)}return await r.json()}async fetchWithAuth(t,n={}){if(this.getAuthMethod()==="none")throw new Error("No admin authentication configured");const o=this.getPurposeFromPath(t,n.method||"GET"),a=await this.createAuthHeaders(o),i=(n.method||"GET").toUpperCase(),c={...i!=="GET"&&i!=="HEAD"?{"Content-Type":"application/json"}:{},...n.headers||{},...a},l=await Je.fetchWithTimeout(`${this.serverUrl}${t}`,{...n,headers:c});if(!l.ok){let d=`Admin API error ${l.status}`;try{const f=await l.json();f&&typeof f.error=="string"?d=f.error:f&&typeof f.message=="string"&&(d=f.message)}catch{}throw new Error(d)}return await l.json()}getPurposeFromPath(t,n){const o={"/admin/stats":{GET:"admin_stats"},"/admin/products":{GET:"admin_products_list",POST:"admin_products_create"},"/admin/transactions":{GET:"admin_transactions_list"},"/admin/coupons":{GET:"admin_coupons_list",POST:"admin_coupons_create"},"/admin/refunds":{GET:"admin_refunds_list"},"/admin/config":{GET:"admin_config_list"}}[t];if(o?.[n])return o[n];if(t.startsWith("/admin/products/")){if(n==="PUT")return"admin_products_update";if(n==="DELETE")return"admin_products_delete"}if(t.startsWith("/admin/coupons/")){if(n==="PUT")return"admin_coupons_update";if(n==="DELETE")return"admin_coupons_delete"}if(t.startsWith("/admin/refunds/")&&t.includes("/process"))return"admin_refunds_process";if(t.startsWith("/admin/config/")){if(n==="GET")return"admin_config_get";if(n==="PUT")return"admin_config_update";if(n==="PATCH")return"admin_config_patch"}return`admin_${n.toLowerCase()}`}}const Gf={publicKey:null};function Yf({serverUrl:e,cedrosLoginToken:t,isAdmin:n=!1,wallet:r=Gf}){const o=k.useMemo(()=>{const u=new $c(e);return u.setCedrosLoginAuth(t??null,n),u},[e,t,n]);k.useEffect(()=>{r.publicKey&&r.signMessage?o.setWalletSigner({publicKey:r.publicKey,signMessage:r.signMessage}):o.setWalletSigner(null)},[o,r.publicKey,r.signMessage]);const a=o.getAuthMethod(),i=o.isAuthenticated(),c=!!(r.publicKey&&r.signMessage),l=!!t,d=k.useMemo(()=>{if(!r.publicKey)return null;const u=r.publicKey.toBase58();return`${u.slice(0,4)}...${u.slice(-4)}`},[r.publicKey]),f=k.useCallback((u,h)=>o.fetchWithAuth(u,h),[o]);return{authMethod:a,isAuthenticated:i,walletConnected:c,walletAddress:d,cedrosLoginAvailable:l,authManager:o,fetchWithAuth:f}}const Qf=k.lazy(()=>Promise.resolve().then(()=>require("./SubscriptionsSection-BboudRYv.js")).then(e=>({default:e.SubscriptionsSection}))),Kf=k.lazy(()=>Promise.resolve().then(()=>require("./StorefrontSection-DfN5yxkV.js")).then(e=>({default:e.StorefrontSection}))),Jf=k.lazy(()=>Promise.resolve().then(()=>require("./AISettingsSection-f5K0nUoQ.js")).then(e=>({default:e.AISettingsSection}))),Xf=k.lazy(()=>Promise.resolve().then(()=>require("./PaymentSettingsSection-BKDiep-C.js")).then(e=>({default:e.PaymentSettingsSection}))),em=k.lazy(()=>Promise.resolve().then(()=>require("./MessagingSection-CRFtSoE8.js")).then(e=>({default:e.MessagingSection}))),tm=k.lazy(()=>Promise.resolve().then(()=>require("./FAQSection-CVJ5w6cB.js")).then(e=>({default:e.FAQSection}))),zc=[{label:"Menu",sections:[{id:"transactions",label:"Transactions",icon:Y.transactions},{id:"products",label:"Products",icon:Y.products},{id:"subscriptions",label:"Subscriptions",icon:Y.calendarRepeat},{id:"coupons",label:"Coupons",icon:Y.coupons},{id:"refunds",label:"Refunds",icon:Y.refunds}]},{label:"Configuration",collapsible:!0,sections:[{id:"storefront",label:"Storefront",icon:Y.storefront},{id:"ai-settings",label:"Store AI",icon:Y.brain},{id:"faqs",label:"Knowledge Base",icon:Y.faq},{id:"payment-settings",label:"Payment Options",icon:Y.creditCard},{id:"messaging",label:"Store Messages",icon:Y.mail},{id:"settings",label:"Store Server",icon:Y.server}]}],nm=zc.flatMap(e=>e.sections);function rm(){const[e,t]=k.useState(()=>typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");return k.useEffect(()=>{const n=window.matchMedia("(prefers-color-scheme: dark)"),r=o=>t(o.matches?"dark":"light");return n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),e}function sm(e,t,n){return e!=="system"?e:t||n}function om({serverUrl:e,apiKey:t,title:n="Cedros Pay",sections:r=["transactions","products","subscriptions","coupons","refunds","storefront","ai-settings","faqs","payment-settings","messaging","settings"],defaultSection:o="transactions",refreshInterval:a=3e4,pageSize:i=20,onSectionChange:c,className:l="",cedrosLoginToken:d,isAdmin:f=!1,theme:u="system"}){const[h,g]=k.useState(o),[y]=k.useState(!1),[x,p]=k.useState(new Set),v=k.useCallback(M=>{p(U=>{const D=new Set(U);return D.has(M)?D.delete(M):D.add(M),D})},[]),_=Je.useCedrosThemeOptional(),w=rm(),j=sm(u,_?.mode??null,w)==="dark"?"cedros-admin--dark":"",R=$f.useWallet(),{authManager:I,isAuthenticated:C}=Yf({serverUrl:e,cedrosLoginToken:d,isAdmin:f,wallet:R}),E=k.useCallback(M=>{g(M),c?.(M)},[c]),F=nm.filter(M=>r.includes(M.id)).find(M=>M.id===h);return y?s.jsxs("div",{className:`cedros-admin cedros-admin--loading ${j} ${l}`,children:[Y.loading,s.jsx("span",{className:"cedros-admin__loading-text",children:"Loading dashboard..."})]}):C?s.jsxs("div",{className:`cedros-admin ${j} ${l}`,children:[s.jsxs("aside",{className:"cedros-admin__sidebar",children:[s.jsx("div",{className:"cedros-admin__sidebar-header",children:s.jsxs("div",{className:"cedros-admin__logo",children:[Y.wallet,s.jsx("span",{className:"cedros-admin__logo-text",children:n})]})}),s.jsx("nav",{className:"cedros-admin__nav",children:zc.map(M=>{const U=M.sections.filter(H=>r.includes(H.id));if(U.length===0)return null;const D=M.collapsible&&x.has(M.label);return s.jsxs("div",{className:"cedros-admin__nav-group",children:[M.collapsible?s.jsxs("button",{type:"button",className:"cedros-admin__nav-label cedros-admin__nav-label--collapsible",onClick:()=>v(M.label),"aria-expanded":!D,children:[M.label,s.jsx("span",{className:`cedros-admin__nav-label-icon ${D?"":"cedros-admin__nav-label-icon--expanded"}`,children:Y.chevronRight})]}):s.jsx("span",{className:"cedros-admin__nav-label",children:M.label}),!D&&U.map(H=>s.jsxs("button",{type:"button",className:`cedros-admin__nav-item ${h===H.id?"cedros-admin__nav-item--active":""}`,onClick:()=>E(H.id),"aria-current":h===H.id?"page":void 0,children:[s.jsx("span",{className:"cedros-admin__nav-icon",children:H.icon}),s.jsx("span",{className:"cedros-admin__nav-text",children:H.label})]},H.id))]},M.label)})})]}),s.jsxs("main",{className:"cedros-admin__main",children:[s.jsx("header",{className:"cedros-admin__header",children:s.jsxs("div",{className:"cedros-admin__breadcrumb",children:[s.jsx("span",{className:"cedros-admin__breadcrumb-root",children:n}),s.jsx("span",{className:"cedros-admin__breadcrumb-sep",children:Y.chevronRight}),s.jsx("span",{className:"cedros-admin__breadcrumb-current",children:F?.label})]})}),s.jsxs("div",{className:"cedros-admin__content",children:[h==="products"&&s.jsx(Rc,{serverUrl:e,apiKey:t,pageSize:i,authManager:I}),h==="subscriptions"&&s.jsx(k.Suspense,{fallback:s.jsx("div",{className:"cedros-admin__loading-text",children:"Loading section..."}),children:s.jsx(Qf,{serverUrl:e,apiKey:t,authManager:I})}),h==="transactions"&&s.jsx(Oc,{serverUrl:e,apiKey:t,pageSize:i,authManager:I}),h==="coupons"&&s.jsx(Mc,{serverUrl:e,apiKey:t,pageSize:i,authManager:I}),h==="refunds"&&s.jsx(Lc,{serverUrl:e,apiKey:t,pageSize:i,authManager:I}),h==="storefront"&&s.jsx(k.Suspense,{fallback:s.jsx("div",{className:"cedros-admin__loading-text",children:"Loading section..."}),children:s.jsx(Kf,{serverUrl:e,apiKey:t,authManager:I})}),h==="ai-settings"&&s.jsx(k.Suspense,{fallback:s.jsx("div",{className:"cedros-admin__loading-text",children:"Loading section..."}),children:s.jsx(Jf,{serverUrl:e,apiKey:t,authManager:I})}),h==="faqs"&&s.jsx(k.Suspense,{fallback:s.jsx("div",{className:"cedros-admin__loading-text",children:"Loading section..."}),children:s.jsx(tm,{serverUrl:e,apiKey:t,pageSize:i,authManager:I})}),h==="payment-settings"&&s.jsx(k.Suspense,{fallback:s.jsx("div",{className:"cedros-admin__loading-text",children:"Loading section..."}),children:s.jsx(Xf,{serverUrl:e,apiKey:t,authManager:I})}),h==="messaging"&&s.jsx(k.Suspense,{fallback:s.jsx("div",{className:"cedros-admin__loading-text",children:"Loading section..."}),children:s.jsx(em,{serverUrl:e,apiKey:t,authManager:I})}),h==="settings"&&s.jsx(Dc,{serverUrl:e,apiKey:t,authManager:I})]})]})]}):s.jsx("div",{className:`cedros-admin cedros-admin--unauthenticated ${j} ${l}`,children:s.jsx("p",{className:"cedros-admin__auth-prompt",children:"Please connect a wallet or sign in as admin to access the dashboard."})})}const kt=e=>k.lazy(async()=>{const r=(await e()).default;return{default:({pluginContext:a})=>{const c=zf.useCedrosLogin()?._internal?.getAccessToken()??a.getAccessToken(),l=k.useMemo(()=>{const f=new $c(a.serverUrl);return f.setCedrosLoginAuth(c??null,!!c),f},[a.serverUrl,c]),d={serverUrl:a.serverUrl,authManager:l};return s.jsx(r,{...d})}}}),am={id:"cedros-pay",name:"Cedros Pay",version:"1.0.0",sections:[{id:"transactions",label:"Transactions",icon:Y.transactions,group:"Store",order:0},{id:"products",label:"Products",icon:Y.products,group:"Store",order:1},{id:"subscriptions",label:"Subscriptions",icon:Y.subscriptions,group:"Store",order:2},{id:"coupons",label:"Coupons",icon:Y.coupons,group:"Store",order:3},{id:"refunds",label:"Refunds",icon:Y.refunds,group:"Store",order:4},{id:"storefront",label:"Storefront",icon:Y.storefront,group:"Configuration",order:10},{id:"ai-settings",label:"Store AI",icon:Y.ai,group:"Configuration",order:11},{id:"faqs",label:"Knowledge Base",icon:Y.faq,group:"Configuration",order:12},{id:"payment-settings",label:"Payment Options",icon:Y.wallet,group:"Configuration",order:13},{id:"messaging",label:"Store Messages",icon:Y.notifications,group:"Configuration",order:14},{id:"settings",label:"Store Server",icon:Y.settings,group:"Configuration",order:15}],groups:[{id:"Store",label:"Store",order:1},{id:"Configuration",label:"Configuration",order:2,defaultCollapsed:!0}],components:{products:kt(()=>Promise.resolve().then(()=>require("./sections-BCdzdqlG.js")).then(e=>({default:e.ProductsSection}))),subscriptions:kt(()=>Promise.resolve().then(()=>require("./SubscriptionsSection-BboudRYv.js")).then(e=>({default:e.SubscriptionsSection}))),transactions:kt(()=>Promise.resolve().then(()=>require("./sections-BCdzdqlG.js")).then(e=>({default:e.TransactionsSection}))),coupons:kt(()=>Promise.resolve().then(()=>require("./sections-BCdzdqlG.js")).then(e=>({default:e.CouponsSection}))),refunds:kt(()=>Promise.resolve().then(()=>require("./sections-BCdzdqlG.js")).then(e=>({default:e.RefundsSection}))),storefront:kt(()=>Promise.resolve().then(()=>require("./StorefrontSection-DfN5yxkV.js")).then(e=>({default:e.StorefrontSection}))),"ai-settings":kt(()=>Promise.resolve().then(()=>require("./AISettingsSection-f5K0nUoQ.js")).then(e=>({default:e.AISettingsSection}))),faqs:kt(()=>Promise.resolve().then(()=>require("./FAQSection-CVJ5w6cB.js")).then(e=>({default:e.FAQSection}))),"payment-settings":kt(()=>Promise.resolve().then(()=>require("./PaymentSettingsSection-BKDiep-C.js")).then(e=>({default:e.PaymentSettingsSection}))),messaging:kt(()=>Promise.resolve().then(()=>require("./MessagingSection-CRFtSoE8.js")).then(e=>({default:e.MessagingSection}))),settings:kt(()=>Promise.resolve().then(()=>require("./SettingsSection-DSlW47o4.js")).then(e=>({default:e.SettingsSection})))},createPluginContext(e){const t=e.cedrosPay,n=e.cedrosLogin;return{serverUrl:t?.serverUrl||n?.serverUrl||"",userId:n?.user?.id,getAccessToken:()=>n?.getAccessToken?.()||t?.jwtToken||null,hasPermission:o=>this.checkPermission(o,e),orgId:e.org?.orgId,pluginData:{walletAddress:t?.walletAddress}}},checkPermission(e,t){return t.org?.permissions?t.org.permissions.includes(e):!!(t.cedrosLogin?.user||t.cedrosPay?.jwtToken||t.cedrosPay?.walletAddress)},cssNamespace:"cedros-dashboard"},qo=k.createContext(null);function Ee(){const e=k.useContext(qo);if(!e)throw new Error("useCedrosShop must be used within CedrosShopProvider");return e}function Go(){return k.useContext(qo)}function im({config:e,children:t}){const n=k.useMemo(()=>({config:e}),[e]);return s.jsx(qo.Provider,{value:n,children:t})}function jt(e){return new Promise(t=>setTimeout(t,e))}const Fc=[{id:"cat_all",slug:"all",name:"All Products",description:"Everything in the catalog."},{id:"cat_apparel",slug:"apparel",name:"Apparel",description:"Soft goods and daily wear."},{id:"cat_accessories",slug:"accessories",name:"Accessories",description:"Carry, attach, decorate."}],Kr=[{id:"p_tee",slug:"cedros-tee",title:"Cedros Tee",description:"A heavyweight tee with a clean silhouette.",images:[{url:"https://picsum.photos/seed/cedros-tee/900/900",alt:"Cedros Tee"},{url:"https://picsum.photos/seed/cedros-tee-2/900/900",alt:"Cedros Tee detail"}],price:38,currency:"USD",tags:["new","cotton"],categoryIds:["cat_apparel"],compareAtPrice:48,inventoryStatus:"in_stock",variants:[{id:"v_tee_s",title:"Small / Black",options:{Size:"S",Color:"Black"}},{id:"v_tee_m",title:"Medium / Black",options:{Size:"M",Color:"Black"}},{id:"v_tee_l",title:"Large / Black",options:{Size:"L",Color:"Black"}}],shippingProfile:"physical"},{id:"p_crewneck",slug:"cedros-crewneck",title:"Cedros Crewneck",description:"Midweight fleece with a relaxed fit and embroidered mark.",images:[{url:"https://picsum.photos/seed/cedros-crewneck/900/900",alt:"Cedros Crewneck"}],price:64,currency:"USD",tags:["fleece","core"],categoryIds:["cat_apparel"],inventoryStatus:"in_stock",compareAtPrice:78,variants:[{id:"v_crew_s",title:"Small / Heather",options:{Size:"S",Color:"Heather"}},{id:"v_crew_m",title:"Medium / Heather",options:{Size:"M",Color:"Heather"}},{id:"v_crew_l",title:"Large / Heather",options:{Size:"L",Color:"Heather"}}],shippingProfile:"physical"},{id:"p_hoodie",slug:"cedros-hoodie",title:"Cedros Hoodie",description:"Pullover hoodie with soft interior and structured hood.",images:[{url:"https://picsum.photos/seed/cedros-hoodie/900/900",alt:"Cedros Hoodie"},{url:"https://picsum.photos/seed/cedros-hoodie-2/900/900",alt:"Cedros Hoodie detail"}],price:74,currency:"USD",tags:["fleece","new"],categoryIds:["cat_apparel"],inventoryStatus:"low",variants:[{id:"v_hoodie_s",title:"Small / Black",options:{Size:"S",Color:"Black"}},{id:"v_hoodie_m",title:"Medium / Black",options:{Size:"M",Color:"Black"}},{id:"v_hoodie_l",title:"Large / Black",options:{Size:"L",Color:"Black"}}],shippingProfile:"physical"},{id:"p_cap",slug:"cedros-cap",title:"Cedros Cap",description:"Unstructured cap with adjustable strap and curved brim.",images:[{url:"https://picsum.photos/seed/cedros-cap/900/900",alt:"Cedros Cap"}],price:28,currency:"USD",tags:["core"],categoryIds:["cat_apparel"],inventoryStatus:"in_stock",shippingProfile:"physical"},{id:"p_socks",slug:"cedros-socks",title:"Cedros Socks",description:"Rib-knit socks designed for everyday comfort.",images:[{url:"https://picsum.photos/seed/cedros-socks/900/900",alt:"Cedros Socks"}],price:14,currency:"USD",tags:["cotton"],categoryIds:["cat_apparel"],inventoryStatus:"in_stock",shippingProfile:"physical"},{id:"p_tote",slug:"cedros-tote",title:"Cedros Tote",description:"Heavy canvas tote with reinforced handles.",images:[{url:"https://picsum.photos/seed/cedros-tote/900/900",alt:"Cedros Tote"}],price:32,currency:"USD",tags:["gift","canvas"],categoryIds:["cat_accessories"],inventoryStatus:"in_stock",shippingProfile:"physical"},{id:"p_stickers",slug:"cedros-sticker-pack",title:"Sticker Pack",description:"Five durable vinyl stickers for laptops and water bottles.",images:[{url:"https://picsum.photos/seed/cedros-stickers/900/900",alt:"Sticker Pack"}],price:8,currency:"USD",tags:["gift"],categoryIds:["cat_accessories"],inventoryStatus:"in_stock",shippingProfile:"physical"},{id:"p_keychain",slug:"cedros-keychain",title:"Enamel Keychain",description:"Polished enamel keychain with a subtle mark.",images:[{url:"https://picsum.photos/seed/cedros-keychain/900/900",alt:"Enamel Keychain"}],price:12,currency:"USD",tags:["gift"],categoryIds:["cat_accessories"],inventoryStatus:"low",shippingProfile:"physical"},{id:"p_lanyard",slug:"cedros-lanyard",title:"Woven Lanyard",description:"Soft woven lanyard with swivel clasp.",images:[{url:"https://picsum.photos/seed/cedros-lanyard/900/900",alt:"Woven Lanyard"}],price:10,currency:"USD",tags:["core"],categoryIds:["cat_accessories"],inventoryStatus:"in_stock",shippingProfile:"physical"},{id:"p_notebook",slug:"cedros-notebook",title:"Dot Grid Notebook",description:"Lay-flat notebook for sketches, notes, and plans.",images:[{url:"https://picsum.photos/seed/cedros-notebook/900/900",alt:"Dot Grid Notebook"}],price:18,currency:"USD",tags:["gift"],categoryIds:["cat_accessories"],inventoryStatus:"in_stock",shippingProfile:"physical"},{id:"p_waterbottle",slug:"cedros-water-bottle",title:"Insulated Bottle",description:"Vacuum-insulated bottle that keeps drinks cold for hours.",images:[{url:"https://picsum.photos/seed/cedros-bottle/900/900",alt:"Insulated Bottle"}],price:36,currency:"USD",tags:["gift","new"],categoryIds:["cat_accessories"],inventoryStatus:"backorder",shippingProfile:"physical"},{id:"p_posters",slug:"cedros-poster-set",title:"Poster Set",description:"Two prints on thick matte stock.",images:[{url:"https://picsum.photos/seed/cedros-posters/900/900",alt:"Poster Set"}],price:24,currency:"USD",tags:["gift","limited"],categoryIds:["cat_accessories"],inventoryStatus:"out_of_stock",shippingProfile:"physical"},{id:"p_pins",slug:"cedros-pin-set",title:"Pin Set",description:"Two enamel pins with rubber backings.",images:[{url:"https://picsum.photos/seed/cedros-pins/900/900",alt:"Pin Set"}],price:16,currency:"USD",tags:["gift"],categoryIds:["cat_accessories"],inventoryStatus:"in_stock",shippingProfile:"physical"},{id:"p_brandbook",slug:"cedros-brand-book",title:"Brand Book (PDF)",description:"A compact brand book: typography, color, layout, and voice.",images:[{url:"https://picsum.photos/seed/cedros-brandbook/900/900",alt:"Brand Book cover"}],price:19,currency:"USD",tags:["digital"],categoryIds:["cat_accessories"],inventoryStatus:"in_stock",shippingProfile:"digital",checkoutRequirements:{email:"optional",name:"none",phone:"none",shippingAddress:!1,billingAddress:!1},fulfillment:{type:"digital_download",notes:"This is a digital product and will be downloadable from your account after purchase."}},{id:"p_wallpaper",slug:"cedros-wallpaper-pack",title:"Wallpaper Pack",description:"A set of desktop + mobile wallpapers in multiple colorways.",images:[{url:"https://picsum.photos/seed/cedros-wallpaper/900/900",alt:"Wallpaper Pack"}],price:6,currency:"USD",tags:["digital","new"],categoryIds:["cat_accessories"],inventoryStatus:"in_stock",shippingProfile:"digital"},{id:"p_longsleeve",slug:"cedros-long-sleeve",title:"Long Sleeve Tee",description:"Soft long sleeve tee with rib cuff and relaxed drape.",images:[{url:"https://picsum.photos/seed/cedros-longsleeve/900/900",alt:"Long Sleeve Tee"}],price:44,currency:"USD",tags:["cotton"],categoryIds:["cat_apparel"],inventoryStatus:"in_stock",shippingProfile:"physical"},{id:"p_shorts",slug:"cedros-shorts",title:"Everyday Shorts",description:"Lightweight shorts with a comfortable waistband.",images:[{url:"https://picsum.photos/seed/cedros-shorts/900/900",alt:"Everyday Shorts"}],price:40,currency:"USD",tags:["new"],categoryIds:["cat_apparel"],inventoryStatus:"in_stock",shippingProfile:"physical"},{id:"p_beanie",slug:"cedros-beanie",title:"Rib Beanie",description:"Warm rib beanie with a clean folded cuff.",images:[{url:"https://picsum.photos/seed/cedros-beanie/900/900",alt:"Rib Beanie"}],price:20,currency:"USD",tags:["core"],categoryIds:["cat_apparel"],inventoryStatus:"low",shippingProfile:"physical"},{id:"p_jacket",slug:"cedros-coach-jacket",title:"Coach Jacket",description:"Lightweight jacket with snap front and subtle sheen.",images:[{url:"https://picsum.photos/seed/cedros-jacket/900/900",alt:"Coach Jacket"}],price:96,currency:"USD",tags:["limited"],categoryIds:["cat_apparel"],inventoryStatus:"backorder",shippingProfile:"physical"},{id:"p_mug",slug:"cedros-mug",title:"Cedros Mug",description:"Stoneware mug with a satin glaze.",images:[{url:"https://picsum.photos/seed/cedros-mug/900/900",alt:"Cedros Mug"}],price:22,currency:"USD",tags:["gift"],categoryIds:["cat_accessories"],inventoryStatus:"low",shippingProfile:"physical"},{id:"p_guide",slug:"cedros-field-guide",title:"Field Guide (Digital)",description:"A short digital guide to shipping delightful checkout flows.",images:[{url:"https://picsum.photos/seed/cedros-guide/900/900",alt:"Field Guide cover"}],price:12,currency:"USD",tags:["digital"],categoryIds:["cat_accessories"],inventoryStatus:"in_stock",shippingProfile:"digital"}];function cm(e,t){let n=e;if(t.category&&t.category!=="all"){const l=Fc.find(d=>d.slug===t.category||d.id===t.category);l&&(n=n.filter(d=>d.categoryIds.includes(l.id)))}if(t.search){const l=t.search.toLowerCase();n=n.filter(d=>d.title.toLowerCase().includes(l)||d.description.toLowerCase().includes(l))}const r=t.filters??{},o=r.tags;if(Array.isArray(o)&&o.length>0){const l=new Set(o.map(String));n=n.filter(d=>d.tags?.some(f=>l.has(f)))}const a=typeof r.priceMin=="number"?r.priceMin:void 0,i=typeof r.priceMax=="number"?r.priceMax:void 0;return typeof a=="number"&&(n=n.filter(l=>l.price>=a)),typeof i=="number"&&(n=n.filter(l=>l.price<=i)),(typeof r.inStock=="boolean"?r.inStock:void 0)===!0&&(n=n.filter(l=>l.inventoryStatus!=="out_of_stock")),n}function lm(e,t){if(!t||t==="featured")return e;const n=[...e];return t==="price_asc"&&n.sort((r,o)=>r.price-o.price),t==="price_desc"&&n.sort((r,o)=>o.price-r.price),n}function dm(e,t,n){const r=(t-1)*n;return{items:e.slice(r,r+n),page:t,pageSize:n,total:e.length,hasNextPage:r+n<e.length}}function um(e){const t=new Date().toISOString(),n=e.cart.map(o=>{const a=Kr.find(i=>i.id===o.resource||i.slug===o.resource)??Kr[0];return{title:a.title,qty:o.quantity,unitPrice:a.price,currency:e.options.currency,imageUrl:a.images[0]?.url}}),r=n.reduce((o,a)=>o+a.qty*a.unitPrice,0);return{id:`ord_${Math.random().toString(16).slice(2)}`,createdAt:t,status:"paid",total:r,currency:e.options.currency,items:n,receiptUrl:e.options.successUrl}}function fm(){let e=[];const t={};return{async listProducts(n){await jt(150);const r=n.page??1,o=n.pageSize??24,a=cm(Kr,n),i=lm(a,n.sort);return dm(i,r,o)},async getProductBySlug(n){return await jt(100),Kr.find(r=>r.slug===n)??null},async listCategories(){return await jt(80),Fc},async getOrderHistory(){return await jt(120),e},async getCart({customerId:n}){return await jt(80),t[n]??{items:[]}},async mergeCart({customerId:n,cart:r}){await jt(120);const o=t[n]??{items:[]},a=new Map,i=l=>{const d=`${l.productId}::${l.variantId??""}`,f=a.get(d);f?a.set(d,{...f,qty:f.qty+l.qty}):a.set(d,l)};for(const l of o.items)i(l);for(const l of r.items)i(l);const c={items:Array.from(a.values()),promoCode:r.promoCode??o.promoCode};return t[n]=c,c},async updateCart({customerId:n,cart:r}){await jt(60),t[n]=r},async createCheckoutSession(n){await jt(250);const r=um(n);if(e=[r,...e].slice(0,25),n.options.successUrl){const o=new URL(n.options.successUrl,"http://localhost");return o.searchParams.set("demoOrderId",r.id),{kind:"redirect",url:o.toString().replace("http://localhost","")}}return{kind:"custom",data:{orderId:r.id}}},async listSubscriptionTiers(){return await jt(80),[{id:"tier_starter",title:"Starter",description:"For small shops getting started.",priceMonthly:19,priceAnnual:190,currency:"USD",features:["Basic analytics","Email support","1 storefront"]},{id:"tier_growth",title:"Growth",description:"For teams iterating fast.",priceMonthly:49,priceAnnual:490,currency:"USD",features:["Advanced analytics","Priority support","3 storefronts"],isPopular:!0},{id:"tier_enterprise",title:"Enterprise",description:"For high volume and custom needs.",priceMonthly:199,priceAnnual:1990,currency:"USD",features:["SLA","Dedicated success","Unlimited storefronts"]}]},async getSubscriptionStatus(){return await jt(80),{isActive:!1}},async createSubscriptionCheckoutSession(n){return await jt(200),n.successUrl?{kind:"redirect",url:n.successUrl}:{kind:"custom",data:n}}}}const ci=50,mm=4,pm=5,hm=1e4,gm={maxRetries:2,initialDelayMs:100,backoffFactor:2,maxDelayMs:500,jitter:!1};function Uc(e){return e.replace(/[_-]+/g," ").trim().replace(/\b\w/g,t=>t.toUpperCase())}function xm(e){return e?e.toUpperCase():"USD"}function vm(e){if(e&&(e==="in_stock"||e==="low"||e==="out_of_stock"||e==="backorder"))return e}function ym(e){if(e&&(e==="physical"||e==="digital"))return e}function bm(e){const t=[];if(Array.isArray(e))for(const n of e)typeof n=="string"&&t.push(n);else if(typeof e=="string"){const n=e.trim();if(n.startsWith("["))try{const r=JSON.parse(n);if(Array.isArray(r))for(const o of r)typeof o=="string"&&t.push(o);else t.push(e)}catch{t.push(e)}else t.push(e)}return t.flatMap(n=>n.split(",")).map(n=>n.trim().toUpperCase()).filter(Boolean)}function Tn(e){const t=xm(e.fiatCurrency),n=e.images&&e.images.length?e.images:e.imageUrl?[{url:e.imageUrl,alt:e.title}]:[],r=e.effectiveFiatAmountCents??e.fiatAmountCents??0,o=e.compareAtAmountCents,a=e.metadata?.shippingCountries??e.metadata?.shipping_countries,i=bm(a);return{id:e.id,slug:e.slug??e.id,title:e.title??Uc(e.id),description:e.description??"",images:n,price:r/100,currency:t,tags:e.tags??[],categoryIds:e.categoryIds??[],inventoryStatus:vm(e.inventoryStatus),inventoryQuantity:typeof e.inventoryQuantity=="number"?e.inventoryQuantity:void 0,compareAtPrice:typeof o=="number"?o/100:void 0,shippingProfile:ym(e.shippingProfile),checkoutRequirements:e.checkoutRequirements,fulfillment:e.fulfillment,attributes:i.length?{shippingCountries:i.join(",")}:void 0}}function Hr(e){if(Array.isArray(e))return{products:e};const t=e.products??e.items??[],n=e.total??e.count;return{products:t,total:n}}async function Ct(e,t,n,r={}){const{body:o,headers:a,method:i="GET",retryableRead:c=!1,timeoutMs:l=hm}=r,d={};n&&(d["X-API-Key"]=n),a&&Object.assign(d,a);const f=async()=>{const u=await Je.fetchWithTimeout(`${e}${t}`,{body:o,headers:d,method:i},l);if(!u.ok){const h=await u.text().catch(()=>""),g=new Error(`Request failed (${u.status}): ${h}`);throw g.status=u.status,g}return u.json()};return c?Je.retryWithBackoff(f,{...gm,name:`paywall-read-${i.toLowerCase()}`}):f()}async function wm(e,t,n,r){const o=await Ct(e,`/paywall/v1/products?limit=${n}&offset=${r}`,t,{retryableRead:!0});return Hr(o)}async function li(e,t,n,r){const{maxPages:o,pageSize:a}=n;for(let i=0;i<o;i+=1){const c=i*a,{products:l,total:d}=await wm(e,t,a,c);if(l.length===0||r(l))return;const f=typeof d=="number"&&c+l.length>=d,u=l.length<a;if(f||u)return}}function _m(e){const t=async d=>{const f=d.page??1,u=d.pageSize??24,h=u,g=(f-1)*u,y=new URLSearchParams;y.set("limit",String(h)),y.set("offset",String(g)),d.search&&y.set("search",d.search),d.category&&y.set("category",d.category),d.sort&&y.set("sort",d.sort),d.filters?.inStock&&y.set("in_stock","true"),d.filters?.minPrice!=null&&y.set("min_price",String(d.filters.minPrice)),d.filters?.maxPrice!=null&&y.set("max_price",String(d.filters.maxPrice));const x=d.filters?.tags,p=Array.isArray(x)?x:typeof x=="string"?[x]:[];p.length&&y.set("tags",p.join(","));const v=await Ct(e.serverUrl,`/paywall/v1/products?${y.toString()}`,e.apiKey,{retryableRead:!0}),{products:_,total:w}=Hr(v);return{items:_.map(Tn),page:f,pageSize:u,total:w,hasNextPage:typeof w=="number"?g+h<w:_.length===h}},n=async d=>{try{const f=await Ct(e.serverUrl,`/paywall/v1/products/by-slug/${encodeURIComponent(d)}`,e.apiKey,{retryableRead:!0});return Tn(f)}catch(f){const u=f?.status;if(u!==404&&u!==405)throw f;try{const h=await Ct(e.serverUrl,`/paywall/v1/products/${encodeURIComponent(d)}`,e.apiKey,{retryableRead:!0});return Tn(h)}catch(h){const g=h?.status;if(g!==404&&g!==405)throw h;let y;return await li(e.serverUrl,e.apiKey,{maxPages:mm,pageSize:ci},x=>(y=x.find(p=>p.slug===d||p.id===d),!!y)),y?Tn(y):null}}};return{listProducts:t,getProductBySlug:n,getProductsByIds:async d=>{const f=Array.from(new Set(d.filter(Boolean)));if(f.length===0)return new Map;const u=new Map;try{const y=new URLSearchParams;y.set("ids",f.join(",")),y.set("limit",String(f.length)),y.set("offset","0");const x=await Ct(e.serverUrl,`/paywall/v1/products?${y.toString()}`,e.apiKey,{retryableRead:!0}),{products:p}=Hr(x);for(const v of p){const _=Tn(v);u.set(_.id,_),_.slug&&_.slug!==_.id&&u.set(_.slug,_)}}catch{}const h=f.filter(y=>!u.has(y));if(h.length===0)return u;let g=h;try{const y=new Set(g);if(await li(e.serverUrl,e.apiKey,{maxPages:pm,pageSize:ci},x=>{for(const p of x){const v=Tn(p);!y.has(v.id)&&!(v.slug&&y.has(v.slug))||(u.set(v.id,v),v.slug&&v.slug!==v.id&&u.set(v.slug,v),y.delete(v.id),v.slug&&y.delete(v.slug))}return y.size===0}),g=Array.from(y),g.length===0)return u}catch{}for(const y of g)try{const x=await n(y);x&&(u.set(x.id,x),x.slug&&x.slug!==x.id&&u.set(x.slug,x))}catch{}return u},listCategories:async()=>{const d=await Ct(e.serverUrl,"/paywall/v1/products?limit=500&offset=0",e.apiKey,{retryableRead:!0}),{products:f}=Hr(d),u=new Set;for(const h of f)for(const g of h.categoryIds??[])u.add(g);return Array.from(u).map(h=>({id:h,slug:h,name:Uc(h)}))},getOrderHistory:async()=>[],createCheckoutSession:async d=>{throw new Error("createCheckoutSession is not implemented for paywall adapter")},getStorefrontSettings:async()=>{try{return(await Ct(e.serverUrl,"/admin/config/shop",e.apiKey,{retryableRead:!0})).config??null}catch{return null}},getPaymentMethodsConfig:async()=>{try{const[d,f,u]=await Promise.allSettled([Ct(e.serverUrl,"/admin/config/stripe",e.apiKey,{retryableRead:!0}),Ct(e.serverUrl,"/admin/config/x402",e.apiKey,{retryableRead:!0}),Ct(e.serverUrl,"/admin/config/cedros_login",e.apiKey,{retryableRead:!0})]),h=d.status==="fulfilled"?!!d.value?.config?.enabled:!1,g=f.status==="fulfilled"?!!f.value?.config?.enabled:!1,y=u.status==="fulfilled"?!!u.value?.config?.enabled:!1;return{card:h,crypto:g,credits:y}}catch{return null}},getAIRelatedProducts:async d=>Ct(e.serverUrl,"/admin/ai/related-products",e.apiKey,{method:"POST",body:JSON.stringify(d),headers:{"Content-Type":"application/json"},retryableRead:!1})}}function km(e){throw new Error(`Unhandled cart action: ${JSON.stringify(e)}`)}function gn(e){return`${e.productId}::${e.variantId??""}`}const jm={items:[]};function Sm(e,t){switch(t.type){case"cart/hydrate":return t.state;case"cart/add":{const n=Math.max(1,Math.floor(t.qty??1)),r=gn(t.item);return e.items.find(a=>gn(a)===r)?{...e,items:e.items.map(a=>gn(a)===r?{...a,qty:a.qty+n}:a)}:{...e,items:[...e.items,{...t.item,qty:n}]}}case"cart/remove":{const n=`${t.productId}::${t.variantId??""}`;return{...e,items:e.items.filter(r=>gn(r)!==n)}}case"cart/setQty":{const n=Math.max(0,Math.floor(t.qty)),r=`${t.productId}::${t.variantId??""}`;return n===0?{...e,items:e.items.filter(o=>gn(o)!==r)}:{...e,items:e.items.map(o=>gn(o)===r?{...o,qty:n}:o)}}case"cart/clear":return{items:[],promoCode:void 0};case"cart/setPromoCode":return{...e,promoCode:t.promoCode||void 0};case"cart/updateHold":{const n=`${t.productId}::${t.variantId??""}`;return{...e,items:e.items.map(r=>gn(r)===n?{...r,holdId:t.holdId,holdExpiresAt:t.holdExpiresAt}:r)}}default:return km(t)}}function Cm(e){return e.reduce((t,n)=>t+n.qty,0)}function Nm(e){return e.reduce((t,n)=>t+n.qty*n.unitPrice,0)}function di(){try{return typeof window>"u"?null:window.localStorage}catch{return null}}function Am(e,t){try{const n=e.getItem(t);return n?JSON.parse(n):null}catch{return null}}function Em(e,t,n){try{return e.setItem(t,JSON.stringify(n)),!0}catch(r){return console.warn(`[cedros] Failed to write "${t}" to storage`,r),!1}}const Bc=k.createContext(null);function Rt(){const e=k.useContext(Bc);if(!e)throw new Error("useCart must be used within CartProvider");return e}function ui(e){return!!e&&typeof e=="object"&&typeof e.productId=="string"&&e.productId.length>0&&typeof e.qty=="number"&&e.qty>0&&typeof e.unitPrice=="number"&&typeof e.currency=="string"&&typeof e.titleSnapshot=="string"}function Im({children:e}){const{config:t}=Ee(),n=t.cart?.storageKey??"cedros_shop_cart_v1",r=t.customer?.id,o=t.customer?.isSignedIn??!!r,a=t.cart?.syncDebounceMs??800,i=!!t.adapter.getCartInventoryStatus,[c,l]=k.useReducer(Sm,jm),d=k.useRef(c);d.current=c;const[f,u]=k.useState(!1),h=k.useRef(!1),g=k.useRef(null),y=k.useRef(null);k.useEffect(()=>{const _=di();if(!_)return;const w=Am(_,n);if(w&&Array.isArray(w.items)){const b=w.items.filter(ui);l({type:"cart/hydrate",state:{items:b,promoCode:typeof w.promoCode=="string"?w.promoCode:void 0}})}u(!0)},[n]),k.useEffect(()=>{if(!f)return;const _=di();_&&Em(_,n,c)},[c,n,f]),k.useEffect(()=>{if(!f||!o||!r||!t.adapter.mergeCart&&!t.adapter.getCart||(y.current!==r&&(h.current=!1,g.current=null,y.current=r),h.current))return;let _=!1;return(async()=>{try{const w=t.adapter.mergeCart?await t.adapter.mergeCart({customerId:r,cart:d.current}):await t.adapter.getCart({customerId:r});if(_)return;if(w&&Array.isArray(w.items)){h.current=!0;const b={...w,items:w.items.filter(ui)};l({type:"cart/hydrate",state:b}),g.current=JSON.stringify(b)}}catch{_||(h.current=!1)}})(),()=>{_=!0}},[t.adapter,r,f,o]),k.useEffect(()=>{if(!f||!o||!r||!t.adapter.updateCart||!h.current||typeof window>"u")return;const _=JSON.stringify(c);if(g.current===_)return;const w=window.setTimeout(()=>{t.adapter.updateCart({customerId:r,cart:c}).then(()=>{g.current=_}).catch(b=>{console.warn("[CedrosPay] Cart server sync failed:",b instanceof Error?b.message:b)})},a);return()=>window.clearTimeout(w)},[t.adapter,r,f,o,c,a]);const x=k.useCallback((_,w)=>{const b=c.items.find(j=>j.productId===_&&j.variantId===w);if(b)return{holdId:b.holdId,expiresAt:b.holdExpiresAt}},[c.items]),p=k.useCallback((_,w,b)=>{l({type:"cart/updateHold",productId:_,variantId:w,holdExpiresAt:b})},[]),v=k.useMemo(()=>{const _=Cm(c.items),w=Nm(c.items);return{items:c.items,promoCode:c.promoCode,count:_,subtotal:w,addItem:(b,j)=>l({type:"cart/add",item:b,qty:j}),removeItem:(b,j)=>l({type:"cart/remove",productId:b,variantId:j}),setQty:(b,j,R)=>l({type:"cart/setQty",productId:b,variantId:j,qty:R}),clear:()=>l({type:"cart/clear"}),setPromoCode:b=>l({type:"cart/setPromoCode",promoCode:b}),holdsSupported:i,getItemHold:x,updateItemHold:p}},[c.items,c.promoCode,i,x,p]);return s.jsx(Bc.Provider,{value:v,children:e})}function $(e,t,n){function r(c,l){if(c._zod||Object.defineProperty(c,"_zod",{value:{def:l,constr:i,traits:new Set},enumerable:!1}),c._zod.traits.has(e))return;c._zod.traits.add(e),t(c,l);const d=i.prototype,f=Object.keys(d);for(let u=0;u<f.length;u++){const h=f[u];h in c||(c[h]=d[h].bind(c))}}const o=n?.Parent??Object;class a extends o{}Object.defineProperty(a,"name",{value:e});function i(c){var l;const d=n?.Parent?new a:this;r(d,c),(l=d._zod).deferred??(l.deferred=[]);for(const f of d._zod.deferred)f();return d}return Object.defineProperty(i,"init",{value:r}),Object.defineProperty(i,Symbol.hasInstance,{value:c=>n?.Parent&&c instanceof n.Parent?!0:c?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}class Dn extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Vc extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const Wc={};function yn(e){return Wc}function Hc(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o)}function ko(e,t){return typeof t=="bigint"?t.toString():t}function Yo(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Qo(e){return e==null}function Ko(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Tm(e,t){const n=(e.toString().split(".")[1]||"").length,r=t.toString();let o=(r.split(".")[1]||"").length;if(o===0&&/\d?e-\d?/.test(r)){const l=r.match(/\d?e-(\d?)/);l?.[1]&&(o=Number.parseInt(l[1]))}const a=n>o?n:o,i=Number.parseInt(e.toFixed(a).replace(".","")),c=Number.parseInt(t.toFixed(a).replace(".",""));return i%c/10**a}const fi=Symbol("evaluating");function be(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==fi)return r===void 0&&(r=fi,r=n()),r},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function Sn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function ln(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function mi(e){return JSON.stringify(e)}function Pm(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Zc="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Jr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Rm=Yo(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function mr(e){if(Jr(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(Jr(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function qc(e){return mr(e)?{...e}:Array.isArray(e)?[...e]:e}const Om=new Set(["string","number","symbol"]);function Fn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function dn(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function ie(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Mm(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const Lm={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Dm(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const a=ln(e._zod.def,{get shape(){const i={};for(const c in t){if(!(c in n.shape))throw new Error(`Unrecognized key: "${c}"`);t[c]&&(i[c]=n.shape[c])}return Sn(this,"shape",i),i},checks:[]});return dn(e,a)}function $m(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const a=ln(e._zod.def,{get shape(){const i={...e._zod.def.shape};for(const c in t){if(!(c in n.shape))throw new Error(`Unrecognized key: "${c}"`);t[c]&&delete i[c]}return Sn(this,"shape",i),i},checks:[]});return dn(e,a)}function zm(e,t){if(!mr(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const a=e._zod.def.shape;for(const i in t)if(Object.getOwnPropertyDescriptor(a,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const o=ln(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t};return Sn(this,"shape",a),a}});return dn(e,o)}function Fm(e,t){if(!mr(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=ln(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return Sn(this,"shape",r),r}});return dn(e,n)}function Um(e,t){const n=ln(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return Sn(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return dn(e,n)}function Bm(e,t,n){const o=t._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const i=ln(t._zod.def,{get shape(){const c=t._zod.def.shape,l={...c};if(n)for(const d in n){if(!(d in c))throw new Error(`Unrecognized key: "${d}"`);n[d]&&(l[d]=e?new e({type:"optional",innerType:c[d]}):c[d])}else for(const d in c)l[d]=e?new e({type:"optional",innerType:c[d]}):c[d];return Sn(this,"shape",l),l},checks:[]});return dn(t,i)}function Vm(e,t,n){const r=ln(t._zod.def,{get shape(){const o=t._zod.def.shape,a={...o};if(n)for(const i in n){if(!(i in a))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(a[i]=new e({type:"nonoptional",innerType:o[i]}))}else for(const i in o)a[i]=new e({type:"nonoptional",innerType:o[i]});return Sn(this,"shape",a),a}});return dn(t,r)}function Ln(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Gc(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function Ir(e){return typeof e=="string"?e:e?.message}function bn(e,t,n){const r={...e,path:e.path??[]};if(!e.message){const o=Ir(e.inst?._zod.def?.error?.(e))??Ir(t?.error?.(e))??Ir(n.customError?.(e))??Ir(n.localeError?.(e))??"Invalid input";r.message=o}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function Jo(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function pr(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const Yc=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,ko,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Qc=$("$ZodError",Yc),Kc=$("$ZodError",Yc,{Parent:Error});function Wm(e,t=n=>n.message){const n={},r=[];for(const o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):r.push(t(o));return{formErrors:r,fieldErrors:n}}function Hm(e,t=n=>n.message){const n={_errors:[]},r=o=>{for(const a of o.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map(i=>r({issues:i}));else if(a.code==="invalid_key")r({issues:a.issues});else if(a.code==="invalid_element")r({issues:a.issues});else if(a.path.length===0)n._errors.push(t(a));else{let i=n,c=0;for(;c<a.path.length;){const l=a.path[c];c===a.path.length-1?(i[l]=i[l]||{_errors:[]},i[l]._errors.push(t(a))):i[l]=i[l]||{_errors:[]},i=i[l],c++}}};return r(e),n}const Xo=e=>(t,n,r,o)=>{const a=r?Object.assign(r,{async:!1}):{async:!1},i=t._zod.run({value:n,issues:[]},a);if(i instanceof Promise)throw new Dn;if(i.issues.length){const c=new(o?.Err??e)(i.issues.map(l=>bn(l,a,yn())));throw Zc(c,o?.callee),c}return i.value},ea=e=>async(t,n,r,o)=>{const a=r?Object.assign(r,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},a);if(i instanceof Promise&&(i=await i),i.issues.length){const c=new(o?.Err??e)(i.issues.map(l=>bn(l,a,yn())));throw Zc(c,o?.callee),c}return i.value},hs=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},o);if(a instanceof Promise)throw new Dn;return a.issues.length?{success:!1,error:new(e??Qc)(a.issues.map(i=>bn(i,o,yn())))}:{success:!0,data:a.value}},Zm=hs(Kc),gs=e=>async(t,n,r)=>{const o=r?Object.assign(r,{async:!0}):{async:!0};let a=t._zod.run({value:n,issues:[]},o);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(i=>bn(i,o,yn())))}:{success:!0,data:a.value}},qm=gs(Kc),Gm=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Xo(e)(t,n,o)},Ym=e=>(t,n,r)=>Xo(e)(t,n,r),Qm=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return ea(e)(t,n,o)},Km=e=>async(t,n,r)=>ea(e)(t,n,r),Jm=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return hs(e)(t,n,o)},Xm=e=>(t,n,r)=>hs(e)(t,n,r),ep=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return gs(e)(t,n,o)},tp=e=>async(t,n,r)=>gs(e)(t,n,r),np=/^[cC][^\s-]{8,}$/,rp=/^[0-9a-z]+$/,sp=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,op=/^[0-9a-vA-V]{20}$/,ap=/^[A-Za-z0-9]{27}$/,ip=/^[a-zA-Z0-9_-]{21}$/,cp=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,lp=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,pi=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,dp=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,up="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function fp(){return new RegExp(up,"u")}const mp=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,pp=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,hp=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,gp=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,xp=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Jc=/^[A-Za-z0-9_-]*$/,vp=/^\+[1-9]\d{6,14}$/,Xc="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",yp=new RegExp(`^${Xc}$`);function el(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function bp(e){return new RegExp(`^${el(e)}$`)}function wp(e){const t=el({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${Xc}T(?:${r})$`)}const _p=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},kp=/^-?\d+$/,jp=/^-?\d+(?:\.\d+)?$/,Sp=/^[^A-Z]*$/,Cp=/^[^a-z]*$/,ut=$("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),tl={number:"number",bigint:"bigint",object:"date"},nl=$("$ZodCheckLessThan",(e,t)=>{ut.init(e,t);const n=tl[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,a=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<a&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),rl=$("$ZodCheckGreaterThan",(e,t)=>{ut.init(e,t);const n=tl[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,a=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>a&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Np=$("$ZodCheckMultipleOf",(e,t)=>{ut.init(e,t),e._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):Tm(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Ap=$("$ZodCheckNumberFormat",(e,t)=>{ut.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[o,a]=Lm[t.format];e._zod.onattach.push(i=>{const c=i._zod.bag;c.format=t.format,c.minimum=o,c.maximum=a,n&&(c.pattern=kp)}),e._zod.check=i=>{const c=i.value;if(n){if(!Number.isInteger(c)){i.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){c>0?i.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):i.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}c<o&&i.issues.push({origin:"number",input:c,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),c>a&&i.issues.push({origin:"number",input:c,code:"too_big",maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),Ep=$("$ZodCheckMaxLength",(e,t)=>{var n;ut.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!Qo(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const o=r.value;if(o.length<=t.maximum)return;const i=Jo(o);r.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Ip=$("$ZodCheckMinLength",(e,t)=>{var n;ut.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!Qo(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const o=r.value;if(o.length>=t.minimum)return;const i=Jo(o);r.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Tp=$("$ZodCheckLengthEquals",(e,t)=>{var n;ut.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!Qo(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=r=>{const o=r.value,a=o.length;if(a===t.length)return;const i=Jo(o),c=a>t.length;r.issues.push({origin:i,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),xs=$("$ZodCheckStringFormat",(e,t)=>{var n,r;ut.init(e,t),e._zod.onattach.push(o=>{const a=o._zod.bag;a.format=t.format,t.pattern&&(a.patterns??(a.patterns=new Set),a.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Pp=$("$ZodCheckRegex",(e,t)=>{xs.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Rp=$("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Sp),xs.init(e,t)}),Op=$("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Cp),xs.init(e,t)}),Mp=$("$ZodCheckIncludes",(e,t)=>{ut.init(e,t);const n=Fn(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(o=>{const a=o._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(r)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),Lp=$("$ZodCheckStartsWith",(e,t)=>{ut.init(e,t);const n=new RegExp(`^${Fn(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),Dp=$("$ZodCheckEndsWith",(e,t)=>{ut.init(e,t);const n=new RegExp(`.*${Fn(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),$p=$("$ZodCheckOverwrite",(e,t)=>{ut.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class zp{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
|
|
1
|
+
"use strict";const s=require("react/jsx-runtime"),k=require("react"),zf=require("@solana/wallet-adapter-react"),Je=require("./CedrosContext-D-lnoEkR.js"),Ff=require("@cedros/login-react"),oi=require("./index-WcOlBYZJ.js"),Zo=require("react-dom"),Uf=require("./styles-BWrLnaUW.js");function Tc(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const m=Tc(k),ps=Tc(Zo);function lr(e){return new Date(e).toLocaleString()}const Y={products:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M20 7.5v9l-4 2.25M4 7.5v9l4 2.25"}),s.jsx("path",{d:"m20 7.5-8-4.5-8 4.5"}),s.jsx("path",{d:"m12 12 8-4.5M12 12v9.5M12 12 4 7.5"})]}),transactions:s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M12 2v20M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"})}),coupons:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z"}),s.jsx("path",{d:"M13 5v2M13 17v2M13 11v2"})]}),refunds:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),s.jsx("path",{d:"M3 3v5h5"}),s.jsx("path",{d:"M12 7v5l4 2"})]}),settings:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),s.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),wallet:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1"}),s.jsx("path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"})]}),chevronRight:s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"m9 18 6-6-6-6"})}),loading:s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"cedros-admin__spinner",children:s.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),refresh:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"}),s.jsx("path",{d:"M21 3v5h-5"}),s.jsx("path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"}),s.jsx("path",{d:"M8 16H3v5"})]}),check:s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M20 6 9 17l-5-5"})}),subscriptions:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"}),s.jsx("circle",{cx:"12",cy:"12",r:"3"}),s.jsx("path",{d:"M12 2v2M12 20v2M2 12H4M20 12h2"})]}),trash:s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M3 6h18M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})}),plus:s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M12 5v14M5 12h14"})}),chevronDown:s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"m6 9 6 6 6-6"})}),chevronUp:s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"m18 15-6-6-6 6"})}),storefront:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M3 9h18v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V9Z"}),s.jsx("path",{d:"m3 9 2.45-4.9A2 2 0 0 1 7.24 3h9.52a2 2 0 0 1 1.8 1.1L21 9"}),s.jsx("path",{d:"M12 3v6"})]}),arrowUp:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"m5 12 7-7 7 7"}),s.jsx("path",{d:"M12 19V5"})]}),arrowDown:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"m5 12 7 7 7-7"}),s.jsx("path",{d:"M12 5v14"})]}),delete:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M3 6h18M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"}),s.jsx("path",{d:"M10 11v6M14 11v6"})]}),close:s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M18 6 6 18M6 6l12 12"})}),edit:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),s.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),faq:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"}),s.jsx("path",{d:"M12 17h.01"})]}),chat:s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"m3 21 1.9-5.7a8.5 8.5 0 1 1 3.8 3.8z"})}),globe:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"}),s.jsx("path",{d:"M2 12h20"})]}),ai:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M12 2a4 4 0 0 1 4 4v2a4 4 0 0 1-8 0V6a4 4 0 0 1 4-4Z"}),s.jsx("path",{d:"M10 10v.5"}),s.jsx("path",{d:"M14 10v.5"}),s.jsx("path",{d:"M12 14v2"}),s.jsx("path",{d:"M8 18h8"}),s.jsx("path",{d:"M6 18a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2"}),s.jsx("path",{d:"M6 12v6"}),s.jsx("path",{d:"M18 12v6"})]}),notifications:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9"}),s.jsx("path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0"})]}),eye:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"}),s.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),eyeOff:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M9.88 9.88a3 3 0 1 0 4.24 4.24"}),s.jsx("path",{d:"M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68"}),s.jsx("path",{d:"M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61"}),s.jsx("line",{x1:"2",x2:"22",y1:"2",y2:"22"})]}),creditCard:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{width:"20",height:"14",x:"2",y:"5",rx:"2"}),s.jsx("line",{x1:"2",x2:"22",y1:"10",y2:"10"})]}),mail:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{width:"20",height:"16",x:"2",y:"4",rx:"2"}),s.jsx("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]}),server:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2"}),s.jsx("rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2"}),s.jsx("line",{x1:"6",x2:"6.01",y1:"6",y2:"6"}),s.jsx("line",{x1:"6",x2:"6.01",y1:"18",y2:"18"})]}),calendarRepeat:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",ry:"2"}),s.jsx("line",{x1:"16",x2:"16",y1:"2",y2:"6"}),s.jsx("line",{x1:"8",x2:"8",y1:"2",y2:"6"}),s.jsx("line",{x1:"3",x2:"21",y1:"10",y2:"10"}),s.jsx("path",{d:"M11 14h1.5a1.5 1.5 0 0 1 0 3H11v2"}),s.jsx("path",{d:"M16 14v3a1 1 0 0 0 1 1h1"})]}),brain:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z"}),s.jsx("path",{d:"M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z"}),s.jsx("path",{d:"M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4"}),s.jsx("path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375"}),s.jsx("path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5"}),s.jsx("path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396"}),s.jsx("path",{d:"M19.938 10.5a4 4 0 0 1 .585.396"}),s.jsx("path",{d:"M6 18a4 4 0 0 1-1.967-.516"}),s.jsx("path",{d:"M19.967 17.484A4 4 0 0 1 18 18"})]})};function jr({message:e,onRetry:t}){return e?s.jsxs("div",{className:"cedros-admin__error-banner",children:[s.jsx("span",{children:e}),t&&s.jsxs("button",{type:"button",className:"cedros-admin__error-banner-retry",onClick:t,children:[Y.refresh," Retry"]})]}):null}function Sr({stats:e,isLoading:t=!1,onRefresh:n}){return s.jsxs("div",{className:"cedros-admin__stats-bar",children:[s.jsx("div",{className:"cedros-admin__stats-bar-grid",children:e.map((r,o)=>s.jsxs("div",{className:"cedros-admin__stats-bar-item",children:[s.jsx("span",{className:"cedros-admin__stats-bar-label",children:r.label}),s.jsx("span",{className:`cedros-admin__stats-bar-value ${r.variant?`cedros-admin__stats-bar-value--${r.variant}`:""}`,children:t?s.jsx("span",{className:"cedros-admin__skeleton cedros-admin__skeleton--value"}):r.value}),r.description&&s.jsx("span",{className:"cedros-admin__stats-bar-desc",children:r.description})]},o))}),n&&s.jsx("button",{type:"button",className:"cedros-admin__stats-bar-refresh",onClick:n,disabled:t,title:"Refresh stats",children:t?Y.loading:Y.refresh})]})}function Bf({serverUrl:e,productId:t,apiKey:n,authManager:r}){const[o,a]=k.useState(null),[i,c]=k.useState(!1),[l,d]=k.useState(!1),[f,u]=k.useState(null),h=k.useCallback(async()=>{if(t){c(!0),u(null);try{let x;if(r?.isAuthenticated())x=await r.fetchWithAuth(`/admin/products/${t}/variations`);else{const p={"Content-Type":"application/json"};n&&(p["X-API-Key"]=n);const v=await fetch(`${e}/admin/products/${t}/variations`,{headers:p});if(!v.ok)throw new Error(`Failed to fetch variations: ${v.status}`);x=await v.json()}x.variationConfig||(x.variationConfig={variationTypes:[]}),x.variants||(x.variants=[]),a(x)}catch(x){const p=x instanceof Error?x.message:"Failed to fetch variations";u(p),a({productId:t,variationConfig:{variationTypes:[]},variants:[]})}finally{c(!1)}}},[e,t,n,r]),g=k.useCallback(async x=>{if(!t)return null;d(!0),u(null);try{let p;if(r?.isAuthenticated())p=await r.fetchWithAuth(`/admin/products/${t}/variations`,{method:"PUT",body:JSON.stringify(x)});else{const v={"Content-Type":"application/json"};n&&(v["X-API-Key"]=n);const _=await fetch(`${e}/admin/products/${t}/variations`,{method:"PUT",headers:v,body:JSON.stringify(x)});if(!_.ok)throw new Error(`Failed to save variations: ${_.status}`);p=await _.json()}return a({productId:t,variationConfig:p.variationConfig,variants:p.variants}),{variantsCreated:p.variantsCreated}}catch(p){const v=p instanceof Error?p.message:"Failed to save variations";return u(v),null}finally{d(!1)}},[e,t,n,r]),y=k.useCallback(async x=>{if(!t||x.length===0)return!1;d(!0),u(null);try{if(r?.isAuthenticated())await r.fetchWithAuth(`/admin/products/${t}/variants/inventory`,{method:"PUT",body:JSON.stringify({updates:x})});else{const p={"Content-Type":"application/json"};n&&(p["X-API-Key"]=n);const v=await fetch(`${e}/admin/products/${t}/variants/inventory`,{method:"PUT",headers:p,body:JSON.stringify({updates:x})});if(!v.ok)throw new Error(`Failed to update inventory: ${v.status}`)}if(o){const p=new Map(x.map(v=>[v.variantId,v]));a({...o,variants:o.variants.map(v=>{const _=p.get(v.id);return _?{...v,inventoryQuantity:_.inventoryQuantity,inventoryStatus:_.inventoryStatus??v.inventoryStatus}:v})})}return!0}catch(p){const v=p instanceof Error?p.message:"Failed to update inventory";return u(v),!1}finally{d(!1)}},[e,t,n,r,o]);return{data:o,isLoading:i,error:f,fetch:h,save:g,bulkUpdateInventory:y,isSaving:l}}function ai(){return`var_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function Vf({value:e,onChange:t,maxTypes:n=5,maxValuesPerType:r=20,disabled:o=!1}){const[a,i]=k.useState(null),[c,l]=k.useState(""),[d,f]=k.useState({}),u=e.variationTypes,h=k.useCallback(()=>{if(!c.trim()||u.length>=n)return;const w={id:ai(),name:c.trim(),displayOrder:u.length,values:[]};t({variationTypes:[...u,w]}),l(""),i(w.id)},[c,u,n,t]),g=k.useCallback(w=>{t({variationTypes:u.filter(b=>b.id!==w).map((b,j)=>({...b,displayOrder:j}))}),a===w&&i(null)},[u,t,a]),y=k.useCallback((w,b)=>{t({variationTypes:u.map(j=>j.id===w?{...j,name:b}:j)})},[u,t]),x=k.useCallback((w,b)=>{const j=u.findIndex(C=>C.id===w);if(j===-1||b==="up"&&j===0||b==="down"&&j===u.length-1)return;const R=[...u],I=b==="up"?j-1:j+1;[R[j],R[I]]=[R[I],R[j]],t({variationTypes:R.map((C,E)=>({...C,displayOrder:E}))})},[u,t]),p=k.useCallback(w=>{const b=(d[w]||"").trim();if(!b)return;const j=u.find(I=>I.id===w);if(!j||j.values.length>=r)return;const R={id:ai(),label:b};t({variationTypes:u.map(I=>I.id===w?{...I,values:[...I.values,R]}:I)}),f(I=>({...I,[w]:""}))},[u,d,r,t]),v=k.useCallback((w,b)=>{t({variationTypes:u.map(j=>j.id===w?{...j,values:j.values.filter(R=>R.id!==b)}:j)})},[u,t]),_=k.useCallback((w,b,j)=>{t({variationTypes:u.map(R=>R.id===w?{...R,values:R.values.map(I=>I.id===b?{...I,label:j}:I)}:R)})},[u,t]);return s.jsxs("div",{className:"cedros-admin__variation-editor",children:[s.jsxs("div",{className:"cedros-admin__variation-editor-header",children:[s.jsx("h4",{className:"cedros-admin__field-label",style:{marginBottom:0},children:"Variation Types"}),s.jsxs("span",{style:{fontSize:12,opacity:.7},children:[u.length,"/",n," types"]})]}),u.length===0?s.jsx("div",{className:"cedros-admin__variation-empty",children:'No variation types defined. Add types like "Size" or "Color" to create product variants.'}):s.jsx("div",{className:"cedros-admin__variation-type-list",children:u.map((w,b)=>s.jsxs("div",{className:"cedros-admin__variation-type-item",children:[s.jsxs("div",{className:"cedros-admin__variation-type-header",children:[s.jsxs("div",{className:"cedros-admin__variation-type-controls",children:[s.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--icon",onClick:()=>x(w.id,"up"),disabled:o||b===0,title:"Move up",children:Y.arrowUp}),s.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--icon",onClick:()=>x(w.id,"down"),disabled:o||b===u.length-1,title:"Move down",children:Y.arrowDown})]}),s.jsx("input",{type:"text",className:"cedros-admin__input cedros-admin__variation-type-name",value:w.name,onChange:j=>y(w.id,j.target.value),disabled:o,placeholder:"Type name"}),s.jsxs("span",{className:"cedros-admin__variation-value-count",children:[w.values.length," values"]}),s.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>i(a===w.id?null:w.id),children:a===w.id?"Collapse":"Edit values"}),s.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--danger",onClick:()=>g(w.id),disabled:o,title:"Remove type",children:Y.delete})]}),a===w.id&&s.jsxs("div",{className:"cedros-admin__variation-values",children:[s.jsxs("div",{className:"cedros-admin__variation-values-header",children:[s.jsxs("span",{style:{fontSize:12,fontWeight:600},children:['Values for "',w.name,'"']}),s.jsxs("span",{style:{fontSize:11,opacity:.7},children:[w.values.length,"/",r]})]}),w.values.length===0?s.jsx("div",{className:"cedros-admin__variation-empty",style:{padding:"8px 0"},children:'No values yet. Add values like "Small", "Medium", "Large".'}):s.jsx("div",{className:"cedros-admin__variation-value-list",children:w.values.map(j=>s.jsxs("div",{className:"cedros-admin__variation-value-item",children:[s.jsx("input",{type:"text",className:"cedros-admin__input cedros-admin__input--sm",value:j.label,onChange:R=>_(w.id,j.id,R.target.value),disabled:o}),s.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--icon cedros-admin__button--danger",onClick:()=>v(w.id,j.id),disabled:o,title:"Remove value",children:Y.close})]},j.id))}),w.values.length<r&&s.jsxs("div",{className:"cedros-admin__variation-add-value",children:[s.jsx("input",{type:"text",className:"cedros-admin__input cedros-admin__input--sm",value:d[w.id]||"",onChange:j=>f(R=>({...R,[w.id]:j.target.value})),placeholder:"Add value...",disabled:o,onKeyDown:j=>{j.key==="Enter"&&(j.preventDefault(),p(w.id))}}),s.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--secondary cedros-admin__button--sm",onClick:()=>p(w.id),disabled:o||!d[w.id]?.trim(),children:"Add"})]})]})]},w.id))}),u.length<n&&s.jsxs("div",{className:"cedros-admin__variation-add-type",children:[s.jsx("input",{type:"text",className:"cedros-admin__input",value:c,onChange:w=>l(w.target.value),placeholder:"New variation type (e.g., Size, Color)",disabled:o,onKeyDown:w=>{w.key==="Enter"&&(w.preventDefault(),h())}}),s.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--secondary",onClick:h,disabled:o||!c.trim(),children:"Add Type"})]})]})}function Pc({value:e,onChange:t,options:n,placeholder:r="Filter",disabled:o}){const[a,i]=k.useState(!1),c=k.useRef(null),d=n.find(f=>f.value===e)?.label||r;return k.useEffect(()=>{const f=u=>{c.current&&!c.current.contains(u.target)&&i(!1)};if(a)return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[a]),k.useEffect(()=>{const f=u=>{u.key==="Escape"&&i(!1)};if(a)return document.addEventListener("keydown",f),()=>document.removeEventListener("keydown",f)},[a]),s.jsxs("div",{className:"cedros-admin__dropdown",ref:c,children:[s.jsxs("button",{type:"button",className:"cedros-admin__dropdown-trigger",onClick:()=>!o&&i(!a),"aria-expanded":a,"aria-haspopup":"listbox",disabled:o,children:[s.jsx("span",{children:d}),s.jsx("span",{className:`cedros-admin__dropdown-chevron ${a?"cedros-admin__dropdown-chevron--open":""}`,children:Y.chevronDown})]}),a&&s.jsx("div",{className:"cedros-admin__dropdown-menu",role:"listbox",children:n.map(f=>s.jsxs("button",{type:"button",className:`cedros-admin__dropdown-item ${f.value===e?"cedros-admin__dropdown-item--selected":""}`,onClick:()=>{f.disabled||(t(f.value),i(!1))},role:"option","aria-selected":f.value===e,disabled:f.disabled,children:[f.label,f.value===e&&s.jsx("span",{className:"cedros-admin__dropdown-check",children:Y.check})]},f.value))})]})}function At({value:e,onChange:t,options:n,label:r,description:o,disabled:a,className:i,style:c}){const[l,d]=k.useState(!1),f=k.useRef(null),h=n.find(g=>g.value===e)?.label||"Select...";return k.useEffect(()=>{const g=y=>{f.current&&!f.current.contains(y.target)&&d(!1)};if(l)return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[l]),k.useEffect(()=>{const g=y=>{y.key==="Escape"&&d(!1)};if(l)return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[l]),s.jsxs("div",{className:`cedros-admin__field ${i||""}`,style:c,children:[s.jsx("label",{className:"cedros-admin__field-label",children:r}),s.jsxs("div",{className:"cedros-admin__dropdown cedros-admin__dropdown--form",ref:f,children:[s.jsxs("button",{type:"button",className:"cedros-admin__dropdown-trigger cedros-admin__dropdown-trigger--form",onClick:()=>!a&&d(!l),"aria-expanded":l,"aria-haspopup":"listbox",disabled:a,children:[s.jsx("span",{children:h}),s.jsx("span",{className:`cedros-admin__dropdown-chevron ${l?"cedros-admin__dropdown-chevron--open":""}`,children:Y.chevronDown})]}),l&&s.jsx("div",{className:"cedros-admin__dropdown-menu cedros-admin__dropdown-menu--form",role:"listbox",children:n.map(g=>s.jsxs("button",{type:"button",className:`cedros-admin__dropdown-item ${g.value===e?"cedros-admin__dropdown-item--selected":""}`,onClick:()=>{g.disabled||(t(g.value),d(!1))},role:"option","aria-selected":g.value===e,disabled:g.disabled,children:[g.label,g.value===e&&s.jsx("span",{className:"cedros-admin__dropdown-check",children:Y.check})]},g.value))})]}),o&&s.jsx("p",{className:"cedros-admin__field-description",children:o})]})}function ii(){return`variant_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function Wf(e){if(e.length===0)return[];const t=[...e].sort((r,o)=>r.displayOrder-o.displayOrder),n=(r,o)=>{if(r>=t.length){const c=o.valueIds.sort().join("|"),l=Object.values(o.options).join(" / ");return[{key:c,title:l,optionValueIds:[...o.valueIds],options:{...o.options}}]}const a=t[r],i=[];for(const c of a.values)i.push(...n(r+1,{valueIds:[...o.valueIds,c.id],options:{...o.options,[a.name]:c.label}}));return i};return n(0,{valueIds:[],options:{}})}function Hf(e){return e.optionValueIds?.length?[...e.optionValueIds].sort().join("|"):Object.entries(e.options).sort(([t],[n])=>t.localeCompare(n)).map(([t,n])=>`${t}:${n}`).join("|")}function Zf({variationConfig:e,variants:t,onChange:n,defaultPrice:r=0,currencySymbol:o="$",maxVariants:a=100,disabled:i=!1}){const c=k.useMemo(()=>Wf(e.variationTypes),[e.variationTypes]),l=k.useMemo(()=>{const x=new Map;for(const p of t)x.set(Hf(p),p);return x},[t]),{existingRows:d,possibleRows:f}=k.useMemo(()=>{const x=[],p=[];for(const v of c){const _=l.get(v.key);_?x.push({combo:v,variant:_}):p.push(v)}return{existingRows:x,possibleRows:p}},[c,l]),u=k.useCallback((x,p)=>{n(t.map(v=>v.id===x?{...v,...p}:v))},[t,n]),h=k.useCallback(x=>{n(t.filter(p=>p.id!==x))},[t,n]),g=k.useCallback(x=>{if(t.length>=a)return;const p={id:ii(),title:x.title,options:x.options,optionValueIds:x.optionValueIds,price:r,inventoryQuantity:0,inventoryStatus:"in_stock",autoGenerated:!1};n([...t,p])},[t,n,a,r]),y=k.useCallback(()=>{const x=a-t.length,v=f.slice(0,x).map(_=>({id:ii(),title:_.title,options:_.options,optionValueIds:_.optionValueIds,price:r,inventoryQuantity:0,inventoryStatus:"in_stock",autoGenerated:!0}));n([...t,...v])},[t,n,f,a,r]);return e.variationTypes.length===0?s.jsx("div",{className:"cedros-admin__variant-grid-empty",children:"Add variation types above to create product variants."}):c.length===0?s.jsx("div",{className:"cedros-admin__variant-grid-empty",children:"Add values to your variation types to create product variants."}):s.jsxs("div",{className:"cedros-admin__variant-grid",children:[s.jsxs("div",{className:"cedros-admin__variant-grid-header",children:[s.jsx("h4",{className:"cedros-admin__field-label",style:{marginBottom:0},children:"Variants"}),s.jsxs("span",{style:{fontSize:12,opacity:.7},children:[t.length,"/",a," variants (",c.length," ","possible)"]})]}),f.length>0&&t.length<a&&s.jsxs("div",{className:"cedros-admin__variant-grid-actions",children:[s.jsxs("button",{type:"button",className:"cedros-admin__button cedros-admin__button--secondary",onClick:y,disabled:i,children:["Generate All (",Math.min(f.length,a-t.length),")"]}),s.jsx("span",{style:{fontSize:11,opacity:.7},children:"Creates variants with default price and 0 inventory"})]}),s.jsx("div",{className:"cedros-admin__table-container",children:s.jsxs("table",{className:"cedros-admin__table cedros-admin__variant-table",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Variant"}),s.jsx("th",{style:{width:100},children:"Price"}),s.jsx("th",{style:{width:80},children:"Qty"}),s.jsx("th",{style:{width:100},children:"SKU"}),s.jsx("th",{style:{width:100},children:"Status"}),s.jsx("th",{style:{width:80},children:"Actions"})]})}),s.jsxs("tbody",{children:[d.map(({combo:x,variant:p})=>s.jsxs("tr",{children:[s.jsx("td",{children:s.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[s.jsx("span",{style:{fontWeight:600},children:x.title}),s.jsx("span",{style:{fontSize:11,opacity:.6},children:Object.entries(x.options).map(([v,_])=>`${v}: ${_}`).join(", ")})]})}),s.jsx("td",{children:s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[s.jsx("span",{children:o}),s.jsx("input",{type:"number",className:"cedros-admin__input cedros-admin__input--sm",value:p.price??"",onChange:v=>u(p.id,{price:v.target.value===""?void 0:parseFloat(v.target.value)||0}),disabled:i,min:"0",step:"0.01",style:{width:70}})]})}),s.jsx("td",{children:s.jsx("input",{type:"number",className:"cedros-admin__input cedros-admin__input--sm",value:p.inventoryQuantity??"",onChange:v=>u(p.id,{inventoryQuantity:v.target.value===""?void 0:parseInt(v.target.value)||0}),disabled:i,min:"0",style:{width:60}})}),s.jsx("td",{children:s.jsx("input",{type:"text",className:"cedros-admin__input cedros-admin__input--sm",value:p.sku??"",onChange:v=>u(p.id,{sku:v.target.value||void 0}),disabled:i,placeholder:"SKU",style:{width:80}})}),s.jsx("td",{children:s.jsx(Pc,{value:p.inventoryStatus??"in_stock",onChange:v=>u(p.id,{inventoryStatus:v}),options:[{value:"in_stock",label:"In stock"},{value:"low",label:"Low"},{value:"out_of_stock",label:"Out of stock"},{value:"backorder",label:"Backorder"}],disabled:i})}),s.jsx("td",{children:s.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--icon cedros-admin__button--danger",onClick:()=>h(p.id),disabled:i,title:"Remove variant",children:Y.trash})})]},p.id)),f.length>0&&t.length<a&&s.jsxs(s.Fragment,{children:[s.jsx("tr",{className:"cedros-admin__variant-separator",children:s.jsx("td",{colSpan:6,children:s.jsxs("span",{style:{fontSize:11,opacity:.6},children:["Uncreated combinations (",f.length,")"]})})}),f.slice(0,10).map(x=>s.jsxs("tr",{className:"cedros-admin__variant-possible",children:[s.jsx("td",{children:s.jsx("span",{style:{opacity:.6},children:x.title})}),s.jsx("td",{colSpan:4,style:{opacity:.5},children:"Not created"}),s.jsx("td",{children:s.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--icon",onClick:()=>g(x),disabled:i,title:"Create variant",children:Y.plus})})]},x.key)),f.length>10&&s.jsx("tr",{className:"cedros-admin__variant-more",children:s.jsxs("td",{colSpan:6,style:{textAlign:"center",opacity:.6},children:["+",f.length-10," more combinations"]})})]})]})]})})]})}function qf({serverUrl:e,productId:t,productTitle:n,defaultPrice:r=0,currencySymbol:o="$",apiKey:a,authManager:i,onClose:c}){const{data:l,isLoading:d,error:f,fetch:u,save:h,isSaving:g}=Bf({serverUrl:e,productId:t,apiKey:a,authManager:i}),[y,x]=k.useState({variationTypes:[]}),[p,v]=k.useState([]),[_,w]=k.useState(!1),[b,j]=k.useState(!1);k.useEffect(()=>{u()},[u]),k.useEffect(()=>{l&&(x(l.variationConfig),v(l.variants),w(!1))},[l]);const R=k.useCallback(E=>{x(E),w(!0),j(!1)},[]),I=k.useCallback(E=>{v(E),w(!0),j(!1)},[]),C=k.useCallback(async()=>{const E=new Set((l?.variants??[]).map(D=>D.id)),O=p.filter(D=>!E.has(D.id)),F=p.filter(D=>E.has(D.id)),M=(l?.variants??[]).filter(D=>!p.some(H=>H.id===D.id)).map(D=>D.id);await h({variationConfig:y,createVariants:O.map(D=>({optionValueIds:D.optionValueIds??[],inventoryQuantity:D.inventoryQuantity,sku:D.sku,price:D.price})),updateVariants:F.map(D=>({id:D.id,inventoryQuantity:D.inventoryQuantity,sku:D.sku,price:D.price,inventoryStatus:D.inventoryStatus})),deleteVariantIds:M.length>0?M:void 0})&&(w(!1),j(!0),setTimeout(()=>j(!1),3e3))},[y,p,l?.variants,h]);return d?s.jsxs("div",{className:"cedros-admin__variations-editor",children:[s.jsxs("div",{className:"cedros-admin__variations-editor-header",children:[s.jsx("h3",{className:"cedros-admin__section-title",children:n?`Variations: ${n}`:"Product Variations"}),c&&s.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost",onClick:c,children:Y.close})]}),s.jsxs("div",{className:"cedros-admin__loading",children:[Y.loading," Loading variations..."]})]}):s.jsxs("div",{className:"cedros-admin__variations-editor",children:[s.jsxs("div",{className:"cedros-admin__variations-editor-header",children:[s.jsx("h3",{className:"cedros-admin__section-title",children:n?`Variations: ${n}`:"Product Variations"}),s.jsxs("div",{className:"cedros-admin__variations-editor-actions",children:[b&&s.jsxs("span",{className:"cedros-admin__success-text",children:[Y.check," Saved"]}),_&&s.jsx("span",{className:"cedros-admin__unsaved-text",children:"Unsaved changes"}),s.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--primary",onClick:C,disabled:g||!_,children:g?"Saving...":"Save Changes"}),c&&s.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost",onClick:c,children:Y.close})]})]}),f&&s.jsx("div",{className:"cedros-admin__error-banner",children:f}),s.jsxs("div",{className:"cedros-admin__variations-editor-content",children:[s.jsx("div",{className:"cedros-admin__variations-editor-section",children:s.jsx(Vf,{value:y,onChange:R,disabled:g})}),y.variationTypes.length>0&&s.jsx("div",{className:"cedros-admin__variations-editor-section",children:s.jsx(Zf,{variationConfig:y,variants:p,onChange:I,defaultPrice:r,currencySymbol:o,disabled:g})})]})]})}function Rc({serverUrl:e,apiKey:t,pageSize:n=20,authManager:r}){const[o,a]=k.useState([]),[i,c]=k.useState(!0),[l,d]=k.useState(!1),[f,u]=k.useState(!1),[h,g]=k.useState(null),[y,x]=k.useState(null),[p,v]=k.useState(null),[_,w]=k.useState(null),[b,j]=k.useState({id:"",title:"",slug:"",imageUrl:"",description:"",productType:"one_time",priceUsd:"",fiatCurrency:"usd",cryptoToken:"USDC",inventoryStatus:"in_stock",compareAtUsd:"",tagsCsv:"",categoryIdsCsv:"",checkoutEmail:"required",checkoutName:"optional",checkoutPhone:"none",checkoutShippingAddress:!1,checkoutBillingAddress:!1,fulfillmentType:"shipping",fulfillmentNotes:"",shippingCountriesCsv:"",inventoryQuantity:""}),R=A=>{const N=A.tagsCsv.split(",").map(q=>q.trim()).filter(Boolean),Z=A.categoryIdsCsv.split(",").map(q=>q.trim()).filter(Boolean),te={email:A.checkoutEmail,name:A.checkoutName,phone:A.checkoutPhone,shippingAddress:A.checkoutShippingAddress,billingAddress:A.checkoutBillingAddress},re=A.fulfillmentType==="shipping"?"physical":"digital",de={title:A.title,slug:A.slug||A.id,shipping_profile:re,inventory_status:A.inventoryStatus,checkout_requirements:JSON.stringify(te),fulfillment_type:A.fulfillmentType};A.imageUrl&&(de.image_url=A.imageUrl);const W=A.compareAtUsd?Math.round(Number(A.compareAtUsd)*100):0;W&&(de.compare_at_amount_cents=String(W)),N.length&&(de.tags=JSON.stringify(N)),Z.length&&(de.category_ids=JSON.stringify(Z)),A.fulfillmentNotes&&(de.fulfillment_notes=A.fulfillmentNotes);const Q=A.shippingCountriesCsv.split(",").map(q=>q.trim().toUpperCase()).filter(Boolean);return Q.length&&(de.shippingCountries=Q.join(","),de.shipping_countries=Q.join(",")),de},I=A=>A.metadata?.title||A.description||A.id,C=A=>A.metadata?.image_url,E=k.useCallback(async()=>{try{w(null);let A;if(r?.isAuthenticated())A=await r.fetchWithAuth(`/admin/products?limit=${n}`);else{const N={"Content-Type":"application/json"};t&&(N["X-API-Key"]=t);const Z=await fetch(`${e}/admin/products?limit=${n}`,{headers:N});if(!Z.ok)throw new Error(`Failed to fetch products: ${Z.status}`);A=await Z.json()}a(A.products||[])}catch{a([]),w("Failed to load products")}finally{c(!1)}},[e,t,n,r]);k.useEffect(()=>{E()},[E]);const O=async A=>{if(A.preventDefault(),!(!b.id||!b.description)){if(g(null),b.fulfillmentType==="shipping"&&b.checkoutShippingAddress&&!b.shippingCountriesCsv.split(",").map(Z=>Z.trim()).filter(Boolean).length){g("Shipping countries are required when collecting shipping address. Example: US,CA");return}u(!0);try{const{productType:N}=b,Z=b.inventoryQuantity===""?void 0:Number.isFinite(Number(b.inventoryQuantity))?Number(b.inventoryQuantity):void 0,te=Number(b.priceUsd)||0,re=Math.round(te*100),de=Math.round(te*1e6),W={id:b.id,description:b.description,fiatAmountCents:re,fiatCurrency:b.fiatCurrency,cryptoAtomicAmount:de,cryptoToken:b.cryptoToken,...Z!==void 0?{inventoryQuantity:Z}:{},metadata:{...N?{product_type:N}:{},...R(b)}};if(r?.isAuthenticated())await r.fetchWithAuth("/admin/products",{method:"POST",body:JSON.stringify(W)});else{const Q={"Content-Type":"application/json"};t&&(Q["X-API-Key"]=t);const q=await fetch(`${e}/admin/products`,{method:"POST",headers:Q,body:JSON.stringify(W)});if(!q.ok)throw new Error(`Failed to create product: ${q.status}`)}j({id:"",title:"",slug:"",imageUrl:"",description:"",productType:"one_time",priceUsd:"",fiatCurrency:"usd",cryptoToken:"USDC",inventoryStatus:"in_stock",compareAtUsd:"",tagsCsv:"",categoryIdsCsv:"",checkoutEmail:"required",checkoutName:"optional",checkoutPhone:"none",checkoutShippingAddress:!1,checkoutBillingAddress:!1,fulfillmentType:"shipping",fulfillmentNotes:"",shippingCountriesCsv:"",inventoryQuantity:""}),d(!1),E()}catch(N){g(N instanceof Error?N.message:"Failed to create product")}finally{u(!1)}}},F=A=>`$${(A/100).toFixed(2)}`,M=A=>{switch(A){case"subscription":return"Subscription";case"pay_per_access":return"Pay per access";case"one_time":return"One-time purchase";default:return"One-time purchase"}},U=k.useMemo(()=>{const A=o.filter(Z=>Z.active).length,N=o.reduce((Z,te)=>{const re=te.variations?.length??0;return Z+(re>0?re:1)},0);return{activeCount:A,totalSkus:N}},[o]),D=A=>{v(N=>!N||N.key!==A?{key:A,direction:"asc"}:{key:A,direction:N.direction==="asc"?"desc":"asc"})},H=A=>!p||p.key!==A?s.jsx("span",{className:"cedros-admin__sort-icon cedros-admin__sort-icon--idle",children:Y.chevronUp}):s.jsx("span",{className:"cedros-admin__sort-icon",children:p.direction==="asc"?Y.chevronUp:Y.chevronDown}),z=k.useMemo(()=>{if(!p)return o;const A=p.direction==="asc"?1:-1,N=Z=>{switch(p.key){case"product":return I(Z);case"type":return M(Z.metadata?.product_type);case"price":return Z.fiatAmountCents??0;case"status":return Z.active?1:0;case"id":default:return Z.id}};return[...o].sort((Z,te)=>{const re=N(Z),de=N(te);return typeof re=="number"&&typeof de=="number"?(re-de)*A:String(re).localeCompare(String(de),void 0,{sensitivity:"base"})*A})},[o,p]);return s.jsxs("div",{className:"cedros-admin__page",children:[s.jsx(jr,{message:_,onRetry:E}),s.jsx(Sr,{stats:[{label:"Total Products",value:o.length},{label:"Active",value:U.activeCount,variant:U.activeCount>0?"success":"muted"},{label:"Total SKUs",value:U.totalSkus}],isLoading:i}),s.jsxs("div",{className:"cedros-admin__section-header",children:[s.jsx("h3",{className:"cedros-admin__section-title",children:"Paywall Products"}),s.jsxs("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--action",onClick:()=>{g(null),d(!l)},children:[l?Y.close:Y.plus,l?"Cancel":"Add Product"]})]}),l&&s.jsxs("form",{onSubmit:O,className:"cedros-admin__add-form",children:[h&&s.jsx("div",{style:{marginBottom:"0.75rem",color:"#B42318",fontWeight:600},children:h}),s.jsxs("div",{className:"cedros-admin__form-row",children:[s.jsxs("div",{className:"cedros-admin__field",children:[s.jsx("label",{className:"cedros-admin__field-label",children:"Product ID"}),s.jsx("input",{type:"text",className:"cedros-admin__input",value:b.id,onChange:A=>j(N=>({...N,id:A.target.value})),placeholder:"e.g., premium-article",required:!0})]}),s.jsxs("div",{className:"cedros-admin__field",children:[s.jsx("label",{className:"cedros-admin__field-label",children:"Product name"}),s.jsx("input",{type:"text",className:"cedros-admin__input",value:b.title,onChange:A=>j(N=>({...N,title:A.target.value})),placeholder:"e.g., Cedros Hoodie"})]})]}),s.jsxs("div",{className:"cedros-admin__form-row",children:[s.jsxs("div",{className:"cedros-admin__field",children:[s.jsx("label",{className:"cedros-admin__field-label",children:"Slug"}),s.jsx("input",{type:"text",className:"cedros-admin__input",value:b.slug,onChange:A=>j(N=>({...N,slug:A.target.value})),placeholder:"e.g., cedros-hoodie (defaults to ID)"})]}),s.jsxs("div",{className:"cedros-admin__field",children:[s.jsx("label",{className:"cedros-admin__field-label",children:"Primary image URL"}),s.jsx("input",{type:"url",className:"cedros-admin__input",value:b.imageUrl,onChange:A=>j(N=>({...N,imageUrl:A.target.value})),placeholder:"https://..."})]})]}),s.jsx("div",{className:"cedros-admin__form-row",children:s.jsxs("div",{className:"cedros-admin__field",children:[s.jsx("label",{className:"cedros-admin__field-label",children:"Short description"}),s.jsx("input",{type:"text",className:"cedros-admin__input",value:b.description,onChange:A=>j(N=>({...N,description:A.target.value})),placeholder:"e.g., Midweight fleece with relaxed fit",required:!0})]})}),s.jsxs("div",{className:"cedros-admin__form-row",children:[s.jsx(At,{value:b.productType,onChange:A=>j(N=>({...N,productType:A})),options:[{value:"one_time",label:"One-time purchase"},{value:"pay_per_access",label:"Pay per access"},{value:"subscription",label:"Subscription"}],label:"Product Type"}),s.jsx(At,{value:b.fulfillmentType,onChange:A=>{const N=A;j(Z=>({...Z,fulfillmentType:N,checkoutShippingAddress:N==="shipping"?Z.checkoutShippingAddress:!1}))},options:[{value:"shipping",label:"Physical (shipped)"},{value:"digital_download",label:"Digital download"},{value:"service",label:"Service"}],label:"Fulfillment"})]}),b.fulfillmentType==="shipping"&&s.jsxs("div",{className:"cedros-admin__form-row",children:[s.jsx(At,{value:b.inventoryStatus,onChange:A=>j(N=>({...N,inventoryStatus:A})),options:[{value:"in_stock",label:"In stock"},{value:"low",label:"Low"},{value:"out_of_stock",label:"Out of stock"},{value:"backorder",label:"Backorder"}],label:"Inventory status"}),s.jsxs("div",{className:"cedros-admin__field",children:[s.jsx("label",{className:"cedros-admin__field-label",children:"Inventory quantity (tracked)"}),s.jsx("input",{type:"number",className:"cedros-admin__input",value:b.inventoryQuantity,onChange:A=>j(N=>({...N,inventoryQuantity:A.target.value===""?"":parseInt(A.target.value)||0})),placeholder:"Leave blank for untracked",min:"0"})]}),s.jsxs("div",{className:"cedros-admin__field",children:[s.jsx("label",{className:"cedros-admin__field-label",children:"Compare-at price (USD)"}),s.jsx("input",{type:"number",className:"cedros-admin__input",value:b.compareAtUsd===""?"":b.compareAtUsd,onChange:A=>j(N=>({...N,compareAtUsd:A.target.value===""?"":parseFloat(A.target.value)||0})),placeholder:"e.g., 78.00",min:"0",step:"0.01"})]})]}),s.jsx("div",{className:"cedros-admin__form-row",children:s.jsxs("div",{className:"cedros-admin__field",children:[s.jsx("label",{className:"cedros-admin__field-label",children:"Price (USD)"}),s.jsx("input",{type:"number",className:"cedros-admin__input",value:b.priceUsd===""?"":b.priceUsd,onChange:A=>j(N=>({...N,priceUsd:A.target.value===""?"":parseFloat(A.target.value)||0})),placeholder:"e.g., 5.00",min:"0",step:"0.01",required:!0})]})}),s.jsxs("div",{className:"cedros-admin__form-row",children:[s.jsxs("div",{className:"cedros-admin__field",children:[s.jsx("label",{className:"cedros-admin__field-label",children:"Tags (comma-separated)"}),s.jsx("input",{type:"text",className:"cedros-admin__input",value:b.tagsCsv,onChange:A=>j(N=>({...N,tagsCsv:A.target.value})),placeholder:"e.g., core, new, gift"})]}),s.jsxs("div",{className:"cedros-admin__field",children:[s.jsx("label",{className:"cedros-admin__field-label",children:"Category IDs (comma-separated)"}),s.jsx("input",{type:"text",className:"cedros-admin__input",value:b.categoryIdsCsv,onChange:A=>j(N=>({...N,categoryIdsCsv:A.target.value})),placeholder:"e.g., cat_apparel, cat_accessories"})]})]}),s.jsxs("div",{className:"cedros-admin__form-row",children:[s.jsx(At,{value:b.checkoutEmail,onChange:A=>j(N=>({...N,checkoutEmail:A})),options:[{value:"none",label:"None"},{value:"optional",label:"Optional"},{value:"required",label:"Required"}],label:"Checkout: Email"}),s.jsx(At,{value:b.checkoutName,onChange:A=>j(N=>({...N,checkoutName:A})),options:[{value:"none",label:"None"},{value:"optional",label:"Optional"},{value:"required",label:"Required"}],label:"Checkout: Name"}),s.jsx(At,{value:b.checkoutPhone,onChange:A=>j(N=>({...N,checkoutPhone:A})),options:[{value:"none",label:"None"},{value:"optional",label:"Optional"},{value:"required",label:"Required"}],label:"Checkout: Phone"})]}),s.jsxs("div",{className:"cedros-admin__form-row",children:[b.fulfillmentType==="shipping"&&s.jsxs("div",{className:"cedros-admin__field",children:[s.jsx("label",{className:"cedros-admin__field-label",children:"Checkout: Shipping address"}),s.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[s.jsx("input",{type:"checkbox",checked:b.checkoutShippingAddress,onChange:A=>j(N=>({...N,checkoutShippingAddress:A.target.checked}))}),"Collect shipping address"]})]}),s.jsxs("div",{className:"cedros-admin__field",children:[s.jsx("label",{className:"cedros-admin__field-label",children:"Checkout: Billing address"}),s.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[s.jsx("input",{type:"checkbox",checked:b.checkoutBillingAddress,onChange:A=>j(N=>({...N,checkoutBillingAddress:A.target.checked}))}),"Collect billing address"]})]})]}),s.jsx("div",{className:"cedros-admin__form-row",children:s.jsxs("div",{className:"cedros-admin__field",children:[s.jsx("label",{className:"cedros-admin__field-label",children:"Fulfillment notes"}),s.jsx("input",{type:"text",className:"cedros-admin__input",value:b.fulfillmentNotes,onChange:A=>j(N=>({...N,fulfillmentNotes:A.target.value})),placeholder:b.fulfillmentType==="shipping"?"e.g., Ships within 3-5 business days":"e.g., Downloadable from your account after purchase"})]})}),b.fulfillmentType==="shipping"&&b.checkoutShippingAddress&&s.jsx("div",{className:"cedros-admin__form-row",children:s.jsxs("div",{className:"cedros-admin__field",children:[s.jsx("label",{className:"cedros-admin__field-label",children:"Shipping countries"}),s.jsx("input",{type:"text",className:"cedros-admin__input",value:b.shippingCountriesCsv,onChange:A=>j(N=>({...N,shippingCountriesCsv:A.target.value})),placeholder:"e.g., US,CA"}),s.jsx("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:"ISO 2-letter country codes, comma-separated. Required for shipping address collection."})]})}),s.jsx("div",{className:"cedros-admin__form-actions",children:s.jsx("button",{type:"submit",className:"cedros-admin__button cedros-admin__button--primary",disabled:f,children:f?"Creating...":"Create Product"})})]}),i?s.jsxs("div",{className:"cedros-admin__loading",children:[Y.loading," Loading products..."]}):s.jsx("div",{className:"cedros-admin__table-container",children:s.jsxs("table",{className:"cedros-admin__table",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{"aria-sort":p?.key==="id"?p?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>D("id"),children:["ID",H("id")]})}),s.jsx("th",{"aria-sort":p?.key==="product"?p?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>D("product"),children:["Product",H("product")]})}),s.jsx("th",{"aria-sort":p?.key==="type"?p?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>D("type"),children:["Type",H("type")]})}),s.jsx("th",{"aria-sort":p?.key==="price"?p?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>D("price"),children:["Price",H("price")]})}),s.jsx("th",{"aria-sort":p?.key==="status"?p?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>D("status"),children:["Status",H("status")]})}),s.jsx("th",{children:"Actions"})]})}),s.jsx("tbody",{children:z.map(A=>s.jsxs("tr",{children:[s.jsx("td",{children:s.jsx("code",{children:A.id})}),s.jsx("td",{children:s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[C(A)?s.jsx("img",{src:C(A),alt:"",style:{width:28,height:28,borderRadius:6,objectFit:"cover"}}):s.jsx("div",{style:{width:28,height:28,borderRadius:6,background:"rgba(0,0,0,0.06)"}}),s.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[s.jsx("span",{style:{fontWeight:600},children:I(A)}),s.jsx("span",{style:{opacity:.8},children:A.description})]})]})}),s.jsx("td",{children:M(A.metadata?.product_type)}),s.jsx("td",{children:F(A.fiatAmountCents)}),s.jsx("td",{children:s.jsx("span",{className:`cedros-admin__badge ${A.active?"cedros-admin__badge--success":"cedros-admin__badge--muted"}`,children:A.active?"Active":"Inactive"})}),s.jsx("td",{children:s.jsx("div",{style:{display:"flex",gap:"0.25rem"},children:s.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>x(A),children:"Variations"})})})]},A.id))})]})}),y&&s.jsx("div",{className:"cedros-admin__modal-overlay",onClick:()=>x(null),children:s.jsx("div",{className:"cedros-admin__modal cedros-admin__modal--lg",onClick:A=>A.stopPropagation(),children:s.jsx(qf,{serverUrl:e,productId:y.id,productTitle:I(y),defaultPrice:y.fiatAmountCents/100,apiKey:t,authManager:r,onClose:()=>x(null)})})})]})}function Oc({serverUrl:e,apiKey:t,pageSize:n=20,authManager:r}){const[o,a]=k.useState([]),[i,c]=k.useState(null),[l,d]=k.useState(!0),[f,u]=k.useState(!0),[h,g]=k.useState(null),[y,x]=k.useState(""),[p,v]=k.useState(null),_=k.useCallback(async()=>{u(!0);try{g(null);let C;if(r?.isAuthenticated())C=await r.fetchWithAuth("/admin/stats");else{const E={"Content-Type":"application/json"};t&&(E["X-API-Key"]=t);const O=await fetch(`${e}/admin/stats`,{headers:E});if(!O.ok)throw new Error(`Failed to fetch stats: ${O.status}`);C=await O.json()}c(C)}catch{c(null),g("Failed to load payment stats")}finally{u(!1)}},[e,t,r]);k.useEffect(()=>{_()},[_]);const w=k.useCallback(async()=>{try{g(null);let C;const E=new URLSearchParams({limit:n.toString()});y&&E.set("method",y);const O=`/admin/transactions?${E}`;if(r?.isAuthenticated())C=await r.fetchWithAuth(O);else{const F={"Content-Type":"application/json"};t&&(F["X-API-Key"]=t);const M=await fetch(`${e}${O}`,{headers:F});if(!M.ok)throw new Error(`Failed to fetch transactions: ${M.status}`);C=await M.json()}a(C.transactions||[])}catch{a([]),g("Failed to load transactions")}finally{d(!1)}},[e,t,n,y,r]);k.useEffect(()=>{w()},[w]);const b=(C,E="USD")=>new Intl.NumberFormat("en-US",{style:"currency",currency:E}).format(C),j=C=>{v(E=>!E||E.key!==C?{key:C,direction:"asc"}:{key:C,direction:E.direction==="asc"?"desc":"asc"})},R=C=>!p||p.key!==C?s.jsx("span",{className:"cedros-admin__sort-icon cedros-admin__sort-icon--idle",children:Y.chevronUp}):s.jsx("span",{className:"cedros-admin__sort-icon",children:p.direction==="asc"?Y.chevronUp:Y.chevronDown}),I=k.useMemo(()=>{if(!p)return o;const C=p.direction==="asc"?1:-1,E=O=>{switch(p.key){case"resource":return O.resourceId;case"method":return O.method;case"amount":return O.amount;case"status":return O.status;case"date":return new Date(O.paidAt).getTime();case"id":default:return O.id}};return[...o].sort((O,F)=>{const M=E(O),U=E(F);return typeof M=="number"&&typeof U=="number"?(M-U)*C:String(M).localeCompare(String(U),void 0,{sensitivity:"base"})*C})},[o,p]);return s.jsxs("div",{className:"cedros-admin__page",children:[s.jsx(jr,{message:h,onRetry:()=>{_(),w()}}),s.jsx(Sr,{stats:[{label:"Revenue",value:b(i?.totalRevenue??0)},{label:"Orders",value:i?.totalTransactions??0},{label:"Card",value:b(i?.revenueByMethod.stripe??0),description:`${i?.transactionsByMethod.stripe??0} orders`},{label:"Crypto",value:b(i?.revenueByMethod.x402??0),description:`${i?.transactionsByMethod.x402??0} orders`},{label:"Credits",value:b(i?.revenueByMethod.credits??0),description:`${i?.transactionsByMethod.credits??0} orders`}],isLoading:f,onRefresh:_}),s.jsxs("div",{className:"cedros-admin__section-header",children:[s.jsx("h3",{className:"cedros-admin__section-title",children:"Transaction History"}),s.jsx(Pc,{value:y,onChange:x,options:[{value:"",label:"All"},{value:"stripe",label:"Card"},{value:"x402",label:"Crypto"},{value:"credits",label:"Credits"}]})]}),l?s.jsxs("div",{className:"cedros-admin__loading",children:[Y.loading," Loading transactions..."]}):s.jsx("div",{className:"cedros-admin__table-container",children:s.jsxs("table",{className:"cedros-admin__table",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{"aria-sort":p?.key==="id"?p?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>j("id"),children:["ID",R("id")]})}),s.jsx("th",{"aria-sort":p?.key==="resource"?p?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>j("resource"),children:["Resource",R("resource")]})}),s.jsx("th",{"aria-sort":p?.key==="method"?p?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>j("method"),children:["Method",R("method")]})}),s.jsx("th",{"aria-sort":p?.key==="amount"?p?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>j("amount"),children:["Amount",R("amount")]})}),s.jsx("th",{"aria-sort":p?.key==="status"?p?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>j("status"),children:["Status",R("status")]})}),s.jsx("th",{"aria-sort":p?.key==="date"?p?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>j("date"),children:["Date",R("date")]})})]})}),s.jsx("tbody",{children:I.map(C=>s.jsxs("tr",{children:[s.jsx("td",{children:s.jsx("code",{children:C.id})}),s.jsx("td",{children:C.resourceId}),s.jsx("td",{children:s.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${C.method}`,children:C.method})}),s.jsxs("td",{children:["$",C.amount.toFixed(2)," ",C.currency.toUpperCase()]}),s.jsx("td",{children:s.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${C.status}`,children:C.status})}),s.jsx("td",{children:lr(C.paidAt)})]},C.id))})]})})]})}function Mc({serverUrl:e,apiKey:t,pageSize:n=20,authManager:r}){const[o,a]=k.useState([]),[i,c]=k.useState(!0),[l,d]=k.useState(!1),[f,u]=k.useState(!1),[h,g]=k.useState(null),[y,x]=k.useState(null),[p,v]=k.useState({code:"",discountType:"percentage",discountValue:0,usageLimit:void 0,expiresAt:"",scope:"all_products",productIdsCsv:"",categoryIdsCsv:"",paymentMethod:"any",autoApply:!1,appliesAt:"both",startsAt:"",minimumAmountUsd:"",usageLimitPerCustomer:void 0,firstPurchaseOnly:!1}),_=k.useCallback(async()=>{try{x(null);let E;const O=`/admin/coupons?limit=${n}`;if(r?.isAuthenticated())E=await r.fetchWithAuth(O);else{const F={"Content-Type":"application/json"};t&&(F["X-API-Key"]=t);const M=await fetch(`${e}${O}`,{headers:F});if(!M.ok)throw new Error(`Failed to fetch coupons: ${M.status}`);E=await M.json()}a(E.coupons||[])}catch(E){Je.getLogger().error("[CouponsSection] Failed to fetch coupons:",E,{serverUrl:e.slice(0,20)+"...",hasApiKey:!!t}),a([]),x("Failed to load coupons")}finally{c(!1)}},[e,t,n,r]);k.useEffect(()=>{_()},[_]);const w=async E=>{if(E.preventDefault(),!(!p.code||p.discountValue<=0)){u(!0);try{const O=p.minimumAmountUsd?Math.round(Number(p.minimumAmountUsd)*100):void 0,F=p.productIdsCsv.split(",").map(D=>D.trim()).filter(Boolean),M=p.categoryIdsCsv.split(",").map(D=>D.trim()).filter(Boolean),U={code:p.code,discountType:p.discountType,discountValue:p.discountValue,usageLimit:p.usageLimit,active:!0,usageCount:0,scope:p.scope,...F.length?{productIds:F}:{},...M.length?{categoryIds:M}:{},...p.paymentMethod!=="any"?{paymentMethod:p.paymentMethod}:{},...p.autoApply?{autoApply:!0}:{},...p.appliesAt!=="both"?{appliesAt:p.appliesAt}:{},...p.startsAt?{startsAt:p.startsAt}:{},...p.expiresAt?{expiresAt:p.expiresAt}:{},...O?{minimumAmountCents:O}:{},...p.usageLimitPerCustomer?{usageLimitPerCustomer:p.usageLimitPerCustomer}:{},...p.firstPurchaseOnly?{firstPurchaseOnly:!0}:{}};if(r?.isAuthenticated())await r.fetchWithAuth("/admin/coupons",{method:"POST",body:JSON.stringify(U)});else{const D={"Content-Type":"application/json"};t&&(D["X-API-Key"]=t);const H=await fetch(`${e}/admin/coupons`,{method:"POST",headers:D,body:JSON.stringify(U)});if(!H.ok)throw new Error(`Failed to create coupon: ${H.status}`)}v({code:"",discountType:"percentage",discountValue:0,usageLimit:void 0,expiresAt:"",scope:"all_products",productIdsCsv:"",categoryIdsCsv:"",paymentMethod:"any",autoApply:!1,appliesAt:"both",startsAt:"",minimumAmountUsd:"",usageLimitPerCustomer:void 0,firstPurchaseOnly:!1}),d(!1),_()}catch(O){Je.getLogger().error("[CouponsSection] Failed to add coupon:",O,{serverUrl:e.slice(0,20)+"...",hasApiKey:!!t}),x("Failed to create coupon")}finally{u(!1)}}},b=o.filter(E=>E.active).length,j=o.reduce((E,O)=>E+(O.usageCount??0),0),R=E=>{g(O=>!O||O.key!==E?{key:E,direction:"asc"}:{key:E,direction:O.direction==="asc"?"desc":"asc"})},I=E=>!h||h.key!==E?s.jsx("span",{className:"cedros-admin__sort-icon cedros-admin__sort-icon--idle",children:Y.chevronUp}):s.jsx("span",{className:"cedros-admin__sort-icon",children:h.direction==="asc"?Y.chevronUp:Y.chevronDown}),C=k.useMemo(()=>{if(!h)return o;const E=h.direction==="asc"?1:-1,O=F=>{switch(h.key){case"discount":return F.discountValue??0;case"usage":return F.usageCount??0;case"status":return F.active?1:0;case"code":default:return F.code}};return[...o].sort((F,M)=>{const U=O(F),D=O(M);return typeof U=="number"&&typeof D=="number"?(U-D)*E:String(U).localeCompare(String(D),void 0,{sensitivity:"base"})*E})},[o,h]);return s.jsxs("div",{className:"cedros-admin__page",children:[s.jsx(jr,{message:y,onRetry:_}),s.jsx(Sr,{stats:[{label:"Total Coupons",value:o.length},{label:"Active",value:b,variant:b>0?"success":"muted"},{label:"Redemptions",value:j}],isLoading:i}),s.jsxs("div",{className:"cedros-admin__section-header",children:[s.jsx("h3",{className:"cedros-admin__section-title",children:"Discount Coupons"}),s.jsxs("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--action",onClick:()=>d(!l),children:[l?Y.close:Y.plus,l?"Cancel":"Add Coupon"]})]}),l&&s.jsxs("form",{onSubmit:w,className:"cedros-admin__add-form",children:[s.jsxs("div",{className:"cedros-admin__form-row",children:[s.jsxs("div",{className:"cedros-admin__field",children:[s.jsx("label",{className:"cedros-admin__field-label",children:"Coupon Code"}),s.jsx("input",{type:"text",className:"cedros-admin__input",value:p.code,onChange:E=>v(O=>({...O,code:E.target.value.toUpperCase()})),placeholder:"e.g., SAVE20",required:!0})]}),s.jsx(At,{value:p.discountType,onChange:E=>v(O=>({...O,discountType:E})),options:[{value:"percentage",label:"Percentage (%)"},{value:"fixed",label:"Fixed Amount ($)"}],label:"Discount Type"})]}),s.jsxs("div",{className:"cedros-admin__form-row",children:[s.jsxs("div",{className:"cedros-admin__field",children:[s.jsxs("label",{className:"cedros-admin__field-label",children:["Discount Value ",p.discountType==="percentage"?"(%)":"($)"]}),s.jsx("input",{type:"number",className:"cedros-admin__input",value:p.discountValue||"",onChange:E=>v(O=>({...O,discountValue:parseFloat(E.target.value)||0})),placeholder:p.discountType==="percentage"?"e.g., 20":"e.g., 10.00",min:"0",step:p.discountType==="percentage"?"1":"0.01",required:!0})]}),s.jsxs("div",{className:"cedros-admin__field",children:[s.jsx("label",{className:"cedros-admin__field-label",children:"Usage Limit (optional)"}),s.jsx("input",{type:"number",className:"cedros-admin__input",value:p.usageLimit||"",onChange:E=>v(O=>({...O,usageLimit:E.target.value?parseInt(E.target.value):void 0})),placeholder:"Leave empty for unlimited",min:"1"})]}),s.jsxs("div",{className:"cedros-admin__field",children:[s.jsx("label",{className:"cedros-admin__field-label",children:"Expiration Date (optional)"}),s.jsx("input",{type:"date",className:"cedros-admin__input",value:p.expiresAt,onChange:E=>v(O=>({...O,expiresAt:E.target.value}))})]})]}),s.jsxs("div",{className:"cedros-admin__form-row",children:[s.jsx(At,{value:p.scope,onChange:E=>v(O=>({...O,scope:E})),options:[{value:"all_products",label:"All Products"},{value:"specific_products",label:"Specific Products"},{value:"specific_categories",label:"Specific Categories"}],label:"Scope"}),s.jsx(At,{value:p.paymentMethod,onChange:E=>v(O=>({...O,paymentMethod:E})),options:[{value:"any",label:"Any Payment Method"},{value:"stripe",label:"Stripe (Card) Only"},{value:"x402",label:"Crypto (x402) Only"},{value:"credits",label:"Credits Only"}],label:"Payment Method"}),s.jsx(At,{value:p.appliesAt,onChange:E=>v(O=>({...O,appliesAt:E})),options:[{value:"both",label:"Cart & Checkout"},{value:"cart",label:"Cart Only"},{value:"checkout",label:"Checkout Only"}],label:"Applies At"})]}),p.scope==="specific_products"&&s.jsx("div",{className:"cedros-admin__form-row",children:s.jsxs("div",{className:"cedros-admin__field",style:{flex:1},children:[s.jsx("label",{className:"cedros-admin__field-label",children:"Product IDs"}),s.jsx("input",{type:"text",className:"cedros-admin__input",value:p.productIdsCsv,onChange:E=>v(O=>({...O,productIdsCsv:E.target.value})),placeholder:"e.g., prod_123, prod_456"}),s.jsx("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:"Comma-separated product IDs this coupon applies to."})]})}),s.jsxs("div",{className:"cedros-admin__form-row",children:[s.jsxs("div",{className:"cedros-admin__field",children:[s.jsx("label",{className:"cedros-admin__field-label",children:"Start Date (optional)"}),s.jsx("input",{type:"date",className:"cedros-admin__input",value:p.startsAt,onChange:E=>v(O=>({...O,startsAt:E.target.value}))})]}),s.jsxs("div",{className:"cedros-admin__field",children:[s.jsx("label",{className:"cedros-admin__field-label",children:"Auto Apply"}),s.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[s.jsx("input",{type:"checkbox",checked:p.autoApply,onChange:E=>v(O=>({...O,autoApply:E.target.checked}))}),"Automatically apply when conditions met"]})]})]}),s.jsxs("div",{className:"cedros-admin__form-row",children:[s.jsxs("div",{className:"cedros-admin__field",children:[s.jsx("label",{className:"cedros-admin__field-label",children:"Minimum Purchase (USD)"}),s.jsx("input",{type:"number",className:"cedros-admin__input",value:p.minimumAmountUsd===""?"":p.minimumAmountUsd,onChange:E=>v(O=>({...O,minimumAmountUsd:E.target.value===""?"":parseFloat(E.target.value)||0})),placeholder:"e.g., 50.00",min:"0",step:"0.01"})]}),s.jsxs("div",{className:"cedros-admin__field",children:[s.jsx("label",{className:"cedros-admin__field-label",children:"Per-Customer Limit"}),s.jsx("input",{type:"number",className:"cedros-admin__input",value:p.usageLimitPerCustomer||"",onChange:E=>v(O=>({...O,usageLimitPerCustomer:E.target.value?parseInt(E.target.value):void 0})),placeholder:"Leave empty for unlimited",min:"1"})]}),s.jsxs("div",{className:"cedros-admin__field",children:[s.jsx("label",{className:"cedros-admin__field-label",children:"First Purchase Only"}),s.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[s.jsx("input",{type:"checkbox",checked:p.firstPurchaseOnly,onChange:E=>v(O=>({...O,firstPurchaseOnly:E.target.checked}))}),"New customers only"]})]})]}),p.scope==="specific_categories"&&s.jsx("div",{className:"cedros-admin__form-row",children:s.jsxs("div",{className:"cedros-admin__field",style:{flex:1},children:[s.jsx("label",{className:"cedros-admin__field-label",children:"Category IDs"}),s.jsx("input",{type:"text",className:"cedros-admin__input",value:p.categoryIdsCsv,onChange:E=>v(O=>({...O,categoryIdsCsv:E.target.value})),placeholder:"e.g., cat_apparel, cat_accessories"}),s.jsx("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:"Comma-separated category IDs this coupon applies to."})]})}),s.jsx("div",{className:"cedros-admin__form-actions",children:s.jsx("button",{type:"submit",className:"cedros-admin__button cedros-admin__button--primary",disabled:f,children:f?"Creating...":"Create Coupon"})})]}),i?s.jsxs("div",{className:"cedros-admin__loading",children:[Y.loading," Loading coupons..."]}):s.jsx("div",{className:"cedros-admin__table-container",children:s.jsxs("table",{className:"cedros-admin__table",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{"aria-sort":h?.key==="code"?h?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>R("code"),children:["Code",I("code")]})}),s.jsx("th",{"aria-sort":h?.key==="discount"?h?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>R("discount"),children:["Discount",I("discount")]})}),s.jsx("th",{"aria-sort":h?.key==="usage"?h?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>R("usage"),children:["Usage",I("usage")]})}),s.jsx("th",{"aria-sort":h?.key==="status"?h?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>R("status"),children:["Status",I("status")]})}),s.jsx("th",{children:"Actions"})]})}),s.jsx("tbody",{children:C.map(E=>s.jsxs("tr",{children:[s.jsx("td",{children:s.jsx("code",{children:E.code})}),s.jsx("td",{children:E.discountType==="percentage"?`${E.discountValue}%`:`$${E.discountValue.toFixed(2)}`}),s.jsxs("td",{children:[E.usageCount,E.usageLimit?` / ${E.usageLimit}`:""]}),s.jsx("td",{children:s.jsx("span",{className:`cedros-admin__badge ${E.active?"cedros-admin__badge--success":"cedros-admin__badge--muted"}`,children:E.active?"Active":"Inactive"})}),s.jsx("td",{children:s.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",children:"Edit"})})]},E.code))})]})})]})}function Lc({serverUrl:e,apiKey:t,pageSize:n=20,authManager:r}){const[o,a]=k.useState([]),[i,c]=k.useState(!0),[l,d]=k.useState(null),[f,u]=k.useState([]),[h,g]=k.useState(!0),[y,x]=k.useState(null),[p,v]=k.useState(null),[_,w]=k.useState([]),[b,j]=k.useState(!0),[R,I]=k.useState(null),[C,E]=k.useState(null),[O,F]=k.useState(null),[M,U]=k.useState(""),[D,H]=k.useState(null),z=k.useCallback(async()=>{try{let T;const K=`/admin/refunds?limit=${n}`;if(r?.isAuthenticated())T=await r.fetchWithAuth(K);else{const se={"Content-Type":"application/json"};t&&(se["X-API-Key"]=t);const ve=await fetch(`${e}${K}`,{headers:se});if(!ve.ok)throw new Error(`Failed to fetch x402 refunds: ${ve.status}`);T=await ve.json()}a(T.refunds||[])}catch(T){Je.getLogger().error("[RefundsSection] Failed to fetch x402 refunds:",T,{serverUrl:e.slice(0,20)+"...",hasApiKey:!!t}),a([]),H("Failed to load x402 refunds")}finally{c(!1)}},[e,t,n,r]);k.useEffect(()=>{z()},[z]);const A=k.useCallback(async()=>{try{let T;const K=`/admin/credits/refund-requests?status=pending&limit=${n}&offset=0`;if(r?.isAuthenticated())T=await r.fetchWithAuth(K);else{const ve={"Content-Type":"application/json"};t&&(ve["X-API-Key"]=t);const ye=await fetch(`${e}${K}`,{headers:ve});if(!ye.ok)throw new Error(`Failed to fetch credits refund requests: ${ye.status}`);T=await ye.json()}const se=Array.isArray(T)?T:"refundRequests"in T?T.refundRequests:T.requests||[];u(se)}catch(T){Je.getLogger().error("[RefundsSection] Failed to fetch credits refunds:",T,{serverUrl:e.slice(0,20)+"...",hasApiKey:!!t}),u([]),H("Failed to load credits refunds")}finally{g(!1)}},[e,t,n,r]);k.useEffect(()=>{A()},[A]);const N=async T=>{x(T.id);try{const K=`/admin/credits/refund-requests/${T.id}/process`,se=JSON.stringify({amountLamports:T.amountLamports,reason:T.reason});if(r?.isAuthenticated())await r.fetchWithAuth(K,{method:"POST",body:se});else{const ve={"Content-Type":"application/json"};t&&(ve["X-API-Key"]=t);const ye=await fetch(`${e}${K}`,{method:"POST",headers:ve,body:se});if(!ye.ok)throw new Error(`Failed to process credits refund: ${ye.status}`)}await A()}catch(K){Je.getLogger().error("[RefundsSection] Failed to process credits refund:",K,{serverUrl:e.slice(0,20)+"...",hasApiKey:!!t,requestId:T.id}),H("Failed to process credits refund")}finally{x(null)}},Z=T=>{U(T.reason??""),F(T)},te=()=>{F(null),U("")},re=async()=>{if(!O)return;const T=O,K=M;te(),x(T.id);try{const se=`/admin/credits/refund-requests/${T.id}/reject`,ve=JSON.stringify({reason:K});if(r?.isAuthenticated())await r.fetchWithAuth(se,{method:"POST",body:ve});else{const ye={"Content-Type":"application/json"};t&&(ye["X-API-Key"]=t);const Pe=await fetch(`${e}${se}`,{method:"POST",headers:ye,body:ve});if(!Pe.ok)throw new Error(`Failed to reject credits refund: ${Pe.status}`)}await A()}catch(se){Je.getLogger().error("[RefundsSection] Failed to reject credits refund:",se,{serverUrl:e.slice(0,20)+"...",hasApiKey:!!t,requestId:T.id}),H("Failed to reject credits refund")}finally{x(null)}},de=k.useCallback(async()=>{try{let T;const K=`/admin/stripe/refunds?limit=${n}`;if(r?.isAuthenticated())T=await r.fetchWithAuth(K);else{const se={"Content-Type":"application/json"};t&&(se["X-API-Key"]=t);const ve=await fetch(`${e}${K}`,{headers:se});if(!ve.ok)throw new Error(`Failed to fetch Stripe refunds: ${ve.status}`);T=await ve.json()}w(T.refunds||[])}catch(T){Je.getLogger().error("[RefundsSection] Failed to fetch Stripe refunds:",T,{serverUrl:e.slice(0,20)+"...",hasApiKey:!!t}),w([]),H("Failed to load Stripe refunds")}finally{j(!1)}},[e,t,n,r]);k.useEffect(()=>{de()},[de]);const W=async T=>{I(T);try{const K=`/admin/stripe/refunds/${T}/process`;if(r?.isAuthenticated())await r.fetchWithAuth(K,{method:"POST"});else{const se={"Content-Type":"application/json"};t&&(se["X-API-Key"]=t);const ve=await fetch(`${e}${K}`,{method:"POST",headers:se});if(!ve.ok)throw new Error(`Failed to process refund: ${ve.status}`)}await de()}catch(K){Je.getLogger().error("[RefundsSection] Failed to process Stripe refund:",K,{serverUrl:e.slice(0,20)+"...",hasApiKey:!!t,refundId:T}),H("Failed to process Stripe refund")}finally{I(null)}},Q=(T,K)=>new Intl.NumberFormat("en-US",{style:"currency",currency:K}).format(T/100),q=T=>T?T.replace(/_/g," ").replace(/\b\w/g,K=>K.toUpperCase()):"—",he=T=>{switch(T){case"processed":return"success";case"pending":return"pending";case"rejected":default:return"muted"}},P=(T,K)=>K?K.toLowerCase()==="usd"?`${new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(T/1e6)} (USD credits)`:`${T.toLocaleString()} ${K.toUpperCase()} (atomic)`:`${T.toLocaleString()} (atomic)`,G=T=>{switch(T){case"succeeded":return"success";case"failed":return"failed";case"pending":case"requires_action":return"pending";case"canceled":default:return"muted"}},ue=T=>T.stripeRefundId??"—",B=T=>T.chargeId??"—",ae=_.filter(T=>T.status==="pending"||T.status==="requires_action").length,ce=f.filter(T=>T.status==="pending").length,we=o.filter(T=>T.status==="pending").length,Te=ae+ce+we,Ve=_.filter(T=>T.status==="succeeded").reduce((T,K)=>T+K.amount,0),Ge=f.filter(T=>T.status==="processed").reduce((T,K)=>T+K.amountLamports,0),We=o.filter(T=>T.status==="completed").reduce((T,K)=>T+K.amount,0),_t=Ve/100+Ge/1e6+We,Ye=T=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(T),en=b||h||i,xt=T=>{E(K=>!K||K.key!==T?{key:T,direction:"asc"}:{key:T,direction:K.direction==="asc"?"desc":"asc"})},je=T=>{v(K=>!K||K.key!==T?{key:T,direction:"asc"}:{key:T,direction:K.direction==="asc"?"desc":"asc"})},Xe=T=>{d(K=>!K||K.key!==T?{key:T,direction:"asc"}:{key:T,direction:K.direction==="asc"?"desc":"asc"})},_e=(T,K)=>!T||!K?s.jsx("span",{className:"cedros-admin__sort-icon cedros-admin__sort-icon--idle",children:Y.chevronUp}):s.jsx("span",{className:"cedros-admin__sort-icon",children:K==="asc"?Y.chevronUp:Y.chevronDown}),Zt=k.useMemo(()=>{if(!C)return _;const T=C.direction==="asc"?1:-1,K=se=>{switch(C.key){case"stripe":return se.stripeRefundId??"";case"charge":return se.chargeId??"";case"amount":return se.amount??0;case"reason":return se.reason??"";case"status":return se.status??"";case"date":return new Date(se.createdAt).getTime();case"id":default:return se.id}};return[..._].sort((se,ve)=>{const ye=K(se),Pe=K(ve);return typeof ye=="number"&&typeof Pe=="number"?(ye-Pe)*T:String(ye).localeCompare(String(Pe),void 0,{sensitivity:"base"})*T})},[_,C]),ft=k.useMemo(()=>{if(!p)return f;const T=p.direction==="asc"?1:-1,K=se=>{switch(p.key){case"original":return se.originalTransactionId??"";case"user":return se.userId??"";case"amount":return se.amountLamports??0;case"reason":return se.reason??"";case"status":return se.status??"";case"date":return new Date(se.createdAt).getTime();case"id":default:return se.id}};return[...f].sort((se,ve)=>{const ye=K(se),Pe=K(ve);return typeof ye=="number"&&typeof Pe=="number"?(ye-Pe)*T:String(ye).localeCompare(String(Pe),void 0,{sensitivity:"base"})*T})},[f,p]),it=k.useMemo(()=>{if(!l)return o;const T=l.direction==="asc"?1:-1,K=se=>{switch(l.key){case"transaction":return se.transactionId??"";case"amount":return se.amount??0;case"reason":return se.reason??"";case"status":return se.status??"";case"date":return new Date(se.createdAt).getTime();case"id":default:return se.id}};return[...o].sort((se,ve)=>{const ye=K(se),Pe=K(ve);return typeof ye=="number"&&typeof Pe=="number"?(ye-Pe)*T:String(ye).localeCompare(String(Pe),void 0,{sensitivity:"base"})*T})},[o,l]);return s.jsxs("div",{className:"cedros-admin__page",children:[s.jsx(jr,{message:D,onRetry:()=>{z(),A(),de()}}),s.jsx(Sr,{stats:[{label:"Pending",value:Te,variant:Te>0?"warning":"muted"},{label:"Card Pending",value:ae,description:"Stripe"},{label:"Credits Pending",value:ce},{label:"Crypto Pending",value:we,description:"x402"},{label:"Total Refunded",value:Ye(_t),variant:"success"}],isLoading:en}),s.jsx("div",{className:"cedros-admin__section-header",children:s.jsx("h3",{className:"cedros-admin__section-title",children:"Stripe Refund Requests"})}),b?s.jsxs("div",{className:"cedros-admin__loading",children:[Y.loading," Loading Stripe refunds..."]}):_.length===0?s.jsx("div",{className:"cedros-admin__empty",children:"No Stripe refund requests found."}):s.jsx("div",{className:"cedros-admin__table-container",children:s.jsxs("table",{className:"cedros-admin__table",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{"aria-sort":C?.key==="id"?C?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>xt("id"),children:["Request ID",_e(C?.key==="id",C?.direction)]})}),s.jsx("th",{"aria-sort":C?.key==="stripe"?C?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>xt("stripe"),children:["Stripe Refund ID",_e(C?.key==="stripe",C?.direction)]})}),s.jsx("th",{"aria-sort":C?.key==="charge"?C?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>xt("charge"),children:["Charge",_e(C?.key==="charge",C?.direction)]})}),s.jsx("th",{"aria-sort":C?.key==="amount"?C?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>xt("amount"),children:["Amount",_e(C?.key==="amount",C?.direction)]})}),s.jsx("th",{"aria-sort":C?.key==="reason"?C?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>xt("reason"),children:["Reason",_e(C?.key==="reason",C?.direction)]})}),s.jsx("th",{"aria-sort":C?.key==="status"?C?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>xt("status"),children:["Status",_e(C?.key==="status",C?.direction)]})}),s.jsx("th",{"aria-sort":C?.key==="date"?C?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>xt("date"),children:["Date",_e(C?.key==="date",C?.direction)]})}),s.jsx("th",{children:"Actions"})]})}),s.jsx("tbody",{children:Zt.map(T=>s.jsxs("tr",{children:[s.jsx("td",{children:s.jsx("code",{children:T.id})}),s.jsx("td",{children:s.jsx("code",{children:ue(T)})}),s.jsx("td",{children:s.jsx("code",{children:B(T)})}),s.jsx("td",{children:Q(T.amount,T.currency)}),s.jsx("td",{children:q(T.reason)}),s.jsx("td",{children:s.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${G(T.status)}`,children:T.status})}),s.jsx("td",{children:lr(T.createdAt)}),s.jsx("td",{children:(T.status==="pending"||T.status==="requires_action")&&s.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--sm",onClick:()=>W(T.id),disabled:R===T.id,children:R===T.id?"Processing...":"Process"})})]},T.id))})]})}),s.jsx("div",{className:"cedros-admin__section-header",style:{marginTop:"2rem"},children:s.jsx("h3",{className:"cedros-admin__section-title",children:"Credits Refund Requests"})}),h?s.jsxs("div",{className:"cedros-admin__loading",children:[Y.loading," Loading credits refunds..."]}):f.length===0?s.jsx("div",{className:"cedros-admin__empty",children:"No credits refund requests found."}):s.jsx("div",{className:"cedros-admin__table-container",children:s.jsxs("table",{className:"cedros-admin__table",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{"aria-sort":p?.key==="id"?p?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>je("id"),children:["Request ID",_e(p?.key==="id",p?.direction)]})}),s.jsx("th",{"aria-sort":p?.key==="original"?p?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>je("original"),children:["Original Tx",_e(p?.key==="original",p?.direction)]})}),s.jsx("th",{"aria-sort":p?.key==="user"?p?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>je("user"),children:["User",_e(p?.key==="user",p?.direction)]})}),s.jsx("th",{"aria-sort":p?.key==="amount"?p?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>je("amount"),children:["Amount",_e(p?.key==="amount",p?.direction)]})}),s.jsx("th",{"aria-sort":p?.key==="reason"?p?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>je("reason"),children:["Reason",_e(p?.key==="reason",p?.direction)]})}),s.jsx("th",{"aria-sort":p?.key==="status"?p?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>je("status"),children:["Status",_e(p?.key==="status",p?.direction)]})}),s.jsx("th",{"aria-sort":p?.key==="date"?p?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>je("date"),children:["Date",_e(p?.key==="date",p?.direction)]})}),s.jsx("th",{children:"Actions"})]})}),s.jsx("tbody",{children:ft.map(T=>s.jsxs("tr",{children:[s.jsx("td",{children:s.jsx("code",{children:T.id})}),s.jsx("td",{children:s.jsx("code",{children:T.originalTransactionId})}),s.jsx("td",{children:s.jsx("code",{children:T.userId??"—"})}),s.jsx("td",{children:P(T.amountLamports,T.currency)}),s.jsx("td",{children:T.reason??"—"}),s.jsx("td",{children:s.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${he(T.status)}`,children:T.status})}),s.jsx("td",{children:lr(T.createdAt)}),s.jsx("td",{children:T.status==="pending"?s.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[s.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--sm",onClick:()=>N(T),disabled:y===T.id,children:y===T.id?"Processing...":"Process"}),s.jsx("button",{className:"cedros-admin__button cedros-admin__button--outline cedros-admin__button--danger cedros-admin__button--sm",onClick:()=>Z(T),disabled:y===T.id,children:"Reject"})]}):null})]},T.id))})]})}),s.jsx("div",{className:"cedros-admin__section-header",style:{marginTop:"2rem"},children:s.jsx("h3",{className:"cedros-admin__section-title",children:"x402 Refund Requests"})}),i?s.jsxs("div",{className:"cedros-admin__loading",children:[Y.loading," Loading x402 refunds..."]}):o.length===0?s.jsx("div",{className:"cedros-admin__empty",children:"No x402 refund requests found."}):s.jsx("div",{className:"cedros-admin__table-container",children:s.jsxs("table",{className:"cedros-admin__table",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{"aria-sort":l?.key==="id"?l?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>Xe("id"),children:["ID",_e(l?.key==="id",l?.direction)]})}),s.jsx("th",{"aria-sort":l?.key==="transaction"?l?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>Xe("transaction"),children:["Transaction",_e(l?.key==="transaction",l?.direction)]})}),s.jsx("th",{"aria-sort":l?.key==="amount"?l?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>Xe("amount"),children:["Amount",_e(l?.key==="amount",l?.direction)]})}),s.jsx("th",{"aria-sort":l?.key==="reason"?l?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>Xe("reason"),children:["Reason",_e(l?.key==="reason",l?.direction)]})}),s.jsx("th",{"aria-sort":l?.key==="status"?l?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>Xe("status"),children:["Status",_e(l?.key==="status",l?.direction)]})}),s.jsx("th",{"aria-sort":l?.key==="date"?l?.direction==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>Xe("date"),children:["Date",_e(l?.key==="date",l?.direction)]})}),s.jsx("th",{children:"Actions"})]})}),s.jsx("tbody",{children:it.map(T=>s.jsxs("tr",{children:[s.jsx("td",{children:s.jsx("code",{children:T.id})}),s.jsx("td",{children:s.jsx("code",{children:T.transactionId})}),s.jsxs("td",{children:["$",T.amount.toFixed(2)]}),s.jsx("td",{children:T.reason||"—"}),s.jsx("td",{children:s.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${T.status}`,children:T.status})}),s.jsx("td",{children:lr(T.createdAt)}),s.jsx("td",{})]},T.id))})]})}),O&&s.jsx("div",{className:"cedros-admin__modal-overlay",onClick:te,children:s.jsxs("div",{className:"cedros-admin__modal",onClick:T=>T.stopPropagation(),children:[s.jsxs("div",{className:"cedros-admin__modal-header",children:[s.jsx("h3",{className:"cedros-admin__modal-title",children:"Reject Refund Request"}),s.jsx("button",{type:"button",className:"cedros-admin__modal-close",onClick:te,"aria-label":"Close",children:Y.close})]}),s.jsxs("div",{className:"cedros-admin__modal-body",children:[s.jsxs("p",{style:{marginBottom:"1rem",color:"var(--admin-muted)"},children:["Rejecting refund request ",s.jsx("code",{children:O.id})," for ",P(O.amountLamports,O.currency),"."]}),s.jsxs("label",{className:"cedros-admin__form-field",children:[s.jsx("span",{className:"cedros-admin__form-label",children:"Reason (optional)"}),s.jsx("textarea",{className:"cedros-admin__input",value:M,onChange:T=>U(T.target.value),placeholder:"Enter rejection reason...",rows:3,style:{resize:"vertical"}})]})]}),s.jsxs("div",{className:"cedros-admin__modal-footer",children:[s.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--outline",onClick:te,children:"Cancel"}),s.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--danger",onClick:re,children:"Reject Refund"})]})]})})]})}const Gf=k.lazy(()=>Promise.resolve().then(()=>require("./SettingsSection-DrzGdvHH.js")).then(e=>({default:e.SettingsSection})));function Dc(e){return s.jsx(k.Suspense,{fallback:null,children:s.jsx(Gf,{...e})})}class $c{serverUrl;walletSigner=null;jwtToken=null;isAdminUser=!1;constructor(t){this.serverUrl=t}getAuthMethod(){return this.walletSigner?.publicKey&&this.walletSigner.signMessage?"wallet":this.jwtToken&&this.isAdminUser?"cedros-login":"none"}isAuthenticated(){return this.getAuthMethod()!=="none"}setWalletSigner(t){this.walletSigner=t,Je.getLogger().debug("[AdminAuthManager] Wallet signer updated:",!!t?.publicKey)}setCedrosLoginAuth(t,n){this.jwtToken=t,this.isAdminUser=n??!1,Je.getLogger().debug("[AdminAuthManager] Cedros-login auth updated:",{hasToken:!!t,isAdmin:this.isAdminUser})}async createAuthHeaders(t){const n=this.getAuthMethod();if(n==="wallet")return this.createWalletAuthHeaders(t);if(n==="cedros-login")return this.createJwtAuthHeaders();throw new Error("No admin authentication configured. Connect a wallet or sign in as admin.")}async createWalletAuthHeaders(t){if(!this.walletSigner?.publicKey||!this.walletSigner.signMessage)throw new Error("Wallet not connected or does not support message signing");const n=await this.fetchNonce(t),r=new TextEncoder().encode(n.nonce_id),o=await this.walletSigner.signMessage(r),a=oi.bs58.encode(this.walletSigner.publicKey.toBytes()),i=oi.bs58.encode(o);return{"X-Signer":a,"X-Message":n.nonce_id,"X-Signature":i}}createJwtAuthHeaders(){if(!this.jwtToken)throw new Error("No JWT token available");return{Authorization:`Bearer ${this.jwtToken}`}}async fetchNonce(t){const n=`${this.serverUrl}/paywall/v1/nonce`;Je.getLogger().debug("[AdminAuthManager] Fetching nonce for purpose:",t);const r=await Je.fetchWithTimeout(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({purpose:t})});if(!r.ok){const o=await r.text();throw new Error(`Failed to fetch nonce: ${r.status} ${o}`)}return await r.json()}async fetchWithAuth(t,n={}){if(this.getAuthMethod()==="none")throw new Error("No admin authentication configured");const o=this.getPurposeFromPath(t,n.method||"GET"),a=await this.createAuthHeaders(o),i=(n.method||"GET").toUpperCase(),c={...i!=="GET"&&i!=="HEAD"?{"Content-Type":"application/json"}:{},...n.headers||{},...a},l=await Je.fetchWithTimeout(`${this.serverUrl}${t}`,{...n,headers:c});if(!l.ok){let d=`Admin API error ${l.status}`;try{const f=await l.json();f&&typeof f.error=="string"?d=f.error:f&&typeof f.message=="string"&&(d=f.message)}catch{}throw new Error(d)}return await l.json()}getPurposeFromPath(t,n){const o={"/admin/stats":{GET:"admin_stats"},"/admin/products":{GET:"admin_products_list",POST:"admin_products_create"},"/admin/transactions":{GET:"admin_transactions_list"},"/admin/coupons":{GET:"admin_coupons_list",POST:"admin_coupons_create"},"/admin/refunds":{GET:"admin_refunds_list"},"/admin/config":{GET:"admin_config_list"}}[t];if(o?.[n])return o[n];if(t.startsWith("/admin/products/")){if(n==="PUT")return"admin_products_update";if(n==="DELETE")return"admin_products_delete"}if(t.startsWith("/admin/coupons/")){if(n==="PUT")return"admin_coupons_update";if(n==="DELETE")return"admin_coupons_delete"}if(t.startsWith("/admin/refunds/")&&t.includes("/process"))return"admin_refunds_process";if(t.startsWith("/admin/config/")){if(n==="GET")return"admin_config_get";if(n==="PUT")return"admin_config_update";if(n==="PATCH")return"admin_config_patch"}return`admin_${n.toLowerCase()}`}}const Yf={publicKey:null};function Qf({serverUrl:e,cedrosLoginToken:t,isAdmin:n=!1,wallet:r=Yf}){const o=k.useMemo(()=>{const u=new $c(e);return u.setCedrosLoginAuth(t??null,n),u},[e,t,n]);k.useEffect(()=>{r.publicKey&&r.signMessage?o.setWalletSigner({publicKey:r.publicKey,signMessage:r.signMessage}):o.setWalletSigner(null)},[o,r.publicKey,r.signMessage]);const a=o.getAuthMethod(),i=o.isAuthenticated(),c=!!(r.publicKey&&r.signMessage),l=!!t,d=k.useMemo(()=>{if(!r.publicKey)return null;const u=r.publicKey.toBase58();return`${u.slice(0,4)}...${u.slice(-4)}`},[r.publicKey]),f=k.useCallback((u,h)=>o.fetchWithAuth(u,h),[o]);return{authMethod:a,isAuthenticated:i,walletConnected:c,walletAddress:d,cedrosLoginAvailable:l,authManager:o,fetchWithAuth:f}}const Kf=k.lazy(()=>Promise.resolve().then(()=>require("./SubscriptionsSection-CYJpArJ8.js")).then(e=>({default:e.SubscriptionsSection}))),Jf=k.lazy(()=>Promise.resolve().then(()=>require("./StorefrontSection-DTpZ_GgO.js")).then(e=>({default:e.StorefrontSection}))),Xf=k.lazy(()=>Promise.resolve().then(()=>require("./AISettingsSection-BtOxEweU.js")).then(e=>({default:e.AISettingsSection}))),em=k.lazy(()=>Promise.resolve().then(()=>require("./PaymentSettingsSection-Cmmuhmd4.js")).then(e=>({default:e.PaymentSettingsSection}))),tm=k.lazy(()=>Promise.resolve().then(()=>require("./MessagingSection-B6EHvjDw.js")).then(e=>({default:e.MessagingSection}))),nm=k.lazy(()=>Promise.resolve().then(()=>require("./FAQSection-DQpF7hVx.js")).then(e=>({default:e.FAQSection}))),zc=[{label:"Menu",sections:[{id:"transactions",label:"Transactions",icon:Y.transactions},{id:"products",label:"Products",icon:Y.products},{id:"subscriptions",label:"Subscriptions",icon:Y.calendarRepeat},{id:"coupons",label:"Coupons",icon:Y.coupons},{id:"refunds",label:"Refunds",icon:Y.refunds}]},{label:"Configuration",collapsible:!0,sections:[{id:"storefront",label:"Storefront",icon:Y.storefront},{id:"ai-settings",label:"Store AI",icon:Y.brain},{id:"faqs",label:"Knowledge Base",icon:Y.faq},{id:"payment-settings",label:"Payment Options",icon:Y.creditCard},{id:"messaging",label:"Store Messages",icon:Y.mail},{id:"settings",label:"Store Server",icon:Y.server}]}],rm=zc.flatMap(e=>e.sections);function sm(){const[e,t]=k.useState(()=>typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");return k.useEffect(()=>{const n=window.matchMedia("(prefers-color-scheme: dark)"),r=o=>t(o.matches?"dark":"light");return n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),e}function om(e,t,n){return e!=="system"?e:t||n}function am({serverUrl:e,apiKey:t,title:n="Cedros Pay",sections:r=["transactions","products","subscriptions","coupons","refunds","storefront","ai-settings","faqs","payment-settings","messaging","settings"],defaultSection:o="transactions",refreshInterval:a=3e4,pageSize:i=20,onSectionChange:c,className:l="",cedrosLoginToken:d,isAdmin:f=!1,theme:u="system"}){const[h,g]=k.useState(o),[y]=k.useState(!1),[x,p]=k.useState(new Set),v=k.useCallback(M=>{p(U=>{const D=new Set(U);return D.has(M)?D.delete(M):D.add(M),D})},[]),_=Je.useCedrosThemeOptional(),w=sm(),j=om(u,_?.mode??null,w)==="dark"?"cedros-admin--dark":"",R=zf.useWallet(),{authManager:I,isAuthenticated:C}=Qf({serverUrl:e,cedrosLoginToken:d,isAdmin:f,wallet:R}),E=k.useCallback(M=>{g(M),c?.(M)},[c]),F=rm.filter(M=>r.includes(M.id)).find(M=>M.id===h);return y?s.jsxs("div",{className:`cedros-admin cedros-admin--loading ${j} ${l}`,children:[Y.loading,s.jsx("span",{className:"cedros-admin__loading-text",children:"Loading dashboard..."})]}):C?s.jsxs("div",{className:`cedros-admin ${j} ${l}`,children:[s.jsxs("aside",{className:"cedros-admin__sidebar",children:[s.jsx("div",{className:"cedros-admin__sidebar-header",children:s.jsxs("div",{className:"cedros-admin__logo",children:[Y.wallet,s.jsx("span",{className:"cedros-admin__logo-text",children:n})]})}),s.jsx("nav",{className:"cedros-admin__nav",children:zc.map(M=>{const U=M.sections.filter(H=>r.includes(H.id));if(U.length===0)return null;const D=M.collapsible&&x.has(M.label);return s.jsxs("div",{className:"cedros-admin__nav-group",children:[M.collapsible?s.jsxs("button",{type:"button",className:"cedros-admin__nav-label cedros-admin__nav-label--collapsible",onClick:()=>v(M.label),"aria-expanded":!D,children:[M.label,s.jsx("span",{className:`cedros-admin__nav-label-icon ${D?"":"cedros-admin__nav-label-icon--expanded"}`,children:Y.chevronRight})]}):s.jsx("span",{className:"cedros-admin__nav-label",children:M.label}),!D&&U.map(H=>s.jsxs("button",{type:"button",className:`cedros-admin__nav-item ${h===H.id?"cedros-admin__nav-item--active":""}`,onClick:()=>E(H.id),"aria-current":h===H.id?"page":void 0,children:[s.jsx("span",{className:"cedros-admin__nav-icon",children:H.icon}),s.jsx("span",{className:"cedros-admin__nav-text",children:H.label})]},H.id))]},M.label)})})]}),s.jsxs("main",{className:"cedros-admin__main",children:[s.jsx("header",{className:"cedros-admin__header",children:s.jsxs("div",{className:"cedros-admin__breadcrumb",children:[s.jsx("span",{className:"cedros-admin__breadcrumb-root",children:n}),s.jsx("span",{className:"cedros-admin__breadcrumb-sep",children:Y.chevronRight}),s.jsx("span",{className:"cedros-admin__breadcrumb-current",children:F?.label})]})}),s.jsxs("div",{className:"cedros-admin__content",children:[h==="products"&&s.jsx(Rc,{serverUrl:e,apiKey:t,pageSize:i,authManager:I}),h==="subscriptions"&&s.jsx(k.Suspense,{fallback:s.jsx("div",{className:"cedros-admin__loading-text",children:"Loading section..."}),children:s.jsx(Kf,{serverUrl:e,apiKey:t,authManager:I})}),h==="transactions"&&s.jsx(Oc,{serverUrl:e,apiKey:t,pageSize:i,authManager:I}),h==="coupons"&&s.jsx(Mc,{serverUrl:e,apiKey:t,pageSize:i,authManager:I}),h==="refunds"&&s.jsx(Lc,{serverUrl:e,apiKey:t,pageSize:i,authManager:I}),h==="storefront"&&s.jsx(k.Suspense,{fallback:s.jsx("div",{className:"cedros-admin__loading-text",children:"Loading section..."}),children:s.jsx(Jf,{serverUrl:e,apiKey:t,authManager:I})}),h==="ai-settings"&&s.jsx(k.Suspense,{fallback:s.jsx("div",{className:"cedros-admin__loading-text",children:"Loading section..."}),children:s.jsx(Xf,{serverUrl:e,apiKey:t,authManager:I})}),h==="faqs"&&s.jsx(k.Suspense,{fallback:s.jsx("div",{className:"cedros-admin__loading-text",children:"Loading section..."}),children:s.jsx(nm,{serverUrl:e,apiKey:t,pageSize:i,authManager:I})}),h==="payment-settings"&&s.jsx(k.Suspense,{fallback:s.jsx("div",{className:"cedros-admin__loading-text",children:"Loading section..."}),children:s.jsx(em,{serverUrl:e,apiKey:t,authManager:I})}),h==="messaging"&&s.jsx(k.Suspense,{fallback:s.jsx("div",{className:"cedros-admin__loading-text",children:"Loading section..."}),children:s.jsx(tm,{serverUrl:e,apiKey:t,authManager:I})}),h==="settings"&&s.jsx(Dc,{serverUrl:e,apiKey:t,authManager:I})]})]})]}):s.jsx("div",{className:`cedros-admin cedros-admin--unauthenticated ${j} ${l}`,children:s.jsx("p",{className:"cedros-admin__auth-prompt",children:"Please connect a wallet or sign in as admin to access the dashboard."})})}const kt=e=>k.lazy(async()=>{const r=(await e()).default;return{default:({pluginContext:a})=>{const c=Ff.useCedrosLogin()?._internal?.getAccessToken()??a.getAccessToken(),l=k.useMemo(()=>{const f=new $c(a.serverUrl);return f.setCedrosLoginAuth(c??null,!!c),f},[a.serverUrl,c]),d={serverUrl:a.serverUrl,authManager:l};return s.jsx(r,{...d})}}}),im={id:"cedros-pay",name:"Cedros Pay",version:"1.0.0",sections:[{id:"transactions",label:"Transactions",icon:Y.transactions,group:"Store",order:0},{id:"products",label:"Products",icon:Y.products,group:"Store",order:1},{id:"subscriptions",label:"Subscriptions",icon:Y.subscriptions,group:"Store",order:2},{id:"coupons",label:"Coupons",icon:Y.coupons,group:"Store",order:3},{id:"refunds",label:"Refunds",icon:Y.refunds,group:"Store",order:4},{id:"storefront",label:"Storefront",icon:Y.storefront,group:"Configuration",order:10},{id:"ai-settings",label:"Store AI",icon:Y.ai,group:"Configuration",order:11},{id:"faqs",label:"Knowledge Base",icon:Y.faq,group:"Configuration",order:12},{id:"payment-settings",label:"Payment Options",icon:Y.wallet,group:"Configuration",order:13},{id:"messaging",label:"Store Messages",icon:Y.notifications,group:"Configuration",order:14},{id:"settings",label:"Store Server",icon:Y.settings,group:"Configuration",order:15}],groups:[{id:"Store",label:"Store",order:1},{id:"Configuration",label:"Configuration",order:2,defaultCollapsed:!0}],components:{products:kt(()=>Promise.resolve().then(()=>require("./sections-CR7NRsjq.js")).then(e=>({default:e.ProductsSection}))),subscriptions:kt(()=>Promise.resolve().then(()=>require("./SubscriptionsSection-CYJpArJ8.js")).then(e=>({default:e.SubscriptionsSection}))),transactions:kt(()=>Promise.resolve().then(()=>require("./sections-CR7NRsjq.js")).then(e=>({default:e.TransactionsSection}))),coupons:kt(()=>Promise.resolve().then(()=>require("./sections-CR7NRsjq.js")).then(e=>({default:e.CouponsSection}))),refunds:kt(()=>Promise.resolve().then(()=>require("./sections-CR7NRsjq.js")).then(e=>({default:e.RefundsSection}))),storefront:kt(()=>Promise.resolve().then(()=>require("./StorefrontSection-DTpZ_GgO.js")).then(e=>({default:e.StorefrontSection}))),"ai-settings":kt(()=>Promise.resolve().then(()=>require("./AISettingsSection-BtOxEweU.js")).then(e=>({default:e.AISettingsSection}))),faqs:kt(()=>Promise.resolve().then(()=>require("./FAQSection-DQpF7hVx.js")).then(e=>({default:e.FAQSection}))),"payment-settings":kt(()=>Promise.resolve().then(()=>require("./PaymentSettingsSection-Cmmuhmd4.js")).then(e=>({default:e.PaymentSettingsSection}))),messaging:kt(()=>Promise.resolve().then(()=>require("./MessagingSection-B6EHvjDw.js")).then(e=>({default:e.MessagingSection}))),settings:kt(()=>Promise.resolve().then(()=>require("./SettingsSection-DrzGdvHH.js")).then(e=>({default:e.SettingsSection})))},createPluginContext(e){const t=e.cedrosPay,n=e.cedrosLogin;return{serverUrl:t?.serverUrl||n?.serverUrl||"",userId:n?.user?.id,getAccessToken:()=>n?.getAccessToken?.()||t?.jwtToken||null,hasPermission:o=>this.checkPermission(o,e),orgId:e.org?.orgId,pluginData:{walletAddress:t?.walletAddress}}},checkPermission(e,t){return t.org?.permissions?t.org.permissions.includes(e):!!(t.cedrosLogin?.user||t.cedrosPay?.jwtToken||t.cedrosPay?.walletAddress)},cssNamespace:"cedros-dashboard"},Fc=[{id:"transactions",qualifiedId:"cedros-pay:transactions",label:"Transactions",group:"Store",order:0,endpoints:["GET /admin/transactions"]},{id:"products",qualifiedId:"cedros-pay:products",label:"Products",group:"Store",order:1,endpoints:["GET /admin/products","POST /admin/products","PUT /admin/products/{id}","DELETE /admin/products/{id}"]},{id:"subscriptions",qualifiedId:"cedros-pay:subscriptions",label:"Subscriptions",group:"Store",order:2,endpoints:["GET /admin/subscriptions","POST /admin/subscriptions","PUT /admin/subscriptions/{id}"]},{id:"coupons",qualifiedId:"cedros-pay:coupons",label:"Coupons",group:"Store",order:3,endpoints:["GET /admin/coupons","POST /admin/coupons","PUT /admin/coupons/{id}","DELETE /admin/coupons/{id}"]},{id:"refunds",qualifiedId:"cedros-pay:refunds",label:"Refunds",group:"Store",order:4,endpoints:["GET /admin/refunds","POST /admin/refunds/{id}/approve","POST /admin/refunds/{id}/deny"]},{id:"storefront",qualifiedId:"cedros-pay:storefront",label:"Storefront",group:"Configuration",order:10,endpoints:["GET /admin/config/shop","PUT /admin/config/shop"]},{id:"ai-settings",qualifiedId:"cedros-pay:ai-settings",label:"Store AI",group:"Configuration",order:11,endpoints:["GET /admin/config/ai","PUT /admin/config/ai/api-key","PUT /admin/config/ai/assignment","PUT /admin/config/ai/prompt"]},{id:"faqs",qualifiedId:"cedros-pay:faqs",label:"Knowledge Base",group:"Configuration",order:12,endpoints:["GET /admin/faqs","POST /admin/faqs","PUT /admin/faqs/{id}","DELETE /admin/faqs/{id}"]},{id:"payment-settings",qualifiedId:"cedros-pay:payment-settings",label:"Payment Options",group:"Configuration",order:13,endpoints:["GET /admin/config/stripe","PUT /admin/config/stripe","GET /admin/config/x402","PUT /admin/config/x402","GET /admin/config/cedros_login","PUT /admin/config/cedros_login"]},{id:"messaging",qualifiedId:"cedros-pay:messaging",label:"Store Messages",group:"Configuration",order:14,endpoints:["GET /admin/config/messaging","PUT /admin/config/messaging"]},{id:"settings",qualifiedId:"cedros-pay:settings",label:"Store Server",group:"Configuration",order:15,endpoints:["GET /admin/config/server","PUT /admin/config/server"]}],cm=Fc.map(e=>e.qualifiedId),lm=[{id:"Store",label:"Store",order:1,defaultCollapsed:!1},{id:"Configuration",label:"Configuration",order:2,defaultCollapsed:!0}],qo=k.createContext(null);function Ee(){const e=k.useContext(qo);if(!e)throw new Error("useCedrosShop must be used within CedrosShopProvider");return e}function Go(){return k.useContext(qo)}function dm({config:e,children:t}){const n=k.useMemo(()=>({config:e}),[e]);return s.jsx(qo.Provider,{value:n,children:t})}function jt(e){return new Promise(t=>setTimeout(t,e))}const Uc=[{id:"cat_all",slug:"all",name:"All Products",description:"Everything in the catalog."},{id:"cat_apparel",slug:"apparel",name:"Apparel",description:"Soft goods and daily wear."},{id:"cat_accessories",slug:"accessories",name:"Accessories",description:"Carry, attach, decorate."}],Kr=[{id:"p_tee",slug:"cedros-tee",title:"Cedros Tee",description:"A heavyweight tee with a clean silhouette.",images:[{url:"https://picsum.photos/seed/cedros-tee/900/900",alt:"Cedros Tee"},{url:"https://picsum.photos/seed/cedros-tee-2/900/900",alt:"Cedros Tee detail"}],price:38,currency:"USD",tags:["new","cotton"],categoryIds:["cat_apparel"],compareAtPrice:48,inventoryStatus:"in_stock",variants:[{id:"v_tee_s",title:"Small / Black",options:{Size:"S",Color:"Black"}},{id:"v_tee_m",title:"Medium / Black",options:{Size:"M",Color:"Black"}},{id:"v_tee_l",title:"Large / Black",options:{Size:"L",Color:"Black"}}],shippingProfile:"physical"},{id:"p_crewneck",slug:"cedros-crewneck",title:"Cedros Crewneck",description:"Midweight fleece with a relaxed fit and embroidered mark.",images:[{url:"https://picsum.photos/seed/cedros-crewneck/900/900",alt:"Cedros Crewneck"}],price:64,currency:"USD",tags:["fleece","core"],categoryIds:["cat_apparel"],inventoryStatus:"in_stock",compareAtPrice:78,variants:[{id:"v_crew_s",title:"Small / Heather",options:{Size:"S",Color:"Heather"}},{id:"v_crew_m",title:"Medium / Heather",options:{Size:"M",Color:"Heather"}},{id:"v_crew_l",title:"Large / Heather",options:{Size:"L",Color:"Heather"}}],shippingProfile:"physical"},{id:"p_hoodie",slug:"cedros-hoodie",title:"Cedros Hoodie",description:"Pullover hoodie with soft interior and structured hood.",images:[{url:"https://picsum.photos/seed/cedros-hoodie/900/900",alt:"Cedros Hoodie"},{url:"https://picsum.photos/seed/cedros-hoodie-2/900/900",alt:"Cedros Hoodie detail"}],price:74,currency:"USD",tags:["fleece","new"],categoryIds:["cat_apparel"],inventoryStatus:"low",variants:[{id:"v_hoodie_s",title:"Small / Black",options:{Size:"S",Color:"Black"}},{id:"v_hoodie_m",title:"Medium / Black",options:{Size:"M",Color:"Black"}},{id:"v_hoodie_l",title:"Large / Black",options:{Size:"L",Color:"Black"}}],shippingProfile:"physical"},{id:"p_cap",slug:"cedros-cap",title:"Cedros Cap",description:"Unstructured cap with adjustable strap and curved brim.",images:[{url:"https://picsum.photos/seed/cedros-cap/900/900",alt:"Cedros Cap"}],price:28,currency:"USD",tags:["core"],categoryIds:["cat_apparel"],inventoryStatus:"in_stock",shippingProfile:"physical"},{id:"p_socks",slug:"cedros-socks",title:"Cedros Socks",description:"Rib-knit socks designed for everyday comfort.",images:[{url:"https://picsum.photos/seed/cedros-socks/900/900",alt:"Cedros Socks"}],price:14,currency:"USD",tags:["cotton"],categoryIds:["cat_apparel"],inventoryStatus:"in_stock",shippingProfile:"physical"},{id:"p_tote",slug:"cedros-tote",title:"Cedros Tote",description:"Heavy canvas tote with reinforced handles.",images:[{url:"https://picsum.photos/seed/cedros-tote/900/900",alt:"Cedros Tote"}],price:32,currency:"USD",tags:["gift","canvas"],categoryIds:["cat_accessories"],inventoryStatus:"in_stock",shippingProfile:"physical"},{id:"p_stickers",slug:"cedros-sticker-pack",title:"Sticker Pack",description:"Five durable vinyl stickers for laptops and water bottles.",images:[{url:"https://picsum.photos/seed/cedros-stickers/900/900",alt:"Sticker Pack"}],price:8,currency:"USD",tags:["gift"],categoryIds:["cat_accessories"],inventoryStatus:"in_stock",shippingProfile:"physical"},{id:"p_keychain",slug:"cedros-keychain",title:"Enamel Keychain",description:"Polished enamel keychain with a subtle mark.",images:[{url:"https://picsum.photos/seed/cedros-keychain/900/900",alt:"Enamel Keychain"}],price:12,currency:"USD",tags:["gift"],categoryIds:["cat_accessories"],inventoryStatus:"low",shippingProfile:"physical"},{id:"p_lanyard",slug:"cedros-lanyard",title:"Woven Lanyard",description:"Soft woven lanyard with swivel clasp.",images:[{url:"https://picsum.photos/seed/cedros-lanyard/900/900",alt:"Woven Lanyard"}],price:10,currency:"USD",tags:["core"],categoryIds:["cat_accessories"],inventoryStatus:"in_stock",shippingProfile:"physical"},{id:"p_notebook",slug:"cedros-notebook",title:"Dot Grid Notebook",description:"Lay-flat notebook for sketches, notes, and plans.",images:[{url:"https://picsum.photos/seed/cedros-notebook/900/900",alt:"Dot Grid Notebook"}],price:18,currency:"USD",tags:["gift"],categoryIds:["cat_accessories"],inventoryStatus:"in_stock",shippingProfile:"physical"},{id:"p_waterbottle",slug:"cedros-water-bottle",title:"Insulated Bottle",description:"Vacuum-insulated bottle that keeps drinks cold for hours.",images:[{url:"https://picsum.photos/seed/cedros-bottle/900/900",alt:"Insulated Bottle"}],price:36,currency:"USD",tags:["gift","new"],categoryIds:["cat_accessories"],inventoryStatus:"backorder",shippingProfile:"physical"},{id:"p_posters",slug:"cedros-poster-set",title:"Poster Set",description:"Two prints on thick matte stock.",images:[{url:"https://picsum.photos/seed/cedros-posters/900/900",alt:"Poster Set"}],price:24,currency:"USD",tags:["gift","limited"],categoryIds:["cat_accessories"],inventoryStatus:"out_of_stock",shippingProfile:"physical"},{id:"p_pins",slug:"cedros-pin-set",title:"Pin Set",description:"Two enamel pins with rubber backings.",images:[{url:"https://picsum.photos/seed/cedros-pins/900/900",alt:"Pin Set"}],price:16,currency:"USD",tags:["gift"],categoryIds:["cat_accessories"],inventoryStatus:"in_stock",shippingProfile:"physical"},{id:"p_brandbook",slug:"cedros-brand-book",title:"Brand Book (PDF)",description:"A compact brand book: typography, color, layout, and voice.",images:[{url:"https://picsum.photos/seed/cedros-brandbook/900/900",alt:"Brand Book cover"}],price:19,currency:"USD",tags:["digital"],categoryIds:["cat_accessories"],inventoryStatus:"in_stock",shippingProfile:"digital",checkoutRequirements:{email:"optional",name:"none",phone:"none",shippingAddress:!1,billingAddress:!1},fulfillment:{type:"digital_download",notes:"This is a digital product and will be downloadable from your account after purchase."}},{id:"p_wallpaper",slug:"cedros-wallpaper-pack",title:"Wallpaper Pack",description:"A set of desktop + mobile wallpapers in multiple colorways.",images:[{url:"https://picsum.photos/seed/cedros-wallpaper/900/900",alt:"Wallpaper Pack"}],price:6,currency:"USD",tags:["digital","new"],categoryIds:["cat_accessories"],inventoryStatus:"in_stock",shippingProfile:"digital"},{id:"p_longsleeve",slug:"cedros-long-sleeve",title:"Long Sleeve Tee",description:"Soft long sleeve tee with rib cuff and relaxed drape.",images:[{url:"https://picsum.photos/seed/cedros-longsleeve/900/900",alt:"Long Sleeve Tee"}],price:44,currency:"USD",tags:["cotton"],categoryIds:["cat_apparel"],inventoryStatus:"in_stock",shippingProfile:"physical"},{id:"p_shorts",slug:"cedros-shorts",title:"Everyday Shorts",description:"Lightweight shorts with a comfortable waistband.",images:[{url:"https://picsum.photos/seed/cedros-shorts/900/900",alt:"Everyday Shorts"}],price:40,currency:"USD",tags:["new"],categoryIds:["cat_apparel"],inventoryStatus:"in_stock",shippingProfile:"physical"},{id:"p_beanie",slug:"cedros-beanie",title:"Rib Beanie",description:"Warm rib beanie with a clean folded cuff.",images:[{url:"https://picsum.photos/seed/cedros-beanie/900/900",alt:"Rib Beanie"}],price:20,currency:"USD",tags:["core"],categoryIds:["cat_apparel"],inventoryStatus:"low",shippingProfile:"physical"},{id:"p_jacket",slug:"cedros-coach-jacket",title:"Coach Jacket",description:"Lightweight jacket with snap front and subtle sheen.",images:[{url:"https://picsum.photos/seed/cedros-jacket/900/900",alt:"Coach Jacket"}],price:96,currency:"USD",tags:["limited"],categoryIds:["cat_apparel"],inventoryStatus:"backorder",shippingProfile:"physical"},{id:"p_mug",slug:"cedros-mug",title:"Cedros Mug",description:"Stoneware mug with a satin glaze.",images:[{url:"https://picsum.photos/seed/cedros-mug/900/900",alt:"Cedros Mug"}],price:22,currency:"USD",tags:["gift"],categoryIds:["cat_accessories"],inventoryStatus:"low",shippingProfile:"physical"},{id:"p_guide",slug:"cedros-field-guide",title:"Field Guide (Digital)",description:"A short digital guide to shipping delightful checkout flows.",images:[{url:"https://picsum.photos/seed/cedros-guide/900/900",alt:"Field Guide cover"}],price:12,currency:"USD",tags:["digital"],categoryIds:["cat_accessories"],inventoryStatus:"in_stock",shippingProfile:"digital"}];function um(e,t){let n=e;if(t.category&&t.category!=="all"){const l=Uc.find(d=>d.slug===t.category||d.id===t.category);l&&(n=n.filter(d=>d.categoryIds.includes(l.id)))}if(t.search){const l=t.search.toLowerCase();n=n.filter(d=>d.title.toLowerCase().includes(l)||d.description.toLowerCase().includes(l))}const r=t.filters??{},o=r.tags;if(Array.isArray(o)&&o.length>0){const l=new Set(o.map(String));n=n.filter(d=>d.tags?.some(f=>l.has(f)))}const a=typeof r.priceMin=="number"?r.priceMin:void 0,i=typeof r.priceMax=="number"?r.priceMax:void 0;return typeof a=="number"&&(n=n.filter(l=>l.price>=a)),typeof i=="number"&&(n=n.filter(l=>l.price<=i)),(typeof r.inStock=="boolean"?r.inStock:void 0)===!0&&(n=n.filter(l=>l.inventoryStatus!=="out_of_stock")),n}function fm(e,t){if(!t||t==="featured")return e;const n=[...e];return t==="price_asc"&&n.sort((r,o)=>r.price-o.price),t==="price_desc"&&n.sort((r,o)=>o.price-r.price),n}function mm(e,t,n){const r=(t-1)*n;return{items:e.slice(r,r+n),page:t,pageSize:n,total:e.length,hasNextPage:r+n<e.length}}function pm(e){const t=new Date().toISOString(),n=e.cart.map(o=>{const a=Kr.find(i=>i.id===o.resource||i.slug===o.resource)??Kr[0];return{title:a.title,qty:o.quantity,unitPrice:a.price,currency:e.options.currency,imageUrl:a.images[0]?.url}}),r=n.reduce((o,a)=>o+a.qty*a.unitPrice,0);return{id:`ord_${Math.random().toString(16).slice(2)}`,createdAt:t,status:"paid",total:r,currency:e.options.currency,items:n,receiptUrl:e.options.successUrl}}function hm(){let e=[];const t={};return{async listProducts(n){await jt(150);const r=n.page??1,o=n.pageSize??24,a=um(Kr,n),i=fm(a,n.sort);return mm(i,r,o)},async getProductBySlug(n){return await jt(100),Kr.find(r=>r.slug===n)??null},async listCategories(){return await jt(80),Uc},async getOrderHistory(){return await jt(120),e},async getCart({customerId:n}){return await jt(80),t[n]??{items:[]}},async mergeCart({customerId:n,cart:r}){await jt(120);const o=t[n]??{items:[]},a=new Map,i=l=>{const d=`${l.productId}::${l.variantId??""}`,f=a.get(d);f?a.set(d,{...f,qty:f.qty+l.qty}):a.set(d,l)};for(const l of o.items)i(l);for(const l of r.items)i(l);const c={items:Array.from(a.values()),promoCode:r.promoCode??o.promoCode};return t[n]=c,c},async updateCart({customerId:n,cart:r}){await jt(60),t[n]=r},async createCheckoutSession(n){await jt(250);const r=pm(n);if(e=[r,...e].slice(0,25),n.options.successUrl){const o=new URL(n.options.successUrl,"http://localhost");return o.searchParams.set("demoOrderId",r.id),{kind:"redirect",url:o.toString().replace("http://localhost","")}}return{kind:"custom",data:{orderId:r.id}}},async listSubscriptionTiers(){return await jt(80),[{id:"tier_starter",title:"Starter",description:"For small shops getting started.",priceMonthly:19,priceAnnual:190,currency:"USD",features:["Basic analytics","Email support","1 storefront"]},{id:"tier_growth",title:"Growth",description:"For teams iterating fast.",priceMonthly:49,priceAnnual:490,currency:"USD",features:["Advanced analytics","Priority support","3 storefronts"],isPopular:!0},{id:"tier_enterprise",title:"Enterprise",description:"For high volume and custom needs.",priceMonthly:199,priceAnnual:1990,currency:"USD",features:["SLA","Dedicated success","Unlimited storefronts"]}]},async getSubscriptionStatus(){return await jt(80),{isActive:!1}},async createSubscriptionCheckoutSession(n){return await jt(200),n.successUrl?{kind:"redirect",url:n.successUrl}:{kind:"custom",data:n}}}}const ci=50,gm=4,xm=5,vm=1e4,ym={maxRetries:2,initialDelayMs:100,backoffFactor:2,maxDelayMs:500,jitter:!1};function Bc(e){return e.replace(/[_-]+/g," ").trim().replace(/\b\w/g,t=>t.toUpperCase())}function bm(e){return e?e.toUpperCase():"USD"}function wm(e){if(e&&(e==="in_stock"||e==="low"||e==="out_of_stock"||e==="backorder"))return e}function _m(e){if(e&&(e==="physical"||e==="digital"))return e}function km(e){const t=[];if(Array.isArray(e))for(const n of e)typeof n=="string"&&t.push(n);else if(typeof e=="string"){const n=e.trim();if(n.startsWith("["))try{const r=JSON.parse(n);if(Array.isArray(r))for(const o of r)typeof o=="string"&&t.push(o);else t.push(e)}catch{t.push(e)}else t.push(e)}return t.flatMap(n=>n.split(",")).map(n=>n.trim().toUpperCase()).filter(Boolean)}function Tn(e){const t=bm(e.fiatCurrency),n=e.images&&e.images.length?e.images:e.imageUrl?[{url:e.imageUrl,alt:e.title}]:[],r=e.effectiveFiatAmountCents??e.fiatAmountCents??0,o=e.compareAtAmountCents,a=e.metadata?.shippingCountries??e.metadata?.shipping_countries,i=km(a);return{id:e.id,slug:e.slug??e.id,title:e.title??Bc(e.id),description:e.description??"",images:n,price:r/100,currency:t,tags:e.tags??[],categoryIds:e.categoryIds??[],inventoryStatus:wm(e.inventoryStatus),inventoryQuantity:typeof e.inventoryQuantity=="number"?e.inventoryQuantity:void 0,compareAtPrice:typeof o=="number"?o/100:void 0,shippingProfile:_m(e.shippingProfile),checkoutRequirements:e.checkoutRequirements,fulfillment:e.fulfillment,attributes:i.length?{shippingCountries:i.join(",")}:void 0}}function Hr(e){if(Array.isArray(e))return{products:e};const t=e.products??e.items??[],n=e.total??e.count;return{products:t,total:n}}async function Kt(e,t,n,r={}){const{body:o,headers:a,method:i="GET",retryableRead:c=!1,timeoutMs:l=vm}=r,d={};n&&(d["X-API-Key"]=n),a&&Object.assign(d,a);const f=async()=>{const u=await Je.fetchWithTimeout(`${e}${t}`,{body:o,headers:d,method:i},l);if(!u.ok){const h=await u.text().catch(()=>""),g=new Error(`Request failed (${u.status}): ${h}`);throw g.status=u.status,g}return u.json()};return c?Je.retryWithBackoff(f,{...ym,name:`paywall-read-${i.toLowerCase()}`}):f()}async function jm(e,t,n,r){const o=await Kt(e,`/paywall/v1/products?limit=${n}&offset=${r}`,t,{retryableRead:!0});return Hr(o)}async function li(e,t,n,r){const{maxPages:o,pageSize:a}=n;for(let i=0;i<o;i+=1){const c=i*a,{products:l,total:d}=await jm(e,t,a,c);if(l.length===0||r(l))return;const f=typeof d=="number"&&c+l.length>=d,u=l.length<a;if(f||u)return}}function Sm(e){const t=async d=>{const f=d.page??1,u=d.pageSize??24,h=u,g=(f-1)*u,y=new URLSearchParams;y.set("limit",String(h)),y.set("offset",String(g)),d.search&&y.set("search",d.search),d.category&&y.set("category",d.category),d.sort&&y.set("sort",d.sort),d.filters?.inStock&&y.set("in_stock","true"),d.filters?.minPrice!=null&&y.set("min_price",String(d.filters.minPrice)),d.filters?.maxPrice!=null&&y.set("max_price",String(d.filters.maxPrice));const x=d.filters?.tags,p=Array.isArray(x)?x:typeof x=="string"?[x]:[];p.length&&y.set("tags",p.join(","));const v=await Kt(e.serverUrl,`/paywall/v1/products?${y.toString()}`,e.apiKey,{retryableRead:!0}),{products:_,total:w}=Hr(v);return{items:_.map(Tn),page:f,pageSize:u,total:w,hasNextPage:typeof w=="number"?g+h<w:_.length===h}},n=async d=>{try{const f=await Kt(e.serverUrl,`/paywall/v1/products/by-slug/${encodeURIComponent(d)}`,e.apiKey,{retryableRead:!0});return Tn(f)}catch(f){const u=f?.status;if(u!==404&&u!==405)throw f;try{const h=await Kt(e.serverUrl,`/paywall/v1/products/${encodeURIComponent(d)}`,e.apiKey,{retryableRead:!0});return Tn(h)}catch(h){const g=h?.status;if(g!==404&&g!==405)throw h;let y;return await li(e.serverUrl,e.apiKey,{maxPages:gm,pageSize:ci},x=>(y=x.find(p=>p.slug===d||p.id===d),!!y)),y?Tn(y):null}}};return{listProducts:t,getProductBySlug:n,getProductsByIds:async d=>{const f=Array.from(new Set(d.filter(Boolean)));if(f.length===0)return new Map;const u=new Map;try{const y=new URLSearchParams;y.set("ids",f.join(",")),y.set("limit",String(f.length)),y.set("offset","0");const x=await Kt(e.serverUrl,`/paywall/v1/products?${y.toString()}`,e.apiKey,{retryableRead:!0}),{products:p}=Hr(x);for(const v of p){const _=Tn(v);u.set(_.id,_),_.slug&&_.slug!==_.id&&u.set(_.slug,_)}}catch{}const h=f.filter(y=>!u.has(y));if(h.length===0)return u;let g=h;try{const y=new Set(g);if(await li(e.serverUrl,e.apiKey,{maxPages:xm,pageSize:ci},x=>{for(const p of x){const v=Tn(p);!y.has(v.id)&&!(v.slug&&y.has(v.slug))||(u.set(v.id,v),v.slug&&v.slug!==v.id&&u.set(v.slug,v),y.delete(v.id),v.slug&&y.delete(v.slug))}return y.size===0}),g=Array.from(y),g.length===0)return u}catch{}for(const y of g)try{const x=await n(y);x&&(u.set(x.id,x),x.slug&&x.slug!==x.id&&u.set(x.slug,x))}catch{}return u},listCategories:async()=>{const d=await Kt(e.serverUrl,"/paywall/v1/products?limit=500&offset=0",e.apiKey,{retryableRead:!0}),{products:f}=Hr(d),u=new Set;for(const h of f)for(const g of h.categoryIds??[])u.add(g);return Array.from(u).map(h=>({id:h,slug:h,name:Bc(h)}))},getOrderHistory:async()=>[],createCheckoutSession:async d=>{throw new Error("createCheckoutSession is not implemented for paywall adapter")},getStorefrontSettings:async()=>{try{return(await Kt(e.serverUrl,"/paywall/v1/storefront",e.apiKey,{retryableRead:!0})).config??null}catch{return null}},getPaymentMethodsConfig:async()=>{try{const f=(await Kt(e.serverUrl,"/paywall/v1/storefront",e.apiKey,{retryableRead:!0})).paymentMethods;return f?{card:!!f.stripe,crypto:!!f.x402,credits:!!f.credits}:null}catch{return null}},getAIRelatedProducts:async d=>Kt(e.serverUrl,"/admin/ai/related-products",e.apiKey,{method:"POST",body:JSON.stringify(d),headers:{"Content-Type":"application/json"},retryableRead:!1})}}function Cm(e){throw new Error(`Unhandled cart action: ${JSON.stringify(e)}`)}function gn(e){return`${e.productId}::${e.variantId??""}`}const Nm={items:[]};function Am(e,t){switch(t.type){case"cart/hydrate":return t.state;case"cart/add":{const n=Math.max(1,Math.floor(t.qty??1)),r=gn(t.item);return e.items.find(a=>gn(a)===r)?{...e,items:e.items.map(a=>gn(a)===r?{...a,qty:a.qty+n}:a)}:{...e,items:[...e.items,{...t.item,qty:n}]}}case"cart/remove":{const n=`${t.productId}::${t.variantId??""}`;return{...e,items:e.items.filter(r=>gn(r)!==n)}}case"cart/setQty":{const n=Math.max(0,Math.floor(t.qty)),r=`${t.productId}::${t.variantId??""}`;return n===0?{...e,items:e.items.filter(o=>gn(o)!==r)}:{...e,items:e.items.map(o=>gn(o)===r?{...o,qty:n}:o)}}case"cart/clear":return{items:[],promoCode:void 0};case"cart/setPromoCode":return{...e,promoCode:t.promoCode||void 0};case"cart/updateHold":{const n=`${t.productId}::${t.variantId??""}`;return{...e,items:e.items.map(r=>gn(r)===n?{...r,holdId:t.holdId,holdExpiresAt:t.holdExpiresAt}:r)}}default:return Cm(t)}}function Em(e){return e.reduce((t,n)=>t+n.qty,0)}function Im(e){return e.reduce((t,n)=>t+n.qty*n.unitPrice,0)}function di(){try{return typeof window>"u"?null:window.localStorage}catch{return null}}function Tm(e,t){try{const n=e.getItem(t);return n?JSON.parse(n):null}catch{return null}}function Pm(e,t,n){try{return e.setItem(t,JSON.stringify(n)),!0}catch(r){return console.warn(`[cedros] Failed to write "${t}" to storage`,r),!1}}const Vc=k.createContext(null);function Pt(){const e=k.useContext(Vc);if(!e)throw new Error("useCart must be used within CartProvider");return e}function ui(e){return!!e&&typeof e=="object"&&typeof e.productId=="string"&&e.productId.length>0&&typeof e.qty=="number"&&e.qty>0&&typeof e.unitPrice=="number"&&typeof e.currency=="string"&&typeof e.titleSnapshot=="string"}function Rm({children:e}){const{config:t}=Ee(),n=t.cart?.storageKey??"cedros_shop_cart_v1",r=t.customer?.id,o=t.customer?.isSignedIn??!!r,a=t.cart?.syncDebounceMs??800,i=!!t.adapter.getCartInventoryStatus,[c,l]=k.useReducer(Am,Nm),d=k.useRef(c);d.current=c;const[f,u]=k.useState(!1),h=k.useRef(!1),g=k.useRef(null),y=k.useRef(null);k.useEffect(()=>{const _=di();if(!_)return;const w=Tm(_,n);if(w&&Array.isArray(w.items)){const b=w.items.filter(ui);l({type:"cart/hydrate",state:{items:b,promoCode:typeof w.promoCode=="string"?w.promoCode:void 0}})}u(!0)},[n]),k.useEffect(()=>{if(!f)return;const _=di();_&&Pm(_,n,c)},[c,n,f]),k.useEffect(()=>{if(!f||!o||!r||!t.adapter.mergeCart&&!t.adapter.getCart||(y.current!==r&&(h.current=!1,g.current=null,y.current=r),h.current))return;let _=!1;return(async()=>{try{const w=t.adapter.mergeCart?await t.adapter.mergeCart({customerId:r,cart:d.current}):await t.adapter.getCart({customerId:r});if(_)return;if(w&&Array.isArray(w.items)){h.current=!0;const b={...w,items:w.items.filter(ui)};l({type:"cart/hydrate",state:b}),g.current=JSON.stringify(b)}}catch{_||(h.current=!1)}})(),()=>{_=!0}},[t.adapter,r,f,o]),k.useEffect(()=>{if(!f||!o||!r||!t.adapter.updateCart||!h.current||typeof window>"u")return;const _=JSON.stringify(c);if(g.current===_)return;const w=window.setTimeout(()=>{t.adapter.updateCart({customerId:r,cart:c}).then(()=>{g.current=_}).catch(b=>{console.warn("[CedrosPay] Cart server sync failed:",b instanceof Error?b.message:b)})},a);return()=>window.clearTimeout(w)},[t.adapter,r,f,o,c,a]);const x=k.useCallback((_,w)=>{const b=c.items.find(j=>j.productId===_&&j.variantId===w);if(b)return{holdId:b.holdId,expiresAt:b.holdExpiresAt}},[c.items]),p=k.useCallback((_,w,b)=>{l({type:"cart/updateHold",productId:_,variantId:w,holdExpiresAt:b})},[]),v=k.useMemo(()=>{const _=Em(c.items),w=Im(c.items);return{items:c.items,promoCode:c.promoCode,count:_,subtotal:w,addItem:(b,j)=>l({type:"cart/add",item:b,qty:j}),removeItem:(b,j)=>l({type:"cart/remove",productId:b,variantId:j}),setQty:(b,j,R)=>l({type:"cart/setQty",productId:b,variantId:j,qty:R}),clear:()=>l({type:"cart/clear"}),setPromoCode:b=>l({type:"cart/setPromoCode",promoCode:b}),holdsSupported:i,getItemHold:x,updateItemHold:p}},[c.items,c.promoCode,i,x,p]);return s.jsx(Vc.Provider,{value:v,children:e})}function $(e,t,n){function r(c,l){if(c._zod||Object.defineProperty(c,"_zod",{value:{def:l,constr:i,traits:new Set},enumerable:!1}),c._zod.traits.has(e))return;c._zod.traits.add(e),t(c,l);const d=i.prototype,f=Object.keys(d);for(let u=0;u<f.length;u++){const h=f[u];h in c||(c[h]=d[h].bind(c))}}const o=n?.Parent??Object;class a extends o{}Object.defineProperty(a,"name",{value:e});function i(c){var l;const d=n?.Parent?new a:this;r(d,c),(l=d._zod).deferred??(l.deferred=[]);for(const f of d._zod.deferred)f();return d}return Object.defineProperty(i,"init",{value:r}),Object.defineProperty(i,Symbol.hasInstance,{value:c=>n?.Parent&&c instanceof n.Parent?!0:c?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}class Dn extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Wc extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const Hc={};function yn(e){return Hc}function Zc(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o)}function ko(e,t){return typeof t=="bigint"?t.toString():t}function Yo(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Qo(e){return e==null}function Ko(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Om(e,t){const n=(e.toString().split(".")[1]||"").length,r=t.toString();let o=(r.split(".")[1]||"").length;if(o===0&&/\d?e-\d?/.test(r)){const l=r.match(/\d?e-(\d?)/);l?.[1]&&(o=Number.parseInt(l[1]))}const a=n>o?n:o,i=Number.parseInt(e.toFixed(a).replace(".","")),c=Number.parseInt(t.toFixed(a).replace(".",""));return i%c/10**a}const fi=Symbol("evaluating");function be(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==fi)return r===void 0&&(r=fi,r=n()),r},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function Sn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function ln(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function mi(e){return JSON.stringify(e)}function Mm(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const qc="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Jr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Lm=Yo(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function mr(e){if(Jr(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(Jr(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Gc(e){return mr(e)?{...e}:Array.isArray(e)?[...e]:e}const Dm=new Set(["string","number","symbol"]);function Fn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function dn(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function ie(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function $m(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const zm={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Fm(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const a=ln(e._zod.def,{get shape(){const i={};for(const c in t){if(!(c in n.shape))throw new Error(`Unrecognized key: "${c}"`);t[c]&&(i[c]=n.shape[c])}return Sn(this,"shape",i),i},checks:[]});return dn(e,a)}function Um(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const a=ln(e._zod.def,{get shape(){const i={...e._zod.def.shape};for(const c in t){if(!(c in n.shape))throw new Error(`Unrecognized key: "${c}"`);t[c]&&delete i[c]}return Sn(this,"shape",i),i},checks:[]});return dn(e,a)}function Bm(e,t){if(!mr(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const a=e._zod.def.shape;for(const i in t)if(Object.getOwnPropertyDescriptor(a,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const o=ln(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t};return Sn(this,"shape",a),a}});return dn(e,o)}function Vm(e,t){if(!mr(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=ln(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return Sn(this,"shape",r),r}});return dn(e,n)}function Wm(e,t){const n=ln(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return Sn(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return dn(e,n)}function Hm(e,t,n){const o=t._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const i=ln(t._zod.def,{get shape(){const c=t._zod.def.shape,l={...c};if(n)for(const d in n){if(!(d in c))throw new Error(`Unrecognized key: "${d}"`);n[d]&&(l[d]=e?new e({type:"optional",innerType:c[d]}):c[d])}else for(const d in c)l[d]=e?new e({type:"optional",innerType:c[d]}):c[d];return Sn(this,"shape",l),l},checks:[]});return dn(t,i)}function Zm(e,t,n){const r=ln(t._zod.def,{get shape(){const o=t._zod.def.shape,a={...o};if(n)for(const i in n){if(!(i in a))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(a[i]=new e({type:"nonoptional",innerType:o[i]}))}else for(const i in o)a[i]=new e({type:"nonoptional",innerType:o[i]});return Sn(this,"shape",a),a}});return dn(t,r)}function Ln(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Yc(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function Ir(e){return typeof e=="string"?e:e?.message}function bn(e,t,n){const r={...e,path:e.path??[]};if(!e.message){const o=Ir(e.inst?._zod.def?.error?.(e))??Ir(t?.error?.(e))??Ir(n.customError?.(e))??Ir(n.localeError?.(e))??"Invalid input";r.message=o}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function Jo(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function pr(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const Qc=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,ko,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Kc=$("$ZodError",Qc),Jc=$("$ZodError",Qc,{Parent:Error});function qm(e,t=n=>n.message){const n={},r=[];for(const o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):r.push(t(o));return{formErrors:r,fieldErrors:n}}function Gm(e,t=n=>n.message){const n={_errors:[]},r=o=>{for(const a of o.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map(i=>r({issues:i}));else if(a.code==="invalid_key")r({issues:a.issues});else if(a.code==="invalid_element")r({issues:a.issues});else if(a.path.length===0)n._errors.push(t(a));else{let i=n,c=0;for(;c<a.path.length;){const l=a.path[c];c===a.path.length-1?(i[l]=i[l]||{_errors:[]},i[l]._errors.push(t(a))):i[l]=i[l]||{_errors:[]},i=i[l],c++}}};return r(e),n}const Xo=e=>(t,n,r,o)=>{const a=r?Object.assign(r,{async:!1}):{async:!1},i=t._zod.run({value:n,issues:[]},a);if(i instanceof Promise)throw new Dn;if(i.issues.length){const c=new(o?.Err??e)(i.issues.map(l=>bn(l,a,yn())));throw qc(c,o?.callee),c}return i.value},ea=e=>async(t,n,r,o)=>{const a=r?Object.assign(r,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},a);if(i instanceof Promise&&(i=await i),i.issues.length){const c=new(o?.Err??e)(i.issues.map(l=>bn(l,a,yn())));throw qc(c,o?.callee),c}return i.value},hs=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},o);if(a instanceof Promise)throw new Dn;return a.issues.length?{success:!1,error:new(e??Kc)(a.issues.map(i=>bn(i,o,yn())))}:{success:!0,data:a.value}},Ym=hs(Jc),gs=e=>async(t,n,r)=>{const o=r?Object.assign(r,{async:!0}):{async:!0};let a=t._zod.run({value:n,issues:[]},o);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(i=>bn(i,o,yn())))}:{success:!0,data:a.value}},Qm=gs(Jc),Km=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Xo(e)(t,n,o)},Jm=e=>(t,n,r)=>Xo(e)(t,n,r),Xm=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return ea(e)(t,n,o)},ep=e=>async(t,n,r)=>ea(e)(t,n,r),tp=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return hs(e)(t,n,o)},np=e=>(t,n,r)=>hs(e)(t,n,r),rp=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return gs(e)(t,n,o)},sp=e=>async(t,n,r)=>gs(e)(t,n,r),op=/^[cC][^\s-]{8,}$/,ap=/^[0-9a-z]+$/,ip=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,cp=/^[0-9a-vA-V]{20}$/,lp=/^[A-Za-z0-9]{27}$/,dp=/^[a-zA-Z0-9_-]{21}$/,up=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,fp=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,pi=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,mp=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,pp="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function hp(){return new RegExp(pp,"u")}const gp=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,xp=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,vp=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,yp=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,bp=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Xc=/^[A-Za-z0-9_-]*$/,wp=/^\+[1-9]\d{6,14}$/,el="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",_p=new RegExp(`^${el}$`);function tl(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function kp(e){return new RegExp(`^${tl(e)}$`)}function jp(e){const t=tl({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${el}T(?:${r})$`)}const Sp=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Cp=/^-?\d+$/,Np=/^-?\d+(?:\.\d+)?$/,Ap=/^[^A-Z]*$/,Ep=/^[^a-z]*$/,ut=$("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),nl={number:"number",bigint:"bigint",object:"date"},rl=$("$ZodCheckLessThan",(e,t)=>{ut.init(e,t);const n=nl[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,a=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<a&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),sl=$("$ZodCheckGreaterThan",(e,t)=>{ut.init(e,t);const n=nl[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,a=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>a&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ip=$("$ZodCheckMultipleOf",(e,t)=>{ut.init(e,t),e._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):Om(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Tp=$("$ZodCheckNumberFormat",(e,t)=>{ut.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[o,a]=zm[t.format];e._zod.onattach.push(i=>{const c=i._zod.bag;c.format=t.format,c.minimum=o,c.maximum=a,n&&(c.pattern=Cp)}),e._zod.check=i=>{const c=i.value;if(n){if(!Number.isInteger(c)){i.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){c>0?i.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):i.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}c<o&&i.issues.push({origin:"number",input:c,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),c>a&&i.issues.push({origin:"number",input:c,code:"too_big",maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),Pp=$("$ZodCheckMaxLength",(e,t)=>{var n;ut.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!Qo(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const o=r.value;if(o.length<=t.maximum)return;const i=Jo(o);r.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Rp=$("$ZodCheckMinLength",(e,t)=>{var n;ut.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!Qo(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const o=r.value;if(o.length>=t.minimum)return;const i=Jo(o);r.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Op=$("$ZodCheckLengthEquals",(e,t)=>{var n;ut.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!Qo(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=r=>{const o=r.value,a=o.length;if(a===t.length)return;const i=Jo(o),c=a>t.length;r.issues.push({origin:i,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),xs=$("$ZodCheckStringFormat",(e,t)=>{var n,r;ut.init(e,t),e._zod.onattach.push(o=>{const a=o._zod.bag;a.format=t.format,t.pattern&&(a.patterns??(a.patterns=new Set),a.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Mp=$("$ZodCheckRegex",(e,t)=>{xs.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Lp=$("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Ap),xs.init(e,t)}),Dp=$("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Ep),xs.init(e,t)}),$p=$("$ZodCheckIncludes",(e,t)=>{ut.init(e,t);const n=Fn(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(o=>{const a=o._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(r)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),zp=$("$ZodCheckStartsWith",(e,t)=>{ut.init(e,t);const n=new RegExp(`^${Fn(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),Fp=$("$ZodCheckEndsWith",(e,t)=>{ut.init(e,t);const n=new RegExp(`.*${Fn(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),Up=$("$ZodCheckOverwrite",(e,t)=>{ut.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class Bp{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
|
|
2
2
|
`).filter(i=>i),o=Math.min(...r.map(i=>i.length-i.trimStart().length)),a=r.map(i=>i.slice(o)).map(i=>" ".repeat(this.indent*2)+i);for(const i of a)this.content.push(i)}compile(){const t=Function,n=this?.args,o=[...(this?.content??[""]).map(a=>` ${a}`)];return new t(...n,o.join(`
|
|
3
|
-
`))}}const
|
|
3
|
+
`))}}const Vp={major:4,minor:3,patch:6},Oe=$("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Vp;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const o of r)for(const a of o._zod.onattach)a(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const o=(i,c,l)=>{let d=Ln(i),f;for(const u of c){if(u._zod.def.when){if(!u._zod.def.when(i))continue}else if(d)continue;const h=i.issues.length,g=u._zod.check(i);if(g instanceof Promise&&l?.async===!1)throw new Dn;if(f||g instanceof Promise)f=(f??Promise.resolve()).then(async()=>{await g,i.issues.length!==h&&(d||(d=Ln(i,h)))});else{if(i.issues.length===h)continue;d||(d=Ln(i,h))}}return f?f.then(()=>i):i},a=(i,c,l)=>{if(Ln(i))return i.aborted=!0,i;const d=o(c,r,l);if(d instanceof Promise){if(l.async===!1)throw new Dn;return d.then(f=>e._zod.parse(f,l))}return e._zod.parse(d,l)};e._zod.run=(i,c)=>{if(c.skipChecks)return e._zod.parse(i,c);if(c.direction==="backward"){const d=e._zod.parse({value:i.value,issues:[]},{...c,skipChecks:!0});return d instanceof Promise?d.then(f=>a(f,i,c)):a(d,i,c)}const l=e._zod.parse(i,c);if(l instanceof Promise){if(c.async===!1)throw new Dn;return l.then(d=>o(d,r,c))}return o(l,r,c)}}be(e,"~standard",()=>({validate:o=>{try{const a=Ym(e,o);return a.success?{value:a.data}:{issues:a.error?.issues}}catch{return Qm(e,o).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}))}),ta=$("$ZodString",(e,t)=>{Oe.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Sp(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),Ne=$("$ZodStringFormat",(e,t)=>{xs.init(e,t),ta.init(e,t)}),Wp=$("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=fp),Ne.init(e,t)}),Hp=$("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=pi(r))}else t.pattern??(t.pattern=pi());Ne.init(e,t)}),Zp=$("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=mp),Ne.init(e,t)}),qp=$("$ZodURL",(e,t)=>{Ne.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),o=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=o.href:n.value=r;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Gp=$("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=hp()),Ne.init(e,t)}),Yp=$("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=dp),Ne.init(e,t)}),Qp=$("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=op),Ne.init(e,t)}),Kp=$("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=ap),Ne.init(e,t)}),Jp=$("$ZodULID",(e,t)=>{t.pattern??(t.pattern=ip),Ne.init(e,t)}),Xp=$("$ZodXID",(e,t)=>{t.pattern??(t.pattern=cp),Ne.init(e,t)}),eh=$("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=lp),Ne.init(e,t)}),th=$("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=jp(t)),Ne.init(e,t)}),nh=$("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=_p),Ne.init(e,t)}),rh=$("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=kp(t)),Ne.init(e,t)}),sh=$("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=up),Ne.init(e,t)}),oh=$("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=gp),Ne.init(e,t),e._zod.bag.format="ipv4"}),ah=$("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=xp),Ne.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),ih=$("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=vp),Ne.init(e,t)}),ch=$("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=yp),Ne.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[o,a]=r;if(!a)throw new Error;const i=Number(a);if(`${i}`!==a)throw new Error;if(i<0||i>128)throw new Error;new URL(`http://[${o}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function ol(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const lh=$("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=bp),Ne.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{ol(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function dh(e){if(!Xc.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return ol(n)}const uh=$("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Xc),Ne.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{dh(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),fh=$("$ZodE164",(e,t)=>{t.pattern??(t.pattern=wp),Ne.init(e,t)});function mh(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const o=JSON.parse(atob(r));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}const ph=$("$ZodJWT",(e,t)=>{Ne.init(e,t),e._zod.check=n=>{mh(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),al=$("$ZodNumber",(e,t)=>{Oe.init(e,t),e._zod.pattern=e._zod.bag.pattern??Np,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const o=n.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return n;const a=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...a?{received:a}:{}}),n}}),hh=$("$ZodNumberFormat",(e,t)=>{Tp.init(e,t),al.init(e,t)}),gh=$("$ZodUnknown",(e,t)=>{Oe.init(e,t),e._zod.parse=n=>n}),xh=$("$ZodNever",(e,t)=>{Oe.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function hi(e,t,n){e.issues.length&&t.issues.push(...Yc(n,e.issues)),t.value[n]=e.value}const vh=$("$ZodArray",(e,t)=>{Oe.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!Array.isArray(o))return n.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),n;n.value=Array(o.length);const a=[];for(let i=0;i<o.length;i++){const c=o[i],l=t.element._zod.run({value:c,issues:[]},r);l instanceof Promise?a.push(l.then(d=>hi(d,n,i))):hi(l,n,i)}return a.length?Promise.all(a).then(()=>n):n}});function Xr(e,t,n,r,o){if(e.issues.length){if(o&&!(n in r))return;t.issues.push(...Yc(n,e.issues))}e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function il(e){const t=Object.keys(e.shape);for(const r of t)if(!e.shape?.[r]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${r}": expected a Zod schema`);const n=$m(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function cl(e,t,n,r,o,a){const i=[],c=o.keySet,l=o.catchall._zod,d=l.def.type,f=l.optout==="optional";for(const u in t){if(c.has(u))continue;if(d==="never"){i.push(u);continue}const h=l.run({value:t[u],issues:[]},r);h instanceof Promise?e.push(h.then(g=>Xr(g,n,u,t,f))):Xr(h,n,u,t,f)}return i.length&&n.issues.push({code:"unrecognized_keys",keys:i,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}const yh=$("$ZodObject",(e,t)=>{if(Oe.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const c=t.shape;Object.defineProperty(t,"shape",{get:()=>{const l={...c};return Object.defineProperty(t,"shape",{value:l}),l}})}const r=Yo(()=>il(t));be(e._zod,"propValues",()=>{const c=t.shape,l={};for(const d in c){const f=c[d]._zod;if(f.values){l[d]??(l[d]=new Set);for(const u of f.values)l[d].add(u)}}return l});const o=Jr,a=t.catchall;let i;e._zod.parse=(c,l)=>{i??(i=r.value);const d=c.value;if(!o(d))return c.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),c;c.value={};const f=[],u=i.shape;for(const h of i.keys){const g=u[h],y=g._zod.optout==="optional",x=g._zod.run({value:d[h],issues:[]},l);x instanceof Promise?f.push(x.then(p=>Xr(p,c,h,d,y))):Xr(x,c,h,d,y)}return a?cl(f,d,c,l,r.value,e):f.length?Promise.all(f).then(()=>c):c}}),bh=$("$ZodObjectJIT",(e,t)=>{yh.init(e,t);const n=e._zod.parse,r=Yo(()=>il(t)),o=h=>{const g=new Bp(["shape","payload","ctx"]),y=r.value,x=w=>{const b=mi(w);return`shape[${b}]._zod.run({ value: input[${b}], issues: [] }, ctx)`};g.write("const input = payload.value;");const p=Object.create(null);let v=0;for(const w of y.keys)p[w]=`key_${v++}`;g.write("const newResult = {};");for(const w of y.keys){const b=p[w],j=mi(w),I=h[w]?._zod?.optout==="optional";g.write(`const ${b} = ${x(w)};`),I?g.write(`
|
|
4
4
|
if (${b}.issues.length) {
|
|
5
5
|
if (${j} in input) {
|
|
6
6
|
payload.issues = payload.issues.concat(${b}.issues.map(iss => ({
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
newResult[${j}] = ${b}.value;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
`)}g.write("payload.value = newResult;"),g.write("return payload;");const _=g.compile();return(w,b)=>_(h,w,b)};let a;const i=Jr,c=!Wc.jitless,d=c&&Rm.value,f=t.catchall;let u;e._zod.parse=(h,g)=>{u??(u=r.value);const y=h.value;return i(y)?c&&d&&g?.async===!1&&g.jitless!==!0?(a||(a=o(t.shape)),h=a(h,g),f?il([],y,h,g,u,e):h):n(h,g):(h.issues.push({expected:"object",code:"invalid_type",input:y,inst:e}),h)}});function gi(e,t,n,r){for(const a of e)if(a.issues.length===0)return t.value=a.value,t;const o=e.filter(a=>!Ln(a));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(a=>a.issues.map(i=>bn(i,r,yn())))}),t)}const vh=$("$ZodUnion",(e,t)=>{Oe.init(e,t),be(e._zod,"optin",()=>t.options.some(o=>o._zod.optin==="optional")?"optional":void 0),be(e._zod,"optout",()=>t.options.some(o=>o._zod.optout==="optional")?"optional":void 0),be(e._zod,"values",()=>{if(t.options.every(o=>o._zod.values))return new Set(t.options.flatMap(o=>Array.from(o._zod.values)))}),be(e._zod,"pattern",()=>{if(t.options.every(o=>o._zod.pattern)){const o=t.options.map(a=>a._zod.pattern);return new RegExp(`^(${o.map(a=>Ko(a.source)).join("|")})$`)}});const n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(o,a)=>{if(n)return r(o,a);let i=!1;const c=[];for(const l of t.options){const d=l._zod.run({value:o.value,issues:[]},a);if(d instanceof Promise)c.push(d),i=!0;else{if(d.issues.length===0)return d;c.push(d)}}return i?Promise.all(c).then(l=>gi(l,o,e,a)):gi(c,o,e,a)}}),yh=$("$ZodIntersection",(e,t)=>{Oe.init(e,t),e._zod.parse=(n,r)=>{const o=n.value,a=t.left._zod.run({value:o,issues:[]},r),i=t.right._zod.run({value:o,issues:[]},r);return a instanceof Promise||i instanceof Promise?Promise.all([a,i]).then(([l,d])=>xi(n,l,d)):xi(n,a,i)}});function jo(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(mr(e)&&mr(t)){const n=Object.keys(t),r=Object.keys(e).filter(a=>n.indexOf(a)!==-1),o={...e,...t};for(const a of r){const i=jo(e[a],t[a]);if(!i.valid)return{valid:!1,mergeErrorPath:[a,...i.mergeErrorPath]};o[a]=i.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const o=e[r],a=t[r],i=jo(o,a);if(!i.valid)return{valid:!1,mergeErrorPath:[r,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function xi(e,t,n){const r=new Map;let o;for(const c of t.issues)if(c.code==="unrecognized_keys"){o??(o=c);for(const l of c.keys)r.has(l)||r.set(l,{}),r.get(l).l=!0}else e.issues.push(c);for(const c of n.issues)if(c.code==="unrecognized_keys")for(const l of c.keys)r.has(l)||r.set(l,{}),r.get(l).r=!0;else e.issues.push(c);const a=[...r].filter(([,c])=>c.l&&c.r).map(([c])=>c);if(a.length&&o&&e.issues.push({...o,keys:a}),Ln(e))return e;const i=jo(t.value,n.value);if(!i.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);return e.value=i.data,e}const bh=$("$ZodEnum",(e,t)=>{Oe.init(e,t);const n=Hc(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(o=>Om.has(typeof o)).map(o=>typeof o=="string"?Fn(o):o.toString()).join("|")})$`),e._zod.parse=(o,a)=>{const i=o.value;return r.has(i)||o.issues.push({code:"invalid_value",values:n,input:i,inst:e}),o}}),wh=$("$ZodLiteral",(e,t)=>{if(Oe.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?Fn(r):r?Fn(r.toString()):String(r)).join("|")})$`),e._zod.parse=(r,o)=>{const a=r.value;return n.has(a)||r.issues.push({code:"invalid_value",values:t.values,input:a,inst:e}),r}}),_h=$("$ZodTransform",(e,t)=>{Oe.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Vc(e.constructor.name);const o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(n.value=i,n));if(o instanceof Promise)throw new Dn;return n.value=o,n}});function vi(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const cl=$("$ZodOptional",(e,t)=>{Oe.init(e,t),e._zod.optin="optional",e._zod.optout="optional",be(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),be(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Ko(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(t.innerType._zod.optin==="optional"){const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(a=>vi(a,n.value)):vi(o,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),kh=$("$ZodExactOptional",(e,t)=>{cl.init(e,t),be(e._zod,"values",()=>t.innerType._zod.values),be(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),jh=$("$ZodNullable",(e,t)=>{Oe.init(e,t),be(e._zod,"optin",()=>t.innerType._zod.optin),be(e._zod,"optout",()=>t.innerType._zod.optout),be(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Ko(n.source)}|null)$`):void 0}),be(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),Sh=$("$ZodDefault",(e,t)=>{Oe.init(e,t),e._zod.optin="optional",be(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(a=>yi(a,t)):yi(o,t)}});function yi(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Ch=$("$ZodPrefault",(e,t)=>{Oe.init(e,t),e._zod.optin="optional",be(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),Nh=$("$ZodNonOptional",(e,t)=>{Oe.init(e,t),be(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(a=>bi(a,e)):bi(o,e)}});function bi(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const Ah=$("$ZodCatch",(e,t)=>{Oe.init(e,t),be(e._zod,"optin",()=>t.innerType._zod.optin),be(e._zod,"optout",()=>t.innerType._zod.optout),be(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(a=>(n.value=a.value,a.issues.length&&(n.value=t.catchValue({...n,error:{issues:a.issues.map(i=>bn(i,r,yn()))},input:n.value}),n.issues=[]),n)):(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(a=>bn(a,r,yn()))},input:n.value}),n.issues=[]),n)}}),Eh=$("$ZodPipe",(e,t)=>{Oe.init(e,t),be(e._zod,"values",()=>t.in._zod.values),be(e._zod,"optin",()=>t.in._zod.optin),be(e._zod,"optout",()=>t.out._zod.optout),be(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const a=t.out._zod.run(n,r);return a instanceof Promise?a.then(i=>Tr(i,t.in,r)):Tr(a,t.in,r)}const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(a=>Tr(a,t.out,r)):Tr(o,t.out,r)}});function Tr(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const Ih=$("$ZodReadonly",(e,t)=>{Oe.init(e,t),be(e._zod,"propValues",()=>t.innerType._zod.propValues),be(e._zod,"values",()=>t.innerType._zod.values),be(e._zod,"optin",()=>t.innerType?._zod?.optin),be(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(wi):wi(o)}});function wi(e){return e.value=Object.freeze(e.value),e}const Th=$("$ZodCustom",(e,t)=>{ut.init(e,t),Oe.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(a=>_i(a,n,r,e));_i(o,n,r,e)}});function _i(e,t,n,r){if(!e){const o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(pr(o))}}var ki;class Ph{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const r=n[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const o={...r,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function Rh(){return new Ph}(ki=globalThis).__zod_globalRegistry??(ki.__zod_globalRegistry=Rh());const ir=globalThis.__zod_globalRegistry;function Oh(e,t){return new e({type:"string",...ie(t)})}function Mh(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...ie(t)})}function ji(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...ie(t)})}function Lh(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...ie(t)})}function Dh(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...ie(t)})}function $h(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...ie(t)})}function zh(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...ie(t)})}function Fh(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...ie(t)})}function Uh(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...ie(t)})}function Bh(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...ie(t)})}function Vh(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...ie(t)})}function Wh(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...ie(t)})}function Hh(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...ie(t)})}function Zh(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...ie(t)})}function qh(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...ie(t)})}function Gh(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...ie(t)})}function Yh(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...ie(t)})}function Qh(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...ie(t)})}function Kh(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...ie(t)})}function Jh(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...ie(t)})}function Xh(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...ie(t)})}function eg(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...ie(t)})}function tg(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...ie(t)})}function ng(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...ie(t)})}function rg(e,t){return new e({type:"string",format:"date",check:"string_format",...ie(t)})}function sg(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...ie(t)})}function og(e,t){return new e({type:"string",format:"duration",check:"string_format",...ie(t)})}function ag(e,t){return new e({type:"number",checks:[],...ie(t)})}function ig(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...ie(t)})}function cg(e){return new e({type:"unknown"})}function lg(e,t){return new e({type:"never",...ie(t)})}function Si(e,t){return new nl({check:"less_than",...ie(t),value:e,inclusive:!1})}function Js(e,t){return new nl({check:"less_than",...ie(t),value:e,inclusive:!0})}function Ci(e,t){return new rl({check:"greater_than",...ie(t),value:e,inclusive:!1})}function Xs(e,t){return new rl({check:"greater_than",...ie(t),value:e,inclusive:!0})}function Ni(e,t){return new Np({check:"multiple_of",...ie(t),value:e})}function ll(e,t){return new Ep({check:"max_length",...ie(t),maximum:e})}function es(e,t){return new Ip({check:"min_length",...ie(t),minimum:e})}function dl(e,t){return new Tp({check:"length_equals",...ie(t),length:e})}function dg(e,t){return new Pp({check:"string_format",format:"regex",...ie(t),pattern:e})}function ug(e){return new Rp({check:"string_format",format:"lowercase",...ie(e)})}function fg(e){return new Op({check:"string_format",format:"uppercase",...ie(e)})}function mg(e,t){return new Mp({check:"string_format",format:"includes",...ie(t),includes:e})}function pg(e,t){return new Lp({check:"string_format",format:"starts_with",...ie(t),prefix:e})}function hg(e,t){return new Dp({check:"string_format",format:"ends_with",...ie(t),suffix:e})}function Vn(e){return new $p({check:"overwrite",tx:e})}function gg(e){return Vn(t=>t.normalize(e))}function xg(){return Vn(e=>e.trim())}function vg(){return Vn(e=>e.toLowerCase())}function yg(){return Vn(e=>e.toUpperCase())}function bg(){return Vn(e=>Pm(e))}function wg(e,t,n){return new e({type:"array",element:t,...ie(n)})}function _g(e,t,n){return new e({type:"custom",check:"custom",fn:t,...ie(n)})}function kg(e){const t=jg(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(pr(r,n.value,t._zod.def));else{const o=r;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=t),o.continue??(o.continue=!t._zod.def.abort),n.issues.push(pr(o))}},e(n.value,n)));return t}function jg(e,t){const n=new ut({check:"custom",...ie(t)});return n._zod.check=e,n}function ul(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??ir,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function Ze(e,t,n={path:[],schemaPath:[]}){var r;const o=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;const i={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,i);const c=e._zod.toJSONSchema?.();if(c)i.schema=c;else{const f={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,f);else{const h=i.schema,g=t.processors[o.type];if(!g)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);g(e,t,h,f)}const u=e._zod.parent;u&&(i.ref||(i.ref=u),Ze(u,t,f),t.seen.get(u).isParent=!0)}const l=t.metadataRegistry.get(e);return l&&Object.assign(i.schema,l),t.io==="input"&&nt(e)&&(delete i.schema.examples,delete i.schema.default),t.io==="input"&&i.schema._prefault&&((r=i.schema).default??(r.default=i.schema._prefault)),delete i.schema._prefault,t.seen.get(e).schema}function fl(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const i of e.seen.entries()){const c=e.metadataRegistry.get(i[0])?.id;if(c){const l=r.get(c);if(l&&l!==i[0])throw new Error(`Duplicate schema id "${c}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(c,i[0])}}const o=i=>{const c=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const u=e.external.registry.get(i[0])?.id,h=e.external.uri??(y=>y);if(u)return{ref:h(u)};const g=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=g,{defId:g,ref:`${h("__shared")}#/${c}/${g}`}}if(i[1]===n)return{ref:"#"};const d=`#/${c}/`,f=i[1].schema.id??`__schema${e.counter++}`;return{defId:f,ref:d+f}},a=i=>{if(i[1].schema.$ref)return;const c=i[1],{ref:l,defId:d}=o(i);c.def={...c.schema},d&&(c.defId=d);const f=c.schema;for(const u in f)delete f[u];f.$ref=l};if(e.cycles==="throw")for(const i of e.seen.entries()){const c=i[1];if(c.cycle)throw new Error(`Cycle detected: #/${c.cycle?.join("/")}/<root>
|
|
37
|
+
`)}g.write("payload.value = newResult;"),g.write("return payload;");const _=g.compile();return(w,b)=>_(h,w,b)};let a;const i=Jr,c=!Hc.jitless,d=c&&Lm.value,f=t.catchall;let u;e._zod.parse=(h,g)=>{u??(u=r.value);const y=h.value;return i(y)?c&&d&&g?.async===!1&&g.jitless!==!0?(a||(a=o(t.shape)),h=a(h,g),f?cl([],y,h,g,u,e):h):n(h,g):(h.issues.push({expected:"object",code:"invalid_type",input:y,inst:e}),h)}});function gi(e,t,n,r){for(const a of e)if(a.issues.length===0)return t.value=a.value,t;const o=e.filter(a=>!Ln(a));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(a=>a.issues.map(i=>bn(i,r,yn())))}),t)}const wh=$("$ZodUnion",(e,t)=>{Oe.init(e,t),be(e._zod,"optin",()=>t.options.some(o=>o._zod.optin==="optional")?"optional":void 0),be(e._zod,"optout",()=>t.options.some(o=>o._zod.optout==="optional")?"optional":void 0),be(e._zod,"values",()=>{if(t.options.every(o=>o._zod.values))return new Set(t.options.flatMap(o=>Array.from(o._zod.values)))}),be(e._zod,"pattern",()=>{if(t.options.every(o=>o._zod.pattern)){const o=t.options.map(a=>a._zod.pattern);return new RegExp(`^(${o.map(a=>Ko(a.source)).join("|")})$`)}});const n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(o,a)=>{if(n)return r(o,a);let i=!1;const c=[];for(const l of t.options){const d=l._zod.run({value:o.value,issues:[]},a);if(d instanceof Promise)c.push(d),i=!0;else{if(d.issues.length===0)return d;c.push(d)}}return i?Promise.all(c).then(l=>gi(l,o,e,a)):gi(c,o,e,a)}}),_h=$("$ZodIntersection",(e,t)=>{Oe.init(e,t),e._zod.parse=(n,r)=>{const o=n.value,a=t.left._zod.run({value:o,issues:[]},r),i=t.right._zod.run({value:o,issues:[]},r);return a instanceof Promise||i instanceof Promise?Promise.all([a,i]).then(([l,d])=>xi(n,l,d)):xi(n,a,i)}});function jo(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(mr(e)&&mr(t)){const n=Object.keys(t),r=Object.keys(e).filter(a=>n.indexOf(a)!==-1),o={...e,...t};for(const a of r){const i=jo(e[a],t[a]);if(!i.valid)return{valid:!1,mergeErrorPath:[a,...i.mergeErrorPath]};o[a]=i.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const o=e[r],a=t[r],i=jo(o,a);if(!i.valid)return{valid:!1,mergeErrorPath:[r,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function xi(e,t,n){const r=new Map;let o;for(const c of t.issues)if(c.code==="unrecognized_keys"){o??(o=c);for(const l of c.keys)r.has(l)||r.set(l,{}),r.get(l).l=!0}else e.issues.push(c);for(const c of n.issues)if(c.code==="unrecognized_keys")for(const l of c.keys)r.has(l)||r.set(l,{}),r.get(l).r=!0;else e.issues.push(c);const a=[...r].filter(([,c])=>c.l&&c.r).map(([c])=>c);if(a.length&&o&&e.issues.push({...o,keys:a}),Ln(e))return e;const i=jo(t.value,n.value);if(!i.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);return e.value=i.data,e}const kh=$("$ZodEnum",(e,t)=>{Oe.init(e,t);const n=Zc(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(o=>Dm.has(typeof o)).map(o=>typeof o=="string"?Fn(o):o.toString()).join("|")})$`),e._zod.parse=(o,a)=>{const i=o.value;return r.has(i)||o.issues.push({code:"invalid_value",values:n,input:i,inst:e}),o}}),jh=$("$ZodLiteral",(e,t)=>{if(Oe.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?Fn(r):r?Fn(r.toString()):String(r)).join("|")})$`),e._zod.parse=(r,o)=>{const a=r.value;return n.has(a)||r.issues.push({code:"invalid_value",values:t.values,input:a,inst:e}),r}}),Sh=$("$ZodTransform",(e,t)=>{Oe.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Wc(e.constructor.name);const o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(n.value=i,n));if(o instanceof Promise)throw new Dn;return n.value=o,n}});function vi(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const ll=$("$ZodOptional",(e,t)=>{Oe.init(e,t),e._zod.optin="optional",e._zod.optout="optional",be(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),be(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Ko(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(t.innerType._zod.optin==="optional"){const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(a=>vi(a,n.value)):vi(o,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),Ch=$("$ZodExactOptional",(e,t)=>{ll.init(e,t),be(e._zod,"values",()=>t.innerType._zod.values),be(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),Nh=$("$ZodNullable",(e,t)=>{Oe.init(e,t),be(e._zod,"optin",()=>t.innerType._zod.optin),be(e._zod,"optout",()=>t.innerType._zod.optout),be(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Ko(n.source)}|null)$`):void 0}),be(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),Ah=$("$ZodDefault",(e,t)=>{Oe.init(e,t),e._zod.optin="optional",be(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(a=>yi(a,t)):yi(o,t)}});function yi(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Eh=$("$ZodPrefault",(e,t)=>{Oe.init(e,t),e._zod.optin="optional",be(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),Ih=$("$ZodNonOptional",(e,t)=>{Oe.init(e,t),be(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(a=>bi(a,e)):bi(o,e)}});function bi(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const Th=$("$ZodCatch",(e,t)=>{Oe.init(e,t),be(e._zod,"optin",()=>t.innerType._zod.optin),be(e._zod,"optout",()=>t.innerType._zod.optout),be(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(a=>(n.value=a.value,a.issues.length&&(n.value=t.catchValue({...n,error:{issues:a.issues.map(i=>bn(i,r,yn()))},input:n.value}),n.issues=[]),n)):(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(a=>bn(a,r,yn()))},input:n.value}),n.issues=[]),n)}}),Ph=$("$ZodPipe",(e,t)=>{Oe.init(e,t),be(e._zod,"values",()=>t.in._zod.values),be(e._zod,"optin",()=>t.in._zod.optin),be(e._zod,"optout",()=>t.out._zod.optout),be(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const a=t.out._zod.run(n,r);return a instanceof Promise?a.then(i=>Tr(i,t.in,r)):Tr(a,t.in,r)}const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(a=>Tr(a,t.out,r)):Tr(o,t.out,r)}});function Tr(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const Rh=$("$ZodReadonly",(e,t)=>{Oe.init(e,t),be(e._zod,"propValues",()=>t.innerType._zod.propValues),be(e._zod,"values",()=>t.innerType._zod.values),be(e._zod,"optin",()=>t.innerType?._zod?.optin),be(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(wi):wi(o)}});function wi(e){return e.value=Object.freeze(e.value),e}const Oh=$("$ZodCustom",(e,t)=>{ut.init(e,t),Oe.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(a=>_i(a,n,r,e));_i(o,n,r,e)}});function _i(e,t,n,r){if(!e){const o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(pr(o))}}var ki;class Mh{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const r=n[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const o={...r,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function Lh(){return new Mh}(ki=globalThis).__zod_globalRegistry??(ki.__zod_globalRegistry=Lh());const ir=globalThis.__zod_globalRegistry;function Dh(e,t){return new e({type:"string",...ie(t)})}function $h(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...ie(t)})}function ji(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...ie(t)})}function zh(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...ie(t)})}function Fh(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...ie(t)})}function Uh(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...ie(t)})}function Bh(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...ie(t)})}function Vh(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...ie(t)})}function Wh(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...ie(t)})}function Hh(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...ie(t)})}function Zh(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...ie(t)})}function qh(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...ie(t)})}function Gh(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...ie(t)})}function Yh(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...ie(t)})}function Qh(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...ie(t)})}function Kh(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...ie(t)})}function Jh(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...ie(t)})}function Xh(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...ie(t)})}function eg(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...ie(t)})}function tg(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...ie(t)})}function ng(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...ie(t)})}function rg(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...ie(t)})}function sg(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...ie(t)})}function og(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...ie(t)})}function ag(e,t){return new e({type:"string",format:"date",check:"string_format",...ie(t)})}function ig(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...ie(t)})}function cg(e,t){return new e({type:"string",format:"duration",check:"string_format",...ie(t)})}function lg(e,t){return new e({type:"number",checks:[],...ie(t)})}function dg(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...ie(t)})}function ug(e){return new e({type:"unknown"})}function fg(e,t){return new e({type:"never",...ie(t)})}function Si(e,t){return new rl({check:"less_than",...ie(t),value:e,inclusive:!1})}function Js(e,t){return new rl({check:"less_than",...ie(t),value:e,inclusive:!0})}function Ci(e,t){return new sl({check:"greater_than",...ie(t),value:e,inclusive:!1})}function Xs(e,t){return new sl({check:"greater_than",...ie(t),value:e,inclusive:!0})}function Ni(e,t){return new Ip({check:"multiple_of",...ie(t),value:e})}function dl(e,t){return new Pp({check:"max_length",...ie(t),maximum:e})}function es(e,t){return new Rp({check:"min_length",...ie(t),minimum:e})}function ul(e,t){return new Op({check:"length_equals",...ie(t),length:e})}function mg(e,t){return new Mp({check:"string_format",format:"regex",...ie(t),pattern:e})}function pg(e){return new Lp({check:"string_format",format:"lowercase",...ie(e)})}function hg(e){return new Dp({check:"string_format",format:"uppercase",...ie(e)})}function gg(e,t){return new $p({check:"string_format",format:"includes",...ie(t),includes:e})}function xg(e,t){return new zp({check:"string_format",format:"starts_with",...ie(t),prefix:e})}function vg(e,t){return new Fp({check:"string_format",format:"ends_with",...ie(t),suffix:e})}function Vn(e){return new Up({check:"overwrite",tx:e})}function yg(e){return Vn(t=>t.normalize(e))}function bg(){return Vn(e=>e.trim())}function wg(){return Vn(e=>e.toLowerCase())}function _g(){return Vn(e=>e.toUpperCase())}function kg(){return Vn(e=>Mm(e))}function jg(e,t,n){return new e({type:"array",element:t,...ie(n)})}function Sg(e,t,n){return new e({type:"custom",check:"custom",fn:t,...ie(n)})}function Cg(e){const t=Ng(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(pr(r,n.value,t._zod.def));else{const o=r;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=t),o.continue??(o.continue=!t._zod.def.abort),n.issues.push(pr(o))}},e(n.value,n)));return t}function Ng(e,t){const n=new ut({check:"custom",...ie(t)});return n._zod.check=e,n}function fl(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??ir,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function Ze(e,t,n={path:[],schemaPath:[]}){var r;const o=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;const i={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,i);const c=e._zod.toJSONSchema?.();if(c)i.schema=c;else{const f={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,f);else{const h=i.schema,g=t.processors[o.type];if(!g)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);g(e,t,h,f)}const u=e._zod.parent;u&&(i.ref||(i.ref=u),Ze(u,t,f),t.seen.get(u).isParent=!0)}const l=t.metadataRegistry.get(e);return l&&Object.assign(i.schema,l),t.io==="input"&&nt(e)&&(delete i.schema.examples,delete i.schema.default),t.io==="input"&&i.schema._prefault&&((r=i.schema).default??(r.default=i.schema._prefault)),delete i.schema._prefault,t.seen.get(e).schema}function ml(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const i of e.seen.entries()){const c=e.metadataRegistry.get(i[0])?.id;if(c){const l=r.get(c);if(l&&l!==i[0])throw new Error(`Duplicate schema id "${c}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(c,i[0])}}const o=i=>{const c=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const u=e.external.registry.get(i[0])?.id,h=e.external.uri??(y=>y);if(u)return{ref:h(u)};const g=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=g,{defId:g,ref:`${h("__shared")}#/${c}/${g}`}}if(i[1]===n)return{ref:"#"};const d=`#/${c}/`,f=i[1].schema.id??`__schema${e.counter++}`;return{defId:f,ref:d+f}},a=i=>{if(i[1].schema.$ref)return;const c=i[1],{ref:l,defId:d}=o(i);c.def={...c.schema},d&&(c.defId=d);const f=c.schema;for(const u in f)delete f[u];f.$ref=l};if(e.cycles==="throw")for(const i of e.seen.entries()){const c=i[1];if(c.cycle)throw new Error(`Cycle detected: #/${c.cycle?.join("/")}/<root>
|
|
38
38
|
|
|
39
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const i of e.seen.entries()){const c=i[1];if(t===i[0]){a(i);continue}if(e.external){const d=e.external.registry.get(i[0])?.id;if(t!==i[0]&&d){a(i);continue}}if(e.metadataRegistry.get(i[0])?.id){a(i);continue}if(c.cycle){a(i);continue}if(c.count>1&&e.reused==="ref"){a(i);continue}}}function ml(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=i=>{const c=e.seen.get(i);if(c.ref===null)return;const l=c.def??c.schema,d={...l},f=c.ref;if(c.ref=null,f){r(f);const h=e.seen.get(f),g=h.schema;if(g.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(l.allOf=l.allOf??[],l.allOf.push(g)):Object.assign(l,g),Object.assign(l,d),i._zod.parent===f)for(const x in l)x==="$ref"||x==="allOf"||x in d||delete l[x];if(g.$ref&&h.def)for(const x in l)x==="$ref"||x==="allOf"||x in h.def&&JSON.stringify(l[x])===JSON.stringify(h.def[x])&&delete l[x]}const u=i._zod.parent;if(u&&u!==f){r(u);const h=e.seen.get(u);if(h?.schema.$ref&&(l.$ref=h.schema.$ref,h.def))for(const g in l)g==="$ref"||g==="allOf"||g in h.def&&JSON.stringify(l[g])===JSON.stringify(h.def[g])&&delete l[g]}e.override({zodSchema:i,jsonSchema:l,path:c.path??[]})};for(const i of[...e.seen.entries()].reverse())r(i[0]);const o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const i=e.external.registry.get(t)?.id;if(!i)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(i)}Object.assign(o,n.def??n.schema);const a=e.external?.defs??{};for(const i of e.seen.entries()){const c=i[1];c.def&&c.defId&&(a[c.defId]=c.def)}e.external||Object.keys(a).length>0&&(e.target==="draft-2020-12"?o.$defs=a:o.definitions=a);try{const i=JSON.parse(JSON.stringify(o));return Object.defineProperty(i,"~standard",{value:{...t["~standard"],jsonSchema:{input:ts(t,"input",e.processors),output:ts(t,"output",e.processors)}},enumerable:!1,writable:!1}),i}catch{throw new Error("Error converting schema to JSON.")}}function nt(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return nt(r.element,n);if(r.type==="set")return nt(r.valueType,n);if(r.type==="lazy")return nt(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return nt(r.innerType,n);if(r.type==="intersection")return nt(r.left,n)||nt(r.right,n);if(r.type==="record"||r.type==="map")return nt(r.keyType,n)||nt(r.valueType,n);if(r.type==="pipe")return nt(r.in,n)||nt(r.out,n);if(r.type==="object"){for(const o in r.shape)if(nt(r.shape[o],n))return!0;return!1}if(r.type==="union"){for(const o of r.options)if(nt(o,n))return!0;return!1}if(r.type==="tuple"){for(const o of r.items)if(nt(o,n))return!0;return!!(r.rest&&nt(r.rest,n))}return!1}const Sg=(e,t={})=>n=>{const r=ul({...n,processors:t});return Ze(e,r),fl(r,e),ml(r,e)},ts=(e,t,n={})=>r=>{const{libraryOptions:o,target:a}=r??{},i=ul({...o??{},target:a,io:t,processors:n});return Ze(e,i),fl(i,e),ml(i,e)},Cg={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Ng=(e,t,n,r)=>{const o=n;o.type="string";const{minimum:a,maximum:i,format:c,patterns:l,contentEncoding:d}=e._zod.bag;if(typeof a=="number"&&(o.minLength=a),typeof i=="number"&&(o.maxLength=i),c&&(o.format=Cg[c]??c,o.format===""&&delete o.format,c==="time"&&delete o.format),d&&(o.contentEncoding=d),l&&l.size>0){const f=[...l];f.length===1?o.pattern=f[0].source:f.length>1&&(o.allOf=[...f.map(u=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:u.source}))])}},Ag=(e,t,n,r)=>{const o=n,{minimum:a,maximum:i,format:c,multipleOf:l,exclusiveMaximum:d,exclusiveMinimum:f}=e._zod.bag;typeof c=="string"&&c.includes("int")?o.type="integer":o.type="number",typeof f=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.minimum=f,o.exclusiveMinimum=!0):o.exclusiveMinimum=f),typeof a=="number"&&(o.minimum=a,typeof f=="number"&&t.target!=="draft-04"&&(f>=a?delete o.minimum:delete o.exclusiveMinimum)),typeof d=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.maximum=d,o.exclusiveMaximum=!0):o.exclusiveMaximum=d),typeof i=="number"&&(o.maximum=i,typeof d=="number"&&t.target!=="draft-04"&&(d<=i?delete o.maximum:delete o.exclusiveMaximum)),typeof l=="number"&&(o.multipleOf=l)},Eg=(e,t,n,r)=>{n.not={}},Ig=(e,t,n,r)=>{},Tg=(e,t,n,r)=>{const o=e._zod.def,a=Hc(o.entries);a.every(i=>typeof i=="number")&&(n.type="number"),a.every(i=>typeof i=="string")&&(n.type="string"),n.enum=a},Pg=(e,t,n,r)=>{const o=e._zod.def,a=[];for(const i of o.values)if(i===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof i=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");a.push(Number(i))}else a.push(i);if(a.length!==0)if(a.length===1){const i=a[0];n.type=i===null?"null":typeof i,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[i]:n.const=i}else a.every(i=>typeof i=="number")&&(n.type="number"),a.every(i=>typeof i=="string")&&(n.type="string"),a.every(i=>typeof i=="boolean")&&(n.type="boolean"),a.every(i=>i===null)&&(n.type="null"),n.enum=a},Rg=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Og=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Mg=(e,t,n,r)=>{const o=n,a=e._zod.def,{minimum:i,maximum:c}=e._zod.bag;typeof i=="number"&&(o.minItems=i),typeof c=="number"&&(o.maxItems=c),o.type="array",o.items=Ze(a.element,t,{...r,path:[...r.path,"items"]})},Lg=(e,t,n,r)=>{const o=n,a=e._zod.def;o.type="object",o.properties={};const i=a.shape;for(const d in i)o.properties[d]=Ze(i[d],t,{...r,path:[...r.path,"properties",d]});const c=new Set(Object.keys(i)),l=new Set([...c].filter(d=>{const f=a.shape[d]._zod;return t.io==="input"?f.optin===void 0:f.optout===void 0}));l.size>0&&(o.required=Array.from(l)),a.catchall?._zod.def.type==="never"?o.additionalProperties=!1:a.catchall?a.catchall&&(o.additionalProperties=Ze(a.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},Dg=(e,t,n,r)=>{const o=e._zod.def,a=o.inclusive===!1,i=o.options.map((c,l)=>Ze(c,t,{...r,path:[...r.path,a?"oneOf":"anyOf",l]}));a?n.oneOf=i:n.anyOf=i},$g=(e,t,n,r)=>{const o=e._zod.def,a=Ze(o.left,t,{...r,path:[...r.path,"allOf",0]}),i=Ze(o.right,t,{...r,path:[...r.path,"allOf",1]}),c=d=>"allOf"in d&&Object.keys(d).length===1,l=[...c(a)?a.allOf:[a],...c(i)?i.allOf:[i]];n.allOf=l},zg=(e,t,n,r)=>{const o=e._zod.def,a=Ze(o.innerType,t,r),i=t.seen.get(e);t.target==="openapi-3.0"?(i.ref=o.innerType,n.nullable=!0):n.anyOf=[a,{type:"null"}]},Fg=(e,t,n,r)=>{const o=e._zod.def;Ze(o.innerType,t,r);const a=t.seen.get(e);a.ref=o.innerType},Ug=(e,t,n,r)=>{const o=e._zod.def;Ze(o.innerType,t,r);const a=t.seen.get(e);a.ref=o.innerType,n.default=JSON.parse(JSON.stringify(o.defaultValue))},Bg=(e,t,n,r)=>{const o=e._zod.def;Ze(o.innerType,t,r);const a=t.seen.get(e);a.ref=o.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},Vg=(e,t,n,r)=>{const o=e._zod.def;Ze(o.innerType,t,r);const a=t.seen.get(e);a.ref=o.innerType;let i;try{i=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=i},Wg=(e,t,n,r)=>{const o=e._zod.def,a=t.io==="input"?o.in._zod.def.type==="transform"?o.out:o.in:o.out;Ze(a,t,r);const i=t.seen.get(e);i.ref=a},Hg=(e,t,n,r)=>{const o=e._zod.def;Ze(o.innerType,t,r);const a=t.seen.get(e);a.ref=o.innerType,n.readOnly=!0},pl=(e,t,n,r)=>{const o=e._zod.def;Ze(o.innerType,t,r);const a=t.seen.get(e);a.ref=o.innerType},Zg=$("ZodISODateTime",(e,t)=>{Jp.init(e,t),Ie.init(e,t)});function qg(e){return ng(Zg,e)}const Gg=$("ZodISODate",(e,t)=>{Xp.init(e,t),Ie.init(e,t)});function Yg(e){return rg(Gg,e)}const Qg=$("ZodISOTime",(e,t)=>{eh.init(e,t),Ie.init(e,t)});function Kg(e){return sg(Qg,e)}const Jg=$("ZodISODuration",(e,t)=>{th.init(e,t),Ie.init(e,t)});function Xg(e){return og(Jg,e)}const ex=(e,t)=>{Qc.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>Hm(e,n)},flatten:{value:n=>Wm(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,ko,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,ko,2)}},isEmpty:{get(){return e.issues.length===0}}})},wt=$("ZodError",ex,{Parent:Error}),tx=Xo(wt),nx=ea(wt),rx=hs(wt),sx=gs(wt),ox=Gm(wt),ax=Ym(wt),ix=Qm(wt),cx=Km(wt),lx=Jm(wt),dx=Xm(wt),ux=ep(wt),fx=tp(wt),Me=$("ZodType",(e,t)=>(Oe.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:ts(e,"input"),output:ts(e,"output")}}),e.toJSONSchema=Sg(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(ln(t,{checks:[...t.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0}),e.with=e.check,e.clone=(n,r)=>dn(e,n,r),e.brand=()=>e,e.register=((n,r)=>(n.add(e,r),e)),e.parse=(n,r)=>tx(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>rx(e,n,r),e.parseAsync=async(n,r)=>nx(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>sx(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>ox(e,n,r),e.decode=(n,r)=>ax(e,n,r),e.encodeAsync=async(n,r)=>ix(e,n,r),e.decodeAsync=async(n,r)=>cx(e,n,r),e.safeEncode=(n,r)=>lx(e,n,r),e.safeDecode=(n,r)=>dx(e,n,r),e.safeEncodeAsync=async(n,r)=>ux(e,n,r),e.safeDecodeAsync=async(n,r)=>fx(e,n,r),e.refine=(n,r)=>e.check(cv(n,r)),e.superRefine=n=>e.check(lv(n)),e.overwrite=n=>e.check(Vn(n)),e.optional=()=>Ti(e),e.exactOptional=()=>Yx(e),e.nullable=()=>Pi(e),e.nullish=()=>Ti(Pi(e)),e.nonoptional=n=>tv(e,n),e.array=()=>Dx(e),e.or=n=>Fx([e,n]),e.and=n=>Bx(e,n),e.transform=n=>Ri(e,qx(n)),e.default=n=>Jx(e,n),e.prefault=n=>ev(e,n),e.catch=n=>rv(e,n),e.pipe=n=>Ri(e,n),e.readonly=()=>av(e),e.describe=n=>{const r=e.clone();return ir.add(r,{description:n}),r},Object.defineProperty(e,"description",{get(){return ir.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return ir.get(e);const r=e.clone();return ir.add(r,n[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),hl=$("_ZodString",(e,t)=>{ta.init(e,t),Me.init(e,t),e._zod.processJSONSchema=(r,o,a)=>Ng(e,r,o);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...r)=>e.check(dg(...r)),e.includes=(...r)=>e.check(mg(...r)),e.startsWith=(...r)=>e.check(pg(...r)),e.endsWith=(...r)=>e.check(hg(...r)),e.min=(...r)=>e.check(es(...r)),e.max=(...r)=>e.check(ll(...r)),e.length=(...r)=>e.check(dl(...r)),e.nonempty=(...r)=>e.check(es(1,...r)),e.lowercase=r=>e.check(ug(r)),e.uppercase=r=>e.check(fg(r)),e.trim=()=>e.check(xg()),e.normalize=(...r)=>e.check(gg(...r)),e.toLowerCase=()=>e.check(vg()),e.toUpperCase=()=>e.check(yg()),e.slugify=()=>e.check(bg())}),mx=$("ZodString",(e,t)=>{ta.init(e,t),hl.init(e,t),e.email=n=>e.check(Mh(px,n)),e.url=n=>e.check(Fh(hx,n)),e.jwt=n=>e.check(tg(Ix,n)),e.emoji=n=>e.check(Uh(gx,n)),e.guid=n=>e.check(ji(Ai,n)),e.uuid=n=>e.check(Lh(Pr,n)),e.uuidv4=n=>e.check(Dh(Pr,n)),e.uuidv6=n=>e.check($h(Pr,n)),e.uuidv7=n=>e.check(zh(Pr,n)),e.nanoid=n=>e.check(Bh(xx,n)),e.guid=n=>e.check(ji(Ai,n)),e.cuid=n=>e.check(Vh(vx,n)),e.cuid2=n=>e.check(Wh(yx,n)),e.ulid=n=>e.check(Hh(bx,n)),e.base64=n=>e.check(Jh(Nx,n)),e.base64url=n=>e.check(Xh(Ax,n)),e.xid=n=>e.check(Zh(wx,n)),e.ksuid=n=>e.check(qh(_x,n)),e.ipv4=n=>e.check(Gh(kx,n)),e.ipv6=n=>e.check(Yh(jx,n)),e.cidrv4=n=>e.check(Qh(Sx,n)),e.cidrv6=n=>e.check(Kh(Cx,n)),e.e164=n=>e.check(eg(Ex,n)),e.datetime=n=>e.check(qg(n)),e.date=n=>e.check(Yg(n)),e.time=n=>e.check(Kg(n)),e.duration=n=>e.check(Xg(n))});function rt(e){return Oh(mx,e)}const Ie=$("ZodStringFormat",(e,t)=>{Ne.init(e,t),hl.init(e,t)}),px=$("ZodEmail",(e,t)=>{Vp.init(e,t),Ie.init(e,t)}),Ai=$("ZodGUID",(e,t)=>{Up.init(e,t),Ie.init(e,t)}),Pr=$("ZodUUID",(e,t)=>{Bp.init(e,t),Ie.init(e,t)}),hx=$("ZodURL",(e,t)=>{Wp.init(e,t),Ie.init(e,t)}),gx=$("ZodEmoji",(e,t)=>{Hp.init(e,t),Ie.init(e,t)}),xx=$("ZodNanoID",(e,t)=>{Zp.init(e,t),Ie.init(e,t)}),vx=$("ZodCUID",(e,t)=>{qp.init(e,t),Ie.init(e,t)}),yx=$("ZodCUID2",(e,t)=>{Gp.init(e,t),Ie.init(e,t)}),bx=$("ZodULID",(e,t)=>{Yp.init(e,t),Ie.init(e,t)}),wx=$("ZodXID",(e,t)=>{Qp.init(e,t),Ie.init(e,t)}),_x=$("ZodKSUID",(e,t)=>{Kp.init(e,t),Ie.init(e,t)}),kx=$("ZodIPv4",(e,t)=>{nh.init(e,t),Ie.init(e,t)}),jx=$("ZodIPv6",(e,t)=>{rh.init(e,t),Ie.init(e,t)}),Sx=$("ZodCIDRv4",(e,t)=>{sh.init(e,t),Ie.init(e,t)}),Cx=$("ZodCIDRv6",(e,t)=>{oh.init(e,t),Ie.init(e,t)}),Nx=$("ZodBase64",(e,t)=>{ah.init(e,t),Ie.init(e,t)}),Ax=$("ZodBase64URL",(e,t)=>{ch.init(e,t),Ie.init(e,t)}),Ex=$("ZodE164",(e,t)=>{lh.init(e,t),Ie.init(e,t)}),Ix=$("ZodJWT",(e,t)=>{uh.init(e,t),Ie.init(e,t)}),gl=$("ZodNumber",(e,t)=>{ol.init(e,t),Me.init(e,t),e._zod.processJSONSchema=(r,o,a)=>Ag(e,r,o),e.gt=(r,o)=>e.check(Ci(r,o)),e.gte=(r,o)=>e.check(Xs(r,o)),e.min=(r,o)=>e.check(Xs(r,o)),e.lt=(r,o)=>e.check(Si(r,o)),e.lte=(r,o)=>e.check(Js(r,o)),e.max=(r,o)=>e.check(Js(r,o)),e.int=r=>e.check(Ei(r)),e.safe=r=>e.check(Ei(r)),e.positive=r=>e.check(Ci(0,r)),e.nonnegative=r=>e.check(Xs(0,r)),e.negative=r=>e.check(Si(0,r)),e.nonpositive=r=>e.check(Js(0,r)),e.multipleOf=(r,o)=>e.check(Ni(r,o)),e.step=(r,o)=>e.check(Ni(r,o)),e.finite=()=>e;const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function Tx(e){return ag(gl,e)}const Px=$("ZodNumberFormat",(e,t)=>{fh.init(e,t),gl.init(e,t)});function Ei(e){return ig(Px,e)}const Rx=$("ZodUnknown",(e,t)=>{mh.init(e,t),Me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ig()});function Ii(){return cg(Rx)}const Ox=$("ZodNever",(e,t)=>{ph.init(e,t),Me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Eg(e,n,r)});function Mx(e){return lg(Ox,e)}const Lx=$("ZodArray",(e,t)=>{hh.init(e,t),Me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Mg(e,n,r,o),e.element=t.element,e.min=(n,r)=>e.check(es(n,r)),e.nonempty=n=>e.check(es(1,n)),e.max=(n,r)=>e.check(ll(n,r)),e.length=(n,r)=>e.check(dl(n,r)),e.unwrap=()=>e.element});function Dx(e,t){return wg(Lx,e,t)}const $x=$("ZodObject",(e,t)=>{xh.init(e,t),Me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Lg(e,n,r,o),be(e,"shape",()=>t.shape),e.keyof=()=>Vx(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Ii()}),e.loose=()=>e.clone({...e._zod.def,catchall:Ii()}),e.strict=()=>e.clone({...e._zod.def,catchall:Mx()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>zm(e,n),e.safeExtend=n=>Fm(e,n),e.merge=n=>Um(e,n),e.pick=n=>Dm(e,n),e.omit=n=>$m(e,n),e.partial=(...n)=>Bm(vl,e,n[0]),e.required=(...n)=>Vm(yl,e,n[0])});function xl(e,t){const n={type:"object",shape:e??{},...ie(t)};return new $x(n)}const zx=$("ZodUnion",(e,t)=>{vh.init(e,t),Me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Dg(e,n,r,o),e.options=t.options});function Fx(e,t){return new zx({type:"union",options:e,...ie(t)})}const Ux=$("ZodIntersection",(e,t)=>{yh.init(e,t),Me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>$g(e,n,r,o)});function Bx(e,t){return new Ux({type:"intersection",left:e,right:t})}const So=$("ZodEnum",(e,t)=>{bh.init(e,t),Me.init(e,t),e._zod.processJSONSchema=(r,o,a)=>Tg(e,r,o),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,o)=>{const a={};for(const i of r)if(n.has(i))a[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new So({...t,checks:[],...ie(o),entries:a})},e.exclude=(r,o)=>{const a={...t.entries};for(const i of r)if(n.has(i))delete a[i];else throw new Error(`Key ${i} not found in enum`);return new So({...t,checks:[],...ie(o),entries:a})}});function Vx(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new So({type:"enum",entries:n,...ie(t)})}const Wx=$("ZodLiteral",(e,t)=>{wh.init(e,t),Me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Pg(e,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Hx(e,t){return new Wx({type:"literal",values:Array.isArray(e)?e:[e],...ie(t)})}const Zx=$("ZodTransform",(e,t)=>{_h.init(e,t),Me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Og(e,n),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Vc(e.constructor.name);n.addIssue=a=>{if(typeof a=="string")n.issues.push(pr(a,n.value,t));else{const i=a;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=e),n.issues.push(pr(i))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(a=>(n.value=a,n)):(n.value=o,n)}});function qx(e){return new Zx({type:"transform",transform:e})}const vl=$("ZodOptional",(e,t)=>{cl.init(e,t),Me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>pl(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Ti(e){return new vl({type:"optional",innerType:e})}const Gx=$("ZodExactOptional",(e,t)=>{kh.init(e,t),Me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>pl(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Yx(e){return new Gx({type:"optional",innerType:e})}const Qx=$("ZodNullable",(e,t)=>{jh.init(e,t),Me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>zg(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Pi(e){return new Qx({type:"nullable",innerType:e})}const Kx=$("ZodDefault",(e,t)=>{Sh.init(e,t),Me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ug(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Jx(e,t){return new Kx({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():qc(t)}})}const Xx=$("ZodPrefault",(e,t)=>{Ch.init(e,t),Me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Bg(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function ev(e,t){return new Xx({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():qc(t)}})}const yl=$("ZodNonOptional",(e,t)=>{Nh.init(e,t),Me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Fg(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function tv(e,t){return new yl({type:"nonoptional",innerType:e,...ie(t)})}const nv=$("ZodCatch",(e,t)=>{Ah.init(e,t),Me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Vg(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function rv(e,t){return new nv({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const sv=$("ZodPipe",(e,t)=>{Eh.init(e,t),Me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Wg(e,n,r,o),e.in=t.in,e.out=t.out});function Ri(e,t){return new sv({type:"pipe",in:e,out:t})}const ov=$("ZodReadonly",(e,t)=>{Ih.init(e,t),Me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Hg(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function av(e){return new ov({type:"readonly",innerType:e})}const iv=$("ZodCustom",(e,t)=>{Th.init(e,t),Me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Rg(e,n)});function cv(e,t={}){return _g(iv,e,t)}function lv(e){return kg(e)}const Rr=xl({line1:rt().min(1,"Address line 1 is required"),line2:rt().optional(),city:rt().min(1,"City is required"),state:rt().optional(),postalCode:rt().min(1,"Postal code is required"),country:rt().min(2,"Country is required")});function dv(e){return xl({email:e.requireEmail?rt().email("Valid email required"):rt().email("Valid email required").or(Hx("")).optional(),name:e.requireName?rt().min(1,"Name is required"):rt().optional(),phone:e.requirePhone?rt().min(6,"Phone is required"):rt().optional(),notes:rt().max(500).optional(),shippingAddress:e.requireShippingAddress?Rr:Rr.optional(),billingAddress:e.requireBillingAddress?Rr:Rr.optional(),discountCode:rt().optional(),tipAmount:Tx().min(0).optional(),shippingMethodId:rt().optional()})}const Oi={none:0,optional:1,required:2};function eo(e,t){return Oi[e]>=Oi[t]?e:t}function uv(e){if(!e)return null;try{const t=JSON.parse(e);return!t||typeof t!="object"?null:t}catch{return null}}function Zr(e,t){let n=!1,r=!1;const o=new Set;let a=t.requireEmail?"required":"none",i=t.defaultMode==="none"?"none":"optional",c=t.defaultMode==="full"?"optional":"none",l=t.allowShipping&&(t.defaultMode==="shipping"||t.defaultMode==="full"),d=t.defaultMode==="full";for(const u of e){u.metadata?.shippingProfile==="digital"?n=!0:r=!0;const g=uv(u.metadata?.checkoutRequirements);g&&(g.email&&(a=eo(a,g.email)),g.name&&(i=eo(i,g.name)),g.phone&&(c=eo(c,g.phone)),typeof g.shippingAddress=="boolean"&&(l=l||g.shippingAddress),typeof g.billingAddress=="boolean"&&(d=d||g.billingAddress));const y=u.metadata?.fulfillmentNotes;y&&o.add(y)}const f=n&&!r;return f&&(l=!1),{email:a,name:i,phone:c,shippingAddress:l,billingAddress:d,fulfillmentNotes:Array.from(o).join(" "),isDigitalOnly:f,hasPhysical:r}}const bl=k.createContext(null);function wl(){const{config:e}=Ee(),t=Rt(),n=k.useMemo(()=>({line1:"",line2:"",city:"",state:"",postalCode:"",country:"US"}),[]),r=k.useMemo(()=>{const w=Zr(t.items,{requireEmail:e.checkout.requireEmail??!0,defaultMode:e.checkout.mode,allowShipping:e.checkout.allowShipping??!1});return dv({requireEmail:w.email==="required",requireName:w.name==="required",requirePhone:w.phone==="required",requireShippingAddress:w.shippingAddress,requireBillingAddress:w.billingAddress})},[t.items,e.checkout.allowShipping,e.checkout.mode,e.checkout.requireEmail]),[o,a]=k.useState(()=>({email:e.checkout.requireEmail??!0?"":void 0,name:"",phone:"",notes:"",shippingAddress:e.checkout.mode==="shipping"||e.checkout.mode==="full"?n:void 0,billingAddress:e.checkout.mode==="full"?n:void 0,discountCode:"",tipAmount:0,shippingMethodId:""}));k.useEffect(()=>{const w=Zr(t.items,{requireEmail:e.checkout.requireEmail??!0,defaultMode:e.checkout.mode,allowShipping:e.checkout.allowShipping??!1});a(b=>{const j={...b};return w.email==="required"&&!j.email&&(j.email=""),w.shippingAddress&&!j.shippingAddress&&(j.shippingAddress=n),w.billingAddress&&!j.billingAddress&&(j.billingAddress=n),w.shippingAddress||(j.shippingAddress=void 0),w.billingAddress||(j.billingAddress=void 0),j})},[t.items,e.checkout.allowShipping,e.checkout.mode,e.checkout.requireEmail,n]);const i=k.useRef(!1),[c,l]=k.useState({}),[d,f]=k.useState("idle"),[u,h]=k.useState(null),[g,y]=k.useState(null),x=k.useCallback(()=>{l({}),f("idle"),h(null),y(null)},[]),p=k.useCallback((w,b)=>{a(j=>({...j,[w]:b}))},[]),v=k.useCallback(()=>{f("validating"),h(null);const w=r.safeParse(o);if(w.success)return l({}),f("idle"),{ok:!0,values:w.data};const b={};for(const j of w.error.issues)b[j.path.join(".")]=j.message;return l(b),f("error"),h("Please fix the highlighted fields."),{ok:!1}},[r,o]),_=k.useCallback(async w=>{if(i.current)return{ok:!1};const b=v();if(!b.ok)return{ok:!1};i.current=!0,f("creating_session"),h(null),y(null);const j=t.items.map(E=>({resource:E.paymentResource??E.productId,quantity:E.qty,variantId:E.variantId})),R=Zr(t.items,{requireEmail:e.checkout.requireEmail??!0,defaultMode:e.checkout.mode,allowShipping:e.checkout.allowShipping??!1}),I=new Set;if(R.shippingAddress)for(const E of t.items){const O=E.metadata?.shippingCountries;if(O)for(const F of O.split(",")){const M=F.trim().toUpperCase();M&&I.add(M)}}const C={...I.size?{shippingCountries:Array.from(I).join(","),shipping_countries:Array.from(I).join(",")}:{}};try{const E=await e.adapter.createCheckoutSession({cart:j,customer:{email:b.values.email||void 0,name:b.values.name||void 0,phone:b.values.phone||void 0,notes:b.values.notes||void 0,shippingAddress:b.values.shippingAddress,billingAddress:b.values.billingAddress},options:{currency:e.currency,successUrl:e.checkout.successUrl,cancelUrl:e.checkout.cancelUrl,allowPromoCodes:e.checkout.allowPromoCodes,metadata:Object.keys(C).length?C:void 0,discountCode:(e.checkout.allowPromoCodes?b.values.discountCode||t.promoCode:void 0)||void 0,tipAmount:e.checkout.allowTipping&&b.values.tipAmount||void 0,shippingMethodId:e.checkout.allowShipping&&b.values.shippingMethodId||void 0,paymentMethodId:w?.paymentMethodId}});return E.kind==="redirect"?(y(E),f("redirecting"),typeof window<"u"&&window.location.assign(E.url),{ok:!0,session:E}):(y(E),f("success"),{ok:!0,session:E})}catch(E){return f("error"),h(E instanceof Error?E.message:"Checkout failed"),{ok:!1}}finally{i.current=!1}},[t.items,t.promoCode,e.adapter,e.checkout,e.currency,v]);return{values:o,setValues:a,setField:p,fieldErrors:c,status:d,error:u,session:g,reset:x,validate:v,createCheckoutSession:_}}function _l({children:e}){const t=wl();return s.jsx(bl.Provider,{value:t,children:e})}function vs(){const e=k.useContext(bl);if(!e)throw new Error("useCheckout must be used within CheckoutProvider");return e}function fv(){return wl()}function na(){const{config:e}=Ee(),[t,n]=m.useState([]),[r,o]=m.useState(!0),[a,i]=m.useState(null);return m.useEffect(()=>{let c=!1;return o(!0),i(null),e.adapter.listCategories().then(l=>{c||n(l)}).catch(l=>{c||i(l instanceof Error?l.message:"Failed to load categories")}).finally(()=>{c||o(!1)}),()=>{c=!0}},[e.adapter]),{categories:t,isLoading:r,error:a}}function ys(e){const{config:t}=Ee(),[n,r]=m.useState(null),[o,a]=m.useState(!0),[i,c]=m.useState(null),l=m.useMemo(()=>JSON.stringify(e.filters??{}),[e.filters]);return m.useEffect(()=>{let d=!1;return a(!0),c(null),t.adapter.listProducts(e).then(f=>{d||r(f)}).catch(f=>{d||c(f instanceof Error?f.message:"Failed to load products")}).finally(()=>{d||a(!1)}),()=>{d=!0}},[t.adapter,e.category,e.search,e.sort,e.page,e.pageSize,l]),{data:n,isLoading:o,error:i}}function kl(e){const{config:t}=Ee(),[n,r]=m.useState(null),[o,a]=m.useState(!0),[i,c]=m.useState(null);return m.useEffect(()=>{let l=!1;return a(!0),c(null),t.adapter.getProductBySlug(e).then(d=>{l||r(d)}).catch(d=>{l||c(d instanceof Error?d.message:"Failed to load product")}).finally(()=>{l||a(!1)}),()=>{l=!0}},[t.adapter,e]),{product:n,isLoading:o,error:i}}function jl(){const{config:e}=Ee(),[t,n]=m.useState([]),[r,o]=m.useState(!0),[a,i]=m.useState(null);return m.useEffect(()=>{let c=!1;return o(!0),i(null),e.adapter.getOrderHistory().then(l=>{c||n(l)}).catch(l=>{c||i(l instanceof Error?l.message:"Failed to load orders")}).finally(()=>{c||o(!1)}),()=>{c=!0}},[e.adapter]),{orders:t,isLoading:r,error:a}}function Sl(){const{config:e}=Ee(),[t,n]=m.useState([]),[r,o]=m.useState(null),[a,i]=m.useState(!0),[c,l]=m.useState(null);return m.useEffect(()=>{let d=!1;async function f(){i(!0),l(null);try{const[u,h]=await Promise.all([e.adapter.listSubscriptionTiers?.()??Promise.resolve([]),e.adapter.getSubscriptionStatus?.()??Promise.resolve(null)]);if(d)return;n(u),o(h)}catch(u){if(d)return;l(u instanceof Error?u.message:"Failed to load subscriptions")}finally{d||i(!1)}}return f(),()=>{d=!0}},[e.adapter]),{tiers:t,status:r,isLoading:a,error:c}}function Cl({enabled:e,customer:t}){const{config:n}=Ee(),[r,o]=m.useState([]),[a,i]=m.useState(!1),[c,l]=m.useState(null),d=JSON.stringify(t.shippingAddress??{});return m.useEffect(()=>{let f=!1;if(!e||!n.adapter.getShippingMethods){o([]);return}return i(!0),l(null),n.adapter.getShippingMethods({currency:n.currency,customer:t}).then(u=>{f||o(u)}).catch(u=>{f||l(u instanceof Error?u.message:"Failed to load shipping methods")}).finally(()=>{f||i(!1)}),()=>{f=!0}},[n.adapter,n.currency,e,t.email,t.name,d]),{methods:r,isLoading:a,error:c}}function Xn(e,...t){for(const n of t){const r=e[n];if(r)return r}}function ra(e){const t=Xn(e,"error","error_message","message");if(t)return{kind:"error",message:t};const n=Xn(e,"canceled","cancelled","cancel","canceled_at");if(n&&n!=="0"&&n!=="false")return{kind:"cancel"};const r=Xn(e,"orderId","order_id","demoOrderId"),o=Xn(e,"session_id","checkout_session_id");if(r||o)return{kind:"success",orderId:r??o};const a=(Xn(e,"status","checkout")??"").toLowerCase();return a==="success"?{kind:"success",orderId:r}:a==="cancel"||a==="canceled"?{kind:"cancel"}:a==="error"?{kind:"error"}:{kind:"idle"}}function mv(e){const t={};return e.forEach((n,r)=>{t[r]=n}),t}function sa(){const{config:e}=Ee(),[t,n]=m.useState({kind:"idle"});return m.useEffect(()=>{if(typeof window>"u")return;const r=new URLSearchParams(window.location.search),o=mv(r);(async()=>{try{const a=e.adapter.resolveCheckoutReturn?await e.adapter.resolveCheckoutReturn({query:o}):ra(o);if(a.kind==="success"&&a.orderId&&e.adapter.getOrderById){const i=await e.adapter.getOrderById(a.orderId);if(i){n({kind:"success",orderId:a.orderId,order:i});return}}n(a)}catch(a){n({kind:"error",message:a instanceof Error?a.message:"Failed to resolve checkout"})}})()},[e.adapter]),t}function Co(e){if(!e)return;const t=Number(e);return Number.isFinite(t)?t:void 0}function pv(e){const t=e.get("tags"),n=t?t.split(",").map(c=>c.trim()).filter(Boolean):void 0,r=Co(e.get("min")),o=Co(e.get("max")),a=e.get("inStock"),i=a==="1"?!0:a==="0"?!1:void 0;return{tags:n&&n.length?n:void 0,priceMin:r,priceMax:o,inStock:i}}function hv(e,t){t.tags?.length?e.set("tags",t.tags.join(",")):e.delete("tags"),typeof t.priceMin=="number"?e.set("min",String(t.priceMin)):e.delete("min"),typeof t.priceMax=="number"?e.set("max",String(t.priceMax)):e.delete("max"),typeof t.inStock=="boolean"?e.set("inStock",t.inStock?"1":"0"):e.delete("inStock")}function oa({includeCategory:e}){if(typeof window>"u")return null;const t=new URLSearchParams(window.location.search),n=t.get("q")??"",r=t.get("sort")??"featured",o=Co(t.get("page"))??1,a=pv(t),i=e?t.get("cat")??void 0:void 0;return{search:n,sort:r,page:Math.max(1,Math.floor(o)),category:i,filters:a}}function aa(e,{includeCategory:t}){const n=e.filters.tags?.join(",")??"";m.useEffect(()=>{if(typeof window>"u")return;const r=window.setTimeout(()=>{const o=new URL(window.location.href),a=o.searchParams;e.search.trim()?a.set("q",e.search.trim()):a.delete("q"),e.sort&&e.sort!=="featured"?a.set("sort",e.sort):a.delete("sort"),e.page&&e.page!==1?a.set("page",String(e.page)):a.delete("page"),t&&(e.category?a.set("cat",e.category):a.delete("cat")),hv(a,e.filters);const i=`${o.pathname}?${a.toString()}${o.hash}`,c=`${window.location.pathname}${window.location.search}${window.location.hash}`;i!==c&&window.history.replaceState({},"",i)},250);return()=>window.clearTimeout(r)},[t,e.category,e.page,e.search,e.sort,n,e.filters.priceMin,e.filters.priceMax,e.filters.inStock])}function Mi(e,t){return`${e}::${t??""}`}function gv(e,t){if(t&&e.variants?.length){const n=e.variants.find(r=>r.id===t);if(n)return{qty:n.inventoryQuantity,status:n.inventoryStatus}}return{qty:e.inventoryQuantity,status:e.inventoryStatus}}function xv(e,t){const n={productId:e.productId,variantId:e.variantId,isOutOfStock:!1,exceedsAvailable:!1,isLowStock:!1};if(!t)return{...n,isOutOfStock:!0,message:"This product is no longer available"};const{qty:r,status:o}=gv(t,e.variantId);return n.availableQty=r,n.status=o,o==="out_of_stock"||typeof r=="number"&&r<=0?{...n,isOutOfStock:!0,message:"Out of stock"}:typeof r=="number"&&e.qty>r?{...n,exceedsAvailable:!0,message:r===0?"Out of stock":`Only ${r} available (you have ${e.qty} in cart)`}:o==="low"||typeof r=="number"&&r>0&&r<=5?{...n,isLowStock:!0,message:typeof r=="number"?`Only ${r} left`:"Low stock"}:n}function ia({items:e,refreshInterval:t=3e4,skip:n=!1}){const{config:r}=Ee(),[o,a]=m.useState(new Map),[i,c]=m.useState(!1),[l,d]=m.useState(null),f=m.useRef(e);f.current=e;const u=m.useMemo(()=>{const v=new Set;for(const _ of e)v.add(_.productId);return v},[e]),h=m.useMemo(()=>Array.from(u).sort().join(","),[u]),g=m.useMemo(()=>Array.from(u),[u]),y=m.useCallback(async()=>{if(n||g.length===0){a(new Map);return}c(!0),d(null);try{let v=new Map;if(r.adapter.getProductsByIds)v=await r.adapter.getProductsByIds(g);else{const w=await Promise.all(g.map(async b=>{try{return await r.adapter.getProductBySlug(b)}catch{return null}}));v=new Map;for(const b of w)b&&(v.set(b.id,b),b.slug&&b.slug!==b.id&&v.set(b.slug,b))}const _=new Map;for(const w of f.current){const b=Mi(w.productId,w.variantId),j=v.get(w.productId)??null;_.set(b,xv(w,j))}a(_)}catch(v){d(v instanceof Error?v.message:"Failed to check inventory")}finally{c(!1)}},[r.adapter,h,n]);m.useEffect(()=>{y()},[y]),m.useEffect(()=>{if(n||t<=0||g.length===0)return;const v=setInterval(y,t);return()=>clearInterval(v)},[y,g.length,t,n]);const x=m.useCallback((v,_)=>o.get(Mi(v,_)),[o]),p=m.useMemo(()=>{for(const v of o.values())if(v.isOutOfStock||v.exceedsAvailable)return!0;return!1},[o]);return{inventory:o,isLoading:i,error:l,refresh:y,getItemInventory:x,hasIssues:p}}function vv(e,t){if(t&&e.variants?.length){const n=e.variants.find(r=>r.id===t);if(n)return{qty:n.inventoryQuantity,status:n.inventoryStatus}}return{qty:e.inventoryQuantity,status:e.inventoryStatus}}function yv(e,t,n){if(!t)return e.titleSnapshot??"Unknown Product";const r=t.title??e.titleSnapshot??"Product";if(n&&t.variants?.length){const o=t.variants.find(a=>a.id===n);if(o?.title)return`${r} - ${o.title}`}return r}function bv(e,t){const n=yv(e,t,e.variantId);if(!t)return{productId:e.productId,variantId:e.variantId,title:n,requestedQty:e.qty,availableQty:0,type:"product_unavailable",message:"This product is no longer available"};const{qty:r,status:o}=vv(t,e.variantId);return o==="out_of_stock"||typeof r=="number"&&r<=0?{productId:e.productId,variantId:e.variantId,title:n,requestedQty:e.qty,availableQty:0,type:"out_of_stock",message:"This item is out of stock"}:typeof r=="number"&&e.qty>r?{productId:e.productId,variantId:e.variantId,title:n,requestedQty:e.qty,availableQty:r,type:"insufficient_stock",message:r===0?"This item is out of stock":`Only ${r} available`}:null}function Nl({items:e}){const{config:t}=Ee(),[n,r]=m.useState(null),[o,a]=m.useState(!1),[i,c]=m.useState(null),l=m.useMemo(()=>{const u=new Set;for(const h of e)u.add(h.productId);return Array.from(u)},[e]),d=m.useCallback(async()=>{if(e.length===0){const u={ok:!0,issues:[],verifiedAt:new Date};return r(u),u}a(!0),c(null);try{let u=new Map;if(t.adapter.getProductsByIds)u=await t.adapter.getProductsByIds(l);else{const y=await Promise.all(l.map(async x=>{try{return await t.adapter.getProductBySlug(x)}catch{return null}}));u=new Map;for(const x of y)x&&(u.set(x.id,x),x.slug&&x.slug!==x.id&&u.set(x.slug,x))}const h=[];for(const y of e){const x=u.get(y.productId)??null,p=bv(y,x);p&&h.push(p)}const g={ok:h.length===0,issues:h,verifiedAt:new Date};return r(g),a(!1),g}catch(u){const h=u instanceof Error?u.message:"Failed to verify inventory";c(h),a(!1);const g={ok:!1,issues:[],verifiedAt:new Date};return r(g),g}},[t.adapter,e,l]),f=m.useCallback(()=>{r(null),c(null)},[]);return{result:n,isVerifying:o,error:i,verify:d,reset:f}}function wv({items:e,onExpiry:t,enabled:n=!0}){const[r,o]=m.useState([]),[a,i]=m.useState([]),c=m.useRef(new Set),l=m.useRef(t);l.current=t;const d=m.useMemo(()=>n?e.filter(f=>f.holdId&&f.holdExpiresAt):[],[e,n]);return m.useEffect(()=>{if(!n||d.length===0){o([]),i([]);return}const f=()=>{const h=Date.now(),g=120*1e3,y=[],x=[];for(const p of d){if(!p.holdExpiresAt)continue;const v=new Date(p.holdExpiresAt),_=v.getTime()-h,w=`${p.productId}::${p.variantId??""}`;_<=0?(y.push({productId:p.productId,variantId:p.variantId}),c.current.has(w)||(c.current.add(w),l.current?.({productId:p.productId,variantId:p.variantId,title:p.titleSnapshot,expiredAt:v}))):_<=g&&x.push({productId:p.productId,variantId:p.variantId,expiresAt:v,remainingMs:_})}o(y),i(x)};f();const u=setInterval(f,1e4);return()=>clearInterval(u)},[n,d]),m.useEffect(()=>{const f=new Set(d.map(u=>`${u.productId}::${u.variantId??""}`));for(const u of c.current)f.has(u)||c.current.delete(u)},[d]),{expiringItems:a,expiredItems:r}}const ke={relatedProducts:{mode:"most_recent",maxItems:4,layout:{layout:"large",imageCrop:"center"}},catalog:{filters:{tags:!0,priceRange:!0,inStock:!0},sort:{featured:!0,priceAsc:!0,priceDesc:!0}},checkout:{promoCodes:!0},shopLayout:{layout:"large",imageCrop:"center"},categoryLayout:{layout:"large",imageCrop:"center"},sections:{showDescription:!0,showSpecs:!0,showShipping:!0,showRelatedProducts:!0},inventory:{preCheckoutVerification:!0,holdsEnabled:!1,holdDurationMinutes:15},shopPage:{title:"Shop",description:""}};function _v(e){return{relatedProducts:{mode:e.relatedProducts?.mode||ke.relatedProducts.mode,maxItems:e.relatedProducts?.maxItems||ke.relatedProducts.maxItems,layout:{layout:e.relatedProducts?.layout?.layout??ke.relatedProducts.layout.layout,imageCrop:e.relatedProducts?.layout?.imageCrop??ke.relatedProducts.layout.imageCrop}},catalog:{filters:{tags:e.catalog?.filters?.tags??ke.catalog.filters.tags,priceRange:e.catalog?.filters?.priceRange??ke.catalog.filters.priceRange,inStock:e.catalog?.filters?.inStock??ke.catalog.filters.inStock},sort:{featured:e.catalog?.sort?.featured??ke.catalog.sort.featured,priceAsc:e.catalog?.sort?.priceAsc??ke.catalog.sort.priceAsc,priceDesc:e.catalog?.sort?.priceDesc??ke.catalog.sort.priceDesc}},checkout:{promoCodes:e.checkout?.promoCodes??ke.checkout.promoCodes},shopLayout:{layout:e.shopLayout?.layout??ke.shopLayout.layout,imageCrop:e.shopLayout?.imageCrop??ke.shopLayout.imageCrop},categoryLayout:{layout:e.categoryLayout?.layout??ke.categoryLayout.layout,imageCrop:e.categoryLayout?.imageCrop??ke.categoryLayout.imageCrop},sections:{showDescription:e.sections?.showDescription??ke.sections.showDescription,showSpecs:e.sections?.showSpecs??ke.sections.showSpecs,showShipping:e.sections?.showShipping??ke.sections.showShipping,showRelatedProducts:e.sections?.showRelatedProducts??ke.sections.showRelatedProducts},inventory:{preCheckoutVerification:e.inventory?.preCheckoutVerification??ke.inventory.preCheckoutVerification,holdsEnabled:e.inventory?.holdsEnabled??ke.inventory.holdsEnabled,holdDurationMinutes:e.inventory?.holdDurationMinutes??ke.inventory.holdDurationMinutes},shopPage:{title:e.shopPage?.title??ke.shopPage.title,description:e.shopPage?.description??ke.shopPage.description}}}function Wn(e={}){const n=Go()?.config?.adapter,[r,o]=k.useState(ke),[a,i]=k.useState(!!n?.getStorefrontSettings);return k.useEffect(()=>{if(!n?.getStorefrontSettings){i(!1);return}let c=!1;async function l(){try{const d=await n.getStorefrontSettings();!c&&d&&o(_v(d))}catch{}finally{c||i(!1)}}return l(),()=>{c=!0}},[n]),{settings:r,isLoading:a}}const kv={card:!0,crypto:!0,credits:!1};function Al(){const t=Go()?.config?.adapter,[n,r]=k.useState(kv),[o,a]=k.useState(!!t?.getPaymentMethodsConfig);return k.useEffect(()=>{if(!t?.getPaymentMethodsConfig){a(!1);return}let i=!1;async function c(){try{const l=await t.getPaymentMethodsConfig();!i&&l&&r(l)}catch{}finally{i||a(!1)}}return c(),()=>{i=!0}},[t]),{config:n,isLoading:o}}const jv=50,er=new Map;function Sv(e){return e.productId?`id:${e.productId}`:e.name?`name:${e.name}`:""}function El(e={}){const{productId:t,product:n,enabled:r=!0}=e,a=Go()?.config?.adapter,[i,c]=k.useState(null),[l,d]=k.useState(null),[f,u]=k.useState(!1),[h,g]=k.useState(null),y=k.useRef(0),x=k.useCallback(async()=>{const p=t?{productId:t}:n?{name:n.name,description:n.description,tags:n.tags,categoryIds:n.categoryIds}:{};if(!p.productId&&!p.name)return;if(!a?.getAIRelatedProducts){g("AI recommendations not available");return}const v=Sv(p),_=er.get(v);if(_){c(_.relatedProductIds),d(_.reasoning),g(null);return}const w=++y.current;u(!0),g(null);try{const b=await a.getAIRelatedProducts(p);if(w===y.current&&(c(b.relatedProductIds),d(b.reasoning),g(null),v)){if(er.size>=jv){const j=er.keys().next().value;j!==void 0&&er.delete(j)}er.set(v,b)}}catch(b){if(w===y.current){const j=b instanceof Error?b.message:"Failed to get AI recommendations";g(j),c(null),d(null)}}finally{w===y.current&&u(!1)}},[a,t,n]);return k.useEffect(()=>{r&&(!t&&!n?.name||x())},[r,t,n?.name,x]),{relatedProductIds:i,reasoning:l,isLoading:f,error:h,refetch:x}}function Ae(e,t){if(!e)throw new Error(t)}function St(e){return typeof e=="string"&&e.trim().length>0}async function Cv(e,t={}){const n=t.pageSize??10,r=await e.listCategories();Ae(Array.isArray(r),"listCategories() must return an array");for(const i of r)Ae(St(i.id),"Category.id is required"),Ae(St(i.slug),"Category.slug is required"),Ae(St(i.name),"Category.name is required");const o=await e.listProducts({page:1,pageSize:n});if(Ae(o&&Array.isArray(o.items),"listProducts() must return { items: Product[] }"),Ae(typeof o.page=="number","listProducts().page must be a number"),Ae(typeof o.pageSize=="number","listProducts().pageSize must be a number"),o.items.length>0){const i=o.items[0];Ae(St(i.id),"Product.id is required"),Ae(St(i.slug),"Product.slug is required"),Ae(St(i.title),"Product.title is required"),Ae(typeof i.description=="string","Product.description must be a string"),Ae(Array.isArray(i.images),"Product.images must be an array"),Ae(typeof i.price=="number","Product.price must be a number"),Ae(St(i.currency),"Product.currency is required"),Ae(Array.isArray(i.tags),"Product.tags must be an array"),Ae(Array.isArray(i.categoryIds),"Product.categoryIds must be an array");const c=await e.getProductBySlug(i.slug);Ae(c===null||St(c.id),"getProductBySlug() must return Product or null")}const a=await e.getOrderHistory();Ae(Array.isArray(a),"getOrderHistory() must return an array");for(const i of a)Ae(St(i.id),"Order.id is required"),Ae(St(i.createdAt),"Order.createdAt is required"),Ae(typeof i.total=="number","Order.total must be a number"),Ae(St(i.currency),"Order.currency is required"),Ae(Array.isArray(i.items),"Order.items must be an array")}function Li(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Hn(...e){return t=>{let n=!1;const r=e.map(o=>{const a=Li(o,t);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let o=0;o<r.length;o++){const a=r[o];typeof a=="function"?a():Li(e[o],null)}}}}function Ce(...e){return m.useCallback(Hn(...e),e)}var Nv=Symbol.for("react.lazy"),ns=m[" use ".trim().toString()];function Av(e){return typeof e=="object"&&e!==null&&"then"in e}function Il(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===Nv&&"_payload"in e&&Av(e._payload)}function Tl(e){const t=Iv(e),n=m.forwardRef((r,o)=>{let{children:a,...i}=r;Il(a)&&typeof ns=="function"&&(a=ns(a._payload));const c=m.Children.toArray(a),l=c.find(Pv);if(l){const d=l.props.children,f=c.map(u=>u===l?m.Children.count(d)>1?m.Children.only(null):m.isValidElement(d)?d.props.children:null:u);return s.jsx(t,{...i,ref:o,children:m.isValidElement(d)?m.cloneElement(d,void 0,f):null})}return s.jsx(t,{...i,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}var Ev=Tl("Slot");function Iv(e){const t=m.forwardRef((n,r)=>{let{children:o,...a}=n;if(Il(o)&&typeof ns=="function"&&(o=ns(o._payload)),m.isValidElement(o)){const i=Ov(o),c=Rv(a,o.props);return o.type!==m.Fragment&&(c.ref=r?Hn(r,i):i),m.cloneElement(o,c)}return m.Children.count(o)>1?m.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Tv=Symbol("radix.slottable");function Pv(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Tv}function Rv(e,t){const n={...t};for(const r in t){const o=e[r],a=t[r];/^on[A-Z]/.test(r)?o&&a?n[r]=(...c)=>{const l=a(...c);return o(...c),l}:o&&(n[r]=o):r==="style"?n[r]={...o,...a}:r==="className"&&(n[r]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function Ov(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function Pl(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(n=Pl(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function Rl(){for(var e,t,n=0,r="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=Pl(e))&&(r&&(r+=" "),r+=t);return r}const Di=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,$i=Rl,ca=(e,t)=>n=>{var r;if(t?.variants==null)return $i(e,n?.class,n?.className);const{variants:o,defaultVariants:a}=t,i=Object.keys(o).map(d=>{const f=n?.[d],u=a?.[d];if(f===null)return null;const h=Di(f)||Di(u);return o[d][h]}),c=n&&Object.entries(n).reduce((d,f)=>{let[u,h]=f;return h===void 0||(d[u]=h),d},{}),l=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((d,f)=>{let{class:u,className:h,...g}=f;return Object.entries(g).every(y=>{let[x,p]=y;return Array.isArray(p)?p.includes({...a,...c}[x]):{...a,...c}[x]===p})?[...d,u,h]:d},[]);return $i(e,i,l,n?.class,n?.className)},Mv=(e,t)=>{const n=new Array(e.length+t.length);for(let r=0;r<e.length;r++)n[r]=e[r];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},Lv=(e,t)=>({classGroupId:e,validator:t}),Ol=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),rs="-",zi=[],Dv="arbitrary..",$v=e=>{const t=Fv(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:i=>{if(i.startsWith("[")&&i.endsWith("]"))return zv(i);const c=i.split(rs),l=c[0]===""&&c.length>1?1:0;return Ml(c,l,t)},getConflictingClassGroupIds:(i,c)=>{if(c){const l=r[i],d=n[i];return l?d?Mv(d,l):l:d||zi}return n[i]||zi}}},Ml=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const o=e[t],a=n.nextPart.get(o);if(a){const d=Ml(e,t+1,a);if(d)return d}const i=n.validators;if(i===null)return;const c=t===0?e.join(rs):e.slice(t).join(rs),l=i.length;for(let d=0;d<l;d++){const f=i[d];if(f.validator(c))return f.classGroupId}},zv=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),n=t.indexOf(":"),r=t.slice(0,n);return r?Dv+r:void 0})(),Fv=e=>{const{theme:t,classGroups:n}=e;return Uv(n,t)},Uv=(e,t)=>{const n=Ol();for(const r in e){const o=e[r];la(o,n,r,t)}return n},la=(e,t,n,r)=>{const o=e.length;for(let a=0;a<o;a++){const i=e[a];Bv(i,t,n,r)}},Bv=(e,t,n,r)=>{if(typeof e=="string"){Vv(e,t,n);return}if(typeof e=="function"){Wv(e,t,n,r);return}Hv(e,t,n,r)},Vv=(e,t,n)=>{const r=e===""?t:Ll(t,e);r.classGroupId=n},Wv=(e,t,n,r)=>{if(Zv(e)){la(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(Lv(n,e))},Hv=(e,t,n,r)=>{const o=Object.entries(e),a=o.length;for(let i=0;i<a;i++){const[c,l]=o[i];la(l,Ll(t,c),n,r)}},Ll=(e,t)=>{let n=e;const r=t.split(rs),o=r.length;for(let a=0;a<o;a++){const i=r[a];let c=n.nextPart.get(i);c||(c=Ol(),n.nextPart.set(i,c)),n=c}return n},Zv=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,qv=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null);const o=(a,i)=>{n[a]=i,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(a){let i=n[a];if(i!==void 0)return i;if((i=r[a])!==void 0)return o(a,i),i},set(a,i){a in n?n[a]=i:o(a,i)}}},No="!",Fi=":",Gv=[],Ui=(e,t,n,r,o)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:o}),Yv=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=o=>{const a=[];let i=0,c=0,l=0,d;const f=o.length;for(let x=0;x<f;x++){const p=o[x];if(i===0&&c===0){if(p===Fi){a.push(o.slice(l,x)),l=x+1;continue}if(p==="/"){d=x;continue}}p==="["?i++:p==="]"?i--:p==="("?c++:p===")"&&c--}const u=a.length===0?o:o.slice(l);let h=u,g=!1;u.endsWith(No)?(h=u.slice(0,-1),g=!0):u.startsWith(No)&&(h=u.slice(1),g=!0);const y=d&&d>l?d-l:void 0;return Ui(a,g,h,y)};if(t){const o=t+Fi,a=r;r=i=>i.startsWith(o)?a(i.slice(o.length)):Ui(Gv,!1,i,void 0,!0)}if(n){const o=r;r=a=>n({className:a,parseClassName:o})}return r},Qv=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((n,r)=>{t.set(n,1e6+r)}),n=>{const r=[];let o=[];for(let a=0;a<n.length;a++){const i=n[a],c=i[0]==="[",l=t.has(i);c||l?(o.length>0&&(o.sort(),r.push(...o),o=[]),r.push(i)):o.push(i)}return o.length>0&&(o.sort(),r.push(...o)),r}},Kv=e=>({cache:qv(e.cacheSize),parseClassName:Yv(e),sortModifiers:Qv(e),...$v(e)}),Jv=/\s+/,Xv=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:o,sortModifiers:a}=t,i=[],c=e.trim().split(Jv);let l="";for(let d=c.length-1;d>=0;d-=1){const f=c[d],{isExternal:u,modifiers:h,hasImportantModifier:g,baseClassName:y,maybePostfixModifierPosition:x}=n(f);if(u){l=f+(l.length>0?" "+l:l);continue}let p=!!x,v=r(p?y.substring(0,x):y);if(!v){if(!p){l=f+(l.length>0?" "+l:l);continue}if(v=r(y),!v){l=f+(l.length>0?" "+l:l);continue}p=!1}const _=h.length===0?"":h.length===1?h[0]:a(h).join(":"),w=g?_+No:_,b=w+v;if(i.indexOf(b)>-1)continue;i.push(b);const j=o(v,p);for(let R=0;R<j.length;++R){const I=j[R];i.push(w+I)}l=f+(l.length>0?" "+l:l)}return l},ey=(...e)=>{let t=0,n,r,o="";for(;t<e.length;)(n=e[t++])&&(r=Dl(n))&&(o&&(o+=" "),o+=r);return o},Dl=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=Dl(e[r]))&&(n&&(n+=" "),n+=t);return n},ty=(e,...t)=>{let n,r,o,a;const i=l=>{const d=t.reduce((f,u)=>u(f),e());return n=Kv(d),r=n.cache.get,o=n.cache.set,a=c,c(l)},c=l=>{const d=r(l);if(d)return d;const f=Xv(l,n);return o(l,f),f};return a=i,(...l)=>a(ey(...l))},ny=[],Ue=e=>{const t=n=>n[e]||ny;return t.isThemeGetter=!0,t},$l=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,zl=/^\((?:(\w[\w-]*):)?(.+)\)$/i,ry=/^\d+\/\d+$/,sy=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,oy=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,ay=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,iy=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,cy=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Pn=e=>ry.test(e),fe=e=>!!e&&!Number.isNaN(Number(e)),nn=e=>!!e&&Number.isInteger(Number(e)),to=e=>e.endsWith("%")&&fe(e.slice(0,-1)),Kt=e=>sy.test(e),ly=()=>!0,dy=e=>oy.test(e)&&!ay.test(e),Fl=()=>!1,uy=e=>iy.test(e),fy=e=>cy.test(e),my=e=>!J(e)&&!X(e),py=e=>Zn(e,Vl,Fl),J=e=>$l.test(e),xn=e=>Zn(e,Wl,dy),no=e=>Zn(e,yy,fe),Bi=e=>Zn(e,Ul,Fl),hy=e=>Zn(e,Bl,fy),Or=e=>Zn(e,Hl,uy),X=e=>zl.test(e),tr=e=>qn(e,Wl),gy=e=>qn(e,by),Vi=e=>qn(e,Ul),xy=e=>qn(e,Vl),vy=e=>qn(e,Bl),Mr=e=>qn(e,Hl,!0),Zn=(e,t,n)=>{const r=$l.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},qn=(e,t,n=!1)=>{const r=zl.exec(e);return r?r[1]?t(r[1]):n:!1},Ul=e=>e==="position"||e==="percentage",Bl=e=>e==="image"||e==="url",Vl=e=>e==="length"||e==="size"||e==="bg-size",Wl=e=>e==="length",yy=e=>e==="number",by=e=>e==="family-name",Hl=e=>e==="shadow",wy=()=>{const e=Ue("color"),t=Ue("font"),n=Ue("text"),r=Ue("font-weight"),o=Ue("tracking"),a=Ue("leading"),i=Ue("breakpoint"),c=Ue("container"),l=Ue("spacing"),d=Ue("radius"),f=Ue("shadow"),u=Ue("inset-shadow"),h=Ue("text-shadow"),g=Ue("drop-shadow"),y=Ue("blur"),x=Ue("perspective"),p=Ue("aspect"),v=Ue("ease"),_=Ue("animate"),w=()=>["auto","avoid","all","avoid-page","page","left","right","column"],b=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],j=()=>[...b(),X,J],R=()=>["auto","hidden","clip","visible","scroll"],I=()=>["auto","contain","none"],C=()=>[X,J,l],E=()=>[Pn,"full","auto",...C()],O=()=>[nn,"none","subgrid",X,J],F=()=>["auto",{span:["full",nn,X,J]},nn,X,J],M=()=>[nn,"auto",X,J],U=()=>["auto","min","max","fr",X,J],D=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],H=()=>["start","end","center","stretch","center-safe","end-safe"],z=()=>["auto",...C()],A=()=>[Pn,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...C()],N=()=>[e,X,J],Z=()=>[...b(),Vi,Bi,{position:[X,J]}],te=()=>["no-repeat",{repeat:["","x","y","space","round"]}],re=()=>["auto","cover","contain",xy,py,{size:[X,J]}],de=()=>[to,tr,xn],W=()=>["","none","full",d,X,J],Q=()=>["",fe,tr,xn],q=()=>["solid","dashed","dotted","double"],he=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],P=()=>[fe,to,Vi,Bi],G=()=>["","none",y,X,J],ue=()=>["none",fe,X,J],B=()=>["none",fe,X,J],ae=()=>[fe,X,J],ce=()=>[Pn,"full",...C()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Kt],breakpoint:[Kt],color:[ly],container:[Kt],"drop-shadow":[Kt],ease:["in","out","in-out"],font:[my],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Kt],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Kt],shadow:[Kt],spacing:["px",fe],text:[Kt],"text-shadow":[Kt],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Pn,J,X,p]}],container:["container"],columns:[{columns:[fe,J,X,c]}],"break-after":[{"break-after":w()}],"break-before":[{"break-before":w()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:j()}],overflow:[{overflow:R()}],"overflow-x":[{"overflow-x":R()}],"overflow-y":[{"overflow-y":R()}],overscroll:[{overscroll:I()}],"overscroll-x":[{"overscroll-x":I()}],"overscroll-y":[{"overscroll-y":I()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:E()}],"inset-x":[{"inset-x":E()}],"inset-y":[{"inset-y":E()}],start:[{start:E()}],end:[{end:E()}],top:[{top:E()}],right:[{right:E()}],bottom:[{bottom:E()}],left:[{left:E()}],visibility:["visible","invisible","collapse"],z:[{z:[nn,"auto",X,J]}],basis:[{basis:[Pn,"full","auto",c,...C()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[fe,Pn,"auto","initial","none",J]}],grow:[{grow:["",fe,X,J]}],shrink:[{shrink:["",fe,X,J]}],order:[{order:[nn,"first","last","none",X,J]}],"grid-cols":[{"grid-cols":O()}],"col-start-end":[{col:F()}],"col-start":[{"col-start":M()}],"col-end":[{"col-end":M()}],"grid-rows":[{"grid-rows":O()}],"row-start-end":[{row:F()}],"row-start":[{"row-start":M()}],"row-end":[{"row-end":M()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":U()}],"auto-rows":[{"auto-rows":U()}],gap:[{gap:C()}],"gap-x":[{"gap-x":C()}],"gap-y":[{"gap-y":C()}],"justify-content":[{justify:[...D(),"normal"]}],"justify-items":[{"justify-items":[...H(),"normal"]}],"justify-self":[{"justify-self":["auto",...H()]}],"align-content":[{content:["normal",...D()]}],"align-items":[{items:[...H(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...H(),{baseline:["","last"]}]}],"place-content":[{"place-content":D()}],"place-items":[{"place-items":[...H(),"baseline"]}],"place-self":[{"place-self":["auto",...H()]}],p:[{p:C()}],px:[{px:C()}],py:[{py:C()}],ps:[{ps:C()}],pe:[{pe:C()}],pt:[{pt:C()}],pr:[{pr:C()}],pb:[{pb:C()}],pl:[{pl:C()}],m:[{m:z()}],mx:[{mx:z()}],my:[{my:z()}],ms:[{ms:z()}],me:[{me:z()}],mt:[{mt:z()}],mr:[{mr:z()}],mb:[{mb:z()}],ml:[{ml:z()}],"space-x":[{"space-x":C()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":C()}],"space-y-reverse":["space-y-reverse"],size:[{size:A()}],w:[{w:[c,"screen",...A()]}],"min-w":[{"min-w":[c,"screen","none",...A()]}],"max-w":[{"max-w":[c,"screen","none","prose",{screen:[i]},...A()]}],h:[{h:["screen","lh",...A()]}],"min-h":[{"min-h":["screen","lh","none",...A()]}],"max-h":[{"max-h":["screen","lh",...A()]}],"font-size":[{text:["base",n,tr,xn]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,X,no]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",to,J]}],"font-family":[{font:[gy,J,t]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[o,X,J]}],"line-clamp":[{"line-clamp":[fe,"none",X,no]}],leading:[{leading:[a,...C()]}],"list-image":[{"list-image":["none",X,J]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",X,J]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:N()}],"text-color":[{text:N()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...q(),"wavy"]}],"text-decoration-thickness":[{decoration:[fe,"from-font","auto",X,xn]}],"text-decoration-color":[{decoration:N()}],"underline-offset":[{"underline-offset":[fe,"auto",X,J]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:C()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",X,J]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",X,J]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:Z()}],"bg-repeat":[{bg:te()}],"bg-size":[{bg:re()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},nn,X,J],radial:["",X,J],conic:[nn,X,J]},vy,hy]}],"bg-color":[{bg:N()}],"gradient-from-pos":[{from:de()}],"gradient-via-pos":[{via:de()}],"gradient-to-pos":[{to:de()}],"gradient-from":[{from:N()}],"gradient-via":[{via:N()}],"gradient-to":[{to:N()}],rounded:[{rounded:W()}],"rounded-s":[{"rounded-s":W()}],"rounded-e":[{"rounded-e":W()}],"rounded-t":[{"rounded-t":W()}],"rounded-r":[{"rounded-r":W()}],"rounded-b":[{"rounded-b":W()}],"rounded-l":[{"rounded-l":W()}],"rounded-ss":[{"rounded-ss":W()}],"rounded-se":[{"rounded-se":W()}],"rounded-ee":[{"rounded-ee":W()}],"rounded-es":[{"rounded-es":W()}],"rounded-tl":[{"rounded-tl":W()}],"rounded-tr":[{"rounded-tr":W()}],"rounded-br":[{"rounded-br":W()}],"rounded-bl":[{"rounded-bl":W()}],"border-w":[{border:Q()}],"border-w-x":[{"border-x":Q()}],"border-w-y":[{"border-y":Q()}],"border-w-s":[{"border-s":Q()}],"border-w-e":[{"border-e":Q()}],"border-w-t":[{"border-t":Q()}],"border-w-r":[{"border-r":Q()}],"border-w-b":[{"border-b":Q()}],"border-w-l":[{"border-l":Q()}],"divide-x":[{"divide-x":Q()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":Q()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...q(),"hidden","none"]}],"divide-style":[{divide:[...q(),"hidden","none"]}],"border-color":[{border:N()}],"border-color-x":[{"border-x":N()}],"border-color-y":[{"border-y":N()}],"border-color-s":[{"border-s":N()}],"border-color-e":[{"border-e":N()}],"border-color-t":[{"border-t":N()}],"border-color-r":[{"border-r":N()}],"border-color-b":[{"border-b":N()}],"border-color-l":[{"border-l":N()}],"divide-color":[{divide:N()}],"outline-style":[{outline:[...q(),"none","hidden"]}],"outline-offset":[{"outline-offset":[fe,X,J]}],"outline-w":[{outline:["",fe,tr,xn]}],"outline-color":[{outline:N()}],shadow:[{shadow:["","none",f,Mr,Or]}],"shadow-color":[{shadow:N()}],"inset-shadow":[{"inset-shadow":["none",u,Mr,Or]}],"inset-shadow-color":[{"inset-shadow":N()}],"ring-w":[{ring:Q()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:N()}],"ring-offset-w":[{"ring-offset":[fe,xn]}],"ring-offset-color":[{"ring-offset":N()}],"inset-ring-w":[{"inset-ring":Q()}],"inset-ring-color":[{"inset-ring":N()}],"text-shadow":[{"text-shadow":["none",h,Mr,Or]}],"text-shadow-color":[{"text-shadow":N()}],opacity:[{opacity:[fe,X,J]}],"mix-blend":[{"mix-blend":[...he(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":he()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[fe]}],"mask-image-linear-from-pos":[{"mask-linear-from":P()}],"mask-image-linear-to-pos":[{"mask-linear-to":P()}],"mask-image-linear-from-color":[{"mask-linear-from":N()}],"mask-image-linear-to-color":[{"mask-linear-to":N()}],"mask-image-t-from-pos":[{"mask-t-from":P()}],"mask-image-t-to-pos":[{"mask-t-to":P()}],"mask-image-t-from-color":[{"mask-t-from":N()}],"mask-image-t-to-color":[{"mask-t-to":N()}],"mask-image-r-from-pos":[{"mask-r-from":P()}],"mask-image-r-to-pos":[{"mask-r-to":P()}],"mask-image-r-from-color":[{"mask-r-from":N()}],"mask-image-r-to-color":[{"mask-r-to":N()}],"mask-image-b-from-pos":[{"mask-b-from":P()}],"mask-image-b-to-pos":[{"mask-b-to":P()}],"mask-image-b-from-color":[{"mask-b-from":N()}],"mask-image-b-to-color":[{"mask-b-to":N()}],"mask-image-l-from-pos":[{"mask-l-from":P()}],"mask-image-l-to-pos":[{"mask-l-to":P()}],"mask-image-l-from-color":[{"mask-l-from":N()}],"mask-image-l-to-color":[{"mask-l-to":N()}],"mask-image-x-from-pos":[{"mask-x-from":P()}],"mask-image-x-to-pos":[{"mask-x-to":P()}],"mask-image-x-from-color":[{"mask-x-from":N()}],"mask-image-x-to-color":[{"mask-x-to":N()}],"mask-image-y-from-pos":[{"mask-y-from":P()}],"mask-image-y-to-pos":[{"mask-y-to":P()}],"mask-image-y-from-color":[{"mask-y-from":N()}],"mask-image-y-to-color":[{"mask-y-to":N()}],"mask-image-radial":[{"mask-radial":[X,J]}],"mask-image-radial-from-pos":[{"mask-radial-from":P()}],"mask-image-radial-to-pos":[{"mask-radial-to":P()}],"mask-image-radial-from-color":[{"mask-radial-from":N()}],"mask-image-radial-to-color":[{"mask-radial-to":N()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":b()}],"mask-image-conic-pos":[{"mask-conic":[fe]}],"mask-image-conic-from-pos":[{"mask-conic-from":P()}],"mask-image-conic-to-pos":[{"mask-conic-to":P()}],"mask-image-conic-from-color":[{"mask-conic-from":N()}],"mask-image-conic-to-color":[{"mask-conic-to":N()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:Z()}],"mask-repeat":[{mask:te()}],"mask-size":[{mask:re()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",X,J]}],filter:[{filter:["","none",X,J]}],blur:[{blur:G()}],brightness:[{brightness:[fe,X,J]}],contrast:[{contrast:[fe,X,J]}],"drop-shadow":[{"drop-shadow":["","none",g,Mr,Or]}],"drop-shadow-color":[{"drop-shadow":N()}],grayscale:[{grayscale:["",fe,X,J]}],"hue-rotate":[{"hue-rotate":[fe,X,J]}],invert:[{invert:["",fe,X,J]}],saturate:[{saturate:[fe,X,J]}],sepia:[{sepia:["",fe,X,J]}],"backdrop-filter":[{"backdrop-filter":["","none",X,J]}],"backdrop-blur":[{"backdrop-blur":G()}],"backdrop-brightness":[{"backdrop-brightness":[fe,X,J]}],"backdrop-contrast":[{"backdrop-contrast":[fe,X,J]}],"backdrop-grayscale":[{"backdrop-grayscale":["",fe,X,J]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[fe,X,J]}],"backdrop-invert":[{"backdrop-invert":["",fe,X,J]}],"backdrop-opacity":[{"backdrop-opacity":[fe,X,J]}],"backdrop-saturate":[{"backdrop-saturate":[fe,X,J]}],"backdrop-sepia":[{"backdrop-sepia":["",fe,X,J]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":C()}],"border-spacing-x":[{"border-spacing-x":C()}],"border-spacing-y":[{"border-spacing-y":C()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",X,J]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[fe,"initial",X,J]}],ease:[{ease:["linear","initial",v,X,J]}],delay:[{delay:[fe,X,J]}],animate:[{animate:["none",_,X,J]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[x,X,J]}],"perspective-origin":[{"perspective-origin":j()}],rotate:[{rotate:ue()}],"rotate-x":[{"rotate-x":ue()}],"rotate-y":[{"rotate-y":ue()}],"rotate-z":[{"rotate-z":ue()}],scale:[{scale:B()}],"scale-x":[{"scale-x":B()}],"scale-y":[{"scale-y":B()}],"scale-z":[{"scale-z":B()}],"scale-3d":["scale-3d"],skew:[{skew:ae()}],"skew-x":[{"skew-x":ae()}],"skew-y":[{"skew-y":ae()}],transform:[{transform:[X,J,"","none","gpu","cpu"]}],"transform-origin":[{origin:j()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ce()}],"translate-x":[{"translate-x":ce()}],"translate-y":[{"translate-y":ce()}],"translate-z":[{"translate-z":ce()}],"translate-none":["translate-none"],accent:[{accent:N()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:N()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",X,J]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":C()}],"scroll-mx":[{"scroll-mx":C()}],"scroll-my":[{"scroll-my":C()}],"scroll-ms":[{"scroll-ms":C()}],"scroll-me":[{"scroll-me":C()}],"scroll-mt":[{"scroll-mt":C()}],"scroll-mr":[{"scroll-mr":C()}],"scroll-mb":[{"scroll-mb":C()}],"scroll-ml":[{"scroll-ml":C()}],"scroll-p":[{"scroll-p":C()}],"scroll-px":[{"scroll-px":C()}],"scroll-py":[{"scroll-py":C()}],"scroll-ps":[{"scroll-ps":C()}],"scroll-pe":[{"scroll-pe":C()}],"scroll-pt":[{"scroll-pt":C()}],"scroll-pr":[{"scroll-pr":C()}],"scroll-pb":[{"scroll-pb":C()}],"scroll-pl":[{"scroll-pl":C()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",X,J]}],fill:[{fill:["none",...N()]}],"stroke-w":[{stroke:[fe,tr,xn,no]}],stroke:[{stroke:["none",...N()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},_y=ty(wy);function L(...e){return _y(Rl(e))}const ky=ca("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-900/20 disabled:pointer-events-none disabled:opacity-50 dark:focus-visible:ring-neutral-50/20",{variants:{variant:{default:"bg-neutral-900 text-neutral-50 hover:bg-neutral-900/90 dark:bg-neutral-50 dark:text-neutral-900 dark:hover:bg-neutral-50/90",secondary:"bg-neutral-100 text-neutral-900 hover:bg-neutral-100/80 dark:bg-neutral-800 dark:text-neutral-50 dark:hover:bg-neutral-800/80",outline:"border border-neutral-200 bg-transparent text-neutral-900 hover:bg-neutral-100 dark:border-neutral-800 dark:text-neutral-50 dark:hover:bg-neutral-800",ghost:"bg-transparent text-neutral-900 hover:bg-neutral-100 dark:text-neutral-50 dark:hover:bg-neutral-800",destructive:"bg-red-600 text-neutral-50 hover:bg-red-600/90 dark:bg-red-500 dark:hover:bg-red-500/90",link:"bg-transparent text-neutral-900 underline-offset-4 hover:underline dark:text-neutral-50"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-6",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),ne=m.forwardRef(({className:e,variant:t,size:n,asChild:r,...o},a)=>{const i=r?Ev:"button";return s.jsx(i,{className:L(ky({variant:t,size:n}),e),ref:a,...o})});ne.displayName="Button";const jy=ca("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-medium transition-colors",{variants:{variant:{default:"border-transparent bg-neutral-900 text-neutral-50 dark:bg-neutral-50 dark:text-neutral-900",secondary:"border-transparent bg-neutral-100 text-neutral-900 dark:bg-neutral-800 dark:text-neutral-50",outline:"border-neutral-200 text-neutral-900 dark:border-neutral-800 dark:text-neutral-50"}},defaultVariants:{variant:"secondary"}});function vn({className:e,variant:t,...n}){return s.jsx("div",{className:L(jy({variant:t}),e),...n})}const It=m.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,className:L("rounded-xl border border-neutral-200 bg-white text-neutral-950 shadow-sm dark:border-neutral-800 dark:bg-neutral-950 dark:text-neutral-50",e),...t}));It.displayName="Card";const hr=m.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,className:L("flex flex-col space-y-1.5 p-6",e),...t}));hr.displayName="CardHeader";const gr=m.forwardRef(({className:e,...t},n)=>s.jsx("h3",{ref:n,className:L("text-lg font-semibold leading-none tracking-tight",e),...t}));gr.displayName="CardTitle";const Zl=m.forwardRef(({className:e,...t},n)=>s.jsx("p",{ref:n,className:L("text-sm text-neutral-500 dark:text-neutral-400",e),...t}));Zl.displayName="CardDescription";const Wt=m.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,className:L("p-6 pt-0",e),...t}));Wt.displayName="CardContent";const ql=m.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,className:L("flex items-center p-6 pt-0",e),...t}));ql.displayName="CardFooter";const Fe=m.forwardRef(({className:e,...t},n)=>s.jsx("input",{ref:n,className:L("flex h-10 w-full rounded-md border border-neutral-200 bg-white px-3 py-2 text-sm text-neutral-950 shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-neutral-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-900/20 disabled:cursor-not-allowed disabled:opacity-50 dark:border-neutral-800 dark:bg-neutral-950 dark:text-neutral-50 dark:placeholder:text-neutral-400 dark:focus-visible:ring-neutral-50/20",e),...t}));Fe.displayName="Input";const st=m.forwardRef(({className:e,...t},n)=>s.jsx("label",{ref:n,className:L("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",e),...t}));st.displayName="Label";var Sy=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Cy=Sy.reduce((e,t)=>{const n=Tl(`Primitive.${t}`),r=m.forwardRef((o,a)=>{const{asChild:i,...c}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(l,{...c,ref:a})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),Ny="Separator",Wi="horizontal",Ay=["horizontal","vertical"],Gl=m.forwardRef((e,t)=>{const{decorative:n,orientation:r=Wi,...o}=e,a=Ey(r)?r:Wi,c=n?{role:"none"}:{"aria-orientation":a==="vertical"?a:void 0,role:"separator"};return s.jsx(Cy.div,{"data-orientation":a,...c,...o,ref:t})});Gl.displayName=Ny;function Ey(e){return Ay.includes(e)}var Yl=Gl;const yt=m.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>s.jsx(Yl,{ref:o,decorative:n,orientation:t,className:L("shrink-0 bg-neutral-200 dark:bg-neutral-800",t==="horizontal"?"h-px w-full":"h-full w-px",e),...r}));yt.displayName=Yl.displayName;function Re({className:e,...t}){return s.jsx("div",{className:L("animate-pulse rounded-md bg-neutral-100 dark:bg-neutral-800",e),...t})}function Hi(e,[t,n]){return Math.min(n,Math.max(t,e))}function xe(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e?.(o),n===!1||!o.defaultPrevented)return t?.(o)}}function Iy(e,t){const n=m.createContext(t),r=a=>{const{children:i,...c}=a,l=m.useMemo(()=>c,Object.values(c));return s.jsx(n.Provider,{value:l,children:i})};r.displayName=e+"Provider";function o(a){const i=m.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${a}\` must be used within \`${e}\``)}return[r,o]}function un(e,t=[]){let n=[];function r(a,i){const c=m.createContext(i),l=n.length;n=[...n,i];const d=u=>{const{scope:h,children:g,...y}=u,x=h?.[e]?.[l]||c,p=m.useMemo(()=>y,Object.values(y));return s.jsx(x.Provider,{value:p,children:g})};d.displayName=a+"Provider";function f(u,h){const g=h?.[e]?.[l]||c,y=m.useContext(g);if(y)return y;if(i!==void 0)return i;throw new Error(`\`${u}\` must be used within \`${a}\``)}return[d,f]}const o=()=>{const a=n.map(i=>m.createContext(i));return function(c){const l=c?.[e]||a;return m.useMemo(()=>({[`__scope${e}`]:{...c,[e]:l}}),[c,l])}};return o.scopeName=e,[r,Ty(o,...t)]}function Ty(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(a){const i=r.reduce((c,{useScope:l,scopeName:d})=>{const u=l(a)[`__scope${d}`];return{...c,...u}},{});return m.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}function Zi(e){const t=Py(e),n=m.forwardRef((r,o)=>{const{children:a,...i}=r,c=m.Children.toArray(a),l=c.find(Oy);if(l){const d=l.props.children,f=c.map(u=>u===l?m.Children.count(d)>1?m.Children.only(null):m.isValidElement(d)?d.props.children:null:u);return s.jsx(t,{...i,ref:o,children:m.isValidElement(d)?m.cloneElement(d,void 0,f):null})}return s.jsx(t,{...i,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}function Py(e){const t=m.forwardRef((n,r)=>{const{children:o,...a}=n;if(m.isValidElement(o)){const i=Ly(o),c=My(a,o.props);return o.type!==m.Fragment&&(c.ref=r?Hn(r,i):i),m.cloneElement(o,c)}return m.Children.count(o)>1?m.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Ry=Symbol("radix.slottable");function Oy(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Ry}function My(e,t){const n={...t};for(const r in t){const o=e[r],a=t[r];/^on[A-Z]/.test(r)?o&&a?n[r]=(...c)=>{const l=a(...c);return o(...c),l}:o&&(n[r]=o):r==="style"?n[r]={...o,...a}:r==="className"&&(n[r]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function Ly(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function da(e){const t=e+"CollectionProvider",[n,r]=un(t),[o,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=x=>{const{scope:p,children:v}=x,_=k.useRef(null),w=k.useRef(new Map).current;return s.jsx(o,{scope:p,itemMap:w,collectionRef:_,children:v})};i.displayName=t;const c=e+"CollectionSlot",l=Zi(c),d=k.forwardRef((x,p)=>{const{scope:v,children:_}=x,w=a(c,v),b=Ce(p,w.collectionRef);return s.jsx(l,{ref:b,children:_})});d.displayName=c;const f=e+"CollectionItemSlot",u="data-radix-collection-item",h=Zi(f),g=k.forwardRef((x,p)=>{const{scope:v,children:_,...w}=x,b=k.useRef(null),j=Ce(p,b),R=a(f,v);return k.useEffect(()=>(R.itemMap.set(b,{ref:b,...w}),()=>void R.itemMap.delete(b))),s.jsx(h,{[u]:"",ref:j,children:_})});g.displayName=f;function y(x){const p=a(e+"CollectionConsumer",x);return k.useCallback(()=>{const _=p.collectionRef.current;if(!_)return[];const w=Array.from(_.querySelectorAll(`[${u}]`));return Array.from(p.itemMap.values()).sort((R,I)=>w.indexOf(R.ref.current)-w.indexOf(I.ref.current))},[p.collectionRef,p.itemMap])}return[{Provider:i,Slot:d,ItemSlot:g},y,r]}var Dy=m.createContext(void 0);function bs(e){const t=m.useContext(Dy);return e||t||"ltr"}function $y(e){const t=zy(e),n=m.forwardRef((r,o)=>{const{children:a,...i}=r,c=m.Children.toArray(a),l=c.find(Uy);if(l){const d=l.props.children,f=c.map(u=>u===l?m.Children.count(d)>1?m.Children.only(null):m.isValidElement(d)?d.props.children:null:u);return s.jsx(t,{...i,ref:o,children:m.isValidElement(d)?m.cloneElement(d,void 0,f):null})}return s.jsx(t,{...i,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}function zy(e){const t=m.forwardRef((n,r)=>{const{children:o,...a}=n;if(m.isValidElement(o)){const i=Vy(o),c=By(a,o.props);return o.type!==m.Fragment&&(c.ref=r?Hn(r,i):i),m.cloneElement(o,c)}return m.Children.count(o)>1?m.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Fy=Symbol("radix.slottable");function Uy(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Fy}function By(e,t){const n={...t};for(const r in t){const o=e[r],a=t[r];/^on[A-Z]/.test(r)?o&&a?n[r]=(...c)=>{const l=a(...c);return o(...c),l}:o&&(n[r]=o):r==="style"?n[r]={...o,...a}:r==="className"&&(n[r]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function Vy(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Wy=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],pe=Wy.reduce((e,t)=>{const n=$y(`Primitive.${t}`),r=m.forwardRef((o,a)=>{const{asChild:i,...c}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(l,{...c,ref:a})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Hy(e,t){e&&ps.flushSync(()=>e.dispatchEvent(t))}function sn(e){const t=m.useRef(e);return m.useEffect(()=>{t.current=e}),m.useMemo(()=>(...n)=>t.current?.(...n),[])}function Zy(e,t=globalThis?.document){const n=sn(e);m.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var qy="DismissableLayer",Ao="dismissableLayer.update",Gy="dismissableLayer.pointerDownOutside",Yy="dismissableLayer.focusOutside",qi,Ql=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),ua=m.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:i,onDismiss:c,...l}=e,d=m.useContext(Ql),[f,u]=m.useState(null),h=f?.ownerDocument??globalThis?.document,[,g]=m.useState({}),y=Ce(t,I=>u(I)),x=Array.from(d.layers),[p]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),v=x.indexOf(p),_=f?x.indexOf(f):-1,w=d.layersWithOutsidePointerEventsDisabled.size>0,b=_>=v,j=Jy(I=>{const C=I.target,E=[...d.branches].some(O=>O.contains(C));!b||E||(o?.(I),i?.(I),I.defaultPrevented||c?.())},h),R=Xy(I=>{const C=I.target;[...d.branches].some(O=>O.contains(C))||(a?.(I),i?.(I),I.defaultPrevented||c?.())},h);return Zy(I=>{_===d.layers.size-1&&(r?.(I),!I.defaultPrevented&&c&&(I.preventDefault(),c()))},h),m.useEffect(()=>{if(f)return n&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(qi=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(f)),d.layers.add(f),Gi(),()=>{n&&d.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=qi)}},[f,h,n,d]),m.useEffect(()=>()=>{f&&(d.layers.delete(f),d.layersWithOutsidePointerEventsDisabled.delete(f),Gi())},[f,d]),m.useEffect(()=>{const I=()=>g({});return document.addEventListener(Ao,I),()=>document.removeEventListener(Ao,I)},[]),s.jsx(pe.div,{...l,ref:y,style:{pointerEvents:w?b?"auto":"none":void 0,...e.style},onFocusCapture:xe(e.onFocusCapture,R.onFocusCapture),onBlurCapture:xe(e.onBlurCapture,R.onBlurCapture),onPointerDownCapture:xe(e.onPointerDownCapture,j.onPointerDownCapture)})});ua.displayName=qy;var Qy="DismissableLayerBranch",Ky=m.forwardRef((e,t)=>{const n=m.useContext(Ql),r=m.useRef(null),o=Ce(t,r);return m.useEffect(()=>{const a=r.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),s.jsx(pe.div,{...e,ref:o})});Ky.displayName=Qy;function Jy(e,t=globalThis?.document){const n=sn(e),r=m.useRef(!1),o=m.useRef(()=>{});return m.useEffect(()=>{const a=c=>{if(c.target&&!r.current){let l=function(){Kl(Gy,n,d,{discrete:!0})};const d={originalEvent:c};c.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=l,t.addEventListener("click",o.current,{once:!0})):l()}else t.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",a),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function Xy(e,t=globalThis?.document){const n=sn(e),r=m.useRef(!1);return m.useEffect(()=>{const o=a=>{a.target&&!r.current&&Kl(Yy,n,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Gi(){const e=new CustomEvent(Ao);document.dispatchEvent(e)}function Kl(e,t,n,{discrete:r}){const o=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Hy(o,a):o.dispatchEvent(a)}var ro=0;function Jl(){m.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Yi()),document.body.insertAdjacentElement("beforeend",e[1]??Yi()),ro++,()=>{ro===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),ro--}},[])}function Yi(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var so="focusScope.autoFocusOnMount",oo="focusScope.autoFocusOnUnmount",Qi={bubbles:!1,cancelable:!0},e0="FocusScope",fa=m.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...i}=e,[c,l]=m.useState(null),d=sn(o),f=sn(a),u=m.useRef(null),h=Ce(t,x=>l(x)),g=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(r){let x=function(w){if(g.paused||!c)return;const b=w.target;c.contains(b)?u.current=b:rn(u.current,{select:!0})},p=function(w){if(g.paused||!c)return;const b=w.relatedTarget;b!==null&&(c.contains(b)||rn(u.current,{select:!0}))},v=function(w){if(document.activeElement===document.body)for(const j of w)j.removedNodes.length>0&&rn(c)};document.addEventListener("focusin",x),document.addEventListener("focusout",p);const _=new MutationObserver(v);return c&&_.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",x),document.removeEventListener("focusout",p),_.disconnect()}}},[r,c,g.paused]),m.useEffect(()=>{if(c){Ji.add(g);const x=document.activeElement;if(!c.contains(x)){const v=new CustomEvent(so,Qi);c.addEventListener(so,d),c.dispatchEvent(v),v.defaultPrevented||(t0(a0(Xl(c)),{select:!0}),document.activeElement===x&&rn(c))}return()=>{c.removeEventListener(so,d),setTimeout(()=>{const v=new CustomEvent(oo,Qi);c.addEventListener(oo,f),c.dispatchEvent(v),v.defaultPrevented||rn(x??document.body,{select:!0}),c.removeEventListener(oo,f),Ji.remove(g)},0)}}},[c,d,f,g]);const y=m.useCallback(x=>{if(!n&&!r||g.paused)return;const p=x.key==="Tab"&&!x.altKey&&!x.ctrlKey&&!x.metaKey,v=document.activeElement;if(p&&v){const _=x.currentTarget,[w,b]=n0(_);w&&b?!x.shiftKey&&v===b?(x.preventDefault(),n&&rn(w,{select:!0})):x.shiftKey&&v===w&&(x.preventDefault(),n&&rn(b,{select:!0})):v===_&&x.preventDefault()}},[n,r,g.paused]);return s.jsx(pe.div,{tabIndex:-1,...i,ref:h,onKeyDown:y})});fa.displayName=e0;function t0(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(rn(r,{select:t}),document.activeElement!==n)return}function n0(e){const t=Xl(e),n=Ki(t,e),r=Ki(t.reverse(),e);return[n,r]}function Xl(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Ki(e,t){for(const n of e)if(!r0(n,{upTo:t}))return n}function r0(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function s0(e){return e instanceof HTMLInputElement&&"select"in e}function rn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&s0(e)&&t&&e.select()}}var Ji=o0();function o0(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=Xi(e,t),e.unshift(t)},remove(t){e=Xi(e,t),e[0]?.resume()}}}function Xi(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function a0(e){return e.filter(t=>t.tagName!=="A")}var qe=globalThis?.document?m.useLayoutEffect:()=>{},i0=m[" useId ".trim().toString()]||(()=>{}),c0=0;function Ut(e){const[t,n]=m.useState(i0());return qe(()=>{n(r=>r??String(c0++))},[e]),e||(t?`radix-${t}`:"")}const l0=["top","right","bottom","left"],on=Math.min,ht=Math.max,ss=Math.round,Lr=Math.floor,Bt=e=>({x:e,y:e}),d0={left:"right",right:"left",bottom:"top",top:"bottom"},u0={start:"end",end:"start"};function Eo(e,t,n){return ht(e,on(t,n))}function Jt(e,t){return typeof e=="function"?e(t):e}function Xt(e){return e.split("-")[0]}function Gn(e){return e.split("-")[1]}function ma(e){return e==="x"?"y":"x"}function pa(e){return e==="y"?"height":"width"}const f0=new Set(["top","bottom"]);function Ft(e){return f0.has(Xt(e))?"y":"x"}function ha(e){return ma(Ft(e))}function m0(e,t,n){n===void 0&&(n=!1);const r=Gn(e),o=ha(e),a=pa(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(i=os(i)),[i,os(i)]}function p0(e){const t=os(e);return[Io(e),t,Io(t)]}function Io(e){return e.replace(/start|end/g,t=>u0[t])}const ec=["left","right"],tc=["right","left"],h0=["top","bottom"],g0=["bottom","top"];function x0(e,t,n){switch(e){case"top":case"bottom":return n?t?tc:ec:t?ec:tc;case"left":case"right":return t?h0:g0;default:return[]}}function v0(e,t,n,r){const o=Gn(e);let a=x0(Xt(e),n==="start",r);return o&&(a=a.map(i=>i+"-"+o),t&&(a=a.concat(a.map(Io)))),a}function os(e){return e.replace(/left|right|bottom|top/g,t=>d0[t])}function y0(e){return{top:0,right:0,bottom:0,left:0,...e}}function ed(e){return typeof e!="number"?y0(e):{top:e,right:e,bottom:e,left:e}}function as(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function nc(e,t,n){let{reference:r,floating:o}=e;const a=Ft(t),i=ha(t),c=pa(i),l=Xt(t),d=a==="y",f=r.x+r.width/2-o.width/2,u=r.y+r.height/2-o.height/2,h=r[c]/2-o[c]/2;let g;switch(l){case"top":g={x:f,y:r.y-o.height};break;case"bottom":g={x:f,y:r.y+r.height};break;case"right":g={x:r.x+r.width,y:u};break;case"left":g={x:r.x-o.width,y:u};break;default:g={x:r.x,y:r.y}}switch(Gn(t)){case"start":g[i]-=h*(n&&d?-1:1);break;case"end":g[i]+=h*(n&&d?-1:1);break}return g}const b0=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:a=[],platform:i}=n,c=a.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(t));let d=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:f,y:u}=nc(d,r,l),h=r,g={},y=0;for(let x=0;x<c.length;x++){const{name:p,fn:v}=c[x],{x:_,y:w,data:b,reset:j}=await v({x:f,y:u,initialPlacement:r,placement:h,strategy:o,middlewareData:g,rects:d,platform:i,elements:{reference:e,floating:t}});f=_??f,u=w??u,g={...g,[p]:{...g[p],...b}},j&&y<=50&&(y++,typeof j=="object"&&(j.placement&&(h=j.placement),j.rects&&(d=j.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):j.rects),{x:f,y:u}=nc(d,h,l)),x=-1)}return{x:f,y:u,placement:h,strategy:o,middlewareData:g}};async function xr(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:a,rects:i,elements:c,strategy:l}=e,{boundary:d="clippingAncestors",rootBoundary:f="viewport",elementContext:u="floating",altBoundary:h=!1,padding:g=0}=Jt(t,e),y=ed(g),p=c[h?u==="floating"?"reference":"floating":u],v=as(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(p)))==null||n?p:p.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(c.floating)),boundary:d,rootBoundary:f,strategy:l})),_=u==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,w=await(a.getOffsetParent==null?void 0:a.getOffsetParent(c.floating)),b=await(a.isElement==null?void 0:a.isElement(w))?await(a.getScale==null?void 0:a.getScale(w))||{x:1,y:1}:{x:1,y:1},j=as(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:_,offsetParent:w,strategy:l}):_);return{top:(v.top-j.top+y.top)/b.y,bottom:(j.bottom-v.bottom+y.bottom)/b.y,left:(v.left-j.left+y.left)/b.x,right:(j.right-v.right+y.right)/b.x}}const w0=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:a,platform:i,elements:c,middlewareData:l}=t,{element:d,padding:f=0}=Jt(e,t)||{};if(d==null)return{};const u=ed(f),h={x:n,y:r},g=ha(o),y=pa(g),x=await i.getDimensions(d),p=g==="y",v=p?"top":"left",_=p?"bottom":"right",w=p?"clientHeight":"clientWidth",b=a.reference[y]+a.reference[g]-h[g]-a.floating[y],j=h[g]-a.reference[g],R=await(i.getOffsetParent==null?void 0:i.getOffsetParent(d));let I=R?R[w]:0;(!I||!await(i.isElement==null?void 0:i.isElement(R)))&&(I=c.floating[w]||a.floating[y]);const C=b/2-j/2,E=I/2-x[y]/2-1,O=on(u[v],E),F=on(u[_],E),M=O,U=I-x[y]-F,D=I/2-x[y]/2+C,H=Eo(M,D,U),z=!l.arrow&&Gn(o)!=null&&D!==H&&a.reference[y]/2-(D<M?O:F)-x[y]/2<0,A=z?D<M?D-M:D-U:0;return{[g]:h[g]+A,data:{[g]:H,centerOffset:D-H-A,...z&&{alignmentOffset:A}},reset:z}}}),_0=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:a,rects:i,initialPlacement:c,platform:l,elements:d}=t,{mainAxis:f=!0,crossAxis:u=!0,fallbackPlacements:h,fallbackStrategy:g="bestFit",fallbackAxisSideDirection:y="none",flipAlignment:x=!0,...p}=Jt(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const v=Xt(o),_=Ft(c),w=Xt(c)===c,b=await(l.isRTL==null?void 0:l.isRTL(d.floating)),j=h||(w||!x?[os(c)]:p0(c)),R=y!=="none";!h&&R&&j.push(...v0(c,x,y,b));const I=[c,...j],C=await xr(t,p),E=[];let O=((r=a.flip)==null?void 0:r.overflows)||[];if(f&&E.push(C[v]),u){const D=m0(o,i,b);E.push(C[D[0]],C[D[1]])}if(O=[...O,{placement:o,overflows:E}],!E.every(D=>D<=0)){var F,M;const D=(((F=a.flip)==null?void 0:F.index)||0)+1,H=I[D];if(H&&(!(u==="alignment"?_!==Ft(H):!1)||O.every(N=>Ft(N.placement)===_?N.overflows[0]>0:!0)))return{data:{index:D,overflows:O},reset:{placement:H}};let z=(M=O.filter(A=>A.overflows[0]<=0).sort((A,N)=>A.overflows[1]-N.overflows[1])[0])==null?void 0:M.placement;if(!z)switch(g){case"bestFit":{var U;const A=(U=O.filter(N=>{if(R){const Z=Ft(N.placement);return Z===_||Z==="y"}return!0}).map(N=>[N.placement,N.overflows.filter(Z=>Z>0).reduce((Z,te)=>Z+te,0)]).sort((N,Z)=>N[1]-Z[1])[0])==null?void 0:U[0];A&&(z=A);break}case"initialPlacement":z=c;break}if(o!==z)return{reset:{placement:z}}}return{}}}};function rc(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function sc(e){return l0.some(t=>e[t]>=0)}const k0=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=Jt(e,t);switch(r){case"referenceHidden":{const a=await xr(t,{...o,elementContext:"reference"}),i=rc(a,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:sc(i)}}}case"escaped":{const a=await xr(t,{...o,altBoundary:!0}),i=rc(a,n.floating);return{data:{escapedOffsets:i,escaped:sc(i)}}}default:return{}}}}},td=new Set(["left","top"]);async function j0(e,t){const{placement:n,platform:r,elements:o}=e,a=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=Xt(n),c=Gn(n),l=Ft(n)==="y",d=td.has(i)?-1:1,f=a&&l?-1:1,u=Jt(t,e);let{mainAxis:h,crossAxis:g,alignmentAxis:y}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return c&&typeof y=="number"&&(g=c==="end"?y*-1:y),l?{x:g*f,y:h*d}:{x:h*d,y:g*f}}const S0=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:a,placement:i,middlewareData:c}=t,l=await j0(t,e);return i===((n=c.offset)==null?void 0:n.placement)&&(r=c.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:a+l.y,data:{...l,placement:i}}}}},C0=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:a=!0,crossAxis:i=!1,limiter:c={fn:p=>{let{x:v,y:_}=p;return{x:v,y:_}}},...l}=Jt(e,t),d={x:n,y:r},f=await xr(t,l),u=Ft(Xt(o)),h=ma(u);let g=d[h],y=d[u];if(a){const p=h==="y"?"top":"left",v=h==="y"?"bottom":"right",_=g+f[p],w=g-f[v];g=Eo(_,g,w)}if(i){const p=u==="y"?"top":"left",v=u==="y"?"bottom":"right",_=y+f[p],w=y-f[v];y=Eo(_,y,w)}const x=c.fn({...t,[h]:g,[u]:y});return{...x,data:{x:x.x-n,y:x.y-r,enabled:{[h]:a,[u]:i}}}}}},N0=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:a,middlewareData:i}=t,{offset:c=0,mainAxis:l=!0,crossAxis:d=!0}=Jt(e,t),f={x:n,y:r},u=Ft(o),h=ma(u);let g=f[h],y=f[u];const x=Jt(c,t),p=typeof x=="number"?{mainAxis:x,crossAxis:0}:{mainAxis:0,crossAxis:0,...x};if(l){const w=h==="y"?"height":"width",b=a.reference[h]-a.floating[w]+p.mainAxis,j=a.reference[h]+a.reference[w]-p.mainAxis;g<b?g=b:g>j&&(g=j)}if(d){var v,_;const w=h==="y"?"width":"height",b=td.has(Xt(o)),j=a.reference[u]-a.floating[w]+(b&&((v=i.offset)==null?void 0:v[u])||0)+(b?0:p.crossAxis),R=a.reference[u]+a.reference[w]+(b?0:((_=i.offset)==null?void 0:_[u])||0)-(b?p.crossAxis:0);y<j?y=j:y>R&&(y=R)}return{[h]:g,[u]:y}}}},A0=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:a,platform:i,elements:c}=t,{apply:l=()=>{},...d}=Jt(e,t),f=await xr(t,d),u=Xt(o),h=Gn(o),g=Ft(o)==="y",{width:y,height:x}=a.floating;let p,v;u==="top"||u==="bottom"?(p=u,v=h===(await(i.isRTL==null?void 0:i.isRTL(c.floating))?"start":"end")?"left":"right"):(v=u,p=h==="end"?"top":"bottom");const _=x-f.top-f.bottom,w=y-f.left-f.right,b=on(x-f[p],_),j=on(y-f[v],w),R=!t.middlewareData.shift;let I=b,C=j;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(C=w),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(I=_),R&&!h){const O=ht(f.left,0),F=ht(f.right,0),M=ht(f.top,0),U=ht(f.bottom,0);g?C=y-2*(O!==0||F!==0?O+F:ht(f.left,f.right)):I=x-2*(M!==0||U!==0?M+U:ht(f.top,f.bottom))}await l({...t,availableWidth:C,availableHeight:I});const E=await i.getDimensions(c.floating);return y!==E.width||x!==E.height?{reset:{rects:!0}}:{}}}};function ws(){return typeof window<"u"}function Yn(e){return nd(e)?(e.nodeName||"").toLowerCase():"#document"}function gt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Zt(e){var t;return(t=(nd(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function nd(e){return ws()?e instanceof Node||e instanceof gt(e).Node:!1}function Tt(e){return ws()?e instanceof Element||e instanceof gt(e).Element:!1}function Ht(e){return ws()?e instanceof HTMLElement||e instanceof gt(e).HTMLElement:!1}function oc(e){return!ws()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof gt(e).ShadowRoot}const E0=new Set(["inline","contents"]);function Cr(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Pt(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!E0.has(o)}const I0=new Set(["table","td","th"]);function T0(e){return I0.has(Yn(e))}const P0=[":popover-open",":modal"];function _s(e){return P0.some(t=>{try{return e.matches(t)}catch{return!1}})}const R0=["transform","translate","scale","rotate","perspective"],O0=["transform","translate","scale","rotate","perspective","filter"],M0=["paint","layout","strict","content"];function ga(e){const t=xa(),n=Tt(e)?Pt(e):e;return R0.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||O0.some(r=>(n.willChange||"").includes(r))||M0.some(r=>(n.contain||"").includes(r))}function L0(e){let t=an(e);for(;Ht(t)&&!Un(t);){if(ga(t))return t;if(_s(t))return null;t=an(t)}return null}function xa(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const D0=new Set(["html","body","#document"]);function Un(e){return D0.has(Yn(e))}function Pt(e){return gt(e).getComputedStyle(e)}function ks(e){return Tt(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function an(e){if(Yn(e)==="html")return e;const t=e.assignedSlot||e.parentNode||oc(e)&&e.host||Zt(e);return oc(t)?t.host:t}function rd(e){const t=an(e);return Un(t)?e.ownerDocument?e.ownerDocument.body:e.body:Ht(t)&&Cr(t)?t:rd(t)}function vr(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=rd(e),a=o===((r=e.ownerDocument)==null?void 0:r.body),i=gt(o);if(a){const c=To(i);return t.concat(i,i.visualViewport||[],Cr(o)?o:[],c&&n?vr(c):[])}return t.concat(o,vr(o,[],n))}function To(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function sd(e){const t=Pt(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Ht(e),a=o?e.offsetWidth:n,i=o?e.offsetHeight:r,c=ss(n)!==a||ss(r)!==i;return c&&(n=a,r=i),{width:n,height:r,$:c}}function va(e){return Tt(e)?e:e.contextElement}function $n(e){const t=va(e);if(!Ht(t))return Bt(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:a}=sd(t);let i=(a?ss(n.width):n.width)/r,c=(a?ss(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!c||!Number.isFinite(c))&&(c=1),{x:i,y:c}}const $0=Bt(0);function od(e){const t=gt(e);return!xa()||!t.visualViewport?$0:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function z0(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==gt(e)?!1:t}function wn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),a=va(e);let i=Bt(1);t&&(r?Tt(r)&&(i=$n(r)):i=$n(e));const c=z0(a,n,r)?od(a):Bt(0);let l=(o.left+c.x)/i.x,d=(o.top+c.y)/i.y,f=o.width/i.x,u=o.height/i.y;if(a){const h=gt(a),g=r&&Tt(r)?gt(r):r;let y=h,x=To(y);for(;x&&r&&g!==y;){const p=$n(x),v=x.getBoundingClientRect(),_=Pt(x),w=v.left+(x.clientLeft+parseFloat(_.paddingLeft))*p.x,b=v.top+(x.clientTop+parseFloat(_.paddingTop))*p.y;l*=p.x,d*=p.y,f*=p.x,u*=p.y,l+=w,d+=b,y=gt(x),x=To(y)}}return as({width:f,height:u,x:l,y:d})}function js(e,t){const n=ks(e).scrollLeft;return t?t.left+n:wn(Zt(e)).left+n}function ad(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-js(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function F0(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const a=o==="fixed",i=Zt(r),c=t?_s(t.floating):!1;if(r===i||c&&a)return n;let l={scrollLeft:0,scrollTop:0},d=Bt(1);const f=Bt(0),u=Ht(r);if((u||!u&&!a)&&((Yn(r)!=="body"||Cr(i))&&(l=ks(r)),Ht(r))){const g=wn(r);d=$n(r),f.x=g.x+r.clientLeft,f.y=g.y+r.clientTop}const h=i&&!u&&!a?ad(i,l):Bt(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-l.scrollLeft*d.x+f.x+h.x,y:n.y*d.y-l.scrollTop*d.y+f.y+h.y}}function U0(e){return Array.from(e.getClientRects())}function B0(e){const t=Zt(e),n=ks(e),r=e.ownerDocument.body,o=ht(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=ht(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+js(e);const c=-n.scrollTop;return Pt(r).direction==="rtl"&&(i+=ht(t.clientWidth,r.clientWidth)-o),{width:o,height:a,x:i,y:c}}const ac=25;function V0(e,t){const n=gt(e),r=Zt(e),o=n.visualViewport;let a=r.clientWidth,i=r.clientHeight,c=0,l=0;if(o){a=o.width,i=o.height;const f=xa();(!f||f&&t==="fixed")&&(c=o.offsetLeft,l=o.offsetTop)}const d=js(r);if(d<=0){const f=r.ownerDocument,u=f.body,h=getComputedStyle(u),g=f.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,y=Math.abs(r.clientWidth-u.clientWidth-g);y<=ac&&(a-=y)}else d<=ac&&(a+=d);return{width:a,height:i,x:c,y:l}}const W0=new Set(["absolute","fixed"]);function H0(e,t){const n=wn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,a=Ht(e)?$n(e):Bt(1),i=e.clientWidth*a.x,c=e.clientHeight*a.y,l=o*a.x,d=r*a.y;return{width:i,height:c,x:l,y:d}}function ic(e,t,n){let r;if(t==="viewport")r=V0(e,n);else if(t==="document")r=B0(Zt(e));else if(Tt(t))r=H0(t,n);else{const o=od(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return as(r)}function id(e,t){const n=an(e);return n===t||!Tt(n)||Un(n)?!1:Pt(n).position==="fixed"||id(n,t)}function Z0(e,t){const n=t.get(e);if(n)return n;let r=vr(e,[],!1).filter(c=>Tt(c)&&Yn(c)!=="body"),o=null;const a=Pt(e).position==="fixed";let i=a?an(e):e;for(;Tt(i)&&!Un(i);){const c=Pt(i),l=ga(i);!l&&c.position==="fixed"&&(o=null),(a?!l&&!o:!l&&c.position==="static"&&!!o&&W0.has(o.position)||Cr(i)&&!l&&id(e,i))?r=r.filter(f=>f!==i):o=c,i=an(i)}return t.set(e,r),r}function q0(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?_s(t)?[]:Z0(t,this._c):[].concat(n),r],c=i[0],l=i.reduce((d,f)=>{const u=ic(t,f,o);return d.top=ht(u.top,d.top),d.right=on(u.right,d.right),d.bottom=on(u.bottom,d.bottom),d.left=ht(u.left,d.left),d},ic(t,c,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function G0(e){const{width:t,height:n}=sd(e);return{width:t,height:n}}function Y0(e,t,n){const r=Ht(t),o=Zt(t),a=n==="fixed",i=wn(e,!0,a,t);let c={scrollLeft:0,scrollTop:0};const l=Bt(0);function d(){l.x=js(o)}if(r||!r&&!a)if((Yn(t)!=="body"||Cr(o))&&(c=ks(t)),r){const g=wn(t,!0,a,t);l.x=g.x+t.clientLeft,l.y=g.y+t.clientTop}else o&&d();a&&!r&&o&&d();const f=o&&!r&&!a?ad(o,c):Bt(0),u=i.left+c.scrollLeft-l.x-f.x,h=i.top+c.scrollTop-l.y-f.y;return{x:u,y:h,width:i.width,height:i.height}}function ao(e){return Pt(e).position==="static"}function cc(e,t){if(!Ht(e)||Pt(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Zt(e)===n&&(n=n.ownerDocument.body),n}function cd(e,t){const n=gt(e);if(_s(e))return n;if(!Ht(e)){let o=an(e);for(;o&&!Un(o);){if(Tt(o)&&!ao(o))return o;o=an(o)}return n}let r=cc(e,t);for(;r&&T0(r)&&ao(r);)r=cc(r,t);return r&&Un(r)&&ao(r)&&!ga(r)?n:r||L0(e)||n}const Q0=async function(e){const t=this.getOffsetParent||cd,n=this.getDimensions,r=await n(e.floating);return{reference:Y0(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function K0(e){return Pt(e).direction==="rtl"}const J0={convertOffsetParentRelativeRectToViewportRelativeRect:F0,getDocumentElement:Zt,getClippingRect:q0,getOffsetParent:cd,getElementRects:Q0,getClientRects:U0,getDimensions:G0,getScale:$n,isElement:Tt,isRTL:K0};function ld(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function X0(e,t){let n=null,r;const o=Zt(e);function a(){var c;clearTimeout(r),(c=n)==null||c.disconnect(),n=null}function i(c,l){c===void 0&&(c=!1),l===void 0&&(l=1),a();const d=e.getBoundingClientRect(),{left:f,top:u,width:h,height:g}=d;if(c||t(),!h||!g)return;const y=Lr(u),x=Lr(o.clientWidth-(f+h)),p=Lr(o.clientHeight-(u+g)),v=Lr(f),w={rootMargin:-y+"px "+-x+"px "+-p+"px "+-v+"px",threshold:ht(0,on(1,l))||1};let b=!0;function j(R){const I=R[0].intersectionRatio;if(I!==l){if(!b)return i();I?i(!1,I):r=setTimeout(()=>{i(!1,1e-7)},1e3)}I===1&&!ld(d,e.getBoundingClientRect())&&i(),b=!1}try{n=new IntersectionObserver(j,{...w,root:o.ownerDocument})}catch{n=new IntersectionObserver(j,w)}n.observe(e)}return i(!0),a}function eb(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:a=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,d=va(e),f=o||a?[...d?vr(d):[],...vr(t)]:[];f.forEach(v=>{o&&v.addEventListener("scroll",n,{passive:!0}),a&&v.addEventListener("resize",n)});const u=d&&c?X0(d,n):null;let h=-1,g=null;i&&(g=new ResizeObserver(v=>{let[_]=v;_&&_.target===d&&g&&(g.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var w;(w=g)==null||w.observe(t)})),n()}),d&&!l&&g.observe(d),g.observe(t));let y,x=l?wn(e):null;l&&p();function p(){const v=wn(e);x&&!ld(x,v)&&n(),x=v,y=requestAnimationFrame(p)}return n(),()=>{var v;f.forEach(_=>{o&&_.removeEventListener("scroll",n),a&&_.removeEventListener("resize",n)}),u?.(),(v=g)==null||v.disconnect(),g=null,l&&cancelAnimationFrame(y)}}const tb=S0,nb=C0,rb=_0,sb=A0,ob=k0,lc=w0,ab=N0,ib=(e,t,n)=>{const r=new Map,o={platform:J0,...n},a={...o.platform,_c:r};return b0(e,t,{...o,platform:a})};var cb=typeof document<"u",lb=function(){},qr=cb?k.useLayoutEffect:lb;function is(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!is(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const a=o[r];if(!(a==="_owner"&&e.$$typeof)&&!is(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function dd(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function dc(e,t){const n=dd(e);return Math.round(t*n)/n}function io(e){const t=m.useRef(e);return qr(()=>{t.current=e}),t}function db(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:a,floating:i}={},transform:c=!0,whileElementsMounted:l,open:d}=e,[f,u]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,g]=m.useState(r);is(h,r)||g(r);const[y,x]=m.useState(null),[p,v]=m.useState(null),_=m.useCallback(N=>{N!==R.current&&(R.current=N,x(N))},[]),w=m.useCallback(N=>{N!==I.current&&(I.current=N,v(N))},[]),b=a||y,j=i||p,R=m.useRef(null),I=m.useRef(null),C=m.useRef(f),E=l!=null,O=io(l),F=io(o),M=io(d),U=m.useCallback(()=>{if(!R.current||!I.current)return;const N={placement:t,strategy:n,middleware:h};F.current&&(N.platform=F.current),ib(R.current,I.current,N).then(Z=>{const te={...Z,isPositioned:M.current!==!1};D.current&&!is(C.current,te)&&(C.current=te,ps.flushSync(()=>{u(te)}))})},[h,t,n,F,M]);qr(()=>{d===!1&&C.current.isPositioned&&(C.current.isPositioned=!1,u(N=>({...N,isPositioned:!1})))},[d]);const D=m.useRef(!1);qr(()=>(D.current=!0,()=>{D.current=!1}),[]),qr(()=>{if(b&&(R.current=b),j&&(I.current=j),b&&j){if(O.current)return O.current(b,j,U);U()}},[b,j,U,O,E]);const H=m.useMemo(()=>({reference:R,floating:I,setReference:_,setFloating:w}),[_,w]),z=m.useMemo(()=>({reference:b,floating:j}),[b,j]),A=m.useMemo(()=>{const N={position:n,left:0,top:0};if(!z.floating)return N;const Z=dc(z.floating,f.x),te=dc(z.floating,f.y);return c?{...N,transform:"translate("+Z+"px, "+te+"px)",...dd(z.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:Z,top:te}},[n,c,z.floating,f.x,f.y]);return m.useMemo(()=>({...f,update:U,refs:H,elements:z,floatingStyles:A}),[f,U,H,z,A])}const ub=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?lc({element:r.current,padding:o}).fn(n):{}:r?lc({element:r,padding:o}).fn(n):{}}}},fb=(e,t)=>({...tb(e),options:[e,t]}),mb=(e,t)=>({...nb(e),options:[e,t]}),pb=(e,t)=>({...ab(e),options:[e,t]}),hb=(e,t)=>({...rb(e),options:[e,t]}),gb=(e,t)=>({...sb(e),options:[e,t]}),xb=(e,t)=>({...ob(e),options:[e,t]}),vb=(e,t)=>({...ub(e),options:[e,t]});var yb="Arrow",ud=m.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...a}=e;return s.jsx(pe.svg,{...a,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:s.jsx("polygon",{points:"0,0 30,0 15,10"})})});ud.displayName=yb;var bb=ud;function wb(e){const[t,n]=m.useState(void 0);return qe(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const a=o[0];let i,c;if("borderBoxSize"in a){const l=a.borderBoxSize,d=Array.isArray(l)?l[0]:l;i=d.inlineSize,c=d.blockSize}else i=e.offsetWidth,c=e.offsetHeight;n({width:i,height:c})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var ya="Popper",[fd,md]=un(ya),[_b,pd]=fd(ya),hd=e=>{const{__scopePopper:t,children:n}=e,[r,o]=m.useState(null);return s.jsx(_b,{scope:t,anchor:r,onAnchorChange:o,children:n})};hd.displayName=ya;var gd="PopperAnchor",xd=m.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,a=pd(gd,n),i=m.useRef(null),c=Ce(t,i),l=m.useRef(null);return m.useEffect(()=>{const d=l.current;l.current=r?.current||i.current,d!==l.current&&a.onAnchorChange(l.current)}),r?null:s.jsx(pe.div,{...o,ref:c})});xd.displayName=gd;var ba="PopperContent",[kb,jb]=fd(ba),vd=m.forwardRef((e,t)=>{const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:a="center",alignOffset:i=0,arrowPadding:c=0,avoidCollisions:l=!0,collisionBoundary:d=[],collisionPadding:f=0,sticky:u="partial",hideWhenDetached:h=!1,updatePositionStrategy:g="optimized",onPlaced:y,...x}=e,p=pd(ba,n),[v,_]=m.useState(null),w=Ce(t,P=>_(P)),[b,j]=m.useState(null),R=wb(b),I=R?.width??0,C=R?.height??0,E=r+(a!=="center"?"-"+a:""),O=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},F=Array.isArray(d)?d:[d],M=F.length>0,U={padding:O,boundary:F.filter(Cb),altBoundary:M},{refs:D,floatingStyles:H,placement:z,isPositioned:A,middlewareData:N}=db({strategy:"fixed",placement:E,whileElementsMounted:(...P)=>eb(...P,{animationFrame:g==="always"}),elements:{reference:p.anchor},middleware:[fb({mainAxis:o+C,alignmentAxis:i}),l&&mb({mainAxis:!0,crossAxis:!1,limiter:u==="partial"?pb():void 0,...U}),l&&hb({...U}),gb({...U,apply:({elements:P,rects:G,availableWidth:ue,availableHeight:B})=>{const{width:ae,height:ce}=G.reference,we=P.floating.style;we.setProperty("--radix-popper-available-width",`${ue}px`),we.setProperty("--radix-popper-available-height",`${B}px`),we.setProperty("--radix-popper-anchor-width",`${ae}px`),we.setProperty("--radix-popper-anchor-height",`${ce}px`)}}),b&&vb({element:b,padding:c}),Nb({arrowWidth:I,arrowHeight:C}),h&&xb({strategy:"referenceHidden",...U})]}),[Z,te]=wd(z),re=sn(y);qe(()=>{A&&re?.()},[A,re]);const de=N.arrow?.x,W=N.arrow?.y,Q=N.arrow?.centerOffset!==0,[q,he]=m.useState();return qe(()=>{v&&he(window.getComputedStyle(v).zIndex)},[v]),s.jsx("div",{ref:D.setFloating,"data-radix-popper-content-wrapper":"",style:{...H,transform:A?H.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:q,"--radix-popper-transform-origin":[N.transformOrigin?.x,N.transformOrigin?.y].join(" "),...N.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:s.jsx(kb,{scope:n,placedSide:Z,onArrowChange:j,arrowX:de,arrowY:W,shouldHideArrow:Q,children:s.jsx(pe.div,{"data-side":Z,"data-align":te,...x,ref:w,style:{...x.style,animation:A?void 0:"none"}})})})});vd.displayName=ba;var yd="PopperArrow",Sb={top:"bottom",right:"left",bottom:"top",left:"right"},bd=m.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,a=jb(yd,r),i=Sb[a.placedSide];return s.jsx("span",{ref:a.onArrowChange,style:{position:"absolute",left:a.arrowX,top:a.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[a.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[a.placedSide],visibility:a.shouldHideArrow?"hidden":void 0},children:s.jsx(bb,{...o,ref:n,style:{...o.style,display:"block"}})})});bd.displayName=yd;function Cb(e){return e!==null}var Nb=e=>({name:"transformOrigin",options:e,fn(t){const{placement:n,rects:r,middlewareData:o}=t,i=o.arrow?.centerOffset!==0,c=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[d,f]=wd(n),u={start:"0%",center:"50%",end:"100%"}[f],h=(o.arrow?.x??0)+c/2,g=(o.arrow?.y??0)+l/2;let y="",x="";return d==="bottom"?(y=i?u:`${h}px`,x=`${-l}px`):d==="top"?(y=i?u:`${h}px`,x=`${r.floating.height+l}px`):d==="right"?(y=`${-l}px`,x=i?u:`${g}px`):d==="left"&&(y=`${r.floating.width+l}px`,x=i?u:`${g}px`),{data:{x:y,y:x}}}});function wd(e){const[t,n="center"]=e.split("-");return[t,n]}var Ab=hd,Eb=xd,Ib=vd,Tb=bd,Pb="Portal",wa=m.forwardRef((e,t)=>{const{container:n,...r}=e,[o,a]=m.useState(!1);qe(()=>a(!0),[]);const i=n||o&&globalThis?.document?.body;return i?Zo.createPortal(s.jsx(pe.div,{...r,ref:t}),i):null});wa.displayName=Pb;function Rb(e){const t=Ob(e),n=m.forwardRef((r,o)=>{const{children:a,...i}=r,c=m.Children.toArray(a),l=c.find(Lb);if(l){const d=l.props.children,f=c.map(u=>u===l?m.Children.count(d)>1?m.Children.only(null):m.isValidElement(d)?d.props.children:null:u);return s.jsx(t,{...i,ref:o,children:m.isValidElement(d)?m.cloneElement(d,void 0,f):null})}return s.jsx(t,{...i,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}function Ob(e){const t=m.forwardRef((n,r)=>{const{children:o,...a}=n;if(m.isValidElement(o)){const i=$b(o),c=Db(a,o.props);return o.type!==m.Fragment&&(c.ref=r?Hn(r,i):i),m.cloneElement(o,c)}return m.Children.count(o)>1?m.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Mb=Symbol("radix.slottable");function Lb(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Mb}function Db(e,t){const n={...t};for(const r in t){const o=e[r],a=t[r];/^on[A-Z]/.test(r)?o&&a?n[r]=(...c)=>{const l=a(...c);return o(...c),l}:o&&(n[r]=o):r==="style"?n[r]={...o,...a}:r==="className"&&(n[r]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function $b(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var zb=m[" useInsertionEffect ".trim().toString()]||qe;function cn({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,a,i]=Fb({defaultProp:t,onChange:n}),c=e!==void 0,l=c?e:o;{const f=m.useRef(e!==void 0);m.useEffect(()=>{const u=f.current;u!==c&&console.warn(`${r} is changing from ${u?"controlled":"uncontrolled"} to ${c?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),f.current=c},[c,r])}const d=m.useCallback(f=>{if(c){const u=Ub(f)?f(e):f;u!==e&&i.current?.(u)}else a(f)},[c,e,a,i]);return[l,d]}function Fb({defaultProp:e,onChange:t}){const[n,r]=m.useState(e),o=m.useRef(n),a=m.useRef(t);return zb(()=>{a.current=t},[t]),m.useEffect(()=>{o.current!==n&&(a.current?.(n),o.current=n)},[n,o]),[n,r,a]}function Ub(e){return typeof e=="function"}function Bb(e){const t=m.useRef({value:e,previous:e});return m.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var _d=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),Vb="VisuallyHidden",Wb=m.forwardRef((e,t)=>s.jsx(pe.span,{...e,ref:t,style:{..._d,...e.style}}));Wb.displayName=Vb;var Hb=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Rn=new WeakMap,Dr=new WeakMap,$r={},co=0,kd=function(e){return e&&(e.host||kd(e.parentNode))},Zb=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=kd(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},qb=function(e,t,n,r){var o=Zb(t,Array.isArray(e)?e:[e]);$r[n]||($r[n]=new WeakMap);var a=$r[n],i=[],c=new Set,l=new Set(o),d=function(u){!u||c.has(u)||(c.add(u),d(u.parentNode))};o.forEach(d);var f=function(u){!u||l.has(u)||Array.prototype.forEach.call(u.children,function(h){if(c.has(h))f(h);else try{var g=h.getAttribute(r),y=g!==null&&g!=="false",x=(Rn.get(h)||0)+1,p=(a.get(h)||0)+1;Rn.set(h,x),a.set(h,p),i.push(h),x===1&&y&&Dr.set(h,!0),p===1&&h.setAttribute(n,"true"),y||h.setAttribute(r,"true")}catch(v){console.error("aria-hidden: cannot operate on ",h,v)}})};return f(t),c.clear(),co++,function(){i.forEach(function(u){var h=Rn.get(u)-1,g=a.get(u)-1;Rn.set(u,h),a.set(u,g),h||(Dr.has(u)||u.removeAttribute(r),Dr.delete(u)),g||u.removeAttribute(n)}),co--,co||(Rn=new WeakMap,Rn=new WeakMap,Dr=new WeakMap,$r={})}},jd=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=Hb(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),qb(r,o,n,"aria-hidden")):function(){return null}},zt=function(){return zt=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},zt.apply(this,arguments)};function Sd(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function Gb(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,a;r<o;r++)(a||!(r in t))&&(a||(a=Array.prototype.slice.call(t,0,r)),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var Gr="right-scroll-bar-position",Yr="width-before-scroll-bar",Yb="with-scroll-bars-hidden",Qb="--removed-body-scroll-bar-size";function lo(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Kb(e,t){var n=k.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var Jb=typeof window<"u"?m.useLayoutEffect:m.useEffect,uc=new WeakMap;function Xb(e,t){var n=Kb(null,function(r){return e.forEach(function(o){return lo(o,r)})});return Jb(function(){var r=uc.get(n);if(r){var o=new Set(r),a=new Set(e),i=n.current;o.forEach(function(c){a.has(c)||lo(c,null)}),a.forEach(function(c){o.has(c)||lo(c,i)})}uc.set(n,e)},[e]),n}function ew(e){return e}function tw(e,t){t===void 0&&(t=ew);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(a){var i=t(a,r);return n.push(i),function(){n=n.filter(function(c){return c!==i})}},assignSyncMedium:function(a){for(r=!0;n.length;){var i=n;n=[],i.forEach(a)}n={push:function(c){return a(c)},filter:function(){return n}}},assignMedium:function(a){r=!0;var i=[];if(n.length){var c=n;n=[],c.forEach(a),i=n}var l=function(){var f=i;i=[],f.forEach(a)},d=function(){return Promise.resolve().then(l)};d(),n={push:function(f){i.push(f),d()},filter:function(f){return i=i.filter(f),n}}}};return o}function nw(e){e===void 0&&(e={});var t=tw(null);return t.options=zt({async:!0,ssr:!1},e),t}var Cd=function(e){var t=e.sideCar,n=Sd(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return m.createElement(r,zt({},n))};Cd.isSideCarExport=!0;function rw(e,t){return e.useMedium(t),Cd}var Nd=nw(),uo=function(){},Ss=m.forwardRef(function(e,t){var n=m.useRef(null),r=m.useState({onScrollCapture:uo,onWheelCapture:uo,onTouchMoveCapture:uo}),o=r[0],a=r[1],i=e.forwardProps,c=e.children,l=e.className,d=e.removeScrollBar,f=e.enabled,u=e.shards,h=e.sideCar,g=e.noRelative,y=e.noIsolation,x=e.inert,p=e.allowPinchZoom,v=e.as,_=v===void 0?"div":v,w=e.gapMode,b=Sd(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),j=h,R=Xb([n,t]),I=zt(zt({},b),o);return m.createElement(m.Fragment,null,f&&m.createElement(j,{sideCar:Nd,removeScrollBar:d,shards:u,noRelative:g,noIsolation:y,inert:x,setCallbacks:a,allowPinchZoom:!!p,lockRef:n,gapMode:w}),i?m.cloneElement(m.Children.only(c),zt(zt({},I),{ref:R})):m.createElement(_,zt({},I,{className:l,ref:R}),c))});Ss.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Ss.classNames={fullWidth:Yr,zeroRight:Gr};var sw=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function ow(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=sw();return t&&e.setAttribute("nonce",t),e}function aw(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function iw(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var cw=function(){var e=0,t=null;return{add:function(n){e==0&&(t=ow())&&(aw(t,n),iw(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},lw=function(){var e=cw();return function(t,n){m.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Ad=function(){var e=lw(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},dw={left:0,top:0,right:0,gap:0},fo=function(e){return parseInt(e||"",10)||0},uw=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[fo(n),fo(r),fo(o)]},fw=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return dw;var t=uw(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},mw=Ad(),zn="data-scroll-locked",pw=function(e,t,n,r){var o=e.left,a=e.top,i=e.right,c=e.gap;return n===void 0&&(n="margin"),`
|
|
40
|
-
.`.concat(
|
|
39
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const i of e.seen.entries()){const c=i[1];if(t===i[0]){a(i);continue}if(e.external){const d=e.external.registry.get(i[0])?.id;if(t!==i[0]&&d){a(i);continue}}if(e.metadataRegistry.get(i[0])?.id){a(i);continue}if(c.cycle){a(i);continue}if(c.count>1&&e.reused==="ref"){a(i);continue}}}function pl(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=i=>{const c=e.seen.get(i);if(c.ref===null)return;const l=c.def??c.schema,d={...l},f=c.ref;if(c.ref=null,f){r(f);const h=e.seen.get(f),g=h.schema;if(g.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(l.allOf=l.allOf??[],l.allOf.push(g)):Object.assign(l,g),Object.assign(l,d),i._zod.parent===f)for(const x in l)x==="$ref"||x==="allOf"||x in d||delete l[x];if(g.$ref&&h.def)for(const x in l)x==="$ref"||x==="allOf"||x in h.def&&JSON.stringify(l[x])===JSON.stringify(h.def[x])&&delete l[x]}const u=i._zod.parent;if(u&&u!==f){r(u);const h=e.seen.get(u);if(h?.schema.$ref&&(l.$ref=h.schema.$ref,h.def))for(const g in l)g==="$ref"||g==="allOf"||g in h.def&&JSON.stringify(l[g])===JSON.stringify(h.def[g])&&delete l[g]}e.override({zodSchema:i,jsonSchema:l,path:c.path??[]})};for(const i of[...e.seen.entries()].reverse())r(i[0]);const o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const i=e.external.registry.get(t)?.id;if(!i)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(i)}Object.assign(o,n.def??n.schema);const a=e.external?.defs??{};for(const i of e.seen.entries()){const c=i[1];c.def&&c.defId&&(a[c.defId]=c.def)}e.external||Object.keys(a).length>0&&(e.target==="draft-2020-12"?o.$defs=a:o.definitions=a);try{const i=JSON.parse(JSON.stringify(o));return Object.defineProperty(i,"~standard",{value:{...t["~standard"],jsonSchema:{input:ts(t,"input",e.processors),output:ts(t,"output",e.processors)}},enumerable:!1,writable:!1}),i}catch{throw new Error("Error converting schema to JSON.")}}function nt(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return nt(r.element,n);if(r.type==="set")return nt(r.valueType,n);if(r.type==="lazy")return nt(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return nt(r.innerType,n);if(r.type==="intersection")return nt(r.left,n)||nt(r.right,n);if(r.type==="record"||r.type==="map")return nt(r.keyType,n)||nt(r.valueType,n);if(r.type==="pipe")return nt(r.in,n)||nt(r.out,n);if(r.type==="object"){for(const o in r.shape)if(nt(r.shape[o],n))return!0;return!1}if(r.type==="union"){for(const o of r.options)if(nt(o,n))return!0;return!1}if(r.type==="tuple"){for(const o of r.items)if(nt(o,n))return!0;return!!(r.rest&&nt(r.rest,n))}return!1}const Ag=(e,t={})=>n=>{const r=fl({...n,processors:t});return Ze(e,r),ml(r,e),pl(r,e)},ts=(e,t,n={})=>r=>{const{libraryOptions:o,target:a}=r??{},i=fl({...o??{},target:a,io:t,processors:n});return Ze(e,i),ml(i,e),pl(i,e)},Eg={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Ig=(e,t,n,r)=>{const o=n;o.type="string";const{minimum:a,maximum:i,format:c,patterns:l,contentEncoding:d}=e._zod.bag;if(typeof a=="number"&&(o.minLength=a),typeof i=="number"&&(o.maxLength=i),c&&(o.format=Eg[c]??c,o.format===""&&delete o.format,c==="time"&&delete o.format),d&&(o.contentEncoding=d),l&&l.size>0){const f=[...l];f.length===1?o.pattern=f[0].source:f.length>1&&(o.allOf=[...f.map(u=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:u.source}))])}},Tg=(e,t,n,r)=>{const o=n,{minimum:a,maximum:i,format:c,multipleOf:l,exclusiveMaximum:d,exclusiveMinimum:f}=e._zod.bag;typeof c=="string"&&c.includes("int")?o.type="integer":o.type="number",typeof f=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.minimum=f,o.exclusiveMinimum=!0):o.exclusiveMinimum=f),typeof a=="number"&&(o.minimum=a,typeof f=="number"&&t.target!=="draft-04"&&(f>=a?delete o.minimum:delete o.exclusiveMinimum)),typeof d=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.maximum=d,o.exclusiveMaximum=!0):o.exclusiveMaximum=d),typeof i=="number"&&(o.maximum=i,typeof d=="number"&&t.target!=="draft-04"&&(d<=i?delete o.maximum:delete o.exclusiveMaximum)),typeof l=="number"&&(o.multipleOf=l)},Pg=(e,t,n,r)=>{n.not={}},Rg=(e,t,n,r)=>{},Og=(e,t,n,r)=>{const o=e._zod.def,a=Zc(o.entries);a.every(i=>typeof i=="number")&&(n.type="number"),a.every(i=>typeof i=="string")&&(n.type="string"),n.enum=a},Mg=(e,t,n,r)=>{const o=e._zod.def,a=[];for(const i of o.values)if(i===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof i=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");a.push(Number(i))}else a.push(i);if(a.length!==0)if(a.length===1){const i=a[0];n.type=i===null?"null":typeof i,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[i]:n.const=i}else a.every(i=>typeof i=="number")&&(n.type="number"),a.every(i=>typeof i=="string")&&(n.type="string"),a.every(i=>typeof i=="boolean")&&(n.type="boolean"),a.every(i=>i===null)&&(n.type="null"),n.enum=a},Lg=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Dg=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},$g=(e,t,n,r)=>{const o=n,a=e._zod.def,{minimum:i,maximum:c}=e._zod.bag;typeof i=="number"&&(o.minItems=i),typeof c=="number"&&(o.maxItems=c),o.type="array",o.items=Ze(a.element,t,{...r,path:[...r.path,"items"]})},zg=(e,t,n,r)=>{const o=n,a=e._zod.def;o.type="object",o.properties={};const i=a.shape;for(const d in i)o.properties[d]=Ze(i[d],t,{...r,path:[...r.path,"properties",d]});const c=new Set(Object.keys(i)),l=new Set([...c].filter(d=>{const f=a.shape[d]._zod;return t.io==="input"?f.optin===void 0:f.optout===void 0}));l.size>0&&(o.required=Array.from(l)),a.catchall?._zod.def.type==="never"?o.additionalProperties=!1:a.catchall?a.catchall&&(o.additionalProperties=Ze(a.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},Fg=(e,t,n,r)=>{const o=e._zod.def,a=o.inclusive===!1,i=o.options.map((c,l)=>Ze(c,t,{...r,path:[...r.path,a?"oneOf":"anyOf",l]}));a?n.oneOf=i:n.anyOf=i},Ug=(e,t,n,r)=>{const o=e._zod.def,a=Ze(o.left,t,{...r,path:[...r.path,"allOf",0]}),i=Ze(o.right,t,{...r,path:[...r.path,"allOf",1]}),c=d=>"allOf"in d&&Object.keys(d).length===1,l=[...c(a)?a.allOf:[a],...c(i)?i.allOf:[i]];n.allOf=l},Bg=(e,t,n,r)=>{const o=e._zod.def,a=Ze(o.innerType,t,r),i=t.seen.get(e);t.target==="openapi-3.0"?(i.ref=o.innerType,n.nullable=!0):n.anyOf=[a,{type:"null"}]},Vg=(e,t,n,r)=>{const o=e._zod.def;Ze(o.innerType,t,r);const a=t.seen.get(e);a.ref=o.innerType},Wg=(e,t,n,r)=>{const o=e._zod.def;Ze(o.innerType,t,r);const a=t.seen.get(e);a.ref=o.innerType,n.default=JSON.parse(JSON.stringify(o.defaultValue))},Hg=(e,t,n,r)=>{const o=e._zod.def;Ze(o.innerType,t,r);const a=t.seen.get(e);a.ref=o.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},Zg=(e,t,n,r)=>{const o=e._zod.def;Ze(o.innerType,t,r);const a=t.seen.get(e);a.ref=o.innerType;let i;try{i=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=i},qg=(e,t,n,r)=>{const o=e._zod.def,a=t.io==="input"?o.in._zod.def.type==="transform"?o.out:o.in:o.out;Ze(a,t,r);const i=t.seen.get(e);i.ref=a},Gg=(e,t,n,r)=>{const o=e._zod.def;Ze(o.innerType,t,r);const a=t.seen.get(e);a.ref=o.innerType,n.readOnly=!0},hl=(e,t,n,r)=>{const o=e._zod.def;Ze(o.innerType,t,r);const a=t.seen.get(e);a.ref=o.innerType},Yg=$("ZodISODateTime",(e,t)=>{th.init(e,t),Ie.init(e,t)});function Qg(e){return og(Yg,e)}const Kg=$("ZodISODate",(e,t)=>{nh.init(e,t),Ie.init(e,t)});function Jg(e){return ag(Kg,e)}const Xg=$("ZodISOTime",(e,t)=>{rh.init(e,t),Ie.init(e,t)});function ex(e){return ig(Xg,e)}const tx=$("ZodISODuration",(e,t)=>{sh.init(e,t),Ie.init(e,t)});function nx(e){return cg(tx,e)}const rx=(e,t)=>{Kc.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>Gm(e,n)},flatten:{value:n=>qm(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,ko,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,ko,2)}},isEmpty:{get(){return e.issues.length===0}}})},wt=$("ZodError",rx,{Parent:Error}),sx=Xo(wt),ox=ea(wt),ax=hs(wt),ix=gs(wt),cx=Km(wt),lx=Jm(wt),dx=Xm(wt),ux=ep(wt),fx=tp(wt),mx=np(wt),px=rp(wt),hx=sp(wt),Me=$("ZodType",(e,t)=>(Oe.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:ts(e,"input"),output:ts(e,"output")}}),e.toJSONSchema=Ag(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(ln(t,{checks:[...t.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0}),e.with=e.check,e.clone=(n,r)=>dn(e,n,r),e.brand=()=>e,e.register=((n,r)=>(n.add(e,r),e)),e.parse=(n,r)=>sx(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>ax(e,n,r),e.parseAsync=async(n,r)=>ox(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>ix(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>cx(e,n,r),e.decode=(n,r)=>lx(e,n,r),e.encodeAsync=async(n,r)=>dx(e,n,r),e.decodeAsync=async(n,r)=>ux(e,n,r),e.safeEncode=(n,r)=>fx(e,n,r),e.safeDecode=(n,r)=>mx(e,n,r),e.safeEncodeAsync=async(n,r)=>px(e,n,r),e.safeDecodeAsync=async(n,r)=>hx(e,n,r),e.refine=(n,r)=>e.check(uv(n,r)),e.superRefine=n=>e.check(fv(n)),e.overwrite=n=>e.check(Vn(n)),e.optional=()=>Ti(e),e.exactOptional=()=>Jx(e),e.nullable=()=>Pi(e),e.nullish=()=>Ti(Pi(e)),e.nonoptional=n=>sv(e,n),e.array=()=>Fx(e),e.or=n=>Vx([e,n]),e.and=n=>Hx(e,n),e.transform=n=>Ri(e,Qx(n)),e.default=n=>tv(e,n),e.prefault=n=>rv(e,n),e.catch=n=>av(e,n),e.pipe=n=>Ri(e,n),e.readonly=()=>lv(e),e.describe=n=>{const r=e.clone();return ir.add(r,{description:n}),r},Object.defineProperty(e,"description",{get(){return ir.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return ir.get(e);const r=e.clone();return ir.add(r,n[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),gl=$("_ZodString",(e,t)=>{ta.init(e,t),Me.init(e,t),e._zod.processJSONSchema=(r,o,a)=>Ig(e,r,o);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...r)=>e.check(mg(...r)),e.includes=(...r)=>e.check(gg(...r)),e.startsWith=(...r)=>e.check(xg(...r)),e.endsWith=(...r)=>e.check(vg(...r)),e.min=(...r)=>e.check(es(...r)),e.max=(...r)=>e.check(dl(...r)),e.length=(...r)=>e.check(ul(...r)),e.nonempty=(...r)=>e.check(es(1,...r)),e.lowercase=r=>e.check(pg(r)),e.uppercase=r=>e.check(hg(r)),e.trim=()=>e.check(bg()),e.normalize=(...r)=>e.check(yg(...r)),e.toLowerCase=()=>e.check(wg()),e.toUpperCase=()=>e.check(_g()),e.slugify=()=>e.check(kg())}),gx=$("ZodString",(e,t)=>{ta.init(e,t),gl.init(e,t),e.email=n=>e.check($h(xx,n)),e.url=n=>e.check(Vh(vx,n)),e.jwt=n=>e.check(sg(Rx,n)),e.emoji=n=>e.check(Wh(yx,n)),e.guid=n=>e.check(ji(Ai,n)),e.uuid=n=>e.check(zh(Pr,n)),e.uuidv4=n=>e.check(Fh(Pr,n)),e.uuidv6=n=>e.check(Uh(Pr,n)),e.uuidv7=n=>e.check(Bh(Pr,n)),e.nanoid=n=>e.check(Hh(bx,n)),e.guid=n=>e.check(ji(Ai,n)),e.cuid=n=>e.check(Zh(wx,n)),e.cuid2=n=>e.check(qh(_x,n)),e.ulid=n=>e.check(Gh(kx,n)),e.base64=n=>e.check(tg(Ix,n)),e.base64url=n=>e.check(ng(Tx,n)),e.xid=n=>e.check(Yh(jx,n)),e.ksuid=n=>e.check(Qh(Sx,n)),e.ipv4=n=>e.check(Kh(Cx,n)),e.ipv6=n=>e.check(Jh(Nx,n)),e.cidrv4=n=>e.check(Xh(Ax,n)),e.cidrv6=n=>e.check(eg(Ex,n)),e.e164=n=>e.check(rg(Px,n)),e.datetime=n=>e.check(Qg(n)),e.date=n=>e.check(Jg(n)),e.time=n=>e.check(ex(n)),e.duration=n=>e.check(nx(n))});function rt(e){return Dh(gx,e)}const Ie=$("ZodStringFormat",(e,t)=>{Ne.init(e,t),gl.init(e,t)}),xx=$("ZodEmail",(e,t)=>{Zp.init(e,t),Ie.init(e,t)}),Ai=$("ZodGUID",(e,t)=>{Wp.init(e,t),Ie.init(e,t)}),Pr=$("ZodUUID",(e,t)=>{Hp.init(e,t),Ie.init(e,t)}),vx=$("ZodURL",(e,t)=>{qp.init(e,t),Ie.init(e,t)}),yx=$("ZodEmoji",(e,t)=>{Gp.init(e,t),Ie.init(e,t)}),bx=$("ZodNanoID",(e,t)=>{Yp.init(e,t),Ie.init(e,t)}),wx=$("ZodCUID",(e,t)=>{Qp.init(e,t),Ie.init(e,t)}),_x=$("ZodCUID2",(e,t)=>{Kp.init(e,t),Ie.init(e,t)}),kx=$("ZodULID",(e,t)=>{Jp.init(e,t),Ie.init(e,t)}),jx=$("ZodXID",(e,t)=>{Xp.init(e,t),Ie.init(e,t)}),Sx=$("ZodKSUID",(e,t)=>{eh.init(e,t),Ie.init(e,t)}),Cx=$("ZodIPv4",(e,t)=>{oh.init(e,t),Ie.init(e,t)}),Nx=$("ZodIPv6",(e,t)=>{ah.init(e,t),Ie.init(e,t)}),Ax=$("ZodCIDRv4",(e,t)=>{ih.init(e,t),Ie.init(e,t)}),Ex=$("ZodCIDRv6",(e,t)=>{ch.init(e,t),Ie.init(e,t)}),Ix=$("ZodBase64",(e,t)=>{lh.init(e,t),Ie.init(e,t)}),Tx=$("ZodBase64URL",(e,t)=>{uh.init(e,t),Ie.init(e,t)}),Px=$("ZodE164",(e,t)=>{fh.init(e,t),Ie.init(e,t)}),Rx=$("ZodJWT",(e,t)=>{ph.init(e,t),Ie.init(e,t)}),xl=$("ZodNumber",(e,t)=>{al.init(e,t),Me.init(e,t),e._zod.processJSONSchema=(r,o,a)=>Tg(e,r,o),e.gt=(r,o)=>e.check(Ci(r,o)),e.gte=(r,o)=>e.check(Xs(r,o)),e.min=(r,o)=>e.check(Xs(r,o)),e.lt=(r,o)=>e.check(Si(r,o)),e.lte=(r,o)=>e.check(Js(r,o)),e.max=(r,o)=>e.check(Js(r,o)),e.int=r=>e.check(Ei(r)),e.safe=r=>e.check(Ei(r)),e.positive=r=>e.check(Ci(0,r)),e.nonnegative=r=>e.check(Xs(0,r)),e.negative=r=>e.check(Si(0,r)),e.nonpositive=r=>e.check(Js(0,r)),e.multipleOf=(r,o)=>e.check(Ni(r,o)),e.step=(r,o)=>e.check(Ni(r,o)),e.finite=()=>e;const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function Ox(e){return lg(xl,e)}const Mx=$("ZodNumberFormat",(e,t)=>{hh.init(e,t),xl.init(e,t)});function Ei(e){return dg(Mx,e)}const Lx=$("ZodUnknown",(e,t)=>{gh.init(e,t),Me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Rg()});function Ii(){return ug(Lx)}const Dx=$("ZodNever",(e,t)=>{xh.init(e,t),Me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Pg(e,n,r)});function $x(e){return fg(Dx,e)}const zx=$("ZodArray",(e,t)=>{vh.init(e,t),Me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>$g(e,n,r,o),e.element=t.element,e.min=(n,r)=>e.check(es(n,r)),e.nonempty=n=>e.check(es(1,n)),e.max=(n,r)=>e.check(dl(n,r)),e.length=(n,r)=>e.check(ul(n,r)),e.unwrap=()=>e.element});function Fx(e,t){return jg(zx,e,t)}const Ux=$("ZodObject",(e,t)=>{bh.init(e,t),Me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>zg(e,n,r,o),be(e,"shape",()=>t.shape),e.keyof=()=>Zx(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Ii()}),e.loose=()=>e.clone({...e._zod.def,catchall:Ii()}),e.strict=()=>e.clone({...e._zod.def,catchall:$x()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>Bm(e,n),e.safeExtend=n=>Vm(e,n),e.merge=n=>Wm(e,n),e.pick=n=>Fm(e,n),e.omit=n=>Um(e,n),e.partial=(...n)=>Hm(yl,e,n[0]),e.required=(...n)=>Zm(bl,e,n[0])});function vl(e,t){const n={type:"object",shape:e??{},...ie(t)};return new Ux(n)}const Bx=$("ZodUnion",(e,t)=>{wh.init(e,t),Me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Fg(e,n,r,o),e.options=t.options});function Vx(e,t){return new Bx({type:"union",options:e,...ie(t)})}const Wx=$("ZodIntersection",(e,t)=>{_h.init(e,t),Me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ug(e,n,r,o)});function Hx(e,t){return new Wx({type:"intersection",left:e,right:t})}const So=$("ZodEnum",(e,t)=>{kh.init(e,t),Me.init(e,t),e._zod.processJSONSchema=(r,o,a)=>Og(e,r,o),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,o)=>{const a={};for(const i of r)if(n.has(i))a[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new So({...t,checks:[],...ie(o),entries:a})},e.exclude=(r,o)=>{const a={...t.entries};for(const i of r)if(n.has(i))delete a[i];else throw new Error(`Key ${i} not found in enum`);return new So({...t,checks:[],...ie(o),entries:a})}});function Zx(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new So({type:"enum",entries:n,...ie(t)})}const qx=$("ZodLiteral",(e,t)=>{jh.init(e,t),Me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Mg(e,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Gx(e,t){return new qx({type:"literal",values:Array.isArray(e)?e:[e],...ie(t)})}const Yx=$("ZodTransform",(e,t)=>{Sh.init(e,t),Me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Dg(e,n),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Wc(e.constructor.name);n.addIssue=a=>{if(typeof a=="string")n.issues.push(pr(a,n.value,t));else{const i=a;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=e),n.issues.push(pr(i))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(a=>(n.value=a,n)):(n.value=o,n)}});function Qx(e){return new Yx({type:"transform",transform:e})}const yl=$("ZodOptional",(e,t)=>{ll.init(e,t),Me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>hl(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Ti(e){return new yl({type:"optional",innerType:e})}const Kx=$("ZodExactOptional",(e,t)=>{Ch.init(e,t),Me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>hl(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Jx(e){return new Kx({type:"optional",innerType:e})}const Xx=$("ZodNullable",(e,t)=>{Nh.init(e,t),Me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Bg(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Pi(e){return new Xx({type:"nullable",innerType:e})}const ev=$("ZodDefault",(e,t)=>{Ah.init(e,t),Me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Wg(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function tv(e,t){return new ev({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Gc(t)}})}const nv=$("ZodPrefault",(e,t)=>{Eh.init(e,t),Me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Hg(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function rv(e,t){return new nv({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Gc(t)}})}const bl=$("ZodNonOptional",(e,t)=>{Ih.init(e,t),Me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Vg(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function sv(e,t){return new bl({type:"nonoptional",innerType:e,...ie(t)})}const ov=$("ZodCatch",(e,t)=>{Th.init(e,t),Me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Zg(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function av(e,t){return new ov({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const iv=$("ZodPipe",(e,t)=>{Ph.init(e,t),Me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>qg(e,n,r,o),e.in=t.in,e.out=t.out});function Ri(e,t){return new iv({type:"pipe",in:e,out:t})}const cv=$("ZodReadonly",(e,t)=>{Rh.init(e,t),Me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Gg(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function lv(e){return new cv({type:"readonly",innerType:e})}const dv=$("ZodCustom",(e,t)=>{Oh.init(e,t),Me.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Lg(e,n)});function uv(e,t={}){return Sg(dv,e,t)}function fv(e){return Cg(e)}const Rr=vl({line1:rt().min(1,"Address line 1 is required"),line2:rt().optional(),city:rt().min(1,"City is required"),state:rt().optional(),postalCode:rt().min(1,"Postal code is required"),country:rt().min(2,"Country is required")});function mv(e){return vl({email:e.requireEmail?rt().email("Valid email required"):rt().email("Valid email required").or(Gx("")).optional(),name:e.requireName?rt().min(1,"Name is required"):rt().optional(),phone:e.requirePhone?rt().min(6,"Phone is required"):rt().optional(),notes:rt().max(500).optional(),shippingAddress:e.requireShippingAddress?Rr:Rr.optional(),billingAddress:e.requireBillingAddress?Rr:Rr.optional(),discountCode:rt().optional(),tipAmount:Ox().min(0).optional(),shippingMethodId:rt().optional()})}const Oi={none:0,optional:1,required:2};function eo(e,t){return Oi[e]>=Oi[t]?e:t}function pv(e){if(!e)return null;try{const t=JSON.parse(e);return!t||typeof t!="object"?null:t}catch{return null}}function Zr(e,t){let n=!1,r=!1;const o=new Set;let a=t.requireEmail?"required":"none",i=t.defaultMode==="none"?"none":"optional",c=t.defaultMode==="full"?"optional":"none",l=t.allowShipping&&(t.defaultMode==="shipping"||t.defaultMode==="full"),d=t.defaultMode==="full";for(const u of e){u.metadata?.shippingProfile==="digital"?n=!0:r=!0;const g=pv(u.metadata?.checkoutRequirements);g&&(g.email&&(a=eo(a,g.email)),g.name&&(i=eo(i,g.name)),g.phone&&(c=eo(c,g.phone)),typeof g.shippingAddress=="boolean"&&(l=l||g.shippingAddress),typeof g.billingAddress=="boolean"&&(d=d||g.billingAddress));const y=u.metadata?.fulfillmentNotes;y&&o.add(y)}const f=n&&!r;return f&&(l=!1),{email:a,name:i,phone:c,shippingAddress:l,billingAddress:d,fulfillmentNotes:Array.from(o).join(" "),isDigitalOnly:f,hasPhysical:r}}const wl=k.createContext(null);function _l(){const{config:e}=Ee(),t=Pt(),n=k.useMemo(()=>({line1:"",line2:"",city:"",state:"",postalCode:"",country:"US"}),[]),r=k.useMemo(()=>{const w=Zr(t.items,{requireEmail:e.checkout.requireEmail??!0,defaultMode:e.checkout.mode,allowShipping:e.checkout.allowShipping??!1});return mv({requireEmail:w.email==="required",requireName:w.name==="required",requirePhone:w.phone==="required",requireShippingAddress:w.shippingAddress,requireBillingAddress:w.billingAddress})},[t.items,e.checkout.allowShipping,e.checkout.mode,e.checkout.requireEmail]),[o,a]=k.useState(()=>({email:e.checkout.requireEmail??!0?"":void 0,name:"",phone:"",notes:"",shippingAddress:e.checkout.mode==="shipping"||e.checkout.mode==="full"?n:void 0,billingAddress:e.checkout.mode==="full"?n:void 0,discountCode:"",tipAmount:0,shippingMethodId:""}));k.useEffect(()=>{const w=Zr(t.items,{requireEmail:e.checkout.requireEmail??!0,defaultMode:e.checkout.mode,allowShipping:e.checkout.allowShipping??!1});a(b=>{const j={...b};return w.email==="required"&&!j.email&&(j.email=""),w.shippingAddress&&!j.shippingAddress&&(j.shippingAddress=n),w.billingAddress&&!j.billingAddress&&(j.billingAddress=n),w.shippingAddress||(j.shippingAddress=void 0),w.billingAddress||(j.billingAddress=void 0),j})},[t.items,e.checkout.allowShipping,e.checkout.mode,e.checkout.requireEmail,n]);const i=k.useRef(!1),[c,l]=k.useState({}),[d,f]=k.useState("idle"),[u,h]=k.useState(null),[g,y]=k.useState(null),x=k.useCallback(()=>{l({}),f("idle"),h(null),y(null)},[]),p=k.useCallback((w,b)=>{a(j=>({...j,[w]:b}))},[]),v=k.useCallback(()=>{f("validating"),h(null);const w=r.safeParse(o);if(w.success)return l({}),f("idle"),{ok:!0,values:w.data};const b={};for(const j of w.error.issues)b[j.path.join(".")]=j.message;return l(b),f("error"),h("Please fix the highlighted fields."),{ok:!1}},[r,o]),_=k.useCallback(async w=>{if(i.current)return{ok:!1};const b=v();if(!b.ok)return{ok:!1};i.current=!0,f("creating_session"),h(null),y(null);const j=t.items.map(E=>({resource:E.paymentResource??E.productId,quantity:E.qty,variantId:E.variantId})),R=Zr(t.items,{requireEmail:e.checkout.requireEmail??!0,defaultMode:e.checkout.mode,allowShipping:e.checkout.allowShipping??!1}),I=new Set;if(R.shippingAddress)for(const E of t.items){const O=E.metadata?.shippingCountries;if(O)for(const F of O.split(",")){const M=F.trim().toUpperCase();M&&I.add(M)}}const C={...I.size?{shippingCountries:Array.from(I).join(","),shipping_countries:Array.from(I).join(",")}:{}};try{const E=await e.adapter.createCheckoutSession({cart:j,customer:{email:b.values.email||void 0,name:b.values.name||void 0,phone:b.values.phone||void 0,notes:b.values.notes||void 0,shippingAddress:b.values.shippingAddress,billingAddress:b.values.billingAddress},options:{currency:e.currency,successUrl:e.checkout.successUrl,cancelUrl:e.checkout.cancelUrl,allowPromoCodes:e.checkout.allowPromoCodes,metadata:Object.keys(C).length?C:void 0,discountCode:(e.checkout.allowPromoCodes?b.values.discountCode||t.promoCode:void 0)||void 0,tipAmount:e.checkout.allowTipping&&b.values.tipAmount||void 0,shippingMethodId:e.checkout.allowShipping&&b.values.shippingMethodId||void 0,paymentMethodId:w?.paymentMethodId}});return E.kind==="redirect"?(y(E),f("redirecting"),typeof window<"u"&&window.location.assign(E.url),{ok:!0,session:E}):(y(E),f("success"),{ok:!0,session:E})}catch(E){return f("error"),h(E instanceof Error?E.message:"Checkout failed"),{ok:!1}}finally{i.current=!1}},[t.items,t.promoCode,e.adapter,e.checkout,e.currency,v]);return{values:o,setValues:a,setField:p,fieldErrors:c,status:d,error:u,session:g,reset:x,validate:v,createCheckoutSession:_}}function kl({children:e}){const t=_l();return s.jsx(wl.Provider,{value:t,children:e})}function vs(){const e=k.useContext(wl);if(!e)throw new Error("useCheckout must be used within CheckoutProvider");return e}function hv(){return _l()}function na(){const{config:e}=Ee(),[t,n]=m.useState([]),[r,o]=m.useState(!0),[a,i]=m.useState(null);return m.useEffect(()=>{let c=!1;return o(!0),i(null),e.adapter.listCategories().then(l=>{c||n(l)}).catch(l=>{c||i(l instanceof Error?l.message:"Failed to load categories")}).finally(()=>{c||o(!1)}),()=>{c=!0}},[e.adapter]),{categories:t,isLoading:r,error:a}}function ys(e){const{config:t}=Ee(),[n,r]=m.useState(null),[o,a]=m.useState(!0),[i,c]=m.useState(null),l=m.useMemo(()=>JSON.stringify(e.filters??{}),[e.filters]);return m.useEffect(()=>{let d=!1;return a(!0),c(null),t.adapter.listProducts(e).then(f=>{d||r(f)}).catch(f=>{d||c(f instanceof Error?f.message:"Failed to load products")}).finally(()=>{d||a(!1)}),()=>{d=!0}},[t.adapter,e.category,e.search,e.sort,e.page,e.pageSize,l]),{data:n,isLoading:o,error:i}}function jl(e){const{config:t}=Ee(),[n,r]=m.useState(null),[o,a]=m.useState(!0),[i,c]=m.useState(null);return m.useEffect(()=>{let l=!1;return a(!0),c(null),t.adapter.getProductBySlug(e).then(d=>{l||r(d)}).catch(d=>{l||c(d instanceof Error?d.message:"Failed to load product")}).finally(()=>{l||a(!1)}),()=>{l=!0}},[t.adapter,e]),{product:n,isLoading:o,error:i}}function Sl(){const{config:e}=Ee(),[t,n]=m.useState([]),[r,o]=m.useState(!0),[a,i]=m.useState(null);return m.useEffect(()=>{let c=!1;return o(!0),i(null),e.adapter.getOrderHistory().then(l=>{c||n(l)}).catch(l=>{c||i(l instanceof Error?l.message:"Failed to load orders")}).finally(()=>{c||o(!1)}),()=>{c=!0}},[e.adapter]),{orders:t,isLoading:r,error:a}}function Cl(){const{config:e}=Ee(),[t,n]=m.useState([]),[r,o]=m.useState(null),[a,i]=m.useState(!0),[c,l]=m.useState(null);return m.useEffect(()=>{let d=!1;async function f(){i(!0),l(null);try{const[u,h]=await Promise.all([e.adapter.listSubscriptionTiers?.()??Promise.resolve([]),e.adapter.getSubscriptionStatus?.()??Promise.resolve(null)]);if(d)return;n(u),o(h)}catch(u){if(d)return;l(u instanceof Error?u.message:"Failed to load subscriptions")}finally{d||i(!1)}}return f(),()=>{d=!0}},[e.adapter]),{tiers:t,status:r,isLoading:a,error:c}}function Nl({enabled:e,customer:t}){const{config:n}=Ee(),[r,o]=m.useState([]),[a,i]=m.useState(!1),[c,l]=m.useState(null),d=JSON.stringify(t.shippingAddress??{});return m.useEffect(()=>{let f=!1;if(!e||!n.adapter.getShippingMethods){o([]);return}return i(!0),l(null),n.adapter.getShippingMethods({currency:n.currency,customer:t}).then(u=>{f||o(u)}).catch(u=>{f||l(u instanceof Error?u.message:"Failed to load shipping methods")}).finally(()=>{f||i(!1)}),()=>{f=!0}},[n.adapter,n.currency,e,t.email,t.name,d]),{methods:r,isLoading:a,error:c}}function Xn(e,...t){for(const n of t){const r=e[n];if(r)return r}}function ra(e){const t=Xn(e,"error","error_message","message");if(t)return{kind:"error",message:t};const n=Xn(e,"canceled","cancelled","cancel","canceled_at");if(n&&n!=="0"&&n!=="false")return{kind:"cancel"};const r=Xn(e,"orderId","order_id","demoOrderId"),o=Xn(e,"session_id","checkout_session_id");if(r||o)return{kind:"success",orderId:r??o};const a=(Xn(e,"status","checkout")??"").toLowerCase();return a==="success"?{kind:"success",orderId:r}:a==="cancel"||a==="canceled"?{kind:"cancel"}:a==="error"?{kind:"error"}:{kind:"idle"}}function gv(e){const t={};return e.forEach((n,r)=>{t[r]=n}),t}function sa(){const{config:e}=Ee(),[t,n]=m.useState({kind:"idle"});return m.useEffect(()=>{if(typeof window>"u")return;const r=new URLSearchParams(window.location.search),o=gv(r);(async()=>{try{const a=e.adapter.resolveCheckoutReturn?await e.adapter.resolveCheckoutReturn({query:o}):ra(o);if(a.kind==="success"&&a.orderId&&e.adapter.getOrderById){const i=await e.adapter.getOrderById(a.orderId);if(i){n({kind:"success",orderId:a.orderId,order:i});return}}n(a)}catch(a){n({kind:"error",message:a instanceof Error?a.message:"Failed to resolve checkout"})}})()},[e.adapter]),t}function Co(e){if(!e)return;const t=Number(e);return Number.isFinite(t)?t:void 0}function xv(e){const t=e.get("tags"),n=t?t.split(",").map(c=>c.trim()).filter(Boolean):void 0,r=Co(e.get("min")),o=Co(e.get("max")),a=e.get("inStock"),i=a==="1"?!0:a==="0"?!1:void 0;return{tags:n&&n.length?n:void 0,priceMin:r,priceMax:o,inStock:i}}function vv(e,t){t.tags?.length?e.set("tags",t.tags.join(",")):e.delete("tags"),typeof t.priceMin=="number"?e.set("min",String(t.priceMin)):e.delete("min"),typeof t.priceMax=="number"?e.set("max",String(t.priceMax)):e.delete("max"),typeof t.inStock=="boolean"?e.set("inStock",t.inStock?"1":"0"):e.delete("inStock")}function oa({includeCategory:e}){if(typeof window>"u")return null;const t=new URLSearchParams(window.location.search),n=t.get("q")??"",r=t.get("sort")??"featured",o=Co(t.get("page"))??1,a=xv(t),i=e?t.get("cat")??void 0:void 0;return{search:n,sort:r,page:Math.max(1,Math.floor(o)),category:i,filters:a}}function aa(e,{includeCategory:t}){const n=e.filters.tags?.join(",")??"";m.useEffect(()=>{if(typeof window>"u")return;const r=window.setTimeout(()=>{const o=new URL(window.location.href),a=o.searchParams;e.search.trim()?a.set("q",e.search.trim()):a.delete("q"),e.sort&&e.sort!=="featured"?a.set("sort",e.sort):a.delete("sort"),e.page&&e.page!==1?a.set("page",String(e.page)):a.delete("page"),t&&(e.category?a.set("cat",e.category):a.delete("cat")),vv(a,e.filters);const i=`${o.pathname}?${a.toString()}${o.hash}`,c=`${window.location.pathname}${window.location.search}${window.location.hash}`;i!==c&&window.history.replaceState({},"",i)},250);return()=>window.clearTimeout(r)},[t,e.category,e.page,e.search,e.sort,n,e.filters.priceMin,e.filters.priceMax,e.filters.inStock])}function Mi(e,t){return`${e}::${t??""}`}function yv(e,t){if(t&&e.variants?.length){const n=e.variants.find(r=>r.id===t);if(n)return{qty:n.inventoryQuantity,status:n.inventoryStatus}}return{qty:e.inventoryQuantity,status:e.inventoryStatus}}function bv(e,t){const n={productId:e.productId,variantId:e.variantId,isOutOfStock:!1,exceedsAvailable:!1,isLowStock:!1};if(!t)return{...n,isOutOfStock:!0,message:"This product is no longer available"};const{qty:r,status:o}=yv(t,e.variantId);return n.availableQty=r,n.status=o,o==="out_of_stock"||typeof r=="number"&&r<=0?{...n,isOutOfStock:!0,message:"Out of stock"}:typeof r=="number"&&e.qty>r?{...n,exceedsAvailable:!0,message:r===0?"Out of stock":`Only ${r} available (you have ${e.qty} in cart)`}:o==="low"||typeof r=="number"&&r>0&&r<=5?{...n,isLowStock:!0,message:typeof r=="number"?`Only ${r} left`:"Low stock"}:n}function ia({items:e,refreshInterval:t=3e4,skip:n=!1}){const{config:r}=Ee(),[o,a]=m.useState(new Map),[i,c]=m.useState(!1),[l,d]=m.useState(null),f=m.useRef(e);f.current=e;const u=m.useMemo(()=>{const v=new Set;for(const _ of e)v.add(_.productId);return v},[e]),h=m.useMemo(()=>Array.from(u).sort().join(","),[u]),g=m.useMemo(()=>Array.from(u),[u]),y=m.useCallback(async()=>{if(n||g.length===0){a(new Map);return}c(!0),d(null);try{let v=new Map;if(r.adapter.getProductsByIds)v=await r.adapter.getProductsByIds(g);else{const w=await Promise.all(g.map(async b=>{try{return await r.adapter.getProductBySlug(b)}catch{return null}}));v=new Map;for(const b of w)b&&(v.set(b.id,b),b.slug&&b.slug!==b.id&&v.set(b.slug,b))}const _=new Map;for(const w of f.current){const b=Mi(w.productId,w.variantId),j=v.get(w.productId)??null;_.set(b,bv(w,j))}a(_)}catch(v){d(v instanceof Error?v.message:"Failed to check inventory")}finally{c(!1)}},[r.adapter,h,n]);m.useEffect(()=>{y()},[y]),m.useEffect(()=>{if(n||t<=0||g.length===0)return;const v=setInterval(y,t);return()=>clearInterval(v)},[y,g.length,t,n]);const x=m.useCallback((v,_)=>o.get(Mi(v,_)),[o]),p=m.useMemo(()=>{for(const v of o.values())if(v.isOutOfStock||v.exceedsAvailable)return!0;return!1},[o]);return{inventory:o,isLoading:i,error:l,refresh:y,getItemInventory:x,hasIssues:p}}function wv(e,t){if(t&&e.variants?.length){const n=e.variants.find(r=>r.id===t);if(n)return{qty:n.inventoryQuantity,status:n.inventoryStatus}}return{qty:e.inventoryQuantity,status:e.inventoryStatus}}function _v(e,t,n){if(!t)return e.titleSnapshot??"Unknown Product";const r=t.title??e.titleSnapshot??"Product";if(n&&t.variants?.length){const o=t.variants.find(a=>a.id===n);if(o?.title)return`${r} - ${o.title}`}return r}function kv(e,t){const n=_v(e,t,e.variantId);if(!t)return{productId:e.productId,variantId:e.variantId,title:n,requestedQty:e.qty,availableQty:0,type:"product_unavailable",message:"This product is no longer available"};const{qty:r,status:o}=wv(t,e.variantId);return o==="out_of_stock"||typeof r=="number"&&r<=0?{productId:e.productId,variantId:e.variantId,title:n,requestedQty:e.qty,availableQty:0,type:"out_of_stock",message:"This item is out of stock"}:typeof r=="number"&&e.qty>r?{productId:e.productId,variantId:e.variantId,title:n,requestedQty:e.qty,availableQty:r,type:"insufficient_stock",message:r===0?"This item is out of stock":`Only ${r} available`}:null}function Al({items:e}){const{config:t}=Ee(),[n,r]=m.useState(null),[o,a]=m.useState(!1),[i,c]=m.useState(null),l=m.useMemo(()=>{const u=new Set;for(const h of e)u.add(h.productId);return Array.from(u)},[e]),d=m.useCallback(async()=>{if(e.length===0){const u={ok:!0,issues:[],verifiedAt:new Date};return r(u),u}a(!0),c(null);try{let u=new Map;if(t.adapter.getProductsByIds)u=await t.adapter.getProductsByIds(l);else{const y=await Promise.all(l.map(async x=>{try{return await t.adapter.getProductBySlug(x)}catch{return null}}));u=new Map;for(const x of y)x&&(u.set(x.id,x),x.slug&&x.slug!==x.id&&u.set(x.slug,x))}const h=[];for(const y of e){const x=u.get(y.productId)??null,p=kv(y,x);p&&h.push(p)}const g={ok:h.length===0,issues:h,verifiedAt:new Date};return r(g),a(!1),g}catch(u){const h=u instanceof Error?u.message:"Failed to verify inventory";c(h),a(!1);const g={ok:!1,issues:[],verifiedAt:new Date};return r(g),g}},[t.adapter,e,l]),f=m.useCallback(()=>{r(null),c(null)},[]);return{result:n,isVerifying:o,error:i,verify:d,reset:f}}function jv({items:e,onExpiry:t,enabled:n=!0}){const[r,o]=m.useState([]),[a,i]=m.useState([]),c=m.useRef(new Set),l=m.useRef(t);l.current=t;const d=m.useMemo(()=>n?e.filter(f=>f.holdId&&f.holdExpiresAt):[],[e,n]);return m.useEffect(()=>{if(!n||d.length===0){o([]),i([]);return}const f=()=>{const h=Date.now(),g=120*1e3,y=[],x=[];for(const p of d){if(!p.holdExpiresAt)continue;const v=new Date(p.holdExpiresAt),_=v.getTime()-h,w=`${p.productId}::${p.variantId??""}`;_<=0?(y.push({productId:p.productId,variantId:p.variantId}),c.current.has(w)||(c.current.add(w),l.current?.({productId:p.productId,variantId:p.variantId,title:p.titleSnapshot,expiredAt:v}))):_<=g&&x.push({productId:p.productId,variantId:p.variantId,expiresAt:v,remainingMs:_})}o(y),i(x)};f();const u=setInterval(f,1e4);return()=>clearInterval(u)},[n,d]),m.useEffect(()=>{const f=new Set(d.map(u=>`${u.productId}::${u.variantId??""}`));for(const u of c.current)f.has(u)||c.current.delete(u)},[d]),{expiringItems:a,expiredItems:r}}const ke={relatedProducts:{mode:"most_recent",maxItems:4,layout:{layout:"large",imageCrop:"center"}},catalog:{filters:{tags:!0,priceRange:!0,inStock:!0},sort:{featured:!0,priceAsc:!0,priceDesc:!0}},checkout:{promoCodes:!0},shopLayout:{layout:"large",imageCrop:"center"},categoryLayout:{layout:"large",imageCrop:"center"},sections:{showDescription:!0,showSpecs:!0,showShipping:!0,showRelatedProducts:!0},inventory:{preCheckoutVerification:!0,holdsEnabled:!1,holdDurationMinutes:15},shopPage:{title:"Shop",description:""}};function Sv(e){return{relatedProducts:{mode:e.relatedProducts?.mode||ke.relatedProducts.mode,maxItems:e.relatedProducts?.maxItems||ke.relatedProducts.maxItems,layout:{layout:e.relatedProducts?.layout?.layout??ke.relatedProducts.layout.layout,imageCrop:e.relatedProducts?.layout?.imageCrop??ke.relatedProducts.layout.imageCrop}},catalog:{filters:{tags:e.catalog?.filters?.tags??ke.catalog.filters.tags,priceRange:e.catalog?.filters?.priceRange??ke.catalog.filters.priceRange,inStock:e.catalog?.filters?.inStock??ke.catalog.filters.inStock},sort:{featured:e.catalog?.sort?.featured??ke.catalog.sort.featured,priceAsc:e.catalog?.sort?.priceAsc??ke.catalog.sort.priceAsc,priceDesc:e.catalog?.sort?.priceDesc??ke.catalog.sort.priceDesc}},checkout:{promoCodes:e.checkout?.promoCodes??ke.checkout.promoCodes},shopLayout:{layout:e.shopLayout?.layout??ke.shopLayout.layout,imageCrop:e.shopLayout?.imageCrop??ke.shopLayout.imageCrop},categoryLayout:{layout:e.categoryLayout?.layout??ke.categoryLayout.layout,imageCrop:e.categoryLayout?.imageCrop??ke.categoryLayout.imageCrop},sections:{showDescription:e.sections?.showDescription??ke.sections.showDescription,showSpecs:e.sections?.showSpecs??ke.sections.showSpecs,showShipping:e.sections?.showShipping??ke.sections.showShipping,showRelatedProducts:e.sections?.showRelatedProducts??ke.sections.showRelatedProducts},inventory:{preCheckoutVerification:e.inventory?.preCheckoutVerification??ke.inventory.preCheckoutVerification,holdsEnabled:e.inventory?.holdsEnabled??ke.inventory.holdsEnabled,holdDurationMinutes:e.inventory?.holdDurationMinutes??ke.inventory.holdDurationMinutes},shopPage:{title:e.shopPage?.title??ke.shopPage.title,description:e.shopPage?.description??ke.shopPage.description}}}function Wn(e={}){const n=Go()?.config?.adapter,[r,o]=k.useState(ke),[a,i]=k.useState(!!n?.getStorefrontSettings);return k.useEffect(()=>{if(!n?.getStorefrontSettings){i(!1);return}let c=!1;async function l(){try{const d=await n.getStorefrontSettings();!c&&d&&o(Sv(d))}catch{}finally{c||i(!1)}}return l(),()=>{c=!0}},[n]),{settings:r,isLoading:a}}const Cv={card:!0,crypto:!0,credits:!1};function El(){const t=Go()?.config?.adapter,[n,r]=k.useState(Cv),[o,a]=k.useState(!!t?.getPaymentMethodsConfig);return k.useEffect(()=>{if(!t?.getPaymentMethodsConfig){a(!1);return}let i=!1;async function c(){try{const l=await t.getPaymentMethodsConfig();!i&&l&&r(l)}catch{}finally{i||a(!1)}}return c(),()=>{i=!0}},[t]),{config:n,isLoading:o}}const Nv=50,er=new Map;function Av(e){return e.productId?`id:${e.productId}`:e.name?`name:${e.name}`:""}function Il(e={}){const{productId:t,product:n,enabled:r=!0}=e,a=Go()?.config?.adapter,[i,c]=k.useState(null),[l,d]=k.useState(null),[f,u]=k.useState(!1),[h,g]=k.useState(null),y=k.useRef(0),x=k.useCallback(async()=>{const p=t?{productId:t}:n?{name:n.name,description:n.description,tags:n.tags,categoryIds:n.categoryIds}:{};if(!p.productId&&!p.name)return;if(!a?.getAIRelatedProducts){g("AI recommendations not available");return}const v=Av(p),_=er.get(v);if(_){c(_.relatedProductIds),d(_.reasoning),g(null);return}const w=++y.current;u(!0),g(null);try{const b=await a.getAIRelatedProducts(p);if(w===y.current&&(c(b.relatedProductIds),d(b.reasoning),g(null),v)){if(er.size>=Nv){const j=er.keys().next().value;j!==void 0&&er.delete(j)}er.set(v,b)}}catch(b){if(w===y.current){const j=b instanceof Error?b.message:"Failed to get AI recommendations";g(j),c(null),d(null)}}finally{w===y.current&&u(!1)}},[a,t,n]);return k.useEffect(()=>{r&&(!t&&!n?.name||x())},[r,t,n?.name,x]),{relatedProductIds:i,reasoning:l,isLoading:f,error:h,refetch:x}}function Ae(e,t){if(!e)throw new Error(t)}function St(e){return typeof e=="string"&&e.trim().length>0}async function Ev(e,t={}){const n=t.pageSize??10,r=await e.listCategories();Ae(Array.isArray(r),"listCategories() must return an array");for(const i of r)Ae(St(i.id),"Category.id is required"),Ae(St(i.slug),"Category.slug is required"),Ae(St(i.name),"Category.name is required");const o=await e.listProducts({page:1,pageSize:n});if(Ae(o&&Array.isArray(o.items),"listProducts() must return { items: Product[] }"),Ae(typeof o.page=="number","listProducts().page must be a number"),Ae(typeof o.pageSize=="number","listProducts().pageSize must be a number"),o.items.length>0){const i=o.items[0];Ae(St(i.id),"Product.id is required"),Ae(St(i.slug),"Product.slug is required"),Ae(St(i.title),"Product.title is required"),Ae(typeof i.description=="string","Product.description must be a string"),Ae(Array.isArray(i.images),"Product.images must be an array"),Ae(typeof i.price=="number","Product.price must be a number"),Ae(St(i.currency),"Product.currency is required"),Ae(Array.isArray(i.tags),"Product.tags must be an array"),Ae(Array.isArray(i.categoryIds),"Product.categoryIds must be an array");const c=await e.getProductBySlug(i.slug);Ae(c===null||St(c.id),"getProductBySlug() must return Product or null")}const a=await e.getOrderHistory();Ae(Array.isArray(a),"getOrderHistory() must return an array");for(const i of a)Ae(St(i.id),"Order.id is required"),Ae(St(i.createdAt),"Order.createdAt is required"),Ae(typeof i.total=="number","Order.total must be a number"),Ae(St(i.currency),"Order.currency is required"),Ae(Array.isArray(i.items),"Order.items must be an array")}function Li(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Hn(...e){return t=>{let n=!1;const r=e.map(o=>{const a=Li(o,t);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let o=0;o<r.length;o++){const a=r[o];typeof a=="function"?a():Li(e[o],null)}}}}function Ce(...e){return m.useCallback(Hn(...e),e)}var Iv=Symbol.for("react.lazy"),ns=m[" use ".trim().toString()];function Tv(e){return typeof e=="object"&&e!==null&&"then"in e}function Tl(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===Iv&&"_payload"in e&&Tv(e._payload)}function Pl(e){const t=Rv(e),n=m.forwardRef((r,o)=>{let{children:a,...i}=r;Tl(a)&&typeof ns=="function"&&(a=ns(a._payload));const c=m.Children.toArray(a),l=c.find(Mv);if(l){const d=l.props.children,f=c.map(u=>u===l?m.Children.count(d)>1?m.Children.only(null):m.isValidElement(d)?d.props.children:null:u);return s.jsx(t,{...i,ref:o,children:m.isValidElement(d)?m.cloneElement(d,void 0,f):null})}return s.jsx(t,{...i,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}var Pv=Pl("Slot");function Rv(e){const t=m.forwardRef((n,r)=>{let{children:o,...a}=n;if(Tl(o)&&typeof ns=="function"&&(o=ns(o._payload)),m.isValidElement(o)){const i=Dv(o),c=Lv(a,o.props);return o.type!==m.Fragment&&(c.ref=r?Hn(r,i):i),m.cloneElement(o,c)}return m.Children.count(o)>1?m.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Ov=Symbol("radix.slottable");function Mv(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Ov}function Lv(e,t){const n={...t};for(const r in t){const o=e[r],a=t[r];/^on[A-Z]/.test(r)?o&&a?n[r]=(...c)=>{const l=a(...c);return o(...c),l}:o&&(n[r]=o):r==="style"?n[r]={...o,...a}:r==="className"&&(n[r]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function Dv(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function Rl(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(n=Rl(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function Ol(){for(var e,t,n=0,r="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=Rl(e))&&(r&&(r+=" "),r+=t);return r}const Di=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,$i=Ol,ca=(e,t)=>n=>{var r;if(t?.variants==null)return $i(e,n?.class,n?.className);const{variants:o,defaultVariants:a}=t,i=Object.keys(o).map(d=>{const f=n?.[d],u=a?.[d];if(f===null)return null;const h=Di(f)||Di(u);return o[d][h]}),c=n&&Object.entries(n).reduce((d,f)=>{let[u,h]=f;return h===void 0||(d[u]=h),d},{}),l=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((d,f)=>{let{class:u,className:h,...g}=f;return Object.entries(g).every(y=>{let[x,p]=y;return Array.isArray(p)?p.includes({...a,...c}[x]):{...a,...c}[x]===p})?[...d,u,h]:d},[]);return $i(e,i,l,n?.class,n?.className)},$v=(e,t)=>{const n=new Array(e.length+t.length);for(let r=0;r<e.length;r++)n[r]=e[r];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},zv=(e,t)=>({classGroupId:e,validator:t}),Ml=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),rs="-",zi=[],Fv="arbitrary..",Uv=e=>{const t=Vv(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:i=>{if(i.startsWith("[")&&i.endsWith("]"))return Bv(i);const c=i.split(rs),l=c[0]===""&&c.length>1?1:0;return Ll(c,l,t)},getConflictingClassGroupIds:(i,c)=>{if(c){const l=r[i],d=n[i];return l?d?$v(d,l):l:d||zi}return n[i]||zi}}},Ll=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const o=e[t],a=n.nextPart.get(o);if(a){const d=Ll(e,t+1,a);if(d)return d}const i=n.validators;if(i===null)return;const c=t===0?e.join(rs):e.slice(t).join(rs),l=i.length;for(let d=0;d<l;d++){const f=i[d];if(f.validator(c))return f.classGroupId}},Bv=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),n=t.indexOf(":"),r=t.slice(0,n);return r?Fv+r:void 0})(),Vv=e=>{const{theme:t,classGroups:n}=e;return Wv(n,t)},Wv=(e,t)=>{const n=Ml();for(const r in e){const o=e[r];la(o,n,r,t)}return n},la=(e,t,n,r)=>{const o=e.length;for(let a=0;a<o;a++){const i=e[a];Hv(i,t,n,r)}},Hv=(e,t,n,r)=>{if(typeof e=="string"){Zv(e,t,n);return}if(typeof e=="function"){qv(e,t,n,r);return}Gv(e,t,n,r)},Zv=(e,t,n)=>{const r=e===""?t:Dl(t,e);r.classGroupId=n},qv=(e,t,n,r)=>{if(Yv(e)){la(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(zv(n,e))},Gv=(e,t,n,r)=>{const o=Object.entries(e),a=o.length;for(let i=0;i<a;i++){const[c,l]=o[i];la(l,Dl(t,c),n,r)}},Dl=(e,t)=>{let n=e;const r=t.split(rs),o=r.length;for(let a=0;a<o;a++){const i=r[a];let c=n.nextPart.get(i);c||(c=Ml(),n.nextPart.set(i,c)),n=c}return n},Yv=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,Qv=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null);const o=(a,i)=>{n[a]=i,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(a){let i=n[a];if(i!==void 0)return i;if((i=r[a])!==void 0)return o(a,i),i},set(a,i){a in n?n[a]=i:o(a,i)}}},No="!",Fi=":",Kv=[],Ui=(e,t,n,r,o)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:o}),Jv=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=o=>{const a=[];let i=0,c=0,l=0,d;const f=o.length;for(let x=0;x<f;x++){const p=o[x];if(i===0&&c===0){if(p===Fi){a.push(o.slice(l,x)),l=x+1;continue}if(p==="/"){d=x;continue}}p==="["?i++:p==="]"?i--:p==="("?c++:p===")"&&c--}const u=a.length===0?o:o.slice(l);let h=u,g=!1;u.endsWith(No)?(h=u.slice(0,-1),g=!0):u.startsWith(No)&&(h=u.slice(1),g=!0);const y=d&&d>l?d-l:void 0;return Ui(a,g,h,y)};if(t){const o=t+Fi,a=r;r=i=>i.startsWith(o)?a(i.slice(o.length)):Ui(Kv,!1,i,void 0,!0)}if(n){const o=r;r=a=>n({className:a,parseClassName:o})}return r},Xv=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((n,r)=>{t.set(n,1e6+r)}),n=>{const r=[];let o=[];for(let a=0;a<n.length;a++){const i=n[a],c=i[0]==="[",l=t.has(i);c||l?(o.length>0&&(o.sort(),r.push(...o),o=[]),r.push(i)):o.push(i)}return o.length>0&&(o.sort(),r.push(...o)),r}},ey=e=>({cache:Qv(e.cacheSize),parseClassName:Jv(e),sortModifiers:Xv(e),...Uv(e)}),ty=/\s+/,ny=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:o,sortModifiers:a}=t,i=[],c=e.trim().split(ty);let l="";for(let d=c.length-1;d>=0;d-=1){const f=c[d],{isExternal:u,modifiers:h,hasImportantModifier:g,baseClassName:y,maybePostfixModifierPosition:x}=n(f);if(u){l=f+(l.length>0?" "+l:l);continue}let p=!!x,v=r(p?y.substring(0,x):y);if(!v){if(!p){l=f+(l.length>0?" "+l:l);continue}if(v=r(y),!v){l=f+(l.length>0?" "+l:l);continue}p=!1}const _=h.length===0?"":h.length===1?h[0]:a(h).join(":"),w=g?_+No:_,b=w+v;if(i.indexOf(b)>-1)continue;i.push(b);const j=o(v,p);for(let R=0;R<j.length;++R){const I=j[R];i.push(w+I)}l=f+(l.length>0?" "+l:l)}return l},ry=(...e)=>{let t=0,n,r,o="";for(;t<e.length;)(n=e[t++])&&(r=$l(n))&&(o&&(o+=" "),o+=r);return o},$l=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=$l(e[r]))&&(n&&(n+=" "),n+=t);return n},sy=(e,...t)=>{let n,r,o,a;const i=l=>{const d=t.reduce((f,u)=>u(f),e());return n=ey(d),r=n.cache.get,o=n.cache.set,a=c,c(l)},c=l=>{const d=r(l);if(d)return d;const f=ny(l,n);return o(l,f),f};return a=i,(...l)=>a(ry(...l))},oy=[],Ue=e=>{const t=n=>n[e]||oy;return t.isThemeGetter=!0,t},zl=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Fl=/^\((?:(\w[\w-]*):)?(.+)\)$/i,ay=/^\d+\/\d+$/,iy=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,cy=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,ly=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,dy=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,uy=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Pn=e=>ay.test(e),fe=e=>!!e&&!Number.isNaN(Number(e)),nn=e=>!!e&&Number.isInteger(Number(e)),to=e=>e.endsWith("%")&&fe(e.slice(0,-1)),Qt=e=>iy.test(e),fy=()=>!0,my=e=>cy.test(e)&&!ly.test(e),Ul=()=>!1,py=e=>dy.test(e),hy=e=>uy.test(e),gy=e=>!J(e)&&!X(e),xy=e=>Zn(e,Wl,Ul),J=e=>zl.test(e),xn=e=>Zn(e,Hl,my),no=e=>Zn(e,_y,fe),Bi=e=>Zn(e,Bl,Ul),vy=e=>Zn(e,Vl,hy),Or=e=>Zn(e,Zl,py),X=e=>Fl.test(e),tr=e=>qn(e,Hl),yy=e=>qn(e,ky),Vi=e=>qn(e,Bl),by=e=>qn(e,Wl),wy=e=>qn(e,Vl),Mr=e=>qn(e,Zl,!0),Zn=(e,t,n)=>{const r=zl.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},qn=(e,t,n=!1)=>{const r=Fl.exec(e);return r?r[1]?t(r[1]):n:!1},Bl=e=>e==="position"||e==="percentage",Vl=e=>e==="image"||e==="url",Wl=e=>e==="length"||e==="size"||e==="bg-size",Hl=e=>e==="length",_y=e=>e==="number",ky=e=>e==="family-name",Zl=e=>e==="shadow",jy=()=>{const e=Ue("color"),t=Ue("font"),n=Ue("text"),r=Ue("font-weight"),o=Ue("tracking"),a=Ue("leading"),i=Ue("breakpoint"),c=Ue("container"),l=Ue("spacing"),d=Ue("radius"),f=Ue("shadow"),u=Ue("inset-shadow"),h=Ue("text-shadow"),g=Ue("drop-shadow"),y=Ue("blur"),x=Ue("perspective"),p=Ue("aspect"),v=Ue("ease"),_=Ue("animate"),w=()=>["auto","avoid","all","avoid-page","page","left","right","column"],b=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],j=()=>[...b(),X,J],R=()=>["auto","hidden","clip","visible","scroll"],I=()=>["auto","contain","none"],C=()=>[X,J,l],E=()=>[Pn,"full","auto",...C()],O=()=>[nn,"none","subgrid",X,J],F=()=>["auto",{span:["full",nn,X,J]},nn,X,J],M=()=>[nn,"auto",X,J],U=()=>["auto","min","max","fr",X,J],D=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],H=()=>["start","end","center","stretch","center-safe","end-safe"],z=()=>["auto",...C()],A=()=>[Pn,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...C()],N=()=>[e,X,J],Z=()=>[...b(),Vi,Bi,{position:[X,J]}],te=()=>["no-repeat",{repeat:["","x","y","space","round"]}],re=()=>["auto","cover","contain",by,xy,{size:[X,J]}],de=()=>[to,tr,xn],W=()=>["","none","full",d,X,J],Q=()=>["",fe,tr,xn],q=()=>["solid","dashed","dotted","double"],he=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],P=()=>[fe,to,Vi,Bi],G=()=>["","none",y,X,J],ue=()=>["none",fe,X,J],B=()=>["none",fe,X,J],ae=()=>[fe,X,J],ce=()=>[Pn,"full",...C()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Qt],breakpoint:[Qt],color:[fy],container:[Qt],"drop-shadow":[Qt],ease:["in","out","in-out"],font:[gy],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Qt],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Qt],shadow:[Qt],spacing:["px",fe],text:[Qt],"text-shadow":[Qt],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Pn,J,X,p]}],container:["container"],columns:[{columns:[fe,J,X,c]}],"break-after":[{"break-after":w()}],"break-before":[{"break-before":w()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:j()}],overflow:[{overflow:R()}],"overflow-x":[{"overflow-x":R()}],"overflow-y":[{"overflow-y":R()}],overscroll:[{overscroll:I()}],"overscroll-x":[{"overscroll-x":I()}],"overscroll-y":[{"overscroll-y":I()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:E()}],"inset-x":[{"inset-x":E()}],"inset-y":[{"inset-y":E()}],start:[{start:E()}],end:[{end:E()}],top:[{top:E()}],right:[{right:E()}],bottom:[{bottom:E()}],left:[{left:E()}],visibility:["visible","invisible","collapse"],z:[{z:[nn,"auto",X,J]}],basis:[{basis:[Pn,"full","auto",c,...C()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[fe,Pn,"auto","initial","none",J]}],grow:[{grow:["",fe,X,J]}],shrink:[{shrink:["",fe,X,J]}],order:[{order:[nn,"first","last","none",X,J]}],"grid-cols":[{"grid-cols":O()}],"col-start-end":[{col:F()}],"col-start":[{"col-start":M()}],"col-end":[{"col-end":M()}],"grid-rows":[{"grid-rows":O()}],"row-start-end":[{row:F()}],"row-start":[{"row-start":M()}],"row-end":[{"row-end":M()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":U()}],"auto-rows":[{"auto-rows":U()}],gap:[{gap:C()}],"gap-x":[{"gap-x":C()}],"gap-y":[{"gap-y":C()}],"justify-content":[{justify:[...D(),"normal"]}],"justify-items":[{"justify-items":[...H(),"normal"]}],"justify-self":[{"justify-self":["auto",...H()]}],"align-content":[{content:["normal",...D()]}],"align-items":[{items:[...H(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...H(),{baseline:["","last"]}]}],"place-content":[{"place-content":D()}],"place-items":[{"place-items":[...H(),"baseline"]}],"place-self":[{"place-self":["auto",...H()]}],p:[{p:C()}],px:[{px:C()}],py:[{py:C()}],ps:[{ps:C()}],pe:[{pe:C()}],pt:[{pt:C()}],pr:[{pr:C()}],pb:[{pb:C()}],pl:[{pl:C()}],m:[{m:z()}],mx:[{mx:z()}],my:[{my:z()}],ms:[{ms:z()}],me:[{me:z()}],mt:[{mt:z()}],mr:[{mr:z()}],mb:[{mb:z()}],ml:[{ml:z()}],"space-x":[{"space-x":C()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":C()}],"space-y-reverse":["space-y-reverse"],size:[{size:A()}],w:[{w:[c,"screen",...A()]}],"min-w":[{"min-w":[c,"screen","none",...A()]}],"max-w":[{"max-w":[c,"screen","none","prose",{screen:[i]},...A()]}],h:[{h:["screen","lh",...A()]}],"min-h":[{"min-h":["screen","lh","none",...A()]}],"max-h":[{"max-h":["screen","lh",...A()]}],"font-size":[{text:["base",n,tr,xn]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,X,no]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",to,J]}],"font-family":[{font:[yy,J,t]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[o,X,J]}],"line-clamp":[{"line-clamp":[fe,"none",X,no]}],leading:[{leading:[a,...C()]}],"list-image":[{"list-image":["none",X,J]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",X,J]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:N()}],"text-color":[{text:N()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...q(),"wavy"]}],"text-decoration-thickness":[{decoration:[fe,"from-font","auto",X,xn]}],"text-decoration-color":[{decoration:N()}],"underline-offset":[{"underline-offset":[fe,"auto",X,J]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:C()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",X,J]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",X,J]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:Z()}],"bg-repeat":[{bg:te()}],"bg-size":[{bg:re()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},nn,X,J],radial:["",X,J],conic:[nn,X,J]},wy,vy]}],"bg-color":[{bg:N()}],"gradient-from-pos":[{from:de()}],"gradient-via-pos":[{via:de()}],"gradient-to-pos":[{to:de()}],"gradient-from":[{from:N()}],"gradient-via":[{via:N()}],"gradient-to":[{to:N()}],rounded:[{rounded:W()}],"rounded-s":[{"rounded-s":W()}],"rounded-e":[{"rounded-e":W()}],"rounded-t":[{"rounded-t":W()}],"rounded-r":[{"rounded-r":W()}],"rounded-b":[{"rounded-b":W()}],"rounded-l":[{"rounded-l":W()}],"rounded-ss":[{"rounded-ss":W()}],"rounded-se":[{"rounded-se":W()}],"rounded-ee":[{"rounded-ee":W()}],"rounded-es":[{"rounded-es":W()}],"rounded-tl":[{"rounded-tl":W()}],"rounded-tr":[{"rounded-tr":W()}],"rounded-br":[{"rounded-br":W()}],"rounded-bl":[{"rounded-bl":W()}],"border-w":[{border:Q()}],"border-w-x":[{"border-x":Q()}],"border-w-y":[{"border-y":Q()}],"border-w-s":[{"border-s":Q()}],"border-w-e":[{"border-e":Q()}],"border-w-t":[{"border-t":Q()}],"border-w-r":[{"border-r":Q()}],"border-w-b":[{"border-b":Q()}],"border-w-l":[{"border-l":Q()}],"divide-x":[{"divide-x":Q()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":Q()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...q(),"hidden","none"]}],"divide-style":[{divide:[...q(),"hidden","none"]}],"border-color":[{border:N()}],"border-color-x":[{"border-x":N()}],"border-color-y":[{"border-y":N()}],"border-color-s":[{"border-s":N()}],"border-color-e":[{"border-e":N()}],"border-color-t":[{"border-t":N()}],"border-color-r":[{"border-r":N()}],"border-color-b":[{"border-b":N()}],"border-color-l":[{"border-l":N()}],"divide-color":[{divide:N()}],"outline-style":[{outline:[...q(),"none","hidden"]}],"outline-offset":[{"outline-offset":[fe,X,J]}],"outline-w":[{outline:["",fe,tr,xn]}],"outline-color":[{outline:N()}],shadow:[{shadow:["","none",f,Mr,Or]}],"shadow-color":[{shadow:N()}],"inset-shadow":[{"inset-shadow":["none",u,Mr,Or]}],"inset-shadow-color":[{"inset-shadow":N()}],"ring-w":[{ring:Q()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:N()}],"ring-offset-w":[{"ring-offset":[fe,xn]}],"ring-offset-color":[{"ring-offset":N()}],"inset-ring-w":[{"inset-ring":Q()}],"inset-ring-color":[{"inset-ring":N()}],"text-shadow":[{"text-shadow":["none",h,Mr,Or]}],"text-shadow-color":[{"text-shadow":N()}],opacity:[{opacity:[fe,X,J]}],"mix-blend":[{"mix-blend":[...he(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":he()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[fe]}],"mask-image-linear-from-pos":[{"mask-linear-from":P()}],"mask-image-linear-to-pos":[{"mask-linear-to":P()}],"mask-image-linear-from-color":[{"mask-linear-from":N()}],"mask-image-linear-to-color":[{"mask-linear-to":N()}],"mask-image-t-from-pos":[{"mask-t-from":P()}],"mask-image-t-to-pos":[{"mask-t-to":P()}],"mask-image-t-from-color":[{"mask-t-from":N()}],"mask-image-t-to-color":[{"mask-t-to":N()}],"mask-image-r-from-pos":[{"mask-r-from":P()}],"mask-image-r-to-pos":[{"mask-r-to":P()}],"mask-image-r-from-color":[{"mask-r-from":N()}],"mask-image-r-to-color":[{"mask-r-to":N()}],"mask-image-b-from-pos":[{"mask-b-from":P()}],"mask-image-b-to-pos":[{"mask-b-to":P()}],"mask-image-b-from-color":[{"mask-b-from":N()}],"mask-image-b-to-color":[{"mask-b-to":N()}],"mask-image-l-from-pos":[{"mask-l-from":P()}],"mask-image-l-to-pos":[{"mask-l-to":P()}],"mask-image-l-from-color":[{"mask-l-from":N()}],"mask-image-l-to-color":[{"mask-l-to":N()}],"mask-image-x-from-pos":[{"mask-x-from":P()}],"mask-image-x-to-pos":[{"mask-x-to":P()}],"mask-image-x-from-color":[{"mask-x-from":N()}],"mask-image-x-to-color":[{"mask-x-to":N()}],"mask-image-y-from-pos":[{"mask-y-from":P()}],"mask-image-y-to-pos":[{"mask-y-to":P()}],"mask-image-y-from-color":[{"mask-y-from":N()}],"mask-image-y-to-color":[{"mask-y-to":N()}],"mask-image-radial":[{"mask-radial":[X,J]}],"mask-image-radial-from-pos":[{"mask-radial-from":P()}],"mask-image-radial-to-pos":[{"mask-radial-to":P()}],"mask-image-radial-from-color":[{"mask-radial-from":N()}],"mask-image-radial-to-color":[{"mask-radial-to":N()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":b()}],"mask-image-conic-pos":[{"mask-conic":[fe]}],"mask-image-conic-from-pos":[{"mask-conic-from":P()}],"mask-image-conic-to-pos":[{"mask-conic-to":P()}],"mask-image-conic-from-color":[{"mask-conic-from":N()}],"mask-image-conic-to-color":[{"mask-conic-to":N()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:Z()}],"mask-repeat":[{mask:te()}],"mask-size":[{mask:re()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",X,J]}],filter:[{filter:["","none",X,J]}],blur:[{blur:G()}],brightness:[{brightness:[fe,X,J]}],contrast:[{contrast:[fe,X,J]}],"drop-shadow":[{"drop-shadow":["","none",g,Mr,Or]}],"drop-shadow-color":[{"drop-shadow":N()}],grayscale:[{grayscale:["",fe,X,J]}],"hue-rotate":[{"hue-rotate":[fe,X,J]}],invert:[{invert:["",fe,X,J]}],saturate:[{saturate:[fe,X,J]}],sepia:[{sepia:["",fe,X,J]}],"backdrop-filter":[{"backdrop-filter":["","none",X,J]}],"backdrop-blur":[{"backdrop-blur":G()}],"backdrop-brightness":[{"backdrop-brightness":[fe,X,J]}],"backdrop-contrast":[{"backdrop-contrast":[fe,X,J]}],"backdrop-grayscale":[{"backdrop-grayscale":["",fe,X,J]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[fe,X,J]}],"backdrop-invert":[{"backdrop-invert":["",fe,X,J]}],"backdrop-opacity":[{"backdrop-opacity":[fe,X,J]}],"backdrop-saturate":[{"backdrop-saturate":[fe,X,J]}],"backdrop-sepia":[{"backdrop-sepia":["",fe,X,J]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":C()}],"border-spacing-x":[{"border-spacing-x":C()}],"border-spacing-y":[{"border-spacing-y":C()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",X,J]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[fe,"initial",X,J]}],ease:[{ease:["linear","initial",v,X,J]}],delay:[{delay:[fe,X,J]}],animate:[{animate:["none",_,X,J]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[x,X,J]}],"perspective-origin":[{"perspective-origin":j()}],rotate:[{rotate:ue()}],"rotate-x":[{"rotate-x":ue()}],"rotate-y":[{"rotate-y":ue()}],"rotate-z":[{"rotate-z":ue()}],scale:[{scale:B()}],"scale-x":[{"scale-x":B()}],"scale-y":[{"scale-y":B()}],"scale-z":[{"scale-z":B()}],"scale-3d":["scale-3d"],skew:[{skew:ae()}],"skew-x":[{"skew-x":ae()}],"skew-y":[{"skew-y":ae()}],transform:[{transform:[X,J,"","none","gpu","cpu"]}],"transform-origin":[{origin:j()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ce()}],"translate-x":[{"translate-x":ce()}],"translate-y":[{"translate-y":ce()}],"translate-z":[{"translate-z":ce()}],"translate-none":["translate-none"],accent:[{accent:N()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:N()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",X,J]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":C()}],"scroll-mx":[{"scroll-mx":C()}],"scroll-my":[{"scroll-my":C()}],"scroll-ms":[{"scroll-ms":C()}],"scroll-me":[{"scroll-me":C()}],"scroll-mt":[{"scroll-mt":C()}],"scroll-mr":[{"scroll-mr":C()}],"scroll-mb":[{"scroll-mb":C()}],"scroll-ml":[{"scroll-ml":C()}],"scroll-p":[{"scroll-p":C()}],"scroll-px":[{"scroll-px":C()}],"scroll-py":[{"scroll-py":C()}],"scroll-ps":[{"scroll-ps":C()}],"scroll-pe":[{"scroll-pe":C()}],"scroll-pt":[{"scroll-pt":C()}],"scroll-pr":[{"scroll-pr":C()}],"scroll-pb":[{"scroll-pb":C()}],"scroll-pl":[{"scroll-pl":C()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",X,J]}],fill:[{fill:["none",...N()]}],"stroke-w":[{stroke:[fe,tr,xn,no]}],stroke:[{stroke:["none",...N()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},Sy=sy(jy);function L(...e){return Sy(Ol(e))}const Cy=ca("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-900/20 disabled:pointer-events-none disabled:opacity-50 dark:focus-visible:ring-neutral-50/20",{variants:{variant:{default:"bg-neutral-900 text-neutral-50 hover:bg-neutral-900/90 dark:bg-neutral-50 dark:text-neutral-900 dark:hover:bg-neutral-50/90",secondary:"bg-neutral-100 text-neutral-900 hover:bg-neutral-100/80 dark:bg-neutral-800 dark:text-neutral-50 dark:hover:bg-neutral-800/80",outline:"border border-neutral-200 bg-transparent text-neutral-900 hover:bg-neutral-100 dark:border-neutral-800 dark:text-neutral-50 dark:hover:bg-neutral-800",ghost:"bg-transparent text-neutral-900 hover:bg-neutral-100 dark:text-neutral-50 dark:hover:bg-neutral-800",destructive:"bg-red-600 text-neutral-50 hover:bg-red-600/90 dark:bg-red-500 dark:hover:bg-red-500/90",link:"bg-transparent text-neutral-900 underline-offset-4 hover:underline dark:text-neutral-50"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-6",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),ne=m.forwardRef(({className:e,variant:t,size:n,asChild:r,...o},a)=>{const i=r?Pv:"button";return s.jsx(i,{className:L(Cy({variant:t,size:n}),e),ref:a,...o})});ne.displayName="Button";const Ny=ca("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-medium transition-colors",{variants:{variant:{default:"border-transparent bg-neutral-900 text-neutral-50 dark:bg-neutral-50 dark:text-neutral-900",secondary:"border-transparent bg-neutral-100 text-neutral-900 dark:bg-neutral-800 dark:text-neutral-50",outline:"border-neutral-200 text-neutral-900 dark:border-neutral-800 dark:text-neutral-50"}},defaultVariants:{variant:"secondary"}});function vn({className:e,variant:t,...n}){return s.jsx("div",{className:L(Ny({variant:t}),e),...n})}const Et=m.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,className:L("rounded-xl border border-neutral-200 bg-white text-neutral-950 shadow-sm dark:border-neutral-800 dark:bg-neutral-950 dark:text-neutral-50",e),...t}));Et.displayName="Card";const hr=m.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,className:L("flex flex-col space-y-1.5 p-6",e),...t}));hr.displayName="CardHeader";const gr=m.forwardRef(({className:e,...t},n)=>s.jsx("h3",{ref:n,className:L("text-lg font-semibold leading-none tracking-tight",e),...t}));gr.displayName="CardTitle";const ql=m.forwardRef(({className:e,...t},n)=>s.jsx("p",{ref:n,className:L("text-sm text-neutral-500 dark:text-neutral-400",e),...t}));ql.displayName="CardDescription";const Vt=m.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,className:L("p-6 pt-0",e),...t}));Vt.displayName="CardContent";const Gl=m.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,className:L("flex items-center p-6 pt-0",e),...t}));Gl.displayName="CardFooter";const Fe=m.forwardRef(({className:e,...t},n)=>s.jsx("input",{ref:n,className:L("flex h-10 w-full rounded-md border border-neutral-200 bg-white px-3 py-2 text-sm text-neutral-950 shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-neutral-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-900/20 disabled:cursor-not-allowed disabled:opacity-50 dark:border-neutral-800 dark:bg-neutral-950 dark:text-neutral-50 dark:placeholder:text-neutral-400 dark:focus-visible:ring-neutral-50/20",e),...t}));Fe.displayName="Input";const st=m.forwardRef(({className:e,...t},n)=>s.jsx("label",{ref:n,className:L("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",e),...t}));st.displayName="Label";var Ay=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ey=Ay.reduce((e,t)=>{const n=Pl(`Primitive.${t}`),r=m.forwardRef((o,a)=>{const{asChild:i,...c}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(l,{...c,ref:a})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),Iy="Separator",Wi="horizontal",Ty=["horizontal","vertical"],Yl=m.forwardRef((e,t)=>{const{decorative:n,orientation:r=Wi,...o}=e,a=Py(r)?r:Wi,c=n?{role:"none"}:{"aria-orientation":a==="vertical"?a:void 0,role:"separator"};return s.jsx(Ey.div,{"data-orientation":a,...c,...o,ref:t})});Yl.displayName=Iy;function Py(e){return Ty.includes(e)}var Ql=Yl;const yt=m.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>s.jsx(Ql,{ref:o,decorative:n,orientation:t,className:L("shrink-0 bg-neutral-200 dark:bg-neutral-800",t==="horizontal"?"h-px w-full":"h-full w-px",e),...r}));yt.displayName=Ql.displayName;function Re({className:e,...t}){return s.jsx("div",{className:L("animate-pulse rounded-md bg-neutral-100 dark:bg-neutral-800",e),...t})}function Hi(e,[t,n]){return Math.min(n,Math.max(t,e))}function xe(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e?.(o),n===!1||!o.defaultPrevented)return t?.(o)}}function Ry(e,t){const n=m.createContext(t),r=a=>{const{children:i,...c}=a,l=m.useMemo(()=>c,Object.values(c));return s.jsx(n.Provider,{value:l,children:i})};r.displayName=e+"Provider";function o(a){const i=m.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${a}\` must be used within \`${e}\``)}return[r,o]}function un(e,t=[]){let n=[];function r(a,i){const c=m.createContext(i),l=n.length;n=[...n,i];const d=u=>{const{scope:h,children:g,...y}=u,x=h?.[e]?.[l]||c,p=m.useMemo(()=>y,Object.values(y));return s.jsx(x.Provider,{value:p,children:g})};d.displayName=a+"Provider";function f(u,h){const g=h?.[e]?.[l]||c,y=m.useContext(g);if(y)return y;if(i!==void 0)return i;throw new Error(`\`${u}\` must be used within \`${a}\``)}return[d,f]}const o=()=>{const a=n.map(i=>m.createContext(i));return function(c){const l=c?.[e]||a;return m.useMemo(()=>({[`__scope${e}`]:{...c,[e]:l}}),[c,l])}};return o.scopeName=e,[r,Oy(o,...t)]}function Oy(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(a){const i=r.reduce((c,{useScope:l,scopeName:d})=>{const u=l(a)[`__scope${d}`];return{...c,...u}},{});return m.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}function Zi(e){const t=My(e),n=m.forwardRef((r,o)=>{const{children:a,...i}=r,c=m.Children.toArray(a),l=c.find(Dy);if(l){const d=l.props.children,f=c.map(u=>u===l?m.Children.count(d)>1?m.Children.only(null):m.isValidElement(d)?d.props.children:null:u);return s.jsx(t,{...i,ref:o,children:m.isValidElement(d)?m.cloneElement(d,void 0,f):null})}return s.jsx(t,{...i,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}function My(e){const t=m.forwardRef((n,r)=>{const{children:o,...a}=n;if(m.isValidElement(o)){const i=zy(o),c=$y(a,o.props);return o.type!==m.Fragment&&(c.ref=r?Hn(r,i):i),m.cloneElement(o,c)}return m.Children.count(o)>1?m.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Ly=Symbol("radix.slottable");function Dy(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Ly}function $y(e,t){const n={...t};for(const r in t){const o=e[r],a=t[r];/^on[A-Z]/.test(r)?o&&a?n[r]=(...c)=>{const l=a(...c);return o(...c),l}:o&&(n[r]=o):r==="style"?n[r]={...o,...a}:r==="className"&&(n[r]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function zy(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function da(e){const t=e+"CollectionProvider",[n,r]=un(t),[o,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=x=>{const{scope:p,children:v}=x,_=k.useRef(null),w=k.useRef(new Map).current;return s.jsx(o,{scope:p,itemMap:w,collectionRef:_,children:v})};i.displayName=t;const c=e+"CollectionSlot",l=Zi(c),d=k.forwardRef((x,p)=>{const{scope:v,children:_}=x,w=a(c,v),b=Ce(p,w.collectionRef);return s.jsx(l,{ref:b,children:_})});d.displayName=c;const f=e+"CollectionItemSlot",u="data-radix-collection-item",h=Zi(f),g=k.forwardRef((x,p)=>{const{scope:v,children:_,...w}=x,b=k.useRef(null),j=Ce(p,b),R=a(f,v);return k.useEffect(()=>(R.itemMap.set(b,{ref:b,...w}),()=>void R.itemMap.delete(b))),s.jsx(h,{[u]:"",ref:j,children:_})});g.displayName=f;function y(x){const p=a(e+"CollectionConsumer",x);return k.useCallback(()=>{const _=p.collectionRef.current;if(!_)return[];const w=Array.from(_.querySelectorAll(`[${u}]`));return Array.from(p.itemMap.values()).sort((R,I)=>w.indexOf(R.ref.current)-w.indexOf(I.ref.current))},[p.collectionRef,p.itemMap])}return[{Provider:i,Slot:d,ItemSlot:g},y,r]}var Fy=m.createContext(void 0);function bs(e){const t=m.useContext(Fy);return e||t||"ltr"}function Uy(e){const t=By(e),n=m.forwardRef((r,o)=>{const{children:a,...i}=r,c=m.Children.toArray(a),l=c.find(Wy);if(l){const d=l.props.children,f=c.map(u=>u===l?m.Children.count(d)>1?m.Children.only(null):m.isValidElement(d)?d.props.children:null:u);return s.jsx(t,{...i,ref:o,children:m.isValidElement(d)?m.cloneElement(d,void 0,f):null})}return s.jsx(t,{...i,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}function By(e){const t=m.forwardRef((n,r)=>{const{children:o,...a}=n;if(m.isValidElement(o)){const i=Zy(o),c=Hy(a,o.props);return o.type!==m.Fragment&&(c.ref=r?Hn(r,i):i),m.cloneElement(o,c)}return m.Children.count(o)>1?m.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Vy=Symbol("radix.slottable");function Wy(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Vy}function Hy(e,t){const n={...t};for(const r in t){const o=e[r],a=t[r];/^on[A-Z]/.test(r)?o&&a?n[r]=(...c)=>{const l=a(...c);return o(...c),l}:o&&(n[r]=o):r==="style"?n[r]={...o,...a}:r==="className"&&(n[r]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function Zy(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var qy=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],pe=qy.reduce((e,t)=>{const n=Uy(`Primitive.${t}`),r=m.forwardRef((o,a)=>{const{asChild:i,...c}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(l,{...c,ref:a})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Gy(e,t){e&&ps.flushSync(()=>e.dispatchEvent(t))}function sn(e){const t=m.useRef(e);return m.useEffect(()=>{t.current=e}),m.useMemo(()=>(...n)=>t.current?.(...n),[])}function Yy(e,t=globalThis?.document){const n=sn(e);m.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var Qy="DismissableLayer",Ao="dismissableLayer.update",Ky="dismissableLayer.pointerDownOutside",Jy="dismissableLayer.focusOutside",qi,Kl=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),ua=m.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:i,onDismiss:c,...l}=e,d=m.useContext(Kl),[f,u]=m.useState(null),h=f?.ownerDocument??globalThis?.document,[,g]=m.useState({}),y=Ce(t,I=>u(I)),x=Array.from(d.layers),[p]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),v=x.indexOf(p),_=f?x.indexOf(f):-1,w=d.layersWithOutsidePointerEventsDisabled.size>0,b=_>=v,j=t0(I=>{const C=I.target,E=[...d.branches].some(O=>O.contains(C));!b||E||(o?.(I),i?.(I),I.defaultPrevented||c?.())},h),R=n0(I=>{const C=I.target;[...d.branches].some(O=>O.contains(C))||(a?.(I),i?.(I),I.defaultPrevented||c?.())},h);return Yy(I=>{_===d.layers.size-1&&(r?.(I),!I.defaultPrevented&&c&&(I.preventDefault(),c()))},h),m.useEffect(()=>{if(f)return n&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(qi=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(f)),d.layers.add(f),Gi(),()=>{n&&d.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=qi)}},[f,h,n,d]),m.useEffect(()=>()=>{f&&(d.layers.delete(f),d.layersWithOutsidePointerEventsDisabled.delete(f),Gi())},[f,d]),m.useEffect(()=>{const I=()=>g({});return document.addEventListener(Ao,I),()=>document.removeEventListener(Ao,I)},[]),s.jsx(pe.div,{...l,ref:y,style:{pointerEvents:w?b?"auto":"none":void 0,...e.style},onFocusCapture:xe(e.onFocusCapture,R.onFocusCapture),onBlurCapture:xe(e.onBlurCapture,R.onBlurCapture),onPointerDownCapture:xe(e.onPointerDownCapture,j.onPointerDownCapture)})});ua.displayName=Qy;var Xy="DismissableLayerBranch",e0=m.forwardRef((e,t)=>{const n=m.useContext(Kl),r=m.useRef(null),o=Ce(t,r);return m.useEffect(()=>{const a=r.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),s.jsx(pe.div,{...e,ref:o})});e0.displayName=Xy;function t0(e,t=globalThis?.document){const n=sn(e),r=m.useRef(!1),o=m.useRef(()=>{});return m.useEffect(()=>{const a=c=>{if(c.target&&!r.current){let l=function(){Jl(Ky,n,d,{discrete:!0})};const d={originalEvent:c};c.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=l,t.addEventListener("click",o.current,{once:!0})):l()}else t.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",a),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function n0(e,t=globalThis?.document){const n=sn(e),r=m.useRef(!1);return m.useEffect(()=>{const o=a=>{a.target&&!r.current&&Jl(Jy,n,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Gi(){const e=new CustomEvent(Ao);document.dispatchEvent(e)}function Jl(e,t,n,{discrete:r}){const o=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Gy(o,a):o.dispatchEvent(a)}var ro=0;function Xl(){m.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Yi()),document.body.insertAdjacentElement("beforeend",e[1]??Yi()),ro++,()=>{ro===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),ro--}},[])}function Yi(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var so="focusScope.autoFocusOnMount",oo="focusScope.autoFocusOnUnmount",Qi={bubbles:!1,cancelable:!0},r0="FocusScope",fa=m.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...i}=e,[c,l]=m.useState(null),d=sn(o),f=sn(a),u=m.useRef(null),h=Ce(t,x=>l(x)),g=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(r){let x=function(w){if(g.paused||!c)return;const b=w.target;c.contains(b)?u.current=b:rn(u.current,{select:!0})},p=function(w){if(g.paused||!c)return;const b=w.relatedTarget;b!==null&&(c.contains(b)||rn(u.current,{select:!0}))},v=function(w){if(document.activeElement===document.body)for(const j of w)j.removedNodes.length>0&&rn(c)};document.addEventListener("focusin",x),document.addEventListener("focusout",p);const _=new MutationObserver(v);return c&&_.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",x),document.removeEventListener("focusout",p),_.disconnect()}}},[r,c,g.paused]),m.useEffect(()=>{if(c){Ji.add(g);const x=document.activeElement;if(!c.contains(x)){const v=new CustomEvent(so,Qi);c.addEventListener(so,d),c.dispatchEvent(v),v.defaultPrevented||(s0(l0(ed(c)),{select:!0}),document.activeElement===x&&rn(c))}return()=>{c.removeEventListener(so,d),setTimeout(()=>{const v=new CustomEvent(oo,Qi);c.addEventListener(oo,f),c.dispatchEvent(v),v.defaultPrevented||rn(x??document.body,{select:!0}),c.removeEventListener(oo,f),Ji.remove(g)},0)}}},[c,d,f,g]);const y=m.useCallback(x=>{if(!n&&!r||g.paused)return;const p=x.key==="Tab"&&!x.altKey&&!x.ctrlKey&&!x.metaKey,v=document.activeElement;if(p&&v){const _=x.currentTarget,[w,b]=o0(_);w&&b?!x.shiftKey&&v===b?(x.preventDefault(),n&&rn(w,{select:!0})):x.shiftKey&&v===w&&(x.preventDefault(),n&&rn(b,{select:!0})):v===_&&x.preventDefault()}},[n,r,g.paused]);return s.jsx(pe.div,{tabIndex:-1,...i,ref:h,onKeyDown:y})});fa.displayName=r0;function s0(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(rn(r,{select:t}),document.activeElement!==n)return}function o0(e){const t=ed(e),n=Ki(t,e),r=Ki(t.reverse(),e);return[n,r]}function ed(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Ki(e,t){for(const n of e)if(!a0(n,{upTo:t}))return n}function a0(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function i0(e){return e instanceof HTMLInputElement&&"select"in e}function rn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&i0(e)&&t&&e.select()}}var Ji=c0();function c0(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=Xi(e,t),e.unshift(t)},remove(t){e=Xi(e,t),e[0]?.resume()}}}function Xi(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function l0(e){return e.filter(t=>t.tagName!=="A")}var qe=globalThis?.document?m.useLayoutEffect:()=>{},d0=m[" useId ".trim().toString()]||(()=>{}),u0=0;function Ft(e){const[t,n]=m.useState(d0());return qe(()=>{n(r=>r??String(u0++))},[e]),e||(t?`radix-${t}`:"")}const f0=["top","right","bottom","left"],on=Math.min,ht=Math.max,ss=Math.round,Lr=Math.floor,Ut=e=>({x:e,y:e}),m0={left:"right",right:"left",bottom:"top",top:"bottom"},p0={start:"end",end:"start"};function Eo(e,t,n){return ht(e,on(t,n))}function Jt(e,t){return typeof e=="function"?e(t):e}function Xt(e){return e.split("-")[0]}function Gn(e){return e.split("-")[1]}function ma(e){return e==="x"?"y":"x"}function pa(e){return e==="y"?"height":"width"}const h0=new Set(["top","bottom"]);function zt(e){return h0.has(Xt(e))?"y":"x"}function ha(e){return ma(zt(e))}function g0(e,t,n){n===void 0&&(n=!1);const r=Gn(e),o=ha(e),a=pa(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(i=os(i)),[i,os(i)]}function x0(e){const t=os(e);return[Io(e),t,Io(t)]}function Io(e){return e.replace(/start|end/g,t=>p0[t])}const ec=["left","right"],tc=["right","left"],v0=["top","bottom"],y0=["bottom","top"];function b0(e,t,n){switch(e){case"top":case"bottom":return n?t?tc:ec:t?ec:tc;case"left":case"right":return t?v0:y0;default:return[]}}function w0(e,t,n,r){const o=Gn(e);let a=b0(Xt(e),n==="start",r);return o&&(a=a.map(i=>i+"-"+o),t&&(a=a.concat(a.map(Io)))),a}function os(e){return e.replace(/left|right|bottom|top/g,t=>m0[t])}function _0(e){return{top:0,right:0,bottom:0,left:0,...e}}function td(e){return typeof e!="number"?_0(e):{top:e,right:e,bottom:e,left:e}}function as(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function nc(e,t,n){let{reference:r,floating:o}=e;const a=zt(t),i=ha(t),c=pa(i),l=Xt(t),d=a==="y",f=r.x+r.width/2-o.width/2,u=r.y+r.height/2-o.height/2,h=r[c]/2-o[c]/2;let g;switch(l){case"top":g={x:f,y:r.y-o.height};break;case"bottom":g={x:f,y:r.y+r.height};break;case"right":g={x:r.x+r.width,y:u};break;case"left":g={x:r.x-o.width,y:u};break;default:g={x:r.x,y:r.y}}switch(Gn(t)){case"start":g[i]-=h*(n&&d?-1:1);break;case"end":g[i]+=h*(n&&d?-1:1);break}return g}const k0=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:a=[],platform:i}=n,c=a.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(t));let d=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:f,y:u}=nc(d,r,l),h=r,g={},y=0;for(let x=0;x<c.length;x++){const{name:p,fn:v}=c[x],{x:_,y:w,data:b,reset:j}=await v({x:f,y:u,initialPlacement:r,placement:h,strategy:o,middlewareData:g,rects:d,platform:i,elements:{reference:e,floating:t}});f=_??f,u=w??u,g={...g,[p]:{...g[p],...b}},j&&y<=50&&(y++,typeof j=="object"&&(j.placement&&(h=j.placement),j.rects&&(d=j.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):j.rects),{x:f,y:u}=nc(d,h,l)),x=-1)}return{x:f,y:u,placement:h,strategy:o,middlewareData:g}};async function xr(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:a,rects:i,elements:c,strategy:l}=e,{boundary:d="clippingAncestors",rootBoundary:f="viewport",elementContext:u="floating",altBoundary:h=!1,padding:g=0}=Jt(t,e),y=td(g),p=c[h?u==="floating"?"reference":"floating":u],v=as(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(p)))==null||n?p:p.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(c.floating)),boundary:d,rootBoundary:f,strategy:l})),_=u==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,w=await(a.getOffsetParent==null?void 0:a.getOffsetParent(c.floating)),b=await(a.isElement==null?void 0:a.isElement(w))?await(a.getScale==null?void 0:a.getScale(w))||{x:1,y:1}:{x:1,y:1},j=as(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:_,offsetParent:w,strategy:l}):_);return{top:(v.top-j.top+y.top)/b.y,bottom:(j.bottom-v.bottom+y.bottom)/b.y,left:(v.left-j.left+y.left)/b.x,right:(j.right-v.right+y.right)/b.x}}const j0=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:a,platform:i,elements:c,middlewareData:l}=t,{element:d,padding:f=0}=Jt(e,t)||{};if(d==null)return{};const u=td(f),h={x:n,y:r},g=ha(o),y=pa(g),x=await i.getDimensions(d),p=g==="y",v=p?"top":"left",_=p?"bottom":"right",w=p?"clientHeight":"clientWidth",b=a.reference[y]+a.reference[g]-h[g]-a.floating[y],j=h[g]-a.reference[g],R=await(i.getOffsetParent==null?void 0:i.getOffsetParent(d));let I=R?R[w]:0;(!I||!await(i.isElement==null?void 0:i.isElement(R)))&&(I=c.floating[w]||a.floating[y]);const C=b/2-j/2,E=I/2-x[y]/2-1,O=on(u[v],E),F=on(u[_],E),M=O,U=I-x[y]-F,D=I/2-x[y]/2+C,H=Eo(M,D,U),z=!l.arrow&&Gn(o)!=null&&D!==H&&a.reference[y]/2-(D<M?O:F)-x[y]/2<0,A=z?D<M?D-M:D-U:0;return{[g]:h[g]+A,data:{[g]:H,centerOffset:D-H-A,...z&&{alignmentOffset:A}},reset:z}}}),S0=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:a,rects:i,initialPlacement:c,platform:l,elements:d}=t,{mainAxis:f=!0,crossAxis:u=!0,fallbackPlacements:h,fallbackStrategy:g="bestFit",fallbackAxisSideDirection:y="none",flipAlignment:x=!0,...p}=Jt(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const v=Xt(o),_=zt(c),w=Xt(c)===c,b=await(l.isRTL==null?void 0:l.isRTL(d.floating)),j=h||(w||!x?[os(c)]:x0(c)),R=y!=="none";!h&&R&&j.push(...w0(c,x,y,b));const I=[c,...j],C=await xr(t,p),E=[];let O=((r=a.flip)==null?void 0:r.overflows)||[];if(f&&E.push(C[v]),u){const D=g0(o,i,b);E.push(C[D[0]],C[D[1]])}if(O=[...O,{placement:o,overflows:E}],!E.every(D=>D<=0)){var F,M;const D=(((F=a.flip)==null?void 0:F.index)||0)+1,H=I[D];if(H&&(!(u==="alignment"?_!==zt(H):!1)||O.every(N=>zt(N.placement)===_?N.overflows[0]>0:!0)))return{data:{index:D,overflows:O},reset:{placement:H}};let z=(M=O.filter(A=>A.overflows[0]<=0).sort((A,N)=>A.overflows[1]-N.overflows[1])[0])==null?void 0:M.placement;if(!z)switch(g){case"bestFit":{var U;const A=(U=O.filter(N=>{if(R){const Z=zt(N.placement);return Z===_||Z==="y"}return!0}).map(N=>[N.placement,N.overflows.filter(Z=>Z>0).reduce((Z,te)=>Z+te,0)]).sort((N,Z)=>N[1]-Z[1])[0])==null?void 0:U[0];A&&(z=A);break}case"initialPlacement":z=c;break}if(o!==z)return{reset:{placement:z}}}return{}}}};function rc(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function sc(e){return f0.some(t=>e[t]>=0)}const C0=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=Jt(e,t);switch(r){case"referenceHidden":{const a=await xr(t,{...o,elementContext:"reference"}),i=rc(a,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:sc(i)}}}case"escaped":{const a=await xr(t,{...o,altBoundary:!0}),i=rc(a,n.floating);return{data:{escapedOffsets:i,escaped:sc(i)}}}default:return{}}}}},nd=new Set(["left","top"]);async function N0(e,t){const{placement:n,platform:r,elements:o}=e,a=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=Xt(n),c=Gn(n),l=zt(n)==="y",d=nd.has(i)?-1:1,f=a&&l?-1:1,u=Jt(t,e);let{mainAxis:h,crossAxis:g,alignmentAxis:y}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return c&&typeof y=="number"&&(g=c==="end"?y*-1:y),l?{x:g*f,y:h*d}:{x:h*d,y:g*f}}const A0=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:a,placement:i,middlewareData:c}=t,l=await N0(t,e);return i===((n=c.offset)==null?void 0:n.placement)&&(r=c.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:a+l.y,data:{...l,placement:i}}}}},E0=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:a=!0,crossAxis:i=!1,limiter:c={fn:p=>{let{x:v,y:_}=p;return{x:v,y:_}}},...l}=Jt(e,t),d={x:n,y:r},f=await xr(t,l),u=zt(Xt(o)),h=ma(u);let g=d[h],y=d[u];if(a){const p=h==="y"?"top":"left",v=h==="y"?"bottom":"right",_=g+f[p],w=g-f[v];g=Eo(_,g,w)}if(i){const p=u==="y"?"top":"left",v=u==="y"?"bottom":"right",_=y+f[p],w=y-f[v];y=Eo(_,y,w)}const x=c.fn({...t,[h]:g,[u]:y});return{...x,data:{x:x.x-n,y:x.y-r,enabled:{[h]:a,[u]:i}}}}}},I0=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:a,middlewareData:i}=t,{offset:c=0,mainAxis:l=!0,crossAxis:d=!0}=Jt(e,t),f={x:n,y:r},u=zt(o),h=ma(u);let g=f[h],y=f[u];const x=Jt(c,t),p=typeof x=="number"?{mainAxis:x,crossAxis:0}:{mainAxis:0,crossAxis:0,...x};if(l){const w=h==="y"?"height":"width",b=a.reference[h]-a.floating[w]+p.mainAxis,j=a.reference[h]+a.reference[w]-p.mainAxis;g<b?g=b:g>j&&(g=j)}if(d){var v,_;const w=h==="y"?"width":"height",b=nd.has(Xt(o)),j=a.reference[u]-a.floating[w]+(b&&((v=i.offset)==null?void 0:v[u])||0)+(b?0:p.crossAxis),R=a.reference[u]+a.reference[w]+(b?0:((_=i.offset)==null?void 0:_[u])||0)-(b?p.crossAxis:0);y<j?y=j:y>R&&(y=R)}return{[h]:g,[u]:y}}}},T0=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:a,platform:i,elements:c}=t,{apply:l=()=>{},...d}=Jt(e,t),f=await xr(t,d),u=Xt(o),h=Gn(o),g=zt(o)==="y",{width:y,height:x}=a.floating;let p,v;u==="top"||u==="bottom"?(p=u,v=h===(await(i.isRTL==null?void 0:i.isRTL(c.floating))?"start":"end")?"left":"right"):(v=u,p=h==="end"?"top":"bottom");const _=x-f.top-f.bottom,w=y-f.left-f.right,b=on(x-f[p],_),j=on(y-f[v],w),R=!t.middlewareData.shift;let I=b,C=j;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(C=w),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(I=_),R&&!h){const O=ht(f.left,0),F=ht(f.right,0),M=ht(f.top,0),U=ht(f.bottom,0);g?C=y-2*(O!==0||F!==0?O+F:ht(f.left,f.right)):I=x-2*(M!==0||U!==0?M+U:ht(f.top,f.bottom))}await l({...t,availableWidth:C,availableHeight:I});const E=await i.getDimensions(c.floating);return y!==E.width||x!==E.height?{reset:{rects:!0}}:{}}}};function ws(){return typeof window<"u"}function Yn(e){return rd(e)?(e.nodeName||"").toLowerCase():"#document"}function gt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ht(e){var t;return(t=(rd(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function rd(e){return ws()?e instanceof Node||e instanceof gt(e).Node:!1}function It(e){return ws()?e instanceof Element||e instanceof gt(e).Element:!1}function Wt(e){return ws()?e instanceof HTMLElement||e instanceof gt(e).HTMLElement:!1}function oc(e){return!ws()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof gt(e).ShadowRoot}const P0=new Set(["inline","contents"]);function Cr(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Tt(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!P0.has(o)}const R0=new Set(["table","td","th"]);function O0(e){return R0.has(Yn(e))}const M0=[":popover-open",":modal"];function _s(e){return M0.some(t=>{try{return e.matches(t)}catch{return!1}})}const L0=["transform","translate","scale","rotate","perspective"],D0=["transform","translate","scale","rotate","perspective","filter"],$0=["paint","layout","strict","content"];function ga(e){const t=xa(),n=It(e)?Tt(e):e;return L0.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||D0.some(r=>(n.willChange||"").includes(r))||$0.some(r=>(n.contain||"").includes(r))}function z0(e){let t=an(e);for(;Wt(t)&&!Un(t);){if(ga(t))return t;if(_s(t))return null;t=an(t)}return null}function xa(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const F0=new Set(["html","body","#document"]);function Un(e){return F0.has(Yn(e))}function Tt(e){return gt(e).getComputedStyle(e)}function ks(e){return It(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function an(e){if(Yn(e)==="html")return e;const t=e.assignedSlot||e.parentNode||oc(e)&&e.host||Ht(e);return oc(t)?t.host:t}function sd(e){const t=an(e);return Un(t)?e.ownerDocument?e.ownerDocument.body:e.body:Wt(t)&&Cr(t)?t:sd(t)}function vr(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=sd(e),a=o===((r=e.ownerDocument)==null?void 0:r.body),i=gt(o);if(a){const c=To(i);return t.concat(i,i.visualViewport||[],Cr(o)?o:[],c&&n?vr(c):[])}return t.concat(o,vr(o,[],n))}function To(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function od(e){const t=Tt(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Wt(e),a=o?e.offsetWidth:n,i=o?e.offsetHeight:r,c=ss(n)!==a||ss(r)!==i;return c&&(n=a,r=i),{width:n,height:r,$:c}}function va(e){return It(e)?e:e.contextElement}function $n(e){const t=va(e);if(!Wt(t))return Ut(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:a}=od(t);let i=(a?ss(n.width):n.width)/r,c=(a?ss(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!c||!Number.isFinite(c))&&(c=1),{x:i,y:c}}const U0=Ut(0);function ad(e){const t=gt(e);return!xa()||!t.visualViewport?U0:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function B0(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==gt(e)?!1:t}function wn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),a=va(e);let i=Ut(1);t&&(r?It(r)&&(i=$n(r)):i=$n(e));const c=B0(a,n,r)?ad(a):Ut(0);let l=(o.left+c.x)/i.x,d=(o.top+c.y)/i.y,f=o.width/i.x,u=o.height/i.y;if(a){const h=gt(a),g=r&&It(r)?gt(r):r;let y=h,x=To(y);for(;x&&r&&g!==y;){const p=$n(x),v=x.getBoundingClientRect(),_=Tt(x),w=v.left+(x.clientLeft+parseFloat(_.paddingLeft))*p.x,b=v.top+(x.clientTop+parseFloat(_.paddingTop))*p.y;l*=p.x,d*=p.y,f*=p.x,u*=p.y,l+=w,d+=b,y=gt(x),x=To(y)}}return as({width:f,height:u,x:l,y:d})}function js(e,t){const n=ks(e).scrollLeft;return t?t.left+n:wn(Ht(e)).left+n}function id(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-js(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function V0(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const a=o==="fixed",i=Ht(r),c=t?_s(t.floating):!1;if(r===i||c&&a)return n;let l={scrollLeft:0,scrollTop:0},d=Ut(1);const f=Ut(0),u=Wt(r);if((u||!u&&!a)&&((Yn(r)!=="body"||Cr(i))&&(l=ks(r)),Wt(r))){const g=wn(r);d=$n(r),f.x=g.x+r.clientLeft,f.y=g.y+r.clientTop}const h=i&&!u&&!a?id(i,l):Ut(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-l.scrollLeft*d.x+f.x+h.x,y:n.y*d.y-l.scrollTop*d.y+f.y+h.y}}function W0(e){return Array.from(e.getClientRects())}function H0(e){const t=Ht(e),n=ks(e),r=e.ownerDocument.body,o=ht(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=ht(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+js(e);const c=-n.scrollTop;return Tt(r).direction==="rtl"&&(i+=ht(t.clientWidth,r.clientWidth)-o),{width:o,height:a,x:i,y:c}}const ac=25;function Z0(e,t){const n=gt(e),r=Ht(e),o=n.visualViewport;let a=r.clientWidth,i=r.clientHeight,c=0,l=0;if(o){a=o.width,i=o.height;const f=xa();(!f||f&&t==="fixed")&&(c=o.offsetLeft,l=o.offsetTop)}const d=js(r);if(d<=0){const f=r.ownerDocument,u=f.body,h=getComputedStyle(u),g=f.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,y=Math.abs(r.clientWidth-u.clientWidth-g);y<=ac&&(a-=y)}else d<=ac&&(a+=d);return{width:a,height:i,x:c,y:l}}const q0=new Set(["absolute","fixed"]);function G0(e,t){const n=wn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,a=Wt(e)?$n(e):Ut(1),i=e.clientWidth*a.x,c=e.clientHeight*a.y,l=o*a.x,d=r*a.y;return{width:i,height:c,x:l,y:d}}function ic(e,t,n){let r;if(t==="viewport")r=Z0(e,n);else if(t==="document")r=H0(Ht(e));else if(It(t))r=G0(t,n);else{const o=ad(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return as(r)}function cd(e,t){const n=an(e);return n===t||!It(n)||Un(n)?!1:Tt(n).position==="fixed"||cd(n,t)}function Y0(e,t){const n=t.get(e);if(n)return n;let r=vr(e,[],!1).filter(c=>It(c)&&Yn(c)!=="body"),o=null;const a=Tt(e).position==="fixed";let i=a?an(e):e;for(;It(i)&&!Un(i);){const c=Tt(i),l=ga(i);!l&&c.position==="fixed"&&(o=null),(a?!l&&!o:!l&&c.position==="static"&&!!o&&q0.has(o.position)||Cr(i)&&!l&&cd(e,i))?r=r.filter(f=>f!==i):o=c,i=an(i)}return t.set(e,r),r}function Q0(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?_s(t)?[]:Y0(t,this._c):[].concat(n),r],c=i[0],l=i.reduce((d,f)=>{const u=ic(t,f,o);return d.top=ht(u.top,d.top),d.right=on(u.right,d.right),d.bottom=on(u.bottom,d.bottom),d.left=ht(u.left,d.left),d},ic(t,c,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function K0(e){const{width:t,height:n}=od(e);return{width:t,height:n}}function J0(e,t,n){const r=Wt(t),o=Ht(t),a=n==="fixed",i=wn(e,!0,a,t);let c={scrollLeft:0,scrollTop:0};const l=Ut(0);function d(){l.x=js(o)}if(r||!r&&!a)if((Yn(t)!=="body"||Cr(o))&&(c=ks(t)),r){const g=wn(t,!0,a,t);l.x=g.x+t.clientLeft,l.y=g.y+t.clientTop}else o&&d();a&&!r&&o&&d();const f=o&&!r&&!a?id(o,c):Ut(0),u=i.left+c.scrollLeft-l.x-f.x,h=i.top+c.scrollTop-l.y-f.y;return{x:u,y:h,width:i.width,height:i.height}}function ao(e){return Tt(e).position==="static"}function cc(e,t){if(!Wt(e)||Tt(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Ht(e)===n&&(n=n.ownerDocument.body),n}function ld(e,t){const n=gt(e);if(_s(e))return n;if(!Wt(e)){let o=an(e);for(;o&&!Un(o);){if(It(o)&&!ao(o))return o;o=an(o)}return n}let r=cc(e,t);for(;r&&O0(r)&&ao(r);)r=cc(r,t);return r&&Un(r)&&ao(r)&&!ga(r)?n:r||z0(e)||n}const X0=async function(e){const t=this.getOffsetParent||ld,n=this.getDimensions,r=await n(e.floating);return{reference:J0(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function eb(e){return Tt(e).direction==="rtl"}const tb={convertOffsetParentRelativeRectToViewportRelativeRect:V0,getDocumentElement:Ht,getClippingRect:Q0,getOffsetParent:ld,getElementRects:X0,getClientRects:W0,getDimensions:K0,getScale:$n,isElement:It,isRTL:eb};function dd(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function nb(e,t){let n=null,r;const o=Ht(e);function a(){var c;clearTimeout(r),(c=n)==null||c.disconnect(),n=null}function i(c,l){c===void 0&&(c=!1),l===void 0&&(l=1),a();const d=e.getBoundingClientRect(),{left:f,top:u,width:h,height:g}=d;if(c||t(),!h||!g)return;const y=Lr(u),x=Lr(o.clientWidth-(f+h)),p=Lr(o.clientHeight-(u+g)),v=Lr(f),w={rootMargin:-y+"px "+-x+"px "+-p+"px "+-v+"px",threshold:ht(0,on(1,l))||1};let b=!0;function j(R){const I=R[0].intersectionRatio;if(I!==l){if(!b)return i();I?i(!1,I):r=setTimeout(()=>{i(!1,1e-7)},1e3)}I===1&&!dd(d,e.getBoundingClientRect())&&i(),b=!1}try{n=new IntersectionObserver(j,{...w,root:o.ownerDocument})}catch{n=new IntersectionObserver(j,w)}n.observe(e)}return i(!0),a}function rb(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:a=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,d=va(e),f=o||a?[...d?vr(d):[],...vr(t)]:[];f.forEach(v=>{o&&v.addEventListener("scroll",n,{passive:!0}),a&&v.addEventListener("resize",n)});const u=d&&c?nb(d,n):null;let h=-1,g=null;i&&(g=new ResizeObserver(v=>{let[_]=v;_&&_.target===d&&g&&(g.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var w;(w=g)==null||w.observe(t)})),n()}),d&&!l&&g.observe(d),g.observe(t));let y,x=l?wn(e):null;l&&p();function p(){const v=wn(e);x&&!dd(x,v)&&n(),x=v,y=requestAnimationFrame(p)}return n(),()=>{var v;f.forEach(_=>{o&&_.removeEventListener("scroll",n),a&&_.removeEventListener("resize",n)}),u?.(),(v=g)==null||v.disconnect(),g=null,l&&cancelAnimationFrame(y)}}const sb=A0,ob=E0,ab=S0,ib=T0,cb=C0,lc=j0,lb=I0,db=(e,t,n)=>{const r=new Map,o={platform:tb,...n},a={...o.platform,_c:r};return k0(e,t,{...o,platform:a})};var ub=typeof document<"u",fb=function(){},qr=ub?k.useLayoutEffect:fb;function is(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!is(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const a=o[r];if(!(a==="_owner"&&e.$$typeof)&&!is(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function ud(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function dc(e,t){const n=ud(e);return Math.round(t*n)/n}function io(e){const t=m.useRef(e);return qr(()=>{t.current=e}),t}function mb(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:a,floating:i}={},transform:c=!0,whileElementsMounted:l,open:d}=e,[f,u]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,g]=m.useState(r);is(h,r)||g(r);const[y,x]=m.useState(null),[p,v]=m.useState(null),_=m.useCallback(N=>{N!==R.current&&(R.current=N,x(N))},[]),w=m.useCallback(N=>{N!==I.current&&(I.current=N,v(N))},[]),b=a||y,j=i||p,R=m.useRef(null),I=m.useRef(null),C=m.useRef(f),E=l!=null,O=io(l),F=io(o),M=io(d),U=m.useCallback(()=>{if(!R.current||!I.current)return;const N={placement:t,strategy:n,middleware:h};F.current&&(N.platform=F.current),db(R.current,I.current,N).then(Z=>{const te={...Z,isPositioned:M.current!==!1};D.current&&!is(C.current,te)&&(C.current=te,ps.flushSync(()=>{u(te)}))})},[h,t,n,F,M]);qr(()=>{d===!1&&C.current.isPositioned&&(C.current.isPositioned=!1,u(N=>({...N,isPositioned:!1})))},[d]);const D=m.useRef(!1);qr(()=>(D.current=!0,()=>{D.current=!1}),[]),qr(()=>{if(b&&(R.current=b),j&&(I.current=j),b&&j){if(O.current)return O.current(b,j,U);U()}},[b,j,U,O,E]);const H=m.useMemo(()=>({reference:R,floating:I,setReference:_,setFloating:w}),[_,w]),z=m.useMemo(()=>({reference:b,floating:j}),[b,j]),A=m.useMemo(()=>{const N={position:n,left:0,top:0};if(!z.floating)return N;const Z=dc(z.floating,f.x),te=dc(z.floating,f.y);return c?{...N,transform:"translate("+Z+"px, "+te+"px)",...ud(z.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:Z,top:te}},[n,c,z.floating,f.x,f.y]);return m.useMemo(()=>({...f,update:U,refs:H,elements:z,floatingStyles:A}),[f,U,H,z,A])}const pb=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?lc({element:r.current,padding:o}).fn(n):{}:r?lc({element:r,padding:o}).fn(n):{}}}},hb=(e,t)=>({...sb(e),options:[e,t]}),gb=(e,t)=>({...ob(e),options:[e,t]}),xb=(e,t)=>({...lb(e),options:[e,t]}),vb=(e,t)=>({...ab(e),options:[e,t]}),yb=(e,t)=>({...ib(e),options:[e,t]}),bb=(e,t)=>({...cb(e),options:[e,t]}),wb=(e,t)=>({...pb(e),options:[e,t]});var _b="Arrow",fd=m.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...a}=e;return s.jsx(pe.svg,{...a,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:s.jsx("polygon",{points:"0,0 30,0 15,10"})})});fd.displayName=_b;var kb=fd;function jb(e){const[t,n]=m.useState(void 0);return qe(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const a=o[0];let i,c;if("borderBoxSize"in a){const l=a.borderBoxSize,d=Array.isArray(l)?l[0]:l;i=d.inlineSize,c=d.blockSize}else i=e.offsetWidth,c=e.offsetHeight;n({width:i,height:c})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var ya="Popper",[md,pd]=un(ya),[Sb,hd]=md(ya),gd=e=>{const{__scopePopper:t,children:n}=e,[r,o]=m.useState(null);return s.jsx(Sb,{scope:t,anchor:r,onAnchorChange:o,children:n})};gd.displayName=ya;var xd="PopperAnchor",vd=m.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,a=hd(xd,n),i=m.useRef(null),c=Ce(t,i),l=m.useRef(null);return m.useEffect(()=>{const d=l.current;l.current=r?.current||i.current,d!==l.current&&a.onAnchorChange(l.current)}),r?null:s.jsx(pe.div,{...o,ref:c})});vd.displayName=xd;var ba="PopperContent",[Cb,Nb]=md(ba),yd=m.forwardRef((e,t)=>{const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:a="center",alignOffset:i=0,arrowPadding:c=0,avoidCollisions:l=!0,collisionBoundary:d=[],collisionPadding:f=0,sticky:u="partial",hideWhenDetached:h=!1,updatePositionStrategy:g="optimized",onPlaced:y,...x}=e,p=hd(ba,n),[v,_]=m.useState(null),w=Ce(t,P=>_(P)),[b,j]=m.useState(null),R=jb(b),I=R?.width??0,C=R?.height??0,E=r+(a!=="center"?"-"+a:""),O=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},F=Array.isArray(d)?d:[d],M=F.length>0,U={padding:O,boundary:F.filter(Eb),altBoundary:M},{refs:D,floatingStyles:H,placement:z,isPositioned:A,middlewareData:N}=mb({strategy:"fixed",placement:E,whileElementsMounted:(...P)=>rb(...P,{animationFrame:g==="always"}),elements:{reference:p.anchor},middleware:[hb({mainAxis:o+C,alignmentAxis:i}),l&&gb({mainAxis:!0,crossAxis:!1,limiter:u==="partial"?xb():void 0,...U}),l&&vb({...U}),yb({...U,apply:({elements:P,rects:G,availableWidth:ue,availableHeight:B})=>{const{width:ae,height:ce}=G.reference,we=P.floating.style;we.setProperty("--radix-popper-available-width",`${ue}px`),we.setProperty("--radix-popper-available-height",`${B}px`),we.setProperty("--radix-popper-anchor-width",`${ae}px`),we.setProperty("--radix-popper-anchor-height",`${ce}px`)}}),b&&wb({element:b,padding:c}),Ib({arrowWidth:I,arrowHeight:C}),h&&bb({strategy:"referenceHidden",...U})]}),[Z,te]=_d(z),re=sn(y);qe(()=>{A&&re?.()},[A,re]);const de=N.arrow?.x,W=N.arrow?.y,Q=N.arrow?.centerOffset!==0,[q,he]=m.useState();return qe(()=>{v&&he(window.getComputedStyle(v).zIndex)},[v]),s.jsx("div",{ref:D.setFloating,"data-radix-popper-content-wrapper":"",style:{...H,transform:A?H.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:q,"--radix-popper-transform-origin":[N.transformOrigin?.x,N.transformOrigin?.y].join(" "),...N.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:s.jsx(Cb,{scope:n,placedSide:Z,onArrowChange:j,arrowX:de,arrowY:W,shouldHideArrow:Q,children:s.jsx(pe.div,{"data-side":Z,"data-align":te,...x,ref:w,style:{...x.style,animation:A?void 0:"none"}})})})});yd.displayName=ba;var bd="PopperArrow",Ab={top:"bottom",right:"left",bottom:"top",left:"right"},wd=m.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,a=Nb(bd,r),i=Ab[a.placedSide];return s.jsx("span",{ref:a.onArrowChange,style:{position:"absolute",left:a.arrowX,top:a.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[a.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[a.placedSide],visibility:a.shouldHideArrow?"hidden":void 0},children:s.jsx(kb,{...o,ref:n,style:{...o.style,display:"block"}})})});wd.displayName=bd;function Eb(e){return e!==null}var Ib=e=>({name:"transformOrigin",options:e,fn(t){const{placement:n,rects:r,middlewareData:o}=t,i=o.arrow?.centerOffset!==0,c=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[d,f]=_d(n),u={start:"0%",center:"50%",end:"100%"}[f],h=(o.arrow?.x??0)+c/2,g=(o.arrow?.y??0)+l/2;let y="",x="";return d==="bottom"?(y=i?u:`${h}px`,x=`${-l}px`):d==="top"?(y=i?u:`${h}px`,x=`${r.floating.height+l}px`):d==="right"?(y=`${-l}px`,x=i?u:`${g}px`):d==="left"&&(y=`${r.floating.width+l}px`,x=i?u:`${g}px`),{data:{x:y,y:x}}}});function _d(e){const[t,n="center"]=e.split("-");return[t,n]}var Tb=gd,Pb=vd,Rb=yd,Ob=wd,Mb="Portal",wa=m.forwardRef((e,t)=>{const{container:n,...r}=e,[o,a]=m.useState(!1);qe(()=>a(!0),[]);const i=n||o&&globalThis?.document?.body;return i?Zo.createPortal(s.jsx(pe.div,{...r,ref:t}),i):null});wa.displayName=Mb;function Lb(e){const t=Db(e),n=m.forwardRef((r,o)=>{const{children:a,...i}=r,c=m.Children.toArray(a),l=c.find(zb);if(l){const d=l.props.children,f=c.map(u=>u===l?m.Children.count(d)>1?m.Children.only(null):m.isValidElement(d)?d.props.children:null:u);return s.jsx(t,{...i,ref:o,children:m.isValidElement(d)?m.cloneElement(d,void 0,f):null})}return s.jsx(t,{...i,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}function Db(e){const t=m.forwardRef((n,r)=>{const{children:o,...a}=n;if(m.isValidElement(o)){const i=Ub(o),c=Fb(a,o.props);return o.type!==m.Fragment&&(c.ref=r?Hn(r,i):i),m.cloneElement(o,c)}return m.Children.count(o)>1?m.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var $b=Symbol("radix.slottable");function zb(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===$b}function Fb(e,t){const n={...t};for(const r in t){const o=e[r],a=t[r];/^on[A-Z]/.test(r)?o&&a?n[r]=(...c)=>{const l=a(...c);return o(...c),l}:o&&(n[r]=o):r==="style"?n[r]={...o,...a}:r==="className"&&(n[r]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function Ub(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Bb=m[" useInsertionEffect ".trim().toString()]||qe;function cn({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,a,i]=Vb({defaultProp:t,onChange:n}),c=e!==void 0,l=c?e:o;{const f=m.useRef(e!==void 0);m.useEffect(()=>{const u=f.current;u!==c&&console.warn(`${r} is changing from ${u?"controlled":"uncontrolled"} to ${c?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),f.current=c},[c,r])}const d=m.useCallback(f=>{if(c){const u=Wb(f)?f(e):f;u!==e&&i.current?.(u)}else a(f)},[c,e,a,i]);return[l,d]}function Vb({defaultProp:e,onChange:t}){const[n,r]=m.useState(e),o=m.useRef(n),a=m.useRef(t);return Bb(()=>{a.current=t},[t]),m.useEffect(()=>{o.current!==n&&(a.current?.(n),o.current=n)},[n,o]),[n,r,a]}function Wb(e){return typeof e=="function"}function Hb(e){const t=m.useRef({value:e,previous:e});return m.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var kd=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),Zb="VisuallyHidden",qb=m.forwardRef((e,t)=>s.jsx(pe.span,{...e,ref:t,style:{...kd,...e.style}}));qb.displayName=Zb;var Gb=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Rn=new WeakMap,Dr=new WeakMap,$r={},co=0,jd=function(e){return e&&(e.host||jd(e.parentNode))},Yb=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=jd(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},Qb=function(e,t,n,r){var o=Yb(t,Array.isArray(e)?e:[e]);$r[n]||($r[n]=new WeakMap);var a=$r[n],i=[],c=new Set,l=new Set(o),d=function(u){!u||c.has(u)||(c.add(u),d(u.parentNode))};o.forEach(d);var f=function(u){!u||l.has(u)||Array.prototype.forEach.call(u.children,function(h){if(c.has(h))f(h);else try{var g=h.getAttribute(r),y=g!==null&&g!=="false",x=(Rn.get(h)||0)+1,p=(a.get(h)||0)+1;Rn.set(h,x),a.set(h,p),i.push(h),x===1&&y&&Dr.set(h,!0),p===1&&h.setAttribute(n,"true"),y||h.setAttribute(r,"true")}catch(v){console.error("aria-hidden: cannot operate on ",h,v)}})};return f(t),c.clear(),co++,function(){i.forEach(function(u){var h=Rn.get(u)-1,g=a.get(u)-1;Rn.set(u,h),a.set(u,g),h||(Dr.has(u)||u.removeAttribute(r),Dr.delete(u)),g||u.removeAttribute(n)}),co--,co||(Rn=new WeakMap,Rn=new WeakMap,Dr=new WeakMap,$r={})}},Sd=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=Gb(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Qb(r,o,n,"aria-hidden")):function(){return null}},$t=function(){return $t=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},$t.apply(this,arguments)};function Cd(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function Kb(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,a;r<o;r++)(a||!(r in t))&&(a||(a=Array.prototype.slice.call(t,0,r)),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var Gr="right-scroll-bar-position",Yr="width-before-scroll-bar",Jb="with-scroll-bars-hidden",Xb="--removed-body-scroll-bar-size";function lo(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function ew(e,t){var n=k.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var tw=typeof window<"u"?m.useLayoutEffect:m.useEffect,uc=new WeakMap;function nw(e,t){var n=ew(null,function(r){return e.forEach(function(o){return lo(o,r)})});return tw(function(){var r=uc.get(n);if(r){var o=new Set(r),a=new Set(e),i=n.current;o.forEach(function(c){a.has(c)||lo(c,null)}),a.forEach(function(c){o.has(c)||lo(c,i)})}uc.set(n,e)},[e]),n}function rw(e){return e}function sw(e,t){t===void 0&&(t=rw);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(a){var i=t(a,r);return n.push(i),function(){n=n.filter(function(c){return c!==i})}},assignSyncMedium:function(a){for(r=!0;n.length;){var i=n;n=[],i.forEach(a)}n={push:function(c){return a(c)},filter:function(){return n}}},assignMedium:function(a){r=!0;var i=[];if(n.length){var c=n;n=[],c.forEach(a),i=n}var l=function(){var f=i;i=[],f.forEach(a)},d=function(){return Promise.resolve().then(l)};d(),n={push:function(f){i.push(f),d()},filter:function(f){return i=i.filter(f),n}}}};return o}function ow(e){e===void 0&&(e={});var t=sw(null);return t.options=$t({async:!0,ssr:!1},e),t}var Nd=function(e){var t=e.sideCar,n=Cd(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return m.createElement(r,$t({},n))};Nd.isSideCarExport=!0;function aw(e,t){return e.useMedium(t),Nd}var Ad=ow(),uo=function(){},Ss=m.forwardRef(function(e,t){var n=m.useRef(null),r=m.useState({onScrollCapture:uo,onWheelCapture:uo,onTouchMoveCapture:uo}),o=r[0],a=r[1],i=e.forwardProps,c=e.children,l=e.className,d=e.removeScrollBar,f=e.enabled,u=e.shards,h=e.sideCar,g=e.noRelative,y=e.noIsolation,x=e.inert,p=e.allowPinchZoom,v=e.as,_=v===void 0?"div":v,w=e.gapMode,b=Cd(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),j=h,R=nw([n,t]),I=$t($t({},b),o);return m.createElement(m.Fragment,null,f&&m.createElement(j,{sideCar:Ad,removeScrollBar:d,shards:u,noRelative:g,noIsolation:y,inert:x,setCallbacks:a,allowPinchZoom:!!p,lockRef:n,gapMode:w}),i?m.cloneElement(m.Children.only(c),$t($t({},I),{ref:R})):m.createElement(_,$t({},I,{className:l,ref:R}),c))});Ss.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Ss.classNames={fullWidth:Yr,zeroRight:Gr};var iw=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function cw(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=iw();return t&&e.setAttribute("nonce",t),e}function lw(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function dw(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var uw=function(){var e=0,t=null;return{add:function(n){e==0&&(t=cw())&&(lw(t,n),dw(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},fw=function(){var e=uw();return function(t,n){m.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Ed=function(){var e=fw(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},mw={left:0,top:0,right:0,gap:0},fo=function(e){return parseInt(e||"",10)||0},pw=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[fo(n),fo(r),fo(o)]},hw=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return mw;var t=pw(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},gw=Ed(),zn="data-scroll-locked",xw=function(e,t,n,r){var o=e.left,a=e.top,i=e.right,c=e.gap;return n===void 0&&(n="margin"),`
|
|
40
|
+
.`.concat(Jb,` {
|
|
41
41
|
overflow: hidden `).concat(r,`;
|
|
42
42
|
padding-right: `).concat(c,"px ").concat(r,`;
|
|
43
43
|
}
|
|
@@ -71,14 +71,14 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
body[`).concat(zn,`] {
|
|
74
|
-
`).concat(
|
|
74
|
+
`).concat(Xb,": ").concat(c,`px;
|
|
75
75
|
}
|
|
76
|
-
`)},fc=function(){var e=parseInt(document.body.getAttribute(zn)||"0",10);return isFinite(e)?e:0},
|
|
76
|
+
`)},fc=function(){var e=parseInt(document.body.getAttribute(zn)||"0",10);return isFinite(e)?e:0},vw=function(){m.useEffect(function(){return document.body.setAttribute(zn,(fc()+1).toString()),function(){var e=fc()-1;e<=0?document.body.removeAttribute(zn):document.body.setAttribute(zn,e.toString())}},[])},yw=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;vw();var a=m.useMemo(function(){return hw(o)},[o]);return m.createElement(gw,{styles:xw(a,!t,o,n?"":"!important")})},Po=!1;if(typeof window<"u")try{var zr=Object.defineProperty({},"passive",{get:function(){return Po=!0,!0}});window.addEventListener("test",zr,zr),window.removeEventListener("test",zr,zr)}catch{Po=!1}var On=Po?{passive:!1}:!1,bw=function(e){return e.tagName==="TEXTAREA"},Id=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!bw(e)&&n[t]==="visible")},ww=function(e){return Id(e,"overflowY")},_w=function(e){return Id(e,"overflowX")},mc=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Td(e,r);if(o){var a=Pd(e,r),i=a[1],c=a[2];if(i>c)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},kw=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},jw=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Td=function(e,t){return e==="v"?ww(t):_w(t)},Pd=function(e,t){return e==="v"?kw(t):jw(t)},Sw=function(e,t){return e==="h"&&t==="rtl"?-1:1},Cw=function(e,t,n,r,o){var a=Sw(e,window.getComputedStyle(t).direction),i=a*r,c=n.target,l=t.contains(c),d=!1,f=i>0,u=0,h=0;do{if(!c)break;var g=Pd(e,c),y=g[0],x=g[1],p=g[2],v=x-p-a*y;(y||v)&&Td(e,c)&&(u+=v,h+=y);var _=c.parentNode;c=_&&_.nodeType===Node.DOCUMENT_FRAGMENT_NODE?_.host:_}while(!l&&c!==document.body||l&&(t.contains(c)||t===c));return(f&&Math.abs(u)<1||!f&&Math.abs(h)<1)&&(d=!0),d},Fr=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},pc=function(e){return[e.deltaX,e.deltaY]},hc=function(e){return e&&"current"in e?e.current:e},Nw=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Aw=function(e){return`
|
|
77
77
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
78
78
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
79
|
-
`)},Cw=0,Mn=[];function Nw(e){var t=m.useRef([]),n=m.useRef([0,0]),r=m.useRef(),o=m.useState(Cw++)[0],a=m.useState(Ad)[0],i=m.useRef(e);m.useEffect(function(){i.current=e},[e]),m.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var x=Gb([e.lockRef.current],(e.shards||[]).map(hc),!0).filter(Boolean);return x.forEach(function(p){return p.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),x.forEach(function(p){return p.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var c=m.useCallback(function(x,p){if("touches"in x&&x.touches.length===2||x.type==="wheel"&&x.ctrlKey)return!i.current.allowPinchZoom;var v=Fr(x),_=n.current,w="deltaX"in x?x.deltaX:_[0]-v[0],b="deltaY"in x?x.deltaY:_[1]-v[1],j,R=x.target,I=Math.abs(w)>Math.abs(b)?"h":"v";if("touches"in x&&I==="h"&&R.type==="range")return!1;var C=window.getSelection(),E=C&&C.anchorNode,O=E?E===R||E.contains(R):!1;if(O)return!1;var F=mc(I,R);if(!F)return!0;if(F?j=I:(j=I==="v"?"h":"v",F=mc(I,R)),!F)return!1;if(!r.current&&"changedTouches"in x&&(w||b)&&(r.current=j),!j)return!0;var M=r.current||j;return kw(M,p,x,M==="h"?w:b)},[]),l=m.useCallback(function(x){var p=x;if(!(!Mn.length||Mn[Mn.length-1]!==a)){var v="deltaY"in p?pc(p):Fr(p),_=t.current.filter(function(j){return j.name===p.type&&(j.target===p.target||p.target===j.shadowParent)&&jw(j.delta,v)})[0];if(_&&_.should){p.cancelable&&p.preventDefault();return}if(!_){var w=(i.current.shards||[]).map(hc).filter(Boolean).filter(function(j){return j.contains(p.target)}),b=w.length>0?c(p,w[0]):!i.current.noIsolation;b&&p.cancelable&&p.preventDefault()}}},[]),d=m.useCallback(function(x,p,v,_){var w={name:x,delta:p,target:v,should:_,shadowParent:Aw(v)};t.current.push(w),setTimeout(function(){t.current=t.current.filter(function(b){return b!==w})},1)},[]),f=m.useCallback(function(x){n.current=Fr(x),r.current=void 0},[]),u=m.useCallback(function(x){d(x.type,pc(x),x.target,c(x,e.lockRef.current))},[]),h=m.useCallback(function(x){d(x.type,Fr(x),x.target,c(x,e.lockRef.current))},[]);m.useEffect(function(){return Mn.push(a),e.setCallbacks({onScrollCapture:u,onWheelCapture:u,onTouchMoveCapture:h}),document.addEventListener("wheel",l,On),document.addEventListener("touchmove",l,On),document.addEventListener("touchstart",f,On),function(){Mn=Mn.filter(function(x){return x!==a}),document.removeEventListener("wheel",l,On),document.removeEventListener("touchmove",l,On),document.removeEventListener("touchstart",f,On)}},[]);var g=e.removeScrollBar,y=e.inert;return m.createElement(m.Fragment,null,y?m.createElement(a,{styles:Sw(o)}):null,g?m.createElement(gw,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Aw(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Ew=rw(Nd,Nw);var _a=m.forwardRef(function(e,t){return m.createElement(Ss,zt({},e,{ref:t,sideCar:Ew}))});_a.classNames=Ss.classNames;var Iw=[" ","Enter","ArrowUp","ArrowDown"],Tw=[" ","Enter"],_n="Select",[Cs,Ns,Pw]=da(_n),[Qn]=un(_n,[Pw,md]),As=md(),[Rw,fn]=Qn(_n),[Ow,Mw]=Qn(_n),Pd=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:a,value:i,defaultValue:c,onValueChange:l,dir:d,name:f,autoComplete:u,disabled:h,required:g,form:y}=e,x=As(t),[p,v]=m.useState(null),[_,w]=m.useState(null),[b,j]=m.useState(!1),R=bs(d),[I,C]=cn({prop:r,defaultProp:o??!1,onChange:a,caller:_n}),[E,O]=cn({prop:i,defaultProp:c,onChange:l,caller:_n}),F=m.useRef(null),M=p?y||!!p.closest("form"):!0,[U,D]=m.useState(new Set),H=Array.from(U).map(z=>z.props.value).join(";");return s.jsx(Ab,{...x,children:s.jsxs(Rw,{required:g,scope:t,trigger:p,onTriggerChange:v,valueNode:_,onValueNodeChange:w,valueNodeHasChildren:b,onValueNodeHasChildrenChange:j,contentId:Ut(),value:E,onValueChange:O,open:I,onOpenChange:C,dir:R,triggerPointerDownPosRef:F,disabled:h,children:[s.jsx(Cs.Provider,{scope:t,children:s.jsx(Ow,{scope:e.__scopeSelect,onNativeOptionAdd:m.useCallback(z=>{D(A=>new Set(A).add(z))},[]),onNativeOptionRemove:m.useCallback(z=>{D(A=>{const N=new Set(A);return N.delete(z),N})},[]),children:n})}),M?s.jsxs(Jd,{"aria-hidden":!0,required:g,tabIndex:-1,name:f,autoComplete:u,value:E,onChange:z=>O(z.target.value),disabled:h,form:y,children:[E===void 0?s.jsx("option",{value:""}):null,Array.from(U)]},H):null]})})};Pd.displayName=_n;var Rd="SelectTrigger",Od=m.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,a=As(n),i=fn(Rd,n),c=i.disabled||r,l=Ce(t,i.onTriggerChange),d=Ns(n),f=m.useRef("touch"),[u,h,g]=eu(x=>{const p=d().filter(w=>!w.disabled),v=p.find(w=>w.value===i.value),_=tu(p,x,v);_!==void 0&&i.onValueChange(_.value)}),y=x=>{c||(i.onOpenChange(!0),g()),x&&(i.triggerPointerDownPosRef.current={x:Math.round(x.pageX),y:Math.round(x.pageY)})};return s.jsx(Eb,{asChild:!0,...a,children:s.jsx(pe.button,{type:"button",role:"combobox","aria-controls":i.contentId,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:c,"data-disabled":c?"":void 0,"data-placeholder":Xd(i.value)?"":void 0,...o,ref:l,onClick:xe(o.onClick,x=>{x.currentTarget.focus(),f.current!=="mouse"&&y(x)}),onPointerDown:xe(o.onPointerDown,x=>{f.current=x.pointerType;const p=x.target;p.hasPointerCapture(x.pointerId)&&p.releasePointerCapture(x.pointerId),x.button===0&&x.ctrlKey===!1&&x.pointerType==="mouse"&&(y(x),x.preventDefault())}),onKeyDown:xe(o.onKeyDown,x=>{const p=u.current!=="";!(x.ctrlKey||x.altKey||x.metaKey)&&x.key.length===1&&h(x.key),!(p&&x.key===" ")&&Iw.includes(x.key)&&(y(),x.preventDefault())})})})});Od.displayName=Rd;var Md="SelectValue",Ld=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:a,placeholder:i="",...c}=e,l=fn(Md,n),{onValueNodeHasChildrenChange:d}=l,f=a!==void 0,u=Ce(t,l.onValueNodeChange);return qe(()=>{d(f)},[d,f]),s.jsx(pe.span,{...c,ref:u,style:{pointerEvents:"none"},children:Xd(l.value)?s.jsx(s.Fragment,{children:i}):a})});Ld.displayName=Md;var Lw="SelectIcon",Dd=m.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return s.jsx(pe.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Dd.displayName=Lw;var Dw="SelectPortal",$d=e=>s.jsx(wa,{asChild:!0,...e});$d.displayName=Dw;var kn="SelectContent",zd=m.forwardRef((e,t)=>{const n=fn(kn,e.__scopeSelect),[r,o]=m.useState();if(qe(()=>{o(new DocumentFragment)},[]),!n.open){const a=r;return a?ps.createPortal(s.jsx(Fd,{scope:e.__scopeSelect,children:s.jsx(Cs.Slot,{scope:e.__scopeSelect,children:s.jsx("div",{children:e.children})})}),a):null}return s.jsx(Ud,{...e,ref:t})});zd.displayName=kn;var Nt=10,[Fd,mn]=Qn(kn),$w="SelectContentImpl",zw=Rb("SelectContent.RemoveScroll"),Ud=m.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:a,onPointerDownOutside:i,side:c,sideOffset:l,align:d,alignOffset:f,arrowPadding:u,collisionBoundary:h,collisionPadding:g,sticky:y,hideWhenDetached:x,avoidCollisions:p,...v}=e,_=fn(kn,n),[w,b]=m.useState(null),[j,R]=m.useState(null),I=Ce(t,P=>b(P)),[C,E]=m.useState(null),[O,F]=m.useState(null),M=Ns(n),[U,D]=m.useState(!1),H=m.useRef(!1);m.useEffect(()=>{if(w)return jd(w)},[w]),Jl();const z=m.useCallback(P=>{const[G,...ue]=M().map(ce=>ce.ref.current),[B]=ue.slice(-1),ae=document.activeElement;for(const ce of P)if(ce===ae||(ce?.scrollIntoView({block:"nearest"}),ce===G&&j&&(j.scrollTop=0),ce===B&&j&&(j.scrollTop=j.scrollHeight),ce?.focus(),document.activeElement!==ae))return},[M,j]),A=m.useCallback(()=>z([C,w]),[z,C,w]);m.useEffect(()=>{U&&A()},[U,A]);const{onOpenChange:N,triggerPointerDownPosRef:Z}=_;m.useEffect(()=>{if(w){let P={x:0,y:0};const G=B=>{P={x:Math.abs(Math.round(B.pageX)-(Z.current?.x??0)),y:Math.abs(Math.round(B.pageY)-(Z.current?.y??0))}},ue=B=>{P.x<=10&&P.y<=10?B.preventDefault():w.contains(B.target)||N(!1),document.removeEventListener("pointermove",G),Z.current=null};return Z.current!==null&&(document.addEventListener("pointermove",G),document.addEventListener("pointerup",ue,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",G),document.removeEventListener("pointerup",ue,{capture:!0})}}},[w,N,Z]),m.useEffect(()=>{const P=()=>N(!1);return window.addEventListener("blur",P),window.addEventListener("resize",P),()=>{window.removeEventListener("blur",P),window.removeEventListener("resize",P)}},[N]);const[te,re]=eu(P=>{const G=M().filter(ae=>!ae.disabled),ue=G.find(ae=>ae.ref.current===document.activeElement),B=tu(G,P,ue);B&&setTimeout(()=>B.ref.current.focus())}),de=m.useCallback((P,G,ue)=>{const B=!H.current&&!ue;(_.value!==void 0&&_.value===G||B)&&(E(P),B&&(H.current=!0))},[_.value]),W=m.useCallback(()=>w?.focus(),[w]),Q=m.useCallback((P,G,ue)=>{const B=!H.current&&!ue;(_.value!==void 0&&_.value===G||B)&&F(P)},[_.value]),q=r==="popper"?Ro:Bd,he=q===Ro?{side:c,sideOffset:l,align:d,alignOffset:f,arrowPadding:u,collisionBoundary:h,collisionPadding:g,sticky:y,hideWhenDetached:x,avoidCollisions:p}:{};return s.jsx(Fd,{scope:n,content:w,viewport:j,onViewportChange:R,itemRefCallback:de,selectedItem:C,onItemLeave:W,itemTextRefCallback:Q,focusSelectedItem:A,selectedItemText:O,position:r,isPositioned:U,searchRef:te,children:s.jsx(_a,{as:zw,allowPinchZoom:!0,children:s.jsx(fa,{asChild:!0,trapped:_.open,onMountAutoFocus:P=>{P.preventDefault()},onUnmountAutoFocus:xe(o,P=>{_.trigger?.focus({preventScroll:!0}),P.preventDefault()}),children:s.jsx(ua,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:i,onFocusOutside:P=>P.preventDefault(),onDismiss:()=>_.onOpenChange(!1),children:s.jsx(q,{role:"listbox",id:_.contentId,"data-state":_.open?"open":"closed",dir:_.dir,onContextMenu:P=>P.preventDefault(),...v,...he,onPlaced:()=>D(!0),ref:I,style:{display:"flex",flexDirection:"column",outline:"none",...v.style},onKeyDown:xe(v.onKeyDown,P=>{const G=P.ctrlKey||P.altKey||P.metaKey;if(P.key==="Tab"&&P.preventDefault(),!G&&P.key.length===1&&re(P.key),["ArrowUp","ArrowDown","Home","End"].includes(P.key)){let B=M().filter(ae=>!ae.disabled).map(ae=>ae.ref.current);if(["ArrowUp","End"].includes(P.key)&&(B=B.slice().reverse()),["ArrowUp","ArrowDown"].includes(P.key)){const ae=P.target,ce=B.indexOf(ae);B=B.slice(ce+1)}setTimeout(()=>z(B)),P.preventDefault()}})})})})})})});Ud.displayName=$w;var Fw="SelectItemAlignedPosition",Bd=m.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,a=fn(kn,n),i=mn(kn,n),[c,l]=m.useState(null),[d,f]=m.useState(null),u=Ce(t,I=>f(I)),h=Ns(n),g=m.useRef(!1),y=m.useRef(!0),{viewport:x,selectedItem:p,selectedItemText:v,focusSelectedItem:_}=i,w=m.useCallback(()=>{if(a.trigger&&a.valueNode&&c&&d&&x&&p&&v){const I=a.trigger.getBoundingClientRect(),C=d.getBoundingClientRect(),E=a.valueNode.getBoundingClientRect(),O=v.getBoundingClientRect();if(a.dir!=="rtl"){const ae=O.left-C.left,ce=E.left-ae,we=I.left-ce,Te=I.width+we,Ve=Math.max(Te,C.width),Ge=window.innerWidth-Nt,We=Hi(ce,[Nt,Math.max(Nt,Ge-Ve)]);c.style.minWidth=Te+"px",c.style.left=We+"px"}else{const ae=C.right-O.right,ce=window.innerWidth-E.right-ae,we=window.innerWidth-I.right-ce,Te=I.width+we,Ve=Math.max(Te,C.width),Ge=window.innerWidth-Nt,We=Hi(ce,[Nt,Math.max(Nt,Ge-Ve)]);c.style.minWidth=Te+"px",c.style.right=We+"px"}const F=h(),M=window.innerHeight-Nt*2,U=x.scrollHeight,D=window.getComputedStyle(d),H=parseInt(D.borderTopWidth,10),z=parseInt(D.paddingTop,10),A=parseInt(D.borderBottomWidth,10),N=parseInt(D.paddingBottom,10),Z=H+z+U+N+A,te=Math.min(p.offsetHeight*5,Z),re=window.getComputedStyle(x),de=parseInt(re.paddingTop,10),W=parseInt(re.paddingBottom,10),Q=I.top+I.height/2-Nt,q=M-Q,he=p.offsetHeight/2,P=p.offsetTop+he,G=H+z+P,ue=Z-G;if(G<=Q){const ae=F.length>0&&p===F[F.length-1].ref.current;c.style.bottom="0px";const ce=d.clientHeight-x.offsetTop-x.offsetHeight,we=Math.max(q,he+(ae?W:0)+ce+A),Te=G+we;c.style.height=Te+"px"}else{const ae=F.length>0&&p===F[0].ref.current;c.style.top="0px";const we=Math.max(Q,H+x.offsetTop+(ae?de:0)+he)+ue;c.style.height=we+"px",x.scrollTop=G-Q+x.offsetTop}c.style.margin=`${Nt}px 0`,c.style.minHeight=te+"px",c.style.maxHeight=M+"px",r?.(),requestAnimationFrame(()=>g.current=!0)}},[h,a.trigger,a.valueNode,c,d,x,p,v,a.dir,r]);qe(()=>w(),[w]);const[b,j]=m.useState();qe(()=>{d&&j(window.getComputedStyle(d).zIndex)},[d]);const R=m.useCallback(I=>{I&&y.current===!0&&(w(),_?.(),y.current=!1)},[w,_]);return s.jsx(Bw,{scope:n,contentWrapper:c,shouldExpandOnScrollRef:g,onScrollButtonChange:R,children:s.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:b},children:s.jsx(pe.div,{...o,ref:u,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Bd.displayName=Fw;var Uw="SelectPopperPosition",Ro=m.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=Nt,...a}=e,i=As(n);return s.jsx(Ib,{...i,...a,ref:t,align:r,collisionPadding:o,style:{boxSizing:"border-box",...a.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Ro.displayName=Uw;var[Bw,ka]=Qn(kn,{}),Oo="SelectViewport",Vd=m.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,a=mn(Oo,n),i=ka(Oo,n),c=Ce(t,a.onViewportChange),l=m.useRef(0);return s.jsxs(s.Fragment,{children:[s.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),s.jsx(Cs.Slot,{scope:n,children:s.jsx(pe.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:xe(o.onScroll,d=>{const f=d.currentTarget,{contentWrapper:u,shouldExpandOnScrollRef:h}=i;if(h?.current&&u){const g=Math.abs(l.current-f.scrollTop);if(g>0){const y=window.innerHeight-Nt*2,x=parseFloat(u.style.minHeight),p=parseFloat(u.style.height),v=Math.max(x,p);if(v<y){const _=v+g,w=Math.min(y,_),b=_-w;u.style.height=w+"px",u.style.bottom==="0px"&&(f.scrollTop=b>0?b:0,u.style.justifyContent="flex-end")}}}l.current=f.scrollTop})})})]})});Vd.displayName=Oo;var Wd="SelectGroup",[Vw,Ww]=Qn(Wd),Hd=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Ut();return s.jsx(Vw,{scope:n,id:o,children:s.jsx(pe.div,{role:"group","aria-labelledby":o,...r,ref:t})})});Hd.displayName=Wd;var Zd="SelectLabel",Hw=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Ww(Zd,n);return s.jsx(pe.div,{id:o.id,...r,ref:t})});Hw.displayName=Zd;var cs="SelectItem",[Zw,qd]=Qn(cs),Gd=m.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:a,...i}=e,c=fn(cs,n),l=mn(cs,n),d=c.value===r,[f,u]=m.useState(a??""),[h,g]=m.useState(!1),y=Ce(t,_=>l.itemRefCallback?.(_,r,o)),x=Ut(),p=m.useRef("touch"),v=()=>{o||(c.onValueChange(r),c.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return s.jsx(Zw,{scope:n,value:r,disabled:o,textId:x,isSelected:d,onItemTextChange:m.useCallback(_=>{u(w=>w||(_?.textContent??"").trim())},[]),children:s.jsx(Cs.ItemSlot,{scope:n,value:r,disabled:o,textValue:f,children:s.jsx(pe.div,{role:"option","aria-labelledby":x,"data-highlighted":h?"":void 0,"aria-selected":d&&h,"data-state":d?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:y,onFocus:xe(i.onFocus,()=>g(!0)),onBlur:xe(i.onBlur,()=>g(!1)),onClick:xe(i.onClick,()=>{p.current!=="mouse"&&v()}),onPointerUp:xe(i.onPointerUp,()=>{p.current==="mouse"&&v()}),onPointerDown:xe(i.onPointerDown,_=>{p.current=_.pointerType}),onPointerMove:xe(i.onPointerMove,_=>{p.current=_.pointerType,o?l.onItemLeave?.():p.current==="mouse"&&_.currentTarget.focus({preventScroll:!0})}),onPointerLeave:xe(i.onPointerLeave,_=>{_.currentTarget===document.activeElement&&l.onItemLeave?.()}),onKeyDown:xe(i.onKeyDown,_=>{l.searchRef?.current!==""&&_.key===" "||(Tw.includes(_.key)&&v(),_.key===" "&&_.preventDefault())})})})})});Gd.displayName=cs;var cr="SelectItemText",Yd=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...a}=e,i=fn(cr,n),c=mn(cr,n),l=qd(cr,n),d=Mw(cr,n),[f,u]=m.useState(null),h=Ce(t,v=>u(v),l.onItemTextChange,v=>c.itemTextRefCallback?.(v,l.value,l.disabled)),g=f?.textContent,y=m.useMemo(()=>s.jsx("option",{value:l.value,disabled:l.disabled,children:g},l.value),[l.disabled,l.value,g]),{onNativeOptionAdd:x,onNativeOptionRemove:p}=d;return qe(()=>(x(y),()=>p(y)),[x,p,y]),s.jsxs(s.Fragment,{children:[s.jsx(pe.span,{id:l.textId,...a,ref:h}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?ps.createPortal(a.children,i.valueNode):null]})});Yd.displayName=cr;var Qd="SelectItemIndicator",qw=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return qd(Qd,n).isSelected?s.jsx(pe.span,{"aria-hidden":!0,...r,ref:t}):null});qw.displayName=Qd;var Mo="SelectScrollUpButton",Gw=m.forwardRef((e,t)=>{const n=mn(Mo,e.__scopeSelect),r=ka(Mo,e.__scopeSelect),[o,a]=m.useState(!1),i=Ce(t,r.onScrollButtonChange);return qe(()=>{if(n.viewport&&n.isPositioned){let c=function(){const d=l.scrollTop>0;a(d)};const l=n.viewport;return c(),l.addEventListener("scroll",c),()=>l.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),o?s.jsx(Kd,{...e,ref:i,onAutoScroll:()=>{const{viewport:c,selectedItem:l}=n;c&&l&&(c.scrollTop=c.scrollTop-l.offsetHeight)}}):null});Gw.displayName=Mo;var Lo="SelectScrollDownButton",Yw=m.forwardRef((e,t)=>{const n=mn(Lo,e.__scopeSelect),r=ka(Lo,e.__scopeSelect),[o,a]=m.useState(!1),i=Ce(t,r.onScrollButtonChange);return qe(()=>{if(n.viewport&&n.isPositioned){let c=function(){const d=l.scrollHeight-l.clientHeight,f=Math.ceil(l.scrollTop)<d;a(f)};const l=n.viewport;return c(),l.addEventListener("scroll",c),()=>l.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),o?s.jsx(Kd,{...e,ref:i,onAutoScroll:()=>{const{viewport:c,selectedItem:l}=n;c&&l&&(c.scrollTop=c.scrollTop+l.offsetHeight)}}):null});Yw.displayName=Lo;var Kd=m.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,a=mn("SelectScrollButton",n),i=m.useRef(null),c=Ns(n),l=m.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return m.useEffect(()=>()=>l(),[l]),qe(()=>{c().find(f=>f.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[c]),s.jsx(pe.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:xe(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:xe(o.onPointerMove,()=>{a.onItemLeave?.(),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:xe(o.onPointerLeave,()=>{l()})})}),Qw="SelectSeparator",Kw=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return s.jsx(pe.div,{"aria-hidden":!0,...r,ref:t})});Kw.displayName=Qw;var Do="SelectArrow",Jw=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=As(n),a=fn(Do,n),i=mn(Do,n);return a.open&&i.position==="popper"?s.jsx(Tb,{...o,...r,ref:t}):null});Jw.displayName=Do;var Xw="SelectBubbleInput",Jd=m.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=m.useRef(null),a=Ce(r,o),i=Bb(t);return m.useEffect(()=>{const c=o.current;if(!c)return;const l=window.HTMLSelectElement.prototype,f=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&f){const u=new Event("change",{bubbles:!0});f.call(c,t),c.dispatchEvent(u)}},[i,t]),s.jsx(pe.select,{...n,style:{..._d,...n.style},ref:a,defaultValue:t})});Jd.displayName=Xw;function Xd(e){return e===""||e===void 0}function eu(e){const t=sn(e),n=m.useRef(""),r=m.useRef(0),o=m.useCallback(i=>{const c=n.current+i;t(c),(function l(d){n.current=d,window.clearTimeout(r.current),d!==""&&(r.current=window.setTimeout(()=>l(""),1e3))})(c)},[t]),a=m.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,a]}function tu(e,t,n){const o=t.length>1&&Array.from(t).every(d=>d===t[0])?t[0]:t,a=n?e.indexOf(n):-1;let i=e_(e,Math.max(a,0));o.length===1&&(i=i.filter(d=>d!==n));const l=i.find(d=>d.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function e_(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var t_=Pd,nu=Od,n_=Ld,r_=Dd,s_=$d,ru=zd,o_=Vd,a_=Hd,su=Gd,i_=Yd;const ls=t_,c_=a_,ds=n_,yr=m.forwardRef(({className:e,children:t,...n},r)=>s.jsxs(nu,{ref:r,className:L("flex h-10 w-full items-center justify-between rounded-md border border-neutral-200 bg-white px-3 py-2 text-sm text-neutral-950 shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-900/20 disabled:cursor-not-allowed disabled:opacity-50 dark:border-neutral-800 dark:bg-neutral-950 dark:text-neutral-50 dark:focus-visible:ring-neutral-50/20",e),...n,children:[t,s.jsx(r_,{className:"ml-2 text-neutral-500 dark:text-neutral-400",children:"▾"})]}));yr.displayName=nu.displayName;const br=m.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>s.jsx(s_,{children:s.jsx(ru,{ref:o,position:n,className:L("z-50 min-w-[8rem] overflow-hidden rounded-md border border-neutral-200 bg-white text-neutral-950 shadow-md dark:border-neutral-800 dark:bg-neutral-950 dark:text-neutral-50",e),...r,children:s.jsx(o_,{className:L("p-1",n==="popper"?"w-full":void 0),children:t})})}));br.displayName=ru.displayName;const wr=m.forwardRef(({className:e,children:t,...n},r)=>s.jsx(su,{ref:r,className:L("relative flex w-full cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-neutral-100 data-[disabled]:pointer-events-none data-[disabled]:opacity-50 dark:focus:bg-neutral-800",e),...n,children:s.jsx(i_,{children:t})}));wr.displayName=su.displayName;function l_(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var Kn=e=>{const{present:t,children:n}=e,r=d_(t),o=typeof n=="function"?n({present:r.isPresent}):m.Children.only(n),a=Ce(r.ref,u_(o));return typeof n=="function"||r.isPresent?m.cloneElement(o,{ref:a}):null};Kn.displayName="Presence";function d_(e){const[t,n]=m.useState(),r=m.useRef(null),o=m.useRef(e),a=m.useRef("none"),i=e?"mounted":"unmounted",[c,l]=l_(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{const d=Ur(r.current);a.current=c==="mounted"?d:"none"},[c]),qe(()=>{const d=r.current,f=o.current;if(f!==e){const h=a.current,g=Ur(d);e?l("MOUNT"):g==="none"||d?.display==="none"?l("UNMOUNT"):l(f&&h!==g?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),qe(()=>{if(t){let d;const f=t.ownerDocument.defaultView??window,u=g=>{const x=Ur(r.current).includes(CSS.escape(g.animationName));if(g.target===t&&x&&(l("ANIMATION_END"),!o.current)){const p=t.style.animationFillMode;t.style.animationFillMode="forwards",d=f.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=p)})}},h=g=>{g.target===t&&(a.current=Ur(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",u),t.addEventListener("animationend",u),()=>{f.clearTimeout(d),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",u),t.removeEventListener("animationend",u)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:m.useCallback(d=>{r.current=d?getComputedStyle(d):null,n(d)},[])}}function Ur(e){return e?.animationName||"none"}function u_(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function f_(e){const t=m_(e),n=m.forwardRef((r,o)=>{const{children:a,...i}=r,c=m.Children.toArray(a),l=c.find(h_);if(l){const d=l.props.children,f=c.map(u=>u===l?m.Children.count(d)>1?m.Children.only(null):m.isValidElement(d)?d.props.children:null:u);return s.jsx(t,{...i,ref:o,children:m.isValidElement(d)?m.cloneElement(d,void 0,f):null})}return s.jsx(t,{...i,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}function m_(e){const t=m.forwardRef((n,r)=>{const{children:o,...a}=n;if(m.isValidElement(o)){const i=x_(o),c=g_(a,o.props);return o.type!==m.Fragment&&(c.ref=r?Hn(r,i):i),m.cloneElement(o,c)}return m.Children.count(o)>1?m.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var p_=Symbol("radix.slottable");function h_(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===p_}function g_(e,t){const n={...t};for(const r in t){const o=e[r],a=t[r];/^on[A-Z]/.test(r)?o&&a?n[r]=(...c)=>{const l=a(...c);return o(...c),l}:o&&(n[r]=o):r==="style"?n[r]={...o,...a}:r==="className"&&(n[r]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function x_(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Es="Dialog",[ou]=un(Es),[v_,Ot]=ou(Es),au=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:a,modal:i=!0}=e,c=m.useRef(null),l=m.useRef(null),[d,f]=cn({prop:r,defaultProp:o??!1,onChange:a,caller:Es});return s.jsx(v_,{scope:t,triggerRef:c,contentRef:l,contentId:Ut(),titleId:Ut(),descriptionId:Ut(),open:d,onOpenChange:f,onOpenToggle:m.useCallback(()=>f(u=>!u),[f]),modal:i,children:n})};au.displayName=Es;var iu="DialogTrigger",cu=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Ot(iu,n),a=Ce(t,o.triggerRef);return s.jsx(pe.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Ca(o.open),...r,ref:a,onClick:xe(e.onClick,o.onOpenToggle)})});cu.displayName=iu;var ja="DialogPortal",[y_,lu]=ou(ja,{forceMount:void 0}),du=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,a=Ot(ja,t);return s.jsx(y_,{scope:t,forceMount:n,children:m.Children.map(r,i=>s.jsx(Kn,{present:n||a.open,children:s.jsx(wa,{asChild:!0,container:o,children:i})}))})};du.displayName=ja;var us="DialogOverlay",uu=m.forwardRef((e,t)=>{const n=lu(us,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,a=Ot(us,e.__scopeDialog);return a.modal?s.jsx(Kn,{present:r||a.open,children:s.jsx(w_,{...o,ref:t})}):null});uu.displayName=us;var b_=f_("DialogOverlay.RemoveScroll"),w_=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Ot(us,n);return s.jsx(_a,{as:b_,allowPinchZoom:!0,shards:[o.contentRef],children:s.jsx(pe.div,{"data-state":Ca(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),jn="DialogContent",fu=m.forwardRef((e,t)=>{const n=lu(jn,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,a=Ot(jn,e.__scopeDialog);return s.jsx(Kn,{present:r||a.open,children:a.modal?s.jsx(__,{...o,ref:t}):s.jsx(k_,{...o,ref:t})})});fu.displayName=jn;var __=m.forwardRef((e,t)=>{const n=Ot(jn,e.__scopeDialog),r=m.useRef(null),o=Ce(t,n.contentRef,r);return m.useEffect(()=>{const a=r.current;if(a)return jd(a)},[]),s.jsx(mu,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:xe(e.onCloseAutoFocus,a=>{a.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:xe(e.onPointerDownOutside,a=>{const i=a.detail.originalEvent,c=i.button===0&&i.ctrlKey===!0;(i.button===2||c)&&a.preventDefault()}),onFocusOutside:xe(e.onFocusOutside,a=>a.preventDefault())})}),k_=m.forwardRef((e,t)=>{const n=Ot(jn,e.__scopeDialog),r=m.useRef(!1),o=m.useRef(!1);return s.jsx(mu,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{e.onCloseAutoFocus?.(a),a.defaultPrevented||(r.current||n.triggerRef.current?.focus(),a.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:a=>{e.onInteractOutside?.(a),a.defaultPrevented||(r.current=!0,a.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=a.target;n.triggerRef.current?.contains(i)&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&o.current&&a.preventDefault()}})}),mu=m.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:a,...i}=e,c=Ot(jn,n),l=m.useRef(null),d=Ce(t,l);return Jl(),s.jsxs(s.Fragment,{children:[s.jsx(fa,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:a,children:s.jsx(ua,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":Ca(c.open),...i,ref:d,onDismiss:()=>c.onOpenChange(!1)})}),s.jsxs(s.Fragment,{children:[s.jsx(j_,{titleId:c.titleId}),s.jsx(C_,{contentRef:l,descriptionId:c.descriptionId})]})]})}),Sa="DialogTitle",pu=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Ot(Sa,n);return s.jsx(pe.h2,{id:o.titleId,...r,ref:t})});pu.displayName=Sa;var hu="DialogDescription",gu=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Ot(hu,n);return s.jsx(pe.p,{id:o.descriptionId,...r,ref:t})});gu.displayName=hu;var xu="DialogClose",vu=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Ot(xu,n);return s.jsx(pe.button,{type:"button",...r,ref:t,onClick:xe(e.onClick,()=>o.onOpenChange(!1))})});vu.displayName=xu;function Ca(e){return e?"open":"closed"}var yu="DialogTitleWarning",[Fj,bu]=Iy(yu,{contentName:jn,titleName:Sa,docsSlug:"dialog"}),j_=({titleId:e})=>{const t=bu(yu),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
79
|
+
`)},Ew=0,Mn=[];function Iw(e){var t=m.useRef([]),n=m.useRef([0,0]),r=m.useRef(),o=m.useState(Ew++)[0],a=m.useState(Ed)[0],i=m.useRef(e);m.useEffect(function(){i.current=e},[e]),m.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var x=Kb([e.lockRef.current],(e.shards||[]).map(hc),!0).filter(Boolean);return x.forEach(function(p){return p.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),x.forEach(function(p){return p.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var c=m.useCallback(function(x,p){if("touches"in x&&x.touches.length===2||x.type==="wheel"&&x.ctrlKey)return!i.current.allowPinchZoom;var v=Fr(x),_=n.current,w="deltaX"in x?x.deltaX:_[0]-v[0],b="deltaY"in x?x.deltaY:_[1]-v[1],j,R=x.target,I=Math.abs(w)>Math.abs(b)?"h":"v";if("touches"in x&&I==="h"&&R.type==="range")return!1;var C=window.getSelection(),E=C&&C.anchorNode,O=E?E===R||E.contains(R):!1;if(O)return!1;var F=mc(I,R);if(!F)return!0;if(F?j=I:(j=I==="v"?"h":"v",F=mc(I,R)),!F)return!1;if(!r.current&&"changedTouches"in x&&(w||b)&&(r.current=j),!j)return!0;var M=r.current||j;return Cw(M,p,x,M==="h"?w:b)},[]),l=m.useCallback(function(x){var p=x;if(!(!Mn.length||Mn[Mn.length-1]!==a)){var v="deltaY"in p?pc(p):Fr(p),_=t.current.filter(function(j){return j.name===p.type&&(j.target===p.target||p.target===j.shadowParent)&&Nw(j.delta,v)})[0];if(_&&_.should){p.cancelable&&p.preventDefault();return}if(!_){var w=(i.current.shards||[]).map(hc).filter(Boolean).filter(function(j){return j.contains(p.target)}),b=w.length>0?c(p,w[0]):!i.current.noIsolation;b&&p.cancelable&&p.preventDefault()}}},[]),d=m.useCallback(function(x,p,v,_){var w={name:x,delta:p,target:v,should:_,shadowParent:Tw(v)};t.current.push(w),setTimeout(function(){t.current=t.current.filter(function(b){return b!==w})},1)},[]),f=m.useCallback(function(x){n.current=Fr(x),r.current=void 0},[]),u=m.useCallback(function(x){d(x.type,pc(x),x.target,c(x,e.lockRef.current))},[]),h=m.useCallback(function(x){d(x.type,Fr(x),x.target,c(x,e.lockRef.current))},[]);m.useEffect(function(){return Mn.push(a),e.setCallbacks({onScrollCapture:u,onWheelCapture:u,onTouchMoveCapture:h}),document.addEventListener("wheel",l,On),document.addEventListener("touchmove",l,On),document.addEventListener("touchstart",f,On),function(){Mn=Mn.filter(function(x){return x!==a}),document.removeEventListener("wheel",l,On),document.removeEventListener("touchmove",l,On),document.removeEventListener("touchstart",f,On)}},[]);var g=e.removeScrollBar,y=e.inert;return m.createElement(m.Fragment,null,y?m.createElement(a,{styles:Aw(o)}):null,g?m.createElement(yw,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Tw(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Pw=aw(Ad,Iw);var _a=m.forwardRef(function(e,t){return m.createElement(Ss,$t({},e,{ref:t,sideCar:Pw}))});_a.classNames=Ss.classNames;var Rw=[" ","Enter","ArrowUp","ArrowDown"],Ow=[" ","Enter"],_n="Select",[Cs,Ns,Mw]=da(_n),[Qn]=un(_n,[Mw,pd]),As=pd(),[Lw,fn]=Qn(_n),[Dw,$w]=Qn(_n),Rd=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:a,value:i,defaultValue:c,onValueChange:l,dir:d,name:f,autoComplete:u,disabled:h,required:g,form:y}=e,x=As(t),[p,v]=m.useState(null),[_,w]=m.useState(null),[b,j]=m.useState(!1),R=bs(d),[I,C]=cn({prop:r,defaultProp:o??!1,onChange:a,caller:_n}),[E,O]=cn({prop:i,defaultProp:c,onChange:l,caller:_n}),F=m.useRef(null),M=p?y||!!p.closest("form"):!0,[U,D]=m.useState(new Set),H=Array.from(U).map(z=>z.props.value).join(";");return s.jsx(Tb,{...x,children:s.jsxs(Lw,{required:g,scope:t,trigger:p,onTriggerChange:v,valueNode:_,onValueNodeChange:w,valueNodeHasChildren:b,onValueNodeHasChildrenChange:j,contentId:Ft(),value:E,onValueChange:O,open:I,onOpenChange:C,dir:R,triggerPointerDownPosRef:F,disabled:h,children:[s.jsx(Cs.Provider,{scope:t,children:s.jsx(Dw,{scope:e.__scopeSelect,onNativeOptionAdd:m.useCallback(z=>{D(A=>new Set(A).add(z))},[]),onNativeOptionRemove:m.useCallback(z=>{D(A=>{const N=new Set(A);return N.delete(z),N})},[]),children:n})}),M?s.jsxs(Xd,{"aria-hidden":!0,required:g,tabIndex:-1,name:f,autoComplete:u,value:E,onChange:z=>O(z.target.value),disabled:h,form:y,children:[E===void 0?s.jsx("option",{value:""}):null,Array.from(U)]},H):null]})})};Rd.displayName=_n;var Od="SelectTrigger",Md=m.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,a=As(n),i=fn(Od,n),c=i.disabled||r,l=Ce(t,i.onTriggerChange),d=Ns(n),f=m.useRef("touch"),[u,h,g]=tu(x=>{const p=d().filter(w=>!w.disabled),v=p.find(w=>w.value===i.value),_=nu(p,x,v);_!==void 0&&i.onValueChange(_.value)}),y=x=>{c||(i.onOpenChange(!0),g()),x&&(i.triggerPointerDownPosRef.current={x:Math.round(x.pageX),y:Math.round(x.pageY)})};return s.jsx(Pb,{asChild:!0,...a,children:s.jsx(pe.button,{type:"button",role:"combobox","aria-controls":i.contentId,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:c,"data-disabled":c?"":void 0,"data-placeholder":eu(i.value)?"":void 0,...o,ref:l,onClick:xe(o.onClick,x=>{x.currentTarget.focus(),f.current!=="mouse"&&y(x)}),onPointerDown:xe(o.onPointerDown,x=>{f.current=x.pointerType;const p=x.target;p.hasPointerCapture(x.pointerId)&&p.releasePointerCapture(x.pointerId),x.button===0&&x.ctrlKey===!1&&x.pointerType==="mouse"&&(y(x),x.preventDefault())}),onKeyDown:xe(o.onKeyDown,x=>{const p=u.current!=="";!(x.ctrlKey||x.altKey||x.metaKey)&&x.key.length===1&&h(x.key),!(p&&x.key===" ")&&Rw.includes(x.key)&&(y(),x.preventDefault())})})})});Md.displayName=Od;var Ld="SelectValue",Dd=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:a,placeholder:i="",...c}=e,l=fn(Ld,n),{onValueNodeHasChildrenChange:d}=l,f=a!==void 0,u=Ce(t,l.onValueNodeChange);return qe(()=>{d(f)},[d,f]),s.jsx(pe.span,{...c,ref:u,style:{pointerEvents:"none"},children:eu(l.value)?s.jsx(s.Fragment,{children:i}):a})});Dd.displayName=Ld;var zw="SelectIcon",$d=m.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return s.jsx(pe.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});$d.displayName=zw;var Fw="SelectPortal",zd=e=>s.jsx(wa,{asChild:!0,...e});zd.displayName=Fw;var kn="SelectContent",Fd=m.forwardRef((e,t)=>{const n=fn(kn,e.__scopeSelect),[r,o]=m.useState();if(qe(()=>{o(new DocumentFragment)},[]),!n.open){const a=r;return a?ps.createPortal(s.jsx(Ud,{scope:e.__scopeSelect,children:s.jsx(Cs.Slot,{scope:e.__scopeSelect,children:s.jsx("div",{children:e.children})})}),a):null}return s.jsx(Bd,{...e,ref:t})});Fd.displayName=kn;var Ct=10,[Ud,mn]=Qn(kn),Uw="SelectContentImpl",Bw=Lb("SelectContent.RemoveScroll"),Bd=m.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:a,onPointerDownOutside:i,side:c,sideOffset:l,align:d,alignOffset:f,arrowPadding:u,collisionBoundary:h,collisionPadding:g,sticky:y,hideWhenDetached:x,avoidCollisions:p,...v}=e,_=fn(kn,n),[w,b]=m.useState(null),[j,R]=m.useState(null),I=Ce(t,P=>b(P)),[C,E]=m.useState(null),[O,F]=m.useState(null),M=Ns(n),[U,D]=m.useState(!1),H=m.useRef(!1);m.useEffect(()=>{if(w)return Sd(w)},[w]),Xl();const z=m.useCallback(P=>{const[G,...ue]=M().map(ce=>ce.ref.current),[B]=ue.slice(-1),ae=document.activeElement;for(const ce of P)if(ce===ae||(ce?.scrollIntoView({block:"nearest"}),ce===G&&j&&(j.scrollTop=0),ce===B&&j&&(j.scrollTop=j.scrollHeight),ce?.focus(),document.activeElement!==ae))return},[M,j]),A=m.useCallback(()=>z([C,w]),[z,C,w]);m.useEffect(()=>{U&&A()},[U,A]);const{onOpenChange:N,triggerPointerDownPosRef:Z}=_;m.useEffect(()=>{if(w){let P={x:0,y:0};const G=B=>{P={x:Math.abs(Math.round(B.pageX)-(Z.current?.x??0)),y:Math.abs(Math.round(B.pageY)-(Z.current?.y??0))}},ue=B=>{P.x<=10&&P.y<=10?B.preventDefault():w.contains(B.target)||N(!1),document.removeEventListener("pointermove",G),Z.current=null};return Z.current!==null&&(document.addEventListener("pointermove",G),document.addEventListener("pointerup",ue,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",G),document.removeEventListener("pointerup",ue,{capture:!0})}}},[w,N,Z]),m.useEffect(()=>{const P=()=>N(!1);return window.addEventListener("blur",P),window.addEventListener("resize",P),()=>{window.removeEventListener("blur",P),window.removeEventListener("resize",P)}},[N]);const[te,re]=tu(P=>{const G=M().filter(ae=>!ae.disabled),ue=G.find(ae=>ae.ref.current===document.activeElement),B=nu(G,P,ue);B&&setTimeout(()=>B.ref.current.focus())}),de=m.useCallback((P,G,ue)=>{const B=!H.current&&!ue;(_.value!==void 0&&_.value===G||B)&&(E(P),B&&(H.current=!0))},[_.value]),W=m.useCallback(()=>w?.focus(),[w]),Q=m.useCallback((P,G,ue)=>{const B=!H.current&&!ue;(_.value!==void 0&&_.value===G||B)&&F(P)},[_.value]),q=r==="popper"?Ro:Vd,he=q===Ro?{side:c,sideOffset:l,align:d,alignOffset:f,arrowPadding:u,collisionBoundary:h,collisionPadding:g,sticky:y,hideWhenDetached:x,avoidCollisions:p}:{};return s.jsx(Ud,{scope:n,content:w,viewport:j,onViewportChange:R,itemRefCallback:de,selectedItem:C,onItemLeave:W,itemTextRefCallback:Q,focusSelectedItem:A,selectedItemText:O,position:r,isPositioned:U,searchRef:te,children:s.jsx(_a,{as:Bw,allowPinchZoom:!0,children:s.jsx(fa,{asChild:!0,trapped:_.open,onMountAutoFocus:P=>{P.preventDefault()},onUnmountAutoFocus:xe(o,P=>{_.trigger?.focus({preventScroll:!0}),P.preventDefault()}),children:s.jsx(ua,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:i,onFocusOutside:P=>P.preventDefault(),onDismiss:()=>_.onOpenChange(!1),children:s.jsx(q,{role:"listbox",id:_.contentId,"data-state":_.open?"open":"closed",dir:_.dir,onContextMenu:P=>P.preventDefault(),...v,...he,onPlaced:()=>D(!0),ref:I,style:{display:"flex",flexDirection:"column",outline:"none",...v.style},onKeyDown:xe(v.onKeyDown,P=>{const G=P.ctrlKey||P.altKey||P.metaKey;if(P.key==="Tab"&&P.preventDefault(),!G&&P.key.length===1&&re(P.key),["ArrowUp","ArrowDown","Home","End"].includes(P.key)){let B=M().filter(ae=>!ae.disabled).map(ae=>ae.ref.current);if(["ArrowUp","End"].includes(P.key)&&(B=B.slice().reverse()),["ArrowUp","ArrowDown"].includes(P.key)){const ae=P.target,ce=B.indexOf(ae);B=B.slice(ce+1)}setTimeout(()=>z(B)),P.preventDefault()}})})})})})})});Bd.displayName=Uw;var Vw="SelectItemAlignedPosition",Vd=m.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,a=fn(kn,n),i=mn(kn,n),[c,l]=m.useState(null),[d,f]=m.useState(null),u=Ce(t,I=>f(I)),h=Ns(n),g=m.useRef(!1),y=m.useRef(!0),{viewport:x,selectedItem:p,selectedItemText:v,focusSelectedItem:_}=i,w=m.useCallback(()=>{if(a.trigger&&a.valueNode&&c&&d&&x&&p&&v){const I=a.trigger.getBoundingClientRect(),C=d.getBoundingClientRect(),E=a.valueNode.getBoundingClientRect(),O=v.getBoundingClientRect();if(a.dir!=="rtl"){const ae=O.left-C.left,ce=E.left-ae,we=I.left-ce,Te=I.width+we,Ve=Math.max(Te,C.width),Ge=window.innerWidth-Ct,We=Hi(ce,[Ct,Math.max(Ct,Ge-Ve)]);c.style.minWidth=Te+"px",c.style.left=We+"px"}else{const ae=C.right-O.right,ce=window.innerWidth-E.right-ae,we=window.innerWidth-I.right-ce,Te=I.width+we,Ve=Math.max(Te,C.width),Ge=window.innerWidth-Ct,We=Hi(ce,[Ct,Math.max(Ct,Ge-Ve)]);c.style.minWidth=Te+"px",c.style.right=We+"px"}const F=h(),M=window.innerHeight-Ct*2,U=x.scrollHeight,D=window.getComputedStyle(d),H=parseInt(D.borderTopWidth,10),z=parseInt(D.paddingTop,10),A=parseInt(D.borderBottomWidth,10),N=parseInt(D.paddingBottom,10),Z=H+z+U+N+A,te=Math.min(p.offsetHeight*5,Z),re=window.getComputedStyle(x),de=parseInt(re.paddingTop,10),W=parseInt(re.paddingBottom,10),Q=I.top+I.height/2-Ct,q=M-Q,he=p.offsetHeight/2,P=p.offsetTop+he,G=H+z+P,ue=Z-G;if(G<=Q){const ae=F.length>0&&p===F[F.length-1].ref.current;c.style.bottom="0px";const ce=d.clientHeight-x.offsetTop-x.offsetHeight,we=Math.max(q,he+(ae?W:0)+ce+A),Te=G+we;c.style.height=Te+"px"}else{const ae=F.length>0&&p===F[0].ref.current;c.style.top="0px";const we=Math.max(Q,H+x.offsetTop+(ae?de:0)+he)+ue;c.style.height=we+"px",x.scrollTop=G-Q+x.offsetTop}c.style.margin=`${Ct}px 0`,c.style.minHeight=te+"px",c.style.maxHeight=M+"px",r?.(),requestAnimationFrame(()=>g.current=!0)}},[h,a.trigger,a.valueNode,c,d,x,p,v,a.dir,r]);qe(()=>w(),[w]);const[b,j]=m.useState();qe(()=>{d&&j(window.getComputedStyle(d).zIndex)},[d]);const R=m.useCallback(I=>{I&&y.current===!0&&(w(),_?.(),y.current=!1)},[w,_]);return s.jsx(Hw,{scope:n,contentWrapper:c,shouldExpandOnScrollRef:g,onScrollButtonChange:R,children:s.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:b},children:s.jsx(pe.div,{...o,ref:u,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Vd.displayName=Vw;var Ww="SelectPopperPosition",Ro=m.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=Ct,...a}=e,i=As(n);return s.jsx(Rb,{...i,...a,ref:t,align:r,collisionPadding:o,style:{boxSizing:"border-box",...a.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Ro.displayName=Ww;var[Hw,ka]=Qn(kn,{}),Oo="SelectViewport",Wd=m.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,a=mn(Oo,n),i=ka(Oo,n),c=Ce(t,a.onViewportChange),l=m.useRef(0);return s.jsxs(s.Fragment,{children:[s.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),s.jsx(Cs.Slot,{scope:n,children:s.jsx(pe.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:xe(o.onScroll,d=>{const f=d.currentTarget,{contentWrapper:u,shouldExpandOnScrollRef:h}=i;if(h?.current&&u){const g=Math.abs(l.current-f.scrollTop);if(g>0){const y=window.innerHeight-Ct*2,x=parseFloat(u.style.minHeight),p=parseFloat(u.style.height),v=Math.max(x,p);if(v<y){const _=v+g,w=Math.min(y,_),b=_-w;u.style.height=w+"px",u.style.bottom==="0px"&&(f.scrollTop=b>0?b:0,u.style.justifyContent="flex-end")}}}l.current=f.scrollTop})})})]})});Wd.displayName=Oo;var Hd="SelectGroup",[Zw,qw]=Qn(Hd),Zd=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Ft();return s.jsx(Zw,{scope:n,id:o,children:s.jsx(pe.div,{role:"group","aria-labelledby":o,...r,ref:t})})});Zd.displayName=Hd;var qd="SelectLabel",Gw=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=qw(qd,n);return s.jsx(pe.div,{id:o.id,...r,ref:t})});Gw.displayName=qd;var cs="SelectItem",[Yw,Gd]=Qn(cs),Yd=m.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:a,...i}=e,c=fn(cs,n),l=mn(cs,n),d=c.value===r,[f,u]=m.useState(a??""),[h,g]=m.useState(!1),y=Ce(t,_=>l.itemRefCallback?.(_,r,o)),x=Ft(),p=m.useRef("touch"),v=()=>{o||(c.onValueChange(r),c.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return s.jsx(Yw,{scope:n,value:r,disabled:o,textId:x,isSelected:d,onItemTextChange:m.useCallback(_=>{u(w=>w||(_?.textContent??"").trim())},[]),children:s.jsx(Cs.ItemSlot,{scope:n,value:r,disabled:o,textValue:f,children:s.jsx(pe.div,{role:"option","aria-labelledby":x,"data-highlighted":h?"":void 0,"aria-selected":d&&h,"data-state":d?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:y,onFocus:xe(i.onFocus,()=>g(!0)),onBlur:xe(i.onBlur,()=>g(!1)),onClick:xe(i.onClick,()=>{p.current!=="mouse"&&v()}),onPointerUp:xe(i.onPointerUp,()=>{p.current==="mouse"&&v()}),onPointerDown:xe(i.onPointerDown,_=>{p.current=_.pointerType}),onPointerMove:xe(i.onPointerMove,_=>{p.current=_.pointerType,o?l.onItemLeave?.():p.current==="mouse"&&_.currentTarget.focus({preventScroll:!0})}),onPointerLeave:xe(i.onPointerLeave,_=>{_.currentTarget===document.activeElement&&l.onItemLeave?.()}),onKeyDown:xe(i.onKeyDown,_=>{l.searchRef?.current!==""&&_.key===" "||(Ow.includes(_.key)&&v(),_.key===" "&&_.preventDefault())})})})})});Yd.displayName=cs;var cr="SelectItemText",Qd=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...a}=e,i=fn(cr,n),c=mn(cr,n),l=Gd(cr,n),d=$w(cr,n),[f,u]=m.useState(null),h=Ce(t,v=>u(v),l.onItemTextChange,v=>c.itemTextRefCallback?.(v,l.value,l.disabled)),g=f?.textContent,y=m.useMemo(()=>s.jsx("option",{value:l.value,disabled:l.disabled,children:g},l.value),[l.disabled,l.value,g]),{onNativeOptionAdd:x,onNativeOptionRemove:p}=d;return qe(()=>(x(y),()=>p(y)),[x,p,y]),s.jsxs(s.Fragment,{children:[s.jsx(pe.span,{id:l.textId,...a,ref:h}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?ps.createPortal(a.children,i.valueNode):null]})});Qd.displayName=cr;var Kd="SelectItemIndicator",Qw=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Gd(Kd,n).isSelected?s.jsx(pe.span,{"aria-hidden":!0,...r,ref:t}):null});Qw.displayName=Kd;var Mo="SelectScrollUpButton",Kw=m.forwardRef((e,t)=>{const n=mn(Mo,e.__scopeSelect),r=ka(Mo,e.__scopeSelect),[o,a]=m.useState(!1),i=Ce(t,r.onScrollButtonChange);return qe(()=>{if(n.viewport&&n.isPositioned){let c=function(){const d=l.scrollTop>0;a(d)};const l=n.viewport;return c(),l.addEventListener("scroll",c),()=>l.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),o?s.jsx(Jd,{...e,ref:i,onAutoScroll:()=>{const{viewport:c,selectedItem:l}=n;c&&l&&(c.scrollTop=c.scrollTop-l.offsetHeight)}}):null});Kw.displayName=Mo;var Lo="SelectScrollDownButton",Jw=m.forwardRef((e,t)=>{const n=mn(Lo,e.__scopeSelect),r=ka(Lo,e.__scopeSelect),[o,a]=m.useState(!1),i=Ce(t,r.onScrollButtonChange);return qe(()=>{if(n.viewport&&n.isPositioned){let c=function(){const d=l.scrollHeight-l.clientHeight,f=Math.ceil(l.scrollTop)<d;a(f)};const l=n.viewport;return c(),l.addEventListener("scroll",c),()=>l.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),o?s.jsx(Jd,{...e,ref:i,onAutoScroll:()=>{const{viewport:c,selectedItem:l}=n;c&&l&&(c.scrollTop=c.scrollTop+l.offsetHeight)}}):null});Jw.displayName=Lo;var Jd=m.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,a=mn("SelectScrollButton",n),i=m.useRef(null),c=Ns(n),l=m.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return m.useEffect(()=>()=>l(),[l]),qe(()=>{c().find(f=>f.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[c]),s.jsx(pe.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:xe(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:xe(o.onPointerMove,()=>{a.onItemLeave?.(),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:xe(o.onPointerLeave,()=>{l()})})}),Xw="SelectSeparator",e_=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return s.jsx(pe.div,{"aria-hidden":!0,...r,ref:t})});e_.displayName=Xw;var Do="SelectArrow",t_=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=As(n),a=fn(Do,n),i=mn(Do,n);return a.open&&i.position==="popper"?s.jsx(Ob,{...o,...r,ref:t}):null});t_.displayName=Do;var n_="SelectBubbleInput",Xd=m.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=m.useRef(null),a=Ce(r,o),i=Hb(t);return m.useEffect(()=>{const c=o.current;if(!c)return;const l=window.HTMLSelectElement.prototype,f=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&f){const u=new Event("change",{bubbles:!0});f.call(c,t),c.dispatchEvent(u)}},[i,t]),s.jsx(pe.select,{...n,style:{...kd,...n.style},ref:a,defaultValue:t})});Xd.displayName=n_;function eu(e){return e===""||e===void 0}function tu(e){const t=sn(e),n=m.useRef(""),r=m.useRef(0),o=m.useCallback(i=>{const c=n.current+i;t(c),(function l(d){n.current=d,window.clearTimeout(r.current),d!==""&&(r.current=window.setTimeout(()=>l(""),1e3))})(c)},[t]),a=m.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,a]}function nu(e,t,n){const o=t.length>1&&Array.from(t).every(d=>d===t[0])?t[0]:t,a=n?e.indexOf(n):-1;let i=r_(e,Math.max(a,0));o.length===1&&(i=i.filter(d=>d!==n));const l=i.find(d=>d.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function r_(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var s_=Rd,ru=Md,o_=Dd,a_=$d,i_=zd,su=Fd,c_=Wd,l_=Zd,ou=Yd,d_=Qd;const ls=s_,u_=l_,ds=o_,yr=m.forwardRef(({className:e,children:t,...n},r)=>s.jsxs(ru,{ref:r,className:L("flex h-10 w-full items-center justify-between rounded-md border border-neutral-200 bg-white px-3 py-2 text-sm text-neutral-950 shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-900/20 disabled:cursor-not-allowed disabled:opacity-50 dark:border-neutral-800 dark:bg-neutral-950 dark:text-neutral-50 dark:focus-visible:ring-neutral-50/20",e),...n,children:[t,s.jsx(a_,{className:"ml-2 text-neutral-500 dark:text-neutral-400",children:"▾"})]}));yr.displayName=ru.displayName;const br=m.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>s.jsx(i_,{children:s.jsx(su,{ref:o,position:n,className:L("z-50 min-w-[8rem] overflow-hidden rounded-md border border-neutral-200 bg-white text-neutral-950 shadow-md dark:border-neutral-800 dark:bg-neutral-950 dark:text-neutral-50",e),...r,children:s.jsx(c_,{className:L("p-1",n==="popper"?"w-full":void 0),children:t})})}));br.displayName=su.displayName;const wr=m.forwardRef(({className:e,children:t,...n},r)=>s.jsx(ou,{ref:r,className:L("relative flex w-full cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-neutral-100 data-[disabled]:pointer-events-none data-[disabled]:opacity-50 dark:focus:bg-neutral-800",e),...n,children:s.jsx(d_,{children:t})}));wr.displayName=ou.displayName;function f_(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var Kn=e=>{const{present:t,children:n}=e,r=m_(t),o=typeof n=="function"?n({present:r.isPresent}):m.Children.only(n),a=Ce(r.ref,p_(o));return typeof n=="function"||r.isPresent?m.cloneElement(o,{ref:a}):null};Kn.displayName="Presence";function m_(e){const[t,n]=m.useState(),r=m.useRef(null),o=m.useRef(e),a=m.useRef("none"),i=e?"mounted":"unmounted",[c,l]=f_(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{const d=Ur(r.current);a.current=c==="mounted"?d:"none"},[c]),qe(()=>{const d=r.current,f=o.current;if(f!==e){const h=a.current,g=Ur(d);e?l("MOUNT"):g==="none"||d?.display==="none"?l("UNMOUNT"):l(f&&h!==g?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),qe(()=>{if(t){let d;const f=t.ownerDocument.defaultView??window,u=g=>{const x=Ur(r.current).includes(CSS.escape(g.animationName));if(g.target===t&&x&&(l("ANIMATION_END"),!o.current)){const p=t.style.animationFillMode;t.style.animationFillMode="forwards",d=f.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=p)})}},h=g=>{g.target===t&&(a.current=Ur(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",u),t.addEventListener("animationend",u),()=>{f.clearTimeout(d),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",u),t.removeEventListener("animationend",u)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:m.useCallback(d=>{r.current=d?getComputedStyle(d):null,n(d)},[])}}function Ur(e){return e?.animationName||"none"}function p_(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function h_(e){const t=g_(e),n=m.forwardRef((r,o)=>{const{children:a,...i}=r,c=m.Children.toArray(a),l=c.find(v_);if(l){const d=l.props.children,f=c.map(u=>u===l?m.Children.count(d)>1?m.Children.only(null):m.isValidElement(d)?d.props.children:null:u);return s.jsx(t,{...i,ref:o,children:m.isValidElement(d)?m.cloneElement(d,void 0,f):null})}return s.jsx(t,{...i,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}function g_(e){const t=m.forwardRef((n,r)=>{const{children:o,...a}=n;if(m.isValidElement(o)){const i=b_(o),c=y_(a,o.props);return o.type!==m.Fragment&&(c.ref=r?Hn(r,i):i),m.cloneElement(o,c)}return m.Children.count(o)>1?m.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var x_=Symbol("radix.slottable");function v_(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===x_}function y_(e,t){const n={...t};for(const r in t){const o=e[r],a=t[r];/^on[A-Z]/.test(r)?o&&a?n[r]=(...c)=>{const l=a(...c);return o(...c),l}:o&&(n[r]=o):r==="style"?n[r]={...o,...a}:r==="className"&&(n[r]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function b_(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Es="Dialog",[au]=un(Es),[w_,Rt]=au(Es),iu=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:a,modal:i=!0}=e,c=m.useRef(null),l=m.useRef(null),[d,f]=cn({prop:r,defaultProp:o??!1,onChange:a,caller:Es});return s.jsx(w_,{scope:t,triggerRef:c,contentRef:l,contentId:Ft(),titleId:Ft(),descriptionId:Ft(),open:d,onOpenChange:f,onOpenToggle:m.useCallback(()=>f(u=>!u),[f]),modal:i,children:n})};iu.displayName=Es;var cu="DialogTrigger",lu=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Rt(cu,n),a=Ce(t,o.triggerRef);return s.jsx(pe.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Ca(o.open),...r,ref:a,onClick:xe(e.onClick,o.onOpenToggle)})});lu.displayName=cu;var ja="DialogPortal",[__,du]=au(ja,{forceMount:void 0}),uu=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,a=Rt(ja,t);return s.jsx(__,{scope:t,forceMount:n,children:m.Children.map(r,i=>s.jsx(Kn,{present:n||a.open,children:s.jsx(wa,{asChild:!0,container:o,children:i})}))})};uu.displayName=ja;var us="DialogOverlay",fu=m.forwardRef((e,t)=>{const n=du(us,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,a=Rt(us,e.__scopeDialog);return a.modal?s.jsx(Kn,{present:r||a.open,children:s.jsx(j_,{...o,ref:t})}):null});fu.displayName=us;var k_=h_("DialogOverlay.RemoveScroll"),j_=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Rt(us,n);return s.jsx(_a,{as:k_,allowPinchZoom:!0,shards:[o.contentRef],children:s.jsx(pe.div,{"data-state":Ca(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),jn="DialogContent",mu=m.forwardRef((e,t)=>{const n=du(jn,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,a=Rt(jn,e.__scopeDialog);return s.jsx(Kn,{present:r||a.open,children:a.modal?s.jsx(S_,{...o,ref:t}):s.jsx(C_,{...o,ref:t})})});mu.displayName=jn;var S_=m.forwardRef((e,t)=>{const n=Rt(jn,e.__scopeDialog),r=m.useRef(null),o=Ce(t,n.contentRef,r);return m.useEffect(()=>{const a=r.current;if(a)return Sd(a)},[]),s.jsx(pu,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:xe(e.onCloseAutoFocus,a=>{a.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:xe(e.onPointerDownOutside,a=>{const i=a.detail.originalEvent,c=i.button===0&&i.ctrlKey===!0;(i.button===2||c)&&a.preventDefault()}),onFocusOutside:xe(e.onFocusOutside,a=>a.preventDefault())})}),C_=m.forwardRef((e,t)=>{const n=Rt(jn,e.__scopeDialog),r=m.useRef(!1),o=m.useRef(!1);return s.jsx(pu,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{e.onCloseAutoFocus?.(a),a.defaultPrevented||(r.current||n.triggerRef.current?.focus(),a.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:a=>{e.onInteractOutside?.(a),a.defaultPrevented||(r.current=!0,a.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=a.target;n.triggerRef.current?.contains(i)&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&o.current&&a.preventDefault()}})}),pu=m.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:a,...i}=e,c=Rt(jn,n),l=m.useRef(null),d=Ce(t,l);return Xl(),s.jsxs(s.Fragment,{children:[s.jsx(fa,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:a,children:s.jsx(ua,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":Ca(c.open),...i,ref:d,onDismiss:()=>c.onOpenChange(!1)})}),s.jsxs(s.Fragment,{children:[s.jsx(N_,{titleId:c.titleId}),s.jsx(E_,{contentRef:l,descriptionId:c.descriptionId})]})]})}),Sa="DialogTitle",hu=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Rt(Sa,n);return s.jsx(pe.h2,{id:o.titleId,...r,ref:t})});hu.displayName=Sa;var gu="DialogDescription",xu=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Rt(gu,n);return s.jsx(pe.p,{id:o.descriptionId,...r,ref:t})});xu.displayName=gu;var vu="DialogClose",yu=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Rt(vu,n);return s.jsx(pe.button,{type:"button",...r,ref:t,onClick:xe(e.onClick,()=>o.onOpenChange(!1))})});yu.displayName=vu;function Ca(e){return e?"open":"closed"}var bu="DialogTitleWarning",[Vj,wu]=Ry(bu,{contentName:jn,titleName:Sa,docsSlug:"dialog"}),N_=({titleId:e})=>{const t=wu(bu),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
80
80
|
|
|
81
81
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
82
82
|
|
|
83
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return m.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},S_="DialogDescriptionWarning",C_=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${bu(S_).contentName}}.`;return m.useEffect(()=>{const o=e.current?.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},wu=au,_u=cu,ku=du,Is=uu,Ts=fu,Ps=pu,Rs=gu,ju=vu;const Na=wu,N_=_u,Su=ku,A_=ju,Aa=m.forwardRef(({className:e,...t},n)=>s.jsx(Is,{ref:n,className:L("fixed inset-0 z-50 bg-neutral-950/40 backdrop-blur-sm transition-opacity data-[state=closed]:opacity-0 data-[state=open]:opacity-100",e),...t}));Aa.displayName=Is.displayName;const Os=m.forwardRef(({className:e,children:t,...n},r)=>s.jsxs(Su,{children:[s.jsx(Aa,{}),s.jsx(Ts,{ref:r,className:L("fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg -translate-x-1/2 -translate-y-1/2 gap-4 border border-neutral-200 bg-white p-6 shadow-lg outline-none transition data-[state=closed]:opacity-0 data-[state=closed]:scale-95 data-[state=open]:opacity-100 data-[state=open]:scale-100 dark:border-neutral-800 dark:bg-neutral-950","rounded-2xl",e),...n,children:t})]}));Os.displayName=Ts.displayName;const Ea=({className:e,...t})=>s.jsx("div",{className:L("flex flex-col space-y-2 text-center sm:text-left",e),...t}),Cu=({className:e,...t})=>s.jsx("div",{className:L("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t}),Ms=m.forwardRef(({className:e,...t},n)=>s.jsx(Ps,{ref:n,className:L("text-lg font-semibold leading-none tracking-tight",e),...t}));Ms.displayName=Ps.displayName;const Ia=m.forwardRef(({className:e,...t},n)=>s.jsx(Rs,{ref:n,className:L("text-sm text-neutral-500 dark:text-neutral-400",e),...t}));Ia.displayName=Rs.displayName;const Ls=wu,Ds=_u,Nu=ju,Au=ku,Ta=m.forwardRef(({className:e,...t},n)=>s.jsx(Is,{ref:n,className:L("fixed inset-0 z-50 bg-neutral-950/40 backdrop-blur-sm transition-opacity data-[state=closed]:opacity-0 data-[state=open]:opacity-100",e),...t}));Ta.displayName=Is.displayName;const E_=ca("fixed z-50 gap-4 bg-white p-6 shadow-lg outline-none transition duration-200 ease-out dark:bg-neutral-950",{variants:{side:{top:"inset-x-0 top-0 border-b border-neutral-200 data-[state=closed]:-translate-y-full data-[state=open]:translate-y-0 dark:border-neutral-800",bottom:"inset-x-0 bottom-0 border-t border-neutral-200 data-[state=closed]:translate-y-full data-[state=open]:translate-y-0 dark:border-neutral-800",left:"inset-y-0 left-0 h-full w-3/4 border-r border-neutral-200 data-[state=closed]:-translate-x-full data-[state=open]:translate-x-0 sm:max-w-sm dark:border-neutral-800",right:"inset-y-0 right-0 h-full w-3/4 border-l border-neutral-200 data-[state=closed]:translate-x-full data-[state=open]:translate-x-0 sm:max-w-sm dark:border-neutral-800",popup:"bottom-4 right-4 w-[420px] max-w-[calc(100vw-2rem)] max-h-[calc(100vh-2rem)] overflow-hidden rounded-2xl border border-neutral-200 p-4 data-[state=closed]:translate-y-2 data-[state=open]:translate-y-0 data-[state=closed]:opacity-0 data-[state=open]:opacity-100 data-[state=closed]:scale-95 data-[state=open]:scale-100 dark:border-neutral-800"}},defaultVariants:{side:"right"}}),Nr=m.forwardRef(({side:e="right",className:t,children:n,overlayClassName:r,...o},a)=>s.jsxs(Au,{children:[s.jsx(Ta,{className:r}),s.jsx(Ts,{ref:a,className:L(E_({side:e}),t),...o,children:n})]}));Nr.displayName=Ts.displayName;const $s=({className:e,...t})=>s.jsx("div",{className:L("flex flex-col space-y-2 text-left",e),...t}),zs=m.forwardRef(({className:e,...t},n)=>s.jsx(Ps,{ref:n,className:L("text-lg font-semibold leading-none tracking-tight",e),...t}));zs.displayName=Ps.displayName;const Eu=m.forwardRef(({className:e,...t},n)=>s.jsx(Rs,{ref:n,className:L("text-sm text-neutral-500 dark:text-neutral-400",e),...t}));Eu.displayName=Rs.displayName;var Fs="Collapsible",[I_,Iu]=un(Fs),[T_,Pa]=I_(Fs),Tu=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:a,onOpenChange:i,...c}=e,[l,d]=cn({prop:r,defaultProp:o??!1,onChange:i,caller:Fs});return s.jsx(T_,{scope:n,disabled:a,contentId:Ut(),open:l,onOpenToggle:m.useCallback(()=>d(f=>!f),[d]),children:s.jsx(pe.div,{"data-state":Oa(l),"data-disabled":a?"":void 0,...c,ref:t})})});Tu.displayName=Fs;var Pu="CollapsibleTrigger",Ru=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=Pa(Pu,n);return s.jsx(pe.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":Oa(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:xe(e.onClick,o.onOpenToggle)})});Ru.displayName=Pu;var Ra="CollapsibleContent",Ou=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Pa(Ra,e.__scopeCollapsible);return s.jsx(Kn,{present:n||o.open,children:({present:a})=>s.jsx(P_,{...r,ref:t,present:a})})});Ou.displayName=Ra;var P_=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...a}=e,i=Pa(Ra,n),[c,l]=m.useState(r),d=m.useRef(null),f=Ce(t,d),u=m.useRef(0),h=u.current,g=m.useRef(0),y=g.current,x=i.open||c,p=m.useRef(x),v=m.useRef(void 0);return m.useEffect(()=>{const _=requestAnimationFrame(()=>p.current=!1);return()=>cancelAnimationFrame(_)},[]),qe(()=>{const _=d.current;if(_){v.current=v.current||{transitionDuration:_.style.transitionDuration,animationName:_.style.animationName},_.style.transitionDuration="0s",_.style.animationName="none";const w=_.getBoundingClientRect();u.current=w.height,g.current=w.width,p.current||(_.style.transitionDuration=v.current.transitionDuration,_.style.animationName=v.current.animationName),l(r)}},[i.open,r]),s.jsx(pe.div,{"data-state":Oa(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!x,...a,ref:f,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":y?`${y}px`:void 0,...e.style},children:x&&o})});function Oa(e){return e?"open":"closed"}var R_=Tu,O_=Ru,M_=Ou,Mt="Accordion",L_=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[Ma,D_,$_]=da(Mt),[Us]=un(Mt,[$_,Iu]),La=Iu(),Mu=k.forwardRef((e,t)=>{const{type:n,...r}=e,o=r,a=r;return s.jsx(Ma.Provider,{scope:e.__scopeAccordion,children:n==="multiple"?s.jsx(B_,{...a,ref:t}):s.jsx(U_,{...o,ref:t})})});Mu.displayName=Mt;var[Lu,z_]=Us(Mt),[Du,F_]=Us(Mt,{collapsible:!1}),U_=k.forwardRef((e,t)=>{const{value:n,defaultValue:r,onValueChange:o=()=>{},collapsible:a=!1,...i}=e,[c,l]=cn({prop:n,defaultProp:r??"",onChange:o,caller:Mt});return s.jsx(Lu,{scope:e.__scopeAccordion,value:k.useMemo(()=>c?[c]:[],[c]),onItemOpen:l,onItemClose:k.useCallback(()=>a&&l(""),[a,l]),children:s.jsx(Du,{scope:e.__scopeAccordion,collapsible:a,children:s.jsx($u,{...i,ref:t})})})}),B_=k.forwardRef((e,t)=>{const{value:n,defaultValue:r,onValueChange:o=()=>{},...a}=e,[i,c]=cn({prop:n,defaultProp:r??[],onChange:o,caller:Mt}),l=k.useCallback(f=>c((u=[])=>[...u,f]),[c]),d=k.useCallback(f=>c((u=[])=>u.filter(h=>h!==f)),[c]);return s.jsx(Lu,{scope:e.__scopeAccordion,value:i,onItemOpen:l,onItemClose:d,children:s.jsx(Du,{scope:e.__scopeAccordion,collapsible:!0,children:s.jsx($u,{...a,ref:t})})})}),[V_,Bs]=Us(Mt),$u=k.forwardRef((e,t)=>{const{__scopeAccordion:n,disabled:r,dir:o,orientation:a="vertical",...i}=e,c=k.useRef(null),l=Ce(c,t),d=D_(n),u=bs(o)==="ltr",h=xe(e.onKeyDown,g=>{if(!L_.includes(g.key))return;const y=g.target,x=d().filter(C=>!C.ref.current?.disabled),p=x.findIndex(C=>C.ref.current===y),v=x.length;if(p===-1)return;g.preventDefault();let _=p;const w=0,b=v-1,j=()=>{_=p+1,_>b&&(_=w)},R=()=>{_=p-1,_<w&&(_=b)};switch(g.key){case"Home":_=w;break;case"End":_=b;break;case"ArrowRight":a==="horizontal"&&(u?j():R());break;case"ArrowDown":a==="vertical"&&j();break;case"ArrowLeft":a==="horizontal"&&(u?R():j());break;case"ArrowUp":a==="vertical"&&R();break}const I=_%v;x[I].ref.current?.focus()});return s.jsx(V_,{scope:n,disabled:r,direction:o,orientation:a,children:s.jsx(Ma.Slot,{scope:n,children:s.jsx(pe.div,{...i,"data-orientation":a,ref:l,onKeyDown:r?void 0:h})})})}),fs="AccordionItem",[W_,Da]=Us(fs),zu=k.forwardRef((e,t)=>{const{__scopeAccordion:n,value:r,...o}=e,a=Bs(fs,n),i=z_(fs,n),c=La(n),l=Ut(),d=r&&i.value.includes(r)||!1,f=a.disabled||e.disabled;return s.jsx(W_,{scope:n,open:d,disabled:f,triggerId:l,children:s.jsx(R_,{"data-orientation":a.orientation,"data-state":Hu(d),...c,...o,ref:t,disabled:f,open:d,onOpenChange:u=>{u?i.onItemOpen(r):i.onItemClose(r)}})})});zu.displayName=fs;var Fu="AccordionHeader",Uu=k.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,o=Bs(Mt,n),a=Da(Fu,n);return s.jsx(pe.h3,{"data-orientation":o.orientation,"data-state":Hu(a.open),"data-disabled":a.disabled?"":void 0,...r,ref:t})});Uu.displayName=Fu;var $o="AccordionTrigger",Bu=k.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,o=Bs(Mt,n),a=Da($o,n),i=F_($o,n),c=La(n);return s.jsx(Ma.ItemSlot,{scope:n,children:s.jsx(O_,{"aria-disabled":a.open&&!i.collapsible||void 0,"data-orientation":o.orientation,id:a.triggerId,...c,...r,ref:t})})});Bu.displayName=$o;var Vu="AccordionContent",Wu=k.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,o=Bs(Mt,n),a=Da(Vu,n),i=La(n);return s.jsx(M_,{role:"region","aria-labelledby":a.triggerId,"data-orientation":o.orientation,...i,...r,ref:t,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...e.style}})});Wu.displayName=Vu;function Hu(e){return e?"open":"closed"}var H_=Mu,Zu=zu,Z_=Uu,qu=Bu,Gu=Wu;const Yu=H_,dr=m.forwardRef(({className:e,...t},n)=>s.jsx(Zu,{ref:n,className:L("border-b border-neutral-200 dark:border-neutral-800",e),...t}));dr.displayName=Zu.displayName;const ur=m.forwardRef(({className:e,children:t,...n},r)=>s.jsx(Z_,{className:"flex",children:s.jsxs(qu,{ref:r,className:L("flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline",e),...n,children:[t,s.jsx("span",{className:"ml-3 text-neutral-500 dark:text-neutral-400","aria-hidden":!0,children:"▾"})]})}));ur.displayName=qu.displayName;const fr=m.forwardRef(({className:e,children:t,...n},r)=>s.jsx(Gu,{ref:r,className:L("overflow-hidden text-sm",e),...n,children:s.jsx("div",{className:"pb-4 pt-0",children:t})}));fr.displayName=Gu.displayName;var mo="rovingFocusGroup.onEntryFocus",q_={bubbles:!1,cancelable:!0},Ar="RovingFocusGroup",[zo,Qu,G_]=da(Ar),[Y_,Ku]=un(Ar,[G_]),[Q_,K_]=Y_(Ar),Ju=m.forwardRef((e,t)=>s.jsx(zo.Provider,{scope:e.__scopeRovingFocusGroup,children:s.jsx(zo.Slot,{scope:e.__scopeRovingFocusGroup,children:s.jsx(J_,{...e,ref:t})})}));Ju.displayName=Ar;var J_=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:a,currentTabStopId:i,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:l,onEntryFocus:d,preventScrollOnEntryFocus:f=!1,...u}=e,h=m.useRef(null),g=Ce(t,h),y=bs(a),[x,p]=cn({prop:i,defaultProp:c??null,onChange:l,caller:Ar}),[v,_]=m.useState(!1),w=sn(d),b=Qu(n),j=m.useRef(!1),[R,I]=m.useState(0);return m.useEffect(()=>{const C=h.current;if(C)return C.addEventListener(mo,w),()=>C.removeEventListener(mo,w)},[w]),s.jsx(Q_,{scope:n,orientation:r,dir:y,loop:o,currentTabStopId:x,onItemFocus:m.useCallback(C=>p(C),[p]),onItemShiftTab:m.useCallback(()=>_(!0),[]),onFocusableItemAdd:m.useCallback(()=>I(C=>C+1),[]),onFocusableItemRemove:m.useCallback(()=>I(C=>C-1),[]),children:s.jsx(pe.div,{tabIndex:v||R===0?-1:0,"data-orientation":r,...u,ref:g,style:{outline:"none",...e.style},onMouseDown:xe(e.onMouseDown,()=>{j.current=!0}),onFocus:xe(e.onFocus,C=>{const E=!j.current;if(C.target===C.currentTarget&&E&&!v){const O=new CustomEvent(mo,q_);if(C.currentTarget.dispatchEvent(O),!O.defaultPrevented){const F=b().filter(z=>z.focusable),M=F.find(z=>z.active),U=F.find(z=>z.id===x),H=[M,U,...F].filter(Boolean).map(z=>z.ref.current);tf(H,f)}}j.current=!1}),onBlur:xe(e.onBlur,()=>_(!1))})})}),Xu="RovingFocusGroupItem",ef=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:a,children:i,...c}=e,l=Ut(),d=a||l,f=K_(Xu,n),u=f.currentTabStopId===d,h=Qu(n),{onFocusableItemAdd:g,onFocusableItemRemove:y,currentTabStopId:x}=f;return m.useEffect(()=>{if(r)return g(),()=>y()},[r,g,y]),s.jsx(zo.ItemSlot,{scope:n,id:d,focusable:r,active:o,children:s.jsx(pe.span,{tabIndex:u?0:-1,"data-orientation":f.orientation,...c,ref:t,onMouseDown:xe(e.onMouseDown,p=>{r?f.onItemFocus(d):p.preventDefault()}),onFocus:xe(e.onFocus,()=>f.onItemFocus(d)),onKeyDown:xe(e.onKeyDown,p=>{if(p.key==="Tab"&&p.shiftKey){f.onItemShiftTab();return}if(p.target!==p.currentTarget)return;const v=tk(p,f.orientation,f.dir);if(v!==void 0){if(p.metaKey||p.ctrlKey||p.altKey||p.shiftKey)return;p.preventDefault();let w=h().filter(b=>b.focusable).map(b=>b.ref.current);if(v==="last")w.reverse();else if(v==="prev"||v==="next"){v==="prev"&&w.reverse();const b=w.indexOf(p.currentTarget);w=f.loop?nk(w,b+1):w.slice(b+1)}setTimeout(()=>tf(w))}}),children:typeof i=="function"?i({isCurrentTabStop:u,hasTabStop:x!=null}):i})})});ef.displayName=Xu;var X_={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function ek(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function tk(e,t,n){const r=ek(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return X_[r]}function tf(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function nk(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var rk=Ju,sk=ef,Vs="Tabs",[ok]=un(Vs,[Ku]),nf=Ku(),[ak,$a]=ok(Vs),rf=m.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:o,defaultValue:a,orientation:i="horizontal",dir:c,activationMode:l="automatic",...d}=e,f=bs(c),[u,h]=cn({prop:r,onChange:o,defaultProp:a??"",caller:Vs});return s.jsx(ak,{scope:n,baseId:Ut(),value:u,onValueChange:h,orientation:i,dir:f,activationMode:l,children:s.jsx(pe.div,{dir:f,"data-orientation":i,...d,ref:t})})});rf.displayName=Vs;var sf="TabsList",of=m.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...o}=e,a=$a(sf,n),i=nf(n);return s.jsx(rk,{asChild:!0,...i,orientation:a.orientation,dir:a.dir,loop:r,children:s.jsx(pe.div,{role:"tablist","aria-orientation":a.orientation,...o,ref:t})})});of.displayName=sf;var af="TabsTrigger",cf=m.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:o=!1,...a}=e,i=$a(af,n),c=nf(n),l=uf(i.baseId,r),d=ff(i.baseId,r),f=r===i.value;return s.jsx(sk,{asChild:!0,...c,focusable:!o,active:f,children:s.jsx(pe.button,{type:"button",role:"tab","aria-selected":f,"aria-controls":d,"data-state":f?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:l,...a,ref:t,onMouseDown:xe(e.onMouseDown,u=>{!o&&u.button===0&&u.ctrlKey===!1?i.onValueChange(r):u.preventDefault()}),onKeyDown:xe(e.onKeyDown,u=>{[" ","Enter"].includes(u.key)&&i.onValueChange(r)}),onFocus:xe(e.onFocus,()=>{const u=i.activationMode!=="manual";!f&&!o&&u&&i.onValueChange(r)})})})});cf.displayName=af;var lf="TabsContent",df=m.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:o,children:a,...i}=e,c=$a(lf,n),l=uf(c.baseId,r),d=ff(c.baseId,r),f=r===c.value,u=m.useRef(f);return m.useEffect(()=>{const h=requestAnimationFrame(()=>u.current=!1);return()=>cancelAnimationFrame(h)},[]),s.jsx(Kn,{present:o||f,children:({present:h})=>s.jsx(pe.div,{"data-state":f?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":l,hidden:!h,id:d,tabIndex:0,...i,ref:t,style:{...e.style,animationDuration:u.current?"0s":void 0},children:h&&a})})});df.displayName=lf;function uf(e,t){return`${e}-trigger-${t}`}function ff(e,t){return`${e}-content-${t}`}var ik=rf,mf=of,pf=cf,hf=df;const za=ik,Ws=m.forwardRef(({className:e,...t},n)=>s.jsx(mf,{ref:n,className:L("inline-flex h-10 items-center justify-center rounded-md bg-neutral-100 p-1 text-neutral-500 dark:bg-neutral-800 dark:text-neutral-400",e),...t}));Ws.displayName=mf.displayName;const _r=m.forwardRef(({className:e,...t},n)=>s.jsx(pf,{ref:n,className:L("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-white transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-900/20 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-white data-[state=active]:text-neutral-950 data-[state=active]:shadow-sm dark:ring-offset-neutral-950 dark:focus-visible:ring-neutral-50/20 dark:data-[state=active]:bg-neutral-950 dark:data-[state=active]:text-neutral-50",e),...t}));_r.displayName=pf.displayName;const gf=m.forwardRef(({className:e,...t},n)=>s.jsx(hf,{ref:n,className:L("mt-2 ring-offset-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-900/20 dark:ring-offset-neutral-950 dark:focus-visible:ring-neutral-50/20",e),...t}));gf.displayName=hf.displayName;function Bn({title:e,description:t,actionLabel:n,onAction:r,className:o}){return s.jsx("div",{className:L("flex flex-col items-center justify-center rounded-xl border border-neutral-200 bg-white p-10 text-center dark:border-neutral-800 dark:bg-neutral-950",o),children:s.jsxs("div",{className:"max-w-sm",children:[s.jsx("h3",{className:"text-base font-semibold text-neutral-950 dark:text-neutral-50",children:e}),t?s.jsx("p",{className:"mt-2 text-sm text-neutral-600 dark:text-neutral-400",children:t}):null,n&&r?s.jsx("div",{className:"mt-5",children:s.jsx(ne,{type:"button",onClick:r,variant:"secondary",children:n})}):null]})})}function Vt({title:e,description:t,onRetry:n,className:r}){return s.jsxs("div",{className:L("rounded-xl border border-neutral-200 bg-white p-6 text-neutral-950 dark:border-neutral-800 dark:bg-neutral-950 dark:text-neutral-50",r),children:[s.jsx("h3",{className:"text-sm font-semibold",children:e??"Something went wrong"}),s.jsx("p",{className:"mt-2 text-sm text-neutral-600 dark:text-neutral-400",children:t}),n?s.jsx("div",{className:"mt-4",children:s.jsx(ne,{type:"button",variant:"outline",onClick:n,children:"Try again"})}):null]})}class ck extends m.Component{state={error:null};static getDerivedStateFromError(t){return{error:t}}render(){return this.state.error?this.props.fallback?this.props.fallback(this.state.error):s.jsx(Vt,{description:this.state.error.message}):this.props.children}}function lk(e){if(typeof document>"u")return;let t=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}const dk=e=>{switch(e){case"success":return mk;case"info":return hk;case"warning":return pk;case"error":return gk;default:return null}},uk=Array(12).fill(0),fk=({visible:e,className:t})=>k.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},k.createElement("div",{className:"sonner-spinner"},uk.map((n,r)=>k.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),mk=k.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},k.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),pk=k.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},k.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),hk=k.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},k.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),gk=k.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},k.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),xk=k.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},k.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),k.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),vk=()=>{const[e,t]=k.useState(document.hidden);return k.useEffect(()=>{const n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e};let Fo=1;class yk{constructor(){this.subscribe=t=>(this.subscribers.push(t),()=>{const n=this.subscribers.indexOf(t);this.subscribers.splice(n,1)}),this.publish=t=>{this.subscribers.forEach(n=>n(t))},this.addToast=t=>{this.publish(t),this.toasts=[...this.toasts,t]},this.create=t=>{var n;const{message:r,...o}=t,a=typeof t?.id=="number"||((n=t.id)==null?void 0:n.length)>0?t.id:Fo++,i=this.toasts.find(l=>l.id===a),c=t.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(a)&&this.dismissedToasts.delete(a),i?this.toasts=this.toasts.map(l=>l.id===a?(this.publish({...l,...t,id:a,title:r}),{...l,...t,id:a,dismissible:c,title:r}):l):this.addToast({title:r,...o,dismissible:c,id:a}),a},this.dismiss=t=>(t?(this.dismissedToasts.add(t),requestAnimationFrame(()=>this.subscribers.forEach(n=>n({id:t,dismiss:!0})))):this.toasts.forEach(n=>{this.subscribers.forEach(r=>r({id:n.id,dismiss:!0}))}),t),this.message=(t,n)=>this.create({...n,message:t}),this.error=(t,n)=>this.create({...n,message:t,type:"error"}),this.success=(t,n)=>this.create({...n,type:"success",message:t}),this.info=(t,n)=>this.create({...n,type:"info",message:t}),this.warning=(t,n)=>this.create({...n,type:"warning",message:t}),this.loading=(t,n)=>this.create({...n,type:"loading",message:t}),this.promise=(t,n)=>{if(!n)return;let r;n.loading!==void 0&&(r=this.create({...n,promise:t,type:"loading",message:n.loading,description:typeof n.description!="function"?n.description:void 0}));const o=Promise.resolve(t instanceof Function?t():t);let a=r!==void 0,i;const c=o.then(async d=>{if(i=["resolve",d],k.isValidElement(d))a=!1,this.create({id:r,type:"default",message:d});else if(wk(d)&&!d.ok){a=!1;const u=typeof n.error=="function"?await n.error(`HTTP error! status: ${d.status}`):n.error,h=typeof n.description=="function"?await n.description(`HTTP error! status: ${d.status}`):n.description,y=typeof u=="object"&&!k.isValidElement(u)?u:{message:u};this.create({id:r,type:"error",description:h,...y})}else if(d instanceof Error){a=!1;const u=typeof n.error=="function"?await n.error(d):n.error,h=typeof n.description=="function"?await n.description(d):n.description,y=typeof u=="object"&&!k.isValidElement(u)?u:{message:u};this.create({id:r,type:"error",description:h,...y})}else if(n.success!==void 0){a=!1;const u=typeof n.success=="function"?await n.success(d):n.success,h=typeof n.description=="function"?await n.description(d):n.description,y=typeof u=="object"&&!k.isValidElement(u)?u:{message:u};this.create({id:r,type:"success",description:h,...y})}}).catch(async d=>{if(i=["reject",d],n.error!==void 0){a=!1;const f=typeof n.error=="function"?await n.error(d):n.error,u=typeof n.description=="function"?await n.description(d):n.description,g=typeof f=="object"&&!k.isValidElement(f)?f:{message:f};this.create({id:r,type:"error",description:u,...g})}}).finally(()=>{a&&(this.dismiss(r),r=void 0),n.finally==null||n.finally.call(n)}),l=()=>new Promise((d,f)=>c.then(()=>i[0]==="reject"?f(i[1]):d(i[1])).catch(f));return typeof r!="string"&&typeof r!="number"?{unwrap:l}:Object.assign(r,{unwrap:l})},this.custom=(t,n)=>{const r=n?.id||Fo++;return this.create({jsx:t(r),id:r,...n}),r},this.getActiveToasts=()=>this.toasts.filter(t=>!this.dismissedToasts.has(t.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}}const dt=new yk,bk=(e,t)=>{const n=t?.id||Fo++;return dt.addToast({title:e,...t,id:n}),n},wk=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",_k=bk,kk=()=>dt.toasts,jk=()=>dt.getActiveToasts(),Sk=Object.assign(_k,{success:dt.success,info:dt.info,warning:dt.warning,error:dt.error,custom:dt.custom,message:dt.message,promise:dt.promise,dismiss:dt.dismiss,loading:dt.loading},{getHistory:kk,getToasts:jk});lk("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");function Br(e){return e.label!==void 0}const Ck=3,Nk="24px",Ak="16px",gc=4e3,Ek=356,Ik=14,Tk=45,Pk=200;function Dt(...e){return e.filter(Boolean).join(" ")}function Rk(e){const[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}const Ok=e=>{var t,n,r,o,a,i,c,l,d;const{invert:f,toast:u,unstyled:h,interacting:g,setHeights:y,visibleToasts:x,heights:p,index:v,toasts:_,expanded:w,removeToast:b,defaultRichColors:j,closeButton:R,style:I,cancelButtonStyle:C,actionButtonStyle:E,className:O="",descriptionClassName:F="",duration:M,position:U,gap:D,expandByDefault:H,classNames:z,icons:A,closeButtonAriaLabel:N="Close toast"}=e,[Z,te]=k.useState(null),[re,de]=k.useState(null),[W,Q]=k.useState(!1),[q,he]=k.useState(!1),[P,G]=k.useState(!1),[ue,B]=k.useState(!1),[ae,ce]=k.useState(!1),[we,Te]=k.useState(0),[Ve,Ge]=k.useState(0),We=k.useRef(u.duration||M||gc),_t=k.useRef(null),Ye=k.useRef(null),en=v===0,xt=v+1<=x,je=u.type,Xe=u.dismissible!==!1,_e=u.className||"",qt=u.descriptionClassName||"",ft=k.useMemo(()=>p.findIndex(le=>le.toastId===u.id)||0,[p,u.id]),it=k.useMemo(()=>{var le;return(le=u.closeButton)!=null?le:R},[u.closeButton,R]),T=k.useMemo(()=>u.duration||M||gc,[u.duration,M]),K=k.useRef(0),se=k.useRef(0),ve=k.useRef(0),ye=k.useRef(null),[Pe,Cn]=U.split("-"),vt=k.useMemo(()=>p.reduce((le,Le,ge)=>ge>=ft?le:le+Le.height,0),[p,ft]),Gt=vk(),Jn=u.invert||f,pn=je==="loading";se.current=k.useMemo(()=>ft*D+vt,[ft,vt]),k.useEffect(()=>{We.current=T},[T]),k.useEffect(()=>{Q(!0)},[]),k.useEffect(()=>{const le=Ye.current;if(le){const Le=le.getBoundingClientRect().height;return Ge(Le),y(ge=>[{toastId:u.id,height:Le,position:u.position},...ge]),()=>y(ge=>ge.filter(De=>De.toastId!==u.id))}},[y,u.id]),k.useLayoutEffect(()=>{if(!W)return;const le=Ye.current,Le=le.style.height;le.style.height="auto";const ge=le.getBoundingClientRect().height;le.style.height=Le,Ge(ge),y(De=>De.find($e=>$e.toastId===u.id)?De.map($e=>$e.toastId===u.id?{...$e,height:ge}:$e):[{toastId:u.id,height:ge,position:u.position},...De])},[W,u.title,u.description,y,u.id,u.jsx,u.action,u.cancel]);const Lt=k.useCallback(()=>{he(!0),Te(se.current),y(le=>le.filter(Le=>Le.toastId!==u.id)),setTimeout(()=>{b(u)},Pk)},[u,b,y,se]);k.useEffect(()=>{if(u.promise&&je==="loading"||u.duration===1/0||u.type==="loading")return;let le;return w||g||Gt?(()=>{if(ve.current<K.current){const De=new Date().getTime()-K.current;We.current=We.current-De}ve.current=new Date().getTime()})():(()=>{We.current!==1/0&&(K.current=new Date().getTime(),le=setTimeout(()=>{u.onAutoClose==null||u.onAutoClose.call(u,u),Lt()},We.current))})(),()=>clearTimeout(le)},[w,g,u,je,Gt,Lt]),k.useEffect(()=>{u.delete&&(Lt(),u.onDismiss==null||u.onDismiss.call(u,u))},[Lt,u.delete]);function Nn(){var le;if(A?.loading){var Le;return k.createElement("div",{className:Dt(z?.loader,u==null||(Le=u.classNames)==null?void 0:Le.loader,"sonner-loader"),"data-visible":je==="loading"},A.loading)}return k.createElement(fk,{className:Dt(z?.loader,u==null||(le=u.classNames)==null?void 0:le.loader),visible:je==="loading"})}const An=u.icon||A?.[je]||dk(je);var Er,tn;return k.createElement("li",{tabIndex:0,ref:Ye,className:Dt(O,_e,z?.toast,u==null||(t=u.classNames)==null?void 0:t.toast,z?.default,z?.[je],u==null||(n=u.classNames)==null?void 0:n[je]),"data-sonner-toast":"","data-rich-colors":(Er=u.richColors)!=null?Er:j,"data-styled":!(u.jsx||u.unstyled||h),"data-mounted":W,"data-promise":!!u.promise,"data-swiped":ae,"data-removed":q,"data-visible":xt,"data-y-position":Pe,"data-x-position":Cn,"data-index":v,"data-front":en,"data-swiping":P,"data-dismissible":Xe,"data-type":je,"data-invert":Jn,"data-swipe-out":ue,"data-swipe-direction":re,"data-expanded":!!(w||H&&W),"data-testid":u.testId,style:{"--index":v,"--toasts-before":v,"--z-index":_.length-v,"--offset":`${q?we:se.current}px`,"--initial-height":H?"auto":`${Ve}px`,...I,...u.style},onDragEnd:()=>{G(!1),te(null),ye.current=null},onPointerDown:le=>{le.button!==2&&(pn||!Xe||(_t.current=new Date,Te(se.current),le.target.setPointerCapture(le.pointerId),le.target.tagName!=="BUTTON"&&(G(!0),ye.current={x:le.clientX,y:le.clientY})))},onPointerUp:()=>{var le,Le,ge;if(ue||!Xe)return;ye.current=null;const De=Number(((le=Ye.current)==null?void 0:le.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),En=Number(((Le=Ye.current)==null?void 0:Le.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),$e=new Date().getTime()-((ge=_t.current)==null?void 0:ge.getTime()),Qe=Z==="x"?De:En,hn=Math.abs(Qe)/$e;if(Math.abs(Qe)>=Tk||hn>.11){Te(se.current),u.onDismiss==null||u.onDismiss.call(u,u),de(Z==="x"?De>0?"right":"left":En>0?"down":"up"),Lt(),B(!0);return}else{var ct,mt;(ct=Ye.current)==null||ct.style.setProperty("--swipe-amount-x","0px"),(mt=Ye.current)==null||mt.style.setProperty("--swipe-amount-y","0px")}ce(!1),G(!1),te(null)},onPointerMove:le=>{var Le,ge,De;if(!ye.current||!Xe||((Le=window.getSelection())==null?void 0:Le.toString().length)>0)return;const $e=le.clientY-ye.current.y,Qe=le.clientX-ye.current.x;var hn;const ct=(hn=e.swipeDirections)!=null?hn:Rk(U);!Z&&(Math.abs(Qe)>1||Math.abs($e)>1)&&te(Math.abs(Qe)>Math.abs($e)?"x":"y");let mt={x:0,y:0};const pt=et=>1/(1.5+Math.abs(et)/20);if(Z==="y"){if(ct.includes("top")||ct.includes("bottom"))if(ct.includes("top")&&$e<0||ct.includes("bottom")&&$e>0)mt.y=$e;else{const et=$e*pt($e);mt.y=Math.abs(et)<Math.abs($e)?et:$e}}else if(Z==="x"&&(ct.includes("left")||ct.includes("right")))if(ct.includes("left")&&Qe<0||ct.includes("right")&&Qe>0)mt.x=Qe;else{const et=Qe*pt(Qe);mt.x=Math.abs(et)<Math.abs(Qe)?et:Qe}(Math.abs(mt.x)>0||Math.abs(mt.y)>0)&&ce(!0),(ge=Ye.current)==null||ge.style.setProperty("--swipe-amount-x",`${mt.x}px`),(De=Ye.current)==null||De.style.setProperty("--swipe-amount-y",`${mt.y}px`)}},it&&!u.jsx&&je!=="loading"?k.createElement("button",{"aria-label":N,"data-disabled":pn,"data-close-button":!0,onClick:pn||!Xe?()=>{}:()=>{Lt(),u.onDismiss==null||u.onDismiss.call(u,u)},className:Dt(z?.closeButton,u==null||(r=u.classNames)==null?void 0:r.closeButton)},(tn=A?.close)!=null?tn:xk):null,(je||u.icon||u.promise)&&u.icon!==null&&(A?.[je]!==null||u.icon)?k.createElement("div",{"data-icon":"",className:Dt(z?.icon,u==null||(o=u.classNames)==null?void 0:o.icon)},u.promise||u.type==="loading"&&!u.icon?u.icon||Nn():null,u.type!=="loading"?An:null):null,k.createElement("div",{"data-content":"",className:Dt(z?.content,u==null||(a=u.classNames)==null?void 0:a.content)},k.createElement("div",{"data-title":"",className:Dt(z?.title,u==null||(i=u.classNames)==null?void 0:i.title)},u.jsx?u.jsx:typeof u.title=="function"?u.title():u.title),u.description?k.createElement("div",{"data-description":"",className:Dt(F,qt,z?.description,u==null||(c=u.classNames)==null?void 0:c.description)},typeof u.description=="function"?u.description():u.description):null),k.isValidElement(u.cancel)?u.cancel:u.cancel&&Br(u.cancel)?k.createElement("button",{"data-button":!0,"data-cancel":!0,style:u.cancelButtonStyle||C,onClick:le=>{Br(u.cancel)&&Xe&&(u.cancel.onClick==null||u.cancel.onClick.call(u.cancel,le),Lt())},className:Dt(z?.cancelButton,u==null||(l=u.classNames)==null?void 0:l.cancelButton)},u.cancel.label):null,k.isValidElement(u.action)?u.action:u.action&&Br(u.action)?k.createElement("button",{"data-button":!0,"data-action":!0,style:u.actionButtonStyle||E,onClick:le=>{Br(u.action)&&(u.action.onClick==null||u.action.onClick.call(u.action,le),!le.defaultPrevented&&Lt())},className:Dt(z?.actionButton,u==null||(d=u.classNames)==null?void 0:d.actionButton)},u.action.label):null)};function xc(){if(typeof window>"u"||typeof document>"u")return"ltr";const e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function Mk(e,t){const n={};return[e,t].forEach((r,o)=>{const a=o===1,i=a?"--mobile-offset":"--offset",c=a?Ak:Nk;function l(d){["top","right","bottom","left"].forEach(f=>{n[`${i}-${f}`]=typeof d=="number"?`${d}px`:d})}typeof r=="number"||typeof r=="string"?l(r):typeof r=="object"?["top","right","bottom","left"].forEach(d=>{r[d]===void 0?n[`${i}-${d}`]=c:n[`${i}-${d}`]=typeof r[d]=="number"?`${r[d]}px`:r[d]}):l(c)}),n}const Lk=k.forwardRef(function(t,n){const{id:r,invert:o,position:a="bottom-right",hotkey:i=["altKey","KeyT"],expand:c,closeButton:l,className:d,offset:f,mobileOffset:u,theme:h="light",richColors:g,duration:y,style:x,visibleToasts:p=Ck,toastOptions:v,dir:_=xc(),gap:w=Ik,icons:b,containerAriaLabel:j="Notifications"}=t,[R,I]=k.useState([]),C=k.useMemo(()=>r?R.filter(W=>W.toasterId===r):R.filter(W=>!W.toasterId),[R,r]),E=k.useMemo(()=>Array.from(new Set([a].concat(C.filter(W=>W.position).map(W=>W.position)))),[C,a]),[O,F]=k.useState([]),[M,U]=k.useState(!1),[D,H]=k.useState(!1),[z,A]=k.useState(h!=="system"?h:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),N=k.useRef(null),Z=i.join("+").replace(/Key/g,"").replace(/Digit/g,""),te=k.useRef(null),re=k.useRef(!1),de=k.useCallback(W=>{I(Q=>{var q;return(q=Q.find(he=>he.id===W.id))!=null&&q.delete||dt.dismiss(W.id),Q.filter(({id:he})=>he!==W.id)})},[]);return k.useEffect(()=>dt.subscribe(W=>{if(W.dismiss){requestAnimationFrame(()=>{I(Q=>Q.map(q=>q.id===W.id?{...q,delete:!0}:q))});return}setTimeout(()=>{Zo.flushSync(()=>{I(Q=>{const q=Q.findIndex(he=>he.id===W.id);return q!==-1?[...Q.slice(0,q),{...Q[q],...W},...Q.slice(q+1)]:[W,...Q]})})})}),[R]),k.useEffect(()=>{if(h!=="system"){A(h);return}if(h==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?A("dark"):A("light")),typeof window>"u")return;const W=window.matchMedia("(prefers-color-scheme: dark)");try{W.addEventListener("change",({matches:Q})=>{A(Q?"dark":"light")})}catch{W.addListener(({matches:q})=>{try{A(q?"dark":"light")}catch(he){console.error(he)}})}},[h]),k.useEffect(()=>{R.length<=1&&U(!1)},[R]),k.useEffect(()=>{const W=Q=>{var q;if(i.every(G=>Q[G]||Q.code===G)){var P;U(!0),(P=N.current)==null||P.focus()}Q.code==="Escape"&&(document.activeElement===N.current||(q=N.current)!=null&&q.contains(document.activeElement))&&U(!1)};return document.addEventListener("keydown",W),()=>document.removeEventListener("keydown",W)},[i]),k.useEffect(()=>{if(N.current)return()=>{te.current&&(te.current.focus({preventScroll:!0}),te.current=null,re.current=!1)}},[N.current]),k.createElement("section",{ref:n,"aria-label":`${j} ${Z}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},E.map((W,Q)=>{var q;const[he,P]=W.split("-");return C.length?k.createElement("ol",{key:W,dir:_==="auto"?xc():_,tabIndex:-1,ref:N,className:d,"data-sonner-toaster":!0,"data-sonner-theme":z,"data-y-position":he,"data-x-position":P,style:{"--front-toast-height":`${((q=O[0])==null?void 0:q.height)||0}px`,"--width":`${Ek}px`,"--gap":`${w}px`,...x,...Mk(f,u)},onBlur:G=>{re.current&&!G.currentTarget.contains(G.relatedTarget)&&(re.current=!1,te.current&&(te.current.focus({preventScroll:!0}),te.current=null))},onFocus:G=>{G.target instanceof HTMLElement&&G.target.dataset.dismissible==="false"||re.current||(re.current=!0,te.current=G.relatedTarget)},onMouseEnter:()=>U(!0),onMouseMove:()=>U(!0),onMouseLeave:()=>{D||U(!1)},onDragEnd:()=>U(!1),onPointerDown:G=>{G.target instanceof HTMLElement&&G.target.dataset.dismissible==="false"||H(!0)},onPointerUp:()=>H(!1)},C.filter(G=>!G.position&&Q===0||G.position===W).map((G,ue)=>{var B,ae;return k.createElement(Ok,{key:G.id,icons:b,index:ue,toast:G,defaultRichColors:g,duration:(B=v?.duration)!=null?B:y,className:v?.className,descriptionClassName:v?.descriptionClassName,invert:o,visibleToasts:p,closeButton:(ae=v?.closeButton)!=null?ae:l,interacting:D,position:W,style:v?.style,unstyled:v?.unstyled,classNames:v?.classNames,cancelButtonStyle:v?.cancelButtonStyle,actionButtonStyle:v?.actionButtonStyle,closeButtonAriaLabel:v?.closeButtonAriaLabel,removeToast:de,toasts:C.filter(ce=>ce.position==G.position),heights:O.filter(ce=>ce.position==G.position),setHeights:F,expandByDefault:c,gap:w,expanded:M,swipeDirections:t.swipeDirections})})):null}))}),Fa=m.createContext(null);function Dk(){const e=m.useContext(Fa);if(!e)throw new Error("useToast must be used within ToastProvider");return e}function Hs(){return m.useContext(Fa)}function $k({children:e}){const t=m.useCallback(n=>{const r=n.title??"",o=n.description;Sk(r||o||"Notification",{description:r?o:void 0,duration:n.durationMs??5e3,action:n.actionLabel&&n.onAction?{label:n.actionLabel,onClick:()=>n.onAction?.()}:void 0})},[]);return s.jsxs(Fa.Provider,{value:{toast:t},children:[e,s.jsx(Lk,{position:"top-center",closeButton:!0,expand:!0,className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:pointer-events-auto group-[.toaster]:w-full group-[.toaster]:rounded-xl group-[.toaster]:border group-[.toaster]:border-neutral-200 group-[.toaster]:bg-white group-[.toaster]:p-4 group-[.toaster]:shadow-lg dark:group-[.toaster]:border-neutral-800 dark:group-[.toaster]:bg-neutral-950",title:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",description:"text-sm text-neutral-600 dark:text-neutral-400",actionButton:"h-8 rounded-md border border-neutral-200 bg-white px-3 text-xs font-medium text-neutral-900 shadow-sm hover:bg-neutral-50 dark:border-neutral-800 dark:bg-neutral-950 dark:text-neutral-50 dark:hover:bg-neutral-900",cancelButton:"h-8 rounded-md bg-neutral-100 px-3 text-xs font-medium text-neutral-900 hover:bg-neutral-200 dark:bg-neutral-800 dark:text-neutral-50 dark:hover:bg-neutral-700",closeButton:"rounded-md text-neutral-600 opacity-0 transition-opacity hover:bg-neutral-100 hover:text-neutral-900 group-hover:opacity-100 dark:text-neutral-400 dark:hover:bg-neutral-800 dark:hover:text-neutral-50"}}})]})}const{entries:xf,setPrototypeOf:vc,isFrozen:zk,getPrototypeOf:Fk,getOwnPropertyDescriptor:Uk}=Object;let{freeze:ot,seal:bt,create:Uo}=Object,{apply:Bo,construct:Vo}=typeof Reflect<"u"&&Reflect;ot||(ot=function(t){return t});bt||(bt=function(t){return t});Bo||(Bo=function(t,n){for(var r=arguments.length,o=new Array(r>2?r-2:0),a=2;a<r;a++)o[a-2]=arguments[a];return t.apply(n,o)});Vo||(Vo=function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return new t(...r)});const Vr=at(Array.prototype.forEach),Bk=at(Array.prototype.lastIndexOf),yc=at(Array.prototype.pop),nr=at(Array.prototype.push),Vk=at(Array.prototype.splice),Qr=at(String.prototype.toLowerCase),po=at(String.prototype.toString),ho=at(String.prototype.match),rr=at(String.prototype.replace),Wk=at(String.prototype.indexOf),Hk=at(String.prototype.trim),At=at(Object.prototype.hasOwnProperty),tt=at(RegExp.prototype.test),sr=Zk(TypeError);function at(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return Bo(e,t,r)}}function Zk(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return Vo(e,n)}}function me(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Qr;vc&&vc(e,null);let r=t.length;for(;r--;){let o=t[r];if(typeof o=="string"){const a=n(o);a!==o&&(zk(t)||(t[r]=a),o=a)}e[o]=!0}return e}function qk(e){for(let t=0;t<e.length;t++)At(e,t)||(e[t]=null);return e}function $t(e){const t=Uo(null);for(const[n,r]of xf(e))At(e,n)&&(Array.isArray(r)?t[n]=qk(r):r&&typeof r=="object"&&r.constructor===Object?t[n]=$t(r):t[n]=r);return t}function or(e,t){for(;e!==null;){const r=Uk(e,t);if(r){if(r.get)return at(r.get);if(typeof r.value=="function")return at(r.value)}e=Fk(e)}function n(){return null}return n}const bc=ot(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),go=ot(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),xo=ot(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Gk=ot(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),vo=ot(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),Yk=ot(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),wc=ot(["#text"]),_c=ot(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),yo=ot(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),kc=ot(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Wr=ot(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Qk=bt(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Kk=bt(/<%[\w\W]*|[\w\W]*%>/gm),Jk=bt(/\$\{[\w\W]*/gm),Xk=bt(/^data-[\-\w.\u00B7-\uFFFF]+$/),ej=bt(/^aria-[\-\w]+$/),vf=bt(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),tj=bt(/^(?:\w+script|data):/i),nj=bt(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),yf=bt(/^html$/i),rj=bt(/^[a-z][.\w]*(-[.\w]+)+$/i);var jc=Object.freeze({__proto__:null,ARIA_ATTR:ej,ATTR_WHITESPACE:nj,CUSTOM_ELEMENT:rj,DATA_ATTR:Xk,DOCTYPE_NAME:yf,ERB_EXPR:Kk,IS_ALLOWED_URI:vf,IS_SCRIPT_OR_DATA:tj,MUSTACHE_EXPR:Qk,TMPLIT_EXPR:Jk});const ar={element:1,text:3,progressingInstruction:7,comment:8,document:9},sj=function(){return typeof window>"u"?null:window},oj=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null;const o="data-tt-policy-suffix";n&&n.hasAttribute(o)&&(r=n.getAttribute(o));const a="dompurify"+(r?"#"+r:"");try{return t.createPolicy(a,{createHTML(i){return i},createScriptURL(i){return i}})}catch{return console.warn("TrustedTypes policy "+a+" could not be created."),null}},Sc=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function bf(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:sj();const t=oe=>bf(oe);if(t.version="3.3.1",t.removed=[],!e||!e.document||e.document.nodeType!==ar.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e;const r=n,o=r.currentScript,{DocumentFragment:a,HTMLTemplateElement:i,Node:c,Element:l,NodeFilter:d,NamedNodeMap:f=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:u,DOMParser:h,trustedTypes:g}=e,y=l.prototype,x=or(y,"cloneNode"),p=or(y,"remove"),v=or(y,"nextSibling"),_=or(y,"childNodes"),w=or(y,"parentNode");if(typeof i=="function"){const oe=n.createElement("template");oe.content&&oe.content.ownerDocument&&(n=oe.content.ownerDocument)}let b,j="";const{implementation:R,createNodeIterator:I,createDocumentFragment:C,getElementsByTagName:E}=n,{importNode:O}=r;let F=Sc();t.isSupported=typeof xf=="function"&&typeof w=="function"&&R&&R.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:M,ERB_EXPR:U,TMPLIT_EXPR:D,DATA_ATTR:H,ARIA_ATTR:z,IS_SCRIPT_OR_DATA:A,ATTR_WHITESPACE:N,CUSTOM_ELEMENT:Z}=jc;let{IS_ALLOWED_URI:te}=jc,re=null;const de=me({},[...bc,...go,...xo,...vo,...wc]);let W=null;const Q=me({},[..._c,...yo,...kc,...Wr]);let q=Object.seal(Uo(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),he=null,P=null;const G=Object.seal(Uo(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let ue=!0,B=!0,ae=!1,ce=!0,we=!1,Te=!0,Ve=!1,Ge=!1,We=!1,_t=!1,Ye=!1,en=!1,xt=!0,je=!1;const Xe="user-content-";let _e=!0,qt=!1,ft={},it=null;const T=me({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let K=null;const se=me({},["audio","video","img","source","image","track"]);let ve=null;const ye=me({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Pe="http://www.w3.org/1998/Math/MathML",Cn="http://www.w3.org/2000/svg",vt="http://www.w3.org/1999/xhtml";let Gt=vt,Jn=!1,pn=null;const Lt=me({},[Pe,Cn,vt],po);let Nn=me({},["mi","mo","mn","ms","mtext"]),An=me({},["annotation-xml"]);const Er=me({},["title","style","font","a","script"]);let tn=null;const le=["application/xhtml+xml","text/html"],Le="text/html";let ge=null,De=null;const En=n.createElement("form"),$e=function(S){return S instanceof RegExp||S instanceof Function},Qe=function(){let S=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(De&&De===S)){if((!S||typeof S!="object")&&(S={}),S=$t(S),tn=le.indexOf(S.PARSER_MEDIA_TYPE)===-1?Le:S.PARSER_MEDIA_TYPE,ge=tn==="application/xhtml+xml"?po:Qr,re=At(S,"ALLOWED_TAGS")?me({},S.ALLOWED_TAGS,ge):de,W=At(S,"ALLOWED_ATTR")?me({},S.ALLOWED_ATTR,ge):Q,pn=At(S,"ALLOWED_NAMESPACES")?me({},S.ALLOWED_NAMESPACES,po):Lt,ve=At(S,"ADD_URI_SAFE_ATTR")?me($t(ye),S.ADD_URI_SAFE_ATTR,ge):ye,K=At(S,"ADD_DATA_URI_TAGS")?me($t(se),S.ADD_DATA_URI_TAGS,ge):se,it=At(S,"FORBID_CONTENTS")?me({},S.FORBID_CONTENTS,ge):T,he=At(S,"FORBID_TAGS")?me({},S.FORBID_TAGS,ge):$t({}),P=At(S,"FORBID_ATTR")?me({},S.FORBID_ATTR,ge):$t({}),ft=At(S,"USE_PROFILES")?S.USE_PROFILES:!1,ue=S.ALLOW_ARIA_ATTR!==!1,B=S.ALLOW_DATA_ATTR!==!1,ae=S.ALLOW_UNKNOWN_PROTOCOLS||!1,ce=S.ALLOW_SELF_CLOSE_IN_ATTR!==!1,we=S.SAFE_FOR_TEMPLATES||!1,Te=S.SAFE_FOR_XML!==!1,Ve=S.WHOLE_DOCUMENT||!1,_t=S.RETURN_DOM||!1,Ye=S.RETURN_DOM_FRAGMENT||!1,en=S.RETURN_TRUSTED_TYPE||!1,We=S.FORCE_BODY||!1,xt=S.SANITIZE_DOM!==!1,je=S.SANITIZE_NAMED_PROPS||!1,_e=S.KEEP_CONTENT!==!1,qt=S.IN_PLACE||!1,te=S.ALLOWED_URI_REGEXP||vf,Gt=S.NAMESPACE||vt,Nn=S.MATHML_TEXT_INTEGRATION_POINTS||Nn,An=S.HTML_INTEGRATION_POINTS||An,q=S.CUSTOM_ELEMENT_HANDLING||{},S.CUSTOM_ELEMENT_HANDLING&&$e(S.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(q.tagNameCheck=S.CUSTOM_ELEMENT_HANDLING.tagNameCheck),S.CUSTOM_ELEMENT_HANDLING&&$e(S.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(q.attributeNameCheck=S.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),S.CUSTOM_ELEMENT_HANDLING&&typeof S.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(q.allowCustomizedBuiltInElements=S.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),we&&(B=!1),Ye&&(_t=!0),ft&&(re=me({},wc),W=[],ft.html===!0&&(me(re,bc),me(W,_c)),ft.svg===!0&&(me(re,go),me(W,yo),me(W,Wr)),ft.svgFilters===!0&&(me(re,xo),me(W,yo),me(W,Wr)),ft.mathMl===!0&&(me(re,vo),me(W,kc),me(W,Wr))),S.ADD_TAGS&&(typeof S.ADD_TAGS=="function"?G.tagCheck=S.ADD_TAGS:(re===de&&(re=$t(re)),me(re,S.ADD_TAGS,ge))),S.ADD_ATTR&&(typeof S.ADD_ATTR=="function"?G.attributeCheck=S.ADD_ATTR:(W===Q&&(W=$t(W)),me(W,S.ADD_ATTR,ge))),S.ADD_URI_SAFE_ATTR&&me(ve,S.ADD_URI_SAFE_ATTR,ge),S.FORBID_CONTENTS&&(it===T&&(it=$t(it)),me(it,S.FORBID_CONTENTS,ge)),S.ADD_FORBID_CONTENTS&&(it===T&&(it=$t(it)),me(it,S.ADD_FORBID_CONTENTS,ge)),_e&&(re["#text"]=!0),Ve&&me(re,["html","head","body"]),re.table&&(me(re,["tbody"]),delete he.tbody),S.TRUSTED_TYPES_POLICY){if(typeof S.TRUSTED_TYPES_POLICY.createHTML!="function")throw sr('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof S.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw sr('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');b=S.TRUSTED_TYPES_POLICY,j=b.createHTML("")}else b===void 0&&(b=oj(g,o)),b!==null&&typeof j=="string"&&(j=b.createHTML(""));ot&&ot(S),De=S}},hn=me({},[...go,...xo,...Gk]),ct=me({},[...vo,...Yk]),mt=function(S){let V=w(S);(!V||!V.tagName)&&(V={namespaceURI:Gt,tagName:"template"});const ee=Qr(S.tagName),Se=Qr(V.tagName);return pn[S.namespaceURI]?S.namespaceURI===Cn?V.namespaceURI===vt?ee==="svg":V.namespaceURI===Pe?ee==="svg"&&(Se==="annotation-xml"||Nn[Se]):!!hn[ee]:S.namespaceURI===Pe?V.namespaceURI===vt?ee==="math":V.namespaceURI===Cn?ee==="math"&&An[Se]:!!ct[ee]:S.namespaceURI===vt?V.namespaceURI===Cn&&!An[Se]||V.namespaceURI===Pe&&!Nn[Se]?!1:!ct[ee]&&(Er[ee]||!hn[ee]):!!(tn==="application/xhtml+xml"&&pn[S.namespaceURI]):!1},pt=function(S){nr(t.removed,{element:S});try{w(S).removeChild(S)}catch{p(S)}},et=function(S,V){try{nr(t.removed,{attribute:V.getAttributeNode(S),from:V})}catch{nr(t.removed,{attribute:null,from:V})}if(V.removeAttribute(S),S==="is")if(_t||Ye)try{pt(V)}catch{}else try{V.setAttribute(S,"")}catch{}},Ys=function(S){let V=null,ee=null;if(We)S="<remove></remove>"+S;else{const ze=ho(S,/^[\r\n\t ]+/);ee=ze&&ze[0]}tn==="application/xhtml+xml"&&Gt===vt&&(S='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+S+"</body></html>");const Se=b?b.createHTML(S):S;if(Gt===vt)try{V=new h().parseFromString(Se,tn)}catch{}if(!V||!V.documentElement){V=R.createDocument(Gt,"template",null);try{V.documentElement.innerHTML=Jn?j:Se}catch{}}const Ke=V.body||V.documentElement;return S&&ee&&Ke.insertBefore(n.createTextNode(ee),Ke.childNodes[0]||null),Gt===vt?E.call(V,Ve?"html":"body")[0]:Ve?V.documentElement:Ke},Ka=function(S){return I.call(S.ownerDocument||S,S,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT|d.SHOW_PROCESSING_INSTRUCTION|d.SHOW_CDATA_SECTION,null)},Qs=function(S){return S instanceof u&&(typeof S.nodeName!="string"||typeof S.textContent!="string"||typeof S.removeChild!="function"||!(S.attributes instanceof f)||typeof S.removeAttribute!="function"||typeof S.setAttribute!="function"||typeof S.namespaceURI!="string"||typeof S.insertBefore!="function"||typeof S.hasChildNodes!="function")},Ja=function(S){return typeof c=="function"&&S instanceof c};function Yt(oe,S,V){Vr(oe,ee=>{ee.call(t,S,V,De)})}const Xa=function(S){let V=null;if(Yt(F.beforeSanitizeElements,S,null),Qs(S))return pt(S),!0;const ee=ge(S.nodeName);if(Yt(F.uponSanitizeElement,S,{tagName:ee,allowedTags:re}),Te&&S.hasChildNodes()&&!Ja(S.firstElementChild)&&tt(/<[/\w!]/g,S.innerHTML)&&tt(/<[/\w!]/g,S.textContent)||S.nodeType===ar.progressingInstruction||Te&&S.nodeType===ar.comment&&tt(/<[/\w]/g,S.data))return pt(S),!0;if(!(G.tagCheck instanceof Function&&G.tagCheck(ee))&&(!re[ee]||he[ee])){if(!he[ee]&&ti(ee)&&(q.tagNameCheck instanceof RegExp&&tt(q.tagNameCheck,ee)||q.tagNameCheck instanceof Function&&q.tagNameCheck(ee)))return!1;if(_e&&!it[ee]){const Se=w(S)||S.parentNode,Ke=_(S)||S.childNodes;if(Ke&&Se){const ze=Ke.length;for(let lt=ze-1;lt>=0;--lt){const Qt=x(Ke[lt],!0);Qt.__removalCount=(S.__removalCount||0)+1,Se.insertBefore(Qt,v(S))}}}return pt(S),!0}return S instanceof l&&!mt(S)||(ee==="noscript"||ee==="noembed"||ee==="noframes")&&tt(/<\/no(script|embed|frames)/i,S.innerHTML)?(pt(S),!0):(we&&S.nodeType===ar.text&&(V=S.textContent,Vr([M,U,D],Se=>{V=rr(V,Se," ")}),S.textContent!==V&&(nr(t.removed,{element:S.cloneNode()}),S.textContent=V)),Yt(F.afterSanitizeElements,S,null),!1)},ei=function(S,V,ee){if(xt&&(V==="id"||V==="name")&&(ee in n||ee in En))return!1;if(!(B&&!P[V]&&tt(H,V))){if(!(ue&&tt(z,V))){if(!(G.attributeCheck instanceof Function&&G.attributeCheck(V,S))){if(!W[V]||P[V]){if(!(ti(S)&&(q.tagNameCheck instanceof RegExp&&tt(q.tagNameCheck,S)||q.tagNameCheck instanceof Function&&q.tagNameCheck(S))&&(q.attributeNameCheck instanceof RegExp&&tt(q.attributeNameCheck,V)||q.attributeNameCheck instanceof Function&&q.attributeNameCheck(V,S))||V==="is"&&q.allowCustomizedBuiltInElements&&(q.tagNameCheck instanceof RegExp&&tt(q.tagNameCheck,ee)||q.tagNameCheck instanceof Function&&q.tagNameCheck(ee))))return!1}else if(!ve[V]){if(!tt(te,rr(ee,N,""))){if(!((V==="src"||V==="xlink:href"||V==="href")&&S!=="script"&&Wk(ee,"data:")===0&&K[S])){if(!(ae&&!tt(A,rr(ee,N,"")))){if(ee)return!1}}}}}}}return!0},ti=function(S){return S!=="annotation-xml"&&ho(S,Z)},ni=function(S){Yt(F.beforeSanitizeAttributes,S,null);const{attributes:V}=S;if(!V||Qs(S))return;const ee={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:W,forceKeepAttr:void 0};let Se=V.length;for(;Se--;){const Ke=V[Se],{name:ze,namespaceURI:lt,value:Qt}=Ke,In=ge(ze),Ks=Qt;let He=ze==="value"?Ks:Hk(Ks);if(ee.attrName=In,ee.attrValue=He,ee.keepAttr=!0,ee.forceKeepAttr=void 0,Yt(F.uponSanitizeAttribute,S,ee),He=ee.attrValue,je&&(In==="id"||In==="name")&&(et(ze,S),He=Xe+He),Te&&tt(/((--!?|])>)|<\/(style|title|textarea)/i,He)){et(ze,S);continue}if(In==="attributename"&&ho(He,"href")){et(ze,S);continue}if(ee.forceKeepAttr)continue;if(!ee.keepAttr){et(ze,S);continue}if(!ce&&tt(/\/>/i,He)){et(ze,S);continue}we&&Vr([M,U,D],si=>{He=rr(He,si," ")});const ri=ge(S.nodeName);if(!ei(ri,In,He)){et(ze,S);continue}if(b&&typeof g=="object"&&typeof g.getAttributeType=="function"&&!lt)switch(g.getAttributeType(ri,In)){case"TrustedHTML":{He=b.createHTML(He);break}case"TrustedScriptURL":{He=b.createScriptURL(He);break}}if(He!==Ks)try{lt?S.setAttributeNS(lt,ze,He):S.setAttribute(ze,He),Qs(S)?pt(S):yc(t.removed)}catch{et(ze,S)}}Yt(F.afterSanitizeAttributes,S,null)},Df=function oe(S){let V=null;const ee=Ka(S);for(Yt(F.beforeSanitizeShadowDOM,S,null);V=ee.nextNode();)Yt(F.uponSanitizeShadowNode,V,null),Xa(V),ni(V),V.content instanceof a&&oe(V.content);Yt(F.afterSanitizeShadowDOM,S,null)};return t.sanitize=function(oe){let S=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},V=null,ee=null,Se=null,Ke=null;if(Jn=!oe,Jn&&(oe="<!-->"),typeof oe!="string"&&!Ja(oe))if(typeof oe.toString=="function"){if(oe=oe.toString(),typeof oe!="string")throw sr("dirty is not a string, aborting")}else throw sr("toString is not a function");if(!t.isSupported)return oe;if(Ge||Qe(S),t.removed=[],typeof oe=="string"&&(qt=!1),qt){if(oe.nodeName){const Qt=ge(oe.nodeName);if(!re[Qt]||he[Qt])throw sr("root node is forbidden and cannot be sanitized in-place")}}else if(oe instanceof c)V=Ys("<!---->"),ee=V.ownerDocument.importNode(oe,!0),ee.nodeType===ar.element&&ee.nodeName==="BODY"||ee.nodeName==="HTML"?V=ee:V.appendChild(ee);else{if(!_t&&!we&&!Ve&&oe.indexOf("<")===-1)return b&&en?b.createHTML(oe):oe;if(V=Ys(oe),!V)return _t?null:en?j:""}V&&We&&pt(V.firstChild);const ze=Ka(qt?oe:V);for(;Se=ze.nextNode();)Xa(Se),ni(Se),Se.content instanceof a&&Df(Se.content);if(qt)return oe;if(_t){if(Ye)for(Ke=C.call(V.ownerDocument);V.firstChild;)Ke.appendChild(V.firstChild);else Ke=V;return(W.shadowroot||W.shadowrootmode)&&(Ke=O.call(r,Ke,!0)),Ke}let lt=Ve?V.outerHTML:V.innerHTML;return Ve&&re["!doctype"]&&V.ownerDocument&&V.ownerDocument.doctype&&V.ownerDocument.doctype.name&&tt(yf,V.ownerDocument.doctype.name)&&(lt="<!DOCTYPE "+V.ownerDocument.doctype.name+`>
|
|
84
|
-
`+lt),we&&Vr([M,U,D],Qt=>{lt=rr(lt,Qt," ")}),b&&en?b.createHTML(lt):lt},t.setConfig=function(){let oe=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Qe(oe),Ge=!0},t.clearConfig=function(){De=null,Ge=!1},t.isValidAttribute=function(oe,S,V){De||Qe({});const ee=ge(oe),Se=ge(S);return ei(ee,Se,V)},t.addHook=function(oe,S){typeof S=="function"&&nr(F[oe],S)},t.removeHook=function(oe,S){if(S!==void 0){const V=Bk(F[oe],S);return V===-1?void 0:Vk(F[oe],V,1)[0]}return yc(F[oe])},t.removeHooks=function(oe){F[oe]=[]},t.removeAllHooks=function(){F=Sc()},t}var bo=bf();function wf({faq:e,className:t,expanded:n,defaultExpanded:r=!1,onExpandedChange:o,showKeywords:a=!1,dangerouslySetAnswerHTML:i=!1}){const[c,l]=m.useState(r),d=n!==void 0,f=d?n:c,u=()=>{const h=!f;d||l(h),o?.(h)};return s.jsxs("div",{className:L("border border-neutral-200 rounded-lg overflow-hidden dark:border-neutral-800",t),children:[s.jsxs("button",{type:"button",onClick:u,className:L("w-full flex items-center justify-between px-4 py-3 text-left","bg-neutral-50 hover:bg-neutral-100 dark:bg-neutral-900 dark:hover:bg-neutral-800","transition-colors duration-150"),"aria-expanded":f,children:[s.jsx("span",{className:"font-medium text-neutral-900 dark:text-neutral-100 pr-4",children:e.question}),s.jsx("svg",{className:L("w-5 h-5 text-neutral-500 transition-transform duration-200 flex-shrink-0",f&&"rotate-180"),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),f&&s.jsxs("div",{className:"px-4 py-3 bg-white dark:bg-neutral-950",children:[i?s.jsx("div",{className:"text-sm text-neutral-600 dark:text-neutral-400 prose prose-sm dark:prose-invert max-w-none",dangerouslySetInnerHTML:{__html:(()=>{bo.addHook("afterSanitizeAttributes",g=>{g.tagName==="A"&&g.setAttribute("rel","noopener noreferrer")});const h=bo.sanitize(e.answer,{ALLOWED_TAGS:["b","i","em","strong","a","p","br","ul","ol","li"],ALLOWED_ATTR:["href","target","rel"]});return bo.removeAllHooks(),h})()}}):s.jsx("p",{className:"text-sm text-neutral-600 dark:text-neutral-400 whitespace-pre-wrap",children:e.answer}),a&&e.keywords&&e.keywords.length>0&&s.jsx("div",{className:"mt-3 flex flex-wrap gap-1",children:e.keywords.map(h=>s.jsx("span",{className:"px-2 py-0.5 text-xs bg-neutral-100 text-neutral-600 rounded dark:bg-neutral-800 dark:text-neutral-400",children:h},h))})]})]})}function aj({faqs:e,className:t,accordion:n=!1,showKeywords:r=!1,dangerouslySetAnswerHTML:o=!1,emptyMessage:a="No FAQs available."}){const[i,c]=m.useState(null),l=e.filter(d=>d.active!==!1);return l.length===0?s.jsx("div",{className:L("text-center py-8 text-neutral-500 dark:text-neutral-400",t),children:a}):s.jsx("div",{className:L("space-y-2",t),children:l.map(d=>s.jsx(wf,{faq:d,showKeywords:r,dangerouslySetAnswerHTML:o,expanded:n?i===d.id:void 0,onExpandedChange:n?f=>c(f?d.id:null):void 0},d.id))})}function Be({amount:e,currency:t}){return new Intl.NumberFormat(void 0,{style:"currency",currency:t}).format(e)}function Zs({amount:e,currency:t,compareAt:n,className:r,size:o="default"}){const a=typeof n=="number"&&n>e;return s.jsxs("div",{className:L("flex items-baseline gap-2 tabular-nums",r),children:[s.jsx("span",{className:L("font-semibold",o==="sm"?"text-sm":"text-base"),children:Be({amount:e,currency:t})}),a?s.jsx("span",{className:L("text-neutral-500 line-through dark:text-neutral-400",o==="sm"?"text-xs":"text-sm"),children:Be({amount:n,currency:t})}):null]})}const Cc={large:"aspect-[4/5]",square:"aspect-square",compact:"aspect-[3/4]"},Nc={center:"object-center",top:"object-top",bottom:"object-bottom",left:"object-left",right:"object-right"};function _f({product:e,href:t,onAddToCart:n,onQuickView:r,className:o,layout:a="large",imageCrop:i="center"}){const c=e.inventoryStatus==="out_of_stock"||typeof e.inventoryQuantity=="number"&&e.inventoryQuantity<=0,l=typeof e.inventoryQuantity=="number"?e.inventoryQuantity:null;return s.jsxs(It,{className:L("group flex h-full flex-col overflow-hidden rounded-2xl",o),children:[s.jsxs("div",{className:"relative",children:[t?s.jsx("a",{href:t,className:"block","aria-label":`View ${e.title}`,children:s.jsx("div",{className:L("overflow-hidden bg-neutral-100 dark:bg-neutral-900",Cc[a]),children:s.jsx("img",{src:e.images[0]?.url,alt:e.images[0]?.alt??e.title,className:L("h-full w-full object-cover transition-transform duration-300 group-hover:scale-[1.03]",Nc[i]),loading:"lazy"})})}):s.jsx("div",{className:L("overflow-hidden bg-neutral-100 dark:bg-neutral-900",Cc[a]),children:s.jsx("img",{src:e.images[0]?.url,alt:e.images[0]?.alt??e.title,className:L("h-full w-full object-cover transition-transform duration-300 group-hover:scale-[1.03]",Nc[i]),loading:"lazy"})}),a!=="compact"&&e.tags?.length?s.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 flex gap-1 p-3",children:e.tags.slice(0,2).map(d=>s.jsx(vn,{className:"pointer-events-none bg-white/90 text-neutral-900 backdrop-blur dark:bg-neutral-950/80 dark:text-neutral-50",children:d},d))}):null,c?s.jsx("div",{className:"pointer-events-none absolute left-3 top-3",children:s.jsx(vn,{variant:"secondary",className:"bg-white/90 text-neutral-900 backdrop-blur dark:bg-neutral-950/80 dark:text-neutral-50",children:"Out of stock"})}):l!=null&&l>0&&l<=5?s.jsx("div",{className:"pointer-events-none absolute left-3 top-3",children:s.jsxs(vn,{variant:"secondary",className:"bg-white/90 text-neutral-900 backdrop-blur dark:bg-neutral-950/80 dark:text-neutral-50",children:["Only ",l," left"]})}):null,r?s.jsx("div",{className:"absolute right-3 top-3 opacity-0 transition-opacity group-hover:opacity-100",children:s.jsx(ne,{type:"button",size:"sm",variant:"secondary",className:"h-9",onClick:()=>r(e),children:"Quick view"})}):null]}),s.jsxs("div",{className:L("flex flex-1 flex-col",a==="compact"?"p-3":"p-4"),children:[s.jsx("div",{className:"flex items-start justify-between gap-3",children:s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:L("line-clamp-1 font-medium text-neutral-950 dark:text-neutral-50",a==="compact"?"text-xs":"text-sm"),children:e.title}),s.jsx("div",{className:"mt-1",children:s.jsx(Zs,{amount:e.price,currency:e.currency,compareAt:e.compareAtPrice,size:a==="compact"?"sm":"default"})})]})}),a==="large"&&s.jsx("p",{className:"mt-2 line-clamp-2 min-h-8 text-xs leading-4 text-neutral-600 dark:text-neutral-400",children:e.description}),s.jsx("div",{className:L("mt-auto",a==="compact"?"pt-3":"pt-4"),children:s.jsx(ne,{type:"button",className:"w-full",size:a==="compact"?"sm":"default",onClick:()=>n?.(e,null),disabled:c,children:c?"Out of stock":"Add to cart"})})]})]})}function qs({products:e,columns:t,onAddToCart:n,onQuickView:r,getProductHref:o,className:a,layout:i,imageCrop:c}){const l=t?.base??2,d=t?.md??3,f=t?.lg??3,u={1:"grid-cols-1",2:"grid-cols-2",3:"grid-cols-3",4:"grid-cols-4"},h={1:"md:grid-cols-1",2:"md:grid-cols-2",3:"md:grid-cols-3",4:"md:grid-cols-4"},g={1:"lg:grid-cols-1",2:"lg:grid-cols-2",3:"lg:grid-cols-3",4:"lg:grid-cols-4"},y=L("grid gap-4",u[Math.min(4,Math.max(1,l))],h[Math.min(4,Math.max(1,d))],g[Math.min(4,Math.max(1,f))]);return s.jsx("div",{className:L(y,a),children:e.map(x=>s.jsx(_f,{product:x,href:o?o(x):void 0,onAddToCart:n,onQuickView:r,layout:i,imageCrop:c},x.id))})}function Ua({images:e,className:t}){const[n,r]=m.useState(0),o=e[n];return e.length===0?s.jsx("div",{className:L("aspect-square w-full rounded-xl border border-neutral-200 bg-neutral-100 dark:border-neutral-800 dark:bg-neutral-900",t)}):s.jsxs("div",{className:L("space-y-3",t),children:[s.jsx("div",{className:"aspect-square overflow-hidden rounded-2xl border border-neutral-200 bg-neutral-100 dark:border-neutral-800 dark:bg-neutral-900",children:s.jsx("img",{src:o?.url,alt:o?.alt??"",className:"h-full w-full object-cover",loading:"eager"})}),e.length>1?s.jsx("div",{className:"flex gap-2 overflow-x-auto pb-1",children:e.map((a,i)=>{const c=i===n;return s.jsx("button",{type:"button",className:L("h-16 w-16 shrink-0 overflow-hidden rounded-lg border",c?"border-neutral-900 dark:border-neutral-50":"border-neutral-200 dark:border-neutral-800"),onClick:()=>r(i),"aria-label":`View image ${i+1}`,children:s.jsx("img",{src:a.url,alt:a.alt??"",className:"h-full w-full object-cover",loading:"lazy"})},a.url)})}):null]})}function ij(e){const t=new Set;for(const n of e)for(const r of Object.keys(n.options))t.add(r);return Array.from(t)}function cj(e,t){const n=new Set;for(const r of e){const o=r.options[t];o&&n.add(o)}return Array.from(n)}function Ac(e,t){return e.find(n=>Object.entries(t).every(([r,o])=>n.options[r]===o))??null}function kf(e){return e.inventoryStatus==="out_of_stock"||typeof e.inventoryQuantity=="number"&&e.inventoryQuantity<=0}function lj(e){return e.inventoryStatus==="low"||typeof e.inventoryQuantity=="number"&&e.inventoryQuantity>0&&e.inventoryQuantity<=5}function dj(e){const t=kf(e),n=!t&&lj(e),r=typeof e.inventoryQuantity=="number"?e.inventoryQuantity:void 0;return{isOutOfStock:t,isLow:n,quantity:r}}function uj(e,t,n,r){const o={...t,[n]:r},a=e.filter(i=>Object.entries(o).every(([c,l])=>i.options[c]===l));return a.length===0?!1:a.some(i=>!kf(i))}function Ba({product:e,value:t,onChange:n,className:r,showInventory:o=!0,disableOutOfStock:a=!1}){const i=m.useMemo(()=>e.variants??[],[e.variants]),c=m.useMemo(()=>ij(i),[i]),l=m.useMemo(()=>Ac(i,t.selectedOptions),[i,t.selectedOptions]),d=m.useMemo(()=>l?dj(l):null,[l]);return i.length===0||c.length===0?null:s.jsxs("div",{className:L("space-y-4",r),children:[c.map(f=>{const u=cj(i,f),h=t.selectedOptions[f];return s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-baseline justify-between",children:[s.jsx("div",{className:"text-sm font-medium text-neutral-950 dark:text-neutral-50",children:f}),s.jsx("div",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:h||"Select"})]}),s.jsx("div",{className:"flex flex-wrap gap-2",children:u.map(g=>{const y=g===h,x=uj(i,t.selectedOptions,f,g),p=a&&!x;return s.jsxs(ne,{type:"button",size:"sm",variant:y?"default":"outline",onClick:()=>{const v={...t.selectedOptions,[f]:g},_=Ac(i,v);n({selectedOptions:v,variant:_})},"aria-pressed":y,disabled:p,className:L(!x&&!p&&"opacity-50 line-through"),children:[g,!x&&!p&&s.jsx("span",{className:"ml-1 text-[10px] opacity-70",children:"(Out)"})]},g)})})]},f)}),o&&l&&d&&s.jsx("div",{className:"pt-2",children:d.isOutOfStock?s.jsx("div",{className:"text-sm font-medium text-red-600 dark:text-red-400",children:"Out of stock"}):d.isLow&&d.quantity!==void 0?s.jsxs("div",{className:"text-sm text-amber-600 dark:text-amber-400",children:["Only ",s.jsx("span",{className:"font-semibold",children:d.quantity})," left"]}):null})]})}function Va({qty:e,onChange:t,min:n=1,max:r,className:o}){const a=Number.isFinite(e)?Math.max(n,Math.floor(e)):n,i=a>n,c=typeof r=="number"?a<r:!0;return s.jsxs("div",{className:L("flex items-center gap-2",o),children:[s.jsx(ne,{type:"button",size:"icon",variant:"outline",onClick:()=>t(Math.max(n,a-1)),disabled:!i,"aria-label":"Decrease quantity",children:"-"}),s.jsx(Fe,{inputMode:"numeric",pattern:"[0-9]*",value:String(a),onChange:l=>{const d=Math.floor(Number(l.target.value));if(!Number.isFinite(d))return;const f=Math.max(n,typeof r=="number"?Math.min(r,d):d);t(f)},className:"h-10 w-16 text-center","aria-label":"Quantity"}),s.jsx(ne,{type:"button",size:"icon",variant:"outline",onClick:()=>t(a+1),disabled:!c,"aria-label":"Increase quantity",children:"+"})]})}function Wa({product:e,open:t,onOpenChange:n,productHref:r,onAddToCart:o,className:a}){const[i,c]=m.useState(1),[l,d]=m.useState({selectedOptions:{},variant:null});if(m.useEffect(()=>{if(e)if(c(1),e.variants?.length){const x=e.variants[0];d({selectedOptions:{...x.options},variant:x})}else d({selectedOptions:{},variant:null})},[e?.id]),!e)return null;const f=l.variant?.price??e.price,u=l.variant?.compareAtPrice??e.compareAtPrice,h=l.variant?.inventoryStatus==="out_of_stock"||typeof l.variant?.inventoryQuantity=="number"&&l.variant.inventoryQuantity<=0,g=e.inventoryStatus==="out_of_stock"||typeof e.inventoryQuantity=="number"&&e.inventoryQuantity<=0,y=l.variant?h:g;return s.jsx(Na,{open:t,onOpenChange:n,children:s.jsxs(Os,{className:L("max-w-3xl",a),children:[s.jsx(Ea,{children:s.jsxs(Ms,{className:"flex items-center justify-between gap-3",children:[s.jsx("span",{className:"truncate",children:e.title}),r?s.jsx("a",{href:r(e.slug),className:"text-sm font-normal text-neutral-700 hover:underline dark:text-neutral-300",children:"View details"}):null]})}),s.jsxs("div",{className:"grid gap-8 md:grid-cols-2",children:[s.jsx(Ua,{images:e.images}),s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{children:[s.jsx(Zs,{amount:f,currency:e.currency,compareAt:u}),s.jsx("p",{className:"mt-3 text-sm text-neutral-600 dark:text-neutral-400",children:e.description})]}),s.jsx(Ba,{product:e,value:{selectedOptions:l.selectedOptions,variantId:l.variant?.id},onChange:x=>d(x)}),s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[s.jsx(Va,{qty:i,onChange:c}),s.jsx(ne,{type:"button",className:"flex-1",disabled:y,onClick:()=>{o(e,l.variant,i),n(!1)},children:y?"Out of stock":"Add to cart"})]}),s.jsx("div",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:y?"Out of stock":"In stock"})]})]})]})})}function Wo({categories:e,activeSlug:t,onSelect:n,className:r}){return s.jsx("nav",{className:L("space-y-1",r),"aria-label":"Categories",children:e.map(o=>{const a=t===o.slug;return s.jsxs("button",{type:"button",className:L("flex w-full items-center justify-between rounded-md px-3 py-2 text-sm transition-colors",a?"bg-neutral-900 text-neutral-50 dark:bg-neutral-50 dark:text-neutral-900":"text-neutral-700 hover:bg-neutral-100 dark:text-neutral-300 dark:hover:bg-neutral-800"),onClick:()=>n?.(o),"aria-current":a?"page":void 0,children:[s.jsx("span",{className:"truncate",children:o.name}),s.jsx("span",{className:"text-xs opacity-70",children:"›"})]},o.id)})})}function Ha({items:e,className:t}){return s.jsx("nav",{className:L("flex items-center gap-2 text-xs text-neutral-600 dark:text-neutral-400",t),"aria-label":"Breadcrumb",children:e.map((n,r)=>s.jsxs("span",{className:"flex items-center gap-2",children:[n.href?s.jsx("a",{href:n.href,className:"hover:underline",children:n.label}):s.jsx("span",{className:"text-neutral-900 dark:text-neutral-50",children:n.label}),r<e.length-1?s.jsx("span",{"aria-hidden":!0,children:"·"}):null]},`${n.label}-${r}`))})}function Za({value:e,onChange:t,placeholder:n="Search products…",className:r}){return s.jsxs("div",{className:L("relative",r),children:[s.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-3 flex items-center text-neutral-500 dark:text-neutral-400","aria-hidden":!0,children:"⌕"}),s.jsx(Fe,{value:e,onChange:o=>t(o.target.value),placeholder:n,className:"pl-9","aria-label":"Search"})]})}function ms({facets:e,value:t,onChange:n,onClear:r,className:o,enabledFilters:a}){const i=e.tags??[],c=new Set(t.tags??[]),l=a?.tags??!0,d=a?.priceRange??!0,f=a?.inStock??!0;return l||d||f?s.jsxs("div",{className:L("space-y-4",o),children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("div",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:"Filters"}),s.jsx(ne,{type:"button",variant:"ghost",className:"h-8 px-2 text-xs",onClick:r,children:"Clear"})]}),s.jsx(yt,{}),l&&i.length?s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"text-sm font-medium",children:"Tags"}),s.jsx("div",{className:"space-y-2",children:i.map(h=>s.jsxs("label",{className:"flex cursor-pointer items-center gap-2 text-sm text-neutral-700 dark:text-neutral-300",children:[s.jsx("input",{type:"checkbox",checked:c.has(h),onChange:g=>{const y=new Set(c);g.target.checked?y.add(h):y.delete(h),n({...t,tags:Array.from(y)})}}),h]},h))})]}):null,d&&e.price?s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"text-sm font-medium",children:"Price"}),s.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[s.jsxs("div",{className:"grid gap-1",children:[s.jsx(st,{className:"text-xs",htmlFor:"price-min",children:"Min"}),s.jsx(Fe,{id:"price-min",inputMode:"decimal",placeholder:String(e.price.min),value:t.priceMin??"",onChange:h=>{const g=Number(h.target.value);n({...t,priceMin:Number.isFinite(g)&&h.target.value!==""?g:void 0})}})]}),s.jsxs("div",{className:"grid gap-1",children:[s.jsx(st,{className:"text-xs",htmlFor:"price-max",children:"Max"}),s.jsx(Fe,{id:"price-max",inputMode:"decimal",placeholder:String(e.price.max),value:t.priceMax??"",onChange:h=>{const g=Number(h.target.value);n({...t,priceMax:Number.isFinite(g)&&h.target.value!==""?g:void 0})}})]})]})]}):null,f?s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"text-sm font-medium",children:"Availability"}),s.jsxs("label",{className:"flex cursor-pointer items-center gap-2 text-sm text-neutral-700 dark:text-neutral-300",children:[s.jsx("input",{type:"checkbox",checked:t.inStock??!1,onChange:h=>n({...t,inStock:h.target.checked})}),"In stock"]})]}):null]}):null}function Ec(e){return s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),s.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]})}function fj(e){return s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[s.jsx("path",{d:"M3 6h18"}),s.jsx("path",{d:"M8 6V4h8v2"}),s.jsx("path",{d:"M6 6l1 16h10l1-16"}),s.jsx("path",{d:"M10 11v6"}),s.jsx("path",{d:"M14 11v6"})]})}function qa({item:e,onRemove:t,onSetQty:n,variant:r="table",className:o,inventory:a}){const i=e.unitPrice*e.qty,[c,l]=m.useState(!1),d=m.useMemo(()=>{if(a?.availableQty)return a.availableQty},[a?.availableQty]),f=!a?.isOutOfStock&&(d===void 0||e.qty<d),u=m.useMemo(()=>a?a.isOutOfStock?{type:"error",message:a.message||"Out of stock"}:a.exceedsAvailable?{type:"warning",message:a.message||"Quantity exceeds available stock"}:a.isLowStock?{type:"info",message:a.message||"Low stock"}:null:null,[a]);return m.useEffect(()=>{c&&e.qty!==1&&l(!1)},[c,e.qty]),r==="compact"?s.jsxs("div",{className:L("flex items-start gap-3",o),children:[s.jsx("div",{className:"h-12 w-12 shrink-0 overflow-hidden rounded-lg border border-neutral-200 bg-neutral-100 dark:border-neutral-800 dark:bg-neutral-900",children:e.imageSnapshot?s.jsx("img",{src:e.imageSnapshot,alt:e.titleSnapshot,className:"h-full w-full object-cover"}):null}),s.jsx("div",{className:"min-w-0 flex-1",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"truncate text-sm font-medium text-neutral-950 dark:text-neutral-50",children:e.titleSnapshot}),s.jsx("div",{className:"mt-0.5 text-xs tabular-nums text-neutral-600 dark:text-neutral-400",children:Be({amount:i,currency:e.currency})}),u&&s.jsxs("div",{className:L("mt-1 flex items-center gap-1 text-[11px]",u.type==="error"&&"text-red-600 dark:text-red-400",u.type==="warning"&&"text-amber-600 dark:text-amber-400",u.type==="info"&&"text-blue-600 dark:text-blue-400"),children:[s.jsx(Ec,{className:"h-3 w-3 shrink-0"}),s.jsx("span",{children:u.message})]})]}),s.jsx("div",{className:"flex h-12 w-[140px] shrink-0 items-center justify-end",children:c?s.jsxs("div",{className:"flex w-full flex-col items-center justify-center gap-2",children:[s.jsx("div",{className:"text-center text-[11px] font-medium leading-none text-neutral-600 dark:text-neutral-400",children:"Remove item?"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ne,{type:"button",variant:"outline",className:"h-7 w-[62px] px-0 text-[11px] leading-none",onClick:()=>l(!1),children:"Cancel"}),s.jsx(ne,{type:"button",variant:"destructive",className:"h-7 w-[62px] px-0 text-[11px] leading-none",onClick:t,children:"Confirm"})]})]}):s.jsxs("div",{className:"flex items-center justify-end gap-1.5 whitespace-nowrap",children:[s.jsx(ne,{type:"button",size:"icon",variant:"outline",className:"h-8 w-8","aria-label":e.qty===1?"Remove item":"Decrease quantity",onClick:()=>{if(e.qty===1){l(!0);return}n(e.qty-1)},children:e.qty===1?s.jsx(fj,{className:"h-4 w-4"}):"-"}),s.jsx(Fe,{inputMode:"numeric",pattern:"[0-9]*",value:String(e.qty),onChange:h=>{const g=Math.floor(Number(h.target.value));if(!Number.isFinite(g))return;const y=Math.max(1,d?Math.min(d,g):g);n(y)},className:"h-8 w-11 px-2 text-center","aria-label":"Quantity"}),s.jsx(ne,{type:"button",size:"icon",variant:"outline",className:"h-8 w-8","aria-label":"Increase quantity",onClick:()=>n(d?Math.min(d,e.qty+1):e.qty+1),disabled:!f,children:"+"})]})})]})})]}):s.jsxs("div",{className:L("grid grid-cols-[64px_1fr] items-start gap-x-4 gap-y-3 sm:grid-cols-[64px_1fr_176px_120px]",o),children:[s.jsx("div",{className:"h-16 w-16 overflow-hidden rounded-lg border border-neutral-200 bg-neutral-100 dark:border-neutral-800 dark:bg-neutral-900",children:e.imageSnapshot?s.jsx("img",{src:e.imageSnapshot,alt:e.titleSnapshot,className:"h-full w-full object-cover"}):null}),s.jsxs("div",{className:"col-start-2 row-start-1 min-w-0",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsx("div",{className:"truncate text-sm font-medium text-neutral-950 dark:text-neutral-50",children:e.titleSnapshot}),s.jsx("div",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50 sm:hidden",children:Be({amount:i,currency:e.currency})})]}),s.jsxs("div",{className:"mt-1 text-xs text-neutral-600 dark:text-neutral-400",children:[Be({amount:e.unitPrice,currency:e.currency})," each"]}),u&&s.jsxs("div",{className:L("mt-1.5 flex items-center gap-1 text-xs",u.type==="error"&&"text-red-600 dark:text-red-400",u.type==="warning"&&"text-amber-600 dark:text-amber-400",u.type==="info"&&"text-blue-600 dark:text-blue-400"),children:[s.jsx(Ec,{className:"h-3.5 w-3.5 shrink-0"}),s.jsx("span",{children:u.message})]})]}),s.jsxs("div",{className:"col-span-2 col-start-1 row-start-2 flex items-center justify-between gap-3 sm:col-span-1 sm:col-start-3 sm:row-start-1 sm:justify-center",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ne,{type:"button",size:"icon",variant:"outline",className:"h-9 w-9","aria-label":"Decrease quantity",onClick:()=>n(Math.max(1,e.qty-1)),children:"-"}),s.jsx(Fe,{inputMode:"numeric",pattern:"[0-9]*",value:String(e.qty),onChange:h=>{const g=Math.floor(Number(h.target.value));if(!Number.isFinite(g))return;const y=Math.max(1,d?Math.min(d,g):g);n(y)},className:"h-9 w-14 text-center","aria-label":"Quantity"}),s.jsx(ne,{type:"button",size:"icon",variant:"outline",className:"h-9 w-9","aria-label":"Increase quantity",onClick:()=>n(d?Math.min(d,e.qty+1):e.qty+1),disabled:!f,children:"+"})]}),s.jsx(ne,{type:"button",variant:"ghost",className:"h-9 px-2 text-xs text-red-600 dark:text-red-400 sm:hidden",onClick:t,children:"Remove"})]}),s.jsxs("div",{className:"hidden sm:col-start-4 sm:row-start-1 sm:flex sm:flex-col sm:items-center sm:text-center",children:[s.jsx("div",{className:"text-sm font-semibold tabular-nums text-neutral-950 dark:text-neutral-50",children:Be({amount:i,currency:e.currency})}),s.jsx(ne,{type:"button",variant:"ghost",className:"mt-1 h-8 px-2 text-xs text-red-600 dark:text-red-400",onClick:t,children:"Remove"})]})]})}function Ga({currency:e,subtotal:t,itemCount:n,onCheckout:r,isCheckoutDisabled:o,checkoutDisabledReason:a,onRemoveUnavailable:i,className:c}){return s.jsxs("div",{className:L("space-y-4",c),children:[s.jsx(yt,{}),s.jsxs("div",{className:"flex items-center justify-between text-sm",children:[s.jsxs("div",{className:"flex items-center gap-2 text-neutral-600 dark:text-neutral-400",children:[s.jsx("span",{children:"Subtotal"}),typeof n=="number"?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-neutral-300 dark:text-neutral-700",children:"·"}),s.jsxs("span",{className:"tabular-nums",children:[n," item",n===1?"":"s"]})]}):null]}),s.jsx("span",{className:"font-semibold text-neutral-950 dark:text-neutral-50",children:Be({amount:t,currency:e})})]}),s.jsx(ne,{type:"button",onClick:r,disabled:o,className:"w-full",children:"Checkout"}),o&&a&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-center text-xs text-amber-600 dark:text-amber-400",children:a}),i&&s.jsx("button",{type:"button",onClick:i,className:"mx-auto block text-xs text-neutral-500 underline underline-offset-2 hover:text-neutral-700 dark:text-neutral-400 dark:hover:text-neutral-300",children:"Remove unavailable items"})]})]})}function jf({onCheckout:e,className:t}){const{config:n}=Ee(),r=Rt(),{getItemInventory:o,hasIssues:a}=ia({items:r.items,refreshInterval:3e4,skip:r.items.length===0}),i=()=>{for(const c of r.items){const l=o(c.productId,c.variantId);(l?.isOutOfStock||l?.exceedsAvailable)&&r.removeItem(c.productId,c.variantId)}};return r.items.length===0?s.jsx(Bn,{title:"Cart is empty",description:"Add items from the catalog to check out.",className:t}):s.jsxs("div",{className:L("flex h-full flex-col rounded-xl border border-neutral-200 bg-white p-4 dark:border-neutral-800 dark:bg-neutral-950",t),children:[s.jsx("div",{className:"-mr-4 min-h-0 flex-1 overflow-y-auto overflow-x-hidden pr-4",children:s.jsx("div",{className:"divide-y divide-neutral-200 dark:divide-neutral-800",children:r.items.map(c=>s.jsx("div",{className:"py-3",children:s.jsx(qa,{variant:"compact",item:c,onRemove:()=>r.removeItem(c.productId,c.variantId),onSetQty:l=>r.setQty(c.productId,c.variantId,l),inventory:o(c.productId,c.variantId)})},`${c.productId}::${c.variantId??""}`))})}),s.jsx("div",{className:"mt-4 space-y-4",children:s.jsx(Ga,{currency:n.currency,subtotal:r.subtotal,itemCount:r.count,onCheckout:e,isCheckoutDisabled:r.items.length===0||a,checkoutDisabledReason:a?"Some items have inventory issues":void 0,onRemoveUnavailable:a?i:void 0})})]})}const Sf=m.forwardRef(({className:e,...t},n)=>s.jsx("textarea",{ref:n,className:L("flex min-h-10 w-full rounded-md border border-neutral-200 bg-white px-3 py-2 text-sm text-neutral-950 shadow-sm transition-colors placeholder:text-neutral-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-900/20 disabled:cursor-not-allowed disabled:opacity-50 dark:border-neutral-800 dark:bg-neutral-950 dark:text-neutral-50 dark:placeholder:text-neutral-400 dark:focus-visible:ring-neutral-50/20",e),...t}));Sf.displayName="Textarea";function mj(){const[e,t]=m.useState(!1);return m.useEffect(()=>{const n=window.matchMedia?.("(prefers-reduced-motion: reduce)");if(!n)return;const r=()=>t(n.matches);return r(),n.addEventListener?.("change",r),()=>n.removeEventListener?.("change",r)},[]),e}function Ic({children:e,className:t}){const n=m.useRef(null),r=mj();return m.useEffect(()=>{const o=n.current;!o||r||o.animate([{opacity:0,transform:"translateY(6px)"},{opacity:1,transform:"translateY(0px)"}],{duration:180,easing:"cubic-bezier(0.2, 0.8, 0.2, 1)",fill:"both"})},[r]),s.jsx("div",{ref:n,className:t,children:e})}function wo(){return`${Date.now()}_${Math.random().toString(16).slice(2)}`}function Cf({className:e}){m.useEffect(()=>{console.warn("[ShopChatPanel] This component is experimental and has no backend configured. Messages are handled locally and will not be sent to any server.")},[]);const[t,n]=m.useState(""),[r,o]=m.useState(!1),[a,i]=m.useState(()=>[{id:wo(),role:"agent",text:"Hi! How can we help today? We can recommend products or answer support questions.",createdAt:Date.now()}]),[c,l]=m.useState("…");m.useEffect(()=>{if(!r)return;const g=[".","..","..."];let y=0;const x=window.setInterval(()=>{y=(y+1)%g.length,l(g[y])},450);return()=>window.clearInterval(x)},[r]);const d=m.useRef(null),f=m.useRef(null);m.useEffect(()=>{const g=d.current;g&&(g.scrollTop=g.scrollHeight)},[a.length]);const u=m.useCallback(()=>{const g=f.current;if(!g)return;const y=120;g.style.height="0px";const x=Math.min(y,Math.max(40,g.scrollHeight));g.style.height=`${x}px`,g.style.overflowY=g.scrollHeight>y?"auto":"hidden"},[]);m.useEffect(()=>{u()},[t,u]);const h=m.useCallback(()=>{const g=t.trim();g&&(i(y=>[...y,{id:wo(),role:"user",text:g,createdAt:Date.now()}]),n(""),o(!0),window.setTimeout(()=>{i(y=>[...y,{id:wo(),role:"agent",text:"Got it. Want recommendations, sizing help, or help with an order?",createdAt:Date.now()}]),o(!1)},450))},[t]);return s.jsxs("div",{className:L("flex h-full min-h-0 flex-col",e),children:[s.jsxs("div",{ref:d,className:"min-h-0 flex-1 space-y-3 overflow-y-auto overscroll-contain rounded-2xl border border-neutral-200 bg-white p-4 dark:border-neutral-800 dark:bg-neutral-950",children:[a.map(g=>s.jsx(Ic,{className:L("flex",g.role==="user"?"justify-end":"justify-start"),children:s.jsx("div",{className:L("max-w-[85%] rounded-2xl px-3 py-2 text-sm leading-5",g.role==="user"?"bg-neutral-900 text-neutral-50 dark:bg-neutral-50 dark:text-neutral-900":"bg-neutral-100 text-neutral-900 dark:bg-neutral-800 dark:text-neutral-50"),children:s.jsx("span",{className:"whitespace-pre-wrap break-words",children:g.text})})},g.id)),r?s.jsx(Ic,{className:"flex justify-start",children:s.jsx("div",{className:"max-w-[85%] rounded-2xl bg-neutral-100 px-3 py-2 text-sm leading-5 text-neutral-900 dark:bg-neutral-800 dark:text-neutral-50",children:c})}):null]}),s.jsxs("div",{className:"mt-3 flex shrink-0 items-end gap-2",children:[s.jsx(Sf,{ref:f,rows:1,value:t,onChange:g=>n(g.target.value),placeholder:"Type a message…",className:"max-h-[120px] resize-none",onKeyDown:g=>{g.key==="Enter"&&(g.shiftKey||(g.preventDefault(),h()))}}),s.jsx(ne,{type:"button",onClick:h,disabled:!t.trim(),className:"h-10 shrink-0",children:"Send"})]})]})}function kr({trigger:e,side:t="right",open:n,onOpenChange:r,onCheckout:o,preferredTab:a,className:i}){const[c,l]=m.useState(a??"cart");return m.useEffect(()=>{n&&l(a??"cart")},[n,a]),s.jsxs(Ls,{modal:!1,open:n,onOpenChange:r,children:[e?s.jsx(Ds,{asChild:!0,children:e}):null,s.jsxs(Nr,{side:t,overlayClassName:t==="popup"?"pointer-events-none bg-transparent backdrop-blur-none":"pointer-events-none bg-neutral-950/40 backdrop-blur-none",className:L(t==="bottom"?"h-[85vh] rounded-t-2xl":void 0,t==="popup"?"shadow-xl":"w-full sm:max-w-md",t==="popup"?"h-[min(640px,calc(100vh-2rem))]":void 0,t==="popup"?void 0:"p-4","flex flex-col overflow-hidden",i),children:[s.jsx($s,{className:"space-y-0",children:s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsx(za,{value:c,onValueChange:d=>l(d),children:s.jsxs(Ws,{className:"h-9",children:[s.jsx(_r,{value:"cart",className:"text-sm",children:"Cart"}),s.jsx(_r,{value:"chat",className:"text-sm",children:"Chat"})]})}),s.jsx(Nu,{asChild:!0,children:s.jsx(ne,{type:"button",size:"icon",variant:"ghost",className:"h-9 w-9 rounded-full text-lg leading-none","aria-label":"Close cart",children:"X"})})]})}),s.jsx("div",{className:"mt-3 min-h-0 flex-1 overflow-hidden",children:c==="chat"?s.jsxs("div",{className:"flex h-full flex-col",children:[s.jsx("div",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:"Get help finding a product or ask us any questions. We’re both your shopping assistant and support chat."}),s.jsx("div",{className:"mt-3 min-h-0 flex-1",children:s.jsx(Cf,{className:"h-full"})})]}):s.jsx(jf,{onCheckout:()=>{o(),r?.(!1)},className:"h-full border-0 bg-transparent p-0 shadow-none"})})]})]})}function Ya({value:e,onApply:t,className:n}){const[r,o]=m.useState(e??"");return m.useEffect(()=>{o(e??"")},[e]),s.jsxs("div",{className:L("space-y-2",n),children:[s.jsx("div",{className:"text-sm font-medium text-neutral-950 dark:text-neutral-50",children:"Promo code"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Fe,{value:r,onChange:a=>o(a.target.value),placeholder:"SAVE10","aria-label":"Promo code"}),s.jsx(ne,{type:"button",variant:"outline",onClick:()=>t(r.trim()||void 0),children:"Apply"})]})]})}function Nf({onCheckout:e,showPromoCode:t,className:n}){const{config:r}=Ee(),o=Rt(),{getItemInventory:a,hasIssues:i}=ia({items:o.items,refreshInterval:3e4,skip:o.items.length===0}),c=()=>{for(const l of o.items){const d=a(l.productId,l.variantId);(d?.isOutOfStock||d?.exceedsAvailable)&&o.removeItem(l.productId,l.variantId)}};return o.items.length===0?s.jsx(Bn,{title:"Your cart is empty",description:"Add a few products and come back here when you're ready to check out.",className:n}):s.jsxs("div",{className:L("grid items-start gap-6 lg:grid-cols-[1fr_360px]",n),children:[s.jsxs("div",{className:"self-start rounded-2xl border border-neutral-200 bg-white dark:border-neutral-800 dark:bg-neutral-950",children:[s.jsxs("div",{className:"hidden grid-cols-[64px_1fr_176px_120px] gap-x-4 px-5 py-3 text-xs font-medium text-neutral-500 dark:text-neutral-400 sm:grid",children:[s.jsx("div",{}),s.jsx("div",{children:"Item"}),s.jsx("div",{className:"text-center",children:"Qty"}),s.jsx("div",{className:"text-center",children:"Total"})]}),s.jsx("div",{className:"divide-y divide-neutral-200 dark:divide-neutral-800",children:o.items.map(l=>s.jsx("div",{className:"px-4 py-4 sm:px-5",children:s.jsx(qa,{item:l,onRemove:()=>o.removeItem(l.productId,l.variantId),onSetQty:d=>o.setQty(l.productId,l.variantId,d),inventory:a(l.productId,l.variantId)})},`${l.productId}::${l.variantId??""}`))})]}),s.jsx("div",{className:"lg:sticky lg:top-24 self-start",children:s.jsxs("div",{className:"rounded-2xl border border-neutral-200 bg-white p-5 shadow-sm dark:border-neutral-800 dark:bg-neutral-950",children:[s.jsx("div",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:"Summary"}),s.jsx(yt,{className:"my-4"}),s.jsxs("div",{className:"space-y-4",children:[t?s.jsx(Ya,{value:o.promoCode,onApply:o.setPromoCode}):null,s.jsx(Ga,{currency:r.currency,subtotal:o.subtotal,onCheckout:e,isCheckoutDisabled:o.items.length===0||i,checkoutDisabledReason:i?"Some items have inventory issues":void 0,onRemoveUnavailable:i?c:void 0})]})]})})]})}function Af({left:e,right:t,className:n}){return s.jsxs("div",{className:L("grid items-start gap-8 lg:grid-cols-[1fr_420px]",n),children:[s.jsx("div",{children:e}),s.jsx("div",{children:t})]})}function Ho({title:e,value:t,onChange:n,errors:r,className:o}){return s.jsxs("section",{className:L("space-y-4 rounded-2xl border border-neutral-200 bg-white p-5 dark:border-neutral-800 dark:bg-neutral-950",o),children:[s.jsx("div",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:e}),s.jsxs("div",{className:"grid gap-3",children:[s.jsxs("div",{className:"grid gap-2",children:[s.jsx(st,{htmlFor:`${e}-line1`,children:"Address line 1"}),s.jsx(Fe,{id:`${e}-line1`,value:t.line1,onChange:a=>n({...t,line1:a.target.value}),"aria-invalid":!!r?.line1}),r?.line1?s.jsx("div",{className:"text-xs text-red-600",children:r.line1}):null]}),s.jsxs("div",{className:"grid gap-2",children:[s.jsx(st,{htmlFor:`${e}-line2`,children:"Address line 2"}),s.jsx(Fe,{id:`${e}-line2`,value:t.line2??"",onChange:a=>n({...t,line2:a.target.value})})]}),s.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"grid gap-2",children:[s.jsx(st,{htmlFor:`${e}-city`,children:"City"}),s.jsx(Fe,{id:`${e}-city`,value:t.city,onChange:a=>n({...t,city:a.target.value}),"aria-invalid":!!r?.city}),r?.city?s.jsx("div",{className:"text-xs text-red-600",children:r.city}):null]}),s.jsxs("div",{className:"grid gap-2",children:[s.jsx(st,{htmlFor:`${e}-state`,children:"State"}),s.jsx(Fe,{id:`${e}-state`,value:t.state??"",onChange:a=>n({...t,state:a.target.value})})]})]}),s.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"grid gap-2",children:[s.jsx(st,{htmlFor:`${e}-postal`,children:"Postal code"}),s.jsx(Fe,{id:`${e}-postal`,value:t.postalCode,onChange:a=>n({...t,postalCode:a.target.value}),"aria-invalid":!!r?.postalCode}),r?.postalCode?s.jsx("div",{className:"text-xs text-red-600",children:r.postalCode}):null]}),s.jsxs("div",{className:"grid gap-2",children:[s.jsx(st,{htmlFor:`${e}-country`,children:"Country"}),s.jsx(Fe,{id:`${e}-country`,value:t.country,onChange:a=>n({...t,country:a.target.value}),"aria-invalid":!!r?.country}),r?.country?s.jsx("div",{className:"text-xs text-red-600",children:r.country}):null]})]})]})]})}function Ef({methods:e,value:t,onChange:n,currency:r,className:o}){return e.length===0?null:s.jsxs("section",{className:L("space-y-4 rounded-2xl border border-neutral-200 bg-white p-5 dark:border-neutral-800 dark:bg-neutral-950",o),children:[s.jsx("div",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:"Shipping method"}),s.jsx("div",{className:"space-y-2",children:e.map(a=>{const i=a.id===t;return s.jsxs(ne,{type:"button",variant:i?"default":"outline",className:"h-auto w-full justify-between px-4 py-3",onClick:()=>n(a.id),"aria-pressed":i,children:[s.jsxs("div",{className:"text-left",children:[s.jsx("div",{className:"text-sm font-medium",children:a.label}),a.detail?s.jsx("div",{className:"text-xs opacity-80",children:a.detail}):null]}),s.jsx("div",{className:"text-sm font-semibold",children:Be({amount:a.price,currency:a.currency||r})})]},a.id)})})]})}function _o({message:e}){return e?s.jsx("div",{className:"text-xs text-red-600",children:e}):null}function If({className:e}){const{config:t}=Ee(),n=vs(),r=Rt(),o=t.checkout.mode,a=m.useMemo(()=>Zr(r.items,{requireEmail:t.checkout.requireEmail??!0,defaultMode:o,allowShipping:t.checkout.allowShipping??!1}),[r.items,t.checkout.allowShipping,t.checkout.requireEmail,o]),i=(t.checkout.allowShipping??!1)&&a.shippingAddress&&(o==="shipping"||o==="full"),c=a.email!=="none"||a.name!=="none"||a.phone!=="none",l={line1:"",line2:"",city:"",state:"",postalCode:"",country:"US"},d=n.values.shippingAddress??l,f=n.values.billingAddress??l,u=Cl({enabled:!!t.adapter.getShippingMethods&&i,customer:{email:n.values.email||void 0,name:n.values.name||void 0,shippingAddress:d}});return s.jsxs("form",{className:L("space-y-6",e),onSubmit:h=>h.preventDefault(),children:[a.isDigitalOnly?s.jsx(It,{className:"rounded-2xl",children:s.jsxs(Wt,{className:"p-5",children:[s.jsx("div",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:"Digital delivery"}),s.jsx("div",{className:"mt-1 text-sm text-neutral-600 dark:text-neutral-400",children:a.fulfillmentNotes||"This is a digital product and will be available from your account after purchase."})]})}):null,a.hasPhysical&&!(t.checkout.allowShipping??!1)?s.jsx(It,{className:"rounded-2xl border-red-200 bg-red-50 dark:border-red-900/40 dark:bg-red-950/30",children:s.jsxs(Wt,{className:"p-5",children:[s.jsx("div",{className:"text-sm font-semibold text-red-900 dark:text-red-200",children:"Shipping required"}),s.jsx("div",{className:"mt-1 text-sm text-red-800/90 dark:text-red-200/80",children:"Your cart contains shippable items, but shipping is disabled for this checkout."})]})}):null,c?s.jsxs("section",{className:"space-y-4 rounded-2xl border border-neutral-200 bg-white p-5 dark:border-neutral-800 dark:bg-neutral-950",children:[s.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[s.jsx("div",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:"Contact"}),s.jsx("div",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:a.email==="required"||a.name==="required"||a.phone==="required"?"Required":"Optional"})]}),s.jsxs("div",{className:"grid gap-3",children:[a.email!=="none"?s.jsxs("div",{className:"grid gap-2",children:[s.jsx(st,{htmlFor:"checkout-email",children:"Email"}),s.jsx(Fe,{id:"checkout-email",value:n.values.email??"",onChange:h=>n.setField("email",h.target.value),placeholder:"you@company.com","aria-invalid":!!n.fieldErrors.email,required:a.email==="required"}),s.jsx(_o,{message:n.fieldErrors.email})]}):null,a.name!=="none"?s.jsxs("div",{className:"grid gap-2",children:[s.jsx(st,{htmlFor:"checkout-name",children:"Name"}),s.jsx(Fe,{id:"checkout-name",value:n.values.name??"",onChange:h=>n.setField("name",h.target.value),placeholder:"Full name","aria-invalid":!!n.fieldErrors.name,required:a.name==="required"}),s.jsx(_o,{message:n.fieldErrors.name})]}):null,a.phone!=="none"?s.jsxs("div",{className:"grid gap-2",children:[s.jsx(st,{htmlFor:"checkout-phone",children:"Phone"}),s.jsx(Fe,{id:"checkout-phone",value:n.values.phone??"",onChange:h=>n.setField("phone",h.target.value),placeholder:"Phone number","aria-invalid":!!n.fieldErrors.phone,required:a.phone==="required"}),s.jsx(_o,{message:n.fieldErrors.phone})]}):null]})]}):null,i?s.jsx(Ho,{title:"Shipping address",value:d,onChange:h=>n.setField("shippingAddress",h),errors:{line1:n.fieldErrors["shippingAddress.line1"],city:n.fieldErrors["shippingAddress.city"],postalCode:n.fieldErrors["shippingAddress.postalCode"],country:n.fieldErrors["shippingAddress.country"]}}):null,i&&u.methods.length?s.jsx(Ef,{methods:u.methods,value:n.values.shippingMethodId,onChange:h=>n.setField("shippingMethodId",h),currency:t.currency}):null,o==="full"?s.jsx(Ho,{title:"Billing address",value:f,onChange:h=>n.setField("billingAddress",h)}):null,t.checkout.allowTipping?s.jsxs("section",{className:"space-y-4 rounded-2xl border border-neutral-200 bg-white p-5 dark:border-neutral-800 dark:bg-neutral-950",children:[s.jsx("div",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:"Tip"}),s.jsxs("div",{className:"grid gap-2",children:[s.jsxs(st,{htmlFor:"checkout-tip",children:["Tip amount (",t.currency,")"]}),s.jsx(Fe,{id:"checkout-tip",inputMode:"decimal",value:String(n.values.tipAmount??0),onChange:h=>n.setField("tipAmount",Number(h.target.value)||0)})]})]}):null,o==="full"?s.jsxs("section",{className:"space-y-4 rounded-2xl border border-neutral-200 bg-white p-5 dark:border-neutral-800 dark:bg-neutral-950",children:[s.jsx("div",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:"Notes"}),s.jsxs("div",{className:"grid gap-2",children:[s.jsx(st,{htmlFor:"checkout-notes",children:"Order notes (optional)"}),s.jsx(Fe,{id:"checkout-notes",value:n.values.notes??"",onChange:h=>n.setField("notes",h.target.value),placeholder:"Delivery instructions, gift note…"})]})]}):null]})}function pj(e){return s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),s.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]})}function hj(e){return s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[s.jsx("path",{d:"M3 6h18"}),s.jsx("path",{d:"M8 6V4h8v2"}),s.jsx("path",{d:"M6 6l1 16h10l1-16"})]})}function Tf({open:e,onOpenChange:t,issues:n,onRemoveItem:r,onUpdateQuantity:o,onGoToCart:a,className:i}){const c=n.some(l=>l.type==="out_of_stock"||l.type==="product_unavailable");return s.jsx(Na,{open:e,onOpenChange:t,children:s.jsxs(Os,{className:L("sm:max-w-lg",i),children:[s.jsxs(Ea,{children:[s.jsxs(Ms,{className:"flex items-center gap-2",children:[s.jsx(pj,{className:"h-5 w-5 text-amber-500"}),"Inventory Update"]}),s.jsx(Ia,{children:c?"Some items in your cart are no longer available.":"Some items in your cart have limited availability."})]}),s.jsx("div",{className:"my-4 divide-y divide-neutral-200 dark:divide-neutral-800",children:n.map(l=>s.jsx(gj,{issue:l,onRemove:()=>r(l.productId,l.variantId),onUpdateQty:d=>o(l.productId,l.variantId,d)},`${l.productId}::${l.variantId??""}`))}),s.jsxs(Cu,{className:"flex-col gap-2 sm:flex-row",children:[a?s.jsx(ne,{type:"button",variant:"outline",onClick:()=>{t(!1),a()},children:"Go to Cart"}):null,s.jsx(ne,{type:"button",onClick:()=>t(!1),children:"Continue"})]})]})})}function gj({issue:e,onRemove:t,onUpdateQty:n}){const r=e.type==="out_of_stock"||e.type==="product_unavailable";return s.jsxs("div",{className:"flex items-start gap-3 py-3",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"text-sm font-medium text-neutral-900 dark:text-neutral-100",children:e.title}),s.jsx("div",{className:L("mt-0.5 text-sm",r?"text-red-600 dark:text-red-400":"text-amber-600 dark:text-amber-400"),children:e.message}),e.type==="insufficient_stock"&&e.availableQty>0?s.jsxs("div",{className:"mt-1 text-xs text-neutral-500 dark:text-neutral-400",children:["You requested ",e.requestedQty,", but only ",e.availableQty," available"]}):null]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.type==="insufficient_stock"&&e.availableQty>0?s.jsxs(ne,{type:"button",size:"sm",variant:"outline",onClick:()=>n(e.availableQty),children:["Update to ",e.availableQty]}):null,s.jsxs(ne,{type:"button",size:"sm",variant:"ghost",className:"text-red-600 hover:bg-red-50 hover:text-red-700 dark:text-red-400 dark:hover:bg-red-950/30 dark:hover:text-red-300",onClick:t,children:[s.jsx(hj,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Remove"})]})]})]})}function Pf({className:e,ctaLabel:t,renderEmbedded:n,embeddedFallback:r,renderCustom:o,customFallback:a}){const{config:i}=Ee(),c=Rt(),l=vs(),{config:d,isLoading:f}=Al(),[u,h]=m.useState(!1);m.useEffect(()=>{let M=!0;return Promise.resolve().then(()=>require("./walletDetection-bNmV5ItZ.js")).then(U=>{M&&h(U.detectSolanaWallets())}),()=>{M=!1}},[]);const g=Nl({items:c.items}),[y,x]=m.useState(!1),p=m.useMemo(()=>i.checkout.paymentMethods&&i.checkout.paymentMethods.length?i.checkout.paymentMethods:[{id:"card",label:"Card",ctaLabel:"Pay now"}],[i.checkout.paymentMethods]),v=m.useMemo(()=>p.filter(U=>!(U.id==="card"&&!d.card||U.id==="crypto"&&!d.crypto||U.id==="credits"&&!d.credits||U.id==="crypto"&&!u)),[u,p,d]),[_,w]=m.useState((v[0]??p[0])?.id??"card");m.useEffect(()=>{v.length&&(v.some(M=>M.id===_)||w(v[0].id))},[_,v]),m.useEffect(()=>{l.reset()},[_]);const b=v.find(M=>M.id===_)??p.find(M=>M.id===_)??p[0]??{ctaLabel:"Pay now"},j=b.description??(_==="crypto"?"Pay using a connected wallet.":void 0),R=_==="crypto"&&!u,I=f||l.status==="validating"||l.status==="creating_session"||l.status==="redirecting"||g.isVerifying,C=t??b.ctaLabel??(i.checkout.mode==="none"?"Continue to payment":"Pay now"),E=m.useCallback(async M=>{const U=await g.verify();if(!U.ok&&U.issues.length>0){x(!0);return}l.createCheckoutSession({paymentMethodId:M})},[l,g]),O=l.session?.kind==="embedded"?l.session:null,F=l.session?.kind==="custom"?l.session:null;return s.jsxs("div",{className:L("space-y-3",e),children:[v.length>1?s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"text-xs font-medium text-neutral-600 dark:text-neutral-400",children:"Payment method"}),s.jsx(za,{value:_,onValueChange:w,children:s.jsx(Ws,{className:"w-full",children:v.map(M=>s.jsx(_r,{value:M.id,className:"flex-1",disabled:I,children:M.label},M.id))})})]}):null,l.error?s.jsx("div",{className:"rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-800 dark:border-red-900/40 dark:bg-red-950/30 dark:text-red-200",children:l.error}):null,F?s.jsx("div",{className:"space-y-3",children:o?o(F):a??s.jsx("div",{className:"rounded-lg border border-neutral-200 bg-neutral-50 p-4 text-sm text-neutral-700 dark:border-neutral-800 dark:bg-neutral-900/40 dark:text-neutral-300",children:"Checkout session created. Provide `renderCustom` to render a custom payment UI."})}):O?s.jsx("div",{className:"space-y-3",children:n?n(O):r??s.jsx("div",{className:"rounded-lg border border-neutral-200 bg-neutral-50 p-4 text-sm text-neutral-700 dark:border-neutral-800 dark:bg-neutral-900/40 dark:text-neutral-300",children:"Embedded checkout session created. Provide `renderEmbedded` to render your payment UI."})}):s.jsx(ne,{type:"button",className:"w-full",disabled:c.items.length===0||I||R,onClick:()=>{E(_)},children:g.isVerifying?"Checking availability…":I?"Processing…":C}),!O&&!F?s.jsx("p",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:R?"Install a browser wallet to enable crypto payments.":j??"You will be redirected to complete your payment."}):null,s.jsx(Tf,{open:y,onOpenChange:M=>{x(M),M||g.reset()},issues:g.result?.issues??[],onRemoveItem:(M,U)=>{c.removeItem(M,U)},onUpdateQuantity:(M,U,D)=>{c.setQty(M,U,D)}})]})}function Rf({className:e}){const{config:t}=Ee(),n=Rt(),r=vs(),{settings:o}=Wn(),a=(t.checkout.allowPromoCodes??!1)&&o.checkout.promoCodes;return s.jsxs("div",{className:L("rounded-2xl border border-neutral-200 bg-white p-5 dark:border-neutral-800 dark:bg-neutral-950",e),children:[s.jsx("div",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:"Order review"}),s.jsx(yt,{className:"my-3"}),s.jsx("div",{className:"space-y-3",children:n.items.map(i=>s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[s.jsx("div",{className:"h-10 w-10 shrink-0 overflow-hidden rounded-lg border border-neutral-200 bg-neutral-100 dark:border-neutral-800 dark:bg-neutral-900",children:i.imageSnapshot?s.jsx("img",{src:i.imageSnapshot,alt:i.titleSnapshot,className:"h-full w-full object-cover"}):null}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"line-clamp-1 text-sm text-neutral-950 dark:text-neutral-50",children:i.titleSnapshot}),s.jsxs("div",{className:"text-xs text-neutral-600 dark:text-neutral-400",children:["Qty ",i.qty]})]})]}),s.jsx("div",{className:"text-sm font-semibold tabular-nums text-neutral-950 dark:text-neutral-50",children:Be({amount:i.unitPrice*i.qty,currency:i.currency})})]},`${i.productId}::${i.variantId??""}`))}),s.jsx(yt,{className:"my-3"}),a?s.jsx(Ya,{value:r.values.discountCode??n.promoCode,onApply:i=>{r.setField("discountCode",i??""),n.setPromoCode(i)}}):null,a?s.jsx(yt,{className:"my-3"}):null,s.jsxs("div",{className:"flex items-center justify-between text-sm",children:[s.jsx("span",{className:"text-neutral-600 dark:text-neutral-400",children:"Subtotal"}),s.jsx("span",{className:"font-semibold text-neutral-950 dark:text-neutral-50",children:Be({amount:n.subtotal,currency:t.currency})})]})]})}function Gs({result:e,onContinueShopping:t,onViewOrders:n,className:r}){return e.kind==="idle"?null:e.kind==="success"?s.jsxs("div",{className:L("rounded-2xl border border-neutral-200 bg-white p-8 text-neutral-950 dark:border-neutral-800 dark:bg-neutral-950 dark:text-neutral-50",r),children:[s.jsx("div",{className:"text-sm font-semibold text-neutral-600 dark:text-neutral-400",children:"Receipt"}),s.jsx("h2",{className:"mt-2 text-2xl font-semibold",children:"Payment successful"}),s.jsx("p",{className:"mt-2 text-sm text-neutral-600 dark:text-neutral-400",children:"Thanks for your purchase. You’ll receive a confirmation email shortly."}),e.order?s.jsxs("div",{className:"mt-5 rounded-xl border border-neutral-200 bg-neutral-50 p-4 dark:border-neutral-800 dark:bg-neutral-900/40",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:["Order ",e.order.id]}),s.jsxs("div",{className:"mt-1 text-xs text-neutral-600 dark:text-neutral-400",children:[new Date(e.order.createdAt).toLocaleString()," · ",e.order.status]})]}),s.jsx("div",{className:"text-sm font-semibold",children:Be({amount:e.order.total,currency:e.order.currency})})]}),s.jsxs("div",{className:"mt-3 space-y-2",children:[e.order.items.slice(0,4).map((o,a)=>s.jsxs("div",{className:"flex items-center justify-between gap-3 text-sm",children:[s.jsx("div",{className:"min-w-0 truncate",children:o.title}),s.jsxs("div",{className:"shrink-0 text-neutral-600 dark:text-neutral-400",children:["Qty ",o.qty]})]},`${o.title}-${a}`)),e.order.items.length>4?s.jsxs("div",{className:"text-xs text-neutral-600 dark:text-neutral-400",children:["+",e.order.items.length-4," more item(s)"]}):null]}),s.jsxs("div",{className:"mt-3 flex gap-3 text-sm",children:[e.order.receiptUrl?s.jsx("a",{href:e.order.receiptUrl,className:"hover:underline",children:"Receipt"}):null,e.order.invoiceUrl?s.jsx("a",{href:e.order.invoiceUrl,className:"hover:underline",children:"Invoice"}):null]})]}):e.orderId?s.jsxs("p",{className:"mt-4 text-xs text-neutral-500 dark:text-neutral-400",children:["Session/Order ID: ",s.jsx("span",{className:"font-mono",children:e.orderId})]}):null,s.jsxs("div",{className:"mt-6 flex flex-col gap-2 sm:flex-row",children:[t?s.jsx(ne,{type:"button",onClick:t,children:"Continue shopping"}):null,n?s.jsx(ne,{type:"button",variant:"outline",onClick:n,children:"View orders"}):null]})]}):e.kind==="cancel"?s.jsxs("div",{className:L("rounded-2xl border border-neutral-200 bg-white p-8 text-neutral-950 dark:border-neutral-800 dark:bg-neutral-950 dark:text-neutral-50",r),children:[s.jsx("h2",{className:"text-2xl font-semibold",children:"Checkout cancelled"}),s.jsx("p",{className:"mt-2 text-sm text-neutral-600 dark:text-neutral-400",children:"No charges were made. You can continue shopping and try again."}),t?s.jsx("div",{className:"mt-6",children:s.jsx(ne,{type:"button",onClick:t,children:"Back to shop"})}):null]}):s.jsxs("div",{className:L("rounded-2xl border border-neutral-200 bg-white p-8 text-neutral-950 dark:border-neutral-800 dark:bg-neutral-950 dark:text-neutral-50",r),children:[s.jsx("h2",{className:"text-2xl font-semibold",children:"Payment failed"}),s.jsx("p",{className:"mt-2 text-sm text-neutral-600 dark:text-neutral-400",children:e.message??"Something went wrong while processing your payment."}),t?s.jsx("div",{className:"mt-6",children:s.jsx(ne,{type:"button",onClick:t,children:"Back to shop"})}):null]})}function xj({onContinueShopping:e,onViewOrders:t,className:n,receiptClassName:r}){const o=sa();return o.kind==="idle"?s.jsx("div",{className:L("flex min-h-[50vh] items-center justify-center p-4",n),children:s.jsx("div",{className:"text-center text-neutral-600 dark:text-neutral-400",children:"Loading order details..."})}):s.jsx("div",{className:L("flex min-h-[50vh] items-center justify-center p-4",n),children:s.jsx(Gs,{result:o,onContinueShopping:e,onViewOrders:t,className:L("w-full max-w-lg",r)})})}function vj({onContinueShopping:e,className:t,receiptClassName:n}){const r={kind:"cancel"};return s.jsx("div",{className:L("flex min-h-[50vh] items-center justify-center p-4",t),children:s.jsx(Gs,{result:r,onContinueShopping:e,className:L("w-full max-w-lg",n)})})}function yj(e){switch(e){case"created":return"secondary";case"paid":return"default";case"processing":return"secondary";case"fulfilled":return"outline";case"shipped":return"default";case"delivered":return"outline";case"cancelled":return"outline";case"refunded":return"outline";default:return"secondary"}}function Of({order:e,onView:t,className:n}){const r=`${e.items.length} item${e.items.length===1?"":"s"}`,o=new Date(e.createdAt).toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}),a=e.status.charAt(0).toUpperCase()+e.status.slice(1);return s.jsx(It,{className:L("group overflow-hidden rounded-2xl border-neutral-200/70 bg-white shadow-sm transition-shadow hover:shadow-md dark:border-neutral-800 dark:bg-neutral-950",n),children:s.jsx(Wt,{className:"p-5",children:s.jsxs("div",{className:"grid grid-cols-[1fr_auto] gap-x-4 gap-y-2",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[s.jsx("span",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:"Order"}),s.jsx("span",{className:"truncate font-mono text-sm font-semibold text-neutral-950/80 dark:text-neutral-50/80",children:e.id})]}),s.jsx("div",{className:"mt-0.5 text-xs text-neutral-600 dark:text-neutral-400",children:o})]}),s.jsx("div",{className:"flex items-start justify-end",children:s.jsx(vn,{variant:yj(e.status),className:"capitalize",children:a})}),s.jsx("div",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:r}),s.jsx("div",{className:"text-right text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:Be({amount:e.total,currency:e.currency})}),s.jsxs("div",{className:"col-span-2 mt-3 flex items-center justify-between gap-3 border-t border-neutral-200/70 pt-3 dark:border-neutral-800",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[e.receiptUrl?s.jsx(ne,{asChild:!0,type:"button",variant:"ghost",size:"sm",className:"h-8 px-2",children:s.jsx("a",{href:e.receiptUrl,target:"_blank",rel:"noreferrer",children:"Receipt"})}):null,e.invoiceUrl?s.jsx(ne,{asChild:!0,type:"button",variant:"ghost",size:"sm",className:"h-8 px-2",children:s.jsx("a",{href:e.invoiceUrl,target:"_blank",rel:"noreferrer",children:"Invoice"})}):null]}),t?s.jsx(ne,{type:"button",variant:"outline",size:"sm",className:"h-8",onClick:()=>t(e),children:"Details"}):null]})]})})})}function Mf({orders:e,onView:t,className:n}){return s.jsx("div",{className:L("grid gap-4",n),children:e.map(r=>s.jsx(Of,{order:r,onView:t},r.id))})}function bj(e){switch(e){case"paid":return"default";case"processing":return"secondary";case"fulfilled":return"outline";case"cancelled":return"outline";case"refunded":return"outline";default:return"secondary"}}function Lf({order:e,onBack:t,className:n}){const r=new Date(e.createdAt).toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}),o=e.status.charAt(0).toUpperCase()+e.status.slice(1);return s.jsx(It,{className:L("overflow-hidden rounded-2xl border-neutral-200/70 bg-white shadow-sm dark:border-neutral-800 dark:bg-neutral-950",n),children:s.jsxs(Wt,{className:"p-6",children:[s.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[s.jsx("span",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:"Order"}),s.jsx("span",{className:"truncate font-mono text-sm font-semibold text-neutral-950/80 dark:text-neutral-50/80",children:e.id})]}),s.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-neutral-600 dark:text-neutral-400",children:[s.jsx("span",{children:r}),s.jsx("span",{className:"text-neutral-300 dark:text-neutral-700",children:"·"}),s.jsx("span",{children:o})]})]}),s.jsxs("div",{className:"flex items-center gap-2 sm:justify-end",children:[s.jsx(vn,{variant:bj(e.status),className:"capitalize",children:o}),t?s.jsx(ne,{type:"button",variant:"outline",size:"sm",className:"h-8",onClick:t,children:"Back"}):null]})]}),s.jsx(yt,{className:"my-5"}),s.jsx("div",{className:"space-y-3",children:e.items.map((a,i)=>s.jsxs("div",{className:"flex items-start justify-between gap-4",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"truncate text-sm text-neutral-950 dark:text-neutral-50",children:a.title}),s.jsxs("div",{className:"mt-0.5 text-xs text-neutral-600 dark:text-neutral-400",children:["Qty ",a.qty]})]}),s.jsx("div",{className:"text-right text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:Be({amount:a.unitPrice*a.qty,currency:a.currency})})]},`${a.title}-${i}`))}),s.jsx(yt,{className:"my-5"}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:"Total"}),s.jsx("span",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:Be({amount:e.total,currency:e.currency})})]}),e.receiptUrl||e.invoiceUrl?s.jsxs("div",{className:"mt-5 flex flex-wrap items-center gap-2",children:[e.receiptUrl?s.jsx(ne,{asChild:!0,type:"button",variant:"ghost",size:"sm",className:"h-8 px-2",children:s.jsx("a",{href:e.receiptUrl,target:"_blank",rel:"noreferrer",children:"Receipt"})}):null,e.invoiceUrl?s.jsx(ne,{asChild:!0,type:"button",variant:"ghost",size:"sm",className:"h-8 px-2",children:s.jsx("a",{href:e.invoiceUrl,target:"_blank",rel:"noreferrer",children:"Invoice"})}):null]}):null]})})}function Qa(e){const t={};e.shippingProfile&&(t.shippingProfile=e.shippingProfile),e.checkoutRequirements&&(t.checkoutRequirements=JSON.stringify(e.checkoutRequirements)),e.fulfillment?.type&&(t.fulfillmentType=e.fulfillment.type),e.fulfillment?.notes&&(t.fulfillmentNotes=e.fulfillment.notes);const n=e.attributes?.shippingCountries;return typeof n=="string"&&n.trim()&&(t.shippingCountries=n),Object.keys(t).length?t:void 0}function wj(e){return s.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:s.jsx("path",{d:"M21 15a4 4 0 0 1-4 4H8l-5 3V7a4 4 0 0 1 4-4h10a4 4 0 0 1 4 4z"})})}const _j={shop:"/shop",category:e=>`/shop/${e}`,product:e=>`/product/${e}`,cart:"/cart",checkout:"/checkout",orders:"/account/orders",subscribe:"/subscribe"};function kj(e){const t=new Set;let n=Number.POSITIVE_INFINITY,r=0;for(const i of e){for(const c of i.tags??[])t.add(c);n=Math.min(n,i.price),r=Math.max(r,i.price)}const o=Array.from(t).slice(0,12),a=Number.isFinite(n)?{min:n,max:r}:void 0;return{tags:o,price:a}}function jj({className:e,routes:t,initialCategorySlug:n}){const{config:r}=Ee(),o=Rt(),a=Hs(),i={..._j,...t},[c,l]=m.useState("cart"),[d,f]=m.useState(()=>typeof window>"u"?!1:window.matchMedia?.("(min-width: 1024px)")?.matches??!1);m.useEffect(()=>{if(typeof window>"u")return;const P=window.matchMedia?.("(min-width: 1024px)");if(!P)return;const G=()=>f(P.matches);return G(),P.addEventListener?.("change",G),()=>P.removeEventListener?.("change",G)},[]);const{categories:u,isLoading:h,error:g}=na(),y=m.useMemo(()=>oa({includeCategory:!0}),[]),[x,p]=m.useState(y?.search??""),[v,_]=m.useState(n??y?.category),[w,b]=m.useState(y?.page??1),[j,R]=m.useState(y?.sort??"featured"),[I,C]=m.useState(y?.filters??{}),{data:E,isLoading:O,error:F}=ys({category:v,search:x.trim()||void 0,filters:I,sort:j,page:w,pageSize:24}),M=m.useMemo(()=>kj(E?.items??[]),[E?.items]),{settings:U}=Wn(),D=U.catalog.filters,H=U.catalog.sort,z=m.useMemo(()=>{const P=[];return H.featured&&P.push({value:"featured",label:"Featured"}),H.priceAsc&&P.push({value:"price_asc",label:"Price: Low to High"}),H.priceDesc&&P.push({value:"price_desc",label:"Price: High to Low"}),P.length===0&&P.push({value:"featured",label:"Featured"}),P},[H]);m.useEffect(()=>{z.some(P=>P.value===j)||R(z[0].value)},[z,j]),aa({search:x,sort:j,page:w,category:v,filters:I},{includeCategory:!0});const[A,N]=m.useState(!1),[Z,te]=m.useState(!1),[re,de]=m.useState(null),[W,Q]=m.useState(!1),q=P=>{_(P.slug),b(1),N(!1)},he=m.useCallback((P,G,ue)=>{o.addItem({productId:P.id,variantId:G?.id,unitPrice:P.price,currency:P.currency,titleSnapshot:G?`${P.title} — ${G.title}`:P.title,imageSnapshot:P.images[0]?.url,paymentResource:P.id,metadata:Qa(P)},ue),a?.toast({title:"Added to cart",description:P.title,actionLabel:"View cart",onAction:()=>{typeof window<"u"&&(window.matchMedia?.("(min-width: 1024px)").matches?window.location.assign(i.cart):(l("cart"),te(!0)))}})},[o,i.cart,a]);return s.jsxs("div",{className:L("min-h-screen bg-neutral-50 text-neutral-950 dark:bg-neutral-950 dark:text-neutral-50",e),children:[s.jsx("header",{className:"sticky top-0 z-40 border-b border-neutral-200 bg-neutral-50/80 backdrop-blur dark:border-neutral-800 dark:bg-neutral-950/70",children:s.jsxs("div",{className:"mx-auto flex max-w-7xl items-center gap-3 px-4 py-3",children:[s.jsx("a",{href:i.shop,className:"text-sm font-semibold tracking-tight",children:r.brand?.name??"Shop"}),s.jsx("div",{className:"flex-1",children:s.jsx(Za,{value:x,onChange:p})}),s.jsxs("div",{className:"flex items-center gap-2 lg:hidden",children:[s.jsxs(Ls,{open:A,onOpenChange:N,children:[s.jsx(Ds,{asChild:!0,children:s.jsx(ne,{type:"button",variant:"outline",children:"Filters"})}),s.jsxs(Nr,{side:"left",children:[s.jsx($s,{children:s.jsx(zs,{children:"Browse"})}),s.jsxs("div",{className:"mt-4",children:[g?s.jsx(Vt,{description:g}):null,h?s.jsxs("div",{className:"space-y-2",children:[s.jsx(Re,{className:"h-9"}),s.jsx(Re,{className:"h-9"}),s.jsx(Re,{className:"h-9"})]}):s.jsxs("div",{className:"space-y-6",children:[s.jsx(Wo,{categories:u,activeSlug:v,onSelect:q}),s.jsx(ms,{facets:M,value:I,onChange:P=>{C(P),b(1)},onClear:()=>{C({}),b(1)},enabledFilters:D}),z.length>1&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"text-sm font-semibold",children:"Sort"}),s.jsxs(ls,{value:j,onValueChange:P=>{R(P),b(1)},children:[s.jsx(yr,{"aria-label":"Sort",children:s.jsx(ds,{placeholder:"Sort"})}),s.jsx(br,{children:z.map(P=>s.jsx(wr,{value:P.value,children:P.label},P.value))})]})]})]})]})]})]}),s.jsx(kr,{open:!d&&Z,onOpenChange:te,side:"bottom",preferredTab:c,onCheckout:()=>{typeof window<"u"&&window.location.assign(i.checkout)},trigger:s.jsxs(ne,{type:"button",variant:"default",onClick:()=>l("cart"),children:["Cart (",o.count,")"]})})]}),s.jsxs("div",{className:"hidden lg:flex items-center gap-2",children:[s.jsx(kr,{open:d&&Z,onOpenChange:te,side:"popup",preferredTab:c,onCheckout:()=>{typeof window<"u"&&window.location.assign(i.checkout)},trigger:s.jsxs(ne,{type:"button",variant:"outline",onClick:()=>l("cart"),children:["Cart (",o.count,")"]})}),s.jsx(ne,{type:"button",variant:"default",onClick:()=>{typeof window<"u"&&window.location.assign(i.checkout)},children:"Checkout"})]})]})}),s.jsxs(ne,{type:"button",variant:"ghost",className:L("fixed bottom-4 right-4 z-30 hidden items-center gap-2 rounded-full border border-neutral-200 bg-white/90 px-3 py-2 text-xs font-medium text-neutral-900 shadow-sm backdrop-blur hover:bg-white dark:border-neutral-800 dark:bg-neutral-950/80 dark:text-neutral-50 dark:hover:bg-neutral-950 lg:flex",Z?"lg:hidden":void 0),onClick:()=>{l("chat"),te(!0)},"aria-label":"Open chat",children:[s.jsx(wj,{className:"h-4 w-4"}),"Chat"]}),s.jsxs("main",{className:"mx-auto grid max-w-7xl items-start gap-6 px-4 py-6 lg:grid-cols-[280px_1fr]",children:[s.jsx("aside",{className:"hidden lg:block",children:s.jsx("div",{className:"sticky top-24",children:s.jsxs(It,{className:"flex max-h-[calc(100vh-6rem)] flex-col rounded-2xl",children:[s.jsx(hr,{className:"pb-4",children:s.jsx(gr,{className:"text-base",children:"Browse"})}),s.jsxs(Wt,{className:"flex-1 space-y-6 overflow-y-auto pr-2",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-semibold",children:"Categories"}),g?s.jsx(Vt,{className:"mt-3",description:g}):null,h?s.jsxs("div",{className:"mt-3 space-y-2",children:[s.jsx(Re,{className:"h-9"}),s.jsx(Re,{className:"h-9"}),s.jsx(Re,{className:"h-9"})]}):s.jsx("div",{className:"mt-3",children:s.jsx(Wo,{categories:u,activeSlug:v,onSelect:q})})]}),z.length>1&&s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-semibold",children:"Sort"}),s.jsx("div",{className:"mt-2",children:s.jsxs(ls,{value:j,onValueChange:P=>{R(P),b(1)},children:[s.jsx(yr,{"aria-label":"Sort",children:s.jsx(ds,{placeholder:"Sort"})}),s.jsx(br,{children:z.map(P=>s.jsx(wr,{value:P.value,children:P.label},P.value))})]})})]}),s.jsx(ms,{facets:M,value:I,onChange:P=>{C(P),b(1)},onClear:()=>{C({}),b(1)},enabledFilters:D})]})]})})}),s.jsxs("section",{children:[s.jsx("div",{className:"flex items-end justify-between gap-3",children:s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:U.shopPage.title||"Shop"}),U.shopPage.description&&s.jsx("p",{className:"mt-1 text-sm text-neutral-600 dark:text-neutral-400",children:U.shopPage.description})]})}),F?s.jsx(Vt,{className:"mt-6",description:F}):null,O?s.jsx("div",{className:"mt-6 grid grid-cols-2 gap-4 md:grid-cols-3 lg:grid-cols-4",children:Array.from({length:8}).map((P,G)=>s.jsx(Re,{className:"aspect-[4/5] rounded-2xl"},G))}):s.jsxs("div",{className:"mt-6",children:[s.jsx(qs,{products:E?.items??[],columns:r.ui?.productGrid?.columns,getProductHref:P=>i.product(P.slug),onAddToCart:P=>he(P,null,1),onQuickView:P=>{de(P),Q(!0)},layout:U.shopLayout.layout,imageCrop:U.shopLayout.imageCrop}),s.jsxs("div",{className:"mt-8 flex items-center justify-between",children:[s.jsx(ne,{type:"button",variant:"outline",disabled:w<=1,onClick:()=>b(P=>Math.max(1,P-1)),children:"Previous"}),s.jsxs("div",{className:"text-xs text-neutral-600 dark:text-neutral-400",children:["Page ",w]}),s.jsx(ne,{type:"button",variant:"outline",disabled:!E?.hasNextPage,onClick:()=>b(P=>P+1),children:"Next"})]})]})]})]}),s.jsx(Wa,{product:re,open:W,onOpenChange:Q,productHref:P=>i.product(P),onAddToCart:(P,G,ue)=>he(P,G,ue)})]})}function Sj(e){return s.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:s.jsx("path",{d:"M21 15a4 4 0 0 1-4 4H8l-5 3V7a4 4 0 0 1 4-4h10a4 4 0 0 1 4 4z"})})}function Cj({categorySlug:e,className:t,routes:n}){const{config:r}=Ee(),o=Rt(),a=Hs(),{categories:i}=na(),[c,l]=m.useState(()=>typeof window>"u"?!1:window.matchMedia?.("(min-width: 1024px)")?.matches??!1);m.useEffect(()=>{if(typeof window>"u")return;const B=window.matchMedia?.("(min-width: 1024px)");if(!B)return;const ae=()=>l(B.matches);return ae(),B.addEventListener?.("change",ae),()=>B.removeEventListener?.("change",ae)},[]);const[d,f]=m.useState(!1),[u,h]=m.useState(!1),[g,y]=m.useState("cart"),x=m.useMemo(()=>oa({includeCategory:!1}),[]),[p,v]=m.useState(x?.search??""),[_,w]=m.useState(x?.page??1),[b,j]=m.useState(x?.sort??"featured"),[R,I]=m.useState(x?.filters??{}),[C,E]=m.useState(null),[O,F]=m.useState(!1),M=i.find(B=>B.slug===e)??null,{data:U,isLoading:D,error:H}=ys({category:e,search:p.trim()||void 0,filters:R,sort:b,page:_,pageSize:24}),z=n?.product??(B=>`/product/${B}`),A=n?.shop??"/shop",N=n?.cart??"/cart",Z=n?.checkout??"/checkout",te=m.useMemo(()=>{const B=U?.items??[],ae=new Set;let ce=Number.POSITIVE_INFINITY,we=0;for(const Ge of B){for(const We of Ge.tags??[])ae.add(We);ce=Math.min(ce,Ge.price),we=Math.max(we,Ge.price)}const Te=Array.from(ae).slice(0,12),Ve=Number.isFinite(ce)?{min:ce,max:we}:void 0;return{tags:Te,price:Ve}},[U?.items]),{settings:re}=Wn(),de=re.catalog.filters,W=re.catalog.sort,Q=m.useMemo(()=>{const B=[];return W.featured&&B.push({value:"featured",label:"Featured"}),W.priceAsc&&B.push({value:"price_asc",label:"Price: Low to High"}),W.priceDesc&&B.push({value:"price_desc",label:"Price: High to Low"}),B.length===0&&B.push({value:"featured",label:"Featured"}),B},[W]);m.useEffect(()=>{Q.some(B=>B.value===b)||j(Q[0].value)},[Q,b]),aa({search:p,sort:b,page:_,filters:R},{includeCategory:!1});const q=m.useCallback((B,ae,ce)=>{o.addItem({productId:B.id,variantId:ae?.id,unitPrice:B.price,currency:B.currency,titleSnapshot:ae?`${B.title} — ${ae.title}`:B.title,imageSnapshot:B.images[0]?.url,paymentResource:B.id,metadata:Qa(B)},ce),a?.toast({title:"Added to cart",description:B.title,actionLabel:"View cart",onAction:()=>{typeof window<"u"&&(window.matchMedia?.("(min-width: 1024px)").matches?window.location.assign(N):(y("cart"),h(!0)))}})},[o,N,a]),he=B=>{I(B),w(1)},P=()=>{I({}),w(1)},G=B=>{j(B),w(1)},ue=s.jsx(It,{className:"flex max-h-[calc(100vh-6rem)] flex-col rounded-2xl",children:s.jsxs(Wt,{className:"flex-1 space-y-5 overflow-y-auto pr-2 pt-6",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-neutral-500 dark:text-neutral-400",children:"Category"}),s.jsx(ne,{asChild:!0,type:"button",variant:"ghost",size:"sm",className:"h-8 px-2 text-xs",children:s.jsx("a",{href:A,children:"All categories"})})]}),s.jsx("div",{className:"text-base font-semibold text-neutral-950 dark:text-neutral-50",children:M?.name??e}),s.jsx("div",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:M?.description??"Browse products in this category."})]}),Q.length>1&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"text-sm font-semibold",children:"Sort"}),s.jsxs(ls,{value:b,onValueChange:G,children:[s.jsx(yr,{"aria-label":"Sort",children:s.jsx(ds,{placeholder:"Sort"})}),s.jsx(br,{children:Q.map(B=>s.jsx(wr,{value:B.value,children:B.label},B.value))})]})]}),s.jsx(yt,{}),s.jsx(ms,{facets:te,value:R,onChange:he,onClear:P,enabledFilters:de})]})});return s.jsxs("div",{className:L("min-h-screen bg-neutral-50 text-neutral-950 dark:bg-neutral-950 dark:text-neutral-50",t),children:[s.jsx("header",{className:"sticky top-0 z-40 border-b border-neutral-200 bg-neutral-50/80 backdrop-blur dark:border-neutral-800 dark:bg-neutral-950/70",children:s.jsxs("div",{className:"mx-auto flex max-w-7xl items-center gap-3 px-4 py-3",children:[s.jsx("a",{href:A,className:"text-sm font-semibold tracking-tight",children:r.brand?.name??"Shop"}),s.jsx("div",{className:"flex-1",children:s.jsx(Za,{value:p,onChange:v})}),s.jsxs("div",{className:"flex items-center gap-2 lg:hidden",children:[s.jsxs(Ls,{open:d,onOpenChange:f,children:[s.jsx(Ds,{asChild:!0,children:s.jsx(ne,{type:"button",variant:"outline",children:"Filters"})}),s.jsxs(Nr,{side:"left",children:[s.jsx($s,{children:s.jsx(zs,{children:"Filters"})}),s.jsx("div",{className:"mt-4",children:ue})]})]}),s.jsx(kr,{open:!c&&u,onOpenChange:h,side:"bottom",preferredTab:g,onCheckout:()=>{typeof window<"u"&&window.location.assign(Z)},trigger:s.jsxs(ne,{type:"button",variant:"default",onClick:()=>y("cart"),children:["Cart (",o.count,")"]})})]}),s.jsxs("div",{className:"hidden lg:flex items-center gap-2",children:[s.jsx(kr,{open:c&&u,onOpenChange:h,side:"popup",preferredTab:g,onCheckout:()=>{typeof window<"u"&&window.location.assign(Z)},trigger:s.jsxs(ne,{type:"button",variant:"outline",onClick:()=>y("cart"),children:["Cart (",o.count,")"]})}),s.jsx(ne,{type:"button",variant:"default",onClick:()=>{typeof window<"u"&&window.location.assign(Z)},children:"Checkout"})]})]})}),s.jsxs(ne,{type:"button",variant:"ghost",className:L("fixed bottom-4 right-4 z-30 hidden items-center gap-2 rounded-full border border-neutral-200 bg-white/90 px-3 py-2 text-xs font-medium text-neutral-900 shadow-sm backdrop-blur hover:bg-white dark:border-neutral-800 dark:bg-neutral-950/80 dark:text-neutral-50 dark:hover:bg-neutral-950 lg:flex",u?"lg:hidden":void 0),onClick:()=>{y("chat"),h(!0)},"aria-label":"Open chat",children:[s.jsx(Sj,{className:"h-4 w-4"}),"Chat"]}),s.jsxs("main",{className:"mx-auto max-w-7xl px-4 py-8",children:[s.jsx(Ha,{items:[{label:"Shop",href:A},{label:M?.name??e}]}),s.jsxs("div",{className:"mt-6",children:[s.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:M?.name??"Category"}),s.jsx("p",{className:"mt-1 text-sm text-neutral-600 dark:text-neutral-400",children:M?.description??"Browse products in this category."})]}),H?s.jsx(Vt,{className:"mt-6",description:H}):null,s.jsxs("div",{className:"mt-6 grid gap-6 lg:grid-cols-[280px_1fr]",children:[s.jsx("aside",{className:"hidden lg:block",children:s.jsx("div",{className:"sticky top-24",children:ue})}),s.jsx("div",{children:D?s.jsx("div",{className:"mt-6 grid grid-cols-2 gap-4 md:grid-cols-3 lg:grid-cols-4",children:Array.from({length:8}).map((B,ae)=>s.jsx(Re,{className:"aspect-[4/5] rounded-2xl"},ae))}):s.jsxs("div",{className:"mt-6",children:[s.jsx(qs,{products:U?.items??[],columns:r.ui?.productGrid?.columns,getProductHref:B=>z(B.slug),onAddToCart:B=>q(B,null,1),onQuickView:B=>{E(B),F(!0)},layout:re.categoryLayout.layout,imageCrop:re.categoryLayout.imageCrop}),s.jsxs("div",{className:"mt-8 flex items-center justify-between",children:[s.jsx(ne,{type:"button",variant:"outline",disabled:_<=1,onClick:()=>w(B=>Math.max(1,B-1)),children:"Previous"}),s.jsxs("div",{className:"text-xs text-neutral-600 dark:text-neutral-400",children:["Page ",_]}),s.jsx(ne,{type:"button",variant:"outline",disabled:!U?.hasNextPage,onClick:()=>w(B=>B+1),children:"Next"})]})]})})]}),s.jsx(Wa,{product:C,open:O,onOpenChange:F,productHref:B=>z(B),onAddToCart:(B,ae,ce)=>q(B,ae,ce)})]})]})}function Nj(e){return!e||typeof e!="string"?[]:e.split(",").map(t=>t.trim()).filter(Boolean)}function Aj({slug:e,className:t,routes:n}){const r=Rt(),o=Hs(),{product:a,isLoading:i,error:c}=kl(e),[l,d]=m.useState(1),[f,u]=m.useState({selectedOptions:{},variant:null});m.useEffect(()=>{if(!a||!a.variants?.length)return;const D=a.variants[0];u({selectedOptions:{...D.options},variant:D})},[a?.id]);const{settings:h}=Wn(),{mode:g,maxItems:y}=h.relatedProducts,x=El({productId:a?.id,enabled:g==="ai"&&!!a?.id}),p=m.useMemo(()=>g==="by_category"&&a?.categoryIds?.length?{category:a.categoryIds[0],page:1,pageSize:y+1}:{page:1,pageSize:y+4},[g,y,a?.categoryIds]),v=ys(p),_=m.useMemo(()=>{const H=(v.data?.items??[]).filter(z=>z.slug!==e);if(g==="manual"&&a){const z=a.attributes?.relatedProductIds||a.attributes?.related_product_ids;if(z){const A=Nj(String(z));if(A.length>0){const N=new Map(H.map(te=>[te.id,te]));return A.map(te=>N.get(te)).filter(te=>!!te).slice(0,y)}}}if(g==="ai"&&x.relatedProductIds&&x.relatedProductIds.length>0){const z=new Map(H.map(N=>[N.id,N])),A=x.relatedProductIds.map(N=>z.get(N)).filter(N=>!!N);if(A.length>0)return A.slice(0,y)}return H.slice(0,y)},[v.data?.items,e,g,y,a,x.relatedProductIds]),w=n?.shop??"/shop",b=n?.checkout??"/checkout",j=n?.cart??"/cart",R=n?.product??(D=>`/product/${D}`);if(i)return s.jsx("div",{className:L("min-h-screen bg-neutral-50 p-6 dark:bg-neutral-950",t),children:s.jsxs("div",{className:"mx-auto max-w-6xl",children:[s.jsx(Re,{className:"h-5 w-40"}),s.jsxs("div",{className:"mt-6 grid gap-8 lg:grid-cols-2",children:[s.jsx(Re,{className:"aspect-square rounded-2xl"}),s.jsxs("div",{className:"space-y-4",children:[s.jsx(Re,{className:"h-8 w-2/3"}),s.jsx(Re,{className:"h-6 w-32"}),s.jsx(Re,{className:"h-20"}),s.jsx(Re,{className:"h-11"})]})]})]})});if(c)return s.jsx("div",{className:L("min-h-screen bg-neutral-50 p-6 dark:bg-neutral-950",t),children:s.jsx("div",{className:"mx-auto max-w-6xl",children:s.jsx(Vt,{description:c})})});if(!a)return s.jsx("div",{className:L("min-h-screen bg-neutral-50 p-6 dark:bg-neutral-950",t),children:s.jsx("div",{className:"mx-auto max-w-6xl",children:s.jsx(Vt,{description:"Product not found."})})});const I=f.variant?.price??a.price,C=f.variant?.compareAtPrice??a.compareAtPrice,E=f.variant?.inventoryStatus==="out_of_stock"||typeof f.variant?.inventoryQuantity=="number"&&f.variant.inventoryQuantity<=0,O=a.inventoryStatus==="out_of_stock"||typeof a.inventoryQuantity=="number"&&a.inventoryQuantity<=0,F=f.variant?E:O,M=()=>{F||(r.addItem({productId:a.id,variantId:f.variant?.id,unitPrice:I,currency:a.currency,titleSnapshot:f.variant?`${a.title} — ${f.variant.title}`:a.title,imageSnapshot:a.images[0]?.url,paymentResource:a.id,metadata:Qa(a)},l),o?.toast({title:"Added to cart",description:a.title,actionLabel:"View cart",onAction:()=>{typeof window<"u"&&window.location.assign(j)}}))},U=()=>{F||(M(),typeof window<"u"&&window.location.assign(b))};return s.jsx("div",{className:L("min-h-screen bg-neutral-50 text-neutral-950 dark:bg-neutral-950 dark:text-neutral-50",t),children:s.jsxs("main",{className:"mx-auto max-w-6xl px-4 py-8",children:[s.jsx(Ha,{items:[{label:"Shop",href:w},{label:a.title}]}),s.jsxs("div",{className:"mt-6 grid gap-10 lg:grid-cols-2",children:[s.jsx(Ua,{images:a.images}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-3xl font-semibold tracking-tight",children:a.title}),s.jsx("div",{className:"mt-3",children:s.jsx(Zs,{amount:I,currency:a.currency,compareAt:C})}),F?s.jsx("div",{className:"mt-2 text-sm font-medium text-red-700 dark:text-red-300",children:"Out of stock"}):typeof a.inventoryQuantity=="number"&&a.inventoryQuantity>0&&a.inventoryQuantity<=5?s.jsxs("div",{className:"mt-2 text-sm text-neutral-600 dark:text-neutral-400",children:["Only ",s.jsx("span",{className:"font-semibold text-neutral-950 dark:text-neutral-50",children:a.inventoryQuantity})," left"]}):null,s.jsx("p",{className:"mt-4 text-sm text-neutral-600 dark:text-neutral-400",children:a.description})]}),s.jsx(Ba,{product:a,value:{selectedOptions:f.selectedOptions,variantId:f.variant?.id},onChange:D=>u(D)}),s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[s.jsx(Va,{qty:l,onChange:d}),s.jsx(ne,{type:"button",onClick:M,className:"flex-1",disabled:F,children:F?"Out of stock":"Add to cart"}),s.jsx(ne,{type:"button",variant:"outline",onClick:U,disabled:F,children:"Buy now"})]}),(h.sections.showDescription||h.sections.showSpecs||h.sections.showShipping)&&s.jsxs(Yu,{type:"single",collapsible:!0,defaultValue:h.sections.showDescription?"desc":void 0,children:[h.sections.showDescription&&s.jsxs(dr,{value:"desc",children:[s.jsx(ur,{children:"Description"}),s.jsx(fr,{children:s.jsx("div",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:a.description})})]}),h.sections.showSpecs&&s.jsxs(dr,{value:"specs",children:[s.jsx(ur,{children:"Specs"}),s.jsx(fr,{children:s.jsx("div",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:a.attributes?s.jsx("div",{className:"space-y-1",children:Object.entries(a.attributes).map(([D,H])=>s.jsxs("div",{children:[s.jsxs("span",{className:"font-medium text-neutral-950 dark:text-neutral-50",children:[D,":"]})," ",String(H)]},D))}):"No specs provided."})})]}),h.sections.showShipping&&s.jsxs(dr,{value:"ship",children:[s.jsx(ur,{children:"Shipping & returns"}),s.jsx(fr,{children:s.jsx("div",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:"Ships in 2–3 business days. Easy returns within 30 days."})})]})]})]})]}),h.sections.showRelatedProducts&&_.length?s.jsxs("section",{className:"mt-12",children:[s.jsx("h2",{className:"text-lg font-semibold",children:"Related products"}),s.jsx("div",{className:"mt-4",children:s.jsx(qs,{products:_,columns:{base:2,md:4,lg:4},layout:h.relatedProducts.layout.layout,imageCrop:h.relatedProducts.layout.imageCrop,getProductHref:D=>R(D.slug),onAddToCart:D=>r.addItem({productId:D.id,unitPrice:D.price,currency:D.currency,titleSnapshot:D.title,imageSnapshot:D.images[0]?.url,paymentResource:D.id},1)})})]}):null]})})}function Ej({className:e,checkoutHref:t}){const{config:n}=Ee(),{settings:r}=Wn(),o=t??"/checkout",a=n.checkout.allowPromoCodes&&r.checkout.promoCodes;return s.jsx("div",{className:L("min-h-screen bg-neutral-50 text-neutral-950 dark:bg-neutral-950 dark:text-neutral-50",e),children:s.jsxs("main",{className:"mx-auto max-w-6xl px-4 py-10",children:[s.jsx("h1",{className:"text-3xl font-semibold tracking-tight",children:"Cart"}),s.jsx("p",{className:"mt-2 text-sm text-neutral-600 dark:text-neutral-400",children:"Review items, adjust quantities, then check out."}),s.jsx("div",{className:"mt-8",children:s.jsx(Nf,{onCheckout:()=>{typeof window<"u"&&window.location.assign(o)},showPromoCode:a})})]})})}function Ij({className:e,routes:t}){const{config:n}=Ee(),r=Rt(),o=sa(),a=n.customer?.isSignedIn??!!n.customer?.id,c=!(n.checkout.requireAccount?!1:n.checkout.guestCheckout??!0)&&!a;m.useEffect(()=>{o.kind==="success"&&r.clear()},[o.kind]);const l=t?.shop??"/shop",d=t?.orders??"/account/orders",f=t?.login;return s.jsx("div",{className:L("min-h-screen bg-neutral-50 text-neutral-950 dark:bg-neutral-950 dark:text-neutral-50",e),children:s.jsxs("main",{className:"mx-auto max-w-6xl px-4 py-10",children:[s.jsx(Gs,{result:o,onContinueShopping:()=>{typeof window<"u"&&window.location.assign(l)},onViewOrders:()=>{typeof window<"u"&&window.location.assign(d)}}),o.kind==="idle"?s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-3xl font-semibold tracking-tight",children:"Checkout"}),s.jsx("p",{className:"mt-2 text-sm text-neutral-600 dark:text-neutral-400",children:n.checkout.mode==="none"?"Confirm and pay.":"Enter details, then complete payment."})]}),s.jsx("div",{className:"mt-8",children:s.jsx(_l,{children:c?s.jsxs(It,{className:"rounded-2xl",children:[s.jsx(hr,{className:"pb-4",children:s.jsx(gr,{className:"text-base",children:"Sign in required"})}),s.jsxs(Wt,{children:[s.jsx("div",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:"This store requires an account to complete checkout."}),f?s.jsx("div",{className:"mt-4",children:s.jsx(ne,{type:"button",onClick:()=>{typeof window<"u"&&window.location.assign(f)},children:"Sign in"})}):null]})]}):s.jsx(Af,{left:s.jsxs("div",{className:"space-y-6",children:[s.jsx(If,{}),s.jsxs(It,{className:"rounded-2xl",children:[s.jsx(hr,{className:"pb-4",children:s.jsx(gr,{className:"text-base",children:"Payment"})}),s.jsxs(Wt,{children:[s.jsx(yt,{className:"mb-4"}),s.jsx(Pf,{})]})]})]}),right:s.jsx("div",{className:"lg:sticky lg:top-24",children:s.jsx(Rf,{})})})})})]}):null]})})}function Tj({className:e,isSignedIn:t=!0,onLogin:n}){const{orders:r,isLoading:o,error:a}=jl(),[i,c]=m.useState(null);return t?s.jsx("div",{className:L("min-h-screen bg-neutral-50 text-neutral-950 dark:bg-neutral-950 dark:text-neutral-50",e),children:s.jsxs("main",{className:"mx-auto max-w-5xl px-4 py-10 sm:py-12",children:[s.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-3xl font-semibold tracking-tight",children:"Orders"}),s.jsx("p",{className:"mt-2 text-sm text-neutral-600 dark:text-neutral-400",children:"View past purchases and receipts."})]}),!o&&!a&&!i&&r.length>0?s.jsxs("div",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:[r.length," order",r.length===1?"":"s"]}):null]}),a?s.jsx(Vt,{className:"mt-8",description:a}):null,o?s.jsxs("div",{className:"mt-8 grid gap-4",children:[s.jsx(Re,{className:"h-32 rounded-2xl"}),s.jsx(Re,{className:"h-32 rounded-2xl"}),s.jsx(Re,{className:"h-32 rounded-2xl"})]}):r.length===0?s.jsx("div",{className:"mt-8",children:s.jsx(Bn,{title:"No orders yet",description:"When you purchase something, it will show up here."})}):i?s.jsx("div",{className:"mt-8",children:s.jsx(Lf,{order:i,onBack:()=>c(null)})}):s.jsx("div",{className:"mt-8",children:s.jsx(Mf,{orders:r,onView:c})})]})}):s.jsx("div",{className:L("min-h-screen bg-neutral-50 p-10 dark:bg-neutral-950",e),children:s.jsx("div",{className:"mx-auto max-w-4xl",children:s.jsx(Bn,{title:"Sign in to view your orders",description:"Your purchase history will appear here once you're logged in.",actionLabel:n?"Sign in":void 0,onAction:n})})})}function Pj({className:e}){return s.jsxs("svg",{className:e,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("polyline",{points:"6 9 6 2 18 2 18 9"}),s.jsx("path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2"}),s.jsx("rect",{x:"6",y:"14",width:"12",height:"8"})]})}function Rj({className:e}){return s.jsx("svg",{className:e,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"m15 18-6-6 6-6"})})}function Oj(e){switch(e){case"x402":return"Crypto (x402)";case"credits":return"Credits";case"stripe":return"Card";default:return"Payment"}}function Mj({order:e,source:t,purchaseId:n,customerEmail:r,customerName:o,className:a,onBack:i}){const{config:c}=Ee(),l=t??e.source,d=n??e.purchaseId,f=r??e.customerEmail,u=o??e.customerName,h=c.brand?.name??"Store",g=c.brand?.logoUrl,y=()=>{typeof window<"u"&&window.print()},x=new Date(e.createdAt).toLocaleDateString(void 0,{year:"numeric",month:"long",day:"numeric"}),p=new Date(e.createdAt).toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"});return s.jsxs("div",{className:L("min-h-screen bg-neutral-100 dark:bg-neutral-900 print:bg-white print:dark:bg-white",a),children:[s.jsx("div",{className:"border-b border-neutral-200 bg-white px-4 py-3 dark:border-neutral-800 dark:bg-neutral-950 print:hidden",children:s.jsxs("div",{className:"mx-auto flex max-w-2xl items-center justify-between",children:[i?s.jsxs(ne,{type:"button",variant:"ghost",size:"sm",onClick:i,children:[s.jsx(Rj,{className:"mr-1"})," Back"]}):s.jsx("div",{}),s.jsxs(ne,{type:"button",variant:"outline",size:"sm",onClick:y,children:[s.jsx(Pj,{className:"mr-2"})," Print Receipt"]})]})}),s.jsx("div",{className:"mx-auto max-w-2xl px-4 py-8 print:max-w-none print:px-0 print:py-0",children:s.jsxs("div",{className:"rounded-xl border border-neutral-200 bg-white p-8 shadow-sm dark:border-neutral-800 dark:bg-neutral-950 print:border-0 print:shadow-none print:dark:bg-white print:dark:text-neutral-950",children:[s.jsxs("div",{className:"flex items-center justify-between border-b border-neutral-200 pb-6 dark:border-neutral-800 print:dark:border-neutral-200",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[g?s.jsx("img",{src:g,alt:h,className:"h-10 w-10 rounded-lg object-contain"}):null,s.jsx("div",{className:"text-xl font-semibold",children:h})]}),s.jsxs("div",{className:"text-right",children:[s.jsx("div",{className:"text-sm font-medium text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:"Receipt"}),s.jsx("div",{className:"mt-1 font-mono text-sm",children:e.id})]})]}),s.jsxs("div",{className:"mt-6 grid grid-cols-2 gap-4 text-sm sm:grid-cols-3",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:"Date"}),s.jsx("div",{className:"mt-1 font-medium",children:x}),s.jsx("div",{className:"text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:p})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:"Payment Method"}),s.jsx("div",{className:"mt-1 font-medium",children:Oj(l)})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:"Status"}),s.jsx("div",{className:"mt-1",children:s.jsx(vn,{variant:"outline",className:"capitalize print:border-neutral-300",children:e.status})})]})]}),(u||f)&&s.jsxs("div",{className:"mt-6 border-t border-neutral-200 pt-6 dark:border-neutral-800 print:dark:border-neutral-200",children:[s.jsx("div",{className:"text-sm text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:"Customer"}),u&&s.jsx("div",{className:"mt-1 font-medium",children:u}),f&&s.jsx("div",{className:"text-sm text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:f})]}),s.jsx("div",{className:"mt-6 border-t border-neutral-200 pt-6 dark:border-neutral-800 print:dark:border-neutral-200",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-neutral-200 dark:border-neutral-800 print:dark:border-neutral-200",children:[s.jsx("th",{className:"pb-3 text-left font-medium text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:"Item"}),s.jsx("th",{className:"pb-3 text-center font-medium text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:"Qty"}),s.jsx("th",{className:"pb-3 text-right font-medium text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:"Price"})]})}),s.jsx("tbody",{children:e.items.map((v,_)=>s.jsxs("tr",{className:"border-b border-neutral-100 dark:border-neutral-800/50 print:dark:border-neutral-100",children:[s.jsx("td",{className:"py-3",children:s.jsx("div",{className:"font-medium",children:v.title})}),s.jsx("td",{className:"py-3 text-center text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:v.qty}),s.jsx("td",{className:"py-3 text-right",children:Be({amount:v.unitPrice*v.qty,currency:v.currency})})]},`${v.title}-${_}`))})]})}),s.jsxs("div",{className:"mt-4 flex flex-col items-end gap-2 text-sm",children:[s.jsxs("div",{className:"flex w-48 justify-between",children:[s.jsx("span",{className:"text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:"Subtotal"}),s.jsx("span",{children:Be({amount:e.total,currency:e.currency})})]}),s.jsxs("div",{className:"flex w-48 justify-between border-t border-neutral-200 pt-2 text-base font-semibold dark:border-neutral-800 print:dark:border-neutral-200",children:[s.jsx("span",{children:"Total"}),s.jsx("span",{children:Be({amount:e.total,currency:e.currency})})]})]}),d&&s.jsxs("div",{className:"mt-6 border-t border-neutral-200 pt-6 dark:border-neutral-800 print:dark:border-neutral-200",children:[s.jsx("div",{className:"text-sm text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:"Transaction ID"}),s.jsx("div",{className:"mt-1 break-all font-mono text-xs",children:d})]}),s.jsxs("div",{className:"mt-8 border-t border-neutral-200 pt-6 text-center text-xs text-neutral-500 dark:border-neutral-800 dark:text-neutral-400 print:dark:border-neutral-200 print:dark:text-neutral-500",children:[s.jsx("p",{children:"Thank you for your purchase!"}),s.jsx("p",{className:"mt-1",children:"If you have any questions, please contact support."})]})]})})]})}function Lj({className:e}){return s.jsx("svg",{className:L("h-4 w-4 flex-shrink-0",e),viewBox:"0 0 20 20",fill:"currentColor",children:s.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})})}function Dj({className:e,title:t="Choose Your Plan",subtitle:n="Select the plan that best fits your needs.",annualSavingsBadge:r="2 months free",popularBadgeText:o="Best Deal",footerNotice:a}){const{config:i}=Ee(),{tiers:c,status:l,isLoading:d,error:f}=Sl(),[u,h]=m.useState("monthly"),g=!!i.adapter.createSubscriptionCheckoutSession,y=async x=>{if(!i.adapter.createSubscriptionCheckoutSession)return;const p=await i.adapter.createSubscriptionCheckoutSession({tierId:x,interval:u,successUrl:i.checkout.successUrl,cancelUrl:i.checkout.cancelUrl});p.kind==="redirect"&&typeof window<"u"&&window.location.assign(p.url)};return s.jsx("div",{className:L("min-h-screen bg-neutral-50 text-neutral-950 dark:bg-neutral-950 dark:text-neutral-50",e),children:s.jsxs("main",{className:"mx-auto max-w-6xl px-4 py-16",children:[s.jsxs("div",{className:"text-center",children:[s.jsx("h1",{className:"text-5xl font-bold tracking-tight",children:t}),s.jsx("p",{className:"mt-4 text-base text-neutral-600 dark:text-neutral-400",children:n})]}),s.jsx("div",{className:"mt-10 flex justify-center",children:s.jsxs("div",{className:"inline-flex items-center rounded-full bg-neutral-200/60 p-1 dark:bg-neutral-800/60",children:[s.jsxs("button",{type:"button",onClick:()=>h("annual"),className:L("relative flex items-center gap-2 rounded-full px-4 py-2 text-sm font-medium transition-all",u==="annual"?"bg-neutral-900 text-white dark:bg-white dark:text-neutral-900":"text-neutral-600 hover:text-neutral-900 dark:text-neutral-400 dark:hover:text-white"),children:["Yearly",r&&s.jsx("span",{className:L("rounded-full px-2 py-0.5 text-xs font-medium",u==="annual"?"bg-white/20 text-white dark:bg-neutral-900/20 dark:text-neutral-900":"bg-neutral-900 text-white dark:bg-white dark:text-neutral-900"),children:r})]}),s.jsx("button",{type:"button",onClick:()=>h("monthly"),className:L("rounded-full px-4 py-2 text-sm font-medium transition-all",u==="monthly"?"bg-neutral-900 text-white dark:bg-white dark:text-neutral-900":"text-neutral-600 hover:text-neutral-900 dark:text-neutral-400 dark:hover:text-white"),children:"Monthly"})]})}),f?s.jsx(Vt,{className:"mt-10",description:f}):null,d?s.jsxs("div",{className:"mt-12 grid gap-6 md:grid-cols-3",children:[s.jsx(Re,{className:"h-[480px] rounded-2xl"}),s.jsx(Re,{className:"h-[480px] rounded-2xl"}),s.jsx(Re,{className:"h-[480px] rounded-2xl"})]}):c.length===0?s.jsx("div",{className:"mt-12",children:s.jsx(Bn,{title:"No plans available",description:"Subscription plans will appear here once configured."})}):s.jsx("div",{className:"mt-12 grid gap-6 md:grid-cols-3 items-start",children:c.map(x=>{const p=l?.isActive&&l.currentTierId===x.id,v=u==="annual"&&x.priceAnnual?x.priceAnnual:x.priceMonthly,_=x.isPopular,w=x.inventoryQuantity!=null,b=w?Math.max(0,(x.inventoryQuantity??0)-(x.inventorySold??0)):null,j=w&&b===0,R=w&&b!=null&&b>0&&b<=5,[I,...C]=x.features;return s.jsxs("div",{className:L("relative flex flex-col rounded-2xl border p-6 transition-shadow",_?"border-neutral-900 bg-neutral-900 text-white shadow-xl dark:border-white dark:bg-white dark:text-neutral-900":"border-neutral-200 bg-white dark:border-neutral-800 dark:bg-neutral-900"),children:[_&&o&&s.jsx("div",{className:"absolute -top-3 right-4",children:s.jsx("span",{className:"rounded-full bg-neutral-100 px-3 py-1 text-xs font-semibold text-neutral-900 shadow-sm dark:bg-neutral-800 dark:text-white",children:o})}),s.jsxs("div",{className:"mb-6",children:[s.jsx("h3",{className:"text-xl font-bold",children:x.title}),x.description&&s.jsx("p",{className:L("mt-2 text-sm leading-relaxed",_?"text-neutral-300 dark:text-neutral-600":"text-neutral-600 dark:text-neutral-400"),children:x.description})]}),s.jsxs("div",{className:"mb-6",children:[s.jsx("div",{className:"text-5xl font-bold tracking-tight",children:Be({amount:v,currency:x.currency||i.currency})}),s.jsxs("div",{className:L("mt-2 text-sm",_?"text-neutral-400 dark:text-neutral-500":"text-neutral-500 dark:text-neutral-400"),children:["Per ",u==="annual"?"year":"month",", billed ",u==="annual"?"annually":"monthly"]})]}),w&&s.jsx("div",{className:L("mb-3 text-xs font-medium",j?"text-red-600 dark:text-red-400":R?_?"text-amber-300 dark:text-amber-600":"text-amber-600 dark:text-amber-400":_?"text-neutral-400 dark:text-neutral-500":"text-neutral-500 dark:text-neutral-400"),children:j?"Sold out":`${b} remaining`}),s.jsx(ne,{type:"button",className:L("mb-6 w-full rounded-full py-3 font-medium",_?"bg-white text-neutral-900 hover:bg-neutral-100 dark:bg-neutral-900 dark:text-white dark:hover:bg-neutral-800":""),variant:_?"default":"outline",disabled:p||!g||j,onClick:()=>void y(x.id),children:j?"Sold Out":p?"Current Plan":"Purchase"}),I&&s.jsx("div",{className:L("mb-4 text-sm font-semibold",_?"":"text-neutral-900 dark:text-white"),children:I}),C.length>0&&s.jsx("ul",{className:"space-y-3",children:C.map((E,O)=>s.jsxs("li",{className:"flex items-start gap-3",children:[s.jsx(Lj,{className:L("mt-0.5",_?"text-neutral-400 dark:text-neutral-500":"text-neutral-500 dark:text-neutral-400")}),s.jsx("span",{className:L("text-sm leading-relaxed",_?"text-neutral-300 dark:text-neutral-600":"text-neutral-600 dark:text-neutral-400"),children:E})]},O))})]},x.id)})}),a&&s.jsx("div",{className:"mt-12 text-center",children:s.jsx("p",{className:"text-xs text-neutral-500 dark:text-neutral-400 leading-relaxed max-w-2xl mx-auto",children:a})})]})})}function $j(e){const{processCartCheckout:t}=Ff.useStripeCheckout();return m.useMemo(()=>({...e,async createCheckoutSession(n){const{customer:r,options:o}=n,a=r.shippingAddress?r.shippingAddress:void 0,i=r.billingAddress?r.billingAddress:void 0,c=await t(n.cart,o.successUrl,o.cancelUrl,o.metadata,r.email,o.discountCode,r.name,r.phone,a,i,o.tipAmount,o.shippingMethodId,o.paymentMethodId);if(!c.success)throw new Error(c.error||"Checkout failed");return{kind:"redirect",url:n.options.successUrl??"/"}},async resolveCheckoutReturn({query:n}){return ra(n)}}),[e,t])}const zj=Object.freeze(Object.defineProperty({__proto__:null,Accordion:Yu,AccordionContent:fr,AccordionItem:dr,AccordionTrigger:ur,AddressForm:Ho,Badge:vn,Breadcrumbs:Ha,Button:ne,Card:It,CardContent:Wt,CardDescription:Zl,CardFooter:ql,CardHeader:hr,CardTitle:gr,CartLineItem:qa,CartPageContent:Nf,CartPanel:jf,CartProvider:Im,CartSidebar:kr,CartSummary:Ga,CartTemplate:Ej,CategoryNav:Wo,CategoryTemplate:Cj,CedrosShopProvider:im,CheckoutCancelPage:vj,CheckoutForm:If,CheckoutLayout:Af,CheckoutProvider:_l,CheckoutReceipt:Gs,CheckoutSuccessPage:xj,CheckoutTemplate:Ij,Dialog:Na,DialogClose:A_,DialogContent:Os,DialogDescription:Ia,DialogFooter:Cu,DialogHeader:Ea,DialogOverlay:Aa,DialogPortal:Su,DialogTitle:Ms,DialogTrigger:N_,EmptyState:Bn,ErrorBoundary:ck,ErrorState:Vt,FAQItem:wf,FAQList:aj,FilterPanel:ms,Input:Fe,InventoryVerificationDialog:Tf,Label:st,OrderCard:Of,OrderDetails:Lf,OrderList:Mf,OrderReview:Rf,PaymentStep:Pf,Price:Zs,ProductCard:_f,ProductGallery:Ua,ProductGrid:qs,ProductTemplate:Aj,PromoCodeInput:Ya,PurchaseHistoryTemplate:Tj,QuantitySelector:Va,QuickViewDialog:Wa,ReceiptTemplate:Mj,SearchInput:Za,Select:ls,SelectContent:br,SelectGroup:c_,SelectItem:wr,SelectTrigger:yr,SelectValue:ds,Separator:yt,Sheet:Ls,SheetClose:Nu,SheetContent:Nr,SheetDescription:Eu,SheetHeader:$s,SheetOverlay:Ta,SheetPortal:Au,SheetTitle:zs,SheetTrigger:Ds,ShippingMethodSelector:Ef,ShopChatPanel:Cf,ShopTemplate:jj,Skeleton:Re,SubscriptionTemplate:Dj,Tabs:za,TabsContent:gf,TabsList:Ws,TabsTrigger:_r,ToastProvider:$k,VariantSelector:Ba,createMockCommerceAdapter:fm,createPaywallCommerceAdapter:_m,parseCheckoutReturn:ra,readCatalogUrlState:oa,useAIRelatedProducts:El,useCart:Rt,useCartInventory:ia,useCatalogUrlSync:aa,useCategories:na,useCedrosPayCheckoutAdapter:$j,useCedrosShop:Ee,useCheckout:vs,useCheckoutResultFromUrl:sa,useHoldExpiry:wv,useInventoryVerification:Nl,useOptionalToast:Hs,useOrders:jl,usePaymentMethodsConfig:Al,useProduct:kl,useProducts:ys,useShippingMethods:Cl,useStandaloneCheckout:fv,useStorefrontSettings:Wn,useSubscriptionData:Sl,useToast:Dk,validateCommerceAdapterContract:Cv},Symbol.toStringTag,{value:"Module"}));exports.CedrosPayAdminDashboard=om;exports.CouponsSection=Mc;exports.ErrorBanner=jr;exports.FormDropdown=Et;exports.Icons=Y;exports.ProductsSection=Rc;exports.RefundsSection=Lc;exports.SettingsSection=Dc;exports.StatsBar=Sr;exports.TransactionsSection=Oc;exports.cedrosPayPlugin=am;exports.formatDateTime=lr;exports.index=zj;
|
|
83
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return m.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},A_="DialogDescriptionWarning",E_=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${wu(A_).contentName}}.`;return m.useEffect(()=>{const o=e.current?.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},_u=iu,ku=lu,ju=uu,Is=fu,Ts=mu,Ps=hu,Rs=xu,Su=yu;const Na=_u,I_=ku,Cu=ju,T_=Su,Aa=m.forwardRef(({className:e,...t},n)=>s.jsx(Is,{ref:n,className:L("fixed inset-0 z-50 bg-neutral-950/40 backdrop-blur-sm transition-opacity data-[state=closed]:opacity-0 data-[state=open]:opacity-100",e),...t}));Aa.displayName=Is.displayName;const Os=m.forwardRef(({className:e,children:t,...n},r)=>s.jsxs(Cu,{children:[s.jsx(Aa,{}),s.jsx(Ts,{ref:r,className:L("fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg -translate-x-1/2 -translate-y-1/2 gap-4 border border-neutral-200 bg-white p-6 shadow-lg outline-none transition data-[state=closed]:opacity-0 data-[state=closed]:scale-95 data-[state=open]:opacity-100 data-[state=open]:scale-100 dark:border-neutral-800 dark:bg-neutral-950","rounded-2xl",e),...n,children:t})]}));Os.displayName=Ts.displayName;const Ea=({className:e,...t})=>s.jsx("div",{className:L("flex flex-col space-y-2 text-center sm:text-left",e),...t}),Nu=({className:e,...t})=>s.jsx("div",{className:L("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t}),Ms=m.forwardRef(({className:e,...t},n)=>s.jsx(Ps,{ref:n,className:L("text-lg font-semibold leading-none tracking-tight",e),...t}));Ms.displayName=Ps.displayName;const Ia=m.forwardRef(({className:e,...t},n)=>s.jsx(Rs,{ref:n,className:L("text-sm text-neutral-500 dark:text-neutral-400",e),...t}));Ia.displayName=Rs.displayName;const Ls=_u,Ds=ku,Au=Su,Eu=ju,Ta=m.forwardRef(({className:e,...t},n)=>s.jsx(Is,{ref:n,className:L("fixed inset-0 z-50 bg-neutral-950/40 backdrop-blur-sm transition-opacity data-[state=closed]:opacity-0 data-[state=open]:opacity-100",e),...t}));Ta.displayName=Is.displayName;const P_=ca("fixed z-50 gap-4 bg-white p-6 shadow-lg outline-none transition duration-200 ease-out dark:bg-neutral-950",{variants:{side:{top:"inset-x-0 top-0 border-b border-neutral-200 data-[state=closed]:-translate-y-full data-[state=open]:translate-y-0 dark:border-neutral-800",bottom:"inset-x-0 bottom-0 border-t border-neutral-200 data-[state=closed]:translate-y-full data-[state=open]:translate-y-0 dark:border-neutral-800",left:"inset-y-0 left-0 h-full w-3/4 border-r border-neutral-200 data-[state=closed]:-translate-x-full data-[state=open]:translate-x-0 sm:max-w-sm dark:border-neutral-800",right:"inset-y-0 right-0 h-full w-3/4 border-l border-neutral-200 data-[state=closed]:translate-x-full data-[state=open]:translate-x-0 sm:max-w-sm dark:border-neutral-800",popup:"bottom-4 right-4 w-[420px] max-w-[calc(100vw-2rem)] max-h-[calc(100vh-2rem)] overflow-hidden rounded-2xl border border-neutral-200 p-4 data-[state=closed]:translate-y-2 data-[state=open]:translate-y-0 data-[state=closed]:opacity-0 data-[state=open]:opacity-100 data-[state=closed]:scale-95 data-[state=open]:scale-100 dark:border-neutral-800"}},defaultVariants:{side:"right"}}),Nr=m.forwardRef(({side:e="right",className:t,children:n,overlayClassName:r,...o},a)=>s.jsxs(Eu,{children:[s.jsx(Ta,{className:r}),s.jsx(Ts,{ref:a,className:L(P_({side:e}),t),...o,children:n})]}));Nr.displayName=Ts.displayName;const $s=({className:e,...t})=>s.jsx("div",{className:L("flex flex-col space-y-2 text-left",e),...t}),zs=m.forwardRef(({className:e,...t},n)=>s.jsx(Ps,{ref:n,className:L("text-lg font-semibold leading-none tracking-tight",e),...t}));zs.displayName=Ps.displayName;const Iu=m.forwardRef(({className:e,...t},n)=>s.jsx(Rs,{ref:n,className:L("text-sm text-neutral-500 dark:text-neutral-400",e),...t}));Iu.displayName=Rs.displayName;var Fs="Collapsible",[R_,Tu]=un(Fs),[O_,Pa]=R_(Fs),Pu=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:a,onOpenChange:i,...c}=e,[l,d]=cn({prop:r,defaultProp:o??!1,onChange:i,caller:Fs});return s.jsx(O_,{scope:n,disabled:a,contentId:Ft(),open:l,onOpenToggle:m.useCallback(()=>d(f=>!f),[d]),children:s.jsx(pe.div,{"data-state":Oa(l),"data-disabled":a?"":void 0,...c,ref:t})})});Pu.displayName=Fs;var Ru="CollapsibleTrigger",Ou=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=Pa(Ru,n);return s.jsx(pe.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":Oa(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:xe(e.onClick,o.onOpenToggle)})});Ou.displayName=Ru;var Ra="CollapsibleContent",Mu=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Pa(Ra,e.__scopeCollapsible);return s.jsx(Kn,{present:n||o.open,children:({present:a})=>s.jsx(M_,{...r,ref:t,present:a})})});Mu.displayName=Ra;var M_=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...a}=e,i=Pa(Ra,n),[c,l]=m.useState(r),d=m.useRef(null),f=Ce(t,d),u=m.useRef(0),h=u.current,g=m.useRef(0),y=g.current,x=i.open||c,p=m.useRef(x),v=m.useRef(void 0);return m.useEffect(()=>{const _=requestAnimationFrame(()=>p.current=!1);return()=>cancelAnimationFrame(_)},[]),qe(()=>{const _=d.current;if(_){v.current=v.current||{transitionDuration:_.style.transitionDuration,animationName:_.style.animationName},_.style.transitionDuration="0s",_.style.animationName="none";const w=_.getBoundingClientRect();u.current=w.height,g.current=w.width,p.current||(_.style.transitionDuration=v.current.transitionDuration,_.style.animationName=v.current.animationName),l(r)}},[i.open,r]),s.jsx(pe.div,{"data-state":Oa(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!x,...a,ref:f,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":y?`${y}px`:void 0,...e.style},children:x&&o})});function Oa(e){return e?"open":"closed"}var L_=Pu,D_=Ou,$_=Mu,Ot="Accordion",z_=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[Ma,F_,U_]=da(Ot),[Us]=un(Ot,[U_,Tu]),La=Tu(),Lu=k.forwardRef((e,t)=>{const{type:n,...r}=e,o=r,a=r;return s.jsx(Ma.Provider,{scope:e.__scopeAccordion,children:n==="multiple"?s.jsx(H_,{...a,ref:t}):s.jsx(W_,{...o,ref:t})})});Lu.displayName=Ot;var[Du,B_]=Us(Ot),[$u,V_]=Us(Ot,{collapsible:!1}),W_=k.forwardRef((e,t)=>{const{value:n,defaultValue:r,onValueChange:o=()=>{},collapsible:a=!1,...i}=e,[c,l]=cn({prop:n,defaultProp:r??"",onChange:o,caller:Ot});return s.jsx(Du,{scope:e.__scopeAccordion,value:k.useMemo(()=>c?[c]:[],[c]),onItemOpen:l,onItemClose:k.useCallback(()=>a&&l(""),[a,l]),children:s.jsx($u,{scope:e.__scopeAccordion,collapsible:a,children:s.jsx(zu,{...i,ref:t})})})}),H_=k.forwardRef((e,t)=>{const{value:n,defaultValue:r,onValueChange:o=()=>{},...a}=e,[i,c]=cn({prop:n,defaultProp:r??[],onChange:o,caller:Ot}),l=k.useCallback(f=>c((u=[])=>[...u,f]),[c]),d=k.useCallback(f=>c((u=[])=>u.filter(h=>h!==f)),[c]);return s.jsx(Du,{scope:e.__scopeAccordion,value:i,onItemOpen:l,onItemClose:d,children:s.jsx($u,{scope:e.__scopeAccordion,collapsible:!0,children:s.jsx(zu,{...a,ref:t})})})}),[Z_,Bs]=Us(Ot),zu=k.forwardRef((e,t)=>{const{__scopeAccordion:n,disabled:r,dir:o,orientation:a="vertical",...i}=e,c=k.useRef(null),l=Ce(c,t),d=F_(n),u=bs(o)==="ltr",h=xe(e.onKeyDown,g=>{if(!z_.includes(g.key))return;const y=g.target,x=d().filter(C=>!C.ref.current?.disabled),p=x.findIndex(C=>C.ref.current===y),v=x.length;if(p===-1)return;g.preventDefault();let _=p;const w=0,b=v-1,j=()=>{_=p+1,_>b&&(_=w)},R=()=>{_=p-1,_<w&&(_=b)};switch(g.key){case"Home":_=w;break;case"End":_=b;break;case"ArrowRight":a==="horizontal"&&(u?j():R());break;case"ArrowDown":a==="vertical"&&j();break;case"ArrowLeft":a==="horizontal"&&(u?R():j());break;case"ArrowUp":a==="vertical"&&R();break}const I=_%v;x[I].ref.current?.focus()});return s.jsx(Z_,{scope:n,disabled:r,direction:o,orientation:a,children:s.jsx(Ma.Slot,{scope:n,children:s.jsx(pe.div,{...i,"data-orientation":a,ref:l,onKeyDown:r?void 0:h})})})}),fs="AccordionItem",[q_,Da]=Us(fs),Fu=k.forwardRef((e,t)=>{const{__scopeAccordion:n,value:r,...o}=e,a=Bs(fs,n),i=B_(fs,n),c=La(n),l=Ft(),d=r&&i.value.includes(r)||!1,f=a.disabled||e.disabled;return s.jsx(q_,{scope:n,open:d,disabled:f,triggerId:l,children:s.jsx(L_,{"data-orientation":a.orientation,"data-state":Zu(d),...c,...o,ref:t,disabled:f,open:d,onOpenChange:u=>{u?i.onItemOpen(r):i.onItemClose(r)}})})});Fu.displayName=fs;var Uu="AccordionHeader",Bu=k.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,o=Bs(Ot,n),a=Da(Uu,n);return s.jsx(pe.h3,{"data-orientation":o.orientation,"data-state":Zu(a.open),"data-disabled":a.disabled?"":void 0,...r,ref:t})});Bu.displayName=Uu;var $o="AccordionTrigger",Vu=k.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,o=Bs(Ot,n),a=Da($o,n),i=V_($o,n),c=La(n);return s.jsx(Ma.ItemSlot,{scope:n,children:s.jsx(D_,{"aria-disabled":a.open&&!i.collapsible||void 0,"data-orientation":o.orientation,id:a.triggerId,...c,...r,ref:t})})});Vu.displayName=$o;var Wu="AccordionContent",Hu=k.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,o=Bs(Ot,n),a=Da(Wu,n),i=La(n);return s.jsx($_,{role:"region","aria-labelledby":a.triggerId,"data-orientation":o.orientation,...i,...r,ref:t,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...e.style}})});Hu.displayName=Wu;function Zu(e){return e?"open":"closed"}var G_=Lu,qu=Fu,Y_=Bu,Gu=Vu,Yu=Hu;const Qu=G_,dr=m.forwardRef(({className:e,...t},n)=>s.jsx(qu,{ref:n,className:L("border-b border-neutral-200 dark:border-neutral-800",e),...t}));dr.displayName=qu.displayName;const ur=m.forwardRef(({className:e,children:t,...n},r)=>s.jsx(Y_,{className:"flex",children:s.jsxs(Gu,{ref:r,className:L("flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline",e),...n,children:[t,s.jsx("span",{className:"ml-3 text-neutral-500 dark:text-neutral-400","aria-hidden":!0,children:"▾"})]})}));ur.displayName=Gu.displayName;const fr=m.forwardRef(({className:e,children:t,...n},r)=>s.jsx(Yu,{ref:r,className:L("overflow-hidden text-sm",e),...n,children:s.jsx("div",{className:"pb-4 pt-0",children:t})}));fr.displayName=Yu.displayName;var mo="rovingFocusGroup.onEntryFocus",Q_={bubbles:!1,cancelable:!0},Ar="RovingFocusGroup",[zo,Ku,K_]=da(Ar),[J_,Ju]=un(Ar,[K_]),[X_,ek]=J_(Ar),Xu=m.forwardRef((e,t)=>s.jsx(zo.Provider,{scope:e.__scopeRovingFocusGroup,children:s.jsx(zo.Slot,{scope:e.__scopeRovingFocusGroup,children:s.jsx(tk,{...e,ref:t})})}));Xu.displayName=Ar;var tk=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:a,currentTabStopId:i,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:l,onEntryFocus:d,preventScrollOnEntryFocus:f=!1,...u}=e,h=m.useRef(null),g=Ce(t,h),y=bs(a),[x,p]=cn({prop:i,defaultProp:c??null,onChange:l,caller:Ar}),[v,_]=m.useState(!1),w=sn(d),b=Ku(n),j=m.useRef(!1),[R,I]=m.useState(0);return m.useEffect(()=>{const C=h.current;if(C)return C.addEventListener(mo,w),()=>C.removeEventListener(mo,w)},[w]),s.jsx(X_,{scope:n,orientation:r,dir:y,loop:o,currentTabStopId:x,onItemFocus:m.useCallback(C=>p(C),[p]),onItemShiftTab:m.useCallback(()=>_(!0),[]),onFocusableItemAdd:m.useCallback(()=>I(C=>C+1),[]),onFocusableItemRemove:m.useCallback(()=>I(C=>C-1),[]),children:s.jsx(pe.div,{tabIndex:v||R===0?-1:0,"data-orientation":r,...u,ref:g,style:{outline:"none",...e.style},onMouseDown:xe(e.onMouseDown,()=>{j.current=!0}),onFocus:xe(e.onFocus,C=>{const E=!j.current;if(C.target===C.currentTarget&&E&&!v){const O=new CustomEvent(mo,Q_);if(C.currentTarget.dispatchEvent(O),!O.defaultPrevented){const F=b().filter(z=>z.focusable),M=F.find(z=>z.active),U=F.find(z=>z.id===x),H=[M,U,...F].filter(Boolean).map(z=>z.ref.current);nf(H,f)}}j.current=!1}),onBlur:xe(e.onBlur,()=>_(!1))})})}),ef="RovingFocusGroupItem",tf=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:a,children:i,...c}=e,l=Ft(),d=a||l,f=ek(ef,n),u=f.currentTabStopId===d,h=Ku(n),{onFocusableItemAdd:g,onFocusableItemRemove:y,currentTabStopId:x}=f;return m.useEffect(()=>{if(r)return g(),()=>y()},[r,g,y]),s.jsx(zo.ItemSlot,{scope:n,id:d,focusable:r,active:o,children:s.jsx(pe.span,{tabIndex:u?0:-1,"data-orientation":f.orientation,...c,ref:t,onMouseDown:xe(e.onMouseDown,p=>{r?f.onItemFocus(d):p.preventDefault()}),onFocus:xe(e.onFocus,()=>f.onItemFocus(d)),onKeyDown:xe(e.onKeyDown,p=>{if(p.key==="Tab"&&p.shiftKey){f.onItemShiftTab();return}if(p.target!==p.currentTarget)return;const v=sk(p,f.orientation,f.dir);if(v!==void 0){if(p.metaKey||p.ctrlKey||p.altKey||p.shiftKey)return;p.preventDefault();let w=h().filter(b=>b.focusable).map(b=>b.ref.current);if(v==="last")w.reverse();else if(v==="prev"||v==="next"){v==="prev"&&w.reverse();const b=w.indexOf(p.currentTarget);w=f.loop?ok(w,b+1):w.slice(b+1)}setTimeout(()=>nf(w))}}),children:typeof i=="function"?i({isCurrentTabStop:u,hasTabStop:x!=null}):i})})});tf.displayName=ef;var nk={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function rk(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function sk(e,t,n){const r=rk(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return nk[r]}function nf(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function ok(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var ak=Xu,ik=tf,Vs="Tabs",[ck]=un(Vs,[Ju]),rf=Ju(),[lk,$a]=ck(Vs),sf=m.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:o,defaultValue:a,orientation:i="horizontal",dir:c,activationMode:l="automatic",...d}=e,f=bs(c),[u,h]=cn({prop:r,onChange:o,defaultProp:a??"",caller:Vs});return s.jsx(lk,{scope:n,baseId:Ft(),value:u,onValueChange:h,orientation:i,dir:f,activationMode:l,children:s.jsx(pe.div,{dir:f,"data-orientation":i,...d,ref:t})})});sf.displayName=Vs;var of="TabsList",af=m.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...o}=e,a=$a(of,n),i=rf(n);return s.jsx(ak,{asChild:!0,...i,orientation:a.orientation,dir:a.dir,loop:r,children:s.jsx(pe.div,{role:"tablist","aria-orientation":a.orientation,...o,ref:t})})});af.displayName=of;var cf="TabsTrigger",lf=m.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:o=!1,...a}=e,i=$a(cf,n),c=rf(n),l=ff(i.baseId,r),d=mf(i.baseId,r),f=r===i.value;return s.jsx(ik,{asChild:!0,...c,focusable:!o,active:f,children:s.jsx(pe.button,{type:"button",role:"tab","aria-selected":f,"aria-controls":d,"data-state":f?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:l,...a,ref:t,onMouseDown:xe(e.onMouseDown,u=>{!o&&u.button===0&&u.ctrlKey===!1?i.onValueChange(r):u.preventDefault()}),onKeyDown:xe(e.onKeyDown,u=>{[" ","Enter"].includes(u.key)&&i.onValueChange(r)}),onFocus:xe(e.onFocus,()=>{const u=i.activationMode!=="manual";!f&&!o&&u&&i.onValueChange(r)})})})});lf.displayName=cf;var df="TabsContent",uf=m.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:o,children:a,...i}=e,c=$a(df,n),l=ff(c.baseId,r),d=mf(c.baseId,r),f=r===c.value,u=m.useRef(f);return m.useEffect(()=>{const h=requestAnimationFrame(()=>u.current=!1);return()=>cancelAnimationFrame(h)},[]),s.jsx(Kn,{present:o||f,children:({present:h})=>s.jsx(pe.div,{"data-state":f?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":l,hidden:!h,id:d,tabIndex:0,...i,ref:t,style:{...e.style,animationDuration:u.current?"0s":void 0},children:h&&a})})});uf.displayName=df;function ff(e,t){return`${e}-trigger-${t}`}function mf(e,t){return`${e}-content-${t}`}var dk=sf,pf=af,hf=lf,gf=uf;const za=dk,Ws=m.forwardRef(({className:e,...t},n)=>s.jsx(pf,{ref:n,className:L("inline-flex h-10 items-center justify-center rounded-md bg-neutral-100 p-1 text-neutral-500 dark:bg-neutral-800 dark:text-neutral-400",e),...t}));Ws.displayName=pf.displayName;const _r=m.forwardRef(({className:e,...t},n)=>s.jsx(hf,{ref:n,className:L("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-white transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-900/20 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-white data-[state=active]:text-neutral-950 data-[state=active]:shadow-sm dark:ring-offset-neutral-950 dark:focus-visible:ring-neutral-50/20 dark:data-[state=active]:bg-neutral-950 dark:data-[state=active]:text-neutral-50",e),...t}));_r.displayName=hf.displayName;const xf=m.forwardRef(({className:e,...t},n)=>s.jsx(gf,{ref:n,className:L("mt-2 ring-offset-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-900/20 dark:ring-offset-neutral-950 dark:focus-visible:ring-neutral-50/20",e),...t}));xf.displayName=gf.displayName;function Bn({title:e,description:t,actionLabel:n,onAction:r,className:o}){return s.jsx("div",{className:L("flex flex-col items-center justify-center rounded-xl border border-neutral-200 bg-white p-10 text-center dark:border-neutral-800 dark:bg-neutral-950",o),children:s.jsxs("div",{className:"max-w-sm",children:[s.jsx("h3",{className:"text-base font-semibold text-neutral-950 dark:text-neutral-50",children:e}),t?s.jsx("p",{className:"mt-2 text-sm text-neutral-600 dark:text-neutral-400",children:t}):null,n&&r?s.jsx("div",{className:"mt-5",children:s.jsx(ne,{type:"button",onClick:r,variant:"secondary",children:n})}):null]})})}function Bt({title:e,description:t,onRetry:n,className:r}){return s.jsxs("div",{className:L("rounded-xl border border-neutral-200 bg-white p-6 text-neutral-950 dark:border-neutral-800 dark:bg-neutral-950 dark:text-neutral-50",r),children:[s.jsx("h3",{className:"text-sm font-semibold",children:e??"Something went wrong"}),s.jsx("p",{className:"mt-2 text-sm text-neutral-600 dark:text-neutral-400",children:t}),n?s.jsx("div",{className:"mt-4",children:s.jsx(ne,{type:"button",variant:"outline",onClick:n,children:"Try again"})}):null]})}class uk extends m.Component{state={error:null};static getDerivedStateFromError(t){return{error:t}}render(){return this.state.error?this.props.fallback?this.props.fallback(this.state.error):s.jsx(Bt,{description:this.state.error.message}):this.props.children}}function fk(e){if(typeof document>"u")return;let t=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}const mk=e=>{switch(e){case"success":return gk;case"info":return vk;case"warning":return xk;case"error":return yk;default:return null}},pk=Array(12).fill(0),hk=({visible:e,className:t})=>k.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},k.createElement("div",{className:"sonner-spinner"},pk.map((n,r)=>k.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),gk=k.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},k.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),xk=k.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},k.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),vk=k.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},k.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),yk=k.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},k.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),bk=k.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},k.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),k.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),wk=()=>{const[e,t]=k.useState(document.hidden);return k.useEffect(()=>{const n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e};let Fo=1;class _k{constructor(){this.subscribe=t=>(this.subscribers.push(t),()=>{const n=this.subscribers.indexOf(t);this.subscribers.splice(n,1)}),this.publish=t=>{this.subscribers.forEach(n=>n(t))},this.addToast=t=>{this.publish(t),this.toasts=[...this.toasts,t]},this.create=t=>{var n;const{message:r,...o}=t,a=typeof t?.id=="number"||((n=t.id)==null?void 0:n.length)>0?t.id:Fo++,i=this.toasts.find(l=>l.id===a),c=t.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(a)&&this.dismissedToasts.delete(a),i?this.toasts=this.toasts.map(l=>l.id===a?(this.publish({...l,...t,id:a,title:r}),{...l,...t,id:a,dismissible:c,title:r}):l):this.addToast({title:r,...o,dismissible:c,id:a}),a},this.dismiss=t=>(t?(this.dismissedToasts.add(t),requestAnimationFrame(()=>this.subscribers.forEach(n=>n({id:t,dismiss:!0})))):this.toasts.forEach(n=>{this.subscribers.forEach(r=>r({id:n.id,dismiss:!0}))}),t),this.message=(t,n)=>this.create({...n,message:t}),this.error=(t,n)=>this.create({...n,message:t,type:"error"}),this.success=(t,n)=>this.create({...n,type:"success",message:t}),this.info=(t,n)=>this.create({...n,type:"info",message:t}),this.warning=(t,n)=>this.create({...n,type:"warning",message:t}),this.loading=(t,n)=>this.create({...n,type:"loading",message:t}),this.promise=(t,n)=>{if(!n)return;let r;n.loading!==void 0&&(r=this.create({...n,promise:t,type:"loading",message:n.loading,description:typeof n.description!="function"?n.description:void 0}));const o=Promise.resolve(t instanceof Function?t():t);let a=r!==void 0,i;const c=o.then(async d=>{if(i=["resolve",d],k.isValidElement(d))a=!1,this.create({id:r,type:"default",message:d});else if(jk(d)&&!d.ok){a=!1;const u=typeof n.error=="function"?await n.error(`HTTP error! status: ${d.status}`):n.error,h=typeof n.description=="function"?await n.description(`HTTP error! status: ${d.status}`):n.description,y=typeof u=="object"&&!k.isValidElement(u)?u:{message:u};this.create({id:r,type:"error",description:h,...y})}else if(d instanceof Error){a=!1;const u=typeof n.error=="function"?await n.error(d):n.error,h=typeof n.description=="function"?await n.description(d):n.description,y=typeof u=="object"&&!k.isValidElement(u)?u:{message:u};this.create({id:r,type:"error",description:h,...y})}else if(n.success!==void 0){a=!1;const u=typeof n.success=="function"?await n.success(d):n.success,h=typeof n.description=="function"?await n.description(d):n.description,y=typeof u=="object"&&!k.isValidElement(u)?u:{message:u};this.create({id:r,type:"success",description:h,...y})}}).catch(async d=>{if(i=["reject",d],n.error!==void 0){a=!1;const f=typeof n.error=="function"?await n.error(d):n.error,u=typeof n.description=="function"?await n.description(d):n.description,g=typeof f=="object"&&!k.isValidElement(f)?f:{message:f};this.create({id:r,type:"error",description:u,...g})}}).finally(()=>{a&&(this.dismiss(r),r=void 0),n.finally==null||n.finally.call(n)}),l=()=>new Promise((d,f)=>c.then(()=>i[0]==="reject"?f(i[1]):d(i[1])).catch(f));return typeof r!="string"&&typeof r!="number"?{unwrap:l}:Object.assign(r,{unwrap:l})},this.custom=(t,n)=>{const r=n?.id||Fo++;return this.create({jsx:t(r),id:r,...n}),r},this.getActiveToasts=()=>this.toasts.filter(t=>!this.dismissedToasts.has(t.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}}const dt=new _k,kk=(e,t)=>{const n=t?.id||Fo++;return dt.addToast({title:e,...t,id:n}),n},jk=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",Sk=kk,Ck=()=>dt.toasts,Nk=()=>dt.getActiveToasts(),Ak=Object.assign(Sk,{success:dt.success,info:dt.info,warning:dt.warning,error:dt.error,custom:dt.custom,message:dt.message,promise:dt.promise,dismiss:dt.dismiss,loading:dt.loading},{getHistory:Ck,getToasts:Nk});fk("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");function Br(e){return e.label!==void 0}const Ek=3,Ik="24px",Tk="16px",gc=4e3,Pk=356,Rk=14,Ok=45,Mk=200;function Lt(...e){return e.filter(Boolean).join(" ")}function Lk(e){const[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}const Dk=e=>{var t,n,r,o,a,i,c,l,d;const{invert:f,toast:u,unstyled:h,interacting:g,setHeights:y,visibleToasts:x,heights:p,index:v,toasts:_,expanded:w,removeToast:b,defaultRichColors:j,closeButton:R,style:I,cancelButtonStyle:C,actionButtonStyle:E,className:O="",descriptionClassName:F="",duration:M,position:U,gap:D,expandByDefault:H,classNames:z,icons:A,closeButtonAriaLabel:N="Close toast"}=e,[Z,te]=k.useState(null),[re,de]=k.useState(null),[W,Q]=k.useState(!1),[q,he]=k.useState(!1),[P,G]=k.useState(!1),[ue,B]=k.useState(!1),[ae,ce]=k.useState(!1),[we,Te]=k.useState(0),[Ve,Ge]=k.useState(0),We=k.useRef(u.duration||M||gc),_t=k.useRef(null),Ye=k.useRef(null),en=v===0,xt=v+1<=x,je=u.type,Xe=u.dismissible!==!1,_e=u.className||"",Zt=u.descriptionClassName||"",ft=k.useMemo(()=>p.findIndex(le=>le.toastId===u.id)||0,[p,u.id]),it=k.useMemo(()=>{var le;return(le=u.closeButton)!=null?le:R},[u.closeButton,R]),T=k.useMemo(()=>u.duration||M||gc,[u.duration,M]),K=k.useRef(0),se=k.useRef(0),ve=k.useRef(0),ye=k.useRef(null),[Pe,Cn]=U.split("-"),vt=k.useMemo(()=>p.reduce((le,Le,ge)=>ge>=ft?le:le+Le.height,0),[p,ft]),qt=wk(),Jn=u.invert||f,pn=je==="loading";se.current=k.useMemo(()=>ft*D+vt,[ft,vt]),k.useEffect(()=>{We.current=T},[T]),k.useEffect(()=>{Q(!0)},[]),k.useEffect(()=>{const le=Ye.current;if(le){const Le=le.getBoundingClientRect().height;return Ge(Le),y(ge=>[{toastId:u.id,height:Le,position:u.position},...ge]),()=>y(ge=>ge.filter(De=>De.toastId!==u.id))}},[y,u.id]),k.useLayoutEffect(()=>{if(!W)return;const le=Ye.current,Le=le.style.height;le.style.height="auto";const ge=le.getBoundingClientRect().height;le.style.height=Le,Ge(ge),y(De=>De.find($e=>$e.toastId===u.id)?De.map($e=>$e.toastId===u.id?{...$e,height:ge}:$e):[{toastId:u.id,height:ge,position:u.position},...De])},[W,u.title,u.description,y,u.id,u.jsx,u.action,u.cancel]);const Mt=k.useCallback(()=>{he(!0),Te(se.current),y(le=>le.filter(Le=>Le.toastId!==u.id)),setTimeout(()=>{b(u)},Mk)},[u,b,y,se]);k.useEffect(()=>{if(u.promise&&je==="loading"||u.duration===1/0||u.type==="loading")return;let le;return w||g||qt?(()=>{if(ve.current<K.current){const De=new Date().getTime()-K.current;We.current=We.current-De}ve.current=new Date().getTime()})():(()=>{We.current!==1/0&&(K.current=new Date().getTime(),le=setTimeout(()=>{u.onAutoClose==null||u.onAutoClose.call(u,u),Mt()},We.current))})(),()=>clearTimeout(le)},[w,g,u,je,qt,Mt]),k.useEffect(()=>{u.delete&&(Mt(),u.onDismiss==null||u.onDismiss.call(u,u))},[Mt,u.delete]);function Nn(){var le;if(A?.loading){var Le;return k.createElement("div",{className:Lt(z?.loader,u==null||(Le=u.classNames)==null?void 0:Le.loader,"sonner-loader"),"data-visible":je==="loading"},A.loading)}return k.createElement(hk,{className:Lt(z?.loader,u==null||(le=u.classNames)==null?void 0:le.loader),visible:je==="loading"})}const An=u.icon||A?.[je]||mk(je);var Er,tn;return k.createElement("li",{tabIndex:0,ref:Ye,className:Lt(O,_e,z?.toast,u==null||(t=u.classNames)==null?void 0:t.toast,z?.default,z?.[je],u==null||(n=u.classNames)==null?void 0:n[je]),"data-sonner-toast":"","data-rich-colors":(Er=u.richColors)!=null?Er:j,"data-styled":!(u.jsx||u.unstyled||h),"data-mounted":W,"data-promise":!!u.promise,"data-swiped":ae,"data-removed":q,"data-visible":xt,"data-y-position":Pe,"data-x-position":Cn,"data-index":v,"data-front":en,"data-swiping":P,"data-dismissible":Xe,"data-type":je,"data-invert":Jn,"data-swipe-out":ue,"data-swipe-direction":re,"data-expanded":!!(w||H&&W),"data-testid":u.testId,style:{"--index":v,"--toasts-before":v,"--z-index":_.length-v,"--offset":`${q?we:se.current}px`,"--initial-height":H?"auto":`${Ve}px`,...I,...u.style},onDragEnd:()=>{G(!1),te(null),ye.current=null},onPointerDown:le=>{le.button!==2&&(pn||!Xe||(_t.current=new Date,Te(se.current),le.target.setPointerCapture(le.pointerId),le.target.tagName!=="BUTTON"&&(G(!0),ye.current={x:le.clientX,y:le.clientY})))},onPointerUp:()=>{var le,Le,ge;if(ue||!Xe)return;ye.current=null;const De=Number(((le=Ye.current)==null?void 0:le.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),En=Number(((Le=Ye.current)==null?void 0:Le.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),$e=new Date().getTime()-((ge=_t.current)==null?void 0:ge.getTime()),Qe=Z==="x"?De:En,hn=Math.abs(Qe)/$e;if(Math.abs(Qe)>=Ok||hn>.11){Te(se.current),u.onDismiss==null||u.onDismiss.call(u,u),de(Z==="x"?De>0?"right":"left":En>0?"down":"up"),Mt(),B(!0);return}else{var ct,mt;(ct=Ye.current)==null||ct.style.setProperty("--swipe-amount-x","0px"),(mt=Ye.current)==null||mt.style.setProperty("--swipe-amount-y","0px")}ce(!1),G(!1),te(null)},onPointerMove:le=>{var Le,ge,De;if(!ye.current||!Xe||((Le=window.getSelection())==null?void 0:Le.toString().length)>0)return;const $e=le.clientY-ye.current.y,Qe=le.clientX-ye.current.x;var hn;const ct=(hn=e.swipeDirections)!=null?hn:Lk(U);!Z&&(Math.abs(Qe)>1||Math.abs($e)>1)&&te(Math.abs(Qe)>Math.abs($e)?"x":"y");let mt={x:0,y:0};const pt=et=>1/(1.5+Math.abs(et)/20);if(Z==="y"){if(ct.includes("top")||ct.includes("bottom"))if(ct.includes("top")&&$e<0||ct.includes("bottom")&&$e>0)mt.y=$e;else{const et=$e*pt($e);mt.y=Math.abs(et)<Math.abs($e)?et:$e}}else if(Z==="x"&&(ct.includes("left")||ct.includes("right")))if(ct.includes("left")&&Qe<0||ct.includes("right")&&Qe>0)mt.x=Qe;else{const et=Qe*pt(Qe);mt.x=Math.abs(et)<Math.abs(Qe)?et:Qe}(Math.abs(mt.x)>0||Math.abs(mt.y)>0)&&ce(!0),(ge=Ye.current)==null||ge.style.setProperty("--swipe-amount-x",`${mt.x}px`),(De=Ye.current)==null||De.style.setProperty("--swipe-amount-y",`${mt.y}px`)}},it&&!u.jsx&&je!=="loading"?k.createElement("button",{"aria-label":N,"data-disabled":pn,"data-close-button":!0,onClick:pn||!Xe?()=>{}:()=>{Mt(),u.onDismiss==null||u.onDismiss.call(u,u)},className:Lt(z?.closeButton,u==null||(r=u.classNames)==null?void 0:r.closeButton)},(tn=A?.close)!=null?tn:bk):null,(je||u.icon||u.promise)&&u.icon!==null&&(A?.[je]!==null||u.icon)?k.createElement("div",{"data-icon":"",className:Lt(z?.icon,u==null||(o=u.classNames)==null?void 0:o.icon)},u.promise||u.type==="loading"&&!u.icon?u.icon||Nn():null,u.type!=="loading"?An:null):null,k.createElement("div",{"data-content":"",className:Lt(z?.content,u==null||(a=u.classNames)==null?void 0:a.content)},k.createElement("div",{"data-title":"",className:Lt(z?.title,u==null||(i=u.classNames)==null?void 0:i.title)},u.jsx?u.jsx:typeof u.title=="function"?u.title():u.title),u.description?k.createElement("div",{"data-description":"",className:Lt(F,Zt,z?.description,u==null||(c=u.classNames)==null?void 0:c.description)},typeof u.description=="function"?u.description():u.description):null),k.isValidElement(u.cancel)?u.cancel:u.cancel&&Br(u.cancel)?k.createElement("button",{"data-button":!0,"data-cancel":!0,style:u.cancelButtonStyle||C,onClick:le=>{Br(u.cancel)&&Xe&&(u.cancel.onClick==null||u.cancel.onClick.call(u.cancel,le),Mt())},className:Lt(z?.cancelButton,u==null||(l=u.classNames)==null?void 0:l.cancelButton)},u.cancel.label):null,k.isValidElement(u.action)?u.action:u.action&&Br(u.action)?k.createElement("button",{"data-button":!0,"data-action":!0,style:u.actionButtonStyle||E,onClick:le=>{Br(u.action)&&(u.action.onClick==null||u.action.onClick.call(u.action,le),!le.defaultPrevented&&Mt())},className:Lt(z?.actionButton,u==null||(d=u.classNames)==null?void 0:d.actionButton)},u.action.label):null)};function xc(){if(typeof window>"u"||typeof document>"u")return"ltr";const e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function $k(e,t){const n={};return[e,t].forEach((r,o)=>{const a=o===1,i=a?"--mobile-offset":"--offset",c=a?Tk:Ik;function l(d){["top","right","bottom","left"].forEach(f=>{n[`${i}-${f}`]=typeof d=="number"?`${d}px`:d})}typeof r=="number"||typeof r=="string"?l(r):typeof r=="object"?["top","right","bottom","left"].forEach(d=>{r[d]===void 0?n[`${i}-${d}`]=c:n[`${i}-${d}`]=typeof r[d]=="number"?`${r[d]}px`:r[d]}):l(c)}),n}const zk=k.forwardRef(function(t,n){const{id:r,invert:o,position:a="bottom-right",hotkey:i=["altKey","KeyT"],expand:c,closeButton:l,className:d,offset:f,mobileOffset:u,theme:h="light",richColors:g,duration:y,style:x,visibleToasts:p=Ek,toastOptions:v,dir:_=xc(),gap:w=Rk,icons:b,containerAriaLabel:j="Notifications"}=t,[R,I]=k.useState([]),C=k.useMemo(()=>r?R.filter(W=>W.toasterId===r):R.filter(W=>!W.toasterId),[R,r]),E=k.useMemo(()=>Array.from(new Set([a].concat(C.filter(W=>W.position).map(W=>W.position)))),[C,a]),[O,F]=k.useState([]),[M,U]=k.useState(!1),[D,H]=k.useState(!1),[z,A]=k.useState(h!=="system"?h:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),N=k.useRef(null),Z=i.join("+").replace(/Key/g,"").replace(/Digit/g,""),te=k.useRef(null),re=k.useRef(!1),de=k.useCallback(W=>{I(Q=>{var q;return(q=Q.find(he=>he.id===W.id))!=null&&q.delete||dt.dismiss(W.id),Q.filter(({id:he})=>he!==W.id)})},[]);return k.useEffect(()=>dt.subscribe(W=>{if(W.dismiss){requestAnimationFrame(()=>{I(Q=>Q.map(q=>q.id===W.id?{...q,delete:!0}:q))});return}setTimeout(()=>{Zo.flushSync(()=>{I(Q=>{const q=Q.findIndex(he=>he.id===W.id);return q!==-1?[...Q.slice(0,q),{...Q[q],...W},...Q.slice(q+1)]:[W,...Q]})})})}),[R]),k.useEffect(()=>{if(h!=="system"){A(h);return}if(h==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?A("dark"):A("light")),typeof window>"u")return;const W=window.matchMedia("(prefers-color-scheme: dark)");try{W.addEventListener("change",({matches:Q})=>{A(Q?"dark":"light")})}catch{W.addListener(({matches:q})=>{try{A(q?"dark":"light")}catch(he){console.error(he)}})}},[h]),k.useEffect(()=>{R.length<=1&&U(!1)},[R]),k.useEffect(()=>{const W=Q=>{var q;if(i.every(G=>Q[G]||Q.code===G)){var P;U(!0),(P=N.current)==null||P.focus()}Q.code==="Escape"&&(document.activeElement===N.current||(q=N.current)!=null&&q.contains(document.activeElement))&&U(!1)};return document.addEventListener("keydown",W),()=>document.removeEventListener("keydown",W)},[i]),k.useEffect(()=>{if(N.current)return()=>{te.current&&(te.current.focus({preventScroll:!0}),te.current=null,re.current=!1)}},[N.current]),k.createElement("section",{ref:n,"aria-label":`${j} ${Z}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},E.map((W,Q)=>{var q;const[he,P]=W.split("-");return C.length?k.createElement("ol",{key:W,dir:_==="auto"?xc():_,tabIndex:-1,ref:N,className:d,"data-sonner-toaster":!0,"data-sonner-theme":z,"data-y-position":he,"data-x-position":P,style:{"--front-toast-height":`${((q=O[0])==null?void 0:q.height)||0}px`,"--width":`${Pk}px`,"--gap":`${w}px`,...x,...$k(f,u)},onBlur:G=>{re.current&&!G.currentTarget.contains(G.relatedTarget)&&(re.current=!1,te.current&&(te.current.focus({preventScroll:!0}),te.current=null))},onFocus:G=>{G.target instanceof HTMLElement&&G.target.dataset.dismissible==="false"||re.current||(re.current=!0,te.current=G.relatedTarget)},onMouseEnter:()=>U(!0),onMouseMove:()=>U(!0),onMouseLeave:()=>{D||U(!1)},onDragEnd:()=>U(!1),onPointerDown:G=>{G.target instanceof HTMLElement&&G.target.dataset.dismissible==="false"||H(!0)},onPointerUp:()=>H(!1)},C.filter(G=>!G.position&&Q===0||G.position===W).map((G,ue)=>{var B,ae;return k.createElement(Dk,{key:G.id,icons:b,index:ue,toast:G,defaultRichColors:g,duration:(B=v?.duration)!=null?B:y,className:v?.className,descriptionClassName:v?.descriptionClassName,invert:o,visibleToasts:p,closeButton:(ae=v?.closeButton)!=null?ae:l,interacting:D,position:W,style:v?.style,unstyled:v?.unstyled,classNames:v?.classNames,cancelButtonStyle:v?.cancelButtonStyle,actionButtonStyle:v?.actionButtonStyle,closeButtonAriaLabel:v?.closeButtonAriaLabel,removeToast:de,toasts:C.filter(ce=>ce.position==G.position),heights:O.filter(ce=>ce.position==G.position),setHeights:F,expandByDefault:c,gap:w,expanded:M,swipeDirections:t.swipeDirections})})):null}))}),Fa=m.createContext(null);function Fk(){const e=m.useContext(Fa);if(!e)throw new Error("useToast must be used within ToastProvider");return e}function Hs(){return m.useContext(Fa)}function Uk({children:e}){const t=m.useCallback(n=>{const r=n.title??"",o=n.description;Ak(r||o||"Notification",{description:r?o:void 0,duration:n.durationMs??5e3,action:n.actionLabel&&n.onAction?{label:n.actionLabel,onClick:()=>n.onAction?.()}:void 0})},[]);return s.jsxs(Fa.Provider,{value:{toast:t},children:[e,s.jsx(zk,{position:"top-center",closeButton:!0,expand:!0,className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:pointer-events-auto group-[.toaster]:w-full group-[.toaster]:rounded-xl group-[.toaster]:border group-[.toaster]:border-neutral-200 group-[.toaster]:bg-white group-[.toaster]:p-4 group-[.toaster]:shadow-lg dark:group-[.toaster]:border-neutral-800 dark:group-[.toaster]:bg-neutral-950",title:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",description:"text-sm text-neutral-600 dark:text-neutral-400",actionButton:"h-8 rounded-md border border-neutral-200 bg-white px-3 text-xs font-medium text-neutral-900 shadow-sm hover:bg-neutral-50 dark:border-neutral-800 dark:bg-neutral-950 dark:text-neutral-50 dark:hover:bg-neutral-900",cancelButton:"h-8 rounded-md bg-neutral-100 px-3 text-xs font-medium text-neutral-900 hover:bg-neutral-200 dark:bg-neutral-800 dark:text-neutral-50 dark:hover:bg-neutral-700",closeButton:"rounded-md text-neutral-600 opacity-0 transition-opacity hover:bg-neutral-100 hover:text-neutral-900 group-hover:opacity-100 dark:text-neutral-400 dark:hover:bg-neutral-800 dark:hover:text-neutral-50"}}})]})}const{entries:vf,setPrototypeOf:vc,isFrozen:Bk,getPrototypeOf:Vk,getOwnPropertyDescriptor:Wk}=Object;let{freeze:ot,seal:bt,create:Uo}=Object,{apply:Bo,construct:Vo}=typeof Reflect<"u"&&Reflect;ot||(ot=function(t){return t});bt||(bt=function(t){return t});Bo||(Bo=function(t,n){for(var r=arguments.length,o=new Array(r>2?r-2:0),a=2;a<r;a++)o[a-2]=arguments[a];return t.apply(n,o)});Vo||(Vo=function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return new t(...r)});const Vr=at(Array.prototype.forEach),Hk=at(Array.prototype.lastIndexOf),yc=at(Array.prototype.pop),nr=at(Array.prototype.push),Zk=at(Array.prototype.splice),Qr=at(String.prototype.toLowerCase),po=at(String.prototype.toString),ho=at(String.prototype.match),rr=at(String.prototype.replace),qk=at(String.prototype.indexOf),Gk=at(String.prototype.trim),Nt=at(Object.prototype.hasOwnProperty),tt=at(RegExp.prototype.test),sr=Yk(TypeError);function at(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return Bo(e,t,r)}}function Yk(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return Vo(e,n)}}function me(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Qr;vc&&vc(e,null);let r=t.length;for(;r--;){let o=t[r];if(typeof o=="string"){const a=n(o);a!==o&&(Bk(t)||(t[r]=a),o=a)}e[o]=!0}return e}function Qk(e){for(let t=0;t<e.length;t++)Nt(e,t)||(e[t]=null);return e}function Dt(e){const t=Uo(null);for(const[n,r]of vf(e))Nt(e,n)&&(Array.isArray(r)?t[n]=Qk(r):r&&typeof r=="object"&&r.constructor===Object?t[n]=Dt(r):t[n]=r);return t}function or(e,t){for(;e!==null;){const r=Wk(e,t);if(r){if(r.get)return at(r.get);if(typeof r.value=="function")return at(r.value)}e=Vk(e)}function n(){return null}return n}const bc=ot(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),go=ot(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),xo=ot(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Kk=ot(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),vo=ot(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),Jk=ot(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),wc=ot(["#text"]),_c=ot(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),yo=ot(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),kc=ot(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Wr=ot(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Xk=bt(/\{\{[\w\W]*|[\w\W]*\}\}/gm),ej=bt(/<%[\w\W]*|[\w\W]*%>/gm),tj=bt(/\$\{[\w\W]*/gm),nj=bt(/^data-[\-\w.\u00B7-\uFFFF]+$/),rj=bt(/^aria-[\-\w]+$/),yf=bt(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),sj=bt(/^(?:\w+script|data):/i),oj=bt(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),bf=bt(/^html$/i),aj=bt(/^[a-z][.\w]*(-[.\w]+)+$/i);var jc=Object.freeze({__proto__:null,ARIA_ATTR:rj,ATTR_WHITESPACE:oj,CUSTOM_ELEMENT:aj,DATA_ATTR:nj,DOCTYPE_NAME:bf,ERB_EXPR:ej,IS_ALLOWED_URI:yf,IS_SCRIPT_OR_DATA:sj,MUSTACHE_EXPR:Xk,TMPLIT_EXPR:tj});const ar={element:1,text:3,progressingInstruction:7,comment:8,document:9},ij=function(){return typeof window>"u"?null:window},cj=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null;const o="data-tt-policy-suffix";n&&n.hasAttribute(o)&&(r=n.getAttribute(o));const a="dompurify"+(r?"#"+r:"");try{return t.createPolicy(a,{createHTML(i){return i},createScriptURL(i){return i}})}catch{return console.warn("TrustedTypes policy "+a+" could not be created."),null}},Sc=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function wf(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:ij();const t=oe=>wf(oe);if(t.version="3.3.1",t.removed=[],!e||!e.document||e.document.nodeType!==ar.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e;const r=n,o=r.currentScript,{DocumentFragment:a,HTMLTemplateElement:i,Node:c,Element:l,NodeFilter:d,NamedNodeMap:f=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:u,DOMParser:h,trustedTypes:g}=e,y=l.prototype,x=or(y,"cloneNode"),p=or(y,"remove"),v=or(y,"nextSibling"),_=or(y,"childNodes"),w=or(y,"parentNode");if(typeof i=="function"){const oe=n.createElement("template");oe.content&&oe.content.ownerDocument&&(n=oe.content.ownerDocument)}let b,j="";const{implementation:R,createNodeIterator:I,createDocumentFragment:C,getElementsByTagName:E}=n,{importNode:O}=r;let F=Sc();t.isSupported=typeof vf=="function"&&typeof w=="function"&&R&&R.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:M,ERB_EXPR:U,TMPLIT_EXPR:D,DATA_ATTR:H,ARIA_ATTR:z,IS_SCRIPT_OR_DATA:A,ATTR_WHITESPACE:N,CUSTOM_ELEMENT:Z}=jc;let{IS_ALLOWED_URI:te}=jc,re=null;const de=me({},[...bc,...go,...xo,...vo,...wc]);let W=null;const Q=me({},[..._c,...yo,...kc,...Wr]);let q=Object.seal(Uo(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),he=null,P=null;const G=Object.seal(Uo(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let ue=!0,B=!0,ae=!1,ce=!0,we=!1,Te=!0,Ve=!1,Ge=!1,We=!1,_t=!1,Ye=!1,en=!1,xt=!0,je=!1;const Xe="user-content-";let _e=!0,Zt=!1,ft={},it=null;const T=me({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let K=null;const se=me({},["audio","video","img","source","image","track"]);let ve=null;const ye=me({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Pe="http://www.w3.org/1998/Math/MathML",Cn="http://www.w3.org/2000/svg",vt="http://www.w3.org/1999/xhtml";let qt=vt,Jn=!1,pn=null;const Mt=me({},[Pe,Cn,vt],po);let Nn=me({},["mi","mo","mn","ms","mtext"]),An=me({},["annotation-xml"]);const Er=me({},["title","style","font","a","script"]);let tn=null;const le=["application/xhtml+xml","text/html"],Le="text/html";let ge=null,De=null;const En=n.createElement("form"),$e=function(S){return S instanceof RegExp||S instanceof Function},Qe=function(){let S=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(De&&De===S)){if((!S||typeof S!="object")&&(S={}),S=Dt(S),tn=le.indexOf(S.PARSER_MEDIA_TYPE)===-1?Le:S.PARSER_MEDIA_TYPE,ge=tn==="application/xhtml+xml"?po:Qr,re=Nt(S,"ALLOWED_TAGS")?me({},S.ALLOWED_TAGS,ge):de,W=Nt(S,"ALLOWED_ATTR")?me({},S.ALLOWED_ATTR,ge):Q,pn=Nt(S,"ALLOWED_NAMESPACES")?me({},S.ALLOWED_NAMESPACES,po):Mt,ve=Nt(S,"ADD_URI_SAFE_ATTR")?me(Dt(ye),S.ADD_URI_SAFE_ATTR,ge):ye,K=Nt(S,"ADD_DATA_URI_TAGS")?me(Dt(se),S.ADD_DATA_URI_TAGS,ge):se,it=Nt(S,"FORBID_CONTENTS")?me({},S.FORBID_CONTENTS,ge):T,he=Nt(S,"FORBID_TAGS")?me({},S.FORBID_TAGS,ge):Dt({}),P=Nt(S,"FORBID_ATTR")?me({},S.FORBID_ATTR,ge):Dt({}),ft=Nt(S,"USE_PROFILES")?S.USE_PROFILES:!1,ue=S.ALLOW_ARIA_ATTR!==!1,B=S.ALLOW_DATA_ATTR!==!1,ae=S.ALLOW_UNKNOWN_PROTOCOLS||!1,ce=S.ALLOW_SELF_CLOSE_IN_ATTR!==!1,we=S.SAFE_FOR_TEMPLATES||!1,Te=S.SAFE_FOR_XML!==!1,Ve=S.WHOLE_DOCUMENT||!1,_t=S.RETURN_DOM||!1,Ye=S.RETURN_DOM_FRAGMENT||!1,en=S.RETURN_TRUSTED_TYPE||!1,We=S.FORCE_BODY||!1,xt=S.SANITIZE_DOM!==!1,je=S.SANITIZE_NAMED_PROPS||!1,_e=S.KEEP_CONTENT!==!1,Zt=S.IN_PLACE||!1,te=S.ALLOWED_URI_REGEXP||yf,qt=S.NAMESPACE||vt,Nn=S.MATHML_TEXT_INTEGRATION_POINTS||Nn,An=S.HTML_INTEGRATION_POINTS||An,q=S.CUSTOM_ELEMENT_HANDLING||{},S.CUSTOM_ELEMENT_HANDLING&&$e(S.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(q.tagNameCheck=S.CUSTOM_ELEMENT_HANDLING.tagNameCheck),S.CUSTOM_ELEMENT_HANDLING&&$e(S.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(q.attributeNameCheck=S.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),S.CUSTOM_ELEMENT_HANDLING&&typeof S.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(q.allowCustomizedBuiltInElements=S.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),we&&(B=!1),Ye&&(_t=!0),ft&&(re=me({},wc),W=[],ft.html===!0&&(me(re,bc),me(W,_c)),ft.svg===!0&&(me(re,go),me(W,yo),me(W,Wr)),ft.svgFilters===!0&&(me(re,xo),me(W,yo),me(W,Wr)),ft.mathMl===!0&&(me(re,vo),me(W,kc),me(W,Wr))),S.ADD_TAGS&&(typeof S.ADD_TAGS=="function"?G.tagCheck=S.ADD_TAGS:(re===de&&(re=Dt(re)),me(re,S.ADD_TAGS,ge))),S.ADD_ATTR&&(typeof S.ADD_ATTR=="function"?G.attributeCheck=S.ADD_ATTR:(W===Q&&(W=Dt(W)),me(W,S.ADD_ATTR,ge))),S.ADD_URI_SAFE_ATTR&&me(ve,S.ADD_URI_SAFE_ATTR,ge),S.FORBID_CONTENTS&&(it===T&&(it=Dt(it)),me(it,S.FORBID_CONTENTS,ge)),S.ADD_FORBID_CONTENTS&&(it===T&&(it=Dt(it)),me(it,S.ADD_FORBID_CONTENTS,ge)),_e&&(re["#text"]=!0),Ve&&me(re,["html","head","body"]),re.table&&(me(re,["tbody"]),delete he.tbody),S.TRUSTED_TYPES_POLICY){if(typeof S.TRUSTED_TYPES_POLICY.createHTML!="function")throw sr('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof S.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw sr('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');b=S.TRUSTED_TYPES_POLICY,j=b.createHTML("")}else b===void 0&&(b=cj(g,o)),b!==null&&typeof j=="string"&&(j=b.createHTML(""));ot&&ot(S),De=S}},hn=me({},[...go,...xo,...Kk]),ct=me({},[...vo,...Jk]),mt=function(S){let V=w(S);(!V||!V.tagName)&&(V={namespaceURI:qt,tagName:"template"});const ee=Qr(S.tagName),Se=Qr(V.tagName);return pn[S.namespaceURI]?S.namespaceURI===Cn?V.namespaceURI===vt?ee==="svg":V.namespaceURI===Pe?ee==="svg"&&(Se==="annotation-xml"||Nn[Se]):!!hn[ee]:S.namespaceURI===Pe?V.namespaceURI===vt?ee==="math":V.namespaceURI===Cn?ee==="math"&&An[Se]:!!ct[ee]:S.namespaceURI===vt?V.namespaceURI===Cn&&!An[Se]||V.namespaceURI===Pe&&!Nn[Se]?!1:!ct[ee]&&(Er[ee]||!hn[ee]):!!(tn==="application/xhtml+xml"&&pn[S.namespaceURI]):!1},pt=function(S){nr(t.removed,{element:S});try{w(S).removeChild(S)}catch{p(S)}},et=function(S,V){try{nr(t.removed,{attribute:V.getAttributeNode(S),from:V})}catch{nr(t.removed,{attribute:null,from:V})}if(V.removeAttribute(S),S==="is")if(_t||Ye)try{pt(V)}catch{}else try{V.setAttribute(S,"")}catch{}},Ys=function(S){let V=null,ee=null;if(We)S="<remove></remove>"+S;else{const ze=ho(S,/^[\r\n\t ]+/);ee=ze&&ze[0]}tn==="application/xhtml+xml"&&qt===vt&&(S='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+S+"</body></html>");const Se=b?b.createHTML(S):S;if(qt===vt)try{V=new h().parseFromString(Se,tn)}catch{}if(!V||!V.documentElement){V=R.createDocument(qt,"template",null);try{V.documentElement.innerHTML=Jn?j:Se}catch{}}const Ke=V.body||V.documentElement;return S&&ee&&Ke.insertBefore(n.createTextNode(ee),Ke.childNodes[0]||null),qt===vt?E.call(V,Ve?"html":"body")[0]:Ve?V.documentElement:Ke},Ka=function(S){return I.call(S.ownerDocument||S,S,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT|d.SHOW_PROCESSING_INSTRUCTION|d.SHOW_CDATA_SECTION,null)},Qs=function(S){return S instanceof u&&(typeof S.nodeName!="string"||typeof S.textContent!="string"||typeof S.removeChild!="function"||!(S.attributes instanceof f)||typeof S.removeAttribute!="function"||typeof S.setAttribute!="function"||typeof S.namespaceURI!="string"||typeof S.insertBefore!="function"||typeof S.hasChildNodes!="function")},Ja=function(S){return typeof c=="function"&&S instanceof c};function Gt(oe,S,V){Vr(oe,ee=>{ee.call(t,S,V,De)})}const Xa=function(S){let V=null;if(Gt(F.beforeSanitizeElements,S,null),Qs(S))return pt(S),!0;const ee=ge(S.nodeName);if(Gt(F.uponSanitizeElement,S,{tagName:ee,allowedTags:re}),Te&&S.hasChildNodes()&&!Ja(S.firstElementChild)&&tt(/<[/\w!]/g,S.innerHTML)&&tt(/<[/\w!]/g,S.textContent)||S.nodeType===ar.progressingInstruction||Te&&S.nodeType===ar.comment&&tt(/<[/\w]/g,S.data))return pt(S),!0;if(!(G.tagCheck instanceof Function&&G.tagCheck(ee))&&(!re[ee]||he[ee])){if(!he[ee]&&ti(ee)&&(q.tagNameCheck instanceof RegExp&&tt(q.tagNameCheck,ee)||q.tagNameCheck instanceof Function&&q.tagNameCheck(ee)))return!1;if(_e&&!it[ee]){const Se=w(S)||S.parentNode,Ke=_(S)||S.childNodes;if(Ke&&Se){const ze=Ke.length;for(let lt=ze-1;lt>=0;--lt){const Yt=x(Ke[lt],!0);Yt.__removalCount=(S.__removalCount||0)+1,Se.insertBefore(Yt,v(S))}}}return pt(S),!0}return S instanceof l&&!mt(S)||(ee==="noscript"||ee==="noembed"||ee==="noframes")&&tt(/<\/no(script|embed|frames)/i,S.innerHTML)?(pt(S),!0):(we&&S.nodeType===ar.text&&(V=S.textContent,Vr([M,U,D],Se=>{V=rr(V,Se," ")}),S.textContent!==V&&(nr(t.removed,{element:S.cloneNode()}),S.textContent=V)),Gt(F.afterSanitizeElements,S,null),!1)},ei=function(S,V,ee){if(xt&&(V==="id"||V==="name")&&(ee in n||ee in En))return!1;if(!(B&&!P[V]&&tt(H,V))){if(!(ue&&tt(z,V))){if(!(G.attributeCheck instanceof Function&&G.attributeCheck(V,S))){if(!W[V]||P[V]){if(!(ti(S)&&(q.tagNameCheck instanceof RegExp&&tt(q.tagNameCheck,S)||q.tagNameCheck instanceof Function&&q.tagNameCheck(S))&&(q.attributeNameCheck instanceof RegExp&&tt(q.attributeNameCheck,V)||q.attributeNameCheck instanceof Function&&q.attributeNameCheck(V,S))||V==="is"&&q.allowCustomizedBuiltInElements&&(q.tagNameCheck instanceof RegExp&&tt(q.tagNameCheck,ee)||q.tagNameCheck instanceof Function&&q.tagNameCheck(ee))))return!1}else if(!ve[V]){if(!tt(te,rr(ee,N,""))){if(!((V==="src"||V==="xlink:href"||V==="href")&&S!=="script"&&qk(ee,"data:")===0&&K[S])){if(!(ae&&!tt(A,rr(ee,N,"")))){if(ee)return!1}}}}}}}return!0},ti=function(S){return S!=="annotation-xml"&&ho(S,Z)},ni=function(S){Gt(F.beforeSanitizeAttributes,S,null);const{attributes:V}=S;if(!V||Qs(S))return;const ee={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:W,forceKeepAttr:void 0};let Se=V.length;for(;Se--;){const Ke=V[Se],{name:ze,namespaceURI:lt,value:Yt}=Ke,In=ge(ze),Ks=Yt;let He=ze==="value"?Ks:Gk(Ks);if(ee.attrName=In,ee.attrValue=He,ee.keepAttr=!0,ee.forceKeepAttr=void 0,Gt(F.uponSanitizeAttribute,S,ee),He=ee.attrValue,je&&(In==="id"||In==="name")&&(et(ze,S),He=Xe+He),Te&&tt(/((--!?|])>)|<\/(style|title|textarea)/i,He)){et(ze,S);continue}if(In==="attributename"&&ho(He,"href")){et(ze,S);continue}if(ee.forceKeepAttr)continue;if(!ee.keepAttr){et(ze,S);continue}if(!ce&&tt(/\/>/i,He)){et(ze,S);continue}we&&Vr([M,U,D],si=>{He=rr(He,si," ")});const ri=ge(S.nodeName);if(!ei(ri,In,He)){et(ze,S);continue}if(b&&typeof g=="object"&&typeof g.getAttributeType=="function"&&!lt)switch(g.getAttributeType(ri,In)){case"TrustedHTML":{He=b.createHTML(He);break}case"TrustedScriptURL":{He=b.createScriptURL(He);break}}if(He!==Ks)try{lt?S.setAttributeNS(lt,ze,He):S.setAttribute(ze,He),Qs(S)?pt(S):yc(t.removed)}catch{et(ze,S)}}Gt(F.afterSanitizeAttributes,S,null)},$f=function oe(S){let V=null;const ee=Ka(S);for(Gt(F.beforeSanitizeShadowDOM,S,null);V=ee.nextNode();)Gt(F.uponSanitizeShadowNode,V,null),Xa(V),ni(V),V.content instanceof a&&oe(V.content);Gt(F.afterSanitizeShadowDOM,S,null)};return t.sanitize=function(oe){let S=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},V=null,ee=null,Se=null,Ke=null;if(Jn=!oe,Jn&&(oe="<!-->"),typeof oe!="string"&&!Ja(oe))if(typeof oe.toString=="function"){if(oe=oe.toString(),typeof oe!="string")throw sr("dirty is not a string, aborting")}else throw sr("toString is not a function");if(!t.isSupported)return oe;if(Ge||Qe(S),t.removed=[],typeof oe=="string"&&(Zt=!1),Zt){if(oe.nodeName){const Yt=ge(oe.nodeName);if(!re[Yt]||he[Yt])throw sr("root node is forbidden and cannot be sanitized in-place")}}else if(oe instanceof c)V=Ys("<!---->"),ee=V.ownerDocument.importNode(oe,!0),ee.nodeType===ar.element&&ee.nodeName==="BODY"||ee.nodeName==="HTML"?V=ee:V.appendChild(ee);else{if(!_t&&!we&&!Ve&&oe.indexOf("<")===-1)return b&&en?b.createHTML(oe):oe;if(V=Ys(oe),!V)return _t?null:en?j:""}V&&We&&pt(V.firstChild);const ze=Ka(Zt?oe:V);for(;Se=ze.nextNode();)Xa(Se),ni(Se),Se.content instanceof a&&$f(Se.content);if(Zt)return oe;if(_t){if(Ye)for(Ke=C.call(V.ownerDocument);V.firstChild;)Ke.appendChild(V.firstChild);else Ke=V;return(W.shadowroot||W.shadowrootmode)&&(Ke=O.call(r,Ke,!0)),Ke}let lt=Ve?V.outerHTML:V.innerHTML;return Ve&&re["!doctype"]&&V.ownerDocument&&V.ownerDocument.doctype&&V.ownerDocument.doctype.name&&tt(bf,V.ownerDocument.doctype.name)&&(lt="<!DOCTYPE "+V.ownerDocument.doctype.name+`>
|
|
84
|
+
`+lt),we&&Vr([M,U,D],Yt=>{lt=rr(lt,Yt," ")}),b&&en?b.createHTML(lt):lt},t.setConfig=function(){let oe=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Qe(oe),Ge=!0},t.clearConfig=function(){De=null,Ge=!1},t.isValidAttribute=function(oe,S,V){De||Qe({});const ee=ge(oe),Se=ge(S);return ei(ee,Se,V)},t.addHook=function(oe,S){typeof S=="function"&&nr(F[oe],S)},t.removeHook=function(oe,S){if(S!==void 0){const V=Hk(F[oe],S);return V===-1?void 0:Zk(F[oe],V,1)[0]}return yc(F[oe])},t.removeHooks=function(oe){F[oe]=[]},t.removeAllHooks=function(){F=Sc()},t}var bo=wf();function _f({faq:e,className:t,expanded:n,defaultExpanded:r=!1,onExpandedChange:o,showKeywords:a=!1,dangerouslySetAnswerHTML:i=!1}){const[c,l]=m.useState(r),d=n!==void 0,f=d?n:c,u=()=>{const h=!f;d||l(h),o?.(h)};return s.jsxs("div",{className:L("border border-neutral-200 rounded-lg overflow-hidden dark:border-neutral-800",t),children:[s.jsxs("button",{type:"button",onClick:u,className:L("w-full flex items-center justify-between px-4 py-3 text-left","bg-neutral-50 hover:bg-neutral-100 dark:bg-neutral-900 dark:hover:bg-neutral-800","transition-colors duration-150"),"aria-expanded":f,children:[s.jsx("span",{className:"font-medium text-neutral-900 dark:text-neutral-100 pr-4",children:e.question}),s.jsx("svg",{className:L("w-5 h-5 text-neutral-500 transition-transform duration-200 flex-shrink-0",f&&"rotate-180"),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),f&&s.jsxs("div",{className:"px-4 py-3 bg-white dark:bg-neutral-950",children:[i?s.jsx("div",{className:"text-sm text-neutral-600 dark:text-neutral-400 prose prose-sm dark:prose-invert max-w-none",dangerouslySetInnerHTML:{__html:(()=>{bo.addHook("afterSanitizeAttributes",g=>{g.tagName==="A"&&g.setAttribute("rel","noopener noreferrer")});const h=bo.sanitize(e.answer,{ALLOWED_TAGS:["b","i","em","strong","a","p","br","ul","ol","li"],ALLOWED_ATTR:["href","target","rel"]});return bo.removeAllHooks(),h})()}}):s.jsx("p",{className:"text-sm text-neutral-600 dark:text-neutral-400 whitespace-pre-wrap",children:e.answer}),a&&e.keywords&&e.keywords.length>0&&s.jsx("div",{className:"mt-3 flex flex-wrap gap-1",children:e.keywords.map(h=>s.jsx("span",{className:"px-2 py-0.5 text-xs bg-neutral-100 text-neutral-600 rounded dark:bg-neutral-800 dark:text-neutral-400",children:h},h))})]})]})}function lj({faqs:e,className:t,accordion:n=!1,showKeywords:r=!1,dangerouslySetAnswerHTML:o=!1,emptyMessage:a="No FAQs available."}){const[i,c]=m.useState(null),l=e.filter(d=>d.active!==!1);return l.length===0?s.jsx("div",{className:L("text-center py-8 text-neutral-500 dark:text-neutral-400",t),children:a}):s.jsx("div",{className:L("space-y-2",t),children:l.map(d=>s.jsx(_f,{faq:d,showKeywords:r,dangerouslySetAnswerHTML:o,expanded:n?i===d.id:void 0,onExpandedChange:n?f=>c(f?d.id:null):void 0},d.id))})}function Be({amount:e,currency:t}){return new Intl.NumberFormat(void 0,{style:"currency",currency:t}).format(e)}function Zs({amount:e,currency:t,compareAt:n,className:r,size:o="default"}){const a=typeof n=="number"&&n>e;return s.jsxs("div",{className:L("flex items-baseline gap-2 tabular-nums",r),children:[s.jsx("span",{className:L("font-semibold",o==="sm"?"text-sm":"text-base"),children:Be({amount:e,currency:t})}),a?s.jsx("span",{className:L("text-neutral-500 line-through dark:text-neutral-400",o==="sm"?"text-xs":"text-sm"),children:Be({amount:n,currency:t})}):null]})}const Cc={large:"aspect-[4/5]",square:"aspect-square",compact:"aspect-[3/4]"},Nc={center:"object-center",top:"object-top",bottom:"object-bottom",left:"object-left",right:"object-right"};function kf({product:e,href:t,onAddToCart:n,onQuickView:r,className:o,layout:a="large",imageCrop:i="center"}){const c=e.inventoryStatus==="out_of_stock"||typeof e.inventoryQuantity=="number"&&e.inventoryQuantity<=0,l=typeof e.inventoryQuantity=="number"?e.inventoryQuantity:null;return s.jsxs(Et,{className:L("group flex h-full flex-col overflow-hidden rounded-2xl",o),children:[s.jsxs("div",{className:"relative",children:[t?s.jsx("a",{href:t,className:"block","aria-label":`View ${e.title}`,children:s.jsx("div",{className:L("overflow-hidden bg-neutral-100 dark:bg-neutral-900",Cc[a]),children:s.jsx("img",{src:e.images[0]?.url,alt:e.images[0]?.alt??e.title,className:L("h-full w-full object-cover transition-transform duration-300 group-hover:scale-[1.03]",Nc[i]),loading:"lazy"})})}):s.jsx("div",{className:L("overflow-hidden bg-neutral-100 dark:bg-neutral-900",Cc[a]),children:s.jsx("img",{src:e.images[0]?.url,alt:e.images[0]?.alt??e.title,className:L("h-full w-full object-cover transition-transform duration-300 group-hover:scale-[1.03]",Nc[i]),loading:"lazy"})}),a!=="compact"&&e.tags?.length?s.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 flex gap-1 p-3",children:e.tags.slice(0,2).map(d=>s.jsx(vn,{className:"pointer-events-none bg-white/90 text-neutral-900 backdrop-blur dark:bg-neutral-950/80 dark:text-neutral-50",children:d},d))}):null,c?s.jsx("div",{className:"pointer-events-none absolute left-3 top-3",children:s.jsx(vn,{variant:"secondary",className:"bg-white/90 text-neutral-900 backdrop-blur dark:bg-neutral-950/80 dark:text-neutral-50",children:"Out of stock"})}):l!=null&&l>0&&l<=5?s.jsx("div",{className:"pointer-events-none absolute left-3 top-3",children:s.jsxs(vn,{variant:"secondary",className:"bg-white/90 text-neutral-900 backdrop-blur dark:bg-neutral-950/80 dark:text-neutral-50",children:["Only ",l," left"]})}):null,r?s.jsx("div",{className:"absolute right-3 top-3 opacity-0 transition-opacity group-hover:opacity-100",children:s.jsx(ne,{type:"button",size:"sm",variant:"secondary",className:"h-9",onClick:()=>r(e),children:"Quick view"})}):null]}),s.jsxs("div",{className:L("flex flex-1 flex-col",a==="compact"?"p-3":"p-4"),children:[s.jsx("div",{className:"flex items-start justify-between gap-3",children:s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:L("line-clamp-1 font-medium text-neutral-950 dark:text-neutral-50",a==="compact"?"text-xs":"text-sm"),children:e.title}),s.jsx("div",{className:"mt-1",children:s.jsx(Zs,{amount:e.price,currency:e.currency,compareAt:e.compareAtPrice,size:a==="compact"?"sm":"default"})})]})}),a==="large"&&s.jsx("p",{className:"mt-2 line-clamp-2 min-h-8 text-xs leading-4 text-neutral-600 dark:text-neutral-400",children:e.description}),s.jsx("div",{className:L("mt-auto",a==="compact"?"pt-3":"pt-4"),children:s.jsx(ne,{type:"button",className:"w-full",size:a==="compact"?"sm":"default",onClick:()=>n?.(e,null),disabled:c,children:c?"Out of stock":"Add to cart"})})]})]})}function qs({products:e,columns:t,onAddToCart:n,onQuickView:r,getProductHref:o,className:a,layout:i,imageCrop:c}){const l=t?.base??2,d=t?.md??3,f=t?.lg??3,u={1:"grid-cols-1",2:"grid-cols-2",3:"grid-cols-3",4:"grid-cols-4"},h={1:"md:grid-cols-1",2:"md:grid-cols-2",3:"md:grid-cols-3",4:"md:grid-cols-4"},g={1:"lg:grid-cols-1",2:"lg:grid-cols-2",3:"lg:grid-cols-3",4:"lg:grid-cols-4"},y=L("grid gap-4",u[Math.min(4,Math.max(1,l))],h[Math.min(4,Math.max(1,d))],g[Math.min(4,Math.max(1,f))]);return s.jsx("div",{className:L(y,a),children:e.map(x=>s.jsx(kf,{product:x,href:o?o(x):void 0,onAddToCart:n,onQuickView:r,layout:i,imageCrop:c},x.id))})}function Ua({images:e,className:t}){const[n,r]=m.useState(0),o=e[n];return e.length===0?s.jsx("div",{className:L("aspect-square w-full rounded-xl border border-neutral-200 bg-neutral-100 dark:border-neutral-800 dark:bg-neutral-900",t)}):s.jsxs("div",{className:L("space-y-3",t),children:[s.jsx("div",{className:"aspect-square overflow-hidden rounded-2xl border border-neutral-200 bg-neutral-100 dark:border-neutral-800 dark:bg-neutral-900",children:s.jsx("img",{src:o?.url,alt:o?.alt??"",className:"h-full w-full object-cover",loading:"eager"})}),e.length>1?s.jsx("div",{className:"flex gap-2 overflow-x-auto pb-1",children:e.map((a,i)=>{const c=i===n;return s.jsx("button",{type:"button",className:L("h-16 w-16 shrink-0 overflow-hidden rounded-lg border",c?"border-neutral-900 dark:border-neutral-50":"border-neutral-200 dark:border-neutral-800"),onClick:()=>r(i),"aria-label":`View image ${i+1}`,children:s.jsx("img",{src:a.url,alt:a.alt??"",className:"h-full w-full object-cover",loading:"lazy"})},a.url)})}):null]})}function dj(e){const t=new Set;for(const n of e)for(const r of Object.keys(n.options))t.add(r);return Array.from(t)}function uj(e,t){const n=new Set;for(const r of e){const o=r.options[t];o&&n.add(o)}return Array.from(n)}function Ac(e,t){return e.find(n=>Object.entries(t).every(([r,o])=>n.options[r]===o))??null}function jf(e){return e.inventoryStatus==="out_of_stock"||typeof e.inventoryQuantity=="number"&&e.inventoryQuantity<=0}function fj(e){return e.inventoryStatus==="low"||typeof e.inventoryQuantity=="number"&&e.inventoryQuantity>0&&e.inventoryQuantity<=5}function mj(e){const t=jf(e),n=!t&&fj(e),r=typeof e.inventoryQuantity=="number"?e.inventoryQuantity:void 0;return{isOutOfStock:t,isLow:n,quantity:r}}function pj(e,t,n,r){const o={...t,[n]:r},a=e.filter(i=>Object.entries(o).every(([c,l])=>i.options[c]===l));return a.length===0?!1:a.some(i=>!jf(i))}function Ba({product:e,value:t,onChange:n,className:r,showInventory:o=!0,disableOutOfStock:a=!1}){const i=m.useMemo(()=>e.variants??[],[e.variants]),c=m.useMemo(()=>dj(i),[i]),l=m.useMemo(()=>Ac(i,t.selectedOptions),[i,t.selectedOptions]),d=m.useMemo(()=>l?mj(l):null,[l]);return i.length===0||c.length===0?null:s.jsxs("div",{className:L("space-y-4",r),children:[c.map(f=>{const u=uj(i,f),h=t.selectedOptions[f];return s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-baseline justify-between",children:[s.jsx("div",{className:"text-sm font-medium text-neutral-950 dark:text-neutral-50",children:f}),s.jsx("div",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:h||"Select"})]}),s.jsx("div",{className:"flex flex-wrap gap-2",children:u.map(g=>{const y=g===h,x=pj(i,t.selectedOptions,f,g),p=a&&!x;return s.jsxs(ne,{type:"button",size:"sm",variant:y?"default":"outline",onClick:()=>{const v={...t.selectedOptions,[f]:g},_=Ac(i,v);n({selectedOptions:v,variant:_})},"aria-pressed":y,disabled:p,className:L(!x&&!p&&"opacity-50 line-through"),children:[g,!x&&!p&&s.jsx("span",{className:"ml-1 text-[10px] opacity-70",children:"(Out)"})]},g)})})]},f)}),o&&l&&d&&s.jsx("div",{className:"pt-2",children:d.isOutOfStock?s.jsx("div",{className:"text-sm font-medium text-red-600 dark:text-red-400",children:"Out of stock"}):d.isLow&&d.quantity!==void 0?s.jsxs("div",{className:"text-sm text-amber-600 dark:text-amber-400",children:["Only ",s.jsx("span",{className:"font-semibold",children:d.quantity})," left"]}):null})]})}function Va({qty:e,onChange:t,min:n=1,max:r,className:o}){const a=Number.isFinite(e)?Math.max(n,Math.floor(e)):n,i=a>n,c=typeof r=="number"?a<r:!0;return s.jsxs("div",{className:L("flex items-center gap-2",o),children:[s.jsx(ne,{type:"button",size:"icon",variant:"outline",onClick:()=>t(Math.max(n,a-1)),disabled:!i,"aria-label":"Decrease quantity",children:"-"}),s.jsx(Fe,{inputMode:"numeric",pattern:"[0-9]*",value:String(a),onChange:l=>{const d=Math.floor(Number(l.target.value));if(!Number.isFinite(d))return;const f=Math.max(n,typeof r=="number"?Math.min(r,d):d);t(f)},className:"h-10 w-16 text-center","aria-label":"Quantity"}),s.jsx(ne,{type:"button",size:"icon",variant:"outline",onClick:()=>t(a+1),disabled:!c,"aria-label":"Increase quantity",children:"+"})]})}function Wa({product:e,open:t,onOpenChange:n,productHref:r,onAddToCart:o,className:a}){const[i,c]=m.useState(1),[l,d]=m.useState({selectedOptions:{},variant:null});if(m.useEffect(()=>{if(e)if(c(1),e.variants?.length){const x=e.variants[0];d({selectedOptions:{...x.options},variant:x})}else d({selectedOptions:{},variant:null})},[e?.id]),!e)return null;const f=l.variant?.price??e.price,u=l.variant?.compareAtPrice??e.compareAtPrice,h=l.variant?.inventoryStatus==="out_of_stock"||typeof l.variant?.inventoryQuantity=="number"&&l.variant.inventoryQuantity<=0,g=e.inventoryStatus==="out_of_stock"||typeof e.inventoryQuantity=="number"&&e.inventoryQuantity<=0,y=l.variant?h:g;return s.jsx(Na,{open:t,onOpenChange:n,children:s.jsxs(Os,{className:L("max-w-3xl",a),children:[s.jsx(Ea,{children:s.jsxs(Ms,{className:"flex items-center justify-between gap-3",children:[s.jsx("span",{className:"truncate",children:e.title}),r?s.jsx("a",{href:r(e.slug),className:"text-sm font-normal text-neutral-700 hover:underline dark:text-neutral-300",children:"View details"}):null]})}),s.jsxs("div",{className:"grid gap-8 md:grid-cols-2",children:[s.jsx(Ua,{images:e.images}),s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{children:[s.jsx(Zs,{amount:f,currency:e.currency,compareAt:u}),s.jsx("p",{className:"mt-3 text-sm text-neutral-600 dark:text-neutral-400",children:e.description})]}),s.jsx(Ba,{product:e,value:{selectedOptions:l.selectedOptions,variantId:l.variant?.id},onChange:x=>d(x)}),s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[s.jsx(Va,{qty:i,onChange:c}),s.jsx(ne,{type:"button",className:"flex-1",disabled:y,onClick:()=>{o(e,l.variant,i),n(!1)},children:y?"Out of stock":"Add to cart"})]}),s.jsx("div",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:y?"Out of stock":"In stock"})]})]})]})})}function Wo({categories:e,activeSlug:t,onSelect:n,className:r}){return s.jsx("nav",{className:L("space-y-1",r),"aria-label":"Categories",children:e.map(o=>{const a=t===o.slug;return s.jsxs("button",{type:"button",className:L("flex w-full items-center justify-between rounded-md px-3 py-2 text-sm transition-colors",a?"bg-neutral-900 text-neutral-50 dark:bg-neutral-50 dark:text-neutral-900":"text-neutral-700 hover:bg-neutral-100 dark:text-neutral-300 dark:hover:bg-neutral-800"),onClick:()=>n?.(o),"aria-current":a?"page":void 0,children:[s.jsx("span",{className:"truncate",children:o.name}),s.jsx("span",{className:"text-xs opacity-70",children:"›"})]},o.id)})})}function Ha({items:e,className:t}){return s.jsx("nav",{className:L("flex items-center gap-2 text-xs text-neutral-600 dark:text-neutral-400",t),"aria-label":"Breadcrumb",children:e.map((n,r)=>s.jsxs("span",{className:"flex items-center gap-2",children:[n.href?s.jsx("a",{href:n.href,className:"hover:underline",children:n.label}):s.jsx("span",{className:"text-neutral-900 dark:text-neutral-50",children:n.label}),r<e.length-1?s.jsx("span",{"aria-hidden":!0,children:"·"}):null]},`${n.label}-${r}`))})}function Za({value:e,onChange:t,placeholder:n="Search products…",className:r}){return s.jsxs("div",{className:L("relative",r),children:[s.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-3 flex items-center text-neutral-500 dark:text-neutral-400","aria-hidden":!0,children:"⌕"}),s.jsx(Fe,{value:e,onChange:o=>t(o.target.value),placeholder:n,className:"pl-9","aria-label":"Search"})]})}function ms({facets:e,value:t,onChange:n,onClear:r,className:o,enabledFilters:a}){const i=e.tags??[],c=new Set(t.tags??[]),l=a?.tags??!0,d=a?.priceRange??!0,f=a?.inStock??!0;return l||d||f?s.jsxs("div",{className:L("space-y-4",o),children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("div",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:"Filters"}),s.jsx(ne,{type:"button",variant:"ghost",className:"h-8 px-2 text-xs",onClick:r,children:"Clear"})]}),s.jsx(yt,{}),l&&i.length?s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"text-sm font-medium",children:"Tags"}),s.jsx("div",{className:"space-y-2",children:i.map(h=>s.jsxs("label",{className:"flex cursor-pointer items-center gap-2 text-sm text-neutral-700 dark:text-neutral-300",children:[s.jsx("input",{type:"checkbox",checked:c.has(h),onChange:g=>{const y=new Set(c);g.target.checked?y.add(h):y.delete(h),n({...t,tags:Array.from(y)})}}),h]},h))})]}):null,d&&e.price?s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"text-sm font-medium",children:"Price"}),s.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[s.jsxs("div",{className:"grid gap-1",children:[s.jsx(st,{className:"text-xs",htmlFor:"price-min",children:"Min"}),s.jsx(Fe,{id:"price-min",inputMode:"decimal",placeholder:String(e.price.min),value:t.priceMin??"",onChange:h=>{const g=Number(h.target.value);n({...t,priceMin:Number.isFinite(g)&&h.target.value!==""?g:void 0})}})]}),s.jsxs("div",{className:"grid gap-1",children:[s.jsx(st,{className:"text-xs",htmlFor:"price-max",children:"Max"}),s.jsx(Fe,{id:"price-max",inputMode:"decimal",placeholder:String(e.price.max),value:t.priceMax??"",onChange:h=>{const g=Number(h.target.value);n({...t,priceMax:Number.isFinite(g)&&h.target.value!==""?g:void 0})}})]})]})]}):null,f?s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"text-sm font-medium",children:"Availability"}),s.jsxs("label",{className:"flex cursor-pointer items-center gap-2 text-sm text-neutral-700 dark:text-neutral-300",children:[s.jsx("input",{type:"checkbox",checked:t.inStock??!1,onChange:h=>n({...t,inStock:h.target.checked})}),"In stock"]})]}):null]}):null}function Ec(e){return s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),s.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]})}function hj(e){return s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[s.jsx("path",{d:"M3 6h18"}),s.jsx("path",{d:"M8 6V4h8v2"}),s.jsx("path",{d:"M6 6l1 16h10l1-16"}),s.jsx("path",{d:"M10 11v6"}),s.jsx("path",{d:"M14 11v6"})]})}function qa({item:e,onRemove:t,onSetQty:n,variant:r="table",className:o,inventory:a}){const i=e.unitPrice*e.qty,[c,l]=m.useState(!1),d=m.useMemo(()=>{if(a?.availableQty)return a.availableQty},[a?.availableQty]),f=!a?.isOutOfStock&&(d===void 0||e.qty<d),u=m.useMemo(()=>a?a.isOutOfStock?{type:"error",message:a.message||"Out of stock"}:a.exceedsAvailable?{type:"warning",message:a.message||"Quantity exceeds available stock"}:a.isLowStock?{type:"info",message:a.message||"Low stock"}:null:null,[a]);return m.useEffect(()=>{c&&e.qty!==1&&l(!1)},[c,e.qty]),r==="compact"?s.jsxs("div",{className:L("flex items-start gap-3",o),children:[s.jsx("div",{className:"h-12 w-12 shrink-0 overflow-hidden rounded-lg border border-neutral-200 bg-neutral-100 dark:border-neutral-800 dark:bg-neutral-900",children:e.imageSnapshot?s.jsx("img",{src:e.imageSnapshot,alt:e.titleSnapshot,className:"h-full w-full object-cover"}):null}),s.jsx("div",{className:"min-w-0 flex-1",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"truncate text-sm font-medium text-neutral-950 dark:text-neutral-50",children:e.titleSnapshot}),s.jsx("div",{className:"mt-0.5 text-xs tabular-nums text-neutral-600 dark:text-neutral-400",children:Be({amount:i,currency:e.currency})}),u&&s.jsxs("div",{className:L("mt-1 flex items-center gap-1 text-[11px]",u.type==="error"&&"text-red-600 dark:text-red-400",u.type==="warning"&&"text-amber-600 dark:text-amber-400",u.type==="info"&&"text-blue-600 dark:text-blue-400"),children:[s.jsx(Ec,{className:"h-3 w-3 shrink-0"}),s.jsx("span",{children:u.message})]})]}),s.jsx("div",{className:"flex h-12 w-[140px] shrink-0 items-center justify-end",children:c?s.jsxs("div",{className:"flex w-full flex-col items-center justify-center gap-2",children:[s.jsx("div",{className:"text-center text-[11px] font-medium leading-none text-neutral-600 dark:text-neutral-400",children:"Remove item?"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ne,{type:"button",variant:"outline",className:"h-7 w-[62px] px-0 text-[11px] leading-none",onClick:()=>l(!1),children:"Cancel"}),s.jsx(ne,{type:"button",variant:"destructive",className:"h-7 w-[62px] px-0 text-[11px] leading-none",onClick:t,children:"Confirm"})]})]}):s.jsxs("div",{className:"flex items-center justify-end gap-1.5 whitespace-nowrap",children:[s.jsx(ne,{type:"button",size:"icon",variant:"outline",className:"h-8 w-8","aria-label":e.qty===1?"Remove item":"Decrease quantity",onClick:()=>{if(e.qty===1){l(!0);return}n(e.qty-1)},children:e.qty===1?s.jsx(hj,{className:"h-4 w-4"}):"-"}),s.jsx(Fe,{inputMode:"numeric",pattern:"[0-9]*",value:String(e.qty),onChange:h=>{const g=Math.floor(Number(h.target.value));if(!Number.isFinite(g))return;const y=Math.max(1,d?Math.min(d,g):g);n(y)},className:"h-8 w-11 px-2 text-center","aria-label":"Quantity"}),s.jsx(ne,{type:"button",size:"icon",variant:"outline",className:"h-8 w-8","aria-label":"Increase quantity",onClick:()=>n(d?Math.min(d,e.qty+1):e.qty+1),disabled:!f,children:"+"})]})})]})})]}):s.jsxs("div",{className:L("grid grid-cols-[64px_1fr] items-start gap-x-4 gap-y-3 sm:grid-cols-[64px_1fr_176px_120px]",o),children:[s.jsx("div",{className:"h-16 w-16 overflow-hidden rounded-lg border border-neutral-200 bg-neutral-100 dark:border-neutral-800 dark:bg-neutral-900",children:e.imageSnapshot?s.jsx("img",{src:e.imageSnapshot,alt:e.titleSnapshot,className:"h-full w-full object-cover"}):null}),s.jsxs("div",{className:"col-start-2 row-start-1 min-w-0",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsx("div",{className:"truncate text-sm font-medium text-neutral-950 dark:text-neutral-50",children:e.titleSnapshot}),s.jsx("div",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50 sm:hidden",children:Be({amount:i,currency:e.currency})})]}),s.jsxs("div",{className:"mt-1 text-xs text-neutral-600 dark:text-neutral-400",children:[Be({amount:e.unitPrice,currency:e.currency})," each"]}),u&&s.jsxs("div",{className:L("mt-1.5 flex items-center gap-1 text-xs",u.type==="error"&&"text-red-600 dark:text-red-400",u.type==="warning"&&"text-amber-600 dark:text-amber-400",u.type==="info"&&"text-blue-600 dark:text-blue-400"),children:[s.jsx(Ec,{className:"h-3.5 w-3.5 shrink-0"}),s.jsx("span",{children:u.message})]})]}),s.jsxs("div",{className:"col-span-2 col-start-1 row-start-2 flex items-center justify-between gap-3 sm:col-span-1 sm:col-start-3 sm:row-start-1 sm:justify-center",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ne,{type:"button",size:"icon",variant:"outline",className:"h-9 w-9","aria-label":"Decrease quantity",onClick:()=>n(Math.max(1,e.qty-1)),children:"-"}),s.jsx(Fe,{inputMode:"numeric",pattern:"[0-9]*",value:String(e.qty),onChange:h=>{const g=Math.floor(Number(h.target.value));if(!Number.isFinite(g))return;const y=Math.max(1,d?Math.min(d,g):g);n(y)},className:"h-9 w-14 text-center","aria-label":"Quantity"}),s.jsx(ne,{type:"button",size:"icon",variant:"outline",className:"h-9 w-9","aria-label":"Increase quantity",onClick:()=>n(d?Math.min(d,e.qty+1):e.qty+1),disabled:!f,children:"+"})]}),s.jsx(ne,{type:"button",variant:"ghost",className:"h-9 px-2 text-xs text-red-600 dark:text-red-400 sm:hidden",onClick:t,children:"Remove"})]}),s.jsxs("div",{className:"hidden sm:col-start-4 sm:row-start-1 sm:flex sm:flex-col sm:items-center sm:text-center",children:[s.jsx("div",{className:"text-sm font-semibold tabular-nums text-neutral-950 dark:text-neutral-50",children:Be({amount:i,currency:e.currency})}),s.jsx(ne,{type:"button",variant:"ghost",className:"mt-1 h-8 px-2 text-xs text-red-600 dark:text-red-400",onClick:t,children:"Remove"})]})]})}function Ga({currency:e,subtotal:t,itemCount:n,onCheckout:r,isCheckoutDisabled:o,checkoutDisabledReason:a,onRemoveUnavailable:i,className:c}){return s.jsxs("div",{className:L("space-y-4",c),children:[s.jsx(yt,{}),s.jsxs("div",{className:"flex items-center justify-between text-sm",children:[s.jsxs("div",{className:"flex items-center gap-2 text-neutral-600 dark:text-neutral-400",children:[s.jsx("span",{children:"Subtotal"}),typeof n=="number"?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-neutral-300 dark:text-neutral-700",children:"·"}),s.jsxs("span",{className:"tabular-nums",children:[n," item",n===1?"":"s"]})]}):null]}),s.jsx("span",{className:"font-semibold text-neutral-950 dark:text-neutral-50",children:Be({amount:t,currency:e})})]}),s.jsx(ne,{type:"button",onClick:r,disabled:o,className:"w-full",children:"Checkout"}),o&&a&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-center text-xs text-amber-600 dark:text-amber-400",children:a}),i&&s.jsx("button",{type:"button",onClick:i,className:"mx-auto block text-xs text-neutral-500 underline underline-offset-2 hover:text-neutral-700 dark:text-neutral-400 dark:hover:text-neutral-300",children:"Remove unavailable items"})]})]})}function Sf({onCheckout:e,className:t}){const{config:n}=Ee(),r=Pt(),{getItemInventory:o,hasIssues:a}=ia({items:r.items,refreshInterval:3e4,skip:r.items.length===0}),i=()=>{for(const c of r.items){const l=o(c.productId,c.variantId);(l?.isOutOfStock||l?.exceedsAvailable)&&r.removeItem(c.productId,c.variantId)}};return r.items.length===0?s.jsx(Bn,{title:"Cart is empty",description:"Add items from the catalog to check out.",className:t}):s.jsxs("div",{className:L("flex h-full flex-col rounded-xl border border-neutral-200 bg-white p-4 dark:border-neutral-800 dark:bg-neutral-950",t),children:[s.jsx("div",{className:"-mr-4 min-h-0 flex-1 overflow-y-auto overflow-x-hidden pr-4",children:s.jsx("div",{className:"divide-y divide-neutral-200 dark:divide-neutral-800",children:r.items.map(c=>s.jsx("div",{className:"py-3",children:s.jsx(qa,{variant:"compact",item:c,onRemove:()=>r.removeItem(c.productId,c.variantId),onSetQty:l=>r.setQty(c.productId,c.variantId,l),inventory:o(c.productId,c.variantId)})},`${c.productId}::${c.variantId??""}`))})}),s.jsx("div",{className:"mt-4 space-y-4",children:s.jsx(Ga,{currency:n.currency,subtotal:r.subtotal,itemCount:r.count,onCheckout:e,isCheckoutDisabled:r.items.length===0||a,checkoutDisabledReason:a?"Some items have inventory issues":void 0,onRemoveUnavailable:a?i:void 0})})]})}const Cf=m.forwardRef(({className:e,...t},n)=>s.jsx("textarea",{ref:n,className:L("flex min-h-10 w-full rounded-md border border-neutral-200 bg-white px-3 py-2 text-sm text-neutral-950 shadow-sm transition-colors placeholder:text-neutral-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-900/20 disabled:cursor-not-allowed disabled:opacity-50 dark:border-neutral-800 dark:bg-neutral-950 dark:text-neutral-50 dark:placeholder:text-neutral-400 dark:focus-visible:ring-neutral-50/20",e),...t}));Cf.displayName="Textarea";function gj(){const[e,t]=m.useState(!1);return m.useEffect(()=>{const n=window.matchMedia?.("(prefers-reduced-motion: reduce)");if(!n)return;const r=()=>t(n.matches);return r(),n.addEventListener?.("change",r),()=>n.removeEventListener?.("change",r)},[]),e}function Ic({children:e,className:t}){const n=m.useRef(null),r=gj();return m.useEffect(()=>{const o=n.current;!o||r||o.animate([{opacity:0,transform:"translateY(6px)"},{opacity:1,transform:"translateY(0px)"}],{duration:180,easing:"cubic-bezier(0.2, 0.8, 0.2, 1)",fill:"both"})},[r]),s.jsx("div",{ref:n,className:t,children:e})}function wo(){return`${Date.now()}_${Math.random().toString(16).slice(2)}`}function Nf({className:e}){m.useEffect(()=>{console.warn("[ShopChatPanel] This component is experimental and has no backend configured. Messages are handled locally and will not be sent to any server.")},[]);const[t,n]=m.useState(""),[r,o]=m.useState(!1),[a,i]=m.useState(()=>[{id:wo(),role:"agent",text:"Hi! How can we help today? We can recommend products or answer support questions.",createdAt:Date.now()}]),[c,l]=m.useState("…");m.useEffect(()=>{if(!r)return;const g=[".","..","..."];let y=0;const x=window.setInterval(()=>{y=(y+1)%g.length,l(g[y])},450);return()=>window.clearInterval(x)},[r]);const d=m.useRef(null),f=m.useRef(null);m.useEffect(()=>{const g=d.current;g&&(g.scrollTop=g.scrollHeight)},[a.length]);const u=m.useCallback(()=>{const g=f.current;if(!g)return;const y=120;g.style.height="0px";const x=Math.min(y,Math.max(40,g.scrollHeight));g.style.height=`${x}px`,g.style.overflowY=g.scrollHeight>y?"auto":"hidden"},[]);m.useEffect(()=>{u()},[t,u]);const h=m.useCallback(()=>{const g=t.trim();g&&(i(y=>[...y,{id:wo(),role:"user",text:g,createdAt:Date.now()}]),n(""),o(!0),window.setTimeout(()=>{i(y=>[...y,{id:wo(),role:"agent",text:"Got it. Want recommendations, sizing help, or help with an order?",createdAt:Date.now()}]),o(!1)},450))},[t]);return s.jsxs("div",{className:L("flex h-full min-h-0 flex-col",e),children:[s.jsxs("div",{ref:d,className:"min-h-0 flex-1 space-y-3 overflow-y-auto overscroll-contain rounded-2xl border border-neutral-200 bg-white p-4 dark:border-neutral-800 dark:bg-neutral-950",children:[a.map(g=>s.jsx(Ic,{className:L("flex",g.role==="user"?"justify-end":"justify-start"),children:s.jsx("div",{className:L("max-w-[85%] rounded-2xl px-3 py-2 text-sm leading-5",g.role==="user"?"bg-neutral-900 text-neutral-50 dark:bg-neutral-50 dark:text-neutral-900":"bg-neutral-100 text-neutral-900 dark:bg-neutral-800 dark:text-neutral-50"),children:s.jsx("span",{className:"whitespace-pre-wrap break-words",children:g.text})})},g.id)),r?s.jsx(Ic,{className:"flex justify-start",children:s.jsx("div",{className:"max-w-[85%] rounded-2xl bg-neutral-100 px-3 py-2 text-sm leading-5 text-neutral-900 dark:bg-neutral-800 dark:text-neutral-50",children:c})}):null]}),s.jsxs("div",{className:"mt-3 flex shrink-0 items-end gap-2",children:[s.jsx(Cf,{ref:f,rows:1,value:t,onChange:g=>n(g.target.value),placeholder:"Type a message…",className:"max-h-[120px] resize-none",onKeyDown:g=>{g.key==="Enter"&&(g.shiftKey||(g.preventDefault(),h()))}}),s.jsx(ne,{type:"button",onClick:h,disabled:!t.trim(),className:"h-10 shrink-0",children:"Send"})]})]})}function kr({trigger:e,side:t="right",open:n,onOpenChange:r,onCheckout:o,preferredTab:a,className:i}){const[c,l]=m.useState(a??"cart");return m.useEffect(()=>{n&&l(a??"cart")},[n,a]),s.jsxs(Ls,{modal:!1,open:n,onOpenChange:r,children:[e?s.jsx(Ds,{asChild:!0,children:e}):null,s.jsxs(Nr,{side:t,overlayClassName:t==="popup"?"pointer-events-none bg-transparent backdrop-blur-none":"pointer-events-none bg-neutral-950/40 backdrop-blur-none",className:L(t==="bottom"?"h-[85vh] rounded-t-2xl":void 0,t==="popup"?"shadow-xl":"w-full sm:max-w-md",t==="popup"?"h-[min(640px,calc(100vh-2rem))]":void 0,t==="popup"?void 0:"p-4","flex flex-col overflow-hidden",i),children:[s.jsx($s,{className:"space-y-0",children:s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsx(za,{value:c,onValueChange:d=>l(d),children:s.jsxs(Ws,{className:"h-9",children:[s.jsx(_r,{value:"cart",className:"text-sm",children:"Cart"}),s.jsx(_r,{value:"chat",className:"text-sm",children:"Chat"})]})}),s.jsx(Au,{asChild:!0,children:s.jsx(ne,{type:"button",size:"icon",variant:"ghost",className:"h-9 w-9 rounded-full text-lg leading-none","aria-label":"Close cart",children:"X"})})]})}),s.jsx("div",{className:"mt-3 min-h-0 flex-1 overflow-hidden",children:c==="chat"?s.jsxs("div",{className:"flex h-full flex-col",children:[s.jsx("div",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:"Get help finding a product or ask us any questions. We’re both your shopping assistant and support chat."}),s.jsx("div",{className:"mt-3 min-h-0 flex-1",children:s.jsx(Nf,{className:"h-full"})})]}):s.jsx(Sf,{onCheckout:()=>{o(),r?.(!1)},className:"h-full border-0 bg-transparent p-0 shadow-none"})})]})]})}function Ya({value:e,onApply:t,className:n}){const[r,o]=m.useState(e??"");return m.useEffect(()=>{o(e??"")},[e]),s.jsxs("div",{className:L("space-y-2",n),children:[s.jsx("div",{className:"text-sm font-medium text-neutral-950 dark:text-neutral-50",children:"Promo code"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Fe,{value:r,onChange:a=>o(a.target.value),placeholder:"SAVE10","aria-label":"Promo code"}),s.jsx(ne,{type:"button",variant:"outline",onClick:()=>t(r.trim()||void 0),children:"Apply"})]})]})}function Af({onCheckout:e,showPromoCode:t,className:n}){const{config:r}=Ee(),o=Pt(),{getItemInventory:a,hasIssues:i}=ia({items:o.items,refreshInterval:3e4,skip:o.items.length===0}),c=()=>{for(const l of o.items){const d=a(l.productId,l.variantId);(d?.isOutOfStock||d?.exceedsAvailable)&&o.removeItem(l.productId,l.variantId)}};return o.items.length===0?s.jsx(Bn,{title:"Your cart is empty",description:"Add a few products and come back here when you're ready to check out.",className:n}):s.jsxs("div",{className:L("grid items-start gap-6 lg:grid-cols-[1fr_360px]",n),children:[s.jsxs("div",{className:"self-start rounded-2xl border border-neutral-200 bg-white dark:border-neutral-800 dark:bg-neutral-950",children:[s.jsxs("div",{className:"hidden grid-cols-[64px_1fr_176px_120px] gap-x-4 px-5 py-3 text-xs font-medium text-neutral-500 dark:text-neutral-400 sm:grid",children:[s.jsx("div",{}),s.jsx("div",{children:"Item"}),s.jsx("div",{className:"text-center",children:"Qty"}),s.jsx("div",{className:"text-center",children:"Total"})]}),s.jsx("div",{className:"divide-y divide-neutral-200 dark:divide-neutral-800",children:o.items.map(l=>s.jsx("div",{className:"px-4 py-4 sm:px-5",children:s.jsx(qa,{item:l,onRemove:()=>o.removeItem(l.productId,l.variantId),onSetQty:d=>o.setQty(l.productId,l.variantId,d),inventory:a(l.productId,l.variantId)})},`${l.productId}::${l.variantId??""}`))})]}),s.jsx("div",{className:"lg:sticky lg:top-24 self-start",children:s.jsxs("div",{className:"rounded-2xl border border-neutral-200 bg-white p-5 shadow-sm dark:border-neutral-800 dark:bg-neutral-950",children:[s.jsx("div",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:"Summary"}),s.jsx(yt,{className:"my-4"}),s.jsxs("div",{className:"space-y-4",children:[t?s.jsx(Ya,{value:o.promoCode,onApply:o.setPromoCode}):null,s.jsx(Ga,{currency:r.currency,subtotal:o.subtotal,onCheckout:e,isCheckoutDisabled:o.items.length===0||i,checkoutDisabledReason:i?"Some items have inventory issues":void 0,onRemoveUnavailable:i?c:void 0})]})]})})]})}function Ef({left:e,right:t,className:n}){return s.jsxs("div",{className:L("grid items-start gap-8 lg:grid-cols-[1fr_420px]",n),children:[s.jsx("div",{children:e}),s.jsx("div",{children:t})]})}function Ho({title:e,value:t,onChange:n,errors:r,className:o}){return s.jsxs("section",{className:L("space-y-4 rounded-2xl border border-neutral-200 bg-white p-5 dark:border-neutral-800 dark:bg-neutral-950",o),children:[s.jsx("div",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:e}),s.jsxs("div",{className:"grid gap-3",children:[s.jsxs("div",{className:"grid gap-2",children:[s.jsx(st,{htmlFor:`${e}-line1`,children:"Address line 1"}),s.jsx(Fe,{id:`${e}-line1`,value:t.line1,onChange:a=>n({...t,line1:a.target.value}),"aria-invalid":!!r?.line1}),r?.line1?s.jsx("div",{className:"text-xs text-red-600",children:r.line1}):null]}),s.jsxs("div",{className:"grid gap-2",children:[s.jsx(st,{htmlFor:`${e}-line2`,children:"Address line 2"}),s.jsx(Fe,{id:`${e}-line2`,value:t.line2??"",onChange:a=>n({...t,line2:a.target.value})})]}),s.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"grid gap-2",children:[s.jsx(st,{htmlFor:`${e}-city`,children:"City"}),s.jsx(Fe,{id:`${e}-city`,value:t.city,onChange:a=>n({...t,city:a.target.value}),"aria-invalid":!!r?.city}),r?.city?s.jsx("div",{className:"text-xs text-red-600",children:r.city}):null]}),s.jsxs("div",{className:"grid gap-2",children:[s.jsx(st,{htmlFor:`${e}-state`,children:"State"}),s.jsx(Fe,{id:`${e}-state`,value:t.state??"",onChange:a=>n({...t,state:a.target.value})})]})]}),s.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"grid gap-2",children:[s.jsx(st,{htmlFor:`${e}-postal`,children:"Postal code"}),s.jsx(Fe,{id:`${e}-postal`,value:t.postalCode,onChange:a=>n({...t,postalCode:a.target.value}),"aria-invalid":!!r?.postalCode}),r?.postalCode?s.jsx("div",{className:"text-xs text-red-600",children:r.postalCode}):null]}),s.jsxs("div",{className:"grid gap-2",children:[s.jsx(st,{htmlFor:`${e}-country`,children:"Country"}),s.jsx(Fe,{id:`${e}-country`,value:t.country,onChange:a=>n({...t,country:a.target.value}),"aria-invalid":!!r?.country}),r?.country?s.jsx("div",{className:"text-xs text-red-600",children:r.country}):null]})]})]})]})}function If({methods:e,value:t,onChange:n,currency:r,className:o}){return e.length===0?null:s.jsxs("section",{className:L("space-y-4 rounded-2xl border border-neutral-200 bg-white p-5 dark:border-neutral-800 dark:bg-neutral-950",o),children:[s.jsx("div",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:"Shipping method"}),s.jsx("div",{className:"space-y-2",children:e.map(a=>{const i=a.id===t;return s.jsxs(ne,{type:"button",variant:i?"default":"outline",className:"h-auto w-full justify-between px-4 py-3",onClick:()=>n(a.id),"aria-pressed":i,children:[s.jsxs("div",{className:"text-left",children:[s.jsx("div",{className:"text-sm font-medium",children:a.label}),a.detail?s.jsx("div",{className:"text-xs opacity-80",children:a.detail}):null]}),s.jsx("div",{className:"text-sm font-semibold",children:Be({amount:a.price,currency:a.currency||r})})]},a.id)})})]})}function _o({message:e}){return e?s.jsx("div",{className:"text-xs text-red-600",children:e}):null}function Tf({className:e}){const{config:t}=Ee(),n=vs(),r=Pt(),o=t.checkout.mode,a=m.useMemo(()=>Zr(r.items,{requireEmail:t.checkout.requireEmail??!0,defaultMode:o,allowShipping:t.checkout.allowShipping??!1}),[r.items,t.checkout.allowShipping,t.checkout.requireEmail,o]),i=(t.checkout.allowShipping??!1)&&a.shippingAddress&&(o==="shipping"||o==="full"),c=a.email!=="none"||a.name!=="none"||a.phone!=="none",l={line1:"",line2:"",city:"",state:"",postalCode:"",country:"US"},d=n.values.shippingAddress??l,f=n.values.billingAddress??l,u=Nl({enabled:!!t.adapter.getShippingMethods&&i,customer:{email:n.values.email||void 0,name:n.values.name||void 0,shippingAddress:d}});return s.jsxs("form",{className:L("space-y-6",e),onSubmit:h=>h.preventDefault(),children:[a.isDigitalOnly?s.jsx(Et,{className:"rounded-2xl",children:s.jsxs(Vt,{className:"p-5",children:[s.jsx("div",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:"Digital delivery"}),s.jsx("div",{className:"mt-1 text-sm text-neutral-600 dark:text-neutral-400",children:a.fulfillmentNotes||"This is a digital product and will be available from your account after purchase."})]})}):null,a.hasPhysical&&!(t.checkout.allowShipping??!1)?s.jsx(Et,{className:"rounded-2xl border-red-200 bg-red-50 dark:border-red-900/40 dark:bg-red-950/30",children:s.jsxs(Vt,{className:"p-5",children:[s.jsx("div",{className:"text-sm font-semibold text-red-900 dark:text-red-200",children:"Shipping required"}),s.jsx("div",{className:"mt-1 text-sm text-red-800/90 dark:text-red-200/80",children:"Your cart contains shippable items, but shipping is disabled for this checkout."})]})}):null,c?s.jsxs("section",{className:"space-y-4 rounded-2xl border border-neutral-200 bg-white p-5 dark:border-neutral-800 dark:bg-neutral-950",children:[s.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[s.jsx("div",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:"Contact"}),s.jsx("div",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:a.email==="required"||a.name==="required"||a.phone==="required"?"Required":"Optional"})]}),s.jsxs("div",{className:"grid gap-3",children:[a.email!=="none"?s.jsxs("div",{className:"grid gap-2",children:[s.jsx(st,{htmlFor:"checkout-email",children:"Email"}),s.jsx(Fe,{id:"checkout-email",value:n.values.email??"",onChange:h=>n.setField("email",h.target.value),placeholder:"you@company.com","aria-invalid":!!n.fieldErrors.email,required:a.email==="required"}),s.jsx(_o,{message:n.fieldErrors.email})]}):null,a.name!=="none"?s.jsxs("div",{className:"grid gap-2",children:[s.jsx(st,{htmlFor:"checkout-name",children:"Name"}),s.jsx(Fe,{id:"checkout-name",value:n.values.name??"",onChange:h=>n.setField("name",h.target.value),placeholder:"Full name","aria-invalid":!!n.fieldErrors.name,required:a.name==="required"}),s.jsx(_o,{message:n.fieldErrors.name})]}):null,a.phone!=="none"?s.jsxs("div",{className:"grid gap-2",children:[s.jsx(st,{htmlFor:"checkout-phone",children:"Phone"}),s.jsx(Fe,{id:"checkout-phone",value:n.values.phone??"",onChange:h=>n.setField("phone",h.target.value),placeholder:"Phone number","aria-invalid":!!n.fieldErrors.phone,required:a.phone==="required"}),s.jsx(_o,{message:n.fieldErrors.phone})]}):null]})]}):null,i?s.jsx(Ho,{title:"Shipping address",value:d,onChange:h=>n.setField("shippingAddress",h),errors:{line1:n.fieldErrors["shippingAddress.line1"],city:n.fieldErrors["shippingAddress.city"],postalCode:n.fieldErrors["shippingAddress.postalCode"],country:n.fieldErrors["shippingAddress.country"]}}):null,i&&u.methods.length?s.jsx(If,{methods:u.methods,value:n.values.shippingMethodId,onChange:h=>n.setField("shippingMethodId",h),currency:t.currency}):null,o==="full"?s.jsx(Ho,{title:"Billing address",value:f,onChange:h=>n.setField("billingAddress",h)}):null,t.checkout.allowTipping?s.jsxs("section",{className:"space-y-4 rounded-2xl border border-neutral-200 bg-white p-5 dark:border-neutral-800 dark:bg-neutral-950",children:[s.jsx("div",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:"Tip"}),s.jsxs("div",{className:"grid gap-2",children:[s.jsxs(st,{htmlFor:"checkout-tip",children:["Tip amount (",t.currency,")"]}),s.jsx(Fe,{id:"checkout-tip",inputMode:"decimal",value:String(n.values.tipAmount??0),onChange:h=>n.setField("tipAmount",Number(h.target.value)||0)})]})]}):null,o==="full"?s.jsxs("section",{className:"space-y-4 rounded-2xl border border-neutral-200 bg-white p-5 dark:border-neutral-800 dark:bg-neutral-950",children:[s.jsx("div",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:"Notes"}),s.jsxs("div",{className:"grid gap-2",children:[s.jsx(st,{htmlFor:"checkout-notes",children:"Order notes (optional)"}),s.jsx(Fe,{id:"checkout-notes",value:n.values.notes??"",onChange:h=>n.setField("notes",h.target.value),placeholder:"Delivery instructions, gift note…"})]})]}):null]})}function xj(e){return s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),s.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]})}function vj(e){return s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[s.jsx("path",{d:"M3 6h18"}),s.jsx("path",{d:"M8 6V4h8v2"}),s.jsx("path",{d:"M6 6l1 16h10l1-16"})]})}function Pf({open:e,onOpenChange:t,issues:n,onRemoveItem:r,onUpdateQuantity:o,onGoToCart:a,className:i}){const c=n.some(l=>l.type==="out_of_stock"||l.type==="product_unavailable");return s.jsx(Na,{open:e,onOpenChange:t,children:s.jsxs(Os,{className:L("sm:max-w-lg",i),children:[s.jsxs(Ea,{children:[s.jsxs(Ms,{className:"flex items-center gap-2",children:[s.jsx(xj,{className:"h-5 w-5 text-amber-500"}),"Inventory Update"]}),s.jsx(Ia,{children:c?"Some items in your cart are no longer available.":"Some items in your cart have limited availability."})]}),s.jsx("div",{className:"my-4 divide-y divide-neutral-200 dark:divide-neutral-800",children:n.map(l=>s.jsx(yj,{issue:l,onRemove:()=>r(l.productId,l.variantId),onUpdateQty:d=>o(l.productId,l.variantId,d)},`${l.productId}::${l.variantId??""}`))}),s.jsxs(Nu,{className:"flex-col gap-2 sm:flex-row",children:[a?s.jsx(ne,{type:"button",variant:"outline",onClick:()=>{t(!1),a()},children:"Go to Cart"}):null,s.jsx(ne,{type:"button",onClick:()=>t(!1),children:"Continue"})]})]})})}function yj({issue:e,onRemove:t,onUpdateQty:n}){const r=e.type==="out_of_stock"||e.type==="product_unavailable";return s.jsxs("div",{className:"flex items-start gap-3 py-3",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"text-sm font-medium text-neutral-900 dark:text-neutral-100",children:e.title}),s.jsx("div",{className:L("mt-0.5 text-sm",r?"text-red-600 dark:text-red-400":"text-amber-600 dark:text-amber-400"),children:e.message}),e.type==="insufficient_stock"&&e.availableQty>0?s.jsxs("div",{className:"mt-1 text-xs text-neutral-500 dark:text-neutral-400",children:["You requested ",e.requestedQty,", but only ",e.availableQty," available"]}):null]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.type==="insufficient_stock"&&e.availableQty>0?s.jsxs(ne,{type:"button",size:"sm",variant:"outline",onClick:()=>n(e.availableQty),children:["Update to ",e.availableQty]}):null,s.jsxs(ne,{type:"button",size:"sm",variant:"ghost",className:"text-red-600 hover:bg-red-50 hover:text-red-700 dark:text-red-400 dark:hover:bg-red-950/30 dark:hover:text-red-300",onClick:t,children:[s.jsx(vj,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Remove"})]})]})]})}function Rf({className:e,ctaLabel:t,renderEmbedded:n,embeddedFallback:r,renderCustom:o,customFallback:a}){const{config:i}=Ee(),c=Pt(),l=vs(),{config:d,isLoading:f}=El(),[u,h]=m.useState(!1);m.useEffect(()=>{let M=!0;return Promise.resolve().then(()=>require("./walletDetection-bNmV5ItZ.js")).then(U=>{M&&h(U.detectSolanaWallets())}),()=>{M=!1}},[]);const g=Al({items:c.items}),[y,x]=m.useState(!1),p=m.useMemo(()=>i.checkout.paymentMethods&&i.checkout.paymentMethods.length?i.checkout.paymentMethods:[{id:"card",label:"Card",ctaLabel:"Pay now"}],[i.checkout.paymentMethods]),v=m.useMemo(()=>p.filter(U=>!(U.id==="card"&&!d.card||U.id==="crypto"&&!d.crypto||U.id==="credits"&&!d.credits||U.id==="crypto"&&!u)),[u,p,d]),[_,w]=m.useState((v[0]??p[0])?.id??"card");m.useEffect(()=>{v.length&&(v.some(M=>M.id===_)||w(v[0].id))},[_,v]),m.useEffect(()=>{l.reset()},[_]);const b=v.find(M=>M.id===_)??p.find(M=>M.id===_)??p[0]??{ctaLabel:"Pay now"},j=b.description??(_==="crypto"?"Pay using a connected wallet.":void 0),R=_==="crypto"&&!u,I=f||l.status==="validating"||l.status==="creating_session"||l.status==="redirecting"||g.isVerifying,C=t??b.ctaLabel??(i.checkout.mode==="none"?"Continue to payment":"Pay now"),E=m.useCallback(async M=>{const U=await g.verify();if(!U.ok&&U.issues.length>0){x(!0);return}l.createCheckoutSession({paymentMethodId:M})},[l,g]),O=l.session?.kind==="embedded"?l.session:null,F=l.session?.kind==="custom"?l.session:null;return s.jsxs("div",{className:L("space-y-3",e),children:[v.length>1?s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"text-xs font-medium text-neutral-600 dark:text-neutral-400",children:"Payment method"}),s.jsx(za,{value:_,onValueChange:w,children:s.jsx(Ws,{className:"w-full",children:v.map(M=>s.jsx(_r,{value:M.id,className:"flex-1",disabled:I,children:M.label},M.id))})})]}):null,l.error?s.jsx("div",{className:"rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-800 dark:border-red-900/40 dark:bg-red-950/30 dark:text-red-200",children:l.error}):null,F?s.jsx("div",{className:"space-y-3",children:o?o(F):a??s.jsx("div",{className:"rounded-lg border border-neutral-200 bg-neutral-50 p-4 text-sm text-neutral-700 dark:border-neutral-800 dark:bg-neutral-900/40 dark:text-neutral-300",children:"Checkout session created. Provide `renderCustom` to render a custom payment UI."})}):O?s.jsx("div",{className:"space-y-3",children:n?n(O):r??s.jsx("div",{className:"rounded-lg border border-neutral-200 bg-neutral-50 p-4 text-sm text-neutral-700 dark:border-neutral-800 dark:bg-neutral-900/40 dark:text-neutral-300",children:"Embedded checkout session created. Provide `renderEmbedded` to render your payment UI."})}):s.jsx(ne,{type:"button",className:"w-full",disabled:c.items.length===0||I||R,onClick:()=>{E(_)},children:g.isVerifying?"Checking availability…":I?"Processing…":C}),!O&&!F?s.jsx("p",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:R?"Install a browser wallet to enable crypto payments.":j??"You will be redirected to complete your payment."}):null,s.jsx(Pf,{open:y,onOpenChange:M=>{x(M),M||g.reset()},issues:g.result?.issues??[],onRemoveItem:(M,U)=>{c.removeItem(M,U)},onUpdateQuantity:(M,U,D)=>{c.setQty(M,U,D)}})]})}function Of({className:e}){const{config:t}=Ee(),n=Pt(),r=vs(),{settings:o}=Wn(),a=(t.checkout.allowPromoCodes??!1)&&o.checkout.promoCodes;return s.jsxs("div",{className:L("rounded-2xl border border-neutral-200 bg-white p-5 dark:border-neutral-800 dark:bg-neutral-950",e),children:[s.jsx("div",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:"Order review"}),s.jsx(yt,{className:"my-3"}),s.jsx("div",{className:"space-y-3",children:n.items.map(i=>s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[s.jsx("div",{className:"h-10 w-10 shrink-0 overflow-hidden rounded-lg border border-neutral-200 bg-neutral-100 dark:border-neutral-800 dark:bg-neutral-900",children:i.imageSnapshot?s.jsx("img",{src:i.imageSnapshot,alt:i.titleSnapshot,className:"h-full w-full object-cover"}):null}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"line-clamp-1 text-sm text-neutral-950 dark:text-neutral-50",children:i.titleSnapshot}),s.jsxs("div",{className:"text-xs text-neutral-600 dark:text-neutral-400",children:["Qty ",i.qty]})]})]}),s.jsx("div",{className:"text-sm font-semibold tabular-nums text-neutral-950 dark:text-neutral-50",children:Be({amount:i.unitPrice*i.qty,currency:i.currency})})]},`${i.productId}::${i.variantId??""}`))}),s.jsx(yt,{className:"my-3"}),a?s.jsx(Ya,{value:r.values.discountCode??n.promoCode,onApply:i=>{r.setField("discountCode",i??""),n.setPromoCode(i)}}):null,a?s.jsx(yt,{className:"my-3"}):null,s.jsxs("div",{className:"flex items-center justify-between text-sm",children:[s.jsx("span",{className:"text-neutral-600 dark:text-neutral-400",children:"Subtotal"}),s.jsx("span",{className:"font-semibold text-neutral-950 dark:text-neutral-50",children:Be({amount:n.subtotal,currency:t.currency})})]})]})}function Gs({result:e,onContinueShopping:t,onViewOrders:n,className:r}){return e.kind==="idle"?null:e.kind==="success"?s.jsxs("div",{className:L("rounded-2xl border border-neutral-200 bg-white p-8 text-neutral-950 dark:border-neutral-800 dark:bg-neutral-950 dark:text-neutral-50",r),children:[s.jsx("div",{className:"text-sm font-semibold text-neutral-600 dark:text-neutral-400",children:"Receipt"}),s.jsx("h2",{className:"mt-2 text-2xl font-semibold",children:"Payment successful"}),s.jsx("p",{className:"mt-2 text-sm text-neutral-600 dark:text-neutral-400",children:"Thanks for your purchase. You’ll receive a confirmation email shortly."}),e.order?s.jsxs("div",{className:"mt-5 rounded-xl border border-neutral-200 bg-neutral-50 p-4 dark:border-neutral-800 dark:bg-neutral-900/40",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:["Order ",e.order.id]}),s.jsxs("div",{className:"mt-1 text-xs text-neutral-600 dark:text-neutral-400",children:[new Date(e.order.createdAt).toLocaleString()," · ",e.order.status]})]}),s.jsx("div",{className:"text-sm font-semibold",children:Be({amount:e.order.total,currency:e.order.currency})})]}),s.jsxs("div",{className:"mt-3 space-y-2",children:[e.order.items.slice(0,4).map((o,a)=>s.jsxs("div",{className:"flex items-center justify-between gap-3 text-sm",children:[s.jsx("div",{className:"min-w-0 truncate",children:o.title}),s.jsxs("div",{className:"shrink-0 text-neutral-600 dark:text-neutral-400",children:["Qty ",o.qty]})]},`${o.title}-${a}`)),e.order.items.length>4?s.jsxs("div",{className:"text-xs text-neutral-600 dark:text-neutral-400",children:["+",e.order.items.length-4," more item(s)"]}):null]}),s.jsxs("div",{className:"mt-3 flex gap-3 text-sm",children:[e.order.receiptUrl?s.jsx("a",{href:e.order.receiptUrl,className:"hover:underline",children:"Receipt"}):null,e.order.invoiceUrl?s.jsx("a",{href:e.order.invoiceUrl,className:"hover:underline",children:"Invoice"}):null]})]}):e.orderId?s.jsxs("p",{className:"mt-4 text-xs text-neutral-500 dark:text-neutral-400",children:["Session/Order ID: ",s.jsx("span",{className:"font-mono",children:e.orderId})]}):null,s.jsxs("div",{className:"mt-6 flex flex-col gap-2 sm:flex-row",children:[t?s.jsx(ne,{type:"button",onClick:t,children:"Continue shopping"}):null,n?s.jsx(ne,{type:"button",variant:"outline",onClick:n,children:"View orders"}):null]})]}):e.kind==="cancel"?s.jsxs("div",{className:L("rounded-2xl border border-neutral-200 bg-white p-8 text-neutral-950 dark:border-neutral-800 dark:bg-neutral-950 dark:text-neutral-50",r),children:[s.jsx("h2",{className:"text-2xl font-semibold",children:"Checkout cancelled"}),s.jsx("p",{className:"mt-2 text-sm text-neutral-600 dark:text-neutral-400",children:"No charges were made. You can continue shopping and try again."}),t?s.jsx("div",{className:"mt-6",children:s.jsx(ne,{type:"button",onClick:t,children:"Back to shop"})}):null]}):s.jsxs("div",{className:L("rounded-2xl border border-neutral-200 bg-white p-8 text-neutral-950 dark:border-neutral-800 dark:bg-neutral-950 dark:text-neutral-50",r),children:[s.jsx("h2",{className:"text-2xl font-semibold",children:"Payment failed"}),s.jsx("p",{className:"mt-2 text-sm text-neutral-600 dark:text-neutral-400",children:e.message??"Something went wrong while processing your payment."}),t?s.jsx("div",{className:"mt-6",children:s.jsx(ne,{type:"button",onClick:t,children:"Back to shop"})}):null]})}function bj({onContinueShopping:e,onViewOrders:t,className:n,receiptClassName:r}){const o=sa();return o.kind==="idle"?s.jsx("div",{className:L("flex min-h-[50vh] items-center justify-center p-4",n),children:s.jsx("div",{className:"text-center text-neutral-600 dark:text-neutral-400",children:"Loading order details..."})}):s.jsx("div",{className:L("flex min-h-[50vh] items-center justify-center p-4",n),children:s.jsx(Gs,{result:o,onContinueShopping:e,onViewOrders:t,className:L("w-full max-w-lg",r)})})}function wj({onContinueShopping:e,className:t,receiptClassName:n}){const r={kind:"cancel"};return s.jsx("div",{className:L("flex min-h-[50vh] items-center justify-center p-4",t),children:s.jsx(Gs,{result:r,onContinueShopping:e,className:L("w-full max-w-lg",n)})})}function _j(e){switch(e){case"created":return"secondary";case"paid":return"default";case"processing":return"secondary";case"fulfilled":return"outline";case"shipped":return"default";case"delivered":return"outline";case"cancelled":return"outline";case"refunded":return"outline";default:return"secondary"}}function Mf({order:e,onView:t,className:n}){const r=`${e.items.length} item${e.items.length===1?"":"s"}`,o=new Date(e.createdAt).toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}),a=e.status.charAt(0).toUpperCase()+e.status.slice(1);return s.jsx(Et,{className:L("group overflow-hidden rounded-2xl border-neutral-200/70 bg-white shadow-sm transition-shadow hover:shadow-md dark:border-neutral-800 dark:bg-neutral-950",n),children:s.jsx(Vt,{className:"p-5",children:s.jsxs("div",{className:"grid grid-cols-[1fr_auto] gap-x-4 gap-y-2",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[s.jsx("span",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:"Order"}),s.jsx("span",{className:"truncate font-mono text-sm font-semibold text-neutral-950/80 dark:text-neutral-50/80",children:e.id})]}),s.jsx("div",{className:"mt-0.5 text-xs text-neutral-600 dark:text-neutral-400",children:o})]}),s.jsx("div",{className:"flex items-start justify-end",children:s.jsx(vn,{variant:_j(e.status),className:"capitalize",children:a})}),s.jsx("div",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:r}),s.jsx("div",{className:"text-right text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:Be({amount:e.total,currency:e.currency})}),s.jsxs("div",{className:"col-span-2 mt-3 flex items-center justify-between gap-3 border-t border-neutral-200/70 pt-3 dark:border-neutral-800",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[e.receiptUrl?s.jsx(ne,{asChild:!0,type:"button",variant:"ghost",size:"sm",className:"h-8 px-2",children:s.jsx("a",{href:e.receiptUrl,target:"_blank",rel:"noreferrer",children:"Receipt"})}):null,e.invoiceUrl?s.jsx(ne,{asChild:!0,type:"button",variant:"ghost",size:"sm",className:"h-8 px-2",children:s.jsx("a",{href:e.invoiceUrl,target:"_blank",rel:"noreferrer",children:"Invoice"})}):null]}),t?s.jsx(ne,{type:"button",variant:"outline",size:"sm",className:"h-8",onClick:()=>t(e),children:"Details"}):null]})]})})})}function Lf({orders:e,onView:t,className:n}){return s.jsx("div",{className:L("grid gap-4",n),children:e.map(r=>s.jsx(Mf,{order:r,onView:t},r.id))})}function kj(e){switch(e){case"paid":return"default";case"processing":return"secondary";case"fulfilled":return"outline";case"cancelled":return"outline";case"refunded":return"outline";default:return"secondary"}}function Df({order:e,onBack:t,className:n}){const r=new Date(e.createdAt).toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}),o=e.status.charAt(0).toUpperCase()+e.status.slice(1);return s.jsx(Et,{className:L("overflow-hidden rounded-2xl border-neutral-200/70 bg-white shadow-sm dark:border-neutral-800 dark:bg-neutral-950",n),children:s.jsxs(Vt,{className:"p-6",children:[s.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[s.jsx("span",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:"Order"}),s.jsx("span",{className:"truncate font-mono text-sm font-semibold text-neutral-950/80 dark:text-neutral-50/80",children:e.id})]}),s.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-neutral-600 dark:text-neutral-400",children:[s.jsx("span",{children:r}),s.jsx("span",{className:"text-neutral-300 dark:text-neutral-700",children:"·"}),s.jsx("span",{children:o})]})]}),s.jsxs("div",{className:"flex items-center gap-2 sm:justify-end",children:[s.jsx(vn,{variant:kj(e.status),className:"capitalize",children:o}),t?s.jsx(ne,{type:"button",variant:"outline",size:"sm",className:"h-8",onClick:t,children:"Back"}):null]})]}),s.jsx(yt,{className:"my-5"}),s.jsx("div",{className:"space-y-3",children:e.items.map((a,i)=>s.jsxs("div",{className:"flex items-start justify-between gap-4",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"truncate text-sm text-neutral-950 dark:text-neutral-50",children:a.title}),s.jsxs("div",{className:"mt-0.5 text-xs text-neutral-600 dark:text-neutral-400",children:["Qty ",a.qty]})]}),s.jsx("div",{className:"text-right text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:Be({amount:a.unitPrice*a.qty,currency:a.currency})})]},`${a.title}-${i}`))}),s.jsx(yt,{className:"my-5"}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:"Total"}),s.jsx("span",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:Be({amount:e.total,currency:e.currency})})]}),e.receiptUrl||e.invoiceUrl?s.jsxs("div",{className:"mt-5 flex flex-wrap items-center gap-2",children:[e.receiptUrl?s.jsx(ne,{asChild:!0,type:"button",variant:"ghost",size:"sm",className:"h-8 px-2",children:s.jsx("a",{href:e.receiptUrl,target:"_blank",rel:"noreferrer",children:"Receipt"})}):null,e.invoiceUrl?s.jsx(ne,{asChild:!0,type:"button",variant:"ghost",size:"sm",className:"h-8 px-2",children:s.jsx("a",{href:e.invoiceUrl,target:"_blank",rel:"noreferrer",children:"Invoice"})}):null]}):null]})})}function Qa(e){const t={};e.shippingProfile&&(t.shippingProfile=e.shippingProfile),e.checkoutRequirements&&(t.checkoutRequirements=JSON.stringify(e.checkoutRequirements)),e.fulfillment?.type&&(t.fulfillmentType=e.fulfillment.type),e.fulfillment?.notes&&(t.fulfillmentNotes=e.fulfillment.notes);const n=e.attributes?.shippingCountries;return typeof n=="string"&&n.trim()&&(t.shippingCountries=n),Object.keys(t).length?t:void 0}function jj(e){return s.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:s.jsx("path",{d:"M21 15a4 4 0 0 1-4 4H8l-5 3V7a4 4 0 0 1 4-4h10a4 4 0 0 1 4 4z"})})}const Sj={shop:"/shop",category:e=>`/shop/${e}`,product:e=>`/product/${e}`,cart:"/cart",checkout:"/checkout",orders:"/account/orders",subscribe:"/subscribe"};function Cj(e){const t=new Set;let n=Number.POSITIVE_INFINITY,r=0;for(const i of e){for(const c of i.tags??[])t.add(c);n=Math.min(n,i.price),r=Math.max(r,i.price)}const o=Array.from(t).slice(0,12),a=Number.isFinite(n)?{min:n,max:r}:void 0;return{tags:o,price:a}}function Nj({className:e,routes:t,initialCategorySlug:n}){const{config:r}=Ee(),o=Pt(),a=Hs(),i={...Sj,...t},[c,l]=m.useState("cart"),[d,f]=m.useState(()=>typeof window>"u"?!1:window.matchMedia?.("(min-width: 1024px)")?.matches??!1);m.useEffect(()=>{if(typeof window>"u")return;const P=window.matchMedia?.("(min-width: 1024px)");if(!P)return;const G=()=>f(P.matches);return G(),P.addEventListener?.("change",G),()=>P.removeEventListener?.("change",G)},[]);const{categories:u,isLoading:h,error:g}=na(),y=m.useMemo(()=>oa({includeCategory:!0}),[]),[x,p]=m.useState(y?.search??""),[v,_]=m.useState(n??y?.category),[w,b]=m.useState(y?.page??1),[j,R]=m.useState(y?.sort??"featured"),[I,C]=m.useState(y?.filters??{}),{data:E,isLoading:O,error:F}=ys({category:v,search:x.trim()||void 0,filters:I,sort:j,page:w,pageSize:24}),M=m.useMemo(()=>Cj(E?.items??[]),[E?.items]),{settings:U}=Wn(),D=U.catalog.filters,H=U.catalog.sort,z=m.useMemo(()=>{const P=[];return H.featured&&P.push({value:"featured",label:"Featured"}),H.priceAsc&&P.push({value:"price_asc",label:"Price: Low to High"}),H.priceDesc&&P.push({value:"price_desc",label:"Price: High to Low"}),P.length===0&&P.push({value:"featured",label:"Featured"}),P},[H]);m.useEffect(()=>{z.some(P=>P.value===j)||R(z[0].value)},[z,j]),aa({search:x,sort:j,page:w,category:v,filters:I},{includeCategory:!0});const[A,N]=m.useState(!1),[Z,te]=m.useState(!1),[re,de]=m.useState(null),[W,Q]=m.useState(!1),q=P=>{_(P.slug),b(1),N(!1)},he=m.useCallback((P,G,ue)=>{o.addItem({productId:P.id,variantId:G?.id,unitPrice:P.price,currency:P.currency,titleSnapshot:G?`${P.title} — ${G.title}`:P.title,imageSnapshot:P.images[0]?.url,paymentResource:P.id,metadata:Qa(P)},ue),a?.toast({title:"Added to cart",description:P.title,actionLabel:"View cart",onAction:()=>{typeof window<"u"&&(window.matchMedia?.("(min-width: 1024px)").matches?window.location.assign(i.cart):(l("cart"),te(!0)))}})},[o,i.cart,a]);return s.jsxs("div",{className:L("min-h-screen bg-neutral-50 text-neutral-950 dark:bg-neutral-950 dark:text-neutral-50",e),children:[s.jsx("header",{className:"sticky top-0 z-40 border-b border-neutral-200 bg-neutral-50/80 backdrop-blur dark:border-neutral-800 dark:bg-neutral-950/70",children:s.jsxs("div",{className:"mx-auto flex max-w-7xl items-center gap-3 px-4 py-3",children:[s.jsx("a",{href:i.shop,className:"text-sm font-semibold tracking-tight",children:r.brand?.name??"Shop"}),s.jsx("div",{className:"flex-1",children:s.jsx(Za,{value:x,onChange:p})}),s.jsxs("div",{className:"flex items-center gap-2 lg:hidden",children:[s.jsxs(Ls,{open:A,onOpenChange:N,children:[s.jsx(Ds,{asChild:!0,children:s.jsx(ne,{type:"button",variant:"outline",children:"Filters"})}),s.jsxs(Nr,{side:"left",children:[s.jsx($s,{children:s.jsx(zs,{children:"Browse"})}),s.jsxs("div",{className:"mt-4",children:[g?s.jsx(Bt,{description:g}):null,h?s.jsxs("div",{className:"space-y-2",children:[s.jsx(Re,{className:"h-9"}),s.jsx(Re,{className:"h-9"}),s.jsx(Re,{className:"h-9"})]}):s.jsxs("div",{className:"space-y-6",children:[s.jsx(Wo,{categories:u,activeSlug:v,onSelect:q}),s.jsx(ms,{facets:M,value:I,onChange:P=>{C(P),b(1)},onClear:()=>{C({}),b(1)},enabledFilters:D}),z.length>1&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"text-sm font-semibold",children:"Sort"}),s.jsxs(ls,{value:j,onValueChange:P=>{R(P),b(1)},children:[s.jsx(yr,{"aria-label":"Sort",children:s.jsx(ds,{placeholder:"Sort"})}),s.jsx(br,{children:z.map(P=>s.jsx(wr,{value:P.value,children:P.label},P.value))})]})]})]})]})]})]}),s.jsx(kr,{open:!d&&Z,onOpenChange:te,side:"bottom",preferredTab:c,onCheckout:()=>{typeof window<"u"&&window.location.assign(i.checkout)},trigger:s.jsxs(ne,{type:"button",variant:"default",onClick:()=>l("cart"),children:["Cart (",o.count,")"]})})]}),s.jsxs("div",{className:"hidden lg:flex items-center gap-2",children:[s.jsx(kr,{open:d&&Z,onOpenChange:te,side:"popup",preferredTab:c,onCheckout:()=>{typeof window<"u"&&window.location.assign(i.checkout)},trigger:s.jsxs(ne,{type:"button",variant:"outline",onClick:()=>l("cart"),children:["Cart (",o.count,")"]})}),s.jsx(ne,{type:"button",variant:"default",onClick:()=>{typeof window<"u"&&window.location.assign(i.checkout)},children:"Checkout"})]})]})}),s.jsxs(ne,{type:"button",variant:"ghost",className:L("fixed bottom-4 right-4 z-30 hidden items-center gap-2 rounded-full border border-neutral-200 bg-white/90 px-3 py-2 text-xs font-medium text-neutral-900 shadow-sm backdrop-blur hover:bg-white dark:border-neutral-800 dark:bg-neutral-950/80 dark:text-neutral-50 dark:hover:bg-neutral-950 lg:flex",Z?"lg:hidden":void 0),onClick:()=>{l("chat"),te(!0)},"aria-label":"Open chat",children:[s.jsx(jj,{className:"h-4 w-4"}),"Chat"]}),s.jsxs("main",{className:"mx-auto grid max-w-7xl items-start gap-6 px-4 py-6 lg:grid-cols-[280px_1fr]",children:[s.jsx("aside",{className:"hidden lg:block",children:s.jsx("div",{className:"sticky top-24",children:s.jsxs(Et,{className:"flex max-h-[calc(100vh-6rem)] flex-col rounded-2xl",children:[s.jsx(hr,{className:"pb-4",children:s.jsx(gr,{className:"text-base",children:"Browse"})}),s.jsxs(Vt,{className:"flex-1 space-y-6 overflow-y-auto pr-2",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-semibold",children:"Categories"}),g?s.jsx(Bt,{className:"mt-3",description:g}):null,h?s.jsxs("div",{className:"mt-3 space-y-2",children:[s.jsx(Re,{className:"h-9"}),s.jsx(Re,{className:"h-9"}),s.jsx(Re,{className:"h-9"})]}):s.jsx("div",{className:"mt-3",children:s.jsx(Wo,{categories:u,activeSlug:v,onSelect:q})})]}),z.length>1&&s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-semibold",children:"Sort"}),s.jsx("div",{className:"mt-2",children:s.jsxs(ls,{value:j,onValueChange:P=>{R(P),b(1)},children:[s.jsx(yr,{"aria-label":"Sort",children:s.jsx(ds,{placeholder:"Sort"})}),s.jsx(br,{children:z.map(P=>s.jsx(wr,{value:P.value,children:P.label},P.value))})]})})]}),s.jsx(ms,{facets:M,value:I,onChange:P=>{C(P),b(1)},onClear:()=>{C({}),b(1)},enabledFilters:D})]})]})})}),s.jsxs("section",{children:[s.jsx("div",{className:"flex items-end justify-between gap-3",children:s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:U.shopPage.title||"Shop"}),U.shopPage.description&&s.jsx("p",{className:"mt-1 text-sm text-neutral-600 dark:text-neutral-400",children:U.shopPage.description})]})}),F?s.jsx(Bt,{className:"mt-6",description:F}):null,O?s.jsx("div",{className:"mt-6 grid grid-cols-2 gap-4 md:grid-cols-3 lg:grid-cols-4",children:Array.from({length:8}).map((P,G)=>s.jsx(Re,{className:"aspect-[4/5] rounded-2xl"},G))}):s.jsxs("div",{className:"mt-6",children:[s.jsx(qs,{products:E?.items??[],columns:r.ui?.productGrid?.columns,getProductHref:P=>i.product(P.slug),onAddToCart:P=>he(P,null,1),onQuickView:P=>{de(P),Q(!0)},layout:U.shopLayout.layout,imageCrop:U.shopLayout.imageCrop}),s.jsxs("div",{className:"mt-8 flex items-center justify-between",children:[s.jsx(ne,{type:"button",variant:"outline",disabled:w<=1,onClick:()=>b(P=>Math.max(1,P-1)),children:"Previous"}),s.jsxs("div",{className:"text-xs text-neutral-600 dark:text-neutral-400",children:["Page ",w]}),s.jsx(ne,{type:"button",variant:"outline",disabled:!E?.hasNextPage,onClick:()=>b(P=>P+1),children:"Next"})]})]})]})]}),s.jsx(Wa,{product:re,open:W,onOpenChange:Q,productHref:P=>i.product(P),onAddToCart:(P,G,ue)=>he(P,G,ue)})]})}function Aj(e){return s.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:s.jsx("path",{d:"M21 15a4 4 0 0 1-4 4H8l-5 3V7a4 4 0 0 1 4-4h10a4 4 0 0 1 4 4z"})})}function Ej({categorySlug:e,className:t,routes:n}){const{config:r}=Ee(),o=Pt(),a=Hs(),{categories:i}=na(),[c,l]=m.useState(()=>typeof window>"u"?!1:window.matchMedia?.("(min-width: 1024px)")?.matches??!1);m.useEffect(()=>{if(typeof window>"u")return;const B=window.matchMedia?.("(min-width: 1024px)");if(!B)return;const ae=()=>l(B.matches);return ae(),B.addEventListener?.("change",ae),()=>B.removeEventListener?.("change",ae)},[]);const[d,f]=m.useState(!1),[u,h]=m.useState(!1),[g,y]=m.useState("cart"),x=m.useMemo(()=>oa({includeCategory:!1}),[]),[p,v]=m.useState(x?.search??""),[_,w]=m.useState(x?.page??1),[b,j]=m.useState(x?.sort??"featured"),[R,I]=m.useState(x?.filters??{}),[C,E]=m.useState(null),[O,F]=m.useState(!1),M=i.find(B=>B.slug===e)??null,{data:U,isLoading:D,error:H}=ys({category:e,search:p.trim()||void 0,filters:R,sort:b,page:_,pageSize:24}),z=n?.product??(B=>`/product/${B}`),A=n?.shop??"/shop",N=n?.cart??"/cart",Z=n?.checkout??"/checkout",te=m.useMemo(()=>{const B=U?.items??[],ae=new Set;let ce=Number.POSITIVE_INFINITY,we=0;for(const Ge of B){for(const We of Ge.tags??[])ae.add(We);ce=Math.min(ce,Ge.price),we=Math.max(we,Ge.price)}const Te=Array.from(ae).slice(0,12),Ve=Number.isFinite(ce)?{min:ce,max:we}:void 0;return{tags:Te,price:Ve}},[U?.items]),{settings:re}=Wn(),de=re.catalog.filters,W=re.catalog.sort,Q=m.useMemo(()=>{const B=[];return W.featured&&B.push({value:"featured",label:"Featured"}),W.priceAsc&&B.push({value:"price_asc",label:"Price: Low to High"}),W.priceDesc&&B.push({value:"price_desc",label:"Price: High to Low"}),B.length===0&&B.push({value:"featured",label:"Featured"}),B},[W]);m.useEffect(()=>{Q.some(B=>B.value===b)||j(Q[0].value)},[Q,b]),aa({search:p,sort:b,page:_,filters:R},{includeCategory:!1});const q=m.useCallback((B,ae,ce)=>{o.addItem({productId:B.id,variantId:ae?.id,unitPrice:B.price,currency:B.currency,titleSnapshot:ae?`${B.title} — ${ae.title}`:B.title,imageSnapshot:B.images[0]?.url,paymentResource:B.id,metadata:Qa(B)},ce),a?.toast({title:"Added to cart",description:B.title,actionLabel:"View cart",onAction:()=>{typeof window<"u"&&(window.matchMedia?.("(min-width: 1024px)").matches?window.location.assign(N):(y("cart"),h(!0)))}})},[o,N,a]),he=B=>{I(B),w(1)},P=()=>{I({}),w(1)},G=B=>{j(B),w(1)},ue=s.jsx(Et,{className:"flex max-h-[calc(100vh-6rem)] flex-col rounded-2xl",children:s.jsxs(Vt,{className:"flex-1 space-y-5 overflow-y-auto pr-2 pt-6",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-neutral-500 dark:text-neutral-400",children:"Category"}),s.jsx(ne,{asChild:!0,type:"button",variant:"ghost",size:"sm",className:"h-8 px-2 text-xs",children:s.jsx("a",{href:A,children:"All categories"})})]}),s.jsx("div",{className:"text-base font-semibold text-neutral-950 dark:text-neutral-50",children:M?.name??e}),s.jsx("div",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:M?.description??"Browse products in this category."})]}),Q.length>1&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"text-sm font-semibold",children:"Sort"}),s.jsxs(ls,{value:b,onValueChange:G,children:[s.jsx(yr,{"aria-label":"Sort",children:s.jsx(ds,{placeholder:"Sort"})}),s.jsx(br,{children:Q.map(B=>s.jsx(wr,{value:B.value,children:B.label},B.value))})]})]}),s.jsx(yt,{}),s.jsx(ms,{facets:te,value:R,onChange:he,onClear:P,enabledFilters:de})]})});return s.jsxs("div",{className:L("min-h-screen bg-neutral-50 text-neutral-950 dark:bg-neutral-950 dark:text-neutral-50",t),children:[s.jsx("header",{className:"sticky top-0 z-40 border-b border-neutral-200 bg-neutral-50/80 backdrop-blur dark:border-neutral-800 dark:bg-neutral-950/70",children:s.jsxs("div",{className:"mx-auto flex max-w-7xl items-center gap-3 px-4 py-3",children:[s.jsx("a",{href:A,className:"text-sm font-semibold tracking-tight",children:r.brand?.name??"Shop"}),s.jsx("div",{className:"flex-1",children:s.jsx(Za,{value:p,onChange:v})}),s.jsxs("div",{className:"flex items-center gap-2 lg:hidden",children:[s.jsxs(Ls,{open:d,onOpenChange:f,children:[s.jsx(Ds,{asChild:!0,children:s.jsx(ne,{type:"button",variant:"outline",children:"Filters"})}),s.jsxs(Nr,{side:"left",children:[s.jsx($s,{children:s.jsx(zs,{children:"Filters"})}),s.jsx("div",{className:"mt-4",children:ue})]})]}),s.jsx(kr,{open:!c&&u,onOpenChange:h,side:"bottom",preferredTab:g,onCheckout:()=>{typeof window<"u"&&window.location.assign(Z)},trigger:s.jsxs(ne,{type:"button",variant:"default",onClick:()=>y("cart"),children:["Cart (",o.count,")"]})})]}),s.jsxs("div",{className:"hidden lg:flex items-center gap-2",children:[s.jsx(kr,{open:c&&u,onOpenChange:h,side:"popup",preferredTab:g,onCheckout:()=>{typeof window<"u"&&window.location.assign(Z)},trigger:s.jsxs(ne,{type:"button",variant:"outline",onClick:()=>y("cart"),children:["Cart (",o.count,")"]})}),s.jsx(ne,{type:"button",variant:"default",onClick:()=>{typeof window<"u"&&window.location.assign(Z)},children:"Checkout"})]})]})}),s.jsxs(ne,{type:"button",variant:"ghost",className:L("fixed bottom-4 right-4 z-30 hidden items-center gap-2 rounded-full border border-neutral-200 bg-white/90 px-3 py-2 text-xs font-medium text-neutral-900 shadow-sm backdrop-blur hover:bg-white dark:border-neutral-800 dark:bg-neutral-950/80 dark:text-neutral-50 dark:hover:bg-neutral-950 lg:flex",u?"lg:hidden":void 0),onClick:()=>{y("chat"),h(!0)},"aria-label":"Open chat",children:[s.jsx(Aj,{className:"h-4 w-4"}),"Chat"]}),s.jsxs("main",{className:"mx-auto max-w-7xl px-4 py-8",children:[s.jsx(Ha,{items:[{label:"Shop",href:A},{label:M?.name??e}]}),s.jsxs("div",{className:"mt-6",children:[s.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:M?.name??"Category"}),s.jsx("p",{className:"mt-1 text-sm text-neutral-600 dark:text-neutral-400",children:M?.description??"Browse products in this category."})]}),H?s.jsx(Bt,{className:"mt-6",description:H}):null,s.jsxs("div",{className:"mt-6 grid gap-6 lg:grid-cols-[280px_1fr]",children:[s.jsx("aside",{className:"hidden lg:block",children:s.jsx("div",{className:"sticky top-24",children:ue})}),s.jsx("div",{children:D?s.jsx("div",{className:"mt-6 grid grid-cols-2 gap-4 md:grid-cols-3 lg:grid-cols-4",children:Array.from({length:8}).map((B,ae)=>s.jsx(Re,{className:"aspect-[4/5] rounded-2xl"},ae))}):s.jsxs("div",{className:"mt-6",children:[s.jsx(qs,{products:U?.items??[],columns:r.ui?.productGrid?.columns,getProductHref:B=>z(B.slug),onAddToCart:B=>q(B,null,1),onQuickView:B=>{E(B),F(!0)},layout:re.categoryLayout.layout,imageCrop:re.categoryLayout.imageCrop}),s.jsxs("div",{className:"mt-8 flex items-center justify-between",children:[s.jsx(ne,{type:"button",variant:"outline",disabled:_<=1,onClick:()=>w(B=>Math.max(1,B-1)),children:"Previous"}),s.jsxs("div",{className:"text-xs text-neutral-600 dark:text-neutral-400",children:["Page ",_]}),s.jsx(ne,{type:"button",variant:"outline",disabled:!U?.hasNextPage,onClick:()=>w(B=>B+1),children:"Next"})]})]})})]}),s.jsx(Wa,{product:C,open:O,onOpenChange:F,productHref:B=>z(B),onAddToCart:(B,ae,ce)=>q(B,ae,ce)})]})]})}function Ij(e){return!e||typeof e!="string"?[]:e.split(",").map(t=>t.trim()).filter(Boolean)}function Tj({slug:e,className:t,routes:n}){const r=Pt(),o=Hs(),{product:a,isLoading:i,error:c}=jl(e),[l,d]=m.useState(1),[f,u]=m.useState({selectedOptions:{},variant:null});m.useEffect(()=>{if(!a||!a.variants?.length)return;const D=a.variants[0];u({selectedOptions:{...D.options},variant:D})},[a?.id]);const{settings:h}=Wn(),{mode:g,maxItems:y}=h.relatedProducts,x=Il({productId:a?.id,enabled:g==="ai"&&!!a?.id}),p=m.useMemo(()=>g==="by_category"&&a?.categoryIds?.length?{category:a.categoryIds[0],page:1,pageSize:y+1}:{page:1,pageSize:y+4},[g,y,a?.categoryIds]),v=ys(p),_=m.useMemo(()=>{const H=(v.data?.items??[]).filter(z=>z.slug!==e);if(g==="manual"&&a){const z=a.attributes?.relatedProductIds||a.attributes?.related_product_ids;if(z){const A=Ij(String(z));if(A.length>0){const N=new Map(H.map(te=>[te.id,te]));return A.map(te=>N.get(te)).filter(te=>!!te).slice(0,y)}}}if(g==="ai"&&x.relatedProductIds&&x.relatedProductIds.length>0){const z=new Map(H.map(N=>[N.id,N])),A=x.relatedProductIds.map(N=>z.get(N)).filter(N=>!!N);if(A.length>0)return A.slice(0,y)}return H.slice(0,y)},[v.data?.items,e,g,y,a,x.relatedProductIds]),w=n?.shop??"/shop",b=n?.checkout??"/checkout",j=n?.cart??"/cart",R=n?.product??(D=>`/product/${D}`);if(i)return s.jsx("div",{className:L("min-h-screen bg-neutral-50 p-6 dark:bg-neutral-950",t),children:s.jsxs("div",{className:"mx-auto max-w-6xl",children:[s.jsx(Re,{className:"h-5 w-40"}),s.jsxs("div",{className:"mt-6 grid gap-8 lg:grid-cols-2",children:[s.jsx(Re,{className:"aspect-square rounded-2xl"}),s.jsxs("div",{className:"space-y-4",children:[s.jsx(Re,{className:"h-8 w-2/3"}),s.jsx(Re,{className:"h-6 w-32"}),s.jsx(Re,{className:"h-20"}),s.jsx(Re,{className:"h-11"})]})]})]})});if(c)return s.jsx("div",{className:L("min-h-screen bg-neutral-50 p-6 dark:bg-neutral-950",t),children:s.jsx("div",{className:"mx-auto max-w-6xl",children:s.jsx(Bt,{description:c})})});if(!a)return s.jsx("div",{className:L("min-h-screen bg-neutral-50 p-6 dark:bg-neutral-950",t),children:s.jsx("div",{className:"mx-auto max-w-6xl",children:s.jsx(Bt,{description:"Product not found."})})});const I=f.variant?.price??a.price,C=f.variant?.compareAtPrice??a.compareAtPrice,E=f.variant?.inventoryStatus==="out_of_stock"||typeof f.variant?.inventoryQuantity=="number"&&f.variant.inventoryQuantity<=0,O=a.inventoryStatus==="out_of_stock"||typeof a.inventoryQuantity=="number"&&a.inventoryQuantity<=0,F=f.variant?E:O,M=()=>{F||(r.addItem({productId:a.id,variantId:f.variant?.id,unitPrice:I,currency:a.currency,titleSnapshot:f.variant?`${a.title} — ${f.variant.title}`:a.title,imageSnapshot:a.images[0]?.url,paymentResource:a.id,metadata:Qa(a)},l),o?.toast({title:"Added to cart",description:a.title,actionLabel:"View cart",onAction:()=>{typeof window<"u"&&window.location.assign(j)}}))},U=()=>{F||(M(),typeof window<"u"&&window.location.assign(b))};return s.jsx("div",{className:L("min-h-screen bg-neutral-50 text-neutral-950 dark:bg-neutral-950 dark:text-neutral-50",t),children:s.jsxs("main",{className:"mx-auto max-w-6xl px-4 py-8",children:[s.jsx(Ha,{items:[{label:"Shop",href:w},{label:a.title}]}),s.jsxs("div",{className:"mt-6 grid gap-10 lg:grid-cols-2",children:[s.jsx(Ua,{images:a.images}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-3xl font-semibold tracking-tight",children:a.title}),s.jsx("div",{className:"mt-3",children:s.jsx(Zs,{amount:I,currency:a.currency,compareAt:C})}),F?s.jsx("div",{className:"mt-2 text-sm font-medium text-red-700 dark:text-red-300",children:"Out of stock"}):typeof a.inventoryQuantity=="number"&&a.inventoryQuantity>0&&a.inventoryQuantity<=5?s.jsxs("div",{className:"mt-2 text-sm text-neutral-600 dark:text-neutral-400",children:["Only ",s.jsx("span",{className:"font-semibold text-neutral-950 dark:text-neutral-50",children:a.inventoryQuantity})," left"]}):null,s.jsx("p",{className:"mt-4 text-sm text-neutral-600 dark:text-neutral-400",children:a.description})]}),s.jsx(Ba,{product:a,value:{selectedOptions:f.selectedOptions,variantId:f.variant?.id},onChange:D=>u(D)}),s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[s.jsx(Va,{qty:l,onChange:d}),s.jsx(ne,{type:"button",onClick:M,className:"flex-1",disabled:F,children:F?"Out of stock":"Add to cart"}),s.jsx(ne,{type:"button",variant:"outline",onClick:U,disabled:F,children:"Buy now"})]}),(h.sections.showDescription||h.sections.showSpecs||h.sections.showShipping)&&s.jsxs(Qu,{type:"single",collapsible:!0,defaultValue:h.sections.showDescription?"desc":void 0,children:[h.sections.showDescription&&s.jsxs(dr,{value:"desc",children:[s.jsx(ur,{children:"Description"}),s.jsx(fr,{children:s.jsx("div",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:a.description})})]}),h.sections.showSpecs&&s.jsxs(dr,{value:"specs",children:[s.jsx(ur,{children:"Specs"}),s.jsx(fr,{children:s.jsx("div",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:a.attributes?s.jsx("div",{className:"space-y-1",children:Object.entries(a.attributes).map(([D,H])=>s.jsxs("div",{children:[s.jsxs("span",{className:"font-medium text-neutral-950 dark:text-neutral-50",children:[D,":"]})," ",String(H)]},D))}):"No specs provided."})})]}),h.sections.showShipping&&s.jsxs(dr,{value:"ship",children:[s.jsx(ur,{children:"Shipping & returns"}),s.jsx(fr,{children:s.jsx("div",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:"Ships in 2–3 business days. Easy returns within 30 days."})})]})]})]})]}),h.sections.showRelatedProducts&&_.length?s.jsxs("section",{className:"mt-12",children:[s.jsx("h2",{className:"text-lg font-semibold",children:"Related products"}),s.jsx("div",{className:"mt-4",children:s.jsx(qs,{products:_,columns:{base:2,md:4,lg:4},layout:h.relatedProducts.layout.layout,imageCrop:h.relatedProducts.layout.imageCrop,getProductHref:D=>R(D.slug),onAddToCart:D=>r.addItem({productId:D.id,unitPrice:D.price,currency:D.currency,titleSnapshot:D.title,imageSnapshot:D.images[0]?.url,paymentResource:D.id},1)})})]}):null]})})}function Pj({className:e,checkoutHref:t}){const{config:n}=Ee(),{settings:r}=Wn(),o=t??"/checkout",a=n.checkout.allowPromoCodes&&r.checkout.promoCodes;return s.jsx("div",{className:L("min-h-screen bg-neutral-50 text-neutral-950 dark:bg-neutral-950 dark:text-neutral-50",e),children:s.jsxs("main",{className:"mx-auto max-w-6xl px-4 py-10",children:[s.jsx("h1",{className:"text-3xl font-semibold tracking-tight",children:"Cart"}),s.jsx("p",{className:"mt-2 text-sm text-neutral-600 dark:text-neutral-400",children:"Review items, adjust quantities, then check out."}),s.jsx("div",{className:"mt-8",children:s.jsx(Af,{onCheckout:()=>{typeof window<"u"&&window.location.assign(o)},showPromoCode:a})})]})})}function Rj({className:e,routes:t}){const{config:n}=Ee(),r=Pt(),o=sa(),a=n.customer?.isSignedIn??!!n.customer?.id,c=!(n.checkout.requireAccount?!1:n.checkout.guestCheckout??!0)&&!a;m.useEffect(()=>{o.kind==="success"&&r.clear()},[o.kind]);const l=t?.shop??"/shop",d=t?.orders??"/account/orders",f=t?.login;return s.jsx("div",{className:L("min-h-screen bg-neutral-50 text-neutral-950 dark:bg-neutral-950 dark:text-neutral-50",e),children:s.jsxs("main",{className:"mx-auto max-w-6xl px-4 py-10",children:[s.jsx(Gs,{result:o,onContinueShopping:()=>{typeof window<"u"&&window.location.assign(l)},onViewOrders:()=>{typeof window<"u"&&window.location.assign(d)}}),o.kind==="idle"?s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-3xl font-semibold tracking-tight",children:"Checkout"}),s.jsx("p",{className:"mt-2 text-sm text-neutral-600 dark:text-neutral-400",children:n.checkout.mode==="none"?"Confirm and pay.":"Enter details, then complete payment."})]}),s.jsx("div",{className:"mt-8",children:s.jsx(kl,{children:c?s.jsxs(Et,{className:"rounded-2xl",children:[s.jsx(hr,{className:"pb-4",children:s.jsx(gr,{className:"text-base",children:"Sign in required"})}),s.jsxs(Vt,{children:[s.jsx("div",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:"This store requires an account to complete checkout."}),f?s.jsx("div",{className:"mt-4",children:s.jsx(ne,{type:"button",onClick:()=>{typeof window<"u"&&window.location.assign(f)},children:"Sign in"})}):null]})]}):s.jsx(Ef,{left:s.jsxs("div",{className:"space-y-6",children:[s.jsx(Tf,{}),s.jsxs(Et,{className:"rounded-2xl",children:[s.jsx(hr,{className:"pb-4",children:s.jsx(gr,{className:"text-base",children:"Payment"})}),s.jsxs(Vt,{children:[s.jsx(yt,{className:"mb-4"}),s.jsx(Rf,{})]})]})]}),right:s.jsx("div",{className:"lg:sticky lg:top-24",children:s.jsx(Of,{})})})})})]}):null]})})}function Oj({className:e,isSignedIn:t=!0,onLogin:n}){const{orders:r,isLoading:o,error:a}=Sl(),[i,c]=m.useState(null);return t?s.jsx("div",{className:L("min-h-screen bg-neutral-50 text-neutral-950 dark:bg-neutral-950 dark:text-neutral-50",e),children:s.jsxs("main",{className:"mx-auto max-w-5xl px-4 py-10 sm:py-12",children:[s.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-3xl font-semibold tracking-tight",children:"Orders"}),s.jsx("p",{className:"mt-2 text-sm text-neutral-600 dark:text-neutral-400",children:"View past purchases and receipts."})]}),!o&&!a&&!i&&r.length>0?s.jsxs("div",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:[r.length," order",r.length===1?"":"s"]}):null]}),a?s.jsx(Bt,{className:"mt-8",description:a}):null,o?s.jsxs("div",{className:"mt-8 grid gap-4",children:[s.jsx(Re,{className:"h-32 rounded-2xl"}),s.jsx(Re,{className:"h-32 rounded-2xl"}),s.jsx(Re,{className:"h-32 rounded-2xl"})]}):r.length===0?s.jsx("div",{className:"mt-8",children:s.jsx(Bn,{title:"No orders yet",description:"When you purchase something, it will show up here."})}):i?s.jsx("div",{className:"mt-8",children:s.jsx(Df,{order:i,onBack:()=>c(null)})}):s.jsx("div",{className:"mt-8",children:s.jsx(Lf,{orders:r,onView:c})})]})}):s.jsx("div",{className:L("min-h-screen bg-neutral-50 p-10 dark:bg-neutral-950",e),children:s.jsx("div",{className:"mx-auto max-w-4xl",children:s.jsx(Bn,{title:"Sign in to view your orders",description:"Your purchase history will appear here once you're logged in.",actionLabel:n?"Sign in":void 0,onAction:n})})})}function Mj({className:e}){return s.jsxs("svg",{className:e,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("polyline",{points:"6 9 6 2 18 2 18 9"}),s.jsx("path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2"}),s.jsx("rect",{x:"6",y:"14",width:"12",height:"8"})]})}function Lj({className:e}){return s.jsx("svg",{className:e,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"m15 18-6-6 6-6"})})}function Dj(e){switch(e){case"x402":return"Crypto (x402)";case"credits":return"Credits";case"stripe":return"Card";default:return"Payment"}}function $j({order:e,source:t,purchaseId:n,customerEmail:r,customerName:o,className:a,onBack:i}){const{config:c}=Ee(),l=t??e.source,d=n??e.purchaseId,f=r??e.customerEmail,u=o??e.customerName,h=c.brand?.name??"Store",g=c.brand?.logoUrl,y=()=>{typeof window<"u"&&window.print()},x=new Date(e.createdAt).toLocaleDateString(void 0,{year:"numeric",month:"long",day:"numeric"}),p=new Date(e.createdAt).toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"});return s.jsxs("div",{className:L("min-h-screen bg-neutral-100 dark:bg-neutral-900 print:bg-white print:dark:bg-white",a),children:[s.jsx("div",{className:"border-b border-neutral-200 bg-white px-4 py-3 dark:border-neutral-800 dark:bg-neutral-950 print:hidden",children:s.jsxs("div",{className:"mx-auto flex max-w-2xl items-center justify-between",children:[i?s.jsxs(ne,{type:"button",variant:"ghost",size:"sm",onClick:i,children:[s.jsx(Lj,{className:"mr-1"})," Back"]}):s.jsx("div",{}),s.jsxs(ne,{type:"button",variant:"outline",size:"sm",onClick:y,children:[s.jsx(Mj,{className:"mr-2"})," Print Receipt"]})]})}),s.jsx("div",{className:"mx-auto max-w-2xl px-4 py-8 print:max-w-none print:px-0 print:py-0",children:s.jsxs("div",{className:"rounded-xl border border-neutral-200 bg-white p-8 shadow-sm dark:border-neutral-800 dark:bg-neutral-950 print:border-0 print:shadow-none print:dark:bg-white print:dark:text-neutral-950",children:[s.jsxs("div",{className:"flex items-center justify-between border-b border-neutral-200 pb-6 dark:border-neutral-800 print:dark:border-neutral-200",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[g?s.jsx("img",{src:g,alt:h,className:"h-10 w-10 rounded-lg object-contain"}):null,s.jsx("div",{className:"text-xl font-semibold",children:h})]}),s.jsxs("div",{className:"text-right",children:[s.jsx("div",{className:"text-sm font-medium text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:"Receipt"}),s.jsx("div",{className:"mt-1 font-mono text-sm",children:e.id})]})]}),s.jsxs("div",{className:"mt-6 grid grid-cols-2 gap-4 text-sm sm:grid-cols-3",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:"Date"}),s.jsx("div",{className:"mt-1 font-medium",children:x}),s.jsx("div",{className:"text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:p})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:"Payment Method"}),s.jsx("div",{className:"mt-1 font-medium",children:Dj(l)})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:"Status"}),s.jsx("div",{className:"mt-1",children:s.jsx(vn,{variant:"outline",className:"capitalize print:border-neutral-300",children:e.status})})]})]}),(u||f)&&s.jsxs("div",{className:"mt-6 border-t border-neutral-200 pt-6 dark:border-neutral-800 print:dark:border-neutral-200",children:[s.jsx("div",{className:"text-sm text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:"Customer"}),u&&s.jsx("div",{className:"mt-1 font-medium",children:u}),f&&s.jsx("div",{className:"text-sm text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:f})]}),s.jsx("div",{className:"mt-6 border-t border-neutral-200 pt-6 dark:border-neutral-800 print:dark:border-neutral-200",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-neutral-200 dark:border-neutral-800 print:dark:border-neutral-200",children:[s.jsx("th",{className:"pb-3 text-left font-medium text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:"Item"}),s.jsx("th",{className:"pb-3 text-center font-medium text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:"Qty"}),s.jsx("th",{className:"pb-3 text-right font-medium text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:"Price"})]})}),s.jsx("tbody",{children:e.items.map((v,_)=>s.jsxs("tr",{className:"border-b border-neutral-100 dark:border-neutral-800/50 print:dark:border-neutral-100",children:[s.jsx("td",{className:"py-3",children:s.jsx("div",{className:"font-medium",children:v.title})}),s.jsx("td",{className:"py-3 text-center text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:v.qty}),s.jsx("td",{className:"py-3 text-right",children:Be({amount:v.unitPrice*v.qty,currency:v.currency})})]},`${v.title}-${_}`))})]})}),s.jsxs("div",{className:"mt-4 flex flex-col items-end gap-2 text-sm",children:[s.jsxs("div",{className:"flex w-48 justify-between",children:[s.jsx("span",{className:"text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:"Subtotal"}),s.jsx("span",{children:Be({amount:e.total,currency:e.currency})})]}),s.jsxs("div",{className:"flex w-48 justify-between border-t border-neutral-200 pt-2 text-base font-semibold dark:border-neutral-800 print:dark:border-neutral-200",children:[s.jsx("span",{children:"Total"}),s.jsx("span",{children:Be({amount:e.total,currency:e.currency})})]})]}),d&&s.jsxs("div",{className:"mt-6 border-t border-neutral-200 pt-6 dark:border-neutral-800 print:dark:border-neutral-200",children:[s.jsx("div",{className:"text-sm text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:"Transaction ID"}),s.jsx("div",{className:"mt-1 break-all font-mono text-xs",children:d})]}),s.jsxs("div",{className:"mt-8 border-t border-neutral-200 pt-6 text-center text-xs text-neutral-500 dark:border-neutral-800 dark:text-neutral-400 print:dark:border-neutral-200 print:dark:text-neutral-500",children:[s.jsx("p",{children:"Thank you for your purchase!"}),s.jsx("p",{className:"mt-1",children:"If you have any questions, please contact support."})]})]})})]})}function zj({className:e}){return s.jsx("svg",{className:L("h-4 w-4 flex-shrink-0",e),viewBox:"0 0 20 20",fill:"currentColor",children:s.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})})}function Fj({className:e,title:t="Choose Your Plan",subtitle:n="Select the plan that best fits your needs.",annualSavingsBadge:r="2 months free",popularBadgeText:o="Best Deal",footerNotice:a}){const{config:i}=Ee(),{tiers:c,status:l,isLoading:d,error:f}=Cl(),[u,h]=m.useState("monthly"),g=!!i.adapter.createSubscriptionCheckoutSession,y=async x=>{if(!i.adapter.createSubscriptionCheckoutSession)return;const p=await i.adapter.createSubscriptionCheckoutSession({tierId:x,interval:u,successUrl:i.checkout.successUrl,cancelUrl:i.checkout.cancelUrl});p.kind==="redirect"&&typeof window<"u"&&window.location.assign(p.url)};return s.jsx("div",{className:L("min-h-screen bg-neutral-50 text-neutral-950 dark:bg-neutral-950 dark:text-neutral-50",e),children:s.jsxs("main",{className:"mx-auto max-w-6xl px-4 py-16",children:[s.jsxs("div",{className:"text-center",children:[s.jsx("h1",{className:"text-5xl font-bold tracking-tight",children:t}),s.jsx("p",{className:"mt-4 text-base text-neutral-600 dark:text-neutral-400",children:n})]}),s.jsx("div",{className:"mt-10 flex justify-center",children:s.jsxs("div",{className:"inline-flex items-center rounded-full bg-neutral-200/60 p-1 dark:bg-neutral-800/60",children:[s.jsxs("button",{type:"button",onClick:()=>h("annual"),className:L("relative flex items-center gap-2 rounded-full px-4 py-2 text-sm font-medium transition-all",u==="annual"?"bg-neutral-900 text-white dark:bg-white dark:text-neutral-900":"text-neutral-600 hover:text-neutral-900 dark:text-neutral-400 dark:hover:text-white"),children:["Yearly",r&&s.jsx("span",{className:L("rounded-full px-2 py-0.5 text-xs font-medium",u==="annual"?"bg-white/20 text-white dark:bg-neutral-900/20 dark:text-neutral-900":"bg-neutral-900 text-white dark:bg-white dark:text-neutral-900"),children:r})]}),s.jsx("button",{type:"button",onClick:()=>h("monthly"),className:L("rounded-full px-4 py-2 text-sm font-medium transition-all",u==="monthly"?"bg-neutral-900 text-white dark:bg-white dark:text-neutral-900":"text-neutral-600 hover:text-neutral-900 dark:text-neutral-400 dark:hover:text-white"),children:"Monthly"})]})}),f?s.jsx(Bt,{className:"mt-10",description:f}):null,d?s.jsxs("div",{className:"mt-12 grid gap-6 md:grid-cols-3",children:[s.jsx(Re,{className:"h-[480px] rounded-2xl"}),s.jsx(Re,{className:"h-[480px] rounded-2xl"}),s.jsx(Re,{className:"h-[480px] rounded-2xl"})]}):c.length===0?s.jsx("div",{className:"mt-12",children:s.jsx(Bn,{title:"No plans available",description:"Subscription plans will appear here once configured."})}):s.jsx("div",{className:"mt-12 grid gap-6 md:grid-cols-3 items-start",children:c.map(x=>{const p=l?.isActive&&l.currentTierId===x.id,v=u==="annual"&&x.priceAnnual?x.priceAnnual:x.priceMonthly,_=x.isPopular,w=x.inventoryQuantity!=null,b=w?Math.max(0,(x.inventoryQuantity??0)-(x.inventorySold??0)):null,j=w&&b===0,R=w&&b!=null&&b>0&&b<=5,[I,...C]=x.features;return s.jsxs("div",{className:L("relative flex flex-col rounded-2xl border p-6 transition-shadow",_?"border-neutral-900 bg-neutral-900 text-white shadow-xl dark:border-white dark:bg-white dark:text-neutral-900":"border-neutral-200 bg-white dark:border-neutral-800 dark:bg-neutral-900"),children:[_&&o&&s.jsx("div",{className:"absolute -top-3 right-4",children:s.jsx("span",{className:"rounded-full bg-neutral-100 px-3 py-1 text-xs font-semibold text-neutral-900 shadow-sm dark:bg-neutral-800 dark:text-white",children:o})}),s.jsxs("div",{className:"mb-6",children:[s.jsx("h3",{className:"text-xl font-bold",children:x.title}),x.description&&s.jsx("p",{className:L("mt-2 text-sm leading-relaxed",_?"text-neutral-300 dark:text-neutral-600":"text-neutral-600 dark:text-neutral-400"),children:x.description})]}),s.jsxs("div",{className:"mb-6",children:[s.jsx("div",{className:"text-5xl font-bold tracking-tight",children:Be({amount:v,currency:x.currency||i.currency})}),s.jsxs("div",{className:L("mt-2 text-sm",_?"text-neutral-400 dark:text-neutral-500":"text-neutral-500 dark:text-neutral-400"),children:["Per ",u==="annual"?"year":"month",", billed ",u==="annual"?"annually":"monthly"]})]}),w&&s.jsx("div",{className:L("mb-3 text-xs font-medium",j?"text-red-600 dark:text-red-400":R?_?"text-amber-300 dark:text-amber-600":"text-amber-600 dark:text-amber-400":_?"text-neutral-400 dark:text-neutral-500":"text-neutral-500 dark:text-neutral-400"),children:j?"Sold out":`${b} remaining`}),s.jsx(ne,{type:"button",className:L("mb-6 w-full rounded-full py-3 font-medium",_?"bg-white text-neutral-900 hover:bg-neutral-100 dark:bg-neutral-900 dark:text-white dark:hover:bg-neutral-800":""),variant:_?"default":"outline",disabled:p||!g||j,onClick:()=>void y(x.id),children:j?"Sold Out":p?"Current Plan":"Purchase"}),I&&s.jsx("div",{className:L("mb-4 text-sm font-semibold",_?"":"text-neutral-900 dark:text-white"),children:I}),C.length>0&&s.jsx("ul",{className:"space-y-3",children:C.map((E,O)=>s.jsxs("li",{className:"flex items-start gap-3",children:[s.jsx(zj,{className:L("mt-0.5",_?"text-neutral-400 dark:text-neutral-500":"text-neutral-500 dark:text-neutral-400")}),s.jsx("span",{className:L("text-sm leading-relaxed",_?"text-neutral-300 dark:text-neutral-600":"text-neutral-600 dark:text-neutral-400"),children:E})]},O))})]},x.id)})}),a&&s.jsx("div",{className:"mt-12 text-center",children:s.jsx("p",{className:"text-xs text-neutral-500 dark:text-neutral-400 leading-relaxed max-w-2xl mx-auto",children:a})})]})})}function Uj(e){const{processCartCheckout:t}=Uf.useStripeCheckout();return m.useMemo(()=>({...e,async createCheckoutSession(n){const{customer:r,options:o}=n,a=r.shippingAddress?r.shippingAddress:void 0,i=r.billingAddress?r.billingAddress:void 0,c=await t(n.cart,o.successUrl,o.cancelUrl,o.metadata,r.email,o.discountCode,r.name,r.phone,a,i,o.tipAmount,o.shippingMethodId,o.paymentMethodId);if(!c.success)throw new Error(c.error||"Checkout failed");return{kind:"redirect",url:n.options.successUrl??"/"}},async resolveCheckoutReturn({query:n}){return ra(n)}}),[e,t])}const Bj=Object.freeze(Object.defineProperty({__proto__:null,Accordion:Qu,AccordionContent:fr,AccordionItem:dr,AccordionTrigger:ur,AddressForm:Ho,Badge:vn,Breadcrumbs:Ha,Button:ne,Card:Et,CardContent:Vt,CardDescription:ql,CardFooter:Gl,CardHeader:hr,CardTitle:gr,CartLineItem:qa,CartPageContent:Af,CartPanel:Sf,CartProvider:Rm,CartSidebar:kr,CartSummary:Ga,CartTemplate:Pj,CategoryNav:Wo,CategoryTemplate:Ej,CedrosShopProvider:dm,CheckoutCancelPage:wj,CheckoutForm:Tf,CheckoutLayout:Ef,CheckoutProvider:kl,CheckoutReceipt:Gs,CheckoutSuccessPage:bj,CheckoutTemplate:Rj,Dialog:Na,DialogClose:T_,DialogContent:Os,DialogDescription:Ia,DialogFooter:Nu,DialogHeader:Ea,DialogOverlay:Aa,DialogPortal:Cu,DialogTitle:Ms,DialogTrigger:I_,EmptyState:Bn,ErrorBoundary:uk,ErrorState:Bt,FAQItem:_f,FAQList:lj,FilterPanel:ms,Input:Fe,InventoryVerificationDialog:Pf,Label:st,OrderCard:Mf,OrderDetails:Df,OrderList:Lf,OrderReview:Of,PaymentStep:Rf,Price:Zs,ProductCard:kf,ProductGallery:Ua,ProductGrid:qs,ProductTemplate:Tj,PromoCodeInput:Ya,PurchaseHistoryTemplate:Oj,QuantitySelector:Va,QuickViewDialog:Wa,ReceiptTemplate:$j,SearchInput:Za,Select:ls,SelectContent:br,SelectGroup:u_,SelectItem:wr,SelectTrigger:yr,SelectValue:ds,Separator:yt,Sheet:Ls,SheetClose:Au,SheetContent:Nr,SheetDescription:Iu,SheetHeader:$s,SheetOverlay:Ta,SheetPortal:Eu,SheetTitle:zs,SheetTrigger:Ds,ShippingMethodSelector:If,ShopChatPanel:Nf,ShopTemplate:Nj,Skeleton:Re,SubscriptionTemplate:Fj,Tabs:za,TabsContent:xf,TabsList:Ws,TabsTrigger:_r,ToastProvider:Uk,VariantSelector:Ba,createMockCommerceAdapter:hm,createPaywallCommerceAdapter:Sm,parseCheckoutReturn:ra,readCatalogUrlState:oa,useAIRelatedProducts:Il,useCart:Pt,useCartInventory:ia,useCatalogUrlSync:aa,useCategories:na,useCedrosPayCheckoutAdapter:Uj,useCedrosShop:Ee,useCheckout:vs,useCheckoutResultFromUrl:sa,useHoldExpiry:jv,useInventoryVerification:Al,useOptionalToast:Hs,useOrders:Sl,usePaymentMethodsConfig:El,useProduct:jl,useProducts:ys,useShippingMethods:Nl,useStandaloneCheckout:hv,useStorefrontSettings:Wn,useSubscriptionData:Cl,useToast:Fk,validateCommerceAdapterContract:Ev},Symbol.toStringTag,{value:"Module"}));exports.CEDROS_PAY_GROUPS=lm;exports.CEDROS_PAY_SECTIONS=Fc;exports.CEDROS_PAY_SECTION_IDS=cm;exports.CedrosPayAdminDashboard=am;exports.CouponsSection=Mc;exports.ErrorBanner=jr;exports.FormDropdown=At;exports.Icons=Y;exports.ProductsSection=Rc;exports.RefundsSection=Lc;exports.SettingsSection=Dc;exports.StatsBar=Sr;exports.TransactionsSection=Oc;exports.cedrosPayPlugin=im;exports.formatDateTime=lr;exports.index=Bj;
|