nubot-lite 0.1.0 → 0.1.2

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 (272) hide show
  1. package/README.md +6 -5
  2. package/lib/api.mjs +6 -2
  3. package/lib/cloudflare.mjs +13 -12
  4. package/lib/commands/init.mjs +260 -251
  5. package/package.json +1 -1
  6. package/template/.claude/skills/nubot-lite/SKILL.md +7 -1
  7. package/template/panel/PANEL.md +1 -1
  8. package/template/panel/assets/AgendarDemoPage-Bn_BvTp1.js +1 -0
  9. package/template/panel/assets/{AgentDatasetsPage-D8vQhRWO.js → AgentDatasetsPage-wLtBtSB2.js} +2 -2
  10. package/template/panel/assets/AgentKnowledgeGroupsPage-BGHNFj-e.js +1 -0
  11. package/template/panel/assets/AgentListPage-F3ja9_o_.js +1 -0
  12. package/template/panel/assets/AgentQaTrainingPage-CojiU8_W.js +1 -0
  13. package/template/panel/assets/AiAgentWhatsappPage-Bn_BvTp1.js +1 -0
  14. package/template/panel/assets/BlogPage-Bn_BvTp1.js +1 -0
  15. package/template/panel/assets/BlogPostPage-Bn_BvTp1.js +1 -0
  16. package/template/panel/assets/CalculadoraTiempoRespuestaPage-Bn_BvTp1.js +1 -0
  17. package/template/panel/assets/{CampaignDetailPage-DFMctNEj.js → CampaignDetailPage-DUNnckvn.js} +1 -1
  18. package/template/panel/assets/CampaignsPage-CS60yZBd.js +1 -0
  19. package/template/panel/assets/ChannelSelector-C7R9zqrt.js +1 -0
  20. package/template/panel/assets/ChatbotParaWhatsappPage-Bn_BvTp1.js +1 -0
  21. package/template/panel/assets/ConfirmModal-B27OBQdm.js +1 -0
  22. package/template/panel/assets/ContactsPage-CvoDlFUN.js +14 -0
  23. package/template/panel/assets/CreateAgentPage-CbhikMY1.js +19 -0
  24. package/template/panel/assets/CreditLimitBanner-j72L7jgK.js +1 -0
  25. package/template/panel/assets/CrmParaWhatsappPage-Bn_BvTp1.js +1 -0
  26. package/template/panel/assets/DashboardPage-BGWkXY7W.js +1 -0
  27. package/template/panel/assets/{EmojiPicker-BToAe-MT.js → EmojiPicker-ByTMSXTj.js} +1 -1
  28. package/template/panel/assets/{EventTypesSettingsPage-DCedeQzM.js → EventTypesSettingsPage-CLpO1VBL.js} +1 -1
  29. package/template/panel/assets/GeneradorEnlacesPage-Bn_BvTp1.js +1 -0
  30. package/template/panel/assets/GeneradorQrWhatsappPage-Bn_BvTp1.js +1 -0
  31. package/template/panel/assets/{GeneralSettingsPage-B04ozcHb.js → GeneralSettingsPage-CY-5aGgL.js} +1 -1
  32. package/template/panel/assets/GoogleCalendarManagePage-oX7DuErV.js +1 -0
  33. package/template/panel/assets/{InvitationAcceptancePage-BPgtBFl5.js → InvitationAcceptancePage-BYllrAYs.js} +1 -1
  34. package/template/panel/assets/IrAlSitioPublico-Bn_BvTp1.js +1 -0
  35. package/template/panel/assets/LiteAiUsagePage-Dzm8jBL2.js +1 -0
  36. package/template/panel/assets/{LiteSetupPage-42rgAdnG.js → LiteSetupPage-CMSAur_e.js} +1 -1
  37. package/template/panel/assets/MarkdownRenderer-C3TD9KYa.js +3 -0
  38. package/template/panel/assets/MediaProcessingService-CG2DdSyN.js +1 -0
  39. package/template/panel/assets/NewCampaignPage-BfSEd075.js +1 -0
  40. package/template/panel/assets/OrdersConfigPage-BAKKaX0L.js +1 -0
  41. package/template/panel/assets/OrdersPage-CXiPOCXP.js +1 -0
  42. package/template/panel/assets/{PasswordStrengthIndicator-HZK_oU0W.js → PasswordStrengthIndicator-4h-Y0s2r.js} +1 -1
  43. package/template/panel/assets/PlantillaDetailPage-Bn_BvTp1.js +1 -0
  44. package/template/panel/assets/PlantillasIndexPage-Bn_BvTp1.js +1 -0
  45. package/template/panel/assets/PrivacyPolicy-Bn_BvTp1.js +1 -0
  46. package/template/panel/assets/{ProductManagementPage-DNM7DEgt.js → ProductManagementPage-CRkNTicv.js} +4 -4
  47. package/template/panel/assets/PublicFormPage-BxPxJ3Pq.js +1 -0
  48. package/template/panel/assets/QaForm-Px-cmakA.js +5 -0
  49. package/template/panel/assets/SelectPlanPage-Gyo5C1Hq.js +1 -0
  50. package/template/panel/assets/SignatureEditor-DIhmrXow.js +1 -0
  51. package/template/panel/assets/{TagSelector-ChoKzvjW.js → TagSelector-o6tVpRs9.js} +1 -1
  52. package/template/panel/assets/TagsSettingsPage-DT8MfW1H.js +2 -0
  53. package/template/panel/assets/TeamsPage-BuWuGxZo.js +1 -0
  54. package/template/panel/assets/WhatsappBusinessApiPage-Bn_BvTp1.js +1 -0
  55. package/template/panel/assets/WhatsappMultiagentePage-Bn_BvTp1.js +1 -0
  56. package/template/panel/assets/{account-D2ltXC_U.js → account-G3WXxisG.js} +1 -1
  57. package/template/panel/assets/{admin-lEgqZTsa.js → admin-CSMlOMR8.js} +1 -1
  58. package/template/panel/assets/{agent.service-BcAkMU7j.js → agent.service-BE2rJG_o.js} +1 -1
  59. package/template/panel/assets/{alert-dialog-D8P69s-m.js → alert-dialog-gzZZoAiu.js} +2 -2
  60. package/template/panel/assets/{alert-DI3GBLi1.js → alert-seLKo73M.js} +1 -1
  61. package/template/panel/assets/api-keys-BF33GS2N.js +1 -0
  62. package/template/panel/assets/{archive-LUe5bKi5.js → archive-CxUKRJwu.js} +1 -1
  63. package/template/panel/assets/{arrow-left-BeDdBs_Q.js → arrow-left-CI7mH7bD.js} +1 -1
  64. package/template/panel/assets/{arrow-up-BiBq8Pvx.js → arrow-up-DJzXCc8_.js} +1 -1
  65. package/template/panel/assets/{arrow-up-down-CaG2BONN.js → arrow-up-down-DkSCsCjR.js} +1 -1
  66. package/template/panel/assets/audit-slljESxh.js +1 -0
  67. package/template/panel/assets/{authService-Cbm8LdlJ.js → authService-CtvlzCDa.js} +1 -1
  68. package/template/panel/assets/{avatar-CILB1zwS.js → avatar-BXhSKQGY.js} +1 -1
  69. package/template/panel/assets/{billing-IVLNopU2.js → billing-Cy2XUBeY.js} +1 -1
  70. package/template/panel/assets/{brain-B9z7jZ7A.js → brain-BmrjUpsb.js} +1 -1
  71. package/template/panel/assets/{calendar-CIHhMjNy.js → calendar-Bu0aDtW1.js} +1 -1
  72. package/template/panel/assets/{calendar-days-BwJfOz8M.js → calendar-days-CXtOZxOF.js} +1 -1
  73. package/template/panel/assets/{card-DcKsxjXK.js → card-DdbmSh-v.js} +1 -1
  74. package/template/panel/assets/{checkbox-pcbjC0d3.js → checkbox-CuJh5AMO.js} +1 -1
  75. package/template/panel/assets/{chevrons-up-down-DC-BWTrj.js → chevrons-up-down-DNNdNhV8.js} +1 -1
  76. package/template/panel/assets/{circle-check-big-DzPo5zZX.js → circle-check-big-BOZQ_2Kv.js} +1 -1
  77. package/template/panel/assets/{circle-x-BwMKIs8b.js → circle-x-decmm7ip.js} +1 -1
  78. package/template/panel/assets/cloud-B3m0_VpL.js +1 -0
  79. package/template/panel/assets/{code-BMAyHFJe.js → code-C-UH-ZD-.js} +1 -1
  80. package/template/panel/assets/{cog-M7j64wa2.js → cog-BS-_-U4F.js} +1 -1
  81. package/template/panel/assets/{collapsible-B22t1J-V.js → collapsible-Ce_8EeFJ.js} +1 -1
  82. package/template/panel/assets/{command-COdSmSIB.js → command-aHRTWaYV.js} +1 -1
  83. package/template/panel/assets/connectionsService-BJg4S1e9.js +1 -0
  84. package/template/panel/assets/contactsApi-DI5dcMLo.js +1 -0
  85. package/template/panel/assets/creditErrors-DSbswjsG.js +1 -0
  86. package/template/panel/assets/{database-C1qvt3Py.js → database-Brb7Omak.js} +1 -1
  87. package/template/panel/assets/{datapath-C12uI_pT.js → datapath-CHeKabeh.js} +1 -1
  88. package/template/panel/assets/{datetime-BuZosCVk.js → datetime-D72Uxhjs.js} +1 -1
  89. package/template/panel/assets/{download-CiVQHPeB.js → download-CyfdxFCW.js} +1 -1
  90. package/template/panel/assets/{ellipsis-CMEJnUfK.js → ellipsis-GLu0u4ze.js} +1 -1
  91. package/template/panel/assets/{ellipsis-vertical-DTqbEYYp.js → ellipsis-vertical-CskGwbgN.js} +1 -1
  92. package/template/panel/assets/email-inbox-kyJ2qML5.js +1 -0
  93. package/template/panel/assets/es-BDgg6unH.js +1 -0
  94. package/template/panel/assets/external-link-w7K66ae2.js +1 -0
  95. package/template/panel/assets/{eye-HfQCUjxJ.js → eye-CR5C6hVv.js} +1 -1
  96. package/template/panel/assets/{eye-off-v1Z_lKS0.js → eye-off-CBiJXw4j.js} +1 -1
  97. package/template/panel/assets/facebook-D0SQMea2.js +1 -0
  98. package/template/panel/assets/{file-DMzjdlTL.js → file-CTZ8-xmL.js} +1 -1
  99. package/template/panel/assets/file-braces-54MsOnzo.js +1 -0
  100. package/template/panel/assets/file-spreadsheet-DpekIaV8.js +1 -0
  101. package/template/panel/assets/{folder-D0GKakGp.js → folder-DxTHNhQ_.js} +1 -1
  102. package/template/panel/assets/{folder-open-DQFc4qTJ.js → folder-open-BM4rA96e.js} +1 -1
  103. package/template/panel/assets/format-BG1mN6C0.js +1 -0
  104. package/template/panel/assets/{grip-vertical-FN-eTC2C.js → grip-vertical-CS-dU0tJ.js} +1 -1
  105. package/template/panel/assets/{hash-BoTE56iw.js → hash-ByrjK6gt.js} +1 -1
  106. package/template/panel/assets/{help-center-B1MAIBWA.js → help-center-fmvvoAkD.js} +1 -1
  107. package/template/panel/assets/{history-DhHayxUg.js → history-97D1GT_9.js} +1 -1
  108. package/template/panel/assets/house-CXew5LB-.js +1 -0
  109. package/template/panel/assets/{index-DsyZ_FlA.js → index-43NA2pdZ.js} +23 -23
  110. package/template/panel/assets/index-BG59-Kyv.js +6 -0
  111. package/template/panel/assets/{index-DUnioqCT.js → index-BGvtgHY3.js} +1 -1
  112. package/template/panel/assets/index-BL76lyPt.js +2 -0
  113. package/template/panel/assets/index-BUA9lP4J.js +1 -0
  114. package/template/panel/assets/index-Bfvq4Q3v.js +1 -0
  115. package/template/panel/assets/index-CK793Wzl.css +1 -0
  116. package/template/panel/assets/{index-BTxe6gLJ.js → index-ChrvveQm.js} +1 -1
  117. package/template/panel/assets/index-CoJIvJ6y.js +1 -0
  118. package/template/panel/assets/{index-CMEeV9dO.js → index-CsV1u-Y7.js} +2 -2
  119. package/template/panel/assets/{index-BiSc3WD9.js → index-DIxON2Dm.js} +1 -1
  120. package/template/panel/assets/index-DtoSJTyl.js +1 -0
  121. package/template/panel/assets/index-FBuxpbGF.js +36 -0
  122. package/template/panel/assets/index-YR5X3nd4.js +1 -0
  123. package/template/panel/assets/{instagram-CC7iYt7V.js → instagram-Bm17x-Fs.js} +1 -1
  124. package/template/panel/assets/interactiveLimits-C7Sx7s9W.js +1 -0
  125. package/template/panel/assets/landing-CEUFhLJ9.js +1 -0
  126. package/template/panel/assets/{layout-grid-Cm6hfBWZ.js → layout-grid-DN-t2Wjd.js} +1 -1
  127. package/template/panel/assets/{list-BKc6EXnV.js → list-B0uLKf1b.js} +1 -1
  128. package/template/panel/assets/{map-pin-CPmcofD3.js → map-pin-COYHwobx.js} +1 -1
  129. package/template/panel/assets/{maximize-2-WdbM7Kdx.js → maximize-2-SbmXBBYe.js} +1 -1
  130. package/template/panel/assets/mediaLimits-CAYdWqeQ.js +1 -0
  131. package/template/panel/assets/mediaValidation-Bg0xHQrv.js +1 -0
  132. package/template/panel/assets/message-circle-tNSzOeOW.js +1 -0
  133. package/template/panel/assets/{message-square-Dfn16oHc.js → message-square-B1_OirdW.js} +1 -1
  134. package/template/panel/assets/{meta-templates-C7yEjSOI.js → meta-templates-hhDdxBOR.js} +1 -1
  135. package/template/panel/assets/metadataSchemasApi-BmJko2eC.js +1 -0
  136. package/template/panel/assets/{mic-CT4vyzLZ.js → mic-ClFq9hMZ.js} +1 -1
  137. package/template/panel/assets/minus-vh4a51Mn.js +1 -0
  138. package/template/panel/assets/{music-Cu8AQMFp.js → music-CgtkroYi.js} +1 -1
  139. package/template/panel/assets/{page-components-o2TF52HV.js → page-components-DXOKtt_M.js} +1 -1
  140. package/template/panel/assets/{pages-Cj5Qd1QO.js → pages-BcYbyh_-.js} +1 -1
  141. package/template/panel/assets/{pages-B7digtXi.js → pages-BuibyrnC.js} +1 -1
  142. package/template/panel/assets/{pages-Dw7dvmaS.js → pages-CGXCBdff.js} +1 -1
  143. package/template/panel/assets/paperclip-DVRbzE7C.js +1 -0
  144. package/template/panel/assets/{pen-line-DLnhkIuw.js → pen-line-Cr0YFjAs.js} +1 -1
  145. package/template/panel/assets/{pencil-Cx8u1N8t.js → pencil-aqjc7AWb.js} +1 -1
  146. package/template/panel/assets/{popover-MyuU-yAK.js → popover-cWIhNmod.js} +1 -1
  147. package/template/panel/assets/{power-CdR2OkIX.js → power-CVFzhVJx.js} +1 -1
  148. package/template/panel/assets/{product.service-CRLZOQsr.js → product.service-FClit10f.js} +1 -1
  149. package/template/panel/assets/products.types-nZIsk2w8.js +1 -0
  150. package/template/panel/assets/proxy-CvX2KM2u.js +1 -0
  151. package/template/panel/assets/{save-Dua2yhWl.js → save-mwkHDnDL.js} +1 -1
  152. package/template/panel/assets/scroll-area-CSCo4HHB.js +1 -0
  153. package/template/panel/assets/{select-DlB_BbfM.js → select-DCY_lg9j.js} +1 -1
  154. package/template/panel/assets/{send-Dxmdupsl.js → send-DBQH77K9.js} +1 -1
  155. package/template/panel/assets/{separator-CPT3uVRM.js → separator-DznqP68l.js} +1 -1
  156. package/template/panel/assets/{settings-2-C-c8ECWW.js → settings-2-PhKPMrsj.js} +1 -1
  157. package/template/panel/assets/shield-alert-Fv3j9Wbv.js +1 -0
  158. package/template/panel/assets/{skeleton-B0zh8s_y.js → skeleton-CN6xlRXP.js} +1 -1
  159. package/template/panel/assets/{slider-CY71MXOW.js → slider-D0QB_Lme.js} +1 -1
  160. package/template/panel/assets/{square-BuGqLxJB.js → square-Dm5VC71z.js} +1 -1
  161. package/template/panel/assets/{square-pen-CJajoyrm.js → square-pen-Dbn7xmc-.js} +1 -1
  162. package/template/panel/assets/{star-Cuegk1GF.js → star-BMD3HmS6.js} +1 -1
  163. package/template/panel/assets/stat-card-W7s_-fHW.js +1 -0
  164. package/template/panel/assets/storage.api-C0ZJBoSz.js +20 -0
  165. package/template/panel/assets/{switch-ODBa0fCT.js → switch-C7XmAU1c.js} +1 -1
  166. package/template/panel/assets/{table-CvSELOPi.js → table-7NGq0kRw.js} +1 -1
  167. package/template/panel/assets/{tabs-DqXhuAr6.js → tabs-BGCKrmVw.js} +1 -1
  168. package/template/panel/assets/{tags-By_tlh_r.js → tags-HU2fuPFH.js} +1 -1
  169. package/template/panel/assets/{target-DEuCdeUI.js → target-CG_g4_Fj.js} +1 -1
  170. package/template/panel/assets/{textarea-BYtcLsMD.js → textarea-B1anutjq.js} +1 -1
  171. package/template/panel/assets/{ticket-CWba7G1i.js → ticket-CHs1Xojr.js} +1 -1
  172. package/template/panel/assets/{trash-2-Du2vmQCH.js → trash-2-D_kmHMwn.js} +1 -1
  173. package/template/panel/assets/{trending-up-Ba4HSvuW.js → trending-up-BnHeLWFs.js} +1 -1
  174. package/template/panel/assets/{upload-C7TwpdyA.js → upload-CQg4_W5r.js} +1 -1
  175. package/template/panel/assets/{useAiAgentsQuery-Bm6aRHKj.js → useAiAgentsQuery-CXo6TmU6.js} +1 -1
  176. package/template/panel/assets/useFunnelStats-Bk8wTET5.js +1 -0
  177. package/template/panel/assets/useFunnelsQuery-vDrahaDr.js +1 -0
  178. package/template/panel/assets/{useInfiniteQuery-BXUM1Z9V.js → useInfiniteQuery-D0sFT2K2.js} +1 -1
  179. package/template/panel/assets/{useMutation-a5tIBvQY.js → useMutation-0ypmz8SO.js} +1 -1
  180. package/template/panel/assets/useOrgSyncedFetch-FSgwRhpR.js +1 -0
  181. package/template/panel/assets/usePipelineBoardQuery-BysscZXI.js +9 -0
  182. package/template/panel/assets/{useUploadConfig-BuiF0X-3.js → useUploadConfig-CvVmSc6S.js} +1 -1
  183. package/template/panel/assets/{user-DwCALzIG.js → user-l48WDfDH.js} +1 -1
  184. package/template/panel/assets/{user-plus-BiUjcHil.js → user-plus-CWaaUP-O.js} +1 -1
  185. package/template/panel/assets/{video-VfwKgB6z.js → video-CILE66CA.js} +1 -1
  186. package/template/panel/assets/{volume-2-C5DMdOVq.js → volume-2-DfFqN0dw.js} +1 -1
  187. package/template/panel/assets/wrench-Dcbk4scY.js +1 -0
  188. package/template/panel/index.html +2 -2
  189. package/template/panel/version.json +2 -2
  190. package/template/worker/migrations/0006_ai_usage.sql +33 -0
  191. package/template/worker/migrations/0007_channels.sql +18 -0
  192. package/template/worker/src/agent/pricing.ts +37 -0
  193. package/template/worker/src/agent/prompt.ts +137 -134
  194. package/template/worker/src/agent/run.ts +350 -243
  195. package/template/worker/src/agent/sandbox.ts +2 -2
  196. package/template/worker/src/agent/tools.ts +463 -463
  197. package/template/worker/src/channels/accounts.ts +177 -0
  198. package/template/worker/src/channels/zernio.ts +161 -148
  199. package/template/worker/src/inbox/contacts.ts +2 -0
  200. package/template/worker/src/inbox/store.ts +199 -187
  201. package/template/worker/src/index.ts +2 -0
  202. package/template/worker/src/nubot/account.ts +163 -178
  203. package/template/worker/src/nubot/ai-usage.ts +197 -0
  204. package/template/worker/src/nubot/channels.ts +159 -0
  205. package/template/worker/src/nubot/contacts.ts +387 -386
  206. package/template/worker/src/nubot/funnels.ts +672 -670
  207. package/template/worker/src/nubot/inbox.ts +623 -616
  208. package/template/worker/src/nubot/index.ts +127 -122
  209. package/template/worker/src/nubot/mappers.ts +12 -5
  210. package/template/worker/src/routes/channels.ts +13 -0
  211. package/template/worker/src/routes/system.ts +110 -100
  212. package/template/worker/src/webhooks/zernio.ts +154 -125
  213. package/template/panel/assets/AgendarDemoPage-DOiS40FL.js +0 -1
  214. package/template/panel/assets/AgentKnowledgeGroupsPage-DEPS1lsk.js +0 -1
  215. package/template/panel/assets/AgentListPage-DqY9rze5.js +0 -1
  216. package/template/panel/assets/AgentQaTrainingPage-Ecis7xoc.js +0 -1
  217. package/template/panel/assets/AiAgentWhatsappPage-DOiS40FL.js +0 -1
  218. package/template/panel/assets/AiMetricsPage-DEPS1lsk.js +0 -1
  219. package/template/panel/assets/BlogPage-DOiS40FL.js +0 -1
  220. package/template/panel/assets/BlogPostPage-DOiS40FL.js +0 -1
  221. package/template/panel/assets/CalculadoraTiempoRespuestaPage-DOiS40FL.js +0 -1
  222. package/template/panel/assets/CampaignsPage-CLRaXGlj.js +0 -1
  223. package/template/panel/assets/ChannelSelector-q9tTirNo.js +0 -1
  224. package/template/panel/assets/ChatbotParaWhatsappPage-DOiS40FL.js +0 -1
  225. package/template/panel/assets/ConfirmModal-W7VUI3Z_.js +0 -1
  226. package/template/panel/assets/ContactsPage-CsOFsOPw.js +0 -14
  227. package/template/panel/assets/CreateAgentPage-Ifxx6_UX.js +0 -19
  228. package/template/panel/assets/CreditLimitBanner-J49rSVEn.js +0 -1
  229. package/template/panel/assets/CrmParaWhatsappPage-DOiS40FL.js +0 -1
  230. package/template/panel/assets/DashboardPage-3Viy83dd.js +0 -1
  231. package/template/panel/assets/GeneradorEnlacesPage-DOiS40FL.js +0 -1
  232. package/template/panel/assets/GeneradorQrWhatsappPage-DOiS40FL.js +0 -1
  233. package/template/panel/assets/IrAlSitioPublico-DOiS40FL.js +0 -1
  234. package/template/panel/assets/MediaProcessingService-glHGiE_o.js +0 -1
  235. package/template/panel/assets/NewCampaignPage-Cw99m3W8.js +0 -1
  236. package/template/panel/assets/OrdersConfigPage-B6BfM3lf.js +0 -1
  237. package/template/panel/assets/OrdersPage-Du7CJjty.js +0 -1
  238. package/template/panel/assets/PlantillaDetailPage-DOiS40FL.js +0 -1
  239. package/template/panel/assets/PlantillasIndexPage-DOiS40FL.js +0 -1
  240. package/template/panel/assets/PrivacyPolicy-DOiS40FL.js +0 -1
  241. package/template/panel/assets/PublicFormPage-DDb4OXEM.js +0 -1
  242. package/template/panel/assets/QaForm-BDboHNKo.js +0 -5
  243. package/template/panel/assets/SelectPlanPage-DALaf8E5.js +0 -1
  244. package/template/panel/assets/TagsSettingsPage-DYCKveQq.js +0 -2
  245. package/template/panel/assets/TeamsPage-DPUcRdlh.js +0 -1
  246. package/template/panel/assets/WhatsappBusinessApiPage-DOiS40FL.js +0 -1
  247. package/template/panel/assets/WhatsappMultiagentePage-DOiS40FL.js +0 -1
  248. package/template/panel/assets/api-keys-B0UQNR5E.js +0 -1
  249. package/template/panel/assets/audit-BrdHcTNl.js +0 -1
  250. package/template/panel/assets/connections-Dqwd01UI.js +0 -1
  251. package/template/panel/assets/connectionsService-BsJf8pFz.js +0 -3
  252. package/template/panel/assets/contactsApi-B851NME_.js +0 -1
  253. package/template/panel/assets/creditErrors-CrpkwwUI.js +0 -1
  254. package/template/panel/assets/email-inbox-LbGeQCty.js +0 -1
  255. package/template/panel/assets/es-BG480iA5.js +0 -1
  256. package/template/panel/assets/facebook-RxMBweMB.js +0 -1
  257. package/template/panel/assets/index-B183O0S5.js +0 -1
  258. package/template/panel/assets/index-BJCPaymI.css +0 -1
  259. package/template/panel/assets/index-BtxJGfLL.js +0 -6
  260. package/template/panel/assets/index-Bz-ixwph.js +0 -1
  261. package/template/panel/assets/index-CjQSv8hF.js +0 -2
  262. package/template/panel/assets/index-D3vkHHjD.js +0 -9
  263. package/template/panel/assets/index-D4WhIkMN.js +0 -1
  264. package/template/panel/assets/interactiveLimits-CfLJ1O4_.js +0 -1
  265. package/template/panel/assets/landing-If3oVsS0.js +0 -1
  266. package/template/panel/assets/mediaValidation-BR-ZOj5w.js +0 -1
  267. package/template/panel/assets/minus-CyVEzdqL.js +0 -1
  268. package/template/panel/assets/products.types-46xSxBS8.js +0 -1
  269. package/template/panel/assets/scroll-area-CavEOIyz.js +0 -1
  270. package/template/panel/assets/shield-alert-04pSYngI.js +0 -1
  271. package/template/panel/assets/storage.api-CFU3KJNp.js +0 -20
  272. package/template/panel/assets/useFunnelStats-tvjpmWIC.js +0 -1
