@cedros/pay-react 1.1.25 → 1.1.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/dist/{AISettingsSection-Dg1kazTI.mjs → AISettingsSection-BlIv3CzS.mjs} +2 -2
  2. package/dist/{AISettingsSection-BvSSiK2G.js → AISettingsSection-DELur7D2.js} +1 -1
  3. package/dist/{AutosaveIndicator-BHfkV59p.mjs → AutosaveIndicator-Bed0-ekg.mjs} +1 -1
  4. package/dist/{AutosaveIndicator-D2l7U8R1.js → AutosaveIndicator-Dn_qA2hK.js} +1 -1
  5. package/dist/ChatLogsSection-BH5tLA4T.js +1 -0
  6. package/dist/ChatLogsSection-v4zwzCTC.mjs +201 -0
  7. package/dist/{ComplianceSection-BSE2f3Wo.mjs → ComplianceSection-CemgfDrL.mjs} +282 -166
  8. package/dist/ComplianceSection-DP2a9-S0.js +1 -0
  9. package/dist/CustomersSection-CBwy_waO.js +1 -0
  10. package/dist/CustomersSection-D_j7OrfS.mjs +207 -0
  11. package/dist/DisputesSection-BLjIk60n.js +1 -0
  12. package/dist/DisputesSection-BcAbXp3K.mjs +230 -0
  13. package/dist/{FAQSection-uZG5V3pJ.mjs → FAQSection-Dn38OhB_.mjs} +1 -1
  14. package/dist/{FAQSection-6nGI0FK9.js → FAQSection-wNeH0i6Q.js} +1 -1
  15. package/dist/ImagesSection-0ZzKlzMJ.js +1 -0
  16. package/dist/ImagesSection-Ctw9Icym.mjs +216 -0
  17. package/dist/InventorySection-DmhjUlRZ.mjs +150 -0
  18. package/dist/InventorySection-zV6lTmue.js +1 -0
  19. package/dist/{MessagingSection-M0lj5yo4.mjs → MessagingSection-B1FaGxkp.mjs} +2 -2
  20. package/dist/{MessagingSection-DrXb578q.js → MessagingSection-B_wdFR0j.js} +1 -1
  21. package/dist/{OrdersSection-DteItv_O.mjs → OrdersSection-Bj8bPdg8.mjs} +1 -1
  22. package/dist/{OrdersSection-_-rIw6XW.js → OrdersSection-Dw2FX-1d.js} +1 -1
  23. package/dist/{PaymentSettingsSection-enTbUI95.js → PaymentSettingsSection-BYF4D-GR.js} +1 -1
  24. package/dist/{PaymentSettingsSection-CdtdLFTg.mjs → PaymentSettingsSection-EnMxeWjv.mjs} +1 -1
  25. package/dist/ReturnsSection-BC0L8r2e.mjs +267 -0
  26. package/dist/ReturnsSection-D_pJVxuG.js +1 -0
  27. package/dist/{SettingsSection-mcT4LEhO.mjs → SettingsSection-KYdEizq_.mjs} +1 -1
  28. package/dist/{SettingsSection-DUTEd6uV.js → SettingsSection-vdYFSNxB.js} +1 -1
  29. package/dist/ShippingSection-1DRSTu49.js +1 -0
  30. package/dist/ShippingSection-BOgto6_9.mjs +434 -0
  31. package/dist/{SingleCategorySettings-D2LVM5mn.js → SingleCategorySettings-DwCnBdRf.js} +1 -1
  32. package/dist/{SingleCategorySettings-BvHBVfSe.mjs → SingleCategorySettings-suJ8z9d8.mjs} +2 -2
  33. package/dist/{StorefrontSection-BqQ36JIS.mjs → StorefrontSection-BRvIGBEJ.mjs} +2 -2
  34. package/dist/{StorefrontSection-Du7hV2Gc.js → StorefrontSection-RumGkb3C.js} +1 -1
  35. package/dist/{SubscriptionsSection-C4BRN1dP.js → SubscriptionsSection-C2aLLn7L.js} +1 -1
  36. package/dist/{SubscriptionsSection-BYiCBwKZ.mjs → SubscriptionsSection-D60qrX9a.mjs} +1 -1
  37. package/dist/TaxSection-C7-pv-Rl.mjs +294 -0
  38. package/dist/TaxSection-Dt1DnM51.js +1 -0
  39. package/dist/{Token22Section-BHvOhz5d.mjs → Token22Section-CrHLQ0EB.mjs} +1 -1
  40. package/dist/{Token22Section-0c22NM5G.js → Token22Section-DY3mUwTY.js} +1 -1
  41. package/dist/WebhooksSection-CKeiJ7Py.js +1 -0
  42. package/dist/WebhooksSection-COPW4Ec0.mjs +223 -0
  43. package/dist/crypto-only.js +1 -1
  44. package/dist/crypto-only.mjs +1 -1
  45. package/dist/index-C0g-JxJk.js +84 -0
  46. package/dist/{index-BkDimQDF.mjs → index-DXnuQp5x.mjs} +7068 -6768
  47. package/dist/index.js +1 -1
  48. package/dist/index.mjs +1 -1
  49. package/dist/{sections-By4H1baL.mjs → sections-C1NpK7hk.mjs} +2 -2
  50. package/dist/{sections-5jO2aHAo.js → sections-DVVSZBhW.js} +1 -1
  51. package/dist/src/components/ComplianceGatePage.d.ts +3 -1
  52. package/dist/src/components/ComplianceGatePage.d.ts.map +1 -1
  53. package/dist/src/components/admin/CedrosPayAdminDashboard.d.ts +1 -1
  54. package/dist/src/components/admin/CedrosPayAdminDashboard.d.ts.map +1 -1
  55. package/dist/src/components/admin/ChatLogsSection.d.ts +3 -0
  56. package/dist/src/components/admin/ChatLogsSection.d.ts.map +1 -0
  57. package/dist/src/components/admin/ComplianceKycTab.d.ts +3 -0
  58. package/dist/src/components/admin/ComplianceKycTab.d.ts.map +1 -0
  59. package/dist/src/components/admin/ComplianceRequirementsEditor.d.ts +8 -0
  60. package/dist/src/components/admin/ComplianceRequirementsEditor.d.ts.map +1 -0
  61. package/dist/src/components/admin/ComplianceSection.d.ts.map +1 -1
  62. package/dist/src/components/admin/CustomersSection.d.ts +3 -0
  63. package/dist/src/components/admin/CustomersSection.d.ts.map +1 -0
  64. package/dist/src/components/admin/DisputesSection.d.ts +3 -0
  65. package/dist/src/components/admin/DisputesSection.d.ts.map +1 -0
  66. package/dist/src/components/admin/ImagesSection.d.ts +3 -0
  67. package/dist/src/components/admin/ImagesSection.d.ts.map +1 -0
  68. package/dist/src/components/admin/InventorySection.d.ts +3 -0
  69. package/dist/src/components/admin/InventorySection.d.ts.map +1 -0
  70. package/dist/src/components/admin/NftMetadataPreview.d.ts +20 -0
  71. package/dist/src/components/admin/NftMetadataPreview.d.ts.map +1 -0
  72. package/dist/src/components/admin/ProductsSection.d.ts.map +1 -1
  73. package/dist/src/components/admin/ReturnsSection.d.ts +3 -0
  74. package/dist/src/components/admin/ReturnsSection.d.ts.map +1 -0
  75. package/dist/src/components/admin/ShippingSection.d.ts +3 -0
  76. package/dist/src/components/admin/ShippingSection.d.ts.map +1 -0
  77. package/dist/src/components/admin/TaxSection.d.ts +3 -0
  78. package/dist/src/components/admin/TaxSection.d.ts.map +1 -0
  79. package/dist/src/components/admin/WebhooksSection.d.ts +3 -0
  80. package/dist/src/components/admin/WebhooksSection.d.ts.map +1 -0
  81. package/dist/src/components/admin/complianceTypes.d.ts +15 -1
  82. package/dist/src/components/admin/complianceTypes.d.ts.map +1 -1
  83. package/dist/src/ecommerce/adapters/CommerceAdapter.d.ts +36 -0
  84. package/dist/src/ecommerce/adapters/CommerceAdapter.d.ts.map +1 -1
  85. package/dist/src/ecommerce/adapters/paywall/paywallAdapter.d.ts.map +1 -1
  86. package/dist/src/ecommerce/components/chat/ShopChatPanel.d.ts +8 -5
  87. package/dist/src/ecommerce/components/chat/ShopChatPanel.d.ts.map +1 -1
  88. package/dist/src/ecommerce/index.d.ts +2 -2
  89. package/dist/src/ecommerce/index.d.ts.map +1 -1
  90. package/dist/src/hooks/useComplianceCheck.d.ts +1 -1
  91. package/dist/src/hooks/useComplianceCheck.d.ts.map +1 -1
  92. package/package.json +1 -1
  93. package/dist/ComplianceSection-D6ETKG6b.js +0 -1
  94. package/dist/index-C7MWL6O8.js +0 -84
@@ -0,0 +1,84 @@
1
+ "use strict";const r=require("react/jsx-runtime"),b=require("react"),Jm=require("@solana/wallet-adapter-react"),Ie=require("./CedrosContext-C2RjHLaQ.js"),Xm=require("@cedros/login-react"),ef=require("./index-WcOlBYZJ.js"),ta=require("react-dom"),tf=require("./styles-BT4bhFey.js");function Bc(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,s.get?s:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const f=Bc(b),ws=Bc(ta);function mr(e){return new Date(e).toLocaleString()}const Z={products:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M20 7.5v9l-4 2.25M4 7.5v9l4 2.25"}),r.jsx("path",{d:"m20 7.5-8-4.5-8 4.5"}),r.jsx("path",{d:"m12 12 8-4.5M12 12v9.5M12 12 4 7.5"})]}),transactions:r.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M12 2v20M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"})}),coupons:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.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"}),r.jsx("path",{d:"M13 5v2M13 17v2M13 11v2"})]}),refunds:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),r.jsx("path",{d:"M3 3v5h5"}),r.jsx("path",{d:"M12 7v5l4 2"})]}),settings:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.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"}),r.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),wallet:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.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"}),r.jsx("path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"})]}),chevronRight:r.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"m9 18 6-6-6-6"})}),loading:r.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:r.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),refresh:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"}),r.jsx("path",{d:"M21 3v5h-5"}),r.jsx("path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"}),r.jsx("path",{d:"M8 16H3v5"})]}),user:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"12",cy:"8",r:"5"}),r.jsx("path",{d:"M20 21a8 8 0 0 0-16 0"})]}),check:r.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M20 6 9 17l-5-5"})}),subscriptions:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"}),r.jsx("circle",{cx:"12",cy:"12",r:"3"}),r.jsx("path",{d:"M12 2v2M12 20v2M2 12H4M20 12h2"})]}),trash:r.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.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:r.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M12 5v14M5 12h14"})}),chevronDown:r.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"m6 9 6 6 6-6"})}),chevronUp:r.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"m18 15-6-6-6 6"})}),storefront:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M3 9h18v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V9Z"}),r.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"}),r.jsx("path",{d:"M12 3v6"})]}),arrowUp:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"m5 12 7-7 7 7"}),r.jsx("path",{d:"M12 19V5"})]}),arrowDown:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"m5 12 7 7 7-7"}),r.jsx("path",{d:"M12 5v14"})]}),delete:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.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"}),r.jsx("path",{d:"M10 11v6M14 11v6"})]}),close:r.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M18 6 6 18M6 6l12 12"})}),edit:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),r.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:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"12",cy:"12",r:"10"}),r.jsx("path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"}),r.jsx("path",{d:"M12 17h.01"})]}),chat:r.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"m3 21 1.9-5.7a8.5 8.5 0 1 1 3.8 3.8z"})}),globe:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"12",cy:"12",r:"10"}),r.jsx("path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"}),r.jsx("path",{d:"M2 12h20"})]}),ai:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M12 2a4 4 0 0 1 4 4v2a4 4 0 0 1-8 0V6a4 4 0 0 1 4-4Z"}),r.jsx("path",{d:"M10 10v.5"}),r.jsx("path",{d:"M14 10v.5"}),r.jsx("path",{d:"M12 14v2"}),r.jsx("path",{d:"M8 18h8"}),r.jsx("path",{d:"M6 18a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2"}),r.jsx("path",{d:"M6 12v6"}),r.jsx("path",{d:"M18 12v6"})]}),notifications:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9"}),r.jsx("path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0"})]}),eye:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"}),r.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),eyeOff:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M9.88 9.88a3 3 0 1 0 4.24 4.24"}),r.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"}),r.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"}),r.jsx("line",{x1:"2",x2:"22",y1:"2",y2:"22"})]}),creditCard:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{width:"20",height:"14",x:"2",y:"5",rx:"2"}),r.jsx("line",{x1:"2",x2:"22",y1:"10",y2:"10"})]}),mail:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{width:"20",height:"16",x:"2",y:"4",rx:"2"}),r.jsx("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]}),server:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2"}),r.jsx("rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2"}),r.jsx("line",{x1:"6",x2:"6.01",y1:"6",y2:"6"}),r.jsx("line",{x1:"6",x2:"6.01",y1:"18",y2:"18"})]}),calendarRepeat:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",ry:"2"}),r.jsx("line",{x1:"16",x2:"16",y1:"2",y2:"6"}),r.jsx("line",{x1:"8",x2:"8",y1:"2",y2:"6"}),r.jsx("line",{x1:"3",x2:"21",y1:"10",y2:"10"}),r.jsx("path",{d:"M11 14h1.5a1.5 1.5 0 0 1 0 3H11v2"}),r.jsx("path",{d:"M16 14v3a1 1 0 0 0 1 1h1"})]}),shield:r.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"})}),brain:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.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"}),r.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"}),r.jsx("path",{d:"M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4"}),r.jsx("path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375"}),r.jsx("path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5"}),r.jsx("path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396"}),r.jsx("path",{d:"M19.938 10.5a4 4 0 0 1 .585.396"}),r.jsx("path",{d:"M6 18a4 4 0 0 1-1.967-.516"}),r.jsx("path",{d:"M19.967 17.484A4 4 0 0 1 18 18"})]})};function Vn({message:e,onRetry:t}){return e?r.jsxs("div",{className:"cedros-admin__error-banner",children:[r.jsx("span",{children:e}),t&&r.jsxs("button",{type:"button",className:"cedros-admin__error-banner-retry",onClick:t,children:[Z.refresh," Retry"]})]}):null}function Nr({stats:e,isLoading:t=!1,onRefresh:n}){return r.jsxs("div",{className:"cedros-admin__stats-bar",children:[r.jsx("div",{className:"cedros-admin__stats-bar-grid",children:e.map((s,o)=>r.jsxs("div",{className:"cedros-admin__stats-bar-item",children:[r.jsx("span",{className:"cedros-admin__stats-bar-label",children:s.label}),r.jsx("span",{className:`cedros-admin__stats-bar-value ${s.variant?`cedros-admin__stats-bar-value--${s.variant}`:""}`,children:t?r.jsx("span",{className:"cedros-admin__skeleton cedros-admin__skeleton--value"}):s.value}),s.description&&r.jsx("span",{className:"cedros-admin__stats-bar-desc",children:s.description})]},o))}),n&&r.jsx("button",{type:"button",className:"cedros-admin__stats-bar-refresh",onClick:n,disabled:t,title:"Refresh stats",children:t?Z.loading:Z.refresh})]})}function nf({serverUrl:e,productId:t,apiKey:n,authManager:s}){const[o,a]=b.useState(null),[i,c]=b.useState(!1),[l,u]=b.useState(!1),[m,d]=b.useState(null),x=b.useCallback(async()=>{if(t){c(!0),d(null);try{let p;if(s?.isAuthenticated())p=await s.fetchWithAuth(`/admin/products/${t}/variations`);else{const g={"Content-Type":"application/json"};n&&(g["X-API-Key"]=n);const y=await fetch(`${e}/admin/products/${t}/variations`,{headers:g});if(!y.ok)throw new Error(`Failed to fetch variations: ${y.status}`);p=await y.json()}p.variationConfig||(p.variationConfig={variationTypes:[]}),p.variants||(p.variants=[]),a(p)}catch(p){const g=p instanceof Error?p.message:"Failed to fetch variations";d(g),a({productId:t,variationConfig:{variationTypes:[]},variants:[]})}finally{c(!1)}}},[e,t,n,s]),h=b.useCallback(async p=>{if(!t)return null;u(!0),d(null);try{let g;if(s?.isAuthenticated())g=await s.fetchWithAuth(`/admin/products/${t}/variations`,{method:"PUT",body:JSON.stringify(p)});else{const y={"Content-Type":"application/json"};n&&(y["X-API-Key"]=n);const w=await fetch(`${e}/admin/products/${t}/variations`,{method:"PUT",headers:y,body:JSON.stringify(p)});if(!w.ok)throw new Error(`Failed to save variations: ${w.status}`);g=await w.json()}return a({productId:t,variationConfig:g.variationConfig,variants:g.variants}),{variantsCreated:g.variantsCreated}}catch(g){const y=g instanceof Error?g.message:"Failed to save variations";return d(y),null}finally{u(!1)}},[e,t,n,s]),v=b.useCallback(async p=>{if(!t||p.length===0)return!1;u(!0),d(null);try{if(s?.isAuthenticated())await s.fetchWithAuth(`/admin/products/${t}/variants/inventory`,{method:"PUT",body:JSON.stringify({updates:p})});else{const g={"Content-Type":"application/json"};n&&(g["X-API-Key"]=n);const y=await fetch(`${e}/admin/products/${t}/variants/inventory`,{method:"PUT",headers:g,body:JSON.stringify({updates:p})});if(!y.ok)throw new Error(`Failed to update inventory: ${y.status}`)}if(o){const g=new Map(p.map(y=>[y.variantId,y]));a({...o,variants:o.variants.map(y=>{const w=g.get(y.id);return w?{...y,inventoryQuantity:w.inventoryQuantity,inventoryStatus:w.inventoryStatus??y.inventoryStatus}:y})})}return!0}catch(g){const y=g instanceof Error?g.message:"Failed to update inventory";return d(y),!1}finally{u(!1)}},[e,t,n,s,o]);return{data:o,isLoading:i,error:m,fetch:x,save:h,bulkUpdateInventory:v,isSaving:l}}function hi(){return`var_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function rf({value:e,onChange:t,maxTypes:n=5,maxValuesPerType:s=20,disabled:o=!1}){const[a,i]=b.useState(null),[c,l]=b.useState(""),[u,m]=b.useState({}),d=e.variationTypes,x=b.useCallback(()=>{if(!c.trim()||d.length>=n)return;const j={id:hi(),name:c.trim(),displayOrder:d.length,values:[]};t({variationTypes:[...d,j]}),l(""),i(j.id)},[c,d,n,t]),h=b.useCallback(j=>{t({variationTypes:d.filter(k=>k.id!==j).map((k,_)=>({...k,displayOrder:_}))}),a===j&&i(null)},[d,t,a]),v=b.useCallback((j,k)=>{t({variationTypes:d.map(_=>_.id===j?{..._,name:k}:_)})},[d,t]),p=b.useCallback((j,k)=>{const _=d.findIndex(E=>E.id===j);if(_===-1||k==="up"&&_===0||k==="down"&&_===d.length-1)return;const S=[...d],A=k==="up"?_-1:_+1;[S[_],S[A]]=[S[A],S[_]],t({variationTypes:S.map((E,I)=>({...E,displayOrder:I}))})},[d,t]),g=b.useCallback(j=>{const k=(u[j]||"").trim();if(!k)return;const _=d.find(A=>A.id===j);if(!_||_.values.length>=s)return;const S={id:hi(),label:k};t({variationTypes:d.map(A=>A.id===j?{...A,values:[...A.values,S]}:A)}),m(A=>({...A,[j]:""}))},[d,u,s,t]),y=b.useCallback((j,k)=>{t({variationTypes:d.map(_=>_.id===j?{..._,values:_.values.filter(S=>S.id!==k)}:_)})},[d,t]),w=b.useCallback((j,k,_)=>{t({variationTypes:d.map(S=>S.id===j?{...S,values:S.values.map(A=>A.id===k?{...A,label:_}:A)}:S)})},[d,t]);return r.jsxs("div",{className:"cedros-admin__variation-editor",children:[r.jsxs("div",{className:"cedros-admin__variation-editor-header",children:[r.jsx("h4",{className:"cedros-admin__field-label",style:{marginBottom:0},children:"Variation Types"}),r.jsxs("span",{style:{fontSize:12,opacity:.7},children:[d.length,"/",n," types"]})]}),d.length===0?r.jsx("div",{className:"cedros-admin__variation-empty",children:'No variation types defined. Add types like "Size" or "Color" to create product variants.'}):r.jsx("div",{className:"cedros-admin__variation-type-list",children:d.map((j,k)=>r.jsxs("div",{className:"cedros-admin__variation-type-item",children:[r.jsxs("div",{className:"cedros-admin__variation-type-header",children:[r.jsxs("div",{className:"cedros-admin__variation-type-controls",children:[r.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--icon",onClick:()=>p(j.id,"up"),disabled:o||k===0,title:"Move up",children:Z.arrowUp}),r.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--icon",onClick:()=>p(j.id,"down"),disabled:o||k===d.length-1,title:"Move down",children:Z.arrowDown})]}),r.jsx("input",{type:"text",className:"cedros-admin__input cedros-admin__variation-type-name",value:j.name,onChange:_=>v(j.id,_.target.value),disabled:o,placeholder:"Type name"}),r.jsxs("span",{className:"cedros-admin__variation-value-count",children:[j.values.length," values"]}),r.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>i(a===j.id?null:j.id),children:a===j.id?"Collapse":"Edit values"}),r.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--danger",onClick:()=>h(j.id),disabled:o,title:"Remove type",children:Z.delete})]}),a===j.id&&r.jsxs("div",{className:"cedros-admin__variation-values",children:[r.jsxs("div",{className:"cedros-admin__variation-values-header",children:[r.jsxs("span",{style:{fontSize:12,fontWeight:600},children:['Values for "',j.name,'"']}),r.jsxs("span",{style:{fontSize:11,opacity:.7},children:[j.values.length,"/",s]})]}),j.values.length===0?r.jsx("div",{className:"cedros-admin__variation-empty",style:{padding:"8px 0"},children:'No values yet. Add values like "Small", "Medium", "Large".'}):r.jsx("div",{className:"cedros-admin__variation-value-list",children:j.values.map(_=>r.jsxs("div",{className:"cedros-admin__variation-value-item",children:[r.jsx("input",{type:"text",className:"cedros-admin__input cedros-admin__input--sm",value:_.label,onChange:S=>w(j.id,_.id,S.target.value),disabled:o}),r.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--icon cedros-admin__button--danger",onClick:()=>y(j.id,_.id),disabled:o,title:"Remove value",children:Z.close})]},_.id))}),j.values.length<s&&r.jsxs("div",{className:"cedros-admin__variation-add-value",children:[r.jsx("input",{type:"text",className:"cedros-admin__input cedros-admin__input--sm",value:u[j.id]||"",onChange:_=>m(S=>({...S,[j.id]:_.target.value})),placeholder:"Add value...",disabled:o,onKeyDown:_=>{_.key==="Enter"&&(_.preventDefault(),g(j.id))}}),r.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--secondary cedros-admin__button--sm",onClick:()=>g(j.id),disabled:o||!u[j.id]?.trim(),children:"Add"})]})]})]},j.id))}),d.length<n&&r.jsxs("div",{className:"cedros-admin__variation-add-type",children:[r.jsx("input",{type:"text",className:"cedros-admin__input",value:c,onChange:j=>l(j.target.value),placeholder:"New variation type (e.g., Size, Color)",disabled:o,onKeyDown:j=>{j.key==="Enter"&&(j.preventDefault(),x())}}),r.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--secondary",onClick:x,disabled:o||!c.trim(),children:"Add Type"})]})]})}function Vc({value:e,onChange:t,options:n,placeholder:s="Filter",disabled:o}){const[a,i]=b.useState(!1),c=b.useRef(null),u=n.find(m=>m.value===e)?.label||s;return b.useEffect(()=>{const m=d=>{c.current&&!c.current.contains(d.target)&&i(!1)};if(a)return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[a]),b.useEffect(()=>{const m=d=>{d.key==="Escape"&&i(!1)};if(a)return document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)},[a]),r.jsxs("div",{className:"cedros-admin__dropdown",ref:c,children:[r.jsxs("button",{type:"button",className:"cedros-admin__dropdown-trigger",onClick:()=>!o&&i(!a),"aria-expanded":a,"aria-haspopup":"listbox",disabled:o,children:[r.jsx("span",{children:u}),r.jsx("span",{className:`cedros-admin__dropdown-chevron ${a?"cedros-admin__dropdown-chevron--open":""}`,children:Z.chevronDown})]}),a&&r.jsx("div",{className:"cedros-admin__dropdown-menu",role:"listbox",children:n.map(m=>r.jsxs("button",{type:"button",className:`cedros-admin__dropdown-item ${m.value===e?"cedros-admin__dropdown-item--selected":""}`,onClick:()=>{m.disabled||(t(m.value),i(!1))},role:"option","aria-selected":m.value===e,disabled:m.disabled,children:[m.label,m.value===e&&r.jsx("span",{className:"cedros-admin__dropdown-check",children:Z.check})]},m.value))})]})}function Ct({value:e,onChange:t,options:n,label:s,description:o,disabled:a,className:i,style:c}){const[l,u]=b.useState(!1),m=b.useRef(null),x=n.find(h=>h.value===e)?.label||"Select...";return b.useEffect(()=>{const h=v=>{m.current&&!m.current.contains(v.target)&&u(!1)};if(l)return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[l]),b.useEffect(()=>{const h=v=>{v.key==="Escape"&&u(!1)};if(l)return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[l]),r.jsxs("div",{className:`cedros-admin__field ${i||""}`,style:c,children:[r.jsx("label",{className:"cedros-admin__field-label",children:s}),r.jsxs("div",{className:"cedros-admin__dropdown cedros-admin__dropdown--form",ref:m,children:[r.jsxs("button",{type:"button",className:"cedros-admin__dropdown-trigger cedros-admin__dropdown-trigger--form",onClick:()=>!a&&u(!l),"aria-expanded":l,"aria-haspopup":"listbox",disabled:a,children:[r.jsx("span",{children:x}),r.jsx("span",{className:`cedros-admin__dropdown-chevron ${l?"cedros-admin__dropdown-chevron--open":""}`,children:Z.chevronDown})]}),l&&r.jsx("div",{className:"cedros-admin__dropdown-menu cedros-admin__dropdown-menu--form",role:"listbox",children:n.map(h=>r.jsxs("button",{type:"button",className:`cedros-admin__dropdown-item ${h.value===e?"cedros-admin__dropdown-item--selected":""}`,onClick:()=>{h.disabled||(t(h.value),u(!1))},role:"option","aria-selected":h.value===e,disabled:h.disabled,children:[h.label,h.value===e&&r.jsx("span",{className:"cedros-admin__dropdown-check",children:Z.check})]},h.value))})]}),o&&r.jsx("p",{className:"cedros-admin__field-description",children:o})]})}function gi(){return`variant_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function sf(e){if(e.length===0)return[];const t=[...e].sort((s,o)=>s.displayOrder-o.displayOrder),n=(s,o)=>{if(s>=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[s],i=[];for(const c of a.values)i.push(...n(s+1,{valueIds:[...o.valueIds,c.id],options:{...o.options,[a.name]:c.label}}));return i};return n(0,{valueIds:[],options:{}})}function of(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 af({variationConfig:e,variants:t,onChange:n,defaultPrice:s=0,currencySymbol:o="$",maxVariants:a=100,disabled:i=!1}){const c=b.useMemo(()=>sf(e.variationTypes),[e.variationTypes]),l=b.useMemo(()=>{const p=new Map;for(const g of t)p.set(of(g),g);return p},[t]),{existingRows:u,possibleRows:m}=b.useMemo(()=>{const p=[],g=[];for(const y of c){const w=l.get(y.key);w?p.push({combo:y,variant:w}):g.push(y)}return{existingRows:p,possibleRows:g}},[c,l]),d=b.useCallback((p,g)=>{n(t.map(y=>y.id===p?{...y,...g}:y))},[t,n]),x=b.useCallback(p=>{n(t.filter(g=>g.id!==p))},[t,n]),h=b.useCallback(p=>{if(t.length>=a)return;const g={id:gi(),title:p.title,options:p.options,optionValueIds:p.optionValueIds,price:s,inventoryQuantity:0,inventoryStatus:"in_stock",autoGenerated:!1};n([...t,g])},[t,n,a,s]),v=b.useCallback(()=>{const p=a-t.length,y=m.slice(0,p).map(w=>({id:gi(),title:w.title,options:w.options,optionValueIds:w.optionValueIds,price:s,inventoryQuantity:0,inventoryStatus:"in_stock",autoGenerated:!0}));n([...t,...y])},[t,n,m,a,s]);return e.variationTypes.length===0?r.jsx("div",{className:"cedros-admin__variant-grid-empty",children:"Add variation types above to create product variants."}):c.length===0?r.jsx("div",{className:"cedros-admin__variant-grid-empty",children:"Add values to your variation types to create product variants."}):r.jsxs("div",{className:"cedros-admin__variant-grid",children:[r.jsxs("div",{className:"cedros-admin__variant-grid-header",children:[r.jsx("h4",{className:"cedros-admin__field-label",style:{marginBottom:0},children:"Variants"}),r.jsxs("span",{style:{fontSize:12,opacity:.7},children:[t.length,"/",a," variants (",c.length," ","possible)"]})]}),m.length>0&&t.length<a&&r.jsxs("div",{className:"cedros-admin__variant-grid-actions",children:[r.jsxs("button",{type:"button",className:"cedros-admin__button cedros-admin__button--secondary",onClick:v,disabled:i,children:["Generate All (",Math.min(m.length,a-t.length),")"]}),r.jsx("span",{style:{fontSize:11,opacity:.7},children:"Creates variants with default price and 0 inventory"})]}),r.jsx("div",{className:"cedros-admin__table-container",children:r.jsxs("table",{className:"cedros-admin__table cedros-admin__variant-table",children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{children:"Variant"}),r.jsx("th",{style:{width:100},children:"Price"}),r.jsx("th",{style:{width:80},children:"Qty"}),r.jsx("th",{style:{width:100},children:"SKU"}),r.jsx("th",{style:{width:100},children:"Status"}),r.jsx("th",{style:{width:80},children:"Actions"})]})}),r.jsxs("tbody",{children:[u.map(({combo:p,variant:g})=>r.jsxs("tr",{children:[r.jsx("td",{children:r.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[r.jsx("span",{style:{fontWeight:600},children:p.title}),r.jsx("span",{style:{fontSize:11,opacity:.6},children:Object.entries(p.options).map(([y,w])=>`${y}: ${w}`).join(", ")})]})}),r.jsx("td",{children:r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[r.jsx("span",{children:o}),r.jsx("input",{type:"number",className:"cedros-admin__input cedros-admin__input--sm",value:g.price??"",onChange:y=>d(g.id,{price:y.target.value===""?void 0:parseFloat(y.target.value)||0}),disabled:i,min:"0",step:"0.01",style:{width:70}})]})}),r.jsx("td",{children:r.jsx("input",{type:"number",className:"cedros-admin__input cedros-admin__input--sm",value:g.inventoryQuantity??"",onChange:y=>d(g.id,{inventoryQuantity:y.target.value===""?void 0:parseInt(y.target.value)||0}),disabled:i,min:"0",style:{width:60}})}),r.jsx("td",{children:r.jsx("input",{type:"text",className:"cedros-admin__input cedros-admin__input--sm",value:g.sku??"",onChange:y=>d(g.id,{sku:y.target.value||void 0}),disabled:i,placeholder:"SKU",style:{width:80}})}),r.jsx("td",{children:r.jsx(Vc,{value:g.inventoryStatus??"in_stock",onChange:y=>d(g.id,{inventoryStatus:y}),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})}),r.jsx("td",{children:r.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--icon cedros-admin__button--danger",onClick:()=>x(g.id),disabled:i,title:"Remove variant",children:Z.trash})})]},g.id)),m.length>0&&t.length<a&&r.jsxs(r.Fragment,{children:[r.jsx("tr",{className:"cedros-admin__variant-separator",children:r.jsx("td",{colSpan:6,children:r.jsxs("span",{style:{fontSize:11,opacity:.6},children:["Uncreated combinations (",m.length,")"]})})}),m.slice(0,10).map(p=>r.jsxs("tr",{className:"cedros-admin__variant-possible",children:[r.jsx("td",{children:r.jsx("span",{style:{opacity:.6},children:p.title})}),r.jsx("td",{colSpan:4,style:{opacity:.5},children:"Not created"}),r.jsx("td",{children:r.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--icon",onClick:()=>h(p),disabled:i,title:"Create variant",children:Z.plus})})]},p.key)),m.length>10&&r.jsx("tr",{className:"cedros-admin__variant-more",children:r.jsxs("td",{colSpan:6,style:{textAlign:"center",opacity:.6},children:["+",m.length-10," more combinations"]})})]})]})]})})]})}function cf({serverUrl:e,productId:t,productTitle:n,defaultPrice:s=0,currencySymbol:o="$",apiKey:a,authManager:i,onClose:c}){const{data:l,isLoading:u,error:m,fetch:d,save:x,isSaving:h}=nf({serverUrl:e,productId:t,apiKey:a,authManager:i}),[v,p]=b.useState({variationTypes:[]}),[g,y]=b.useState([]),[w,j]=b.useState(!1),[k,_]=b.useState(!1);b.useEffect(()=>{d()},[d]),b.useEffect(()=>{l&&(p(l.variationConfig),y(l.variants),j(!1))},[l]);const S=b.useCallback(I=>{p(I),j(!0),_(!1)},[]),A=b.useCallback(I=>{y(I),j(!0),_(!1)},[]),E=b.useCallback(async()=>{const I=new Set((l?.variants??[]).map(z=>z.id)),T=g.filter(z=>!I.has(z.id)),U=g.filter(z=>I.has(z.id)),L=(l?.variants??[]).filter(z=>!g.some(K=>K.id===z.id)).map(z=>z.id);await x({variationConfig:v,createVariants:T.map(z=>({optionValueIds:z.optionValueIds??[],inventoryQuantity:z.inventoryQuantity,sku:z.sku,price:z.price})),updateVariants:U.map(z=>({id:z.id,inventoryQuantity:z.inventoryQuantity,sku:z.sku,price:z.price,inventoryStatus:z.inventoryStatus})),deleteVariantIds:L.length>0?L:void 0})&&(j(!1),_(!0),setTimeout(()=>_(!1),3e3))},[v,g,l?.variants,x]);return u?r.jsxs("div",{className:"cedros-admin__variations-editor",children:[r.jsxs("div",{className:"cedros-admin__variations-editor-header",children:[r.jsx("h3",{className:"cedros-admin__section-title",children:n?`Variations: ${n}`:"Product Variations"}),c&&r.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost",onClick:c,children:Z.close})]}),r.jsxs("div",{className:"cedros-admin__loading",children:[Z.loading," Loading variations..."]})]}):r.jsxs("div",{className:"cedros-admin__variations-editor",children:[r.jsxs("div",{className:"cedros-admin__variations-editor-header",children:[r.jsx("h3",{className:"cedros-admin__section-title",children:n?`Variations: ${n}`:"Product Variations"}),r.jsxs("div",{className:"cedros-admin__variations-editor-actions",children:[k&&r.jsxs("span",{className:"cedros-admin__success-text",children:[Z.check," Saved"]}),w&&r.jsx("span",{className:"cedros-admin__unsaved-text",children:"Unsaved changes"}),r.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--primary",onClick:E,disabled:h||!w,children:h?"Saving...":"Save Changes"}),c&&r.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost",onClick:c,children:Z.close})]})]}),m&&r.jsx("div",{className:"cedros-admin__error-banner",children:m}),r.jsxs("div",{className:"cedros-admin__variations-editor-content",children:[r.jsx("div",{className:"cedros-admin__variations-editor-section",children:r.jsx(rf,{value:v,onChange:S,disabled:h})}),v.variationTypes.length>0&&r.jsx("div",{className:"cedros-admin__variations-editor-section",children:r.jsx(af,{variationConfig:v,variants:g,onChange:A,defaultPrice:s,currencySymbol:o,disabled:h})})]})]})}const xi={requireSanctionsClear:!0,requireKyc:!1,requireAccreditedInvestor:!1,tokenGates:[]};function lf({value:e,onChange:t}){const[n,s]=b.useState(e!==null),[o,a]=b.useState(""),[i,c]=b.useState("fungible_token"),[l,u]=b.useState(1),m=e??xi,d=()=>{e?(t(null),s(!1)):(t({...xi}),s(!0))},x=p=>{t({...m,...p})},h=()=>{if(!o.trim())return;const p={address:o.trim(),gateType:i,minAmount:l},g=[...m.tokenGates??[],p];x({tokenGates:g}),a(""),u(1)},v=p=>{const g=(m.tokenGates??[]).filter((y,w)=>w!==p);x({tokenGates:g.length>0?g:[]})};return r.jsxs("div",{style:{border:"1px solid var(--cedros-admin-border, #e0e0e0)",borderRadius:"4px",padding:"0.75rem",marginTop:"0.5rem"},children:[r.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",fontSize:"0.9rem",fontWeight:600,cursor:"pointer"},children:[r.jsx("input",{type:"checkbox",checked:e!==null,onChange:d}),"Enable compliance gates"]}),e!==null&&n&&r.jsxs("div",{style:{marginTop:"0.75rem",display:"flex",flexDirection:"column",gap:"0.5rem"},children:[r.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",fontSize:"0.85rem"},children:[r.jsx("input",{type:"checkbox",checked:m.requireSanctionsClear,onChange:p=>x({requireSanctionsClear:p.target.checked})}),"Require sanctions clearance"]}),r.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",fontSize:"0.85rem"},children:[r.jsx("input",{type:"checkbox",checked:m.requireKyc,onChange:p=>x({requireKyc:p.target.checked})}),"Require KYC verification"]}),r.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",fontSize:"0.85rem"},children:[r.jsx("input",{type:"checkbox",checked:m.requireAccreditedInvestor,onChange:p=>x({requireAccreditedInvestor:p.target.checked})}),"Require accredited investor status"]}),r.jsxs("div",{style:{marginTop:"0.5rem"},children:[r.jsx("span",{style:{fontSize:"0.85rem",fontWeight:600},children:"Token Gates"}),(m.tokenGates??[]).length>0&&r.jsx("div",{style:{marginTop:"0.25rem"},children:(m.tokenGates??[]).map((p,g)=>r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",fontSize:"0.8rem",padding:"0.25rem 0"},children:[r.jsxs("code",{style:{fontSize:"0.75rem"},children:[p.address.slice(0,8),"..."]}),r.jsx("span",{className:"cedros-admin__badge cedros-admin__badge--muted",children:p.gateType==="fungible_token"?"Fungible":"NFT"}),r.jsxs("span",{children:["min: ",p.minAmount]}),r.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",onClick:()=>v(g),style:{padding:"0 0.25rem"},children:"×"})]},g))}),r.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"flex-end",marginTop:"0.25rem",flexWrap:"wrap"},children:[r.jsx("input",{type:"text",className:"cedros-admin__input",placeholder:"Mint or collection address",value:o,onChange:p=>a(p.target.value),style:{flex:1,minWidth:"200px",fontSize:"0.8rem"}}),r.jsxs("select",{className:"cedros-admin__input",value:i,onChange:p=>c(p.target.value),style:{width:"auto",fontSize:"0.8rem"},children:[r.jsx("option",{value:"fungible_token",children:"Fungible"}),r.jsx("option",{value:"nft_collection",children:"NFT"})]}),r.jsx("input",{type:"number",className:"cedros-admin__input",min:1,value:l,onChange:p=>u(Number(p.target.value)),style:{width:"80px",fontSize:"0.8rem"}}),r.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",onClick:h,disabled:!o.trim(),children:"Add Gate"})]})]})]})]})}function df({serverUrl:e,productId:t,productTitle:n,apiKey:s,authManager:o,onClose:a}){const[i,c]=b.useState(null),[l,u]=b.useState(!0),[m,d]=b.useState(null),x=b.useCallback(async()=>{u(!0),d(null);try{const h=`/paywall/v1/products/${encodeURIComponent(t)}/nft-metadata`;let v;if(o?.isAuthenticated())v=await o.fetchWithAuth(h);else{const p={"Content-Type":"application/json"};s&&(p["X-API-Key"]=s);const g=await fetch(`${e}${h}`,{headers:p});if(!g.ok)throw new Error(`Request failed: ${g.status}`);v=await g.json()}c(v)}catch{d("Failed to load NFT metadata. Ensure this product exists and the server is running.")}finally{u(!1)}},[e,t,s,o]);return b.useEffect(()=>{x()},[x]),r.jsxs("div",{children:[r.jsxs("div",{className:"cedros-admin__section-header",style:{marginBottom:"1rem"},children:[r.jsxs("h3",{className:"cedros-admin__section-title",style:{fontSize:"1rem"},children:["NFT Metadata — ",n]}),r.jsxs("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost",onClick:a,children:[Z.close," Close"]})]}),r.jsx(Vn,{message:m,onRetry:x}),l?r.jsxs("div",{className:"cedros-admin__loading",children:[Z.loading," Loading metadata..."]}):i?r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[r.jsxs("div",{style:{display:"flex",gap:"1rem",padding:"1rem",border:"1px solid var(--cedros-admin-border, #e0e0e0)",borderRadius:"8px"},children:[i.image&&r.jsx("img",{src:i.image,alt:i.name,style:{width:120,height:120,borderRadius:8,objectFit:"cover",flexShrink:0}}),r.jsxs("div",{style:{flex:1},children:[r.jsx("h4",{style:{margin:"0 0 0.25rem",fontSize:"1rem",fontWeight:600},children:i.name}),r.jsx("p",{style:{margin:"0 0 0.5rem",fontSize:"0.85rem",color:"var(--cedros-admin-text-muted, #888)"},children:i.description}),i.external_url&&r.jsxs("p",{style:{margin:"0 0 0.5rem",fontSize:"0.8rem"},children:[r.jsx("strong",{children:"URL:"})," ",r.jsx("code",{children:i.external_url})]}),i.attributes.length>0&&r.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"0.5rem"},children:i.attributes.map(h=>r.jsxs("div",{style:{padding:"0.25rem 0.5rem",border:"1px solid var(--cedros-admin-border, #e0e0e0)",borderRadius:"4px",fontSize:"0.8rem"},children:[r.jsxs("span",{style:{color:"var(--cedros-admin-text-muted, #888)"},children:[h.trait_type,":"]})," ",r.jsx("strong",{children:h.value})]},h.trait_type))})]})]}),r.jsxs("div",{children:[r.jsx("h4",{style:{margin:"0 0 0.5rem",fontSize:"0.85rem",fontWeight:600},children:"Raw JSON (stored on-chain URI)"}),r.jsx("pre",{style:{background:"var(--cedros-admin-bg-muted, #f5f5f5)",border:"1px solid var(--cedros-admin-border, #e0e0e0)",borderRadius:"4px",padding:"0.75rem",fontSize:"0.8rem",overflow:"auto",maxHeight:"300px"},children:JSON.stringify(i,null,2)})]})]}):null]})}function Wc({serverUrl:e,apiKey:t,pageSize:n=20,authManager:s}){const[o,a]=b.useState([]),[i,c]=b.useState(!0),[l,u]=b.useState(!1),[m,d]=b.useState(!1),[x,h]=b.useState(null),[v,p]=b.useState(null),[g,y]=b.useState(null),[w,j]=b.useState(null),[k,_]=b.useState(null),[S,A]=b.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:"",giftCardConfig:null,tokenizedAssetConfig:null,complianceRequirements:null}),E=N=>{const R=N.tagsCsv.split(",").map(de=>de.trim()).filter(Boolean),F=N.categoryIdsCsv.split(",").map(de=>de.trim()).filter(Boolean),Q={email:N.checkoutEmail,name:N.checkoutName,phone:N.checkoutPhone,shippingAddress:N.checkoutShippingAddress,billingAddress:N.checkoutBillingAddress},Y=N.fulfillmentType==="shipping"?"physical":"digital",ce={title:N.title,slug:N.slug||N.id,shipping_profile:Y,inventory_status:N.inventoryStatus,checkout_requirements:JSON.stringify(Q),fulfillment_type:N.fulfillmentType};N.imageUrl&&(ce.image_url=N.imageUrl);const P=N.compareAtUsd?Math.round(Number(N.compareAtUsd)*100):0;P&&(ce.compare_at_amount_cents=String(P)),R.length&&(ce.tags=JSON.stringify(R)),F.length&&(ce.category_ids=JSON.stringify(F)),N.fulfillmentNotes&&(ce.fulfillment_notes=N.fulfillmentNotes);const H=N.shippingCountriesCsv.split(",").map(de=>de.trim().toUpperCase()).filter(Boolean);return H.length&&(ce.shippingCountries=H.join(","),ce.shipping_countries=H.join(",")),ce},[I,T]=b.useState([]),U=N=>N.metadata?.title||N.description||N.id,L=N=>N.metadata?.image_url,B=b.useCallback(async()=>{try{_(null);let N;if(s?.isAuthenticated())N=await s.fetchWithAuth(`/admin/products?limit=${n}`);else{const R={"Content-Type":"application/json"};t&&(R["X-API-Key"]=t);const F=await fetch(`${e}/admin/products?limit=${n}`,{headers:R});if(!F.ok)throw new Error(`Failed to fetch products: ${F.status}`);N=await F.json()}a(N.products||[])}catch{a([]),_("Failed to load products")}finally{c(!1)}},[e,t,n,s]);b.useEffect(()=>{B(),(async()=>{try{let N;if(s?.isAuthenticated())N=await s.fetchWithAuth("/admin/collections");else{const R={"Content-Type":"application/json"};t&&(R["X-API-Key"]=t);const F=await fetch(`${e}/admin/collections`,{headers:R});if(!F.ok)return;N=await F.json()}T((N.collections||[]).filter(R=>R.tokenizationConfig).map(R=>({id:R.id,name:R.name})))}catch{}})()},[B,e,t,s]);const z=async N=>{if(N.preventDefault(),!(!S.id||!S.description)){if(h(null),S.fulfillmentType==="shipping"&&S.checkoutShippingAddress&&!S.shippingCountriesCsv.split(",").map(F=>F.trim()).filter(Boolean).length){h("Shipping countries are required when collecting shipping address. Example: US,CA");return}d(!0);try{const{productType:R}=S,F=S.inventoryQuantity===""?void 0:Number.isFinite(Number(S.inventoryQuantity))?Number(S.inventoryQuantity):void 0,Q=Number(S.priceUsd)||0,Y=Math.round(Q*100),ce=Math.round(Q*1e6),P={id:S.id,description:S.description,fiatAmountCents:Y,fiatCurrency:S.fiatCurrency,cryptoAtomicAmount:ce,cryptoToken:S.cryptoToken,...F!==void 0?{inventoryQuantity:F}:{},metadata:{...R?{product_type:R}:{},...E(S)}};if(R==="gift_card"&&S.giftCardConfig&&(P.giftCardConfig=S.giftCardConfig),R==="tokenized_asset"&&S.tokenizedAssetConfig&&(P.tokenizedAssetConfig=S.tokenizedAssetConfig),S.complianceRequirements&&(P.complianceRequirements=S.complianceRequirements),s?.isAuthenticated())await s.fetchWithAuth("/admin/products",{method:"POST",body:JSON.stringify(P)});else{const H={"Content-Type":"application/json"};t&&(H["X-API-Key"]=t);const de=await fetch(`${e}/admin/products`,{method:"POST",headers:H,body:JSON.stringify(P)});if(!de.ok)throw new Error(`Failed to create product: ${de.status}`)}A({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:"",giftCardConfig:null,tokenizedAssetConfig:null,complianceRequirements:null}),u(!1),B()}catch(R){h(R instanceof Error?R.message:"Failed to create product")}finally{d(!1)}}},K=N=>`$${(N/100).toFixed(2)}`,V=N=>{switch(N){case"subscription":return"Subscription";case"pay_per_access":return"Pay per access";case"one_time":return"One-time purchase";case"gift_card":return"Gift card";default:return"One-time purchase"}},G=b.useMemo(()=>{const N=o.filter(F=>F.active).length,R=o.reduce((F,Q)=>{const Y=Q.variations?.length??0;return F+(Y>0?Y:1)},0);return{activeCount:N,totalSkus:R}},[o]),D=N=>{j(R=>!R||R.key!==N?{key:N,direction:"asc"}:{key:N,direction:R.direction==="asc"?"desc":"asc"})},se=N=>!w||w.key!==N?r.jsx("span",{className:"cedros-admin__sort-icon cedros-admin__sort-icon--idle",children:Z.chevronUp}):r.jsx("span",{className:"cedros-admin__sort-icon",children:w.direction==="asc"?Z.chevronUp:Z.chevronDown}),le=b.useMemo(()=>{if(!w)return o;const N=w.direction==="asc"?1:-1,R=F=>{switch(w.key){case"product":return U(F);case"type":return V(F.metadata?.product_type);case"price":return F.fiatAmountCents??0;case"status":return F.active?1:0;case"id":default:return F.id}};return[...o].sort((F,Q)=>{const Y=R(F),ce=R(Q);return typeof Y=="number"&&typeof ce=="number"?(Y-ce)*N:String(Y).localeCompare(String(ce),void 0,{sensitivity:"base"})*N})},[o,w]);return r.jsxs("div",{className:"cedros-admin__page",children:[r.jsx(Vn,{message:k,onRetry:B}),r.jsx(Nr,{stats:[{label:"Total Products",value:o.length},{label:"Active",value:G.activeCount,variant:G.activeCount>0?"success":"muted"},{label:"Total SKUs",value:G.totalSkus}],isLoading:i}),r.jsxs("div",{className:"cedros-admin__section-header",children:[r.jsx("h3",{className:"cedros-admin__section-title",children:"Paywall Products"}),r.jsxs("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--action",onClick:()=>{h(null),u(!l)},children:[l?Z.close:Z.plus,l?"Cancel":"Add Product"]})]}),l&&r.jsxs("form",{onSubmit:z,className:"cedros-admin__add-form",children:[x&&r.jsx("div",{style:{marginBottom:"0.75rem",color:"#B42318",fontWeight:600},children:x}),r.jsxs("div",{className:"cedros-admin__form-row",children:[r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Product ID"}),r.jsx("input",{type:"text",className:"cedros-admin__input",value:S.id,onChange:N=>A(R=>({...R,id:N.target.value})),placeholder:"e.g., premium-article",required:!0})]}),r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Product name"}),r.jsx("input",{type:"text",className:"cedros-admin__input",value:S.title,onChange:N=>A(R=>({...R,title:N.target.value})),placeholder:"e.g., Cedros Hoodie"})]})]}),r.jsxs("div",{className:"cedros-admin__form-row",children:[r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Slug"}),r.jsx("input",{type:"text",className:"cedros-admin__input",value:S.slug,onChange:N=>A(R=>({...R,slug:N.target.value})),placeholder:"e.g., cedros-hoodie (defaults to ID)"})]}),r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Primary image URL"}),r.jsx("input",{type:"url",className:"cedros-admin__input",value:S.imageUrl,onChange:N=>A(R=>({...R,imageUrl:N.target.value})),placeholder:"https://..."})]})]}),r.jsx("div",{className:"cedros-admin__form-row",children:r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Short description"}),r.jsx("input",{type:"text",className:"cedros-admin__input",value:S.description,onChange:N=>A(R=>({...R,description:N.target.value})),placeholder:"e.g., Midweight fleece with relaxed fit",required:!0})]})}),r.jsxs("div",{className:"cedros-admin__form-row",children:[r.jsx(Ct,{value:S.productType,onChange:N=>A(R=>({...R,productType:N,giftCardConfig:N==="gift_card"?R.giftCardConfig??{faceValueCents:0,currency:"usd",secondaryMarket:!1,expiresInDays:null}:null,tokenizedAssetConfig:N==="tokenized_asset"?R.tokenizedAssetConfig??{assetClassCollectionId:"",backingValueCents:0,backingCurrency:"usd",assetIdentifier:"",tokensPerUnit:1,custodyProofUrl:null}:null})),options:[{value:"one_time",label:"One-time purchase"},{value:"pay_per_access",label:"Pay per access"},{value:"subscription",label:"Subscription"},{value:"gift_card",label:"Gift card"},{value:"tokenized_asset",label:"Tokenized asset"}],label:"Product Type"}),r.jsx(Ct,{value:S.fulfillmentType,onChange:N=>{const R=N;A(F=>({...F,fulfillmentType:R,checkoutShippingAddress:R==="shipping"?F.checkoutShippingAddress:!1}))},options:[{value:"shipping",label:"Physical (shipped)"},{value:"digital_download",label:"Digital download"},{value:"service",label:"Service"}],label:"Fulfillment"})]}),S.productType==="gift_card"&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"cedros-admin__form-row",children:[r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Gift card face value (USD cents)"}),r.jsx("input",{type:"number",className:"cedros-admin__input",value:S.giftCardConfig?.faceValueCents??"",onChange:N=>A(R=>({...R,giftCardConfig:{faceValueCents:parseInt(N.target.value)||0,currency:R.giftCardConfig?.currency??"usd",secondaryMarket:R.giftCardConfig?.secondaryMarket??!1,expiresInDays:R.giftCardConfig?.expiresInDays??null}})),placeholder:"e.g., 5000 for $50.00",min:"1",required:!0}),r.jsx("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:"Face value in cents (e.g. 5000 = $50.00). Must be greater than 0."})]}),r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Gift card currency"}),r.jsx("input",{type:"text",className:"cedros-admin__input",value:S.giftCardConfig?.currency??"",onChange:N=>A(R=>({...R,giftCardConfig:{faceValueCents:R.giftCardConfig?.faceValueCents??0,currency:N.target.value.toLowerCase().slice(0,3),secondaryMarket:R.giftCardConfig?.secondaryMarket??!1,expiresInDays:R.giftCardConfig?.expiresInDays??null}})),placeholder:"usd",maxLength:3,required:!0}),r.jsx("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:"ISO 4217 3-letter currency code (e.g. usd, eur, gbp)."})]})]}),r.jsxs("div",{className:"cedros-admin__form-row",children:[r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Expiration (days)"}),r.jsx("input",{type:"number",className:"cedros-admin__input",value:S.giftCardConfig?.expiresInDays??"",onChange:N=>A(R=>({...R,giftCardConfig:{faceValueCents:R.giftCardConfig?.faceValueCents??0,currency:R.giftCardConfig?.currency??"usd",secondaryMarket:R.giftCardConfig?.secondaryMarket??!1,expiresInDays:N.target.value===""?null:parseInt(N.target.value)||0}})),placeholder:"Leave blank for no expiry",min:"0"}),r.jsx("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:"Number of days until gift card expires. Leave blank for no expiry."})]}),r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Secondary market (Token-22)"}),r.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginTop:8},children:[r.jsx("input",{type:"checkbox",checked:S.giftCardConfig?.secondaryMarket??!1,onChange:N=>A(R=>({...R,giftCardConfig:{faceValueCents:R.giftCardConfig?.faceValueCents??0,currency:R.giftCardConfig?.currency??"usd",secondaryMarket:N.target.checked,expiresInDays:R.giftCardConfig?.expiresInDays??null}}))}),"Enable Token-22 secondary market trading"]}),r.jsx("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:"Mints store credit tokens to recipient's embedded wallet for peer-to-peer trading with transfer fees."})]})]})]}),S.productType==="tokenized_asset"&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"cedros-admin__form-row",children:[r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Asset class collection"}),I.length>0?r.jsxs("select",{className:"cedros-admin__input",value:S.tokenizedAssetConfig?.assetClassCollectionId??"",onChange:N=>A(R=>({...R,tokenizedAssetConfig:{...R.tokenizedAssetConfig,assetClassCollectionId:N.target.value}})),required:!0,children:[r.jsx("option",{value:"",children:"Select asset class..."}),I.map(N=>r.jsx("option",{value:N.id,children:N.name},N.id))]}):r.jsx("input",{type:"text",className:"cedros-admin__input",value:S.tokenizedAssetConfig?.assetClassCollectionId??"",onChange:N=>A(R=>({...R,tokenizedAssetConfig:{...R.tokenizedAssetConfig,assetClassCollectionId:N.target.value}})),placeholder:"Collection ID of the asset class",required:!0})]}),r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Backing value (cents)"}),r.jsx("input",{type:"number",className:"cedros-admin__input",value:S.tokenizedAssetConfig?.backingValueCents??0,onChange:N=>A(R=>({...R,tokenizedAssetConfig:{...R.tokenizedAssetConfig,backingValueCents:Number(N.target.value)}})),min:0})]})]}),r.jsxs("div",{className:"cedros-admin__form-row",children:[r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Backing currency"}),r.jsx("input",{type:"text",className:"cedros-admin__input",value:S.tokenizedAssetConfig?.backingCurrency??"usd",onChange:N=>A(R=>({...R,tokenizedAssetConfig:{...R.tokenizedAssetConfig,backingCurrency:N.target.value}})),placeholder:"usd",maxLength:3})]}),r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Asset identifier"}),r.jsx("input",{type:"text",className:"cedros-admin__input",value:S.tokenizedAssetConfig?.assetIdentifier??"",onChange:N=>A(R=>({...R,tokenizedAssetConfig:{...R.tokenizedAssetConfig,assetIdentifier:N.target.value}})),placeholder:"e.g., ISIN, lot number"})]})]}),r.jsxs("div",{className:"cedros-admin__form-row",children:[r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Tokens per unit"}),r.jsx("input",{type:"number",className:"cedros-admin__input",value:S.tokenizedAssetConfig?.tokensPerUnit??1,onChange:N=>A(R=>({...R,tokenizedAssetConfig:{...R.tokenizedAssetConfig,tokensPerUnit:Number(N.target.value)}})),min:1})]}),r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Custody proof URL"}),r.jsx("input",{type:"text",className:"cedros-admin__input",value:S.tokenizedAssetConfig?.custodyProofUrl??"",onChange:N=>A(R=>({...R,tokenizedAssetConfig:{...R.tokenizedAssetConfig,custodyProofUrl:N.target.value||null}})),placeholder:"https://..."})]})]})]}),S.fulfillmentType==="shipping"&&r.jsxs("div",{className:"cedros-admin__form-row",children:[r.jsx(Ct,{value:S.inventoryStatus,onChange:N=>A(R=>({...R,inventoryStatus:N})),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"}),r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Inventory quantity (tracked)"}),r.jsx("input",{type:"number",className:"cedros-admin__input",value:S.inventoryQuantity,onChange:N=>A(R=>({...R,inventoryQuantity:N.target.value===""?"":parseInt(N.target.value)||0})),placeholder:"Leave blank for untracked",min:"0"})]}),r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Compare-at price (USD)"}),r.jsx("input",{type:"number",className:"cedros-admin__input",value:S.compareAtUsd===""?"":S.compareAtUsd,onChange:N=>A(R=>({...R,compareAtUsd:N.target.value===""?"":parseFloat(N.target.value)||0})),placeholder:"e.g., 78.00",min:"0",step:"0.01"})]})]}),r.jsx("div",{className:"cedros-admin__form-row",children:r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Price (USD)"}),r.jsx("input",{type:"number",className:"cedros-admin__input",value:S.priceUsd===""?"":S.priceUsd,onChange:N=>A(R=>({...R,priceUsd:N.target.value===""?"":parseFloat(N.target.value)||0})),placeholder:"e.g., 5.00",min:"0",step:"0.01",required:!0})]})}),r.jsxs("div",{className:"cedros-admin__form-row",children:[r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Tags (comma-separated)"}),r.jsx("input",{type:"text",className:"cedros-admin__input",value:S.tagsCsv,onChange:N=>A(R=>({...R,tagsCsv:N.target.value})),placeholder:"e.g., core, new, gift"})]}),r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Category IDs (comma-separated)"}),r.jsx("input",{type:"text",className:"cedros-admin__input",value:S.categoryIdsCsv,onChange:N=>A(R=>({...R,categoryIdsCsv:N.target.value})),placeholder:"e.g., cat_apparel, cat_accessories"})]})]}),r.jsxs("div",{className:"cedros-admin__form-row",children:[r.jsx(Ct,{value:S.checkoutEmail,onChange:N=>A(R=>({...R,checkoutEmail:N})),options:[{value:"none",label:"None"},{value:"optional",label:"Optional"},{value:"required",label:"Required"}],label:"Checkout: Email"}),r.jsx(Ct,{value:S.checkoutName,onChange:N=>A(R=>({...R,checkoutName:N})),options:[{value:"none",label:"None"},{value:"optional",label:"Optional"},{value:"required",label:"Required"}],label:"Checkout: Name"}),r.jsx(Ct,{value:S.checkoutPhone,onChange:N=>A(R=>({...R,checkoutPhone:N})),options:[{value:"none",label:"None"},{value:"optional",label:"Optional"},{value:"required",label:"Required"}],label:"Checkout: Phone"})]}),r.jsxs("div",{className:"cedros-admin__form-row",children:[S.fulfillmentType==="shipping"&&r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Checkout: Shipping address"}),r.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[r.jsx("input",{type:"checkbox",checked:S.checkoutShippingAddress,onChange:N=>A(R=>({...R,checkoutShippingAddress:N.target.checked}))}),"Collect shipping address"]})]}),r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Checkout: Billing address"}),r.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[r.jsx("input",{type:"checkbox",checked:S.checkoutBillingAddress,onChange:N=>A(R=>({...R,checkoutBillingAddress:N.target.checked}))}),"Collect billing address"]})]})]}),r.jsx("div",{className:"cedros-admin__form-row",children:r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Fulfillment notes"}),r.jsx("input",{type:"text",className:"cedros-admin__input",value:S.fulfillmentNotes,onChange:N=>A(R=>({...R,fulfillmentNotes:N.target.value})),placeholder:S.fulfillmentType==="shipping"?"e.g., Ships within 3-5 business days":"e.g., Downloadable from your account after purchase"})]})}),S.fulfillmentType==="shipping"&&S.checkoutShippingAddress&&r.jsx("div",{className:"cedros-admin__form-row",children:r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Shipping countries"}),r.jsx("input",{type:"text",className:"cedros-admin__input",value:S.shippingCountriesCsv,onChange:N=>A(R=>({...R,shippingCountriesCsv:N.target.value})),placeholder:"e.g., US,CA"}),r.jsx("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:"ISO 2-letter country codes, comma-separated. Required for shipping address collection."})]})}),r.jsx(lf,{value:S.complianceRequirements,onChange:N=>A(R=>({...R,complianceRequirements:N}))}),r.jsx("div",{className:"cedros-admin__form-actions",children:r.jsx("button",{type:"submit",className:"cedros-admin__button cedros-admin__button--primary",disabled:m,children:m?"Creating...":"Create Product"})})]}),i?r.jsxs("div",{className:"cedros-admin__loading",children:[Z.loading," Loading products..."]}):r.jsx("div",{className:"cedros-admin__table-container",children:r.jsxs("table",{className:"cedros-admin__table",children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{"aria-sort":w?.key==="id"?w?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>D("id"),children:["ID",se("id")]})}),r.jsx("th",{"aria-sort":w?.key==="product"?w?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>D("product"),children:["Product",se("product")]})}),r.jsx("th",{"aria-sort":w?.key==="type"?w?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>D("type"),children:["Type",se("type")]})}),r.jsx("th",{"aria-sort":w?.key==="price"?w?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>D("price"),children:["Price",se("price")]})}),r.jsx("th",{"aria-sort":w?.key==="status"?w?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>D("status"),children:["Status",se("status")]})}),r.jsx("th",{children:"Actions"})]})}),r.jsx("tbody",{children:le.map(N=>r.jsxs("tr",{children:[r.jsx("td",{children:r.jsx("code",{children:N.id})}),r.jsx("td",{children:r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[L(N)?r.jsx("img",{src:L(N),alt:"",style:{width:28,height:28,borderRadius:6,objectFit:"cover"}}):r.jsx("div",{style:{width:28,height:28,borderRadius:6,background:"rgba(0,0,0,0.06)"}}),r.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[r.jsx("span",{style:{fontWeight:600},children:U(N)}),r.jsx("span",{style:{opacity:.8},children:N.description})]})]})}),r.jsx("td",{children:V(N.metadata?.product_type)}),r.jsx("td",{children:K(N.fiatAmountCents)}),r.jsx("td",{children:r.jsx("span",{className:`cedros-admin__badge ${N.active?"cedros-admin__badge--success":"cedros-admin__badge--muted"}`,children:N.active?"Active":"Inactive"})}),r.jsx("td",{children:r.jsxs("div",{style:{display:"flex",gap:"0.25rem"},children:[r.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>p(N),children:"Variations"}),N.metadata?.product_type==="tokenized_asset"&&r.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>y(N),children:"NFT"})]})})]},N.id))})]})}),v&&r.jsx("div",{className:"cedros-admin__modal-overlay",onClick:()=>p(null),children:r.jsx("div",{className:"cedros-admin__modal cedros-admin__modal--lg",onClick:N=>N.stopPropagation(),children:r.jsx(cf,{serverUrl:e,productId:v.id,productTitle:U(v),defaultPrice:v.fiatAmountCents/100,apiKey:t,authManager:s,onClose:()=>p(null)})})}),g&&r.jsx("div",{className:"cedros-admin__modal-overlay",onClick:()=>y(null),children:r.jsx("div",{className:"cedros-admin__modal cedros-admin__modal--lg",onClick:N=>N.stopPropagation(),children:r.jsx(df,{serverUrl:e,productId:g.id,productTitle:U(g),apiKey:t,authManager:s,onClose:()=>y(null)})})})]})}function qc({serverUrl:e,apiKey:t,pageSize:n=20,authManager:s}){const[o,a]=b.useState([]),[i,c]=b.useState(null),[l,u]=b.useState(!0),[m,d]=b.useState(!0),[x,h]=b.useState(null),[v,p]=b.useState(""),[g,y]=b.useState(null),w=b.useCallback(async()=>{d(!0);try{h(null);let E;if(s?.isAuthenticated())E=await s.fetchWithAuth("/admin/stats");else{const I={"Content-Type":"application/json"};t&&(I["X-API-Key"]=t);const T=await fetch(`${e}/admin/stats`,{headers:I});if(!T.ok)throw new Error(`Failed to fetch stats: ${T.status}`);E=await T.json()}c(E)}catch{c(null),h("Failed to load payment stats")}finally{d(!1)}},[e,t,s]);b.useEffect(()=>{w()},[w]);const j=b.useCallback(async()=>{try{h(null);let E;const I=new URLSearchParams({limit:n.toString()});v&&I.set("method",v);const T=`/admin/transactions?${I}`;if(s?.isAuthenticated())E=await s.fetchWithAuth(T);else{const U={"Content-Type":"application/json"};t&&(U["X-API-Key"]=t);const L=await fetch(`${e}${T}`,{headers:U});if(!L.ok)throw new Error(`Failed to fetch transactions: ${L.status}`);E=await L.json()}a(E.transactions||[])}catch{a([]),h("Failed to load transactions")}finally{u(!1)}},[e,t,n,v,s]);b.useEffect(()=>{j()},[j]);const k=(E,I="USD")=>new Intl.NumberFormat("en-US",{style:"currency",currency:I}).format(E),_=E=>{y(I=>!I||I.key!==E?{key:E,direction:"asc"}:{key:E,direction:I.direction==="asc"?"desc":"asc"})},S=E=>!g||g.key!==E?r.jsx("span",{className:"cedros-admin__sort-icon cedros-admin__sort-icon--idle",children:Z.chevronUp}):r.jsx("span",{className:"cedros-admin__sort-icon",children:g.direction==="asc"?Z.chevronUp:Z.chevronDown}),A=b.useMemo(()=>{if(!g)return o;const E=g.direction==="asc"?1:-1,I=T=>{switch(g.key){case"resource":return T.resourceId;case"method":return T.method;case"amount":return T.amount;case"status":return T.status;case"date":return new Date(T.paidAt).getTime();case"id":default:return T.id}};return[...o].sort((T,U)=>{const L=I(T),B=I(U);return typeof L=="number"&&typeof B=="number"?(L-B)*E:String(L).localeCompare(String(B),void 0,{sensitivity:"base"})*E})},[o,g]);return r.jsxs("div",{className:"cedros-admin__page",children:[r.jsx(Vn,{message:x,onRetry:()=>{w(),j()}}),r.jsx(Nr,{stats:[{label:"Revenue",value:k(i?.totalRevenue??0)},{label:"Orders",value:i?.totalTransactions??0},{label:"Card",value:k(i?.revenueByMethod.stripe??0),description:`${i?.transactionsByMethod.stripe??0} orders`},{label:"Crypto",value:k(i?.revenueByMethod.x402??0),description:`${i?.transactionsByMethod.x402??0} orders`},{label:"Credits",value:k(i?.revenueByMethod.credits??0),description:`${i?.transactionsByMethod.credits??0} orders`}],isLoading:m,onRefresh:w}),r.jsxs("div",{className:"cedros-admin__section-header",children:[r.jsx("h3",{className:"cedros-admin__section-title",children:"Transaction History"}),r.jsx(Vc,{value:v,onChange:p,options:[{value:"",label:"All"},{value:"stripe",label:"Card"},{value:"x402",label:"Crypto"},{value:"credits",label:"Credits"}]})]}),l?r.jsxs("div",{className:"cedros-admin__loading",children:[Z.loading," Loading transactions..."]}):r.jsx("div",{className:"cedros-admin__table-container",children:r.jsxs("table",{className:"cedros-admin__table",children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{"aria-sort":g?.key==="id"?g?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>_("id"),children:["ID",S("id")]})}),r.jsx("th",{"aria-sort":g?.key==="resource"?g?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>_("resource"),children:["Resource",S("resource")]})}),r.jsx("th",{"aria-sort":g?.key==="method"?g?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>_("method"),children:["Method",S("method")]})}),r.jsx("th",{"aria-sort":g?.key==="amount"?g?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>_("amount"),children:["Amount",S("amount")]})}),r.jsx("th",{"aria-sort":g?.key==="status"?g?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>_("status"),children:["Status",S("status")]})}),r.jsx("th",{"aria-sort":g?.key==="date"?g?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>_("date"),children:["Date",S("date")]})})]})}),r.jsx("tbody",{children:A.map(E=>r.jsxs("tr",{children:[r.jsx("td",{children:r.jsx("code",{children:E.id})}),r.jsx("td",{children:E.resourceId}),r.jsx("td",{children:r.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${E.method}`,children:E.method})}),r.jsxs("td",{children:["$",E.amount.toFixed(2)," ",E.currency.toUpperCase()]}),r.jsx("td",{children:r.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${E.status}`,children:E.status})}),r.jsx("td",{children:mr(E.paidAt)})]},E.id))})]})})]})}function Hc({serverUrl:e,apiKey:t,pageSize:n=20,authManager:s}){const[o,a]=b.useState([]),[i,c]=b.useState(!0),[l,u]=b.useState(!1),[m,d]=b.useState(!1),[x,h]=b.useState(null),[v,p]=b.useState(null),[g,y]=b.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}),w=b.useCallback(async()=>{try{p(null);let I;const T=`/admin/coupons?limit=${n}`;if(s?.isAuthenticated())I=await s.fetchWithAuth(T);else{const U={"Content-Type":"application/json"};t&&(U["X-API-Key"]=t);const L=await fetch(`${e}${T}`,{headers:U});if(!L.ok)throw new Error(`Failed to fetch coupons: ${L.status}`);I=await L.json()}a(I.coupons||[])}catch(I){Ie.getLogger().error("[CouponsSection] Failed to fetch coupons:",I,{serverUrl:e.slice(0,20)+"...",hasApiKey:!!t}),a([]),p("Failed to load coupons")}finally{c(!1)}},[e,t,n,s]);b.useEffect(()=>{w()},[w]);const j=async I=>{if(I.preventDefault(),!(!g.code||g.discountValue<=0)){d(!0);try{const T=g.minimumAmountUsd?Math.round(Number(g.minimumAmountUsd)*100):void 0,U=g.productIdsCsv.split(",").map(z=>z.trim()).filter(Boolean),L=g.categoryIdsCsv.split(",").map(z=>z.trim()).filter(Boolean),B={code:g.code,discountType:g.discountType,discountValue:g.discountValue,usageLimit:g.usageLimit,active:!0,usageCount:0,scope:g.scope,...U.length?{productIds:U}:{},...L.length?{categoryIds:L}:{},...g.paymentMethod!=="any"?{paymentMethod:g.paymentMethod}:{},...g.autoApply?{autoApply:!0}:{},...g.appliesAt!=="both"?{appliesAt:g.appliesAt}:{},...g.startsAt?{startsAt:g.startsAt}:{},...g.expiresAt?{expiresAt:g.expiresAt}:{},...T?{minimumAmountCents:T}:{},...g.usageLimitPerCustomer?{usageLimitPerCustomer:g.usageLimitPerCustomer}:{},...g.firstPurchaseOnly?{firstPurchaseOnly:!0}:{}};if(s?.isAuthenticated())await s.fetchWithAuth("/admin/coupons",{method:"POST",body:JSON.stringify(B)});else{const z={"Content-Type":"application/json"};t&&(z["X-API-Key"]=t);const K=await fetch(`${e}/admin/coupons`,{method:"POST",headers:z,body:JSON.stringify(B)});if(!K.ok)throw new Error(`Failed to create coupon: ${K.status}`)}y({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}),u(!1),w()}catch(T){Ie.getLogger().error("[CouponsSection] Failed to add coupon:",T,{serverUrl:e.slice(0,20)+"...",hasApiKey:!!t}),p("Failed to create coupon")}finally{d(!1)}}},k=o.filter(I=>I.active).length,_=o.reduce((I,T)=>I+(T.usageCount??0),0),S=I=>{h(T=>!T||T.key!==I?{key:I,direction:"asc"}:{key:I,direction:T.direction==="asc"?"desc":"asc"})},A=I=>!x||x.key!==I?r.jsx("span",{className:"cedros-admin__sort-icon cedros-admin__sort-icon--idle",children:Z.chevronUp}):r.jsx("span",{className:"cedros-admin__sort-icon",children:x.direction==="asc"?Z.chevronUp:Z.chevronDown}),E=b.useMemo(()=>{if(!x)return o;const I=x.direction==="asc"?1:-1,T=U=>{switch(x.key){case"discount":return U.discountValue??0;case"usage":return U.usageCount??0;case"status":return U.active?1:0;case"code":default:return U.code}};return[...o].sort((U,L)=>{const B=T(U),z=T(L);return typeof B=="number"&&typeof z=="number"?(B-z)*I:String(B).localeCompare(String(z),void 0,{sensitivity:"base"})*I})},[o,x]);return r.jsxs("div",{className:"cedros-admin__page",children:[r.jsx(Vn,{message:v,onRetry:w}),r.jsx(Nr,{stats:[{label:"Total Coupons",value:o.length},{label:"Active",value:k,variant:k>0?"success":"muted"},{label:"Redemptions",value:_}],isLoading:i}),r.jsxs("div",{className:"cedros-admin__section-header",children:[r.jsx("h3",{className:"cedros-admin__section-title",children:"Discount Coupons"}),r.jsxs("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--action",onClick:()=>u(!l),children:[l?Z.close:Z.plus,l?"Cancel":"Add Coupon"]})]}),l&&r.jsxs("form",{onSubmit:j,className:"cedros-admin__add-form",children:[r.jsxs("div",{className:"cedros-admin__form-row",children:[r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Coupon Code"}),r.jsx("input",{type:"text",className:"cedros-admin__input",value:g.code,onChange:I=>y(T=>({...T,code:I.target.value.toUpperCase()})),placeholder:"e.g., SAVE20",required:!0})]}),r.jsx(Ct,{value:g.discountType,onChange:I=>y(T=>({...T,discountType:I})),options:[{value:"percentage",label:"Percentage (%)"},{value:"fixed",label:"Fixed Amount ($)"}],label:"Discount Type"})]}),r.jsxs("div",{className:"cedros-admin__form-row",children:[r.jsxs("div",{className:"cedros-admin__field",children:[r.jsxs("label",{className:"cedros-admin__field-label",children:["Discount Value ",g.discountType==="percentage"?"(%)":"($)"]}),r.jsx("input",{type:"number",className:"cedros-admin__input",value:g.discountValue||"",onChange:I=>y(T=>({...T,discountValue:parseFloat(I.target.value)||0})),placeholder:g.discountType==="percentage"?"e.g., 20":"e.g., 10.00",min:"0",step:g.discountType==="percentage"?"1":"0.01",required:!0})]}),r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Usage Limit (optional)"}),r.jsx("input",{type:"number",className:"cedros-admin__input",value:g.usageLimit||"",onChange:I=>y(T=>({...T,usageLimit:I.target.value?parseInt(I.target.value):void 0})),placeholder:"Leave empty for unlimited",min:"1"})]}),r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Expiration Date (optional)"}),r.jsx("input",{type:"date",className:"cedros-admin__input",value:g.expiresAt,onChange:I=>y(T=>({...T,expiresAt:I.target.value}))})]})]}),r.jsxs("div",{className:"cedros-admin__form-row",children:[r.jsx(Ct,{value:g.scope,onChange:I=>y(T=>({...T,scope:I})),options:[{value:"all_products",label:"All Products"},{value:"specific_products",label:"Specific Products"},{value:"specific_categories",label:"Specific Categories"}],label:"Scope"}),r.jsx(Ct,{value:g.paymentMethod,onChange:I=>y(T=>({...T,paymentMethod:I})),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"}),r.jsx(Ct,{value:g.appliesAt,onChange:I=>y(T=>({...T,appliesAt:I})),options:[{value:"both",label:"Cart & Checkout"},{value:"cart",label:"Cart Only"},{value:"checkout",label:"Checkout Only"}],label:"Applies At"})]}),g.scope==="specific_products"&&r.jsx("div",{className:"cedros-admin__form-row",children:r.jsxs("div",{className:"cedros-admin__field",style:{flex:1},children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Product IDs"}),r.jsx("input",{type:"text",className:"cedros-admin__input",value:g.productIdsCsv,onChange:I=>y(T=>({...T,productIdsCsv:I.target.value})),placeholder:"e.g., prod_123, prod_456"}),r.jsx("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:"Comma-separated product IDs this coupon applies to."})]})}),r.jsxs("div",{className:"cedros-admin__form-row",children:[r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Start Date (optional)"}),r.jsx("input",{type:"date",className:"cedros-admin__input",value:g.startsAt,onChange:I=>y(T=>({...T,startsAt:I.target.value}))})]}),r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Auto Apply"}),r.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[r.jsx("input",{type:"checkbox",checked:g.autoApply,onChange:I=>y(T=>({...T,autoApply:I.target.checked}))}),"Automatically apply when conditions met"]})]})]}),r.jsxs("div",{className:"cedros-admin__form-row",children:[r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Minimum Purchase (USD)"}),r.jsx("input",{type:"number",className:"cedros-admin__input",value:g.minimumAmountUsd===""?"":g.minimumAmountUsd,onChange:I=>y(T=>({...T,minimumAmountUsd:I.target.value===""?"":parseFloat(I.target.value)||0})),placeholder:"e.g., 50.00",min:"0",step:"0.01"})]}),r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Per-Customer Limit"}),r.jsx("input",{type:"number",className:"cedros-admin__input",value:g.usageLimitPerCustomer||"",onChange:I=>y(T=>({...T,usageLimitPerCustomer:I.target.value?parseInt(I.target.value):void 0})),placeholder:"Leave empty for unlimited",min:"1"})]}),r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"First Purchase Only"}),r.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[r.jsx("input",{type:"checkbox",checked:g.firstPurchaseOnly,onChange:I=>y(T=>({...T,firstPurchaseOnly:I.target.checked}))}),"New customers only"]})]})]}),g.scope==="specific_categories"&&r.jsx("div",{className:"cedros-admin__form-row",children:r.jsxs("div",{className:"cedros-admin__field",style:{flex:1},children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Category IDs"}),r.jsx("input",{type:"text",className:"cedros-admin__input",value:g.categoryIdsCsv,onChange:I=>y(T=>({...T,categoryIdsCsv:I.target.value})),placeholder:"e.g., cat_apparel, cat_accessories"}),r.jsx("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:"Comma-separated category IDs this coupon applies to."})]})}),r.jsx("div",{className:"cedros-admin__form-actions",children:r.jsx("button",{type:"submit",className:"cedros-admin__button cedros-admin__button--primary",disabled:m,children:m?"Creating...":"Create Coupon"})})]}),i?r.jsxs("div",{className:"cedros-admin__loading",children:[Z.loading," Loading coupons..."]}):r.jsx("div",{className:"cedros-admin__table-container",children:r.jsxs("table",{className:"cedros-admin__table",children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{"aria-sort":x?.key==="code"?x?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>S("code"),children:["Code",A("code")]})}),r.jsx("th",{"aria-sort":x?.key==="discount"?x?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>S("discount"),children:["Discount",A("discount")]})}),r.jsx("th",{"aria-sort":x?.key==="usage"?x?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>S("usage"),children:["Usage",A("usage")]})}),r.jsx("th",{"aria-sort":x?.key==="status"?x?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>S("status"),children:["Status",A("status")]})}),r.jsx("th",{children:"Actions"})]})}),r.jsx("tbody",{children:E.map(I=>r.jsxs("tr",{children:[r.jsx("td",{children:r.jsx("code",{children:I.code})}),r.jsx("td",{children:I.discountType==="percentage"?`${I.discountValue}%`:`$${I.discountValue.toFixed(2)}`}),r.jsxs("td",{children:[I.usageCount,I.usageLimit?` / ${I.usageLimit}`:""]}),r.jsx("td",{children:r.jsx("span",{className:`cedros-admin__badge ${I.active?"cedros-admin__badge--success":"cedros-admin__badge--muted"}`,children:I.active?"Active":"Inactive"})}),r.jsx("td",{children:r.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",children:"Edit"})})]},I.code))})]})})]})}function Zc({serverUrl:e,apiKey:t,pageSize:n=20,authManager:s}){const[o,a]=b.useState([]),[i,c]=b.useState(!0),[l,u]=b.useState(null),[m,d]=b.useState([]),[x,h]=b.useState(!0),[v,p]=b.useState(null),[g,y]=b.useState([]),[w,j]=b.useState(!0),[k,_]=b.useState(null),[S,A]=b.useState(null),[E,I]=b.useState(null),T=b.useCallback(async()=>{try{let M;const X=`/admin/refunds?limit=${n}`;if(s?.isAuthenticated())M=await s.fetchWithAuth(X);else{const ue={"Content-Type":"application/json"};t&&(ue["X-API-Key"]=t);const je=await fetch(`${e}${X}`,{headers:ue});if(!je.ok)throw new Error(`Failed to fetch x402 refunds: ${je.status}`);M=await je.json()}a(M.refunds||[])}catch(M){Ie.getLogger().error("[RefundsSection] Failed to fetch x402 refunds:",M,{serverUrl:e.slice(0,20)+"...",hasApiKey:!!t}),a([]),I("Failed to load x402 refunds")}finally{c(!1)}},[e,t,n,s]);b.useEffect(()=>{T()},[T]);const U=b.useCallback(async()=>{try{let M;const X=`/admin/credits/refund-requests?status=pending&limit=${n}&offset=0`;if(s?.isAuthenticated())M=await s.fetchWithAuth(X);else{const je={"Content-Type":"application/json"};t&&(je["X-API-Key"]=t);const be=await fetch(`${e}${X}`,{headers:je});if(!be.ok)throw new Error(`Failed to fetch credits refund requests: ${be.status}`);M=await be.json()}const ue=Array.isArray(M)?M:"refundRequests"in M?M.refundRequests:M.requests||[];d(ue)}catch(M){Ie.getLogger().error("[RefundsSection] Failed to fetch credits refunds:",M,{serverUrl:e.slice(0,20)+"...",hasApiKey:!!t}),d([]),I("Failed to load credits refunds")}finally{h(!1)}},[e,t,n,s]);b.useEffect(()=>{U()},[U]);const L=b.useCallback(async()=>{try{let M;const X=`/admin/stripe/refunds?limit=${n}`;if(s?.isAuthenticated())M=await s.fetchWithAuth(X);else{const ue={"Content-Type":"application/json"};t&&(ue["X-API-Key"]=t);const je=await fetch(`${e}${X}`,{headers:ue});if(!je.ok)throw new Error(`Failed to fetch Stripe refunds: ${je.status}`);M=await je.json()}y(M.refunds||[])}catch(M){Ie.getLogger().error("[RefundsSection] Failed to fetch Stripe refunds:",M,{serverUrl:e.slice(0,20)+"...",hasApiKey:!!t}),y([]),I("Failed to load Stripe refunds")}finally{j(!1)}},[e,t,n,s]);b.useEffect(()=>{L()},[L]);const B=async M=>{_(M);try{const X=`/admin/stripe/refunds/${M}/process`;if(s?.isAuthenticated())await s.fetchWithAuth(X,{method:"POST"});else{const ue={"Content-Type":"application/json"};t&&(ue["X-API-Key"]=t);const je=await fetch(`${e}${X}`,{method:"POST",headers:ue});if(!je.ok)throw new Error(`Failed to process refund: ${je.status}`)}await L()}catch(X){Ie.getLogger().error("[RefundsSection] Failed to process Stripe refund:",X,{serverUrl:e.slice(0,20)+"...",hasApiKey:!!t,refundId:M}),I("Failed to process Stripe refund")}finally{_(null)}},z=(M,X)=>new Intl.NumberFormat("en-US",{style:"currency",currency:X}).format(M/100),K=M=>M?M.replace(/_/g," ").replace(/\b\w/g,X=>X.toUpperCase()):"—",V=M=>{switch(M){case"processed":return"success";case"pending":return"pending";case"rejected":default:return"muted"}},G=(M,X)=>X?X.toLowerCase()==="usd"?`${new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(M/1e6)} (USD credits)`:`${M.toLocaleString()} ${X.toUpperCase()} (atomic)`:`${M.toLocaleString()} (atomic)`,D=M=>{switch(M){case"succeeded":return"success";case"failed":return"failed";case"pending":case"requires_action":return"pending";case"canceled":default:return"muted"}},se=M=>M.stripeRefundId??"—",le=M=>M.chargeId??"—",N=g.filter(M=>M.status==="pending"||M.status==="requires_action").length,R=m.filter(M=>M.status==="pending").length,F=o.filter(M=>M.status==="pending").length,Q=N+R+F,Y=g.filter(M=>M.status==="succeeded").reduce((M,X)=>M+X.amount,0),ce=m.filter(M=>M.status==="processed").reduce((M,X)=>M+X.amountLamports,0),P=o.filter(M=>M.status==="completed").reduce((M,X)=>M+X.amount,0),H=Y/100+ce/1e6+P,de=M=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(M),W=w||x||i,re=M=>{A(X=>!X||X.key!==M?{key:M,direction:"asc"}:{key:M,direction:X.direction==="asc"?"desc":"asc"})},ie=M=>{p(X=>!X||X.key!==M?{key:M,direction:"asc"}:{key:M,direction:X.direction==="asc"?"desc":"asc"})},ye=M=>{u(X=>!X||X.key!==M?{key:M,direction:"asc"}:{key:M,direction:X.direction==="asc"?"desc":"asc"})},fe=(M,X)=>!M||!X?r.jsx("span",{className:"cedros-admin__sort-icon cedros-admin__sort-icon--idle",children:Z.chevronUp}):r.jsx("span",{className:"cedros-admin__sort-icon",children:X==="asc"?Z.chevronUp:Z.chevronDown}),Be=b.useMemo(()=>{if(!S)return g;const M=S.direction==="asc"?1:-1,X=ue=>{switch(S.key){case"stripe":return ue.stripeRefundId??"";case"charge":return ue.chargeId??"";case"amount":return ue.amount??0;case"reason":return ue.reason??"";case"status":return ue.status??"";case"date":return new Date(ue.createdAt).getTime();case"id":default:return ue.id}};return[...g].sort((ue,je)=>{const be=X(ue),Me=X(je);return typeof be=="number"&&typeof Me=="number"?(be-Me)*M:String(be).localeCompare(String(Me),void 0,{sensitivity:"base"})*M})},[g,S]),Ke=b.useMemo(()=>{if(!v)return m;const M=v.direction==="asc"?1:-1,X=ue=>{switch(v.key){case"original":return ue.originalTransactionId??"";case"user":return ue.userId??"";case"amount":return ue.amountLamports??0;case"reason":return ue.reason??"";case"status":return ue.status??"";case"date":return new Date(ue.createdAt).getTime();case"id":default:return ue.id}};return[...m].sort((ue,je)=>{const be=X(ue),Me=X(je);return typeof be=="number"&&typeof Me=="number"?(be-Me)*M:String(be).localeCompare(String(Me),void 0,{sensitivity:"base"})*M})},[m,v]),Ve=b.useMemo(()=>{if(!l)return o;const M=l.direction==="asc"?1:-1,X=ue=>{switch(l.key){case"transaction":return ue.transactionId??"";case"amount":return ue.amount??0;case"reason":return ue.reason??"";case"status":return ue.status??"";case"date":return new Date(ue.createdAt).getTime();case"id":default:return ue.id}};return[...o].sort((ue,je)=>{const be=X(ue),Me=X(je);return typeof be=="number"&&typeof Me=="number"?(be-Me)*M:String(be).localeCompare(String(Me),void 0,{sensitivity:"base"})*M})},[o,l]);return r.jsxs("div",{className:"cedros-admin__page",children:[r.jsx(Vn,{message:E,onRetry:()=>{T(),U(),L()}}),r.jsx(Nr,{stats:[{label:"Pending",value:Q,variant:Q>0?"warning":"muted"},{label:"Card Pending",value:N,description:"Stripe"},{label:"Credits Pending",value:R},{label:"Crypto Pending",value:F,description:"x402"},{label:"Total Refunded",value:de(H),variant:"success"}],isLoading:W}),r.jsx("div",{className:"cedros-admin__section-header",children:r.jsx("h3",{className:"cedros-admin__section-title",children:"Stripe Refund Requests"})}),w?r.jsxs("div",{className:"cedros-admin__loading",children:[Z.loading," Loading Stripe refunds..."]}):g.length===0?r.jsx("div",{className:"cedros-admin__empty",children:"No Stripe refund requests found."}):r.jsx("div",{className:"cedros-admin__table-container",children:r.jsxs("table",{className:"cedros-admin__table",children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{"aria-sort":S?.key==="id"?S?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>re("id"),children:["Request ID",fe(S?.key==="id",S?.direction)]})}),r.jsx("th",{"aria-sort":S?.key==="stripe"?S?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>re("stripe"),children:["Stripe Refund ID",fe(S?.key==="stripe",S?.direction)]})}),r.jsx("th",{"aria-sort":S?.key==="charge"?S?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>re("charge"),children:["Charge",fe(S?.key==="charge",S?.direction)]})}),r.jsx("th",{"aria-sort":S?.key==="amount"?S?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>re("amount"),children:["Amount",fe(S?.key==="amount",S?.direction)]})}),r.jsx("th",{"aria-sort":S?.key==="reason"?S?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>re("reason"),children:["Reason",fe(S?.key==="reason",S?.direction)]})}),r.jsx("th",{"aria-sort":S?.key==="status"?S?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>re("status"),children:["Status",fe(S?.key==="status",S?.direction)]})}),r.jsx("th",{"aria-sort":S?.key==="date"?S?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>re("date"),children:["Date",fe(S?.key==="date",S?.direction)]})}),r.jsx("th",{children:"Actions"})]})}),r.jsx("tbody",{children:Be.map(M=>r.jsxs("tr",{children:[r.jsx("td",{children:r.jsx("code",{children:M.id})}),r.jsx("td",{children:r.jsx("code",{children:se(M)})}),r.jsx("td",{children:r.jsx("code",{children:le(M)})}),r.jsx("td",{children:z(M.amount,M.currency)}),r.jsx("td",{children:K(M.reason)}),r.jsx("td",{children:r.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${D(M.status)}`,children:M.status})}),r.jsx("td",{children:mr(M.createdAt)}),r.jsx("td",{children:(M.status==="pending"||M.status==="requires_action")&&r.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--sm",onClick:()=>B(M.id),disabled:k===M.id,children:k===M.id?"Processing...":"Process"})})]},M.id))})]})}),r.jsx("div",{className:"cedros-admin__section-header",style:{marginTop:"2rem"},children:r.jsx("h3",{className:"cedros-admin__section-title",children:"Credits Refund Requests"})}),r.jsx("p",{className:"cedros-admin__hint",style:{marginBottom:"0.75rem"},children:"Credits refund requests are read-only in this admin surface."}),x?r.jsxs("div",{className:"cedros-admin__loading",children:[Z.loading," Loading credits refunds..."]}):m.length===0?r.jsx("div",{className:"cedros-admin__empty",children:"No credits refund requests found."}):r.jsx("div",{className:"cedros-admin__table-container",children:r.jsxs("table",{className:"cedros-admin__table",children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{"aria-sort":v?.key==="id"?v?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>ie("id"),children:["Request ID",fe(v?.key==="id",v?.direction)]})}),r.jsx("th",{"aria-sort":v?.key==="original"?v?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>ie("original"),children:["Original Tx",fe(v?.key==="original",v?.direction)]})}),r.jsx("th",{"aria-sort":v?.key==="user"?v?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>ie("user"),children:["User",fe(v?.key==="user",v?.direction)]})}),r.jsx("th",{"aria-sort":v?.key==="amount"?v?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>ie("amount"),children:["Amount",fe(v?.key==="amount",v?.direction)]})}),r.jsx("th",{"aria-sort":v?.key==="reason"?v?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>ie("reason"),children:["Reason",fe(v?.key==="reason",v?.direction)]})}),r.jsx("th",{"aria-sort":v?.key==="status"?v?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>ie("status"),children:["Status",fe(v?.key==="status",v?.direction)]})}),r.jsx("th",{"aria-sort":v?.key==="date"?v?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>ie("date"),children:["Date",fe(v?.key==="date",v?.direction)]})})]})}),r.jsx("tbody",{children:Ke.map(M=>r.jsxs("tr",{children:[r.jsx("td",{children:r.jsx("code",{children:M.id})}),r.jsx("td",{children:r.jsx("code",{children:M.originalTransactionId})}),r.jsx("td",{children:r.jsx("code",{children:M.userId??"—"})}),r.jsx("td",{children:G(M.amountLamports,M.currency)}),r.jsx("td",{children:M.reason??"—"}),r.jsx("td",{children:r.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${V(M.status)}`,children:M.status})}),r.jsx("td",{children:mr(M.createdAt)})]},M.id))})]})}),r.jsx("div",{className:"cedros-admin__section-header",style:{marginTop:"2rem"},children:r.jsx("h3",{className:"cedros-admin__section-title",children:"x402 Refund Requests"})}),r.jsx("p",{className:"cedros-admin__hint",style:{marginBottom:"0.75rem"},children:"x402 refund approvals use the signed refund workflow, not this dashboard table."}),i?r.jsxs("div",{className:"cedros-admin__loading",children:[Z.loading," Loading x402 refunds..."]}):o.length===0?r.jsx("div",{className:"cedros-admin__empty",children:"No x402 refund requests found."}):r.jsx("div",{className:"cedros-admin__table-container",children:r.jsxs("table",{className:"cedros-admin__table",children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{"aria-sort":l?.key==="id"?l?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>ye("id"),children:["ID",fe(l?.key==="id",l?.direction)]})}),r.jsx("th",{"aria-sort":l?.key==="transaction"?l?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>ye("transaction"),children:["Transaction",fe(l?.key==="transaction",l?.direction)]})}),r.jsx("th",{"aria-sort":l?.key==="amount"?l?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>ye("amount"),children:["Amount",fe(l?.key==="amount",l?.direction)]})}),r.jsx("th",{"aria-sort":l?.key==="reason"?l?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>ye("reason"),children:["Reason",fe(l?.key==="reason",l?.direction)]})}),r.jsx("th",{"aria-sort":l?.key==="status"?l?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>ye("status"),children:["Status",fe(l?.key==="status",l?.direction)]})}),r.jsx("th",{"aria-sort":l?.key==="date"?l?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>ye("date"),children:["Date",fe(l?.key==="date",l?.direction)]})})]})}),r.jsx("tbody",{children:Ve.map(M=>r.jsxs("tr",{children:[r.jsx("td",{children:r.jsx("code",{children:M.id})}),r.jsx("td",{children:r.jsx("code",{children:M.transactionId})}),r.jsxs("td",{children:["$",M.amount.toFixed(2)]}),r.jsx("td",{children:M.reason||"—"}),r.jsx("td",{children:r.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${M.status}`,children:M.status})}),r.jsx("td",{children:mr(M.createdAt)})]},M.id))})]})})]})}const uf=b.lazy(()=>Promise.resolve().then(()=>require("./SettingsSection-vdYFSNxB.js")).then(e=>({default:e.SettingsSection})));function Gc(e){return r.jsx(b.Suspense,{fallback:null,children:r.jsx(uf,{...e})})}class Yc{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,Ie.getLogger().debug("[AdminAuthManager] Wallet signer updated:",!!t?.publicKey)}setCedrosLoginAuth(t,n){this.jwtToken=t,this.isAdminUser=n??!1,Ie.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),s=new TextEncoder().encode(n.nonce),o=await this.walletSigner.signMessage(s),a=ef.bs58.encode(this.walletSigner.publicKey.toBytes()),i=Ie.gBase64.fromUint8Array(o);return{"X-Signer":a,"X-Message":n.nonce,"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`,s=typeof t=="string"?{purpose:t}:{path:t.path,method:t.method.toUpperCase()};Ie.getLogger().debug("[AdminAuthManager] Fetching nonce:",s);const o=await Ie.fetchWithTimeout(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!o.ok){const a=await o.text();throw new Error(`Failed to fetch nonce: ${o.status} ${a}`)}return await o.json()}async fetchWithAuth(t,n={}){if(this.getAuthMethod()==="none")throw new Error("No admin authentication configured");const o=(n.method||"GET").toUpperCase(),a=await this.createAuthHeaders({path:t,method:o}),i={...o!=="GET"&&o!=="HEAD"?{"Content-Type":"application/json"}:{},...n.headers||{},...a},c=await Ie.fetchWithTimeout(`${this.serverUrl}${t}`,{...n,headers:i});if(!c.ok){let l=`Admin API error ${c.status}`;try{const u=await c.json();u&&typeof u.error=="string"?l=u.error:u&&typeof u.message=="string"&&(l=u.message)}catch{}throw new Error(l)}return await c.json()}}const mf={publicKey:null};function ff({serverUrl:e,cedrosLoginToken:t,isAdmin:n=!1,wallet:s=mf}){const o=b.useMemo(()=>{const d=new Yc(e);return d.setCedrosLoginAuth(t??null,n),d},[e,t,n]);b.useEffect(()=>{s.publicKey&&s.signMessage?o.setWalletSigner({publicKey:s.publicKey,signMessage:s.signMessage}):o.setWalletSigner(null)},[o,s.publicKey,s.signMessage]);const a=o.getAuthMethod(),i=o.isAuthenticated(),c=!!(s.publicKey&&s.signMessage),l=!!(t&&n),u=b.useMemo(()=>{if(!s.publicKey)return null;const d=s.publicKey.toBase58();return`${d.slice(0,4)}...${d.slice(-4)}`},[s.publicKey]),m=b.useCallback((d,x)=>o.fetchWithAuth(d,x),[o]);return{authMethod:a,isAuthenticated:i,walletConnected:c,walletAddress:u,cedrosLoginAvailable:l,authManager:o,fetchWithAuth:m}}const pf=b.lazy(()=>Promise.resolve().then(()=>require("./SubscriptionsSection-C2aLLn7L.js")).then(e=>({default:e.SubscriptionsSection}))),hf=b.lazy(()=>Promise.resolve().then(()=>require("./StorefrontSection-RumGkb3C.js")).then(e=>({default:e.StorefrontSection}))),gf=b.lazy(()=>Promise.resolve().then(()=>require("./AISettingsSection-DELur7D2.js")).then(e=>({default:e.AISettingsSection}))),xf=b.lazy(()=>Promise.resolve().then(()=>require("./PaymentSettingsSection-BYF4D-GR.js")).then(e=>({default:e.PaymentSettingsSection}))),vf=b.lazy(()=>Promise.resolve().then(()=>require("./MessagingSection-B_wdFR0j.js")).then(e=>({default:e.MessagingSection}))),yf=b.lazy(()=>Promise.resolve().then(()=>require("./FAQSection-wNeH0i6Q.js")).then(e=>({default:e.FAQSection}))),bf=b.lazy(()=>Promise.resolve().then(()=>require("./Token22Section-DY3mUwTY.js")).then(e=>({default:e.Token22Section}))),wf=b.lazy(()=>Promise.resolve().then(()=>require("./OrdersSection-Dw2FX-1d.js")).then(e=>({default:e.OrdersSection}))),kf=b.lazy(()=>Promise.resolve().then(()=>require("./ComplianceSection-DP2a9-S0.js")).then(e=>({default:e.ComplianceSection}))),jf=b.lazy(()=>Promise.resolve().then(()=>require("./ChatLogsSection-BH5tLA4T.js")).then(e=>({default:e.ChatLogsSection}))),_f=b.lazy(()=>Promise.resolve().then(()=>require("./CustomersSection-CBwy_waO.js")).then(e=>({default:e.CustomersSection}))),Sf=b.lazy(()=>Promise.resolve().then(()=>require("./DisputesSection-BLjIk60n.js")).then(e=>({default:e.DisputesSection}))),Cf=b.lazy(()=>Promise.resolve().then(()=>require("./WebhooksSection-CKeiJ7Py.js")).then(e=>({default:e.WebhooksSection}))),Nf=b.lazy(()=>Promise.resolve().then(()=>require("./ShippingSection-1DRSTu49.js")).then(e=>({default:e.ShippingSection}))),Af=b.lazy(()=>Promise.resolve().then(()=>require("./TaxSection-Dt1DnM51.js")).then(e=>({default:e.TaxSection}))),Ef=b.lazy(()=>Promise.resolve().then(()=>require("./ReturnsSection-D_pJVxuG.js")).then(e=>({default:e.ReturnsSection}))),If=b.lazy(()=>Promise.resolve().then(()=>require("./ImagesSection-0ZzKlzMJ.js")).then(e=>({default:e.ImagesSection}))),Tf=b.lazy(()=>Promise.resolve().then(()=>require("./InventorySection-zV6lTmue.js")).then(e=>({default:e.InventorySection}))),Kc=[{label:"Menu",sections:[{id:"transactions",label:"Transactions",icon:Z.transactions},{id:"orders",label:"Orders",icon:Z.transactions},{id:"products",label:"Products",icon:Z.products},{id:"subscriptions",label:"Subscriptions",icon:Z.calendarRepeat},{id:"coupons",label:"Coupons",icon:Z.coupons},{id:"refunds",label:"Refunds",icon:Z.refunds},{id:"compliance",label:"Compliance",icon:Z.shield},{id:"chat-logs",label:"Chat Logs",icon:Z.chat},{id:"customers",label:"Customers",icon:Z.user},{id:"disputes",label:"Disputes",icon:Z.shield},{id:"returns",label:"Returns",icon:Z.refunds},{id:"images",label:"Images",icon:Z.eye},{id:"inventory",label:"Inventory",icon:Z.products}]},{label:"Configuration",collapsible:!0,sections:[{id:"storefront",label:"Storefront",icon:Z.storefront},{id:"ai-settings",label:"Store AI",icon:Z.brain},{id:"faqs",label:"Knowledge Base",icon:Z.faq},{id:"payment-settings",label:"Payment Options",icon:Z.creditCard},{id:"token22",label:"Gift Cards & Token-22",icon:Z.wallet},{id:"messaging",label:"Store Messages",icon:Z.mail},{id:"webhooks",label:"Webhooks",icon:Z.globe},{id:"shipping",label:"Shipping",icon:Z.products},{id:"tax",label:"Tax Rates",icon:Z.transactions},{id:"settings",label:"Store Server",icon:Z.server}]}],Pf=Kc.flatMap(e=>e.sections);function Rf(){const[e,t]=b.useState(()=>typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");return b.useEffect(()=>{const n=window.matchMedia("(prefers-color-scheme: dark)"),s=o=>t(o.matches?"dark":"light");return n.addEventListener("change",s),()=>n.removeEventListener("change",s)},[]),e}function Of(e,t,n){return e!=="system"?e:t||n}const Mf={products:Wc,transactions:qc,coupons:Hc,refunds:Zc,settings:Gc,subscriptions:pf,storefront:hf,"ai-settings":gf,"payment-settings":xf,messaging:vf,faqs:yf,token22:bf,orders:wf,compliance:kf,"chat-logs":jf,customers:_f,disputes:Sf,webhooks:Cf,shipping:Nf,tax:Af,returns:Ef,images:If,inventory:Tf},Lf=new Set(["products","transactions","coupons","refunds","settings"]);function Df({activeSection:e,serverUrl:t,apiKey:n,pageSize:s,authManager:o}){const a=Mf[e];if(!a)return null;const i={serverUrl:t,apiKey:n,pageSize:s,authManager:o};return Lf.has(e)?r.jsx(a,{...i}):r.jsx(b.Suspense,{fallback:r.jsx("div",{className:"cedros-admin__loading-text",children:"Loading section..."}),children:r.jsx(a,{...i})})}function zf({serverUrl:e,apiKey:t,title:n="Cedros Pay",sections:s=["transactions","orders","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:u,isAdmin:m=!1,theme:d="system"}){const[x,h]=b.useState(o),[v]=b.useState(!1),[p,g]=b.useState(new Set),y=b.useCallback(L=>{g(B=>{const z=new Set(B);return z.has(L)?z.delete(L):z.add(L),z})},[]),w=Ie.useCedrosThemeOptional(),j=Rf(),_=Of(d,w?.mode??null,j)==="dark"?"cedros-admin--dark":"",S=Jm.useWallet(),{authManager:A,isAuthenticated:E}=ff({serverUrl:e,cedrosLoginToken:u,isAdmin:m,wallet:S}),I=b.useCallback(L=>{h(L),c?.(L)},[c]),U=Pf.filter(L=>s.includes(L.id)).find(L=>L.id===x);return v?r.jsxs("div",{className:`cedros-admin cedros-admin--loading ${_} ${l}`,children:[Z.loading,r.jsx("span",{className:"cedros-admin__loading-text",children:"Loading dashboard..."})]}):E?r.jsxs("div",{className:`cedros-admin ${_} ${l}`,children:[r.jsxs("aside",{className:"cedros-admin__sidebar",children:[r.jsx("div",{className:"cedros-admin__sidebar-header",children:r.jsxs("div",{className:"cedros-admin__logo",children:[Z.wallet,r.jsx("span",{className:"cedros-admin__logo-text",children:n})]})}),r.jsx("nav",{className:"cedros-admin__nav",children:Kc.map(L=>{const B=L.sections.filter(K=>s.includes(K.id));if(B.length===0)return null;const z=L.collapsible&&p.has(L.label);return r.jsxs("div",{className:"cedros-admin__nav-group",children:[L.collapsible?r.jsxs("button",{type:"button",className:"cedros-admin__nav-label cedros-admin__nav-label--collapsible",onClick:()=>y(L.label),"aria-expanded":!z,children:[L.label,r.jsx("span",{className:`cedros-admin__nav-label-icon ${z?"":"cedros-admin__nav-label-icon--expanded"}`,children:Z.chevronRight})]}):r.jsx("span",{className:"cedros-admin__nav-label",children:L.label}),!z&&B.map(K=>r.jsxs("button",{type:"button",className:`cedros-admin__nav-item ${x===K.id?"cedros-admin__nav-item--active":""}`,onClick:()=>I(K.id),"aria-current":x===K.id?"page":void 0,children:[r.jsx("span",{className:"cedros-admin__nav-icon",children:K.icon}),r.jsx("span",{className:"cedros-admin__nav-text",children:K.label})]},K.id))]},L.label)})})]}),r.jsxs("main",{className:"cedros-admin__main",children:[r.jsx("header",{className:"cedros-admin__header",children:r.jsxs("div",{className:"cedros-admin__breadcrumb",children:[r.jsx("span",{className:"cedros-admin__breadcrumb-root",children:n}),r.jsx("span",{className:"cedros-admin__breadcrumb-sep",children:Z.chevronRight}),r.jsx("span",{className:"cedros-admin__breadcrumb-current",children:U?.label})]})}),r.jsx("div",{className:"cedros-admin__content",children:r.jsx(Df,{activeSection:x,serverUrl:e,apiKey:t,pageSize:i,authManager:A})})]})]}):r.jsx("div",{className:`cedros-admin cedros-admin--unauthenticated ${_} ${l}`,children:r.jsx("p",{className:"cedros-admin__auth-prompt",children:"Please connect a wallet or sign in as admin to access the dashboard."})})}const yt=e=>b.lazy(async()=>{const s=(await e()).default;return{default:({pluginContext:a})=>{const c=Xm.useCedrosLogin()?._internal?.getAccessToken()??a.getAccessToken(),l=a.hasPermission("cedros-pay:admin")||a.hasPermission("admin"),u=b.useMemo(()=>{const d=new Yc(a.serverUrl);return d.setCedrosLoginAuth(c??null,l),d},[l,a.serverUrl,c]),m={serverUrl:a.serverUrl,authManager:u};return r.jsx(s,{...m})}}}),$f={id:"cedros-pay",name:"Cedros Pay",version:"1.0.0",sections:[{id:"transactions",label:"Transactions",icon:Z.transactions,group:"Store",order:0},{id:"products",label:"Products",icon:Z.products,group:"Store",order:1},{id:"subscriptions",label:"Subscriptions",icon:Z.subscriptions,group:"Store",order:2},{id:"coupons",label:"Coupons",icon:Z.coupons,group:"Store",order:3},{id:"refunds",label:"Refunds",icon:Z.refunds,group:"Store",order:4},{id:"compliance",label:"Compliance",icon:Z.shield,group:"Store",order:5},{id:"storefront",label:"Storefront",icon:Z.storefront,group:"Configuration",order:10},{id:"ai-settings",label:"Store AI",icon:Z.ai,group:"Configuration",order:11},{id:"faqs",label:"Knowledge Base",icon:Z.faq,group:"Configuration",order:12},{id:"payment-settings",label:"Payment Options",icon:Z.wallet,group:"Configuration",order:13},{id:"messaging",label:"Store Messages",icon:Z.notifications,group:"Configuration",order:14},{id:"settings",label:"Store Server",icon:Z.settings,group:"Configuration",order:15}],groups:[{id:"Store",label:"Store",order:1},{id:"Configuration",label:"Configuration",order:2,defaultCollapsed:!0}],components:{products:yt(()=>Promise.resolve().then(()=>require("./sections-DVVSZBhW.js")).then(e=>({default:e.ProductsSection}))),subscriptions:yt(()=>Promise.resolve().then(()=>require("./SubscriptionsSection-C2aLLn7L.js")).then(e=>({default:e.SubscriptionsSection}))),transactions:yt(()=>Promise.resolve().then(()=>require("./sections-DVVSZBhW.js")).then(e=>({default:e.TransactionsSection}))),coupons:yt(()=>Promise.resolve().then(()=>require("./sections-DVVSZBhW.js")).then(e=>({default:e.CouponsSection}))),refunds:yt(()=>Promise.resolve().then(()=>require("./sections-DVVSZBhW.js")).then(e=>({default:e.RefundsSection}))),compliance:yt(()=>Promise.resolve().then(()=>require("./ComplianceSection-DP2a9-S0.js")).then(e=>({default:e.ComplianceSection}))),storefront:yt(()=>Promise.resolve().then(()=>require("./StorefrontSection-RumGkb3C.js")).then(e=>({default:e.StorefrontSection}))),"ai-settings":yt(()=>Promise.resolve().then(()=>require("./AISettingsSection-DELur7D2.js")).then(e=>({default:e.AISettingsSection}))),faqs:yt(()=>Promise.resolve().then(()=>require("./FAQSection-wNeH0i6Q.js")).then(e=>({default:e.FAQSection}))),"payment-settings":yt(()=>Promise.resolve().then(()=>require("./PaymentSettingsSection-BYF4D-GR.js")).then(e=>({default:e.PaymentSettingsSection}))),messaging:yt(()=>Promise.resolve().then(()=>require("./MessagingSection-B_wdFR0j.js")).then(e=>({default:e.MessagingSection}))),settings:yt(()=>Promise.resolve().then(()=>require("./SettingsSection-vdYFSNxB.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):!1},cssNamespace:"cedros-dashboard"},Qc=[{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"]}],Ff=Qc.map(e=>e.qualifiedId),Uf=[{id:"Store",label:"Store",order:1,defaultCollapsed:!1},{id:"Configuration",label:"Configuration",order:2,defaultCollapsed:!0}];function Jc(){const{config:e}=Ie.useCedrosContext(),[t,n]=b.useState(!1),[s,o]=b.useState(null),[a,i]=b.useState(null);return{checkCompliance:b.useCallback(async(l,u,m)=>{n(!0),i(null),o(null);try{const x=`${e.serverUrl||window.location.origin}/paywall/v1/compliance-check`,h={"Content-Type":"application/json"};u&&(h.Authorization=`Bearer ${u}`);const v=await Ie.fetchWithTimeout(x,{method:"POST",headers:h,body:JSON.stringify({resources:l,...m?{wallet:m}:{}})});if(!v.ok){const g=await Ie.parseErrorResponse(v,"Compliance check failed");throw new Error(g)}const p=await v.json();return o(p),p}catch(d){const x=d instanceof Error?d.message:"Compliance check failed";Ie.getLogger().error("[useComplianceCheck]",x),i(x);const h={cleared:!0};return o(h),h}finally{n(!1)}},[e.serverUrl]),loading:t,result:s,error:a}}function Bf({resources:e,onCleared:t,onBlocked:n,onCancel:s,authToken:o,wallet:a,children:i}){const c=Ie.useCedrosTheme(),{checkCompliance:l,loading:u,result:m,error:d}=Jc(),x=b.useRef(!1);b.useEffect(()=>{x.current||e.length===0||(x.current=!0,l(e,o,a))},[e,o,a,l]),b.useEffect(()=>{m&&(m.cleared?t():m.reasons?.length&&n?.(m.reasons))},[m,t,n]);const h=c.unstyled?"":`${c.className} cedros-theme__compliance-gate`,v=c.unstyled?{}:c.style;return u||!m?r.jsx("div",{className:h,style:v,children:i??r.jsx("div",{className:c.unstyled?"":"cedros-theme__compliance-checking",children:r.jsx("p",{children:"Verifying purchase eligibility..."})})}):m.cleared?null:r.jsx("div",{className:h,style:v,children:r.jsxs("div",{className:c.unstyled?"":"cedros-theme__compliance-blocked",children:[r.jsx("h3",{children:"Purchase Not Available"}),r.jsx("ul",{children:m.reasons?.map((p,g)=>r.jsx("li",{children:p},g))}),d&&r.jsx("p",{className:c.unstyled?"":"cedros-theme__error",children:d}),s&&r.jsx("button",{type:"button",onClick:s,className:c.unstyled?"":"cedros-theme__button",children:"Go back"})]})})}function Xc(e){const{creditsManager:t}=Ie.useCedrosContext(),[n,s]=b.useState({available:0,held:0,currency:"",loading:!1,error:null}),o=b.useRef(!0);b.useEffect(()=>(o.current=!0,()=>{o.current=!1}),[]);const a=b.useCallback(async()=>{if(e){s(i=>({...i,loading:!0,error:null}));try{const i=await t.getBalance(e);if(!o.current)return;s(i?{available:i.available,held:i.held,currency:i.currency,loading:!1,error:null}:c=>({...c,loading:!1}))}catch(i){if(!o.current)return;s(c=>({...c,loading:!1,error:i instanceof Error?i.message:"Failed to fetch balance"}))}}},[e,t]);return b.useEffect(()=>{a()},[a]),{...n,refresh:a}}function Vf({authToken:e,className:t="",formatBalance:n,showHeld:s=!1}){const o=Ie.useCedrosTheme(),{available:a,held:i,currency:c,loading:l,error:u,refresh:m}=Xc(e),d=o.unstyled?t:`${o.className} cedros-theme__credits-balance ${t}`.trim();if(!e)return null;const x=n?n(a,c):`${a} ${c}`;return r.jsxs("div",{className:d,style:o.unstyled?{}:o.style,children:[r.jsx("div",{className:o.unstyled?"":"cedros-theme__credits-balance-amount",children:l?"Loading…":x}),s&&i>0&&!l&&r.jsxs("div",{className:o.unstyled?"":"cedros-theme__credits-balance-held",children:[i," ",c," held"]}),u&&r.jsx("div",{className:o.unstyled?"":"cedros-theme__error",children:u}),!l&&r.jsx("button",{type:"button",onClick:m,className:o.unstyled?"":"cedros-theme__credits-balance-refresh","aria-label":"Refresh balance",children:"↻"})]})}const na=b.createContext(null);function Ae(){const e=b.useContext(na);if(!e)throw new Error("useCedrosShop must be used within CedrosShopProvider");return e}function ks(){return b.useContext(na)}function Wf({config:e,children:t}){const n=b.useMemo(()=>({config:e}),[e]);return r.jsx(na.Provider,{value:n,children:t})}function jt(e){return new Promise(t=>setTimeout(t,e))}const el=[{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."}],rs=[{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 qf(e,t){let n=e;if(t.category&&t.category!=="all"){const l=el.find(u=>u.slug===t.category||u.id===t.category);l&&(n=n.filter(u=>u.categoryIds.includes(l.id)))}if(t.search){const l=t.search.toLowerCase();n=n.filter(u=>u.title.toLowerCase().includes(l)||u.description.toLowerCase().includes(l))}const s=t.filters??{},o=s.tags;if(Array.isArray(o)&&o.length>0){const l=new Set(o.map(String));n=n.filter(u=>u.tags?.some(m=>l.has(m)))}const a=typeof s.priceMin=="number"?s.priceMin:void 0,i=typeof s.priceMax=="number"?s.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 s.inStock=="boolean"?s.inStock:void 0)===!0&&(n=n.filter(l=>l.inventoryStatus!=="out_of_stock")),n}function Hf(e,t){if(!t||t==="featured")return e;const n=[...e];return t==="price_asc"&&n.sort((s,o)=>s.price-o.price),t==="price_desc"&&n.sort((s,o)=>o.price-s.price),n}function Zf(e,t,n){const s=(t-1)*n;return{items:e.slice(s,s+n),page:t,pageSize:n,total:e.length,hasNextPage:s+n<e.length}}function Gf(e){const t=new Date().toISOString(),n=e.cart.map(o=>{const a=rs.find(i=>i.id===o.resource||i.slug===o.resource)??rs[0];return{title:a.title,qty:o.quantity,unitPrice:a.price,currency:e.options.currency,imageUrl:a.images[0]?.url,productId:a.id,tokenizedAsset:!!a.tokenizedAssetConfig}}),s=n.reduce((o,a)=>o+a.qty*a.unitPrice,0);return{id:`ord_${Math.random().toString(16).slice(2)}`,createdAt:t,status:"paid",total:s,currency:e.options.currency,items:n,receiptUrl:e.options.successUrl}}function Yf(){let e=[];const t={};return{async listProducts(n){await jt(150);const s=n.page??1,o=n.pageSize??24,a=qf(rs,n),i=Hf(a,n.sort);return Zf(i,s,o)},async getProductBySlug(n){return await jt(100),rs.find(s=>s.slug===n)??null},async listCategories(){return await jt(80),el},async getOrderHistory(){return await jt(120),e},async getCart({customerId:n}){return await jt(80),t[n]??{items:[]}},async mergeCart({customerId:n,cart:s}){await jt(120);const o=t[n]??{items:[]},a=new Map,i=l=>{const u=`${l.productId}::${l.variantId??""}`,m=a.get(u);m?a.set(u,{...m,qty:m.qty+l.qty}):a.set(u,l)};for(const l of o.items)i(l);for(const l of s.items)i(l);const c={items:Array.from(a.values()),promoCode:s.promoCode??o.promoCode};return t[n]=c,c},async updateCart({customerId:n,cart:s}){await jt(60),t[n]=s},async createCheckoutSession(n){await jt(250);const s=Gf(n);if(e=[s,...e].slice(0,25),n.options.successUrl){const o=new URL(n.options.successUrl,"http://localhost");return o.searchParams.set("demoOrderId",s.id),{kind:"redirect",url:o.toString().replace("http://localhost","")}}return{kind:"custom",data:{orderId:s.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 vi=50,Kf=4,Qf=5,Jf=1e4,Xf={maxRetries:2,initialDelayMs:100,backoffFactor:2,maxDelayMs:500,jitter:!1};function tl(e){return e.replace(/[_-]+/g," ").trim().replace(/\b\w/g,t=>t.toUpperCase())}function ep(e){return e?e.toUpperCase():"USD"}function tp(e){if(e&&(e==="in_stock"||e==="low"||e==="out_of_stock"||e==="backorder"))return e}function np(e){if(e&&(e==="physical"||e==="digital"))return e}function rp(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 s=JSON.parse(n);if(Array.isArray(s))for(const o of s)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=ep(e.fiatCurrency),n=e.images&&e.images.length?e.images:e.imageUrl?[{url:e.imageUrl,alt:e.title}]:[],s=e.effectiveFiatAmountCents??e.fiatAmountCents??0,o=e.compareAtAmountCents,a=e.metadata?.shippingCountries??e.metadata?.shipping_countries,i=rp(a);return{id:e.id,slug:e.slug??e.id,title:e.title??tl(e.id),description:e.description??"",images:n,price:s/100,currency:t,tags:e.tags??[],categoryIds:e.categoryIds??[],inventoryStatus:tp(e.inventoryStatus),inventoryQuantity:typeof e.inventoryQuantity=="number"?e.inventoryQuantity:void 0,compareAtPrice:typeof o=="number"?o/100:void 0,shippingProfile:np(e.shippingProfile),checkoutRequirements:e.checkoutRequirements,fulfillment:e.fulfillment,tokenizedAssetConfig:e.tokenizedAssetConfig,attributes:i.length?{shippingCountries:i.join(",")}:void 0}}function Kr(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 Ot(e,t,n,s={}){const{body:o,headers:a,method:i="GET",retryableRead:c=!1,timeoutMs:l=Jf}=s,u={};n&&(u["X-API-Key"]=n),a&&Object.assign(u,a);const m=async()=>{const d=await Ie.fetchWithTimeout(`${e}${t}`,{body:o,headers:u,method:i},l);if(!d.ok){const x=await d.text().catch(()=>""),h=new Error(`Request failed (${d.status}): ${x}`);throw h.status=d.status,h}return d.json()};return c?Ie.retryWithBackoff(m,{...Xf,name:`paywall-read-${i.toLowerCase()}`}):m()}async function sp(e,t,n,s){const o=await Ot(e,`/paywall/v1/products?limit=${n}&offset=${s}`,t,{retryableRead:!0});return Kr(o)}async function yi(e,t,n,s){const{maxPages:o,pageSize:a}=n;for(let i=0;i<o;i+=1){const c=i*a,{products:l,total:u}=await sp(e,t,a,c);if(l.length===0||s(l))return;const m=typeof u=="number"&&c+l.length>=u,d=l.length<a;if(m||d)return}}function op(e){const t=async m=>{const d=m.page??1,x=m.pageSize??24,h=x,v=(d-1)*x,p=new URLSearchParams;p.set("limit",String(h)),p.set("offset",String(v)),m.search&&p.set("search",m.search),m.category&&p.set("category",m.category),m.sort&&p.set("sort",m.sort),m.filters?.inStock&&p.set("in_stock","true"),m.filters?.minPrice!=null&&p.set("min_price",String(m.filters.minPrice)),m.filters?.maxPrice!=null&&p.set("max_price",String(m.filters.maxPrice));const g=m.filters?.tags,y=Array.isArray(g)?g:typeof g=="string"?[g]:[];y.length&&p.set("tags",y.join(","));const w=await Ot(e.serverUrl,`/paywall/v1/products?${p.toString()}`,e.apiKey,{retryableRead:!0}),{products:j,total:k}=Kr(w);return{items:j.map(Tn),page:d,pageSize:x,total:k,hasNextPage:typeof k=="number"?v+h<k:j.length===h}},n=async m=>{try{const d=await Ot(e.serverUrl,`/paywall/v1/products/by-slug/${encodeURIComponent(m)}`,e.apiKey,{retryableRead:!0});return Tn(d)}catch(d){const x=d?.status;if(x!==404&&x!==405)throw d;try{const h=await Ot(e.serverUrl,`/paywall/v1/products/${encodeURIComponent(m)}`,e.apiKey,{retryableRead:!0});return Tn(h)}catch(h){const v=h?.status;if(v!==404&&v!==405)throw h;let p;return await yi(e.serverUrl,e.apiKey,{maxPages:Kf,pageSize:vi},g=>(p=g.find(y=>y.slug===m||y.id===m),!!p)),p?Tn(p):null}}};return{listProducts:t,getProductBySlug:n,getProductsByIds:async m=>{const d=Array.from(new Set(m.filter(Boolean)));if(d.length===0)return new Map;const x=new Map;try{const p=new URLSearchParams;p.set("ids",d.join(",")),p.set("limit",String(d.length)),p.set("offset","0");const g=await Ot(e.serverUrl,`/paywall/v1/products?${p.toString()}`,e.apiKey,{retryableRead:!0}),{products:y}=Kr(g);for(const w of y){const j=Tn(w);x.set(j.id,j),j.slug&&j.slug!==j.id&&x.set(j.slug,j)}}catch{}const h=d.filter(p=>!x.has(p));if(h.length===0)return x;let v=h;try{const p=new Set(v);if(await yi(e.serverUrl,e.apiKey,{maxPages:Qf,pageSize:vi},g=>{for(const y of g){const w=Tn(y);!p.has(w.id)&&!(w.slug&&p.has(w.slug))||(x.set(w.id,w),w.slug&&w.slug!==w.id&&x.set(w.slug,w),p.delete(w.id),w.slug&&p.delete(w.slug))}return p.size===0}),v=Array.from(p),v.length===0)return x}catch{}for(const p of v)try{const g=await n(p);g&&(x.set(g.id,g),g.slug&&g.slug!==g.id&&x.set(g.slug,g))}catch{}return x},listCategories:async()=>{const m=await Ot(e.serverUrl,"/paywall/v1/products?limit=500&offset=0",e.apiKey,{retryableRead:!0}),{products:d}=Kr(m),x=new Set;for(const h of d)for(const v of h.categoryIds??[])x.add(v);return Array.from(x).map(h=>({id:h,slug:h,name:tl(h)}))},getOrderHistory:async()=>[],createCheckoutSession:async m=>{throw new Error("createCheckoutSession is not implemented for paywall adapter")},getStorefrontSettings:async()=>{try{return(await Ot(e.serverUrl,"/paywall/v1/storefront",e.apiKey,{retryableRead:!0})).config??null}catch{return null}},getPaymentMethodsConfig:async()=>{try{const d=(await Ot(e.serverUrl,"/paywall/v1/storefront",e.apiKey,{retryableRead:!0})).paymentMethods;return d?{card:!!d.stripe,crypto:!!d.x402,credits:!!d.credits}:null}catch{return null}},getAIRelatedProducts:async m=>Ot(e.serverUrl,"/admin/ai/related-products",e.apiKey,{method:"POST",body:JSON.stringify(m),headers:{"Content-Type":"application/json"},retryableRead:!1}),sendChatMessage:async m=>{const d={message:m.message};return m.sessionId&&(d.sessionId=m.sessionId),Ot(e.serverUrl,"/paywall/v1/chat",e.apiKey,{method:"POST",body:JSON.stringify(d),headers:{"Content-Type":"application/json"},retryableRead:!1})}}}function ap(e){throw new Error(`Unhandled cart action: ${JSON.stringify(e)}`)}function fn(e){return`${e.productId}::${e.variantId??""}`}const ip={items:[]};function cp(e,t){switch(t.type){case"cart/hydrate":return t.state;case"cart/add":{const n=Math.max(1,Math.floor(t.qty??1)),s=fn(t.item);return e.items.find(a=>fn(a)===s)?{...e,items:e.items.map(a=>fn(a)===s?{...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(s=>fn(s)!==n)}}case"cart/setQty":{const n=Math.max(0,Math.floor(t.qty)),s=`${t.productId}::${t.variantId??""}`;return n===0?{...e,items:e.items.filter(o=>fn(o)!==s)}:{...e,items:e.items.map(o=>fn(o)===s?{...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(s=>fn(s)===n?{...s,holdId:t.holdId,holdExpiresAt:t.holdExpiresAt}:s)}}default:return ap(t)}}function lp(e){return e.reduce((t,n)=>t+n.qty,0)}function dp(e){return e.reduce((t,n)=>t+n.qty*n.unitPrice,0)}function bi(){try{return typeof window>"u"?null:window.localStorage}catch{return null}}function up(e,t){try{const n=e.getItem(t);return n?JSON.parse(n):null}catch{return null}}function mp(e,t,n){try{return e.setItem(t,JSON.stringify(n)),!0}catch(s){return console.warn(`[cedros] Failed to write "${t}" to storage`,s),!1}}const nl=b.createContext(null);function Et(){const e=b.useContext(nl);if(!e)throw new Error("useCart must be used within CartProvider");return e}function wi(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 fp({children:e}){const{config:t}=Ae(),n=t.cart?.storageKey??"cedros_shop_cart_v1",s=t.customer?.id,o=t.customer?.isSignedIn??!!s,a=t.cart?.syncDebounceMs??800,i=!!t.adapter.getCartInventoryStatus,[c,l]=b.useReducer(cp,ip),u=b.useRef(c);u.current=c;const[m,d]=b.useState(!1),x=b.useRef(!1),h=b.useRef(null),v=b.useRef(null);b.useEffect(()=>{const w=bi();if(!w)return;const j=up(w,n);if(j&&Array.isArray(j.items)){const k=j.items.filter(wi);l({type:"cart/hydrate",state:{items:k,promoCode:typeof j.promoCode=="string"?j.promoCode:void 0}})}d(!0)},[n]),b.useEffect(()=>{if(!m)return;const w=bi();w&&mp(w,n,c)},[c,n,m]),b.useEffect(()=>{if(!m||!o||!s||!t.adapter.mergeCart&&!t.adapter.getCart||(v.current!==s&&(x.current=!1,h.current=null,v.current=s),x.current))return;let w=!1;return(async()=>{try{const j=t.adapter.mergeCart?await t.adapter.mergeCart({customerId:s,cart:u.current}):await t.adapter.getCart({customerId:s});if(w)return;if(j&&Array.isArray(j.items)){x.current=!0;const k={...j,items:j.items.filter(wi)};l({type:"cart/hydrate",state:k}),h.current=JSON.stringify(k)}}catch{w||(x.current=!1)}})(),()=>{w=!0}},[t.adapter,s,m,o]),b.useEffect(()=>{if(!m||!o||!s||!t.adapter.updateCart||!x.current||typeof window>"u")return;const w=JSON.stringify(c);if(h.current===w)return;const j=window.setTimeout(()=>{t.adapter.updateCart({customerId:s,cart:c}).then(()=>{h.current=w}).catch(k=>{console.warn("[CedrosPay] Cart server sync failed:",k instanceof Error?k.message:k)})},a);return()=>window.clearTimeout(j)},[t.adapter,s,m,o,c,a]);const p=b.useCallback((w,j)=>{const k=c.items.find(_=>_.productId===w&&_.variantId===j);if(k)return{holdId:k.holdId,expiresAt:k.holdExpiresAt}},[c.items]),g=b.useCallback((w,j,k)=>{l({type:"cart/updateHold",productId:w,variantId:j,holdExpiresAt:k})},[]),y=b.useMemo(()=>{const w=lp(c.items),j=dp(c.items);return{items:c.items,promoCode:c.promoCode,count:w,subtotal:j,addItem:(k,_)=>l({type:"cart/add",item:k,qty:_}),removeItem:(k,_)=>l({type:"cart/remove",productId:k,variantId:_}),setQty:(k,_,S)=>l({type:"cart/setQty",productId:k,variantId:_,qty:S}),clear:()=>l({type:"cart/clear"}),setPromoCode:k=>l({type:"cart/setPromoCode",promoCode:k}),holdsSupported:i,getItemHold:p,updateItemHold:g}},[c.items,c.promoCode,i,p,g]);return r.jsx(nl.Provider,{value:y,children:e})}function $(e,t,n){function s(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 u=i.prototype,m=Object.keys(u);for(let d=0;d<m.length;d++){const x=m[d];x in c||(c[x]=u[x].bind(c))}}const o=n?.Parent??Object;class a extends o{}Object.defineProperty(a,"name",{value:e});function i(c){var l;const u=n?.Parent?new a:this;s(u,c),(l=u._zod).deferred??(l.deferred=[]);for(const m of u._zod.deferred)m();return u}return Object.defineProperty(i,"init",{value:s}),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 rl extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const sl={};function hn(e){return sl}function ol(e){const t=Object.values(e).filter(s=>typeof s=="number");return Object.entries(e).filter(([s,o])=>t.indexOf(+s)===-1).map(([s,o])=>o)}function Ro(e,t){return typeof t=="bigint"?t.toString():t}function ra(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function sa(e){return e==null}function oa(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function pp(e,t){const n=(e.toString().split(".")[1]||"").length,s=t.toString();let o=(s.split(".")[1]||"").length;if(o===0&&/\d?e-\d?/.test(s)){const l=s.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 ki=Symbol("evaluating");function we(e,t,n){let s;Object.defineProperty(e,t,{get(){if(s!==ki)return s===void 0&&(s=ki,s=n()),s},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function wn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function sn(...e){const t={};for(const n of e){const s=Object.getOwnPropertyDescriptors(n);Object.assign(t,s)}return Object.defineProperties({},t)}function ji(e){return JSON.stringify(e)}function hp(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const al="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function ss(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const gp=ra(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function gr(e){if(ss(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(ss(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function il(e){return gr(e)?{...e}:Array.isArray(e)?[...e]:e}const xp=new Set(["string","number","symbol"]);function Fn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function on(e,t,n){const s=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(s._zod.parent=e),s}function ae(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 vp(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const yp={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 bp(e,t){const n=e._zod.def,s=n.checks;if(s&&s.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const a=sn(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 wn(this,"shape",i),i},checks:[]});return on(e,a)}function wp(e,t){const n=e._zod.def,s=n.checks;if(s&&s.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const a=sn(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 wn(this,"shape",i),i},checks:[]});return on(e,a)}function kp(e,t){if(!gr(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=sn(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t};return wn(this,"shape",a),a}});return on(e,o)}function jp(e,t){if(!gr(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=sn(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return wn(this,"shape",s),s}});return on(e,n)}function _p(e,t){const n=sn(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t._zod.def.shape};return wn(this,"shape",s),s},get catchall(){return t._zod.def.catchall},checks:[]});return on(e,n)}function Sp(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=sn(t._zod.def,{get shape(){const c=t._zod.def.shape,l={...c};if(n)for(const u in n){if(!(u in c))throw new Error(`Unrecognized key: "${u}"`);n[u]&&(l[u]=e?new e({type:"optional",innerType:c[u]}):c[u])}else for(const u in c)l[u]=e?new e({type:"optional",innerType:c[u]}):c[u];return wn(this,"shape",l),l},checks:[]});return on(t,i)}function Cp(e,t,n){const s=sn(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 wn(this,"shape",a),a}});return on(t,s)}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 cl(e,t){return t.map(n=>{var s;return(s=n).path??(s.path=[]),n.path.unshift(e),n})}function Rr(e){return typeof e=="string"?e:e?.message}function gn(e,t,n){const s={...e,path:e.path??[]};if(!e.message){const o=Rr(e.inst?._zod.def?.error?.(e))??Rr(t?.error?.(e))??Rr(n.customError?.(e))??Rr(n.localeError?.(e))??"Invalid input";s.message=o}return delete s.inst,delete s.continue,t?.reportInput||delete s.input,s}function aa(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function xr(...e){const[t,n,s]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:s}:{...t}}const ll=(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,Ro,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},dl=$("$ZodError",ll),ul=$("$ZodError",ll,{Parent:Error});function Np(e,t=n=>n.message){const n={},s=[];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))):s.push(t(o));return{formErrors:s,fieldErrors:n}}function Ap(e,t=n=>n.message){const n={_errors:[]},s=o=>{for(const a of o.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map(i=>s({issues:i}));else if(a.code==="invalid_key")s({issues:a.issues});else if(a.code==="invalid_element")s({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 s(e),n}const ia=e=>(t,n,s,o)=>{const a=s?Object.assign(s,{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=>gn(l,a,hn())));throw al(c,o?.callee),c}return i.value},ca=e=>async(t,n,s,o)=>{const a=s?Object.assign(s,{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=>gn(l,a,hn())));throw al(c,o?.callee),c}return i.value},js=e=>(t,n,s)=>{const o=s?{...s,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??dl)(a.issues.map(i=>gn(i,o,hn())))}:{success:!0,data:a.value}},Ep=js(ul),_s=e=>async(t,n,s)=>{const o=s?Object.assign(s,{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=>gn(i,o,hn())))}:{success:!0,data:a.value}},Ip=_s(ul),Tp=e=>(t,n,s)=>{const o=s?Object.assign(s,{direction:"backward"}):{direction:"backward"};return ia(e)(t,n,o)},Pp=e=>(t,n,s)=>ia(e)(t,n,s),Rp=e=>async(t,n,s)=>{const o=s?Object.assign(s,{direction:"backward"}):{direction:"backward"};return ca(e)(t,n,o)},Op=e=>async(t,n,s)=>ca(e)(t,n,s),Mp=e=>(t,n,s)=>{const o=s?Object.assign(s,{direction:"backward"}):{direction:"backward"};return js(e)(t,n,o)},Lp=e=>(t,n,s)=>js(e)(t,n,s),Dp=e=>async(t,n,s)=>{const o=s?Object.assign(s,{direction:"backward"}):{direction:"backward"};return _s(e)(t,n,o)},zp=e=>async(t,n,s)=>_s(e)(t,n,s),$p=/^[cC][^\s-]{8,}$/,Fp=/^[0-9a-z]+$/,Up=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Bp=/^[0-9a-vA-V]{20}$/,Vp=/^[A-Za-z0-9]{27}$/,Wp=/^[a-zA-Z0-9_-]{21}$/,qp=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Hp=/^([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})$/,_i=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)$/,Zp=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Gp="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Yp(){return new RegExp(Gp,"u")}const Kp=/^(?:(?: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])$/,Qp=/^(([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}|:))$/,Jp=/^((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])$/,Xp=/^(([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])$/,eh=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,ml=/^[A-Za-z0-9_-]*$/,th=/^\+[1-9]\d{6,14}$/,fl="(?:(?:\\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])))",nh=new RegExp(`^${fl}$`);function pl(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 rh(e){return new RegExp(`^${pl(e)}$`)}function sh(e){const t=pl({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const s=`${t}(?:${n.join("|")})`;return new RegExp(`^${fl}T(?:${s})$`)}const oh=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},ah=/^-?\d+$/,ih=/^-?\d+(?:\.\d+)?$/,ch=/^(?:true|false)$/i,lh=/^[^A-Z]*$/,dh=/^[^a-z]*$/,dt=$("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),hl={number:"number",bigint:"bigint",object:"date"},gl=$("$ZodCheckLessThan",(e,t)=>{dt.init(e,t);const n=hl[typeof t.value];e._zod.onattach.push(s=>{const o=s._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=s=>{(t.inclusive?s.value<=t.value:s.value<t.value)||s.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:s.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),xl=$("$ZodCheckGreaterThan",(e,t)=>{dt.init(e,t);const n=hl[typeof t.value];e._zod.onattach.push(s=>{const o=s._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=s=>{(t.inclusive?s.value>=t.value:s.value>t.value)||s.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:s.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),uh=$("$ZodCheckMultipleOf",(e,t)=>{dt.init(e,t),e._zod.onattach.push(n=>{var s;(s=n._zod.bag).multipleOf??(s.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):pp(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})}}),mh=$("$ZodCheckNumberFormat",(e,t)=>{dt.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),s=n?"int":"number",[o,a]=yp[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=ah)}),e._zod.check=i=>{const c=i.value;if(n){if(!Number.isInteger(c)){i.issues.push({expected:s,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:s,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:s,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})}}),fh=$("$ZodCheckMaxLength",(e,t)=>{var n;dt.init(e,t),(n=e._zod.def).when??(n.when=s=>{const o=s.value;return!sa(o)&&o.length!==void 0}),e._zod.onattach.push(s=>{const o=s._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(s._zod.bag.maximum=t.maximum)}),e._zod.check=s=>{const o=s.value;if(o.length<=t.maximum)return;const i=aa(o);s.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),ph=$("$ZodCheckMinLength",(e,t)=>{var n;dt.init(e,t),(n=e._zod.def).when??(n.when=s=>{const o=s.value;return!sa(o)&&o.length!==void 0}),e._zod.onattach.push(s=>{const o=s._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(s._zod.bag.minimum=t.minimum)}),e._zod.check=s=>{const o=s.value;if(o.length>=t.minimum)return;const i=aa(o);s.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),hh=$("$ZodCheckLengthEquals",(e,t)=>{var n;dt.init(e,t),(n=e._zod.def).when??(n.when=s=>{const o=s.value;return!sa(o)&&o.length!==void 0}),e._zod.onattach.push(s=>{const o=s._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=s=>{const o=s.value,a=o.length;if(a===t.length)return;const i=aa(o),c=a>t.length;s.issues.push({origin:i,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:s.value,inst:e,continue:!t.abort})}}),Ss=$("$ZodCheckStringFormat",(e,t)=>{var n,s;dt.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})}):(s=e._zod).check??(s.check=()=>{})}),gh=$("$ZodCheckRegex",(e,t)=>{Ss.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})}}),xh=$("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=lh),Ss.init(e,t)}),vh=$("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=dh),Ss.init(e,t)}),yh=$("$ZodCheckIncludes",(e,t)=>{dt.init(e,t);const n=Fn(t.includes),s=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=s,e._zod.onattach.push(o=>{const a=o._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(s)}),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})}}),bh=$("$ZodCheckStartsWith",(e,t)=>{dt.init(e,t);const n=new RegExp(`^${Fn(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(s=>{const o=s._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=s=>{s.value.startsWith(t.prefix)||s.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:s.value,inst:e,continue:!t.abort})}}),wh=$("$ZodCheckEndsWith",(e,t)=>{dt.init(e,t);const n=new RegExp(`.*${Fn(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(s=>{const o=s._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=s=>{s.value.endsWith(t.suffix)||s.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:s.value,inst:e,continue:!t.abort})}}),kh=$("$ZodCheckOverwrite",(e,t)=>{dt.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class jh{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 s=t.split(`
2
+ `).filter(i=>i),o=Math.min(...s.map(i=>i.length-i.trimStart().length)),a=s.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 _h={major:4,minor:3,patch:6},Pe=$("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=_h;const s=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&s.unshift(e);for(const o of s)for(const a of o._zod.onattach)a(e);if(s.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 u=Ln(i),m;for(const d of c){if(d._zod.def.when){if(!d._zod.def.when(i))continue}else if(u)continue;const x=i.issues.length,h=d._zod.check(i);if(h instanceof Promise&&l?.async===!1)throw new Dn;if(m||h instanceof Promise)m=(m??Promise.resolve()).then(async()=>{await h,i.issues.length!==x&&(u||(u=Ln(i,x)))});else{if(i.issues.length===x)continue;u||(u=Ln(i,x))}}return m?m.then(()=>i):i},a=(i,c,l)=>{if(Ln(i))return i.aborted=!0,i;const u=o(c,s,l);if(u instanceof Promise){if(l.async===!1)throw new Dn;return u.then(m=>e._zod.parse(m,l))}return e._zod.parse(u,l)};e._zod.run=(i,c)=>{if(c.skipChecks)return e._zod.parse(i,c);if(c.direction==="backward"){const u=e._zod.parse({value:i.value,issues:[]},{...c,skipChecks:!0});return u instanceof Promise?u.then(m=>a(m,i,c)):a(u,i,c)}const l=e._zod.parse(i,c);if(l instanceof Promise){if(c.async===!1)throw new Dn;return l.then(u=>o(u,s,c))}return o(l,s,c)}}we(e,"~standard",()=>({validate:o=>{try{const a=Ep(e,o);return a.success?{value:a.data}:{issues:a.error?.issues}}catch{return Ip(e,o).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}))}),la=$("$ZodString",(e,t)=>{Pe.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??oh(e._zod.bag),e._zod.parse=(n,s)=>{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}}),Ce=$("$ZodStringFormat",(e,t)=>{Ss.init(e,t),la.init(e,t)}),Sh=$("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Hp),Ce.init(e,t)}),Ch=$("$ZodUUID",(e,t)=>{if(t.version){const s={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(s===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=_i(s))}else t.pattern??(t.pattern=_i());Ce.init(e,t)}),Nh=$("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Zp),Ce.init(e,t)}),Ah=$("$ZodURL",(e,t)=>{Ce.init(e,t),e._zod.check=n=>{try{const s=n.value.trim(),o=new URL(s);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=s;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Eh=$("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Yp()),Ce.init(e,t)}),Ih=$("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Wp),Ce.init(e,t)}),Th=$("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=$p),Ce.init(e,t)}),Ph=$("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Fp),Ce.init(e,t)}),Rh=$("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Up),Ce.init(e,t)}),Oh=$("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Bp),Ce.init(e,t)}),Mh=$("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Vp),Ce.init(e,t)}),Lh=$("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=sh(t)),Ce.init(e,t)}),Dh=$("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=nh),Ce.init(e,t)}),zh=$("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=rh(t)),Ce.init(e,t)}),$h=$("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=qp),Ce.init(e,t)}),Fh=$("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Kp),Ce.init(e,t),e._zod.bag.format="ipv4"}),Uh=$("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Qp),Ce.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})}}}),Bh=$("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Jp),Ce.init(e,t)}),Vh=$("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Xp),Ce.init(e,t),e._zod.check=n=>{const s=n.value.split("/");try{if(s.length!==2)throw new Error;const[o,a]=s;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 vl(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Wh=$("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=eh),Ce.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{vl(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function qh(e){if(!ml.test(e))return!1;const t=e.replace(/[-_]/g,s=>s==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return vl(n)}const Hh=$("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=ml),Ce.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{qh(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Zh=$("$ZodE164",(e,t)=>{t.pattern??(t.pattern=th),Ce.init(e,t)});function Gh(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[s]=n;if(!s)return!1;const o=JSON.parse(atob(s));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}const Yh=$("$ZodJWT",(e,t)=>{Ce.init(e,t),e._zod.check=n=>{Gh(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),yl=$("$ZodNumber",(e,t)=>{Pe.init(e,t),e._zod.pattern=e._zod.bag.pattern??ih,e._zod.parse=(n,s)=>{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}}),Kh=$("$ZodNumberFormat",(e,t)=>{mh.init(e,t),yl.init(e,t)}),Qh=$("$ZodBoolean",(e,t)=>{Pe.init(e,t),e._zod.pattern=ch,e._zod.parse=(n,s)=>{if(t.coerce)try{n.value=!!n.value}catch{}const o=n.value;return typeof o=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}}),Jh=$("$ZodUnknown",(e,t)=>{Pe.init(e,t),e._zod.parse=n=>n}),Xh=$("$ZodNever",(e,t)=>{Pe.init(e,t),e._zod.parse=(n,s)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Si(e,t,n){e.issues.length&&t.issues.push(...cl(n,e.issues)),t.value[n]=e.value}const eg=$("$ZodArray",(e,t)=>{Pe.init(e,t),e._zod.parse=(n,s)=>{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:[]},s);l instanceof Promise?a.push(l.then(u=>Si(u,n,i))):Si(l,n,i)}return a.length?Promise.all(a).then(()=>n):n}});function os(e,t,n,s,o){if(e.issues.length){if(o&&!(n in s))return;t.issues.push(...cl(n,e.issues))}e.value===void 0?n in s&&(t.value[n]=void 0):t.value[n]=e.value}function bl(e){const t=Object.keys(e.shape);for(const s of t)if(!e.shape?.[s]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${s}": expected a Zod schema`);const n=vp(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function wl(e,t,n,s,o,a){const i=[],c=o.keySet,l=o.catchall._zod,u=l.def.type,m=l.optout==="optional";for(const d in t){if(c.has(d))continue;if(u==="never"){i.push(d);continue}const x=l.run({value:t[d],issues:[]},s);x instanceof Promise?e.push(x.then(h=>os(h,n,d,t,m))):os(x,n,d,t,m)}return i.length&&n.issues.push({code:"unrecognized_keys",keys:i,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}const tg=$("$ZodObject",(e,t)=>{if(Pe.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 s=ra(()=>bl(t));we(e._zod,"propValues",()=>{const c=t.shape,l={};for(const u in c){const m=c[u]._zod;if(m.values){l[u]??(l[u]=new Set);for(const d of m.values)l[u].add(d)}}return l});const o=ss,a=t.catchall;let i;e._zod.parse=(c,l)=>{i??(i=s.value);const u=c.value;if(!o(u))return c.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),c;c.value={};const m=[],d=i.shape;for(const x of i.keys){const h=d[x],v=h._zod.optout==="optional",p=h._zod.run({value:u[x],issues:[]},l);p instanceof Promise?m.push(p.then(g=>os(g,c,x,u,v))):os(p,c,x,u,v)}return a?wl(m,u,c,l,s.value,e):m.length?Promise.all(m).then(()=>c):c}}),ng=$("$ZodObjectJIT",(e,t)=>{tg.init(e,t);const n=e._zod.parse,s=ra(()=>bl(t)),o=x=>{const h=new jh(["shape","payload","ctx"]),v=s.value,p=j=>{const k=ji(j);return`shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`};h.write("const input = payload.value;");const g=Object.create(null);let y=0;for(const j of v.keys)g[j]=`key_${y++}`;h.write("const newResult = {};");for(const j of v.keys){const k=g[j],_=ji(j),A=x[j]?._zod?.optout==="optional";h.write(`const ${k} = ${p(j)};`),A?h.write(`
4
+ if (${k}.issues.length) {
5
+ if (${_} in input) {
6
+ payload.issues = payload.issues.concat(${k}.issues.map(iss => ({
7
+ ...iss,
8
+ path: iss.path ? [${_}, ...iss.path] : [${_}]
9
+ })));
10
+ }
11
+ }
12
+
13
+ if (${k}.value === undefined) {
14
+ if (${_} in input) {
15
+ newResult[${_}] = undefined;
16
+ }
17
+ } else {
18
+ newResult[${_}] = ${k}.value;
19
+ }
20
+
21
+ `):h.write(`
22
+ if (${k}.issues.length) {
23
+ payload.issues = payload.issues.concat(${k}.issues.map(iss => ({
24
+ ...iss,
25
+ path: iss.path ? [${_}, ...iss.path] : [${_}]
26
+ })));
27
+ }
28
+
29
+ if (${k}.value === undefined) {
30
+ if (${_} in input) {
31
+ newResult[${_}] = undefined;
32
+ }
33
+ } else {
34
+ newResult[${_}] = ${k}.value;
35
+ }
36
+
37
+ `)}h.write("payload.value = newResult;"),h.write("return payload;");const w=h.compile();return(j,k)=>w(x,j,k)};let a;const i=ss,c=!sl.jitless,u=c&&gp.value,m=t.catchall;let d;e._zod.parse=(x,h)=>{d??(d=s.value);const v=x.value;return i(v)?c&&u&&h?.async===!1&&h.jitless!==!0?(a||(a=o(t.shape)),x=a(x,h),m?wl([],v,x,h,d,e):x):n(x,h):(x.issues.push({expected:"object",code:"invalid_type",input:v,inst:e}),x)}});function Ci(e,t,n,s){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=>gn(i,s,hn())))}),t)}const rg=$("$ZodUnion",(e,t)=>{Pe.init(e,t),we(e._zod,"optin",()=>t.options.some(o=>o._zod.optin==="optional")?"optional":void 0),we(e._zod,"optout",()=>t.options.some(o=>o._zod.optout==="optional")?"optional":void 0),we(e._zod,"values",()=>{if(t.options.every(o=>o._zod.values))return new Set(t.options.flatMap(o=>Array.from(o._zod.values)))}),we(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=>oa(a.source)).join("|")})$`)}});const n=t.options.length===1,s=t.options[0]._zod.run;e._zod.parse=(o,a)=>{if(n)return s(o,a);let i=!1;const c=[];for(const l of t.options){const u=l._zod.run({value:o.value,issues:[]},a);if(u instanceof Promise)c.push(u),i=!0;else{if(u.issues.length===0)return u;c.push(u)}}return i?Promise.all(c).then(l=>Ci(l,o,e,a)):Ci(c,o,e,a)}}),sg=$("$ZodIntersection",(e,t)=>{Pe.init(e,t),e._zod.parse=(n,s)=>{const o=n.value,a=t.left._zod.run({value:o,issues:[]},s),i=t.right._zod.run({value:o,issues:[]},s);return a instanceof Promise||i instanceof Promise?Promise.all([a,i]).then(([l,u])=>Ni(n,l,u)):Ni(n,a,i)}});function Oo(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(gr(e)&&gr(t)){const n=Object.keys(t),s=Object.keys(e).filter(a=>n.indexOf(a)!==-1),o={...e,...t};for(const a of s){const i=Oo(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 s=0;s<e.length;s++){const o=e[s],a=t[s],i=Oo(o,a);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Ni(e,t,n){const s=new Map;let o;for(const c of t.issues)if(c.code==="unrecognized_keys"){o??(o=c);for(const l of c.keys)s.has(l)||s.set(l,{}),s.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)s.has(l)||s.set(l,{}),s.get(l).r=!0;else e.issues.push(c);const a=[...s].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=Oo(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 og=$("$ZodEnum",(e,t)=>{Pe.init(e,t);const n=ol(t.entries),s=new Set(n);e._zod.values=s,e._zod.pattern=new RegExp(`^(${n.filter(o=>xp.has(typeof o)).map(o=>typeof o=="string"?Fn(o):o.toString()).join("|")})$`),e._zod.parse=(o,a)=>{const i=o.value;return s.has(i)||o.issues.push({code:"invalid_value",values:n,input:i,inst:e}),o}}),ag=$("$ZodLiteral",(e,t)=>{if(Pe.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(s=>typeof s=="string"?Fn(s):s?Fn(s.toString()):String(s)).join("|")})$`),e._zod.parse=(s,o)=>{const a=s.value;return n.has(a)||s.issues.push({code:"invalid_value",values:t.values,input:a,inst:e}),s}}),ig=$("$ZodTransform",(e,t)=>{Pe.init(e,t),e._zod.parse=(n,s)=>{if(s.direction==="backward")throw new rl(e.constructor.name);const o=t.transform(n.value,n);if(s.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 Ai(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const kl=$("$ZodOptional",(e,t)=>{Pe.init(e,t),e._zod.optin="optional",e._zod.optout="optional",we(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),we(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${oa(n.source)})?$`):void 0}),e._zod.parse=(n,s)=>{if(t.innerType._zod.optin==="optional"){const o=t.innerType._zod.run(n,s);return o instanceof Promise?o.then(a=>Ai(a,n.value)):Ai(o,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,s)}}),cg=$("$ZodExactOptional",(e,t)=>{kl.init(e,t),we(e._zod,"values",()=>t.innerType._zod.values),we(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,s)=>t.innerType._zod.run(n,s)}),lg=$("$ZodNullable",(e,t)=>{Pe.init(e,t),we(e._zod,"optin",()=>t.innerType._zod.optin),we(e._zod,"optout",()=>t.innerType._zod.optout),we(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${oa(n.source)}|null)$`):void 0}),we(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,s)=>n.value===null?n:t.innerType._zod.run(n,s)}),dg=$("$ZodDefault",(e,t)=>{Pe.init(e,t),e._zod.optin="optional",we(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,s)=>{if(s.direction==="backward")return t.innerType._zod.run(n,s);if(n.value===void 0)return n.value=t.defaultValue,n;const o=t.innerType._zod.run(n,s);return o instanceof Promise?o.then(a=>Ei(a,t)):Ei(o,t)}});function Ei(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const ug=$("$ZodPrefault",(e,t)=>{Pe.init(e,t),e._zod.optin="optional",we(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,s)=>(s.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,s))}),mg=$("$ZodNonOptional",(e,t)=>{Pe.init(e,t),we(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(s=>s!==void 0)):void 0}),e._zod.parse=(n,s)=>{const o=t.innerType._zod.run(n,s);return o instanceof Promise?o.then(a=>Ii(a,e)):Ii(o,e)}});function Ii(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 fg=$("$ZodCatch",(e,t)=>{Pe.init(e,t),we(e._zod,"optin",()=>t.innerType._zod.optin),we(e._zod,"optout",()=>t.innerType._zod.optout),we(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,s)=>{if(s.direction==="backward")return t.innerType._zod.run(n,s);const o=t.innerType._zod.run(n,s);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=>gn(i,s,hn()))},input:n.value}),n.issues=[]),n)):(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(a=>gn(a,s,hn()))},input:n.value}),n.issues=[]),n)}}),pg=$("$ZodPipe",(e,t)=>{Pe.init(e,t),we(e._zod,"values",()=>t.in._zod.values),we(e._zod,"optin",()=>t.in._zod.optin),we(e._zod,"optout",()=>t.out._zod.optout),we(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,s)=>{if(s.direction==="backward"){const a=t.out._zod.run(n,s);return a instanceof Promise?a.then(i=>Or(i,t.in,s)):Or(a,t.in,s)}const o=t.in._zod.run(n,s);return o instanceof Promise?o.then(a=>Or(a,t.out,s)):Or(o,t.out,s)}});function Or(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const hg=$("$ZodReadonly",(e,t)=>{Pe.init(e,t),we(e._zod,"propValues",()=>t.innerType._zod.propValues),we(e._zod,"values",()=>t.innerType._zod.values),we(e._zod,"optin",()=>t.innerType?._zod?.optin),we(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,s)=>{if(s.direction==="backward")return t.innerType._zod.run(n,s);const o=t.innerType._zod.run(n,s);return o instanceof Promise?o.then(Ti):Ti(o)}});function Ti(e){return e.value=Object.freeze(e.value),e}const gg=$("$ZodCustom",(e,t)=>{dt.init(e,t),Pe.init(e,t),e._zod.parse=(n,s)=>n,e._zod.check=n=>{const s=n.value,o=t.fn(s);if(o instanceof Promise)return o.then(a=>Pi(a,n,s,e));Pi(o,n,s,e)}});function Pi(e,t,n,s){if(!e){const o={code:"custom",input:n,inst:s,path:[...s._zod.def.path??[]],continue:!s._zod.def.abort};s._zod.def.params&&(o.params=s._zod.def.params),t.issues.push(xr(o))}}var Ri;class xg{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const s=n[0];return this._map.set(t,s),s&&typeof s=="object"&&"id"in s&&this._idmap.set(s.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 s={...this.get(n)??{}};delete s.id;const o={...s,...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 vg(){return new xg}(Ri=globalThis).__zod_globalRegistry??(Ri.__zod_globalRegistry=vg());const dr=globalThis.__zod_globalRegistry;function yg(e,t){return new e({type:"string",...ae(t)})}function bg(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...ae(t)})}function Oi(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...ae(t)})}function wg(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...ae(t)})}function kg(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...ae(t)})}function jg(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...ae(t)})}function _g(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...ae(t)})}function Sg(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...ae(t)})}function Cg(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...ae(t)})}function Ng(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...ae(t)})}function Ag(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...ae(t)})}function Eg(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...ae(t)})}function Ig(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...ae(t)})}function Tg(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...ae(t)})}function Pg(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...ae(t)})}function Rg(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...ae(t)})}function Og(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...ae(t)})}function Mg(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...ae(t)})}function Lg(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...ae(t)})}function Dg(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...ae(t)})}function zg(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...ae(t)})}function $g(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...ae(t)})}function Fg(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...ae(t)})}function Ug(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...ae(t)})}function Bg(e,t){return new e({type:"string",format:"date",check:"string_format",...ae(t)})}function Vg(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...ae(t)})}function Wg(e,t){return new e({type:"string",format:"duration",check:"string_format",...ae(t)})}function qg(e,t){return new e({type:"number",checks:[],...ae(t)})}function Hg(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...ae(t)})}function Zg(e,t){return new e({type:"boolean",...ae(t)})}function Gg(e){return new e({type:"unknown"})}function Yg(e,t){return new e({type:"never",...ae(t)})}function Mi(e,t){return new gl({check:"less_than",...ae(t),value:e,inclusive:!1})}function ao(e,t){return new gl({check:"less_than",...ae(t),value:e,inclusive:!0})}function Li(e,t){return new xl({check:"greater_than",...ae(t),value:e,inclusive:!1})}function io(e,t){return new xl({check:"greater_than",...ae(t),value:e,inclusive:!0})}function Di(e,t){return new uh({check:"multiple_of",...ae(t),value:e})}function jl(e,t){return new fh({check:"max_length",...ae(t),maximum:e})}function as(e,t){return new ph({check:"min_length",...ae(t),minimum:e})}function _l(e,t){return new hh({check:"length_equals",...ae(t),length:e})}function Kg(e,t){return new gh({check:"string_format",format:"regex",...ae(t),pattern:e})}function Qg(e){return new xh({check:"string_format",format:"lowercase",...ae(e)})}function Jg(e){return new vh({check:"string_format",format:"uppercase",...ae(e)})}function Xg(e,t){return new yh({check:"string_format",format:"includes",...ae(t),includes:e})}function ex(e,t){return new bh({check:"string_format",format:"starts_with",...ae(t),prefix:e})}function tx(e,t){return new wh({check:"string_format",format:"ends_with",...ae(t),suffix:e})}function Wn(e){return new kh({check:"overwrite",tx:e})}function nx(e){return Wn(t=>t.normalize(e))}function rx(){return Wn(e=>e.trim())}function sx(){return Wn(e=>e.toLowerCase())}function ox(){return Wn(e=>e.toUpperCase())}function ax(){return Wn(e=>hp(e))}function ix(e,t,n){return new e({type:"array",element:t,...ae(n)})}function cx(e,t,n){return new e({type:"custom",check:"custom",fn:t,...ae(n)})}function lx(e){const t=dx(n=>(n.addIssue=s=>{if(typeof s=="string")n.issues.push(xr(s,n.value,t._zod.def));else{const o=s;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(xr(o))}},e(n.value,n)));return t}function dx(e,t){const n=new dt({check:"custom",...ae(t)});return n._zod.check=e,n}function Sl(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??dr,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 Ge(e,t,n={path:[],schemaPath:[]}){var s;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 m={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,m);else{const x=i.schema,h=t.processors[o.type];if(!h)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);h(e,t,x,m)}const d=e._zod.parent;d&&(i.ref||(i.ref=d),Ge(d,t,m),t.seen.get(d).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&&((s=i.schema).default??(s.default=i.schema._prefault)),delete i.schema._prefault,t.seen.get(e).schema}function Cl(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const s=new Map;for(const i of e.seen.entries()){const c=e.metadataRegistry.get(i[0])?.id;if(c){const l=s.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.`);s.set(c,i[0])}}const o=i=>{const c=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const d=e.external.registry.get(i[0])?.id,x=e.external.uri??(v=>v);if(d)return{ref:x(d)};const h=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=h,{defId:h,ref:`${x("__shared")}#/${c}/${h}`}}if(i[1]===n)return{ref:"#"};const u=`#/${c}/`,m=i[1].schema.id??`__schema${e.counter++}`;return{defId:m,ref:u+m}},a=i=>{if(i[1].schema.$ref)return;const c=i[1],{ref:l,defId:u}=o(i);c.def={...c.schema},u&&(c.defId=u);const m=c.schema;for(const d in m)delete m[d];m.$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
+
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 u=e.external.registry.get(i[0])?.id;if(t!==i[0]&&u){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 Nl(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const s=i=>{const c=e.seen.get(i);if(c.ref===null)return;const l=c.def??c.schema,u={...l},m=c.ref;if(c.ref=null,m){s(m);const x=e.seen.get(m),h=x.schema;if(h.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(l.allOf=l.allOf??[],l.allOf.push(h)):Object.assign(l,h),Object.assign(l,u),i._zod.parent===m)for(const p in l)p==="$ref"||p==="allOf"||p in u||delete l[p];if(h.$ref&&x.def)for(const p in l)p==="$ref"||p==="allOf"||p in x.def&&JSON.stringify(l[p])===JSON.stringify(x.def[p])&&delete l[p]}const d=i._zod.parent;if(d&&d!==m){s(d);const x=e.seen.get(d);if(x?.schema.$ref&&(l.$ref=x.schema.$ref,x.def))for(const h in l)h==="$ref"||h==="allOf"||h in x.def&&JSON.stringify(l[h])===JSON.stringify(x.def[h])&&delete l[h]}e.override({zodSchema:i,jsonSchema:l,path:c.path??[]})};for(const i of[...e.seen.entries()].reverse())s(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:is(t,"input",e.processors),output:is(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 s=e._zod.def;if(s.type==="transform")return!0;if(s.type==="array")return nt(s.element,n);if(s.type==="set")return nt(s.valueType,n);if(s.type==="lazy")return nt(s.getter(),n);if(s.type==="promise"||s.type==="optional"||s.type==="nonoptional"||s.type==="nullable"||s.type==="readonly"||s.type==="default"||s.type==="prefault")return nt(s.innerType,n);if(s.type==="intersection")return nt(s.left,n)||nt(s.right,n);if(s.type==="record"||s.type==="map")return nt(s.keyType,n)||nt(s.valueType,n);if(s.type==="pipe")return nt(s.in,n)||nt(s.out,n);if(s.type==="object"){for(const o in s.shape)if(nt(s.shape[o],n))return!0;return!1}if(s.type==="union"){for(const o of s.options)if(nt(o,n))return!0;return!1}if(s.type==="tuple"){for(const o of s.items)if(nt(o,n))return!0;return!!(s.rest&&nt(s.rest,n))}return!1}const ux=(e,t={})=>n=>{const s=Sl({...n,processors:t});return Ge(e,s),Cl(s,e),Nl(s,e)},is=(e,t,n={})=>s=>{const{libraryOptions:o,target:a}=s??{},i=Sl({...o??{},target:a,io:t,processors:n});return Ge(e,i),Cl(i,e),Nl(i,e)},mx={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},fx=(e,t,n,s)=>{const o=n;o.type="string";const{minimum:a,maximum:i,format:c,patterns:l,contentEncoding:u}=e._zod.bag;if(typeof a=="number"&&(o.minLength=a),typeof i=="number"&&(o.maxLength=i),c&&(o.format=mx[c]??c,o.format===""&&delete o.format,c==="time"&&delete o.format),u&&(o.contentEncoding=u),l&&l.size>0){const m=[...l];m.length===1?o.pattern=m[0].source:m.length>1&&(o.allOf=[...m.map(d=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))])}},px=(e,t,n,s)=>{const o=n,{minimum:a,maximum:i,format:c,multipleOf:l,exclusiveMaximum:u,exclusiveMinimum:m}=e._zod.bag;typeof c=="string"&&c.includes("int")?o.type="integer":o.type="number",typeof m=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.minimum=m,o.exclusiveMinimum=!0):o.exclusiveMinimum=m),typeof a=="number"&&(o.minimum=a,typeof m=="number"&&t.target!=="draft-04"&&(m>=a?delete o.minimum:delete o.exclusiveMinimum)),typeof u=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.maximum=u,o.exclusiveMaximum=!0):o.exclusiveMaximum=u),typeof i=="number"&&(o.maximum=i,typeof u=="number"&&t.target!=="draft-04"&&(u<=i?delete o.maximum:delete o.exclusiveMaximum)),typeof l=="number"&&(o.multipleOf=l)},hx=(e,t,n,s)=>{n.type="boolean"},gx=(e,t,n,s)=>{n.not={}},xx=(e,t,n,s)=>{},vx=(e,t,n,s)=>{const o=e._zod.def,a=ol(o.entries);a.every(i=>typeof i=="number")&&(n.type="number"),a.every(i=>typeof i=="string")&&(n.type="string"),n.enum=a},yx=(e,t,n,s)=>{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},bx=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},wx=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},kx=(e,t,n,s)=>{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=Ge(a.element,t,{...s,path:[...s.path,"items"]})},jx=(e,t,n,s)=>{const o=n,a=e._zod.def;o.type="object",o.properties={};const i=a.shape;for(const u in i)o.properties[u]=Ge(i[u],t,{...s,path:[...s.path,"properties",u]});const c=new Set(Object.keys(i)),l=new Set([...c].filter(u=>{const m=a.shape[u]._zod;return t.io==="input"?m.optin===void 0:m.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=Ge(a.catchall,t,{...s,path:[...s.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},_x=(e,t,n,s)=>{const o=e._zod.def,a=o.inclusive===!1,i=o.options.map((c,l)=>Ge(c,t,{...s,path:[...s.path,a?"oneOf":"anyOf",l]}));a?n.oneOf=i:n.anyOf=i},Sx=(e,t,n,s)=>{const o=e._zod.def,a=Ge(o.left,t,{...s,path:[...s.path,"allOf",0]}),i=Ge(o.right,t,{...s,path:[...s.path,"allOf",1]}),c=u=>"allOf"in u&&Object.keys(u).length===1,l=[...c(a)?a.allOf:[a],...c(i)?i.allOf:[i]];n.allOf=l},Cx=(e,t,n,s)=>{const o=e._zod.def,a=Ge(o.innerType,t,s),i=t.seen.get(e);t.target==="openapi-3.0"?(i.ref=o.innerType,n.nullable=!0):n.anyOf=[a,{type:"null"}]},Nx=(e,t,n,s)=>{const o=e._zod.def;Ge(o.innerType,t,s);const a=t.seen.get(e);a.ref=o.innerType},Ax=(e,t,n,s)=>{const o=e._zod.def;Ge(o.innerType,t,s);const a=t.seen.get(e);a.ref=o.innerType,n.default=JSON.parse(JSON.stringify(o.defaultValue))},Ex=(e,t,n,s)=>{const o=e._zod.def;Ge(o.innerType,t,s);const a=t.seen.get(e);a.ref=o.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},Ix=(e,t,n,s)=>{const o=e._zod.def;Ge(o.innerType,t,s);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},Tx=(e,t,n,s)=>{const o=e._zod.def,a=t.io==="input"?o.in._zod.def.type==="transform"?o.out:o.in:o.out;Ge(a,t,s);const i=t.seen.get(e);i.ref=a},Px=(e,t,n,s)=>{const o=e._zod.def;Ge(o.innerType,t,s);const a=t.seen.get(e);a.ref=o.innerType,n.readOnly=!0},Al=(e,t,n,s)=>{const o=e._zod.def;Ge(o.innerType,t,s);const a=t.seen.get(e);a.ref=o.innerType},Rx=$("ZodISODateTime",(e,t)=>{Lh.init(e,t),Ee.init(e,t)});function Ox(e){return Ug(Rx,e)}const Mx=$("ZodISODate",(e,t)=>{Dh.init(e,t),Ee.init(e,t)});function Lx(e){return Bg(Mx,e)}const Dx=$("ZodISOTime",(e,t)=>{zh.init(e,t),Ee.init(e,t)});function zx(e){return Vg(Dx,e)}const $x=$("ZodISODuration",(e,t)=>{$h.init(e,t),Ee.init(e,t)});function Fx(e){return Wg($x,e)}const Ux=(e,t)=>{dl.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>Ap(e,n)},flatten:{value:n=>Np(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,Ro,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,Ro,2)}},isEmpty:{get(){return e.issues.length===0}}})},wt=$("ZodError",Ux,{Parent:Error}),Bx=ia(wt),Vx=ca(wt),Wx=js(wt),qx=_s(wt),Hx=Tp(wt),Zx=Pp(wt),Gx=Rp(wt),Yx=Op(wt),Kx=Mp(wt),Qx=Lp(wt),Jx=Dp(wt),Xx=zp(wt),Re=$("ZodType",(e,t)=>(Pe.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:is(e,"input"),output:is(e,"output")}}),e.toJSONSchema=ux(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(sn(t,{checks:[...t.checks??[],...n.map(s=>typeof s=="function"?{_zod:{check:s,def:{check:"custom"},onattach:[]}}:s)]}),{parent:!0}),e.with=e.check,e.clone=(n,s)=>on(e,n,s),e.brand=()=>e,e.register=((n,s)=>(n.add(e,s),e)),e.parse=(n,s)=>Bx(e,n,s,{callee:e.parse}),e.safeParse=(n,s)=>Wx(e,n,s),e.parseAsync=async(n,s)=>Vx(e,n,s,{callee:e.parseAsync}),e.safeParseAsync=async(n,s)=>qx(e,n,s),e.spa=e.safeParseAsync,e.encode=(n,s)=>Hx(e,n,s),e.decode=(n,s)=>Zx(e,n,s),e.encodeAsync=async(n,s)=>Gx(e,n,s),e.decodeAsync=async(n,s)=>Yx(e,n,s),e.safeEncode=(n,s)=>Kx(e,n,s),e.safeDecode=(n,s)=>Qx(e,n,s),e.safeEncodeAsync=async(n,s)=>Jx(e,n,s),e.safeDecodeAsync=async(n,s)=>Xx(e,n,s),e.refine=(n,s)=>e.check(K0(n,s)),e.superRefine=n=>e.check(Q0(n)),e.overwrite=n=>e.check(Wn(n)),e.optional=()=>Ui(e),e.exactOptional=()=>D0(e),e.nullable=()=>Bi(e),e.nullish=()=>Ui(Bi(e)),e.nonoptional=n=>V0(e,n),e.array=()=>C0(e),e.or=n=>E0([e,n]),e.and=n=>T0(e,n),e.transform=n=>Vi(e,M0(n)),e.default=n=>F0(e,n),e.prefault=n=>B0(e,n),e.catch=n=>q0(e,n),e.pipe=n=>Vi(e,n),e.readonly=()=>G0(e),e.describe=n=>{const s=e.clone();return dr.add(s,{description:n}),s},Object.defineProperty(e,"description",{get(){return dr.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return dr.get(e);const s=e.clone();return dr.add(s,n[0]),s},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),El=$("_ZodString",(e,t)=>{la.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(s,o,a)=>fx(e,s,o);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...s)=>e.check(Kg(...s)),e.includes=(...s)=>e.check(Xg(...s)),e.startsWith=(...s)=>e.check(ex(...s)),e.endsWith=(...s)=>e.check(tx(...s)),e.min=(...s)=>e.check(as(...s)),e.max=(...s)=>e.check(jl(...s)),e.length=(...s)=>e.check(_l(...s)),e.nonempty=(...s)=>e.check(as(1,...s)),e.lowercase=s=>e.check(Qg(s)),e.uppercase=s=>e.check(Jg(s)),e.trim=()=>e.check(rx()),e.normalize=(...s)=>e.check(nx(...s)),e.toLowerCase=()=>e.check(sx()),e.toUpperCase=()=>e.check(ox()),e.slugify=()=>e.check(ax())}),e0=$("ZodString",(e,t)=>{la.init(e,t),El.init(e,t),e.email=n=>e.check(bg(t0,n)),e.url=n=>e.check(Sg(n0,n)),e.jwt=n=>e.check(Fg(x0,n)),e.emoji=n=>e.check(Cg(r0,n)),e.guid=n=>e.check(Oi(zi,n)),e.uuid=n=>e.check(wg(Mr,n)),e.uuidv4=n=>e.check(kg(Mr,n)),e.uuidv6=n=>e.check(jg(Mr,n)),e.uuidv7=n=>e.check(_g(Mr,n)),e.nanoid=n=>e.check(Ng(s0,n)),e.guid=n=>e.check(Oi(zi,n)),e.cuid=n=>e.check(Ag(o0,n)),e.cuid2=n=>e.check(Eg(a0,n)),e.ulid=n=>e.check(Ig(i0,n)),e.base64=n=>e.check(Dg(p0,n)),e.base64url=n=>e.check(zg(h0,n)),e.xid=n=>e.check(Tg(c0,n)),e.ksuid=n=>e.check(Pg(l0,n)),e.ipv4=n=>e.check(Rg(d0,n)),e.ipv6=n=>e.check(Og(u0,n)),e.cidrv4=n=>e.check(Mg(m0,n)),e.cidrv6=n=>e.check(Lg(f0,n)),e.e164=n=>e.check($g(g0,n)),e.datetime=n=>e.check(Ox(n)),e.date=n=>e.check(Lx(n)),e.time=n=>e.check(zx(n)),e.duration=n=>e.check(Fx(n))});function qe(e){return yg(e0,e)}const Ee=$("ZodStringFormat",(e,t)=>{Ce.init(e,t),El.init(e,t)}),t0=$("ZodEmail",(e,t)=>{Nh.init(e,t),Ee.init(e,t)}),zi=$("ZodGUID",(e,t)=>{Sh.init(e,t),Ee.init(e,t)}),Mr=$("ZodUUID",(e,t)=>{Ch.init(e,t),Ee.init(e,t)}),n0=$("ZodURL",(e,t)=>{Ah.init(e,t),Ee.init(e,t)}),r0=$("ZodEmoji",(e,t)=>{Eh.init(e,t),Ee.init(e,t)}),s0=$("ZodNanoID",(e,t)=>{Ih.init(e,t),Ee.init(e,t)}),o0=$("ZodCUID",(e,t)=>{Th.init(e,t),Ee.init(e,t)}),a0=$("ZodCUID2",(e,t)=>{Ph.init(e,t),Ee.init(e,t)}),i0=$("ZodULID",(e,t)=>{Rh.init(e,t),Ee.init(e,t)}),c0=$("ZodXID",(e,t)=>{Oh.init(e,t),Ee.init(e,t)}),l0=$("ZodKSUID",(e,t)=>{Mh.init(e,t),Ee.init(e,t)}),d0=$("ZodIPv4",(e,t)=>{Fh.init(e,t),Ee.init(e,t)}),u0=$("ZodIPv6",(e,t)=>{Uh.init(e,t),Ee.init(e,t)}),m0=$("ZodCIDRv4",(e,t)=>{Bh.init(e,t),Ee.init(e,t)}),f0=$("ZodCIDRv6",(e,t)=>{Vh.init(e,t),Ee.init(e,t)}),p0=$("ZodBase64",(e,t)=>{Wh.init(e,t),Ee.init(e,t)}),h0=$("ZodBase64URL",(e,t)=>{Hh.init(e,t),Ee.init(e,t)}),g0=$("ZodE164",(e,t)=>{Zh.init(e,t),Ee.init(e,t)}),x0=$("ZodJWT",(e,t)=>{Yh.init(e,t),Ee.init(e,t)}),Il=$("ZodNumber",(e,t)=>{yl.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(s,o,a)=>px(e,s,o),e.gt=(s,o)=>e.check(Li(s,o)),e.gte=(s,o)=>e.check(io(s,o)),e.min=(s,o)=>e.check(io(s,o)),e.lt=(s,o)=>e.check(Mi(s,o)),e.lte=(s,o)=>e.check(ao(s,o)),e.max=(s,o)=>e.check(ao(s,o)),e.int=s=>e.check($i(s)),e.safe=s=>e.check($i(s)),e.positive=s=>e.check(Li(0,s)),e.nonnegative=s=>e.check(io(0,s)),e.negative=s=>e.check(Mi(0,s)),e.nonpositive=s=>e.check(ao(0,s)),e.multipleOf=(s,o)=>e.check(Di(s,o)),e.step=(s,o)=>e.check(Di(s,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 v0(e){return qg(Il,e)}const y0=$("ZodNumberFormat",(e,t)=>{Kh.init(e,t),Il.init(e,t)});function $i(e){return Hg(y0,e)}const b0=$("ZodBoolean",(e,t)=>{Qh.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,s,o)=>hx(e,n,s)});function w0(e){return Zg(b0,e)}const k0=$("ZodUnknown",(e,t)=>{Jh.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,s,o)=>xx()});function Fi(){return Gg(k0)}const j0=$("ZodNever",(e,t)=>{Xh.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,s,o)=>gx(e,n,s)});function _0(e){return Yg(j0,e)}const S0=$("ZodArray",(e,t)=>{eg.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,s,o)=>kx(e,n,s,o),e.element=t.element,e.min=(n,s)=>e.check(as(n,s)),e.nonempty=n=>e.check(as(1,n)),e.max=(n,s)=>e.check(jl(n,s)),e.length=(n,s)=>e.check(_l(n,s)),e.unwrap=()=>e.element});function C0(e,t){return ix(S0,e,t)}const N0=$("ZodObject",(e,t)=>{ng.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,s,o)=>jx(e,n,s,o),we(e,"shape",()=>t.shape),e.keyof=()=>P0(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Fi()}),e.loose=()=>e.clone({...e._zod.def,catchall:Fi()}),e.strict=()=>e.clone({...e._zod.def,catchall:_0()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>kp(e,n),e.safeExtend=n=>jp(e,n),e.merge=n=>_p(e,n),e.pick=n=>bp(e,n),e.omit=n=>wp(e,n),e.partial=(...n)=>Sp(Pl,e,n[0]),e.required=(...n)=>Cp(Rl,e,n[0])});function Tl(e,t){const n={type:"object",shape:e??{},...ae(t)};return new N0(n)}const A0=$("ZodUnion",(e,t)=>{rg.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,s,o)=>_x(e,n,s,o),e.options=t.options});function E0(e,t){return new A0({type:"union",options:e,...ae(t)})}const I0=$("ZodIntersection",(e,t)=>{sg.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,s,o)=>Sx(e,n,s,o)});function T0(e,t){return new I0({type:"intersection",left:e,right:t})}const Mo=$("ZodEnum",(e,t)=>{og.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(s,o,a)=>vx(e,s,o),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(s,o)=>{const a={};for(const i of s)if(n.has(i))a[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new Mo({...t,checks:[],...ae(o),entries:a})},e.exclude=(s,o)=>{const a={...t.entries};for(const i of s)if(n.has(i))delete a[i];else throw new Error(`Key ${i} not found in enum`);return new Mo({...t,checks:[],...ae(o),entries:a})}});function P0(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(s=>[s,s])):e;return new Mo({type:"enum",entries:n,...ae(t)})}const R0=$("ZodLiteral",(e,t)=>{ag.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,s,o)=>yx(e,n,s),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 co(e,t){return new R0({type:"literal",values:Array.isArray(e)?e:[e],...ae(t)})}const O0=$("ZodTransform",(e,t)=>{ig.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,s,o)=>wx(e,n),e._zod.parse=(n,s)=>{if(s.direction==="backward")throw new rl(e.constructor.name);n.addIssue=a=>{if(typeof a=="string")n.issues.push(xr(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(xr(i))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(a=>(n.value=a,n)):(n.value=o,n)}});function M0(e){return new O0({type:"transform",transform:e})}const Pl=$("ZodOptional",(e,t)=>{kl.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,s,o)=>Al(e,n,s,o),e.unwrap=()=>e._zod.def.innerType});function Ui(e){return new Pl({type:"optional",innerType:e})}const L0=$("ZodExactOptional",(e,t)=>{cg.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,s,o)=>Al(e,n,s,o),e.unwrap=()=>e._zod.def.innerType});function D0(e){return new L0({type:"optional",innerType:e})}const z0=$("ZodNullable",(e,t)=>{lg.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,s,o)=>Cx(e,n,s,o),e.unwrap=()=>e._zod.def.innerType});function Bi(e){return new z0({type:"nullable",innerType:e})}const $0=$("ZodDefault",(e,t)=>{dg.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,s,o)=>Ax(e,n,s,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function F0(e,t){return new $0({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():il(t)}})}const U0=$("ZodPrefault",(e,t)=>{ug.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,s,o)=>Ex(e,n,s,o),e.unwrap=()=>e._zod.def.innerType});function B0(e,t){return new U0({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():il(t)}})}const Rl=$("ZodNonOptional",(e,t)=>{mg.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,s,o)=>Nx(e,n,s,o),e.unwrap=()=>e._zod.def.innerType});function V0(e,t){return new Rl({type:"nonoptional",innerType:e,...ae(t)})}const W0=$("ZodCatch",(e,t)=>{fg.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,s,o)=>Ix(e,n,s,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function q0(e,t){return new W0({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const H0=$("ZodPipe",(e,t)=>{pg.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,s,o)=>Tx(e,n,s,o),e.in=t.in,e.out=t.out});function Vi(e,t){return new H0({type:"pipe",in:e,out:t})}const Z0=$("ZodReadonly",(e,t)=>{hg.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,s,o)=>Px(e,n,s,o),e.unwrap=()=>e._zod.def.innerType});function G0(e){return new Z0({type:"readonly",innerType:e})}const Y0=$("ZodCustom",(e,t)=>{gg.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,s,o)=>bx(e,n)});function K0(e,t={}){return cx(Y0,e,t)}function Q0(e){return lx(e)}const Lr=Tl({line1:qe().min(1,"Address line 1 is required"),line2:qe().optional(),city:qe().min(1,"City is required"),state:qe().optional(),postalCode:qe().min(1,"Postal code is required"),country:qe().min(2,"Country is required")});function J0(e){return Tl({email:e.requireEmail?qe().email("Valid email required"):qe().email("Valid email required").or(co("")).optional(),name:e.requireName?qe().min(1,"Name is required"):qe().optional(),phone:e.requirePhone?qe().min(6,"Phone is required"):qe().optional(),notes:qe().max(500).optional(),shippingAddress:e.requireShippingAddress?Lr:Lr.optional(),billingAddress:e.requireBillingAddress?Lr:Lr.optional(),recipientEmail:qe().email("Valid recipient email required").or(co("")).optional(),giftMessage:qe().max(500).optional(),discountCode:qe().optional(),tipAmount:v0().min(0).optional(),shippingMethodId:qe().optional(),regulatoryConsent:e.requireRegulatoryConsent?co(!0,{message:"You must acknowledge the regulatory notice"}):w0().optional()})}const Wi={none:0,optional:1,required:2};function lo(e,t){return Wi[e]>=Wi[t]?e:t}function X0(e){if(!e)return null;try{const t=JSON.parse(e);return!t||typeof t!="object"?null:t}catch{return null}}function Qr(e,t){let n=!1,s=!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"),u=t.defaultMode==="full";for(const d of e){d.metadata?.shippingProfile==="digital"?n=!0:s=!0;const h=X0(d.metadata?.checkoutRequirements);h&&(h.email&&(a=lo(a,h.email)),h.name&&(i=lo(i,h.name)),h.phone&&(c=lo(c,h.phone)),typeof h.shippingAddress=="boolean"&&(l=l||h.shippingAddress),typeof h.billingAddress=="boolean"&&(u=u||h.billingAddress));const v=d.metadata?.fulfillmentNotes;v&&o.add(v)}const m=n&&!s;return m&&(l=!1),{email:a,name:i,phone:c,shippingAddress:l,billingAddress:u,fulfillmentNotes:Array.from(o).join(" "),isDigitalOnly:m,hasPhysical:s}}const Ol=b.createContext(null);function Ml(){const{config:e}=Ae(),t=Et(),n=b.useMemo(()=>({line1:"",line2:"",city:"",state:"",postalCode:"",country:"US"}),[]),s=t.items.some(k=>!!k.metadata?.regulatoryNotice),o=b.useMemo(()=>{const k=Qr(t.items,{requireEmail:e.checkout.requireEmail??!0,defaultMode:e.checkout.mode,allowShipping:e.checkout.allowShipping??!1});return J0({requireEmail:k.email==="required",requireName:k.name==="required",requirePhone:k.phone==="required",requireShippingAddress:k.shippingAddress,requireBillingAddress:k.billingAddress,requireRegulatoryConsent:s})},[t.items,e.checkout.allowShipping,e.checkout.mode,e.checkout.requireEmail,s]),[a,i]=b.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:"",regulatoryConsent:void 0}));b.useEffect(()=>{const k=Qr(t.items,{requireEmail:e.checkout.requireEmail??!0,defaultMode:e.checkout.mode,allowShipping:e.checkout.allowShipping??!1});i(_=>{const S={..._};return k.email==="required"&&!S.email&&(S.email=""),k.shippingAddress&&!S.shippingAddress&&(S.shippingAddress=n),k.billingAddress&&!S.billingAddress&&(S.billingAddress=n),k.shippingAddress||(S.shippingAddress=void 0),k.billingAddress||(S.billingAddress=void 0),S})},[t.items,e.checkout.allowShipping,e.checkout.mode,e.checkout.requireEmail,n]);const c=b.useRef(!1),[l,u]=b.useState({}),[m,d]=b.useState("idle"),[x,h]=b.useState(null),[v,p]=b.useState(null),g=b.useCallback(()=>{u({}),d("idle"),h(null),p(null)},[]),y=b.useCallback((k,_)=>{i(S=>({...S,[k]:_}))},[]),w=b.useCallback(()=>{d("validating"),h(null);const k=o.safeParse(a);if(k.success)return u({}),d("idle"),{ok:!0,values:k.data};const _={};for(const S of k.error.issues)_[S.path.join(".")]=S.message;return u(_),d("error"),h("Please fix the highlighted fields."),{ok:!1}},[o,a]),j=b.useCallback(async k=>{if(c.current)return{ok:!1};const _=w();if(!_.ok)return{ok:!1};c.current=!0,d("creating_session"),h(null),p(null);const S=t.items.map(T=>({resource:T.paymentResource??T.productId,quantity:T.qty,variantId:T.variantId})),A=Qr(t.items,{requireEmail:e.checkout.requireEmail??!0,defaultMode:e.checkout.mode,allowShipping:e.checkout.allowShipping??!1}),E=new Set;if(A.shippingAddress)for(const T of t.items){const U=T.metadata?.shippingCountries;if(U)for(const L of U.split(",")){const B=L.trim().toUpperCase();B&&E.add(B)}}const I={...E.size?{shippingCountries:Array.from(E).join(","),shipping_countries:Array.from(E).join(",")}:{},..._.values.recipientEmail?{recipient_email:_.values.recipientEmail}:{},..._.values.giftMessage?{gift_message:_.values.giftMessage}:{},..._.values.regulatoryConsent?{regulatory_consent:"true"}:{}};try{const T=await e.adapter.createCheckoutSession({cart:S,customer:{email:_.values.email||void 0,name:_.values.name||void 0,phone:_.values.phone||void 0,notes:_.values.notes||void 0,shippingAddress:_.values.shippingAddress,billingAddress:_.values.billingAddress},options:{currency:e.currency,successUrl:e.checkout.successUrl,cancelUrl:e.checkout.cancelUrl,allowPromoCodes:e.checkout.allowPromoCodes,metadata:Object.keys(I).length?I:void 0,discountCode:(e.checkout.allowPromoCodes?_.values.discountCode||t.promoCode:void 0)||void 0,tipAmount:e.checkout.allowTipping&&_.values.tipAmount||void 0,shippingMethodId:e.checkout.allowShipping&&_.values.shippingMethodId||void 0,paymentMethodId:k?.paymentMethodId}});return T.kind==="redirect"?(p(T),d("redirecting"),typeof window<"u"&&window.location.assign(T.url),{ok:!0,session:T}):(p(T),d("success"),{ok:!0,session:T})}catch(T){return d("error"),h(T instanceof Error?T.message:"Checkout failed"),{ok:!1}}finally{c.current=!1}},[t.items,t.promoCode,e.adapter,e.checkout,e.currency,w]);return{values:a,setValues:i,setField:y,fieldErrors:l,status:m,error:x,session:v,reset:g,validate:w,createCheckoutSession:j}}function Ll({children:e}){const t=Ml();return r.jsx(Ol.Provider,{value:t,children:e})}function Ar(){const e=b.useContext(Ol);if(!e)throw new Error("useCheckout must be used within CheckoutProvider");return e}function ev(){return Ml()}function da(){const{config:e}=Ae(),[t,n]=f.useState([]),[s,o]=f.useState(!0),[a,i]=f.useState(null);return f.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:s,error:a}}function Cs(e){const{config:t}=Ae(),[n,s]=f.useState(null),[o,a]=f.useState(!0),[i,c]=f.useState(null),l=f.useMemo(()=>JSON.stringify(e.filters??{}),[e.filters]);return f.useEffect(()=>{let u=!1;return a(!0),c(null),t.adapter.listProducts(e).then(m=>{u||s(m)}).catch(m=>{u||c(m instanceof Error?m.message:"Failed to load products")}).finally(()=>{u||a(!1)}),()=>{u=!0}},[t.adapter,e.category,e.search,e.sort,e.page,e.pageSize,l]),{data:n,isLoading:o,error:i}}function Dl(e){const{config:t}=Ae(),[n,s]=f.useState(null),[o,a]=f.useState(!0),[i,c]=f.useState(null);return f.useEffect(()=>{let l=!1;return a(!0),c(null),t.adapter.getProductBySlug(e).then(u=>{l||s(u)}).catch(u=>{l||c(u instanceof Error?u.message:"Failed to load product")}).finally(()=>{l||a(!1)}),()=>{l=!0}},[t.adapter,e]),{product:n,isLoading:o,error:i}}function zl(){const{config:e}=Ae(),[t,n]=f.useState([]),[s,o]=f.useState(!0),[a,i]=f.useState(null);return f.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:s,error:a}}function $l(){const{config:e}=Ae(),[t,n]=f.useState([]),[s,o]=f.useState(null),[a,i]=f.useState(!0),[c,l]=f.useState(null);return f.useEffect(()=>{let u=!1;async function m(){i(!0),l(null);try{const[d,x]=await Promise.all([e.adapter.listSubscriptionTiers?.()??Promise.resolve([]),e.adapter.getSubscriptionStatus?.()??Promise.resolve(null)]);if(u)return;n(d),o(x)}catch(d){if(u)return;l(d instanceof Error?d.message:"Failed to load subscriptions")}finally{u||i(!1)}}return m(),()=>{u=!0}},[e.adapter]),{tiers:t,status:s,isLoading:a,error:c}}function Fl({enabled:e,customer:t}){const{config:n}=Ae(),[s,o]=f.useState([]),[a,i]=f.useState(!1),[c,l]=f.useState(null),u=JSON.stringify(t.shippingAddress??{});return f.useEffect(()=>{let m=!1;if(!e||!n.adapter.getShippingMethods){o([]);return}return i(!0),l(null),n.adapter.getShippingMethods({currency:n.currency,customer:t}).then(d=>{m||o(d)}).catch(d=>{m||l(d instanceof Error?d.message:"Failed to load shipping methods")}).finally(()=>{m||i(!1)}),()=>{m=!0}},[n.adapter,n.currency,e,t.email,t.name,u]),{methods:s,isLoading:a,error:c}}function tr(e,...t){for(const n of t){const s=e[n];if(s)return s}}function ua(e){const t=tr(e,"error","error_message","message");if(t)return{kind:"error",message:t};const n=tr(e,"canceled","cancelled","cancel","canceled_at");if(n&&n!=="0"&&n!=="false")return{kind:"cancel"};const s=tr(e,"orderId","order_id","demoOrderId"),o=tr(e,"session_id","checkout_session_id");if(s||o)return{kind:"success",orderId:s??o};const a=(tr(e,"status","checkout")??"").toLowerCase();return a==="success"?{kind:"success",orderId:s}:a==="cancel"||a==="canceled"?{kind:"cancel"}:a==="error"?{kind:"error"}:{kind:"idle"}}function tv(e){const t={};return e.forEach((n,s)=>{t[s]=n}),t}function ma(){const{config:e}=Ae(),[t,n]=f.useState({kind:"idle"});return f.useEffect(()=>{if(typeof window>"u")return;const s=new URLSearchParams(window.location.search),o=tv(s);(async()=>{try{const a=e.adapter.resolveCheckoutReturn?await e.adapter.resolveCheckoutReturn({query:o}):ua(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 Lo(e){if(!e)return;const t=Number(e);return Number.isFinite(t)?t:void 0}function nv(e){const t=e.get("tags"),n=t?t.split(",").map(c=>c.trim()).filter(Boolean):void 0,s=Lo(e.get("min")),o=Lo(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:s,priceMax:o,inStock:i}}function rv(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 fa({includeCategory:e}){if(typeof window>"u")return null;const t=new URLSearchParams(window.location.search),n=t.get("q")??"",s=t.get("sort")??"featured",o=Lo(t.get("page"))??1,a=nv(t),i=e?t.get("cat")??void 0:void 0;return{search:n,sort:s,page:Math.max(1,Math.floor(o)),category:i,filters:a}}function pa(e,{includeCategory:t}){const n=e.filters.tags?.join(",")??"";f.useEffect(()=>{if(typeof window>"u")return;const s=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")),rv(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(s)},[t,e.category,e.page,e.search,e.sort,n,e.filters.priceMin,e.filters.priceMax,e.filters.inStock])}const qi=2;function Hi(e,t){return`${e}::${t??""}`}function sv(e,t){if(t&&e.variants?.length){const n=e.variants.find(s=>s.id===t);if(n)return{qty:n.inventoryQuantity,status:n.inventoryStatus}}return{qty:e.inventoryQuantity,status:e.inventoryStatus}}function ov(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:s,status:o}=sv(t,e.variantId);return n.availableQty=s,n.status=o,o==="out_of_stock"||typeof s=="number"&&s<=0?{...n,isOutOfStock:!0,message:"Out of stock"}:typeof s=="number"&&e.qty>s?{...n,exceedsAvailable:!0,message:s===0?"Out of stock":`Only ${s} available (you have ${e.qty} in cart)`}:o==="low"||typeof s=="number"&&s>0&&s<=5?{...n,isLowStock:!0,message:typeof s=="number"?`Only ${s} left`:"Low stock"}:n}function av(e,t){if(e.size!==t.size)return!1;for(const[n,s]of e){const o=t.get(n);if(!o||s.productId!==o.productId||s.variantId!==o.variantId||s.availableQty!==o.availableQty||s.status!==o.status||s.isOutOfStock!==o.isOutOfStock||s.exceedsAvailable!==o.exceedsAvailable||s.isLowStock!==o.isLowStock||s.message!==o.message)return!1}return!0}async function iv(e,t){const n=new Map;for(let s=0;s<e.length;s+=qi){const o=e.slice(s,s+qi),a=await Promise.all(o.map(async i=>{try{return await t(i)}catch{return null}}));for(const i of a)i&&(n.set(i.id,i),i.slug&&i.slug!==i.id&&n.set(i.slug,i))}return n}function ha({items:e,refreshInterval:t=3e4,skip:n=!1}){const{config:s}=Ae(),[o,a]=f.useState(new Map),[i,c]=f.useState(!1),[l,u]=f.useState(null),m=f.useRef(null),d=f.useRef(e);d.current=e;const x=f.useRef([]),h=f.useMemo(()=>{const j=new Set;for(const k of e)j.add(k.productId);return j},[e]),v=f.useMemo(()=>Array.from(h).sort().join(","),[h]),p=f.useMemo(()=>Array.from(h),[h]);x.current=p;const g=f.useCallback(async()=>{if(n||x.current.length===0){u(null),c(!1),a(_=>_.size===0?_:new Map);return}if(m.current)return m.current;const k=(async()=>{c(!0),u(null);try{const _=x.current,S=s.adapter.getProductsByIds?await s.adapter.getProductsByIds(_):await iv(_,s.adapter.getProductBySlug),A=new Map;for(const E of d.current){const I=Hi(E.productId,E.variantId),T=S.get(E.productId)??null;A.set(I,ov(E,T))}a(E=>av(E,A)?E:A)}catch(_){u(_ instanceof Error?_.message:"Failed to check inventory")}finally{c(!1),m.current=null}})();return m.current=k,k},[s.adapter,v,n]);f.useEffect(()=>{g()},[g]),f.useEffect(()=>{if(n||t<=0||p.length===0)return;let j=!1,k=null;const _=()=>{k=setTimeout(async()=>{await g(),j||_()},t)};return _(),()=>{j=!0,k&&clearTimeout(k)}},[g,p.length,t,n]);const y=f.useCallback((j,k)=>o.get(Hi(j,k)),[o]),w=f.useMemo(()=>{for(const j of o.values())if(j.isOutOfStock||j.exceedsAvailable)return!0;return!1},[o]);return{inventory:o,isLoading:i,error:l,refresh:g,getItemInventory:y,hasIssues:w}}function cv(e,t){if(t&&e.variants?.length){const n=e.variants.find(s=>s.id===t);if(n)return{qty:n.inventoryQuantity,status:n.inventoryStatus}}return{qty:e.inventoryQuantity,status:e.inventoryStatus}}function lv(e,t,n){if(!t)return e.titleSnapshot??"Unknown Product";const s=t.title??e.titleSnapshot??"Product";if(n&&t.variants?.length){const o=t.variants.find(a=>a.id===n);if(o?.title)return`${s} - ${o.title}`}return s}function dv(e,t){const n=lv(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:s,status:o}=cv(t,e.variantId);return o==="out_of_stock"||typeof s=="number"&&s<=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 s=="number"&&e.qty>s?{productId:e.productId,variantId:e.variantId,title:n,requestedQty:e.qty,availableQty:s,type:"insufficient_stock",message:s===0?"This item is out of stock":`Only ${s} available`}:null}function Ul({items:e}){const{config:t}=Ae(),[n,s]=f.useState(null),[o,a]=f.useState(!1),[i,c]=f.useState(null),l=f.useMemo(()=>{const d=new Set;for(const x of e)d.add(x.productId);return Array.from(d)},[e]),u=f.useCallback(async()=>{if(e.length===0){const d={ok:!0,issues:[],verifiedAt:new Date};return s(d),d}a(!0),c(null);try{let d=new Map;if(t.adapter.getProductsByIds)d=await t.adapter.getProductsByIds(l);else{const v=await Promise.all(l.map(async p=>{try{return await t.adapter.getProductBySlug(p)}catch{return null}}));d=new Map;for(const p of v)p&&(d.set(p.id,p),p.slug&&p.slug!==p.id&&d.set(p.slug,p))}const x=[];for(const v of e){const p=d.get(v.productId)??null,g=dv(v,p);g&&x.push(g)}const h={ok:x.length===0,issues:x,verifiedAt:new Date};return s(h),a(!1),h}catch(d){const x=d instanceof Error?d.message:"Failed to verify inventory";c(x),a(!1);const h={ok:!1,issues:[],verifiedAt:new Date};return s(h),h}},[t.adapter,e,l]),m=f.useCallback(()=>{s(null),c(null)},[]);return{result:n,isVerifying:o,error:i,verify:u,reset:m}}function uv({items:e,onExpiry:t,enabled:n=!0}){const[s,o]=f.useState([]),[a,i]=f.useState([]),c=f.useRef(new Set),l=f.useRef(t);l.current=t;const u=f.useMemo(()=>n?e.filter(m=>m.holdId&&m.holdExpiresAt):[],[e,n]);return f.useEffect(()=>{if(!n||u.length===0){o([]),i([]);return}const m=()=>{const x=Date.now(),h=120*1e3,v=[],p=[];for(const g of u){if(!g.holdExpiresAt)continue;const y=new Date(g.holdExpiresAt),w=y.getTime()-x,j=`${g.productId}::${g.variantId??""}`;w<=0?(v.push({productId:g.productId,variantId:g.variantId}),c.current.has(j)||(c.current.add(j),l.current?.({productId:g.productId,variantId:g.variantId,title:g.titleSnapshot,expiredAt:y}))):w<=h&&p.push({productId:g.productId,variantId:g.variantId,expiresAt:y,remainingMs:w})}o(v),i(p)};m();const d=setInterval(m,1e4);return()=>clearInterval(d)},[n,u]),f.useEffect(()=>{const m=new Set(u.map(d=>`${d.productId}::${d.variantId??""}`));for(const d of c.current)m.has(d)||c.current.delete(d)},[u]),{expiringItems:a,expiredItems:s}}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 mv(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 qn(e={}){const n=ks()?.config?.adapter,[s,o]=b.useState(ke),[a,i]=b.useState(!!n?.getStorefrontSettings);return b.useEffect(()=>{if(!n?.getStorefrontSettings){i(!1);return}let c=!1;async function l(){try{const u=await n.getStorefrontSettings();!c&&u&&o(mv(u))}catch{}finally{c||i(!1)}}return l(),()=>{c=!0}},[n]),{settings:s,isLoading:a}}const fv={card:!0,crypto:!0,credits:!1};function Bl(){const t=ks()?.config?.adapter,[n,s]=b.useState(fv),[o,a]=b.useState(!!t?.getPaymentMethodsConfig);return b.useEffect(()=>{if(!t?.getPaymentMethodsConfig){a(!1);return}let i=!1;async function c(){try{const l=await t.getPaymentMethodsConfig();!i&&l&&s(l)}catch{}finally{i||a(!1)}}return c(),()=>{i=!0}},[t]),{config:n,isLoading:o}}const pv=50,nr=new Map;function hv(e){return e.productId?`id:${e.productId}`:e.name?`name:${e.name}`:""}function Vl(e={}){const{productId:t,product:n,enabled:s=!0}=e,a=ks()?.config?.adapter,[i,c]=b.useState(null),[l,u]=b.useState(null),[m,d]=b.useState(!1),[x,h]=b.useState(null),v=b.useRef(0),p=b.useCallback(async()=>{const g=t?{productId:t}:n?{name:n.name,description:n.description,tags:n.tags,categoryIds:n.categoryIds}:{};if(!g.productId&&!g.name)return;if(!a?.getAIRelatedProducts){h("AI recommendations not available");return}const y=hv(g),w=nr.get(y);if(w){c(w.relatedProductIds),u(w.reasoning),h(null);return}const j=++v.current;d(!0),h(null);try{const k=await a.getAIRelatedProducts(g);if(j===v.current&&(c(k.relatedProductIds),u(k.reasoning),h(null),y)){if(nr.size>=pv){const _=nr.keys().next().value;_!==void 0&&nr.delete(_)}nr.set(y,k)}}catch(k){if(j===v.current){const _=k instanceof Error?k.message:"Failed to get AI recommendations";h(_),c(null),u(null)}}finally{j===v.current&&d(!1)}},[a,t,n]);return b.useEffect(()=>{s&&(!t&&!n?.name||p())},[s,t,n?.name,p]),{relatedProductIds:i,reasoning:l,isLoading:m,error:x,refetch:p}}function Ne(e,t){if(!e)throw new Error(t)}function _t(e){return typeof e=="string"&&e.trim().length>0}async function gv(e,t={}){const n=t.pageSize??10,s=await e.listCategories();Ne(Array.isArray(s),"listCategories() must return an array");for(const i of s)Ne(_t(i.id),"Category.id is required"),Ne(_t(i.slug),"Category.slug is required"),Ne(_t(i.name),"Category.name is required");const o=await e.listProducts({page:1,pageSize:n});if(Ne(o&&Array.isArray(o.items),"listProducts() must return { items: Product[] }"),Ne(typeof o.page=="number","listProducts().page must be a number"),Ne(typeof o.pageSize=="number","listProducts().pageSize must be a number"),o.items.length>0){const i=o.items[0];Ne(_t(i.id),"Product.id is required"),Ne(_t(i.slug),"Product.slug is required"),Ne(_t(i.title),"Product.title is required"),Ne(typeof i.description=="string","Product.description must be a string"),Ne(Array.isArray(i.images),"Product.images must be an array"),Ne(typeof i.price=="number","Product.price must be a number"),Ne(_t(i.currency),"Product.currency is required"),Ne(Array.isArray(i.tags),"Product.tags must be an array"),Ne(Array.isArray(i.categoryIds),"Product.categoryIds must be an array");const c=await e.getProductBySlug(i.slug);Ne(c===null||_t(c.id),"getProductBySlug() must return Product or null")}const a=await e.getOrderHistory();Ne(Array.isArray(a),"getOrderHistory() must return an array");for(const i of a)Ne(_t(i.id),"Order.id is required"),Ne(_t(i.createdAt),"Order.createdAt is required"),Ne(typeof i.total=="number","Order.total must be a number"),Ne(_t(i.currency),"Order.currency is required"),Ne(Array.isArray(i.items),"Order.items must be an array")}function Zi(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Hn(...e){return t=>{let n=!1;const s=e.map(o=>{const a=Zi(o,t);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let o=0;o<s.length;o++){const a=s[o];typeof a=="function"?a():Zi(e[o],null)}}}}function Se(...e){return f.useCallback(Hn(...e),e)}var xv=Symbol.for("react.lazy"),cs=f[" use ".trim().toString()];function vv(e){return typeof e=="object"&&e!==null&&"then"in e}function Wl(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===xv&&"_payload"in e&&vv(e._payload)}function ql(e){const t=bv(e),n=f.forwardRef((s,o)=>{let{children:a,...i}=s;Wl(a)&&typeof cs=="function"&&(a=cs(a._payload));const c=f.Children.toArray(a),l=c.find(kv);if(l){const u=l.props.children,m=c.map(d=>d===l?f.Children.count(u)>1?f.Children.only(null):f.isValidElement(u)?u.props.children:null:d);return r.jsx(t,{...i,ref:o,children:f.isValidElement(u)?f.cloneElement(u,void 0,m):null})}return r.jsx(t,{...i,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}var yv=ql("Slot");function bv(e){const t=f.forwardRef((n,s)=>{let{children:o,...a}=n;if(Wl(o)&&typeof cs=="function"&&(o=cs(o._payload)),f.isValidElement(o)){const i=_v(o),c=jv(a,o.props);return o.type!==f.Fragment&&(c.ref=s?Hn(s,i):i),f.cloneElement(o,c)}return f.Children.count(o)>1?f.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var wv=Symbol("radix.slottable");function kv(e){return f.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===wv}function jv(e,t){const n={...t};for(const s in t){const o=e[s],a=t[s];/^on[A-Z]/.test(s)?o&&a?n[s]=(...c)=>{const l=a(...c);return o(...c),l}:o&&(n[s]=o):s==="style"?n[s]={...o,...a}:s==="className"&&(n[s]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function _v(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 Hl(e){var t,n,s="";if(typeof e=="string"||typeof e=="number")s+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(n=Hl(e[t]))&&(s&&(s+=" "),s+=n)}else for(n in e)e[n]&&(s&&(s+=" "),s+=n);return s}function Zl(){for(var e,t,n=0,s="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=Hl(e))&&(s&&(s+=" "),s+=t);return s}const Gi=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Yi=Zl,ga=(e,t)=>n=>{var s;if(t?.variants==null)return Yi(e,n?.class,n?.className);const{variants:o,defaultVariants:a}=t,i=Object.keys(o).map(u=>{const m=n?.[u],d=a?.[u];if(m===null)return null;const x=Gi(m)||Gi(d);return o[u][x]}),c=n&&Object.entries(n).reduce((u,m)=>{let[d,x]=m;return x===void 0||(u[d]=x),u},{}),l=t==null||(s=t.compoundVariants)===null||s===void 0?void 0:s.reduce((u,m)=>{let{class:d,className:x,...h}=m;return Object.entries(h).every(v=>{let[p,g]=v;return Array.isArray(g)?g.includes({...a,...c}[p]):{...a,...c}[p]===g})?[...u,d,x]:u},[]);return Yi(e,i,l,n?.class,n?.className)},Sv=(e,t)=>{const n=new Array(e.length+t.length);for(let s=0;s<e.length;s++)n[s]=e[s];for(let s=0;s<t.length;s++)n[e.length+s]=t[s];return n},Cv=(e,t)=>({classGroupId:e,validator:t}),Gl=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),ls="-",Ki=[],Nv="arbitrary..",Av=e=>{const t=Iv(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:s}=e;return{getClassGroupId:i=>{if(i.startsWith("[")&&i.endsWith("]"))return Ev(i);const c=i.split(ls),l=c[0]===""&&c.length>1?1:0;return Yl(c,l,t)},getConflictingClassGroupIds:(i,c)=>{if(c){const l=s[i],u=n[i];return l?u?Sv(u,l):l:u||Ki}return n[i]||Ki}}},Yl=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const o=e[t],a=n.nextPart.get(o);if(a){const u=Yl(e,t+1,a);if(u)return u}const i=n.validators;if(i===null)return;const c=t===0?e.join(ls):e.slice(t).join(ls),l=i.length;for(let u=0;u<l;u++){const m=i[u];if(m.validator(c))return m.classGroupId}},Ev=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),n=t.indexOf(":"),s=t.slice(0,n);return s?Nv+s:void 0})(),Iv=e=>{const{theme:t,classGroups:n}=e;return Tv(n,t)},Tv=(e,t)=>{const n=Gl();for(const s in e){const o=e[s];xa(o,n,s,t)}return n},xa=(e,t,n,s)=>{const o=e.length;for(let a=0;a<o;a++){const i=e[a];Pv(i,t,n,s)}},Pv=(e,t,n,s)=>{if(typeof e=="string"){Rv(e,t,n);return}if(typeof e=="function"){Ov(e,t,n,s);return}Mv(e,t,n,s)},Rv=(e,t,n)=>{const s=e===""?t:Kl(t,e);s.classGroupId=n},Ov=(e,t,n,s)=>{if(Lv(e)){xa(e(s),t,n,s);return}t.validators===null&&(t.validators=[]),t.validators.push(Cv(n,e))},Mv=(e,t,n,s)=>{const o=Object.entries(e),a=o.length;for(let i=0;i<a;i++){const[c,l]=o[i];xa(l,Kl(t,c),n,s)}},Kl=(e,t)=>{let n=e;const s=t.split(ls),o=s.length;for(let a=0;a<o;a++){const i=s[a];let c=n.nextPart.get(i);c||(c=Gl(),n.nextPart.set(i,c)),n=c}return n},Lv=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,Dv=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),s=Object.create(null);const o=(a,i)=>{n[a]=i,t++,t>e&&(t=0,s=n,n=Object.create(null))};return{get(a){let i=n[a];if(i!==void 0)return i;if((i=s[a])!==void 0)return o(a,i),i},set(a,i){a in n?n[a]=i:o(a,i)}}},Do="!",Qi=":",zv=[],Ji=(e,t,n,s,o)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:s,isExternal:o}),$v=e=>{const{prefix:t,experimentalParseClassName:n}=e;let s=o=>{const a=[];let i=0,c=0,l=0,u;const m=o.length;for(let p=0;p<m;p++){const g=o[p];if(i===0&&c===0){if(g===Qi){a.push(o.slice(l,p)),l=p+1;continue}if(g==="/"){u=p;continue}}g==="["?i++:g==="]"?i--:g==="("?c++:g===")"&&c--}const d=a.length===0?o:o.slice(l);let x=d,h=!1;d.endsWith(Do)?(x=d.slice(0,-1),h=!0):d.startsWith(Do)&&(x=d.slice(1),h=!0);const v=u&&u>l?u-l:void 0;return Ji(a,h,x,v)};if(t){const o=t+Qi,a=s;s=i=>i.startsWith(o)?a(i.slice(o.length)):Ji(zv,!1,i,void 0,!0)}if(n){const o=s;s=a=>n({className:a,parseClassName:o})}return s},Fv=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((n,s)=>{t.set(n,1e6+s)}),n=>{const s=[];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(),s.push(...o),o=[]),s.push(i)):o.push(i)}return o.length>0&&(o.sort(),s.push(...o)),s}},Uv=e=>({cache:Dv(e.cacheSize),parseClassName:$v(e),sortModifiers:Fv(e),...Av(e)}),Bv=/\s+/,Vv=(e,t)=>{const{parseClassName:n,getClassGroupId:s,getConflictingClassGroupIds:o,sortModifiers:a}=t,i=[],c=e.trim().split(Bv);let l="";for(let u=c.length-1;u>=0;u-=1){const m=c[u],{isExternal:d,modifiers:x,hasImportantModifier:h,baseClassName:v,maybePostfixModifierPosition:p}=n(m);if(d){l=m+(l.length>0?" "+l:l);continue}let g=!!p,y=s(g?v.substring(0,p):v);if(!y){if(!g){l=m+(l.length>0?" "+l:l);continue}if(y=s(v),!y){l=m+(l.length>0?" "+l:l);continue}g=!1}const w=x.length===0?"":x.length===1?x[0]:a(x).join(":"),j=h?w+Do:w,k=j+y;if(i.indexOf(k)>-1)continue;i.push(k);const _=o(y,g);for(let S=0;S<_.length;++S){const A=_[S];i.push(j+A)}l=m+(l.length>0?" "+l:l)}return l},Wv=(...e)=>{let t=0,n,s,o="";for(;t<e.length;)(n=e[t++])&&(s=Ql(n))&&(o&&(o+=" "),o+=s);return o},Ql=e=>{if(typeof e=="string")return e;let t,n="";for(let s=0;s<e.length;s++)e[s]&&(t=Ql(e[s]))&&(n&&(n+=" "),n+=t);return n},qv=(e,...t)=>{let n,s,o,a;const i=l=>{const u=t.reduce((m,d)=>d(m),e());return n=Uv(u),s=n.cache.get,o=n.cache.set,a=c,c(l)},c=l=>{const u=s(l);if(u)return u;const m=Vv(l,n);return o(l,m),m};return a=i,(...l)=>a(Wv(...l))},Hv=[],Ue=e=>{const t=n=>n[e]||Hv;return t.isThemeGetter=!0,t},Jl=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Xl=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Zv=/^\d+\/\d+$/,Gv=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Yv=/\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$/,Kv=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Qv=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Jv=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Pn=e=>Zv.test(e),pe=e=>!!e&&!Number.isNaN(Number(e)),Jt=e=>!!e&&Number.isInteger(Number(e)),uo=e=>e.endsWith("%")&&pe(e.slice(0,-1)),Gt=e=>Gv.test(e),Xv=()=>!0,ey=e=>Yv.test(e)&&!Kv.test(e),ed=()=>!1,ty=e=>Qv.test(e),ny=e=>Jv.test(e),ry=e=>!ee(e)&&!te(e),sy=e=>Zn(e,rd,ed),ee=e=>Jl.test(e),pn=e=>Zn(e,sd,ey),mo=e=>Zn(e,ly,pe),Xi=e=>Zn(e,td,ed),oy=e=>Zn(e,nd,ny),Dr=e=>Zn(e,od,ty),te=e=>Xl.test(e),rr=e=>Gn(e,sd),ay=e=>Gn(e,dy),ec=e=>Gn(e,td),iy=e=>Gn(e,rd),cy=e=>Gn(e,nd),zr=e=>Gn(e,od,!0),Zn=(e,t,n)=>{const s=Jl.exec(e);return s?s[1]?t(s[1]):n(s[2]):!1},Gn=(e,t,n=!1)=>{const s=Xl.exec(e);return s?s[1]?t(s[1]):n:!1},td=e=>e==="position"||e==="percentage",nd=e=>e==="image"||e==="url",rd=e=>e==="length"||e==="size"||e==="bg-size",sd=e=>e==="length",ly=e=>e==="number",dy=e=>e==="family-name",od=e=>e==="shadow",uy=()=>{const e=Ue("color"),t=Ue("font"),n=Ue("text"),s=Ue("font-weight"),o=Ue("tracking"),a=Ue("leading"),i=Ue("breakpoint"),c=Ue("container"),l=Ue("spacing"),u=Ue("radius"),m=Ue("shadow"),d=Ue("inset-shadow"),x=Ue("text-shadow"),h=Ue("drop-shadow"),v=Ue("blur"),p=Ue("perspective"),g=Ue("aspect"),y=Ue("ease"),w=Ue("animate"),j=()=>["auto","avoid","all","avoid-page","page","left","right","column"],k=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],_=()=>[...k(),te,ee],S=()=>["auto","hidden","clip","visible","scroll"],A=()=>["auto","contain","none"],E=()=>[te,ee,l],I=()=>[Pn,"full","auto",...E()],T=()=>[Jt,"none","subgrid",te,ee],U=()=>["auto",{span:["full",Jt,te,ee]},Jt,te,ee],L=()=>[Jt,"auto",te,ee],B=()=>["auto","min","max","fr",te,ee],z=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],K=()=>["start","end","center","stretch","center-safe","end-safe"],V=()=>["auto",...E()],G=()=>[Pn,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...E()],D=()=>[e,te,ee],se=()=>[...k(),ec,Xi,{position:[te,ee]}],le=()=>["no-repeat",{repeat:["","x","y","space","round"]}],N=()=>["auto","cover","contain",iy,sy,{size:[te,ee]}],R=()=>[uo,rr,pn],F=()=>["","none","full",u,te,ee],Q=()=>["",pe,rr,pn],Y=()=>["solid","dashed","dotted","double"],ce=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],P=()=>[pe,uo,ec,Xi],H=()=>["","none",v,te,ee],de=()=>["none",pe,te,ee],W=()=>["none",pe,te,ee],re=()=>[pe,te,ee],ie=()=>[Pn,"full",...E()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Gt],breakpoint:[Gt],color:[Xv],container:[Gt],"drop-shadow":[Gt],ease:["in","out","in-out"],font:[ry],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Gt],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Gt],shadow:[Gt],spacing:["px",pe],text:[Gt],"text-shadow":[Gt],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Pn,ee,te,g]}],container:["container"],columns:[{columns:[pe,ee,te,c]}],"break-after":[{"break-after":j()}],"break-before":[{"break-before":j()}],"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:_()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:A()}],"overscroll-x":[{"overscroll-x":A()}],"overscroll-y":[{"overscroll-y":A()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:I()}],"inset-x":[{"inset-x":I()}],"inset-y":[{"inset-y":I()}],start:[{start:I()}],end:[{end:I()}],top:[{top:I()}],right:[{right:I()}],bottom:[{bottom:I()}],left:[{left:I()}],visibility:["visible","invisible","collapse"],z:[{z:[Jt,"auto",te,ee]}],basis:[{basis:[Pn,"full","auto",c,...E()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[pe,Pn,"auto","initial","none",ee]}],grow:[{grow:["",pe,te,ee]}],shrink:[{shrink:["",pe,te,ee]}],order:[{order:[Jt,"first","last","none",te,ee]}],"grid-cols":[{"grid-cols":T()}],"col-start-end":[{col:U()}],"col-start":[{"col-start":L()}],"col-end":[{"col-end":L()}],"grid-rows":[{"grid-rows":T()}],"row-start-end":[{row:U()}],"row-start":[{"row-start":L()}],"row-end":[{"row-end":L()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":B()}],"auto-rows":[{"auto-rows":B()}],gap:[{gap:E()}],"gap-x":[{"gap-x":E()}],"gap-y":[{"gap-y":E()}],"justify-content":[{justify:[...z(),"normal"]}],"justify-items":[{"justify-items":[...K(),"normal"]}],"justify-self":[{"justify-self":["auto",...K()]}],"align-content":[{content:["normal",...z()]}],"align-items":[{items:[...K(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...K(),{baseline:["","last"]}]}],"place-content":[{"place-content":z()}],"place-items":[{"place-items":[...K(),"baseline"]}],"place-self":[{"place-self":["auto",...K()]}],p:[{p:E()}],px:[{px:E()}],py:[{py:E()}],ps:[{ps:E()}],pe:[{pe:E()}],pt:[{pt:E()}],pr:[{pr:E()}],pb:[{pb:E()}],pl:[{pl:E()}],m:[{m:V()}],mx:[{mx:V()}],my:[{my:V()}],ms:[{ms:V()}],me:[{me:V()}],mt:[{mt:V()}],mr:[{mr:V()}],mb:[{mb:V()}],ml:[{ml:V()}],"space-x":[{"space-x":E()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":E()}],"space-y-reverse":["space-y-reverse"],size:[{size:G()}],w:[{w:[c,"screen",...G()]}],"min-w":[{"min-w":[c,"screen","none",...G()]}],"max-w":[{"max-w":[c,"screen","none","prose",{screen:[i]},...G()]}],h:[{h:["screen","lh",...G()]}],"min-h":[{"min-h":["screen","lh","none",...G()]}],"max-h":[{"max-h":["screen","lh",...G()]}],"font-size":[{text:["base",n,rr,pn]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[s,te,mo]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",uo,ee]}],"font-family":[{font:[ay,ee,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,te,ee]}],"line-clamp":[{"line-clamp":[pe,"none",te,mo]}],leading:[{leading:[a,...E()]}],"list-image":[{"list-image":["none",te,ee]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",te,ee]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:D()}],"text-color":[{text:D()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...Y(),"wavy"]}],"text-decoration-thickness":[{decoration:[pe,"from-font","auto",te,pn]}],"text-decoration-color":[{decoration:D()}],"underline-offset":[{"underline-offset":[pe,"auto",te,ee]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:E()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",te,ee]}],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",te,ee]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:se()}],"bg-repeat":[{bg:le()}],"bg-size":[{bg:N()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Jt,te,ee],radial:["",te,ee],conic:[Jt,te,ee]},cy,oy]}],"bg-color":[{bg:D()}],"gradient-from-pos":[{from:R()}],"gradient-via-pos":[{via:R()}],"gradient-to-pos":[{to:R()}],"gradient-from":[{from:D()}],"gradient-via":[{via:D()}],"gradient-to":[{to:D()}],rounded:[{rounded:F()}],"rounded-s":[{"rounded-s":F()}],"rounded-e":[{"rounded-e":F()}],"rounded-t":[{"rounded-t":F()}],"rounded-r":[{"rounded-r":F()}],"rounded-b":[{"rounded-b":F()}],"rounded-l":[{"rounded-l":F()}],"rounded-ss":[{"rounded-ss":F()}],"rounded-se":[{"rounded-se":F()}],"rounded-ee":[{"rounded-ee":F()}],"rounded-es":[{"rounded-es":F()}],"rounded-tl":[{"rounded-tl":F()}],"rounded-tr":[{"rounded-tr":F()}],"rounded-br":[{"rounded-br":F()}],"rounded-bl":[{"rounded-bl":F()}],"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:[...Y(),"hidden","none"]}],"divide-style":[{divide:[...Y(),"hidden","none"]}],"border-color":[{border:D()}],"border-color-x":[{"border-x":D()}],"border-color-y":[{"border-y":D()}],"border-color-s":[{"border-s":D()}],"border-color-e":[{"border-e":D()}],"border-color-t":[{"border-t":D()}],"border-color-r":[{"border-r":D()}],"border-color-b":[{"border-b":D()}],"border-color-l":[{"border-l":D()}],"divide-color":[{divide:D()}],"outline-style":[{outline:[...Y(),"none","hidden"]}],"outline-offset":[{"outline-offset":[pe,te,ee]}],"outline-w":[{outline:["",pe,rr,pn]}],"outline-color":[{outline:D()}],shadow:[{shadow:["","none",m,zr,Dr]}],"shadow-color":[{shadow:D()}],"inset-shadow":[{"inset-shadow":["none",d,zr,Dr]}],"inset-shadow-color":[{"inset-shadow":D()}],"ring-w":[{ring:Q()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:D()}],"ring-offset-w":[{"ring-offset":[pe,pn]}],"ring-offset-color":[{"ring-offset":D()}],"inset-ring-w":[{"inset-ring":Q()}],"inset-ring-color":[{"inset-ring":D()}],"text-shadow":[{"text-shadow":["none",x,zr,Dr]}],"text-shadow-color":[{"text-shadow":D()}],opacity:[{opacity:[pe,te,ee]}],"mix-blend":[{"mix-blend":[...ce(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":ce()}],"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":[pe]}],"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":D()}],"mask-image-linear-to-color":[{"mask-linear-to":D()}],"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":D()}],"mask-image-t-to-color":[{"mask-t-to":D()}],"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":D()}],"mask-image-r-to-color":[{"mask-r-to":D()}],"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":D()}],"mask-image-b-to-color":[{"mask-b-to":D()}],"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":D()}],"mask-image-l-to-color":[{"mask-l-to":D()}],"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":D()}],"mask-image-x-to-color":[{"mask-x-to":D()}],"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":D()}],"mask-image-y-to-color":[{"mask-y-to":D()}],"mask-image-radial":[{"mask-radial":[te,ee]}],"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":D()}],"mask-image-radial-to-color":[{"mask-radial-to":D()}],"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":k()}],"mask-image-conic-pos":[{"mask-conic":[pe]}],"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":D()}],"mask-image-conic-to-color":[{"mask-conic-to":D()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:se()}],"mask-repeat":[{mask:le()}],"mask-size":[{mask:N()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",te,ee]}],filter:[{filter:["","none",te,ee]}],blur:[{blur:H()}],brightness:[{brightness:[pe,te,ee]}],contrast:[{contrast:[pe,te,ee]}],"drop-shadow":[{"drop-shadow":["","none",h,zr,Dr]}],"drop-shadow-color":[{"drop-shadow":D()}],grayscale:[{grayscale:["",pe,te,ee]}],"hue-rotate":[{"hue-rotate":[pe,te,ee]}],invert:[{invert:["",pe,te,ee]}],saturate:[{saturate:[pe,te,ee]}],sepia:[{sepia:["",pe,te,ee]}],"backdrop-filter":[{"backdrop-filter":["","none",te,ee]}],"backdrop-blur":[{"backdrop-blur":H()}],"backdrop-brightness":[{"backdrop-brightness":[pe,te,ee]}],"backdrop-contrast":[{"backdrop-contrast":[pe,te,ee]}],"backdrop-grayscale":[{"backdrop-grayscale":["",pe,te,ee]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[pe,te,ee]}],"backdrop-invert":[{"backdrop-invert":["",pe,te,ee]}],"backdrop-opacity":[{"backdrop-opacity":[pe,te,ee]}],"backdrop-saturate":[{"backdrop-saturate":[pe,te,ee]}],"backdrop-sepia":[{"backdrop-sepia":["",pe,te,ee]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":E()}],"border-spacing-x":[{"border-spacing-x":E()}],"border-spacing-y":[{"border-spacing-y":E()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",te,ee]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[pe,"initial",te,ee]}],ease:[{ease:["linear","initial",y,te,ee]}],delay:[{delay:[pe,te,ee]}],animate:[{animate:["none",w,te,ee]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[p,te,ee]}],"perspective-origin":[{"perspective-origin":_()}],rotate:[{rotate:de()}],"rotate-x":[{"rotate-x":de()}],"rotate-y":[{"rotate-y":de()}],"rotate-z":[{"rotate-z":de()}],scale:[{scale:W()}],"scale-x":[{"scale-x":W()}],"scale-y":[{"scale-y":W()}],"scale-z":[{"scale-z":W()}],"scale-3d":["scale-3d"],skew:[{skew:re()}],"skew-x":[{"skew-x":re()}],"skew-y":[{"skew-y":re()}],transform:[{transform:[te,ee,"","none","gpu","cpu"]}],"transform-origin":[{origin:_()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ie()}],"translate-x":[{"translate-x":ie()}],"translate-y":[{"translate-y":ie()}],"translate-z":[{"translate-z":ie()}],"translate-none":["translate-none"],accent:[{accent:D()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:D()}],"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",te,ee]}],"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":E()}],"scroll-mx":[{"scroll-mx":E()}],"scroll-my":[{"scroll-my":E()}],"scroll-ms":[{"scroll-ms":E()}],"scroll-me":[{"scroll-me":E()}],"scroll-mt":[{"scroll-mt":E()}],"scroll-mr":[{"scroll-mr":E()}],"scroll-mb":[{"scroll-mb":E()}],"scroll-ml":[{"scroll-ml":E()}],"scroll-p":[{"scroll-p":E()}],"scroll-px":[{"scroll-px":E()}],"scroll-py":[{"scroll-py":E()}],"scroll-ps":[{"scroll-ps":E()}],"scroll-pe":[{"scroll-pe":E()}],"scroll-pt":[{"scroll-pt":E()}],"scroll-pr":[{"scroll-pr":E()}],"scroll-pb":[{"scroll-pb":E()}],"scroll-pl":[{"scroll-pl":E()}],"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",te,ee]}],fill:[{fill:["none",...D()]}],"stroke-w":[{stroke:[pe,rr,pn,mo]}],stroke:[{stroke:["none",...D()]}],"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"]}},my=qv(uy);function O(...e){return my(Zl(e))}const fy=ga("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"}}),J=f.forwardRef(({className:e,variant:t,size:n,asChild:s,...o},a)=>{const i=s?yv:"button";return r.jsx(i,{className:O(fy({variant:t,size:n}),e),ref:a,...o})});J.displayName="Button";const py=ga("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 ht({className:e,variant:t,...n}){return r.jsx("div",{className:O(py({variant:t}),e),...n})}const Xe=f.forwardRef(({className:e,...t},n)=>r.jsx("div",{ref:n,className:O("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}));Xe.displayName="Card";const vr=f.forwardRef(({className:e,...t},n)=>r.jsx("div",{ref:n,className:O("flex flex-col space-y-1.5 p-6",e),...t}));vr.displayName="CardHeader";const yr=f.forwardRef(({className:e,...t},n)=>r.jsx("h3",{ref:n,className:O("text-lg font-semibold leading-none tracking-tight",e),...t}));yr.displayName="CardTitle";const ad=f.forwardRef(({className:e,...t},n)=>r.jsx("p",{ref:n,className:O("text-sm text-neutral-500 dark:text-neutral-400",e),...t}));ad.displayName="CardDescription";const rt=f.forwardRef(({className:e,...t},n)=>r.jsx("div",{ref:n,className:O("p-6 pt-0",e),...t}));rt.displayName="CardContent";const id=f.forwardRef(({className:e,...t},n)=>r.jsx("div",{ref:n,className:O("flex items-center p-6 pt-0",e),...t}));id.displayName="CardFooter";const Te=f.forwardRef(({className:e,...t},n)=>r.jsx("input",{ref:n,className:O("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}));Te.displayName="Input";const He=f.forwardRef(({className:e,...t},n)=>r.jsx("label",{ref:n,className:O("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",e),...t}));He.displayName="Label";var hy=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],gy=hy.reduce((e,t)=>{const n=ql(`Primitive.${t}`),s=f.forwardRef((o,a)=>{const{asChild:i,...c}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(l,{...c,ref:a})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{}),xy="Separator",tc="horizontal",vy=["horizontal","vertical"],cd=f.forwardRef((e,t)=>{const{decorative:n,orientation:s=tc,...o}=e,a=yy(s)?s:tc,c=n?{role:"none"}:{"aria-orientation":a==="vertical"?a:void 0,role:"separator"};return r.jsx(gy.div,{"data-orientation":a,...c,...o,ref:t})});cd.displayName=xy;function yy(e){return vy.includes(e)}var ld=cd;const lt=f.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...s},o)=>r.jsx(ld,{ref:o,decorative:n,orientation:t,className:O("shrink-0 bg-neutral-200 dark:bg-neutral-800",t==="horizontal"?"h-px w-full":"h-full w-px",e),...s}));lt.displayName=ld.displayName;function Oe({className:e,...t}){return r.jsx("div",{className:O("animate-pulse rounded-md bg-neutral-100 dark:bg-neutral-800",e),...t})}function nc(e,[t,n]){return Math.min(n,Math.max(t,e))}function ve(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e?.(o),n===!1||!o.defaultPrevented)return t?.(o)}}function by(e,t){const n=f.createContext(t),s=a=>{const{children:i,...c}=a,l=f.useMemo(()=>c,Object.values(c));return r.jsx(n.Provider,{value:l,children:i})};s.displayName=e+"Provider";function o(a){const i=f.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${a}\` must be used within \`${e}\``)}return[s,o]}function an(e,t=[]){let n=[];function s(a,i){const c=f.createContext(i),l=n.length;n=[...n,i];const u=d=>{const{scope:x,children:h,...v}=d,p=x?.[e]?.[l]||c,g=f.useMemo(()=>v,Object.values(v));return r.jsx(p.Provider,{value:g,children:h})};u.displayName=a+"Provider";function m(d,x){const h=x?.[e]?.[l]||c,v=f.useContext(h);if(v)return v;if(i!==void 0)return i;throw new Error(`\`${d}\` must be used within \`${a}\``)}return[u,m]}const o=()=>{const a=n.map(i=>f.createContext(i));return function(c){const l=c?.[e]||a;return f.useMemo(()=>({[`__scope${e}`]:{...c,[e]:l}}),[c,l])}};return o.scopeName=e,[s,wy(o,...t)]}function wy(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const s=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(a){const i=s.reduce((c,{useScope:l,scopeName:u})=>{const d=l(a)[`__scope${u}`];return{...c,...d}},{});return f.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}function rc(e){const t=ky(e),n=f.forwardRef((s,o)=>{const{children:a,...i}=s,c=f.Children.toArray(a),l=c.find(_y);if(l){const u=l.props.children,m=c.map(d=>d===l?f.Children.count(u)>1?f.Children.only(null):f.isValidElement(u)?u.props.children:null:d);return r.jsx(t,{...i,ref:o,children:f.isValidElement(u)?f.cloneElement(u,void 0,m):null})}return r.jsx(t,{...i,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}function ky(e){const t=f.forwardRef((n,s)=>{const{children:o,...a}=n;if(f.isValidElement(o)){const i=Cy(o),c=Sy(a,o.props);return o.type!==f.Fragment&&(c.ref=s?Hn(s,i):i),f.cloneElement(o,c)}return f.Children.count(o)>1?f.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var jy=Symbol("radix.slottable");function _y(e){return f.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===jy}function Sy(e,t){const n={...t};for(const s in t){const o=e[s],a=t[s];/^on[A-Z]/.test(s)?o&&a?n[s]=(...c)=>{const l=a(...c);return o(...c),l}:o&&(n[s]=o):s==="style"?n[s]={...o,...a}:s==="className"&&(n[s]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function Cy(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 va(e){const t=e+"CollectionProvider",[n,s]=an(t),[o,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=p=>{const{scope:g,children:y}=p,w=b.useRef(null),j=b.useRef(new Map).current;return r.jsx(o,{scope:g,itemMap:j,collectionRef:w,children:y})};i.displayName=t;const c=e+"CollectionSlot",l=rc(c),u=b.forwardRef((p,g)=>{const{scope:y,children:w}=p,j=a(c,y),k=Se(g,j.collectionRef);return r.jsx(l,{ref:k,children:w})});u.displayName=c;const m=e+"CollectionItemSlot",d="data-radix-collection-item",x=rc(m),h=b.forwardRef((p,g)=>{const{scope:y,children:w,...j}=p,k=b.useRef(null),_=Se(g,k),S=a(m,y);return b.useEffect(()=>(S.itemMap.set(k,{ref:k,...j}),()=>void S.itemMap.delete(k))),r.jsx(x,{[d]:"",ref:_,children:w})});h.displayName=m;function v(p){const g=a(e+"CollectionConsumer",p);return b.useCallback(()=>{const w=g.collectionRef.current;if(!w)return[];const j=Array.from(w.querySelectorAll(`[${d}]`));return Array.from(g.itemMap.values()).sort((S,A)=>j.indexOf(S.ref.current)-j.indexOf(A.ref.current))},[g.collectionRef,g.itemMap])}return[{Provider:i,Slot:u,ItemSlot:h},v,s]}var Ny=f.createContext(void 0);function Ns(e){const t=f.useContext(Ny);return e||t||"ltr"}function Ay(e){const t=Ey(e),n=f.forwardRef((s,o)=>{const{children:a,...i}=s,c=f.Children.toArray(a),l=c.find(Ty);if(l){const u=l.props.children,m=c.map(d=>d===l?f.Children.count(u)>1?f.Children.only(null):f.isValidElement(u)?u.props.children:null:d);return r.jsx(t,{...i,ref:o,children:f.isValidElement(u)?f.cloneElement(u,void 0,m):null})}return r.jsx(t,{...i,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}function Ey(e){const t=f.forwardRef((n,s)=>{const{children:o,...a}=n;if(f.isValidElement(o)){const i=Ry(o),c=Py(a,o.props);return o.type!==f.Fragment&&(c.ref=s?Hn(s,i):i),f.cloneElement(o,c)}return f.Children.count(o)>1?f.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Iy=Symbol("radix.slottable");function Ty(e){return f.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Iy}function Py(e,t){const n={...t};for(const s in t){const o=e[s],a=t[s];/^on[A-Z]/.test(s)?o&&a?n[s]=(...c)=>{const l=a(...c);return o(...c),l}:o&&(n[s]=o):s==="style"?n[s]={...o,...a}:s==="className"&&(n[s]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function Ry(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 Oy=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ge=Oy.reduce((e,t)=>{const n=Ay(`Primitive.${t}`),s=f.forwardRef((o,a)=>{const{asChild:i,...c}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(l,{...c,ref:a})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{});function My(e,t){e&&ws.flushSync(()=>e.dispatchEvent(t))}function en(e){const t=f.useRef(e);return f.useEffect(()=>{t.current=e}),f.useMemo(()=>(...n)=>t.current?.(...n),[])}function Ly(e,t=globalThis?.document){const n=en(e);f.useEffect(()=>{const s=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",s,{capture:!0}),()=>t.removeEventListener("keydown",s,{capture:!0})},[n,t])}var Dy="DismissableLayer",zo="dismissableLayer.update",zy="dismissableLayer.pointerDownOutside",$y="dismissableLayer.focusOutside",sc,dd=f.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),ya=f.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:i,onDismiss:c,...l}=e,u=f.useContext(dd),[m,d]=f.useState(null),x=m?.ownerDocument??globalThis?.document,[,h]=f.useState({}),v=Se(t,A=>d(A)),p=Array.from(u.layers),[g]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),y=p.indexOf(g),w=m?p.indexOf(m):-1,j=u.layersWithOutsidePointerEventsDisabled.size>0,k=w>=y,_=By(A=>{const E=A.target,I=[...u.branches].some(T=>T.contains(E));!k||I||(o?.(A),i?.(A),A.defaultPrevented||c?.())},x),S=Vy(A=>{const E=A.target;[...u.branches].some(T=>T.contains(E))||(a?.(A),i?.(A),A.defaultPrevented||c?.())},x);return Ly(A=>{w===u.layers.size-1&&(s?.(A),!A.defaultPrevented&&c&&(A.preventDefault(),c()))},x),f.useEffect(()=>{if(m)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(sc=x.body.style.pointerEvents,x.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(m)),u.layers.add(m),oc(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(x.body.style.pointerEvents=sc)}},[m,x,n,u]),f.useEffect(()=>()=>{m&&(u.layers.delete(m),u.layersWithOutsidePointerEventsDisabled.delete(m),oc())},[m,u]),f.useEffect(()=>{const A=()=>h({});return document.addEventListener(zo,A),()=>document.removeEventListener(zo,A)},[]),r.jsx(ge.div,{...l,ref:v,style:{pointerEvents:j?k?"auto":"none":void 0,...e.style},onFocusCapture:ve(e.onFocusCapture,S.onFocusCapture),onBlurCapture:ve(e.onBlurCapture,S.onBlurCapture),onPointerDownCapture:ve(e.onPointerDownCapture,_.onPointerDownCapture)})});ya.displayName=Dy;var Fy="DismissableLayerBranch",Uy=f.forwardRef((e,t)=>{const n=f.useContext(dd),s=f.useRef(null),o=Se(t,s);return f.useEffect(()=>{const a=s.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),r.jsx(ge.div,{...e,ref:o})});Uy.displayName=Fy;function By(e,t=globalThis?.document){const n=en(e),s=f.useRef(!1),o=f.useRef(()=>{});return f.useEffect(()=>{const a=c=>{if(c.target&&!s.current){let l=function(){ud(zy,n,u,{discrete:!0})};const u={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);s.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:()=>s.current=!0}}function Vy(e,t=globalThis?.document){const n=en(e),s=f.useRef(!1);return f.useEffect(()=>{const o=a=>{a.target&&!s.current&&ud($y,n,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>s.current=!0,onBlurCapture:()=>s.current=!1}}function oc(){const e=new CustomEvent(zo);document.dispatchEvent(e)}function ud(e,t,n,{discrete:s}){const o=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),s?My(o,a):o.dispatchEvent(a)}var fo=0;function md(){f.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??ac()),document.body.insertAdjacentElement("beforeend",e[1]??ac()),fo++,()=>{fo===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),fo--}},[])}function ac(){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 po="focusScope.autoFocusOnMount",ho="focusScope.autoFocusOnUnmount",ic={bubbles:!1,cancelable:!0},Wy="FocusScope",ba=f.forwardRef((e,t)=>{const{loop:n=!1,trapped:s=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...i}=e,[c,l]=f.useState(null),u=en(o),m=en(a),d=f.useRef(null),x=Se(t,p=>l(p)),h=f.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;f.useEffect(()=>{if(s){let p=function(j){if(h.paused||!c)return;const k=j.target;c.contains(k)?d.current=k:Xt(d.current,{select:!0})},g=function(j){if(h.paused||!c)return;const k=j.relatedTarget;k!==null&&(c.contains(k)||Xt(d.current,{select:!0}))},y=function(j){if(document.activeElement===document.body)for(const _ of j)_.removedNodes.length>0&&Xt(c)};document.addEventListener("focusin",p),document.addEventListener("focusout",g);const w=new MutationObserver(y);return c&&w.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",p),document.removeEventListener("focusout",g),w.disconnect()}}},[s,c,h.paused]),f.useEffect(()=>{if(c){lc.add(h);const p=document.activeElement;if(!c.contains(p)){const y=new CustomEvent(po,ic);c.addEventListener(po,u),c.dispatchEvent(y),y.defaultPrevented||(qy(Ky(fd(c)),{select:!0}),document.activeElement===p&&Xt(c))}return()=>{c.removeEventListener(po,u),setTimeout(()=>{const y=new CustomEvent(ho,ic);c.addEventListener(ho,m),c.dispatchEvent(y),y.defaultPrevented||Xt(p??document.body,{select:!0}),c.removeEventListener(ho,m),lc.remove(h)},0)}}},[c,u,m,h]);const v=f.useCallback(p=>{if(!n&&!s||h.paused)return;const g=p.key==="Tab"&&!p.altKey&&!p.ctrlKey&&!p.metaKey,y=document.activeElement;if(g&&y){const w=p.currentTarget,[j,k]=Hy(w);j&&k?!p.shiftKey&&y===k?(p.preventDefault(),n&&Xt(j,{select:!0})):p.shiftKey&&y===j&&(p.preventDefault(),n&&Xt(k,{select:!0})):y===w&&p.preventDefault()}},[n,s,h.paused]);return r.jsx(ge.div,{tabIndex:-1,...i,ref:x,onKeyDown:v})});ba.displayName=Wy;function qy(e,{select:t=!1}={}){const n=document.activeElement;for(const s of e)if(Xt(s,{select:t}),document.activeElement!==n)return}function Hy(e){const t=fd(e),n=cc(t,e),s=cc(t.reverse(),e);return[n,s]}function fd(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:s=>{const o=s.tagName==="INPUT"&&s.type==="hidden";return s.disabled||s.hidden||o?NodeFilter.FILTER_SKIP:s.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function cc(e,t){for(const n of e)if(!Zy(n,{upTo:t}))return n}function Zy(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 Gy(e){return e instanceof HTMLInputElement&&"select"in e}function Xt(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Gy(e)&&t&&e.select()}}var lc=Yy();function Yy(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=dc(e,t),e.unshift(t)},remove(t){e=dc(e,t),e[0]?.resume()}}}function dc(e,t){const n=[...e],s=n.indexOf(t);return s!==-1&&n.splice(s,1),n}function Ky(e){return e.filter(t=>t.tagName!=="A")}var Ye=globalThis?.document?f.useLayoutEffect:()=>{},Qy=f[" useId ".trim().toString()]||(()=>{}),Jy=0;function zt(e){const[t,n]=f.useState(Qy());return Ye(()=>{n(s=>s??String(Jy++))},[e]),e||(t?`radix-${t}`:"")}const Xy=["top","right","bottom","left"],tn=Math.min,pt=Math.max,ds=Math.round,$r=Math.floor,$t=e=>({x:e,y:e}),eb={left:"right",right:"left",bottom:"top",top:"bottom"},tb={start:"end",end:"start"};function $o(e,t,n){return pt(e,tn(t,n))}function Yt(e,t){return typeof e=="function"?e(t):e}function Kt(e){return e.split("-")[0]}function Yn(e){return e.split("-")[1]}function wa(e){return e==="x"?"y":"x"}function ka(e){return e==="y"?"height":"width"}const nb=new Set(["top","bottom"]);function Dt(e){return nb.has(Kt(e))?"y":"x"}function ja(e){return wa(Dt(e))}function rb(e,t,n){n===void 0&&(n=!1);const s=Yn(e),o=ja(e),a=ka(o);let i=o==="x"?s===(n?"end":"start")?"right":"left":s==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(i=us(i)),[i,us(i)]}function sb(e){const t=us(e);return[Fo(e),t,Fo(t)]}function Fo(e){return e.replace(/start|end/g,t=>tb[t])}const uc=["left","right"],mc=["right","left"],ob=["top","bottom"],ab=["bottom","top"];function ib(e,t,n){switch(e){case"top":case"bottom":return n?t?mc:uc:t?uc:mc;case"left":case"right":return t?ob:ab;default:return[]}}function cb(e,t,n,s){const o=Yn(e);let a=ib(Kt(e),n==="start",s);return o&&(a=a.map(i=>i+"-"+o),t&&(a=a.concat(a.map(Fo)))),a}function us(e){return e.replace(/left|right|bottom|top/g,t=>eb[t])}function lb(e){return{top:0,right:0,bottom:0,left:0,...e}}function pd(e){return typeof e!="number"?lb(e):{top:e,right:e,bottom:e,left:e}}function ms(e){const{x:t,y:n,width:s,height:o}=e;return{width:s,height:o,top:n,left:t,right:t+s,bottom:n+o,x:t,y:n}}function fc(e,t,n){let{reference:s,floating:o}=e;const a=Dt(t),i=ja(t),c=ka(i),l=Kt(t),u=a==="y",m=s.x+s.width/2-o.width/2,d=s.y+s.height/2-o.height/2,x=s[c]/2-o[c]/2;let h;switch(l){case"top":h={x:m,y:s.y-o.height};break;case"bottom":h={x:m,y:s.y+s.height};break;case"right":h={x:s.x+s.width,y:d};break;case"left":h={x:s.x-o.width,y:d};break;default:h={x:s.x,y:s.y}}switch(Yn(t)){case"start":h[i]-=x*(n&&u?-1:1);break;case"end":h[i]+=x*(n&&u?-1:1);break}return h}const db=async(e,t,n)=>{const{placement:s="bottom",strategy:o="absolute",middleware:a=[],platform:i}=n,c=a.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(t));let u=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:m,y:d}=fc(u,s,l),x=s,h={},v=0;for(let p=0;p<c.length;p++){const{name:g,fn:y}=c[p],{x:w,y:j,data:k,reset:_}=await y({x:m,y:d,initialPlacement:s,placement:x,strategy:o,middlewareData:h,rects:u,platform:i,elements:{reference:e,floating:t}});m=w??m,d=j??d,h={...h,[g]:{...h[g],...k}},_&&v<=50&&(v++,typeof _=="object"&&(_.placement&&(x=_.placement),_.rects&&(u=_.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):_.rects),{x:m,y:d}=fc(u,x,l)),p=-1)}return{x:m,y:d,placement:x,strategy:o,middlewareData:h}};async function br(e,t){var n;t===void 0&&(t={});const{x:s,y:o,platform:a,rects:i,elements:c,strategy:l}=e,{boundary:u="clippingAncestors",rootBoundary:m="viewport",elementContext:d="floating",altBoundary:x=!1,padding:h=0}=Yt(t,e),v=pd(h),g=c[x?d==="floating"?"reference":"floating":d],y=ms(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(g)))==null||n?g:g.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(c.floating)),boundary:u,rootBoundary:m,strategy:l})),w=d==="floating"?{x:s,y:o,width:i.floating.width,height:i.floating.height}:i.reference,j=await(a.getOffsetParent==null?void 0:a.getOffsetParent(c.floating)),k=await(a.isElement==null?void 0:a.isElement(j))?await(a.getScale==null?void 0:a.getScale(j))||{x:1,y:1}:{x:1,y:1},_=ms(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:w,offsetParent:j,strategy:l}):w);return{top:(y.top-_.top+v.top)/k.y,bottom:(_.bottom-y.bottom+v.bottom)/k.y,left:(y.left-_.left+v.left)/k.x,right:(_.right-y.right+v.right)/k.x}}const ub=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:s,placement:o,rects:a,platform:i,elements:c,middlewareData:l}=t,{element:u,padding:m=0}=Yt(e,t)||{};if(u==null)return{};const d=pd(m),x={x:n,y:s},h=ja(o),v=ka(h),p=await i.getDimensions(u),g=h==="y",y=g?"top":"left",w=g?"bottom":"right",j=g?"clientHeight":"clientWidth",k=a.reference[v]+a.reference[h]-x[h]-a.floating[v],_=x[h]-a.reference[h],S=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let A=S?S[j]:0;(!A||!await(i.isElement==null?void 0:i.isElement(S)))&&(A=c.floating[j]||a.floating[v]);const E=k/2-_/2,I=A/2-p[v]/2-1,T=tn(d[y],I),U=tn(d[w],I),L=T,B=A-p[v]-U,z=A/2-p[v]/2+E,K=$o(L,z,B),V=!l.arrow&&Yn(o)!=null&&z!==K&&a.reference[v]/2-(z<L?T:U)-p[v]/2<0,G=V?z<L?z-L:z-B:0;return{[h]:x[h]+G,data:{[h]:K,centerOffset:z-K-G,...V&&{alignmentOffset:G}},reset:V}}}),mb=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,s;const{placement:o,middlewareData:a,rects:i,initialPlacement:c,platform:l,elements:u}=t,{mainAxis:m=!0,crossAxis:d=!0,fallbackPlacements:x,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:p=!0,...g}=Yt(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const y=Kt(o),w=Dt(c),j=Kt(c)===c,k=await(l.isRTL==null?void 0:l.isRTL(u.floating)),_=x||(j||!p?[us(c)]:sb(c)),S=v!=="none";!x&&S&&_.push(...cb(c,p,v,k));const A=[c,..._],E=await br(t,g),I=[];let T=((s=a.flip)==null?void 0:s.overflows)||[];if(m&&I.push(E[y]),d){const z=rb(o,i,k);I.push(E[z[0]],E[z[1]])}if(T=[...T,{placement:o,overflows:I}],!I.every(z=>z<=0)){var U,L;const z=(((U=a.flip)==null?void 0:U.index)||0)+1,K=A[z];if(K&&(!(d==="alignment"?w!==Dt(K):!1)||T.every(D=>Dt(D.placement)===w?D.overflows[0]>0:!0)))return{data:{index:z,overflows:T},reset:{placement:K}};let V=(L=T.filter(G=>G.overflows[0]<=0).sort((G,D)=>G.overflows[1]-D.overflows[1])[0])==null?void 0:L.placement;if(!V)switch(h){case"bestFit":{var B;const G=(B=T.filter(D=>{if(S){const se=Dt(D.placement);return se===w||se==="y"}return!0}).map(D=>[D.placement,D.overflows.filter(se=>se>0).reduce((se,le)=>se+le,0)]).sort((D,se)=>D[1]-se[1])[0])==null?void 0:B[0];G&&(V=G);break}case"initialPlacement":V=c;break}if(o!==V)return{reset:{placement:V}}}return{}}}};function pc(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function hc(e){return Xy.some(t=>e[t]>=0)}const fb=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:s="referenceHidden",...o}=Yt(e,t);switch(s){case"referenceHidden":{const a=await br(t,{...o,elementContext:"reference"}),i=pc(a,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:hc(i)}}}case"escaped":{const a=await br(t,{...o,altBoundary:!0}),i=pc(a,n.floating);return{data:{escapedOffsets:i,escaped:hc(i)}}}default:return{}}}}},hd=new Set(["left","top"]);async function pb(e,t){const{placement:n,platform:s,elements:o}=e,a=await(s.isRTL==null?void 0:s.isRTL(o.floating)),i=Kt(n),c=Yn(n),l=Dt(n)==="y",u=hd.has(i)?-1:1,m=a&&l?-1:1,d=Yt(t,e);let{mainAxis:x,crossAxis:h,alignmentAxis:v}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return c&&typeof v=="number"&&(h=c==="end"?v*-1:v),l?{x:h*m,y:x*u}:{x:x*u,y:h*m}}const hb=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,s;const{x:o,y:a,placement:i,middlewareData:c}=t,l=await pb(t,e);return i===((n=c.offset)==null?void 0:n.placement)&&(s=c.arrow)!=null&&s.alignmentOffset?{}:{x:o+l.x,y:a+l.y,data:{...l,placement:i}}}}},gb=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:s,placement:o}=t,{mainAxis:a=!0,crossAxis:i=!1,limiter:c={fn:g=>{let{x:y,y:w}=g;return{x:y,y:w}}},...l}=Yt(e,t),u={x:n,y:s},m=await br(t,l),d=Dt(Kt(o)),x=wa(d);let h=u[x],v=u[d];if(a){const g=x==="y"?"top":"left",y=x==="y"?"bottom":"right",w=h+m[g],j=h-m[y];h=$o(w,h,j)}if(i){const g=d==="y"?"top":"left",y=d==="y"?"bottom":"right",w=v+m[g],j=v-m[y];v=$o(w,v,j)}const p=c.fn({...t,[x]:h,[d]:v});return{...p,data:{x:p.x-n,y:p.y-s,enabled:{[x]:a,[d]:i}}}}}},xb=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:s,placement:o,rects:a,middlewareData:i}=t,{offset:c=0,mainAxis:l=!0,crossAxis:u=!0}=Yt(e,t),m={x:n,y:s},d=Dt(o),x=wa(d);let h=m[x],v=m[d];const p=Yt(c,t),g=typeof p=="number"?{mainAxis:p,crossAxis:0}:{mainAxis:0,crossAxis:0,...p};if(l){const j=x==="y"?"height":"width",k=a.reference[x]-a.floating[j]+g.mainAxis,_=a.reference[x]+a.reference[j]-g.mainAxis;h<k?h=k:h>_&&(h=_)}if(u){var y,w;const j=x==="y"?"width":"height",k=hd.has(Kt(o)),_=a.reference[d]-a.floating[j]+(k&&((y=i.offset)==null?void 0:y[d])||0)+(k?0:g.crossAxis),S=a.reference[d]+a.reference[j]+(k?0:((w=i.offset)==null?void 0:w[d])||0)-(k?g.crossAxis:0);v<_?v=_:v>S&&(v=S)}return{[x]:h,[d]:v}}}},vb=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,s;const{placement:o,rects:a,platform:i,elements:c}=t,{apply:l=()=>{},...u}=Yt(e,t),m=await br(t,u),d=Kt(o),x=Yn(o),h=Dt(o)==="y",{width:v,height:p}=a.floating;let g,y;d==="top"||d==="bottom"?(g=d,y=x===(await(i.isRTL==null?void 0:i.isRTL(c.floating))?"start":"end")?"left":"right"):(y=d,g=x==="end"?"top":"bottom");const w=p-m.top-m.bottom,j=v-m.left-m.right,k=tn(p-m[g],w),_=tn(v-m[y],j),S=!t.middlewareData.shift;let A=k,E=_;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(E=j),(s=t.middlewareData.shift)!=null&&s.enabled.y&&(A=w),S&&!x){const T=pt(m.left,0),U=pt(m.right,0),L=pt(m.top,0),B=pt(m.bottom,0);h?E=v-2*(T!==0||U!==0?T+U:pt(m.left,m.right)):A=p-2*(L!==0||B!==0?L+B:pt(m.top,m.bottom))}await l({...t,availableWidth:E,availableHeight:A});const I=await i.getDimensions(c.floating);return v!==I.width||p!==I.height?{reset:{rects:!0}}:{}}}};function As(){return typeof window<"u"}function Kn(e){return gd(e)?(e.nodeName||"").toLowerCase():"#document"}function gt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Bt(e){var t;return(t=(gd(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function gd(e){return As()?e instanceof Node||e instanceof gt(e).Node:!1}function Nt(e){return As()?e instanceof Element||e instanceof gt(e).Element:!1}function Ut(e){return As()?e instanceof HTMLElement||e instanceof gt(e).HTMLElement:!1}function gc(e){return!As()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof gt(e).ShadowRoot}const yb=new Set(["inline","contents"]);function Er(e){const{overflow:t,overflowX:n,overflowY:s,display:o}=At(e);return/auto|scroll|overlay|hidden|clip/.test(t+s+n)&&!yb.has(o)}const bb=new Set(["table","td","th"]);function wb(e){return bb.has(Kn(e))}const kb=[":popover-open",":modal"];function Es(e){return kb.some(t=>{try{return e.matches(t)}catch{return!1}})}const jb=["transform","translate","scale","rotate","perspective"],_b=["transform","translate","scale","rotate","perspective","filter"],Sb=["paint","layout","strict","content"];function _a(e){const t=Sa(),n=Nt(e)?At(e):e;return jb.some(s=>n[s]?n[s]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||_b.some(s=>(n.willChange||"").includes(s))||Sb.some(s=>(n.contain||"").includes(s))}function Cb(e){let t=nn(e);for(;Ut(t)&&!Un(t);){if(_a(t))return t;if(Es(t))return null;t=nn(t)}return null}function Sa(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Nb=new Set(["html","body","#document"]);function Un(e){return Nb.has(Kn(e))}function At(e){return gt(e).getComputedStyle(e)}function Is(e){return Nt(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function nn(e){if(Kn(e)==="html")return e;const t=e.assignedSlot||e.parentNode||gc(e)&&e.host||Bt(e);return gc(t)?t.host:t}function xd(e){const t=nn(e);return Un(t)?e.ownerDocument?e.ownerDocument.body:e.body:Ut(t)&&Er(t)?t:xd(t)}function wr(e,t,n){var s;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=xd(e),a=o===((s=e.ownerDocument)==null?void 0:s.body),i=gt(o);if(a){const c=Uo(i);return t.concat(i,i.visualViewport||[],Er(o)?o:[],c&&n?wr(c):[])}return t.concat(o,wr(o,[],n))}function Uo(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function vd(e){const t=At(e);let n=parseFloat(t.width)||0,s=parseFloat(t.height)||0;const o=Ut(e),a=o?e.offsetWidth:n,i=o?e.offsetHeight:s,c=ds(n)!==a||ds(s)!==i;return c&&(n=a,s=i),{width:n,height:s,$:c}}function Ca(e){return Nt(e)?e:e.contextElement}function zn(e){const t=Ca(e);if(!Ut(t))return $t(1);const n=t.getBoundingClientRect(),{width:s,height:o,$:a}=vd(t);let i=(a?ds(n.width):n.width)/s,c=(a?ds(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!c||!Number.isFinite(c))&&(c=1),{x:i,y:c}}const Ab=$t(0);function yd(e){const t=gt(e);return!Sa()||!t.visualViewport?Ab:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Eb(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==gt(e)?!1:t}function xn(e,t,n,s){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),a=Ca(e);let i=$t(1);t&&(s?Nt(s)&&(i=zn(s)):i=zn(e));const c=Eb(a,n,s)?yd(a):$t(0);let l=(o.left+c.x)/i.x,u=(o.top+c.y)/i.y,m=o.width/i.x,d=o.height/i.y;if(a){const x=gt(a),h=s&&Nt(s)?gt(s):s;let v=x,p=Uo(v);for(;p&&s&&h!==v;){const g=zn(p),y=p.getBoundingClientRect(),w=At(p),j=y.left+(p.clientLeft+parseFloat(w.paddingLeft))*g.x,k=y.top+(p.clientTop+parseFloat(w.paddingTop))*g.y;l*=g.x,u*=g.y,m*=g.x,d*=g.y,l+=j,u+=k,v=gt(p),p=Uo(v)}}return ms({width:m,height:d,x:l,y:u})}function Ts(e,t){const n=Is(e).scrollLeft;return t?t.left+n:xn(Bt(e)).left+n}function bd(e,t){const n=e.getBoundingClientRect(),s=n.left+t.scrollLeft-Ts(e,n),o=n.top+t.scrollTop;return{x:s,y:o}}function Ib(e){let{elements:t,rect:n,offsetParent:s,strategy:o}=e;const a=o==="fixed",i=Bt(s),c=t?Es(t.floating):!1;if(s===i||c&&a)return n;let l={scrollLeft:0,scrollTop:0},u=$t(1);const m=$t(0),d=Ut(s);if((d||!d&&!a)&&((Kn(s)!=="body"||Er(i))&&(l=Is(s)),Ut(s))){const h=xn(s);u=zn(s),m.x=h.x+s.clientLeft,m.y=h.y+s.clientTop}const x=i&&!d&&!a?bd(i,l):$t(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-l.scrollLeft*u.x+m.x+x.x,y:n.y*u.y-l.scrollTop*u.y+m.y+x.y}}function Tb(e){return Array.from(e.getClientRects())}function Pb(e){const t=Bt(e),n=Is(e),s=e.ownerDocument.body,o=pt(t.scrollWidth,t.clientWidth,s.scrollWidth,s.clientWidth),a=pt(t.scrollHeight,t.clientHeight,s.scrollHeight,s.clientHeight);let i=-n.scrollLeft+Ts(e);const c=-n.scrollTop;return At(s).direction==="rtl"&&(i+=pt(t.clientWidth,s.clientWidth)-o),{width:o,height:a,x:i,y:c}}const xc=25;function Rb(e,t){const n=gt(e),s=Bt(e),o=n.visualViewport;let a=s.clientWidth,i=s.clientHeight,c=0,l=0;if(o){a=o.width,i=o.height;const m=Sa();(!m||m&&t==="fixed")&&(c=o.offsetLeft,l=o.offsetTop)}const u=Ts(s);if(u<=0){const m=s.ownerDocument,d=m.body,x=getComputedStyle(d),h=m.compatMode==="CSS1Compat"&&parseFloat(x.marginLeft)+parseFloat(x.marginRight)||0,v=Math.abs(s.clientWidth-d.clientWidth-h);v<=xc&&(a-=v)}else u<=xc&&(a+=u);return{width:a,height:i,x:c,y:l}}const Ob=new Set(["absolute","fixed"]);function Mb(e,t){const n=xn(e,!0,t==="fixed"),s=n.top+e.clientTop,o=n.left+e.clientLeft,a=Ut(e)?zn(e):$t(1),i=e.clientWidth*a.x,c=e.clientHeight*a.y,l=o*a.x,u=s*a.y;return{width:i,height:c,x:l,y:u}}function vc(e,t,n){let s;if(t==="viewport")s=Rb(e,n);else if(t==="document")s=Pb(Bt(e));else if(Nt(t))s=Mb(t,n);else{const o=yd(e);s={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return ms(s)}function wd(e,t){const n=nn(e);return n===t||!Nt(n)||Un(n)?!1:At(n).position==="fixed"||wd(n,t)}function Lb(e,t){const n=t.get(e);if(n)return n;let s=wr(e,[],!1).filter(c=>Nt(c)&&Kn(c)!=="body"),o=null;const a=At(e).position==="fixed";let i=a?nn(e):e;for(;Nt(i)&&!Un(i);){const c=At(i),l=_a(i);!l&&c.position==="fixed"&&(o=null),(a?!l&&!o:!l&&c.position==="static"&&!!o&&Ob.has(o.position)||Er(i)&&!l&&wd(e,i))?s=s.filter(m=>m!==i):o=c,i=nn(i)}return t.set(e,s),s}function Db(e){let{element:t,boundary:n,rootBoundary:s,strategy:o}=e;const i=[...n==="clippingAncestors"?Es(t)?[]:Lb(t,this._c):[].concat(n),s],c=i[0],l=i.reduce((u,m)=>{const d=vc(t,m,o);return u.top=pt(d.top,u.top),u.right=tn(d.right,u.right),u.bottom=tn(d.bottom,u.bottom),u.left=pt(d.left,u.left),u},vc(t,c,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function zb(e){const{width:t,height:n}=vd(e);return{width:t,height:n}}function $b(e,t,n){const s=Ut(t),o=Bt(t),a=n==="fixed",i=xn(e,!0,a,t);let c={scrollLeft:0,scrollTop:0};const l=$t(0);function u(){l.x=Ts(o)}if(s||!s&&!a)if((Kn(t)!=="body"||Er(o))&&(c=Is(t)),s){const h=xn(t,!0,a,t);l.x=h.x+t.clientLeft,l.y=h.y+t.clientTop}else o&&u();a&&!s&&o&&u();const m=o&&!s&&!a?bd(o,c):$t(0),d=i.left+c.scrollLeft-l.x-m.x,x=i.top+c.scrollTop-l.y-m.y;return{x:d,y:x,width:i.width,height:i.height}}function go(e){return At(e).position==="static"}function yc(e,t){if(!Ut(e)||At(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Bt(e)===n&&(n=n.ownerDocument.body),n}function kd(e,t){const n=gt(e);if(Es(e))return n;if(!Ut(e)){let o=nn(e);for(;o&&!Un(o);){if(Nt(o)&&!go(o))return o;o=nn(o)}return n}let s=yc(e,t);for(;s&&wb(s)&&go(s);)s=yc(s,t);return s&&Un(s)&&go(s)&&!_a(s)?n:s||Cb(e)||n}const Fb=async function(e){const t=this.getOffsetParent||kd,n=this.getDimensions,s=await n(e.floating);return{reference:$b(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}};function Ub(e){return At(e).direction==="rtl"}const Bb={convertOffsetParentRelativeRectToViewportRelativeRect:Ib,getDocumentElement:Bt,getClippingRect:Db,getOffsetParent:kd,getElementRects:Fb,getClientRects:Tb,getDimensions:zb,getScale:zn,isElement:Nt,isRTL:Ub};function jd(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Vb(e,t){let n=null,s;const o=Bt(e);function a(){var c;clearTimeout(s),(c=n)==null||c.disconnect(),n=null}function i(c,l){c===void 0&&(c=!1),l===void 0&&(l=1),a();const u=e.getBoundingClientRect(),{left:m,top:d,width:x,height:h}=u;if(c||t(),!x||!h)return;const v=$r(d),p=$r(o.clientWidth-(m+x)),g=$r(o.clientHeight-(d+h)),y=$r(m),j={rootMargin:-v+"px "+-p+"px "+-g+"px "+-y+"px",threshold:pt(0,tn(1,l))||1};let k=!0;function _(S){const A=S[0].intersectionRatio;if(A!==l){if(!k)return i();A?i(!1,A):s=setTimeout(()=>{i(!1,1e-7)},1e3)}A===1&&!jd(u,e.getBoundingClientRect())&&i(),k=!1}try{n=new IntersectionObserver(_,{...j,root:o.ownerDocument})}catch{n=new IntersectionObserver(_,j)}n.observe(e)}return i(!0),a}function Wb(e,t,n,s){s===void 0&&(s={});const{ancestorScroll:o=!0,ancestorResize:a=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:l=!1}=s,u=Ca(e),m=o||a?[...u?wr(u):[],...wr(t)]:[];m.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),a&&y.addEventListener("resize",n)});const d=u&&c?Vb(u,n):null;let x=-1,h=null;i&&(h=new ResizeObserver(y=>{let[w]=y;w&&w.target===u&&h&&(h.unobserve(t),cancelAnimationFrame(x),x=requestAnimationFrame(()=>{var j;(j=h)==null||j.observe(t)})),n()}),u&&!l&&h.observe(u),h.observe(t));let v,p=l?xn(e):null;l&&g();function g(){const y=xn(e);p&&!jd(p,y)&&n(),p=y,v=requestAnimationFrame(g)}return n(),()=>{var y;m.forEach(w=>{o&&w.removeEventListener("scroll",n),a&&w.removeEventListener("resize",n)}),d?.(),(y=h)==null||y.disconnect(),h=null,l&&cancelAnimationFrame(v)}}const qb=hb,Hb=gb,Zb=mb,Gb=vb,Yb=fb,bc=ub,Kb=xb,Qb=(e,t,n)=>{const s=new Map,o={platform:Bb,...n},a={...o.platform,_c:s};return db(e,t,{...o,platform:a})};var Jb=typeof document<"u",Xb=function(){},Jr=Jb?b.useLayoutEffect:Xb;function fs(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,s,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(s=n;s--!==0;)if(!fs(e[s],t[s]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(s=n;s--!==0;)if(!{}.hasOwnProperty.call(t,o[s]))return!1;for(s=n;s--!==0;){const a=o[s];if(!(a==="_owner"&&e.$$typeof)&&!fs(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function _d(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function wc(e,t){const n=_d(e);return Math.round(t*n)/n}function xo(e){const t=f.useRef(e);return Jr(()=>{t.current=e}),t}function ew(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:s=[],platform:o,elements:{reference:a,floating:i}={},transform:c=!0,whileElementsMounted:l,open:u}=e,[m,d]=f.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[x,h]=f.useState(s);fs(x,s)||h(s);const[v,p]=f.useState(null),[g,y]=f.useState(null),w=f.useCallback(D=>{D!==S.current&&(S.current=D,p(D))},[]),j=f.useCallback(D=>{D!==A.current&&(A.current=D,y(D))},[]),k=a||v,_=i||g,S=f.useRef(null),A=f.useRef(null),E=f.useRef(m),I=l!=null,T=xo(l),U=xo(o),L=xo(u),B=f.useCallback(()=>{if(!S.current||!A.current)return;const D={placement:t,strategy:n,middleware:x};U.current&&(D.platform=U.current),Qb(S.current,A.current,D).then(se=>{const le={...se,isPositioned:L.current!==!1};z.current&&!fs(E.current,le)&&(E.current=le,ws.flushSync(()=>{d(le)}))})},[x,t,n,U,L]);Jr(()=>{u===!1&&E.current.isPositioned&&(E.current.isPositioned=!1,d(D=>({...D,isPositioned:!1})))},[u]);const z=f.useRef(!1);Jr(()=>(z.current=!0,()=>{z.current=!1}),[]),Jr(()=>{if(k&&(S.current=k),_&&(A.current=_),k&&_){if(T.current)return T.current(k,_,B);B()}},[k,_,B,T,I]);const K=f.useMemo(()=>({reference:S,floating:A,setReference:w,setFloating:j}),[w,j]),V=f.useMemo(()=>({reference:k,floating:_}),[k,_]),G=f.useMemo(()=>{const D={position:n,left:0,top:0};if(!V.floating)return D;const se=wc(V.floating,m.x),le=wc(V.floating,m.y);return c?{...D,transform:"translate("+se+"px, "+le+"px)",..._d(V.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:se,top:le}},[n,c,V.floating,m.x,m.y]);return f.useMemo(()=>({...m,update:B,refs:K,elements:V,floatingStyles:G}),[m,B,K,V,G])}const tw=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:s,padding:o}=typeof e=="function"?e(n):e;return s&&t(s)?s.current!=null?bc({element:s.current,padding:o}).fn(n):{}:s?bc({element:s,padding:o}).fn(n):{}}}},nw=(e,t)=>({...qb(e),options:[e,t]}),rw=(e,t)=>({...Hb(e),options:[e,t]}),sw=(e,t)=>({...Kb(e),options:[e,t]}),ow=(e,t)=>({...Zb(e),options:[e,t]}),aw=(e,t)=>({...Gb(e),options:[e,t]}),iw=(e,t)=>({...Yb(e),options:[e,t]}),cw=(e,t)=>({...tw(e),options:[e,t]});var lw="Arrow",Sd=f.forwardRef((e,t)=>{const{children:n,width:s=10,height:o=5,...a}=e;return r.jsx(ge.svg,{...a,ref:t,width:s,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:r.jsx("polygon",{points:"0,0 30,0 15,10"})})});Sd.displayName=lw;var dw=Sd;function uw(e){const[t,n]=f.useState(void 0);return Ye(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const s=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,u=Array.isArray(l)?l[0]:l;i=u.inlineSize,c=u.blockSize}else i=e.offsetWidth,c=e.offsetHeight;n({width:i,height:c})});return s.observe(e,{box:"border-box"}),()=>s.unobserve(e)}else n(void 0)},[e]),t}var Na="Popper",[Cd,Nd]=an(Na),[mw,Ad]=Cd(Na),Ed=e=>{const{__scopePopper:t,children:n}=e,[s,o]=f.useState(null);return r.jsx(mw,{scope:t,anchor:s,onAnchorChange:o,children:n})};Ed.displayName=Na;var Id="PopperAnchor",Td=f.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:s,...o}=e,a=Ad(Id,n),i=f.useRef(null),c=Se(t,i),l=f.useRef(null);return f.useEffect(()=>{const u=l.current;l.current=s?.current||i.current,u!==l.current&&a.onAnchorChange(l.current)}),s?null:r.jsx(ge.div,{...o,ref:c})});Td.displayName=Id;var Aa="PopperContent",[fw,pw]=Cd(Aa),Pd=f.forwardRef((e,t)=>{const{__scopePopper:n,side:s="bottom",sideOffset:o=0,align:a="center",alignOffset:i=0,arrowPadding:c=0,avoidCollisions:l=!0,collisionBoundary:u=[],collisionPadding:m=0,sticky:d="partial",hideWhenDetached:x=!1,updatePositionStrategy:h="optimized",onPlaced:v,...p}=e,g=Ad(Aa,n),[y,w]=f.useState(null),j=Se(t,P=>w(P)),[k,_]=f.useState(null),S=uw(k),A=S?.width??0,E=S?.height??0,I=s+(a!=="center"?"-"+a:""),T=typeof m=="number"?m:{top:0,right:0,bottom:0,left:0,...m},U=Array.isArray(u)?u:[u],L=U.length>0,B={padding:T,boundary:U.filter(gw),altBoundary:L},{refs:z,floatingStyles:K,placement:V,isPositioned:G,middlewareData:D}=ew({strategy:"fixed",placement:I,whileElementsMounted:(...P)=>Wb(...P,{animationFrame:h==="always"}),elements:{reference:g.anchor},middleware:[nw({mainAxis:o+E,alignmentAxis:i}),l&&rw({mainAxis:!0,crossAxis:!1,limiter:d==="partial"?sw():void 0,...B}),l&&ow({...B}),aw({...B,apply:({elements:P,rects:H,availableWidth:de,availableHeight:W})=>{const{width:re,height:ie}=H.reference,ye=P.floating.style;ye.setProperty("--radix-popper-available-width",`${de}px`),ye.setProperty("--radix-popper-available-height",`${W}px`),ye.setProperty("--radix-popper-anchor-width",`${re}px`),ye.setProperty("--radix-popper-anchor-height",`${ie}px`)}}),k&&cw({element:k,padding:c}),xw({arrowWidth:A,arrowHeight:E}),x&&iw({strategy:"referenceHidden",...B})]}),[se,le]=Md(V),N=en(v);Ye(()=>{G&&N?.()},[G,N]);const R=D.arrow?.x,F=D.arrow?.y,Q=D.arrow?.centerOffset!==0,[Y,ce]=f.useState();return Ye(()=>{y&&ce(window.getComputedStyle(y).zIndex)},[y]),r.jsx("div",{ref:z.setFloating,"data-radix-popper-content-wrapper":"",style:{...K,transform:G?K.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Y,"--radix-popper-transform-origin":[D.transformOrigin?.x,D.transformOrigin?.y].join(" "),...D.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:r.jsx(fw,{scope:n,placedSide:se,onArrowChange:_,arrowX:R,arrowY:F,shouldHideArrow:Q,children:r.jsx(ge.div,{"data-side":se,"data-align":le,...p,ref:j,style:{...p.style,animation:G?void 0:"none"}})})})});Pd.displayName=Aa;var Rd="PopperArrow",hw={top:"bottom",right:"left",bottom:"top",left:"right"},Od=f.forwardRef(function(t,n){const{__scopePopper:s,...o}=t,a=pw(Rd,s),i=hw[a.placedSide];return r.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:r.jsx(dw,{...o,ref:n,style:{...o.style,display:"block"}})})});Od.displayName=Rd;function gw(e){return e!==null}var xw=e=>({name:"transformOrigin",options:e,fn(t){const{placement:n,rects:s,middlewareData:o}=t,i=o.arrow?.centerOffset!==0,c=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[u,m]=Md(n),d={start:"0%",center:"50%",end:"100%"}[m],x=(o.arrow?.x??0)+c/2,h=(o.arrow?.y??0)+l/2;let v="",p="";return u==="bottom"?(v=i?d:`${x}px`,p=`${-l}px`):u==="top"?(v=i?d:`${x}px`,p=`${s.floating.height+l}px`):u==="right"?(v=`${-l}px`,p=i?d:`${h}px`):u==="left"&&(v=`${s.floating.width+l}px`,p=i?d:`${h}px`),{data:{x:v,y:p}}}});function Md(e){const[t,n="center"]=e.split("-");return[t,n]}var vw=Ed,yw=Td,bw=Pd,ww=Od,kw="Portal",Ea=f.forwardRef((e,t)=>{const{container:n,...s}=e,[o,a]=f.useState(!1);Ye(()=>a(!0),[]);const i=n||o&&globalThis?.document?.body;return i?ta.createPortal(r.jsx(ge.div,{...s,ref:t}),i):null});Ea.displayName=kw;function jw(e){const t=_w(e),n=f.forwardRef((s,o)=>{const{children:a,...i}=s,c=f.Children.toArray(a),l=c.find(Cw);if(l){const u=l.props.children,m=c.map(d=>d===l?f.Children.count(u)>1?f.Children.only(null):f.isValidElement(u)?u.props.children:null:d);return r.jsx(t,{...i,ref:o,children:f.isValidElement(u)?f.cloneElement(u,void 0,m):null})}return r.jsx(t,{...i,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}function _w(e){const t=f.forwardRef((n,s)=>{const{children:o,...a}=n;if(f.isValidElement(o)){const i=Aw(o),c=Nw(a,o.props);return o.type!==f.Fragment&&(c.ref=s?Hn(s,i):i),f.cloneElement(o,c)}return f.Children.count(o)>1?f.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Sw=Symbol("radix.slottable");function Cw(e){return f.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Sw}function Nw(e,t){const n={...t};for(const s in t){const o=e[s],a=t[s];/^on[A-Z]/.test(s)?o&&a?n[s]=(...c)=>{const l=a(...c);return o(...c),l}:o&&(n[s]=o):s==="style"?n[s]={...o,...a}:s==="className"&&(n[s]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function Aw(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 Ew=f[" useInsertionEffect ".trim().toString()]||Ye;function rn({prop:e,defaultProp:t,onChange:n=()=>{},caller:s}){const[o,a,i]=Iw({defaultProp:t,onChange:n}),c=e!==void 0,l=c?e:o;{const m=f.useRef(e!==void 0);f.useEffect(()=>{const d=m.current;d!==c&&console.warn(`${s} is changing from ${d?"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.`),m.current=c},[c,s])}const u=f.useCallback(m=>{if(c){const d=Tw(m)?m(e):m;d!==e&&i.current?.(d)}else a(m)},[c,e,a,i]);return[l,u]}function Iw({defaultProp:e,onChange:t}){const[n,s]=f.useState(e),o=f.useRef(n),a=f.useRef(t);return Ew(()=>{a.current=t},[t]),f.useEffect(()=>{o.current!==n&&(a.current?.(n),o.current=n)},[n,o]),[n,s,a]}function Tw(e){return typeof e=="function"}function Pw(e){const t=f.useRef({value:e,previous:e});return f.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Ld=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"}),Rw="VisuallyHidden",Ow=f.forwardRef((e,t)=>r.jsx(ge.span,{...e,ref:t,style:{...Ld,...e.style}}));Ow.displayName=Rw;var Mw=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Rn=new WeakMap,Fr=new WeakMap,Ur={},vo=0,Dd=function(e){return e&&(e.host||Dd(e.parentNode))},Lw=function(e,t){return t.map(function(n){if(e.contains(n))return n;var s=Dd(n);return s&&e.contains(s)?s:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},Dw=function(e,t,n,s){var o=Lw(t,Array.isArray(e)?e:[e]);Ur[n]||(Ur[n]=new WeakMap);var a=Ur[n],i=[],c=new Set,l=new Set(o),u=function(d){!d||c.has(d)||(c.add(d),u(d.parentNode))};o.forEach(u);var m=function(d){!d||l.has(d)||Array.prototype.forEach.call(d.children,function(x){if(c.has(x))m(x);else try{var h=x.getAttribute(s),v=h!==null&&h!=="false",p=(Rn.get(x)||0)+1,g=(a.get(x)||0)+1;Rn.set(x,p),a.set(x,g),i.push(x),p===1&&v&&Fr.set(x,!0),g===1&&x.setAttribute(n,"true"),v||x.setAttribute(s,"true")}catch(y){console.error("aria-hidden: cannot operate on ",x,y)}})};return m(t),c.clear(),vo++,function(){i.forEach(function(d){var x=Rn.get(d)-1,h=a.get(d)-1;Rn.set(d,x),a.set(d,h),x||(Fr.has(d)||d.removeAttribute(s),Fr.delete(d)),h||d.removeAttribute(n)}),vo--,vo||(Rn=new WeakMap,Rn=new WeakMap,Fr=new WeakMap,Ur={})}},zd=function(e,t,n){n===void 0&&(n="data-aria-hidden");var s=Array.from(Array.isArray(e)?e:[e]),o=Mw(e);return o?(s.push.apply(s,Array.from(o.querySelectorAll("[aria-live], script"))),Dw(s,o,n,"aria-hidden")):function(){return null}},Lt=function(){return Lt=Object.assign||function(t){for(var n,s=1,o=arguments.length;s<o;s++){n=arguments[s];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},Lt.apply(this,arguments)};function $d(e,t){var n={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,s=Object.getOwnPropertySymbols(e);o<s.length;o++)t.indexOf(s[o])<0&&Object.prototype.propertyIsEnumerable.call(e,s[o])&&(n[s[o]]=e[s[o]]);return n}function zw(e,t,n){if(n||arguments.length===2)for(var s=0,o=t.length,a;s<o;s++)(a||!(s in t))&&(a||(a=Array.prototype.slice.call(t,0,s)),a[s]=t[s]);return e.concat(a||Array.prototype.slice.call(t))}var Xr="right-scroll-bar-position",es="width-before-scroll-bar",$w="with-scroll-bars-hidden",Fw="--removed-body-scroll-bar-size";function yo(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Uw(e,t){var n=b.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(s){var o=n.value;o!==s&&(n.value=s,n.callback(s,o))}}}})[0];return n.callback=t,n.facade}var Bw=typeof window<"u"?f.useLayoutEffect:f.useEffect,kc=new WeakMap;function Vw(e,t){var n=Uw(null,function(s){return e.forEach(function(o){return yo(o,s)})});return Bw(function(){var s=kc.get(n);if(s){var o=new Set(s),a=new Set(e),i=n.current;o.forEach(function(c){a.has(c)||yo(c,null)}),a.forEach(function(c){o.has(c)||yo(c,i)})}kc.set(n,e)},[e]),n}function Ww(e){return e}function qw(e,t){t===void 0&&(t=Ww);var n=[],s=!1,o={read:function(){if(s)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,s);return n.push(i),function(){n=n.filter(function(c){return c!==i})}},assignSyncMedium:function(a){for(s=!0;n.length;){var i=n;n=[],i.forEach(a)}n={push:function(c){return a(c)},filter:function(){return n}}},assignMedium:function(a){s=!0;var i=[];if(n.length){var c=n;n=[],c.forEach(a),i=n}var l=function(){var m=i;i=[],m.forEach(a)},u=function(){return Promise.resolve().then(l)};u(),n={push:function(m){i.push(m),u()},filter:function(m){return i=i.filter(m),n}}}};return o}function Hw(e){e===void 0&&(e={});var t=qw(null);return t.options=Lt({async:!0,ssr:!1},e),t}var Fd=function(e){var t=e.sideCar,n=$d(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var s=t.read();if(!s)throw new Error("Sidecar medium not found");return f.createElement(s,Lt({},n))};Fd.isSideCarExport=!0;function Zw(e,t){return e.useMedium(t),Fd}var Ud=Hw(),bo=function(){},Ps=f.forwardRef(function(e,t){var n=f.useRef(null),s=f.useState({onScrollCapture:bo,onWheelCapture:bo,onTouchMoveCapture:bo}),o=s[0],a=s[1],i=e.forwardProps,c=e.children,l=e.className,u=e.removeScrollBar,m=e.enabled,d=e.shards,x=e.sideCar,h=e.noRelative,v=e.noIsolation,p=e.inert,g=e.allowPinchZoom,y=e.as,w=y===void 0?"div":y,j=e.gapMode,k=$d(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),_=x,S=Vw([n,t]),A=Lt(Lt({},k),o);return f.createElement(f.Fragment,null,m&&f.createElement(_,{sideCar:Ud,removeScrollBar:u,shards:d,noRelative:h,noIsolation:v,inert:p,setCallbacks:a,allowPinchZoom:!!g,lockRef:n,gapMode:j}),i?f.cloneElement(f.Children.only(c),Lt(Lt({},A),{ref:S})):f.createElement(w,Lt({},A,{className:l,ref:S}),c))});Ps.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Ps.classNames={fullWidth:es,zeroRight:Xr};var Gw=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Yw(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Gw();return t&&e.setAttribute("nonce",t),e}function Kw(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Qw(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Jw=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Yw())&&(Kw(t,n),Qw(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Xw=function(){var e=Jw();return function(t,n){f.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Bd=function(){var e=Xw(),t=function(n){var s=n.styles,o=n.dynamic;return e(s,o),null};return t},ek={left:0,top:0,right:0,gap:0},wo=function(e){return parseInt(e||"",10)||0},tk=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],s=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[wo(n),wo(s),wo(o)]},nk=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return ek;var t=tk(e),n=document.documentElement.clientWidth,s=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,s-n+t[2]-t[0])}},rk=Bd(),$n="data-scroll-locked",sk=function(e,t,n,s){var o=e.left,a=e.top,i=e.right,c=e.gap;return n===void 0&&(n="margin"),`
40
+ .`.concat($w,` {
41
+ overflow: hidden `).concat(s,`;
42
+ padding-right: `).concat(c,"px ").concat(s,`;
43
+ }
44
+ body[`).concat($n,`] {
45
+ overflow: hidden `).concat(s,`;
46
+ overscroll-behavior: contain;
47
+ `).concat([t&&"position: relative ".concat(s,";"),n==="margin"&&`
48
+ padding-left: `.concat(o,`px;
49
+ padding-top: `).concat(a,`px;
50
+ padding-right: `).concat(i,`px;
51
+ margin-left:0;
52
+ margin-top:0;
53
+ margin-right: `).concat(c,"px ").concat(s,`;
54
+ `),n==="padding"&&"padding-right: ".concat(c,"px ").concat(s,";")].filter(Boolean).join(""),`
55
+ }
56
+
57
+ .`).concat(Xr,` {
58
+ right: `).concat(c,"px ").concat(s,`;
59
+ }
60
+
61
+ .`).concat(es,` {
62
+ margin-right: `).concat(c,"px ").concat(s,`;
63
+ }
64
+
65
+ .`).concat(Xr," .").concat(Xr,` {
66
+ right: 0 `).concat(s,`;
67
+ }
68
+
69
+ .`).concat(es," .").concat(es,` {
70
+ margin-right: 0 `).concat(s,`;
71
+ }
72
+
73
+ body[`).concat($n,`] {
74
+ `).concat(Fw,": ").concat(c,`px;
75
+ }
76
+ `)},jc=function(){var e=parseInt(document.body.getAttribute($n)||"0",10);return isFinite(e)?e:0},ok=function(){f.useEffect(function(){return document.body.setAttribute($n,(jc()+1).toString()),function(){var e=jc()-1;e<=0?document.body.removeAttribute($n):document.body.setAttribute($n,e.toString())}},[])},ak=function(e){var t=e.noRelative,n=e.noImportant,s=e.gapMode,o=s===void 0?"margin":s;ok();var a=f.useMemo(function(){return nk(o)},[o]);return f.createElement(rk,{styles:sk(a,!t,o,n?"":"!important")})},Bo=!1;if(typeof window<"u")try{var Br=Object.defineProperty({},"passive",{get:function(){return Bo=!0,!0}});window.addEventListener("test",Br,Br),window.removeEventListener("test",Br,Br)}catch{Bo=!1}var On=Bo?{passive:!1}:!1,ik=function(e){return e.tagName==="TEXTAREA"},Vd=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!ik(e)&&n[t]==="visible")},ck=function(e){return Vd(e,"overflowY")},lk=function(e){return Vd(e,"overflowX")},_c=function(e,t){var n=t.ownerDocument,s=t;do{typeof ShadowRoot<"u"&&s instanceof ShadowRoot&&(s=s.host);var o=Wd(e,s);if(o){var a=qd(e,s),i=a[1],c=a[2];if(i>c)return!0}s=s.parentNode}while(s&&s!==n.body);return!1},dk=function(e){var t=e.scrollTop,n=e.scrollHeight,s=e.clientHeight;return[t,n,s]},uk=function(e){var t=e.scrollLeft,n=e.scrollWidth,s=e.clientWidth;return[t,n,s]},Wd=function(e,t){return e==="v"?ck(t):lk(t)},qd=function(e,t){return e==="v"?dk(t):uk(t)},mk=function(e,t){return e==="h"&&t==="rtl"?-1:1},fk=function(e,t,n,s,o){var a=mk(e,window.getComputedStyle(t).direction),i=a*s,c=n.target,l=t.contains(c),u=!1,m=i>0,d=0,x=0;do{if(!c)break;var h=qd(e,c),v=h[0],p=h[1],g=h[2],y=p-g-a*v;(v||y)&&Wd(e,c)&&(d+=y,x+=v);var w=c.parentNode;c=w&&w.nodeType===Node.DOCUMENT_FRAGMENT_NODE?w.host:w}while(!l&&c!==document.body||l&&(t.contains(c)||t===c));return(m&&Math.abs(d)<1||!m&&Math.abs(x)<1)&&(u=!0),u},Vr=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Sc=function(e){return[e.deltaX,e.deltaY]},Cc=function(e){return e&&"current"in e?e.current:e},pk=function(e,t){return e[0]===t[0]&&e[1]===t[1]},hk=function(e){return`
77
+ .block-interactivity-`.concat(e,` {pointer-events: none;}
78
+ .allow-interactivity-`).concat(e,` {pointer-events: all;}
79
+ `)},gk=0,Mn=[];function xk(e){var t=f.useRef([]),n=f.useRef([0,0]),s=f.useRef(),o=f.useState(gk++)[0],a=f.useState(Bd)[0],i=f.useRef(e);f.useEffect(function(){i.current=e},[e]),f.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var p=zw([e.lockRef.current],(e.shards||[]).map(Cc),!0).filter(Boolean);return p.forEach(function(g){return g.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),p.forEach(function(g){return g.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var c=f.useCallback(function(p,g){if("touches"in p&&p.touches.length===2||p.type==="wheel"&&p.ctrlKey)return!i.current.allowPinchZoom;var y=Vr(p),w=n.current,j="deltaX"in p?p.deltaX:w[0]-y[0],k="deltaY"in p?p.deltaY:w[1]-y[1],_,S=p.target,A=Math.abs(j)>Math.abs(k)?"h":"v";if("touches"in p&&A==="h"&&S.type==="range")return!1;var E=window.getSelection(),I=E&&E.anchorNode,T=I?I===S||I.contains(S):!1;if(T)return!1;var U=_c(A,S);if(!U)return!0;if(U?_=A:(_=A==="v"?"h":"v",U=_c(A,S)),!U)return!1;if(!s.current&&"changedTouches"in p&&(j||k)&&(s.current=_),!_)return!0;var L=s.current||_;return fk(L,g,p,L==="h"?j:k)},[]),l=f.useCallback(function(p){var g=p;if(!(!Mn.length||Mn[Mn.length-1]!==a)){var y="deltaY"in g?Sc(g):Vr(g),w=t.current.filter(function(_){return _.name===g.type&&(_.target===g.target||g.target===_.shadowParent)&&pk(_.delta,y)})[0];if(w&&w.should){g.cancelable&&g.preventDefault();return}if(!w){var j=(i.current.shards||[]).map(Cc).filter(Boolean).filter(function(_){return _.contains(g.target)}),k=j.length>0?c(g,j[0]):!i.current.noIsolation;k&&g.cancelable&&g.preventDefault()}}},[]),u=f.useCallback(function(p,g,y,w){var j={name:p,delta:g,target:y,should:w,shadowParent:vk(y)};t.current.push(j),setTimeout(function(){t.current=t.current.filter(function(k){return k!==j})},1)},[]),m=f.useCallback(function(p){n.current=Vr(p),s.current=void 0},[]),d=f.useCallback(function(p){u(p.type,Sc(p),p.target,c(p,e.lockRef.current))},[]),x=f.useCallback(function(p){u(p.type,Vr(p),p.target,c(p,e.lockRef.current))},[]);f.useEffect(function(){return Mn.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:x}),document.addEventListener("wheel",l,On),document.addEventListener("touchmove",l,On),document.addEventListener("touchstart",m,On),function(){Mn=Mn.filter(function(p){return p!==a}),document.removeEventListener("wheel",l,On),document.removeEventListener("touchmove",l,On),document.removeEventListener("touchstart",m,On)}},[]);var h=e.removeScrollBar,v=e.inert;return f.createElement(f.Fragment,null,v?f.createElement(a,{styles:hk(o)}):null,h?f.createElement(ak,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function vk(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const yk=Zw(Ud,xk);var Ia=f.forwardRef(function(e,t){return f.createElement(Ps,Lt({},e,{ref:t,sideCar:yk}))});Ia.classNames=Ps.classNames;var bk=[" ","Enter","ArrowUp","ArrowDown"],wk=[" ","Enter"],vn="Select",[Rs,Os,kk]=va(vn),[Qn]=an(vn,[kk,Nd]),Ms=Nd(),[jk,cn]=Qn(vn),[_k,Sk]=Qn(vn),Hd=e=>{const{__scopeSelect:t,children:n,open:s,defaultOpen:o,onOpenChange:a,value:i,defaultValue:c,onValueChange:l,dir:u,name:m,autoComplete:d,disabled:x,required:h,form:v}=e,p=Ms(t),[g,y]=f.useState(null),[w,j]=f.useState(null),[k,_]=f.useState(!1),S=Ns(u),[A,E]=rn({prop:s,defaultProp:o??!1,onChange:a,caller:vn}),[I,T]=rn({prop:i,defaultProp:c,onChange:l,caller:vn}),U=f.useRef(null),L=g?v||!!g.closest("form"):!0,[B,z]=f.useState(new Set),K=Array.from(B).map(V=>V.props.value).join(";");return r.jsx(vw,{...p,children:r.jsxs(jk,{required:h,scope:t,trigger:g,onTriggerChange:y,valueNode:w,onValueNodeChange:j,valueNodeHasChildren:k,onValueNodeHasChildrenChange:_,contentId:zt(),value:I,onValueChange:T,open:A,onOpenChange:E,dir:S,triggerPointerDownPosRef:U,disabled:x,children:[r.jsx(Rs.Provider,{scope:t,children:r.jsx(_k,{scope:e.__scopeSelect,onNativeOptionAdd:f.useCallback(V=>{z(G=>new Set(G).add(V))},[]),onNativeOptionRemove:f.useCallback(V=>{z(G=>{const D=new Set(G);return D.delete(V),D})},[]),children:n})}),L?r.jsxs(mu,{"aria-hidden":!0,required:h,tabIndex:-1,name:m,autoComplete:d,value:I,onChange:V=>T(V.target.value),disabled:x,form:v,children:[I===void 0?r.jsx("option",{value:""}):null,Array.from(B)]},K):null]})})};Hd.displayName=vn;var Zd="SelectTrigger",Gd=f.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:s=!1,...o}=e,a=Ms(n),i=cn(Zd,n),c=i.disabled||s,l=Se(t,i.onTriggerChange),u=Os(n),m=f.useRef("touch"),[d,x,h]=pu(p=>{const g=u().filter(j=>!j.disabled),y=g.find(j=>j.value===i.value),w=hu(g,p,y);w!==void 0&&i.onValueChange(w.value)}),v=p=>{c||(i.onOpenChange(!0),h()),p&&(i.triggerPointerDownPosRef.current={x:Math.round(p.pageX),y:Math.round(p.pageY)})};return r.jsx(yw,{asChild:!0,...a,children:r.jsx(ge.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":fu(i.value)?"":void 0,...o,ref:l,onClick:ve(o.onClick,p=>{p.currentTarget.focus(),m.current!=="mouse"&&v(p)}),onPointerDown:ve(o.onPointerDown,p=>{m.current=p.pointerType;const g=p.target;g.hasPointerCapture(p.pointerId)&&g.releasePointerCapture(p.pointerId),p.button===0&&p.ctrlKey===!1&&p.pointerType==="mouse"&&(v(p),p.preventDefault())}),onKeyDown:ve(o.onKeyDown,p=>{const g=d.current!=="";!(p.ctrlKey||p.altKey||p.metaKey)&&p.key.length===1&&x(p.key),!(g&&p.key===" ")&&bk.includes(p.key)&&(v(),p.preventDefault())})})})});Gd.displayName=Zd;var Yd="SelectValue",Kd=f.forwardRef((e,t)=>{const{__scopeSelect:n,className:s,style:o,children:a,placeholder:i="",...c}=e,l=cn(Yd,n),{onValueNodeHasChildrenChange:u}=l,m=a!==void 0,d=Se(t,l.onValueNodeChange);return Ye(()=>{u(m)},[u,m]),r.jsx(ge.span,{...c,ref:d,style:{pointerEvents:"none"},children:fu(l.value)?r.jsx(r.Fragment,{children:i}):a})});Kd.displayName=Yd;var Ck="SelectIcon",Qd=f.forwardRef((e,t)=>{const{__scopeSelect:n,children:s,...o}=e;return r.jsx(ge.span,{"aria-hidden":!0,...o,ref:t,children:s||"▼"})});Qd.displayName=Ck;var Nk="SelectPortal",Jd=e=>r.jsx(Ea,{asChild:!0,...e});Jd.displayName=Nk;var yn="SelectContent",Xd=f.forwardRef((e,t)=>{const n=cn(yn,e.__scopeSelect),[s,o]=f.useState();if(Ye(()=>{o(new DocumentFragment)},[]),!n.open){const a=s;return a?ws.createPortal(r.jsx(eu,{scope:e.__scopeSelect,children:r.jsx(Rs.Slot,{scope:e.__scopeSelect,children:r.jsx("div",{children:e.children})})}),a):null}return r.jsx(tu,{...e,ref:t})});Xd.displayName=yn;var St=10,[eu,ln]=Qn(yn),Ak="SelectContentImpl",Ek=jw("SelectContent.RemoveScroll"),tu=f.forwardRef((e,t)=>{const{__scopeSelect:n,position:s="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:a,onPointerDownOutside:i,side:c,sideOffset:l,align:u,alignOffset:m,arrowPadding:d,collisionBoundary:x,collisionPadding:h,sticky:v,hideWhenDetached:p,avoidCollisions:g,...y}=e,w=cn(yn,n),[j,k]=f.useState(null),[_,S]=f.useState(null),A=Se(t,P=>k(P)),[E,I]=f.useState(null),[T,U]=f.useState(null),L=Os(n),[B,z]=f.useState(!1),K=f.useRef(!1);f.useEffect(()=>{if(j)return zd(j)},[j]),md();const V=f.useCallback(P=>{const[H,...de]=L().map(ie=>ie.ref.current),[W]=de.slice(-1),re=document.activeElement;for(const ie of P)if(ie===re||(ie?.scrollIntoView({block:"nearest"}),ie===H&&_&&(_.scrollTop=0),ie===W&&_&&(_.scrollTop=_.scrollHeight),ie?.focus(),document.activeElement!==re))return},[L,_]),G=f.useCallback(()=>V([E,j]),[V,E,j]);f.useEffect(()=>{B&&G()},[B,G]);const{onOpenChange:D,triggerPointerDownPosRef:se}=w;f.useEffect(()=>{if(j){let P={x:0,y:0};const H=W=>{P={x:Math.abs(Math.round(W.pageX)-(se.current?.x??0)),y:Math.abs(Math.round(W.pageY)-(se.current?.y??0))}},de=W=>{P.x<=10&&P.y<=10?W.preventDefault():j.contains(W.target)||D(!1),document.removeEventListener("pointermove",H),se.current=null};return se.current!==null&&(document.addEventListener("pointermove",H),document.addEventListener("pointerup",de,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",H),document.removeEventListener("pointerup",de,{capture:!0})}}},[j,D,se]),f.useEffect(()=>{const P=()=>D(!1);return window.addEventListener("blur",P),window.addEventListener("resize",P),()=>{window.removeEventListener("blur",P),window.removeEventListener("resize",P)}},[D]);const[le,N]=pu(P=>{const H=L().filter(re=>!re.disabled),de=H.find(re=>re.ref.current===document.activeElement),W=hu(H,P,de);W&&setTimeout(()=>W.ref.current.focus())}),R=f.useCallback((P,H,de)=>{const W=!K.current&&!de;(w.value!==void 0&&w.value===H||W)&&(I(P),W&&(K.current=!0))},[w.value]),F=f.useCallback(()=>j?.focus(),[j]),Q=f.useCallback((P,H,de)=>{const W=!K.current&&!de;(w.value!==void 0&&w.value===H||W)&&U(P)},[w.value]),Y=s==="popper"?Vo:nu,ce=Y===Vo?{side:c,sideOffset:l,align:u,alignOffset:m,arrowPadding:d,collisionBoundary:x,collisionPadding:h,sticky:v,hideWhenDetached:p,avoidCollisions:g}:{};return r.jsx(eu,{scope:n,content:j,viewport:_,onViewportChange:S,itemRefCallback:R,selectedItem:E,onItemLeave:F,itemTextRefCallback:Q,focusSelectedItem:G,selectedItemText:T,position:s,isPositioned:B,searchRef:le,children:r.jsx(Ia,{as:Ek,allowPinchZoom:!0,children:r.jsx(ba,{asChild:!0,trapped:w.open,onMountAutoFocus:P=>{P.preventDefault()},onUnmountAutoFocus:ve(o,P=>{w.trigger?.focus({preventScroll:!0}),P.preventDefault()}),children:r.jsx(ya,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:i,onFocusOutside:P=>P.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:r.jsx(Y,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:P=>P.preventDefault(),...y,...ce,onPlaced:()=>z(!0),ref:A,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:ve(y.onKeyDown,P=>{const H=P.ctrlKey||P.altKey||P.metaKey;if(P.key==="Tab"&&P.preventDefault(),!H&&P.key.length===1&&N(P.key),["ArrowUp","ArrowDown","Home","End"].includes(P.key)){let W=L().filter(re=>!re.disabled).map(re=>re.ref.current);if(["ArrowUp","End"].includes(P.key)&&(W=W.slice().reverse()),["ArrowUp","ArrowDown"].includes(P.key)){const re=P.target,ie=W.indexOf(re);W=W.slice(ie+1)}setTimeout(()=>V(W)),P.preventDefault()}})})})})})})});tu.displayName=Ak;var Ik="SelectItemAlignedPosition",nu=f.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:s,...o}=e,a=cn(yn,n),i=ln(yn,n),[c,l]=f.useState(null),[u,m]=f.useState(null),d=Se(t,A=>m(A)),x=Os(n),h=f.useRef(!1),v=f.useRef(!0),{viewport:p,selectedItem:g,selectedItemText:y,focusSelectedItem:w}=i,j=f.useCallback(()=>{if(a.trigger&&a.valueNode&&c&&u&&p&&g&&y){const A=a.trigger.getBoundingClientRect(),E=u.getBoundingClientRect(),I=a.valueNode.getBoundingClientRect(),T=y.getBoundingClientRect();if(a.dir!=="rtl"){const re=T.left-E.left,ie=I.left-re,ye=A.left-ie,fe=A.width+ye,Be=Math.max(fe,E.width),Ke=window.innerWidth-St,Ve=nc(ie,[St,Math.max(St,Ke-Be)]);c.style.minWidth=fe+"px",c.style.left=Ve+"px"}else{const re=E.right-T.right,ie=window.innerWidth-I.right-re,ye=window.innerWidth-A.right-ie,fe=A.width+ye,Be=Math.max(fe,E.width),Ke=window.innerWidth-St,Ve=nc(ie,[St,Math.max(St,Ke-Be)]);c.style.minWidth=fe+"px",c.style.right=Ve+"px"}const U=x(),L=window.innerHeight-St*2,B=p.scrollHeight,z=window.getComputedStyle(u),K=parseInt(z.borderTopWidth,10),V=parseInt(z.paddingTop,10),G=parseInt(z.borderBottomWidth,10),D=parseInt(z.paddingBottom,10),se=K+V+B+D+G,le=Math.min(g.offsetHeight*5,se),N=window.getComputedStyle(p),R=parseInt(N.paddingTop,10),F=parseInt(N.paddingBottom,10),Q=A.top+A.height/2-St,Y=L-Q,ce=g.offsetHeight/2,P=g.offsetTop+ce,H=K+V+P,de=se-H;if(H<=Q){const re=U.length>0&&g===U[U.length-1].ref.current;c.style.bottom="0px";const ie=u.clientHeight-p.offsetTop-p.offsetHeight,ye=Math.max(Y,ce+(re?F:0)+ie+G),fe=H+ye;c.style.height=fe+"px"}else{const re=U.length>0&&g===U[0].ref.current;c.style.top="0px";const ye=Math.max(Q,K+p.offsetTop+(re?R:0)+ce)+de;c.style.height=ye+"px",p.scrollTop=H-Q+p.offsetTop}c.style.margin=`${St}px 0`,c.style.minHeight=le+"px",c.style.maxHeight=L+"px",s?.(),requestAnimationFrame(()=>h.current=!0)}},[x,a.trigger,a.valueNode,c,u,p,g,y,a.dir,s]);Ye(()=>j(),[j]);const[k,_]=f.useState();Ye(()=>{u&&_(window.getComputedStyle(u).zIndex)},[u]);const S=f.useCallback(A=>{A&&v.current===!0&&(j(),w?.(),v.current=!1)},[j,w]);return r.jsx(Pk,{scope:n,contentWrapper:c,shouldExpandOnScrollRef:h,onScrollButtonChange:S,children:r.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:r.jsx(ge.div,{...o,ref:d,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});nu.displayName=Ik;var Tk="SelectPopperPosition",Vo=f.forwardRef((e,t)=>{const{__scopeSelect:n,align:s="start",collisionPadding:o=St,...a}=e,i=Ms(n);return r.jsx(bw,{...i,...a,ref:t,align:s,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)"}})});Vo.displayName=Tk;var[Pk,Ta]=Qn(yn,{}),Wo="SelectViewport",ru=f.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:s,...o}=e,a=ln(Wo,n),i=Ta(Wo,n),c=Se(t,a.onViewportChange),l=f.useRef(0);return r.jsxs(r.Fragment,{children:[r.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:s}),r.jsx(Rs.Slot,{scope:n,children:r.jsx(ge.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:ve(o.onScroll,u=>{const m=u.currentTarget,{contentWrapper:d,shouldExpandOnScrollRef:x}=i;if(x?.current&&d){const h=Math.abs(l.current-m.scrollTop);if(h>0){const v=window.innerHeight-St*2,p=parseFloat(d.style.minHeight),g=parseFloat(d.style.height),y=Math.max(p,g);if(y<v){const w=y+h,j=Math.min(v,w),k=w-j;d.style.height=j+"px",d.style.bottom==="0px"&&(m.scrollTop=k>0?k:0,d.style.justifyContent="flex-end")}}}l.current=m.scrollTop})})})]})});ru.displayName=Wo;var su="SelectGroup",[Rk,Ok]=Qn(su),ou=f.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,o=zt();return r.jsx(Rk,{scope:n,id:o,children:r.jsx(ge.div,{role:"group","aria-labelledby":o,...s,ref:t})})});ou.displayName=su;var au="SelectLabel",Mk=f.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,o=Ok(au,n);return r.jsx(ge.div,{id:o.id,...s,ref:t})});Mk.displayName=au;var ps="SelectItem",[Lk,iu]=Qn(ps),cu=f.forwardRef((e,t)=>{const{__scopeSelect:n,value:s,disabled:o=!1,textValue:a,...i}=e,c=cn(ps,n),l=ln(ps,n),u=c.value===s,[m,d]=f.useState(a??""),[x,h]=f.useState(!1),v=Se(t,w=>l.itemRefCallback?.(w,s,o)),p=zt(),g=f.useRef("touch"),y=()=>{o||(c.onValueChange(s),c.onOpenChange(!1))};if(s==="")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 r.jsx(Lk,{scope:n,value:s,disabled:o,textId:p,isSelected:u,onItemTextChange:f.useCallback(w=>{d(j=>j||(w?.textContent??"").trim())},[]),children:r.jsx(Rs.ItemSlot,{scope:n,value:s,disabled:o,textValue:m,children:r.jsx(ge.div,{role:"option","aria-labelledby":p,"data-highlighted":x?"":void 0,"aria-selected":u&&x,"data-state":u?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:v,onFocus:ve(i.onFocus,()=>h(!0)),onBlur:ve(i.onBlur,()=>h(!1)),onClick:ve(i.onClick,()=>{g.current!=="mouse"&&y()}),onPointerUp:ve(i.onPointerUp,()=>{g.current==="mouse"&&y()}),onPointerDown:ve(i.onPointerDown,w=>{g.current=w.pointerType}),onPointerMove:ve(i.onPointerMove,w=>{g.current=w.pointerType,o?l.onItemLeave?.():g.current==="mouse"&&w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ve(i.onPointerLeave,w=>{w.currentTarget===document.activeElement&&l.onItemLeave?.()}),onKeyDown:ve(i.onKeyDown,w=>{l.searchRef?.current!==""&&w.key===" "||(wk.includes(w.key)&&y(),w.key===" "&&w.preventDefault())})})})})});cu.displayName=ps;var ur="SelectItemText",lu=f.forwardRef((e,t)=>{const{__scopeSelect:n,className:s,style:o,...a}=e,i=cn(ur,n),c=ln(ur,n),l=iu(ur,n),u=Sk(ur,n),[m,d]=f.useState(null),x=Se(t,y=>d(y),l.onItemTextChange,y=>c.itemTextRefCallback?.(y,l.value,l.disabled)),h=m?.textContent,v=f.useMemo(()=>r.jsx("option",{value:l.value,disabled:l.disabled,children:h},l.value),[l.disabled,l.value,h]),{onNativeOptionAdd:p,onNativeOptionRemove:g}=u;return Ye(()=>(p(v),()=>g(v)),[p,g,v]),r.jsxs(r.Fragment,{children:[r.jsx(ge.span,{id:l.textId,...a,ref:x}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?ws.createPortal(a.children,i.valueNode):null]})});lu.displayName=ur;var du="SelectItemIndicator",Dk=f.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e;return iu(du,n).isSelected?r.jsx(ge.span,{"aria-hidden":!0,...s,ref:t}):null});Dk.displayName=du;var qo="SelectScrollUpButton",zk=f.forwardRef((e,t)=>{const n=ln(qo,e.__scopeSelect),s=Ta(qo,e.__scopeSelect),[o,a]=f.useState(!1),i=Se(t,s.onScrollButtonChange);return Ye(()=>{if(n.viewport&&n.isPositioned){let c=function(){const u=l.scrollTop>0;a(u)};const l=n.viewport;return c(),l.addEventListener("scroll",c),()=>l.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),o?r.jsx(uu,{...e,ref:i,onAutoScroll:()=>{const{viewport:c,selectedItem:l}=n;c&&l&&(c.scrollTop=c.scrollTop-l.offsetHeight)}}):null});zk.displayName=qo;var Ho="SelectScrollDownButton",$k=f.forwardRef((e,t)=>{const n=ln(Ho,e.__scopeSelect),s=Ta(Ho,e.__scopeSelect),[o,a]=f.useState(!1),i=Se(t,s.onScrollButtonChange);return Ye(()=>{if(n.viewport&&n.isPositioned){let c=function(){const u=l.scrollHeight-l.clientHeight,m=Math.ceil(l.scrollTop)<u;a(m)};const l=n.viewport;return c(),l.addEventListener("scroll",c),()=>l.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),o?r.jsx(uu,{...e,ref:i,onAutoScroll:()=>{const{viewport:c,selectedItem:l}=n;c&&l&&(c.scrollTop=c.scrollTop+l.offsetHeight)}}):null});$k.displayName=Ho;var uu=f.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:s,...o}=e,a=ln("SelectScrollButton",n),i=f.useRef(null),c=Os(n),l=f.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return f.useEffect(()=>()=>l(),[l]),Ye(()=>{c().find(m=>m.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[c]),r.jsx(ge.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:ve(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(s,50))}),onPointerMove:ve(o.onPointerMove,()=>{a.onItemLeave?.(),i.current===null&&(i.current=window.setInterval(s,50))}),onPointerLeave:ve(o.onPointerLeave,()=>{l()})})}),Fk="SelectSeparator",Uk=f.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e;return r.jsx(ge.div,{"aria-hidden":!0,...s,ref:t})});Uk.displayName=Fk;var Zo="SelectArrow",Bk=f.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,o=Ms(n),a=cn(Zo,n),i=ln(Zo,n);return a.open&&i.position==="popper"?r.jsx(ww,{...o,...s,ref:t}):null});Bk.displayName=Zo;var Vk="SelectBubbleInput",mu=f.forwardRef(({__scopeSelect:e,value:t,...n},s)=>{const o=f.useRef(null),a=Se(s,o),i=Pw(t);return f.useEffect(()=>{const c=o.current;if(!c)return;const l=window.HTMLSelectElement.prototype,m=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&m){const d=new Event("change",{bubbles:!0});m.call(c,t),c.dispatchEvent(d)}},[i,t]),r.jsx(ge.select,{...n,style:{...Ld,...n.style},ref:a,defaultValue:t})});mu.displayName=Vk;function fu(e){return e===""||e===void 0}function pu(e){const t=en(e),n=f.useRef(""),s=f.useRef(0),o=f.useCallback(i=>{const c=n.current+i;t(c),(function l(u){n.current=u,window.clearTimeout(s.current),u!==""&&(s.current=window.setTimeout(()=>l(""),1e3))})(c)},[t]),a=f.useCallback(()=>{n.current="",window.clearTimeout(s.current)},[]);return f.useEffect(()=>()=>window.clearTimeout(s.current),[]),[n,o,a]}function hu(e,t,n){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,a=n?e.indexOf(n):-1;let i=Wk(e,Math.max(a,0));o.length===1&&(i=i.filter(u=>u!==n));const l=i.find(u=>u.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function Wk(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var qk=Hd,gu=Gd,Hk=Kd,Zk=Qd,Gk=Jd,xu=Xd,Yk=ru,Kk=ou,vu=cu,Qk=lu;const hs=qk,Jk=Kk,gs=Hk,kr=f.forwardRef(({className:e,children:t,...n},s)=>r.jsxs(gu,{ref:s,className:O("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,r.jsx(Zk,{className:"ml-2 text-neutral-500 dark:text-neutral-400",children:"▾"})]}));kr.displayName=gu.displayName;const jr=f.forwardRef(({className:e,children:t,position:n="popper",...s},o)=>r.jsx(Gk,{children:r.jsx(xu,{ref:o,position:n,className:O("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),...s,children:r.jsx(Yk,{className:O("p-1",n==="popper"?"w-full":void 0),children:t})})}));jr.displayName=xu.displayName;const _r=f.forwardRef(({className:e,children:t,...n},s)=>r.jsx(vu,{ref:s,className:O("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:r.jsx(Qk,{children:t})}));_r.displayName=vu.displayName;function Xk(e,t){return f.useReducer((n,s)=>t[n][s]??n,e)}var Jn=e=>{const{present:t,children:n}=e,s=ej(t),o=typeof n=="function"?n({present:s.isPresent}):f.Children.only(n),a=Se(s.ref,tj(o));return typeof n=="function"||s.isPresent?f.cloneElement(o,{ref:a}):null};Jn.displayName="Presence";function ej(e){const[t,n]=f.useState(),s=f.useRef(null),o=f.useRef(e),a=f.useRef("none"),i=e?"mounted":"unmounted",[c,l]=Xk(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return f.useEffect(()=>{const u=Wr(s.current);a.current=c==="mounted"?u:"none"},[c]),Ye(()=>{const u=s.current,m=o.current;if(m!==e){const x=a.current,h=Wr(u);e?l("MOUNT"):h==="none"||u?.display==="none"?l("UNMOUNT"):l(m&&x!==h?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),Ye(()=>{if(t){let u;const m=t.ownerDocument.defaultView??window,d=h=>{const p=Wr(s.current).includes(CSS.escape(h.animationName));if(h.target===t&&p&&(l("ANIMATION_END"),!o.current)){const g=t.style.animationFillMode;t.style.animationFillMode="forwards",u=m.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=g)})}},x=h=>{h.target===t&&(a.current=Wr(s.current))};return t.addEventListener("animationstart",x),t.addEventListener("animationcancel",d),t.addEventListener("animationend",d),()=>{m.clearTimeout(u),t.removeEventListener("animationstart",x),t.removeEventListener("animationcancel",d),t.removeEventListener("animationend",d)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:f.useCallback(u=>{s.current=u?getComputedStyle(u):null,n(u)},[])}}function Wr(e){return e?.animationName||"none"}function tj(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 nj(e){const t=rj(e),n=f.forwardRef((s,o)=>{const{children:a,...i}=s,c=f.Children.toArray(a),l=c.find(oj);if(l){const u=l.props.children,m=c.map(d=>d===l?f.Children.count(u)>1?f.Children.only(null):f.isValidElement(u)?u.props.children:null:d);return r.jsx(t,{...i,ref:o,children:f.isValidElement(u)?f.cloneElement(u,void 0,m):null})}return r.jsx(t,{...i,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}function rj(e){const t=f.forwardRef((n,s)=>{const{children:o,...a}=n;if(f.isValidElement(o)){const i=ij(o),c=aj(a,o.props);return o.type!==f.Fragment&&(c.ref=s?Hn(s,i):i),f.cloneElement(o,c)}return f.Children.count(o)>1?f.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var sj=Symbol("radix.slottable");function oj(e){return f.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===sj}function aj(e,t){const n={...t};for(const s in t){const o=e[s],a=t[s];/^on[A-Z]/.test(s)?o&&a?n[s]=(...c)=>{const l=a(...c);return o(...c),l}:o&&(n[s]=o):s==="style"?n[s]={...o,...a}:s==="className"&&(n[s]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function ij(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 Ls="Dialog",[yu]=an(Ls),[cj,It]=yu(Ls),bu=e=>{const{__scopeDialog:t,children:n,open:s,defaultOpen:o,onOpenChange:a,modal:i=!0}=e,c=f.useRef(null),l=f.useRef(null),[u,m]=rn({prop:s,defaultProp:o??!1,onChange:a,caller:Ls});return r.jsx(cj,{scope:t,triggerRef:c,contentRef:l,contentId:zt(),titleId:zt(),descriptionId:zt(),open:u,onOpenChange:m,onOpenToggle:f.useCallback(()=>m(d=>!d),[m]),modal:i,children:n})};bu.displayName=Ls;var wu="DialogTrigger",ku=f.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=It(wu,n),a=Se(t,o.triggerRef);return r.jsx(ge.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Oa(o.open),...s,ref:a,onClick:ve(e.onClick,o.onOpenToggle)})});ku.displayName=wu;var Pa="DialogPortal",[lj,ju]=yu(Pa,{forceMount:void 0}),_u=e=>{const{__scopeDialog:t,forceMount:n,children:s,container:o}=e,a=It(Pa,t);return r.jsx(lj,{scope:t,forceMount:n,children:f.Children.map(s,i=>r.jsx(Jn,{present:n||a.open,children:r.jsx(Ea,{asChild:!0,container:o,children:i})}))})};_u.displayName=Pa;var xs="DialogOverlay",Su=f.forwardRef((e,t)=>{const n=ju(xs,e.__scopeDialog),{forceMount:s=n.forceMount,...o}=e,a=It(xs,e.__scopeDialog);return a.modal?r.jsx(Jn,{present:s||a.open,children:r.jsx(uj,{...o,ref:t})}):null});Su.displayName=xs;var dj=nj("DialogOverlay.RemoveScroll"),uj=f.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=It(xs,n);return r.jsx(Ia,{as:dj,allowPinchZoom:!0,shards:[o.contentRef],children:r.jsx(ge.div,{"data-state":Oa(o.open),...s,ref:t,style:{pointerEvents:"auto",...s.style}})})}),bn="DialogContent",Cu=f.forwardRef((e,t)=>{const n=ju(bn,e.__scopeDialog),{forceMount:s=n.forceMount,...o}=e,a=It(bn,e.__scopeDialog);return r.jsx(Jn,{present:s||a.open,children:a.modal?r.jsx(mj,{...o,ref:t}):r.jsx(fj,{...o,ref:t})})});Cu.displayName=bn;var mj=f.forwardRef((e,t)=>{const n=It(bn,e.__scopeDialog),s=f.useRef(null),o=Se(t,n.contentRef,s);return f.useEffect(()=>{const a=s.current;if(a)return zd(a)},[]),r.jsx(Nu,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ve(e.onCloseAutoFocus,a=>{a.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:ve(e.onPointerDownOutside,a=>{const i=a.detail.originalEvent,c=i.button===0&&i.ctrlKey===!0;(i.button===2||c)&&a.preventDefault()}),onFocusOutside:ve(e.onFocusOutside,a=>a.preventDefault())})}),fj=f.forwardRef((e,t)=>{const n=It(bn,e.__scopeDialog),s=f.useRef(!1),o=f.useRef(!1);return r.jsx(Nu,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{e.onCloseAutoFocus?.(a),a.defaultPrevented||(s.current||n.triggerRef.current?.focus(),a.preventDefault()),s.current=!1,o.current=!1},onInteractOutside:a=>{e.onInteractOutside?.(a),a.defaultPrevented||(s.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()}})}),Nu=f.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:s,onOpenAutoFocus:o,onCloseAutoFocus:a,...i}=e,c=It(bn,n),l=f.useRef(null),u=Se(t,l);return md(),r.jsxs(r.Fragment,{children:[r.jsx(ba,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:o,onUnmountAutoFocus:a,children:r.jsx(ya,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":Oa(c.open),...i,ref:u,onDismiss:()=>c.onOpenChange(!1)})}),r.jsxs(r.Fragment,{children:[r.jsx(pj,{titleId:c.titleId}),r.jsx(gj,{contentRef:l,descriptionId:c.descriptionId})]})]})}),Ra="DialogTitle",Au=f.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=It(Ra,n);return r.jsx(ge.h2,{id:o.titleId,...s,ref:t})});Au.displayName=Ra;var Eu="DialogDescription",Iu=f.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=It(Eu,n);return r.jsx(ge.p,{id:o.descriptionId,...s,ref:t})});Iu.displayName=Eu;var Tu="DialogClose",Pu=f.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=It(Tu,n);return r.jsx(ge.button,{type:"button",...s,ref:t,onClick:ve(e.onClick,()=>o.onOpenChange(!1))})});Pu.displayName=Tu;function Oa(e){return e?"open":"closed"}var Ru="DialogTitleWarning",[aC,Ou]=by(Ru,{contentName:bn,titleName:Ra,docsSlug:"dialog"}),pj=({titleId:e})=>{const t=Ou(Ru),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
80
+
81
+ If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
82
+
83
+ For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return f.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},hj="DialogDescriptionWarning",gj=({contentRef:e,descriptionId:t})=>{const s=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Ou(hj).contentName}}.`;return f.useEffect(()=>{const o=e.current?.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(s))},[s,e,t]),null},Mu=bu,Lu=ku,Du=_u,Ds=Su,zs=Cu,$s=Au,Fs=Iu,zu=Pu;const Ma=Mu,xj=Lu,$u=Du,vj=zu,La=f.forwardRef(({className:e,...t},n)=>r.jsx(Ds,{ref:n,className:O("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}));La.displayName=Ds.displayName;const Us=f.forwardRef(({className:e,children:t,...n},s)=>r.jsxs($u,{children:[r.jsx(La,{}),r.jsx(zs,{ref:s,className:O("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})]}));Us.displayName=zs.displayName;const Da=({className:e,...t})=>r.jsx("div",{className:O("flex flex-col space-y-2 text-center sm:text-left",e),...t}),Fu=({className:e,...t})=>r.jsx("div",{className:O("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t}),Bs=f.forwardRef(({className:e,...t},n)=>r.jsx($s,{ref:n,className:O("text-lg font-semibold leading-none tracking-tight",e),...t}));Bs.displayName=$s.displayName;const za=f.forwardRef(({className:e,...t},n)=>r.jsx(Fs,{ref:n,className:O("text-sm text-neutral-500 dark:text-neutral-400",e),...t}));za.displayName=Fs.displayName;const Vs=Mu,Ws=Lu,Uu=zu,Bu=Du,$a=f.forwardRef(({className:e,...t},n)=>r.jsx(Ds,{ref:n,className:O("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}));$a.displayName=Ds.displayName;const yj=ga("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"}}),Ir=f.forwardRef(({side:e="right",className:t,children:n,overlayClassName:s,...o},a)=>r.jsxs(Bu,{children:[r.jsx($a,{className:s}),r.jsx(zs,{ref:a,className:O(yj({side:e}),t),...o,children:n})]}));Ir.displayName=zs.displayName;const qs=({className:e,...t})=>r.jsx("div",{className:O("flex flex-col space-y-2 text-left",e),...t}),Hs=f.forwardRef(({className:e,...t},n)=>r.jsx($s,{ref:n,className:O("text-lg font-semibold leading-none tracking-tight",e),...t}));Hs.displayName=$s.displayName;const Vu=f.forwardRef(({className:e,...t},n)=>r.jsx(Fs,{ref:n,className:O("text-sm text-neutral-500 dark:text-neutral-400",e),...t}));Vu.displayName=Fs.displayName;var Zs="Collapsible",[bj,Wu]=an(Zs),[wj,Fa]=bj(Zs),qu=f.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:s,defaultOpen:o,disabled:a,onOpenChange:i,...c}=e,[l,u]=rn({prop:s,defaultProp:o??!1,onChange:i,caller:Zs});return r.jsx(wj,{scope:n,disabled:a,contentId:zt(),open:l,onOpenToggle:f.useCallback(()=>u(m=>!m),[u]),children:r.jsx(ge.div,{"data-state":Ba(l),"data-disabled":a?"":void 0,...c,ref:t})})});qu.displayName=Zs;var Hu="CollapsibleTrigger",Zu=f.forwardRef((e,t)=>{const{__scopeCollapsible:n,...s}=e,o=Fa(Hu,n);return r.jsx(ge.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":Ba(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...s,ref:t,onClick:ve(e.onClick,o.onOpenToggle)})});Zu.displayName=Hu;var Ua="CollapsibleContent",Gu=f.forwardRef((e,t)=>{const{forceMount:n,...s}=e,o=Fa(Ua,e.__scopeCollapsible);return r.jsx(Jn,{present:n||o.open,children:({present:a})=>r.jsx(kj,{...s,ref:t,present:a})})});Gu.displayName=Ua;var kj=f.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:s,children:o,...a}=e,i=Fa(Ua,n),[c,l]=f.useState(s),u=f.useRef(null),m=Se(t,u),d=f.useRef(0),x=d.current,h=f.useRef(0),v=h.current,p=i.open||c,g=f.useRef(p),y=f.useRef(void 0);return f.useEffect(()=>{const w=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(w)},[]),Ye(()=>{const w=u.current;if(w){y.current=y.current||{transitionDuration:w.style.transitionDuration,animationName:w.style.animationName},w.style.transitionDuration="0s",w.style.animationName="none";const j=w.getBoundingClientRect();d.current=j.height,h.current=j.width,g.current||(w.style.transitionDuration=y.current.transitionDuration,w.style.animationName=y.current.animationName),l(s)}},[i.open,s]),r.jsx(ge.div,{"data-state":Ba(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!p,...a,ref:m,style:{"--radix-collapsible-content-height":x?`${x}px`:void 0,"--radix-collapsible-content-width":v?`${v}px`:void 0,...e.style},children:p&&o})});function Ba(e){return e?"open":"closed"}var jj=qu,_j=Zu,Sj=Gu,Tt="Accordion",Cj=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[Va,Nj,Aj]=va(Tt),[Gs]=an(Tt,[Aj,Wu]),Wa=Wu(),Yu=b.forwardRef((e,t)=>{const{type:n,...s}=e,o=s,a=s;return r.jsx(Va.Provider,{scope:e.__scopeAccordion,children:n==="multiple"?r.jsx(Pj,{...a,ref:t}):r.jsx(Tj,{...o,ref:t})})});Yu.displayName=Tt;var[Ku,Ej]=Gs(Tt),[Qu,Ij]=Gs(Tt,{collapsible:!1}),Tj=b.forwardRef((e,t)=>{const{value:n,defaultValue:s,onValueChange:o=()=>{},collapsible:a=!1,...i}=e,[c,l]=rn({prop:n,defaultProp:s??"",onChange:o,caller:Tt});return r.jsx(Ku,{scope:e.__scopeAccordion,value:b.useMemo(()=>c?[c]:[],[c]),onItemOpen:l,onItemClose:b.useCallback(()=>a&&l(""),[a,l]),children:r.jsx(Qu,{scope:e.__scopeAccordion,collapsible:a,children:r.jsx(Ju,{...i,ref:t})})})}),Pj=b.forwardRef((e,t)=>{const{value:n,defaultValue:s,onValueChange:o=()=>{},...a}=e,[i,c]=rn({prop:n,defaultProp:s??[],onChange:o,caller:Tt}),l=b.useCallback(m=>c((d=[])=>[...d,m]),[c]),u=b.useCallback(m=>c((d=[])=>d.filter(x=>x!==m)),[c]);return r.jsx(Ku,{scope:e.__scopeAccordion,value:i,onItemOpen:l,onItemClose:u,children:r.jsx(Qu,{scope:e.__scopeAccordion,collapsible:!0,children:r.jsx(Ju,{...a,ref:t})})})}),[Rj,Ys]=Gs(Tt),Ju=b.forwardRef((e,t)=>{const{__scopeAccordion:n,disabled:s,dir:o,orientation:a="vertical",...i}=e,c=b.useRef(null),l=Se(c,t),u=Nj(n),d=Ns(o)==="ltr",x=ve(e.onKeyDown,h=>{if(!Cj.includes(h.key))return;const v=h.target,p=u().filter(E=>!E.ref.current?.disabled),g=p.findIndex(E=>E.ref.current===v),y=p.length;if(g===-1)return;h.preventDefault();let w=g;const j=0,k=y-1,_=()=>{w=g+1,w>k&&(w=j)},S=()=>{w=g-1,w<j&&(w=k)};switch(h.key){case"Home":w=j;break;case"End":w=k;break;case"ArrowRight":a==="horizontal"&&(d?_():S());break;case"ArrowDown":a==="vertical"&&_();break;case"ArrowLeft":a==="horizontal"&&(d?S():_());break;case"ArrowUp":a==="vertical"&&S();break}const A=w%y;p[A].ref.current?.focus()});return r.jsx(Rj,{scope:n,disabled:s,direction:o,orientation:a,children:r.jsx(Va.Slot,{scope:n,children:r.jsx(ge.div,{...i,"data-orientation":a,ref:l,onKeyDown:s?void 0:x})})})}),vs="AccordionItem",[Oj,qa]=Gs(vs),Xu=b.forwardRef((e,t)=>{const{__scopeAccordion:n,value:s,...o}=e,a=Ys(vs,n),i=Ej(vs,n),c=Wa(n),l=zt(),u=s&&i.value.includes(s)||!1,m=a.disabled||e.disabled;return r.jsx(Oj,{scope:n,open:u,disabled:m,triggerId:l,children:r.jsx(jj,{"data-orientation":a.orientation,"data-state":om(u),...c,...o,ref:t,disabled:m,open:u,onOpenChange:d=>{d?i.onItemOpen(s):i.onItemClose(s)}})})});Xu.displayName=vs;var em="AccordionHeader",tm=b.forwardRef((e,t)=>{const{__scopeAccordion:n,...s}=e,o=Ys(Tt,n),a=qa(em,n);return r.jsx(ge.h3,{"data-orientation":o.orientation,"data-state":om(a.open),"data-disabled":a.disabled?"":void 0,...s,ref:t})});tm.displayName=em;var Go="AccordionTrigger",nm=b.forwardRef((e,t)=>{const{__scopeAccordion:n,...s}=e,o=Ys(Tt,n),a=qa(Go,n),i=Ij(Go,n),c=Wa(n);return r.jsx(Va.ItemSlot,{scope:n,children:r.jsx(_j,{"aria-disabled":a.open&&!i.collapsible||void 0,"data-orientation":o.orientation,id:a.triggerId,...c,...s,ref:t})})});nm.displayName=Go;var rm="AccordionContent",sm=b.forwardRef((e,t)=>{const{__scopeAccordion:n,...s}=e,o=Ys(Tt,n),a=qa(rm,n),i=Wa(n);return r.jsx(Sj,{role:"region","aria-labelledby":a.triggerId,"data-orientation":o.orientation,...i,...s,ref:t,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...e.style}})});sm.displayName=rm;function om(e){return e?"open":"closed"}var Mj=Yu,am=Xu,Lj=tm,im=nm,cm=sm;const lm=Mj,fr=f.forwardRef(({className:e,...t},n)=>r.jsx(am,{ref:n,className:O("border-b border-neutral-200 dark:border-neutral-800",e),...t}));fr.displayName=am.displayName;const pr=f.forwardRef(({className:e,children:t,...n},s)=>r.jsx(Lj,{className:"flex",children:r.jsxs(im,{ref:s,className:O("flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline",e),...n,children:[t,r.jsx("span",{className:"ml-3 text-neutral-500 dark:text-neutral-400","aria-hidden":!0,children:"▾"})]})}));pr.displayName=im.displayName;const hr=f.forwardRef(({className:e,children:t,...n},s)=>r.jsx(cm,{ref:s,className:O("overflow-hidden text-sm",e),...n,children:r.jsx("div",{className:"pb-4 pt-0",children:t})}));hr.displayName=cm.displayName;var ko="rovingFocusGroup.onEntryFocus",Dj={bubbles:!1,cancelable:!0},Tr="RovingFocusGroup",[Yo,dm,zj]=va(Tr),[$j,um]=an(Tr,[zj]),[Fj,Uj]=$j(Tr),mm=f.forwardRef((e,t)=>r.jsx(Yo.Provider,{scope:e.__scopeRovingFocusGroup,children:r.jsx(Yo.Slot,{scope:e.__scopeRovingFocusGroup,children:r.jsx(Bj,{...e,ref:t})})}));mm.displayName=Tr;var Bj=f.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:s,loop:o=!1,dir:a,currentTabStopId:i,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:l,onEntryFocus:u,preventScrollOnEntryFocus:m=!1,...d}=e,x=f.useRef(null),h=Se(t,x),v=Ns(a),[p,g]=rn({prop:i,defaultProp:c??null,onChange:l,caller:Tr}),[y,w]=f.useState(!1),j=en(u),k=dm(n),_=f.useRef(!1),[S,A]=f.useState(0);return f.useEffect(()=>{const E=x.current;if(E)return E.addEventListener(ko,j),()=>E.removeEventListener(ko,j)},[j]),r.jsx(Fj,{scope:n,orientation:s,dir:v,loop:o,currentTabStopId:p,onItemFocus:f.useCallback(E=>g(E),[g]),onItemShiftTab:f.useCallback(()=>w(!0),[]),onFocusableItemAdd:f.useCallback(()=>A(E=>E+1),[]),onFocusableItemRemove:f.useCallback(()=>A(E=>E-1),[]),children:r.jsx(ge.div,{tabIndex:y||S===0?-1:0,"data-orientation":s,...d,ref:h,style:{outline:"none",...e.style},onMouseDown:ve(e.onMouseDown,()=>{_.current=!0}),onFocus:ve(e.onFocus,E=>{const I=!_.current;if(E.target===E.currentTarget&&I&&!y){const T=new CustomEvent(ko,Dj);if(E.currentTarget.dispatchEvent(T),!T.defaultPrevented){const U=k().filter(V=>V.focusable),L=U.find(V=>V.active),B=U.find(V=>V.id===p),K=[L,B,...U].filter(Boolean).map(V=>V.ref.current);hm(K,m)}}_.current=!1}),onBlur:ve(e.onBlur,()=>w(!1))})})}),fm="RovingFocusGroupItem",pm=f.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:s=!0,active:o=!1,tabStopId:a,children:i,...c}=e,l=zt(),u=a||l,m=Uj(fm,n),d=m.currentTabStopId===u,x=dm(n),{onFocusableItemAdd:h,onFocusableItemRemove:v,currentTabStopId:p}=m;return f.useEffect(()=>{if(s)return h(),()=>v()},[s,h,v]),r.jsx(Yo.ItemSlot,{scope:n,id:u,focusable:s,active:o,children:r.jsx(ge.span,{tabIndex:d?0:-1,"data-orientation":m.orientation,...c,ref:t,onMouseDown:ve(e.onMouseDown,g=>{s?m.onItemFocus(u):g.preventDefault()}),onFocus:ve(e.onFocus,()=>m.onItemFocus(u)),onKeyDown:ve(e.onKeyDown,g=>{if(g.key==="Tab"&&g.shiftKey){m.onItemShiftTab();return}if(g.target!==g.currentTarget)return;const y=qj(g,m.orientation,m.dir);if(y!==void 0){if(g.metaKey||g.ctrlKey||g.altKey||g.shiftKey)return;g.preventDefault();let j=x().filter(k=>k.focusable).map(k=>k.ref.current);if(y==="last")j.reverse();else if(y==="prev"||y==="next"){y==="prev"&&j.reverse();const k=j.indexOf(g.currentTarget);j=m.loop?Hj(j,k+1):j.slice(k+1)}setTimeout(()=>hm(j))}}),children:typeof i=="function"?i({isCurrentTabStop:d,hasTabStop:p!=null}):i})})});pm.displayName=fm;var Vj={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Wj(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function qj(e,t,n){const s=Wj(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(s))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(s)))return Vj[s]}function hm(e,t=!1){const n=document.activeElement;for(const s of e)if(s===n||(s.focus({preventScroll:t}),document.activeElement!==n))return}function Hj(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var Zj=mm,Gj=pm,Ks="Tabs",[Yj]=an(Ks,[um]),gm=um(),[Kj,Ha]=Yj(Ks),xm=f.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,onValueChange:o,defaultValue:a,orientation:i="horizontal",dir:c,activationMode:l="automatic",...u}=e,m=Ns(c),[d,x]=rn({prop:s,onChange:o,defaultProp:a??"",caller:Ks});return r.jsx(Kj,{scope:n,baseId:zt(),value:d,onValueChange:x,orientation:i,dir:m,activationMode:l,children:r.jsx(ge.div,{dir:m,"data-orientation":i,...u,ref:t})})});xm.displayName=Ks;var vm="TabsList",ym=f.forwardRef((e,t)=>{const{__scopeTabs:n,loop:s=!0,...o}=e,a=Ha(vm,n),i=gm(n);return r.jsx(Zj,{asChild:!0,...i,orientation:a.orientation,dir:a.dir,loop:s,children:r.jsx(ge.div,{role:"tablist","aria-orientation":a.orientation,...o,ref:t})})});ym.displayName=vm;var bm="TabsTrigger",wm=f.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,disabled:o=!1,...a}=e,i=Ha(bm,n),c=gm(n),l=_m(i.baseId,s),u=Sm(i.baseId,s),m=s===i.value;return r.jsx(Gj,{asChild:!0,...c,focusable:!o,active:m,children:r.jsx(ge.button,{type:"button",role:"tab","aria-selected":m,"aria-controls":u,"data-state":m?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:l,...a,ref:t,onMouseDown:ve(e.onMouseDown,d=>{!o&&d.button===0&&d.ctrlKey===!1?i.onValueChange(s):d.preventDefault()}),onKeyDown:ve(e.onKeyDown,d=>{[" ","Enter"].includes(d.key)&&i.onValueChange(s)}),onFocus:ve(e.onFocus,()=>{const d=i.activationMode!=="manual";!m&&!o&&d&&i.onValueChange(s)})})})});wm.displayName=bm;var km="TabsContent",jm=f.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,forceMount:o,children:a,...i}=e,c=Ha(km,n),l=_m(c.baseId,s),u=Sm(c.baseId,s),m=s===c.value,d=f.useRef(m);return f.useEffect(()=>{const x=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(x)},[]),r.jsx(Jn,{present:o||m,children:({present:x})=>r.jsx(ge.div,{"data-state":m?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":l,hidden:!x,id:u,tabIndex:0,...i,ref:t,style:{...e.style,animationDuration:d.current?"0s":void 0},children:x&&a})})});jm.displayName=km;function _m(e,t){return`${e}-trigger-${t}`}function Sm(e,t){return`${e}-content-${t}`}var Qj=xm,Cm=ym,Nm=wm,Am=jm;const Za=Qj,Qs=f.forwardRef(({className:e,...t},n)=>r.jsx(Cm,{ref:n,className:O("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}));Qs.displayName=Cm.displayName;const Sr=f.forwardRef(({className:e,...t},n)=>r.jsx(Nm,{ref:n,className:O("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}));Sr.displayName=Nm.displayName;const Em=f.forwardRef(({className:e,...t},n)=>r.jsx(Am,{ref:n,className:O("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}));Em.displayName=Am.displayName;function Bn({title:e,description:t,actionLabel:n,onAction:s,className:o}){return r.jsx("div",{className:O("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:r.jsxs("div",{className:"max-w-sm",children:[r.jsx("h3",{className:"text-base font-semibold text-neutral-950 dark:text-neutral-50",children:e}),t?r.jsx("p",{className:"mt-2 text-sm text-neutral-600 dark:text-neutral-400",children:t}):null,n&&s?r.jsx("div",{className:"mt-5",children:r.jsx(J,{type:"button",onClick:s,variant:"secondary",children:n})}):null]})})}function Ft({title:e,description:t,onRetry:n,className:s}){return r.jsxs("div",{className:O("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",s),children:[r.jsx("h3",{className:"text-sm font-semibold",children:e??"Something went wrong"}),r.jsx("p",{className:"mt-2 text-sm text-neutral-600 dark:text-neutral-400",children:t}),n?r.jsx("div",{className:"mt-4",children:r.jsx(J,{type:"button",variant:"outline",onClick:n,children:"Try again"})}):null]})}class Jj extends f.Component{state={error:null};static getDerivedStateFromError(t){return{error:t}}render(){return this.state.error?this.props.fallback?this.props.fallback(this.state.error):r.jsx(Ft,{description:this.state.error.message}):this.props.children}}function Xj(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 e_=e=>{switch(e){case"success":return r_;case"info":return o_;case"warning":return s_;case"error":return a_;default:return null}},t_=Array(12).fill(0),n_=({visible:e,className:t})=>b.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},b.createElement("div",{className:"sonner-spinner"},t_.map((n,s)=>b.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${s}`})))),r_=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},b.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"})),s_=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},b.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"})),o_=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},b.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"})),a_=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},b.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"})),i_=b.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"},b.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),b.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),c_=()=>{const[e,t]=b.useState(document.hidden);return b.useEffect(()=>{const n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e};let Ko=1;class l_{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:s,...o}=t,a=typeof t?.id=="number"||((n=t.id)==null?void 0:n.length)>0?t.id:Ko++,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:s}),{...l,...t,id:a,dismissible:c,title:s}):l):this.addToast({title:s,...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(s=>s({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 s;n.loading!==void 0&&(s=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=s!==void 0,i;const c=o.then(async u=>{if(i=["resolve",u],b.isValidElement(u))a=!1,this.create({id:s,type:"default",message:u});else if(u_(u)&&!u.ok){a=!1;const d=typeof n.error=="function"?await n.error(`HTTP error! status: ${u.status}`):n.error,x=typeof n.description=="function"?await n.description(`HTTP error! status: ${u.status}`):n.description,v=typeof d=="object"&&!b.isValidElement(d)?d:{message:d};this.create({id:s,type:"error",description:x,...v})}else if(u instanceof Error){a=!1;const d=typeof n.error=="function"?await n.error(u):n.error,x=typeof n.description=="function"?await n.description(u):n.description,v=typeof d=="object"&&!b.isValidElement(d)?d:{message:d};this.create({id:s,type:"error",description:x,...v})}else if(n.success!==void 0){a=!1;const d=typeof n.success=="function"?await n.success(u):n.success,x=typeof n.description=="function"?await n.description(u):n.description,v=typeof d=="object"&&!b.isValidElement(d)?d:{message:d};this.create({id:s,type:"success",description:x,...v})}}).catch(async u=>{if(i=["reject",u],n.error!==void 0){a=!1;const m=typeof n.error=="function"?await n.error(u):n.error,d=typeof n.description=="function"?await n.description(u):n.description,h=typeof m=="object"&&!b.isValidElement(m)?m:{message:m};this.create({id:s,type:"error",description:d,...h})}}).finally(()=>{a&&(this.dismiss(s),s=void 0),n.finally==null||n.finally.call(n)}),l=()=>new Promise((u,m)=>c.then(()=>i[0]==="reject"?m(i[1]):u(i[1])).catch(m));return typeof s!="string"&&typeof s!="number"?{unwrap:l}:Object.assign(s,{unwrap:l})},this.custom=(t,n)=>{const s=n?.id||Ko++;return this.create({jsx:t(s),id:s,...n}),s},this.getActiveToasts=()=>this.toasts.filter(t=>!this.dismissedToasts.has(t.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}}const ct=new l_,d_=(e,t)=>{const n=t?.id||Ko++;return ct.addToast({title:e,...t,id:n}),n},u_=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",m_=d_,f_=()=>ct.toasts,p_=()=>ct.getActiveToasts(),h_=Object.assign(m_,{success:ct.success,info:ct.info,warning:ct.warning,error:ct.error,custom:ct.custom,message:ct.message,promise:ct.promise,dismiss:ct.dismiss,loading:ct.loading},{getHistory:f_,getToasts:p_});Xj("[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 qr(e){return e.label!==void 0}const g_=3,x_="24px",v_="16px",Nc=4e3,y_=356,b_=14,w_=45,k_=200;function Rt(...e){return e.filter(Boolean).join(" ")}function j_(e){const[t,n]=e.split("-"),s=[];return t&&s.push(t),n&&s.push(n),s}const __=e=>{var t,n,s,o,a,i,c,l,u;const{invert:m,toast:d,unstyled:x,interacting:h,setHeights:v,visibleToasts:p,heights:g,index:y,toasts:w,expanded:j,removeToast:k,defaultRichColors:_,closeButton:S,style:A,cancelButtonStyle:E,actionButtonStyle:I,className:T="",descriptionClassName:U="",duration:L,position:B,gap:z,expandByDefault:K,classNames:V,icons:G,closeButtonAriaLabel:D="Close toast"}=e,[se,le]=b.useState(null),[N,R]=b.useState(null),[F,Q]=b.useState(!1),[Y,ce]=b.useState(!1),[P,H]=b.useState(!1),[de,W]=b.useState(!1),[re,ie]=b.useState(!1),[ye,fe]=b.useState(0),[Be,Ke]=b.useState(0),Ve=b.useRef(d.duration||L||Nc),M=b.useRef(null),X=b.useRef(null),ue=y===0,je=y+1<=p,be=d.type,Me=d.dismissible!==!1,Xn=d.className||"",dn=d.descriptionClassName||"",kt=b.useMemo(()=>g.findIndex(me=>me.toastId===d.id)||0,[g,d.id]),xt=b.useMemo(()=>{var me;return(me=d.closeButton)!=null?me:S},[d.closeButton,S]),kn=b.useMemo(()=>d.duration||L||Nc,[d.duration,L]),jn=b.useRef(0),Vt=b.useRef(0),_n=b.useRef(0),Wt=b.useRef(null),[Sn,Cn]=B.split("-"),vt=b.useMemo(()=>g.reduce((me,Le,xe)=>xe>=kt?me:me+Le.height,0),[g,kt]),qt=c_(),er=d.invert||m,un=be==="loading";Vt.current=b.useMemo(()=>kt*z+vt,[kt,vt]),b.useEffect(()=>{Ve.current=kn},[kn]),b.useEffect(()=>{Q(!0)},[]),b.useEffect(()=>{const me=X.current;if(me){const Le=me.getBoundingClientRect().height;return Ke(Le),v(xe=>[{toastId:d.id,height:Le,position:d.position},...xe]),()=>v(xe=>xe.filter(De=>De.toastId!==d.id))}},[v,d.id]),b.useLayoutEffect(()=>{if(!F)return;const me=X.current,Le=me.style.height;me.style.height="auto";const xe=me.getBoundingClientRect().height;me.style.height=Le,Ke(xe),v(De=>De.find(ze=>ze.toastId===d.id)?De.map(ze=>ze.toastId===d.id?{...ze,height:xe}:ze):[{toastId:d.id,height:xe,position:d.position},...De])},[F,d.title,d.description,v,d.id,d.jsx,d.action,d.cancel]);const Pt=b.useCallback(()=>{ce(!0),fe(Vt.current),v(me=>me.filter(Le=>Le.toastId!==d.id)),setTimeout(()=>{k(d)},k_)},[d,k,v,Vt]);b.useEffect(()=>{if(d.promise&&be==="loading"||d.duration===1/0||d.type==="loading")return;let me;return j||h||qt?(()=>{if(_n.current<jn.current){const De=new Date().getTime()-jn.current;Ve.current=Ve.current-De}_n.current=new Date().getTime()})():(()=>{Ve.current!==1/0&&(jn.current=new Date().getTime(),me=setTimeout(()=>{d.onAutoClose==null||d.onAutoClose.call(d,d),Pt()},Ve.current))})(),()=>clearTimeout(me)},[j,h,d,be,qt,Pt]),b.useEffect(()=>{d.delete&&(Pt(),d.onDismiss==null||d.onDismiss.call(d,d))},[Pt,d.delete]);function Nn(){var me;if(G?.loading){var Le;return b.createElement("div",{className:Rt(V?.loader,d==null||(Le=d.classNames)==null?void 0:Le.loader,"sonner-loader"),"data-visible":be==="loading"},G.loading)}return b.createElement(n_,{className:Rt(V?.loader,d==null||(me=d.classNames)==null?void 0:me.loader),visible:be==="loading"})}const An=d.icon||G?.[be]||e_(be);var Pr,Qt;return b.createElement("li",{tabIndex:0,ref:X,className:Rt(T,Xn,V?.toast,d==null||(t=d.classNames)==null?void 0:t.toast,V?.default,V?.[be],d==null||(n=d.classNames)==null?void 0:n[be]),"data-sonner-toast":"","data-rich-colors":(Pr=d.richColors)!=null?Pr:_,"data-styled":!(d.jsx||d.unstyled||x),"data-mounted":F,"data-promise":!!d.promise,"data-swiped":re,"data-removed":Y,"data-visible":je,"data-y-position":Sn,"data-x-position":Cn,"data-index":y,"data-front":ue,"data-swiping":P,"data-dismissible":Me,"data-type":be,"data-invert":er,"data-swipe-out":de,"data-swipe-direction":N,"data-expanded":!!(j||K&&F),"data-testid":d.testId,style:{"--index":y,"--toasts-before":y,"--z-index":w.length-y,"--offset":`${Y?ye:Vt.current}px`,"--initial-height":K?"auto":`${Be}px`,...A,...d.style},onDragEnd:()=>{H(!1),le(null),Wt.current=null},onPointerDown:me=>{me.button!==2&&(un||!Me||(M.current=new Date,fe(Vt.current),me.target.setPointerCapture(me.pointerId),me.target.tagName!=="BUTTON"&&(H(!0),Wt.current={x:me.clientX,y:me.clientY})))},onPointerUp:()=>{var me,Le,xe;if(de||!Me)return;Wt.current=null;const De=Number(((me=X.current)==null?void 0:me.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),En=Number(((Le=X.current)==null?void 0:Le.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),ze=new Date().getTime()-((xe=M.current)==null?void 0:xe.getTime()),Qe=se==="x"?De:En,mn=Math.abs(Qe)/ze;if(Math.abs(Qe)>=w_||mn>.11){fe(Vt.current),d.onDismiss==null||d.onDismiss.call(d,d),R(se==="x"?De>0?"right":"left":En>0?"down":"up"),Pt(),W(!0);return}else{var at,ut;(at=X.current)==null||at.style.setProperty("--swipe-amount-x","0px"),(ut=X.current)==null||ut.style.setProperty("--swipe-amount-y","0px")}ie(!1),H(!1),le(null)},onPointerMove:me=>{var Le,xe,De;if(!Wt.current||!Me||((Le=window.getSelection())==null?void 0:Le.toString().length)>0)return;const ze=me.clientY-Wt.current.y,Qe=me.clientX-Wt.current.x;var mn;const at=(mn=e.swipeDirections)!=null?mn:j_(B);!se&&(Math.abs(Qe)>1||Math.abs(ze)>1)&&le(Math.abs(Qe)>Math.abs(ze)?"x":"y");let ut={x:0,y:0};const mt=et=>1/(1.5+Math.abs(et)/20);if(se==="y"){if(at.includes("top")||at.includes("bottom"))if(at.includes("top")&&ze<0||at.includes("bottom")&&ze>0)ut.y=ze;else{const et=ze*mt(ze);ut.y=Math.abs(et)<Math.abs(ze)?et:ze}}else if(se==="x"&&(at.includes("left")||at.includes("right")))if(at.includes("left")&&Qe<0||at.includes("right")&&Qe>0)ut.x=Qe;else{const et=Qe*mt(Qe);ut.x=Math.abs(et)<Math.abs(Qe)?et:Qe}(Math.abs(ut.x)>0||Math.abs(ut.y)>0)&&ie(!0),(xe=X.current)==null||xe.style.setProperty("--swipe-amount-x",`${ut.x}px`),(De=X.current)==null||De.style.setProperty("--swipe-amount-y",`${ut.y}px`)}},xt&&!d.jsx&&be!=="loading"?b.createElement("button",{"aria-label":D,"data-disabled":un,"data-close-button":!0,onClick:un||!Me?()=>{}:()=>{Pt(),d.onDismiss==null||d.onDismiss.call(d,d)},className:Rt(V?.closeButton,d==null||(s=d.classNames)==null?void 0:s.closeButton)},(Qt=G?.close)!=null?Qt:i_):null,(be||d.icon||d.promise)&&d.icon!==null&&(G?.[be]!==null||d.icon)?b.createElement("div",{"data-icon":"",className:Rt(V?.icon,d==null||(o=d.classNames)==null?void 0:o.icon)},d.promise||d.type==="loading"&&!d.icon?d.icon||Nn():null,d.type!=="loading"?An:null):null,b.createElement("div",{"data-content":"",className:Rt(V?.content,d==null||(a=d.classNames)==null?void 0:a.content)},b.createElement("div",{"data-title":"",className:Rt(V?.title,d==null||(i=d.classNames)==null?void 0:i.title)},d.jsx?d.jsx:typeof d.title=="function"?d.title():d.title),d.description?b.createElement("div",{"data-description":"",className:Rt(U,dn,V?.description,d==null||(c=d.classNames)==null?void 0:c.description)},typeof d.description=="function"?d.description():d.description):null),b.isValidElement(d.cancel)?d.cancel:d.cancel&&qr(d.cancel)?b.createElement("button",{"data-button":!0,"data-cancel":!0,style:d.cancelButtonStyle||E,onClick:me=>{qr(d.cancel)&&Me&&(d.cancel.onClick==null||d.cancel.onClick.call(d.cancel,me),Pt())},className:Rt(V?.cancelButton,d==null||(l=d.classNames)==null?void 0:l.cancelButton)},d.cancel.label):null,b.isValidElement(d.action)?d.action:d.action&&qr(d.action)?b.createElement("button",{"data-button":!0,"data-action":!0,style:d.actionButtonStyle||I,onClick:me=>{qr(d.action)&&(d.action.onClick==null||d.action.onClick.call(d.action,me),!me.defaultPrevented&&Pt())},className:Rt(V?.actionButton,d==null||(u=d.classNames)==null?void 0:u.actionButton)},d.action.label):null)};function Ac(){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 S_(e,t){const n={};return[e,t].forEach((s,o)=>{const a=o===1,i=a?"--mobile-offset":"--offset",c=a?v_:x_;function l(u){["top","right","bottom","left"].forEach(m=>{n[`${i}-${m}`]=typeof u=="number"?`${u}px`:u})}typeof s=="number"||typeof s=="string"?l(s):typeof s=="object"?["top","right","bottom","left"].forEach(u=>{s[u]===void 0?n[`${i}-${u}`]=c:n[`${i}-${u}`]=typeof s[u]=="number"?`${s[u]}px`:s[u]}):l(c)}),n}const C_=b.forwardRef(function(t,n){const{id:s,invert:o,position:a="bottom-right",hotkey:i=["altKey","KeyT"],expand:c,closeButton:l,className:u,offset:m,mobileOffset:d,theme:x="light",richColors:h,duration:v,style:p,visibleToasts:g=g_,toastOptions:y,dir:w=Ac(),gap:j=b_,icons:k,containerAriaLabel:_="Notifications"}=t,[S,A]=b.useState([]),E=b.useMemo(()=>s?S.filter(F=>F.toasterId===s):S.filter(F=>!F.toasterId),[S,s]),I=b.useMemo(()=>Array.from(new Set([a].concat(E.filter(F=>F.position).map(F=>F.position)))),[E,a]),[T,U]=b.useState([]),[L,B]=b.useState(!1),[z,K]=b.useState(!1),[V,G]=b.useState(x!=="system"?x:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),D=b.useRef(null),se=i.join("+").replace(/Key/g,"").replace(/Digit/g,""),le=b.useRef(null),N=b.useRef(!1),R=b.useCallback(F=>{A(Q=>{var Y;return(Y=Q.find(ce=>ce.id===F.id))!=null&&Y.delete||ct.dismiss(F.id),Q.filter(({id:ce})=>ce!==F.id)})},[]);return b.useEffect(()=>ct.subscribe(F=>{if(F.dismiss){requestAnimationFrame(()=>{A(Q=>Q.map(Y=>Y.id===F.id?{...Y,delete:!0}:Y))});return}setTimeout(()=>{ta.flushSync(()=>{A(Q=>{const Y=Q.findIndex(ce=>ce.id===F.id);return Y!==-1?[...Q.slice(0,Y),{...Q[Y],...F},...Q.slice(Y+1)]:[F,...Q]})})})}),[S]),b.useEffect(()=>{if(x!=="system"){G(x);return}if(x==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?G("dark"):G("light")),typeof window>"u")return;const F=window.matchMedia("(prefers-color-scheme: dark)");try{F.addEventListener("change",({matches:Q})=>{G(Q?"dark":"light")})}catch{F.addListener(({matches:Y})=>{try{G(Y?"dark":"light")}catch(ce){console.error(ce)}})}},[x]),b.useEffect(()=>{S.length<=1&&B(!1)},[S]),b.useEffect(()=>{const F=Q=>{var Y;if(i.every(H=>Q[H]||Q.code===H)){var P;B(!0),(P=D.current)==null||P.focus()}Q.code==="Escape"&&(document.activeElement===D.current||(Y=D.current)!=null&&Y.contains(document.activeElement))&&B(!1)};return document.addEventListener("keydown",F),()=>document.removeEventListener("keydown",F)},[i]),b.useEffect(()=>{if(D.current)return()=>{le.current&&(le.current.focus({preventScroll:!0}),le.current=null,N.current=!1)}},[D.current]),b.createElement("section",{ref:n,"aria-label":`${_} ${se}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},I.map((F,Q)=>{var Y;const[ce,P]=F.split("-");return E.length?b.createElement("ol",{key:F,dir:w==="auto"?Ac():w,tabIndex:-1,ref:D,className:u,"data-sonner-toaster":!0,"data-sonner-theme":V,"data-y-position":ce,"data-x-position":P,style:{"--front-toast-height":`${((Y=T[0])==null?void 0:Y.height)||0}px`,"--width":`${y_}px`,"--gap":`${j}px`,...p,...S_(m,d)},onBlur:H=>{N.current&&!H.currentTarget.contains(H.relatedTarget)&&(N.current=!1,le.current&&(le.current.focus({preventScroll:!0}),le.current=null))},onFocus:H=>{H.target instanceof HTMLElement&&H.target.dataset.dismissible==="false"||N.current||(N.current=!0,le.current=H.relatedTarget)},onMouseEnter:()=>B(!0),onMouseMove:()=>B(!0),onMouseLeave:()=>{z||B(!1)},onDragEnd:()=>B(!1),onPointerDown:H=>{H.target instanceof HTMLElement&&H.target.dataset.dismissible==="false"||K(!0)},onPointerUp:()=>K(!1)},E.filter(H=>!H.position&&Q===0||H.position===F).map((H,de)=>{var W,re;return b.createElement(__,{key:H.id,icons:k,index:de,toast:H,defaultRichColors:h,duration:(W=y?.duration)!=null?W:v,className:y?.className,descriptionClassName:y?.descriptionClassName,invert:o,visibleToasts:g,closeButton:(re=y?.closeButton)!=null?re:l,interacting:z,position:F,style:y?.style,unstyled:y?.unstyled,classNames:y?.classNames,cancelButtonStyle:y?.cancelButtonStyle,actionButtonStyle:y?.actionButtonStyle,closeButtonAriaLabel:y?.closeButtonAriaLabel,removeToast:R,toasts:E.filter(ie=>ie.position==H.position),heights:T.filter(ie=>ie.position==H.position),setHeights:U,expandByDefault:c,gap:j,expanded:L,swipeDirections:t.swipeDirections})})):null}))}),Ga=f.createContext(null);function N_(){const e=f.useContext(Ga);if(!e)throw new Error("useToast must be used within ToastProvider");return e}function Js(){return f.useContext(Ga)}function A_({children:e}){const t=f.useCallback(n=>{const s=n.title??"",o=n.description;h_(s||o||"Notification",{description:s?o:void 0,duration:n.durationMs??5e3,action:n.actionLabel&&n.onAction?{label:n.actionLabel,onClick:()=>n.onAction?.()}:void 0})},[]);return r.jsxs(Ga.Provider,{value:{toast:t},children:[e,r.jsx(C_,{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:Im,setPrototypeOf:Ec,isFrozen:E_,getPrototypeOf:I_,getOwnPropertyDescriptor:T_}=Object;let{freeze:st,seal:bt,create:ts}=Object,{apply:Qo,construct:Jo}=typeof Reflect<"u"&&Reflect;st||(st=function(t){return t});bt||(bt=function(t){return t});Qo||(Qo=function(t,n){for(var s=arguments.length,o=new Array(s>2?s-2:0),a=2;a<s;a++)o[a-2]=arguments[a];return t.apply(n,o)});Jo||(Jo=function(t){for(var n=arguments.length,s=new Array(n>1?n-1:0),o=1;o<n;o++)s[o-1]=arguments[o];return new t(...s)});const Hr=ot(Array.prototype.forEach),P_=ot(Array.prototype.lastIndexOf),Ic=ot(Array.prototype.pop),sr=ot(Array.prototype.push),R_=ot(Array.prototype.splice),ns=ot(String.prototype.toLowerCase),jo=ot(String.prototype.toString),_o=ot(String.prototype.match),or=ot(String.prototype.replace),O_=ot(String.prototype.indexOf),M_=ot(String.prototype.trim),ft=ot(Object.prototype.hasOwnProperty),tt=ot(RegExp.prototype.test),ar=L_(TypeError);function ot(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,s=new Array(n>1?n-1:0),o=1;o<n;o++)s[o-1]=arguments[o];return Qo(e,t,s)}}function L_(e){return function(){for(var t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];return Jo(e,n)}}function he(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ns;Ec&&Ec(e,null);let s=t.length;for(;s--;){let o=t[s];if(typeof o=="string"){const a=n(o);a!==o&&(E_(t)||(t[s]=a),o=a)}e[o]=!0}return e}function D_(e){for(let t=0;t<e.length;t++)ft(e,t)||(e[t]=null);return e}function Mt(e){const t=ts(null);for(const[n,s]of Im(e))ft(e,n)&&(Array.isArray(s)?t[n]=D_(s):s&&typeof s=="object"&&s.constructor===Object?t[n]=Mt(s):t[n]=s);return t}function ir(e,t){for(;e!==null;){const s=T_(e,t);if(s){if(s.get)return ot(s.get);if(typeof s.value=="function")return ot(s.value)}e=I_(e)}function n(){return null}return n}const Tc=st(["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"]),So=st(["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"]),Co=st(["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"]),z_=st(["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"]),No=st(["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"]),$_=st(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Pc=st(["#text"]),Rc=st(["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"]),Ao=st(["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"]),Oc=st(["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"]),Zr=st(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),F_=bt(/\{\{[\w\W]*|[\w\W]*\}\}/gm),U_=bt(/<%[\w\W]*|[\w\W]*%>/gm),B_=bt(/\$\{[\w\W]*/gm),V_=bt(/^data-[\-\w.\u00B7-\uFFFF]+$/),W_=bt(/^aria-[\-\w]+$/),Tm=bt(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),q_=bt(/^(?:\w+script|data):/i),H_=bt(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Pm=bt(/^html$/i),Z_=bt(/^[a-z][.\w]*(-[.\w]+)+$/i);var Mc=Object.freeze({__proto__:null,ARIA_ATTR:W_,ATTR_WHITESPACE:H_,CUSTOM_ELEMENT:Z_,DATA_ATTR:V_,DOCTYPE_NAME:Pm,ERB_EXPR:U_,IS_ALLOWED_URI:Tm,IS_SCRIPT_OR_DATA:q_,MUSTACHE_EXPR:F_,TMPLIT_EXPR:B_});const cr={element:1,text:3,progressingInstruction:7,comment:8,document:9},G_=function(){return typeof window>"u"?null:window},Y_=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let s=null;const o="data-tt-policy-suffix";n&&n.hasAttribute(o)&&(s=n.getAttribute(o));const a="dompurify"+(s?"#"+s:"");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}},Lc=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Rm(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:G_();const t=oe=>Rm(oe);if(t.version="3.3.2",t.removed=[],!e||!e.document||e.document.nodeType!==cr.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e;const s=n,o=s.currentScript,{DocumentFragment:a,HTMLTemplateElement:i,Node:c,Element:l,NodeFilter:u,NamedNodeMap:m=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:d,DOMParser:x,trustedTypes:h}=e,v=l.prototype,p=ir(v,"cloneNode"),g=ir(v,"remove"),y=ir(v,"nextSibling"),w=ir(v,"childNodes"),j=ir(v,"parentNode");if(typeof i=="function"){const oe=n.createElement("template");oe.content&&oe.content.ownerDocument&&(n=oe.content.ownerDocument)}let k,_="";const{implementation:S,createNodeIterator:A,createDocumentFragment:E,getElementsByTagName:I}=n,{importNode:T}=s;let U=Lc();t.isSupported=typeof Im=="function"&&typeof j=="function"&&S&&S.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:L,ERB_EXPR:B,TMPLIT_EXPR:z,DATA_ATTR:K,ARIA_ATTR:V,IS_SCRIPT_OR_DATA:G,ATTR_WHITESPACE:D,CUSTOM_ELEMENT:se}=Mc;let{IS_ALLOWED_URI:le}=Mc,N=null;const R=he({},[...Tc,...So,...Co,...No,...Pc]);let F=null;const Q=he({},[...Rc,...Ao,...Oc,...Zr]);let Y=Object.seal(ts(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}})),ce=null,P=null;const H=Object.seal(ts(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let de=!0,W=!0,re=!1,ie=!0,ye=!1,fe=!0,Be=!1,Ke=!1,Ve=!1,M=!1,X=!1,ue=!1,je=!0,be=!1;const Me="user-content-";let Xn=!0,dn=!1,kt={},xt=null;const kn=he({},["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 jn=null;const Vt=he({},["audio","video","img","source","image","track"]);let _n=null;const Wt=he({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Sn="http://www.w3.org/1998/Math/MathML",Cn="http://www.w3.org/2000/svg",vt="http://www.w3.org/1999/xhtml";let qt=vt,er=!1,un=null;const Pt=he({},[Sn,Cn,vt],jo);let Nn=he({},["mi","mo","mn","ms","mtext"]),An=he({},["annotation-xml"]);const Pr=he({},["title","style","font","a","script"]);let Qt=null;const me=["application/xhtml+xml","text/html"],Le="text/html";let xe=null,De=null;const En=n.createElement("form"),ze=function(C){return C instanceof RegExp||C instanceof Function},Qe=function(){let C=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(De&&De===C)){if((!C||typeof C!="object")&&(C={}),C=Mt(C),Qt=me.indexOf(C.PARSER_MEDIA_TYPE)===-1?Le:C.PARSER_MEDIA_TYPE,xe=Qt==="application/xhtml+xml"?jo:ns,N=ft(C,"ALLOWED_TAGS")?he({},C.ALLOWED_TAGS,xe):R,F=ft(C,"ALLOWED_ATTR")?he({},C.ALLOWED_ATTR,xe):Q,un=ft(C,"ALLOWED_NAMESPACES")?he({},C.ALLOWED_NAMESPACES,jo):Pt,_n=ft(C,"ADD_URI_SAFE_ATTR")?he(Mt(Wt),C.ADD_URI_SAFE_ATTR,xe):Wt,jn=ft(C,"ADD_DATA_URI_TAGS")?he(Mt(Vt),C.ADD_DATA_URI_TAGS,xe):Vt,xt=ft(C,"FORBID_CONTENTS")?he({},C.FORBID_CONTENTS,xe):kn,ce=ft(C,"FORBID_TAGS")?he({},C.FORBID_TAGS,xe):Mt({}),P=ft(C,"FORBID_ATTR")?he({},C.FORBID_ATTR,xe):Mt({}),kt=ft(C,"USE_PROFILES")?C.USE_PROFILES:!1,de=C.ALLOW_ARIA_ATTR!==!1,W=C.ALLOW_DATA_ATTR!==!1,re=C.ALLOW_UNKNOWN_PROTOCOLS||!1,ie=C.ALLOW_SELF_CLOSE_IN_ATTR!==!1,ye=C.SAFE_FOR_TEMPLATES||!1,fe=C.SAFE_FOR_XML!==!1,Be=C.WHOLE_DOCUMENT||!1,M=C.RETURN_DOM||!1,X=C.RETURN_DOM_FRAGMENT||!1,ue=C.RETURN_TRUSTED_TYPE||!1,Ve=C.FORCE_BODY||!1,je=C.SANITIZE_DOM!==!1,be=C.SANITIZE_NAMED_PROPS||!1,Xn=C.KEEP_CONTENT!==!1,dn=C.IN_PLACE||!1,le=C.ALLOWED_URI_REGEXP||Tm,qt=C.NAMESPACE||vt,Nn=C.MATHML_TEXT_INTEGRATION_POINTS||Nn,An=C.HTML_INTEGRATION_POINTS||An,Y=C.CUSTOM_ELEMENT_HANDLING||{},C.CUSTOM_ELEMENT_HANDLING&&ze(C.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Y.tagNameCheck=C.CUSTOM_ELEMENT_HANDLING.tagNameCheck),C.CUSTOM_ELEMENT_HANDLING&&ze(C.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Y.attributeNameCheck=C.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),C.CUSTOM_ELEMENT_HANDLING&&typeof C.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(Y.allowCustomizedBuiltInElements=C.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),ye&&(W=!1),X&&(M=!0),kt&&(N=he({},Pc),F=ts(null),kt.html===!0&&(he(N,Tc),he(F,Rc)),kt.svg===!0&&(he(N,So),he(F,Ao),he(F,Zr)),kt.svgFilters===!0&&(he(N,Co),he(F,Ao),he(F,Zr)),kt.mathMl===!0&&(he(N,No),he(F,Oc),he(F,Zr))),ft(C,"ADD_TAGS")||(H.tagCheck=null),ft(C,"ADD_ATTR")||(H.attributeCheck=null),C.ADD_TAGS&&(typeof C.ADD_TAGS=="function"?H.tagCheck=C.ADD_TAGS:(N===R&&(N=Mt(N)),he(N,C.ADD_TAGS,xe))),C.ADD_ATTR&&(typeof C.ADD_ATTR=="function"?H.attributeCheck=C.ADD_ATTR:(F===Q&&(F=Mt(F)),he(F,C.ADD_ATTR,xe))),C.ADD_URI_SAFE_ATTR&&he(_n,C.ADD_URI_SAFE_ATTR,xe),C.FORBID_CONTENTS&&(xt===kn&&(xt=Mt(xt)),he(xt,C.FORBID_CONTENTS,xe)),C.ADD_FORBID_CONTENTS&&(xt===kn&&(xt=Mt(xt)),he(xt,C.ADD_FORBID_CONTENTS,xe)),Xn&&(N["#text"]=!0),Be&&he(N,["html","head","body"]),N.table&&(he(N,["tbody"]),delete ce.tbody),C.TRUSTED_TYPES_POLICY){if(typeof C.TRUSTED_TYPES_POLICY.createHTML!="function")throw ar('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof C.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw ar('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');k=C.TRUSTED_TYPES_POLICY,_=k.createHTML("")}else k===void 0&&(k=Y_(h,o)),k!==null&&typeof _=="string"&&(_=k.createHTML(""));st&&st(C),De=C}},mn=he({},[...So,...Co,...z_]),at=he({},[...No,...$_]),ut=function(C){let q=j(C);(!q||!q.tagName)&&(q={namespaceURI:qt,tagName:"template"});const ne=ns(C.tagName),_e=ns(q.tagName);return un[C.namespaceURI]?C.namespaceURI===Cn?q.namespaceURI===vt?ne==="svg":q.namespaceURI===Sn?ne==="svg"&&(_e==="annotation-xml"||Nn[_e]):!!mn[ne]:C.namespaceURI===Sn?q.namespaceURI===vt?ne==="math":q.namespaceURI===Cn?ne==="math"&&An[_e]:!!at[ne]:C.namespaceURI===vt?q.namespaceURI===Cn&&!An[_e]||q.namespaceURI===Sn&&!Nn[_e]?!1:!at[ne]&&(Pr[ne]||!mn[ne]):!!(Qt==="application/xhtml+xml"&&un[C.namespaceURI]):!1},mt=function(C){sr(t.removed,{element:C});try{j(C).removeChild(C)}catch{g(C)}},et=function(C,q){try{sr(t.removed,{attribute:q.getAttributeNode(C),from:q})}catch{sr(t.removed,{attribute:null,from:q})}if(q.removeAttribute(C),C==="is")if(M||X)try{mt(q)}catch{}else try{q.setAttribute(C,"")}catch{}},ro=function(C){let q=null,ne=null;if(Ve)C="<remove></remove>"+C;else{const $e=_o(C,/^[\r\n\t ]+/);ne=$e&&$e[0]}Qt==="application/xhtml+xml"&&qt===vt&&(C='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+C+"</body></html>");const _e=k?k.createHTML(C):C;if(qt===vt)try{q=new x().parseFromString(_e,Qt)}catch{}if(!q||!q.documentElement){q=S.createDocument(qt,"template",null);try{q.documentElement.innerHTML=er?_:_e}catch{}}const Je=q.body||q.documentElement;return C&&ne&&Je.insertBefore(n.createTextNode(ne),Je.childNodes[0]||null),qt===vt?I.call(q,Be?"html":"body")[0]:Be?q.documentElement:Je},ii=function(C){return A.call(C.ownerDocument||C,C,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},so=function(C){return C instanceof d&&(typeof C.nodeName!="string"||typeof C.textContent!="string"||typeof C.removeChild!="function"||!(C.attributes instanceof m)||typeof C.removeAttribute!="function"||typeof C.setAttribute!="function"||typeof C.namespaceURI!="string"||typeof C.insertBefore!="function"||typeof C.hasChildNodes!="function")},ci=function(C){return typeof c=="function"&&C instanceof c};function Ht(oe,C,q){Hr(oe,ne=>{ne.call(t,C,q,De)})}const li=function(C){let q=null;if(Ht(U.beforeSanitizeElements,C,null),so(C))return mt(C),!0;const ne=xe(C.nodeName);if(Ht(U.uponSanitizeElement,C,{tagName:ne,allowedTags:N}),fe&&C.hasChildNodes()&&!ci(C.firstElementChild)&&tt(/<[/\w!]/g,C.innerHTML)&&tt(/<[/\w!]/g,C.textContent)||C.nodeType===cr.progressingInstruction||fe&&C.nodeType===cr.comment&&tt(/<[/\w]/g,C.data))return mt(C),!0;if(!(H.tagCheck instanceof Function&&H.tagCheck(ne))&&(!N[ne]||ce[ne])){if(!ce[ne]&&ui(ne)&&(Y.tagNameCheck instanceof RegExp&&tt(Y.tagNameCheck,ne)||Y.tagNameCheck instanceof Function&&Y.tagNameCheck(ne)))return!1;if(Xn&&!xt[ne]){const _e=j(C)||C.parentNode,Je=w(C)||C.childNodes;if(Je&&_e){const $e=Je.length;for(let it=$e-1;it>=0;--it){const Zt=p(Je[it],!0);Zt.__removalCount=(C.__removalCount||0)+1,_e.insertBefore(Zt,y(C))}}}return mt(C),!0}return C instanceof l&&!ut(C)||(ne==="noscript"||ne==="noembed"||ne==="noframes")&&tt(/<\/no(script|embed|frames)/i,C.innerHTML)?(mt(C),!0):(ye&&C.nodeType===cr.text&&(q=C.textContent,Hr([L,B,z],_e=>{q=or(q,_e," ")}),C.textContent!==q&&(sr(t.removed,{element:C.cloneNode()}),C.textContent=q)),Ht(U.afterSanitizeElements,C,null),!1)},di=function(C,q,ne){if(P[q]||je&&(q==="id"||q==="name")&&(ne in n||ne in En))return!1;if(!(W&&!P[q]&&tt(K,q))){if(!(de&&tt(V,q))){if(!(H.attributeCheck instanceof Function&&H.attributeCheck(q,C))){if(!F[q]||P[q]){if(!(ui(C)&&(Y.tagNameCheck instanceof RegExp&&tt(Y.tagNameCheck,C)||Y.tagNameCheck instanceof Function&&Y.tagNameCheck(C))&&(Y.attributeNameCheck instanceof RegExp&&tt(Y.attributeNameCheck,q)||Y.attributeNameCheck instanceof Function&&Y.attributeNameCheck(q,C))||q==="is"&&Y.allowCustomizedBuiltInElements&&(Y.tagNameCheck instanceof RegExp&&tt(Y.tagNameCheck,ne)||Y.tagNameCheck instanceof Function&&Y.tagNameCheck(ne))))return!1}else if(!_n[q]){if(!tt(le,or(ne,D,""))){if(!((q==="src"||q==="xlink:href"||q==="href")&&C!=="script"&&O_(ne,"data:")===0&&jn[C])){if(!(re&&!tt(G,or(ne,D,"")))){if(ne)return!1}}}}}}}return!0},ui=function(C){return C!=="annotation-xml"&&_o(C,se)},mi=function(C){Ht(U.beforeSanitizeAttributes,C,null);const{attributes:q}=C;if(!q||so(C))return;const ne={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:F,forceKeepAttr:void 0};let _e=q.length;for(;_e--;){const Je=q[_e],{name:$e,namespaceURI:it,value:Zt}=Je,In=xe($e),oo=Zt;let We=$e==="value"?oo:M_(oo);if(ne.attrName=In,ne.attrValue=We,ne.keepAttr=!0,ne.forceKeepAttr=void 0,Ht(U.uponSanitizeAttribute,C,ne),We=ne.attrValue,be&&(In==="id"||In==="name")&&(et($e,C),We=Me+We),fe&&tt(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,We)){et($e,C);continue}if(In==="attributename"&&_o(We,"href")){et($e,C);continue}if(ne.forceKeepAttr)continue;if(!ne.keepAttr){et($e,C);continue}if(!ie&&tt(/\/>/i,We)){et($e,C);continue}ye&&Hr([L,B,z],pi=>{We=or(We,pi," ")});const fi=xe(C.nodeName);if(!di(fi,In,We)){et($e,C);continue}if(k&&typeof h=="object"&&typeof h.getAttributeType=="function"&&!it)switch(h.getAttributeType(fi,In)){case"TrustedHTML":{We=k.createHTML(We);break}case"TrustedScriptURL":{We=k.createScriptURL(We);break}}if(We!==oo)try{it?C.setAttributeNS(it,$e,We):C.setAttribute($e,We),so(C)?mt(C):Ic(t.removed)}catch{et($e,C)}}Ht(U.afterSanitizeAttributes,C,null)},Qm=function oe(C){let q=null;const ne=ii(C);for(Ht(U.beforeSanitizeShadowDOM,C,null);q=ne.nextNode();)Ht(U.uponSanitizeShadowNode,q,null),li(q),mi(q),q.content instanceof a&&oe(q.content);Ht(U.afterSanitizeShadowDOM,C,null)};return t.sanitize=function(oe){let C=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},q=null,ne=null,_e=null,Je=null;if(er=!oe,er&&(oe="<!-->"),typeof oe!="string"&&!ci(oe))if(typeof oe.toString=="function"){if(oe=oe.toString(),typeof oe!="string")throw ar("dirty is not a string, aborting")}else throw ar("toString is not a function");if(!t.isSupported)return oe;if(Ke||Qe(C),t.removed=[],typeof oe=="string"&&(dn=!1),dn){if(oe.nodeName){const Zt=xe(oe.nodeName);if(!N[Zt]||ce[Zt])throw ar("root node is forbidden and cannot be sanitized in-place")}}else if(oe instanceof c)q=ro("<!---->"),ne=q.ownerDocument.importNode(oe,!0),ne.nodeType===cr.element&&ne.nodeName==="BODY"||ne.nodeName==="HTML"?q=ne:q.appendChild(ne);else{if(!M&&!ye&&!Be&&oe.indexOf("<")===-1)return k&&ue?k.createHTML(oe):oe;if(q=ro(oe),!q)return M?null:ue?_:""}q&&Ve&&mt(q.firstChild);const $e=ii(dn?oe:q);for(;_e=$e.nextNode();)li(_e),mi(_e),_e.content instanceof a&&Qm(_e.content);if(dn)return oe;if(M){if(X)for(Je=E.call(q.ownerDocument);q.firstChild;)Je.appendChild(q.firstChild);else Je=q;return(F.shadowroot||F.shadowrootmode)&&(Je=T.call(s,Je,!0)),Je}let it=Be?q.outerHTML:q.innerHTML;return Be&&N["!doctype"]&&q.ownerDocument&&q.ownerDocument.doctype&&q.ownerDocument.doctype.name&&tt(Pm,q.ownerDocument.doctype.name)&&(it="<!DOCTYPE "+q.ownerDocument.doctype.name+`>
84
+ `+it),ye&&Hr([L,B,z],Zt=>{it=or(it,Zt," ")}),k&&ue?k.createHTML(it):it},t.setConfig=function(){let oe=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Qe(oe),Ke=!0},t.clearConfig=function(){De=null,Ke=!1},t.isValidAttribute=function(oe,C,q){De||Qe({});const ne=xe(oe),_e=xe(C);return di(ne,_e,q)},t.addHook=function(oe,C){typeof C=="function"&&sr(U[oe],C)},t.removeHook=function(oe,C){if(C!==void 0){const q=P_(U[oe],C);return q===-1?void 0:R_(U[oe],q,1)[0]}return Ic(U[oe])},t.removeHooks=function(oe){U[oe]=[]},t.removeAllHooks=function(){U=Lc()},t}var Eo=Rm();function Om({faq:e,className:t,expanded:n,defaultExpanded:s=!1,onExpandedChange:o,showKeywords:a=!1,dangerouslySetAnswerHTML:i=!1}){const[c,l]=f.useState(s),u=n!==void 0,m=u?n:c,d=()=>{const x=!m;u||l(x),o?.(x)};return r.jsxs("div",{className:O("border border-neutral-200 rounded-lg overflow-hidden dark:border-neutral-800",t),children:[r.jsxs("button",{type:"button",onClick:d,className:O("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":m,children:[r.jsx("span",{className:"font-medium text-neutral-900 dark:text-neutral-100 pr-4",children:e.question}),r.jsx("svg",{className:O("w-5 h-5 text-neutral-500 transition-transform duration-200 flex-shrink-0",m&&"rotate-180"),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),m&&r.jsxs("div",{className:"px-4 py-3 bg-white dark:bg-neutral-950",children:[i?r.jsx("div",{className:"text-sm text-neutral-600 dark:text-neutral-400 prose prose-sm dark:prose-invert max-w-none",dangerouslySetInnerHTML:{__html:(()=>{Eo.addHook("afterSanitizeAttributes",h=>{h.tagName==="A"&&h.setAttribute("rel","noopener noreferrer")});const x=Eo.sanitize(e.answer,{ALLOWED_TAGS:["b","i","em","strong","a","p","br","ul","ol","li"],ALLOWED_ATTR:["href","target","rel"]});return Eo.removeAllHooks(),x})()}}):r.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&&r.jsx("div",{className:"mt-3 flex flex-wrap gap-1",children:e.keywords.map(x=>r.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:x},x))})]})]})}function K_({faqs:e,className:t,accordion:n=!1,showKeywords:s=!1,dangerouslySetAnswerHTML:o=!1,emptyMessage:a="No FAQs available."}){const[i,c]=f.useState(null),l=e.filter(u=>u.active!==!1);return l.length===0?r.jsx("div",{className:O("text-center py-8 text-neutral-500 dark:text-neutral-400",t),children:a}):r.jsx("div",{className:O("space-y-2",t),children:l.map(u=>r.jsx(Om,{faq:u,showKeywords:s,dangerouslySetAnswerHTML:o,expanded:n?i===u.id:void 0,onExpandedChange:n?m=>c(m?u.id:null):void 0},u.id))})}function Fe({amount:e,currency:t}){return new Intl.NumberFormat(void 0,{style:"currency",currency:t}).format(e)}function Xs({amount:e,currency:t,compareAt:n,className:s,size:o="default"}){const a=typeof n=="number"&&n>e;return r.jsxs("div",{className:O("flex items-baseline gap-2 tabular-nums",s),children:[r.jsx("span",{className:O("font-semibold",o==="sm"?"text-sm":"text-base"),children:Fe({amount:e,currency:t})}),a?r.jsx("span",{className:O("text-neutral-500 line-through dark:text-neutral-400",o==="sm"?"text-xs":"text-sm"),children:Fe({amount:n,currency:t})}):null]})}const Q_={securities:{label:"Security",className:"bg-blue-100 text-blue-800 dark:bg-blue-900/50 dark:text-blue-200"},commodities:{label:"Commodity",className:"bg-amber-100 text-amber-800 dark:bg-amber-900/50 dark:text-amber-200"},property:{label:"Property",className:"bg-emerald-100 text-emerald-800 dark:bg-emerald-900/50 dark:text-emerald-200"},collectibles:{label:"Collectible",className:"bg-purple-100 text-purple-800 dark:bg-purple-900/50 dark:text-purple-200"}},J_={label:"Tokenized Asset",className:"bg-neutral-100 text-neutral-700 dark:bg-neutral-800 dark:text-neutral-300"};function Ya({assetClass:e}){const{label:t,className:n}=Q_[e.toLowerCase()]??J_;return r.jsx(ht,{className:n,children:t})}const Dc={large:"aspect-[4/5]",square:"aspect-square",compact:"aspect-[3/4]"},zc={center:"object-center",top:"object-top",bottom:"object-bottom",left:"object-left",right:"object-right"};function Mm({product:e,href:t,onAddToCart:n,onQuickView:s,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 r.jsxs(Xe,{className:O("group flex h-full flex-col overflow-hidden rounded-2xl",o),children:[r.jsxs("div",{className:"relative",children:[t?r.jsx("a",{href:t,className:"block","aria-label":`View ${e.title}`,children:r.jsx("div",{className:O("overflow-hidden bg-neutral-100 dark:bg-neutral-900",Dc[a]),children:r.jsx("img",{src:e.images[0]?.url,alt:e.images[0]?.alt??e.title,className:O("h-full w-full object-cover transition-transform duration-300 group-hover:scale-[1.03]",zc[i]),loading:"lazy"})})}):r.jsx("div",{className:O("overflow-hidden bg-neutral-100 dark:bg-neutral-900",Dc[a]),children:r.jsx("img",{src:e.images[0]?.url,alt:e.images[0]?.alt??e.title,className:O("h-full w-full object-cover transition-transform duration-300 group-hover:scale-[1.03]",zc[i]),loading:"lazy"})}),a!=="compact"&&e.tags?.length?r.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 flex gap-1 p-3",children:e.tags.slice(0,2).map(u=>r.jsx(ht,{className:"pointer-events-none bg-white/90 text-neutral-900 backdrop-blur dark:bg-neutral-950/80 dark:text-neutral-50",children:u},u))}):null,e.tokenizedAssetConfig?r.jsx("div",{className:"pointer-events-none absolute right-3 bottom-3",children:r.jsx(Ya,{assetClass:e.tokenizedAssetConfig?.assetClass??""})}):null,c?r.jsx("div",{className:"pointer-events-none absolute left-3 top-3",children:r.jsx(ht,{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?r.jsx("div",{className:"pointer-events-none absolute left-3 top-3",children:r.jsxs(ht,{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,s?r.jsx("div",{className:"absolute right-3 top-3 opacity-0 transition-opacity group-hover:opacity-100",children:r.jsx(J,{type:"button",size:"sm",variant:"secondary",className:"h-9",onClick:()=>s(e),children:"Quick view"})}):null]}),r.jsxs("div",{className:O("flex flex-1 flex-col",a==="compact"?"p-3":"p-4"),children:[r.jsx("div",{className:"flex items-start justify-between gap-3",children:r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:O("line-clamp-1 font-medium text-neutral-950 dark:text-neutral-50",a==="compact"?"text-xs":"text-sm"),children:e.title}),r.jsx("div",{className:"mt-1",children:r.jsx(Xs,{amount:e.price,currency:e.currency,compareAt:e.compareAtPrice,size:a==="compact"?"sm":"default"})})]})}),a==="large"&&r.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}),r.jsx("div",{className:O("mt-auto",a==="compact"?"pt-3":"pt-4"),children:r.jsx(J,{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 eo({products:e,columns:t,onAddToCart:n,onQuickView:s,getProductHref:o,className:a,layout:i,imageCrop:c}){const l=t?.base??2,u=t?.md??3,m=t?.lg??3,d={1:"grid-cols-1",2:"grid-cols-2",3:"grid-cols-3",4:"grid-cols-4"},x={1:"md:grid-cols-1",2:"md:grid-cols-2",3:"md:grid-cols-3",4:"md:grid-cols-4"},h={1:"lg:grid-cols-1",2:"lg:grid-cols-2",3:"lg:grid-cols-3",4:"lg:grid-cols-4"},v=O("grid gap-4",d[Math.min(4,Math.max(1,l))],x[Math.min(4,Math.max(1,u))],h[Math.min(4,Math.max(1,m))]);return r.jsx("div",{className:O(v,a),children:e.map(p=>r.jsx(Mm,{product:p,href:o?o(p):void 0,onAddToCart:n,onQuickView:s,layout:i,imageCrop:c},p.id))})}function Ka({images:e,className:t}){const[n,s]=f.useState(0),o=e[n];return e.length===0?r.jsx("div",{className:O("aspect-square w-full rounded-xl border border-neutral-200 bg-neutral-100 dark:border-neutral-800 dark:bg-neutral-900",t)}):r.jsxs("div",{className:O("space-y-3",t),children:[r.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:r.jsx("img",{src:o?.url,alt:o?.alt??"",className:"h-full w-full object-cover",loading:"eager"})}),e.length>1?r.jsx("div",{className:"flex gap-2 overflow-x-auto pb-1",children:e.map((a,i)=>{const c=i===n;return r.jsx("button",{type:"button",className:O("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:()=>s(i),"aria-label":`View image ${i+1}`,children:r.jsx("img",{src:a.url,alt:a.alt??"",className:"h-full w-full object-cover",loading:"lazy"})},a.url)})}):null]})}function X_(e){const t=new Set;for(const n of e)for(const s of Object.keys(n.options))t.add(s);return Array.from(t)}function eS(e,t){const n=new Set;for(const s of e){const o=s.options[t];o&&n.add(o)}return Array.from(n)}function $c(e,t){return e.find(n=>Object.entries(t).every(([s,o])=>n.options[s]===o))??null}function Lm(e){return e.inventoryStatus==="out_of_stock"||typeof e.inventoryQuantity=="number"&&e.inventoryQuantity<=0}function tS(e){return e.inventoryStatus==="low"||typeof e.inventoryQuantity=="number"&&e.inventoryQuantity>0&&e.inventoryQuantity<=5}function nS(e){const t=Lm(e),n=!t&&tS(e),s=typeof e.inventoryQuantity=="number"?e.inventoryQuantity:void 0;return{isOutOfStock:t,isLow:n,quantity:s}}function rS(e,t,n,s){const o={...t,[n]:s},a=e.filter(i=>Object.entries(o).every(([c,l])=>i.options[c]===l));return a.length===0?!1:a.some(i=>!Lm(i))}function Qa({product:e,value:t,onChange:n,className:s,showInventory:o=!0,disableOutOfStock:a=!1}){const i=f.useMemo(()=>e.variants??[],[e.variants]),c=f.useMemo(()=>X_(i),[i]),l=f.useMemo(()=>$c(i,t.selectedOptions),[i,t.selectedOptions]),u=f.useMemo(()=>l?nS(l):null,[l]);return i.length===0||c.length===0?null:r.jsxs("div",{className:O("space-y-4",s),children:[c.map(m=>{const d=eS(i,m),x=t.selectedOptions[m];return r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-baseline justify-between",children:[r.jsx("div",{className:"text-sm font-medium text-neutral-950 dark:text-neutral-50",children:m}),r.jsx("div",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:x||"Select"})]}),r.jsx("div",{className:"flex flex-wrap gap-2",children:d.map(h=>{const v=h===x,p=rS(i,t.selectedOptions,m,h),g=a&&!p;return r.jsxs(J,{type:"button",size:"sm",variant:v?"default":"outline",onClick:()=>{const y={...t.selectedOptions,[m]:h},w=$c(i,y);n({selectedOptions:y,variant:w})},"aria-pressed":v,disabled:g,className:O(!p&&!g&&"opacity-50 line-through"),children:[h,!p&&!g&&r.jsx("span",{className:"ml-1 text-[10px] opacity-70",children:"(Out)"})]},h)})})]},m)}),o&&l&&u&&r.jsx("div",{className:"pt-2",children:u.isOutOfStock?r.jsx("div",{className:"text-sm font-medium text-red-600 dark:text-red-400",children:"Out of stock"}):u.isLow&&u.quantity!==void 0?r.jsxs("div",{className:"text-sm text-amber-600 dark:text-amber-400",children:["Only ",r.jsx("span",{className:"font-semibold",children:u.quantity})," left"]}):null})]})}function Ja({qty:e,onChange:t,min:n=1,max:s,className:o}){const a=Number.isFinite(e)?Math.max(n,Math.floor(e)):n,i=a>n,c=typeof s=="number"?a<s:!0;return r.jsxs("div",{className:O("flex items-center gap-2",o),children:[r.jsx(J,{type:"button",size:"icon",variant:"outline",onClick:()=>t(Math.max(n,a-1)),disabled:!i,"aria-label":"Decrease quantity",children:"-"}),r.jsx(Te,{inputMode:"numeric",pattern:"[0-9]*",value:String(a),onChange:l=>{const u=Math.floor(Number(l.target.value));if(!Number.isFinite(u))return;const m=Math.max(n,typeof s=="number"?Math.min(s,u):u);t(m)},className:"h-10 w-16 text-center","aria-label":"Quantity"}),r.jsx(J,{type:"button",size:"icon",variant:"outline",onClick:()=>t(a+1),disabled:!c,"aria-label":"Increase quantity",children:"+"})]})}function Xa({product:e,open:t,onOpenChange:n,productHref:s,onAddToCart:o,className:a}){const[i,c]=f.useState(1),[l,u]=f.useState({selectedOptions:{},variant:null});if(f.useEffect(()=>{if(e)if(c(1),e.variants?.length){const p=e.variants[0];u({selectedOptions:{...p.options},variant:p})}else u({selectedOptions:{},variant:null})},[e?.id]),!e)return null;const m=l.variant?.price??e.price,d=l.variant?.compareAtPrice??e.compareAtPrice,x=l.variant?.inventoryStatus==="out_of_stock"||typeof l.variant?.inventoryQuantity=="number"&&l.variant.inventoryQuantity<=0,h=e.inventoryStatus==="out_of_stock"||typeof e.inventoryQuantity=="number"&&e.inventoryQuantity<=0,v=l.variant?x:h;return r.jsx(Ma,{open:t,onOpenChange:n,children:r.jsxs(Us,{className:O("max-w-3xl",a),children:[r.jsx(Da,{children:r.jsxs(Bs,{className:"flex items-center justify-between gap-3",children:[r.jsx("span",{className:"truncate",children:e.title}),s?r.jsx("a",{href:s(e.slug),className:"text-sm font-normal text-neutral-700 hover:underline dark:text-neutral-300",children:"View details"}):null]})}),r.jsxs("div",{className:"grid gap-8 md:grid-cols-2",children:[r.jsx(Ka,{images:e.images}),r.jsxs("div",{className:"space-y-5",children:[r.jsxs("div",{children:[r.jsx(Xs,{amount:m,currency:e.currency,compareAt:d}),r.jsx("p",{className:"mt-3 text-sm text-neutral-600 dark:text-neutral-400",children:e.description})]}),r.jsx(Qa,{product:e,value:{selectedOptions:l.selectedOptions,variantId:l.variant?.id},onChange:p=>u(p)}),r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsx(Ja,{qty:i,onChange:c}),r.jsx(J,{type:"button",className:"flex-1",disabled:v,onClick:()=>{o(e,l.variant,i),n(!1)},children:v?"Out of stock":"Add to cart"})]}),r.jsx("div",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:v?"Out of stock":"In stock"})]})]})]})})}function Xo({categories:e,activeSlug:t,onSelect:n,className:s}){return r.jsx("nav",{className:O("space-y-1",s),"aria-label":"Categories",children:e.map(o=>{const a=t===o.slug;return r.jsxs("button",{type:"button",className:O("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:[r.jsx("span",{className:"truncate",children:o.name}),r.jsx("span",{className:"text-xs opacity-70",children:"›"})]},o.id)})})}function ei({items:e,className:t}){return r.jsx("nav",{className:O("flex items-center gap-2 text-xs text-neutral-600 dark:text-neutral-400",t),"aria-label":"Breadcrumb",children:e.map((n,s)=>r.jsxs("span",{className:"flex items-center gap-2",children:[n.href?r.jsx("a",{href:n.href,className:"hover:underline",children:n.label}):r.jsx("span",{className:"text-neutral-900 dark:text-neutral-50",children:n.label}),s<e.length-1?r.jsx("span",{"aria-hidden":!0,children:"·"}):null]},`${n.label}-${s}`))})}function ti({value:e,onChange:t,placeholder:n="Search products…",className:s}){return r.jsxs("div",{className:O("relative",s),children:[r.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:"⌕"}),r.jsx(Te,{value:e,onChange:o=>t(o.target.value),placeholder:n,className:"pl-9","aria-label":"Search"})]})}function ys({facets:e,value:t,onChange:n,onClear:s,className:o,enabledFilters:a}){const i=e.tags??[],c=new Set(t.tags??[]),l=a?.tags??!0,u=a?.priceRange??!0,m=a?.inStock??!0;return l||u||m?r.jsxs("div",{className:O("space-y-4",o),children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("div",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:"Filters"}),r.jsx(J,{type:"button",variant:"ghost",className:"h-8 px-2 text-xs",onClick:s,children:"Clear"})]}),r.jsx(lt,{}),l&&i.length?r.jsxs("div",{className:"space-y-2",children:[r.jsx("div",{className:"text-sm font-medium",children:"Tags"}),r.jsx("div",{className:"space-y-2",children:i.map(x=>r.jsxs("label",{className:"flex cursor-pointer items-center gap-2 text-sm text-neutral-700 dark:text-neutral-300",children:[r.jsx("input",{type:"checkbox",checked:c.has(x),onChange:h=>{const v=new Set(c);h.target.checked?v.add(x):v.delete(x),n({...t,tags:Array.from(v)})}}),x]},x))})]}):null,u&&e.price?r.jsxs("div",{className:"space-y-2",children:[r.jsx("div",{className:"text-sm font-medium",children:"Price"}),r.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[r.jsxs("div",{className:"grid gap-1",children:[r.jsx(He,{className:"text-xs",htmlFor:"price-min",children:"Min"}),r.jsx(Te,{id:"price-min",inputMode:"decimal",placeholder:String(e.price.min),value:t.priceMin??"",onChange:x=>{const h=Number(x.target.value);n({...t,priceMin:Number.isFinite(h)&&x.target.value!==""?h:void 0})}})]}),r.jsxs("div",{className:"grid gap-1",children:[r.jsx(He,{className:"text-xs",htmlFor:"price-max",children:"Max"}),r.jsx(Te,{id:"price-max",inputMode:"decimal",placeholder:String(e.price.max),value:t.priceMax??"",onChange:x=>{const h=Number(x.target.value);n({...t,priceMax:Number.isFinite(h)&&x.target.value!==""?h:void 0})}})]})]})]}):null,m?r.jsxs("div",{className:"space-y-2",children:[r.jsx("div",{className:"text-sm font-medium",children:"Availability"}),r.jsxs("label",{className:"flex cursor-pointer items-center gap-2 text-sm text-neutral-700 dark:text-neutral-300",children:[r.jsx("input",{type:"checkbox",checked:t.inStock??!1,onChange:x=>n({...t,inStock:x.target.checked})}),"In stock"]})]}):null]}):null}function Fc(e){return r.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[r.jsx("circle",{cx:"12",cy:"12",r:"10"}),r.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),r.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]})}function sS(e){return r.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[r.jsx("path",{d:"M3 6h18"}),r.jsx("path",{d:"M8 6V4h8v2"}),r.jsx("path",{d:"M6 6l1 16h10l1-16"}),r.jsx("path",{d:"M10 11v6"}),r.jsx("path",{d:"M14 11v6"})]})}function ni({item:e,onRemove:t,onSetQty:n,variant:s="table",className:o,inventory:a}){const i=e.unitPrice*e.qty,[c,l]=f.useState(!1),u=f.useMemo(()=>{if(a?.availableQty)return a.availableQty},[a?.availableQty]),m=!a?.isOutOfStock&&(u===void 0||e.qty<u),d=f.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 f.useEffect(()=>{c&&e.qty!==1&&l(!1)},[c,e.qty]),s==="compact"?r.jsxs("div",{className:O("flex items-start gap-3",o),children:[r.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?r.jsx("img",{src:e.imageSnapshot,alt:e.titleSnapshot,className:"h-full w-full object-cover"}):null}),r.jsx("div",{className:"min-w-0 flex-1",children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("div",{className:"truncate text-sm font-medium text-neutral-950 dark:text-neutral-50",children:e.titleSnapshot}),r.jsx("div",{className:"mt-0.5 text-xs tabular-nums text-neutral-600 dark:text-neutral-400",children:Fe({amount:i,currency:e.currency})}),d&&r.jsxs("div",{className:O("mt-1 flex items-center gap-1 text-[11px]",d.type==="error"&&"text-red-600 dark:text-red-400",d.type==="warning"&&"text-amber-600 dark:text-amber-400",d.type==="info"&&"text-blue-600 dark:text-blue-400"),children:[r.jsx(Fc,{className:"h-3 w-3 shrink-0"}),r.jsx("span",{children:d.message})]})]}),r.jsx("div",{className:"flex h-12 w-[140px] shrink-0 items-center justify-end",children:c?r.jsxs("div",{className:"flex w-full flex-col items-center justify-center gap-2",children:[r.jsx("div",{className:"text-center text-[11px] font-medium leading-none text-neutral-600 dark:text-neutral-400",children:"Remove item?"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(J,{type:"button",variant:"outline",className:"h-7 w-[62px] px-0 text-[11px] leading-none",onClick:()=>l(!1),children:"Cancel"}),r.jsx(J,{type:"button",variant:"destructive",className:"h-7 w-[62px] px-0 text-[11px] leading-none",onClick:t,children:"Confirm"})]})]}):r.jsxs("div",{className:"flex items-center justify-end gap-1.5 whitespace-nowrap",children:[r.jsx(J,{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?r.jsx(sS,{className:"h-4 w-4"}):"-"}),r.jsx(Te,{inputMode:"numeric",pattern:"[0-9]*",value:String(e.qty),onChange:x=>{const h=Math.floor(Number(x.target.value));if(!Number.isFinite(h))return;const v=Math.max(1,u?Math.min(u,h):h);n(v)},className:"h-8 w-11 px-2 text-center","aria-label":"Quantity"}),r.jsx(J,{type:"button",size:"icon",variant:"outline",className:"h-8 w-8","aria-label":"Increase quantity",onClick:()=>n(u?Math.min(u,e.qty+1):e.qty+1),disabled:!m,children:"+"})]})})]})})]}):r.jsxs("div",{className:O("grid grid-cols-[64px_1fr] items-start gap-x-4 gap-y-3 sm:grid-cols-[64px_1fr_176px_120px]",o),children:[r.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?r.jsx("img",{src:e.imageSnapshot,alt:e.titleSnapshot,className:"h-full w-full object-cover"}):null}),r.jsxs("div",{className:"col-start-2 row-start-1 min-w-0",children:[r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsx("div",{className:"truncate text-sm font-medium text-neutral-950 dark:text-neutral-50",children:e.titleSnapshot}),r.jsx("div",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50 sm:hidden",children:Fe({amount:i,currency:e.currency})})]}),r.jsxs("div",{className:"mt-1 text-xs text-neutral-600 dark:text-neutral-400",children:[Fe({amount:e.unitPrice,currency:e.currency})," each"]}),d&&r.jsxs("div",{className:O("mt-1.5 flex items-center gap-1 text-xs",d.type==="error"&&"text-red-600 dark:text-red-400",d.type==="warning"&&"text-amber-600 dark:text-amber-400",d.type==="info"&&"text-blue-600 dark:text-blue-400"),children:[r.jsx(Fc,{className:"h-3.5 w-3.5 shrink-0"}),r.jsx("span",{children:d.message})]})]}),r.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:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(J,{type:"button",size:"icon",variant:"outline",className:"h-9 w-9","aria-label":"Decrease quantity",onClick:()=>n(Math.max(1,e.qty-1)),children:"-"}),r.jsx(Te,{inputMode:"numeric",pattern:"[0-9]*",value:String(e.qty),onChange:x=>{const h=Math.floor(Number(x.target.value));if(!Number.isFinite(h))return;const v=Math.max(1,u?Math.min(u,h):h);n(v)},className:"h-9 w-14 text-center","aria-label":"Quantity"}),r.jsx(J,{type:"button",size:"icon",variant:"outline",className:"h-9 w-9","aria-label":"Increase quantity",onClick:()=>n(u?Math.min(u,e.qty+1):e.qty+1),disabled:!m,children:"+"})]}),r.jsx(J,{type:"button",variant:"ghost",className:"h-9 px-2 text-xs text-red-600 dark:text-red-400 sm:hidden",onClick:t,children:"Remove"})]}),r.jsxs("div",{className:"hidden sm:col-start-4 sm:row-start-1 sm:flex sm:flex-col sm:items-center sm:text-center",children:[r.jsx("div",{className:"text-sm font-semibold tabular-nums text-neutral-950 dark:text-neutral-50",children:Fe({amount:i,currency:e.currency})}),r.jsx(J,{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 ri({currency:e,subtotal:t,itemCount:n,onCheckout:s,isCheckoutDisabled:o,checkoutDisabledReason:a,onRemoveUnavailable:i,className:c}){return r.jsxs("div",{className:O("space-y-4",c),children:[r.jsx(lt,{}),r.jsxs("div",{className:"flex items-center justify-between text-sm",children:[r.jsxs("div",{className:"flex items-center gap-2 text-neutral-600 dark:text-neutral-400",children:[r.jsx("span",{children:"Subtotal"}),typeof n=="number"?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"text-neutral-300 dark:text-neutral-700",children:"·"}),r.jsxs("span",{className:"tabular-nums",children:[n," item",n===1?"":"s"]})]}):null]}),r.jsx("span",{className:"font-semibold text-neutral-950 dark:text-neutral-50",children:Fe({amount:t,currency:e})})]}),r.jsx(J,{type:"button",onClick:s,disabled:o,className:"w-full",children:"Checkout"}),o&&a&&r.jsxs("div",{className:"space-y-2",children:[r.jsx("p",{className:"text-center text-xs text-amber-600 dark:text-amber-400",children:a}),i&&r.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 Dm({onCheckout:e,className:t}){const{config:n}=Ae(),s=Et(),{getItemInventory:o,hasIssues:a}=ha({items:s.items,refreshInterval:3e4,skip:s.items.length===0}),i=()=>{for(const c of s.items){const l=o(c.productId,c.variantId);(l?.isOutOfStock||l?.exceedsAvailable)&&s.removeItem(c.productId,c.variantId)}};return s.items.length===0?r.jsx(Bn,{title:"Cart is empty",description:"Add items from the catalog to check out.",className:t}):r.jsxs("div",{className:O("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:[r.jsx("div",{className:"-mr-4 min-h-0 flex-1 overflow-y-auto overflow-x-hidden pr-4",children:r.jsx("div",{className:"divide-y divide-neutral-200 dark:divide-neutral-800",children:s.items.map(c=>r.jsx("div",{className:"py-3",children:r.jsx(ni,{variant:"compact",item:c,onRemove:()=>s.removeItem(c.productId,c.variantId),onSetQty:l=>s.setQty(c.productId,c.variantId,l),inventory:o(c.productId,c.variantId)})},`${c.productId}::${c.variantId??""}`))})}),r.jsx("div",{className:"mt-4 space-y-4",children:r.jsx(ri,{currency:n.currency,subtotal:s.subtotal,itemCount:s.count,onCheckout:e,isCheckoutDisabled:s.items.length===0||a,checkoutDisabledReason:a?"Some items have inventory issues":void 0,onRemoveUnavailable:a?i:void 0})})]})}const zm=f.forwardRef(({className:e,...t},n)=>r.jsx("textarea",{ref:n,className:O("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}));zm.displayName="Textarea";function oS(){const[e,t]=f.useState(!1);return f.useEffect(()=>{const n=window.matchMedia?.("(prefers-reduced-motion: reduce)");if(!n)return;const s=()=>t(n.matches);return s(),n.addEventListener?.("change",s),()=>n.removeEventListener?.("change",s)},[]),e}function Uc({children:e,className:t}){const n=f.useRef(null),s=oS();return f.useEffect(()=>{const o=n.current;!o||s||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"})},[s]),r.jsx("div",{ref:n,className:t,children:e})}function lr(){return`${Date.now()}_${Math.random().toString(16).slice(2)}`}function aS(e){return`$${(e/100).toFixed(2)}`}function iS({product:e,onSelect:t}){return r.jsxs("button",{type:"button",onClick:()=>t?.(e.slug??e.id),className:"flex w-full items-center gap-2 rounded-lg border border-neutral-200 bg-white p-2 text-left transition-colors hover:bg-neutral-50 dark:border-neutral-700 dark:bg-neutral-900 dark:hover:bg-neutral-800",children:[e.imageUrl&&r.jsx("img",{src:e.imageUrl,alt:e.name,className:"h-10 w-10 shrink-0 rounded object-cover"}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("div",{className:"truncate text-xs font-medium",children:e.name}),e.priceCents!=null&&r.jsx("div",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:aS(e.priceCents)})]})]})}function cS({faq:e}){const[t,n]=f.useState(!1);return r.jsxs("button",{type:"button",onClick:()=>n(s=>!s),className:"w-full rounded-lg border border-neutral-200 bg-white p-2 text-left transition-colors hover:bg-neutral-50 dark:border-neutral-700 dark:bg-neutral-900 dark:hover:bg-neutral-800",children:[r.jsx("div",{className:"text-xs font-medium",children:e.question}),t&&r.jsx("div",{className:"mt-1 text-xs text-neutral-600 dark:text-neutral-400",children:e.answer})]})}function $m({className:e,onProductSelect:t}){const s=ks()?.config.adapter,o=!!s?.sendChatMessage,[a,i]=f.useState(""),[c,l]=f.useState(!1),[u,m]=f.useState(null),d=f.useRef(void 0),[x,h]=f.useState(()=>[{id:lr(),role:"agent",text:"Hi! How can we help today? We can recommend products or answer support questions.",createdAt:Date.now()}]),[v,p]=f.useState("…");f.useEffect(()=>{if(!c)return;const k=[".","..","..."];let _=0;const S=window.setInterval(()=>{_=(_+1)%k.length,p(k[_])},450);return()=>window.clearInterval(S)},[c]);const g=f.useRef(null),y=f.useRef(null);f.useEffect(()=>{const k=g.current;k&&(k.scrollTop=k.scrollHeight)},[x.length]);const w=f.useCallback(()=>{const k=y.current;if(!k)return;const _=120;k.style.height="0px";const S=Math.min(_,Math.max(40,k.scrollHeight));k.style.height=`${S}px`,k.style.overflowY=k.scrollHeight>_?"auto":"hidden"},[]);f.useEffect(()=>{w()},[a,w]);const j=f.useCallback(async()=>{const k=a.trim();if(!(!k||c)){if(h(_=>[..._,{id:lr(),role:"user",text:k,createdAt:Date.now()}]),i(""),m(null),l(!0),!o||!s?.sendChatMessage){window.setTimeout(()=>{h(_=>[..._,{id:lr(),role:"agent",text:"Chat is not configured. Please contact support.",createdAt:Date.now()}]),l(!1)},300);return}try{const _=await s.sendChatMessage({sessionId:d.current,message:k});d.current=_.sessionId,h(S=>[...S,{id:lr(),role:"agent",text:_.message,products:_.products,faqs:_.faqs,createdAt:Date.now()}])}catch(_){const S=_ instanceof Error?_.message:"Something went wrong";m(S),h(A=>[...A,{id:lr(),role:"agent",text:"Sorry, I had trouble processing that. Please try again.",createdAt:Date.now()}])}finally{l(!1)}}},[a,c,o,s]);return r.jsxs("div",{className:O("flex h-full min-h-0 flex-col",e),children:[r.jsxs("div",{ref:g,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:[x.map(k=>r.jsx(Uc,{className:O("flex",k.role==="user"?"justify-end":"justify-start"),children:r.jsxs("div",{className:O("max-w-[85%]",k.role==="user"?"":"space-y-2"),children:[r.jsx("div",{className:O("rounded-2xl px-3 py-2 text-sm leading-5",k.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:r.jsx("span",{className:"whitespace-pre-wrap break-words",children:k.text})}),k.products&&k.products.length>0&&r.jsx("div",{className:"space-y-1",children:k.products.map(_=>r.jsx(iS,{product:_,onSelect:t},_.id))}),k.faqs&&k.faqs.length>0&&r.jsx("div",{className:"space-y-1",children:k.faqs.map(_=>r.jsx(cS,{faq:_},_.id))})]})},k.id)),c?r.jsx(Uc,{className:"flex justify-start",children:r.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:v})}):null]}),u&&r.jsx("div",{className:"mt-1 text-xs text-red-500 dark:text-red-400",children:u}),r.jsxs("div",{className:"mt-3 flex shrink-0 items-end gap-2",children:[r.jsx(zm,{ref:y,rows:1,value:a,onChange:k=>i(k.target.value),placeholder:"Type a message…",className:"max-h-[120px] resize-none",onKeyDown:k=>{k.key==="Enter"&&(k.shiftKey||(k.preventDefault(),j()))}}),r.jsx(J,{type:"button",onClick:j,disabled:!a.trim()||c,className:"h-10 shrink-0",children:"Send"})]})]})}function Cr({trigger:e,side:t="right",open:n,onOpenChange:s,onCheckout:o,preferredTab:a,className:i}){const[c,l]=f.useState(a??"cart");return f.useEffect(()=>{n&&l(a??"cart")},[n,a]),r.jsxs(Vs,{modal:!1,open:n,onOpenChange:s,children:[e?r.jsx(Ws,{asChild:!0,children:e}):null,r.jsxs(Ir,{side:t,overlayClassName:t==="popup"?"pointer-events-none bg-transparent backdrop-blur-none":"pointer-events-none bg-neutral-950/40 backdrop-blur-none",className:O(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:[r.jsx(qs,{className:"space-y-0",children:r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsx(Za,{value:c,onValueChange:u=>l(u),children:r.jsxs(Qs,{className:"h-9",children:[r.jsx(Sr,{value:"cart",className:"text-sm",children:"Cart"}),r.jsx(Sr,{value:"chat",className:"text-sm",children:"Chat"})]})}),r.jsx(Uu,{asChild:!0,children:r.jsx(J,{type:"button",size:"icon",variant:"ghost",className:"h-9 w-9 rounded-full text-lg leading-none","aria-label":"Close cart",children:"X"})})]})}),r.jsx("div",{className:"mt-3 min-h-0 flex-1 overflow-hidden",children:c==="chat"?r.jsxs("div",{className:"flex h-full flex-col",children:[r.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."}),r.jsx("div",{className:"mt-3 min-h-0 flex-1",children:r.jsx($m,{className:"h-full"})})]}):r.jsx(Dm,{onCheckout:()=>{o(),s?.(!1)},className:"h-full border-0 bg-transparent p-0 shadow-none"})})]})]})}function si({value:e,onApply:t,className:n}){const[s,o]=f.useState(e??"");return f.useEffect(()=>{o(e??"")},[e]),r.jsxs("div",{className:O("space-y-2",n),children:[r.jsx("div",{className:"text-sm font-medium text-neutral-950 dark:text-neutral-50",children:"Promo code"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(Te,{value:s,onChange:a=>o(a.target.value),placeholder:"SAVE10","aria-label":"Promo code"}),r.jsx(J,{type:"button",variant:"outline",onClick:()=>t(s.trim()||void 0),children:"Apply"})]})]})}function Fm({onCheckout:e,showPromoCode:t,className:n}){const{config:s}=Ae(),o=Et(),{getItemInventory:a,hasIssues:i}=ha({items:o.items,refreshInterval:3e4,skip:o.items.length===0}),c=()=>{for(const l of o.items){const u=a(l.productId,l.variantId);(u?.isOutOfStock||u?.exceedsAvailable)&&o.removeItem(l.productId,l.variantId)}};return o.items.length===0?r.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}):r.jsxs("div",{className:O("grid items-start gap-6 lg:grid-cols-[1fr_360px]",n),children:[r.jsxs("div",{className:"self-start rounded-2xl border border-neutral-200 bg-white dark:border-neutral-800 dark:bg-neutral-950",children:[r.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:[r.jsx("div",{}),r.jsx("div",{children:"Item"}),r.jsx("div",{className:"text-center",children:"Qty"}),r.jsx("div",{className:"text-center",children:"Total"})]}),r.jsx("div",{className:"divide-y divide-neutral-200 dark:divide-neutral-800",children:o.items.map(l=>r.jsx("div",{className:"px-4 py-4 sm:px-5",children:r.jsx(ni,{item:l,onRemove:()=>o.removeItem(l.productId,l.variantId),onSetQty:u=>o.setQty(l.productId,l.variantId,u),inventory:a(l.productId,l.variantId)})},`${l.productId}::${l.variantId??""}`))})]}),r.jsx("div",{className:"lg:sticky lg:top-24 self-start",children:r.jsxs("div",{className:"rounded-2xl border border-neutral-200 bg-white p-5 shadow-sm dark:border-neutral-800 dark:bg-neutral-950",children:[r.jsx("div",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:"Summary"}),r.jsx(lt,{className:"my-4"}),r.jsxs("div",{className:"space-y-4",children:[t?r.jsx(si,{value:o.promoCode,onApply:o.setPromoCode}):null,r.jsx(ri,{currency:s.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 Um({left:e,right:t,className:n}){return r.jsxs("div",{className:O("grid items-start gap-8 lg:grid-cols-[1fr_420px]",n),children:[r.jsx("div",{children:e}),r.jsx("div",{children:t})]})}function ea({title:e,value:t,onChange:n,errors:s,className:o}){return r.jsxs("section",{className:O("space-y-4 rounded-2xl border border-neutral-200 bg-white p-5 dark:border-neutral-800 dark:bg-neutral-950",o),children:[r.jsx("div",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:e}),r.jsxs("div",{className:"grid gap-3",children:[r.jsxs("div",{className:"grid gap-2",children:[r.jsx(He,{htmlFor:`${e}-line1`,children:"Address line 1"}),r.jsx(Te,{id:`${e}-line1`,value:t.line1,onChange:a=>n({...t,line1:a.target.value}),"aria-invalid":!!s?.line1}),s?.line1?r.jsx("div",{className:"text-xs text-red-600",children:s.line1}):null]}),r.jsxs("div",{className:"grid gap-2",children:[r.jsx(He,{htmlFor:`${e}-line2`,children:"Address line 2"}),r.jsx(Te,{id:`${e}-line2`,value:t.line2??"",onChange:a=>n({...t,line2:a.target.value})})]}),r.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[r.jsxs("div",{className:"grid gap-2",children:[r.jsx(He,{htmlFor:`${e}-city`,children:"City"}),r.jsx(Te,{id:`${e}-city`,value:t.city,onChange:a=>n({...t,city:a.target.value}),"aria-invalid":!!s?.city}),s?.city?r.jsx("div",{className:"text-xs text-red-600",children:s.city}):null]}),r.jsxs("div",{className:"grid gap-2",children:[r.jsx(He,{htmlFor:`${e}-state`,children:"State"}),r.jsx(Te,{id:`${e}-state`,value:t.state??"",onChange:a=>n({...t,state:a.target.value})})]})]}),r.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[r.jsxs("div",{className:"grid gap-2",children:[r.jsx(He,{htmlFor:`${e}-postal`,children:"Postal code"}),r.jsx(Te,{id:`${e}-postal`,value:t.postalCode,onChange:a=>n({...t,postalCode:a.target.value}),"aria-invalid":!!s?.postalCode}),s?.postalCode?r.jsx("div",{className:"text-xs text-red-600",children:s.postalCode}):null]}),r.jsxs("div",{className:"grid gap-2",children:[r.jsx(He,{htmlFor:`${e}-country`,children:"Country"}),r.jsx(Te,{id:`${e}-country`,value:t.country,onChange:a=>n({...t,country:a.target.value}),"aria-invalid":!!s?.country}),s?.country?r.jsx("div",{className:"text-xs text-red-600",children:s.country}):null]})]})]})]})}function lS({message:e}){return e?r.jsx("div",{className:"text-xs text-red-600",children:e}):null}function Bm({defaultOpen:e=!1,label:t="Send as a gift"}){const n=Ar(),[s,o]=b.useState(e||!!(n.values.recipientEmail||n.values.giftMessage)),a=()=>{const i=!s;o(i),i||(n.setField("recipientEmail",""),n.setField("giftMessage",""))};return r.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:[r.jsxs("label",{className:"flex cursor-pointer items-center gap-3",children:[r.jsx("input",{type:"checkbox",checked:s,onChange:a,className:"h-4 w-4 rounded border-neutral-300 text-neutral-900 focus:ring-neutral-500 dark:border-neutral-600 dark:bg-neutral-800"}),r.jsx("span",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:t})]}),s&&r.jsxs("div",{className:"grid gap-3 pl-7",children:[r.jsxs("div",{className:"grid gap-2",children:[r.jsx(He,{htmlFor:"gift-recipient-email",children:"Recipient email"}),r.jsx(Te,{id:"gift-recipient-email",type:"email",value:n.values.recipientEmail??"",onChange:i=>n.setField("recipientEmail",i.target.value),placeholder:"recipient@example.com","aria-invalid":!!n.fieldErrors.recipientEmail}),r.jsx(lS,{message:n.fieldErrors.recipientEmail}),r.jsx("div",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:"The recipient will receive an email with details on how to claim their gift."})]}),r.jsxs("div",{className:"grid gap-2",children:[r.jsx(He,{htmlFor:"gift-message",children:"Gift message (optional)"}),r.jsx("textarea",{id:"gift-message",value:n.values.giftMessage??"",onChange:i=>n.setField("giftMessage",i.target.value),placeholder:"Add a personal message...",maxLength:500,rows:3,className:"w-full resize-y rounded-md border border-neutral-300 bg-white px-3 py-2 text-sm text-neutral-900 placeholder-neutral-400 focus:outline-none focus:ring-2 focus:ring-neutral-500 dark:border-neutral-700 dark:bg-neutral-900 dark:text-neutral-50 dark:placeholder-neutral-500"}),n.values.giftMessage&&r.jsxs("div",{className:"text-right text-xs text-neutral-400",children:[n.values.giftMessage.length,"/500"]})]})]})]})}function Vm({methods:e,value:t,onChange:n,currency:s,className:o}){return e.length===0?null:r.jsxs("section",{className:O("space-y-4 rounded-2xl border border-neutral-200 bg-white p-5 dark:border-neutral-800 dark:bg-neutral-950",o),children:[r.jsx("div",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:"Shipping method"}),r.jsx("div",{className:"space-y-2",children:e.map(a=>{const i=a.id===t;return r.jsxs(J,{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:[r.jsxs("div",{className:"text-left",children:[r.jsx("div",{className:"text-sm font-medium",children:a.label}),a.detail?r.jsx("div",{className:"text-xs opacity-80",children:a.detail}):null]}),r.jsx("div",{className:"text-sm font-semibold",children:Fe({amount:a.price,currency:a.currency||s})})]},a.id)})})]})}function Gr({message:e}){return e?r.jsx("div",{className:"text-xs text-red-600",children:e}):null}function Wm({className:e}){const{config:t}=Ae(),n=Ar(),s=Et(),o=t.checkout.mode,a=f.useMemo(()=>Qr(s.items,{requireEmail:t.checkout.requireEmail??!0,defaultMode:o,allowShipping:t.checkout.allowShipping??!1}),[s.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=s.items.some(v=>v.metadata?.product_type==="gift_card"),u=f.useMemo(()=>{const v=new Set;for(const p of s.items)p.metadata?.regulatoryNotice&&v.add(p.metadata.regulatoryNotice);return Array.from(v)},[s.items]),m={line1:"",line2:"",city:"",state:"",postalCode:"",country:"US"},d=n.values.shippingAddress??m,x=n.values.billingAddress??m,h=Fl({enabled:!!t.adapter.getShippingMethods&&i,customer:{email:n.values.email||void 0,name:n.values.name||void 0,shippingAddress:d}});return r.jsxs("form",{className:O("space-y-6",e),onSubmit:v=>v.preventDefault(),children:[a.isDigitalOnly?r.jsx(Xe,{className:"rounded-2xl",children:r.jsxs(rt,{className:"p-5",children:[r.jsx("div",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:"Digital delivery"}),r.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)?r.jsx(Xe,{className:"rounded-2xl border-red-200 bg-red-50 dark:border-red-900/40 dark:bg-red-950/30",children:r.jsxs(rt,{className:"p-5",children:[r.jsx("div",{className:"text-sm font-semibold text-red-900 dark:text-red-200",children:"Shipping required"}),r.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?r.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:[r.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[r.jsx("div",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:"Contact"}),r.jsx("div",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:a.email==="required"||a.name==="required"||a.phone==="required"?"Required":"Optional"})]}),r.jsxs("div",{className:"grid gap-3",children:[a.email!=="none"?r.jsxs("div",{className:"grid gap-2",children:[r.jsx(He,{htmlFor:"checkout-email",children:"Email"}),r.jsx(Te,{id:"checkout-email",value:n.values.email??"",onChange:v=>n.setField("email",v.target.value),placeholder:"you@company.com","aria-invalid":!!n.fieldErrors.email,required:a.email==="required"}),r.jsx(Gr,{message:n.fieldErrors.email})]}):null,a.name!=="none"?r.jsxs("div",{className:"grid gap-2",children:[r.jsx(He,{htmlFor:"checkout-name",children:"Name"}),r.jsx(Te,{id:"checkout-name",value:n.values.name??"",onChange:v=>n.setField("name",v.target.value),placeholder:"Full name","aria-invalid":!!n.fieldErrors.name,required:a.name==="required"}),r.jsx(Gr,{message:n.fieldErrors.name})]}):null,a.phone!=="none"?r.jsxs("div",{className:"grid gap-2",children:[r.jsx(He,{htmlFor:"checkout-phone",children:"Phone"}),r.jsx(Te,{id:"checkout-phone",value:n.values.phone??"",onChange:v=>n.setField("phone",v.target.value),placeholder:"Phone number","aria-invalid":!!n.fieldErrors.phone,required:a.phone==="required"}),r.jsx(Gr,{message:n.fieldErrors.phone})]}):null]})]}):null,r.jsx(Bm,{defaultOpen:l,label:l?"Send gift card to someone":"Send as a gift"}),u.length>0?r.jsxs("section",{className:"space-y-3 rounded-2xl border border-amber-200 bg-amber-50 p-5 dark:border-amber-900/40 dark:bg-amber-950/30",children:[r.jsx("div",{className:"text-sm font-semibold text-amber-900 dark:text-amber-200",children:"Regulatory notice"}),u.map((v,p)=>r.jsx("div",{className:"text-xs text-amber-800/90 dark:text-amber-200/80",children:v},p)),r.jsxs("label",{className:"flex items-start gap-2 pt-1",children:[r.jsx("input",{type:"checkbox",checked:n.values.regulatoryConsent===!0,onChange:v=>n.setField("regulatoryConsent",v.target.checked),className:"mt-0.5 h-4 w-4 rounded border-amber-300 accent-amber-700"}),r.jsx("span",{className:"text-xs font-medium text-amber-900 dark:text-amber-200",children:"I acknowledge and accept the regulatory terms above"})]}),r.jsx(Gr,{message:n.fieldErrors.regulatoryConsent})]}):null,i?r.jsx(ea,{title:"Shipping address",value:d,onChange:v=>n.setField("shippingAddress",v),errors:{line1:n.fieldErrors["shippingAddress.line1"],city:n.fieldErrors["shippingAddress.city"],postalCode:n.fieldErrors["shippingAddress.postalCode"],country:n.fieldErrors["shippingAddress.country"]}}):null,i&&h.methods.length?r.jsx(Vm,{methods:h.methods,value:n.values.shippingMethodId,onChange:v=>n.setField("shippingMethodId",v),currency:t.currency}):null,o==="full"?r.jsx(ea,{title:"Billing address",value:x,onChange:v=>n.setField("billingAddress",v)}):null,t.checkout.allowTipping?r.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:[r.jsx("div",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:"Tip"}),r.jsxs("div",{className:"grid gap-2",children:[r.jsxs(He,{htmlFor:"checkout-tip",children:["Tip amount (",t.currency,")"]}),r.jsx(Te,{id:"checkout-tip",inputMode:"decimal",value:String(n.values.tipAmount??0),onChange:v=>n.setField("tipAmount",Number(v.target.value)||0)})]})]}):null,o==="full"?r.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:[r.jsx("div",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:"Notes"}),r.jsxs("div",{className:"grid gap-2",children:[r.jsx(He,{htmlFor:"checkout-notes",children:"Order notes (optional)"}),r.jsx(Te,{id:"checkout-notes",value:n.values.notes??"",onChange:v=>n.setField("notes",v.target.value),placeholder:"Delivery instructions, gift note…"})]})]}):null]})}function dS(e){return r.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[r.jsx("circle",{cx:"12",cy:"12",r:"10"}),r.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),r.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]})}function uS(e){return r.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[r.jsx("path",{d:"M3 6h18"}),r.jsx("path",{d:"M8 6V4h8v2"}),r.jsx("path",{d:"M6 6l1 16h10l1-16"})]})}function qm({open:e,onOpenChange:t,issues:n,onRemoveItem:s,onUpdateQuantity:o,onGoToCart:a,className:i}){const c=n.some(l=>l.type==="out_of_stock"||l.type==="product_unavailable");return r.jsx(Ma,{open:e,onOpenChange:t,children:r.jsxs(Us,{className:O("sm:max-w-lg",i),children:[r.jsxs(Da,{children:[r.jsxs(Bs,{className:"flex items-center gap-2",children:[r.jsx(dS,{className:"h-5 w-5 text-amber-500"}),"Inventory Update"]}),r.jsx(za,{children:c?"Some items in your cart are no longer available.":"Some items in your cart have limited availability."})]}),r.jsx("div",{className:"my-4 divide-y divide-neutral-200 dark:divide-neutral-800",children:n.map(l=>r.jsx(mS,{issue:l,onRemove:()=>s(l.productId,l.variantId),onUpdateQty:u=>o(l.productId,l.variantId,u)},`${l.productId}::${l.variantId??""}`))}),r.jsxs(Fu,{className:"flex-col gap-2 sm:flex-row",children:[a?r.jsx(J,{type:"button",variant:"outline",onClick:()=>{t(!1),a()},children:"Go to Cart"}):null,r.jsx(J,{type:"button",onClick:()=>t(!1),children:"Continue"})]})]})})}function mS({issue:e,onRemove:t,onUpdateQty:n}){const s=e.type==="out_of_stock"||e.type==="product_unavailable";return r.jsxs("div",{className:"flex items-start gap-3 py-3",children:[r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("div",{className:"text-sm font-medium text-neutral-900 dark:text-neutral-100",children:e.title}),r.jsx("div",{className:O("mt-0.5 text-sm",s?"text-red-600 dark:text-red-400":"text-amber-600 dark:text-amber-400"),children:e.message}),e.type==="insufficient_stock"&&e.availableQty>0?r.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]}),r.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.type==="insufficient_stock"&&e.availableQty>0?r.jsxs(J,{type:"button",size:"sm",variant:"outline",onClick:()=>n(e.availableQty),children:["Update to ",e.availableQty]}):null,r.jsxs(J,{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:[r.jsx(uS,{className:"h-4 w-4"}),r.jsx("span",{className:"sr-only",children:"Remove"})]})]})]})}function Hm({className:e,ctaLabel:t,renderEmbedded:n,embeddedFallback:s,renderCustom:o,customFallback:a}){const{config:i}=Ae(),c=Et(),l=Ar(),{config:u,isLoading:m}=Bl(),[d,x]=f.useState(!1);f.useEffect(()=>{let L=!0;return Promise.resolve().then(()=>require("./walletDetection-bNmV5ItZ.js")).then(B=>{L&&x(B.detectSolanaWallets())}),()=>{L=!1}},[]);const h=Ul({items:c.items}),[v,p]=f.useState(!1),g=f.useMemo(()=>i.checkout.paymentMethods&&i.checkout.paymentMethods.length?i.checkout.paymentMethods:[{id:"card",label:"Card",ctaLabel:"Pay now"}],[i.checkout.paymentMethods]),y=f.useMemo(()=>g.filter(B=>!(B.id==="card"&&!u.card||B.id==="crypto"&&!u.crypto||B.id==="credits"&&!u.credits||B.id==="crypto"&&!d)),[d,g,u]),[w,j]=f.useState((y[0]??g[0])?.id??"card");f.useEffect(()=>{y.length&&(y.some(L=>L.id===w)||j(y[0].id))},[w,y]),f.useEffect(()=>{l.reset()},[w]);const k=y.find(L=>L.id===w)??g.find(L=>L.id===w)??g[0]??{ctaLabel:"Pay now"},_=k.description??(w==="crypto"?"Pay using a connected wallet.":void 0),S=w==="crypto"&&!d,A=m||l.status==="validating"||l.status==="creating_session"||l.status==="redirecting"||h.isVerifying,E=t??k.ctaLabel??(i.checkout.mode==="none"?"Continue to payment":"Pay now"),I=f.useCallback(async L=>{const B=await h.verify();if(!B.ok&&B.issues.length>0){p(!0);return}l.createCheckoutSession({paymentMethodId:L})},[l,h]),T=l.session?.kind==="embedded"?l.session:null,U=l.session?.kind==="custom"?l.session:null;return r.jsxs("div",{className:O("space-y-3",e),children:[y.length>1?r.jsxs("div",{className:"space-y-2",children:[r.jsx("div",{className:"text-xs font-medium text-neutral-600 dark:text-neutral-400",children:"Payment method"}),r.jsx(Za,{value:w,onValueChange:j,children:r.jsx(Qs,{className:"w-full",children:y.map(L=>r.jsx(Sr,{value:L.id,className:"flex-1",disabled:A,children:L.label},L.id))})})]}):null,l.error?r.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,U?r.jsx("div",{className:"space-y-3",children:o?o(U):a??r.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."})}):T?r.jsx("div",{className:"space-y-3",children:n?n(T):s??r.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."})}):r.jsx(J,{type:"button",className:"w-full",disabled:c.items.length===0||A||S,onClick:()=>{I(w)},children:h.isVerifying?"Checking availability…":A?"Processing…":E}),!T&&!U?r.jsx("p",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:S?"Install a browser wallet to enable crypto payments.":_??"You will be redirected to complete your payment."}):null,r.jsx(qm,{open:v,onOpenChange:L=>{p(L),L||h.reset()},issues:h.result?.issues??[],onRemoveItem:(L,B)=>{c.removeItem(L,B)},onUpdateQuantity:(L,B,z)=>{c.setQty(L,B,z)}})]})}function Zm({className:e}){const{config:t}=Ae(),n=Et(),s=Ar(),{settings:o}=qn(),a=(t.checkout.allowPromoCodes??!1)&&o.checkout.promoCodes;return r.jsxs("div",{className:O("rounded-2xl border border-neutral-200 bg-white p-5 dark:border-neutral-800 dark:bg-neutral-950",e),children:[r.jsx("div",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:"Order review"}),r.jsx(lt,{className:"my-3"}),r.jsx("div",{className:"space-y-3",children:n.items.map(i=>r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[r.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?r.jsx("img",{src:i.imageSnapshot,alt:i.titleSnapshot,className:"h-full w-full object-cover"}):null}),r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"line-clamp-1 text-sm text-neutral-950 dark:text-neutral-50",children:i.titleSnapshot}),r.jsxs("div",{className:"text-xs text-neutral-600 dark:text-neutral-400",children:["Qty ",i.qty]})]})]}),r.jsx("div",{className:"text-sm font-semibold tabular-nums text-neutral-950 dark:text-neutral-50",children:Fe({amount:i.unitPrice*i.qty,currency:i.currency})})]},`${i.productId}::${i.variantId??""}`))}),r.jsx(lt,{className:"my-3"}),a?r.jsx(si,{value:s.values.discountCode??n.promoCode,onApply:i=>{s.setField("discountCode",i??""),n.setPromoCode(i)}}):null,a?r.jsx(lt,{className:"my-3"}):null,r.jsxs("div",{className:"flex items-center justify-between text-sm",children:[r.jsx("span",{className:"text-neutral-600 dark:text-neutral-400",children:"Subtotal"}),r.jsx("span",{className:"font-semibold text-neutral-950 dark:text-neutral-50",children:Fe({amount:n.subtotal,currency:t.currency})})]})]})}function Ze(e){if(e)try{const t=new URL(e,"https://placeholder.invalid");return t.protocol==="https:"||t.protocol==="http:"?e:void 0}catch{return}}function Io(e){const t={"Content-Type":"application/json"};return e&&(t.Authorization=`Bearer ${e}`),t}function fS({status:e}){const t={info_submitted:"bg-blue-100 text-blue-800 dark:bg-blue-900/50 dark:text-blue-200",approved:"bg-emerald-100 text-emerald-800 dark:bg-emerald-900/50 dark:text-emerald-200",rejected:"bg-red-100 text-red-800 dark:bg-red-900/50 dark:text-red-200",processing:"bg-amber-100 text-amber-800 dark:bg-amber-900/50 dark:text-amber-200"},n=e.replace(/_/g," ");return r.jsx(ht,{className:t[e]??"bg-neutral-100 text-neutral-700",children:n})}function pS({field:e,value:t,onChange:n}){const s="w-full rounded-md border border-neutral-300 bg-white px-3 py-2 text-sm text-neutral-900 placeholder-neutral-400 focus:outline-none focus:ring-2 focus:ring-neutral-500 dark:border-neutral-700 dark:bg-neutral-900 dark:text-neutral-50 dark:placeholder-neutral-500";if(e.fieldType==="dropdown"&&e.options?.length)return r.jsxs("select",{id:e.id,required:e.required,value:t,onChange:a=>n(a.target.value),className:s,children:[r.jsx("option",{value:"",children:"Select…"}),e.options.map(a=>r.jsx("option",{value:a,children:a},a))]});if(e.fieldType==="address"||e.fieldType==="textarea")return r.jsx("textarea",{id:e.id,required:e.required,value:t,placeholder:e.placeholder,rows:3,onChange:a=>n(a.target.value),className:O(s,"resize-y")});if(e.fieldType==="file_upload"){const a=i=>{const c=i.target.files?.[0];if(!c){n("");return}if(c.size>1572864){n(""),i.target.value="",alert("File must be under 1.5 MB.");return}const l=new FileReader;l.onload=()=>{const u=l.result,m=c.name.replace(/[^a-zA-Z0-9._\-() ]/g,"_").slice(0,200);n(JSON.stringify({name:m,data:u}))},l.readAsDataURL(c)};return r.jsx("input",{id:e.id,type:"file",required:e.required,onChange:a,className:"w-full text-sm text-neutral-700 file:mr-3 file:rounded file:border-0 file:bg-neutral-100 file:px-3 file:py-1.5 file:text-sm file:font-medium dark:text-neutral-300 dark:file:bg-neutral-800 dark:file:text-neutral-200"})}const o={email:"email",phone:"tel",text:"text"};return r.jsx("input",{id:e.id,type:o[e.fieldType]??"text",required:e.required,value:t,placeholder:e.placeholder,onChange:a=>n(a.target.value),className:s})}function to({serverUrl:e,productId:t,authToken:n}){const[s,o]=f.useState("loading"),[a,i]=f.useState(null),[c,l]=f.useState(null),[u,m]=f.useState({}),[d,x]=f.useState(!1),[h,v]=f.useState(null),p=f.useCallback((y,w)=>{m(j=>({...j,[y]:w}))},[]);f.useEffect(()=>{if(s!=="already_submitted"&&s!=="success")return;const y=Io(n),j=setInterval(async()=>{try{const k=await fetch(`${e}/paywall/v1/asset-redemption/${t}/status`,{headers:y});if(!k.ok)return;const _=await k.json();_.redemptions?.length&&(l(_.redemptions[0].status),s==="success"&&o("already_submitted"))}catch{}},3e4);return()=>clearInterval(j)},[s,e,t,n]),f.useEffect(()=>{let y=!1;const w=Io(n);async function j(){try{const k=await fetch(`${e}/paywall/v1/asset-redemption/${t}/status`,{headers:w});if(!y&&k.ok){const A=await k.json();if(A.redemptions?.length){l(A.redemptions[0].status),o("already_submitted");return}}const _=await fetch(`${e}/paywall/v1/asset-redemption/${t}/form`,{headers:w});if(y)return;if(!_.ok)throw new Error(`Server error: ${_.status}`);const S=await _.json();if(!S.redemptionConfig){o("no_config");return}i(S.redemptionConfig),o("form")}catch(k){y||(v(k instanceof Error?k.message:"Failed to load redemption form."),o("form"))}}return j(),()=>{y=!0}},[e,t,n]);const g=f.useCallback(async y=>{y.preventDefault(),x(!0),v(null);try{const w=await fetch(`${e}/paywall/v1/asset-redemption/${t}/submit`,{method:"POST",headers:Io(n),body:JSON.stringify({formData:u})});if(!w.ok){const j=await w.text();throw new Error(j||`Server error: ${w.status}`)}o("success")}catch(w){v(w instanceof Error?w.message:"Submission failed. Please try again.")}finally{x(!1)}},[e,t,n,u]);return s==="loading"?r.jsx("div",{className:"py-8 text-center text-sm text-neutral-500 dark:text-neutral-400",children:"Loading redemption form..."}):s==="no_config"?r.jsx("div",{className:"py-8 text-center text-sm text-neutral-500 dark:text-neutral-400",children:"Redemption not available for this product."}):s==="already_submitted"?r.jsxs("div",{className:"space-y-3 rounded-xl border border-neutral-200 bg-neutral-50 p-5 dark:border-neutral-800 dark:bg-neutral-900/50",children:[r.jsx("p",{className:"text-sm font-medium text-neutral-900 dark:text-neutral-50",children:"Redemption request status"}),c?r.jsx(fS,{status:c}):null,r.jsx("p",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:"You have already submitted redemption information. We will notify you of any updates."})]}):s==="success"?r.jsx("div",{className:"rounded-xl border border-emerald-200 bg-emerald-50 p-5 text-sm text-emerald-800 dark:border-emerald-900/40 dark:bg-emerald-950/30 dark:text-emerald-200",children:"Redemption submitted! You will be notified when reviewed."}):r.jsxs("form",{onSubmit:y=>{g(y)},className:"space-y-5",children:[a?.instructions?r.jsx("p",{className:"text-sm text-neutral-700 dark:text-neutral-300",children:a.instructions}):null,h?r.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:h}):null,a?.fields.map(y=>r.jsxs("div",{className:"space-y-1.5",children:[r.jsxs("label",{htmlFor:y.id,className:"block text-sm font-medium text-neutral-900 dark:text-neutral-50",children:[y.label,y.required?r.jsx("span",{className:"ml-1 text-red-500","aria-hidden":"true",children:"*"}):null]}),r.jsx(pS,{field:y,value:u[y.id]??"",onChange:w=>p(y.id,w)})]},y.id)),a?.estimatedProcessingDays?r.jsxs("p",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:["Estimated processing time: ",a.estimatedProcessingDays," business day",a.estimatedProcessingDays!==1?"s":"","."]}):null,r.jsx(J,{type:"submit",className:"w-full",disabled:d,children:d?"Submitting...":"Submit redemption info"})]})}function no({result:e,onContinueShopping:t,onViewOrders:n,className:s,serverUrl:o,authToken:a,tokenizedProductIds:i}){return e.kind==="idle"?null:e.kind==="success"?r.jsxs("div",{className:O("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",s),children:[r.jsx("div",{className:"text-sm font-semibold text-neutral-600 dark:text-neutral-400",children:"Receipt"}),r.jsx("h2",{className:"mt-2 text-2xl font-semibold",children:"Payment successful"}),r.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?.metadata?.recipient_email?r.jsxs("div",{className:"mt-4 rounded-xl border border-emerald-200 bg-emerald-50 p-4 dark:border-emerald-900/40 dark:bg-emerald-950/30",children:[r.jsx("div",{className:"text-sm font-semibold text-emerald-900 dark:text-emerald-200",children:"Gift card sent"}),r.jsxs("div",{className:"mt-1 text-sm text-emerald-800/90 dark:text-emerald-200/80",children:["A gift card has been sent to"," ",r.jsx("span",{className:"font-medium",children:e.order.metadata.recipient_email}),"."," ","The recipient will receive credits in their account."]})]}):e.order?.items.some(c=>c.title.toLowerCase().includes("gift card"))?r.jsxs("div",{className:"mt-4 rounded-xl border border-emerald-200 bg-emerald-50 p-4 dark:border-emerald-900/40 dark:bg-emerald-950/30",children:[r.jsx("div",{className:"text-sm font-semibold text-emerald-900 dark:text-emerald-200",children:"Gift card credits added"}),r.jsx("div",{className:"mt-1 text-sm text-emerald-800/90 dark:text-emerald-200/80",children:"Your gift card credits have been added to your account and are ready to use."})]}):null,e.order?r.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:[r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{children:[r.jsxs("div",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:["Order ",e.order.id]}),r.jsxs("div",{className:"mt-1 text-xs text-neutral-600 dark:text-neutral-400",children:[new Date(e.order.createdAt).toLocaleString()," · ",e.order.status]})]}),r.jsx("div",{className:"text-sm font-semibold",children:Fe({amount:e.order.total,currency:e.order.currency})})]}),r.jsxs("div",{className:"mt-3 space-y-2",children:[e.order.items.slice(0,4).map((c,l)=>r.jsxs("div",{className:"flex items-center justify-between gap-3 text-sm",children:[r.jsx("div",{className:"min-w-0 truncate",children:c.title}),r.jsxs("div",{className:"shrink-0 text-neutral-600 dark:text-neutral-400",children:["Qty ",c.qty]})]},`${c.title}-${l}`)),e.order.items.length>4?r.jsxs("div",{className:"text-xs text-neutral-600 dark:text-neutral-400",children:["+",e.order.items.length-4," more item(s)"]}):null]}),r.jsxs("div",{className:"mt-3 flex gap-3 text-sm",children:[Ze(e.order.receiptUrl)?r.jsx("a",{href:Ze(e.order.receiptUrl),className:"hover:underline",children:"Receipt"}):null,Ze(e.order.invoiceUrl)?r.jsx("a",{href:Ze(e.order.invoiceUrl),className:"hover:underline",children:"Invoice"}):null]})]}):e.orderId?r.jsxs("p",{className:"mt-4 text-xs text-neutral-500 dark:text-neutral-400",children:["Session/Order ID: ",r.jsx("span",{className:"font-mono",children:e.orderId})]}):null,(()=>{const c=i??e.order?.items.filter(l=>l.tokenizedAsset&&l.productId).map(l=>l.productId)??[];return!o||c.length===0?null:r.jsxs("div",{className:"mt-5 space-y-4",children:[r.jsx("div",{className:"text-sm font-semibold text-neutral-900 dark:text-neutral-50",children:"Complete your asset redemption"}),r.jsx("p",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:"Your tokenized asset was minted on-chain. Submit your redemption information below."}),c.map(l=>r.jsx("div",{className:"rounded-xl border border-neutral-200 bg-neutral-50 p-4 dark:border-neutral-800 dark:bg-neutral-900/40",children:r.jsx(to,{serverUrl:o,productId:l,authToken:a})},l))]})})(),r.jsxs("div",{className:"mt-6 flex flex-col gap-2 sm:flex-row",children:[t?r.jsx(J,{type:"button",onClick:t,children:"Continue shopping"}):null,n?r.jsx(J,{type:"button",variant:"outline",onClick:n,children:"View orders"}):null]})]}):e.kind==="cancel"?r.jsxs("div",{className:O("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",s),children:[r.jsx("h2",{className:"text-2xl font-semibold",children:"Checkout cancelled"}),r.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?r.jsx("div",{className:"mt-6",children:r.jsx(J,{type:"button",onClick:t,children:"Back to shop"})}):null]}):r.jsxs("div",{className:O("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",s),children:[r.jsx("h2",{className:"text-2xl font-semibold",children:"Payment failed"}),r.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?r.jsx("div",{className:"mt-6",children:r.jsx(J,{type:"button",onClick:t,children:"Back to shop"})}):null]})}function hS({onContinueShopping:e,onViewOrders:t,className:n,receiptClassName:s,serverUrl:o,authToken:a,tokenizedProductIds:i}){const c=ma();return c.kind==="idle"?r.jsx("div",{className:O("flex min-h-[50vh] items-center justify-center p-4",n),children:r.jsx("div",{className:"text-center text-neutral-600 dark:text-neutral-400",children:"Loading order details..."})}):r.jsx("div",{className:O("flex min-h-[50vh] items-center justify-center p-4",n),children:r.jsx(no,{result:c,onContinueShopping:e,onViewOrders:t,className:O("w-full max-w-lg",s),serverUrl:o,authToken:a,tokenizedProductIds:i})})}function gS({onContinueShopping:e,className:t,receiptClassName:n}){const s={kind:"cancel"};return r.jsx("div",{className:O("flex min-h-[50vh] items-center justify-center p-4",t),children:r.jsx(no,{result:s,onContinueShopping:e,className:O("w-full max-w-lg",n)})})}function xS(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 Gm({order:e,onView:t,className:n}){const s=`${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 r.jsx(Xe,{className:O("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:r.jsx(rt,{className:"p-5",children:r.jsxs("div",{className:"grid grid-cols-[1fr_auto] gap-x-4 gap-y-2",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[r.jsx("span",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:"Order"}),r.jsx("span",{className:"truncate font-mono text-sm font-semibold text-neutral-950/80 dark:text-neutral-50/80",children:e.id})]}),r.jsx("div",{className:"mt-0.5 text-xs text-neutral-600 dark:text-neutral-400",children:o})]}),r.jsx("div",{className:"flex items-start justify-end",children:r.jsx(ht,{variant:xS(e.status),className:"capitalize",children:a})}),r.jsx("div",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:s}),r.jsx("div",{className:"text-right text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:Fe({amount:e.total,currency:e.currency})}),r.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:[r.jsxs("div",{className:"flex items-center gap-1",children:[Ze(e.receiptUrl)?r.jsx(J,{asChild:!0,type:"button",variant:"ghost",size:"sm",className:"h-8 px-2",children:r.jsx("a",{href:Ze(e.receiptUrl),target:"_blank",rel:"noreferrer",children:"Receipt"})}):null,Ze(e.invoiceUrl)?r.jsx(J,{asChild:!0,type:"button",variant:"ghost",size:"sm",className:"h-8 px-2",children:r.jsx("a",{href:Ze(e.invoiceUrl),target:"_blank",rel:"noreferrer",children:"Invoice"})}):null]}),t?r.jsx(J,{type:"button",variant:"outline",size:"sm",className:"h-8",onClick:()=>t(e),children:"Details"}):null]})]})})})}function Ym({orders:e,onView:t,className:n}){return r.jsx("div",{className:O("grid gap-4",n),children:e.map(s=>r.jsx(Gm,{order:s,onView:t},s.id))})}function To(e,t,n){const s="https://explorer.solana.com",o=n==="mainnet-beta"?"":`?cluster=${n}`;return`${s}/${e}/${t}${o}`}function Po(e){return e.length<=12?e:`${e.slice(0,6)}...${e.slice(-4)}`}function vS(e,t){const n=e/100;try{return new Intl.NumberFormat(void 0,{style:"currency",currency:t}).format(n)}catch{return`${n.toFixed(2)} ${t}`}}const yS={securities:"Security Token",commodities:"Commodity Token",property:"Property Token",collectibles:"Collectible NFT"};function oi({mintAddress:e,mintSignature:t,burnSignature:n,assetClass:s,backingValueCents:o,backingCurrency:a,cluster:i="mainnet-beta",className:c}){if(!e&&!t)return null;const l=s?yS[s.toLowerCase()]??"Tokenized Asset":"Tokenized Asset",u=!!n;return r.jsx(Xe,{className:O("overflow-hidden rounded-xl border-neutral-200/70 bg-white shadow-sm dark:border-neutral-800 dark:bg-neutral-950",c),children:r.jsxs(rt,{className:"p-4",children:[r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(bS,{}),r.jsx("span",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:l})]}),u?r.jsx(ht,{className:"bg-amber-100 text-amber-800 dark:bg-amber-900/50 dark:text-amber-200",children:"redeemed"}):r.jsx(ht,{className:"bg-emerald-100 text-emerald-800 dark:bg-emerald-900/50 dark:text-emerald-200",children:"on-chain"})]}),r.jsxs("div",{className:"mt-3 space-y-2 text-sm",children:[e&&r.jsx(Yr,{label:"Token address",value:Po(e),href:To("address",e,i),mono:!0}),t&&r.jsx(Yr,{label:"Mint transaction",value:Po(t),href:To("tx",t,i),mono:!0}),n&&r.jsx(Yr,{label:"Burn transaction",value:Po(n),href:To("tx",n,i),mono:!0}),o!=null&&a&&r.jsx(Yr,{label:"Backing value",value:vS(o,a)})]})]})})}function Yr({label:e,value:t,href:n,mono:s}){return r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsx("span",{className:"text-neutral-500 dark:text-neutral-400",children:e}),n?r.jsx("a",{href:n,target:"_blank",rel:"noreferrer",className:O("text-blue-600 underline decoration-blue-600/30 hover:decoration-blue-600 dark:text-blue-400",s&&"font-mono text-xs"),children:t}):r.jsx("span",{className:O("text-neutral-950 dark:text-neutral-50",s&&"font-mono text-xs"),children:t})]})}function bS(){return r.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-neutral-400 dark:text-neutral-500",children:[r.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),r.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})}function wS(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 Km({order:e,onBack:t,className:n,serverUrl:s,authToken:o}){const a=new Date(e.createdAt).toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}),i=e.status.charAt(0).toUpperCase()+e.status.slice(1),c=e.items.filter(d=>d.tokenizedAsset&&d.productId),[l,u]=b.useState({}),m=b.useCallback(async()=>{if(!s||!c.length)return;const d={"Content-Type":"application/json"};o&&(d.Authorization=`Bearer ${o}`);const x={};await Promise.all(c.map(async h=>{try{const v=await fetch(`${s}/paywall/v1/asset-redemption/${encodeURIComponent(h.productId)}/status`,{headers:d});if(v.ok){const g=(await v.json()).redemptions?.[0];g&&(x[h.productId]={mintSignature:g.tokenMintSignature??void 0,burnSignature:g.tokenBurnSignature??void 0,status:g.status??void 0})}}catch{}})),u(x)},[s,o,c.map(d=>d.productId).join(",")]);return b.useEffect(()=>{m()},[m]),r.jsx(Xe,{className:O("overflow-hidden rounded-2xl border-neutral-200/70 bg-white shadow-sm dark:border-neutral-800 dark:bg-neutral-950",n),children:r.jsxs(rt,{className:"p-6",children:[r.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[r.jsx("span",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:"Order"}),r.jsx("span",{className:"truncate font-mono text-sm font-semibold text-neutral-950/80 dark:text-neutral-50/80",children:e.id})]}),r.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:[r.jsx("span",{children:a}),r.jsx("span",{className:"text-neutral-300 dark:text-neutral-700",children:"·"}),r.jsx("span",{children:i})]})]}),r.jsxs("div",{className:"flex items-center gap-2 sm:justify-end",children:[r.jsx(ht,{variant:wS(e.status),className:"capitalize",children:i}),t?r.jsx(J,{type:"button",variant:"outline",size:"sm",className:"h-8",onClick:t,children:"Back"}):null]})]}),r.jsx(lt,{className:"my-5"}),r.jsx("div",{className:"space-y-3",children:e.items.map((d,x)=>r.jsxs("div",{className:"flex items-start justify-between gap-4",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"truncate text-sm text-neutral-950 dark:text-neutral-50",children:d.title}),r.jsxs("div",{className:"mt-0.5 text-xs text-neutral-600 dark:text-neutral-400",children:["Qty ",d.qty]})]}),r.jsx("div",{className:"text-right text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:Fe({amount:d.unitPrice*d.qty,currency:d.currency})})]},`${d.title}-${x}`))}),e.metadata?.recipient_email?r.jsxs(r.Fragment,{children:[r.jsx(lt,{className:"my-5"}),r.jsxs("div",{className:"rounded-xl border border-emerald-200 bg-emerald-50 p-3 dark:border-emerald-900/40 dark:bg-emerald-950/30",children:[r.jsx("div",{className:"text-xs font-semibold text-emerald-900 dark:text-emerald-200",children:"Gift card"}),r.jsxs("div",{className:"mt-1 text-xs text-emerald-800/90 dark:text-emerald-200/80",children:["Sent to ",r.jsx("span",{className:"font-medium",children:e.metadata.recipient_email})]})]})]}):null,s&&c.length>0?r.jsxs(r.Fragment,{children:[r.jsx(lt,{className:"my-5"}),r.jsxs("div",{className:"space-y-3",children:[r.jsx("div",{className:"text-sm font-semibold text-neutral-900 dark:text-neutral-50",children:"Asset redemption"}),c.map(d=>{const x=l[d.productId];return r.jsxs("div",{className:"space-y-3",children:[r.jsx("div",{className:"text-xs font-medium text-neutral-600 dark:text-neutral-400",children:d.title}),x?.mintSignature&&r.jsx(oi,{mintSignature:x.mintSignature,burnSignature:x.burnSignature,assetClass:d.assetClass,backingValueCents:d.backingValueCents,backingCurrency:d.backingCurrency}),r.jsx("div",{className:"rounded-xl border border-neutral-200 bg-neutral-50 p-4 dark:border-neutral-800 dark:bg-neutral-900/40",children:r.jsx(to,{serverUrl:s,productId:d.productId,authToken:o})})]},d.productId)})]})]}):null,r.jsx(lt,{className:"my-5"}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:"Total"}),r.jsx("span",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:Fe({amount:e.total,currency:e.currency})})]}),Ze(e.receiptUrl)||Ze(e.invoiceUrl)?r.jsxs("div",{className:"mt-5 flex flex-wrap items-center gap-2",children:[Ze(e.receiptUrl)?r.jsx(J,{asChild:!0,type:"button",variant:"ghost",size:"sm",className:"h-8 px-2",children:r.jsx("a",{href:Ze(e.receiptUrl),target:"_blank",rel:"noreferrer",children:"Receipt"})}):null,Ze(e.invoiceUrl)?r.jsx(J,{asChild:!0,type:"button",variant:"ghost",size:"sm",className:"h-8 px-2",children:r.jsx("a",{href:Ze(e.invoiceUrl),target:"_blank",rel:"noreferrer",children:"Invoice"})}):null]}):null]})})}const kS={pending_info:"bg-amber-100 text-amber-800 dark:bg-amber-900/50 dark:text-amber-200",info_submitted:"bg-blue-100 text-blue-800 dark:bg-blue-900/50 dark:text-blue-200",approved:"bg-emerald-100 text-emerald-800 dark:bg-emerald-900/50 dark:text-emerald-200",completed:"bg-emerald-100 text-emerald-800 dark:bg-emerald-900/50 dark:text-emerald-200",processing:"bg-blue-100 text-blue-800 dark:bg-blue-900/50 dark:text-blue-200",rejected:"bg-red-100 text-red-800 dark:bg-red-900/50 dark:text-red-200"};function jS({status:e}){const t=e.replace(/_/g," ");return r.jsx(ht,{className:kS[e]??"bg-neutral-100 text-neutral-700 dark:bg-neutral-800 dark:text-neutral-300",children:t})}function _S({orders:e,serverUrl:t,authToken:n,className:s}){const[o,a]=b.useState({}),[i,c]=b.useState(!0),[l,u]=b.useState(null),m=e.flatMap(v=>v.items.filter(p=>p.tokenizedAsset&&p.productId).map(p=>p.productId)),d=[...new Set(m)],x=b.useCallback(async()=>{if(!d.length){c(!1);return}c(!0);const v={"Content-Type":"application/json"};n&&(v.Authorization=`Bearer ${n}`);const p={};await Promise.all(d.map(async g=>{try{const y=await fetch(`${t}/paywall/v1/asset-redemption/${encodeURIComponent(g)}/status`,{headers:v});if(y.ok){const w=await y.json();p[g]=(w.redemptions??[]).map(j=>({...j,productId:g}))}}catch{}})),a(p),c(!1)},[t,n,d.join(",")]);b.useEffect(()=>{x()},[x]);const h=[];for(const v of e){v.metadata?.recipient_email&&h.push({kind:"gift-card",order:v,recipientEmail:v.metadata.recipient_email});for(const p of v.items)if(p.tokenizedAsset&&p.productId){const g=o[p.productId]??[];if(g.length)for(const y of g)h.push({kind:"asset",order:v,item:p,status:y.status,redemptionId:y.redemptionId});else h.push({kind:"asset",order:v,item:p,status:null,redemptionId:null})}}return h.sort((v,p)=>{const g=new Date(v.order.createdAt).getTime();return new Date(p.order.createdAt).getTime()-g}),i?r.jsx("div",{className:O("py-8 text-center text-sm text-neutral-500 dark:text-neutral-400",s),children:"Loading redemptions..."}):h.length?r.jsxs("div",{className:O("space-y-3",s),children:[r.jsx("h2",{className:"text-lg font-semibold text-neutral-950 dark:text-neutral-50",children:"My Redemptions"}),h.map((v,p)=>v.kind==="gift-card"?r.jsx(SS,{order:v.order,recipientEmail:v.recipientEmail},`gc-${v.order.id}-${p}`):r.jsx(CS,{order:v.order,item:v.item,status:v.status,isExpanded:l===v.item.productId,onToggle:()=>u(g=>g===v.item.productId?null:v.item.productId),serverUrl:t,authToken:n},`ar-${v.order.id}-${v.item.productId}-${p}`))]}):r.jsxs("div",{className:O("py-12 text-center",s),children:[r.jsx("div",{className:"text-sm font-medium text-neutral-900 dark:text-neutral-100",children:"No redemptions yet"}),r.jsx("div",{className:"mt-1 text-xs text-neutral-500 dark:text-neutral-400",children:"Redemptions from tokenized asset purchases and gift card claims will appear here."})]})}function SS({order:e,recipientEmail:t}){return r.jsx(Xe,{className:"rounded-xl border-neutral-200/70 bg-white shadow-sm dark:border-neutral-800 dark:bg-neutral-950",children:r.jsx(rt,{className:"p-4",children:r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"text-sm font-medium text-neutral-950 dark:text-neutral-50",children:"Gift card sent"}),r.jsxs("div",{className:"mt-0.5 text-xs text-neutral-500 dark:text-neutral-400",children:["To ",t]})]}),r.jsxs("div",{className:"text-right",children:[r.jsx("div",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:Fe({amount:e.total,currency:e.currency})}),r.jsx("div",{className:"mt-0.5 text-xs text-neutral-400",children:new Date(e.createdAt).toLocaleDateString()})]})]})})})}function CS({order:e,item:t,status:n,isExpanded:s,onToggle:o,serverUrl:a,authToken:i}){return r.jsx(Xe,{className:"rounded-xl border-neutral-200/70 bg-white shadow-sm dark:border-neutral-800 dark:bg-neutral-950",children:r.jsxs(rt,{className:"p-4",children:[r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"text-sm font-medium text-neutral-950 dark:text-neutral-50",children:t.title}),r.jsxs("div",{className:"mt-0.5 flex items-center gap-2 text-xs text-neutral-500 dark:text-neutral-400",children:[r.jsxs("span",{children:["Order ",e.id.slice(0,8),"..."]}),r.jsx("span",{children:new Date(e.createdAt).toLocaleDateString()})]})]}),r.jsx("div",{className:"flex items-center gap-2",children:n?r.jsx(jS,{status:n}):r.jsx(ht,{className:"bg-neutral-100 text-neutral-600 dark:bg-neutral-800 dark:text-neutral-400",children:"awaiting info"})})]}),(!n||n==="pending_info")&&r.jsxs("div",{className:"mt-3",children:[r.jsx(J,{type:"button",variant:"outline",size:"sm",className:"h-7 text-xs",onClick:o,children:s?"Hide form":"Submit redemption info"}),s&&t.productId&&r.jsx("div",{className:"mt-3 rounded-lg border border-neutral-200 bg-neutral-50 p-4 dark:border-neutral-800 dark:bg-neutral-900/40",children:r.jsx(to,{serverUrl:a,productId:t.productId,authToken:i})})]})]})})}function NS({orders:e,serverUrl:t,authToken:n,cluster:s="mainnet-beta",className:o}){const[a,i]=b.useState({}),[c,l]=b.useState(!0),u=e.flatMap(h=>h.items.filter(v=>v.tokenizedAsset&&v.productId).map(v=>v.productId)),m=[...new Set(u)],d=b.useCallback(async()=>{if(!m.length){l(!1);return}l(!0);const h={"Content-Type":"application/json"};n&&(h.Authorization=`Bearer ${n}`);const v={};await Promise.all(m.map(async p=>{try{const g=await fetch(`${t}/paywall/v1/asset-redemption/${encodeURIComponent(p)}/status`,{headers:h});if(g.ok){const w=(await g.json()).redemptions?.[0];w&&(v[p]={tokenMintSignature:w.tokenMintSignature??void 0,tokenBurnSignature:w.tokenBurnSignature??void 0,status:w.status??void 0})}}catch{}})),i(v),l(!1)},[t,n,m.join(",")]);b.useEffect(()=>{d()},[d]);const x=[];for(const h of e)for(const v of h.items)if(v.tokenizedAsset&&v.productId){const p=a[v.productId];x.push({order:h,item:v,mintSignature:p?.tokenMintSignature,burnSignature:p?.tokenBurnSignature,status:p?.status})}return x.sort((h,v)=>{const p=new Date(h.order.createdAt).getTime();return new Date(v.order.createdAt).getTime()-p}),c?r.jsx("div",{className:O("py-8 text-center text-sm text-neutral-500 dark:text-neutral-400",o),children:"Loading tokens..."}):x.length?r.jsxs("div",{className:O("space-y-4",o),children:[r.jsx("h2",{className:"text-lg font-semibold text-neutral-950 dark:text-neutral-50",children:"My Tokens"}),r.jsxs("div",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:[x.length," token",x.length===1?"":"s"]}),r.jsx("div",{className:"grid gap-4 sm:grid-cols-2",children:x.map((h,v)=>r.jsxs("div",{className:"space-y-2",children:[r.jsx("div",{className:"text-sm font-medium text-neutral-950 dark:text-neutral-50",children:h.item.title}),r.jsxs("div",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:["Order ",h.order.id.slice(0,8),"... ·"," ",new Date(h.order.createdAt).toLocaleDateString()]}),r.jsx(oi,{mintSignature:h.mintSignature,burnSignature:h.burnSignature,assetClass:h.item.assetClass,backingValueCents:h.item.backingValueCents,backingCurrency:h.item.backingCurrency,cluster:s})]},`${h.item.productId}-${v}`))})]}):r.jsxs("div",{className:O("py-12 text-center",o),children:[r.jsx("div",{className:"text-sm font-medium text-neutral-900 dark:text-neutral-100",children:"No tokens yet"}),r.jsx("div",{className:"mt-1 text-xs text-neutral-500 dark:text-neutral-400",children:"Tokens from tokenized asset purchases will appear here."})]})}function bs(e,t){const n=e/100;try{return new Intl.NumberFormat(void 0,{style:"currency",currency:t}).format(n)}catch{return`${n.toFixed(2)} ${t}`}}function AS({serverUrl:e,token:t,authToken:n,onSignIn:s,onContinueShopping:o,className:a}){const[i,c]=b.useState({kind:"loading"}),l=b.useCallback(async()=>{c({kind:"loading"});try{const m=await fetch(`${e}/paywall/v1/gift-card/claim/${encodeURIComponent(t)}`);if(m.status===404){c({kind:"not-found"});return}if(!m.ok){const x=await m.text().catch(()=>`HTTP ${m.status}`);c({kind:"error",message:x});return}const d=await m.json();d.claimed?c({kind:"already-claimed",data:d}):c({kind:"info",data:d})}catch(m){c({kind:"error",message:m instanceof Error?m.message:"Network error"})}},[e,t]);b.useEffect(()=>{l()},[l]);const u=b.useCallback(async()=>{if(n){c({kind:"claiming"});try{const m=await fetch(`${e}/paywall/v1/gift-card/claim/${encodeURIComponent(t)}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`}});if(!m.ok){const x=await m.text().catch(()=>`HTTP ${m.status}`);c({kind:"error",message:x});return}const d=await m.json();c({kind:"claimed",result:d})}catch(m){c({kind:"error",message:m instanceof Error?m.message:"Network error"})}}},[e,t,n]);return r.jsx("div",{className:O("flex min-h-[50vh] items-center justify-center p-4",a),children:r.jsx(Xe,{className:"w-full max-w-md overflow-hidden rounded-2xl border-neutral-200/70 bg-white shadow-sm dark:border-neutral-800 dark:bg-neutral-950",children:r.jsx(rt,{className:"p-8",children:i.kind==="loading"?r.jsx(ES,{}):i.kind==="not-found"?r.jsx(IS,{}):i.kind==="error"?r.jsx(TS,{message:i.message,onRetry:l}):i.kind==="already-claimed"?r.jsx(PS,{data:i.data,onContinueShopping:o}):i.kind==="info"?r.jsx(RS,{data:i.data,isAuthenticated:!!n,onClaim:u,onSignIn:s}):i.kind==="claiming"?r.jsx(OS,{}):r.jsx(MS,{result:i.result,onContinueShopping:o})})})})}function ES(){return r.jsx("div",{className:"text-center text-neutral-600 dark:text-neutral-400",children:"Loading gift card details..."})}function IS(){return r.jsxs("div",{className:"text-center",children:[r.jsx("h2",{className:"text-xl font-semibold text-neutral-950 dark:text-neutral-50",children:"Gift card not found"}),r.jsx("p",{className:"mt-2 text-sm text-neutral-600 dark:text-neutral-400",children:"This gift card link is invalid or has expired. Please check the link and try again."})]})}function TS({message:e,onRetry:t}){return r.jsxs("div",{className:"text-center",children:[r.jsx("h2",{className:"text-xl font-semibold text-neutral-950 dark:text-neutral-50",children:"Something went wrong"}),r.jsx("p",{className:"mt-2 text-sm text-neutral-600 dark:text-neutral-400",children:e}),r.jsx("div",{className:"mt-4",children:r.jsx(J,{type:"button",variant:"outline",size:"sm",onClick:t,children:"Try again"})})]})}function PS({data:e,onContinueShopping:t}){return r.jsxs("div",{className:"text-center",children:[r.jsx("h2",{className:"text-xl font-semibold text-neutral-950 dark:text-neutral-50",children:"Already claimed"}),r.jsxs("p",{className:"mt-2 text-sm text-neutral-600 dark:text-neutral-400",children:["This ",bs(e.faceValueCents,e.currency)," gift card has already been redeemed. The credits are in your account."]}),t?r.jsx("div",{className:"mt-6",children:r.jsx(J,{type:"button",onClick:t,children:"Continue shopping"})}):null]})}function RS({data:e,isAuthenticated:t,onClaim:n,onSignIn:s}){const o=bs(e.faceValueCents,e.currency);return r.jsxs("div",{className:"text-center",children:[r.jsx("div",{className:"text-sm font-semibold text-emerald-700 dark:text-emerald-400",children:"Gift card"}),r.jsx("div",{className:"mt-2 text-4xl font-bold text-neutral-950 dark:text-neutral-50",children:o}),r.jsx("p",{className:"mt-3 text-sm text-neutral-600 dark:text-neutral-400",children:e.recipientEmail?`A gift card for ${e.recipientEmail} is ready to claim.`:"You have a gift card ready to claim."}),r.jsx("p",{className:"mt-1 text-xs text-neutral-500 dark:text-neutral-500",children:"Credits will be added to your account and can be used for purchases."}),r.jsx("div",{className:"mt-6",children:t?r.jsxs(J,{type:"button",onClick:n,className:"w-full",children:["Claim ",o," credits"]}):r.jsxs(r.Fragment,{children:[r.jsx(J,{type:"button",onClick:s,className:"w-full",children:"Sign in to claim"}),r.jsx("p",{className:"mt-2 text-xs text-neutral-500 dark:text-neutral-500",children:"You need to sign in or create an account to receive your credits."})]})})]})}function OS(){return r.jsx("div",{className:"text-center text-neutral-600 dark:text-neutral-400",children:"Claiming your gift card..."})}function MS({result:e,onContinueShopping:t}){const n=bs(e.creditsAdded,e.currency),s=bs(e.newBalance,e.currency);return r.jsxs("div",{className:"text-center",children:[r.jsx("h2",{className:"text-xl font-semibold text-neutral-950 dark:text-neutral-50",children:"Gift card claimed"}),r.jsxs("div",{className:"mt-4 rounded-xl border border-emerald-200 bg-emerald-50 p-4 dark:border-emerald-900/40 dark:bg-emerald-950/30",children:[r.jsxs("div",{className:"text-sm font-semibold text-emerald-900 dark:text-emerald-200",children:[n," credits added"]}),r.jsxs("div",{className:"mt-1 text-xs text-emerald-800/90 dark:text-emerald-200/80",children:["Your new balance is ",s]})]}),t?r.jsx("div",{className:"mt-6",children:r.jsx(J,{type:"button",onClick:t,children:"Start shopping"})}):null]})}function LS(e,t){const n=e/100;try{return new Intl.NumberFormat(void 0,{style:"currency",currency:t}).format(n)}catch{return`${n.toFixed(2)} ${t}`}}function DS(e){try{return new Date(e).toLocaleDateString(void 0,{month:"long",day:"numeric",year:"numeric"})}catch{return e}}function zS({serverUrl:e,className:t}){const[n,s]=b.useState(""),[o,a]=b.useState({kind:"idle"}),i=b.useCallback(async c=>{c.preventDefault();const l=n.trim();if(l){a({kind:"loading"});try{const u=await fetch(`${e}/paywall/v1/gift-card/balance/${encodeURIComponent(l)}`);if(u.status===404){a({kind:"not-found"});return}if(!u.ok){const d=await u.text().catch(()=>`HTTP ${u.status}`);a({kind:"error",message:d});return}const m=await u.json();a({kind:"result",data:m})}catch(u){a({kind:"error",message:u instanceof Error?u.message:"Network error"})}}},[e,n]);return r.jsx(Xe,{className:O("w-full max-w-md overflow-hidden rounded-2xl border-neutral-200/70 bg-white shadow-sm dark:border-neutral-800 dark:bg-neutral-950",t),children:r.jsxs(rt,{className:"p-6",children:[r.jsx("h2",{className:"mb-4 text-lg font-semibold text-neutral-950 dark:text-neutral-50",children:"Check gift card balance"}),r.jsxs("form",{onSubmit:c=>void i(c),className:"space-y-3",children:[r.jsx(Te,{type:"text",value:n,onChange:c=>s(c.target.value),placeholder:"Enter gift card code",required:!0,className:"font-mono tracking-wide uppercase"}),r.jsx(J,{type:"submit",className:"w-full",disabled:o.kind==="loading"||!n.trim(),children:o.kind==="loading"?"Checking...":"Check balance"})]}),o.kind==="result"&&r.jsx($S,{data:o.data}),o.kind==="not-found"&&r.jsx("div",{className:"mt-4 rounded-lg border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-800 dark:border-amber-900/40 dark:bg-amber-950/30 dark:text-amber-200",children:"No gift card found with that code. Please check the code and try again."}),o.kind==="error"&&r.jsx("div",{className:"mt-4 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:o.message})]})})}function $S({data:e}){const t=e.expiresAt&&new Date(e.expiresAt)<=new Date,n=e.active&&!t&&e.balance>0;return r.jsxs("div",{className:"mt-4 space-y-3",children:[r.jsxs("div",{className:O("rounded-xl border p-4 text-center",n?"border-emerald-200 bg-emerald-50 dark:border-emerald-900/40 dark:bg-emerald-950/30":"border-neutral-200 bg-neutral-50 dark:border-neutral-800 dark:bg-neutral-900/50"),children:[r.jsx("div",{className:"text-xs font-medium uppercase tracking-wider text-neutral-500 dark:text-neutral-400",children:"Available balance"}),r.jsx("div",{className:O("mt-1 text-3xl font-bold",n?"text-emerald-700 dark:text-emerald-300":"text-neutral-400 dark:text-neutral-600"),children:LS(e.balance,e.currency)})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[r.jsx("div",{className:"text-neutral-500 dark:text-neutral-400",children:"Status"}),r.jsx("div",{className:"text-right",children:e.active?t?r.jsx("span",{className:"text-amber-600 dark:text-amber-400",children:"Expired"}):e.balance===0?r.jsx("span",{className:"text-neutral-500 dark:text-neutral-400",children:"Fully used"}):r.jsx("span",{className:"text-emerald-600 dark:text-emerald-400",children:"Active"}):r.jsx("span",{className:"text-red-600 dark:text-red-400",children:"Inactive"})}),e.expiresAt&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"text-neutral-500 dark:text-neutral-400",children:"Expires"}),r.jsx("div",{className:O("text-right",t?"text-amber-600 dark:text-amber-400":"text-neutral-900 dark:text-neutral-100"),children:DS(e.expiresAt)})]})]})]})}function ai(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),e.tokenizedAssetConfig&&(t.tokenizedAsset="true",e.tokenizedAssetConfig.regulatoryNotice&&(t.regulatoryNotice=e.tokenizedAssetConfig.regulatoryNotice),e.tokenizedAssetConfig.assetClass&&(t.assetClass=e.tokenizedAssetConfig.assetClass),e.tokenizedAssetConfig.backingValueCents!=null&&(t.backingValueCents=String(e.tokenizedAssetConfig.backingValueCents)),e.tokenizedAssetConfig.backingCurrency&&(t.backingCurrency=e.tokenizedAssetConfig.backingCurrency)),Object.keys(t).length?t:void 0}function FS(e){return r.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:r.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 US={shop:"/shop",category:e=>`/shop/${e}`,product:e=>`/product/${e}`,cart:"/cart",checkout:"/checkout",orders:"/account/orders",subscribe:"/subscribe"};function BS(e){const t=new Set;let n=Number.POSITIVE_INFINITY,s=0;for(const i of e){for(const c of i.tags??[])t.add(c);n=Math.min(n,i.price),s=Math.max(s,i.price)}const o=Array.from(t).slice(0,12),a=Number.isFinite(n)?{min:n,max:s}:void 0;return{tags:o,price:a}}function VS({className:e,routes:t,initialCategorySlug:n}){const{config:s}=Ae(),o=Et(),a=Js(),i={...US,...t},[c,l]=f.useState("cart"),[u,m]=f.useState(()=>typeof window>"u"?!1:window.matchMedia?.("(min-width: 1024px)")?.matches??!1);f.useEffect(()=>{if(typeof window>"u")return;const P=window.matchMedia?.("(min-width: 1024px)");if(!P)return;const H=()=>m(P.matches);return H(),P.addEventListener?.("change",H),()=>P.removeEventListener?.("change",H)},[]);const{categories:d,isLoading:x,error:h}=da(),v=f.useMemo(()=>fa({includeCategory:!0}),[]),[p,g]=f.useState(v?.search??""),[y,w]=f.useState(n??v?.category),[j,k]=f.useState(v?.page??1),[_,S]=f.useState(v?.sort??"featured"),[A,E]=f.useState(v?.filters??{}),{data:I,isLoading:T,error:U}=Cs({category:y,search:p.trim()||void 0,filters:A,sort:_,page:j,pageSize:24}),L=f.useMemo(()=>BS(I?.items??[]),[I?.items]),{settings:B}=qn(),z=B.catalog.filters,K=B.catalog.sort,V=f.useMemo(()=>{const P=[];return K.featured&&P.push({value:"featured",label:"Featured"}),K.priceAsc&&P.push({value:"price_asc",label:"Price: Low to High"}),K.priceDesc&&P.push({value:"price_desc",label:"Price: High to Low"}),P.length===0&&P.push({value:"featured",label:"Featured"}),P},[K]);f.useEffect(()=>{V.some(P=>P.value===_)||S(V[0].value)},[V,_]),pa({search:p,sort:_,page:j,category:y,filters:A},{includeCategory:!0});const[G,D]=f.useState(!1),[se,le]=f.useState(!1),[N,R]=f.useState(null),[F,Q]=f.useState(!1),Y=P=>{w(P.slug),k(1),D(!1)},ce=f.useCallback((P,H,de)=>{o.addItem({productId:P.id,variantId:H?.id,unitPrice:P.price,currency:P.currency,titleSnapshot:H?`${P.title} — ${H.title}`:P.title,imageSnapshot:P.images[0]?.url,paymentResource:P.id,metadata:ai(P)},de),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"),le(!0)))}})},[o,i.cart,a]);return r.jsxs("div",{className:O("min-h-screen bg-neutral-50 text-neutral-950 dark:bg-neutral-950 dark:text-neutral-50",e),children:[r.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:r.jsxs("div",{className:"mx-auto flex max-w-7xl items-center gap-3 px-4 py-3",children:[r.jsx("a",{href:i.shop,className:"text-sm font-semibold tracking-tight",children:s.brand?.name??"Shop"}),r.jsx("div",{className:"flex-1",children:r.jsx(ti,{value:p,onChange:g})}),r.jsxs("div",{className:"flex items-center gap-2 lg:hidden",children:[r.jsxs(Vs,{open:G,onOpenChange:D,children:[r.jsx(Ws,{asChild:!0,children:r.jsx(J,{type:"button",variant:"outline",children:"Filters"})}),r.jsxs(Ir,{side:"left",children:[r.jsx(qs,{children:r.jsx(Hs,{children:"Browse"})}),r.jsxs("div",{className:"mt-4",children:[h?r.jsx(Ft,{description:h}):null,x?r.jsxs("div",{className:"space-y-2",children:[r.jsx(Oe,{className:"h-9"}),r.jsx(Oe,{className:"h-9"}),r.jsx(Oe,{className:"h-9"})]}):r.jsxs("div",{className:"space-y-6",children:[r.jsx(Xo,{categories:d,activeSlug:y,onSelect:Y}),r.jsx(ys,{facets:L,value:A,onChange:P=>{E(P),k(1)},onClear:()=>{E({}),k(1)},enabledFilters:z}),V.length>1&&r.jsxs("div",{className:"space-y-2",children:[r.jsx("div",{className:"text-sm font-semibold",children:"Sort"}),r.jsxs(hs,{value:_,onValueChange:P=>{S(P),k(1)},children:[r.jsx(kr,{"aria-label":"Sort",children:r.jsx(gs,{placeholder:"Sort"})}),r.jsx(jr,{children:V.map(P=>r.jsx(_r,{value:P.value,children:P.label},P.value))})]})]})]})]})]})]}),r.jsx(Cr,{open:!u&&se,onOpenChange:le,side:"bottom",preferredTab:c,onCheckout:()=>{typeof window<"u"&&window.location.assign(i.checkout)},trigger:r.jsxs(J,{type:"button",variant:"default",onClick:()=>l("cart"),children:["Cart (",o.count,")"]})})]}),r.jsxs("div",{className:"hidden lg:flex items-center gap-2",children:[r.jsx(Cr,{open:u&&se,onOpenChange:le,side:"popup",preferredTab:c,onCheckout:()=>{typeof window<"u"&&window.location.assign(i.checkout)},trigger:r.jsxs(J,{type:"button",variant:"outline",onClick:()=>l("cart"),children:["Cart (",o.count,")"]})}),r.jsx(J,{type:"button",variant:"default",onClick:()=>{typeof window<"u"&&window.location.assign(i.checkout)},children:"Checkout"})]})]})}),r.jsxs(J,{type:"button",variant:"ghost",className:O("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",se?"lg:hidden":void 0),onClick:()=>{l("chat"),le(!0)},"aria-label":"Open chat",children:[r.jsx(FS,{className:"h-4 w-4"}),"Chat"]}),r.jsxs("main",{className:"mx-auto grid max-w-7xl items-start gap-6 px-4 py-6 lg:grid-cols-[280px_1fr]",children:[r.jsx("aside",{className:"hidden lg:block",children:r.jsx("div",{className:"sticky top-24",children:r.jsxs(Xe,{className:"flex max-h-[calc(100vh-6rem)] flex-col rounded-2xl",children:[r.jsx(vr,{className:"pb-4",children:r.jsx(yr,{className:"text-base",children:"Browse"})}),r.jsxs(rt,{className:"flex-1 space-y-6 overflow-y-auto pr-2",children:[r.jsxs("div",{children:[r.jsx("div",{className:"text-sm font-semibold",children:"Categories"}),h?r.jsx(Ft,{className:"mt-3",description:h}):null,x?r.jsxs("div",{className:"mt-3 space-y-2",children:[r.jsx(Oe,{className:"h-9"}),r.jsx(Oe,{className:"h-9"}),r.jsx(Oe,{className:"h-9"})]}):r.jsx("div",{className:"mt-3",children:r.jsx(Xo,{categories:d,activeSlug:y,onSelect:Y})})]}),V.length>1&&r.jsxs("div",{children:[r.jsx("div",{className:"text-sm font-semibold",children:"Sort"}),r.jsx("div",{className:"mt-2",children:r.jsxs(hs,{value:_,onValueChange:P=>{S(P),k(1)},children:[r.jsx(kr,{"aria-label":"Sort",children:r.jsx(gs,{placeholder:"Sort"})}),r.jsx(jr,{children:V.map(P=>r.jsx(_r,{value:P.value,children:P.label},P.value))})]})})]}),r.jsx(ys,{facets:L,value:A,onChange:P=>{E(P),k(1)},onClear:()=>{E({}),k(1)},enabledFilters:z})]})]})})}),r.jsxs("section",{children:[r.jsx("div",{className:"flex items-end justify-between gap-3",children:r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:B.shopPage.title||"Shop"}),B.shopPage.description&&r.jsx("p",{className:"mt-1 text-sm text-neutral-600 dark:text-neutral-400",children:B.shopPage.description})]})}),U?r.jsx(Ft,{className:"mt-6",description:U}):null,T?r.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,H)=>r.jsx(Oe,{className:"aspect-[4/5] rounded-2xl"},H))}):r.jsxs("div",{className:"mt-6",children:[r.jsx(eo,{products:I?.items??[],columns:s.ui?.productGrid?.columns,getProductHref:P=>i.product(P.slug),onAddToCart:P=>ce(P,null,1),onQuickView:P=>{R(P),Q(!0)},layout:B.shopLayout.layout,imageCrop:B.shopLayout.imageCrop}),r.jsxs("div",{className:"mt-8 flex items-center justify-between",children:[r.jsx(J,{type:"button",variant:"outline",disabled:j<=1,onClick:()=>k(P=>Math.max(1,P-1)),children:"Previous"}),r.jsxs("div",{className:"text-xs text-neutral-600 dark:text-neutral-400",children:["Page ",j]}),r.jsx(J,{type:"button",variant:"outline",disabled:!I?.hasNextPage,onClick:()=>k(P=>P+1),children:"Next"})]})]})]})]}),r.jsx(Xa,{product:N,open:F,onOpenChange:Q,productHref:P=>i.product(P),onAddToCart:(P,H,de)=>ce(P,H,de)})]})}function WS(e){return r.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:r.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 qS({categorySlug:e,className:t,routes:n}){const{config:s}=Ae(),o=Et(),a=Js(),{categories:i}=da(),[c,l]=f.useState(()=>typeof window>"u"?!1:window.matchMedia?.("(min-width: 1024px)")?.matches??!1);f.useEffect(()=>{if(typeof window>"u")return;const W=window.matchMedia?.("(min-width: 1024px)");if(!W)return;const re=()=>l(W.matches);return re(),W.addEventListener?.("change",re),()=>W.removeEventListener?.("change",re)},[]);const[u,m]=f.useState(!1),[d,x]=f.useState(!1),[h,v]=f.useState("cart"),p=f.useMemo(()=>fa({includeCategory:!1}),[]),[g,y]=f.useState(p?.search??""),[w,j]=f.useState(p?.page??1),[k,_]=f.useState(p?.sort??"featured"),[S,A]=f.useState(p?.filters??{}),[E,I]=f.useState(null),[T,U]=f.useState(!1),L=i.find(W=>W.slug===e)??null,{data:B,isLoading:z,error:K}=Cs({category:e,search:g.trim()||void 0,filters:S,sort:k,page:w,pageSize:24}),V=n?.product??(W=>`/product/${W}`),G=n?.shop??"/shop",D=n?.cart??"/cart",se=n?.checkout??"/checkout",le=f.useMemo(()=>{const W=B?.items??[],re=new Set;let ie=Number.POSITIVE_INFINITY,ye=0;for(const Ke of W){for(const Ve of Ke.tags??[])re.add(Ve);ie=Math.min(ie,Ke.price),ye=Math.max(ye,Ke.price)}const fe=Array.from(re).slice(0,12),Be=Number.isFinite(ie)?{min:ie,max:ye}:void 0;return{tags:fe,price:Be}},[B?.items]),{settings:N}=qn(),R=N.catalog.filters,F=N.catalog.sort,Q=f.useMemo(()=>{const W=[];return F.featured&&W.push({value:"featured",label:"Featured"}),F.priceAsc&&W.push({value:"price_asc",label:"Price: Low to High"}),F.priceDesc&&W.push({value:"price_desc",label:"Price: High to Low"}),W.length===0&&W.push({value:"featured",label:"Featured"}),W},[F]);f.useEffect(()=>{Q.some(W=>W.value===k)||_(Q[0].value)},[Q,k]),pa({search:g,sort:k,page:w,filters:S},{includeCategory:!1});const Y=f.useCallback((W,re,ie)=>{o.addItem({productId:W.id,variantId:re?.id,unitPrice:W.price,currency:W.currency,titleSnapshot:re?`${W.title} — ${re.title}`:W.title,imageSnapshot:W.images[0]?.url,paymentResource:W.id,metadata:ai(W)},ie),a?.toast({title:"Added to cart",description:W.title,actionLabel:"View cart",onAction:()=>{typeof window<"u"&&(window.matchMedia?.("(min-width: 1024px)").matches?window.location.assign(D):(v("cart"),x(!0)))}})},[o,D,a]),ce=W=>{A(W),j(1)},P=()=>{A({}),j(1)},H=W=>{_(W),j(1)},de=r.jsx(Xe,{className:"flex max-h-[calc(100vh-6rem)] flex-col rounded-2xl",children:r.jsxs(rt,{className:"flex-1 space-y-5 overflow-y-auto pr-2 pt-6",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[r.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-neutral-500 dark:text-neutral-400",children:"Category"}),r.jsx(J,{asChild:!0,type:"button",variant:"ghost",size:"sm",className:"h-8 px-2 text-xs",children:r.jsx("a",{href:G,children:"All categories"})})]}),r.jsx("div",{className:"text-base font-semibold text-neutral-950 dark:text-neutral-50",children:L?.name??e}),r.jsx("div",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:L?.description??"Browse products in this category."})]}),Q.length>1&&r.jsxs("div",{className:"space-y-2",children:[r.jsx("div",{className:"text-sm font-semibold",children:"Sort"}),r.jsxs(hs,{value:k,onValueChange:H,children:[r.jsx(kr,{"aria-label":"Sort",children:r.jsx(gs,{placeholder:"Sort"})}),r.jsx(jr,{children:Q.map(W=>r.jsx(_r,{value:W.value,children:W.label},W.value))})]})]}),r.jsx(lt,{}),r.jsx(ys,{facets:le,value:S,onChange:ce,onClear:P,enabledFilters:R})]})});return r.jsxs("div",{className:O("min-h-screen bg-neutral-50 text-neutral-950 dark:bg-neutral-950 dark:text-neutral-50",t),children:[r.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:r.jsxs("div",{className:"mx-auto flex max-w-7xl items-center gap-3 px-4 py-3",children:[r.jsx("a",{href:G,className:"text-sm font-semibold tracking-tight",children:s.brand?.name??"Shop"}),r.jsx("div",{className:"flex-1",children:r.jsx(ti,{value:g,onChange:y})}),r.jsxs("div",{className:"flex items-center gap-2 lg:hidden",children:[r.jsxs(Vs,{open:u,onOpenChange:m,children:[r.jsx(Ws,{asChild:!0,children:r.jsx(J,{type:"button",variant:"outline",children:"Filters"})}),r.jsxs(Ir,{side:"left",children:[r.jsx(qs,{children:r.jsx(Hs,{children:"Filters"})}),r.jsx("div",{className:"mt-4",children:de})]})]}),r.jsx(Cr,{open:!c&&d,onOpenChange:x,side:"bottom",preferredTab:h,onCheckout:()=>{typeof window<"u"&&window.location.assign(se)},trigger:r.jsxs(J,{type:"button",variant:"default",onClick:()=>v("cart"),children:["Cart (",o.count,")"]})})]}),r.jsxs("div",{className:"hidden lg:flex items-center gap-2",children:[r.jsx(Cr,{open:c&&d,onOpenChange:x,side:"popup",preferredTab:h,onCheckout:()=>{typeof window<"u"&&window.location.assign(se)},trigger:r.jsxs(J,{type:"button",variant:"outline",onClick:()=>v("cart"),children:["Cart (",o.count,")"]})}),r.jsx(J,{type:"button",variant:"default",onClick:()=>{typeof window<"u"&&window.location.assign(se)},children:"Checkout"})]})]})}),r.jsxs(J,{type:"button",variant:"ghost",className:O("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",d?"lg:hidden":void 0),onClick:()=>{v("chat"),x(!0)},"aria-label":"Open chat",children:[r.jsx(WS,{className:"h-4 w-4"}),"Chat"]}),r.jsxs("main",{className:"mx-auto max-w-7xl px-4 py-8",children:[r.jsx(ei,{items:[{label:"Shop",href:G},{label:L?.name??e}]}),r.jsxs("div",{className:"mt-6",children:[r.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:L?.name??"Category"}),r.jsx("p",{className:"mt-1 text-sm text-neutral-600 dark:text-neutral-400",children:L?.description??"Browse products in this category."})]}),K?r.jsx(Ft,{className:"mt-6",description:K}):null,r.jsxs("div",{className:"mt-6 grid gap-6 lg:grid-cols-[280px_1fr]",children:[r.jsx("aside",{className:"hidden lg:block",children:r.jsx("div",{className:"sticky top-24",children:de})}),r.jsx("div",{children:z?r.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((W,re)=>r.jsx(Oe,{className:"aspect-[4/5] rounded-2xl"},re))}):r.jsxs("div",{className:"mt-6",children:[r.jsx(eo,{products:B?.items??[],columns:s.ui?.productGrid?.columns,getProductHref:W=>V(W.slug),onAddToCart:W=>Y(W,null,1),onQuickView:W=>{I(W),U(!0)},layout:N.categoryLayout.layout,imageCrop:N.categoryLayout.imageCrop}),r.jsxs("div",{className:"mt-8 flex items-center justify-between",children:[r.jsx(J,{type:"button",variant:"outline",disabled:w<=1,onClick:()=>j(W=>Math.max(1,W-1)),children:"Previous"}),r.jsxs("div",{className:"text-xs text-neutral-600 dark:text-neutral-400",children:["Page ",w]}),r.jsx(J,{type:"button",variant:"outline",disabled:!B?.hasNextPage,onClick:()=>j(W=>W+1),children:"Next"})]})]})})]}),r.jsx(Xa,{product:E,open:T,onOpenChange:U,productHref:W=>V(W),onAddToCart:(W,re,ie)=>Y(W,re,ie)})]})]})}function HS(e){return!e||typeof e!="string"?[]:e.split(",").map(t=>t.trim()).filter(Boolean)}function ZS({config:e,currency:t}){return r.jsxs("div",{className:"mt-4 rounded-xl border border-neutral-200 bg-neutral-50 p-4 dark:border-neutral-800 dark:bg-neutral-900/40",children:[r.jsx("div",{className:"text-xs font-semibold uppercase tracking-wider text-neutral-500 dark:text-neutral-400",children:"Tokenized Asset"}),r.jsxs("div",{className:"mt-2 space-y-1.5 text-sm text-neutral-700 dark:text-neutral-300",children:[r.jsxs("div",{className:"flex justify-between",children:[r.jsx("span",{children:"Backing value"}),r.jsx("span",{className:"font-medium text-neutral-950 dark:text-neutral-50",children:Fe({amount:e.backingValueCents/100,currency:e.backingCurrency||t})})]}),e.assetIdentifier?r.jsxs("div",{className:"flex justify-between",children:[r.jsx("span",{children:"Asset ID"}),r.jsx("span",{className:"font-mono text-xs text-neutral-950 dark:text-neutral-50",children:e.assetIdentifier})]}):null,e.tokensPerUnit>1?r.jsxs("div",{className:"flex justify-between",children:[r.jsx("span",{children:"Tokens per unit"}),r.jsx("span",{className:"font-medium text-neutral-950 dark:text-neutral-50",children:e.tokensPerUnit})]}):null,Ze(e.custodyProofUrl)?r.jsxs("div",{className:"flex justify-between",children:[r.jsx("span",{children:"Custody proof"}),r.jsx("a",{href:Ze(e.custodyProofUrl),target:"_blank",rel:"noreferrer",className:"text-xs font-medium underline underline-offset-2",children:"View document"})]}):null,e.nftMintAddress?r.jsxs("div",{className:"flex justify-between",children:[r.jsx("span",{children:"On-chain token"}),r.jsxs("a",{href:`https://solscan.io/account/${e.nftMintAddress}`,target:"_blank",rel:"noreferrer",className:"font-mono text-xs font-medium underline underline-offset-2",children:[e.nftMintAddress.slice(0,4),"...",e.nftMintAddress.slice(-4)]})]}):null]}),e.regulatoryNotice?r.jsx("div",{className:"mt-3 rounded-lg border border-amber-200 bg-amber-50 p-3 text-xs text-amber-900 dark:border-amber-900/40 dark:bg-amber-950/30 dark:text-amber-200",children:e.regulatoryNotice}):null]})}function GS({slug:e,className:t,routes:n}){const s=Et(),o=Js(),{product:a,isLoading:i,error:c}=Dl(e),[l,u]=f.useState(1),[m,d]=f.useState({selectedOptions:{},variant:null});f.useEffect(()=>{if(!a||!a.variants?.length)return;const z=a.variants[0];d({selectedOptions:{...z.options},variant:z})},[a?.id]);const{settings:x}=qn(),{mode:h,maxItems:v}=x.relatedProducts,p=Vl({productId:a?.id,enabled:h==="ai"&&!!a?.id}),g=f.useMemo(()=>h==="by_category"&&a?.categoryIds?.length?{category:a.categoryIds[0],page:1,pageSize:v+1}:{page:1,pageSize:v+4},[h,v,a?.categoryIds]),y=Cs(g),w=f.useMemo(()=>{const K=(y.data?.items??[]).filter(V=>V.slug!==e);if(h==="manual"&&a){const V=a.attributes?.relatedProductIds||a.attributes?.related_product_ids;if(V){const G=HS(String(V));if(G.length>0){const D=new Map(K.map(le=>[le.id,le]));return G.map(le=>D.get(le)).filter(le=>!!le).slice(0,v)}}}if(h==="ai"&&p.relatedProductIds&&p.relatedProductIds.length>0){const V=new Map(K.map(D=>[D.id,D])),G=p.relatedProductIds.map(D=>V.get(D)).filter(D=>!!D);if(G.length>0)return G.slice(0,v)}return K.slice(0,v)},[y.data?.items,e,h,v,a,p.relatedProductIds]),j=n?.shop??"/shop",k=n?.checkout??"/checkout",_=n?.cart??"/cart",S=n?.product??(z=>`/product/${z}`);if(i)return r.jsx("div",{className:O("min-h-screen bg-neutral-50 p-6 dark:bg-neutral-950",t),children:r.jsxs("div",{className:"mx-auto max-w-6xl",children:[r.jsx(Oe,{className:"h-5 w-40"}),r.jsxs("div",{className:"mt-6 grid gap-8 lg:grid-cols-2",children:[r.jsx(Oe,{className:"aspect-square rounded-2xl"}),r.jsxs("div",{className:"space-y-4",children:[r.jsx(Oe,{className:"h-8 w-2/3"}),r.jsx(Oe,{className:"h-6 w-32"}),r.jsx(Oe,{className:"h-20"}),r.jsx(Oe,{className:"h-11"})]})]})]})});if(c)return r.jsx("div",{className:O("min-h-screen bg-neutral-50 p-6 dark:bg-neutral-950",t),children:r.jsx("div",{className:"mx-auto max-w-6xl",children:r.jsx(Ft,{description:c})})});if(!a)return r.jsx("div",{className:O("min-h-screen bg-neutral-50 p-6 dark:bg-neutral-950",t),children:r.jsx("div",{className:"mx-auto max-w-6xl",children:r.jsx(Ft,{description:"Product not found."})})});const A=m.variant?.price??a.price,E=m.variant?.compareAtPrice??a.compareAtPrice,I=m.variant?.inventoryStatus==="out_of_stock"||typeof m.variant?.inventoryQuantity=="number"&&m.variant.inventoryQuantity<=0,T=a.inventoryStatus==="out_of_stock"||typeof a.inventoryQuantity=="number"&&a.inventoryQuantity<=0,U=m.variant?I:T,L=()=>{U||(s.addItem({productId:a.id,variantId:m.variant?.id,unitPrice:A,currency:a.currency,titleSnapshot:m.variant?`${a.title} — ${m.variant.title}`:a.title,imageSnapshot:a.images[0]?.url,paymentResource:a.id,metadata:ai(a)},l),o?.toast({title:"Added to cart",description:a.title,actionLabel:"View cart",onAction:()=>{typeof window<"u"&&window.location.assign(_)}}))},B=()=>{U||(L(),typeof window<"u"&&window.location.assign(k))};return r.jsx("div",{className:O("min-h-screen bg-neutral-50 text-neutral-950 dark:bg-neutral-950 dark:text-neutral-50",t),children:r.jsxs("main",{className:"mx-auto max-w-6xl px-4 py-8",children:[r.jsx(ei,{items:[{label:"Shop",href:j},{label:a.title}]}),r.jsxs("div",{className:"mt-6 grid gap-10 lg:grid-cols-2",children:[r.jsx(Ka,{images:a.images}),r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsx("h1",{className:"text-3xl font-semibold tracking-tight",children:a.title}),a.tokenizedAssetConfig?.assetClass?r.jsx(Ya,{assetClass:a.tokenizedAssetConfig.assetClass}):null]}),r.jsx("div",{className:"mt-3",children:r.jsx(Xs,{amount:A,currency:a.currency,compareAt:E})}),U?r.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?r.jsxs("div",{className:"mt-2 text-sm text-neutral-600 dark:text-neutral-400",children:["Only ",r.jsx("span",{className:"font-semibold text-neutral-950 dark:text-neutral-50",children:a.inventoryQuantity})," left"]}):null,r.jsx("p",{className:"mt-4 text-sm text-neutral-600 dark:text-neutral-400",children:a.description}),a.tokenizedAssetConfig?r.jsx(ZS,{config:a.tokenizedAssetConfig,currency:a.currency}):null]}),r.jsx(Qa,{product:a,value:{selectedOptions:m.selectedOptions,variantId:m.variant?.id},onChange:z=>d(z)}),r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsx(Ja,{qty:l,onChange:u}),r.jsx(J,{type:"button",onClick:L,className:"flex-1",disabled:U,children:U?"Out of stock":"Add to cart"}),r.jsx(J,{type:"button",variant:"outline",onClick:B,disabled:U,children:"Buy now"})]}),(x.sections.showDescription||x.sections.showSpecs||x.sections.showShipping)&&r.jsxs(lm,{type:"single",collapsible:!0,defaultValue:x.sections.showDescription?"desc":void 0,children:[x.sections.showDescription&&r.jsxs(fr,{value:"desc",children:[r.jsx(pr,{children:"Description"}),r.jsx(hr,{children:r.jsx("div",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:a.description})})]}),x.sections.showSpecs&&r.jsxs(fr,{value:"specs",children:[r.jsx(pr,{children:"Specs"}),r.jsx(hr,{children:r.jsx("div",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:a.attributes?r.jsx("div",{className:"space-y-1",children:Object.entries(a.attributes).map(([z,K])=>r.jsxs("div",{children:[r.jsxs("span",{className:"font-medium text-neutral-950 dark:text-neutral-50",children:[z,":"]})," ",String(K)]},z))}):"No specs provided."})})]}),x.sections.showShipping&&r.jsxs(fr,{value:"ship",children:[r.jsx(pr,{children:"Shipping & returns"}),r.jsx(hr,{children:r.jsx("div",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:"Ships in 2–3 business days. Easy returns within 30 days."})})]})]})]})]}),x.sections.showRelatedProducts&&w.length?r.jsxs("section",{className:"mt-12",children:[r.jsx("h2",{className:"text-lg font-semibold",children:"Related products"}),r.jsx("div",{className:"mt-4",children:r.jsx(eo,{products:w,columns:{base:2,md:4,lg:4},layout:x.relatedProducts.layout.layout,imageCrop:x.relatedProducts.layout.imageCrop,getProductHref:z=>S(z.slug),onAddToCart:z=>s.addItem({productId:z.id,unitPrice:z.price,currency:z.currency,titleSnapshot:z.title,imageSnapshot:z.images[0]?.url,paymentResource:z.id},1)})})]}):null]})})}function YS({className:e,checkoutHref:t}){const{config:n}=Ae(),{settings:s}=qn(),o=t??"/checkout",a=n.checkout.allowPromoCodes&&s.checkout.promoCodes;return r.jsx("div",{className:O("min-h-screen bg-neutral-50 text-neutral-950 dark:bg-neutral-950 dark:text-neutral-50",e),children:r.jsxs("main",{className:"mx-auto max-w-6xl px-4 py-10",children:[r.jsx("h1",{className:"text-3xl font-semibold tracking-tight",children:"Cart"}),r.jsx("p",{className:"mt-2 text-sm text-neutral-600 dark:text-neutral-400",children:"Review items, adjust quantities, then check out."}),r.jsx("div",{className:"mt-8",children:r.jsx(Fm,{onCheckout:()=>{typeof window<"u"&&window.location.assign(o)},showPromoCode:a})})]})})}function KS({className:e,routes:t}){const{config:n}=Ae(),s=Et(),o=ma(),a=n.customer?.isSignedIn??!!n.customer?.id,c=!(n.checkout.requireAccount?!1:n.checkout.guestCheckout??!0)&&!a;f.useEffect(()=>{o.kind==="success"&&s.clear()},[o.kind]);const l=t?.shop??"/shop",u=t?.orders??"/account/orders",m=t?.login;return r.jsx("div",{className:O("min-h-screen bg-neutral-50 text-neutral-950 dark:bg-neutral-950 dark:text-neutral-50",e),children:r.jsxs("main",{className:"mx-auto max-w-6xl px-4 py-10",children:[r.jsx(no,{result:o,onContinueShopping:()=>{typeof window<"u"&&window.location.assign(l)},onViewOrders:()=>{typeof window<"u"&&window.location.assign(u)}}),o.kind==="idle"?r.jsxs(r.Fragment,{children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-3xl font-semibold tracking-tight",children:"Checkout"}),r.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."})]}),r.jsx("div",{className:"mt-8",children:r.jsx(Ll,{children:c?r.jsxs(Xe,{className:"rounded-2xl",children:[r.jsx(vr,{className:"pb-4",children:r.jsx(yr,{className:"text-base",children:"Sign in required"})}),r.jsxs(rt,{children:[r.jsx("div",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:"This store requires an account to complete checkout."}),m?r.jsx("div",{className:"mt-4",children:r.jsx(J,{type:"button",onClick:()=>{typeof window<"u"&&window.location.assign(m)},children:"Sign in"})}):null]})]}):r.jsx(Um,{left:r.jsxs("div",{className:"space-y-6",children:[r.jsx(Wm,{}),r.jsxs(Xe,{className:"rounded-2xl",children:[r.jsx(vr,{className:"pb-4",children:r.jsx(yr,{className:"text-base",children:"Payment"})}),r.jsxs(rt,{children:[r.jsx(lt,{className:"mb-4"}),r.jsx(Hm,{})]})]})]}),right:r.jsx("div",{className:"lg:sticky lg:top-24",children:r.jsx(Zm,{})})})})})]}):null]})})}function QS({className:e,isSignedIn:t=!0,onLogin:n,serverUrl:s,authToken:o}){const{orders:a,isLoading:i,error:c}=zl(),[l,u]=f.useState(null);return t?r.jsx("div",{className:O("min-h-screen bg-neutral-50 text-neutral-950 dark:bg-neutral-950 dark:text-neutral-50",e),children:r.jsxs("main",{className:"mx-auto max-w-5xl px-4 py-10 sm:py-12",children:[r.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-3xl font-semibold tracking-tight",children:"Orders"}),r.jsx("p",{className:"mt-2 text-sm text-neutral-600 dark:text-neutral-400",children:"View past purchases and receipts."})]}),!i&&!c&&!l&&a.length>0?r.jsxs("div",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:[a.length," order",a.length===1?"":"s"]}):null]}),c?r.jsx(Ft,{className:"mt-8",description:c}):null,i?r.jsxs("div",{className:"mt-8 grid gap-4",children:[r.jsx(Oe,{className:"h-32 rounded-2xl"}),r.jsx(Oe,{className:"h-32 rounded-2xl"}),r.jsx(Oe,{className:"h-32 rounded-2xl"})]}):a.length===0?r.jsx("div",{className:"mt-8",children:r.jsx(Bn,{title:"No orders yet",description:"When you purchase something, it will show up here."})}):l?r.jsx("div",{className:"mt-8",children:r.jsx(Km,{order:l,onBack:()=>u(null),serverUrl:s,authToken:o})}):r.jsx("div",{className:"mt-8",children:r.jsx(Ym,{orders:a,onView:u})})]})}):r.jsx("div",{className:O("min-h-screen bg-neutral-50 p-10 dark:bg-neutral-950",e),children:r.jsx("div",{className:"mx-auto max-w-4xl",children:r.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 JS({className:e}){return r.jsxs("svg",{className:e,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("polyline",{points:"6 9 6 2 18 2 18 9"}),r.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"}),r.jsx("rect",{x:"6",y:"14",width:"12",height:"8"})]})}function XS({className:e}){return r.jsx("svg",{className:e,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"m15 18-6-6 6-6"})})}function eC(e){switch(e){case"x402":return"Crypto (x402)";case"credits":return"Credits";case"stripe":return"Card";default:return"Payment"}}function tC({order:e,source:t,purchaseId:n,customerEmail:s,customerName:o,className:a,onBack:i}){const{config:c}=Ae(),l=t??e.source,u=n??e.purchaseId,m=s??e.customerEmail,d=o??e.customerName,x=c.brand?.name??"Store",h=c.brand?.logoUrl,v=()=>{typeof window<"u"&&window.print()},p=new Date(e.createdAt).toLocaleDateString(void 0,{year:"numeric",month:"long",day:"numeric"}),g=new Date(e.createdAt).toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"});return r.jsxs("div",{className:O("min-h-screen bg-neutral-100 dark:bg-neutral-900 print:bg-white print:dark:bg-white",a),children:[r.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:r.jsxs("div",{className:"mx-auto flex max-w-2xl items-center justify-between",children:[i?r.jsxs(J,{type:"button",variant:"ghost",size:"sm",onClick:i,children:[r.jsx(XS,{className:"mr-1"})," Back"]}):r.jsx("div",{}),r.jsxs(J,{type:"button",variant:"outline",size:"sm",onClick:v,children:[r.jsx(JS,{className:"mr-2"})," Print Receipt"]})]})}),r.jsx("div",{className:"mx-auto max-w-2xl px-4 py-8 print:max-w-none print:px-0 print:py-0",children:r.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:[r.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:[r.jsxs("div",{className:"flex items-center gap-3",children:[h?r.jsx("img",{src:h,alt:x,className:"h-10 w-10 rounded-lg object-contain"}):null,r.jsx("div",{className:"text-xl font-semibold",children:x})]}),r.jsxs("div",{className:"text-right",children:[r.jsx("div",{className:"text-sm font-medium text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:"Receipt"}),r.jsx("div",{className:"mt-1 font-mono text-sm",children:e.id})]})]}),r.jsxs("div",{className:"mt-6 grid grid-cols-2 gap-4 text-sm sm:grid-cols-3",children:[r.jsxs("div",{children:[r.jsx("div",{className:"text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:"Date"}),r.jsx("div",{className:"mt-1 font-medium",children:p}),r.jsx("div",{className:"text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:g})]}),r.jsxs("div",{children:[r.jsx("div",{className:"text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:"Payment Method"}),r.jsx("div",{className:"mt-1 font-medium",children:eC(l)})]}),r.jsxs("div",{children:[r.jsx("div",{className:"text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:"Status"}),r.jsx("div",{className:"mt-1",children:r.jsx(ht,{variant:"outline",className:"capitalize print:border-neutral-300",children:e.status})})]})]}),(d||m)&&r.jsxs("div",{className:"mt-6 border-t border-neutral-200 pt-6 dark:border-neutral-800 print:dark:border-neutral-200",children:[r.jsx("div",{className:"text-sm text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:"Customer"}),d&&r.jsx("div",{className:"mt-1 font-medium",children:d}),m&&r.jsx("div",{className:"text-sm text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:m})]}),r.jsx("div",{className:"mt-6 border-t border-neutral-200 pt-6 dark:border-neutral-800 print:dark:border-neutral-200",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b border-neutral-200 dark:border-neutral-800 print:dark:border-neutral-200",children:[r.jsx("th",{className:"pb-3 text-left font-medium text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:"Item"}),r.jsx("th",{className:"pb-3 text-center font-medium text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:"Qty"}),r.jsx("th",{className:"pb-3 text-right font-medium text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:"Price"})]})}),r.jsx("tbody",{children:e.items.map((y,w)=>r.jsxs("tr",{className:"border-b border-neutral-100 dark:border-neutral-800/50 print:dark:border-neutral-100",children:[r.jsx("td",{className:"py-3",children:r.jsx("div",{className:"font-medium",children:y.title})}),r.jsx("td",{className:"py-3 text-center text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:y.qty}),r.jsx("td",{className:"py-3 text-right",children:Fe({amount:y.unitPrice*y.qty,currency:y.currency})})]},`${y.title}-${w}`))})]})}),r.jsxs("div",{className:"mt-4 flex flex-col items-end gap-2 text-sm",children:[r.jsxs("div",{className:"flex w-48 justify-between",children:[r.jsx("span",{className:"text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:"Subtotal"}),r.jsx("span",{children:Fe({amount:e.total,currency:e.currency})})]}),r.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:[r.jsx("span",{children:"Total"}),r.jsx("span",{children:Fe({amount:e.total,currency:e.currency})})]})]}),u&&r.jsxs("div",{className:"mt-6 border-t border-neutral-200 pt-6 dark:border-neutral-800 print:dark:border-neutral-200",children:[r.jsx("div",{className:"text-sm text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:"Transaction ID"}),r.jsx("div",{className:"mt-1 break-all font-mono text-xs",children:u})]}),r.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:[r.jsx("p",{children:"Thank you for your purchase!"}),r.jsx("p",{className:"mt-1",children:"If you have any questions, please contact support."})]})]})})]})}function nC({className:e}){return r.jsx("svg",{className:O("h-4 w-4 flex-shrink-0",e),viewBox:"0 0 20 20",fill:"currentColor",children:r.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 rC({className:e,title:t="Choose Your Plan",subtitle:n="Select the plan that best fits your needs.",annualSavingsBadge:s="2 months free",popularBadgeText:o="Best Deal",footerNotice:a}){const{config:i}=Ae(),{tiers:c,status:l,isLoading:u,error:m}=$l(),[d,x]=f.useState("monthly"),h=!!i.adapter.createSubscriptionCheckoutSession,v=async p=>{if(!i.adapter.createSubscriptionCheckoutSession)return;const g=await i.adapter.createSubscriptionCheckoutSession({tierId:p,interval:d,successUrl:i.checkout.successUrl,cancelUrl:i.checkout.cancelUrl});g.kind==="redirect"&&typeof window<"u"&&window.location.assign(g.url)};return r.jsx("div",{className:O("min-h-screen bg-neutral-50 text-neutral-950 dark:bg-neutral-950 dark:text-neutral-50",e),children:r.jsxs("main",{className:"mx-auto max-w-6xl px-4 py-16",children:[r.jsxs("div",{className:"text-center",children:[r.jsx("h1",{className:"text-5xl font-bold tracking-tight",children:t}),r.jsx("p",{className:"mt-4 text-base text-neutral-600 dark:text-neutral-400",children:n})]}),r.jsx("div",{className:"mt-10 flex justify-center",children:r.jsxs("div",{className:"inline-flex items-center rounded-full bg-neutral-200/60 p-1 dark:bg-neutral-800/60",children:[r.jsxs("button",{type:"button",onClick:()=>x("annual"),className:O("relative flex items-center gap-2 rounded-full px-4 py-2 text-sm font-medium transition-all",d==="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",s&&r.jsx("span",{className:O("rounded-full px-2 py-0.5 text-xs font-medium",d==="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:s})]}),r.jsx("button",{type:"button",onClick:()=>x("monthly"),className:O("rounded-full px-4 py-2 text-sm font-medium transition-all",d==="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"})]})}),m?r.jsx(Ft,{className:"mt-10",description:m}):null,u?r.jsxs("div",{className:"mt-12 grid gap-6 md:grid-cols-3",children:[r.jsx(Oe,{className:"h-[480px] rounded-2xl"}),r.jsx(Oe,{className:"h-[480px] rounded-2xl"}),r.jsx(Oe,{className:"h-[480px] rounded-2xl"})]}):c.length===0?r.jsx("div",{className:"mt-12",children:r.jsx(Bn,{title:"No plans available",description:"Subscription plans will appear here once configured."})}):r.jsx("div",{className:"mt-12 grid gap-6 md:grid-cols-3 items-start",children:c.map(p=>{const g=l?.isActive&&l.currentTierId===p.id,y=d==="annual"&&p.priceAnnual?p.priceAnnual:p.priceMonthly,w=p.isPopular,j=p.inventoryQuantity!=null,k=j?Math.max(0,(p.inventoryQuantity??0)-(p.inventorySold??0)):null,_=j&&k===0,S=j&&k!=null&&k>0&&k<=5,[A,...E]=p.features;return r.jsxs("div",{className:O("relative flex flex-col rounded-2xl border p-6 transition-shadow",w?"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:[w&&o&&r.jsx("div",{className:"absolute -top-3 right-4",children:r.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})}),r.jsxs("div",{className:"mb-6",children:[r.jsx("h3",{className:"text-xl font-bold",children:p.title}),p.description&&r.jsx("p",{className:O("mt-2 text-sm leading-relaxed",w?"text-neutral-300 dark:text-neutral-600":"text-neutral-600 dark:text-neutral-400"),children:p.description})]}),r.jsxs("div",{className:"mb-6",children:[r.jsx("div",{className:"text-5xl font-bold tracking-tight",children:Fe({amount:y,currency:p.currency||i.currency})}),r.jsxs("div",{className:O("mt-2 text-sm",w?"text-neutral-400 dark:text-neutral-500":"text-neutral-500 dark:text-neutral-400"),children:["Per ",d==="annual"?"year":"month",", billed ",d==="annual"?"annually":"monthly"]})]}),j&&r.jsx("div",{className:O("mb-3 text-xs font-medium",_?"text-red-600 dark:text-red-400":S?w?"text-amber-300 dark:text-amber-600":"text-amber-600 dark:text-amber-400":w?"text-neutral-400 dark:text-neutral-500":"text-neutral-500 dark:text-neutral-400"),children:_?"Sold out":`${k} remaining`}),r.jsx(J,{type:"button",className:O("mb-6 w-full rounded-full py-3 font-medium",w?"bg-white text-neutral-900 hover:bg-neutral-100 dark:bg-neutral-900 dark:text-white dark:hover:bg-neutral-800":""),variant:w?"default":"outline",disabled:g||!h||_,onClick:()=>void v(p.id),children:_?"Sold Out":g?"Current Plan":"Purchase"}),A&&r.jsx("div",{className:O("mb-4 text-sm font-semibold",w?"":"text-neutral-900 dark:text-white"),children:A}),E.length>0&&r.jsx("ul",{className:"space-y-3",children:E.map((I,T)=>r.jsxs("li",{className:"flex items-start gap-3",children:[r.jsx(nC,{className:O("mt-0.5",w?"text-neutral-400 dark:text-neutral-500":"text-neutral-500 dark:text-neutral-400")}),r.jsx("span",{className:O("text-sm leading-relaxed",w?"text-neutral-300 dark:text-neutral-600":"text-neutral-600 dark:text-neutral-400"),children:I})]},T))})]},p.id)})}),a&&r.jsx("div",{className:"mt-12 text-center",children:r.jsx("p",{className:"text-xs text-neutral-500 dark:text-neutral-400 leading-relaxed max-w-2xl mx-auto",children:a})})]})})}function sC(e){const{processCartCheckout:t}=tf.useStripeCheckout();return f.useMemo(()=>({...e,async createCheckoutSession(n){const{customer:s,options:o}=n,a=s.shippingAddress?s.shippingAddress:void 0,i=s.billingAddress?s.billingAddress:void 0,c=await t(n.cart,o.successUrl,o.cancelUrl,o.metadata,s.email,o.discountCode,s.name,s.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 ua(n)}}),[e,t])}const oC=Object.freeze(Object.defineProperty({__proto__:null,Accordion:lm,AccordionContent:hr,AccordionItem:fr,AccordionTrigger:pr,AddressForm:ea,AssetBadge:Ya,Badge:ht,Breadcrumbs:ei,Button:J,Card:Xe,CardContent:rt,CardDescription:ad,CardFooter:id,CardHeader:vr,CardTitle:yr,CartLineItem:ni,CartPageContent:Fm,CartPanel:Dm,CartProvider:fp,CartSidebar:Cr,CartSummary:ri,CartTemplate:YS,CategoryNav:Xo,CategoryTemplate:qS,CedrosShopProvider:Wf,CheckoutCancelPage:gS,CheckoutForm:Wm,CheckoutLayout:Um,CheckoutProvider:Ll,CheckoutReceipt:no,CheckoutSuccessPage:hS,CheckoutTemplate:KS,Dialog:Ma,DialogClose:vj,DialogContent:Us,DialogDescription:za,DialogFooter:Fu,DialogHeader:Da,DialogOverlay:La,DialogPortal:$u,DialogTitle:Bs,DialogTrigger:xj,EmptyState:Bn,ErrorBoundary:Jj,ErrorState:Ft,FAQItem:Om,FAQList:K_,FilterPanel:ys,GiftCardBalanceChecker:zS,GiftCardRedemptionPage:AS,Input:Te,InventoryVerificationDialog:qm,Label:He,MyRedemptionsPage:_S,MyTokensPage:NS,OrderCard:Gm,OrderDetails:Km,OrderList:Ym,OrderReview:Zm,PaymentStep:Hm,Price:Xs,ProductCard:Mm,ProductGallery:Ka,ProductGrid:eo,ProductTemplate:GS,PromoCodeInput:si,PurchaseHistoryTemplate:QS,QuantitySelector:Ja,QuickViewDialog:Xa,ReceiptTemplate:tC,RedemptionForm:to,SearchInput:ti,Select:hs,SelectContent:jr,SelectGroup:Jk,SelectItem:_r,SelectTrigger:kr,SelectValue:gs,SendAsGiftSection:Bm,Separator:lt,Sheet:Vs,SheetClose:Uu,SheetContent:Ir,SheetDescription:Vu,SheetHeader:qs,SheetOverlay:$a,SheetPortal:Bu,SheetTitle:Hs,SheetTrigger:Ws,ShippingMethodSelector:Vm,ShopChatPanel:$m,ShopTemplate:VS,Skeleton:Oe,SubscriptionTemplate:rC,Tabs:Za,TabsContent:Em,TabsList:Qs,TabsTrigger:Sr,ToastProvider:A_,TokenDisplay:oi,VariantSelector:Qa,createMockCommerceAdapter:Yf,createPaywallCommerceAdapter:op,parseCheckoutReturn:ua,readCatalogUrlState:fa,useAIRelatedProducts:Vl,useCart:Et,useCartInventory:ha,useCatalogUrlSync:pa,useCategories:da,useCedrosPayCheckoutAdapter:sC,useCedrosShop:Ae,useCheckout:Ar,useCheckoutResultFromUrl:ma,useHoldExpiry:uv,useInventoryVerification:Ul,useOptionalToast:Js,useOrders:zl,usePaymentMethodsConfig:Bl,useProduct:Dl,useProducts:Cs,useShippingMethods:Fl,useStandaloneCheckout:ev,useStorefrontSettings:qn,useSubscriptionData:$l,useToast:N_,validateCommerceAdapterContract:gv},Symbol.toStringTag,{value:"Module"}));exports.CEDROS_PAY_GROUPS=Uf;exports.CEDROS_PAY_SECTIONS=Qc;exports.CEDROS_PAY_SECTION_IDS=Ff;exports.CedrosPayAdminDashboard=zf;exports.ComplianceGatePage=Bf;exports.CouponsSection=Hc;exports.CreditsBalance=Vf;exports.ErrorBanner=Vn;exports.FormDropdown=Ct;exports.Icons=Z;exports.ProductsSection=Wc;exports.RefundsSection=Zc;exports.SettingsSection=Gc;exports.StatsBar=Nr;exports.TransactionsSection=qc;exports.cedrosPayPlugin=$f;exports.formatDateTime=mr;exports.index=oC;exports.safeHref=Ze;exports.useComplianceCheck=Jc;exports.useCreditsBalance=Xc;