denchclaw 2.5.2 → 2.5.4

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 (592) hide show
  1. package/README.md +8 -0
  2. package/apps/web/.next/standalone/apps/web/.next/BUILD_ID +1 -1
  3. package/apps/web/.next/standalone/apps/web/.next/app-build-manifest.json +160 -167
  4. package/apps/web/.next/standalone/apps/web/.next/app-path-routes-manifest.json +33 -34
  5. package/apps/web/.next/standalone/apps/web/.next/build-manifest.json +2 -2
  6. package/apps/web/.next/standalone/apps/web/.next/cache/config.json +3 -3
  7. package/apps/web/.next/standalone/apps/web/.next/prerender-manifest.json +3 -3
  8. package/apps/web/.next/standalone/apps/web/.next/required-server-files.json +1 -1
  9. package/apps/web/.next/standalone/apps/web/.next/routes-manifest.json +1 -1
  10. package/apps/web/.next/standalone/apps/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  11. package/apps/web/.next/standalone/apps/web/.next/server/app/api/apps/cron/route_client-reference-manifest.js +1 -1
  12. package/apps/web/.next/standalone/apps/web/.next/server/app/api/apps/proxy/route_client-reference-manifest.js +1 -1
  13. package/apps/web/.next/standalone/apps/web/.next/server/app/api/apps/route_client-reference-manifest.js +1 -1
  14. package/apps/web/.next/standalone/apps/web/.next/server/app/api/apps/serve/[...path]/route_client-reference-manifest.js +1 -1
  15. package/apps/web/.next/standalone/apps/web/.next/server/app/api/apps/store/route_client-reference-manifest.js +1 -1
  16. package/apps/web/.next/standalone/apps/web/.next/server/app/api/apps/webhooks/[...path]/route_client-reference-manifest.js +1 -1
  17. package/apps/web/.next/standalone/apps/web/.next/server/app/api/chat/active/route.js.nft.json +1 -1
  18. package/apps/web/.next/standalone/apps/web/.next/server/app/api/chat/active/route_client-reference-manifest.js +1 -1
  19. package/apps/web/.next/standalone/apps/web/.next/server/app/api/chat/route.js +1 -1
  20. package/apps/web/.next/standalone/apps/web/.next/server/app/api/chat/route.js.nft.json +1 -1
  21. package/apps/web/.next/standalone/apps/web/.next/server/app/api/chat/route_client-reference-manifest.js +1 -1
  22. package/apps/web/.next/standalone/apps/web/.next/server/app/api/chat/runs/route.js.nft.json +1 -1
  23. package/apps/web/.next/standalone/apps/web/.next/server/app/api/chat/runs/route_client-reference-manifest.js +1 -1
  24. package/apps/web/.next/standalone/apps/web/.next/server/app/api/chat/stop/route.js +1 -1
  25. package/apps/web/.next/standalone/apps/web/.next/server/app/api/chat/stop/route.js.nft.json +1 -1
  26. package/apps/web/.next/standalone/apps/web/.next/server/app/api/chat/stop/route_client-reference-manifest.js +1 -1
  27. package/apps/web/.next/standalone/apps/web/.next/server/app/api/chat/stream/route.js.nft.json +1 -1
  28. package/apps/web/.next/standalone/apps/web/.next/server/app/api/chat/stream/route_client-reference-manifest.js +1 -1
  29. package/apps/web/.next/standalone/apps/web/.next/server/app/api/chat/subagents/route.js.nft.json +1 -1
  30. package/apps/web/.next/standalone/apps/web/.next/server/app/api/chat/subagents/route_client-reference-manifest.js +1 -1
  31. package/apps/web/.next/standalone/apps/web/.next/server/app/api/composio/callback/route.js +8 -8
  32. package/apps/web/.next/standalone/apps/web/.next/server/app/api/composio/callback/route.js.nft.json +1 -1
  33. package/apps/web/.next/standalone/apps/web/.next/server/app/api/composio/callback/route_client-reference-manifest.js +1 -1
  34. package/apps/web/.next/standalone/apps/web/.next/server/app/api/composio/connect/route_client-reference-manifest.js +1 -1
  35. package/apps/web/.next/standalone/apps/web/.next/server/app/api/composio/connections/route.js +1 -1
  36. package/apps/web/.next/standalone/apps/web/.next/server/app/api/composio/connections/route.js.nft.json +1 -1
  37. package/apps/web/.next/standalone/apps/web/.next/server/app/api/composio/connections/route_client-reference-manifest.js +1 -1
  38. package/apps/web/.next/standalone/apps/web/.next/server/app/api/composio/disconnect/route.js +1 -1
  39. package/apps/web/.next/standalone/apps/web/.next/server/app/api/composio/disconnect/route.js.nft.json +1 -1
  40. package/apps/web/.next/standalone/apps/web/.next/server/app/api/composio/disconnect/route_client-reference-manifest.js +1 -1
  41. package/apps/web/.next/standalone/apps/web/.next/server/app/api/composio/status/route.js +7 -1
  42. package/apps/web/.next/standalone/apps/web/.next/server/app/api/composio/status/route.js.nft.json +1 -1
  43. package/apps/web/.next/standalone/apps/web/.next/server/app/api/composio/status/route_client-reference-manifest.js +1 -1
  44. package/apps/web/.next/standalone/apps/web/.next/server/app/api/composio/toolkits/route_client-reference-manifest.js +1 -1
  45. package/apps/web/.next/standalone/apps/web/.next/server/app/api/cron/jobs/[jobId]/runs/route_client-reference-manifest.js +1 -1
  46. package/apps/web/.next/standalone/apps/web/.next/server/app/api/cron/jobs/route_client-reference-manifest.js +1 -1
  47. package/apps/web/.next/standalone/apps/web/.next/server/app/api/cron/runs/[sessionId]/route_client-reference-manifest.js +1 -1
  48. package/apps/web/.next/standalone/apps/web/.next/server/app/api/cron/runs/search-transcript/route_client-reference-manifest.js +1 -1
  49. package/apps/web/.next/standalone/apps/web/.next/server/app/api/feedback/route.js +1 -1
  50. package/apps/web/.next/standalone/apps/web/.next/server/app/api/feedback/route_client-reference-manifest.js +1 -1
  51. package/apps/web/.next/standalone/apps/web/.next/server/app/api/gateway/channels/route_client-reference-manifest.js +1 -1
  52. package/apps/web/.next/standalone/apps/web/.next/server/app/api/gateway/chat/route.js.nft.json +1 -1
  53. package/apps/web/.next/standalone/apps/web/.next/server/app/api/gateway/chat/route_client-reference-manifest.js +1 -1
  54. package/apps/web/.next/standalone/apps/web/.next/server/app/api/gateway/chat/stream/route.js.nft.json +1 -1
  55. package/apps/web/.next/standalone/apps/web/.next/server/app/api/gateway/chat/stream/route_client-reference-manifest.js +1 -1
  56. package/apps/web/.next/standalone/apps/web/.next/server/app/api/gateway/sessions/[id]/route_client-reference-manifest.js +1 -1
  57. package/apps/web/.next/standalone/apps/web/.next/server/app/api/gateway/sessions/route_client-reference-manifest.js +1 -1
  58. package/apps/web/.next/standalone/apps/web/.next/server/app/api/integrations/[id]/toggle/route.js.nft.json +1 -1
  59. package/apps/web/.next/standalone/apps/web/.next/server/app/api/integrations/[id]/toggle/route_client-reference-manifest.js +1 -1
  60. package/apps/web/.next/standalone/apps/web/.next/server/app/api/integrations/repair/route.js.nft.json +1 -1
  61. package/apps/web/.next/standalone/apps/web/.next/server/app/api/integrations/repair/route_client-reference-manifest.js +1 -1
  62. package/apps/web/.next/standalone/apps/web/.next/server/app/api/integrations/route.js.nft.json +1 -1
  63. package/apps/web/.next/standalone/apps/web/.next/server/app/api/integrations/route_client-reference-manifest.js +1 -1
  64. package/apps/web/.next/standalone/apps/web/.next/server/app/api/memories/route_client-reference-manifest.js +1 -1
  65. package/apps/web/.next/standalone/apps/web/.next/server/app/api/profiles/route_client-reference-manifest.js +1 -1
  66. package/apps/web/.next/standalone/apps/web/.next/server/app/api/profiles/switch/route_client-reference-manifest.js +1 -1
  67. package/apps/web/.next/standalone/apps/web/.next/server/app/api/sessions/[sessionId]/route_client-reference-manifest.js +1 -1
  68. package/apps/web/.next/standalone/apps/web/.next/server/app/api/sessions/route_client-reference-manifest.js +1 -1
  69. package/apps/web/.next/standalone/apps/web/.next/server/app/api/settings/cloud/route.js +1 -1
  70. package/apps/web/.next/standalone/apps/web/.next/server/app/api/settings/cloud/route.js.nft.json +1 -1
  71. package/apps/web/.next/standalone/apps/web/.next/server/app/api/settings/cloud/route_client-reference-manifest.js +1 -1
  72. package/apps/web/.next/standalone/apps/web/.next/server/app/api/skills/[slug]/content/route_client-reference-manifest.js +1 -1
  73. package/apps/web/.next/standalone/apps/web/.next/server/app/api/skills/[slug]/route.js +1 -1
  74. package/apps/web/.next/standalone/apps/web/.next/server/app/api/skills/[slug]/route_client-reference-manifest.js +1 -1
  75. package/apps/web/.next/standalone/apps/web/.next/server/app/api/skills/browse/route_client-reference-manifest.js +1 -1
  76. package/apps/web/.next/standalone/apps/web/.next/server/app/api/skills/install/route_client-reference-manifest.js +1 -1
  77. package/apps/web/.next/standalone/apps/web/.next/server/app/api/skills/route.js +1 -1
  78. package/apps/web/.next/standalone/apps/web/.next/server/app/api/skills/route_client-reference-manifest.js +1 -1
  79. package/apps/web/.next/standalone/apps/web/.next/server/app/api/terminal/port/route_client-reference-manifest.js +1 -1
  80. package/apps/web/.next/standalone/apps/web/.next/server/app/api/voice/speech/route.js +1 -1
  81. package/apps/web/.next/standalone/apps/web/.next/server/app/api/voice/speech/route.js.nft.json +1 -1
  82. package/apps/web/.next/standalone/apps/web/.next/server/app/api/voice/speech/route_client-reference-manifest.js +1 -1
  83. package/apps/web/.next/standalone/apps/web/.next/server/app/api/voice/transcribe/route.js +1 -1
  84. package/apps/web/.next/standalone/apps/web/.next/server/app/api/voice/transcribe/route.js.nft.json +1 -1
  85. package/apps/web/.next/standalone/apps/web/.next/server/app/api/voice/transcribe/route_client-reference-manifest.js +1 -1
  86. package/apps/web/.next/standalone/apps/web/.next/server/app/api/voice/voices/route.js +1 -1
  87. package/apps/web/.next/standalone/apps/web/.next/server/app/api/voice/voices/route.js.nft.json +1 -1
  88. package/apps/web/.next/standalone/apps/web/.next/server/app/api/voice/voices/route_client-reference-manifest.js +1 -1
  89. package/apps/web/.next/standalone/apps/web/.next/server/app/api/web-sessions/[id]/messages/route_client-reference-manifest.js +1 -1
  90. package/apps/web/.next/standalone/apps/web/.next/server/app/api/web-sessions/[id]/route.js.nft.json +1 -1
  91. package/apps/web/.next/standalone/apps/web/.next/server/app/api/web-sessions/[id]/route_client-reference-manifest.js +1 -1
  92. package/apps/web/.next/standalone/apps/web/.next/server/app/api/web-sessions/route.js +1 -1
  93. package/apps/web/.next/standalone/apps/web/.next/server/app/api/web-sessions/route_client-reference-manifest.js +1 -1
  94. package/apps/web/.next/standalone/apps/web/.next/server/app/api/workspace/assets/[...path]/route_client-reference-manifest.js +1 -1
  95. package/apps/web/.next/standalone/apps/web/.next/server/app/api/workspace/browse/route_client-reference-manifest.js +1 -1
  96. package/apps/web/.next/standalone/apps/web/.next/server/app/api/workspace/browse-file/route_client-reference-manifest.js +1 -1
  97. package/apps/web/.next/standalone/apps/web/.next/server/app/api/workspace/context/route_client-reference-manifest.js +1 -1
  98. package/apps/web/.next/standalone/apps/web/.next/server/app/api/workspace/copy/route_client-reference-manifest.js +1 -1
  99. package/apps/web/.next/standalone/apps/web/.next/server/app/api/workspace/db/introspect/route_client-reference-manifest.js +1 -1
  100. package/apps/web/.next/standalone/apps/web/.next/server/app/api/workspace/db/query/route_client-reference-manifest.js +1 -1
  101. package/apps/web/.next/standalone/apps/web/.next/server/app/api/workspace/delete/route.js +1 -1
  102. package/apps/web/.next/standalone/apps/web/.next/server/app/api/workspace/delete/route_client-reference-manifest.js +1 -1
  103. package/apps/web/.next/standalone/apps/web/.next/server/app/api/workspace/execute/route_client-reference-manifest.js +1 -1
  104. package/apps/web/.next/standalone/apps/web/.next/server/app/api/workspace/file/route_client-reference-manifest.js +1 -1
  105. package/apps/web/.next/standalone/apps/web/.next/server/app/api/workspace/init/route.js +1 -1
  106. package/apps/web/.next/standalone/apps/web/.next/server/app/api/workspace/init/route_client-reference-manifest.js +1 -1
  107. package/apps/web/.next/standalone/apps/web/.next/server/app/api/workspace/link-preview/route_client-reference-manifest.js +1 -1
  108. package/apps/web/.next/standalone/apps/web/.next/server/app/api/workspace/list/route_client-reference-manifest.js +1 -1
  109. package/apps/web/.next/standalone/apps/web/.next/server/app/api/workspace/mkdir/route_client-reference-manifest.js +1 -1
  110. package/apps/web/.next/standalone/apps/web/.next/server/app/api/workspace/move/route_client-reference-manifest.js +1 -1
  111. package/apps/web/.next/standalone/apps/web/.next/server/app/api/workspace/objects/[name]/actions/route_client-reference-manifest.js +1 -1
  112. package/apps/web/.next/standalone/apps/web/.next/server/app/api/workspace/objects/[name]/actions/runs/route_client-reference-manifest.js +1 -1
  113. package/apps/web/.next/standalone/apps/web/.next/server/app/api/workspace/objects/[name]/display-field/route_client-reference-manifest.js +1 -1
  114. package/apps/web/.next/standalone/apps/web/.next/server/app/api/workspace/objects/[name]/entries/[id]/content/route_client-reference-manifest.js +1 -1
  115. package/apps/web/.next/standalone/apps/web/.next/server/app/api/workspace/objects/[name]/entries/[id]/route_client-reference-manifest.js +1 -1
  116. package/apps/web/.next/standalone/apps/web/.next/server/app/api/workspace/objects/[name]/entries/bulk-delete/route_client-reference-manifest.js +1 -1
  117. package/apps/web/.next/standalone/apps/web/.next/server/app/api/workspace/objects/[name]/entries/options/route_client-reference-manifest.js +1 -1
  118. package/apps/web/.next/standalone/apps/web/.next/server/app/api/workspace/objects/[name]/entries/route.js +1 -1
  119. package/apps/web/.next/standalone/apps/web/.next/server/app/api/workspace/objects/[name]/entries/route_client-reference-manifest.js +1 -1
  120. package/apps/web/.next/standalone/apps/web/.next/server/app/api/workspace/objects/[name]/fields/[fieldId]/enum-rename/route_client-reference-manifest.js +1 -1
  121. package/apps/web/.next/standalone/apps/web/.next/server/app/api/workspace/objects/[name]/fields/[fieldId]/route_client-reference-manifest.js +1 -1
  122. package/apps/web/.next/standalone/apps/web/.next/server/app/api/workspace/objects/[name]/fields/reorder/route_client-reference-manifest.js +1 -1
  123. package/apps/web/.next/standalone/apps/web/.next/server/app/api/workspace/objects/[name]/fields/route_client-reference-manifest.js +1 -1
  124. package/apps/web/.next/standalone/apps/web/.next/server/app/api/workspace/objects/[name]/route_client-reference-manifest.js +1 -1
  125. package/apps/web/.next/standalone/apps/web/.next/server/app/api/workspace/objects/[name]/views/route_client-reference-manifest.js +1 -1
  126. package/apps/web/.next/standalone/apps/web/.next/server/app/api/workspace/open-file/route_client-reference-manifest.js +1 -1
  127. package/apps/web/.next/standalone/apps/web/.next/server/app/api/workspace/path-info/route_client-reference-manifest.js +1 -1
  128. package/apps/web/.next/standalone/apps/web/.next/server/app/api/workspace/query/route_client-reference-manifest.js +1 -1
  129. package/apps/web/.next/standalone/apps/web/.next/server/app/api/workspace/raw-file/route_client-reference-manifest.js +1 -1
  130. package/apps/web/.next/standalone/apps/web/.next/server/app/api/workspace/rename/route_client-reference-manifest.js +1 -1
  131. package/apps/web/.next/standalone/apps/web/.next/server/app/api/workspace/reports/execute/route.js +1 -1
  132. package/apps/web/.next/standalone/apps/web/.next/server/app/api/workspace/reports/execute/route_client-reference-manifest.js +1 -1
  133. package/apps/web/.next/standalone/apps/web/.next/server/app/api/workspace/search-index/route_client-reference-manifest.js +1 -1
  134. package/apps/web/.next/standalone/apps/web/.next/server/app/api/workspace/suggest-files/route_client-reference-manifest.js +1 -1
  135. package/apps/web/.next/standalone/apps/web/.next/server/app/api/workspace/switch/route.js +1 -1
  136. package/apps/web/.next/standalone/apps/web/.next/server/app/api/workspace/switch/route_client-reference-manifest.js +1 -1
  137. package/apps/web/.next/standalone/apps/web/.next/server/app/api/workspace/thumbnail/route_client-reference-manifest.js +1 -1
  138. package/apps/web/.next/standalone/apps/web/.next/server/app/api/workspace/tree/route_client-reference-manifest.js +1 -1
  139. package/apps/web/.next/standalone/apps/web/.next/server/app/api/workspace/upload/route.js +1 -1
  140. package/apps/web/.next/standalone/apps/web/.next/server/app/api/workspace/upload/route_client-reference-manifest.js +1 -1
  141. package/apps/web/.next/standalone/apps/web/.next/server/app/api/workspace/virtual-file/route_client-reference-manifest.js +1 -1
  142. package/apps/web/.next/standalone/apps/web/.next/server/app/api/workspace/watch/route_client-reference-manifest.js +1 -1
  143. package/apps/web/.next/standalone/apps/web/.next/server/app/api/workspace/write-binary/route_client-reference-manifest.js +1 -1
  144. package/apps/web/.next/standalone/apps/web/.next/server/app/page.js +9 -8
  145. package/apps/web/.next/standalone/apps/web/.next/server/app/page_client-reference-manifest.js +1 -1
  146. package/apps/web/.next/standalone/apps/web/.next/server/app/workspace/page.js +1 -1
  147. package/apps/web/.next/standalone/apps/web/.next/server/app/workspace/page_client-reference-manifest.js +1 -1
  148. package/apps/web/.next/standalone/apps/web/.next/server/app-paths-manifest.json +33 -34
  149. package/apps/web/.next/standalone/apps/web/.next/server/chunks/6426.js +3 -3
  150. package/apps/web/.next/standalone/apps/web/.next/server/chunks/6787.js +1 -1
  151. package/apps/web/.next/standalone/apps/web/.next/server/chunks/687.js +4 -4
  152. package/apps/web/.next/standalone/apps/web/.next/server/chunks/7488.js +1 -1
  153. package/apps/web/.next/standalone/apps/web/.next/server/chunks/7515.js +1 -0
  154. package/apps/web/.next/standalone/apps/web/.next/server/chunks/8306.js +1 -1
  155. package/apps/web/.next/standalone/apps/web/.next/server/functions-config-manifest.json +18 -19
  156. package/apps/web/.next/standalone/apps/web/.next/server/pages/500.html +1 -1
  157. package/apps/web/.next/standalone/apps/web/.next/server/server-reference-manifest.json +1 -1
  158. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/apps/cron/{route-982235d988e17f31.js → route-3f5324f861724fe4.js} +1 -1
  159. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/apps/proxy/{route-982235d988e17f31.js → route-3f5324f861724fe4.js} +1 -1
  160. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/apps/{route-982235d988e17f31.js → route-3f5324f861724fe4.js} +1 -1
  161. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/apps/serve/[...path]/{route-982235d988e17f31.js → route-3f5324f861724fe4.js} +1 -1
  162. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/apps/store/route-3f5324f861724fe4.js +1 -0
  163. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/apps/webhooks/[...path]/route-3f5324f861724fe4.js +1 -0
  164. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/chat/active/route-3f5324f861724fe4.js +1 -0
  165. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/chat/route-3f5324f861724fe4.js +1 -0
  166. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/chat/runs/route-3f5324f861724fe4.js +1 -0
  167. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/chat/stop/route-3f5324f861724fe4.js +1 -0
  168. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/chat/stream/route-3f5324f861724fe4.js +1 -0
  169. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/chat/subagents/route-3f5324f861724fe4.js +1 -0
  170. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/composio/callback/route-3f5324f861724fe4.js +1 -0
  171. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/composio/connect/route-3f5324f861724fe4.js +1 -0
  172. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/composio/connections/route-3f5324f861724fe4.js +1 -0
  173. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/composio/disconnect/route-3f5324f861724fe4.js +1 -0
  174. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/composio/status/route-3f5324f861724fe4.js +1 -0
  175. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/composio/toolkits/route-3f5324f861724fe4.js +1 -0
  176. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/cron/jobs/[jobId]/runs/route-3f5324f861724fe4.js +1 -0
  177. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/cron/jobs/route-3f5324f861724fe4.js +1 -0
  178. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/cron/runs/[sessionId]/route-3f5324f861724fe4.js +1 -0
  179. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/cron/runs/search-transcript/route-3f5324f861724fe4.js +1 -0
  180. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/feedback/route-3f5324f861724fe4.js +1 -0
  181. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/gateway/channels/route-3f5324f861724fe4.js +1 -0
  182. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/gateway/chat/route-3f5324f861724fe4.js +1 -0
  183. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/gateway/chat/stream/route-3f5324f861724fe4.js +1 -0
  184. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/gateway/sessions/[id]/route-3f5324f861724fe4.js +1 -0
  185. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/gateway/sessions/route-3f5324f861724fe4.js +1 -0
  186. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/integrations/[id]/toggle/route-3f5324f861724fe4.js +1 -0
  187. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/integrations/repair/route-3f5324f861724fe4.js +1 -0
  188. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/integrations/route-3f5324f861724fe4.js +1 -0
  189. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/memories/route-3f5324f861724fe4.js +1 -0
  190. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/profiles/route-3f5324f861724fe4.js +1 -0
  191. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/profiles/switch/route-3f5324f861724fe4.js +1 -0
  192. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/sessions/[sessionId]/route-3f5324f861724fe4.js +1 -0
  193. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/sessions/route-3f5324f861724fe4.js +1 -0
  194. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/settings/cloud/route-3f5324f861724fe4.js +1 -0
  195. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/skills/[slug]/content/route-3f5324f861724fe4.js +1 -0
  196. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/skills/[slug]/route-3f5324f861724fe4.js +1 -0
  197. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/skills/browse/route-3f5324f861724fe4.js +1 -0
  198. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/skills/install/route-3f5324f861724fe4.js +1 -0
  199. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/skills/route-3f5324f861724fe4.js +1 -0
  200. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/terminal/port/route-3f5324f861724fe4.js +1 -0
  201. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/voice/speech/route-3f5324f861724fe4.js +1 -0
  202. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/voice/transcribe/route-3f5324f861724fe4.js +1 -0
  203. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/voice/voices/route-3f5324f861724fe4.js +1 -0
  204. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/web-sessions/[id]/messages/route-3f5324f861724fe4.js +1 -0
  205. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/web-sessions/[id]/route-3f5324f861724fe4.js +1 -0
  206. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/web-sessions/route-3f5324f861724fe4.js +1 -0
  207. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/assets/[...path]/route-3f5324f861724fe4.js +1 -0
  208. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/browse/route-3f5324f861724fe4.js +1 -0
  209. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/browse-file/route-3f5324f861724fe4.js +1 -0
  210. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/context/route-3f5324f861724fe4.js +1 -0
  211. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/copy/route-3f5324f861724fe4.js +1 -0
  212. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/db/introspect/route-3f5324f861724fe4.js +1 -0
  213. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/db/query/route-3f5324f861724fe4.js +1 -0
  214. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/delete/route-3f5324f861724fe4.js +1 -0
  215. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/execute/route-3f5324f861724fe4.js +1 -0
  216. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/file/route-3f5324f861724fe4.js +1 -0
  217. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/init/route-3f5324f861724fe4.js +1 -0
  218. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/link-preview/route-3f5324f861724fe4.js +1 -0
  219. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/list/route-3f5324f861724fe4.js +1 -0
  220. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/mkdir/route-3f5324f861724fe4.js +1 -0
  221. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/move/route-3f5324f861724fe4.js +1 -0
  222. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/actions/route-3f5324f861724fe4.js +1 -0
  223. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/actions/runs/route-3f5324f861724fe4.js +1 -0
  224. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/display-field/route-3f5324f861724fe4.js +1 -0
  225. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/entries/[id]/content/route-3f5324f861724fe4.js +1 -0
  226. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/entries/[id]/route-3f5324f861724fe4.js +1 -0
  227. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/entries/bulk-delete/route-3f5324f861724fe4.js +1 -0
  228. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/entries/options/route-3f5324f861724fe4.js +1 -0
  229. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/entries/route-3f5324f861724fe4.js +1 -0
  230. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/fields/[fieldId]/enum-rename/route-3f5324f861724fe4.js +1 -0
  231. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/fields/[fieldId]/route-3f5324f861724fe4.js +1 -0
  232. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/fields/reorder/route-3f5324f861724fe4.js +1 -0
  233. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/fields/route-3f5324f861724fe4.js +1 -0
  234. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/route-3f5324f861724fe4.js +1 -0
  235. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/views/route-3f5324f861724fe4.js +1 -0
  236. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/open-file/route-3f5324f861724fe4.js +1 -0
  237. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/path-info/route-3f5324f861724fe4.js +1 -0
  238. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/query/route-3f5324f861724fe4.js +1 -0
  239. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/raw-file/route-3f5324f861724fe4.js +1 -0
  240. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/rename/route-3f5324f861724fe4.js +1 -0
  241. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/reports/execute/route-3f5324f861724fe4.js +1 -0
  242. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/search-index/route-3f5324f861724fe4.js +1 -0
  243. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/suggest-files/route-3f5324f861724fe4.js +1 -0
  244. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/switch/route-3f5324f861724fe4.js +1 -0
  245. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/thumbnail/route-3f5324f861724fe4.js +1 -0
  246. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/tree/route-3f5324f861724fe4.js +1 -0
  247. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/upload/route-3f5324f861724fe4.js +1 -0
  248. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/virtual-file/route-3f5324f861724fe4.js +1 -0
  249. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/watch/route-3f5324f861724fe4.js +1 -0
  250. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/write-binary/route-3f5324f861724fe4.js +1 -0
  251. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/{layout-4e33b3503af94c5b.js → layout-f3680ff738cac0bb.js} +1 -1
  252. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/page-9d91562ada53b3ef.js +1 -0
  253. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/workspace/page-449a49cbf2cfee70.js +1 -0
  254. package/apps/web/.next/standalone/apps/web/.next/static/css/74b1299abb24af0e.css +1 -0
  255. package/apps/web/.next/standalone/apps/web/.next/static/oj1WoDEuGOF0TNojiymK5/_buildManifest.js +1 -0
  256. package/apps/web/.next/standalone/apps/web/app/components/__fixtures__/composio-empty-final-reply.jsonl +4 -0
  257. package/apps/web/.next/standalone/apps/web/public/dench-integrations-icon.png +0 -0
  258. package/apps/web/.next/standalone/apps/web/server.js +1 -1
  259. package/apps/web/.next/standalone/extensions/apollo-enrichment/index.ts +4 -26
  260. package/apps/web/.next/standalone/extensions/dench-ai-gateway/composio-bridge.ts +152 -426
  261. package/apps/web/.next/standalone/extensions/dench-ai-gateway/config-patch.ts +7 -4
  262. package/apps/web/.next/standalone/extensions/dench-ai-gateway/index.test.ts +280 -220
  263. package/apps/web/.next/standalone/extensions/dench-ai-gateway/index.ts +2 -2
  264. package/apps/web/.next/standalone/extensions/dench-identity/composio-cheat-sheet.test.ts +19 -111
  265. package/apps/web/.next/standalone/extensions/dench-identity/composio-cheat-sheet.ts +63 -108
  266. package/apps/web/.next/standalone/extensions/dench-identity/composio-tool-search.ts +322 -0
  267. package/apps/web/.next/standalone/extensions/dench-identity/index.test.ts +461 -55
  268. package/apps/web/.next/standalone/extensions/dench-identity/index.ts +1316 -200
  269. package/apps/web/.next/standalone/extensions/exa-search/index.ts +4 -27
  270. package/apps/web/.next/standalone/extensions/posthog-analytics/lib/build-env.js +1 -1
  271. package/apps/web/.next/standalone/extensions/shared/composio-search-context.ts +134 -0
  272. package/apps/web/.next/standalone/extensions/shared/dench-auth.ts +47 -0
  273. package/apps/web/.next/standalone/package.json +1 -1
  274. package/apps/web/.next/static/chunks/app/api/apps/cron/route-3f5324f861724fe4.js +1 -0
  275. package/apps/web/.next/static/chunks/app/api/apps/proxy/route-3f5324f861724fe4.js +1 -0
  276. package/apps/web/.next/static/chunks/app/api/apps/route-3f5324f861724fe4.js +1 -0
  277. package/apps/web/.next/static/chunks/app/api/apps/serve/[...path]/route-3f5324f861724fe4.js +1 -0
  278. package/apps/web/.next/static/chunks/app/api/apps/store/route-3f5324f861724fe4.js +1 -0
  279. package/apps/web/.next/static/chunks/app/api/apps/webhooks/[...path]/route-3f5324f861724fe4.js +1 -0
  280. package/apps/web/.next/static/chunks/app/api/chat/active/route-3f5324f861724fe4.js +1 -0
  281. package/apps/web/.next/static/chunks/app/api/chat/route-3f5324f861724fe4.js +1 -0
  282. package/apps/web/.next/static/chunks/app/api/chat/runs/route-3f5324f861724fe4.js +1 -0
  283. package/apps/web/.next/static/chunks/app/api/chat/stop/route-3f5324f861724fe4.js +1 -0
  284. package/apps/web/.next/static/chunks/app/api/chat/stream/route-3f5324f861724fe4.js +1 -0
  285. package/apps/web/.next/static/chunks/app/api/chat/subagents/route-3f5324f861724fe4.js +1 -0
  286. package/apps/web/.next/static/chunks/app/api/composio/callback/route-3f5324f861724fe4.js +1 -0
  287. package/apps/web/.next/static/chunks/app/api/composio/connect/route-3f5324f861724fe4.js +1 -0
  288. package/apps/web/.next/static/chunks/app/api/composio/connections/route-3f5324f861724fe4.js +1 -0
  289. package/apps/web/.next/static/chunks/app/api/composio/disconnect/route-3f5324f861724fe4.js +1 -0
  290. package/apps/web/.next/static/chunks/app/api/composio/status/route-3f5324f861724fe4.js +1 -0
  291. package/apps/web/.next/static/chunks/app/api/composio/toolkits/route-3f5324f861724fe4.js +1 -0
  292. package/apps/web/.next/static/chunks/app/api/cron/jobs/[jobId]/runs/route-3f5324f861724fe4.js +1 -0
  293. package/apps/web/.next/static/chunks/app/api/cron/jobs/route-3f5324f861724fe4.js +1 -0
  294. package/apps/web/.next/static/chunks/app/api/cron/runs/[sessionId]/route-3f5324f861724fe4.js +1 -0
  295. package/apps/web/.next/static/chunks/app/api/cron/runs/search-transcript/route-3f5324f861724fe4.js +1 -0
  296. package/apps/web/.next/static/chunks/app/api/feedback/route-3f5324f861724fe4.js +1 -0
  297. package/apps/web/.next/static/chunks/app/api/gateway/channels/route-3f5324f861724fe4.js +1 -0
  298. package/apps/web/.next/static/chunks/app/api/gateway/chat/route-3f5324f861724fe4.js +1 -0
  299. package/apps/web/.next/static/chunks/app/api/gateway/chat/stream/route-3f5324f861724fe4.js +1 -0
  300. package/apps/web/.next/static/chunks/app/api/gateway/sessions/[id]/route-3f5324f861724fe4.js +1 -0
  301. package/apps/web/.next/static/chunks/app/api/gateway/sessions/route-3f5324f861724fe4.js +1 -0
  302. package/apps/web/.next/static/chunks/app/api/integrations/[id]/toggle/route-3f5324f861724fe4.js +1 -0
  303. package/apps/web/.next/static/chunks/app/api/integrations/repair/route-3f5324f861724fe4.js +1 -0
  304. package/apps/web/.next/static/chunks/app/api/integrations/route-3f5324f861724fe4.js +1 -0
  305. package/apps/web/.next/static/chunks/app/api/memories/route-3f5324f861724fe4.js +1 -0
  306. package/apps/web/.next/static/chunks/app/api/profiles/route-3f5324f861724fe4.js +1 -0
  307. package/apps/web/.next/static/chunks/app/api/profiles/switch/route-3f5324f861724fe4.js +1 -0
  308. package/apps/web/.next/static/chunks/app/api/sessions/[sessionId]/route-3f5324f861724fe4.js +1 -0
  309. package/apps/web/.next/static/chunks/app/api/sessions/route-3f5324f861724fe4.js +1 -0
  310. package/apps/web/.next/static/chunks/app/api/settings/cloud/route-3f5324f861724fe4.js +1 -0
  311. package/apps/web/.next/static/chunks/app/api/skills/[slug]/content/route-3f5324f861724fe4.js +1 -0
  312. package/apps/web/.next/static/chunks/app/api/skills/[slug]/route-3f5324f861724fe4.js +1 -0
  313. package/apps/web/.next/static/chunks/app/api/skills/browse/route-3f5324f861724fe4.js +1 -0
  314. package/apps/web/.next/static/chunks/app/api/skills/install/route-3f5324f861724fe4.js +1 -0
  315. package/apps/web/.next/static/chunks/app/api/skills/route-3f5324f861724fe4.js +1 -0
  316. package/apps/web/.next/static/chunks/app/api/terminal/port/route-3f5324f861724fe4.js +1 -0
  317. package/apps/web/.next/static/chunks/app/api/voice/speech/route-3f5324f861724fe4.js +1 -0
  318. package/apps/web/.next/static/chunks/app/api/voice/transcribe/route-3f5324f861724fe4.js +1 -0
  319. package/apps/web/.next/static/chunks/app/api/voice/voices/route-3f5324f861724fe4.js +1 -0
  320. package/apps/web/.next/static/chunks/app/api/web-sessions/[id]/messages/route-3f5324f861724fe4.js +1 -0
  321. package/apps/web/.next/static/chunks/app/api/web-sessions/[id]/route-3f5324f861724fe4.js +1 -0
  322. package/apps/web/.next/static/chunks/app/api/web-sessions/route-3f5324f861724fe4.js +1 -0
  323. package/apps/web/.next/static/chunks/app/api/workspace/assets/[...path]/route-3f5324f861724fe4.js +1 -0
  324. package/apps/web/.next/static/chunks/app/api/workspace/browse/route-3f5324f861724fe4.js +1 -0
  325. package/apps/web/.next/static/chunks/app/api/workspace/browse-file/route-3f5324f861724fe4.js +1 -0
  326. package/apps/web/.next/static/chunks/app/api/workspace/context/route-3f5324f861724fe4.js +1 -0
  327. package/apps/web/.next/static/chunks/app/api/workspace/copy/route-3f5324f861724fe4.js +1 -0
  328. package/apps/web/.next/static/chunks/app/api/workspace/db/introspect/route-3f5324f861724fe4.js +1 -0
  329. package/apps/web/.next/static/chunks/app/api/workspace/db/query/route-3f5324f861724fe4.js +1 -0
  330. package/apps/web/.next/static/chunks/app/api/workspace/delete/route-3f5324f861724fe4.js +1 -0
  331. package/apps/web/.next/static/chunks/app/api/workspace/execute/route-3f5324f861724fe4.js +1 -0
  332. package/apps/web/.next/static/chunks/app/api/workspace/file/route-3f5324f861724fe4.js +1 -0
  333. package/apps/web/.next/static/chunks/app/api/workspace/init/route-3f5324f861724fe4.js +1 -0
  334. package/apps/web/.next/static/chunks/app/api/workspace/link-preview/route-3f5324f861724fe4.js +1 -0
  335. package/apps/web/.next/static/chunks/app/api/workspace/list/route-3f5324f861724fe4.js +1 -0
  336. package/apps/web/.next/static/chunks/app/api/workspace/mkdir/route-3f5324f861724fe4.js +1 -0
  337. package/apps/web/.next/static/chunks/app/api/workspace/move/route-3f5324f861724fe4.js +1 -0
  338. package/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/actions/route-3f5324f861724fe4.js +1 -0
  339. package/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/actions/runs/route-3f5324f861724fe4.js +1 -0
  340. package/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/display-field/route-3f5324f861724fe4.js +1 -0
  341. package/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/entries/[id]/content/route-3f5324f861724fe4.js +1 -0
  342. package/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/entries/[id]/route-3f5324f861724fe4.js +1 -0
  343. package/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/entries/bulk-delete/route-3f5324f861724fe4.js +1 -0
  344. package/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/entries/options/route-3f5324f861724fe4.js +1 -0
  345. package/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/entries/route-3f5324f861724fe4.js +1 -0
  346. package/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/fields/[fieldId]/enum-rename/route-3f5324f861724fe4.js +1 -0
  347. package/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/fields/[fieldId]/route-3f5324f861724fe4.js +1 -0
  348. package/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/fields/reorder/route-3f5324f861724fe4.js +1 -0
  349. package/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/fields/route-3f5324f861724fe4.js +1 -0
  350. package/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/route-3f5324f861724fe4.js +1 -0
  351. package/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/views/route-3f5324f861724fe4.js +1 -0
  352. package/apps/web/.next/static/chunks/app/api/workspace/open-file/route-3f5324f861724fe4.js +1 -0
  353. package/apps/web/.next/static/chunks/app/api/workspace/path-info/route-3f5324f861724fe4.js +1 -0
  354. package/apps/web/.next/static/chunks/app/api/workspace/query/route-3f5324f861724fe4.js +1 -0
  355. package/apps/web/.next/static/chunks/app/api/workspace/raw-file/route-3f5324f861724fe4.js +1 -0
  356. package/apps/web/.next/static/chunks/app/api/workspace/rename/route-3f5324f861724fe4.js +1 -0
  357. package/apps/web/.next/static/chunks/app/api/workspace/reports/execute/route-3f5324f861724fe4.js +1 -0
  358. package/apps/web/.next/static/chunks/app/api/workspace/search-index/route-3f5324f861724fe4.js +1 -0
  359. package/apps/web/.next/static/chunks/app/api/workspace/suggest-files/route-3f5324f861724fe4.js +1 -0
  360. package/apps/web/.next/static/chunks/app/api/workspace/switch/route-3f5324f861724fe4.js +1 -0
  361. package/apps/web/.next/static/chunks/app/api/workspace/thumbnail/route-3f5324f861724fe4.js +1 -0
  362. package/apps/web/.next/static/chunks/app/api/workspace/tree/route-3f5324f861724fe4.js +1 -0
  363. package/apps/web/.next/static/chunks/app/api/workspace/upload/route-3f5324f861724fe4.js +1 -0
  364. package/apps/web/.next/static/chunks/app/api/workspace/virtual-file/route-3f5324f861724fe4.js +1 -0
  365. package/apps/web/.next/static/chunks/app/api/workspace/watch/route-3f5324f861724fe4.js +1 -0
  366. package/apps/web/.next/static/chunks/app/api/workspace/write-binary/route-3f5324f861724fe4.js +1 -0
  367. package/apps/web/.next/static/chunks/app/{layout-4e33b3503af94c5b.js → layout-f3680ff738cac0bb.js} +1 -1
  368. package/apps/web/.next/static/chunks/app/page-9d91562ada53b3ef.js +1 -0
  369. package/apps/web/.next/static/chunks/app/workspace/page-449a49cbf2cfee70.js +1 -0
  370. package/apps/web/.next/static/css/74b1299abb24af0e.css +1 -0
  371. package/apps/web/.next/static/oj1WoDEuGOF0TNojiymK5/_buildManifest.js +1 -0
  372. package/apps/web/public/dench-integrations-icon.png +0 -0
  373. package/dist/{cli-name-CoW7mNz-.js → cli-name-Sz-5E3q2.js} +1 -1
  374. package/dist/entry.js +9 -2
  375. package/dist/{program-C4ijUMvC.js → program-CtW4fcfa.js} +265 -70
  376. package/dist/{run-main-tu5KGaV-.js → run-main-CPnN1zoG.js} +3 -3
  377. package/dist/{telemetry-DguRjCZq.js → telemetry-C_b18hhq.js} +1 -1
  378. package/extensions/apollo-enrichment/index.ts +4 -26
  379. package/extensions/dench-ai-gateway/composio-bridge.ts +152 -426
  380. package/extensions/dench-ai-gateway/config-patch.ts +7 -4
  381. package/extensions/dench-ai-gateway/index.test.ts +280 -220
  382. package/extensions/dench-ai-gateway/index.ts +2 -2
  383. package/extensions/dench-identity/composio-cheat-sheet.test.ts +19 -111
  384. package/extensions/dench-identity/composio-cheat-sheet.ts +63 -108
  385. package/extensions/dench-identity/composio-tool-search.ts +322 -0
  386. package/extensions/dench-identity/index.test.ts +461 -55
  387. package/extensions/dench-identity/index.ts +1316 -200
  388. package/extensions/exa-search/index.ts +4 -27
  389. package/extensions/posthog-analytics/lib/build-env.js +1 -1
  390. package/extensions/shared/composio-search-context.ts +134 -0
  391. package/extensions/shared/dench-auth.ts +47 -0
  392. package/package.json +1 -1
  393. package/skills/composio-apps/SKILL.md +27 -9
  394. package/skills/dench-integrations/SKILL.md +189 -0
  395. package/apps/web/.next/standalone/apps/web/.next/server/app/api/composio/tool-index/route.js +0 -1
  396. package/apps/web/.next/standalone/apps/web/.next/server/app/api/composio/tool-index/route.js.nft.json +0 -1
  397. package/apps/web/.next/standalone/apps/web/.next/server/app/api/composio/tool-index/route_client-reference-manifest.js +0 -1
  398. package/apps/web/.next/standalone/apps/web/.next/server/chunks/8650.js +0 -1
  399. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/apps/store/route-982235d988e17f31.js +0 -1
  400. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/apps/webhooks/[...path]/route-982235d988e17f31.js +0 -1
  401. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/chat/active/route-982235d988e17f31.js +0 -1
  402. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/chat/route-982235d988e17f31.js +0 -1
  403. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/chat/runs/route-982235d988e17f31.js +0 -1
  404. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/chat/stop/route-982235d988e17f31.js +0 -1
  405. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/chat/stream/route-982235d988e17f31.js +0 -1
  406. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/chat/subagents/route-982235d988e17f31.js +0 -1
  407. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/composio/callback/route-982235d988e17f31.js +0 -1
  408. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/composio/connect/route-982235d988e17f31.js +0 -1
  409. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/composio/connections/route-982235d988e17f31.js +0 -1
  410. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/composio/disconnect/route-982235d988e17f31.js +0 -1
  411. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/composio/status/route-982235d988e17f31.js +0 -1
  412. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/composio/tool-index/route-982235d988e17f31.js +0 -1
  413. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/composio/toolkits/route-982235d988e17f31.js +0 -1
  414. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/cron/jobs/[jobId]/runs/route-982235d988e17f31.js +0 -1
  415. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/cron/jobs/route-982235d988e17f31.js +0 -1
  416. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/cron/runs/[sessionId]/route-982235d988e17f31.js +0 -1
  417. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/cron/runs/search-transcript/route-982235d988e17f31.js +0 -1
  418. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/feedback/route-982235d988e17f31.js +0 -1
  419. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/gateway/channels/route-982235d988e17f31.js +0 -1
  420. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/gateway/chat/route-982235d988e17f31.js +0 -1
  421. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/gateway/chat/stream/route-982235d988e17f31.js +0 -1
  422. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/gateway/sessions/[id]/route-982235d988e17f31.js +0 -1
  423. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/gateway/sessions/route-982235d988e17f31.js +0 -1
  424. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/integrations/[id]/toggle/route-982235d988e17f31.js +0 -1
  425. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/integrations/repair/route-982235d988e17f31.js +0 -1
  426. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/integrations/route-982235d988e17f31.js +0 -1
  427. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/memories/route-982235d988e17f31.js +0 -1
  428. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/profiles/route-982235d988e17f31.js +0 -1
  429. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/profiles/switch/route-982235d988e17f31.js +0 -1
  430. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/sessions/[sessionId]/route-982235d988e17f31.js +0 -1
  431. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/sessions/route-982235d988e17f31.js +0 -1
  432. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/settings/cloud/route-982235d988e17f31.js +0 -1
  433. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/skills/[slug]/content/route-982235d988e17f31.js +0 -1
  434. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/skills/[slug]/route-982235d988e17f31.js +0 -1
  435. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/skills/browse/route-982235d988e17f31.js +0 -1
  436. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/skills/install/route-982235d988e17f31.js +0 -1
  437. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/skills/route-982235d988e17f31.js +0 -1
  438. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/terminal/port/route-982235d988e17f31.js +0 -1
  439. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/voice/speech/route-982235d988e17f31.js +0 -1
  440. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/voice/transcribe/route-982235d988e17f31.js +0 -1
  441. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/voice/voices/route-982235d988e17f31.js +0 -1
  442. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/web-sessions/[id]/messages/route-982235d988e17f31.js +0 -1
  443. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/web-sessions/[id]/route-982235d988e17f31.js +0 -1
  444. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/web-sessions/route-982235d988e17f31.js +0 -1
  445. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/assets/[...path]/route-982235d988e17f31.js +0 -1
  446. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/browse/route-982235d988e17f31.js +0 -1
  447. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/browse-file/route-982235d988e17f31.js +0 -1
  448. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/context/route-982235d988e17f31.js +0 -1
  449. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/copy/route-982235d988e17f31.js +0 -1
  450. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/db/introspect/route-982235d988e17f31.js +0 -1
  451. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/db/query/route-982235d988e17f31.js +0 -1
  452. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/delete/route-982235d988e17f31.js +0 -1
  453. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/execute/route-982235d988e17f31.js +0 -1
  454. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/file/route-982235d988e17f31.js +0 -1
  455. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/init/route-982235d988e17f31.js +0 -1
  456. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/link-preview/route-982235d988e17f31.js +0 -1
  457. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/list/route-982235d988e17f31.js +0 -1
  458. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/mkdir/route-982235d988e17f31.js +0 -1
  459. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/move/route-982235d988e17f31.js +0 -1
  460. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/actions/route-982235d988e17f31.js +0 -1
  461. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/actions/runs/route-982235d988e17f31.js +0 -1
  462. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/display-field/route-982235d988e17f31.js +0 -1
  463. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/entries/[id]/content/route-982235d988e17f31.js +0 -1
  464. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/entries/[id]/route-982235d988e17f31.js +0 -1
  465. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/entries/bulk-delete/route-982235d988e17f31.js +0 -1
  466. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/entries/options/route-982235d988e17f31.js +0 -1
  467. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/entries/route-982235d988e17f31.js +0 -1
  468. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/fields/[fieldId]/enum-rename/route-982235d988e17f31.js +0 -1
  469. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/fields/[fieldId]/route-982235d988e17f31.js +0 -1
  470. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/fields/reorder/route-982235d988e17f31.js +0 -1
  471. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/fields/route-982235d988e17f31.js +0 -1
  472. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/route-982235d988e17f31.js +0 -1
  473. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/views/route-982235d988e17f31.js +0 -1
  474. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/open-file/route-982235d988e17f31.js +0 -1
  475. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/path-info/route-982235d988e17f31.js +0 -1
  476. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/query/route-982235d988e17f31.js +0 -1
  477. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/raw-file/route-982235d988e17f31.js +0 -1
  478. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/rename/route-982235d988e17f31.js +0 -1
  479. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/reports/execute/route-982235d988e17f31.js +0 -1
  480. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/search-index/route-982235d988e17f31.js +0 -1
  481. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/suggest-files/route-982235d988e17f31.js +0 -1
  482. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/switch/route-982235d988e17f31.js +0 -1
  483. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/thumbnail/route-982235d988e17f31.js +0 -1
  484. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/tree/route-982235d988e17f31.js +0 -1
  485. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/upload/route-982235d988e17f31.js +0 -1
  486. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/virtual-file/route-982235d988e17f31.js +0 -1
  487. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/watch/route-982235d988e17f31.js +0 -1
  488. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/api/workspace/write-binary/route-982235d988e17f31.js +0 -1
  489. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/page-93ec42bca0d82a2b.js +0 -1
  490. package/apps/web/.next/standalone/apps/web/.next/static/chunks/app/workspace/page-7f60d4efe8904f55.js +0 -1
  491. package/apps/web/.next/standalone/apps/web/.next/static/css/4f71a2dee93c9f97.css +0 -1
  492. package/apps/web/.next/standalone/apps/web/.next/static/hGwOuep2JUMOZ4iiPjKLY/_buildManifest.js +0 -1
  493. package/apps/web/.next/static/chunks/app/api/apps/cron/route-982235d988e17f31.js +0 -1
  494. package/apps/web/.next/static/chunks/app/api/apps/proxy/route-982235d988e17f31.js +0 -1
  495. package/apps/web/.next/static/chunks/app/api/apps/route-982235d988e17f31.js +0 -1
  496. package/apps/web/.next/static/chunks/app/api/apps/serve/[...path]/route-982235d988e17f31.js +0 -1
  497. package/apps/web/.next/static/chunks/app/api/apps/store/route-982235d988e17f31.js +0 -1
  498. package/apps/web/.next/static/chunks/app/api/apps/webhooks/[...path]/route-982235d988e17f31.js +0 -1
  499. package/apps/web/.next/static/chunks/app/api/chat/active/route-982235d988e17f31.js +0 -1
  500. package/apps/web/.next/static/chunks/app/api/chat/route-982235d988e17f31.js +0 -1
  501. package/apps/web/.next/static/chunks/app/api/chat/runs/route-982235d988e17f31.js +0 -1
  502. package/apps/web/.next/static/chunks/app/api/chat/stop/route-982235d988e17f31.js +0 -1
  503. package/apps/web/.next/static/chunks/app/api/chat/stream/route-982235d988e17f31.js +0 -1
  504. package/apps/web/.next/static/chunks/app/api/chat/subagents/route-982235d988e17f31.js +0 -1
  505. package/apps/web/.next/static/chunks/app/api/composio/callback/route-982235d988e17f31.js +0 -1
  506. package/apps/web/.next/static/chunks/app/api/composio/connect/route-982235d988e17f31.js +0 -1
  507. package/apps/web/.next/static/chunks/app/api/composio/connections/route-982235d988e17f31.js +0 -1
  508. package/apps/web/.next/static/chunks/app/api/composio/disconnect/route-982235d988e17f31.js +0 -1
  509. package/apps/web/.next/static/chunks/app/api/composio/status/route-982235d988e17f31.js +0 -1
  510. package/apps/web/.next/static/chunks/app/api/composio/tool-index/route-982235d988e17f31.js +0 -1
  511. package/apps/web/.next/static/chunks/app/api/composio/toolkits/route-982235d988e17f31.js +0 -1
  512. package/apps/web/.next/static/chunks/app/api/cron/jobs/[jobId]/runs/route-982235d988e17f31.js +0 -1
  513. package/apps/web/.next/static/chunks/app/api/cron/jobs/route-982235d988e17f31.js +0 -1
  514. package/apps/web/.next/static/chunks/app/api/cron/runs/[sessionId]/route-982235d988e17f31.js +0 -1
  515. package/apps/web/.next/static/chunks/app/api/cron/runs/search-transcript/route-982235d988e17f31.js +0 -1
  516. package/apps/web/.next/static/chunks/app/api/feedback/route-982235d988e17f31.js +0 -1
  517. package/apps/web/.next/static/chunks/app/api/gateway/channels/route-982235d988e17f31.js +0 -1
  518. package/apps/web/.next/static/chunks/app/api/gateway/chat/route-982235d988e17f31.js +0 -1
  519. package/apps/web/.next/static/chunks/app/api/gateway/chat/stream/route-982235d988e17f31.js +0 -1
  520. package/apps/web/.next/static/chunks/app/api/gateway/sessions/[id]/route-982235d988e17f31.js +0 -1
  521. package/apps/web/.next/static/chunks/app/api/gateway/sessions/route-982235d988e17f31.js +0 -1
  522. package/apps/web/.next/static/chunks/app/api/integrations/[id]/toggle/route-982235d988e17f31.js +0 -1
  523. package/apps/web/.next/static/chunks/app/api/integrations/repair/route-982235d988e17f31.js +0 -1
  524. package/apps/web/.next/static/chunks/app/api/integrations/route-982235d988e17f31.js +0 -1
  525. package/apps/web/.next/static/chunks/app/api/memories/route-982235d988e17f31.js +0 -1
  526. package/apps/web/.next/static/chunks/app/api/profiles/route-982235d988e17f31.js +0 -1
  527. package/apps/web/.next/static/chunks/app/api/profiles/switch/route-982235d988e17f31.js +0 -1
  528. package/apps/web/.next/static/chunks/app/api/sessions/[sessionId]/route-982235d988e17f31.js +0 -1
  529. package/apps/web/.next/static/chunks/app/api/sessions/route-982235d988e17f31.js +0 -1
  530. package/apps/web/.next/static/chunks/app/api/settings/cloud/route-982235d988e17f31.js +0 -1
  531. package/apps/web/.next/static/chunks/app/api/skills/[slug]/content/route-982235d988e17f31.js +0 -1
  532. package/apps/web/.next/static/chunks/app/api/skills/[slug]/route-982235d988e17f31.js +0 -1
  533. package/apps/web/.next/static/chunks/app/api/skills/browse/route-982235d988e17f31.js +0 -1
  534. package/apps/web/.next/static/chunks/app/api/skills/install/route-982235d988e17f31.js +0 -1
  535. package/apps/web/.next/static/chunks/app/api/skills/route-982235d988e17f31.js +0 -1
  536. package/apps/web/.next/static/chunks/app/api/terminal/port/route-982235d988e17f31.js +0 -1
  537. package/apps/web/.next/static/chunks/app/api/voice/speech/route-982235d988e17f31.js +0 -1
  538. package/apps/web/.next/static/chunks/app/api/voice/transcribe/route-982235d988e17f31.js +0 -1
  539. package/apps/web/.next/static/chunks/app/api/voice/voices/route-982235d988e17f31.js +0 -1
  540. package/apps/web/.next/static/chunks/app/api/web-sessions/[id]/messages/route-982235d988e17f31.js +0 -1
  541. package/apps/web/.next/static/chunks/app/api/web-sessions/[id]/route-982235d988e17f31.js +0 -1
  542. package/apps/web/.next/static/chunks/app/api/web-sessions/route-982235d988e17f31.js +0 -1
  543. package/apps/web/.next/static/chunks/app/api/workspace/assets/[...path]/route-982235d988e17f31.js +0 -1
  544. package/apps/web/.next/static/chunks/app/api/workspace/browse/route-982235d988e17f31.js +0 -1
  545. package/apps/web/.next/static/chunks/app/api/workspace/browse-file/route-982235d988e17f31.js +0 -1
  546. package/apps/web/.next/static/chunks/app/api/workspace/context/route-982235d988e17f31.js +0 -1
  547. package/apps/web/.next/static/chunks/app/api/workspace/copy/route-982235d988e17f31.js +0 -1
  548. package/apps/web/.next/static/chunks/app/api/workspace/db/introspect/route-982235d988e17f31.js +0 -1
  549. package/apps/web/.next/static/chunks/app/api/workspace/db/query/route-982235d988e17f31.js +0 -1
  550. package/apps/web/.next/static/chunks/app/api/workspace/delete/route-982235d988e17f31.js +0 -1
  551. package/apps/web/.next/static/chunks/app/api/workspace/execute/route-982235d988e17f31.js +0 -1
  552. package/apps/web/.next/static/chunks/app/api/workspace/file/route-982235d988e17f31.js +0 -1
  553. package/apps/web/.next/static/chunks/app/api/workspace/init/route-982235d988e17f31.js +0 -1
  554. package/apps/web/.next/static/chunks/app/api/workspace/link-preview/route-982235d988e17f31.js +0 -1
  555. package/apps/web/.next/static/chunks/app/api/workspace/list/route-982235d988e17f31.js +0 -1
  556. package/apps/web/.next/static/chunks/app/api/workspace/mkdir/route-982235d988e17f31.js +0 -1
  557. package/apps/web/.next/static/chunks/app/api/workspace/move/route-982235d988e17f31.js +0 -1
  558. package/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/actions/route-982235d988e17f31.js +0 -1
  559. package/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/actions/runs/route-982235d988e17f31.js +0 -1
  560. package/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/display-field/route-982235d988e17f31.js +0 -1
  561. package/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/entries/[id]/content/route-982235d988e17f31.js +0 -1
  562. package/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/entries/[id]/route-982235d988e17f31.js +0 -1
  563. package/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/entries/bulk-delete/route-982235d988e17f31.js +0 -1
  564. package/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/entries/options/route-982235d988e17f31.js +0 -1
  565. package/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/entries/route-982235d988e17f31.js +0 -1
  566. package/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/fields/[fieldId]/enum-rename/route-982235d988e17f31.js +0 -1
  567. package/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/fields/[fieldId]/route-982235d988e17f31.js +0 -1
  568. package/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/fields/reorder/route-982235d988e17f31.js +0 -1
  569. package/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/fields/route-982235d988e17f31.js +0 -1
  570. package/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/route-982235d988e17f31.js +0 -1
  571. package/apps/web/.next/static/chunks/app/api/workspace/objects/[name]/views/route-982235d988e17f31.js +0 -1
  572. package/apps/web/.next/static/chunks/app/api/workspace/open-file/route-982235d988e17f31.js +0 -1
  573. package/apps/web/.next/static/chunks/app/api/workspace/path-info/route-982235d988e17f31.js +0 -1
  574. package/apps/web/.next/static/chunks/app/api/workspace/query/route-982235d988e17f31.js +0 -1
  575. package/apps/web/.next/static/chunks/app/api/workspace/raw-file/route-982235d988e17f31.js +0 -1
  576. package/apps/web/.next/static/chunks/app/api/workspace/rename/route-982235d988e17f31.js +0 -1
  577. package/apps/web/.next/static/chunks/app/api/workspace/reports/execute/route-982235d988e17f31.js +0 -1
  578. package/apps/web/.next/static/chunks/app/api/workspace/search-index/route-982235d988e17f31.js +0 -1
  579. package/apps/web/.next/static/chunks/app/api/workspace/suggest-files/route-982235d988e17f31.js +0 -1
  580. package/apps/web/.next/static/chunks/app/api/workspace/switch/route-982235d988e17f31.js +0 -1
  581. package/apps/web/.next/static/chunks/app/api/workspace/thumbnail/route-982235d988e17f31.js +0 -1
  582. package/apps/web/.next/static/chunks/app/api/workspace/tree/route-982235d988e17f31.js +0 -1
  583. package/apps/web/.next/static/chunks/app/api/workspace/upload/route-982235d988e17f31.js +0 -1
  584. package/apps/web/.next/static/chunks/app/api/workspace/virtual-file/route-982235d988e17f31.js +0 -1
  585. package/apps/web/.next/static/chunks/app/api/workspace/watch/route-982235d988e17f31.js +0 -1
  586. package/apps/web/.next/static/chunks/app/api/workspace/write-binary/route-982235d988e17f31.js +0 -1
  587. package/apps/web/.next/static/chunks/app/page-93ec42bca0d82a2b.js +0 -1
  588. package/apps/web/.next/static/chunks/app/workspace/page-7f60d4efe8904f55.js +0 -1
  589. package/apps/web/.next/static/css/4f71a2dee93c9f97.css +0 -1
  590. package/apps/web/.next/static/hGwOuep2JUMOZ4iiPjKLY/_buildManifest.js +0 -1
  591. /package/apps/web/.next/standalone/apps/web/.next/static/{hGwOuep2JUMOZ4iiPjKLY → oj1WoDEuGOF0TNojiymK5}/_ssgManifest.js +0 -0
  592. /package/apps/web/.next/static/{hGwOuep2JUMOZ4iiPjKLY → oj1WoDEuGOF0TNojiymK5}/_ssgManifest.js +0 -0
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8974],{395:(e,t,r)=>{"use strict";r.d(t,{V:()=>a});var n=r(80534),o=r(74166),l=r(65163);function a(e){let{name:t="braille",children:r,className:a,style:s}=e,[i,c]=(0,o.useState)(0),d=(0,o.useMemo)(()=>{var e;return null!=(e=l.Mb[t])?e:l.Mb.braille},[t]),u=d.frames.length,p=u>0?d.frames[i%u]:"";return(0,o.useEffect)(()=>{if(c(0),u<=1||d.interval<=0)return;let e=window.setInterval(()=>c(e=>(e+1)%u),d.interval);return()=>window.clearInterval(e)},[d,u]),(0,n.jsxs)("span",{className:a,style:{fontFamily:"monospace",...s},children:[p,null!=r&&(0,n.jsxs)(n.Fragment,{children:[" ",r]})]})}},4582:()=>{},40077:(e,t,r)=>{"use strict";r.d(t,{N:()=>U});var n=r(80534),o=r(74166),l=r(44960),a=r(2741),s=r(12890),i=r(19237),c=r(45770),d=r(68354),u=r(48357),p=r(3224),h=r(13707),x=r(23173),m=r(58313),f=r(97726),v=r(90171),g=r(66735),y=r(51329),b=r(12674),j=r(25249),k=r(11913),w=r(67283),N=r(60577),C=r(1208),S=r(84240),M=r(53940),L=r(13847),T=r(49166);let I=["#2563eb","#60a5fa","#22c55e","#f59e0b","#c084fc","#fb923c","#14b8a6","#f43f5e","#a78bfa","#38bdf8"],R={fontSize:11,fill:"var(--color-text-muted)"},_={stroke:"var(--color-border-strong)",strokeDasharray:"3 3"};function E(){return{contentStyle:{background:"var(--color-surface)",border:"1px solid var(--color-border)",borderRadius:8,fontSize:12,color:"var(--color-text)"},itemStyle:{color:"var(--color-text)"},labelStyle:{color:"var(--color-text-muted)",marginBottom:4}}}function D(e){return null==e?"":"object"==typeof e?JSON.stringify(e):"string"==typeof e?e:String(e)}function A(e){return null==e?"":"object"==typeof e?JSON.stringify(e):"number"==typeof e?Math.abs(e)>=1e6?"".concat((e/1e6).toFixed(1),"M"):Math.abs(e)>=1e3?"".concat((e/1e3).toFixed(1),"K"):Number.isInteger(e)?String(e):e.toFixed(2):D(e)}function W(e){if(null==e)return"";let t=D(e);return t.length>16&&!isNaN(Date.parse(t))?t.slice(0,10):t.length>20?t.slice(0,18)+"...":t}function B(e){var t,r,o,x,m,f;let{config:v,data:g,compact:y,ChartComponent:b,SeriesComponent:j,areaProps:k}=e,{mapping:w}=v,N=null!=(o=null!=(r=w.xAxis)?r:Object.keys(null!=(t=g[0])?t:{})[0])?o:"x",C=null!=(m=w.yAxis)?m:Object.keys(null!=(x=g[0])?x:{}).filter(e=>e!==N),S=null!=(f=w.colors)?f:I,M=E();return(0,n.jsx)(l.u,{width:"100%",height:y?200:320,children:(0,n.jsxs)(b,{data:g,margin:{top:8,right:16,left:0,bottom:4},children:[(0,n.jsx)(a.d,{..._}),(0,n.jsx)(s.W,{dataKey:N,tick:R,tickFormatter:W,axisLine:{stroke:"var(--color-border)"},tickLine:!1}),(0,n.jsx)(i.h,{tick:R,tickFormatter:A,axisLine:!1,tickLine:!1,width:48}),(0,n.jsx)(c.m,{...M,formatter:A,labelFormatter:W}),C.length>1&&!y&&(0,n.jsx)(d.s,{wrapperStyle:{fontSize:11}}),C.map((e,t)=>{let r=S[t%S.length],o={key:e,dataKey:e,fill:r,stroke:r,name:e,...k};return j===u.yP&&(o.radius=[4,4,0,0],o.maxBarSize=48),j===p.N1&&(o.strokeWidth=2,o.dot={r:3,fill:r},o.activeDot={r:5}),j===h.Gk&&(o.fillOpacity=.15,o.strokeWidth=2),(0,n.jsx)(j,{...o})})]})})}function F(e){var t,r,o,a,s,i,u;let{config:p,data:h,compact:v}=e,{mapping:g,type:y}=p,b=null!=(o=null!=(r=g.nameKey)?r:Object.keys(null!=(t=h[0])?t:{})[0])?o:"name",j=null!=(i=null!=(s=g.valueKey)?s:Object.keys(null!=(a=h[0])?a:{})[1])?i:"value",k=null!=(u=g.colors)?u:I,w=E();return(0,n.jsx)(l.u,{width:"100%",height:v?200:320,children:(0,n.jsxs)(x.r,{children:[(0,n.jsx)(m.Fq,{data:h,dataKey:j,nameKey:b,cx:"50%",cy:"50%",innerRadius:"donut"===y?"50%":0,outerRadius:v?70:110,paddingAngle:2,label:v?void 0:e=>{let t=e.name,r="number"==typeof e.percent?e.percent:0;return"".concat(W(t)," ").concat((100*r).toFixed(0),"%")},labelLine:!v,style:{fontSize:11},children:h.map((e,t)=>(0,n.jsx)(f.f,{fill:k[t%k.length]},t))}),(0,n.jsx)(c.m,{...w,formatter:A}),!v&&(0,n.jsx)(d.s,{wrapperStyle:{fontSize:11}})]})})}function P(e){var t,r,o,a,s,i,u,p;let{config:h,data:x,compact:m}=e,{mapping:f}=h,k=null!=(a=null!=(o=null!=(t=f.xAxis)?t:f.nameKey)?o:Object.keys(null!=(r=x[0])?r:{})[0])?a:"name",w=null!=(u=f.yAxis)?u:[null!=(i=Object.keys(null!=(s=x[0])?s:{})[1])?i:"value"],N=null!=(p=f.colors)?p:I,C=E();return(0,n.jsx)(l.u,{width:"100%",height:m?200:320,children:(0,n.jsxs)(v.V,{data:x,cx:"50%",cy:"50%",outerRadius:m?60:100,children:[(0,n.jsx)(g.z,{stroke:"var(--color-border)"}),(0,n.jsx)(y.r,{dataKey:k,tick:{fontSize:11,fill:"var(--color-text-muted)"}}),(0,n.jsx)(b.E,{tick:{fontSize:10,fill:"var(--color-text-muted)"}}),w.map((e,t)=>(0,n.jsx)(j.Vd,{name:e,dataKey:e,stroke:N[t%N.length],fill:N[t%N.length],fillOpacity:.2},e)),(0,n.jsx)(c.m,{...C}),!m&&w.length>1&&(0,n.jsx)(d.s,{wrapperStyle:{fontSize:11}})]})})}function z(e){var t,r,o,u,p,h,x;let{config:m,data:f,compact:v}=e,{mapping:g}=m,y=null!=(o=null!=(r=g.xAxis)?r:Object.keys(null!=(t=f[0])?t:{})[0])?o:"x",b=null!=(h=g.yAxis)?h:[null!=(p=Object.keys(null!=(u=f[0])?u:{})[1])?p:"y"],j=null!=(x=g.colors)?x:I,N=E();return(0,n.jsx)(l.u,{width:"100%",height:v?200:320,children:(0,n.jsxs)(k.t,{margin:{top:8,right:16,left:0,bottom:4},children:[(0,n.jsx)(a.d,{..._}),(0,n.jsx)(s.W,{dataKey:y,tick:R,name:y,axisLine:{stroke:"var(--color-border)"},tickLine:!1}),(0,n.jsx)(i.h,{tick:R,tickFormatter:A,axisLine:!1,tickLine:!1,width:48}),(0,n.jsx)(c.m,{...N}),b.map((e,t)=>(0,n.jsx)(w.Xl,{name:e,data:f,fill:j[t%j.length]},e)),!v&&b.length>1&&(0,n.jsx)(d.s,{wrapperStyle:{fontSize:11}})]})})}function O(e){var t,r,o,a,s,i,d;let{config:u,data:p,compact:h}=e,{mapping:x}=u,m=null!=(o=null!=(r=x.nameKey)?r:Object.keys(null!=(t=p[0])?t:{})[0])?o:"name",f=null!=(i=null!=(s=x.valueKey)?s:Object.keys(null!=(a=p[0])?a:{})[1])?i:"value",v=null!=(d=x.colors)?d:I,g=E(),y=p.map((e,t)=>({...e,fill:v[t%v.length]}));return(0,n.jsx)(l.u,{width:"100%",height:h?200:320,children:(0,n.jsxs)(N.v,{children:[(0,n.jsx)(c.m,{...g}),(0,n.jsx)(C.rh,{data:y,dataKey:f,nameKey:m,isAnimationActive:!0,children:(0,n.jsx)(S.Ze,{position:"right",fill:"var(--color-text-muted)",stroke:"none",fontSize:11,dataKey:m})})]})})}function U(e){let{config:t,data:r,compact:l}=e,a=(0,o.useMemo)(()=>{var e;if(!r||0===r.length)return[];let{mapping:n}=t,o=new Set([...null!=(e=n.yAxis)?e:[],...n.valueKey?[n.valueKey]:[]]);return r.map(e=>{let t={...e};for(let e of o)if(e in t){let r=t[e];"string"!=typeof r||""===r||isNaN(Number(r))||(t[e]=Number(r))}return t})},[r,t]);if(0===a.length)return(0,n.jsx)("div",{className:"flex items-center justify-center rounded-xl",style:{height:l?200:320,background:"var(--color-surface)",border:"1px solid var(--color-border)",color:"var(--color-text-muted)",fontSize:13},children:"No data"});switch(t.type){case"bar":default:return(0,n.jsx)(B,{config:t,data:a,compact:l,ChartComponent:M.E,SeriesComponent:u.yP});case"line":return(0,n.jsx)(B,{config:t,data:a,compact:l,ChartComponent:L.b,SeriesComponent:p.N1});case"area":return(0,n.jsx)(B,{config:t,data:a,compact:l,ChartComponent:T.Q,SeriesComponent:h.Gk});case"pie":case"donut":return(0,n.jsx)(F,{config:t,data:a,compact:l});case"radar":case"radialBar":return(0,n.jsx)(P,{config:t,data:a,compact:l});case"scatter":return(0,n.jsx)(z,{config:t,data:a,compact:l});case"funnel":return(0,n.jsx)(O,{config:t,data:a,compact:l})}}},52597:(e,t,r)=>{"use strict";r.r(t),r.d(t,{BubbleButton:()=>K.zM,MarkdownEditor:()=>G,ToolbarButton:()=>K.IB,ToolbarDivider:()=>K.x_,ToolbarGroup:()=>K.$Q});var n=r(80534),o=r(69176),l=r(87131),a=r(22856),s=r(64652),i=r(3087),c=r(86233),d=r(79919),u=r(34872),p=r(8466),h=r(83879),x=r(14273),m=r(54602),f=r(95107),v=r(74166),g=r(79534);let y=(0,r(24946).default)(()=>r.e(5477).then(r.bind(r,45477)).then(e=>({default:e.ReportCard})),{loadableGenerated:{webpack:()=>[45477]},ssr:!1,loading:()=>(0,n.jsx)("div",{className:"h-48 rounded-xl animate-pulse",style:{background:"var(--color-surface)"}})});function b(e){let{node:t,updateAttributes:r,deleteNode:l,selected:a}=e,s=t.attrs.config,[i,c]=(0,v.useState)(!1),[d,u]=(0,v.useState)(s),p=null,h=null;try{let e=JSON.parse(s);(null==e?void 0:e.panels)&&Array.isArray(e.panels)?p=e:h="Invalid report config: missing panels array"}catch(e){h="Invalid JSON in report block"}let x=(0,v.useCallback)(()=>{try{JSON.parse(d),r({config:d}),c(!1)}catch(e){}},[d,r]);return(0,n.jsxs)(o.VR,{className:"report-block-wrapper","data-selected":a||void 0,children:[(0,n.jsxs)("div",{className:"report-block-toolbar",children:[(0,n.jsxs)("button",{type:"button",onClick:()=>{i?x():(u(s),c(!0))},className:"report-block-btn",title:i?"Apply & show chart":"Edit JSON source",children:[i?(0,n.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("polyline",{points:"20 6 9 17 4 12"})}):(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("polyline",{points:"16 18 22 12 16 6"}),(0,n.jsx)("polyline",{points:"8 6 2 12 8 18"})]}),(0,n.jsx)("span",{children:i?"Apply":"Edit JSON"})]}),(0,n.jsx)("button",{type:"button",onClick:l,className:"report-block-btn report-block-btn-danger",title:"Remove report block",children:(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M3 6h18"}),(0,n.jsx)("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),(0,n.jsx)("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]})})]}),i?(0,n.jsxs)("div",{className:"report-block-source",children:[(0,n.jsx)("div",{className:"report-block-source-label",children:"report-json"}),(0,n.jsx)("textarea",{className:"report-block-textarea",value:d,onChange:e=>u(e.target.value),spellCheck:!1,rows:Math.min(20,d.split("\n").length+2)})]}):h?(0,n.jsxs)("div",{className:"report-block-error",children:[(0,n.jsx)("span",{children:h}),(0,n.jsx)("button",{type:"button",onClick:()=>{u(s),c(!0)},className:"report-block-btn",children:"Fix JSON"})]}):(0,n.jsx)(y,{config:p})]})}let j=g.bP.create({name:"reportBlock",group:"block",atom:!0,addAttributes:()=>({config:{default:"{}",parseHTML:e=>e.getAttribute("data-config")||"{}",renderHTML:e=>({"data-config":e.config})}}),parseHTML:()=>[{tag:'div[data-type="report-block"]'}],renderHTML(e){let{HTMLAttributes:t}=e;return["div",(0,g.KV)(t,{"data-type":"report-block"})]},addNodeView:()=>(0,o.gu)(b)});function k(e){return e.replace(/```report-json\s*\n([\s\S]*?)```/g,(e,t)=>{let r=t.trim().replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;");return'<div data-type="report-block" data-config="'.concat(r,'"></div>')})}var w=r(48997),N=r(63550),C=r(17763),S=r(68840);let M=new N.hs("slashCommand"),L=new N.hs("fileMention"),T=e=>(0,n.jsxs)("span",{className:"slash-cmd-icon-text",children:["H",e]}),I=(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("line",{x1:"8",x2:"21",y1:"6",y2:"6"}),(0,n.jsx)("line",{x1:"8",x2:"21",y1:"12",y2:"12"}),(0,n.jsx)("line",{x1:"8",x2:"21",y1:"18",y2:"18"}),(0,n.jsx)("line",{x1:"3",x2:"3.01",y1:"6",y2:"6"}),(0,n.jsx)("line",{x1:"3",x2:"3.01",y1:"12",y2:"12"}),(0,n.jsx)("line",{x1:"3",x2:"3.01",y1:"18",y2:"18"})]}),R=(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("line",{x1:"10",x2:"21",y1:"6",y2:"6"}),(0,n.jsx)("line",{x1:"10",x2:"21",y1:"12",y2:"12"}),(0,n.jsx)("line",{x1:"10",x2:"21",y1:"18",y2:"18"}),(0,n.jsx)("path",{d:"M4 6h1v4"}),(0,n.jsx)("path",{d:"M4 10h2"}),(0,n.jsx)("path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1"})]}),_=(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M3 21c3 0 7-1 7-8V5c0-1.25-.756-2.017-2-2H4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2 1 0 1 0 1 1v1c0 1-1 2-2 2s-1 .008-1 1.031V21z"}),(0,n.jsx)("path",{d:"M15 21c3 0 7-1 7-8V5c0-1.25-.757-2.017-2-2h-4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2h.75c0 2.25.25 4-2.75 4v3z"})]}),E=(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("polyline",{points:"16 18 22 12 16 6"}),(0,n.jsx)("polyline",{points:"8 6 2 12 8 18"})]}),D=(0,n.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("line",{x1:"2",x2:"22",y1:"12",y2:"12"})}),A=(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),(0,n.jsx)("circle",{cx:"9",cy:"9",r:"2"}),(0,n.jsx)("path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"})]}),W=(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M12 3v18"}),(0,n.jsx)("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),(0,n.jsx)("path",{d:"M3 9h18"}),(0,n.jsx)("path",{d:"M3 15h18"})]}),B=(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{x:"3",y:"5",width:"6",height:"6",rx:"1"}),(0,n.jsx)("path",{d:"m3 17 2 2 4-4"}),(0,n.jsx)("line",{x1:"13",x2:"21",y1:"6",y2:"6"}),(0,n.jsx)("line",{x1:"13",x2:"21",y1:"18",y2:"18"})]}),F=(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("line",{x1:"12",x2:"12",y1:"20",y2:"10"}),(0,n.jsx)("line",{x1:"18",x2:"18",y1:"20",y2:"4"}),(0,n.jsx)("line",{x1:"6",x2:"6",y1:"20",y2:"14"})]}),P=(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M16 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V8Z"}),(0,n.jsx)("path",{d:"M15 3v4a2 2 0 0 0 2 2h4"}),(0,n.jsx)("path",{d:"M10 16h4"}),(0,n.jsx)("path",{d:"M10 12h4"})]});function z(e){var t;if("entry"===e.kind){let t=e.label||"(".concat(e.objectName," entry)");return{title:t,description:e.fields?Object.entries(e.fields).slice(0,2).map(e=>{let[t,r]=e;return"".concat(t,": ").concat(r)}).join(" | "):void 0,badge:e.objectName,icon:P,category:"entry",command:r=>{let{editor:n,range:o}=r,l=(0,S.VE)(e.objectName,e.entryId);n.chain().focus().deleteRange(o).insertContent({type:"text",text:t,marks:[{type:"link",attrs:{href:l,target:null}}]}).run()}}}let r=null!=(t=e.nodeType)?t:"object"===e.kind?"object":"file",o=e.label||e.path||e.id;return{title:o,description:e.sublabel,icon:function(e){switch(e){case"document":default:return(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"}),(0,n.jsx)("path",{d:"M14 2v4a2 2 0 0 0 2 2h4"})]});case"object":return(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M12 3v18"}),(0,n.jsx)("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),(0,n.jsx)("path",{d:"M3 9h18"}),(0,n.jsx)("path",{d:"M3 15h18"})]});case"report":return(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("line",{x1:"12",x2:"12",y1:"20",y2:"10"}),(0,n.jsx)("line",{x1:"18",x2:"18",y1:"20",y2:"4"}),(0,n.jsx)("line",{x1:"6",x2:"6",y1:"20",y2:"14"})]})}}(r),category:"file",command:t=>{var r;let{editor:n,range:l}=t,a=(0,S.bJ)(null!=(r=e.path)?r:e.id);n.chain().focus().deleteRange(l).insertContent({type:"text",text:o,marks:[{type:"link",attrs:{href:a,target:null}}]}).run()}}}let O=(0,v.forwardRef)((e,t)=>{let{items:r,command:o}=e,[l,a]=(0,v.useState)(0),s=(0,v.useRef)(null);(0,v.useEffect)(()=>{a(0)},[r]),(0,v.useEffect)(()=>{var e;let t=null==(e=s.current)?void 0:e.children[l];null==t||t.scrollIntoView({block:"nearest"})},[l]);let i=(0,v.useCallback)(e=>{let t=r[e];t&&o(t)},[r,o]);return((0,v.useImperativeHandle)(t,()=>({onKeyDown:e=>{let{event:t}=e;return"ArrowUp"===t.key?(a(e=>(e+r.length-1)%r.length),!0):"ArrowDown"===t.key?(a(e=>(e+1)%r.length),!0):"Enter"===t.key&&(i(l),!0)}})),0===r.length)?(0,n.jsx)("div",{className:"slash-cmd-popup",children:(0,n.jsx)("div",{className:"slash-cmd-empty",children:"No results"})}):(0,n.jsx)("div",{className:"slash-cmd-popup",ref:s,children:r.map((e,t)=>(0,n.jsxs)("button",{type:"button",className:"slash-cmd-item ".concat(t===l?"slash-cmd-item-active":""),onClick:()=>i(t),onMouseEnter:()=>a(t),children:[(0,n.jsx)("span",{className:"slash-cmd-item-icon",children:e.icon}),(0,n.jsxs)("span",{className:"slash-cmd-item-body",children:[(0,n.jsxs)("span",{className:"slash-cmd-item-title",children:[e.title,e.badge&&(0,n.jsx)("span",{className:"slash-cmd-item-badge",children:e.badge})]}),e.description&&(0,n.jsx)("span",{className:"slash-cmd-item-desc",children:e.description})]})]},"".concat(e.category,"-").concat(e.title,"-").concat(t)))})});function U(e){let{items:t,command:r,clientRect:o,componentRef:l}=e,a=(0,v.useRef)(null);return(0,v.useLayoutEffect)(()=>{if(!a.current||!o)return;let e=o();if(!e)return;let t=a.current;t.style.position="fixed",t.style.left="".concat(e.left,"px"),t.style.top="".concat(e.bottom+4,"px"),t.style.zIndex="50"},[o,t]),(0,C.createPortal)((0,n.jsx)("div",{ref:a,children:(0,n.jsx)(O,{ref:l,items:t,command:r})}),document.body)}function H(){return()=>{let e=null,t=null,o={current:null};return{onStart:l=>{e=document.createElement("div"),document.body.appendChild(e),Promise.resolve().then(r.t.bind(r,80282,19)).then(r=>{let{createRoot:a}=r;(t=a(e)).render((0,n.jsx)(U,{items:l.items,command:l.command,clientRect:l.clientRect,componentRef:o}))})},onUpdate:e=>{null==t||t.render((0,n.jsx)(U,{items:e.items,command:e.command,clientRect:e.clientRect,componentRef:o}))},onKeyDown:r=>{var n,l;return"Escape"===r.event.key?(null==t||t.unmount(),null==e||e.remove(),e=null,t=null,!0):null!=(l=null==(n=o.current)?void 0:n.onKeyDown(r))&&l},onExit:()=>{null==t||t.unmount(),null==e||e.remove(),e=null,t=null}}}}function V(e){return g.YY.create({name:"fileMention",addOptions:()=>({suggestion:{char:"@",pluginKey:L,startOfLine:!1,command:e=>{let{editor:t,range:r,props:n}=e;n.command({editor:t,range:r})},items:t=>{let{query:r}=t;return e(r,15).map(z)},render:H()}}),addProseMirrorPlugins(){return[(0,w.Ay)({editor:this.editor,...this.options.suggestion})]}})}O.displayName="CommandList";var K=r(77704),J=r(90425);function q(e){let t=e.match(/^(---\s*\n[\s\S]*?\n---\s*\n)/);return t?t[1]:""}function G(e){var t;let{content:r,rawContent:y,filePath:b,tree:N,onSave:C,onDirty:L,onNavigate:P,searchFn:z}=e,[O,U]=(0,v.useState)(!1),[G,Z]=(0,v.useState)("idle"),[Y,Q]=(0,v.useState)(!1),X=(0,v.useRef)(r),ee=(0,v.useRef)(null),et=(0,v.useRef)(q(null!=y?y:"")),er=(0,v.useMemo)(()=>(function(){let e=[{title:"Heading 1",description:"Large section heading",icon:T(1),category:"block",command:e=>{let{editor:t,range:r}=e;t.chain().focus().deleteRange(r).setNode("heading",{level:1}).run()}},{title:"Heading 2",description:"Medium section heading",icon:T(2),category:"block",command:e=>{let{editor:t,range:r}=e;t.chain().focus().deleteRange(r).setNode("heading",{level:2}).run()}},{title:"Heading 3",description:"Small section heading",icon:T(3),category:"block",command:e=>{let{editor:t,range:r}=e;t.chain().focus().deleteRange(r).setNode("heading",{level:3}).run()}},{title:"Bullet List",description:"Unordered list",icon:I,category:"block",command:e=>{let{editor:t,range:r}=e;t.chain().focus().deleteRange(r).toggleBulletList().run()}},{title:"Numbered List",description:"Ordered list",icon:R,category:"block",command:e=>{let{editor:t,range:r}=e;t.chain().focus().deleteRange(r).toggleOrderedList().run()}},{title:"Task List",description:"Checklist with checkboxes",icon:B,category:"block",command:e=>{let{editor:t,range:r}=e;t.chain().focus().deleteRange(r).toggleTaskList().run()}},{title:"Blockquote",description:"Quote block",icon:_,category:"block",command:e=>{let{editor:t,range:r}=e;t.chain().focus().deleteRange(r).toggleBlockquote().run()}},{title:"Code Block",description:"Fenced code block",icon:E,category:"block",command:e=>{let{editor:t,range:r}=e;t.chain().focus().deleteRange(r).toggleCodeBlock().run()}},{title:"Horizontal Rule",description:"Divider line",icon:D,category:"block",command:e=>{let{editor:t,range:r}=e;t.chain().focus().deleteRange(r).setHorizontalRule().run()}},{title:"Image",description:"Insert image from URL",icon:A,category:"block",command:e=>{let{editor:t,range:r}=e,n=window.prompt("Image URL:");n&&t.chain().focus().deleteRange(r).setImage({src:n}).run()}},{title:"Table",description:"Insert a 3x3 table",icon:W,category:"block",command:e=>{let{editor:t,range:r}=e;t.chain().focus().deleteRange(r).insertTable({rows:3,cols:3,withHeaderRow:!0}).run()}},{title:"Report Chart",description:"Interactive report-json block",icon:F,category:"block",command:e=>{let{editor:t,range:r}=e,n=JSON.stringify({version:1,title:"New Report",panels:[{id:"panel-1",title:"Chart",type:"bar",sql:"SELECT 1 as x, 10 as y",mapping:{xAxis:"x",yAxis:["y"]}}]},null,2);t.chain().focus().deleteRange(r).insertContent({type:"reportBlock",attrs:{config:n}}).run()}}];return g.YY.create({name:"slashCommand",addOptions:()=>({suggestion:{char:"/",pluginKey:M,startOfLine:!1,command:e=>{let{editor:t,range:r,props:n}=e;n.command({editor:t,range:r})},items:t=>{let{query:r}=t,n=r.toLowerCase();return n?e.filter(e=>{var t,r;return e.title.toLowerCase().includes(n)||null!=(r=null==(t=e.description)?void 0:t.toLowerCase().includes(n))&&r}):e},render:H()}}),addProseMirrorPlugins(){return[(0,w.Ay)({editor:this.editor,...this.options.suggestion})]}})})(),[]),en=(0,v.useMemo)(()=>z?V(z):function(e){let t=(function e(t){let r=[];for(let n of t)"folder"!==n.type&&r.push(n),n.children&&r.push(...e(n.children));return r})(e).map(e=>({id:e.path,label:e.name.replace(/\.md$/,""),sublabel:e.path,kind:"object"===e.type?"object":"file",path:e.path,nodeType:e.type}));return V(function(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:15;if(!e)return t.slice(0,r);let n=e.toLowerCase();return t.filter(e=>{var t,r;return e.label.toLowerCase().includes(n)||null!=(r=null==(t=e.sublabel)?void 0:t.toLowerCase().includes(n))&&r}).slice(0,r)})}(N),[z,N]),eo=(0,o.hG)({extensions:[a.A.configure({codeBlock:{HTMLAttributes:{class:"code-block"}}}),s.oz.configure({markedOptions:{gfm:!0}}),i.Ay.configure({inline:!1,allowBase64:!0,HTMLAttributes:{class:"editor-image"}}),c.Ay.configure({openOnClick:!1,autolink:!0,HTMLAttributes:{class:"editor-link",rel:"noopener"}}),d.XI.configure({resizable:!1}),u.A,p.A,h.h,x.A,m.A.configure({nested:!0}),f.A.configure({placeholder:"Start writing, or type / for commands..."}),j,er,en],content:k(r),contentType:"markdown",immediatelyRender:!1,onUpdate:()=>{Q(!0),Z("idle"),null==L||L()}}),el=(0,v.useCallback)(async e=>{let t=new FormData;t.append("file",e);try{let e=await fetch("/api/workspace/upload",{method:"POST",body:t});if(!e.ok)return null;let r=await e.json();return"/api/workspace/assets/".concat(r.path.replace(/^assets\//,""))}catch(e){return null}},[]),ea=(0,v.useCallback)(async e=>{if(eo)for(let t of e){let e=await el(t);e&&eo.chain().focus().setImage({src:e,alt:t.name}).run()}},[eo,el]);(0,v.useEffect)(()=>{if(!eo)return;let e=eo.view.dom,t=e=>{var t,r;if(!(null==(r=e.dataTransfer)||null==(t=r.files)?void 0:t.length))return;let n=Array.from(e.dataTransfer.files).filter(e=>e.type.startsWith("image/"));0!==n.length&&(e.preventDefault(),e.stopPropagation(),ea(n))},r=e=>{var t,r;(null==(r=e.dataTransfer)||null==(t=r.types)?void 0:t.includes("Files"))&&e.preventDefault()},n=e=>{if(!e.clipboardData)return;let t=Array.from(e.clipboardData.files).filter(e=>e.type.startsWith("image/"));if(t.length>0){e.preventDefault(),e.stopPropagation(),ea(t);return}let r=e.clipboardData.getData("text/plain");if(r&&(r.startsWith("file://")||/^(\/|~\/|[A-Z]:\\).*\.(png|jpe?g|gif|webp|svg|bmp|ico)$/i.test(r.trim()))){e.preventDefault(),e.stopPropagation();let t=r.trim().replace(/^file:\/\//,"");null==eo||eo.chain().focus().setImage({src:t}).run()}};return e.addEventListener("drop",t),e.addEventListener("dragover",r),e.addEventListener("paste",n),()=>{e.removeEventListener("drop",t),e.removeEventListener("dragover",r),e.removeEventListener("paste",n)}},[eo,ea]),(0,v.useEffect)(()=>{if(!eo||!P)return;let e=e=>{let t=e.target.closest("a");if(!t)return;let r=t.getAttribute("href");if(r){if(r.startsWith("#")){var n;e.preventDefault(),e.stopPropagation();let t=r.slice(1),o=eo.view.dom,l=null!=(n=o.querySelector('[id="'.concat(CSS.escape(t),'"]')))?n:o.querySelector("h1, h2, h3, h4, h5, h6");if(l){let e=Array.from(o.querySelectorAll("h1, h2, h3, h4, h5, h6")).find(e=>(e.textContent||"").trim().toLowerCase().replace(/[^\w\s-]/g,"").replace(/\s+/g,"-")===t);(null!=e?e:l).scrollIntoView({behavior:"smooth",block:"start"})}return}if((0,S.m9)(r)||!r.startsWith("http://")&&!r.startsWith("https://")&&!r.startsWith("mailto:")){e.preventDefault(),e.stopPropagation(),P(r);return}e.preventDefault(),e.stopPropagation(),window.open(r,"_blank","noopener,noreferrer")}},t=eo.view.dom;return t.addEventListener("click",e,!0),()=>t.removeEventListener("click",e,!0)},[eo,P]);let es=(0,v.useCallback)(async()=>{if(eo&&!O){U(!0),Z("idle");try{let e=("function"==typeof eo.getMarkdown?eo.getMarkdown():eo.getHTML()).replace(/<div data-type="report-block" data-config="([^"]*)">\s*<\/div>/g,(e,t)=>"```report-json\n"+t.replace(/&gt;/g,">").replace(/&lt;/g,"<").replace(/&quot;/g,'"').replace(/&amp;/g,"&")+"\n```"),t=et.current+e;(await fetch((0,J.nC)(b),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:b,content:t})})).ok?(Z("saved"),Q(!1),X.current=r,null==C||C(),ee.current&&clearTimeout(ee.current),ee.current=setTimeout(()=>Z("idle"),2e3)):Z("error")}catch(e){Z("error")}finally{U(!1)}}},[eo,b,O,C]);return((0,v.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&"s"===e.key&&(e.preventDefault(),es())};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[es]),(0,v.useEffect)(()=>{if(eo&&!Y&&r!==X.current){X.current=r,et.current=q(null!=y?y:"");let e=k(r);eo.commands.setContent(e,{contentType:"markdown"}),Q(!1)}},[r,y,eo,Y]),eo)?(0,n.jsxs)("div",{className:"markdown-editor-container",children:[(0,n.jsxs)("div",{className:"editor-top-bar",children:[(0,n.jsxs)("div",{className:"editor-top-bar-left",children:[Y&&(0,n.jsx)("span",{className:"editor-save-indicator editor-save-unsaved",children:"Unsaved changes"}),"saved"===G&&!Y&&(0,n.jsx)("span",{className:"editor-save-indicator editor-save-saved",children:"Saved"}),"error"===G&&(0,n.jsx)("span",{className:"editor-save-indicator editor-save-error",children:"Save failed"})]}),(0,n.jsxs)("div",{className:"editor-top-bar-right",children:[(0,n.jsxs)("span",{className:"editor-save-hint",children:["undefined"!=typeof navigator&&(null==(t=navigator.platform)?void 0:t.includes("Mac"))?"⌘":"Ctrl","+S"]}),(0,n.jsx)("button",{type:"button",onClick:()=>void es(),disabled:O||!Y,className:"editor-save-button",children:O?"Saving...":"Save"})]})]}),(0,n.jsx)($,{editor:eo,onUploadImages:ea}),(0,n.jsx)(l.m,{editor:eo,children:(0,n.jsxs)("div",{className:"bubble-menu",children:[(0,n.jsx)(K.zM,{active:eo.isActive("bold"),onClick:()=>eo.chain().focus().toggleBold().run(),title:"Bold",children:(0,n.jsx)("strong",{children:"B"})}),(0,n.jsx)(K.zM,{active:eo.isActive("italic"),onClick:()=>eo.chain().focus().toggleItalic().run(),title:"Italic",children:(0,n.jsx)("em",{children:"I"})}),(0,n.jsx)(K.zM,{active:eo.isActive("strike"),onClick:()=>eo.chain().focus().toggleStrike().run(),title:"Strikethrough",children:(0,n.jsx)("s",{children:"S"})}),(0,n.jsx)(K.zM,{active:eo.isActive("code"),onClick:()=>eo.chain().focus().toggleCode().run(),title:"Inline code",children:"<>"}),(0,n.jsx)(K.zM,{active:eo.isActive("link"),onClick:()=>{if(eo.isActive("link"))eo.chain().focus().unsetLink().run();else{let e=window.prompt("URL:");e&&eo.chain().focus().setLink({href:e}).run()}},title:"Link",children:(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),(0,n.jsx)("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})})]})}),(0,n.jsx)("div",{className:"editor-content-area workspace-prose",children:(0,n.jsx)(o.$Z,{editor:eo})})]}):(0,n.jsxs)("div",{className:"animate-pulse space-y-3 py-4 px-6",children:[(0,n.jsx)("div",{className:"h-4 rounded",style:{background:"var(--color-surface)",width:"80%"}}),(0,n.jsx)("div",{className:"h-4 rounded",style:{background:"var(--color-surface)",width:"60%"}}),(0,n.jsx)("div",{className:"h-4 rounded",style:{background:"var(--color-surface)",width:"70%"}})]})}function $(e){let{editor:t,onUploadImages:r}=e,o=(0,v.useRef)(null);return t?(0,n.jsxs)("div",{className:"editor-toolbar",children:[(0,n.jsxs)(K.$Q,{children:[(0,n.jsx)(K.IB,{active:t.isActive("heading",{level:1}),onClick:()=>t.chain().focus().toggleHeading({level:1}).run(),title:"Heading 1",children:"H1"}),(0,n.jsx)(K.IB,{active:t.isActive("heading",{level:2}),onClick:()=>t.chain().focus().toggleHeading({level:2}).run(),title:"Heading 2",children:"H2"}),(0,n.jsx)(K.IB,{active:t.isActive("heading",{level:3}),onClick:()=>t.chain().focus().toggleHeading({level:3}).run(),title:"Heading 3",children:"H3"})]}),(0,n.jsx)(K.x_,{}),(0,n.jsxs)(K.$Q,{children:[(0,n.jsx)(K.IB,{active:t.isActive("bold"),onClick:()=>t.chain().focus().toggleBold().run(),title:"Bold",children:(0,n.jsx)("strong",{children:"B"})}),(0,n.jsx)(K.IB,{active:t.isActive("italic"),onClick:()=>t.chain().focus().toggleItalic().run(),title:"Italic",children:(0,n.jsx)("em",{children:"I"})}),(0,n.jsx)(K.IB,{active:t.isActive("strike"),onClick:()=>t.chain().focus().toggleStrike().run(),title:"Strikethrough",children:(0,n.jsx)("s",{children:"S"})}),(0,n.jsx)(K.IB,{active:t.isActive("code"),onClick:()=>t.chain().focus().toggleCode().run(),title:"Inline code",children:"<>"})]}),(0,n.jsx)(K.x_,{}),(0,n.jsxs)(K.$Q,{children:[(0,n.jsx)(K.IB,{active:t.isActive("bulletList"),onClick:()=>t.chain().focus().toggleBulletList().run(),title:"Bullet list",children:(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("line",{x1:"8",x2:"21",y1:"6",y2:"6"}),(0,n.jsx)("line",{x1:"8",x2:"21",y1:"12",y2:"12"}),(0,n.jsx)("line",{x1:"8",x2:"21",y1:"18",y2:"18"}),(0,n.jsx)("line",{x1:"3",x2:"3.01",y1:"6",y2:"6"}),(0,n.jsx)("line",{x1:"3",x2:"3.01",y1:"12",y2:"12"}),(0,n.jsx)("line",{x1:"3",x2:"3.01",y1:"18",y2:"18"})]})}),(0,n.jsx)(K.IB,{active:t.isActive("orderedList"),onClick:()=>t.chain().focus().toggleOrderedList().run(),title:"Ordered list",children:(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("line",{x1:"10",x2:"21",y1:"6",y2:"6"}),(0,n.jsx)("line",{x1:"10",x2:"21",y1:"12",y2:"12"}),(0,n.jsx)("line",{x1:"10",x2:"21",y1:"18",y2:"18"}),(0,n.jsx)("path",{d:"M4 6h1v4"}),(0,n.jsx)("path",{d:"M4 10h2"}),(0,n.jsx)("path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1"})]})}),(0,n.jsx)(K.IB,{active:t.isActive("taskList"),onClick:()=>t.chain().focus().toggleTaskList().run(),title:"Task list",children:(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{x:"3",y:"5",width:"6",height:"6",rx:"1"}),(0,n.jsx)("path",{d:"m3 17 2 2 4-4"}),(0,n.jsx)("line",{x1:"13",x2:"21",y1:"6",y2:"6"}),(0,n.jsx)("line",{x1:"13",x2:"21",y1:"18",y2:"18"})]})}),(0,n.jsx)(K.IB,{active:t.isActive("blockquote"),onClick:()=>t.chain().focus().toggleBlockquote().run(),title:"Blockquote",children:(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M3 21c3 0 7-1 7-8V5c0-1.25-.756-2.017-2-2H4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2 1 0 1 0 1 1v1c0 1-1 2-2 2s-1 .008-1 1.031V21z"}),(0,n.jsx)("path",{d:"M15 21c3 0 7-1 7-8V5c0-1.25-.757-2.017-2-2h-4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2h.75c0 2.25.25 4-2.75 4v3z"})]})}),(0,n.jsx)(K.IB,{active:t.isActive("codeBlock"),onClick:()=>t.chain().focus().toggleCodeBlock().run(),title:"Code block",children:(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("polyline",{points:"16 18 22 12 16 6"}),(0,n.jsx)("polyline",{points:"8 6 2 12 8 18"})]})})]}),(0,n.jsx)(K.x_,{}),(0,n.jsxs)(K.$Q,{children:[(0,n.jsx)(K.IB,{active:!1,onClick:()=>{let e=window.prompt("Link URL:");e&&t.chain().focus().setLink({href:e}).run()},title:"Insert link",children:(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),(0,n.jsx)("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})}),(0,n.jsx)(K.IB,{active:!1,onClick:()=>{if(r){var e;null==(e=o.current)||e.click()}else{let e=window.prompt("Image URL:");e&&t.chain().focus().setImage({src:e}).run()}},title:"Insert image (click to upload, or drag & drop)",children:(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),(0,n.jsx)("circle",{cx:"9",cy:"9",r:"2"}),(0,n.jsx)("path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"})]})}),(0,n.jsx)("input",{ref:o,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:e=>{var t;let n=Array.from(null!=(t=e.target.files)?t:[]);n.length>0&&r&&r(n),e.target.value=""}}),(0,n.jsx)(K.IB,{active:!1,onClick:()=>{t.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run()},title:"Insert table",children:(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M12 3v18"}),(0,n.jsx)("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),(0,n.jsx)("path",{d:"M3 9h18"}),(0,n.jsx)("path",{d:"M3 15h18"})]})}),(0,n.jsx)(K.IB,{active:!1,onClick:()=>{t.chain().focus().setHorizontalRule().run()},title:"Horizontal rule",children:(0,n.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("line",{x1:"2",x2:"22",y1:"12",y2:"12"})})})]})]}):null}},64243:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>ul});var n=r(80534),o=r(74166),l=r(99197),a=r(82311),s=r(94626),i=r(5742),c=r(87694);function d(){return(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{opacity:.5},children:[(0,n.jsx)("rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}),(0,n.jsx)("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})}var u=r(26165),p=r(66862),h=r(7589);function x(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return(0,h.QP)((0,p.$)(t))}function m(e){let{...t}=e;return(0,n.jsx)(u.bL,{"data-slot":"context-menu",...t})}function f(e){let{className:t,...r}=e;return(0,n.jsx)(u.l9,{"data-slot":"context-menu-trigger",className:x("select-none",t),...r})}function v(e){let{className:t,...r}=e;return(0,n.jsx)(u.ZL,{children:(0,n.jsx)(u.UC,{"data-slot":"context-menu-content",className:x("bg-neutral-100/[0.67] dark:bg-neutral-900/[0.67] border border-white dark:border-white/10 backdrop-blur-md text-[var(--color-text)] z-[9999] max-h-[var(--radix-context-menu-content-available-height)] min-w-[8rem] overflow-x-hidden overflow-y-auto rounded-3xl p-1 shadow-[0_0_25px_0_rgba(0,0,0,0.16)] outline-none","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...r})})}function g(e){let{className:t,inset:r,variant:o="default",...l}=e;return(0,n.jsx)(u.q7,{"data-slot":"context-menu-item","data-inset":r,"data-variant":o,className:x("bg-transparent hover:bg-neutral-400/15 focus:bg-neutral-400/15 text-sm transition-all relative flex cursor-pointer items-center gap-2 rounded-full px-2 py-1.5 outline-none select-none","data-[variant=destructive]:text-[var(--color-error)] data-[variant=destructive]:hover:bg-[var(--color-error)]/10 data-[variant=destructive]:focus:bg-[var(--color-error)]/10 data-[variant=destructive]:hover:text-[var(--color-error)]",r&&"pl-8","[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...l})}function y(e){let{className:t,...r}=e;return(0,n.jsx)(u.wv,{"data-slot":"context-menu-separator",className:x("bg-neutral-400/15 -mx-1 my-1 h-px",t),...r})}function b(e){let{className:t,...r}=e;return(0,n.jsx)("span",{"data-slot":"context-menu-shortcut",className:x("text-[var(--color-text-muted)] ml-auto text-xs tracking-widest",t),...r})}function j(e){let{currentName:t,onCommit:r,onCancel:l}=e,[a,s]=(0,o.useState)(t),[i,c]=(0,o.useState)(!1),d=(0,o.useRef)(null);(0,o.useEffect)(()=>{let e=d.current;if(!e)return;e.focus();let r=t.lastIndexOf(".");r>0?e.setSelectionRange(0,r):e.select()},[t]);let u=(0,o.useCallback)(e=>{let t=e.trim();return!(!t||t.includes("/")||t.includes("\\"))},[]),p=(0,o.useCallback)(()=>{let e=a.trim();if(!u(e)){c(!0),setTimeout(()=>c(!1),500);return}if(e===t)return void l();r(e)},[a,t,u,r,l]),h=(0,o.useCallback)(e=>{e.stopPropagation(),"Enter"===e.key?(e.preventDefault(),p()):"Escape"===e.key&&(e.preventDefault(),l())},[p,l]);return(0,n.jsx)("input",{ref:d,type:"text",value:a,onChange:e=>{s(e.target.value),c(!1)},onBlur:p,onKeyDown:h,className:"flex-1 text-sm rounded px-1 py-0 outline-none min-w-0",style:{background:"var(--color-bg)",color:"var(--color-text)",border:i?"1px solid #ef4444":"1px solid var(--color-accent)",animation:i?"renameShake 300ms ease":void 0},onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation()})}var k=r(90425);function w(e){return!!e.virtual||(0,k.L6)(e.path)}let N=[/^\.object\.yaml$/,/\.wal$/,/\.tmp$/],C=[/^workspace\.duckdb/,/^workspace_context\.yaml$/];function S(e,t){var r;let n=function(e,t){let r=(0,k.Bv)(e);return"virtual"===r||"homeRelative"===r?null:"workspaceRelative"===r?e:t&&(e===t||e.startsWith("".concat(t,"/")))?e===t?"":e.slice(t.length+1):null}(e,t);if(null==n)return!1;let o=null!=(r=n.split("/").pop())?r:"";return!!N.some(e=>e.test(o))||""!==n&&!n.includes("/")&&C.some(e=>e.test(o))}function M(e){let{open:t}=e;return(0,n.jsx)("img",{src:t?"/icons/folder-open.png":"/icons/folder.png",alt:"",width:16,height:16,draggable:!1,style:{flexShrink:0}})}function L(){return(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[(0,n.jsx)("rect",{x:"1.5",y:"2.5",width:"13",height:"11",rx:"2",fill:"#42a97a",fillOpacity:"0.15",stroke:"#42a97a",strokeWidth:"1.2"}),(0,n.jsx)("path",{d:"M1.5 6.5h13",stroke:"#42a97a",strokeWidth:"1.2"}),(0,n.jsx)("path",{d:"M6 6.5v7",stroke:"#42a97a",strokeWidth:"1.2"})]})}function T(){return(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[(0,n.jsx)("rect",{x:"1.5",y:"2.5",width:"3.5",height:"9.5",rx:"1",fill:"#8b7cf6",fillOpacity:"0.18",stroke:"#8b7cf6",strokeWidth:"1.1"}),(0,n.jsx)("rect",{x:"6.25",y:"2.5",width:"3.5",height:"6.5",rx:"1",fill:"#8b7cf6",fillOpacity:"0.18",stroke:"#8b7cf6",strokeWidth:"1.1"}),(0,n.jsx)("rect",{x:"11",y:"2.5",width:"3.5",height:"11",rx:"1",fill:"#8b7cf6",fillOpacity:"0.18",stroke:"#8b7cf6",strokeWidth:"1.1"})]})}function I(){return(0,n.jsx)("img",{src:"/icons/document.png",alt:"",width:16,height:16,draggable:!1,style:{flexShrink:0,filter:"drop-shadow(0 0.5px 1.5px rgba(0,0,0,0.2))"}})}function R(){return(0,n.jsx)("img",{src:"/icons/document.png",alt:"",width:16,height:16,draggable:!1,style:{flexShrink:0,filter:"drop-shadow(0 0.5px 1.5px rgba(0,0,0,0.2))"}})}function _(){return(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("ellipse",{cx:"12",cy:"5",rx:"9",ry:"3"}),(0,n.jsx)("path",{d:"M3 5V19A9 3 0 0 0 21 19V5"}),(0,n.jsx)("path",{d:"M3 12A9 3 0 0 0 21 12"})]})}function E(){return(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("line",{x1:"12",x2:"12",y1:"20",y2:"10"}),(0,n.jsx)("line",{x1:"18",x2:"18",y1:"20",y2:"4"}),(0,n.jsx)("line",{x1:"6",x2:"6",y1:"20",y2:"14"})]})}function D(){return(0,n.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function A(){return(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"#6366f1",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{width:"7",height:"7",x:"3",y:"3",rx:"1"}),(0,n.jsx)("rect",{width:"7",height:"7",x:"14",y:"3",rx:"1"}),(0,n.jsx)("rect",{width:"7",height:"7",x:"3",y:"14",rx:"1"}),(0,n.jsx)("rect",{width:"7",height:"7",x:"14",y:"14",rx:"1"})]})}function W(){return(0,n.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{opacity:.4},children:[(0,n.jsx)("rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}),(0,n.jsx)("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})}function B(){return(0,n.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{opacity:.55},children:(0,n.jsx)("path",{d:"m9 18 6-6-6-6"})})}function F(e){let{open:t}=e;return(0,n.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:t?"rotate(90deg)":"rotate(0deg)",transition:"transform 150ms ease"},children:(0,n.jsx)("path",{d:"m9 18 6-6-6-6"})})}function P(){return(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{width:"7",height:"7",x:"3",y:"3",rx:"1"}),(0,n.jsx)("rect",{width:"7",height:"7",x:"14",y:"3",rx:"1"}),(0,n.jsx)("rect",{width:"7",height:"7",x:"14",y:"14",rx:"1"}),(0,n.jsx)("rect",{width:"7",height:"7",x:"3",y:"14",rx:"1"})]})}function z(e){let{node:t,open:r}=e;if(t.path.startsWith("~chats/")||"~chats"===t.path)return(0,n.jsx)(D,{});switch(t.type){case"object":return"kanban"===t.defaultView?(0,n.jsx)(T,{}):(0,n.jsx)(L,{});case"document":return(0,n.jsx)(I,{});case"folder":return(0,n.jsx)(M,{open:r});case"database":return(0,n.jsx)(_,{});case"report":return(0,n.jsx)(E,{});case"app":{var o,l;let e=null!=(l=null==(o=t.appManifest)?void 0:o.icon)?l:t.icon;if(e&&(e.endsWith(".png")||e.endsWith(".svg")||e.endsWith(".jpg")||e.endsWith(".jpeg")||e.endsWith(".webp")))return(0,n.jsx)("img",{src:"/api/apps/serve/".concat(t.path,"/").concat(e),alt:"",width:16,height:16,className:"rounded-sm flex-shrink-0",style:{objectFit:"cover"}});return(0,n.jsx)(A,{})}default:return(0,n.jsx)(R,{})}}function O(e){switch(e.type){case"object":return"var(--color-accent)";case"document":return"#60a5fa";case"database":return"#c084fc";case"report":return"#22c55e";case"app":return"#6366f1";default:return"var(--color-text-muted)"}}async function U(e,t){return(await fetch("/api/workspace/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e,newName:t})})).json()}async function H(e){return(await fetch("/api/workspace/file",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})})).json()}async function V(e,t){return(await fetch("/api/workspace/move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sourcePath:e,destinationDir:t})})).json()}async function K(e){return(await fetch("/api/workspace/copy",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})})).json()}async function J(e){return(await fetch("/api/workspace/mkdir",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})})).json()}async function q(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return(await fetch((0,k.nC)(e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e,content:t})})).json()}function G(e){let{message:t,onConfirm:r,onCancel:l}=e;return(0,o.useEffect)(()=>{function e(e){"Escape"===e.key&&l(),"Enter"===e.key&&r()}return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[r,l]),(0,n.jsx)("div",{className:"fixed inset-0 z-[10000] flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},children:(0,n.jsxs)("div",{className:"rounded-xl p-5 max-w-sm w-full shadow-2xl border",style:{background:"var(--color-surface)",borderColor:"var(--color-border)"},children:[(0,n.jsx)("p",{className:"text-sm mb-4",style:{color:"var(--color-text)"},children:t}),(0,n.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,n.jsx)("button",{type:"button",onClick:l,className:"px-3 py-1.5 rounded-md text-sm",style:{color:"var(--color-text-muted)",background:"var(--color-surface-hover)"},children:"Cancel"}),(0,n.jsx)("button",{type:"button",onClick:r,className:"px-3 py-1.5 rounded-md text-sm text-white",style:{background:"#ef4444"},children:"Delete"})]})]})})}function $(e){let{kind:t,parentPath:r,onSubmit:l,onCancel:a}=e,[s,i]=(0,o.useState)("file"===t?"untitled.md":"new-folder"),c=(0,o.useRef)(null);return(0,o.useEffect)(()=>{let e=c.current;if(e)if(e.focus(),"file"===t){let t=s.lastIndexOf(".");e.setSelectionRange(0,t>0?t:s.length)}else e.select()},[]),(0,n.jsx)("div",{className:"fixed inset-0 z-[10000] flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},children:(0,n.jsxs)("div",{className:"rounded-xl p-5 max-w-sm w-full shadow-2xl border",style:{background:"var(--color-surface)",borderColor:"var(--color-border)"},children:[(0,n.jsxs)("p",{className:"text-sm mb-3 font-medium",style:{color:"var(--color-text)"},children:["New ",t," in ",(0,n.jsx)("span",{style:{color:"var(--color-accent)"},children:r||"/"})]}),(0,n.jsx)("input",{ref:c,type:"text",value:s,onChange:e=>i(e.target.value),onKeyDown:e=>{"Enter"===e.key&&l(s.trim()),"Escape"===e.key&&a()},className:"w-full px-3 py-2 rounded-md text-sm outline-none border",style:{background:"var(--color-bg)",color:"var(--color-text)",borderColor:"var(--color-border)"}}),(0,n.jsxs)("div",{className:"flex justify-end gap-2 mt-3",children:[(0,n.jsx)("button",{type:"button",onClick:a,className:"px-3 py-1.5 rounded-md text-sm",style:{color:"var(--color-text-muted)",background:"var(--color-surface-hover)"},children:"Cancel"}),(0,n.jsx)("button",{type:"button",onClick:()=>l(s.trim()),className:"px-3 py-1.5 rounded-md text-sm text-white",style:{background:"var(--color-accent)"},children:"Create"})]})]})})}function Z(e){let{node:t,depth:r,activePath:l,selectedPath:a,onSelect:s,onNodeSelect:i,expandedPaths:d,onToggleExpand:u,renamingPath:p,onStartRename:h,onCommitRename:x,onCancelRename:m,onContextMenu:f,compact:v,dragOverPath:g,workspaceRoot:y}=e,b=!!y&&t.path===y,k=t.children&&t.children.length>0,N=!b&&!!k,C=!b&&d.has(t.path),M=l===t.path,L=a===t.path,T=N&&"object"!==t.type,I=p===t.path,R=S(t.path,y),_=w(t),E=R||_||b,D=g===t.path&&N,{attributes:A,listeners:U,setNodeRef:H,isDragging:V}=(0,c.PM)({id:"drag-".concat(t.path),data:{node:t},disabled:E}),{setNodeRef:K,isOver:J}=(0,c.zM)({id:"drop-".concat(t.path),data:{node:t},disabled:!N||_}),q=(0,o.useCallback)(()=>{i(t.path),s(t),T&&u(t.path)},[t,s,i,u,T]),G=(0,o.useCallback)(()=>{E||h(t.path)},[t.path,E,h]),$=(0,o.useCallback)(e=>{i(t.path),f(e,t)},[t,i,f]),Y=(0,o.useCallback)(e=>{H(e),K(e)},[H,K]),Q=(J||D)&&N;return(0,n.jsxs)("div",{style:{opacity:V?.4:1},children:[(0,n.jsxs)("div",{ref:Y,...A,...U,role:"treeitem",tabIndex:-1,draggable:!E,onDragStart:e=>{e.dataTransfer.setData("application/x-file-mention",JSON.stringify({name:t.name,path:t.path})),e.dataTransfer.setData("text/plain",t.path),e.dataTransfer.effectAllowed="copy"},onClick:q,onDoubleClick:G,onContextMenu:$,className:"w-full flex items-center gap-1.5 py-1 px-2 rounded-md text-left text-sm transition-all duration-100 cursor-pointer select-none",style:{paddingLeft:"".concat(10*r+8,"px"),background:b||Q?"var(--color-accent-light)":L||M?"var(--color-surface-hover)":"transparent",color:b?"var(--color-accent)":M||L?"var(--color-text)":"var(--color-text-muted)",outline:b?"1.5px solid var(--color-accent)":Q?"1px dashed var(--color-accent)":"none",outlineOffset:"-1px",borderRadius:b?"8px":"6px",marginTop:b?"2px":void 0,marginBottom:b?"2px":void 0},onMouseEnter:e=>{b?e.currentTarget.style.opacity="0.8":M||L||Q||(e.currentTarget.style.background="var(--color-surface-hover)")},onMouseLeave:e=>{b?e.currentTarget.style.opacity="1":M||L||Q||(e.currentTarget.style.background="transparent")},children:[(0,n.jsx)("span",{className:"flex-shrink-0 w-4 h-4 flex items-center justify-center",style:{opacity:+!!N,cursor:N?"pointer":void 0},onClick:N?e=>{e.stopPropagation(),u(t.path)}:void 0,children:N&&(0,n.jsx)(F,{open:C})}),(0,n.jsx)("span",{className:"flex-shrink-0 flex items-center",style:{color:b?"var(--color-accent)":O(t)},children:b?(0,n.jsx)(P,{}):(0,n.jsx)(z,{node:t,open:C})}),I?(0,n.jsx)(j,{currentName:t.name,onCommit:x,onCancel:m}):(0,n.jsx)("span",{className:"truncate flex-1",children:t.name}),b&&(0,n.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full flex-shrink-0 font-medium",style:{background:"var(--color-accent)",color:"white"},children:"workspace"}),"app"===t.type&&(0,n.jsx)("span",{className:"text-[9px] px-1.5 py-[1px] rounded flex-shrink-0 font-medium",style:{background:"#6366f118",color:"#6366f1"},children:"APP"}),E&&!b&&!v&&(0,n.jsx)("span",{className:"flex-shrink-0 ml-1",children:(0,n.jsx)(W,{})}),t.symlink&&!v&&(0,n.jsx)("span",{className:"flex-shrink-0 ml-0.5",title:"Symbolic link",style:{color:"var(--color-text-muted)"},children:(0,n.jsx)(B,{})})]}),C&&k&&(0,n.jsx)("div",{className:"relative",style:{borderLeft:r>0?"1px solid var(--color-border)":"none",marginLeft:"".concat(10*r+14,"px")},children:t.children.map(e=>(0,n.jsx)(Z,{node:e,depth:r+1,activePath:l,selectedPath:a,onSelect:s,onNodeSelect:i,expandedPaths:d,onToggleExpand:u,renamingPath:p,onStartRename:h,onCommitRename:x,onCancelRename:m,onContextMenu:f,compact:v,dragOverPath:g,workspaceRoot:y},e.path))})]})}function Y(e){let{isDragging:t}=e,{setNodeRef:r,isOver:o}=(0,c.zM)({id:"drop-__root__",data:{rootDrop:!0}}),l=o&&t;return(0,n.jsx)("div",{ref:r,className:"flex-1 min-h-[48px]",style:{margin:t?"4px 8px":void 0,borderRadius:"6px",border:l?"1.5px dashed var(--color-accent)":t?"1.5px dashed var(--color-border)":"1.5px dashed transparent",background:l?"var(--color-accent-light)":"transparent",transition:"all 150ms ease",display:"flex",alignItems:"center",justifyContent:"center"},children:t&&(0,n.jsx)("span",{className:"text-[11px] select-none",style:{color:l?"var(--color-accent)":"var(--color-text-muted)",opacity:l?1:.6},children:"Drop here to move to root"})})}function Q(e){let{node:t}=e;return(0,n.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm shadow-lg border",style:{background:"var(--color-surface)",borderColor:"var(--color-border)",color:"var(--color-text)",pointerEvents:"none"},children:[(0,n.jsx)("span",{style:{color:O(t)},children:(0,n.jsx)(z,{node:t})}),(0,n.jsx)("span",{children:t.name})]})}function X(e){let t=e.split("/");return t.pop(),t.join("/")||"."}let ee="denchclaw-tree-expanded";function et(e){let{tree:t,activePath:r,onSelect:l,onRefresh:a,compact:s,parentDir:i,onNavigateUp:d,browseDir:u,workspaceRoot:p,onExternalDrop:h}=e,[x,v]=(0,o.useState)(()=>(function(){try{let e=window.localStorage.getItem(ee);if(e){let t=JSON.parse(e);if(Array.isArray(t))return new Set(t)}}catch(e){}return new Set})()),[g,y]=(0,o.useState)(null),[b,j]=(0,o.useState)(null),[N,C]=(0,o.useState)(null),[L,T]=(0,o.useState)(null),I=(0,o.useRef)({x:0,y:0}),R=(0,o.useRef)(null),_=(0,o.useCallback)(()=>{let e=e=>{I.current={x:e.clientX,y:e.clientY};let t=document.elementFromPoint(e.clientX,e.clientY),r=null==t?void 0:t.closest("[data-chat-drop-target]"),n=document.querySelector("[data-drag-hover]");r&&!r.hasAttribute("data-drag-hover")&&r.setAttribute("data-drag-hover",""),n&&n!==r&&n.removeAttribute("data-drag-hover")};R.current=e,window.addEventListener("pointermove",e,!0)},[]),E=(0,o.useCallback)(()=>{var e;R.current&&(window.removeEventListener("pointermove",R.current,!0),R.current=null),null==(e=document.querySelector("[data-drag-hover]"))||e.removeAttribute("data-drag-hover")},[]);(0,o.useEffect)(()=>E,[E]);let[D,A]=(0,o.useState)({kind:"empty"}),W=(0,o.useRef)(0),[B,F]=(0,o.useState)(null),[P,z]=(0,o.useState)(null),O=(0,o.useRef)(null),et=(0,o.useRef)(null),en=(0,o.useRef)(null);(0,o.useEffect)(()=>{try{window.localStorage.setItem(ee,JSON.stringify([...x]))}catch(e){}},[x]);let eo=(0,o.useCallback)(e=>{v(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},[]),el=(0,c.FR)((0,c.MS)(c.AN,{activationConstraint:{distance:8}})),ea=(0,o.useCallback)(e=>{let t=e.active.data.current;(null==t?void 0:t.node)&&(T(t.node),_())},[_]),es=(0,o.useCallback)(e=>{var t;let r=null==(t=e.over)?void 0:t.data.current;if(null==r?void 0:r.rootDrop)"__root__"!==en.current&&(et.current&&clearTimeout(et.current),en.current="__root__"),C("__root__");else if(null==r?void 0:r.node){let e=r.node.path;C(e),en.current!==e&&(et.current&&clearTimeout(et.current),en.current=e,("folder"===r.node.type||"object"===r.node.type)&&(et.current=setTimeout(()=>{en.current===e&&v(t=>{if(t.has(e))return t;let r=new Set(t);return r.add(e),r})},300)))}else et.current&&clearTimeout(et.current),en.current=null,C(null)},[]),ei=(0,o.useCallback)(async e=>{var t;T(null),C(null),et.current&&clearTimeout(et.current),en.current=null,E();let r=e.active.data.current;if(!(null==r?void 0:r.node))return;let n=r.node;if(h){let{x:e,y:t}=I.current,r=document.elementFromPoint(e,t);if(null==r?void 0:r.closest("[data-chat-drop-target]"))return void h(n)}let o=null==(t=e.over)?void 0:t.data.current;if(null==o?void 0:o.rootDrop){if("."===X(n.path))return;(await V(n.path,".")).ok&&a();return}if(!(null==o?void 0:o.node))return;let l=o.node;!("folder"!==l.type&&"object"!==l.type||l.path===n.path||l.path.startsWith(n.path+"/"))&&X(n.path)!==l.path&&(await V(n.path,l.path)).ok&&a()},[a,h,E]),ec=(0,o.useCallback)(()=>{T(null),C(null),et.current&&clearTimeout(et.current),en.current=null,E()},[E]),ed=(0,o.useCallback)((e,t)=>{if(W.current===e.timeStamp)return;W.current=e.timeStamp;let r=S(t.path,p)||w(t);A({kind:"folder"===t.type||"object"===t.type?"folder":"file",path:t.path,name:t.name,isSystem:r})},[p]),eu=(0,o.useCallback)(e=>{W.current!==e.timeStamp&&(W.current=e.timeStamp,A({kind:"empty"}))},[]),ep=(0,o.useCallback)(async e=>{if(D)switch(e){case"open":if("empty"!==D.kind){let e=function e(t,r){for(let n of t){if(n.path===r)return n;if(n.children){let t=e(n.children,r);if(t)return t}}return null}(t,D.path);e&&l(e)}break;case"rename":"empty"!==D.kind&&j(D.path);break;case"duplicate":"empty"!==D.kind&&(await K(D.path),a());break;case"copy":case"getInfo":"empty"!==D.kind&&await navigator.clipboard.writeText((0,k.WW)(D.path,p));break;case"delete":"empty"!==D.kind&&F(D.path);break;case"newFile":z({kind:"file",parentPath:"folder"===D.kind?D.path:"file"===D.kind?X(D.path):""});break;case"newFolder":z({kind:"folder",parentPath:"folder"===D.kind?D.path:"file"===D.kind?X(D.path):""})}},[D,t,l,a,p]),eh=(0,o.useCallback)(async e=>{if(!b)return;let t=await U(b,e);j(null),t.ok&&a()},[b,a]),ex=(0,o.useCallback)(()=>{j(null)},[]),em=(0,o.useCallback)(async()=>{if(!B)return;let e=await H(B);F(null),e.ok&&a()},[B,a]),ef=(0,o.useCallback)(async e=>{if(!P||!e)return;let t=P.parentPath?"".concat(P.parentPath,"/").concat(e):e;"folder"===P.kind?await J(t):await q(t,""),z(null),a(),v(e=>{let t=new Set(e);return t.add(P.parentPath),t})},[P,a]),ev=(0,o.useCallback)(e=>{if(b)return;let r=function(e,t){let r=[];return!function e(n){for(let o of n)r.push(o),o.children&&t.has(o.path)&&e(o.children)}(e),r}(t,x),n=r.findIndex(e=>e.path===g),o=n>=0?r[n]:null;switch(e.key){case"ArrowDown":{e.preventDefault();let t=n<r.length-1?r[n+1]:r[0];t&&y(t.path);break}case"ArrowUp":{e.preventDefault();let t=n>0?r[n-1]:r[r.length-1];t&&y(t.path);break}case"ArrowRight":e.preventDefault(),o&&("folder"===o.type||"object"===o.type)&&v(e=>new Set([...e,o.path]));break;case"ArrowLeft":e.preventDefault(),o&&x.has(o.path)&&v(e=>{let t=new Set(e);return t.delete(o.path),t});break;case"Enter":if(e.preventDefault(),o){let t=S(o.path,p)||w(o);e.shiftKey||t?l(o):j(o.path)}break;case"F2":e.preventDefault(),!o||S(o.path,p)||w(o)||j(o.path);break;case"Backspace":case"Delete":!o||S(o.path,p)||w(o)||(e.preventDefault(),F(o.path));break;default:if(e.metaKey||e.ctrlKey){if("c"===e.key&&o)e.preventDefault(),navigator.clipboard.writeText((0,k.WW)(o.path,p));else if("d"===e.key&&o&&!S(o.path,p))e.preventDefault(),K(o.path).then(()=>a());else if("n"===e.key){e.preventDefault();let t=o?"folder"===o.type||"object"===o.type?o.path:X(o.path):"";e.shiftKey?z({kind:"folder",parentPath:t}):z({kind:"file",parentPath:t})}}}},[t,x,g,b,l,a,p]);return 0===t.length?(0,n.jsxs)(m,{children:[(0,n.jsx)(f,{asChild:!0,children:(0,n.jsx)("div",{className:"px-4 py-6 text-center text-sm",style:{color:"var(--color-text-muted)"},onContextMenu:eu,children:"No files in workspace"})}),(0,n.jsx)(er,{target:D,onAction:ep}),P&&(0,n.jsx)($,{kind:P.kind,parentPath:P.parentPath,onSubmit:ef,onCancel:()=>z(null)})]}):(0,n.jsxs)(c.Mp,{sensors:el,collisionDetection:c.fp,onDragStart:ea,onDragOver:es,onDragEnd:ei,onDragCancel:ec,children:[(0,n.jsxs)(m,{children:[(0,n.jsx)(f,{asChild:!0,children:(0,n.jsxs)("div",{ref:O,className:"py-1 outline-none flex flex-col min-h-full",tabIndex:0,role:"tree",onKeyDown:ev,onContextMenu:eu,children:[null!=i&&d&&(0,n.jsxs)("div",{role:"treeitem",tabIndex:-1,onClick:d,className:"w-full flex items-center gap-1.5 py-1 px-2 rounded-md text-left text-sm transition-all duration-100 cursor-pointer select-none",style:{paddingLeft:"8px",color:"var(--color-text-muted)",borderRadius:"6px"},onMouseEnter:e=>{e.currentTarget.style.background="var(--color-surface-hover)"},onMouseLeave:e=>{e.currentTarget.style.background="transparent"},children:[(0,n.jsx)("span",{className:"flex-shrink-0 w-4 h-4 flex items-center justify-center",children:(0,n.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"m15 18-6-6 6-6"})})}),(0,n.jsx)("span",{className:"flex-shrink-0 flex items-center",style:{color:"var(--color-text-muted)"},children:(0,n.jsx)(M,{})}),(0,n.jsx)("span",{className:"truncate flex-1",children:".."})]}),t.map(e=>(0,n.jsx)(Z,{node:e,depth:0,activePath:r,selectedPath:g,onSelect:l,onNodeSelect:y,expandedPaths:x,onToggleExpand:eo,renamingPath:b,onStartRename:j,onCommitRename:eh,onCancelRename:ex,onContextMenu:ed,compact:s,dragOverPath:N,workspaceRoot:p},e.path)),(0,n.jsx)(Y,{isDragging:!!L})]})}),(0,n.jsx)(er,{target:D,onAction:ep})]}),(0,n.jsx)(c.Hd,{dropAnimation:null,style:{pointerEvents:"none"},children:L?(0,n.jsx)(Q,{node:L}):null}),B&&(0,n.jsx)(G,{message:'Are you sure you want to delete "'.concat(B.split("/").pop(),'"? This action cannot be undone.'),onConfirm:em,onCancel:()=>F(null)}),P&&(0,n.jsx)($,{kind:P.kind,parentPath:P.parentPath,onSubmit:ef,onCancel:()=>z(null)}),(0,n.jsx)("style",{children:"\n @keyframes renameShake {\n 0%, 100% { transform: translateX(0); }\n 20%, 60% { transform: translateX(-3px); }\n 40%, 80% { transform: translateX(3px); }\n }\n"})]})}function er(e){let{target:t,onAction:r}=e,o=function(e){let t="empty"!==e.kind&&e.isSystem;return"file"===e.kind?[{action:"open",label:"Open"},{separator:!0},{action:"rename",label:"Rename",shortcut:"Enter",disabled:t},{action:"duplicate",label:"Duplicate",shortcut:"⌘D",disabled:t},{action:"copy",label:"Copy Path",shortcut:"⌘C"},{separator:!0},{action:"getInfo",label:"Get Info",shortcut:"⌘I"},{separator:!0},{action:"delete",label:"Move to Trash",shortcut:"⌘⌫",disabled:t,danger:!0}]:"folder"===e.kind?[{action:"open",label:"Open"},{separator:!0},{action:"newFile",label:"New File",shortcut:"⌘N",disabled:t},{action:"newFolder",label:"New Folder",shortcut:"⇧⌘N",disabled:t},{separator:!0},{action:"rename",label:"Rename",shortcut:"Enter",disabled:t},{action:"duplicate",label:"Duplicate",shortcut:"⌘D",disabled:t},{action:"copy",label:"Copy Path",shortcut:"⌘C"},{separator:!0},{action:"getInfo",label:"Get Info",shortcut:"⌘I"},{separator:!0},{action:"delete",label:"Move to Trash",shortcut:"⌘⌫",disabled:t,danger:!0}]:[{action:"newFile",label:"New File",shortcut:"⌘N"},{action:"newFolder",label:"New Folder",shortcut:"⇧⌘N"},{separator:!0},{action:"paste",label:"Paste",shortcut:"⌘V",disabled:!0}]}(t),l="empty"!==t.kind&&t.isSystem;return(0,n.jsxs)(v,{className:"min-w-[200px]",children:[l&&(0,n.jsxs)("div",{className:"flex items-center gap-1.5 px-3 py-1.5 text-[11px]",style:{color:"var(--color-text-muted)"},children:[(0,n.jsx)(d,{}),(0,n.jsx)("span",{children:"System file (locked)"})]}),o.map((e,t)=>"separator"in e&&e.separator?(0,n.jsx)(y,{},"sep-".concat(t)):(0,n.jsxs)(g,{variant:e.danger?"destructive":"default",disabled:e.disabled,onSelect:()=>r(e.action),children:[e.icon,(0,n.jsx)("span",{className:"flex-1",children:e.label}),e.disabled&&l&&(0,n.jsx)(d,{}),e.shortcut&&(0,n.jsx)(b,{children:e.shortcut})]},e.action))]})}var en=r(12438),eo=r(90461),el=r(13170),ea=r(50057),es=r(55283),ei=r(74788),ec=r(8565),ed=r(55662),eu=r(79907),ep=r(81067),eh=r(60216),ex=r(763),em=r(47419);function ef(e){let{...t}=e;return(0,n.jsx)(en.i,{"data-slot":"dropdown-menu",...t})}function ev(e){let{className:t,...r}=e;return(0,n.jsx)(eo.c,{"data-slot":"dropdown-menu-trigger",className:x("cursor-pointer outline-none ring-0 border-none",t),...r})}function eg(e){let{align:t="start",alignOffset:r=0,side:o="bottom",sideOffset:l=4,className:a,...s}=e;return(0,n.jsx)(el.g,{children:(0,n.jsx)(ea.y,{className:"isolate z-[10000] outline-none",align:t,alignOffset:r,side:o,sideOffset:l,children:(0,n.jsx)(es._,{"data-slot":"dropdown-menu-content",className:x("bg-neutral-100/[0.67] dark:bg-neutral-900/[0.67] border border-white dark:border-white/10 backdrop-blur-md text-[var(--color-text)] z-50 max-h-[var(--available-height)] min-h-0 min-w-[8rem] overflow-x-hidden overflow-y-auto rounded-3xl p-1 shadow-[0_0_25px_0_rgba(0,0,0,0.16)] outline-none","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a),...s})})})}function ey(e){let{className:t,inset:r,variant:o="default",onSelect:l,onClick:a,...s}=e;return(0,n.jsx)(ei.D,{"data-slot":"dropdown-menu-item","data-inset":r,"data-variant":o,className:x("bg-transparent hover:bg-neutral-400/15 text-sm transition-all relative flex cursor-pointer items-center gap-2 rounded-full px-2 py-1.5 outline-none ring-0 border-none select-none","data-[variant=destructive]:text-[var(--color-error)] data-[variant=destructive]:hover:bg-[var(--color-error)]/10 data-[variant=destructive]:hover:text-[var(--color-error)]",r&&"pl-8","[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4","data-disabled:pointer-events-none data-disabled:opacity-50",t),onClick:e=>{null==a||a(e),null==l||l()},...s})}function eb(e){let{className:t,children:r,checked:o,inset:l,...a}=e;return(0,n.jsxs)(ec.s,{"data-slot":"dropdown-menu-checkbox-item","data-inset":l,className:x("hover:bg-neutral-400/15 focus:bg-neutral-400/15 relative flex cursor-pointer items-center gap-2 rounded-full py-1.5 pr-2 pl-8 text-sm outline-none select-none transition-colors",l&&"pl-8","[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4","data-disabled:pointer-events-none data-disabled:opacity-50",t),checked:o,...a,children:[(0,n.jsx)("span",{className:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center",children:(0,n.jsx)(ed.F,{children:(0,n.jsx)(em.A,{className:"size-4"})})}),r]})}function ej(e){let{...t}=e;return(0,n.jsx)(eu.a,{"data-slot":"dropdown-menu-radio-group",...t})}function ek(e){let{className:t,children:r,inset:o,...l}=e;return(0,n.jsxs)(ep.i,{"data-slot":"dropdown-menu-radio-item","data-inset":o,className:x("hover:bg-neutral-400/15 focus:bg-neutral-400/15 relative flex cursor-pointer items-center gap-2 rounded-full py-1.5 pr-2 pl-8 text-sm outline-none select-none transition-colors",o&&"pl-8","[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4","data-disabled:pointer-events-none data-disabled:opacity-50",t),...l,children:[(0,n.jsx)("span",{className:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center",children:(0,n.jsx)(eh.p,{children:(0,n.jsx)(em.A,{className:"size-4"})})}),r]})}function ew(e){let{className:t,...r}=e;return(0,n.jsx)(ex.w,{"data-slot":"dropdown-menu-separator",className:x("bg-neutral-400/15 -mx-1 my-1 h-px",t),...r})}var eN=r(79105),eC=r(10874),eS=r(54450),eM=r(9076),eL=r(7588),eT=r(99104),eI=r(74336),eR=r(93047);function e_(e){let{...t}=e;return(0,n.jsx)(eN.D,{"data-slot":"dialog",...t})}function eE(e){let{...t}=e;return(0,n.jsx)(eC.Z,{"data-slot":"dialog-portal",...t})}function eD(e){let{className:t,...r}=e;return(0,n.jsx)(eS.X,{"data-slot":"dialog-overlay",className:x("data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 fixed inset-0 z-[10000] bg-black/30 backdrop-blur-sm duration-100",t),...r})}function eA(e){let{className:t,children:r,showCloseButton:o=!0,...l}=e;return(0,n.jsxs)(eE,{children:[(0,n.jsx)(eD,{}),(0,n.jsxs)(eM.h,{"data-slot":"dialog-content",className:x("fixed top-1/2 left-1/2 z-[10001] w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 sm:max-w-sm","grid gap-4 rounded-3xl p-5 text-sm outline-none","bg-white dark:bg-neutral-900 border border-white/10 dark:border-white/10 shadow-[0_0_25px_0_rgba(0,0,0,0.16)]","data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 duration-100",t),...l,children:[r,o&&(0,n.jsxs)(eL.H,{"data-slot":"dialog-close",className:"absolute top-3 right-3 p-1.5 rounded-full transition-all hover:bg-neutral-400/15 cursor-pointer outline-none",style:{color:"var(--color-text-muted)"},children:[(0,n.jsx)(eR.A,{className:"size-4"}),(0,n.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})}function eW(e){let{className:t,...r}=e;return(0,n.jsx)("div",{"data-slot":"dialog-header",className:x("flex flex-col gap-1.5",t),...r})}function eB(e){let{className:t,children:r,...o}=e;return(0,n.jsx)("div",{"data-slot":"dialog-footer",className:x("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...o,children:r})}function eF(e){let{className:t,...r}=e;return(0,n.jsx)(eT.L,{"data-slot":"dialog-title",className:x("text-[15px] leading-none font-semibold",t),style:{color:"var(--color-text)"},...r})}function eP(e){let{className:t,...r}=e;return(0,n.jsx)(eI.r,{"data-slot":"dialog-description",className:x("text-[13px] leading-relaxed",t),style:{color:"var(--color-text-muted)"},...r})}function ez(e){let{onWorkspaceSwitch:t,onWorkspaceDelete:r,onCreateWorkspace:l,activeWorkspaceHint:a,trigger:s}=e,[i,c]=(0,o.useState)([]),[d,u]=(0,o.useState)(null),[p,h]=(0,o.useState)(!1),[x,m]=(0,o.useState)(!1),[f,v]=(0,o.useState)(null),[g,y]=(0,o.useState)(null),[b,j]=(0,o.useState)(null),k=(0,o.useRef)(null),w=(0,o.useCallback)(async()=>{try{var e,t,r,n,o,l,a,s;let i=await fetch("/api/workspace/list"),d=await i.json(),p=(null!=(n=null!=(r=d.workspaces)?r:d.profiles)?n:[]).filter(e=>!!e.workspaceDir),h=null!=(l=null!=(o=d.activeWorkspace)?o:d.activeProfile)?l:null,x=h&&p.some(e=>e.name===h)?h:null!=(s=null!=(a=null==(e=p.find(e=>e.isActive))?void 0:e.name)?a:null==(t=p[0])?void 0:t.name)?s:null;c(p),u(x)}catch(e){}},[]);(0,o.useEffect)(()=>{w()},[w,a]),(0,o.useEffect)(()=>{function e(e){let t=e.target;if(k.current&&!k.current.contains(t)){var r;if(null==(r=t.closest)?void 0:r.call(t,'[data-slot="dropdown-menu-item"], [data-slot="dropdown-menu-content"]'))return;h(!1)}}if(p)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[p]);let N=async e=>{if(e===d)return void h(!1);j(null),m(!0);try{var r,n,o;let l=await fetch("/api/workspace/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspace:e})});if(l.ok){let e=await l.json();u(null!=(n=null!=(r=e.activeWorkspace)?r:e.activeProfile)?n:null),null==t||t(),w()}else{let e=await l.json().catch(()=>({}));j(null!=(o=e.error)?o:"Failed to switch workspace.")}}catch(e){j("Failed to switch workspace.")}finally{m(!1),h(!1)}},C=async e=>{j(null),v(e),y(null);try{let o=await fetch("/api/workspace/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspace:e})});if(!o.ok){var n;let t=await o.json().catch(()=>({}));j(null!=(n=t.error)?n:"Failed to delete workspace '".concat(e,"'."));return}e===d&&(null==t||t()),null==r||r(e),await w()}catch(t){j("Failed to delete workspace '".concat(e,"'."))}finally{v(null)}},S=i.length>0,M=()=>{S&&h(e=>!e)};return s||S?(0,n.jsxs)("div",{className:"relative ".concat(s?"flex-1 min-w-0":""),ref:k,children:[s?s({isOpen:p,onClick:M,activeWorkspace:d,switching:x}):(0,n.jsxs)("button",{onClick:M,disabled:x,className:"flex items-center gap-1.5 px-2 py-1 rounded-md text-xs transition-colors hover:bg-[var(--color-surface-hover)] disabled:opacity-50",style:{color:"var(--color-text-secondary)"},title:"Switch workspace",children:[(0,n.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"})}),(0,n.jsx)("span",{className:"truncate max-w-[120px]",children:null!=d?d:"No workspace"}),(0,n.jsx)("svg",{className:"w-3 h-3 transition-transform ".concat(p?"rotate-180":""),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),S&&p&&(0,n.jsxs)("div",{className:"absolute left-0 top-full mt-1.5 w-64 rounded-2xl overflow-hidden z-50 p-1 bg-neutral-100/[0.67] dark:bg-neutral-900/[0.67] border border-white dark:border-white/10 backdrop-blur-md shadow-[0_0_25px_0_rgba(0,0,0,0.16)]",children:[(0,n.jsx)("div",{className:"px-2.5 py-1.5 text-[11px] font-medium",style:{color:"var(--color-text-muted)"},children:"Workspaces"}),(0,n.jsx)("div",{className:"max-h-64 overflow-y-auto",children:i.map(e=>{let t=e.name===d;return(0,n.jsxs)("div",{className:"group flex items-center rounded-xl transition-all hover:bg-neutral-400/15 cursor-pointer",onClick:()=>void N(e.name),style:{color:"var(--color-text)"},children:[(0,n.jsxs)("div",{className:"flex-1 min-w-0 flex items-center gap-2 px-2.5 py-1.5",children:[(0,n.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{background:t?"var(--color-success)":"transparent",border:t?"none":"1px solid var(--color-border-strong)"}}),(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsx)("span",{className:"truncate font-medium text-[13px] block",children:e.name}),(0,n.jsx)("span",{className:"text-[11px] truncate block mt-0.5",style:{color:"var(--color-text-muted)"},children:e.workspaceDir?e.workspaceDir.replace(/^\/Users\/[^/]+/,"~").replace(/^\/home\/[^/]+/,"~").replace(/^[A-Za-z]:[/\\]Users[/\\][^/\\]+/,"~"):"No workspace yet"})]}),t&&(0,n.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full shrink-0 bg-neutral-400/15",style:{color:"var(--color-text-muted)"},children:"Active"})]}),e.workspaceDir&&(0,n.jsxs)(ef,{children:[(0,n.jsx)(ev,{onClick:e=>e.stopPropagation(),className:"p-1 mr-1 rounded-lg transition-all opacity-0 group-hover:opacity-100 hover:bg-neutral-400/25 shrink-0 cursor-pointer",style:{color:"var(--color-text-muted)"},children:(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("circle",{cx:"12",cy:"5",r:"1"}),(0,n.jsx)("circle",{cx:"12",cy:"12",r:"1"}),(0,n.jsx)("circle",{cx:"12",cy:"19",r:"1"})]})}),(0,n.jsx)(eg,{side:"right",align:"start",sideOffset:4,className:"min-w-[140px]",children:(0,n.jsxs)(ey,{variant:"destructive",onSelect:()=>y(e.name),children:[(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M3 6h18"}),(0,n.jsx)("path",{d:"M8 6V4h8v2"}),(0,n.jsx)("path",{d:"M19 6l-1 14H6L5 6"})]}),"Delete"]})})]})]},e.name)})}),b&&(0,n.jsx)("p",{className:"mx-2 mb-1 mt-1 rounded-xl px-2.5 py-1.5 text-xs",style:{background:"rgba(220, 38, 38, 0.08)",color:"var(--color-error)"},children:b}),(0,n.jsx)("div",{className:"border-t border-neutral-400/15 mt-0.5 pt-0.5",children:(0,n.jsxs)("button",{onClick:()=>{h(!1),null==l||l()},className:"w-full flex items-center gap-2 px-2.5 py-1.5 text-sm rounded-xl transition-all hover:bg-neutral-400/15 cursor-pointer",style:{color:"var(--color-accent)"},children:[(0,n.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M12 5v14"}),(0,n.jsx)("path",{d:"M5 12h14"})]}),"New Workspace"]})})]}),(0,n.jsx)(e_,{open:!!g,onOpenChange:e=>{e||y(null)},children:(0,n.jsxs)(eA,{showCloseButton:!1,children:[(0,n.jsxs)(eW,{children:[(0,n.jsx)(eF,{children:"Delete workspace"}),(0,n.jsxs)(eP,{children:["This will permanently delete ",(0,n.jsx)("strong",{style:{color:"var(--color-text)"},children:g})," and all its data. This cannot be undone."]})]}),(0,n.jsxs)(eB,{children:[(0,n.jsx)("button",{onClick:()=>y(null),className:"px-3 py-1.5 text-[13px] rounded-full transition-all hover:bg-neutral-400/15 cursor-pointer",style:{color:"var(--color-text-muted)"},children:"Cancel"}),(0,n.jsx)("button",{onClick:()=>{g&&C(g)},disabled:!!f,className:"px-3 py-1.5 text-[13px] font-medium rounded-full transition-all hover:opacity-80 disabled:opacity-50 cursor-pointer",style:{background:"var(--color-error)",color:"#fff"},children:f===g?"Deleting...":"Delete"})]})]})})]}):null}function eO(e){let{isOpen:t,onClose:r,onCreated:l}=e,[a,s]=(0,o.useState)(""),[i,c]=(0,o.useState)(!0),[d,u]=(0,o.useState)(!1),[p,h]=(0,o.useState)(null),[x,m]=(0,o.useState)(null),f=(0,o.useRef)(null);(0,o.useEffect)(()=>{t&&(s(""),h(null),m(null),setTimeout(()=>{var e;return null==(e=f.current)?void 0:e.focus()},100))},[t]);let v=async()=>{let e=a.trim();if(!e)return void h("Please enter a workspace name.");if(!/^[a-zA-Z0-9_-]+$/.test(e))return void h("Name must use only letters, numbers, hyphens, or underscores.");u(!0),h(null);try{var t;let r=await fetch("/api/workspace/init",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspace:e,seedBootstrap:i})}),n=await r.json();if(!r.ok)return void h(n.error||"Failed to create workspace.");m({workspaceDir:n.workspaceDir,seededFiles:null!=(t=n.seededFiles)?t:[]}),null==l||l()}catch(e){h(e.message)}finally{u(!1)}};return(0,n.jsx)(e_,{open:t,onOpenChange:e=>{e||r()},children:(0,n.jsx)(eA,{showCloseButton:!x,className:"sm:max-w-md",children:x?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"text-center py-4",children:[(0,n.jsx)("div",{className:"w-12 h-12 rounded-full flex items-center justify-center mx-auto mb-3",style:{background:"rgba(22, 163, 74, 0.1)"},children:(0,n.jsx)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"#16a34a",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"M20 6 9 17l-5-5"})})}),(0,n.jsx)("p",{className:"text-sm font-medium",style:{color:"var(--color-text)"},children:"Workspace created"}),(0,n.jsx)("code",{className:"text-xs px-2 py-1 rounded mt-2 inline-block",style:{background:"var(--color-surface-hover)",color:"var(--color-text-secondary)",border:"1px solid var(--color-border)"},children:x.workspaceDir.replace(/^\/Users\/[^/]+/,"~").replace(/^\/home\/[^/]+/,"~").replace(/^[A-Za-z]:[/\\]Users[/\\][^/\\]+/,"~")}),x.seededFiles.length>0&&(0,n.jsxs)("p",{className:"text-xs mt-2",style:{color:"var(--color-text-muted)"},children:["Seeded: ",x.seededFiles.join(", ")]})]}),(0,n.jsx)(eB,{children:(0,n.jsx)("button",{onClick:r,className:"px-4 py-2 text-sm font-medium rounded-lg transition-colors hover:opacity-80 cursor-pointer",style:{background:"var(--color-accent)",color:"#fff"},children:"Done"})})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(eW,{children:(0,n.jsx)(eF,{children:"New Workspace"})}),(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"block text-sm font-medium mb-1.5",style:{color:"var(--color-text-secondary)"},children:"Workspace name"}),(0,n.jsx)("input",{ref:f,type:"text",value:a,onChange:e=>{s(e.target.value),h(null)},onKeyDown:e=>{"Enter"!==e.key||d||v()},placeholder:"e.g. work, personal, project-x",className:"w-full px-3 py-2 text-sm rounded-lg focus:outline-none focus:ring-2 focus:ring-[var(--color-accent)]",style:{background:"var(--color-bg)",border:"1px solid var(--color-border)",color:"var(--color-text)"}}),(0,n.jsxs)("p",{className:"text-xs mt-1",style:{color:"var(--color-text-muted)"},children:["This creates a workspace under ~/.openclaw-dench/workspace-","{name}","."]})]}),(0,n.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer hidden",children:[(0,n.jsx)("input",{type:"checkbox",checked:i,onChange:e=>c(e.target.checked),className:"rounded",style:{accentColor:"var(--color-accent)"}}),(0,n.jsx)("span",{className:"text-sm",style:{color:"var(--color-text-secondary)"},children:"Seed bootstrap files and workspace database"})]}),p&&(0,n.jsx)("p",{className:"text-sm px-3 py-2 rounded-lg",style:{background:"rgba(220, 38, 38, 0.08)",color:"var(--color-error)"},children:p})]}),(0,n.jsxs)(eB,{children:[(0,n.jsx)("button",{onClick:r,className:"px-3 py-1.5 text-[13px] rounded-full transition-all hover:bg-neutral-400/15 cursor-pointer",style:{color:"var(--color-text-muted)"},children:"Cancel"}),(0,n.jsx)("button",{onClick:()=>void v(),disabled:d||!a.trim(),className:"px-4 py-2 text-sm font-medium rounded-full transition-colors hover:opacity-80 disabled:opacity-50 cursor-pointer",style:{background:"var(--color-accent)",color:"#fff"},children:d?"Creating...":"Create Workspace"})]})]})})})}var eU=r(395);function eH(){return(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"m3 9 9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"}),(0,n.jsx)("polyline",{points:"9 22 9 12 15 12 15 22"})]})}function eV(){return(0,n.jsx)("img",{src:"/icons/folder-open.png",alt:"",width:20,height:20,draggable:!1,style:{flexShrink:0}})}function eK(){let{resolvedTheme:e,setTheme:t}=(0,i.D)(),[r,l]=(0,o.useState)(!1);if((0,o.useEffect)(()=>l(!0),[]),!r)return(0,n.jsx)("div",{className:"w-[28px] h-[28px]"});let a="dark"===e;return(0,n.jsx)("button",{type:"button",onClick:()=>t(a?"light":"dark"),className:"p-1.5 rounded-lg",style:{color:"var(--color-text-muted)"},title:a?"Switch to light mode":"Switch to dark mode",children:a?(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"4"}),(0,n.jsx)("path",{d:"M12 2v2"}),(0,n.jsx)("path",{d:"M12 20v2"}),(0,n.jsx)("path",{d:"m4.93 4.93 1.41 1.41"}),(0,n.jsx)("path",{d:"m17.66 17.66 1.41 1.41"}),(0,n.jsx)("path",{d:"M2 12h2"}),(0,n.jsx)("path",{d:"M20 12h2"}),(0,n.jsx)("path",{d:"m6.34 17.66-1.41 1.41"}),(0,n.jsx)("path",{d:"m19.07 4.93-1.41 1.41"})]}):(0,n.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"})})})}function eJ(){return(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,n.jsx)("path",{d:"m21 21-4.3-4.3"})]})}function eq(){return(0,n.jsx)("img",{src:"/icons/folder.png",alt:"",width:14,height:14,draggable:!1,style:{flexShrink:0}})}function eG(){return(0,n.jsx)("img",{src:"/icons/document.png",alt:"",width:14,height:14,draggable:!1,style:{flexShrink:0,filter:"drop-shadow(0 0.5px 1.5px rgba(0,0,0,0.2))"}})}function e$(){return(0,n.jsx)("img",{src:"/icons/document.png",alt:"",width:14,height:14,draggable:!1,style:{flexShrink:0,filter:"drop-shadow(0 0.5px 1.5px rgba(0,0,0,0.2))"}})}function eZ(){return(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("ellipse",{cx:"12",cy:"5",rx:"9",ry:"3"}),(0,n.jsx)("path",{d:"M3 5V19A9 3 0 0 0 21 19V5"}),(0,n.jsx)("path",{d:"M3 12A9 3 0 0 0 21 12"})]})}function eY(e){let{type:t}=e;switch(t){case"folder":return(0,n.jsx)(eq,{});case"document":return(0,n.jsx)(e$,{});case"database":return(0,n.jsx)(eZ,{});default:return(0,n.jsx)(eG,{})}}function eQ(e){let{onSelect:t}=e,[r,l]=(0,o.useState)(""),[a,s]=(0,o.useState)([]),[i,c]=(0,o.useState)(!1),[d,u]=(0,o.useState)(!1),[p,h]=(0,o.useState)(0),x=(0,o.useRef)(null),m=(0,o.useRef)(null);(0,o.useEffect)(()=>{if(!r.trim()){s([]),c(!1);return}u(!0);let e=setTimeout(async()=>{try{var e;let t=await fetch("/api/workspace/suggest-files?q=".concat(encodeURIComponent(r.trim()))),n=await t.json();s(null!=(e=n.items)?e:[]),c(!0),h(0)}catch(e){s([])}finally{u(!1)}},150);return()=>clearTimeout(e)},[r]),(0,o.useEffect)(()=>{function e(e){m.current&&!m.current.contains(e.target)&&c(!1)}return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);let f=(0,o.useCallback)(e=>{var r,n;"ArrowDown"===e.key?(e.preventDefault(),h(e=>Math.min(e+1,a.length-1))):"ArrowUp"===e.key?(e.preventDefault(),h(e=>Math.max(e-1,0))):"Enter"===e.key&&a[p]?(e.preventDefault(),t(a[p]),l(""),c(!1),null==(r=x.current)||r.blur()):"Escape"===e.key&&(c(!1),l(""),null==(n=x.current)||n.blur())},[a,p,t]),v=(0,o.useCallback)(e=>{t(e),l(""),c(!1)},[t]);return(0,n.jsxs)("div",{ref:m,className:"relative",children:[(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsx)("span",{className:"absolute left-2.5 top-1/2 -translate-y-1/2 pointer-events-none",style:{color:"var(--color-text-muted)"},children:(0,n.jsx)(eJ,{})}),(0,n.jsx)("input",{ref:x,type:"text",value:r,onChange:e=>l(e.target.value),onKeyDown:f,onFocus:()=>{a.length>0&&c(!0)},placeholder:"Search files...",className:"w-full pl-8 pr-3 py-1.5 rounded-lg text-xs outline-none transition-colors",style:{background:"var(--color-bg)",color:"var(--color-text)",border:"1px solid var(--color-border)"}}),d&&(0,n.jsx)("span",{className:"absolute right-2.5 top-1/2 -translate-y-1/2",children:(0,n.jsx)(eU.V,{name:"braille",className:"text-sm",style:{color:"var(--color-text-muted)"}})})]}),i&&a.length>0&&(0,n.jsx)("div",{className:"absolute left-0 right-0 mt-1 rounded-lg shadow-lg border overflow-hidden z-50 max-h-[300px] overflow-y-auto",style:{background:"var(--color-surface)",borderColor:"var(--color-border)"},children:a.map((e,t)=>(0,n.jsxs)("button",{type:"button",onClick:()=>v(e),className:"w-full flex items-center gap-2 px-3 py-2 text-left text-xs cursor-pointer transition-colors",style:{background:t===p?"var(--color-surface-hover)":"transparent",color:"var(--color-text)"},onMouseEnter:()=>h(t),children:[(0,n.jsx)("span",{className:"flex-shrink-0",style:{color:"var(--color-text-muted)"},children:(0,n.jsx)(eY,{type:e.type})}),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsx)("div",{className:"truncate font-medium",children:e.name}),(0,n.jsx)("div",{className:"truncate",style:{color:"var(--color-text-muted)",fontSize:"10px"},children:e.path.split("/").slice(0,-1).join("/")})]}),(0,n.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full flex-shrink-0 capitalize",style:{background:"var(--color-surface-hover)",color:"var(--color-text-muted)"},children:e.type})]},e.path))}),i&&r.trim()&&!d&&0===a.length&&(0,n.jsx)("div",{className:"absolute left-0 right-0 mt-1 rounded-lg shadow-lg border z-50 px-3 py-3 text-center",style:{background:"var(--color-surface)",borderColor:"var(--color-border)"},children:(0,n.jsx)("p",{className:"text-xs",style:{color:"var(--color-text-muted)"},children:"No files found"})})]})}function eX(e){let{tree:t,activePath:r,onSelect:l,onRefresh:i,orgName:c,loading:d,browseDir:u,parentDir:p,onNavigateUp:h,onGoHome:x,onFileSearchSelect:m,workspaceRoot:f,onGoToChat:v,onExternalDrop:g,mobile:y,onClose:b,showHidden:j,onToggleHidden:k,width:w,onCollapse:N,activeWorkspace:C,onWorkspaceChanged:S,chatSessions:M,activeChatSessionId:L,activeChatSessionTitle:T,chatStreamingSessionIds:I,chatSubagents:R,chatActiveSubagentKey:_,chatSessionsLoading:E,onSelectChatSession:D,onNewChatSession:A,onSelectChatSubagent:W,onDeleteChatSession:B,onRenameChatSession:F,activeTab:P,onTabChange:z,onNavigate:O}=e,U=null!=u,H=y?"280px":null!=w?w:260,[V,K]=(0,o.useState)(!1),[J,q]=(0,o.useState)(null!=P?P:"files");(0,o.useCallback)(e=>{q(e),null==z||z(e)},[z]);let G=(0,n.jsxs)("aside",{className:"flex flex-col h-screen shrink-0 ".concat(y?"drawer-left":"border-r"),style:{width:"number"==typeof H?"".concat(H,"px"):H,minWidth:"number"==typeof H?"".concat(H,"px"):H,background:"var(--color-bg)",borderColor:"var(--color-border)"},children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 px-3 h-[36px] border-b",style:{borderColor:"var(--color-border)"},children:[U?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"flex-1 min-w-0 flex items-center gap-1.5",children:[(0,n.jsx)("span",{className:"shrink-0",style:{color:"var(--color-text-muted)"},children:(0,n.jsx)(eV,{})}),(0,n.jsx)("span",{className:"text-[12px] font-medium truncate",style:{color:"var(--color-text)"},title:u,children:"/"===u?"/":u.split("/").pop()||u})]}),x&&(0,n.jsx)("button",{type:"button",onClick:x,className:"p-1 rounded-md shrink-0 transition-colors hover:bg-stone-200 dark:hover:bg-stone-700",style:{color:"var(--color-text-muted)"},title:"Return to workspace",children:(0,n.jsx)(eH,{})})]}):(0,n.jsx)(n.Fragment,{children:(0,n.jsx)("div",{className:"flex-1 min-w-0",children:(0,n.jsx)(ez,{activeWorkspaceHint:null!=C?C:null,onWorkspaceSwitch:()=>{null==S||S()},onWorkspaceDelete:()=>{null==S||S()},onCreateWorkspace:()=>{K(!0)},trigger:e=>{let{onClick:t,activeWorkspace:r,switching:o}=e;return(0,n.jsxs)("button",{type:"button",onClick:t,disabled:o,className:"group/ws text-[12px] flex items-center gap-1.5 truncate w-full transition-colors font-medium rounded-md px-1.5 py-1 -mx-1.5 hover:bg-stone-200/60 dark:hover:bg-stone-700/60",style:{color:"var(--color-text)"},title:"Switch workspace",children:[(0,n.jsx)("span",{className:"truncate",children:c||"Workspace"}),(0,n.jsx)("span",{className:"flex-1"}),(0,n.jsx)("span",{className:"px-1 py-px rounded text-[10px] leading-tight shrink-0 bg-stone-200 text-stone-600 dark:bg-stone-700 dark:text-stone-300",children:r||"-"}),(0,n.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",style:{color:"var(--color-text-muted)"},children:(0,n.jsx)("path",{d:"m6 9 6 6 6-6"})})]})}})})}),N&&(0,n.jsx)("button",{type:"button",onClick:N,className:"p-1 rounded-md shrink-0 transition-colors hover:bg-stone-200 dark:hover:bg-stone-700",style:{color:"var(--color-text-muted)"},title:"Hide sidebar (⌘B)",children:(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),(0,n.jsx)("path",{d:"M9 3v18"})]})})]}),m&&(0,n.jsx)("div",{className:"px-3 pt-2 pb-1",children:(0,n.jsx)(eQ,{onSelect:m})}),(0,n.jsx)("div",{className:"flex-1 overflow-y-auto px-1",children:d?(0,n.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,n.jsx)(eU.V,{name:"braille",className:"text-2xl",style:{color:"var(--color-text-muted)"}})}):(0,n.jsx)(et,{tree:t,activePath:r,onSelect:l,onRefresh:i,parentDir:p,onNavigateUp:h,browseDir:u,workspaceRoot:f,onExternalDrop:g})}),O&&(0,n.jsx)("div",{className:"px-2 py-1.5 border-t space-y-0.5",style:{borderColor:"var(--color-border)"},children:[{id:"cloud",label:"Cloud",icon:(0,n.jsx)("svg",{className:"h-4 w-4 shrink-0",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:(0,n.jsx)("path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z"})})},{id:"integrations",label:"Integrations",icon:(0,n.jsx)(s.qX3,{className:"h-4 w-4 shrink-0","aria-hidden":!0})},{id:"skills",label:"Skills",icon:(0,n.jsx)(a.abJ,{className:"h-4 w-4 shrink-0","aria-hidden":!0})},{id:"cron",label:"Cron",icon:(0,n.jsxs)("svg",{className:"h-4 w-4 shrink-0",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,n.jsx)("polyline",{points:"12 6 12 12 16 14"})]})}].map(e=>(0,n.jsxs)("button",{type:"button",onClick:()=>O(e.id),className:"w-full flex items-center gap-2.5 px-2 py-1.5 rounded-lg text-sm font-medium transition-colors hover:bg-stone-200/60 dark:hover:bg-stone-700/60 hover:[color:var(--color-text)]",style:{color:"var(--color-text-secondary)"},children:[(0,n.jsx)("span",{className:"shrink-0",children:e.icon}),e.label]},e.id))}),(0,n.jsxs)("div",{className:"px-3 py-2.5 border-t flex items-center justify-between",style:{borderColor:"var(--color-border)"},children:[(0,n.jsxs)("a",{href:"https://dench.com",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 px-2 py-1.5 rounded-lg text-sm",style:{color:"var(--color-text-muted)"},children:["dench.com"," (v".concat("2.5.4",")")]}),(0,n.jsxs)("div",{className:"flex items-center gap-0.5",children:[k&&(0,n.jsx)("button",{type:"button",onClick:k,className:"p-1.5 rounded-lg transition-colors",style:{color:j?"var(--color-accent)":"var(--color-text-muted)"},title:j?"Hide dotfiles":"Show dotfiles",children:(0,n.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:j?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"}),(0,n.jsx)("circle",{cx:"12",cy:"12",r:"3"})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49"}),(0,n.jsx)("path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242"}),(0,n.jsx)("path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143"}),(0,n.jsx)("path",{d:"m2 2 20 20"})]})})}),(0,n.jsx)(eK,{})]})]})]});return y?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"drawer-backdrop",onClick:()=>void(null==b||b()),children:(0,n.jsx)("div",{onClick:e=>e.stopPropagation(),className:"fixed inset-y-0 left-0 z-50",children:G})}),(0,n.jsx)(eO,{isOpen:V,onClose:()=>K(!1),onCreated:()=>{null==S||S()}})]}):(0,n.jsxs)(n.Fragment,{children:[G,(0,n.jsx)(eO,{isOpen:V,onClose:()=>K(!1),onCreated:()=>{null==S||S()}})]})}var e0=r(50890),e1=r(76552),e2=r(42282),e4=r(24285),e5=r(98832);function e3(e){let{src:t,className:r}=e;return(0,n.jsx)("img",{src:t,alt:"","aria-hidden":"true",className:null!=r?r:"w-4 h-4 rounded-[4px] shrink-0"})}function e6(e,t,r){return(0,e5.IL)(e.getValue(t),r).passed}function e8(e){let{id:t,children:r,style:o,className:l}=e,{attributes:a,listeners:s,setNodeRef:i,transform:c,transition:d,isDragging:u}=(0,e2.gl)({id:t}),p={...o,transform:e4.Ks.Translate.toString(c),transition:d,opacity:u?.5:1};return(0,n.jsx)("th",{ref:i,style:p,className:l,...a,children:r(s)})}function e7(e){let{direction:t}=e;return t?(0,n.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:"asc"===t?(0,n.jsx)("path",{d:"m5 12 7-7 7 7"}):(0,n.jsx)("path",{d:"m19 12-7 7-7-7"})}):(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{opacity:.25},children:[(0,n.jsx)("path",{d:"m7 15 5 5 5-5"}),(0,n.jsx)("path",{d:"m7 9 5-5 5 5"})]})}function e9(e){let{columns:t,data:r,loading:l=!1,searchPlaceholder:a="Search...",enableGlobalFilter:s=!0,enableSorting:i=!0,enableRowSelection:d=!1,rowSelection:u,onRowSelectionChange:p,bulkActions:h,enableColumnReordering:m=!1,onColumnReorder:f,initialColumnVisibility:v,onColumnVisibilityChanged:g,initialColumnSizing:y,onColumnSizingChange:b,pageSize:j=100,onRefresh:k,onAdd:w,addButtonLabel:N="+ Add",onRowClick:C,getFirstDataColumnFaviconUrl:S,rowActions:M,toolbarExtra:L,title:T,titleIcon:I,stickyFirstColumn:R=!0,activeRowId:_,getRowId:E,serverPagination:D,onServerSearch:A}=e,[W,B]=(0,o.useState)([]),[F,P]=(0,o.useState)(""),[z,O]=(0,o.useState)([]),[U,H]=(0,o.useState)(null!=v?v:{}),[V,K]=(0,o.useState)(null!=y?y:{});(0,o.useEffect)(()=>{H(null!=v?v:{})},[v]),(0,o.useEffect)(()=>{K(null!=y?y:{})},[y]);let[J,q]=(0,o.useState)({}),[G,$]=(0,o.useState)(R),[Z,Y]=(0,o.useState)(!1),[Q,X]=(0,o.useState)({pageIndex:0,pageSize:j}),ee=(0,o.useRef)(null),et=void 0!==u?u:J,er=(0,o.useCallback)(e=>"id"in e&&"string"==typeof e.id?e.id:"accessorKey"in e&&"string"==typeof e.accessorKey?e.accessorKey:"",[]),en=(0,o.useCallback)(e=>{let t=e.map(er),r=[];return d&&r.push("select"),r.push(...t),M&&r.push("actions"),r},[er,d,M]),[eo,el]=(0,o.useState)(()=>en(t)),ea=new Set(["select","actions","__add_column"]);(0,o.useEffect)(()=>{el(e=>{let r=en(t),n=new Set(r),o=new Set(r.filter(e=>!ea.has(e))),l=e.filter(e=>!ea.has(e)&&o.has(e)),a=new Set(l);for(let e of o)a.has(e)||l.push(e);let s=[];return(n.has("select")&&s.push("select"),s.push(...l),n.has("actions")&&s.push("actions"),n.has("__add_column")&&s.push("__add_column"),s.length===e.length&&s.every((t,r)=>t===e[r]))?e:s})},[t,en]);let es=(0,c.FR)((0,c.MS)(c.AN,{activationConstraint:{distance:5}})),ei=(0,o.useCallback)(e=>{let{active:t,over:r}=e;r&&t.id!==r.id&&el(e=>{let n=e.indexOf(t.id),o=e.indexOf(r.id),l=(0,e2.be)(e,n,o);return null==f||f(l),l})},[f]),ec=(0,o.useCallback)(e=>{Y(e.currentTarget.scrollLeft>0)},[]),ed=d?{id:"select",header:e=>{let{table:t}=e;return(0,n.jsx)("input",{type:"checkbox",checked:t.getIsAllPageRowsSelected(),onChange:t.getToggleAllPageRowsSelectedHandler(),className:"w-3.5 h-3.5 rounded accent-[var(--color-accent)] cursor-pointer"})},cell:e=>{let{row:t}=e;return(0,n.jsx)("input",{type:"checkbox",checked:t.getIsSelected(),onChange:t.getToggleSelectedHandler(),onClick:e=>e.stopPropagation(),className:"w-3.5 h-3.5 rounded accent-[var(--color-accent)] cursor-pointer"})},size:40,minSize:40,enableSorting:!1,enableHiding:!1}:null,eu=M?{id:"actions",header:()=>null,cell:e=>{let{row:t}=e;return(0,n.jsx)(tr,{row:t.original,actions:M(t.original)})},size:48,minSize:48,enableSorting:!1,enableHiding:!1}:null,ep=(0,o.useMemo)(()=>{let e=[];return ed&&e.push(ed),e.push(...t),eu&&e.push(eu),e},[t,ed,eu]),eh=D?{pageIndex:D.page-1,pageSize:D.pageSize}:void 0,ex=(0,o.useRef)(null),em=(0,e0.N4)({data:r,columns:ep,state:{sorting:W,globalFilter:F,columnFilters:z,columnVisibility:U,columnSizing:V,rowSelection:et,columnOrder:m?eo:void 0,pagination:null!=eh?eh:Q},onSortingChange:B,onGlobalFilterChange:P,onColumnFiltersChange:O,onColumnVisibilityChange:e=>{let t="function"==typeof e?e(U):e;H(t),null==g||g(t)},onColumnSizingChange:e=>{let t="function"==typeof e?e(V):e;K(t),ex.current&&clearTimeout(ex.current),ex.current=setTimeout(()=>null==b?void 0:b(t),500)},onRowSelectionChange:e=>{p?p(e):q(e)},onPaginationChange:D?e=>{let t="function"==typeof e?e(eh):e;t.pageSize!==D.pageSize?D.onPageSizeChange(t.pageSize):t.pageIndex!==D.page-1&&D.onPageChange(t.pageIndex+1)}:X,getCoreRowModel:(0,e1.HT)(),getSortedRowModel:i?(0,e1.h5)():void 0,getFilteredRowModel:D?void 0:(0,e1.hM)(),getPaginationRowModel:D?void 0:(0,e1.kW)(),...D?{manualPagination:!0,pageCount:Math.ceil(D.totalCount/D.pageSize)}:{},enableRowSelection:d,enableSorting:i,globalFilterFn:e6,columnResizeMode:"onChange",defaultColumn:{minSize:150}}),ey=Object.keys(et).filter(e=>et[e]).length,ej=em.getVisibleFlatColumns().filter(e=>"select"!==e.id&&"actions"!==e.id&&"__add_column"!==e.id),ek=(0,o.useMemo)(()=>{let e=em.getFlatHeaders(),t={};for(let r of e)t["--header-".concat(r.id,"-size")]=r.getSize(),t["--col-".concat(r.column.id,"-size")]=r.column.getSize();return t},[em.getState().columnSizingInfo,em.getState().columnSizing]);return(0,n.jsxs)("div",{className:"w-full h-full flex flex-col overflow-hidden",style:{overscrollBehavior:"contain"},children:[(0,n.jsxs)("div",{className:"flex items-center gap-3 px-3 py-2 shrink-0 flex-wrap backdrop-blur-md",style:{background:"var(--color-glass)",borderBottom:"1px solid var(--color-border)"},children:[T&&(0,n.jsxs)("div",{className:"flex items-center gap-2 mr-1",children:[I,(0,n.jsx)("span",{className:"text-xs font-semibold",style:{color:"var(--color-text)"},children:T})]}),s&&(0,n.jsxs)("div",{className:"flex items-center gap-2 h-8 px-3 backdrop-blur-sm rounded-full focus-within:ring-2 focus-within:ring-(--color-accent)/30 transition-shadow max-w-[260px] min-w-[140px] shadow-[0_0_21px_0_rgba(0,0,0,0.05)]",style:{border:"1px solid var(--color-border)",background:"var(--color-surface)"},children:[(0,n.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",style:{color:"var(--color-text-muted)",opacity:.5},children:[(0,n.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,n.jsx)("path",{d:"m21 21-4.3-4.3"})]}),(0,n.jsx)("input",{type:"text",value:F,onChange:e=>{P(e.target.value),null==A||A(e.target.value)},placeholder:a,className:"w-full h-full text-xs bg-transparent outline-none border-0 p-0",style:{color:"var(--color-text)"}}),F&&(0,n.jsx)("button",{type:"button",onClick:()=>{P(""),null==A||A("")},className:"shrink-0 h-5 w-5 rounded-full flex items-center justify-center cursor-pointer transition-colors",style:{color:"var(--color-text-muted)"},children:(0,n.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("path",{d:"M18 6 6 18"}),(0,n.jsx)("path",{d:"m6 6 12 12"})]})})]}),ey>0&&h&&(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsxs)("span",{className:"text-xs font-medium",style:{color:"var(--color-text-muted)"},children:[ey," selected"]}),h]}),(0,n.jsx)("div",{className:"flex-1"}),L,(0,n.jsxs)(ef,{children:[(0,n.jsxs)(ev,{className:"h-8 px-3 flex items-center gap-1.5 rounded-full text-xs cursor-pointer transition-colors backdrop-blur-sm shadow-[0_0_21px_0_rgba(0,0,0,0.05)] outline-none focus:outline-none",style:{color:"var(--color-text-muted)",border:"1px solid var(--color-border)",background:"var(--color-surface)"},children:[(0,n.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),(0,n.jsx)("path",{d:"M9 3v18"}),(0,n.jsx)("path",{d:"M15 3v18"})]}),"Columns"]}),(0,n.jsxs)(eg,{align:"end",sideOffset:6,children:[(0,n.jsx)(eb,{checked:G,onSelect:()=>$(e=>!e),children:"Freeze first column"}),(0,n.jsx)(ew,{}),0===ej.length?(0,n.jsx)("div",{className:"px-2 py-1.5 text-xs opacity-50",children:"No toggleable columns"}):em.getAllLeafColumns().filter(e=>"select"!==e.id&&"actions"!==e.id&&"__add_column"!==e.id&&e.getCanHide()).map(e=>{var t,r;return(0,n.jsx)(eb,{checked:e.getIsVisible(),onSelect:()=>e.toggleVisibility(!e.getIsVisible()),children:"string"==typeof e.columnDef.header?e.columnDef.header:String(null!=(r=null==(t=e.columnDef.meta)?void 0:t.label)?r:e.id)},e.id)})]})]}),k&&(0,n.jsx)("button",{type:"button",onClick:k,className:"h-8 w-8 rounded-full flex items-center justify-center cursor-pointer transition-colors backdrop-blur-sm shadow-[0_0_21px_0_rgba(0,0,0,0.05)]",style:{border:"1px solid var(--color-border)",background:"var(--color-surface)",color:"var(--color-text-muted)"},children:(0,n.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),(0,n.jsx)("path",{d:"M3 3v5h5"}),(0,n.jsx)("path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16"}),(0,n.jsx)("path",{d:"M16 21h5v-5"})]})}),w&&(0,n.jsx)("button",{type:"button",onClick:w,className:"h-8 px-3 flex items-center gap-1.5 rounded-full text-xs font-medium cursor-pointer transition-colors shadow-[0_0_21px_0_rgba(0,0,0,0.05)]",style:{background:"var(--color-accent)",color:"#fff"},children:N})]}),(0,n.jsx)("div",{ref:ee,className:"overflow-auto flex-1 min-h-0 max-h-full relative",onScroll:ec,style:{overscrollBehavior:"contain"},children:l?(0,n.jsx)(tn,{columnCount:ep.length}):0===r.length?(0,n.jsxs)("div",{className:"flex flex-col items-center justify-center py-24 gap-4",children:[(0,n.jsx)("div",{className:"rounded-full p-4 mb-2 backdrop-blur-sm",style:{background:"var(--color-glass)",border:"1px solid var(--color-border)",boxShadow:"var(--shadow-sm)"},children:(0,n.jsxs)("svg",{width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",style:{color:"var(--color-text-muted)"},children:[(0,n.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,n.jsx)("path",{d:"m21 21-4.3-4.3"})]})}),(0,n.jsxs)("div",{className:"text-center",children:[(0,n.jsx)("h3",{className:"text-base font-semibold mb-1",style:{color:"var(--color-text)"},children:"No results found"}),(0,n.jsx)("p",{className:"text-sm max-w-xs",style:{color:"var(--color-text-muted)"},children:F?"Try adjusting your search or filter criteria.":"No data available yet. Create your first entry to get started."})]})]}):(0,n.jsx)(c.Mp,{sensors:es,collisionDetection:c.fp,onDragEnd:ei,children:(0,n.jsxs)("table",{className:"w-full caption-bottom text-sm",style:{...ek,tableLayout:"fixed",minWidth:em.getTotalSize()},children:[(0,n.jsx)("thead",{className:"[&_tr]:border-b sticky top-0 z-30",style:{background:"var(--color-surface)"},children:em.getHeaderGroups().map(e=>(0,n.jsx)("tr",{style:{borderColor:"var(--color-border)"},className:"border-b-2 backdrop-blur-sm",children:(0,n.jsx)(e2.gB,{items:eo.filter(e=>!ea.has(e)),strategy:e2.m$,children:e.headers.map((t,r)=>{let o=r===+!!d,l=G&&o,a="select"===t.id,s="actions"===t.id,i="__add_column"===t.id,c=t.column.getCanSort(),u=t.column.getIsSorted(),p=r===e.headers.length-1,h={background:"var(--color-surface)",position:"sticky",top:0,zIndex:l||a?31:30,...l?{left:40*!!d,boxShadow:Z?"4px 0 12px -2px rgba(0,0,0,0.15), 2px 0 4px -1px rgba(0,0,0,0.08)":"none"}:{},...a?{left:0,position:"sticky",zIndex:31,width:40}:{},width:"calc(var(--header-".concat(t.id,"-size) * 1px)")},f=t.isPlaceholder?null:(0,e0.Kv)(t.column.columnDef.header,t.getContext()),v=x("h-11 text-left align-middle font-medium text-xs uppercase tracking-wider whitespace-nowrap p-0 group select-none relative box-border",!p&&"border-r",l&&Z&&"border-r-2!"),g=x("flex items-center gap-1 h-full px-4 transition-colors",c&&"cursor-pointer hover:bg-[var(--color-surface-hover)]",u&&"bg-[var(--color-surface-hover)]"),y=!a&&!i&&t.column.getCanResize()?(0,n.jsx)("div",{"data-resize-handle":!0,onMouseDown:t.getResizeHandler(),onTouchStart:t.getResizeHandler(),onDoubleClick:()=>t.column.resetSize(),onClick:e=>e.stopPropagation(),className:x("dt-resize-handle",t.column.getIsResizing()&&"dt-resize-active")}):null;return!m||a||s||i?(0,n.jsxs)("th",{style:{...h,borderColor:"var(--color-border)"},className:v,children:[(0,n.jsxs)("span",{className:g,onClick:c?t.column.getToggleSortingHandler():void 0,style:{color:"var(--color-text-muted)"},children:[f,c&&(0,n.jsx)(e7,{direction:u})]}),y,l&&Z&&(0,n.jsx)("div",{className:"absolute top-0 right-0 bottom-0 w-4 translate-x-full pointer-events-none bg-linear-to-r from-black/4 to-transparent z-100"})]},t.id):(0,n.jsx)(e8,{id:t.id,style:h,className:v,children:e=>(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("span",{className:g,onClick:c?t.column.getToggleSortingHandler():void 0,style:{color:"var(--color-text-muted)",cursor:"grab"},...e,children:[f,c&&(0,n.jsx)(e7,{direction:u})]}),y,l&&Z&&(0,n.jsx)("div",{className:"absolute top-0 right-0 bottom-0 w-4 translate-x-full pointer-events-none bg-linear-to-r from-black/4 to-transparent z-100"})]})},t.id)})})},e.id))}),(0,n.jsx)(te,{table:em,activeRowId:_,getRowId:E,enableRowSelection:d,stickyFirstColumn:G,isScrolled:Z,onRowClick:C,getFirstDataColumnFaviconUrl:S})]})})}),!l&&r.length>0&&(0,n.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 text-xs shrink-0 backdrop-blur-xl",style:{borderTop:"1px solid var(--color-border)",color:"var(--color-text-muted)",background:"var(--color-glass)"},children:[(0,n.jsxs)("span",{className:"text-xs font-medium",children:[D?"Showing ".concat((D.page-1)*D.pageSize+1,"–").concat(Math.min(D.page*D.pageSize,D.totalCount)," of ").concat(D.totalCount," results"):"Showing ".concat(em.getRowModel().rows.length," of ").concat(r.length," results"),ey>0&&" (".concat(ey," selected)")]}),(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("span",{className:"text-xs font-medium",children:"Rows per page"}),(0,n.jsx)("select",{value:D?D.pageSize:Q.pageSize,onChange:e=>{let t=Number(e.target.value);D?D.onPageSizeChange(t):X(e=>({...e,pageSize:t,pageIndex:0}))},className:"h-7 px-2 py-0 rounded-full text-xs outline-none shadow-[0_0_21px_0_rgba(0,0,0,0.05)] transition-colors",style:{background:"var(--color-surface)",color:"var(--color-text)",border:"1px solid var(--color-border)"},children:[20,50,100,250,500].map(e=>(0,n.jsx)("option",{value:e,children:e},e))})]}),(0,n.jsxs)("span",{className:"text-xs font-medium min-w-[80px] text-center",children:["Page ",D?D.page:Q.pageIndex+1," of ",em.getPageCount()]}),(0,n.jsx)("div",{className:"flex gap-1",children:D?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(tt,{onClick:()=>D.onPageChange(1),disabled:D.page<=1,label:"\xab"}),(0,n.jsx)(tt,{onClick:()=>D.onPageChange(D.page-1),disabled:D.page<=1,label:"‹"}),(0,n.jsx)(tt,{onClick:()=>D.onPageChange(D.page+1),disabled:D.page>=Math.ceil(D.totalCount/D.pageSize),label:"›"}),(0,n.jsx)(tt,{onClick:()=>D.onPageChange(Math.ceil(D.totalCount/D.pageSize)),disabled:D.page>=Math.ceil(D.totalCount/D.pageSize),label:"\xbb"})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(tt,{onClick:()=>X(e=>({...e,pageIndex:0})),disabled:!em.getCanPreviousPage(),label:"\xab"}),(0,n.jsx)(tt,{onClick:()=>em.previousPage(),disabled:!em.getCanPreviousPage(),label:"‹"}),(0,n.jsx)(tt,{onClick:()=>em.nextPage(),disabled:!em.getCanNextPage(),label:"›"}),(0,n.jsx)(tt,{onClick:()=>X(e=>({...e,pageIndex:em.getPageCount()-1})),disabled:!em.getCanNextPage(),label:"\xbb"})]})})]})]})]})}let te=o.memo(function(e){let{table:t,activeRowId:r,getRowId:o,enableRowSelection:l,stickyFirstColumn:a,isScrolled:s,onRowClick:i,getFirstDataColumnFaviconUrl:c}=e;return(0,n.jsx)("tbody",{className:"[&_tr:last-child]:border-0",children:t.getRowModel().rows.map((e,d)=>{let u=e.getIsSelected(),p=e.getVisibleCells(),h=null!=r&&null!=o&&o(e.original)===r,m=h||u?"var(--color-accent-light)":d%2==0?"var(--color-surface)":"var(--color-bg)";return(0,n.jsx)("tr",{"data-state":u?"selected":h?"active":void 0,className:x("border-b transition-all duration-150 group/row",i&&"cursor-pointer",u&&"data-[state=selected]:bg-(--color-accent-light)"),style:{borderColor:h?"var(--color-accent)":"var(--color-border)",background:m},onClick:()=>null==i?void 0:i(e.original,d),onMouseEnter:e=>{u||h||(e.currentTarget.style.background="var(--color-surface-hover)")},onMouseLeave:e=>{u||h||(e.currentTarget.style.background=d%2==0?"var(--color-surface)":"var(--color-bg)")},children:p.map((r,o)=>{let i=o===+!!l,f=a&&i,v="select"===r.column.id,g=o===p.length-1,y=i&&!v?null==c?void 0:c(e,t):void 0,b=d%2==0?"var(--color-surface)":"var(--color-bg)",j=h||u?"linear-gradient(var(--color-accent-light), var(--color-accent-light)), linear-gradient(".concat(b,", ").concat(b,")"):m,k={borderColor:"var(--color-border)",...f?{position:"sticky",left:40*!!l,zIndex:2,background:j,boxShadow:s?"4px 0 12px -2px rgba(0,0,0,0.12), 2px 0 4px -1px rgba(0,0,0,0.06)":"none"}:{},...v?{position:"sticky",left:0,zIndex:2,background:j,width:40}:{}};return(0,n.jsxs)("td",{className:x("px-3 py-1.5 align-middle whitespace-nowrap text-xs border-b transition-colors box-border",!g&&"border-r",f&&s&&"border-r-2!"),style:k,children:[(0,n.jsx)("div",{className:"overflow-hidden",children:y?(0,n.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5",children:[(0,n.jsx)("span",{className:"pointer-events-none shrink-0",children:(0,n.jsx)(e3,{src:y})}),(0,n.jsx)("div",{className:"min-w-0 flex-1 overflow-hidden",children:(0,e0.Kv)(r.column.columnDef.cell,r.getContext())})]}):(0,e0.Kv)(r.column.columnDef.cell,r.getContext())}),f&&s&&(0,n.jsx)("div",{className:"absolute top-0 right-0 bottom-0 w-4 translate-x-full pointer-events-none bg-linear-to-r from-black/4 to-transparent z-100"})]},r.id)})},e.id)})})},(e,t)=>!!t.table.getState().columnSizingInfo.isResizingColumn&&e.table.options.data===t.table.options.data);function tt(e){let{onClick:t,disabled:r,label:o}=e;return(0,n.jsx)("button",{type:"button",onClick:t,disabled:r,className:"h-7 w-7 rounded-full flex items-center justify-center text-xs disabled:opacity-30 cursor-pointer transition-colors backdrop-blur-sm shadow-[0_0_21px_0_rgba(0,0,0,0.05)]",style:{color:"var(--color-text-muted)",border:"1px solid var(--color-border)",background:"var(--color-surface)"},dangerouslySetInnerHTML:{__html:o}})}function tr(e){let{row:t,actions:r}=e;return(0,n.jsxs)(ef,{children:[(0,n.jsx)(ev,{className:"p-1 rounded-md cursor-pointer",style:{color:"var(--color-text-muted)"},onClick:e=>e.stopPropagation(),children:(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,n.jsx)("circle",{cx:"12",cy:"5",r:"1.5"}),(0,n.jsx)("circle",{cx:"12",cy:"12",r:"1.5"}),(0,n.jsx)("circle",{cx:"12",cy:"19",r:"1.5"})]})}),(0,n.jsx)(eg,{align:"end",sideOffset:4,children:r.map((e,r)=>(0,n.jsxs)(ey,{variant:"destructive"===e.variant?"destructive":"default",onSelect:()=>{var r;return null==(r=e.onClick)?void 0:r.call(e,t)},children:[e.icon,e.label]},r))})]})}function tn(e){let{columnCount:t}=e,r=["w-full","w-3/4","w-5/6","w-2/3"];return(0,n.jsxs)("div",{className:"w-full",children:[(0,n.jsx)("div",{className:"flex gap-0 border-b-2",style:{borderColor:"var(--color-border)",background:"var(--color-surface)"},children:Array.from({length:Math.min(t,6)}).map((e,r)=>(0,n.jsx)("div",{className:"flex-1 h-11 px-4 flex items-center",style:{borderRight:r<Math.min(t,6)-1?"1px solid var(--color-border)":"none"},children:(0,n.jsx)("div",{className:"h-3 w-16 rounded animate-pulse",style:{background:"var(--color-surface-hover)",animationDelay:"".concat(50*r,"ms"),animationDuration:"1.5s"}})},r))}),Array.from({length:15}).map((e,o)=>(0,n.jsx)("div",{className:"flex gap-0 border-b",style:{borderColor:"var(--color-border)"},children:Array.from({length:Math.min(t,6)}).map((e,l)=>(0,n.jsx)("div",{className:"flex-1 px-3 py-2.5 flex items-center",style:{borderRight:l<Math.min(t,6)-1?"1px solid var(--color-border)":"none"},children:(0,n.jsx)("div",{className:x("h-3.5 rounded animate-pulse",r[(o+l)%r.length]),style:{background:"var(--color-surface-hover)",animationDelay:"".concat(50*o+30*l,"ms"),animationDuration:"1.5s"}})},l))},o))]})}function to(e){if(!e)return[];let t=e.trim();if(!t)return[];if(t.startsWith("["))try{let e=JSON.parse(t);if(Array.isArray(e))return e.map(String).filter(Boolean)}catch(e){}return[t]}function tl(e){let{relatedObjectName:t,value:r,multiple:l=!1,onChange:a,placeholder:s,variant:i="modal",autoFocus:c=!1}=e,[d,u]=(0,o.useState)(c),[p,h]=(0,o.useState)(""),[x,m]=(0,o.useState)([]),[f,v]=(0,o.useState)(!1),[g,y]=(0,o.useState)(()=>to(r)),b=(0,o.useRef)(null),j=(0,o.useRef)(null),k=(0,o.useRef)(null);(0,o.useEffect)(()=>{y(to(r))},[r]);let w=(0,o.useCallback)(async e=>{v(!0);try{let n=new URLSearchParams;e&&n.set("q",e);let o=await fetch("/api/workspace/objects/".concat(encodeURIComponent(t),"/entries/options?").concat(n));if(o.ok){var r;let e=await o.json();m(null!=(r=e.options)?r:[])}}catch(e){}finally{v(!1)}},[t]);(0,o.useEffect)(()=>{d&&w(p)},[d]),(0,o.useEffect)(()=>{if(d)return k.current&&clearTimeout(k.current),k.current=setTimeout(()=>w(p),250),()=>{k.current&&clearTimeout(k.current)}},[p]),(0,o.useEffect)(()=>{d&&j.current&&j.current.focus()},[d]),(0,o.useEffect)(()=>{if(!d)return;let e=e=>{b.current&&!b.current.contains(e.target)&&u(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[d]);let N=g.map(e=>{var t;let r=x.find(t=>t.id===e),n=null!=(t=null==r?void 0:r.label)?t:e;return{id:e,label:String(null!=n&&"object"==typeof n?JSON.stringify(n):null!=n?n:"")}}),C="inline"===i;return(0,n.jsxs)("div",{ref:b,className:"relative w-full",children:[(0,n.jsxs)("div",{onClick:()=>u(!d),className:"w-full flex items-center flex-wrap gap-1 cursor-pointer min-h-[1.5em] ".concat(C?"text-xs":"px-3 py-2 text-sm rounded-lg"),style:C?{}:{background:"var(--color-surface)",color:"var(--color-text)",border:"1px solid var(--color-border)"},children:[N.length>0?N.map(e=>{let{id:t,label:r}=e;return(0,n.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-md text-xs font-medium",style:{background:"rgba(96, 165, 250, 0.1)",color:"#60a5fa",border:"1px solid rgba(96, 165, 250, 0.2)"},children:[(0,n.jsx)("span",{className:"truncate max-w-[160px]",children:String(null!=r?r:"")}),(0,n.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation();let r=g.filter(e=>e!==t);y(r),l?a(0===r.length?"":JSON.stringify(r)):a("")},className:"ml-0.5 hover:opacity-70",style:{color:"#60a5fa"},children:(0,n.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M18 6 6 18"}),(0,n.jsx)("path",{d:"m6 6 12 12"})]})})]},t)}):(0,n.jsx)("span",{style:{color:"var(--color-text-muted)",opacity:.5},children:null!=s?s:"Select ".concat(t,"...")}),(0,n.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"ml-auto flex-shrink-0",style:{color:"var(--color-text-muted)",transform:d?"rotate(180deg)":void 0,transition:"transform 0.15s"},children:(0,n.jsx)("path",{d:"m6 9 6 6 6-6"})})]}),d&&(0,n.jsxs)("div",{className:"absolute z-50 mt-1 w-full rounded-lg shadow-lg overflow-hidden",style:{background:"var(--color-bg)",border:"1px solid var(--color-border)",maxHeight:260},children:[(0,n.jsx)("div",{className:"p-2 border-b",style:{borderColor:"var(--color-border)"},children:(0,n.jsx)("input",{ref:j,type:"text",value:p,onChange:e=>h(e.target.value),placeholder:"Search ".concat(t,"..."),className:"w-full px-2.5 py-1.5 text-xs rounded-md outline-none",style:{background:"var(--color-surface)",color:"var(--color-text)",border:"1px solid var(--color-border)"},onKeyDown:e=>{"Escape"===e.key&&u(!1)}})}),(0,n.jsx)("div",{className:"overflow-y-auto",style:{maxHeight:200},children:f?(0,n.jsx)("div",{className:"px-3 py-4 text-center text-xs",style:{color:"var(--color-text-muted)"},children:"Loading..."}):0===x.length?(0,n.jsx)("div",{className:"px-3 py-4 text-center text-xs",style:{color:"var(--color-text-muted)"},children:p?"No matches found":"No entries"}):x.map(e=>{var t;let r=g.includes(e.id);return(0,n.jsxs)("button",{type:"button",onClick:()=>(e=>{if(l){let t=g.includes(e)?g.filter(t=>t!==e):[...g,e];y(t),a(0===t.length?"":JSON.stringify(t))}else y([e]),a(e),u(!1)})(e.id),className:"w-full text-left px-3 py-2 text-xs flex items-center gap-2 transition-colors",style:{background:r?"var(--color-accent-light, rgba(96, 165, 250, 0.08))":"transparent",color:"var(--color-text)"},onMouseEnter:e=>{r||(e.currentTarget.style.background="var(--color-surface-hover, rgba(255,255,255,0.04))")},onMouseLeave:e=>{e.currentTarget.style.background=r?"var(--color-accent-light, rgba(96, 165, 250, 0.08))":"transparent"},children:[l&&(0,n.jsx)("span",{className:"w-3.5 h-3.5 rounded border flex items-center justify-center flex-shrink-0",style:{borderColor:r?"var(--color-accent)":"var(--color-border)",background:r?"var(--color-accent)":"transparent"},children:r&&(0,n.jsx)("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"M20 6 9 17l-5-5"})})}),!l&&r&&(0,n.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--color-accent)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:"flex-shrink-0",children:(0,n.jsx)("path",{d:"M20 6 9 17l-5-5"})}),(0,n.jsx)("span",{className:"truncate",children:String(null!=e.label&&"object"==typeof e.label?JSON.stringify(e.label):null!=(t=e.label)?t:"")})]},e.id)})})]})]})}var ta=r(68840);let ts=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,ti=/^https?:\/\/\S+$/i,tc=/^\+?[0-9().\-\s]{7,}$/,td=/^\d{4}-\d{2}-\d{2}$/,tu=/^\d{4}-\d{2}-\d{2}(?:[T\s]\d{2}:\d{2}(?::\d{2}(?:\.\d{1,9})?)?(?:Z|[+-]\d{2}(?::?\d{2})?)?)?$/,tp=/^\d{1,2}\/\d{1,2}\/\d{2,4}$/,th=/^([$\u20ac\u00a3\u00a5])\s*(-?\d[\d,]*(?:\.\d+)?)$/,tx=/^-?\d[\d,]*(?:\.\d+)?$/,tm=new Set(["jpg","jpeg","png","gif","webp","svg","bmp","avif","heic","heif","ico","tiff","tif"]),tf=new Set(["mp4","webm","mov","avi","mkv"]),tv=new Set(["mp3","wav","ogg","m4a","aac","flac"]),tg=new Set(["pdf"]),ty=new Set([...tm,...tf,...tv,...tg,"txt","md","json","yaml","yml","csv","sql","doc","docx","xls","xlsx","ppt","pptx","zip","tar","gz"]);function tb(e){var t,r,n,o;return null!=(o=null==(r=(null!=(n=null==(t=e.split("?")[0])?void 0:t.split("#")[0])?n:e).split(".").pop())?void 0:r.toLowerCase())?o:""}function tj(e){let t=tb(e);if(t){if(tm.has(t))return"image";if(tf.has(t))return"video";if(tv.has(t))return"audio";if(tg.has(t))return"pdf"}}function tk(e){return e.startsWith("/")||e.startsWith("~/")||/^[A-Za-z]:[\\/]/.test(e)}function tw(e){let t=(0,ta.lc)(e);if((null==t?void 0:t.kind)==="file")return t.path;let r=function(e){if(!e.startsWith("file://"))return null;try{let t=new URL(e);if("file:"!==t.protocol)return null;let r=decodeURIComponent(t.pathname);if(/^\/[A-Za-z]:\//.test(r))return r.slice(1);return r}catch(e){return null}}(e);if(r)return r;let n=e.trim();return!function(e){let t=e.trim();if(!t||t.includes("://")&&!t.startsWith("file://"))return!1;if(t.startsWith("./")||t.startsWith("../")||tk(t))return!0;let r=t.includes("/")||t.includes("\\"),n=tb(t);return r?n.length>0&&n.length<=8:ty.has(n)}(n)?null:n}function tN(e){let t=e.trim();if(!t)return null;if(t.startsWith("www."))return"https://".concat(t);if(!ti.test(t))return null;try{let e=new URL(t);if("http:"!==e.protocol&&"https:"!==e.protocol)return null;return e.toString()}catch(e){return null}}function tC(e){try{let t=new URL(e);if("http:"!==t.protocol&&"https:"!==t.protocol)return;let r=t.hostname.trim();if(!r)return;return"https://www.google.com/s2/favicons?domain=".concat(encodeURIComponent(r),"&sz=32")}catch(e){return}}function tS(e){let t=e.trim();if(!tc.test(t)||t.replace(/\D/g,"").length<7)return null;let r=t.replace(/[^\d+]/g,"");return r?"tel:".concat(r):null}function tM(e){let t=e.replace(/,/g,"").trim();if(!t)return null;let r=Number(t);return Number.isFinite(r)?r:null}function tL(e){return new Intl.NumberFormat(void 0,{maximumFractionDigits:6}).format(e)}function tT(e,t){let r=function(e){switch(e){case"$":return"USD";case"€":return"EUR";case"\xa3":return"GBP";case"\xa5":return"JPY";default:return null}}(e);return r?new Intl.NumberFormat(void 0,{style:"currency",currency:r,maximumFractionDigits:2}).format(t):"".concat(e).concat(tL(t))}function tI(e){let t=function(e){let t,r=e.trim();if(td.test(r)){let[e,t,n]=r.split("-").map(e=>Number(e)),o=new Date(e,(null!=t?t:1)-1,null!=n?n:1);return Number.isNaN(o.getTime())?null:o}if(!(tu.test(r)||tp.test(r)))return null;let n=new Date(((t=r).includes(" ")&&(t=t.replace(" ","T")),t=(t=(t=t.replace(/(\.\d{3})\d+(?=(?:Z|[+-]\d{2}(?::?\d{2})?)?$)/,"$1")).replace(/([+-]\d{2})$/,"$1:00")).replace(/([+-]\d{2})(\d{2})$/,"$1:$2")));return Number.isNaN(n.getTime())?null:n}(e);return t?{text:e.includes("T")||/\d{1,2}:\d{2}/.test(e)?new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(t):new Intl.DateTimeFormat(void 0,{dateStyle:"medium"}).format(t),iso:t.toISOString()}:null}function tR(e){return e.startsWith("http://")||e.startsWith("https://")?e:tk(e)?"/api/workspace/browse-file?path=".concat(encodeURIComponent(e),"&raw=true"):"/api/workspace/raw-file?path=".concat(encodeURIComponent(e))}function t_(e,t){let r=function(e){if(null==e)return"";if("string"==typeof e)return e;if("number"==typeof e||"boolean"==typeof e||"bigint"==typeof e)return String(e);if("object"==typeof e)try{return JSON.stringify(e)}catch(e){}return""}(e);if(!r||0===r.trim().length)return{kind:"empty",raw:r,text:""};let n=(null!=t?t:"").trim().toLowerCase(),o=function(e,t){if("email"===t&&ts.test(e.trim())){let t=e.trim();return{kind:"link",raw:e,text:t,linkType:"email",href:"mailto:".concat(t)}}if("phone"===t){let t=tS(e);if(t)return{kind:"link",raw:e,text:e.trim(),linkType:"phone",href:t}}if("url"===t){let t=tN(e);if(t)return{kind:"link",raw:e,text:e.trim(),linkType:"url",href:t,mediaType:tj(t),embedUrl:t,faviconUrl:tC(t)}}if("date"===t){let t=tI(e);if(t)return{kind:"date",raw:e,text:t.text,isoDate:t.iso}}if("number"===t){let t=e.trim().match(th);if(t){var r,n;let o=tM(null!=(r=t[2])?r:"");if(null!=o)return{kind:"currency",raw:e,text:tT(null!=(n=t[1])?n:"$",o),numericValue:o}}let o=tM(e);if(null!=o)return{kind:"number",raw:e,text:tL(o),numericValue:o}}if("file"===t){let t=tw(e);if(t)return{kind:"link",raw:e,text:t,linkType:"file",href:(0,ta.bJ)(t),filePath:t,mediaType:tj(t),embedUrl:tR(t)}}return null}(r,n);return o||("richtext"===n||"relation"===n||"enum"===n||"user"===n?{kind:"text",raw:r,text:r}:function(e){let t=e.trim(),r=tw(t);if(r)return{kind:"link",raw:e,text:r,linkType:"file",href:(0,ta.bJ)(r),filePath:r,mediaType:tj(r),embedUrl:tR(r)};if(ts.test(t))return{kind:"link",raw:e,text:t,linkType:"email",href:"mailto:".concat(t)};let n=tN(t);if(n)return{kind:"link",raw:e,text:t,linkType:"url",href:n,mediaType:tj(n),embedUrl:n,faviconUrl:tC(n)};let o=tS(t);if(o)return{kind:"link",raw:e,text:t,linkType:"phone",href:o};let l=tI(t);if(l)return{kind:"date",raw:e,text:l.text,isoDate:l.iso};let a=t.match(th);if(a){var s,i;let t=tM(null!=(s=a[2])?s:"");if(null!=t)return{kind:"currency",raw:e,text:tT(null!=(i=a[1])?i:"$",t),numericValue:t}}if(tx.test(t)){let r=tM(t);if(null!=r)return{kind:"number",raw:e,text:tL(r),numericValue:r}}return{kind:"text",raw:e,text:e}}(r))}function tE(e){let{href:t,openInNewTab:r=!0,title:o="Open link",className:l}=e;return(0,n.jsx)("a",{href:t,...r?{target:"_blank",rel:"noopener noreferrer"}:{},title:o,"aria-label":o,onPointerDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),className:null!=l?l:"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-md hover:bg-black/5",children:(0,n.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M7 7h10v10"}),(0,n.jsx)("path",{d:"M7 17 17 7"})]})})}var tD=r(17763);let tA=new Map,tW=new Map;function tB(e){let t=tW.get(e);if(t)for(let e of t)e()}async function tF(e){if(!tA.has(e)){tA.set(e,"loading"),tB(e);try{let t=await fetch("/api/workspace/link-preview?url=".concat(encodeURIComponent(e)));if(!t.ok)throw Error("fetch failed");let r=await t.json();tA.set(e,r)}catch(t){tA.set(e,"error")}tB(e)}}function tP(e){let[,t]=(0,o.useState)(0);if((0,o.useEffect)(()=>{if(e){var r;let n;return r=()=>t(e=>e+1),(n=tW.get(e))||(n=new Set,tW.set(e,n)),n.add(r),()=>{n.delete(r),0===n.size&&tW.delete(e)}}},[e]),!e)return{state:"idle",data:void 0};let r=tA.get(e);return r?"loading"===r?{state:"loading",data:void 0}:"error"===r?{state:"error",data:void 0}:{state:"ready",data:r}:{state:"idle",data:void 0}}function tz(e){let[t,r]=(0,o.useState)(!1),n=(0,o.useRef)(null),l=(0,o.useRef)(null),a=(0,o.useRef)(null),s=(0,o.useCallback)(()=>{n.current&&(clearTimeout(n.current),n.current=null),l.current&&(clearTimeout(l.current),l.current=null)},[]),i=(0,o.useCallback)(()=>{e&&(l.current&&(clearTimeout(l.current),l.current=null),n.current=setTimeout(()=>{tF(e),r(!0)},200))},[e]),c=(0,o.useCallback)(()=>{n.current&&(clearTimeout(n.current),n.current=null),l.current=setTimeout(()=>r(!1),200)},[]),d=(0,o.useCallback)(()=>{l.current&&(clearTimeout(l.current),l.current=null)},[]),u=(0,o.useCallback)(()=>{l.current=setTimeout(()=>r(!1),200)},[]);return(0,o.useEffect)(()=>s,[s]),{open:t,triggerRef:a,triggerProps:{ref:a,onMouseEnter:i,onMouseLeave:c,onFocus:i,onBlur:c},cardProps:{onMouseEnter:d,onMouseLeave:u}}}function tO(e){let{data:t,loading:r}=e;if(r||!t)return(0,n.jsxs)("div",{className:"flex items-center gap-2 px-3 py-3",children:[(0,n.jsx)("div",{className:"w-4 h-4 rounded-full border-2 border-t-transparent animate-spin",style:{borderColor:"var(--color-border)",borderTopColor:"transparent"}}),(0,n.jsx)("span",{className:"text-xs",style:{color:"var(--color-text-muted)"},children:"Loading preview..."})]});let o=!!t.imageUrl;return t.title||t.description||o?(0,n.jsxs)(n.Fragment,{children:[o&&(0,n.jsx)("div",{className:"w-full h-[140px] overflow-hidden bg-black/5 dark:bg-white/5",children:(0,n.jsx)("img",{src:t.imageUrl,alt:"",className:"w-full h-full object-cover",onError:e=>{e.currentTarget.parentElement.style.display="none"}})}),(0,n.jsxs)("div",{className:"px-3 py-2.5 space-y-1",children:[(0,n.jsxs)("div",{className:"flex items-center gap-1.5",children:[t.faviconUrl&&(0,n.jsx)("img",{src:t.faviconUrl,alt:"",className:"w-3.5 h-3.5 rounded-[3px] shrink-0",onError:e=>{e.currentTarget.style.display="none"}}),(0,n.jsx)("span",{className:"text-[10px] font-medium truncate",style:{color:"var(--color-text-muted)"},children:t.siteName||t.domain})]}),t.title&&(0,n.jsx)("p",{className:"text-xs font-semibold leading-snug line-clamp-2",style:{color:"var(--color-text)"},children:t.title}),t.description&&(0,n.jsx)("p",{className:"text-[11px] leading-relaxed line-clamp-3",style:{color:"var(--color-text-muted)"},children:t.description})]})]}):(0,n.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2.5",children:[t.faviconUrl&&(0,n.jsx)("img",{src:t.faviconUrl,alt:"",className:"w-4 h-4 rounded-[3px] shrink-0"}),(0,n.jsx)("span",{className:"text-xs font-medium truncate",style:{color:"var(--color-text)"},children:t.domain})]})}function tU(e){let{open:t,triggerRef:r,data:l,loading:a,cardProps:s}=e,i=(0,o.useRef)(null),[c,d]=(0,o.useState)(null);return((0,o.useEffect)(()=>{if(!t||!r.current)return void d(null);let e=r.current.getBoundingClientRect(),n=window.innerHeight-e.bottom>248?"below":"above",o="below"===n?e.bottom+8:e.top-240-8,l=e.left+e.width/2-160;l=Math.max(8,Math.min(l,window.innerWidth-320-8)),d({top:o=Math.max(8,o),left:l,placement:n})},[t,r,l]),t&&c)?(0,tD.createPortal)((0,n.jsx)("div",{ref:i,role:"tooltip",...s,className:"fixed z-[99999] w-[320px] rounded-xl overflow-hidden animate-in fade-in-0 zoom-in-95 duration-150",style:{top:c.top,left:c.left,background:"var(--color-surface)",border:"1px solid var(--color-border)",boxShadow:"0 8px 30px rgba(0,0,0,0.16), 0 2px 8px rgba(0,0,0,0.08)",transformOrigin:"below"===c.placement?"top center":"bottom center"},children:(0,n.jsx)(tO,{data:l,loading:a})}),document.body):null}function tH(e){let{href:t,text:r,linkType:o,faviconUrl:l,showFavicon:a=!1,layout:s="inline",className:i,children:c}=e,d="url"===o,u=d?t:void 0,{open:p,triggerRef:h,triggerProps:x,cardProps:m}=tz(u),{state:f,data:v}=tP(u),g=a&&"url"===o&&l,y=g?(0,n.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5 ".concat("inline"===s?"max-w-full":"w-full"),children:[(0,n.jsx)(e3,{src:l}),(0,n.jsx)("span",{className:"min-w-0 truncate",children:r})]}):r,b=(()=>{let e=null!=i?i:"";return g?"block"===s?"block underline underline-offset-2 ".concat(e).trim():"inline-flex min-w-0 max-w-full items-center gap-1.5 align-middle underline underline-offset-2 ".concat(e).trim():"underline underline-offset-2 ".concat(e).trim()})();return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("a",{...d?x:{},ref:d?h:void 0,href:t,..."url"===o||"file"===o?{target:"_blank",rel:"noopener noreferrer"}:{},className:b,style:{color:"var(--color-accent)"},onClick:e=>e.stopPropagation(),children:null!=c?c:y}),d&&(0,n.jsx)(tU,{open:p,triggerRef:h,data:v,loading:"loading"===f,cardProps:m})]})}function tV(e){let{href:t,children:r,className:o,style:l,...a}=e,{open:s,triggerRef:i,triggerProps:c,cardProps:d}=tz(t),{state:u,data:p}=tP(t);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{...a,...c,ref:i,className:o,style:l,children:r}),(0,n.jsx)(tU,{open:s,triggerRef:i,data:p,loading:"loading"===u,cardProps:d})]})}function tK(){return(0,n.jsx)("span",{style:{color:"var(--color-text-muted)",opacity:.5},children:"--"})}function tJ(e){let{mediaType:t,url:r,label:o}=e;return"image"===t?(0,n.jsx)("div",{className:"mt-2 rounded-lg overflow-hidden border",style:{borderColor:"var(--color-border)"},children:(0,n.jsx)("img",{src:r,alt:o,className:"max-h-64 w-auto"})}):"video"===t?(0,n.jsx)("video",{src:r,controls:!0,className:"mt-2 w-full max-h-72 rounded-lg border",style:{borderColor:"var(--color-border)",background:"#000"}}):"audio"===t?(0,n.jsx)("audio",{src:r,controls:!0,className:"mt-2 w-full"}):(0,n.jsx)("iframe",{src:"".concat(r,"#toolbar=0&navpanes=0&scrollbar=1"),title:o,className:"mt-2 w-full h-72 rounded-lg border",style:{borderColor:"var(--color-border)",background:"white"}})}function tq(e){let{text:t,fieldType:r,showUrlFavicon:o=!1,linkInteractionMode:l="inline",isTableMode:a=!1}=e,s=t.trim();if(!s)return(0,n.jsx)(n.Fragment,{children:t});let i=r&&"text"!==r&&"richtext"!==r?r:void 0,c=t_(s,i);if("link"===c.kind&&c.href){var d;if(!i&&"file"===c.linkType&&s.includes(" "))return(0,n.jsx)(n.Fragment,{children:c.text});let e="url"===c.linkType||"file"===c.linkType,t=o&&"url"===c.linkType&&!!c.faviconUrl;if("button"===l){let r=(0,n.jsxs)("span",{className:"inline-flex min-w-0 max-w-full items-center gap-1.5 align-middle",style:{color:"var(--color-accent)"},children:[t&&(0,n.jsx)(e3,{src:c.faviconUrl}),(0,n.jsx)("span",{className:a?"min-w-0 truncate":"min-w-0 break-all",children:c.text}),(0,n.jsx)(tE,{href:c.href,openInNewTab:e,className:"inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-sm hover:bg-black/5"})]});return"url"===c.linkType?(0,n.jsx)(tV,{href:c.href,children:r}):r}return(0,n.jsx)(tH,{href:c.href,text:c.text,linkType:null!=(d=c.linkType)?d:"url",faviconUrl:c.faviconUrl,showFavicon:t})}return"number"===c.kind||"currency"===c.kind?(0,n.jsx)("span",{className:"tabular-nums",children:c.text}):(0,n.jsx)(n.Fragment,{children:c.text})}function tG(e){let{value:t,fieldType:r,mode:l="table",className:a,showUrlFavicon:s=!1,linkInteractionMode:i="inline"}=e,c=t_(t,r),d="table"===l;if("empty"===c.kind)return(0,n.jsx)(tK,{});let u=c.text.replace(/\\r\\n/g,"\n").replace(/\\n/g,"\n").replace(/\\r/g,"\n");if(u.includes("\n")){let e=u.split("\n"),t=null!=a?a:d?"block max-w-[300px] line-clamp-3":"break-words";return(0,n.jsx)("span",{className:t,children:e.map((e,t)=>(0,n.jsxs)(o.Fragment,{children:[t>0&&(0,n.jsx)("br",{}),(0,n.jsx)(tq,{text:e,fieldType:r,showUrlFavicon:s,linkInteractionMode:i,isTableMode:d})]},t))})}let p=null!=a?a:d?"truncate block max-w-[300px]":"break-words";if("link"===c.kind&&c.href){var h;let e="url"===c.linkType||"file"===c.linkType,t=!d&&!!c.embedUrl&&!!c.mediaType,r=s&&"url"===c.linkType&&!!c.faviconUrl;if("button"===i){let o=(0,n.jsxs)("div",{className:d?"block max-w-[300px]":"w-full",children:[(0,n.jsxs)("span",{className:"flex w-full min-w-0 items-center gap-1.5",style:{color:"var(--color-accent)"},children:[r&&(0,n.jsx)(e3,{src:c.faviconUrl}),(0,n.jsx)("span",{className:d?"min-w-0 truncate":"min-w-0 break-all",children:c.text}),(0,n.jsx)(tE,{href:c.href,openInNewTab:e})]}),t&&(0,n.jsx)(tJ,{mediaType:c.mediaType,url:c.embedUrl,label:c.text})]});return"url"===c.linkType?(0,n.jsx)(tV,{href:c.href,children:o}):o}return(0,n.jsxs)("div",{className:d?"block max-w-[300px]":"w-full",children:[(0,n.jsx)(tH,{href:c.href,text:c.text,linkType:null!=(h=c.linkType)?h:"url",faviconUrl:c.faviconUrl,showFavicon:r,layout:"block",className:d?"truncate":""}),t&&(0,n.jsx)(tJ,{mediaType:c.mediaType,url:c.embedUrl,label:c.text})]})}return"number"===c.kind||"currency"===c.kind?(0,n.jsx)("span",{className:"tabular-nums ".concat(p),children:c.text}):(0,n.jsx)("span",{className:p,children:u})}function t$(e){if(null==e)return[];if(Array.isArray(e))return e.map(String).filter(Boolean);let t=String(e).trim();if(!t)return[];if(t.startsWith("["))try{let e=JSON.parse(t);if(Array.isArray(e))return e.map(String).filter(Boolean)}catch(e){}return[t]}let tZ={default:{bg:"rgba(148, 163, 184, 0.08)",border:"1px solid rgba(148, 163, 184, 0.2)",text:"var(--color-text)",hoverBg:"rgba(148, 163, 184, 0.15)"},primary:{bg:"rgba(59, 130, 246, 0.08)",border:"1px solid rgba(59, 130, 246, 0.25)",text:"#3b82f6",hoverBg:"rgba(59, 130, 246, 0.15)"},destructive:{bg:"rgba(220, 38, 38, 0.08)",border:"1px solid rgba(220, 38, 38, 0.2)",text:"var(--color-error)",hoverBg:"rgba(220, 38, 38, 0.15)"},success:{bg:"rgba(34, 197, 94, 0.08)",border:"1px solid rgba(34, 197, 94, 0.25)",text:"#22c55e",hoverBg:"rgba(34, 197, 94, 0.15)"},warning:{bg:"rgba(245, 158, 11, 0.08)",border:"1px solid rgba(245, 158, 11, 0.25)",text:"#f59e0b",hoverBg:"rgba(245, 158, 11, 0.15)"}};function tY(e){let{size:t=12}=e;return(0,n.jsx)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"animate-spin",children:(0,n.jsx)("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})})}function tQ(e){let{size:t=12}=e;return(0,n.jsx)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("polyline",{points:"20 6 9 17 4 12"})})}function tX(e){let{size:t=12}=e;return(0,n.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,n.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function t0(e){let{size:t=12}=e;return(0,n.jsx)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("polygon",{points:"5 3 19 12 5 21 5 3"})})}function t1(e){var t,r,l,a,s,i;let c,d,{action:u,entryId:p,objectName:h,fieldId:x,compact:m=!1,state:f,onExecute:v,onRequestConfirm:g,onToast:y,disabled:b=!1}=e,[j,k]=(0,o.useState)({status:"idle"}),w=(0,o.useRef)(null),N=(0,o.useRef)(null),C=null!=f?f:j,{status:S}=C;(0,o.useEffect)(()=>()=>{w.current&&clearTimeout(w.current),N.current&&N.current.abort()},[]);let M=(0,o.useCallback)(async()=>{if(v)return void v(u,p);k({status:"loading"});let e=new AbortController;N.current=e;try{var t,r,n,o,l,a,s,i;let c=await fetch("/api/workspace/objects/".concat(encodeURIComponent(h),"/actions"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({actionId:u.id,fieldId:x,entryIds:[p]}),signal:e.signal});if(!c.ok){let e=null!=(r=(await c.json().catch(()=>({error:"Request failed"}))).error)?r:"Request failed";k({status:"error",error:e}),null==y||y(e,{type:"error"});return}let d=null==(t=c.body)?void 0:t.getReader();if(!d){k({status:"error",error:"No response stream"}),null==y||y("No response stream",{type:"error"});return}let m=new TextDecoder,f="";for(;;){let{done:e,value:t}=await d.read();if(e)break;let r=(f+=m.decode(t,{stream:!0})).split("\n");for(let e of(f=null!=(n=r.pop())?n:"",r))if(e.startsWith("data: "))try{let t=JSON.parse(e.slice(6));if("progress"===t.type)k({status:"loading",progress:{percent:t.percent,message:t.message}});else if("log"===t.type)null==y||y(null!=(o=t.message)?o:"",{type:"error"===t.level?"error":"info"});else if("completed"===t.type)if("success"===t.status)k({status:"success",result:t.result}),null==y||y(null!=(l=u.successLabel)?l:"".concat(u.label," completed"),{type:"success"}),w.current=setTimeout(()=>{k({status:"idle"})},null!=(a=u.autoResetMs)?a:3e3);else{let e=null!=(s=t.error)?s:"Action failed";k({status:"error",error:e}),null==y||y(e,{type:"error"}),w.current=setTimeout(()=>{k({status:"idle"})},null!=(i=u.autoResetMs)?i:5e3)}}catch(e){}}}catch(r){if(e.signal.aborted)return;let t=r instanceof Error?r.message:"Unknown error";k({status:"error",error:t}),null==y||y(t,{type:"error"})}},[u,p,h,x,v,y]),L=(0,o.useCallback)(e=>{if(e.stopPropagation(),"loading"!==S&&!b){if("error"===S)return void k({status:"idle"});u.confirmMessage&&g?g(u,p,M):M()}},[S,b,u,p,g,M]),T=null!=(l=tZ[null!=(r=u.variant)?r:"default"])?l:tZ.default,I=T.bg,R=T.border,_=T.text;switch(S){case"loading":c=null!=(a=u.loadingLabel)?a:"Running...",d=(0,n.jsx)(tY,{size:m?14:12});break;case"success":c=null!=(s=u.successLabel)?s:"Done!",d=(0,n.jsx)(tQ,{size:m?14:12}),I="rgba(34, 197, 94, 0.1)",R="1px solid rgba(34, 197, 94, 0.3)",_="#22c55e";break;case"error":c=null!=(i=u.errorLabel)?i:"Failed",d=(0,n.jsx)(tX,{size:m?14:12}),I="rgba(220, 38, 38, 0.1)",R="1px solid rgba(220, 38, 38, 0.3)",_="var(--color-error)";break;default:c=u.label,d=(0,n.jsx)(t0,{size:m?14:12})}let E=null==(t=C.progress)?void 0:t.percent;return(0,n.jsxs)("button",{type:"button",onClick:L,disabled:"loading"===S||b,className:"relative flex items-center gap-1.5 rounded-lg text-xs font-medium transition-all duration-200 overflow-hidden select-none",style:{padding:m?"4px 6px":"5px 10px",background:I,border:R,color:_,opacity:b?.5:1,cursor:"loading"===S||b?"not-allowed":"pointer"},title:"error"===S?C.error:u.label,onMouseEnter:e=>{"loading"===S||b||(e.currentTarget.style.background=T.hoverBg)},onMouseLeave:e=>{e.currentTarget.style.background=I},children:[null!=E&&"loading"===S&&(0,n.jsx)("div",{className:"absolute inset-0 opacity-15 transition-all duration-300",style:{background:_,width:"".concat(E,"%")}}),(0,n.jsxs)("span",{className:"relative z-10 flex items-center gap-1.5",children:[d,!m&&(0,n.jsx)("span",{className:"whitespace-nowrap",children:c})]})]})}function t2(e){let{open:t,title:r,message:l,confirmLabel:a="Confirm",cancelLabel:s="Cancel",variant:i="default",onConfirm:c,onCancel:d,loading:u=!1}=e,p=(0,o.useRef)(null);(0,o.useEffect)(()=>{t&&setTimeout(()=>{var e;return null==(e=p.current)?void 0:e.focus()},50)},[t]);let h=(0,o.useCallback)(e=>{"Escape"===e.key&&(e.stopPropagation(),d())},[d]);if(!t)return null;let x="destructive"===i;return(0,n.jsxs)("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center",onKeyDown:h,children:[(0,n.jsx)("div",{className:"absolute inset-0 backdrop-blur-sm animate-in fade-in duration-150",style:{background:"rgba(0, 0, 0, 0.4)"},onClick:d}),(0,n.jsxs)("div",{className:"relative w-full max-w-sm mx-4 rounded-xl p-6 shadow-2xl animate-in zoom-in-95 fade-in duration-200",style:{background:"var(--color-surface)",border:"1px solid var(--color-border)"},children:[(0,n.jsxs)("div",{className:"flex items-start gap-3 mb-4",children:[(0,n.jsx)("div",{className:"flex-shrink-0 w-10 h-10 rounded-full flex items-center justify-center",style:{background:x?"rgba(220, 38, 38, 0.1)":"rgba(59, 130, 246, 0.1)"},children:x?(0,n.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"#dc2626",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),(0,n.jsx)("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),(0,n.jsx)("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}):(0,n.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"#3b82f6",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,n.jsx)("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),(0,n.jsx)("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]})}),(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsx)("h3",{className:"text-sm font-semibold mb-1",style:{color:"var(--color-text)"},children:r}),(0,n.jsx)("p",{className:"text-sm leading-relaxed",style:{color:"var(--color-text-muted)"},children:l})]})]}),(0,n.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,n.jsx)("button",{type:"button",onClick:d,disabled:u,className:"px-4 py-2 rounded-lg text-sm font-medium transition-colors",style:{background:"transparent",border:"1px solid var(--color-border)",color:"var(--color-text-muted)"},children:s}),(0,n.jsxs)("button",{ref:p,type:"button",onClick:c,disabled:u,className:"px-4 py-2 rounded-lg text-sm font-medium transition-colors flex items-center gap-2",style:{background:x?"#dc2626":"var(--color-accent)",border:"none",color:"#fff",opacity:u?.7:1},children:[u&&(0,n.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"animate-spin",children:(0,n.jsx)("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),a]})]})]})]})}let t4={default:"var(--color-text)",primary:"#3b82f6",destructive:"var(--color-error)",success:"#22c55e",warning:"#f59e0b"};function t5(e){var t,r;let{action:o,fieldId:l,runState:a,onClick:s}=e,i=null!=(r=t4[null!=(t=o.variant)?t:"default"])?r:t4.default,c=(null==a?void 0:a.status)==="running",d=(null==a?void 0:a.status)==="done",u=o.label,p=(0,n.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("polygon",{points:"5 3 19 12 5 21 5 3"})}),h=null,x=i,m="color-mix(in srgb, ".concat(i," 8%, transparent)"),f="1px solid color-mix(in srgb, ".concat(i," 20%, transparent)");return c&&a?(u="".concat(o.label),p=(0,n.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"animate-spin",children:(0,n.jsx)("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),h=(0,n.jsxs)("span",{className:"text-[10px] font-mono opacity-70 tabular-nums",children:[a.succeeded+a.failed,"/",a.total]})):d&&a&&(0===a.failed?(p=(0,n.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"#22c55e",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("polyline",{points:"20 6 9 17 4 12"})}),x="#22c55e",m="rgba(34, 197, 94, 0.1)",f="1px solid rgba(34, 197, 94, 0.3)",u="".concat(a.succeeded," done")):(p=(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"#dc2626",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,n.jsx)("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),(0,n.jsx)("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]}),x="#dc2626",m="rgba(220, 38, 38, 0.1)",f="1px solid rgba(220, 38, 38, 0.3)",u="".concat(a.succeeded," ok, ").concat(a.failed," failed"))),(0,n.jsxs)("button",{type:"button",onClick:s,disabled:c,className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-xs font-medium transition-all hover:opacity-80",style:{background:m,border:f,color:x,opacity:c?.8:1,cursor:c?"not-allowed":"pointer"},children:[p,(0,n.jsx)("span",{className:"whitespace-nowrap",children:u}),h]},"".concat(l,"_").concat(o.id))}function t3(e){let{selectedCount:t,actions:r,onDeselectAll:o,onBulkAction:l,onBulkDelete:a,bulkRunStates:s}=e;return 0===t?null:(0,n.jsxs)("div",{className:"fixed bottom-6 left-1/2 -translate-x-1/2 z-[100] flex items-center gap-3 px-4 py-2.5 rounded-xl shadow-2xl animate-in slide-in-from-bottom-4 fade-in duration-300",style:{background:"var(--color-surface)",border:"1px solid var(--color-border)",backdropFilter:"blur(16px)",minWidth:320},children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 pr-3",style:{borderRight:"1px solid var(--color-border)"},children:[(0,n.jsx)("span",{className:"flex items-center justify-center w-6 h-6 rounded-md text-xs font-bold",style:{background:"var(--color-accent)",color:"#fff"},children:t}),(0,n.jsx)("span",{className:"text-xs font-medium whitespace-nowrap",style:{color:"var(--color-text-muted)"},children:"selected"}),(0,n.jsx)("button",{type:"button",onClick:o,className:"text-[11px] underline underline-offset-2 transition-opacity hover:opacity-70",style:{color:"var(--color-text-muted)"},children:"Clear"})]}),r.length>0&&(0,n.jsx)("div",{className:"flex items-center gap-1.5",children:r.map(e=>{let{action:t,fieldId:r}=e;return(0,n.jsx)(t5,{action:t,fieldId:r,runState:null==s?void 0:s.get(t.id),onClick:()=>l(t,r)},"".concat(r,"_").concat(t.id))})}),(0,n.jsx)("div",{className:"ml-auto pl-3",style:{borderLeft:r.length>0?"1px solid var(--color-border)":"none"},children:(0,n.jsxs)("button",{type:"button",onClick:a,className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-xs font-medium transition-all hover:opacity-80",style:{background:"rgba(220, 38, 38, 0.08)",border:"1px solid rgba(220, 38, 38, 0.2)",color:"var(--color-error)"},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("path",{d:"M3 6h18"}),(0,n.jsx)("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),(0,n.jsx)("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]}),"Delete"]})})]})}let t6=(0,o.createContext)(()=>{});function t8(){return(0,o.useContext)(t6)}let t7={success:{bg:"rgba(34, 197, 94, 0.08)",border:"1px solid rgba(34, 197, 94, 0.25)",color:"#22c55e",icon:(0,n.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#22c55e",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("polyline",{points:"20 6 9 17 4 12"})})},error:{bg:"rgba(220, 38, 38, 0.08)",border:"1px solid rgba(220, 38, 38, 0.25)",color:"#dc2626",icon:(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#dc2626",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,n.jsx)("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),(0,n.jsx)("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]})},info:{bg:"rgba(59, 130, 246, 0.08)",border:"1px solid rgba(59, 130, 246, 0.2)",color:"#3b82f6",icon:(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#3b82f6",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,n.jsx)("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),(0,n.jsx)("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]})}};function t9(e){let{children:t}=e,[r,l]=(0,o.useState)([]),a=(0,o.useRef)(0),s=(0,o.useRef)(new Map),i=(0,o.useCallback)(e=>{l(t=>t.map(t=>t.id===e?{...t,dismissing:!0}:t)),setTimeout(()=>{l(t=>t.filter(t=>t.id!==e))},200);let t=s.current.get(e);t&&(clearTimeout(t),s.current.delete(e))},[]),c=(0,o.useCallback)((e,t)=>{var r,n;let o=null!=(r=null==t?void 0:t.type)?r:"info",c=null!=(n=null==t?void 0:t.duration)?n:"error"===o?6e3:4e3,d=++a.current;l(t=>{let r=[...t,{id:d,message:e,type:o,duration:c}];return r.length>5?r.slice(-5):r});let u=setTimeout(()=>{i(d),s.current.delete(d)},c);s.current.set(d,u)},[i]);return(0,n.jsxs)(t6.Provider,{value:c,children:[t,r.length>0&&(0,n.jsx)("div",{className:"fixed bottom-4 right-4 z-[9998] flex flex-col-reverse gap-2 pointer-events-none",style:{maxWidth:380},children:r.map(e=>{let t=t7[e.type];return(0,n.jsxs)("div",{className:"pointer-events-auto flex items-start gap-2.5 px-3.5 py-2.5 rounded-lg shadow-lg transition-all duration-200 ".concat(e.dismissing?"opacity-0 translate-x-4":"opacity-100 translate-x-0"),style:{background:"var(--color-surface)",border:t.border,backdropFilter:"blur(12px)"},children:[(0,n.jsx)("span",{className:"flex-shrink-0 mt-0.5",children:t.icon}),(0,n.jsx)("p",{className:"text-xs leading-relaxed flex-1 min-w-0 break-words",style:{color:"var(--color-text)"},children:e.message}),(0,n.jsx)("button",{type:"button",onClick:()=>i(e.id),className:"flex-shrink-0 p-0.5 rounded hover:opacity-60 transition-opacity",style:{color:"var(--color-text-muted)"},children:(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,n.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},e.id)})})]})}let re=[{value:"text",label:"Text"},{value:"number",label:"Number"},{value:"email",label:"Email"},{value:"phone",label:"Phone"},{value:"date",label:"Date"},{value:"boolean",label:"Checkbox"},{value:"enum",label:"Select"},{value:"tags",label:"Tags"},{value:"url",label:"URL"},{value:"richtext",label:"Rich Text"}];function rt(e){let{type:t,size:r=14,className:o}=e,l={width:r,height:r,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:o};switch(t){case"text":return(0,n.jsxs)("svg",{...l,children:[(0,n.jsx)("path",{d:"M4 7V4h16v3"}),(0,n.jsx)("path",{d:"M9 20h6"}),(0,n.jsx)("path",{d:"M12 4v16"})]});case"number":return(0,n.jsxs)("svg",{...l,children:[(0,n.jsx)("path",{d:"M4 9h16"}),(0,n.jsx)("path",{d:"M4 15h16"}),(0,n.jsx)("path",{d:"M10 3 8 21"}),(0,n.jsx)("path",{d:"M16 3 14 21"})]});case"email":return(0,n.jsxs)("svg",{...l,children:[(0,n.jsx)("rect",{width:"20",height:"16",x:"2",y:"4",rx:"2"}),(0,n.jsx)("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]});case"phone":return(0,n.jsx)("svg",{...l,children:(0,n.jsx)("path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z"})});case"date":return(0,n.jsxs)("svg",{...l,children:[(0,n.jsx)("path",{d:"M8 2v4"}),(0,n.jsx)("path",{d:"M16 2v4"}),(0,n.jsx)("rect",{width:"18",height:"18",x:"3",y:"4",rx:"2"}),(0,n.jsx)("path",{d:"M3 10h18"})]});case"boolean":return(0,n.jsxs)("svg",{...l,children:[(0,n.jsx)("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),(0,n.jsx)("path",{d:"m9 12 2 2 4-4"})]});case"enum":return(0,n.jsxs)("svg",{...l,children:[(0,n.jsx)("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),(0,n.jsx)("path",{d:"m8 10 4 4 4-4"})]});case"tags":return(0,n.jsxs)("svg",{...l,children:[(0,n.jsx)("path",{d:"M12 2H2v10l9.29 9.29c.94.94 2.48.94 3.42 0l6.58-6.58c.94-.94.94-2.48 0-3.42L12 2Z"}),(0,n.jsx)("path",{d:"M7 7h.01"})]});case"url":return(0,n.jsxs)("svg",{...l,children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,n.jsx)("path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"}),(0,n.jsx)("path",{d:"M2 12h20"})]});case"richtext":return(0,n.jsxs)("svg",{...l,children:[(0,n.jsx)("path",{d:"M17 6H3"}),(0,n.jsx)("path",{d:"M21 12H3"}),(0,n.jsx)("path",{d:"M15.1 18H3"})]});case"relation":return(0,n.jsxs)("svg",{...l,children:[(0,n.jsx)("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),(0,n.jsx)("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]});case"user":return(0,n.jsxs)("svg",{...l,children:[(0,n.jsx)("path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"}),(0,n.jsx)("circle",{cx:"12",cy:"7",r:"4"})]});case"action":return(0,n.jsx)("svg",{...l,children:(0,n.jsx)("path",{d:"M13 2 3 14h9l-1 8 10-12h-9l1-8z"})});case"file":return(0,n.jsxs)("svg",{...l,children:[(0,n.jsx)("path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"}),(0,n.jsx)("path",{d:"M14 2v4a2 2 0 0 0 2 2h4"})]});default:return(0,n.jsxs)("svg",{...l,children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,n.jsx)("path",{d:"M12 16v-4"}),(0,n.jsx)("path",{d:"M12 8h.01"})]})}}function rr(e){let{field:t,sortDirection:r,onSort:o,onHide:l,onRename:a,onDelete:s,canMoveLeft:i,canMoveRight:c,onMoveLeft:d,onMoveRight:u}=e;return(0,n.jsxs)(ef,{children:[(0,n.jsx)(ev,{className:"col-header-menu-trigger shrink-0 p-0.5 rounded opacity-0 group-hover:opacity-60 aria-expanded:opacity-100 hover:!opacity-100 transition-opacity ml-auto",style:{color:"var(--color-text-muted)"},onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:(0,n.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"m6 9 6 6 6-6"})})}),(0,n.jsxs)(eg,{align:"start",sideOffset:6,className:"min-w-[180px]",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 px-2.5 py-1.5 text-xs normal-case tracking-normal",style:{color:"var(--color-text-muted)"},children:[(0,n.jsx)(rt,{type:t.type,size:14,className:"shrink-0"}),(0,n.jsx)("span",{className:"font-medium",children:function(e){var t;let r=re.find(t=>t.value===e);return null!=(t=null==r?void 0:r.label)?t:e.charAt(0).toUpperCase()+e.slice(1)}(t.type)})]}),(0,n.jsx)(ew,{}),(0,n.jsxs)(ey,{onSelect:a,children:[(0,n.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"})}),"Rename"]}),(0,n.jsx)(ew,{}),(0,n.jsxs)(ey,{onSelect:()=>o(!1),children:[(0,n.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"m5 12 7-7 7 7"})}),"Sort ascending","asc"===r&&(0,n.jsx)("span",{className:"ml-auto text-[10px] font-medium",style:{color:"var(--color-accent)"},children:"On"})]}),(0,n.jsxs)(ey,{onSelect:()=>o(!0),children:[(0,n.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"m19 12-7 7-7-7"})}),"Sort descending","desc"===r&&(0,n.jsx)("span",{className:"ml-auto text-[10px] font-medium",style:{color:"var(--color-accent)"},children:"On"})]}),(0,n.jsx)(ew,{}),(0,n.jsxs)(ey,{onSelect:l,children:[(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49"}),(0,n.jsx)("path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242"}),(0,n.jsx)("path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143"}),(0,n.jsx)("path",{d:"m2 2 20 20"})]}),"Hide column"]}),(i||c)&&(0,n.jsx)(ew,{}),i&&(0,n.jsxs)(ey,{onSelect:d,children:[(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"m12 19-7-7 7-7"}),(0,n.jsx)("path",{d:"M19 12H5"})]}),"Move left"]}),c&&(0,n.jsxs)(ey,{onSelect:u,children:[(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M5 12h14"}),(0,n.jsx)("path",{d:"m12 5 7 7-7 7"})]}),"Move right"]}),(0,n.jsx)(ew,{}),(0,n.jsxs)(ey,{variant:"destructive",onSelect:s,children:[(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M3 6h18"}),(0,n.jsx)("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),(0,n.jsx)("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]}),"Delete column"]})]})]})}function rn(e){let{currentName:t,onSave:r,onCancel:l}=e,[a,s]=(0,o.useState)(t),i=(0,o.useRef)(null);(0,o.useEffect)(()=>{let e=i.current;e&&(e.focus(),e.select())},[]);let c=(0,o.useCallback)(()=>{let e=a.trim();e&&e!==t?r(e):l()},[a,t,r,l]);return(0,n.jsx)("input",{ref:i,type:"text",value:a,onChange:e=>s(e.target.value),onBlur:c,onKeyDown:e=>{e.stopPropagation(),"Enter"===e.key&&(e.preventDefault(),c()),"Escape"===e.key&&(e.preventDefault(),l())},onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),className:"w-full text-xs font-medium outline-none bg-transparent normal-case tracking-normal rounded px-1.5 py-0.5 -mx-1.5",style:{color:"var(--color-text)",background:"var(--color-bg)",boxShadow:"inset 0 0 0 2px var(--color-accent)"}})}function ro(e){let{objectName:t,onCreated:r}=e,[l,a]=(0,o.useState)(!1),[s,i]=(0,o.useState)(""),[c,d]=(0,o.useState)("text"),[u,p]=(0,o.useState)(""),[h,x]=(0,o.useState)(!1),[m,f]=(0,o.useState)(null),v=(0,o.useRef)(null),g=(0,o.useRef)(null),y=(0,o.useRef)(null),[b,j]=(0,o.useState)({top:0,left:0}),k=(0,o.useCallback)(()=>{var e;let t=null==(e=v.current)?void 0:e.getBoundingClientRect();if(t){let e=t.left;e+280>window.innerWidth-16&&(e=Math.max(16,t.right-280)),j({top:t.bottom+6,left:e})}a(!0),i(""),d("text"),p(""),f(null)},[]),w=(0,o.useCallback)(()=>{a(!1),f(null)},[]);(0,o.useEffect)(()=>{if(l){let e=setTimeout(()=>{var e;return null==(e=y.current)?void 0:e.focus()},50);return()=>clearTimeout(e)}},[l]),(0,o.useEffect)(()=>{if(!l)return;let e=e=>{g.current&&!g.current.contains(e.target)&&v.current&&!v.current.contains(e.target)&&w()},t=e=>{"Escape"===e.key&&w()};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[l,w]);let N=(0,o.useCallback)(async()=>{if(!s.trim())return;let e={name:s.trim(),type:c};if("enum"===c){let t=u.split(",").map(e=>e.trim()).filter(Boolean);if(0===t.length)return void f("Add at least one option");e.enum_values=t}x(!0),f(null);try{let o=await fetch("/api/workspace/objects/".concat(encodeURIComponent(t),"/fields"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!o.ok){var n;let e=await o.json().catch(()=>({error:"Failed"}));f(null!=(n=e.error)?n:"Failed to create field");return}w(),r()}catch(e){f("Network error")}finally{x(!1)}},[s,c,u,t,w,r]);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{ref:v,type:"button",onClick:e=>{e.stopPropagation(),l?w():k()},onPointerDown:e=>e.stopPropagation(),className:"flex items-center justify-center w-full h-full transition-colors",style:{color:l?"var(--color-accent)":"var(--color-text-muted)",opacity:l?1:.4},title:"Add column",children:(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M12 5v14"}),(0,n.jsx)("path",{d:"M5 12h14"})]})}),l&&"undefined"!=typeof document&&(0,tD.createPortal)((0,n.jsxs)("div",{ref:g,className:"fixed z-[10000] w-[280px] rounded-2xl overflow-hidden animate-in fade-in-0 zoom-in-95 slide-in-from-top-2",style:{top:b.top,left:b.left,background:"var(--color-bg)",border:"1px solid var(--color-border)",boxShadow:"0 8px 32px rgba(0,0,0,0.16), 0 0 1px rgba(0,0,0,0.1)"},onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:[(0,n.jsx)("div",{className:"p-3 pb-2",style:{borderBottom:"1px solid var(--color-border)"},children:(0,n.jsx)("input",{ref:y,type:"text",value:s,onChange:e=>i(e.target.value),onKeyDown:e=>{e.stopPropagation(),"Enter"===e.key&&s.trim()&&N(),"Escape"===e.key&&w()},placeholder:"Column name...",className:"w-full px-2.5 py-1.5 text-sm rounded-lg outline-none",style:{background:"var(--color-surface)",color:"var(--color-text)",border:"1px solid var(--color-border)"}})}),(0,n.jsxs)("div",{className:"p-2",children:[(0,n.jsx)("div",{className:"text-[10px] font-medium uppercase tracking-wider px-1 mb-1.5",style:{color:"var(--color-text-muted)"},children:"Type"}),(0,n.jsx)("div",{className:"grid grid-cols-2 gap-0.5",children:re.map(e=>(0,n.jsxs)("button",{type:"button",onClick:()=>d(e.value),className:"flex items-center gap-2 px-2.5 py-1.5 rounded-xl text-xs transition-all text-left",style:{color:c===e.value?"var(--color-accent)":"var(--color-text)",background:c===e.value?"var(--color-accent-light, rgba(99,102,241,0.08))":"transparent",fontWeight:c===e.value?600:400},children:[(0,n.jsx)(rt,{type:e.value,size:14,className:"shrink-0"}),e.label]},e.value))})]}),"enum"===c&&(0,n.jsx)("div",{className:"px-3 pb-2",children:(0,n.jsx)("input",{type:"text",value:u,onChange:e=>p(e.target.value),onKeyDown:e=>{e.stopPropagation(),"Enter"===e.key&&s.trim()&&N()},placeholder:"Options (comma-separated)",className:"w-full px-2.5 py-1.5 text-sm rounded-lg outline-none",style:{background:"var(--color-surface)",color:"var(--color-text)",border:"1px solid var(--color-border)"}})}),m&&(0,n.jsx)("div",{className:"px-3 pb-2",children:(0,n.jsx)("p",{className:"text-xs",style:{color:"var(--color-error)"},children:m})}),(0,n.jsxs)("div",{className:"flex items-center justify-end gap-2 px-3 py-2.5",style:{borderTop:"1px solid var(--color-border)"},children:[(0,n.jsx)("button",{type:"button",onClick:w,className:"px-3 py-1.5 text-xs rounded-lg transition-colors hover:opacity-70",style:{color:"var(--color-text-muted)"},children:"Cancel"}),(0,n.jsx)("button",{type:"button",onClick:()=>void N(),disabled:h||!s.trim(),className:"px-3 py-1.5 text-xs font-medium rounded-lg transition-colors disabled:opacity-40",style:{background:"var(--color-accent)",color:"white"},children:h?"Creating...":"Create"})]})]}),document.body)]})}let rl=["created_at","Created","createdAt","created"],ra=["updated_at","Updated","updatedAt","updated"],rs=new Set(["select","actions","__add_column"]);function ri(e){return null==e?"":"object"==typeof e?JSON.stringify(e):"string"==typeof e?e:"number"==typeof e||"boolean"==typeof e||"bigint"==typeof e?String(e):""}function rc(e){switch(e){case"number":return"number";case"date":return"date";case"email":return"email";case"phone":return"tel";case"url":return"url";default:return"text"}}function rd(e,t){for(let r of t){let t=e[r];if(null!=t&&""!==t)return t}}function ru(e){if(!e||"object"!=typeof e)return;let t=e.fieldType;return"string"==typeof t?t:void 0}function rp(e){let t=e.getVisibleCells().filter(e=>!rs.has(e.column.id)),r=t.filter(e=>"url"===ru(e.column.columnDef.meta));for(let e of r.length>0?r:t){let t=function(e){let t=t_(e.getValue(),ru(e.column.columnDef.meta));return"link"===t.kind&&"url"===t.linkType?t.faviconUrl:void 0}(e);if(t)return t}}function rh(e){var t;let{value:r,enumValues:o,enumColors:l}=e,a=null!=(t=null==o?void 0:o.indexOf(r))?t:-1,s=a>=0&&l?l[a]:"#94a3b8";return(0,n.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium",style:{background:"".concat(s,"20"),color:s,border:"1px solid ".concat(s,"40")},children:r})}function rx(e){let{value:t}=e,r=!0===t||"true"===t||"1"===t||"yes"===t;return(0,n.jsx)("span",{style:{color:r?"var(--color-success)":"var(--color-text-muted)"},children:r?"Yes":"No"})}function rm(e){var t,r;let{value:o,members:l}=e,a=String(o),s=null==l?void 0:l.find(e=>e.id===a);return(0,n.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,n.jsx)("span",{className:"w-5 h-5 rounded-full flex items-center justify-center text-[10px] font-medium flex-shrink-0",style:{background:"var(--color-accent)",color:"white"},children:(null!=(t=null==s?void 0:s.name)?t:a).charAt(0).toUpperCase()}),(0,n.jsx)("span",{className:"truncate",children:null!=(r=null==s?void 0:s.name)?r:a})]})}function rf(e){let{value:t,field:r,relationLabels:o,onNavigateObject:l,onNavigateEntry:a}=e,s=null==o?void 0:o[r.name],i=function(e){if(!e)return[];let t=e.trim();if(!t)return[];if(t.startsWith("["))try{let e=JSON.parse(t);if(Array.isArray(e))return e.map(String).filter(Boolean)}catch(e){}return[t]}(String(t));return 0===i.length?(0,n.jsx)("span",{style:{color:"var(--color-text-muted)",opacity:.5},children:"--"}):(0,n.jsx)("span",{className:"flex items-center gap-1 flex-wrap",children:i.map(e=>{var t;return(0,n.jsx)("span",{onClick:t=>{if(r.related_object_name&&(a||l)){if(t.stopPropagation(),a)return void a(r.related_object_name,e);null==l||l(r.related_object_name)}},className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-md text-xs font-medium ".concat(r.related_object_name&&(a||l)?"cursor-pointer":""),style:{background:"var(--color-chip-document)",color:"var(--color-chip-document-text)",border:"1px solid var(--color-border)"},children:(0,n.jsx)("span",{className:"truncate max-w-[180px]",children:null!=(t=null==s?void 0:s[e])?t:e})},e)})})}function rv(e){let{tag:t}=e,r=t_(t),o="link"===r.kind&&r.href,l="url"===r.linkType&&!!r.faviconUrl,a="url"===r.linkType||"file"===r.linkType,s={background:"rgba(148, 163, 184, 0.12)",border:"1px solid var(--color-border)"};if(o){let e=(0,n.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs font-medium max-w-[200px]",style:{...s,color:"var(--color-accent)"},children:[l&&(0,n.jsx)(e3,{src:r.faviconUrl,className:"w-3.5 h-3.5 rounded-[3px] shrink-0"}),(0,n.jsx)("span",{className:"min-w-0 truncate",children:r.text}),(0,n.jsx)(tE,{href:r.href,openInNewTab:a,className:"inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-sm hover:bg-black/5"})]});return"url"===r.linkType?(0,n.jsx)(tV,{href:r.href,children:e}):e}return(0,n.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium",style:{...s,color:"var(--color-text-muted)"},children:t})}function rg(e){let{value:t}=e,r=t$(t);return 0===r.length?(0,n.jsx)("span",{style:{color:"var(--color-text-muted)",opacity:.5},children:"--"}):(0,n.jsxs)("span",{className:"flex items-center gap-1 flex-wrap",children:[r.slice(0,5).map(e=>(0,n.jsx)(rv,{tag:e},e)),r.length>5&&(0,n.jsxs)("span",{className:"text-xs",style:{color:"var(--color-text-muted)"},children:["+",r.length-5]})]})}function ry(e){let{value:t,onChange:r,autoFocus:l}=e,a=t$(t),[s,i]=(0,o.useState)(""),c=(0,o.useRef)(null);(0,o.useEffect)(()=>{l&&c.current&&c.current.focus()},[l]);let d=e=>{let t=e.trim();!t||a.includes(t)||(r(JSON.stringify([...a,t])),i(""))},u=e=>{let t=a.filter(t=>t!==e);r(t.length>0?JSON.stringify(t):"")};return(0,n.jsxs)("div",{className:"flex items-center gap-1 flex-wrap min-h-[1.5em]",children:[a.map(e=>(0,n.jsxs)("span",{className:"inline-flex items-center gap-0.5 px-2 py-0.5 rounded-full text-xs font-medium",style:{background:"rgba(148, 163, 184, 0.12)",color:"var(--color-text-muted)",border:"1px solid var(--color-border)"},children:[e,(0,n.jsx)("button",{type:"button",onClick:()=>u(e),className:"ml-0.5 hover:opacity-70",style:{color:"var(--color-text-muted)"},children:(0,n.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[(0,n.jsx)("path",{d:"M18 6 6 18"}),(0,n.jsx)("path",{d:"m6 6 12 12"})]})})]},e)),(0,n.jsx)("input",{ref:c,type:"text",value:s,onChange:e=>i(e.target.value),onKeyDown:e=>{("Enter"===e.key||","===e.key)&&s.trim()&&(e.preventDefault(),d(s)),"Backspace"===e.key&&!s&&a.length>0&&u(a[a.length-1])},onBlur:()=>{s.trim()&&d(s)},placeholder:0===a.length?"Type and press Enter...":"",className:"flex-1 min-w-[80px] text-xs outline-none bg-transparent",style:{color:"var(--color-text)"}})]})}function rb(e){let{links:t,sourceObjectName:r,onNavigateObject:o,onNavigateEntry:l}=e;if(!t||0===t.length)return(0,n.jsx)("span",{style:{color:"var(--color-text-muted)",opacity:.5},children:"--"});let a=t.slice(0,5),s=t.length-a.length;return(0,n.jsxs)("span",{className:"flex items-center gap-1 flex-wrap",children:[a.map(e=>(0,n.jsx)("span",{onClick:t=>{if(l||o){if(t.stopPropagation(),l)return void l(r,e.id);null==o||o(r)}},className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-md text-xs font-medium ".concat(l||o?"cursor-pointer":""),style:{background:"var(--color-chip-database)",color:"var(--color-chip-database-text)",border:"1px solid var(--color-border)"},children:(0,n.jsx)("span",{className:"truncate max-w-[180px]",children:e.label})},e.id)),s>0&&(0,n.jsxs)("span",{className:"text-xs",style:{color:"var(--color-text-muted)"},children:["+",s]})]})}function rj(e){let{value:t,entryId:r,fieldName:l,objectName:a,field:s,members:i,relationLabels:c,onNavigateObject:d,onNavigateEntry:u,onLocalValueChange:p,onSaved:h,showUrlFavicon:x=!1}=e,[m,f]=(0,o.useState)(!1),[v,g]=(0,o.useState)(ri(t)),y=(0,o.useRef)(null),b=(0,o.useRef)(null);(0,o.useEffect)(()=>{m||g(ri(t))},[t,m]),(0,o.useEffect)(()=>{m&&y.current&&y.current.focus()},[m]);let j=!["user"].includes(s.type),k="relation"===s.type&&!!s.related_object_name,w="tags"===s.type,N=(0,o.useCallback)(async e=>{null==p||p(e);try{await fetch("/api/workspace/objects/".concat(encodeURIComponent(a),"/entries/").concat(encodeURIComponent(r)),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({fields:{[l]:e}})}),null==h||h()}catch(e){}},[a,r,l,p,h]),C=e=>{g(e),b.current&&clearTimeout(b.current),b.current=setTimeout(()=>N(e),500)},S=()=>{b.current&&(clearTimeout(b.current),N(v)),f(!1)},M=e=>{"Enter"===e.key&&S(),"Escape"===e.key&&(f(!1),g(ri(t)))};if(!j)return"user"===s.type?(0,n.jsx)(rm,{value:t,members:i}):(0,n.jsx)("span",{className:"truncate block max-w-[300px]",children:ri(t)});if(m){let e;return k?(0,n.jsx)("div",{className:"-mx-3 -my-2 px-3 py-2",style:{background:"var(--color-bg)",boxShadow:"inset 0 0 0 2px var(--color-accent)"},children:(0,n.jsx)(tl,{relatedObjectName:s.related_object_name,value:ri(t),multiple:"many_to_many"===s.relationship_type,onChange:e=>{N(e),f(!1)},variant:"inline",autoFocus:!0})}):w?(0,n.jsx)("div",{className:"-mx-3 -my-2 px-3 py-2",style:{background:"var(--color-bg)",boxShadow:"inset 0 0 0 2px var(--color-accent)"},children:(0,n.jsx)(ry,{value:ri(t),onChange:e=>{N(e)},autoFocus:!0})}):(e="enum"===s.type&&s.enum_values?(0,n.jsxs)("select",{ref:y,value:v,onChange:e=>{C(e.target.value),f(!1)},onBlur:S,onKeyDown:M,className:"w-full text-xs outline-none bg-transparent",style:{color:"var(--color-text)"},children:[(0,n.jsx)("option",{value:"",children:"--"}),s.enum_values.map(e=>(0,n.jsx)("option",{value:e,children:e},e))]}):"boolean"===s.type?(0,n.jsxs)("select",{ref:y,value:v,onChange:e=>{C(e.target.value),f(!1)},onBlur:S,onKeyDown:M,className:"w-full text-xs outline-none bg-transparent",style:{color:"var(--color-text)"},children:[(0,n.jsx)("option",{value:"true",children:"Yes"}),(0,n.jsx)("option",{value:"false",children:"No"})]}):(0,n.jsx)("input",{ref:y,type:rc(s.type),value:v,onChange:e=>C(e.target.value),onBlur:S,onKeyDown:M,className:"w-full text-xs outline-none bg-transparent",style:{color:"var(--color-text)"}}),(0,n.jsx)("div",{className:"-mx-3 -my-2 px-3 py-2",style:{background:"var(--color-bg)",boxShadow:"inset 0 0 0 2px var(--color-accent)"},children:e}))}return k?(0,n.jsx)("div",{onDoubleClick:()=>f(!0),className:"cursor-cell min-h-[1.5em]",title:"Double-click to edit",children:(0,n.jsx)(rf,{value:t,field:s,relationLabels:c,onNavigateObject:d,onNavigateEntry:u})}):w?(0,n.jsx)("div",{onDoubleClick:()=>f(!0),className:"cursor-cell min-h-[1.5em]",title:"Double-click to edit",children:(0,n.jsx)(rg,{value:t})}):(0,n.jsx)("div",{onDoubleClick:()=>f(!0),className:"cursor-cell min-h-[1.5em]",title:"Double-click to edit",children:null==t||""===t?(0,n.jsx)("span",{style:{color:"var(--color-text-muted)",opacity:.5},children:"--"}):"enum"===s.type?(0,n.jsx)(rh,{value:ri(t),enumValues:s.enum_values,enumColors:s.enum_colors}):"boolean"===s.type?(0,n.jsx)(rx,{value:t}):(0,n.jsx)(tG,{value:t,fieldType:s.type,mode:"table",showUrlFavicon:x,linkInteractionMode:"button"})})}function rk(e){if(!e)return[];try{let t=JSON.parse(e);if(t&&Array.isArray(t.actions))return t.actions}catch(e){}return[]}function rw(e){let{objectName:t,fields:r,entries:l,members:a,relationLabels:s,reverseRelations:i,onNavigateToObject:c,onNavigateToEntry:d,onEntryClick:u,onRefresh:p,activeEntryId:h,columnVisibility:x,onColumnVisibilityChanged:m,columnSizing:f,onColumnSizingChanged:v,serverPagination:g,onServerSearch:y}=e,[b,j]=(0,o.useState)({}),[k,w]=(0,o.useState)(!1),[N,C]=(0,o.useState)(l),[S,M]=(0,o.useState)(null),{executeBulkAction:L,bulkStates:T}=function(){let[e,t]=(0,o.useState)(new Map),[r,n]=(0,o.useState)(new Map),l=(0,o.useCallback)((t,r)=>{var n;return null!=(n=e.get("".concat(t,"_").concat(r)))?n:{status:"idle"}},[e]),a=(0,o.useCallback)((e,r,n)=>{t(t=>{let o=new Map(t);return o.set("".concat(e,"_").concat(r),n),o})},[]),s=(0,o.useCallback)(async(e,t,r,o,l)=>{var s,i,c,d,u,p,h;let x=o.length,m=0,f=0,v=x;for(let t of o)a(e.id,t,{status:"loading"});n(t=>{let r=new Map(t);return r.set(e.id,{status:"running",running:v,succeeded:m,failed:f,total:x}),r});try{let p=await fetch("/api/workspace/objects/".concat(encodeURIComponent(r),"/actions"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({actionId:e.id,fieldId:t,entryIds:o})});if(!p.ok){n(t=>{let r=new Map(t);return r.set(e.id,{status:"done",running:0,succeeded:0,failed:x,total:x}),r}),null==l||null==(i=l.onToast)||i.call(l,"".concat(e.label," failed to start"),{type:"error"});return}let h=null==(s=p.body)?void 0:s.getReader();if(!h)return;let g=new TextDecoder,y="";for(;;){let{done:t,value:r}=await h.read();if(t)break;let o=(y+=g.decode(r,{stream:!0})).split("\n");for(let t of(y=null!=(c=o.pop())?c:"",o))if(t.startsWith("data: "))try{let r=JSON.parse(t.slice(6));if("progress"===r.type&&r.entryId)a(e.id,r.entryId,{status:"loading",progress:{percent:r.percent,message:r.message}});else if("completed"===r.type&&r.entryId){v--,"success"===r.status?(m++,a(e.id,r.entryId,{status:"success",result:r.result})):(f++,a(e.id,r.entryId,{status:"error",error:r.error})),n(t=>{let r=new Map(t);return r.set(e.id,{status:v>0?"running":"done",running:v,succeeded:m,failed:f,total:x}),r});let t=null!=(u=null!=(d=null==l?void 0:l.autoResetMs)?d:e.autoResetMs)?u:3e3;setTimeout(()=>{a(e.id,r.entryId,{status:"idle"})},t)}}catch(e){}}}catch(e){}n(t=>{let r=new Map(t);return r.set(e.id,{status:"done",running:0,succeeded:m,failed:f,total:x}),r}),f>0?null==l||null==(p=l.onToast)||p.call(l,"".concat(e.label,": ").concat(m," succeeded, ").concat(f," failed"),{type:"error"}):m>0&&(null==l||null==(h=l.onToast)||h.call(l,"".concat(e.label,": ").concat(m," entries completed"),{type:"success"})),setTimeout(()=>{n(t=>{let r=new Map(t);return r.delete(e.id),r})},5e3)},[a]);return{getState:l,setState:a,executeBulkAction:s,bulkStates:r}}(),I=t8(),[R,_]=(0,o.useState)(null),E=(0,o.useMemo)(()=>r.filter(e=>"action"!==e.type),[r]),D=(0,o.useMemo)(()=>r.filter(e=>"action"===e.type),[r]),A=(0,o.useMemo)(()=>{let e=[];for(let t of D)for(let r of rk(t.default_value))e.push({action:r,fieldId:t.id});return e},[D]);(0,o.useEffect)(()=>{C(l)},[l]);let W=(0,o.useCallback)((e,t,r)=>{C(n=>n.map(n=>{let o=n.entry_id;return String(null!=o&&"object"==typeof o?JSON.stringify(o):null!=o?o:"")!==e?n:{...n,[t]:r}}))},[]),B=(0,o.useMemo)(()=>i?i.filter(e=>Object.keys(e.entries).length>0):[],[i]),F=(0,o.useCallback)(async e=>{let n=new Set(r.map(e=>e.id)),o=e.filter(e=>n.has(e));try{await fetch("/api/workspace/objects/".concat(encodeURIComponent(t),"/fields/reorder"),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({fieldOrder:o})})}catch(e){}},[t,r]),P=(0,o.useCallback)(async(e,r)=>{try{(await fetch("/api/workspace/objects/".concat(encodeURIComponent(t),"/fields/").concat(encodeURIComponent(e)),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:r})})).ok&&(null==p||p())}catch(e){}_(null)},[t,p]),z=(0,o.useCallback)((e,r)=>{M({open:!0,title:'Delete "'.concat(r,'" column?'),message:"This will permanently remove this column and all its data from every entry. This cannot be undone.",variant:"destructive",confirmLabel:"Delete column",onConfirm:async()=>{M(null);try{await fetch("/api/workspace/objects/".concat(encodeURIComponent(t),"/fields/").concat(encodeURIComponent(e)),{method:"DELETE"}),null==p||p()}catch(e){}}})},[t,p]),O=(0,o.useCallback)((e,t)=>{let r=E.map(e=>e.id),n=r.indexOf(e);if("left"===t&&n>0){let e=[...r];[e[n],e[n-1]]=[e[n-1],e[n]],F(e)}else if("right"===t&&n<r.length-1){let e=[...r];[e[n],e[n+1]]=[e[n+1],e[n]],F(e)}},[E,F]),U=(0,o.useMemo)(()=>{let e=E.map((e,r)=>({id:e.id,accessorKey:e.name,meta:{label:e.name,fieldName:e.name,fieldType:e.type},header:t=>{let{column:o}=t;return R===e.id?(0,n.jsx)(rn,{currentName:e.name,onSave:t=>void P(e.id,t),onCancel:()=>_(null)}):(0,n.jsxs)("span",{className:"flex items-center gap-1.5 w-full",style:{color:"var(--color-text-muted)"},children:[(0,n.jsx)(rt,{type:e.type,size:12,className:"shrink-0 opacity-50"}),(0,n.jsx)("span",{className:"truncate",children:e.name}),"relation"===e.type&&e.related_object_name&&(0,n.jsxs)("span",{className:"text-[9px] font-normal normal-case tracking-normal opacity-60 shrink-0",children:["(",e.related_object_name,")"]}),(0,n.jsx)(rr,{field:e,sortDirection:o.getIsSorted(),onSort:e=>o.toggleSorting(e),onHide:()=>o.toggleVisibility(!1),onRename:()=>_(e.id),onDelete:()=>z(e.id,e.name),canMoveLeft:r>0,canMoveRight:r<E.length-1,onMoveLeft:()=>O(e.id,"left"),onMoveRight:()=>O(e.id,"right")})]})},cell:o=>{let l=o.row.original.entry_id,i=String(null!=l&&"object"==typeof l?JSON.stringify(l):null!=l?l:"");if(0===r&&u){let e=o.getValue(),t=null==e||""===e?"--":ri(e),r="--"===t;return(0,n.jsx)("span",{className:"font-semibold truncate block max-w-[300px] ".concat(r?"":"cursor-pointer hover:underline"),style:{color:r?"var(--color-text-muted)":"var(--color-accent)",opacity:r?.5:1},onClick:e=>{e.stopPropagation(),i&&!r&&u(i)},children:t})}return(0,n.jsx)(rj,{value:o.getValue(),entryId:i,fieldName:e.name,objectName:t,field:e,members:a,relationLabels:s,onNavigateObject:c,onNavigateEntry:d,onLocalValueChange:t=>W(i,e.name,t),onSaved:p,showUrlFavicon:0!==r})},size:"richtext"===e.type?300:"relation"===e.type||"tags"===e.type?220:200,enableSorting:!0}));for(let t of(e.push({id:"created_at",accessorFn:e=>rd(e,rl),meta:{label:"Created",fieldName:"created_at",fieldType:"date"},header:()=>(0,n.jsx)("span",{className:"flex items-center gap-1",style:{color:"var(--color-text-muted)"},children:"Created"}),cell:e=>(0,n.jsx)(tG,{value:e.getValue(),fieldType:"date",mode:"table"}),size:190,enableSorting:!0}),e.push({id:"updated_at",accessorFn:e=>rd(e,ra),meta:{label:"Updated",fieldName:"updated_at",fieldType:"date"},header:()=>(0,n.jsx)("span",{className:"flex items-center gap-1",style:{color:"var(--color-text-muted)"},children:"Updated"}),cell:e=>(0,n.jsx)(tG,{value:e.getValue(),fieldType:"date",mode:"table"}),size:190,enableSorting:!0}),B))e.push({id:"rev_".concat(t.sourceObjectName,"_").concat(t.fieldName),meta:{label:"".concat(t.sourceObjectName," (via ").concat(t.fieldName,")"),fieldType:"relation"},header:()=>(0,n.jsxs)("span",{className:"flex items-center gap-1.5",style:{color:"var(--color-text-muted)"},children:[(0,n.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{opacity:.4},children:[(0,n.jsx)("path",{d:"m12 19-7-7 7-7"}),(0,n.jsx)("path",{d:"M19 12H5"})]}),(0,n.jsx)("span",{className:"capitalize",children:t.sourceObjectName}),(0,n.jsxs)("span",{className:"text-[9px] font-normal normal-case tracking-normal opacity-50",children:["via ",t.fieldName]})]}),cell:e=>{var r;let o=e.row.original.entry_id,l=String(null!=o&&"object"==typeof o?JSON.stringify(o):null!=o?o:""),a=null!=(r=t.entries[l])?r:[];return(0,n.jsx)(rb,{links:a,sourceObjectName:t.sourceObjectName,onNavigateObject:c,onNavigateEntry:d})},enableSorting:!1,size:200});for(let r of D){let o=rk(r.default_value);0!==o.length&&e.push({id:"action_".concat(r.id),meta:{label:r.name,fieldName:r.name,fieldType:"action"},header:()=>(0,n.jsx)("span",{className:"flex items-center gap-1",style:{color:"var(--color-text-muted)"},children:r.name}),cell:e=>{let l=e.row.original.entry_id,a=String(null!=l&&"object"==typeof l?JSON.stringify(l):null!=l?l:"");return(0,n.jsx)("div",{className:"flex items-center gap-1",onClick:e=>e.stopPropagation(),children:o.map(e=>(0,n.jsx)(t1,{action:e,entryId:a,objectName:t,fieldId:r.id,compact:o.length>1,onToast:I,onRequestConfirm:(e,t,r)=>{var n;M({open:!0,title:e.label,message:null!=(n=e.confirmMessage)?n:'Run "'.concat(e.label,'" on this entry?'),variant:"destructive"===e.variant?"destructive":"default",confirmLabel:e.label,onConfirm:()=>{M(null),r()}})}},e.id))})},enableSorting:!1,enableHiding:!0,size:Math.max(100,100*o.length)})}return e.push({id:"__add_column",header:()=>(0,n.jsx)(ro,{objectName:t,onCreated:()=>null==p?void 0:p()}),cell:()=>null,size:44,minSize:44,enableSorting:!1,enableHiding:!1,enableResizing:!1}),e},[E,D,B,t,a,s,c,d,p,I,R,P,z,O]),H=(0,o.useCallback)(()=>{w(!0)},[]),V=(0,o.useCallback)(()=>Object.keys(b).filter(e=>b[e]).map(e=>{var t;return ri(null==(t=N[Number(e)])?void 0:t.entry_id)}).filter(Boolean),[b,N]),K=(0,o.useCallback)(async()=>{let e=V();if(0!==e.length)try{await fetch("/api/workspace/objects/".concat(encodeURIComponent(t),"/entries/bulk-delete"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({entryIds:e})}),j({}),null==p||p()}catch(e){}},[V,t,p]),J=(0,o.useCallback)(()=>{let e=V().length;0!==e&&M({open:!0,title:"Delete ".concat(e," ").concat(1===e?"entry":"entries","?"),message:"This action cannot be undone. All selected entries will be permanently removed.",variant:"destructive",confirmLabel:"Delete",onConfirm:()=>{M(null),K()}})},[V,K]),q=(0,o.useCallback)(e=>{let r=e.entry_id,n=String(null!=r&&"object"==typeof r?JSON.stringify(r):null!=r?r:"");n&&M({open:!0,title:"Delete this entry?",message:"This action cannot be undone.",variant:"destructive",confirmLabel:"Delete",onConfirm:async()=>{M(null);try{await fetch("/api/workspace/objects/".concat(encodeURIComponent(t),"/entries/").concat(encodeURIComponent(n)),{method:"DELETE"}),null==p||p()}catch(e){}}})},[t,p]),G=(0,o.useCallback)((e,r)=>{let n=V();if(0===n.length)return;let o=()=>void L(e,r,t,n,{autoResetMs:e.autoResetMs,onToast:I});e.confirmMessage?M({open:!0,title:"".concat(e.label," (").concat(n.length," entries)"),message:e.confirmMessage,variant:"destructive"===e.variant?"destructive":"default",confirmLabel:e.label,onConfirm:()=>{M(null),o()}}):o()},[V,t,L,I]),$=(0,o.useCallback)(e=>{let t=[];return u&&t.push({label:"View details",onClick:e=>{var t;let r=String(null!=(t=e.entry_id)?t:"");r&&u(r)},icon:(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"}),(0,n.jsx)("circle",{cx:"12",cy:"12",r:"3"})]})}),t.push({label:"Delete",variant:"destructive",onClick:q,icon:(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("path",{d:"M3 6h18"}),(0,n.jsx)("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),(0,n.jsx)("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]})}),t},[u,q]),Z=Object.keys(b).filter(e=>b[e]).length;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(e9,{columns:U,data:N,enableSorting:!0,enableGlobalFilter:!0,enableRowSelection:!0,enableColumnReordering:!0,rowSelection:b,onRowSelectionChange:j,onColumnReorder:F,searchPlaceholder:"Search ".concat(t,"..."),onRefresh:p,onAdd:H,addButtonLabel:"+ Add",rowActions:$,stickyFirstColumn:!0,activeRowId:h,getRowId:e=>{var t;return String(null!=(t=e.entry_id)?t:"")},initialColumnVisibility:x,onColumnVisibilityChanged:m,initialColumnSizing:f,onColumnSizingChange:v,serverPagination:g,onServerSearch:y,getFirstDataColumnFaviconUrl:rp}),(0,n.jsx)(t3,{selectedCount:Z,actions:A,onDeselectAll:()=>j({}),onBulkAction:G,onBulkDelete:J,bulkRunStates:T}),S&&(0,n.jsx)(t2,{open:S.open,title:S.title,message:S.message,variant:S.variant,confirmLabel:S.confirmLabel,onConfirm:S.onConfirm,onCancel:()=>M(null)}),k&&(0,n.jsx)(rN,{objectName:t,fields:E,members:a,onClose:()=>w(!1),onSaved:p})]})}function rN(e){let{objectName:t,fields:r,members:l,onClose:a,onSaved:s}=e,[i,c]=(0,o.useState)({}),[d,u]=(0,o.useState)(!1),p=(0,o.useRef)(null);(0,o.useEffect)(()=>{let e=e=>{"Escape"===e.key&&a()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[a]);let h=(e,t)=>{c(r=>({...r,[e]:t}))},x=async()=>{u(!0);try{(await fetch("/api/workspace/objects/".concat(encodeURIComponent(t),"/entries"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fields:i})})).ok&&(null==s||s(),a())}catch(e){}finally{u(!1)}};return(0,n.jsx)("div",{ref:p,onClick:e=>{e.target===p.current&&a()},className:"fixed inset-0 z-50 flex items-start justify-center",style:{background:"rgba(0, 0, 0, 0.5)",backdropFilter:"blur(2px)"},children:(0,n.jsxs)("div",{className:"relative mt-4 mb-4 mx-3 md:mt-12 md:mb-12 md:mx-0 w-full max-w-lg rounded-2xl overflow-hidden shadow-2xl flex flex-col",style:{background:"var(--color-bg)",border:"1px solid var(--color-border)",maxHeight:"calc(100vh - 6rem)"},children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-6 py-4 border-b flex-shrink-0",style:{borderColor:"var(--color-border)"},children:[(0,n.jsxs)("h2",{className:"text-lg font-semibold capitalize",style:{color:"var(--color-text)"},children:["Add ",t]}),(0,n.jsx)("button",{type:"button",onClick:a,className:"p-1.5 rounded-lg",style:{color:"var(--color-text-muted)"},children:(0,n.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M18 6 6 18"}),(0,n.jsx)("path",{d:"m6 6 12 12"})]})})]}),(0,n.jsx)("form",{onSubmit:e=>{e.preventDefault(),x()},className:"flex-1 overflow-y-auto px-6 py-5 space-y-4",children:r.map(e=>{var t,r,o,a,s,c,d;let u="relation"===e.type,p="user"===e.type;return(0,n.jsxs)("div",{children:[(0,n.jsxs)("label",{className:"block text-xs font-medium uppercase tracking-wider mb-1.5",style:{color:"var(--color-text-muted)"},children:[e.name,u&&e.related_object_name&&(0,n.jsxs)("span",{className:"normal-case tracking-normal font-normal opacity-60 ml-1",children:["(",e.related_object_name,")"]})]}),"tags"===e.type?(0,n.jsx)("div",{className:"w-full px-3 py-2 text-sm rounded-lg",style:{background:"var(--color-surface)",border:"1px solid var(--color-border)"},children:(0,n.jsx)(ry,{value:null!=(t=i[e.name])?t:"",onChange:t=>h(e.name,t)})}):"enum"===e.type&&e.enum_values?(0,n.jsxs)("select",{value:null!=(r=i[e.name])?r:"",onChange:t=>h(e.name,t.target.value),className:"w-full px-3 py-2 text-sm rounded-lg outline-none",style:{background:"var(--color-surface)",color:"var(--color-text)",border:"1px solid var(--color-border)"},children:[(0,n.jsx)("option",{value:"",children:"-- Select --"}),e.enum_values.map(e=>(0,n.jsx)("option",{value:e,children:e},e))]}):"boolean"===e.type?(0,n.jsxs)("select",{value:null!=(o=i[e.name])?o:"",onChange:t=>h(e.name,t.target.value),className:"w-full px-3 py-2 text-sm rounded-lg outline-none",style:{background:"var(--color-surface)",color:"var(--color-text)",border:"1px solid var(--color-border)"},children:[(0,n.jsx)("option",{value:"",children:"-- Select --"}),(0,n.jsx)("option",{value:"true",children:"Yes"}),(0,n.jsx)("option",{value:"false",children:"No"})]}):"richtext"===e.type?(0,n.jsx)("textarea",{value:null!=(a=i[e.name])?a:"",onChange:t=>h(e.name,t.target.value),rows:3,className:"w-full px-3 py-2 text-sm rounded-lg outline-none resize-none",style:{background:"var(--color-surface)",color:"var(--color-text)",border:"1px solid var(--color-border)"},placeholder:e.name}):u&&e.related_object_name?(0,n.jsx)(tl,{relatedObjectName:e.related_object_name,value:null!=(s=i[e.name])?s:"",multiple:"many_to_many"===e.relationship_type,onChange:t=>h(e.name,t),placeholder:"Select ".concat(e.related_object_name,"...")}):p?(0,n.jsxs)("select",{value:null!=(c=i[e.name])?c:"",onChange:t=>h(e.name,t.target.value),className:"w-full px-3 py-2 text-sm rounded-lg outline-none",style:{background:"var(--color-surface)",color:"var(--color-text)",border:"1px solid var(--color-border)"},children:[(0,n.jsx)("option",{value:"",children:"-- Select member --"}),null==l?void 0:l.map(e=>(0,n.jsx)("option",{value:e.id,children:e.name},e.id))]}):(0,n.jsx)("input",{type:rc(e.type),value:null!=(d=i[e.name])?d:"",onChange:t=>h(e.name,t.target.value),className:"w-full px-3 py-2 text-sm rounded-lg outline-none",style:{background:"var(--color-surface)",color:"var(--color-text)",border:"1px solid var(--color-border)"},placeholder:e.name})]},e.id)})}),(0,n.jsxs)("div",{className:"flex items-center justify-end gap-2 px-6 py-4 border-t flex-shrink-0",style:{borderColor:"var(--color-border)"},children:[(0,n.jsx)("button",{type:"button",onClick:a,className:"px-4 py-2 text-sm rounded-lg",style:{color:"var(--color-text-muted)",border:"1px solid var(--color-border)"},children:"Cancel"}),(0,n.jsx)("button",{type:"button",onClick:()=>void x(),disabled:d,className:"px-4 py-2 text-sm font-medium rounded-lg",style:{background:"var(--color-accent)",color:"white",opacity:d?.7:1},children:d?"Saving...":"Save"})]})]})})}function rC(e,t){for(let r of[...t.filter(e=>"url"===e.type),...t.filter(e=>"url"!==e.type)]){let t=function(e,t){let r=t_(e,t);if("link"===r.kind&&"url"===r.linkType&&r.href&&r.faviconUrl)return{href:r.href,text:r.text,faviconUrl:r.faviconUrl}}(e[r.name],r.type);if(t)return t}}function rS(e){return null==e?"":"object"==typeof e?JSON.stringify(e):"string"==typeof e?e:"number"==typeof e||"boolean"==typeof e||"bigint"==typeof e?String(e):""}function rM(e){let{entry:t,fields:r,members:o,relationLabels:l,onEntryClick:a,objectName:s,onToast:i}=e,d=rS(t.entry_id)||"",{attributes:u,listeners:p,setNodeRef:h,isDragging:x}=(0,c.PM)({id:d,data:{entry:t}});return(0,n.jsx)("div",{ref:h,...p,...u,onClick:e=>{!x&&a&&(e.stopPropagation(),a(d))},className:"rounded-lg p-3 mb-2 transition-all duration-100 cursor-grab active:cursor-grabbing select-none",style:{background:"var(--color-surface)",border:"1px solid ".concat(x?"var(--color-accent)":"var(--color-border)"),opacity:x?.4:1,transform:x?"scale(1.02)":void 0},children:(0,n.jsx)(rL,{entry:t,fields:r,members:o,relationLabels:l,objectName:s,onToast:i})})}function rL(e){let{entry:t,fields:r,members:o,relationLabels:l,objectName:a,onToast:s}=e,i=function(e,t){var r;let n=t.find(e=>e.name.toLowerCase().includes("name")||e.name.toLowerCase().includes("title"));return n?rS(e[n.name])||"Untitled":rS(e[null==(r=t[0])?void 0:r.name])||"Untitled"}(t,r),c=rC(t,r),d=r.filter(e=>"action"===e.type),u=r.filter(e=>"action"!==e.type).filter(e=>"richtext"!==e.type&&null!==t[e.name]&&void 0!==t[e.name]&&""!==t[e.name]).slice(0,4),p=r.find(e=>e.name.toLowerCase().includes("name")||e.name.toLowerCase().includes("title"));return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 mb-1.5 min-w-0",style:{color:"var(--color-text)"},children:[(null==c?void 0:c.faviconUrl)&&(0,n.jsx)(e3,{src:c.faviconUrl,className:"w-4 h-4 rounded-[4px] shrink-0"}),(0,n.jsx)("div",{className:"text-sm font-medium truncate min-w-0",children:i})]}),(0,n.jsx)("div",{className:"space-y-1",children:u.filter(e=>e!==p).slice(0,3).map(e=>{let r=t[e.name];if(!r)return null;let a=rS(r);if("user"===e.type){let e=null==o?void 0:o.find(e=>e.id===a);e&&(a=e.name)}else if("relation"===e.type){let t=null==l?void 0:l[e.name];a=(function(e){if(!e)return[];let t=e.trim();if(!t)return[];if(t.startsWith("["))try{let e=JSON.parse(t);if(Array.isArray(e))return e.map(String).filter(Boolean)}catch(e){}return[t]})(a).map(e=>{var r;return null!=(r=null==t?void 0:t[e])?r:e}).join(", ")}let s="tags"===e.type?t$(r):[];return(0,n.jsxs)("div",{className:"flex items-center gap-1.5 text-xs",children:[(0,n.jsxs)("span",{style:{color:"var(--color-text-muted)"},children:[e.name,":"]}),"enum"===e.type?(0,n.jsx)(rT,{value:rS(r),enumValues:e.enum_values,enumColors:e.enum_colors}):"tags"===e.type?(0,n.jsxs)("span",{className:"flex items-center gap-0.5 flex-wrap",children:[s.slice(0,3).map(e=>{let t=t_(e),r="link"===t.kind&&t.href,o="url"===t.linkType&&!!t.faviconUrl;return r?(0,n.jsxs)("a",{href:t.href,target:"url"===t.linkType||"file"===t.linkType?"_blank":void 0,rel:"url"===t.linkType||"file"===t.linkType?"noopener noreferrer":void 0,onClick:e=>e.stopPropagation(),className:"inline-flex items-center gap-1 px-1.5 py-0 rounded text-[11px] font-medium hover:underline underline-offset-2 max-w-[220px]",style:{background:"rgba(148, 163, 184, 0.12)",color:"var(--color-accent)"},children:[o&&(0,n.jsx)(e3,{src:t.faviconUrl,className:"w-3 h-3 rounded-[2px] shrink-0"}),(0,n.jsx)("span",{className:"min-w-0 truncate",children:t.text})]},e):(0,n.jsx)("span",{className:"inline-flex items-center px-1.5 py-0 rounded text-[11px] font-medium",style:{background:"rgba(148, 163, 184, 0.12)",color:"var(--color-text-muted)"},children:e},e)}),s.length>3&&(0,n.jsxs)("span",{style:{color:"var(--color-text-muted)",opacity:.6},children:["+",s.length-3]})]}):"relation"===e.type?(0,n.jsxs)("span",{className:"truncate inline-flex items-center gap-0.5",style:{color:"#60a5fa"},children:[(0,n.jsxs)("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:"flex-shrink-0",style:{opacity:.5},children:[(0,n.jsx)("path",{d:"M7 7h10v10"}),(0,n.jsx)("path",{d:"M7 17 17 7"})]}),a]}):(0,n.jsx)("span",{className:"whitespace-pre-line line-clamp-2",style:{color:"var(--color-text)"},children:a})]},e.id)})}),a&&d.length>0&&(0,n.jsx)("div",{className:"flex items-center gap-1 mt-2 pt-1.5",style:{borderTop:"1px solid var(--color-border)"},onClick:e=>e.stopPropagation(),children:d.flatMap(e=>(function(e){if(!e)return[];try{let t=JSON.parse(e);if(t&&Array.isArray(t.actions))return t.actions}catch(e){}return[]})(e.default_value).map(r=>{var o;return(0,n.jsx)(t1,{action:r,entryId:String(null!=(o=t.entry_id)?o:""),objectName:a,fieldId:e.id,compact:!0,onToast:s},"".concat(e.id,"_").concat(r.id))}))})]})}function rT(e){var t;let{value:r,enumValues:o,enumColors:l}=e,a=null!=(t=null==o?void 0:o.indexOf(r))?t:-1,s=a>=0&&l?l[a]:"#94a3b8";return(0,n.jsx)("span",{className:"inline-flex items-center px-1.5 py-0 rounded text-[11px] font-medium",style:{background:"".concat(s,"20"),color:s},children:r})}function rI(e){let{columnName:t,color:r,items:l,cardFields:a,members:s,relationLabels:i,onEntryClick:d,isOver:u,groupFieldId:p,objectName:h,onRefresh:x,onToast:m}=e,{setNodeRef:f}=(0,c.zM)({id:"column:".concat(t)}),[v,g]=(0,o.useState)(!1),[y,b]=(0,o.useState)(t),[j,k]=(0,o.useState)(!1),w=(0,o.useRef)(null);(0,o.useEffect)(()=>{v&&w.current&&(w.current.focus(),w.current.select())},[v]);let N=(0,o.useCallback)(async()=>{let e=y.trim();if(!e||e===t||!p){g(!1),b(t);return}k(!0);try{(await fetch("/api/workspace/objects/".concat(encodeURIComponent(h),"/fields/").concat(encodeURIComponent(p),"/enum-rename"),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldValue:t,newValue:e})})).ok?null==x||x():b(t)}catch(e){b(t)}finally{k(!1),g(!1)}},[y,t,p,h,x]);return(0,n.jsxs)("div",{ref:f,className:"flex-shrink-0 flex flex-col rounded-xl transition-colors duration-150",style:{width:"280px",background:u?"var(--color-surface)":"var(--color-bg)",border:"1px solid ".concat(u?"var(--color-accent)":"var(--color-border)")},children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2.5 border-b",style:{borderColor:"var(--color-border)"},children:[(0,n.jsx)("span",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0",style:{background:r}}),v?(0,n.jsx)("input",{ref:w,value:y,onChange:e=>b(e.target.value),onBlur:N,onKeyDown:e=>{"Enter"===e.key&&N(),"Escape"===e.key&&(b(t),g(!1))},disabled:j,className:"text-sm font-medium flex-1 bg-transparent outline-none rounded px-1 -mx-1",style:{color:"var(--color-text)",border:"1px solid var(--color-accent)"}}):(0,n.jsx)("span",{className:"text-sm font-medium flex-1 cursor-text rounded px-1 -mx-1 hover:bg-[var(--color-surface-hover)] transition-colors",style:{color:"var(--color-text)"},onDoubleClick:()=>{p&&(b(t),g(!0))},title:p?"Double-click to rename":void 0,children:t}),(0,n.jsx)("span",{className:"text-xs px-1.5 py-0.5 rounded-full",style:{background:"var(--color-surface)",color:"var(--color-text-muted)"},children:l.length})]}),(0,n.jsx)("div",{className:"flex-1 overflow-y-auto p-2",style:{minHeight:"80px"},children:0===l.length?(0,n.jsx)("div",{className:"flex items-center justify-center py-8 rounded-lg border border-dashed text-xs transition-colors",style:{borderColor:u?"var(--color-accent)":"var(--color-border)",color:u?"var(--color-accent)":"var(--color-text-muted)"},children:u?"Drop here":"No entries"}):l.map((e,t)=>(0,n.jsx)(rM,{entry:e,fields:a,members:s,relationLabels:i,onEntryClick:d,objectName:h,onToast:m},rS(e.entry_id)||String(t)))})]})}function rR(e){var t;let{objectName:r,fields:l,entries:a,statuses:s,members:i,relationLabels:d,onEntryClick:u,onRefresh:p}=e,h=t8(),[x,m]=(0,o.useState)(null),[f,v]=(0,o.useState)(null),[g,y]=(0,o.useState)(a);(0,o.useEffect)(()=>{y(a)},[a]);let b=(0,c.FR)((0,c.MS)(c.AN,{activationConstraint:{distance:5}})),j=(0,o.useMemo)(()=>{var e;let t=l.find(e=>"enum"===e.type&&e.name.toLowerCase().includes("status"));return t||(null!=(e=l.find(e=>"enum"===e.type))?e:null)},[l]),k=(0,o.useMemo)(()=>{if(s.length>0)return s.map(e=>{var t;return{name:e.name,color:null!=(t=e.color)?t:"#94a3b8"}});if(null==j?void 0:j.enum_values)return j.enum_values.map((e,t)=>{var r,n;return{name:e,color:null!=(n=null==(r=j.enum_colors)?void 0:r[t])?n:"#94a3b8"}});let e=new Set;for(let t of g){let r=j?t[j.name]:void 0;r&&e.add(rS(r))}return Array.from(e).map(e=>({name:e,color:"#94a3b8"}))},[s,j,g]),w=(0,o.useMemo)(()=>{let e={};for(let t of k)e[t.name]=[];for(let t of(e._ungrouped=[],g)){let r=j?rS(t[j.name]):"";e[r]?e[r].push(t):e._ungrouped.push(t)}return e},[k,g,j]),N=l.filter(e=>e!==j),C=(0,o.useMemo)(()=>{var e;return x&&null!=(e=g.find(e=>String(e.entry_id)===x))?e:null},[x,g]),S=(0,o.useCallback)(e=>{m(String(e.active.id))},[]),M=(0,o.useCallback)(e=>{var t;let r=(null==(t=e.over)?void 0:t.id)?String(e.over.id):null;(null==r?void 0:r.startsWith("column:"))?v(r.replace("column:","")):v(null)},[]),L=(0,o.useCallback)(async e=>{m(null),v(null);let{active:t,over:n}=e;if(!n||!j)return;let o=String(n.id);if(!o.startsWith("column:"))return;let l=o.replace("column:",""),a=String(t.id),s=g.find(e=>String(e.entry_id)===a);if(!s)return;let i=rS(s[j.name]);if(i!==l){y(e=>e.map(e=>String(e.entry_id)===a?{...e,[j.name]:l}:e));try{(await fetch("/api/workspace/objects/".concat(encodeURIComponent(r),"/entries/").concat(encodeURIComponent(a)),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({fields:{[j.name]:l}})})).ok?null==p||p():y(e=>e.map(e=>String(e.entry_id)===a?{...e,[j.name]:i}:e))}catch(e){y(e=>e.map(e=>String(e.entry_id)===a?{...e,[j.name]:i}:e))}}},[j,g,r,p]);return j?(0,n.jsxs)(c.Mp,{sensors:b,collisionDetection:c.y$,onDragStart:S,onDragOver:M,onDragEnd:L,children:[(0,n.jsxs)("div",{className:"flex gap-4 overflow-x-auto pb-4 px-1",style:{minHeight:"400px"},children:[k.map(e=>{var t;return(0,n.jsx)(rI,{columnName:e.name,color:e.color,items:null!=(t=w[e.name])?t:[],cardFields:N,members:i,relationLabels:d,onEntryClick:u,isOver:f===e.name,groupFieldId:j.id,objectName:r,onRefresh:p,onToast:h},e.name)}),(null==(t=w._ungrouped)?void 0:t.length)>0&&(0,n.jsxs)("div",{className:"flex-shrink-0 flex flex-col rounded-xl",style:{width:"280px",background:"var(--color-bg)",border:"1px dashed var(--color-border)"},children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2.5 border-b",style:{borderColor:"var(--color-border)"},children:[(0,n.jsx)("span",{className:"text-sm font-medium",style:{color:"var(--color-text-muted)"},children:"Ungrouped"}),(0,n.jsx)("span",{className:"text-xs px-1.5 py-0.5 rounded-full",style:{background:"var(--color-surface)",color:"var(--color-text-muted)"},children:w._ungrouped.length})]}),(0,n.jsx)("div",{className:"flex-1 overflow-y-auto p-2",children:w._ungrouped.map((e,t)=>(0,n.jsx)(rM,{entry:e,fields:N,members:i,relationLabels:d,onEntryClick:u,objectName:r,onToast:h},rS(e.entry_id)||String(t)))})]})]}),(0,n.jsx)(c.Hd,{dropAnimation:null,children:C?(0,n.jsx)("div",{className:"rounded-lg p-3 shadow-xl",style:{width:"260px",background:"var(--color-surface)",border:"1px solid var(--color-accent)",transform:"rotate(2deg)"},children:(0,n.jsx)(rL,{entry:C,fields:N,members:i,objectName:r,relationLabels:d,onToast:h})}):null})]}):(0,n.jsx)("div",{className:"flex flex-col items-center justify-center py-20 gap-3",children:(0,n.jsxs)("p",{className:"text-sm",style:{color:"var(--color-text-muted)"},children:["No enum field found for kanban grouping in"," ",(0,n.jsx)("span",{className:"font-medium",style:{color:"var(--color-text)"},children:r})]})})}var r_=r(70739),rE=r(30489),rD=r(75885),rA=r(65316),rW=r(1059),rB=r(38804),rF=r(45609),rP=r(98540),rz=r(14716),rO=r(92423),rU=r(3904),rH=r(67977),rV=r(39682),rK=r(99509),rJ=r(89748),rq=r(25277),rG=r(67697),r$=r(77894),rZ=r(74575),rY=r(76149),rQ=r(49054),rX=r(67034),r0=r(12904),r1=r(84373),r2=r(65440),r4=r(75096);function r5(e){return null==e?"":"string"==typeof e?e:"number"==typeof e||"boolean"==typeof e||"bigint"==typeof e?String(e):"object"==typeof e?JSON.stringify(e):""}function r3(e){return(0,rE.GP)(e,"yyyy-MM-dd")}function r6(e){return e.toISOString()}function r8(e,t,r){switch(t){case"day":return 1===r?(0,rD.f)(e,1):(0,rA.e)(e,1);case"week":return 1===r?(0,rW.J)(e,1):(0,rB.k)(e,1);case"month":return 1===r?(0,rF.P)(e,1):(0,rP.a)(e,1);case"year":return 1===r?(0,rz.e)(e,1):(0,rO.d)(e,1)}}function r7(e){var t;let{event:r,compact:o,onClick:l,draggable:a,onDragStart:s}=e,i=null!=(t=r.color)?t:"var(--color-accent)";return(0,n.jsx)("button",{type:"button",draggable:a,onDragStart:s,onClick:e=>{e.stopPropagation(),null==l||l()},className:"text-left rounded px-1.5 truncate cursor-pointer transition-opacity hover:opacity-80 ".concat(o?"text-[10px] py-0":"text-[11px] py-0.5"),style:{backgroundColor:i,color:"#fff",border:"none",width:"100%",lineHeight:o?"16px":"18px"},title:r.title,children:(0,n.jsxs)("span",{className:"flex min-w-0 items-center gap-1",children:[!o&&(0,n.jsx)("span",{className:"opacity-70 shrink-0",children:(0,rE.GP)(r.date,"HH:mm")}),r.faviconUrl&&(0,n.jsx)(e3,{src:r.faviconUrl,className:"w-3 h-3 rounded-[2px] shrink-0"}),(0,n.jsx)("span",{className:"truncate",children:r.title||"Untitled"})]})})}function r9(e){let{date:t,events:r,onEntryClick:l,onEntryDateChange:a}=e,[s,i]=(0,o.useState)(null),c=(0,o.useRef)(null),d=(0,rV.w)(t),u=(0,rK.p)(t),p=(0,rU.k)(d,{weekStartsOn:1}),h=(0,rH.$)(u,{weekStartsOn:1}),x=(0,rJ.k)({start:p,end:h}),m=(0,o.useMemo)(()=>{let e=new Map;for(let t of r){let r=(0,rE.GP)(t.date,"yyyy-MM-dd");if(e.has(r)||e.set(r,[]),e.get(r).push(t),t.endDate&&!(0,rq.r)(t.date,t.endDate))for(let r of(0,rJ.k)({start:(0,rD.f)(t.date,1),end:t.endDate})){let n=(0,rE.GP)(r,"yyyy-MM-dd");e.has(n)||e.set(n,[]),e.get(n).push(t)}}return e},[r]),f=(0,o.useCallback)(e=>{c.current=e},[]),v=(0,o.useCallback)((e,t)=>{e.preventDefault(),i(t)},[]),g=(0,o.useCallback)((e,t)=>{e.preventDefault(),i(null);let r=c.current;if(!r||!a||(0,rq.r)(r.date,t))return;let n=(0,rG.o)((0,r$.o)(t),(0,r$.o)(r.date)),o=(0,rZ.z)(r.date,n),l={entryId:r.id,newDate:r3(o)};r.endDate&&(l.newEndDate=r3((0,rZ.z)(r.endDate,n))),a(l),c.current=null},[a]),y=(0,o.useCallback)(()=>i(null),[]);return(0,n.jsxs)("div",{className:"w-full",children:[(0,n.jsx)("div",{className:"grid grid-cols-7 border-b",style:{borderColor:"var(--color-border)"},children:["Mon","Tue","Wed","Thu","Fri","Sat","Sun"].map(e=>(0,n.jsx)("div",{className:"text-center text-[11px] font-medium py-2",style:{color:"var(--color-text-muted)"},children:e},e))}),(0,n.jsx)("div",{className:"grid grid-cols-7",children:x.map(e=>{var r;let o=(0,rE.GP)(e,"yyyy-MM-dd"),i=null!=(r=m.get(o))?r:[],c=(0,rY.t)(e,t),d=(0,rQ.c)(e),u=s===o;return(0,n.jsxs)("div",{className:"min-h-[100px] border-b border-r p-1 transition-colors",style:{borderColor:"var(--color-border)",opacity:c?1:.4,background:u?"var(--color-accent-light, rgba(99,102,241,0.12))":d?"var(--color-surface-hover)":void 0},onDragOver:e=>v(e,o),onDragLeave:y,onDrop:t=>g(t,e),children:[(0,n.jsx)("div",{className:"text-[11px] mb-0.5 ".concat(d?"font-bold":""),style:{color:d?"var(--color-accent)":"var(--color-text-muted)"},children:(0,rE.GP)(e,"d")}),(0,n.jsxs)("div",{className:"flex flex-col gap-0.5",children:[i.slice(0,3).map(e=>(0,n.jsx)(r7,{event:e,compact:!0,onClick:()=>null==l?void 0:l(e.id),draggable:!!a,onDragStart:()=>f(e)},e.id)),i.length>3&&(0,n.jsxs)("span",{className:"text-[10px] pl-1",style:{color:"var(--color-text-muted)"},children:["+",i.length-3," more"]})]})]},o)})})]})}function ne(e){var t;let{event:r,hourHeight:l,onEntryClick:a,onEntryDateChange:s}=e,i=(0,o.useRef)(null),[c,d]=(0,o.useState)(null),u=(0,o.useRef)({y:0,startMinute:0,duration:0}),p=(0,rX.O)(r.date)/60*l,h=r.endDate?Math.max((0,rG.o)(r.endDate,r.date),15):30,x=h/60*l,[m,f]=(0,o.useState)(0),[v,g]=(0,o.useState)(0),y=(0,o.useCallback)(e=>{s&&(e.preventDefault(),e.stopPropagation(),d("move"),u.current={y:e.clientY,startMinute:60*(0,r0.q)(r.date)+(0,rX.O)(r.date),duration:h},e.target.setPointerCapture(e.pointerId))},[s,r.date,h]),b=(0,o.useCallback)(e=>{s&&(e.preventDefault(),e.stopPropagation(),d("resize"),u.current={y:e.clientY,startMinute:0,duration:h},e.target.setPointerCapture(e.pointerId))},[s,h]),j=(0,o.useCallback)(e=>{if(!c)return;let t=e.clientY-u.current.y;"move"===c?f(t):g(t)},[c]),k=(0,o.useCallback)(e=>{if(!c||!s)return;let t=15*Math.round((e.clientY-u.current.y)/l*60/15);if("move"===c&&0!==t){let e=(0,rZ.z)(r.date,t),n={entryId:r.id,newDate:r6(e)};r.endDate&&(n.newEndDate=r6((0,rZ.z)(r.endDate,t))),s(n)}else if("resize"===c&&0!==t){var n;let e=(0,rZ.z)(null!=(n=r.endDate)?n:(0,rZ.z)(r.date,h),t);e>r.date&&s({entryId:r.id,newDate:r6(r.date),newEndDate:r6(e)})}d(null),f(0),g(0)},[c,s,r,l,h]),w=p+("move"===c?m:0),N=Math.max(x+("resize"===c?v:0),15);return(0,n.jsxs)("div",{ref:i,className:"absolute left-0.5 right-0.5 rounded px-1 text-[10px] truncate select-none",style:{top:w,height:Math.min(N,6*l),backgroundColor:null!=(t=r.color)?t:"var(--color-accent)",color:"#fff",lineHeight:"16px",zIndex:c?20:2,cursor:s?"move"===c?"grabbing":"grab":"pointer",opacity:c?.85:1,transition:c?"none":"top 0.15s, height 0.15s"},onPointerDown:y,onPointerMove:j,onPointerUp:k,onClick:e=>{c||(e.stopPropagation(),null==a||a(r.id))},title:r.title,children:[(0,n.jsxs)("span",{className:"flex min-w-0 items-center gap-1",children:[r.faviconUrl&&(0,n.jsx)(e3,{src:r.faviconUrl,className:"w-3 h-3 rounded-[2px] shrink-0"}),(0,n.jsx)("span",{className:"truncate",children:r.title||"Untitled"})]}),s&&(0,n.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-2 cursor-ns-resize",style:{borderRadius:"0 0 4px 4px"},onPointerDown:b})]})}function nt(e){let{date:t,events:r,onEntryClick:l,onEntryDateChange:a}=e,s=(0,rU.k)(t,{weekStartsOn:1}),i=(0,rJ.k)({start:s,end:(0,rD.f)(s,6)}),c=Array.from({length:24},(e,t)=>t+0),d=(0,o.useMemo)(()=>{let e=new Map;for(let t of r){let r=(0,rE.GP)(t.date,"yyyy-MM-dd");e.has(r)||e.set(r,[]),e.get(r).push(t)}return e},[r]);return(0,n.jsx)("div",{className:"w-full overflow-auto",style:{maxHeight:"calc(100vh - 280px)"},children:(0,n.jsxs)("div",{className:"grid",style:{gridTemplateColumns:"50px repeat(7, 1fr)"},children:[(0,n.jsx)("div",{className:"sticky top-0 z-10",style:{background:"var(--color-bg)"}}),i.map(e=>(0,n.jsxs)("div",{className:"sticky top-0 z-10 text-center py-2 border-b border-l text-[12px] font-medium",style:{borderColor:"var(--color-border)",background:"var(--color-bg)",color:(0,rQ.c)(e)?"var(--color-accent)":"var(--color-text)"},children:[(0,n.jsx)("div",{children:(0,rE.GP)(e,"EEE")}),(0,n.jsx)("div",{className:"text-lg ".concat((0,rQ.c)(e)?"font-bold":""),children:(0,rE.GP)(e,"d")})]},e.toISOString())),c.map(e=>(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"text-[10px] text-right pr-2 pt-0.5",style:{color:"var(--color-text-muted)",height:60},children:(0,rE.GP)(new Date(2e3,0,1,e),"ha")},"label-".concat(e)),i.map(t=>{var r;let o=(0,rE.GP)(t,"yyyy-MM-dd"),s=(null!=(r=d.get(o))?r:[]).filter(t=>(0,r0.q)(t.date)===e);return(0,n.jsx)("div",{className:"border-b border-l relative",style:{borderColor:"var(--color-border)",height:60},children:s.map(e=>(0,n.jsx)(ne,{event:e,hourHeight:60,onEntryClick:l,onEntryDateChange:a},e.id))},"".concat(o,"-").concat(e))})]}))]})})}function nr(e){let{date:t,events:r,onEntryClick:l,onEntryDateChange:a}=e,s=Array.from({length:24},(e,t)=>t+0),i=(0,o.useMemo)(()=>r.filter(e=>(0,rq.r)(e.date,t)),[r,t]);return(0,n.jsx)("div",{className:"w-full overflow-auto",style:{maxHeight:"calc(100vh - 280px)"},children:(0,n.jsx)("div",{className:"grid",style:{gridTemplateColumns:"60px 1fr"},children:s.map(e=>{let t=i.filter(t=>(0,r0.q)(t.date)===e);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"text-[11px] text-right pr-3 pt-0.5",style:{color:"var(--color-text-muted)",height:60},children:(0,rE.GP)(new Date(2e3,0,1,e),"h:mm a")},"label-".concat(e)),(0,n.jsx)("div",{className:"border-b border-l relative",style:{borderColor:"var(--color-border)",height:60},children:t.map(e=>(0,n.jsx)(ne,{event:e,hourHeight:60,onEntryClick:l,onEntryDateChange:a},e.id))},"cell-".concat(e))]})})})})}function nn(e){let{date:t,events:r}=e,l=(0,r1.D)(t),a=(0,r2.Q)(t),s=(0,r4.i)({start:l,end:a}),i=(0,o.useMemo)(()=>{let e=new Map;for(let t of r){let r=t.date.getMonth();e.has(r)||e.set(r,[]),e.get(r).push(t)}return e},[r]);return(0,n.jsx)("div",{className:"grid grid-cols-3 md:grid-cols-4 gap-4 p-2",children:s.map(e=>{var t;let r=(0,rV.w)(e),o=(0,rK.p)(e),l=(0,rU.k)(r,{weekStartsOn:1}),a=(0,rH.$)(o,{weekStartsOn:1}),s=(0,rJ.k)({start:l,end:a}),c=null!=(t=i.get(e.getMonth()))?t:[];return(0,n.jsxs)("div",{className:"rounded-lg border p-2",style:{borderColor:"var(--color-border)",background:"var(--color-surface)"},children:[(0,n.jsx)("div",{className:"text-[12px] font-semibold mb-1",style:{color:"var(--color-text)"},children:(0,rE.GP)(e,"MMMM")}),(0,n.jsxs)("div",{className:"grid grid-cols-7 gap-px",children:[["M","T","W","T","F","S","S"].map((e,t)=>(0,n.jsx)("div",{className:"text-[9px] text-center",style:{color:"var(--color-text-muted)"},children:e},t)),s.map(t=>{let r=(0,rY.t)(t,e),o=(0,rQ.c)(t),l=c.some(e=>(0,rq.r)(e.date,t));return(0,n.jsxs)("div",{className:"text-[9px] text-center py-0.5 relative",style:{color:r?o?"var(--color-accent)":"var(--color-text)":"transparent",fontWeight:o?700:400},children:[(0,rE.GP)(t,"d"),l&&r&&(0,n.jsx)("div",{className:"absolute bottom-0 left-1/2 -translate-x-1/2 w-1 h-1 rounded-full",style:{backgroundColor:"var(--color-accent)"}})]},t.toISOString())})]}),c.length>0&&(0,n.jsxs)("div",{className:"mt-1 text-[10px]",style:{color:"var(--color-text-muted)"},children:[c.length," event",1!==c.length?"s":""]})]},e.toISOString())})})}function no(e){let{reason:t}=e;return(0,n.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 gap-2",children:[(0,n.jsxs)("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",style:{color:"var(--color-text-muted)",opacity:.4},children:[(0,n.jsx)("rect",{width:"18",height:"18",x:"3",y:"4",rx:"2"}),(0,n.jsx)("path",{d:"M16 2v4"}),(0,n.jsx)("path",{d:"M8 2v4"}),(0,n.jsx)("path",{d:"M3 10h18"})]}),(0,n.jsx)("span",{className:"text-sm",style:{color:"var(--color-text-muted)"},children:"no-date-field"===t?"No date field configured for calendar view. Open view settings to select one.":"No events to display in this range."})]})}function nl(e){let{objectName:t,fields:r,entries:l,dateField:a,endDateField:s,mode:i,onModeChange:c,members:d,onEntryClick:u,onEntryDateChange:p}=e,[h,x]=(0,o.useState)(()=>new Date),m=(0,o.useMemo)(()=>(function(e,t,r,n){let o=[];for(let s of e){let e=r5(s[r]);if(e)try{var l,a;let r,i=(0,r_.H)(e);if(Number.isNaN(i.getTime()))continue;if(n){let e=r5(s[n]);if(e){let t=(0,r_.H)(e);Number.isNaN(t.getTime())||(r=t)}}o.push({id:r5(null!=(a=s.entry_id)?a:s.id),title:function(e,t){var r;let n=null!=(r=t.find(e=>"text"===e.type&&/name|title/i.test(e.name)))?r:t.find(e=>"text"===e.type);return n?r5(e[n.name]):r5(e.id)}(s,t),faviconUrl:null==(l=rC(s,t))?void 0:l.faviconUrl,date:i,endDate:r,entry:s,color:function(e,t){var r,n;let o=t.find(e=>{var t;return"enum"===e.type&&(null==(t=e.enum_colors)?void 0:t.length)});if(!o)return;let l=r5(e[o.name]),a=null!=(n=null==(r=o.enum_values)?void 0:r.indexOf(l))?n:-1;return a>=0?o.enum_colors[a]:void 0}(s,t)})}catch(e){}}return o})(l,r,a,s),[l,r,a,s]),f=(0,o.useCallback)(()=>x(e=>r8(e,i,-1)),[i]),v=(0,o.useCallback)(()=>x(e=>r8(e,i,1)),[i]),g=(0,o.useCallback)(()=>x(new Date),[]);return a?(0,n.jsxs)("div",{className:"w-full",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between mb-3 px-1",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("button",{type:"button",onClick:f,className:"p-1.5 rounded-md hover:bg-[var(--color-surface-hover)] transition-colors",style:{color:"var(--color-text)"},children:(0,n.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,n.jsx)("path",{d:"m15 18-6-6 6-6"})})}),(0,n.jsx)("button",{type:"button",onClick:v,className:"p-1.5 rounded-md hover:bg-[var(--color-surface-hover)] transition-colors",style:{color:"var(--color-text)"},children:(0,n.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,n.jsx)("path",{d:"m9 18 6-6-6-6"})})}),(0,n.jsx)("button",{type:"button",onClick:g,className:"text-[12px] px-2.5 py-1 rounded-md border hover:bg-[var(--color-surface-hover)] transition-colors",style:{color:"var(--color-text)",borderColor:"var(--color-border)"},children:"Today"}),(0,n.jsx)("h3",{className:"text-sm font-semibold ml-2",style:{color:"var(--color-text)"},children:function(e,t){switch(t){case"day":return(0,rE.GP)(e,"EEEE, MMMM d, yyyy");case"week":{let t=(0,rU.k)(e,{weekStartsOn:1}),r=(0,rH.$)(e,{weekStartsOn:1});return"".concat((0,rE.GP)(t,"MMM d")," - ").concat((0,rE.GP)(r,"MMM d, yyyy"))}case"month":return(0,rE.GP)(e,"MMMM yyyy");case"year":return(0,rE.GP)(e,"yyyy")}}(h,i)})]}),(0,n.jsx)("div",{className:"flex rounded-lg border overflow-hidden",style:{borderColor:"var(--color-border)"},children:["day","week","month","year"].map(e=>(0,n.jsx)("button",{type:"button",onClick:()=>c(e),className:"text-[11px] px-3 py-1 capitalize transition-colors",style:{background:e===i?"var(--color-accent)":"var(--color-surface)",color:e===i?"#fff":"var(--color-text-muted)",borderRight:"year"!==e?"1px solid var(--color-border)":void 0},children:e},e))})]}),(0,n.jsxs)("div",{className:"rounded-lg border overflow-hidden",style:{borderColor:"var(--color-border)",background:"var(--color-bg)"},children:["month"===i&&(0,n.jsx)(r9,{date:h,events:m,onEntryClick:u,onEntryDateChange:p}),"week"===i&&(0,n.jsx)(nt,{date:h,events:m,onEntryClick:u,onEntryDateChange:p}),"day"===i&&(0,n.jsx)(nr,{date:h,events:m,onEntryClick:u,onEntryDateChange:p}),"year"===i&&(0,n.jsx)(nn,{date:h,events:m})]})]}):(0,n.jsx)(no,{reason:"no-date-field"})}var na=r(35933),ns=r(22507),ni=r(88382),nc=r(29788);let nd={day:{dayWidth:80,headerFormat:"MMM d"},week:{dayWidth:30,headerFormat:"MMM d"},month:{dayWidth:10,headerFormat:"MMM yyyy"},quarter:{dayWidth:4,headerFormat:"QQQ yyyy"}},nu=["#3b82f6","#22c55e","#f59e0b","#ef4444","#8b5cf6","#06b6d4","#ec4899","#14b8a6","#f97316","#6366f1"];function np(e){return null==e?"":"string"==typeof e?e:"number"==typeof e||"boolean"==typeof e||"bigint"==typeof e?String(e):"object"==typeof e?JSON.stringify(e):""}function nh(e){return(0,rE.GP)(e,"yyyy-MM-dd")}function nx(e){let{item:t,x:r,w:l,dayWidth:a,onEntryClick:s,onEntryDateChange:i}=e,[c,d]=(0,o.useState)(null),[u,p]=(0,o.useState)(0),[h,x]=(0,o.useState)(0),m=(0,o.useRef)(0),f=!!i,v=(0,o.useCallback)(e=>Math.round(e/a)*a,[a]),g=(0,o.useCallback)(e=>Math.round(e/a),[a]),y=(0,o.useCallback)((e,t)=>{f&&(e.preventDefault(),e.stopPropagation(),m.current=e.clientX,d(t),e.target.setPointerCapture(e.pointerId))},[f]),b=(0,o.useCallback)(e=>{if(!c)return;let t=v(e.clientX-m.current);"move"===c?p(t):"resize-left"===c?(p(t),x(-t)):x(t)},[c,v]),j=(0,o.useCallback)(e=>{if(!c||!i)return void d(null);let r=g(e.clientX-m.current);if(0===r&&"move"===c){d(null),p(0),x(0);return}let n=t.startDate,o=t.endDate;"move"===c?(n=(0,rD.f)(t.startDate,r),o=(0,rD.f)(t.endDate,r)):"resize-left"===c?(n=(0,rD.f)(t.startDate,r))>=o&&(n=(0,rD.f)(o,-1)):(o=(0,rD.f)(t.endDate,r))<=n&&(o=(0,rD.f)(n,1)),i({entryId:t.id,newStartDate:nh(n),newEndDate:nh(o)}),d(null),p(0),x(0)},[c,i,t,g]),k=Math.max(l+h,.5*a);return(0,n.jsxs)("div",{className:"absolute rounded flex items-center text-[11px] truncate select-none",style:{left:r+u,width:k,top:6,height:28,backgroundColor:t.color,color:"#fff",zIndex:c?20:2,cursor:f?"move"===c?"grabbing":"grab":"pointer",opacity:c?.85:1,transition:c?"none":"left 0.15s, width 0.15s"},onPointerDown:e=>y(e,"move"),onPointerMove:b,onPointerUp:j,onClick:e=>{c||(e.stopPropagation(),null==s||s(t.id))},title:"".concat(t.title,"\n").concat((0,rE.GP)(t.startDate,"MMM d")," - ").concat((0,rE.GP)(t.endDate,"MMM d")),children:[f&&(0,n.jsx)("div",{className:"absolute left-0 top-0 bottom-0 cursor-ew-resize hover:bg-white/20 rounded-l",style:{width:8},onPointerDown:e=>y(e,"resize-left")}),(0,n.jsxs)("span",{className:"px-2 flex min-w-0 items-center gap-1.5 flex-1",children:[t.faviconUrl&&k>84&&(0,n.jsx)(e3,{src:t.faviconUrl,className:"w-3 h-3 rounded-[2px] shrink-0"}),(0,n.jsx)("span",{className:"truncate",children:k>60?t.title||"Untitled":""})]}),f&&(0,n.jsx)("div",{className:"absolute right-0 top-0 bottom-0 cursor-ew-resize hover:bg-white/20 rounded-r",style:{width:8},onPointerDown:e=>y(e,"resize-right")})]})}function nm(e){let{reason:t}=e;return(0,n.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 gap-2",children:[(0,n.jsxs)("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",style:{color:"var(--color-text-muted)",opacity:.4},children:[(0,n.jsx)("path",{d:"M8 6h13"}),(0,n.jsx)("path",{d:"M8 12h13"}),(0,n.jsx)("path",{d:"M8 18h13"}),(0,n.jsx)("path",{d:"M3 6h.01"}),(0,n.jsx)("path",{d:"M3 12h.01"}),(0,n.jsx)("path",{d:"M3 18h.01"})]}),(0,n.jsx)("span",{className:"text-sm",style:{color:"var(--color-text-muted)"},children:"no-fields"===t?"No date fields configured for timeline view. Open view settings to select start/end dates.":"No items with dates to display in this view."})]})}function nf(e){let{objectName:t,fields:r,entries:l,startDateField:a,endDateField:s,groupField:i,zoom:c,onZoomChange:d,members:u,onEntryClick:p,onEntryDateChange:h}=e,x=(0,o.useRef)(null),m=(0,o.useMemo)(()=>(function(e,t,r,n,o){let l=[];for(let i=0;i<e.length;i++){let c=e[i],d=np(c[r]);if(d)try{var a,s;let e,r=(0,r_.H)(d);if(Number.isNaN(r.getTime()))continue;if(n){let t=np(c[n]);if(t){let n=(0,r_.H)(t);e=Number.isNaN(n.getTime())?(0,rD.f)(r,1):n}else e=(0,rD.f)(r,1)}else e=(0,rD.f)(r,1);e<=r&&(e=(0,rD.f)(r,1)),l.push({id:np(null!=(s=c.entry_id)?s:c.id),title:function(e,t){var r;let n=null!=(r=t.find(e=>"text"===e.type&&/name|title/i.test(e.name)))?r:t.find(e=>"text"===e.type);return n?np(e[n.name]):np(e.id)}(c,t),faviconUrl:null==(a=rC(c,t))?void 0:a.faviconUrl,startDate:r,endDate:e,group:o?np(c[o]):void 0,color:function(e,t,r){let n=t.find(e=>{var t;return"enum"===e.type&&(null==(t=e.enum_colors)?void 0:t.length)});if(n){var o,l;let t=np(e[n.name]),r=null!=(l=null==(o=n.enum_values)?void 0:o.indexOf(t))?l:-1;if(r>=0&&n.enum_colors[r])return n.enum_colors[r]}return nu[r%nu.length]}(c,t,i),entry:c})}catch(e){}}return l.toSorted((e,t)=>e.startDate.getTime()-t.startDate.getTime())})(l,r,a,s,i),[l,r,a,s,i]),{start:f,end:v}=(0,o.useMemo)(()=>(function(e,t){if(0===e.length){let e=new Date;return{start:(0,rP.a)(e,1),end:(0,rF.P)(e,2)}}let r=(0,na.j)(e.map(e=>e.startDate)),n=(0,ns.T)(e.map(e=>e.endDate)),o="day"===t?3:"week"===t?7:"month"===t?14:30;return{start:(0,rD.f)(r,-o),end:(0,rD.f)(n,o)}})(m,c),[m,c]),{dayWidth:g}=nd[c],y=((0,nc.c)(v,f)+1)*g,b=(0,o.useMemo)(()=>(function(e,t,r){switch(r){case"day":return(0,rJ.k)({start:e,end:t}).map(e=>({date:e,label:(0,rE.GP)(e,"MMM d")}));case"week":return(0,ni.Y)({start:e,end:t},{weekStartsOn:1}).map(e=>({date:e,label:(0,rE.GP)(e,"MMM d")}));case"month":return(0,r4.i)({start:e,end:t}).map(e=>({date:e,label:(0,rE.GP)(e,"MMM yyyy")}));case"quarter":return(0,r4.i)({start:e,end:t}).filter(e=>e.getMonth()%3==0).map(e=>({date:e,label:(0,rE.GP)(e,"QQQ yyyy")}))}})(f,v,c),[f,v,c]),j=(0,o.useMemo)(()=>{if(!i)return[{name:"",items:m}];let e=new Map;for(let t of m){let r=t.group||"Ungrouped";e.has(r)||e.set(r,[]),e.get(r).push(t)}return Array.from(e.entries()).map(e=>{let[t,r]=e;return{name:t,items:r}})},[m,i]),k=(0,o.useMemo)(()=>{let e=[];for(let t of j)for(let r of(i&&t.name&&e.push({type:"group",group:t.name}),t.items))e.push({type:"item",item:r});return e},[j,i]),w=(0,o.useCallback)(e=>(0,nc.c)(e,f)*g,[f,g]);if((0,o.useEffect)(()=>{if(!x.current)return;let e=w(new Date);x.current.scrollLeft=Math.max(0,e-300)},[w]),!a)return(0,n.jsx)(nm,{reason:"no-fields"});if(0===m.length)return(0,n.jsx)(nm,{reason:"no-items"});let N=w((0,r$.o)(new Date));return(0,n.jsxs)("div",{className:"w-full",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between mb-3 px-1",children:[(0,n.jsxs)("div",{className:"text-[12px]",style:{color:"var(--color-text-muted)"},children:[m.length," item",1!==m.length?"s":""]}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("span",{className:"text-[11px]",style:{color:"var(--color-text-muted)"},children:"Zoom:"}),(0,n.jsx)("div",{className:"flex rounded-lg border overflow-hidden",style:{borderColor:"var(--color-border)"},children:["day","week","month","quarter"].map(e=>(0,n.jsx)("button",{type:"button",onClick:()=>d(e),className:"text-[11px] px-3 py-1 capitalize transition-colors",style:{background:e===c?"var(--color-accent)":"var(--color-surface)",color:e===c?"#fff":"var(--color-text-muted)",borderRight:"quarter"!==e?"1px solid var(--color-border)":void 0},children:e},e))})]})]}),(0,n.jsx)("div",{className:"rounded-lg border overflow-hidden",style:{borderColor:"var(--color-border)",background:"var(--color-bg)"},children:(0,n.jsxs)("div",{className:"flex",children:[(0,n.jsxs)("div",{className:"flex-shrink-0 border-r",style:{width:200,borderColor:"var(--color-border)",background:"var(--color-surface)"},children:[(0,n.jsx)("div",{className:"border-b px-3 flex items-center text-[11px] font-medium",style:{height:50,borderColor:"var(--color-border)",color:"var(--color-text-muted)"},children:"Name"}),k.map((e,t)=>{var r,o;return(0,n.jsx)("div",{className:"px-3 flex items-center border-b truncate ".concat("group"===e.type?"text-[10px] font-semibold uppercase tracking-wider":"text-[12px] cursor-pointer hover:bg-[var(--color-surface-hover)]"),style:{height:40,borderColor:"var(--color-border)",color:"group"===e.type?"var(--color-text-muted)":"var(--color-text)",background:"group"===e.type?"var(--color-surface-hover)":void 0},onClick:()=>e.item&&(null==p?void 0:p(e.item.id)),children:"group"===e.type?e.group:(0,n.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5",children:[(null==(r=e.item)?void 0:r.faviconUrl)&&(0,n.jsx)(e3,{src:e.item.faviconUrl,className:"w-3.5 h-3.5 rounded-[3px] shrink-0"}),(0,n.jsx)("span",{className:"truncate",children:(null==(o=e.item)?void 0:o.title)||"Untitled"})]})},t)})]}),(0,n.jsx)("div",{ref:x,className:"flex-1 overflow-x-auto overflow-y-hidden",style:{maxHeight:"calc(100vh - 280px)"},children:(0,n.jsxs)("div",{style:{width:y,position:"relative"},children:[(0,n.jsx)("div",{className:"border-b flex",style:{height:50,borderColor:"var(--color-border)"},children:b.map((e,t)=>{let r=w(e.date),o=t<b.length-1?w(b[t+1].date):y;return(0,n.jsx)("div",{className:"absolute border-r flex items-end pb-1 px-2 text-[10px]",style:{left:r,width:o-r,height:50,borderColor:"var(--color-border)",color:"var(--color-text-muted)"},children:e.label},t)})}),k.map((e,t)=>(0,n.jsx)("div",{className:"relative border-b",style:{height:40,borderColor:"var(--color-border)",background:"group"===e.type?"var(--color-surface-hover)":void 0},children:e.item&&(()=>{let t=e.item,r=w(t.startDate),o=Math.max(w(t.endDate)-r,.5*g);return(0,n.jsx)(nx,{item:t,x:r,w:o,dayWidth:g,onEntryClick:p,onEntryDateChange:h})})()},t)),N>=0&&N<=y&&(0,n.jsx)("div",{className:"absolute top-0 bottom-0 pointer-events-none",style:{left:N,width:2,backgroundColor:"var(--color-accent)",opacity:.6,zIndex:10}})]})})]})})]})}function nv(e){return null==e?"":"string"==typeof e?e:"number"==typeof e||"boolean"==typeof e||"bigint"==typeof e?String(e):"object"==typeof e?JSON.stringify(e):""}function ng(e){var t;let{entry:r,fields:l,titleField:a,coverField:s,onEntryClick:i}=e,c=nv(null!=(t=r.entry_id)?t:r.id),d=function(e,t,r){var n;if(r){let t=nv(e[r]);if(t)return t}let o=null!=(n=t.find(e=>"text"===e.type&&/name|title/i.test(e.name)))?n:t.find(e=>"text"===e.type);return o?nv(e[o.name]):nv(e.id)}(r,l,a),u=rC(r,l),p=(0,o.useMemo)(()=>l.filter(e=>e.name!==a&&e.name!==s).slice(0,4),[l,a,s]),h=l.find(e=>{var t;return"enum"===e.type&&(null==(t=e.enum_values)?void 0:t.length)}),x=h?nv(r[h.name]):null,m=h&&x?function(e,t){var r;if(!e||!t.enum_values)return null;let n=t.enum_values.indexOf(e);return{text:e,color:n>=0&&(null==(r=t.enum_colors)?void 0:r[n])?t.enum_colors[n]:"#94a3b8"}}(x,h):null;return(0,n.jsxs)("button",{type:"button",onClick:()=>null==i?void 0:i(c),className:"text-left rounded-xl border p-4 hover:shadow-md transition-all cursor-pointer w-full group",style:{borderColor:"var(--color-border)",background:"var(--color-surface)"},children:[(0,n.jsxs)("div",{className:"flex items-start justify-between gap-2 mb-2",children:[(0,n.jsxs)("div",{className:"flex min-w-0 items-start gap-2",children:[(null==u?void 0:u.faviconUrl)&&(0,n.jsx)(e3,{src:u.faviconUrl,className:"w-4 h-4 rounded-[4px] shrink-0 mt-0.5"}),(0,n.jsx)("h4",{className:"text-[13px] font-semibold leading-tight line-clamp-2 group-hover:underline",style:{color:"var(--color-text)"},children:d||"Untitled"})]}),m&&(0,n.jsx)("span",{className:"text-[10px] px-2 py-0.5 rounded-full flex-shrink-0 whitespace-nowrap",style:{backgroundColor:m.color,color:"#fff"},children:m.text})]}),(0,n.jsx)("div",{className:"flex flex-col gap-1.5",children:p.map(e=>{let t=r[e.name];if(null==t||""===nv(t))return null;let o="tags"===e.type?t$(t):[];return(0,n.jsxs)("div",{className:"flex items-baseline gap-2",children:[(0,n.jsx)("span",{className:"text-[10px] flex-shrink-0 min-w-[60px]",style:{color:"var(--color-text-muted)"},children:e.name}),(0,n.jsx)("div",{className:"text-[12px] whitespace-pre-line line-clamp-2",style:{color:"var(--color-text)"},children:"tags"===e.type?(0,n.jsxs)("span",{className:"flex items-center gap-0.5 flex-wrap",children:[o.slice(0,3).map(e=>{let t=t_(e),r="link"===t.kind&&t.href,o="url"===t.linkType&&!!t.faviconUrl;return r?(0,n.jsxs)("a",{href:t.href,target:"url"===t.linkType||"file"===t.linkType?"_blank":void 0,rel:"url"===t.linkType||"file"===t.linkType?"noopener noreferrer":void 0,onClick:e=>e.stopPropagation(),className:"inline-flex items-center gap-1 px-1.5 py-0 rounded text-[11px] font-medium hover:underline underline-offset-2 max-w-[220px]",style:{background:"rgba(148, 163, 184, 0.12)",color:"var(--color-accent)"},children:[o&&(0,n.jsx)(e3,{src:t.faviconUrl,className:"w-3 h-3 rounded-[2px] shrink-0"}),(0,n.jsx)("span",{className:"min-w-0 truncate",children:t.text})]},e):(0,n.jsx)("span",{className:"inline-flex items-center px-1.5 py-0 rounded text-[11px] font-medium",style:{background:"rgba(148, 163, 184, 0.12)",color:"var(--color-text-muted)"},children:e},e)}),o.length>3&&(0,n.jsxs)("span",{className:"text-[10px]",style:{color:"var(--color-text-muted)"},children:["+",o.length-3]})]}):(0,n.jsx)(tG,{value:t,fieldType:e.type,mode:"table",showUrlFavicon:!0})})]},e.id)})}),null!=r.created_at&&(0,n.jsx)("div",{className:"mt-3 text-[10px]",style:{color:"var(--color-text-muted)",opacity:.6},children:nv(r.created_at).slice(0,10)})]})}function ny(){return(0,n.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 gap-2",children:[(0,n.jsxs)("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",style:{color:"var(--color-text-muted)",opacity:.4},children:[(0,n.jsx)("rect",{width:"7",height:"7",x:"3",y:"3",rx:"1"}),(0,n.jsx)("rect",{width:"7",height:"7",x:"14",y:"3",rx:"1"}),(0,n.jsx)("rect",{width:"7",height:"7",x:"3",y:"14",rx:"1"}),(0,n.jsx)("rect",{width:"7",height:"7",x:"14",y:"14",rx:"1"})]}),(0,n.jsx)("span",{className:"text-sm",style:{color:"var(--color-text-muted)"},children:"No entries to display in gallery view."})]})}function nb(e){let{objectName:t,fields:r,entries:o,titleField:l,coverField:a,members:s,relationLabels:i,onEntryClick:c}=e;return 0===o.length?(0,n.jsx)(ny,{}):(0,n.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3",children:o.map(e=>{var t;return(0,n.jsx)(ng,{entry:e,fields:r,titleField:l,coverField:a,onEntryClick:c},nv(null!=(t=e.entry_id)?t:e.id))})})}function nj(e){return null==e?"":"string"==typeof e?e:"number"==typeof e||"boolean"==typeof e||"bigint"==typeof e?String(e):"object"==typeof e?JSON.stringify(e):""}function nk(e){var t,r;let{entry:l,fields:a,titleField:s,subtitleField:i,onEntryClick:c}=e,d=nj(null!=(t=l.entry_id)?t:l.id),u=function(e,t,r){var n;if(r){let t=nj(e[r]);if(t)return t}let o=null!=(n=t.find(e=>"text"===e.type&&/name|title/i.test(e.name)))?n:t.find(e=>"text"===e.type);return o?nj(e[o.name]):nj(e.id)}(l,a,s),p=rC(l,a),h=(0,o.useMemo)(()=>{if(i){let e=nj(l[i]);if(e)return e}let e=a.find(e=>"text"===e.type&&e.name!==s&&!/name|title/i.test(e.name));return e?nj(l[e.name]):void 0},[l,a,s,i]),x=a.find(e=>{var t;return"enum"===e.type&&(null==(t=e.enum_values)?void 0:t.length)}),m=x?nj(l[x.name]):null,f=x&&m?function(e,t){var r;if(!e||!t.enum_values)return null;let n=t.enum_values.indexOf(e);return{text:e,color:n>=0&&(null==(r=t.enum_colors)?void 0:r[n])?t.enum_colors[n]:"#94a3b8"}}(m,x):null,v=a.find(e=>"tags"===e.type),g=v?t$(l[v.name]):[],y=a.find(e=>"date"===e.type),b=y?nj(l[y.name]):null;return(0,n.jsxs)("button",{type:"button",onClick:()=>null==c?void 0:c(d),className:"w-full text-left flex items-center gap-3 px-4 py-3 border-b hover:bg-[var(--color-surface-hover)] transition-colors cursor-pointer group",style:{borderColor:"var(--color-border)"},children:[(0,n.jsx)("div",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:null!=(r=null==f?void 0:f.color)?r:"var(--color-text-muted)",opacity:.6}}),(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(null==p?void 0:p.faviconUrl)&&(0,n.jsx)(e3,{src:p.faviconUrl,className:"w-4 h-4 rounded-[4px] shrink-0"}),(0,n.jsx)("span",{className:"text-[13px] font-medium truncate group-hover:underline",style:{color:"var(--color-text)"},children:u||"Untitled"})]}),f&&(0,n.jsx)("span",{className:"text-[10px] px-2 py-0.5 rounded-full flex-shrink-0",style:{backgroundColor:f.color,color:"#fff"},children:f.text}),g.slice(0,3).map(e=>{let t=t_(e),r="link"===t.kind&&t.href,o="url"===t.linkType&&!!t.faviconUrl;return r?(0,n.jsxs)("a",{href:t.href,target:"url"===t.linkType||"file"===t.linkType?"_blank":void 0,rel:"url"===t.linkType||"file"===t.linkType?"noopener noreferrer":void 0,onClick:e=>e.stopPropagation(),className:"inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded-full flex-shrink-0 hover:underline underline-offset-2 max-w-[220px]",style:{background:"rgba(148, 163, 184, 0.12)",color:"var(--color-accent)",border:"1px solid var(--color-border)"},children:[o&&(0,n.jsx)(e3,{src:t.faviconUrl,className:"w-3 h-3 rounded-[2px] shrink-0"}),(0,n.jsx)("span",{className:"min-w-0 truncate",children:t.text})]},e):(0,n.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full flex-shrink-0",style:{background:"rgba(148, 163, 184, 0.12)",color:"var(--color-text-muted)",border:"1px solid var(--color-border)"},children:e},e)})]}),h&&(0,n.jsx)("div",{className:"text-[11px] whitespace-pre-line line-clamp-1 mt-0.5",style:{color:"var(--color-text-muted)"},children:h})]}),b&&(0,n.jsx)("span",{className:"text-[11px] flex-shrink-0 tabular-nums",style:{color:"var(--color-text-muted)"},children:b.slice(0,10)})]})}function nw(){return(0,n.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 gap-2",children:[(0,n.jsxs)("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",style:{color:"var(--color-text-muted)",opacity:.4},children:[(0,n.jsx)("path",{d:"M8 6h13"}),(0,n.jsx)("path",{d:"M8 12h13"}),(0,n.jsx)("path",{d:"M8 18h13"}),(0,n.jsx)("path",{d:"M3 6h.01"}),(0,n.jsx)("path",{d:"M3 12h.01"}),(0,n.jsx)("path",{d:"M3 18h.01"})]}),(0,n.jsx)("span",{className:"text-sm",style:{color:"var(--color-text-muted)"},children:"No entries to display in list view."})]})}function nN(e){let{objectName:t,fields:r,entries:o,titleField:l,subtitleField:a,members:s,onEntryClick:i}=e;return 0===o.length?(0,n.jsx)(nw,{}):(0,n.jsx)("div",{className:"rounded-lg border overflow-hidden",style:{borderColor:"var(--color-border)",background:"var(--color-surface)"},children:o.map(e=>{var t;return(0,n.jsx)(nk,{entry:e,fields:r,titleField:l,subtitleField:a,onEntryClick:i},nj(null!=(t=e.entry_id)?t:e.id))})})}let nC=["table","kanban","calendar","timeline","gallery","list"];function nS(e){return"string"==typeof e&&nC.includes(e)}function nM(e,t,r){return(null==e?void 0:e.view_type)&&nS(e.view_type)?e.view_type:t&&nS(t)?t:r&&nS(r)?r:"table"}function nL(e,t,r){var n,o,l,a,s,i,c,d,u,p,h,x;switch(t){case"kanbanField":return null!=(l=null==(n=r.find(e=>"enum"===e.type&&/status/i.test(e.name)))?void 0:n.name)?l:null==(o=r.find(e=>"enum"===e.type))?void 0:o.name;case"calendarDateField":case"timelineStartField":return null!=(i=null==(a=r.find(e=>"date"===e.type&&/due|start|begin/i.test(e.name)))?void 0:a.name)?i:null==(s=r.find(e=>"date"===e.type))?void 0:s.name;case"calendarEndDateField":case"timelineEndField":return null==(c=r.find(e=>"date"===e.type&&/end|finish|close/i.test(e.name)))?void 0:c.name;case"timelineGroupField":return null==(d=r.find(e=>"enum"===e.type))?void 0:d.name;case"galleryTitleField":case"listTitleField":return null!=(h=null==(u=r.find(e=>"text"===e.type&&/name|title/i.test(e.name)))?void 0:u.name)?h:null==(p=r.find(e=>"text"===e.type))?void 0:p.name;case"galleryCoverField":default:return;case"listSubtitleField":return null==(x=r.find(e=>"text"===e.type&&!/name|title/i.test(e.name)))?void 0:x.name}}let nT=[{value:"is_empty",label:"is empty"},{value:"is_not_empty",label:"is not empty"}],nI=[{value:"contains",label:"contains"},{value:"not_contains",label:"does not contain"},{value:"equals",label:"equals"},{value:"not_equals",label:"does not equal"},{value:"starts_with",label:"starts with"},{value:"ends_with",label:"ends with"},...nT],nR=[{value:"eq",label:"="},{value:"neq",label:"≠"},{value:"gt",label:">"},{value:"gte",label:"≥"},{value:"lt",label:"<"},{value:"lte",label:"≤"},{value:"between",label:"between"},...nT],n_=[{value:"on",label:"is"},{value:"before",label:"before"},{value:"after",label:"after"},{value:"date_between",label:"between"},{value:"relative_past",label:"in the last"},{value:"relative_next",label:"in the next"},...nT],nE=[{value:"is",label:"is"},{value:"is_not",label:"is not"},{value:"is_any_of",label:"is any of"},{value:"is_none_of",label:"is none of"},...nT],nD=[{value:"is_true",label:"is true"},{value:"is_false",label:"is false"},...nT],nA=[{value:"has_any",label:"has any of"},{value:"has_none",label:"has none of"},{value:"has_all",label:"has all of"},...nT],nW=[{value:"contains",label:"contains"},{value:"not_contains",label:"does not contain"},...nT];function nB(e){switch(e){case"text":case"richtext":case"email":case"tags":default:return"contains";case"number":return"eq";case"date":return"relative_past";case"enum":return"is";case"boolean":return"is_true";case"relation":case"user":return"has_any"}}function nF(e){return"conjunction"in e&&"rules"in e}function nP(e){return btoa(JSON.stringify(e))}function nz(){return{id:"root",conjunction:"and",rules:[]}}function nO(e){var t,r;let n=e.field,o=e.operator,l=Array.isArray(e.value)?e.value.join(", "):String(null!=(t=e.value)?t:"");return"is_empty"===o?"".concat(n," is empty"):"is_not_empty"===o?"".concat(n," is not empty"):"is_true"===o?"".concat(n," is true"):"is_false"===o?"".concat(n," is false"):"between"===o||"date_between"===o?"".concat(n," between ").concat(l," and ").concat(e.valueTo):"relative_past"===o?"".concat(n," in the last ").concat(e.relativeAmount," ").concat(e.relativeUnit):"relative_next"===o?"".concat(n," in the next ").concat(e.relativeAmount," ").concat(e.relativeUnit):"".concat(n," ").concat(null!=(r=({contains:"contains",not_contains:"doesn't contain",equals:"=",not_equals:"≠",starts_with:"starts with",ends_with:"ends with",eq:"=",neq:"≠",gt:">",gte:"≥",lt:"<",lte:"≤",before:"before",after:"after",on:"is",is:"is",is_not:"is not",is_any_of:"is any of",is_none_of:"is none of",has_any:"has any of",has_none:"has none of",has_all:"has all of"})[o])?r:o," ").concat(l)}let nU={table:{icon:function(){return(0,n.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M12 3v18"}),(0,n.jsx)("path",{d:"M3 12h18"}),(0,n.jsx)("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"})]})},label:"Table"},kanban:{icon:function(){return(0,n.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{width:"6",height:"14",x:"3",y:"5",rx:"1"}),(0,n.jsx)("rect",{width:"6",height:"10",x:"9",y:"9",rx:"1"}),(0,n.jsx)("rect",{width:"6",height:"16",x:"15",y:"3",rx:"1"})]})},label:"Board"},calendar:{icon:function(){return(0,n.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{width:"18",height:"18",x:"3",y:"4",rx:"2"}),(0,n.jsx)("path",{d:"M16 2v4"}),(0,n.jsx)("path",{d:"M8 2v4"}),(0,n.jsx)("path",{d:"M3 10h18"})]})},label:"Calendar"},timeline:{icon:function(){return(0,n.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M3 6h7"}),(0,n.jsx)("path",{d:"M6 12h10"}),(0,n.jsx)("path",{d:"M5 18h5"}),(0,n.jsx)("path",{d:"M14 6h7"}),(0,n.jsx)("path",{d:"M18 12h3"}),(0,n.jsx)("path",{d:"M12 18h9"})]})},label:"Timeline"},gallery:{icon:function(){return(0,n.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{width:"7",height:"7",x:"3",y:"3",rx:"1"}),(0,n.jsx)("rect",{width:"7",height:"7",x:"14",y:"3",rx:"1"}),(0,n.jsx)("rect",{width:"7",height:"7",x:"3",y:"14",rx:"1"}),(0,n.jsx)("rect",{width:"7",height:"7",x:"14",y:"14",rx:"1"})]})},label:"Gallery"},list:{icon:function(){return(0,n.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M8 6h13"}),(0,n.jsx)("path",{d:"M8 12h13"}),(0,n.jsx)("path",{d:"M8 18h13"}),(0,n.jsx)("path",{d:"M3 6h.01"}),(0,n.jsx)("path",{d:"M3 12h.01"}),(0,n.jsx)("path",{d:"M3 18h.01"})]})},label:"List"}};function nH(e){let{value:t,onChange:r}=e;return(0,n.jsx)("div",{className:"flex items-center gap-1",children:nC.map(e=>{let o=nU[e],l=o.icon,a=e===t;return(0,n.jsxs)("button",{type:"button",onClick:()=>r(e),className:"flex items-center gap-1.5 px-2.5 py-1 text-[12px] rounded-md transition-colors cursor-pointer",style:{background:a?"var(--color-surface-hover)":"transparent",color:a?"var(--color-text)":"var(--color-text-muted)",fontWeight:a?500:400},title:o.label,children:[(0,n.jsx)(l,{}),(0,n.jsx)("span",{className:"hidden sm:inline",children:o.label})]},e)})})}function nV(e){let{label:t,value:r,onChange:o,fields:l,filterType:a,allowEmpty:s}=e,i=a?Array.isArray(a)?a:[a]:null,c=i?l.filter(e=>i.includes(e.type)):l;return(0,n.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,n.jsx)("label",{className:"text-[10px] font-medium",style:{color:"var(--color-text-muted)"},children:t}),(0,n.jsxs)("select",{value:null!=r?r:"",onChange:e=>o(e.target.value||void 0),className:"text-[12px] rounded-md border px-2 py-1.5 bg-transparent",style:{borderColor:"var(--color-border)",color:"var(--color-text)",background:"var(--color-surface)"},children:[s&&(0,n.jsx)("option",{value:"",children:"None"}),0===c.length&&(0,n.jsx)("option",{value:"",disabled:!0,children:"No matching fields"}),c.map(e=>(0,n.jsx)("option",{value:e.name,children:e.name},e.id))]})]})}function nK(e){let{label:t,value:r,options:o,onChange:l}=e;return(0,n.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,n.jsx)("label",{className:"text-[10px] font-medium",style:{color:"var(--color-text-muted)"},children:t}),(0,n.jsx)("div",{className:"flex rounded-md border overflow-hidden",style:{borderColor:"var(--color-border)"},children:o.map(e=>(0,n.jsx)("button",{type:"button",onClick:()=>l(e.value),className:"text-[11px] px-2.5 py-1 flex-1 transition-colors capitalize",style:{background:e.value===r?"var(--color-accent)":"var(--color-surface)",color:e.value===r?"#fff":"var(--color-text-muted)"},children:e.label},e.value))})]})}function nJ(e){let{settings:t,fields:r,onSettingsChange:o}=e;return(0,n.jsx)(nV,{label:"Group by field",value:t.kanbanField,onChange:e=>o({...t,kanbanField:e}),fields:r,filterType:"enum"})}function nq(e){var t;let{settings:r,fields:o,onSettingsChange:l}=e;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(nV,{label:"Date field",value:r.calendarDateField,onChange:e=>l({...r,calendarDateField:e}),fields:o,filterType:"date"}),(0,n.jsx)(nV,{label:"End date field (optional)",value:r.calendarEndDateField,onChange:e=>l({...r,calendarEndDateField:e}),fields:o,filterType:"date",allowEmpty:!0}),(0,n.jsx)(nK,{label:"Default view",value:null!=(t=r.calendarMode)?t:"month",options:[{value:"day",label:"Day"},{value:"week",label:"Week"},{value:"month",label:"Month"},{value:"year",label:"Year"}],onChange:e=>l({...r,calendarMode:e})})]})}function nG(e){var t;let{settings:r,fields:o,onSettingsChange:l}=e;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(nV,{label:"Start date field",value:r.timelineStartField,onChange:e=>l({...r,timelineStartField:e}),fields:o,filterType:"date"}),(0,n.jsx)(nV,{label:"End date field",value:r.timelineEndField,onChange:e=>l({...r,timelineEndField:e}),fields:o,filterType:"date",allowEmpty:!0}),(0,n.jsx)(nV,{label:"Group by (optional)",value:r.timelineGroupField,onChange:e=>l({...r,timelineGroupField:e}),fields:o,filterType:"enum",allowEmpty:!0}),(0,n.jsx)(nK,{label:"Default zoom",value:null!=(t=r.timelineZoom)?t:"week",options:[{value:"day",label:"Day"},{value:"week",label:"Week"},{value:"month",label:"Month"},{value:"quarter",label:"Quarter"}],onChange:e=>l({...r,timelineZoom:e})})]})}function n$(e){let{settings:t,fields:r,onSettingsChange:o}=e;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(nV,{label:"Title field",value:t.galleryTitleField,onChange:e=>o({...t,galleryTitleField:e}),fields:r,filterType:"text"}),(0,n.jsx)(nV,{label:"Cover field (optional)",value:t.galleryCoverField,onChange:e=>o({...t,galleryCoverField:e}),fields:r,allowEmpty:!0})]})}function nZ(e){let{settings:t,fields:r,onSettingsChange:o}=e;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(nV,{label:"Title field",value:t.listTitleField,onChange:e=>o({...t,listTitleField:e}),fields:r,filterType:"text"}),(0,n.jsx)(nV,{label:"Subtitle field (optional)",value:t.listSubtitleField,onChange:e=>o({...t,listSubtitleField:e}),fields:r,filterType:["text","email","richtext"],allowEmpty:!0})]})}function nY(){return(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),(0,n.jsx)("circle",{cx:"12",cy:"12",r:"3"})]})}function nQ(e){let{viewType:t,settings:r,fields:l,onSettingsChange:a}=e,[s,i]=(0,o.useState)(!1),c=(0,o.useRef)(null);return((0,o.useEffect)(()=>{if(!s)return;let e=e=>{c.current&&!c.current.contains(e.target)&&i(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[s]),"table"===t)?null:(0,n.jsxs)("div",{className:"relative",ref:c,children:[(0,n.jsx)("button",{type:"button",onClick:()=>i(!s),className:"p-1.5 rounded-md hover:bg-[var(--color-surface-hover)] transition-colors",style:{color:"var(--color-text-muted)"},title:"View settings",children:(0,n.jsx)(nY,{})}),s&&(0,n.jsxs)("div",{className:"absolute right-0 top-full mt-1 z-50 rounded-lg border shadow-lg p-3 min-w-[200px] sm:min-w-[240px] max-w-[calc(100vw-2rem)] flex flex-col gap-3",style:{borderColor:"var(--color-border)",background:"var(--color-surface)",boxShadow:"0 8px 24px rgba(0,0,0,0.12)"},children:[(0,n.jsx)("div",{className:"text-[11px] font-semibold",style:{color:"var(--color-text)"},children:{table:"",kanban:"Board Settings",calendar:"Calendar Settings",timeline:"Timeline Settings",gallery:"Gallery Settings",list:"List Settings"}[t]}),"kanban"===t&&(0,n.jsx)(nJ,{settings:r,fields:l,onSettingsChange:a}),"calendar"===t&&(0,n.jsx)(nq,{settings:r,fields:l,onSettingsChange:a}),"timeline"===t&&(0,n.jsx)(nG,{settings:r,fields:l,onSettingsChange:a}),"gallery"===t&&(0,n.jsx)(n$,{settings:r,fields:l,onSettingsChange:a}),"list"===t&&(0,n.jsx)(nZ,{settings:r,fields:l,onSettingsChange:a})]})]})}var nX=r(24946);function n0(e){let t=[],r=0;for(let o of e.matchAll(/```report-json\s*\n([\s\S]*?)```/g)){var n;let l=e.slice(r,o.index);l.trim()&&t.push({type:"text",text:l});try{let e=JSON.parse(o[1]);e.panels&&Array.isArray(e.panels)?t.push({type:"report-artifact",config:e}):t.push({type:"text",text:o[0]})}catch(e){t.push({type:"text",text:o[0]})}r=(null!=(n=o.index)?n:0)+o[0].length}let o=e.slice(r);return o.trim()&&t.push({type:"text",text:o}),t}function n1(e){return e.includes("```report-json")}function n2(e){let t=[],r=0;for(let o of e.matchAll(/```diff\s*\n([\s\S]*?)```/g)){var n;let l=e.slice(r,o.index);l.trim()&&t.push({type:"text",text:l});let a=o[1].trimEnd();a?t.push({type:"diff-artifact",diff:a}):t.push({type:"text",text:o[0]}),r=(null!=(n=o.index)?n:0)+o[0].length}let o=e.slice(r);return o.trim()&&t.push({type:"text",text:o}),t}function n4(e){return e.includes("```diff")}function n5(){return(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"}),(0,n.jsx)("path",{d:"M14 2v4a2 2 0 0 0 2 2h4"})]})}function n3(e){let{expanded:t}=e;return(0,n.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{transition:"transform 150ms ease",transform:t?"rotate(90deg)":"rotate(0deg)"},children:(0,n.jsx)("polyline",{points:"9 18 15 12 9 6"})})}function n6(e){let{file:t}=e,[r,l]=(0,o.useState)(!0),a=t.newPath&&"/dev/null"!==t.newPath?t.newPath:t.oldPath&&"/dev/null"!==t.oldPath?t.oldPath:"diff";return(0,n.jsxs)("div",{className:"rounded-lg border overflow-hidden",style:{borderColor:"var(--color-border)"},children:[(0,n.jsxs)("button",{type:"button",onClick:()=>l(!r),className:"flex items-center gap-2 w-full px-3 py-2 text-left",style:{background:"var(--color-surface)",borderBottom:r?"1px solid var(--color-border)":"none"},children:[(0,n.jsx)(n3,{expanded:r}),(0,n.jsx)(n5,{}),(0,n.jsx)("span",{className:"text-sm font-mono font-medium flex-1 truncate",style:{color:"var(--color-text)"},children:a}),t.additions>0&&(0,n.jsxs)("span",{className:"text-xs font-mono font-medium",style:{color:"var(--diff-add-badge)"},children:["+",t.additions]}),t.deletions>0&&(0,n.jsxs)("span",{className:"text-xs font-mono font-medium",style:{color:"var(--diff-del-badge)"},children:["-",t.deletions]})]}),r&&(0,n.jsx)("div",{className:"overflow-x-auto",style:{background:"var(--color-bg)"},children:(0,n.jsx)("table",{className:"w-full text-xs font-mono leading-5 border-collapse",style:{tabSize:4},children:(0,n.jsx)("tbody",{children:t.hunks.map((e,t)=>e.lines.map((e,r)=>{if("header"===e.type)return(0,n.jsx)("tr",{children:(0,n.jsx)("td",{colSpan:3,className:"px-3 py-1 select-none",style:{background:"var(--color-surface)",color:"var(--color-text-muted)"},children:e.content})},"".concat(t,"-").concat(r));let o="addition"===e.type?"var(--diff-add-bg)":"deletion"===e.type?"var(--diff-del-bg)":"transparent",l="addition"===e.type?"var(--diff-add-text)":"deletion"===e.type?"var(--diff-del-text)":"var(--color-text)",a="addition"===e.type?"+":"deletion"===e.type?"-":" ";return(0,n.jsxs)("tr",{style:{background:o},children:[(0,n.jsx)("td",{className:"select-none text-right pr-2 pl-3",style:{color:"var(--color-text-muted)",opacity:.5,width:"1%",whiteSpace:"nowrap",userSelect:"none"},children:"addition"!==e.type?e.oldLine:""}),(0,n.jsx)("td",{className:"select-none text-right pr-3",style:{color:"var(--color-text-muted)",opacity:.5,width:"1%",whiteSpace:"nowrap",userSelect:"none"},children:"deletion"!==e.type?e.newLine:""}),(0,n.jsxs)("td",{className:"pr-4",style:{color:l},children:[(0,n.jsx)("span",{className:"select-none inline-block w-4 text-center",style:{opacity:.6,userSelect:"none"},children:a}),e.content]})]},"".concat(t,"-").concat(r))}))})})})]})}function n8(e){let{diff:t}=e,r=(0,o.useMemo)(()=>(function(e){let t=[],r=e.split("\n"),n=null,o=null,l=0,a=0;for(let e=0;e<r.length;e++){let s=r[e];if(s.startsWith("--- ")){let o=r[e+1];if(null==o?void 0:o.startsWith("+++ ")){n={oldPath:s.replace(/^--- (a\/)?/,"").trim(),newPath:o.replace(/^\+\+\+ (b\/)?/,"").trim(),hunks:[],additions:0,deletions:0},t.push(n),e++;continue}}let i=s.match(/^@@\s+-(\d+)(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s+@@(.*)/);if(i){l=parseInt(i[1],10),a=parseInt(i[2],10),o={header:s,lines:[{type:"header",content:s}]},n?n.hunks.push(o):(n={oldPath:"",newPath:"",hunks:[o],additions:0,deletions:0},t.push(n));continue}o&&n&&(s.startsWith("+")?(o.lines.push({type:"addition",content:s.slice(1),newLine:a}),n.additions++,a++):s.startsWith("-")?(o.lines.push({type:"deletion",content:s.slice(1),oldLine:l}),n.deletions++,l++):(s.startsWith(" ")||""===s)&&(o.lines.push({type:"context",content:s.slice(1)||"",oldLine:l,newLine:a}),l++,a++))}if(0===t.length&&e.trim()){let r=e.split("\n").map(e=>e.startsWith("+")?{type:"addition",content:e.slice(1)}:e.startsWith("-")?{type:"deletion",content:e.slice(1)}:{type:"context",content:e});t.push({oldPath:"",newPath:"",hunks:[{header:"",lines:r}],additions:r.filter(e=>"addition"===e.type).length,deletions:r.filter(e=>"deletion"===e.type).length})}return t})(t),[t]);return(0,n.jsx)("div",{className:"space-y-2 my-3",children:r.map((e,t)=>(0,n.jsx)(n6,{file:e},t))})}let n7=(0,nX.default)(()=>r.e(3867).then(r.bind(r,53867)).then(e=>e.MarkdownContent),{loadableGenerated:{webpack:()=>[53867]},ssr:!1,loading:()=>(0,n.jsxs)("div",{className:"animate-pulse space-y-3 py-4",children:[(0,n.jsx)("div",{className:"h-4 rounded",style:{background:"var(--color-surface)",width:"80%"}}),(0,n.jsx)("div",{className:"h-4 rounded",style:{background:"var(--color-surface)",width:"60%"}}),(0,n.jsx)("div",{className:"h-4 rounded",style:{background:"var(--color-surface)",width:"70%"}})]})}),n9=(0,nX.default)(()=>r.e(5477).then(r.bind(r,45477)).then(e=>({default:e.ReportCard})),{loadableGenerated:{webpack:()=>[45477]},ssr:!1,loading:()=>(0,n.jsx)("div",{className:"h-48 rounded-xl animate-pulse my-4",style:{background:"var(--color-surface)"}})}),oe=(0,nX.default)(()=>Promise.resolve().then(r.bind(r,52597)).then(e=>({default:e.MarkdownEditor})),{loadableGenerated:{webpack:()=>[52597]},ssr:!1,loading:()=>(0,n.jsxs)("div",{className:"animate-pulse space-y-3 py-4 px-6",children:[(0,n.jsx)("div",{className:"h-4 rounded",style:{background:"var(--color-surface)",width:"80%"}}),(0,n.jsx)("div",{className:"h-4 rounded",style:{background:"var(--color-surface)",width:"60%"}}),(0,n.jsx)("div",{className:"h-4 rounded",style:{background:"var(--color-surface)",width:"70%"}})]})});function ot(e){let{content:t,title:r,filePath:l,tree:a,onSave:s,onDirty:i,onNavigate:c,searchFn:d}=e,[u,p]=(0,o.useState)(!!l),h=t.replace(/^---\s*\n[\s\S]*?\n---\s*\n/,""),x=h.match(/^#\s+(.+)/m),m=null!=r?r:null==x?void 0:x[1],f=m&&x?h.replace(/^#\s+.+\n?/,""):h;if(u&&l)return(0,n.jsx)("div",{className:"max-w-3xl mx-auto",children:(0,n.jsx)(oe,{content:h,rawContent:t,filePath:l,tree:null!=a?a:[],onSave:s,onDirty:i,onNavigate:c,searchFn:d})});let v=n1(f)||n4(f),g=(0,o.useCallback)(e=>{let t=e.target.closest("a");if(!t)return;let r=t.getAttribute("href");if(r){if(r.startsWith("#")){var n;e.preventDefault(),e.stopPropagation();let t=r.slice(1),o=e.currentTarget,l=null!=(n=Array.from(o.querySelectorAll("h1, h2, h3, h4, h5, h6")).find(e=>(e.textContent||"").trim().toLowerCase().replace(/[^\w\s-]/g,"").replace(/\s+/g,"-")===t))?n:o.querySelector('[id="'.concat(CSS.escape(t),'"]'));null==l||l.scrollIntoView({behavior:"smooth",block:"start"});return}if(c){if((0,ta.m9)(r)||!r.startsWith("http://")&&!r.startsWith("https://")&&!r.startsWith("mailto:")){e.preventDefault(),e.stopPropagation(),c(r);return}e.preventDefault(),e.stopPropagation(),window.open(r,"_blank","noopener,noreferrer")}}},[c]);return(0,n.jsxs)("div",{className:"max-w-3xl mx-auto px-6 py-8",onClick:g,children:[(0,n.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[m&&(0,n.jsx)("h1",{className:"text-3xl font-bold mb-6 flex-1",style:{color:"var(--color-text)"},children:m}),l&&(0,n.jsxs)("button",{type:"button",onClick:()=>p(!0),className:"editor-mode-toggle flex-shrink-0 mt-1",title:"Edit this document",children:[(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"}),(0,n.jsx)("path",{d:"m15 5 4 4"})]}),(0,n.jsx)("span",{children:"Edit"})]})]}),v?(0,n.jsx)(or,{content:f}):(0,n.jsx)("div",{className:"workspace-prose",children:(0,n.jsx)(n7,{content:f})})]})}function or(e){let{content:t}=e,r=n0(t),o=[];for(let e of r)if("text"===e.type&&n4(e.text))for(let t of n2(e.text))o.push(t);else o.push(e);return(0,n.jsx)("div",{className:"space-y-4",children:o.map((e,t)=>"report-artifact"===e.type?(0,n.jsx)("div",{className:"my-6",children:(0,n.jsx)(n9,{config:e.config})},t):"diff-artifact"===e.type?(0,n.jsx)("div",{className:"my-4",children:(0,n.jsx)(n8,{diff:e.diff})},t):(0,n.jsx)("div",{className:"workspace-prose",children:(0,n.jsx)(n7,{content:e.text})},t))})}let on=new Set(["xlsx","xls","xlsb","xlsm","xltx","xltm","ods","fods","csv","tsv","numbers"]);function oo(e){var t,r;let n=null!=(r=null==(t=e.split(".").pop())?void 0:t.toLowerCase())?r:"";return on.has(n)}function ol(e){let{content:t,filename:r,type:o}=e,l=t.split("\n");return(0,n.jsxs)("div",{className:"max-w-4xl mx-auto px-6 py-8",children:[(0,n.jsx)(oa,{filename:r,label:o.toUpperCase()}),(0,n.jsx)("div",{className:"rounded-b-lg border overflow-x-auto",style:{background:"var(--color-bg)",borderColor:"var(--color-border)"},children:(0,n.jsx)("pre",{className:"text-sm leading-6",style:{margin:0},children:(0,n.jsx)("code",{children:l.map((e,t)=>(0,n.jsxs)("div",{className:"flex hover:bg-[var(--color-surface-hover)] transition-colors duration-75",children:[(0,n.jsx)("span",{className:"select-none text-right pr-4 pl-4 flex-shrink-0 tabular-nums",style:{color:"var(--color-text-muted)",opacity:.5,minWidth:"3rem",userSelect:"none"},children:t+1}),(0,n.jsx)("span",{className:"pr-4 flex-1",style:{color:"var(--color-text)"},children:"yaml"===o?(0,n.jsx)(os,{line:e}):e||" "})]},t))})})})]})}function oa(e){let{filename:t,label:r,icon:o}=e;return(0,n.jsxs)("div",{className:"flex items-center gap-2 px-4 py-2.5 rounded-t-lg border border-b-0",style:{background:"var(--color-surface)",borderColor:"var(--color-border)"},children:[null!=o?o:(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--color-text-muted)"},children:[(0,n.jsx)("path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"}),(0,n.jsx)("path",{d:"M14 2v4a2 2 0 0 0 2 2h4"})]}),(0,n.jsx)("span",{className:"text-sm font-medium",style:{color:"var(--color-text)"},children:t}),(0,n.jsx)("span",{className:"text-xs px-1.5 py-0.5 rounded ml-auto",style:{background:"var(--color-surface-hover)",color:"var(--color-text-muted)"},children:r})]})}function os(e){let{line:t}=e;if(t.trim().startsWith("#"))return(0,n.jsx)("span",{style:{color:"var(--color-text-muted)"},children:t});let r=t.match(/^(\s*)([\w][\w_-]*)\s*(:)(.*)/);if(r){let[,e,t,o,l]=r;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{children:e}),(0,n.jsx)("span",{style:{color:"#60a5fa"},children:t}),(0,n.jsx)("span",{style:{color:"var(--color-text-muted)"},children:o}),(0,n.jsx)(oi,{value:l})]})}let o=t.match(/^(\s*)(-)(\s*)(.*)/);if(o){let[,e,t,r,l]=o;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{children:e}),(0,n.jsx)("span",{style:{color:"var(--color-accent)"},children:t}),(0,n.jsx)("span",{children:r}),(0,n.jsx)("span",{style:{color:"var(--color-text)"},children:l})]})}return(0,n.jsx)("span",{children:t||" "})}function oi(e){let{value:t}=e,r=t.trim();return r.startsWith('"')&&r.endsWith('"')||r.startsWith("'")&&r.endsWith("'")?(0,n.jsxs)("span",{style:{color:"#a5d6a7"},children:[" ",r]}):"true"===r||"false"===r?(0,n.jsxs)("span",{style:{color:"#f59e0b"},children:[" ",r]}):/^-?\d+(\.\d+)?$/.test(r)?(0,n.jsxs)("span",{style:{color:"#c084fc"},children:[" ",r]}):"null"===r?(0,n.jsxs)("span",{style:{color:"var(--color-text-muted)",fontStyle:"italic"},children:[" ",r]}):(0,n.jsxs)("span",{style:{color:"var(--color-text)"},children:[" ",t]})}var oc=r(81584),od=r(13292);let ou=new Set(["csv","tsv"]);function op(e){var t,r;return null!=(r=null==(t=e.split(".").pop())?void 0:t.toLowerCase())?r:""}function oh(e){let t="",r=e;do t=String.fromCharCode(65+r%26)+t,r=Math.floor(r/26)-1;while(r>=0);return t}function ox(e){let{state:t,onClose:r,onInsertRowAbove:l,onInsertRowBelow:a,onInsertColLeft:s,onInsertColRight:i,onDeleteRow:c,onDeleteCol:d,onClearCells:u}=e,p=(0,o.useRef)(null);if((0,o.useEffect)(()=>{if(!t)return;let e=e=>{p.current&&!p.current.contains(e.target)&&r()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[t,r]),!t)return null;let h={padding:"6px 12px",fontSize:"12px",cursor:"pointer",color:"var(--color-text)",borderRadius:"4px"};return(0,n.jsx)("div",{ref:p,style:{position:"fixed",top:t.y,left:t.x,zIndex:9999,background:"var(--color-surface-raised)",border:"1px solid var(--color-border)",borderRadius:"8px",padding:"4px",boxShadow:"var(--shadow-lg)",minWidth:"180px"},children:[{label:"Insert row above",action:l},{label:"Insert row below",action:a},{label:"Insert column left",action:s},{label:"Insert column right",action:i},{label:"Delete row",action:c,danger:!0},{label:"Delete column",action:d,danger:!0},{label:"Clear cells",action:u,danger:!0}].map((e,t)=>(0,n.jsxs)("div",{children:[4===t&&(0,n.jsx)("div",{style:{height:"1px",background:"var(--color-border)",margin:"4px 0"}}),(0,n.jsx)("button",{type:"button",onClick:()=>{e.action(),r()},style:{...h,color:e.danger?"var(--color-error)":"var(--color-text)",display:"block",width:"100%",textAlign:"left",background:"transparent",border:"none"},onMouseEnter:e=>{e.currentTarget.style.background="var(--color-surface-hover)"},onMouseLeave:e=>{e.currentTarget.style.background="transparent"},children:e.label})]},t))})}function om(e){let{data:t,onNavigate:r,onClose:l}=e,[a,s]=(0,o.useState)(""),[i,c]=(0,o.useState)([]),[d,u]=(0,o.useState)(0),p=(0,o.useRef)(null);(0,o.useEffect)(()=>{var e;null==(e=p.current)||e.focus()},[]),(0,o.useEffect)(()=>{if(!a.trim()){c([]),u(0);return}let e=a.toLowerCase(),n=[];t.forEach((t,r)=>{null==t||t.forEach((t,o)=>{t&&String(t.value).toLowerCase().includes(e)&&n.push({row:r,column:o})})}),c(n),u(0),n.length>0&&r(n[0])},[a,t,r]);let h=(0,o.useCallback)(e=>{if(0===i.length)return;let t=(e%i.length+i.length)%i.length;u(t),r(i[t])},[i,r]);return(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"6px",padding:"6px 12px",background:"var(--color-surface)",borderBottom:"1px solid var(--color-border)"},children:[(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--color-text-muted)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,n.jsx)("path",{d:"m21 21-4.3-4.3"})]}),(0,n.jsx)("input",{ref:p,value:a,onChange:e=>s(e.target.value),onKeyDown:e=>{"Escape"===e.key&&l(),"Enter"===e.key&&(e.preventDefault(),h(e.shiftKey?d-1:d+1))},placeholder:"Find in sheet...",style:{flex:1,background:"transparent",border:"none",outline:"none",fontSize:"12px",color:"var(--color-text)"}}),a&&(0,n.jsx)("span",{style:{fontSize:"11px",color:"var(--color-text-muted)",whiteSpace:"nowrap"},children:i.length>0?"".concat(d+1," of ").concat(i.length):"No results"}),(0,n.jsx)("button",{type:"button",onClick:()=>h(d-1),disabled:0===i.length,style:{background:"transparent",border:"none",cursor:"pointer",padding:"2px",color:"var(--color-text-muted)",opacity:0===i.length?.3:1},title:"Previous (Shift+Enter)",children:(0,n.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,n.jsx)("path",{d:"m18 15-6-6-6 6"})})}),(0,n.jsx)("button",{type:"button",onClick:()=>h(d+1),disabled:0===i.length,style:{background:"transparent",border:"none",cursor:"pointer",padding:"2px",color:"var(--color-text-muted)",opacity:0===i.length?.3:1},title:"Next (Enter)",children:(0,n.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,n.jsx)("path",{d:"m6 9 6 6 6-6"})})}),(0,n.jsx)("button",{type:"button",onClick:l,style:{background:"transparent",border:"none",cursor:"pointer",padding:"2px",color:"var(--color-text-muted)"},title:"Close (Esc)",children:(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[(0,n.jsx)("path",{d:"M18 6 6 18"}),(0,n.jsx)("path",{d:"m6 6 12 12"})]})})]})}function of(e){let{onClick:t,title:r,disabled:o,children:l,accent:a}=e;return(0,n.jsx)("button",{type:"button",onClick:t,disabled:o,title:r,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"28px",height:"28px",borderRadius:"6px",border:"none",background:a?"var(--color-accent)":"transparent",color:a?"#fff":"var(--color-text-muted)",cursor:o?"default":"pointer",opacity:o?.35:1,flexShrink:0,transition:"background 0.1s, color 0.1s"},onMouseEnter:e=>{o||a||(e.currentTarget.style.background="var(--color-surface-hover)")},onMouseLeave:e=>{a||(e.currentTarget.style.background="transparent")},children:l})}function ov(){return(0,n.jsx)("div",{style:{width:"1px",height:"18px",background:"var(--color-border)",margin:"0 4px",flexShrink:0}})}function og(e){var t,r;let{url:l,filename:a,filePath:s,compact:i=!1,onDirty:c}=e,[d,u]=(0,o.useState)(null),[p,h]=(0,o.useState)(0),[x,m]=(0,o.useState)(null),[f,v]=(0,o.useState)(!1),[g,y]=(0,o.useState)(!1),[b,j]=(0,o.useState)(!1),[w,N]=(0,o.useState)(null),[C,S]=(0,o.useState)(null),[M,L]=(0,o.useState)(null),[T,I]=(0,o.useState)(!1),R=(0,o.useRef)(null),[_,E]=(0,o.useState)([]),[D,A]=(0,o.useState)([]);(0,o.useEffect)(()=>{let e=!1;return u(null),h(0),m(null),v(!1),E([]),A([]),fetch(l).then(e=>{if(!e.ok)throw Error("Failed to load file (".concat(e.status,")"));return e.arrayBuffer()}).then(t=>{if(e)return;let r=(0,od.LF)(t,{type:"array"}),n=r.SheetNames.map(e=>({name:e,data:function(e){let t=od.Wp.sheet_to_json(e,{header:1,defval:""});if(0===t.length)return(0,oc.JH)(1,1);let r=t.reduce((e,t)=>Math.max(e,t.length),0);return t.map(e=>{let t=[];for(let n=0;n<r;n++){let r=n<e.length?e[n]:"";t.push({value:null==r?"":r})}return t})}(r.Sheets[e])}));0===n.length&&n.push({name:"Sheet1",data:(0,oc.JH)(50,26)}),u(n)}).catch(t=>{e||m(String(t))}),()=>{e=!0}},[l]);let W=null!=(r=null==d||null==(t=d[p])?void 0:t.data)?r:[],B=(0,o.useMemo)(()=>{let e=0;for(let t of W)t&&(e=Math.max(e,t.length));return e},[W]),F=(0,o.useMemo)(()=>Array.from({length:B},(e,t)=>oh(t)),[B]),P=(0,o.useCallback)(()=>{d&&(E(e=>[...e.slice(-49),{sheetIdx:p,data:d[p].data}]),A([]))},[d,p]),z=(0,o.useCallback)(e=>{u(t=>{if(!t)return t;let r=[...t];return r[p]={...r[p],data:e},r}),v(!0),null==c||c()},[p,c]),O=(0,o.useCallback)(e=>{P(),z(e)},[P,z]),U=(0,o.useCallback)(()=>{if(0===_.length||!d)return;let e=_[_.length-1];A(e=>[...e,{sheetIdx:p,data:d[p].data}]),E(e=>e.slice(0,-1)),u(t=>{if(!t)return t;let r=[...t];return r[e.sheetIdx]={...r[e.sheetIdx],data:e.data},r}),e.sheetIdx!==p&&h(e.sheetIdx)},[_,d,p]),H=(0,o.useCallback)(()=>{if(0===D.length||!d)return;let e=D[D.length-1];E(e=>[...e,{sheetIdx:p,data:d[p].data}]),A(e=>e.slice(0,-1)),u(t=>{if(!t)return t;let r=[...t];return r[e.sheetIdx]={...r[e.sheetIdx],data:e.data},r}),e.sheetIdx!==p&&h(e.sheetIdx)},[D,d,p]),V=(0,o.useCallback)(e=>{P();let t=Array.from({length:B},()=>({value:""})),r=[...W];r.splice(e,0,t),z(r)},[P,z,W,B]),K=(0,o.useCallback)(e=>{if(W.length<=1)return;P();let t=[...W];t.splice(e,1),z(t)},[P,z,W]),J=(0,o.useCallback)(e=>{P(),z(W.map(t=>{let r=[...null!=t?t:[]];return r.splice(e,0,{value:""}),r}))},[P,z,W]),q=(0,o.useCallback)(e=>{B<=1||(P(),z(W.map(t=>{let r=[...null!=t?t:[]];return r.splice(e,1),r})))},[P,z,W,B]),G=(0,o.useCallback)(()=>{if(!C)return;let e=C.toRange(W);if(!e)return;P();let t=W.map(e=>e?[...e]:[]);for(let r of e)t[r.row]&&(t[r.row][r.column]={value:""});z(t)},[C,W,P,z]),$=(0,o.useCallback)(async()=>{if(d&&!g){y(!0);try{if(ou.has(op(a))){let e="tsv"===op(a)?" ":",",t=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:",";return e.map(e=>(null!=e?e:[]).map(e=>{let r=e?String(e.value):"";return r.includes(t)||r.includes('"')||r.includes("\n")?'"'.concat(r.replace(/"/g,'""'),'"'):r}).join(t)).join("\n")}(d[p].data,e);if(!(await fetch((0,k.nC)(s),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:s,content:t})})).ok)throw Error("Save failed")}else{let e=od.Wp.book_new();for(let t of d)od.Wp.book_append_sheet(e,function(e){let t=e.map(e=>(null!=e?e:[]).map(e=>e?e.value:""));return od.Wp.aoa_to_sheet(t)}(t.data),t.name);let t=(0,od.M9)(e,{type:"array",bookType:op(a)});if(!(await fetch("/api/workspace/raw-file?path=".concat(encodeURIComponent(s)),{method:"POST",body:t})).ok)throw Error("Save failed")}v(!1),j(!0),setTimeout(()=>j(!1),1500)}catch(e){console.error("Spreadsheet save error:",e)}finally{y(!1)}}},[d,g,a,s,p]);(0,o.useEffect)(()=>{let e=e=>{let t=e.metaKey||e.ctrlKey;t&&"s"===e.key&&(e.preventDefault(),$()),t&&"z"===e.key&&!e.shiftKey&&(e.preventDefault(),U()),t&&"z"===e.key&&e.shiftKey&&(e.preventDefault(),H()),t&&"f"===e.key&&(e.preventDefault(),I(e=>!e))};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[$,U,H]);let Z=(0,o.useCallback)(e=>{e.preventDefault();let t=e.target.closest("td");if(!t)return;let r=t.closest("tr");if(!r)return;let n=r.closest("tbody");if(!n)return;let o=Array.from(n.children).indexOf(r),l=Array.from(r.children).indexOf(t)-1;o<0||l<0||L({x:e.clientX,y:e.clientY,row:o,col:l})},[]),Y=(0,o.useCallback)(e=>{var t;N(e),null==(t=R.current)||t.activate(e),S(new oc.MH(new oc.m9(e,e)))},[]),Q=(0,o.useMemo)(()=>{var e;if(!w)return"";let t=null==(e=W[w.row])?void 0:e[w.column];return t?String(t.value):""},[w,W]),X=(0,o.useCallback)(e=>{if(!w)return;P();let t=W.map(e=>e?[...e]:[]);t[w.row]||(t[w.row]=[]),t[w.row][w.column]={value:e},z(t)},[w,W,P,z]),ee=(0,o.useMemo)(()=>(function(e,t){if(!t)return null;let r=t.toRange(e);if(!r)return null;let n=0,o=0,l=0;for(let t of r){var a;let r=null==(a=e[t.row])?void 0:a[t.column];if(!r)continue;n++;let s=Number(r.value);""===r.value||isNaN(s)||(o++,l+=s)}return n<=1?null:{count:n,numericCount:o,sum:l,avg:o>0?l/o:0}})(W,C),[W,C]),et=op(a).toUpperCase()||"SPREADSHEET";return x?(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",gap:"12px",padding:"24px"},children:[(0,n.jsx)(oy,{size:32}),(0,n.jsx)("p",{style:{color:"var(--color-text)",fontWeight:500,fontSize:"14px"},children:"Failed to load spreadsheet"}),(0,n.jsx)("p",{style:{color:"var(--color-text-muted)",fontSize:"12px"},children:x})]}):d?(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",background:"var(--color-bg)",overflow:"hidden"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:i?"6px 10px":"8px 16px",borderBottom:"1px solid var(--color-border)",background:"var(--color-surface)",flexShrink:0},children:[(0,n.jsx)(oy,{size:16}),(0,n.jsx)("span",{style:{fontSize:i?"12px":"13px",fontWeight:600,color:"var(--color-text)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a}),(0,n.jsx)("span",{style:{fontSize:"10px",padding:"1px 6px",borderRadius:"4px",background:"var(--color-surface-hover)",color:"var(--color-text-muted)",fontWeight:500,flexShrink:0},children:et}),f&&(0,n.jsx)("span",{style:{fontSize:"10px",padding:"1px 6px",borderRadius:"4px",background:"var(--color-warning)",color:"#fff",fontWeight:500,flexShrink:0},children:"Unsaved"}),b&&(0,n.jsx)("span",{style:{fontSize:"10px",padding:"1px 6px",borderRadius:"4px",background:"var(--color-success)",color:"#fff",fontWeight:500,flexShrink:0},children:"Saved"}),(0,n.jsx)("div",{style:{flex:1}}),!i&&(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"2px"},children:[(0,n.jsx)(of,{onClick:$,title:"Save (⌘S)",disabled:!f||g,accent:f,children:(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z"}),(0,n.jsx)("path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7"}),(0,n.jsx)("path",{d:"M7 3v4a1 1 0 0 0 1 1h7"})]})}),(0,n.jsx)(ov,{}),(0,n.jsx)(of,{onClick:U,title:"Undo (⌘Z)",disabled:0===_.length,children:(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M3 7v6h6"}),(0,n.jsx)("path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"})]})}),(0,n.jsx)(of,{onClick:H,title:"Redo (⌘⇧Z)",disabled:0===D.length,children:(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M21 7v6h-6"}),(0,n.jsx)("path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3L21 13"})]})}),(0,n.jsx)(ov,{}),(0,n.jsx)(of,{onClick:()=>w&&V(w.row),title:"Insert row above",disabled:!w,children:(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M12 5v14"}),(0,n.jsx)("path",{d:"M5 12h14"})]})}),(0,n.jsx)(of,{onClick:()=>w&&J(w.column),title:"Insert column left",disabled:!w,children:(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),(0,n.jsx)("path",{d:"M12 8v8"}),(0,n.jsx)("path",{d:"M8 12h8"})]})}),(0,n.jsx)(ov,{}),(0,n.jsx)(of,{onClick:()=>I(e=>!e),title:"Find (⌘F)",children:(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,n.jsx)("path",{d:"m21 21-4.3-4.3"})]})})]}),i&&f&&(0,n.jsx)(of,{onClick:$,title:"Save (⌘S)",disabled:g,accent:!0,children:(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z"}),(0,n.jsx)("path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7"}),(0,n.jsx)("path",{d:"M7 3v4a1 1 0 0 0 1 1h7"})]})})]}),!i&&(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"4px 16px",borderBottom:"1px solid var(--color-border)",background:"var(--color-surface)",flexShrink:0},children:[(0,n.jsx)("span",{style:{fontSize:"11px",fontWeight:600,color:"var(--color-text-muted)",minWidth:"36px",textAlign:"center",padding:"2px 6px",borderRadius:"4px",background:"var(--color-surface-hover)",fontFamily:"monospace"},children:w?"".concat(oh(w.column)).concat(w.row+1):"\xa0"}),(0,n.jsx)("div",{style:{width:"1px",height:"18px",background:"var(--color-border)",flexShrink:0}}),(0,n.jsx)("span",{style:{fontSize:"11px",fontWeight:500,color:"var(--color-text-muted)",flexShrink:0},children:"fx"}),(0,n.jsx)("input",{type:"text",value:Q,onChange:e=>X(e.target.value),placeholder:"Select a cell",style:{flex:1,background:"transparent",border:"none",outline:"none",fontSize:"12px",color:"var(--color-text)",fontFamily:"monospace"}})]}),T&&(0,n.jsx)(om,{data:W,onNavigate:Y,onClose:()=>I(!1)}),(0,n.jsx)("div",{style:{flex:1,overflow:"auto",position:"relative"},onContextMenu:Z,children:(0,n.jsx)(oc.Ay,{ref:R,data:W,onChange:O,columnLabels:F,onActivate:N,onSelect:S,darkMode:"undefined"!=typeof document&&document.documentElement.classList.contains("dark"),className:"spreadsheet-editor-grid"})}),(0,n.jsx)(ox,{state:M,onClose:()=>L(null),onInsertRowAbove:()=>M&&V(M.row),onInsertRowBelow:()=>M&&V(M.row+1),onInsertColLeft:()=>M&&J(M.col),onInsertColRight:()=>M&&J(M.col+1),onDeleteRow:()=>M&&K(M.row),onDeleteCol:()=>M&&q(M.col),onClearCells:G}),d.length>1&&(0,n.jsx)("div",{style:{display:"flex",alignItems:"center",gap:0,borderTop:"1px solid var(--color-border)",background:"var(--color-surface)",overflow:"auto",flexShrink:0},children:d.map((e,t)=>(0,n.jsxs)("button",{type:"button",onClick:()=>h(t),style:{padding:i?"4px 10px":"6px 16px",fontSize:i?"10px":"11px",fontWeight:t===p?600:400,color:t===p?"var(--color-text)":"var(--color-text-muted)",background:t===p?"var(--color-bg)":"transparent",border:"none",borderRight:"1px solid var(--color-border)",cursor:"pointer",whiteSpace:"nowrap",transition:"background 0.1s",position:"relative"},children:[e.name,t===p&&(0,n.jsx)("div",{style:{position:"absolute",top:0,left:0,right:0,height:"2px",background:"var(--color-accent)",borderRadius:"0 0 2px 2px"}})]},e.name))}),(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:i?"3px 10px":"4px 16px",borderTop:"1px solid var(--color-border)",background:"var(--color-surface)",fontSize:i?"10px":"11px",color:"var(--color-text-muted)",flexShrink:0,gap:"12px"},children:[(0,n.jsxs)("span",{children:[W.length," row",1!==W.length?"s":""," \xd7 ",B," col",1!==B?"s":"",d.length>1?" \xb7 ".concat(d.length," sheets"):""]}),ee&&(0,n.jsxs)("span",{style:{textAlign:"right"},children:["Count: ",ee.count,ee.numericCount>0&&(0,n.jsxs)(n.Fragment,{children:[" \xb7 ","Sum: ",ee.sum.toLocaleString()," \xb7 ","Avg: ",ee.avg.toLocaleString(void 0,{maximumFractionDigits:2})]})]})]})]}):(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",gap:"12px"},children:[(0,n.jsx)("div",{className:"animate-spin",style:{width:"20px",height:"20px",border:"2px solid var(--color-border)",borderTopColor:"var(--color-accent)",borderRadius:"50%"}}),(0,n.jsx)("p",{style:{color:"var(--color-text-muted)",fontSize:"12px"},children:"Loading spreadsheet..."})]})}function oy(e){let{size:t=16}=e;return(0,n.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"#22c55e",flexShrink:0},children:[(0,n.jsx)("path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"}),(0,n.jsx)("path",{d:"M14 2v4a2 2 0 0 0 2 2h4"}),(0,n.jsx)("path",{d:"M8 13h2"}),(0,n.jsx)("path",{d:"M14 13h2"}),(0,n.jsx)("path",{d:"M8 17h2"}),(0,n.jsx)("path",{d:"M14 17h2"})]})}var ob=r(35778);let oj=null;function ok(e){let{filename:t,rawUrl:r,contentUrl:l}=e,[a,s]=(0,o.useState)("rendered"),[i,c]=(0,o.useState)(null),[d,u]=(0,o.useState)(!1),p=(0,o.useCallback)(()=>{s("code"),null===i&&(u(!0),fetch(l).then(e=>e.json()).then(e=>c(e.content)).catch(()=>c("\x3c!-- Failed to load source --\x3e")).finally(()=>u(!1)))},[l,i]);return(0,n.jsxs)("div",{className:"flex flex-col h-full",children:[(0,n.jsxs)("div",{className:"flex items-center gap-3 px-5 py-3 border-b flex-shrink-0",style:{borderColor:"var(--color-border)"},children:[(0,n.jsx)(oC,{}),(0,n.jsx)("span",{className:"text-sm font-medium truncate",style:{color:"var(--color-text)"},children:t}),(0,n.jsx)("span",{className:"text-[10px] px-2 py-0.5 rounded-full flex-shrink-0",style:{background:"#f9731618",color:"#f97316",border:"1px solid #f9731630"},children:"HTML"}),(0,n.jsxs)("div",{className:"flex items-center ml-auto rounded-lg p-0.5",style:{background:"var(--color-surface-hover)"},children:[(0,n.jsxs)("button",{type:"button",onClick:()=>s("rendered"),className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium transition-colors duration-100 cursor-pointer",style:{background:"rendered"===a?"var(--color-surface)":"transparent",color:"rendered"===a?"var(--color-text)":"var(--color-text-muted)",boxShadow:"rendered"===a?"0 1px 2px rgba(0,0,0,0.1)":"none"},children:[(0,n.jsx)(oS,{}),"Preview"]}),(0,n.jsxs)("button",{type:"button",onClick:p,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium transition-colors duration-100 cursor-pointer",style:{background:"code"===a?"var(--color-surface)":"transparent",color:"code"===a?"var(--color-text)":"var(--color-text-muted)",boxShadow:"code"===a?"0 1px 2px rgba(0,0,0,0.1)":"none"},children:[(0,n.jsx)(oM,{}),"Code"]})]}),(0,n.jsx)("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"p-1.5 rounded-md transition-colors duration-100",style:{color:"var(--color-text-muted)"},title:"Open in new tab",onMouseEnter:e=>{e.currentTarget.style.background="var(--color-surface-hover)"},onMouseLeave:e=>{e.currentTarget.style.background="transparent"},children:(0,n.jsx)(oL,{})})]}),"rendered"===a?(0,n.jsx)(ow,{rawUrl:r}):d||null===i?(0,n.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,n.jsx)("div",{className:"w-6 h-6 border-2 rounded-full animate-spin",style:{borderColor:"var(--color-border)",borderTopColor:"var(--color-accent)"}})}):(0,n.jsx)(oN,{content:i})]})}function ow(e){let{rawUrl:t}=e;return(0,n.jsx)("div",{className:"flex-1 overflow-hidden",style:{background:"white"},children:(0,n.jsx)("iframe",{src:t,className:"w-full h-full border-0",sandbox:"allow-same-origin allow-scripts allow-popups",title:"HTML preview",style:{minHeight:"calc(100vh - 120px)"}})})}function oN(e){let{content:t}=e,[r,l]=(0,o.useState)(null),a=(0,o.useMemo)(()=>t.split("\n").length,[t]);return(0,o.useEffect)(()=>{let e=!1;return(!oj&&(oj=(0,ob.O_)({themes:["github-dark","github-light"],langs:["html"]})),oj).then(r=>{e||l(r.codeToHtml(t,{lang:"html",themes:{dark:"github-dark",light:"github-light"}}))}),()=>{e=!0}},[t]),(0,n.jsx)("div",{className:"flex-1 overflow-auto",style:{background:"var(--color-surface)"},children:(0,n.jsxs)("div",{className:"max-w-4xl mx-auto px-6 py-8",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 px-4 py-2.5 rounded-t-lg border border-b-0",style:{background:"var(--color-surface)",borderColor:"var(--color-border)"},children:[(0,n.jsx)(oM,{}),(0,n.jsx)("span",{className:"text-xs",style:{color:"var(--color-text-muted)"},children:"HTML"}),(0,n.jsxs)("span",{className:"text-xs ml-auto",style:{color:"var(--color-text-muted)"},children:[a," lines"]})]}),(0,n.jsx)("div",{className:"code-viewer-content rounded-b-lg border overflow-x-auto",style:{background:"var(--color-bg)",borderColor:"var(--color-border)"},children:r?(0,n.jsx)("div",{className:"code-viewer-highlighted",dangerouslySetInnerHTML:{__html:r}}):(0,n.jsx)("pre",{className:"text-sm leading-6",style:{margin:0},children:(0,n.jsx)("code",{children:t.split("\n").map((e,t)=>(0,n.jsxs)("div",{className:"flex hover:bg-[var(--color-surface-hover)] transition-colors duration-75",children:[(0,n.jsx)("span",{className:"select-none text-right pr-4 pl-4 flex-shrink-0 tabular-nums",style:{color:"var(--color-text-muted)",opacity:.5,minWidth:"3rem",userSelect:"none"},children:t+1}),(0,n.jsx)("span",{className:"pr-4 flex-1",style:{color:"var(--color-text)"},children:e||" "})]},t))})})})]})})}function oC(){return(0,n.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"#f97316",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("polyline",{points:"16 18 22 12 16 6"}),(0,n.jsx)("polyline",{points:"8 6 2 12 8 18"}),(0,n.jsx)("line",{x1:"12",x2:"10",y1:"2",y2:"22"})]})}function oS(){return(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"}),(0,n.jsx)("circle",{cx:"12",cy:"12",r:"3"})]})}function oM(){return(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("polyline",{points:"16 18 22 12 16 6"}),(0,n.jsx)("polyline",{points:"8 6 2 12 8 18"})]})}function oL(){return(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M15 3h6v6"}),(0,n.jsx)("path",{d:"M10 14 21 3"}),(0,n.jsx)("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"})]})}let oT="undefined"!=typeof globalThis?globalThis:window;oT.__denchAppRegistry||(oT.__denchAppRegistry=new Map),oT.__denchAppMessageHandlers||(oT.__denchAppMessageHandlers=new Set);let oI=oT.__denchAppRegistry;function oR(e,t){return"/api/apps/serve/".concat(e,"/").concat(t)}function o_(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];return!!e&&r.some(t=>e.includes(t))}function oE(e){let{appPath:t,manifest:r,onToast:l,onNavigate:a}=e,s=(0,o.useRef)(null),[i,c]=(0,o.useState)(!0),[d,u]=(0,o.useState)(null),p=(0,o.useRef)(null),h=(0,o.useRef)(new Set),x=(0,o.useRef)(new Map),m=(0,o.useRef)(new Map),f=oR(t,r.entry||"index.html"),v=r.permissions||[],g=t.split("/").pop()||t,y=(0,o.useCallback)(()=>{c(!0),u(null),s.current&&(s.current.src="".concat(f,"?_t=").concat(Date.now()))},[f]),b=(0,o.useCallback)(()=>{c(!1)},[]),j=(0,o.useCallback)(()=>{c(!1),u("Failed to load app")},[]);(0,o.useEffect)(()=>{let e,t={appName:g,iframe:s.current,tools:new Map};return p.current=t,(e=oI.get(t.appName))||(e=new Set,oI.set(t.appName,e)),e.add(t),()=>{let e=oI.get(t.appName);for(let r of(e&&(e.delete(t),0===e.size&&oI.delete(t.appName)),x.current.values()))clearInterval(r);x.current.clear()}},[g]),(0,o.useEffect)(()=>{function e(e,t,r,n){var o;null==(o=e.contentWindow)||o.postMessage(n?{type:"dench:response",id:t,error:n}:{type:"dench:response",id:t,result:r},"*")}function n(e,t,r){var n;null==(n=e.contentWindow)||n.postMessage({type:"dench:event",channel:t,data:r},"*")}let o=async o=>{var d,u;let f=s.current;if(!(null==f?void 0:f.contentWindow)||o.source!==f.contentWindow)return;if((null==(d=o.data)?void 0:d.type)==="dench:tool-response"){let{invokeId:e,result:t,error:r}=o.data,n=m.current.get(e);n&&(m.current.delete(e),r?n.reject(Error(r)):n.resolve(t));return}if(!o.data||"dench:request"!==o.data.type)return;let{id:y,method:b,params:j}=o.data;try{let o;if("app.getManifest"===b)o=r;else if("app.getTheme"===b)o=document.documentElement.classList.contains("dark")?"dark":"light";else if("context.getWorkspace"===b)o={name:t.split("/")[0]||"workspace"};else if("context.getAppInfo"===b)o={appPath:t,folderName:g,permissions:v,manifest:r};else if("db.query"===b&&o_(v,"database","database:write")){let e=await fetch("/api/workspace/query",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sql:null==j?void 0:j.sql})});o=await e.json()}else if("db.execute"===b&&o_(v,"database:write")){let e=await fetch("/api/workspace/execute",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sql:null==j?void 0:j.sql})});o=await e.json()}else if("objects.list"===b&&o_(v,"objects")){let e=new URLSearchParams;(null==j?void 0:j.filters)&&e.set("filters",j.filters),(null==j?void 0:j.sort)&&e.set("sort",j.sort),(null==j?void 0:j.search)&&e.set("search",j.search),(null==j?void 0:j.page)&&e.set("page",String(j.page)),(null==j?void 0:j.pageSize)&&e.set("pageSize",String(j.pageSize));let t=await fetch("/api/workspace/objects/".concat(encodeURIComponent(null==j?void 0:j.name),"?").concat(e));o=await t.json()}else if("objects.get"===b&&o_(v,"objects")){let e=await fetch("/api/workspace/objects/".concat(encodeURIComponent(null==j?void 0:j.name),"/entries/").concat(encodeURIComponent(null==j?void 0:j.entryId)));o=await e.json()}else if("objects.create"===b&&o_(v,"objects")){let e=await fetch("/api/workspace/objects/".concat(encodeURIComponent(null==j?void 0:j.name),"/entries"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fields:null==j?void 0:j.fields})});o=await e.json(),c(f,"object.entry.created",null==j?void 0:j.name,o)}else if("objects.update"===b&&o_(v,"objects")){let e=await fetch("/api/workspace/objects/".concat(encodeURIComponent(null==j?void 0:j.name),"/entries/").concat(encodeURIComponent(null==j?void 0:j.entryId)),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({fields:null==j?void 0:j.fields})});o=await e.json(),c(f,"object.entry.updated",null==j?void 0:j.name,{entryId:null==j?void 0:j.entryId})}else if("objects.delete"===b&&o_(v,"objects")){let e=await fetch("/api/workspace/objects/".concat(encodeURIComponent(null==j?void 0:j.name),"/entries/").concat(encodeURIComponent(null==j?void 0:j.entryId)),{method:"DELETE"});o=await e.json(),c(f,"object.entry.deleted",null==j?void 0:j.name,{entryId:null==j?void 0:j.entryId})}else if("objects.bulkDelete"===b&&o_(v,"objects")){let e=await fetch("/api/workspace/objects/".concat(encodeURIComponent(null==j?void 0:j.name),"/entries/bulk-delete"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({entryIds:null==j?void 0:j.entryIds})});o=await e.json(),c(f,"object.entry.deleted",null==j?void 0:j.name,{entryIds:null==j?void 0:j.entryIds})}else if("objects.getSchema"===b&&o_(v,"objects")){let e=await fetch("/api/workspace/objects/".concat(encodeURIComponent(null==j?void 0:j.name),"?schemaOnly=1"));o=await e.json()}else if("objects.getOptions"===b&&o_(v,"objects")){let e=(null==j?void 0:j.query)?"?q=".concat(encodeURIComponent(j.query)):"",t=await fetch("/api/workspace/objects/".concat(encodeURIComponent(null==j?void 0:j.name),"/entries/options").concat(e));o=await t.json()}else if("files.read"===b&&o_(v,"files","files:write")){let e=await fetch("/api/workspace/file?path=".concat(encodeURIComponent(null==j?void 0:j.path)));o=await e.json()}else if("files.list"===b&&o_(v,"files","files:write")){let e=(null==j?void 0:j.dir)?"?path=".concat(encodeURIComponent(j.dir)):"?showHidden=0",t=await fetch("/api/workspace/browse".concat(e));o=await t.json()}else if("files.write"===b&&o_(v,"files:write")){let e=await fetch("/api/workspace/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:null==j?void 0:j.path,content:null==j?void 0:j.content})});o=await e.json()}else if("files.delete"===b&&o_(v,"files:write")){let e=await fetch("/api/workspace/file?path=".concat(encodeURIComponent(null==j?void 0:j.path)),{method:"DELETE"});o=await e.json()}else if("files.mkdir"===b&&o_(v,"files:write")){let e=await fetch("/api/workspace/mkdir",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:null==j?void 0:j.path})});o=await e.json()}else if("chat.createSession"===b&&o_(v,"agent")){let e=await fetch("/api/web-sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:null==j?void 0:j.title})});o=await e.json()}else if("chat.send"===b&&o_(v,"agent")){let e=null==j?void 0:j._streamId,t=await fetch("/api/chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messages:[{role:"user",content:null==j?void 0:j.message}],sessionId:null==j?void 0:j.sessionId})});if(e&&t.body){let r=t.body.getReader(),n=new TextDecoder,l="",a="";for(;;){let{done:t,value:o}=await r.read();if(t)break;let s=(l+=n.decode(o,{stream:!0})).split("\n");for(let t of(l=s.pop()||"",s))if(t.startsWith("data: "))try{let r=JSON.parse(t.slice(6));!function(e,t,r,n,o){var l;null==(l=e.contentWindow)||l.postMessage({type:"dench:stream",streamId:t,event:r,data:n,...o},"*")}(f,e,r.type,r.data,{name:r.name,args:r.args,result:r.result}),"text-delta"===r.type&&"string"==typeof r.data&&(a+=r.data)}catch(e){}}o={text:a}}else o=await t.json()}else if("chat.getHistory"===b&&o_(v,"agent")){let e=await fetch("/api/web-sessions/".concat(encodeURIComponent(null==j?void 0:j.sessionId),"/messages"));o=await e.json()}else if("chat.getSessions"===b&&o_(v,"agent")){let e=(null==j?void 0:j.limit)?"?limit=".concat(j.limit):"",t=await fetch("/api/web-sessions".concat(e));o=await t.json()}else if("chat.abort"===b&&o_(v,"agent")){let e=await fetch("/api/chat/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:null==j?void 0:j.sessionId})});o=await e.json()}else if("chat.isActive"===b&&o_(v,"agent")){let e=await fetch("/api/chat/active"),t=await e.json();o=!!Array.isArray(t)&&t.includes(null==j?void 0:j.sessionId)}else if("agent.send"===b&&o_(v,"agent"))o={ok:(await fetch("/api/chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messages:[{role:"user",content:null==j?void 0:j.message}]})})).ok};else if("tool.register"===b&&o_(v,"agent")){let e=p.current;if(e&&(null==j?void 0:j.name)){let t={name:j.name,description:j.description||"",inputSchema:j.inputSchema};e.tools.set(j.name,t)}o={ok:!0}}else if("memory.get"===b&&o_(v,"agent")){let e=await fetch("/api/memories");o=await e.json()}else if("ui.toast"===b&&o_(v,"ui"))l&&l(null==j?void 0:j.message,{type:null==j?void 0:j.type}),o={ok:!0};else if("ui.navigate"===b&&o_(v,"ui"))a&&a(null==j?void 0:j.path),o={ok:!0};else if("ui.openEntry"===b&&o_(v,"ui"))a&&a("/".concat(null==j?void 0:j.objectName,"/").concat(null==j?void 0:j.entryId)),o={ok:!0};else if("ui.setTitle"===b&&o_(v,"ui"))window.dispatchEvent(new CustomEvent("dench:app-title-change",{detail:{appPath:t,title:null==j?void 0:j.title}})),o={ok:!0};else if("ui.confirm"===b&&o_(v,"ui"))o=window.confirm((null==j?void 0:j.message)||"");else if("ui.prompt"===b&&o_(v,"ui"))o=window.prompt((null==j?void 0:j.message)||"",(null==j?void 0:j.defaultValue)||"");else if("store.get"===b&&o_(v,"store")){let e=await fetch("/api/apps/store?app=".concat(encodeURIComponent(g),"&key=").concat(encodeURIComponent(null==j?void 0:j.key)));o=(await e.json()).value}else if("store.set"===b&&o_(v,"store")){let e=await fetch("/api/apps/store",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({app:g,key:null==j?void 0:j.key,value:null==j?void 0:j.value})});o=await e.json()}else if("store.delete"===b&&o_(v,"store")){let e=await fetch("/api/apps/store?app=".concat(encodeURIComponent(g),"&key=").concat(encodeURIComponent(null==j?void 0:j.key)),{method:"DELETE"});o=await e.json()}else if("store.list"===b&&o_(v,"store")){let e=await fetch("/api/apps/store?app=".concat(encodeURIComponent(g)));o=(await e.json()).keys}else if("store.clear"===b&&o_(v,"store")){let e=await fetch("/api/apps/store?app=".concat(encodeURIComponent(g)),{method:"DELETE"});o=await e.json()}else if("http.fetch"===b&&o_(v,"http")){let e=await fetch("/api/apps/proxy",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:null==j?void 0:j.url,method:null==j?void 0:j.method,headers:null==j?void 0:j.headers,body:null==j?void 0:j.body})});o=await e.json()}else if("events.subscribe"===b){h.current.add(null==j?void 0:j.channel),(null==j?void 0:j.channel)==="theme.changed"&&(u=f,i||(i=new MutationObserver(()=>{h.current.has("theme.changed")&&n(u,"theme.changed",{theme:document.documentElement.classList.contains("dark")?"dark":"light"})})).observe(document.documentElement,{attributes:!0,attributeFilter:["class"]})),o={ok:!0}}else if("events.unsubscribe"===b)h.current.delete(null==j?void 0:j.channel),o={ok:!0};else if("apps.send"===b&&o_(v,"apps"))!function(e,t,r){let n=oI.get(e);if(n&&0!==n.size)for(let e of n){var o;null==(o=e.iframe.contentWindow)||o.postMessage({type:"dench:event",channel:"apps.message",data:{from:r,message:t}},"*")}}(null==j?void 0:j.targetApp,null==j?void 0:j.message,g),o={ok:!0};else if("apps.list"===b&&o_(v,"apps"))o=function(){let e=[];for(let[t,r]of oI)e.push({name:t,instanceCount:r.size});return e}();else if("cron.schedule"===b&&o_(v,"cron")){let e=await fetch("/api/apps/cron",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"add",params:{expression:null==j?void 0:j.expression,message:null==j?void 0:j.message,channel:null==j?void 0:j.channel}})});o=await e.json()}else if("cron.list"===b&&o_(v,"cron")){let e=await fetch("/api/apps/cron");o=await e.json()}else if("cron.run"===b&&o_(v,"cron")){let e=await fetch("/api/apps/cron",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"run",params:{id:null==j?void 0:j.jobId}})});o=await e.json()}else if("cron.cancel"===b&&o_(v,"cron")){let e=await fetch("/api/apps/cron",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"remove",params:{id:null==j?void 0:j.jobId}})});o=await e.json()}else if("webhooks.register"===b&&o_(v,"webhooks"))o={url:"".concat(window.location.origin,"/api/apps/webhooks/").concat(encodeURIComponent(g),"/").concat(encodeURIComponent(null==j?void 0:j.hookName)),hookName:null==j?void 0:j.hookName};else if("webhooks.subscribe"===b&&o_(v,"webhooks")){let e=null==j?void 0:j.hookName;if(e&&!x.current.has(e)){let t=Date.now(),r=setInterval(async()=>{try{var r;let o=await fetch("/api/apps/webhooks/".concat(encodeURIComponent(g),"/").concat(encodeURIComponent(e),"?poll=1&since=").concat(t)),l=await o.json();if(null==(r=l.events)?void 0:r.length)for(let r of(t=Math.max(...l.events.map(e=>e.receivedAt)),l.events))n(f,"webhooks.".concat(e),r)}catch(e){}},5e3);x.current.set(e,r)}o={ok:!0}}else if("webhooks.poll"===b&&o_(v,"webhooks")){let e=(null==j?void 0:j.since)||0,t=await fetch("/api/apps/webhooks/".concat(encodeURIComponent(g),"/").concat(encodeURIComponent(null==j?void 0:j.hookName),"?poll=1&since=").concat(e));o=await t.json()}else if("clipboard.write"===b&&o_(v,"clipboard"))try{await navigator.clipboard.writeText((null==j?void 0:j.text)||""),o={ok:!0}}catch(t){let e=document.createElement("textarea");e.value=(null==j?void 0:j.text)||"",e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e),o={ok:!0}}else if(!("clipboard.read"===b&&o_(v,"clipboard")))return void e(f,y,null,"Unknown method or insufficient permissions: ".concat(b));else try{o=await navigator.clipboard.readText()}catch(e){o=null}e(f,y,o)}catch(t){e(f,y,null,t instanceof Error?t.message:"Unknown error")}},i=null;function c(e,t,r,n){let o={objectName:r,...n};if(h.current.has(t)){var l;null==(l=e.contentWindow)||l.postMessage({type:"dench:event",channel:t,data:o},"*")}}return window.addEventListener("message",o),()=>{window.removeEventListener("message",o),i&&i.disconnect()}},[r,t,g,v,l,a]);let k=r.icon&&(r.icon.endsWith(".png")||r.icon.endsWith(".svg")||r.icon.endsWith(".jpg")||r.icon.endsWith(".jpeg")||r.icon.endsWith(".webp"));return(0,n.jsxs)("div",{className:"flex flex-col h-full",children:[(0,n.jsxs)("div",{className:"flex items-center gap-3 px-5 py-2.5 border-b flex-shrink-0",style:{borderColor:"var(--color-border)"},children:[k?(0,n.jsx)("img",{src:oR(t,r.icon),alt:"",width:20,height:20,className:"rounded flex-shrink-0",style:{objectFit:"cover"}}):(0,n.jsx)(oD,{}),(0,n.jsx)("span",{className:"text-sm font-medium truncate",style:{color:"var(--color-text)"},children:r.name}),r.version&&(0,n.jsxs)("span",{className:"text-[10px] px-2 py-0.5 rounded-full flex-shrink-0",style:{background:"var(--color-accent-light)",color:"var(--color-accent)",border:"1px solid color-mix(in srgb, var(--color-accent) 20%, transparent)"},children:["v",r.version]}),(0,n.jsx)("span",{className:"text-[10px] px-2 py-0.5 rounded-full flex-shrink-0",style:{background:"#6366f118",color:"#6366f1",border:"1px solid #6366f130"},children:"APP"}),(0,n.jsxs)("div",{className:"flex items-center gap-1 ml-auto",children:[(0,n.jsx)("button",{type:"button",onClick:y,className:"p-1.5 rounded-md transition-colors duration-100 cursor-pointer",style:{color:"var(--color-text-muted)"},title:"Reload app",onMouseEnter:e=>{e.currentTarget.style.background="var(--color-surface-hover)"},onMouseLeave:e=>{e.currentTarget.style.background="transparent"},children:(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),(0,n.jsx)("path",{d:"M3 3v5h5"}),(0,n.jsx)("path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16"}),(0,n.jsx)("path",{d:"M16 16h5v5"})]})}),(0,n.jsx)("a",{href:f,target:"_blank",rel:"noopener noreferrer",className:"p-1.5 rounded-md transition-colors duration-100",style:{color:"var(--color-text-muted)"},title:"Open in new tab",onMouseEnter:e=>{e.currentTarget.style.background="var(--color-surface-hover)"},onMouseLeave:e=>{e.currentTarget.style.background="transparent"},children:(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M15 3h6v6"}),(0,n.jsx)("path",{d:"M10 14 21 3"}),(0,n.jsx)("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"})]})})]})]}),(0,n.jsxs)("div",{className:"flex-1 overflow-hidden relative",style:{background:"white"},children:[i&&(0,n.jsxs)("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-3 z-10",style:{background:"var(--color-bg)"},children:[k?(0,n.jsx)("img",{src:oR(t,r.icon),alt:"",width:48,height:48,className:"rounded-xl",style:{objectFit:"cover"}}):(0,n.jsx)("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center",style:{background:"var(--color-accent-light)"},children:(0,n.jsx)(oD,{size:24})}),(0,n.jsx)("div",{className:"w-5 h-5 border-2 rounded-full animate-spin",style:{borderColor:"var(--color-border)",borderTopColor:"var(--color-accent)"}}),(0,n.jsxs)("p",{className:"text-xs",style:{color:"var(--color-text-muted)"},children:["Loading ",r.name,"..."]})]}),d&&(0,n.jsxs)("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-3 z-10",style:{background:"var(--color-bg)"},children:[(0,n.jsx)("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center",style:{background:"color-mix(in srgb, var(--color-error) 10%, transparent)"},children:(0,n.jsxs)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"var(--color-error)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,n.jsx)("line",{x1:"15",x2:"9",y1:"9",y2:"15"}),(0,n.jsx)("line",{x1:"9",x2:"15",y1:"9",y2:"15"})]})}),(0,n.jsx)("p",{className:"text-sm font-medium",style:{color:"var(--color-text)"},children:d}),(0,n.jsx)("button",{type:"button",onClick:y,className:"text-xs px-3 py-1.5 rounded-md cursor-pointer",style:{color:"var(--color-accent)",background:"var(--color-accent-light)"},children:"Try again"})]}),(0,n.jsx)("iframe",{ref:s,src:f,className:"w-full h-full border-0",sandbox:"allow-same-origin allow-scripts allow-popups allow-forms",title:r.name,onLoad:b,onError:j,style:{minHeight:"calc(100vh - 120px)"}})]})]})}function oD(e){let{size:t=18}=e;return(0,n.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"#6366f1",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{width:"7",height:"7",x:"3",y:"3",rx:"1"}),(0,n.jsx)("rect",{width:"7",height:"7",x:"14",y:"3",rx:"1"}),(0,n.jsx)("rect",{width:"7",height:"7",x:"3",y:"14",rx:"1"}),(0,n.jsx)("rect",{width:"7",height:"7",x:"14",y:"14",rx:"1"})]})}oT.__denchAppMessageHandlers;var oA=r(47164);let oW={ts:"typescript",tsx:"typescript",js:"javascript",jsx:"javascript",mjs:"javascript",cjs:"javascript",py:"python",rb:"ruby",go:"go",rs:"rust",java:"java",kt:"kotlin",swift:"swift",c:"c",cpp:"cpp",h:"c",hpp:"cpp",cs:"csharp",css:"css",scss:"scss",less:"less",html:"html",htm:"html",xml:"xml",svg:"xml",json:"json",jsonc:"json",yaml:"yaml",yml:"yaml",toml:"plaintext",md:"markdown",mdx:"markdown",sh:"shell",bash:"shell",zsh:"shell",fish:"shell",ps1:"powershell",sql:"sql",graphql:"graphql",gql:"graphql",dockerfile:"dockerfile",docker:"dockerfile",makefile:"plaintext",cmake:"plaintext",r:"r",lua:"lua",php:"php",vue:"html",svelte:"html",diff:"plaintext",patch:"plaintext",ini:"ini",env:"ini",tf:"plaintext",proto:"protobuf",zig:"plaintext",elixir:"plaintext",ex:"plaintext",erl:"plaintext",hs:"plaintext",scala:"scala",clj:"clojure",dart:"dart"};function oB(e){var t;let r=e.toLowerCase();return"dockerfile"===r||r.startsWith("dockerfile.")?"dockerfile":"makefile"===r||"gnumakefile"===r?"makefile":"cmakelists.txt"===r?"cmake":null!=(t=r.split(".").pop())?t:""}function oF(e){var t;return null!=(t=oW[oB(e)])?t:"plaintext"}let oP=!1;function oz(){return"undefined"!=typeof document&&document.documentElement.classList.contains("dark")}function oO(e){let{content:t,filename:r,filePath:o,className:l,onDirty:a}=e,s=oB(r);return"diff"===s||"patch"===s?(0,n.jsx)("div",{className:"max-w-4xl mx-auto px-6 py-8",children:(0,n.jsx)(n8,{diff:t})}):(0,n.jsx)(oU,{content:t,filename:r,filePath:o,className:l,onDirty:a})}function oU(e){let{content:t,filename:r,filePath:l,className:a,onDirty:s}=e,i=(0,o.useRef)(null),c=(0,o.useRef)(null),[d,u]=(0,o.useState)(oz()?"denchclaw-dark":"denchclaw-light"),[p,h]=(0,o.useState)("clean"),[x,m]=(0,o.useState)({line:1,col:1}),f=(0,o.useRef)(null),v=(0,o.useRef)(t),g=oF(r),y=!!l;(0,o.useEffect)(()=>{v.current=t},[t]),(0,o.useEffect)(()=>{let e=document.documentElement,t=new MutationObserver(()=>u(oz()?"denchclaw-dark":"denchclaw-light"));return t.observe(e,{attributes:!0,attributeFilter:["class"]}),()=>t.disconnect()},[]);let b=(0,o.useCallback)(async()=>{if(!l||!i.current)return;let e=i.current.getValue();h("saving");try{if(!(await fetch((0,k.nC)(l),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:l,content:e})})).ok)throw Error("Save failed");v.current=e,h("saved"),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>h("clean"),2e3)}catch(e){h("error"),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>h("dirty"),3e3)}},[l]),j=(0,o.useCallback)((e,t)=>{i.current=e,c.current=t,oP||(oP=!0,t.editor.defineTheme("denchclaw-light",{base:"vs",inherit:!0,rules:[],colors:{"editor.background":"#ffffff","editor.foreground":"#1c1c1a","editor.lineHighlightBackground":"#f5f4f1","editor.selectionBackground":"#2563eb20","editor.inactiveSelectionBackground":"#2563eb10","editorLineNumber.foreground":"#8a8a82","editorLineNumber.activeForeground":"#44443e","editorIndentGuide.background":"#00000010","editorIndentGuide.activeBackground":"#00000020","editor.selectionHighlightBackground":"#2563eb12","editorCursor.foreground":"#2563eb","editorWhitespace.foreground":"#00000010","editorBracketMatch.background":"#2563eb15","editorBracketMatch.border":"#2563eb40","editorGutter.background":"#ffffff","editorWidget.background":"#ffffff","editorWidget.border":"#00000014","editorSuggestWidget.background":"#ffffff","editorSuggestWidget.border":"#00000014","editorSuggestWidget.selectedBackground":"#f5f4f1","editorHoverWidget.background":"#ffffff","editorHoverWidget.border":"#00000014","input.background":"#f5f5f4","input.border":"#00000014","input.foreground":"#1c1c1a","minimap.background":"#ffffff","scrollbarSlider.background":"#00000012","scrollbarSlider.hoverBackground":"#00000020","scrollbarSlider.activeBackground":"#0000002a"}}),t.editor.defineTheme("denchclaw-dark",{base:"vs-dark",inherit:!0,rules:[],colors:{"editor.background":"#0c0c0b","editor.foreground":"#ececea","editor.lineHighlightBackground":"#1e1e1c","editor.selectionBackground":"#3b82f630","editor.inactiveSelectionBackground":"#3b82f618","editorLineNumber.foreground":"#78776f","editorLineNumber.activeForeground":"#b8b8b0","editorIndentGuide.background":"#ffffff08","editorIndentGuide.activeBackground":"#ffffff14","editor.selectionHighlightBackground":"#3b82f618","editorCursor.foreground":"#3b82f6","editorWhitespace.foreground":"#ffffff08","editorBracketMatch.background":"#3b82f620","editorBracketMatch.border":"#3b82f650","editorGutter.background":"#0c0c0b","editorWidget.background":"#161615","editorWidget.border":"#ffffff14","editorSuggestWidget.background":"#161615","editorSuggestWidget.border":"#ffffff14","editorSuggestWidget.selectedBackground":"#1e1e1c","editorHoverWidget.background":"#161615","editorHoverWidget.border":"#ffffff14","input.background":"#1e1e1c","input.border":"#ffffff14","input.foreground":"#ececea","minimap.background":"#0c0c0b","scrollbarSlider.background":"#ffffff12","scrollbarSlider.hoverBackground":"#ffffff20","scrollbarSlider.activeBackground":"#ffffff2a"}})),t.editor.setTheme(oz()?"denchclaw-dark":"denchclaw-light"),e.addCommand(t.KeyMod.CtrlCmd|t.KeyCode.KeyS,()=>{b()}),e.onDidChangeCursorPosition(e=>{m({line:e.position.lineNumber,col:e.position.column})}),e.onDidChangeModelContent(()=>{e.getValue()!==v.current?(h("dirty"),null==s||s()):h("clean")}),e.focus()},[b,s]);(0,o.useEffect)(()=>{c.current&&c.current.editor.setTheme(d)},[d]);let w=function(e){let t=oF(e);return"plaintext"===t?oB(e)||"TEXT":t}(r),N=t.split("\n").length;return(0,n.jsxs)("div",{className:"flex flex-col h-full ".concat(null!=a?a:""),children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 px-4 py-2 flex-shrink-0",style:{background:"var(--color-surface)",borderBottom:"1px solid var(--color-border)"},children:[(0,n.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--color-text-muted)",flexShrink:0},children:[(0,n.jsx)("polyline",{points:"16 18 22 12 16 6"}),(0,n.jsx)("polyline",{points:"8 6 2 12 8 18"})]}),(0,n.jsx)("span",{className:"text-sm font-medium truncate",style:{color:"var(--color-text)"},children:r}),"dirty"===p&&(0,n.jsx)("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{background:"var(--color-text-muted)"},title:"Unsaved changes"}),(0,n.jsx)("div",{className:"flex-1"}),(0,n.jsx)("span",{className:"text-[11px] px-1.5 py-0.5 rounded font-medium",style:{background:"var(--color-surface-hover)",color:"var(--color-text-muted)"},children:w.toUpperCase()}),(0,n.jsxs)("span",{className:"text-[11px] tabular-nums",style:{color:"var(--color-text-muted)"},children:[N," lines"]}),(0,n.jsxs)("span",{className:"text-[11px] tabular-nums",style:{color:"var(--color-text-muted)"},children:["Ln ",x.line,", Col ",x.col]}),y&&(0,n.jsxs)(n.Fragment,{children:["saving"===p&&(0,n.jsx)("span",{className:"text-[11px]",style:{color:"var(--color-text-muted)"},children:"Saving..."}),"saved"===p&&(0,n.jsx)("span",{className:"text-[11px]",style:{color:"var(--color-success)"},children:"Saved"}),"error"===p&&(0,n.jsx)("span",{className:"text-[11px]",style:{color:"var(--color-error)"},children:"Save failed"}),(0,n.jsx)("button",{type:"button",onClick:()=>void b(),disabled:"dirty"!==p,className:"text-[11px] px-2 py-0.5 rounded transition-colors",style:{background:"dirty"===p?"var(--color-accent)":"var(--color-surface-hover)",color:"dirty"===p?"#fff":"var(--color-text-muted)",cursor:"dirty"===p?"pointer":"default",opacity:"dirty"===p?1:.5},children:"Save"})]})]}),(0,n.jsx)("div",{className:"flex-1 min-h-0",children:(0,n.jsx)(oA.Ay,{defaultValue:t,language:g,theme:d,onMount:j,loading:(0,n.jsx)("div",{className:"flex items-center justify-center h-full",style:{background:"var(--color-bg)"},children:(0,n.jsx)("span",{className:"text-sm",style:{color:"var(--color-text-muted)"},children:"Loading editor..."})}),options:{readOnly:!y,fontSize:13,lineHeight:20,fontFamily:"'SF Mono', 'Fira Code', 'Cascadia Code', 'JetBrains Mono', Menlo, Monaco, 'Courier New', monospace",fontLigatures:!0,minimap:{enabled:!0,scale:1,showSlider:"mouseover"},scrollBeyondLastLine:!0,smoothScrolling:!0,cursorBlinking:"smooth",cursorSmoothCaretAnimation:"on",renderLineHighlight:"all",renderWhitespace:"selection",bracketPairColorization:{enabled:!0},guides:{bracketPairs:!0,indentation:!0,highlightActiveIndentation:!0},stickyScroll:{enabled:!0},folding:!0,foldingHighlight:!0,showFoldingControls:"mouseover",links:!0,wordWrap:"off",padding:{top:8,bottom:8},scrollbar:{verticalScrollbarSize:10,horizontalScrollbarSize:10,verticalSliderSize:10,horizontalSliderSize:10},overviewRulerBorder:!1,hideCursorInOverviewRuler:!0,automaticLayout:!0,tabSize:2,insertSpaces:!1,detectIndentation:!0,formatOnPaste:!1,formatOnType:!1,suggestOnTriggerCharacters:!0,quickSuggestions:!0,contextmenu:!0,mouseWheelZoom:!0,find:{addExtraSpaceOnTop:!1,autoFindInSelection:"multiline",seedSearchStringFromSelection:"selection"}}})})]})}let oH=new Set(["jpg","jpeg","png","gif","webp","svg","bmp","avif","heic","heif","ico","tiff","tif"]),oV=new Set(["mp4","webm","mov","avi","mkv"]),oK=new Set(["mp3","wav","ogg","m4a","aac","flac"]),oJ=new Set(["pdf"]);function oq(e){var t,r;let n=null!=(r=null==(t=e.split(".").pop())?void 0:t.toLowerCase())?r:"";return oH.has(n)?"image":oV.has(n)?"video":oK.has(n)?"audio":oJ.has(n)?"pdf":null}function oG(){return(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,n.jsx)("polyline",{points:"7 10 12 15 17 10"}),(0,n.jsx)("line",{x1:"12",x2:"12",y1:"15",y2:"3"})]})}function o$(){return(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M15 3h6v6"}),(0,n.jsx)("path",{d:"M10 14 21 3"}),(0,n.jsx)("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"})]})}function oZ(){return(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,n.jsx)("line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65"}),(0,n.jsx)("line",{x1:"11",x2:"11",y1:"8",y2:"14"}),(0,n.jsx)("line",{x1:"8",x2:"14",y1:"11",y2:"11"})]})}function oY(){return(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,n.jsx)("line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65"}),(0,n.jsx)("line",{x1:"8",x2:"14",y1:"11",y2:"11"})]})}function oQ(e){switch(e){case"image":return"#60a5fa";case"video":return"#c084fc";case"audio":return"#f59e0b";case"pdf":return"#ef4444"}}function oX(e){let{url:t,filename:r,mediaType:o,filePath:l}=e;return(0,n.jsxs)("div",{className:"flex flex-col h-full",children:[(0,n.jsxs)("div",{className:"flex items-center gap-3 px-5 py-3 border-b flex-shrink-0",style:{borderColor:"var(--color-border)"},children:[(0,n.jsx)(o5,{mediaType:o}),(0,n.jsx)("span",{className:"text-sm font-medium truncate",style:{color:"var(--color-text)"},children:r}),(0,n.jsx)("span",{className:"text-[10px] px-2 py-0.5 rounded-full flex-shrink-0",style:{background:"".concat(oQ(o),"18"),color:oQ(o),border:"1px solid ".concat(oQ(o),"30")},children:function(e){switch(e){case"image":return"Image";case"video":return"Video";case"audio":return"Audio";case"pdf":return"PDF"}}(o)}),(0,n.jsxs)("div",{className:"flex items-center gap-1 ml-auto",children:[(0,n.jsx)("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"p-1.5 rounded-md transition-colors duration-100",style:{color:"var(--color-text-muted)"},title:"Open in new tab",onMouseEnter:e=>{e.currentTarget.style.background="var(--color-surface-hover)"},onMouseLeave:e=>{e.currentTarget.style.background="transparent"},children:(0,n.jsx)(o$,{})}),(0,n.jsx)("a",{href:t,download:r,className:"p-1.5 rounded-md transition-colors duration-100",style:{color:"var(--color-text-muted)"},title:"Download",onMouseEnter:e=>{e.currentTarget.style.background="var(--color-surface-hover)"},onMouseLeave:e=>{e.currentTarget.style.background="transparent"},children:(0,n.jsx)(oG,{})})]})]}),(0,n.jsxs)("div",{className:"flex-1 overflow-auto flex items-center justify-center p-6",style:{background:"var(--color-surface)"},children:["image"===o&&(0,n.jsx)(o0,{url:t,filename:r}),"video"===o&&(0,n.jsx)(o1,{url:t}),"audio"===o&&(0,n.jsx)(o2,{url:t,filename:r}),"pdf"===o&&(0,n.jsx)(o4,{url:t})]}),l&&(0,n.jsx)("div",{className:"px-5 py-2 border-t flex-shrink-0 flex items-center",style:{borderColor:"var(--color-border)"},children:(0,n.jsx)("span",{className:"text-[11px] truncate",style:{color:"var(--color-text-muted)",fontFamily:"'SF Mono', 'Fira Code', monospace"},children:l})})]})}function o0(e){let{url:t,filename:r}=e,[l,a]=(0,o.useState)(1),[s,i]=(0,o.useState)(!1),c=(0,o.useCallback)(()=>a(e=>Math.min(1.5*e,5)),[]),d=(0,o.useCallback)(()=>a(e=>Math.max(e/1.5,.25)),[]),u=(0,o.useCallback)(()=>a(1),[]);return s?(0,n.jsxs)("div",{className:"flex flex-col items-center gap-3 py-12",children:[(0,n.jsx)("span",{className:"text-4xl",style:{opacity:.3},children:"\uD83D\uDDBC"}),(0,n.jsx)("p",{className:"text-sm",style:{color:"var(--color-text-muted)"},children:"Failed to load image"})]}):(0,n.jsxs)("div",{className:"flex flex-col items-center gap-4 w-full",children:[(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)("button",{type:"button",onClick:d,className:"p-1.5 rounded-md transition-colors duration-100 cursor-pointer",style:{color:"var(--color-text-muted)"},title:"Zoom out",onMouseEnter:e=>{e.currentTarget.style.background="var(--color-surface-hover)"},onMouseLeave:e=>{e.currentTarget.style.background="transparent"},children:(0,n.jsx)(oY,{})}),(0,n.jsxs)("button",{type:"button",onClick:u,className:"px-2 py-1 rounded-md text-[11px] tabular-nums transition-colors duration-100 cursor-pointer",style:{color:"var(--color-text-muted)"},title:"Reset zoom",onMouseEnter:e=>{e.currentTarget.style.background="var(--color-surface-hover)"},onMouseLeave:e=>{e.currentTarget.style.background="transparent"},children:[Math.round(100*l),"%"]}),(0,n.jsx)("button",{type:"button",onClick:c,className:"p-1.5 rounded-md transition-colors duration-100 cursor-pointer",style:{color:"var(--color-text-muted)"},title:"Zoom in",onMouseEnter:e=>{e.currentTarget.style.background="var(--color-surface-hover)"},onMouseLeave:e=>{e.currentTarget.style.background="transparent"},children:(0,n.jsx)(oZ,{})})]}),(0,n.jsx)("div",{className:"overflow-auto max-w-full max-h-[calc(100vh-260px)] rounded-xl border",style:{borderColor:"var(--color-border)",backgroundImage:"linear-gradient(45deg, var(--color-surface-hover) 25%, transparent 25%), linear-gradient(-45deg, var(--color-surface-hover) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, var(--color-surface-hover) 75%), linear-gradient(-45deg, transparent 75%, var(--color-surface-hover) 75%)",backgroundSize:"20px 20px",backgroundPosition:"0 0, 0 10px, 10px -10px, -10px 0px"},children:(0,n.jsx)("img",{src:t,alt:r,onError:()=>i(!0),style:{transform:"scale(".concat(l,")"),transformOrigin:"center center",transition:"transform 200ms ease",maxWidth:l<=1?"100%":"none",display:"block"},draggable:!1})})]})}function o1(e){let{url:t}=e;return(0,n.jsx)("div",{className:"w-full max-w-4xl",children:(0,n.jsx)("video",{src:t,controls:!0,className:"w-full rounded-xl border",style:{borderColor:"var(--color-border)",maxHeight:"calc(100vh - 220px)",background:"#000"}})})}function o2(e){let{url:t,filename:r}=e;return(0,n.jsxs)("div",{className:"flex flex-col items-center gap-6 py-8",children:[(0,n.jsx)("div",{className:"w-32 h-32 rounded-2xl flex items-center justify-center",style:{background:"linear-gradient(135deg, #f59e0b20, #f59e0b10)",border:"1px solid #f59e0b30"},children:(0,n.jsxs)("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"#f59e0b",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M9 18V5l12-2v13"}),(0,n.jsx)("circle",{cx:"6",cy:"18",r:"3"}),(0,n.jsx)("circle",{cx:"18",cy:"16",r:"3"})]})}),(0,n.jsx)("p",{className:"text-sm font-medium",style:{color:"var(--color-text)"},children:r}),(0,n.jsx)("audio",{src:t,controls:!0,className:"w-full max-w-md"})]})}function o4(e){let{url:t}=e;return(0,n.jsx)("div",{className:"w-full h-full flex flex-col",children:(0,n.jsx)("iframe",{src:t,className:"w-full flex-1 rounded-xl border",style:{borderColor:"var(--color-border)",minHeight:"calc(100vh - 220px)",background:"white"},title:"PDF viewer"})})}function o5(e){let{mediaType:t}=e,r=oQ(t);switch(t){case"image":return(0,n.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:r,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),(0,n.jsx)("circle",{cx:"9",cy:"9",r:"2"}),(0,n.jsx)("path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"})]});case"video":return(0,n.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:r,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5"}),(0,n.jsx)("rect",{x:"2",y:"6",width:"14",height:"12",rx:"2"})]});case"audio":return(0,n.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:r,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M9 18V5l12-2v13"}),(0,n.jsx)("circle",{cx:"6",cy:"18",r:"3"}),(0,n.jsx)("circle",{cx:"18",cy:"16",r:"3"})]});case"pdf":return(0,n.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:r,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"}),(0,n.jsx)("path",{d:"M14 2v4a2 2 0 0 0 2 2h4"}),(0,n.jsx)("path",{d:"M10 9H8"}),(0,n.jsx)("path",{d:"M16 13H8"}),(0,n.jsx)("path",{d:"M16 17H8"})]})}}function o3(e){let{size:t=16}=e;return(0,n.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("ellipse",{cx:"12",cy:"5",rx:"9",ry:"3"}),(0,n.jsx)("path",{d:"M3 5V19A9 3 0 0 0 21 19V5"}),(0,n.jsx)("path",{d:"M3 12A9 3 0 0 0 21 12"})]})}function o6(){return(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M12 3v18"}),(0,n.jsx)("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),(0,n.jsx)("path",{d:"M3 9h18"}),(0,n.jsx)("path",{d:"M3 15h18"})]})}function o8(){return(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"}),(0,n.jsx)("circle",{cx:"12",cy:"12",r:"3"})]})}function o7(){return(0,n.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("circle",{cx:"12",cy:"12",r:"1"})})}function o9(){return(0,n.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("polygon",{points:"6 3 20 12 6 21 6 3"})})}function le(e){let{direction:t}=e;return(0,n.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:"left"===t?(0,n.jsx)("path",{d:"m15 18-6-6 6-6"}):(0,n.jsx)("path",{d:"m9 18 6-6-6-6"})})}function lt(e){let{active:t,direction:r}=e;return(0,n.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{opacity:t?1:.25},children:"asc"===r?(0,n.jsx)("path",{d:"m5 12 7-7 7 7"}):(0,n.jsx)("path",{d:"m19 12-7 7-7-7"})})}function lr(e){return null==e?"":"object"==typeof e?JSON.stringify(e):"string"==typeof e?e:"number"==typeof e||"boolean"==typeof e||"bigint"==typeof e?String(e):""}function ln(e){let t=e.toUpperCase();return t.includes("INT")||t.includes("BIGINT")||t.includes("SMALLINT")||t.includes("TINYINT")||t.includes("HUGEINT")?{label:"int",color:"#c084fc"}:t.includes("FLOAT")||t.includes("DOUBLE")||t.includes("DECIMAL")||t.includes("NUMERIC")||t.includes("REAL")?{label:"float",color:"#c084fc"}:t.includes("BOOL")?{label:"bool",color:"#f59e0b"}:t.includes("VARCHAR")||t.includes("TEXT")||t.includes("STRING")||t.includes("CHAR")||"UUID"===t||"BLOB"===t?{label:t.includes("UUID")?"uuid":"text",color:"#22c55e"}:t.includes("TIMESTAMP")||t.includes("DATETIME")?{label:"timestamp",color:"#60a5fa"}:t.includes("DATE")?{label:"date",color:"#60a5fa"}:t.includes("TIME")?{label:"time",color:"#60a5fa"}:t.includes("JSON")?{label:"json",color:"#fb923c"}:{label:e.toLowerCase(),color:"var(--color-text-muted)"}}function lo(){return(0,n.jsxs)("div",{className:"flex flex-col items-center justify-center h-full gap-5 p-8",children:[(0,n.jsx)("div",{className:"w-16 h-16 rounded-2xl flex items-center justify-center",style:{background:"var(--color-surface)",border:"1px solid var(--color-border)",boxShadow:"var(--shadow-sm)"},children:(0,n.jsx)(o3,{size:32})}),(0,n.jsxs)("div",{className:"text-center max-w-sm",children:[(0,n.jsx)("h3",{className:"text-sm font-medium mb-1",style:{color:"var(--color-text)"},children:"DuckDB is not installed"}),(0,n.jsx)("p",{className:"text-xs leading-relaxed",style:{color:"var(--color-text-muted)"},children:"The DuckDB CLI is required to view database files and workspace data. Click below to install it automatically."})]}),(0,n.jsxs)("button",{type:"button",onClick:()=>{let e=new URLSearchParams(window.location.search);e.set("send","install duckdb"),window.location.href="/?".concat(e.toString())},className:"flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium transition-colors cursor-pointer",style:{background:"var(--color-accent)",color:"white"},children:[(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,n.jsx)("polyline",{points:"7 10 12 15 17 10"}),(0,n.jsx)("line",{x1:"12",x2:"12",y1:"15",y2:"3"})]}),"Install DuckDB"]})]})}function ll(e){let{dbPath:t,filename:r}=e,[l,a]=(0,o.useState)([]),[s,i]=(0,o.useState)(!0),[c,d]=(0,o.useState)(null),[u,p]=(0,o.useState)(!0),[h,x]=(0,o.useState)(null),[m,f]=(0,o.useState)([]),[v,g]=(0,o.useState)(!1),[y,b]=(0,o.useState)(null),[j,k]=(0,o.useState)(0),[w,N]=(0,o.useState)(!1),[C,S]=(0,o.useState)(""),[M,L]=(0,o.useState)(null),[T,I]=(0,o.useState)(null),[R,_]=(0,o.useState)(!1),[E,D]=(0,o.useState)(!1);(0,o.useEffect)(()=>{let e=!1;return async function(){i(!0),d(null);try{let o=await fetch("/api/workspace/db/introspect?path=".concat(encodeURIComponent(t)));if(!o.ok){let e=await o.json().catch(()=>({}));throw Error(e.error||"HTTP ".concat(o.status))}let l=await o.json();if(!e)if(!1===l.duckdb_available)p(!1);else{var r,n;a(null!=(n=l.tables)?n:[]),(null==(r=l.tables)?void 0:r.length)>0&&x(l.tables[0].table_name)}}catch(t){e||d(t instanceof Error?t.message:"Failed to introspect database")}finally{e||i(!1)}}(),()=>{e=!0}},[t]);let A=(0,o.useCallback)(async(e,r)=>{g(!0);try{var n;let o=e.replace(/"/g,'""'),l='SELECT * FROM "'.concat(o,'" LIMIT ').concat(100," OFFSET ").concat(r),a=await fetch("/api/workspace/db/query",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t,sql:l})});if(!a.ok)return void f([]);let s=await a.json();f(null!=(n=s.rows)?n:[])}catch(e){f([])}finally{g(!1)}},[t]);(0,o.useEffect)(()=>{h&&(b(null),A(h,100*j))},[h,j,A]);let W=(0,o.useCallback)(async()=>{if(C.trim()){_(!0),I(null),L(null);try{let r=await fetch("/api/workspace/db/query",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t,sql:C})}),n=await r.json();if(r.ok){var e;L(null!=(e=n.rows)?e:[])}else I(n.error||"HTTP ".concat(r.status))}catch(e){I(e instanceof Error?e.message:"Query failed")}finally{_(!1)}}},[t,C]),B=(0,o.useMemo)(()=>{var e;return null!=(e=l.find(e=>e.table_name===h))?e:null},[l,h]),F=(0,o.useMemo)(()=>{let e=w&&M?M:m;return y?[...e].toSorted((e,t)=>{let r=lr(e[y.column]),n=lr(t[y.column]),o=r.localeCompare(n,void 0,{numeric:!0});return"asc"===y.direction?o:-o}):e},[w,M,m,y]),P=e=>{b(t=>(null==t?void 0:t.column)===e?"asc"===t.direction?{column:e,direction:"desc"}:null:{column:e,direction:"asc"})},z=(0,o.useMemo)(()=>{let e=w&&M?M:m;return 0===e.length?[]:Object.keys(e[0])},[w,M,m]),O=(0,o.useMemo)(()=>{var e;let t=null==(e=r.split(".").pop())?void 0:e.toLowerCase();return"duckdb"===t?"DuckDB":"sqlite"===t||"sqlite3"===t?"SQLite":"postgres"===t?"PostgreSQL":"Database"},[r]);return s?(0,n.jsxs)("div",{className:"flex items-center justify-center h-full gap-3",children:[(0,n.jsx)("div",{className:"w-5 h-5 border-2 rounded-full animate-spin",style:{borderRightColor:"var(--color-border)",borderBottomColor:"var(--color-border)",borderLeftColor:"var(--color-border)",borderTopColor:"var(--color-accent)"}}),(0,n.jsx)("span",{className:"text-sm",style:{color:"var(--color-text-muted)"},children:"Loading database..."})]}):c?(0,n.jsxs)("div",{className:"flex flex-col items-center justify-center h-full gap-4 p-8",children:[(0,n.jsx)(o3,{size:48}),(0,n.jsx)("p",{className:"text-sm",style:{color:"var(--color-text-muted)"},children:"Failed to open database"}),(0,n.jsx)("p",{className:"text-xs px-3 py-2 rounded-lg max-w-md text-center",style:{background:"var(--color-surface)",color:"#f87171"},children:c})]}):u?(0,n.jsxs)("div",{className:"flex flex-col md:flex-row h-full",children:[(0,n.jsxs)("div",{className:"hidden md:flex w-56 flex-shrink-0 border-r flex-col overflow-hidden",style:{borderColor:"var(--color-border)",background:"var(--color-surface)"},children:[(0,n.jsxs)("div",{className:"px-3 py-3 border-b flex items-center gap-2",style:{borderColor:"var(--color-border)"},children:[(0,n.jsx)("span",{style:{color:"var(--color-accent)"},children:(0,n.jsx)(o3,{size:18})}),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsx)("div",{className:"text-xs font-medium truncate",style:{color:"var(--color-text)"},children:r}),(0,n.jsxs)("div",{className:"text-[10px]",style:{color:"var(--color-text-muted)"},children:[O," \xb7 ",l.length," table",1!==l.length?"s":""]})]})]}),(0,n.jsx)("div",{className:"flex-1 overflow-y-auto py-1",children:0===l.length?(0,n.jsx)("div",{className:"px-3 py-6 text-center text-xs",style:{color:"var(--color-text-muted)"},children:"No tables found"}):l.map(e=>{var t;let r=e.table_name.startsWith("v_"),o=h===e.table_name;return(0,n.jsxs)("button",{type:"button",onClick:()=>{x(e.table_name),k(0),N(!1)},className:"w-full flex items-center gap-2 px-3 py-1.5 text-left text-xs transition-colors duration-75 cursor-pointer",style:{background:o?"var(--color-surface-hover)":"transparent",color:o?"var(--color-text)":"var(--color-text-muted)"},onMouseEnter:e=>{o||(e.currentTarget.style.background="var(--color-surface-hover)")},onMouseLeave:e=>{o||(e.currentTarget.style.background="transparent")},children:[(0,n.jsx)("span",{className:"flex-shrink-0",style:{color:r?"#60a5fa":"var(--color-accent)"},children:r?(0,n.jsx)(o8,{}):(0,n.jsx)(o6,{})}),(0,n.jsx)("span",{className:"truncate flex-1",children:e.table_name}),(0,n.jsx)("span",{className:"flex-shrink-0 text-[10px] tabular-nums",style:{color:"var(--color-text-muted)"},children:(t=e.estimated_row_count)>=1e6?"".concat((t/1e6).toFixed(1),"M"):t>=1e3?"".concat((t/1e3).toFixed(1),"K"):String(t)})]},e.table_name)})}),(0,n.jsx)("div",{className:"px-3 py-2 border-t",style:{borderColor:"var(--color-border)"},children:(0,n.jsxs)("button",{type:"button",onClick:()=>N(!w),className:"w-full flex items-center justify-center gap-1.5 py-1.5 rounded-md text-xs font-medium transition-colors duration-100 cursor-pointer",style:{background:w?"var(--color-accent-light)":"var(--color-surface-hover)",color:w?"var(--color-accent)":"var(--color-text-muted)",border:"1px solid ".concat(w?"var(--color-accent)":"var(--color-border)")},children:[(0,n.jsx)(o9,{}),"SQL Query"]})})]}),(0,n.jsxs)("div",{className:"flex md:hidden flex-shrink-0 items-center gap-1.5 px-2 py-1.5 border-b overflow-x-auto",style:{borderColor:"var(--color-border)",background:"var(--color-surface)"},children:[l.map(e=>{let t=e.table_name.startsWith("v_"),r=h===e.table_name&&!w;return(0,n.jsxs)("button",{type:"button",onClick:()=>{x(e.table_name),k(0),N(!1)},className:"px-2.5 py-1 text-[11px] rounded-full whitespace-nowrap shrink-0 font-medium flex items-center gap-1",style:{background:r?"var(--color-accent)":"var(--color-surface-hover)",color:r?"white":"var(--color-text-muted)",border:r?"none":"1px solid var(--color-border)"},children:[(0,n.jsx)("span",{className:"flex-shrink-0",style:{color:r?"white":t?"#60a5fa":"var(--color-accent)"},children:t?(0,n.jsx)(o8,{}):(0,n.jsx)(o6,{})}),e.table_name]},e.table_name)}),(0,n.jsxs)("button",{type:"button",onClick:()=>N(!w),className:"px-2.5 py-1 text-[11px] rounded-full whitespace-nowrap shrink-0 font-medium flex items-center gap-1",style:{background:w?"var(--color-accent)":"var(--color-surface-hover)",color:w?"white":"var(--color-text-muted)",border:w?"none":"1px solid var(--color-border)"},children:[(0,n.jsx)(o9,{})," SQL"]})]}),(0,n.jsx)("div",{className:"flex-1 flex flex-col min-w-0 overflow-hidden",children:w?(0,n.jsx)(ls,{sqlInput:C,setSqlInput:S,queryResult:M,queryError:T,queryRunning:R,runQuery:W,dataColumns:z,sortedData:F,sort:y,onSort:P}):B?(0,n.jsx)(la,{table:B,data:F,dataLoading:v,dataColumns:z,sort:y,onSort:P,page:j,pageSize:100,onPageChange:k,showSchema:E,onToggleSchema:()=>D(!E)}):(0,n.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,n.jsx)("p",{className:"text-sm",style:{color:"var(--color-text-muted)"},children:"Select a table to view its data"})})})]}):(0,n.jsx)(lo,{})}function la(e){let{table:t,data:r,dataLoading:o,dataColumns:l,sort:a,onSort:s,page:i,pageSize:c,onPageChange:d,showSchema:u,onToggleSchema:p}=e,h=t.estimated_row_count,x=Math.max(1,Math.ceil(h/c));return(0,n.jsxs)("div",{className:"flex flex-col h-full",children:[(0,n.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2.5 border-b flex-shrink-0",style:{borderColor:"var(--color-border)"},children:[(0,n.jsx)("span",{style:{color:"var(--color-accent)"},children:(0,n.jsx)(o6,{})}),(0,n.jsx)("span",{className:"text-sm font-medium",style:{color:"var(--color-text)"},children:t.table_name}),(0,n.jsxs)("div",{className:"flex items-center gap-2 ml-auto",children:[(0,n.jsxs)("span",{className:"text-[10px] px-2 py-0.5 rounded-full",style:{background:"var(--color-surface)",color:"var(--color-text-muted)",border:"1px solid var(--color-border)"},children:[t.estimated_row_count.toLocaleString()," rows"]}),(0,n.jsxs)("span",{className:"text-[10px] px-2 py-0.5 rounded-full",style:{background:"var(--color-surface)",color:"var(--color-text-muted)",border:"1px solid var(--color-border)"},children:[t.column_count," columns"]}),(0,n.jsx)("button",{type:"button",onClick:p,className:"text-[10px] px-2 py-0.5 rounded-full cursor-pointer transition-colors duration-100",style:{background:u?"rgba(96, 165, 250, 0.15)":"var(--color-surface)",color:u?"#60a5fa":"var(--color-text-muted)",border:"1px solid ".concat(u?"#60a5fa":"var(--color-border)")},children:"Schema"})]})]}),u&&(0,n.jsx)("div",{className:"px-4 py-3 border-b overflow-x-auto flex-shrink-0",style:{borderColor:"var(--color-border)",background:"var(--color-surface)"},children:(0,n.jsx)("div",{className:"flex flex-wrap gap-x-6 gap-y-1.5",children:t.columns.map(e=>{let t=ln(e.type);return(0,n.jsxs)("div",{className:"flex items-center gap-1.5 text-xs",children:[(0,n.jsx)("span",{style:{color:"var(--color-text-muted)"},children:(0,n.jsx)(o7,{})}),(0,n.jsx)("span",{className:"font-medium",style:{color:"var(--color-text)"},children:e.name}),(0,n.jsx)("span",{className:"px-1 py-px rounded text-[10px]",style:{background:"".concat(t.color,"18"),color:t.color},children:t.label}),e.is_nullable&&(0,n.jsx)("span",{className:"text-[10px]",style:{color:"var(--color-text-muted)",opacity:.5},children:"null"})]},e.name)})})}),(0,n.jsx)("div",{className:"flex-1 overflow-auto relative",children:o?(0,n.jsx)("div",{className:"flex items-center justify-center h-32",children:(0,n.jsx)("div",{className:"w-5 h-5 border-2 rounded-full animate-spin",style:{borderRightColor:"var(--color-border)",borderBottomColor:"var(--color-border)",borderLeftColor:"var(--color-border)",borderTopColor:"var(--color-accent)"}})}):0===r.length?(0,n.jsxs)("div",{className:"flex flex-col items-center justify-center py-20 gap-2",children:[(0,n.jsx)("span",{style:{color:"var(--color-text-muted)",opacity:.4},children:(0,n.jsx)(o6,{})}),(0,n.jsx)("p",{className:"text-xs",style:{color:"var(--color-text-muted)"},children:"No data"})]}):(0,n.jsx)(li,{columns:l,rows:r,sort:a,onSort:s,schemaColumns:t.columns})}),h>c&&(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-t flex-shrink-0",style:{borderColor:"var(--color-border)"},children:[(0,n.jsxs)("span",{className:"text-xs",style:{color:"var(--color-text-muted)"},children:["Page ",i+1," of ",x]}),(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)("button",{type:"button",disabled:0===i,onClick:()=>d(i-1),className:"p-1 rounded transition-colors duration-100 cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed",style:{color:"var(--color-text-muted)"},children:(0,n.jsx)(le,{direction:"left"})}),(0,n.jsx)("button",{type:"button",disabled:i>=x-1,onClick:()=>d(i+1),className:"p-1 rounded transition-colors duration-100 cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed",style:{color:"var(--color-text-muted)"},children:(0,n.jsx)(le,{direction:"right"})})]})]})]})}function ls(e){let{sqlInput:t,setSqlInput:r,queryResult:o,queryError:l,queryRunning:a,runQuery:s,dataColumns:i,sortedData:c,sort:d,onSort:u}=e;return(0,n.jsxs)("div",{className:"flex flex-col h-full",children:[(0,n.jsx)("div",{className:"px-4 py-3 border-b flex-shrink-0",style:{borderColor:"var(--color-border)"},children:(0,n.jsxs)("div",{className:"flex items-start gap-2",children:[(0,n.jsxs)("div",{className:"flex-1",children:[(0,n.jsx)("textarea",{value:t,onChange:e=>r(e.target.value),placeholder:"SELECT * FROM table_name LIMIT 100",className:"w-full text-xs rounded-lg px-3 py-2 resize-none outline-none",style:{background:"var(--color-surface)",color:"var(--color-text)",border:"1px solid var(--color-border)",fontFamily:"'SF Mono', 'Fira Code', 'JetBrains Mono', monospace",minHeight:"60px"},onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&"Enter"===e.key&&(e.preventDefault(),s())}}),(0,n.jsx)("div",{className:"text-[10px] mt-1",style:{color:"var(--color-text-muted)"},children:"Press Cmd+Enter to run"})]}),(0,n.jsxs)("button",{type:"button",onClick:s,disabled:a||!t.trim(),className:"flex items-center gap-1.5 px-3 py-2 rounded-lg text-xs font-medium transition-colors duration-100 cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"var(--color-accent)",color:"white"},children:[a?(0,n.jsx)("div",{className:"w-3.5 h-3.5 border-2 rounded-full animate-spin",style:{borderRightColor:"rgba(255,255,255,0.3)",borderBottomColor:"rgba(255,255,255,0.3)",borderLeftColor:"rgba(255,255,255,0.3)",borderTopColor:"white"}}):(0,n.jsx)(o9,{}),"Run"]})]})}),(0,n.jsxs)("div",{className:"flex-1 overflow-auto",children:[l&&(0,n.jsx)("div",{className:"px-4 py-3",children:(0,n.jsx)("div",{className:"px-3 py-2 rounded-lg text-xs",style:{background:"rgba(248, 113, 113, 0.1)",color:"#f87171",border:"1px solid rgba(248, 113, 113, 0.2)"},children:l})}),null!==o&&0===o.length&&!l&&(0,n.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,n.jsx)("p",{className:"text-xs",style:{color:"var(--color-text-muted)"},children:"Query returned no results"})}),null!==o&&o.length>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"px-4 py-1.5",children:(0,n.jsxs)("span",{className:"text-[10px]",style:{color:"var(--color-text-muted)"},children:[o.length," row",1!==o.length?"s":""]})}),(0,n.jsx)(li,{columns:i,rows:c,sort:d,onSort:u})]}),null===o&&!l&&(0,n.jsxs)("div",{className:"flex flex-col items-center justify-center py-20 gap-3",children:[(0,n.jsx)("span",{style:{color:"var(--color-text-muted)",opacity:.3},children:(0,n.jsx)(o9,{})}),(0,n.jsx)("p",{className:"text-xs",style:{color:"var(--color-text-muted)"},children:"Write a SQL query and press Run"})]})]})]})}function li(e){let{columns:t,rows:r,sort:o,onSort:l,schemaColumns:a}=e;return(0,n.jsxs)("table",{className:"w-full text-xs",style:{borderCollapse:"separate",borderSpacing:0},children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{className:"text-right px-2 py-2 font-normal whitespace-nowrap border-b sticky top-0 z-[1]",style:{color:"var(--color-text-muted)",borderColor:"var(--color-border)",background:"var(--color-surface)",width:"2.5rem",opacity:.5},children:"#"}),t.map(e=>{let t=null==a?void 0:a.find(t=>t.name===e),r=t?ln(t.type):null;return(0,n.jsx)("th",{className:"text-left px-3 py-2 font-medium whitespace-nowrap border-b cursor-pointer select-none sticky top-0 z-[1]",style:{color:"var(--color-text-muted)",borderColor:"var(--color-border)",background:"var(--color-surface)"},onClick:()=>l(e),children:(0,n.jsxs)("span",{className:"flex items-center gap-1",children:[e,r&&(0,n.jsx)("span",{className:"text-[9px] px-1 rounded",style:{color:r.color,opacity:.6},children:r.label}),(0,n.jsx)(lt,{active:(null==o?void 0:o.column)===e,direction:(null==o?void 0:o.column)===e?o.direction:"asc"})]})},e)})]})}),(0,n.jsx)("tbody",{children:r.map((e,r)=>(0,n.jsxs)("tr",{className:"transition-colors duration-75 group",style:{background:r%2==0?"transparent":"var(--color-surface)"},onMouseEnter:e=>{e.currentTarget.style.background="var(--color-surface-hover)"},onMouseLeave:e=>{e.currentTarget.style.background=r%2==0?"transparent":"var(--color-surface)"},children:[(0,n.jsx)("td",{className:"text-right px-2 py-1.5 border-b tabular-nums",style:{color:"var(--color-text-muted)",borderColor:"var(--color-border)",opacity:.4},children:r+1}),t.map(t=>(0,n.jsx)("td",{className:"px-3 py-1.5 border-b whitespace-nowrap",style:{borderColor:"var(--color-border)",color:"var(--color-text)"},children:(0,n.jsx)(lc,{value:e[t]})},t))]},r))})]})}function lc(e){let{value:t}=e;if(null==t)return(0,n.jsx)("span",{style:{color:"var(--color-text-muted)",opacity:.4,fontStyle:"italic"},children:"null"});if("boolean"==typeof t)return(0,n.jsx)("span",{style:{color:t?"#22c55e":"#f87171"},children:t?"true":"false"});if("number"==typeof t)return(0,n.jsx)("span",{className:"tabular-nums",children:t});let r=lr(t);return r.length>120?(0,n.jsxs)("span",{title:r,className:"cursor-help",children:[r.slice(0,120),(0,n.jsx)("span",{style:{color:"var(--color-text-muted)"},children:"..."})]}):(0,n.jsx)("span",{children:r})}var ld=r(69176),lu=r(87131),lp=r(22856),lh=r(3087),lx=r(86233),lm=r(79919),lf=r(34872),lv=r(8466),lg=r(83879),ly=r(14273),lb=r(54602),lj=r(95107),lk=r(95573),lw=r(75643),lN=r(97199),lC=r(52454),lS=r(47697),lM=r(45679),lL=r(47325),lT=r(68996),lI=r(77704);function lR(e){var t,r;let n=null!=(r=null==(t=e.split(".").pop())?void 0:t.toLowerCase())?r:"";return"docx"===n||"doc"===n}function l_(e){var t;return(null==(t=e.split(".").pop())?void 0:t.toLowerCase())==="txt"}function lE(e){return e.trim()?e.split("\n").map(e=>"<p>".concat(e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")||"<br>","</p>")).join(""):"<p></p>"}function lD(e){var t,l,a,s,i,c;let{mode:d,initialHtml:u,filePath:p,onSave:h,onDirty:x,compact:m}=e,[f,v]=(0,o.useState)(!1),[g,y]=(0,o.useState)("idle"),[b,j]=(0,o.useState)(!1),w=(0,o.useRef)(null),N=(0,o.useRef)(null),C=null!=(s=p.split("/").pop())?s:p,S="txt"===d,M=(0,ld.hG)({extensions:[lp.A.configure({codeBlock:{HTMLAttributes:{class:"code-block"}}}),lk.A,lM.A,lL.A,lN.xJ,lC.A,lS.Ay.configure({multicolor:!0}),lw.A.configure({types:["heading","paragraph"]}),lh.Ay.configure({inline:!1,allowBase64:!0,HTMLAttributes:{class:"editor-image"}}),lx.Ay.configure({openOnClick:!1,autolink:!0,HTMLAttributes:{class:"editor-link",rel:"noopener"}}),lm.XI.configure({resizable:!1}),lf.A,lv.A,lg.h,ly.A,lb.A.configure({nested:!0}),lj.A.configure({placeholder:S?"Start typing...":"Start writing your document..."}),lT.A],content:u,immediatelyRender:!1,onUpdate:()=>{j(!0),y("idle"),null==x||x()}}),L=(0,o.useCallback)(async e=>{let t=new FormData;t.append("file",e);try{let e=await fetch("/api/workspace/upload",{method:"POST",body:t});if(!e.ok)return null;let r=await e.json();return"/api/workspace/assets/".concat(r.path.replace(/^assets\//,""))}catch(e){return null}},[]),T=(0,o.useCallback)(async e=>{if(M)for(let t of e){let e=await L(t);e&&M.chain().focus().setImage({src:e,alt:t.name}).run()}},[M,L]);(0,o.useEffect)(()=>{if(!M)return;let e=M.view.dom,t=e=>{var t,r;if(!(null==(r=e.dataTransfer)||null==(t=r.files)?void 0:t.length))return;let n=Array.from(e.dataTransfer.files).filter(e=>e.type.startsWith("image/"));0!==n.length&&(e.preventDefault(),e.stopPropagation(),T(n))},r=e=>{var t,r;(null==(r=e.dataTransfer)||null==(t=r.types)?void 0:t.includes("Files"))&&e.preventDefault()},n=e=>{if(!e.clipboardData)return;let t=Array.from(e.clipboardData.files).filter(e=>e.type.startsWith("image/"));t.length>0&&(e.preventDefault(),e.stopPropagation(),T(t))};return e.addEventListener("drop",t),e.addEventListener("dragover",r),e.addEventListener("paste",n),()=>{e.removeEventListener("drop",t),e.removeEventListener("dragover",r),e.removeEventListener("paste",n)}},[M,T]);let I=(0,o.useCallback)(async()=>{if(M&&!f){v(!0),y("idle");try{if(S){let e=M.getText();if(!(await fetch((0,k.nC)(p),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:p,content:e})})).ok)throw Error("Save failed")}else{let e=M.getHTML(),{default:t}=await Promise.all([r.e(515),r.e(1078),r.e(5360),r.e(9372),r.e(3999)]).then(r.bind(r,91e3)),n=await t(e,void 0,{table:{row:{cantSplit:!0}},footer:!0,pageNumber:!0}),o=new FormData;if(o.append("file",n),o.append("path",p),!(await fetch("/api/workspace/write-binary",{method:"POST",body:o})).ok)throw Error("Save failed")}y("saved"),j(!1),null==h||h(),w.current&&clearTimeout(w.current),w.current=setTimeout(()=>y("idle"),2e3)}catch(e){y("error")}finally{v(!1)}}},[M,p,f,S,h]);if((0,o.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&"s"===e.key&&(e.preventDefault(),I())};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[I]),!M)return(0,n.jsxs)("div",{className:"animate-pulse space-y-3 py-4 px-6",children:[(0,n.jsx)("div",{className:"h-4 rounded",style:{background:"var(--color-surface)",width:"80%"}}),(0,n.jsx)("div",{className:"h-4 rounded",style:{background:"var(--color-surface)",width:"60%"}}),(0,n.jsx)("div",{className:"h-4 rounded",style:{background:"var(--color-surface)",width:"70%"}})]});let R=null!=(i=null==(t=M.storage.characterCount)?void 0:t.words())?i:0,_=null!=(c=null==(l=M.storage.characterCount)?void 0:l.characters())?c:0;return(0,n.jsxs)("div",{className:"rich-doc-editor ".concat(m?"rich-doc-editor--compact":""),children:[(0,n.jsxs)("div",{className:"rich-doc-topbar",children:[(0,n.jsxs)("div",{className:"rich-doc-topbar-left",children:[(0,n.jsx)(l5,{mode:d}),(0,n.jsx)("span",{className:"rich-doc-filename",children:C}),b&&(0,n.jsx)("span",{className:"editor-save-indicator editor-save-unsaved",children:"Unsaved changes"}),"saved"===g&&!b&&(0,n.jsx)("span",{className:"editor-save-indicator editor-save-saved",children:"Saved"}),"error"===g&&(0,n.jsx)("span",{className:"editor-save-indicator editor-save-error",children:"Save failed"})]}),(0,n.jsxs)("div",{className:"rich-doc-topbar-right",children:[(0,n.jsxs)("span",{className:"editor-save-hint",children:["undefined"!=typeof navigator&&(null==(a=navigator.platform)?void 0:a.includes("Mac"))?"⌘":"Ctrl","+S"]}),(0,n.jsx)("button",{type:"button",onClick:()=>void I(),disabled:f||!b,className:"editor-save-button",children:f?"Saving...":"Save"})]})]}),!S&&(0,n.jsx)(lA,{editor:M,onUploadImages:T,imageInputRef:N}),S&&!m&&(0,n.jsxs)("div",{className:"editor-toolbar rich-doc-toolbar-minimal",children:[(0,n.jsxs)(lI.$Q,{children:[(0,n.jsx)(lI.IB,{active:!1,onClick:()=>M.chain().focus().undo().run(),title:"Undo",disabled:!M.can().undo(),children:(0,n.jsx)(lz,{})}),(0,n.jsx)(lI.IB,{active:!1,onClick:()=>M.chain().focus().redo().run(),title:"Redo",disabled:!M.can().redo(),children:(0,n.jsx)(lO,{})})]}),(0,n.jsx)("div",{className:"flex-1"}),(0,n.jsx)("span",{className:"rich-doc-txt-hint",children:"Plain text — formatting not preserved on save"})]}),!S&&(0,n.jsx)(lu.m,{editor:M,children:(0,n.jsxs)("div",{className:"bubble-menu",children:[(0,n.jsx)(lI.zM,{active:M.isActive("bold"),onClick:()=>M.chain().focus().toggleBold().run(),title:"Bold",children:(0,n.jsx)("strong",{children:"B"})}),(0,n.jsx)(lI.zM,{active:M.isActive("italic"),onClick:()=>M.chain().focus().toggleItalic().run(),title:"Italic",children:(0,n.jsx)("em",{children:"I"})}),(0,n.jsx)(lI.zM,{active:M.isActive("underline"),onClick:()=>M.chain().focus().toggleUnderline().run(),title:"Underline",children:(0,n.jsx)("span",{style:{textDecoration:"underline"},children:"U"})}),(0,n.jsx)(lI.zM,{active:M.isActive("strike"),onClick:()=>M.chain().focus().toggleStrike().run(),title:"Strikethrough",children:(0,n.jsx)("s",{children:"S"})}),(0,n.jsx)(lI.zM,{active:M.isActive("code"),onClick:()=>M.chain().focus().toggleCode().run(),title:"Inline code",children:"<>"}),(0,n.jsx)(lI.zM,{active:M.isActive("link"),onClick:()=>{if(M.isActive("link"))M.chain().focus().unsetLink().run();else{let e=window.prompt("URL:");e&&M.chain().focus().setLink({href:e}).run()}},title:"Link",children:(0,n.jsx)(lQ,{size:14})})]})}),(0,n.jsx)("div",{className:"rich-doc-scroll",children:(0,n.jsx)("div",{className:"rich-doc-page ".concat(S?"rich-doc-page--txt":""),children:(0,n.jsx)(ld.$Z,{editor:M})})}),!m&&(0,n.jsxs)("div",{className:"rich-doc-statusbar",children:[(0,n.jsxs)("span",{children:[R.toLocaleString()," word",1!==R?"s":""]}),(0,n.jsx)("span",{className:"rich-doc-statusbar-sep"}),(0,n.jsxs)("span",{children:[_.toLocaleString()," character",1!==_?"s":""]}),(0,n.jsx)("div",{className:"flex-1"}),(0,n.jsx)("span",{className:"rich-doc-statusbar-mode",children:"docx"===d?"DOCX":"TXT"})]}),(0,n.jsx)("input",{ref:N,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:e=>{var t;let r=Array.from(null!=(t=e.target.files)?t:[]);r.length>0&&T(r),e.target.value=""}})]})}function lA(e){var t;let{editor:r,onUploadImages:l,imageInputRef:a}=e,[s,i]=(0,o.useState)(!1),[c,d]=(0,o.useState)(!1),u=(0,o.useRef)(null),p=(0,o.useRef)(null);return(0,o.useEffect)(()=>{let e=e=>{u.current&&!u.current.contains(e.target)&&i(!1),p.current&&!p.current.contains(e.target)&&d(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),(0,n.jsxs)("div",{className:"editor-toolbar rich-doc-toolbar",children:[(0,n.jsxs)(lI.$Q,{children:[(0,n.jsx)(lI.IB,{active:!1,onClick:()=>r.chain().focus().undo().run(),title:"Undo",disabled:!r.can().undo(),children:(0,n.jsx)(lz,{})}),(0,n.jsx)(lI.IB,{active:!1,onClick:()=>r.chain().focus().redo().run(),title:"Redo",disabled:!r.can().redo(),children:(0,n.jsx)(lO,{})})]}),(0,n.jsx)(lI.x_,{}),(0,n.jsx)(lI.$Q,{children:(0,n.jsx)(lB,{editor:r})}),(0,n.jsx)(lI.x_,{}),(0,n.jsxs)(lI.$Q,{children:[(0,n.jsx)(lI.IB,{active:r.isActive("bold"),onClick:()=>r.chain().focus().toggleBold().run(),title:"Bold (Cmd+B)",children:(0,n.jsx)("strong",{children:"B"})}),(0,n.jsx)(lI.IB,{active:r.isActive("italic"),onClick:()=>r.chain().focus().toggleItalic().run(),title:"Italic (Cmd+I)",children:(0,n.jsx)("em",{children:"I"})}),(0,n.jsx)(lI.IB,{active:r.isActive("underline"),onClick:()=>r.chain().focus().toggleUnderline().run(),title:"Underline (Cmd+U)",children:(0,n.jsx)("span",{style:{textDecoration:"underline"},children:"U"})}),(0,n.jsx)(lI.IB,{active:r.isActive("strike"),onClick:()=>r.chain().focus().toggleStrike().run(),title:"Strikethrough",children:(0,n.jsx)("s",{children:"S"})}),(0,n.jsx)(lI.IB,{active:r.isActive("superscript"),onClick:()=>r.chain().focus().toggleSuperscript().run(),title:"Superscript",children:(0,n.jsxs)("span",{children:["X",(0,n.jsx)("sup",{style:{fontSize:"0.6em"},children:"2"})]})}),(0,n.jsx)(lI.IB,{active:r.isActive("subscript"),onClick:()=>r.chain().focus().toggleSubscript().run(),title:"Subscript",children:(0,n.jsxs)("span",{children:["X",(0,n.jsx)("sub",{style:{fontSize:"0.6em"},children:"2"})]})})]}),(0,n.jsx)(lI.x_,{}),(0,n.jsxs)(lI.$Q,{children:[(0,n.jsxs)("div",{className:"relative",ref:u,children:[(0,n.jsx)(lI.IB,{active:s,onClick:()=>{i(!s),d(!1)},title:"Text color",children:(0,n.jsx)(l2,{color:null!=(t=r.getAttributes("textStyle").color)?t:"currentColor"})}),s&&(0,n.jsx)(lP,{onSelect:e=>{e?r.chain().focus().setColor(e).run():r.chain().focus().unsetColor().run(),i(!1)}})]}),(0,n.jsxs)("div",{className:"relative",ref:p,children:[(0,n.jsx)(lI.IB,{active:c,onClick:()=>{d(!c),i(!1)},title:"Highlight color",children:(0,n.jsx)(l4,{})}),c&&(0,n.jsx)(lP,{onSelect:e=>{e?r.chain().focus().toggleHighlight({color:e}).run():r.chain().focus().unsetHighlight().run(),d(!1)}})]})]}),(0,n.jsx)(lI.x_,{}),(0,n.jsxs)(lI.$Q,{children:[(0,n.jsx)(lI.IB,{active:r.isActive({textAlign:"left"}),onClick:()=>r.chain().focus().setTextAlign("left").run(),title:"Align left",children:(0,n.jsx)(lU,{})}),(0,n.jsx)(lI.IB,{active:r.isActive({textAlign:"center"}),onClick:()=>r.chain().focus().setTextAlign("center").run(),title:"Align center",children:(0,n.jsx)(lH,{})}),(0,n.jsx)(lI.IB,{active:r.isActive({textAlign:"right"}),onClick:()=>r.chain().focus().setTextAlign("right").run(),title:"Align right",children:(0,n.jsx)(lV,{})}),(0,n.jsx)(lI.IB,{active:r.isActive({textAlign:"justify"}),onClick:()=>r.chain().focus().setTextAlign("justify").run(),title:"Justify",children:(0,n.jsx)(lK,{})})]}),(0,n.jsx)(lI.x_,{}),(0,n.jsxs)(lI.$Q,{children:[(0,n.jsx)(lI.IB,{active:r.isActive("bulletList"),onClick:()=>r.chain().focus().toggleBulletList().run(),title:"Bullet list",children:(0,n.jsx)(lJ,{})}),(0,n.jsx)(lI.IB,{active:r.isActive("orderedList"),onClick:()=>r.chain().focus().toggleOrderedList().run(),title:"Ordered list",children:(0,n.jsx)(lq,{})}),(0,n.jsx)(lI.IB,{active:r.isActive("taskList"),onClick:()=>r.chain().focus().toggleTaskList().run(),title:"Task list",children:(0,n.jsx)(lG,{})})]}),(0,n.jsx)(lI.x_,{}),(0,n.jsxs)(lI.$Q,{children:[(0,n.jsx)(lI.IB,{active:r.isActive("blockquote"),onClick:()=>r.chain().focus().toggleBlockquote().run(),title:"Blockquote",children:(0,n.jsx)(l$,{})}),(0,n.jsx)(lI.IB,{active:r.isActive("codeBlock"),onClick:()=>r.chain().focus().toggleCodeBlock().run(),title:"Code block",children:(0,n.jsx)(lZ,{})}),(0,n.jsx)(lI.IB,{active:!1,onClick:()=>r.chain().focus().setHorizontalRule().run(),title:"Horizontal rule",children:(0,n.jsx)(lY,{})})]}),(0,n.jsx)(lI.x_,{}),(0,n.jsxs)(lI.$Q,{children:[(0,n.jsx)(lI.IB,{active:r.isActive("link"),onClick:()=>{if(r.isActive("link"))r.chain().focus().unsetLink().run();else{let e=window.prompt("Link URL:");e&&r.chain().focus().setLink({href:e}).run()}},title:"Insert link",children:(0,n.jsx)(lQ,{})}),(0,n.jsx)(lI.IB,{active:!1,onClick:()=>{if(l){var e;null==(e=a.current)||e.click()}else{let e=window.prompt("Image URL:");e&&r.chain().focus().setImage({src:e}).run()}},title:"Insert image",children:(0,n.jsx)(lX,{})}),(0,n.jsx)(lI.IB,{active:!1,onClick:()=>r.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),title:"Insert table",children:(0,n.jsx)(l0,{})})]})]})}let lW=[{label:"Normal text",level:0},{label:"Heading 1",level:1},{label:"Heading 2",level:2},{label:"Heading 3",level:3},{label:"Heading 4",level:4},{label:"Heading 5",level:5},{label:"Heading 6",level:6}];function lB(e){var t;let{editor:r}=e,[l,a]=(0,o.useState)(!1),s=(0,o.useRef)(null);(0,o.useEffect)(()=>{let e=e=>{s.current&&!s.current.contains(e.target)&&a(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);let i=null!=(t=lW.find(e=>e.level>0&&r.isActive("heading",{level:e.level})))?t:lW[0];return(0,n.jsxs)("div",{className:"relative",ref:s,children:[(0,n.jsxs)("button",{type:"button",className:"rich-doc-style-dropdown",onClick:()=>a(!l),title:"Paragraph style",children:[(0,n.jsx)("span",{children:i.label}),(0,n.jsx)(l1,{})]}),l&&(0,n.jsx)("div",{className:"rich-doc-style-menu",children:lW.map(e=>(0,n.jsx)("button",{type:"button",className:"rich-doc-style-option ".concat(e.level===i.level?"rich-doc-style-option--active":""),onClick:()=>{0===e.level?r.chain().focus().setParagraph().run():r.chain().focus().toggleHeading({level:e.level}).run(),a(!1)},children:(0,n.jsx)("span",{style:{fontSize:0===e.level?void 0:"".concat(Math.max(.75,1.4-.1*e.level),"rem"),fontWeight:e.level>0?600:400},children:e.label})},e.level))})]})}let lF=[null,"#000000","#434343","#666666","#999999","#b7b7b7","#cccccc","#d9d9d9","#efefef","#ffffff","#980000","#ff0000","#ff9900","#ffff00","#00ff00","#00ffff","#4a86e8","#0000ff","#9900ff","#ff00ff","#e6b8af","#f4cccc","#fce5cd","#fff2cc","#d9ead3","#d0e0e3","#c9daf8","#cfe2f3","#d9d2e9","#ead1dc","#dd7e6b","#ea9999","#f9cb9c","#ffe599","#b6d7a8","#a2c4c9","#a4c2f4","#9fc5e8","#b4a7d6","#d5a6bd","#cc4125","#e06666","#f6b26b","#ffd966","#93c47d","#76a5af","#6d9eeb","#6fa8dc","#8e7cc3","#c27ba0"];function lP(e){let{onSelect:t}=e;return(0,n.jsx)("div",{className:"rich-doc-color-palette",children:lF.map(e=>(0,n.jsx)("button",{type:"button",className:"rich-doc-color-swatch",style:{background:null!=e?e:"transparent",border:e?"1px solid var(--color-border)":"2px dashed var(--color-border)"},onClick:()=>t(e),title:null!=e?e:"Remove color",children:!e&&(0,n.jsx)("span",{style:{fontSize:"10px",color:"var(--color-text-muted)"},children:"\xd7"})},null!=e?e:"none"))})}function lz(){return(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M3 7v6h6"}),(0,n.jsx)("path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"})]})}function lO(){return(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M21 7v6h-6"}),(0,n.jsx)("path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3L21 13"})]})}function lU(){return(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("line",{x1:"17",x2:"3",y1:"10",y2:"10"}),(0,n.jsx)("line",{x1:"21",x2:"3",y1:"6",y2:"6"}),(0,n.jsx)("line",{x1:"21",x2:"3",y1:"14",y2:"14"}),(0,n.jsx)("line",{x1:"17",x2:"3",y1:"18",y2:"18"})]})}function lH(){return(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("line",{x1:"18",x2:"6",y1:"10",y2:"10"}),(0,n.jsx)("line",{x1:"21",x2:"3",y1:"6",y2:"6"}),(0,n.jsx)("line",{x1:"21",x2:"3",y1:"14",y2:"14"}),(0,n.jsx)("line",{x1:"18",x2:"6",y1:"18",y2:"18"})]})}function lV(){return(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("line",{x1:"21",x2:"7",y1:"10",y2:"10"}),(0,n.jsx)("line",{x1:"21",x2:"3",y1:"6",y2:"6"}),(0,n.jsx)("line",{x1:"21",x2:"3",y1:"14",y2:"14"}),(0,n.jsx)("line",{x1:"21",x2:"7",y1:"18",y2:"18"})]})}function lK(){return(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("line",{x1:"21",x2:"3",y1:"10",y2:"10"}),(0,n.jsx)("line",{x1:"21",x2:"3",y1:"6",y2:"6"}),(0,n.jsx)("line",{x1:"21",x2:"3",y1:"14",y2:"14"}),(0,n.jsx)("line",{x1:"21",x2:"3",y1:"18",y2:"18"})]})}function lJ(){return(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("line",{x1:"8",x2:"21",y1:"6",y2:"6"}),(0,n.jsx)("line",{x1:"8",x2:"21",y1:"12",y2:"12"}),(0,n.jsx)("line",{x1:"8",x2:"21",y1:"18",y2:"18"}),(0,n.jsx)("line",{x1:"3",x2:"3.01",y1:"6",y2:"6"}),(0,n.jsx)("line",{x1:"3",x2:"3.01",y1:"12",y2:"12"}),(0,n.jsx)("line",{x1:"3",x2:"3.01",y1:"18",y2:"18"})]})}function lq(){return(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("line",{x1:"10",x2:"21",y1:"6",y2:"6"}),(0,n.jsx)("line",{x1:"10",x2:"21",y1:"12",y2:"12"}),(0,n.jsx)("line",{x1:"10",x2:"21",y1:"18",y2:"18"}),(0,n.jsx)("path",{d:"M4 6h1v4"}),(0,n.jsx)("path",{d:"M4 10h2"}),(0,n.jsx)("path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1"})]})}function lG(){return(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{x:"3",y:"5",width:"6",height:"6",rx:"1"}),(0,n.jsx)("path",{d:"m3 17 2 2 4-4"}),(0,n.jsx)("line",{x1:"13",x2:"21",y1:"6",y2:"6"}),(0,n.jsx)("line",{x1:"13",x2:"21",y1:"18",y2:"18"})]})}function l$(){return(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M3 21c3 0 7-1 7-8V5c0-1.25-.756-2.017-2-2H4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2 1 0 1 0 1 1v1c0 1-1 2-2 2s-1 .008-1 1.031V21z"}),(0,n.jsx)("path",{d:"M15 21c3 0 7-1 7-8V5c0-1.25-.757-2.017-2-2h-4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2h.75c0 2.25.25 4-2.75 4v3z"})]})}function lZ(){return(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("polyline",{points:"16 18 22 12 16 6"}),(0,n.jsx)("polyline",{points:"8 6 2 12 8 18"})]})}function lY(){return(0,n.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("line",{x1:"2",x2:"22",y1:"12",y2:"12"})})}function lQ(e){let{size:t=14}=e;return(0,n.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),(0,n.jsx)("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})}function lX(){return(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),(0,n.jsx)("circle",{cx:"9",cy:"9",r:"2"}),(0,n.jsx)("path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"})]})}function l0(){return(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M12 3v18"}),(0,n.jsx)("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),(0,n.jsx)("path",{d:"M3 9h18"}),(0,n.jsx)("path",{d:"M3 15h18"})]})}function l1(){return(0,n.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"m6 9 6 6 6-6"})})}function l2(e){let{color:t}=e;return(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M4 20h16",stroke:t,strokeWidth:"3"}),(0,n.jsx)("path",{d:"m8.5 3 3.5 11 3.5-11"})]})}function l4(){return(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"m9 11-6 6v3h9l3-3"}),(0,n.jsx)("path",{d:"m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4"})]})}function l5(e){let{mode:t}=e;return"txt"===t?(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"var(--color-text-muted)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"}),(0,n.jsx)("path",{d:"M14 2v6h6"}),(0,n.jsx)("line",{x1:"8",x2:"16",y1:"13",y2:"13"}),(0,n.jsx)("line",{x1:"8",x2:"16",y1:"17",y2:"17"}),(0,n.jsx)("line",{x1:"8",x2:"10",y1:"9",y2:"9"})]}):(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"#2b579a",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"}),(0,n.jsx)("path",{d:"M14 2v6h6"}),(0,n.jsx)("line",{x1:"8",x2:"16",y1:"13",y2:"13"}),(0,n.jsx)("line",{x1:"8",x2:"16",y1:"17",y2:"17"}),(0,n.jsx)("line",{x1:"8",x2:"10",y1:"9",y2:"9"})]})}function l3(e){let{path:t,onNavigate:r}=e,o=t.startsWith("/"),l=t.split("/").filter(Boolean);return(0,n.jsxs)("nav",{className:"flex items-center gap-1 text-xs md:text-sm py-2 overflow-x-auto min-w-0",children:[(0,n.jsx)("button",{type:"button",onClick:()=>r(""),className:"px-1.5 py-0.5 rounded transition-colors cursor-pointer",style:{color:"var(--color-text-muted)"},onMouseEnter:e=>{e.currentTarget.style.color="var(--color-text)",e.currentTarget.style.background="var(--color-surface-hover)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--color-text-muted)",e.currentTarget.style.background="transparent"},children:"All Chats"}),l.map((e,t)=>{let a=(o?"/":"")+l.slice(0,t+1).join("/"),s=t===l.length-1;return(0,n.jsxs)("span",{className:"flex items-center gap-1",children:[(0,n.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--color-text-muted)",opacity:.4},children:(0,n.jsx)("path",{d:"m9 18 6-6-6-6"})}),s?(0,n.jsx)("span",{className:"px-1.5 py-0.5",style:{color:"var(--color-text)"},children:e.replace(/\.md$/,"")}):(0,n.jsx)("button",{type:"button",onClick:()=>r(a),className:"px-1.5 py-0.5 rounded transition-colors cursor-pointer",style:{color:"var(--color-text-muted)"},onMouseEnter:e=>{e.currentTarget.style.color="var(--color-text)",e.currentTarget.style.background="var(--color-surface-hover)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--color-text-muted)",e.currentTarget.style.background="transparent"},children:e})]},a)})]})}function l6(e){let{workspaceExists:t,expectedPath:r}=e;return(0,n.jsxs)("div",{className:"flex flex-col items-center justify-center h-full gap-6 px-8",children:[(0,n.jsx)("div",{className:"w-20 h-20 rounded-2xl flex items-center justify-center",style:{background:"var(--color-surface)",border:"1px solid var(--color-border)",boxShadow:"var(--shadow-sm)"},children:(0,n.jsxs)("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--color-text-muted)",opacity:.5},children:[(0,n.jsx)("rect",{width:"7",height:"7",x:"3",y:"3",rx:"1"}),(0,n.jsx)("rect",{width:"7",height:"7",x:"14",y:"3",rx:"1"}),(0,n.jsx)("rect",{width:"7",height:"7",x:"14",y:"14",rx:"1"}),(0,n.jsx)("rect",{width:"7",height:"7",x:"3",y:"14",rx:"1"})]})}),(0,n.jsxs)("div",{className:"text-center max-w-md",children:[(0,n.jsx)("h2",{className:"font-instrument text-2xl tracking-tight mb-2",style:{color:"var(--color-text)"},children:t?"Workspace is empty":"No workspace found"}),(0,n.jsx)("p",{className:"text-sm leading-relaxed",style:{color:"var(--color-text-muted)"},children:t?(0,n.jsx)(n.Fragment,{children:"The workspace exists but has no knowledge tree yet. Ask the CRM agent to create objects and documents to populate it."}):(0,n.jsx)(n.Fragment,{children:"The workspace directory was not found. Run the denchclaw bootstrap flow or start a conversation and the agent will set it up automatically in the managed profile."})})]}),(0,n.jsxs)("div",{className:"flex items-center gap-2 px-4 py-3 rounded-xl text-sm",style:{background:"var(--color-surface)",border:"1px solid var(--color-border)",color:"var(--color-text-muted)",boxShadow:"var(--shadow-sm)"},children:[(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--color-accent)",flexShrink:0},children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,n.jsx)("path",{d:"M12 16v-4"}),(0,n.jsx)("path",{d:"M12 8h.01"})]}),(0,n.jsxs)("span",{children:["Expected location:"," ",(0,n.jsx)("code",{className:"px-1.5 py-0.5 rounded-md text-xs",style:{background:"var(--color-surface-hover)",border:"1px solid var(--color-border)"},children:r?r.replace(/^\/Users\/[^/]+/,"~").replace(/^\/home\/[^/]+/,"~").replace(/^[A-Za-z]:[/\\]Users[/\\][^/\\]+/,"~"):"~/.openclaw-dench/workspace-<name>"})]})]}),(0,n.jsxs)("a",{href:"/",className:"flex items-center gap-2 text-sm mt-2",style:{color:"var(--color-accent)"},children:[(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"m12 19-7-7 7-7"}),(0,n.jsx)("path",{d:"M19 12H5"})]}),"Back to Home"]})]})}var l8=r(40077);function l7(){return(0,n.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})})}function l9(){return(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M18 6 6 18"}),(0,n.jsx)("path",{d:"m6 6 12 12"})]})}function ae(e){var t,r;let{filter:o,value:l,onChange:a}=e,s=(null==l?void 0:l.type)==="dateRange"?l:{type:"dateRange"};return(0,n.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,n.jsx)("label",{className:"text-[11px] whitespace-nowrap",style:{color:"var(--color-text-muted)"},children:o.label}),(0,n.jsx)("input",{type:"date",value:null!=(t=s.from)?t:"",onChange:e=>a({...s,from:e.target.value||void 0}),className:"px-2 py-1 rounded-md text-[11px] outline-none",style:{background:"var(--color-bg)",border:"1px solid var(--color-border)",color:"var(--color-text)",colorScheme:"dark"}}),(0,n.jsx)("span",{className:"text-[10px]",style:{color:"var(--color-text-muted)"},children:"to"}),(0,n.jsx)("input",{type:"date",value:null!=(r=s.to)?r:"",onChange:e=>a({...s,to:e.target.value||void 0}),className:"px-2 py-1 rounded-md text-[11px] outline-none",style:{background:"var(--color-bg)",border:"1px solid var(--color-border)",color:"var(--color-text)",colorScheme:"dark"}})]})}function at(e){let{filter:t,value:r,onChange:o,options:l}=e,a=(null==r?void 0:r.type)==="select"?r.value:void 0;return(0,n.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,n.jsx)("label",{className:"text-[11px] whitespace-nowrap",style:{color:"var(--color-text-muted)"},children:t.label}),(0,n.jsxs)("select",{value:null!=a?a:"",onChange:e=>o({type:"select",value:e.target.value||void 0}),className:"px-2 py-1 rounded-md text-[11px] outline-none cursor-pointer",style:{background:"var(--color-bg)",border:"1px solid var(--color-border)",color:"var(--color-text)",minWidth:100},children:[(0,n.jsx)("option",{value:"",children:"All"}),l.map(e=>(0,n.jsx)("option",{value:e,children:e},e))]})]})}function ar(e){var t;let{filter:r,value:o,onChange:l,options:a}=e,s=(null==o?void 0:o.type)==="multiSelect"&&null!=(t=o.values)?t:[];return(0,n.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,n.jsx)("label",{className:"text-[11px] whitespace-nowrap",style:{color:"var(--color-text-muted)"},children:r.label}),(0,n.jsx)("div",{className:"flex flex-wrap gap-1",children:a.map(e=>{let t=s.includes(e);return(0,n.jsx)("button",{type:"button",onClick:()=>(e=>{let t=s.includes(e)?s.filter(t=>t!==e):[...s,e];l({type:"multiSelect",values:t.length>0?t:void 0})})(e),className:"px-2 py-0.5 rounded-full text-[10px] transition-colors cursor-pointer",style:{background:t?"var(--color-accent-light)":"var(--color-surface)",border:"1px solid ".concat(t?"var(--color-accent)":"var(--color-border)"),color:t?"var(--color-accent)":"var(--color-text-muted)"},children:e},e)})})]})}function an(e){var t,r;let{filter:o,value:l,onChange:a}=e,s=(null==l?void 0:l.type)==="number"?l:{type:"number"};return(0,n.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,n.jsx)("label",{className:"text-[11px] whitespace-nowrap",style:{color:"var(--color-text-muted)"},children:o.label}),(0,n.jsx)("input",{type:"number",placeholder:"Min",value:null!=(t=s.min)?t:"",onChange:e=>a({...s,min:e.target.value?Number(e.target.value):void 0}),className:"px-2 py-1 rounded-md text-[11px] outline-none w-20",style:{background:"var(--color-bg)",border:"1px solid var(--color-border)",color:"var(--color-text)"}}),(0,n.jsx)("span",{className:"text-[10px]",style:{color:"var(--color-text-muted)"},children:"to"}),(0,n.jsx)("input",{type:"number",placeholder:"Max",value:null!=(r=s.max)?r:"",onChange:e=>a({...s,max:e.target.value?Number(e.target.value):void 0}),className:"px-2 py-1 rounded-md text-[11px] outline-none w-20",style:{background:"var(--color-bg)",border:"1px solid var(--color-border)",color:"var(--color-text)"}})]})}function ao(e){let{filters:t,value:r,onChange:l}=e,[a,s]=(0,o.useState)({}),i=(0,o.useCallback)(async()=>{let e=t.filter(e=>("select"===e.type||"multiSelect"===e.type)&&e.sql);if(0===e.length)return;let r={};await Promise.all(e.map(async e=>{try{var t;let n=await fetch("/api/workspace/reports/execute",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sql:e.sql})});if(!n.ok)return;let o=(null!=(t=(await n.json()).rows)?t:[]).map(e=>{let t=Object.values(e)[0];return null==t?null:"object"==typeof t?JSON.stringify(t):"string"==typeof t?t:String(t)}).filter(e=>null!==e);r[e.id]=o}catch(e){}})),s(r)},[t]);(0,o.useEffect)(()=>{i()},[i]);let c=(0,o.useCallback)((e,t)=>{l({...r,[e]:t})},[r,l]),d=Object.values(r).some(e=>!!e&&("dateRange"===e.type?e.from||e.to:"select"===e.type?e.value:"multiSelect"===e.type?e.values&&e.values.length>0:"number"===e.type&&(void 0!==e.min||void 0!==e.max)));return 0===t.length?null:(0,n.jsxs)("div",{className:"flex items-center gap-4 px-4 py-2.5 border-b flex-wrap",style:{borderColor:"var(--color-border)"},children:[(0,n.jsxs)("span",{className:"flex items-center gap-1.5 text-xs font-medium",style:{color:"var(--color-text-muted)"},children:[(0,n.jsx)(l7,{}),"Filters"]}),t.map(e=>{var t,o;let l=r[e.id];switch(e.type){case"dateRange":return(0,n.jsx)(ae,{filter:e,value:l,onChange:t=>c(e.id,t)},e.id);case"select":return(0,n.jsx)(at,{filter:e,value:l,onChange:t=>c(e.id,t),options:null!=(t=a[e.id])?t:[]},e.id);case"multiSelect":return(0,n.jsx)(ar,{filter:e,value:l,onChange:t=>c(e.id,t),options:null!=(o=a[e.id])?o:[]},e.id);case"number":return(0,n.jsx)(an,{filter:e,value:l,onChange:t=>c(e.id,t)},e.id);default:return null}}),d&&(0,n.jsxs)("button",{type:"button",onClick:()=>l({}),className:"flex items-center gap-1 px-2 py-1 rounded-md text-[11px] transition-colors cursor-pointer",style:{color:"var(--color-accent)",background:"var(--color-accent-light)"},children:[(0,n.jsx)(l9,{}),"Clear"]})]})}function al(e){let{size:t=20}=e;return(0,n.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("line",{x1:"12",x2:"12",y1:"20",y2:"10"}),(0,n.jsx)("line",{x1:"18",x2:"18",y1:"20",y2:"4"}),(0,n.jsx)("line",{x1:"6",x2:"6",y1:"20",y2:"14"})]})}function aa(){return(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),(0,n.jsx)("path",{d:"M3 3v5h5"}),(0,n.jsx)("path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16"}),(0,n.jsx)("path",{d:"M16 16h5v5"})]})}function as(e){let{config:t,reportPath:r}=e,[l,a]=(0,o.useState)(null!=t?t:null),[s,i]=(0,o.useState)(!t&&!!r),[c,d]=(0,o.useState)(null),[u,p]=(0,o.useState)({}),[h,x]=(0,o.useState)({}),[m,f]=(0,o.useState)(0);(0,o.useEffect)(()=>{if(t)return void a(t);if(!r)return;let e=!1;return i(!0),d(null),fetch("/api/workspace/file?path=".concat(encodeURIComponent(r))).then(async t=>{if(!t.ok)throw Error("Failed to load report: HTTP ".concat(t.status));let r=await t.json();if(!e)try{let e=JSON.parse(r.content);a(e)}catch(e){throw Error("Invalid report JSON")}}).catch(t=>{e||d(t instanceof Error?t.message:"Failed to load report")}).finally(()=>{e||i(!1)}),()=>{e=!0}},[t,r]);let v=(0,o.useCallback)(async()=>{var e;if(!l)return;let t=function(e,t){let r=[];for(let n of t){let t=e[n.id];t&&("dateRange"===t.type&&(t.from||t.to)||"select"===t.type&&t.value||"multiSelect"===t.type&&t.values&&t.values.length>0||"number"===t.type&&(void 0!==t.min||void 0!==t.max))&&r.push({id:n.id,column:n.column,value:t})}return r}(h,null!=(e=l.filters)?e:[]),r={};for(let e of l.panels)r[e.id]={panelId:e.id,rows:[],loading:!0};p(r),await Promise.all(l.panels.map(async e=>{try{let r=await fetch("/api/workspace/reports/execute",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sql:e.sql,filters:t.length>0?t:void 0})});if(!r.ok){let t=await r.json().catch(()=>({}));p(n=>({...n,[e.id]:{panelId:e.id,rows:[],loading:!1,error:t.error||"HTTP ".concat(r.status)}}));return}let n=await r.json();p(t=>{var r;return{...t,[e.id]:{panelId:e.id,rows:null!=(r=n.rows)?r:[],loading:!1}}})}catch(t){p(r=>({...r,[e.id]:{panelId:e.id,rows:[],loading:!1,error:t instanceof Error?t.message:"Query failed"}}))}}))},[l,h]);(0,o.useEffect)(()=>{v()},[v,m]);let g=(0,o.useMemo)(()=>Object.values(u).reduce((e,t)=>e+t.rows.length,0),[u]);return s?(0,n.jsxs)("div",{className:"flex items-center justify-center h-full gap-3",children:[(0,n.jsx)("div",{className:"w-5 h-5 border-2 rounded-full animate-spin",style:{borderColor:"var(--color-border)",borderTopColor:"var(--color-accent)"}}),(0,n.jsx)("span",{className:"text-sm",style:{color:"var(--color-text-muted)"},children:"Loading report..."})]}):c?(0,n.jsxs)("div",{className:"flex flex-col items-center justify-center h-full gap-4 p-8",children:[(0,n.jsx)(al,{size:48}),(0,n.jsx)("p",{className:"text-sm",style:{color:"var(--color-text-muted)"},children:"Failed to load report"}),(0,n.jsx)("p",{className:"text-xs px-3 py-2 rounded-lg max-w-md text-center",style:{background:"var(--color-surface)",color:"#f87171"},children:c})]}):l?(0,n.jsxs)("div",{className:"flex flex-col h-full",children:[(0,n.jsx)("div",{className:"px-6 py-4 border-b flex-shrink-0",style:{borderColor:"var(--color-border)"},children:(0,n.jsxs)("div",{className:"flex items-start justify-between",children:[(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"flex items-center gap-2.5 mb-1",children:[(0,n.jsx)("span",{style:{color:"var(--color-accent)"},children:(0,n.jsx)(al,{})}),(0,n.jsx)("h1",{className:"text-xl font-bold",style:{color:"var(--color-text)"},children:l.title})]}),l.description&&(0,n.jsx)("p",{className:"text-sm ml-7",style:{color:"var(--color-text-muted)"},children:l.description})]}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsxs)("span",{className:"text-[10px] px-2 py-1 rounded-full",style:{background:"var(--color-surface)",color:"var(--color-text-muted)",border:"1px solid var(--color-border)"},children:[l.panels.length," panel",1!==l.panels.length?"s":""]}),(0,n.jsxs)("span",{className:"text-[10px] px-2 py-1 rounded-full",style:{background:"var(--color-surface)",color:"var(--color-text-muted)",border:"1px solid var(--color-border)"},children:[g," rows"]}),(0,n.jsx)("button",{type:"button",onClick:()=>f(e=>e+1),className:"p-1.5 rounded-md transition-colors cursor-pointer",style:{color:"var(--color-text-muted)"},title:"Refresh data",children:(0,n.jsx)(aa,{})})]})]})}),l.filters&&l.filters.length>0&&(0,n.jsx)(ao,{filters:l.filters,value:h,onChange:x}),(0,n.jsx)("div",{className:"flex-1 overflow-y-auto p-3 sm:p-6",children:(0,n.jsx)("div",{className:"grid grid-cols-2 sm:grid-cols-4 lg:grid-cols-6 gap-3 sm:gap-5",children:l.panels.map(e=>(0,n.jsx)(ai,{panel:e,data:u[e.id]},e.id))})})]}):(0,n.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,n.jsx)("p",{className:"text-sm",style:{color:"var(--color-text-muted)"},children:"No report configuration found"})})}function ai(e){var t;let{panel:r,data:o}=e,l=function(e){switch(e){case"full":return"col-span-2 sm:col-span-4 lg:col-span-6";case"third":return"col-span-1 sm:col-span-2 lg:col-span-2";default:return"col-span-2 sm:col-span-2 lg:col-span-3"}}(r.size);return(0,n.jsxs)("div",{className:"".concat(l," rounded-xl overflow-hidden"),style:{background:"var(--color-surface)",border:"1px solid var(--color-border)"},children:[(0,n.jsxs)("div",{className:"px-4 py-3 flex items-center justify-between",children:[(0,n.jsx)("h3",{className:"text-sm font-medium",style:{color:"var(--color-text)"},children:r.title}),o&&!o.loading&&!o.error&&(0,n.jsxs)("span",{className:"text-[10px] px-1.5 py-0.5 rounded",style:{color:"var(--color-text-muted)"},children:[o.rows.length," rows"]})]}),(0,n.jsx)("div",{className:"px-2 pb-3",children:(null==o?void 0:o.loading)?(0,n.jsx)("div",{className:"flex items-center justify-center",style:{height:320},children:(0,n.jsx)("div",{className:"w-5 h-5 border-2 rounded-full animate-spin",style:{borderColor:"var(--color-border)",borderTopColor:"var(--color-accent)"}})}):(null==o?void 0:o.error)?(0,n.jsxs)("div",{className:"flex flex-col items-center justify-center gap-2",style:{height:320},children:[(0,n.jsx)("p",{className:"text-xs",style:{color:"#f87171"},children:"Query error"}),(0,n.jsx)("p",{className:"text-[10px] px-2 py-1 rounded max-w-xs text-center",style:{background:"rgba(248, 113, 113, 0.1)",color:"#f87171"},children:o.error})]}):(0,n.jsx)(l8.N,{config:r,data:null!=(t=null==o?void 0:o.rows)?t:[]})})]})}var ac=r(77592),ad=r(70793),au=r(1061),ap=r(52973),ah=r(80148),ax=r(64518),am=r(81199),af=r(50045),av=r(47186),ag=r(39128),ay=r(18520),ab=r(80096),aj=r(54113),ak=r(72092);let aw=[{id:"hubspot-sync-contacts",label:"Sync HubSpot Contacts",subtitle:"Import & deduplicate CRM contacts",icon:au.mM8,iconType:"brand",brandColor:"#FF7A59",category:"crm-sales",prompt:"Connect to my HubSpot CRM and pull all contacts updated this week. Deduplicate them by email and list any with missing phone numbers or job titles so I can clean up the data."},{id:"salesforce-pipeline",label:"Salesforce Pipeline",subtitle:"Analyze deal stages & revenue",icon:au.wsd,iconType:"brand",brandColor:"#00A1E0",category:"crm-sales",prompt:"Connect to Salesforce and pull my current sales pipeline. Break down deals by stage, show total expected revenue per stage, and flag any deals that have been stuck in the same stage for more than 14 days."},{id:"apollo-enrich-lead",label:"Enrich Lead via Apollo",subtitle:"Find LinkedIn, company data & funding",icon:ap.A,iconType:"generic",category:"crm-sales",prompt:"I just added a new lead — use Apollo enrichment to find their LinkedIn profile, current company, job title, company size, funding stage, and any recent news. Update the contact record with everything you find."},{id:"hubspot-deal-update",label:"Update HubSpot Deals",subtitle:"Bulk update deal properties",icon:au.mM8,iconType:"brand",brandColor:"#FF7A59",category:"crm-sales",prompt:"Find all HubSpot deals in 'Negotiation' stage that haven't been touched in 7+ days. Move them to 'Needs Follow-up' and add a note saying 'Auto-flagged: no activity for 7 days'."},{id:"salesforce-lead-score",label:"Score Salesforce Leads",subtitle:"Rank leads by engagement signals",icon:au.wsd,iconType:"brand",brandColor:"#00A1E0",category:"crm-sales",prompt:"Pull all Salesforce leads from this month. Score them based on email opens, meeting attendance, and form submissions. Give me a ranked list of the top 20 hottest leads with their scores and recommended next actions."},{id:"apollo-company-research",label:"Research Company",subtitle:"Apollo + web research on a prospect",icon:ah.A,iconType:"generic",category:"crm-sales",prompt:"Research this prospect's company using Apollo enrichment and Exa web search. I need: company size, revenue, tech stack, recent news, key decision-makers, and any mutual connections. Compile everything into a one-page briefing."},{id:"intercom-tickets",label:"Intercom Ticket Summary",subtitle:"Summarize open support tickets",icon:au.ezH,iconType:"brand",brandColor:"#6AFDEF",category:"crm-sales",prompt:"Pull all open Intercom conversations from this week. Categorize them by issue type (bug, feature request, billing, onboarding) and summarize the top 5 most urgent ones with recommended responses."},{id:"zendesk-trends",label:"Zendesk Support Trends",subtitle:"Analyze ticket patterns",icon:au.x5_,iconType:"brand",brandColor:"#03363D",category:"crm-sales",prompt:"Analyze my Zendesk tickets from the past 30 days. What are the most common issues? Show a breakdown by category, average resolution time, and flag any recurring problems that might need a product fix."},{id:"crm-weekly-report",label:"CRM Weekly Report",subtitle:"Pipeline + activity summary",icon:ax.A,iconType:"generic",category:"crm-sales",prompt:"Generate a weekly CRM report: new leads added, deals moved forward, deals closed (won/lost), total pipeline value, and team activity metrics. Format it as a clean summary I can share with leadership."},{id:"gmail-follow-up",label:"Gmail Follow-ups",subtitle:"Draft replies to unanswered threads",icon:au.nP5,iconType:"brand",brandColor:"#EA4335",category:"email-comms",prompt:"Check my Gmail for threads where I was the last sender and haven't gotten a reply in 3+ days. Draft a friendly follow-up for each one, keeping the original context. Show me all drafts before sending."},{id:"slack-standup",label:"Slack Standup Summary",subtitle:"Digest #standup channel updates",icon:au.D6W,iconType:"brand",brandColor:"#4A154B",category:"email-comms",prompt:"Read today's messages in #standup on Slack. Summarize what each team member is working on, any blockers they mentioned, and highlight anything that needs my attention or a response."},{id:"discord-moderation",label:"Discord Community Digest",subtitle:"Summarize server activity",icon:au.Nxe,iconType:"brand",brandColor:"#5865F2",category:"email-comms",prompt:"Pull the last 24 hours of messages from my Discord server's #general and #support channels. Summarize the key discussions, flag any unanswered questions, and list new member introductions."},{id:"gmail-newsletter-cleanup",label:"Clean Up Gmail",subtitle:"Unsubscribe from noisy newsletters",icon:au.nP5,iconType:"brand",brandColor:"#EA4335",category:"email-comms",prompt:"Scan my Gmail inbox for newsletter and promotional emails I haven't opened in the last 30 days. List them with their sender and frequency, then help me draft unsubscribe actions for the ones I don't need."},{id:"slack-channel-summary",label:"Slack Channel Recap",subtitle:"Catch up on missed conversations",icon:au.D6W,iconType:"brand",brandColor:"#4A154B",category:"email-comms",prompt:"I've been away for 2 days. Summarize the important messages and decisions from my top Slack channels (#engineering, #sales, #general). Highlight anything that needs my input and any @mentions I missed."},{id:"phone-call-summary",label:"Call Summary",subtitle:"Recap client phone calls",icon:am.A,iconType:"generic",category:"email-comms",prompt:"I just finished a client call. Help me write a structured summary: key discussion points, decisions made, action items for each party, and next meeting date. Format it so I can paste it directly into the CRM notes."},{id:"twilio-sms-campaign",label:"SMS Campaign via Twilio",subtitle:"Draft & schedule text messages",icon:au.vzR,iconType:"brand",brandColor:"#F22F46",category:"email-comms",prompt:"I need to send a promotional SMS to my customer list via Twilio. Draft a short, compelling message (under 160 chars) about our new feature launch, with a link to the landing page. Set it up to send tomorrow at 10am."},{id:"github-pr-review",label:"Review GitHub PRs",subtitle:"Summarize open pull requests",icon:au.SrF,iconType:"brand",brandColor:"#181717",category:"dev-tools",prompt:"List all open pull requests on my GitHub repo. For each one, summarize the changes, check if CI passed, note how long it's been open, and flag any that have merge conflicts or are missing reviews."},{id:"linear-sprint-status",label:"Linear Sprint Status",subtitle:"Track current sprint progress",icon:au.iU0,iconType:"brand",brandColor:"#5E6AD2",category:"dev-tools",prompt:"Pull the current sprint from Linear. Show me: total issues, completed vs in-progress vs blocked, who's overloaded, and which issues are at risk of not being completed by sprint end. Suggest priorities."},{id:"jira-backlog-groom",label:"Groom Jira Backlog",subtitle:"Prioritize & clean up stale tickets",icon:au.$lo,iconType:"brand",brandColor:"#0052CC",category:"dev-tools",prompt:"Review my Jira backlog. Find tickets older than 90 days with no activity, duplicates, and vague tickets missing acceptance criteria. Suggest which to close, merge, or update with better descriptions."},{id:"github-issue-triage",label:"Triage GitHub Issues",subtitle:"Categorize & label new issues",icon:au.SrF,iconType:"brand",brandColor:"#181717",category:"dev-tools",prompt:"Go through unlabeled GitHub issues in my repo from this week. Read each one, categorize it (bug, feature, question, docs), suggest appropriate labels and priority, and draft a short acknowledgment comment for each."},{id:"linear-create-issues",label:"Create Linear Issues",subtitle:"Turn meeting notes into tasks",icon:au.iU0,iconType:"brand",brandColor:"#5E6AD2",category:"dev-tools",prompt:"I have meeting notes in my workspace with action items. Parse them and create Linear issues for each action item. Set appropriate priorities, assign to team members mentioned, and add them to the current sprint."},{id:"github-release-notes",label:"GitHub Release Notes",subtitle:"Auto-generate changelog from PRs",icon:au.SrF,iconType:"brand",brandColor:"#181717",category:"dev-tools",prompt:"Generate release notes for my GitHub repo based on all merged PRs since the last release tag. Categorize changes into Features, Bug Fixes, and Improvements. Format as a clean Markdown changelog ready to publish."},{id:"notion-meeting-notes",label:"Notion Meeting Notes",subtitle:"Create structured meeting page",icon:au.i4$,iconType:"brand",brandColor:"#000000",category:"productivity",prompt:"Create a new page in my Notion workspace for today's team meeting. Include sections for Attendees, Agenda, Discussion Notes, Action Items, and Decisions. Pre-fill the agenda from my calendar event details."},{id:"gcal-schedule-optimizer",label:"Optimize My Calendar",subtitle:"Find focus time & reduce conflicts",icon:au._eB,iconType:"brand",brandColor:"#4285F4",category:"productivity",prompt:"Analyze my Google Calendar for this week. Identify back-to-back meetings without breaks, suggest which meetings could be shorter or async, and find 2-hour blocks I can protect as focus time for deep work."},{id:"asana-project-plan",label:"Asana Project Plan",subtitle:"Break down a project into tasks",icon:au.lic,iconType:"brand",brandColor:"#F06A6A",category:"productivity",prompt:"I'm starting a new product launch. Create an Asana project with milestones for: market research, design, development, testing, marketing prep, and launch day. Add subtasks under each milestone with estimated durations."},{id:"airtable-tracker",label:"Airtable Content Tracker",subtitle:"Build a content pipeline base",icon:au.J2O,iconType:"brand",brandColor:"#18BFFF",category:"productivity",prompt:"Create an Airtable base for tracking our content marketing pipeline. I need columns for: Title, Type (blog/video/social), Status (idea/draft/review/published), Author, Due Date, Target Audience, and Performance Metrics."},{id:"notion-weekly-planning",label:"Notion Weekly Plan",subtitle:"Structure your week ahead",icon:au.i4$,iconType:"brand",brandColor:"#000000",category:"productivity",prompt:"Create a weekly planning page in Notion for next week. Pull my upcoming calendar events, pending tasks from my project boards, and any deadlines. Organize them by day with priority levels and estimated time needed."},{id:"google-sheets-dashboard",label:"Sheets KPI Dashboard",subtitle:"Build a metrics tracking sheet",icon:au.CZR,iconType:"brand",brandColor:"#34A853",category:"productivity",prompt:"Create a Google Sheets dashboard to track our key business metrics: MRR, churn rate, new signups, active users, NPS score, and support ticket volume. Include formulas for month-over-month changes and visual sparklines."},{id:"trello-kanban",label:"Trello Board Setup",subtitle:"Design a workflow board",icon:au.N3N,iconType:"brand",brandColor:"#0052CC",category:"productivity",prompt:"Set up a Trello board for our hiring pipeline. Create lists for: Applications Received, Phone Screen, Technical Interview, Culture Fit, Offer Sent, and Hired. Add card templates with checklists for each stage."},{id:"gcal-meeting-prep",label:"Calendar Meeting Prep",subtitle:"Brief me before each meeting",icon:au._eB,iconType:"brand",brandColor:"#4285F4",category:"productivity",prompt:"Check my Google Calendar for tomorrow's meetings. For each one, pull the attendee list, find relevant context (recent emails, CRM notes, past meeting notes), and create a quick briefing with talking points I should prepare."},{id:"figma-handoff",label:"Figma Design Handoff",subtitle:"Extract specs from designs",icon:au.lNO,iconType:"brand",brandColor:"#F24E1E",category:"productivity",prompt:"I have a new Figma design ready for development. Extract all the key specs: colors, typography, spacing, component hierarchy, and interaction notes. Format them as a developer handoff document with clear implementation guidance."},{id:"zoom-meeting-summary",label:"Zoom Call Summary",subtitle:"Summarize recorded calls",icon:au.gkj,iconType:"brand",brandColor:"#0B5CFF",category:"productivity",prompt:"I have a Zoom recording transcript from my latest client call. Summarize the key discussion points, extract action items with assigned owners, and highlight any concerns or risks the client raised that we need to address."},{id:"dropbox-organize",label:"Organize Dropbox",subtitle:"Clean up shared folders",icon:au.z3D,iconType:"brand",brandColor:"#0061FF",category:"productivity",prompt:"Scan my Dropbox workspace for duplicate files, outdated documents, and files with no clear folder. Suggest a cleaner folder structure and help me reorganize by project and document type."},{id:"gdrive-doc-summary",label:"Summarize Google Docs",subtitle:"Digest long documents",icon:au.unz,iconType:"brand",brandColor:"#4285F4",category:"productivity",prompt:"I have several long Google Docs from last quarter's planning sessions. Read through them and create a single executive summary covering: key decisions made, goals set, assigned responsibilities, and current status of each initiative."},{id:"exa-competitor-research",label:"Research Competitors",subtitle:"Deep web search via Exa",icon:af.A,iconType:"generic",category:"search-research",prompt:"Use Exa to research my top 5 competitors. For each, find: pricing page, recent blog posts, product updates in the last 3 months, customer reviews, and social media presence. Compile into a comparison matrix."},{id:"exa-industry-trends",label:"Industry Trend Report",subtitle:"Search for latest trends & insights",icon:av.A,iconType:"generic",category:"search-research",prompt:"Use Exa web search to find the latest trends in my industry from the past month. Look for analyst reports, notable funding rounds, product launches, and thought leadership articles. Create a trends briefing I can share with the team."},{id:"exa-prospect-intel",label:"Prospect Intelligence",subtitle:"Research a prospect before outreach",icon:af.A,iconType:"generic",category:"search-research",prompt:"I'm about to reach out to a prospect. Use Exa to research their company: recent news, tech blog posts, job openings (to infer priorities), and any public talks by their team. Help me craft a personalized outreach message based on what you find."},{id:"web-market-analysis",label:"Market Analysis",subtitle:"Research market size & opportunities",icon:ag.A,iconType:"generic",category:"search-research",prompt:"Research the market opportunity for our product category. Find total addressable market size, growth rate, key players and their market share, emerging trends, and any analyst predictions for the next 2-3 years."},{id:"exa-content-ideas",label:"Content Research",subtitle:"Find trending topics for content",icon:av.A,iconType:"generic",category:"search-research",prompt:"Search the web for the most popular and trending content in my industry from the last 2 weeks. Find top-performing blog posts, viral social threads, and trending discussions. Suggest 10 content ideas based on the gaps you see."},{id:"auto-lead-nurture",label:"Lead Nurture Workflow",subtitle:"Auto-follow-up new signups",icon:ay.A,iconType:"generic",category:"automation",prompt:"Design an automated lead nurture workflow: when a new user signs up, send a welcome email via Gmail, wait 3 days, check if they've logged in — if not, send a helpful onboarding tip. If still inactive after 7 days, alert the sales team on Slack."},{id:"auto-invoice-tracking",label:"Invoice Automation",subtitle:"Track & remind overdue payments",icon:au.kDV,iconType:"brand",brandColor:"#635BFF",category:"automation",prompt:"Set up a workflow that checks Stripe for invoices overdue by more than 5 days. For each one, draft a friendly reminder email, send it via Gmail, and post a summary in the #finance Slack channel. Run this check every morning at 9am."},{id:"auto-onboarding",label:"Client Onboarding Flow",subtitle:"Automate new client setup",icon:ab.A,iconType:"generic",category:"automation",prompt:"Build an automated client onboarding workflow: create a Notion project page, set up a Slack channel, add a HubSpot deal, schedule a kickoff meeting via Google Calendar, and send a welcome email with next steps. Trigger it when a deal is marked 'Closed Won'."},{id:"auto-daily-digest",label:"Daily Briefing Bot",subtitle:"Morning summary across all tools",icon:aj.A,iconType:"generic",category:"automation",prompt:"Create a daily briefing cron job that runs at 8:30am: pull today's calendar events, unread email count, open support tickets, any blocked tasks from Linear, and yesterday's revenue from Stripe. Compile into a clean summary and post to #daily-digest on Slack."},{id:"auto-github-slack",label:"GitHub → Slack Alerts",subtitle:"Notify team of PR & issue activity",icon:au.SrF,iconType:"brand",brandColor:"#181717",category:"automation",prompt:"Set up a workflow that watches my GitHub repo. When a new PR is opened, post a summary in #engineering on Slack with the author, description, and a review link. When CI fails, alert the PR author directly via DM."},{id:"auto-deal-alert",label:"Deal Stage Alerts",subtitle:"Notify sales on CRM changes",icon:au.mM8,iconType:"brand",brandColor:"#FF7A59",category:"automation",prompt:"Create an automation that watches HubSpot deal stage changes. When a deal moves to 'Demo Scheduled', send the AE a prep email with the prospect's enrichment data. When it moves to 'Closed Won', post a celebration message in #wins on Slack."},{id:"auto-shopify-support",label:"Shopify Order Alerts",subtitle:"Auto-handle order issues",icon:au.jHc,iconType:"brand",brandColor:"#96BF48",category:"automation",prompt:"Set up a workflow for my Shopify store: when an order is flagged as high-risk, automatically hold it, create a Zendesk ticket for review, and notify the team on Slack. When an order is refunded, update the customer record in HubSpot."},{id:"auto-content-pipeline",label:"Content Pipeline Bot",subtitle:"Auto-assign & remind writers",icon:au.i4$,iconType:"brand",brandColor:"#000000",category:"automation",prompt:"Build a workflow that checks my Notion content calendar every Monday. For any pieces due this week that are still in 'Idea' status, assign them to available writers, send them a Slack message with the brief, and set a reminder for Wednesday if the draft isn't started."},{id:"auto-expense-report",label:"Auto Expense Report",subtitle:"Compile weekly expenses",icon:ak.A,iconType:"generic",category:"automation",prompt:"Create a weekly automation that pulls transaction data from Stripe, categorizes expenses (software, marketing, operations), calculates totals, and generates a formatted expense report in Google Sheets. Email the report to the finance team every Friday at 5pm."},{id:"auto-meeting-followup",label:"Auto Meeting Follow-up",subtitle:"Send notes after every meeting",icon:au._eB,iconType:"brand",brandColor:"#4285F4",category:"automation",prompt:"After each meeting on my Google Calendar, automatically compile the notes (from Notion or the calendar description), extract action items, and send a follow-up email to all attendees via Gmail with the summary and their assigned tasks."}];function aN(e){let{suggestion:t,onClick:r}=e,o=t.icon,l="brand"===t.iconType;return(0,n.jsxs)("button",{type:"button",onClick:()=>r(t.prompt),className:"group flex items-center gap-1.5 px-3 md:px-3.5 py-1.5 md:py-2 text-[11px] md:text-xs font-medium whitespace-nowrap rounded-xl transition-all duration-200 border shrink-0",style:{background:"var(--color-surface)",borderColor:"var(--color-border)",color:"var(--color-text-secondary)"},children:[(0,n.jsx)("div",{className:"flex-shrink-0 transition-all duration-200 ".concat(l?"grayscale opacity-50 group-hover:grayscale-0 group-hover:opacity-100":"opacity-45 group-hover:opacity-100"),children:l?(0,n.jsx)(o,{className:"w-3.5 h-3.5",style:{color:t.brandColor}}):(0,n.jsx)(o,{className:"w-3.5 h-3.5"})}),t.label]})}function aC(e){let{compact:t,onPromptClick:r}=e,[l]=(0,o.useState)(0),a=(0,o.useMemo)(()=>(function(e){let t=[...e];for(let e=t.length-1;e>0;e--){let r=Math.floor(Math.random()*(e+1));[t[e],t[r]]=[t[r],t[e]]}return t})(aw).slice(0,6),[l]),s=a.slice(0,3),i=a.slice(3);return(0,n.jsxs)("div",{className:"mt-4 md:mt-6 flex flex-col gap-2 md:gap-2.5 w-full max-w-[720px] mx-auto ".concat(t?"px-2":"px-4"),children:[(0,n.jsx)("div",{className:"flex items-center justify-center gap-2 flex-wrap",children:s.map(e=>(0,n.jsx)(aN,{suggestion:e,onClick:r},e.id))}),(0,n.jsx)("div",{className:"flex items-center justify-center gap-2 flex-wrap",children:i.map(e=>(0,n.jsx)(aN,{suggestion:e,onClick:r},e.id))})]})}var aS=r(29341),aM=r(94003),aL=r(12594),aT=r(60743),aI=r(64049),aR=r(97185);let a_={displayName:"Dench Integrations",searchLabel:"Searching Dench Integrations",callLabel:"Calling Dench Integration",genericToolLabel:"Using Dench Integrations",attentionLabel:"Dench Integrations needs attention"};function aE(e,t){let r="Failed to ".concat(e," ").concat(a_.displayName," status");return"number"==typeof t?"".concat(r," (").concat(t,")"):"".concat(r,".")}let aD=new Set(["jpg","jpeg","png","gif","webp","svg","bmp","avif","heic","heif","tiff","tif","ico"]),aA=new Set(["mp4","webm","mov","avi","mkv"]),aW=new Set(["pdf"]),aB=new Set(["mp3","wav","ogg","m4a"]);function aF(e){var t;let r=(null!=(t=e.split(".").pop())?t:"").toLowerCase();return aD.has(r)?"image":aA.has(r)?"video":aW.has(r)?"pdf":aB.has(r)?"audio":null}function aP(e){return e.startsWith("http://")||e.startsWith("https://")?e:"/api/workspace/raw-file?path=".concat(encodeURIComponent(e))}let az=/(?:^|[\s"'(=])(((?:\/|\.\/)?[\w.\-/\\]+)\.(?:jpe?g|png|gif|webp|svg|bmp|avif|heic|heif|tiff?|ico|mp4|webm|mov|avi|mkv|mp3|wav|ogg|m4a|pdf))\b/i,aO=["path","file","file_path","filePath","filename","url","src","name","target"];function aU(e,t){if(e)for(let t of aO){let r=e[t];if("string"==typeof r&&r.length>0)return r}if(t)for(let e of aO){let r=t[e];if("string"==typeof r&&r.length>0&&aH(r))return r}if(e){let t=aV(e);if(t)return t}if((null==t?void 0:t.text)&&"string"==typeof t.text){let e=t.text.match(az);if(e)return e[1]}if(t){let e=aV(t);if(e)return e}return null}function aH(e){return e.length>2&&e.length<500&&/\.\w{1,5}$/.test(e)&&!e.includes(" ")}function aV(e){for(let t of Object.values(e))if("string"==typeof t&&aH(t))return t;return null}let aK=/https?:\/\/[^\s"'<>,;)}\]]+/gi;function aJ(e){return"https://www.google.com/s2/favicons?sz=64&domain_url=".concat(encodeURIComponent(e))}function aq(e){return e&&"object"==typeof e&&!Array.isArray(e)?e:null}function aG(e){return Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e&&!Array.isArray(e)):[]}function a$(e){return"string"==typeof e&&e.trim().length>0?e.trim():null}function aZ(e){return Array.isArray(e)?e.filter(e=>"string"==typeof e&&e.trim().length>0).map(e=>e.trim()):[]}function aY(e){let{label:t,value:r}=e;return(0,n.jsxs)("div",{className:"text-[11px] leading-relaxed",style:{color:"var(--color-text-secondary)"},children:[(0,n.jsxs)("span",{style:{color:"var(--color-text-muted)"},children:[t,": "]}),(0,n.jsx)("span",{children:r})]})}function aQ(e,t,r){if("dench_search_integrations"===e||"dench_execute_integrations"===e||"composio_search_tools"===e||"composio_call_tool"===e)return"composio";let n=e.toLowerCase().replace(/[_-]/g,"");if(["websearch","search","googlesearch","bingsearch","browsersearch","tavily"].some(e=>n.includes(e)))return"search";if("browser"===n){let e="string"==typeof(null==t?void 0:t.action)?t.action.toLowerCase():"";return"open"===e||"navigate"===e?"fetch":"screenshot"===e?"image":"generic"}if(["fetchurl","fetch","browse","browseurl","webfetch"].some(e=>n.includes(e)))return"fetch";if(["read","file","readfile","getfile"].some(e=>n.includes(e)))return"read";if(["bash","shell","execute","exec","terminal","command","run"].some(e=>n.includes(e)))return"exec";if(["write","create","edit","str_replace","save","patch"].some(e=>n.includes(e)))return"write";if(["image","screenshot","photo","picture","dalle","generateimage"].some(e=>n.includes(e))){if(("string"==typeof(null==t?void 0:t.description)?t.description.trim():"")||n.includes("generateimage")||n.includes("dalle"))return"image";let e=aU(t,r);return e&&"image"===aF(e)?"read":"image"}return"generic"}function aX(e){let{parts:t,isStreaming:r}=e,[l,a]=(0,o.useState)(!!r),s=t.some(e=>"reasoning"===e.kind&&e.isStreaming||"tool"===e.kind&&"running"===e.status),i=(0,o.useRef)(null),[c,d]=(0,o.useState)(0);(0,o.useEffect)(()=>{s&&null===i.current&&(i.current=Date.now())},[s]),(0,o.useEffect)(()=>{if(!s)return;let e=()=>{null!==i.current&&d(Math.floor((Date.now()-i.current)/1e3))};e();let t=setInterval(e,1e3);return()=>clearInterval(t)},[s]);let u=(0,o.useCallback)(e=>{if(e<60)return"".concat(e,"s");let t=Math.floor(e/60),r=e%60;return r>0?"".concat(t,"m ").concat(r,"s"):"".concat(t,"m")},[]),p=(0,o.useRef)(!1);(0,o.useEffect)(()=>{r?p.current=!0:p.current&&t.length>0&&(p.current=!1,a(!1))},[r,t.length]);let h=t.filter(e=>"reasoning"===e.kind).map(e=>e.text).join(""),x=t.some(e=>"reasoning"===e.kind&&e.isStreaming),m=function(e){let t=[],r=0;for(;r<e.length;){let n=e[r],o=aQ(n.toolName,n.args,n.output),l=aU(n.args,n.output),a=l?aF(l):null;if("read"===o&&a&&l){let o=[{path:l,tool:n}],s=r+1;for(;s<e.length;){let t=e[s],r=aQ(t.toolName,t.args,t.output),n=aU(t.args,t.output),l=n?aF(n):null;if("read"===r&&l===a&&n)o.push({path:n,tool:t}),s++;else break}t.push({type:"media-group",mediaKind:a,items:o}),r=s}else if("fetch"===o){let o=[n],l=r+1;for(;l<e.length;){let t=e[l];if("fetch"===aQ(t.toolName,t.args,t.output))o.push(t),l++;else break}o.length>1?t.push({type:"fetch-group",items:o}):t.push({type:"tool",tool:n}),r=l}else t.push({type:"tool",tool:n}),r++}return t}(t.filter(e=>"tool"===e.kind)),f=s?c>0?"Thinking for ".concat(u(c)):"Thinking...":c>0?"Thought for ".concat(u(c)):"Thought";return(0,n.jsxs)("div",{className:"my-3",children:[(0,n.jsxs)("button",{type:"button",onClick:()=>a(e=>!e),className:"flex items-center gap-2 py-1 text-[13px] cursor-pointer group",style:{color:"var(--color-text-muted)"},children:[(0,n.jsx)(a9,{className:"w-4 h-4 flex-shrink-0 opacity-60"}),(0,n.jsx)("span",{className:"font-medium",children:f}),(0,n.jsx)(se,{className:"w-3.5 h-3.5 ml-1 flex-shrink-0 transition-transform duration-200 ".concat(l?"":"-rotate-90")})]}),(0,n.jsx)(aL.N,{initial:!1,children:l&&(0,n.jsx)(aT.P.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.3,ease:[.25,.1,.25,1]},className:"overflow-hidden",children:(0,n.jsxs)("div",{className:"relative pt-2 pb-1",children:[(0,n.jsx)("div",{className:"absolute w-px",style:{left:9,top:16,bottom:8,background:"var(--color-border)"}}),(0,n.jsxs)(aL.N,{initial:!1,children:[h&&(0,n.jsxs)(aT.P.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.25,ease:"easeOut"},className:"flex items-start gap-2.5 py-1.5",children:[(0,n.jsx)("div",{className:"relative z-10 flex-shrink-0 w-[18px] h-[18px] flex items-center justify-center rounded-full",style:{background:"var(--color-bg)"},children:(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--color-text-muted)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M12 2a7 7 0 0 0-7 7c0 2.38 1.19 4.47 3 5.74V17a2 2 0 0 0 2 2h4a2 2 0 0 0 2-2v-2.26c1.81-1.27 3-3.36 3-5.74a7 7 0 0 0-7-7z"}),(0,n.jsx)("path",{d:"M10 21h4"})]})}),(0,n.jsx)("div",{className:"flex-1 min-w-0",children:(0,n.jsx)(a0,{text:h,isStreaming:x})})]},"reasoning"),m.map((e,t)=>"media-group"===e.type?(0,n.jsx)(aT.P.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.25,ease:"easeOut"},children:(0,n.jsx)(a2,{mediaKind:e.mediaKind,items:e.items})},"media-".concat(t)):"fetch-group"===e.type?(0,n.jsx)(aT.P.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.25,ease:"easeOut"},children:(0,n.jsx)(a1,{items:e.items})},"fetch-".concat(t)):(0,n.jsx)(aT.P.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.25,ease:"easeOut"},children:(0,n.jsx)(a5,{...e.tool})},e.tool.toolCallId))]})]})},"content")})]})}function a0(e){let{text:t,isStreaming:r}=e;return(0,n.jsx)("div",{className:"mb-2",children:(0,n.jsx)("div",{className:"text-[13px] whitespace-pre-wrap leading-relaxed",style:{color:"var(--color-text-muted)"},children:t})})}function a1(e){let{items:t}=e,r=t.some(e=>"running"===e.status),o=t.filter(e=>"done"===e.status).length;return(0,n.jsxs)("div",{className:"flex items-start gap-2.5 py-1.5",children:[(0,n.jsx)("div",{className:"relative z-10 flex-shrink-0 w-[18px] h-[18px] flex items-center justify-center rounded-full",style:{background:"var(--color-bg)"},children:(0,n.jsx)("span",{className:r?"animate-pulse":"",children:(0,n.jsx)(a6,{kind:"fetch"})})}),(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsxs)("div",{className:"text-[13px] leading-snug mb-1.5 flex items-center justify-between",style:{color:r?"var(--color-text)":"var(--color-text-secondary)"},children:[(0,n.jsx)("span",{className:r?"animate-pulse":"",children:r?"Fetching ".concat(t.length," sources..."):"Fetched ".concat(t.length," sources")}),!r&&(0,n.jsxs)("span",{className:"text-[11px]",style:{color:"var(--color-text-muted)"},children:[o," ",1===o?"result":"results"]})]}),(0,n.jsx)("div",{className:"rounded-2xl overflow-hidden",style:{background:"var(--color-surface)",border:"1px solid var(--color-border)"},children:t.map(e=>{var t,r;let{domain:o,url:l}=function(e,t){for(let t of["url","targetUrl","path","src"]){let r=null==e?void 0:e[t];if("string"==typeof r&&r.startsWith("http"))try{return{domain:new URL(r).hostname,url:r}}catch(e){}}for(let e of["url","finalUrl","targetUrl"]){let r=null==t?void 0:t[e];if("string"==typeof r&&r.startsWith("http"))try{return{domain:new URL(r).hostname,url:r}}catch(e){}}return{domain:null,url:null}}(e.args,e.output);return(0,n.jsxs)("a",{href:null!=l?l:void 0,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2.5 px-3 py-2.5 text-[12px] no-underline",style:{color:"var(--color-text)",cursor:l?"pointer":"default"},onMouseEnter:e=>{e.currentTarget.style.background="var(--color-surface-hover)"},onMouseLeave:e=>{e.currentTarget.style.background="transparent"},onClick:l?void 0:e=>e.preventDefault(),children:[o?(0,n.jsx)("img",{src:aJ(o),alt:"",width:16,height:16,className:"rounded-sm flex-shrink-0",loading:"lazy"}):(0,n.jsx)("div",{className:"w-4 h-4 rounded-sm flex-shrink-0",style:{background:"var(--color-surface-hover)"}}),(0,n.jsx)("span",{className:"flex-1 min-w-0 truncate",style:{color:"var(--color-text)"},children:null!=(r=null!=(t=null==o?void 0:o.replace(/^www\./,""))?t:l)?r:"Fetching..."}),"running"===e.status?(0,n.jsx)("span",{className:"w-2 h-2 rounded-full animate-pulse flex-shrink-0",style:{background:"var(--color-accent)"}}):l?(0,n.jsx)("span",{className:"text-[11px] truncate max-w-[45%] text-right",style:{color:"var(--color-text-muted)"},title:l,children:l}):null]},e.toolCallId)})})]})]})}function a2(e){let{mediaKind:t,items:r}=e,[l,a]=(0,o.useState)(!1),s=r.some(e=>"running"===e.tool.status),i=r.filter(e=>"done"===e.tool.status),c=i.length,d=s?"Reading ".concat(r.length," ").concat(t).concat(r.length>1?"s":"","..."):"image"===t?1===r.length?"Read 1 image":"Read ".concat(r.length," images"):"video"===t?1===r.length?"Read 1 video":"Read ".concat(r.length," videos"):"pdf"===t?1===r.length?"Read 1 PDF":"Read ".concat(r.length," PDFs"):1===r.length?"Read 1 audio file":"Read ".concat(r.length," audio files"),u=l?i:i.slice(0,6),p=i.length>6&&!l;return(0,n.jsxs)("div",{className:"flex items-start gap-2.5 py-1.5",children:[(0,n.jsx)("div",{className:"relative z-10 flex-shrink-0 w-[18px] h-[18px] flex items-center justify-center rounded-full",style:{background:"var(--color-bg)"},children:(0,n.jsx)("span",{className:s?"animate-pulse":"",children:(0,n.jsx)(a6,{kind:"image"===t?"image":"read"})})}),(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsx)("div",{className:"text-[13px] leading-snug mb-1.5".concat(s?" animate-pulse":""),style:{color:s?"var(--color-text)":"var(--color-text-secondary)"},children:d}),c>0&&"image"===t&&(0,n.jsxs)("div",{className:"flex flex-wrap gap-1.5",children:[u.map(e=>(0,n.jsx)(a4,{path:e.path,single:1===r.length},e.tool.toolCallId)),s&&(0,n.jsx)("div",{className:"flex items-center justify-center rounded-lg",style:{width:80,height:80,background:"var(--color-surface-hover)",border:"1px solid var(--color-border)"},children:(0,n.jsx)("span",{className:"animate-pulse",style:{color:"var(--color-text-muted)"},children:(0,n.jsx)(a6,{kind:"image"})})}),p&&(0,n.jsxs)("button",{type:"button",onClick:()=>a(!0),className:"flex items-center justify-center rounded-lg text-xs font-medium cursor-pointer",style:{width:80,height:80,background:"var(--color-surface-hover)",color:"var(--color-text-muted)",border:"1px solid var(--color-border)"},children:["+",i.length-6," ","more"]})]}),c>0&&"video"===t&&(0,n.jsx)("div",{className:"flex flex-wrap gap-2",children:u.map(e=>(0,n.jsx)("video",{src:aP(e.path),controls:!0,preload:"metadata",className:"rounded-lg max-w-[240px] max-h-[160px]",style:{border:"1px solid var(--color-border)"}},e.tool.toolCallId))}),c>0&&"pdf"===t&&(0,n.jsx)("div",{className:"flex flex-col gap-1.5",children:u.map(e=>{var t;let r=null!=(t=e.path.split("/").pop())?t:e.path;return(0,n.jsxs)("a",{href:aP(e.path),target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 px-3 py-2 rounded-lg text-[12px]",style:{background:"var(--color-surface-hover)",color:"var(--color-text-secondary)",border:"1px solid var(--color-border)"},children:[(0,n.jsx)(a7,{}),(0,n.jsx)("span",{className:"truncate max-w-[200px]",children:r})]},e.tool.toolCallId)})}),c>0&&"audio"===t&&(0,n.jsx)("div",{className:"flex flex-col gap-1.5",children:u.map(e=>(0,n.jsx)("audio",{src:aP(e.path),controls:!0,preload:"metadata",className:"max-w-[280px] h-8"},e.tool.toolCallId))})]})]})}function a4(e){var t;let{path:r,single:l}=e,[a,s]=(0,o.useState)(!1),i=null!=(t=r.split("/").pop())?t:r,c=aP(r),d=l?200:80,u=l?150:80;return a?(0,n.jsx)("div",{className:"flex items-center justify-center rounded-lg text-[10px] text-center p-1",style:{width:d,height:u,background:"var(--color-surface-hover)",color:"var(--color-text-muted)",border:"1px solid var(--color-border)"},title:r,children:(0,n.jsx)("span",{className:"truncate",children:i})}):(0,n.jsx)("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:"block rounded-lg overflow-hidden flex-shrink-0",style:{border:"1px solid var(--color-border)",width:d,height:u},title:i,children:(0,n.jsx)("img",{src:c,alt:i,className:"w-full h-full object-cover",loading:"lazy",onError:()=>s(!0)})})}function a5(e){var t;let{toolName:r,status:l,args:a,output:s,errorText:i}=e,c=aQ(r,a,s),d="dench_search_integrations"===r||"composio_search_tools"===r,u="dench_execute_integrations"===r||"composio_call_tool"===r,[p,h]=(0,o.useState)(!(d||u)&&("exec"===c||"generic"===c)),[x,m]=(0,o.useState)(!0),f=function(e,t,r,n){var o,l,a,s,i,c,d,u,p,h,x,m,f,v,g,y,b,j,k;let w=e=>{let t=null==r?void 0:r[e];return"string"==typeof t&&t.length>0?t:null};switch(e){case"composio":return"dench_search_integrations"===t||"composio_search_tools"===t?a_.searchLabel:"dench_execute_integrations"===t||"composio_call_tool"===t?a_.callLabel:a_.genericToolLabel;case"search":{let e=null!=(a=null!=(l=null!=(o=w("query"))?o:w("search_query"))?l:w("search"))?a:w("q");return e?"Searching for ".concat(e):"Searching..."}case"fetch":{let e=null!=(c=null!=(i=null!=(s=w("url"))?s:w("targetUrl"))?i:w("path"))?c:w("src");if(e)try{return"Fetching ".concat(new URL(e).hostname)}catch(t){return"Fetching ".concat(e)}let t="string"==typeof(null==n?void 0:n.finalUrl)&&n.finalUrl||"string"==typeof(null==n?void 0:n.url)&&n.url;if(t)try{return"Fetched ".concat(new URL(t).hostname)}catch(e){return"Fetched ".concat(t)}return"Fetching page"}case"read":{let e=aU(r,n);if(e){let t=null!=(d=e.split("/").pop())?d:e;return t.startsWith("http")?"Fetching ".concat(t):"Reading ".concat(t)}return"Reading file"}case"exec":{let e=null!=(u=w("command"))?u:w("cmd");if(e)return"Running: ".concat(e);return"Running command"}case"write":{let e=null!=(h=null!=(p=w("path"))?p:w("file"))?h:w("file_path");if(e){let t=null!=(x=e.split("/").pop())?x:e;return"Editing ".concat(t)}return"Editing file"}case"image":return w("description")?"Generating image: ".concat(w("description")):"Generating image";default:{let e=t.replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()).trim();if(r){let t=null!=(k=null!=(j=null!=(b=null!=(y=null!=(g=null!=(v=null!=(f=null!=(m=w("command"))?m:w("cmd"))?f:w("query"))?v:w("path"))?g:w("url"))?y:w("message"))?b:w("description"))?j:w("input"))?k:w("text");if(t)return"".concat(e,": ").concat(t)}return e||"Tool"}}}(c,r,a,s),v=d?function(e){var t,r,n,o,l,a,s;if(!e)return null;let i=aG(e.results),c=null!=(t=aq(e.recommended_result))?t:i[0],d=i.slice(0,3).map(e=>{var t,r;return null!=(r=null!=(t=a$(e.tool))?t:a$(e.tool_slug))?r:a$(e.name)}).filter(e=>!!e),u=aq(null==c?void 0:c.selected_account),p=aG(null!=(r=null==c?void 0:c.account_candidates)?r:null==c?void 0:c.accounts),h=aq(null!=(n=null==c?void 0:c.input_schema)?n:null==c?void 0:c.input_parameters),x=aq(null==h?void 0:h.properties),m=x?Object.keys(x):[],f=aZ(null==h?void 0:h.required),v=aZ(null!=(o=null==c?void 0:c.recommended_plan_steps)?o:e.next_steps_guidance).slice(0,3),g=aZ(null==c?void 0:c.known_pitfalls).slice(0,2),y="number"==typeof(null==c?void 0:c.account_count)?c.account_count:p.length,b=aq(null==c?void 0:c.toolkit),j=null!=(l=a$(null==b?void 0:b.name))?l:a$(null==b?void 0:b.slug),k="number"==typeof e.result_count?e.result_count:i.length,w=aZ(e.connected_toolkits),N=null!=(a=a$(e.toolkit_filter))?a:a$(e.app_filter);return{resultSummary:k>0?"".concat(k," tool").concat(1===k?"":"s"," found"):N?"No ".concat(N," tools matched"):"No tools matched",connectedToolkits:w.length>0?w.join(", "):null,topTools:d,sessionId:a$(e.search_session_id),accountSummary:null!=(s=a$(null==u?void 0:u.display_label))?s:y>0?"".concat(y," connected account").concat(1===y?"":"s").concat(j?" (".concat(j,")"):""):(null==c?void 0:c.is_connected)===!0?"Connected":null,schemaSummary:m.length>0?"".concat(m.length," input fields").concat(f.length>0?", ".concat(f.length," required"):""):null,schemaText:h?JSON.stringify(h,null,2):null,planSteps:v,pitfalls:g}}(s):null,g=u?function(e,t){var r,n,o,l,a,s,i,c,d,u,p,h,x,m;let f=aq(null==t?void 0:t.execution),v=aq(null==t?void 0:t.recovery),g=null!=(l=null!=(o=null!=(n=a$(null==e?void 0:e.tool_name))?n:a$(null==e?void 0:e.tool_slug))?o:a$(null==t?void 0:t.tool_slug))?l:a$(null==f?void 0:f.tool_name);if(!g)return null;let y=aq(null==e?void 0:e.arguments),b=y?Object.entries(y).slice(0,3).map(e=>{let[t,r]=e,n="string"==typeof r?r:JSON.stringify(r);return"".concat(t,": ").concat(n)}):[],j=aq(null==t?void 0:t.structuredContent),k=null!=j?j:t,w=Array.isArray(null==k?void 0:k.data)?k.data:Array.isArray(null==k?void 0:k.items)?k.items:void 0,N=w?"".concat(w.length," result").concat(1===w.length?"":"s"):null!=(a=a$(null==t?void 0:t.status))?a:null,C=[Object.hasOwn(null!=k?k:{},"has_more")?"has_more: ".concat(String(null==k?void 0:k.has_more)):null,a$(null==k?void 0:k.next_cursor)?"next_cursor: ".concat(a$(null==k?void 0:k.next_cursor)):null,a$(null==k?void 0:k.starting_after)?"starting_after: ".concat(a$(null==k?void 0:k.starting_after)):null].filter(e=>!!e),S=[a$(null==v?void 0:v.recovered_via),a$(null==v?void 0:v.retried_with_account)?"account: ".concat(a$(null==v?void 0:v.retried_with_account)):null,a$(null==v?void 0:v.refreshed_execution_ref)?"refreshed execution_ref returned":null].filter(e=>!!e),M=g.split("_"),L=M.length>1?null==(r=M[0])?void 0:r.toLowerCase():null;return{app:null!=(c=null!=(i=null!=(s=a$(null==e?void 0:e.app))?s:a$(null==t?void 0:t.toolkit))?i:a$(null==f?void 0:f.toolkit))?c:L,toolName:g,account:null!=(x=null!=(h=null!=(p=null!=(u=null!=(d=a$(null==e?void 0:e.account))?d:a$(null==t?void 0:t.account))?u:a$(null==f?void 0:f.account))?p:a$(null==e?void 0:e.connected_account_id))?h:a$(null==t?void 0:t.connectedAccountId))?x:a$(null==e?void 0:e.account_identity),keyArgs:b,pagination:C.length>0?C.join(" | "):null,resultSummary:N,sessionId:null!=(m=a$(null==t?void 0:t.tool_router_session_id))?m:a$(null==f?void 0:f.tool_router_session_id),recoverySummary:S.length>0?S.join(" | "):null}}(a,s):null,y="search"===c?function(e){var t;if(!e)return[];let r="string"==typeof e.text?e.text:"",n=e.results,o=e.citations,l=r;if(Array.isArray(n))for(let e of n)"string"==typeof e?l+=" ".concat(e):"object"==typeof e&&null!==e&&("string"==typeof e.url&&(l+=" ".concat(e.url)),"string"==typeof e.link&&(l+=" ".concat(e.link)));if(Array.isArray(o))for(let e of o)"string"==typeof e?l+=" ".concat(e):"object"==typeof e&&null!==e&&"string"==typeof e.url&&(l+=" ".concat(e.url));for(let t of Object.values(e))"string"==typeof t&&t!==r&&t.includes("http")&&(l+=" ".concat(t));let a=null!=(t=l.match(aK))?t:[],s=new Set;for(let e of a)try{let t=new URL(e).hostname;t&&!t.includes("localhost")&&s.add(t)}catch(e){}return[...s].slice(0,8)}(s):"fetch"===c?function(e,t){let r=new Set;for(let t of["url","targetUrl","path","src"]){let n=null==e?void 0:e[t];if("string"==typeof n&&n.startsWith("http"))try{let e=new URL(n).hostname;e&&!e.includes("localhost")&&r.add(e)}catch(e){}}for(let e of["url","finalUrl","targetUrl"]){let n=null==t?void 0:t[e];if("string"==typeof n&&n.startsWith("http"))try{let e=new URL(n).hostname;e&&!e.includes("localhost")&&r.add(e)}catch(e){}}return[...r].slice(0,4)}(a,s):[],b="string"==typeof(null==s?void 0:s.error)?s.error:void 0,j=null!=i?i:b,k="string"==typeof(null==s?void 0:s.text)?s.text:void 0,w=(()=>{if("write"!==c||"done"!==l)return;if("string"==typeof(null==s?void 0:s.diff))return s.diff;let e="string"==typeof(null==a?void 0:a.old_string)?a.old_string:"string"==typeof(null==a?void 0:a.oldText)?a.oldText:null,t="string"==typeof(null==a?void 0:a.new_string)?a.new_string:"string"==typeof(null==a?void 0:a.newText)?a.newText:null;if(null!==e&&null!==t){var r="string"==typeof(null==a?void 0:a.path)?a.path:"string"==typeof(null==a?void 0:a.file_path)?a.file_path:"file";let n=e.split("\n"),o=t.split("\n"),l=["--- a/".concat(r),"+++ b/".concat(r),"@@ -1,".concat(n.length," +1,").concat(o.length," @@")];for(let e of n)l.push("-".concat(e));for(let e of o)l.push("+".concat(e));return l.join("\n")}})(),N=aU(a,s),C=N?aF(N):null,S="read"===c&&C&&"done"===l;return(0,n.jsxs)("div",{className:"flex items-start gap-2.5 py-1.5",children:[(0,n.jsx)("div",{className:"relative z-10 flex-shrink-0 w-[18px] h-[18px] flex items-center justify-center rounded-full",style:{background:"var(--color-bg)"},children:"error"===l?(0,n.jsx)(a8,{}):(0,n.jsx)("span",{className:"running"===l?"animate-pulse":"",children:(0,n.jsx)(a6,{kind:c})})}),(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsxs)("div",{className:"text-[13px] leading-snug flex items-center gap-2 flex-wrap",style:{color:"running"===l?"var(--color-text)":"var(--color-text-secondary)"},children:[(0,n.jsx)("span",{className:"break-all".concat("running"===l?" animate-pulse":"").concat(!k||S||w||"done"!==l?"":" cursor-pointer hover:underline"),onClick:!k||S||w||"done"!==l?void 0:()=>h(e=>!e),children:f}),"exec"===c&&"done"===l&&(null==s?void 0:s.exitCode)!==void 0&&(0,n.jsxs)("span",{className:"text-[11px] font-mono px-1.5 py-0.5 rounded",style:{background:0===s.exitCode?"color-mix(in srgb, var(--color-success, #22c55e) 12%, transparent)":"color-mix(in srgb, var(--color-error) 12%, transparent)",color:0===s.exitCode?"var(--color-success, #22c55e)":"var(--color-error)"},children:["exit ","object"==typeof s.exitCode&&null!=s.exitCode?JSON.stringify(s.exitCode):"number"==typeof s.exitCode?String(s.exitCode):"string"==typeof s.exitCode?s.exitCode:""]})]}),w&&"done"===l&&(0,n.jsxs)("div",{className:"mt-1.5",children:[(0,n.jsx)("button",{type:"button",onClick:()=>m(e=>!e),className:"text-[11px] hover:underline cursor-pointer mb-1",style:{color:"var(--color-accent)"},children:x?"Hide changes":"Show changes"}),x&&(0,n.jsx)(n8,{diff:w})]}),S&&N&&"image"===C&&(0,n.jsx)("div",{className:"mt-1.5",children:(0,n.jsx)(a4,{path:N,single:!0})}),S&&N&&"video"===C&&(0,n.jsx)("video",{src:aP(N),controls:!0,preload:"metadata",className:"mt-1.5 rounded-lg max-w-[240px] max-h-[160px]",style:{border:"1px solid var(--color-border)"}}),S&&N&&"pdf"===C&&(0,n.jsxs)("a",{href:aP(N),target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 mt-1.5 px-3 py-2 rounded-lg text-[12px]",style:{background:"var(--color-surface-hover)",color:"var(--color-text-secondary)",border:"1px solid var(--color-border)"},children:[(0,n.jsx)(a7,{}),(0,n.jsx)("span",{className:"truncate max-w-[200px]",children:null!=(t=N.split("/").pop())?t:N})]}),S&&N&&"audio"===C&&(0,n.jsx)("audio",{src:aP(N),controls:!0,preload:"metadata",className:"mt-1.5 max-w-[280px] h-8"}),y.length>0&&"running"!==l&&(0,n.jsx)("div",{className:"flex items-center gap-1.5 flex-wrap mt-1.5",children:y.map(e=>(0,n.jsx)(a3,{domain:e},e))}),("search"===c||"fetch"===c)&&"running"===l&&a&&(0,n.jsx)("div",{className:"flex items-center gap-1.5 flex-wrap mt-1.5",children:y.length>0?y.map(e=>(0,n.jsxs)("span",{className:"inline-flex items-center gap-1.5 h-7 px-2.5 rounded-full text-[12px]",style:{background:"var(--color-surface-hover)",color:"var(--color-text-secondary)",border:"1px solid var(--color-border)"},children:[(0,n.jsx)("img",{src:aJ(e),alt:"",width:14,height:14,className:"rounded-sm flex-shrink-0",loading:"lazy"}),e.replace(/^www\./,""),(0,n.jsx)("span",{className:"w-2 h-2 rounded-full animate-pulse",style:{background:"var(--color-accent)"}})]},e)):(0,n.jsxs)("span",{className:"inline-flex items-center gap-1 h-6 px-2 rounded-full text-[11px]",style:{background:"var(--color-surface-hover)",color:"var(--color-text-muted)",border:"1px solid var(--color-border)"},children:[(0,n.jsx)("span",{className:"w-2 h-2 rounded-full animate-pulse",style:{background:"var(--color-accent)"}}),"fetch"===c?"Fetching...":"Searching..."]})}),"error"===l&&j&&(0,n.jsx)("div",{className:"mt-1.5 text-[12px] font-mono rounded-lg px-2.5 py-1.5",style:{color:"var(--color-error)",background:"color-mix(in srgb, var(--color-error) 6%, var(--color-surface))"},children:j}),v&&(0,n.jsxs)("div",{className:"mt-1.5 rounded-lg px-2.5 py-2",style:{background:"var(--color-bg)",border:"1px solid var(--color-border)"},children:[(0,n.jsx)(aY,{label:"Results",value:v.resultSummary}),v.connectedToolkits&&(0,n.jsx)(aY,{label:"Connected",value:v.connectedToolkits}),v.topTools.length>0&&(0,n.jsx)(aY,{label:"Top matches",value:v.topTools.join(", ")}),v.accountSummary&&(0,n.jsx)(aY,{label:"Accounts",value:v.accountSummary}),v.schemaSummary&&(0,n.jsx)(aY,{label:"Schema",value:v.schemaSummary}),v.planSteps.length>0&&(0,n.jsx)(aY,{label:"Plan",value:v.planSteps.join(" -> ")}),v.pitfalls.length>0&&(0,n.jsx)(aY,{label:"Pitfalls",value:v.pitfalls.join(" | ")}),v.sessionId&&(0,n.jsx)(aY,{label:"Session",value:v.sessionId}),v.schemaText&&(0,n.jsxs)("details",{className:"mt-2",children:[(0,n.jsx)("summary",{className:"text-[11px] cursor-pointer",style:{color:"var(--color-text-secondary)"},children:"Schema details"}),(0,n.jsx)("pre",{className:"mt-2 text-[11px] font-mono rounded-lg px-2.5 py-2 overflow-x-auto whitespace-pre-wrap break-all max-h-56 overflow-y-auto leading-relaxed",style:{color:"var(--color-text-muted)",background:"var(--color-surface-hover)"},children:v.schemaText})]})]}),g&&(0,n.jsxs)("div",{className:"mt-1.5 rounded-lg px-2.5 py-2",style:{background:"var(--color-bg)",border:"1px solid var(--color-border)"},children:[(0,n.jsx)(aY,{label:"Tool",value:g.app?"".concat(g.app," / ").concat(g.toolName):g.toolName}),g.account&&(0,n.jsx)(aY,{label:"Account",value:g.account}),g.sessionId&&(0,n.jsx)(aY,{label:"Session",value:g.sessionId}),g.recoverySummary&&(0,n.jsx)(aY,{label:"Recovery",value:g.recoverySummary}),g.keyArgs.length>0&&(0,n.jsx)(aY,{label:"Args",value:g.keyArgs.join(" | ")}),g.pagination&&(0,n.jsx)(aY,{label:"Pagination",value:g.pagination}),g.resultSummary&&(0,n.jsx)(aY,{label:"Result",value:g.resultSummary})]}),!k&&!w&&!S&&"running"!==l&&a&&Object.keys(a).length>0&&(0,n.jsx)("pre",{className:"mt-1 text-[11px] font-mono rounded-lg px-2.5 py-1.5 whitespace-pre-wrap break-all max-h-48 overflow-y-auto leading-relaxed",style:{color:"var(--color-text-muted)",background:"var(--color-bg)"},children:function(e){let t=[];for(let[r,n]of Object.entries(e)){if(null==n)continue;let e="string"==typeof n?n:JSON.stringify(n,null,2);t.push("".concat(r,": ").concat(e))}let r=t.join("\n");return r.length>2e3?r.slice(0,2e3)+"\n...":r}(a)}),k&&!S&&!w&&(0,n.jsx)("div",{className:"mt-1",children:(p||"running"===l)&&(0,n.jsx)("pre",{className:"mt-1 text-[11px] font-mono rounded-lg px-2.5 py-2 overflow-x-auto whitespace-pre-wrap break-all max-h-96 overflow-y-auto leading-relaxed",style:{color:"var(--color-text-muted)",background:"var(--color-bg)"},children:k.length>1e4?k.slice(0,1e4)+"\n... (truncated)":k})})]})]})}function a3(e){let{domain:t}=e,r=t.replace(/^www\./,"");return(0,n.jsxs)("span",{className:"inline-flex items-center gap-1.5 h-7 px-2.5 rounded-full text-[12px]",style:{background:"var(--color-surface-hover)",color:"var(--color-text-secondary)",border:"1px solid var(--color-border)"},children:[(0,n.jsx)("img",{src:aJ(t),alt:"",width:16,height:16,className:"rounded-sm flex-shrink-0",loading:"lazy"}),r]})}function a6(e){let{kind:t}=e,r="var(--color-text-muted)";switch(t){case"composio":return(0,n.jsx)("img",{src:"/dench-integrations-icon.png",alt:"",width:16,height:16,className:"rounded-sm"});case"search":return(0,n.jsxs)("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:r,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,n.jsx)("path",{d:"m21 21-4.3-4.3"})]});case"fetch":return(0,n.jsxs)("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:r,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,n.jsx)("path",{d:"M2 12h20"}),(0,n.jsx)("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]});case"read":return(0,n.jsxs)("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:r,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"}),(0,n.jsx)("path",{d:"M14 2v4a2 2 0 0 0 2 2h4"})]});case"exec":return(0,n.jsxs)("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:r,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("polyline",{points:"4 17 10 11 4 5"}),(0,n.jsx)("line",{x1:"12",x2:"20",y1:"19",y2:"19"})]});case"write":return(0,n.jsxs)("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:r,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),(0,n.jsx)("path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z"})]});case"image":return(0,n.jsxs)("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:r,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),(0,n.jsx)("circle",{cx:"9",cy:"9",r:"2"}),(0,n.jsx)("path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"})]});default:return(0,n.jsx)("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:r,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("circle",{cx:"12",cy:"12",r:"1"})})}}function a8(){return(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"var(--color-error)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,n.jsx)("line",{x1:"15",x2:"9",y1:"9",y2:"15"}),(0,n.jsx)("line",{x1:"9",x2:"15",y1:"9",y2:"15"})]})}function a7(){return(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"}),(0,n.jsx)("path",{d:"M14 2v4a2 2 0 0 0 2 2h4"}),(0,n.jsx)("path",{d:"M10 9H8"}),(0,n.jsx)("path",{d:"M16 13H8"}),(0,n.jsx)("path",{d:"M16 17H8"})]})}function a9(e){let{className:t}=e;return(0,n.jsxs)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M12 2a7 7 0 0 0-7 7c0 2.38 1.19 4.47 3 5.74V17a2 2 0 0 0 2 2h4a2 2 0 0 0 2-2v-2.26c1.81-1.27 3-3.36 3-5.74a7 7 0 0 0-7-7z"}),(0,n.jsx)("path",{d:"M10 21h4"}),(0,n.jsx)("path",{d:"M9 9.4a3 3 0 0 1 5.1-2"})]})}function se(e){let{className:t}=e;return(0,n.jsx)("svg",{className:t,viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"M3 4.5L6 7.5L9 4.5"})})}let st=["Preparing response...","Optimizing session context...","Waiting for subagent results...","Waiting for subagents..."];function sr(e){return e.trim().replace(/\s+/g," ")}function sn(e){return"text"===e.type&&"string"==typeof e.text&&sr(e.text).length>0}function so(e){return"dynamic-tool"===e.type||"tool-invocation"===e.type||e.type.startsWith("tool-")}function sl(e){for(let t=e.length-1;t>=0;t--)if(so(e[t]))return t;return -1}function sa(e){return"dynamic-tool"===e.type?"string"==typeof e.toolName?e.toolName:null:e.type.startsWith("tool-")?"string"==typeof e.title&&e.title.trim()?e.title:"string"==typeof e.toolName&&e.toolName.trim()?e.toolName:e.type.replace(/^tool-/,""):null}function ss(e){return"dynamic-tool"===e.type?"string"==typeof e.state?e.state:"input-available":e.type.startsWith("tool-")?"string"==typeof e.state?e.state:"string"==typeof e.errorText&&e.errorText.trim()?"error":"result"in e||"output"in e?"output-available":"input-available":null}function si(e){return!!((null==e?void 0:e.role)==="assistant"&&e.parts.some(e=>sn(e)))}function sc(e){if(!e||"assistant"!==e.role)return!1;let t=sl(e.parts);return -1===t?si(e):e.parts.slice(t+1).some(e=>sn(e))}function sd(e){return st.some(t=>e.startsWith(t))}function su(e){let{state:t}=e;return"loading"===t?(0,n.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"animate-spin",children:(0,n.jsx)("path",{d:"M21 12a9 9 0 1 1-9-9"})}):"playing"===t?(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,n.jsx)("rect",{x:"6",y:"5",width:"4",height:"14",rx:"1"}),(0,n.jsx)("rect",{x:"14",y:"5",width:"4",height:"14",rx:"1"})]}):(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),(0,n.jsx)("path",{d:"M15.5 8.5a5 5 0 0 1 0 7"}),(0,n.jsx)("path",{d:"M19 5a10 10 0 0 1 0 14"})]})}function sp(e){let{text:t}=e,[r,l]=(0,o.useState)("idle"),a=(0,o.useRef)(null),s=(0,o.useRef)(null);(0,o.useEffect)(()=>()=>{var e;null==(e=a.current)||e.pause(),s.current&&URL.revokeObjectURL(s.current)},[]);let i=()=>{var e;null==(e=a.current)||e.pause(),a.current=null,s.current&&(URL.revokeObjectURL(s.current),s.current=null),l("idle")},c=async()=>{if("loading"!==r){if("playing"===r)return void i();l("loading");try{let e=await fetch("/api/voice/speech",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:t})});if(!e.ok)throw Error("Failed to generate audio.");s.current&&URL.revokeObjectURL(s.current);let r=URL.createObjectURL(await e.blob());s.current=r;let n=new Audio(r);a.current=n,n.addEventListener("ended",i,{once:!0}),await n.play(),l("playing")}catch(e){l("error"),window.setTimeout(()=>l("idle"),2e3)}}};return(0,n.jsx)("button",{type:"button",onClick:()=>void c(),className:"p-1 rounded-md transition-colors",style:{color:"error"===r?"var(--color-error, #ef4444)":"var(--color-text-muted)"},title:"playing"===r?"Stop voice playback":"Play voice","aria-label":"playing"===r?"Stop voice playback":"Play voice",children:(0,n.jsx)(su,{state:r})})}let sh=null,sx=["typescript","tsx","javascript","jsx","python","ruby","go","rust","java","c","cpp","csharp","swift","kotlin","css","scss","html","xml","json","yaml","toml","bash","sql","graphql","markdown","diff","php","lua","vue","svelte","dart","zig"];function sm(e){let{code:t,lang:r}=e,[l,a]=(0,o.useState)(null);return((0,o.useEffect)(()=>{let e=!1;return(!sh&&(sh=(0,ob.O_)({themes:["github-dark","github-light"],langs:sx})),sh).then(n=>{if(!e)try{let e=n.codeToHtml(t,{lang:r,themes:{dark:"github-dark",light:"github-light"}});a(e)}catch(e){try{let e=n.codeToHtml(t,{lang:"text",themes:{dark:"github-dark",light:"github-light"}});a(e)}catch(e){}}}),()=>{e=!0}},[t,r]),l)?(0,n.jsx)("div",{className:"syntax-block",dangerouslySetInnerHTML:{__html:l}}):(0,n.jsx)("code",{className:"block",children:t})}function sf(e,t){let r=e.get(t);return"string"==typeof r&&r.trim().length>0?r.trim():null}function sv(e){let t,r=e.trim();if(!r)return null;try{t=new URL(r)}catch(e){return null}if("dench:"!==t.protocol||"composio"!==t.hostname)return null;let n=t.pathname.replace(/^\/+|\/+$/g,"");return"connect"!==n&&"reconnect"!==n?null:{action:n,toolkitSlug:sf(t.searchParams,"toolkit"),toolkitName:sf(t.searchParams,"name")}}let sg={x:"x",twitter:"x",googlecalendar:"google-calendar","google-calendar":"google-calendar",googlesheets:"google-sheets","google-sheets":"google-sheets",googledrive:"google-drive","google-drive":"google-drive",googledocs:"google-docs","google-docs":"google-docs"},sy={x:["twitter","x"],"google-calendar":["google calendar","googlecalendar","google-calendar"],"google-sheets":["google sheets","googlesheets","google-sheets"],"google-drive":["google drive","googledrive","google-drive"],"google-docs":["google docs","googledocs","google-docs"]},sb={x:"twitter","google-calendar":"googlecalendar","google-sheets":"googlesheets","google-drive":"googledrive","google-docs":"googledocs"};function sj(e){var t;let r=e.trim().toLowerCase();return null!=(t=sg[r])?t:r}function sk(e,t){let r=sj(t);return"x"===r?"X":"string"==typeof e&&e.trim().length>0?e.trim():r}function sw(e){return Array.isArray(e)?e.filter(e=>"string"==typeof e&&e.trim().length>0):[]}function sN(e){return"string"==typeof e&&e.trim()?e.trim():void 0}function sC(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];for(let e of t){let t=sN(e);if(t)return t}}function sS(e){var t,r,n,o,l;let a=(l=e.meta)&&"object"==typeof l&&!Array.isArray(l)?l:void 0,s=null!=(t=sC(e.slug,e.name))?t:"unknown",i=sj(s),c="number"==typeof(null==a?void 0:a.tools_count)?a.tools_count:void 0,d="number"==typeof e.tools_count?e.tools_count:"number"==typeof e.toolsCount?e.toolsCount:null!=c?c:0,u=sw(e.categories),p=sw(null==a?void 0:a.categories),h=u.length>0?u:p;return{slug:i,connect_slug:s,name:sk(sC(e.name,e.slug),s),description:null!=(r=sC(e.description,e.description_short,e.summary,sN(null==a?void 0:a.description)))?r:"",logo:null!=(n=sC(e.logo,e.logo_url,e.icon,e.image,sN(null==a?void 0:a.logo)))?n:null,categories:h,auth_schemes:sw(null!=(o=e.auth_schemes)?o:e.authSchemes),tools_count:d}}function sM(e){var t,r,n,o,l;let a=(null!=(r=e.items)?r:[]).map(sS),s=(null==(t=e.categories)?void 0:t.length)?e.categories:Array.from(new Set(a.flatMap(e=>e.categories)));return{items:a,categories:s,cursor:null!=(l=null!=(o=null!=(n=e.cursor)?n:e.next_cursor)?o:e.nextCursor)?l:null,total:"number"==typeof e.total?e.total:"number"==typeof e.total_items?e.total_items:a.length}}function sL(e){var t,r;return((null==(t=e.connections)?void 0:t.length)?e.connections:null!=(r=e.items)?r:[]).map(sT)}function sT(e){var t,r,n,o,l,a,s,i,c,d,u,p,h,x,m,f,v,g,y,b;let j=null!=(p=sC(e.id,e.connectionId))?p:"unknown-connection",k=null!=(h=sC(e.toolkit_slug,null==(t=e.toolkit)?void 0:t.slug))?h:"unknown",w=sj(k),N=sC(e.toolkit_name,null==(r=e.toolkit)?void 0:r.name,k),C=sC(e.account_label,null==(n=e.account)?void 0:n.label),S=sC(e.account_name,null==(o=e.account)?void 0:o.label,C),M=sC(e.account_email,null==(l=e.account)?void 0:l.email),L=sC(e.external_account_id,null==(s=e.account)||null==(a=s.rawIds)?void 0:a.externalAccountId,null==(c=e.account)||null==(i=c.rawIds)?void 0:i.providerAccountId),T=sC(e.account_stable_id,null==(d=e.account)?void 0:d.stableId);return{id:j,toolkit_slug:w,toolkit_name:sk(N,k),status:null!=(x=sC(e.status))?x:"UNKNOWN",created_at:null!=(m=sC(e.created_at,e.createdAt))?m:"",updated_at:null!=(f=sC(e.updated_at,e.updatedAt))?f:null,account_label:null!=C?C:null,account_name:null!=S?S:null,account_email:null!=M?M:null,external_account_id:null!=L?L:null,account_stable_id:null!=T?T:null,toolkit:{slug:w,name:sk(sC(null==(u=e.toolkit)?void 0:u.name,N),k)},account:e.account?{...e.account,stableId:null!=T?T:null,confidence:null!=(v=e.account.confidence)?v:void 0,label:null!=C?C:null,email:null!=M?M:null}:void 0,reconnect:e.reconnect?{claim:null!=(g=e.reconnect.claim)?g:"unknown",confidence:null!=(y=e.reconnect.confidence)?y:"unknown",relatedConnectionIds:null!=(b=e.reconnect.relatedConnectionIds)?b:[]}:void 0}}function sI(e){var t,r,n,o,l,a,s;let i="string"==typeof(s=e.status)&&s.trim()?s.trim().toUpperCase():"UNKNOWN",c=function(e){var t,r,n;let o=sC(e.account_stable_id,null==(t=e.account)?void 0:t.stableId);if(o)return{value:o,source:"gateway_stable_id",confidence:null!=(n=null==(r=e.account)?void 0:r.confidence)?n:"high"};let l=[e.external_account_id,e.account_email,e.account_name,e.account_label].find(e=>"string"==typeof e&&e.trim());return l?{value:"".concat(sj(e.toolkit_slug),":").concat(l.trim().toLowerCase()),source:"legacy_heuristic",confidence:e.external_account_id?"high":"low"}:{value:"".concat(sj(e.toolkit_slug),":").concat(e.id),source:"connection_id",confidence:"unknown"}}(e),d=null!=(o=null==(t=e.reconnect)?void 0:t.claim)?o:"unknown",u=null!=(l=null==(r=e.reconnect)?void 0:r.confidence)?l:"unknown",p=null!=(a=null==(n=e.reconnect)?void 0:n.relatedConnectionIds)?a:[];return{...e,normalized_toolkit_slug:sj(e.toolkit_slug),normalized_status:i,is_active:"ACTIVE"===i,account_identity:c.value,account_identity_source:c.source,identity_confidence:c.confidence,display_label:function(e){let t=[e.account_label,e.account_name,e.account_email].find(e=>"string"==typeof e&&e.trim());return t||"Connection ".concat(e.id.slice(-6))}(e),reconnect_claim:d,reconnect_confidence:u,related_connection_ids:p,is_same_account_reconnect:"same"===d&&"high"===u}}function sR(e){let t=Date.parse(e.created_at);return Number.isFinite(t)?t:0}function s_(e,t){if(e.is_active!==t.is_active)return e.is_active?-1:1;let r=sR(t)-sR(e);return 0!==r?r:e.display_label.localeCompare(t.display_label)}function sE(e){return e.map(sI).sort(s_)}let sD=new Map;function sA(e){return"string"==typeof e&&e.trim().length>0?e.trim():null}function sW(e,t,r){var n,o;let l=sj(t),a=null!=(n=null==r?void 0:r.trim().toLowerCase())?n:"";return null!=(o=e.find(e=>sj(e.slug)===l||a.length>0&&e.name.trim().toLowerCase()===a))?o:null}async function sB(e){var t,r;let n=new URLSearchParams({search:e.query,limit:"24"}),o=await fetch("/api/composio/toolkits?".concat(n.toString()));if(!o.ok)return null;let l=sW(sM(await o.json()).items,null!=(r=null!=(t=e.toolkitSlug)?t:e.toolkitName)?r:"",e.toolkitName);return l?{logo:sA(l.logo),name:l.name}:null}async function sF(e){var t,r,n,o;let l=(null==(t=e.toolkitSlug)?void 0:t.trim())?"slug:".concat(sj(e.toolkitSlug)):(null==(r=e.toolkitName)?void 0:r.trim())?"name:".concat(e.toolkitName.trim().toLowerCase()):null,a=function(e){let t=new Set,r=[];for(let n of e){if("string"!=typeof n||0===n.trim().length)continue;let e=n.trim(),o=e.toLowerCase();t.has(o)||(t.add(o),r.push(e))}return r}([null!=(o=e.toolkitName)?o:null,...(null==(n=e.toolkitSlug)?void 0:n.trim())?function(e){var t;let r=sj(e);return null!=(t=sy[r])?t:[r]}(e.toolkitSlug):[]]);if(!l||0===a.length)return null;let s=Date.now(),i=sD.get(l);if(i&&i.expiresAt>s)return"value"in i?i.value:i.promise;let c=(async()=>{for(let t of a){let r=await sB({query:t,toolkitSlug:e.toolkitSlug,toolkitName:e.toolkitName});if(r)return r}return null})();sD.set(l,{expiresAt:s+3e5,promise:c});try{let e=await c;return sD.set(l,{expiresAt:Date.now()+3e5,value:e}),e}catch(e){throw sD.delete(l),e}}function sP(e){var t,r;let n=sA(e.initialLogo),l=null!=(r=null==(t=e.toolkitName)?void 0:t.trim())?r:null,[a,s]=(0,o.useState)({logo:n,name:l});return(0,o.useEffect)(()=>{s({logo:n,name:l})},[n,l]),(0,o.useEffect)(()=>{var t,r;if(n||!(null==(t=e.toolkitSlug)?void 0:t.trim())&&!(null==(r=e.toolkitName)?void 0:r.trim()))return;let o=!1;return sF({toolkitSlug:e.toolkitSlug,toolkitName:e.toolkitName}).then(e=>{!o&&e&&s(t=>{var r,n;return{logo:null!=(r=t.logo)?r:e.logo,name:null!=(n=t.name)?n:e.name}})}).catch(()=>{}),()=>{o=!0}},[n,e.toolkitName,e.toolkitSlug]),a}let sz=(0,nX.default)(()=>r.e(5477).then(r.bind(r,45477)).then(e=>({default:e.ReportCard})),{loadableGenerated:{webpack:()=>[45477]},ssr:!1,loading:()=>(0,n.jsx)("div",{className:"h-48 rounded-2xl animate-pulse",style:{background:"var(--color-surface-hover)"}})}),sO="NO_REPLY";function sU(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return"output-error"===e||"error"===e?"error":"output-available"!==e||t?"running":"done"}function sH(e){if(e&&"object"==typeof e&&!Array.isArray(e))return e}function sV(e){var t;let r=e.match(/\[Attached files: (.+?)\]/);if(!r)return null;let n=(null!=(t=r.index)?t:0)+r[0].length,o=e.slice(n).trim();return{paths:r[1].split(", ").map(e=>e.trim()).filter(Boolean),message:o}}async function sK(e){var t;if("undefined"!=typeof navigator&&(null==(t=navigator.clipboard)?void 0:t.writeText))return void await navigator.clipboard.writeText(e);if("undefined"==typeof document)throw Error("Clipboard is unavailable");let r=document.createElement("textarea");r.value=e,r.setAttribute("readonly","true"),r.style.position="fixed",r.style.opacity="0",document.body.appendChild(r),r.focus(),r.select();let n=document.execCommand("copy");if(document.body.removeChild(r),!n)throw Error("Clipboard copy failed")}function sJ(e){let{paths:t}=e,[r,l]=(0,o.useState)(null);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"flex flex-wrap gap-1.5 mb-2 justify-end",children:t.map((e,t)=>{var r,o,a;let s=function(e){var t,r;let n=null!=(r=null==(t=e.split(".").pop())?void 0:t.toLowerCase())?r:"";return["jpg","jpeg","png","gif","webp","svg","bmp","ico","tiff","heic"].includes(n)?"image":["mp4","webm","mov","avi","mkv","flv"].includes(n)?"video":["mp3","wav","ogg","aac","flac","m4a"].includes(n)?"audio":"pdf"===n?"pdf":["js","ts","tsx","jsx","py","rb","go","rs","java","cpp","c","h","css","html","json","yaml","yml","toml","md","sh","bash","sql","swift","kt"].includes(n)?"code":["doc","docx","xls","xlsx","ppt","pptx","txt","rtf","csv","pages","numbers","key"].includes(n)?"document":"other"}(e),i="image"===s?"/api/workspace/raw-file?path=".concat(encodeURIComponent(e)):"/api/workspace/thumbnail?path=".concat(encodeURIComponent(e),"&size=200"),c=null!=(o=null==(r=e.split(".").pop())?void 0:r.toUpperCase())?o:"";return(0,n.jsxs)("div",{className:"relative rounded-xl overflow-hidden shrink-0 cursor-pointer transition-all duration-200 hover:opacity-95",onClick:()=>l(i),children:[(0,n.jsx)("img",{src:i,alt:null!=(a=e.split("/").pop())?a:"",className:"block rounded-xl object-cover",style:{maxHeight:140,maxWidth:160,background:"rgba(0,0,0,0.04)"},loading:"lazy",onError:e=>{e.currentTarget.style.display="none"}}),"image"!==s&&(0,n.jsx)("span",{className:"absolute bottom-2 left-2 rounded-md px-1.5 py-0.5 text-[10px] font-bold uppercase",style:{background:"rgba(255,255,255,0.85)",color:"rgba(0,0,0,0.5)",backdropFilter:"blur(4px)"},children:c})]},t)})}),(0,n.jsx)(e_,{open:null!==r,onOpenChange:e=>{e||l(null)},children:(0,n.jsxs)(eA,{className:"!max-w-[90vw] !w-auto !p-0 !rounded-2xl !bg-transparent !border-none !shadow-[0_0_120px_rgba(0,0,0,0.4)]",showCloseButton:!1,children:[(0,n.jsx)("button",{type:"button",onClick:()=>l(null),className:"absolute top-3 right-3 z-10 w-7 h-7 rounded-full flex items-center justify-center cursor-pointer outline-none transition-all hover:opacity-85",style:{background:"rgba(0,0,0,0.55)",color:"white",backdropFilter:"blur(4px)",boxShadow:"0 2px 8px rgba(0,0,0,0.3)"},children:(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:[(0,n.jsx)("path",{d:"M18 6 6 18"}),(0,n.jsx)("path",{d:"m6 6 12 12"})]})}),r&&(0,n.jsx)("img",{src:r,alt:"Preview",className:"block rounded-xl",style:{maxHeight:"80vh",maxWidth:"85vw",objectFit:"contain"}})]})})]})}function sq(e){let t=e.trim();if(!t||t.length<3||t.length>500)return!1;if(t.startsWith("~/")||t.startsWith("/")||t.startsWith("./")||t.startsWith("../")){let e=t.startsWith("~/")?t.slice(2):t.startsWith("../")?t.slice(3):t.startsWith("./")?t.slice(2):t.slice(1);return e.includes("/")||e.includes(".")}return!(!/\.(pdf|docx?|xlsx?|pptx?|csv|txt|rtf|pages|numbers|key|md|json|yaml|yml|toml|xml|html?|css|jsx?|tsx?|py|rb|go|rs|java|cpp|c|h|sh|sql|swift|kt|png|jpe?g|gif|webp|svg|bmp|ico|heic|tiff|mp[34]|webm|mov|avi|mkv|flv|wav|ogg|aac|flac|m4a|zip|tar|gz|dmg)$/i.test(t)||t.includes(" "))}async function sG(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];try{let r=await fetch("/api/workspace/open-file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e,reveal:t})});if(!r.ok){let e=await r.json().catch(()=>({}));console.error("Failed to open file:",e)}}catch(e){console.error("Failed to open file:",e)}}function s$(e){let t=e.trim();if(!t.startsWith("file://"))return t;try{let e=new URL(t);if("file:"!==e.protocol)return t;let r=decodeURIComponent(e.pathname);if(/^\/[A-Za-z]:\//.test(r))return r.slice(1);return r}catch(e){return t}}function sZ(e){let{path:t,children:r,onFilePathClick:l}=e,[a,s]=(0,o.useState)("idle"),i=async e=>{e.preventDefault(),s("opening");try{if(l){let e=await l(t);if(!1===e){s("error"),setTimeout(()=>s("idle"),2e3);return}s("idle")}else(await fetch("/api/workspace/open-file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t})})).ok?s("idle"):(s("error"),setTimeout(()=>s("idle"),2e3))}catch(e){s("error"),setTimeout(()=>s("idle"),2e3)}},c=async e=>{e.preventDefault(),await sG(t,!0)};return(0,n.jsx)("code",{className:"px-[0.3em] no-underline transition-colors duration-150 rounded-[4px] border border-[color:var(--color-border)] bg-white/20 hover:bg-white/40 active:bg-white ".concat("opening"===a?"cursor-wait opacity-70":"cursor-pointer"),style:{color:"var(--color-accent)"},onClick:i,onContextMenu:c,title:"error"===a?"File not found":l?"Click to preview in workspace \xb7 Right-click to reveal in Finder":"Click to open \xb7 Right-click to reveal in Finder",children:r})}function sY(e){let{src:t,alt:r,...l}=e,[a,s]=(0,o.useState)(!1);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("img",{src:t,alt:null!=r?r:"",loading:"lazy",className:"cursor-pointer transition-all duration-200 hover:opacity-95",onClick:()=>s(!0),...l}),(0,n.jsx)(e_,{open:a,onOpenChange:s,children:(0,n.jsxs)(eA,{className:"!max-w-[90vw] !w-auto !p-0 !rounded-2xl !bg-transparent !border-none !shadow-[0_0_120px_rgba(0,0,0,0.4)]",showCloseButton:!1,children:[(0,n.jsx)("button",{type:"button",onClick:()=>s(!1),className:"absolute top-3 right-3 z-10 w-7 h-7 rounded-full flex items-center justify-center cursor-pointer outline-none transition-all hover:opacity-85",style:{background:"rgba(0,0,0,0.55)",color:"white",backdropFilter:"blur(4px)",boxShadow:"0 2px 8px rgba(0,0,0,0.3)"},children:(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:[(0,n.jsx)("path",{d:"M18 6 6 18"}),(0,n.jsx)("path",{d:"m6 6 12 12"})]})}),t&&(0,n.jsx)("img",{src:t,alt:null!=r?r:"Preview",className:"block rounded-xl",style:{maxHeight:"80vh",maxWidth:"85vw",objectFit:"contain"}})]})})]})}function sQ(e){var t,r,o,l,a;let{action:s,children:i,onPress:c}=e,d=sP({toolkitSlug:null!=(l=s.toolkitSlug)?l:null,toolkitName:null!=(a=s.toolkitName)?a:null}),u=(null==(t=d.name)?void 0:t.trim())||(null==(r=s.toolkitName)?void 0:r.trim())||(null==(o=s.toolkitSlug)?void 0:o.trim().replace(/-/g," "))||"app",p=d.logo,h=u.split(/\s+/).filter(Boolean).slice(0,2).map(e=>e.charAt(0)).join("").toUpperCase()||"AP",x="connect"===s.action;return(0,n.jsxs)("button",{type:"button",className:"not-prose my-1 inline-flex items-center gap-1.5 rounded-lg px-1 py-0.5 pr-2.5 text-xs font-semibold whitespace-nowrap transition-colors",style:{background:"color-mix(in srgb, var(--color-accent) 10%, transparent)",color:"var(--color-accent)",border:"none"},onMouseEnter:e=>{e.currentTarget.style.background="color-mix(in srgb, var(--color-accent) 15%, transparent)"},onMouseLeave:e=>{e.currentTarget.style.background="color-mix(in srgb, var(--color-accent) 10%, transparent)"},onClick:()=>null==c?void 0:c(s),children:[(0,n.jsx)("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center overflow-hidden rounded","aria-hidden":"true",style:x?{background:"rgba(255, 255, 255, 0.16)",color:"#fff"}:{background:"var(--color-surface-hover)",color:"var(--color-text-muted)"},children:p?(0,n.jsx)("img",{src:p,alt:"",className:"h-4 w-4 object-contain",loading:"lazy",decoding:"async"}):(0,n.jsx)("span",{className:"text-[10px] font-bold uppercase",children:h})}),(0,n.jsx)("span",{className:"leading-none",children:i})]})}let sX="phc_Nt8s1Ny8062TY9aKT8LWiB4nBuoHNYQXRU9MypWfQCW";function s0(e){let{messageId:t,sessionId:r}=e,l=(0,o.useCallback)((e,t)=>{var r;e&&fetch("/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:e,messageId:t,distinctId:null==(r=aS.Ay.get_distinct_id)?void 0:r.call(aS.Ay)})}).catch(()=>{})},[]),{respond:a,response:s,triggerRef:i}=(0,aM.y)({surveyId:"019cc021-a8bf-0000-d41d-b82956ef7e6a",properties:{$ai_trace_id:r,message_id:t},onResponse:()=>l(r,t)}),c="p-1 rounded-md transition-colors";return(0,n.jsxs)("div",{ref:i,className:"flex items-center gap-0.5",children:[(0,n.jsx)("button",{type:"button",onClick:()=>a("up"),className:c,style:{color:"up"===s?"var(--color-accent)":"var(--color-text-muted)"},title:"Good response","aria-label":"Thumbs up",children:(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"up"===s?"currentColor":"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M7 10v12"}),(0,n.jsx)("path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z"})]})}),(0,n.jsx)("button",{type:"button",onClick:()=>a("down"),className:c,style:{color:"down"===s?"var(--color-error, #ef4444)":"var(--color-text-muted)"},title:"Bad response","aria-label":"Thumbs down",children:(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"down"===s?"currentColor":"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M17 14V2"}),(0,n.jsx)("path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z"})]})})]})}function s1(e){let{text:t}=e,[r,l]=(0,o.useState)(!1),a=(0,o.useRef)(null);(0,o.useEffect)(()=>()=>{null!==a.current&&window.clearTimeout(a.current)},[]);let s=(0,o.useCallback)(async()=>{try{await sK(t),l(!0),null!==a.current&&window.clearTimeout(a.current),a.current=window.setTimeout(()=>{l(!1),a.current=null},1500)}catch(e){l(!1)}},[t]);return(0,n.jsx)("button",{type:"button",onClick:()=>{s()},className:"p-1 rounded-md transition-colors",style:{color:r?"var(--color-accent)":"var(--color-text-muted)"},title:r?"Copied":"Copy message","aria-label":r?"Copied":"Copy message",children:r?(0,n.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"m20 6-11 11-5-5"})}):(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),(0,n.jsx)("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})})}let s2=(0,o.memo)(function(e){let{message:t,isStreaming:r,onSubagentClick:l,onFilePathClick:a,onComposioAction:s,sessionId:i,voicePlaybackEnabled:c=!1,userHtmlMap:d,copyable:u=!1}=e,p="user"===t.role,h=(0,o.useMemo)(()=>(function(e){let t=[],r=[],n=e=>{if(r.length>0){if(e)for(let e of r)"tool"===e.kind&&"running"===e.status&&(e.status="done");t.push({type:"chain",parts:[...r]}),r=[]}};for(let p of e)if("text"===p.type){let e=p.text;if(function(e){let t=e.trim();return!!t&&!!(new RegExp("^".concat(sO,"\\W*$")).test(t)||sO.startsWith(t)&&t.length>=2&&t.length<sO.length)}(e))continue;if(n(!0),n1(e))t.push(...n0(e));else if(n4(e))for(let r of n2(e))"diff-artifact"===r.type?t.push({type:"diff-artifact",diff:r.diff}):t.push({type:"text",text:r.text});else t.push({type:"text",text:e})}else if("reasoning"===p.type)sd(p.text)||r.push({kind:"reasoning",text:p.text,isStreaming:"streaming"===p.state});else if("dynamic-tool"===p.type)if("sessions_spawn"===p.toolName){n(!0);let e=sH(p.input),r=sH(p.output),o="string"==typeof(null==e?void 0:e.task)?e.task:"Subagent task",l="string"==typeof(null==e?void 0:e.label)?e.label:void 0,a="string"==typeof(null==r?void 0:r.sessionKey)?r.sessionKey:void 0;t.push({type:"subagent-card",task:o,label:l,sessionKey:a,status:sU(p.state,!0===p.preliminary)})}else{let e=sH(p.output),t=sU(p.state,!0===p.preliminary);r.push({kind:"tool",toolName:p.toolName,toolCallId:p.toolCallId,status:t,args:sH(p.input),output:e,errorText:"error"===t&&"string"==typeof(null==e?void 0:e.error)?e.error:void 0})}else if(p.type.startsWith("tool-")){var o,l,a,s,i,c,d,u;let e=null!=(l=null!=(o=p.title)?o:p.toolName)?l:p.type.replace("tool-","");if("sessions_spawn"===e){n(!0);let e=null!=(a=sH(p.input))?a:sH(p.args),r=null!=(s=sH(p.output))?s:sH(p.result),o="string"==typeof(null==e?void 0:e.task)?e.task:"Subagent task",l="string"==typeof(null==e?void 0:e.label)?e.label:void 0,c="string"==typeof(null==r?void 0:r.sessionKey)?r.sessionKey:void 0,d=null!=(i=p.state)?i:p.errorText?"output-error":"result"in p||"output"in p?"output-available":"input-available";t.push({type:"subagent-card",task:o,label:l,sessionKey:c,status:sU(d,!0===p.preliminary)})}else{let t=null!=(c=p.state)?c:p.errorText?"output-error":"result"in p||"output"in p?"output-available":"input-available";r.push({kind:"tool",toolName:e,toolCallId:p.toolCallId,status:sU(t,!0===p.preliminary),args:null!=(d=sH(p.input))?d:sH(p.args),output:null!=(u=sH(p.output))?u:sH(p.result),errorText:p.errorText})}}return n(),t})(t.parts),[t.parts]),x=(0,o.useMemo)(()=>h.filter(e=>"text"===e.type).map(e=>e.text).join("\n\n").replace(/```[\s\S]*?```/g," Code block omitted. ").replace(/`([^`]+)`/g,"$1").replace(/\[([^\]]+)\]\(([^)]+)\)/g,"$1").replace(/^#{1,6}\s+/gm,"").replace(/[*_~]/g,"").replace(/\n{3,}/g,"\n\n").replace(/\s+/g," ").trim(),[h]),m=(0,o.useMemo)(()=>(function(e,t){if("user"===e){let e=t.filter(e=>"text"===e.type).map(e=>e.text).join("\n").trim(),r=sV(e);return r?[r.message,r.paths.length>0?"Attached files:\n".concat(r.paths.join("\n")):""].filter(Boolean).join("\n\n").trim():e}return t.map(e=>{switch(e.type){case"text":return e.text.trim();case"diff-artifact":return e.diff.trim();case"subagent-card":return(e.label||e.task).trim();default:return""}}).filter(Boolean).join("\n\n").trim()})(t.role,h),[t.role,h]),f=u&&!!m,v=(0,o.useMemo)(()=>({a:e=>{let{href:t,children:r,...o}=e,l="string"==typeof t?t:"",i=sv(l),c=s$(l),d=l&&(l.startsWith("http://")||l.startsWith("https://")||l.startsWith("//")),u=!(l.startsWith("/workspace")||l.startsWith("/?"))&&(!!l.startsWith("file://")||sq(c));return i?(0,n.jsx)(sQ,{action:i,onPress:s,children:r}):(0,n.jsx)("a",{href:t,...d?{target:"_blank",rel:"noopener noreferrer"}:{},...o,onClick:e=>{u&&a&&(e.preventDefault(),a(c))},children:r})},img:e=>{let{src:t,alt:r,...o}=e,l="string"!=typeof t||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("data:")?t:"/api/workspace/raw-file?path=".concat(encodeURIComponent(t));return(0,n.jsx)(sY,{src:l,alt:null!=r?r:"",...o})},pre:e=>{let{children:t,...r}=e,o=Array.isArray(t)?t[0]:t;if(o&&"object"==typeof o&&"type"in o&&"code"===o.type){var l,a,s,i;let e=(null!=(s=null==(l=o.props)?void 0:l.className)?s:"").match(/language-(\w+)/),t=null!=(i=null==e?void 0:e[1])?i:"",r="string"==typeof(null==(a=o.props)?void 0:a.children)?o.props.children.replace(/\n$/,""):"";if("diff"===t)return(0,n.jsx)(n8,{diff:r});if(t)return(0,n.jsxs)("div",{className:"chat-code-block",children:[(0,n.jsx)("div",{className:"chat-code-lang",children:t}),(0,n.jsx)(sm,{code:r,lang:t})]})}return(0,n.jsx)("pre",{...r,children:t})},code:e=>{let{children:t,className:r,...o}=e;if(null==r?void 0:r.startsWith("language-"))return(0,n.jsx)("code",{className:r,...o,children:t});let l=s$("string"==typeof t?t:"");return l&&sq(l)?(0,n.jsx)(sZ,{path:l,onFilePathClick:a,children:t}):(0,n.jsx)("code",{...o,children:t})},strong:e=>{let{children:t,...r}=e,o="string"==typeof t?t:Array.isArray(t)?t.filter(e=>"string"==typeof e).join(""):"";return o&&function(e){let t=e.trim();return!!t&&!(t.length<3)&&!(t.length>300)&&/\.(pdf|docx?|xlsx?|pptx?|csv|txt|rtf|pages|numbers|key|md|json|yaml|yml|toml|xml|html?|css|jsx?|tsx?|py|rb|go|rs|java|cpp|c|h|sh|sql|swift|kt|png|jpe?g|gif|webp|svg|bmp|ico|heic|tiff|mp[34]|webm|mov|avi|mkv|flv|wav|ogg|aac|flac|m4a|zip|tar|gz|dmg)$/i.test(t)}(o)?(0,n.jsx)("strong",{...r,children:(0,n.jsx)(sZ,{path:o,onFilePathClick:a,children:t})}):(0,n.jsx)("strong",{...r,children:t})}}),[s,a]);if(p){var g,y,b,j;let e=h.filter(e=>"text"===e.type).map(e=>e.text).join("\n"),r=sV(e),o=null!=(b=null!=(g=null==d?void 0:d.get(t.id))?g:null==d?void 0:d.get(e))?b:null==d?void 0:d.get(null!=(y=null==r?void 0:r.message)?y:""),l=o?(0,n.jsx)("div",{className:"chat-user-html-content",dangerouslySetInnerHTML:{__html:o}}):(0,n.jsx)("p",{className:"whitespace-pre-wrap break-words",children:null!=(j=null==r?void 0:r.message)?j:e});return r?(0,n.jsxs)("div",{className:"flex flex-col items-end gap-1.5 py-2 group",children:[(0,n.jsx)(sJ,{paths:r.paths}),(r.message||o)&&(0,n.jsx)("div",{className:"max-w-[80%] w-fit rounded-2xl rounded-br-sm px-3 py-2 text-sm leading-6 break-words chat-message-font",style:{background:"var(--color-user-bubble)",color:"var(--color-user-bubble-text)"},children:l}),f&&(0,n.jsx)("div",{className:"flex items-center gap-1 self-end md:opacity-0 md:group-hover:opacity-100 transition-opacity",children:(0,n.jsx)(s1,{text:m})})]}):(0,n.jsxs)("div",{className:"flex flex-col items-end gap-1 py-2 group",children:[(0,n.jsx)("div",{className:"max-w-[80%] min-w-0 rounded-2xl rounded-br-sm px-3 py-2 text-sm leading-6 overflow-hidden break-words chat-message-font",style:{background:"var(--color-user-bubble)",color:"var(--color-user-bubble-text)"},children:l}),f&&(0,n.jsx)("div",{className:"flex items-center gap-1 md:opacity-0 md:group-hover:opacity-100 transition-opacity",children:(0,n.jsx)(s1,{text:m})})]})}return(0,n.jsxs)("div",{className:"py-3 space-y-2 min-w-0 overflow-hidden group",children:[(0,n.jsx)(aL.N,{initial:!1,children:h.map((e,t)=>{if("text"===e.type){let r=e.text.match(/^\[error\]\s*([\s\S]*)$/);return r?(0,n.jsxs)("div",{className:"chat-message-font flex items-start gap-2 rounded-xl px-3 py-2 text-[13px] leading-relaxed overflow-hidden",style:{background:"color-mix(in srgb, var(--color-error) 6%, var(--color-surface))",color:"var(--color-error)",border:"1px solid color-mix(in srgb, var(--color-error) 18%, transparent)"},children:[(0,n.jsx)("span",{className:"flex-shrink-0 mt-0.5","aria-hidden":"true",children:(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,n.jsx)("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),(0,n.jsx)("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]})}),(0,n.jsx)("span",{className:"whitespace-pre-wrap break-all min-w-0",children:r[1].trim()})]},t):(0,n.jsx)(aT.P.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{duration:.2,ease:"easeOut"},className:"chat-prose chat-message-font text-sm",style:{color:"var(--color-text)"},children:(0,n.jsx)(aI.oz,{remarkPlugins:[aR.A],components:v,urlTransform:e=>sv(e)?e:(0,aI.Lv)(e),children:e.text})},"text-".concat(t))}if("report-artifact"===e.type)return(0,n.jsx)(aT.P.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{duration:.2,ease:"easeOut"},children:(0,n.jsx)(sz,{config:e.config})},"report-".concat(t));if("diff-artifact"===e.type)return(0,n.jsx)(aT.P.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{duration:.2,ease:"easeOut"},children:(0,n.jsx)(n8,{diff:e.diff})},"diff-".concat(t));if("subagent-card"===e.type){let r=e.task.length>80?e.task.slice(0,80)+"...":e.task,o="running"===e.status;return(0,n.jsx)(aT.P.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{duration:.2,ease:"easeOut"},children:(0,n.jsx)("button",{type:"button",onClick:()=>{var t;return null==l?void 0:l(null!=(t=e.sessionKey)?t:e.task)},className:"w-full text-left rounded-xl px-3.5 py-2.5 transition-colors cursor-pointer",style:{background:"var(--color-accent-light)",border:"1px solid color-mix(in srgb, var(--color-accent) 20%, transparent)"},children:(0,n.jsxs)("div",{className:"flex items-center gap-2.5",children:[o?(0,n.jsx)("span",{className:"inline-block w-2 h-2 rounded-full animate-pulse flex-shrink-0",style:{background:"var(--color-accent)"}}):(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"flex-shrink-0",style:{color:"var(--color-accent)"},children:[(0,n.jsx)("path",{d:"M16 3h5v5"}),(0,n.jsx)("path",{d:"m21 3-7 7"}),(0,n.jsx)("path",{d:"M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6"})]}),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsx)("div",{className:"flex items-center gap-2",children:(0,n.jsx)("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--color-accent)"},children:o?"Running Subagent":"Subagent"})}),(0,n.jsx)("p",{className:"text-xs mt-0.5 leading-relaxed",style:{color:"var(--color-text)"},children:e.label||r})]}),(0,n.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"flex-shrink-0 opacity-40",style:{color:"var(--color-text)"},children:(0,n.jsx)("path",{d:"m9 18 6-6-6-6"})})]})})},"subagent-".concat(t))}return(0,n.jsx)(aT.P.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{duration:.2,ease:"easeOut"},children:(0,n.jsx)(aX,{parts:e.parts,isStreaming:r})},"chain-".concat(t))})}),!r&&(f||sX||c&&x)&&(0,n.jsxs)("div",{className:"flex items-center gap-1 mt-1 md:opacity-0 md:group-hover:opacity-100 transition-opacity",children:[f&&(0,n.jsx)(s1,{text:m}),c&&x&&(0,n.jsx)(sp,{text:x}),sX&&(0,n.jsx)(s0,{messageId:t.id,sessionId:i})]})]})});var s4=r(48997),s5=r(79534);let s3=new(r(63550)).hs("chatFileMention"),s6=s5.bP.create({name:"chatFileMention",group:"inline",inline:!0,atom:!0,selectable:!0,draggable:!0,addAttributes:()=>({label:{default:""},path:{default:""},mentionType:{default:"file"},objectName:{default:""}}),parseHTML:()=>[{tag:"span[data-chat-file-mention]"}],renderHTML(e){let{HTMLAttributes:t}=e,r=t.label||"file",n=function(e,t){var r,n;if("object"===t)return{bg:"rgba(14,165,233,0.15)",fg:"#0ea5e9"};if("entry"===t)return{bg:"rgba(34,197,94,0.15)",fg:"#22c55e"};let o=null!=(n=null==(r=e.split(".").pop())?void 0:r.toLowerCase())?n:"";return["jpg","jpeg","png","gif","webp","svg","bmp","ico","tiff","heic"].includes(o)?{bg:"rgba(16,185,129,0.15)",fg:"#10b981"}:["mp4","webm","mov","avi","mkv","flv"].includes(o)?{bg:"rgba(139,92,246,0.15)",fg:"#8b5cf6"}:["mp3","wav","ogg","aac","flac","m4a"].includes(o)?{bg:"rgba(245,158,11,0.15)",fg:"#f59e0b"}:"pdf"===o?{bg:"rgba(239,68,68,0.15)",fg:"#ef4444"}:["js","ts","tsx","jsx","py","rb","go","rs","java","cpp","c","h","css","html","json","yaml","yml","toml","md","sh","bash","sql","swift","kt"].includes(o)?{bg:"rgba(59,130,246,0.15)",fg:"#3b82f6"}:["doc","docx","xls","xlsx","ppt","pptx","txt","rtf","csv"].includes(o)?{bg:"rgba(107,114,128,0.15)",fg:"#6b7280"}:{bg:"rgba(107,114,128,0.10)",fg:"#9ca3af"}}(r,t.mentionType);return["span",(0,s5.KV)({"data-chat-file-mention":"",class:"chat-file-mention",style:"--mention-bg: ".concat(n.bg,"; --mention-fg: ").concat(n.fg,";"),title:t.path||""},t),r]}}),s8={folder:{bg:"rgba(245, 158, 11, 0.12)",fg:"#f59e0b"},image:{bg:"rgba(16, 185, 129, 0.12)",fg:"#10b981"},video:{bg:"rgba(139, 92, 246, 0.12)",fg:"#8b5cf6"},audio:{bg:"rgba(245, 158, 11, 0.12)",fg:"#f59e0b"},pdf:{bg:"rgba(239, 68, 68, 0.12)",fg:"#ef4444"},code:{bg:"rgba(59, 130, 246, 0.12)",fg:"#3b82f6"},document:{bg:"rgba(107, 114, 128, 0.12)",fg:"#6b7280"},database:{bg:"rgba(168, 85, 247, 0.12)",fg:"#a855f7"},object:{bg:"rgba(14, 165, 233, 0.12)",fg:"#0ea5e9"},entry:{bg:"rgba(34, 197, 94, 0.12)",fg:"#22c55e"},other:{bg:"rgba(107, 114, 128, 0.08)",fg:"#9ca3af"}};function s7(e){let{category:t}=e,r={width:12,height:12,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};switch(t){case"folder":return(0,n.jsx)("svg",{...r,children:(0,n.jsx)("path",{d:"M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z"})});case"image":return(0,n.jsxs)("svg",{...r,children:[(0,n.jsx)("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),(0,n.jsx)("circle",{cx:"9",cy:"9",r:"2"}),(0,n.jsx)("path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"})]});case"video":return(0,n.jsxs)("svg",{...r,children:[(0,n.jsx)("path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5"}),(0,n.jsx)("rect",{x:"2",y:"6",width:"14",height:"12",rx:"2"})]});case"audio":return(0,n.jsxs)("svg",{...r,children:[(0,n.jsx)("path",{d:"M9 18V5l12-2v13"}),(0,n.jsx)("circle",{cx:"6",cy:"18",r:"3"}),(0,n.jsx)("circle",{cx:"18",cy:"16",r:"3"})]});case"pdf":return(0,n.jsxs)("svg",{...r,children:[(0,n.jsx)("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),(0,n.jsx)("path",{d:"M14 2v6h6"}),(0,n.jsx)("path",{d:"M10 13h4"}),(0,n.jsx)("path",{d:"M10 17h4"})]});case"code":return(0,n.jsxs)("svg",{...r,children:[(0,n.jsx)("polyline",{points:"16 18 22 12 16 6"}),(0,n.jsx)("polyline",{points:"8 6 2 12 8 18"})]});case"database":return(0,n.jsxs)("svg",{...r,children:[(0,n.jsx)("ellipse",{cx:"12",cy:"5",rx:"9",ry:"3"}),(0,n.jsx)("path",{d:"M3 5V19A9 3 0 0 0 21 19V5"}),(0,n.jsx)("path",{d:"M3 12A9 3 0 0 0 21 12"})]});case"object":return(0,n.jsxs)("svg",{...r,children:[(0,n.jsx)("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),(0,n.jsx)("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),(0,n.jsx)("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"}),(0,n.jsx)("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1"})]});case"entry":return(0,n.jsxs)("svg",{...r,children:[(0,n.jsx)("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),(0,n.jsx)("circle",{cx:"9",cy:"7",r:"4"}),(0,n.jsx)("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),(0,n.jsx)("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]});default:return(0,n.jsxs)("svg",{...r,children:[(0,n.jsx)("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),(0,n.jsx)("path",{d:"M14 2v6h6"})]})}}let s9=(0,o.forwardRef)((e,t)=>{let{items:r,command:l,loading:a}=e,[s,i]=(0,o.useState)(0),c=(0,o.useRef)(null);(0,o.useEffect)(()=>{i(0)},[r]),(0,o.useEffect)(()=>{var e;let t=null==(e=c.current)?void 0:e.children[s];null==t||t.scrollIntoView({block:"nearest"})},[s]);let d=(0,o.useCallback)(e=>{let t=r[e];t&&l(t)},[r,l]);return((0,o.useImperativeHandle)(t,()=>({onKeyDown:e=>{let{event:t}=e;return"ArrowUp"===t.key?(i(e=>(e+r.length-1)%r.length),!0):"ArrowDown"===t.key?(i(e=>(e+1)%r.length),!0):("Enter"===t.key||"Tab"===t.key)&&(d(s),!0)}})),a)?(0,n.jsx)("div",{className:"rounded-xl py-3 px-4 shadow-xl",style:{background:"var(--color-surface)",border:"1px solid var(--color-border)",backdropFilter:"blur(12px)",minWidth:260},children:(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("div",{className:"w-3.5 h-3.5 border-2 rounded-full animate-spin",style:{borderColor:"var(--color-border)",borderTopColor:"var(--color-accent)"}}),(0,n.jsx)("span",{className:"text-[12px]",style:{color:"var(--color-text-muted)"},children:"Searching..."})]})}):0===r.length?(0,n.jsx)("div",{className:"rounded-xl py-3 px-4 shadow-xl",style:{background:"var(--color-surface)",border:"1px solid var(--color-border)",backdropFilter:"blur(12px)",minWidth:260},children:(0,n.jsx)("span",{className:"text-[12px]",style:{color:"var(--color-text-muted)"},children:"No results found"})}):(0,n.jsx)("div",{ref:c,className:"rounded-xl py-1 shadow-xl overflow-y-auto",style:{background:"var(--color-surface)",border:"1px solid var(--color-border)",backdropFilter:"blur(12px)",minWidth:280,maxWidth:400,maxHeight:300},children:r.map((e,t)=>{var r;let o=function(e,t){var r,n;if("folder"===t)return"folder";if("database"===t)return"database";if("object"===t)return"object";if("entry"===t)return"entry";let o=null!=(n=null==(r=e.split(".").pop())?void 0:r.toLowerCase())?n:"";return["jpg","jpeg","png","gif","webp","svg","bmp","ico","tiff","heic"].includes(o)?"image":["mp4","webm","mov","avi","mkv","flv"].includes(o)?"video":["mp3","wav","ogg","aac","flac","m4a"].includes(o)?"audio":"pdf"===o?"pdf":["js","ts","tsx","jsx","py","rb","go","rs","java","cpp","c","h","css","html","json","yaml","yml","toml","md","sh","bash","sql","swift","kt"].includes(o)?"code":"document"===t?"document":"other"}(e.name,e.type),l=null!=(r=s8[o])?r:s8.other,a=e.icon&&RegExp("\\p{Emoji_Presentation}","u").test(e.icon),c="object"===e.type||"entry"===e.type,u="entry"===e.type&&e.objectName?e.objectName:c?e.type:e.path.replace(/^\/Users\/[^/]+/,"~").replace(/^\/home\/[^/]+/,"~").replace(/^[A-Z]:\\Users\\[^\\]+/,"~");return(0,n.jsxs)("button",{type:"button",className:"w-full flex items-center gap-2.5 px-3 py-1.5 text-left transition-colors",style:{background:t===s?"var(--color-surface-hover)":"transparent"},onClick:()=>d(t),onMouseEnter:()=>i(t),children:[(0,n.jsx)("div",{className:"w-6 h-6 rounded-md flex items-center justify-center flex-shrink-0",style:{background:l.bg,color:l.fg},children:a?(0,n.jsx)("span",{className:"text-[13px] leading-none",children:e.icon}):(0,n.jsx)(s7,{category:o})}),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsx)("div",{className:"text-[12px] font-medium truncate",style:{color:"var(--color-text)"},children:e.name}),(0,n.jsxs)("div",{className:"text-[10px] truncate flex items-center gap-1",style:{color:"var(--color-text-muted)"},title:c?u:e.path,children:[c&&(0,n.jsx)("span",{className:"inline-block rounded px-1 py-px text-[9px] font-medium leading-tight",style:{background:l.bg,color:l.fg},children:e.type}),u]})]}),"folder"===e.type&&(0,n.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"flex-shrink-0 opacity-40",children:(0,n.jsx)("path",{d:"m9 18 6-6-6-6"})})]},e.path)})})});function ie(e){let{items:t,command:r,clientRect:l,componentRef:a,loading:s}=e,i=(0,o.useRef)(null);return(0,o.useLayoutEffect)(()=>{if(!i.current||!l)return;let e=l();if(!e)return;let t=i.current,r=t.offsetHeight||200;window.innerHeight-e.bottom<r+8?(t.style.position="fixed",t.style.left="".concat(e.left,"px"),t.style.bottom="".concat(window.innerHeight-e.top+4,"px"),t.style.top="auto"):(t.style.position="fixed",t.style.left="".concat(e.left,"px"),t.style.top="".concat(e.bottom+4,"px"),t.style.bottom="auto"),t.style.zIndex="100"},[l,t,s]),(0,tD.createPortal)((0,n.jsx)("div",{ref:i,children:(0,n.jsx)(s9,{ref:a,items:t,command:r,loading:s})}),document.body)}function it(e){if(!e)return{text:"",mentionedFiles:[]};let t=[],r=[];return e.state.doc.forEach(e=>{if("paragraph"===e.type.name||"hardBreak"===e.type.name){let n="";e.descendants(e=>{if("chatFileMention"===e.type.name){let r=e.attrs.label,o=e.attrs.path,l=e.attrs.mentionType,a=e.attrs.objectName;return t.push({name:r,path:o}),"object"===l?n+="[object: ".concat(r,"]"):"entry"===l?n+="[entry: ".concat(a?"".concat(a,"/"):"").concat(r,"]"):n+="[file: ".concat(o,"]"),!1}return e.isText&&e.text&&(n+=e.text),"hardBreak"===e.type.name&&(n+="\n"),!0}),r.push(n)}}),{text:r.join("\n").trim(),mentionedFiles:t}}s9.displayName="FileMentionList";let ir=(0,o.forwardRef)(function(e,t){let{onSubmit:l,onChange:a,onNativeFileDrop:s,placeholder:i,disabled:c,compact:d}=e,u=(0,o.useRef)(l);u.current=l;let p=(0,o.useRef)(s);p.current=s;let h=(0,o.useRef)(null),x=(0,ld.hG)({immediatelyRender:!1,extensions:[lp.A.configure({heading:!1,codeBlock:!1,blockquote:!1,horizontalRule:!1,bulletList:!1,orderedList:!1,listItem:!1}),lj.A.configure({placeholder:null!=i?i:"Ask anything...",showOnlyWhenEditable:!1}),s6,s5.YY.create({name:"chatFileMentionSuggestion",addProseMirrorPlugins(){return[(0,s4.Ay)({editor:this.editor,char:"@",pluginKey:s3,startOfLine:!1,allowSpaces:!0,command:e=>{var t;let{editor:r,range:n,props:o}=e;if("folder"===o.type){let e=o.path.replace(/^\/Users\/[^/]+/,"~").replace(/^\/home\/[^/]+/,"~").replace(/^[A-Z]:\\Users\\[^\\]+/,"~");r.chain().focus().deleteRange(n).insertContent("@".concat(e,"/")).run();return}let l="object"===o.type?"object":"entry"===o.type?"entry":"file";r.chain().focus().deleteRange(n).insertContent([{type:"chatFileMention",attrs:{label:o.name,path:o.path,mentionType:l,objectName:null!=(t=o.objectName)?t:""}},{type:"text",text:" "}]).run()},items:e=>{let{query:t}=e;return[]},render:()=>{let e=null,t=null,o={current:null},l="",a=[],s=!1,i=null,c=null,d=null;function u(){t&&c&&t.render((0,n.jsx)(ie,{items:a,command:c,clientRect:d,componentRef:o,loading:s}))}async function p(e){s=!0,u();try{var t;let r=e.startsWith("/")||e.startsWith("~/")||e.startsWith("../")||e.startsWith("./")||e.includes("/")?"path=".concat(encodeURIComponent(e)):e?"q=".concat(encodeURIComponent(e)):"",n=await fetch("/api/workspace/suggest-files".concat(r?"?".concat(r):""));a=null!=(t=(await n.json()).items)?t:[]}catch(e){a=[]}s=!1,u()}function h(e){i&&clearTimeout(i),i=setTimeout(()=>{p(e)},120)}return{onStart:n=>{var o;e=document.createElement("div"),document.body.appendChild(e),c=n.command,d=null!=(o=n.clientRect)?o:null,l=n.query,Promise.resolve().then(r.t.bind(r,80282,19)).then(r=>{let{createRoot:n}=r;t=n(e),h(l)})},onUpdate:e=>{var t;c=e.command,d=null!=(t=e.clientRect)?t:null,h(l=e.query)},onKeyDown:r=>{var n,l;if("Escape"===r.event.key)return null==t||t.unmount(),null==e||e.remove(),e=null,t=null,!0;let a=null!=(l=null==(n=o.current)?void 0:n.onKeyDown(r))&&l;return a&&r.event.stopImmediatePropagation(),a},onExit:()=>{i&&clearTimeout(i),null==t||t.unmount(),null==e||e.remove(),e=null,t=null}}}})]}})],editorProps:{attributes:{class:"chat-editor-content ".concat(d?"chat-editor-compact":""),style:"color: var(--color-text);"},handleKeyDown:(e,t)=>("Enter"===t.key&&!t.shiftKey,!1),handleDOMEvents:{paste:(e,t)=>{let r=t.clipboardData;if(!r)return!1;let n=[];if(r.items){for(let e of Array.from(r.items))if("file"===e.kind){let t=e.getAsFile();t&&n.push(t)}}if(n.length>0){var o;t.preventDefault();let e=new DataTransfer;for(let t of n)e.items.add(t);return null==(o=p.current)||o.call(p,e.files),!0}return!1},dragover:(e,t)=>{var r,n;return!!((null==(r=t.dataTransfer)?void 0:r.types.includes("application/x-file-mention"))||(null==(n=t.dataTransfer)?void 0:n.types.includes("Files")))&&(t.preventDefault(),t.dataTransfer.dropEffect="copy",!0)},drop:(e,t)=>{var r,n,o,l;let a=()=>{let e=t.target instanceof HTMLElement?t.target.closest("[data-chat-drop-target]"):null;null==e||e.removeAttribute("data-drag-hover")},s=null==(r=t.dataTransfer)?void 0:r.getData("application/x-file-mention");if(s){t.preventDefault(),t.stopPropagation(),a();try{let{name:e,path:t}=JSON.parse(s);e&&t&&(null==(o=h.current)||o.chain().focus().insertContent([{type:"chatFileMention",attrs:{label:e,path:t}},{type:"text",text:" "}]).run())}catch(e){}return!0}let i=null==(n=t.dataTransfer)?void 0:n.files;return!!i&&i.length>0&&(t.preventDefault(),t.stopPropagation(),a(),null==(l=p.current)||l.call(p,i),!0)}}},onUpdate:e=>{let{editor:t}=e;null==a||a(t.isEmpty)}});return(0,o.useEffect)(()=>{h.current=null!=x?x:null},[x]),(0,o.useEffect)(()=>{if(!x)return;let e=e=>{if("Enter"===e.key&&!e.shiftKey&&!e.isComposing){let t=s3.getState(x.state);if(null==t?void 0:t.active)return;e.preventDefault();let{text:r,mentionedFiles:n}=it(x);if(r.trim()||n.length>0){let e=x.getHTML();u.current(r,n,e),x.commands.clearContent(!0),requestAnimationFrame(()=>x.commands.focus())}}},t=x.view.dom;return t.addEventListener("keydown",e),()=>t.removeEventListener("keydown",e)},[x]),(0,o.useEffect)(()=>{x&&x.setEditable(!c)},[x,c]),(0,o.useImperativeHandle)(t,()=>({insertFileMention:(e,t)=>{null==x||x.chain().focus().insertContent([{type:"chatFileMention",attrs:{label:e,path:t}},{type:"text",text:" "}]).run()},clear:()=>{null==x||x.commands.clearContent(!0)},focus:()=>{null==x||x.commands.focus()},isEmpty:()=>{var e;return null==(e=null==x?void 0:x.isEmpty)||e},submit:()=>{if(!x)return;let{text:e,mentionedFiles:t}=it(x);if(e.trim()||t.length>0){let r=x.getHTML();u.current(e,t,r),x.commands.clearContent(!0),requestAnimationFrame(()=>x.commands.focus())}},setText:e=>{null==x||x.commands.setContent(e),null==x||x.commands.focus("end")},appendText:e=>{if(!x)return;let t=e.trim();if(!t)return;let{text:r}=it(x),n=r.trim().length>0?" ":"";x.chain().focus("end").insertContent("".concat(n).concat(t)).run()}})),(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(ld.$Z,{editor:x}),(0,n.jsx)("style",{children:"\n .chat-editor-content {\n outline: none;\n min-height: ".concat(d?"16px":"28px",";\n max-height: 200px;\n overflow-y: auto;\n padding: ").concat(d?"10px 12px":"14px 16px",";\n font-size: ").concat(d?"12px":"14px",';\n line-height: 1.5;\n transition: opacity 0.15s ease;\n }\n .chat-editor-content[contenteditable="false"] {\n opacity: 0.5;\n cursor: not-allowed;\n }\n .chat-editor-content p {\n margin: 0;\n }\n .chat-editor-content p.is-editor-empty:first-child::before {\n content: attr(data-placeholder);\n color: var(--color-text-muted);\n float: left;\n height: 0;\n pointer-events: none;\n }\n /* File mention pill styles */\n .chat-editor-content span[data-chat-file-mention] {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n padding: 1px 8px 1px 6px;\n margin: 0 1px;\n border-radius: 6px;\n background: var(--mention-bg, rgba(59, 130, 246, 0.12));\n color: var(--mention-fg, #3b82f6);\n font-size: 12px;\n font-weight: 500;\n line-height: 1.6;\n vertical-align: baseline;\n cursor: default;\n user-select: all;\n white-space: nowrap;\n transition: opacity 0.15s ease;\n }\n .chat-editor-content span[data-chat-file-mention]::before {\n content: "@";\n opacity: 0.5;\n font-size: 11px;\n }\n .chat-editor-content span[data-chat-file-mention]:hover {\n opacity: 0.85;\n }\n .chat-editor-content.chat-editor-compact {\n min-height: 16px;\n }\n ')})]})});function io(e){let{state:t}=e;return"processing"===t?(0,n.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"animate-spin",children:(0,n.jsx)("path",{d:"M21 12a9 9 0 1 1-9-9"})}):"recording"===t||"listening"===t?(0,n.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:(0,n.jsx)("rect",{x:"7",y:"7",width:"10",height:"10",rx:"2"})}):(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 1 0 6 0V5a3 3 0 0 0-3-3Z"}),(0,n.jsx)("path",{d:"M19 10v2a7 7 0 0 1-14 0v-2"}),(0,n.jsx)("path",{d:"M12 19v3"})]})}function il(e){let{compact:t,disabled:r=!1,preferServerTranscription:l,onTranscript:a}=e,[s,i]=(0,o.useState)("idle"),[c,d]=(0,o.useState)(!1),[u,p]=(0,o.useState)(!1),h=(0,o.useRef)(null),x=(0,o.useRef)(null),m=(0,o.useRef)(null);(0,o.useEffect)(()=>{var e;let t=window;d(!!(t.SpeechRecognition||t.webkitSpeechRecognition)),p("undefined"!=typeof navigator&&!!(null==(e=navigator.mediaDevices)?void 0:e.getUserMedia)&&"undefined"!=typeof MediaRecorder)},[]),(0,o.useEffect)(()=>()=>{var e,t,r;null==(e=m.current)||e.stop(),null==(t=h.current)||t.stop(),null==(r=x.current)||r.getTracks().forEach(e=>e.stop())},[]);let f=(0,o.useMemo)(()=>l&&u?"server":c?"browser":"unsupported",[c,l,u]),v=async()=>{let e=window,t=e.SpeechRecognition||e.webkitSpeechRecognition;if(!t){i("error"),window.setTimeout(()=>i("idle"),1500);return}let r=new t;m.current=r,r.continuous=!1,r.interimResults=!1,r.maxAlternatives=1,r.onresult=e=>{let t=Array.from(e.results).map(e=>{var t,r;return null!=(r=null==(t=e[0])?void 0:t.transcript)?r:""}).join(" ").trim();t&&a(t)},r.onerror=()=>{i("idle"),m.current=null},r.onend=()=>{i("idle"),m.current=null},r.start(),i("listening")},g=async()=>{try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});x.current=e;let t=[],r=new MediaRecorder(e);h.current=r,r.ondataavailable=e=>{e.data.size>0&&t.push(e.data)},r.onstop=async()=>{var e,n;try{i("processing");let n=new Blob(t,{type:r.mimeType||"audio/webm"}),o=new FormData;o.set("file",new File([n],"voice-input.webm",{type:n.type||"audio/webm"}));let l=await fetch("/api/voice/transcribe",{method:"POST",body:o});if(!l.ok)throw Error("Failed to transcribe audio.");let s=await l.json();(null==(e=s.text)?void 0:e.trim())&&a(s.text.trim()),i("idle")}catch(e){i("error"),window.setTimeout(()=>i("idle"),1500)}finally{h.current=null,null==(n=x.current)||n.getTracks().forEach(e=>e.stop()),x.current=null}},r.start(),i("recording")}catch(e){if(c)return void await v();i("error"),window.setTimeout(()=>i("idle"),1500)}},y=async()=>{if(!r&&"processing"!==s&&"unsupported"!==f){var e,t;if("server"===f)return"recording"===s?void(null==(e=h.current)||e.stop()):void await g();if("listening"===s)return void(null==(t=m.current)||t.stop(),m.current=null,i("idle"));await v()}},b="unsupported"===f?"Voice input is not supported in this browser":"processing"===s?"Transcribing...":"recording"===s||"listening"===s?"Stop voice input":"Start voice input";return(0,n.jsx)("button",{type:"button",onClick:()=>void y(),disabled:r||"unsupported"===f,className:"p-1.5 rounded-lg transition-opacity disabled:cursor-not-allowed disabled:opacity-40",style:{color:"error"===s?"var(--color-error, #ef4444)":"recording"===s||"listening"===s?"var(--color-accent)":"var(--color-text-muted)"},title:b,"aria-label":b,"data-compact":t?"true":"false",children:(0,n.jsx)(io,{state:s})})}function ia(e){return!e||"object"!=typeof e||Array.isArray(e)?null:e}function is(e){let t=ia(e);if(!t)return null;let r="string"==typeof t.stableId&&t.stableId.trim()?t.stableId.trim():null,n="string"==typeof t.displayName&&t.displayName.trim()?t.displayName.trim():null,o="string"==typeof t.provider&&t.provider.trim()?t.provider.trim():null;if(!r||!n||!o)return null;let l="string"==typeof t.id&&t.id.trim()?t.id.trim():null,a=l&&l!==r?l:void 0;return{stableId:r,...a?{catalogId:a}:{},displayName:n,provider:o,reasoning:!!t.reasoning}}function ii(e){var t,r;let n=null!=(r=null==(t=e.split(".").pop())?void 0:t.toLowerCase())?r:"";return["jpg","jpeg","png","gif","webp","svg","bmp","ico","tiff","heic"].includes(n)?"image":["mp4","webm","mov","avi","mkv","flv"].includes(n)?"video":["mp3","wav","ogg","aac","flac","m4a"].includes(n)?"audio":"pdf"===n?"pdf":["js","ts","tsx","jsx","py","rb","go","rs","java","cpp","c","h","css","html","json","yaml","yml","toml","md","sh","bash","sql","swift","kt"].includes(n)?"code":["doc","docx","xls","xlsx","ppt","pptx","txt","rtf","csv","pages","numbers","key"].includes(n)?"document":"other"}let ic={image:{bg:"rgba(16, 185, 129, 0.12)",fg:"#10b981"},video:{bg:"rgba(139, 92, 246, 0.12)",fg:"#8b5cf6"},audio:{bg:"rgba(245, 158, 11, 0.12)",fg:"#f59e0b"},pdf:{bg:"rgba(239, 68, 68, 0.12)",fg:"#ef4444"},code:{bg:"rgba(59, 130, 246, 0.12)",fg:"#3b82f6"},document:{bg:"rgba(107, 114, 128, 0.12)",fg:"#6b7280"},other:{bg:"rgba(107, 114, 128, 0.08)",fg:"#9ca3af"}};function id(e){let{category:t}=e,r={width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};switch(t){case"image":return(0,n.jsxs)("svg",{...r,children:[(0,n.jsx)("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),(0,n.jsx)("circle",{cx:"9",cy:"9",r:"2"}),(0,n.jsx)("path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"})]});case"video":return(0,n.jsxs)("svg",{...r,children:[(0,n.jsx)("path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5"}),(0,n.jsx)("rect",{x:"2",y:"6",width:"14",height:"12",rx:"2"})]});case"audio":return(0,n.jsxs)("svg",{...r,children:[(0,n.jsx)("path",{d:"M9 18V5l12-2v13"}),(0,n.jsx)("circle",{cx:"6",cy:"18",r:"3"}),(0,n.jsx)("circle",{cx:"18",cy:"16",r:"3"})]});case"pdf":return(0,n.jsxs)("svg",{...r,children:[(0,n.jsx)("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),(0,n.jsx)("path",{d:"M14 2v6h6"}),(0,n.jsx)("path",{d:"M10 13h4"}),(0,n.jsx)("path",{d:"M10 17h4"})]});case"code":return(0,n.jsxs)("svg",{...r,children:[(0,n.jsx)("polyline",{points:"16 18 22 12 16 6"}),(0,n.jsx)("polyline",{points:"8 6 2 12 8 18"})]});case"document":return(0,n.jsxs)("svg",{...r,children:[(0,n.jsx)("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),(0,n.jsx)("path",{d:"M14 2v6h6"}),(0,n.jsx)("path",{d:"M16 13H8"}),(0,n.jsx)("path",{d:"M16 17H8"}),(0,n.jsx)("path",{d:"M10 9H8"})]});default:return(0,n.jsxs)("svg",{...r,children:[(0,n.jsx)("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),(0,n.jsx)("path",{d:"M14 2v6h6"})]})}}function iu(e){let{msg:t,idx:r,onEdit:l,onSendNow:a,onRemove:s}=e,[i,c]=(0,o.useState)(!1),[d,u]=(0,o.useState)(t.text),p=(0,o.useRef)(null),h=()=>{let e=p.current;e&&(e.style.height="auto",e.style.height="".concat(e.scrollHeight,"px"))};(0,o.useEffect)(()=>{if(i){var e,t,r,n;null==(e=p.current)||e.focus();let o=null!=(n=null==(t=p.current)?void 0:t.value.length)?n:0;null==(r=p.current)||r.setSelectionRange(o,o),h()}},[i]);let x=()=>{let e=d.trim();e&&e!==t.text?l(t.id,e):u(t.text),c(!1)};return(0,n.jsxs)("div",{className:"flex items-start gap-2.5 group py-2 ".concat(r>0?"border-t":""),style:r>0?{borderColor:"var(--color-border)"}:void 0,children:[(0,n.jsx)("span",{className:"shrink-0 mt-px text-[11px] font-medium tabular-nums w-4",style:{color:"var(--color-text-muted)"},children:r+1}),i?(0,n.jsx)("textarea",{ref:p,className:"flex-1 text-[13px] leading-[1.45] min-w-0 resize-none rounded-md px-2 py-1 outline-none",style:{color:"var(--color-text-secondary)",background:"var(--color-bg)",border:"1px solid var(--color-border)"},rows:1,value:d,onChange:e=>{u(e.target.value),h()},onBlur:x,onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),x()),"Escape"===e.key&&(u(t.text),c(!1))}}):(0,n.jsxs)("div",{className:"flex-1 min-w-0 flex items-center gap-2",children:[t.attachedFiles.length>0&&(0,n.jsx)("div",{className:"flex gap-1 shrink-0",children:t.attachedFiles.map(e=>{let t="image"===ii(e.name)?e.localUrl||"/api/workspace/raw-file?path=".concat(encodeURIComponent(e.path)):e.path?"/api/workspace/thumbnail?path=".concat(encodeURIComponent(e.path),"&size=100"):void 0;return(0,n.jsx)("img",{src:t,alt:e.name,className:"rounded object-cover",style:{height:28,width:28,background:"var(--color-surface-hover)"},onError:e=>{e.currentTarget.style.display="none"}},e.id)})}),(0,n.jsx)("p",{className:"text-[13px] leading-[1.45] line-clamp-1 min-w-0",style:{color:"var(--color-text-secondary)"},children:t.text||"".concat(t.attachedFiles.length," ").concat(1===t.attachedFiles.length?"file":"files")})]}),!i&&(0,n.jsxs)("div",{className:"flex items-center gap-1 shrink-0 md:opacity-0 md:group-hover:opacity-100 transition-opacity",children:[(0,n.jsx)("button",{type:"button",className:"rounded-md p-1 transition-colors hover:bg-stone-100 dark:hover:bg-stone-800",title:"Edit message",onClick:()=>{u(t.text),c(!0)},children:(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-stone-400",children:[(0,n.jsx)("path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),(0,n.jsx)("path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z"})]})}),(0,n.jsx)("button",{type:"button",className:"rounded-md p-1 transition-colors hover:bg-stone-100 dark:hover:bg-stone-800",title:"Send now",onClick:()=>a(t.id),children:(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-stone-400",children:[(0,n.jsx)("path",{d:"M12 19V5"}),(0,n.jsx)("path",{d:"m5 12 7-7 7 7"})]})}),(0,n.jsx)("button",{type:"button",className:"rounded-md p-1 transition-colors hover:bg-stone-100 dark:hover:bg-stone-800",title:"Remove from queue",onClick:()=>s(t.id),children:(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-stone-400",children:[(0,n.jsx)("path",{d:"M3 6h18"}),(0,n.jsx)("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),(0,n.jsx)("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]})})]})]})}function ip(e){let{files:t,compact:r,onRemove:l,onClearAll:a}=e,[s,i]=(0,o.useState)(null);return 0===t.length?null:(0,n.jsxs)("div",{className:"".concat(r?"px-2":"px-3"," pt-2"),children:[(0,n.jsx)("div",{className:"flex gap-2 overflow-x-auto pb-1",style:{scrollbarWidth:"thin"},children:t.map(e=>{var t;let r=ii(e.name),o=null!=(t=ic[r])?t:ic.other,a=e.path.replace(/^\/Users\/[^/]+/,"~").replace(/^\/home\/[^/]+/,"~").replace(/^[A-Z]:\\Users\\[^\\]+/,"~");return(0,n.jsxs)("div",{className:"relative group flex-shrink-0 rounded-xl overflow-hidden",style:{background:"var(--color-surface-hover)",border:"1px solid var(--color-border)"},children:[(0,n.jsx)("button",{type:"button",onClick:()=>l(e.id),className:"absolute top-1 right-1 z-10 w-[18px] h-[18px] rounded-full flex items-center justify-center md:opacity-0 md:group-hover:opacity-100 transition-opacity",style:{background:"rgba(0,0,0,0.55)",color:"white",backdropFilter:"blur(4px)"},children:(0,n.jsxs)("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",children:[(0,n.jsx)("path",{d:"M18 6 6 18"}),(0,n.jsx)("path",{d:"m6 6 12 12"})]})}),"image"===r?(0,n.jsx)("img",{src:e.localUrl||"/api/workspace/raw-file?path=".concat(encodeURIComponent(e.path)),alt:e.name,className:"block rounded-xl object-cover cursor-pointer transition-all duration-200 hover:opacity-95",style:{height:80,width:"auto",minWidth:60,maxWidth:140,opacity:e.uploading?.6:1,background:"var(--color-bg-secondary)"},onClick:()=>{i(e.localUrl||"/api/workspace/raw-file?path=".concat(encodeURIComponent(e.path)))},onError:e=>{e.currentTarget.style.display="none"}}):"pdf"===r&&e.path?(0,n.jsx)("img",{src:"/api/workspace/thumbnail?path=".concat(encodeURIComponent(e.path),"&size=200"),alt:e.name,className:"block rounded-xl object-cover",style:{height:80,width:"auto",minWidth:60,maxWidth:140,opacity:e.uploading?.6:1,background:"var(--color-bg-secondary)"},onError:e=>{e.currentTarget.style.display="none"}}):(0,n.jsxs)("div",{className:"flex items-center gap-2.5 px-3 py-2.5",style:{opacity:e.uploading?.6:1},children:[(0,n.jsx)("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center shrink-0",style:{background:o.bg,color:o.fg},children:(0,n.jsx)(id,{category:r})}),(0,n.jsxs)("div",{className:"min-w-0 max-w-[140px]",children:[(0,n.jsx)("p",{className:"text-[11px] font-medium truncate",style:{color:"var(--color-text)"},title:e.path||e.name,children:e.name}),(0,n.jsx)("p",{className:"text-[9px] truncate",style:{color:"var(--color-text-muted)"},title:e.path||e.name,children:e.uploading?"Uploading...":a})]})]})]},e.id)})}),(0,n.jsx)(e_,{open:null!==s,onOpenChange:e=>{e||i(null)},children:(0,n.jsxs)(eA,{className:"!max-w-[90vw] !w-auto !p-0 !rounded-2xl !bg-transparent !border-none !shadow-[0_0_120px_rgba(0,0,0,0.4)]",showCloseButton:!1,children:[(0,n.jsx)("button",{type:"button",onClick:()=>i(null),className:"absolute top-3 right-3 z-10 w-7 h-7 rounded-full flex items-center justify-center cursor-pointer outline-none transition-all hover:opacity-85",style:{background:"rgba(0,0,0,0.55)",color:"white",backdropFilter:"blur(4px)",boxShadow:"0 2px 8px rgba(0,0,0,0.3)"},children:(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:[(0,n.jsx)("path",{d:"M18 6 6 18"}),(0,n.jsx)("path",{d:"m6 6 12 12"})]})}),s&&(0,n.jsx)("img",{src:s,alt:"Preview",className:"block rounded-xl",style:{maxHeight:"80vh",maxWidth:"85vw",objectFit:"contain"}})]})})]})}let ih=(0,o.forwardRef)(function(e,t){var r,l;let{fileContext:a,compact:s,sessionTitle:i,initialSessionId:c,onFileChanged:d,onActiveSessionChange:u,onSessionsChange:p,onSubagentSpawned:h,onSubagentClick:x,onFilePathClick:m,onComposioAction:f,onDeleteSession:v,onRenameSession:g,sessionKey:y,subagentTask:b,subagentLabel:j,onBack:k,hideHeaderActions:w,onRuntimeStateChange:N,onConversationActivity:C,gatewaySessionKey:S,gatewaySessionId:M,gatewayChannel:L,visible:T}=e,I=!!y,R=!!S,_=(0,o.useRef)(null),[E,D]=(0,o.useState)(!0),[A,W]=(0,o.useState)(null),[B,F]=(0,o.useState)(!1),P=(0,o.useRef)(null),[z,O]=(0,o.useState)([]),U=(0,o.useRef)(null),[H,V]=(0,o.useState)(!1);(0,o.useEffect)(()=>{V(!0)},[]),(0,o.useEffect)(()=>{if(!1===T)return;let e=setTimeout(()=>{var e;null==(e=_.current)||e.focus()},150);return()=>clearTimeout(e)},[T]);let[K,J]=(0,o.useState)(!1),q=(0,o.useRef)(null),[G,$]=(0,o.useState)(null),Z=(0,o.useRef)(new Set),Y=(0,o.useRef)(!1),Q=(0,o.useRef)(!0),[X,ee]=(0,o.useState)([]),et=(0,o.useRef)(new Map),er=(0,o.useRef)(null),[en,eo]=(0,o.useState)([]),[el,ea]=(0,o.useState)(!1),[es,ei]=(0,o.useState)(null),ec="What can I help with?",ed=(0,o.useCallback)(e=>{var t;null==(t=_.current)||t.setText(e),D(!1)},[]),eu=(0,o.useCallback)(e=>{var t;null==(t=_.current)||t.appendText(e),D(!1)},[]),ep=null!=(r=null==a?void 0:a.path)?r:null,eh=(0,o.useRef)(null);(0,o.useEffect)(()=>{eh.current=A},[A]);let ex=(0,o.useRef)(y);(0,o.useEffect)(()=>{ex.current=y},[y]);let em=(0,o.useMemo)(()=>new ad.rL({api:"/api/chat",body:()=>{let e={},t=ex.current;t&&(e.sessionKey=t);let r=eh.current;return r&&(e.sessionId=r),er.current&&(e.userHtml=er.current,er.current=null),e}}),[]),{messages:eb,sendMessage:ej,status:ek,stop:ew,error:eN,setMessages:eC}=(0,ac.Y_)({transport:em}),eS="streaming"===ek||"submitted"===ek||K;(0,o.useEffect)(()=>{if("ready"!==ek)return;let e=!1,t=new AbortController;return(async()=>{try{let r=await fetch("/api/settings/cloud",{cache:"no-store",signal:t.signal});if(!r.ok)return;let n=await r.json(),o=function(e){let t=ia(e);if(!t)return null;let r=Array.isArray(t.models)?t.models.map(is).filter(e=>null!==e):[];return{status:"no_key"===t.status||"invalid_key"===t.status||"valid"===t.status?t.status:"no_key",isDenchPrimary:!!t.isDenchPrimary,elevenLabsEnabled:!!t.elevenLabsEnabled,selectedDenchModel:"string"==typeof t.selectedDenchModel&&t.selectedDenchModel.trim()?t.selectedDenchModel.trim():null,models:r}}(n);!e&&o&&ei(o)}catch(e){}})(),()=>{e=!0,t.abort()}},[ek,eb.length,A]);let eM=!!((null==es?void 0:es.status)==="valid"&&es.elevenLabsEnabled),eL=!!((null==es?void 0:es.status)==="valid"&&es.elevenLabsEnabled),eT=(0,o.useRef)(N);eT.current=N,(0,o.useEffect)(()=>{var e;null==(e=eT.current)||e.call(eT,{sessionId:A,sessionKey:null!=y?y:null,isStreaming:eS,status:ek,isReconnecting:K,loadingSession:B})},[A,y,eS,ek,K,B]);let eI=(0,o.useRef)(null);(0,o.useEffect)(()=>(eI.current&&(clearTimeout(eI.current),eI.current=null),"submitted"===ek&&(eI.current=setTimeout(()=>{eI.current=null,"submitted"===ek&&($("Request timed out — no response from agent. Try again or check the gateway."),ew())},9e4)),()=>{eI.current&&(clearTimeout(eI.current),eI.current=null)}),[ek,ew]);let eR=(0,o.useRef)(null),e_=(0,o.useRef)(!1),eE=(0,o.useRef)(0),[eD,eA]=(0,o.useState)(!1);(0,o.useEffect)(()=>{let e=eR.current;if(!e)return;let t=()=>{let t=e.scrollHeight-e.scrollTop-e.clientHeight>80;e_.current=t,eA(t)};return e.addEventListener("scroll",t,{passive:!0}),()=>e.removeEventListener("scroll",t)},[]);let eW=(0,o.useCallback)(()=>{var e;null==(e=P.current)||e.scrollIntoView({behavior:"smooth"})},[]);(0,o.useEffect)(()=>{!e_.current&&(eE.current||(eE.current=requestAnimationFrame(()=>{var e;eE.current=0,null==(e=P.current)||e.scrollIntoView({behavior:"smooth"})})))},[eb]);let eB=(0,o.useCallback)(async e=>{let t={title:e};ep&&(t.filePath=ep);let r=await fetch("/api/web-sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return(await r.json()).session.id},[ep]),eF=(0,o.useCallback)(async(e,t,r)=>{let n=new AbortController;q.current=n;try{let o=null==r?void 0:r.sessionKey,l=!o||o.includes(":subagent:")||o.includes(":web:")?o?"/api/chat/stream?sessionKey=".concat(encodeURIComponent(o)):"/api/chat/stream?sessionId=".concat(encodeURIComponent(e)):"/api/gateway/chat/stream?sessionKey=".concat(encodeURIComponent(o)),a=await fetch(l,{signal:n.signal});if(!a.ok||!a.body)return!1;if("false"===a.headers.get("X-Run-Active"))return a.body.cancel(),!1;J(!0);let s=function(){let e=[],t=-1,r=-1;return{processEvent:function(n){var o,l,a,s;switch(n.type){case"user-message":t=-1,r=-1,e.push({type:"user-message",id:n.id,text:null!=(o=n.text)?o:""});break;case"reasoning-start":e.push({type:"reasoning",text:"",state:"streaming"}),r=e.length-1;break;case"reasoning-delta":if(r>=0){let t=e[r];t.text+=n.delta}break;case"reasoning-end":if(r>=0){let t=e[r];delete t.state}r=-1;break;case"text-start":e.push({type:"text",text:""}),t=e.length-1;break;case"text-delta":if(t>=0){let r=e[t];r.text+=n.delta}break;case"text-end":t=-1;break;case"tool-input-start":for(let t=e.length-1;t>=0;t--){let r=e[t];if("dynamic-tool"===r.type&&r.toolCallId===n.toolCallId){r.toolName=n.toolName,r.state="input-available",r.input||(r.input={});return}}e.push({type:"dynamic-tool",toolCallId:n.toolCallId,toolName:n.toolName,state:"input-available",input:{}});break;case"tool-input-available":for(let t=e.length-1;t>=0;t--){let r=e[t];if("dynamic-tool"===r.type&&r.toolCallId===n.toolCallId){r.input=null!=(l=n.input)?l:{};break}}break;case"tool-output-partial":for(let t=e.length-1;t>=0;t--){let r=e[t];if("dynamic-tool"===r.type&&r.toolCallId===n.toolCallId){r.preliminary=!0,r.output=null!=(a=n.output)?a:{};break}}break;case"tool-output-available":for(let t=e.length-1;t>=0;t--){let r=e[t];if("dynamic-tool"===r.type&&r.toolCallId===n.toolCallId){!0===n.preliminary?(r.preliminary=!0,r.state="input-available"):(delete r.preliminary,r.state="output-available"),r.output=null!=(s=n.output)?s:{};break}}break;case"tool-output-error":for(let t=e.length-1;t>=0;t--){let r=e[t];if("dynamic-tool"===r.type&&r.toolCallId===n.toolCallId){r.state="error",r.output={error:n.errorText};break}}}},getParts:()=>e.map(e=>({...e}))}}(),i=a.body.getReader(),c=new TextDecoder,d="reconnect-".concat(e),u="",p=!1,h=()=>{if(n.signal.aborted)return;let e={id:d,role:"assistant",parts:s.getParts()};eC([...t,e])};for(;;){let e,{done:t,value:r}=await i.read();if(t)break;for(u+=c.decode(r,{stream:!0});-1!==(e=u.indexOf("\n\n"));){let t=u.slice(0,e);if(u=u.slice(e+2),t.startsWith("data: "))try{let e=JSON.parse(t.slice(6));s.processEvent(e)}catch(e){}}p||(p=!0,requestAnimationFrame(()=>{p=!1,h()}))}if(h(),!n.signal.aborted){for(let e of t)Z.current.add(e.id);Z.current.add(d)}return J(!1),q.current=null,!0}catch(e){return"AbortError"!==e.name&&console.error("Reconnection error:",e),J(!1),q.current=null,!1}},[eC]),eP=(0,o.useRef)(null);eP.current=async()=>{if(!ep)return[];try{let e=await fetch("/api/web-sessions?filePath=".concat(encodeURIComponent(ep)));return(await e.json()).sessions||[]}catch(e){return[]}},(0,o.useEffect)(()=>{if(!ep||I)return;let e=!1;return eh.current=null,W(null),null==u||u(null),eC([]),Z.current.clear(),Q.current=!0,(async()=>{var t,r,n;let o=null!=(r=await (null==(t=eP.current)?void 0:t.call(eP)))?r:[];if(!e&&(ee(o),o.length>0)){let t=null!=(n=c?o.find(e=>e.id===c):void 0)?n:o[0];W(t.id),eh.current=t.id,null==u||u(t.id),Q.current=!1;try{let r=await fetch("/api/web-sessions/".concat(t.id));if(e)return;let n=(await r.json()).messages||[],o=n.some(e=>e._streaming)?n.filter(e=>!e._streaming):n;for(let e of o)"user"===e.role&&e.html&&et.current.set(e.id,e.html);let l=o.map(e=>{var t;return Z.current.add(e.id),{id:e.id,role:e.role,parts:null!=(t=e.parts)?t:[{type:"text",text:e.content}]}});e||eC(l),e||await eF(t.id,l)}catch(e){}}})(),()=>{e=!0}},[ep,eF]);let ez=(0,o.useRef)(!1),eO=(0,o.useRef)(null);(0,o.useEffect)(()=>{ep||I||R||!c||ez.current&&c===eO.current||(ez.current=!0,eO.current=c,eY(c))},[c]),(0,o.useEffect)(()=>{var e;if(!y||!b)return;let t=!1;null==(e=q.current)||e.abort(),ew(),Z.current.clear(),eo([]);let r={id:"task-".concat(y),role:"user",parts:[{type:"text",text:b}]};return eC([r]),(async()=>{if(t)return;let e=[r];try{let n=await fetch("/api/web-sessions/".concat(encodeURIComponent(y)));if(t)return;if(n.ok){let o=(await n.json()).messages||[],l=o.some(e=>e._streaming)?o.filter(e=>!e._streaming):o;if(l.length>0){for(let e of l)"user"===e.role&&e.html&&et.current.set(e.id,e.html);let n=l.map(e=>{var t;return Z.current.add(e.id),{id:e.id,role:e.role,parts:null!=(t=e.parts)?t:[{type:"text",text:e.content}]}});e=[r,...n],t||eC(e)}}}catch(e){}t||await eF(y,e,{sessionKey:y})})(),()=>{var e;t=!0,null==(e=q.current)||e.abort()}},[y,b,eF]),(0,o.useEffect)(()=>{var e;if(!S||!M)return;let t=!1;return null==(e=q.current)||e.abort(),ew(),Z.current.clear(),eo([]),F(!0),(async()=>{let e=[];try{let r=await fetch("/api/gateway/sessions/".concat(encodeURIComponent(M)));if(t)return;r.ok&&(e=((await r.json()).messages||[]).map(e=>{var t;return Z.current.add(e.id),{id:e.id,role:e.role,parts:null!=(t=e.parts)?t:[{type:"text",text:e.content}]}}),t||eC(e))}catch(e){}t||(F(!1),await eF(S,e,{sessionKey:S}))})(),()=>{var e;t=!0,null==(e=q.current)||e.abort()}},[S,M,eF]);let[eH,eV]=(0,o.useState)(!1);(0,o.useEffect)(()=>{if(!A||!h)return;let e=!1,t=async()=>{try{var t;let r=await fetch("/api/chat/subagents?sessionId=".concat(encodeURIComponent(A)));if(e||!r.ok)return;let n=null!=(t=(await r.json()).subagents)?t:[],o=!1;for(let e of n)"running"===e.status&&(o=!0),h({childSessionKey:e.sessionKey,runId:e.runId,task:e.task,label:e.label,parentSessionId:A,status:e.status});e||eV(o)}catch(e){}};t();let r=setInterval(t,3e3);return()=>{e=!0,clearInterval(r)}},[A,h]);let eK=(0,o.useRef)(ek),eJ=eK.current;(0,o.useEffect)(()=>{let e="ready"===ek;if(("streaming"===eJ||"submitted"===eJ)&&e&&A){for(let e of eb)Z.current.add(e.id);if(ep){var t;null==(t=eP.current)||t.call(eP).then(e=>{ee(e)})}ep&&d&&fetch("/api/workspace/file?path=".concat(encodeURIComponent(ep))).then(e=>e.json()).then(e=>{e.content&&d(e.content)}).catch(()=>{}),null==p||p()}},[eJ,ek,eb,A,ep,d,p]);let eq=(0,o.useRef)(null);(0,o.useEffect)(()=>{eq.current&&(clearTimeout(eq.current),eq.current=null);let e="ready"===ek;return("streaming"===eJ||"submitted"===eJ)&&e&&(eq.current=setTimeout(()=>{var e;eq.current=null;let t=eb[eb.length-1],r=!!((null==(e=null!=t?t:null)?void 0:e.role)==="assistant"&&e.parts.some(e=>"reasoning"===e.type||"dynamic-tool"===e.type||e.type.startsWith("tool-")||"tool-invocation"===e.type)),n=r?sc(null!=t?t:null):si(null!=t?t:null),o=function(e){if(!e||"assistant"!==e.role||-1===sl(e.parts)||sc(e))return null;if(function(e){if(!e)return!1;if("error"===ss(e))return!0;if("tool-invocation"===e.type){let t=e.result;if(t&&"object"==typeof t){let e="string"==typeof t.status?t.status.toLowerCase():null;if("error"===e||"failed"===e)return!0}}return!1}(function(e){for(let t=e.length-1;t>=0;t--){let r=e[t];if(so(r))return r}return null}(e.parts)))return"Tool execution failed and the agent stopped without summarizing the failure.";let t=e.parts.filter(e=>so(e)).map(e=>sa(e)).filter(e=>!!e);return t.includes("composio_search_tools")&&!t.includes("composio_call_tool")?"Search completed but the agent never followed through with the tool call.":"Agent finished tool activity but did not send a final text reply."}(null!=t?t:null);n||r||eN?n||!r||eN?$(null):$(null!=o?o:"Agent finished tool activity but did not send a final text reply."):$("No response received from agent.")},50)),"submitted"===ek&&$(null),()=>{eq.current&&(clearTimeout(eq.current),eq.current=null)}},[eJ,ek,eb,eN]),(0,o.useEffect)(()=>{eK.current=ek},[ek]);let eG=(0,o.useRef)(()=>{}),e$=(0,o.useCallback)(async(e,t,r,n)=>{let o=e.trim().length>0,l=t.length>0,s=n?n.filter(e=>!e.uploading&&e.path):z.filter(e=>!e.uploading&&e.path),i=s.length>0;if(!o&&!l&&!i)return;let c=e.trim(),d=[...s];if("/new"===c.toLowerCase()){for(let e of z)e.localUrl&&URL.revokeObjectURL(e.localUrl);O([]),eG.current();return}if(null==C||C(),eS){n||O([]),eo(e=>[...e,{id:crypto.randomUUID(),text:c,html:r,mentionedFiles:t,attachedFiles:d,createdAt:Date.now()}]);return}if(!n&&d.length>0){for(let e of z)e.localUrl&&URL.revokeObjectURL(e.localUrl);O([])}let h=A;if(!h&&!I&&!R){let e=c||"File attachment",t=e.length>60?e.slice(0,60)+"...":e;if(W(h=await eB(t)),eh.current=h,null==u||u(h),null==p||p(),ep){var x;null==(x=eP.current)||x.call(eP).then(e=>{ee(e)})}}let m=c,f=[...t.map(e=>e.path),...d.map(e=>e.path)];if(f.length>0){let e="[Attached files: ".concat(f.join(", "),"]");m=m?"".concat(e,"\n\n").concat(m):e}if(a&&Q.current){let e=a.isDirectory?"directory":"file";m="[Context: workspace ".concat(e," '").concat(a.path,"']\n\n").concat(m),Q.current=!1}if(et.current.set(m,r),er.current=r,e_.current=!1,S){let e={id:"user-".concat(Date.now()),role:"user",parts:[{type:"text",text:m}]};eC(t=>[...t,e]);try{let e=await fetch("/api/gateway/chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionKey:S,message:m})});e.ok&&e.body&&await eF(S,[],{sessionKey:S})}catch(e){}}else ej({text:m});setTimeout(()=>{var e;null==(e=_.current)||e.focus()},200)},[z,eS,A,eB,u,p,ep,a,ej,S,eF,C,I,eC]),eZ=(0,o.useRef)(ek);(0,o.useEffect)(()=>{let e="streaming"===eZ.current||"submitted"===eZ.current,t="ready"===ek;if(eZ.current=ek,e&&t&&en.length>0){let[e,...t]=en;for(let r of(eo(t),e.attachedFiles))r.localUrl&&URL.revokeObjectURL(r.localUrl);queueMicrotask(()=>{e$(e.text,e.mentionedFiles,e.html,e.attachedFiles)})}},[ek,en,e$]);let eY=(0,o.useCallback)(async e=>{var t;if(e!==A){null==(t=q.current)||t.abort(),ew(),F(!0),W(e),eh.current=e,null==u||u(e),Z.current.clear(),Q.current=!1,eo([]);try{let t=await fetch("/api/web-sessions/".concat(e));if(!t.ok){console.warn("Session ".concat(e," not found (").concat(t.status,"), starting fresh.")),eC([]),F(!1);return}let r=(await t.json()).messages||[],n=r.some(e=>e._streaming)?r.filter(e=>!e._streaming):r;for(let e of(et.current.clear(),n))"user"===e.role&&e.html&&et.current.set(e.id,e.html);let o=n.map(e=>{var t;return Z.current.add(e.id),{id:e.id,role:e.role,parts:null!=(t=e.parts)?t:[{type:"text",text:e.content}]}});eC(o),F(!1),await eF(e,o)}catch(e){console.error("Error loading session:",e),F(!1)}}},[A,eC,u,ew,eF]),eQ=(0,o.useCallback)(()=>{var e;null==(e=q.current)||e.abort(),ew(),J(!1),W(null),eh.current=null,null==u||u(null),eC([]),Z.current.clear(),et.current.clear(),Q.current=!0,Y.current=!1,eo([]),requestAnimationFrame(()=>{var e;null==(e=_.current)||e.focus()})},[eC,u,ew]);eG.current=eQ,(0,o.useImperativeHandle)(t,()=>({loadSession:eY,newSession:async()=>{eQ()},sendNewMessage:async e=>{null==C||C(),eQ();let t=e.length>60?e.slice(0,60)+"...":e,r=await eB(t);W(r),eh.current=r,null==u||u(r),null==p||p(),e_.current=!1,ej({text:e})},insertFileMention:(e,t)=>{var r;null==(r=_.current)||r.insertFileMention(e,t)}}),[eY,eQ,eB,u,p,C,ej]);let eX=(0,o.useCallback)(async()=>{var e;null==(e=q.current)||e.abort(),J(!1);let t=ex.current,r=eh.current;if(t||r)try{await fetch("/api/chat/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t?{sessionKey:t}:{sessionId:r})})}catch(e){}ew()},[ew]),e0=(0,o.useCallback)(e=>{eo(t=>t.filter(t=>t.id!==e))},[]),e1=(0,o.useCallback)((e,t)=>{eo(r=>r.map(r=>r.id===e?{...r,text:t}:r))},[]),e2=(0,o.useCallback)(async e=>{let t=en.find(t=>t.id===e);t&&(eo(t=>t.filter(t=>t.id!==e)),await eX(),setTimeout(()=>{e$(t.text,t.mentionedFiles,t.html,t.attachedFiles)},100))},[en,eX,e$]),e4=(0,o.useCallback)(e=>{O(t=>{let r=t.find(t=>t.id===e);return(null==r?void 0:r.localUrl)&&URL.revokeObjectURL(r.localUrl),t.filter(t=>t.id!==e)})},[]),e5=(0,o.useCallback)(()=>{O(e=>{for(let t of e)t.localUrl&&URL.revokeObjectURL(t.localUrl);return[]})},[]),e3=(0,o.useCallback)(e=>{let t=Array.from(e),r=t.map(e=>({id:"pending-".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2)),name:e.name,path:"",uploading:!0,localUrl:URL.createObjectURL(e)}));O(e=>[...e,...r]);for(let e=0;e<t.length;e++){let n=t[e],o=r[e].id,l=r[e].localUrl,a=new FormData;a.append("file",n),fetch("/api/workspace/upload",{method:"POST",body:a}).then(e=>e.ok?e.json():null).then(e=>{(null==e?void 0:e.ok)&&e.path?O(t=>t.map(t=>t.id===o?{...t,path:e.path,uploading:!1}:t)):(O(e=>e.filter(e=>e.id!==o)),l&&URL.revokeObjectURL(l))}).catch(()=>{O(e=>e.filter(e=>e.id!==o)),l&&URL.revokeObjectURL(l)})}},[]),e6=eb.length>0?eb[eb.length-1]:null,e8=si(e6),e7=function(e){let{loadingSession:t,isReconnecting:r,status:n,hasRunningSubagents:o,lastMessage:l}=e;if(t)return"Loading session...";if(r)return"Resuming stream...";if(o)return"Waiting for subagents...";if((null==l?void 0:l.role)==="assistant"){let e=function(e){for(let t=e.length-1;t>=0;t--){let r=e[t];if("reasoning"!==r.type)continue;let n="string"==typeof r.text?sr(r.text):"";if(n&&sd(n))return n}return null}(l.parts);if(e)return e;let t=function(e){for(let t=e.length-1;t>=0;t--){let r=e[t],n=ss(r);if(!n||"output-available"===n||"error"===n)continue;let o=sa(r);if(o){if("sessions_spawn"===o)return"Starting subagent...";return"Running ".concat(function(e){let t=e.replace(/^tool-/,"").replace(/[_-]+/g," ").trim();return t?t.replace(/\b\w/g,e=>e.toUpperCase()):"tool"}(o),"...")}}return null}(l.parts);if(t)return t}return"submitted"===n?"Thinking...":"streaming"===n?si(l)?"Still streaming...":"Streaming...":null}({loadingSession:B,isReconnecting:K,status:ek,hasRunningSubagents:eH,lastMessage:e6}),e9=eS&&!!e7,te=0===eb.length&&(!s||!a)&&!I&&!B,tt=(0,n.jsxs)(n.Fragment,{children:[en.length>0&&(0,n.jsx)("div",{className:s?"px-2 pt-2":"px-3 pt-3",children:(0,n.jsxs)("div",{className:"rounded-xl border overflow-hidden",style:{background:"var(--color-surface)",borderColor:"var(--color-border)",boxShadow:"var(--shadow-sm)"},children:[(0,n.jsxs)("div",{className:"px-3 py-1.5 text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--color-text-muted)",background:"var(--color-surface-hover)"},children:["Queue (",en.length,")"]}),(0,n.jsx)("div",{className:"flex flex-col p-2",children:en.map((e,t)=>(0,n.jsx)(iu,{msg:e,idx:t,onEdit:e1,onSendNow:e2,onRemove:e0},e.id))})]})}),!I&&(0,n.jsx)(ip,{files:z,compact:s,onRemove:e4,onClearAll:e5}),(0,n.jsx)(ir,{ref:_,onSubmit:e$,onChange:e=>D(e),onNativeFileDrop:I?void 0:e3,placeholder:te?"Build a workflow to automate your tasks":I?eS?"Type to queue a message...":"Type @ to mention files...":s&&a?"Ask about ".concat(a.isDirectory?"this folder":a.filename,"..."):eS?"Type to queue a message...":z.length>0?"Add a message or send files...":"Type @ to mention files...",disabled:B,compact:s}),(0,n.jsxs)("div",{className:"flex items-center justify-between ".concat(s?"px-2 pb-1.5":"px-3 pb-2.5"),children:[(0,n.jsx)("div",{className:"flex items-center gap-0.5",children:!I&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("input",{ref:U,type:"file",multiple:!0,className:"hidden",onChange:e=>{e.target.files&&e.target.files.length>0&&e3(e.target.files),e.target.value=""}}),(0,n.jsx)("button",{type:"button",onClick:()=>{var e;return null==(e=U.current)?void 0:e.click()},className:"p-1.5 rounded-lg hover:opacity-80 transition-opacity",style:{color:z.length>0?"var(--color-accent)":"var(--color-text-muted)"},title:"Attach files",children:(0,n.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48"})})})]})}),(0,n.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,n.jsx)(il,{compact:s,disabled:B,preferServerTranscription:eM,onTranscript:eu}),eS?(0,n.jsx)("button",{type:"button",onClick:()=>eX(),className:"".concat(s?"w-6 h-6":"w-7 h-7"," rounded-full flex items-center justify-center"),style:{background:"var(--color-text)",color:"var(--color-bg)"},title:"Stop generating",children:(0,n.jsx)("svg",{width:"8",height:"8",viewBox:"0 0 10 10",fill:"currentColor",children:(0,n.jsx)("rect",{width:"10",height:"10",rx:"1.5"})})}):(0,n.jsx)("button",{type:"button",onClick:()=>{var e;return null==(e=_.current)?void 0:e.submit()},disabled:E&&0===z.length||B,className:"".concat(s?"w-6 h-6":"w-7 h-7"," rounded-full flex items-center justify-center disabled:opacity-50 disabled:cursor-not-allowed"),style:{background:!E||z.length>0?"linear-gradient(to top, #0065A2, #0075AA)":"var(--color-text-muted)",color:!E||z.length>0?"white":"var(--color-bg)"},title:"Send message",children:(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M12 19V5"}),(0,n.jsx)("path",{d:"m5 12 7-7 7 7"})]})})]})]})]}),tr=(e,t,r)=>(0,n.jsx)("div",{"data-chat-drop-target":"",className:"".concat(s?"rounded-2xl":"rounded-3xl"," overflow-hidden border shadow-[0_0_32px_rgba(0,0,0,0.07)] transition-[outline,box-shadow,border-color] duration-150 ease-out focus-within:border-[var(--color-border-strong)]! data-drag-hover:outline-2 data-drag-hover:outline-dashed data-drag-hover:outline-(--color-accent) data-drag-hover:-outline-offset-2 data-drag-hover:shadow-[0_0_0_4px_color-mix(in_srgb,var(--color-accent)_15%,transparent),0_0_32px_rgba(0,0,0,0.07)]!"),style:{background:"var(--color-surface)",borderColor:"var(--color-border)"},onDragOver:e,onDragLeave:t,onDrop:r,children:tt}),tn=e=>{var t,r;((null==(t=e.dataTransfer)?void 0:t.types.includes("application/x-file-mention"))||(null==(r=e.dataTransfer)?void 0:r.types.includes("Files")))&&(e.preventDefault(),e.dataTransfer.dropEffect="copy",e.currentTarget.setAttribute("data-drag-hover",""))},to=e=>{e.currentTarget.contains(e.relatedTarget)||e.currentTarget.removeAttribute("data-drag-hover")},tl=e=>{var t,r,n;e.currentTarget.removeAttribute("data-drag-hover");let o=null==(t=e.dataTransfer)?void 0:t.getData("application/x-file-mention");if(o){e.preventDefault(),e.stopPropagation();try{let{name:e,path:t}=JSON.parse(o);e&&t&&(null==(n=_.current)||n.insertFileMention(e,t))}catch(e){}return}let l=null==(r=e.dataTransfer)?void 0:r.files;l&&l.length>0&&(e.preventDefault(),e.stopPropagation(),e3(l))};return(0,n.jsxs)("div",{className:"h-full min-h-0 flex flex-col overflow-hidden",style:{background:"var(--color-main-bg)"},children:[(0,n.jsx)("header",{className:"".concat(s?"px-3 py-2":"px-3 py-2 md:px-6 md:py-3"," flex shrink-0 items-center ").concat(I?"gap-3":"justify-between"," z-20"),children:I?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{type:"button",onClick:k,className:"p-1.5 rounded-lg flex-shrink-0",style:{color:"var(--color-text-muted)"},title:"Back to parent chat",children:(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"m12 19-7-7 7-7"}),(0,n.jsx)("path",{d:"M19 12H5"})]})}),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsx)("h2",{className:"text-sm font-semibold truncate",style:{color:"var(--color-text)"},children:j||(b&&b.length>60?b.slice(0,60)+"...":b)}),(0,n.jsx)("p",{className:"text-xs",style:{color:"var(--color-text-muted)"},children:eS?(0,n.jsx)(eU.V,{name:"braille"}):"Completed"})]})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"min-w-0 flex-1",children:s&&a?(0,n.jsxs)("h2",{className:"text-xs font-semibold truncate",style:{color:"var(--color-text)"},children:["Chat: ",a.filename]}):A?(0,n.jsx)("h2",{className:"text-sm font-semibold",style:{color:"var(--color-text)"},children:i||"Chat Session"}):null}),!w&&(0,n.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[A&&v&&(0,n.jsxs)(ef,{children:[(0,n.jsx)(ev,{className:"p-1.5 rounded-lg",style:{color:"var(--color-text-muted)"},title:"More options","aria-label":"More options",children:(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"1"}),(0,n.jsx)("circle",{cx:"5",cy:"12",r:"1"}),(0,n.jsx)("circle",{cx:"19",cy:"12",r:"1"})]})}),(0,n.jsx)(eg,{align:"end",side:"bottom",children:(0,n.jsxs)(ey,{variant:"destructive",onSelect:()=>v(A),children:[(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M3 6h18"}),(0,n.jsx)("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),(0,n.jsx)("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]}),"Delete this chat"]})})]}),(0,n.jsx)("button",{type:"button",onClick:()=>eQ(),className:"p-1.5 rounded-lg",style:{color:"var(--color-text-muted)"},title:"New chat",children:(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M12 5v14"}),(0,n.jsx)("path",{d:"M5 12h14"})]})})]})]})}),!I&&s&&a&&X.length>0&&(0,n.jsx)("div",{className:"px-2 py-1.5 border-b flex shrink-0 gap-1 overflow-x-auto z-20",style:{borderColor:"var(--color-border)",background:"var(--color-bg-glass)"},children:X.slice(0,10).map(e=>(0,n.jsx)("button",{type:"button",onClick:()=>eY(e.id),className:"px-2.5 py-1 text-[10px] rounded-full whitespace-nowrap shrink-0 font-medium",style:{background:e.id===A?"var(--color-accent)":"var(--color-surface-hover)",color:e.id===A?"white":"var(--color-text-muted)",border:e.id===A?"none":"1px solid var(--color-border)"},children:e.title.length>25?e.title.slice(0,25)+"...":e.title},e.id))}),(0,n.jsxs)("div",{ref:eR,className:"min-h-0 min-w-0 flex-1 overflow-y-auto",style:{scrollbarGutter:"stable"},children:[(0,n.jsx)("div",{className:s?"px-3":"px-6",children:B?(0,n.jsx)("div",{className:"flex items-center justify-center h-full min-h-[60vh]",children:(0,n.jsxs)("div",{className:"text-center",children:[(0,n.jsx)(eU.V,{name:"braille",className:"block text-2xl mx-auto mb-3",style:{color:"var(--color-text-muted)"}}),(0,n.jsx)("p",{className:"text-xs",style:{color:"var(--color-text-muted)"},children:"Loading session..."})]})}):te&&!H?(0,n.jsx)("div",{className:"flex items-center justify-center h-full ".concat(s?"min-h-[40vh]":"min-h-[60vh]")}):te?(0,n.jsxs)("div",{className:"flex flex-col items-center justify-center py-8 md:py-12 ".concat(s?"min-h-[60vh]":"min-h-[75vh]"),children:[ec&&(0,n.jsx)("h1",{className:"text-3xl md:text-5xl font-light tracking-normal font-instrument mb-6 md:mb-10 text-center px-4",style:{color:"var(--color-text)"},children:ec}),(0,n.jsx)("div",{className:"w-full max-w-[720px] mx-auto px-3 md:px-4",children:tr(tn,to,tl)}),(0,n.jsx)(aC,{compact:!!s,onPromptClick:ed})]}):0===eb.length?(0,n.jsx)("div",{className:"flex items-center justify-center h-full min-h-[60vh]",children:(0,n.jsx)("div",{className:"text-center max-w-md px-4",children:(0,n.jsx)("p",{className:"text-sm",style:{color:"var(--color-text-muted)"},children:"Ask about this file"})})}):(0,n.jsxs)("div",{className:"".concat(s?"":"max-w-2xl mx-auto"," py-3"),children:[el?(0,n.jsx)("pre",{className:"text-xs whitespace-pre-wrap break-all font-mono p-4 rounded-xl",style:{color:"var(--color-text)",background:"var(--color-surface-hover)"},children:JSON.stringify(eb,null,2)}):eb.map((e,t)=>(0,n.jsx)(s2,{message:e,isStreaming:eS&&t===eb.length-1,onSubagentClick:x,onFilePathClick:m,onComposioAction:f,sessionId:A,voicePlaybackEnabled:eL,userHtmlMap:et.current,copyable:!0},e.id)),e9&&(0,n.jsx)("div",{className:"py-3 min-w-0",children:(0,n.jsxs)("div",{className:"inline-flex max-w-full items-center gap-2 rounded-full px-3 py-1.5",style:{background:"var(--color-surface-hover)",border:"1px solid var(--color-border)",color:"var(--color-text-muted)"},children:[(0,n.jsx)(eU.V,{name:"braille",className:"text-sm ".concat(e8?"":"opacity-90"),style:{color:"inherit"}}),(0,n.jsx)("span",{className:"text-xs truncate",children:e7})]})}),(0,n.jsx)("div",{ref:P})]})}),(eN||G)&&(0,n.jsxs)("div",{className:"px-3 py-2 flex items-center gap-2 sticky bottom-[72px] z-10",style:{background:"color-mix(in srgb, var(--color-error) 6%, var(--color-surface))",borderColor:"color-mix(in srgb, var(--color-error) 18%, transparent)",color:"var(--color-error)"},children:[(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,n.jsx)("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),(0,n.jsx)("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),(0,n.jsx)("p",{className:"text-xs",children:null!=(l=null==eN?void 0:eN.message)?l:G})]})]}),eD&&!te&&(0,n.jsx)("div",{className:"flex justify-center pointer-events-none",style:{marginTop:-80,marginBottom:4,position:"relative",zIndex:20},children:(0,n.jsx)("button",{type:"button",onClick:eW,className:"pointer-events-auto w-8 h-8 rounded-full flex items-center justify-center shadow-md border backdrop-blur-xl transition-colors",style:{background:"color-mix(in srgb, var(--color-surface) 70%, transparent)",borderColor:"var(--color-border)",color:"var(--color-text-muted)"},title:"Scroll to bottom",children:(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M12 5v14"}),(0,n.jsx)("path",{d:"m19 12-7 7-7-7"})]})})}),!te&&(0,n.jsx)("div",{className:"".concat(s?"px-3 py-2":"px-3 pb-3 pt-0 md:px-6 md:pb-5"," shrink-0 z-20"),style:{background:"var(--color-bg-glass)"},children:(0,n.jsx)("div",{className:s?"":"max-w-[720px] mx-auto",children:tr(tn,to,tl)})})]})});var ix=r(52597);function im(e){return null==e?"":"object"==typeof e?JSON.stringify(e):"string"==typeof e?e:"number"==typeof e||"boolean"==typeof e||"bigint"==typeof e?String(e):""}let iv=["created_at","Created","createdAt","created"],ig=["updated_at","Updated","updatedAt","updated"],iy=[{value:"text",label:"Text"},{value:"number",label:"Number"},{value:"email",label:"Email"},{value:"phone",label:"Phone"},{value:"date",label:"Date"},{value:"boolean",label:"Boolean"},{value:"enum",label:"Select"},{value:"tags",label:"Tags"},{value:"url",label:"URL"},{value:"richtext",label:"Rich Text"},{value:"action",label:"Action"}];function ib(e,t){for(let r of t){let t=e[r];if(null!=t&&""!==t)return t}}function ij(e){var t;let{value:r,enumValues:o,enumColors:l}=e,a=null!=(t=null==o?void 0:o.indexOf(r))?t:-1,s=a>=0&&l?l[a]:"#94a3b8";return(0,n.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium",style:{background:"".concat(s,"20"),color:s,border:"1px solid ".concat(s,"40")},children:r})}function ik(e){var t,r;let{value:o,members:l}=e,a=String(o),s=null==l?void 0:l.find(e=>e.id===a);return(0,n.jsxs)("span",{className:"flex items-center gap-2",children:[(0,n.jsx)("span",{className:"w-5 h-5 rounded-full flex items-center justify-center text-[10px] font-medium flex-shrink-0",style:{background:"var(--color-accent)",color:"white"},children:(null!=(t=null==s?void 0:s.name)?t:a).charAt(0).toUpperCase()}),(0,n.jsx)("span",{className:"text-sm",children:null!=(r=null==s?void 0:s.name)?r:a})]})}function iw(e){let{value:t,field:r,relationLabels:o,onNavigateEntry:l}=e,a=null==o?void 0:o[r.name],s=function(e){if(!e)return[];let t=e.trim();if(!t)return[];if(t.startsWith("["))try{let e=JSON.parse(t);if(Array.isArray(e))return e.map(String).filter(Boolean)}catch(e){}return[t]}(String(t));return 0===s.length?(0,n.jsx)(iS,{}):(0,n.jsx)("span",{className:"flex items-center gap-1 flex-wrap",children:s.map(e=>{var t;let o=null!=(t=null==a?void 0:a[e])?t:e,s=r.related_object_name&&l?t=>{t.stopPropagation(),l(r.related_object_name,e)}:void 0;return(0,n.jsxs)("button",{type:"button",onClick:s,className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-md text-xs font-medium ".concat(s?"cursor-pointer hover:opacity-80":""),style:{background:"rgba(96, 165, 250, 0.1)",color:"#60a5fa",border:"1px solid rgba(96, 165, 250, 0.2)"},title:s?"Open ".concat(o):o,children:[(0,n.jsxs)("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{opacity:.5},children:[(0,n.jsx)("path",{d:"M7 7h10v10"}),(0,n.jsx)("path",{d:"M7 17 17 7"})]}),(0,n.jsx)("span",{className:"truncate max-w-[180px]",children:o})]},e)})})}function iN(e){let{value:t}=e,r=t$(t);if(0===r.length)return(0,n.jsx)(iS,{});let o={background:"rgba(148, 163, 184, 0.12)",border:"1px solid var(--color-border)"};return(0,n.jsx)("span",{className:"flex items-center gap-1 flex-wrap",children:r.map(e=>{let t=t_(e),r="link"===t.kind&&t.href,l="url"===t.linkType&&!!t.faviconUrl,a="url"===t.linkType||"file"===t.linkType;if(r){let r=(0,n.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs font-medium max-w-[240px]",style:{...o,color:"var(--color-accent)"},children:[l&&(0,n.jsx)(e3,{src:t.faviconUrl,className:"w-3.5 h-3.5 rounded-[3px] shrink-0"}),(0,n.jsx)("span",{className:"min-w-0 truncate",children:t.text}),(0,n.jsx)(tE,{href:t.href,openInNewTab:a,className:"inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-sm hover:bg-black/5"})]});return"url"===t.linkType?(0,n.jsx)(tV,{href:t.href,children:r},e):(0,n.jsx)("span",{children:r},e)}return(0,n.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium",style:{...o,color:"var(--color-text-muted)"},children:e},e)})})}function iC(e){let{value:t,onChange:r,autoFocus:l}=e,a=t$(t),[s,i]=(0,o.useState)(""),c=(0,o.useRef)(null);(0,o.useEffect)(()=>{l&&c.current&&c.current.focus()},[l]);let d=e=>{let t=e.trim();!t||a.includes(t)||(r(JSON.stringify([...a,t])),i(""))},u=e=>{let t=a.filter(t=>t!==e);r(t.length>0?JSON.stringify(t):"")};return(0,n.jsxs)("div",{className:"flex items-center gap-1 flex-wrap min-h-[1.5rem]",children:[a.map(e=>(0,n.jsxs)("span",{className:"inline-flex items-center gap-0.5 px-2 py-0.5 rounded-full text-xs font-medium",style:{background:"rgba(148, 163, 184, 0.12)",color:"var(--color-text-muted)",border:"1px solid var(--color-border)"},children:[e,(0,n.jsx)("button",{type:"button",onClick:()=>u(e),className:"ml-0.5 hover:opacity-70",style:{color:"var(--color-text-muted)"},children:(0,n.jsxs)("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[(0,n.jsx)("path",{d:"M18 6 6 18"}),(0,n.jsx)("path",{d:"m6 6 12 12"})]})})]},e)),(0,n.jsx)("input",{ref:c,type:"text",value:s,onChange:e=>i(e.target.value),onKeyDown:e=>{("Enter"===e.key||","===e.key)&&s.trim()&&(e.preventDefault(),d(s)),"Backspace"===e.key&&!s&&a.length>0&&u(a[a.length-1])},onBlur:()=>{s.trim()&&d(s)},placeholder:0===a.length?"Type and press Enter...":"",className:"flex-1 min-w-[60px] text-xs outline-none bg-transparent",style:{color:"var(--color-text)"}})]})}function iS(){return(0,n.jsx)("span",{style:{color:"var(--color-text-muted)",opacity:.5},className:"text-sm",children:"Empty"})}function iM(e){let{value:t,field:r,members:o,relationLabels:l,onNavigateEntry:a}=e;if(null==t||""===t)return(0,n.jsx)(iS,{});switch(r.type){case"enum":return(0,n.jsx)(ij,{value:im(t),enumValues:r.enum_values,enumColors:r.enum_colors});case"boolean":{let e=!0===t||"true"===t||"1"===t||"yes"===t;return(0,n.jsx)("span",{style:{color:e?"#22c55e":"var(--color-text-muted)"},children:e?"Yes":"No"})}case"user":return(0,n.jsx)(ik,{value:t,members:o});case"relation":return(0,n.jsx)(iw,{value:t,field:r,relationLabels:l,onNavigateEntry:a});case"tags":return(0,n.jsx)(iN,{value:t});default:return(0,n.jsx)(tG,{value:t,fieldType:r.type,mode:"detail",showUrlFavicon:!0,linkInteractionMode:"button"})}}function iL(e){let{relation:t,onNavigateEntry:r}=e,o=t.links.slice(0,10),l=t.links.length-o.length;return(0,n.jsxs)("div",{children:[(0,n.jsxs)("label",{className:"flex items-center gap-1.5 text-[11px] font-medium uppercase tracking-wider mb-1",style:{color:"var(--color-text-muted)"},children:[(0,n.jsxs)("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{opacity:.4},children:[(0,n.jsx)("path",{d:"m12 19-7-7 7-7"}),(0,n.jsx)("path",{d:"M19 12H5"})]}),(0,n.jsx)("span",{className:"capitalize",children:t.sourceObjectName}),(0,n.jsxs)("span",{className:"normal-case tracking-normal font-normal opacity-60",children:["via ",t.fieldName]})]}),(0,n.jsxs)("div",{className:"flex items-center gap-1 flex-wrap text-sm min-h-[1.5rem]",children:[o.map(e=>(0,n.jsxs)("button",{type:"button",onClick:()=>null==r?void 0:r(t.sourceObjectName,e.id),className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-md text-xs font-medium cursor-pointer hover:opacity-80",style:{background:"rgba(192, 132, 252, 0.1)",color:"#c084fc",border:"1px solid rgba(192, 132, 252, 0.2)"},title:"Open ".concat(e.label," in ").concat(t.sourceObjectName),children:[(0,n.jsxs)("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{opacity:.5},children:[(0,n.jsx)("path",{d:"M7 7h10v10"}),(0,n.jsx)("path",{d:"M7 17 17 7"})]}),(0,n.jsx)("span",{className:"truncate max-w-[180px]",children:e.label})]},e.id)),l>0&&(0,n.jsxs)("span",{className:"text-xs px-1 py-0.5 rounded",style:{color:"var(--color-text-muted)"},children:["+",l," more"]})]})]})}function iT(e){let{objectName:t,onCreated:r,onCancel:l}=e,[a,s]=(0,o.useState)(""),[i,c]=(0,o.useState)("text"),[d,u]=(0,o.useState)(""),[p,h]=(0,o.useState)(!1),[x,m]=(0,o.useState)(null),f=(0,o.useRef)(null);(0,o.useEffect)(()=>{var e;null==(e=f.current)||e.focus()},[]);let v=async e=>{if(e.preventDefault(),!a.trim())return;let n={name:a.trim(),type:i};if("enum"===i){let e=d.split(",").map(e=>e.trim()).filter(Boolean);if(0===e.length)return void m("Add at least one option");n.enum_values=e}h(!0),m(null);try{let e=await fetch("/api/workspace/objects/".concat(encodeURIComponent(t),"/fields"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!e.ok){var o;let t=await e.json().catch(()=>({error:"Failed"}));m(null!=(o=t.error)?o:"Failed to create field");return}r()}catch(e){m("Network error")}finally{h(!1)}};return(0,n.jsxs)("form",{onSubmit:v,className:"flex flex-col gap-2 p-3 rounded-lg",style:{background:"var(--color-surface-hover)",border:"1px solid var(--color-border)"},children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("input",{ref:f,type:"text",value:a,onChange:e=>s(e.target.value),placeholder:"Property name",className:"flex-1 px-2 py-1 text-sm rounded-md outline-none",style:{background:"var(--color-bg)",color:"var(--color-text)",border:"1px solid var(--color-border)"}}),(0,n.jsx)("select",{value:i,onChange:e=>c(e.target.value),className:"px-2 py-1 text-sm rounded-md outline-none",style:{background:"var(--color-bg)",color:"var(--color-text)",border:"1px solid var(--color-border)"},children:iy.map(e=>(0,n.jsx)("option",{value:e.value,children:e.label},e.value))})]}),"enum"===i&&(0,n.jsx)("input",{type:"text",value:d,onChange:e=>u(e.target.value),placeholder:"Options (comma-separated)",className:"px-2 py-1 text-sm rounded-md outline-none",style:{background:"var(--color-bg)",color:"var(--color-text)",border:"1px solid var(--color-border)"}}),x&&(0,n.jsx)("p",{className:"text-xs",style:{color:"var(--color-error)"},children:x}),(0,n.jsxs)("div",{className:"flex items-center gap-2 justify-end",children:[(0,n.jsx)("button",{type:"button",onClick:l,className:"px-2 py-1 text-xs rounded-md",style:{color:"var(--color-text-muted)"},children:"Cancel"}),(0,n.jsx)("button",{type:"submit",disabled:p||!a.trim(),className:"px-3 py-1 text-xs rounded-md font-medium disabled:opacity-50",style:{background:"var(--color-accent)",color:"white"},children:p?"Adding...":"Add"})]})]})}function iI(){return(0,n.jsx)("div",{className:"space-y-3",children:[1,2,3,4].map(e=>(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsx)("div",{className:"w-24 h-3 rounded animate-pulse",style:{background:"var(--color-surface-hover)"}}),(0,n.jsx)("div",{className:"flex-1 h-4 rounded animate-pulse",style:{background:"var(--color-surface-hover)"}})]},e))})}function iR(e){let{objectName:t,entryId:r,members:l,tree:a,searchFn:s,onClose:i,onNavigateEntry:c,onNavigateObject:d,onRefresh:u,onNavigate:p}=e,[h,x]=(0,o.useState)(null),[m,f]=(0,o.useState)(!0),[v,g]=(0,o.useState)(null),[y,b]=(0,o.useState)(null),[j,k]=(0,o.useState)(""),[w,N]=(0,o.useState)(!1),[C,S]=(0,o.useState)(!1),[M,L]=(0,o.useState)(!1),T=t8(),[I,R]=(0,o.useState)(""),[_,E]=(0,o.useState)("".concat(t,"/").concat(r,".md")),[D,A]=(0,o.useState)(!0);(0,o.useEffect)(()=>{let e=!1;return f(!0),g(null),(async()=>{try{let o=await fetch("/api/workspace/objects/".concat(encodeURIComponent(t),"/entries/").concat(encodeURIComponent(r)));if(!o.ok){let t=await o.json().catch(()=>({error:"Failed to load"}));if(!e){var n;g(null!=(n=t.error)?n:"Failed to load entry"),f(!1)}return}let l=await o.json();e||(x(l),f(!1))}catch(t){e||(g("Network error"),f(!1))}})(),()=>{e=!0}},[t,r]),(0,o.useEffect)(()=>{let e=!1;return A(!0),(async()=>{try{let o=await fetch("/api/workspace/objects/".concat(encodeURIComponent(t),"/entries/").concat(encodeURIComponent(r),"/content"));if(o.ok){let t=await o.json();if(!e){var n;R(null!=(n=t.content)?n:""),t.path&&E(t.path)}}}catch(e){}finally{e||A(!1)}})(),()=>{e=!0}},[t,r]),(0,o.useEffect)(()=>{let e=e=>{"Escape"!==e.key||y||M||i()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[i,y,M]);let W=(0,o.useCallback)(async(e,n)=>{N(!0);try{(await fetch("/api/workspace/objects/".concat(encodeURIComponent(t),"/entries/").concat(encodeURIComponent(r)),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({fields:{[e]:n}})})).ok&&(x(t=>t?{...t,entry:{...t.entry,[e]:n}}:t),b(null),null==u||u())}catch(e){}finally{N(!1)}},[t,r,u]),[B,F]=(0,o.useState)(null),P=(0,o.useCallback)(()=>{F({open:!0,title:"Delete this entry?",message:"This action cannot be undone. The entry will be permanently removed.",variant:"destructive",confirmLabel:"Delete",onConfirm:async()=>{F(null),S(!0);try{await fetch("/api/workspace/objects/".concat(encodeURIComponent(t),"/entries/").concat(encodeURIComponent(r)),{method:"DELETE"}),null==u||u(),i()}catch(e){}finally{S(!1)}}})},[t,r,u,i]),z=(0,o.useCallback)(()=>{L(!1),f(!0),(async()=>{try{let e=await fetch("/api/workspace/objects/".concat(encodeURIComponent(t),"/entries/").concat(encodeURIComponent(r)));if(e.ok){let t=await e.json();x(t)}}catch(e){}finally{f(!1)}})(),null==u||u()},[t,r,u]),O=null==h?void 0:h.effectiveDisplayField,U=O&&(null==h?void 0:h.entry[O])?im(h.entry[O]):"".concat(String(t)," entry"),H=h?ib(h.entry,iv):void 0,V=h?ib(h.entry,ig):void 0,[K,J]=(0,o.useState)(!1),q=(0,o.useMemo)(()=>{var e;return null!=(e=null==h?void 0:h.fields.filter(e=>"action"!==e.type))?e:[]},[null==h?void 0:h.fields]),G=(0,o.useMemo)(()=>{var e;return null!=(e=null==h?void 0:h.fields.filter(e=>"action"===e.type))?e:[]},[null==h?void 0:h.fields]);return(0,n.jsxs)("div",{className:"flex flex-col h-full min-h-0 overflow-hidden",style:{background:"var(--color-bg)"},children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b flex-shrink-0",style:{borderColor:"var(--color-border)"},children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[(0,n.jsxs)("button",{type:"button",onClick:()=>void(null==d||d(t)),className:"flex items-center gap-1 px-2 py-0.5 rounded-md text-[11px] font-medium capitalize transition-colors hover:opacity-80 flex-shrink-0",style:{background:"var(--color-accent-light)",color:"var(--color-accent)",border:"1px solid var(--color-border)"},title:"Go to ".concat(t),children:[(0,n.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M12 3v18"}),(0,n.jsx)("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),(0,n.jsx)("path",{d:"M3 9h18"}),(0,n.jsx)("path",{d:"M3 15h18"})]}),t]}),(0,n.jsx)("h2",{className:"text-sm font-semibold truncate",style:{color:"var(--color-text)"},children:m?"":U})]}),(0,n.jsxs)("div",{className:"flex items-center gap-0.5 flex-shrink-0",children:[(0,n.jsx)("button",{type:"button",onClick:()=>void P(),disabled:C,className:"p-1 rounded-md flex-shrink-0 hover:opacity-80",style:{color:"var(--color-error)"},title:"Delete entry",children:(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M3 6h18"}),(0,n.jsx)("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),(0,n.jsx)("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]})}),(0,n.jsx)("button",{type:"button",onClick:i,className:"p-1 rounded-md flex-shrink-0 hover:opacity-80",style:{color:"var(--color-text-muted)"},title:"Close (Esc)",children:(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M18 6 6 18"}),(0,n.jsx)("path",{d:"m6 6 12 12"})]})})]})]}),(0,n.jsxs)("div",{className:"flex-1 overflow-y-auto overflow-x-hidden min-h-0",children:[(0,n.jsxs)("div",{className:"px-5 pt-4 pb-2",children:[m&&(0,n.jsx)(iI,{}),v&&(0,n.jsx)("div",{className:"py-8 text-center",children:(0,n.jsx)("p",{className:"text-sm",style:{color:"var(--color-text-muted)"},children:v})}),h&&!m&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("button",{type:"button",onClick:()=>J(e=>!e),className:"flex items-center gap-1.5 mb-2 text-[11px] font-medium uppercase tracking-wider hover:opacity-70 transition-opacity",style:{color:"var(--color-text-muted)"},children:[(0,n.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:"transition-transform",style:{transform:K?"rotate(-90deg)":"rotate(0deg)"},children:(0,n.jsx)("path",{d:"m6 9 6 6 6-6"})}),"Properties"]}),!K&&(0,n.jsxs)("div",{className:"space-y-0.5 mb-2",children:[q.map(e=>{let t=h.entry[e.name];return(0,n.jsxs)("div",{className:"entry-detail-row",children:[(0,n.jsx)("div",{className:"entry-detail-label",title:e.name,children:e.name}),(0,n.jsx)("div",{className:"entry-detail-value",children:y===e.name?"tags"===e.type?(0,n.jsxs)("div",{className:"flex items-center gap-1 w-full",children:[(0,n.jsx)("div",{className:"flex-1 px-2 py-0.5 rounded-md",style:{background:"var(--color-surface-hover)",border:"2px solid var(--color-accent)"},children:(0,n.jsx)(iC,{value:im(t),onChange:t=>{W(e.name,t)},autoFocus:!0})}),(0,n.jsx)("button",{type:"button",onClick:()=>b(null),className:"px-1.5 py-0.5 text-xs rounded-md flex-shrink-0",style:{color:"var(--color-text-muted)",border:"1px solid var(--color-border)"},children:"Done"})]}):"relation"===e.type&&e.related_object_name?(0,n.jsxs)("div",{className:"flex items-center gap-1 w-full",children:[(0,n.jsx)("div",{className:"flex-1 min-w-0",children:(0,n.jsx)(tl,{relatedObjectName:e.related_object_name,value:im(t),multiple:"many_to_many"===e.relationship_type,onChange:t=>{W(e.name,t)},autoFocus:!0})}),(0,n.jsx)("button",{type:"button",onClick:()=>b(null),className:"px-1.5 py-0.5 text-xs rounded-md flex-shrink-0",style:{color:"var(--color-text-muted)",border:"1px solid var(--color-border)"},children:"Cancel"})]}):(0,n.jsxs)("form",{onSubmit:t=>{t.preventDefault(),W(e.name,j)},className:"flex items-center gap-1 w-full",children:["enum"===e.type&&e.enum_values?(0,n.jsxs)("select",{value:j,onChange:t=>{k(t.target.value),W(e.name,t.target.value)},autoFocus:!0,className:"flex-1 min-w-0 px-2 py-0.5 text-sm rounded-md outline-none",style:{background:"var(--color-surface-hover)",color:"var(--color-text)",border:"2px solid var(--color-accent)"},children:[(0,n.jsx)("option",{value:"",children:"--"}),e.enum_values.map(e=>(0,n.jsx)("option",{value:e,children:e},e))]}):"boolean"===e.type?(0,n.jsxs)("select",{value:j,onChange:t=>{k(t.target.value),W(e.name,t.target.value)},autoFocus:!0,className:"flex-1 min-w-0 px-2 py-0.5 text-sm rounded-md outline-none",style:{background:"var(--color-surface-hover)",color:"var(--color-text)",border:"2px solid var(--color-accent)"},children:[(0,n.jsx)("option",{value:"true",children:"Yes"}),(0,n.jsx)("option",{value:"false",children:"No"})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("input",{type:function(e){switch(e){case"number":return"number";case"date":return"date";case"email":return"email";case"phone":return"tel";case"url":return"url";default:return"text"}}(e.type),value:j,onChange:e=>k(e.target.value),autoFocus:!0,className:"flex-1 min-w-0 px-2 py-0.5 text-sm rounded-md outline-none",style:{background:"var(--color-surface-hover)",color:"var(--color-text)",border:"2px solid var(--color-accent)"}}),(0,n.jsx)("button",{type:"submit",disabled:w,className:"px-1.5 py-0.5 text-xs rounded-md font-medium flex-shrink-0",style:{background:"var(--color-accent)",color:"white"},children:w?"...":"Save"})]}),(0,n.jsx)("button",{type:"button",onClick:()=>b(null),className:"px-1.5 py-0.5 text-xs rounded-md flex-shrink-0",style:{color:"var(--color-text-muted)",border:"1px solid var(--color-border)"},children:"Cancel"})]}):(0,n.jsx)("div",{className:"py-0.5 px-1.5 -mx-1.5 rounded-md transition-colors ".concat(["user"].includes(e.type)?"":"cursor-pointer hover:bg-[var(--color-surface-hover)]"),onClick:()=>{["user"].includes(e.type)||(b(e.name),k(im(t)))},title:["user"].includes(e.type)?void 0:"Click to edit",children:(0,n.jsx)(iM,{value:t,field:e,members:l,relationLabels:h.relationLabels,onNavigateEntry:c})})})]},e.id)}),M?(0,n.jsx)(iT,{objectName:t,onCreated:z,onCancel:()=>L(!1)}):(0,n.jsxs)("button",{type:"button",onClick:()=>L(!0),className:"flex items-center gap-1.5 text-xs py-1.5 px-1 rounded-md hover:bg-[var(--color-surface-hover)] transition-colors mt-1",style:{color:"var(--color-text-muted)"},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M12 5v14"}),(0,n.jsx)("path",{d:"M5 12h14"})]}),"Add a property"]}),G.length>0&&(0,n.jsxs)("div",{className:"mt-3 pt-3",style:{borderTop:"1px solid var(--color-border)"},children:[(0,n.jsx)("div",{className:"text-[11px] font-medium uppercase tracking-wider mb-2",style:{color:"var(--color-text-muted)"},children:"Actions"}),(0,n.jsx)("div",{className:"flex flex-wrap gap-2",children:G.map(e=>(function(e){if(!e)return[];try{let t=JSON.parse(e);if(t&&Array.isArray(t.actions))return t.actions}catch(e){}return[]})(e.default_value).map(o=>(0,n.jsx)(t1,{action:o,entryId:r,objectName:t,fieldId:e.id,onToast:T,onRequestConfirm:(e,t,r)=>{var n;F({open:!0,title:e.label,message:null!=(n=e.confirmMessage)?n:'Run "'.concat(e.label,'" on this entry?'),variant:"destructive"===e.variant?"destructive":"default",confirmLabel:e.label,onConfirm:()=>{F(null),r()}})}},"".concat(e.id,"_").concat(o.id))))})]})]}),!K&&h.reverseRelations&&h.reverseRelations.length>0&&(0,n.jsxs)("div",{className:"pb-2 space-y-2",children:[(0,n.jsx)("div",{className:"text-[10px] font-medium uppercase tracking-widest",style:{color:"var(--color-text-muted)",opacity:.6},children:"Linked from"}),h.reverseRelations.map(e=>(0,n.jsx)(iL,{relation:e,onNavigateEntry:c},"".concat(e.sourceObjectName,"_").concat(e.fieldName)))]}),(null!=H||null!=V)&&(0,n.jsxs)("div",{className:"pb-2 text-[11px] flex gap-3 flex-wrap",style:{color:"var(--color-text-muted)"},children:[null!=H&&(0,n.jsxs)("span",{children:["Created: ",(0,n.jsx)(tG,{value:H,fieldType:"date",mode:"detail",className:"inline"})]}),null!=V&&(0,n.jsxs)("span",{children:["Updated: ",(0,n.jsx)(tG,{value:V,fieldType:"date",mode:"detail",className:"inline"})]})]})]})]}),!m&&!v&&(0,n.jsx)("div",{className:"entry-detail-editor",children:D?(0,n.jsx)("div",{className:"px-5 py-6",children:(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)("div",{className:"h-3 w-3/4 rounded animate-pulse",style:{background:"var(--color-surface-hover)"}}),(0,n.jsx)("div",{className:"h-3 w-1/2 rounded animate-pulse",style:{background:"var(--color-surface-hover)"}})]})}):(0,n.jsx)(ix.MarkdownEditor,{content:I,filePath:_,tree:a,onSave:u,onNavigate:p,searchFn:s})})]}),B&&(0,n.jsx)(t2,{open:B.open,title:B.title,message:B.message,variant:B.variant,confirmLabel:B.confirmLabel,onConfirm:B.onConfirm,onCancel:()=>F(null)})]})}var i_=r(91365);let iE={keys:[{name:"label",weight:3},{name:"sublabel",weight:1},{name:"objectName",weight:1.5},{name:"fieldValues",weight:2}],threshold:.4,distance:200,includeScore:!0,shouldSort:!0,minMatchCharLength:1},iD=new Set(["ts","tsx","js","jsx","mjs","cjs","py","rb","go","rs","java","kt","swift","c","cpp","h","hpp","cs","css","scss","less","html","htm","xml","svg","json","jsonc","yaml","yml","toml","sh","bash","zsh","fish","ps1","sql","graphql","gql","dockerfile","makefile","cmake","r","lua","php","vue","svelte","diff","patch","ini","env","tf","proto","zig","elixir","ex","erl","hs","scala","clj","dart"]);function iA(e){var t,r;let n=null!=(r=null==(t=e.split(".").pop())?void 0:t.toLowerCase())?r:"";return iD.has(n)}function iW(e){if(e<=0)return"now";let t=Math.ceil(e/1e3);if(t<60)return"".concat(t,"s");let r=Math.floor(t/60),n=t%60;if(r<60)return n>0?"".concat(r,"m ").concat(n,"s"):"".concat(r,"m");let o=Math.floor(r/60),l=r%60;return l>0?"".concat(o,"h ").concat(l,"m"):"".concat(o,"h")}function iB(e){return e<1e3?"".concat(e,"ms"):e<6e4?"".concat((e/1e3).toFixed(1),"s"):"".concat(Math.floor(e/6e4),"m ").concat(Math.floor(e%6e4/1e3),"s")}function iF(e){switch(e){case"ok":return"var(--color-success, #22c55e)";case"running":return"var(--color-accent)";case"error":return"var(--color-error, #ef4444)";case"disabled":default:return"var(--color-text-muted)";case"skipped":return"var(--color-warning, #f59e0b)"}}function iP(e){let[t,r]=(0,o.useState)(Date.now());return((0,o.useEffect)(()=>{if(!e)return;let t=setInterval(()=>r(Date.now()),1e3);return()=>clearInterval(t)},[e]),e)?iW(e-t):null}let iz=[{id:"overview",label:"Overview"},{id:"calendar",label:"Calendar"},{id:"insights",label:"Insights"}];function iO(e){let{onSelectJob:t,onSendCommand:r,activeView:l="overview",onViewChange:a,calendarMode:s="month",onCalendarModeChange:i,calendarDate:c,onCalendarDateChange:d}=e,[u,p]=(0,o.useState)([]),[h,x]=(0,o.useState)({intervalMs:18e5,nextDueEstimateMs:null}),[m,f]=(0,o.useState)({enabled:!1,nextWakeAtMs:null}),[v,g]=(0,o.useState)(!0),[y,b]=(0,o.useState)([]),j=(0,o.useCallback)(async()=>{try{var e,t,r,n;let o=await fetch("/api/cron/jobs"),l=await o.json();p(null!=(e=l.jobs)?e:[]),x(null!=(t=l.heartbeat)?t:{intervalMs:18e5,nextDueEstimateMs:null}),f(null!=(r=l.cronStatus)?r:{enabled:!1,nextWakeAtMs:null});let a=(null!=(n=l.jobs)?n:[]).map(e=>e.id).map(async e=>{try{var t;let r=await fetch("/api/cron/jobs/".concat(encodeURIComponent(e),"/runs?limit=50"));return null!=(t=(await r.json()).entries)?t:[]}catch(e){return[]}}),s=await Promise.all(a);b(s.flat().toSorted((e,t)=>t.ts-e.ts))}catch(e){}finally{g(!1)}},[]);(0,o.useEffect)(()=>{j();let e=setInterval(()=>void j(),15e3);return()=>clearInterval(e)},[j]);let k=iP(h.nextDueEstimateMs),w=iP(m.nextWakeAtMs);if(v)return(0,n.jsx)("div",{className:"flex items-center justify-center h-full p-8",children:(0,n.jsx)("div",{className:"w-6 h-6 border-2 rounded-full animate-spin",style:{borderColor:"var(--color-border)",borderTopColor:"var(--color-accent)"}})});let N=u.filter(e=>e.enabled),C=u.filter(e=>!e.enabled);return(0,n.jsxs)("div",{className:"p-6 max-w-5xl mx-auto",children:[(0,n.jsx)("div",{className:"flex items-end justify-between mb-6",children:(0,n.jsxs)("div",{children:[(0,n.jsx)("h1",{className:"font-instrument text-3xl tracking-tight mb-1",style:{color:"var(--color-text)"},children:"Cron"}),(0,n.jsxs)("p",{className:"text-sm",style:{color:"var(--color-text-muted)"},children:[N.length," active job",1!==N.length?"s":"",C.length>0&&" / ".concat(C.length," disabled")]})]})}),(0,n.jsx)("div",{className:"flex items-center gap-1 mb-6 rounded-xl p-1",style:{background:"var(--color-surface-hover)"},children:iz.map(e=>(0,n.jsx)("button",{type:"button",onClick:()=>null==a?void 0:a(e.id),className:"px-4 py-1.5 rounded-lg text-sm font-medium transition-all cursor-pointer",style:{background:l===e.id?"var(--color-surface)":"transparent",color:l===e.id?"var(--color-text)":"var(--color-text-muted)",boxShadow:l===e.id?"var(--shadow-sm)":"none"},children:e.label},e.id))}),"overview"===l&&(0,n.jsx)(iU,{jobs:u,enabledJobs:N,disabledJobs:C,heartbeatCountdown:k,heartbeat:h,cronWakeCountdown:w,onSelectJob:t,onSendCommand:r}),"calendar"===l&&(0,n.jsx)(i$,{jobs:u,allRuns:y,mode:s,onModeChange:i,dateAnchor:c,onDateChange:d,onSelectJob:t}),"insights"===l&&(0,n.jsx)(i0,{jobs:u,allRuns:y,onSelectJob:t})]})}function iU(e){let{jobs:t,enabledJobs:r,disabledJobs:o,heartbeatCountdown:l,heartbeat:a,cronWakeCountdown:s,onSelectJob:i,onSendCommand:c}=e;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4 mb-8",children:[(0,n.jsx)(i2,{title:"Heartbeat",icon:(0,n.jsx)(i6,{}),value:l?"in ".concat(l):"unknown",subtitle:"Interval: ".concat(iW(a.intervalMs))}),(0,n.jsx)(i2,{title:"Cron Scheduler",icon:(0,n.jsx)(i8,{}),value:s?"next in ".concat(s):0===t.length?"no jobs":"idle",subtitle:"".concat(r.length," active / ").concat(t.length," total jobs")}),(0,n.jsx)(i2,{title:"Active Runs",icon:(0,n.jsx)(i7,{}),value:"".concat(t.filter(e=>e.state.runningAtMs).length),subtitle:(()=>{let e=t.filter(e=>e.state.runningAtMs),r=t.filter(e=>"error"===e.state.lastStatus).length;return e.length>0?e.map(e=>e.name).join(", "):r>0?"".concat(r," with errors"):"All clear"})()})]}),(0,n.jsx)(i4,{jobs:r}),(0,n.jsx)(i5,{jobs:[...r,...o],onSelectJob:i,onSendCommand:c})]})}function iH(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function iV(e){let t=iH(e);return t.setDate(t.getDate()-t.getDay()),t}function iK(e,t){let r=iH(e);return r.setDate(r.getDate()+t),r}function iJ(e){return"".concat(e.getFullYear(),"-").concat(String(e.getMonth()+1).padStart(2,"0"),"-").concat(String(e.getDate()).padStart(2,"0"))}function iq(e,t,r){let n=new Set;for(let o of e.split(",")){let e=o.match(/^(.+)\/(\d+)$/),l=e?parseInt(e[2],10):1,a=e?e[1]:o;if("*"===a)for(let e=t;e<=r;e+=l)n.add(e);else if(a.includes("-")){let[e,t]=a.split("-").map(Number);for(let r=e;r<=t;r+=l)n.add(r)}else n.add(parseInt(a,10))}return[...n].filter(e=>e>=t&&e<=r).sort((e,t)=>e-t)}function iG(e){var t,r,o,l,a;let{ev:s,onSelectJob:i}=e,c=new Date(s.at).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});if("scheduled"===s.kind)return(0,n.jsxs)("button",{type:"button",onClick:()=>i(s.job.id),className:"w-full text-left text-[10px] px-1.5 py-0.5 rounded truncate cursor-pointer",style:{background:"color-mix(in srgb, var(--color-accent) 15%, transparent)",color:"var(--color-accent)"},title:"Scheduled: ".concat(s.job.name," at ").concat(c),children:[c," ",s.job.name]});let d="ok"===s.run.status?"var(--color-success, #22c55e)":"error"===s.run.status?"var(--color-error, #ef4444)":"var(--color-text-muted)";return(0,n.jsxs)("button",{type:"button",onClick:()=>s.job&&i(s.job.id),className:"w-full text-left text-[10px] px-1.5 py-0.5 rounded truncate flex items-center gap-1 cursor-pointer",style:{background:"color-mix(in srgb, ".concat(d," 10%, transparent)"),color:d},title:"".concat(null!=(o=s.run.status)?o:"finished",": ").concat(null!=(l=null==(t=s.job)?void 0:t.name)?l:s.run.jobId," at ").concat(c),children:[(0,n.jsx)("span",{className:"w-1 h-1 rounded-full flex-shrink-0",style:{background:d}}),(0,n.jsxs)("span",{className:"truncate",children:[c," ",null!=(a=null==(r=s.job)?void 0:r.name)?a:s.run.jobId.slice(0,8)]})]})}function i$(e){var t;let{jobs:r,allRuns:l,mode:a="month",onModeChange:s,dateAnchor:i,onDateChange:c,onSelectJob:d}=e,u=null!=(t=function(e){if(!e)return null;let t=e.match(/^(\d{4})-(\d{2})-(\d{2})$/);if(t)return new Date(Number(t[1]),Number(t[2])-1,Number(t[3]));let r=new Date(e);return Number.isNaN(r.getTime())?null:iH(r)}(i))?t:iH(new Date),p=e=>{let t="month"===a?function(e,t){let r=new Date(e.getFullYear(),e.getMonth(),1);r.setMonth(r.getMonth()+t);let n=new Date(r.getFullYear(),r.getMonth()+1,0).getDate();return r.setDate(Math.min(e.getDate(),n)),r}(u,e):"week"===a?iK(u,7*e):"day"===a?iK(u,e):function(e,t){let r=new Date(e.getFullYear()+t,e.getMonth(),1),n=new Date(r.getFullYear(),r.getMonth()+1,0).getDate();return r.setDate(Math.min(e.getDate(),n)),r}(u,e);null==c||c(iJ(t))},h=(0,o.useMemo)(()=>{let e=new Map;for(let t of r)e.set(t.id,t);return e},[r]),{rangeFrom:x,rangeTo:m}=(0,o.useMemo)(()=>{let e=u.getFullYear(),t=u.getMonth();if("day"===a){let r=new Date(e,t,u.getDate());return{rangeFrom:r.getTime(),rangeTo:iK(r,1).getTime()}}if("week"===a){let e=iV(u);return{rangeFrom:e.getTime(),rangeTo:iK(e,7).getTime()}}if("year"===a)return{rangeFrom:new Date(e,0,1).getTime(),rangeTo:new Date(e+1,0,1).getTime()};let r=iV(new Date(e,t,1));return{rangeFrom:r.getTime(),rangeTo:iK(r,42).getTime()}},[u,a]),f=(0,o.useMemo)(()=>(function(e,t,r,n,o){var l,a,s;let i=new Map,c=Date.now();for(let t of e){let e=null!=(l=t.runAtMs)?l:t.ts;if(e<n||e>=o)continue;let s=iJ(new Date(e)),c=null!=(a=i.get(s))?a:[];c.push({kind:"run",run:t,job:r.get(t.jobId),at:e}),i.set(s,c)}for(let e of t)if(e.enabled)for(let t of function(e,t,r){if(!e.enabled)return[];let n=e.schedule;switch(n.kind){case"at":{let e=new Date(n.at).getTime();return e>=t&&e<r?[e]:[]}case"every":{var o,l;let a=n.everyMs;if(a<=0)return[];let s=null!=(l=null!=(o=n.anchorMs)?o:e.createdAtMs)?l:t,i=[],c=s;if(c<t){let e=Math.floor((t-c)/a);c+=e*a}for(;c<r&&i.length<5e3;)c>=t&&i.push(c),c+=a;return i}case"cron":return function(e,t,r,n){let o=e.trim().split(/\s+/);if(o.length<5)return[];let l=iq(o[0],0,59),a=iq(o[1],0,23),s=iq(o[2],1,31),i=iq(o[3],1,12),c=iq(o[4],0,6),d="*"===o[2],u="*"===o[4],p=[],h=new Date(t);h.setSeconds(0,0);let x=0;for(;h.getTime()<r&&x++<5e4;){if(!i.includes(h.getMonth()+1)){h.setMonth(h.getMonth()+1,1),h.setHours(0,0,0,0);continue}let e=d||s.includes(h.getDate()),n=u||c.includes(h.getDay());if(!(d&&u||(d||u?e&&n:e||n))){h.setDate(h.getDate()+1),h.setHours(0,0,0,0);continue}for(let e of a)for(let n of l){let o=new Date(h.getFullYear(),h.getMonth(),h.getDate(),e,n,0,0).getTime();o>=t&&o<r&&p.push(o)}h.setDate(h.getDate()+1),h.setHours(0,0,0,0)}return p}(n.expr,t,r,n.tz);default:return[]}}(e,n,o)){if(t<c)continue;let r=iJ(new Date(t)),n=null!=(s=i.get(r))?s:[];n.push({kind:"scheduled",job:e,at:t}),i.set(r,n)}for(let e of i.values())e.sort((e,t)=>{var r,n,o,l;if(e.at!==t.at)return e.at-t.at;let a="run"===e.kind?null!=(o=null==(r=e.job)?void 0:r.name)?o:e.run.jobId:e.job.name,s="run"===t.kind?null!=(l=null==(n=t.job)?void 0:n.name)?l:t.run.jobId:t.job.name;return a.localeCompare(s)});return i})(l,r,h,x,m),[l,r,h,x,m]),v=(0,o.useMemo)(()=>{if("day"===a)return u.toLocaleDateString(void 0,{weekday:"long",month:"long",day:"numeric",year:"numeric"});if("week"===a){let e=iV(u),t=new Date(e);return(t.setDate(t.getDate()+6),e.getMonth()===t.getMonth())?"".concat(e.toLocaleDateString(void 0,{month:"long"})," ").concat(e.getDate(),"–").concat(t.getDate(),", ").concat(e.getFullYear()):"".concat(e.toLocaleDateString(void 0,{month:"short",day:"numeric"})," – ").concat(t.toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"}))}return"year"===a?String(u.getFullYear()):u.toLocaleDateString(void 0,{month:"long",year:"numeric"})},[u,a]),g=iJ(new Date);return(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("button",{type:"button",onClick:()=>p(-1),className:"p-1.5 rounded-lg cursor-pointer",style:{color:"var(--color-text-muted)"},children:(0,n.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"m15 18-6-6 6-6"})})}),(0,n.jsx)("h2",{className:"text-lg font-semibold",style:{color:"var(--color-text)"},children:v}),(0,n.jsx)("button",{type:"button",onClick:()=>p(1),className:"p-1.5 rounded-lg cursor-pointer",style:{color:"var(--color-text-muted)"},children:(0,n.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"m9 18 6-6-6-6"})})}),(0,n.jsx)("button",{type:"button",onClick:()=>null==c?void 0:c(iJ(new Date)),className:"text-xs px-2.5 py-1 rounded-lg ml-2 cursor-pointer",style:{background:"var(--color-surface-hover)",color:"var(--color-text-muted)"},children:"Today"})]}),(0,n.jsx)("div",{className:"flex items-center gap-1 rounded-lg p-0.5",style:{background:"var(--color-surface-hover)"},children:["day","week","month","year"].map(e=>(0,n.jsx)("button",{type:"button",onClick:()=>null==s?void 0:s(e),className:"px-3 py-1 rounded-md text-xs font-medium cursor-pointer",style:{background:a===e?"var(--color-surface)":"transparent",color:a===e?"var(--color-text)":"var(--color-text-muted)"},children:e.charAt(0).toUpperCase()+e.slice(1)},e))})]}),"day"===a&&(0,n.jsx)(iZ,{anchor:u,eventsByDay:f,todayStr:g,onSelectJob:d}),"week"===a&&(0,n.jsx)(iY,{anchor:u,eventsByDay:f,todayStr:g,onSelectJob:d,onDateChange:c,onModeChange:s}),"month"===a&&(0,n.jsx)(iQ,{anchor:u,eventsByDay:f,todayStr:g,onSelectJob:d}),"year"===a&&(0,n.jsx)(iX,{anchor:u,eventsByDay:f,todayStr:g,onDateChange:c,onModeChange:s})]})}function iZ(e){var t;let{anchor:r,eventsByDay:l,todayStr:a,onSelectJob:s}=e,i=iJ(r),c=null!=(t=l.get(i))?t:[],d=i===a,u=Array.from({length:24},(e,t)=>t),p=(0,o.useMemo)(()=>{let e=new Map;for(let r of c){var t;let n=new Date(r.at).getHours(),o=null!=(t=e.get(n))?t:[];o.push(r),e.set(n,o)}return e},[c]);return(0,n.jsx)("div",{className:"rounded-2xl overflow-hidden",style:{border:"1px solid var(--color-border)",background:"var(--color-surface)"},children:u.map(e=>{var t;let r=null!=(t=p.get(e))?t:[],o=new Date().getHours(),l=d&&e===o;return(0,n.jsxs)("div",{className:"flex",style:{borderBottom:e<23?"1px solid var(--color-border)":void 0,background:l?"color-mix(in srgb, var(--color-accent) 4%, transparent)":void 0},children:[(0,n.jsx)("div",{className:"w-16 flex-shrink-0 px-3 py-2 text-right text-[11px] font-medium",style:{color:"var(--color-text-muted)",borderRight:"1px solid var(--color-border)"},children:0===e?"12 AM":e<12?"".concat(e," AM"):12===e?"12 PM":"".concat(e-12," PM")}),(0,n.jsx)("div",{className:"flex-1 min-h-[36px] px-2 py-1 flex flex-wrap gap-1 items-start",children:r.map((e,t)=>(0,n.jsx)(iG,{ev:e,onSelectJob:s},t))})]},e)})})}function iY(e){let{anchor:t,eventsByDay:r,todayStr:o,onSelectJob:l,onDateChange:a,onModeChange:s}=e,i=iV(t),c=Array.from({length:7},(e,t)=>{let r=new Date(i);return r.setDate(r.getDate()+t),r});return(0,n.jsxs)("div",{className:"rounded-2xl overflow-hidden",style:{border:"1px solid var(--color-border)",background:"var(--color-surface)"},children:[(0,n.jsx)("div",{className:"grid grid-cols-7",style:{borderBottom:"1px solid var(--color-border)"},children:c.map(e=>{let t=iJ(e),r=t===o;return(0,n.jsxs)("button",{type:"button",onClick:()=>{null==a||a(t),null==s||s("day")},className:"px-2 py-2 text-center cursor-pointer",style:{borderRight:6>e.getDay()?"1px solid var(--color-border)":void 0},children:[(0,n.jsx)("div",{className:"text-[10px] font-medium uppercase tracking-wider",style:{color:"var(--color-text-muted)"},children:e.toLocaleDateString(void 0,{weekday:"short"})}),(0,n.jsx)("div",{className:"text-sm font-semibold",style:{color:r?"var(--color-accent)":"var(--color-text)"},children:e.getDate()})]},t)})}),(0,n.jsx)("div",{className:"grid grid-cols-7",children:c.map(e=>{var t;let a=iJ(e),s=null!=(t=r.get(a))?t:[],i=a===o;return(0,n.jsx)("div",{className:"min-h-[200px] p-1.5",style:{borderRight:6>e.getDay()?"1px solid var(--color-border)":void 0,background:i?"color-mix(in srgb, var(--color-accent) 4%, transparent)":void 0},children:(0,n.jsxs)("div",{className:"space-y-0.5",children:[s.slice(0,8).map((e,t)=>(0,n.jsx)(iG,{ev:e,onSelectJob:l},t)),s.length>8&&(0,n.jsxs)("div",{className:"text-[9px] px-1",style:{color:"var(--color-text-muted)"},children:["+",s.length-8," more"]})]})},a)})})]})}function iQ(e){let{anchor:t,eventsByDay:r,todayStr:l,onSelectJob:a}=e,s=(0,o.useMemo)(()=>{let e=iV(new Date(t.getFullYear(),t.getMonth(),1)),r=[];for(let t=0;t<6;t++){let n=[];for(let r=0;r<7;r++){let o=new Date(e);o.setDate(o.getDate()+7*t+r),n.push(o)}r.push(n)}return r},[t]);return(0,n.jsxs)("div",{className:"rounded-2xl overflow-hidden",style:{border:"1px solid var(--color-border)",background:"var(--color-surface)"},children:[(0,n.jsx)("div",{className:"grid grid-cols-7",style:{borderBottom:"1px solid var(--color-border)"},children:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].map(e=>(0,n.jsx)("div",{className:"px-2 py-2 text-center text-[11px] font-medium uppercase tracking-wider",style:{color:"var(--color-text-muted)"},children:e},e))}),s.map((e,o)=>(0,n.jsx)("div",{className:"grid grid-cols-7",style:{borderBottom:o<5?"1px solid var(--color-border)":void 0},children:e.map(e=>{var o;let s=iJ(e),i=null!=(o=r.get(s))?o:[],c=e.getMonth()===t.getMonth(),d=s===l;return(0,n.jsxs)("div",{className:"min-h-[80px] p-1.5",style:{borderRight:6>e.getDay()?"1px solid var(--color-border)":void 0,opacity:c?1:.4,background:d?"color-mix(in srgb, var(--color-accent) 5%, transparent)":void 0},children:[(0,n.jsx)("div",{className:"text-xs font-medium mb-1",style:{color:d?"var(--color-accent)":"var(--color-text-muted)"},children:e.getDate()}),(0,n.jsxs)("div",{className:"space-y-0.5",children:[i.slice(0,3).map((e,t)=>(0,n.jsx)(iG,{ev:e,onSelectJob:a},t)),i.length>3&&(0,n.jsxs)("div",{className:"text-[9px] px-1",style:{color:"var(--color-text-muted)"},children:["+",i.length-3," more"]})]})]},s)})},o))]})}function iX(e){let{anchor:t,eventsByDay:r,todayStr:o,onDateChange:l,onModeChange:a}=e,s=t.getFullYear(),i=Array.from({length:12},(e,t)=>t);return(0,n.jsx)("div",{className:"grid grid-cols-3 sm:grid-cols-4 gap-4",children:i.map(e=>{let t=new Date(s,e,1),i=t.getDay(),c=new Date(s,e+1,0).getDate(),d=[];for(let e=0;e<i;e++)d.push(null);for(let e=1;e<=c;e++)d.push(e);return(0,n.jsxs)("button",{type:"button",onClick:()=>{null==l||l(iJ(t)),null==a||a("month")},className:"rounded-xl p-3 text-left cursor-pointer transition-colors",style:{background:"var(--color-surface)",border:"1px solid var(--color-border)"},onMouseEnter:e=>{e.currentTarget.style.background="var(--color-surface-hover)"},onMouseLeave:e=>{e.currentTarget.style.background="var(--color-surface)"},children:[(0,n.jsx)("div",{className:"text-xs font-semibold mb-2",style:{color:"var(--color-text)"},children:t.toLocaleDateString(void 0,{month:"short"})}),(0,n.jsxs)("div",{className:"grid grid-cols-7 gap-px",children:[["S","M","T","W","T","F","S"].map((e,t)=>(0,n.jsx)("div",{className:"text-[8px] text-center font-medium",style:{color:"var(--color-text-muted)"},children:e},t)),d.map((t,l)=>{var a;if(null===t)return(0,n.jsx)("div",{},"e-".concat(l));let i="".concat(s,"-").concat(String(e+1).padStart(2,"0"),"-").concat(String(t).padStart(2,"0")),c=null!=(a=r.get(i))?a:[],d=i===o,u=c.length>0,p=c.some(e=>"run"===e.kind&&"error"===e.run.status);return(0,n.jsx)("div",{className:"text-[9px] text-center rounded-sm leading-[16px]",style:{color:d?"var(--color-accent)":u?"var(--color-text)":"var(--color-text-muted)",fontWeight:d||u?600:400,background:p?"color-mix(in srgb, var(--color-error, #ef4444) 15%, transparent)":u?"color-mix(in srgb, var(--color-accent) 10%, transparent)":void 0},children:t},i)})]}),(()=>{let t=0;for(let n=1;n<=c;n++){var o;let l="".concat(s,"-").concat(String(e+1).padStart(2,"0"),"-").concat(String(n).padStart(2,"0"));t+=(null!=(o=r.get(l))?o:[]).length}return t>0?(0,n.jsxs)("div",{className:"text-[9px] mt-1.5",style:{color:"var(--color-text-muted)"},children:[t," event",1!==t?"s":""]}):null})()]},e)})})}function i0(e){let{jobs:t,allRuns:r,onSelectJob:l}=e,a=(0,o.useMemo)(()=>{let e=r.length,n=r.filter(e=>"ok"===e.status).length,o=r.filter(e=>"error"===e.status).length,l=e>0?r.filter(e=>null!=e.durationMs).reduce((e,t)=>{var r;return e+(null!=(r=t.durationMs)?r:0)},0)/Math.max(1,r.filter(e=>null!=e.durationMs).length):0,a=e>0?Math.round(n/e*100):0,s=Date.now(),i=[];for(let e=13;e>=0;e--){let t=s-864e5*e,n=t+864e5,o=r.filter(e=>e.ts>=t&&e.ts<n),l=new Date(t);i.push({day:"".concat(l.getMonth()+1,"/").concat(l.getDate()),ok:o.filter(e=>"ok"===e.status).length,error:o.filter(e=>"error"===e.status).length,other:o.filter(e=>"ok"!==e.status&&"error"!==e.status).length})}return{total:e,ok:n,errors:o,avgDuration:l,successRate:a,runsByDay:i,jobStats:t.map(e=>{let t=r.filter(t=>t.jobId===e.id),n=t.filter(e=>"ok"===e.status).length,o=t.filter(e=>"error"===e.status).length,l=t.filter(e=>null!=e.durationMs).length>0?t.filter(e=>null!=e.durationMs).reduce((e,t)=>{var r;return e+(null!=(r=t.durationMs)?r:0)},0)/t.filter(e=>null!=e.durationMs).length:0;return{job:e,runs:t.length,ok:n,errors:o,avgDuration:l}}).toSorted((e,t)=>t.runs-e.runs)}},[r,t]);return(0,n.jsxs)("div",{className:"space-y-6",children:[(0,n.jsxs)("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[(0,n.jsx)(i1,{label:"Total Runs",value:String(a.total)}),(0,n.jsx)(i1,{label:"Success Rate",value:"".concat(a.successRate,"%"),accent:a.successRate>=90?"var(--color-success, #22c55e)":a.successRate>=70?"var(--color-warning, #f59e0b)":"var(--color-error, #ef4444)"}),(0,n.jsx)(i1,{label:"Errors",value:String(a.errors),accent:a.errors>0?"var(--color-error, #ef4444)":void 0}),(0,n.jsx)(i1,{label:"Avg Duration",value:iB(a.avgDuration)})]}),(0,n.jsxs)("div",{className:"rounded-2xl p-4",style:{background:"var(--color-surface)",border:"1px solid var(--color-border)"},children:[(0,n.jsx)("h3",{className:"text-xs font-medium uppercase tracking-wider mb-4",style:{color:"var(--color-text-muted)"},children:"Runs (Last 14 Days)"}),(0,n.jsx)("div",{className:"flex items-end gap-1 h-32",children:a.runsByDay.map(e=>{let t=Math.max(...a.runsByDay.map(e=>e.ok+e.error+e.other),1),r=e.ok+e.error+e.other,o=Math.max(2,r/t*100),l=r>0?e.ok/r*100:100;return(0,n.jsxs)("div",{className:"flex-1 flex flex-col items-center gap-1",children:[(0,n.jsx)("div",{className:"w-full flex flex-col justify-end",style:{height:"100%"},children:(0,n.jsx)("div",{className:"w-full rounded-t-sm",style:{height:"".concat(o,"%"),background:0===r?"var(--color-surface-hover)":100===l?"var(--color-success, #22c55e)":l>50?"color-mix(in srgb, var(--color-success, #22c55e) 60%, var(--color-error, #ef4444))":"var(--color-error, #ef4444)",opacity:0===r?.3:.7},title:"".concat(e.day,": ").concat(e.ok," ok, ").concat(e.error," errors")})}),(0,n.jsx)("span",{className:"text-[9px]",style:{color:"var(--color-text-muted)"},children:e.day})]},e.day)})}),(0,n.jsxs)("div",{className:"flex items-center gap-4 mt-3",children:[(0,n.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,n.jsx)("span",{className:"w-2 h-2 rounded-sm",style:{background:"var(--color-success, #22c55e)",opacity:.7}}),(0,n.jsx)("span",{className:"text-[10px]",style:{color:"var(--color-text-muted)"},children:"Success"})]}),(0,n.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,n.jsx)("span",{className:"w-2 h-2 rounded-sm",style:{background:"var(--color-error, #ef4444)",opacity:.7}}),(0,n.jsx)("span",{className:"text-[10px]",style:{color:"var(--color-text-muted)"},children:"Error"})]})]})]}),(0,n.jsxs)("div",{className:"rounded-2xl overflow-hidden",style:{border:"1px solid var(--color-border)",background:"var(--color-surface)"},children:[(0,n.jsx)("div",{className:"px-4 py-3",style:{borderBottom:"1px solid var(--color-border)"},children:(0,n.jsx)("h3",{className:"text-xs font-medium uppercase tracking-wider",style:{color:"var(--color-text-muted)"},children:"Per-Job Breakdown"})}),a.jobStats.map(e=>{let t=e.runs>0?Math.round(e.ok/e.runs*100):0;return(0,n.jsxs)("button",{type:"button",onClick:()=>l(e.job.id),className:"w-full flex items-center gap-3 px-4 py-3 text-left cursor-pointer transition-colors",style:{borderBottom:"1px solid var(--color-border)"},onMouseEnter:e=>{e.currentTarget.style.background="var(--color-surface-hover)"},onMouseLeave:e=>{e.currentTarget.style.background="transparent"},children:[(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsx)("div",{className:"text-sm font-medium truncate",style:{color:"var(--color-text)"},children:e.job.name}),(0,n.jsxs)("div",{className:"text-xs",style:{color:"var(--color-text-muted)"},children:[e.runs," runs / ",t,"% success / avg ",iB(e.avgDuration)]})]}),(0,n.jsx)("div",{className:"w-24 h-2 rounded-full overflow-hidden flex-shrink-0",style:{background:"var(--color-surface-hover)"},children:(0,n.jsx)("div",{className:"h-full rounded-full",style:{width:"".concat(t,"%"),background:t>=90?"var(--color-success, #22c55e)":t>=70?"var(--color-warning, #f59e0b)":"var(--color-error, #ef4444)"}})}),null!=e.job.state.consecutiveErrors&&e.job.state.consecutiveErrors>0&&(0,n.jsxs)("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full flex-shrink-0",style:{background:"color-mix(in srgb, var(--color-error, #ef4444) 12%, transparent)",color:"var(--color-error, #ef4444)"},children:[e.job.state.consecutiveErrors," err"]})]},e.job.id)})]})]})}function i1(e){let{label:t,value:r,accent:o}=e;return(0,n.jsxs)("div",{className:"rounded-xl p-3",style:{background:"var(--color-surface)",border:"1px solid var(--color-border)"},children:[(0,n.jsx)("div",{className:"text-[11px] font-medium uppercase tracking-wider mb-1",style:{color:"var(--color-text-muted)"},children:t}),(0,n.jsx)("div",{className:"text-xl font-semibold",style:{color:null!=o?o:"var(--color-text)"},children:r})]})}function i2(e){let{title:t,icon:r,value:o,subtitle:l}=e;return(0,n.jsxs)("div",{className:"rounded-2xl p-4",style:{background:"var(--color-surface)",border:"1px solid var(--color-border)"},children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,n.jsx)("span",{style:{color:"var(--color-accent)"},children:r}),(0,n.jsx)("span",{className:"text-xs font-medium uppercase tracking-wider",style:{color:"var(--color-text-muted)"},children:t})]}),(0,n.jsx)("div",{className:"text-lg font-semibold mb-0.5",style:{color:"var(--color-text)"},children:o}),(0,n.jsx)("div",{className:"text-xs",style:{color:"var(--color-text-muted)"},children:l})]})}function i4(e){let{jobs:t}=e,[r,l]=(0,o.useState)(Date.now());(0,o.useEffect)(()=>{let e=setInterval(()=>l(Date.now()),1e4);return()=>clearInterval(e)},[]);let a=t.filter(e=>e.state.nextRunAtMs&&e.state.nextRunAtMs>r&&e.state.nextRunAtMs<r+864e5).toSorted((e,t)=>{var r,n;return(null!=(r=e.state.nextRunAtMs)?r:0)-(null!=(n=t.state.nextRunAtMs)?n:0)});return 0===a.length?null:(0,n.jsxs)("div",{className:"mb-8",children:[(0,n.jsx)("h2",{className:"text-sm font-medium uppercase tracking-wider mb-3",style:{color:"var(--color-text-muted)"},children:"Upcoming (next 24h)"}),(0,n.jsx)("div",{className:"rounded-2xl p-4",style:{background:"var(--color-surface)",border:"1px solid var(--color-border)"},children:(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsx)("div",{className:"absolute top-0 left-3 bottom-0 w-px",style:{background:"var(--color-border)"}}),(0,n.jsx)("div",{className:"space-y-3",children:a.map(e=>{var t;return(0,n.jsxs)("div",{className:"flex items-center gap-3 pl-1",children:[(0,n.jsx)("div",{className:"relative z-10 w-5 h-5 rounded-full flex items-center justify-center flex-shrink-0",style:{background:"var(--color-accent)",opacity:.8},children:(0,n.jsx)("div",{className:"w-2 h-2 rounded-full",style:{background:"var(--color-bg)"}})}),(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsx)("span",{className:"text-sm font-medium",style:{color:"var(--color-text)"},children:e.name}),(0,n.jsxs)("span",{className:"text-xs ml-2",style:{color:"var(--color-text-muted)"},children:["in ",iW((null!=(t=e.state.nextRunAtMs)?t:0)-r)]})]}),(0,n.jsx)("span",{className:"text-[11px] flex-shrink-0",style:{color:"var(--color-text-muted)"},children:new Date(e.state.nextRunAtMs).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]},e.id)})})]})})]})}function i5(e){let{jobs:t,onSelectJob:r,onSendCommand:o}=e;return(0,n.jsxs)("div",{className:"mb-6",children:[(0,n.jsx)("h2",{className:"text-sm font-medium uppercase tracking-wider mb-3",style:{color:"var(--color-text-muted)"},children:"Jobs"}),0===t.length?(0,n.jsx)("div",{className:"p-8 text-center rounded-2xl",style:{background:"var(--color-surface)",border:"1px solid var(--color-border)"},children:(0,n.jsx)("p",{className:"text-sm",style:{color:"var(--color-text-muted)"},children:"No cron jobs configured."})}):(0,n.jsx)("div",{className:"rounded-2xl overflow-hidden",style:{border:"1px solid var(--color-border)",background:"var(--color-surface)"},children:(0,n.jsxs)("table",{className:"w-full text-sm",children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{style:{borderBottom:"1px solid var(--color-border)",color:"var(--color-text-muted)"},children:[(0,n.jsx)("th",{className:"text-left px-4 py-2.5 font-medium text-xs uppercase tracking-wider",children:"Name"}),(0,n.jsx)("th",{className:"text-left px-4 py-2.5 font-medium text-xs uppercase tracking-wider",children:"Schedule"}),(0,n.jsx)("th",{className:"text-left px-4 py-2.5 font-medium text-xs uppercase tracking-wider",children:"Status"}),(0,n.jsx)("th",{className:"text-left px-4 py-2.5 font-medium text-xs uppercase tracking-wider",children:"Next Run"}),(0,n.jsx)("th",{className:"text-left px-4 py-2.5 font-medium text-xs uppercase tracking-wider",children:"Last Run"}),(0,n.jsx)("th",{className:"text-left px-4 py-2.5 font-medium text-xs uppercase tracking-wider w-20"})]})}),(0,n.jsx)("tbody",{children:t.map(e=>(0,n.jsx)(i3,{job:e,onClick:()=>r(e.id),onSendCommand:o},e.id))})]})})]})}function i3(e){var t;let{job:r,onClick:l,onSendCommand:a}=e,s=r.enabled?r.state.runningAtMs?"running":null!=(t=r.state.lastStatus)?t:"idle":"disabled",i=iF(s),[c,d]=(0,o.useState)(Date.now());return(0,o.useEffect)(()=>{let e=setInterval(()=>d(Date.now()),5e3);return()=>clearInterval(e)},[]),(0,n.jsxs)("tr",{className:"cursor-pointer transition-colors group",style:{borderBottom:"1px solid var(--color-border)"},onClick:l,onMouseEnter:e=>{e.currentTarget.style.background="var(--color-surface-hover)"},onMouseLeave:e=>{e.currentTarget.style.background="transparent"},children:[(0,n.jsxs)("td",{className:"px-4 py-3",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("div",{className:"font-medium",style:{color:"var(--color-text)"},children:r.name}),null!=r.state.consecutiveErrors&&r.state.consecutiveErrors>0&&(0,n.jsxs)("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full",style:{background:"color-mix(in srgb, var(--color-error, #ef4444) 12%, transparent)",color:"var(--color-error, #ef4444)"},children:[r.state.consecutiveErrors," err"]})]}),r.description&&(0,n.jsx)("div",{className:"text-xs truncate max-w-[200px]",style:{color:"var(--color-text-muted)"},children:r.description})]}),(0,n.jsx)("td",{className:"px-4 py-3 text-xs",style:{color:"var(--color-text-muted)"},children:function(e){switch(e.kind){case"cron":return"cron: ".concat(e.expr).concat(e.tz?" (".concat(e.tz,")"):"");case"every":{let t=e.everyMs;if(t>=864e5)return"every ".concat(Math.round(t/864e5),"d");if(t>=36e5)return"every ".concat(Math.round(t/36e5),"h");if(t>=6e4)return"every ".concat(Math.round(t/6e4),"m");return"every ".concat(Math.round(t/1e3),"s")}case"at":return"at ".concat(e.at);default:return"unknown"}}(r.schedule)}),(0,n.jsx)("td",{className:"px-4 py-3",children:(0,n.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-xs px-2 py-0.5 rounded-full",style:{background:"color-mix(in srgb, ".concat(i," 12%, transparent)"),color:i},children:["running"===s&&(0,n.jsx)("span",{className:"w-1.5 h-1.5 rounded-full animate-pulse",style:{background:i}}),s]})}),(0,n.jsx)("td",{className:"px-4 py-3 text-xs",style:{color:"var(--color-text-muted)"},children:r.state.nextRunAtMs?r.state.nextRunAtMs>c?"in ".concat(iW(r.state.nextRunAtMs-c)):"overdue":"-"}),(0,n.jsx)("td",{className:"px-4 py-3",children:(0,n.jsxs)("div",{className:"flex items-center gap-1.5",children:[r.state.lastStatus&&(0,n.jsx)("span",{className:"w-1.5 h-1.5 rounded-full flex-shrink-0",style:{background:iF(r.state.lastStatus)}}),(0,n.jsx)("span",{className:"text-xs",style:{color:"var(--color-text-muted)"},children:r.state.lastRunAtMs?"".concat(function(e){let t=Date.now()-e;return t<6e4?"just now":t<36e5?"".concat(Math.floor(t/6e4),"m ago"):t<864e5?"".concat(Math.floor(t/36e5),"h ago"):"".concat(Math.floor(t/864e5),"d ago")}(r.state.lastRunAtMs)).concat(r.state.lastDurationMs?" (".concat(iB(r.state.lastDurationMs),")"):""):"-"})]})}),(0,n.jsx)("td",{className:"px-4 py-3",children:(0,n.jsxs)("div",{className:"flex items-center gap-1 md:opacity-0 md:group-hover:opacity-100 transition-opacity",children:[!r.state.runningAtMs&&r.enabled&&(0,n.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),null==a||a('Run cron job "'.concat(r.name,'" (').concat(r.id,") now with --force"))},className:"p-1 rounded cursor-pointer",style:{color:"var(--color-accent)"},title:"Run now",children:(0,n.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("polygon",{points:"6 3 20 12 6 21 6 3"})})}),(0,n.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),null==a||a("".concat(r.enabled?"Disable":"Enable",' cron job "').concat(r.name,'" (').concat(r.id,")"))},className:"p-1 rounded cursor-pointer",style:{color:r.enabled?"var(--color-text-muted)":"var(--color-success, #22c55e)"},title:r.enabled?"Disable":"Enable",children:r.enabled?(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,n.jsx)("path",{d:"m4.93 4.93 14.14 14.14"})]}):(0,n.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"M20 6 9 17l-5-5"})})})]})})]})}function i6(){return(0,n.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"M19.5 12.572l-7.5 7.428l-7.5 -7.428a5 5 0 1 1 7.5 -6.566a5 5 0 1 1 7.5 6.572"})})}function i8(){return(0,n.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,n.jsx)("polyline",{points:"12 6 12 12 16 14"})]})}function i7(){return(0,n.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("polygon",{points:"6 3 20 12 6 21 6 3"})})}function i9(e){var t;return null!=(t=e.split("/")[0])?t:e}function ce(e){let{source:t,size:r=36,emoji:l,isManaged:a}=e,[s,i]=(0,o.useState)(!1),c="".concat(r,"px");return a?(0,n.jsx)("img",{src:"/dench-workspace-icon.png",alt:"DenchClaw",width:r,height:r,className:"rounded-xl shrink-0",style:{width:c,height:c,objectFit:"cover"},loading:"lazy"}):l&&!s?(0,n.jsx)("div",{className:"flex items-center justify-center rounded-xl shrink-0",style:{width:c,height:c,background:"var(--color-surface-hover)",fontSize:"".concat(Math.round(.5*r),"px")},children:l}):"workspace"===t?(0,n.jsx)("img",{src:"/icons/folder.png",alt:"",width:r,height:r,className:"rounded-xl shrink-0",style:{width:c,height:c,objectFit:"cover"},loading:"lazy"}):s?(0,n.jsx)("div",{className:"flex items-center justify-center rounded-xl shrink-0",style:{width:c,height:c,background:"var(--color-surface-hover)",color:"var(--color-text-muted)",fontSize:"".concat(Math.round(.35*r),"px"),fontWeight:600},children:i9(t).slice(0,2).toUpperCase()}):(0,n.jsx)("img",{src:function(e){let t=i9(e);return"https://github.com/".concat(t,".png?size=80")}(t),alt:"",width:r,height:r,className:"rounded-xl shrink-0",style:{width:c,height:c,objectFit:"cover"},onError:()=>i(!0),loading:"lazy"})}function ct(){return(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"inline",verticalAlign:"middle"},children:[(0,n.jsx)("polyline",{points:"23 6 13.5 15.5 8.5 10.5 1 18"}),(0,n.jsx)("polyline",{points:"17 6 23 6 23 12"})]})}function cr(){return(0,n.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"inline",verticalAlign:"middle"},children:[(0,n.jsx)("line",{x1:"7",y1:"17",x2:"17",y2:"7"}),(0,n.jsx)("polyline",{points:"7 7 17 7 17 17"})]})}function cn(){return(0,n.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}),(0,n.jsx)("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})}function co(){return(0,n.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"inline",verticalAlign:"middle"},children:[(0,n.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,n.jsx)("polyline",{points:"7 10 12 15 17 10"}),(0,n.jsx)("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}function cl(e){let{skill:t,removingSlug:r,confirmRemove:o,onConfirmRemove:l,onRemove:a,onClick:s}=e;return(0,n.jsxs)("div",{className:"group rounded-2xl p-4 flex flex-col gap-2.5 transition-colors cursor-pointer",style:{background:"var(--color-surface)",border:"1px solid var(--color-border)"},role:"button",tabIndex:0,onClick:s,onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(null==s||s())},children:[(0,n.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,n.jsxs)("div",{className:"flex items-center gap-3 min-w-0",children:[(0,n.jsx)(ce,{source:t.source,emoji:t.emoji,size:36,isManaged:t.protected||"managed"===t.source}),(0,n.jsxs)("div",{className:"min-w-0",children:[(0,n.jsx)("div",{className:"text-sm font-medium truncate",style:{color:"var(--color-text)"},children:t.name}),(0,n.jsxs)("div",{className:"flex items-center gap-1.5 mt-0.5",children:[(0,n.jsx)("span",{className:"text-[10px] truncate",style:{color:"var(--color-text-muted)"},children:"managed"===t.source?"DenchClaw":i9(t.source)}),(0,n.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full shrink-0",style:{background:"managed"===t.source?"color-mix(in srgb, var(--color-accent) 12%, transparent)":"var(--color-surface-hover)",color:"managed"===t.source?"var(--color-accent)":"var(--color-text-muted)"},children:"managed"===t.source?"built-in":t.source}),t.protected&&(0,n.jsxs)("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full flex items-center gap-1 shrink-0",style:{background:"color-mix(in srgb, var(--color-warning, #f59e0b) 12%, transparent)",color:"var(--color-warning, #f59e0b)"},title:"Required by DenchClaw",children:[(0,n.jsx)(cn,{}),"protected"]})]})]})]}),!t.protected&&(0,n.jsx)("div",{className:"flex-shrink-0",onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:o===t.slug?(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)("button",{type:"button",onClick:()=>a(t.slug),disabled:r===t.slug,className:"text-[11px] px-2 py-1 rounded-lg cursor-pointer transition-colors",style:{background:"color-mix(in srgb, var(--color-error, #ef4444) 12%, transparent)",color:"var(--color-error, #ef4444)"},children:r===t.slug?(0,n.jsxs)("span",{className:"flex items-center gap-1",children:[(0,n.jsx)("span",{className:"w-3 h-3 border border-current rounded-full animate-spin",style:{borderTopColor:"transparent"}}),"Removing..."]}):"Confirm"}),(0,n.jsx)("button",{type:"button",onClick:()=>l(null),className:"text-[11px] px-2 py-1 rounded-lg cursor-pointer",style:{color:"var(--color-text-muted)"},children:"Cancel"})]}):(0,n.jsx)("button",{type:"button",onClick:()=>l(t.slug),className:"text-[11px] px-2 py-1 rounded-lg cursor-pointer transition-opacity opacity-0 group-hover:opacity-100",style:{color:"var(--color-text-muted)"},children:"Remove"})})]}),t.description&&(0,n.jsx)("p",{className:"text-xs leading-relaxed line-clamp-2",style:{color:"var(--color-text-muted)"},children:t.description})]})}function ca(e){var t;let{skill:r,isInstalled:o,installStatus:l,onInstall:a,featured:s=!1}=e,i=(null==l?void 0:l.phase)==="installing"||(null==l?void 0:l.phase)==="refreshing",c=r.installs>=5e4;return(0,n.jsxs)("div",{className:"group rounded-2xl p-4 flex flex-col gap-2.5",style:{background:"var(--color-surface)",border:"1px solid var(--color-border)"},children:[(0,n.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,n.jsxs)("div",{className:"flex items-center gap-3 min-w-0",children:[(0,n.jsx)(ce,{source:r.source,size:s?40:36}),(0,n.jsxs)("div",{className:"min-w-0",children:[(0,n.jsx)("div",{className:"font-medium truncate ".concat("text-sm"),style:{color:"var(--color-text)"},children:r.displayName}),(0,n.jsxs)("div",{className:"flex items-center gap-1.5 mt-0.5",children:[(0,n.jsx)("span",{className:"text-[10px] truncate",style:{color:"var(--color-text-muted)"},children:i9(r.source)}),r.installs>0&&(0,n.jsxs)("span",{className:"text-[10px] flex items-center gap-0.5 shrink-0",style:{color:c?"var(--color-accent)":"var(--color-text-muted)"},children:[c?(0,n.jsx)(ct,{}):(0,n.jsx)(co,{})," ",(t=r.installs)>=1e6?"".concat((t/1e6).toFixed(1),"M"):t>=1e3?"".concat((t/1e3).toFixed(t>=1e4?0:1),"K"):String(t)]})]})]})]}),(0,n.jsx)("div",{className:"flex-shrink-0",children:o?(0,n.jsx)("span",{className:"text-[11px] px-2.5 py-1 rounded-lg",style:{background:"color-mix(in srgb, var(--color-success, #22c55e) 12%, transparent)",color:"var(--color-success, #22c55e)"},children:"Installed"}):i?(0,n.jsxs)("span",{className:"text-[11px] px-2.5 py-1 rounded-lg flex items-center gap-1",style:{background:"var(--color-surface-hover)",color:"var(--color-text-muted)"},children:[(0,n.jsx)("span",{className:"w-3 h-3 border border-current rounded-full animate-spin",style:{borderTopColor:"transparent"}}),(null==l?void 0:l.phase)==="installing"?"Installing...":"Syncing..."]}):(0,n.jsxs)("button",{type:"button",onClick:a,className:"text-[11px] px-2.5 py-1 rounded-lg cursor-pointer transition-opacity opacity-0 group-hover:opacity-100 flex items-center gap-1",style:{background:"var(--color-surface-hover)",color:"var(--color-text)"},children:[(0,n.jsx)(cr,{})," Install"]})})]}),r.summary&&!l&&(0,n.jsx)("p",{className:"text-xs leading-relaxed line-clamp-2",style:{color:"var(--color-text-muted)"},children:r.summary}),l&&(0,n.jsx)("p",{className:"text-[11px]",style:{color:"error"===l.phase?"var(--color-error, #ef4444)":"var(--color-text-muted)"},children:l.message})]})}function cs(e){let{tone:t,children:r}=e;return(0,n.jsx)("div",{className:"rounded-xl px-3 py-2 text-sm",style:{info:{background:"color-mix(in srgb, var(--color-accent) 10%, transparent)",color:"var(--color-text)",border:"1px solid color-mix(in srgb, var(--color-accent) 30%, transparent)"},success:{background:"color-mix(in srgb, var(--color-success, #22c55e) 12%, transparent)",color:"var(--color-success, #22c55e)",border:"1px solid color-mix(in srgb, var(--color-success, #22c55e) 28%, transparent)"},error:{background:"color-mix(in srgb, var(--color-error, #ef4444) 12%, transparent)",color:"var(--color-error, #ef4444)",border:"1px solid color-mix(in srgb, var(--color-error, #ef4444) 28%, transparent)"}}[t],children:r})}let ci=[{id:"installed",label:"Installed",icon:function(){return(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"m7.5 4.27 9 5.15"}),(0,n.jsx)("path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z"}),(0,n.jsx)("path",{d:"m3.3 7 8.7 5 8.7-5"}),(0,n.jsx)("path",{d:"M12 22V12"})]})}},{id:"browse",label:"Browse",icon:function(){return(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,n.jsx)("polygon",{points:"16.24 7.76 14.12 14.12 7.76 16.24 9.88 9.88 16.24 7.76"})]})}}];function cc(){let{embedded:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},[t,r]=(0,o.useState)("installed"),[l,a]=(0,o.useState)([]),[s,i]=(0,o.useState)({}),[c,d]=(0,o.useState)(!0),[u,p]=(0,o.useState)(!1),[h,x]=(0,o.useState)(null),[m,f]=(0,o.useState)(""),[v,g]=(0,o.useState)(null),[y,b]=(0,o.useState)(null),[j,k]=(0,o.useState)([]),[w,N]=(0,o.useState)(!1),[C,S]=(0,o.useState)(null),[M,L]=(0,o.useState)(""),T=(0,o.useRef)(void 0),I=(0,o.useRef)(null),R=(0,o.useRef)(!1),[_,E]=(0,o.useState)({}),[D,A]=(0,o.useState)(null),[W,B]=(0,o.useState)([]),F=(0,o.useRef)(!1),[P,z]=(0,o.useState)(!1),[O,U]=(0,o.useState)([]),[H,V]=(0,o.useState)(null),[K,J]=(0,o.useState)(null),[q,G]=(0,o.useState)(null),[$,Z]=(0,o.useState)(!1),Y=(0,o.useMemo)(()=>{let e=new Map;for(let t of l)e.set(t.slug,t);for(let t of Object.values(s))e.has(t.slug)||e.set(t.slug,t);return Array.from(e.values()).sort((e,t)=>e.name.localeCompare(t.name))},[s,l]),Q=(0,o.useMemo)(()=>new Set(Y.map(e=>e.slug)),[Y]),X=(0,o.useCallback)(async function(){let{showSpinner:e=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e?d(!0):p(!0),x(null);try{var t;let e=await fetch("/api/skills");if(!e.ok)throw Error("Failed to load installed skills (".concat(e.status,")"));let r=null!=(t=(await e.json()).skills)?t:[];return a(r),i(e=>{if(0===Object.keys(e).length)return e;let t={...e};for(let e of r)delete t[e.slug];return t}),!0}catch(e){return x(e instanceof Error?e.message:"Failed to load installed skills"),!1}finally{e&&d(!1),p(!1)}},[]);(0,o.useEffect)(()=>{X({showSpinner:!0})},[X]);let ee=(0,o.useCallback)(async(e,t)=>{var r,n;null==(r=I.current)||r.abort();let o=new AbortController;I.current=o,N(!0),S(null);try{let r=new URLSearchParams;(null==e?void 0:e.trim())?r.set("q",e.trim()):t&&r.set("category",t);let l=await fetch("/api/skills/browse?".concat(r.toString()),{signal:o.signal}),a=await l.json();if(o.signal.aborted)return;a.error&&S(a.error),k(null!=(n=a.skills)?n:[]),a.categories&&U(a.categories)}catch(e){if(o.signal.aborted)return;S(e instanceof Error?e.message:"Failed to load skills"),k([])}finally{o.signal.aborted||N(!1)}},[]),et=(0,o.useCallback)(async()=>{z(!0);try{var e;let t=await fetch("/api/skills/browse?featured=true"),r=await t.json();B(null!=(e=r.skills)?e:[]),r.categories&&U(r.categories)}catch(e){B([])}finally{z(!1)}},[]);(0,o.useEffect)(()=>{"browse"!==t||F.current||P||(F.current=!0,et()),"browse"!==t||R.current||w||(R.current=!0,ee())},[t,P,w,ee,et]);let er=(0,o.useCallback)(e=>{L(e),clearTimeout(T.current),T.current=setTimeout(()=>{ee(e,H)},300)},[ee,H]),en=(0,o.useCallback)(e=>{V(e),L(""),ee("",e)},[ee]),eo=(0,o.useCallback)(async e=>{g(e),A(null);try{let r=await fetch("/api/skills/".concat(encodeURIComponent(e)),{method:"DELETE"}),n=await r.json();if(n.ok)a(t=>t.filter(t=>t.slug!==e)),i(t=>{if(!(e in t))return t;let r={...t};return delete r[e],r}),E(t=>{if(!(e in t))return t;let r={...t};return delete r[e],r}),A({tone:"success",text:"Removed ".concat(e,".")}),(null==K?void 0:K.slug)===e&&J(null);else{var t;A({tone:"error",text:null!=(t=n.error)?t:"Failed to remove ".concat(e,".")})}}catch(t){A({tone:"error",text:t instanceof Error?t.message:"Failed to remove ".concat(e,".")})}finally{g(null),b(null)}},[null==K?void 0:K.slug]),el=(0,o.useCallback)(async e=>{A({tone:"info",text:"Installing ".concat(e.displayName,"...")}),E(t=>({...t,[e.slug]:{phase:"installing",message:"Installing ".concat(e.displayName,"...")}}));try{var t,r;let n=await fetch("/api/skills/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:e.slug,source:e.source})}),o=await n.json();if(!n.ok||!o.ok)throw Error(null!=(t=o.error)?t:"Failed to install ".concat(e.displayName));let l=null!=(r=o.skill)?r:{name:e.displayName,slug:e.slug,description:e.summary,source:"skills.sh",filePath:"",protected:!1};i(e=>({...e,[l.slug]:l})),E(t=>({...t,[e.slug]:{phase:"refreshing",message:"Refreshing installed skills..."}})),A({tone:"info",text:"Installed ".concat(e.displayName,". Refreshing the Installed list...")}),await X()?(E(t=>({...t,[e.slug]:{phase:"success",message:"".concat(e.displayName," installed successfully.")}})),A({tone:"success",text:"".concat(e.displayName," is now installed.")})):(E(t=>({...t,[e.slug]:{phase:"success",message:"".concat(e.displayName," was installed, but the Installed list could not be refreshed.")}})),A({tone:"info",text:"".concat(e.displayName," was installed, but we could not refresh the Installed list automatically.")}))}catch(r){let t=r instanceof Error?r.message:"Failed to install ".concat(e.displayName);E(r=>({...r,[e.slug]:{phase:"error",message:t}})),A({tone:"error",text:t})}},[X]),ea=(0,o.useCallback)(async e=>{J(e),G(null),Z(!0);try{let r=await fetch("/api/skills/".concat(encodeURIComponent(e.slug),"/content"));if(r.ok){var t;let e=await r.json();G(null!=(t=e.content)?t:null)}}catch(e){}finally{Z(!1)}},[]),es=(0,o.useMemo)(()=>{if(!m.trim())return Y;let e=m.toLowerCase();return Y.filter(t=>t.name.toLowerCase().includes(e)||t.description.toLowerCase().includes(e))},[Y,m]),ei="browse"===t&&!M.trim()&&!H,ec=(0,o.useMemo)(()=>W.slice(0,6),[W]);return(0,n.jsxs)("div",{className:e?"":"p-6 max-w-5xl mx-auto",children:[!e&&(0,n.jsx)("div",{className:"flex items-end justify-between mb-6",children:(0,n.jsxs)("div",{children:[(0,n.jsx)("h1",{className:"font-instrument text-3xl tracking-tight mb-1",style:{color:"var(--color-text)"},children:"Skill Store"}),(0,n.jsxs)("p",{className:"text-sm",style:{color:"var(--color-text-muted)"},children:[Y.length," skill",1!==Y.length?"s":""," installed"]})]})}),(0,n.jsx)("div",{className:"flex w-fit items-center gap-1 mb-6 rounded-xl p-1",style:{background:"var(--color-surface-hover)"},children:ci.map(e=>{let o=e.icon;return(0,n.jsxs)("button",{type:"button",onClick:()=>r(e.id),className:"px-4 py-1.5 rounded-lg text-sm font-medium transition-all cursor-pointer flex items-center gap-1.5",style:{background:t===e.id?"var(--color-surface)":"transparent",color:t===e.id?"var(--color-text)":"var(--color-text-muted)",boxShadow:t===e.id?"var(--shadow-sm)":"none"},children:[(0,n.jsx)(o,{}),e.label]},e.id)})}),(0,n.jsx)("div",{className:"mb-4",children:(0,n.jsx)("input",{type:"text",value:"installed"===t?m:M,onChange:e=>"installed"===t?f(e.target.value):er(e.target.value),placeholder:"installed"===t?"Filter installed skills...":"Search skills...",className:"w-full px-3 py-2 rounded-xl text-sm outline-none",style:{background:"var(--color-surface)",border:"1px solid var(--color-border)",color:"var(--color-text)"}})}),"browse"===t&&O.length>0&&(0,n.jsxs)("div",{className:"mb-4 flex flex-wrap gap-1.5",children:[(0,n.jsx)("button",{type:"button",onClick:()=>en(null),className:"rounded-full px-2.5 py-1 text-[11px] font-medium transition-colors cursor-pointer",style:{background:H?"var(--color-surface)":"var(--color-accent)",color:H?"var(--color-text-muted)":"var(--color-bg, #fff)",border:H?"1px solid var(--color-border)":"none"},children:"All"}),O.map(e=>(0,n.jsx)("button",{type:"button",onClick:()=>en(H===e?null:e),className:"rounded-full px-2.5 py-1 text-[11px] font-medium transition-colors cursor-pointer",style:{background:H===e?"var(--color-accent)":"var(--color-surface)",color:H===e?"var(--color-bg, #fff)":"var(--color-text-muted)",border:H===e?"none":"1px solid var(--color-border)"},children:e},e))]}),(D||u||h)&&(0,n.jsxs)("div",{className:"mb-4 space-y-2",children:[D&&(0,n.jsx)(cs,{tone:D.tone,children:D.text}),u&&(0,n.jsx)(cs,{tone:"info",children:"Refreshing installed skills..."}),h&&(0,n.jsx)(cs,{tone:"error",children:h})]}),"installed"===t&&(0,n.jsx)(cd,{skills:es,loading:c,error:h,removingSlug:v,confirmRemove:y,onConfirmRemove:b,onRemove:eo,onRetry:()=>void X({showSpinner:!0}),onSkillClick:ea}),"browse"===t&&(0,n.jsx)(cu,{skills:j,loading:w,error:C,installedSlugs:Q,installStatuses:_,onInstall:el,onRetry:()=>void ee(M,H),showFeatured:ei,featuredSkills:ec,featuredLoading:P}),K&&(0,n.jsx)(cp,{skill:K,content:q,loading:$,onClose:()=>J(null),onRemove:e=>{J(null),b(null),eo(e)}})]})}function cd(e){let{skills:t,loading:r,error:o,removingSlug:l,confirmRemove:a,onConfirmRemove:s,onRemove:i,onRetry:c,onSkillClick:d}=e;return r?(0,n.jsx)("div",{className:"flex items-center justify-center py-16",children:(0,n.jsx)("div",{className:"w-6 h-6 border-2 rounded-full animate-spin",style:{borderColor:"var(--color-border)",borderTopColor:"var(--color-accent)"}})}):o&&0===t.length?(0,n.jsxs)("div",{className:"p-8 text-center rounded-2xl",style:{background:"var(--color-surface)",border:"1px solid var(--color-border)"},children:[(0,n.jsx)("p",{className:"text-sm mb-3",style:{color:"var(--color-text-muted)"},children:"Could not load installed skills"}),(0,n.jsx)("p",{className:"text-xs mb-4",style:{color:"var(--color-text-muted)"},children:o}),(0,n.jsx)("button",{type:"button",onClick:c,className:"text-xs px-3 py-1.5 rounded-lg cursor-pointer",style:{background:"var(--color-accent)",color:"var(--color-bg)"},children:"Retry"})]}):0===t.length?(0,n.jsx)("div",{className:"p-8 text-center rounded-2xl",style:{background:"var(--color-surface)",border:"1px solid var(--color-border)"},children:(0,n.jsx)("p",{className:"text-sm",style:{color:"var(--color-text-muted)"},children:"No installed skills found."})}):(0,n.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:t.map(e=>(0,n.jsx)(cl,{skill:e,removingSlug:l,confirmRemove:a,onConfirmRemove:s,onRemove:i,onClick:()=>d(e)},e.slug))})}function cu(e){let{skills:t,loading:r,error:o,installedSlugs:l,installStatuses:a,onInstall:s,onRetry:i,showFeatured:c,featuredSkills:d,featuredLoading:u}=e;return r&&0===t.length&&0===d.length?(0,n.jsx)("div",{className:"flex items-center justify-center py-16",children:(0,n.jsx)("div",{className:"w-6 h-6 border-2 rounded-full animate-spin",style:{borderColor:"var(--color-border)",borderTopColor:"var(--color-accent)"}})}):o&&0===t.length&&0===d.length?(0,n.jsxs)("div",{className:"p-8 text-center rounded-2xl",style:{background:"var(--color-surface)",border:"1px solid var(--color-border)"},children:[(0,n.jsx)("p",{className:"text-sm mb-3",style:{color:"var(--color-text-muted)"},children:"Could not load skills"}),(0,n.jsx)("p",{className:"text-xs mb-4",style:{color:"var(--color-text-muted)"},children:o}),(0,n.jsx)("button",{type:"button",onClick:i,className:"text-xs px-3 py-1.5 rounded-lg cursor-pointer",style:{background:"var(--color-accent)",color:"var(--color-bg)"},children:"Retry"})]}):c||0!==t.length?(0,n.jsxs)("div",{className:"space-y-6",children:[c&&d.length>0&&(0,n.jsxs)("div",{children:[(0,n.jsx)("h2",{className:"text-xs font-semibold uppercase tracking-wider mb-3",style:{color:"var(--color-text-muted)"},children:"Popular Skills"}),u?(0,n.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,n.jsx)("div",{className:"w-5 h-5 border-2 rounded-full animate-spin",style:{borderColor:"var(--color-border)",borderTopColor:"var(--color-accent)"}})}):(0,n.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:d.map(e=>(0,n.jsx)(ca,{skill:e,isInstalled:l.has(e.slug),installStatus:a[e.slug],onInstall:()=>s(e),featured:!0},e.slug))})]}),t.length>0&&(0,n.jsxs)("div",{children:[c&&(0,n.jsx)("h2",{className:"text-xs font-semibold uppercase tracking-wider mb-3",style:{color:"var(--color-text-muted)"},children:"All Skills"}),r&&(0,n.jsx)("div",{className:"text-xs mb-2",style:{color:"var(--color-text-muted)"},children:"Loading skills..."}),(0,n.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:t.map(e=>(0,n.jsx)(ca,{skill:e,isInstalled:l.has(e.slug),installStatus:a[e.slug],onInstall:()=>s(e)},e.slug))})]})]}):(0,n.jsx)("div",{className:"p-8 text-center rounded-2xl",style:{background:"var(--color-surface)",border:"1px solid var(--color-border)"},children:(0,n.jsx)("p",{className:"text-sm",style:{color:"var(--color-text-muted)"},children:"No skills found."})})}function cp(e){let{skill:t,content:r,loading:l,onClose:a,onRemove:s}=e;return(0,o.useEffect)(()=>{let e=e=>{"Escape"===e.key&&a()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[a]),(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"fixed inset-0 z-40",style:{background:"rgba(0,0,0,0.4)"},onClick:a,role:"presentation"}),(0,n.jsxs)("div",{className:"fixed top-0 right-0 bottom-0 z-50 w-full max-w-lg flex flex-col overflow-hidden",style:{background:"var(--color-bg, #0a0a0a)",borderLeft:"1px solid var(--color-border)"},role:"dialog","aria-label":"".concat(t.name," details"),children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-6 py-4 shrink-0",style:{borderBottom:"1px solid var(--color-border)"},children:[(0,n.jsxs)("div",{className:"flex items-center gap-3 min-w-0",children:[t.emoji&&(0,n.jsx)("span",{className:"text-xl",children:t.emoji}),(0,n.jsxs)("div",{className:"min-w-0",children:[(0,n.jsx)("h2",{className:"text-base font-semibold truncate",style:{color:"var(--color-text)"},children:t.name}),(0,n.jsx)("p",{className:"text-xs",style:{color:"var(--color-text-muted)"},children:t.source})]})]}),(0,n.jsx)("button",{type:"button",onClick:a,className:"p-1.5 rounded-lg cursor-pointer transition-colors",style:{color:"var(--color-text-muted)"},"aria-label":"Close",children:(0,n.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,n.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),(0,n.jsxs)("div",{className:"flex-1 overflow-y-auto px-6 py-5",children:[t.description&&(0,n.jsx)("p",{className:"text-sm mb-4 leading-relaxed",style:{color:"var(--color-text-muted)"},children:t.description}),l?(0,n.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,n.jsx)("div",{className:"w-5 h-5 border-2 rounded-full animate-spin",style:{borderColor:"var(--color-border)",borderTopColor:"var(--color-accent)"}})}):r?(0,n.jsx)("div",{className:"prose prose-sm prose-invert max-w-none",children:(0,n.jsx)("pre",{className:"text-xs leading-relaxed whitespace-pre-wrap",style:{color:"var(--color-text)",background:"transparent",border:"none",padding:0},children:r})}):(0,n.jsx)("p",{className:"text-xs",style:{color:"var(--color-text-muted)"},children:"No content available for this skill."})]}),!t.protected&&(0,n.jsx)("div",{className:"px-6 py-4 shrink-0",style:{borderTop:"1px solid var(--color-border)"},children:(0,n.jsx)("button",{type:"button",onClick:()=>s(t.slug),className:"text-sm px-4 py-2 rounded-xl cursor-pointer transition-colors w-full",style:{background:"color-mix(in srgb, var(--color-error, #ef4444) 12%, transparent)",color:"var(--color-error, #ef4444)",border:"1px solid color-mix(in srgb, var(--color-error, #ef4444) 28%, transparent)"},children:"Remove Skill"})})]})]})}var ch=r(25588);let cx=(0,r(71712).F)("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 outline-none ring-0 border-none",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),cm=o.forwardRef((e,t)=>{let{className:r,variant:o,size:l,asChild:a=!1,...s}=e,i=a?ch.DX:"button";return(0,n.jsx)(i,{className:x(cx({variant:o,size:l,className:r})),ref:t,...s})});function cf(e){var t;let{logo:r,name:l,slug:a}=e,[s,i]=(0,o.useState)(!1),c=sP({toolkitSlug:a,toolkitName:l,initialLogo:r}),d=c.logo&&!s;return(0,n.jsx)("div",{className:"flex h-12 w-12 shrink-0 items-center justify-center overflow-hidden",style:{background:"var(--color-surface-hover)",borderRadius:"13px",boxShadow:"inset 0 0 0 0.5px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.06)"},children:d?(0,n.jsx)("img",{src:null!=(t=c.logo)?t:void 0,alt:"",className:"h-7 w-7 object-contain",loading:"lazy",decoding:"async",onError:()=>i(!0)}):(0,n.jsx)("span",{className:"text-sm font-semibold uppercase",style:{color:"var(--color-text-muted)"},children:l.slice(0,2)})})}function cv(e){let{toolkit:t,activeConnections:r,totalConnections:o,mode:l="marketplace",onClick:a}=e,s=r>0;return(0,n.jsxs)("div",{className:"group rounded-2xl p-3.5 flex items-start gap-3.5 cursor-pointer transition-shadow duration-200 hover:shadow-md",style:{background:"var(--color-surface)",border:"1px solid var(--color-border)"},onClick:a,role:"button",tabIndex:0,onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&a()},"aria-label":"".concat(s?"Manage":"Get"," ").concat(t.name),children:[(0,n.jsx)(cf,{logo:t.logo,name:t.name,slug:t.slug}),(0,n.jsxs)("div",{className:"flex-1 min-w-0 pt-0.5",children:[(0,n.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,n.jsxs)("div",{className:"min-w-0",children:[(0,n.jsx)("div",{className:"text-[13px] font-semibold truncate leading-tight",style:{color:"var(--color-text)"},children:t.name}),(0,n.jsxs)("div",{className:"flex items-center gap-1 mt-0.5 text-[11px]",children:[s&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("span",{className:"font-medium",style:{color:"var(--color-success, #34C759)"},children:[r," account",1===r?"":"s"]}),(t.tools_count>0||"number"==typeof o&&o>r)&&(0,n.jsx)("span",{style:{color:"var(--color-text-muted)"},children:"\xb7"})]}),s&&"number"==typeof o&&o>r&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("span",{style:{color:"var(--color-text-muted)"},children:[o," total"]}),t.tools_count>0&&(0,n.jsx)("span",{style:{color:"var(--color-text-muted)"},children:"\xb7"})]}),t.tools_count>0&&(0,n.jsxs)("span",{style:{color:"var(--color-text-muted)"},children:[t.tools_count," tool",1===t.tools_count?"":"s"]})]})]}),(0,n.jsx)("span",{className:"shrink-0 rounded-full px-3.5 py-1 text-[12px] font-bold mt-0.5",style:s?{background:"var(--color-surface-hover)",color:"var(--color-accent)"}:{background:"var(--color-accent)",color:"#fff"},children:s?"Connected":"Connect"})]}),t.description&&(0,n.jsx)("p",{className:"text-[11px] leading-relaxed line-clamp-2 mt-1.5",style:{color:"var(--color-text-muted)"},children:t.description})]})]})}function cg(e){var t;let{logo:r,name:l,slug:a}=e,[s,i]=(0,o.useState)(!1),c=sP({toolkitSlug:a,toolkitName:l,initialLogo:r}),d=c.logo&&!s;return(0,n.jsx)("div",{className:"flex h-12 w-12 items-center justify-center overflow-hidden rounded-xl",style:{background:"var(--color-surface-hover)",border:"1px solid var(--color-border)"},children:d?(0,n.jsx)("img",{src:null!=(t=c.logo)?t:void 0,alt:"",className:"h-8 w-8 object-contain",decoding:"async",onError:()=>i(!0)}):(0,n.jsx)("span",{className:"text-base font-semibold uppercase",style:{color:"var(--color-text-muted)"},children:l.slice(0,2)})})}function cy(e){var t;return null!=(t=({OAUTH2:"OAuth 2.0",OAUTH1:"OAuth 1.0",API_KEY:"API Key",BASIC:"Basic Auth",BEARER_TOKEN:"Bearer Token",JWT:"JWT",NO_AUTH:"No Auth"})[e])?t:e.replace(/_/g," ")}function cb(e){let t=Date.parse(e);return Number.isFinite(t)?new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",year:"numeric"}).format(t):"Connected recently"}function cj(e){let{toolkit:t,connections:r,open:l,preferredAction:a,onOpenChange:s,onConnectionChange:i}=e,[c,d]=(0,o.useState)(!1),[u,p]=(0,o.useState)(null),[h,x]=(0,o.useState)(null),m=(0,o.useRef)(null),f=(0,o.useRef)(null),v=(0,o.useRef)(!1),g=(0,o.useMemo)(()=>sE(r),[r]),y=(0,o.useMemo)(()=>g.filter(e=>e.is_active),[g]),b=y.length>0,j=null!=a?a:b?"connect":g.length>0?"reconnect":"connect",k=(0,o.useCallback)(()=>{null!==f.current&&(window.clearInterval(f.current),f.current=null)},[]),w=(0,o.useCallback)(()=>{k(),m.current=null,v.current=!1},[k]);(0,o.useEffect)(()=>{l||(x(null),d(!1),p(null),w())},[w,l]),(0,o.useEffect)(()=>w,[w]),(0,o.useEffect)(()=>{function e(e){var r,n,o;(null==(r=e.data)?void 0:r.type)==="composio-callback"&&e.origin===window.location.origin&&(v.current=!0,k(),m.current=null,d(!1),"success"===e.data.status?(i({toolkit:t,connected:!0,connectedToolkitSlug:"string"==typeof e.data.connected_toolkit_slug?e.data.connected_toolkit_slug:null!=(n=null==t?void 0:t.slug)?n:null,connectedToolkitName:"string"==typeof e.data.connected_toolkit_name?e.data.connected_toolkit_name:null!=(o=null==t?void 0:t.name)?o:null,shouldProbeLiveAgent:!0}),s(!1)):x("Connection was not completed. Please try again."))}return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[i,s,k,t]);let N=(0,o.useCallback)(async()=>{if(t){d(!0),x(null),w();try{var e,r,n;let o=await fetch("/api/composio/connect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({toolkit:null!=(r=t.connect_slug)?r:t.slug})}),l=await o.json();if(!o.ok)throw Error(null!=(n=l.error)?n:"Failed to start connection.");let a=window.open(l.redirect_url,"_blank","popup=yes,width=560,height=720,resizable=yes,scrollbars=yes");if(!a)throw Error("Popup was blocked. Please allow popups and try again.");m.current=a,v.current=!1,null==(e=a.focus)||e.call(a),f.current=window.setInterval(()=>{let e=m.current;e&&e.closed&&(k(),m.current=null,d(!1),v.current||(i({toolkit:t}),s(!1)))},500)}catch(e){d(!1),x(e instanceof Error?e.message:"Failed to connect.")}}},[w,i,s,k,t]),C=(0,o.useCallback)(async e=>{p(e),x(null);try{let n=await fetch("/api/composio/disconnect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({connection_id:e})}),o=await n.json();if(!n.ok){var r;throw Error(null!=(r=o.error)?r:"Failed to disconnect.")}i({toolkit:t,connected:!1})}catch(e){x(e instanceof Error?e.message:"Failed to disconnect.")}finally{p(null)}},[i]);if(!t)return null;let S=t.auth_schemes.length>0?t.auth_schemes.map(cy).join(", "):null;return(0,n.jsx)(e_,{open:l,onOpenChange:s,children:(0,n.jsxs)(eA,{className:"sm:max-w-lg p-0 gap-0 overflow-hidden",children:[(0,n.jsxs)("div",{className:"px-6 pt-6 pb-4",style:{borderBottom:"1px solid var(--color-border)"},children:[(0,n.jsx)(eW,{className:"space-y-0",children:(0,n.jsxs)("div",{className:"flex items-start gap-4",children:[(0,n.jsx)(cg,{logo:t.logo,name:t.name,slug:t.slug}),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsx)(eF,{className:"text-lg leading-tight",children:t.name}),t.description&&(0,n.jsx)(eP,{className:"mt-1 text-[13px] leading-relaxed line-clamp-2",children:t.description})]})]})}),(0,n.jsxs)("div",{className:"mt-4 flex flex-wrap items-center gap-3",children:[t.tools_count>0&&(0,n.jsxs)("span",{className:"inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1 text-xs font-medium",style:{background:"var(--color-surface-hover)",color:"var(--color-text)"},children:[(0,n.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"})}),t.tools_count," tool",1!==t.tools_count?"s":""]}),S&&(0,n.jsxs)("span",{className:"inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1 text-xs font-medium",style:{background:"var(--color-surface-hover)",color:"var(--color-text)"},children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),(0,n.jsx)("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),S]}),b&&(0,n.jsxs)("span",{className:"inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1 text-xs font-medium",style:{background:"rgba(16, 185, 129, 0.1)",color:"rgb(74 222 128)",border:"1px solid rgba(16, 185, 129, 0.2)"},children:[(0,n.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("polyline",{points:"20 6 9 17 4 12"})}),y.length," connected"]})]}),t.categories.length>0&&(0,n.jsx)("div",{className:"mt-3 flex flex-wrap gap-1.5",children:t.categories.slice(0,5).map(e=>(0,n.jsx)("span",{className:"rounded-full px-2 py-0.5 text-[11px]",style:{background:"var(--color-surface-hover)",color:"var(--color-text-muted)"},children:e},e))})]}),(0,n.jsxs)("div",{className:"px-6 py-4 space-y-3 max-h-[340px] overflow-y-auto",children:[h&&(0,n.jsx)("div",{className:"rounded-lg border border-destructive/30 bg-destructive/10 px-3 py-2 text-[12px] text-red-300",children:h}),g.length>0?(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,n.jsx)("h4",{className:"text-xs font-semibold uppercase tracking-[0.14em] text-muted-foreground",children:"Connections"}),(0,n.jsxs)("span",{className:"text-[11px] text-muted-foreground",children:[g.length," total"]})]}),g.map((e,t)=>{let r=e.is_active?"Disconnect":"Remove",o=e.is_same_account_reconnect,l="gateway_stable_id"!==e.account_identity_source;return(0,n.jsx)("div",{className:"rounded-xl border px-3 py-3",style:{borderColor:e.is_active?"rgba(16, 185, 129, 0.22)":"var(--color-border)",background:e.is_active?"rgba(16, 185, 129, 0.05)":"var(--color-surface-hover)"},children:(0,n.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,n.jsxs)("div",{className:"min-w-0",children:[(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,n.jsx)("p",{className:"truncate text-sm font-medium text-foreground",children:e.display_label}),(0,n.jsx)("span",{className:"inline-flex items-center rounded-full px-2 py-0.5 text-[10px] font-medium",style:{background:e.is_active?"rgba(16, 185, 129, 0.15)":"var(--color-background)",color:e.is_active?"rgb(74 222 128)":"var(--color-text-muted)",border:e.is_active?"1px solid rgba(16, 185, 129, 0.24)":"1px solid var(--color-border)"},children:e.normalized_status})]}),(0,n.jsx)("p",{className:"mt-1 text-[11px] text-muted-foreground",children:e.account_email||e.account_name||e.account_label?"Added ".concat(cb(e.created_at)):"Connection ".concat(t+1," \xb7 Added ").concat(cb(e.created_at))}),(o||l)&&(0,n.jsxs)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[o&&(0,n.jsx)("span",{className:"inline-flex items-center rounded-full px-2 py-0.5 text-[10px] font-medium",style:{background:"rgba(96, 165, 250, 0.12)",color:"rgb(147 197 253)",border:"1px solid rgba(96, 165, 250, 0.2)"},children:"Same account reconnected"}),l&&(0,n.jsx)("span",{className:"inline-flex items-center rounded-full px-2 py-0.5 text-[10px] font-medium",style:{background:"var(--color-background)",color:"var(--color-text-muted)",border:"1px solid var(--color-border)"},children:"Identity inferred"})]})]}),(0,n.jsx)(cm,{variant:"outline",size:"sm",onClick:()=>void C(e.id),disabled:u===e.id,children:u===e.id?"".concat(r,"..."):r})]})},e.id)})]}):(0,n.jsxs)("div",{className:"px-3 py-5 text-center text-sm",style:{color:"#a3a3a3"},children:["No accounts connected yet. Connect your ",t.name," account to get started."]})]}),(0,n.jsxs)("div",{className:"flex items-center justify-end gap-2 px-6 py-4",style:{borderTop:"1px solid var(--color-border)"},children:[(0,n.jsx)("button",{type:"button",className:"rounded-full px-4 py-1.5 text-sm font-medium transition-all bg-stone-100 hover:bg-stone-200/50",style:{color:"#57534e"},onClick:()=>s(!1),children:"Close"}),(0,n.jsx)("button",{type:"button",className:"rounded-full px-4 py-1.5 text-sm font-medium",style:{background:"var(--color-accent)",color:"#fff"},onClick:()=>void N(),disabled:c,children:c?"Waiting for authorization...":"reconnect"===j?"Reconnect ".concat(t.name):b?"Connect another account":"Connect ".concat(t.name)})]})]})})}cm.displayName="Button";let ck=["gmail","slack","github","notion","google-calendar","linear","airtable","hubspot","salesforce","jira","asana","discord"];function cw(){return(0,n.jsxs)("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 pointer-events-none",width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--color-text-muted)"},children:[(0,n.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,n.jsx)("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}let cN=null,cC="composio-connected-apps-snapshot";function cS(e){let t=new Map;for(let r of e)t.set(sj(r.slug),r);return Array.from(t.values())}function cM(){var e,t;return cN||(cN=function(){try{let e=localStorage.getItem(cC);if(!e)return null;let t=JSON.parse(e);if(Array.isArray(null==t?void 0:t.connectedToolkits)&&Array.isArray(null==t?void 0:t.connections))return t}catch(e){}return null}()),{connectedToolkits:null!=(e=null==cN?void 0:cN.connectedToolkits)?e:[],marketplaceToolkits:[],marketplaceCursor:null,connections:null!=(t=null==cN?void 0:cN.connections)?t:[],categories:[],loading:null===cN,marketplaceLoading:!1,marketplaceReady:!1,loadingMore:!1,error:null,connectionsError:null}}function cL(e){var t,r,l,a;let{eligible:s,lockBadge:i}=e,[c,d]=(0,o.useState)(cM),[u,p]=(0,o.useState)(""),[h,x]=(0,o.useState)(""),[m,f]=(0,o.useState)(null),[v,g]=(0,o.useState)(null),[y,b]=(0,o.useState)(!1),[j,k]=(0,o.useState)(null),[w,N]=(0,o.useState)(null),[C,S]=(0,o.useState)(!1),[M,L]=(0,o.useState)([]),T=(0,o.useRef)(!1),I=(0,o.useRef)(""),R=(0,o.useRef)(null),_=(0,o.useCallback)(async e=>{let t=new URLSearchParams;(null==e?void 0:e.search)&&t.set("search",e.search),(null==e?void 0:e.category)&&t.set("category",e.category),(null==e?void 0:e.cursor)&&t.set("cursor",e.cursor),(null==e?void 0:e.limit)&&t.set("limit",String(e.limit));let r=t.toString(),n=await fetch("/api/composio/toolkits".concat(r?"?".concat(r):""));if(!n.ok){var o;throw Error(null!=(o=(await n.json().catch(()=>({}))).error)?o:"Failed to load apps (".concat(n.status,")"))}return sM(await n.json())},[]),E=(0,o.useCallback)(async e=>{try{var t;let r=e?await fetch("/api/composio/status",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:e})}):await fetch("/api/composio/status");if(r.ok){k(await r.json()),N(null);return}k(null);let n=await r.json().catch(()=>({}));N(null!=(t=n.error)?t:aE("load",r.status))}catch(e){k(null),N(e instanceof Error?e.message:aE("load"))}},[]),D=(0,o.useCallback)(async e=>{d(e=>({...e,loading:0===e.connectedToolkits.length&&0===e.connections.length,error:null,connectionsError:null})),N(null),_({limit:24}).then(e=>{let t=new Set(ck),r=[...e.items.filter(e=>t.has(e.slug)).sort((e,t)=>ck.indexOf(e.slug)-ck.indexOf(t.slug)),...e.items.filter(e=>!t.has(e.slug))];d(t=>t.marketplaceReady?t:{...t,marketplaceToolkits:r,marketplaceCursor:e.cursor,categories:e.categories,marketplaceReady:!0,marketplaceLoading:!1}),I.current="::"}).catch(()=>{});try{let o=await fetch("/api/composio/connections?include_toolkits=1".concat((null==e?void 0:e.fresh)?"&fresh=1":"")),l={items:[]},a=null;o.ok?l=await o.json():a=null!=(t=(await o.json().catch(()=>({}))).error)?t:"Failed to load connections (".concat(o.status,")");let s=sL(l),i=cS(null!=(r=l.toolkits)?r:[]).sort((e,t)=>e.name.localeCompare(t.name));var t,r,n=cN={connectedToolkits:i,connections:s};try{localStorage.setItem(cC,JSON.stringify(n))}catch(e){}L(e=>e.filter(e=>!i.some(t=>sj(t.slug)===sj(e.slug)))),d(e=>({...e,connectedToolkits:i,connections:s,loading:!1,error:null,connectionsError:a})),window.setTimeout(()=>{E()},0)}catch(e){k(null),d(t=>({...t,loading:!1,error:t.connectedToolkits.length>0||t.connections.length>0?t.error:e instanceof Error?e.message:"Failed to load apps.",connectionsError:e instanceof Error?e.message:"Failed to load connections."}))}},[E,_]),A=(0,o.useCallback)(async e=>{var t;let r=null!=(t=null==e?void 0:e.reset)&&t,n=h.trim(),o="".concat(n.toLowerCase(),"::").concat(null!=m?m:""),l=r&&c.marketplaceReady;r?(I.current=o,d(e=>({...e,marketplaceToolkits:l?e.marketplaceToolkits:[],marketplaceCursor:null,categories:l?e.categories:[],marketplaceLoading:!0,marketplaceReady:l,loadingMore:!1,error:null}))):d(e=>({...e,loadingMore:!0}));try{let e=r?null:c.marketplaceCursor,t=await _({search:n||void 0,category:null!=m?m:void 0,cursor:e,limit:24});if(I.current!==o)return;d(e=>{let o=r?t.items:cS([...e.marketplaceToolkits,...t.items]),l=new Set(ck),a=n||m?o:[...o.filter(e=>l.has(e.slug)).sort((e,t)=>ck.indexOf(e.slug)-ck.indexOf(t.slug)),...o.filter(e=>!l.has(e.slug))];return{...e,marketplaceToolkits:a,marketplaceCursor:t.cursor,categories:t.categories,marketplaceLoading:!1,marketplaceReady:!0,loadingMore:!1,error:null}})}catch(e){if(I.current!==o)return;d(t=>({...t,marketplaceLoading:!1,marketplaceReady:!0,loadingMore:!1,error:e instanceof Error?e.message:"Failed to load apps."}))}},[m,h,_,c.marketplaceCursor,c.marketplaceReady]);(0,o.useEffect)(()=>{let e=window.setTimeout(()=>{x(u)},300);return()=>window.clearTimeout(e)},[u]),(0,o.useEffect)(()=>{s?T.current||(T.current=!0,D()):(T.current=!1,d(e=>({...e,loading:!1})))},[s,D]),(0,o.useEffect)(()=>{if(!s||c.loading)return;let e="".concat(h.trim().toLowerCase(),"::").concat(null!=m?m:"");c.marketplaceReady&&I.current===e||A({reset:!0})},[m,s,A,h,c.loading,c.marketplaceReady]);let W=(0,o.useMemo)(()=>sE(c.connections),[c.connections]),B=(0,o.useMemo)(()=>{let e=new Map;for(let t of W){let r=e.get(t.normalized_toolkit_slug);r?r.push(t):e.set(t.normalized_toolkit_slug,[t])}return e},[W]),F=(0,o.useMemo)(()=>{let e=new Map;for(let[t,r]of B){let n=r.filter(e=>e.is_active);n.length>0&&e.set(t,n)}return e},[B]),P=(0,o.useMemo)(()=>{let e=new Map;for(let[t,r]of F){let n=new Map;for(let e of r)n.has(e.account_identity)||n.set(e.account_identity,e);e.set(t,Array.from(n.values()))}return e},[F]),z=(0,o.useMemo)(()=>new Set(M.map(e=>sj(e.slug))),[M]),O=(0,o.useMemo)(()=>cS([...c.connectedToolkits,...M]).filter(e=>{let t=sj(e.slug);return P.has(t)||z.has(t)}),[P,M,z,c.connectedToolkits]),U=(0,o.useMemo)(()=>{let e=h.trim().toLowerCase();return c.marketplaceToolkits.filter(t=>{let r=sj(t.slug);return!(P.has(r)||z.has(r))&&(!e||t.name.toLowerCase().includes(e)||t.slug.toLowerCase().includes(e)||t.description.toLowerCase().includes(e))})},[P,h,z,c.marketplaceToolkits]),H=(0,o.useMemo)(()=>c.categories.slice(0,6),[c.categories]),V=v?null!=(r=B.get(sj(v.slug)))?r:[]:null,K=(0,o.useCallback)(e=>{g(e),b(!0)},[]),J=(0,o.useCallback)(e=>{if((null==e?void 0:e.toolkit)&&!1===e.connected){let t=sj(e.toolkit.slug);L(e=>e.filter(e=>sj(e.slug)!==t))}if(null==e?void 0:e.connected){var t,r,n,o,l,a,s,i,d,u;let p=null!=(o=null!=(n=e.connectedToolkitSlug)?n:null==(t=e.toolkit)?void 0:t.slug)?o:null,h=null!=(a=null!=(l=e.connectedToolkitName)?l:null==(r=e.toolkit)?void 0:r.name)?a:null;if(p&&h){let t=sj(p),r=null!=(i=[e.toolkit,...c.connectedToolkits,...c.marketplaceToolkits].filter(e=>!!e).find(e=>sj(e.slug)===t))?i:null,n=r?{...r,slug:t,name:h}:(u=null!=(d=null==(s=e.toolkit)?void 0:s.connect_slug)?d:p,{slug:sj(t),connect_slug:null!=u?u:t,name:h,description:"",logo:null,categories:[],auth_schemes:[],tools_count:0});L(e=>cS([...e.filter(e=>sj(e.slug)!==t),n]))}}D({fresh:!0}),(null==e?void 0:e.connected)&&window.setTimeout(()=>{D({fresh:!0})},1500),(null==e?void 0:e.shouldProbeLiveAgent)&&window.setTimeout(()=>{E("probe_live_agent")},300),A({reset:!0})},[D,E,A,c.connectedToolkits,c.marketplaceToolkits]),q=(0,o.useCallback)(async()=>{S(!0),N(null);try{let t=await fetch("/api/composio/status",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"repair_mcp"})}),r=await t.json().catch(()=>({}));if(!t.ok){var e;N(null!=(e=r.error)?e:aE("update"));return}k(r)}catch(e){N(e instanceof Error?e.message:aE("update"))}finally{S(!1)}},[]);if((0,o.useEffect)(()=>{if(!s||c.loading||c.marketplaceLoading||c.loadingMore||!c.marketplaceReady||!c.marketplaceCursor||!R.current)return;let e=R.current,t=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&A()},{rootMargin:"160px 0px"});return t.observe(e),()=>t.disconnect()},[s,A,c.loading,c.loadingMore,c.marketplaceCursor,c.marketplaceLoading,c.marketplaceReady]),!s)return(0,n.jsx)("div",{children:(0,n.jsx)("div",{className:"flex items-center justify-center rounded-2xl px-6 py-10",style:{background:"var(--color-surface)",border:"1px solid var(--color-border)"},children:(0,n.jsxs)("div",{className:"text-center",children:[(0,n.jsx)("p",{className:"text-sm",style:{color:"var(--color-text-muted)"},children:"Available with Dench Cloud"}),i&&(0,n.jsx)("span",{className:"mt-2 inline-flex items-center rounded-full px-3 py-1 text-[11px] font-medium",style:{background:"var(--color-surface-hover)",color:"var(--color-text)",border:"1px solid var(--color-border)"},children:i})]})})});let G=h.trim();return(0,n.jsxs)("div",{children:[(w||j&&"healthy"!==j.summary.level)&&(0,n.jsxs)("div",{className:"mb-6 flex items-start justify-between gap-3 rounded-xl px-3 py-2 text-xs",style:{background:"color-mix(in srgb, var(--color-error, #ef4444) 8%, transparent)",color:"var(--color-error, #ef4444)",border:"1px solid color-mix(in srgb, var(--color-error, #ef4444) 20%, transparent)"},children:[(0,n.jsxs)("div",{className:"min-w-0",children:[(0,n.jsx)("p",{className:"truncate",children:null!=(l=null!=w?w:null==j?void 0:j.summary.message)?l:a_.attentionLabel}),!w&&(null==j?void 0:j.liveAgent.detail)&&"healthy"!==j.summary.level&&(0,n.jsx)("p",{className:"mt-1 text-[11px] opacity-80",children:j.liveAgent.detail}),!w&&(null!=(a=null==j||null==(t=j.liveAgent.evidence)?void 0:t.length)?a:0)>0&&(0,n.jsxs)("p",{className:"mt-1 truncate text-[11px] opacity-70",children:["Evidence: ",null==j?void 0:j.liveAgent.evidence.slice(0,3).join(", ")]})]}),(0,n.jsx)("button",{type:"button",onClick:()=>void q(),disabled:C,className:"shrink-0 rounded-lg px-2 py-1 text-[11px] font-medium cursor-pointer transition-colors",style:{background:"color-mix(in srgb, var(--color-error, #ef4444) 15%, transparent)"},children:C?"Repairing...":"Repair"})]}),c.loading&&(0,n.jsx)("div",{className:"flex items-center justify-center py-16",children:(0,n.jsx)("div",{className:"w-6 h-6 border-2 rounded-full animate-spin",style:{borderColor:"var(--color-border)",borderTopColor:"var(--color-accent)"}})}),!c.loading&&c.error&&(0,n.jsxs)("div",{className:"p-8 text-center rounded-2xl",style:{background:"var(--color-surface)",border:"1px solid var(--color-border)"},children:[(0,n.jsx)("p",{className:"text-sm mb-3",style:{color:"var(--color-text-muted)"},children:c.error}),(0,n.jsx)(cm,{type:"button",variant:"outline",size:"sm",onClick:()=>void D(),children:"Retry"})]}),!c.loading&&!c.error&&(0,n.jsxs)(n.Fragment,{children:[O.length>0&&(0,n.jsxs)("section",{className:"mb-10",children:[(0,n.jsxs)("div",{className:"flex items-baseline gap-2.5 mb-4",children:[(0,n.jsx)("h2",{className:"text-lg font-bold tracking-tight",style:{color:"var(--color-text)"},children:"Your Apps"}),(0,n.jsx)("span",{className:"text-[11px] font-medium rounded-full px-2 py-0.5",style:{background:"var(--color-surface-hover)",color:"var(--color-text-muted)"},children:O.length})]}),(0,n.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:O.map(e=>{var t,r,o;let l=sj(e.slug),a=null!=(r=P.get(l))?r:[],s=null!=(o=null==(t=B.get(l))?void 0:t.length)?o:0;return(0,n.jsx)(cv,{toolkit:e,activeConnections:a.length,totalConnections:s,mode:"connected",onClick:()=>K(e)},e.slug)})})]}),(0,n.jsxs)("section",{children:[(0,n.jsx)("h2",{className:"text-lg font-bold tracking-tight mb-4",style:{color:"var(--color-text)"},children:"Discover"}),(0,n.jsxs)("div",{className:"relative mb-4",children:[(0,n.jsx)(cw,{}),(0,n.jsx)("input",{type:"text",value:u,onChange:e=>p(e.target.value),placeholder:"Search apps...",className:"w-full pl-9 pr-4 py-2.5 rounded-xl text-sm outline-none transition-shadow focus:shadow-[0_0_0_3px_rgba(0,122,255,0.12)]",style:{background:"var(--color-surface-hover)",color:"var(--color-text)"}})]}),H.length>0&&(0,n.jsxs)("div",{className:"mb-4 flex flex-wrap gap-1.5",children:[(0,n.jsx)("button",{type:"button",onClick:()=>f(null),className:"rounded-full px-3 py-1 text-[11px] font-medium transition-colors cursor-pointer",style:{background:m?"var(--color-surface)":"var(--color-accent)",color:m?"var(--color-text-muted)":"var(--color-bg, #fff)",border:"1px solid ".concat(m?"var(--color-border)":"var(--color-accent)")},children:"All"}),H.map(e=>(0,n.jsx)("button",{type:"button",onClick:()=>f(m===e?null:e),className:"rounded-full px-3 py-1 text-[11px] font-medium transition-colors cursor-pointer",style:{background:m===e?"var(--color-accent)":"var(--color-surface)",color:m===e?"var(--color-bg, #fff)":"var(--color-text-muted)",border:"1px solid ".concat(m===e?"var(--color-accent)":"var(--color-border)")},children:e},e))]}),c.marketplaceLoading&&c.marketplaceReady&&(0,n.jsx)("div",{className:"mb-4 text-xs",style:{color:"var(--color-text-muted)"},children:"Searching..."}),!c.marketplaceReady&&!c.loading&&(0,n.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,n.jsx)("div",{className:"w-5 h-5 border-2 rounded-full animate-spin",style:{borderColor:"var(--color-border)",borderTopColor:"var(--color-accent)"}})}),c.marketplaceReady&&U.length>0&&(0,n.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:U.map(e=>(0,n.jsx)(cv,{toolkit:e,activeConnections:0,mode:"marketplace",onClick:()=>K(e)},e.slug))}),c.marketplaceReady&&!c.marketplaceLoading&&0===U.length&&(0,n.jsxs)("div",{className:"p-8 text-center rounded-2xl",style:{background:"var(--color-surface)",border:"1px solid var(--color-border)"},children:[(0,n.jsx)("p",{className:"text-sm",style:{color:"var(--color-text-muted)"},children:G?'No apps found for "'.concat(G,'".'):m?'No apps found in "'.concat(m,'".'):"No apps found."}),(G||m)&&(0,n.jsx)("p",{className:"mt-2 text-xs",style:{color:"var(--color-text-muted)"},children:"Try clearing search or category filters."})]}),(!!c.marketplaceCursor||c.loadingMore)&&(0,n.jsx)("div",{ref:R,className:"flex items-center justify-center py-6 text-xs",style:{color:"var(--color-text-muted)"},children:c.loadingMore?"Loading more apps...":"Scroll to load more"})]})]}),(0,n.jsx)(cj,{toolkit:v,connections:null!=V?V:[],open:y,onOpenChange:b,onConnectionChange:J})]})}function cT(){let{embedded:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},[t,r]=(0,o.useState)(null),[l,a]=(0,o.useState)(!0),[s,i]=(0,o.useState)(null),c=(0,o.useCallback)(async()=>{a(!0),i(null);try{let e=await fetch("/api/integrations");if(!e.ok)throw Error("Failed to load integrations (".concat(e.status,")"));let t=await e.json();r(t)}catch(e){i(e instanceof Error?e.message:"Failed to load integrations")}finally{a(!1)}},[]);return(0,o.useEffect)(()=>{c()},[c]),(0,n.jsxs)("div",{className:"",children:[!e&&(0,n.jsxs)("div",{className:"mb-6 flex items-start justify-between gap-4",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h1",{className:"font-instrument text-3xl tracking-tight",style:{color:"var(--color-text)"},children:"Integrations"}),(0,n.jsx)("p",{className:"mt-1 text-sm",style:{color:"var(--color-text-muted)"},children:"Connect third-party apps to your Dench Cloud workspace."})]}),(0,n.jsxs)("a",{className:"flex shrink-0 items-center gap-1.5 rounded-full px-3 py-1.5 text-[11px] font-medium transition-opacity hover:opacity-80",style:{background:"var(--color-surface)",border:"1px solid var(--color-border)",color:"var(--color-text-muted)"},children:["Powered by",(0,n.jsx)("img",{src:"/logo/composio.webp",alt:"Composio",className:"h-10 w-auto dark:invert"})]})]}),l&&(0,n.jsx)("div",{className:"flex items-center justify-center py-16",children:(0,n.jsx)("div",{className:"h-6 w-6 animate-spin rounded-full border-2",style:{borderColor:"var(--color-border)",borderTopColor:"var(--color-accent)"}})}),!l&&s&&(0,n.jsxs)("div",{className:"rounded-xl border px-4 py-6 text-center",style:{borderColor:"var(--color-border)"},children:[(0,n.jsx)("p",{className:"text-sm mb-3",style:{color:"var(--color-text-muted)"},children:s}),(0,n.jsx)(cm,{type:"button",variant:"outline",onClick:()=>void c(),children:"Retry"})]}),!l&&!s&&t&&(0,n.jsx)(cL,{eligible:!!(t.denchCloud.hasKey&&t.denchCloud.isPrimaryProvider),lockBadge:t.denchCloud.hasKey?t.denchCloud.isPrimaryProvider?null:"Use Dench Cloud":"Get Dench Cloud API Key"})]})}async function cI(e,t){let r=sj(e),n=null,o=[],l=await fetch("/api/composio/connections?include_toolkits=1&fresh=1");if(l.ok){let e=await l.json();o=sL(e).filter(e=>sj(e.toolkit_slug)===r),n=sW(Array.isArray(e.toolkits)?e.toolkits:[],r,t)}if(!n){let e=new URLSearchParams({search:(null==t?void 0:t.trim())||r,limit:"24"}),o=await fetch("/api/composio/toolkits?".concat(e.toString()));o.ok&&(n=sW(sM(await o.json()).items,r,t))}return{toolkit:n,connections:o}}function cR(e){let{request:t,onFallbackToIntegrations:r}=e,[l,a]=(0,o.useState)(!1),[s,i]=(0,o.useState)(null),[c,d]=(0,o.useState)([]),[u,p]=(0,o.useState)("connect"),h=(0,o.useRef)(0),x=(0,o.useCallback)(async(e,t)=>{var n,o;let l=null==(n=e.toolkitSlug)?void 0:n.trim();if(!l){a(!1),i(null),d([]),r();return}let s=sj(l),c=function(e,t){var r;let n=sj(e),o=sk(void 0,n);return{slug:n,connect_slug:null!=(r=sb[sj(n)])?r:n.trim().toLowerCase(),name:"string"==typeof t&&t.trim().length>0?t.trim():o.includes("-")?o.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "):o.charAt(0).toUpperCase()+o.slice(1),description:"",logo:null,categories:[],auth_schemes:[],tools_count:0}}(s,e.toolkitName),u=h.current+1;h.current=u,p(e.action),(null==t?void 0:t.openModal)!==!1&&(i(c),d([]),a(!0));try{let t=await cI(s,e.toolkitName);if(u!==h.current)return;i(null!=(o=t.toolkit)?o:c),d(t.connections)}catch(e){if(u!==h.current)return;i(e=>null!=e?e:c)}},[r]);(0,o.useEffect)(()=>{t&&x(t)},[x,t]);let m=(0,o.useCallback)(e=>{var t,r,n,o,l,a,i,c;let d=null!=(l=null!=(o=null!=(n=null==e?void 0:e.connectedToolkitSlug)?n:null==e||null==(t=e.toolkit)?void 0:t.slug)?o:null==s?void 0:s.slug)?l:null;d&&x({action:u,toolkitSlug:d,toolkitName:null!=(c=null!=(i=null!=(a=null==e?void 0:e.connectedToolkitName)?a:null==e||null==(r=e.toolkit)?void 0:r.name)?i:null==s?void 0:s.name)?c:null},{openModal:!1})},[x,u,null==s?void 0:s.name,null==s?void 0:s.slug]);return(0,n.jsx)(cj,{toolkit:s,connections:c,open:l,preferredAction:u,onOpenChange:a,onConnectionChange:m})}var c_=r(82958),cE=r(96863),cD=r(47734);function cA(e){let{model:t,className:r}=e,o=t.provider.trim().toLowerCase(),l={color:"currentColor"};if("minimax"===o||"mini-max"===o)return(0,n.jsx)("img",{src:"/models/minimax.png",alt:"",className:r,draggable:!1,"data-provider-icon":"minimax"});if("deepseek"===o)return(0,n.jsx)("img",{src:"/models/deepseek.ico",alt:"",className:r,draggable:!1,"data-provider-icon":"deepseek"});if("kimi"===o||"moonshot"===o||"moonshotai"===o)return(0,n.jsx)("img",{src:"/models/kimi.png",alt:"",className:r,draggable:!1,"data-provider-icon":"kimi"});switch(o){case"anthropic":case"claude":return(0,n.jsx)(au.phd,{className:r,style:l,"data-provider-icon":"claude"});case"openai":case"chatgpt":return(0,n.jsx)(au.pz8,{className:r,style:l,"data-provider-icon":"openai"});case"google":return(0,n.jsx)(au.UKz,{className:r,style:{color:"#4285F4"},"data-provider-icon":"google"});case"meta":return(0,n.jsx)(au.awM,{className:r,style:{color:"#0668E1"},"data-provider-icon":"meta"});case"mistral":return(0,n.jsx)(au.$7J,{className:r,style:{color:"#FF7000"},"data-provider-icon":"mistral"});case"perplexity":return(0,n.jsx)(au.X_y,{className:r,style:{color:"#20B8CD"},"data-provider-icon":"perplexity"});default:return(0,n.jsx)("span",{className:r,style:{color:"var(--color-text-muted)",fontSize:"0.75rem",fontWeight:600,lineHeight:1},"aria-hidden":!0,"data-provider-icon":"fallback",children:t.provider.slice(0,1).toUpperCase()})}}function cW(e){var t,r,o,l,a;let{models:s,selectedModel:i,onSelect:c,disabled:d=!1,loading:u=!1,disabledHint:p,fallbackToFirst:h=!0,placeholder:m="Choose a model...",ariaLabel:f="Select chat model",triggerClassName:v}=e,g=null!=(r=function(e,t){let r="string"==typeof t?t.trim():"";if(r)return e.find(e=>e.stableId===r||"string"==typeof e.catalogId&&e.catalogId.trim()===r)}(s,i))?r:h&&null!=(t=s[0])?t:null;if(0===s.length)return null;let y=d&&u?"Switching model…":d&&(null==p?void 0:p.trim())?p.trim():null!=(o=null==g?void 0:g.displayName)?o:m;return(0,n.jsxs)(ef,{children:[(0,n.jsxs)(ev,{className:x("inline-flex max-w-full items-center gap-1.5 rounded-lg p-0 text-sm font-medium transition-opacity hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-60",v),style:{color:"var(--color-text-secondary)",opacity:.9},"aria-label":f,title:y,disabled:d,children:[g?(0,n.jsx)(cA,{model:g,className:"h-3.5 w-3.5 shrink-0"}):(0,n.jsx)("span",{className:"inline-block h-3.5 w-3.5 shrink-0 rounded-full",style:{background:"var(--color-surface-hover)"},"aria-hidden":!0}),(0,n.jsx)("span",{className:x("max-w-[240px] truncate",!g&&"italic"),style:g?void 0:{color:"var(--color-text-muted)"},children:null!=(l=null==g?void 0:g.displayName)?l:m}),d&&u?(0,n.jsx)(c_.A,{className:"h-3.5 w-3.5 shrink-0 animate-spin"}):d?(0,n.jsx)(cD.A,{className:"h-3.5 w-3.5 shrink-0 opacity-70","aria-hidden":!0}):(0,n.jsx)(cE.A,{className:"h-3.5 w-3.5 shrink-0"})]}),(0,n.jsx)(eg,{align:"start",side:"bottom",sideOffset:8,className:"min-w-[15rem] max-w-[20rem] p-1.5",children:(0,n.jsx)(ej,{value:null!=(a=null==g?void 0:g.stableId)?a:"",onValueChange:e=>{d||c(e)},children:s.map(e=>(0,n.jsxs)(ek,{value:e.stableId,disabled:d,children:[(0,n.jsx)(cA,{model:e,className:"h-4 w-4 shrink-0"}),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsx)("div",{className:"truncate text-sm font-medium",style:{color:"var(--color-text)"},children:e.displayName}),(0,n.jsxs)("div",{className:"mt-0.5 flex flex-wrap items-center gap-1.5 text-[10px]",style:{color:"var(--color-text-muted)"},children:[(0,n.jsx)("span",{children:e.provider}),e.reasoning&&(0,n.jsx)("span",{children:"Reasoning"}),e.isRecommended&&(0,n.jsx)("span",{className:"rounded-full px-1.5 py-0.5",style:{background:"var(--color-surface-hover)",color:"var(--color-text)"},children:"Recommended"})]})]})]},e.stableId))})})]})}var cB=r(28594);let cF=o.forwardRef((e,t)=>{let{className:r,...o}=e;return(0,n.jsx)(cB.bL,{className:x("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border border-zinc-300 bg-zinc-200 shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-zinc-900 data-[state=unchecked]:bg-zinc-200 dark:border-zinc-700 dark:data-[state=checked]:bg-zinc-50 dark:data-[state=unchecked]:bg-zinc-700",r),...o,ref:t,children:(0,n.jsx)(cB.zi,{className:x("pointer-events-none block h-5 w-5 rounded-full bg-white shadow-md ring-1 ring-black/10 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0 dark:bg-zinc-900 dark:ring-white/10")})})});function cP(e){let{notice:t}=e,r="success"===t.tone?"border-emerald-500/30 bg-emerald-500/10 text-emerald-100":"border-amber-500/30 bg-amber-500/10 text-amber-100";return(0,n.jsx)("div",{className:"rounded-xl border px-4 py-3 text-sm ".concat(r),children:t.message})}function cz(e){let{className:t}=e;return(0,n.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 64 64","aria-hidden":"true",className:t,children:(0,n.jsx)("path",{fill:"currentColor",d:"M32.4,0l-24,49.6h7.8l16.2-33.9l15.5,33.9h7.7L32.4,0z M25.5,49.6L32.4,64l6.7-14.4H25.5z"})})}cF.displayName=cB.bL.displayName;let cO={exa:"Search the web with Exa",apollo:"Enrich people and company data",elevenlabs:"Generate speech with ElevenLabs"};function cU(e){let{integration:t,isSaving:r,onToggle:o}=e,l=cO[t.id],a=r?"Saving...":t.locked?"Unavailable until Dench Cloud is ready":l;return(0,n.jsxs)("div",{className:"flex items-center justify-between gap-4 rounded-xl px-1 py-2",style:{background:"transparent"},children:[(0,n.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,n.jsx)("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg",style:{background:"var(--color-surface-hover)",color:"var(--color-text)"},children:function(e){switch(e){case"exa":return(0,n.jsx)("img",{src:"/integrations/exa-logomark.svg",alt:"",width:20,height:20,className:"h-5 w-5 shrink-0 object-contain",draggable:!1});case"apollo":return(0,n.jsx)(cz,{className:"h-5 w-5 shrink-0"});case"elevenlabs":return(0,n.jsx)(au.AHR,{className:"h-5 w-5 shrink-0","aria-hidden":!0})}}(t.id)}),(0,n.jsxs)("div",{className:"min-w-0",children:[(0,n.jsx)("div",{className:"truncate text-sm font-medium text-foreground",children:t.label}),(0,n.jsxs)("div",{className:"mt-1 flex flex-wrap items-center gap-2 text-[11px] leading-4 text-muted-foreground",children:[(0,n.jsx)("span",{children:a}),t.lockBadge&&(0,n.jsx)("span",{className:"inline-flex items-center rounded-full px-2 py-0.5 text-[10px] font-medium",style:{background:"var(--color-surface-hover)",color:"var(--color-text)"},children:t.lockBadge})]})]})]}),(0,n.jsx)(cF,{"aria-label":"Toggle ".concat(t.label),checked:t.enabled,disabled:r||t.locked,onCheckedChange:e=>o(t,e)})]})}function cH(){let[e,t]=(0,o.useState)(null),[r,l]=(0,o.useState)(!0),[a,s]=(0,o.useState)(null),[i,c]=(0,o.useState)(null),[d,u]=(0,o.useState)(!1),[p,h]=(0,o.useState)(null),x=(0,o.useCallback)(async()=>{l(!0),s(null);try{let e=await fetch("/api/integrations");if(!e.ok)throw Error("Failed to load integrations (".concat(e.status,")"));let r=await e.json();t(r)}catch(e){s(e instanceof Error?e.message:"Failed to load integrations")}finally{l(!1)}},[]);(0,o.useEffect)(()=>{x()},[x]);let m=(0,o.useMemo)(()=>{var t;return null!=(t=null==e?void 0:e.integrations)?t:[]},[e]),f=(0,o.useMemo)(()=>m.some(e=>("exa"===e.id||"apollo"===e.id)&&e.health.pluginMissing),[m]),v=(0,o.useCallback)(e=>{t(e)},[]),g=(0,o.useCallback)(async(e,t)=>{c(e.id),h(null);try{let n=await fetch("/api/integrations/".concat(e.id,"/toggle"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:t})}),o=await n.json();if(!n.ok)throw Error("error"in o&&o.error?o.error:"Failed to update ".concat(e.label));if(v(o),o.refresh.restarted)h({tone:"success",message:"".concat(e.label," updated and the ").concat(o.refresh.profile," gateway restarted successfully.")});else if(o.changed){var r;h({tone:"warning",message:"".concat(e.label," updated, but the gateway restart did not complete: ").concat(null!=(r=o.refresh.error)?r:"unknown error",".")})}else h({tone:"success",message:"".concat(e.label," was already in the requested state.")})}catch(t){h({tone:"warning",message:t instanceof Error?t.message:"Failed to update ".concat(e.label,".")})}finally{c(null)}},[v]),y=(0,o.useCallback)(async()=>{u(!0),h(null);try{let t=await fetch("/api/integrations/repair",{method:"POST"}),r=await t.json();if(!t.ok)throw Error("error"in r&&r.error?r.error:"Failed to repair integrations.");if(v(r),r.changed&&r.refresh.restarted){let e=r.repairedIds.length>0?r.repairedIds.join(", "):"profiles";h({tone:"success",message:"Repair completed for ".concat(e," and the ").concat(r.refresh.profile," gateway restarted successfully.")})}else if(r.changed){var e;h({tone:"warning",message:"Repair updated the profile, but the gateway restart did not complete: ".concat(null!=(e=r.refresh.error)?e:"unknown error",".")})}else h({tone:"success",message:"No repair changes were needed for this profile."})}catch(e){h({tone:"warning",message:e instanceof Error?e.message:"Failed to repair integrations."})}finally{u(!1)}},[v]);return r?(0,n.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,n.jsx)("div",{className:"h-5 w-5 animate-spin rounded-full border-2",style:{borderColor:"var(--color-border)",borderTopColor:"var(--color-accent)"}})}):a?(0,n.jsxs)("div",{className:"rounded-xl border px-4 py-4 text-center",style:{borderColor:"var(--color-border)"},children:[(0,n.jsx)("p",{className:"text-sm mb-2",style:{color:"var(--color-text-muted)"},children:a}),(0,n.jsx)(cm,{type:"button",variant:"outline",size:"sm",onClick:()=>void x(),children:"Retry"})]}):e?(0,n.jsxs)("div",{className:"space-y-4",children:[p&&(0,n.jsx)(cP,{notice:p}),f&&(0,n.jsx)(cm,{type:"button",variant:"outline",size:"sm",onClick:()=>void y(),disabled:d,children:d?"Repairing...":"Repair older profiles"}),(0,n.jsx)("div",{className:"space-y-1",children:m.map(e=>(0,n.jsx)(cU,{integration:e,isSaving:i===e.id,onToggle:g},e.id))})]}):null}let cV="__dench_default_voice__";function cK(e){let{notice:t}=e,r="success"===t.tone?"border-emerald-500/30 bg-emerald-500/10 text-emerald-300":"warning"===t.tone?"border-amber-500/30 bg-amber-500/10 text-amber-300":"border-red-500/30 bg-red-500/10 text-red-300";return(0,n.jsx)("div",{className:"rounded-xl border px-4 py-3 text-sm ".concat(r),children:t.message})}function cJ(){return(0,n.jsx)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z"})})}function cq(){return(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4"}),(0,n.jsx)("path",{d:"m21 2-9.6 9.6"}),(0,n.jsx)("circle",{cx:"7.5",cy:"15.5",r:"5.5"})]})}function cG(){return(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M15 3h6v6"}),(0,n.jsx)("path",{d:"M10 14 21 3"}),(0,n.jsx)("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"})]})}function c$(e){let{onSave:t,saving:r,notice:l,validationError:a}=e,[s,i]=(0,o.useState)("");return(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsxs)("div",{className:"flex items-center gap-3 rounded-xl border px-4 py-3",style:{borderColor:"var(--color-border)",background:"var(--color-surface)"},children:[(0,n.jsx)("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg shrink-0",style:{background:"var(--color-surface-hover)",color:"var(--color-text)"},children:(0,n.jsx)(cJ,{})}),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsx)("div",{className:"text-sm font-medium",style:{color:"var(--color-text)"},children:"Dench Cloud"}),(0,n.jsx)("div",{className:"text-[11px] mt-0.5",style:{color:"var(--color-text-muted)"},children:a?"Your API key is invalid. Enter a new one below.":"Connect to Dench Cloud for AI model access."})]}),(0,n.jsxs)("a",{href:"https://dench.com/api",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-xs font-medium px-3 py-1.5 rounded-lg transition-colors hover:bg-stone-200 dark:hover:bg-stone-700",style:{color:"var(--color-accent)"},children:["Get API Key ",(0,n.jsx)(cG,{})]})]}),a&&(0,n.jsx)("div",{className:"rounded-xl border border-red-500/30 bg-red-500/10 px-4 py-3 text-sm text-red-300",children:a}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsxs)("div",{className:"relative flex-1",children:[(0,n.jsx)("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 pointer-events-none",style:{color:"var(--color-text-muted)"},children:(0,n.jsx)(cq,{})}),(0,n.jsx)("input",{type:"password",value:s,onChange:e=>i(e.target.value),onKeyDown:e=>{"Enter"===e.key&&s.trim()&&!r&&t(s.trim())},placeholder:"Paste your Dench API key...",className:"w-full pl-9 pr-3 py-2.5 rounded-xl text-sm outline-none transition-colors",style:{background:"var(--color-surface)",border:"1px solid var(--color-border)",color:"var(--color-text)"},disabled:r})]}),(0,n.jsx)(cm,{type:"button",onClick:()=>{s.trim()&&t(s.trim())},disabled:!s.trim()||r,children:r?"Validating...":"Save"})]}),l&&(0,n.jsx)(cK,{notice:l})]})}function cZ(e){var t,r;let{models:o,selectedModel:l,selectedVoiceId:a,elevenLabsEnabled:s,isDenchPrimary:i,recommendedModelId:c,onSelect:d,onSelectVoice:u,selecting:p,savingVoice:h,voiceLoading:x,voices:m,notice:f}=e,v=o.map(e=>({stableId:e.stableId,...e.id.trim()&&e.id!==e.stableId?{catalogId:e.id}:{},displayName:e.displayName,provider:e.provider,reasoning:e.reasoning,isRecommended:e.id===c})),g=null!=(t=m.find(e=>e.voiceId===a))?t:null;return(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsxs)("div",{className:"flex items-center gap-3 rounded-xl border px-4 py-3",style:{borderColor:"var(--color-border)",background:"var(--color-surface)"},children:[(0,n.jsx)("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg shrink-0",style:{background:"var(--color-surface-hover)",color:"var(--color-text)"},children:(0,n.jsx)(cJ,{})}),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsx)("div",{className:"text-sm font-medium",style:{color:"var(--color-text)"},children:"Dench Cloud"}),(0,n.jsx)("div",{className:"text-[11px] mt-0.5",style:{color:"var(--color-text-muted)"},children:i?"Connected and active as your primary provider.":"Connected. Select a model to use Dench Cloud as your primary provider."})]}),(0,n.jsx)("span",{className:"inline-flex items-center rounded-full px-2.5 py-0.5 text-[10px] font-medium",style:{background:i?"rgba(16,185,129,0.15)":"var(--color-surface-hover)",color:i?"rgb(16,185,129)":"var(--color-text-muted)"},children:i?"Active":"Available"})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"block text-xs font-medium mb-2",style:{color:"var(--color-text-muted)"},children:"Primary Model"}),(0,n.jsx)(cW,{models:v,selectedModel:i?l:null,onSelect:d,disabled:p,loading:p,fallbackToFirst:i,placeholder:"Choose a model...",ariaLabel:"Select primary model"})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"block text-xs font-medium mb-2",style:{color:"var(--color-text-muted)"},children:"ElevenLabs Voice"}),(0,n.jsxs)(ef,{children:[(0,n.jsxs)(ev,{className:"inline-flex max-w-full items-center gap-1.5 rounded-lg p-0 text-sm font-medium transition-opacity hover:opacity-100 disabled:cursor-default disabled:opacity-60 cursor-pointer outline-none ring-0 border-none",style:{color:"var(--color-text-secondary)",opacity:.9},"aria-label":"Select ElevenLabs voice",title:null!=(r=null==g?void 0:g.name)?r:void 0,disabled:x||h||0===m.length,children:[(0,n.jsx)("span",{className:"max-w-[240px] truncate",style:x||!g&&0===m.length?{color:"var(--color-text-muted)"}:void 0,children:x?"Loading voices...":0===m.length?"No voices available":g?"".concat(g.name).concat(g.category?" \xb7 ".concat(g.category):""):"Default voice (first available)"}),x||h?(0,n.jsx)(c_.A,{className:"h-3.5 w-3.5 shrink-0 animate-spin","aria-hidden":!0}):(0,n.jsx)(cE.A,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0})]}),(0,n.jsx)(eg,{align:"start",side:"bottom",sideOffset:8,className:"min-w-[15rem] max-w-[20rem] p-1.5",children:(0,n.jsxs)(ej,{value:null!=a?a:cV,onValueChange:e=>{u(e===cV?null:e)},children:[(0,n.jsx)(ek,{value:cV,children:"Default voice (first available)"}),m.map(e=>(0,n.jsx)(ek,{value:e.voiceId,children:(0,n.jsxs)("span",{className:"truncate",children:[e.name,e.category?" \xb7 ".concat(e.category):""]})},e.voiceId))]})})]}),(0,n.jsxs)("div",{className:"mt-2 space-y-1",children:[(0,n.jsx)("p",{className:"text-[11px]",style:{color:"var(--color-text-muted)"},children:s?"Used for message playback and server-side voice input.":"Choose a voice now. Playback and server-side voice input stay off until ElevenLabs is enabled in Integrations."}),(null==g?void 0:g.description)&&(0,n.jsx)("p",{className:"text-[11px]",style:{color:"var(--color-text-muted)"},children:g.description})]})]}),f&&(0,n.jsx)(cK,{notice:f})]})}function cY(){let[e,t]=(0,o.useState)(null),[r,l]=(0,o.useState)([]),[a,s]=(0,o.useState)(!0),[i,c]=(0,o.useState)(!1),[d,u]=(0,o.useState)(null),[p,h]=(0,o.useState)(!1),[x,m]=(0,o.useState)(!1),[f,v]=(0,o.useState)(!1),[g,y]=(0,o.useState)(null),b=(0,o.useCallback)(async()=>{s(!0),u(null);try{let e=await fetch("/api/settings/cloud");if(!e.ok)throw Error("Failed to load cloud settings (".concat(e.status,")"));let r=await e.json();t(r)}catch(e){u(e instanceof Error?e.message:"Failed to load cloud settings.")}finally{s(!1)}},[]);(0,o.useEffect)(()=>{b()},[b]),(0,o.useEffect)(()=>{if((null==e?void 0:e.status)!=="valid")return void l([]);let t=!1;return c(!0),(async()=>{try{let e=await fetch("/api/voice/voices");if(!e.ok){t||l([]);return}let r=await e.json();t||l(Array.isArray(r.voices)?r.voices:[])}catch(e){t||l([])}finally{t||c(!1)}})(),()=>{t=!0}},[null==e?void 0:e.status,null==e?void 0:e.gatewayUrl]);let j=(0,o.useCallback)(async e=>{h(!0),y(null);try{var r,n;let o=await fetch("/api/settings/cloud",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"save_key",apiKey:e})}),l=await o.json();if(!o.ok)return void y({tone:"error",message:null!=(r=l.error)?r:"Failed to save API key."});t(l.state);let a=l.refresh;a.restarted?y({tone:"success",message:"API key saved and the ".concat(a.profile," gateway restarted successfully.")}):a.attempted?y({tone:"warning",message:"API key saved, but the gateway restart did not complete: ".concat(null!=(n=a.error)?n:"unknown error",".")}):y({tone:"success",message:"API key saved successfully."})}catch(e){y({tone:"error",message:e instanceof Error?e.message:"Failed to save API key."})}finally{h(!1)}},[]),k=(0,o.useCallback)(async e=>{m(!0),y(null);try{var r,n,o,l,a,s;let i=await fetch("/api/settings/cloud",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"select_model",stableId:e})}),c=await i.json();if(!i.ok)return void y({tone:"error",message:null!=(l=c.error)?l:"Failed to select model."});t(c.state);let d=c.refresh,u=null!=(a=null==(o=c.state)||null==(n=o.models)||null==(r=n.find(t=>t.stableId===e))?void 0:r.displayName)?a:e;d.restarted?y({tone:"success",message:"Switched to ".concat(u," and the ").concat(d.profile," gateway restarted successfully.")}):d.attempted?y({tone:"warning",message:"Switched to ".concat(u,", but the gateway restart did not complete: ").concat(null!=(s=d.error)?s:"unknown error",".")}):y({tone:"success",message:"Switched to ".concat(u,".")})}catch(e){y({tone:"error",message:e instanceof Error?e.message:"Failed to select model."})}finally{m(!1)}},[]),w=(0,o.useCallback)(async e=>{v(!0),y(null);try{var n,o;let l=await fetch("/api/settings/cloud",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"save_voice",voiceId:e})}),a=await l.json();if(!l.ok)return void y({tone:"error",message:null!=(o=a.error)?o:"Failed to save voice."});t(a.state);let s=null==(n=r.find(t=>t.voiceId===e))?void 0:n.name;y({tone:"success",message:e?"Saved ".concat(null!=s?s:"your selected voice"," for ElevenLabs playback."):"Cleared the custom ElevenLabs voice selection."})}catch(e){y({tone:"error",message:e instanceof Error?e.message:"Failed to save voice."})}finally{v(!1)}},[r]);return a?(0,n.jsx)("div",{className:"flex items-center justify-center py-16",children:(0,n.jsx)("div",{className:"h-6 w-6 animate-spin rounded-full border-2",style:{borderColor:"var(--color-border)",borderTopColor:"var(--color-accent)"}})}):d?(0,n.jsxs)("div",{className:"rounded-xl border px-4 py-6 text-center",style:{borderColor:"var(--color-border)"},children:[(0,n.jsx)("p",{className:"text-sm mb-3",style:{color:"var(--color-text-muted)"},children:d}),(0,n.jsx)(cm,{type:"button",variant:"outline",onClick:()=>void b(),children:"Retry"})]}):e?"no_key"===e.status||"invalid_key"===e.status?(0,n.jsxs)("div",{className:"space-y-8",children:[(0,n.jsx)(c$,{onSave:j,saving:p,notice:g,validationError:"invalid_key"===e.status?e.validationError:void 0}),(0,n.jsxs)("div",{children:[(0,n.jsx)("h2",{className:"text-sm font-medium mb-3",style:{color:"var(--color-text)"},children:"Integrations"}),(0,n.jsx)(cH,{})]})]}):(0,n.jsxs)("div",{className:"space-y-8",children:[(0,n.jsx)(cZ,{models:e.models,selectedModel:e.selectedDenchModel,selectedVoiceId:e.selectedVoiceId,elevenLabsEnabled:e.elevenLabsEnabled,isDenchPrimary:e.isDenchPrimary,recommendedModelId:e.recommendedModelId,onSelect:k,onSelectVoice:w,selecting:x,savingVoice:f,voiceLoading:i,voices:r,notice:g}),(0,n.jsxs)("div",{children:[(0,n.jsx)("h2",{className:"text-sm font-medium mb-3",style:{color:"var(--color-text)"},children:"Integrations"}),(0,n.jsx)(cH,{})]})]}):null}function cQ(e){var t;return{id:e.id,role:e.role,parts:null!=(t=e.parts)?t:[{type:"text",text:e.content}]}}function cX(e){let{sessionId:t}=e,[r,l]=(0,o.useState)([]),[a,s]=(0,o.useState)(!0),[i,c]=(0,o.useState)(null),d=(0,o.useCallback)(async()=>{try{var e,r;let n=await fetch("/api/web-sessions/".concat(encodeURIComponent(t)));if(!n.ok){let r=await fetch("/api/cron/runs/".concat(encodeURIComponent(t)));if(!r.ok)return void c(404===r.status?"Session transcript not found":"Failed to load session");let n=(null!=(e=(await r.json()).messages)?e:[]).filter(e=>"system"!==e.role).map(e=>({id:e.id,role:e.role,content:e.parts.filter(e=>"text"===e.type).map(e=>e.text).join("\n"),parts:e.parts.map(e=>{if("text"===e.type)return{type:"text",text:e.text};if("thinking"===e.type)return{type:"reasoning",text:e.thinking};if("tool-call"===e.type){var t;let r=null!=e.output?(()=>{try{return JSON.parse(e.output)}catch(t){return{output:e.output}}})():void 0,n={type:"tool-invocation",toolCallId:e.toolCallId,toolName:e.toolName,args:null!=(t=e.args)?t:{}};return null!=r&&(n.result=r),n}return{type:"text",text:""}}),timestamp:e.timestamp}));l(n);return}let o=await n.json();l(null!=(r=o.messages)?r:[])}catch(e){c("Failed to load session")}finally{s(!1)}},[t]);return((0,o.useEffect)(()=>{d()},[d]),a)?(0,n.jsxs)("div",{className:"flex items-center gap-2 py-4",children:[(0,n.jsx)("div",{className:"w-4 h-4 border-[1.5px] rounded-full animate-spin",style:{borderColor:"var(--color-border)",borderTopColor:"var(--color-accent)"}}),(0,n.jsx)("span",{className:"text-xs",style:{color:"var(--color-text-muted)"},children:"Loading session transcript..."})]}):i?(0,n.jsx)("div",{className:"text-xs rounded-lg px-3 py-2",style:{color:"var(--color-text-muted)",background:"var(--color-surface-hover)"},children:i}):0===r.length?(0,n.jsx)("div",{className:"text-xs py-2",style:{color:"var(--color-text-muted)"},children:"Empty session transcript."}):(0,n.jsxs)("div",{className:"space-y-1",children:[(0,n.jsx)("div",{className:"text-[11px] uppercase tracking-wider font-medium mb-2",style:{color:"var(--color-text-muted)"},children:"Session Transcript"}),r.map(e=>(0,n.jsx)(s2,{message:cQ(e)},e.id))]})}function c0(e){let{jobId:t,runAtMs:r,summary:l,fallback:a}=e,[s,i]=(0,o.useState)([]),[c,d]=(0,o.useState)(!0),[u,p]=(0,o.useState)(!1),h=(0,o.useCallback)(async()=>{if(!r||!l){d(!1),p(!0);return}try{let e=new URLSearchParams({jobId:t,runAtMs:String(r),summary:l}),n=await fetch("/api/cron/runs/search-transcript?".concat(e));if(!n.ok)return void p(!0);let o=await n.json();if(o.sessionId){let e=await fetch("/api/web-sessions/".concat(encodeURIComponent(o.sessionId)));if(e.ok){let t=await e.json();if(t.messages&&t.messages.length>0)return void i(t.messages)}}if(o.messages&&o.messages.length>0){let e=o.messages.filter(e=>"system"!==e.role).map(e=>({id:e.id,role:e.role,content:e.parts.filter(e=>"text"===e.type).map(e=>e.text).join("\n"),parts:e.parts.map(e=>{if("text"===e.type)return{type:"text",text:e.text};if("thinking"===e.type)return{type:"reasoning",text:e.thinking};if("tool-call"===e.type){var t;let r=null!=e.output?(()=>{try{return JSON.parse(e.output)}catch(t){return{output:e.output}}})():void 0,n={type:"tool-invocation",toolCallId:e.toolCallId,toolName:e.toolName,args:null!=(t=e.args)?t:{}};return null!=r&&(n.result=r),n}return{type:"text",text:""}}),timestamp:e.timestamp}));i(e)}else p(!0)}catch(e){p(!0)}finally{d(!1)}},[t,r,l]);return((0,o.useEffect)(()=>{h()},[h]),c)?(0,n.jsxs)("div",{className:"flex items-center gap-2 py-4",children:[(0,n.jsx)("div",{className:"w-4 h-4 border-[1.5px] rounded-full animate-spin",style:{borderColor:"var(--color-border)",borderTopColor:"var(--color-accent)"}}),(0,n.jsx)("span",{className:"text-xs",style:{color:"var(--color-text-muted)"},children:"Searching for transcript..."})]}):u||0===s.length?(0,n.jsx)(n.Fragment,{children:a}):(0,n.jsxs)("div",{className:"space-y-1",children:[(0,n.jsx)("div",{className:"text-[11px] uppercase tracking-wider font-medium mb-2",style:{color:"var(--color-text-muted)"},children:"Session Transcript"}),s.map(e=>(0,n.jsx)(s2,{message:cQ(e)},e.id))]})}function c1(e){return e<1e3?"".concat(e,"ms"):e<6e4?"".concat((e/1e3).toFixed(1),"s"):"".concat(Math.floor(e/6e4),"m ").concat(Math.floor(e%6e4/1e3),"s")}function c2(e){var t,r;let{job:l,onBack:a,onSendCommand:s,runFilter:i="all",onRunFilterChange:c,expandedRunTs:d,onExpandedRunChange:u}=e,[p,h]=(0,o.useState)([]),[x,m]=(0,o.useState)(!0),f=null!=d?d:null,v=null!=u?u:()=>{},g=(0,o.useCallback)(async()=>{try{var e;let t=await fetch("/api/cron/jobs/".concat(encodeURIComponent(l.id),"/runs?limit=50")),r=await t.json();h(null!=(e=r.entries)?e:[])}catch(e){}finally{m(!1)}},[l.id]);(0,o.useEffect)(()=>{g();let e=setInterval(g,15e3);return()=>clearInterval(e)},[g]);let y=l.enabled?l.state.runningAtMs?"running":null!=(t=l.state.lastStatus)?t:"idle":"disabled";return(0,n.jsxs)("div",{className:"p-6 max-w-4xl mx-auto",children:[(0,n.jsxs)("button",{type:"button",onClick:a,className:"flex items-center gap-1 text-sm mb-4 cursor-pointer",style:{color:"var(--color-text-muted)"},children:[(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"m12 19-7-7 7-7"}),(0,n.jsx)("path",{d:"M19 12H5"})]}),"Back to Cron"]}),(0,n.jsxs)("div",{className:"mb-6",children:[(0,n.jsxs)("div",{className:"flex items-center gap-3 mb-1",children:[(0,n.jsx)("h1",{className:"font-instrument text-3xl tracking-tight",style:{color:"var(--color-text)"},children:l.name}),(0,n.jsx)(c7,{status:y})]}),l.description&&(0,n.jsx)("p",{className:"text-sm mb-3",style:{color:"var(--color-text-muted)"},children:l.description}),(0,n.jsx)(c6,{job:l,onSendCommand:s})]}),(0,n.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-8",children:[(0,n.jsx)(c4,{job:l}),(0,n.jsxs)("div",{className:"rounded-2xl p-4",style:{background:"var(--color-surface)",border:"1px solid var(--color-border)"},children:[(0,n.jsx)("h3",{className:"text-xs font-medium uppercase tracking-wider mb-3",style:{color:"var(--color-text-muted)"},children:"Configuration"}),(0,n.jsxs)("div",{className:"space-y-2 text-sm",children:[(0,n.jsx)(c9,{label:"Schedule",value:function(e){switch(e.kind){case"cron":return e.expr+(e.tz?" (".concat(e.tz,")"):"");case"every":{let t=e.everyMs;if(t>=864e5)return"every ".concat(Math.round(t/864e5)," day(s)");if(t>=36e5)return"every ".concat(Math.round(t/36e5)," hour(s)");if(t>=6e4)return"every ".concat(Math.round(t/6e4)," minute(s)");return"every ".concat(Math.round(t/1e3)," second(s)")}case"at":return new Date(e.at).toLocaleString();default:return"unknown"}}(l.schedule)}),(0,n.jsx)(c9,{label:"Target",value:l.sessionTarget}),(0,n.jsx)(c9,{label:"Wake mode",value:l.wakeMode}),(0,n.jsx)(c9,{label:"Payload",value:"".concat(l.payload.kind,": ").concat("systemEvent"===(r=l.payload).kind?r.text.slice(0,120):r.message.slice(0,120))}),l.agentId&&(0,n.jsx)(c9,{label:"Agent",value:l.agentId}),l.delivery&&(0,n.jsx)(c9,{label:"Delivery",value:l.delivery.mode}),(0,n.jsx)(c9,{label:"Created",value:new Date(l.createdAtMs).toLocaleString()})]})]})]}),null!=l.state.consecutiveErrors&&l.state.consecutiveErrors>0&&(0,n.jsxs)("div",{className:"rounded-2xl p-4 mb-6",style:{background:"color-mix(in srgb, var(--color-error, #ef4444) 6%, var(--color-surface))",border:"1px solid color-mix(in srgb, var(--color-error, #ef4444) 18%, transparent)"},children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"var(--color-error, #ef4444)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,n.jsx)("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),(0,n.jsx)("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),(0,n.jsxs)("span",{className:"text-sm font-medium",style:{color:"var(--color-error, #ef4444)"},children:[l.state.consecutiveErrors," consecutive error",l.state.consecutiveErrors>1?"s":""]})]}),l.state.lastError&&(0,n.jsx)("p",{className:"text-xs font-mono mt-1",style:{color:"var(--color-error, #ef4444)",opacity:.8},children:l.state.lastError})]}),(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,n.jsx)("h2",{className:"text-sm font-medium uppercase tracking-wider",style:{color:"var(--color-text-muted)"},children:"Run History"}),(0,n.jsx)("div",{className:"flex items-center gap-1 rounded-lg p-0.5",style:{background:"var(--color-surface-hover)"},children:["all","ok","error","running"].map(e=>(0,n.jsx)("button",{type:"button",onClick:()=>null==c?void 0:c(e),className:"px-2.5 py-1 rounded-md text-[11px] font-medium cursor-pointer",style:{background:i===e?"var(--color-surface)":"transparent",color:i===e?"var(--color-text)":"var(--color-text-muted)",boxShadow:i===e?"var(--shadow-sm)":"none"},children:"all"===e?"All":e.charAt(0).toUpperCase()+e.slice(1)},e))})]}),x?(0,n.jsx)("div",{className:"flex items-center justify-center p-8",children:(0,n.jsx)("div",{className:"w-5 h-5 border-2 rounded-full animate-spin",style:{borderColor:"var(--color-border)",borderTopColor:"var(--color-accent)"}})}):0===p.length?(0,n.jsx)("div",{className:"p-8 text-center rounded-2xl",style:{background:"var(--color-surface)",border:"1px solid var(--color-border)"},children:(0,n.jsx)("p",{className:"text-sm",style:{color:"var(--color-text-muted)"},children:"No runs recorded yet."})}):(0,n.jsx)("div",{className:"space-y-2",children:p.toReversed().filter(e=>"all"===i||e.status===i).map(e=>(0,n.jsx)(c5,{run:e,isExpanded:f===e.ts,onToggle:()=>v(f===e.ts?null:e.ts)},"".concat(e.ts,"-").concat(e.jobId)))})]})]})}function c4(e){let{job:t}=e,[r,l]=(0,o.useState)(Date.now());(0,o.useEffect)(()=>{let e=setInterval(()=>l(Date.now()),1e3);return()=>clearInterval(e)},[]);let a=t.state.nextRunAtMs,s=!!t.state.runningAtMs;return(0,n.jsxs)("div",{className:"rounded-2xl p-4 flex flex-col justify-center",style:{background:"var(--color-surface)",border:"1px solid var(--color-border)"},children:[(0,n.jsx)("h3",{className:"text-xs font-medium uppercase tracking-wider mb-2",style:{color:"var(--color-text-muted)"},children:s?"Currently Running":"Next Run"}),s?(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("span",{className:"w-2 h-2 rounded-full animate-pulse",style:{background:"var(--color-accent)"}}),(0,n.jsx)("span",{className:"text-2xl font-semibold",style:{color:"var(--color-accent)"},children:"Running now"})]}):a?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"text-3xl font-semibold mb-1",style:{color:"var(--color-text)"},children:a>r?function(e){if(e<=0)return"now";let t=Math.ceil(e/1e3);if(t<60)return"".concat(t,"s");let r=Math.floor(t/60),n=t%60;if(r<60)return n>0?"".concat(r,"m ").concat(n,"s"):"".concat(r,"m");let o=Math.floor(r/60),l=r%60;return l>0?"".concat(o,"h ").concat(l,"m"):"".concat(o,"h")}(a-r):"overdue"}),(0,n.jsx)("div",{className:"text-xs",style:{color:"var(--color-text-muted)"},children:new Date(a).toLocaleString()})]}):(0,n.jsx)("div",{className:"text-lg",style:{color:"var(--color-text-muted)"},children:t.enabled?"Not scheduled":"Disabled"})]})}function c5(e){var t;let{run:r,isExpanded:o,onToggle:l}=e,a="ok"===r.status?"var(--color-success, #22c55e)":"error"===r.status?"var(--color-error, #ef4444)":"var(--color-warning, #f59e0b)",s=!!r.sessionId;return(0,n.jsxs)("div",{className:"rounded-xl overflow-hidden",style:{background:"var(--color-surface)",border:"1px solid var(--color-border)"},children:[(0,n.jsxs)("button",{type:"button",onClick:l,className:"w-full flex items-center gap-3 px-4 py-3 text-left cursor-pointer transition-colors",onMouseEnter:e=>{e.currentTarget.style.background="var(--color-surface-hover)"},onMouseLeave:e=>{e.currentTarget.style.background="transparent"},children:[(0,n.jsx)("span",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0",style:{background:a}}),(0,n.jsx)("span",{className:"text-sm flex-shrink-0",style:{color:"var(--color-text)"},title:new Date(r.ts).toLocaleString(),children:function(e){let t=Date.now()-e;return t<0||t<6e4?"just now":t<36e5?"".concat(Math.floor(t/6e4),"m ago"):t<864e5?"".concat(Math.floor(t/36e5),"h ago"):t<6048e5?"".concat(Math.floor(t/864e5),"d ago"):new Date(e).toLocaleDateString()}(r.ts)}),(0,n.jsx)("span",{className:"text-xs px-2 py-0.5 rounded-full flex-shrink-0",style:{background:"color-mix(in srgb, ".concat(a," 12%, transparent)"),color:a},children:null!=(t=r.status)?t:"unknown"}),null!=r.durationMs&&(0,n.jsx)("span",{className:"text-xs flex-shrink-0",style:{color:"var(--color-text-muted)"},children:c1(r.durationMs)}),r.summary&&(0,n.jsx)("span",{className:"text-xs truncate flex-1 min-w-0",style:{color:"var(--color-text-muted)"},children:r.summary}),s&&(0,n.jsxs)("span",{className:"text-[10px] px-1.5 py-0.5 rounded flex-shrink-0 flex items-center gap-1",style:{background:"var(--color-surface-hover)",color:"var(--color-text-muted)"},children:[(0,n.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})}),"session"]}),(0,n.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 12 12",fill:"none",stroke:"var(--color-text-muted)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:"flex-shrink-0 transition-transform duration-200 ".concat(o?"":"-rotate-90"),children:(0,n.jsx)("path",{d:"M3 4.5L6 7.5L9 4.5"})})]}),o&&(0,n.jsxs)("div",{className:"px-4 pb-4",style:{borderTop:"1px solid var(--color-border)"},children:[(0,n.jsxs)("div",{className:"flex items-center gap-4 mt-3 mb-3 flex-wrap",children:[(0,n.jsx)("span",{className:"text-xs",style:{color:"var(--color-text-muted)"},children:new Date(r.ts).toLocaleString()}),null!=r.durationMs&&(0,n.jsxs)("span",{className:"text-xs",style:{color:"var(--color-text-muted)"},children:["Duration: ",c1(r.durationMs)]})]}),r.error&&(0,n.jsx)("div",{className:"text-xs font-mono rounded-lg px-3 py-2 mb-3",style:{color:"var(--color-error, #ef4444)",background:"color-mix(in srgb, var(--color-error, #ef4444) 6%, var(--color-surface))"},children:r.error}),r.sessionId?(0,n.jsx)(cX,{sessionId:r.sessionId}):(0,n.jsx)(c3,{run:r})]})]})}function c3(e){let{run:t}=e,r=t.summary?(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"text-[11px] uppercase tracking-wider font-medium mb-2",style:{color:"var(--color-text-muted)"},children:"Run Output"}),(0,n.jsx)("div",{className:"chat-prose text-sm",style:{color:"var(--color-text)"},children:(0,n.jsx)(aI.oz,{remarkPlugins:[aR.A],children:t.summary})})]}):(0,n.jsx)("div",{className:"text-xs",style:{color:"var(--color-text-muted)"},children:"No output recorded for this run."});return(0,n.jsx)(c0,{jobId:t.jobId,runAtMs:t.runAtMs,summary:t.summary,fallback:r})}function c6(e){let{job:t,onSendCommand:r}=e;return(0,n.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[!t.state.runningAtMs&&t.enabled&&(0,n.jsxs)(c8,{onClick:()=>null==r?void 0:r('Run cron job "'.concat(t.name,'" (').concat(t.id,") now with --force")),accent:!0,children:[(0,n.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("polygon",{points:"6 3 20 12 6 21 6 3"})}),"Run now"]}),t.state.runningAtMs&&(0,n.jsxs)(c8,{disabled:!0,accent:!0,children:[(0,n.jsx)("span",{className:"w-1.5 h-1.5 rounded-full animate-pulse",style:{background:"currentColor"}}),"Running..."]}),(0,n.jsx)(c8,{onClick:()=>null==r?void 0:r("".concat(t.enabled?"Disable":"Enable",' cron job "').concat(t.name,'" (').concat(t.id,")")),children:t.enabled?"Disable":"Enable"}),(0,n.jsx)(c8,{onClick:()=>null==r?void 0:r('Delete cron job "'.concat(t.name,'" (').concat(t.id,")")),danger:!0,children:"Delete"})]})}function c8(e){let{children:t,onClick:r,disabled:o,accent:l,danger:a}=e;return(0,n.jsx)("button",{type:"button",onClick:r,disabled:o,className:"text-xs font-medium px-3 py-1.5 rounded-lg flex items-center gap-1.5 cursor-pointer transition-opacity disabled:opacity-40 disabled:cursor-not-allowed",style:{background:l?"var(--color-accent)":a?"color-mix(in srgb, var(--color-error, #ef4444) 12%, transparent)":"var(--color-surface-hover)",color:l?"white":a?"var(--color-error, #ef4444)":"var(--color-text-muted)"},children:t})}function c7(e){let{status:t}=e,r="ok"===t?"var(--color-success, #22c55e)":"running"===t?"var(--color-accent)":"error"===t?"var(--color-error, #ef4444)":"var(--color-text-muted)";return(0,n.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-xs px-2.5 py-1 rounded-full",style:{background:"color-mix(in srgb, ".concat(r," 12%, transparent)"),color:r},children:["running"===t&&(0,n.jsx)("span",{className:"w-1.5 h-1.5 rounded-full animate-pulse",style:{background:r}}),t]})}function c9(e){let{label:t,value:r}=e;return(0,n.jsxs)("div",{className:"flex items-start gap-2",children:[(0,n.jsx)("span",{className:"text-xs font-medium w-20 flex-shrink-0",style:{color:"var(--color-text-muted)"},children:t}),(0,n.jsx)("span",{className:"text-xs break-all",style:{color:"var(--color-text)"},children:r})]})}function de(e){var t,r;let{job:o,run:l,sessionId:a,onBack:s,onBackToJob:i}=e,c="ok"===l.status?"var(--color-success, #22c55e)":"error"===l.status?"var(--color-error, #ef4444)":"var(--color-warning, #f59e0b)";return(0,n.jsxs)("div",{className:"h-full flex flex-col",children:[(0,n.jsxs)("div",{className:"px-4 py-3 flex items-center gap-3 flex-shrink-0",style:{borderBottom:"1px solid var(--color-border)",background:"var(--color-bg-glass)"},children:[(0,n.jsx)("button",{type:"button",onClick:s,className:"p-1.5 rounded-lg flex-shrink-0 cursor-pointer",style:{color:"var(--color-text-muted)"},title:"Back to Cron",children:(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"m12 19-7-7 7-7"}),(0,n.jsx)("path",{d:"M19 12H5"})]})}),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("button",{type:"button",onClick:i,className:"text-sm font-semibold truncate cursor-pointer hover:underline",style:{color:"var(--color-text)"},title:"Back to job detail",children:o.name}),(0,n.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full flex-shrink-0",style:{background:"color-mix(in srgb, ".concat(c," 12%, transparent)"),color:c},children:null!=(t=l.status)?t:"unknown"})]}),(0,n.jsxs)("div",{className:"flex items-center gap-3 text-xs",style:{color:"var(--color-text-muted)"},children:[(0,n.jsx)("span",{children:new Date(l.ts).toLocaleString()}),null!=l.durationMs&&(0,n.jsx)("span",{children:(r=l.durationMs)<1e3?"".concat(r,"ms"):r<6e4?"".concat((r/1e3).toFixed(1),"s"):"".concat(Math.floor(r/6e4),"m ").concat(Math.floor(r%6e4/1e3),"s")}),l.summary&&(0,n.jsx)("span",{className:"truncate",children:l.summary})]})]})]}),(0,n.jsx)("div",{className:"flex-1 min-h-0",children:(0,n.jsx)(ih,{initialSessionId:a,sessionTitle:"".concat(o.name," - Run ").concat(new Date(l.ts).toLocaleString())})})]})}function dt(){return(0,n.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})})}function dr(){return(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M12 5v14"}),(0,n.jsx)("path",{d:"M5 12h14"})]})}function dn(e){let{size:t=12}=e;return(0,n.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M18 6 6 18"}),(0,n.jsx)("path",{d:"m6 6 12 12"})]})}function dl(){return(0,n.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"m6 9 6 6 6-6"})})}function da(){return(0,n.jsx)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z"})})}function ds(){return(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M3 6h18"}),(0,n.jsx)("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),(0,n.jsx)("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]})}let di={text:"Aa",number:"#",date:"\uD83D\uDCC5",boolean:"☑",enum:"\uD83C\uDFF7",relation:"\uD83D\uDD17",user:"\uD83D\uDC64",richtext:"\xb6",email:"@"};function dc(e){let{trigger:t,open:r,onOpenChange:l,children:a,align:s="left"}=e,i=(0,o.useRef)(null);return(0,o.useEffect)(()=>{if(!r)return;let e=e=>{i.current&&!i.current.contains(e.target)&&l(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[r,l]),(0,n.jsxs)("div",{ref:i,className:"relative inline-block",children:[(0,n.jsx)("div",{onClick:()=>l(!r),children:t}),r&&(0,n.jsx)("div",{className:"absolute z-50 mt-1 rounded-lg shadow-lg border py-1 min-w-[160px] sm:min-w-[200px] max-w-[calc(100vw-2rem)] max-h-[320px] overflow-y-auto",style:{background:"var(--color-surface)",borderColor:"var(--color-border)",["right"===s?"right":"left"]:0},children:a})]})}function dd(e){let{children:t,onClick:r,danger:o,active:l}=e;return(0,n.jsx)("button",{type:"button",className:"w-full text-left px-3 py-1.5 text-xs transition-colors cursor-pointer flex items-center gap-2",style:{color:o?"var(--color-error, #ef4444)":l?"var(--color-accent)":"var(--color-text)",background:l?"var(--color-accent-light, rgba(99,102,241,0.1))":"transparent"},onMouseEnter:e=>{e.currentTarget.style.background=o?"rgba(239,68,68,0.1)":"var(--color-accent-light, rgba(99,102,241,0.1))"},onMouseLeave:e=>{e.currentTarget.style.background=l?"var(--color-accent-light, rgba(99,102,241,0.1))":"transparent"},onClick:r,children:t})}function du(e){let{value:t,onChange:r,placeholder:o}=e;return(0,n.jsx)("input",{type:"text",value:t,onChange:e=>r(e.target.value),placeholder:null!=o?o:"Value...",className:"px-2 py-1 rounded-md text-xs outline-none min-w-[80px] sm:min-w-[120px]",style:{background:"var(--color-bg)",border:"1px solid var(--color-border)",color:"var(--color-text)"}})}function dp(e){let{value:t,valueTo:r,showRange:o,onChange:l}=e;return(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)("input",{type:"number",value:null!=t?t:"",onChange:e=>l(e.target.value?Number(e.target.value):void 0,r),placeholder:o?"Min":"Value",className:"px-2 py-1 rounded-md text-xs outline-none w-20",style:{background:"var(--color-bg)",border:"1px solid var(--color-border)",color:"var(--color-text)"}}),o&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"text-[10px]",style:{color:"var(--color-text-muted)"},children:"to"}),(0,n.jsx)("input",{type:"number",value:null!=r?r:"",onChange:e=>l(t,e.target.value?Number(e.target.value):void 0),placeholder:"Max",className:"px-2 py-1 rounded-md text-xs outline-none w-20",style:{background:"var(--color-bg)",border:"1px solid var(--color-border)",color:"var(--color-text)"}})]})]})}function dh(e){let{value:t,valueTo:r,showRange:o,showRelative:l,relativeAmount:a,relativeUnit:s,onChange:i}=e;return l?(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)("input",{type:"number",min:1,value:null!=a?a:7,onChange:e=>i({relativeAmount:Number(e.target.value)||7}),className:"px-2 py-1 rounded-md text-xs outline-none w-16",style:{background:"var(--color-bg)",border:"1px solid var(--color-border)",color:"var(--color-text)"}}),(0,n.jsxs)("select",{value:null!=s?s:"days",onChange:e=>i({relativeUnit:e.target.value}),className:"px-2 py-1 rounded-md text-xs outline-none cursor-pointer",style:{background:"var(--color-bg)",border:"1px solid var(--color-border)",color:"var(--color-text)"},children:[(0,n.jsx)("option",{value:"days",children:"days"}),(0,n.jsx)("option",{value:"weeks",children:"weeks"}),(0,n.jsx)("option",{value:"months",children:"months"})]})]}):(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)("input",{type:"date",value:t,onChange:e=>i({value:e.target.value}),className:"px-2 py-1 rounded-md text-xs outline-none",style:{background:"var(--color-bg)",border:"1px solid var(--color-border)",color:"var(--color-text)",colorScheme:"dark"}}),o&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"text-[10px]",style:{color:"var(--color-text-muted)"},children:"to"}),(0,n.jsx)("input",{type:"date",value:r,onChange:e=>i({valueTo:e.target.value}),className:"px-2 py-1 rounded-md text-xs outline-none",style:{background:"var(--color-bg)",border:"1px solid var(--color-border)",color:"var(--color-text)",colorScheme:"dark"}})]})]})}function dx(e){var t;let{value:r,enumValues:o,enumColors:l,multiple:a,onChange:s}=e,i=Array.isArray(r)?r:r?[r]:[];return a?(0,n.jsx)("div",{className:"flex flex-wrap gap-1",children:o.map((e,t)=>{var o;let a=i.includes(e),c=null!=(o=null==l?void 0:l[t])?o:"#94a3b8";return(0,n.jsx)("button",{type:"button",onClick:()=>{let t=a?i.filter(t=>t!==e):[...i,e];s(1!==t.length||Array.isArray(r)?t:t[0])},className:"px-2 py-0.5 rounded-full text-[10px] transition-colors cursor-pointer",style:{background:a?"".concat(c,"20"):"var(--color-surface)",border:"1px solid ".concat(a?"".concat(c,"60"):"var(--color-border)"),color:a?c:"var(--color-text-muted)"},children:e},e)})}):(0,n.jsxs)("select",{value:"string"==typeof r?r:null!=(t=r[0])?t:"",onChange:e=>s(e.target.value),className:"px-2 py-1 rounded-md text-xs outline-none cursor-pointer",style:{background:"var(--color-bg)",border:"1px solid var(--color-border)",color:"var(--color-text)",minWidth:100},children:[(0,n.jsx)("option",{value:"",children:"Select..."}),o.map(e=>(0,n.jsx)("option",{value:e,children:e},e))]})}function dm(){return null}function df(e){let{value:t,relatedObjectName:r,members:o,multiple:l,onChange:a}=e;if(o&&o.length>0){let e=Array.isArray(t)?t:t?[t]:[];return(0,n.jsx)("div",{className:"flex flex-wrap gap-1",children:o.map(t=>{let r=e.includes(t.id);return(0,n.jsx)("button",{type:"button",onClick:()=>{l?a(r?e.filter(e=>e!==t.id):[...e,t.id]):a(r?"":t.id)},className:"px-2 py-0.5 rounded-full text-[10px] transition-colors cursor-pointer",style:{background:r?"var(--color-accent-light)":"var(--color-surface)",border:"1px solid ".concat(r?"var(--color-accent)":"var(--color-border)"),color:r?"var(--color-accent)":"var(--color-text-muted)"},children:t.name},t.id)})})}return(0,n.jsx)(du,{value:Array.isArray(t)?t.join(", "):String(null!=t?t:""),onChange:e=>{let t=e.split(",").map(e=>e.trim()).filter(Boolean);a(1===t.length?t[0]:t)},placeholder:r?"Search ".concat(r,"..."):"ID..."})}function dv(e){var t,r,o,l,a,s,i;let{rule:c,field:d,fields:u,members:p,onUpdate:h,onRemove:x}=e,m=null!=(t=null==d?void 0:d.type)?t:"text",f=function(e){switch(e){case"text":case"richtext":case"email":default:return nI;case"number":return nR;case"date":return n_;case"enum":return nE;case"boolean":return nD;case"relation":case"user":return nA;case"tags":return nW}}(m),v="between"===c.operator||"date_between"===c.operator,g="relative_past"===c.operator||"relative_next"===c.operator,y="is_any_of"===c.operator||"is_none_of"===c.operator||"has_any"===c.operator||"has_none"===c.operator||"has_all"===c.operator,b="is_empty"===c.operator||"is_not_empty"===c.operator||"is_true"===c.operator||"is_false"===c.operator;return(0,n.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap",children:[(0,n.jsx)("select",{value:c.field,onChange:e=>(e=>{var t;let r=u.find(t=>t.name===e);h({field:e,operator:nB(null!=(t=null==r?void 0:r.type)?t:"text"),value:void 0,valueTo:void 0,relativeAmount:void 0,relativeUnit:void 0})})(e.target.value),className:"px-2 py-1 rounded-md text-xs outline-none cursor-pointer font-medium",style:{background:"var(--color-bg)",border:"1px solid var(--color-border)",color:"var(--color-text)",maxWidth:140},children:u.map(e=>{var t;return(0,n.jsxs)("option",{value:e.name,children:[null!=(t=di[e.type])?t:"?"," ",e.name]},e.name)})}),(0,n.jsx)("select",{value:c.operator,onChange:e=>h({operator:e.target.value,value:void 0,valueTo:void 0}),className:"px-2 py-1 rounded-md text-xs outline-none cursor-pointer",style:{background:"var(--color-bg)",border:"1px solid var(--color-border)",color:"var(--color-text-muted)"},children:f.map(e=>(0,n.jsx)("option",{value:e.value,children:e.label},e.value))}),!b&&(0,n.jsxs)(n.Fragment,{children:[("text"===m||"richtext"===m||"email"===m||"tags"===m)&&(0,n.jsx)(du,{value:String(null!=(r=c.value)?r:""),onChange:e=>h({value:e})}),"number"===m&&(0,n.jsx)(dp,{value:"number"==typeof c.value?c.value:void 0,valueTo:"number"==typeof c.valueTo?c.valueTo:void 0,showRange:v,onChange:(e,t)=>h({value:e,valueTo:t})}),"date"===m&&(0,n.jsx)(dh,{value:String(null!=(o=c.value)?o:""),valueTo:String(null!=(l=c.valueTo)?l:""),showRange:v,showRelative:g,relativeAmount:c.relativeAmount,relativeUnit:c.relativeUnit,onChange:h}),"enum"===m&&(0,n.jsx)(dx,{value:null!=(a=c.value)?a:"",enumValues:null!=(s=null==d?void 0:d.enum_values)?s:[],enumColors:null==d?void 0:d.enum_colors,multiple:y,onChange:e=>h({value:e})}),"boolean"===m&&(0,n.jsx)(dm,{}),("relation"===m||"user"===m)&&(0,n.jsx)(df,{value:null!=(i=c.value)?i:"",relatedObjectName:null==d?void 0:d.related_object_name,members:"user"===m?p:void 0,multiple:y,onChange:e=>h({value:e})})]}),(0,n.jsx)("button",{type:"button",onClick:x,className:"p-1 rounded transition-colors cursor-pointer",style:{color:"var(--color-text-muted)"},title:"Remove filter",children:(0,n.jsx)(dn,{size:14})})]})}function dg(e){let{fields:t,filters:r,onFiltersChange:l,savedViews:a,activeViewName:s,onSaveView:i,onLoadView:c,onDeleteView:d,onSetActiveView:u,members:p}=e,[h,x]=(0,o.useState)(!1),[m,f]=(0,o.useState)(!1),[v,g]=(0,o.useState)(!1),[y,b]=(0,o.useState)(""),j=(0,o.useRef)(null),k=r.rules.length>0;(0,o.useEffect)(()=>{v&&j.current&&j.current.focus()},[v]);let w=(0,o.useCallback)(e=>{var n;let o=t.find(t=>t.name===e),a=null!=(n=null==o?void 0:o.type)?n:"text",s={id:Math.random().toString(36).slice(2,9),field:e,operator:nB(a)};l({...r,rules:[...r.rules,s]}),x(!1)},[t,r,l]),N=(0,o.useCallback)((e,t)=>{let n=r.rules.map(r=>nF(r)||r.id!==e?r:{...r,...t});l({...r,rules:n})},[r,l]),C=(0,o.useCallback)(e=>{let t=r.rules.filter(t=>!!nF(t)||t.id!==e);l({...r,rules:t})},[r,l]),S=(0,o.useCallback)(()=>{l(nz()),u(void 0)},[l,u]),M=(0,o.useCallback)(()=>{l({...r,conjunction:"and"===r.conjunction?"or":"and"})},[r,l]),L=(0,o.useCallback)(()=>{y.trim()&&(i(y.trim()),b(""),g(!1))},[y,i]),T=(0,o.useMemo)(()=>{let e={};for(let n of t){var r;let t=null!=(r=e[n.type])?r:[];t.push(n),e[n.type]=t}return e},[t]);return(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,n.jsxs)("span",{className:"flex items-center gap-1.5 text-xs font-medium",style:{color:"var(--color-text-muted)"},children:[(0,n.jsx)(dt,{}),"Filters"]}),r.rules.length>=2&&(0,n.jsx)("button",{type:"button",onClick:M,className:"px-2 py-0.5 rounded-full text-[10px] font-semibold uppercase tracking-wider transition-colors cursor-pointer",style:{background:"var(--color-accent-light, rgba(99,102,241,0.1))",color:"var(--color-accent)",border:"1px solid var(--color-accent)"},title:"Matching ".concat("and"===r.conjunction?"ALL":"ANY"," rules. Click to toggle."),children:r.conjunction}),r.rules.map(e=>nF(e)?null:(0,n.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[11px] max-w-[180px] sm:max-w-[250px] truncate",style:{background:"var(--color-accent-light, rgba(99,102,241,0.1))",color:"var(--color-accent)",border:"1px solid var(--color-accent)"},title:nO(e),children:[(0,n.jsx)("span",{className:"truncate",children:nO(e)}),(0,n.jsx)("button",{type:"button",onClick:()=>C(e.id),className:"flex-shrink-0 cursor-pointer p-0.5 rounded-full transition-colors",style:{color:"var(--color-accent)"},children:(0,n.jsx)(dn,{size:10})})]},e.id)),(0,n.jsx)(dc,{trigger:(0,n.jsxs)("button",{type:"button",className:"flex items-center gap-1 px-2 py-1 rounded-md text-xs transition-colors cursor-pointer",style:{color:"var(--color-text-muted)",border:"1px dashed var(--color-border)"},children:[(0,n.jsx)(dr,{})," Add filter"]}),open:h,onOpenChange:x,children:Object.entries(T).map(e=>{var t;let[r,o]=e;return(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"px-3 py-1 text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--color-text-muted)"},children:[null!=(t=di[r])?t:"?"," ",r]}),o.map(e=>(0,n.jsx)(dd,{onClick:()=>w(e.name),children:e.name},e.name))]},r)})}),k&&(0,n.jsxs)("button",{type:"button",onClick:S,className:"flex items-center gap-1 px-2 py-1 rounded-md text-[11px] transition-colors cursor-pointer",style:{color:"var(--color-accent)",background:"var(--color-accent-light, rgba(99,102,241,0.1))"},children:[(0,n.jsx)(dn,{size:10}),"Clear all"]}),(0,n.jsx)("div",{className:"flex-1"}),(0,n.jsxs)(dc,{trigger:(0,n.jsxs)("button",{type:"button",className:"flex items-center gap-1 px-2 py-1 rounded-md text-xs transition-colors cursor-pointer",style:{color:s?"var(--color-accent)":"var(--color-text-muted)",border:"1px solid ".concat(s?"var(--color-accent)":"var(--color-border)"),background:s?"var(--color-accent-light, rgba(99,102,241,0.1))":"transparent"},children:[(0,n.jsx)(da,{}),null!=s?s:"Views",(0,n.jsx)(dl,{})]}),open:m,onOpenChange:f,align:"right",children:[0===a.length&&(0,n.jsx)("div",{className:"px-3 py-2 text-xs",style:{color:"var(--color-text-muted)"},children:"No saved views"}),a.map(e=>(0,n.jsxs)("div",{className:"flex items-center group",children:[(0,n.jsxs)(dd,{onClick:()=>{c(e),f(!1)},active:s===e.name,children:[(0,n.jsx)("span",{className:"flex-1 truncate",children:e.name}),e.view_type&&"table"!==e.view_type&&(0,n.jsx)("span",{className:"text-[9px] px-1.5 py-0.5 rounded ml-1 capitalize",style:{background:"var(--color-surface-hover)",color:"var(--color-text-muted)"},children:e.view_type}),e.filters&&e.filters.rules.length>0&&(0,n.jsxs)("span",{className:"text-[10px] ml-1",style:{color:"var(--color-text-muted)"},children:[e.filters.rules.length," filter",1!==e.filters.rules.length?"s":""]})]}),(0,n.jsx)("button",{type:"button",onClick:t=>{t.stopPropagation(),d(e.name)},className:"px-2 py-1 md:opacity-0 md:group-hover:opacity-100 transition-opacity cursor-pointer",style:{color:"var(--color-text-muted)"},title:"Delete view",children:(0,n.jsx)(ds,{})})]},e.name)),(0,n.jsx)("div",{className:"border-t my-1",style:{borderColor:"var(--color-border)"}}),k&&!v&&(0,n.jsxs)(dd,{onClick:()=>g(!0),children:[(0,n.jsx)(da,{}),"Save current filters as view..."]}),v&&(0,n.jsxs)("div",{className:"px-3 py-2 flex items-center gap-1",children:[(0,n.jsx)("input",{ref:j,type:"text",value:y,onChange:e=>b(e.target.value),onKeyDown:e=>{"Enter"===e.key&&L(),"Escape"===e.key&&g(!1)},placeholder:"View name...",className:"px-2 py-1 rounded-md text-xs outline-none flex-1",style:{background:"var(--color-bg)",border:"1px solid var(--color-border)",color:"var(--color-text)"}}),(0,n.jsx)("button",{type:"button",onClick:L,className:"px-2 py-1 rounded-md text-xs transition-colors cursor-pointer",style:{background:"var(--color-accent)",color:"white"},children:"Save"})]}),s&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"border-t my-1",style:{borderColor:"var(--color-border)"}}),(0,n.jsxs)(dd,{onClick:()=>{S(),f(!1)},children:[(0,n.jsx)(dn,{size:12}),"Clear active view"]})]})]})]}),k&&(0,n.jsx)("div",{className:"space-y-1.5 pl-5",children:r.rules.map((e,o)=>{if(nF(e))return null;let l=t.find(t=>t.name===e.field);return(0,n.jsxs)("div",{className:"flex items-center gap-1.5",children:[o>0&&(0,n.jsx)("span",{className:"text-[10px] font-semibold uppercase w-8 text-center flex-shrink-0",style:{color:"var(--color-text-muted)"},children:r.conjunction}),0===o&&(0,n.jsx)("span",{className:"w-8 flex-shrink-0"}),(0,n.jsx)(dv,{rule:e,field:l,fields:t,members:p,onUpdate:t=>N(e.id,t),onRemove:()=>C(e.id)})]},e.id)})})]})}function dy(e){let t=Math.floor((Date.now()-e)/1e3);if(t<60)return"just now";let r=Math.floor(t/60);if(r<60)return"".concat(r,"m ago");let n=Math.floor(r/60);if(n<24)return"".concat(n,"h ago");let o=Math.floor(n/24);if(o<30)return"".concat(o,"d ago");let l=Math.floor(o/30);return l<12?"".concat(l,"mo ago"):"".concat(Math.floor(l/12),"y ago")}function db(){return(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M5 12h14"}),(0,n.jsx)("path",{d:"M12 5v14"})]})}function dj(){return(0,n.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M16 3h5v5"}),(0,n.jsx)("path",{d:"m21 3-7 7"}),(0,n.jsx)("path",{d:"M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6"})]})}function dk(){return(0,n.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function dw(){return(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"1"}),(0,n.jsx)("circle",{cx:"5",cy:"12",r:"1"}),(0,n.jsx)("circle",{cx:"19",cy:"12",r:"1"})]})}function dN(){return(0,n.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:(0,n.jsx)("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2"})})}function dC(){return(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,n.jsx)("polyline",{points:"12 6 12 12 16 14"})]})}function dS(){return(0,n.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"M22 12h-4l-3 9L9 3l-3 9H2"})})}function dM(){return(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"}),(0,n.jsx)("path",{d:"M14 2v4a2 2 0 0 0 2 2h4"})]})}let dL={telegram:{label:"Telegram",icon:function(){return(0,n.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:(0,n.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm4.64 6.8c-.15 1.58-.8 5.42-1.13 7.19-.14.75-.42 1-.68 1.03-.58.05-1.02-.38-1.58-.75-.88-.58-1.38-.94-2.23-1.5-.99-.65-.35-1.01.22-1.59.15-.15 2.71-2.48 2.76-2.69a.2.2 0 00-.05-.18c-.06-.05-.14-.03-.21-.02-.09.02-1.49.95-4.22 2.79-.4.27-.76.41-1.08.4-.36-.01-1.04-.2-1.55-.37-.63-.2-1.12-.31-1.08-.66.02-.18.27-.36.74-.55 2.92-1.27 4.86-2.11 5.83-2.51 2.78-1.16 3.35-1.36 3.73-1.36.08 0 .27.02.39.12.1.08.13.19.14.27-.01.06.01.24 0 .38z"})})},color:"#2AABEE"},whatsapp:{label:"WhatsApp",icon:function(){return(0,n.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:(0,n.jsx)("path",{d:"M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413z"})})},color:"#25D366"},discord:{label:"Discord",icon:function(){return(0,n.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:(0,n.jsx)("path",{d:"M20.317 4.37a19.791 19.791 0 00-4.885-1.515.074.074 0 00-.079.037c-.21.375-.444.864-.608 1.25a18.27 18.27 0 00-5.487 0 12.64 12.64 0 00-.617-1.25.077.077 0 00-.079-.037A19.736 19.736 0 003.677 4.37a.07.07 0 00-.032.027C.533 9.046-.32 13.58.099 18.057a.082.082 0 00.031.057 19.9 19.9 0 005.993 3.03.078.078 0 00.084-.028c.462-.63.874-1.295 1.226-1.994a.076.076 0 00-.041-.106 13.107 13.107 0 01-1.872-.892.077.077 0 01-.008-.128 10.2 10.2 0 00.372-.292.074.074 0 01.077-.01c3.928 1.793 8.18 1.793 12.062 0a.074.074 0 01.078.01c.12.098.246.198.373.292a.077.077 0 01-.006.127 12.299 12.299 0 01-1.873.892.077.077 0 00-.041.107c.36.698.772 1.362 1.225 1.993a.076.076 0 00.084.028 19.839 19.839 0 006.002-3.03.077.077 0 00.032-.054c.5-5.177-.838-9.674-3.549-13.66a.061.061 0 00-.031-.03zM8.02 15.33c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.956-2.419 2.157-2.419 1.21 0 2.176 1.096 2.157 2.42 0 1.333-.956 2.418-2.157 2.418zm7.975 0c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.955-2.419 2.157-2.419 1.21 0 2.176 1.096 2.157 2.42 0 1.333-.946 2.418-2.157 2.418z"})})},color:"#5865F2"},slack:{label:"Slack",icon:function(){return(0,n.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:(0,n.jsx)("path",{d:"M5.042 15.165a2.528 2.528 0 01-2.52 2.523A2.528 2.528 0 010 15.165a2.527 2.527 0 012.522-2.52h2.52v2.52zm1.271 0a2.527 2.527 0 012.521-2.52 2.527 2.527 0 012.521 2.52v6.313A2.528 2.528 0 018.834 24a2.528 2.528 0 01-2.521-2.522v-6.313zM8.834 5.042a2.528 2.528 0 01-2.521-2.52A2.528 2.528 0 018.834 0a2.528 2.528 0 012.521 2.522v2.52H8.834zm0 1.271a2.528 2.528 0 012.521 2.521 2.528 2.528 0 01-2.521 2.521H2.522A2.528 2.528 0 010 8.834a2.528 2.528 0 012.522-2.521h6.312zM18.956 8.834a2.528 2.528 0 012.522-2.521A2.528 2.528 0 0124 8.834a2.528 2.528 0 01-2.522 2.521h-2.522V8.834zm-1.27 0a2.528 2.528 0 01-2.523 2.521 2.527 2.527 0 01-2.52-2.521V2.522A2.527 2.527 0 0115.163 0a2.528 2.528 0 012.523 2.522v6.312zM15.163 18.956a2.528 2.528 0 012.523 2.522A2.528 2.528 0 0115.163 24a2.527 2.527 0 01-2.52-2.522v-2.522h2.52zm0-1.27a2.527 2.527 0 01-2.52-2.523 2.527 2.527 0 012.52-2.52h6.315A2.528 2.528 0 0124 15.163a2.528 2.528 0 01-2.522 2.523h-6.315z"})})},color:"#4A154B"},signal:{label:"Signal",icon:function(){return(0,n.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:(0,n.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-1 15h-2v-6h2v6zm4 0h-2v-6h2v6zm-2-8a1.5 1.5 0 110-3 1.5 1.5 0 010 3zm-4 0a1.5 1.5 0 110-3 1.5 1.5 0 010 3z"})})},color:"#3A76F0"},imessage:{label:"iMessage",icon:function(){return(0,n.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:(0,n.jsx)("path",{d:"M12 2C6.477 2 2 5.813 2 10.5c0 2.684 1.464 5.084 3.768 6.635L4.5 21l4.17-2.083A11.51 11.51 0 0012 19.5c5.523 0 10-3.813 10-8.5S17.523 2 12 2z"})})},color:"#34C759"},googlechat:{label:"Google Chat",icon:function(){return(0,n.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:(0,n.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10h5v-2h-5a8 8 0 110-16 8 8 0 018 8v1.43c0 .79-.71 1.57-1.5 1.57s-1.5-.78-1.5-1.57V12a5 5 0 10-1.47 3.53 3.5 3.5 0 002.97 1.47c1.93 0 3.5-1.57 3.5-3.57V12c0-5.52-4.48-10-10-10zm0 13a3 3 0 110-6 3 3 0 010 6z"})})},color:"#00AC47"},nostr:{label:"Nostr",icon:function(){return(0,n.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:(0,n.jsx)("path",{d:"M12 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5"})})},color:"#8B5CF6"},cron:{label:"Crons",icon:dC,color:"var(--color-text-muted)"}};function dT(e){let{channel:t,size:r=12}=e,o=dL[t];if(!o)return(0,n.jsx)(dk,{});let l=o.icon;return(0,n.jsx)("span",{style:{color:o.color,width:r,height:r,display:"inline-flex"},children:(0,n.jsx)(l,{})})}function dI(e){let{status:t}=e;return(0,n.jsx)("span",{className:"inline-block rounded-full shrink-0",style:{width:6,height:6,background:"connected"===t?"#22c55e":"running"===t?"#eab308":"error"===t?"#ef4444":"var(--color-text-muted)"},title:t})}function dR(e){let{session:t,isActive:r,isHovered:o,isStreaming:l,sessionSubagents:a,activeSubagentKey:s,renamingId:i,renameValue:c,onHover:d,onLeave:u,onSelect:p,onStartRename:h,onCommitRename:x,onCancelRename:m,onRenameChange:f,onDelete:v,onStop:g,onSelectSubagent:y,onStopSubagent:b,showFilePath:j}=e,k=o||l;return(0,n.jsxs)("div",{className:"group relative",onMouseEnter:()=>d(t.id),onMouseLeave:u,children:[(0,n.jsxs)("div",{className:"flex items-stretch w-full rounded-lg",style:{background:r?"var(--color-chat-sidebar-active-bg)":o?"var(--color-surface-hover)":"transparent"},children:[i===t.id?(0,n.jsx)("form",{className:"flex-1 min-w-0 px-2 py-1.5",onSubmit:e=>{e.preventDefault(),null==x||x()},children:(0,n.jsx)("input",{type:"text",value:c,onChange:e=>null==f?void 0:f(e.target.value),onBlur:x,onKeyDown:e=>{"Escape"===e.key&&(null==m||m())},autoFocus:!0,className:"w-full text-xs font-medium px-1 py-0.5 rounded outline-none border",style:{color:"var(--color-text)",background:"var(--color-surface)",borderColor:"var(--color-border)"}})}):(0,n.jsxs)("button",{type:"button",onClick:()=>p(t.id),className:"flex-1 min-w-0 text-left px-2 py-2 rounded-l-lg transition-colors cursor-pointer",children:[(0,n.jsxs)("div",{className:"flex items-center gap-1.5",children:[l&&(0,n.jsx)(eU.V,{name:"braille",className:"text-[10px] flex-shrink-0",style:{color:"var(--color-chat-sidebar-muted)"}}),(0,n.jsx)("div",{className:"text-xs font-medium truncate",style:{color:r?"var(--color-chat-sidebar-active-text)":"var(--color-text)"},children:t.title||"Untitled chat"})]}),(0,n.jsxs)("div",{className:"flex items-center gap-2 mt-0.5",style:{paddingLeft:l?"calc(0.375rem + 6px)":void 0},children:[(0,n.jsx)("span",{className:"text-[10px]",style:{color:"var(--color-text-muted)"},children:dy(t.updatedAt)}),t.messageCount>0&&(0,n.jsxs)("span",{className:"text-[10px]",style:{color:"var(--color-text-muted)"},children:[t.messageCount," msg",1!==t.messageCount?"s":""]})]}),j&&t.filePath&&(0,n.jsx)("div",{className:"text-[9px] mt-0.5 truncate",style:{color:"var(--color-text-muted)",opacity:.7},children:t.filePath})]}),(0,n.jsxs)("div",{className:"shrink-0 flex items-center pr-1 gap-0.5 transition-opacity ".concat(k?"opacity-100":"opacity-0"),children:[l&&g&&(0,n.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),g(t.id)},className:"flex items-center justify-center w-6 h-6 rounded-md transition-colors hover:bg-black/5",style:{color:"var(--color-text-muted)"},title:"Stop chat","aria-label":"Stop chat",children:(0,n.jsx)(dN,{})}),v&&(0,n.jsxs)(ef,{children:[(0,n.jsx)(ev,{onClick:e=>e.stopPropagation(),className:"flex items-center justify-center w-6 h-6 rounded-md",style:{color:"var(--color-text-muted)"},title:"More options","aria-label":"More options",children:(0,n.jsx)(dw,{})}),(0,n.jsxs)(eg,{align:"end",side:"bottom",children:[h&&(0,n.jsxs)(ey,{onSelect:()=>h(t.id,t.title),children:[(0,n.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"})}),"Rename"]}),(0,n.jsxs)(ey,{variant:"destructive",onSelect:()=>v(t.id),children:[(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M3 6h18"}),(0,n.jsx)("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),(0,n.jsx)("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]}),"Delete"]})]})]})]})]}),a&&a.length>0&&(0,n.jsx)("div",{className:"ml-4 border-l",style:{borderColor:"var(--color-border)"},children:a.map(e=>{let t=s===e.childSessionKey,r="running"===e.status,o=e.label||e.task,l=o.length>40?o.slice(0,40)+"...":o;return(0,n.jsxs)("div",{className:"flex items-center",children:[(0,n.jsx)("button",{type:"button",onClick:()=>null==y?void 0:y(e.childSessionKey),className:"flex-1 text-left pl-3 pr-2 py-1.5 rounded-r-lg transition-colors cursor-pointer",style:{background:t?"var(--color-chat-sidebar-active-bg)":"transparent"},children:(0,n.jsxs)("div",{className:"flex items-center gap-1.5",children:[r&&(0,n.jsx)(eU.V,{name:"braille",className:"text-[9px] flex-shrink-0",style:{color:"var(--color-chat-sidebar-muted)"}}),(0,n.jsx)(dj,{}),(0,n.jsx)("span",{className:"text-[11px] truncate",style:{color:t?"var(--color-chat-sidebar-active-text)":"var(--color-text-muted)"},children:l})]})}),r&&b&&(0,n.jsx)("button",{type:"button",onClick:t=>{t.stopPropagation(),b(e.childSessionKey)},className:"shrink-0 flex items-center justify-center w-6 h-6 rounded-md mr-1 transition-colors hover:bg-black/5",style:{color:"var(--color-text-muted)"},title:"Stop subagent","aria-label":"Stop subagent",children:(0,n.jsx)(dN,{})})]},e.childSessionKey)})})]})}function d_(e){let{gs:t,isActive:r,isHovered:o,onHover:l,onLeave:a,onSelect:s}=e;return(0,n.jsx)("div",{onMouseEnter:()=>l(t.sessionKey),onMouseLeave:a,children:(0,n.jsxs)("button",{type:"button",onClick:()=>s(t.sessionKey,t.sessionId),className:"w-full text-left px-2 py-2 rounded-lg transition-colors cursor-pointer",style:{background:r?"var(--color-chat-sidebar-active-bg)":o?"var(--color-surface-hover)":"transparent"},children:[(0,n.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,n.jsx)(dT,{channel:t.channel,size:11}),(0,n.jsx)("div",{className:"text-xs font-medium truncate",style:{color:r?"var(--color-chat-sidebar-active-text)":"var(--color-text)"},children:t.title})]}),(0,n.jsx)("div",{className:"flex items-center gap-2 mt-0.5 pl-[calc(11px+0.375rem)]",children:(0,n.jsx)("span",{className:"text-[10px]",style:{color:"var(--color-text-muted)"},children:dy(t.updatedAt)})})]})})}function dE(e){let{sessions:t,activeSessionId:r,activeSessionTitle:l,streamingSessionIds:a,subagents:s,activeSubagentKey:i,onSelectSession:c,onNewSession:d,onSelectSubagent:u,onDeleteSession:p,onRenameSession:h,onStopSession:x,onStopSubagent:m,onCollapse:f,mobile:v,onClose:g,width:y,loading:b=!1,embedded:j=!1,gatewaySessions:k,channelStatuses:w,activeGatewaySessionKey:N,onSelectGatewaySession:C,fileScopedSessions:S,heartbeatInfo:M}=e,[L,T]=(0,o.useState)(null),[I,R]=(0,o.useState)(null),[_,E]=(0,o.useState)(""),[D,A]=(0,o.useState)("denchclaw"),W=(0,o.useCallback)(e=>{c(e),null==g||g()},[c,g]),B=(0,o.useCallback)(e=>{null==u||u(e),null==g||g()},[u,g]),F=(0,o.useCallback)(e=>{null==p||p(e)},[p]),P=(0,o.useCallback)((e,t)=>{R(e),E(t||"")},[]),z=(0,o.useCallback)(()=>{I&&_.trim()&&(null==h||h(I,_.trim())),R(null),E("")},[I,_,h]),O=(0,o.useCallback)(()=>{R(null),E("")},[]),U=(0,o.useCallback)((e,t)=>{null==C||C(e,t),null==g||g()},[C,g]),H=(0,o.useMemo)(()=>{let e=new Map;if(!s)return e;for(let t of s){let r=e.get(t.parentSessionId);r||(r=[],e.set(t.parentSessionId,r)),r.push(t)}return e},[s]),V=(0,o.useMemo)(()=>t.filter(e=>!e.id.includes(":subagent:")&&!e.filePath),[t]),K=dD(V),J=(0,o.useMemo)(()=>{let e=new Map;if(!w)return e;for(let t of w)e.set(t.id,t);return e},[w]),q=(0,o.useMemo)(()=>{let e=new Map;if(!k)return e;for(let t of k){let r=e.get(t.channel);r||(r=[],e.set(t.channel,r)),r.push(t)}return e},[k]),G=(0,o.useMemo)(()=>dD(null!=S?S:[]),[S]),$=q.get("cron"),Z=(0,o.useMemo)(()=>{var e,t,r;let n=[{id:"denchclaw",label:"DenchClaw",count:V.length}],o=["telegram","whatsapp","discord","slack","signal","imessage","googlechat","nostr"];for(let t of o){let r=q.get(t);if(!(null==r?void 0:r.length))continue;let o=dL[t];n.push({id:t,label:null!=(e=null==o?void 0:o.label)?e:t,icon:null==o?void 0:o.icon,iconColor:null==o?void 0:o.color,count:r.length})}for(let[e,r]of q.entries()){if(o.includes(e)||"cron"===e||"unknown"===e)continue;let l=dL[e];n.push({id:e,label:null!=(t=null==l?void 0:l.label)?t:e,icon:null==l?void 0:l.icon,iconColor:null==l?void 0:l.color,count:r.length})}return(null==$?void 0:$.length)&&(n.push({id:"cron",label:"Crons",icon:dC,count:$.length}),n.push({id:"heartbeat",label:"Heartbeat",icon:dS})),(null!=(r=null==S?void 0:S.length)?r:0)>0&&n.push({id:"other",label:"Other",icon:dM,count:S.length}),n},[V,q,$,S]),Y=Z.length>1,Q=v?"280px":null!=y?y:260,X=j?36:40,ee=30*!!Y,et=(0,n.jsxs)("div",{className:"flex-1 min-h-0 relative",children:[(0,n.jsx)("div",{className:"absolute inset-0 overflow-y-auto",style:{paddingTop:X+ee},children:(()=>{if(b&&0===t.length&&!(null==k?void 0:k.length))return(0,n.jsxs)("div",{className:"px-4 py-8 flex flex-col items-center justify-center min-h-[120px]",children:[(0,n.jsx)(eU.V,{name:"braille",className:"text-xl mb-2",style:{color:"var(--color-text-muted)"}}),(0,n.jsx)("p",{className:"text-xs",style:{color:"var(--color-text-muted)"},children:"Loading…"})]});if("denchclaw"===D)return 0===V.length?(0,n.jsxs)("div",{className:"px-4 py-8 text-center",children:[(0,n.jsx)("div",{className:"mx-auto w-10 h-10 rounded-xl flex items-center justify-center mb-3",style:{background:"var(--color-surface-hover)",color:"var(--color-text-muted)"},children:(0,n.jsx)(dk,{})}),(0,n.jsxs)("p",{className:"text-xs",style:{color:"var(--color-text-muted)"},children:["No conversations yet.",(0,n.jsx)("br",{}),"Start a new chat to begin."]})]}):(0,n.jsx)("div",{className:"px-2 py-1",children:K.map(e=>(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"px-2 pt-3 pb-1 text-[10px] font-medium uppercase tracking-wider",style:{color:"var(--color-text-muted)"},children:e.label}),e.sessions.map(e=>{var t;return(0,n.jsx)(dR,{session:e,isActive:e.id===r&&!i&&!N,isHovered:e.id===L,isStreaming:null!=(t=null==a?void 0:a.has(e.id))&&t,sessionSubagents:H.get(e.id),activeSubagentKey:i,renamingId:I,renameValue:_,onHover:T,onLeave:()=>T(null),onSelect:W,onStartRename:h?P:void 0,onCommitRename:z,onCancelRename:O,onRenameChange:E,onDelete:p?F:void 0,onStop:x,onSelectSubagent:B,onStopSubagent:m},e.id)})]},e.label))});if("heartbeat"===D)return(0,n.jsxs)("div",{className:"px-2 py-1",children:[(0,n.jsxs)("div",{className:"mx-1 mb-2 p-2.5 rounded-lg",style:{background:"var(--color-surface-hover)"},children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 mb-1.5",children:[(0,n.jsx)(dI,{status:(null==w?void 0:w.some(e=>e.connected))?"connected":(null==w?void 0:w.some(e=>e.running))?"running":"configured"}),(0,n.jsxs)("span",{className:"text-[11px] font-medium",style:{color:"var(--color-text)"},children:["Gateway ",(null==w?void 0:w.some(e=>e.connected))?"Connected":"Disconnected"]})]}),M&&(0,n.jsxs)("div",{className:"space-y-0.5",children:[(0,n.jsxs)("div",{className:"text-[10px]",style:{color:"var(--color-text-muted)"},children:["Interval: ",Math.round(M.intervalMs/6e4),"m"]}),M.nextDueEstimateMs&&(0,n.jsxs)("div",{className:"text-[10px]",style:{color:"var(--color-text-muted)"},children:["Next: ",dy(M.nextDueEstimateMs).replace(" ago","")," from now"]})]}),!M&&(0,n.jsx)("div",{className:"text-[10px]",style:{color:"var(--color-text-muted)"},children:"No heartbeat data"})]}),null==$?void 0:$.map(e=>(0,n.jsx)(d_,{gs:e,isActive:N===e.sessionKey,isHovered:L===e.sessionKey,onHover:T,onLeave:()=>T(null),onSelect:U},e.sessionKey)),!(null==$?void 0:$.length)&&(0,n.jsx)("div",{className:"px-4 py-6 text-center",children:(0,n.jsx)("p",{className:"text-xs",style:{color:"var(--color-text-muted)"},children:"No cron sessions"})})]});if("other"===D)return(null==S?void 0:S.length)?(0,n.jsx)("div",{className:"px-2 py-1",children:G.map(e=>(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"px-2 pt-3 pb-1 text-[10px] font-medium uppercase tracking-wider",style:{color:"var(--color-text-muted)"},children:e.label}),e.sessions.map(e=>{var t;return(0,n.jsx)(dR,{session:e,isActive:e.id===r&&!i&&!N,isHovered:e.id===L,isStreaming:null!=(t=null==a?void 0:a.has(e.id))&&t,renamingId:I,renameValue:_,onHover:T,onLeave:()=>T(null),onSelect:W,onCommitRename:z,onCancelRename:O,onRenameChange:E,onDelete:p?F:void 0,showFilePath:!0},e.id)})]},e.label))}):(0,n.jsx)("div",{className:"px-4 py-8 text-center",children:(0,n.jsx)("p",{className:"text-xs",style:{color:"var(--color-text-muted)"},children:"No file-scoped sessions"})});let e=q.get(D),o=J.get(D),l=(null==o?void 0:o.connected)?"connected":(null==o?void 0:o.running)?"running":(null==o?void 0:o.error)?"error":(null==o?void 0:o.configured)?"configured":void 0;return(null==e?void 0:e.length)?(0,n.jsxs)("div",{className:"px-2 py-1",children:[l&&(0,n.jsxs)("div",{className:"px-2 pt-2 pb-1 flex items-center gap-1.5",children:[(0,n.jsx)(dI,{status:l}),(0,n.jsx)("span",{className:"text-[10px]",style:{color:"var(--color-text-muted)"},children:"connected"===l?"Connected":"running"===l?"Running":"error"===l?"Error":"Configured"})]}),e.map(e=>(0,n.jsx)(d_,{gs:e,isActive:N===e.sessionKey,isHovered:L===e.sessionKey,onHover:T,onLeave:()=>T(null),onSelect:U},e.sessionKey))]}):(0,n.jsx)("div",{className:"px-4 py-8 text-center",children:(0,n.jsx)("p",{className:"text-xs",style:{color:"var(--color-text-muted)"},children:"No sessions"})})})()}),(0,n.jsxs)("div",{className:"absolute top-0 left-0 right-0 z-10 backdrop-blur-md ".concat(j?"":"border-b"),style:{borderColor:j?void 0:"var(--color-border)",background:"color-mix(in srgb, var(--color-bg) 80%, transparent)",boxShadow:j?"inset 0 -1px 0 0 var(--color-border)":void 0},children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-4",style:{height:X},children:[(0,n.jsxs)("div",{className:"min-w-0 flex-1 flex items-center gap-1.5",children:[f&&(0,n.jsx)("button",{type:"button",onClick:f,className:"p-1 rounded-md shrink-0 transition-colors hover:bg-black/5",style:{color:"var(--color-text-muted)"},title:"Hide chat sidebar",children:(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),(0,n.jsx)("path",{d:"M15 3v18"})]})}),(0,n.jsx)("span",{className:"text-xs font-medium truncate block",style:{color:"var(--color-text)"},children:"Chats"})]}),(0,n.jsxs)("button",{type:"button",onClick:d,className:"flex items-center gap-1 px-2 py-1 rounded-full text-[11px] font-medium transition-all cursor-pointer shrink-0 ml-1.5 ".concat(j?"hover:bg-neutral-400/15":""),style:{color:j?"var(--color-text)":"var(--color-chat-sidebar-active-text)",background:j?"transparent":"var(--color-chat-sidebar-active-bg)"},title:"New chat",children:[(0,n.jsx)(db,{}),"New"]})]}),Y&&(0,n.jsx)("div",{className:"flex items-center gap-0.5 px-2 pb-1.5 overflow-x-auto scrollbar-none",children:Z.map(e=>{var t;let r=D===e.id,o=e.icon;return(0,n.jsxs)("button",{type:"button",onClick:()=>A(e.id),className:"flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-medium transition-colors cursor-pointer shrink-0 whitespace-nowrap",style:{color:r?"var(--color-chat-sidebar-active-text)":"var(--color-text-muted)",background:r?"var(--color-chat-sidebar-active-bg)":"transparent"},children:[o&&(0,n.jsx)("span",{style:{color:r?void 0:null!=(t=e.iconColor)?t:"var(--color-text-muted)",display:"inline-flex"},children:(0,n.jsx)(o,{})}),e.label,void 0!==e.count&&e.count>0&&(0,n.jsx)("span",{className:"text-[9px] opacity-60",children:e.count})]},e.id)})})]})]});if(j)return et;let er=(0,n.jsx)("aside",{className:"flex flex-col h-full shrink-0 ".concat(v?"drawer-right":"border-l"),style:{width:"number"==typeof Q?"".concat(Q,"px"):Q,minWidth:"number"==typeof Q?"".concat(Q,"px"):Q,borderColor:"var(--color-border)",background:"var(--color-sidebar-bg)"},children:et});return v?(0,n.jsx)("div",{className:"drawer-backdrop",onClick:()=>void(null==g||g()),children:(0,n.jsx)("div",{onClick:e=>e.stopPropagation(),className:"fixed inset-y-0 right-0 z-50",children:er})}):er}function dD(e){let t=new Date,r=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),n=r-864e5,o=r-6048e5,l=r-2592e6,a=[],s=[],i=[],c=[],d=[];for(let t of e){let e=t.updatedAt;e>=r?a.push(t):e>=n?s.push(t):e>=o?i.push(t):e>=l?c.push(t):d.push(t)}let u=[];return a.length>0&&u.push({label:"Today",sessions:a}),s.length>0&&u.push({label:"Yesterday",sessions:s}),i.length>0&&u.push({label:"This Week",sessions:i}),c.length>0&&u.push({label:"This Month",sessions:c}),d.length>0&&u.push({label:"Older",sessions:d}),u}let dA="__home__",dW={id:dA,type:"home",title:"Home",pinned:!0};function dB(e){return"".concat("dench:tabs",":").concat(e||"default")}function dF(){return Math.random().toString(36).slice(2,10)}function dP(e){var t,r,n;return(t=function(e){if(e.tabs.some(e=>e.id===dA)){let t={...dW,...e.tabs.find(e=>e.id===dA),preview:void 0,pinned:!0},r=e.tabs.filter(e=>e.id!==dA);return{...e,tabs:[t,...r]}}return{tabs:[dW,...e.tabs],activeTabId:e.activeTabId||dA}}(function(e){let t=!1,r=e.activeTabId,n=new Map,o=[];for(let l of e.tabs){let e=l.id===dA||"home"===l.type?null:l.path?"path:".concat(l.path):l.sessionKey?"sessionKey:".concat(l.sessionKey):"chat"===l.type&&l.sessionId?"sessionId:".concat(l.sessionId):null;if(!e){o.push(l);continue}let a=n.get(e);if(void 0===a){n.set(e,o.length),o.push(l);continue}t=!0,r===l.id&&(r=o[a].id),o[a]=function(e,t){var r,n,o,l,a,s;return dz({...e,title:e.title||t.title,icon:null!=(r=e.icon)?r:t.icon,path:null!=(n=e.path)?n:t.path,sessionId:null!=(o=e.sessionId)?o:t.sessionId,sessionKey:null!=(l=e.sessionKey)?l:t.sessionKey,parentSessionId:null!=(a=e.parentSessionId)?a:t.parentSessionId,pinned:e.pinned||t.pinned,preview:!!e.preview&&!!t.preview||void 0,channel:null!=(s=e.channel)?s:t.channel})}(o[a],l)}return t?{tabs:o,activeTabId:r}:e}(e))).tabs.some(e=>e.id===t.activeTabId)?t:{...t,activeTabId:null!=(n=null==(r=t.tabs[t.tabs.length-1])?void 0:r.id)?n:dA}}function dz(e){return e.id===dA||"home"===e.type?dW:e.preview?{...e,preview:!0,pinned:!1}:{...e,preview:void 0}}function dO(e,t,r){var n,o,l,a,s,i,c;let d=t.path?(o=e.tabs,l=t.path,o.find(e=>e.path===l)):t.sessionKey?(a=e.tabs,s=t.sessionKey,a.find(e=>e.sessionKey===s)):t.sessionId?(i=e.tabs,c=t.sessionId,i.find(e=>"chat"===e.type&&e.sessionId===c)):void 0;if(d)return e.activeTabId===d.id?e:{...e,activeTabId:d.id};let u=dz({...t,preview:null==(n=null==r?void 0:r.preview)||n});if(!u.preview)return{tabs:[...e.tabs,u],activeTabId:u.id};let p=function(e){let t=e.tabs.findIndex(t=>t.id!==dA&&t.preview&&t.id===e.activeTabId);return -1!==t?t:e.tabs.findIndex(e=>e.id!==dA&&e.preview)}(e);if(-1!==p){let t=[...e.tabs];return t[p]=u,{tabs:t,activeTabId:u.id}}return{tabs:[...e.tabs,u],activeTabId:u.id}}function dU(e,t){return e.tabs.some(e=>e.id===t)&&e.activeTabId!==t?{...e,activeTabId:t}:e}function dH(e,t){let r=!1,n=e.tabs.map(e=>e.id===t&&e.preview?(r=!0,{...e,preview:void 0}):e);return r?{...e,tabs:n}:e}let dV=(0,nX.default)(()=>r.e(6742).then(r.t.bind(r,46742,23)).then(e=>e.Tabs),{loadableGenerated:{webpack:()=>[46742]},ssr:!1});function dK(e){let{tabs:t,activeTabId:r,onActivate:l,onClose:a,onCloseOthers:s,onCloseToRight:i,onCloseAll:c,onReorder:d,onTogglePin:u,onMakePermanent:p,liveChatTabIds:h,onStopTab:x,onNewTab:j,leftContent:k,rightContent:w}=e,[N,C]=(0,o.useState)(null),[S,M]=(0,o.useState)(!1),L=(0,o.useRef)(null),T=(0,o.useRef)(0);(0,o.useEffect)(()=>{let e=window.matchMedia("(prefers-color-scheme: dark)");M(document.documentElement.classList.contains("dark")||e.matches);let t=()=>M(document.documentElement.classList.contains("dark")||e.matches);e.addEventListener("change",t);let r=new MutationObserver(t);return r.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>{e.removeEventListener("change",t),r.disconnect()}},[]),(0,o.useEffect)(()=>{let e=e=>{if(2===e.button){var t,r,n;let o=null==(t=(r=e.target).closest)?void 0:t.call(r,".chrome-tab");o&&(null==(n=L.current)?void 0:n.contains(o))&&(e.stopImmediatePropagation(),e.preventDefault(),T.current=Date.now())}};return document.addEventListener("pointerdown",e,!0),document.addEventListener("mousedown",e,!0),()=>{document.removeEventListener("pointerdown",e,!0),document.removeEventListener("mousedown",e,!0)}},[]);let I=(0,o.useMemo)(()=>t.filter(e=>e.id!==dA),[t]),R=(0,o.useMemo)(()=>new Set(I.filter(e=>e.preview).map(e=>e.id)),[I]),_=(0,o.useMemo)(()=>I.map(e=>{var t;return{id:e.id,title:e.title,active:e.id===r,favicon:!!(e.icon&&e.path&&/\.(png|svg|jpe?g|webp)$/i.test(e.icon))&&oR(e.path,e.icon),faviconClass:function(e,t){switch(e.type){case"home":return"dench-favicon-home";case"chat":return t?"dench-favicon-chat-live":"dench-favicon-chat";case"app":return"dench-favicon-app";case"cron":return"dench-favicon-cron";case"object":return"dench-favicon-object";default:return"dench-favicon-file"}}(e,null!=(t=null==h?void 0:h.has(e.id))&&t),isCloseIconVisible:!e.pinned}}),[I,r,h]);(0,o.useEffect)(()=>{let e=L.current;if(!e)return;let t=()=>{e.querySelectorAll(".chrome-tab[data-tab-id]").forEach(e=>{let t=e.getAttribute("data-tab-id");t&&R.has(t)?e.setAttribute("data-preview","true"):e.removeAttribute("data-preview")})};t();let r=window.requestAnimationFrame(t);return()=>window.cancelAnimationFrame(r)},[_,R]);let E=(0,o.useCallback)(e=>{Date.now()-T.current<200||l(e)},[l]),D=(0,o.useCallback)(e=>a(e),[a]),A=(0,o.useCallback)((e,r,n)=>{let o=t.findIndex(t=>t.id===e);o>=0&&o!==n&&d(e,o,n)},[t,d]),W=(0,o.useCallback)(e=>{var t,r;let n=null==(t=(r=e.target).closest)?void 0:t.call(r,".chrome-tab");if(!n||!p)return;let o=n.getAttribute("data-tab-id");o&&R.has(o)&&p(o)},[p,R]),B=(0,o.useCallback)(e=>{var t,r;let n=null==(t=(r=e.target).closest)?void 0:t.call(r,".chrome-tab");if(n){let e=n.getAttribute("data-tab-id");if(e&&e!==dA){n.setAttribute("data-context","true"),C(e);return}}e.preventDefault()},[]);if(0===t.length)return null;let F=N?t.find(e=>e.id===N):null;return(0,n.jsxs)(m,{onOpenChange:e=>{if(!e){var t,r;null==(r=L.current)||null==(t=r.querySelector("[data-context]"))||t.removeAttribute("data-context"),C(null)}},children:[(0,n.jsx)(f,{asChild:!0,children:(0,n.jsxs)("div",{ref:L,className:"dench-chrome-tabs-wrapper flex items-center shrink-0 relative",onContextMenu:B,onDoubleClick:W,children:[k&&(0,n.jsx)("div",{className:"flex items-center px-1.5 shrink-0 z-10",children:k}),(0,n.jsx)("div",{className:"flex-1 min-w-0",children:(0,n.jsx)(dV,{darkMode:S,tabs:_,draggable:!0,onTabActive:E,onTabClose:D,onTabReorder:A,pinnedRight:j?(0,n.jsx)("button",{type:"button",onClick:j,className:"flex items-center justify-center w-7 h-7 rounded-full shrink-0 cursor-pointer transition-colors hover:bg-black/5 dark:hover:bg-white/5 ml-2",style:{color:"var(--color-text-muted)"},title:"New chat",children:(0,n.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M12 5v14"}),(0,n.jsx)("path",{d:"M5 12h14"})]})}):void 0})}),w&&(0,n.jsx)("div",{className:"flex items-center gap-0.5 px-2 shrink-0 z-10",children:w})]})}),F&&(0,n.jsxs)(v,{className:"min-w-[180px]",children:[(0,n.jsx)(g,{onSelect:()=>u(F.id),children:F.pinned?"Unpin Tab":"Pin Tab"}),"chat"===F.type&&(null==h?void 0:h.has(F.id))&&x&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(y,{}),(0,n.jsx)(g,{onSelect:()=>x(F.id),children:"Stop Session"})]}),(0,n.jsx)(y,{}),(0,n.jsxs)(g,{disabled:F.pinned,onSelect:()=>a(F.id),children:["Close",(0,n.jsx)(b,{children:"⌘W"})]}),(0,n.jsx)(g,{onSelect:()=>s(F.id),children:"Close Others"}),(0,n.jsx)(g,{onSelect:()=>i(F.id),children:"Close to the Right"}),(0,n.jsx)(g,{onSelect:()=>c(),children:"Close All"})]})]})}function dJ(e){return(null==e?void 0:e.type)==="chat"}function dq(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"New Chat";return{id:dF(),type:"chat",title:e}}function dG(e){var t,r,n,o;return e?"gateway-chat"===e.type?{sessionId:null!=(t=e.sessionId)?t:null,subagentKey:null,gatewaySessionKey:null!=(r=e.sessionKey)?r:null}:"chat"!==e.type?{sessionId:null,subagentKey:null,gatewaySessionKey:null}:e.sessionKey?{sessionId:null!=(n=e.parentSessionId)?n:null,subagentKey:e.sessionKey,gatewaySessionKey:null}:{sessionId:null!=(o=e.sessionId)?o:null,subagentKey:null,gatewaySessionKey:null}:{sessionId:null,subagentKey:null,gatewaySessionKey:null}}function d$(e,t){if(!(t in e))return e;let r={...e};return delete r[t],r}function dZ(e){return{parentStatuses:new Map(e.parentRuns.map(e=>[e.sessionId,e.status])),subagentStatuses:new Map(e.subagents.map(e=>[e.childSessionKey,e.status]))}}let dY=(0,nX.default)(()=>Promise.all([r.e(2078),r.e(4560),r.e(7858)]).then(r.bind(r,77858)),{loadableGenerated:{webpack:()=>[77858]},ssr:!1}),dQ="dench-workspace-left-sidebar-width",dX="dench-workspace-right-sidebar-width",d0="dench-workspace-chat-sidebar-width",d1="dench-workspace-entry-panel-width";function d2(e,t,r){return Math.min(r,Math.max(t,e))}function d4(e){let{mode:t,containerRef:r,min:l,max:a,onResize:s}=e,[i,c]=(0,o.useState)(!1),d=(0,o.useCallback)(e=>{e.preventDefault(),c(!0);let n=e=>{let n=r.current;if(!n)return;let o=n.getBoundingClientRect();s(d2("left"===t?e.clientX-o.left:o.right-e.clientX,l,a))},o=()=>{c(!1),document.removeEventListener("mousemove",n),document.removeEventListener("mouseup",o),document.body.style.removeProperty("user-select"),document.body.style.removeProperty("cursor"),document.body.classList.remove("resizing")};document.body.style.setProperty("user-select","none"),document.body.style.setProperty("cursor","col-resize"),document.body.classList.add("resizing"),document.addEventListener("mousemove",n),document.addEventListener("mouseup",o)},[r,t,l,a,s]);return(0,n.jsx)("div",{role:"separator","aria-orientation":"vertical",onMouseDown:d,className:"cursor-col-resize flex justify-center transition-colors ".concat(i?"bg-blue-600/30":"hover:bg-blue-600/30"),style:{position:"absolute",["left"===t?"right":"left"]:-2,top:0,bottom:0,width:4,zIndex:20}})}function d5(e,t){for(let r of e){if(r.path===t)return r;if(r.children){let e=d5(r.children,t);if(e)return e}}return null}function d3(e){let t=e.split("/");return t[t.length-1]}function d6(e){var t,r;if(e.endsWith(".dench.app"))return"app";let n=null!=(r=null==(t=e.split(".").pop())?void 0:t.toLowerCase())?r:"";return"md"===n||"mdx"===n?"document":"duckdb"===n||"sqlite"===n||"sqlite3"===n||"db"===n?"database":"file"}function d8(e,t){let r=d5(e,t);if(r||!t.startsWith("knowledge/")&&(r=d5(e,"knowledge/".concat(t)))||t.startsWith("knowledge/")&&(r=d5(e,t.slice(10))))return r;let n=t.split("/").pop();return n&&(r=function e(t){for(let r of t){if("object"===r.type&&d3(r.path)===n)return r;if(r.children){let t=e(r.children);if(t)return t}}return null}(e))?r:null}function d7(){return(0,n.jsx)(t9,{children:(0,n.jsx)(o.Suspense,{fallback:(0,n.jsx)("div",{className:"flex h-screen items-center justify-center",style:{background:"var(--color-bg)"},children:(0,n.jsx)(eU.V,{name:"braille",className:"text-2xl",style:{color:"var(--color-text-muted)"}})}),children:(0,n.jsx)(d9,{})})})}function d9(){var e,t,a;let s=(0,l.useSearchParams)(),i=(0,l.useRouter)(),c=(0,o.useRef)("init"),d=(0,o.useRef)(!1),u=(0,o.useRef)(null),p=(0,o.useRef)(null),h=(0,o.useRef)({}),x=(0,o.useRef)(null),m=(0,o.useRef)(null),{tree:f,loading:v,exists:g,refresh:y,reconnect:b,browseDir:j,setBrowseDir:w,parentDir:N,workspaceRoot:C,openclawDir:S,activeWorkspace:M,showHidden:L,setShowHidden:T}=function(){let[e,t]=(0,o.useState)([]),[r,n]=(0,o.useState)(!0),[l,a]=(0,o.useState)(!1),[s,i]=(0,o.useState)(null),[c,d]=(0,o.useState)(null),[u,p]=(0,o.useState)(null),[h,x]=(0,o.useState)(null),[m,f]=(0,o.useState)(null),[v,g]=(0,o.useState)(!1),y=(0,o.useRef)(!0),b=(0,o.useRef)(1e3),j=(0,o.useRef)(0),[k,w]=(0,o.useState)(0),N=(0,o.useCallback)(async()=>{let e=++j.current;try{let d=v?"?showHidden=1":"",u=await fetch("/api/workspace/tree".concat(d)),h=await u.json();if(y.current&&j.current===e){var r,o,l,s,i,c;t(null!=(r=h.tree)?r:[]),a(null!=(o=h.exists)&&o),p(null!=(l=h.workspaceRoot)?l:null),x(null!=(s=h.openclawDir)?s:null),f(null!=(c=null!=(i=h.workspace)?i:h.profile)?c:null),n(!1)}}catch(t){y.current&&j.current===e&&n(!1)}},[v]),C=(0,o.useCallback)(async e=>{let r=++j.current;try{n(!0);let s=v?"&showHidden=1":"",i=await fetch("/api/workspace/browse?dir=".concat(encodeURIComponent(e)).concat(s)),c=await i.json();if(y.current&&j.current===r){var o,l;t(null!=(o=c.entries)?o:[]),d(null!=(l=c.parentDir)?l:null),a(!0),n(!1)}}catch(e){y.current&&j.current===r&&n(!1)}},[v]),S=(0,o.useRef)(null),M=(0,o.useCallback)(e=>{let t=e;null!=e&&u&&e===u&&(t=null),null!=t&&t!==S.current&&n(!0),S.current=t,i(t)},[u]),L=(0,o.useCallback)(async()=>{s?await C(s):await N()},[s,C,N]),T=(0,o.useCallback)(()=>{L()},[L]),I=(0,o.useCallback)(()=>{w(e=>e+1),L()},[L]);return(0,o.useEffect)(()=>(y.current=!0,L(),()=>{y.current=!1}),[L]),(0,o.useEffect)(()=>{if(s)return;let e=null,t=null,r=null,n=!0,o=null;function l(){!t&&n&&(t=setInterval(()=>{n&&N()},5e3))}return function a(){if(n)try{(e=new EventSource("/api/workspace/watch")).addEventListener("connected",()=>{b.current=1e3,t&&(clearInterval(t),t=null)}),e.addEventListener("change",()=>{o&&clearTimeout(o),o=setTimeout(()=>{n&&N()},300)}),e.addEventListener("error",()=>{null==e||e.close(),e=null,function(){if(!n)return;l();let e=b.current;b.current=Math.min(2*e,3e4),r=setTimeout(()=>{t&&(clearInterval(t),t=null),a()},e)}()})}catch(e){l()}}(),()=>{n=!1,e&&e.close(),t&&clearInterval(t),r&&clearTimeout(r),o&&clearTimeout(o)}},[s,N,k]),{tree:e,loading:r,exists:l,refresh:T,reconnect:I,browseDir:s,setBrowseDir:M,parentDir:c,workspaceRoot:u,openclawDir:h,activeWorkspace:m,showHidden:v,setShowHidden:g}}(),{search:I}=function(e){let[t,r]=(0,o.useState)([]),[n,l]=(0,o.useState)(!0),a=(0,o.useRef)(!0),s=(0,o.useCallback)(async()=>{try{let t=await fetch("/api/workspace/search-index"),n=await t.json();if(a.current){var e;r(null!=(e=n.items)?e:[]),l(!1)}}catch(e){a.current&&l(!1)}},[]);(0,o.useEffect)(()=>(a.current=!0,s(),()=>{a.current=!1}),[s,e]);let i=(0,o.useMemo)(()=>{if(0===t.length)return null;let e=t.map(e=>({...e,fieldValues:e.fields?Object.values(e.fields).join(" "):void 0}));return new i_.A(e,iE)},[t]),c=(0,o.useCallback)(function(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:20;return e.trim()?i?i.search(e,{limit:r}).map(e=>e.item):[]:[...t].toSorted((e,t)=>{var r,n;let o={object:0,file:1,entry:2};return(null!=(r=o[e.kind])?r:9)-(null!=(n=o[t.kind])?n:9)}).slice(0,r)},[i,t]),d=(0,o.useRef)(c);return d.current=c,{items:t,loading:n,search:(0,o.useCallback)((e,t)=>d.current(e,t),[])}}(),[R,_]=(0,o.useState)(null),[E,D]=(0,o.useState)(null),[A,W]=(0,o.useState)({kind:"none"}),[B,F]=(0,o.useState)(!0),[P,z]=(0,o.useState)(null),[O,U]=(0,o.useState)(null),[H,V]=(0,o.useState)(null),[K,J]=(0,o.useState)([]),[q,G]=(0,o.useState)(!0),[$,Z]=(0,o.useState)(0),[Y,Q]=(0,o.useState)(new Set),[X,ee]=(0,o.useState)({}),[et,er]=(0,o.useState)(()=>dZ({parentRuns:[],subagents:[]})),[en,eo]=(0,o.useState)([]),[el,ea]=(0,o.useState)(null),[es,ei]=(0,o.useState)([]),[ec,ed]=(0,o.useState)([]),[eu,ep]=(0,o.useState)(null),[eh,ex]=(0,o.useState)([]),[em,eb]=(0,o.useState)(null),[ej,ek]=(0,o.useState)("overview"),[ew,eN]=(0,o.useState)("month"),[eC,eS]=(0,o.useState)(null),[eM,eL]=(0,o.useState)("all"),[eT,eI]=(0,o.useState)(null),[eR,e_]=(0,o.useState)(null),eE=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:768,[t,r]=(0,o.useState)(!1);return(0,o.useEffect)(()=>{let t=window.matchMedia("(max-width: ".concat(e-1,"px)")),n=()=>r(t.matches);return n(),t.addEventListener("change",n),()=>t.removeEventListener("change",n)},[e]),t}(),[eD,eA]=(0,o.useState)(!1),[eW,eB]=(0,o.useState)(!1),[eF,eP]=(0,o.useState)(!1),[ez,eO]=(0,o.useState)("files"),[eU,eH]=(0,o.useState)(!0),[eV,eK]=(0,o.useState)(!1),[eJ,eq]=(0,o.useState)(!1),[eG,e$]=(0,o.useState)(!1),[eZ,eY]=(0,o.useState)(null),[eQ,e0]=(0,o.useState)({tabs:[dW],activeTabId:dA}),e1=(0,o.useRef)(null),e2=(0,o.useRef)({tabs:[dW],activeTabId:dA});(0,o.useEffect)(()=>{let e=M||null;if(e1.current===e)return;e1.current=e;let t=function(e){try{let t=localStorage.getItem(dB(e));if(!t)return{tabs:[dW],activeTabId:dA};let r=JSON.parse(t);if(!Array.isArray(r.tabs))return{tabs:[dW],activeTabId:dA};return dP({tabs:r.tabs.map(dz),activeTabId:r.activeTabId})}catch(e){return{tabs:[dW],activeTabId:dA}}}(e);t.tabs.some(e=>e.id!==dA)?e0(t):e0(dO(t,dq())),ee({})},[M]),(0,o.useEffect)(()=>{if("hydrated"===c.current){var e=M||null;try{let t=dP({tabs:eQ.tabs,activeTabId:eQ.activeTabId}),r={tabs:t.tabs.map(e=>{let{id:t,type:r,title:n,icon:o,path:l,sessionId:a,sessionKey:s,parentSessionId:i,pinned:c,preview:d,channel:u}=e;return{id:t,type:r,title:n,icon:o,path:l,sessionId:a,sessionKey:s,parentSessionId:i,pinned:c,preview:d,channel:u}}),activeTabId:t.activeTabId};localStorage.setItem(dB(e),JSON.stringify(r))}catch(e){}}},[eQ,M]),(0,o.useEffect)(()=>{let e=new Set(eQ.tabs.map(e=>e.id));for(let t of(ee(t=>{let r=t;for(let n of Object.keys(t))e.has(n)||(r=d$(r,n));return r}),Object.keys(h.current)))e.has(t)||delete h.current[t]},[eQ.tabs]);let e4=(0,o.useRef)(null),e5=(0,o.useMemo)(()=>{var e;return null!=(e=eQ.tabs.find(e=>e.id===eQ.activeTabId))?e:dW},[eQ]),e3=(0,o.useMemo)(()=>eQ.tabs.filter(e=>e.id!==dA&&("chat"===e.type||"gateway-chat"===e.type)),[eQ.tabs]);(0,o.useEffect)(()=>{e2.current=eQ},[eQ]);let e6=(0,o.useCallback)(()=>{let e=dq();return D(null),W({kind:"none"}),U(null),ea(null),e0(t=>dO(t,e,{preview:!0})),e},[]),e8=(0,o.useCallback)(()=>{let e=dq();return D(null),W({kind:"none"}),U(null),ea(null),e0(t=>dO(t,e,{preview:!1})),e},[]),e7=(0,o.useCallback)((e,t)=>{D(null),W({kind:"none"}),U(e),ea(null),e0(r=>{var n,o;return n={preview:!0},dO(r,(o={sessionId:e,title:t},{id:dF(),type:"chat",title:o.title||"New Chat",sessionId:o.sessionId}),n)})},[]),e9=(0,o.useCallback)(e=>{D(null),W({kind:"none"}),U(e.parentSessionId),ea(e.sessionKey),e0(t=>{var r;return r={preview:!0},dO(t,{id:dF(),type:"chat",title:e.title||"Subagent",sessionKey:e.sessionKey,parentSessionId:e.parentSessionId},r)})},[]),te=(0,o.useCallback)((e,t,r,n)=>{D(null),W({kind:"none"}),U(null),ea(null),ep(e),e0(o=>{var l,a;return l={preview:!0},dO(o,(a={sessionKey:e,sessionId:t,channel:null!=r?r:"unknown",title:null!=n?n:"Channel Chat"},{id:dF(),type:"gateway-chat",title:a.title||"Channel Chat",sessionKey:a.sessionKey,sessionId:a.sessionId,channel:a.channel}),l)})},[]),tt=(0,o.useCallback)(e=>{e&&e!==dA&&e0(t=>dH(t,e))},[]),tr=(0,o.useCallback)(e=>{e&&e0(t=>{let r=t.tabs.find(t=>t.path===e);return r?dH(t,r.id):t})},[]),tn=(0,o.useMemo)(()=>{var e,t;if("chat"===e5.type||"gateway-chat"===e5.type)return e5.id;if(eu){let e=e3.find(e=>"gateway-chat"===e.type&&e.sessionKey===eu);if(e)return e.id}if(el){let e=e3.find(e=>e.sessionKey===el);if(e)return e.id}if(O){let e=e3.find(e=>e.sessionId===O);if(e)return e.id}if(eQ.activeTabId===dA){let e=e3.find(e=>!e.sessionId&&!e.sessionKey);if(e)return e.id}return null!=(t=null==(e=e3[0])?void 0:e.id)?t:null},[e5,O,el,eu,e3,eQ.activeTabId]);(0,o.useEffect)(()=>{if("chat"!==e5.type&&"gateway-chat"!==e5.type)return;let e=dG(e5);U(t=>t===e.sessionId?t:e.sessionId),ea(t=>t===e.subagentKey?t:e.subagentKey),ep(t=>t===e.gatewaySessionKey?t:e.gatewaySessionKey)},[e5]);let to=(0,o.useCallback)((e,t)=>{h.current[e]=t},[]);(0,o.useEffect)(()=>{var e;p.current=tn&&null!=(e=h.current[tn])?e:null},[tn]);let tl=(0,o.useCallback)((e,t)=>{ee(r=>(function(e,t){let r=e[t.tabId];return r&&r.sessionId===t.sessionId&&r.sessionKey===t.sessionKey&&r.isStreaming===t.isStreaming&&r.status===t.status&&r.isReconnecting===t.isReconnecting&&r.loadingSession===t.loadingSession?e:{...e,[t.tabId]:t}})(r,{tabId:e,...t}))},[]),ts=(0,o.useCallback)((e,t)=>{e0(r=>{let n=function(e,t,r){let n=null!=r?r:void 0,o=r?e.tabs.find(e=>e.id!==t&&"chat"===e.type&&!e.sessionKey&&e.sessionId===r):void 0;if(o){let r=e.tabs.find(e=>e.id===t),n=r&&!r.pinned?e.tabs.filter(e=>e.id!==t):e.tabs;return n===e.tabs&&e.activeTabId===o.id?e:{tabs:n,activeTabId:o.id}}let l=!1,a=e.tabs.map(e=>e.id!==t||e.sessionId===n&&void 0===e.sessionKey?e:(l=!0,{...e,sessionId:n,sessionKey:void 0}));return l?{...e,tabs:a}:e}(r,e,t);return t&&r.activeTabId===dA&&(n=dU(n,e)),n}),(eQ.activeTabId===e||eQ.activeTabId===dA||tn===e)&&(U(t),ea(null))},[eQ.activeTabId,tn]),ti=(0,o.useCallback)((e,t)=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{var r;null==(r=h.current[e])||r.sendNewMessage(t)})})},[]),tc=(0,o.useCallback)(e=>{let t=en.find(t=>t.childSessionKey===e);if(t)return void e9({sessionKey:t.childSessionKey,parentSessionId:t.parentSessionId,title:t.label||t.task});let r=en.find(t=>t.task===e);r&&e9({sessionKey:r.childSessionKey,parentSessionId:r.parentSessionId,title:r.label||r.task})},[e9,en]),td=(0,o.useCallback)(e=>{let t=en.find(t=>t.childSessionKey===e);t&&e9({sessionKey:e,parentSessionId:t.parentSessionId,title:t.label||t.task})},[e9,en]),tu=(0,o.useCallback)(()=>{if(!el)return;let e=en.find(e=>e.childSessionKey===el);if(e)return void e7(e.parentSessionId);ea(null)},[el,e7,en]),tp=(0,o.useCallback)(e=>{var t,r,n;let o={id:dF(),type:"object"===e.type?"object":(t=e.path).includes(".dench.app")?"app":t.startsWith("~cron")?"cron":t.startsWith("~cloud")?"cloud":t.startsWith("~integrations")?"integrations":t.startsWith("~skills")?"skills":"file",title:(r=e.path,(n=e.name)?n:r.split("/").pop()||r),path:e.path};e0(e=>dO(e,o,{preview:!0}))},[]),[th,tx]=(0,o.useState)(260),[tm,tf]=(0,o.useState)(320),[tv,tg]=(0,o.useState)(280),[ty,tb]=(0,o.useState)(420);(0,o.useEffect)(()=>{let e=window.localStorage.getItem(dQ),t=e?parseInt(e,10):NaN;Number.isFinite(t)&&tx(d2(t,200,480));let r=window.localStorage.getItem(dX),n=r?parseInt(r,10):NaN;Number.isFinite(n)&&tf(d2(n,260,900));let o=window.localStorage.getItem(d0),l=o?parseInt(o,10):NaN;Number.isFinite(l)&&tg(d2(l,220,480));let a=window.localStorage.getItem(d1),s=a?parseInt(a,10):NaN;Number.isFinite(s)&&tb(d2(s,360,720))},[]),(0,o.useEffect)(()=>{window.localStorage.setItem(dQ,String(th))},[th]),(0,o.useEffect)(()=>{window.localStorage.setItem(dX,String(tm))},[tm]),(0,o.useEffect)(()=>{window.localStorage.setItem(d0,String(tv))},[tv]),(0,o.useEffect)(()=>{window.localStorage.setItem(d1,String(ty))},[ty]),(0,o.useEffect)(()=>{let e=e=>{let t=e.metaKey||e.ctrlKey,r=e.key.toLowerCase();if(t&&"b"===r){e.preventDefault(),e.shiftKey?eP(e=>!e):eB(e=>!e);return}if(t&&"j"===r&&!e.shiftKey&&!e.altKey){e.preventDefault(),e$(e=>!e);return}if(t&&"w"===r&&!e.shiftKey&&!e.altKey){var n;e.preventDefault(),null==(n=e4.current)||n.call(e4);return}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[]);let tj=(0,o.useMemo)(()=>{if(!E||(0,k.L6)(E))return;let e=E.split("/").pop()||E;return{path:E,filename:e,isDirectory:"directory"===A.kind}},[E,A.kind]);(0,o.useEffect)(()=>{E||V(null)},[E]);let tk=(0,o.useCallback)(e=>{W(t=>"document"===t.kind||"file"===t.kind||"code"===t.kind?{...t,data:{...t.data,content:e}}:t)},[]),tw=(0,o.useCallback)(async()=>{try{let e=await fetch("/api/workspace/context"),t=await e.json();_(t)}catch(e){}},[]);(0,o.useEffect)(()=>{tw()},[tw]);let[tN,tC]=(0,o.useState)([]),tS=(0,o.useCallback)(async()=>{G(!0);try{var e;let t=await fetch("/api/web-sessions?includeAll=true"),r=null!=(e=(await t.json()).sessions)?e:[];J(r.filter(e=>!e.filePath)),tC(r.filter(e=>!!e.filePath))}catch(e){}finally{G(!1)}},[]);(0,o.useEffect)(()=>{tS()},[tS,$]);let tM=(0,o.useCallback)(()=>{Z(e=>e+1)},[]),tL=(0,o.useCallback)(async()=>{try{var e;let t=await fetch("/api/gateway/sessions"),r=(null!=(e=(await t.json()).sessions)?e:[]).map(e=>{var t;return{sessionKey:e.sessionKey,sessionId:e.sessionId,channel:e.channel,title:(null==(t=e.origin)?void 0:t.label)||"".concat(e.channel.charAt(0).toUpperCase()+e.channel.slice(1)," Session"),updatedAt:e.updatedAt,origin:e.origin}});ei(r)}catch(e){}},[]),tT=(0,o.useCallback)(async()=>{try{var e;let t=await fetch("/api/gateway/channels"),r=await t.json();ed(null!=(e=r.channels)?e:[])}catch(e){}},[]);(0,o.useEffect)(()=>{tL(),tT();let e=setInterval(tL,1e4),t=setInterval(tT,3e4);return()=>{clearInterval(e),clearInterval(t)}},[tL,tT]);let tI=(0,o.useCallback)(()=>{var e;(e={setBrowseDir:w,setActivePath:D,setContent:W,setChatSidebarPreview:z,setShowChatSidebar:F,setActiveSessionId:U,setActiveSubagentKey:ea,resetMainChat:()=>{h.current={},ee({}),er(dZ({parentRuns:[],subagents:[]})),Q(new Set),eo([]),e0({tabs:[dW],activeTabId:dA})},replaceUrlToRoot:()=>{},reconnectWorkspaceWatcher:b,refreshSessions:tM,refreshContext:()=>{tw()}}).setBrowseDir(null),e.setActivePath(null),e.setContent({kind:"none"}),e.setChatSidebarPreview(null),e.setShowChatSidebar(!0),e.setActiveSessionId(null),e.setActiveSubagentKey(null),e.resetMainChat(),e.replaceUrlToRoot(),e.reconnectWorkspaceWatcher(),e.refreshSessions(),e.refreshContext()},[b,tw,tM,i,w]),tR=(0,o.useCallback)(async e=>{if(!(await fetch("/api/web-sessions/".concat(e),{method:"DELETE"})).ok)return;let t=new Set(eQ.tabs.filter(t=>"chat"===t.type&&(t.sessionId===e||t.parentSessionId===e)).map(e=>e.id));if(e0(t=>{let r=function(e,t){var r,n;let o=e.tabs.filter(e=>!!e.pinned||"chat"!==e.type||e.sessionId!==t&&e.parentSessionId!==t),l=o.some(t=>t.id===e.activeTabId);return{tabs:o,activeTabId:l?e.activeTabId:null!=(n=null==(r=o[o.length-1])?void 0:r.id)?n:null}}(t,e);return r.tabs.some(e=>e.id!==dA)||(r=dO(r,dq())),r}),ee(e=>{let r=e;for(let e of t)r=d$(r,e);return r}),O===e){let t=K.filter(t=>t.id!==e);t.length>0?e7(t[0].id,t[0].title):e6()}tS()},[O,K,tS,e6,e7,eQ.tabs]),t_=(0,o.useCallback)(async(e,t)=>{await fetch("/api/web-sessions/".concat(e),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:t})}),tS()},[tS]);(0,o.useEffect)(()=>{let e=!1,t=async()=>{try{var t,r;let n=await fetch("/api/chat/runs");if(e)return;let o=await n.json(),l=null!=(t=o.parentRuns)?t:[],a=null!=(r=o.subagents)?r:[],s=l.filter(e=>"running"===e.status||"waiting-for-subagents"===e.status).map(e=>e.sessionId);er(dZ({parentRuns:l,subagents:a.map(e=>{var t;return{childSessionKey:e.childSessionKey,status:null!=(t=e.status)?t:"completed"}})})),eo(a),Q(e=>e.size===s.length&&s.every(t=>e.has(t))?e:new Set(s))}catch(e){}};t();let r=setInterval(t,3e3);return()=>{e=!0,clearInterval(r)}},[]);let tE=(0,o.useCallback)(async()=>{try{var e;let t=await fetch("/api/cron/jobs"),r=await t.json();ex(null!=(e=r.jobs)?e:[]),r.heartbeat&&eb(r.heartbeat)}catch(e){}},[]);(0,o.useEffect)(()=>{tE();let e=setInterval(tE,3e4);return()=>clearInterval(e)},[tE]);let tD=(0,o.useCallback)(async e=>{D(e.path),W({kind:"loading"});try{if("object"===e.type){let t=d3(e.path),r=async()=>{let e=await fetch("/api/workspace/objects/".concat(encodeURIComponent(t)));if(!e.ok){let t=await e.json().catch(()=>({}));return"DUCKDB_NOT_INSTALLED"===t.code?{status:"duckdb-missing"}:404===e.status||e.status>=500?{status:"retryable"}:{status:"fatal"}}return{status:"ok",data:await e.json()}},n=await r();if("retryable"===n.status&&(await new Promise(e=>setTimeout(e,150)),n=await r()),"duckdb-missing"===n.status)return void W({kind:"duckdb-missing"});if("ok"!==n.status)return void W({kind:"none"});let o=n.data;if(0===o.fields.length&&o.entries.length>0){await new Promise(e=>setTimeout(e,200));let e=await r();if("duckdb-missing"===e.status)return void W({kind:"duckdb-missing"});"ok"===e.status&&(o=e.data)}W({kind:"object",data:o})}else if("document"===e.type){let t=await fetch((0,k.kb)(e.path));if(!t.ok)return void W({kind:"none"});let r=await t.json();W({kind:"document",data:r,title:e.name.replace(/\.md$/,"")})}else if("database"===e.type)W({kind:"database",dbPath:e.path,filename:e.name});else if("report"===e.type)W({kind:"report",reportPath:e.path,filename:e.name});else if("file"===e.type){var t,n;if(oo(e.name)){let t=(0,k.oj)(e.path);W({kind:"spreadsheet",url:t,filename:e.name,filePath:e.path});return}if(lR(e.name)){try{let t=await fetch((0,k.oj)(e.path));if(!t.ok)return void W({kind:"none"});let n=await t.arrayBuffer(),o=await Promise.all([r.e(5360),r.e(4995)]).then(r.t.bind(r,14995,19)),l=await o.convertToHtml({arrayBuffer:n});W({kind:"richDocument",html:l.value,filePath:e.path,mode:"docx"})}catch(e){W({kind:"none"})}return}if(l_(e.name)){let t=await fetch((0,k.kb)(e.path));if(!t.ok)return void W({kind:"none"});let r=await t.json();W({kind:"richDocument",html:lE(r.content),filePath:e.path,mode:"txt"});return}let o=null!=(n=null==(t=e.name.split(".").pop())?void 0:t.toLowerCase())?n:"";if("html"===o||"htm"===o)return void W({kind:"html",rawUrl:(0,k.oj)(e.path),contentUrl:(0,k.kb)(e.path),filename:e.name});let l=oq(e.name);if(l){let t=(0,k.oj)(e.path);W({kind:"media",url:t,mediaType:l,filename:e.name,filePath:e.path});return}let a=await fetch((0,k.kb)(e.path));if(!a.ok)return void W({kind:"none"});let s=await a.json();iA(e.name)?W({kind:"code",data:s,filename:e.name,filePath:e.path}):W({kind:"file",data:s,filename:e.name})}else if("app"===e.type){let t=await fetch("/api/apps?app=".concat(encodeURIComponent(e.path),"&file=.dench.yaml&meta=1")),r={name:e.name};if(t.ok)try{r=await t.json()}catch(e){}W({kind:"app",appPath:e.path,manifest:r,filename:e.name})}else"folder"===e.type&&W({kind:"directory",node:e})}catch(e){W({kind:"none"})}},[]),tA=(0,o.useCallback)(e=>{let t={cloud:{path:"~cloud",name:"Cloud",kind:"cloud"},integrations:{path:"~integrations",name:"Integrations",kind:"integrations"},skills:{path:"~skills",name:"Skills",kind:"skill-store"},cron:{path:"~cron",name:"Cron",kind:"cron-dashboard"}}[e];tp({path:t.path,name:t.name,type:"folder"}),D(t.path),W({kind:t.kind})},[tp]),tW=(0,o.useCallback)(e=>{var t,r;eY({action:e.action,toolkitSlug:null!=(t=e.toolkitSlug)?t:null,toolkitName:null!=(r=e.toolkitName)?r:null})},[]),tB=(0,o.useCallback)(()=>{tA("integrations")},[tA]),tF=(0,o.useCallback)(e=>{if(j&&(0,k.Z1)(e.path)){if(C&&e.path===C)return void w(null);if(S&&S&&e.path.startsWith(S+"/web-chat")){w(null),D(null),W({kind:"none"}),e6();return}if("folder"===e.type){w(e.path),tp(e),D(e.path),W({kind:"directory",node:{name:e.name,path:e.path,type:"folder"}});return}}if(e.path.startsWith("~chats/"))return void e7(e.path.slice(7));if("~chats"===e.path)return void e6();if(e.path.startsWith("~cron/")){let t=e.path.slice(6),r=eh.find(e=>e.id===t);if(r){tp(e),D(e.path),W({kind:"cron-job",jobId:t,job:r});return}}if("~cron"===e.path){tp(e),D(e.path),W({kind:"cron-dashboard"});return}return"~skills"===e.path?void tA("skills"):"~integrations"===e.path?void tA("integrations"):"~cloud"===e.path?void tA("cloud"):void("folder"!==e.type&&(tp(e),tD(e)))},[tD,e6,e7,tp,eh,j,C,S,w,tA]),tP=(0,o.useCallback)(e=>{if(!e||e.id===dA){D(null),W({kind:"none"});return}if("chat"===e.type||"gateway-chat"===e.type){D(null),W({kind:"none"});let t=dG(e);U(t.sessionId),ea(t.subagentKey),ep(t.gatewaySessionKey);return}if(e.path){let t=d8(f,e.path);if(D(e.path),t)W({kind:"loading"}),tD(t);else if("~cron"===e.path)W({kind:"cron-dashboard"});else if("~skills"===e.path)W({kind:"skill-store"});else if("~integrations"===e.path)W({kind:"integrations"});else if("~cloud"===e.path)W({kind:"cloud"});else if(e.path.startsWith("~cron/")){let t=e.path.slice(6),r=eh.find(e=>e.id===t);r&&W({kind:"cron-job",jobId:t,job:r})}else{let t=e.title||e.path.split("/").pop()||e.path,r={name:t,path:e.path,type:"object"===e.type?"object":d6(t)};W({kind:"loading"}),tD(r)}}},[f,tD,eh]),tz=(0,o.useCallback)(e=>{let t=e2.current.tabs.find(t=>t.id===e);if(e===dA){e0(t=>{let r=dU(t,e);return r.tabs.filter(e=>e.id!==dA&&dJ(e)).some(e=>!e.sessionId&&!e.sessionKey)||(r={...dO(r,dq(),{preview:!0}),activeTabId:dA}),r}),U(null),ea(null),ep(null),tP(void 0);return}e0(t=>dU(t,e)),tP(t)},[tP]),tO=(0,o.useCallback)(e=>{let t=function(e,t){if(t===dA)return e;let r=e.tabs.findIndex(e=>e.id===t);if(-1===r||e.tabs[r].pinned)return e;let n=e.tabs.filter(e=>e.id!==t),o=e.activeTabId;return e.activeTabId===t&&(o=0===n.length?null:r<n.length?n[r].id:n[n.length-1].id),{tabs:n,activeTabId:o}}(eQ,e);if(!t.tabs.some(e=>e.id!==dA)){e0(t=dO(t,dq())),D(null),W({kind:"none"}),U(null),ea(null);return}if(e0(t),t.activeTabId!==eQ.activeTabId){let e=t.tabs.find(e=>e.id===t.activeTabId);if(e&&e.id!==dA)tP(e);else{let e=dG(t.tabs.find(e=>"chat"===e.type));U(e.sessionId),ea(e.subagentKey),tP(void 0)}}},[tP,eQ]);(0,o.useEffect)(()=>{e4.current=()=>{eQ.activeTabId&&tO(eQ.activeTabId)}},[eQ.activeTabId,tO]);let tU=(0,o.useCallback)(e=>{let t={tabs:eQ.tabs.filter(t=>t.id===e||t.pinned),activeTabId:e};e0(t),tP(t.tabs.find(e=>e.id===t.activeTabId))},[tP,eQ]),tH=(0,o.useCallback)(e=>{let t=function(e,t){let r=e.tabs.findIndex(e=>e.id===t);if(-1===r)return e;let n=e.tabs.filter((e,t)=>t<=r||e.pinned),o=n.some(t=>t.id===e.activeTabId);return{tabs:n,activeTabId:o?e.activeTabId:t}}(eQ,e);e0(t),tP(t.tabs.find(e=>e.id===t.activeTabId))},[tP,eQ]),tV=(0,o.useCallback)(()=>{e0(e=>{let t=function(e){let t=e.tabs.filter(e=>e.pinned),r=t.some(t=>t.id===e.activeTabId);return{tabs:t,activeTabId:r?e.activeTabId:dA}}(e);return D(null),W({kind:"none"}),U(null),ea(null),dO(t,dq())})},[]),tK=(0,o.useCallback)((e,t,r)=>{e0(n=>(function(e,t,r){var n;if(t===r||(null==(n=e.tabs[t])?void 0:n.id)===dA)return e;let o=Math.max(1,r),l=[...e.tabs],[a]=l.splice(t,1);return l.splice(o,0,a),{...e,tabs:l}})(dH(n,e),t,r))},[]),tJ=(0,o.useCallback)(e=>{e0(t=>({...t,tabs:t.tabs.map(t=>t.id===e?{...t,pinned:!t.pinned,preview:t.pinned?t.preview:void 0}:t)}))},[]),tq=(0,o.useCallback)(async e=>{if("folder"===e.type)return{kind:"directory",path:e.path,name:e.name};if("database"===e.type)return{kind:"database",dbPath:e.path,filename:e.name};let t=oq(e.name);if(t)return{kind:"media",url:(0,k.oj)(e.path),mediaType:t,filename:e.name,filePath:e.path};if(oo(e.name))return{kind:"spreadsheet",url:(0,k.oj)(e.path),filename:e.name,filePath:e.path};if(lR(e.name))try{let t=await fetch((0,k.oj)(e.path));if(!t.ok)return null;let n=await t.arrayBuffer(),o=await Promise.all([r.e(5360),r.e(4995)]).then(r.t.bind(r,14995,19)),l=await o.convertToHtml({arrayBuffer:n});return{kind:"richDocument",html:l.value,filePath:e.path,mode:"docx"}}catch(e){return null}if(l_(e.name)){let t=await fetch((0,k.kb)(e.path));return t.ok?{kind:"richDocument",html:lE((await t.json()).content),filePath:e.path,mode:"txt"}:null}let n=await fetch((0,k.kb)(e.path));if(!n.ok)return null;let o=await n.json();return"document"===e.type||"markdown"===o.type?{kind:"document",data:o,title:e.name.replace(/\.mdx?$/,"")}:iA(e.name)?{kind:"code",data:o,filename:e.name,filePath:e.path}:{kind:"file",data:o,filename:e.name}},[]),tG=(0,o.useCallback)(async e=>{let t=function(e){let t=e.trim();if(!t.startsWith("file://"))return t;try{let e=new URL(t);if("file:"!==e.protocol)return t;let r=decodeURIComponent(e.pathname);if(/^\/[A-Za-z]:\//.test(r))return r.slice(1);return r}catch(e){return t}}(e);if(!t)return!1;let r=e=>(tF(e),!0);if(!(0,k.Z1)(t)&&!(0,k.Pv)(t)&&!t.startsWith("./")&&!t.startsWith("../")){let e=d8(f,t);if(e)return r(e)}try{let e=await fetch("/api/workspace/path-info?path=".concat(encodeURIComponent(t)));if(!e.ok)return!1;let n=await e.json();if(!n.path||!n.name||!n.type)return!1;if(C&&(n.path===C||n.path.startsWith("".concat(C,"/")))){let e=n.path===C?"":n.path.slice(C.length+1);if(e){let t=d8(f,e);if(t)return r(t)}}if("directory"===n.type){let e={name:n.name,path:n.path,type:"folder"};return r(e)}if("file"===n.type){let e={name:n.name,path:n.path,type:d6(n.name)};return r(e)}}catch(e){}return!1},[f,tF,C]),t$=(0,o.useMemo)(()=>f,[f]),tZ=(0,o.useMemo)(()=>j?N:C?"/"===C?null:C.split("/").slice(0,-1).join("/")||"/":null,[j,N,C]),tY=(0,o.useCallback)(()=>{null!=tZ&&w(tZ)},[tZ,w]),tQ=(0,o.useCallback)(()=>{w(null)},[w]),tX=(0,o.useCallback)(()=>{D(null),W({kind:"none"}),U(null),ea(null),ep(null),e0(e=>{let t=dU(e,dA);return t.tabs.filter(e=>e.id!==dA&&dJ(e)).some(e=>!e.sessionId&&!e.sessionKey)||(t={...dO(t,dq(),{preview:!0}),activeTabId:dA}),t})},[]),t0=(0,o.useCallback)(e=>{var t,r;let n=null!=(r=p.current)?r:x.current;null==n||null==(t=n.insertFileMention)||t.call(n,e.name,e.path)},[]),t1=(0,o.useCallback)(e=>{let t={name:e.name,path:e.path,type:e.type};"folder"===e.type?(w(e.path),tp(t),D(e.path),W({kind:"directory",node:{name:e.name,path:e.path,type:"folder"}})):(w(e.path.split("/").slice(0,-1).join("/")||"/"),tp(t),tD(t))},[w,tp,tD]);(0,o.useEffect)(()=>{var e;if("hydrated"!==c.current)return;if(d.current){d.current=!1;return}let t=new URLSearchParams(window.location.search),r=(0,ta.ZC)({activePath:E,activeSessionId:O,activeSubagentKey:el,fileChatSessionId:H,browseDir:j,showHidden:L,previewPath:null!=(e=null==P?void 0:P.path)?e:null,terminalOpen:eG,cronView:ej,cronCalMode:ew,cronDate:eC,cronRunFilter:eM,cronRun:eT},t).toString();r!==t.toString()&&(u.current=r,i.push(r?"/?".concat(r):"/",{scroll:!1}))},[E,O,el,H,j,L,P,i,ej,ew,eC,eM,eT]),(0,o.useEffect)(()=>{let e=new URLSearchParams(window.location.search);if("1"===e.get("terminal")===eG)return;eG?e.set("terminal","1"):e.delete("terminal");let t=e.toString();window.history.replaceState(window.history.state,"",t?"/?".concat(t):"/")},[eG]);let t2=(0,o.useCallback)((e,t)=>{e_({objectName:e,entryId:t});let r=new URLSearchParams(s.toString());r.set("entry","".concat(e,":").concat(t)),i.push("/?".concat(r.toString()),{scroll:!1})},[s,i]),t4=(0,o.useCallback)(()=>{e_(null);let e=new URLSearchParams(s.toString());e.delete("entry");let t=e.toString();i.replace(t?"/?".concat(t):"/",{scroll:!1})},[s,i]);(0,o.useEffect)(()=>{if("init"!==c.current||v||0===f.length||e1.current!==(M||null))return;let e=(0,ta.yh)(s);if(e.path){let t=d8(f,e.path);if(t)tp(t),tD(t);else if("~cron"===e.path)tp({path:"~cron",name:"Cron",type:"folder"}),D("~cron"),W({kind:"cron-dashboard"}),e.cronView&&ek(e.cronView),e.cronCalMode&&eN(e.cronCalMode),e.cronDate&&eS(e.cronDate);else if(e.path.startsWith("~cron/"))tp({path:e.path,name:e.path.split("/").pop()||"Cron Job",type:"file"}),D(e.path),W({kind:"cron-dashboard"}),e.cronRunFilter&&eL(e.cronRunFilter),null!=e.cronRun&&eI(e.cronRun);else if("~skills"===e.path)tp({path:"~skills",name:"Skills",type:"folder"}),D("~skills"),W({kind:"skill-store"});else if("~integrations"===e.path)tp({path:"~integrations",name:"Integrations",type:"folder"}),D("~integrations"),W({kind:"integrations"});else if("~cloud"===e.path)tp({path:"~cloud",name:"Cloud",type:"folder"}),D("~cloud"),W({kind:"cloud"});else if((0,k.Z1)(e.path)||(0,k.Pv)(e.path)){let t={name:e.path.split("/").pop()||e.path,path:e.path,type:"file"};tp(t),tD(t)}e.fileChat&&V(e.fileChat)}else if(e.chat)e.subagent?e9({sessionKey:e.subagent,parentSessionId:e.chat,title:"Subagent"}):e7(e.chat);else{let e=eQ.tabs.find(e=>e.id===eQ.activeTabId);e&&e.id!==dA&&tP(e)}if(e.entry&&e_(e.entry),e.browse&&w(e.browse),e.hidden&&T(!0),e.preview){let t=e.preview,r=t.split("/").pop()||t;z({status:"loading",path:t,filename:r}),tq({name:r,path:t,type:"file"}).then(e=>{e?z({status:"ready",path:t,filename:r,content:e}):z({status:"error",path:t,filename:r,message:"Could not load preview"})})}e.terminal&&e$(!0),d.current=!0,c.current="hydrated"},[f,v,s,M,eQ,tD,tP,w,T,tq]),(0,o.useEffect)(()=>{let e=()=>{let e=window.location.search.replace(/^\?/,"");if(e===u.current)return;let t=(0,ta.yh)(window.location.search);if(t.path){let e=d8(f,t.path);if(e)tp(e),tD(e);else if("~cron"===t.path)tp({path:"~cron",name:"Cron",type:"folder"}),D("~cron"),W({kind:"cron-dashboard"});else if(t.path.startsWith("~cron/")){tp({path:t.path,name:t.path.split("/").pop()||"Cron Job",type:"file"}),D(t.path);let e=t.path.slice(6),r=eh.find(t=>t.id===e);r?W({kind:"cron-job",jobId:e,job:r}):W({kind:"cron-dashboard"})}else if("~skills"===t.path)tp({path:"~skills",name:"Skills",type:"folder"}),D("~skills"),W({kind:"skill-store"});else if("~integrations"===t.path)tp({path:"~integrations",name:"Integrations",type:"folder"}),D("~integrations"),W({kind:"integrations"});else if("~cloud"===t.path)tp({path:"~cloud",name:"Cloud",type:"folder"}),D("~cloud"),W({kind:"cloud"});else if((0,k.Z1)(t.path)||(0,k.Pv)(t.path)){let e={name:t.path.split("/").pop()||t.path,path:t.path,type:"file"};tp(e),tD(e)}V(t.fileChat)}else t.chat?t.subagent?e9({sessionKey:t.subagent,parentSessionId:t.chat,title:"Subagent"}):e7(t.chat):(D(null),W({kind:"none"}),U(null),ea(null),ep(null),e0(e=>{let t=dU(e,dA);return t.tabs.filter(e=>e.id!==dA&&dJ(e)).some(e=>!e.sessionId&&!e.sessionKey)||(t={...dO(t,dq(),{preview:!0}),activeTabId:dA}),t}));if(t.entry?e_(t.entry):e_(null),t.browse?w(t.browse):t.path&&(0,k.Z1)(t.path)||w(null),t.hidden?T(!0):T(!1),z(null),t.preview){let e=t.preview.split("/").pop()||t.preview;z({status:"loading",path:t.preview,filename:e}),tq({name:e,path:t.preview,type:"file"}).then(r=>{r?z({status:"ready",path:t.preview,filename:e,content:r}):z({status:"error",path:t.preview,filename:e,message:"Could not load preview"})})}e$(t.terminal),u.current=e};return window.addEventListener("popstate",e),()=>window.removeEventListener("popstate",e)},[f,eh,tD,w,T,tq]),(0,o.useEffect)(()=>{if(!(null==E?void 0:E.startsWith("~cron/"))||0===eh.length||"cron-job"===A.kind)return;let e=E.slice(6),t=eh.find(t=>t.id===e);t&&W({kind:"cron-job",jobId:e,job:t})},[E,eh,A.kind]),(0,o.useEffect)(()=>{let e=s.get("send");if(!e)return;let t=new URLSearchParams(window.location.search);t.delete("send");let r=t.toString();i.replace(r?"/?".concat(r):"/",{scroll:!1}),D(null),W({kind:"none"}),ti(e6().id,e)},[e6,s,i,ti]);let t5=(0,o.useCallback)(e=>{if(!e){D(null),W({kind:"none"});return}if((0,k.Z1)(e)){let t=e.split("/").pop()||e;w(e),D(e),W({kind:"directory",node:{name:t,path:e,type:"folder"}});return}let t=d8(f,e);t&&tF(t)},[f,tF,w]),t3=(0,o.useCallback)(e=>{let t=function t(r){for(let n of r){if("object"===n.type&&d3(n.path)===e)return n;if(n.children){let e=t(n.children);if(e)return e}}return null}(f);t&&tF(t)},[f,tF]),t6=(0,o.useCallback)(e=>{let t=(0,ta.lc)(e);if(t){if("entry"===t.kind)return void t2(t.objectName,t.entryId);let e=d8(f,t.path);if(e)return void tF(e)}let r=d8(f,e);r&&tF(r)},[f,tF,t2]),t8=(0,o.useCallback)(async()=>{if("object"!==A.kind)return;let e=A.data.object.name;try{let t=await fetch("/api/workspace/objects/".concat(encodeURIComponent(e)));if(!t.ok)return;let r=await t.json();W({kind:"object",data:r})}catch(e){}},[A]),t7=(0,o.useRef)(f);(0,o.useEffect)(()=>{t7.current!==f&&(t7.current=f,"object"===A.kind&&t8())},[f,A.kind,t8]);let t9=(0,o.useCallback)(e=>{let t=e.target.closest("a");if(!t)return;let r=t.getAttribute("href");r&&(0,ta.m9)(r)&&(e.preventDefault(),e.stopPropagation(),t6(r))},[t6]),re=(0,o.useCallback)(e=>{let t=eh.find(t=>t.id===e);t&&(D("~cron/".concat(e)),W({kind:"cron-job",jobId:e,job:t}))},[eh]),rt=(0,o.useCallback)(()=>{D("~cron"),W({kind:"cron-dashboard"}),eL("all"),eI(null)},[]),rr=(0,o.useCallback)(e=>{D(null),W({kind:"none"}),ti(e6().id,e)},[e6,ti]),rn=(0,o.useMemo)(()=>{if(!O)return;let e=K.find(e=>e.id===O);return(null==e?void 0:e.title)||void 0},[O,K]);(0,o.useEffect)(()=>{e0(e=>{let t=function(e,t){let r=new Map(t.map(e=>[e.id,e.title])),n=!1,o=e.tabs.map(e=>{if("chat"!==e.type||!e.sessionId)return e;let t=r.get(e.sessionId);return t&&t!==e.title?(n=!0,{...e,title:t}):e});return n?{...e,tabs:o}:e}(e,K);if(t=function(e,t){let r=new Map(t.map(e=>[e.childSessionKey,e.label||e.task])),n=!1,o=e.tabs.map(e=>{if("chat"!==e.type||!e.sessionKey)return e;let t=r.get(e.sessionKey);return t&&t!==e.title?(n=!0,{...e,title:t}):e});return n?{...e,tabs:o}:e}(t,en),!rn)return t;let r=t.tabs.find(e=>e.id===t.activeTabId);if((null==r?void 0:r.type)==="chat"&&r.title!==rn&&!r.sessionKey){var n=t,o=r.id;let e=!1,l=n.tabs.map(t=>t.id!==o||t.title===rn?t:(e=!0,{...t,title:rn}));return e?{...n,tabs:l}:n}return t})},[rn,K,en]);let ro=(0,o.useMemo)(()=>new Set(en.filter(e=>"running"===e.status).map(e=>e.childSessionKey)),[en]),rl=(0,o.useMemo)(()=>{let e=new Set;for(let t of e3){let r=X[t.id];if((null==r?void 0:r.isStreaming)||t.sessionKey&&(ro.has(t.sessionKey)||"running"===et.subagentStatuses.get(t.sessionKey))){e.add(t.id);continue}t.sessionId&&Y.has(t.sessionId)&&e.add(t.id)}return e},[et.subagentStatuses,X,e3,ro,Y]),ra=(0,o.useCallback)(e=>{Q(t=>{if(!t.has(e))return t;let r=new Set(t);return r.delete(e),r}),eo(t=>t.map(t=>t.parentSessionId===e&&"running"===t.status?{...t,status:"completed"}:t)),ee(t=>{let r={};for(let[n,o]of Object.entries(t))r[n]=o.sessionId===e?{...o,isStreaming:!1,isReconnecting:!1,status:"ready"}:o;return r})},[]),rs=(0,o.useCallback)(e=>{eo(t=>t.map(t=>t.childSessionKey===e&&"running"===t.status?{...t,status:"completed"}:t)),ee(t=>{let r={};for(let[n,o]of Object.entries(t))r[n]=o.sessionKey===e?{...o,isStreaming:!1,isReconnecting:!1,status:"ready"}:o;return r})},[]),ri=(0,o.useCallback)(async e=>{ra(e);try{await fetch("/api/chat/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:e,cascadeChildren:!0})})}catch(e){}},[ra]),rc=(0,o.useCallback)(async e=>{rs(e);try{await fetch("/api/chat/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionKey:e})})}catch(e){}},[rs]),rd=(0,o.useCallback)(e=>{let t=eQ.tabs.find(t=>t.id===e);if(t&&"chat"===t.type){if(t.sessionKey)return void rc(t.sessionKey);t.sessionId&&ri(t.sessionId)}},[ri,rc,eQ.tabs]),ru="chat"===e5.type||"gateway-chat"===e5.type||e5.id===dA||!E&&"none"===A.kind;return(0,n.jsxs)("div",{ref:m,className:"flex h-screen",style:{background:"var(--color-main-bg)"},onClick:t9,children:[eE?eD&&(0,n.jsx)(eX,{tree:t$,activePath:E,onSelect:e=>{tF(e),eA(!1)},onRefresh:y,orgName:null==R||null==(e=R.organization)?void 0:e.name,loading:v,browseDir:j,parentDir:tZ,onNavigateUp:tY,onGoHome:tQ,onFileSearchSelect:e=>{null==t1||t1(e),eA(!1)},workspaceRoot:C,onGoToChat:()=>{tX(),eA(!1)},onExternalDrop:t0,showHidden:L,onToggleHidden:()=>T(e=>!e),activeWorkspace:M,onWorkspaceChanged:tI,chatSessions:K,activeChatSessionId:O,activeChatSessionTitle:rn,chatStreamingSessionIds:Y,chatSubagents:en,chatActiveSubagentKey:el,chatSessionsLoading:q,onSelectChatSession:e=>{let t=K.find(t=>t.id===e);e7(e,null==t?void 0:t.title),eA(!1)},onNewChatSession:()=>{e8(),eA(!1)},onSelectChatSubagent:td,onDeleteChatSession:tR,onRenameChatSession:t_,chatGatewaySessions:es,chatChannelStatuses:ec,chatActiveGatewaySessionKey:eu,onSelectGatewayChatSession:(e,t)=>{let r=es.find(t=>t.sessionKey===e);te(e,t,null==r?void 0:r.channel,null==r?void 0:r.title),eA(!1)},chatFileScopedSessions:tN,chatHeartbeatInfo:em,activeTab:ez,onTabChange:eO,onNavigate:e=>{tA(e),eA(!1)},mobile:!0,onClose:()=>eA(!1)}):(0,n.jsx)("div",{className:"sidebar-animate flex shrink-0 flex-col relative z-10 ".concat(eW?"overflow-hidden":""),style:{width:eW?0:th,minWidth:eW?0:th,transition:"width 200ms ease, min-width 200ms ease"},children:(0,n.jsxs)("div",{className:"flex flex-col h-full relative",style:{width:th,minWidth:th},children:[(0,n.jsx)(d4,{mode:"left",containerRef:m,min:200,max:480,onResize:tx}),(0,n.jsx)(eX,{tree:t$,activePath:E,onSelect:tF,onRefresh:y,orgName:null==R||null==(t=R.organization)?void 0:t.name,loading:v,browseDir:j,parentDir:tZ,onNavigateUp:tY,onGoHome:tQ,onFileSearchSelect:t1,workspaceRoot:C,onGoToChat:tX,onExternalDrop:t0,showHidden:L,onToggleHidden:()=>T(e=>!e),width:th,onCollapse:()=>eB(!0),activeWorkspace:M,onWorkspaceChanged:tI,chatSessions:K,activeChatSessionId:O,activeChatSessionTitle:rn,chatStreamingSessionIds:Y,chatSubagents:en,chatActiveSubagentKey:el,chatSessionsLoading:q,onSelectChatSession:e=>{let t=K.find(t=>t.id===e);e7(e,null==t?void 0:t.title)},onNewChatSession:()=>{e8()},onSelectChatSubagent:td,onDeleteChatSession:tR,onRenameChatSession:t_,chatGatewaySessions:es,chatChannelStatuses:ec,chatActiveGatewaySessionKey:eu,onSelectGatewayChatSession:(e,t)=>{let r=es.find(t=>t.sessionKey===e);te(e,t,null==r?void 0:r.channel,null==r?void 0:r.title)},chatFileScopedSessions:tN,chatHeartbeatInfo:em,activeTab:ez,onTabChange:eO,onNavigate:tA})]})}),(0,n.jsxs)("main",{className:"flex-1 flex flex-col min-w-0 overflow-hidden",style:{background:"var(--color-surface)"},children:[(0,n.jsxs)("div",{className:"flex flex-1 min-h-0",children:[(0,n.jsxs)("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden",children:[eE&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"px-2 py-1.5 border-b flex-shrink-0 flex items-center gap-1.5",style:{borderColor:"var(--color-border)",background:"var(--color-surface)"},children:[(0,n.jsx)("button",{type:"button",onClick:()=>eA(!0),className:"p-1.5 rounded-lg flex-shrink-0",style:{color:"var(--color-text-muted)"},title:"Open sidebar",children:(0,n.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("line",{x1:"4",x2:"20",y1:"12",y2:"12"}),(0,n.jsx)("line",{x1:"4",x2:"20",y1:"6",y2:"6"}),(0,n.jsx)("line",{x1:"4",x2:"20",y1:"18",y2:"18"})]})}),(0,n.jsx)("div",{className:"flex-1 min-w-0 text-sm font-medium truncate",style:{color:"var(--color-text)"},children:E?E.split("/").pop():(null==R||null==(a=R.organization)?void 0:a.name)||"Workspace"}),(0,n.jsxs)("div",{className:"flex items-center gap-0.5",children:[E&&"none"!==A.kind&&(0,n.jsx)("button",{type:"button",onClick:()=>{D(null),W({kind:"none"})},className:"p-1.5 rounded-lg flex-shrink-0",style:{color:"var(--color-text-muted)"},title:"Back to chat",children:(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"m12 19-7-7 7-7"}),(0,n.jsx)("path",{d:"M19 12H5"})]})}),!ru&&tj&&(0,n.jsx)("button",{type:"button",onClick:()=>eq(!0),className:"p-1.5 rounded-lg flex-shrink-0",style:{color:"var(--color-text-muted)"},title:"Chat about this file",children:(0,n.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}),ru&&(0,n.jsx)("button",{type:"button",onClick:()=>eK(!0),className:"p-1.5 rounded-lg flex-shrink-0",style:{color:"var(--color-text-muted)"},title:"Chat history",children:(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,n.jsx)("polyline",{points:"12 6 12 12 16 14"})]})}),(0,n.jsx)("button",{type:"button",onClick:()=>e$(e=>!e),className:"p-1.5 rounded-lg flex-shrink-0",style:{color:eG?"var(--color-text)":"var(--color-text-muted)",background:eG?"var(--color-surface-hover)":"transparent"},title:"Terminal",children:(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("polyline",{points:"4 17 10 11 4 5"}),(0,n.jsx)("line",{x1:"12",x2:"20",y1:"19",y2:"19"})]})}),(0,n.jsx)("button",{type:"button",onClick:()=>e8(),className:"p-1.5 rounded-lg flex-shrink-0",style:{color:"var(--color-text-muted)"},title:"New chat",children:(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M12 5v14"}),(0,n.jsx)("path",{d:"M5 12h14"})]})})]})]}),eQ.tabs.length>1&&(0,n.jsx)("div",{className:"flex-shrink-0 flex items-center gap-1 px-2 py-1 overflow-x-auto border-b",style:{borderColor:"var(--color-border)",background:"var(--color-surface)"},children:eQ.tabs.map(e=>{let t=e.id===eQ.activeTabId,r=rl.has(e.id);return(0,n.jsxs)("button",{type:"button",onClick:()=>tz(e.id),className:"px-2.5 py-1 text-[11px] rounded-full whitespace-nowrap shrink-0 font-medium flex items-center gap-1.5",style:{background:t?"var(--color-accent)":"var(--color-surface-hover)",color:t?"white":"var(--color-text-muted)",border:t?"none":"1px solid var(--color-border)"},children:[r&&(0,n.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-green-500 shrink-0"}),(0,n.jsx)("span",{className:"truncate max-w-[120px]",style:{fontStyle:e.preview?"italic":"normal"},children:e.title.length>20?e.title.slice(0,20)+"...":e.title})]},e.id)})})]}),!eE&&(0,n.jsx)(dK,{tabs:eQ.tabs,activeTabId:eQ.activeTabId,onActivate:tz,leftContent:eW?(0,n.jsx)("button",{type:"button",onClick:()=>eB(!1),className:"p-1.5 rounded-md transition-colors hover:bg-black/5 cursor-pointer",style:{color:"var(--color-text-muted)"},title:"Show sidebar (⌘B)",children:(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),(0,n.jsx)("path",{d:"M9 3v18"})]})}):void 0,onClose:tO,onCloseOthers:tU,onCloseToRight:tH,onCloseAll:tV,onReorder:tK,onTogglePin:tJ,onMakePermanent:tt,liveChatTabIds:rl,onStopTab:rd,onNewTab:e8,rightContent:ru?(0,n.jsxs)(n.Fragment,{children:[tn&&rl.has(tn)&&(0,n.jsx)("button",{type:"button",onClick:()=>rd(tn),className:"p-1.5 rounded-lg cursor-pointer",style:{color:"var(--color-text-muted)"},title:"Stop active chat",children:(0,n.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:(0,n.jsx)("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2"})})}),(0,n.jsx)("button",{type:"button",onClick:()=>eH(e=>!e),className:"p-1.5 rounded-lg cursor-pointer",style:{color:eU?"var(--color-text)":"var(--color-text-muted)",background:eU?"var(--color-surface-hover)":"transparent"},title:"Chat history",children:(0,n.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}),O&&!el&&(0,n.jsxs)(ef,{children:[(0,n.jsx)(ev,{className:"p-1.5 rounded-lg cursor-pointer",style:{color:"var(--color-text-muted)"},title:"More options","aria-label":"More options",children:(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"1"}),(0,n.jsx)("circle",{cx:"5",cy:"12",r:"1"}),(0,n.jsx)("circle",{cx:"19",cy:"12",r:"1"})]})}),(0,n.jsx)(eg,{align:"end",side:"bottom",children:(0,n.jsxs)(ey,{variant:"destructive",onSelect:()=>tR(O),children:[(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M3 6h18"}),(0,n.jsx)("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),(0,n.jsx)("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]}),"Delete this chat"]})})]})]}):void 0}),!eE&&E&&"none"!==A.kind&&(0,n.jsxs)("div",{className:"px-6 border-b flex-shrink-0 flex items-center justify-between",style:{borderColor:"var(--color-border)"},children:[(0,n.jsx)(l3,{path:E,onNavigate:t5}),(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)("button",{type:"button",onClick:()=>{D(null),W({kind:"none"})},className:"p-1.5 rounded-lg flex-shrink-0",style:{color:"var(--color-text-muted)"},title:"Back to chat",children:(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"m12 19-7-7 7-7"}),(0,n.jsx)("path",{d:"M19 12H5"})]})}),tj&&(0,n.jsx)("button",{type:"button",onClick:()=>F(e=>!e),className:"p-1.5 rounded-lg flex-shrink-0",style:{color:B?"var(--color-text)":"var(--color-text-muted)",background:B?"var(--color-surface-hover)":"transparent"},title:B?"Hide chat":tj.isDirectory?"Chat about this folder":"Chat about this file",children:(0,n.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})})]})]}),(0,n.jsxs)("div",{className:"flex-1 flex min-h-0",children:[(0,n.jsx)("div",{className:ru?"flex-1 flex min-h-0 min-w-0 flex-col overflow-hidden":"hidden",style:{background:"var(--color-main-bg)"},children:e3.map(e=>{var t,r;let o="gateway-chat"===e.type,l=!o&&e.sessionKey?en.find(t=>t.childSessionKey===e.sessionKey):null,a=e.id===tn;return(0,n.jsx)("div",{className:a?"flex-1 flex min-h-0 min-w-0 flex-col overflow-hidden":"hidden",children:(0,n.jsx)(ih,{ref:t=>to(e.id,t),sessionTitle:e.title,initialSessionId:o||e.sessionKey?void 0:null!=(t=e.sessionId)?t:void 0,onActiveSessionChange:o||e.sessionKey?void 0:t=>ts(e.id,t),onSessionsChange:o?void 0:tM,onConversationActivity:()=>tt(e.id),onSubagentClick:tc,onFilePathClick:tG,onComposioAction:tW,onDeleteSession:o||e.sessionKey?void 0:tR,onRenameSession:o||e.sessionKey?void 0:t_,compact:eE,sessionKey:o?void 0:null!=(r=e.sessionKey)?r:void 0,subagentTask:null==l?void 0:l.task,subagentLabel:null==l?void 0:l.label,onBack:e.sessionKey&&!o?tu:void 0,hideHeaderActions:!eE,onRuntimeStateChange:t=>tl(e.id,t),gatewaySessionKey:o?e.sessionKey:void 0,gatewaySessionId:o?e.sessionId:void 0,gatewayChannel:o?e.channel:void 0,visible:a})},e.id)})}),!ru&&(0,n.jsx)("div",{className:"flex-1 overflow-y-auto",children:(0,n.jsx)(ue,{content:A,workspaceExists:g,expectedPath:C,tree:f,activePath:E,browseDir:j,treeLoading:v,members:null==R?void 0:R.members,onNodeSelect:tF,onNavigateToObject:t3,onRefreshObject:t8,onRefreshTree:y,onNavigate:t6,onOpenEntry:t2,activeEntryId:null==eR?void 0:eR.entryId,searchFn:I,onSelectCronJob:re,onBackToCronDashboard:rt,cronView:ej,onCronViewChange:ek,cronCalMode:ew,onCronCalModeChange:eN,cronDate:eC,onCronDateChange:eS,cronRunFilter:eM,onCronRunFilterChange:eL,cronRun:eT,onCronRunChange:eI,onSendCommand:rr,onMakeTabPermanent:tr})})]})]}),!eE&&ru&&eR&&(0,n.jsx)("aside",{className:"sidebar-animate flex-shrink-0 min-h-0 border-l flex flex-col relative overflow-hidden",style:{width:ty,borderColor:"var(--color-border)",background:"var(--color-bg)",transition:"width 200ms ease"},children:(0,n.jsxs)("div",{className:"flex h-full min-h-0 flex-col relative overflow-hidden",style:{width:ty,minWidth:ty},children:[(0,n.jsx)(d4,{mode:"right",containerRef:m,min:360,max:720,onResize:tb}),(0,n.jsx)(iR,{objectName:eR.objectName,entryId:eR.entryId,members:null==R?void 0:R.members,tree:f,searchFn:I,onClose:t4,onNavigateEntry:(e,t)=>t2(e,t),onNavigateObject:e=>{t4(),t3(e)},onRefresh:t8,onNavigate:t6})]})}),!eE&&ru&&!eR&&(0,n.jsx)("aside",{className:"sidebar-animate flex-shrink-0 min-h-0 border-l flex flex-col relative overflow-hidden",style:{width:eU?tv:0,borderColor:eU?"var(--color-border)":"transparent",background:"var(--color-bg)",transition:"width 200ms ease"},children:(0,n.jsxs)("div",{className:"flex h-full min-h-0 flex-col relative overflow-hidden",style:{width:tv,minWidth:tv},children:[(0,n.jsx)(d4,{mode:"right",containerRef:m,min:220,max:480,onResize:tg}),(0,n.jsx)(dE,{sessions:K,activeSessionId:O,activeSessionTitle:rn,streamingSessionIds:Y,subagents:en,activeSubagentKey:el,loading:q,onSelectSession:e=>{let t=K.find(t=>t.id===e);e7(e,null==t?void 0:t.title)},onNewSession:()=>{e8()},onSelectSubagent:td,onDeleteSession:tR,onRenameSession:t_,onStopSession:e=>{ri(e)},onStopSubagent:e=>{rc(e)},gatewaySessions:es,channelStatuses:ec,activeGatewaySessionKey:eu,onSelectGatewaySession:(e,t)=>{let r=es.find(t=>t.sessionKey===e);te(e,t,null==r?void 0:r.channel,null==r?void 0:r.title)},fileScopedSessions:tN,heartbeatInfo:em,embedded:!0})]})}),!eE&&!ru&&eR&&(0,n.jsx)("aside",{className:"sidebar-animate flex-shrink-0 min-h-0 border-l flex flex-col relative overflow-hidden",style:{width:ty,borderColor:"var(--color-border)",background:"var(--color-bg)",transition:"width 200ms ease"},children:(0,n.jsxs)("div",{className:"flex h-full min-h-0 flex-col relative overflow-hidden",style:{width:ty,minWidth:ty},children:[(0,n.jsx)(d4,{mode:"right",containerRef:m,min:360,max:720,onResize:tb}),(0,n.jsx)(iR,{objectName:eR.objectName,entryId:eR.entryId,members:null==R?void 0:R.members,tree:f,searchFn:I,onClose:t4,onNavigateEntry:(e,t)=>t2(e,t),onNavigateObject:e=>{t4(),t3(e)},onRefresh:t8,onNavigate:t6})]})}),!eE&&!ru&&!eR&&tj&&(0,n.jsx)("aside",{className:"sidebar-animate flex-shrink-0 min-h-0 border-l flex flex-col relative overflow-hidden",style:{width:B&&!eF?tm:0,borderColor:B&&!eF?"var(--color-border)":"transparent",background:"var(--color-bg)",transition:"width 200ms ease"},children:(0,n.jsxs)("div",{className:"flex h-full min-h-0 flex-col relative overflow-hidden",style:{width:tm,minWidth:tm},children:[(0,n.jsx)(d4,{mode:"right",containerRef:m,min:260,max:900,onResize:tf}),(0,n.jsx)(ih,{ref:x,compact:!0,fileContext:tj,initialSessionId:null!=H?H:void 0,onFileChanged:tk,onFilePathClick:tG,onComposioAction:tW,onActiveSessionChange:V})]})})]}),eE&&eV&&(0,n.jsx)(dE,{sessions:K,activeSessionId:O,activeSessionTitle:rn,streamingSessionIds:Y,subagents:en,activeSubagentKey:el,loading:q,onSelectSession:e=>{let t=K.find(t=>t.id===e);e7(e,null==t?void 0:t.title),eK(!1)},onNewSession:()=>{e8(),eK(!1)},onSelectSubagent:e=>{td(e),eK(!1)},onDeleteSession:tR,onRenameSession:t_,onStopSession:e=>{ri(e)},onStopSubagent:e=>{rc(e)},gatewaySessions:es,channelStatuses:ec,activeGatewaySessionKey:eu,onSelectGatewaySession:(e,t)=>{let r=es.find(t=>t.sessionKey===e);te(e,t,null==r?void 0:r.channel,null==r?void 0:r.title),eK(!1)},fileScopedSessions:tN,heartbeatInfo:em,mobile:!0,width:280,onClose:()=>eK(!1)}),eE&&eJ&&tj&&(0,n.jsx)("div",{className:"drawer-backdrop",onClick:()=>eq(!1),children:(0,n.jsx)("div",{onClick:e=>e.stopPropagation(),className:"fixed inset-y-0 right-0 z-50 drawer-right",style:{width:"min(85vw, 360px)"},children:(0,n.jsx)("div",{className:"flex flex-col h-full",style:{background:"var(--color-bg)"},children:(0,n.jsx)(ih,{ref:x,compact:!0,fileContext:tj,initialSessionId:null!=H?H:void 0,onFileChanged:tk,onFilePathClick:e=>{tG(e),eq(!1)},onComposioAction:e=>{tW(e),eq(!1)},onActiveSessionChange:V})})})}),(0,n.jsx)(cR,{request:eZ,onFallbackToIntegrations:tB}),eG&&(0,n.jsx)(dY,{onClose:()=>e$(!1),cwd:null!=C?C:void 0})]}),eE&&eR&&(0,n.jsx)("div",{className:"fixed inset-0 z-50 flex flex-col",style:{background:"var(--color-bg)"},children:(0,n.jsx)(iR,{objectName:eR.objectName,entryId:eR.entryId,members:null==R?void 0:R.members,tree:f,searchFn:I,onClose:t4,onNavigateEntry:(e,t)=>t2(e,t),onNavigateObject:e=>{t4(),t3(e)},onRefresh:t8,onNavigate:t6})})]})}function ue(e){let{content:t,workspaceExists:r,expectedPath:o,tree:l,activePath:a,browseDir:s,treeLoading:i,members:c,onNodeSelect:d,onNavigateToObject:u,onRefreshObject:p,onRefreshTree:h,onNavigate:x,onOpenEntry:m,activeEntryId:f,searchFn:v,onSelectCronJob:g,onBackToCronDashboard:y,cronView:b,onCronViewChange:j,cronCalMode:k,onCronCalModeChange:w,cronDate:N,onCronDateChange:C,cronRunFilter:S,onCronRunFilterChange:M,cronRun:L,onCronRunChange:T,onSendCommand:I,onMakeTabPermanent:R}=e;switch(t.kind){case"loading":return(0,n.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,n.jsx)(eU.V,{name:"braille",className:"text-2xl",style:{color:"var(--color-text-muted)"}})});case"object":return(0,n.jsx)(ut,{data:t.data,members:c,onNavigateToObject:u,onRefreshObject:p,onOpenEntry:m,activeEntryId:f});case"document":return(0,n.jsx)(ot,{content:t.data.content,title:t.title,filePath:null!=a?a:void 0,tree:l,onSave:h,onNavigate:x,searchFn:v,onDirty:a?()=>R(a):void 0});case"file":return(0,n.jsx)(ol,{content:t.data.content,filename:t.filename,type:"yaml"===t.data.type?"yaml":"text"});case"code":return(0,n.jsx)(oO,{content:t.data.content,filename:t.filename,filePath:t.filePath,onDirty:t.filePath?()=>R(t.filePath):void 0});case"media":return(0,n.jsx)(oX,{url:t.url,filename:t.filename,mediaType:t.mediaType,filePath:t.filePath});case"spreadsheet":return(0,n.jsx)(og,{url:t.url,filename:t.filename,filePath:t.filePath,onDirty:()=>R(t.filePath)});case"html":return(0,n.jsx)(ok,{rawUrl:t.rawUrl,contentUrl:t.contentUrl,filename:t.filename});case"app":return(0,n.jsx)(oE,{appPath:t.appPath,manifest:t.manifest});case"database":return(0,n.jsx)(ll,{dbPath:t.dbPath,filename:t.filename});case"report":return(0,n.jsx)(as,{reportPath:t.reportPath});case"directory":{let e=null!=s&&a===s;if(e&&i)return(0,n.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,n.jsx)(eU.V,{name:"braille",className:"text-2xl",style:{color:"var(--color-text-muted)"}})});let r=e?{...t.node,children:l}:t.node;return(0,n.jsx)(ur,{node:r,onNodeSelect:d})}case"cron-dashboard":return(0,n.jsx)(iO,{onSelectJob:g,onSendCommand:I,activeView:b,onViewChange:j,calendarMode:k,onCalendarModeChange:w,calendarDate:N,onCalendarDateChange:C});case"skill-store":return(0,n.jsx)("div",{className:"h-full overflow-y-auto",children:(0,n.jsx)("div",{className:"mx-auto max-w-5xl p-6",children:(0,n.jsx)(cc,{})})});case"integrations":return(0,n.jsx)("div",{className:"h-full overflow-y-auto",children:(0,n.jsx)("div",{className:"mx-auto max-w-5xl p-6",children:(0,n.jsx)(cT,{})})});case"cloud":return(0,n.jsx)("div",{className:"h-full overflow-y-auto",children:(0,n.jsxs)("div",{className:"mx-auto max-w-5xl p-6",children:[(0,n.jsxs)("div",{className:"mb-6",children:[(0,n.jsx)("h1",{className:"font-instrument text-3xl tracking-tight",style:{color:"var(--color-text)"},children:"Cloud"}),(0,n.jsx)("p",{className:"mt-1 text-sm",style:{color:"var(--color-text-muted)"},children:"Manage your Dench Cloud connection and model settings."})]}),(0,n.jsx)(cY,{})]})});case"cron-job":return(0,n.jsx)(c2,{job:t.job,onBack:y,onSendCommand:I,runFilter:S,onRunFilterChange:M,expandedRunTs:L,onExpandedRunChange:T});case"cron-session":return(0,n.jsx)(de,{job:t.job,run:t.run,sessionId:t.sessionId,onBack:()=>y(),onBackToJob:()=>g(t.jobId)});case"duckdb-missing":return(0,n.jsx)(lo,{});case"richDocument":return(0,n.jsx)(lD,{mode:t.mode,initialHtml:t.html,filePath:t.filePath,onSave:h,onDirty:()=>R(t.filePath)});default:if(0===l.length)return(0,n.jsx)(l6,{workspaceExists:r,expectedPath:o});return(0,n.jsx)(un,{tree:l,onNodeSelect:d})}}function ut(e){var t,r,a,s,i,c,d,u,p,h,x,m,f,v,g,y;let{data:b,members:j,onNavigateToObject:k,onRefreshObject:w,onOpenEntry:N,activeEntryId:C}=e,S=(0,l.useSearchParams)(),M=(0,l.useRouter)(),L=e=>{var t;let r=null!=(t=e.entry_id)?t:e.id;return"string"==typeof r?r:"number"==typeof r||"boolean"==typeof r||"bigint"==typeof r?String(r):""},[T,I]=(0,o.useState)(!1),R=(0,o.useMemo)(()=>(0,ta.yh)(S),[]),[_,E]=(0,o.useState)(()=>{var e;return null!=(e=R.viewType)?e:nM(void 0,void 0,b.object.default_view)}),[D,A]=(0,o.useState)(()=>{var e;return null!=(e=b.viewSettings)?e:{}}),[W,B]=(0,o.useState)(()=>{var e;return null!=(e=R.filters)?e:nz()}),[F,P]=(0,o.useState)(null!=(t=b.savedViews)?t:[]),[z,O]=(0,o.useState)(null!=(r=R.view)?r:b.activeView),[U,H]=(0,o.useState)(null!=(s=null!=(a=R.page)?a:b.page)?s:1),[V,K]=(0,o.useState)(null!=(c=null!=(i=R.pageSize)?i:b.pageSize)?c:100),[J,q]=(0,o.useState)(null!=(d=b.totalCount)?d:b.entries.length),[G,$]=(0,o.useState)(b.entries),[Z,Y]=(0,o.useState)(null!=(u=R.search)?u:""),[Q,X]=(0,o.useState)(null!=(p=R.sort)?p:void 0),ee=(0,o.useRef)(null),et=W.rules.length>0||(null!=(h=null==Q?void 0:Q.length)?h:0)>0||Z.trim().length>0,[er,en]=(0,o.useState)(null!=(x=R.cols)?x:void 0),[eo,el]=(0,o.useState)(()=>{var e;return null==(e=b.viewSettings)?void 0:e.column_widths}),ea=(0,o.useRef)(!1);(0,o.useEffect)(()=>{if(!ea.current){ea.current=!0;return}let e=new URLSearchParams(window.location.search),t=new URLSearchParams(e);for(let e of["viewType","view","filters","search","sort","page","pageSize","cols"])t.delete(e);_!==nM(void 0,void 0,b.object.default_view)&&t.set("viewType",_),z&&t.set("view",z),W.rules.length>0&&t.set("filters",btoa(JSON.stringify(W))),Z&&t.set("search",Z),Q&&Q.length>0&&t.set("sort",btoa(JSON.stringify(Q))),U>1&&t.set("page",String(U)),100!==V&&t.set("pageSize",String(V)),er&&er.length>0&&t.set("cols",er.join(","));let r=t.toString();r!==e.toString()&&M.replace(r?"/?".concat(r):"/",{scroll:!1})},[_,z,W,Z,Q,U,V,er]);let es=(0,o.useMemo)(()=>{if(!er||0===er.length)return;let e={};for(let t of b.fields)e[t.id]=er.includes(t.name);return e.created_at=er.includes("created_at"),e.updated_at=er.includes("updated_at"),e},[er,b.fields]),ei=(0,o.useCallback)(e=>{let t=[];for(let r of b.fields)!1!==e[r.id]&&t.push(r.name);!1!==e.created_at&&t.push("created_at"),!1!==e.updated_at&&t.push("updated_at"),en(t.length>0?t:void 0)},[b.fields]),ec=(0,o.useMemo)(()=>{if(!eo)return;let e={};for(let t of b.fields)null!=eo[t.name]&&(e[t.id]=eo[t.name]);return null!=eo.created_at&&(e.created_at=eo.created_at),null!=eo.updated_at&&(e.updated_at=eo.updated_at),Object.keys(e).length>0?e:void 0},[eo,b.fields]),ed=(0,o.useCallback)(e=>{let t={};for(let r of b.fields)null!=e[r.id]&&(t[r.name]=Math.round(e[r.id]));null!=e.created_at&&(t.created_at=Math.round(e.created_at)),null!=e.updated_at&&(t.updated_at=Math.round(e.updated_at));let r=Object.keys(t).length>0?t:void 0;el(r);let n={...D,column_widths:r};fetch("/api/workspace/objects/".concat(encodeURIComponent(b.object.name),"/views"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({views:F,activeView:z,viewSettings:n})}).catch(()=>{})},[b.fields,b.object.name,D,F,z]),eu=(0,o.useCallback)(async e=>{var t,r,n,o,l,a,s,i;let c=null!=(t=null==e?void 0:e.page)?t:U,d=null!=(r=null==e?void 0:e.pageSize)?r:V,u=null!=(n=null==e?void 0:e.filters)?n:W,p=null!=(o=null==e?void 0:e.sort)?o:Q,h=null!=(l=null==e?void 0:e.search)?l:Z,x=new URLSearchParams;x.set("page",String(c)),x.set("pageSize",String(d)),u&&u.rules.length>0&&x.set("filters",nP(u)),p&&p.length>0&&x.set("sort",JSON.stringify(p)),h&&x.set("search",h);try{let e=await fetch("/api/workspace/objects/".concat(encodeURIComponent(b.object.name),"?").concat(x.toString()));if(!e.ok)return;let t=await e.json();$(t.entries),q(null!=(a=t.totalCount)?a:t.entries.length),H(null!=(s=t.page)?s:c),K(null!=(i=t.pageSize)?i:d)}catch(e){}},[U,V,W,Q,Z,b.object.name]);(0,o.useEffect)(()=>{var e;if(et)return void eu();$(b.entries),q(null!=(e=b.totalCount)?e:b.entries.length)},[b.entries,b.totalCount]),(0,o.useEffect)(()=>{var e;P(null!=(e=b.savedViews)?e:[]),b.viewSettings&&A(b.viewSettings);let t=function(e){var t,r,n,o;let l=e.activeView;if(!l)return null;let a=(null!=(t=e.savedViews)?t:[]).find(e=>e.name===l);if(!a)return null;let s=null!=(r=a.filters)?r:nz(),i=a.columns,c=a.column_widths,d=a.name,u=a.view_type,p=a.settings,h=e.currentActiveViewName!==d,x=(n=e.currentFilters,nP(n)!==nP(s)),m=!function(e,t){if(!e&&!t)return!0;if(!e||!t||e.length!==t.length)return!1;for(let r=0;r<e.length;r+=1)if(e[r]!==t[r])return!1;return!0}(e.currentViewColumns,i),f=e.currentViewType!==u,v=(o=e.currentSettings,(!!o||!!p)&&(!o||!p||JSON.stringify(o)!==JSON.stringify(p)));return{shouldApply:h||x||m||f||v,nextFilters:s,nextColumns:i,nextColumnWidths:c,nextActiveViewName:d,nextViewType:u,nextSettings:p}}({savedViews:b.savedViews,activeView:b.activeView,currentActiveViewName:z,currentFilters:W,currentViewColumns:er,currentColumnWidths:eo,currentViewType:_,currentSettings:D});(null==t?void 0:t.shouldApply)&&(B(t.nextFilters),en(t.nextColumns),void 0!==t.nextColumnWidths&&el(t.nextColumnWidths),O(t.nextActiveViewName),t.nextViewType&&E(t.nextViewType),t.nextSettings&&A(e=>({...e,...t.nextSettings})),eu({page:1,filters:t.nextFilters}))},[b.savedViews,b.activeView]);let ep=(0,o.useCallback)(e=>{B(e),H(1),eu({page:1,filters:e})},[eu]),eh=(0,o.useCallback)(e=>{Y(e),ee.current&&clearTimeout(ee.current),ee.current=setTimeout(()=>{H(1),eu({page:1,search:e})},300)},[eu]),ex=(0,o.useCallback)(e=>{H(e),eu({page:e})},[eu]),em=(0,o.useCallback)(e=>{K(e),H(1),eu({page:1,pageSize:e})},[eu]),ef=(0,o.useCallback)(()=>{eu(),w()},[eu,w]),ev=(0,o.useCallback)(async e=>{let t=[...F.filter(t=>t.name!==e),{name:e,view_type:_,filters:W,columns:er,column_widths:eo,settings:D}];P(t),O(e);try{await fetch("/api/workspace/objects/".concat(encodeURIComponent(b.object.name),"/views"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({views:t,activeView:e,viewSettings:D})})}catch(e){}},[W,F,b.object.name,_,er,eo,D]),eg=(0,o.useCallback)(e=>{var t;let r=null!=(t=e.filters)?t:nz();B(r),en(e.columns),el(e.column_widths),O(e.name),e.view_type&&E(e.view_type),e.settings&&A(t=>({...t,...e.settings})),H(1),eu({page:1,filters:r})},[eu]),ey=(0,o.useCallback)(async e=>{let t=F.filter(t=>t.name!==e);P(t),z===e&&(O(void 0),B(nz()),en(void 0));try{await fetch("/api/workspace/objects/".concat(encodeURIComponent(b.object.name),"/views"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({views:t,activeView:z===e?void 0:z})})}catch(e){}},[F,z,b.object.name]),eb=(0,o.useCallback)(async e=>{O(e),e||en(void 0);try{await fetch("/api/workspace/objects/".concat(encodeURIComponent(b.object.name),"/views"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({views:F,activeView:e})})}catch(e){}},[F,b.object.name]),ej=(0,o.useCallback)(e=>{E(e)},[]),ek=(0,o.useCallback)(async e=>{A(e);try{await fetch("/api/workspace/objects/".concat(encodeURIComponent(b.object.name),"/views"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({views:F,activeView:z,viewSettings:e})})}catch(e){}},[F,z,b.object.name]),ew=(0,o.useMemo)(()=>{let e=F.find(e=>e.name===z),t=function(e,t){if(!t)return null!=e?e:{};if(!e)return t;let r={...t};for(let t of Object.keys(e)){let n=e[t];void 0!==n&&(r[t]=n)}return r}(null==e?void 0:e.settings,D),r=[...b.fields.map(e=>({name:e.name,type:e.type})),{name:"created_at",type:"date"},{name:"updated_at",type:"date"}];return"kanban"!==_||t.kanbanField||(t.kanbanField=nL("kanban","kanbanField",r)),"calendar"!==_||t.calendarDateField||(t.calendarDateField=nL("calendar","calendarDateField",r)),"timeline"!==_||t.timelineStartField||(t.timelineStartField=nL("timeline","timelineStartField",r)),"gallery"!==_||t.galleryTitleField||(t.galleryTitleField=nL("gallery","galleryTitleField",r)),"list"!==_||t.listTitleField||(t.listTitleField=nL("list","listTitleField",r)),t},[_,D,F,z,b.fields]),eN=async e=>{I(!0);try{(await fetch("/api/workspace/objects/".concat(encodeURIComponent(b.object.name),"/display-field"),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({displayField:e})})).ok&&w()}catch(e){}finally{I(!1)}},eC=(0,o.useCallback)(async e=>{let t=ew.calendarDateField,r=ew.calendarEndDateField;if(!t)return;let n={[t]:e.newDate};r&&e.newEndDate&&(n[r]=e.newEndDate),$(n=>n.map(n=>{if(L(n)!==e.entryId)return n;let o={...n,[t]:e.newDate};return r&&e.newEndDate&&(o[r]=e.newEndDate),o}));try{await fetch("/api/workspace/objects/".concat(encodeURIComponent(b.object.name),"/entries/").concat(encodeURIComponent(e.entryId)),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({fields:n})})}catch(e){}},[ew,b.object.name]),eS=(0,o.useCallback)(async e=>{let t=ew.timelineStartField,r=ew.timelineEndField;if(!t)return;let n={[t]:e.newStartDate};r&&(n[r]=e.newEndDate),$(n=>n.map(n=>{if(L(n)!==e.entryId)return n;let o={...n,[t]:e.newStartDate};return r&&(o[r]=e.newEndDate),o}));try{await fetch("/api/workspace/objects/".concat(encodeURIComponent(b.object.name),"/entries/").concat(encodeURIComponent(e.entryId)),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({fields:n})})}catch(e){}},[ew,b.object.name]),eM=b.fields.filter(e=>!["relation","boolean","richtext"].includes(e.type));b.fields.some(e=>"relation"===e.type),b.reverseRelations&&b.reverseRelations.some(e=>Object.keys(e.entries).length>0);let eL=(0,o.useMemo)(()=>null==j?void 0:j.map(e=>({id:e.id,name:e.name})),[j]),eT=(0,o.useMemo)(()=>[...b.fields,{id:"created_at",name:"created_at",type:"date"},{id:"updated_at",name:"updated_at",type:"date"}],[b.fields]);return(0,n.jsxs)("div",{className:"flex flex-col h-full",children:[(0,n.jsxs)("div",{className:"px-5 py-2.5 flex items-center gap-3 flex-shrink-0",style:{borderBottom:"1px solid var(--color-border)"},children:[(0,n.jsx)("h1",{className:"text-sm font-semibold capitalize",style:{color:"var(--color-text)"},children:b.object.name}),b.object.description&&(0,n.jsx)("span",{className:"text-xs",style:{color:"var(--color-text-muted)"},children:b.object.description}),(0,n.jsxs)("span",{className:"text-[11px]",style:{color:"var(--color-text-muted)"},children:[J," ",1===J?"entry":"entries"," \xb7 ",b.fields.length," fields"]}),(0,n.jsx)("div",{className:"flex-1"}),eM.length>0&&(0,n.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,n.jsx)("span",{className:"text-[11px]",style:{color:"var(--color-text-muted)"},children:"Display field:"}),(0,n.jsx)("select",{value:null!=(m=b.effectiveDisplayField)?m:"",onChange:e=>eN(e.target.value),disabled:T,className:"text-[11px] px-1.5 py-0.5 rounded outline-none cursor-pointer",style:{background:"var(--color-surface)",color:"var(--color-text)",border:"1px solid var(--color-border)",opacity:T?.5:1},children:eM.map(e=>(0,n.jsx)("option",{value:e.name,children:e.name},e.id))}),T&&(0,n.jsx)("div",{className:"w-3 h-3 border border-t-transparent rounded-full animate-spin",style:{borderColor:"var(--color-text-muted)"}})]})]}),(0,n.jsxs)("div",{className:"px-5 py-1.5 flex items-center gap-4 flex-shrink-0",style:{borderBottom:"1px solid var(--color-border)"},children:[(0,n.jsx)(nH,{value:_,onChange:ej}),(0,n.jsx)("div",{className:"w-px h-4 flex-shrink-0",style:{background:"var(--color-border)"}}),(0,n.jsx)("div",{className:"flex-1 min-w-0",children:(0,n.jsx)(dg,{fields:b.fields,filters:W,onFiltersChange:ep,savedViews:F,activeViewName:z,onSaveView:ev,onLoadView:eg,onDeleteView:ey,onSetActiveView:eb,members:eL})}),(0,n.jsx)(nQ,{viewType:_,settings:ew,fields:eT,onSettingsChange:ek})]}),(0,n.jsxs)("div",{className:"flex-1 min-h-0 overflow-hidden",children:["kanban"===_&&(0,n.jsx)("div",{className:"h-full overflow-auto px-6 py-4",children:(0,n.jsx)(rR,{objectName:b.object.name,fields:b.fields,entries:G,statuses:b.statuses,members:j,relationLabels:b.relationLabels,onEntryClick:N?e=>N(b.object.name,e):void 0,onRefresh:ef})}),"table"===_&&(0,n.jsx)(rw,{objectName:b.object.name,fields:b.fields,entries:G,members:j,relationLabels:b.relationLabels,reverseRelations:b.reverseRelations,onNavigateToObject:k,onNavigateToEntry:N,onEntryClick:N?e=>N(b.object.name,e):void 0,onRefresh:ef,activeEntryId:C,columnVisibility:es,onColumnVisibilityChanged:ei,columnSizing:ec,onColumnSizingChanged:ed,serverPagination:{totalCount:J,page:U,pageSize:V,onPageChange:ex,onPageSizeChange:em},onServerSearch:eh}),"calendar"===_&&(0,n.jsx)("div",{className:"h-full overflow-auto px-6 py-4",children:(0,n.jsx)(nl,{objectName:b.object.name,fields:b.fields,entries:G,dateField:null!=(f=ew.calendarDateField)?f:"",endDateField:ew.calendarEndDateField,mode:null!=(v=ew.calendarMode)?v:"month",onModeChange:e=>ek({...ew,calendarMode:e}),members:j,onEntryClick:N?e=>N(b.object.name,e):void 0,onEntryDateChange:eC})}),"timeline"===_&&(0,n.jsx)("div",{className:"h-full overflow-auto px-6 py-4",children:(0,n.jsx)(nf,{objectName:b.object.name,fields:b.fields,entries:G,startDateField:null!=(g=ew.timelineStartField)?g:"",endDateField:ew.timelineEndField,groupField:ew.timelineGroupField,zoom:null!=(y=ew.timelineZoom)?y:"week",onZoomChange:e=>ek({...ew,timelineZoom:e}),members:j,onEntryClick:N?e=>N(b.object.name,e):void 0,onEntryDateChange:eS})}),"gallery"===_&&(0,n.jsx)("div",{className:"h-full overflow-auto px-6 py-4",children:(0,n.jsx)(nb,{objectName:b.object.name,fields:b.fields,entries:G,titleField:ew.galleryTitleField,coverField:ew.galleryCoverField,members:j,relationLabels:b.relationLabels,onEntryClick:N?e=>N(b.object.name,e):void 0})}),"list"===_&&(0,n.jsx)("div",{className:"h-full overflow-auto px-6 py-4",children:(0,n.jsx)(nN,{objectName:b.object.name,fields:b.fields,entries:G,titleField:ew.listTitleField,subtitleField:ew.listSubtitleField,members:j,onEntryClick:N?e=>N(b.object.name,e):void 0})})]})]})}function ur(e){var t;let{node:r,onNodeSelect:o}=e,l=null!=(t=r.children)?t:[];return(0,n.jsxs)("div",{className:"p-6 max-w-4xl mx-auto",children:[(0,n.jsx)("h1",{className:"font-instrument text-3xl tracking-tight mb-1 capitalize",style:{color:"var(--color-text)"},children:r.name}),(0,n.jsxs)("p",{className:"text-sm mb-6",style:{color:"var(--color-text-muted)"},children:[l.length," items"]}),0===l.length?(0,n.jsx)("p",{className:"text-sm",style:{color:"var(--color-text-muted)"},children:"This folder is empty."}):(0,n.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:l.map(e=>(0,n.jsxs)("button",{type:"button",onClick:()=>o(e),className:"flex items-center gap-3 p-4 rounded-2xl text-left transition-all duration-100 cursor-pointer",style:{background:"var(--color-surface)",border:"1px solid var(--color-border)",boxShadow:"var(--shadow-sm)"},onMouseEnter:e=>{e.currentTarget.style.borderColor="var(--color-border-strong)",e.currentTarget.style.transform="translateY(-1px)"},onMouseLeave:e=>{e.currentTarget.style.borderColor="var(--color-border)",e.currentTarget.style.transform="translateY(0)"},children:[(0,n.jsx)("span",{className:"w-10 h-10 rounded-xl flex items-center justify-center flex-shrink-0",style:{background:"object"===e.type?"var(--color-chip-object)":"document"===e.type?"var(--color-chip-document)":"database"===e.type?"var(--color-chip-database)":"report"===e.type?"var(--color-chip-report)":"var(--color-surface-hover)",color:"object"===e.type?"var(--color-chip-object-text)":"document"===e.type?"var(--color-chip-document-text)":"database"===e.type?"var(--color-chip-database-text)":"report"===e.type?"var(--color-chip-report-text)":"var(--color-text-muted)"},children:(0,n.jsx)(uo,{type:e.type})}),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsx)("div",{className:"text-sm font-medium truncate",style:{color:"var(--color-text)"},children:e.name.replace(/\.md$/,"")}),(0,n.jsxs)("div",{className:"text-xs capitalize",style:{color:"var(--color-text-muted)"},children:[e.type,e.children?" (".concat(e.children.length,")"):""]})]})]},e.path))})]})}function un(e){let{tree:t,onNodeSelect:r}=e,o=[],l=[];return!function e(t){for(let r of t)"object"===r.type?o.push(r):"document"===r.type&&l.push(r),r.children&&e(r.children)}(t),(0,n.jsxs)("div",{className:"p-8 max-w-4xl mx-auto",children:[(0,n.jsx)("h1",{className:"font-instrument text-3xl tracking-tight mb-2",style:{color:"var(--color-text)"},children:"Workspace"}),(0,n.jsx)("p",{className:"text-sm mb-8",style:{color:"var(--color-text-muted)"},children:"Select an item from the sidebar, or browse the sections below."}),o.length>0&&(0,n.jsxs)("div",{className:"mb-8",children:[(0,n.jsx)("h2",{className:"text-sm font-medium uppercase tracking-wider mb-3",style:{color:"var(--color-text-muted)"},children:"Objects"}),(0,n.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:o.map(e=>(0,n.jsxs)("button",{type:"button",onClick:()=>r(e),className:"flex items-center gap-3 p-4 rounded-2xl text-left transition-all duration-100 cursor-pointer",style:{background:"var(--color-surface)",border:"1px solid var(--color-border)",boxShadow:"var(--shadow-sm)"},onMouseEnter:e=>{e.currentTarget.style.borderColor="var(--color-accent)"},onMouseLeave:e=>{e.currentTarget.style.borderColor="var(--color-border)"},children:[(0,n.jsx)("span",{className:"w-10 h-10 rounded-xl flex items-center justify-center flex-shrink-0",style:{background:"var(--color-chip-object)",color:"var(--color-chip-object-text)"},children:(0,n.jsx)(uo,{type:"object"})}),(0,n.jsxs)("div",{className:"min-w-0",children:[(0,n.jsx)("div",{className:"text-sm font-medium capitalize truncate",style:{color:"var(--color-text)"},children:e.name}),(0,n.jsx)("div",{className:"text-xs",style:{color:"var(--color-text-muted)"},children:"kanban"===e.defaultView?"Kanban board":"Table view"})]})]},e.path))})]}),l.length>0&&(0,n.jsxs)("div",{children:[(0,n.jsx)("h2",{className:"text-sm font-medium uppercase tracking-wider mb-3",style:{color:"var(--color-text-muted)"},children:"Documents"}),(0,n.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:l.map(e=>(0,n.jsxs)("button",{type:"button",onClick:()=>r(e),className:"flex items-center gap-3 p-4 rounded-2xl text-left transition-all duration-100 cursor-pointer",style:{background:"var(--color-surface)",border:"1px solid var(--color-border)",boxShadow:"var(--shadow-sm)"},onMouseEnter:e=>{e.currentTarget.style.borderColor="var(--color-chip-document-text)"},onMouseLeave:e=>{e.currentTarget.style.borderColor="var(--color-border)"},children:[(0,n.jsx)("span",{className:"w-10 h-10 rounded-xl flex items-center justify-center flex-shrink-0",style:{background:"var(--color-chip-document)",color:"var(--color-chip-document-text)"},children:(0,n.jsx)(uo,{type:"document"})}),(0,n.jsxs)("div",{className:"min-w-0",children:[(0,n.jsx)("div",{className:"text-sm font-medium truncate",style:{color:"var(--color-text)"},children:e.name.replace(/\.md$/,"")}),(0,n.jsx)("div",{className:"text-xs",style:{color:"var(--color-text-muted)"},children:"Document"})]})]},e.path))})]})]})}function uo(e){let{type:t}=e;switch(t){case"object":return(0,n.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M12 3v18"}),(0,n.jsx)("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),(0,n.jsx)("path",{d:"M3 9h18"}),(0,n.jsx)("path",{d:"M3 15h18"})]});case"document":return(0,n.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"}),(0,n.jsx)("path",{d:"M14 2v4a2 2 0 0 0 2 2h4"}),(0,n.jsx)("path",{d:"M10 9H8"}),(0,n.jsx)("path",{d:"M16 13H8"}),(0,n.jsx)("path",{d:"M16 17H8"})]});case"folder":return(0,n.jsx)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"})});case"database":return(0,n.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("ellipse",{cx:"12",cy:"5",rx:"9",ry:"3"}),(0,n.jsx)("path",{d:"M3 5V19A9 3 0 0 0 21 19V5"}),(0,n.jsx)("path",{d:"M3 12A9 3 0 0 0 21 12"})]});case"report":return(0,n.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("line",{x1:"12",x2:"12",y1:"20",y2:"10"}),(0,n.jsx)("line",{x1:"18",x2:"18",y1:"20",y2:"4"}),(0,n.jsx)("line",{x1:"6",x2:"6",y1:"20",y2:"14"})]});default:return(0,n.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"}),(0,n.jsx)("path",{d:"M14 2v4a2 2 0 0 0 2 2h4"})]})}}function ul(){return(0,n.jsx)(d7,{})}},68840:(e,t,r)=>{"use strict";r.d(t,{VE:()=>d,ZC:()=>c,bJ:()=>u,lc:()=>p,m9:()=>h,yh:()=>s});let n=["table","kanban","calendar","timeline","gallery","list"],o=["overview","calendar","timeline","insights"],l=["day","week","month","year"],a=["all","ok","error","running"];function s(e){let t="string"==typeof e?new URLSearchParams(e):e,r=null,s=t.get("entry");if(s&&s.includes(":")){let e=s.indexOf(":");r={objectName:s.slice(0,e),entryId:s.slice(e+1)}}let i=null,c=t.get("filters");if(c)try{i=JSON.parse(atob(c))}catch(e){}let d=null,u=t.get("sort");if(u)try{d=JSON.parse(atob(u))}catch(e){}let p=t.get("page"),h=t.get("pageSize"),x=t.get("cols"),m=t.get("viewType"),f=t.get("cronView"),v=t.get("cronCalMode"),g=t.get("cronRunFilter"),y=t.get("cronRun");return{path:t.get("path"),chat:t.get("chat"),subagent:t.get("subagent"),fileChat:t.get("fileChat"),entry:r,send:t.get("send"),browse:t.get("browse"),hidden:"1"===t.get("hidden"),preview:t.get("preview"),view:t.get("view"),viewType:m&&n.includes(m)?m:null,filters:i,search:t.get("search"),sort:d,page:p&&parseInt(p,10)||null,pageSize:h&&parseInt(h,10)||null,cols:x?x.split(",").filter(Boolean):null,cronView:f&&o.includes(f)?f:null,cronCalMode:v&&l.includes(v)?v:null,cronDate:t.get("cronDate"),cronRunFilter:g&&a.includes(g)?g:null,cronRun:y&&parseInt(y,10)||null,terminal:"1"===t.get("terminal")}}let i=["viewType","view","filters","search","sort","page","pageSize","cols"];function c(e,t){let r=new URLSearchParams;if(e.activePath){r.set("path",e.activePath);let n=t.get("entry");for(let o of(n&&r.set("entry",n),e.fileChatSessionId&&r.set("fileChat",e.fileChatSessionId),"~cron"===e.activePath?("overview"!==e.cronView&&r.set("cronView",e.cronView),"calendar"===e.cronView&&"month"!==e.cronCalMode&&r.set("cronCalMode",e.cronCalMode),("calendar"===e.cronView||"timeline"===e.cronView)&&e.cronDate&&r.set("cronDate",e.cronDate)):e.activePath.startsWith("~cron/")&&("all"!==e.cronRunFilter&&r.set("cronRunFilter",e.cronRunFilter),null!=e.cronRun&&r.set("cronRun",String(e.cronRun))),i)){let e=t.get(o);e&&r.set(o,e)}}else e.activeSessionId&&(r.set("chat",e.activeSessionId),e.activeSubagentKey&&r.set("subagent",e.activeSubagentKey));return e.browseDir&&r.set("browse",e.browseDir),e.showHidden&&r.set("hidden","1"),e.previewPath&&r.set("preview",e.previewPath),e.terminalOpen&&r.set("terminal","1"),r}function d(e,t){return"/?entry=".concat(encodeURIComponent(e),":").concat(encodeURIComponent(t))}function u(e){return"/?path=".concat(encodeURIComponent(e))}function p(e){let t=function(e){try{if(e.startsWith("/"))return new URL(e,"http://localhost");let t=new URL(e);if("/"===t.pathname||"/workspace"===t.pathname)return t}catch(e){}return null}(e);if(t&&("/"===t.pathname||"/workspace"===t.pathname)){let e=t.searchParams.get("entry");if(e&&e.includes(":")){let t=e.indexOf(":");return{kind:"entry",objectName:e.slice(0,t),entryId:e.slice(t+1)}}let r=t.searchParams.get("path");if(r)return{kind:"file",path:r}}if(e.startsWith("@entry/")){let t=e.slice(7),r=t.indexOf("/");if(r>0)return{kind:"entry",objectName:t.slice(0,r),entryId:t.slice(r+1)}}return null}function h(e){return!!(e.startsWith("@entry/")||"/workspace"===e||e.startsWith("/workspace?")||e.startsWith("/workspace#")||"/"===e||e.startsWith("/?")||e.startsWith("/#"))}},71615:()=>{},77704:(e,t,r)=>{"use strict";r.d(t,{$Q:()=>o,IB:()=>a,x_:()=>l,zM:()=>s});var n=r(80534);function o(e){let{children:t}=e;return(0,n.jsx)("div",{className:"editor-toolbar-group",children:t})}function l(){return(0,n.jsx)("div",{className:"editor-toolbar-divider"})}function a(e){let{active:t,onClick:r,title:o,children:l,disabled:a}=e;return(0,n.jsx)("button",{type:"button",className:"editor-toolbar-btn ".concat(t?"editor-toolbar-btn-active":""),onClick:r,title:o,disabled:a,children:l})}function s(e){let{active:t,onClick:r,title:o,children:l}=e;return(0,n.jsx)("button",{type:"button",className:"bubble-menu-btn ".concat(t?"bubble-menu-btn-active":""),onClick:r,title:o,children:l})}},81183:(e,t,r)=>{Promise.resolve().then(r.bind(r,64243))},90425:(e,t,r)=>{"use strict";function n(e){return e.startsWith("~/")}function o(e){return e.startsWith("~")&&!n(e)}function l(e){return e.startsWith("/")}function a(e){return o(e)?"virtual":n(e)?"homeRelative":l(e)?"absolute":"workspaceRelative"}function s(e,t){return t?"/"===e?"/".concat(t):"".concat(e,"/").concat(t):e}function i(e,t){let r=a(e);return"absolute"===r||"homeRelative"===r?e:"workspaceRelative"===r?t?s(t,e):e:t?"~skills"===e?s(t,"skills"):e.startsWith("~skills/")?s(t,"skills/".concat(e.slice(8))):"~workspace"===e?t:e.startsWith("~workspace/")?s(t,e.slice(11)):e:e}function c(e){let t=a(e);return"virtual"===t?"/api/workspace/virtual-file?path=".concat(encodeURIComponent(e)):"absolute"===t||"homeRelative"===t?"/api/workspace/browse-file?path=".concat(encodeURIComponent(e)):"/api/workspace/file?path=".concat(encodeURIComponent(e))}function d(e){return!function(e){let t=a(e);return"absolute"===t||"homeRelative"===t}(e)?"/api/workspace/raw-file?path=".concat(encodeURIComponent(e)):"/api/workspace/browse-file?path=".concat(encodeURIComponent(e),"&raw=true")}function u(e){return"virtual"===a(e)?"/api/workspace/virtual-file":"/api/workspace/file"}r.d(t,{Bv:()=>a,L6:()=>o,Pv:()=>n,WW:()=>i,Z1:()=>l,kb:()=>c,nC:()=>u,oj:()=>d})}},e=>{e.O(0,[5700,6237,2830,5261,8438,2763,7073,1377,9702,1705,8522,7358],()=>e(e.s=81183)),_N_E=e.O()}]);