clawpad 0.3.10 → 0.3.11

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 (138) hide show
  1. package/.next/standalone/.next/BUILD_ID +1 -1
  2. package/.next/standalone/.next/app-path-routes-manifest.json +4 -4
  3. package/.next/standalone/.next/build-manifest.json +2 -2
  4. package/.next/standalone/.next/prerender-manifest.json +3 -3
  5. package/.next/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  6. package/.next/standalone/.next/server/app/_global-error.html +2 -2
  7. package/.next/standalone/.next/server/app/_global-error.rsc +1 -1
  8. package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  9. package/.next/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  10. package/.next/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  11. package/.next/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  12. package/.next/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  13. package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  14. package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  15. package/.next/standalone/.next/server/app/_not-found.html +1 -1
  16. package/.next/standalone/.next/server/app/_not-found.rsc +1 -1
  17. package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
  18. package/.next/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  19. package/.next/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
  20. package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  21. package/.next/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  22. package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  23. package/.next/standalone/.next/server/app/api/ai/write/route_client-reference-manifest.js +1 -1
  24. package/.next/standalone/.next/server/app/api/changes/[id]/route_client-reference-manifest.js +1 -1
  25. package/.next/standalone/.next/server/app/api/changes/record/route_client-reference-manifest.js +1 -1
  26. package/.next/standalone/.next/server/app/api/changes/revert/route_client-reference-manifest.js +1 -1
  27. package/.next/standalone/.next/server/app/api/changes/route_client-reference-manifest.js +1 -1
  28. package/.next/standalone/.next/server/app/api/changes/run/route_client-reference-manifest.js +1 -1
  29. package/.next/standalone/.next/server/app/api/chat/abort/route_client-reference-manifest.js +1 -1
  30. package/.next/standalone/.next/server/app/api/chat/route_client-reference-manifest.js +1 -1
  31. package/.next/standalone/.next/server/app/api/files/pages/[...path]/route_client-reference-manifest.js +1 -1
  32. package/.next/standalone/.next/server/app/api/files/recent/route_client-reference-manifest.js +1 -1
  33. package/.next/standalone/.next/server/app/api/files/search/route_client-reference-manifest.js +1 -1
  34. package/.next/standalone/.next/server/app/api/files/spaces/[space]/pages/route_client-reference-manifest.js +1 -1
  35. package/.next/standalone/.next/server/app/api/files/spaces/route_client-reference-manifest.js +1 -1
  36. package/.next/standalone/.next/server/app/api/files/watch/route_client-reference-manifest.js +1 -1
  37. package/.next/standalone/.next/server/app/api/gateway/detect/route_client-reference-manifest.js +1 -1
  38. package/.next/standalone/.next/server/app/api/gateway/events/route_client-reference-manifest.js +1 -1
  39. package/.next/standalone/.next/server/app/api/gateway/features/route_client-reference-manifest.js +1 -1
  40. package/.next/standalone/.next/server/app/api/gateway/history/route_client-reference-manifest.js +1 -1
  41. package/.next/standalone/.next/server/app/api/gateway/resolve/route_client-reference-manifest.js +1 -1
  42. package/.next/standalone/.next/server/app/api/gateway/sessions/route_client-reference-manifest.js +1 -1
  43. package/.next/standalone/.next/server/app/api/gateway/status/route_client-reference-manifest.js +1 -1
  44. package/.next/standalone/.next/server/app/api/openclaw/commands/route_client-reference-manifest.js +1 -1
  45. package/.next/standalone/.next/server/app/api/search/route_client-reference-manifest.js +1 -1
  46. package/.next/standalone/.next/server/app/api/settings/search-status/route_client-reference-manifest.js +1 -1
  47. package/.next/standalone/.next/server/app/api/setup/bootstrap/route_client-reference-manifest.js +1 -1
  48. package/.next/standalone/.next/server/app/api/setup/bootstrap-workspace/route_client-reference-manifest.js +1 -1
  49. package/.next/standalone/.next/server/app/api/setup/status/route_client-reference-manifest.js +1 -1
  50. package/.next/standalone/.next/server/app/api/setup/trigger-onboarding/route_client-reference-manifest.js +1 -1
  51. package/.next/standalone/.next/server/app/index.html +1 -1
  52. package/.next/standalone/.next/server/app/index.rsc +1 -1
  53. package/.next/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  54. package/.next/standalone/.next/server/app/index.segments/_full.segment.rsc +1 -1
  55. package/.next/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
  56. package/.next/standalone/.next/server/app/index.segments/_index.segment.rsc +1 -1
  57. package/.next/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  58. package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  59. package/.next/standalone/.next/server/app/settings/connection/page_client-reference-manifest.js +1 -1
  60. package/.next/standalone/.next/server/app/settings/connection.html +1 -1
  61. package/.next/standalone/.next/server/app/settings/connection.rsc +1 -1
  62. package/.next/standalone/.next/server/app/settings/connection.segments/_full.segment.rsc +1 -1
  63. package/.next/standalone/.next/server/app/settings/connection.segments/_head.segment.rsc +1 -1
  64. package/.next/standalone/.next/server/app/settings/connection.segments/_index.segment.rsc +1 -1
  65. package/.next/standalone/.next/server/app/settings/connection.segments/_tree.segment.rsc +1 -1
  66. package/.next/standalone/.next/server/app/settings/connection.segments/settings/connection/__PAGE__.segment.rsc +1 -1
  67. package/.next/standalone/.next/server/app/settings/connection.segments/settings/connection.segment.rsc +1 -1
  68. package/.next/standalone/.next/server/app/settings/connection.segments/settings.segment.rsc +1 -1
  69. package/.next/standalone/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  70. package/.next/standalone/.next/server/app/settings/relay/page_client-reference-manifest.js +1 -1
  71. package/.next/standalone/.next/server/app/settings/relay.html +1 -1
  72. package/.next/standalone/.next/server/app/settings/relay.rsc +1 -1
  73. package/.next/standalone/.next/server/app/settings/relay.segments/_full.segment.rsc +1 -1
  74. package/.next/standalone/.next/server/app/settings/relay.segments/_head.segment.rsc +1 -1
  75. package/.next/standalone/.next/server/app/settings/relay.segments/_index.segment.rsc +1 -1
  76. package/.next/standalone/.next/server/app/settings/relay.segments/_tree.segment.rsc +1 -1
  77. package/.next/standalone/.next/server/app/settings/relay.segments/settings/relay/__PAGE__.segment.rsc +1 -1
  78. package/.next/standalone/.next/server/app/settings/relay.segments/settings/relay.segment.rsc +1 -1
  79. package/.next/standalone/.next/server/app/settings/relay.segments/settings.segment.rsc +1 -1
  80. package/.next/standalone/.next/server/app/settings.html +1 -1
  81. package/.next/standalone/.next/server/app/settings.rsc +1 -1
  82. package/.next/standalone/.next/server/app/settings.segments/_full.segment.rsc +1 -1
  83. package/.next/standalone/.next/server/app/settings.segments/_head.segment.rsc +1 -1
  84. package/.next/standalone/.next/server/app/settings.segments/_index.segment.rsc +1 -1
  85. package/.next/standalone/.next/server/app/settings.segments/_tree.segment.rsc +1 -1
  86. package/.next/standalone/.next/server/app/settings.segments/settings/__PAGE__.segment.rsc +1 -1
  87. package/.next/standalone/.next/server/app/settings.segments/settings.segment.rsc +1 -1
  88. package/.next/standalone/.next/server/app/setup/page_client-reference-manifest.js +1 -1
  89. package/.next/standalone/.next/server/app/setup.html +1 -1
  90. package/.next/standalone/.next/server/app/setup.rsc +1 -1
  91. package/.next/standalone/.next/server/app/setup.segments/_full.segment.rsc +1 -1
  92. package/.next/standalone/.next/server/app/setup.segments/_head.segment.rsc +1 -1
  93. package/.next/standalone/.next/server/app/setup.segments/_index.segment.rsc +1 -1
  94. package/.next/standalone/.next/server/app/setup.segments/_tree.segment.rsc +1 -1
  95. package/.next/standalone/.next/server/app/setup.segments/setup/__PAGE__.segment.rsc +1 -1
  96. package/.next/standalone/.next/server/app/setup.segments/setup.segment.rsc +1 -1
  97. package/.next/standalone/.next/server/app/waitlist/page_client-reference-manifest.js +1 -1
  98. package/.next/standalone/.next/server/app/waitlist.html +1 -1
  99. package/.next/standalone/.next/server/app/waitlist.rsc +1 -1
  100. package/.next/standalone/.next/server/app/waitlist.segments/_full.segment.rsc +1 -1
  101. package/.next/standalone/.next/server/app/waitlist.segments/_head.segment.rsc +1 -1
  102. package/.next/standalone/.next/server/app/waitlist.segments/_index.segment.rsc +1 -1
  103. package/.next/standalone/.next/server/app/waitlist.segments/_tree.segment.rsc +1 -1
  104. package/.next/standalone/.next/server/app/waitlist.segments/waitlist/__PAGE__.segment.rsc +1 -1
  105. package/.next/standalone/.next/server/app/waitlist.segments/waitlist.segment.rsc +1 -1
  106. package/.next/standalone/.next/server/app/workspace/[...path]/page_client-reference-manifest.js +1 -1
  107. package/.next/standalone/.next/server/app/workspace/page.js +1 -1
  108. package/.next/standalone/.next/server/app/workspace/page_client-reference-manifest.js +1 -1
  109. package/.next/standalone/.next/server/app/workspace/search/page_client-reference-manifest.js +1 -1
  110. package/.next/standalone/.next/server/app/workspace/search.html +2 -2
  111. package/.next/standalone/.next/server/app/workspace/search.rsc +2 -2
  112. package/.next/standalone/.next/server/app/workspace/search.segments/_full.segment.rsc +2 -2
  113. package/.next/standalone/.next/server/app/workspace/search.segments/_head.segment.rsc +1 -1
  114. package/.next/standalone/.next/server/app/workspace/search.segments/_index.segment.rsc +1 -1
  115. package/.next/standalone/.next/server/app/workspace/search.segments/_tree.segment.rsc +1 -1
  116. package/.next/standalone/.next/server/app/workspace/search.segments/workspace/search/__PAGE__.segment.rsc +1 -1
  117. package/.next/standalone/.next/server/app/workspace/search.segments/workspace/search.segment.rsc +1 -1
  118. package/.next/standalone/.next/server/app/workspace/search.segments/workspace.segment.rsc +2 -2
  119. package/.next/standalone/.next/server/app/workspace.html +2 -2
  120. package/.next/standalone/.next/server/app/workspace.rsc +3 -3
  121. package/.next/standalone/.next/server/app/workspace.segments/_full.segment.rsc +3 -3
  122. package/.next/standalone/.next/server/app/workspace.segments/_head.segment.rsc +1 -1
  123. package/.next/standalone/.next/server/app/workspace.segments/_index.segment.rsc +1 -1
  124. package/.next/standalone/.next/server/app/workspace.segments/_tree.segment.rsc +1 -1
  125. package/.next/standalone/.next/server/app/workspace.segments/workspace/__PAGE__.segment.rsc +2 -2
  126. package/.next/standalone/.next/server/app/workspace.segments/workspace.segment.rsc +2 -2
  127. package/.next/standalone/.next/server/app-paths-manifest.json +4 -4
  128. package/.next/standalone/.next/server/chunks/3251.js +1 -1
  129. package/.next/standalone/.next/server/pages/404.html +1 -1
  130. package/.next/standalone/.next/server/pages/500.html +2 -2
  131. package/.next/standalone/.next/server/server-reference-manifest.json +1 -1
  132. package/.next/standalone/package.json +1 -1
  133. package/.next/static/chunks/app/workspace/{layout-e575f9cf6cc5dad5.js → layout-da037c6e6a03fd07.js} +1 -1
  134. package/.next/static/chunks/app/workspace/page-2f81f83f2248f181.js +1 -0
  135. package/package.json +1 -1
  136. package/.next/static/chunks/app/workspace/page-3869e183f908f2fc.js +0 -1
  137. /package/.next/static/{2YqlktL1-CoQ93cImgNTX → goNHxoIsvvFw7X46QPSkk}/_buildManifest.js +0 -0
  138. /package/.next/static/{2YqlktL1-CoQ93cImgNTX → goNHxoIsvvFw7X46QPSkk}/_ssgManifest.js +0 -0
@@ -1,2 +1,2 @@
1
- <!DOCTYPE html><!--2YqlktL1_CoQ93cImgNTX--><html id="__next_error__"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/webpack-c9a7907951504d87.js"/><script src="/_next/static/chunks/4bd1b696-e5d7c65570c947b7.js" async=""></script><script src="/_next/static/chunks/3794-337d1ca25ad99a89.js" async=""></script><script src="/_next/static/chunks/main-app-a1f34f01f7efbb58.js" async=""></script><meta name="next-size-adjust" content=""/><title>500: Internal Server Error.</title><script src="/_next/static/chunks/polyfills-42372ed130431b0a.js" noModule=""></script></head><body><div hidden=""><!--$--><!--/$--></div><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div style="line-height:48px"><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}
2
- @media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding-right:23px;font-size:24px;font-weight:500;vertical-align:top">500</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:28px">Internal Server Error.</h2></div></div></div><!--$--><!--/$--><script src="/_next/static/chunks/webpack-c9a7907951504d87.js" id="_R_" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0])</script><script>self.__next_f.push([1,"1:\"$Sreact.fragment\"\n2:I[57121,[],\"\"]\n3:I[74581,[],\"\"]\n4:I[90484,[],\"OutletBoundary\"]\n5:\"$Sreact.suspense\"\n7:I[90484,[],\"ViewportBoundary\"]\n9:I[90484,[],\"MetadataBoundary\"]\nb:I[27123,[],\"\"]\n"])</script><script>self.__next_f.push([1,"0:{\"P\":null,\"b\":\"2YqlktL1-CoQ93cImgNTX\",\"c\":[\"\",\"_global-error\"],\"q\":\"\",\"i\":false,\"f\":[[[\"\",{\"children\":[\"_global-error\",{\"children\":[\"__PAGE__\",{}]}]}],[[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$L2\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L3\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],{\"children\":[[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$L2\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L3\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],{\"children\":[[\"$\",\"$1\",\"c\",{\"children\":[[\"$\",\"html\",null,{\"id\":\"__next_error__\",\"children\":[[\"$\",\"head\",null,{\"children\":[\"$\",\"title\",null,{\"children\":\"500: Internal Server Error.\"}]}],[\"$\",\"body\",null,{\"children\":[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"style\":{\"lineHeight\":\"48px\"},\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}\\n@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"paddingRight\":23,\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\"},\"children\":\"500\"}],[\"$\",\"div\",null,{\"style\":{\"display\":\"inline-block\"},\"children\":[\"$\",\"h2\",null,{\"style\":{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"28px\"},\"children\":\"Internal Server Error.\"}]}]]}]}]}]]}],null,[\"$\",\"$L4\",null,{\"children\":[\"$\",\"$5\",null,{\"name\":\"Next.MetadataOutlet\",\"children\":\"$@6\"}]}]]}],{},null,false,false]},null,false,false]},null,false,false],[\"$\",\"$1\",\"h\",{\"children\":[null,[\"$\",\"$L7\",null,{\"children\":\"$L8\"}],[\"$\",\"div\",null,{\"hidden\":true,\"children\":[\"$\",\"$L9\",null,{\"children\":[\"$\",\"$5\",null,{\"name\":\"Next.Metadata\",\"children\":\"$La\"}]}]}],[\"$\",\"meta\",null,{\"name\":\"next-size-adjust\",\"content\":\"\"}]]}],false]],\"m\":\"$undefined\",\"G\":[\"$b\",[]],\"S\":true}\n"])</script><script>self.__next_f.push([1,"8:[[\"$\",\"meta\",\"0\",{\"charSet\":\"utf-8\"}],[\"$\",\"meta\",\"1\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}]]\n"])</script><script>self.__next_f.push([1,"6:null\na:[]\n"])</script></body></html>
1
+ <!DOCTYPE html><!--goNHxoIsvvFw7X46QPSkk--><html id="__next_error__"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/webpack-c9a7907951504d87.js"/><script src="/_next/static/chunks/4bd1b696-e5d7c65570c947b7.js" async=""></script><script src="/_next/static/chunks/3794-337d1ca25ad99a89.js" async=""></script><script src="/_next/static/chunks/main-app-a1f34f01f7efbb58.js" async=""></script><meta name="next-size-adjust" content=""/><title>500: Internal Server Error.</title><script src="/_next/static/chunks/polyfills-42372ed130431b0a.js" noModule=""></script></head><body><div hidden=""><!--$--><!--/$--></div><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div style="line-height:48px"><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}
2
+ @media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding-right:23px;font-size:24px;font-weight:500;vertical-align:top">500</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:28px">Internal Server Error.</h2></div></div></div><!--$--><!--/$--><script src="/_next/static/chunks/webpack-c9a7907951504d87.js" id="_R_" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0])</script><script>self.__next_f.push([1,"1:\"$Sreact.fragment\"\n2:I[57121,[],\"\"]\n3:I[74581,[],\"\"]\n4:I[90484,[],\"OutletBoundary\"]\n5:\"$Sreact.suspense\"\n7:I[90484,[],\"ViewportBoundary\"]\n9:I[90484,[],\"MetadataBoundary\"]\nb:I[27123,[],\"\"]\n"])</script><script>self.__next_f.push([1,"0:{\"P\":null,\"b\":\"goNHxoIsvvFw7X46QPSkk\",\"c\":[\"\",\"_global-error\"],\"q\":\"\",\"i\":false,\"f\":[[[\"\",{\"children\":[\"_global-error\",{\"children\":[\"__PAGE__\",{}]}]}],[[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$L2\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L3\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],{\"children\":[[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$L2\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L3\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],{\"children\":[[\"$\",\"$1\",\"c\",{\"children\":[[\"$\",\"html\",null,{\"id\":\"__next_error__\",\"children\":[[\"$\",\"head\",null,{\"children\":[\"$\",\"title\",null,{\"children\":\"500: Internal Server Error.\"}]}],[\"$\",\"body\",null,{\"children\":[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"style\":{\"lineHeight\":\"48px\"},\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}\\n@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"paddingRight\":23,\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\"},\"children\":\"500\"}],[\"$\",\"div\",null,{\"style\":{\"display\":\"inline-block\"},\"children\":[\"$\",\"h2\",null,{\"style\":{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"28px\"},\"children\":\"Internal Server Error.\"}]}]]}]}]}]]}],null,[\"$\",\"$L4\",null,{\"children\":[\"$\",\"$5\",null,{\"name\":\"Next.MetadataOutlet\",\"children\":\"$@6\"}]}]]}],{},null,false,false]},null,false,false]},null,false,false],[\"$\",\"$1\",\"h\",{\"children\":[null,[\"$\",\"$L7\",null,{\"children\":\"$L8\"}],[\"$\",\"div\",null,{\"hidden\":true,\"children\":[\"$\",\"$L9\",null,{\"children\":[\"$\",\"$5\",null,{\"name\":\"Next.Metadata\",\"children\":\"$La\"}]}]}],[\"$\",\"meta\",null,{\"name\":\"next-size-adjust\",\"content\":\"\"}]]}],false]],\"m\":\"$undefined\",\"G\":[\"$b\",[]],\"S\":true}\n"])</script><script>self.__next_f.push([1,"8:[[\"$\",\"meta\",\"0\",{\"charSet\":\"utf-8\"}],[\"$\",\"meta\",\"1\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}]]\n"])</script><script>self.__next_f.push([1,"6:null\na:[]\n"])</script></body></html>
@@ -1 +1 @@
1
- {"node":{},"edge":{},"encryptionKey":"rrAdRgE4fiAZHITZ+7TONJfUwBTKbwO3+kAhdS1fP0c="}
1
+ {"node":{},"edge":{},"encryptionKey":"RQaoDLuTXGp4Pymy2QN/4/bv5q5ZdFREjP7uwSZtBbo="}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clawpad",
3
- "version": "0.3.10",
3
+ "version": "0.3.11",
4
4
  "description": "A file-based, Notion-style document workspace for OpenClaw",