@@ -1 +0,0 @@
1
- import{c as cr,j as fe}from"./index-DsyZ_FlA.js";import{b as S}from"./recharts-DrC5kNsx.js";import{G as ur}from"./ChannelSelector-q9tTirNo.js";const hr=[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]],zc=cr("user-round",hr),Ms=S.createContext({});function fr(t){const e=S.useRef(null);return e.current===null&&(e.current=t()),e.current}const Be=typeof window<"u",dr=Be?S.useLayoutEffect:S.useEffect,Ie=S.createContext(null);function je(t,e){t.indexOf(e)===-1&&t.push(e)}function Oe(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const _=(t,e,n)=>n>e?e:n<t?t:n;let Ne=()=>{};const X={},Ds=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function Es(t){return typeof t=="object"&&t!==null}const Rs=t=>/^0[^.\s]+$/u.test(t);function Ue(t){let e;return()=>(e===void 0&&(e=t()),e)}const K=t=>t,mr=(t,e)=>n=>e(t(n)),Et=(...t)=>t.reduce(mr),At=(t,e,n)=>{const s=e-t;return s===0?1:(n-t)/s};class We{constructor(){this.subscriptions=[]}add(e){return je(this.subscriptions,e),()=>Oe(this.subscriptions,e)}notify(e,n,s){const i=this.subscriptions.length;if(i)if(i===1)this.subscriptions[0](e,n,s);else for(let o=0;o<i;o++){const r=this.subscriptions[o];r&&r(e,n,s)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const z=t=>t*1e3,W=t=>t/1e3;function Ls(t,e){return e?t*(1e3/e):0}const ks=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t,pr=1e-7,gr=12;function yr(t,e,n,s,i){let o,r,a=0;do r=e+(n-e)/2,o=ks(r,s,i)-t,o>0?n=r:e=r;while(Math.abs(o)>pr&&++a<gr);return r}function Rt(t,e,n,s){if(t===e&&n===s)return K;const i=o=>yr(o,0,1,t,n);return o=>o===0||o===1?o:ks(i(o),e,s)}const Fs=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,Bs=t=>e=>1-t(1-e),Is=Rt(.33,1.53,.69,.99),Ke=Bs(Is),js=Fs(Ke),Os=t=>(t*=2)<1?.5*Ke(t):.5*(2-Math.pow(2,-10*(t-1))),Ge=t=>1-Math.sin(Math.acos(t)),Ns=Bs(Ge),Us=Fs(Ge),vr=Rt(.42,0,1,1),Tr=Rt(0,0,.58,1),Ws=Rt(.42,0,.58,1),xr=t=>Array.isArray(t)&&typeof t[0]!="number",Ks=t=>Array.isArray(t)&&typeof t[0]=="number",Pr={linear:K,easeIn:vr,easeInOut:Ws,easeOut:Tr,circIn:Ge,circInOut:Us,circOut:Ns,backIn:Ke,backInOut:js,backOut:Is,anticipate:Os},Sr=t=>typeof t=="string",gn=t=>{if(Ks(t)){Ne(t.length===4);const[e,n,s,i]=t;return Rt(e,n,s,i)}else if(Sr(t))return Pr[t];return t},Ft=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function wr(t,e){let n=new Set,s=new Set,i=!1,o=!1;const r=new WeakSet;let a={delta:0,timestamp:0,isProcessing:!1};function l(c){r.has(c)&&(u.schedule(c),t()),c(a)}const u={schedule:(c,h=!1,f=!1)=>{const m=f&&i?n:s;return h&&r.add(c),m.has(c)||m.add(c),c},cancel:c=>{s.delete(c),r.delete(c)},process:c=>{if(a=c,i){o=!0;return}i=!0,[n,s]=[s,n],n.forEach(l),n.clear(),i=!1,o&&(o=!1,u.process(c))}};return u}const br=40;function Gs(t,e){let n=!1,s=!0;const i={delta:0,timestamp:0,isProcessing:!1},o=()=>n=!0,r=Ft.reduce((y,b)=>(y[b]=wr(o),y),{}),{setup:a,read:l,resolveKeyframes:u,preUpdate:c,update:h,preRender:f,render:d,postRender:m}=r,v=()=>{const y=X.useManualTiming?i.timestamp:performance.now();n=!1,X.useManualTiming||(i.delta=s?1e3/60:Math.max(Math.min(y-i.timestamp,br),1)),i.timestamp=y,i.isProcessing=!0,a.process(i),l.process(i),u.process(i),c.process(i),h.process(i),f.process(i),d.process(i),m.process(i),i.isProcessing=!1,n&&e&&(s=!1,t(v))},T=()=>{n=!0,s=!0,i.isProcessing||t(v)};return{schedule:Ft.reduce((y,b)=>{const P=r[b];return y[b]=(A,E=!1,w=!1)=>(n||T(),P.schedule(A,E,w)),y},{}),cancel:y=>{for(let b=0;b<Ft.length;b++)r[Ft[b]].cancel(y)},state:i,steps:r}}const{schedule:V,cancel:Z,state:k,steps:qt}=Gs(typeof requestAnimationFrame<"u"?requestAnimationFrame:K,!0);let jt;function Ar(){jt=void 0}const B={now:()=>(jt===void 0&&B.set(k.isProcessing||X.useManualTiming?k.timestamp:performance.now()),jt),set:t=>{jt=t,queueMicrotask(Ar)}},$s=t=>e=>typeof e=="string"&&e.startsWith(t),Hs=$s("--"),Vr=$s("var(--"),$e=t=>Vr(t)?Cr.test(t.split("/*")[0].trim()):!1,Cr=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function yn(t){return typeof t!="string"?!1:t.split("/*")[0].includes("var(--")}const pt={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},Vt={...pt,transform:t=>_(0,1,t)},Bt={...pt,default:1},Pt=t=>Math.round(t*1e5)/1e5,He=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Mr(t){return t==null}const Dr=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,_e=(t,e)=>n=>!!(typeof n=="string"&&Dr.test(n)&&n.startsWith(t)||e&&!Mr(n)&&Object.prototype.hasOwnProperty.call(n,e)),_s=(t,e,n)=>s=>{if(typeof s!="string")return s;const[i,o,r,a]=s.match(He);return{[t]:parseFloat(i),[e]:parseFloat(o),[n]:parseFloat(r),alpha:a!==void 0?parseFloat(a):1}},Er=t=>_(0,255,t),Zt={...pt,transform:t=>Math.round(Er(t))},st={test:_e("rgb","red"),parse:_s("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:s=1})=>"rgba("+Zt.transform(t)+", "+Zt.transform(e)+", "+Zt.transform(n)+", "+Pt(Vt.transform(s))+")"};function Rr(t){let e="",n="",s="",i="";return t.length>5?(e=t.substring(1,3),n=t.substring(3,5),s=t.substring(5,7),i=t.substring(7,9)):(e=t.substring(1,2),n=t.substring(2,3),s=t.substring(3,4),i=t.substring(4,5),e+=e,n+=n,s+=s,i+=i),{red:parseInt(e,16),green:parseInt(n,16),blue:parseInt(s,16),alpha:i?parseInt(i,16)/255:1}}const de={test:_e("#"),parse:Rr,transform:st.transform},Lt=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),Y=Lt("deg"),H=Lt("%"),p=Lt("px"),Lr=Lt("vh"),kr=Lt("vw"),vn={...H,parse:t=>H.parse(t)/100,transform:t=>H.transform(t*100)},lt={test:_e("hsl","hue"),parse:_s("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:s=1})=>"hsla("+Math.round(t)+", "+H.transform(Pt(e))+", "+H.transform(Pt(n))+", "+Pt(Vt.transform(s))+")"},D={test:t=>st.test(t)||de.test(t)||lt.test(t),parse:t=>st.test(t)?st.parse(t):lt.test(t)?lt.parse(t):de.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?st.transform(t):lt.transform(t),getAnimatableNone:t=>{const e=D.parse(t);return e.alpha=0,D.transform(e)}},Fr=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function Br(t){return isNaN(t)&&typeof t=="string"&&(t.match(He)?.length||0)+(t.match(Fr)?.length||0)>0}const zs="number",Xs="color",Ir="var",jr="var(",Tn="${}",Or=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function Ct(t){const e=t.toString(),n=[],s={color:[],number:[],var:[]},i=[];let o=0;const a=e.replace(Or,l=>(D.test(l)?(s.color.push(o),i.push(Xs),n.push(D.parse(l))):l.startsWith(jr)?(s.var.push(o),i.push(Ir),n.push(l)):(s.number.push(o),i.push(zs),n.push(parseFloat(l))),++o,Tn)).split(Tn);return{values:n,split:a,indexes:s,types:i}}function Ys(t){return Ct(t).values}function qs(t){const{split:e,types:n}=Ct(t),s=e.length;return i=>{let o="";for(let r=0;r<s;r++)if(o+=e[r],i[r]!==void 0){const a=n[r];a===zs?o+=Pt(i[r]):a===Xs?o+=D.transform(i[r]):o+=i[r]}return o}}const Nr=t=>typeof t=="number"?0:D.test(t)?D.getAnimatableNone(t):t;function Ur(t){const e=Ys(t);return qs(t)(e.map(Nr))}const J={test:Br,parse:Ys,createTransformer:qs,getAnimatableNone:Ur};function Jt(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*(2/3-n)*6:t}function Wr({hue:t,saturation:e,lightness:n,alpha:s}){t/=360,e/=100,n/=100;let i=0,o=0,r=0;if(!e)i=o=r=n;else{const a=n<.5?n*(1+e):n+e-n*e,l=2*n-a;i=Jt(l,a,t+1/3),o=Jt(l,a,t),r=Jt(l,a,t-1/3)}return{red:Math.round(i*255),green:Math.round(o*255),blue:Math.round(r*255),alpha:s}}function Wt(t,e){return n=>n>0?e:t}const C=(t,e,n)=>t+(e-t)*n,Qt=(t,e,n)=>{const s=t*t,i=n*(e*e-s)+s;return i<0?0:Math.sqrt(i)},Kr=[de,st,lt],Gr=t=>Kr.find(e=>e.test(t));function xn(t){const e=Gr(t);if(!e)return!1;let n=e.parse(t);return e===lt&&(n=Wr(n)),n}const Pn=(t,e)=>{const n=xn(t),s=xn(e);if(!n||!s)return Wt(t,e);const i={...n};return o=>(i.red=Qt(n.red,s.red,o),i.green=Qt(n.green,s.green,o),i.blue=Qt(n.blue,s.blue,o),i.alpha=C(n.alpha,s.alpha,o),st.transform(i))},me=new Set(["none","hidden"]);function $r(t,e){return me.has(t)?n=>n<=0?t:e:n=>n>=1?e:t}function Hr(t,e){return n=>C(t,e,n)}function ze(t){return typeof t=="number"?Hr:typeof t=="string"?$e(t)?Wt:D.test(t)?Pn:Xr:Array.isArray(t)?Zs:typeof t=="object"?D.test(t)?Pn:_r:Wt}function Zs(t,e){const n=[...t],s=n.length,i=t.map((o,r)=>ze(o)(o,e[r]));return o=>{for(let r=0;r<s;r++)n[r]=i[r](o);return n}}function _r(t,e){const n={...t,...e},s={};for(const i in n)t[i]!==void 0&&e[i]!==void 0&&(s[i]=ze(t[i])(t[i],e[i]));return i=>{for(const o in s)n[o]=s[o](i);return n}}function zr(t,e){const n=[],s={color:0,var:0,number:0};for(let i=0;i<e.values.length;i++){const o=e.types[i],r=t.indexes[o][s[o]],a=t.values[r]??0;n[i]=a,s[o]++}return n}const Xr=(t,e)=>{const n=J.createTransformer(e),s=Ct(t),i=Ct(e);return s.indexes.var.length===i.indexes.var.length&&s.indexes.color.length===i.indexes.color.length&&s.indexes.number.length>=i.indexes.number.length?me.has(t)&&!i.values.length||me.has(e)&&!s.values.length?$r(t,e):Et(Zs(zr(s,i),i.values),n):Wt(t,e)};function Js(t,e,n){return typeof t=="number"&&typeof e=="number"&&typeof n=="number"?C(t,e,n):ze(t)(t,e)}const Yr=t=>{const e=({timestamp:n})=>t(n);return{start:(n=!0)=>V.update(e,n),stop:()=>Z(e),now:()=>k.isProcessing?k.timestamp:B.now()}},Qs=(t,e,n=10)=>{let s="";const i=Math.max(Math.round(e/n),2);for(let o=0;o<i;o++)s+=Math.round(t(o/(i-1))*1e4)/1e4+", ";return`linear(${s.substring(0,s.length-2)})`},Kt=2e4;function Xe(t){let e=0;const n=50;let s=t.next(e);for(;!s.done&&e<Kt;)e+=n,s=t.next(e);return e>=Kt?1/0:e}function qr(t,e=100,n){const s=n({...t,keyframes:[0,e]}),i=Math.min(Xe(s),Kt);return{type:"keyframes",ease:o=>s.next(i*o).value/e,duration:W(i)}}const Zr=5;function ti(t,e,n){const s=Math.max(e-Zr,0);return Ls(n-t(s),e-s)}const M={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1},te=.001;function Jr({duration:t=M.duration,bounce:e=M.bounce,velocity:n=M.velocity,mass:s=M.mass}){let i,o,r=1-e;r=_(M.minDamping,M.maxDamping,r),t=_(M.minDuration,M.maxDuration,W(t)),r<1?(i=u=>{const c=u*r,h=c*t,f=c-n,d=pe(u,r),m=Math.exp(-h);return te-f/d*m},o=u=>{const h=u*r*t,f=h*n+n,d=Math.pow(r,2)*Math.pow(u,2)*t,m=Math.exp(-h),v=pe(Math.pow(u,2),r);return(-i(u)+te>0?-1:1)*((f-d)*m)/v}):(i=u=>{const c=Math.exp(-u*t),h=(u-n)*t+1;return-te+c*h},o=u=>{const c=Math.exp(-u*t),h=(n-u)*(t*t);return c*h});const a=5/t,l=to(i,o,a);if(t=z(t),isNaN(l))return{stiffness:M.stiffness,damping:M.damping,duration:t};{const u=Math.pow(l,2)*s;return{stiffness:u,damping:r*2*Math.sqrt(s*u),duration:t}}}const Qr=12;function to(t,e,n){let s=n;for(let i=1;i<Qr;i++)s=s-t(s)/e(s);return s}function pe(t,e){return t*Math.sqrt(1-e*e)}const eo=["duration","bounce"],no=["stiffness","damping","mass"];function Sn(t,e){return e.some(n=>t[n]!==void 0)}function so(t){let e={velocity:M.velocity,stiffness:M.stiffness,damping:M.damping,mass:M.mass,isResolvedFromDuration:!1,...t};if(!Sn(t,no)&&Sn(t,eo))if(t.visualDuration){const n=t.visualDuration,s=2*Math.PI/(n*1.2),i=s*s,o=2*_(.05,1,1-(t.bounce||0))*Math.sqrt(i);e={...e,mass:M.mass,stiffness:i,damping:o}}else{const n=Jr(t);e={...e,...n,mass:M.mass},e.isResolvedFromDuration=!0}return e}function Gt(t=M.visualDuration,e=M.bounce){const n=typeof t!="object"?{visualDuration:t,keyframes:[0,1],bounce:e}:t;let{restSpeed:s,restDelta:i}=n;const o=n.keyframes[0],r=n.keyframes[n.keyframes.length-1],a={done:!1,value:o},{stiffness:l,damping:u,mass:c,duration:h,velocity:f,isResolvedFromDuration:d}=so({...n,velocity:-W(n.velocity||0)}),m=f||0,v=u/(2*Math.sqrt(l*c)),T=r-o,g=W(Math.sqrt(l/c)),x=Math.abs(T)<5;s||(s=x?M.restSpeed.granular:M.restSpeed.default),i||(i=x?M.restDelta.granular:M.restDelta.default);let y;if(v<1){const P=pe(g,v);y=A=>{const E=Math.exp(-v*g*A);return r-E*((m+v*g*T)/P*Math.sin(P*A)+T*Math.cos(P*A))}}else if(v===1)y=P=>r-Math.exp(-g*P)*(T+(m+g*T)*P);else{const P=g*Math.sqrt(v*v-1);y=A=>{const E=Math.exp(-v*g*A),w=Math.min(P*A,300);return r-E*((m+v*g*T)*Math.sinh(w)+P*T*Math.cosh(w))/P}}const b={calculatedDuration:d&&h||null,next:P=>{const A=y(P);if(d)a.done=P>=h;else{let E=P===0?m:0;v<1&&(E=P===0?z(m):ti(y,P,A));const w=Math.abs(E)<=s,j=Math.abs(r-A)<=i;a.done=w&&j}return a.value=a.done?r:A,a},toString:()=>{const P=Math.min(Xe(b),Kt),A=Qs(E=>b.next(P*E).value,P,30);return P+"ms "+A},toTransition:()=>{}};return b}Gt.applyToOptions=t=>{const e=qr(t,100,Gt);return t.ease=e.ease,t.duration=z(e.duration),t.type="keyframes",t};function ge({keyframes:t,velocity:e=0,power:n=.8,timeConstant:s=325,bounceDamping:i=10,bounceStiffness:o=500,modifyTarget:r,min:a,max:l,restDelta:u=.5,restSpeed:c}){const h=t[0],f={done:!1,value:h},d=w=>a!==void 0&&w<a||l!==void 0&&w>l,m=w=>a===void 0?l:l===void 0||Math.abs(a-w)<Math.abs(l-w)?a:l;let v=n*e;const T=h+v,g=r===void 0?T:r(T);g!==T&&(v=g-h);const x=w=>-v*Math.exp(-w/s),y=w=>g+x(w),b=w=>{const j=x(w),O=y(w);f.done=Math.abs(j)<=u,f.value=f.done?g:O};let P,A;const E=w=>{d(f.value)&&(P=w,A=Gt({keyframes:[f.value,m(f.value)],velocity:ti(y,w,f.value),damping:i,stiffness:o,restDelta:u,restSpeed:c}))};return E(0),{calculatedDuration:null,next:w=>{let j=!1;return!A&&P===void 0&&(j=!0,b(w),E(w)),P!==void 0&&w>=P?A.next(w-P):(!j&&b(w),f)}}}function io(t,e,n){const s=[],i=n||X.mix||Js,o=t.length-1;for(let r=0;r<o;r++){let a=i(t[r],t[r+1]);if(e){const l=Array.isArray(e)?e[r]||K:e;a=Et(l,a)}s.push(a)}return s}function ro(t,e,{clamp:n=!0,ease:s,mixer:i}={}){const o=t.length;if(Ne(o===e.length),o===1)return()=>e[0];if(o===2&&e[0]===e[1])return()=>e[1];const r=t[0]===t[1];t[0]>t[o-1]&&(t=[...t].reverse(),e=[...e].reverse());const a=io(e,s,i),l=a.length,u=c=>{if(r&&c<t[0])return e[0];let h=0;if(l>1)for(;h<t.length-2&&!(c<t[h+1]);h++);const f=At(t[h],t[h+1],c);return a[h](f)};return n?c=>u(_(t[0],t[o-1],c)):u}function oo(t,e){const n=t[t.length-1];for(let s=1;s<=e;s++){const i=At(0,e,s);t.push(C(n,1,i))}}function ao(t){const e=[0];return oo(e,t.length-1),e}function lo(t,e){return t.map(n=>n*e)}function co(t,e){return t.map(()=>e||Ws).splice(0,t.length-1)}function St({duration:t=300,keyframes:e,times:n,ease:s="easeInOut"}){const i=xr(s)?s.map(gn):gn(s),o={done:!1,value:e[0]},r=lo(n&&n.length===e.length?n:ao(e),t),a=ro(r,e,{ease:Array.isArray(i)?i:co(e,i)});return{calculatedDuration:t,next:l=>(o.value=a(l),o.done=l>=t,o)}}const uo=t=>t!==null;function Ye(t,{repeat:e,repeatType:n="loop"},s,i=1){const o=t.filter(uo),a=i<0||e&&n!=="loop"&&e%2===1?0:o.length-1;return!a||s===void 0?o[a]:s}const ho={decay:ge,inertia:ge,tween:St,keyframes:St,spring:Gt};function ei(t){typeof t.type=="string"&&(t.type=ho[t.type])}class qe{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,n){return this.finished.then(e,n)}}const fo=t=>t/100;class Ze extends qe{constructor(e){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{const{motionValue:n}=this.options;n&&n.updatedAt!==B.now()&&this.tick(B.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),this.options.onStop?.())},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){const{options:e}=this;ei(e);const{type:n=St,repeat:s=0,repeatDelay:i=0,repeatType:o,velocity:r=0}=e;let{keyframes:a}=e;const l=n||St;l!==St&&typeof a[0]!="number"&&(this.mixKeyframes=Et(fo,Js(a[0],a[1])),a=[0,100]);const u=l({...e,keyframes:a});o==="mirror"&&(this.mirroredGenerator=l({...e,keyframes:[...a].reverse(),velocity:-r})),u.calculatedDuration===null&&(u.calculatedDuration=Xe(u));const{calculatedDuration:c}=u;this.calculatedDuration=c,this.resolvedDuration=c+i,this.totalDuration=this.resolvedDuration*(s+1)-i,this.generator=u}updateTime(e){const n=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(e,n=!1){const{generator:s,totalDuration:i,mixKeyframes:o,mirroredGenerator:r,resolvedDuration:a,calculatedDuration:l}=this;if(this.startTime===null)return s.next(0);const{delay:u=0,keyframes:c,repeat:h,repeatType:f,repeatDelay:d,type:m,onUpdate:v,finalKeyframe:T}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-i/this.speed,this.startTime)),n?this.currentTime=e:this.updateTime(e);const g=this.currentTime-u*(this.playbackSpeed>=0?1:-1),x=this.playbackSpeed>=0?g<0:g>i;this.currentTime=Math.max(g,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=i);let y=this.currentTime,b=s;if(h){const w=Math.min(this.currentTime,i)/a;let j=Math.floor(w),O=w%1;!O&&w>=1&&(O=1),O===1&&j--,j=Math.min(j,h+1),!!(j%2)&&(f==="reverse"?(O=1-O,d&&(O-=d/a)):f==="mirror"&&(b=r)),y=_(0,1,O)*a}const P=x?{done:!1,value:c[0]}:b.next(y);o&&(P.value=o(P.value));let{done:A}=P;!x&&l!==null&&(A=this.playbackSpeed>=0?this.currentTime>=i:this.currentTime<=0);const E=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&A);return E&&m!==ge&&(P.value=Ye(c,this.options,T,this.speed)),v&&v(P.value),E&&this.finish(),P}then(e,n){return this.finished.then(e,n)}get duration(){return W(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+W(e)}get time(){return W(this.currentTime)}set time(e){e=z(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?.start(!1)}get speed(){return this.playbackSpeed}set speed(e){this.updateTime(B.now());const n=this.playbackSpeed!==e;this.playbackSpeed=e,n&&(this.time=W(this.currentTime))}play(){if(this.isStopped)return;const{driver:e=Yr,startTime:n}=this.options;this.driver||(this.driver=e(i=>this.tick(i))),this.options.onPlay?.();const s=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=s):this.holdTime!==null?this.startTime=s-this.holdTime:this.startTime||(this.startTime=n??s),this.state==="finished"&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(B.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state="finished",this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),this.driver?.stop(),e.observe(this)}}function mo(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}const it=t=>t*180/Math.PI,ye=t=>{const e=it(Math.atan2(t[1],t[0]));return ve(e)},po={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:ye,rotateZ:ye,skewX:t=>it(Math.atan(t[1])),skewY:t=>it(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},ve=t=>(t=t%360,t<0&&(t+=360),t),wn=ye,bn=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),An=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),go={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:bn,scaleY:An,scale:t=>(bn(t)+An(t))/2,rotateX:t=>ve(it(Math.atan2(t[6],t[5]))),rotateY:t=>ve(it(Math.atan2(-t[2],t[0]))),rotateZ:wn,rotate:wn,skewX:t=>it(Math.atan(t[4])),skewY:t=>it(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function Te(t){return t.includes("scale")?1:0}function xe(t,e){if(!t||t==="none")return Te(e);const n=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let s,i;if(n)s=go,i=n;else{const a=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);s=po,i=a}if(!i)return Te(e);const o=s[e],r=i[1].split(",").map(vo);return typeof o=="function"?o(r):r[o]}const yo=(t,e)=>{const{transform:n="none"}=getComputedStyle(t);return xe(n,e)};function vo(t){return parseFloat(t.trim())}const gt=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],yt=new Set(gt),Vn=t=>t===pt||t===p,To=new Set(["x","y","z"]),xo=gt.filter(t=>!To.has(t));function Po(t){const e=[];return xo.forEach(n=>{const s=t.getValue(n);s!==void 0&&(e.push([n,s.get()]),s.set(n.startsWith("scale")?1:0))}),e}const q={width:({x:t},{paddingLeft:e="0",paddingRight:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),height:({y:t},{paddingTop:e="0",paddingBottom:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),top:(t,{top:e})=>parseFloat(e),left:(t,{left:e})=>parseFloat(e),bottom:({y:t},{top:e})=>parseFloat(e)+(t.max-t.min),right:({x:t},{left:e})=>parseFloat(e)+(t.max-t.min),x:(t,{transform:e})=>xe(e,"x"),y:(t,{transform:e})=>xe(e,"y")};q.translateX=q.x;q.translateY=q.y;const rt=new Set;let Pe=!1,Se=!1,we=!1;function ni(){if(Se){const t=Array.from(rt).filter(s=>s.needsMeasurement),e=new Set(t.map(s=>s.element)),n=new Map;e.forEach(s=>{const i=Po(s);i.length&&(n.set(s,i),s.render())}),t.forEach(s=>s.measureInitialState()),e.forEach(s=>{s.render();const i=n.get(s);i&&i.forEach(([o,r])=>{s.getValue(o)?.set(r)})}),t.forEach(s=>s.measureEndState()),t.forEach(s=>{s.suspendedScrollY!==void 0&&window.scrollTo(0,s.suspendedScrollY)})}Se=!1,Pe=!1,rt.forEach(t=>t.complete(we)),rt.clear()}function si(){rt.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(Se=!0)})}function So(){we=!0,si(),ni(),we=!1}class Je{constructor(e,n,s,i,o,r=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=n,this.name=s,this.motionValue=i,this.element=o,this.isAsync=r}scheduleResolve(){this.state="scheduled",this.isAsync?(rt.add(this),Pe||(Pe=!0,V.read(si),V.resolveKeyframes(ni))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:e,name:n,element:s,motionValue:i}=this;if(e[0]===null){const o=i?.get(),r=e[e.length-1];if(o!==void 0)e[0]=o;else if(s&&n){const a=s.readValue(n,r);a!=null&&(e[0]=a)}e[0]===void 0&&(e[0]=r),i&&o===void 0&&i.set(e[0])}mo(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),rt.delete(this)}cancel(){this.state==="scheduled"&&(rt.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const wo=t=>t.startsWith("--");function bo(t,e,n){wo(e)?t.style.setProperty(e,n):t.style[e]=n}const Ao=Ue(()=>window.ScrollTimeline!==void 0),Vo={};function Co(t,e){const n=Ue(t);return()=>Vo[e]??n()}const ii=Co(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),Tt=([t,e,n,s])=>`cubic-bezier(${t}, ${e}, ${n}, ${s})`,Cn={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:Tt([0,.65,.55,1]),circOut:Tt([.55,0,1,.45]),backIn:Tt([.31,.01,.66,-.59]),backOut:Tt([.33,1.53,.69,.99])};function ri(t,e){if(t)return typeof t=="function"?ii()?Qs(t,e):"ease-out":Ks(t)?Tt(t):Array.isArray(t)?t.map(n=>ri(n,e)||Cn.easeOut):Cn[t]}function Mo(t,e,n,{delay:s=0,duration:i=300,repeat:o=0,repeatType:r="loop",ease:a="easeOut",times:l}={},u=void 0){const c={[e]:n};l&&(c.offset=l);const h=ri(a,i);Array.isArray(h)&&(c.easing=h);const f={delay:s,duration:i,easing:Array.isArray(h)?"linear":h,fill:"both",iterations:o+1,direction:r==="reverse"?"alternate":"normal"};return u&&(f.pseudoElement=u),t.animate(c,f)}function oi(t){return typeof t=="function"&&"applyToOptions"in t}function Do({type:t,...e}){return oi(t)&&ii()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class Eo extends qe{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!e)return;const{element:n,name:s,keyframes:i,pseudoElement:o,allowFlatten:r=!1,finalKeyframe:a,onComplete:l}=e;this.isPseudoElement=!!o,this.allowFlatten=r,this.options=e,Ne(typeof e.type!="string");const u=Do(e);this.animation=Mo(n,s,i,u,o),u.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const c=Ye(i,this.options,a,this.speed);this.updateMotionValue?this.updateMotionValue(c):bo(n,s,c),this.animation.cancel()}l?.(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:e}=this;e==="idle"||e==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){this.isPseudoElement||this.animation.commitStyles?.()}get duration(){const e=this.animation.effect?.getComputedTiming?.().duration||0;return W(Number(e))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+W(e)}get time(){return W(Number(this.animation.currentTime)||0)}set time(e){this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=z(e)}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(e){this.manualStartTime=this.animation.startTime=e}attachTimeline({timeline:e,observe:n}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,e&&Ao()?(this.animation.timeline=e,K):n(this)}}const ai={anticipate:Os,backInOut:js,circInOut:Us};function Ro(t){return t in ai}function Lo(t){typeof t.ease=="string"&&Ro(t.ease)&&(t.ease=ai[t.ease])}const ee=10;class ko extends Eo{constructor(e){Lo(e),ei(e),super(e),e.startTime!==void 0&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){const{motionValue:n,onUpdate:s,onComplete:i,element:o,...r}=this.options;if(!n)return;if(e!==void 0){n.set(e);return}const a=new Ze({...r,autoplay:!1}),l=Math.max(ee,B.now()-this.startTime),u=_(0,ee,l-ee);n.setWithVelocity(a.sample(Math.max(0,l-u)).value,a.sample(l).value,u),a.stop()}}const Mn=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(J.test(t)||t==="0")&&!t.startsWith("url("));function Fo(t){const e=t[0];if(t.length===1)return!0;for(let n=0;n<t.length;n++)if(t[n]!==e)return!0}function Bo(t,e,n,s){const i=t[0];if(i===null)return!1;if(e==="display"||e==="visibility")return!0;const o=t[t.length-1],r=Mn(i,e),a=Mn(o,e);return!r||!a?!1:Fo(t)||(n==="spring"||oi(n))&&s}function be(t){t.duration=0,t.type="keyframes"}const Io=new Set(["opacity","clipPath","filter","transform"]),jo=Ue(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function Oo(t){const{motionValue:e,name:n,repeatDelay:s,repeatType:i,damping:o,type:r}=t;if(!(e?.owner?.current instanceof HTMLElement))return!1;const{onUpdate:l,transformTemplate:u}=e.owner.getProps();return jo()&&n&&Io.has(n)&&(n!=="transform"||!u)&&!l&&!s&&i!=="mirror"&&o!==0&&r!=="inertia"}const No=40;class Uo extends qe{constructor({autoplay:e=!0,delay:n=0,type:s="keyframes",repeat:i=0,repeatDelay:o=0,repeatType:r="loop",keyframes:a,name:l,motionValue:u,element:c,...h}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=B.now();const f={autoplay:e,delay:n,type:s,repeat:i,repeatDelay:o,repeatType:r,name:l,motionValue:u,element:c,...h},d=c?.KeyframeResolver||Je;this.keyframeResolver=new d(a,(m,v,T)=>this.onKeyframesResolved(m,v,f,!T),l,u,c),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,n,s,i){this.keyframeResolver=void 0;const{name:o,type:r,velocity:a,delay:l,isHandoff:u,onUpdate:c}=s;this.resolvedAt=B.now(),Bo(e,o,r,a)||((X.instantAnimations||!l)&&c?.(Ye(e,s,n)),e[0]=e[e.length-1],be(s),s.repeat=0);const f={startTime:i?this.resolvedAt?this.resolvedAt-this.createdAt>No?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...s,keyframes:e},d=!u&&Oo(f)?new ko({...f,element:f.motionValue.owner.current}):new Ze(f);d.finished.then(()=>this.notifyFinished()).catch(K),this.pendingTimeline&&(this.stopTimeline=d.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=d}get finished(){return this._animation?this.animation.finished:this._finished}then(e,n){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),So()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}}const Wo=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function Ko(t){const e=Wo.exec(t);if(!e)return[,];const[,n,s,i]=e;return[`--${n??s}`,i]}function li(t,e,n=1){const[s,i]=Ko(t);if(!s)return;const o=window.getComputedStyle(e).getPropertyValue(s);if(o){const r=o.trim();return Ds(r)?parseFloat(r):r}return $e(i)?li(i,e,n+1):i}function Qe(t,e){return t?.[e]??t?.default??t}const ci=new Set(["width","height","top","left","right","bottom",...gt]),Go={test:t=>t==="auto",parse:t=>t},ui=t=>e=>e.test(t),hi=[pt,p,H,Y,kr,Lr,Go],Dn=t=>hi.find(ui(t));function $o(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||Rs(t):!0}const Ho=new Set(["brightness","contrast","saturate","opacity"]);function _o(t){const[e,n]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[s]=n.match(He)||[];if(!s)return t;const i=n.replace(s,"");let o=Ho.has(e)?1:0;return s!==n&&(o*=100),e+"("+o+i+")"}const zo=/\b([a-z-]*)\(.*?\)/gu,Ae={...J,getAnimatableNone:t=>{const e=t.match(zo);return e?e.map(_o).join(" "):t}},En={...pt,transform:Math.round},Xo={rotate:Y,rotateX:Y,rotateY:Y,rotateZ:Y,scale:Bt,scaleX:Bt,scaleY:Bt,scaleZ:Bt,skew:Y,skewX:Y,skewY:Y,distance:p,translateX:p,translateY:p,translateZ:p,x:p,y:p,z:p,perspective:p,transformPerspective:p,opacity:Vt,originX:vn,originY:vn,originZ:p},tn={borderWidth:p,borderTopWidth:p,borderRightWidth:p,borderBottomWidth:p,borderLeftWidth:p,borderRadius:p,radius:p,borderTopLeftRadius:p,borderTopRightRadius:p,borderBottomRightRadius:p,borderBottomLeftRadius:p,width:p,maxWidth:p,height:p,maxHeight:p,top:p,right:p,bottom:p,left:p,inset:p,insetBlock:p,insetBlockStart:p,insetBlockEnd:p,insetInline:p,insetInlineStart:p,insetInlineEnd:p,padding:p,paddingTop:p,paddingRight:p,paddingBottom:p,paddingLeft:p,paddingBlock:p,paddingBlockStart:p,paddingBlockEnd:p,paddingInline:p,paddingInlineStart:p,paddingInlineEnd:p,margin:p,marginTop:p,marginRight:p,marginBottom:p,marginLeft:p,marginBlock:p,marginBlockStart:p,marginBlockEnd:p,marginInline:p,marginInlineStart:p,marginInlineEnd:p,backgroundPositionX:p,backgroundPositionY:p,...Xo,zIndex:En,fillOpacity:Vt,strokeOpacity:Vt,numOctaves:En},Yo={...tn,color:D,backgroundColor:D,outlineColor:D,fill:D,stroke:D,borderColor:D,borderTopColor:D,borderRightColor:D,borderBottomColor:D,borderLeftColor:D,filter:Ae,WebkitFilter:Ae},fi=t=>Yo[t];function di(t,e){let n=fi(t);return n!==Ae&&(n=J),n.getAnimatableNone?n.getAnimatableNone(e):void 0}const qo=new Set(["auto","none","0"]);function Zo(t,e,n){let s=0,i;for(;s<t.length&&!i;){const o=t[s];typeof o=="string"&&!qo.has(o)&&Ct(o).values.length&&(i=t[s]),s++}if(i&&n)for(const o of e)t[o]=di(n,i)}class Jo extends Je{constructor(e,n,s,i,o){super(e,n,s,i,o,!0)}readKeyframes(){const{unresolvedKeyframes:e,element:n,name:s}=this;if(!n||!n.current)return;super.readKeyframes();for(let c=0;c<e.length;c++){let h=e[c];if(typeof h=="string"&&(h=h.trim(),$e(h))){const f=li(h,n.current);f!==void 0&&(e[c]=f),c===e.length-1&&(this.finalKeyframe=h)}}if(this.resolveNoneKeyframes(),!ci.has(s)||e.length!==2)return;const[i,o]=e,r=Dn(i),a=Dn(o),l=yn(i),u=yn(o);if(l!==u&&q[s]){this.needsMeasurement=!0;return}if(r!==a)if(Vn(r)&&Vn(a))for(let c=0;c<e.length;c++){const h=e[c];typeof h=="string"&&(e[c]=parseFloat(h))}else q[s]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:n}=this,s=[];for(let i=0;i<e.length;i++)(e[i]===null||$o(e[i]))&&s.push(i);s.length&&Zo(e,s,n)}measureInitialState(){const{element:e,unresolvedKeyframes:n,name:s}=this;if(!e||!e.current)return;s==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=q[s](e.measureViewportBox(),window.getComputedStyle(e.current)),n[0]=this.measuredOrigin;const i=n[n.length-1];i!==void 0&&e.getValue(s,i).jump(i,!1)}measureEndState(){const{element:e,name:n,unresolvedKeyframes:s}=this;if(!e||!e.current)return;const i=e.getValue(n);i&&i.jump(this.measuredOrigin,!1);const o=s.length-1,r=s[o];s[o]=q[n](e.measureViewportBox(),window.getComputedStyle(e.current)),r!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=r),this.removedTransforms?.length&&this.removedTransforms.forEach(([a,l])=>{e.getValue(a).set(l)}),this.resolveNoneKeyframes()}}function Qo(t,e,n){if(t instanceof EventTarget)return[t];if(typeof t=="string"){let s=document;const i=n?.[t]??s.querySelectorAll(t);return i?Array.from(i):[]}return Array.from(t)}const mi=(t,e)=>e&&typeof t=="number"?e.transform(t):t;function ta(t){return Es(t)&&"offsetHeight"in t}const Rn=30,ea=t=>!isNaN(parseFloat(t));class na{constructor(e,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=s=>{const i=B.now();if(this.updatedAt!==i&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(s),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(const o of this.dependents)o.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=n.owner}setCurrent(e){this.current=e,this.updatedAt=B.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=ea(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on("change",e)}on(e,n){this.events[e]||(this.events[e]=new We);const s=this.events[e].add(n);return e==="change"?()=>{s(),V.read(()=>{this.events.change.getSize()||this.stop()})}:s}clearListeners(){for(const e in this.events)this.events[e].clear()}attach(e,n){this.passiveEffect=e,this.stopPassiveEffect=n}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,n,s){this.set(n),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-s}jump(e,n=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(e){this.dependents||(this.dependents=new Set),this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const e=B.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>Rn)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,Rn);return Ls(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(e){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=e(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function dt(t,e){return new na(t,e)}const{schedule:en}=Gs(queueMicrotask,!1),$={x:!1,y:!1};function pi(){return $.x||$.y}function sa(t){return t==="x"||t==="y"?$[t]?null:($[t]=!0,()=>{$[t]=!1}):$.x||$.y?null:($.x=$.y=!0,()=>{$.x=$.y=!1})}function gi(t,e){const n=Qo(t),s=new AbortController,i={passive:!0,...e,signal:s.signal};return[n,i,()=>s.abort()]}function Ln(t){return!(t.pointerType==="touch"||pi())}function ia(t,e,n={}){const[s,i,o]=gi(t,n),r=a=>{if(!Ln(a))return;const{target:l}=a,u=e(l,a);if(typeof u!="function"||!l)return;const c=h=>{Ln(h)&&(u(h),l.removeEventListener("pointerleave",c))};l.addEventListener("pointerleave",c,i)};return s.forEach(a=>{a.addEventListener("pointerenter",r,i)}),o}const yi=(t,e)=>e?t===e?!0:yi(t,e.parentElement):!1,nn=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,ra=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function vi(t){return ra.has(t.tagName)||t.isContentEditable===!0}const Ot=new WeakSet;function kn(t){return e=>{e.key==="Enter"&&t(e)}}function ne(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const oa=(t,e)=>{const n=t.currentTarget;if(!n)return;const s=kn(()=>{if(Ot.has(n))return;ne(n,"down");const i=kn(()=>{ne(n,"up")}),o=()=>ne(n,"cancel");n.addEventListener("keyup",i,e),n.addEventListener("blur",o,e)});n.addEventListener("keydown",s,e),n.addEventListener("blur",()=>n.removeEventListener("keydown",s),e)};function Fn(t){return nn(t)&&!pi()}function aa(t,e,n={}){const[s,i,o]=gi(t,n),r=a=>{const l=a.currentTarget;if(!Fn(a))return;Ot.add(l);const u=e(l,a),c=(d,m)=>{window.removeEventListener("pointerup",h),window.removeEventListener("pointercancel",f),Ot.has(l)&&Ot.delete(l),Fn(d)&&typeof u=="function"&&u(d,{success:m})},h=d=>{c(d,l===window||l===document||n.useGlobalTarget||yi(l,d.target))},f=d=>{c(d,!1)};window.addEventListener("pointerup",h,i),window.addEventListener("pointercancel",f,i)};return s.forEach(a=>{(n.useGlobalTarget?window:a).addEventListener("pointerdown",r,i),ta(a)&&(a.addEventListener("focus",u=>oa(u,i)),!vi(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),o}function Ti(t){return Es(t)&&"ownerSVGElement"in t}function la(t){return Ti(t)&&t.tagName==="svg"}const F=t=>!!(t&&t.getVelocity),ca=[...hi,D,J],ua=t=>ca.find(ui(t)),xi=S.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function ha(t=!0){const e=S.useContext(Ie);if(e===null)return[!0,null];const{isPresent:n,onExitComplete:s,register:i}=e,o=S.useId();S.useEffect(()=>{if(t)return i(o)},[t]);const r=S.useCallback(()=>t&&s&&s(o),[o,s,t]);return!n&&s?[!1,r]:[!0]}const Pi=S.createContext({strict:!1}),Bn={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]},mt={};for(const t in Bn)mt[t]={isEnabled:e=>Bn[t].some(n=>!!e[n])};function fa(t){for(const e in t)mt[e]={...mt[e],...t[e]}}const da=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function $t(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||da.has(t)}let Si=t=>!$t(t);function ma(t){typeof t=="function"&&(Si=e=>e.startsWith("on")?!$t(e):t(e))}try{ma(require("@emotion/is-prop-valid").default)}catch{}function pa(t,e,n){const s={};for(const i in t)i==="values"&&typeof t.values=="object"||(Si(i)||n===!0&&$t(i)||!e&&!$t(i)||t.draggable&&i.startsWith("onDrag"))&&(s[i]=t[i]);return s}const zt=S.createContext({});function Xt(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function Mt(t){return typeof t=="string"||Array.isArray(t)}const sn=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],rn=["initial",...sn];function Yt(t){return Xt(t.animate)||rn.some(e=>Mt(t[e]))}function wi(t){return!!(Yt(t)||t.variants)}function ga(t,e){if(Yt(t)){const{initial:n,animate:s}=t;return{initial:n===!1||Mt(n)?n:void 0,animate:Mt(s)?s:void 0}}return t.inherit!==!1?e:{}}function ya(t){const{initial:e,animate:n}=ga(t,S.useContext(zt));return S.useMemo(()=>({initial:e,animate:n}),[In(e),In(n)])}function In(t){return Array.isArray(t)?t.join(" "):t}function jn(t,e){return e.max===e.min?0:t/(e.max-e.min)*100}const vt={correct:(t,e)=>{if(!e.target)return t;if(typeof t=="string")if(p.test(t))t=parseFloat(t);else return t;const n=jn(t,e.target.x),s=jn(t,e.target.y);return`${n}% ${s}%`}},va={correct:(t,{treeScale:e,projectionDelta:n})=>{const s=t,i=J.parse(t);if(i.length>5)return s;const o=J.createTransformer(t),r=typeof i[0]!="number"?1:0,a=n.x.scale*e.x,l=n.y.scale*e.y;i[0+r]/=a,i[1+r]/=l;const u=C(a,l,.5);return typeof i[2+r]=="number"&&(i[2+r]/=u),typeof i[3+r]=="number"&&(i[3+r]/=u),o(i)}},Ve={borderRadius:{...vt,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:vt,borderTopRightRadius:vt,borderBottomLeftRadius:vt,borderBottomRightRadius:vt,boxShadow:va};function bi(t,{layout:e,layoutId:n}){return yt.has(t)||t.startsWith("origin")||(e||n!==void 0)&&(!!Ve[t]||t==="opacity")}const Ta={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},xa=gt.length;function Pa(t,e,n){let s="",i=!0;for(let o=0;o<xa;o++){const r=gt[o],a=t[r];if(a===void 0)continue;let l=!0;if(typeof a=="number"?l=a===(r.startsWith("scale")?1:0):l=parseFloat(a)===0,!l||n){const u=mi(a,tn[r]);if(!l){i=!1;const c=Ta[r]||r;s+=`${c}(${u}) `}n&&(e[r]=u)}}return s=s.trim(),n?s=n(e,i?"":s):i&&(s="none"),s}function on(t,e,n){const{style:s,vars:i,transformOrigin:o}=t;let r=!1,a=!1;for(const l in e){const u=e[l];if(yt.has(l)){r=!0;continue}else if(Hs(l)){i[l]=u;continue}else{const c=mi(u,tn[l]);l.startsWith("origin")?(a=!0,o[l]=c):s[l]=c}}if(e.transform||(r||n?s.transform=Pa(e,t.transform,n):s.transform&&(s.transform="none")),a){const{originX:l="50%",originY:u="50%",originZ:c=0}=o;s.transformOrigin=`${l} ${u} ${c}`}}const an=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function Ai(t,e,n){for(const s in e)!F(e[s])&&!bi(s,n)&&(t[s]=e[s])}function Sa({transformTemplate:t},e){return S.useMemo(()=>{const n=an();return on(n,e,t),Object.assign({},n.vars,n.style)},[e])}function wa(t,e){const n=t.style||{},s={};return Ai(s,n,t),Object.assign(s,Sa(t,e)),s}function ba(t,e){const n={},s=wa(t,e);return t.drag&&t.dragListener!==!1&&(n.draggable=!1,s.userSelect=s.WebkitUserSelect=s.WebkitTouchCallout="none",s.touchAction=t.drag===!0?"none":`pan-${t.drag==="x"?"y":"x"}`),t.tabIndex===void 0&&(t.onTap||t.onTapStart||t.whileTap)&&(n.tabIndex=0),n.style=s,n}const Aa={offset:"stroke-dashoffset",array:"stroke-dasharray"},Va={offset:"strokeDashoffset",array:"strokeDasharray"};function Ca(t,e,n=1,s=0,i=!0){t.pathLength=1;const o=i?Aa:Va;t[o.offset]=p.transform(-s);const r=p.transform(e),a=p.transform(n);t[o.array]=`${r} ${a}`}const Ma=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function Vi(t,{attrX:e,attrY:n,attrScale:s,pathLength:i,pathSpacing:o=1,pathOffset:r=0,...a},l,u,c){if(on(t,a,u),l){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:h,style:f}=t;h.transform&&(f.transform=h.transform,delete h.transform),(f.transform||h.transformOrigin)&&(f.transformOrigin=h.transformOrigin??"50% 50%",delete h.transformOrigin),f.transform&&(f.transformBox=c?.transformBox??"fill-box",delete h.transformBox);for(const d of Ma)h[d]!==void 0&&(f[d]=h[d],delete h[d]);e!==void 0&&(h.x=e),n!==void 0&&(h.y=n),s!==void 0&&(h.scale=s),i!==void 0&&Ca(h,i,o,r,!1)}const Ci=()=>({...an(),attrs:{}}),Mi=t=>typeof t=="string"&&t.toLowerCase()==="svg";function Da(t,e,n,s){const i=S.useMemo(()=>{const o=Ci();return Vi(o,e,Mi(s),t.transformTemplate,t.style),{...o.attrs,style:{...o.style}}},[e]);if(t.style){const o={};Ai(o,t.style,t),i.style={...o,...i.style}}return i}const Ea=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function ln(t){return typeof t!="string"||t.includes("-")?!1:!!(Ea.indexOf(t)>-1||/[A-Z]/u.test(t))}function Ra(t,e,n,{latestValues:s},i,o=!1,r){const l=(r??ln(t)?Da:ba)(e,s,i,t),u=pa(e,typeof t=="string",o),c=t!==S.Fragment?{...u,...l,ref:n}:{},{children:h}=e,f=S.useMemo(()=>F(h)?h.get():h,[h]);return S.createElement(t,{...c,children:f})}function On(t){const e=[{},{}];return t?.values.forEach((n,s)=>{e[0][s]=n.get(),e[1][s]=n.getVelocity()}),e}function cn(t,e,n,s){if(typeof e=="function"){const[i,o]=On(s);e=e(n!==void 0?n:t.custom,i,o)}if(typeof e=="string"&&(e=t.variants&&t.variants[e]),typeof e=="function"){const[i,o]=On(s);e=e(n!==void 0?n:t.custom,i,o)}return e}function Nt(t){return F(t)?t.get():t}function La({scrapeMotionValuesFromProps:t,createRenderState:e},n,s,i){return{latestValues:ka(n,s,i,t),renderState:e()}}function ka(t,e,n,s){const i={},o=s(t,{});for(const f in o)i[f]=Nt(o[f]);let{initial:r,animate:a}=t;const l=Yt(t),u=wi(t);e&&u&&!l&&t.inherit!==!1&&(r===void 0&&(r=e.initial),a===void 0&&(a=e.animate));let c=n?n.initial===!1:!1;c=c||r===!1;const h=c?a:r;if(h&&typeof h!="boolean"&&!Xt(h)){const f=Array.isArray(h)?h:[h];for(let d=0;d<f.length;d++){const m=cn(t,f[d]);if(m){const{transitionEnd:v,transition:T,...g}=m;for(const x in g){let y=g[x];if(Array.isArray(y)){const b=c?y.length-1:0;y=y[b]}y!==null&&(i[x]=y)}for(const x in v)i[x]=v[x]}}}return i}const Di=t=>(e,n)=>{const s=S.useContext(zt),i=S.useContext(Ie),o=()=>La(t,e,s,i);return n?o():fr(o)};function un(t,e,n){const{style:s}=t,i={};for(const o in s)(F(s[o])||e.style&&F(e.style[o])||bi(o,t)||n?.getValue(o)?.liveStyle!==void 0)&&(i[o]=s[o]);return i}const Fa=Di({scrapeMotionValuesFromProps:un,createRenderState:an});function Ei(t,e,n){const s=un(t,e,n);for(const i in t)if(F(t[i])||F(e[i])){const o=gt.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;s[o]=t[i]}return s}const Ba=Di({scrapeMotionValuesFromProps:Ei,createRenderState:Ci}),Ia=Symbol.for("motionComponentSymbol");function ja(t,e,n){const s=S.useRef(n);S.useInsertionEffect(()=>{s.current=n});const i=S.useRef(null);return S.useCallback(o=>{o&&t.onMount?.(o),e&&(o?e.mount(o):e.unmount());const r=s.current;if(typeof r=="function")if(o){const a=r(o);typeof a=="function"&&(i.current=a)}else i.current?(i.current(),i.current=null):r(o);else r&&(r.current=o)},[e])}const hn=t=>t.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),Oa="framerAppearId",Ri="data-"+hn(Oa),Li=S.createContext({});function xt(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function Na(t,e,n,s,i,o){const{visualElement:r}=S.useContext(zt),a=S.useContext(Pi),l=S.useContext(Ie),u=S.useContext(xi).reducedMotion,c=S.useRef(null);s=s||a.renderer,!c.current&&s&&(c.current=s(t,{visualState:e,parent:r,props:n,presenceContext:l,blockInitialAnimation:l?l.initial===!1:!1,reducedMotionConfig:u,isSVG:o}));const h=c.current,f=S.useContext(Li);h&&!h.projection&&i&&(h.type==="html"||h.type==="svg")&&Ua(c.current,n,i,f);const d=S.useRef(!1);S.useInsertionEffect(()=>{h&&d.current&&h.update(n,l)});const m=n[Ri],v=S.useRef(!!m&&!window.MotionHandoffIsComplete?.(m)&&window.MotionHasOptimisedAnimation?.(m));return dr(()=>{h&&(d.current=!0,window.MotionIsMounted=!0,h.updateFeatures(),h.scheduleRenderMicrotask(),v.current&&h.animationState&&h.animationState.animateChanges())}),S.useEffect(()=>{h&&(!v.current&&h.animationState&&h.animationState.animateChanges(),v.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(m)}),v.current=!1),h.enteringChildren=void 0)}),h}function Ua(t,e,n,s){const{layoutId:i,layout:o,drag:r,dragConstraints:a,layoutScroll:l,layoutRoot:u,layoutCrossfade:c}=e;t.projection=new n(t.latestValues,e["data-framer-portal-id"]?void 0:ki(t.parent)),t.projection.setOptions({layoutId:i,layout:o,alwaysMeasureLayout:!!r||a&&xt(a),visualElement:t,animationType:typeof o=="string"?o:"both",initialPromotionConfig:s,crossfade:c,layoutScroll:l,layoutRoot:u})}function ki(t){if(t)return t.options.allowProjection!==!1?t.projection:ki(t.parent)}function se(t,{forwardMotionProps:e=!1,type:n}={},s,i){s&&fa(s);const o=n?n==="svg":ln(t),r=o?Ba:Fa;function a(u,c){let h;const f={...S.useContext(xi),...u,layoutId:Wa(u)},{isStatic:d}=f,m=ya(u),v=r(u,d);if(!d&&Be){Ka();const T=Ga(f);h=T.MeasureLayout,m.visualElement=Na(t,v,f,i,T.ProjectionNode,o)}return fe.jsxs(zt.Provider,{value:m,children:[h&&m.visualElement?fe.jsx(h,{visualElement:m.visualElement,...f}):null,Ra(t,u,ja(v,m.visualElement,c),v,d,e,o)]})}a.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const l=S.forwardRef(a);return l[Ia]=t,l}function Wa({layoutId:t}){const e=S.useContext(Ms).id;return e&&t!==void 0?e+"-"+t:t}function Ka(t,e){S.useContext(Pi).strict}function Ga(t){const{drag:e,layout:n}=mt;if(!e&&!n)return{};const s={...e,...n};return{MeasureLayout:e?.isEnabled(t)||n?.isEnabled(t)?s.MeasureLayout:void 0,ProjectionNode:s.ProjectionNode}}function $a(t,e){if(typeof Proxy>"u")return se;const n=new Map,s=(o,r)=>se(o,r,t,e),i=(o,r)=>s(o,r);return new Proxy(i,{get:(o,r)=>r==="create"?s:(n.has(r)||n.set(r,se(r,void 0,t,e)),n.get(r))})}function Fi({top:t,left:e,right:n,bottom:s}){return{x:{min:e,max:n},y:{min:t,max:s}}}function Ha({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}function _a(t,e){if(!e)return t;const n=e({x:t.left,y:t.top}),s=e({x:t.right,y:t.bottom});return{top:n.y,left:n.x,bottom:s.y,right:s.x}}function ie(t){return t===void 0||t===1}function Ce({scale:t,scaleX:e,scaleY:n}){return!ie(t)||!ie(e)||!ie(n)}function nt(t){return Ce(t)||Bi(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function Bi(t){return Nn(t.x)||Nn(t.y)}function Nn(t){return t&&t!=="0%"}function Ht(t,e,n){const s=t-n,i=e*s;return n+i}function Un(t,e,n,s,i){return i!==void 0&&(t=Ht(t,i,s)),Ht(t,n,s)+e}function Me(t,e=0,n=1,s,i){t.min=Un(t.min,e,n,s,i),t.max=Un(t.max,e,n,s,i)}function Ii(t,{x:e,y:n}){Me(t.x,e.translate,e.scale,e.originPoint),Me(t.y,n.translate,n.scale,n.originPoint)}const Wn=.999999999999,Kn=1.0000000000001;function za(t,e,n,s=!1){const i=n.length;if(!i)return;e.x=e.y=1;let o,r;for(let a=0;a<i;a++){o=n[a],r=o.projectionDelta;const{visualElement:l}=o.options;l&&l.props.style&&l.props.style.display==="contents"||(s&&o.options.layoutScroll&&o.scroll&&o!==o.root&&ut(t,{x:-o.scroll.offset.x,y:-o.scroll.offset.y}),r&&(e.x*=r.x.scale,e.y*=r.y.scale,Ii(t,r)),s&&nt(o.latestValues)&&ut(t,o.latestValues))}e.x<Kn&&e.x>Wn&&(e.x=1),e.y<Kn&&e.y>Wn&&(e.y=1)}function ct(t,e){t.min=t.min+e,t.max=t.max+e}function Gn(t,e,n,s,i=.5){const o=C(t.min,t.max,i);Me(t,e,n,o,s)}function ut(t,e){Gn(t.x,e.x,e.scaleX,e.scale,e.originX),Gn(t.y,e.y,e.scaleY,e.scale,e.originY)}function ji(t,e){return Fi(_a(t.getBoundingClientRect(),e))}function Xa(t,e,n){const s=ji(t,n),{scroll:i}=e;return i&&(ct(s.x,i.offset.x),ct(s.y,i.offset.y)),s}const $n=()=>({translate:0,scale:1,origin:0,originPoint:0}),ht=()=>({x:$n(),y:$n()}),Hn=()=>({min:0,max:0}),R=()=>({x:Hn(),y:Hn()}),De={current:null},Oi={current:!1};function Ya(){if(Oi.current=!0,!!Be)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>De.current=t.matches;t.addEventListener("change",e),e()}else De.current=!1}const qa=new WeakMap;function Za(t,e,n){for(const s in e){const i=e[s],o=n[s];if(F(i))t.addValue(s,i);else if(F(o))t.addValue(s,dt(i,{owner:t}));else if(o!==i)if(t.hasValue(s)){const r=t.getValue(s);r.liveStyle===!0?r.jump(i):r.hasAnimated||r.set(i)}else{const r=t.getStaticValue(s);t.addValue(s,dt(r!==void 0?r:i,{owner:t}))}}for(const s in n)e[s]===void 0&&t.removeValue(s);return e}const _n=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class Ja{scrapeMotionValuesFromProps(e,n,s){return{}}constructor({parent:e,props:n,presenceContext:s,reducedMotionConfig:i,blockInitialAnimation:o,visualState:r},a={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=Je,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const f=B.now();this.renderScheduledAt<f&&(this.renderScheduledAt=f,V.render(this.render,!1,!0))};const{latestValues:l,renderState:u}=r;this.latestValues=l,this.baseTarget={...l},this.initialValues=n.initial?{...l}:{},this.renderState=u,this.parent=e,this.props=n,this.presenceContext=s,this.depth=e?e.depth+1:0,this.reducedMotionConfig=i,this.options=a,this.blockInitialAnimation=!!o,this.isControllingVariants=Yt(n),this.isVariantNode=wi(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);const{willChange:c,...h}=this.scrapeMotionValuesFromProps(n,{},this);for(const f in h){const d=h[f];l[f]!==void 0&&F(d)&&d.set(l[f])}}mount(e){this.current=e,qa.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((n,s)=>this.bindToMotionValue(s,n)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(Oi.current||Ya(),this.shouldReduceMotion=De.current),this.parent?.addChild(this),this.update(this.props,this.presenceContext)}unmount(){this.projection&&this.projection.unmount(),Z(this.notifyUpdate),Z(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(const e in this.events)this.events[e].clear();for(const e in this.features){const n=this.features[e];n&&(n.unmount(),n.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,n){this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)();const s=yt.has(e);s&&this.onBindTransform&&this.onBindTransform();const i=n.on("change",r=>{this.latestValues[e]=r,this.props.onUpdate&&V.preRender(this.notifyUpdate),s&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let o;window.MotionCheckAppearSync&&(o=window.MotionCheckAppearSync(this,e,n)),this.valueSubscriptions.set(e,()=>{i(),o&&o(),n.owner&&n.stop()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e="animation";for(e in mt){const n=mt[e];if(!n)continue;const{isEnabled:s,Feature:i}=n;if(!this.features[e]&&i&&s(this.props)&&(this.features[e]=new i(this)),this.features[e]){const o=this.features[e];o.isMounted?o.update():(o.mount(),o.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):R()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,n){this.latestValues[e]=n}update(e,n){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let s=0;s<_n.length;s++){const i=_n[s];this.propEventSubscriptions[i]&&(this.propEventSubscriptions[i](),delete this.propEventSubscriptions[i]);const o="on"+i,r=e[o];r&&(this.propEventSubscriptions[i]=this.on(i,r))}this.prevMotionValues=Za(this,this.scrapeMotionValuesFromProps(e,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(e),()=>n.variantChildren.delete(e)}addValue(e,n){const s=this.values.get(e);n!==s&&(s&&this.removeValue(e),this.bindToMotionValue(e,n),this.values.set(e,n),this.latestValues[e]=n.get())}removeValue(e){this.values.delete(e);const n=this.valueSubscriptions.get(e);n&&(n(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,n){if(this.props.values&&this.props.values[e])return this.props.values[e];let s=this.values.get(e);return s===void 0&&n!==void 0&&(s=dt(n===null?void 0:n,{owner:this}),this.addValue(e,s)),s}readValue(e,n){let s=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return s!=null&&(typeof s=="string"&&(Ds(s)||Rs(s))?s=parseFloat(s):!ua(s)&&J.test(n)&&(s=di(e,n)),this.setBaseTarget(e,F(s)?s.get():s)),F(s)?s.get():s}setBaseTarget(e,n){this.baseTarget[e]=n}getBaseTarget(e){const{initial:n}=this.props;let s;if(typeof n=="string"||typeof n=="object"){const o=cn(this.props,n,this.presenceContext?.custom);o&&(s=o[e])}if(n&&s!==void 0)return s;const i=this.getBaseTargetFromProps(this.props,e);return i!==void 0&&!F(i)?i:this.initialValues[e]!==void 0&&s===void 0?void 0:this.baseTarget[e]}on(e,n){return this.events[e]||(this.events[e]=new We),this.events[e].add(n)}notify(e,...n){this.events[e]&&this.events[e].notify(...n)}scheduleRenderMicrotask(){en.render(this.render)}}class Ni extends Ja{constructor(){super(...arguments),this.KeyframeResolver=Jo}sortInstanceNodePosition(e,n){return e.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(e,n){return e.style?e.style[n]:void 0}removeValueFromRenderState(e,{vars:n,style:s}){delete n[e],delete s[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:e}=this.props;F(e)&&(this.childSubscription=e.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function Ui(t,{style:e,vars:n},s,i){const o=t.style;let r;for(r in e)o[r]=e[r];i?.applyProjectionStyles(o,s);for(r in n)o.setProperty(r,n[r])}function Qa(t){return window.getComputedStyle(t)}class tl extends Ni{constructor(){super(...arguments),this.type="html",this.renderInstance=Ui}readValueFromInstance(e,n){if(yt.has(n))return this.projection?.isProjecting?Te(n):yo(e,n);{const s=Qa(e),i=(Hs(n)?s.getPropertyValue(n):s[n])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(e,{transformPagePoint:n}){return ji(e,n)}build(e,n,s){on(e,n,s.transformTemplate)}scrapeMotionValuesFromProps(e,n,s){return un(e,n,s)}}const Wi=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]);function el(t,e,n,s){Ui(t,e,void 0,s);for(const i in e.attrs)t.setAttribute(Wi.has(i)?i:hn(i),e.attrs[i])}class nl extends Ni{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=R}getBaseTargetFromProps(e,n){return e[n]}readValueFromInstance(e,n){if(yt.has(n)){const s=fi(n);return s&&s.default||0}return n=Wi.has(n)?n:hn(n),e.getAttribute(n)}scrapeMotionValuesFromProps(e,n,s){return Ei(e,n,s)}build(e,n,s){Vi(e,n,this.isSVGTag,s.transformTemplate,s.style)}renderInstance(e,n,s,i){el(e,n,s,i)}mount(e){this.isSVGTag=Mi(e.tagName),super.mount(e)}}const sl=(t,e)=>e.isSVG??ln(t)?new nl(e):new tl(e,{allowProjection:t!==S.Fragment});function ft(t,e,n){const s=t.getProps();return cn(s,e,n!==void 0?n:s.custom,t)}const Ee=t=>Array.isArray(t);function il(t,e,n){t.hasValue(e)?t.getValue(e).set(n):t.addValue(e,dt(n))}function rl(t){return Ee(t)?t[t.length-1]||0:t}function ol(t,e){const n=ft(t,e);let{transitionEnd:s={},transition:i={},...o}=n||{};o={...o,...s};for(const r in o){const a=rl(o[r]);il(t,r,a)}}function al(t){return!!(F(t)&&t.add)}function Re(t,e){const n=t.getValue("willChange");if(al(n))return n.add(e);if(!n&&X.WillChange){const s=new X.WillChange("auto");t.addValue("willChange",s),s.add(e)}}function Ki(t){return t.props[Ri]}const ll=t=>t!==null;function cl(t,{repeat:e,repeatType:n="loop"},s){const i=t.filter(ll),o=e&&n!=="loop"&&e%2===1?0:i.length-1;return i[o]}const ul={type:"spring",stiffness:500,damping:25,restSpeed:10},hl=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),fl={type:"keyframes",duration:.8},dl={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},ml=(t,{keyframes:e})=>e.length>2?fl:yt.has(t)?t.startsWith("scale")?hl(e[1]):ul:dl;function pl({when:t,delay:e,delayChildren:n,staggerChildren:s,staggerDirection:i,repeat:o,repeatType:r,repeatDelay:a,from:l,elapsed:u,...c}){return!!Object.keys(c).length}const fn=(t,e,n,s={},i,o)=>r=>{const a=Qe(s,t)||{},l=a.delay||s.delay||0;let{elapsed:u=0}=s;u=u-z(l);const c={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:e.getVelocity(),...a,delay:-u,onUpdate:f=>{e.set(f),a.onUpdate&&a.onUpdate(f)},onComplete:()=>{r(),a.onComplete&&a.onComplete()},name:t,motionValue:e,element:o?void 0:i};pl(a)||Object.assign(c,ml(t,c)),c.duration&&(c.duration=z(c.duration)),c.repeatDelay&&(c.repeatDelay=z(c.repeatDelay)),c.from!==void 0&&(c.keyframes[0]=c.from);let h=!1;if((c.type===!1||c.duration===0&&!c.repeatDelay)&&(be(c),c.delay===0&&(h=!0)),(X.instantAnimations||X.skipAnimations)&&(h=!0,be(c),c.delay=0),c.allowFlatten=!a.type&&!a.ease,h&&!o&&e.get()!==void 0){const f=cl(c.keyframes,a);if(f!==void 0){V.update(()=>{c.onUpdate(f),c.onComplete()});return}}return a.isSync?new Ze(c):new Uo(c)};function gl({protectedKeys:t,needsAnimating:e},n){const s=t.hasOwnProperty(n)&&e[n]!==!0;return e[n]=!1,s}function Gi(t,e,{delay:n=0,transitionOverride:s,type:i}={}){let{transition:o=t.getDefaultTransition(),transitionEnd:r,...a}=e;s&&(o=s);const l=[],u=i&&t.animationState&&t.animationState.getState()[i];for(const c in a){const h=t.getValue(c,t.latestValues[c]??null),f=a[c];if(f===void 0||u&&gl(u,c))continue;const d={delay:n,...Qe(o||{},c)},m=h.get();if(m!==void 0&&!h.isAnimating&&!Array.isArray(f)&&f===m&&!d.velocity)continue;let v=!1;if(window.MotionHandoffAnimation){const g=Ki(t);if(g){const x=window.MotionHandoffAnimation(g,c,V);x!==null&&(d.startTime=x,v=!0)}}Re(t,c),h.start(fn(c,h,f,t.shouldReduceMotion&&ci.has(c)?{type:!1}:d,t,v));const T=h.animation;T&&l.push(T)}return r&&Promise.all(l).then(()=>{V.update(()=>{r&&ol(t,r)})}),l}function $i(t,e,n,s=0,i=1){const o=Array.from(t).sort((u,c)=>u.sortNodePosition(c)).indexOf(e),r=t.size,a=(r-1)*s;return typeof n=="function"?n(o,r):i===1?o*s:a-o*s}function Le(t,e,n={}){const s=ft(t,e,n.type==="exit"?t.presenceContext?.custom:void 0);let{transition:i=t.getDefaultTransition()||{}}=s||{};n.transitionOverride&&(i=n.transitionOverride);const o=s?()=>Promise.all(Gi(t,s,n)):()=>Promise.resolve(),r=t.variantChildren&&t.variantChildren.size?(l=0)=>{const{delayChildren:u=0,staggerChildren:c,staggerDirection:h}=i;return yl(t,e,l,u,c,h,n)}:()=>Promise.resolve(),{when:a}=i;if(a){const[l,u]=a==="beforeChildren"?[o,r]:[r,o];return l().then(()=>u())}else return Promise.all([o(),r(n.delay)])}function yl(t,e,n=0,s=0,i=0,o=1,r){const a=[];for(const l of t.variantChildren)l.notify("AnimationStart",e),a.push(Le(l,e,{...r,delay:n+(typeof s=="function"?0:s)+$i(t.variantChildren,l,s,i,o)}).then(()=>l.notify("AnimationComplete",e)));return Promise.all(a)}function vl(t,e,n={}){t.notify("AnimationStart",e);let s;if(Array.isArray(e)){const i=e.map(o=>Le(t,o,n));s=Promise.all(i)}else if(typeof e=="string")s=Le(t,e,n);else{const i=typeof e=="function"?ft(t,e,n.custom):e;s=Promise.all(Gi(t,i,n))}return s.then(()=>{t.notify("AnimationComplete",e)})}function Hi(t,e){if(!Array.isArray(e))return!1;const n=e.length;if(n!==t.length)return!1;for(let s=0;s<n;s++)if(e[s]!==t[s])return!1;return!0}const Tl=rn.length;function _i(t){if(!t)return;if(!t.isControllingVariants){const n=t.parent?_i(t.parent)||{}:{};return t.props.initial!==void 0&&(n.initial=t.props.initial),n}const e={};for(let n=0;n<Tl;n++){const s=rn[n],i=t.props[s];(Mt(i)||i===!1)&&(e[s]=i)}return e}const xl=[...sn].reverse(),Pl=sn.length;function Sl(t){return e=>Promise.all(e.map(({animation:n,options:s})=>vl(t,n,s)))}function wl(t){let e=Sl(t),n=zn(),s=!0;const i=l=>(u,c)=>{const h=ft(t,c,l==="exit"?t.presenceContext?.custom:void 0);if(h){const{transition:f,transitionEnd:d,...m}=h;u={...u,...m,...d}}return u};function o(l){e=l(t)}function r(l){const{props:u}=t,c=_i(t.parent)||{},h=[],f=new Set;let d={},m=1/0;for(let T=0;T<Pl;T++){const g=xl[T],x=n[g],y=u[g]!==void 0?u[g]:c[g],b=Mt(y),P=g===l?x.isActive:null;P===!1&&(m=T);let A=y===c[g]&&y!==u[g]&&b;if(A&&s&&t.manuallyAnimateOnMount&&(A=!1),x.protectedKeys={...d},!x.isActive&&P===null||!y&&!x.prevProp||Xt(y)||typeof y=="boolean")continue;const E=bl(x.prevProp,y);let w=E||g===l&&x.isActive&&!A&&b||T>m&&b,j=!1;const O=Array.isArray(y)?y:[y];let ot=O.reduce(i(g),{});P===!1&&(ot={});const{prevResolvedValues:dn={}}=x,ar={...dn,...ot},mn=L=>{w=!0,f.has(L)&&(j=!0,f.delete(L)),x.needsAnimating[L]=!0;const N=t.getValue(L);N&&(N.liveStyle=!1)};for(const L in ar){const N=ot[L],tt=dn[L];if(d.hasOwnProperty(L))continue;let at=!1;Ee(N)&&Ee(tt)?at=!Hi(N,tt):at=N!==tt,at?N!=null?mn(L):f.add(L):N!==void 0&&f.has(L)?mn(L):x.protectedKeys[L]=!0}x.prevProp=y,x.prevResolvedValues=ot,x.isActive&&(d={...d,...ot}),s&&t.blockInitialAnimation&&(w=!1);const pn=A&&E;w&&(!pn||j)&&h.push(...O.map(L=>{const N={type:g};if(typeof L=="string"&&s&&!pn&&t.manuallyAnimateOnMount&&t.parent){const{parent:tt}=t,at=ft(tt,L);if(tt.enteringChildren&&at){const{delayChildren:lr}=at.transition||{};N.delay=$i(tt.enteringChildren,t,lr)}}return{animation:L,options:N}}))}if(f.size){const T={};if(typeof u.initial!="boolean"){const g=ft(t,Array.isArray(u.initial)?u.initial[0]:u.initial);g&&g.transition&&(T.transition=g.transition)}f.forEach(g=>{const x=t.getBaseTarget(g),y=t.getValue(g);y&&(y.liveStyle=!0),T[g]=x??null}),h.push({animation:T})}let v=!!h.length;return s&&(u.initial===!1||u.initial===u.animate)&&!t.manuallyAnimateOnMount&&(v=!1),s=!1,v?e(h):Promise.resolve()}function a(l,u){if(n[l].isActive===u)return Promise.resolve();t.variantChildren?.forEach(h=>h.animationState?.setActive(l,u)),n[l].isActive=u;const c=r(l);for(const h in n)n[h].protectedKeys={};return c}return{animateChanges:r,setActive:a,setAnimateFunction:o,getState:()=>n,reset:()=>{n=zn()}}}function bl(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!Hi(e,t):!1}function et(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function zn(){return{animate:et(!0),whileInView:et(),whileHover:et(),whileTap:et(),whileDrag:et(),whileFocus:et(),exit:et()}}class Q{constructor(e){this.isMounted=!1,this.node=e}update(){}}class Al extends Q{constructor(e){super(e),e.animationState||(e.animationState=wl(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();Xt(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:e}=this.node.getProps(),{animate:n}=this.node.prevProps||{};e!==n&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}let Vl=0;class Cl extends Q{constructor(){super(...arguments),this.id=Vl++}update(){if(!this.node.presenceContext)return;const{isPresent:e,onExitComplete:n}=this.node.presenceContext,{isPresent:s}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===s)return;const i=this.node.animationState.setActive("exit",!e);n&&!e&&i.then(()=>{n(this.id)})}mount(){const{register:e,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),e&&(this.unmount=e(this.id))}unmount(){}}const Ml={animation:{Feature:Al},exit:{Feature:Cl}};function Dt(t,e,n,s={passive:!0}){return t.addEventListener(e,n,s),()=>t.removeEventListener(e,n)}function kt(t){return{point:{x:t.pageX,y:t.pageY}}}const Dl=t=>e=>nn(e)&&t(e,kt(e));function wt(t,e,n,s){return Dt(t,e,Dl(n),s)}const zi=1e-4,El=1-zi,Rl=1+zi,Xi=.01,Ll=0-Xi,kl=0+Xi;function I(t){return t.max-t.min}function Fl(t,e,n){return Math.abs(t-e)<=n}function Xn(t,e,n,s=.5){t.origin=s,t.originPoint=C(e.min,e.max,t.origin),t.scale=I(n)/I(e),t.translate=C(n.min,n.max,t.origin)-t.originPoint,(t.scale>=El&&t.scale<=Rl||isNaN(t.scale))&&(t.scale=1),(t.translate>=Ll&&t.translate<=kl||isNaN(t.translate))&&(t.translate=0)}function bt(t,e,n,s){Xn(t.x,e.x,n.x,s?s.originX:void 0),Xn(t.y,e.y,n.y,s?s.originY:void 0)}function Yn(t,e,n){t.min=n.min+e.min,t.max=t.min+I(e)}function Bl(t,e,n){Yn(t.x,e.x,n.x),Yn(t.y,e.y,n.y)}function qn(t,e,n){t.min=e.min-n.min,t.max=t.min+I(e)}function _t(t,e,n){qn(t.x,e.x,n.x),qn(t.y,e.y,n.y)}function U(t){return[t("x"),t("y")]}const Yi=({current:t})=>t?t.ownerDocument.defaultView:null,Zn=(t,e)=>Math.abs(t-e);function Il(t,e){const n=Zn(t.x,e.x),s=Zn(t.y,e.y);return Math.sqrt(n**2+s**2)}const Jn=new Set(["auto","scroll"]);class qi{constructor(e,n,{transformPagePoint:s,contextWindow:i=window,dragSnapToOrigin:o=!1,distanceThreshold:r=3,element:a}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=d=>{this.handleScroll(d.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const d=oe(this.lastMoveEventInfo,this.history),m=this.startEvent!==null,v=Il(d.offset,{x:0,y:0})>=this.distanceThreshold;if(!m&&!v)return;const{point:T}=d,{timestamp:g}=k;this.history.push({...T,timestamp:g});const{onStart:x,onMove:y}=this.handlers;m||(x&&x(this.lastMoveEvent,d),this.startEvent=this.lastMoveEvent),y&&y(this.lastMoveEvent,d)},this.handlePointerMove=(d,m)=>{this.lastMoveEvent=d,this.lastMoveEventInfo=re(m,this.transformPagePoint),V.update(this.updatePoint,!0)},this.handlePointerUp=(d,m)=>{this.end();const{onEnd:v,onSessionEnd:T,resumeAnimation:g}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&g&&g(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const x=oe(d.type==="pointercancel"?this.lastMoveEventInfo:re(m,this.transformPagePoint),this.history);this.startEvent&&v&&v(d,x),T&&T(d,x)},!nn(e))return;this.dragSnapToOrigin=o,this.handlers=n,this.transformPagePoint=s,this.distanceThreshold=r,this.contextWindow=i||window;const l=kt(e),u=re(l,this.transformPagePoint),{point:c}=u,{timestamp:h}=k;this.history=[{...c,timestamp:h}];const{onSessionStart:f}=n;f&&f(e,oe(u,this.history)),this.removeListeners=Et(wt(this.contextWindow,"pointermove",this.handlePointerMove),wt(this.contextWindow,"pointerup",this.handlePointerUp),wt(this.contextWindow,"pointercancel",this.handlePointerUp)),a&&this.startScrollTracking(a)}startScrollTracking(e){let n=e.parentElement;for(;n;){const s=getComputedStyle(n);(Jn.has(s.overflowX)||Jn.has(s.overflowY))&&this.scrollPositions.set(n,{x:n.scrollLeft,y:n.scrollTop}),n=n.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0,passive:!0}),window.addEventListener("scroll",this.onWindowScroll,{passive:!0}),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(e){const n=this.scrollPositions.get(e);if(!n)return;const s=e===window,i=s?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},o={x:i.x-n.x,y:i.y-n.y};o.x===0&&o.y===0||(s?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=o.x,this.lastMoveEventInfo.point.y+=o.y):this.history.length>0&&(this.history[0].x-=o.x,this.history[0].y-=o.y),this.scrollPositions.set(e,i),V.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),Z(this.updatePoint)}}function re(t,e){return e?{point:e(t.point)}:t}function Qn(t,e){return{x:t.x-e.x,y:t.y-e.y}}function oe({point:t},e){return{point:t,delta:Qn(t,Zi(e)),offset:Qn(t,jl(e)),velocity:Ol(e,.1)}}function jl(t){return t[0]}function Zi(t){return t[t.length-1]}function Ol(t,e){if(t.length<2)return{x:0,y:0};let n=t.length-1,s=null;const i=Zi(t);for(;n>=0&&(s=t[n],!(i.timestamp-s.timestamp>z(e)));)n--;if(!s)return{x:0,y:0};const o=W(i.timestamp-s.timestamp);if(o===0)return{x:0,y:0};const r={x:(i.x-s.x)/o,y:(i.y-s.y)/o};return r.x===1/0&&(r.x=0),r.y===1/0&&(r.y=0),r}function Nl(t,{min:e,max:n},s){return e!==void 0&&t<e?t=s?C(e,t,s.min):Math.max(t,e):n!==void 0&&t>n&&(t=s?C(n,t,s.max):Math.min(t,n)),t}function ts(t,e,n){return{min:e!==void 0?t.min+e:void 0,max:n!==void 0?t.max+n-(t.max-t.min):void 0}}function Ul(t,{top:e,left:n,bottom:s,right:i}){return{x:ts(t.x,n,i),y:ts(t.y,e,s)}}function es(t,e){let n=e.min-t.min,s=e.max-t.max;return e.max-e.min<t.max-t.min&&([n,s]=[s,n]),{min:n,max:s}}function Wl(t,e){return{x:es(t.x,e.x),y:es(t.y,e.y)}}function Kl(t,e){let n=.5;const s=I(t),i=I(e);return i>s?n=At(e.min,e.max-s,t.min):s>i&&(n=At(t.min,t.max-i,e.min)),_(0,1,n)}function Gl(t,e){const n={};return e.min!==void 0&&(n.min=e.min-t.min),e.max!==void 0&&(n.max=e.max-t.min),n}const ke=.35;function $l(t=ke){return t===!1?t=0:t===!0&&(t=ke),{x:ns(t,"left","right"),y:ns(t,"top","bottom")}}function ns(t,e,n){return{min:ss(t,e),max:ss(t,n)}}function ss(t,e){return typeof t=="number"?t:t[e]||0}const Hl=new WeakMap;class _l{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=R(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:n=!1,distanceThreshold:s}={}){const{presenceContext:i}=this.visualElement;if(i&&i.isPresent===!1)return;const o=h=>{n?(this.stopAnimation(),this.snapToCursor(kt(h).point)):this.pauseAnimation()},r=(h,f)=>{this.stopAnimation();const{drag:d,dragPropagation:m,onDragStart:v}=this.getProps();if(d&&!m&&(this.openDragLock&&this.openDragLock(),this.openDragLock=sa(d),!this.openDragLock))return;this.latestPointerEvent=h,this.latestPanInfo=f,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),U(g=>{let x=this.getAxisMotionValue(g).get()||0;if(H.test(x)){const{projection:y}=this.visualElement;if(y&&y.layout){const b=y.layout.layoutBox[g];b&&(x=I(b)*(parseFloat(x)/100))}}this.originPoint[g]=x}),v&&V.postRender(()=>v(h,f)),Re(this.visualElement,"transform");const{animationState:T}=this.visualElement;T&&T.setActive("whileDrag",!0)},a=(h,f)=>{this.latestPointerEvent=h,this.latestPanInfo=f;const{dragPropagation:d,dragDirectionLock:m,onDirectionLock:v,onDrag:T}=this.getProps();if(!d&&!this.openDragLock)return;const{offset:g}=f;if(m&&this.currentDirection===null){this.currentDirection=zl(g),this.currentDirection!==null&&v&&v(this.currentDirection);return}this.updateAxis("x",f.point,g),this.updateAxis("y",f.point,g),this.visualElement.render(),T&&T(h,f)},l=(h,f)=>{this.latestPointerEvent=h,this.latestPanInfo=f,this.stop(h,f),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>U(h=>this.getAnimationState(h)==="paused"&&this.getAxisMotionValue(h).animation?.play()),{dragSnapToOrigin:c}=this.getProps();this.panSession=new qi(e,{onSessionStart:o,onStart:r,onMove:a,onSessionEnd:l,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:c,distanceThreshold:s,contextWindow:Yi(this.visualElement),element:this.visualElement.current})}stop(e,n){const s=e||this.latestPointerEvent,i=n||this.latestPanInfo,o=this.isDragging;if(this.cancel(),!o||!i||!s)return;const{velocity:r}=i;this.startAnimation(r);const{onDragEnd:a}=this.getProps();a&&V.postRender(()=>a(s,i))}cancel(){this.isDragging=!1;const{projection:e,animationState:n}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;const{dragPropagation:s}=this.getProps();!s&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}updateAxis(e,n,s){const{drag:i}=this.getProps();if(!s||!It(e,i,this.currentDirection))return;const o=this.getAxisMotionValue(e);let r=this.originPoint[e]+s[e];this.constraints&&this.constraints[e]&&(r=Nl(r,this.constraints[e],this.elastic[e])),o.set(r)}resolveConstraints(){const{dragConstraints:e,dragElastic:n}=this.getProps(),s=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,i=this.constraints;e&&xt(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&s?this.constraints=Ul(s.layoutBox,e):this.constraints=!1,this.elastic=$l(n),i!==this.constraints&&s&&this.constraints&&!this.hasMutatedConstraints&&U(o=>{this.constraints!==!1&&this.getAxisMotionValue(o)&&(this.constraints[o]=Gl(s.layoutBox[o],this.constraints[o]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:n}=this.getProps();if(!e||!xt(e))return!1;const s=e.current,{projection:i}=this.visualElement;if(!i||!i.layout)return!1;const o=Xa(s,i.root,this.visualElement.getTransformPagePoint());let r=Wl(i.layout.layoutBox,o);if(n){const a=n(Ha(r));this.hasMutatedConstraints=!!a,a&&(r=Fi(a))}return r}startAnimation(e){const{drag:n,dragMomentum:s,dragElastic:i,dragTransition:o,dragSnapToOrigin:r,onDragTransitionEnd:a}=this.getProps(),l=this.constraints||{},u=U(c=>{if(!It(c,n,this.currentDirection))return;let h=l&&l[c]||{};r&&(h={min:0,max:0});const f=i?200:1e6,d=i?40:1e7,m={type:"inertia",velocity:s?e[c]:0,bounceStiffness:f,bounceDamping:d,timeConstant:750,restDelta:1,restSpeed:10,...o,...h};return this.startAxisValueAnimation(c,m)});return Promise.all(u).then(a)}startAxisValueAnimation(e,n){const s=this.getAxisMotionValue(e);return Re(this.visualElement,e),s.start(fn(e,s,0,n,this.visualElement,!1))}stopAnimation(){U(e=>this.getAxisMotionValue(e).stop())}pauseAnimation(){U(e=>this.getAxisMotionValue(e).animation?.pause())}getAnimationState(e){return this.getAxisMotionValue(e).animation?.state}getAxisMotionValue(e){const n=`_drag${e.toUpperCase()}`,s=this.visualElement.getProps(),i=s[n];return i||this.visualElement.getValue(e,(s.initial?s.initial[e]:void 0)||0)}snapToCursor(e){U(n=>{const{drag:s}=this.getProps();if(!It(n,s,this.currentDirection))return;const{projection:i}=this.visualElement,o=this.getAxisMotionValue(n);if(i&&i.layout){const{min:r,max:a}=i.layout.layoutBox[n],l=o.get()||0;o.set(e[n]-C(r,a,.5)+l)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:n}=this.getProps(),{projection:s}=this.visualElement;if(!xt(n)||!s||!this.constraints)return;this.stopAnimation();const i={x:0,y:0};U(r=>{const a=this.getAxisMotionValue(r);if(a&&this.constraints!==!1){const l=a.get();i[r]=Kl({min:l,max:l},this.constraints[r])}});const{transformTemplate:o}=this.visualElement.getProps();this.visualElement.current.style.transform=o?o({},""):"none",s.root&&s.root.updateScroll(),s.updateLayout(),this.resolveConstraints(),U(r=>{if(!It(r,e,null))return;const a=this.getAxisMotionValue(r),{min:l,max:u}=this.constraints[r];a.set(C(l,u,i[r]))})}addListeners(){if(!this.visualElement.current)return;Hl.set(this.visualElement,this);const e=this.visualElement.current,n=wt(e,"pointerdown",l=>{const{drag:u,dragListener:c=!0}=this.getProps();u&&c&&!vi(l.target)&&this.start(l)}),s=()=>{const{dragConstraints:l}=this.getProps();xt(l)&&l.current&&(this.constraints=this.resolveRefConstraints())},{projection:i}=this.visualElement,o=i.addEventListener("measure",s);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),V.read(s);const r=Dt(window,"resize",()=>this.scalePositionWithinConstraints()),a=i.addEventListener("didUpdate",(({delta:l,hasLayoutChanged:u})=>{this.isDragging&&u&&(U(c=>{const h=this.getAxisMotionValue(c);h&&(this.originPoint[c]+=l[c].translate,h.set(h.get()+l[c].translate))}),this.visualElement.render())}));return()=>{r(),n(),o(),a&&a()}}getProps(){const e=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:s=!1,dragPropagation:i=!1,dragConstraints:o=!1,dragElastic:r=ke,dragMomentum:a=!0}=e;return{...e,drag:n,dragDirectionLock:s,dragPropagation:i,dragConstraints:o,dragElastic:r,dragMomentum:a}}}function It(t,e,n){return(e===!0||e===t)&&(n===null||n===t)}function zl(t,e=10){let n=null;return Math.abs(t.y)>e?n="y":Math.abs(t.x)>e&&(n="x"),n}class Xl extends Q{constructor(e){super(e),this.removeGroupControls=K,this.removeListeners=K,this.controls=new _l(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||K}update(){const{dragControls:e}=this.node.getProps(),{dragControls:n}=this.node.prevProps||{};e!==n&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners()}}const is=t=>(e,n)=>{t&&V.postRender(()=>t(e,n))};class Yl extends Q{constructor(){super(...arguments),this.removePointerDownListener=K}onPointerDown(e){this.session=new qi(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Yi(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:n,onPan:s,onPanEnd:i}=this.node.getProps();return{onSessionStart:is(e),onStart:is(n),onMove:s,onEnd:(o,r)=>{delete this.session,i&&V.postRender(()=>i(o,r))}}}mount(){this.removePointerDownListener=wt(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}const Ut={hasAnimatedSinceResize:!0,hasEverUpdated:!1};let ae=!1;class ql extends S.Component{componentDidMount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:s,layoutId:i}=this.props,{projection:o}=e;o&&(n.group&&n.group.add(o),s&&s.register&&i&&s.register(o),ae&&o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,onExitComplete:()=>this.safeToRemove()})),Ut.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:n,visualElement:s,drag:i,isPresent:o}=this.props,{projection:r}=s;return r&&(r.isPresent=o,ae=!0,i||e.layoutDependency!==n||n===void 0||e.isPresent!==o?r.willUpdate():this.safeToRemove(),e.isPresent!==o&&(o?r.promote():r.relegate()||V.postRender(()=>{const a=r.getStack();(!a||!a.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),en.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:i}=e;ae=!0,i&&(i.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(i),s&&s.deregister&&s.deregister(i))}safeToRemove(){const{safeToRemove:e}=this.props;e&&e()}render(){return null}}function Ji(t){const[e,n]=ha(),s=S.useContext(Ms);return fe.jsx(ql,{...t,layoutGroup:s,switchLayoutGroup:S.useContext(Li),isPresent:e,safeToRemove:n})}function Zl(t,e,n){const s=F(t)?t:dt(t);return s.start(fn("",s,e,n)),s.animation}const Jl=(t,e)=>t.depth-e.depth;class Ql{constructor(){this.children=[],this.isDirty=!1}add(e){je(this.children,e),this.isDirty=!0}remove(e){Oe(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(Jl),this.isDirty=!1,this.children.forEach(e)}}function tc(t,e){const n=B.now(),s=({timestamp:i})=>{const o=i-n;o>=e&&(Z(s),t(o-e))};return V.setup(s,!0),()=>Z(s)}const Qi=["TopLeft","TopRight","BottomLeft","BottomRight"],ec=Qi.length,rs=t=>typeof t=="string"?parseFloat(t):t,os=t=>typeof t=="number"||p.test(t);function nc(t,e,n,s,i,o){i?(t.opacity=C(0,n.opacity??1,sc(s)),t.opacityExit=C(e.opacity??1,0,ic(s))):o&&(t.opacity=C(e.opacity??1,n.opacity??1,s));for(let r=0;r<ec;r++){const a=`border${Qi[r]}Radius`;let l=as(e,a),u=as(n,a);if(l===void 0&&u===void 0)continue;l||(l=0),u||(u=0),l===0||u===0||os(l)===os(u)?(t[a]=Math.max(C(rs(l),rs(u),s),0),(H.test(u)||H.test(l))&&(t[a]+="%")):t[a]=u}(e.rotate||n.rotate)&&(t.rotate=C(e.rotate||0,n.rotate||0,s))}function as(t,e){return t[e]!==void 0?t[e]:t.borderRadius}const sc=tr(0,.5,Ns),ic=tr(.5,.95,K);function tr(t,e,n){return s=>s<t?0:s>e?1:n(At(t,e,s))}function ls(t,e){t.min=e.min,t.max=e.max}function G(t,e){ls(t.x,e.x),ls(t.y,e.y)}function cs(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}function us(t,e,n,s,i){return t-=e,t=Ht(t,1/n,s),i!==void 0&&(t=Ht(t,1/i,s)),t}function rc(t,e=0,n=1,s=.5,i,o=t,r=t){if(H.test(e)&&(e=parseFloat(e),e=C(r.min,r.max,e/100)-r.min),typeof e!="number")return;let a=C(o.min,o.max,s);t===o&&(a-=e),t.min=us(t.min,e,n,a,i),t.max=us(t.max,e,n,a,i)}function hs(t,e,[n,s,i],o,r){rc(t,e[n],e[s],e[i],e.scale,o,r)}const oc=["x","scaleX","originX"],ac=["y","scaleY","originY"];function fs(t,e,n,s){hs(t.x,e,oc,n?n.x:void 0,s?s.x:void 0),hs(t.y,e,ac,n?n.y:void 0,s?s.y:void 0)}function ds(t){return t.translate===0&&t.scale===1}function er(t){return ds(t.x)&&ds(t.y)}function ms(t,e){return t.min===e.min&&t.max===e.max}function lc(t,e){return ms(t.x,e.x)&&ms(t.y,e.y)}function ps(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function nr(t,e){return ps(t.x,e.x)&&ps(t.y,e.y)}function gs(t){return I(t.x)/I(t.y)}function ys(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}class cc{constructor(){this.members=[]}add(e){je(this.members,e),e.scheduleRender()}remove(e){if(Oe(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(e){const n=this.members.findIndex(i=>e===i);if(n===0)return!1;let s;for(let i=n;i>=0;i--){const o=this.members[i];if(o.isPresent!==!1){s=o;break}}return s?(this.promote(s),!0):!1}promote(e,n){const s=this.lead;if(e!==s&&(this.prevLead=s,this.lead=e,e.show(),s)){s.instance&&s.scheduleRender(),e.scheduleRender(),e.resumeFrom=s,n&&(e.resumeFrom.preserveOpacity=!0),s.snapshot&&(e.snapshot=s.snapshot,e.snapshot.latestValues=s.animationValues||s.latestValues),e.root&&e.root.isUpdating&&(e.isLayoutDirty=!0);const{crossfade:i}=e.options;i===!1&&s.hide()}}exitAnimationComplete(){this.members.forEach(e=>{const{options:n,resumingFrom:s}=e;n.onExitComplete&&n.onExitComplete(),s&&s.options.onExitComplete&&s.options.onExitComplete()})}scheduleRender(){this.members.forEach(e=>{e.instance&&e.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function uc(t,e,n){let s="";const i=t.x.translate/e.x,o=t.y.translate/e.y,r=n?.z||0;if((i||o||r)&&(s=`translate3d(${i}px, ${o}px, ${r}px) `),(e.x!==1||e.y!==1)&&(s+=`scale(${1/e.x}, ${1/e.y}) `),n){const{transformPerspective:u,rotate:c,rotateX:h,rotateY:f,skewX:d,skewY:m}=n;u&&(s=`perspective(${u}px) ${s}`),c&&(s+=`rotate(${c}deg) `),h&&(s+=`rotateX(${h}deg) `),f&&(s+=`rotateY(${f}deg) `),d&&(s+=`skewX(${d}deg) `),m&&(s+=`skewY(${m}deg) `)}const a=t.x.scale*e.x,l=t.y.scale*e.y;return(a!==1||l!==1)&&(s+=`scale(${a}, ${l})`),s||"none"}const le=["","X","Y","Z"],hc=1e3;let fc=0;function ce(t,e,n,s){const{latestValues:i}=e;i[t]&&(n[t]=i[t],e.setStaticValue(t,0),s&&(s[t]=0))}function sr(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const n=Ki(e);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:i,layoutId:o}=t.options;window.MotionCancelOptimisedAnimation(n,"transform",V,!(i||o))}const{parent:s}=t;s&&!s.hasCheckedOptimisedAppear&&sr(s)}function ir({attachResizeListener:t,defaultParent:e,measureScroll:n,checkIsScrollRoot:s,resetTransform:i}){return class{constructor(r={},a=e?.()){this.id=fc++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(pc),this.nodes.forEach(Tc),this.nodes.forEach(xc),this.nodes.forEach(gc)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=r,this.root=a?a.root||a:this,this.path=a?[...a.path,a]:[],this.parent=a,this.depth=a?a.depth+1:0;for(let l=0;l<this.path.length;l++)this.path[l].shouldResetTransform=!0;this.root===this&&(this.nodes=new Ql)}addEventListener(r,a){return this.eventHandlers.has(r)||this.eventHandlers.set(r,new We),this.eventHandlers.get(r).add(a)}notifyListeners(r,...a){const l=this.eventHandlers.get(r);l&&l.notify(...a)}hasListeners(r){return this.eventHandlers.has(r)}mount(r){if(this.instance)return;this.isSVG=Ti(r)&&!la(r),this.instance=r;const{layoutId:a,layout:l,visualElement:u}=this.options;if(u&&!u.current&&u.mount(r),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(l||a)&&(this.isLayoutDirty=!0),t){let c,h=0;const f=()=>this.root.updateBlockedByResize=!1;V.read(()=>{h=window.innerWidth}),t(r,()=>{const d=window.innerWidth;d!==h&&(h=d,this.root.updateBlockedByResize=!0,c&&c(),c=tc(f,250),Ut.hasAnimatedSinceResize&&(Ut.hasAnimatedSinceResize=!1,this.nodes.forEach(xs)))})}a&&this.root.registerSharedNode(a,this),this.options.animate!==!1&&u&&(a||l)&&this.addEventListener("didUpdate",({delta:c,hasLayoutChanged:h,hasRelativeLayoutChanged:f,layout:d})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const m=this.options.transition||u.getDefaultTransition()||Ac,{onLayoutAnimationStart:v,onLayoutAnimationComplete:T}=u.getProps(),g=!this.targetLayout||!nr(this.targetLayout,d),x=!h&&f;if(this.options.layoutRoot||this.resumeFrom||x||h&&(g||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const y={...Qe(m,"layout"),onPlay:v,onComplete:T};(u.shouldReduceMotion||this.options.layoutRoot)&&(y.delay=0,y.type=!1),this.startAnimation(y),this.setAnimationOrigin(c,x)}else h||xs(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=d})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const r=this.getStack();r&&r.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),Z(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(Pc),this.animationId++)}getTransformTemplate(){const{visualElement:r}=this.options;return r&&r.getProps().transformTemplate}willUpdate(r=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&sr(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let c=0;c<this.path.length;c++){const h=this.path[c];h.shouldResetTransform=!0,h.updateScroll("snapshot"),h.options.layoutRoot&&h.willUpdate(!1)}const{layoutId:a,layout:l}=this.options;if(a===void 0&&!l)return;const u=this.getTransformTemplate();this.prevTransformTemplateValue=u?u(this.latestValues,""):void 0,this.updateSnapshot(),r&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(vs);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(Ts);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(vc),this.nodes.forEach(dc),this.nodes.forEach(mc)):this.nodes.forEach(Ts),this.clearAllSnapshots();const a=B.now();k.delta=_(0,1e3/60,a-k.timestamp),k.timestamp=a,k.isProcessing=!0,qt.update.process(k),qt.preRender.process(k),qt.render.process(k),k.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,en.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(yc),this.sharedNodes.forEach(Sc)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,V.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){V.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!I(this.snapshot.measuredBox.x)&&!I(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let l=0;l<this.path.length;l++)this.path[l].updateScroll();const r=this.layout;this.layout=this.measure(!1),this.layoutVersion++,this.layoutCorrected=R(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:a}=this.options;a&&a.notify("LayoutMeasure",this.layout.layoutBox,r?r.layoutBox:void 0)}updateScroll(r="measure"){let a=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===r&&(a=!1),a&&this.instance){const l=s(this.instance);this.scroll={animationId:this.root.animationId,phase:r,isRoot:l,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:l}}}resetTransform(){if(!i)return;const r=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,a=this.projectionDelta&&!er(this.projectionDelta),l=this.getTransformTemplate(),u=l?l(this.latestValues,""):void 0,c=u!==this.prevTransformTemplateValue;r&&this.instance&&(a||nt(this.latestValues)||c)&&(i(this.instance,u),this.shouldResetTransform=!1,this.scheduleRender())}measure(r=!0){const a=this.measurePageBox();let l=this.removeElementScroll(a);return r&&(l=this.removeTransform(l)),Vc(l),{animationId:this.root.animationId,measuredBox:a,layoutBox:l,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:r}=this.options;if(!r)return R();const a=r.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(Cc))){const{scroll:u}=this.root;u&&(ct(a.x,u.offset.x),ct(a.y,u.offset.y))}return a}removeElementScroll(r){const a=R();if(G(a,r),this.scroll?.wasRoot)return a;for(let l=0;l<this.path.length;l++){const u=this.path[l],{scroll:c,options:h}=u;u!==this.root&&c&&h.layoutScroll&&(c.wasRoot&&G(a,r),ct(a.x,c.offset.x),ct(a.y,c.offset.y))}return a}applyTransform(r,a=!1){const l=R();G(l,r);for(let u=0;u<this.path.length;u++){const c=this.path[u];!a&&c.options.layoutScroll&&c.scroll&&c!==c.root&&ut(l,{x:-c.scroll.offset.x,y:-c.scroll.offset.y}),nt(c.latestValues)&&ut(l,c.latestValues)}return nt(this.latestValues)&&ut(l,this.latestValues),l}removeTransform(r){const a=R();G(a,r);for(let l=0;l<this.path.length;l++){const u=this.path[l];if(!u.instance||!nt(u.latestValues))continue;Ce(u.latestValues)&&u.updateSnapshot();const c=R(),h=u.measurePageBox();G(c,h),fs(a,u.latestValues,u.snapshot?u.snapshot.layoutBox:void 0,c)}return nt(this.latestValues)&&fs(a,this.latestValues),a}setTargetDelta(r){this.targetDelta=r,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(r){this.options={...this.options,...r,crossfade:r.crossfade!==void 0?r.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==k.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(r=!1){const a=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=a.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=a.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=a.isSharedProjectionDirty);const l=!!this.resumingFrom||this!==a;if(!(r||l&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:c,layoutId:h}=this.options;if(!this.layout||!(c||h))return;this.resolvedRelativeTargetAt=k.timestamp;const f=this.getClosestProjectingParent();f&&this.linkedParentVersion!==f.layoutVersion&&!f.options.layoutRoot&&this.removeRelativeTarget(),!this.targetDelta&&!this.relativeTarget&&(f&&f.layout?this.createRelativeTarget(f,this.layout.layoutBox,f.layout.layoutBox):this.removeRelativeTarget()),!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=R(),this.targetWithTransforms=R()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),Bl(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):G(this.target,this.layout.layoutBox),Ii(this.target,this.targetDelta)):G(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,f&&!!f.resumingFrom==!!this.resumingFrom&&!f.options.layoutScroll&&f.target&&this.animationProgress!==1?this.createRelativeTarget(f,this.target,f.target):this.relativeParent=this.relativeTarget=void 0))}getClosestProjectingParent(){if(!(!this.parent||Ce(this.parent.latestValues)||Bi(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(r,a,l){this.relativeParent=r,this.linkedParentVersion=r.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=R(),this.relativeTargetOrigin=R(),_t(this.relativeTargetOrigin,a,l),G(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){const r=this.getLead(),a=!!this.resumingFrom||this!==r;let l=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(l=!1),a&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(l=!1),this.resolvedRelativeTargetAt===k.timestamp&&(l=!1),l)return;const{layout:u,layoutId:c}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(u||c))return;G(this.layoutCorrected,this.layout.layoutBox);const h=this.treeScale.x,f=this.treeScale.y;za(this.layoutCorrected,this.treeScale,this.path,a),r.layout&&!r.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(r.target=r.layout.layoutBox,r.targetWithTransforms=R());const{target:d}=r;if(!d){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(cs(this.prevProjectionDelta.x,this.projectionDelta.x),cs(this.prevProjectionDelta.y,this.projectionDelta.y)),bt(this.projectionDelta,this.layoutCorrected,d,this.latestValues),(this.treeScale.x!==h||this.treeScale.y!==f||!ys(this.projectionDelta.x,this.prevProjectionDelta.x)||!ys(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",d))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(r=!0){if(this.options.visualElement?.scheduleRender(),r){const a=this.getStack();a&&a.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=ht(),this.projectionDelta=ht(),this.projectionDeltaWithTransform=ht()}setAnimationOrigin(r,a=!1){const l=this.snapshot,u=l?l.latestValues:{},c={...this.latestValues},h=ht();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!a;const f=R(),d=l?l.source:void 0,m=this.layout?this.layout.source:void 0,v=d!==m,T=this.getStack(),g=!T||T.members.length<=1,x=!!(v&&!g&&this.options.crossfade===!0&&!this.path.some(bc));this.animationProgress=0;let y;this.mixTargetDelta=b=>{const P=b/1e3;Ps(h.x,r.x,P),Ps(h.y,r.y,P),this.setTargetDelta(h),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(_t(f,this.layout.layoutBox,this.relativeParent.layout.layoutBox),wc(this.relativeTarget,this.relativeTargetOrigin,f,P),y&&lc(this.relativeTarget,y)&&(this.isProjectionDirty=!1),y||(y=R()),G(y,this.relativeTarget)),v&&(this.animationValues=c,nc(c,u,this.latestValues,P,x,g)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=P},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(r){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(Z(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=V.update(()=>{Ut.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=dt(0)),this.currentAnimation=Zl(this.motionValue,[0,1e3],{...r,velocity:0,isSync:!0,onUpdate:a=>{this.mixTargetDelta(a),r.onUpdate&&r.onUpdate(a)},onStop:()=>{},onComplete:()=>{r.onComplete&&r.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const r=this.getStack();r&&r.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(hc),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const r=this.getLead();let{targetWithTransforms:a,target:l,layout:u,latestValues:c}=r;if(!(!a||!l||!u)){if(this!==r&&this.layout&&u&&rr(this.options.animationType,this.layout.layoutBox,u.layoutBox)){l=this.target||R();const h=I(this.layout.layoutBox.x);l.x.min=r.target.x.min,l.x.max=l.x.min+h;const f=I(this.layout.layoutBox.y);l.y.min=r.target.y.min,l.y.max=l.y.min+f}G(a,l),ut(a,c),bt(this.projectionDeltaWithTransform,this.layoutCorrected,a,c)}}registerSharedNode(r,a){this.sharedNodes.has(r)||this.sharedNodes.set(r,new cc),this.sharedNodes.get(r).add(a);const u=a.options.initialPromotionConfig;a.promote({transition:u?u.transition:void 0,preserveFollowOpacity:u&&u.shouldPreserveFollowOpacity?u.shouldPreserveFollowOpacity(a):void 0})}isLead(){const r=this.getStack();return r?r.lead===this:!0}getLead(){const{layoutId:r}=this.options;return r?this.getStack()?.lead||this:this}getPrevLead(){const{layoutId:r}=this.options;return r?this.getStack()?.prevLead:void 0}getStack(){const{layoutId:r}=this.options;if(r)return this.root.sharedNodes.get(r)}promote({needsReset:r,transition:a,preserveFollowOpacity:l}={}){const u=this.getStack();u&&u.promote(this,l),r&&(this.projectionDelta=void 0,this.needsReset=!0),a&&this.setOptions({transition:a})}relegate(){const r=this.getStack();return r?r.relegate(this):!1}resetSkewAndRotation(){const{visualElement:r}=this.options;if(!r)return;let a=!1;const{latestValues:l}=r;if((l.z||l.rotate||l.rotateX||l.rotateY||l.rotateZ||l.skewX||l.skewY)&&(a=!0),!a)return;const u={};l.z&&ce("z",r,u,this.animationValues);for(let c=0;c<le.length;c++)ce(`rotate${le[c]}`,r,u,this.animationValues),ce(`skew${le[c]}`,r,u,this.animationValues);r.render();for(const c in u)r.setStaticValue(c,u[c]),this.animationValues&&(this.animationValues[c]=u[c]);r.scheduleRender()}applyProjectionStyles(r,a){if(!this.instance||this.isSVG)return;if(!this.isVisible){r.visibility="hidden";return}const l=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,r.visibility="",r.opacity="",r.pointerEvents=Nt(a?.pointerEvents)||"",r.transform=l?l(this.latestValues,""):"none";return}const u=this.getLead();if(!this.projectionDelta||!this.layout||!u.target){this.options.layoutId&&(r.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,r.pointerEvents=Nt(a?.pointerEvents)||""),this.hasProjected&&!nt(this.latestValues)&&(r.transform=l?l({},""):"none",this.hasProjected=!1);return}r.visibility="";const c=u.animationValues||u.latestValues;this.applyTransformsToTarget();let h=uc(this.projectionDeltaWithTransform,this.treeScale,c);l&&(h=l(c,h)),r.transform=h;const{x:f,y:d}=this.projectionDelta;r.transformOrigin=`${f.origin*100}% ${d.origin*100}% 0`,u.animationValues?r.opacity=u===this?c.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:c.opacityExit:r.opacity=u===this?c.opacity!==void 0?c.opacity:"":c.opacityExit!==void 0?c.opacityExit:0;for(const m in Ve){if(c[m]===void 0)continue;const{correct:v,applyTo:T,isCSSVariable:g}=Ve[m],x=h==="none"?c[m]:v(c[m],u);if(T){const y=T.length;for(let b=0;b<y;b++)r[T[b]]=x}else g?this.options.visualElement.renderState.vars[m]=x:r[m]=x}this.options.layoutId&&(r.pointerEvents=u===this?Nt(a?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(r=>r.currentAnimation?.stop()),this.root.nodes.forEach(vs),this.root.sharedNodes.clear()}}}function dc(t){t.updateLayout()}function mc(t){const e=t.resumeFrom?.snapshot||t.snapshot;if(t.isLead()&&t.layout&&e&&t.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:s}=t.layout,{animationType:i}=t.options,o=e.source!==t.layout.source;i==="size"?U(c=>{const h=o?e.measuredBox[c]:e.layoutBox[c],f=I(h);h.min=n[c].min,h.max=h.min+f}):rr(i,e.layoutBox,n)&&U(c=>{const h=o?e.measuredBox[c]:e.layoutBox[c],f=I(n[c]);h.max=h.min+f,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[c].max=t.relativeTarget[c].min+f)});const r=ht();bt(r,n,e.layoutBox);const a=ht();o?bt(a,t.applyTransform(s,!0),e.measuredBox):bt(a,n,e.layoutBox);const l=!er(r);let u=!1;if(!t.resumeFrom){const c=t.getClosestProjectingParent();if(c&&!c.resumeFrom){const{snapshot:h,layout:f}=c;if(h&&f){const d=R();_t(d,e.layoutBox,h.layoutBox);const m=R();_t(m,n,f.layoutBox),nr(d,m)||(u=!0),c.options.layoutRoot&&(t.relativeTarget=m,t.relativeTargetOrigin=d,t.relativeParent=c)}}}t.notifyListeners("didUpdate",{layout:n,snapshot:e,delta:a,layoutDelta:r,hasLayoutChanged:l,hasRelativeLayoutChanged:u})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function pc(t){t.parent&&(t.isProjecting()||(t.isProjectionDirty=t.parent.isProjectionDirty),t.isSharedProjectionDirty||(t.isSharedProjectionDirty=!!(t.isProjectionDirty||t.parent.isProjectionDirty||t.parent.isSharedProjectionDirty)),t.isTransformDirty||(t.isTransformDirty=t.parent.isTransformDirty))}function gc(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function yc(t){t.clearSnapshot()}function vs(t){t.clearMeasurements()}function Ts(t){t.isLayoutDirty=!1}function vc(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function xs(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function Tc(t){t.resolveTargetDelta()}function xc(t){t.calcProjection()}function Pc(t){t.resetSkewAndRotation()}function Sc(t){t.removeLeadSnapshot()}function Ps(t,e,n){t.translate=C(e.translate,0,n),t.scale=C(e.scale,1,n),t.origin=e.origin,t.originPoint=e.originPoint}function Ss(t,e,n,s){t.min=C(e.min,n.min,s),t.max=C(e.max,n.max,s)}function wc(t,e,n,s){Ss(t.x,e.x,n.x,s),Ss(t.y,e.y,n.y,s)}function bc(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const Ac={duration:.45,ease:[.4,0,.1,1]},ws=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),bs=ws("applewebkit/")&&!ws("chrome/")?Math.round:K;function As(t){t.min=bs(t.min),t.max=bs(t.max)}function Vc(t){As(t.x),As(t.y)}function rr(t,e,n){return t==="position"||t==="preserve-aspect"&&!Fl(gs(e),gs(n),.2)}function Cc(t){return t!==t.root&&t.scroll?.wasRoot}const Mc=ir({attachResizeListener:(t,e)=>Dt(t,"resize",e),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),ue={current:void 0},or=ir({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!ue.current){const t=new Mc({});t.mount(window),t.setOptions({layoutScroll:!0}),ue.current=t}return ue.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),Dc={pan:{Feature:Yl},drag:{Feature:Xl,ProjectionNode:or,MeasureLayout:Ji}};function Vs(t,e,n){const{props:s}=t;t.animationState&&s.whileHover&&t.animationState.setActive("whileHover",n==="Start");const i="onHover"+n,o=s[i];o&&V.postRender(()=>o(e,kt(e)))}class Ec extends Q{mount(){const{current:e}=this.node;e&&(this.unmount=ia(e,(n,s)=>(Vs(this.node,s,"Start"),i=>Vs(this.node,i,"End"))))}unmount(){}}class Rc extends Q{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(":focus-visible")}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=Et(Dt(this.node.current,"focus",()=>this.onFocus()),Dt(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function Cs(t,e,n){const{props:s}=t;if(t.current instanceof HTMLButtonElement&&t.current.disabled)return;t.animationState&&s.whileTap&&t.animationState.setActive("whileTap",n==="Start");const i="onTap"+(n==="End"?"":n),o=s[i];o&&V.postRender(()=>o(e,kt(e)))}class Lc extends Q{mount(){const{current:e}=this.node;e&&(this.unmount=aa(e,(n,s)=>(Cs(this.node,s,"Start"),(i,{success:o})=>Cs(this.node,i,o?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const Fe=new WeakMap,he=new WeakMap,kc=t=>{const e=Fe.get(t.target);e&&e(t)},Fc=t=>{t.forEach(kc)};function Bc({root:t,...e}){const n=t||document;he.has(n)||he.set(n,{});const s=he.get(n),i=JSON.stringify(e);return s[i]||(s[i]=new IntersectionObserver(Fc,{root:t,...e})),s[i]}function Ic(t,e,n){const s=Bc(e);return Fe.set(t,n),s.observe(t),()=>{Fe.delete(t),s.unobserve(t)}}const jc={some:0,all:1};class Oc extends Q{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:e={}}=this.node.getProps(),{root:n,margin:s,amount:i="some",once:o}=e,r={root:n?n.current:void 0,rootMargin:s,threshold:typeof i=="number"?i:jc[i]},a=l=>{const{isIntersecting:u}=l;if(this.isInView===u||(this.isInView=u,o&&!u&&this.hasEnteredView))return;u&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",u);const{onViewportEnter:c,onViewportLeave:h}=this.node.getProps(),f=u?c:h;f&&f(l)};return Ic(this.node.current,r,a)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:e,prevProps:n}=this.node;["amount","margin","root"].some(Nc(e,n))&&this.startObserver()}unmount(){}}function Nc({viewport:t={}},{viewport:e={}}={}){return n=>t[n]!==e[n]}const Uc={inView:{Feature:Oc},tap:{Feature:Lc},focus:{Feature:Rc},hover:{Feature:Ec}},Wc={layout:{ProjectionNode:or,MeasureLayout:Ji}},Kc={...Ml,...Uc,...Dc,...Wc},Yc=$a(Kc,sl);function qc(t){return ur({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M380.9 97.1C339 55.1 283.2 32 223.9 32c-122.4 0-222 99.6-222 222 0 39.1 10.2 77.3 29.6 111L0 480l117.7-30.9c32.4 17.7 68.9 27 106.1 27h.1c122.3 0 224.1-99.6 224.1-222 0-59.3-25.2-115-67.1-157zm-157 341.6c-33.2 0-65.7-8.9-94-25.7l-6.7-4-69.8 18.3L72 359.2l-4.4-7c-18.5-29.4-28.2-63.3-28.2-98.2 0-101.7 82.8-184.5 184.6-184.5 49.3 0 95.6 19.2 130.4 54.1 34.8 34.9 56.2 81.2 56.1 130.5 0 101.8-84.9 184.6-186.6 184.6zm101.2-138.2c-5.5-2.8-32.8-16.2-37.9-18-5.1-1.9-8.8-2.8-12.5 2.8-3.7 5.6-14.3 18-17.6 21.8-3.2 3.7-6.5 4.2-12 1.4-32.6-16.3-54-29.1-75.5-66-5.7-9.8 5.7-9.1 16.3-30.3 1.8-3.7.9-6.9-.5-9.7-1.4-2.8-12.5-30.1-17.1-41.2-4.5-10.8-9.1-9.3-12.5-9.5-3.2-.2-6.9-.2-10.6-.2-3.7 0-9.7 1.4-14.8 6.9-5.1 5.6-19.4 19-19.4 46.3 0 27.3 19.9 53.7 22.6 57.4 2.8 3.7 39.1 59.7 94.8 83.8 35.2 15.2 49 16.5 66.6 13.9 10.7-1.6 32.8-13.4 37.4-26.4 4.6-13 4.6-24.1 3.2-26.4-1.3-2.5-5-3.9-10.5-6.6z"},child:[]}]})(t)}export{qc as F,Ms as L,xi as M,Ie as P,zc as U,ha as a,dr as b,ta as i,Yc as m,fr as u};
@@ -1,2 +0,0 @@
1
- import{c as Fe,i as q,h as L,t as I,j as e,l as p,r as U,B as y,aB as js,o as Z,an as bs,ao as vs,ap as Ns,as as me,y as ae,d as ws,P as De,ab as he,av as le,a3 as pe,a4 as ge,a5 as fe,a6 as je,aC as V,a7 as be,n as Q,I as ee,F as ve,aa as ie,R as Re,q as Ie,D as Te,U as ys,A as Ee,a0 as _e,T as ze,v as $e,x as Ue,aD as te,G as Ve,a2 as Ke,J as He,aE as Ss,a9 as ks,aF as Cs}from"./index-DsyZ_FlA.js";import{b as w}from"./recharts-DrC5kNsx.js";import{P as Es,a as Fs,b as Ds}from"./page-components-o2TF52HV.js";import{T as Is,a as As,b as ye}from"./tabs-DqXhuAr6.js";import{S as J}from"./skeleton-B0zh8s_y.js";import{C as Ts,u as Ms,a as Me,D as Qs,c as Ps,b as Os,d as qs,K as Ls,P as Rs}from"./core.esm-Dq12RbIP.js";import{u as _s,S as zs,v as $s,a as Us,s as Vs}from"./sortable.esm-CF3ooibJ.js";import{C as z,a as $}from"./card-DcKsxjXK.js";import{A as Ge,b as Be,c as We,d as Ye,e as Xe,f as Je,g as Ze,h as es}from"./alert-dialog-D8P69s-m.js";import{u as R}from"./useMutation-a5tIBvQY.js";import{f as _,a as m,b as ss,c as Ks,d as Hs,u as Gs,e as Bs}from"./useFunnelStats-tvjpmWIC.js";import{i as ft,l as jt,m as bt,k as vt,g as Nt,h as wt,n as yt,j as St}from"./useFunnelStats-tvjpmWIC.js";import{G as Ws}from"./grip-vertical-FN-eTC2C.js";import{S as re,L as Ys}from"./star-Cuegk1GF.js";import{E as Xs}from"./ellipsis-vertical-DTqbEYYp.js";import{S as as}from"./square-pen-CJajoyrm.js";import{T as ts}from"./trash-2-Du2vmQCH.js";import{P as rs}from"./power-CdR2OkIX.js";import{T as Ne}from"./textarea-BYtcLsMD.js";import{C as we}from"./checkbox-pcbjC0d3.js";import{C as ns,S as K,a as H,b as G,c as B,d as A}from"./select-DlB_BbfM.js";import{S as ls,E as is}from"./EmojiPicker-BToAe-MT.js";import{P as Qe,a as Pe,b as Oe}from"./popover-MyuU-yAK.js";import{T as ne}from"./target-DEuCdeUI.js";import{C as Js}from"./calendar-CIHhMjNy.js";import{D as Zs}from"./download-CiVQHPeB.js";import{H as ea}from"./hash-BoTE56iw.js";import{T as sa}from"./trending-up-Ba4HSvuW.js";import{U as de}from"./user-DwCALzIG.js";import{C as ds}from"./cog-M7j64wa2.js";import{a as aa}from"./datetime-BuZosCVk.js";import{H as os}from"./history-DhHayxUg.js";import{L as ta}from"./list-BKc6EXnV.js";import{T as ra}from"./ticket-CWba7G1i.js";import"./index-KbFmSzBE.js";const na=[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]],la=Fe("arrow-left-right",na);const ia=[["path",{d:"m10 17 5-5-5-5",key:"1bsop3"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}]],da=Fe("log-in",ia);const oa=[["line",{x1:"19",x2:"5",y1:"5",y2:"19",key:"1x9vlm"}],["circle",{cx:"6.5",cy:"6.5",r:"2.5",key:"4mh3h7"}],["circle",{cx:"17.5",cy:"17.5",r:"2.5",key:"1mdrzq"}]],ca=Fe("percent",oa);function ua(){const s=q(),{currentOrganization:u}=L(),t=u?.id||"";return R({mutationFn:a=>_.create(a),onMutate:async a=>{await s.cancelQueries({queryKey:m.withStages(t)});const d=s.getQueryData(m.withStages(t)),r=a.default===!0,i={id:`temp-${Date.now()}`,orgId:"",name:a.name,description:a.description||null,default:a.default||!1,active:a.active??!0,defaultStage:a.defaultStage||null,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),stages:[]};return s.setQueryData(m.withStages(t),(l=[])=>[...r?l.map(o=>o.default?{...o,default:!1,updatedAt:new Date().toISOString()}:o):l,i]),{previousFunnels:d}},onError:(a,d,r)=>{r?.previousFunnels&&s.setQueryData(m.withStages(t),r.previousFunnels);const i=a?.response?.data?.message||a?.message||"Error desconocido";I.error(`Error al crear funnel: ${i}`)},onSuccess:(a,d)=>{s.setQueryData(m.withStages(t),(r=[])=>{const i=r.filter(o=>!o.id.startsWith("temp-"));return[...d.default===!0?i.map(o=>o.default&&o.id!==a.id?{...o,default:!1}:o):i,{...a,stages:[]}]}),I.success(`Funnel "${a.name}" creado`)}})}function cs(){const s=q(),{currentOrganization:u}=L(),t=u?.id||"";return R({mutationFn:({id:a,data:d})=>_.update(a,d),onMutate:async({id:a,data:d})=>{await s.cancelQueries({queryKey:m.withStages(t)}),await s.cancelQueries({queryKey:m.detail(a)});const r=s.getQueryData(m.withStages(t)),i=s.getQueryData(m.detail(a)),l=d.default===!0;return s.setQueryData(m.withStages(t),(c=[])=>c.map(o=>o.id===a?{...o,...d,stages:o.stages||[],updatedAt:new Date().toISOString()}:l&&o.default?{...o,default:!1,updatedAt:new Date().toISOString()}:o)),i&&s.setQueryData(m.detail(a),{...i,...d,updatedAt:new Date().toISOString()}),{previousFunnels:r,previousFunnel:i}},onError:(a,d,r)=>{r?.previousFunnels&&s.setQueryData(m.withStages(t),r.previousFunnels),r?.previousFunnel&&s.setQueryData(m.detail(d.id),r.previousFunnel);const i=a?.response?.data?.message||a?.message||"Error desconocido";I.error(`Error al actualizar: ${i}`)},onSuccess:(a,d)=>{const r=d.data.default===!0;s.setQueryData(m.withStages(t),(o=[])=>{const h=o.find(f=>f.id===a.id)?.stages||[];return o.map(f=>{if(f.id===a.id){const v=a.stages&&a.stages.length>0?a.stages:h;return{...a,stages:v}}return r&&f.default?{...f,default:!1}:f})});const l=s.getQueryData(m.detail(a.id))?.stages||[],c=a.stages&&a.stages.length>0?a.stages:l;s.setQueryData(m.detail(a.id),{...a,stages:c}),I.success("Funnel actualizado")}})}function ma(){const s=q(),{currentOrganization:u}=L(),t=u?.id||"";return R({mutationFn:a=>_.delete(a),onMutate:async a=>{await s.cancelQueries({queryKey:m.withStages(t)}),await s.cancelQueries({queryKey:m.detail(a)});const d=s.getQueryData(m.withStages(t)),r=s.getQueryData(m.detail(a));return s.setQueryData(m.withStages(t),(i=[])=>i.filter(l=>l.id!==a)),s.removeQueries({queryKey:m.detail(a)}),{previousFunnels:d,previousFunnel:r}},onError:(a,d,r)=>{r?.previousFunnels&&s.setQueryData(m.withStages(t),r.previousFunnels),r?.previousFunnel&&s.setQueryData(m.detail(r.previousFunnel.id),r.previousFunnel);const i=a?.response?.data?.message||a?.message||"Error desconocido";I.error(`Error al eliminar: ${i}`)},onSuccess:()=>{I.success("Funnel eliminado")}})}function xa(){const s=q(),{currentOrganization:u}=L(),t=u?.id||"";return R({mutationFn:a=>_.createStage(a),onMutate:async a=>{await s.cancelQueries({queryKey:m.withStages(t)}),await s.cancelQueries({queryKey:m.stages(a.funnelId)});const d=s.getQueryData(m.withStages(t)),r=s.getQueryData(m.stages(a.funnelId)),i=a.default===!0,l={id:`temp-stage-${Date.now()}`,funnelId:a.funnelId,orgId:"",name:a.name,description:a.description||null,icon:a.icon||null,order:a.order??(r?.length||0),active:a.active??!0,default:a.default||!1,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()};return s.setQueryData(m.withStages(t),(c=[])=>c.map(o=>{if(o.id===a.funnelId){const x=i?(o.stages||[]).map(h=>({...h,default:!1,updatedAt:new Date().toISOString()})):o.stages||[];return{...o,stages:[...x,l]}}return o})),s.setQueryData(m.stages(a.funnelId),(c=[])=>[...i?c.map(x=>({...x,default:!1,updatedAt:new Date().toISOString()})):c,l]),{previousFunnels:d,previousStages:r}},onError:(a,d,r)=>{r?.previousFunnels&&s.setQueryData(m.withStages(t),r.previousFunnels),r?.previousStages&&s.setQueryData(m.stages(d.funnelId),r.previousStages);const i=a?.response?.data?.message||a?.message||"Error desconocido";I.error(`Error al crear etapa: ${i}`)},onSuccess:(a,d)=>{const r=d.default===!0;s.setQueryData(m.withStages(t),(i=[])=>i.map(l=>{if(l.id===a.funnelId){const c=(l.stages||[]).filter(x=>!x.id.startsWith("temp-stage-")),o=r?c.map(x=>x.id!==a.id&&x.default?{...x,default:!1}:x):c;return{...l,stages:[...o,a]}}return l})),s.setQueryData(m.stages(a.funnelId),(i=[])=>{const l=i.filter(o=>!o.id.startsWith("temp-stage-"));return[...r?l.map(o=>o.id!==a.id&&o.default?{...o,default:!1}:o):l,a]}),s.invalidateQueries({queryKey:["pipeline-board"]}),I.success(`Etapa "${a.name}" creada`)}})}function us(){const s=q(),{currentOrganization:u}=L(),t=u?.id||"";return R({mutationFn:({id:a,data:d})=>_.updateStage(a,d),onMutate:async({id:a,data:d})=>{const l=(s.getQueryData(m.withStages(t))||[]).find(h=>h.stages?.some(f=>f.id===a))?.id;if(!l)return{previousFunnels:null,previousStages:null};await s.cancelQueries({queryKey:m.withStages(t)}),await s.cancelQueries({queryKey:m.stages(l)});const c=s.getQueryData(m.withStages(t)),o=s.getQueryData(m.stages(l)),x=d.default===!0;return s.setQueryData(m.withStages(t),(h=[])=>h.map(f=>f.id===l?{...f,stages:(f.stages||[]).map(v=>v.id===a?{...v,...d,updatedAt:new Date().toISOString()}:x&&v.default?{...v,default:!1,updatedAt:new Date().toISOString()}:v)}:f)),s.setQueryData(m.stages(l),(h=[])=>h.map(f=>f.id===a?{...f,...d,updatedAt:new Date().toISOString()}:x&&f.default?{...f,default:!1,updatedAt:new Date().toISOString()}:f)),{previousFunnels:c,previousStages:o,funnelId:l}},onError:(a,d,r)=>{r?.previousFunnels&&s.setQueryData(m.withStages(t),r.previousFunnels),r?.previousStages&&r?.funnelId&&s.setQueryData(m.stages(r.funnelId),r.previousStages);const i=a?.response?.data?.message||a?.message||"Error desconocido";I.error(`Error al actualizar etapa: ${i}`)},onSuccess:(a,d)=>{const r=d.data.default===!0;s.setQueryData(m.withStages(t),(i=[])=>i.map(l=>l.id===a.funnelId?{...l,stages:(l.stages||[]).map(c=>c.id===a.id?a:r&&c.default?{...c,default:!1}:c)}:l)),s.setQueryData(m.stages(a.funnelId),(i=[])=>i.map(l=>l.id===a.id?a:r&&l.default?{...l,default:!1}:l)),s.invalidateQueries({queryKey:["pipeline-board"]}),I.success("Etapa actualizada")}})}function ha(){const s=q(),{currentOrganization:u}=L(),t=u?.id||"";return R({mutationFn:({id:a,funnelId:d})=>_.deleteStage(a),onMutate:async({id:a,funnelId:d})=>{await s.cancelQueries({queryKey:m.withStages(t)}),await s.cancelQueries({queryKey:m.stages(d)});const r=s.getQueryData(m.withStages(t)),i=s.getQueryData(m.stages(d));return s.setQueryData(m.withStages(t),(l=[])=>l.map(c=>c.id===d?{...c,stages:(c.stages||[]).filter(o=>o.id!==a)}:c)),s.setQueryData(m.stages(d),(l=[])=>l.filter(c=>c.id!==a)),{previousFunnels:r,previousStages:i}},onError:(a,d,r)=>{r?.previousFunnels&&s.setQueryData(m.withStages(t),r.previousFunnels),r?.previousStages&&s.setQueryData(m.stages(d.funnelId),r.previousStages);const i=a?.response?.data?.message||a?.message||"Error desconocido";I.error(`Error al eliminar etapa: ${i}`)},onSuccess:()=>{s.invalidateQueries({queryKey:["pipeline-board"]}),I.success("Etapa eliminada")}})}function xt(){const s=q(),{currentOrganization:u}=L(),t=u?.id||"";return R({mutationFn:async({funnelId:a,updates:d})=>_.reorderStages(a,d),onMutate:async({funnelId:a,updates:d})=>{await s.cancelQueries({queryKey:m.withStages(t)}),await s.cancelQueries({queryKey:m.stages(a)});const r=s.getQueryData(m.withStages(t)),i=s.getQueryData(m.stages(a));return s.setQueryData(m.withStages(t),(l=[])=>l.map(c=>c.id===a?{...c,stages:(c.stages||[]).map(o=>{const x=d.find(h=>h.id===o.id);return x?{...o,order:Number(x.order),updatedAt:new Date().toISOString()}:o}).sort((o,x)=>o.order-x.order)}:c)),s.setQueryData(m.stages(a),(l=[])=>l.map(c=>{const o=d.find(x=>x.id===c.id);return o?{...c,order:Number(o.order),updatedAt:new Date().toISOString()}:c}).sort((c,o)=>c.order-o.order)),{previousFunnels:r,previousStages:i,funnelId:a}},onError:(a,d,r)=>{r?.previousFunnels&&s.setQueryData(m.withStages(t),r.previousFunnels),r?.previousStages&&r?.funnelId&&s.setQueryData(m.stages(r.funnelId),r.previousStages);const i=a?.response?.data?.message||a?.message||"Error desconocido";I.error(`Error al reordenar etapas: ${i}`)},onSuccess:()=>{s.invalidateQueries({queryKey:m.withStages(t)}),s.invalidateQueries({queryKey:["pipeline-board"]})}})}function pa(){const s=q(),{currentOrganization:u}=L(),t=u?.id||"";return R({mutationFn:async({funnelId:a,stageId:d,afterStageId:r,beforeStageId:i})=>_.moveStage(a,d,r,i),onMutate:async({funnelId:a,stageId:d,afterStageId:r,beforeStageId:i})=>{await s.cancelQueries({queryKey:m.withStages(t)}),await s.cancelQueries({queryKey:m.stages(a)});const l=s.getQueryData(m.withStages(t)),c=s.getQueryData(m.stages(a));return s.setQueryData(m.withStages(t),(o=[])=>o.map(x=>{if(x.id!==a)return x;const h=[...x.stages||[]],f=h.findIndex(k=>k.id===d);if(f===-1)return x;const[v]=h.splice(f,1);let S=0;return r?S=h.findIndex(D=>D.id===r)+1:i&&(S=h.findIndex(k=>k.id===i),S===-1&&(S=h.length)),h.splice(S,0,{...v,updatedAt:new Date().toISOString()}),{...x,stages:h}})),{previousFunnels:l,previousStages:c,funnelId:a}},onError:(a,d,r)=>{r?.previousFunnels&&s.setQueryData(m.withStages(t),r.previousFunnels),r?.previousStages&&r?.funnelId&&s.setQueryData(m.stages(r.funnelId),r.previousStages);const i=a?.response?.data?.message||a?.message||"Error desconocido";I.error(`Error al mover etapa: ${i}`)},onSuccess:()=>{s.invalidateQueries({queryKey:m.withStages(t)}),s.invalidateQueries({queryKey:["pipeline-board"]})}})}function ga(){const s=q(),{currentOrganization:u}=L(),t=u?.id||"";return R({mutationFn:async({id:a,active:d})=>_.toggleFunnelActive(a,d),onMutate:async({id:a,active:d})=>{await s.cancelQueries({queryKey:m.withStages(t)});const r=s.getQueryData(m.withStages(t));return s.setQueryData(m.withStages(t),(i=[])=>i.map(l=>l.id===a?{...l,active:d,updatedAt:new Date().toISOString()}:l)),{previousFunnels:r}},onError:(a,d,r)=>{r?.previousFunnels&&s.setQueryData(m.withStages(t),r.previousFunnels);const i=a?.response?.data?.message||a?.message||"Error desconocido";I.error(`Error al cambiar estado: ${i}`)},onSuccess:(a,{active:d})=>{s.invalidateQueries({queryKey:m.withStages(t)}),I.success(d?"Funnel activado":"Funnel desactivado")}})}function fa(){const s=q(),{currentOrganization:u}=L(),t=u?.id||"";return R({mutationFn:async({id:a,active:d})=>_.toggleStageActive(a,d),onMutate:async({id:a,active:d})=>{await s.cancelQueries({queryKey:m.withStages(t)});const r=s.getQueryData(m.withStages(t));return s.setQueryData(m.withStages(t),(i=[])=>i.map(l=>({...l,stages:l.stages?.map(c=>c.id===a?{...c,active:d,updatedAt:new Date().toISOString()}:c)}))),{previousFunnels:r}},onError:(a,d,r)=>{r?.previousFunnels&&s.setQueryData(m.withStages(t),r.previousFunnels);const i=a?.response?.data?.message||a?.message||"Error desconocido";I.error(`Error al cambiar estado: ${i}`)},onSuccess:(a,{active:d})=>{s.invalidateQueries({queryKey:m.withStages(t)}),s.invalidateQueries({queryKey:["pipeline-board"]}),I.success(d?"Etapa activada":"Etapa desactivada")}})}function qe({stage:s,funnelId:u,onEdit:t,isOverlay:a,density:d="comfortable"}){const[r,i]=w.useState(!1),[l,c]=w.useState(!1),o=us(),x=ha(),h=fa(),f=s.active!==!1,{attributes:v,listeners:S,setNodeRef:k,transform:D,transition:E,isDragging:F}=_s({id:s.id}),b={transform:Ts.Transform.toString(D),transition:E,opacity:F&&!a?.4:1,zIndex:a?40:"auto"},T=async()=>{if(!s.default)try{await o.mutateAsync({id:s.id,data:{default:!0}})}catch{return}},g=async()=>{try{await navigator.clipboard.writeText(s.id),I.success("ID copiado al portapapeles")}catch{I.error("Error al copiar el ID")}},n=()=>{i(!0)},N=async()=>{try{await x.mutateAsync({id:s.id,funnelId:u}),i(!1)}catch{return}},P=(C=>{const O=["from-indigo-500/5 to-indigo-500/0 border-l-indigo-400","from-emerald-500/5 to-emerald-500/0 border-l-emerald-400","from-amber-500/5 to-amber-500/0 border-l-amber-400","from-violet-500/5 to-violet-500/0 border-l-violet-400","from-rose-500/5 to-rose-500/0 border-l-rose-400","from-cyan-500/5 to-cyan-500/0 border-l-cyan-400"];return O[C%O.length]})(s.order),j=d==="compact";return e.jsxs("div",{ref:k,style:b,children:[e.jsx(z,{className:p("border-slate-200/60 dark:border-slate-800 bg-gradient-to-r transition-all border-l-4 group",f?P:"border-l-slate-300 dark:border-l-slate-700 bg-slate-50 dark:bg-slate-900/50 opacity-60 grayscale",j?"rounded-lg":"rounded-xl",a?"shadow-2xl border-primary ring-2 ring-primary/20 bg-white dark:bg-slate-800":"hover:shadow-lg hover:border-slate-300/80 dark:hover:border-slate-700 bg-white dark:bg-slate-900"),children:e.jsxs("div",{className:p("flex items-center gap-3",j?"p-2.5":"p-4 gap-4"),children:[e.jsx("div",{...v,...S,className:"text-slate-300 dark:text-slate-600 cursor-grab active:cursor-grabbing touch-none hover:text-slate-500 dark:hover:text-slate-400 flex-shrink-0 transition-colors",children:e.jsx(Ws,{className:p(j?"h-4 w-4":"h-5 w-5")})}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:p("flex items-center",j?"gap-2":"gap-2.5"),children:[s.icon&&e.jsx("span",{className:p("leading-none flex-shrink-0 bg-slate-100 dark:bg-slate-800 rounded-lg",j?"text-lg p-1":"text-2xl p-1.5"),children:s.icon}),e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h4",{className:p("font-bold text-slate-900 dark:text-white",j?"text-xs":"text-sm",!f&&"text-slate-500 dark:text-slate-400 line-through decoration-slate-400/50"),children:s.name}),s.default?e.jsx(U,{className:p("bg-primary/10 text-primary border-primary/20 font-bold",j?"text-[8px] px-1.5 py-0":"text-[10px] px-2 py-0"),children:"Default"}):!f&&e.jsx(U,{variant:"outline",className:p("font-medium border-red-200 dark:border-red-700 text-red-500 dark:text-red-400 bg-red-50 dark:bg-red-900/20",j?"text-[8px] px-1.5 py-0":"text-[10px] px-2 py-0"),children:"INACTIVE"})]}),s.description&&!j&&e.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 mt-0.5 line-clamp-1",children:s.description})]})]})}),e.jsxs("div",{className:p("flex items-center flex-shrink-0 transition-opacity duration-200",l?"opacity-100":"opacity-0 group-hover:opacity-100",j?"gap-1":"gap-1.5"),children:[e.jsxs(y,{variant:"ghost",size:"sm",onClick:g,className:p("text-slate-500 hover:text-primary hover:bg-primary/5 rounded-lg",j?"text-[10px] h-6 px-2":"text-xs h-8 px-3"),children:[e.jsx(js,{className:p(j?"h-3 w-3 mr-1":"h-3.5 w-3.5 mr-1.5")}),"Copy"]}),!s.default&&e.jsx(y,{variant:"ghost",size:"icon",onClick:T,disabled:o.isPending,className:p("text-slate-400 hover:text-amber-500 hover:bg-amber-50 dark:hover:bg-amber-900/10 rounded-lg",j?"h-6 w-6":"h-8 w-8"),title:"Marcar como default",children:o.isPending?e.jsx(Z,{className:p("animate-spin",j?"h-3 w-3":"h-4 w-4")}):e.jsx(re,{className:p(j?"h-3 w-3":"h-4 w-4")})}),e.jsxs(bs,{open:l,onOpenChange:c,children:[e.jsx(vs,{asChild:!0,children:e.jsx(y,{variant:"ghost",size:"icon",className:p("text-slate-400 hover:text-slate-600 rounded-lg",j?"h-6 w-6":"h-8 w-8"),children:e.jsx(Xs,{className:p(j?"h-3 w-3":"h-4 w-4")})})}),e.jsxs(Ns,{align:"end",className:"rounded-xl shadow-xl p-1",children:[!s.default&&e.jsxs(me,{onClick:T,disabled:o.isPending,className:"rounded-lg",children:[e.jsx(re,{className:"h-4 w-4 mr-2"}),"Marcar como default"]}),e.jsxs(me,{onClick:()=>t?.(s),className:"rounded-lg",children:[e.jsx(as,{className:"h-4 w-4 mr-2"}),"Editar"]}),e.jsxs(me,{onClick:n,className:"text-destructive rounded-lg",children:[e.jsx(ts,{className:"h-4 w-4 mr-2"}),"Eliminar"]}),!s.default&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-px bg-slate-100 dark:bg-slate-800 my-1"}),e.jsxs(me,{onClick:()=>h.mutate({id:s.id,active:!f}),disabled:h.isPending,className:p("rounded-lg",f?"text-red-600 focus:text-red-700":"text-emerald-600 focus:text-emerald-700"),children:[e.jsx(rs,{className:"h-4 w-4 mr-2"}),f?"Desactivar etapa":"Activar etapa"]})]})]})]})]})]})}),e.jsx(Ge,{open:r,onOpenChange:i,children:e.jsxs(Be,{className:"sm:max-w-[425px] border-l-4 border-l-destructive",children:[e.jsxs(We,{children:[e.jsxs("div",{className:"flex items-center gap-3 text-destructive mb-2",children:[e.jsx("div",{className:"p-2 bg-destructive/10 rounded-full",children:e.jsx(ae,{className:"h-5 w-5"})}),e.jsx(Ye,{className:"text-xl",children:"¿Eliminar etapa?"})]}),e.jsx(Xe,{asChild:!0,children:e.jsxs("div",{className:"space-y-3 pt-2 text-sm text-muted-foreground",children:[e.jsxs("p",{children:["Estás a punto de eliminar la etapa ",e.jsxs("strong",{children:['"',s.name,'"']}),"."]}),s.default&&e.jsxs("div",{className:"rounded-lg bg-amber-50 dark:bg-amber-950/30 border border-amber-200 dark:border-amber-800 p-3",children:[e.jsxs("p",{className:"text-sm text-amber-700 dark:text-amber-400 font-medium flex items-center gap-2",children:[e.jsx(re,{className:"h-4 w-4"}),"Esta es la etapa por defecto"]}),e.jsx("p",{className:"text-xs text-amber-600/80 dark:text-amber-500/80 mt-1",children:"Debes asignar otra etapa como default antes de eliminar esta."})]}),!s.default&&e.jsxs("div",{className:"rounded-lg bg-slate-50 dark:bg-slate-800/50 border border-slate-200 dark:border-slate-700 p-3",children:[e.jsxs("p",{className:"text-sm text-slate-600 dark:text-slate-400 font-medium flex items-center gap-2",children:[e.jsx(ae,{className:"h-4 w-4"}),"¿Qué pasará?"]}),e.jsxs("ul",{className:"list-disc pl-5 mt-2 space-y-1 text-xs text-muted-foreground",children:[e.jsx("li",{children:"Si tiene tickets asignados, deberás moverlos primero"}),e.jsx("li",{children:"Si tiene historial de movimientos, se archivará (preservando la data)"}),e.jsx("li",{children:"Si nunca fue usada, se eliminará permanentemente"})]})]}),x.isError&&e.jsxs("div",{className:"rounded-lg bg-destructive/5 border border-destructive/20 p-3",children:[e.jsxs("p",{className:"text-sm text-destructive font-medium flex items-center gap-2",children:[e.jsx(ae,{className:"h-4 w-4"}),"Error"]}),e.jsx("p",{className:"text-xs text-destructive/80 mt-1",children:x.error?.message||"No se pudo eliminar la etapa"})]})]})})]}),e.jsxs(Je,{children:[e.jsx(Ze,{disabled:x.isPending,children:"Cancelar"}),e.jsx(es,{onClick:N,disabled:x.isPending||s.default,className:"bg-destructive hover:bg-destructive/90 text-destructive-foreground",children:x.isPending?"Eliminando...":"Sí, eliminar"})]})]})})]})}const Ae=ws(s=>({expandedFunnelIds:new Set,selectedFunnelId:null,isCreateFunnelModalOpen:!1,isCreateStageModalOpen:!1,editingFunnelId:null,editingStageId:null,toggleFunnelExpanded:u=>s(t=>{const a=new Set(t.expandedFunnelIds);return a.has(u)?a.delete(u):a.add(u),{expandedFunnelIds:a}}),expandFunnel:u=>s(t=>{const a=new Set(t.expandedFunnelIds);return a.add(u),{expandedFunnelIds:a}}),collapseFunnel:u=>s(t=>{const a=new Set(t.expandedFunnelIds);return a.delete(u),{expandedFunnelIds:a}}),setSelectedFunnel:u=>s({selectedFunnelId:u}),openCreateFunnelModal:()=>s({isCreateFunnelModalOpen:!0}),closeCreateFunnelModal:()=>s({isCreateFunnelModalOpen:!1}),openCreateStageModal:u=>s({isCreateStageModalOpen:!0,selectedFunnelId:u}),closeCreateStageModal:()=>s({isCreateStageModalOpen:!1,selectedFunnelId:null}),setEditingFunnel:u=>s({editingFunnelId:u}),setEditingStage:u=>s({editingStageId:u}),reset:()=>s({expandedFunnelIds:new Set,selectedFunnelId:null,isCreateFunnelModalOpen:!1,isCreateStageModalOpen:!1,editingFunnelId:null,editingStageId:null})})),ja=()=>Ae(De(s=>s.expandedFunnelIds)),ba=()=>Ae(De(s=>({selectedFunnelId:s.selectedFunnelId,isCreateFunnelModalOpen:s.isCreateFunnelModalOpen,isCreateStageModalOpen:s.isCreateStageModalOpen,editingFunnelId:s.editingFunnelId,editingStageId:s.editingStageId}))),W=()=>Ae(De(s=>({toggleFunnelExpanded:s.toggleFunnelExpanded,expandFunnel:s.expandFunnel,collapseFunnel:s.collapseFunnel,setSelectedFunnel:s.setSelectedFunnel,openCreateFunnelModal:s.openCreateFunnelModal,closeCreateFunnelModal:s.closeCreateFunnelModal,openCreateStageModal:s.openCreateStageModal,closeCreateStageModal:s.closeCreateStageModal,setEditingFunnel:s.setEditingFunnel,setEditingStage:s.setEditingStage,reset:s.reset}))),va=({transform:s})=>({...s,x:0});function Na({funnel:s,onAddStage:u,onEditStage:t,onEditFunnel:a,density:d="comfortable"}){const[r,i]=w.useState(!1),[l,c]=w.useState(()=>(s.stages||[]).sort((C,O)=>C.order>O.order?1:-1)),[o,x]=w.useState(null),h=ja(),{toggleFunnelExpanded:f}=W(),v=ma(),S=cs(),k=pa(),D=ga(),E=s.active!==!1,F=l.length;h.has(s.id);const b=F>0;w.useEffect(()=>{if(o||k.isPending)return;const O=[...s.stages||[]].sort((se,oe)=>se.order>oe.order?1:-1);c(O)},[s.stages,s.id,o,k.isPending]);const T=Ms(Me(Rs,{activationConstraint:{distance:5}}),Me(Ls,{coordinateGetter:Vs})),g=C=>{x(C.active.id)},n=async C=>{const{active:O,over:se}=C;if(x(null),!se||O.id===se.id)return;const oe=l.findIndex(ue=>ue.id===O.id),Y=l.findIndex(ue=>ue.id===se.id);if(oe===-1||Y===-1)return;const ce=Us(l,oe,Y);c(ce);const xs=Y>0?ce[Y-1].id:null,hs=Y<ce.length-1?ce[Y+1].id:null;try{await k.mutateAsync({funnelId:s.id,stageId:O.id,afterStageId:xs,beforeStageId:hs})}catch{const ps=[...s.stages||[]].sort((gs,fs)=>gs.order>fs.order?1:-1);c(ps)}},N=async()=>{if(!(s.default||S.isPending))try{await S.mutateAsync({id:s.id,data:{default:!0}})}catch{return}},M=()=>{i(!0)},P=async()=>{try{await v.mutateAsync(s.id),i(!1)}catch{return}},j=d==="compact";return e.jsxs(z,{className:p("border-slate-200/60 dark:border-slate-800 bg-white dark:bg-slate-900 hover:shadow-lg transition-all",j?"rounded-xl":"rounded-2xl",!E&&"opacity-60 grayscale-[30%]"),children:[e.jsxs($,{className:"p-0",children:[e.jsx("div",{className:p("border-b border-slate-100 dark:border-slate-800",j?"px-4 py-3":"p-6"),children:e.jsxs("div",{className:p("flex items-center justify-between",!j&&"mb-4"),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h3",{className:p("font-bold text-slate-900 dark:text-white",j?"text-sm":"text-lg"),children:s.name}),s.default?e.jsx(U,{className:p("bg-primary/10 text-primary border-primary/20 font-medium",j?"text-[10px] px-2 py-0":"text-xs px-2.5 py-0.5"),children:"DEFAULT"}):E?e.jsx(U,{variant:"outline",className:p("font-medium border-slate-200 dark:border-slate-700 text-slate-500 dark:text-slate-400",j?"text-[10px] px-2 py-0":"text-xs px-2.5 py-0.5"),children:"ACTIVE"}):e.jsx(U,{variant:"outline",className:p("font-medium border-red-200 dark:border-red-700 text-red-500 dark:text-red-400 bg-red-50 dark:bg-red-900/20",j?"text-[10px] px-2 py-0":"text-xs px-2.5 py-0.5"),children:"INACTIVE"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs(y,{variant:"ghost",size:"sm",onClick:()=>u(s.id),disabled:!E,className:p("text-primary hover:text-primary hover:bg-primary/10",j?"text-[10px] h-7 px-2":"text-xs",!E&&"opacity-50 cursor-not-allowed"),children:[e.jsx(he,{className:p(j?"h-3 w-3 mr-1":"h-3.5 w-3.5 mr-1.5")}),"Add Stage"]}),!s.default&&e.jsx(y,{variant:"ghost",size:"icon",onClick:N,disabled:S.isPending||!E,className:p(j?"h-7 w-7":"h-8 w-8"),title:"Marcar como default",children:S.isPending?e.jsx(Z,{className:p("animate-spin",j?"h-3.5 w-3.5":"h-4 w-4")}):e.jsx(re,{className:p(j?"h-3.5 w-3.5":"h-4 w-4")})}),e.jsx(y,{variant:"ghost",size:"icon",onClick:()=>D.mutate({id:s.id,active:!E}),disabled:D.isPending||s.default,className:p(j?"h-7 w-7":"h-8 w-8",E?"text-emerald-600 hover:text-emerald-700 hover:bg-emerald-50":"text-slate-400 hover:text-slate-600 hover:bg-slate-100",s.default&&"opacity-50 cursor-not-allowed"),title:s.default?"No se puede desactivar el funnel por defecto":E?"Desactivar funnel":"Activar funnel",children:D.isPending?e.jsx(Z,{className:p("animate-spin",j?"h-3.5 w-3.5":"h-4 w-4")}):e.jsx(rs,{className:p(j?"h-3.5 w-3.5":"h-4 w-4")})}),e.jsx(y,{variant:"ghost",size:"icon",onClick:()=>a?.(s),className:p(j?"h-7 w-7":"h-8 w-8"),title:"Editar funnel",children:e.jsx(as,{className:p(j?"h-3.5 w-3.5":"h-4 w-4")})}),e.jsx(y,{variant:"ghost",size:"icon",onClick:M,disabled:v.isPending,className:p("text-destructive hover:text-destructive hover:bg-destructive/10",j?"h-7 w-7":"h-8 w-8"),title:"Eliminar funnel",children:e.jsx(ts,{className:p(j?"h-3.5 w-3.5":"h-4 w-4")})})]})]})}),b?e.jsx("div",{className:p(j?"p-3":"p-6"),children:e.jsxs(Qs,{sensors:T,collisionDetection:Ps,onDragStart:g,onDragEnd:n,modifiers:[va],children:[e.jsx(zs,{items:l.map(C=>C.id),strategy:$s,children:e.jsx("div",{className:p(j?"space-y-1.5":"space-y-3"),children:l.map(C=>C?e.jsx(qe,{stage:C,funnelId:s.id,onEdit:t,density:d},C.id):null)})}),e.jsx(Os,{dropAnimation:{sideEffects:qs({styles:{active:{opacity:"0.4"}}})},children:o?e.jsx(qe,{stage:l.find(C=>C.id===o),funnelId:s.id,isOverlay:!0,density:d}):null})]})}):e.jsx("div",{className:"p-8",children:e.jsxs("div",{className:"border-2 border-dashed border-slate-200 dark:border-slate-700 rounded-2xl p-12 text-center",children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-2xl bg-slate-100 dark:bg-slate-800 flex items-center justify-center",children:e.jsx(le,{className:"h-8 w-8 text-slate-400 dark:text-slate-500"})}),e.jsx("h4",{className:"font-bold text-base text-slate-900 dark:text-white mb-2",children:"No hay etapas definidas aún"}),e.jsx("p",{className:"text-sm text-slate-500 dark:text-slate-400 mb-6 max-w-md mx-auto",children:"Todo gran funnel comienza con etapas claras. Agrega tu primera etapa para comenzar a rastrear tus prospectos."}),e.jsxs(y,{onClick:()=>u(s.id),className:"bg-primary hover:bg-primary/90 text-white",children:[e.jsx(he,{className:"h-4 w-4 mr-2"}),"Agregar Primera Etapa"]})]})})]}),e.jsx(Ge,{open:r,onOpenChange:i,children:e.jsxs(Be,{className:"sm:max-w-[425px] border-l-4 border-l-destructive",children:[e.jsxs(We,{children:[e.jsxs("div",{className:"flex items-center gap-3 text-destructive mb-2",children:[e.jsx("div",{className:"p-2 bg-destructive/10 rounded-full",children:e.jsx(ae,{className:"h-5 w-5"})}),e.jsx(Ye,{className:"text-xl",children:"¿Eliminar funnel?"})]}),e.jsx(Xe,{asChild:!0,children:e.jsxs("div",{className:"space-y-3 pt-2 text-sm text-muted-foreground",children:[e.jsxs("p",{children:["Estás a punto de eliminar el funnel ",e.jsxs("strong",{children:['"',s.name,'"']}),"."]}),s.default&&e.jsxs("div",{className:"rounded-lg bg-amber-50 dark:bg-amber-950/30 border border-amber-200 dark:border-amber-800 p-3",children:[e.jsxs("p",{className:"text-sm text-amber-700 dark:text-amber-400 font-medium flex items-center gap-2",children:[e.jsx(re,{className:"h-4 w-4"}),"Este es el funnel por defecto"]}),e.jsx("p",{className:"text-xs text-amber-600/80 dark:text-amber-500/80 mt-1",children:"Debes asignar otro funnel como default antes de eliminar este."})]}),!s.default&&e.jsxs("div",{className:"rounded-lg bg-slate-50 dark:bg-slate-800/50 border border-slate-200 dark:border-slate-700 p-3",children:[e.jsxs("p",{className:"text-sm text-slate-600 dark:text-slate-400 font-medium flex items-center gap-2",children:[e.jsx(le,{className:"h-4 w-4"}),"¿Qué pasará?"]}),e.jsxs("ul",{className:"list-disc pl-5 mt-2 space-y-1 text-xs text-muted-foreground",children:[e.jsx("li",{children:"Si este funnel tiene tickets asignados, deberás reasignarlos primero"}),e.jsx("li",{children:"Si tiene historial de movimientos, se archivará (preservando la data)"}),e.jsx("li",{children:"Si nunca fue usado, se eliminará permanentemente"}),e.jsxs("li",{children:["Las ",F," etapa",F!==1?"s":""," asociada",F!==1?"s":""," también se ",F>0?"eliminarán":"eliminará"]})]})]}),v.isError&&e.jsxs("div",{className:"rounded-lg bg-destructive/5 border border-destructive/20 p-3",children:[e.jsxs("p",{className:"text-sm text-destructive font-medium flex items-center gap-2",children:[e.jsx(ae,{className:"h-4 w-4"}),"Error"]}),e.jsx("p",{className:"text-xs text-destructive/80 mt-1",children:v.error?.message||"No se pudo eliminar el funnel"})]})]})})]}),e.jsxs(Je,{children:[e.jsx(Ze,{disabled:v.isPending,children:"Cancelar"}),e.jsx(es,{onClick:P,disabled:v.isPending||s.default,className:"bg-destructive hover:bg-destructive/90 text-destructive-foreground",children:v.isPending?"Eliminando...":"Sí, eliminar"})]})]})})]})}function Le({open:s,onOpenChange:u}){const[t,a]=w.useState(""),[d,r]=w.useState(""),[i,l]=w.useState(!1),c=ua(),{closeCreateFunnelModal:o}=W();w.useEffect(()=>{s&&(a(""),r(""),l(!1))},[s]);const x=t.trim().length>=3,h=async f=>{if(f.preventDefault(),!(!x||c.isPending))try{await c.mutateAsync({name:t.trim(),description:d.trim()||void 0,default:i,active:!0}),o(),u(!1)}catch{return}};return e.jsx(pe,{open:s,onOpenChange:u,children:e.jsxs(ge,{className:"sm:max-w-[480px]",children:[e.jsxs(fe,{children:[e.jsxs(je,{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-primary/10 flex items-center justify-center",children:e.jsx(V,{className:"h-5 w-5 text-primary"})}),e.jsx("span",{children:"Crear Funnel"})]}),e.jsx(be,{children:"Crea un nuevo embudo de ventas para organizar tus procesos"})]}),e.jsxs("form",{onSubmit:h,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Q,{htmlFor:"funnel-name",children:"Nombre del Funnel *"}),e.jsx(ee,{id:"funnel-name",value:t,onChange:f=>a(f.target.value),placeholder:"Ej. Funnel de Ventas",autoFocus:!0,required:!0}),t.length>0&&t.trim().length<3?e.jsx("p",{className:"text-xs text-destructive",children:"Mínimo 3 caracteres"}):t.trim().length>=3&&e.jsxs("p",{className:"text-xs text-emerald-500 flex items-center gap-1",children:[e.jsx(ve,{className:"h-3 w-3"}),"Nombre válido"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Q,{htmlFor:"funnel-description",children:"Descripción (opcional)"}),e.jsx(Ne,{id:"funnel-description",value:d,onChange:f=>r(f.target.value),placeholder:"Describe el propósito de este funnel",rows:3})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(we,{id:"funnel-default",checked:i,onCheckedChange:f=>l(f===!0)}),e.jsx(Q,{htmlFor:"funnel-default",className:"text-sm font-normal cursor-pointer",children:"Marcar como funnel por defecto"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(y,{type:"button",variant:"outline",onClick:()=>{u(!1),o()},disabled:c.isPending,children:"Cancelar"}),e.jsx(y,{type:"submit",disabled:!x||c.isPending,children:c.isPending?"Creando...":"Crear Funnel"})]})]})]})})}function wa({open:s,onOpenChange:u,funnel:t}){const[a,d]=w.useState(""),[r,i]=w.useState(""),[l,c]=w.useState(!1),o=cs(),{setEditingFunnel:x}=W();w.useEffect(()=>{s&&t&&(d(t.name||""),i(t.description||""),c(t.default||!1))},[s,t]);const h=a.trim().length>=3,f=async v=>{if(v.preventDefault(),!(!h||!t||o.isPending))try{await o.mutateAsync({id:t.id,data:{name:a.trim(),description:r.trim()||void 0,default:l}}),x(null),u(!1)}catch{return}};return t?e.jsx(pe,{open:s,onOpenChange:u,children:e.jsxs(ge,{className:"sm:max-w-[480px]",children:[e.jsxs(fe,{children:[e.jsxs(je,{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-primary/10 flex items-center justify-center",children:e.jsx(V,{className:"h-5 w-5 text-primary"})}),e.jsx("span",{children:"Editar Funnel"})]}),e.jsxs(be,{children:['Modifica los datos del funnel "',t.name,'"']})]}),e.jsxs("form",{onSubmit:f,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Q,{htmlFor:"edit-funnel-name",children:"Nombre del Funnel *"}),e.jsx(ee,{id:"edit-funnel-name",value:a,onChange:v=>d(v.target.value),placeholder:"Ej. Funnel de Ventas",autoFocus:!0,required:!0}),a.length>0&&a.trim().length<3?e.jsx("p",{className:"text-xs text-destructive",children:"Mínimo 3 caracteres"}):a.trim().length>=3&&e.jsxs("p",{className:"text-xs text-emerald-500 flex items-center gap-1",children:[e.jsx(ve,{className:"h-3 w-3"}),"Nombre válido"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Q,{htmlFor:"edit-funnel-description",children:"Descripción (opcional)"}),e.jsx(Ne,{id:"edit-funnel-description",value:r,onChange:v=>i(v.target.value),placeholder:"Describe el propósito de este funnel",rows:3})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(we,{id:"edit-funnel-default",checked:l,onCheckedChange:v=>c(v===!0)}),e.jsx(Q,{htmlFor:"edit-funnel-default",className:"text-sm font-normal cursor-pointer",children:"Marcar como funnel por defecto"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(y,{type:"button",variant:"outline",onClick:()=>{u(!1),x(null)},disabled:o.isPending,children:"Cancelar"}),e.jsx(y,{type:"submit",disabled:!h||o.isPending,children:o.isPending?"Guardando...":"Guardar Cambios"})]})]})]})}):null}const ms=["Lead","Contact","ViewContent","InitiateCheckout","CompleteRegistration","Subscribe","Schedule","AddToCart","Purchase","QualifiedLead"],Se="__none__",ya={Lead:"Lead — Nuevo cliente potencial calificado",Contact:"Contact — Primera interacción del lead",ViewContent:"ViewContent — Vió contenido importante (precios, info)",InitiateCheckout:"InitiateCheckout — Inició proceso de inscripción/compra",CompleteRegistration:"CompleteRegistration — Completó registro/inscripción",Subscribe:"Subscribe — Se suscribió a algo",Schedule:"Schedule — Agendó cita/reunión",AddToCart:"AddToCart — Expresó intención de compra",Purchase:"Purchase — Conversión final (venta cerrada)",QualifiedLead:"QualifiedLead — Lead calificado (buen lead, no basura)"};function Sa({open:s,onOpenChange:u,funnelId:t}){const[a,d]=w.useState(""),[r,i]=w.useState(""),[l,c]=w.useState(""),[o,x]=w.useState(!1),[h,f]=w.useState(!1),[v,S]=w.useState(null),k=xa(),{closeCreateStageModal:D}=W();w.useEffect(()=>{s&&(d(""),i(""),c(""),x(!1),f(!1),S(null))},[s]);const E=a.trim().length>=3,F=async b=>{if(b.preventDefault(),!(!E||k.isPending))try{await k.mutateAsync({funnelId:t,name:a.trim(),description:r.trim()||void 0,icon:l.trim()||void 0,default:o,active:!0,metaEventType:v??void 0}),D(),u(!1)}catch{return}};return e.jsx(pe,{open:s,onOpenChange:u,children:e.jsxs(ge,{className:"sm:max-w-[480px]",children:[e.jsxs(fe,{children:[e.jsxs(je,{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-primary/10 flex items-center justify-center",children:e.jsx(le,{className:"h-5 w-5 text-primary"})}),e.jsx("span",{children:"Agregar Etapa"})]}),e.jsx(be,{children:"Crea una nueva etapa para este funnel"})]}),e.jsxs("form",{onSubmit:F,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Q,{htmlFor:"stage-name",children:"Nombre de la Etapa *"}),e.jsx(ee,{id:"stage-name",value:a,onChange:b=>d(b.target.value),placeholder:"Ej. Lead - Nurturing",autoFocus:!0,required:!0}),a.length>0&&a.trim().length<3?e.jsx("p",{className:"text-xs text-destructive",children:"Mínimo 3 caracteres"}):a.trim().length>=3&&e.jsxs("p",{className:"text-xs text-emerald-500 flex items-center gap-1",children:[e.jsx(ve,{className:"h-3 w-3"}),"Nombre válido"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Q,{htmlFor:"stage-description",children:"Descripción (opcional)"}),e.jsx(Ne,{id:"stage-description",value:r,onChange:b=>i(b.target.value),placeholder:"Describe esta etapa",rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Q,{htmlFor:"stage-icon",children:"Icono (opcional)"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ee,{id:"stage-icon",value:l,onChange:b=>c(b.target.value),placeholder:"Ej. 😊",className:"flex-1"}),e.jsx(y,{type:"button",variant:h?"secondary":"outline",size:"icon",className:"h-10 w-10 shrink-0",onClick:()=>f(!h),children:h?e.jsx(ns,{className:"h-4 w-4"}):e.jsx(ls,{className:"h-4 w-4"})})]}),l&&!h&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx("span",{children:"Vista previa:"}),e.jsx("span",{className:"text-2xl",children:l})]}),h&&e.jsx("div",{className:"mt-1 rounded-lg border border-border bg-card overflow-hidden shadow-sm",children:e.jsx(is,{onSelect:b=>c(b),fullWidth:!0,height:250})})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(we,{id:"stage-default",checked:o,onCheckedChange:b=>x(b===!0)}),e.jsx(Q,{htmlFor:"stage-default",className:"text-sm font-normal cursor-pointer",children:"Marcar como etapa por defecto"})]}),e.jsxs("div",{className:"space-y-2 pt-2 border-t",children:[e.jsxs(Q,{htmlFor:"stage-meta-event",className:"flex items-center gap-1.5",children:["Evento de Meta CAPI al entrar a esta etapa",e.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"(opcional)"})]}),e.jsxs(K,{value:v??Se,onValueChange:b=>S(b===Se?null:b),children:[e.jsx(H,{id:"stage-meta-event",children:e.jsx(G,{placeholder:"Ninguno"})}),e.jsxs(B,{children:[e.jsx(A,{value:Se,children:"Ninguno (no envía CAPI)"}),ms.map(b=>e.jsx(A,{value:b,children:ya[b]},b))]})]}),e.jsxs("p",{className:"text-[11px] text-muted-foreground flex items-start gap-1",children:[e.jsx(ie,{className:"h-3 w-3 mt-0.5 shrink-0"}),e.jsxs("span",{children:["Si tu org tiene Meta Pixel conectado, al entrar un ticket a esta etapa se enviará automáticamente este evento a Meta Ads (atribución + optimización).",v==="Purchase"||v==="InitiateCheckout"?e.jsxs(e.Fragment,{children:[" ",e.jsx("strong",{className:"text-amber-500",children:'⚠ Si tu equipo también usa "Registrar venta" del inbox para este tipo de evento, ambos se envían a Meta — usá un solo flujo para evitar duplicar atribución.'})]}):null]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(y,{type:"button",variant:"outline",onClick:()=>{u(!1),D()},disabled:k.isPending,children:"Cancelar"}),e.jsx(y,{type:"submit",disabled:!E||k.isPending,children:k.isPending?"Creando...":"Crear Etapa"})]})]})]})})}const ke="__none__",ka={Lead:"Lead — Nuevo cliente potencial calificado",Contact:"Contact — Primera interacción del lead",ViewContent:"ViewContent — Vió contenido importante (precios, info)",InitiateCheckout:"InitiateCheckout — Inició proceso de inscripción/compra",CompleteRegistration:"CompleteRegistration — Completó registro/inscripción",Subscribe:"Subscribe — Se suscribió a algo",Schedule:"Schedule — Agendó cita/reunión",AddToCart:"AddToCart — Expresó intención de compra",Purchase:"Purchase — Conversión final (venta cerrada)",QualifiedLead:"QualifiedLead — Lead calificado (buen lead, no basura)"};function Ca({open:s,onOpenChange:u,stage:t}){const[a,d]=w.useState(""),[r,i]=w.useState(""),[l,c]=w.useState(""),[o,x]=w.useState(!1),[h,f]=w.useState(!1),[v,S]=w.useState(null),k=us(),{setEditingStage:D}=W();w.useEffect(()=>{s&&t&&(d(t.name||""),i(t.description||""),c(t.icon||""),x(t.default||!1),f(!1),S(t.metaEventType||null))},[s,t]);const E=a.trim().length>=3,F=async b=>{if(b.preventDefault(),!(!E||!t||k.isPending))try{await k.mutateAsync({id:t.id,data:{name:a.trim(),description:r.trim()||void 0,icon:l.trim()||void 0,default:o,metaEventType:v}}),D(null),u(!1)}catch{return}};return t?e.jsx(pe,{open:s,onOpenChange:u,children:e.jsxs(ge,{className:"sm:max-w-[480px]",children:[e.jsxs(fe,{children:[e.jsxs(je,{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-primary/10 flex items-center justify-center",children:e.jsx(le,{className:"h-5 w-5 text-primary"})}),e.jsx("span",{children:"Editar Etapa"})]}),e.jsxs(be,{children:['Modifica los datos de la etapa "',t.name,'"']})]}),e.jsxs("form",{onSubmit:F,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Q,{htmlFor:"edit-stage-name",children:"Nombre de la Etapa *"}),e.jsx(ee,{id:"edit-stage-name",value:a,onChange:b=>d(b.target.value),placeholder:"Ej. Lead - Nurturing",autoFocus:!0,required:!0}),a.length>0&&a.trim().length<3?e.jsx("p",{className:"text-xs text-destructive",children:"Mínimo 3 caracteres"}):a.trim().length>=3&&e.jsxs("p",{className:"text-xs text-emerald-500 flex items-center gap-1",children:[e.jsx(ve,{className:"h-3 w-3"}),"Nombre válido"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Q,{htmlFor:"edit-stage-description",children:"Descripción (opcional)"}),e.jsx(Ne,{id:"edit-stage-description",value:r,onChange:b=>i(b.target.value),placeholder:"Describe esta etapa",rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Q,{htmlFor:"edit-stage-icon",children:"Icono (opcional)"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ee,{id:"edit-stage-icon",value:l,onChange:b=>c(b.target.value),placeholder:"Ej. 😊",className:"flex-1"}),e.jsx(y,{type:"button",variant:h?"secondary":"outline",size:"icon",className:"h-10 w-10 shrink-0",onClick:()=>f(!h),children:h?e.jsx(ns,{className:"h-4 w-4"}):e.jsx(ls,{className:"h-4 w-4"})})]}),l&&!h&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx("span",{children:"Vista previa:"}),e.jsx("span",{className:"text-2xl",children:l})]}),h&&e.jsx("div",{className:"mt-1 rounded-lg border border-border bg-card overflow-hidden shadow-sm",children:e.jsx(is,{onSelect:b=>c(b),fullWidth:!0,height:250})})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(we,{id:"edit-stage-default",checked:o,onCheckedChange:b=>x(b===!0)}),e.jsx(Q,{htmlFor:"edit-stage-default",className:"text-sm font-normal cursor-pointer",children:"Marcar como etapa por defecto"})]}),e.jsxs("div",{className:"space-y-2 pt-2 border-t",children:[e.jsxs(Q,{htmlFor:"edit-stage-meta-event",className:"flex items-center gap-1.5",children:["Evento de Meta CAPI al entrar a esta etapa",e.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"(opcional)"})]}),e.jsxs(K,{value:v??ke,onValueChange:b=>S(b===ke?null:b),children:[e.jsx(H,{id:"edit-stage-meta-event",children:e.jsx(G,{placeholder:"Ninguno"})}),e.jsxs(B,{children:[e.jsx(A,{value:ke,children:"Ninguno (no envía CAPI)"}),ms.map(b=>e.jsx(A,{value:b,children:ka[b]},b))]})]}),e.jsxs("p",{className:"text-[11px] text-muted-foreground flex items-start gap-1",children:[e.jsx(ie,{className:"h-3 w-3 mt-0.5 shrink-0"}),e.jsxs("span",{children:["Si tu org tiene Meta Pixel conectado, al entrar un ticket a esta etapa se enviará automáticamente este evento a Meta Ads (atribución + optimización).",v==="Lead"||v==="Contact"?e.jsxs(e.Fragment,{children:[" ","Para tickets que vienen de un anuncio de WhatsApp, Meta lo recibe como"," ",e.jsx("span",{className:"font-mono",children:"LeadSubmitted"}),"."]}):null,v==="CompleteRegistration"||v==="Subscribe"||v==="Schedule"?e.jsxs(e.Fragment,{children:[" ",e.jsx("strong",{className:"text-amber-500",children:"⚠ Este evento no existe para WhatsApp: en tickets de anuncio se envía sin el clic del anuncio. Si quieres marcar un buen lead, usa QualifiedLead."})]}):null,v==="Purchase"||v==="InitiateCheckout"?e.jsxs(e.Fragment,{children:[" ",e.jsx("strong",{className:"text-amber-500",children:'⚠ Si tu equipo también usa "Registrar venta" del inbox para este tipo de evento, ambos se envían a Meta — usá un solo flujo para evitar duplicar atribución.'})]}):null]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(y,{type:"button",variant:"outline",onClick:()=>{u(!1),D(null)},disabled:k.isPending,children:"Cancelar"}),e.jsx(y,{type:"submit",disabled:!E||k.isPending,children:k.isPending?"Guardando...":"Guardar Cambios"})]})]})]})}):null}function Ea({funnels:s,isLoading:u,error:t,density:a="comfortable"}){const{isCreateFunnelModalOpen:d,isCreateStageModalOpen:r,selectedFunnelId:i,editingStageId:l,editingFunnelId:c}=ba(),{openCreateFunnelModal:o,openCreateStageModal:x,closeCreateFunnelModal:h,closeCreateStageModal:f,setEditingStage:v,setEditingFunnel:S}=W(),k=n=>{x(n)},D=n=>{v(n.id)},E=n=>{S(n.id)},F=s?.flatMap(n=>n.stages||[]).find(n=>n.id===l)||null,b=s?.find(n=>n.id===c)||null,T=s?[...s].sort((n,N)=>n.default&&!N.default?-1:!n.default&&N.default?1:n.name.localeCompare(N.name)):[];if(u)return e.jsx("div",{className:"space-y-4",children:[1,2].map(n=>e.jsx(J,{className:"h-32 w-full"},n))});if(t)return e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-destructive mb-4",children:"Error al cargar los funnels. Por favor, intenta nuevamente."}),e.jsx(y,{onClick:()=>window.location.reload(),children:"Recargar"})]});if(T.length===0)return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center",children:[e.jsx("div",{className:"w-20 h-20 bg-slate-100 dark:bg-slate-800 rounded-2xl flex items-center justify-center mb-6",children:e.jsx(V,{className:"h-10 w-10 text-muted-foreground/50"})}),e.jsx("h3",{className:"text-xl font-bold text-slate-900 dark:text-white mb-2",children:"No hay funnels"}),e.jsx("p",{className:"text-slate-500 max-w-sm mx-auto text-sm mb-6",children:"Crea tu primer funnel para comenzar a organizar tus procesos de ventas"}),e.jsxs(y,{onClick:o,children:[e.jsx(he,{className:"h-4 w-4 mr-2"}),"Crear Funnel"]})]}),e.jsx(Le,{open:d,onOpenChange:n=>{n?o():h()}})]});const g=a==="compact";return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:p("space-y-4",g&&"space-y-2"),children:T.map(n=>e.jsx(Na,{funnel:n,onAddStage:k,onEditStage:D,onEditFunnel:E,density:a},n.id))}),e.jsx(Le,{open:d,onOpenChange:n=>{n?o():h()}}),e.jsx(wa,{open:!!b,onOpenChange:n=>{n||S(null)},funnel:b}),i&&e.jsx(Sa,{open:r,onOpenChange:n=>{n?x(i):f()},funnelId:i}),e.jsx(Ca,{open:!!F,onOpenChange:n=>{n||v(null)},stage:F})]})}function Fa({funnels:s}){const{selectedFunnelId:u,periodDays:t,setSelectedFunnelId:a,setPeriodDays:d}=ss();w.useEffect(()=>{!u&&s.length>0&&a(s[0].id)},[s,u,a]);const r=s.find(n=>n.id===u),{distribution:i,conversion:l,actors:c,completion:o,isLoading:x,isFetching:h,refetchAll:f}=Ks(u,t),v=async()=>{if(!u){I.error("Selecciona un funnel primero");return}I.promise(f(),{loading:"Actualizando estadísticas...",success:"Estadísticas actualizadas",error:"Error al actualizar"})},S=w.useMemo(()=>i?i.reduce((n,N)=>n+N.ticketCount,0):0,[i]),k=w.useMemo(()=>!l||l.length===0?0:l.reduce((N,M)=>N+M.conversionRate,0)/l.length,[l]),D=w.useMemo(()=>o?.dropoffByStage?o.dropoffByStage.reduce((n,N)=>n+N.dropoffCount,0):0,[o]),E=n=>{if(n===null)return"-";const N=Math.floor(n/36e5),M=Math.floor(n%36e5/6e4);return N>24?`${Math.floor(N/24)}d ${N%24}h`:N>0?`${N}h ${M}m`:`${M}m`},F=n=>{switch(n){case"HUMAN":return e.jsx(de,{className:"w-4 h-4"});case"BOT":return e.jsx(He,{className:"w-4 h-4"});case"AI_AGENT":return e.jsx(Ke,{className:"w-4 h-4"});case"SYSTEM":return e.jsx(ds,{className:"w-4 h-4"});case"API":return e.jsx(Ve,{className:"w-4 h-4"});default:return e.jsx(de,{className:"w-4 h-4"})}},b=n=>{switch(n){case"HUMAN":return"Agente Humano";case"BOT":return"Bot/Workflow";case"AI_AGENT":return"Agente IA";case"SYSTEM":return"Sistema";case"API":return"API Externa";default:return n}},T=()=>{if(!i||!l)return;const n=[];n.push(`Reporte de Funnel: ${r?.name}`),n.push(`Período: ${t} días`),n.push(""),n.push("DISTRIBUCIÓN POR ETAPA"),n.push("Etapa,Tickets,Tiempo Promedio"),i.forEach(j=>{n.push(`"${j.stageName}",${j.ticketCount},${E(j.avgTimeInStageMs)}`)}),n.push(""),n.push("TASAS DE CONVERSIÓN"),n.push("Desde,Hacia,Tasa,Entrados,Convertidos"),l.forEach(j=>{n.push(`"${j.fromStageName}","${j.toStageName}",${(j.conversionRate*100).toFixed(1)}%,${j.totalEntered},${j.totalConverted}`)});const N=n.join(`
2
- `),M=new Blob([N],{type:"text/csv;charset=utf-8;"}),P=document.createElement("a");P.href=URL.createObjectURL(M),P.download=`reporte-funnel-${r?.name}-${new Date().toISOString().split("T")[0]}.csv`,P.click(),URL.revokeObjectURL(P.href),I.success("Reporte exportado correctamente")},g=i&&i.length>0;return e.jsxs("div",{className:"space-y-6 animate-in fade-in duration-500",children:[e.jsx(z,{className:"border border-slate-200/60 dark:border-slate-800 shadow-sm rounded-2xl bg-white dark:bg-slate-900",children:e.jsx($,{className:"p-4",children:e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 w-full sm:w-auto",children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-slate-50 dark:bg-slate-800 rounded-xl border border-slate-200/50 dark:border-slate-700",children:[e.jsx(ne,{className:"h-4 w-4 text-slate-400"}),e.jsxs(K,{value:u||"",onValueChange:a,children:[e.jsx(H,{className:"w-[180px] border-none bg-transparent h-8 focus:ring-0 text-sm font-semibold p-0 shadow-none text-slate-700 dark:text-slate-200",children:e.jsx(G,{placeholder:"Seleccionar funnel"})}),e.jsx(B,{className:"rounded-xl border-slate-200 shadow-xl",children:s.map(n=>e.jsx(A,{value:n.id,className:"rounded-lg font-medium",children:n.name},n.id))})]})]}),e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-slate-50 dark:bg-slate-800 rounded-xl border border-slate-200/50 dark:border-slate-700",children:[e.jsx(Js,{className:"h-4 w-4 text-slate-400"}),e.jsxs(K,{value:t.toString(),onValueChange:n=>d(parseInt(n)),children:[e.jsx(H,{className:"w-[140px] border-none bg-transparent h-8 focus:ring-0 text-sm font-semibold p-0 shadow-none text-slate-700 dark:text-slate-200",children:e.jsx(G,{})}),e.jsxs(B,{className:"rounded-xl border-slate-200 shadow-xl",children:[e.jsx(A,{value:"7",className:"rounded-lg font-medium",children:"Últimos 7 días"}),e.jsx(A,{value:"30",className:"rounded-lg font-medium",children:"Últimos 30 días"}),e.jsx(A,{value:"90",className:"rounded-lg font-medium",children:"Últimos 90 días"}),e.jsx(A,{value:"365",className:"rounded-lg font-medium",children:"Último año"})]})]})]}),h&&!x&&e.jsx(Z,{className:"h-4 w-4 animate-spin text-primary"})]}),e.jsxs("div",{className:"flex gap-2 w-full sm:w-auto",children:[g&&e.jsxs(y,{variant:"outline",onClick:T,className:"h-10 px-4 rounded-xl font-semibold text-sm border-slate-200 dark:border-slate-700 bg-white dark:bg-slate-800 hover:bg-slate-50 dark:hover:bg-slate-700 text-slate-600 dark:text-slate-300 flex-1 sm:flex-none",children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Exportar"]}),e.jsxs(y,{onClick:v,disabled:h||!u,className:"h-10 px-6 rounded-xl font-semibold text-sm bg-indigo-600 hover:bg-indigo-700 text-white shadow-lg shadow-indigo-500/20 flex-1 sm:flex-none",children:[h?e.jsx(Z,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(Re,{className:"h-4 w-4 mr-2"}),"Actualizar"]})]})]})})}),!g&&!x?e.jsx(z,{className:"border border-slate-200/60 dark:border-slate-800 shadow-sm rounded-2xl bg-white dark:bg-slate-900",children:e.jsx($,{className:"py-20",children:e.jsxs("div",{className:"flex flex-col items-center justify-center text-center",children:[e.jsx("div",{className:"w-20 h-20 bg-indigo-50 dark:bg-indigo-900/20 rounded-2xl flex items-center justify-center mb-6",children:e.jsx(Ie,{className:"h-10 w-10 text-indigo-500"})}),e.jsx("h3",{className:"text-xl font-bold text-slate-900 dark:text-white mb-2",children:"Estadísticas de Funnel"}),e.jsx("p",{className:"text-slate-500 max-w-sm mx-auto text-sm mb-6",children:u?"No hay tickets asignados a este funnel todavía.":"Selecciona un funnel para ver sus estadísticas."})]})})}):e.jsxs("div",{className:"space-y-6 animate-in fade-in slide-in-from-bottom-2 duration-500",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 xl:grid-cols-6 gap-4",children:[e.jsx(X,{icon:e.jsx(ea,{className:"h-5 w-5"}),value:x?null:S,label:"PIPELINE ACTIVO",sublabel:"En curso",color:"indigo",isLoading:x,tooltip:"Número de tickets abiertos actualmente en el embudo (excluye resueltos y archivados)."}),e.jsx(X,{icon:e.jsx(ca,{className:"h-5 w-5"}),value:x?null:`${(k*100).toFixed(1)}%`,label:"CONVERSIÓN",sublabel:"Promedio etapa",color:"emerald",isLoading:x,tooltip:"Tasa media de avance entre etapas consecutivas."}),e.jsx(X,{icon:e.jsx(Te,{className:"h-5 w-5"}),value:x?null:E(o?.avgCompletionTimeMs||0),label:"CICLO DE CIERRE",sublabel:"Tiempo medio",color:"rose",isLoading:x,tooltip:"Tiempo promedio que tarda un ticket desde que entra al funnel hasta que llega a la etapa final."}),e.jsx(X,{icon:e.jsx(ne,{className:"h-5 w-5"}),value:x?null:o?.totalResolved||0,label:"TICKETS GANADOS",sublabel:"Resueltos",color:"amber",isLoading:x,tooltip:"Tickets que han sido marcados como RESUELTOS dentro de este periodo."}),e.jsx(X,{icon:e.jsx(sa,{className:"h-5 w-5"}),value:x?null:D,label:"TICKETS PERDIDOS",sublabel:"Abandonos",color:"rose",isLoading:x,tooltip:"Tickets que salieron del funnel sin completarse (archivados)."}),e.jsx(X,{icon:e.jsx(ys,{className:"h-5 w-5"}),value:x?null:c?.length||0,label:"ACTORES",sublabel:"Interactuando",color:"indigo",isLoading:x,tooltip:"Diversidad de agentes (Humanos, Bots, IA) participando en el proceso."})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(z,{className:"border border-slate-200/60 dark:border-slate-800 shadow-sm rounded-2xl bg-white dark:bg-slate-900 overflow-hidden",children:e.jsxs($,{className:"p-6",children:[e.jsx("div",{className:"flex items-center justify-between mb-6",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"text-base font-bold text-slate-900 dark:text-white",children:"Distribución por Etapa"}),e.jsxs(Qe,{children:[e.jsx(Pe,{asChild:!0,children:e.jsx(y,{variant:"ghost",className:"h-6 w-6 p-0 rounded-full hover:bg-slate-100 dark:hover:bg-slate-800",children:e.jsx(ie,{className:"h-4 w-4 text-indigo-500 cursor-help"})})}),e.jsx(Oe,{className:"w-80 p-4 shadow-2xl border-indigo-100 dark:border-indigo-900/30",side:"right",align:"start",children:e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 pb-2 border-b border-slate-100 dark:border-slate-800",children:[e.jsx(Ee,{className:"h-4 w-4 text-indigo-500"}),e.jsx("span",{className:"font-bold text-slate-900 dark:text-white",children:"Guía: Inventario de Trabajo"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"font-semibold text-indigo-600 dark:text-indigo-400",children:"¿Qué me dice este tablero?"}),e.jsx("p",{className:"text-slate-600 dark:text-slate-400 text-xs leading-relaxed",children:"Es una radiografía de tu **carga de trabajo actual**. Solo muestra tickets abiertos para que el equipo se enfoque en lo que puede resolver **hoy**."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"font-semibold text-slate-800 dark:text-slate-200 text-xs",children:"Puntos de Atención:"}),e.jsxs("ul",{className:"list-disc pl-4 space-y-1.5 text-[11px] text-slate-600 dark:text-slate-400",children:[e.jsxs("li",{children:[e.jsx("span",{className:"font-bold text-slate-700 dark:text-slate-300",children:"Barras Largas:"})," Indican acumulación de trabajo. Si hay muchos tickets aquí, puede haber un cuello de botella."]}),e.jsxs("li",{children:[e.jsx("span",{className:"font-bold text-slate-700 dark:text-slate-300",children:"Tiempo Elevado (Reloj):"}),' Indica que los tickets están "atascados". Revisa si el equipo necesita apoyo en esa etapa.']})]})]}),e.jsx("div",{className:"bg-slate-50 dark:bg-slate-800/50 p-2 rounded-lg text-[10px] text-slate-500 italic",children:"Tip: Una distribución sana reparte los tickets de forma uniforme, con la mayoría moviéndose hacia las etapas finales (derecha/abajo)."})]})})]})]}),e.jsx("p",{className:"text-sm text-slate-500 mt-0.5",children:"Tickets actuales en cada etapa"})]})}),x?e.jsx("div",{className:"space-y-4",children:Array.from({length:4}).map((n,N)=>e.jsx(J,{className:"h-10 w-full rounded-lg"},N))}):!i||i.length===0?e.jsx(Ce,{label:"Sin datos de distribución"}):e.jsx("div",{className:"space-y-3",children:i.map((n,N)=>{const M=Math.max(...i.map(C=>C.ticketCount))||1,P=n.ticketCount/M*100,j=o?.dropoffByStage.find(C=>C.stageId===n.stageId);return e.jsxs("div",{className:"group",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-semibold text-slate-700 dark:text-slate-200",children:n.stageName}),N===i.length-1&&e.jsx(U,{className:"bg-emerald-100 text-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-400 text-[10px] h-4 px-1.5 border-none",children:"META"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"text-xs text-slate-400",children:[e.jsx(Te,{className:"w-3 h-3 inline mr-1"}),E(n.avgTimeInStageMs)]}),j&&j.dropoffCount>0&&e.jsx(_e,{children:e.jsxs(ze,{delayDuration:300,children:[e.jsx($e,{asChild:!0,children:e.jsxs("span",{className:"text-[10px] font-bold text-rose-500 bg-rose-50 dark:bg-rose-900/20 px-1.5 rounded-md cursor-help",children:["-",j.dropoffCount," perdidos"]})}),e.jsx(Ue,{children:e.jsx("p",{children:"Tickets que abandonaron el funnel en esta etapa."})})]})}),e.jsx("span",{className:"text-sm font-bold text-slate-900 dark:text-white",children:n.ticketCount})]})]}),e.jsx("div",{className:"w-full h-2 bg-slate-100 dark:bg-slate-800 rounded-full overflow-hidden",children:e.jsx("div",{className:p("h-full rounded-full transition-all duration-700",N===i.length-1?"bg-emerald-500":"bg-indigo-500"),style:{width:`${P}%`}})})]},n.stageId)})})]})}),e.jsx(z,{className:"border border-slate-200/60 dark:border-slate-800 shadow-sm rounded-2xl bg-white dark:bg-slate-900 overflow-hidden",children:e.jsxs($,{className:"p-6",children:[e.jsx("div",{className:"flex items-center justify-between mb-6",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"text-base font-bold text-slate-900 dark:text-white",children:"Tasas de Conversión"}),e.jsxs(Qe,{children:[e.jsx(Pe,{asChild:!0,children:e.jsx(y,{variant:"ghost",className:"h-6 w-6 p-0 rounded-full hover:bg-slate-100 dark:hover:bg-slate-800",children:e.jsx(ie,{className:"h-4 w-4 text-indigo-500 cursor-help"})})}),e.jsx(Oe,{className:"w-80 p-4 shadow-2xl border-indigo-100 dark:border-indigo-900/30",side:"right",align:"start",children:e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 pb-2 border-b border-slate-100 dark:border-slate-800",children:[e.jsx(ne,{className:"h-4 w-4 text-indigo-500"}),e.jsx("span",{className:"font-bold text-slate-900 dark:text-white",children:"Guía de Negocio: Conversión"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"font-semibold text-indigo-600 dark:text-indigo-400",children:"¿Qué mide este indicador?"}),e.jsx("p",{className:"text-slate-600 dark:text-slate-400 text-xs leading-relaxed",children:"Evalúa la **eficacia operativa**. No mide cuántos tickets tienes hoy, sino qué tan buena es tu operación moviendo prospectos hacia el cierre."})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"font-semibold text-slate-800 dark:text-slate-200 text-xs italic",children:"Interpretación de Resultados:"}),e.jsxs("ul",{className:"space-y-1.5 text-[11px]",children:[e.jsxs("li",{className:"flex gap-2 text-emerald-600 dark:text-emerald-400",children:[e.jsx("span",{className:"font-bold",children:"Alta (>70%):"})," Proceso fluido e interés alto. ¡Excelente!"]}),e.jsxs("li",{className:"flex gap-2 text-amber-600 dark:text-amber-400",children:[e.jsx("span",{className:"font-bold",children:"Media (40-70%):"})," Fricción normal. Revisa si falta seguimiento manual o automatizado."]}),e.jsxs("li",{className:"flex gap-2 text-rose-600 dark:text-rose-400",children:[e.jsx("span",{className:"font-bold",children:"Baja (<40%):"})," Alerta de fuga. Aquí estás perdiendo dinero y esfuerzo."]})]})]}),e.jsxs("div",{className:"bg-indigo-50 dark:bg-indigo-900/20 p-2 rounded-lg text-[10px] text-indigo-700 dark:text-indigo-300 leading-tight",children:[e.jsx("strong",{children:"Acción Sugerida:"})," Si detectas una tasa baja entre dos etapas, es el punto exacto donde debes mejorar tus mensajes o reducir tiempos de respuesta."]})]})})]})]}),e.jsx("p",{className:"text-sm text-slate-500 mt-0.5",children:"Entre etapas consecutivas"})]})}),x?e.jsx("div",{className:"space-y-4",children:Array.from({length:3}).map((n,N)=>e.jsx(J,{className:"h-16 w-full rounded-lg"},N))}):!l||l.length===0?e.jsx(Ce,{label:"Sin datos de conversión"}):e.jsx("div",{className:"space-y-3",children:l.map((n,N)=>e.jsxs("div",{className:"p-3 bg-slate-50 dark:bg-slate-800/50 rounded-xl border border-slate-100 dark:border-slate-700/50",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"text-sm font-medium text-slate-600 dark:text-slate-400 truncate",children:n.fromStageName}),e.jsx(te,{className:"w-4 h-4 text-slate-400 flex-shrink-0"}),e.jsx("span",{className:"text-sm font-medium text-slate-600 dark:text-slate-400 truncate",children:n.toStageName})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("span",{className:"text-xs text-slate-400",children:[n.totalEntered," entraron"]}),e.jsxs("span",{className:"text-xs text-slate-400",children:[n.totalConverted," avanzaron"]})]}),e.jsxs(U,{className:p("px-2 py-0.5 text-xs font-bold",n.conversionRate>=.7?"bg-emerald-100 text-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-400":n.conversionRate>=.4?"bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-400":"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400"),children:[(n.conversionRate*100).toFixed(1),"%"]})]})]},N))})]})})]}),e.jsx(z,{className:"border border-slate-200/60 dark:border-slate-800 shadow-sm rounded-2xl bg-white dark:bg-slate-900 overflow-hidden",children:e.jsxs($,{className:"p-6",children:[e.jsx("div",{className:"flex items-center justify-between mb-6",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-bold text-slate-900 dark:text-white",children:"Rendimiento por Actor"}),e.jsx("p",{className:"text-sm text-slate-500 mt-0.5",children:"Quién mueve los tickets en el funnel"})]})}),x?e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:Array.from({length:5}).map((n,N)=>e.jsx(J,{className:"h-24 w-full rounded-xl"},N))}):!c||c.length===0?e.jsx(Ce,{label:"Sin datos de actores"}):e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:c.map(n=>e.jsxs("div",{className:"p-4 bg-slate-50 dark:bg-slate-800/50 rounded-xl border border-slate-100 dark:border-slate-700/50 text-center",children:[e.jsx("div",{className:"w-10 h-10 mx-auto mb-2 rounded-xl bg-indigo-100 dark:bg-indigo-900/30 flex items-center justify-center text-indigo-600 dark:text-indigo-400",children:F(n.actorType)}),e.jsx("div",{className:"text-xl font-bold text-slate-900 dark:text-white",children:n.transitionCount}),e.jsx("div",{className:"text-xs font-medium text-slate-500",children:b(n.actorType)}),e.jsxs("div",{className:"text-xs text-slate-400 mt-1",children:[(n.percentage*100).toFixed(1),"%"]})]},n.actorType))})]})})]})]})}function X({icon:s,value:u,label:t,sublabel:a,color:d,isLoading:r,tooltip:i}){const c={indigo:{bg:"bg-indigo-50 dark:bg-indigo-900/20",icon:"text-indigo-500 dark:text-indigo-400"},emerald:{bg:"bg-emerald-50 dark:bg-emerald-900/20",icon:"text-emerald-500 dark:text-emerald-400"},amber:{bg:"bg-amber-50 dark:bg-amber-900/20",icon:"text-amber-500 dark:text-amber-400"},rose:{bg:"bg-rose-50 dark:bg-rose-900/20",icon:"text-rose-500 dark:text-rose-400"}}[d],o=e.jsx(z,{className:"border border-slate-200/60 dark:border-slate-800 shadow-sm rounded-2xl bg-white dark:bg-slate-900 overflow-hidden hover:shadow-md transition-shadow cursor-default",children:e.jsxs($,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsx("div",{className:p("w-10 h-10 rounded-xl flex items-center justify-center",c.bg),children:e.jsx("span",{className:c.icon,children:s})}),i&&e.jsx(ie,{className:"h-3.5 w-3.5 text-slate-300 dark:text-slate-600"})]}),e.jsxs("div",{children:[r?e.jsx(J,{className:"h-8 w-16 mb-1"}):e.jsx("div",{className:"text-2xl font-bold text-slate-900 dark:text-white tracking-tight",children:u??"-"}),e.jsx("div",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider mt-1",children:t}),e.jsx("div",{className:"text-xs text-slate-500 font-medium",children:a})]})]})});return i?e.jsx(_e,{children:e.jsxs(ze,{delayDuration:300,children:[e.jsx($e,{asChild:!0,children:o}),e.jsx(Ue,{className:"max-w-[200px] text-xs",children:i})]})}):o}function Ce({label:s}){return e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-slate-300 dark:text-slate-600",children:[e.jsx(Ie,{className:"h-10 w-10 mb-3 opacity-50"}),e.jsx("p",{className:"text-xs font-semibold text-slate-400 dark:text-slate-500",children:s})]})}const Da={ENTERED_FUNNEL:{label:"Entró al Funnel",icon:e.jsx(da,{className:"w-3 h-3"}),color:"text-emerald-600 dark:text-emerald-400",bgColor:"bg-emerald-100 dark:bg-emerald-900/30"},STAGE_CHANGED:{label:"Cambió de Etapa",icon:e.jsx(te,{className:"w-3 h-3"}),color:"text-blue-600 dark:text-blue-400",bgColor:"bg-blue-100 dark:bg-blue-900/30"},FUNNEL_CHANGED:{label:"Transferido",icon:e.jsx(la,{className:"w-3 h-3"}),color:"text-violet-600 dark:text-violet-400",bgColor:"bg-violet-100 dark:bg-violet-900/30"},EXITED_FUNNEL:{label:"Salió del Funnel",icon:e.jsx(Cs,{className:"w-3 h-3"}),color:"text-red-600 dark:text-red-400",bgColor:"bg-red-100 dark:bg-red-900/30"}},Ia={HUMAN:{icon:e.jsx(de,{className:"w-3 h-3"}),label:"Agente"},BOT:{icon:e.jsx(He,{className:"w-3 h-3"}),label:"Bot"},AI_AGENT:{icon:e.jsx(Ke,{className:"w-3 h-3"}),label:"IA"},SYSTEM:{icon:e.jsx(ds,{className:"w-3 h-3"}),label:"Sistema"},API:{icon:e.jsx(Ve,{className:"w-3 h-3"}),label:"API"}};function Aa({funnels:s}){const{selectedFunnelId:u,historyFilters:t,setSelectedFunnelId:a,setHistoryFilters:d}=ss(),{transitionType:r,actorType:i,page:l}=t;w.useEffect(()=>{!u&&s.length>0&&a(s[0].id)},[s,u,a]);const c=new Map;s.forEach(g=>{g.stages?.forEach(n=>{c.set(n.id,n.name)})});const{data:o,isLoading:x,isFetching:h}=Hs(u,{limit:20,offset:(l-1)*20,transitionType:r,actorType:i},!!u),f=g=>Da[g]||{label:g,icon:e.jsx(te,{className:"w-3 h-3"}),color:"text-slate-600 dark:text-slate-400",bgColor:"bg-slate-100 dark:bg-slate-800"},v=g=>Ia[g]||{icon:e.jsx(de,{className:"w-3 h-3"}),label:g},S=g=>{const n=new Date(g),M=new Date().getTime()-n.getTime(),P=Math.floor(M/6e4),j=Math.floor(M/36e5),C=Math.floor(M/864e5);return P<1?"Ahora":P<60?`${P}m`:j<24?`${j}h`:C<7?`${C}d`:aa(n,{style:"day-month"})},k=g=>{if(g===null)return"-";const n=Math.floor(g/36e5),N=Math.floor(g%36e5/6e4);return n>24?`${Math.floor(n/24)}d ${n%24}h`:n>0?`${n}h ${N}m`:`${N}m`},D=g=>g?c.get(g)||g.substring(0,8):"-",E=g=>g?s.find(n=>n.id===g)?.name||g.substring(0,8):"-",F=o?.data||[],b=o?.total||0,T=Math.ceil(b/20)||1;return e.jsxs("div",{className:"space-y-4 animate-in fade-in duration-300",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-white dark:bg-slate-900 border border-slate-200 dark:border-slate-800 rounded-xl",children:[e.jsx(ne,{className:"h-4 w-4 text-slate-400"}),e.jsxs(K,{value:u||"",onValueChange:g=>{a(g),d({page:1})},children:[e.jsx(H,{className:"w-[160px] border-none bg-transparent h-8 focus:ring-0 text-sm font-semibold p-0 shadow-none",children:e.jsx(G,{placeholder:"Seleccionar funnel"})}),e.jsx(B,{className:"rounded-xl",children:s.map(g=>e.jsx(A,{value:g.id,className:"rounded-lg",children:g.name},g.id))})]})]}),e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-white dark:bg-slate-900 border border-slate-200 dark:border-slate-800 rounded-xl",children:[e.jsx(V,{className:"h-4 w-4 text-slate-400"}),e.jsxs(K,{value:r,onValueChange:g=>d({transitionType:g,page:1}),children:[e.jsx(H,{className:"w-[140px] border-none bg-transparent h-8 focus:ring-0 text-sm font-semibold p-0 shadow-none",children:e.jsx(G,{})}),e.jsxs(B,{className:"rounded-xl",children:[e.jsx(A,{value:"all",className:"rounded-lg",children:"Todas las acciones"}),e.jsx(A,{value:"ENTERED_FUNNEL",className:"rounded-lg",children:"Entradas"}),e.jsx(A,{value:"STAGE_CHANGED",className:"rounded-lg",children:"Cambios de etapa"}),e.jsx(A,{value:"FUNNEL_CHANGED",className:"rounded-lg",children:"Transferencias"}),e.jsx(A,{value:"EXITED_FUNNEL",className:"rounded-lg",children:"Salidas"})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-white dark:bg-slate-900 border border-slate-200 dark:border-slate-800 rounded-xl",children:[e.jsx(de,{className:"h-4 w-4 text-slate-400"}),e.jsxs(K,{value:i,onValueChange:g=>d({actorType:g,page:1}),children:[e.jsx(H,{className:"w-[120px] border-none bg-transparent h-8 focus:ring-0 text-sm font-semibold p-0 shadow-none",children:e.jsx(G,{})}),e.jsxs(B,{className:"rounded-xl",children:[e.jsx(A,{value:"all",className:"rounded-lg",children:"Todos"}),e.jsx(A,{value:"HUMAN",className:"rounded-lg",children:"Agentes"}),e.jsx(A,{value:"BOT",className:"rounded-lg",children:"Bots"}),e.jsx(A,{value:"AI_AGENT",className:"rounded-lg",children:"IA"}),e.jsx(A,{value:"SYSTEM",className:"rounded-lg",children:"Sistema"}),e.jsx(A,{value:"API",className:"rounded-lg",children:"API"})]})]})]}),h&&e.jsx(Z,{className:"h-4 w-4 animate-spin text-primary"})]}),e.jsx(z,{className:"border border-slate-200/60 dark:border-slate-800 shadow-sm rounded-2xl bg-white dark:bg-slate-900 overflow-hidden",children:e.jsx($,{className:"p-0",children:x&&l===1?e.jsx("div",{className:"p-3 space-y-1",children:Array.from({length:10}).map((g,n)=>e.jsx(J,{className:"h-12 w-full rounded-lg"},n))}):u?F.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx("div",{className:"w-12 h-12 bg-slate-100 dark:bg-slate-800 rounded-xl flex items-center justify-center mb-3",children:e.jsx(os,{className:"h-6 w-6 text-slate-400"})}),e.jsx("p",{className:"text-sm font-medium text-slate-600 dark:text-slate-400",children:"Sin actividad registrada"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-12 gap-2 px-4 py-2 bg-slate-50 dark:bg-slate-800/50 border-b border-slate-100 dark:border-slate-800 text-[10px] font-bold uppercase tracking-wider text-slate-500",children:[e.jsx("div",{className:"col-span-2",children:"Acción"}),e.jsx("div",{className:"col-span-3",children:"Transición"}),e.jsx("div",{className:"col-span-2",children:"Actor"}),e.jsx("div",{className:"col-span-2",children:"Duración"}),e.jsx("div",{className:"col-span-2",children:"Ticket"}),e.jsx("div",{className:"col-span-1 text-right",children:"Fecha"})]}),e.jsx("div",{className:"divide-y divide-slate-100 dark:divide-slate-800/50",children:F.map(g=>{const n=f(g.transitionType),N=v(g.actorType);return e.jsxs("div",{className:"grid grid-cols-12 gap-2 px-4 py-2.5 items-center hover:bg-slate-50/50 dark:hover:bg-slate-800/20 transition-colors",children:[e.jsxs("div",{className:"col-span-2 flex items-center gap-2 min-w-0",children:[e.jsx("div",{className:p("w-6 h-6 rounded-lg flex items-center justify-center flex-shrink-0",n.bgColor,n.color),children:n.icon}),e.jsx("span",{className:"text-xs font-medium text-slate-800 dark:text-slate-200 truncate",children:n.label})]}),e.jsxs("div",{className:"col-span-3 flex items-center gap-1 min-w-0",children:[g.transitionType==="ENTERED_FUNNEL"&&e.jsxs("span",{className:"text-xs text-slate-500 truncate",children:["→ ",D(g.toStageId)]}),g.transitionType==="STAGE_CHANGED"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-xs text-slate-500 truncate max-w-[80px]",children:D(g.fromStageId)}),e.jsx(te,{className:"w-3 h-3 text-slate-400 flex-shrink-0"}),e.jsx("span",{className:"text-xs text-slate-600 dark:text-slate-300 font-medium truncate max-w-[80px]",children:D(g.toStageId)})]}),g.transitionType==="FUNNEL_CHANGED"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-xs text-slate-500 truncate max-w-[80px]",children:E(g.fromFunnelId)}),e.jsx(te,{className:"w-3 h-3 text-slate-400 flex-shrink-0"}),e.jsx("span",{className:"text-xs text-slate-600 dark:text-slate-300 font-medium truncate max-w-[80px]",children:E(g.toFunnelId)})]}),g.transitionType==="EXITED_FUNNEL"&&e.jsxs("span",{className:"text-xs text-slate-500 truncate",children:[D(g.fromStageId)," →"]})]}),e.jsxs("div",{className:"col-span-2 flex items-center gap-1.5 min-w-0",children:[e.jsx("div",{className:"w-5 h-5 rounded bg-slate-100 dark:bg-slate-800 flex items-center justify-center text-slate-500",children:N.icon}),e.jsx("span",{className:"text-xs text-slate-600 dark:text-slate-400",children:N.label})]}),e.jsx("div",{className:"col-span-2",children:e.jsx("span",{className:"text-xs text-slate-500",children:k(g.durationInPreviousStageMs)})}),e.jsx("div",{className:"col-span-2",children:e.jsx(U,{variant:"outline",className:"text-[10px] px-1.5 py-0.5 font-mono",children:g.ticketId.substring(0,8)})}),e.jsx("div",{className:"col-span-1 text-right",children:e.jsx("span",{className:"text-xs text-slate-400 font-medium",children:S(g.createdAt)})})]},g.id)})}),!x&&F.length>0&&e.jsxs("div",{className:"px-6 py-4 bg-slate-50/50 dark:bg-slate-800/30 border-t border-slate-100 dark:border-slate-800 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("span",{className:"text-[10px] font-black text-slate-400 uppercase tracking-widest",children:["Página"," ",e.jsx("span",{className:"text-slate-900 dark:text-white",children:l})," ","de"," ",e.jsx("span",{className:"text-slate-900 dark:text-white",children:T})]}),e.jsx("div",{className:"h-4 w-[1px] bg-slate-200 dark:bg-slate-700"}),e.jsxs("span",{className:"text-[10px] font-black text-slate-400 uppercase tracking-widest",children:["Total: ",e.jsx("span",{className:"text-primary",children:b})]})]}),T>1&&e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(y,{variant:"outline",size:"sm",onClick:()=>d({page:Math.max(1,l-1)}),disabled:l===1||h,className:"h-8 px-3 rounded-lg font-black text-[10px] uppercase tracking-wider",children:[e.jsx(Ss,{className:"h-3 w-3 mr-1"}),"Anterior"]}),e.jsxs(y,{variant:"outline",size:"sm",onClick:()=>d({page:Math.min(T,l+1)}),disabled:l===T||h,className:"h-8 px-3 rounded-lg font-black text-[10px] uppercase tracking-wider",children:["Siguiente",e.jsx(ks,{className:"h-3 w-3 ml-1"})]})]})]})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx("div",{className:"w-12 h-12 bg-slate-100 dark:bg-slate-800 rounded-xl flex items-center justify-center mb-3",children:e.jsx(ne,{className:"h-6 w-6 text-slate-400"})}),e.jsx("p",{className:"text-sm font-medium text-slate-600 dark:text-slate-400",children:"Selecciona un funnel"})]})})})]})}function ht(){const[s,u]=w.useState("funnels"),[t,a]=w.useState("comfortable"),{data:d,isLoading:r,error:i,refetch:l,isFetching:c}=Gs(),{data:o}=Bs(),{openCreateFunnelModal:x}=W(),h=t==="compact",f=w.useMemo(()=>{if(!d)return{totalFunnels:0,totalStages:0,totalTickets:0,totalTransitions:0};const S=d.length,k=d.reduce((F,b)=>F+(b.stages?.length||0),0),D=o?.reduce((F,b)=>F+b.totalTickets,0)||0,E=o?.reduce((F,b)=>F+b.transitionsToday,0)||0;return{totalFunnels:S,totalStages:k,totalTickets:D,totalTransitions:E}},[d,o]),v=()=>{switch(s){case"funnels":return e.jsx(Ea,{funnels:d||[],isLoading:r,error:i,density:t});case"stats":return e.jsx(Fa,{funnels:d||[]});case"history":return e.jsx(Aa,{funnels:d||[]});default:return null}};return e.jsx(Es,{children:e.jsxs("div",{className:"h-full overflow-y-auto no-scrollbar",children:[e.jsx(Fs,{title:"Funnels",description:"Gestiona tus embudos de ventas, etapas y métricas",icon:V,actions:e.jsxs(y,{onClick:x,className:"bg-primary hover:bg-primary/90 text-white shadow-lg shadow-primary/20 rounded-full",children:[e.jsx(he,{className:"h-4 w-4 mr-2"}),"Agregar Funnel"]})}),e.jsxs(Ds,{className:p("space-y-6 animate-in slide-in-from-bottom-4 fade-in duration-500",h&&"space-y-4"),children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4 px-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ee,{className:"h-4 w-4 text-slate-400"}),e.jsx("h2",{className:"text-xs font-black uppercase tracking-widest text-slate-400",children:"Resumen Rápido"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex bg-slate-100/50 dark:bg-slate-800/50 p-1 rounded-xl",children:[e.jsx(y,{variant:"ghost",size:"icon",onClick:()=>a("comfortable"),className:p("h-7 w-7 rounded-lg transition-all",t==="comfortable"?"bg-white dark:bg-slate-900 shadow-sm text-primary":"text-slate-400 hover:text-slate-600"),title:"Vista cómoda",children:e.jsx(Ys,{className:"h-3.5 w-3.5"})}),e.jsx(y,{variant:"ghost",size:"icon",onClick:()=>a("compact"),className:p("h-7 w-7 rounded-lg transition-all",t==="compact"?"bg-white dark:bg-slate-900 shadow-sm text-primary":"text-slate-400 hover:text-slate-600"),title:"Vista compacta",children:e.jsx(ta,{className:"h-3.5 w-3.5"})})]}),e.jsxs(y,{variant:"ghost",size:"sm",onClick:()=>l(),disabled:c,className:"h-8 px-3 text-xs text-slate-500 hover:text-primary",children:[e.jsx(Re,{className:p("h-3.5 w-3.5 mr-1.5",c&&"animate-spin")}),"Actualizar"]})]})]}),e.jsxs("div",{className:p("grid gap-4 transition-all duration-300",h?"grid-cols-2 md:grid-cols-4 gap-3":"grid-cols-1 md:grid-cols-2 lg:grid-cols-4"),children:[e.jsx(xe,{icon:e.jsx(V,{className:p("text-indigo-500",h?"w-4 h-4":"w-5 h-5")}),label:"Funnels Activos",value:f.totalFunnels,bgClass:"bg-indigo-50 dark:bg-indigo-900/10",isCompact:h,tooltip:"Número de embudos de venta activos en tu organización"}),e.jsx(xe,{icon:e.jsx(le,{className:p("text-emerald-500",h?"w-4 h-4":"w-5 h-5")}),label:"Total Etapas",value:f.totalStages,bgClass:"bg-emerald-50 dark:bg-emerald-900/10",isCompact:h,tooltip:"Suma de todas las etapas definidas en tus funnels"}),e.jsx(xe,{icon:e.jsx(ra,{className:p("text-violet-500",h?"w-4 h-4":"w-5 h-5")}),label:"Tickets en Funnels",value:f.totalTickets,bgClass:"bg-violet-50 dark:bg-violet-900/10",isCompact:h,tooltip:"Tickets activos asignados a algún funnel (excluye cerrados y archivados)"}),e.jsx(xe,{icon:e.jsx(Ee,{className:p("text-amber-500",h?"w-4 h-4":"w-5 h-5")}),label:"Movimientos Hoy",value:f.totalTransitions,bgClass:"bg-amber-50 dark:bg-amber-900/10",isCompact:h,tooltip:"Cambios de etapa o asignaciones a funnels realizados hoy"})]})]}),e.jsx(Is,{value:s,onValueChange:S=>u(S),children:e.jsxs(As,{className:p("p-1 bg-slate-100/80 dark:bg-slate-800/50 rounded-xl border border-slate-200/50 dark:border-slate-700/50",h?"h-9":"h-11"),children:[e.jsxs(ye,{value:"funnels",className:p("rounded-lg font-semibold data-[state=active]:bg-white data-[state=active]:text-slate-900 data-[state=active]:shadow-sm dark:data-[state=active]:bg-slate-900 dark:data-[state=active]:text-white transition-all",h?"h-7 px-3 text-xs":"h-9 px-5 text-sm"),children:[e.jsx(V,{className:p(h?"h-3 w-3 mr-1.5":"h-4 w-4 mr-2")}),"Funnels"]}),e.jsxs(ye,{value:"stats",className:p("rounded-lg font-semibold data-[state=active]:bg-white data-[state=active]:text-slate-900 data-[state=active]:shadow-sm dark:data-[state=active]:bg-slate-900 dark:data-[state=active]:text-white transition-all",h?"h-7 px-3 text-xs":"h-9 px-5 text-sm"),children:[e.jsx(Ie,{className:p(h?"h-3 w-3 mr-1.5":"h-4 w-4 mr-2")}),"Estadísticas"]}),e.jsxs(ye,{value:"history",className:p("rounded-lg font-semibold data-[state=active]:bg-white data-[state=active]:text-slate-900 data-[state=active]:shadow-sm dark:data-[state=active]:bg-slate-900 dark:data-[state=active]:text-white transition-all",h?"h-7 px-3 text-xs":"h-9 px-5 text-sm"),children:[e.jsx(os,{className:p(h?"h-3 w-3 mr-1.5":"h-4 w-4 mr-2")}),"Historial"]})]})}),v()]})]})})}const xe=({icon:s,label:u,value:t,bgClass:a,onClick:d,isInteractive:r,isCompact:i,tooltip:l})=>{const c=e.jsxs("div",{className:p("bg-white dark:bg-slate-900 border border-slate-100 dark:border-slate-800 shadow-sm flex items-center transition-all duration-300 group",i?"p-3 rounded-xl gap-3":"p-5 rounded-[24px] gap-5",r?"cursor-pointer hover:shadow-xl hover:-translate-y-1 hover:border-primary/20":"hover:shadow-lg",l&&"cursor-help"),onClick:d,children:[e.jsx("div",{className:p("rounded-xl flex items-center justify-center shrink-0 shadow-inner group-hover:scale-110 transition-transform duration-300",a,i?"w-10 h-10":"w-14 h-14 rounded-2xl"),children:s}),e.jsxs("div",{children:[e.jsx("div",{className:"flex items-baseline gap-1",children:e.jsx("p",{className:p("font-black text-slate-900 dark:text-white leading-none tracking-tighter",i?"text-xl":"text-3xl"),children:typeof t=="number"?t.toLocaleString():t})}),e.jsx("p",{className:p("uppercase font-black text-slate-400 tracking-widest",i?"text-[9px] mt-1":"text-[11px] mt-2"),children:u})]})]});return l?e.jsxs("div",{className:"relative group/tooltip",children:[c,e.jsxs("div",{className:"absolute z-50 left-1/2 -translate-x-1/2 top-full mt-2 px-3 py-2 bg-slate-900 text-white text-xs rounded-lg shadow-lg opacity-0 pointer-events-none group-hover/tooltip:opacity-100 transition-opacity duration-200 max-w-[220px] text-center whitespace-normal",children:[l,e.jsx("div",{className:"absolute left-1/2 -translate-x-1/2 -top-1 w-2 h-2 bg-slate-900 rotate-45"})]})]}):c};export{Le as CreateFunnelModal,Sa as CreateStageModal,wa as EditFunnelModal,Na as FunnelCard,ht as FunnelsPage,ms as META_FUNNEL_EVENT_TYPES,qe as StageCard,ft as funnelStatsKeys,_ as funnelsApi,m as funnelsKeys,jt as useActorPerformance,bt as useCompletionStats,vt as useConversionRates,ua as useCreateFunnel,xa as useCreateFunnelStage,ma as useDeleteFunnel,ha as useDeleteFunnelStage,Ks as useFunnelAllStats,Nt as useFunnelDetailQuery,Hs as useFunnelHistory,wt as useFunnelStagesQuery,ss as useFunnelStatsStore,Bs as useFunnelSummary,W as useFunnelsActions,ja as useFunnelsExpanded,Gs as useFunnelsQuery,Ae as useFunnelsStore,ba as useFunnelsUIState,yt as useInvalidateFunnelStats,pa as useMoveStage,xt as useReorderStages,St as useTicketDistribution,ga as useToggleFunnelActive,fa as useToggleStageActive,cs as useUpdateFunnel,us as useUpdateFunnelStage};