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 +1 @@
1
- import{aA as e}from"./index-DsyZ_FlA.js";import"./recharts-DrC5kNsx.js";const o=e;export{o as EventTypesSettingsPage,e as default};
1
+ import{ay as e}from"./index-43NA2pdZ.js";import"./recharts-DrC5kNsx.js";const o=e;export{o as EventTypesSettingsPage,e as default};
@@ -0,0 +1 @@
1
+ import{ay as e}from"./index-43NA2pdZ.js";import"./recharts-DrC5kNsx.js";export{e as default};
@@ -0,0 +1 @@
1
+ import{ay as e}from"./index-43NA2pdZ.js";import"./recharts-DrC5kNsx.js";export{e as default};
@@ -1 +1 @@
1
- import{c as ge,aR as be,b as pe,j as e,at as fe,aS as je,$ as Ne,h as ye,s as ve,ax as ke,a0 as we,aT as Ce,aa as R,n as x,I as S,B as b,o as W,D as $,G as Se,aU as De,aV as Ee,aW as ze,a3 as Te,a4 as Le,a5 as Ie,a6 as Ae,y as Oe,a7 as He,ac as _e,R as Be,t as o,aL as Pe}from"./index-DsyZ_FlA.js";import{b as t}from"./recharts-DrC5kNsx.js";import{C as D,b as E,c as z,d as T,a as L}from"./card-DcKsxjXK.js";import{S as Me,a as Re,b as We,c as $e,d as Ue}from"./select-DlB_BbfM.js";import{S as q}from"./switch-ODBa0fCT.js";import{P as Fe,a as Ge,b as Ve}from"./page-components-o2TF52HV.js";import"./checkbox-pcbjC0d3.js";import"./table-CvSELOPi.js";import{S as ee}from"./save-Dua2yhWl.js";import"./index-KbFmSzBE.js";const Ze=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],Ye=ge("server",Ze);be.create({baseURL:pe.defaults.baseURL,timeout:1e4});function se({description:a}){return e.jsxs("div",{className:"flex flex-col gap-3 rounded-xl border border-dashed border-border bg-muted/30 p-5 opacity-80 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-muted",children:e.jsx(fe,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:"Disponible en Nubot"}),a&&e.jsx("p",{className:"text-xs text-muted-foreground",children:a})]})]}),e.jsxs("a",{href:je,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1.5 self-start rounded-lg border border-border px-3 py-1.5 text-xs font-medium text-foreground hover:bg-accent sm:self-auto",children:[e.jsx(Ne,{className:"h-3.5 w-3.5"}),"Conocer Nubot"]})]})}const ds=()=>{const{currentOrganization:a,fetchOrgSettings:p,updateOrgSettings:f,updateOrganization:I,deleteOrganization:h}=ye(),[c,j]=t.useState(10),[N,y]=t.useState("America/Lima"),[r,n]=t.useState(""),[A,U]=t.useState(!1),[d,F]=t.useState(!1),[O,G]=t.useState(!1),[re,v]=t.useState(!1),[te,l]=t.useState(!1),[ne,V]=t.useState(!1),[u,H]=t.useState(!1),[_,Z]=t.useState("08:00"),[B,Y]=t.useState("17:00"),g=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],ie={monday:"Lun",tuesday:"Mar",wednesday:"Mié",thursday:"Jue",friday:"Vie",saturday:"Sáb",sunday:"Dom"},[P,k]=t.useState([...g]),[w,M]=t.useState(!0),[C,Q]=t.useState(null),[de,J]=t.useState(!1),K=t.useCallback(async s=>{J(!0);try{const i=await ve.getWorkerHealth(s);Q(i)}catch(i){console.warn("[WorkerHealth] Failed to fetch worker health:",i),Q(null)}finally{J(!1)}},[]);t.useEffect(()=>{a&&(p(a.id),n(a.name))},[a?.id,p,a?.name,K]),t.useEffect(()=>{a?.inactivityThresholdMinutes&&j(a.inactivityThresholdMinutes)},[a?.inactivityThresholdMinutes]),t.useEffect(()=>{a?.timezone&&y(a.timezone)},[a?.timezone]),t.useEffect(()=>{const s=a?.businessHours;s?(H(!0),Z(s.start||"08:00"),Y(s.end||"17:00"),s.days&&s.days.length>0?(k(s.days),M(s.days.length===g.length)):(k([...g]),M(!0))):H(!1)},[a?.businessHours]);const oe=async()=>{if(a){if(!r.trim()){o.error("El nombre no puede estar vacío");return}U(!0);try{await I(a.id,r),o.success("Nombre de organización actualizado"),V(!1)}catch{o.error("Error al actualizar el nombre"),n(a.name)}finally{U(!1)}}},le=s=>{n(s),V(s!==a?.name)},ce=async()=>{if(a){if(u&&_>=B){o.error("El horario de inicio debe ser anterior al de fin.");return}if(u&&!w&&P.length===0){o.error("Selecciona al menos un día para el horario de atención.");return}F(!0);try{const s=u?{start:_,end:B,...w?{}:{days:P}}:null;await f(a.id,{inactivityThresholdMinutes:c,timezone:N,businessHours:s}),o.success("Configuración guardada"),l(!1)}catch{o.error("Error al guardar la configuración")}finally{F(!1)}}},me=s=>{y(s),l(!0)},xe=s=>{const i=Math.min(60,Math.max(1,s));j(i),l(i!==a?.inactivityThresholdMinutes)},he=async()=>{if(a){G(!0);try{await h(a.id),o.success("Organización eliminada exitosamente"),v(!1),window.location.href="/dashboard"}catch(s){const i=s?.response?.data?.message||"Error al eliminar la organización";o.error(i),v(!1)}finally{G(!1)}}},m=a?.role==="OWNER";return a?e.jsxs(Fe,{children:[e.jsx(Ge,{title:"Configuración General",description:"Gestione los ajustes principales de su organización.",icon:ke}),e.jsx(we,{children:e.jsxs(Ve,{maxWidth:"5xl",className:"space-y-8 animate-in fade-in duration-500 pb-20",children:[C&&C.hasDedicatedQueues&&e.jsx(Je,{queues:C.queues,checkedAt:C.checkedAt,isLoading:de,onRefresh:()=>a&&K(a.id)}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 pb-2 border-b border-border/40",children:[e.jsx("div",{className:"h-8 w-8 rounded-lg bg-primary/10 flex items-center justify-center text-primary",children:e.jsx(Ce,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold tracking-tight",children:"Identidad y Perfil"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Información visible de su organización."})]})]}),e.jsxs(D,{className:"border-border/40 shadow-sm bg-card transition-all hover:bg-accent/5",children:[e.jsxs(E,{className:"pb-3",children:[e.jsxs(z,{className:"text-xs font-bold uppercase tracking-wider text-muted-foreground flex items-center gap-2",children:[e.jsx(R,{className:"h-3.5 w-3.5 text-blue-500"}),"Nombre Público"]}),e.jsx(T,{className:"text-[10px] text-muted-foreground/70",children:"Este nombre será visible para los miembros de su equipo y en sus comunicaciones."})]}),e.jsxs(L,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-end gap-3",children:[e.jsxs("div",{className:"space-y-2 flex-1",children:[e.jsx(x,{htmlFor:"orgName",className:"text-xs font-semibold",children:"Nombre Mostrado"}),e.jsx("div",{className:"relative",children:e.jsx(S,{id:"orgName",value:r,onChange:s=>le(s.target.value),className:"max-w-md h-9",disabled:!m||A,placeholder:"Ej. Mi Empresa"})})]}),m&&e.jsxs(b,{onClick:oe,disabled:!ne||A||!r.trim(),className:"h-9 gap-2 font-bold",size:"sm",children:[A?e.jsx(W,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(ee,{className:"h-3.5 w-3.5"}),"Guardar"]})]}),!m&&e.jsxs("p",{className:"text-[10px] text-muted-foreground flex items-center gap-1.5 p-2 bg-muted/50 rounded-md border border-border/50 max-w-md",children:[e.jsx(R,{className:"h-3 w-3"}),"Solo el propietario puede modificar este ajuste."]})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 pb-2",children:[e.jsx("div",{className:"h-8 w-8 rounded-lg bg-orange-500/10 flex items-center justify-center text-orange-600 dark:text-orange-400",children:e.jsx($,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold tracking-tight",children:"Operaciones"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configuración de comportamiento del sistema y agentes."})]})]}),e.jsxs(D,{className:"border-border/40 shadow-sm bg-card transition-all hover:bg-accent/5",children:[e.jsxs(E,{className:"pb-3",children:[e.jsxs(z,{className:"text-xs font-bold uppercase tracking-wider text-muted-foreground flex items-center gap-2",children:[e.jsx($,{className:"h-3.5 w-3.5 text-orange-500"}),"Umbral de Inactividad"]}),e.jsx(T,{className:"text-[10px] text-muted-foreground/70",children:'Tiempo antes de considerar a un asesor como "ausente" o "inactivo".'})]}),e.jsx(L,{className:"space-y-4",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-4 p-3 border border-border/60 rounded-lg bg-background",children:[e.jsxs("div",{className:"space-y-1 flex-1",children:[e.jsx(x,{htmlFor:"inactivityThreshold",className:"text-sm font-medium",children:"Tiempo límite (minutos)"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Recomendado: 5-15 minutos para equipos activos."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(S,{id:"inactivityThreshold",type:"number",min:1,max:60,value:c,onChange:s=>xe(parseInt(s.target.value)||10),className:"w-20 h-9 text-center font-bold",disabled:d}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"min"})]})]}),e.jsx("div",{className:"flex justify-end pt-2",children:e.jsxs(b,{onClick:ce,disabled:!te||d,className:"h-8 text-xs font-bold px-4",size:"sm",children:[d?e.jsx(W,{className:"h-3.5 w-3.5 animate-spin mr-1.5"}):e.jsx(ee,{className:"h-3.5 w-3.5 mr-1.5"}),"Actualizar Configuración"]})})]})})]}),e.jsxs(D,{className:"border-border/40 shadow-sm bg-card transition-all hover:bg-accent/5",children:[e.jsxs(E,{className:"pb-3",children:[e.jsxs(z,{className:"text-xs font-bold uppercase tracking-wider text-muted-foreground flex items-center gap-2",children:[e.jsx(Se,{className:"h-3.5 w-3.5 text-blue-500"}),"Zona Horaria del Sistema"]}),e.jsx(T,{className:"text-[10px] text-muted-foreground/70",children:"Zona horaria global de la organización. Se usa para las variables de fecha en workflows y automatizaciones."})]}),e.jsx(L,{className:"space-y-4",children:e.jsxs("div",{className:"flex items-center gap-4 p-3 border border-border/60 rounded-lg bg-background",children:[e.jsxs("div",{className:"space-y-1 flex-1",children:[e.jsx(x,{htmlFor:"timezone",className:"text-sm font-medium",children:"Zona Horaria"}),e.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["Afecta las variables ",e.jsx("code",{className:"text-[10px] bg-muted px-1 rounded",children:"{{date.hour}}"}),", ",e.jsx("code",{className:"text-[10px] bg-muted px-1 rounded",children:"{{date.dayOfWeek}}"}),", etc. en workflows."]})]}),e.jsxs(Me,{value:N,onValueChange:me,disabled:d,children:[e.jsx(Re,{className:"w-56 h-9",children:e.jsx(We,{placeholder:"Seleccionar zona horaria"})}),e.jsx($e,{children:De.map(s=>e.jsx(Ue,{value:s.id,children:s.label},s.id))})]})]})})]}),e.jsxs(D,{className:"border-border/40 shadow-sm bg-card transition-all hover:bg-accent/5",children:[e.jsx(E,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(z,{className:"text-xs font-bold uppercase tracking-wider text-muted-foreground flex items-center gap-2",children:[e.jsx($,{className:"h-3.5 w-3.5 text-green-500"}),"Horario de Atención"]}),e.jsx(T,{className:"text-[10px] text-muted-foreground/70 mt-1",children:"Define el horario de atención de tu negocio. Los agentes IA usarán este dato para adaptar su comportamiento (ej: invitar a llamada solo en horario)."})]}),e.jsx(q,{checked:u,onCheckedChange:s=>{H(s),l(!0)},disabled:d})]})}),u&&e.jsxs(L,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-4 p-3 border border-border/60 rounded-lg bg-background",children:[e.jsxs("div",{className:"space-y-1 flex-1",children:[e.jsx(x,{className:"text-sm font-medium",children:"Rango horario"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Formato 24 horas. Ej: 08:00 a 17:20."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(S,{type:"time",value:_,onChange:s=>{Z(s.target.value),l(!0)},className:"w-28 h-9 text-center font-mono",disabled:d}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"a"}),e.jsx(S,{type:"time",value:B,onChange:s=>{Y(s.target.value),l(!0)},className:"w-28 h-9 text-center font-mono",disabled:d})]})]}),e.jsxs("div",{className:"p-3 border border-border/60 rounded-lg bg-background space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(x,{className:"text-sm font-medium",children:"Días de atención"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Selecciona los días en que aplica este horario."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(x,{htmlFor:"bhAllDays",className:"text-xs text-muted-foreground",children:"Todos"}),e.jsx(q,{id:"bhAllDays",checked:w,onCheckedChange:s=>{M(s),s&&k([...g]),l(!0)},disabled:d})]})]}),!w&&e.jsx("div",{className:"flex flex-wrap gap-2",children:g.map(s=>{const i=P.includes(s);return e.jsx("button",{type:"button",onClick:()=>{k(X=>i?X.filter(ue=>ue!==s):[...X,s]),l(!0)},disabled:d,className:`px-3 py-1.5 text-xs font-medium rounded-md border transition-colors ${i?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-border hover:bg-accent"}`,children:ie[s]},s)})})]}),e.jsxs("p",{className:"text-[10px] text-muted-foreground/70 flex items-center gap-1.5",children:[e.jsx(R,{className:"h-3 w-3"}),"Usa la zona horaria configurada arriba. Solo afecta a agentes IA de esta organización."]})]})]})]}),m&&e.jsxs("div",{className:"space-y-4 pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 pb-2",children:[e.jsx("div",{className:"h-8 w-8 rounded-lg bg-indigo-500/10 flex items-center justify-center text-indigo-600 dark:text-indigo-400",children:e.jsx(Ee,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold tracking-tight",children:"Seguridad y Acceso"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Control de dominios y políticas de autenticación."})]})]}),e.jsx(se,{description:"Inicio de sesión con la cuenta de tu empresa (SSO) y dominios propios."})]}),m&&e.jsxs("div",{className:"space-y-4 pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 pb-2",children:[e.jsx("div",{className:"h-8 w-8 rounded-lg bg-sky-500/10 flex items-center justify-center text-sky-600 dark:text-sky-400",children:e.jsx(ze,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold tracking-tight",children:"Pasarelas de Pago"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Conecta tu cuenta para cobrar pagos en los formularios."})]})]}),e.jsx(se,{description:"Cobros con Mercado Pago, Stripe o Culqi dentro de los formularios."})]}),m&&!Pe,e.jsx(Te,{open:re,onOpenChange:v,children:e.jsxs(Le,{children:[e.jsxs(Ie,{children:[e.jsxs(Ae,{className:"flex items-center gap-2 text-red-600",children:[e.jsx(Oe,{className:"h-5 w-5"}),"¿Eliminar Organización?"]}),e.jsx(He,{className:"space-y-3 pt-2",asChild:!0,children:e.jsxs("div",{children:[e.jsxs("p",{children:["Esta acción es ",e.jsx("strong",{children:"irreversible"}),". Se eliminará permanentemente la organización",e.jsxs("strong",{children:[" ",a?.name]}),"."]}),e.jsx("div",{className:"p-3 rounded-lg bg-slate-100 dark:bg-slate-800 text-slate-600 dark:text-slate-300 text-sm",children:e.jsxs("ul",{className:"list-disc pl-4 space-y-1",children:[e.jsx("li",{children:"Verificaremos que no existan tickets, contactos ni canales activos."}),e.jsx("li",{children:"Si existen recursos, la eliminación fallará por seguridad."})]})})]})})]}),e.jsxs(_e,{children:[e.jsx(b,{variant:"outline",onClick:()=>v(!1),disabled:O,children:"Cancelar"}),e.jsxs(b,{variant:"destructive",onClick:he,disabled:O,className:"gap-2",children:[O&&e.jsx(W,{className:"h-4 w-4 animate-spin"}),"Sí, eliminar definitivamente"]})]})]})})]})})]}):null},ae={active:{bgClass:"bg-green-50 dark:bg-green-950/30",borderClass:"border-green-200 dark:border-green-800",iconClass:"text-green-600 dark:text-green-400",dotClass:"bg-green-500",label:"Activo",description:"El worker está procesando jobs normalmente."},idle:{bgClass:"bg-green-50 dark:bg-green-950/30",borderClass:"border-green-200 dark:border-green-800",iconClass:"text-green-600 dark:text-green-400",dotClass:"bg-green-500",label:"Conectado (inactivo)",description:"El worker está conectado y esperando jobs."},likely_missing:{bgClass:"bg-red-50 dark:bg-red-950/30",borderClass:"border-red-300 dark:border-red-800",iconClass:"text-red-600 dark:text-red-400",dotClass:"bg-red-500 animate-pulse",label:"No disponible",description:"Hay jobs en espera pero no se detecta un worker procesando. Los workflows y campañas no se ejecutarán hasta que el worker esté desplegado."},not_provisioned:{bgClass:"bg-amber-50 dark:bg-amber-950/30",borderClass:"border-amber-300 dark:border-amber-800",iconClass:"text-amber-600 dark:text-amber-400",dotClass:"bg-amber-500",label:"No provisionado",description:"La cola dedicada está configurada pero el worker nunca se ha iniciado."},unknown:{bgClass:"bg-muted/50",borderClass:"border-border",iconClass:"text-muted-foreground",dotClass:"bg-gray-400",label:"Desconocido",description:"No se pudo determinar el estado del worker."}},Qe={campaign:"Campañas",workflow:"Workflows"};function Je({queues:a,checkedAt:p,isLoading:f,onRefresh:I}){const h=a.some(r=>r.workerStatus==="likely_missing"||r.workerStatus==="not_provisioned"),c=a.every(r=>r.workerStatus==="active"||r.workerStatus==="idle"),j=h?"bg-red-50 dark:bg-red-950/20":c?"bg-green-50 dark:bg-green-950/20":"bg-muted/30",N=h?"border-red-200 dark:border-red-800/50":c?"border-green-200 dark:border-green-800/50":"border-border",y=h?"text-red-600 dark:text-red-400":c?"text-green-600 dark:text-green-400":"text-muted-foreground";return e.jsxs("div",{className:`rounded-lg border ${N} ${j} p-4 space-y-3 transition-colors duration-700`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(Ye,{className:`h-4.5 w-4.5 ${y}`}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Workers Dedicados"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Estado de los workers dedicados de esta organización."})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[10px] text-muted-foreground/60",children:new Date(p).toLocaleTimeString()}),e.jsxs(b,{variant:"ghost",size:"sm",onClick:I,disabled:f,className:"h-7 px-2 text-xs gap-1.5",children:[e.jsx(Be,{className:`h-3 w-3 ${f?"animate-spin":""}`}),"Verificar"]})]})]}),e.jsx("div",{className:"grid gap-2",children:a.map(r=>{const n=ae[r.workerStatus]||ae.unknown;return e.jsxs("div",{className:`flex items-start gap-3 p-3 rounded-md border transition-colors duration-700 ${n.borderClass} ${n.bgClass}`,children:[e.jsx("div",{className:`mt-0.5 h-2 w-2 rounded-full ${n.dotClass}`}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-semibold",children:Qe[r.type]||r.type}),e.jsx("span",{className:`text-[10px] font-medium px-1.5 py-0.5 rounded-full ${n.bgClass} ${n.iconClass}`,children:n.label}),r.waiting>0&&e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[r.waiting," en espera"]}),r.failed>0&&e.jsxs("span",{className:"text-[10px] text-red-600 dark:text-red-400 font-medium",children:[r.failed," fallido",r.failed!==1?"s":""]})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-0.5 leading-relaxed",children:n.description}),e.jsxs("p",{className:"text-[10px] text-muted-foreground/60 mt-0.5 font-mono",children:["Cola: ",r.queueName]})]})]},r.queueName)})})]})}export{ds as GeneralSettingsPage};
1
+ import{c as ge,b0 as be,b as pe,j as e,ar as fe,b1 as je,Y as Ne,h as ye,aW as ve,aL as ke,Z as we,aV as Ce,a8 as R,n as x,I as S,B as b,o as W,y as $,G as Se,b2 as Ee,aK as De,b3 as ze,a1 as Te,a2 as Le,a3 as Ie,a4 as Ae,w as Oe,a5 as He,aa as _e,R as Be,t as o,aT as Pe}from"./index-43NA2pdZ.js";import{b as t}from"./recharts-DrC5kNsx.js";import{C as E,b as D,c as z,d as T,a as L}from"./card-DdbmSh-v.js";import{S as Me,a as Re,b as We,c as $e,d as Ue}from"./select-DCY_lg9j.js";import{S as q}from"./switch-C7XmAU1c.js";import{P as Fe,a as Ge,b as Ve}from"./page-components-DXOKtt_M.js";import"./checkbox-CuJh5AMO.js";import"./table-7NGq0kRw.js";import{S as ee}from"./save-mwkHDnDL.js";import"./index-KbFmSzBE.js";const Ze=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],Ye=ge("server",Ze);be.create({baseURL:pe.defaults.baseURL,timeout:1e4});function se({description:a}){return e.jsxs("div",{className:"flex flex-col gap-3 rounded-xl border border-dashed border-border bg-muted/30 p-5 opacity-80 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-muted",children:e.jsx(fe,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:"Disponible en Nubot"}),a&&e.jsx("p",{className:"text-xs text-muted-foreground",children:a})]})]}),e.jsxs("a",{href:je,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1.5 self-start rounded-lg border border-border px-3 py-1.5 text-xs font-medium text-foreground hover:bg-accent sm:self-auto",children:[e.jsx(Ne,{className:"h-3.5 w-3.5"}),"Conocer Nubot"]})]})}const ds=()=>{const{currentOrganization:a,fetchOrgSettings:p,updateOrgSettings:f,updateOrganization:I,deleteOrganization:h}=ye(),[c,j]=t.useState(10),[N,y]=t.useState("America/Lima"),[r,n]=t.useState(""),[A,U]=t.useState(!1),[d,F]=t.useState(!1),[O,G]=t.useState(!1),[re,v]=t.useState(!1),[te,l]=t.useState(!1),[ne,V]=t.useState(!1),[u,H]=t.useState(!1),[_,Z]=t.useState("08:00"),[B,Y]=t.useState("17:00"),g=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],ie={monday:"Lun",tuesday:"Mar",wednesday:"Mié",thursday:"Jue",friday:"Vie",saturday:"Sáb",sunday:"Dom"},[P,k]=t.useState([...g]),[w,M]=t.useState(!0),[C,K]=t.useState(null),[de,Q]=t.useState(!1),J=t.useCallback(async s=>{Q(!0);try{const i=await ve.getWorkerHealth(s);K(i)}catch(i){console.warn("[WorkerHealth] Failed to fetch worker health:",i),K(null)}finally{Q(!1)}},[]);t.useEffect(()=>{a&&(p(a.id),n(a.name))},[a?.id,p,a?.name,J]),t.useEffect(()=>{a?.inactivityThresholdMinutes&&j(a.inactivityThresholdMinutes)},[a?.inactivityThresholdMinutes]),t.useEffect(()=>{a?.timezone&&y(a.timezone)},[a?.timezone]),t.useEffect(()=>{const s=a?.businessHours;s?(H(!0),Z(s.start||"08:00"),Y(s.end||"17:00"),s.days&&s.days.length>0?(k(s.days),M(s.days.length===g.length)):(k([...g]),M(!0))):H(!1)},[a?.businessHours]);const oe=async()=>{if(a){if(!r.trim()){o.error("El nombre no puede estar vacío");return}U(!0);try{await I(a.id,r),o.success("Nombre de organización actualizado"),V(!1)}catch{o.error("Error al actualizar el nombre"),n(a.name)}finally{U(!1)}}},le=s=>{n(s),V(s!==a?.name)},ce=async()=>{if(a){if(u&&_>=B){o.error("El horario de inicio debe ser anterior al de fin.");return}if(u&&!w&&P.length===0){o.error("Selecciona al menos un día para el horario de atención.");return}F(!0);try{const s=u?{start:_,end:B,...w?{}:{days:P}}:null;await f(a.id,{inactivityThresholdMinutes:c,timezone:N,businessHours:s}),o.success("Configuración guardada"),l(!1)}catch{o.error("Error al guardar la configuración")}finally{F(!1)}}},me=s=>{y(s),l(!0)},xe=s=>{const i=Math.min(60,Math.max(1,s));j(i),l(i!==a?.inactivityThresholdMinutes)},he=async()=>{if(a){G(!0);try{await h(a.id),o.success("Organización eliminada exitosamente"),v(!1),window.location.href="/dashboard"}catch(s){const i=s?.response?.data?.message||"Error al eliminar la organización";o.error(i),v(!1)}finally{G(!1)}}},m=a?.role==="OWNER";return a?e.jsxs(Fe,{children:[e.jsx(Ge,{title:"Configuración General",description:"Gestione los ajustes principales de su organización.",icon:ke}),e.jsx(we,{children:e.jsxs(Ve,{maxWidth:"5xl",className:"space-y-8 animate-in fade-in duration-500 pb-20",children:[C&&C.hasDedicatedQueues&&e.jsx(Qe,{queues:C.queues,checkedAt:C.checkedAt,isLoading:de,onRefresh:()=>a&&J(a.id)}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 pb-2 border-b border-border/40",children:[e.jsx("div",{className:"h-8 w-8 rounded-lg bg-primary/10 flex items-center justify-center text-primary",children:e.jsx(Ce,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold tracking-tight",children:"Identidad y Perfil"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Información visible de su organización."})]})]}),e.jsxs(E,{className:"border-border/40 shadow-sm bg-card transition-all hover:bg-accent/5",children:[e.jsxs(D,{className:"pb-3",children:[e.jsxs(z,{className:"text-xs font-bold uppercase tracking-wider text-muted-foreground flex items-center gap-2",children:[e.jsx(R,{className:"h-3.5 w-3.5 text-blue-500"}),"Nombre Público"]}),e.jsx(T,{className:"text-[10px] text-muted-foreground/70",children:"Este nombre será visible para los miembros de su equipo y en sus comunicaciones."})]}),e.jsxs(L,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-end gap-3",children:[e.jsxs("div",{className:"space-y-2 flex-1",children:[e.jsx(x,{htmlFor:"orgName",className:"text-xs font-semibold",children:"Nombre Mostrado"}),e.jsx("div",{className:"relative",children:e.jsx(S,{id:"orgName",value:r,onChange:s=>le(s.target.value),className:"max-w-md h-9",disabled:!m||A,placeholder:"Ej. Mi Empresa"})})]}),m&&e.jsxs(b,{onClick:oe,disabled:!ne||A||!r.trim(),className:"h-9 gap-2 font-bold",size:"sm",children:[A?e.jsx(W,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(ee,{className:"h-3.5 w-3.5"}),"Guardar"]})]}),!m&&e.jsxs("p",{className:"text-[10px] text-muted-foreground flex items-center gap-1.5 p-2 bg-muted/50 rounded-md border border-border/50 max-w-md",children:[e.jsx(R,{className:"h-3 w-3"}),"Solo el propietario puede modificar este ajuste."]})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 pb-2",children:[e.jsx("div",{className:"h-8 w-8 rounded-lg bg-orange-500/10 flex items-center justify-center text-orange-600 dark:text-orange-400",children:e.jsx($,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold tracking-tight",children:"Operaciones"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configuración de comportamiento del sistema y agentes."})]})]}),e.jsxs(E,{className:"border-border/40 shadow-sm bg-card transition-all hover:bg-accent/5",children:[e.jsxs(D,{className:"pb-3",children:[e.jsxs(z,{className:"text-xs font-bold uppercase tracking-wider text-muted-foreground flex items-center gap-2",children:[e.jsx($,{className:"h-3.5 w-3.5 text-orange-500"}),"Umbral de Inactividad"]}),e.jsx(T,{className:"text-[10px] text-muted-foreground/70",children:'Tiempo antes de considerar a un asesor como "ausente" o "inactivo".'})]}),e.jsx(L,{className:"space-y-4",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-4 p-3 border border-border/60 rounded-lg bg-background",children:[e.jsxs("div",{className:"space-y-1 flex-1",children:[e.jsx(x,{htmlFor:"inactivityThreshold",className:"text-sm font-medium",children:"Tiempo límite (minutos)"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Recomendado: 5-15 minutos para equipos activos."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(S,{id:"inactivityThreshold",type:"number",min:1,max:60,value:c,onChange:s=>xe(parseInt(s.target.value)||10),className:"w-20 h-9 text-center font-bold",disabled:d}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"min"})]})]}),e.jsx("div",{className:"flex justify-end pt-2",children:e.jsxs(b,{onClick:ce,disabled:!te||d,className:"h-8 text-xs font-bold px-4",size:"sm",children:[d?e.jsx(W,{className:"h-3.5 w-3.5 animate-spin mr-1.5"}):e.jsx(ee,{className:"h-3.5 w-3.5 mr-1.5"}),"Actualizar Configuración"]})})]})})]}),e.jsxs(E,{className:"border-border/40 shadow-sm bg-card transition-all hover:bg-accent/5",children:[e.jsxs(D,{className:"pb-3",children:[e.jsxs(z,{className:"text-xs font-bold uppercase tracking-wider text-muted-foreground flex items-center gap-2",children:[e.jsx(Se,{className:"h-3.5 w-3.5 text-blue-500"}),"Zona Horaria del Sistema"]}),e.jsx(T,{className:"text-[10px] text-muted-foreground/70",children:"Zona horaria global de la organización. Se usa para las variables de fecha en workflows y automatizaciones."})]}),e.jsx(L,{className:"space-y-4",children:e.jsxs("div",{className:"flex items-center gap-4 p-3 border border-border/60 rounded-lg bg-background",children:[e.jsxs("div",{className:"space-y-1 flex-1",children:[e.jsx(x,{htmlFor:"timezone",className:"text-sm font-medium",children:"Zona Horaria"}),e.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["Afecta las variables ",e.jsx("code",{className:"text-[10px] bg-muted px-1 rounded",children:"{{date.hour}}"}),", ",e.jsx("code",{className:"text-[10px] bg-muted px-1 rounded",children:"{{date.dayOfWeek}}"}),", etc. en workflows."]})]}),e.jsxs(Me,{value:N,onValueChange:me,disabled:d,children:[e.jsx(Re,{className:"w-56 h-9",children:e.jsx(We,{placeholder:"Seleccionar zona horaria"})}),e.jsx($e,{children:Ee.map(s=>e.jsx(Ue,{value:s.id,children:s.label},s.id))})]})]})})]}),e.jsxs(E,{className:"border-border/40 shadow-sm bg-card transition-all hover:bg-accent/5",children:[e.jsx(D,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(z,{className:"text-xs font-bold uppercase tracking-wider text-muted-foreground flex items-center gap-2",children:[e.jsx($,{className:"h-3.5 w-3.5 text-green-500"}),"Horario de Atención"]}),e.jsx(T,{className:"text-[10px] text-muted-foreground/70 mt-1",children:"Define el horario de atención de tu negocio. Los agentes IA usarán este dato para adaptar su comportamiento (ej: invitar a llamada solo en horario)."})]}),e.jsx(q,{checked:u,onCheckedChange:s=>{H(s),l(!0)},disabled:d})]})}),u&&e.jsxs(L,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-4 p-3 border border-border/60 rounded-lg bg-background",children:[e.jsxs("div",{className:"space-y-1 flex-1",children:[e.jsx(x,{className:"text-sm font-medium",children:"Rango horario"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Formato 24 horas. Ej: 08:00 a 17:20."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(S,{type:"time",value:_,onChange:s=>{Z(s.target.value),l(!0)},className:"w-28 h-9 text-center font-mono",disabled:d}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"a"}),e.jsx(S,{type:"time",value:B,onChange:s=>{Y(s.target.value),l(!0)},className:"w-28 h-9 text-center font-mono",disabled:d})]})]}),e.jsxs("div",{className:"p-3 border border-border/60 rounded-lg bg-background space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(x,{className:"text-sm font-medium",children:"Días de atención"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Selecciona los días en que aplica este horario."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(x,{htmlFor:"bhAllDays",className:"text-xs text-muted-foreground",children:"Todos"}),e.jsx(q,{id:"bhAllDays",checked:w,onCheckedChange:s=>{M(s),s&&k([...g]),l(!0)},disabled:d})]})]}),!w&&e.jsx("div",{className:"flex flex-wrap gap-2",children:g.map(s=>{const i=P.includes(s);return e.jsx("button",{type:"button",onClick:()=>{k(X=>i?X.filter(ue=>ue!==s):[...X,s]),l(!0)},disabled:d,className:`px-3 py-1.5 text-xs font-medium rounded-md border transition-colors ${i?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-border hover:bg-accent"}`,children:ie[s]},s)})})]}),e.jsxs("p",{className:"text-[10px] text-muted-foreground/70 flex items-center gap-1.5",children:[e.jsx(R,{className:"h-3 w-3"}),"Usa la zona horaria configurada arriba. Solo afecta a agentes IA de esta organización."]})]})]})]}),m&&e.jsxs("div",{className:"space-y-4 pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 pb-2",children:[e.jsx("div",{className:"h-8 w-8 rounded-lg bg-indigo-500/10 flex items-center justify-center text-indigo-600 dark:text-indigo-400",children:e.jsx(De,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold tracking-tight",children:"Seguridad y Acceso"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Control de dominios y políticas de autenticación."})]})]}),e.jsx(se,{description:"Inicio de sesión con la cuenta de tu empresa (SSO) y dominios propios."})]}),m&&e.jsxs("div",{className:"space-y-4 pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 pb-2",children:[e.jsx("div",{className:"h-8 w-8 rounded-lg bg-sky-500/10 flex items-center justify-center text-sky-600 dark:text-sky-400",children:e.jsx(ze,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold tracking-tight",children:"Pasarelas de Pago"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Conecta tu cuenta para cobrar pagos en los formularios."})]})]}),e.jsx(se,{description:"Cobros con Mercado Pago, Stripe o Culqi dentro de los formularios."})]}),m&&!Pe,e.jsx(Te,{open:re,onOpenChange:v,children:e.jsxs(Le,{children:[e.jsxs(Ie,{children:[e.jsxs(Ae,{className:"flex items-center gap-2 text-red-600",children:[e.jsx(Oe,{className:"h-5 w-5"}),"¿Eliminar Organización?"]}),e.jsx(He,{className:"space-y-3 pt-2",asChild:!0,children:e.jsxs("div",{children:[e.jsxs("p",{children:["Esta acción es ",e.jsx("strong",{children:"irreversible"}),". Se eliminará permanentemente la organización",e.jsxs("strong",{children:[" ",a?.name]}),"."]}),e.jsx("div",{className:"p-3 rounded-lg bg-slate-100 dark:bg-slate-800 text-slate-600 dark:text-slate-300 text-sm",children:e.jsxs("ul",{className:"list-disc pl-4 space-y-1",children:[e.jsx("li",{children:"Verificaremos que no existan tickets, contactos ni canales activos."}),e.jsx("li",{children:"Si existen recursos, la eliminación fallará por seguridad."})]})})]})})]}),e.jsxs(_e,{children:[e.jsx(b,{variant:"outline",onClick:()=>v(!1),disabled:O,children:"Cancelar"}),e.jsxs(b,{variant:"destructive",onClick:he,disabled:O,className:"gap-2",children:[O&&e.jsx(W,{className:"h-4 w-4 animate-spin"}),"Sí, eliminar definitivamente"]})]})]})})]})})]}):null},ae={active:{bgClass:"bg-green-50 dark:bg-green-950/30",borderClass:"border-green-200 dark:border-green-800",iconClass:"text-green-600 dark:text-green-400",dotClass:"bg-green-500",label:"Activo",description:"El worker está procesando jobs normalmente."},idle:{bgClass:"bg-green-50 dark:bg-green-950/30",borderClass:"border-green-200 dark:border-green-800",iconClass:"text-green-600 dark:text-green-400",dotClass:"bg-green-500",label:"Conectado (inactivo)",description:"El worker está conectado y esperando jobs."},likely_missing:{bgClass:"bg-red-50 dark:bg-red-950/30",borderClass:"border-red-300 dark:border-red-800",iconClass:"text-red-600 dark:text-red-400",dotClass:"bg-red-500 animate-pulse",label:"No disponible",description:"Hay jobs en espera pero no se detecta un worker procesando. Los workflows y campañas no se ejecutarán hasta que el worker esté desplegado."},not_provisioned:{bgClass:"bg-amber-50 dark:bg-amber-950/30",borderClass:"border-amber-300 dark:border-amber-800",iconClass:"text-amber-600 dark:text-amber-400",dotClass:"bg-amber-500",label:"No provisionado",description:"La cola dedicada está configurada pero el worker nunca se ha iniciado."},unknown:{bgClass:"bg-muted/50",borderClass:"border-border",iconClass:"text-muted-foreground",dotClass:"bg-gray-400",label:"Desconocido",description:"No se pudo determinar el estado del worker."}},Ke={campaign:"Campañas",workflow:"Workflows"};function Qe({queues:a,checkedAt:p,isLoading:f,onRefresh:I}){const h=a.some(r=>r.workerStatus==="likely_missing"||r.workerStatus==="not_provisioned"),c=a.every(r=>r.workerStatus==="active"||r.workerStatus==="idle"),j=h?"bg-red-50 dark:bg-red-950/20":c?"bg-green-50 dark:bg-green-950/20":"bg-muted/30",N=h?"border-red-200 dark:border-red-800/50":c?"border-green-200 dark:border-green-800/50":"border-border",y=h?"text-red-600 dark:text-red-400":c?"text-green-600 dark:text-green-400":"text-muted-foreground";return e.jsxs("div",{className:`rounded-lg border ${N} ${j} p-4 space-y-3 transition-colors duration-700`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(Ye,{className:`h-4.5 w-4.5 ${y}`}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Workers Dedicados"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Estado de los workers dedicados de esta organización."})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[10px] text-muted-foreground/60",children:new Date(p).toLocaleTimeString()}),e.jsxs(b,{variant:"ghost",size:"sm",onClick:I,disabled:f,className:"h-7 px-2 text-xs gap-1.5",children:[e.jsx(Be,{className:`h-3 w-3 ${f?"animate-spin":""}`}),"Verificar"]})]})]}),e.jsx("div",{className:"grid gap-2",children:a.map(r=>{const n=ae[r.workerStatus]||ae.unknown;return e.jsxs("div",{className:`flex items-start gap-3 p-3 rounded-md border transition-colors duration-700 ${n.borderClass} ${n.bgClass}`,children:[e.jsx("div",{className:`mt-0.5 h-2 w-2 rounded-full ${n.dotClass}`}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-semibold",children:Ke[r.type]||r.type}),e.jsx("span",{className:`text-[10px] font-medium px-1.5 py-0.5 rounded-full ${n.bgClass} ${n.iconClass}`,children:n.label}),r.waiting>0&&e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[r.waiting," en espera"]}),r.failed>0&&e.jsxs("span",{className:"text-[10px] text-red-600 dark:text-red-400 font-medium",children:[r.failed," fallido",r.failed!==1?"s":""]})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-0.5 leading-relaxed",children:n.description}),e.jsxs("p",{className:"text-[10px] text-muted-foreground/60 mt-0.5 font-mono",children:["Cola: ",r.queueName]})]})]},r.queueName)})})]})}export{ds as GeneralSettingsPage};
@@ -0,0 +1 @@
1
+ import{c as Oe,i as We,a as Pe,g as Ze,au as P,aW as Je,u as Xe,as as Ye,t as u,j as e,B as h,R as me,aL as ea,a9 as ue,n as y,y as aa,S as sa,I as S,r as J,a1 as _e,a2 as Be,a3 as He,a4 as $e,J as ta,a5 as ra,aa as na}from"./index-43NA2pdZ.js";import{b as c}from"./recharts-DrC5kNsx.js";import{C as M,a as O,b as ia,c as la}from"./card-DdbmSh-v.js";import{T as ca}from"./textarea-B1anutjq.js";import{S as he,a as xe,b as ge,c as pe,d as X}from"./select-DCY_lg9j.js";import{T as oa,a as da,b as U,c as I,d as ma,e as w}from"./table-7NGq0kRw.js";import{S as q}from"./stat-card-W7s_-fHW.js";import{S as ua}from"./skeleton-CN6xlRXP.js";import{A as je,h as fe,a as ve,b as ye,c as Ce,d as Ne,e as we,f as Se,g as be}from"./alert-dialog-gzZZoAiu.js";import{f as ha}from"./index-YR5X3nd4.js";import{c as v}from"./connectionsService-BJg4S1e9.js";import{C as Ee}from"./calendar-Bu0aDtW1.js";import{C as De}from"./circle-x-decmm7ip.js";import{C as xa}from"./calendar-days-CXtOZxOF.js";import{C as ga}from"./circle-check-big-BOZQ_2Kv.js";import{M as Te}from"./map-pin-COYHwobx.js";import{U as pa}from"./user-l48WDfDH.js";import{E as ke}from"./eye-CR5C6hVv.js";import{S as Ie}from"./square-pen-Dbn7xmc-.js";import{T as Ae}from"./trash-2-D_kmHMwn.js";const ja=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["circle",{cx:"10",cy:"12",r:"2",key:"737tya"}],["path",{d:"m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22",key:"wt3hpn"}]],qa=Oe("file-image",ja);const fa=[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]],Va=Oe("keyboard",fa),Y="org-members";function Ka(){const s=We(),n=Pe(p=>p.user)?.organizationId,t=Ze({queryKey:[Y,n],queryFn:async()=>n?Je.getMembers(n):[],enabled:!!n,staleTime:300*1e3});return c.useEffect(()=>{if(!n)return;const p=f=>{s.setQueryData([Y,n],o=>o&&o.map(m=>m.user.id===f.userId?{...m,user:{...m.user,availabilityStatus:f.status}}:m))},g=f=>{s.setQueryData([Y,n],o=>o&&o.map(m=>m.user.id===f.userId?{...m,user:{...m.user,lastActivityAt:f.lastActivityAt}}:m))};P.onAdvisorStatus(p),P.onAdvisorActivity(g)},[n,s]),t}const va={summary:"",description:"",startDate:"",startTime:"",endDate:"",endTime:"",location:"",attendees:""},V=s=>s.toISOString().slice(0,10),Fe=s=>s.toTimeString().slice(0,5),ya=s=>{const d=s.start.dateTime?new Date(s.start.dateTime):null,n=s.end.dateTime?new Date(s.end.dateTime):null;return{summary:s.summary||"",description:s.description||"",startDate:d?V(d):s.start.date||"",startTime:d?Fe(d):"09:00",endDate:n?V(n):s.end.date||"",endTime:n?Fe(n):"10:00",location:s.location||"",attendees:s.attendees?.map(t=>t.email).join(", ")||""}},Ge=(s,d)=>{const n={summary:s.summary};return s.description&&(n.description=s.description),s.location&&(n.location=s.location),n.start={dateTime:new Date(`${s.startDate}T${s.startTime}`).toISOString(),timeZone:d},n.end={dateTime:new Date(`${s.endDate}T${s.endTime}`).toISOString(),timeZone:d},s.attendees.trim()&&(n.attendees=s.attendees.split(",").map(t=>t.trim()).filter(Boolean).map(t=>({email:t}))),n},Le=s=>s?new Date(s).toLocaleDateString("es-ES",{day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"}):"N/A",ze=s=>{if(s.start.dateTime){const d=new Date(s.start.dateTime),n=new Date(s.end.dateTime);return`${d.toLocaleDateString("es-ES",{day:"2-digit",month:"short",hour:"2-digit",minute:"2-digit"})} - ${n.toLocaleTimeString("es-ES",{hour:"2-digit",minute:"2-digit"})}`}return s.start.date?`${s.start.date} (todo el día)`:"N/A"},A=s=>{if(s.start.dateTime)return new Date(s.start.dateTime)>new Date;if(s.start.date){const d=s.start.date,n=new Date().toISOString().split("T")[0];return d>=n}return!1},F=s=>{const d=new Date().toISOString().split("T")[0];return s.start.dateTime?s.start.dateTime.startsWith(d):s.start.date?s.start.date===d:!1},Me=({open:s,onOpenChange:d,title:n,description:t,initialData:p,isSubmitting:g,onSubmit:f})=>{const[o,m]=c.useState(p);c.useEffect(()=>{s&&m(p)},[s,p]);const j=(i,L)=>m(_=>({..._,[i]:L})),G=o.summary.trim()&&o.startDate&&o.startTime&&o.endDate&&o.endTime;return e.jsx(_e,{open:s,onOpenChange:d,children:e.jsxs(Be,{className:"sm:max-w-lg max-h-[85vh] overflow-y-auto",children:[e.jsxs(He,{children:[e.jsx($e,{children:n}),e.jsx(ra,{children:t})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(y,{htmlFor:"evt-summary",children:"Título *"}),e.jsx(S,{id:"evt-summary",value:o.summary,onChange:i=>j("summary",i.target.value),placeholder:"Reunión de equipo"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(y,{htmlFor:"evt-desc",children:"Descripción"}),e.jsx(ca,{id:"evt-desc",value:o.description,onChange:i=>j("description",i.target.value),placeholder:"Detalles del evento...",rows:3})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(y,{htmlFor:"evt-start-date",children:"Fecha inicio *"}),e.jsx(S,{id:"evt-start-date",type:"date",value:o.startDate,onChange:i=>j("startDate",i.target.value)})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(y,{htmlFor:"evt-start-time",children:"Hora inicio *"}),e.jsx(S,{id:"evt-start-time",type:"time",value:o.startTime,onChange:i=>j("startTime",i.target.value)})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(y,{htmlFor:"evt-end-date",children:"Fecha fin *"}),e.jsx(S,{id:"evt-end-date",type:"date",value:o.endDate,onChange:i=>j("endDate",i.target.value)})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(y,{htmlFor:"evt-end-time",children:"Hora fin *"}),e.jsx(S,{id:"evt-end-time",type:"time",value:o.endTime,onChange:i=>j("endTime",i.target.value)})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(y,{htmlFor:"evt-location",children:"Ubicación"}),e.jsx(S,{id:"evt-location",value:o.location,onChange:i=>j("location",i.target.value),placeholder:"Oficina, Google Meet, etc."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(y,{htmlFor:"evt-attendees",children:"Invitados (emails separados por coma)"}),e.jsx(S,{id:"evt-attendees",value:o.attendees,onChange:i=>j("attendees",i.target.value),placeholder:"user@ejemplo.com, otro@ejemplo.com"})]})]}),e.jsxs(na,{children:[e.jsx(h,{variant:"outline",onClick:()=>d(!1),disabled:g,children:"Cancelar"}),e.jsx(h,{onClick:()=>f(o),disabled:!G||g,children:g?"Guardando...":"Guardar"})]})]})})},Qa=()=>{const s=Xe(),{channels:d,fetchChannels:n}=Ye(),[t,p]=c.useState(null),[g,f]=c.useState(null),[o,m]=c.useState([]),[j,G]=c.useState([]),[i,L]=c.useState("primary"),[_,ee]=c.useState(!0),[b,ae]=c.useState(!1),[B,se]=c.useState(!1),[Ca,Na]=c.useState(!1),[wa,Sa]=c.useState(!1),[x,te]=c.useState({search:"",calendarId:"_all"}),[l,D]=c.useState(null),[Re,K]=c.useState(!1),[Ue,Q]=c.useState(!1),[z,W]=c.useState(null),[re,H]=c.useState(!1),[$,ne]=c.useState(null),ie=Intl.DateTimeFormat().resolvedOptions().timeZone,E=d.filter(a=>a.type==="CALENDAR"&&!a.deletedAt);c.useEffect(()=>{n()},[n]),c.useEffect(()=>{E.length>0&&!t&&p(E[0])},[E,t]);const Z=c.useCallback(async()=>{if(t){ee(!0);try{const a=await v.getGoogleCalendarStatus(t.id);if(f(a),a.config?.selectedCalendarId&&L(a.config.selectedCalendarId),a.status==="connected"){const r=await v.listGoogleCalendars(t.id);m(r)}}catch{u.error("Error al cargar estado")}finally{ee(!1)}}},[t]),T=c.useCallback(async()=>{if(!(!t||g?.status!=="connected")){ae(!0);try{const a=await v.listGoogleCalendarEvents({channelId:t.id,calendarId:x.calendarId!=="_all"?x.calendarId:i,maxResults:100});G(a)}catch{u.error("Error al cargar eventos")}finally{ae(!1)}}},[t,g?.status,i,x.calendarId]);c.useEffect(()=>{Z()},[Z]),c.useEffect(()=>{if(g?.status==="connected"){T();const a=x.calendarId!=="_all"?x.calendarId:i;t&&a&&v.subscribeGoogleCalendarWatch(t.id,a).catch(()=>{})}},[g?.status,i,T,t,x.calendarId]),c.useEffect(()=>{const a=Pe.getState().user,r=a?.organizationId;if(!r||!a?.id)return;P.getConnectionStatus()||P.connect(a.id,r);const C=P.onCalendarEventsUpdate(N=>{N.channelId===t?.id&&(N.calendarId===i||x.calendarId==="_all"||N.calendarId===x.calendarId)&&G(N.events)});return()=>{C()}},[t?.id,i,x.calendarId]);const le=async()=>{se(!0);try{const{url:a}=await v.getGoogleCalendarAuthUrl();if(!a){u.error("No se pudo obtener URL de autorización");return}window.location.href=a}catch(a){u.error(a.message||"Error al iniciar OAuth")}finally{se(!1)}},qe=async a=>{if(!t)return;L(a),(await v.updateGoogleCalendarConfig({selectedCalendarId:a},t.id)).success&&(u.success("Calendario actualizado"),T())},Ve=async a=>{if(t){H(!0);try{const r=Ge(a,ie);await v.createGoogleCalendarEvent(r,i,t.id)?(u.success("Evento creado"),K(!1),T()):u.error("Error al crear evento")}catch{u.error("Error al crear evento")}finally{H(!1)}}},Ke=async a=>{if(!(!z||!t)){H(!0);try{const r=Ge(a,ie);await v.updateGoogleCalendarEvent(z.id,r,i,t.id)?(u.success("Evento actualizado"),Q(!1),W(null),T()):u.error("Error al actualizar evento")}catch{u.error("Error al actualizar evento")}finally{H(!1)}}},ce=async a=>{if(t){ne(a);try{(await v.deleteGoogleCalendarEvent(a,i,t.id)).success?(u.success("Evento eliminado"),G(C=>C.filter(N=>N.id!==a)),l?.id===a&&D(null)):u.error("Error al eliminar evento")}catch{u.error("Error al eliminar evento")}finally{ne(null)}}},oe=a=>{W(a),Q(!0)},k=j.filter(a=>{if(x.search){const r=x.search.toLowerCase();return a.summary?.toLowerCase().includes(r)||a.description?.toLowerCase().includes(r)||a.location?.toLowerCase().includes(r)}return!0}),R={total:k.length,upcoming:k.filter(A).length,today:k.filter(F).length,past:k.filter(a=>!A(a)&&!F(a)).length},Qe={...va,startDate:V(new Date),startTime:"09:00",endDate:V(new Date),endTime:"10:00"},de=g?.status==="connected";return e.jsxs("div",{className:"container mx-auto py-8 max-w-7xl space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-3xl font-bold tracking-tight flex items-center gap-3",children:[e.jsx(ha,{className:"h-8 w-8 text-[#4285F4]"}),"Google Calendar"]}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Administra tus calendarios y eventos de Google."})]}),e.jsxs("div",{className:"flex gap-2",children:[de&&e.jsxs(e.Fragment,{children:[e.jsxs(h,{variant:"outline",onClick:()=>{T(),Z()},disabled:_||b,children:[e.jsx(me,{className:`mr-2 h-4 w-4 ${_||b?"animate-spin":""}`}),"Actualizar"]}),e.jsxs(h,{variant:"outline",onClick:()=>s("/conexiones/google-calendar"),children:[e.jsx(ea,{className:"mr-2 h-4 w-4"}),"Configuración"]})]}),E.length>0&&e.jsx(h,{onClick:le,disabled:B,className:"bg-[#4285F4] hover:bg-[#3367D6] text-white",children:B?e.jsxs(e.Fragment,{children:[e.jsx(me,{className:"mr-2 h-4 w-4 animate-spin"}),"Conectando..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"mr-2 h-4 w-4"}),"Nueva Conexión"]})})]})]}),E.length>1&&e.jsx(M,{children:e.jsx(O,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(y,{className:"text-sm font-semibold",children:"Cuenta de Google:"}),e.jsxs(he,{value:t?.id||"",onValueChange:a=>{const r=E.find(C=>C.id===a);p(r||null)},children:[e.jsx(xe,{className:"w-[300px]",children:e.jsx(ge,{placeholder:"Seleccionar cuenta"})}),e.jsx(pe,{children:E.map(a=>e.jsx(X,{value:a.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[a.credentials?.picture&&e.jsx("img",{src:a.credentials.picture,alt:"",className:"w-5 h-5 rounded-full"}),e.jsx("span",{children:a.name})]})},a.id))})]})]})})}),t?de?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsx(q,{title:"Total Eventos",value:R.total,icon:xa,iconColor:"text-primary",iconBgColor:"bg-primary/10",loading:b}),e.jsx(q,{title:"Próximos",value:R.upcoming,icon:aa,iconColor:"text-blue-600",iconBgColor:"bg-blue-100",loading:b}),e.jsx(q,{title:"Hoy",value:R.today,icon:ga,iconColor:"text-emerald-600",iconBgColor:"bg-emerald-100",loading:b}),e.jsx(q,{title:"Pasados",value:R.past,icon:De,iconColor:"text-amber-600",iconBgColor:"bg-amber-100",loading:b})]}),e.jsx(M,{children:e.jsx(O,{className:"pt-6",children:e.jsxs("div",{className:"flex flex-wrap gap-4",children:[e.jsx("div",{className:"flex-1 min-w-[200px]",children:e.jsxs("div",{className:"relative",children:[e.jsx(sa,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(S,{placeholder:"Buscar por título, descripción, ubicación...",className:"pl-10",value:x.search,onChange:a=>te(r=>({...r,search:a.target.value}))})]})}),o.length>0&&e.jsxs(he,{value:x.calendarId,onValueChange:a=>{te(r=>({...r,calendarId:a})),a!=="_all"&&(L(a),qe(a))},children:[e.jsx(xe,{className:"w-[200px]",children:e.jsx(ge,{placeholder:"Calendario"})}),e.jsxs(pe,{children:[e.jsx(X,{value:"_all",children:"Todos los calendarios"}),o.map(a=>e.jsx(X,{value:a.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[a.backgroundColor&&e.jsx("span",{className:"w-3 h-3 rounded-full inline-block",style:{backgroundColor:a.backgroundColor}}),e.jsxs("span",{children:[a.summary,a.primary&&" (Principal)"]})]})},a.id))]})]})]})})}),e.jsxs(M,{children:[e.jsx(ia,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(la,{className:"text-lg font-medium",children:"Lista de Eventos"}),e.jsxs(h,{size:"sm",onClick:()=>K(!0),className:"bg-[#4285F4] hover:bg-[#3367D6] text-white",children:[e.jsx(ue,{className:"mr-2 h-4 w-4"}),"Nuevo Evento"]})]})}),e.jsx(O,{className:"p-0",children:e.jsxs(oa,{children:[e.jsx(da,{children:e.jsxs(U,{className:"bg-muted/50",children:[e.jsx(I,{children:"Título"}),e.jsx(I,{children:"Fecha y Hora"}),e.jsx(I,{children:"Ubicación"}),e.jsx(I,{children:"Invitados"}),e.jsx(I,{children:"Estado"}),e.jsx(I,{className:"w-[120px]"})]})}),e.jsx(ma,{children:b?Array.from({length:5}).map((a,r)=>e.jsx(U,{children:Array.from({length:6}).map((C,N)=>e.jsx(w,{children:e.jsx(ua,{className:"h-5 w-full"})},N))},r)):k.length===0?e.jsx(U,{children:e.jsxs(w,{colSpan:6,className:"h-32 text-center",children:[e.jsx(Ee,{className:"mx-auto h-10 w-10 text-muted-foreground/50 mb-2"}),e.jsx("p",{className:"text-muted-foreground",children:"No hay eventos para mostrar"})]})}):k.map(a=>e.jsxs(U,{className:"cursor-pointer hover:bg-muted/50",onClick:()=>D(a),children:[e.jsx(w,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:a.summary||"(Sin título)"}),a.description&&e.jsx("p",{className:"text-xs text-muted-foreground truncate max-w-md",children:a.description})]})}),e.jsx(w,{className:"text-sm",children:ze(a)}),e.jsx(w,{children:a.location?e.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[e.jsx(Te,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("span",{className:"truncate max-w-[150px]",children:a.location})]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(w,{children:a.attendees&&a.attendees.length>0?e.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[e.jsx(pa,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("span",{children:a.attendees.length})]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(w,{children:e.jsx(J,{variant:A(a)?"default":F(a)?"secondary":"outline",children:A(a)?"Próximo":F(a)?"Hoy":"Pasado"})}),e.jsx(w,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(h,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:r=>{r.stopPropagation(),D(a)},children:e.jsx(ke,{className:"h-4 w-4"})}),e.jsx(h,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:r=>{r.stopPropagation(),oe(a)},children:e.jsx(Ie,{className:"h-4 w-4"})}),e.jsxs(je,{children:[e.jsx(fe,{asChild:!0,children:e.jsx(h,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:r=>r.stopPropagation(),children:e.jsx(Ae,{className:"h-4 w-4"})})}),e.jsxs(ve,{children:[e.jsxs(ye,{children:[e.jsx(Ce,{children:"Eliminar evento"}),e.jsxs(Ne,{children:['Se eliminará "',a.summary||"(Sin título)",'" de tu calendario de Google. Esta acción no se puede deshacer.']})]}),e.jsxs(we,{children:[e.jsx(Se,{children:"Cancelar"}),e.jsx(be,{onClick:()=>ce(a.id),disabled:$===a.id,className:"bg-destructive hover:bg-destructive/90",children:$===a.id?"Eliminando...":"Eliminar"})]})]})]})]})})]},a.id))})]})})]}),e.jsx(_e,{open:!!l,onOpenChange:a=>!a&&D(null),children:e.jsx(Be,{className:"max-w-2xl max-h-[85vh] overflow-y-auto",children:l&&e.jsxs(e.Fragment,{children:[e.jsx(He,{children:e.jsxs($e,{className:"flex items-center gap-3",children:[e.jsx("span",{children:l.summary||"(Sin título)"}),e.jsx(J,{variant:A(l)?"default":F(l)?"secondary":"outline",children:A(l)?"Próximo":F(l)?"Hoy":"Pasado"})]})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:"Fecha y Hora"}),e.jsx("p",{className:"font-medium",children:ze(l)})]}),l.location&&e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{className:"text-xs text-muted-foreground uppercase tracking-wide flex items-center gap-1",children:[e.jsx(Te,{className:"h-3 w-3"})," Ubicación"]}),e.jsx("p",{children:l.location})]}),l.created&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:"Creado"}),e.jsx("p",{className:"text-sm",children:Le(l.created)})]}),l.updated&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:"Actualizado"}),e.jsx("p",{className:"text-sm",children:Le(l.updated)})]})]}),l.description&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-semibold text-sm uppercase tracking-wide text-muted-foreground",children:"Descripción"}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:l.description})]}),l.attendees&&l.attendees.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h4",{className:"font-semibold text-sm uppercase tracking-wide text-muted-foreground flex items-center gap-2",children:[e.jsx(ta,{className:"h-4 w-4"})," Invitados"]}),e.jsx("div",{className:"bg-muted/50 rounded-lg p-4 space-y-2",children:l.attendees.map((a,r)=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm",children:a.email}),a.responseStatus&&e.jsx(J,{variant:"outline",className:"text-xs",children:a.responseStatus})]},r))})]}),e.jsxs("div",{className:"flex gap-3 pt-4 border-t",children:[e.jsxs(h,{variant:"outline",onClick:()=>{D(null),oe(l)},children:[e.jsx(Ie,{className:"mr-2 h-4 w-4"}),"Editar"]}),l.htmlLink&&e.jsx(h,{variant:"outline",asChild:!0,children:e.jsxs("a",{href:l.htmlLink,target:"_blank",rel:"noreferrer",children:[e.jsx(ke,{className:"mr-2 h-4 w-4"}),"Ver en Google Calendar"]})}),e.jsxs(je,{children:[e.jsx(fe,{asChild:!0,children:e.jsxs(h,{variant:"destructive",children:[e.jsx(Ae,{className:"mr-2 h-4 w-4"}),"Eliminar"]})}),e.jsxs(ve,{children:[e.jsxs(ye,{children:[e.jsx(Ce,{children:"Eliminar evento"}),e.jsxs(Ne,{children:['Se eliminará "',l.summary||"(Sin título)",'" de tu calendario de Google. Esta acción no se puede deshacer.']})]}),e.jsxs(we,{children:[e.jsx(Se,{children:"Cancelar"}),e.jsx(be,{onClick:()=>{ce(l.id),D(null)},disabled:$===l.id,className:"bg-destructive hover:bg-destructive/90",children:$===l.id?"Eliminando...":"Eliminar"})]})]})]})]})]})]})})}),e.jsx(Me,{open:Re,onOpenChange:K,title:"Crear evento",description:"Agrega un nuevo evento a tu calendario de Google.",initialData:Qe,isSubmitting:re,onSubmit:Ve}),z&&e.jsx(Me,{open:Ue,onOpenChange:a=>{Q(a),a||W(null)},title:"Editar evento",description:`Editando "${z.summary||"(Sin título)"}"`,initialData:ya(z),isSubmitting:re,onSubmit:Ke})]}):e.jsx(M,{children:e.jsxs(O,{className:"p-8 text-center",children:[e.jsx("div",{className:"mx-auto w-16 h-16 rounded-full bg-muted flex items-center justify-center mb-4",children:e.jsx(De,{className:"w-8 h-8 text-muted-foreground"})}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Esta cuenta no está conectada. Ve a Configuración para conectar."}),e.jsx(h,{onClick:()=>s(`/conexiones/google-calendar/${t.id}`),className:"bg-[#4285F4] hover:bg-[#3367D6] text-white",children:"Conectar"})]})}):e.jsx(M,{children:e.jsxs(O,{className:"p-8 text-center",children:[e.jsx("div",{className:"mx-auto w-16 h-16 rounded-full bg-muted flex items-center justify-center mb-4",children:e.jsx(Ee,{className:"w-8 h-8 text-muted-foreground"})}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"No hay conexiones de Google Calendar. Conecta una cuenta para comenzar."}),e.jsx(h,{onClick:le,disabled:B,className:"bg-[#4285F4] hover:bg-[#3367D6] text-white",children:B?"Conectando...":"Nueva Conexión"})]})})]})};export{qa as F,Qa as G,Va as K,Ka as u};
@@ -1 +1 @@
1
- import{ay as J,u as Y,a as H,aN as K,j as e,B as i,aO as Q,aP as X,n as h,I as w,b as N,t as m}from"./index-DsyZ_FlA.js";import{b as n}from"./recharts-DrC5kNsx.js";import{C as x,b as g,c as p,d as b,a as f,e as v}from"./card-DcKsxjXK.js";import{a as F}from"./authService-Cbm8LdlJ.js";import{u as Z,P as ee}from"./useCountryFromLocale-BavmL9FK.js";import{v as ae,P as re}from"./PasswordStrengthIndicator-HZK_oU0W.js";import"./index-CEYKqxbU.js";function de(){const[E]=J(),s=E.get("token"),o=Y(),{login:B,isAuthenticated:k,user:y}=H(),{theme:T,setTheme:L}=K(),R=Z(),[V,C]=n.useState(!0),[l,u]=n.useState(!1),[r,O]=n.useState(null),[c,z]=n.useState(""),[S,$]=n.useState(""),[d,q]=n.useState(""),[I,U]=n.useState(""),M=n.useMemo(()=>ae(d),[d]);n.useEffect(()=>{if(!s){z("Token de invitación no encontrado"),C(!1);return}(async()=>{try{const t=await N.get(`/invitations/validate/${s}`);O(t.data)}catch(t){z(t.response?.data?.message||"Invitación inválida")}finally{C(!1)}})()},[s]);const j=n.useRef(!1),_=async()=>{if(j.current||l)return;j.current=!0,u(!0);const a=r?.organization?.id||"pending";localStorage.setItem("pendingOrgSelection",a),localStorage.removeItem("pendingInvitation");try{await N.post("/invitations/accept",{token:s}),m.success(`Te has unido a ${r?.organization?.name||"la organización"}`),o("/dashboard")}catch(t){const W=t.response?.data?.message||t.message||"Error al aceptar la invitación";m.error(W),localStorage.removeItem("pendingOrgSelection"),j.current=!1}finally{u(!1)}},G=async a=>{if(a.preventDefault(),!M.isValid){m.error("La contraseña no cumple con los requisitos de seguridad");return}u(!0);try{const t=await N.post("/auth/register",{name:S,password:d,phone:I,email:r.email,invitationToken:s});B(t.data.user,t.data.access_token),m.success(`Bienvenido a ${r.organization.name}`),console.log("[InvitationAcceptancePage] Registration - Setting pendingOrgSelection flag:",r.organization.id),localStorage.setItem("pendingOrgSelection",r.organization.id),localStorage.removeItem("pendingInvitation"),o("/dashboard")}catch(t){m.error(t.response?.data?.message||"Error al aceptar invitación")}finally{u(!1)}},P=()=>{s&&localStorage.setItem("pendingInvitation",s);const a=r?.email,t=r?.organization?.id;F.loginWithGoogle(t,a||void 0)},A=()=>{s&&localStorage.setItem("pendingInvitation",s);const a=r?.email,t=r?.organization?.id;F.loginWithMicrosoft(t,a||void 0)},D=()=>{L(T==="dark"?"light":"dark")};if(V)return e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-gray-50 dark:bg-zinc-950 transition-colors",children:e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx("div",{className:"w-8 h-8 border-4 border-primary border-t-transparent rounded-full animate-spin"}),e.jsx("p",{className:"text-muted-foreground",children:"Validando invitación..."})]})});if(c){const a=c.toLowerCase().includes("expirada")||c.toLowerCase().includes("aceptada")||c.toLowerCase().includes("inválida");return e.jsxs("div",{className:"flex min-h-screen items-center justify-center bg-gradient-to-br from-gray-50 to-gray-100 dark:from-zinc-950 dark:to-zinc-900 p-4 transition-colors relative",children:[e.jsxs(x,{className:"w-full max-w-md shadow-2xl border-white/20 dark:border-white/10 backdrop-blur-xl bg-white/70 dark:bg-zinc-900/70",children:[e.jsxs(g,{className:"space-y-4 text-center pb-2",children:[e.jsx("div",{className:"flex justify-center mb-2",children:e.jsx("img",{src:"/nubot-logo.png",alt:"Nubot",className:"h-8 w-auto opacity-80"})}),e.jsx("div",{className:"w-16 h-16 bg-gradient-to-br from-red-100 to-orange-50 dark:from-red-950/40 dark:to-orange-950/20 rounded-2xl flex items-center justify-center mx-auto shadow-inner ring-1 ring-red-200/50 dark:ring-red-800/30",children:e.jsx("span",{className:"material-symbols-outlined text-red-500 dark:text-red-400 text-3xl",children:a?"link_off":"error_outline"})}),e.jsx(p,{className:"text-2xl font-bold tracking-tight text-foreground",children:a?"Invitación No Disponible":"Error de Invitación"}),e.jsx(b,{className:"text-base text-muted-foreground/90",children:c})]}),e.jsx(f,{className:"pt-2 pb-2",children:e.jsx("div",{className:"p-4 bg-muted/30 dark:bg-muted/10 rounded-xl border border-muted/30 text-center",children:e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:a?"Este enlace ya fue utilizado o ha expirado. Si necesitas acceso, solicita una nueva invitación al administrador de la organización.":"No pudimos procesar tu invitación. Verifica el enlace o contacta al administrador de la organización."})})}),e.jsxs(v,{className:"flex-col gap-3 pb-8",children:[e.jsx(i,{className:"w-full h-11 text-base font-semibold shadow-lg shadow-primary/20 hover:shadow-primary/30 transition-all",onClick:()=>o(`/login${s?`?invitationToken=${s}`:""}`),children:"Ir al Inicio de Sesión"}),e.jsx(i,{variant:"ghost",className:"w-full text-muted-foreground hover:text-foreground",onClick:()=>o("/login"),children:"Volver al Inicio"})]})]}),e.jsx("p",{className:"absolute bottom-6 text-xs text-muted-foreground/50",children:"nubot.io — CRM con IA para WhatsApp"})]})}if(k&&r){const a=y?.email?.toLowerCase()===r.email?.toLowerCase();return e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-gradient-to-br from-gray-50 to-gray-100 dark:from-zinc-950 dark:to-zinc-900 p-4 transition-colors relative",children:e.jsxs(x,{className:"w-full max-w-md shadow-2xl border-white/20 dark:border-white/10 backdrop-blur-xl bg-white/70 dark:bg-zinc-900/70",children:[e.jsxs(g,{className:"space-y-4 text-center pb-2",children:[e.jsx("div",{className:"w-16 h-16 bg-gradient-to-br from-primary/20 to-primary/5 rounded-2xl flex items-center justify-center mx-auto mb-2 shadow-inner ring-1 ring-white/50 dark:ring-white/10",children:e.jsx("span",{className:"text-3xl",children:"📩"})}),e.jsx(p,{className:"text-2xl font-bold tracking-tight",children:"Invitación Pendiente"}),e.jsxs(b,{className:"text-base text-muted-foreground/90",children:["Te han invitado a unirte a ",e.jsx("strong",{className:"text-foreground",children:r.organization.name}),"."]})]}),e.jsx(f,{className:"space-y-6 pt-4",children:a?e.jsx("div",{className:"text-center text-muted-foreground px-4",children:"Haz clic a continuación para aceptar la invitación y obtener acceso inmediato al equipo."}):e.jsxs("div",{className:"p-4 bg-amber-50 dark:bg-amber-950/30 border border-amber-200 dark:border-amber-900/50 rounded-lg text-sm text-center text-amber-800 dark:text-amber-200",children:["Esta invitación fue enviada a ",e.jsx("strong",{children:r.email}),", pero has iniciado sesión como ",e.jsx("strong",{children:y?.email}),".",e.jsx("br",{}),e.jsx("br",{}),"Por favor, cierra sesión para usar la cuenta correcta."]})}),e.jsxs(v,{className:"flex-col gap-3 pb-8",children:[a?e.jsx(i,{className:"w-full h-11 text-base font-semibold shadow-lg shadow-primary/20 hover:shadow-primary/30 transition-all",onClick:_,disabled:l,children:l?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}),"Uniendo..."]}):"Aceptar e Unirse"}):e.jsx(i,{variant:"outline",className:"w-full h-11 border-destructive/20 text-destructive hover:bg-destructive/5 hover:text-destructive hover:border-destructive/30",onClick:()=>{H.getState().logout();const t=new URLSearchParams;s&&t.set("invitationToken",s),r?.email&&t.set("email",r.email),o(`/login?${t.toString()}`)},children:"Cerrar Sesión"}),e.jsx(i,{variant:"ghost",className:"w-full text-muted-foreground hover:text-foreground",onClick:()=>o("/dashboard"),children:"Cancelar"})]})]})})}return!k&&r?.userExists?e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-gradient-to-br from-gray-50 to-gray-100 dark:from-zinc-950 dark:to-zinc-900 p-4 transition-colors relative",children:e.jsxs(x,{className:"w-full max-w-md shadow-2xl border-white/20 dark:border-white/10 backdrop-blur-xl bg-white/70 dark:bg-zinc-900/70",children:[e.jsxs(g,{className:"space-y-4 text-center pb-2",children:[e.jsx("div",{className:"w-16 h-16 bg-gradient-to-br from-primary/20 to-primary/5 rounded-2xl flex items-center justify-center mx-auto mb-2 shadow-inner ring-1 ring-white/50 dark:ring-white/10",children:e.jsx("span",{className:"text-3xl",children:"👋"})}),e.jsx(p,{className:"text-2xl font-bold tracking-tight",children:"¡Hola de nuevo!"}),e.jsxs(b,{className:"text-base text-muted-foreground/90",children:["Vemos que ya tienes una cuenta con ",e.jsx("strong",{children:r.email}),"."]})]}),e.jsxs(f,{className:"text-center text-muted-foreground px-6 py-4",children:["Para aceptar la invitación a ",e.jsx("strong",{children:r.organization.name}),", por favor inicia sesión con tus credenciales habituales."]}),e.jsxs(v,{className:"flex-col gap-4 pb-8",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3 w-full mb-2",children:[e.jsxs(i,{variant:"outline",onClick:P,className:"bg-white/50 dark:bg-black/20 border-muted hover:bg-white dark:hover:bg-black/40 h-10",children:[e.jsxs("svg",{className:"mr-2 h-4 w-4",viewBox:"0 0 24 24",children:[e.jsx("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z",fill:"#4285F4"}),e.jsx("path",{d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z",fill:"#34A853"}),e.jsx("path",{d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.26-.19-.58z",fill:"#FBBC05"}),e.jsx("path",{d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z",fill:"#EA4335"})]}),"Google"]}),e.jsxs(i,{variant:"outline",onClick:A,className:"bg-white/50 dark:bg-black/20 border-muted hover:bg-white dark:hover:bg-black/40 h-10",children:[e.jsxs("svg",{className:"mr-2 h-4 w-4",viewBox:"0 0 24 24",children:[e.jsx("path",{fill:"#F35325",d:"M1 1h10v10H1z"}),e.jsx("path",{fill:"#81BC06",d:"M13 1h10v10H13z"}),e.jsx("path",{fill:"#05A6F0",d:"M1 13h10v10H1z"}),e.jsx("path",{fill:"#FFBA08",d:"M13 13h10v10H13z"})]}),"Microsoft"]})]}),e.jsxs("div",{className:"relative w-full py-2",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t border-muted/30"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-background/0 px-2 text-muted-foreground backdrop-blur-md",children:"O usa tu correo"})})]}),e.jsx(i,{className:"w-full h-11 text-base font-semibold shadow-lg shadow-primary/20 hover:shadow-primary/30 transition-all",onClick:()=>{const a=new URLSearchParams;s&&a.set("invitationToken",s),r?.email&&a.set("email",r.email),o(`/login?${a.toString()}`)},children:"Iniciar Sesión y Aceptar"}),e.jsxs("p",{className:"text-xs text-center text-muted-foreground mt-2",children:["Si no recuerdas tu contraseña, puedes ",e.jsx("span",{className:"underline cursor-pointer hover:text-primary transition-colors",onClick:()=>o("/forgot-password"),children:"recuperarla aquí"}),"."]})]})]})}):e.jsxs("div",{className:"flex min-h-screen items-center justify-center bg-gradient-to-br from-gray-50 to-gray-100 dark:from-zinc-950 dark:to-zinc-900 p-4 transition-colors relative",children:[e.jsxs(i,{variant:"ghost",size:"icon",className:"absolute top-4 right-4 rounded-full",onClick:D,children:[e.jsx(Q,{className:"h-[1.2rem] w-[1.2rem] rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0"}),e.jsx(X,{className:"absolute h-[1.2rem] w-[1.2rem] rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100"}),e.jsx("span",{className:"sr-only",children:"Toggle theme"})]}),e.jsxs(x,{className:"w-full max-w-[440px] shadow-2xl border-white/20 dark:border-white/10 backdrop-blur-xl bg-white/80 dark:bg-zinc-900/80",children:[e.jsxs(g,{className:"space-y-4 text-center pb-2",children:[e.jsx("div",{className:"w-16 h-16 bg-gradient-to-br from-primary/20 to-primary/5 rounded-2xl flex items-center justify-center mx-auto mb-2 shadow-inner ring-1 ring-white/50 dark:ring-white/10",children:e.jsx("span",{className:"text-3xl",children:"👋"})}),e.jsxs("div",{children:[e.jsx(p,{className:"text-2xl font-bold tracking-tight",children:"Bienvenido al equipo"}),e.jsxs(b,{className:"text-base text-muted-foreground/90 mt-1",children:["Te unes a ",e.jsx("strong",{className:"text-foreground",children:r?.organization?.name})]})]})]}),e.jsxs(f,{className:"space-y-6 pt-2",children:[e.jsxs("div",{className:"space-y-3 p-4 bg-muted/40 rounded-xl border border-muted/40",children:[e.jsx("h3",{className:"text-sm font-medium text-foreground text-center",children:"Acceso Rápido (Recomendado)"}),e.jsx("p",{className:"text-xs text-muted-foreground text-center mb-3",children:"Evita llenar formularios. Crea tu cuenta automáticamente iniciando sesión con tu proveedor."}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs(i,{variant:"outline",onClick:P,className:"bg-white dark:bg-black/20 border-muted/60 hover:bg-white dark:hover:bg-black/40 h-10 shadow-sm",children:[e.jsxs("svg",{className:"mr-2 h-4 w-4",viewBox:"0 0 24 24",children:[e.jsx("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z",fill:"#4285F4"}),e.jsx("path",{d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z",fill:"#34A853"}),e.jsx("path",{d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.26-.19-.58z",fill:"#FBBC05"}),e.jsx("path",{d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z",fill:"#EA4335"})]}),"Google"]}),e.jsxs(i,{variant:"outline",onClick:A,className:"bg-white dark:bg-black/20 border-muted/60 hover:bg-white dark:hover:bg-black/40 h-10 shadow-sm",children:[e.jsxs("svg",{className:"mr-2 h-4 w-4",viewBox:"0 0 24 24",children:[e.jsx("path",{fill:"#F35325",d:"M1 1h10v10H1z"}),e.jsx("path",{fill:"#81BC06",d:"M13 1h10v10H13z"}),e.jsx("path",{fill:"#05A6F0",d:"M1 13h10v10H1z"}),e.jsx("path",{fill:"#FFBA08",d:"M13 13h10v10H13z"})]}),"Microsoft"]})]})]}),e.jsxs("div",{className:"relative py-2",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t border-muted/40"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-gray-100/50 dark:bg-zinc-800/50 px-2 text-muted-foreground backdrop-blur-md rounded-full",children:"O completa tu perfil"})})]}),e.jsxs("form",{onSubmit:G,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{htmlFor:"email",className:"text-xs uppercase text-muted-foreground font-semibold",children:"Correo Electrónico"}),e.jsx(w,{id:"email",type:"email",value:r?.email,disabled:!0,className:"bg-muted/50 text-muted-foreground font-medium border-muted/60"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{htmlFor:"name",className:"text-xs uppercase text-muted-foreground font-semibold",children:"Nombre Completo"}),e.jsx(w,{id:"name",placeholder:"Ej: Juan Pérez",value:S,onChange:a=>$(a.target.value),required:!0,className:"bg-background/80"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{htmlFor:"phone",className:"text-xs uppercase text-muted-foreground font-semibold",children:"Teléfono"}),e.jsx("div",{className:"flex rounded-md border border-input bg-background/80 ring-offset-background focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2",children:e.jsx(ee,{international:!0,defaultCountry:R,value:I,onChange:U,className:"flex w-full px-3 py-2 text-sm bg-transparent placeholder:text-muted-foreground focus:outline-none [&>.PhoneInputCountry]:mr-2 [&_input]:bg-transparent [&_input]:outline-none [&_input]:w-full"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{htmlFor:"password",children:"Contraseña"}),e.jsx(w,{id:"password",type:"password",value:d,onChange:a=>q(a.target.value),required:!0,className:"bg-background/80"}),e.jsx(re,{password:d})]}),e.jsx(i,{type:"submit",className:"w-full h-11 text-base font-semibold shadow-lg shadow-primary/20 hover:shadow-primary/30 transition-all mt-6",disabled:l||!M.isValid,children:l?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 border-2 border-white/60 border-t-white/10 rounded-full animate-spin"}),"Configurando cuenta..."]}):"Completar Registro"})]})]}),e.jsx(v,{className:"flex-col gap-4 justify-center border-t border-muted/20 p-4 bg-muted/10",children:e.jsxs("div",{className:"text-center w-full",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"¿Ya tienes una cuenta?"}),e.jsx(i,{variant:"outline",className:"w-full border-muted/40 hover:bg-background",onClick:()=>{const a=new URLSearchParams;s&&a.set("invitationToken",s),r?.email&&a.set("email",r.email),o(`/login?${a.toString()}`)},children:"Iniciar Sesión y Aceptar"})]})})]})]})}export{de as default};
1
+ import{aw as Y,u as J,a as H,aY as Z,j as e,B as i,aZ as K,a_ as Q,n as h,I as w,b as N,t as m}from"./index-43NA2pdZ.js";import{b as n}from"./recharts-DrC5kNsx.js";import{C as x,b as g,c as p,d as b,a as f,e as v}from"./card-DdbmSh-v.js";import{a as F}from"./authService-CtvlzCDa.js";import{u as X,P as ee}from"./useCountryFromLocale-BavmL9FK.js";import{v as ae,P as re}from"./PasswordStrengthIndicator-4h-Y0s2r.js";import"./index-CEYKqxbU.js";function de(){const[E]=Y(),s=E.get("token"),o=J(),{login:B,isAuthenticated:k,user:y}=H(),{theme:T,setTheme:L}=Z(),R=X(),[V,C]=n.useState(!0),[l,u]=n.useState(!1),[r,$]=n.useState(null),[c,z]=n.useState(""),[S,q]=n.useState(""),[d,O]=n.useState(""),[I,_]=n.useState(""),M=n.useMemo(()=>ae(d),[d]);n.useEffect(()=>{if(!s){z("Token de invitación no encontrado"),C(!1);return}(async()=>{try{const t=await N.get(`/invitations/validate/${s}`);$(t.data)}catch(t){z(t.response?.data?.message||"Invitación inválida")}finally{C(!1)}})()},[s]);const j=n.useRef(!1),U=async()=>{if(j.current||l)return;j.current=!0,u(!0);const a=r?.organization?.id||"pending";localStorage.setItem("pendingOrgSelection",a),localStorage.removeItem("pendingInvitation");try{await N.post("/invitations/accept",{token:s}),m.success(`Te has unido a ${r?.organization?.name||"la organización"}`),o("/dashboard")}catch(t){const W=t.response?.data?.message||t.message||"Error al aceptar la invitación";m.error(W),localStorage.removeItem("pendingOrgSelection"),j.current=!1}finally{u(!1)}},G=async a=>{if(a.preventDefault(),!M.isValid){m.error("La contraseña no cumple con los requisitos de seguridad");return}u(!0);try{const t=await N.post("/auth/register",{name:S,password:d,phone:I,email:r.email,invitationToken:s});B(t.data.user,t.data.access_token),m.success(`Bienvenido a ${r.organization.name}`),console.log("[InvitationAcceptancePage] Registration - Setting pendingOrgSelection flag:",r.organization.id),localStorage.setItem("pendingOrgSelection",r.organization.id),localStorage.removeItem("pendingInvitation"),o("/dashboard")}catch(t){m.error(t.response?.data?.message||"Error al aceptar invitación")}finally{u(!1)}},P=()=>{s&&localStorage.setItem("pendingInvitation",s);const a=r?.email,t=r?.organization?.id;F.loginWithGoogle(t,a||void 0)},A=()=>{s&&localStorage.setItem("pendingInvitation",s);const a=r?.email,t=r?.organization?.id;F.loginWithMicrosoft(t,a||void 0)},D=()=>{L(T==="dark"?"light":"dark")};if(V)return e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-gray-50 dark:bg-zinc-950 transition-colors",children:e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx("div",{className:"w-8 h-8 border-4 border-primary border-t-transparent rounded-full animate-spin"}),e.jsx("p",{className:"text-muted-foreground",children:"Validando invitación..."})]})});if(c){const a=c.toLowerCase().includes("expirada")||c.toLowerCase().includes("aceptada")||c.toLowerCase().includes("inválida");return e.jsxs("div",{className:"flex min-h-screen items-center justify-center bg-gradient-to-br from-gray-50 to-gray-100 dark:from-zinc-950 dark:to-zinc-900 p-4 transition-colors relative",children:[e.jsxs(x,{className:"w-full max-w-md shadow-2xl border-white/20 dark:border-white/10 backdrop-blur-xl bg-white/70 dark:bg-zinc-900/70",children:[e.jsxs(g,{className:"space-y-4 text-center pb-2",children:[e.jsx("div",{className:"flex justify-center mb-2",children:e.jsx("img",{src:"/nubot-logo.png",alt:"Nubot",className:"h-8 w-auto opacity-80"})}),e.jsx("div",{className:"w-16 h-16 bg-gradient-to-br from-red-100 to-orange-50 dark:from-red-950/40 dark:to-orange-950/20 rounded-2xl flex items-center justify-center mx-auto shadow-inner ring-1 ring-red-200/50 dark:ring-red-800/30",children:e.jsx("span",{className:"material-symbols-outlined text-red-500 dark:text-red-400 text-3xl",children:a?"link_off":"error_outline"})}),e.jsx(p,{className:"text-2xl font-bold tracking-tight text-foreground",children:a?"Invitación No Disponible":"Error de Invitación"}),e.jsx(b,{className:"text-base text-muted-foreground/90",children:c})]}),e.jsx(f,{className:"pt-2 pb-2",children:e.jsx("div",{className:"p-4 bg-muted/30 dark:bg-muted/10 rounded-xl border border-muted/30 text-center",children:e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:a?"Este enlace ya fue utilizado o ha expirado. Si necesitas acceso, solicita una nueva invitación al administrador de la organización.":"No pudimos procesar tu invitación. Verifica el enlace o contacta al administrador de la organización."})})}),e.jsxs(v,{className:"flex-col gap-3 pb-8",children:[e.jsx(i,{className:"w-full h-11 text-base font-semibold shadow-lg shadow-primary/20 hover:shadow-primary/30 transition-all",onClick:()=>o(`/login${s?`?invitationToken=${s}`:""}`),children:"Ir al Inicio de Sesión"}),e.jsx(i,{variant:"ghost",className:"w-full text-muted-foreground hover:text-foreground",onClick:()=>o("/login"),children:"Volver al Inicio"})]})]}),e.jsx("p",{className:"absolute bottom-6 text-xs text-muted-foreground/50",children:"nubot.io — CRM con IA para WhatsApp"})]})}if(k&&r){const a=y?.email?.toLowerCase()===r.email?.toLowerCase();return e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-gradient-to-br from-gray-50 to-gray-100 dark:from-zinc-950 dark:to-zinc-900 p-4 transition-colors relative",children:e.jsxs(x,{className:"w-full max-w-md shadow-2xl border-white/20 dark:border-white/10 backdrop-blur-xl bg-white/70 dark:bg-zinc-900/70",children:[e.jsxs(g,{className:"space-y-4 text-center pb-2",children:[e.jsx("div",{className:"w-16 h-16 bg-gradient-to-br from-primary/20 to-primary/5 rounded-2xl flex items-center justify-center mx-auto mb-2 shadow-inner ring-1 ring-white/50 dark:ring-white/10",children:e.jsx("span",{className:"text-3xl",children:"📩"})}),e.jsx(p,{className:"text-2xl font-bold tracking-tight",children:"Invitación Pendiente"}),e.jsxs(b,{className:"text-base text-muted-foreground/90",children:["Te han invitado a unirte a ",e.jsx("strong",{className:"text-foreground",children:r.organization.name}),"."]})]}),e.jsx(f,{className:"space-y-6 pt-4",children:a?e.jsx("div",{className:"text-center text-muted-foreground px-4",children:"Haz clic a continuación para aceptar la invitación y obtener acceso inmediato al equipo."}):e.jsxs("div",{className:"p-4 bg-amber-50 dark:bg-amber-950/30 border border-amber-200 dark:border-amber-900/50 rounded-lg text-sm text-center text-amber-800 dark:text-amber-200",children:["Esta invitación fue enviada a ",e.jsx("strong",{children:r.email}),", pero has iniciado sesión como ",e.jsx("strong",{children:y?.email}),".",e.jsx("br",{}),e.jsx("br",{}),"Por favor, cierra sesión para usar la cuenta correcta."]})}),e.jsxs(v,{className:"flex-col gap-3 pb-8",children:[a?e.jsx(i,{className:"w-full h-11 text-base font-semibold shadow-lg shadow-primary/20 hover:shadow-primary/30 transition-all",onClick:U,disabled:l,children:l?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}),"Uniendo..."]}):"Aceptar e Unirse"}):e.jsx(i,{variant:"outline",className:"w-full h-11 border-destructive/20 text-destructive hover:bg-destructive/5 hover:text-destructive hover:border-destructive/30",onClick:()=>{H.getState().logout();const t=new URLSearchParams;s&&t.set("invitationToken",s),r?.email&&t.set("email",r.email),o(`/login?${t.toString()}`)},children:"Cerrar Sesión"}),e.jsx(i,{variant:"ghost",className:"w-full text-muted-foreground hover:text-foreground",onClick:()=>o("/dashboard"),children:"Cancelar"})]})]})})}return!k&&r?.userExists?e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-gradient-to-br from-gray-50 to-gray-100 dark:from-zinc-950 dark:to-zinc-900 p-4 transition-colors relative",children:e.jsxs(x,{className:"w-full max-w-md shadow-2xl border-white/20 dark:border-white/10 backdrop-blur-xl bg-white/70 dark:bg-zinc-900/70",children:[e.jsxs(g,{className:"space-y-4 text-center pb-2",children:[e.jsx("div",{className:"w-16 h-16 bg-gradient-to-br from-primary/20 to-primary/5 rounded-2xl flex items-center justify-center mx-auto mb-2 shadow-inner ring-1 ring-white/50 dark:ring-white/10",children:e.jsx("span",{className:"text-3xl",children:"👋"})}),e.jsx(p,{className:"text-2xl font-bold tracking-tight",children:"¡Hola de nuevo!"}),e.jsxs(b,{className:"text-base text-muted-foreground/90",children:["Vemos que ya tienes una cuenta con ",e.jsx("strong",{children:r.email}),"."]})]}),e.jsxs(f,{className:"text-center text-muted-foreground px-6 py-4",children:["Para aceptar la invitación a ",e.jsx("strong",{children:r.organization.name}),", por favor inicia sesión con tus credenciales habituales."]}),e.jsxs(v,{className:"flex-col gap-4 pb-8",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3 w-full mb-2",children:[e.jsxs(i,{variant:"outline",onClick:P,className:"bg-white/50 dark:bg-black/20 border-muted hover:bg-white dark:hover:bg-black/40 h-10",children:[e.jsxs("svg",{className:"mr-2 h-4 w-4",viewBox:"0 0 24 24",children:[e.jsx("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z",fill:"#4285F4"}),e.jsx("path",{d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z",fill:"#34A853"}),e.jsx("path",{d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.26-.19-.58z",fill:"#FBBC05"}),e.jsx("path",{d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z",fill:"#EA4335"})]}),"Google"]}),e.jsxs(i,{variant:"outline",onClick:A,className:"bg-white/50 dark:bg-black/20 border-muted hover:bg-white dark:hover:bg-black/40 h-10",children:[e.jsxs("svg",{className:"mr-2 h-4 w-4",viewBox:"0 0 24 24",children:[e.jsx("path",{fill:"#F35325",d:"M1 1h10v10H1z"}),e.jsx("path",{fill:"#81BC06",d:"M13 1h10v10H13z"}),e.jsx("path",{fill:"#05A6F0",d:"M1 13h10v10H1z"}),e.jsx("path",{fill:"#FFBA08",d:"M13 13h10v10H13z"})]}),"Microsoft"]})]}),e.jsxs("div",{className:"relative w-full py-2",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t border-muted/30"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-background/0 px-2 text-muted-foreground backdrop-blur-md",children:"O usa tu correo"})})]}),e.jsx(i,{className:"w-full h-11 text-base font-semibold shadow-lg shadow-primary/20 hover:shadow-primary/30 transition-all",onClick:()=>{const a=new URLSearchParams;s&&a.set("invitationToken",s),r?.email&&a.set("email",r.email),o(`/login?${a.toString()}`)},children:"Iniciar Sesión y Aceptar"}),e.jsxs("p",{className:"text-xs text-center text-muted-foreground mt-2",children:["Si no recuerdas tu contraseña, puedes ",e.jsx("span",{className:"underline cursor-pointer hover:text-primary transition-colors",onClick:()=>o("/forgot-password"),children:"recuperarla aquí"}),"."]})]})]})}):e.jsxs("div",{className:"flex min-h-screen items-center justify-center bg-gradient-to-br from-gray-50 to-gray-100 dark:from-zinc-950 dark:to-zinc-900 p-4 transition-colors relative",children:[e.jsxs(i,{variant:"ghost",size:"icon",className:"absolute top-4 right-4 rounded-full",onClick:D,children:[e.jsx(K,{className:"h-[1.2rem] w-[1.2rem] rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0"}),e.jsx(Q,{className:"absolute h-[1.2rem] w-[1.2rem] rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100"}),e.jsx("span",{className:"sr-only",children:"Toggle theme"})]}),e.jsxs(x,{className:"w-full max-w-[440px] shadow-2xl border-white/20 dark:border-white/10 backdrop-blur-xl bg-white/80 dark:bg-zinc-900/80",children:[e.jsxs(g,{className:"space-y-4 text-center pb-2",children:[e.jsx("div",{className:"w-16 h-16 bg-gradient-to-br from-primary/20 to-primary/5 rounded-2xl flex items-center justify-center mx-auto mb-2 shadow-inner ring-1 ring-white/50 dark:ring-white/10",children:e.jsx("span",{className:"text-3xl",children:"👋"})}),e.jsxs("div",{children:[e.jsx(p,{className:"text-2xl font-bold tracking-tight",children:"Bienvenido al equipo"}),e.jsxs(b,{className:"text-base text-muted-foreground/90 mt-1",children:["Te unes a ",e.jsx("strong",{className:"text-foreground",children:r?.organization?.name})]})]})]}),e.jsxs(f,{className:"space-y-6 pt-2",children:[e.jsxs("div",{className:"space-y-3 p-4 bg-muted/40 rounded-xl border border-muted/40",children:[e.jsx("h3",{className:"text-sm font-medium text-foreground text-center",children:"Acceso Rápido (Recomendado)"}),e.jsx("p",{className:"text-xs text-muted-foreground text-center mb-3",children:"Evita llenar formularios. Crea tu cuenta automáticamente iniciando sesión con tu proveedor."}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs(i,{variant:"outline",onClick:P,className:"bg-white dark:bg-black/20 border-muted/60 hover:bg-white dark:hover:bg-black/40 h-10 shadow-sm",children:[e.jsxs("svg",{className:"mr-2 h-4 w-4",viewBox:"0 0 24 24",children:[e.jsx("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z",fill:"#4285F4"}),e.jsx("path",{d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z",fill:"#34A853"}),e.jsx("path",{d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.26-.19-.58z",fill:"#FBBC05"}),e.jsx("path",{d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z",fill:"#EA4335"})]}),"Google"]}),e.jsxs(i,{variant:"outline",onClick:A,className:"bg-white dark:bg-black/20 border-muted/60 hover:bg-white dark:hover:bg-black/40 h-10 shadow-sm",children:[e.jsxs("svg",{className:"mr-2 h-4 w-4",viewBox:"0 0 24 24",children:[e.jsx("path",{fill:"#F35325",d:"M1 1h10v10H1z"}),e.jsx("path",{fill:"#81BC06",d:"M13 1h10v10H13z"}),e.jsx("path",{fill:"#05A6F0",d:"M1 13h10v10H1z"}),e.jsx("path",{fill:"#FFBA08",d:"M13 13h10v10H13z"})]}),"Microsoft"]})]})]}),e.jsxs("div",{className:"relative py-2",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t border-muted/40"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-gray-100/50 dark:bg-zinc-800/50 px-2 text-muted-foreground backdrop-blur-md rounded-full",children:"O completa tu perfil"})})]}),e.jsxs("form",{onSubmit:G,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{htmlFor:"email",className:"text-xs uppercase text-muted-foreground font-semibold",children:"Correo Electrónico"}),e.jsx(w,{id:"email",type:"email",value:r?.email,disabled:!0,className:"bg-muted/50 text-muted-foreground font-medium border-muted/60"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{htmlFor:"name",className:"text-xs uppercase text-muted-foreground font-semibold",children:"Nombre Completo"}),e.jsx(w,{id:"name",placeholder:"Ej: Juan Pérez",value:S,onChange:a=>q(a.target.value),required:!0,className:"bg-background/80"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{htmlFor:"phone",className:"text-xs uppercase text-muted-foreground font-semibold",children:"Teléfono"}),e.jsx("div",{className:"flex rounded-md border border-input bg-background/80 ring-offset-background focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2",children:e.jsx(ee,{international:!0,defaultCountry:R,value:I,onChange:_,className:"flex w-full px-3 py-2 text-sm bg-transparent placeholder:text-muted-foreground focus:outline-none [&>.PhoneInputCountry]:mr-2 [&_input]:bg-transparent [&_input]:outline-none [&_input]:w-full"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{htmlFor:"password",children:"Contraseña"}),e.jsx(w,{id:"password",type:"password",value:d,onChange:a=>O(a.target.value),required:!0,className:"bg-background/80"}),e.jsx(re,{password:d})]}),e.jsx(i,{type:"submit",className:"w-full h-11 text-base font-semibold shadow-lg shadow-primary/20 hover:shadow-primary/30 transition-all mt-6",disabled:l||!M.isValid,children:l?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 border-2 border-white/60 border-t-white/10 rounded-full animate-spin"}),"Configurando cuenta..."]}):"Completar Registro"})]})]}),e.jsx(v,{className:"flex-col gap-4 justify-center border-t border-muted/20 p-4 bg-muted/10",children:e.jsxs("div",{className:"text-center w-full",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"¿Ya tienes una cuenta?"}),e.jsx(i,{variant:"outline",className:"w-full border-muted/40 hover:bg-background",onClick:()=>{const a=new URLSearchParams;s&&a.set("invitationToken",s),r?.email&&a.set("email",r.email),o(`/login?${a.toString()}`)},children:"Iniciar Sesión y Aceptar"})]})})]})]})}export{de as default};
@@ -0,0 +1 @@
1
+ import{ay as e}from"./index-43NA2pdZ.js";import"./recharts-DrC5kNsx.js";export{e as default};
@@ -0,0 +1 @@
1
+ import{j as e,l as m,B as S,aC as z,a7 as W,u as _,g as F,A as K,R as Q,c8 as Y,y as G,ad as J,ae as X,af as Z,ag as ee,ah as se,r as M,F as ae,b as R,t as te}from"./index-43NA2pdZ.js";import{b as N}from"./recharts-DrC5kNsx.js";import{a as U}from"./datetime-D72Uxhjs.js";import{S as D,a as I,b as q,c as A,d as k}from"./select-DCY_lg9j.js";import{S as P}from"./stat-card-W7s_-fHW.js";import{S as re}from"./skeleton-CN6xlRXP.js";import{P as le,a as ne,b as oe}from"./page-components-DXOKtt_M.js";import{D as ie}from"./download-CyfdxFCW.js";import{M as de}from"./message-square-B1_OirdW.js";import{H as ce}from"./hash-ByrjK6gt.js";import{E as me}from"./external-link-w7K66ae2.js";import"./index-KbFmSzBE.js";import"./card-DdbmSh-v.js";function ue({columns:t,data:n,keyExtractor:h,isLoading:p=!1,loadingRows:L=5,emptyState:b,emptyMessage:O="No hay datos disponibles",onRowClick:j,pagination:o,className:r,striped:T=!1,compact:C=!1}){const g=a=>{switch(a){case"center":return"text-center";case"right":return"text-right";default:return"text-left"}},f=C?"py-2.5 px-4":"py-4 px-5",d=C?"py-2 px-4":"py-3 px-5";return p?e.jsx("div",{className:m("rounded-xl border border-border/50 bg-card/50 backdrop-blur-sm overflow-hidden",r),children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsx("tr",{className:"border-b border-border/50 bg-muted/30",children:t.map(a=>e.jsx("th",{className:m(d,"text-[11px] font-medium uppercase tracking-wider text-muted-foreground",g(a.align),a.hideOnMobile&&"hidden md:table-cell"),style:{width:a.width},children:a.header},a.key))})}),e.jsx("tbody",{children:Array.from({length:L}).map((a,u)=>e.jsx("tr",{className:"border-b border-border/30 last:border-0",children:t.map(c=>e.jsx("td",{className:m(f,c.hideOnMobile&&"hidden md:table-cell"),children:e.jsx(re,{className:"h-5 w-full max-w-[120px]"})},c.key))},u))})]})}):!n||n.length===0?e.jsxs("div",{className:m("rounded-xl border border-border/50 bg-card/50 backdrop-blur-sm overflow-hidden",r),children:[e.jsx("table",{className:"w-full",children:e.jsx("thead",{children:e.jsx("tr",{className:"border-b border-border/50 bg-muted/30",children:t.map(a=>e.jsx("th",{className:m(d,"text-[11px] font-medium uppercase tracking-wider text-muted-foreground",g(a.align),a.hideOnMobile&&"hidden md:table-cell"),style:{width:a.width},children:a.header},a.key))})})}),e.jsx("div",{className:"flex flex-col items-center justify-center py-16 px-4",children:b||e.jsx("p",{className:"text-sm text-muted-foreground",children:O})})]}):e.jsxs("div",{className:m("rounded-xl border border-border/50 bg-card/50 backdrop-blur-sm overflow-hidden",r),children:[e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsx("tr",{className:"border-b border-border/50 bg-muted/30",children:t.map(a=>e.jsx("th",{className:m(d,"text-[11px] font-medium uppercase tracking-wider text-muted-foreground",g(a.align),a.hideOnMobile&&"hidden md:table-cell"),style:{width:a.width},children:a.header},a.key))})}),e.jsx("tbody",{children:n.map((a,u)=>e.jsx("tr",{className:m("border-b border-border/30 last:border-0 transition-colors",j&&"cursor-pointer hover:bg-primary/5",!j&&"hover:bg-muted/30",T&&u%2===1&&"bg-muted/20"),onClick:()=>j?.(a),children:t.map(c=>e.jsx("td",{className:m(f,"text-sm",g(c.align),c.hideOnMobile&&"hidden md:table-cell"),style:{width:c.width},children:c.render(a,u)},c.key))},h(a)))})]})}),o&&o.totalPages>1&&e.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-t border-border/30 bg-muted/20",children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Mostrando ",(o.page-1)*(o.limit||20)+1,"-",Math.min(o.page*(o.limit||20),o.total)," ","de ",o.total]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(S,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>o.onPageChange(o.page-1),disabled:o.page<=1,children:e.jsx(z,{className:"h-4 w-4"})}),e.jsxs("span",{className:"text-xs text-muted-foreground px-2",children:[o.page," / ",o.totalPages]}),e.jsx(S,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>o.onPageChange(o.page+1),disabled:o.page>=o.totalPages,children:e.jsx(W,{className:"h-4 w-4"})})]})]})]})}const xe=1440*60*1e3,he=[{value:"today",label:"Hoy"},{value:"7",label:"Últimos 7 días"},{value:"30",label:"Últimos 30 días"},{value:"90",label:"Últimos 90 días"}],w={replied:{label:"Respondió",className:"border-emerald-500/30 text-emerald-600 dark:text-emerald-400"},handoff:{label:"Pasó a un asesor",className:"border-blue-500/30 text-blue-600 dark:text-blue-400"},error:{label:"Error",className:"border-red-500/30 text-red-600 dark:text-red-400"},skipped:{label:"No se envió",className:"border-amber-500/30 text-amber-600 dark:text-amber-400"}},pe={"claude-sonnet-5-5":"Sonnet 5.5","claude-opus-5-5":"Opus 5.5","claude-haiku-5-5":"Haiku 5.5"};function ge(t){const n=Date.now();if(t==="today"){const h=new Date;return h.setHours(0,0,0,0),{from:h.getTime(),to:n}}return{from:n-Number(t)*xe,to:n}}const i=t=>t.toLocaleString("es-PE");function E(t){if(t==null)return"—";const n=t!==0&&Math.abs(t)<1?4:2;return`US$ ${t.toLocaleString("es-PE",{minimumFractionDigits:n,maximumFractionDigits:n})}`}function y(t){if(t==null)return"—";if(t<1e3)return`${Math.round(t)} ms`;const n=t/1e3;return n<60?`${n.toLocaleString("es-PE",{maximumFractionDigits:1})} s`:`${Math.floor(n/60)} min ${Math.round(n%60)} s`}function B(t){return t.source==="prueba"?"Prueba":t.conversationId?t.contactName||"Cliente":"Contacto borrado"}function Ee(){const t=_(),[n,h]=N.useState("30"),[p,L]=N.useState("chat"),[b,O]=N.useState("all"),[j,o]=N.useState(1),[r,T]=N.useState(null),[C,g]=N.useState(!1),f=()=>({...ge(n),source:p==="all"?void 0:p,outcome:b}),d=F({queryKey:["lite-ai-usage-summary",n,p,b],queryFn:async()=>(await R.get("/ai-agents/metrics/summary",{params:f()})).data,refetchInterval:3e4}),a=F({queryKey:["lite-ai-usage-interactions",n,p,b,j],queryFn:async()=>(await R.get("/ai-agents/metrics/interactions",{params:{...f(),page:j,limit:25}})).data,refetchInterval:3e4}),u=s=>v=>{s(v),o(1)},c=()=>{d.refetch(),a.refetch()},H=async()=>{g(!0);try{const s=await R.get("/ai-agents/metrics/interactions/export",{params:f(),responseType:"blob"}),v=URL.createObjectURL(s.data),$=document.createElement("a");$.href=v,$.download=`uso-ia-${new Date().toISOString().slice(0,10)}.csv`,$.click(),URL.revokeObjectURL(v)}catch{te.error("No se pudo descargar el CSV.")}finally{g(!1)}},l=d.data,V=[{key:"date",header:"Fecha",width:"130px",render:s=>e.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:U(s.createdAt,{style:"short"})})},{key:"question",header:"Cliente y pregunta",render:s=>e.jsxs("div",{className:"min-w-0 max-w-md",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:B(s)}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:s.question??"—"})]})},{key:"outcome",header:"Resultado",render:s=>e.jsx(M,{variant:"outline",className:w[s.outcome]?.className,children:w[s.outcome]?.label??s.outcome})},{key:"time",header:"Tiempo",align:"right",render:s=>e.jsxs("div",{className:"text-right whitespace-nowrap",children:[e.jsx("p",{className:"text-sm font-medium",children:y(s.responseMs)}),e.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Claude ",y(s.claudeMs)]})]})},{key:"tokens",header:"Tokens",align:"right",hideOnMobile:!0,render:s=>e.jsxs("div",{className:"text-right text-xs whitespace-nowrap",children:[e.jsxs("p",{children:[i(s.inputTokens+s.cacheReadTokens+s.cacheWriteTokens)," entrada"]}),e.jsxs("p",{className:"text-muted-foreground",children:[i(s.outputTokens)," salida"]})]})},{key:"cost",header:"Costo",align:"right",render:s=>e.jsx("span",{className:"text-sm font-semibold tabular-nums whitespace-nowrap",children:E(s.costUsd)})}];return e.jsxs(le,{children:[e.jsx(ne,{title:"Uso de la IA",description:"Cuánto tarda y cuánto cuesta cada respuesta de tu agente",icon:K,actions:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(S,{variant:"outline",size:"sm",onClick:H,disabled:C,children:[e.jsx(ie,{className:`w-4 h-4 mr-2 ${C?"animate-pulse":""}`}),"Exportar CSV"]}),e.jsxs(S,{variant:"outline",size:"sm",onClick:c,disabled:d.isFetching||a.isFetching,children:[e.jsx(Q,{className:`w-4 h-4 mr-2 ${a.isFetching?"animate-spin":""}`}),"Actualizar"]})]})}),e.jsxs(oe,{maxWidth:"7xl",children:[e.jsxs("div",{className:"flex flex-wrap gap-3 mb-6",children:[e.jsxs(D,{value:n,onValueChange:u(h),children:[e.jsx(I,{className:"w-[180px]",children:e.jsx(q,{})}),e.jsx(A,{children:he.map(s=>e.jsx(k,{value:s.value,children:s.label},s.value))})]}),e.jsxs(D,{value:p,onValueChange:u(L),children:[e.jsx(I,{className:"w-[200px]",children:e.jsx(q,{})}),e.jsxs(A,{children:[e.jsx(k,{value:"chat",children:"Clientes"}),e.jsx(k,{value:"prueba",children:"Pruebas del agente"}),e.jsx(k,{value:"all",children:"Clientes y pruebas"})]})]}),e.jsxs(D,{value:b,onValueChange:u(O),children:[e.jsx(I,{className:"w-[200px]",children:e.jsx(q,{})}),e.jsxs(A,{children:[e.jsx(k,{value:"all",children:"Todos los resultados"}),Object.keys(w).map(s=>e.jsx(k,{value:s,children:w[s].label},s))]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4 mb-3",children:[e.jsx(P,{title:"Interacciones",value:l?i(l.totalInteractions):"—",subtitle:l?`${i(l.totalTickets)} conversaciones`:void 0,icon:de,iconColor:"text-blue-500",iconBgColor:"bg-blue-500/10",loading:d.isLoading}),e.jsx(P,{title:"Costo total",value:l?E(l.totalCost):"—",subtitle:l?`${E(l.avgCost)} por interacción`:void 0,icon:Y,iconColor:"text-emerald-500",iconBgColor:"bg-emerald-500/10",loading:d.isLoading}),e.jsx(P,{title:"Tiempo de respuesta",value:l?y(l.avgResponseMs):"—",subtitle:l?`Promedio · Claude ${y(l.avgClaudeMs)}`:void 0,icon:G,iconColor:"text-amber-500",iconBgColor:"bg-amber-500/10",loading:d.isLoading}),e.jsx(P,{title:"Tokens",value:l?i(l.totalInputTokens+l.totalCacheReadTokens+l.totalCacheWriteTokens+l.totalOutputTokens):"—",subtitle:l?`${i(l.totalInputTokens+l.totalCacheReadTokens+l.totalCacheWriteTokens)} entrada · ${i(l.totalOutputTokens)} salida`:void 0,icon:ce,iconColor:"text-violet-500",iconBgColor:"bg-violet-500/10",loading:d.isLoading})]}),e.jsxs("p",{className:"text-xs text-muted-foreground mb-6",children:["El costo es un estimado con los precios de lista de Anthropic. Lo que te cobran de verdad está en"," ",e.jsx("a",{href:"https://console.anthropic.com",target:"_blank",rel:"noreferrer",className:"underline hover:text-foreground",children:"console.anthropic.com"}),".",l&&l.unpricedInteractions>0?` ${i(l.unpricedInteractions)} interacciones usaron un modelo sin precio conocido y no suman al costo.`:""," ","El tiempo de respuesta va desde el último mensaje del cliente hasta que sale la respuesta; incluye los segundos que el agente espera por si el cliente sigue escribiendo."]}),e.jsx(ue,{columns:V,data:a.data?.data??[],keyExtractor:s=>s.id,isLoading:a.isLoading,onRowClick:T,emptyMessage:"Todavía no hay interacciones del agente en este período.",pagination:a.data&&a.data.pagination.totalPages>1?{...a.data.pagination,onPageChange:o}:void 0})]}),e.jsx(J,{open:!!r,onOpenChange:s=>!s&&T(null),children:e.jsx(X,{className:"w-full sm:max-w-lg overflow-y-auto",children:r&&e.jsxs(e.Fragment,{children:[e.jsxs(Z,{children:[e.jsx(ee,{children:B(r)}),e.jsx(se,{children:U(r.createdAt,{style:"full"})})]}),e.jsxs("div",{className:"px-4 pb-6 space-y-5 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(M,{variant:"outline",className:w[r.outcome]?.className,children:w[r.outcome]?.label??r.outcome}),e.jsxs(M,{variant:"outline",children:[e.jsx(ae,{className:"w-3 h-3 mr-1"}),pe[r.model]??r.model]})]}),e.jsxs("section",{children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground mb-1",children:"El cliente escribió"}),e.jsx("p",{className:"whitespace-pre-wrap rounded-lg bg-muted/50 p-3",children:r.question??"—"})]}),e.jsxs("section",{children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground mb-1",children:"El agente respondió"}),e.jsx("p",{className:"whitespace-pre-wrap rounded-lg bg-primary/5 p-3",children:r.answer??"—"})]}),r.error&&e.jsxs("section",{children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground mb-1",children:"Error"}),e.jsx("p",{className:"rounded-lg bg-red-500/10 p-3 text-red-600 dark:text-red-400 break-words",children:r.error})]}),e.jsxs("dl",{className:"grid grid-cols-2 gap-x-4 gap-y-3",children:[e.jsx(x,{label:"Costo",value:E(r.costUsd)}),e.jsx(x,{label:"Tiempo de respuesta",value:y(r.responseMs)}),e.jsx(x,{label:"Tiempo de Claude",value:y(r.claudeMs)}),e.jsx(x,{label:"Llamadas a Claude",value:i(r.steps)}),e.jsx(x,{label:"Tokens de entrada",value:i(r.inputTokens)}),e.jsx(x,{label:"Tokens de salida",value:i(r.outputTokens)}),e.jsx(x,{label:"Leídos de caché",value:i(r.cacheReadTokens)}),e.jsx(x,{label:"Escritos en caché",value:i(r.cacheWriteTokens)})]}),e.jsxs("section",{children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground mb-2",children:"Herramientas que usó"}),r.tools.length?e.jsx("div",{className:"flex flex-wrap gap-1.5",children:r.tools.map((s,v)=>e.jsx(M,{variant:"secondary",className:"font-mono text-[11px]",children:s},`${s}-${v}`))}):e.jsx("p",{className:"text-muted-foreground",children:"Ninguna"})]}),r.conversationId&&r.source==="chat"&&e.jsxs(S,{className:"w-full",onClick:()=>t(`/bandeja?ticket=${r.conversationId}`),children:[e.jsx(me,{className:"w-4 h-4 mr-2"}),"Abrir la conversación"]})]})]})})})]})}function x({label:t,value:n}){return e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:t}),e.jsx("dd",{className:"font-medium tabular-nums",children:n})]})}export{Ee as default};
@@ -1 +1 @@
1
- import{u as g,a as h,j as e,N as b,I as n,B as f,L as v,b as j}from"./index-DsyZ_FlA.js";import{b as o}from"./recharts-DrC5kNsx.js";function C(){const m=g(),c=h(t=>t.login),[a,p]=o.useState({adminToken:"",name:"",email:"",password:""}),[l,d]=o.useState(null),[i,u]=o.useState(!1),r=t=>s=>p({...a,[t]:s.target.value}),x=async t=>{t.preventDefault(),u(!0),d(null);try{const{data:s}=await j.post("/auth/lite-setup",a);c(s.user,s.access_token),m("/dashboard",{replace:!0})}catch(s){d(s?.response?.data?.message??"No pudimos crear el administrador. Intenta de nuevo.")}finally{u(!1)}};return e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background-light p-6 dark:bg-background-dark",children:e.jsxs("form",{onSubmit:x,className:"w-full max-w-sm space-y-4 rounded-2xl border border-border bg-card p-8 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(b,{size:40,className:"rounded-lg shadow-sm"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-bold text-foreground",children:"Crea el administrador"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Usa la llave de admin que te mostró el instalador."})]})]}),e.jsx(n,{type:"password",placeholder:"Llave de admin",required:!0,value:a.adminToken,onChange:r("adminToken")}),e.jsx(n,{placeholder:"Tu nombre",required:!0,value:a.name,onChange:r("name"),autoComplete:"name"}),e.jsx(n,{type:"email",placeholder:"Correo",required:!0,value:a.email,onChange:r("email"),autoComplete:"email"}),e.jsx(n,{type:"password",placeholder:"Contraseña (mínimo 8 caracteres)",required:!0,minLength:8,value:a.password,onChange:r("password"),autoComplete:"new-password"}),l&&e.jsx("p",{className:"rounded-lg bg-destructive/10 px-3 py-2 text-sm text-destructive",children:l}),e.jsx(f,{type:"submit",className:"w-full bg-brand text-white hover:bg-blue-600",disabled:i,children:i?"Creando…":"Crear y entrar"}),e.jsxs("p",{className:"text-center text-sm text-muted-foreground",children:["¿Ya tienes usuario?"," ",e.jsx(v,{to:"/login",className:"font-semibold text-brand",children:"Inicia sesión"})]})]})})}export{C as default};
1
+ import{u as g,a as h,j as e,N as b,I as n,B as f,L as v,b as j}from"./index-43NA2pdZ.js";import{b as o}from"./recharts-DrC5kNsx.js";function C(){const m=g(),c=h(t=>t.login),[a,p]=o.useState({adminToken:"",name:"",email:"",password:""}),[l,d]=o.useState(null),[i,u]=o.useState(!1),r=t=>s=>p({...a,[t]:s.target.value}),x=async t=>{t.preventDefault(),u(!0),d(null);try{const{data:s}=await j.post("/auth/lite-setup",a);c(s.user,s.access_token),m("/dashboard",{replace:!0})}catch(s){d(s?.response?.data?.message??"No pudimos crear el administrador. Intenta de nuevo.")}finally{u(!1)}};return e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background-light p-6 dark:bg-background-dark",children:e.jsxs("form",{onSubmit:x,className:"w-full max-w-sm space-y-4 rounded-2xl border border-border bg-card p-8 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(b,{size:40,className:"rounded-lg shadow-sm"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-bold text-foreground",children:"Crea el administrador"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Usa la llave de admin que te mostró el instalador."})]})]}),e.jsx(n,{type:"password",placeholder:"Llave de admin",required:!0,value:a.adminToken,onChange:r("adminToken")}),e.jsx(n,{placeholder:"Tu nombre",required:!0,value:a.name,onChange:r("name"),autoComplete:"name"}),e.jsx(n,{type:"email",placeholder:"Correo",required:!0,value:a.email,onChange:r("email"),autoComplete:"email"}),e.jsx(n,{type:"password",placeholder:"Contraseña (mínimo 8 caracteres)",required:!0,minLength:8,value:a.password,onChange:r("password"),autoComplete:"new-password"}),l&&e.jsx("p",{className:"rounded-lg bg-destructive/10 px-3 py-2 text-sm text-destructive",children:l}),e.jsx(f,{type:"submit",className:"w-full bg-brand text-white hover:bg-blue-600",disabled:i,children:i?"Creando…":"Crear y entrar"}),e.jsxs("p",{className:"text-center text-sm text-muted-foreground",children:["¿Ya tienes usuario?"," ",e.jsx(v,{to:"/login",className:"font-semibold text-brand",children:"Inicia sesión"})]})]})})}export{C as default};
@@ -0,0 +1,3 @@
1
+ import{j as o,l as p}from"./index-43NA2pdZ.js";import{b as l}from"./recharts-DrC5kNsx.js";import{f as d,M as c,r as i}from"./index-DIxON2Dm.js";function m(e){d(e,[/\r?\n|\r/g,u])}function u(){return{type:"break"}}function k(){return function(e){m(e)}}const f=e=>{let r=e.replace(/\r\n/g,`
2
+ `).replace(/\r/g,`
3
+ `);return r=r.replace(/(^|[^*])\*([^*]+)\*([^*]|$)/gm,"$1**$2**$3"),r=r.replace(/~([^~]+)~/g,"~~$1~~"),r},x=l.memo(({content:e,className:r,isInverted:b=!1,variant:s="standard"})=>{const a=s==="whatsapp"?f(e):e;return o.jsx("div",{className:p("prose prose-sm max-w-none break-words","prose-p:m-0 prose-p:leading-relaxed","prose-headings:m-0 prose-headings:font-bold prose-headings:text-current","prose-strong:font-bold prose-strong:text-current","prose-a:text-blue-500 prose-a:no-underline hover:prose-a:underline","prose-ul:m-0 prose-ul:pl-4 prose-ol:m-0 prose-ol:pl-4","prose-li:m-0","prose-blockquote:border-l-2 prose-blockquote:pl-2 prose-blockquote:italic prose-blockquote:text-current/80","text-current","dark:prose-invert",r),children:o.jsx(c,{remarkPlugins:[i,k],components:{a:({node:t,...n})=>o.jsx("a",{target:"_blank",rel:"noopener noreferrer",...n}),p:({node:t,...n})=>o.jsx("p",{className:"mb-1 last:mb-0",...n})},children:a})})});x.displayName="MarkdownRenderer";export{x as M};
@@ -0,0 +1 @@
1
+ import{c as R,O as H}from"./index-43NA2pdZ.js";import{i as x,s as S}from"./storage.api-C0ZJBoSz.js";import{a as M,W as N,f as U}from"./mediaLimits-CAYdWqeQ.js";const W=[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]],j=R("image-plus",W);function k(v){return new Worker("/assets/hash.worker-BQBibGe2.js",{name:v?.name})}class p{static instance;constructor(){}static getInstance(){return p.instance||(p.instance=new p),p.instance}async calculateHash(e){return new Promise((s,i)=>{const t=new k;t.onmessage=a=>{s(a.data),t.terminate()},t.onerror=a=>{i(a),t.terminate()},t.postMessage(e)})}}const D=p.getInstance();class u{static instance;constructor(){}static getInstance(){return u.instance||(u.instance=new u),u.instance}async processFile(e,s){const i=M(e.type),t=e.size;if(!i)return{action:"REJECT",file:e,wasOptimized:!1,originalSize:t,finalSize:t,reason:"Tipo de archivo no soportado"};if(s.channelType?.toUpperCase()==="WHATSAPP"&&e.type==="video/quicktime")return{action:"REJECT",file:e,wasOptimized:!1,originalSize:t,finalSize:t,reason:"El formato .MOV (iPhone) no es compatible con WhatsApp.",suggestion:"Por favor convierte el video a .MP4 antes de enviarlo."};const n=s[i]?.maxBytes||0;if(e.size<=n)return{action:"SEND_ORIGINAL",file:e,wasOptimized:!1,originalSize:t,finalSize:t};if(i==="image")try{const o=await this.optimizeImage(e,n);return o.size<=n?{action:"OPTIMIZED",file:o,wasOptimized:!0,originalSize:t,finalSize:o.size}:{action:"REJECT",file:e,wasOptimized:!1,originalSize:t,finalSize:o.size,reason:`La imagen no se pudo comprimir lo suficiente. Resultado: ${this.formatBytes(o.size)}, límite: ${this.formatBytes(n)}`}}catch(o){return console.error("[OptimizationService] Compression error:",o),{action:"REJECT",file:e,wasOptimized:!1,originalSize:t,finalSize:t,reason:"Error durante la compresión de imagen"}}return{action:"REJECT",file:e,wasOptimized:!1,originalSize:t,finalSize:t,reason:`El archivo (${this.formatBytes(e.size)}) supera el límite de ${this.formatBytes(n)} para ${i}`}}async optimizeImage(e,s){const t={maxSizeMB:s/1048576,maxWidthOrHeight:1920,useWebWorker:!0,initialQuality:.9,alwaysKeepResolution:!1};return x(e,t)}formatBytes(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}}const L=u.getInstance();class g extends Error{constructor(e,s){super(e),this.suggestion=s,this.name="MediaError",Object.setPrototypeOf(this,g.prototype)}}class h{static instance;constructor(){}static getInstance(){return h.instance||(h.instance=new h),h.instance}async processFile(e,s={}){const{limits:i,channelId:t,onProgress:a,uploadStrategy:n,skipDedup:o}=s;a?.("HASHING",0);const c=await D.calculateHash(e);a?.("HASHING",100);const d=i||N.outbound;if(!o){a?.("CHECKING_DEDUP",0);const r=await H.checkDuplicate(c);if(r.exists&&r.gcsPath){const w=M(e.type),T=(w?d[w]:null)?.maxBytes||0,B=r.fileSizeBytes||r.size,E=B?parseInt(String(B),10):e.size;if(T>0&&E>T&&w!=="image")throw new g(`El archivo (${U(E)}) existe en la nube pero supera el límite de ${U(T)} para este canal.`,"Por favor intenta con un archivo más pequeño.");let I=r.thumbnailUrl,O=r.thumbnailGcsPath;if(!I&&(e.type.startsWith("image/")||e.type.startsWith("video/")))try{a?.("GENERATING_THUMB",0);const b=await this.generateThumbnail(e);a?.("GENERATING_THUMB",100);const G=r.hash||c,P=await S.uploadThumbnailForHash(G,b);P.thumbnailUrl&&(I=P.thumbnailUrl,O=P.thumbnailGcsPath)}catch(b){console.warn("[MediaProcessing] Dedup thumbnail backfill failed:",b)}return a?.("DONE",100),{id:r.id||"",gcsPath:r.gcsPath,signedUrl:r.signedUrl||"",thumbnailUrl:I,thumbnailGcsPath:O,mimeType:r.mimeType||e.type,size:E,hash:r.hash||c,originalHash:c,isOptimized:!1,isDuplicate:!0}}a?.("CHECKING_DEDUP",100)}a?.("OPTIMIZING",0);let m=e,f=!1;const l=await L.processFile(e,d);if(l.action==="REJECT")throw new g(l.reason||"File rejected",l.suggestion);l.action==="OPTIMIZED"&&(m=l.file,f=!0),a?.("OPTIMIZING",100),a?.("GENERATING_THUMB",0);let y;if(m.type.startsWith("image/")||m.type.startsWith("video/"))try{y=await this.generateThumbnail(m)}catch(r){console.warn("[MediaProcessing] Thumbnail generation failed:",r)}a?.("GENERATING_THUMB",100),a?.("UPLOADING",0);let z;return n?z=await n(m,c,y):z=await this.uploadToBackendStream(m,c,y,t),a?.("DONE",100),{...z,isOptimized:f,originalHash:c,...f?{optimizationStats:{originalSize:l.originalSize,optimizedSize:l.finalSize}}:{}}}async generateThumbnail(e){return e.type.startsWith("video/")?this.generateVideoThumbnail(e):x(e,{maxSizeMB:.05,maxWidthOrHeight:300,useWebWorker:!0,fileType:"image/jpeg"})}async generateVideoThumbnail(e){return new Promise((s,i)=>{const t=document.createElement("video");t.preload="metadata",t.src=URL.createObjectURL(e),t.muted=!0,t.playsInline=!0,t.currentTime=1,t.onloadeddata=async()=>{try{const a=document.createElement("canvas"),n=300,o=Math.min(n/t.videoWidth,n/t.videoHeight,1);a.width=t.videoWidth*o,a.height=t.videoHeight*o,a.getContext("2d")?.drawImage(t,0,0,a.width,a.height);const d=await new Promise(m=>a.toBlob(m,"image/jpeg",.7));d?s(new File([d],"thumbnail.jpg",{type:"image/jpeg"})):i(new Error("Canvas to Blob failed"))}catch(a){i(a)}finally{URL.revokeObjectURL(t.src)}},t.onerror=a=>{URL.revokeObjectURL(t.src),i(a)}})}async uploadToBackendStream(e,s,i,t){const a=new FormData;a.append("file",e),i&&a.append("thumbnail",i),a.append("originalHash",s),t&&a.append("channelId",t);const n=await S.uploadStream(a);return{...n,signedUrl:n.signedUrl,thumbnailUrl:n.thumbnailUrl,thumbnailGcsPath:n.thumbnailGcsPath,isOptimized:!1}}}const J=h.getInstance();export{j as I,D as h,J as m};
@@ -0,0 +1 @@
1
+ import{ay as a}from"./index-43NA2pdZ.js";import"./recharts-DrC5kNsx.js";const t=a;export{t as NewCampaignPage,a as default};
@@ -0,0 +1 @@
1
+ import{ay as e}from"./index-43NA2pdZ.js";import"./recharts-DrC5kNsx.js";const r=e;export{r as OrdersConfigPage,e as default};
@@ -0,0 +1 @@
1
+ import{ay as e}from"./index-43NA2pdZ.js";import"./recharts-DrC5kNsx.js";const r=e;export{r as OrdersPage,e as default};
@@ -1 +1 @@
1
- import{j as s,l as c,F as i,X as m}from"./index-DsyZ_FlA.js";import{b as o}from"./recharts-DrC5kNsx.js";const l={minLength:9};function h(e){const t={minLength:e.length>=l.minLength,hasUppercase:/[A-Z]/.test(e),hasLowercase:/[a-z]/.test(e),hasNumber:/[0-9]/.test(e)};return{isValid:Object.values(t).every(Boolean),checks:t}}const r=({met:e,label:t,detail:a})=>s.jsxs("div",{className:c("flex items-center gap-2 text-sm transition-colors",e?"text-emerald-600 dark:text-emerald-400":"text-muted-foreground"),children:[s.jsx("div",{className:c("flex items-center justify-center w-5 h-5 rounded-full transition-colors",e?"bg-emerald-100 dark:bg-emerald-900/30":"bg-muted"),children:e?s.jsx(i,{className:"w-3 h-3"}):s.jsx(m,{className:"w-3 h-3 opacity-50"})}),s.jsxs("span",{children:[t,a&&s.jsx("span",{className:"text-muted-foreground ml-1",children:a})]})]}),u=({password:e,className:t})=>{const a=o.useMemo(()=>h(e),[e]),{checks:n}=a;return s.jsxs("div",{className:c("space-y-1.5 py-2",t),children:[s.jsx(r,{met:n.minLength,label:`Longitud mínima de ${l.minLength} caracteres`,detail:`(${e.length}/${l.minLength})`}),s.jsx(r,{met:n.hasUppercase,label:"Mayúsculas (A-Z)"}),s.jsx(r,{met:n.hasLowercase,label:"Minúsculas (a-z)"}),s.jsx(r,{met:n.hasNumber,label:"Números (0-9)"})]})};export{u as P,h as v};
1
+ import{j as s,l as c,D as i,X as m}from"./index-43NA2pdZ.js";import{b as o}from"./recharts-DrC5kNsx.js";const l={minLength:9};function h(e){const t={minLength:e.length>=l.minLength,hasUppercase:/[A-Z]/.test(e),hasLowercase:/[a-z]/.test(e),hasNumber:/[0-9]/.test(e)};return{isValid:Object.values(t).every(Boolean),checks:t}}const r=({met:e,label:t,detail:a})=>s.jsxs("div",{className:c("flex items-center gap-2 text-sm transition-colors",e?"text-emerald-600 dark:text-emerald-400":"text-muted-foreground"),children:[s.jsx("div",{className:c("flex items-center justify-center w-5 h-5 rounded-full transition-colors",e?"bg-emerald-100 dark:bg-emerald-900/30":"bg-muted"),children:e?s.jsx(i,{className:"w-3 h-3"}):s.jsx(m,{className:"w-3 h-3 opacity-50"})}),s.jsxs("span",{children:[t,a&&s.jsx("span",{className:"text-muted-foreground ml-1",children:a})]})]}),u=({password:e,className:t})=>{const a=o.useMemo(()=>h(e),[e]),{checks:n}=a;return s.jsxs("div",{className:c("space-y-1.5 py-2",t),children:[s.jsx(r,{met:n.minLength,label:`Longitud mínima de ${l.minLength} caracteres`,detail:`(${e.length}/${l.minLength})`}),s.jsx(r,{met:n.hasUppercase,label:"Mayúsculas (A-Z)"}),s.jsx(r,{met:n.hasLowercase,label:"Minúsculas (a-z)"}),s.jsx(r,{met:n.hasNumber,label:"Números (0-9)"})]})};export{u as P,h as v};
@@ -0,0 +1 @@
1
+ import{ay as e}from"./index-43NA2pdZ.js";import"./recharts-DrC5kNsx.js";export{e as default};
@@ -0,0 +1 @@
1
+ import{ay as e}from"./index-43NA2pdZ.js";import"./recharts-DrC5kNsx.js";export{e as default};
@@ -0,0 +1 @@
1
+ import{ay as e}from"./index-43NA2pdZ.js";import"./recharts-DrC5kNsx.js";export{e as default};