5
5
  "keywords": [
6
6
  "openclaw",
@@ -1,4 +1,4 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1807],{3163:(e,t,n)=>{"use strict";n.d(t,{e:()=>a});var s=n(1934);let r=0,a=(0,s.v)(e=>({items:[],addItem:t=>e(e=>({items:[{...t,id:`activity-${Date.now()}-${++r}`},...e.items].slice(0,20)})),clear:()=>e({items:[]})}))},7814:(e,t,n)=>{"use strict";function s(e){let t=e.replace(/\.md$/,"").split("/").filter(Boolean).map(e=>encodeURIComponent(e));return 0===t.length?"/workspace":`/workspace/${t.join("/")}`}n.d(t,{C:()=>s})},24733:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>nA});var s=n(95155),r=n(12115),a=n(12710),l=n(61878),i=n(51914),o=n(6071),c=n(52799),d=n(89239),u=n(70872),m=n(33210),h=n(19324);function x({...e}){return(0,s.jsx)(h.Root,{"data-slot":"sheet",...e})}function p({...e}){return(0,s.jsx)(h.Portal,{"data-slot":"sheet-portal",...e})}function g({className:e,...t}){return(0,s.jsx)(h.Overlay,{"data-slot":"sheet-overlay",className:(0,c.cn)("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t})}function f({className:e,children:t,side:n="right",showCloseButton:r=!0,...a}){return(0,s.jsxs)(p,{children:[(0,s.jsx)(g,{}),(0,s.jsxs)(h.Content,{"data-slot":"sheet-content",className:(0,c.cn)("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed z-50 flex flex-col gap-4 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500","right"===n&&"data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm","left"===n&&"data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm","top"===n&&"data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b","bottom"===n&&"data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t",e),...a,children:[t,r&&(0,s.jsxs)(h.Close,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none",children:[(0,s.jsx)(m.A,{className:"size-4"}),(0,s.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})}function b({className:e,...t}){return(0,s.jsx)(h.Title,{"data-slot":"sheet-title",className:(0,c.cn)("text-foreground font-semibold",e),...t})}var v=n(98500),w=n.n(v),j=n(73321),y=n(63393),N=n(89363),k=n(21362),C=n(48368),S=n(51900),A=n(36999),E=n(35585);function $({className:e,children:t,...n}){return(0,s.jsxs)(E.Root,{"data-slot":"scroll-area",className:(0,c.cn)("relative",e),...n,children:[(0,s.jsx)(E.Viewport,{"data-slot":"scroll-area-viewport",className:"focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1 [&>div]:!block [&>div]:!min-w-0",children:t}),(0,s.jsx)(z,{}),(0,s.jsx)(E.Corner,{})]})}function z({className:e,orientation:t="vertical",...n}){return(0,s.jsx)(E.ScrollAreaScrollbar,{"data-slot":"scroll-area-scrollbar",orientation:t,className:(0,c.cn)("flex touch-none p-px transition-colors select-none","vertical"===t&&"h-full w-2.5 border-l border-l-transparent","horizontal"===t&&"h-2.5 flex-col border-t border-t-transparent",e),...n,children:(0,s.jsx)(E.ScrollAreaThumb,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}var R=n(97916),T=n(45160),_=n(86846),D=n(93571),L=n(70460),M=n(18496),K=n(31328),P=n(53536),I=n(60464);function F(e,t){let n={type:"folder",name:"",path:"",children:[]},s=new Map;for(let r of(s.set("",n),e)){let e=function(e,t){let n=e.replace(/\\/g,"/").replace(/\.md$/,"");if(t===I.Sz)return n;let s=`${t}/`;return n.startsWith(s)?n.slice(s.length):n}(r.path,t),a=e.split("/").filter(Boolean);if(0===a.length)continue;let l=a.pop(),i=n,o="";for(let e of a){let t=o?`${o}/${e}`:e,n=s.get(t);n||(n={type:"folder",name:e,path:t,children:[]},s.set(t,n),i.children.push(n)),i=n,o=t}i.children.push({type:"page",name:l,path:e,page:r})}return n.children}var W=n(7814);function O({onNavigate:e}){return(0,s.jsxs)(w(),{href:"/workspace",onClick:()=>e?.(),className:"flex items-center gap-2 text-[13px] font-semibold leading-none transition-colors hover:text-foreground/80",children:[(0,s.jsx)(D.R,{variant:"wordmark",size:26,theme:"light",alt:"ClawPad",className:"-translate-y-[2px]"}),(0,s.jsx)(G,{})]})}function U({onNavigate:e,isSheet:t,showHeader:n=!0}){let a=(0,j.usePathname)(),o=(0,j.useRouter)(),{spaces:c,expandedSpaces:d,expandedFolders:u,toggleSpace:m,toggleFolder:h,pagesBySpace:x,spacesStatus:p,pagesStatusBySpace:g,pagesErrorBySpace:f,recentPages:b,recentStatus:v,loadSpaces:w,loadRecentPages:k,loadPages:C,setActivePage:S}=(0,M.M)();(0,r.useEffect)(()=>{w(),k()},[w,k]),(0,r.useEffect)(()=>{for(let e of c){if(!d.has(e.path)||e.pageCount<=0)continue;let t=x.get(e.path);t&&!(t.length>0)&&"loading"!==(g.get(e.path)??"idle")&&C(e.path,{force:!0,silent:!0})}},[d,C,x,g,c]),(0,r.useEffect)(()=>{a.startsWith("/workspace/")?S(a.replace("/workspace/","")):S(null)},[a,S]);let A=(0,r.useCallback)(t=>{o.push((0,W.C)(t)),e?.()},[o,e]),E=(0,r.useCallback)(()=>{window.dispatchEvent(new CustomEvent("clawpad:open-new-page",{detail:{mode:"document"}})),e?.()},[e]),z=(0,r.useCallback)(()=>{window.dispatchEvent(new CustomEvent("clawpad:open-new-page",{detail:{mode:"space"}})),e?.()},[e]),T=(0,r.useCallback)(()=>{window.dispatchEvent(new CustomEvent("clawpad:open-command-palette")),e?.()},[e]),D=(0,r.useCallback)(()=>{o.push("/settings/connection"),e?.()},[e,o]);return(0,s.jsxs)("div",{className:"flex h-full w-full flex-col overflow-hidden",children:[n&&(0,s.jsx)("div",{className:"flex h-12 shrink-0 items-center justify-between px-3",children:(0,s.jsx)(O,{onNavigate:e})}),(0,s.jsxs)("div",{className:"shrink-0 space-y-0.5 px-2",children:[(0,s.jsx)(Z,{icon:(0,s.jsx)(l.A,{className:"h-4 w-4"}),label:"Search",shortcut:"⌘K",onClick:T,touchFriendly:t}),(0,s.jsx)(Z,{icon:(0,s.jsx)(i.A,{className:"h-4 w-4"}),label:"New Document",shortcut:"⌘N",onClick:E,touchFriendly:t}),(0,s.jsx)(Z,{icon:(0,s.jsx)(y.A,{className:"h-4 w-4"}),label:"New Space",onClick:z,touchFriendly:t})]}),(0,s.jsx)(R.w,{className:"my-2 shrink-0"}),(0,s.jsx)($,{className:"min-h-0 flex-1 w-full min-w-0 px-2",children:(0,s.jsxs)("div",{className:"w-full py-1",children:[(0,s.jsx)(J,{children:"Spaces"}),"loading"===p&&0===c.length?(0,s.jsxs)("div",{className:"space-y-1 px-2",children:[(0,s.jsx)(_.E,{className:"h-7 w-full"}),(0,s.jsx)(_.E,{className:"h-7 w-full"}),(0,s.jsx)(_.E,{className:"h-7 w-full"})]}):0===c.length?(0,s.jsx)("p",{className:"px-2 py-2 text-xs text-muted-foreground",children:"No spaces yet"}):(0,s.jsx)("div",{className:"space-y-0.5",children:c.map(e=>(0,s.jsx)(q,{space:e,isExpanded:d.has(e.path),expandedFolders:u,pages:x.get(e.path)??[],pageLoadError:f.get(e.path)??null,isLoadingPages:(g.get(e.path)??"idle")==="loading"&&0===(x.get(e.path)??[]).length,pathname:a,touchFriendly:t,onToggle:()=>m(e.path),onToggleFolder:h,onRetryPages:()=>C(e.path,{force:!0}),onNavigate:A},e.path))}),b.length>0&&(0,s.jsxs)("div",{className:"mt-4",children:[(0,s.jsx)(J,{children:"Recent"}),(0,s.jsx)("div",{className:"space-y-0.5",children:b.slice(0,5).map(e=>(0,s.jsx)(H,{page:e,isActive:a===(0,W.C)(e.path),touchFriendly:t,onNavigate:()=>A(e.path)},e.path))})]}),"loading"===v&&0===b.length&&(0,s.jsxs)("div",{className:"mt-4 space-y-1 px-2",children:[(0,s.jsx)(J,{children:"Recent"}),(0,s.jsx)(_.E,{className:"h-6 w-full"}),(0,s.jsx)(_.E,{className:"h-6 w-5/6"})]})]})}),(0,s.jsx)(R.w,{className:"shrink-0"}),(0,s.jsxs)("div",{className:"shrink-0 space-y-0.5 px-2 py-2",children:[(0,s.jsx)(X,{}),(0,s.jsx)(V,{touchFriendly:t}),(0,s.jsx)(Z,{icon:(0,s.jsx)(N.A,{className:"h-4 w-4"}),label:"Settings",onClick:D,touchFriendly:t})]})]})}let q=(0,r.memo)(function({space:e,isExpanded:t,expandedFolders:n,pages:r,pageLoadError:a,isLoadingPages:l,pathname:i,touchFriendly:o,onToggle:d,onToggleFolder:u,onRetryPages:m,onNavigate:h}){let x=F(r,e.path),p=t=>t.map(t=>{if("page"===t.type)return(0,s.jsx)(B,{page:t.page,isActive:i===(0,W.C)(t.page.path),touchFriendly:o,onNavigate:()=>h(t.page.path)},t.page.path);let r=`${e.path}/${t.path}`,a=n.has(r);return(0,s.jsxs)("div",{children:[(0,s.jsxs)("button",{type:"button",onClick:()=>u(r),className:(0,c.cn)("relative z-[1] flex w-full min-w-0 cursor-pointer items-center gap-1.5 rounded-md px-2 text-[12px] transition-colors","text-muted-foreground hover:bg-sidebar-accent hover:text-sidebar-foreground",o?"py-2 min-h-[44px]":"py-1",a&&"text-foreground"),children:[(0,s.jsx)(k.A,{className:(0,c.cn)("h-3 w-3 shrink-0 transition-transform duration-200",a&&"rotate-90")}),(0,s.jsx)("span",{className:"shrink-0 text-xs",children:"\uD83D\uDCC2"}),(0,s.jsx)("span",{className:"flex-1 min-w-0 truncate text-left",children:t.name})]}),a&&(0,s.jsx)("div",{className:"ml-3 min-w-0 border-l border-border/50 pl-2 py-0.5",children:p(t.children)})]},r)});return(0,s.jsxs)("div",{children:[(0,s.jsxs)("button",{type:"button",onClick:d,className:(0,c.cn)("relative z-[1] flex w-full min-w-0 cursor-pointer items-center gap-1.5 rounded-md px-2 text-[13px] transition-colors","hover:bg-sidebar-accent",o?"py-2 min-h-[44px]":"py-1",t&&"font-medium"),children:[(0,s.jsx)(k.A,{className:(0,c.cn)("h-3 w-3 shrink-0 text-muted-foreground transition-transform duration-200",t&&"rotate-90")}),(0,s.jsx)("span",{className:"shrink-0 text-sm",children:e.icon??"\uD83D\uDCC1"}),(0,s.jsx)("span",{className:"flex-1 min-w-0 truncate text-left",children:e.name}),(0,s.jsx)(T.E,{variant:"secondary",className:"h-4 shrink-0 px-1 text-[10px] font-normal",children:e.pageCount})]}),t&&(0,s.jsx)("div",{className:"ml-3 min-w-0 border-l border-border/50 pl-2 py-0.5",children:l?(0,s.jsxs)("div",{className:"space-y-1 py-1",children:[(0,s.jsx)(_.E,{className:"h-6 w-full"}),(0,s.jsx)(_.E,{className:"h-6 w-3/4"})]}):a&&0===x.length?(0,s.jsxs)("div",{className:"px-2 py-1.5",children:[(0,s.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"Couldn't load pages."}),(0,s.jsx)("button",{type:"button",onClick:m,className:"mt-1 cursor-pointer text-[11px] text-primary hover:underline",children:"Retry"})]}):0===x.length?(0,s.jsx)("p",{className:"py-1.5 px-2 text-[11px] text-muted-foreground",children:"No pages yet. Create your first page."}):p(x)})]})}),B=(0,r.memo)(function({page:e,isActive:t,touchFriendly:n,onNavigate:r}){return(0,s.jsxs)("button",{type:"button",onClick:r,className:(0,c.cn)("relative z-[1] flex w-full min-w-0 cursor-pointer items-center gap-1.5 rounded-md px-2 text-[13px] transition-colors pointer-events-auto","text-muted-foreground hover:bg-sidebar-accent hover:text-sidebar-foreground",n?"py-2 min-h-[44px]":"py-1",t&&"bg-accent-light text-accent-blue font-medium"),children:[e.icon?(0,s.jsx)("span",{className:"shrink-0 text-xs",children:e.icon}):(0,s.jsx)(C.A,{className:"h-3.5 w-3.5 shrink-0"}),(0,s.jsx)("span",{className:"flex-1 min-w-0 truncate text-left",children:e.title})]})}),H=(0,r.memo)(function({page:e,isActive:t,touchFriendly:n,onNavigate:r}){return(0,s.jsxs)("button",{type:"button",onClick:r,className:(0,c.cn)("relative z-[1] flex w-full min-w-0 cursor-pointer items-center gap-2 rounded-md px-2 text-[13px] transition-colors overflow-hidden pointer-events-auto","text-muted-foreground hover:bg-sidebar-accent hover:text-sidebar-foreground",n?"py-2 min-h-[44px]":"py-1",t&&"bg-accent-light text-accent-blue font-medium"),children:[(0,s.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 overflow-hidden",children:[e.icon?(0,s.jsx)("span",{className:"shrink-0 text-xs",children:e.icon}):(0,s.jsx)(C.A,{className:"h-3.5 w-3.5 shrink-0"}),(0,s.jsx)("span",{className:"truncate text-left",children:e.title})]}),(0,s.jsx)("span",{className:"shrink-0 whitespace-nowrap tabular-nums text-[11px] font-medium text-muted-foreground/85",children:(0,P.f)(e.modified)})]})});function Z({icon:e,label:t,shortcut:n,onClick:r,touchFriendly:a}){return(0,s.jsxs)("button",{type:"button",onClick:r,className:(0,c.cn)("relative z-[1] flex w-full min-w-0 cursor-pointer items-center gap-2 rounded-md px-2 text-[13px] transition-colors duration-200 pointer-events-auto","text-muted-foreground hover:bg-sidebar-accent hover:text-sidebar-foreground",a?"py-2.5 min-h-[44px]":"py-1.5"),children:[(0,s.jsx)("span",{className:"shrink-0",children:e}),(0,s.jsx)("span",{className:"flex-1 min-w-0 truncate text-left",children:t}),n&&(0,s.jsx)("kbd",{className:"shrink-0 rounded border border-border/70 bg-muted/70 px-1.5 py-0.5 text-[11px] font-mono font-medium leading-none tracking-tight text-muted-foreground/85",children:n})]})}function J({children:e}){return(0,s.jsx)("h3",{className:"mb-1 px-2 text-[11px] font-medium uppercase tracking-wider text-muted-foreground",children:e})}function V({touchFriendly:e}){let{resolvedTheme:t,setTheme:n}=(0,L.D)(),r="dark"===t;return(0,s.jsx)(Z,{icon:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(S.A,{className:"hidden h-4 w-4 dark:inline"}),(0,s.jsx)(A.A,{className:"inline h-4 w-4 dark:hidden"})]}),label:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"hidden dark:inline",children:"Light Mode"}),(0,s.jsx)("span",{className:"inline dark:hidden",children:"Dark Mode"})]}),onClick:()=>n(r?"light":"dark"),touchFriendly:e})}function G(){let e=(0,K.z)(e=>e.wsStatus),t=(0,K.z)(e=>e.agentStatus),n=(0,K.z)(e=>e.agentName),r=(0,K.z)(e=>e.wsError),a="connected"===e?"thinking"===t||"active"===t?"bg-[color:var(--cp-brand-2)]":"bg-green-400":"connecting"===e||"reconnecting"===e?"bg-yellow-400":"bg-zinc-400",l="connected"===e?"thinking"===t?`${n??"Agent"}: thinking…`:"active"===t?`${n??"Agent"}: working…`:`${n??"Agent"}: online`:"connecting"===e?`Connecting to gateway…${r?` — ${r}`:""}`:"reconnecting"===e?`Reconnecting to gateway…${r?` — ${r}`:""}`:`Disconnected${r?` — ${r}`:""}`;return(0,s.jsxs)(u.m_,{children:[(0,s.jsx)(u.k$,{asChild:!0,children:(0,s.jsxs)("span",{className:"relative flex h-2.5 w-2.5",children:[("connecting"===e||"reconnecting"===e||"thinking"===t||"active"===t)&&(0,s.jsx)("span",{className:(0,c.cn)("absolute inline-flex h-full w-full animate-ping rounded-full opacity-75",a)}),(0,s.jsx)("span",{className:(0,c.cn)("relative inline-flex h-2.5 w-2.5 rounded-full ring-1 ring-[color:var(--cp-brand-border)]",a)})]})}),(0,s.jsx)(u.ZI,{children:l})]})}function X(){let e=(0,K.z)(e=>e.wsStatus),t=(0,K.z)(e=>e.agentStatus),n=(0,K.z)(e=>e.agentName),r=(0,K.z)(e=>e.wsError),a=(0,K.z)(e=>e.detect),l=(0,K.z)(e=>e.connect),i="connected"===e?"bg-green-400":"connecting"===e||"reconnecting"===e?"bg-yellow-400":"bg-red-400",o="connected"===e?"thinking"===t?`${n??"Agent"} thinking…`:"active"===t?`${n??"Agent"} working…`:`${n??"Agent"} online`:"connecting"===e?`Connecting…${r?` — ${r}`:""}`:"reconnecting"===e?`Reconnecting…${r?` — ${r}`:""}`:`Disconnected${r?` — ${r}`:""}`;return(0,s.jsxs)("div",{className:"flex items-center gap-2 rounded-md px-2 py-1.5 text-[13px]",children:[(0,s.jsxs)("span",{className:"relative flex h-2 w-2",children:[("connecting"===e||"reconnecting"===e)&&(0,s.jsx)("span",{className:(0,c.cn)("absolute inline-flex h-full w-full animate-ping rounded-full opacity-75",i)}),(0,s.jsx)("span",{className:(0,c.cn)("relative inline-flex h-2 w-2 rounded-full",i)})]}),(0,s.jsx)("span",{className:"flex-1 text-[11px] text-muted-foreground",children:o}),"disconnected"===e&&(0,s.jsx)("button",{onClick:()=>{a().then(()=>l())},className:"text-[10px] text-blue-500 hover:text-blue-400 transition-colors",children:"Retry"})]})}function Q(){let e=window.innerWidth;return e<640?"mobile-sm":e<768?"mobile":e<1024?"tablet":"desktop"}function Y(){let[e,t]=(0,r.useState)(()=>Q());return(0,r.useEffect)(()=>{let e=window.matchMedia(`(max-width: ${639}px)`),n=window.matchMedia(`(min-width: 640px) and (max-width: ${767}px)`),s=window.matchMedia(`(min-width: 768px) and (max-width: ${1023}px)`);function r(){t(Q())}return e.addEventListener("change",r),n.addEventListener("change",r),s.addEventListener("change",r),()=>{e.removeEventListener("change",r),n.removeEventListener("change",r),s.removeEventListener("change",r)}},[]),{breakpoint:e,isMobileSm:"mobile-sm"===e,isMobile:"mobile-sm"===e||"mobile"===e,isTablet:"tablet"===e,isDesktop:"desktop"===e}}function ee({className:e,...t}){return(0,s.jsx)("span",{className:(0,c.cn)("absolute h-px w-px overflow-hidden whitespace-nowrap border-0 p-0","[clip:rect(0,0,0,0)]",e),...t})}function et(){let{sidebarOpen:e,sidebarWidth:t,toggleSidebar:n,setSidebarOpen:m,setSidebarWidth:h}=(0,M.M)(),{isMobile:p,isTablet:g}=Y(),[v,w]=(0,r.useState)(t),[j,y]=(0,r.useState)(!1),N=(0,r.useRef)(null),k=(0,r.useRef)(0),C=(0,r.useRef)(240),S=(0,r.useRef)(240),A=(0,r.useCallback)(e=>Math.max(208,Math.min(e,Math.round(.35*window.innerWidth))),[]);(0,r.useEffect)(()=>{w(t)},[t]),(0,r.useEffect)(()=>{if(p||g)return;let e=()=>{let e=A(S.current);S.current=e,w(e),h(e)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[A,p,g,h]),(0,r.useEffect)(()=>{S.current=v,N.current&&(N.current.style.width=`${v}px`)},[v]),(0,r.useEffect)(()=>{if(!j)return;let e=e=>{let t=e.clientX-k.current,n=A(C.current+t);S.current=n,N.current&&(N.current.style.width=`${n}px`)},t=()=>{y(!1);let e=S.current;w(e),h(e)};return window.addEventListener("pointermove",e),window.addEventListener("pointerup",t),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{window.removeEventListener("pointermove",e),window.removeEventListener("pointerup",t),document.body.style.cursor="",document.body.style.userSelect=""}},[A,j,h]);let E=(0,r.useCallback)(t=>{p||g||!e||(t.preventDefault(),k.current=t.clientX,C.current=S.current,y(!0))},[p,g,e]),$=(0,r.useCallback)(()=>{m(!1)},[m]),z=(0,r.useCallback)(()=>{window.dispatchEvent(new CustomEvent("clawpad:open-command-palette"))},[]),R=(0,r.useCallback)(()=>{window.dispatchEvent(new CustomEvent("clawpad:open-new-page",{detail:{mode:"document"}}))},[]);return p?null:g?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex h-full w-12 flex-col items-center border-r bg-sidebar py-3 gap-2 shrink-0",children:[(0,s.jsxs)(u.m_,{children:[(0,s.jsx)(u.k$,{asChild:!0,children:(0,s.jsx)(d.$,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:n,children:(0,s.jsx)(a.A,{className:"h-4 w-4"})})}),(0,s.jsx)(u.ZI,{side:"right",children:"Open sidebar (⌘\\)"})]}),(0,s.jsxs)(u.m_,{children:[(0,s.jsx)(u.k$,{asChild:!0,children:(0,s.jsx)(d.$,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:z,children:(0,s.jsx)(l.A,{className:"h-4 w-4"})})}),(0,s.jsx)(u.ZI,{side:"right",children:"Search (⌘K)"})]}),(0,s.jsxs)(u.m_,{children:[(0,s.jsx)(u.k$,{asChild:!0,children:(0,s.jsx)(d.$,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:R,children:(0,s.jsx)(i.A,{className:"h-4 w-4"})})}),(0,s.jsx)(u.ZI,{side:"right",children:"New Document (⌘N)"})]})]}),(0,s.jsx)(x,{open:e,onOpenChange:m,children:(0,s.jsxs)(f,{side:"left",className:"w-72 p-0",showCloseButton:!1,children:[(0,s.jsx)(ee,{children:(0,s.jsx)(b,{children:"Navigation"})}),(0,s.jsx)(U,{onNavigate:$,isSheet:!0})]})})]}):e?(0,s.jsxs)("div",{ref:N,className:"relative flex h-full shrink-0 flex-col border-r bg-sidebar",style:{width:v,minWidth:208,maxWidth:"35vw"},children:[(0,s.jsxs)("div",{className:"flex h-12 shrink-0 items-center justify-between px-3",children:[(0,s.jsx)(O,{}),(0,s.jsxs)(u.m_,{children:[(0,s.jsx)(u.k$,{asChild:!0,children:(0,s.jsx)(d.$,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:n,children:(0,s.jsx)(o.A,{className:"h-4 w-4"})})}),(0,s.jsx)(u.ZI,{side:"right",children:"Close sidebar (⌘\\)"})]})]}),(0,s.jsx)("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden",children:(0,s.jsx)(U,{showHeader:!1})}),(0,s.jsx)("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize sidebar",onPointerDown:E,className:(0,c.cn)("absolute right-0 top-0 z-20 h-full w-2 cursor-col-resize","group"),children:(0,s.jsx)("div",{className:(0,c.cn)("absolute inset-y-0 right-0 w-px bg-border/70","transition-colors group-hover:bg-[color:var(--cp-brand-2)]",j&&"bg-[color:var(--cp-brand-2)]")})})]}):(0,s.jsxs)("div",{className:"flex h-full w-12 flex-col items-center border-r bg-sidebar py-3 gap-2 shrink-0",children:[(0,s.jsxs)(u.m_,{children:[(0,s.jsx)(u.k$,{asChild:!0,children:(0,s.jsx)(d.$,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:n,children:(0,s.jsx)(a.A,{className:"h-4 w-4"})})}),(0,s.jsx)(u.ZI,{side:"right",children:"Open sidebar (⌘\\)"})]}),(0,s.jsxs)(u.m_,{children:[(0,s.jsx)(u.k$,{asChild:!0,children:(0,s.jsx)(d.$,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:z,children:(0,s.jsx)(l.A,{className:"h-4 w-4"})})}),(0,s.jsx)(u.ZI,{side:"right",children:"Search (⌘K)"})]}),(0,s.jsxs)(u.m_,{children:[(0,s.jsx)(u.k$,{asChild:!0,children:(0,s.jsx)(d.$,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:R,children:(0,s.jsx)(i.A,{className:"h-4 w-4"})})}),(0,s.jsx)(u.ZI,{side:"right",children:"New Document (⌘N)"})]})]})}var en=n(21628),es=n(93631),er=n(84980),ea=n(2647),el=n(86901),ei=n(49387),eo=n(34530),ec=n(42129),ed=n(96035),eu=n(92972),em=n(5810),eh=n(53961),ex=n(2467),ep=n(34738);function eg({...e}){return(0,s.jsx)(h.Root,{"data-slot":"dialog",...e})}function ef({...e}){return(0,s.jsx)(h.Portal,{"data-slot":"dialog-portal",...e})}function eb({className:e,...t}){return(0,s.jsx)(h.Overlay,{"data-slot":"dialog-overlay",className:(0,c.cn)("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t})}function ev({className:e,children:t,showCloseButton:n=!0,...r}){return(0,s.jsxs)(ef,{"data-slot":"dialog-portal",children:[(0,s.jsx)(eb,{}),(0,s.jsxs)(h.Content,{"data-slot":"dialog-content",className:(0,c.cn)("bg-background 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 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 outline-none sm:max-w-lg",e),...r,children:[t,n&&(0,s.jsxs)(h.Close,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[(0,s.jsx)(m.A,{}),(0,s.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})}function ew({className:e,...t}){return(0,s.jsx)("div",{"data-slot":"dialog-header",className:(0,c.cn)("flex flex-col gap-2 text-center sm:text-left",e),...t})}function ej({className:e,showCloseButton:t=!1,children:n,...r}){return(0,s.jsxs)("div",{"data-slot":"dialog-footer",className:(0,c.cn)("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...r,children:[n,t&&(0,s.jsx)(h.Close,{asChild:!0,children:(0,s.jsx)(d.$,{variant:"outline",children:"Close"})})]})}function ey({className:e,...t}){return(0,s.jsx)(h.Title,{"data-slot":"dialog-title",className:(0,c.cn)("text-lg leading-none font-semibold",e),...t})}function eN({className:e,...t}){return(0,s.jsx)(h.Description,{"data-slot":"dialog-description",className:(0,c.cn)("text-muted-foreground text-sm",e),...t})}function ek({className:e,...t}){return(0,s.jsx)(ep.uB,{"data-slot":"command",className:(0,c.cn)("bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",e),...t})}function eC({title:e="Command Palette",description:t="Search for a command to run...",children:n,className:r,showCloseButton:a=!0,...l}){return(0,s.jsx)(eg,{...l,children:(0,s.jsxs)(ev,{className:(0,c.cn)("overflow-hidden p-0",r),showCloseButton:a,children:[(0,s.jsxs)(ew,{className:"sr-only",children:[(0,s.jsx)(ey,{children:e}),(0,s.jsx)(eN,{children:t})]}),(0,s.jsx)(ek,{className:"[&_[cmdk-group-heading]]:text-muted-foreground **:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:n})]})})}function eS({className:e,...t}){return(0,s.jsxs)("div",{"data-slot":"command-input-wrapper",className:"flex h-9 items-center gap-2 border-b px-3",children:[(0,s.jsx)(l.A,{className:"size-4 shrink-0 opacity-50"}),(0,s.jsx)(ep.uB.Input,{"data-slot":"command-input",className:(0,c.cn)("placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",e),...t})]})}function eA({className:e,...t}){return(0,s.jsx)(ep.uB.List,{"data-slot":"command-list",className:(0,c.cn)("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",e),...t})}function eE({...e}){return(0,s.jsx)(ep.uB.Empty,{"data-slot":"command-empty",className:"py-6 text-center text-sm",...e})}function e$({className:e,...t}){return(0,s.jsx)(ep.uB.Group,{"data-slot":"command-group",className:(0,c.cn)("text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",e),...t})}function ez({className:e,...t}){return(0,s.jsx)(ep.uB.Separator,{"data-slot":"command-separator",className:(0,c.cn)("bg-border -mx-1 h-px",e),...t})}function eR({className:e,...t}){return(0,s.jsx)(ep.uB.Item,{"data-slot":"command-item",className:(0,c.cn)("data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...t})}function eT({className:e,...t}){return(0,s.jsx)("span",{"data-slot":"command-shortcut",className:(0,c.cn)("text-muted-foreground ml-auto text-xs tracking-widest",e),...t})}function e_(){let[e,t]=(0,r.useState)(!1),[n,o]=(0,r.useState)(""),[c,d]=(0,r.useState)([]),[u,m]=(0,r.useState)([]),[h,x]=(0,r.useState)(!1),p=(0,j.useRouter)(),{resolvedTheme:g,setTheme:f}=(0,L.D)(),{recentPages:b,spaces:v,toggleChatPanel:w,toggleSidebar:k,createPage:E}=(0,M.M)(),$=(0,r.useRef)(null);(0,r.useEffect)(()=>{let e=e=>{"k"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),t(!0))},n=()=>t(!0);return document.addEventListener("keydown",e),window.addEventListener("clawpad:open-command-palette",n),()=>{document.removeEventListener("keydown",e),window.removeEventListener("clawpad:open-command-palette",n)}},[]),(0,r.useEffect)(()=>{e&&fetch("/api/files/recent?limit=8").then(e=>e.ok?e.json():[]).then(e=>m(e)).catch(()=>{})},[e]),(0,r.useEffect)(()=>{if(!n.trim()){d([]),x(!1);return}x(!0);let e=setTimeout(async()=>{$.current?.abort();let e=new AbortController;$.current=e;try{let t=await fetch(`/api/files/search?q=${encodeURIComponent(n)}&limit=10`,{signal:e.signal});if(t.ok){let e=await t.json();d(Array.isArray(e)?e:e.results??[])}}catch(e){e.name}finally{e.signal.aborted||x(!1)}},200);return()=>{clearTimeout(e)}},[n]);let z=(0,r.useCallback)(e=>{p.push((0,W.C)(e)),t(!1),o("")},[p]),R=(0,r.useCallback)(async e=>{try{let t=await E(I.Sz,e);z(t)}catch{}},[E,z]),_=(0,r.useCallback)(()=>{t(!1),window.dispatchEvent(new CustomEvent("clawpad:open-new-page",{detail:{mode:"space"}}))},[]),D=(0,r.useCallback)(()=>{t(!1),window.dispatchEvent(new CustomEvent("clawpad:open-new-page",{detail:{mode:"document"}}))},[]),K=(0,r.useCallback)(e=>{t(e),e||(o(""),d([]))},[]),P=u.length>0?u:b.slice(0,8),F=n.trim().length>0,O=c.length>0;return(0,s.jsxs)(eC,{open:e,onOpenChange:K,children:[(0,s.jsx)(eS,{placeholder:"Search pages or type a command…",value:n,onValueChange:o}),(0,s.jsxs)(eA,{children:[(0,s.jsx)(eE,{children:h?(0,s.jsxs)("div",{className:"flex items-center justify-center gap-2 py-2",children:[(0,s.jsx)("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent"}),(0,s.jsx)("span",{className:"text-sm text-muted-foreground",children:"Searching…"})]}):F?"No results found.":null}),O&&(0,s.jsxs)(e$,{heading:"Pages",children:[c.map(e=>(0,s.jsxs)(eR,{value:`search-${e.path}`,onSelect:()=>z(e.path),className:"flex flex-col items-start gap-1 py-3",children:[(0,s.jsxs)("div",{className:"flex w-full items-center gap-2",children:[(0,s.jsx)(C.A,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,s.jsxs)("span",{className:"truncate font-medium",children:[e.icon&&`${e.icon} `,e.title]}),(0,s.jsx)(T.E,{variant:"secondary",className:"ml-auto shrink-0 text-[10px] px-1.5 py-0",children:e.space}),e.modified&&(0,s.jsx)("span",{className:"shrink-0 text-[10px] text-muted-foreground tabular-nums",children:function(e){try{let t=new Date(e),n=new Date().getTime()-t.getTime(),s=Math.floor(n/6e4),r=Math.floor(n/36e5),a=Math.floor(n/864e5);if(s<1)return"just now";if(s<60)return`${s}m ago`;if(r<24)return`${r}h ago`;if(a<7)return`${a}d ago`;return t.toLocaleDateString(void 0,{month:"short",day:"numeric"})}catch{return""}}(e.modified)})]}),e.snippet&&(0,s.jsx)("p",{className:"ml-6 text-xs text-muted-foreground line-clamp-1 max-w-full",children:e.snippet.replace(/^---[\s\S]*?---\s*/m,"").replace(/^#+\s/gm,"").replace(/\n+/g," ").trim()})]},e.path)),(0,s.jsxs)(eR,{value:`view-all-search-${n}`,onSelect:()=>{p.push(`/workspace/search?q=${encodeURIComponent(n.trim())}`),t(!1),o("")},className:"justify-center text-muted-foreground",children:[(0,s.jsx)(l.A,{className:"mr-2 h-3.5 w-3.5"}),(0,s.jsx)("span",{className:"text-xs",children:"View all results"}),(0,s.jsx)(en.A,{className:"ml-1 h-3 w-3"})]})]}),F&&!O&&!h&&(0,s.jsx)(e$,{heading:"Create",children:(0,s.jsxs)(eR,{value:`create-${n}`,onSelect:()=>R(n.trim()),children:[(0,s.jsx)(es.A,{className:"mr-2 h-4 w-4 text-primary"}),(0,s.jsxs)("span",{children:["Create document: ",(0,s.jsx)("strong",{children:n.trim()})]})]})}),!F&&P.length>0&&(0,s.jsx)(e$,{heading:"Recent Pages",children:P.map(e=>(0,s.jsxs)(eR,{value:`recent-${e.path}`,onSelect:()=>z(e.path),children:[(0,s.jsx)(er.A,{className:"mr-2 h-4 w-4 shrink-0 text-muted-foreground"}),(0,s.jsxs)("div",{className:"flex flex-1 items-center gap-2 overflow-hidden",children:[e.icon&&(0,s.jsx)("span",{className:"shrink-0 text-sm",children:e.icon}),(0,s.jsx)("span",{className:"truncate",children:e.title}),(0,s.jsx)(T.E,{variant:"secondary",className:"ml-auto shrink-0 text-[10px] px-1.5 py-0",children:e.space===I.Sz?I.ke:e.space})]})]},e.path))}),(0,s.jsx)(ez,{}),(0,s.jsxs)(e$,{heading:"Create",children:[(0,s.jsxs)(eR,{value:"new-document",onSelect:D,children:[(0,s.jsx)(i.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"New Document"}),(0,s.jsx)(eT,{children:"⌘N"})]}),(0,s.jsxs)(eR,{value:"new-space",onSelect:_,children:[(0,s.jsx)(y.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"New Space"})]}),(0,s.jsxs)(eR,{value:"new-daily-note",onSelect:()=>{t(!1),R(new Date().toISOString().slice(0,10))},children:[(0,s.jsx)(ea.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"New Daily Note"})]})]}),(0,s.jsxs)(e$,{heading:"AI",children:[(0,s.jsxs)(eR,{value:"ask-agent",onSelect:()=>{let e=M.M.getState();e.chatPanelOpen||e.toggleChatPanel(),t(!1)},children:[(0,s.jsx)(el.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"Ask Agent"}),(0,s.jsx)(eT,{children:"⌘⇧L"})]}),(0,s.jsxs)(eR,{value:"summarize-page",onSelect:()=>{let e=M.M.getState();e.chatPanelOpen||e.toggleChatPanel(),t(!1),window.dispatchEvent(new CustomEvent("clawpad:ai-action",{detail:{action:"summarize"}}))},children:[(0,s.jsx)(C.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"Summarize Page"})]}),(0,s.jsxs)(eR,{value:"improve-writing",onSelect:()=>{let e=M.M.getState();e.chatPanelOpen||e.toggleChatPanel(),t(!1),window.dispatchEvent(new CustomEvent("clawpad:ai-action",{detail:{action:"improve"}}))},children:[(0,s.jsx)(ei.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"Improve Writing"})]})]}),(0,s.jsxs)(e$,{heading:"Navigation",children:[(0,s.jsxs)(eR,{value:"search-workspace",onSelect:()=>{let e=n.trim();p.push(e?`/workspace/search?q=${encodeURIComponent(e)}`:"/workspace/search"),t(!1),o("")},children:[(0,s.jsx)(l.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"Search Workspace"})]}),(0,s.jsxs)(eR,{value:"go-to-settings",onSelect:()=>{p.push("/settings"),t(!1)},children:[(0,s.jsx)(N.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"Go to Settings"})]}),(0,s.jsxs)(eR,{value:"go-to-setup",onSelect:()=>{p.push("/setup"),t(!1)},children:[(0,s.jsx)(eo.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"Go to Setup"})]}),v.map(e=>(0,s.jsxs)(eR,{value:`space-${e.path}`,onSelect:()=>{M.M.getState().toggleSpace(e.path),t(!1)},children:[(0,s.jsx)(ec.A,{className:"mr-2 h-4 w-4 text-muted-foreground"}),(0,s.jsxs)("span",{children:[e.icon&&`${e.icon} `,e.name]})]},e.path))]}),(0,s.jsxs)(e$,{heading:"Actions",children:[(0,s.jsxs)(eR,{value:"toggle-chat",onSelect:()=>{w(),t(!1)},children:[(0,s.jsx)(ed.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"Toggle Chat"}),(0,s.jsx)(eT,{children:"⌘⇧L"})]}),(0,s.jsxs)(eR,{value:"toggle-sidebar",onSelect:()=>{k(),t(!1)},children:[(0,s.jsx)(a.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"Toggle Sidebar"}),(0,s.jsx)(eT,{children:"⌘\\"})]}),(0,s.jsxs)(eR,{value:"toggle-dark-mode",onSelect:()=>{f("dark"===g?"light":"dark"),t(!1)},children:["dark"===g?(0,s.jsx)(S.A,{className:"mr-2 h-4 w-4"}):(0,s.jsx)(A.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"Toggle Dark Mode"}),(0,s.jsx)(eT,{children:"⌘⇧D"})]}),(0,s.jsxs)(eR,{value:"theme-light",onSelect:()=>{f("light"),t(!1)},children:[(0,s.jsx)(S.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"Theme: Light"})]}),(0,s.jsxs)(eR,{value:"theme-dark",onSelect:()=>{f("dark"),t(!1)},children:[(0,s.jsx)(A.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"Theme: Dark"})]}),(0,s.jsxs)(eR,{value:"theme-system",onSelect:()=>{f("system"),t(!1)},children:[(0,s.jsx)(eu.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"Theme: System"})]}),(0,s.jsxs)(eR,{value:"focus-editor",onSelect:()=>{let e=document.querySelector(".clawpad-editor [contenteditable]")??document.querySelector(".clawpad-editor");e?.focus(),t(!1)},children:[(0,s.jsx)(em.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"Focus Editor"}),(0,s.jsx)(eT,{children:"⌘⇧E"})]}),(0,s.jsxs)(eR,{value:"force-save",onSelect:()=>{window.dispatchEvent(new CustomEvent("clawpad:force-save")),t(!1)},children:[(0,s.jsx)(eh.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"Save"}),(0,s.jsx)(eT,{children:"⌘S"})]}),(0,s.jsxs)(eR,{value:"keyboard-shortcuts",onSelect:()=>{window.dispatchEvent(new CustomEvent("clawpad:shortcuts-dialog")),t(!1)},children:[(0,s.jsx)(ex.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"Keyboard Shortcuts"}),(0,s.jsx)(eT,{children:"⌘/"})]})]})]})]})}var eD=n(60529),eL=n(66609);let eM="clawpad-create-location-suggestions";function eK(){let[e,t]=(0,r.useState)(!1),[n,a]=(0,r.useState)("document"),[l,i]=(0,r.useState)(""),[o,c]=(0,r.useState)(""),[u,m]=(0,r.useState)(!1),h=(0,j.useRouter)(),{spaces:x,createPage:p,createSpace:g}=(0,M.M)(),f=(0,r.useMemo)(()=>new Set(x.map(e=>e.path)),[x]);(0,r.useEffect)(()=>{let e=e=>{let n=e?.detail;n?.mode==="space"||n?.mode==="folder"?a("space"):a("document"),"string"==typeof n?.title?i(n.title):i(""),"string"==typeof n?.location?c(n.location):"string"==typeof n?.space&&n.space.trim()?c(n.folderPath?`${n.space}/${n.folderPath}`.replace(/^\/+|\/+$/g,""):n.space):c(""),t(!0)};window.addEventListener("clawpad:open-new-page",e),window.addEventListener("clawpad:new-page",e);let n=e=>{"n"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),a("document"),i(""),c(""),t(!0))};return document.addEventListener("keydown",n),()=>{window.removeEventListener("clawpad:open-new-page",e),window.removeEventListener("clawpad:new-page",e),document.removeEventListener("keydown",n)}},[]),(0,r.useEffect)(()=>{if(!e||"document"!==n||o.trim())return;let t=x.find(e=>e.path!==I.Sz)?.path??x[0]?.path??"";t&&c(t)},[o,n,e,x]);let b=()=>{a("document"),i(""),c(""),m(!1)},v=(0,r.useCallback)(async()=>{let e=l.trim();if(e){m(!0);try{if("space"===n){await g(e),t(!1),b(),eL.oR.success("Space created"),h.push("/workspace");return}let s=function(e,t){let n=e.trim();if(!n)return null;let s=n.replace(/^\/+|\/+$/g,"");if(!s)return null;if(s===I.Sz||"root"===s.toLowerCase()||s.toLowerCase()===I.ke.toLowerCase())return{space:I.Sz};let r=s.split("/").filter(Boolean);if(0===r.length)return null;let[a,...l]=r;return t.has(a)?{space:a,folderPath:l.length>0?l.join("/"):void 0}:null}(o,f);if(!s)throw Error("Choose a valid location (space or space/folder path).");let r=await p(s.space,e,{folderPath:s.folderPath});t(!1),b(),h.push((0,W.C)(r)),eL.oR.success("Document created")}catch(t){let e=t instanceof Error?t.message:"space"===n?"Failed to create space.":"Failed to create document.";eL.oR.error(e)}finally{m(!1)}}},[p,g,f,o,n,h,l]),w=(0,r.useCallback)(e=>{"Enter"!==e.key||u||(e.preventDefault(),v())},[u,v]);return(0,s.jsx)(eg,{open:e,onOpenChange:e=>{t(e),e||b()},children:(0,s.jsxs)(ev,{className:"sm:max-w-[440px]",children:[(0,s.jsxs)(ew,{children:[(0,s.jsx)(ey,{children:"space"===n?"New Space":"New Document"}),(0,s.jsx)(eN,{children:"space"===n?"Create a top-level space in your workspace.":"Create a document in a space or nested folder path."})]}),(0,s.jsxs)("div",{className:"grid gap-4 py-4",children:[(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-2 rounded-lg border bg-muted/30 p-1",children:[(0,s.jsx)("button",{type:"button",onClick:()=>a("document"),className:`rounded-md px-2 py-1.5 text-xs ${"document"===n?"bg-background font-medium shadow-sm":"text-muted-foreground"}`,children:"Document"}),(0,s.jsx)("button",{type:"button",onClick:()=>a("space"),className:`rounded-md px-2 py-1.5 text-xs ${"space"===n?"bg-background font-medium shadow-sm":"text-muted-foreground"}`,children:"Space"})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("label",{htmlFor:"create-title",className:"text-sm font-medium leading-none",children:"space"===n?"Space Name":"Document Name"}),(0,s.jsx)(eD.p,{id:"create-title",placeholder:"space"===n?"e.g. client-work":"Document title…",value:l,onChange:e=>i(e.target.value),onKeyDown:w,autoFocus:!0})]}),"document"===n&&(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("label",{htmlFor:"create-location",className:"text-sm font-medium leading-none",children:"Location"}),(0,s.jsx)(eD.p,{id:"create-location",list:eM,placeholder:"space or space/folder/path",value:o,onChange:e=>c(e.target.value),onKeyDown:w}),(0,s.jsx)("datalist",{id:eM,children:x.map(e=>(0,s.jsx)("option",{value:e.path,children:e.name},e.path))}),(0,s.jsxs)("p",{className:"text-[11px] text-muted-foreground",children:["Example: ",(0,s.jsx)("code",{children:"projects/q1/roadmap"})]})]})]}),(0,s.jsxs)(ej,{children:[(0,s.jsx)(d.$,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),(0,s.jsx)(d.$,{onClick:()=>void v(),disabled:!l.trim()||u,children:u?"Creating…":"space"===n?"Create Space":"Create Document"})]})]})})}var eP=n(84577),eI=n(86726),eF=n(56558),eW=n(15411),eO=n(7915),eU=n(92018),eq=n(6296),eB=n(13545),eH=n(56842),eZ=n(99815),eJ=n(10762),eV=n(72055),eG=n(95672),eX=n(66088),eQ=n(94514),eY=n(38399),e0=n(41730),e1=n(92451),e5=n(17243),e2=n(74643),e4=n(69260),e3=n(6489),e6=n(65576),e9=n(32967),e8=n(13175),e7=n(76597),te=n(25262),tt=n(52159),tn=n(80642),ts=n(18310),tr=n(3163),ta=n(46794),tl=n(83099);let ti=/<\s*\/?\s*(?:think(?:ing)?|thought|antthinking|final)\b/i,to=/<\s*\/?\s*final\b[^<>]*>/gi,tc=/<\s*(\/?)\s*(?:think(?:ing)?|thought|antthinking)\b[^<>]*>/gi;function td(e){let t=[];for(let n of e.matchAll(/(^|\n)(```|~~~)[^\n]*\n[\s\S]*?(?:\n\2(?:\n|$)|$)/g)){let e=(n.index??0)+n[1].length;t.push({start:e,end:e+n[0].length-n[1].length})}for(let n of e.matchAll(/`+[^`]+`+/g)){let e=n.index??0,s=e+n[0].length;t.some(t=>e>=t.start&&s<=t.end)||t.push({start:e,end:s})}return t.sort((e,t)=>e.start-t.start),t}function tu(e,t){return t.some(t=>e>=t.start&&e<t.end)}var tm=n(9921);function th({status:e}){let t=(0,j.useRouter)(),n=(0,tl.W)(e=>e.activeRun),a=(0,tl.W)(e=>e.activeFiles),l=(0,tl.W)(e=>e.lastFileTouchAt),i=(0,tl.W)(e=>e.changeSets),o=(0,tl.W)(e=>e.openReview),d=(0,tl.W)(e=>e.closeReview),u=(0,K.z)(e=>e.agentStatus),m=i.find(e=>"completed"===e.status),[h,x]=(0,r.useState)(!1),p=a.size,g=!!m,f=e?"status":n&&p>0&&"number"==typeof l&&"idle"!==u?"editing":g?"summary":null,b="editing"===f?p:m?.totals.filesChanged??0,v=m?.totals.additions??0,w=m?.totals.deletions??0,y=0===b?"files":1===b?"1 file":`${b} files`,N="summary"===f&&!!m,k=N&&h;if(!f)return null;let C=e?.kind==="alert",S=e?.tone==="error",A=e?(0,c.cn)("flex w-full items-center gap-2 rounded-lg border px-3 py-1.5 text-xs transition-colors","thinking"===e.kind&&"border-[color:var(--cp-brand-border)] bg-[color:var(--cp-status-thinking-bg)] text-[color:var(--cp-status-thinking-text)]","writing"===e.kind&&"border-[color:var(--cp-brand-border)] bg-[color:var(--cp-status-thinking-bg)] text-[color:var(--cp-status-thinking-text)]","background"===e.kind&&"border-border/60 bg-[color:var(--cp-status-neutral-bg)] text-[color:var(--cp-status-neutral-text)]",C&&(S?"border-red-500/40 bg-[color:var(--cp-status-error-bg)] text-[color:var(--cp-status-error-text)]":"border-amber-500/40 bg-[color:var(--cp-status-alert-bg)] text-[color:var(--cp-status-alert-text)]")):"",E=e?(0,c.cn)("inline-flex h-2 w-2 rounded-full",("thinking"===e.kind||"background"===e.kind||"writing"===e.kind)&&"animate-pulse",("thinking"===e.kind||"writing"===e.kind)&&"bg-[color:var(--cp-status-thinking-text)]","background"===e.kind&&"bg-[color:var(--cp-status-neutral-text)]",C&&(S?"bg-[color:var(--cp-status-error-text)]":"bg-[color:var(--cp-status-alert-text)]")):"";return(0,s.jsxs)("div",{className:"mb-2",children:["status"===f&&e&&(0,s.jsxs)("div",{className:A,role:"status","aria-live":"polite",children:[(0,s.jsx)("span",{className:E}),(0,s.jsx)("span",{className:"text-[11px] font-medium",children:e.label}),e.detail&&(0,s.jsx)("span",{className:"max-w-[240px] truncate text-[10px] text-foreground/70",children:e.detail})]}),("editing"===f||"summary"===f)&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("button",{type:"button",onClick:()=>{N&&x(e=>!e)},className:(0,c.cn)("flex w-full items-center gap-2 border border-border/60 bg-muted/40 px-3 py-1.5 text-xs text-muted-foreground","rounded-lg",N&&"cursor-pointer hover:bg-muted/60"),children:[(0,s.jsx)("span",{className:"inline-flex h-2 w-2 rounded-full bg-[color:var(--cp-brand-2)] animate-pulse"}),(0,s.jsx)("span",{className:"flex-1 text-left",children:"editing"===f?(0,s.jsxs)(s.Fragment,{children:["Editing ",y,"…"]}):(0,s.jsxs)(s.Fragment,{children:[y," changed"," ",(0,s.jsxs)("span",{className:"text-emerald-600",children:["+",v]})," ",(0,s.jsxs)("span",{className:"text-rose-500",children:["-",w]})]})}),N&&(0,s.jsx)("span",{className:"text-muted-foreground/70",children:h?(0,s.jsx)(tm.A,{className:"h-3.5 w-3.5"}):(0,s.jsx)(eX.A,{className:"h-3.5 w-3.5"})})]}),k&&m&&(0,s.jsx)("div",{className:"rounded-b-lg border border-t-0 border-border/60 bg-background/95",children:(0,s.jsx)("div",{className:"divide-y divide-border/70",children:m.files.map(e=>(0,s.jsxs)("div",{className:"flex items-center gap-3 px-3 py-2 text-xs",children:[(0,s.jsx)("button",{type:"button",onClick:()=>{var n;return n=e.path,void(m&&(o(m.id,n),t.push((0,W.C)(n))))},className:"rounded-md border border-border/70 px-2 py-0.5 text-[10px] font-medium text-muted-foreground hover:text-foreground",children:"Diff"}),(0,s.jsx)("button",{type:"button",onClick:()=>{var n;return n=e.path,void(d(),t.push((0,W.C)(n)))},className:"flex-1 truncate text-left text-foreground/80 hover:text-foreground",children:e.path}),(0,s.jsxs)("span",{className:"shrink-0 font-mono text-[11px]",children:[(0,s.jsxs)("span",{className:"text-emerald-600",children:["+",e.additions]})," ",(0,s.jsxs)("span",{className:"text-rose-500",children:["-",e.deletions]})]})]},e.path))})})]})]})}let tx={telegram:{icon:"\uD83D\uDCF1",label:"Telegram",color:"bg-sky-100 text-sky-700 dark:bg-sky-900/40 dark:text-sky-300"},whatsapp:{icon:"\uD83D\uDCAC",label:"WhatsApp",color:"bg-emerald-100 text-emerald-700 dark:bg-emerald-900/40 dark:text-emerald-300"},discord:{icon:"\uD83C\uDFAE",label:"Discord",color:"bg-indigo-100 text-indigo-700 dark:bg-indigo-900/40 dark:text-indigo-300"},slack:{icon:"\uD83D\uDCBC",label:"Slack",color:"bg-purple-100 text-purple-700 dark:bg-purple-900/40 dark:text-purple-300"},webchat:{icon:"\uD83C\uDF10",label:"Web",color:"bg-zinc-100 text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400"},clawpad:{icon:"\uD83C\uDF10",label:"ClawPad",color:"bg-zinc-100 text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400"},system:{icon:"\uD83E\uDD16",label:"System",color:"bg-amber-100 text-amber-700 dark:bg-amber-900/40 dark:text-amber-300"}},tp=(0,r.memo)(function({channel:e,sessionKey:t,className:n}){let r=e?e.toLowerCase():t?(t.split(":")[2]??"unknown").toLowerCase():"unknown",a=tx[r];return a&&"webchat"!==r&&"clawpad"!==r?(0,s.jsxs)("span",{className:(0,c.cn)("inline-flex items-center gap-0.5 rounded-full px-1.5 py-0.5 text-[10px] font-medium leading-none",a.color,n),children:[(0,s.jsx)("span",{className:"text-[10px]",children:a.icon}),a.label]}):null}),tg=["image/png","image/jpeg","image/gif","image/webp"],tf=[],tb=null,tv="main";function tw(e){return(e.split("/").pop()??e).replace(/\.md$/,"").replace(/[-_]+/g," ").replace(/\b\w/g,e=>e.toUpperCase())}function tj(e){return{title:e.title?.trim()||tw(e.path),path:e.path,space:e.space,modified:e.modified,snippet:e.snippet}}async function ty(e){return new Promise((t,n)=>{let s=new FileReader;s.onload=()=>t(s.result),s.onerror=n,s.readAsDataURL(e)})}async function tN(e){let t=[];for(let n of e){if(!tg.includes(n.type))continue;if(n.size>5242880){console.warn(`[chat] Skipping ${n.name}: exceeds 5 MB`);continue}let e=await ty(n);t.push({id:crypto.randomUUID(),dataUrl:e,name:n.name})}return t}let tk=/^\[([^\]]+)\]\s*/,tC=["WebChat","WhatsApp","Telegram","Signal","Slack","Discord","Google Chat","iMessage","Teams","Matrix","Zalo","Zalo Personal","BlueBubbles"],tS=/^\s*\[message_id:\s*[^\]]+\]\s*$/i,tA=/^\s*\[message_id:\s*([^\]]+)\]\s*$/i;function tE(e){var t;let n=e.match(tk);return n?(t=n[1]??"",/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}Z\b/.test(t)||/\d{4}-\d{2}-\d{2} \d{2}:\d{2}\b/.test(t)||tC.some(e=>t.startsWith(`${e} `)))?tz(e.slice(n[0].length)):tz(e):tz(e)}function t$(e){return String(e.preview??e.reason??e.status??"Heartbeat").trim()}function tz(e){if(!e.includes("[message_id:"))return e;let t=e.split(/\r?\n/),n=t.filter(e=>!tS.test(e));return n.length===t.length?e:n.join("\n")}function tR(e){return function(e,t){var n;if(!e||!ti.test(e))return e;let s=t?.mode??"strict",r=t?.trim??"both",a=e;if(to.test(a)){to.lastIndex=0;let e=[],t=td(a);for(let n of a.matchAll(to)){let s=n.index??0;e.push({start:s,length:n[0].length,inCode:tu(s,t)})}for(let t=e.length-1;t>=0;t-=1){let n=e[t];n.inCode||(a=a.slice(0,n.start)+a.slice(n.start+n.length))}}else to.lastIndex=0;let l=td(a);tc.lastIndex=0;let i="",o=0,c=!1;for(let e of a.matchAll(tc)){let t=e.index??0,n="/"===e[1];tu(t,l)||(c?n&&(c=!1):(i+=a.slice(o,t),n||(c=!0)),o=t+e[0].length)}return c&&"preserve"!==s||(i+=a.slice(o)),n=i,"none"===r?n:"start"===r?n.trimStart():n.trim()}(e,{mode:"preserve",trim:"start"})}function tT(e){return e.replace(/^\s*\[Context\][\s\S]*?\[\/Context\]\s*/i,"")}function t_(e){return String(e??"").replace(/\s+/g," ").trim()}function tD(e){let t=e.role??"",n=e.content;if("string"==typeof n){let e="assistant"===t?tR(n):tE(n);return"user"===t||"User"===t?tT(e):e}if(Array.isArray(n)){let e=n.filter(e=>"text"===e.type&&"string"==typeof e.text).map(e=>e.text);if(e.length>0){let n=e.join("\n"),s="assistant"===t?tR(n):tE(n);return"user"===t||"User"===t?tT(s):s}}if("string"==typeof e.text){let n=e.text,s="assistant"===t?tR(n):tE(n);return"user"===t||"User"===t?tT(s):s}return null}function tL(e){let t=e.role??"",n=e.content;if("string"==typeof n)return"user"===t||"User"===t?tT(n):n;if(Array.isArray(n)){let e=n.filter(e=>"text"===e.type&&"string"==typeof e.text).map(e=>e.text);if(e.length>0){let n=e.join("\n");return"user"===t||"User"===t?tT(n):n}}if("string"==typeof e.text){let n=e.text;return"user"===t||"User"===t?tT(n):n}return null}function tM(e){var t;let n;if(null==e)return;if("number"==typeof e||"boolean"==typeof e)return String(e);if("string"==typeof e)n=e;else if("object"==typeof e)if("string"==typeof e.text)n=e.text;else if(Array.isArray(e.content)){let t=e.content.map(e=>e&&"object"==typeof e&&"text"===e.type&&"string"==typeof e.text?e.text:null).filter(e=>!!e);n=t.length>0?t.join("\n"):""}else try{n=JSON.stringify(e,null,2)}catch{n=String(e)}else n=String(e);if(!n)return;let s=(t=tK(n)??n).length<=12e4?{text:t,truncated:!1,total:t.length}:{text:t.slice(0,12e4),truncated:!0,total:t.length};return s.truncated?`${s.text}
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1807],{3163:(e,t,n)=>{"use strict";n.d(t,{e:()=>a});var s=n(1934);let r=0,a=(0,s.v)(e=>({items:[],addItem:t=>e(e=>({items:[{...t,id:`activity-${Date.now()}-${++r}`},...e.items].slice(0,20)})),clear:()=>e({items:[]})}))},7814:(e,t,n)=>{"use strict";function s(e){let t=e.replace(/\.md$/,"").split("/").filter(Boolean).map(e=>encodeURIComponent(e));return 0===t.length?"/workspace":`/workspace/${t.join("/")}`}n.d(t,{C:()=>s})},24733:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>nA});var s=n(95155),r=n(12115),a=n(12710),l=n(61878),i=n(51914),o=n(6071),c=n(52799),d=n(89239),u=n(70872),m=n(33210),h=n(19324);function x({...e}){return(0,s.jsx)(h.Root,{"data-slot":"sheet",...e})}function p({...e}){return(0,s.jsx)(h.Portal,{"data-slot":"sheet-portal",...e})}function g({className:e,...t}){return(0,s.jsx)(h.Overlay,{"data-slot":"sheet-overlay",className:(0,c.cn)("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t})}function f({className:e,children:t,side:n="right",showCloseButton:r=!0,...a}){return(0,s.jsxs)(p,{children:[(0,s.jsx)(g,{}),(0,s.jsxs)(h.Content,{"data-slot":"sheet-content",className:(0,c.cn)("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed z-50 flex flex-col gap-4 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500","right"===n&&"data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm","left"===n&&"data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm","top"===n&&"data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b","bottom"===n&&"data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t",e),...a,children:[t,r&&(0,s.jsxs)(h.Close,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none",children:[(0,s.jsx)(m.A,{className:"size-4"}),(0,s.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})}function b({className:e,...t}){return(0,s.jsx)(h.Title,{"data-slot":"sheet-title",className:(0,c.cn)("text-foreground font-semibold",e),...t})}var v=n(98500),w=n.n(v),j=n(73321),y=n(63393),N=n(89363),k=n(21362),C=n(48368),S=n(51900),A=n(36999),E=n(35585);function $({className:e,children:t,...n}){return(0,s.jsxs)(E.Root,{"data-slot":"scroll-area",className:(0,c.cn)("relative",e),...n,children:[(0,s.jsx)(E.Viewport,{"data-slot":"scroll-area-viewport",className:"focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1 [&>div]:!block [&>div]:!min-w-0",children:t}),(0,s.jsx)(z,{}),(0,s.jsx)(E.Corner,{})]})}function z({className:e,orientation:t="vertical",...n}){return(0,s.jsx)(E.ScrollAreaScrollbar,{"data-slot":"scroll-area-scrollbar",orientation:t,className:(0,c.cn)("flex touch-none p-px transition-colors select-none","vertical"===t&&"h-full w-2.5 border-l border-l-transparent","horizontal"===t&&"h-2.5 flex-col border-t border-t-transparent",e),...n,children:(0,s.jsx)(E.ScrollAreaThumb,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}var R=n(97916),T=n(45160),_=n(86846),D=n(93571),L=n(70460),M=n(18496),K=n(31328),P=n(53536),I=n(60464);function F(e,t){let n={type:"folder",name:"",path:"",children:[]},s=new Map;for(let r of(s.set("",n),e)){let e=function(e,t){let n=e.replace(/\\/g,"/").replace(/\.md$/,"");if(t===I.Sz)return n;let s=`${t}/`;return n.startsWith(s)?n.slice(s.length):n}(r.path,t),a=e.split("/").filter(Boolean);if(0===a.length)continue;let l=a.pop(),i=n,o="";for(let e of a){let t=o?`${o}/${e}`:e,n=s.get(t);n||(n={type:"folder",name:e,path:t,children:[]},s.set(t,n),i.children.push(n)),i=n,o=t}i.children.push({type:"page",name:l,path:e,page:r})}return n.children}var W=n(7814);function O({onNavigate:e}){return(0,s.jsxs)(w(),{href:"/workspace",onClick:()=>e?.(),className:"flex items-center gap-2 text-[13px] font-semibold leading-none transition-colors hover:text-foreground/80",children:[(0,s.jsx)(D.R,{variant:"wordmark",size:26,theme:"light",alt:"ClawPad",className:"-translate-y-[2px]"}),(0,s.jsx)(G,{})]})}function U({onNavigate:e,isSheet:t,showHeader:n=!0}){let a=(0,j.usePathname)(),o=(0,j.useRouter)(),{spaces:c,expandedSpaces:d,expandedFolders:u,toggleSpace:m,toggleFolder:h,pagesBySpace:x,spacesStatus:p,pagesStatusBySpace:g,pagesErrorBySpace:f,recentPages:b,recentStatus:v,loadSpaces:w,loadRecentPages:k,loadPages:C,setActivePage:S}=(0,M.M)();(0,r.useEffect)(()=>{w(),k()},[w,k]),(0,r.useEffect)(()=>{for(let e of c){if(!d.has(e.path)||e.pageCount<=0)continue;let t=x.get(e.path);t&&!(t.length>0)&&"loading"!==(g.get(e.path)??"idle")&&C(e.path,{force:!0,silent:!0})}},[d,C,x,g,c]),(0,r.useEffect)(()=>{a.startsWith("/workspace/")?S(a.replace("/workspace/","")):S(null)},[a,S]);let A=(0,r.useCallback)(t=>{o.push((0,W.C)(t)),e?.()},[o,e]),E=(0,r.useCallback)(()=>{window.dispatchEvent(new CustomEvent("clawpad:open-new-page",{detail:{mode:"document"}})),e?.()},[e]),z=(0,r.useCallback)(()=>{window.dispatchEvent(new CustomEvent("clawpad:open-new-page",{detail:{mode:"space"}})),e?.()},[e]),T=(0,r.useCallback)(()=>{window.dispatchEvent(new CustomEvent("clawpad:open-command-palette")),e?.()},[e]),D=(0,r.useCallback)(()=>{o.push("/settings"),e?.()},[e,o]);return(0,s.jsxs)("div",{className:"flex h-full w-full flex-col overflow-hidden",children:[n&&(0,s.jsx)("div",{className:"flex h-12 shrink-0 items-center justify-between px-3",children:(0,s.jsx)(O,{onNavigate:e})}),(0,s.jsxs)("div",{className:"shrink-0 space-y-0.5 px-2",children:[(0,s.jsx)(Z,{icon:(0,s.jsx)(l.A,{className:"h-4 w-4"}),label:"Search",shortcut:"⌘K",onClick:T,touchFriendly:t}),(0,s.jsx)(Z,{icon:(0,s.jsx)(i.A,{className:"h-4 w-4"}),label:"New Document",shortcut:"⌘N",onClick:E,touchFriendly:t}),(0,s.jsx)(Z,{icon:(0,s.jsx)(y.A,{className:"h-4 w-4"}),label:"New Space",onClick:z,touchFriendly:t})]}),(0,s.jsx)(R.w,{className:"my-2 shrink-0"}),(0,s.jsx)($,{className:"min-h-0 flex-1 w-full min-w-0 px-2",children:(0,s.jsxs)("div",{className:"w-full py-1",children:[(0,s.jsx)(J,{children:"Spaces"}),"loading"===p&&0===c.length?(0,s.jsxs)("div",{className:"space-y-1 px-2",children:[(0,s.jsx)(_.E,{className:"h-7 w-full"}),(0,s.jsx)(_.E,{className:"h-7 w-full"}),(0,s.jsx)(_.E,{className:"h-7 w-full"})]}):0===c.length?(0,s.jsx)("p",{className:"px-2 py-2 text-xs text-muted-foreground",children:"No spaces yet"}):(0,s.jsx)("div",{className:"space-y-0.5",children:c.map(e=>(0,s.jsx)(q,{space:e,isExpanded:d.has(e.path),expandedFolders:u,pages:x.get(e.path)??[],pageLoadError:f.get(e.path)??null,isLoadingPages:(g.get(e.path)??"idle")==="loading"&&0===(x.get(e.path)??[]).length,pathname:a,touchFriendly:t,onToggle:()=>m(e.path),onToggleFolder:h,onRetryPages:()=>C(e.path,{force:!0}),onNavigate:A},e.path))}),b.length>0&&(0,s.jsxs)("div",{className:"mt-4",children:[(0,s.jsx)(J,{children:"Recent"}),(0,s.jsx)("div",{className:"space-y-0.5",children:b.slice(0,5).map(e=>(0,s.jsx)(H,{page:e,isActive:a===(0,W.C)(e.path),touchFriendly:t,onNavigate:()=>A(e.path)},e.path))})]}),"loading"===v&&0===b.length&&(0,s.jsxs)("div",{className:"mt-4 space-y-1 px-2",children:[(0,s.jsx)(J,{children:"Recent"}),(0,s.jsx)(_.E,{className:"h-6 w-full"}),(0,s.jsx)(_.E,{className:"h-6 w-5/6"})]})]})}),(0,s.jsx)(R.w,{className:"shrink-0"}),(0,s.jsxs)("div",{className:"shrink-0 space-y-0.5 px-2 py-2",children:[(0,s.jsx)(X,{}),(0,s.jsx)(V,{touchFriendly:t}),(0,s.jsx)(Z,{icon:(0,s.jsx)(N.A,{className:"h-4 w-4"}),label:"Settings",onClick:D,touchFriendly:t})]})]})}let q=(0,r.memo)(function({space:e,isExpanded:t,expandedFolders:n,pages:r,pageLoadError:a,isLoadingPages:l,pathname:i,touchFriendly:o,onToggle:d,onToggleFolder:u,onRetryPages:m,onNavigate:h}){let x=F(r,e.path),p=t=>t.map(t=>{if("page"===t.type)return(0,s.jsx)(B,{page:t.page,isActive:i===(0,W.C)(t.page.path),touchFriendly:o,onNavigate:()=>h(t.page.path)},t.page.path);let r=`${e.path}/${t.path}`,a=n.has(r);return(0,s.jsxs)("div",{children:[(0,s.jsxs)("button",{type:"button",onClick:()=>u(r),className:(0,c.cn)("relative z-[1] flex w-full min-w-0 cursor-pointer items-center gap-1.5 rounded-md px-2 text-[12px] transition-colors","text-muted-foreground hover:bg-sidebar-accent hover:text-sidebar-foreground",o?"py-2 min-h-[44px]":"py-1",a&&"text-foreground"),children:[(0,s.jsx)(k.A,{className:(0,c.cn)("h-3 w-3 shrink-0 transition-transform duration-200",a&&"rotate-90")}),(0,s.jsx)("span",{className:"shrink-0 text-xs",children:"\uD83D\uDCC2"}),(0,s.jsx)("span",{className:"flex-1 min-w-0 truncate text-left",children:t.name})]}),a&&(0,s.jsx)("div",{className:"ml-3 min-w-0 border-l border-border/50 pl-2 py-0.5",children:p(t.children)})]},r)});return(0,s.jsxs)("div",{children:[(0,s.jsxs)("button",{type:"button",onClick:d,className:(0,c.cn)("relative z-[1] flex w-full min-w-0 cursor-pointer items-center gap-1.5 rounded-md px-2 text-[13px] transition-colors","hover:bg-sidebar-accent",o?"py-2 min-h-[44px]":"py-1",t&&"font-medium"),children:[(0,s.jsx)(k.A,{className:(0,c.cn)("h-3 w-3 shrink-0 text-muted-foreground transition-transform duration-200",t&&"rotate-90")}),(0,s.jsx)("span",{className:"shrink-0 text-sm",children:e.icon??"\uD83D\uDCC1"}),(0,s.jsx)("span",{className:"flex-1 min-w-0 truncate text-left",children:e.name}),(0,s.jsx)(T.E,{variant:"secondary",className:"h-4 shrink-0 px-1 text-[10px] font-normal",children:e.pageCount})]}),t&&(0,s.jsx)("div",{className:"ml-3 min-w-0 border-l border-border/50 pl-2 py-0.5",children:l?(0,s.jsxs)("div",{className:"space-y-1 py-1",children:[(0,s.jsx)(_.E,{className:"h-6 w-full"}),(0,s.jsx)(_.E,{className:"h-6 w-3/4"})]}):a&&0===x.length?(0,s.jsxs)("div",{className:"px-2 py-1.5",children:[(0,s.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"Couldn't load pages."}),(0,s.jsx)("button",{type:"button",onClick:m,className:"mt-1 cursor-pointer text-[11px] text-primary hover:underline",children:"Retry"})]}):0===x.length?(0,s.jsx)("p",{className:"py-1.5 px-2 text-[11px] text-muted-foreground",children:"No pages yet. Create your first page."}):p(x)})]})}),B=(0,r.memo)(function({page:e,isActive:t,touchFriendly:n,onNavigate:r}){return(0,s.jsxs)("button",{type:"button",onClick:r,className:(0,c.cn)("relative z-[1] flex w-full min-w-0 cursor-pointer items-center gap-1.5 rounded-md px-2 text-[13px] transition-colors pointer-events-auto","text-muted-foreground hover:bg-sidebar-accent hover:text-sidebar-foreground",n?"py-2 min-h-[44px]":"py-1",t&&"bg-accent-light text-accent-blue font-medium"),children:[e.icon?(0,s.jsx)("span",{className:"shrink-0 text-xs",children:e.icon}):(0,s.jsx)(C.A,{className:"h-3.5 w-3.5 shrink-0"}),(0,s.jsx)("span",{className:"flex-1 min-w-0 truncate text-left",children:e.title})]})}),H=(0,r.memo)(function({page:e,isActive:t,touchFriendly:n,onNavigate:r}){return(0,s.jsxs)("button",{type:"button",onClick:r,className:(0,c.cn)("relative z-[1] flex w-full min-w-0 cursor-pointer items-center gap-2 rounded-md px-2 text-[13px] transition-colors overflow-hidden pointer-events-auto","text-muted-foreground hover:bg-sidebar-accent hover:text-sidebar-foreground",n?"py-2 min-h-[44px]":"py-1",t&&"bg-accent-light text-accent-blue font-medium"),children:[(0,s.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 overflow-hidden",children:[e.icon?(0,s.jsx)("span",{className:"shrink-0 text-xs",children:e.icon}):(0,s.jsx)(C.A,{className:"h-3.5 w-3.5 shrink-0"}),(0,s.jsx)("span",{className:"truncate text-left",children:e.title})]}),(0,s.jsx)("span",{className:"shrink-0 whitespace-nowrap tabular-nums text-[11px] font-medium text-muted-foreground/85",children:(0,P.f)(e.modified)})]})});function Z({icon:e,label:t,shortcut:n,onClick:r,touchFriendly:a}){return(0,s.jsxs)("button",{type:"button",onClick:r,className:(0,c.cn)("relative z-[1] flex w-full min-w-0 cursor-pointer items-center gap-2 rounded-md px-2 text-[13px] transition-colors duration-200 pointer-events-auto","text-muted-foreground hover:bg-sidebar-accent hover:text-sidebar-foreground",a?"py-2.5 min-h-[44px]":"py-1.5"),children:[(0,s.jsx)("span",{className:"shrink-0",children:e}),(0,s.jsx)("span",{className:"flex-1 min-w-0 truncate text-left",children:t}),n&&(0,s.jsx)("kbd",{className:"shrink-0 rounded border border-border/70 bg-muted/70 px-1.5 py-0.5 text-[11px] font-mono font-medium leading-none tracking-tight text-muted-foreground/85",children:n})]})}function J({children:e}){return(0,s.jsx)("h3",{className:"mb-1 px-2 text-[11px] font-medium uppercase tracking-wider text-muted-foreground",children:e})}function V({touchFriendly:e}){let{resolvedTheme:t,setTheme:n}=(0,L.D)(),r="dark"===t;return(0,s.jsx)(Z,{icon:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(S.A,{className:"hidden h-4 w-4 dark:inline"}),(0,s.jsx)(A.A,{className:"inline h-4 w-4 dark:hidden"})]}),label:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"hidden dark:inline",children:"Light Mode"}),(0,s.jsx)("span",{className:"inline dark:hidden",children:"Dark Mode"})]}),onClick:()=>n(r?"light":"dark"),touchFriendly:e})}function G(){let e=(0,K.z)(e=>e.wsStatus),t=(0,K.z)(e=>e.agentStatus),n=(0,K.z)(e=>e.agentName),r=(0,K.z)(e=>e.wsError),a="connected"===e?"thinking"===t||"active"===t?"bg-[color:var(--cp-brand-2)]":"bg-green-400":"connecting"===e||"reconnecting"===e?"bg-yellow-400":"bg-zinc-400",l="connected"===e?"thinking"===t?`${n??"Agent"}: thinking…`:"active"===t?`${n??"Agent"}: working…`:`${n??"Agent"}: online`:"connecting"===e?`Connecting to gateway…${r?` — ${r}`:""}`:"reconnecting"===e?`Reconnecting to gateway…${r?` — ${r}`:""}`:`Disconnected${r?` — ${r}`:""}`;return(0,s.jsxs)(u.m_,{children:[(0,s.jsx)(u.k$,{asChild:!0,children:(0,s.jsxs)("span",{className:"relative flex h-2.5 w-2.5",children:[("connecting"===e||"reconnecting"===e||"thinking"===t||"active"===t)&&(0,s.jsx)("span",{className:(0,c.cn)("absolute inline-flex h-full w-full animate-ping rounded-full opacity-75",a)}),(0,s.jsx)("span",{className:(0,c.cn)("relative inline-flex h-2.5 w-2.5 rounded-full ring-1 ring-[color:var(--cp-brand-border)]",a)})]})}),(0,s.jsx)(u.ZI,{children:l})]})}function X(){let e=(0,K.z)(e=>e.wsStatus),t=(0,K.z)(e=>e.agentStatus),n=(0,K.z)(e=>e.agentName),r=(0,K.z)(e=>e.wsError),a=(0,K.z)(e=>e.detect),l=(0,K.z)(e=>e.connect),i="connected"===e?"bg-green-400":"connecting"===e||"reconnecting"===e?"bg-yellow-400":"bg-red-400",o="connected"===e?"thinking"===t?`${n??"Agent"} thinking…`:"active"===t?`${n??"Agent"} working…`:`${n??"Agent"} online`:"connecting"===e?`Connecting…${r?` — ${r}`:""}`:"reconnecting"===e?`Reconnecting…${r?` — ${r}`:""}`:`Disconnected${r?` — ${r}`:""}`;return(0,s.jsxs)("div",{className:"flex items-center gap-2 rounded-md px-2 py-1.5 text-[13px]",children:[(0,s.jsxs)("span",{className:"relative flex h-2 w-2",children:[("connecting"===e||"reconnecting"===e)&&(0,s.jsx)("span",{className:(0,c.cn)("absolute inline-flex h-full w-full animate-ping rounded-full opacity-75",i)}),(0,s.jsx)("span",{className:(0,c.cn)("relative inline-flex h-2 w-2 rounded-full",i)})]}),(0,s.jsx)("span",{className:"flex-1 text-[11px] text-muted-foreground",children:o}),"disconnected"===e&&(0,s.jsx)("button",{onClick:()=>{a().then(()=>l())},className:"text-[10px] text-blue-500 hover:text-blue-400 transition-colors",children:"Retry"})]})}function Q(){let e=window.innerWidth;return e<640?"mobile-sm":e<768?"mobile":e<1024?"tablet":"desktop"}function Y(){let[e,t]=(0,r.useState)(()=>Q());return(0,r.useEffect)(()=>{let e=window.matchMedia(`(max-width: ${639}px)`),n=window.matchMedia(`(min-width: 640px) and (max-width: ${767}px)`),s=window.matchMedia(`(min-width: 768px) and (max-width: ${1023}px)`);function r(){t(Q())}return e.addEventListener("change",r),n.addEventListener("change",r),s.addEventListener("change",r),()=>{e.removeEventListener("change",r),n.removeEventListener("change",r),s.removeEventListener("change",r)}},[]),{breakpoint:e,isMobileSm:"mobile-sm"===e,isMobile:"mobile-sm"===e||"mobile"===e,isTablet:"tablet"===e,isDesktop:"desktop"===e}}function ee({className:e,...t}){return(0,s.jsx)("span",{className:(0,c.cn)("absolute h-px w-px overflow-hidden whitespace-nowrap border-0 p-0","[clip:rect(0,0,0,0)]",e),...t})}function et(){let{sidebarOpen:e,sidebarWidth:t,toggleSidebar:n,setSidebarOpen:m,setSidebarWidth:h}=(0,M.M)(),{isMobile:p,isTablet:g}=Y(),[v,w]=(0,r.useState)(t),[j,y]=(0,r.useState)(!1),N=(0,r.useRef)(null),k=(0,r.useRef)(0),C=(0,r.useRef)(240),S=(0,r.useRef)(240),A=(0,r.useCallback)(e=>Math.max(208,Math.min(e,Math.round(.35*window.innerWidth))),[]);(0,r.useEffect)(()=>{w(t)},[t]),(0,r.useEffect)(()=>{if(p||g)return;let e=()=>{let e=A(S.current);S.current=e,w(e),h(e)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[A,p,g,h]),(0,r.useEffect)(()=>{S.current=v,N.current&&(N.current.style.width=`${v}px`)},[v]),(0,r.useEffect)(()=>{if(!j)return;let e=e=>{let t=e.clientX-k.current,n=A(C.current+t);S.current=n,N.current&&(N.current.style.width=`${n}px`)},t=()=>{y(!1);let e=S.current;w(e),h(e)};return window.addEventListener("pointermove",e),window.addEventListener("pointerup",t),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{window.removeEventListener("pointermove",e),window.removeEventListener("pointerup",t),document.body.style.cursor="",document.body.style.userSelect=""}},[A,j,h]);let E=(0,r.useCallback)(t=>{p||g||!e||(t.preventDefault(),k.current=t.clientX,C.current=S.current,y(!0))},[p,g,e]),$=(0,r.useCallback)(()=>{m(!1)},[m]),z=(0,r.useCallback)(()=>{window.dispatchEvent(new CustomEvent("clawpad:open-command-palette"))},[]),R=(0,r.useCallback)(()=>{window.dispatchEvent(new CustomEvent("clawpad:open-new-page",{detail:{mode:"document"}}))},[]);return p?null:g?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex h-full w-12 flex-col items-center border-r bg-sidebar py-3 gap-2 shrink-0",children:[(0,s.jsxs)(u.m_,{children:[(0,s.jsx)(u.k$,{asChild:!0,children:(0,s.jsx)(d.$,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:n,children:(0,s.jsx)(a.A,{className:"h-4 w-4"})})}),(0,s.jsx)(u.ZI,{side:"right",children:"Open sidebar (⌘\\)"})]}),(0,s.jsxs)(u.m_,{children:[(0,s.jsx)(u.k$,{asChild:!0,children:(0,s.jsx)(d.$,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:z,children:(0,s.jsx)(l.A,{className:"h-4 w-4"})})}),(0,s.jsx)(u.ZI,{side:"right",children:"Search (⌘K)"})]}),(0,s.jsxs)(u.m_,{children:[(0,s.jsx)(u.k$,{asChild:!0,children:(0,s.jsx)(d.$,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:R,children:(0,s.jsx)(i.A,{className:"h-4 w-4"})})}),(0,s.jsx)(u.ZI,{side:"right",children:"New Document (⌘N)"})]})]}),(0,s.jsx)(x,{open:e,onOpenChange:m,children:(0,s.jsxs)(f,{side:"left",className:"w-72 p-0",showCloseButton:!1,children:[(0,s.jsx)(ee,{children:(0,s.jsx)(b,{children:"Navigation"})}),(0,s.jsx)(U,{onNavigate:$,isSheet:!0})]})})]}):e?(0,s.jsxs)("div",{ref:N,className:"relative flex h-full shrink-0 flex-col border-r bg-sidebar",style:{width:v,minWidth:208,maxWidth:"35vw"},children:[(0,s.jsxs)("div",{className:"flex h-12 shrink-0 items-center justify-between px-3",children:[(0,s.jsx)(O,{}),(0,s.jsxs)(u.m_,{children:[(0,s.jsx)(u.k$,{asChild:!0,children:(0,s.jsx)(d.$,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:n,children:(0,s.jsx)(o.A,{className:"h-4 w-4"})})}),(0,s.jsx)(u.ZI,{side:"right",children:"Close sidebar (⌘\\)"})]})]}),(0,s.jsx)("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden",children:(0,s.jsx)(U,{showHeader:!1})}),(0,s.jsx)("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize sidebar",onPointerDown:E,className:(0,c.cn)("absolute right-0 top-0 z-20 h-full w-2 cursor-col-resize","group"),children:(0,s.jsx)("div",{className:(0,c.cn)("absolute inset-y-0 right-0 w-px bg-border/70","transition-colors group-hover:bg-[color:var(--cp-brand-2)]",j&&"bg-[color:var(--cp-brand-2)]")})})]}):(0,s.jsxs)("div",{className:"flex h-full w-12 flex-col items-center border-r bg-sidebar py-3 gap-2 shrink-0",children:[(0,s.jsxs)(u.m_,{children:[(0,s.jsx)(u.k$,{asChild:!0,children:(0,s.jsx)(d.$,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:n,children:(0,s.jsx)(a.A,{className:"h-4 w-4"})})}),(0,s.jsx)(u.ZI,{side:"right",children:"Open sidebar (⌘\\)"})]}),(0,s.jsxs)(u.m_,{children:[(0,s.jsx)(u.k$,{asChild:!0,children:(0,s.jsx)(d.$,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:z,children:(0,s.jsx)(l.A,{className:"h-4 w-4"})})}),(0,s.jsx)(u.ZI,{side:"right",children:"Search (⌘K)"})]}),(0,s.jsxs)(u.m_,{children:[(0,s.jsx)(u.k$,{asChild:!0,children:(0,s.jsx)(d.$,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:R,children:(0,s.jsx)(i.A,{className:"h-4 w-4"})})}),(0,s.jsx)(u.ZI,{side:"right",children:"New Document (⌘N)"})]})]})}var en=n(21628),es=n(93631),er=n(84980),ea=n(2647),el=n(86901),ei=n(49387),eo=n(34530),ec=n(42129),ed=n(96035),eu=n(92972),em=n(5810),eh=n(53961),ex=n(2467),ep=n(34738);function eg({...e}){return(0,s.jsx)(h.Root,{"data-slot":"dialog",...e})}function ef({...e}){return(0,s.jsx)(h.Portal,{"data-slot":"dialog-portal",...e})}function eb({className:e,...t}){return(0,s.jsx)(h.Overlay,{"data-slot":"dialog-overlay",className:(0,c.cn)("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t})}function ev({className:e,children:t,showCloseButton:n=!0,...r}){return(0,s.jsxs)(ef,{"data-slot":"dialog-portal",children:[(0,s.jsx)(eb,{}),(0,s.jsxs)(h.Content,{"data-slot":"dialog-content",className:(0,c.cn)("bg-background 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 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 outline-none sm:max-w-lg",e),...r,children:[t,n&&(0,s.jsxs)(h.Close,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[(0,s.jsx)(m.A,{}),(0,s.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})}function ew({className:e,...t}){return(0,s.jsx)("div",{"data-slot":"dialog-header",className:(0,c.cn)("flex flex-col gap-2 text-center sm:text-left",e),...t})}function ej({className:e,showCloseButton:t=!1,children:n,...r}){return(0,s.jsxs)("div",{"data-slot":"dialog-footer",className:(0,c.cn)("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...r,children:[n,t&&(0,s.jsx)(h.Close,{asChild:!0,children:(0,s.jsx)(d.$,{variant:"outline",children:"Close"})})]})}function ey({className:e,...t}){return(0,s.jsx)(h.Title,{"data-slot":"dialog-title",className:(0,c.cn)("text-lg leading-none font-semibold",e),...t})}function eN({className:e,...t}){return(0,s.jsx)(h.Description,{"data-slot":"dialog-description",className:(0,c.cn)("text-muted-foreground text-sm",e),...t})}function ek({className:e,...t}){return(0,s.jsx)(ep.uB,{"data-slot":"command",className:(0,c.cn)("bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",e),...t})}function eC({title:e="Command Palette",description:t="Search for a command to run...",children:n,className:r,showCloseButton:a=!0,...l}){return(0,s.jsx)(eg,{...l,children:(0,s.jsxs)(ev,{className:(0,c.cn)("overflow-hidden p-0",r),showCloseButton:a,children:[(0,s.jsxs)(ew,{className:"sr-only",children:[(0,s.jsx)(ey,{children:e}),(0,s.jsx)(eN,{children:t})]}),(0,s.jsx)(ek,{className:"[&_[cmdk-group-heading]]:text-muted-foreground **:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:n})]})})}function eS({className:e,...t}){return(0,s.jsxs)("div",{"data-slot":"command-input-wrapper",className:"flex h-9 items-center gap-2 border-b px-3",children:[(0,s.jsx)(l.A,{className:"size-4 shrink-0 opacity-50"}),(0,s.jsx)(ep.uB.Input,{"data-slot":"command-input",className:(0,c.cn)("placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",e),...t})]})}function eA({className:e,...t}){return(0,s.jsx)(ep.uB.List,{"data-slot":"command-list",className:(0,c.cn)("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",e),...t})}function eE({...e}){return(0,s.jsx)(ep.uB.Empty,{"data-slot":"command-empty",className:"py-6 text-center text-sm",...e})}function e$({className:e,...t}){return(0,s.jsx)(ep.uB.Group,{"data-slot":"command-group",className:(0,c.cn)("text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",e),...t})}function ez({className:e,...t}){return(0,s.jsx)(ep.uB.Separator,{"data-slot":"command-separator",className:(0,c.cn)("bg-border -mx-1 h-px",e),...t})}function eR({className:e,...t}){return(0,s.jsx)(ep.uB.Item,{"data-slot":"command-item",className:(0,c.cn)("data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...t})}function eT({className:e,...t}){return(0,s.jsx)("span",{"data-slot":"command-shortcut",className:(0,c.cn)("text-muted-foreground ml-auto text-xs tracking-widest",e),...t})}function e_(){let[e,t]=(0,r.useState)(!1),[n,o]=(0,r.useState)(""),[c,d]=(0,r.useState)([]),[u,m]=(0,r.useState)([]),[h,x]=(0,r.useState)(!1),p=(0,j.useRouter)(),{resolvedTheme:g,setTheme:f}=(0,L.D)(),{recentPages:b,spaces:v,toggleChatPanel:w,toggleSidebar:k,createPage:E}=(0,M.M)(),$=(0,r.useRef)(null);(0,r.useEffect)(()=>{let e=e=>{"k"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),t(!0))},n=()=>t(!0);return document.addEventListener("keydown",e),window.addEventListener("clawpad:open-command-palette",n),()=>{document.removeEventListener("keydown",e),window.removeEventListener("clawpad:open-command-palette",n)}},[]),(0,r.useEffect)(()=>{e&&fetch("/api/files/recent?limit=8").then(e=>e.ok?e.json():[]).then(e=>m(e)).catch(()=>{})},[e]),(0,r.useEffect)(()=>{if(!n.trim()){d([]),x(!1);return}x(!0);let e=setTimeout(async()=>{$.current?.abort();let e=new AbortController;$.current=e;try{let t=await fetch(`/api/files/search?q=${encodeURIComponent(n)}&limit=10`,{signal:e.signal});if(t.ok){let e=await t.json();d(Array.isArray(e)?e:e.results??[])}}catch(e){e.name}finally{e.signal.aborted||x(!1)}},200);return()=>{clearTimeout(e)}},[n]);let z=(0,r.useCallback)(e=>{p.push((0,W.C)(e)),t(!1),o("")},[p]),R=(0,r.useCallback)(async e=>{try{let t=await E(I.Sz,e);z(t)}catch{}},[E,z]),_=(0,r.useCallback)(()=>{t(!1),window.dispatchEvent(new CustomEvent("clawpad:open-new-page",{detail:{mode:"space"}}))},[]),D=(0,r.useCallback)(()=>{t(!1),window.dispatchEvent(new CustomEvent("clawpad:open-new-page",{detail:{mode:"document"}}))},[]),K=(0,r.useCallback)(e=>{t(e),e||(o(""),d([]))},[]),P=u.length>0?u:b.slice(0,8),F=n.trim().length>0,O=c.length>0;return(0,s.jsxs)(eC,{open:e,onOpenChange:K,children:[(0,s.jsx)(eS,{placeholder:"Search pages or type a command…",value:n,onValueChange:o}),(0,s.jsxs)(eA,{children:[(0,s.jsx)(eE,{children:h?(0,s.jsxs)("div",{className:"flex items-center justify-center gap-2 py-2",children:[(0,s.jsx)("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent"}),(0,s.jsx)("span",{className:"text-sm text-muted-foreground",children:"Searching…"})]}):F?"No results found.":null}),O&&(0,s.jsxs)(e$,{heading:"Pages",children:[c.map(e=>(0,s.jsxs)(eR,{value:`search-${e.path}`,onSelect:()=>z(e.path),className:"flex flex-col items-start gap-1 py-3",children:[(0,s.jsxs)("div",{className:"flex w-full items-center gap-2",children:[(0,s.jsx)(C.A,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,s.jsxs)("span",{className:"truncate font-medium",children:[e.icon&&`${e.icon} `,e.title]}),(0,s.jsx)(T.E,{variant:"secondary",className:"ml-auto shrink-0 text-[10px] px-1.5 py-0",children:e.space}),e.modified&&(0,s.jsx)("span",{className:"shrink-0 text-[10px] text-muted-foreground tabular-nums",children:function(e){try{let t=new Date(e),n=new Date().getTime()-t.getTime(),s=Math.floor(n/6e4),r=Math.floor(n/36e5),a=Math.floor(n/864e5);if(s<1)return"just now";if(s<60)return`${s}m ago`;if(r<24)return`${r}h ago`;if(a<7)return`${a}d ago`;return t.toLocaleDateString(void 0,{month:"short",day:"numeric"})}catch{return""}}(e.modified)})]}),e.snippet&&(0,s.jsx)("p",{className:"ml-6 text-xs text-muted-foreground line-clamp-1 max-w-full",children:e.snippet.replace(/^---[\s\S]*?---\s*/m,"").replace(/^#+\s/gm,"").replace(/\n+/g," ").trim()})]},e.path)),(0,s.jsxs)(eR,{value:`view-all-search-${n}`,onSelect:()=>{p.push(`/workspace/search?q=${encodeURIComponent(n.trim())}`),t(!1),o("")},className:"justify-center text-muted-foreground",children:[(0,s.jsx)(l.A,{className:"mr-2 h-3.5 w-3.5"}),(0,s.jsx)("span",{className:"text-xs",children:"View all results"}),(0,s.jsx)(en.A,{className:"ml-1 h-3 w-3"})]})]}),F&&!O&&!h&&(0,s.jsx)(e$,{heading:"Create",children:(0,s.jsxs)(eR,{value:`create-${n}`,onSelect:()=>R(n.trim()),children:[(0,s.jsx)(es.A,{className:"mr-2 h-4 w-4 text-primary"}),(0,s.jsxs)("span",{children:["Create document: ",(0,s.jsx)("strong",{children:n.trim()})]})]})}),!F&&P.length>0&&(0,s.jsx)(e$,{heading:"Recent Pages",children:P.map(e=>(0,s.jsxs)(eR,{value:`recent-${e.path}`,onSelect:()=>z(e.path),children:[(0,s.jsx)(er.A,{className:"mr-2 h-4 w-4 shrink-0 text-muted-foreground"}),(0,s.jsxs)("div",{className:"flex flex-1 items-center gap-2 overflow-hidden",children:[e.icon&&(0,s.jsx)("span",{className:"shrink-0 text-sm",children:e.icon}),(0,s.jsx)("span",{className:"truncate",children:e.title}),(0,s.jsx)(T.E,{variant:"secondary",className:"ml-auto shrink-0 text-[10px] px-1.5 py-0",children:e.space===I.Sz?I.ke:e.space})]})]},e.path))}),(0,s.jsx)(ez,{}),(0,s.jsxs)(e$,{heading:"Create",children:[(0,s.jsxs)(eR,{value:"new-document",onSelect:D,children:[(0,s.jsx)(i.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"New Document"}),(0,s.jsx)(eT,{children:"⌘N"})]}),(0,s.jsxs)(eR,{value:"new-space",onSelect:_,children:[(0,s.jsx)(y.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"New Space"})]}),(0,s.jsxs)(eR,{value:"new-daily-note",onSelect:()=>{t(!1),R(new Date().toISOString().slice(0,10))},children:[(0,s.jsx)(ea.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"New Daily Note"})]})]}),(0,s.jsxs)(e$,{heading:"AI",children:[(0,s.jsxs)(eR,{value:"ask-agent",onSelect:()=>{let e=M.M.getState();e.chatPanelOpen||e.toggleChatPanel(),t(!1)},children:[(0,s.jsx)(el.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"Ask Agent"}),(0,s.jsx)(eT,{children:"⌘⇧L"})]}),(0,s.jsxs)(eR,{value:"summarize-page",onSelect:()=>{let e=M.M.getState();e.chatPanelOpen||e.toggleChatPanel(),t(!1),window.dispatchEvent(new CustomEvent("clawpad:ai-action",{detail:{action:"summarize"}}))},children:[(0,s.jsx)(C.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"Summarize Page"})]}),(0,s.jsxs)(eR,{value:"improve-writing",onSelect:()=>{let e=M.M.getState();e.chatPanelOpen||e.toggleChatPanel(),t(!1),window.dispatchEvent(new CustomEvent("clawpad:ai-action",{detail:{action:"improve"}}))},children:[(0,s.jsx)(ei.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"Improve Writing"})]})]}),(0,s.jsxs)(e$,{heading:"Navigation",children:[(0,s.jsxs)(eR,{value:"search-workspace",onSelect:()=>{let e=n.trim();p.push(e?`/workspace/search?q=${encodeURIComponent(e)}`:"/workspace/search"),t(!1),o("")},children:[(0,s.jsx)(l.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"Search Workspace"})]}),(0,s.jsxs)(eR,{value:"go-to-settings",onSelect:()=>{p.push("/settings"),t(!1)},children:[(0,s.jsx)(N.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"Go to Settings"})]}),(0,s.jsxs)(eR,{value:"go-to-setup",onSelect:()=>{p.push("/setup"),t(!1)},children:[(0,s.jsx)(eo.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"Go to Setup"})]}),v.map(e=>(0,s.jsxs)(eR,{value:`space-${e.path}`,onSelect:()=>{M.M.getState().toggleSpace(e.path),t(!1)},children:[(0,s.jsx)(ec.A,{className:"mr-2 h-4 w-4 text-muted-foreground"}),(0,s.jsxs)("span",{children:[e.icon&&`${e.icon} `,e.name]})]},e.path))]}),(0,s.jsxs)(e$,{heading:"Actions",children:[(0,s.jsxs)(eR,{value:"toggle-chat",onSelect:()=>{w(),t(!1)},children:[(0,s.jsx)(ed.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"Toggle Chat"}),(0,s.jsx)(eT,{children:"⌘⇧L"})]}),(0,s.jsxs)(eR,{value:"toggle-sidebar",onSelect:()=>{k(),t(!1)},children:[(0,s.jsx)(a.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"Toggle Sidebar"}),(0,s.jsx)(eT,{children:"⌘\\"})]}),(0,s.jsxs)(eR,{value:"toggle-dark-mode",onSelect:()=>{f("dark"===g?"light":"dark"),t(!1)},children:["dark"===g?(0,s.jsx)(S.A,{className:"mr-2 h-4 w-4"}):(0,s.jsx)(A.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"Toggle Dark Mode"}),(0,s.jsx)(eT,{children:"⌘⇧D"})]}),(0,s.jsxs)(eR,{value:"theme-light",onSelect:()=>{f("light"),t(!1)},children:[(0,s.jsx)(S.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"Theme: Light"})]}),(0,s.jsxs)(eR,{value:"theme-dark",onSelect:()=>{f("dark"),t(!1)},children:[(0,s.jsx)(A.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"Theme: Dark"})]}),(0,s.jsxs)(eR,{value:"theme-system",onSelect:()=>{f("system"),t(!1)},children:[(0,s.jsx)(eu.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"Theme: System"})]}),(0,s.jsxs)(eR,{value:"focus-editor",onSelect:()=>{let e=document.querySelector(".clawpad-editor [contenteditable]")??document.querySelector(".clawpad-editor");e?.focus(),t(!1)},children:[(0,s.jsx)(em.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"Focus Editor"}),(0,s.jsx)(eT,{children:"⌘⇧E"})]}),(0,s.jsxs)(eR,{value:"force-save",onSelect:()=>{window.dispatchEvent(new CustomEvent("clawpad:force-save")),t(!1)},children:[(0,s.jsx)(eh.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"Save"}),(0,s.jsx)(eT,{children:"⌘S"})]}),(0,s.jsxs)(eR,{value:"keyboard-shortcuts",onSelect:()=>{window.dispatchEvent(new CustomEvent("clawpad:shortcuts-dialog")),t(!1)},children:[(0,s.jsx)(ex.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"Keyboard Shortcuts"}),(0,s.jsx)(eT,{children:"⌘/"})]})]})]})]})}var eD=n(60529),eL=n(66609);let eM="clawpad-create-location-suggestions";function eK(){let[e,t]=(0,r.useState)(!1),[n,a]=(0,r.useState)("document"),[l,i]=(0,r.useState)(""),[o,c]=(0,r.useState)(""),[u,m]=(0,r.useState)(!1),h=(0,j.useRouter)(),{spaces:x,createPage:p,createSpace:g}=(0,M.M)(),f=(0,r.useMemo)(()=>new Set(x.map(e=>e.path)),[x]);(0,r.useEffect)(()=>{let e=e=>{let n=e?.detail;n?.mode==="space"||n?.mode==="folder"?a("space"):a("document"),"string"==typeof n?.title?i(n.title):i(""),"string"==typeof n?.location?c(n.location):"string"==typeof n?.space&&n.space.trim()?c(n.folderPath?`${n.space}/${n.folderPath}`.replace(/^\/+|\/+$/g,""):n.space):c(""),t(!0)};window.addEventListener("clawpad:open-new-page",e),window.addEventListener("clawpad:new-page",e);let n=e=>{"n"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),a("document"),i(""),c(""),t(!0))};return document.addEventListener("keydown",n),()=>{window.removeEventListener("clawpad:open-new-page",e),window.removeEventListener("clawpad:new-page",e),document.removeEventListener("keydown",n)}},[]),(0,r.useEffect)(()=>{if(!e||"document"!==n||o.trim())return;let t=x.find(e=>e.path!==I.Sz)?.path??x[0]?.path??"";t&&c(t)},[o,n,e,x]);let b=()=>{a("document"),i(""),c(""),m(!1)},v=(0,r.useCallback)(async()=>{let e=l.trim();if(e){m(!0);try{if("space"===n){await g(e),t(!1),b(),eL.oR.success("Space created"),h.push("/workspace");return}let s=function(e,t){let n=e.trim();if(!n)return null;let s=n.replace(/^\/+|\/+$/g,"");if(!s)return null;if(s===I.Sz||"root"===s.toLowerCase()||s.toLowerCase()===I.ke.toLowerCase())return{space:I.Sz};let r=s.split("/").filter(Boolean);if(0===r.length)return null;let[a,...l]=r;return t.has(a)?{space:a,folderPath:l.length>0?l.join("/"):void 0}:null}(o,f);if(!s)throw Error("Choose a valid location (space or space/folder path).");let r=await p(s.space,e,{folderPath:s.folderPath});t(!1),b(),h.push((0,W.C)(r)),eL.oR.success("Document created")}catch(t){let e=t instanceof Error?t.message:"space"===n?"Failed to create space.":"Failed to create document.";eL.oR.error(e)}finally{m(!1)}}},[p,g,f,o,n,h,l]),w=(0,r.useCallback)(e=>{"Enter"!==e.key||u||(e.preventDefault(),v())},[u,v]);return(0,s.jsx)(eg,{open:e,onOpenChange:e=>{t(e),e||b()},children:(0,s.jsxs)(ev,{className:"sm:max-w-[440px]",children:[(0,s.jsxs)(ew,{children:[(0,s.jsx)(ey,{children:"space"===n?"New Space":"New Document"}),(0,s.jsx)(eN,{children:"space"===n?"Create a top-level space in your workspace.":"Create a document in a space or nested folder path."})]}),(0,s.jsxs)("div",{className:"grid gap-4 py-4",children:[(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-2 rounded-lg border bg-muted/30 p-1",children:[(0,s.jsx)("button",{type:"button",onClick:()=>a("document"),className:`rounded-md px-2 py-1.5 text-xs ${"document"===n?"bg-background font-medium shadow-sm":"text-muted-foreground"}`,children:"Document"}),(0,s.jsx)("button",{type:"button",onClick:()=>a("space"),className:`rounded-md px-2 py-1.5 text-xs ${"space"===n?"bg-background font-medium shadow-sm":"text-muted-foreground"}`,children:"Space"})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("label",{htmlFor:"create-title",className:"text-sm font-medium leading-none",children:"space"===n?"Space Name":"Document Name"}),(0,s.jsx)(eD.p,{id:"create-title",placeholder:"space"===n?"e.g. client-work":"Document title…",value:l,onChange:e=>i(e.target.value),onKeyDown:w,autoFocus:!0})]}),"document"===n&&(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("label",{htmlFor:"create-location",className:"text-sm font-medium leading-none",children:"Location"}),(0,s.jsx)(eD.p,{id:"create-location",list:eM,placeholder:"space or space/folder/path",value:o,onChange:e=>c(e.target.value),onKeyDown:w}),(0,s.jsx)("datalist",{id:eM,children:x.map(e=>(0,s.jsx)("option",{value:e.path,children:e.name},e.path))}),(0,s.jsxs)("p",{className:"text-[11px] text-muted-foreground",children:["Example: ",(0,s.jsx)("code",{children:"projects/q1/roadmap"})]})]})]}),(0,s.jsxs)(ej,{children:[(0,s.jsx)(d.$,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),(0,s.jsx)(d.$,{onClick:()=>void v(),disabled:!l.trim()||u,children:u?"Creating…":"space"===n?"Create Space":"Create Document"})]})]})})}var eP=n(84577),eI=n(86726),eF=n(56558),eW=n(15411),eO=n(7915),eU=n(92018),eq=n(6296),eB=n(13545),eH=n(56842),eZ=n(99815),eJ=n(10762),eV=n(72055),eG=n(95672),eX=n(66088),eQ=n(94514),eY=n(38399),e0=n(41730),e1=n(92451),e5=n(17243),e2=n(74643),e4=n(69260),e3=n(6489),e6=n(65576),e9=n(32967),e8=n(13175),e7=n(76597),te=n(25262),tt=n(52159),tn=n(80642),ts=n(18310),tr=n(3163),ta=n(46794),tl=n(83099);let ti=/<\s*\/?\s*(?:think(?:ing)?|thought|antthinking|final)\b/i,to=/<\s*\/?\s*final\b[^<>]*>/gi,tc=/<\s*(\/?)\s*(?:think(?:ing)?|thought|antthinking)\b[^<>]*>/gi;function td(e){let t=[];for(let n of e.matchAll(/(^|\n)(```|~~~)[^\n]*\n[\s\S]*?(?:\n\2(?:\n|$)|$)/g)){let e=(n.index??0)+n[1].length;t.push({start:e,end:e+n[0].length-n[1].length})}for(let n of e.matchAll(/`+[^`]+`+/g)){let e=n.index??0,s=e+n[0].length;t.some(t=>e>=t.start&&s<=t.end)||t.push({start:e,end:s})}return t.sort((e,t)=>e.start-t.start),t}function tu(e,t){return t.some(t=>e>=t.start&&e<t.end)}var tm=n(9921);function th({status:e}){let t=(0,j.useRouter)(),n=(0,tl.W)(e=>e.activeRun),a=(0,tl.W)(e=>e.activeFiles),l=(0,tl.W)(e=>e.lastFileTouchAt),i=(0,tl.W)(e=>e.changeSets),o=(0,tl.W)(e=>e.openReview),d=(0,tl.W)(e=>e.closeReview),u=(0,K.z)(e=>e.agentStatus),m=i.find(e=>"completed"===e.status),[h,x]=(0,r.useState)(!1),p=a.size,g=!!m,f=e?"status":n&&p>0&&"number"==typeof l&&"idle"!==u?"editing":g?"summary":null,b="editing"===f?p:m?.totals.filesChanged??0,v=m?.totals.additions??0,w=m?.totals.deletions??0,y=0===b?"files":1===b?"1 file":`${b} files`,N="summary"===f&&!!m,k=N&&h;if(!f)return null;let C=e?.kind==="alert",S=e?.tone==="error",A=e?(0,c.cn)("flex w-full items-center gap-2 rounded-lg border px-3 py-1.5 text-xs transition-colors","thinking"===e.kind&&"border-[color:var(--cp-brand-border)] bg-[color:var(--cp-status-thinking-bg)] text-[color:var(--cp-status-thinking-text)]","writing"===e.kind&&"border-[color:var(--cp-brand-border)] bg-[color:var(--cp-status-thinking-bg)] text-[color:var(--cp-status-thinking-text)]","background"===e.kind&&"border-border/60 bg-[color:var(--cp-status-neutral-bg)] text-[color:var(--cp-status-neutral-text)]",C&&(S?"border-red-500/40 bg-[color:var(--cp-status-error-bg)] text-[color:var(--cp-status-error-text)]":"border-amber-500/40 bg-[color:var(--cp-status-alert-bg)] text-[color:var(--cp-status-alert-text)]")):"",E=e?(0,c.cn)("inline-flex h-2 w-2 rounded-full",("thinking"===e.kind||"background"===e.kind||"writing"===e.kind)&&"animate-pulse",("thinking"===e.kind||"writing"===e.kind)&&"bg-[color:var(--cp-status-thinking-text)]","background"===e.kind&&"bg-[color:var(--cp-status-neutral-text)]",C&&(S?"bg-[color:var(--cp-status-error-text)]":"bg-[color:var(--cp-status-alert-text)]")):"";return(0,s.jsxs)("div",{className:"mb-2",children:["status"===f&&e&&(0,s.jsxs)("div",{className:A,role:"status","aria-live":"polite",children:[(0,s.jsx)("span",{className:E}),(0,s.jsx)("span",{className:"text-[11px] font-medium",children:e.label}),e.detail&&(0,s.jsx)("span",{className:"max-w-[240px] truncate text-[10px] text-foreground/70",children:e.detail})]}),("editing"===f||"summary"===f)&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("button",{type:"button",onClick:()=>{N&&x(e=>!e)},className:(0,c.cn)("flex w-full items-center gap-2 border border-border/60 bg-muted/40 px-3 py-1.5 text-xs text-muted-foreground","rounded-lg",N&&"cursor-pointer hover:bg-muted/60"),children:[(0,s.jsx)("span",{className:"inline-flex h-2 w-2 rounded-full bg-[color:var(--cp-brand-2)] animate-pulse"}),(0,s.jsx)("span",{className:"flex-1 text-left",children:"editing"===f?(0,s.jsxs)(s.Fragment,{children:["Editing ",y,"…"]}):(0,s.jsxs)(s.Fragment,{children:[y," changed"," ",(0,s.jsxs)("span",{className:"text-emerald-600",children:["+",v]})," ",(0,s.jsxs)("span",{className:"text-rose-500",children:["-",w]})]})}),N&&(0,s.jsx)("span",{className:"text-muted-foreground/70",children:h?(0,s.jsx)(tm.A,{className:"h-3.5 w-3.5"}):(0,s.jsx)(eX.A,{className:"h-3.5 w-3.5"})})]}),k&&m&&(0,s.jsx)("div",{className:"rounded-b-lg border border-t-0 border-border/60 bg-background/95",children:(0,s.jsx)("div",{className:"divide-y divide-border/70",children:m.files.map(e=>(0,s.jsxs)("div",{className:"flex items-center gap-3 px-3 py-2 text-xs",children:[(0,s.jsx)("button",{type:"button",onClick:()=>{var n;return n=e.path,void(m&&(o(m.id,n),t.push((0,W.C)(n))))},className:"rounded-md border border-border/70 px-2 py-0.5 text-[10px] font-medium text-muted-foreground hover:text-foreground",children:"Diff"}),(0,s.jsx)("button",{type:"button",onClick:()=>{var n;return n=e.path,void(d(),t.push((0,W.C)(n)))},className:"flex-1 truncate text-left text-foreground/80 hover:text-foreground",children:e.path}),(0,s.jsxs)("span",{className:"shrink-0 font-mono text-[11px]",children:[(0,s.jsxs)("span",{className:"text-emerald-600",children:["+",e.additions]})," ",(0,s.jsxs)("span",{className:"text-rose-500",children:["-",e.deletions]})]})]},e.path))})})]})]})}let tx={telegram:{icon:"\uD83D\uDCF1",label:"Telegram",color:"bg-sky-100 text-sky-700 dark:bg-sky-900/40 dark:text-sky-300"},whatsapp:{icon:"\uD83D\uDCAC",label:"WhatsApp",color:"bg-emerald-100 text-emerald-700 dark:bg-emerald-900/40 dark:text-emerald-300"},discord:{icon:"\uD83C\uDFAE",label:"Discord",color:"bg-indigo-100 text-indigo-700 dark:bg-indigo-900/40 dark:text-indigo-300"},slack:{icon:"\uD83D\uDCBC",label:"Slack",color:"bg-purple-100 text-purple-700 dark:bg-purple-900/40 dark:text-purple-300"},webchat:{icon:"\uD83C\uDF10",label:"Web",color:"bg-zinc-100 text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400"},clawpad:{icon:"\uD83C\uDF10",label:"ClawPad",color:"bg-zinc-100 text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400"},system:{icon:"\uD83E\uDD16",label:"System",color:"bg-amber-100 text-amber-700 dark:bg-amber-900/40 dark:text-amber-300"}},tp=(0,r.memo)(function({channel:e,sessionKey:t,className:n}){let r=e?e.toLowerCase():t?(t.split(":")[2]??"unknown").toLowerCase():"unknown",a=tx[r];return a&&"webchat"!==r&&"clawpad"!==r?(0,s.jsxs)("span",{className:(0,c.cn)("inline-flex items-center gap-0.5 rounded-full px-1.5 py-0.5 text-[10px] font-medium leading-none",a.color,n),children:[(0,s.jsx)("span",{className:"text-[10px]",children:a.icon}),a.label]}):null}),tg=["image/png","image/jpeg","image/gif","image/webp"],tf=[],tb=null,tv="main";function tw(e){return(e.split("/").pop()??e).replace(/\.md$/,"").replace(/[-_]+/g," ").replace(/\b\w/g,e=>e.toUpperCase())}function tj(e){return{title:e.title?.trim()||tw(e.path),path:e.path,space:e.space,modified:e.modified,snippet:e.snippet}}async function ty(e){return new Promise((t,n)=>{let s=new FileReader;s.onload=()=>t(s.result),s.onerror=n,s.readAsDataURL(e)})}async function tN(e){let t=[];for(let n of e){if(!tg.includes(n.type))continue;if(n.size>5242880){console.warn(`[chat] Skipping ${n.name}: exceeds 5 MB`);continue}let e=await ty(n);t.push({id:crypto.randomUUID(),dataUrl:e,name:n.name})}return t}let tk=/^\[([^\]]+)\]\s*/,tC=["WebChat","WhatsApp","Telegram","Signal","Slack","Discord","Google Chat","iMessage","Teams","Matrix","Zalo","Zalo Personal","BlueBubbles"],tS=/^\s*\[message_id:\s*[^\]]+\]\s*$/i,tA=/^\s*\[message_id:\s*([^\]]+)\]\s*$/i;function tE(e){var t;let n=e.match(tk);return n?(t=n[1]??"",/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}Z\b/.test(t)||/\d{4}-\d{2}-\d{2} \d{2}:\d{2}\b/.test(t)||tC.some(e=>t.startsWith(`${e} `)))?tz(e.slice(n[0].length)):tz(e):tz(e)}function t$(e){return String(e.preview??e.reason??e.status??"Heartbeat").trim()}function tz(e){if(!e.includes("[message_id:"))return e;let t=e.split(/\r?\n/),n=t.filter(e=>!tS.test(e));return n.length===t.length?e:n.join("\n")}function tR(e){return function(e,t){var n;if(!e||!ti.test(e))return e;let s=t?.mode??"strict",r=t?.trim??"both",a=e;if(to.test(a)){to.lastIndex=0;let e=[],t=td(a);for(let n of a.matchAll(to)){let s=n.index??0;e.push({start:s,length:n[0].length,inCode:tu(s,t)})}for(let t=e.length-1;t>=0;t-=1){let n=e[t];n.inCode||(a=a.slice(0,n.start)+a.slice(n.start+n.length))}}else to.lastIndex=0;let l=td(a);tc.lastIndex=0;let i="",o=0,c=!1;for(let e of a.matchAll(tc)){let t=e.index??0,n="/"===e[1];tu(t,l)||(c?n&&(c=!1):(i+=a.slice(o,t),n||(c=!0)),o=t+e[0].length)}return c&&"preserve"!==s||(i+=a.slice(o)),n=i,"none"===r?n:"start"===r?n.trimStart():n.trim()}(e,{mode:"preserve",trim:"start"})}function tT(e){return e.replace(/^\s*\[Context\][\s\S]*?\[\/Context\]\s*/i,"")}function t_(e){return String(e??"").replace(/\s+/g," ").trim()}function tD(e){let t=e.role??"",n=e.content;if("string"==typeof n){let e="assistant"===t?tR(n):tE(n);return"user"===t||"User"===t?tT(e):e}if(Array.isArray(n)){let e=n.filter(e=>"text"===e.type&&"string"==typeof e.text).map(e=>e.text);if(e.length>0){let n=e.join("\n"),s="assistant"===t?tR(n):tE(n);return"user"===t||"User"===t?tT(s):s}}if("string"==typeof e.text){let n=e.text,s="assistant"===t?tR(n):tE(n);return"user"===t||"User"===t?tT(s):s}return null}function tL(e){let t=e.role??"",n=e.content;if("string"==typeof n)return"user"===t||"User"===t?tT(n):n;if(Array.isArray(n)){let e=n.filter(e=>"text"===e.type&&"string"==typeof e.text).map(e=>e.text);if(e.length>0){let n=e.join("\n");return"user"===t||"User"===t?tT(n):n}}if("string"==typeof e.text){let n=e.text;return"user"===t||"User"===t?tT(n):n}return null}function tM(e){var t;let n;if(null==e)return;if("number"==typeof e||"boolean"==typeof e)return String(e);if("string"==typeof e)n=e;else if("object"==typeof e)if("string"==typeof e.text)n=e.text;else if(Array.isArray(e.content)){let t=e.content.map(e=>e&&"object"==typeof e&&"text"===e.type&&"string"==typeof e.text?e.text:null).filter(e=>!!e);n=t.length>0?t.join("\n"):""}else try{n=JSON.stringify(e,null,2)}catch{n=String(e)}else n=String(e);if(!n)return;let s=(t=tK(n)??n).length<=12e4?{text:t,truncated:!1,total:t.length}:{text:t.slice(0,12e4),truncated:!0,total:t.length};return s.truncated?`${s.text}
2
2
 
3
3
  … truncated (${s.total} chars, showing first ${s.text.length}).`:s.text}function tK(e){let t=e.trim();if(!t||!t.startsWith("{")&&!t.startsWith("["))return null;try{return JSON.stringify(JSON.parse(t),null,2)}catch{return null}}function tP(e){var t;let n,s,r=e.role??"unknown";(function(e){let t=(e.role??"").toLowerCase();if("toolresult"===t||"tool_result"===t||e.toolCallId||e.tool_call_id||e.toolName||e.tool_name)return!0;let n=Array.isArray(e.content)?e.content:null;return!!n?.some(e=>{let t=(e.type??"").toLowerCase();return"toolresult"===t||"tool_result"===t})})(e)&&(r="toolResult");let a=[];"string"==typeof e.content?a=[{type:"text",text:e.content}]:Array.isArray(e.content)?a=e.content.map(e=>({...e,type:e.type||"text",text:e.text})):"string"==typeof e.text&&(a=[{type:"text",text:e.text}]);let l=tL(e),i=!!l&&function(e,t){let n=e.trim();if(!n)return!1;if(/^HEARTBEAT_OK\b/i.test(n)||/^HEARTBEAT\b/i.test(n))return!0;let s=/^System:/i.test(n),r=/\[NETWORK\]/i.test(n),a=/\bRead HEARTBEAT\.md\b/i.test(n);return!!s&&(!!r||!!a)||"system"===(t??"").toLowerCase()}(l,r),o=i?"system":(n=((t=r)??"").toLowerCase(),"user"===t||"User"===t?"user":"assistant"===t?"assistant":"system"===t?"system":"toolresult"===n||"tool_result"===n||"tool"===n||"function"===n?"tool":"assistant");return"user"===o&&(s=!1,a=a.map(e=>{if(!s&&"text"===e.type&&"string"==typeof e.text){let t=tT(e.text);return(t!==e.text&&(s=!0),t.trim())?{...e,text:t}:null}return e}).filter(Boolean)),{role:o,content:a,timestamp:e.timestamp??Date.now(),id:e.id,channel:e.channel,sessionKey:e.sessionKey,raw:e,displayText:tD(e),toolCards:function(e){let t=[],n=Array.isArray(e.content)?e.content:[];for(let e of n)(["toolcall","tool_call","tooluse","tool_use"].includes((e.type??"").toLowerCase())||"string"==typeof e.name&&null!=e.arguments)&&t.push({kind:"call",name:e.name??"tool",args:function(e){if("string"!=typeof e)return e;let t=e.trim();if(!t||!t.startsWith("{")&&!t.startsWith("["))return e;try{return JSON.parse(t)}catch{return e}}(e.arguments??e.args??e.input)});for(let e of n){let n=(e.type??"").toLowerCase();if("toolresult"!==n&&"tool_result"!==n)continue;let s=e.text??e.content??void 0,r=e.name??"tool";t.push({kind:"result",name:r,text:s})}if(("toolresult"===(e.role??"").toLowerCase()||"tool_result"===(e.role??"").toLowerCase()||e.toolCallId||e.tool_call_id||e.toolName||e.tool_name)&&!t.some(e=>"result"===e.kind)){let n=e.toolName??e.tool_name??"tool",s=tD(e)??void 0;t.push({kind:"result",name:n,text:s})}return t}(e),internal:i}}function tI(){return new eI.rL({api:"/api/chat",body:()=>({sessionKey:tv,pageContext:tb?.activePage?.path??void 0,context:tb??void 0,images:tf.length>0?[...tf]:void 0})})}let tF=tI(),tW=new eP.ry({transport:tF});function tO({variant:e="default"}){let{chatPanelOpen:t,setChatPanelOpen:n,activePage:a}=(0,M.M)(),l=(0,K.z)(e=>e.connected),o=(0,K.z)(e=>e.wsStatus),u=(0,K.z)(e=>e.reason),h=(0,K.z)(e=>e.wsError),x=(0,K.z)(e=>e.error),p=(0,K.z)(e=>e.agentStatus),g=(0,tl.W)(e=>e.setSessionKey),f=(0,tl.W)(e=>e.loadChangeSets),b=t||"default"!==e,[v,w]=(0,r.useState)("main"),j=(0,r.useRef)("main"),y=(0,r.useRef)(!1),[N,k]=(0,r.useState)(600),[S,A]=(0,r.useState)(!1),E=(0,r.useRef)(0),$=(0,r.useRef)(600),z="default"===e,R=(0,r.useCallback)(e=>Math.max(400,Math.min(e,Math.round(.4*window.innerWidth))),[]);(0,r.useEffect)(()=>{if(!z)return;let e=()=>{k(e=>R(e))};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[R,z]),(0,r.useEffect)(()=>{if(!S)return;let e=e=>{let t=E.current-e.clientX;k(R($.current+t))},t=()=>{A(!1)};return window.addEventListener("pointermove",e),window.addEventListener("pointerup",t),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{window.removeEventListener("pointermove",e),window.removeEventListener("pointerup",t),document.body.style.cursor="",document.body.style.userSelect=""}},[R,S]),(0,r.useEffect)(()=>{j.current=v,tv=v||"main"},[v]),(0,r.useEffect)(()=>{b&&(g(v),f())},[b,v,g,f]),(0,r.useEffect)(()=>{if(!b)return;let e=!1;return fetch("/api/gateway/resolve?key=main").then(e=>e.ok?e.json():null).then(t=>{if(e||!t)return;let n="string"==typeof t.resolved?t.resolved.trim():"";n&&(y.current=!0,n!==j.current&&w(n))}).catch(()=>{}),()=>{e=!0}},[b]);let T=(0,r.useRef)(0),{history:_,loading:D,loadingMore:L,hasMore:P,loadMore:I,refetchHistory:F}=function(e,t,n){let[s,a]=(0,r.useState)([]),[l,i]=(0,r.useState)(300),[o,c]=(0,r.useState)(!0),[d,u]=(0,r.useState)(!1),m=(0,r.useRef)(null),h=(0,r.useRef)(0),x=(0,r.useRef)(0),p=(0,r.useRef)(0),g=(0,r.useCallback)(async e=>{let t=n||"main",s=x.current+1;x.current=s;let r=e?.silent===!0;r||(p.current+=1,c(!0));try{let n=await fetch(`/api/gateway/history?limit=1000&sessionKey=${encodeURIComponent(t)}`,{cache:"no-store"}),r=n.ok?await n.json():{messages:[]};if(s!==x.current)return;let l=Array.isArray(r?.messages)?r.messages:[],i=e?.preserveExistingOnEmpty!==!1;a(e=>i&&0===l.length&&e.length>0?e:l)}catch{}finally{r||(p.current=Math.max(0,p.current-1),0===p.current&&c(!1))}},[n]),f=(0,r.useCallback)(e=>!e?.force&&Date.now()-t.current<5e3?Promise.resolve():g({silent:!0}),[g,t]),b=(0,r.useMemo)(()=>s.length<=l?s:s.slice(s.length-l),[s,l]),v=s.length>l,w=(0,r.useCallback)(()=>{u(!0),setTimeout(()=>{i(e=>Math.min(e+100,s.length)),u(!1)},100)},[s.length]);return(0,r.useEffect)(()=>{m.current!==n&&(m.current=n,h.current=0,i(300),g())},[n,g]),(0,r.useEffect)(()=>{if(e){if(s.length>0){h.current=0;return}o||h.current>=3||(h.current+=1,g())}},[e,s.length,o,g]),{history:b,allMessages:s,loading:o,loadingMore:d,hasMore:v,loadMore:w,refetchHistory:f}}(b,T,v),[W,O]=(0,r.useState)(tW),{messages:U,sendMessage:q,addToolApprovalResponse:B,status:H,stop:Z,error:J}=(0,eP.Y_)({chat:W}),V=(0,r.useRef)(null),G=(0,r.useRef)(null),X=(0,r.useRef)(null),Q=(0,r.useRef)(null),Y=(0,r.useRef)(null),ee=(0,r.useRef)(null),et=(0,r.useRef)(null),en="streaming"===H||"submitted"===H,es=(0,r.useRef)(null),[ea,ei]=(0,r.useState)(null),[eo,ec]=(0,r.useState)(!0),[ed,eu]=(0,r.useState)([]),[em,eh]=(0,r.useState)(!1),[ex,ep]=(0,r.useState)(""),[eg,ef]=(0,r.useState)([]),[eb,ev]=(0,r.useState)(!1),[ew,ej]=(0,r.useState)(0),[ey,eN]=(0,r.useState)([]),[ek,eC]=(0,r.useState)(!1),[eS,eA]=(0,r.useState)(""),[eE,e$]=(0,r.useState)([]),[ez,eR]=(0,r.useState)(!1),[eT,e_]=(0,r.useState)(0),eD="connected"!==o,[eL,eM]=(0,r.useState)(!1),eK=eL&&!1,eI=(0,ta.b)(e=>e.events),eG=(0,ta.b)(e=>e.lastEvent),eX=(0,tr.e)(e=>e.items),[eQ,eY]=(0,r.useState)(null),e0=(0,r.useRef)(null),e1=(0,r.useRef)(0),e5=(0,r.useRef)(0),[e2,e4]=(0,r.useState)(()=>Date.now());(0,r.useEffect)(()=>{if("idle"===p&&"submitted"!==H&&"streaming"!==H)return;let e=setInterval(()=>{e4(Date.now())},1e3);return()=>clearInterval(e)},[p,H]);let e3=(0,r.useMemo)(()=>{let e=[...U].reverse().find(e=>"assistant"===e.role);return!!e&&t1(e).trim().length>0},[U]),e6=(0,r.useMemo)(()=>{let e=eX.find(e=>"tool-used"===e.type||"sub-agent"===e.type);return e?.timestamp??null},[eX]),e9=(0,r.useMemo)(()=>{if("reconnecting"===o)return{kind:"background",label:"Reconnecting...",detail:h||"Trying to restore the gateway stream"};if("connecting"===o)return{kind:"background",label:"Connecting...",detail:h||"Connecting to the gateway"};if("disconnected"===o)return{kind:"alert",label:"server_unreachable"===u?"ClawPad server unreachable":"Gateway unavailable",detail:h||x||("server_unreachable"===u?"ClawPad is not reachable from this browser.":"OpenClaw gateway is not reachable."),tone:"warn"};let e=eG&&("alert"===eG.indicatorType||"error"===eG.indicatorType)&&!eG.silent?eG:null;if(e){let t=t$(e);return{kind:"alert",label:"error"===e.indicatorType?"Background error":"Background alert",detail:t||void 0,tone:"error"===e.indicatorType?"error":"warn"}}return"submitted"===H?{kind:"thinking",label:"Thinking..."}:"streaming"===H?e3?{kind:"writing",label:"Writing response..."}:{kind:"thinking",label:"Thinking..."}:"thinking"===p?{kind:"thinking",label:"Thinking..."}:"active"===p&&"number"==typeof e6&&e2-e6<=15e3?{kind:"background",label:"Working on a background task..."}:null},[p,x,u,e3,eG,e6,H,e2,h,o]);(0,r.useEffect)(()=>{e0.current&&(clearTimeout(e0.current),e0.current=null);let e=Date.now();if(e9){e5.current=e,eY(t=>!t&&!e9||t&&e9&&t.kind===e9.kind&&t.label===e9.label&&t.detail===e9.detail&&t.tone===e9.tone?t:(e1.current=e,e9));return}if(!eQ)return;let t="alert"===eQ.kind?5e3:"background"===eQ.kind?3e3:1500,n="alert"===eQ.kind?6e3:2500,s=Math.max(Math.max(e1.current+t,e5.current+n)-e,0);return 0===s?void eY(null):(e0.current=setTimeout(()=>{eY(null),e0.current=null},s),()=>{e0.current&&(clearTimeout(e0.current),e0.current=null)})},[e9,eQ]),(0,r.useEffect)(()=>{if(!a)return void ei(null);let e=!1;return ec(!0),(async()=>{try{let t=await fetch(`/api/files/pages/${encodeURIComponent(a)}`);if(!t.ok)throw Error("Failed to load page");let n=await t.json();if(e)return;let s=n?.meta;if(s?.path)return void ei(tj({title:s.title,path:s.path,space:s.space,modified:s.modified}))}catch{}e||ei(tj({title:tw(a),path:a}))})(),()=>{e=!0}},[a]);let e8=(0,r.useCallback)(()=>{let e={};eo&&ea&&(e.activePage=ea);let t=ed.filter(t=>!e.activePage||t.path!==e.activePage.path);return t.length>0?(e.attachedPages=t,e.scope="custom"):e.activePage&&(e.scope="current"),Object.keys(e).length>0?e:null},[ea,ed,eo]),e7=(0,r.useCallback)(()=>{let e=G.current;if(!e)return;let t=e.value,n=e.selectionStart??t.length,s=t.slice(0,n),r=s.lastIndexOf("@");if(-1===r){eh(!1),ep(""),Q.current=null;return}let a=s[r-1],l=!a||/[\s([{]/.test(a),i=s.slice(r+1);if(!l||/\s/.test(i)){eh(!1),ep(""),Q.current=null;return}Q.current={start:r,end:n},ep(i),eh(!0),eC(!1),eA(""),ee.current=null},[]),te=(0,r.useCallback)(async()=>{if(!ez&&!(eE.length>0)){eR(!0);try{let e=await fetch("/api/openclaw/commands"),t=e.ok?await e.json():null,n=Array.isArray(t?.commands)?t.commands.filter(e=>!!(e&&"string"==typeof e.name)).map(e=>({name:e.name,description:e.description??"",disabled:e.disabled})):[];e$(n),e_(0)}catch{e$([])}finally{eR(!1)}}},[eE.length,ez]),ts=(0,r.useCallback)(()=>{let e=G.current;if(!e)return;let t=e.value,n=e.selectionStart??t.length,s=t.slice(0,n),r=s.lastIndexOf("/");if(-1===r){eC(!1),eA(""),ee.current=null;return}let a=s[r-1],l=!a||/[\s([{]/.test(a),i=s.slice(r+1);if(!l||/\s/.test(i)){eC(!1),eA(""),ee.current=null;return}ee.current={start:r,end:n},eA(i),eC(!0),eh(!1),ep(""),Q.current=null,te()},[te]),ti=(0,r.useCallback)(e=>{let t=G.current,n=ee.current;if(!t||!n)return;let s=t.value,r=s.slice(0,n.start),a=s.slice(n.end),l=`/${e}`,i=a.startsWith(" ")?"":" ",o=`${r}${l}${i}${a}`,c=r.length+l.length+i.length;t.value=o,t.setSelectionRange(c,c),t.focus(),eC(!1),eA(""),ee.current=null,requestAnimationFrame(()=>{let e=G.current;e&&(e.style.height="auto",e.style.height=`${Math.min(e.scrollHeight,150)}px`)})},[]),to=(0,r.useCallback)(e=>{let t=G.current,n=Q.current;if(!t||!n)return;let s=t.value,r=s.slice(0,n.start),a=s.slice(n.end),l=`@${e.title}`,i=a.startsWith(" ")?"":" ",o=`${r}${l}${i}${a}`,c=r.length+l.length+i.length;t.value=o,t.setSelectionRange(c,c),t.focus(),eu(t=>t.some(t=>t.path===e.path)?t:[...t,e]),eh(!1),ep(""),Q.current=null,requestAnimationFrame(()=>{let e=G.current;e&&(e.style.height="auto",e.style.height=`${Math.min(e.scrollHeight,150)}px`)})},[]),tc=(0,r.useCallback)(()=>{let e=G.current;if(!e)return;let t=e.value,n=e.selectionStart??t.length,s=e.selectionEnd??n;e.value=`${t.slice(0,n)}@${t.slice(s)}`;let r=n+1;e.setSelectionRange(r,r),e.focus(),e7()},[e7]);(0,r.useEffect)(()=>{if(!em)return void ev(!1);let e=!1,t=ex.trim();!t&&ey.length>0&&ef(ey);let n=setTimeout(async()=>{if(!e){ev(!0);try{let n=t?`/api/files/search?q=${encodeURIComponent(t)}&limit=8`:"/api/files/recent?limit=8",s=await fetch(n),r=s.ok?await s.json():[];if(e)return;let a=Array.isArray(r)?r.map(e=>tj(e)):[];ef(a),t||eN(a),ej(0)}catch{e||ef([])}finally{e||ev(!1)}}},150);return()=>{e=!0,clearTimeout(n)}},[em,ex,ey]),(0,r.useEffect)(()=>{b&&te()},[b,te]),(0,r.useEffect)(()=>{if(!b)return;let e=!1;return(async()=>{try{let t=await fetch("/api/files/recent?limit=8");if(!t.ok)return;let n=await t.json();if(e)return;let s=Array.isArray(n)?n.map(e=>tj(e)):[];eN(s)}catch{}})(),()=>{e=!0}},[b]),(0,r.useEffect)(()=>{b||(eh(!1),ep(""),Q.current=null,eC(!1),eA(""),ee.current=null)},[b]),(0,r.useEffect)(()=>{if(!em)return;let e=e=>{let t=e.target;Y.current&&!Y.current.contains(t)&&(eh(!1),ep(""),Q.current=null)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[em]),(0,r.useEffect)(()=>{if(!ek)return;let e=e=>{let t=e.target;et.current&&!et.current.contains(t)&&(eC(!1),eA(""),ee.current=null)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[ek]);let[td,tu]=(0,r.useState)([]),tm=(0,r.useRef)(null),tx=(0,r.useRef)([]),tp=(0,r.useRef)(null),ty=(0,r.useRef)(null),tk=(0,r.useRef)(""),tC=(0,r.useRef)(new Map),tS=(0,r.useRef)([]),tE=(0,r.useRef)(null),tz=(0,r.useRef)(null),[tR,tT]=(0,r.useState)([]),tD=(0,r.useCallback)(()=>{tT(tS.current.map(e=>tC.current.get(e)).filter(e=>!!e))},[]),tK=(0,r.useCallback)((e=!1)=>{if(e){tE.current&&(clearTimeout(tE.current),tE.current=null),tD();return}tE.current||(tE.current=setTimeout(()=>{tE.current=null,tD()},80))},[tD]),tF=(0,r.useCallback)(()=>{tC.current.clear(),tS.current=[],tz.current=null,tE.current&&(clearTimeout(tE.current),tE.current=null),tT([])},[]);(0,r.useEffect)(()=>{let e=tm.current;e&&("streaming"===H?tu(t=>t.map(t=>t.id===e&&"sending"===t.status?{...t,status:"sent"}:t)):"ready"===H&&(tu(t=>t.map(t=>t.id===e&&("sending"===t.status||"streaming"===t.status)?{...t,status:"sent"}:t)),tm.current=null))},[H]),(0,r.useEffect)(()=>{if(J&&tm.current){let e=tm.current;tu(t=>t.map(t=>t.id===e?{...t,status:"error"}:t)),tm.current=null}},[J]);let tO=(0,r.useRef)(!0),tH=(0,r.useRef)(0),[tV,tG]=(0,r.useState)(0),tX=(0,r.useCallback)((e="smooth")=>{let t=V.current;if(!t)return;let n=t.scrollHeight-t.clientHeight;t.scrollTo({top:n>0?n:0,behavior:e})},[]),tQ=(0,r.useCallback)(()=>{let e=V.current;!e||(tO.current=e.scrollHeight-e.scrollTop-e.clientHeight<100,tO.current&&tG(0))},[]),t0=(0,r.useCallback)(e=>{if("tool"!==e.stream)return;let t="string"==typeof e.sessionKey?e.sessionKey:void 0,n=j.current||"main";if(y.current&&t&&t!==n)return;let s="string"==typeof e.runId?e.runId:"unknown",r=e.data??{},a="string"==typeof r.toolCallId?r.toolCallId:"";if(!a)return;let l="string"==typeof r.name?r.name:"tool",i="string"==typeof r.phase?r.phase:"unknown",o="start"===i||"update"===i||"result"===i||"error"===i?i:"unknown",c="start"===o?r.args:void 0,d="update"===o?tM(r.partialResult):"result"===o?tM(r.result):"error"===o?tM(r.error??r.result):void 0,u=Date.now();tz.current&&tz.current!==s&&"start"===o&&tF(),tz.current=s;let m=tC.current.get(a);if(m?(m.name=l,m.phase=o,void 0!==c&&(m.args=c),void 0!==d&&(m.output=d),m.updatedAt=u):(m={toolCallId:a,runId:s,sessionKey:t,name:l,args:c,output:d,phase:o,startedAt:"number"==typeof e.ts?e.ts:u,updatedAt:u},tC.current.set(a,m),tS.current.push(a)),tS.current.length>50){let e=tS.current.length-50;for(let t of tS.current.splice(0,e))tC.current.delete(t)}tK("result"===o||"error"===o)},[tF,tK]),t2=(0,r.useMemo)(()=>{let e=[];for(let t of _){let n=tP(t);if(!n.internal)continue;let s=(n.displayText?.trim()??"").replace(/^System:\s*/i,"").trim();if(!s)continue;let{kind:r,tone:a}=function(e){let t=e.toLowerCase(),n=t.startsWith("heartbeat")||t.includes("heartbeat_ok")||t.includes("heartbeat"),s=/error|failed|denied|blocked|timeout|unavailable/i.test(t),r=/\[network\]|warning|alert/i.test(t);return s?{kind:"alert",tone:"error"}:r?{kind:"alert",tone:"warn"}:n?{kind:"heartbeat"}:{kind:"system"}}(s);e.push({id:`sys-${n.timestamp}-${e.length}`,kind:r,tone:a,text:s,timestamp:n.timestamp,source:"system"})}return e},[_]),t4=(0,r.useMemo)(()=>{let e=[];return eI.forEach((t,n)=>{let s=t$(t);if(!s)return;let r="alert"===t.indicatorType||"error"===t.indicatorType;e.push({id:`hb-${t.ts}-${n}`,kind:r?"alert":"heartbeat",tone:"error"===t.indicatorType?"error":r?"warn":void 0,text:s,timestamp:t.ts,source:"heartbeat"})}),e},[eI]),t3=(0,r.useMemo)(()=>{let e=[...t2,...t4].sort((e,t)=>t.timestamp-e.timestamp),t=new Set,n=[];for(let s of e){let e=`${s.source}-${s.timestamp}-${s.text}`;t.has(e)||(t.add(e),n.push(s))}return n},[t2,t4]),t6=(0,r.useMemo)(()=>{var e=function(e,t,n,s,r,a){let l=[],i=new Map;for(let n=0;n<e.length;n+=1){let s=e[n];i.set(s,n);let r=tP(s);!r.internal&&(t||"tool"!==r.role)&&l.push({kind:"message",normalized:r})}for(let t of n){let n=t_(t.text);l.some(s=>{var r;if("message"!==s.kind)return!1;let a=s.normalized;if(a.role!==t.role)return!1;let l=tL(a.raw),o=l?function(e){if(!e.includes("[message_id:"))return null;for(let t of e.split(/\r?\n/)){let e=t.match(tA);if(e)return(e[1]??"").trim()||null}return null}(l):null;if(o&&o===t.id)return!0;let c=t_(a.displayText);if(!c||!n||c!==n)return!1;let d="number"==typeof(r=a.raw.timestamp)&&Number.isFinite(r)?r<1e12?1e3*r:r:null;if(null!==d){let e=3e5>Math.abs(d-t.timestamp),n=d>=t.timestamp-5e3;return e&&n}let u=i.get(a.raw);return"number"==typeof u&&u>=e.length-5})||l.push({kind:"optimistic",message:t})}if(t)for(let e of s)l.push({kind:"tool-stream",entry:e});if(a&&r.length>0){let e=r[r.length-1];"assistant"===e.role&&l.push({kind:"stream",message:e,isStreaming:a})}return l}(_,eL,td,tR,U,en);let t=[],n=null;for(let s of e)if("message"===s.kind)n&&n.role===s.normalized.role?n.messages.push(s.normalized):(n&&t.push(n),n={kind:"group",role:s.normalized.role,messages:[s.normalized],timestamp:s.normalized.timestamp});else if(n&&(t.push(n),n=null),"optimistic"===s.kind)t.push({kind:"optimistic-group",messages:[s.message]});else if("tool-stream"===s.kind){let e=t[t.length-1];e&&"tool-stream-group"===e.kind?e.entries.push(s.entry):t.push({kind:"tool-stream-group",entries:[s.entry]})}else"stream"===s.kind?t.push({kind:"stream-group",message:s.message,isStreaming:s.isStreaming}):"indicator"===s.kind&&t.push({kind:"indicator-group",status:s.status});return n&&t.push(n),t},[_,eL,td,tR,U,en]),t9=t6.length>0||eL&&t3.length>0;(0,r.useEffect)(()=>{let e=t6.length;if(0===tH.current&&e>0){tH.current=e,tO.current=!0,b&&requestAnimationFrame(()=>tX("auto"));return}tO.current?requestAnimationFrame(()=>tX("smooth")):e>tH.current&&tH.current>0&&tG(t=>t+(e-tH.current)),tH.current=e},[t6.length,tX,b]);let t8=(0,r.useRef)(!1);(0,r.useEffect)(()=>{if(!b){t8.current=!1;return}!D&&(t8.current||(t8.current=!0,tO.current=!0,tG(0),requestAnimationFrame(()=>{tX("auto"),setTimeout(()=>tX("auto"),150)})))},[b,D,tX]);let t7=(0,r.useRef)(null),ne=(0,r.useCallback)(()=>{let e=V.current;e&&(t7.current={prevScrollHeight:e.scrollHeight,prevScrollTop:e.scrollTop}),I()},[I]);(0,r.useLayoutEffect)(()=>{let e=t7.current;if(!e)return;let t=V.current;if(!t)return;let n=t.scrollHeight-e.prevScrollHeight;0!==n&&(t.scrollTop=e.prevScrollTop+n),t7.current=null},[t6.length]),(0,r.useEffect)(()=>{en&&tO.current&&requestAnimationFrame(()=>tX("smooth"))},[en,U,tR,tX]),(0,r.useEffect)(()=>{if(!b)return;let e=null,t=null,n=!1,s=null;return!function r(){n||((e=new EventSource("/api/gateway/events")).addEventListener("gateway",e=>{try{let n=JSON.parse(e.data);if("number"==typeof n.seq&&(null!==s&&n.seq>s+1&&F({force:!0}),s=n.seq),"agent"===n.event&&n.payload&&t0(n.payload),"chat"===n.event&&n.payload){let e=n.payload,s=j.current||"main";if(y.current&&e.sessionKey&&e.sessionKey!==s)return;let r=e.state;("final"===r||"error"===r||"aborted"===r)&&(t&&(clearTimeout(t),t=null),F({force:!0}))}}catch{}}),e.onerror=()=>{e?.close(),e=null,n||setTimeout(r,5e3)})}(),()=>{n=!0,t&&clearTimeout(t),e?.close()}},[t0,b,F]);let[nt,nn]=(0,r.useState)([]),[ns,nr]=(0,r.useState)({}),[na,nl]=(0,r.useState)(!1),ni=(0,r.useCallback)(async e=>{let t=await tN(e);t.length>0&&(nn(e=>[...e,...t]),G.current?.focus())},[]),no=(0,r.useCallback)(e=>{nn(t=>t.filter(t=>t.id!==e))},[]),nc=(0,r.useCallback)(e=>{let t=e.clipboardData?.items;if(!t)return;let n=[];for(let e of Array.from(t))if("file"===e.kind&&tg.includes(e.type)){let t=e.getAsFile();t&&n.push(t)}n.length>0&&(e.preventDefault(),ni(n))},[ni]),nd=(0,r.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),e.dataTransfer?.types.includes("Files")&&nl(!0)},[]),nu=(0,r.useCallback)(e=>{e.preventDefault(),e.stopPropagation();let t=e.currentTarget.getBoundingClientRect(),{clientX:n,clientY:s}=e;(n<=t.left||n>=t.right||s<=t.top||s>=t.bottom)&&nl(!1)},[]),nm=(0,r.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),nl(!1);let t=Array.from(e.dataTransfer?.files??[]).filter(e=>tg.includes(e.type));t.length>0&&ni(t)},[ni]),nh=(0,r.useCallback)(e=>{let t=Array.from(e.target.files??[]);t.length>0&&ni(t),e.target.value=""},[ni]),nx=(0,r.useCallback)(()=>{O(new eP.ry({transport:tI()})),nn([]),eu([]),ec(!0),eh(!1),ep(""),Q.current=null,tu([]),nr({}),tF(),tf=[],tb=null,tm.current=null,G.current&&(G.current.value="",G.current.style.height="auto",G.current.focus())},[tF]);(0,r.useEffect)(()=>{if("default"===e)return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t);function t(e){e.metaKey&&e.shiftKey&&"l"===e.key&&(e.preventDefault(),n(!0))}},[n,e]),(0,r.useEffect)(()=>{if(t||"default"!==e){let e=setTimeout(()=>{G.current?.focus()},100);return()=>clearTimeout(e)}},[t,e]);let np=(0,r.useCallback)(async(e,t)=>{if(eD)return;let n=nt.length>0;if(!e.trim()&&!n)return;let s=e.trim()||(n?"What's in this image?":"");if(!s)return;tF();let r=t?.messageId?.trim()||crypto.randomUUID(),a=nt.map(e=>e.dataUrl),l={id:r,role:"user",text:s,images:a.length>0?a:void 0,timestamp:Date.now(),status:"sending"};tu(e=>[...e,l]),a.length>0&&nr(e=>({...e,[r]:a})),tm.current=r,T.current=Date.now(),nn([]),G.current&&(G.current.value="",G.current.style.height="auto"),eh(!1),ep(""),Q.current=null,tf=a,tb=e8();try{await q({text:s}),setTimeout(()=>{tu(e=>e.map(e=>e.id===r&&"sending"===e.status?{...e,status:"sent"}:e))},2e3)}catch(e){console.error("[chat] sendMessage error:",e),t?.messageId&&(tx.current=tx.current.filter(e=>e!==t.messageId),ty.current===t.messageId&&(ty.current=null,tk.current="")),tu(e=>e.map(e=>e.id===r?{...e,status:"error"}:e))}tf=[],tb=null},[eD,q,nt,e8,tF]);(0,r.useEffect)(()=>{let e=e=>{let s=e.detail??{},r=s.messageId?.trim()||crypto.randomUUID(),l=function(e,t){if(e.message&&e.message.trim()){let t=[e.message.trim()];return e.messageId?.trim()&&t.push(`[message_id: ${e.messageId.trim()}]`),t.join("\n\n")}if(!e.action)return null;let n=e.selection?.trim()??"",s=(e.pagePath??t??"").trim(),r=n.length>0,a="continue"===e.action?r?"context below":"referenced page":r?"selected text":"referenced page",l=[function(e,t){switch(e){case"improve":return`Improve the writing of the ${t}. Return only the improved text.`;case"simplify":return`Simplify the ${t} while preserving meaning. Return only the simplified text.`;case"expand":return`Expand the ${t} with more detail while preserving meaning. Return only the expanded text.`;case"summarize":return`Summarize the ${t} concisely. Return only the summary.`;case"fix-grammar":return`Fix grammar, spelling, and punctuation in the ${t}. Return only the corrected text.`;case"continue":return`Continue writing from the ${t}. Return only the continuation.`;default:return`Please help with the ${t}.`}}(e.action,a)];return s&&l.push(`Reference: ${s}`),n&&l.push(`Selected text:
4
4
  """
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6364],{1934:(e,t,s)=>{"use strict";s.d(t,{v:()=>i});var a=s(12115);let r=e=>{let t,s=new Set,a=(e,a)=>{let r="function"==typeof e?e(t):e;if(!Object.is(r,t)){let e=t;t=(null!=a?a:"object"!=typeof r||null===r)?r:Object.assign({},t,r),s.forEach(s=>s(t,e))}},r=()=>t,n={setState:a,getState:r,getInitialState:()=>i,subscribe:e=>(s.add(e),()=>s.delete(e))},i=t=e(a,r,n);return n},n=e=>{let t=e?r(e):r,s=e=>(function(e,t=e=>e){let s=a.useSyncExternalStore(e.subscribe,a.useCallback(()=>t(e.getState()),[e,t]),a.useCallback(()=>t(e.getInitialState()),[e,t]));return a.useDebugValue(s),s})(t,e);return Object.assign(s,t),s},i=e=>e?n(e):n},7814:(e,t,s)=>{"use strict";function a(e){let t=e.replace(/\.md$/,"").split("/").filter(Boolean).map(e=>encodeURIComponent(e));return 0===t.length?"/workspace":`/workspace/${t.join("/")}`}s.d(t,{C:()=>a})},27027:(e,t,s)=>{Promise.resolve().then(s.bind(s,59176))},32967:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});let a=(0,s(90425).A)("wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]])},51914:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});let a=(0,s(90425).A)("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},53536:(e,t,s)=>{"use strict";function a(e){let t=new Date(e),s=Math.floor((new Date().getTime()-t.getTime())/1e3),a=Math.floor(s/60),r=Math.floor(a/60),n=Math.floor(r/24);return s<60?"just now":a<60?`${a}m`:r<24?`${r}h`:1===n?"Yesterday":n<7?`${n}d`:n<30?`${Math.floor(n/7)}w`:t.toLocaleDateString("en-US",{month:"short",day:"numeric"})}s.d(t,{f:()=>a})},59176:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>v});var a=s(95155),r=s(12115),n=s(73321),i=s(51914),l=s(61878),c=s(32967),o=s(84980),d=s(89239),u=s(18496),m=s(53536),p=s(52799),h=s(93571),g=s(60464),x=s(7814);function f(){let e=(0,n.useSearchParams)(),t=(0,n.useRouter)(),s=(0,u.M)(e=>e.setChatPanelOpen);return(0,r.useEffect)(()=>{"open"===e.get("chat")&&(s(!0),t.replace("/workspace",{scroll:!1}))},[e,s,t]),null}function v(){let e=(0,n.useRouter)(),{recentPages:t,spaces:s,loadRecentPages:v,loadSpaces:w,spacesStatus:b,recentStatus:j}=(0,u.M)(),[k,y]=(0,r.useState)(!1),[N,C]=(0,r.useState)(!1),[S,z]=(0,r.useState)(null);if((0,r.useEffect)(()=>{let t=!1,s=new AbortController,a=setTimeout(()=>s.abort(),8e3);return fetch("/api/setup/status",{signal:s.signal}).then(e=>e.ok?e.json():null).then(s=>{t||(!s?.hasWorkspace||s?.needsSetupSignal?e.replace("/setup"):y(!0))}).catch(()=>{t||y(!0)}).finally(()=>{clearTimeout(a)}),()=>{t=!0,s.abort(),clearTimeout(a)}},[e]),(0,r.useEffect)(()=>{k&&(v(),w())},[v,w,k]),!k)return(0,a.jsx)("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",children:"Loading workspace..."});let A=async()=>{C(!0),z(null);try{let e=await fetch("/api/setup/bootstrap",{method:"POST"});if(!e.ok){let t=await e.json();throw Error(t?.error||"Failed to bootstrap workspace")}await w(),await v()}catch(e){z(e.message)}finally{C(!1)}};return(0,a.jsxs)("div",{className:"flex h-full flex-col items-center justify-center px-4",children:[(0,a.jsx)(r.Suspense,{fallback:null,children:(0,a.jsx)(f,{})}),(0,a.jsxs)("div",{className:"max-w-lg w-full space-y-8 text-center",children:[(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsx)("div",{className:"mx-auto flex h-16 w-16 items-center justify-center rounded-2xl bg-muted/60 ring-1 ring-border/50",children:(0,a.jsx)(h.R,{variant:"icon",size:36,alt:""})}),(0,a.jsx)("h1",{className:"text-2xl font-semibold tracking-tight",children:"Welcome to ClawPad"}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground max-w-sm mx-auto",children:"Your workspace for OpenClaw. Select a page from the sidebar or create a new one to get started."})]}),(0,a.jsxs)("div",{className:"flex items-center justify-center gap-3",children:[(0,a.jsxs)(d.$,{onClick:()=>{window.dispatchEvent(new CustomEvent("clawpad:open-new-page",{detail:{mode:"document"}}))},children:[(0,a.jsx)(i.A,{className:"mr-2 h-4 w-4"}),"New Document"]}),(0,a.jsxs)(d.$,{variant:"outline",onClick:()=>{window.dispatchEvent(new CustomEvent("clawpad:open-command-palette"))},children:[(0,a.jsx)(l.A,{className:"mr-2 h-4 w-4"}),"Search"]}),(0,a.jsxs)(d.$,{variant:"secondary",onClick:()=>{let e=["Please update ClawPad and the OpenClaw CLI on this machine.","Run the following in a terminal, then confirm when done:","u">typeof navigator&&/windows/i.test(navigator.userAgent||navigator.platform||"")?"npm install -g clawpad@latest && npm install -g openclaw@latest":"npm install -g clawpad@latest && npm install -g openclaw@latest # or: brew upgrade clawpad openclaw"].join("\n\n");window.dispatchEvent(new CustomEvent("clawpad:ai-action",{detail:{message:e}}))},children:[(0,a.jsx)(c.A,{className:"mr-2 h-4 w-4"}),"Ask Agent to Update"]})]}),0===s.length&&0===t.length&&"loading"!==b&&"loading"!==j&&(0,a.jsxs)("div",{className:"rounded-lg border border-border/60 bg-muted/20 p-4 text-sm text-muted-foreground",children:[(0,a.jsx)("div",{className:"mb-3 font-medium text-foreground",children:"No workspace yet"}),(0,a.jsx)("p",{className:"mb-4 text-xs",children:"Create a starter workspace with default spaces and a welcome page."}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[(0,a.jsx)(d.$,{size:"sm",onClick:A,disabled:N,children:N?"Creating…":"Create starter workspace"}),(0,a.jsx)(d.$,{size:"sm",variant:"outline",onClick:()=>e.push("/setup"),children:"Open setup"})]}),S&&(0,a.jsx)("p",{className:"mt-3 text-xs text-rose-500",children:S})]}),t.length>0&&(0,a.jsxs)("div",{className:"space-y-3 pt-4",children:[(0,a.jsx)("h2",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"Recent Pages"}),(0,a.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:t.slice(0,6).map(t=>(0,a.jsxs)("button",{onClick:()=>{var s;return s=t.path,void e.push((0,x.C)(s))},className:(0,p.cn)("flex items-center gap-3 rounded-lg border border-border/50 p-3 text-left","transition-colors duration-200 hover:bg-muted/50 hover:border-border"),children:[(0,a.jsx)("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-muted text-sm",children:t.icon??"\uD83D\uDCC4"}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsx)("p",{className:"truncate text-sm font-medium",children:t.title}),(0,a.jsxs)("div",{className:"flex items-center gap-1 text-[11px] text-muted-foreground",children:[(0,a.jsx)(o.A,{className:"h-3 w-3"}),(0,a.jsx)("span",{children:(0,m.f)(t.modified)}),(0,a.jsx)("span",{className:"text-muted-foreground/40",children:"\xb7"}),(0,a.jsx)("span",{children:t.space===g.Sz?g.ke:t.space})]})]})]},t.path))})]})]})]})}},61878:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});let a=(0,s(90425).A)("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]])},84980:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});let a=(0,s(90425).A)("clock",[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]])},89239:(e,t,s)=>{"use strict";s.d(t,{$:()=>c});var a=s(95155);s(12115);var r=s(18460),n=s(42442),i=s(52799);let l=(0,r.F)("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",xs:"h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-xs":"size-6 rounded-md [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function c({className:e,variant:t="default",size:s="default",asChild:r=!1,...c}){let o=r?n.bL:"button";return(0,a.jsx)(o,{"data-slot":"button","data-variant":t,"data-size":s,className:(0,i.cn)(l({variant:t,size:s,className:e})),...c})}},93571:(e,t,s)=>{"use strict";s.d(t,{R:()=>c});var a=s(95155),r=s(5772),n=s(52799);let i=265/235,l=1152/235;function c({variant:e="icon",size:t=24,className:s,imageClassName:c,lightImageClassName:o,darkImageClassName:d,theme:u="auto",alt:m="ClawPad",priority:p=!1}){let h="icon"===e,g=Math.round(t*(h?i:l));return(0,a.jsx)("span",{className:(0,n.cn)("inline-flex items-center",s),children:(0,a.jsx)(r.default,{src:h?"/brand/icon.png":"/brand/logo.png",width:g,height:t,alt:m,priority:p,className:(0,n.cn)("block",c,"dark"===u?d:"light"===u?o:void 0)})})}}},e=>{e.O(0,[330,5403,1178,8441,3794,7358],()=>e(e.s=27027)),_N_E=e.O()}]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clawpad",
3
- "version": "0.3.10",
3
+ "version": "0.3.11",
4
4
  "description": "A file-based, Notion-style document workspace for OpenClaw",
5
5
  "keywords": [
6
6
  "openclaw",
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6364],{1934:(e,t,s)=>{"use strict";s.d(t,{v:()=>i});var r=s(12115);let a=e=>{let t,s=new Set,r=(e,r)=>{let a="function"==typeof e?e(t):e;if(!Object.is(a,t)){let e=t;t=(null!=r?r:"object"!=typeof a||null===a)?a:Object.assign({},t,a),s.forEach(s=>s(t,e))}},a=()=>t,n={setState:r,getState:a,getInitialState:()=>i,subscribe:e=>(s.add(e),()=>s.delete(e))},i=t=e(r,a,n);return n},n=e=>{let t=e?a(e):a,s=e=>(function(e,t=e=>e){let s=r.useSyncExternalStore(e.subscribe,r.useCallback(()=>t(e.getState()),[e,t]),r.useCallback(()=>t(e.getInitialState()),[e,t]));return r.useDebugValue(s),s})(t,e);return Object.assign(s,t),s},i=e=>e?n(e):n},7814:(e,t,s)=>{"use strict";function r(e){let t=e.replace(/\.md$/,"").split("/").filter(Boolean).map(e=>encodeURIComponent(e));return 0===t.length?"/workspace":`/workspace/${t.join("/")}`}s.d(t,{C:()=>r})},27027:(e,t,s)=>{Promise.resolve().then(s.bind(s,59176))},51914:(e,t,s)=>{"use strict";s.d(t,{A:()=>r});let r=(0,s(90425).A)("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},53536:(e,t,s)=>{"use strict";function r(e){let t=new Date(e),s=Math.floor((new Date().getTime()-t.getTime())/1e3),r=Math.floor(s/60),a=Math.floor(r/60),n=Math.floor(a/24);return s<60?"just now":r<60?`${r}m`:a<24?`${a}h`:1===n?"Yesterday":n<7?`${n}d`:n<30?`${Math.floor(n/7)}w`:t.toLocaleDateString("en-US",{month:"short",day:"numeric"})}s.d(t,{f:()=>r})},59176:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>f});var r=s(95155),a=s(12115),n=s(73321),i=s(51914),l=s(61878),c=s(84980),o=s(89239),d=s(18496),u=s(53536),m=s(52799),h=s(93571),p=s(60464),x=s(7814);function g(){let e=(0,n.useSearchParams)(),t=(0,n.useRouter)(),s=(0,d.M)(e=>e.setChatPanelOpen);return(0,a.useEffect)(()=>{"open"===e.get("chat")&&(s(!0),t.replace("/workspace",{scroll:!1}))},[e,s,t]),null}function f(){let e=(0,n.useRouter)(),{recentPages:t,spaces:s,loadRecentPages:f,loadSpaces:v,spacesStatus:b,recentStatus:j}=(0,d.M)(),[w,k]=(0,a.useState)(!1),[y,N]=(0,a.useState)(!1),[C,S]=(0,a.useState)(null);if((0,a.useEffect)(()=>{let t=!1,s=new AbortController,r=setTimeout(()=>s.abort(),8e3);return fetch("/api/setup/status",{signal:s.signal}).then(e=>e.ok?e.json():null).then(s=>{t||(!s?.hasWorkspace||s?.needsSetupSignal?e.replace("/setup"):k(!0))}).catch(()=>{t||k(!0)}).finally(()=>{clearTimeout(r)}),()=>{t=!0,s.abort(),clearTimeout(r)}},[e]),(0,a.useEffect)(()=>{w&&(f(),v())},[f,v,w]),!w)return(0,r.jsx)("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",children:"Loading workspace..."});let z=async()=>{N(!0),S(null);try{let e=await fetch("/api/setup/bootstrap",{method:"POST"});if(!e.ok){let t=await e.json();throw Error(t?.error||"Failed to bootstrap workspace")}await v(),await f()}catch(e){S(e.message)}finally{N(!1)}};return(0,r.jsxs)("div",{className:"flex h-full flex-col items-center justify-center px-4",children:[(0,r.jsx)(a.Suspense,{fallback:null,children:(0,r.jsx)(g,{})}),(0,r.jsxs)("div",{className:"max-w-lg w-full space-y-8 text-center",children:[(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)("div",{className:"mx-auto flex h-16 w-16 items-center justify-center rounded-2xl bg-muted/60 ring-1 ring-border/50",children:(0,r.jsx)(h.R,{variant:"icon",size:36,alt:""})}),(0,r.jsx)("h1",{className:"text-2xl font-semibold tracking-tight",children:"Welcome to ClawPad"}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground max-w-sm mx-auto",children:"Your workspace for OpenClaw. Select a page from the sidebar or create a new one to get started."})]}),(0,r.jsxs)("div",{className:"flex items-center justify-center gap-3",children:[(0,r.jsxs)(o.$,{onClick:()=>{window.dispatchEvent(new CustomEvent("clawpad:open-new-page",{detail:{mode:"document"}}))},children:[(0,r.jsx)(i.A,{className:"mr-2 h-4 w-4"}),"New Document"]}),(0,r.jsxs)(o.$,{variant:"outline",onClick:()=>{window.dispatchEvent(new CustomEvent("clawpad:open-command-palette"))},children:[(0,r.jsx)(l.A,{className:"mr-2 h-4 w-4"}),"Search"]})]}),0===s.length&&0===t.length&&"loading"!==b&&"loading"!==j&&(0,r.jsxs)("div",{className:"rounded-lg border border-border/60 bg-muted/20 p-4 text-sm text-muted-foreground",children:[(0,r.jsx)("div",{className:"mb-3 font-medium text-foreground",children:"No workspace yet"}),(0,r.jsx)("p",{className:"mb-4 text-xs",children:"Create a starter workspace with default spaces and a welcome page."}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[(0,r.jsx)(o.$,{size:"sm",onClick:z,disabled:y,children:y?"Creating…":"Create starter workspace"}),(0,r.jsx)(o.$,{size:"sm",variant:"outline",onClick:()=>e.push("/setup"),children:"Open setup"})]}),C&&(0,r.jsx)("p",{className:"mt-3 text-xs text-rose-500",children:C})]}),t.length>0&&(0,r.jsxs)("div",{className:"space-y-3 pt-4",children:[(0,r.jsx)("h2",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"Recent Pages"}),(0,r.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:t.slice(0,6).map(t=>(0,r.jsxs)("button",{onClick:()=>{var s;return s=t.path,void e.push((0,x.C)(s))},className:(0,m.cn)("flex items-center gap-3 rounded-lg border border-border/50 p-3 text-left","transition-colors duration-200 hover:bg-muted/50 hover:border-border"),children:[(0,r.jsx)("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-muted text-sm",children:t.icon??"\uD83D\uDCC4"}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("p",{className:"truncate text-sm font-medium",children:t.title}),(0,r.jsxs)("div",{className:"flex items-center gap-1 text-[11px] text-muted-foreground",children:[(0,r.jsx)(c.A,{className:"h-3 w-3"}),(0,r.jsx)("span",{children:(0,u.f)(t.modified)}),(0,r.jsx)("span",{className:"text-muted-foreground/40",children:"\xb7"}),(0,r.jsx)("span",{children:t.space===p.Sz?p.ke:t.space})]})]})]},t.path))})]})]})]})}},61878:(e,t,s)=>{"use strict";s.d(t,{A:()=>r});let r=(0,s(90425).A)("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]])},84980:(e,t,s)=>{"use strict";s.d(t,{A:()=>r});let r=(0,s(90425).A)("clock",[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]])},89239:(e,t,s)=>{"use strict";s.d(t,{$:()=>c});var r=s(95155);s(12115);var a=s(18460),n=s(42442),i=s(52799);let l=(0,a.F)("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",xs:"h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-xs":"size-6 rounded-md [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function c({className:e,variant:t="default",size:s="default",asChild:a=!1,...c}){let o=a?n.bL:"button";return(0,r.jsx)(o,{"data-slot":"button","data-variant":t,"data-size":s,className:(0,i.cn)(l({variant:t,size:s,className:e})),...c})}},93571:(e,t,s)=>{"use strict";s.d(t,{R:()=>c});var r=s(95155),a=s(5772),n=s(52799);let i=265/235,l=1152/235;function c({variant:e="icon",size:t=24,className:s,imageClassName:c,lightImageClassName:o,darkImageClassName:d,theme:u="auto",alt:m="ClawPad",priority:h=!1}){let p="icon"===e,x=Math.round(t*(p?i:l));return(0,r.jsx)("span",{className:(0,n.cn)("inline-flex items-center",s),children:(0,r.jsx)(a.default,{src:p?"/brand/icon.png":"/brand/logo.png",width:x,height:t,alt:m,priority:h,className:(0,n.cn)("block",c,"dark"===u?d:"light"===u?o:void 0)})})}}},e=>{e.O(0,[330,5403,1178,8441,3794,7358],()=>e(e.s=27027)),_N_E=e.O()}]);