wiki-viewer 2.5.1 → 2.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. package/.next/standalone/.next/BUILD_ID +1 -1
  2. package/.next/standalone/.next/build-manifest.json +3 -3
  3. package/.next/standalone/.next/prerender-manifest.json +3 -3
  4. package/.next/standalone/.next/server/app/_global-error.html +1 -1
  5. package/.next/standalone/.next/server/app/_global-error.rsc +1 -1
  6. package/.next/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  7. package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  8. package/.next/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  9. package/.next/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  10. package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  11. package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  12. package/.next/standalone/.next/server/app/_not-found.html +1 -1
  13. package/.next/standalone/.next/server/app/_not-found.rsc +2 -2
  14. package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
  15. package/.next/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  16. package/.next/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
  17. package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  18. package/.next/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  19. package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  20. package/.next/standalone/.next/server/app/api/agent/activity/route.js.nft.json +1 -1
  21. package/.next/standalone/.next/server/app/api/agent/events/[...path]/route.js.nft.json +1 -1
  22. package/.next/standalone/.next/server/app/api/agent/files/[...path]/route.js.nft.json +1 -1
  23. package/.next/standalone/.next/server/app/api/agent/fs/file/[...path]/route.js.nft.json +1 -1
  24. package/.next/standalone/.next/server/app/api/agent/fs/ls/[[...path]]/route.js.nft.json +1 -1
  25. package/.next/standalone/.next/server/app/api/agent/fs/move/route.js.nft.json +1 -1
  26. package/.next/standalone/.next/server/app/api/agent/fs/search/route.js.nft.json +1 -1
  27. package/.next/standalone/.next/server/app/api/agent/internal/span/route.js.nft.json +1 -1
  28. package/.next/standalone/.next/server/app/api/agent/settings/route.js.nft.json +1 -1
  29. package/.next/standalone/.next/server/app/api/agent/sidecar/[...path]/route.js.nft.json +1 -1
  30. package/.next/standalone/.next/server/app/api/assets/[...path]/route.js.nft.json +1 -1
  31. package/.next/standalone/.next/server/app/api/pdf/save/route.js.nft.json +1 -1
  32. package/.next/standalone/.next/server/app/api/share/[token]/route.js.nft.json +1 -1
  33. package/.next/standalone/.next/server/app/api/share/route.js.nft.json +1 -1
  34. package/.next/standalone/.next/server/app/api/system/reveal/route.js.nft.json +1 -1
  35. package/.next/standalone/.next/server/app/api/system/set-root/route.js.nft.json +1 -1
  36. package/.next/standalone/.next/server/app/api/system/workspaces/[id]/branch/route.js.nft.json +1 -1
  37. package/.next/standalone/.next/server/app/api/system/workspaces/[id]/open/route.js.nft.json +1 -1
  38. package/.next/standalone/.next/server/app/api/system/workspaces/[id]/refresh/route.js.nft.json +1 -1
  39. package/.next/standalone/.next/server/app/api/system/workspaces/[id]/route.js.nft.json +1 -1
  40. package/.next/standalone/.next/server/app/api/system/workspaces/route.js.nft.json +1 -1
  41. package/.next/standalone/.next/server/app/api/upload/[...path]/route.js.nft.json +1 -1
  42. package/.next/standalone/.next/server/app/api/wiki/app/route.js.nft.json +1 -1
  43. package/.next/standalone/.next/server/app/api/wiki/backlinks/route.js.nft.json +1 -1
  44. package/.next/standalone/.next/server/app/api/wiki/content/route.js.nft.json +1 -1
  45. package/.next/standalone/.next/server/app/api/wiki/download/route.js.nft.json +1 -1
  46. package/.next/standalone/.next/server/app/api/wiki/file/route.js.nft.json +1 -1
  47. package/.next/standalone/.next/server/app/api/wiki/folder/route.js.nft.json +1 -1
  48. package/.next/standalone/.next/server/app/api/wiki/git-branches/route.js.nft.json +1 -1
  49. package/.next/standalone/.next/server/app/api/wiki/git-checkout/route.js.nft.json +1 -1
  50. package/.next/standalone/.next/server/app/api/wiki/git-diff/route.js.nft.json +1 -1
  51. package/.next/standalone/.next/server/app/api/wiki/git-file-info/route.js.nft.json +1 -1
  52. package/.next/standalone/.next/server/app/api/wiki/git-history/route.js.nft.json +1 -1
  53. package/.next/standalone/.next/server/app/api/wiki/git-pull/route.js.nft.json +1 -1
  54. package/.next/standalone/.next/server/app/api/wiki/move/route.js.nft.json +1 -1
  55. package/.next/standalone/.next/server/app/api/wiki/new-file/route.js.nft.json +1 -1
  56. package/.next/standalone/.next/server/app/api/wiki/outlinks/route.js.nft.json +1 -1
  57. package/.next/standalone/.next/server/app/api/wiki/page/route.js.nft.json +1 -1
  58. package/.next/standalone/.next/server/app/api/wiki/presence/route.js.nft.json +1 -1
  59. package/.next/standalone/.next/server/app/api/wiki/route.js.nft.json +1 -1
  60. package/.next/standalone/.next/server/app/api/wiki/search/route.js.nft.json +1 -1
  61. package/.next/standalone/.next/server/app/api/wiki/slugs/route.js.nft.json +1 -1
  62. package/.next/standalone/.next/server/app/api/wiki/upload/route.js.nft.json +1 -1
  63. package/.next/standalone/.next/server/app/api/wiki/watch/route.js.nft.json +1 -1
  64. package/.next/standalone/.next/server/app/index.html +1 -1
  65. package/.next/standalone/.next/server/app/index.rsc +3 -3
  66. package/.next/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
  67. package/.next/standalone/.next/server/app/index.segments/_full.segment.rsc +3 -3
  68. package/.next/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
  69. package/.next/standalone/.next/server/app/index.segments/_index.segment.rsc +2 -2
  70. package/.next/standalone/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  71. package/.next/standalone/.next/server/app/page.js.nft.json +1 -1
  72. package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  73. package/.next/standalone/.next/server/app/s/[token]/page.js.nft.json +1 -1
  74. package/.next/standalone/.next/server/app/s/[token]/page_client-reference-manifest.js +1 -1
  75. package/.next/standalone/.next/server/app/signin/page_client-reference-manifest.js +1 -1
  76. package/.next/standalone/.next/server/chunks/ssr/{0~w0_katex_dist_katex_mjs_0awdhzw._.js → 0~w0_katex_dist_katex_mjs_099a06d._.js} +1 -1
  77. package/.next/standalone/.next/server/chunks/ssr/{0~w0_katex_dist_katex_mjs_0~_hj~1._.js → 0~w0_katex_dist_katex_mjs_0s5pk00._.js} +1 -1
  78. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__0iccgou._.js → [root-of-the-server]__0.iwrh8._.js} +2 -2
  79. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__0w2ebbx._.js → [root-of-the-server]__0m_fh__._.js} +2 -2
  80. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0txwwn-._.js +1 -1
  81. package/.next/standalone/.next/server/chunks/ssr/_0kcfv3r._.js +2 -2
  82. package/.next/standalone/.next/server/chunks/ssr/_0sxeqi8._.js +2 -2
  83. package/.next/standalone/.next/server/chunks/ssr/_0v4uz-4._.js +2 -2
  84. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0ve~5~d._.js → node_modules__pnpm_0-y2z3f._.js} +2 -2
  85. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0u3p3__._.js → node_modules__pnpm_0.ktp2f._.js} +1 -1
  86. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_02vvjkq._.js → node_modules__pnpm_0.wgnmo._.js} +1 -1
  87. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0d3tlox._.js → node_modules__pnpm_006o64y._.js} +1 -1
  88. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0w3.bto._.js → node_modules__pnpm_01a5v1f._.js} +1 -1
  89. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0g7aqxf._.js → node_modules__pnpm_01d7xgc._.js} +2 -2
  90. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0.xr5on._.js → node_modules__pnpm_03ngsnv._.js} +1 -1
  91. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0nystoo._.js → node_modules__pnpm_03yghpt._.js} +1 -1
  92. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0rov440._.js → node_modules__pnpm_06haduc._.js} +1 -1
  93. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0~5s0h-._.js → node_modules__pnpm_06pxh4v._.js} +1 -1
  94. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_00lsym6._.js → node_modules__pnpm_07uo6lf._.js} +1 -1
  95. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_07~8560._.js → node_modules__pnpm_080ky2j._.js} +2 -2
  96. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0j2ck16._.js → node_modules__pnpm_08rypvm._.js} +1 -1
  97. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_09domom._.js → node_modules__pnpm_09n5z4r._.js} +1 -1
  98. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_13kfm1k._.js → node_modules__pnpm_0_8jy20._.js} +2 -2
  99. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0w~3li6._.js → node_modules__pnpm_0_vbya3._.js} +1 -1
  100. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0.t~niv._.js → node_modules__pnpm_0b~f60.._.js} +1 -1
  101. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_10y-1uw._.js → node_modules__pnpm_0cfmtvi._.js} +1 -1
  102. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0c5xt34._.js → node_modules__pnpm_0cv8ur~._.js} +1 -1
  103. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_028urv0._.js → node_modules__pnpm_0c~~s5f._.js} +1 -1
  104. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0viyj44._.js → node_modules__pnpm_0elbth.._.js} +2 -2
  105. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0783up1._.js → node_modules__pnpm_0gkc-q4._.js} +1 -1
  106. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0g~umi9._.js → node_modules__pnpm_0h2eyq-._.js} +1 -1
  107. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0cy5ftq._.js → node_modules__pnpm_0hdpc2i._.js} +2 -2
  108. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_09dbqv9._.js → node_modules__pnpm_0iiz5x0._.js} +1 -1
  109. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0zt6ord._.js → node_modules__pnpm_0j4w26r._.js} +2 -2
  110. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0~gr25-._.js → node_modules__pnpm_0jha_p~._.js} +1 -1
  111. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_04hymjt._.js → node_modules__pnpm_0k7tyhq._.js} +2 -2
  112. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_09gq0e4._.js → node_modules__pnpm_0k9m4v-._.js} +2 -2
  113. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0rg4j~u._.js → node_modules__pnpm_0lgmq.y._.js} +1 -1
  114. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_131u09o._.js → node_modules__pnpm_0mnke-x._.js} +1 -1
  115. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0abi.df._.js → node_modules__pnpm_0mts391._.js} +1 -1
  116. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0_zq~v6._.js → node_modules__pnpm_0nh3omg._.js} +1 -1
  117. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_07mf98k._.js → node_modules__pnpm_0nilz5o._.js} +2 -2
  118. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_070uyez._.js → node_modules__pnpm_0o-arwk._.js} +1 -1
  119. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0bwtedy._.js → node_modules__pnpm_0oa3ogf._.js} +1 -1
  120. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_11fu.e3._.js → node_modules__pnpm_0ofl~h9._.js} +2 -2
  121. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0t16czj._.js → node_modules__pnpm_0p6ykp-._.js} +1 -1
  122. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0~xns8v._.js → node_modules__pnpm_0rfzhs_._.js} +1 -1
  123. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0goz.0g._.js → node_modules__pnpm_0rr59ws._.js} +1 -1
  124. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_05py9u6._.js → node_modules__pnpm_0rwoqnq._.js} +1 -1
  125. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_01uc1hl._.js → node_modules__pnpm_0r~~958._.js} +1 -1
  126. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0jywdw0._.js → node_modules__pnpm_0sgwwbr._.js} +1 -1
  127. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0of-lo7._.js → node_modules__pnpm_0tokt~.._.js} +1 -1
  128. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0w.ycij._.js → node_modules__pnpm_0txagke._.js} +1 -1
  129. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0~l___j._.js → node_modules__pnpm_0yl6x61._.js} +2 -2
  130. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0cvf5tj._.js → node_modules__pnpm_0y~90z9._.js} +2 -2
  131. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0l1oi2n._.js → node_modules__pnpm_0zb~3w8._.js} +1 -1
  132. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_01~a~.j._.js → node_modules__pnpm_1146reo._.js} +1 -1
  133. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_07.uhcc._.js → node_modules__pnpm_123k6e8._.js} +2 -2
  134. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_11-1cme._.js → node_modules__pnpm_12i5i9_._.js} +1 -1
  135. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_134w.0n._.js → node_modules__pnpm_12t_ewq._.js} +1 -1
  136. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0u93cu-._.js → node_modules__pnpm_1317vwj._.js} +1 -1
  137. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0h8t6~c._.js → node_modules__pnpm_1360odf._.js} +1 -1
  138. package/.next/standalone/.next/server/middleware-build-manifest.js +3 -3
  139. package/.next/standalone/.next/server/middleware-manifest.json +5 -5
  140. package/.next/standalone/.next/server/pages/404.html +1 -1
  141. package/.next/standalone/.next/server/pages/500.html +1 -1
  142. package/.next/standalone/.next/server/server-reference-manifest.js +1 -1
  143. package/.next/standalone/.next/server/server-reference-manifest.json +1 -1
  144. package/.next/standalone/.next/static/chunks/{0alhqgtsl8w~~.js → 00xtxs2ylg-v2.js} +2 -2
  145. package/.next/standalone/.next/static/chunks/{0zyv6qhtr6a2j.js → 0gl6v9.~903y1.js} +2 -2
  146. package/.next/standalone/.next/static/chunks/{0qjwq.dzmp2b-.css → 0ncw5hhg~98~p.css} +1 -1
  147. package/.next/standalone/.next/static/chunks/{0on-0-cxvzy-7.js → 16fdw_k6fmj1w.js} +2 -2
  148. package/.next/standalone/package.json +1 -1
  149. package/package.json +1 -1
  150. /package/.next/standalone/.next/static/{5u7laVzuvEqpxLN3F9CCd → 1dT3by-wtO_90-j9Bm33U}/_buildManifest.js +0 -0
  151. /package/.next/standalone/.next/static/{5u7laVzuvEqpxLN3F9CCd → 1dT3by-wtO_90-j9Bm33U}/_clientMiddlewareManifest.js +0 -0
  152. /package/.next/standalone/.next/static/{5u7laVzuvEqpxLN3F9CCd → 1dT3by-wtO_90-j9Bm33U}/_ssgManifest.js +0 -0
@@ -1,6 +1,6 @@
1
1
  module.exports=[40445,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0});var d={BailoutToCSRError:function(){return g},isBailoutToCSRError:function(){return h}};for(var e in d)Object.defineProperty(c,e,{enumerable:!0,get:d[e]});let f="BAILOUT_TO_CLIENT_SIDE_RENDERING";class g extends Error{constructor(a){super(`Bail out to client-side rendering: ${a}`),this.reason=a,this.digest=f}}function h(a){return"object"==typeof a&&null!==a&&"digest"in a&&a.digest===f}},719123,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0}),Object.defineProperty(c,"BailoutToCSR",{enumerable:!0,get:function(){return e}});let d=a.r(40445);function e({reason:a,children:b}){throw Object.defineProperty(new d.BailoutToCSRError(a),"__NEXT_ERROR_CODE",{value:"E394",enumerable:!1,configurable:!0})}},912280,(a,b,c)=>{"use strict";function d(a){return a.split("/").map(a=>encodeURIComponent(a)).join("/")}Object.defineProperty(c,"__esModule",{value:!0}),Object.defineProperty(c,"encodeURIPath",{enumerable:!0,get:function(){return d}})},598909,(a,b,c)=>{"use strict";let d;Object.defineProperty(c,"__esModule",{value:!0});var e={getAssetToken:function(){return i},getAssetTokenQuery:function(){return j},getDeploymentId:function(){return g},getDeploymentIdQuery:function(){return h}};for(var f in e)Object.defineProperty(c,f,{enumerable:!0,get:e[f]});function g(){return d}function h(a=!1){return d?`${a?"&":"?"}dpl=${d}`:""}function i(){return!1}function j(a=!1){return""}d=void 0},494130,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0}),Object.defineProperty(c,"PreloadChunks",{enumerable:!0,get:function(){return i}});let d=a.r(634020),e=a.r(525704),f=a.r(556704),g=a.r(912280),h=a.r(598909);function i({moduleIds:a}){let b=f.workAsyncStorage.getStore();if(void 0===b)return null;let c=[];if(b.reactLoadableManifest&&a){let d=b.reactLoadableManifest;for(let b of a){if(!d[b])continue;let a=d[b].files;c.push(...a)}}if(0===c.length)return null;let j=(0,h.getAssetTokenQuery)();return(0,d.jsx)(d.Fragment,{children:c.map(a=>{let c=`${b.assetPrefix}/_next/${(0,g.encodeURIPath)(a)}${j}`;return a.endsWith(".css")?(0,d.jsx)("link",{precedence:"dynamic",href:c,rel:"stylesheet",as:"style",nonce:b.nonce},a):((0,e.preload)(c,{as:"script",fetchPriority:"low",nonce:b.nonce}),null)})})}},809629,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0}),Object.defineProperty(c,"default",{enumerable:!0,get:function(){return j}});let d=a.r(634020),e=a.r(971938),f=a.r(719123),g=a.r(494130);function h(a){return{default:a&&"default"in a?a.default:a}}let i={loader:()=>Promise.resolve(h(()=>null)),loading:null,ssr:!0},j=function(a){let b={...i,...a},c=(0,e.lazy)(()=>b.loader().then(h)),j=b.loading;function k(a){let h=j?(0,d.jsx)(j,{isLoading:!0,pastDelay:!0,error:null}):null,i=!b.ssr||!!b.loading,k=i?e.Suspense:e.Fragment,l=b.ssr?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(g.PreloadChunks,{moduleIds:b.modules}),(0,d.jsx)(c,{...a})]}):(0,d.jsx)(f.BailoutToCSR,{reason:"next/dynamic",children:(0,d.jsx)(c,{...a})});return(0,d.jsx)(k,{...i?{fallback:h}:{},children:l})}return k.displayName="LoadableComponent",k}},441218,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0}),Object.defineProperty(c,"default",{enumerable:!0,get:function(){return e}});let d=a.r(463652)._(a.r(809629));function e(a,b){let c={};"function"==typeof a&&(c.loader=a);let e={...c,...b};return(0,d.default)({...e,modules:e.loadableGenerated?.modules})}("function"==typeof c.default||"object"==typeof c.default&&null!==c.default)&&void 0===c.default.__esModule&&(Object.defineProperty(c.default,"__esModule",{value:!0}),Object.assign(c.default,c),b.exports=c.default)},240777,a=>{"use strict";var b=a.i(634020),c=a.i(739159),d=a.i(629939);let e=(0,d.default)("bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);var f=a.i(463788),g=a.i(140555),h=a.i(869376),i=a.i(827647);let j=(0,d.default)("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]),k=(0,d.default)("cloud-download",[["path",{d:"M12 13v8l-4-4",key:"1f5nwf"}],["path",{d:"m12 21 4-4",key:"1lfcce"}],["path",{d:"M4.393 15.269A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.436 8.284",key:"ui1hmy"}]]);var l=a.i(382988),m=a.i(40591),n=a.i(715190),o=a.i(222787);let p=(0,d.default)("folder-open",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]),q=(0,d.default)("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),r=(0,d.default)("git-branch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]),s=(0,d.default)("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);var t=a.i(680194),u=a.i(843162);let v=(0,d.default)("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]),w=(0,d.default)("user",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);var x=a.i(818617),x=x,y=a.i(432630),z=a.i(235549);let A=(0,d.default)("maximize-2",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]]),B=(0,d.default)("ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);var C=a.i(796873);let D=(0,d.default)("panel-left-close",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]),E=(0,d.default)("panel-left-open",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]),F=(0,d.default)("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);var G=a.i(410672);let H=(0,d.default)("eye-off",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]),I=(0,d.default)("pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]),J=(0,d.default)("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]),K=(0,d.default)("refresh-cw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]),L=(0,d.default)("settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),M=(0,d.default)("share",[["path",{d:"M12 2v13",key:"1km8f5"}],["path",{d:"m16 6-4-4-4 4",key:"13yo43"}],["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8",key:"1b2hhj"}]]);var N=a.i(453590);let O=(0,d.default)("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]);var P=a.i(336211),Q=a.i(121411),R=a.i(161661),S=a.i(63990),T=a.i(971938),U=a.i(699570),V=a.i(814574);function W({open:a,onOpenChange:c,title:d,description:e,confirmLabel:f="Delete",onConfirm:g,variant:h="destructive"}){return(0,b.jsx)(V.Dialog,{open:a,onOpenChange:c,children:(0,b.jsxs)(V.DialogContent,{className:"sm:max-w-sm",children:[(0,b.jsxs)(V.DialogHeader,{children:[(0,b.jsx)(V.DialogTitle,{children:d}),(0,b.jsx)(V.DialogDescription,{children:e})]}),(0,b.jsxs)(V.DialogFooter,{className:"gap-2 sm:gap-0",children:[(0,b.jsx)(U.Button,{variant:"outline",onClick:()=>c(!1),children:"Cancel"}),(0,b.jsx)(U.Button,{variant:h,onClick:()=>{g(),c(!1)},children:f})]})]})})}let X=(0,d.default)("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);var Y=a.i(304692),Z=a.i(705273);function $({path:a,badge:c,sublabel:d,showBreadcrumb:e=!0,leading:f,children:g,className:h}){return(0,b.jsxs)("div",{className:(0,Z.cn)("flex shrink-0 items-center justify-between gap-3 border-b border-border bg-background px-4 py-2",h),children:[(0,b.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[f,a&&(0,b.jsx)("span",{className:"text-xs text-muted-foreground truncate",title:a,children:a.split("/").pop()??a}),c&&(0,b.jsx)("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground/50",children:c}),d&&(0,b.jsx)("span",{className:"shrink-0 text-xs text-muted-foreground/40",children:d})]}),(0,b.jsx)("div",{className:"flex shrink-0 items-center gap-1",children:g})]})}function _(a){let b=[],c="",d=!1,e=[];for(let f=0;f<a.length;f++){let g=a[f],h=a[f+1];d?'"'===g&&'"'===h?(c+='"',f++):'"'===g?d=!1:c+=g:'"'===g?d=!0:","===g?(e.push(c),c=""):"\n"===g||"\r"===g&&"\n"===h?(e.push(c),c="",e.length>0&&b.push(e),e=[],"\r"===g&&f++):c+=g}return e.push(c),e.some(a=>""!==a)&&b.push(e),b}function aa(a){return a.map(a=>a.map(a=>a.includes(",")||a.includes('"')||a.includes("\n")?`"${a.replace(/"/g,'""')}"`:a).join(",")).join("\n")}function ab({path:a}){let[c,d]=(0,T.useState)([]),[e,f]=(0,T.useState)(""),[g,h]=(0,T.useState)(!1),[i,k]=(0,T.useState)(!1),[l,m]=(0,T.useState)(!1),[n,o]=(0,T.useState)(null),[p,q]=(0,T.useState)(!1),[r,s]=(0,T.useState)(1e3),u=`/api/assets/${a}`;(0,T.useEffect)(()=>{(0,Y.wsFetch)(u).then(a=>a.text()).then(a=>{let b=_(a),c=a.length>2097152||b.length>2e3;f(a),d(b),q(c),h(c),k(!1)})},[u]);let v=(0,T.useCallback)((a,b,c)=>{d(d=>{let e=d.map(a=>[...a]);for(;e.length<=a;)e.push([]);for(;e[a].length<=b;)e[a].push("");return e[a][b]=c,e}),k(!0)},[]),w=async()=>{m(!0);let b=g?e:aa(c);try{await (0,Y.wsFetch)(`/api/assets/${a}`,{method:"PUT",headers:{"Content-Type":"text/plain"},body:b}),g?d(_(e)):f(b),k(!1)}catch(a){console.error("Failed to save CSV:",a)}m(!1)},x=c[0]||[],y=c.slice(1),z=p?y.slice(0,r):y,A=p&&r<y.length;return(0,b.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,b.jsxs)($,{path:a,badge:`CSV${c.length>0?` (${c.length-1} rows)`:""}`,children:[i&&(0,b.jsxs)(U.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:w,disabled:l,children:[(0,b.jsx)(X,{className:"h-3.5 w-3.5"}),l?"Saving...":"Save"]}),p&&(0,b.jsxs)("span",{className:"text-[11px] text-amber-600 dark:text-amber-400 px-1",children:["Large file (",(e.length/1048576).toFixed(1)," MB,"," ",c.length.toLocaleString()," rows)"]}),(0,b.jsxs)("button",{onClick:()=>{g?d(_(e)):f(aa(c)),h(!g)},className:`flex items-center gap-1.5 px-2.5 py-1 text-[11px] rounded-md transition-colors border border-border ${g?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent"}`,children:[(0,b.jsx)(t.Code2,{className:"h-3 w-3"}),g?"Table":"Source"]}),(0,b.jsx)("button",{onClick:()=>window.open(u,"_blank"),className:"inline-flex items-center justify-center rounded-md h-8 w-8 hover:bg-accent hover:text-accent-foreground transition-colors cursor-pointer",title:"Download CSV",children:(0,b.jsx)(j,{className:"h-4 w-4"})})]}),g?(0,b.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:(0,b.jsx)("textarea",{value:e,onChange:a=>{f(a.target.value),k(!0)},className:"w-full h-full min-h-[calc(100vh-12rem)] bg-transparent font-mono text-[13px] leading-relaxed resize-none focus:outline-none",spellCheck:!1})}):(0,b.jsxs)("div",{className:"flex-1 overflow-auto",children:[(0,b.jsxs)("table",{className:"w-full border-collapse text-[13px]",children:[(0,b.jsx)("thead",{className:"sticky top-0 z-10",children:(0,b.jsxs)("tr",{className:"bg-muted/80 backdrop-blur-sm",children:[(0,b.jsx)("th",{className:"border border-border px-1 py-1 text-center text-[10px] text-muted-foreground w-8",children:"#"}),x.map((a,c)=>(0,b.jsx)("th",{className:"border border-border px-3 py-1.5 text-left font-medium text-foreground min-w-[100px]",children:n?.r===0&&n?.c===c?(0,b.jsx)("input",{autoFocus:!0,className:"w-full bg-transparent outline-none",value:a,onChange:a=>v(0,c,a.target.value),onBlur:()=>o(null),onKeyDown:a=>{("Enter"===a.key||"Escape"===a.key)&&o(null),"Tab"===a.key&&(a.preventDefault(),o({r:0,c:c+1<x.length?c+1:0}))}}):(0,b.jsx)("span",{className:"cursor-text",onDoubleClick:()=>o({r:0,c}),children:a||" "})},c))]})}),(0,b.jsx)("tbody",{children:z.map((a,c)=>{let e=c+1;return(0,b.jsxs)("tr",{className:"hover:bg-accent/30 transition-colors group",children:[(0,b.jsxs)("td",{className:"border border-border px-1 py-1 text-center text-[10px] text-muted-foreground/50",children:[(0,b.jsx)("span",{className:"group-hover:hidden",children:c+1}),(0,b.jsx)("button",{className:"hidden group-hover:inline text-destructive hover:text-destructive/80 text-[10px]",onClick:()=>{d(a=>a.filter((a,b)=>b!==e)),k(!0)},title:"Delete row",children:"×"})]}),x.map((c,d)=>{let f=a[d]??"",g=n?.r===e&&n?.c===d;return(0,b.jsx)("td",{className:"border border-border px-3 py-1.5",children:g?(0,b.jsx)("input",{autoFocus:!0,className:"w-full bg-transparent outline-none",value:f,onChange:a=>v(e,d,a.target.value),onBlur:()=>o(null),onKeyDown:a=>{"Escape"===a.key&&o(null),"Enter"===a.key&&o({r:e+1,c:d}),"Tab"===a.key&&(a.preventDefault(),a.shiftKey?o({r:e,c:Math.max(0,d-1)}):o({r:d+1>=x.length?e+1:e,c:d+1>=x.length?0:d+1}))}}):(0,b.jsx)("span",{className:"cursor-text",onDoubleClick:()=>o({r:e,c:d}),children:f||" "})},d)})]},c)})})]}),A&&(0,b.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2 border-t border-border",children:[(0,b.jsxs)("button",{onClick:()=>s(a=>a+1e3),className:"text-[11px] text-foreground hover:bg-accent transition-colors px-2.5 py-1 rounded border border-border",children:["Show"," ",Math.min(1e3,y.length-r).toLocaleString()," ","more rows"]}),(0,b.jsxs)("span",{className:"text-[11px] text-muted-foreground",children:[r.toLocaleString()," /"," ",y.length.toLocaleString()," rows"]})]}),(0,b.jsxs)("div",{className:"flex items-center gap-2 px-4 py-2 border-t border-border",children:[(0,b.jsx)("button",{onClick:()=>{let a=c[0]?.length||1;d(b=>[...b,Array(a).fill("")]),k(!0)},className:"text-[11px] text-muted-foreground hover:text-foreground transition-colors px-2 py-1 rounded hover:bg-accent",children:"+ Add row"}),(0,b.jsx)("button",{onClick:()=>{d(a=>a.map(a=>[...a,""])),k(!0)},className:"text-[11px] text-muted-foreground hover:text-foreground transition-colors px-2 py-1 rounded hover:bg-accent",children:"+ Add column"})]})]})]})}var ac=a.i(602895);function ad({path:a}){let c=(0,Y.withWs)(`/api/assets/${a}`),d=a.split("/").pop()||a,e=d.includes(".")?d.split(".").pop()?.toUpperCase():"",f=async()=>{try{await (0,Y.wsFetch)("/api/system/reveal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a})})}catch{}};return(0,b.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,b.jsx)($,{path:a,badge:e||void 0}),(0,b.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,b.jsxs)("div",{className:"flex flex-col items-center gap-4 text-center max-w-sm",children:[(0,b.jsx)("div",{className:"flex size-16 items-center justify-center rounded-2xl bg-muted",children:(0,b.jsx)(l.File,{className:"size-8 text-muted-foreground/50"})}),(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)("p",{className:"text-sm font-medium",children:d}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:"This file type can't be previewed in Cabinet."})]}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsxs)(U.Button,{variant:"outline",size:"sm",className:"gap-2",onClick:f,children:[(0,b.jsx)(p,{className:"h-4 w-4"}),"Open in Finder"]}),(0,b.jsxs)(U.Button,{variant:"outline",size:"sm",className:"gap-2",onClick:()=>{let a=document.createElement("a");a.href=c,a.download=d,a.click()},children:[(0,b.jsx)(j,{className:"h-4 w-4"}),"Download"]})]})]})})]})}var ae=a.i(33515);let af=(0,d.default)("file-warning",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);function ag({path:a,size:c,onOpen:d}){let e=(0,Y.withWs)(`/api/assets/${a}`),f=a.split("/").pop()||a,g=f.includes(".")?f.split(".").pop()?.toUpperCase():"",h=async()=>{try{await (0,Y.wsFetch)("/api/system/reveal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a})})}catch{}};return(0,b.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,b.jsx)($,{path:a,badge:g||void 0}),(0,b.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,b.jsxs)("div",{className:"flex flex-col items-center gap-4 text-center max-w-sm",children:[(0,b.jsx)("div",{className:"flex size-16 items-center justify-center rounded-2xl bg-amber-500/10",children:(0,b.jsx)(af,{className:"size-8 text-amber-500"})}),(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)("p",{className:"text-sm font-medium",children:f}),(0,b.jsxs)("p",{className:"text-xs text-muted-foreground",children:["This file is ",c>=0x40000000?`${(c/0x40000000).toFixed(1)} GB`:c>=1048576?`${(c/1048576).toFixed(1)} MB`:c>=1024?`${Math.round(c/1024)} KB`:`${c} B`,". Opening it in the viewer may freeze the tab while it loads and renders."]})]}),(0,b.jsxs)("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[(0,b.jsx)(U.Button,{variant:"default",size:"sm",className:"gap-2",onClick:d,children:"Open anyway"}),(0,b.jsxs)(U.Button,{variant:"outline",size:"sm",className:"gap-2",onClick:()=>window.open(e,"_blank"),children:[(0,b.jsx)(ae.ExternalLink,{className:"h-4 w-4"}),"Raw"]}),(0,b.jsxs)(U.Button,{variant:"outline",size:"sm",className:"gap-2",onClick:()=>{let a=document.createElement("a");a.href=e,a.download=f,a.click()},children:[(0,b.jsx)(j,{className:"h-4 w-4"}),"Download"]}),(0,b.jsxs)(U.Button,{variant:"outline",size:"sm",className:"gap-2",onClick:h,children:[(0,b.jsx)(p,{className:"h-4 w-4"}),"Open in Finder"]})]})]})})]})}function ah({path:a,title:c}){let d=(0,Y.withWs)(`/api/assets/${a}`),e=a.split("/").pop()||a,f=e.includes(".")?e.split(".").pop()?.toUpperCase():"IMG";return(0,b.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,b.jsxs)($,{path:a,badge:f,children:[(0,b.jsxs)(U.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>{let a=document.createElement("a");a.href=d,a.download=e,a.click()},children:[(0,b.jsx)(j,{className:"h-3.5 w-3.5"}),"Download"]}),(0,b.jsxs)(U.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>window.open(d,"_blank"),children:[(0,b.jsx)(ae.ExternalLink,{className:"h-3.5 w-3.5"}),"Open in new tab"]})]}),(0,b.jsx)("div",{className:"flex-1 overflow-auto flex items-center justify-center bg-[#1a1a1a] p-8",children:(0,b.jsx)("img",{src:d,alt:c,className:"max-w-full max-h-full object-contain rounded-md shadow-lg",style:{imageRendering:"auto"}})})]})}function ai({path:a,type:c}){let d=(0,Y.withWs)(`/api/assets/${a}`),e=a.split("/").pop()||a,f=e.includes(".")?e.split(".").pop()?.toUpperCase():c.toUpperCase();return(0,b.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,b.jsxs)($,{path:a,badge:f,children:[(0,b.jsxs)(U.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>{let a=document.createElement("a");a.href=d,a.download=e,a.click()},children:[(0,b.jsx)(j,{className:"h-3.5 w-3.5"}),"Download"]}),(0,b.jsxs)(U.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>window.open(d,"_blank"),children:[(0,b.jsx)(ae.ExternalLink,{className:"h-3.5 w-3.5"}),"Open in new tab"]})]}),(0,b.jsx)("div",{className:"flex-1 overflow-auto flex items-center justify-center bg-[#1a1a1a] p-8",children:"video"===c?(0,b.jsx)("video",{src:d,controls:!0,className:"max-w-full max-h-full rounded-md shadow-lg",children:"Your browser does not support the video element."}):(0,b.jsxs)("div",{className:"w-full max-w-lg space-y-4",children:[(0,b.jsx)("div",{className:"text-center text-muted-foreground text-sm",children:e}),(0,b.jsx)("audio",{src:d,controls:!0,className:"w-full",children:"Your browser does not support the audio element."})]})})]})}var aj=a.i(276548);function ak({path:c,title:d}){let[e,g]=(0,T.useState)(""),[h,k]=(0,T.useState)(""),[l,m]=(0,T.useState)(""),[n,o]=(0,T.useState)(!0),[p,q]=(0,T.useState)(!1),[r,s]=(0,T.useState)(!1),u=(0,T.useRef)(0),v=(0,Y.withWs)(`/api/assets/${c}`);c.split("/").pop();let w=(0,T.useCallback)(async()=>{o(!0),m("");try{let b=await (0,Y.wsFetch)(v);if(!b.ok)throw Error("Failed to fetch file");let c=await b.text();g(c);let d=(await a.A(334743)).default;d.initialize({startOnLoad:!1,theme:document.documentElement.classList.contains("dark")?"dark":"default",securityLevel:"loose",suppressErrorRendering:!0}),await d.parse(c.trim());let e=`mermaid-${++u.current}`,{svg:f}=await d.render(e,c.trim());k(f)}catch(a){document.querySelectorAll('[id^="dmermaid-"], [id^="d"]:has(> .error-icon)').forEach(a=>a.remove()),m(a instanceof Error?a.message:"Failed to render diagram")}finally{o(!1)}},[v]);return(0,T.useEffect)(()=>{w()},[w]),(0,b.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,b.jsxs)($,{path:c,badge:"MERMAID",children:[(0,b.jsxs)(U.Button,{variant:"ghost",size:"sm",className:`h-7 gap-1.5 text-xs ${p?"bg-muted":""}`,onClick:()=>q(a=>!a),children:[p?(0,b.jsx)(G.Eye,{className:"h-3.5 w-3.5"}):(0,b.jsx)(t.Code2,{className:"h-3.5 w-3.5"}),p?"Diagram":"Code"]}),(0,b.jsxs)(U.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>{navigator.clipboard.writeText(e),s(!0),setTimeout(()=>s(!1),2e3)},children:[r?(0,b.jsx)(f.Check,{className:"h-3.5 w-3.5 text-green-500"}):(0,b.jsx)(i.Copy,{className:"h-3.5 w-3.5"}),r?"Copied":"Copy"]}),h&&(0,b.jsxs)(U.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>{if(!h)return;let a=new Blob([h],{type:"image/svg+xml"}),b=URL.createObjectURL(a),c=document.createElement("a");c.href=b,c.download=`${d}.svg`,c.click(),URL.revokeObjectURL(b)},children:[(0,b.jsx)(j,{className:"h-3.5 w-3.5"}),"SVG"]})]}),(0,b.jsx)("div",{className:"flex-1 overflow-auto",children:n?(0,b.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Rendering diagram..."}):p?(0,b.jsx)("pre",{className:"p-4 text-[13px] leading-relaxed font-mono bg-[#1e1e1e]",children:(0,b.jsx)("code",{children:e.split("\n").map((a,c)=>(0,b.jsxs)("div",{className:"flex",children:[(0,b.jsx)("span",{className:"inline-block w-12 pr-4 text-right text-[#858585] select-none shrink-0",children:c+1}),(0,b.jsx)("span",{className:"text-[#d4d4d4] flex-1",children:a||"\n"})]},c))})}):l?(0,b.jsxs)("div",{className:"flex flex-col items-center justify-center h-full gap-4 text-sm p-8",children:[(0,b.jsxs)("div",{className:"flex flex-col items-center gap-2",children:[(0,b.jsx)("div",{className:"h-10 w-10 rounded-full bg-red-500/10 flex items-center justify-center",children:(0,b.jsx)(t.Code2,{className:"h-5 w-5 text-red-500"})}),(0,b.jsx)("p",{className:"text-red-500 font-medium",children:"Diagram syntax error"})]}),(0,b.jsx)("pre",{className:"text-muted-foreground text-xs max-w-lg text-left bg-muted rounded-md p-3 overflow-auto whitespace-pre-wrap",children:l}),(0,b.jsx)(U.Button,{variant:"outline",size:"sm",onClick:()=>q(!0),children:"View source to fix"})]}):(0,b.jsx)(aj.MermaidCanvas,{svg:h,className:"w-full h-full"})})]})}var al=a.i(855814),am=a.i(366744),an=a.i(462222),ao=a.i(657941),ap="[0-9](_*[0-9])*",aq=`\\.(${ap})`,ar="[0-9a-fA-F](_*[0-9a-fA-F])*",as={className:"number",variants:[{begin:`(\\b(${ap})((${aq})|\\.)?|(${aq}))[eE][+-]?(${ap})[fFdD]?\\b`},{begin:`\\b(${ap})((${aq})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${aq})[fFdD]?\\b`},{begin:`\\b(${ap})[fFdD]\\b`},{begin:`\\b0[xX]((${ar})\\.?|(${ar})?\\.(${ar}))[pP][+-]?(${ap})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${ar})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0},at=a.i(612805),au=a.i(379138),av="[0-9](_*[0-9])*",aw=`\\.(${av})`,ax="[0-9a-fA-F](_*[0-9a-fA-F])*",ay={className:"number",variants:[{begin:`(\\b(${av})((${aw})|\\.)?|(${aw}))[eE][+-]?(${av})[fFdD]?\\b`},{begin:`\\b(${av})((${aw})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${aw})[fFdD]?\\b`},{begin:`\\b(${av})[fFdD]\\b`},{begin:`\\b0[xX]((${ax})\\.?|(${ax})?\\.(${ax}))[pP][+-]?(${av})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${ax})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};let az=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video","defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],aA=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),aB=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),aC=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),aD=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse(),aE=aB.concat(aC).sort().reverse();var aF=a.i(729438),aG=a.i(396885),aH=a.i(534653);let aI=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video","defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],aJ=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),aK=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),aL=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),aM=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse();var aN=a.i(10551),aO=a.i(928258);function aP(a){return a?"string"==typeof a?a:a.source:null}function aQ(a){return aR("(?=",a,")")}function aR(...a){return a.map(a=>aP(a)).join("")}function aS(...a){let b;return"("+(("object"==typeof(b=a[a.length-1])&&b.constructor===Object?(a.splice(a.length-1,1),b):{}).capture?"":"?:")+a.map(a=>aP(a)).join("|")+")"}let aT=a=>aR(/\b/,a,/\w$/.test(a)?/\b/:/\B/),aU=["Protocol","Type"].map(aT),aV=["init","self"].map(aT),aW=["Any","Self"],aX=["actor","any","associatedtype","async","await",/as\?/,/as!/,"as","borrowing","break","case","catch","class","consume","consuming","continue","convenience","copy","default","defer","deinit","didSet","distributed","do","dynamic","each","else","enum","extension","fallthrough",/fileprivate\(set\)/,"fileprivate","final","for","func","get","guard","if","import","indirect","infix",/init\?/,/init!/,"inout",/internal\(set\)/,"internal","in","is","isolated","nonisolated","lazy","let","macro","mutating","nonmutating",/open\(set\)/,"open","operator","optional","override","package","postfix","precedencegroup","prefix",/private\(set\)/,"private","protocol",/public\(set\)/,"public","repeat","required","rethrows","return","set","some","static","struct","subscript","super","switch","throws","throw",/try\?/,/try!/,"try","typealias",/unowned\(safe\)/,/unowned\(unsafe\)/,"unowned","var","weak","where","while","willSet"],aY=["false","nil","true"],aZ=["assignment","associativity","higherThan","left","lowerThan","none","right"],a$=["#colorLiteral","#column","#dsohandle","#else","#elseif","#endif","#error","#file","#fileID","#fileLiteral","#filePath","#function","#if","#imageLiteral","#keyPath","#line","#selector","#sourceLocation","#warning"],a_=["abs","all","any","assert","assertionFailure","debugPrint","dump","fatalError","getVaList","isKnownUniquelyReferenced","max","min","numericCast","pointwiseMax","pointwiseMin","precondition","preconditionFailure","print","readLine","repeatElement","sequence","stride","swap","swift_unboxFromSwiftValueWithType","transcode","type","unsafeBitCast","unsafeDowncast","withExtendedLifetime","withUnsafeMutablePointer","withUnsafePointer","withVaList","withoutActuallyEscaping","zip"],a0=aS(/[/=\-+!*%<>&|^~?]/,/[\u00A1-\u00A7]/,/[\u00A9\u00AB]/,/[\u00AC\u00AE]/,/[\u00B0\u00B1]/,/[\u00B6\u00BB\u00BF\u00D7\u00F7]/,/[\u2016-\u2017]/,/[\u2020-\u2027]/,/[\u2030-\u203E]/,/[\u2041-\u2053]/,/[\u2055-\u205E]/,/[\u2190-\u23FF]/,/[\u2500-\u2775]/,/[\u2794-\u2BFF]/,/[\u2E00-\u2E7F]/,/[\u3001-\u3003]/,/[\u3008-\u3020]/,/[\u3030]/),a1=aS(a0,/[\u0300-\u036F]/,/[\u1DC0-\u1DFF]/,/[\u20D0-\u20FF]/,/[\uFE00-\uFE0F]/,/[\uFE20-\uFE2F]/),a2=aR(a0,a1,"*"),a3=aS(/[a-zA-Z_]/,/[\u00A8\u00AA\u00AD\u00AF\u00B2-\u00B5\u00B7-\u00BA]/,/[\u00BC-\u00BE\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF]/,/[\u0100-\u02FF\u0370-\u167F\u1681-\u180D\u180F-\u1DBF]/,/[\u1E00-\u1FFF]/,/[\u200B-\u200D\u202A-\u202E\u203F-\u2040\u2054\u2060-\u206F]/,/[\u2070-\u20CF\u2100-\u218F\u2460-\u24FF\u2776-\u2793]/,/[\u2C00-\u2DFF\u2E80-\u2FFF]/,/[\u3004-\u3007\u3021-\u302F\u3031-\u303F\u3040-\uD7FF]/,/[\uF900-\uFD3D\uFD40-\uFDCF\uFDF0-\uFE1F\uFE30-\uFE44]/,/[\uFE47-\uFEFE\uFF00-\uFFFD]/),a4=aS(a3,/\d/,/[\u0300-\u036F\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/),a5=aR(a3,a4,"*"),a6=aR(/[A-Z]/,a4,"*"),a7=["attached","autoclosure",aR(/convention\(/,aS("swift","block","c"),/\)/),"discardableResult","dynamicCallable","dynamicMemberLookup","escaping","freestanding","frozen","GKInspectable","IBAction","IBDesignable","IBInspectable","IBOutlet","IBSegueAction","inlinable","main","nonobjc","NSApplicationMain","NSCopying","NSManaged",aR(/objc\(/,a5,/\)/),"objc","objcMembers","propertyWrapper","requires_stored_property_inits","resultBuilder","Sendable","testable","UIApplicationMain","unchecked","unknown","usableFromInline","warn_unqualified_access"],a8=["iOS","iOSApplicationExtension","macOS","macOSApplicationExtension","macCatalyst","macCatalystApplicationExtension","watchOS","watchOSApplicationExtension","tvOS","tvOSApplicationExtension","swift"];var a9=a.i(297230),ba=a.i(62523),bb=a.i(921800);let bc={arduino:function(a){let b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r=(b=a.regex,c=a.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),e="[a-zA-Z_]\\w*::",f="(?!struct)("+(d="decltype\\(auto\\)")+"|"+b.optional(e)+"[a-zA-Z_]\\w*"+b.optional("<[^<>]+>")+")",g={className:"type",begin:"\\b[a-z\\d_]*_t\\b"},h={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[a.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'(\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)|.)",end:"'",illegal:"."},a.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},i={className:"number",variants:[{begin:"[+-]?(?:(?:[0-9](?:'?[0-9])*\\.(?:[0-9](?:'?[0-9])*)?|\\.[0-9](?:'?[0-9])*)(?:[Ee][+-]?[0-9](?:'?[0-9])*)?|[0-9](?:'?[0-9])*[Ee][+-]?[0-9](?:'?[0-9])*|0[Xx](?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*(?:\\.(?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)?)?|\\.[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)[Pp][+-]?[0-9](?:'?[0-9])*)(?:[Ff](?:16|32|64|128)?|(BF|bf)16|[Ll]|)"},{begin:"[+-]?\\b(?:0[Bb][01](?:'?[01])*|0[Xx][0-9A-Fa-f](?:'?[0-9A-Fa-f])*|0(?:'?[0-7])*|[1-9](?:'?[0-9])*)(?:[Uu](?:LL?|ll?)|[Uu][Zz]?|(?:LL?|ll?)[Uu]?|[Zz][Uu]|)"}],relevance:0},j={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},a.inherit(h,{className:"string"}),{className:"string",begin:/<.*?>/},c,a.C_BLOCK_COMMENT_MODE]},k={className:"title",begin:b.optional(e)+a.IDENT_RE,relevance:0},l=b.optional(e)+a.IDENT_RE+"\\s*\\(",p={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:m={type:["bool","char","char16_t","char32_t","char8_t","double","float","int","long","short","void","wchar_t","unsigned","signed","const","static"],keyword:["alignas","alignof","and","and_eq","asm","atomic_cancel","atomic_commit","atomic_noexcept","auto","bitand","bitor","break","case","catch","class","co_await","co_return","co_yield","compl","concept","const_cast|10","consteval","constexpr","constinit","continue","decltype","default","delete","do","dynamic_cast|10","else","enum","explicit","export","extern","false","final","for","friend","goto","if","import","inline","module","mutable","namespace","new","noexcept","not","not_eq","nullptr","operator","or","or_eq","override","private","protected","public","reflexpr","register","reinterpret_cast|10","requires","return","sizeof","static_assert","static_cast|10","struct","switch","synchronized","template","this","thread_local","throw","transaction_safe","transaction_safe_dynamic","true","try","typedef","typeid","typename","union","using","virtual","volatile","while","xor","xor_eq"],literal:["NULL","false","nullopt","nullptr","true"],built_in:["_Pragma"],_type_hints:["any","auto_ptr","barrier","binary_semaphore","bitset","complex","condition_variable","condition_variable_any","counting_semaphore","deque","false_type","flat_map","flat_set","future","imaginary","initializer_list","istringstream","jthread","latch","lock_guard","multimap","multiset","mutex","optional","ostringstream","packaged_task","pair","promise","priority_queue","queue","recursive_mutex","recursive_timed_mutex","scoped_lock","set","shared_future","shared_lock","shared_mutex","shared_timed_mutex","shared_ptr","stack","string_view","stringstream","timed_mutex","thread","true_type","tuple","unique_lock","unique_ptr","unordered_map","unordered_multimap","unordered_multiset","unordered_set","variant","vector","weak_ptr","wstring","wstring_view"]},contains:(o=[n={className:"function.dispatch",relevance:0,keywords:{_hint:["abort","abs","acos","apply","as_const","asin","atan","atan2","calloc","ceil","cerr","cin","clog","cos","cosh","cout","declval","endl","exchange","exit","exp","fabs","floor","fmod","forward","fprintf","fputs","free","frexp","fscanf","future","invoke","isalnum","isalpha","iscntrl","isdigit","isgraph","islower","isprint","ispunct","isspace","isupper","isxdigit","labs","launder","ldexp","log","log10","make_pair","make_shared","make_shared_for_overwrite","make_tuple","make_unique","malloc","memchr","memcmp","memcpy","memset","modf","move","pow","printf","putchar","puts","realloc","scanf","sin","sinh","snprintf","sprintf","sqrt","sscanf","std","stderr","stdin","stdout","strcat","strchr","strcmp","strcpy","strcspn","strlen","strncat","strncmp","strncpy","strpbrk","strrchr","strspn","strstr","swap","tan","tanh","terminate","to_underlying","tolower","toupper","vfprintf","visit","vprintf","vsprintf"]},begin:b.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,a.IDENT_RE,b.lookahead(/(<[^<>]+>|)\s*\(/))},j,g,c,a.C_BLOCK_COMMENT_MODE,i,h]).concat([{begin:/\(/,end:/\)/,keywords:m,contains:o.concat(["self"]),relevance:0}]),relevance:0},q={className:"function",begin:"("+f+"[\\*&\\s]+)+"+l,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:m,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:d,keywords:m,relevance:0},{begin:l,returnBegin:!0,contains:[k],relevance:0},{begin:/::/,relevance:0},{begin:/:/,endsWithParent:!0,contains:[h,i]},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:m,relevance:0,contains:[c,a.C_BLOCK_COMMENT_MODE,h,i,g,{begin:/\(/,end:/\)/,keywords:m,relevance:0,contains:["self",c,a.C_BLOCK_COMMENT_MODE,h,i,g]}]},g,c,a.C_BLOCK_COMMENT_MODE,j]},{name:"C++",aliases:["cc","c++","h++","hpp","hh","hxx","cxx"],keywords:m,illegal:"</",classNameAliases:{"function.dispatch":"built_in"},contains:[].concat(p,q,n,o,[j,{begin:"\\b(deque|list|queue|priority_queue|pair|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array|tuple|optional|variant|function|flat_map|flat_set)\\s*<(?!<)",end:">",keywords:m,contains:["self",g]},{begin:a.IDENT_RE+"::",keywords:m},{match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/],className:{1:"keyword",3:"title.class"}}])}),s=r.keywords;return s.type=[...s.type,"boolean","byte","word","String"],s.literal=[...s.literal,"DIGITAL_MESSAGE","FIRMATA_STRING","ANALOG_MESSAGE","REPORT_DIGITAL","REPORT_ANALOG","INPUT_PULLUP","SET_PIN_MODE","INTERNAL2V56","SYSTEM_RESET","LED_BUILTIN","INTERNAL1V1","SYSEX_START","INTERNAL","EXTERNAL","DEFAULT","OUTPUT","INPUT","HIGH","LOW"],s.built_in=[...s.built_in,"KeyboardController","MouseController","SoftwareSerial","EthernetServer","EthernetClient","LiquidCrystal","RobotControl","GSMVoiceCall","EthernetUDP","EsploraTFT","HttpClient","RobotMotor","WiFiClient","GSMScanner","FileSystem","Scheduler","GSMServer","YunClient","YunServer","IPAddress","GSMClient","GSMModem","Keyboard","Ethernet","Console","GSMBand","Esplora","Stepper","Process","WiFiUDP","GSM_SMS","Mailbox","USBHost","Firmata","PImage","Client","Server","GSMPIN","FileIO","Bridge","Serial","EEPROM","Stream","Mouse","Audio","Servo","File","Task","GPRS","WiFi","Wire","TFT","GSM","SPI","SD"],s._hints=["setup","loop","runShellCommandAsynchronously","analogWriteResolution","retrieveCallingNumber","printFirmwareVersion","analogReadResolution","sendDigitalPortPair","noListenOnLocalhost","readJoystickButton","setFirmwareVersion","readJoystickSwitch","scrollDisplayRight","getVoiceCallStatus","scrollDisplayLeft","writeMicroseconds","delayMicroseconds","beginTransmission","getSignalStrength","runAsynchronously","getAsynchronously","listenOnLocalhost","getCurrentCarrier","readAccelerometer","messageAvailable","sendDigitalPorts","lineFollowConfig","countryNameWrite","runShellCommand","readStringUntil","rewindDirectory","readTemperature","setClockDivider","readLightSensor","endTransmission","analogReference","detachInterrupt","countryNameRead","attachInterrupt","encryptionType","readBytesUntil","robotNameWrite","readMicrophone","robotNameRead","cityNameWrite","userNameWrite","readJoystickY","readJoystickX","mouseReleased","openNextFile","scanNetworks","noInterrupts","digitalWrite","beginSpeaker","mousePressed","isActionDone","mouseDragged","displayLogos","noAutoscroll","addParameter","remoteNumber","getModifiers","keyboardRead","userNameRead","waitContinue","processInput","parseCommand","printVersion","readNetworks","writeMessage","blinkVersion","cityNameRead","readMessage","setDataMode","parsePacket","isListening","setBitOrder","beginPacket","isDirectory","motorsWrite","drawCompass","digitalRead","clearScreen","serialEvent","rightToLeft","setTextSize","leftToRight","requestFrom","keyReleased","compassRead","analogWrite","interrupts","WiFiServer","disconnect","playMelody","parseFloat","autoscroll","getPINUsed","setPINUsed","setTimeout","sendAnalog","readSlider","analogRead","beginWrite","createChar","motorsStop","keyPressed","tempoWrite","readButton","subnetMask","debugPrint","macAddress","writeGreen","randomSeed","attachGPRS","readString","sendString","remotePort","releaseAll","mouseMoved","background","getXChange","getYChange","answerCall","getResult","voiceCall","endPacket","constrain","getSocket","writeJSON","getButton","available","connected","findUntil","readBytes","exitValue","readGreen","writeBlue","startLoop","IPAddress","isPressed","sendSysex","pauseMode","gatewayIP","setCursor","getOemKey","tuneWrite","noDisplay","loadImage","switchPIN","onRequest","onReceive","changePIN","playFile","noBuffer","parseInt","overflow","checkPIN","knobRead","beginTFT","bitClear","updateIR","bitWrite","position","writeRGB","highByte","writeRed","setSpeed","readBlue","noStroke","remoteIP","transfer","shutdown","hangCall","beginSMS","endWrite","attached","maintain","noCursor","checkReg","checkPUK","shiftOut","isValid","shiftIn","pulseIn","connect","println","localIP","pinMode","getIMEI","display","noBlink","process","getBand","running","beginSD","drawBMP","lowByte","setBand","release","bitRead","prepare","pointTo","readRed","setMode","noFill","remove","listen","stroke","detach","attach","noTone","exists","buffer","height","bitSet","circle","config","cursor","random","IRread","setDNS","endSMS","getKey","micros","millis","begin","print","write","ready","flush","width","isPIN","blink","clear","press","mkdir","rmdir","close","point","yield","image","BSSID","click","delay","read","text","move","peek","beep","rect","line","open","seek","fill","size","turn","stop","home","find","step","tone","sqrt","RSSI","SSID","end","bit","tan","cos","sin","pow","map","abs","max","min","get","run","put"],r.name="Arduino",r.aliases=["ino"],r.supersetOf="cpp",r},bash:am.default,c:function(a){let b=a.regex,c=a.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),d="decltype\\(auto\\)",e="[a-zA-Z_]\\w*::",f="("+d+"|"+b.optional(e)+"[a-zA-Z_]\\w*"+b.optional("<[^<>]+>")+")",g={className:"type",variants:[{begin:"\\b[a-z\\d_]*_t\\b"},{match:/\batomic_[a-z]{3,6}\b/}]},h={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[a.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'(\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)|.)",end:"'",illegal:"."},a.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},i={className:"number",variants:[{match:/\b(0b[01']+)/},{match:/(-?)\b([\d']+(\.[\d']*)?|\.[\d']+)((ll|LL|l|L)(u|U)?|(u|U)(ll|LL|l|L)?|f|F|b|B)/},{match:/(-?)\b(0[xX][a-fA-F0-9]+(?:'[a-fA-F0-9]+)*(?:\.[a-fA-F0-9]*(?:'[a-fA-F0-9]*)*)?(?:[pP][-+]?[0-9]+)?(l|L)?(u|U)?)/},{match:/(-?)\b\d+(?:'\d+)*(?:\.\d*(?:'\d*)*)?(?:[eE][-+]?\d+)?/}],relevance:0},j={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef elifdef elifndef include"},contains:[{begin:/\\\n/,relevance:0},a.inherit(h,{className:"string"}),{className:"string",begin:/<.*?>/},c,a.C_BLOCK_COMMENT_MODE]},k={className:"title",begin:b.optional(e)+a.IDENT_RE,relevance:0},l=b.optional(e)+a.IDENT_RE+"\\s*\\(",m={keyword:["asm","auto","break","case","continue","default","do","else","enum","extern","for","fortran","goto","if","inline","register","restrict","return","sizeof","typeof","typeof_unqual","struct","switch","typedef","union","volatile","while","_Alignas","_Alignof","_Atomic","_Generic","_Noreturn","_Static_assert","_Thread_local","alignas","alignof","noreturn","static_assert","thread_local","_Pragma"],type:["float","double","signed","unsigned","int","short","long","char","void","_Bool","_BitInt","_Complex","_Imaginary","_Decimal32","_Decimal64","_Decimal96","_Decimal128","_Decimal64x","_Decimal128x","_Float16","_Float32","_Float64","_Float128","_Float32x","_Float64x","_Float128x","const","static","constexpr","complex","bool","imaginary"],literal:"true false NULL",built_in:"std string wstring cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream auto_ptr deque list queue stack vector map set pair bitset multiset multimap unordered_set unordered_map unordered_multiset unordered_multimap priority_queue make_pair array shared_ptr abort terminate abs acos asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp fscanf future isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan vfprintf vprintf vsprintf endl initializer_list unique_ptr"},n=[j,g,c,a.C_BLOCK_COMMENT_MODE,i,h],o={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:m,contains:n.concat([{begin:/\(/,end:/\)/,keywords:m,contains:n.concat(["self"]),relevance:0}]),relevance:0},p={begin:"("+f+"[\\*&\\s]+)+"+l,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:m,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:d,keywords:m,relevance:0},{begin:l,returnBegin:!0,contains:[a.inherit(k,{className:"title.function"})],relevance:0},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:m,relevance:0,contains:[c,a.C_BLOCK_COMMENT_MODE,h,i,g,{begin:/\(/,end:/\)/,keywords:m,relevance:0,contains:["self",c,a.C_BLOCK_COMMENT_MODE,h,i,g]}]},g,c,a.C_BLOCK_COMMENT_MODE,j]};return{name:"C",aliases:["h"],keywords:m,disableAutodetect:!0,illegal:"</",contains:[].concat(o,p,n,[j,{begin:a.IDENT_RE+"::",keywords:m},{className:"class",beginKeywords:"enum class struct union",end:/[{;:<>=]/,contains:[{beginKeywords:"final class struct"},a.TITLE_MODE]}]),exports:{preprocessor:j,strings:h,keywords:m}}},cpp:function(a){let b=a.regex,c=a.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),d="decltype\\(auto\\)",e="[a-zA-Z_]\\w*::",f="(?!struct)("+d+"|"+b.optional(e)+"[a-zA-Z_]\\w*"+b.optional("<[^<>]+>")+")",g={className:"type",begin:"\\b[a-z\\d_]*_t\\b"},h={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[a.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'(\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)|.)",end:"'",illegal:"."},a.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},i={className:"number",variants:[{begin:"[+-]?(?:(?:[0-9](?:'?[0-9])*\\.(?:[0-9](?:'?[0-9])*)?|\\.[0-9](?:'?[0-9])*)(?:[Ee][+-]?[0-9](?:'?[0-9])*)?|[0-9](?:'?[0-9])*[Ee][+-]?[0-9](?:'?[0-9])*|0[Xx](?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*(?:\\.(?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)?)?|\\.[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)[Pp][+-]?[0-9](?:'?[0-9])*)(?:[Ff](?:16|32|64|128)?|(BF|bf)16|[Ll]|)"},{begin:"[+-]?\\b(?:0[Bb][01](?:'?[01])*|0[Xx][0-9A-Fa-f](?:'?[0-9A-Fa-f])*|0(?:'?[0-7])*|[1-9](?:'?[0-9])*)(?:[Uu](?:LL?|ll?)|[Uu][Zz]?|(?:LL?|ll?)[Uu]?|[Zz][Uu]|)"}],relevance:0},j={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},a.inherit(h,{className:"string"}),{className:"string",begin:/<.*?>/},c,a.C_BLOCK_COMMENT_MODE]},k={className:"title",begin:b.optional(e)+a.IDENT_RE,relevance:0},l=b.optional(e)+a.IDENT_RE+"\\s*\\(",m={type:["bool","char","char16_t","char32_t","char8_t","double","float","int","long","short","void","wchar_t","unsigned","signed","const","static"],keyword:["alignas","alignof","and","and_eq","asm","atomic_cancel","atomic_commit","atomic_noexcept","auto","bitand","bitor","break","case","catch","class","co_await","co_return","co_yield","compl","concept","const_cast|10","consteval","constexpr","constinit","continue","decltype","default","delete","do","dynamic_cast|10","else","enum","explicit","export","extern","false","final","for","friend","goto","if","import","inline","module","mutable","namespace","new","noexcept","not","not_eq","nullptr","operator","or","or_eq","override","private","protected","public","reflexpr","register","reinterpret_cast|10","requires","return","sizeof","static_assert","static_cast|10","struct","switch","synchronized","template","this","thread_local","throw","transaction_safe","transaction_safe_dynamic","true","try","typedef","typeid","typename","union","using","virtual","volatile","while","xor","xor_eq"],literal:["NULL","false","nullopt","nullptr","true"],built_in:["_Pragma"],_type_hints:["any","auto_ptr","barrier","binary_semaphore","bitset","complex","condition_variable","condition_variable_any","counting_semaphore","deque","false_type","flat_map","flat_set","future","imaginary","initializer_list","istringstream","jthread","latch","lock_guard","multimap","multiset","mutex","optional","ostringstream","packaged_task","pair","promise","priority_queue","queue","recursive_mutex","recursive_timed_mutex","scoped_lock","set","shared_future","shared_lock","shared_mutex","shared_timed_mutex","shared_ptr","stack","string_view","stringstream","timed_mutex","thread","true_type","tuple","unique_lock","unique_ptr","unordered_map","unordered_multimap","unordered_multiset","unordered_set","variant","vector","weak_ptr","wstring","wstring_view"]},n={className:"function.dispatch",relevance:0,keywords:{_hint:["abort","abs","acos","apply","as_const","asin","atan","atan2","calloc","ceil","cerr","cin","clog","cos","cosh","cout","declval","endl","exchange","exit","exp","fabs","floor","fmod","forward","fprintf","fputs","free","frexp","fscanf","future","invoke","isalnum","isalpha","iscntrl","isdigit","isgraph","islower","isprint","ispunct","isspace","isupper","isxdigit","labs","launder","ldexp","log","log10","make_pair","make_shared","make_shared_for_overwrite","make_tuple","make_unique","malloc","memchr","memcmp","memcpy","memset","modf","move","pow","printf","putchar","puts","realloc","scanf","sin","sinh","snprintf","sprintf","sqrt","sscanf","std","stderr","stdin","stdout","strcat","strchr","strcmp","strcpy","strcspn","strlen","strncat","strncmp","strncpy","strpbrk","strrchr","strspn","strstr","swap","tan","tanh","terminate","to_underlying","tolower","toupper","vfprintf","visit","vprintf","vsprintf"]},begin:b.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,a.IDENT_RE,b.lookahead(/(<[^<>]+>|)\s*\(/))},o=[n,j,g,c,a.C_BLOCK_COMMENT_MODE,i,h],p={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:m,contains:o.concat([{begin:/\(/,end:/\)/,keywords:m,contains:o.concat(["self"]),relevance:0}]),relevance:0},q={className:"function",begin:"("+f+"[\\*&\\s]+)+"+l,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:m,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:d,keywords:m,relevance:0},{begin:l,returnBegin:!0,contains:[k],relevance:0},{begin:/::/,relevance:0},{begin:/:/,endsWithParent:!0,contains:[h,i]},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:m,relevance:0,contains:[c,a.C_BLOCK_COMMENT_MODE,h,i,g,{begin:/\(/,end:/\)/,keywords:m,relevance:0,contains:["self",c,a.C_BLOCK_COMMENT_MODE,h,i,g]}]},g,c,a.C_BLOCK_COMMENT_MODE,j]};return{name:"C++",aliases:["cc","c++","h++","hpp","hh","hxx","cxx"],keywords:m,illegal:"</",classNameAliases:{"function.dispatch":"built_in"},contains:[].concat(p,q,n,o,[j,{begin:"\\b(deque|list|queue|priority_queue|pair|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array|tuple|optional|variant|function|flat_map|flat_set)\\s*<(?!<)",end:">",keywords:m,contains:["self",g]},{begin:a.IDENT_RE+"::",keywords:m},{match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/],className:{1:"keyword",3:"title.class"}}])}},csharp:function(a){let b={keyword:["abstract","as","base","break","case","catch","class","const","continue","do","else","event","explicit","extern","finally","fixed","for","foreach","goto","if","implicit","in","interface","internal","is","lock","namespace","new","operator","out","override","params","private","protected","public","readonly","record","ref","return","scoped","sealed","sizeof","stackalloc","static","struct","switch","this","throw","try","typeof","unchecked","unsafe","using","virtual","void","volatile","while"].concat(["add","alias","and","ascending","args","async","await","by","descending","dynamic","equals","file","from","get","global","group","init","into","join","let","nameof","not","notnull","on","or","orderby","partial","record","remove","required","scoped","select","set","unmanaged","value|0","var","when","where","with","yield"]),built_in:["bool","byte","char","decimal","delegate","double","dynamic","enum","float","int","long","nint","nuint","object","sbyte","short","string","ulong","uint","ushort"],literal:["default","false","null","true"]},c=a.inherit(a.TITLE_MODE,{begin:"[a-zA-Z](\\.?\\w)*"}),d={className:"number",variants:[{begin:"\\b(0b[01']+)"},{begin:"(-?)\\b([\\d']+(\\.[\\d']*)?|\\.[\\d']+)(u|U|l|L|ul|UL|f|F|b|B)"},{begin:"(-?)(\\b0[xX][a-fA-F0-9']+|(\\b[\\d']+(\\.[\\d']*)?|\\.[\\d']+)([eE][-+]?[\\d']+)?)"}],relevance:0},e={className:"string",begin:'@"',end:'"',contains:[{begin:'""'}]},f=a.inherit(e,{illegal:/\n/}),g={className:"subst",begin:/\{/,end:/\}/,keywords:b},h=a.inherit(g,{illegal:/\n/}),i={className:"string",begin:/\$"/,end:'"',illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},a.BACKSLASH_ESCAPE,h]},j={className:"string",begin:/\$@"/,end:'"',contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:'""'},g]},k=a.inherit(j,{illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:'""'},h]});g.contains=[j,i,e,a.APOS_STRING_MODE,a.QUOTE_STRING_MODE,d,a.C_BLOCK_COMMENT_MODE],h.contains=[k,i,f,a.APOS_STRING_MODE,a.QUOTE_STRING_MODE,d,a.inherit(a.C_BLOCK_COMMENT_MODE,{illegal:/\n/})];let l={variants:[{className:"string",begin:/"""("*)(?!")(.|\n)*?"""\1/,relevance:1},j,i,e,a.APOS_STRING_MODE,a.QUOTE_STRING_MODE]},m={begin:"<",end:">",contains:[{beginKeywords:"in out"},c]},n=a.IDENT_RE+"(<"+a.IDENT_RE+"(\\s*,\\s*"+a.IDENT_RE+")*>)?(\\[\\])?",o={begin:"@"+a.IDENT_RE,relevance:0};return{name:"C#",aliases:["cs","c#"],keywords:b,illegal:/::/,contains:[a.COMMENT("///","$",{returnBegin:!0,contains:[{className:"doctag",variants:[{begin:"///",relevance:0},{begin:"<!--|-->"},{begin:"</?",end:">"}]}]}),a.C_LINE_COMMENT_MODE,a.C_BLOCK_COMMENT_MODE,{className:"meta",begin:"#",end:"$",keywords:{keyword:"if else elif endif define undef warning error line region endregion pragma checksum"}},l,d,{beginKeywords:"class interface",relevance:0,end:/[{;=]/,illegal:/[^\s:,]/,contains:[{beginKeywords:"where class"},c,m,a.C_LINE_COMMENT_MODE,a.C_BLOCK_COMMENT_MODE]},{beginKeywords:"namespace",relevance:0,end:/[{;=]/,illegal:/[^\s:]/,contains:[c,a.C_LINE_COMMENT_MODE,a.C_BLOCK_COMMENT_MODE]},{beginKeywords:"record",relevance:0,end:/[{;=]/,illegal:/[^\s:]/,contains:[c,m,a.C_LINE_COMMENT_MODE,a.C_BLOCK_COMMENT_MODE]},{className:"meta",begin:"^\\s*\\[(?=[\\w])",excludeBegin:!0,end:"\\]",excludeEnd:!0,contains:[{className:"string",begin:/"/,end:/"/}]},{beginKeywords:"new return throw await else",relevance:0},{className:"function",begin:"("+n+"\\s+)+"+a.IDENT_RE+"\\s*(<[^=]+>\\s*)?\\(",returnBegin:!0,end:/\s*[{;=]/,excludeEnd:!0,keywords:b,contains:[{beginKeywords:"public private protected static internal protected abstract async extern override unsafe virtual new sealed partial",relevance:0},{begin:a.IDENT_RE+"\\s*(<[^=]+>\\s*)?\\(",returnBegin:!0,contains:[a.TITLE_MODE,m],relevance:0},{match:/\(\)/},{className:"params",begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:b,relevance:0,contains:[l,d,a.C_BLOCK_COMMENT_MODE]},a.C_LINE_COMMENT_MODE,a.C_BLOCK_COMMENT_MODE]},o]}},css:an.default,diff:function(a){let b=a.regex;return{name:"Diff",aliases:["patch"],contains:[{className:"meta",relevance:10,match:b.either(/^@@ +-\d+,\d+ +\+\d+,\d+ +@@/,/^\*\*\* +\d+,\d+ +\*\*\*\*$/,/^--- +\d+,\d+ +----$/)},{className:"comment",variants:[{begin:b.either(/Index: /,/^index/,/={3,}/,/^-{3}/,/^\*{3} /,/^\+{3}/,/^diff --git/),end:/$/},{match:/^\*{15}$/}]},{className:"addition",begin:/^\+/,end:/$/},{className:"deletion",begin:/^-/,end:/$/},{className:"addition",begin:/^!/,end:/$/}]}},go:ao.default,graphql:function(a){let b=a.regex;return{name:"GraphQL",aliases:["gql"],case_insensitive:!0,disableAutodetect:!1,keywords:{keyword:["query","mutation","subscription","type","input","schema","directive","interface","union","scalar","fragment","enum","on"],literal:["true","false","null"]},contains:[a.HASH_COMMENT_MODE,a.QUOTE_STRING_MODE,a.NUMBER_MODE,{scope:"punctuation",match:/[.]{3}/,relevance:0},{scope:"punctuation",begin:/[\!\(\)\:\=\[\]\{\|\}]{1}/,relevance:0},{scope:"variable",begin:/\$/,end:/\W/,excludeEnd:!0,relevance:0},{scope:"meta",match:/@\w+/,excludeEnd:!0},{scope:"symbol",begin:b.concat(/[_A-Za-z][_0-9A-Za-z]*/,b.lookahead(/\s*:/)),relevance:0}],illegal:[/[;<']/,/BEGIN/]}},ini:function(a){let b=a.regex,c={className:"number",relevance:0,variants:[{begin:/([+-]+)?[\d]+_[\d_]+/},{begin:a.NUMBER_RE}]},d=a.COMMENT();d.variants=[{begin:/;/,end:/$/},{begin:/#/,end:/$/}];let e={className:"variable",variants:[{begin:/\$[\w\d"][\w\d_]*/},{begin:/\$\{(.*?)\}/}]},f={className:"literal",begin:/\bon|off|true|false|yes|no\b/},g={className:"string",contains:[a.BACKSLASH_ESCAPE],variants:[{begin:"'''",end:"'''",relevance:10},{begin:'"""',end:'"""',relevance:10},{begin:'"',end:'"'},{begin:"'",end:"'"}]},h=b.either(/[A-Za-z0-9_-]+/,/"(\\"|[^"])*"/,/'[^']*'/);return{name:"TOML, also INI",aliases:["toml"],case_insensitive:!0,illegal:/\S/,contains:[d,{className:"section",begin:/\[+/,end:/\]+/},{begin:b.concat(h,"(\\s*\\.\\s*",h,")*",b.lookahead(/\s*=\s*[^#\s]/)),className:"attr",starts:{end:/$/,contains:[d,{begin:/\[/,end:/\]/,contains:[d,f,e,g,c,"self"],relevance:0},f,e,g,c]}}]}},java:function(a){let b=a.regex,c="[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*",d=c+function a(b,c,d){return -1===d?"":b.replace(c,e=>a(b,c,d-1))}("(?:<"+c+"~~~(?:\\s*,\\s*"+c+"~~~)*>)?",/~~~/g,2),e={keyword:["synchronized","abstract","private","var","static","if","const ","for","while","strictfp","finally","protected","import","native","final","void","enum","else","break","transient","catch","instanceof","volatile","case","assert","package","default","public","try","switch","continue","throws","protected","public","private","module","requires","exports","do","sealed","yield","permits","goto","when"],literal:["false","true","null"],type:["char","boolean","long","float","int","byte","short","double"],built_in:["super","this"]},f={className:"meta",begin:"@"+c,contains:[{begin:/\(/,end:/\)/,contains:["self"]}]},g={className:"params",begin:/\(/,end:/\)/,keywords:e,relevance:0,contains:[a.C_BLOCK_COMMENT_MODE],endsParent:!0};return{name:"Java",aliases:["jsp"],keywords:e,illegal:/<\/|#/,contains:[a.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{begin:/\w+@/,relevance:0},{className:"doctag",begin:"@[A-Za-z]+"}]}),{begin:/import java\.[a-z]+\./,keywords:"import",relevance:2},a.C_LINE_COMMENT_MODE,a.C_BLOCK_COMMENT_MODE,{begin:/"""/,end:/"""/,className:"string",contains:[a.BACKSLASH_ESCAPE]},a.APOS_STRING_MODE,a.QUOTE_STRING_MODE,{match:[/\b(?:class|interface|enum|extends|implements|new)/,/\s+/,c],className:{1:"keyword",3:"title.class"}},{match:/non-sealed/,scope:"keyword"},{begin:[b.concat(/(?!else)/,c),/\s+/,c,/\s+/,/=(?!=)/],className:{1:"type",3:"variable",5:"operator"}},{begin:[/record/,/\s+/,c],className:{1:"keyword",3:"title.class"},contains:[g,a.C_LINE_COMMENT_MODE,a.C_BLOCK_COMMENT_MODE]},{beginKeywords:"new throw return else",relevance:0},{begin:["(?:"+d+"\\s+)",a.UNDERSCORE_IDENT_RE,/\s*(?=\()/],className:{2:"title.function"},keywords:e,contains:[{className:"params",begin:/\(/,end:/\)/,keywords:e,relevance:0,contains:[f,a.APOS_STRING_MODE,a.QUOTE_STRING_MODE,as,a.C_BLOCK_COMMENT_MODE]},a.C_LINE_COMMENT_MODE,a.C_BLOCK_COMMENT_MODE]},as,f]}},javascript:at.default,json:au.default,kotlin:function(a){let b={keyword:"abstract as val var vararg get set class object open private protected public noinline crossinline dynamic final enum if else do while for when throw try catch finally import package is in fun override companion reified inline lateinit init interface annotation data sealed internal infix operator out by constructor super tailrec where const inner suspend typealias external expect actual",built_in:"Byte Short Char Int Long Boolean Float Double Void Unit Nothing",literal:"true false null"},c={className:"symbol",begin:a.UNDERSCORE_IDENT_RE+"@"},d={className:"subst",begin:/\$\{/,end:/\}/,contains:[a.C_NUMBER_MODE]},e={className:"variable",begin:"\\$"+a.UNDERSCORE_IDENT_RE},f={className:"string",variants:[{begin:'"""',end:'"""(?=[^"])',contains:[e,d]},{begin:"'",end:"'",illegal:/\n/,contains:[a.BACKSLASH_ESCAPE]},{begin:'"',end:'"',illegal:/\n/,contains:[a.BACKSLASH_ESCAPE,e,d]}]};d.contains.push(f);let g={className:"meta",begin:"@(?:file|property|field|get|set|receiver|param|setparam|delegate)\\s*:(?:\\s*"+a.UNDERSCORE_IDENT_RE+")?"},h={className:"meta",begin:"@"+a.UNDERSCORE_IDENT_RE,contains:[{begin:/\(/,end:/\)/,contains:[a.inherit(f,{className:"string"}),"self"]}]},i=a.COMMENT("/\\*","\\*/",{contains:[a.C_BLOCK_COMMENT_MODE]}),j={variants:[{className:"type",begin:a.UNDERSCORE_IDENT_RE},{begin:/\(/,end:/\)/,contains:[]}]};return j.variants[1].contains=[j],j.variants[1].contains=[j],{name:"Kotlin",aliases:["kt","kts"],keywords:b,contains:[a.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"}]}),a.C_LINE_COMMENT_MODE,i,{className:"keyword",begin:/\b(break|continue|return|this)\b/,starts:{contains:[{className:"symbol",begin:/@\w+/}]}},c,g,h,{className:"function",beginKeywords:"fun",end:"[(]|$",returnBegin:!0,excludeEnd:!0,keywords:b,relevance:5,contains:[{begin:a.UNDERSCORE_IDENT_RE+"\\s*\\(",returnBegin:!0,relevance:0,contains:[a.UNDERSCORE_TITLE_MODE]},{className:"type",begin:/</,end:/>/,keywords:"reified",relevance:0},{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:b,relevance:0,contains:[{begin:/:/,end:/[=,\/]/,endsWithParent:!0,contains:[j,a.C_LINE_COMMENT_MODE,i],relevance:0},a.C_LINE_COMMENT_MODE,i,g,h,f,a.C_NUMBER_MODE]},i]},{begin:[/class|interface|trait/,/\s+/,a.UNDERSCORE_IDENT_RE],beginScope:{3:"title.class"},keywords:"class interface trait",end:/[:\{(]|$/,excludeEnd:!0,illegal:"extends implements",contains:[{beginKeywords:"public protected internal private constructor"},a.UNDERSCORE_TITLE_MODE,{className:"type",begin:/</,end:/>/,excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:/[,:]\s*/,end:/[<\(,){\s]|$/,excludeBegin:!0,returnEnd:!0},g,h]},f,{className:"meta",begin:"^#!/usr/bin/env",end:"$",illegal:"\n"},ay]}},less:function(a){let b={IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:a.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[a.APOS_STRING_MODE,a.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:a.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}},c="[\\w-]+",d="("+c+"|@\\{"+c+"\\})",e=[],f=[],g=function(a){return{className:"string",begin:"~?"+a+".*?"+a}},h=function(a,b,c){return{className:a,begin:b,relevance:c}},i={$pattern:/[a-z-]+/,keyword:"and or not only",attribute:aA.join(" ")};f.push(a.C_LINE_COMMENT_MODE,a.C_BLOCK_COMMENT_MODE,g("'"),g('"'),b.CSS_NUMBER_MODE,{begin:"(url|data-uri)\\(",starts:{className:"string",end:"[\\)\\n]",excludeEnd:!0}},b.HEXCOLOR,{begin:"\\(",end:"\\)",contains:f,keywords:i,relevance:0},h("variable","@@?"+c,10),h("variable","@\\{"+c+"\\}"),h("built_in","~?`[^`]*?`"),{className:"attribute",begin:c+"\\s*:",end:":",returnBegin:!0,excludeEnd:!0},b.IMPORTANT,{beginKeywords:"and not"},b.FUNCTION_DISPATCH);let j=f.concat({begin:/\{/,end:/\}/,contains:e}),k={beginKeywords:"when",endsWithParent:!0,contains:[{beginKeywords:"and not"}].concat(f)},l={begin:d+"\\s*:",returnBegin:!0,end:/[;}]/,relevance:0,contains:[{begin:/-(webkit|moz|ms|o)-/},b.CSS_VARIABLE,{className:"attribute",begin:"\\b("+aD.join("|")+")\\b",end:/(?=:)/,starts:{endsWithParent:!0,illegal:"[<=$]",relevance:0,contains:f}}]},m={variants:[{begin:"[\\.#:&\\[>]",end:"[;{}]"},{begin:d,end:/\{/}],returnBegin:!0,returnEnd:!0,illegal:"[<='$\"]",relevance:0,contains:[a.C_LINE_COMMENT_MODE,a.C_BLOCK_COMMENT_MODE,k,h("keyword","all\\b"),h("variable","@\\{"+c+"\\}"),{begin:"\\b("+az.join("|")+")\\b",className:"selector-tag"},b.CSS_NUMBER_MODE,h("selector-tag",d,0),h("selector-id","#"+d),h("selector-class","\\."+d,0),h("selector-tag","&",0),b.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",begin:":("+aB.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+aC.join("|")+")"},{begin:/\(/,end:/\)/,relevance:0,contains:j},{begin:"!important"},b.FUNCTION_DISPATCH]},n={begin:c+":(:)?"+`(${aE.join("|")})`,returnBegin:!0,contains:[m]};return e.push(a.C_LINE_COMMENT_MODE,a.C_BLOCK_COMMENT_MODE,{className:"keyword",begin:"@(import|media|charset|font-face|(-[a-z]+-)?keyframes|supports|document|namespace|page|viewport|host)\\b",starts:{end:"[;{}]",keywords:i,returnEnd:!0,contains:f,relevance:0}},{className:"variable",variants:[{begin:"@"+c+"\\s*:",relevance:15},{begin:"@"+c}],starts:{end:"[;}]",returnEnd:!0,contains:j}},n,l,m,k,b.FUNCTION_DISPATCH),{name:"Less",case_insensitive:!0,illegal:"[=>'/<($\"]",contains:e}},lua:function(a){let b="\\[=*\\[",c="\\]=*\\]",d={begin:b,end:c,contains:["self"]},e=[a.COMMENT("--(?!"+b+")","$"),a.COMMENT("--"+b,c,{contains:[d],relevance:10})];return{name:"Lua",aliases:["pluto"],keywords:{$pattern:a.UNDERSCORE_IDENT_RE,literal:"true false nil",keyword:"and break do else elseif end for goto if in local not or repeat return then until while",built_in:"_G _ENV _VERSION __index __newindex __mode __call __metatable __tostring __len __gc __add __sub __mul __div __mod __pow __concat __unm __eq __lt __le assert collectgarbage dofile error getfenv getmetatable ipairs load loadfile loadstring module next pairs pcall print rawequal rawget rawset require select setfenv setmetatable tonumber tostring type unpack xpcall arg self coroutine resume yield status wrap create running debug getupvalue debug sethook getmetatable gethook setmetatable setlocal traceback setfenv getinfo setupvalue getlocal getregistry getfenv io lines write close flush open output type read stderr stdin input stdout popen tmpfile math log max acos huge ldexp pi cos tanh pow deg tan cosh sinh random randomseed frexp ceil floor rad abs sqrt modf asin min mod fmod log10 atan2 exp sin atan os exit setlocale date getenv difftime remove time clock tmpname rename execute package preload loadlib loaded loaders cpath config path seeall string sub upper len gfind rep find match char dump gmatch reverse byte format gsub lower table setn insert getn foreachi maxn foreach concat sort remove"},contains:e.concat([{className:"function",beginKeywords:"function",end:"\\)",contains:[a.inherit(a.TITLE_MODE,{begin:"([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*"}),{className:"params",begin:"\\(",endsWithParent:!0,contains:e}].concat(e)},a.C_NUMBER_MODE,a.APOS_STRING_MODE,a.QUOTE_STRING_MODE,{className:"string",begin:b,end:c,contains:[d],relevance:5}])}},makefile:function(a){let b={className:"variable",variants:[{begin:"\\$\\("+a.UNDERSCORE_IDENT_RE+"\\)",contains:[a.BACKSLASH_ESCAPE]},{begin:/\$[@%<?\^\+\*]/}]},c={className:"string",begin:/"/,end:/"/,contains:[a.BACKSLASH_ESCAPE,b]},d={begin:"^"+a.UNDERSCORE_IDENT_RE+"\\s*(?=[:+?]?=)"};return{name:"Makefile",aliases:["mk","mak","make"],keywords:{$pattern:/[\w-]+/,keyword:"define endef undefine ifdef ifndef ifeq ifneq else endif include -include sinclude override export unexport private vpath"},contains:[a.HASH_COMMENT_MODE,b,c,{className:"variable",begin:/\$\([\w-]+\s/,end:/\)/,keywords:{built_in:"subst patsubst strip findstring filter filter-out sort word wordlist firstword lastword dir notdir suffix basename addsuffix addprefix join wildcard realpath abspath error warning shell origin flavor foreach if or and call eval file value"},contains:[b,c]},d,{className:"meta",begin:/^\.PHONY:/,end:/$/,keywords:{$pattern:/[\.\w]+/,keyword:".PHONY"}},{className:"section",begin:/^[^\s]+:/,end:/$/,contains:[b]}]}},markdown:aF.default,objectivec:function(a){let b=/[a-zA-Z@][a-zA-Z0-9_]*/,c={$pattern:b,keyword:["@interface","@class","@protocol","@implementation"]};return{name:"Objective-C",aliases:["mm","objc","obj-c","obj-c++","objective-c++"],keywords:{"variable.language":["this","super"],$pattern:b,keyword:["while","export","sizeof","typedef","const","struct","for","union","volatile","static","mutable","if","do","return","goto","enum","else","break","extern","asm","case","default","register","explicit","typename","switch","continue","inline","readonly","assign","readwrite","self","@synchronized","id","typeof","nonatomic","IBOutlet","IBAction","strong","weak","copy","in","out","inout","bycopy","byref","oneway","__strong","__weak","__block","__autoreleasing","@private","@protected","@public","@try","@property","@end","@throw","@catch","@finally","@autoreleasepool","@synthesize","@dynamic","@selector","@optional","@required","@encode","@package","@import","@defs","@compatibility_alias","__bridge","__bridge_transfer","__bridge_retained","__bridge_retain","__covariant","__contravariant","__kindof","_Nonnull","_Nullable","_Null_unspecified","__FUNCTION__","__PRETTY_FUNCTION__","__attribute__","getter","setter","retain","unsafe_unretained","nonnull","nullable","null_unspecified","null_resettable","class","instancetype","NS_DESIGNATED_INITIALIZER","NS_UNAVAILABLE","NS_REQUIRES_SUPER","NS_RETURNS_INNER_POINTER","NS_INLINE","NS_AVAILABLE","NS_DEPRECATED","NS_ENUM","NS_OPTIONS","NS_SWIFT_UNAVAILABLE","NS_ASSUME_NONNULL_BEGIN","NS_ASSUME_NONNULL_END","NS_REFINED_FOR_SWIFT","NS_SWIFT_NAME","NS_SWIFT_NOTHROW","NS_DURING","NS_HANDLER","NS_ENDHANDLER","NS_VALUERETURN","NS_VOIDRETURN"],literal:["false","true","FALSE","TRUE","nil","YES","NO","NULL"],built_in:["dispatch_once_t","dispatch_queue_t","dispatch_sync","dispatch_async","dispatch_once"],type:["int","float","char","unsigned","signed","short","long","double","wchar_t","unichar","void","bool","BOOL","id|0","_Bool"]},illegal:"</",contains:[{className:"built_in",begin:"\\b(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)\\w+"},a.C_LINE_COMMENT_MODE,a.C_BLOCK_COMMENT_MODE,a.C_NUMBER_MODE,a.QUOTE_STRING_MODE,a.APOS_STRING_MODE,{className:"string",variants:[{begin:'@"',end:'"',illegal:"\\n",contains:[a.BACKSLASH_ESCAPE]}]},{className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},a.inherit(a.QUOTE_STRING_MODE,{className:"string"}),{className:"string",begin:/<.*?>/,end:/$/,illegal:"\\n"},a.C_LINE_COMMENT_MODE,a.C_BLOCK_COMMENT_MODE]},{className:"class",begin:"("+c.keyword.join("|")+")\\b",end:/(\{|$)/,excludeEnd:!0,keywords:c,contains:[a.UNDERSCORE_TITLE_MODE]},{begin:"\\."+a.UNDERSCORE_IDENT_RE,relevance:0}]}},perl:function(a){let b=a.regex,c=/[dualxmsipngr]{0,12}/,d={$pattern:/[\w.]+/,keyword:"abs accept alarm and atan2 bind binmode bless break caller chdir chmod chomp chop chown chr chroot class close closedir connect continue cos crypt dbmclose dbmopen defined delete die do dump each else elsif endgrent endhostent endnetent endprotoent endpwent endservent eof eval exec exists exit exp fcntl field fileno flock for foreach fork format formline getc getgrent getgrgid getgrnam gethostbyaddr gethostbyname gethostent getlogin getnetbyaddr getnetbyname getnetent getpeername getpgrp getpriority getprotobyname getprotobynumber getprotoent getpwent getpwnam getpwuid getservbyname getservbyport getservent getsockname getsockopt given glob gmtime goto grep gt hex if index int ioctl join keys kill last lc lcfirst length link listen local localtime log lstat lt ma map method mkdir msgctl msgget msgrcv msgsnd my ne next no not oct open opendir or ord our pack package pipe pop pos print printf prototype push q|0 qq quotemeta qw qx rand read readdir readline readlink readpipe recv redo ref rename require reset return reverse rewinddir rindex rmdir say scalar seek seekdir select semctl semget semop send setgrent sethostent setnetent setpgrp setpriority setprotoent setpwent setservent setsockopt shift shmctl shmget shmread shmwrite shutdown sin sleep socket socketpair sort splice split sprintf sqrt srand stat state study sub substr symlink syscall sysopen sysread sysseek system syswrite tell telldir tie tied time times tr truncate uc ucfirst umask undef unless unlink unpack unshift untie until use utime values vec wait waitpid wantarray warn when while write x|0 xor y|0"},e={className:"subst",begin:"[$@]\\{",end:"\\}",keywords:d},f={begin:/->\{/,end:/\}/},g={scope:"attr",match:/\s+:\s*\w+(\s*\(.*?\))?/},h={scope:"variable",variants:[{begin:/\$\d/},{begin:b.concat(/[$%@](?!")(\^\w\b|#\w+(::\w+)*|\{\w+\}|\w+(::\w*)*)/,"(?![A-Za-z])(?![@$%])")},{begin:/[$%@](?!")[^\s\w{=]|\$=/,relevance:0}],contains:[g]},i={className:"number",variants:[{match:/0?\.[0-9][0-9_]+\b/},{match:/\bv?(0|[1-9][0-9_]*(\.[0-9_]+)?|[1-9][0-9_]*)\b/},{match:/\b0[0-7][0-7_]*\b/},{match:/\b0x[0-9a-fA-F][0-9a-fA-F_]*\b/},{match:/\b0b[0-1][0-1_]*\b/}],relevance:0},j=[a.BACKSLASH_ESCAPE,e,h],k=[/!/,/\//,/\|/,/\?/,/'/,/"/,/#/],l=(a,d,e="\\1")=>{let f="\\1"===e?e:b.concat(e,d);return b.concat(b.concat("(?:",a,")"),d,/(?:\\.|[^\\\/])*?/,f,/(?:\\.|[^\\\/])*?/,e,c)},m=(a,d,e)=>b.concat(b.concat("(?:",a,")"),d,/(?:\\.|[^\\\/])*?/,e,c),n=[h,a.HASH_COMMENT_MODE,a.COMMENT(/^=\w/,/=cut/,{endsWithParent:!0}),f,{className:"string",contains:j,variants:[{begin:"q[qwxr]?\\s*\\(",end:"\\)",relevance:5},{begin:"q[qwxr]?\\s*\\[",end:"\\]",relevance:5},{begin:"q[qwxr]?\\s*\\{",end:"\\}",relevance:5},{begin:"q[qwxr]?\\s*\\|",end:"\\|",relevance:5},{begin:"q[qwxr]?\\s*<",end:">",relevance:5},{begin:"qw\\s+q",end:"q",relevance:5},{begin:"'",end:"'",contains:[a.BACKSLASH_ESCAPE]},{begin:'"',end:'"'},{begin:"`",end:"`",contains:[a.BACKSLASH_ESCAPE]},{begin:/\{\w+\}/,relevance:0},{begin:"-?\\w+\\s*=>",relevance:0}]},i,{begin:"(\\/\\/|"+a.RE_STARTERS_RE+"|\\b(split|return|print|reverse|grep)\\b)\\s*",keywords:"split return print reverse grep",relevance:0,contains:[a.HASH_COMMENT_MODE,{className:"regexp",variants:[{begin:l("s|tr|y",b.either(...k,{capture:!0}))},{begin:l("s|tr|y","\\(","\\)")},{begin:l("s|tr|y","\\[","\\]")},{begin:l("s|tr|y","\\{","\\}")}],relevance:2},{className:"regexp",variants:[{begin:/(m|qr)\/\//,relevance:0},{begin:m("(?:m|qr)?",/\//,/\//)},{begin:m("m|qr",b.either(...k,{capture:!0}),/\1/)},{begin:m("m|qr",/\(/,/\)/)},{begin:m("m|qr",/\[/,/\]/)},{begin:m("m|qr",/\{/,/\}/)}]}]},{className:"function",beginKeywords:"sub method",end:"(\\s*\\(.*?\\))?[;{]",excludeEnd:!0,relevance:5,contains:[a.TITLE_MODE,g]},{className:"class",beginKeywords:"class",end:"[;{]",excludeEnd:!0,relevance:5,contains:[a.TITLE_MODE,g,i]},{begin:"-\\w\\b",relevance:0},{begin:"^__DATA__$",end:"^__END__$",subLanguage:"mojolicious",contains:[{begin:"^@@.*",end:"$",className:"comment"}]}];return e.contains=n,f.contains=n,{name:"Perl",aliases:["pl","pm"],keywords:d,contains:n}},php:function(a){let b,c=a.regex,d=/(?![A-Za-z0-9])(?![$])/,e=c.concat(/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/,d),f=c.concat(/(\\?[A-Z][a-z0-9_\x7f-\xff]+|\\?[A-Z]+(?=[A-Z][a-z0-9_\x7f-\xff])){1,}/,d),g=c.concat(/[A-Z]+/,d),h={scope:"variable",match:"\\$+"+e},i={scope:"subst",variants:[{begin:/\$\w+/},{begin:/\{\$/,end:/\}/}]},j=a.inherit(a.APOS_STRING_MODE,{illegal:null}),k=a.inherit(a.QUOTE_STRING_MODE,{illegal:null,contains:a.QUOTE_STRING_MODE.contains.concat(i)}),l={begin:/<<<[ \t]*(?:(\w+)|"(\w+)")\n/,end:/[ \t]*(\w+)\b/,contains:a.QUOTE_STRING_MODE.contains.concat(i),"on:begin":(a,b)=>{b.data._beginMatch=a[1]||a[2]},"on:end":(a,b)=>{b.data._beginMatch!==a[1]&&b.ignoreMatch()}},m=a.END_SAME_AS_BEGIN({begin:/<<<[ \t]*'(\w+)'\n/,end:/[ \t]*(\w+)\b/}),n="[ \n]",o={scope:"string",variants:[k,j,l,m]},p={scope:"number",variants:[{begin:"\\b0[bB][01]+(?:_[01]+)*\\b"},{begin:"\\b0[oO][0-7]+(?:_[0-7]+)*\\b"},{begin:"\\b0[xX][\\da-fA-F]+(?:_[\\da-fA-F]+)*\\b"},{begin:"(?:\\b\\d+(?:_\\d+)*(\\.(?:\\d+(?:_\\d+)*))?|\\B\\.\\d+)(?:[eE][+-]?\\d+)?"}],relevance:0},q=["false","null","true"],r=["__CLASS__","__DIR__","__FILE__","__FUNCTION__","__COMPILER_HALT_OFFSET__","__LINE__","__METHOD__","__NAMESPACE__","__TRAIT__","die","echo","exit","include","include_once","print","require","require_once","array","abstract","and","as","binary","bool","boolean","break","callable","case","catch","class","clone","const","continue","declare","default","do","double","else","elseif","empty","enddeclare","endfor","endforeach","endif","endswitch","endwhile","enum","eval","extends","final","finally","float","for","foreach","from","global","goto","if","implements","instanceof","insteadof","int","integer","interface","isset","iterable","list","match|0","mixed","new","never","object","or","private","protected","public","readonly","real","return","string","switch","throw","trait","try","unset","use","var","void","while","xor","yield"],s=["Error|0","AppendIterator","ArgumentCountError","ArithmeticError","ArrayIterator","ArrayObject","AssertionError","BadFunctionCallException","BadMethodCallException","CachingIterator","CallbackFilterIterator","CompileError","Countable","DirectoryIterator","DivisionByZeroError","DomainException","EmptyIterator","ErrorException","Exception","FilesystemIterator","FilterIterator","GlobIterator","InfiniteIterator","InvalidArgumentException","IteratorIterator","LengthException","LimitIterator","LogicException","MultipleIterator","NoRewindIterator","OutOfBoundsException","OutOfRangeException","OuterIterator","OverflowException","ParentIterator","ParseError","RangeException","RecursiveArrayIterator","RecursiveCachingIterator","RecursiveCallbackFilterIterator","RecursiveDirectoryIterator","RecursiveFilterIterator","RecursiveIterator","RecursiveIteratorIterator","RecursiveRegexIterator","RecursiveTreeIterator","RegexIterator","RuntimeException","SeekableIterator","SplDoublyLinkedList","SplFileInfo","SplFileObject","SplFixedArray","SplHeap","SplMaxHeap","SplMinHeap","SplObjectStorage","SplObserver","SplPriorityQueue","SplQueue","SplStack","SplSubject","SplTempFileObject","TypeError","UnderflowException","UnexpectedValueException","UnhandledMatchError","ArrayAccess","BackedEnum","Closure","Fiber","Generator","Iterator","IteratorAggregate","Serializable","Stringable","Throwable","Traversable","UnitEnum","WeakReference","WeakMap","Directory","__PHP_Incomplete_Class","parent","php_user_filter","self","static","stdClass"],t={keyword:r,literal:(b=[],q.forEach(a=>{b.push(a),a.toLowerCase()===a?b.push(a.toUpperCase()):b.push(a.toLowerCase())}),b),built_in:s},u=a=>a.map(a=>a.replace(/\|\d+$/,"")),v={variants:[{match:[/new/,c.concat(n,"+"),c.concat("(?!",u(s).join("\\b|"),"\\b)"),f],scope:{1:"keyword",4:"title.class"}}]},w=c.concat(e,"\\b(?!\\()"),x={variants:[{match:[c.concat(/::/,c.lookahead(/(?!class\b)/)),w],scope:{2:"variable.constant"}},{match:[/::/,/class/],scope:{2:"variable.language"}},{match:[f,c.concat(/::/,c.lookahead(/(?!class\b)/)),w],scope:{1:"title.class",3:"variable.constant"}},{match:[f,c.concat("::",c.lookahead(/(?!class\b)/))],scope:{1:"title.class"}},{match:[f,/::/,/class/],scope:{1:"title.class",3:"variable.language"}}]},y={scope:"attr",match:c.concat(e,c.lookahead(":"),c.lookahead(/(?!::)/))},z={relevance:0,begin:/\(/,end:/\)/,keywords:t,contains:[y,h,x,a.C_BLOCK_COMMENT_MODE,o,p,v]},A={relevance:0,match:[/\b/,c.concat("(?!fn\\b|function\\b|",u(r).join("\\b|"),"|",u(s).join("\\b|"),"\\b)"),e,c.concat(n,"*"),c.lookahead(/(?=\()/)],scope:{3:"title.function.invoke"},contains:[z]};z.contains.push(A);let B=[y,x,a.C_BLOCK_COMMENT_MODE,o,p,v],C={begin:c.concat(/#\[\s*\\?/,c.either(f,g)),beginScope:"meta",end:/]/,endScope:"meta",keywords:{literal:q,keyword:["new","array"]},contains:[{begin:/\[/,end:/]/,keywords:{literal:q,keyword:["new","array"]},contains:["self",...B]},...B,{scope:"meta",variants:[{match:f},{match:g}]}]};return{case_insensitive:!1,keywords:t,contains:[C,a.HASH_COMMENT_MODE,a.COMMENT("//","$"),a.COMMENT("/\\*","\\*/",{contains:[{scope:"doctag",match:"@[A-Za-z]+"}]}),{match:/__halt_compiler\(\);/,keywords:"__halt_compiler",starts:{scope:"comment",end:a.MATCH_NOTHING_RE,contains:[{match:/\?>/,scope:"meta",endsParent:!0}]}},{scope:"meta",variants:[{begin:/<\?php/,relevance:10},{begin:/<\?=/},{begin:/<\?/,relevance:.1},{begin:/\?>/}]},{scope:"variable.language",match:/\$this\b/},h,A,x,{match:[/const/,/\s/,e],scope:{1:"keyword",3:"variable.constant"}},v,{scope:"function",relevance:0,beginKeywords:"fn function",end:/[;{]/,excludeEnd:!0,illegal:"[$%\\[]",contains:[{beginKeywords:"use"},a.UNDERSCORE_TITLE_MODE,{begin:"=>",endsParent:!0},{scope:"params",begin:"\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0,keywords:t,contains:["self",C,h,x,a.C_BLOCK_COMMENT_MODE,o,p]}]},{scope:"class",variants:[{beginKeywords:"enum",illegal:/[($"]/},{beginKeywords:"class interface trait",illegal:/[:($"]/}],relevance:0,end:/\{/,excludeEnd:!0,contains:[{beginKeywords:"extends implements"},a.UNDERSCORE_TITLE_MODE]},{beginKeywords:"namespace",relevance:0,end:";",illegal:/[.']/,contains:[a.inherit(a.UNDERSCORE_TITLE_MODE,{scope:"title.class"})]},{beginKeywords:"use",relevance:0,end:";",contains:[{match:/\b(as|const|function)\b/,scope:"keyword"},a.UNDERSCORE_TITLE_MODE]},o,p]}},"php-template":function(a){return{name:"PHP template",subLanguage:"xml",contains:[{begin:/<\?(php|=)?/,end:/\?>/,subLanguage:"php",contains:[{begin:"/\\*",end:"\\*/",skip:!0},{begin:'b"',end:'"',skip:!0},{begin:"b'",end:"'",skip:!0},a.inherit(a.APOS_STRING_MODE,{illegal:null,className:null,contains:null,skip:!0}),a.inherit(a.QUOTE_STRING_MODE,{illegal:null,className:null,contains:null,skip:!0})]}]}},plaintext:function(a){return{name:"Plain text",aliases:["text","txt"],disableAutodetect:!0}},python:aG.default,"python-repl":function(a){return{aliases:["pycon"],contains:[{className:"meta.prompt",starts:{end:/ |$/,starts:{end:"$",subLanguage:"python"}},variants:[{begin:/^>>>(?=[ ]|$)/},{begin:/^\.\.\.(?=[ ]|$)/}]}]}},r:function(a){let b=a.regex,c=/(?:(?:[a-zA-Z]|\.[._a-zA-Z])[._a-zA-Z0-9]*)|\.(?!\d)/,d=b.either(/0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*[pP][+-]?\d+i?/,/0[xX][0-9a-fA-F]+(?:[pP][+-]?\d+)?[Li]?/,/(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?[Li]?/),e=/[=!<>:]=|\|\||&&|:::?|<-|<<-|->>|->|\|>|[-+*\/?!$&|:<=>@^~]|\*\*/,f=b.either(/[()]/,/[{}]/,/\[\[/,/[[\]]/,/\\/,/,/);return{name:"R",keywords:{$pattern:c,keyword:"function if in break next repeat else for while",literal:"NULL NA TRUE FALSE Inf NaN NA_integer_|10 NA_real_|10 NA_character_|10 NA_complex_|10",built_in:"LETTERS letters month.abb month.name pi T F abs acos acosh all any anyNA Arg as.call as.character as.complex as.double as.environment as.integer as.logical as.null.default as.numeric as.raw asin asinh atan atanh attr attributes baseenv browser c call ceiling class Conj cos cosh cospi cummax cummin cumprod cumsum digamma dim dimnames emptyenv exp expression floor forceAndCall gamma gc.time globalenv Im interactive invisible is.array is.atomic is.call is.character is.complex is.double is.environment is.expression is.finite is.function is.infinite is.integer is.language is.list is.logical is.matrix is.na is.name is.nan is.null is.numeric is.object is.pairlist is.raw is.recursive is.single is.symbol lazyLoadDBfetch length lgamma list log max min missing Mod names nargs nzchar oldClass on.exit pos.to.env proc.time prod quote range Re rep retracemem return round seq_along seq_len seq.int sign signif sin sinh sinpi sqrt standardGeneric substitute sum switch tan tanh tanpi tracemem trigamma trunc unclass untracemem UseMethod xtfrm"},contains:[a.COMMENT(/#'/,/$/,{contains:[{scope:"doctag",match:/@examples/,starts:{end:b.lookahead(b.either(/\n^#'\s*(?=@[a-zA-Z]+)/,/\n^(?!#')/)),endsParent:!0}},{scope:"doctag",begin:"@param",end:/$/,contains:[{scope:"variable",variants:[{match:c},{match:/`(?:\\.|[^`\\])+`/}],endsParent:!0}]},{scope:"doctag",match:/@[a-zA-Z]+/},{scope:"keyword",match:/\\[a-zA-Z]+/}]}),a.HASH_COMMENT_MODE,{scope:"string",contains:[a.BACKSLASH_ESCAPE],variants:[a.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\(/,end:/\)(-*)"/}),a.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\{/,end:/\}(-*)"/}),a.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\[/,end:/\](-*)"/}),a.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\(/,end:/\)(-*)'/}),a.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\{/,end:/\}(-*)'/}),a.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\[/,end:/\](-*)'/}),{begin:'"',end:'"',relevance:0},{begin:"'",end:"'",relevance:0}]},{relevance:0,variants:[{scope:{1:"operator",2:"number"},match:[e,d]},{scope:{1:"operator",2:"number"},match:[/%[^%]*%/,d]},{scope:{1:"punctuation",2:"number"},match:[f,d]},{scope:{2:"number"},match:[/[^a-zA-Z0-9._]|^/,d]}]},{scope:{3:"operator"},match:[c,/\s+/,/<-/,/\s+/]},{scope:"operator",relevance:0,variants:[{match:e},{match:/%[^%]*%/}]},{scope:"punctuation",relevance:0,match:f},{begin:"`",end:"`",contains:[{begin:/\\./}]}]}},ruby:function(a){let b=a.regex,c="([a-zA-Z_]\\w*[!?=]?|[-+~]@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?)",d=b.either(/\b([A-Z]+[a-z0-9]+)+/,/\b([A-Z]+[a-z0-9]+)+[A-Z]+/),e=b.concat(d,/(::\w+)*/),f={"variable.constant":["__FILE__","__LINE__","__ENCODING__"],"variable.language":["self","super"],keyword:["alias","and","begin","BEGIN","break","case","class","defined","do","else","elsif","end","END","ensure","for","if","in","module","next","not","or","redo","require","rescue","retry","return","then","undef","unless","until","when","while","yield","include","extend","prepend","public","private","protected","raise","throw"],built_in:["proc","lambda","attr_accessor","attr_reader","attr_writer","define_method","private_constant","module_function"],literal:["true","false","nil"]},g={className:"doctag",begin:"@[A-Za-z]+"},h={begin:"#<",end:">"},i=[a.COMMENT("#","$",{contains:[g]}),a.COMMENT("^=begin","^=end",{contains:[g],relevance:10}),a.COMMENT("^__END__",a.MATCH_NOTHING_RE)],j={className:"subst",begin:/#\{/,end:/\}/,keywords:f},k={className:"string",contains:[a.BACKSLASH_ESCAPE,j],variants:[{begin:/'/,end:/'/},{begin:/"/,end:/"/},{begin:/`/,end:/`/},{begin:/%[qQwWx]?\(/,end:/\)/},{begin:/%[qQwWx]?\[/,end:/\]/},{begin:/%[qQwWx]?\{/,end:/\}/},{begin:/%[qQwWx]?</,end:/>/},{begin:/%[qQwWx]?\//,end:/\//},{begin:/%[qQwWx]?%/,end:/%/},{begin:/%[qQwWx]?-/,end:/-/},{begin:/%[qQwWx]?\|/,end:/\|/},{begin:/\B\?(\\\d{1,3})/},{begin:/\B\?(\\x[A-Fa-f0-9]{1,2})/},{begin:/\B\?(\\u\{?[A-Fa-f0-9]{1,6}\}?)/},{begin:/\B\?(\\M-\\C-|\\M-\\c|\\c\\M-|\\M-|\\C-\\M-)[\x20-\x7e]/},{begin:/\B\?\\(c|C-)[\x20-\x7e]/},{begin:/\B\?\\?\S/},{begin:b.concat(/<<[-~]?'?/,b.lookahead(/(\w+)(?=\W)[^\n]*\n(?:[^\n]*\n)*?\s*\1\b/)),contains:[a.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,contains:[a.BACKSLASH_ESCAPE,j]})]}]},l="[0-9](_?[0-9])*",m={className:"number",relevance:0,variants:[{begin:`\\b([1-9](_?[0-9])*|0)(\\.(${l}))?([eE][+-]?(${l})|r)?i?\\b`},{begin:"\\b0[dD][0-9](_?[0-9])*r?i?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*r?i?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*r?i?\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*r?i?\\b"},{begin:"\\b0(_?[0-7])+r?i?\\b"}]},n={variants:[{match:/\(\)/},{className:"params",begin:/\(/,end:/(?=\))/,excludeBegin:!0,endsParent:!0,keywords:f}]},o=[k,{variants:[{match:[/class\s+/,e,/\s+<\s+/,e]},{match:[/\b(class|module)\s+/,e]}],scope:{2:"title.class",4:"title.class.inherited"},keywords:f},{match:[/(include|extend)\s+/,e],scope:{2:"title.class"},keywords:f},{relevance:0,match:[e,/\.new[. (]/],scope:{1:"title.class"}},{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"},{relevance:0,match:d,scope:"title.class"},{match:[/def/,/\s+/,c],scope:{1:"keyword",3:"title.function"},contains:[n]},{begin:a.IDENT_RE+"::"},{className:"symbol",begin:a.UNDERSCORE_IDENT_RE+"(!|\\?)?:",relevance:0},{className:"symbol",begin:":(?!\\s)",contains:[k,{begin:c}],relevance:0},m,{className:"variable",begin:"(\\$\\W)|((\\$|@@?)(\\w+))(?=[^@$?])(?![A-Za-z])(?![@$?'])"},{className:"params",begin:/\|(?!=)/,end:/\|/,excludeBegin:!0,excludeEnd:!0,relevance:0,keywords:f},{begin:"("+a.RE_STARTERS_RE+"|unless)\\s*",keywords:"unless",contains:[{className:"regexp",contains:[a.BACKSLASH_ESCAPE,j],illegal:/\n/,variants:[{begin:"/",end:"/[a-z]*"},{begin:/%r\{/,end:/\}[a-z]*/},{begin:"%r\\(",end:"\\)[a-z]*"},{begin:"%r!",end:"![a-z]*"},{begin:"%r\\[",end:"\\][a-z]*"}]}].concat(h,i),relevance:0}].concat(h,i);j.contains=o,n.contains=o;let p=[{begin:/^\s*=>/,starts:{end:"$",contains:o}},{className:"meta.prompt",begin:"^([>?]>|[\\w#]+\\(\\w+\\):\\d+:\\d+[>*]|(\\w+-)?\\d+\\.\\d+\\.\\d+(p\\d+)?[^\\d][^>]+>)(?=[ ])",starts:{end:"$",keywords:f,contains:o}}];return i.unshift(h),{name:"Ruby",aliases:["rb","gemspec","podspec","thor","irb"],keywords:f,illegal:/\/\*/,contains:[a.SHEBANG({binary:"ruby"})].concat(p).concat(i).concat(o)}},rust:aH.default,scss:function(a){let b={IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:a.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[a.APOS_STRING_MODE,a.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:a.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}},c="@[a-z-]+",d={className:"variable",begin:"(\\$[a-zA-Z-][a-zA-Z0-9_-]*)\\b",relevance:0};return{name:"SCSS",case_insensitive:!0,illegal:"[=/|']",contains:[a.C_LINE_COMMENT_MODE,a.C_BLOCK_COMMENT_MODE,b.CSS_NUMBER_MODE,{className:"selector-id",begin:"#[A-Za-z0-9_-]+",relevance:0},{className:"selector-class",begin:"\\.[A-Za-z0-9_-]+",relevance:0},b.ATTRIBUTE_SELECTOR_MODE,{className:"selector-tag",begin:"\\b("+aI.join("|")+")\\b",relevance:0},{className:"selector-pseudo",begin:":("+aK.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+aL.join("|")+")"},d,{begin:/\(/,end:/\)/,contains:[b.CSS_NUMBER_MODE]},b.CSS_VARIABLE,{className:"attribute",begin:"\\b("+aM.join("|")+")\\b"},{begin:"\\b(whitespace|wait|w-resize|visible|vertical-text|vertical-ideographic|uppercase|upper-roman|upper-alpha|underline|transparent|top|thin|thick|text|text-top|text-bottom|tb-rl|table-header-group|table-footer-group|sw-resize|super|strict|static|square|solid|small-caps|separate|se-resize|scroll|s-resize|rtl|row-resize|ridge|right|repeat|repeat-y|repeat-x|relative|progress|pointer|overline|outside|outset|oblique|nowrap|not-allowed|normal|none|nw-resize|no-repeat|no-drop|newspaper|ne-resize|n-resize|move|middle|medium|ltr|lr-tb|lowercase|lower-roman|lower-alpha|loose|list-item|line|line-through|line-edge|lighter|left|keep-all|justify|italic|inter-word|inter-ideograph|inside|inset|inline|inline-block|inherit|inactive|ideograph-space|ideograph-parenthesis|ideograph-numeric|ideograph-alpha|horizontal|hidden|help|hand|groove|fixed|ellipsis|e-resize|double|dotted|distribute|distribute-space|distribute-letter|distribute-all-lines|disc|disabled|default|decimal|dashed|crosshair|collapse|col-resize|circle|char|center|capitalize|break-word|break-all|bottom|both|bolder|bold|block|bidi-override|below|baseline|auto|always|all-scroll|absolute|table|table-cell)\\b"},{begin:/:/,end:/[;}{]/,relevance:0,contains:[b.BLOCK_COMMENT,d,b.HEXCOLOR,b.CSS_NUMBER_MODE,a.QUOTE_STRING_MODE,a.APOS_STRING_MODE,b.IMPORTANT,b.FUNCTION_DISPATCH]},{begin:"@(page|font-face)",keywords:{$pattern:c,keyword:"@page @font-face"}},{begin:"@",end:"[{;]",returnBegin:!0,keywords:{$pattern:/[a-z-]+/,keyword:"and or not only",attribute:aJ.join(" ")},contains:[{begin:c,className:"keyword"},{begin:/[a-z-]+(?=:)/,className:"attribute"},d,a.QUOTE_STRING_MODE,a.APOS_STRING_MODE,b.HEXCOLOR,b.CSS_NUMBER_MODE]},b.FUNCTION_DISPATCH]}},shell:aN.default,sql:aO.default,swift:function(a){let b={match:/\s+/,relevance:0},c=a.COMMENT("/\\*","\\*/",{contains:["self"]}),d=[a.C_LINE_COMMENT_MODE,c],e={match:[/\./,aS(...aU,...aV)],className:{2:"keyword"}},f={match:aR(/\./,aS(...aX)),relevance:0},g=aX.filter(a=>"string"==typeof a).concat(["_|0"]),h={variants:[{className:"keyword",match:aS(...aX.filter(a=>"string"!=typeof a).concat(aW).map(aT),...aV)}]},i={$pattern:aS(/\b\w+/,/#\w+/),keyword:g.concat(a$),literal:aY},j=[e,f,h],k=[{match:aR(/\./,aS(...a_)),relevance:0},{className:"built_in",match:aR(/\b/,aS(...a_),/(?=\()/)}],l={match:/->/,relevance:0},m=[l,{className:"operator",relevance:0,variants:[{match:a2},{match:`\\.(\\.|${a1})+`}]}],n="([0-9]_*)+",o="([0-9a-fA-F]_*)+",p={className:"number",relevance:0,variants:[{match:`\\b(${n})(\\.(${n}))?([eE][+-]?(${n}))?\\b`},{match:`\\b0x(${o})(\\.(${o}))?([pP][+-]?(${n}))?\\b`},{match:/\b0o([0-7]_*)+\b/},{match:/\b0b([01]_*)+\b/}]},q=(a="")=>({className:"subst",variants:[{match:aR(/\\/,a,/[0\\tnr"']/)},{match:aR(/\\/,a,/u\{[0-9a-fA-F]{1,8}\}/)}]}),r=(a="")=>({className:"subst",label:"interpol",begin:aR(/\\/,a,/\(/),end:/\)/}),s=(a="")=>({begin:aR(a,/"""/),end:aR(/"""/,a),contains:[q(a),((a="")=>({className:"subst",match:aR(/\\/,a,/[\t ]*(?:[\r\n]|\r\n)/)}))(a),r(a)]}),t=(a="")=>({begin:aR(a,/"/),end:aR(/"/,a),contains:[q(a),r(a)]}),u={className:"string",variants:[s(),s("#"),s("##"),s("###"),t(),t("#"),t("##"),t("###")]},v=[a.BACKSLASH_ESCAPE,{begin:/\[/,end:/\]/,relevance:0,contains:[a.BACKSLASH_ESCAPE]}],w=a=>{let b=aR(a,/\//),c=aR(/\//,a);return{begin:b,end:c,contains:[...v,{scope:"comment",begin:`#(?!.*${c})`,end:/$/}]}},x={scope:"regexp",variants:[w("###"),w("##"),w("#"),{begin:/\/[^\s](?=[^/\n]*\/)/,end:/\//,contains:v}]},y={match:aR(/`/,a5,/`/)},z=[y,{className:"variable",match:/\$\d+/},{className:"variable",match:`\\$${a4}+`}],A=[{match:/(@|#(un)?)available/,scope:"keyword",starts:{contains:[{begin:/\(/,end:/\)/,keywords:a8,contains:[...m,p,u]}]}},{scope:"keyword",match:aR(/@/,aS(...a7),aQ(aS(/\(/,/\s+/)))},{scope:"meta",match:aR(/@/,a5)}],B={match:aQ(/\b[A-Z]/),relevance:0,contains:[{className:"type",match:aR(/(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)/,a4,"+")},{className:"type",match:a6,relevance:0},{match:/[?!]+/,relevance:0},{match:/\.\.\./,relevance:0},{match:aR(/\s+&\s+/,aQ(a6)),relevance:0}]},C={begin:/</,end:/>/,keywords:i,contains:[...d,...j,...A,l,B]};B.contains.push(C);let D={begin:/\(/,end:/\)/,relevance:0,keywords:i,contains:["self",{match:aR(a5,/\s*:/),keywords:"_|0",relevance:0},...d,x,...j,...k,...m,p,u,...z,...A,B]},E={begin:/</,end:/>/,keywords:"repeat each",contains:[...d,B]},F={begin:/\(/,end:/\)/,keywords:i,contains:[{begin:aS(aQ(aR(a5,/\s*:/)),aQ(aR(a5,/\s+/,a5,/\s*:/))),end:/:/,relevance:0,contains:[{className:"keyword",match:/\b_\b/},{className:"params",match:a5}]},...d,...j,...m,p,u,...A,B,D],endsParent:!0,illegal:/["']/},G={match:[/(func|macro)/,/\s+/,aS(y.match,a5,a2)],className:{1:"keyword",3:"title.function"},contains:[E,F,b],illegal:[/\[/,/%/]},H={begin:[/precedencegroup/,/\s+/,a6],className:{1:"keyword",3:"title"},contains:[B],keywords:[...aZ,...aY],end:/}/},I={begin:[/(struct|protocol|class|extension|enum|actor)/,/\s+/,a5,/\s*/],beginScope:{1:"keyword",3:"title.class"},keywords:i,contains:[E,...j,{begin:/:/,end:/\{/,keywords:i,contains:[{scope:"title.class.inherited",match:a6},...j],relevance:0}]};for(let a of u.variants){let b=a.contains.find(a=>"interpol"===a.label);b.keywords=i;let c=[...j,...k,...m,p,u,...z];b.contains=[...c,{begin:/\(/,end:/\)/,contains:["self",...c]}]}return{name:"Swift",keywords:i,contains:[...d,G,{match:[/\b(?:subscript|init[?!]?)/,/\s*(?=[<(])/],className:{1:"keyword"},contains:[E,F,b],illegal:/\[|%/},{match:[/class\b/,/\s+/,/func\b/,/\s+/,/\b[A-Za-z_][A-Za-z0-9_]*\b/],scope:{1:"keyword",3:"keyword",5:"title.function"}},{match:[/class\b/,/\s+/,/var\b/],scope:{1:"keyword",3:"keyword"}},I,{match:[/operator/,/\s+/,a2],className:{1:"keyword",3:"title"}},H,{beginKeywords:"import",end:/$/,contains:[...d],relevance:0},x,...j,...k,...m,p,u,...z,...A,B,D]}},typescript:a9.default,vbnet:function(a){let b=a.regex,c=/\d{1,2}\/\d{1,2}\/\d{4}/,d=/\d{4}-\d{1,2}-\d{1,2}/,e=/(\d|1[012])(:\d+){0,2} *(AM|PM)/,f=/\d{1,2}(:\d{1,2}){1,2}/,g={className:"literal",variants:[{begin:b.concat(/# */,b.either(d,c),/ *#/)},{begin:b.concat(/# */,f,/ *#/)},{begin:b.concat(/# */,e,/ *#/)},{begin:b.concat(/# */,b.either(d,c),/ +/,b.either(e,f),/ *#/)}]},h=a.COMMENT(/'''/,/$/,{contains:[{className:"doctag",begin:/<\/?/,end:/>/}]}),i=a.COMMENT(null,/$/,{variants:[{begin:/'/},{begin:/([\t ]|^)REM(?=\s)/}]});return{name:"Visual Basic .NET",aliases:["vb"],case_insensitive:!0,classNameAliases:{label:"symbol"},keywords:{keyword:"addhandler alias aggregate ansi as async assembly auto binary by byref byval call case catch class compare const continue custom declare default delegate dim distinct do each equals else elseif end enum erase error event exit explicit finally for friend from function get global goto group handles if implements imports in inherits interface into iterator join key let lib loop me mid module mustinherit mustoverride mybase myclass namespace narrowing new next notinheritable notoverridable of off on operator option optional order overloads overridable overrides paramarray partial preserve private property protected public raiseevent readonly redim removehandler resume return select set shadows shared skip static step stop structure strict sub synclock take text then throw to try unicode until using when where while widening with withevents writeonly yield",built_in:"addressof and andalso await directcast gettype getxmlnamespace is isfalse isnot istrue like mod nameof new not or orelse trycast typeof xor cbool cbyte cchar cdate cdbl cdec cint clng cobj csbyte cshort csng cstr cuint culng cushort",type:"boolean byte char date decimal double integer long object sbyte short single string uinteger ulong ushort",literal:"true false nothing"},illegal:"//|\\{|\\}|endif|gosub|variant|wend|^\\$ ",contains:[{className:"string",begin:/"(""|[^/n])"C\b/},{className:"string",begin:/"/,end:/"/,illegal:/\n/,contains:[{begin:/""/}]},g,{className:"number",relevance:0,variants:[{begin:/\b\d[\d_]*((\.[\d_]+(E[+-]?[\d_]+)?)|(E[+-]?[\d_]+))[RFD@!#]?/},{begin:/\b\d[\d_]*((U?[SIL])|[%&])?/},{begin:/&H[\dA-F_]+((U?[SIL])|[%&])?/},{begin:/&O[0-7_]+((U?[SIL])|[%&])?/},{begin:/&B[01_]+((U?[SIL])|[%&])?/}]},{className:"label",begin:/^\w+:/},h,i,{className:"meta",begin:/[\t ]*#(const|disable|else|elseif|enable|end|externalsource|if|region)\b/,end:/$/,keywords:{keyword:"const disable else elseif enable end externalsource if region then"},contains:[i]}]}},wasm:function(a){a.regex;let b=a.COMMENT(/\(;/,/;\)/);return b.contains.push("self"),{name:"WebAssembly",keywords:{$pattern:/[\w.]+/,keyword:["anyfunc","block","br","br_if","br_table","call","call_indirect","data","drop","elem","else","end","export","func","global.get","global.set","local.get","local.set","local.tee","get_global","get_local","global","if","import","local","loop","memory","memory.grow","memory.size","module","mut","nop","offset","param","result","return","select","set_global","set_local","start","table","tee_local","then","type","unreachable"]},contains:[a.COMMENT(/;;/,/$/),b,{match:[/(?:offset|align)/,/\s*/,/=/],className:{1:"keyword",3:"operator"}},{className:"variable",begin:/\$[\w_]+/},{match:/(\((?!;)|\))+/,className:"punctuation",relevance:0},{begin:[/(?:func|call|call_indirect)/,/\s+/,/\$[^\s)]+/],className:{1:"keyword",3:"title.function"}},a.QUOTE_STRING_MODE,{match:/(i32|i64|f32|f64)(?!\.)/,className:"type"},{className:"keyword",match:/\b(f32|f64|i32|i64)(?:\.(?:abs|add|and|ceil|clz|const|convert_[su]\/i(?:32|64)|copysign|ctz|demote\/f64|div(?:_[su])?|eqz?|extend_[su]\/i32|floor|ge(?:_[su])?|gt(?:_[su])?|le(?:_[su])?|load(?:(?:8|16|32)_[su])?|lt(?:_[su])?|max|min|mul|nearest|neg?|or|popcnt|promote\/f32|reinterpret\/[fi](?:32|64)|rem_[su]|rot[lr]|shl|shr_[su]|store(?:8|16|32)?|sqrt|sub|trunc(?:_[su]\/f(?:32|64))?|wrap\/i64|xor))\b/},{className:"number",relevance:0,match:/[+-]?\b(?:\d(?:_?\d)*(?:\.\d(?:_?\d)*)?(?:[eE][+-]?\d(?:_?\d)*)?|0x[\da-fA-F](?:_?[\da-fA-F])*(?:\.[\da-fA-F](?:_?[\da-fA-D])*)?(?:[pP][+-]?\d(?:_?\d)*)?)\b|\binf\b|\bnan(?::0x[\da-fA-F](?:_?[\da-fA-D])*)?\b/}]}},xml:ba.default,yaml:bb.default};var bd=a.i(374317),be=a.i(260246);let bf=(0,bd.createLowlight)(bc);function bg(a){return Array.isArray(a)?a.join(""):a??""}let bh=/\x1b\[[0-9;]*[A-Za-z]/g;function bi(a){return a.replace(bh,"")}function bj({output:a}){if("stream"===a.output_type){let c=bi(bg(a.text)),d="stderr"===a.name;return(0,b.jsx)("pre",{className:`whitespace-pre-wrap font-mono text-[12.5px] leading-relaxed px-4 py-3 rounded-md ${d?"bg-[rgba(139,46,62,0.06)] text-[#8B2E3E]":"bg-[#F5EEDC] text-[#2A221B]"}`,children:c})}if("error"===a.output_type){let c=a.traceback.map(bi).join("\n");return(0,b.jsxs)("pre",{className:"whitespace-pre-wrap font-mono text-[12.5px] leading-relaxed px-4 py-3 rounded-md bg-[rgba(139,46,62,0.08)] text-[#8B2E3E] border border-[rgba(139,46,62,0.18)]",children:[(0,b.jsxs)("span",{className:"font-semibold",children:[a.ename,": ",a.evalue]}),c?`
2
2
 
3
- ${c}`:""]})}let c=a.data||{};if(c["image/png"]){let a=`data:image/png;base64,${bg(c["image/png"]).replace(/\s/g,"")}`;return(0,b.jsx)("img",{src:a,alt:"output",className:"max-w-full rounded-md bg-card p-2"})}if(c["image/jpeg"]){let a=`data:image/jpeg;base64,${bg(c["image/jpeg"]).replace(/\s/g,"")}`;return(0,b.jsx)("img",{src:a,alt:"output",className:"max-w-full rounded-md bg-card p-2"})}if(c["image/svg+xml"]){let a=bg(c["image/svg+xml"]);return(0,b.jsx)("div",{className:"max-w-full rounded-md bg-card p-2 overflow-auto",dangerouslySetInnerHTML:{__html:a}})}if(c["text/html"]){let a=bg(c["text/html"]);return(0,b.jsx)("iframe",{srcDoc:`<!doctype html><html><head><base target="_blank"><style>body{margin:0;padding:8px;font-family:-apple-system,BlinkMacSystemFont,Inter,system-ui,sans-serif;background:#FFF9E9;color:#2A221B;font-size:13px}table{border-collapse:collapse}th,td{border:1px solid #D4C4B0;padding:4px 8px;text-align:left}thead{background:#EFE5CC}</style></head><body>${a}</body></html>`,sandbox:"allow-scripts",className:"w-full bg-[#FFF9E9] rounded-md border border-[#E8DDC5]",style:{height:360}})}return c["text/plain"]?(0,b.jsx)("pre",{className:"whitespace-pre-wrap font-mono text-[12.5px] leading-relaxed px-4 py-3 rounded-md bg-[#F5EEDC] text-[#2A221B]",children:bi(bg(c["text/plain"]))}):null}function bk({cell:a,language:c}){let d=bg(a.source),e=(0,T.useMemo)(()=>(function(a,b){try{let c=b?bf.highlight(b,a):bf.highlightAuto(a);return(0,al.toHtml)(c)}catch{return a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}})(d,c),[d,c]),f=a.execution_count??" ",g=(a.outputs?.length??0)>0;return(0,b.jsxs)("div",{className:"grid grid-cols-[60px_1fr] gap-3 mb-5",children:[(0,b.jsxs)("div",{className:"text-right pt-3 select-none font-mono text-[11px] text-[#8B5E3C]",children:["In [",f,"]:"]}),(0,b.jsxs)("div",{children:[(0,b.jsx)("pre",{className:"whitespace-pre overflow-x-auto font-mono text-[13px] leading-relaxed px-4 py-3 rounded-md bg-[#FFF9E9] border border-[#E8DDC5] text-[#2A221B]",children:(0,b.jsx)("code",{dangerouslySetInnerHTML:{__html:e}})}),g&&(0,b.jsxs)("div",{className:"mt-2 grid grid-cols-[60px_1fr] gap-3",children:[(0,b.jsxs)("div",{className:"text-right pt-3 select-none font-mono text-[11px] text-[#8B2E3E]",children:["Out[",f,"]:"]}),(0,b.jsx)("div",{className:"space-y-2",children:a.outputs?.map((a,c)=>(0,b.jsx)(bj,{output:a},c))})]})]})]})}function bl({cell:a}){let[c,d]=(0,T.useState)("");return(0,T.useEffect)(()=>{let b=!1;return(0,be.markdownToHtml)(bg(a.source)).then(a=>{b||d(a)}),()=>{b=!0}},[a.source]),(0,b.jsx)("div",{className:"prose prose-sm max-w-none mb-5 px-1 [&_h1]:font-serif [&_h2]:font-serif [&_h3]:font-serif [&_a]:text-[#8B5E3C] [&_a:hover]:underline [&_code]:bg-[#F5EEDC] [&_code]:px-1.5 [&_code]:py-0.5 [&_code]:rounded [&_code]:text-[#8B2E3E]",dangerouslySetInnerHTML:{__html:c}})}function bm({cell:a}){return(0,b.jsx)("pre",{className:"whitespace-pre-wrap font-mono text-[12.5px] leading-relaxed px-4 py-3 rounded-md bg-[#F5EEDC] text-[#2A221B] mb-5",children:bg(a.source)})}function bn({path:a}){let[d,e]=(0,T.useState)(null),[g,h]=(0,T.useState)(!0),[k,l]=(0,T.useState)(null),[m,n]=(0,T.useState)(!1),o=(0,Y.withWs)(`/api/assets/${a}`),p=a.split("/").pop()||a,q=(0,T.useCallback)(async()=>{h(!0),l(null);try{let a=await (0,Y.wsFetch)(o);if(!a.ok)throw Error(`HTTP ${a.status}`);let b=await a.json();e(b)}catch(a){l(a instanceof Error?a.message:"Failed to load notebook")}finally{h(!1)}},[o]);(0,T.useEffect)(()=>{q()},[q]);let r=d?.metadata?.language_info?.name||d?.metadata?.kernelspec?.name||"python",s=d?.cells?.length??0,t=d?.cells?.filter(a=>"code"===a.cell_type).length??0,u=d?.cells?.some(a=>"code"===a.cell_type&&(a.outputs?.length??0)>0)??!1;return(0,b.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,b.jsxs)($,{path:a,badge:"IPYNB",sublabel:`${s} cells \xb7 ${t} code \xb7 ${r}`,children:[(0,b.jsxs)(U.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>{navigator.clipboard.writeText(`jupyter lab ${a}`),n(!0),setTimeout(()=>n(!1),2e3)},title:"Copy: jupyter lab <path>",children:[m?(0,b.jsx)(f.Check,{className:"h-3.5 w-3.5 text-green-500"}):(0,b.jsx)(i.Copy,{className:"h-3.5 w-3.5"}),m?"Copied":"Copy run cmd"]}),(0,b.jsxs)(U.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>{let a=document.createElement("a");a.href=o,a.download=p,a.click()},children:[(0,b.jsx)(j,{className:"h-3.5 w-3.5"}),"Download"]}),(0,b.jsxs)(U.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>window.open(o,"_blank"),children:[(0,b.jsx)(ae.ExternalLink,{className:"h-3.5 w-3.5"}),"Raw JSON"]})]}),(0,b.jsx)("div",{className:"flex-1 overflow-auto bg-[#F5EEDC]",children:g?(0,b.jsx)("div",{className:"flex items-center justify-center h-full text-[#7A6B5D] text-sm",children:"Loading notebook…"}):k?(0,b.jsxs)("div",{className:"flex items-center justify-center h-full text-[#8B2E3E] text-sm gap-2",children:[(0,b.jsx)(c.AlertCircle,{className:"h-4 w-4"})," ",k]}):d?(0,b.jsxs)("div",{className:"max-w-[1100px] mx-auto py-8 px-6",children:[!u&&t>0&&(0,b.jsxs)("div",{className:"mb-6 rounded-md border border-[#E8DDC5] bg-[#FFF9E9] px-4 py-3 text-[13px] text-[#7A6B5D]",children:[(0,b.jsx)("span",{className:"font-semibold text-[#0c0a09]",children:"This notebook hasn't been run yet."})," ","Code and markdown cells display below; outputs appear once the author runs the notebook in Jupyter (or you do, then re-save)."]}),d.cells?.map((a,c)=>"markdown"===a.cell_type?(0,b.jsx)(bl,{cell:a},c):"raw"===a.cell_type?(0,b.jsx)(bm,{cell:a},c):(0,b.jsx)(bk,{cell:a,language:r},c))]}):null})]})}function bo({path:a,extLabel:c,external:d,hideFinder:e}){let f=(0,Y.withWs)(`/api/assets/${a}`),g=a.split("/").pop()||a,h=async()=>{try{await (0,Y.wsFetch)("/api/system/reveal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a})})}catch{}};return(0,b.jsxs)($,{path:a,badge:c||void 0,children:[d&&(0,b.jsxs)("a",{href:d.href,target:"_blank",rel:"noreferrer noopener",className:"inline-flex items-center gap-1.5 text-[11px] h-7 px-2.5 rounded-md border border-border hover:bg-accent transition-colors",children:[(0,b.jsx)(ae.ExternalLink,{className:"h-3.5 w-3.5"}),d.label]}),!e&&(0,b.jsxs)(U.Button,{variant:"outline",size:"sm",className:"gap-1.5 text-[11px] h-7",onClick:h,title:"Open in Finder",children:[(0,b.jsx)(p,{className:"h-3.5 w-3.5"}),"Reveal"]}),!e&&(0,b.jsxs)(U.Button,{variant:"outline",size:"sm",className:"gap-1.5 text-[11px] h-7",onClick:()=>{let a=document.createElement("a");a.href=f,a.download=g,a.click()},title:"Download original",children:[(0,b.jsx)(j,{className:"h-3.5 w-3.5"}),"Download"]})]})}function bp({path:c,title:d}){let e=(0,T.useRef)(null),[f,g]=(0,T.useState)(!0),[h,i]=(0,T.useState)(null);return(0,T.useEffect)(()=>{let b=!1,d=e.current;if(d)return d.innerHTML="",(async()=>{g(!0),i(null);try{let[{renderAsync:e},f]=await Promise.all([a.A(458647),(0,Y.wsFetch)(`/api/assets/${c}`)]);if(b)return;if(!f.ok)throw Error(`Failed to load file (${f.status})`);let h=await f.blob();if(b)return;await e(h,d,void 0,{className:"docx-rendered",inWrapper:!0,ignoreWidth:!1,ignoreHeight:!1,breakPages:!0,renderHeaders:!0,renderFooters:!0,renderFootnotes:!0,experimental:!0,useBase64URL:!0}),b||g(!1)}catch(a){b||(i(a instanceof Error?a.message:"Failed to render document"),g(!1))}})(),()=>{b=!0}},[c]),(0,b.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,b.jsx)(bo,{path:c,title:d,extLabel:"DOCX"}),(0,b.jsxs)("div",{className:"flex-1 overflow-y-auto bg-muted/30",children:[f&&!h&&(0,b.jsxs)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:[(0,b.jsx)(z.Loader2,{className:"h-5 w-5 animate-spin mr-2"}),"Rendering document…"]}),h&&(0,b.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,b.jsxs)("div",{className:"text-center space-y-2",children:[(0,b.jsx)("p",{className:"text-sm text-destructive",children:h}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:"Try downloading the file and opening it externally."})]})}),(0,b.jsx)("div",{ref:e,className:"docx-viewer-body mx-auto max-w-5xl py-6 px-4"})]})]})}function bq({path:c,title:d}){let e=(0,T.useRef)(null),[f,g]=(0,T.useState)(!0),[h,i]=(0,T.useState)(null);return(0,T.useEffect)(()=>{let b=!1,d=e.current;if(!d)return;d.innerHTML="";let f=null;return(async()=>{g(!0),i(null);try{let[{init:e},h]=await Promise.all([a.A(287443),(0,Y.wsFetch)(`/api/assets/${c}`)]);if(b)return;if(!h.ok)throw Error(`Failed to load file (${h.status})`);let i=await h.arrayBuffer();if(b)return;let j=d.clientWidth||960,k=Math.round(9*j/16);f=e(d,{width:j,height:k,mode:"list"}),await f.preview(i),b||g(!1)}catch(a){b||(i(a instanceof Error?a.message:"Failed to render presentation"),g(!1))}})(),()=>{b=!0;try{f?.destroy?.()}catch{}}},[c]),(0,b.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,b.jsx)(bo,{path:c,title:d,extLabel:"PPTX"}),(0,b.jsxs)("div",{className:"flex-1 overflow-auto bg-muted/30 py-4",children:[f&&!h&&(0,b.jsxs)("div",{className:"h-[60vh] flex items-center justify-center text-muted-foreground",children:[(0,b.jsx)(z.Loader2,{className:"h-5 w-5 animate-spin mr-2"}),"Rendering slides…"]}),h&&(0,b.jsx)("div",{className:"h-[60vh] flex items-center justify-center",children:(0,b.jsxs)("div",{className:"text-center space-y-2",children:[(0,b.jsx)("p",{className:"text-sm text-destructive",children:h}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:"Try downloading the file and opening it externally."})]})}),(0,b.jsx)("div",{ref:e,className:"pptx-viewer-body mx-auto max-w-5xl px-4"})]})]})}function br({path:c,title:d}){let[e,f]=(0,T.useState)(null),[g,h]=(0,T.useState)(0),[i,j]=(0,T.useState)(!0),[k,l]=(0,T.useState)(null),m=(0,T.useRef)(null);(0,T.useEffect)(()=>{if(!e||!m.current)return;let a=e[g];if(!a||null!==a.html)return;let{wb:b,toHtml:c}=m.current,d=c(b.Sheets[a.name]);f(a=>{if(!a)return a;let b=[...a];return b[g]={...b[g],html:d.html,rows:d.rows,truncated:d.truncated},b})},[e,g]),(0,T.useEffect)(()=>{let b=!1;return j(!0),l(null),f(null),(async()=>{try{let[d,e]=await Promise.all([a.A(57386),(0,Y.wsFetch)(`/api/assets/${c}`)]);if(b)return;if(!e.ok)throw Error(`Failed to load file (${e.status})`);let g=await e.arrayBuffer();if(b)return;let i=d.read(g,{type:"array",cellDates:!0,cellStyles:!0});if(b)return;m.current={wb:i,toHtml:a=>{let b=a["!ref"],c=b?d.utils.decode_range(b):null,e=c?c.e.r-c.s.r+1:0;if(!c||e<=2e3)return{html:d.utils.sheet_to_html(a,{editable:!1}),rows:e,truncated:!1};let f={...a,"!ref":d.utils.encode_range({s:c.s,e:{r:c.s.r+2e3-1,c:c.e.c}})};return{html:d.utils.sheet_to_html(f,{editable:!1}),rows:e,truncated:!0}}},f(i.SheetNames.map(a=>({name:a,html:null,rows:0,truncated:!1}))),h(0),j(!1)}catch(a){b||(l(a instanceof Error?a.message:"Failed to parse spreadsheet"),j(!1))}})(),()=>{b=!0}},[c]);let n=(0,T.useMemo)(()=>e?.[g]??null,[e,g]);return(0,b.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,b.jsx)(bo,{path:c,title:d,extLabel:"XLSX"}),e&&e.length>1&&(0,b.jsx)("div",{className:"flex items-center gap-0.5 border-b border-border bg-muted/40 px-2 overflow-x-auto scrollbar-none",children:e.map((a,c)=>(0,b.jsx)("button",{type:"button",onClick:()=>h(c),className:(0,Z.cn)("px-3 py-1.5 text-[12px] rounded-t whitespace-nowrap transition-colors",c===g?"bg-background text-foreground font-medium border-t border-x border-border -mb-px":"text-muted-foreground hover:text-foreground"),children:a.name},a.name+c))}),(0,b.jsxs)("div",{className:"flex-1 overflow-auto",children:[i&&!k&&(0,b.jsxs)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:[(0,b.jsx)(z.Loader2,{className:"h-5 w-5 animate-spin mr-2"}),"Parsing spreadsheet…"]}),k&&(0,b.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,b.jsxs)("div",{className:"text-center space-y-2",children:[(0,b.jsx)("p",{className:"text-sm text-destructive",children:k}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:"Try downloading the file and opening it externally."})]})}),n?.truncated&&(0,b.jsxs)("div",{className:"px-3 py-2 text-[11px] text-amber-600 dark:text-amber-400 border-b border-border",children:["Large sheet (",n.rows.toLocaleString()," rows). Showing first"," ",2e3.toLocaleString()," for performance. Download the file to see everything."]}),n?.html!=null&&(0,b.jsx)("div",{className:"xlsx-sheet p-3 text-[12px]",dangerouslySetInnerHTML:{__html:n.html}})]})]})}var bs=a.i(441218);let bt=(0,d.default)("wrap-text",[["path",{d:"m16 16-2 2 2 2",key:"kkc6pm"}],["path",{d:"M3 12h15a3 3 0 1 1 0 6h-4",key:"1cl7v7"}],["path",{d:"M3 18h7",key:"sq21v6"}],["path",{d:"M3 6h18",key:"d0wm0j"}]]);var bu=a.i(617534),bv=a.i(721034),bw=a.i(396106),bx=a.i(279193);let by=(0,bd.createLowlight)(bc);function bz(a){return a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function bA(a){return`${a.lineStart}:${a.lineEnd}:${a.textHash}`}function bB(a){return`L${a.lineStart}-${a.lineEnd}`}async function bC(a){return Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",new TextEncoder().encode(a)))).map(a=>a.toString(16).padStart(2,"0")).join("").slice(0,12)}let bD={".js":"javascript",".cjs":"javascript",".mjs":"javascript",".ts":"typescript",".tsx":"typescript",".jsx":"javascript",".py":"python",".rb":"ruby",".php":"php",".sh":"bash",".bash":"bash",".zsh":"bash",".ps1":"powershell",".css":"css",".scss":"scss",".html":"xml",".json":"json",".jsonc":"json",".yaml":"yaml",".yml":"yaml",".toml":"ini",".ini":"ini",".xml":"xml",".sql":"sql",".graphql":"graphql",".gql":"graphql",".go":"go",".rs":"rust",".swift":"swift",".java":"java",".kt":"kotlin",".kts":"kotlin",".c":"c",".cpp":"cpp",".h":"c",".env":"bash",".txt":"",".text":"",".log":"",".rst":"",".mdx":"markdown"};function bE({path:a}){let[c,d]=(0,T.useState)(null),[e,g]=(0,T.useState)(0),[h,k]=(0,T.useState)(!1),[l,m]=(0,T.useState)(!0),[n,o]=(0,T.useState)(!1),[p,q]=(0,T.useState)(!1),[r,s]=(0,T.useState)(2e3),[t,u]=(0,T.useState)(new Map),[v,w]=(0,T.useState)(null),x=(0,T.useRef)(null),y=(0,Y.withWs)(`/api/assets/${a}`),z=a.split("/").pop()||a,A=bD[z.includes(".")?`.${z.split(".").pop()?.toLowerCase()}`:""]??"",B=(0,bx.useProofStore)(b=>b.byPath[a]?.sidecar??null),C=B?.comments??[],D=(0,T.useMemo)(()=>c?c.replace(/\r\n/g,"\n").split("\n"):[],[c]),E=(0,T.useCallback)(async()=>{m(!0),k(!1),d(null),g(0);try{let a=await (0,Y.wsFetch)(y);if(a.ok){let b=new Uint8Array(await a.arrayBuffer());!function(a){let b=Math.min(a.length,8192);if(0===b)return!1;let c=0;for(let d=0;d<b;d++){let b=a[d];if(0===b)return!0;(b<9||b>13&&b<32)&&c++}return c/b>.3}(b)?(g(b.length),d(new TextDecoder("utf-8").decode(b))):k(!0)}}catch{}finally{m(!1)}},[y]);(0,T.useEffect)(()=>{E(),bx.useProofStore.getState().loadSidecar(a),s(2e3),w(null)},[E,a]);let F=(0,T.useMemo)(()=>D.length,[D]),G=e>2097152||F>5e3,H=(0,T.useMemo)(()=>{if(!c)return[];if(G)return D.map(bz);try{let a=A?by.highlight(A,c):by.highlightAuto(c);return(0,al.toHtml)(a).split("\n")}catch{return D.map(bz)}},[c,A,G,D]),I=G?H.slice(0,r):H,J=G&&r<H.length,K=(0,T.useMemo)(()=>{let a={};for(let b of C){if(!b.lineAnchor)continue;let c=bA(b.lineAnchor);(a[c]??=[]).push(b)}return a},[C]);(0,T.useEffect)(()=>{if(!c||h||l||!x.current)return void u(new Map);let a=x.current,b=a.getBoundingClientRect(),d=Array.from(a.querySelectorAll("[data-line]")),e=new Map;for(let c of d){let d=Number(c.dataset.line);if(!Number.isFinite(d))continue;let f=c.getBoundingClientRect();e.set(d,{top:f.top-b.top+a.scrollTop,left:f.left-b.left,width:f.width,bottom:f.bottom-b.top+a.scrollTop})}u(e)},[c,h,l,r,n,H]);let L=(0,T.useCallback)(()=>{let a=x.current,b=window.getSelection();if(!a||!b||b.isCollapsed||0===b.rangeCount)return;let c=b.getRangeAt(0);if(!a.contains(c.commonAncestorContainer))return;let d=a=>{let b=a?a.nodeType===Node.ELEMENT_NODE?a:a.parentElement:null;return b?.closest("[data-line]")??null},e=d(c.startContainer),f=d(c.endContainer);if(!e||!f)return;let g=Number(e.dataset.line),h=Number(f.dataset.line);if(!Number.isFinite(g)||!Number.isFinite(h))return;let i=Math.min(g,h),j=Math.max(g,h),k=D.slice(i-1,j).join("\n");(async()=>{let a={lineStart:i,lineEnd:j,textHash:await bC(k)};w({anchorKey:bA(a),anchorLabel:bB(a),lineAnchor:a,anchorEl:e})})()},[D]),M=(0,T.useCallback)((a,b)=>{w({anchorKey:bA(a),anchorLabel:bB(a),lineAnchor:a,anchorEl:b})},[]);return h?(0,b.jsx)(ad,{path:a,title:z}):(0,b.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,b.jsxs)($,{path:a,badge:z.includes(".")?z.split(".").pop()?.toUpperCase()??"TEXT":"TEXT",sublabel:A||void 0,children:[(0,b.jsxs)(U.Button,{variant:"ghost",size:"sm",className:`h-7 gap-1.5 text-xs ${n?"bg-muted":""}`,onClick:()=>o(a=>!a),title:n?"Disable line wrap":"Enable line wrap",children:[(0,b.jsx)(bt,{className:"h-3.5 w-3.5"}),"Wrap"]}),(0,b.jsxs)(U.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>{c&&(navigator.clipboard.writeText(c),q(!0),setTimeout(()=>q(!1),2e3))},title:"Copy file contents",children:[p?(0,b.jsx)(f.Check,{className:"h-3.5 w-3.5 text-green-500"}):(0,b.jsx)(i.Copy,{className:"h-3.5 w-3.5"}),p?"Copied":"Copy"]}),(0,b.jsxs)(U.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>{let a=document.createElement("a");a.href=y,a.download=z,a.click()},title:"Download file",children:[(0,b.jsx)(j,{className:"h-3.5 w-3.5"}),"Download"]}),(0,b.jsxs)(U.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>window.open(y,"_blank"),children:[(0,b.jsx)(ae.ExternalLink,{className:"h-3.5 w-3.5"}),"Raw"]})]}),(0,b.jsxs)("div",{ref:x,className:"relative flex-1 overflow-auto source-viewer-code bg-muted",children:[!l&&c&&!h&&(0,b.jsx)(bw.ViewModeCommentButton,{containerRef:x,onComment:L,align:"left"}),(0,b.jsx)("div",{className:"relative pointer-events-none",style:{height:0},children:Object.entries(K).map(([a,c])=>{let d=c[0]?.lineAnchor;if(!d)return null;let e=t.get(d.lineStart);return e?(0,b.jsx)("div",{style:{pointerEvents:"auto"},children:(0,b.jsx)(bu.CommentPip,{anchorKey:a,anchorLabel:bB(d),comments:c,top:e.top+4,left:Math.max(0,e.left-20),onClick:()=>{let a=x.current?.querySelector(`[data-line="${d.lineStart}"]`);a&&M(d,a)}})},`pip-${a}`):null})}),l?(0,b.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Loading..."}):(0,b.jsxs)(b.Fragment,{children:[G&&(0,b.jsxs)("div",{className:"px-4 py-2 text-[11px] text-amber-700 dark:text-amber-300 bg-amber-500/15 border-b border-amber-500/30 font-sans",children:["Large file (",(e/1048576).toFixed(1)," MB, ",H.length.toLocaleString()," lines). Syntax highlighting disabled for performance. Use Raw or Download for the full file."]}),(0,b.jsx)("div",{className:"text-[13px] leading-relaxed font-mono min-w-max",children:I.map((a,c)=>{let d=v?.lineAnchor,e=d&&c+1>=d.lineStart&&c+1<=d.lineEnd;return(0,b.jsxs)("div",{"data-line":c+1,className:`flex ${e?"bg-amber-400/25":"hover:bg-foreground/5"}`,children:[(0,b.jsx)("span",{className:"w-12 shrink-0 pr-4 text-right text-muted-foreground select-none sticky left-0 bg-muted",children:c+1}),(0,b.jsx)("span",{className:`text-foreground pl-2 ${n?"whitespace-pre-wrap break-all":"whitespace-pre"}`,dangerouslySetInnerHTML:{__html:a||" "}})]},c)})}),J&&(0,b.jsxs)("div",{className:"flex items-center gap-3 px-4 py-3 border-t border-border font-sans",children:[(0,b.jsxs)("button",{onClick:()=>s(a=>a+2e3),className:"text-[11px] text-foreground hover:text-foreground px-2.5 py-1 rounded bg-foreground/10 hover:bg-foreground/20 transition-colors",children:["Show ",Math.min(2e3,H.length-r).toLocaleString()," more"]}),(0,b.jsxs)("span",{className:"text-[11px] text-muted-foreground",children:[r.toLocaleString()," / ",H.length.toLocaleString()," lines"]})]})]}),v&&(0,b.jsx)(bv.CommentThread,{path:a,anchorKey:v.anchorKey,anchorLabel:v.anchorLabel,lineAnchor:v.lineAnchor,comments:K[v.anchorKey]??[],anchorEl:v.anchorEl,onClose:()=>w(null)})]})]})}var bF=a.i(28529);function bG({path:a,title:c,src:d,fullscreen:e,onExit:f}){let g=(0,Y.withWs)(d??`/api/assets/${a}/index.html`),h=e&&f?(0,b.jsxs)(U.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:f,title:"Exit app",children:[(0,b.jsx)(bF.ArrowLeft,{className:"h-3.5 w-3.5"}),"Exit app"]}):null;return(0,b.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,b.jsx)($,{path:a,badge:e?"App":void 0,showBreadcrumb:!e,leading:e?(0,b.jsxs)(b.Fragment,{children:[h,(0,b.jsx)("span",{className:"truncate text-[13px] font-medium text-foreground",children:c})]}):null,children:(0,b.jsxs)(U.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>window.open(g,"_blank"),children:[(0,b.jsx)(ae.ExternalLink,{className:"h-3.5 w-3.5"}),"Open in new tab"]})}),(0,b.jsx)("iframe",{src:g,className:"flex-1 w-full border-0 bg-card",title:c,sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-top-navigation-by-user-activation"})]})}let bH=(0,d.default)("play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]),bI=(0,d.default)("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);var bJ=a.i(335732);let bK={stopped:"Stopped",installing:"Installing dependencies…",starting:"Starting…",running:"Running",error:"Error"};function bL({path:a,title:d}){let[e,f]=(0,T.useState)("stopped"),[h,i]=(0,T.useState)(null),[j,k]=(0,T.useState)([]),[l,m]=(0,T.useState)(null),[n,o]=(0,T.useState)(!1),[p,q]=(0,T.useState)(0),[r,s]=(0,T.useState)([]),[t,u]=(0,T.useState)(null),v=(0,T.useRef)(null),w=(0,T.useRef)(null),x=`/api/app-proxy/${a}/`,y=()=>{v.current&&(clearInterval(v.current),v.current=null)},A=(0,T.useCallback)(async()=>{try{let b=await (0,Y.wsFetch)(`/api/wiki/app?path=${encodeURIComponent(a)}`);if(!b.ok)return;let c=await b.json();f(c.status),k(c.logs??[]),c.scripts&&s(c.scripts),void 0!==c.defaultScript&&u(c.defaultScript),c.port&&i(c.port),c.error&&m(c.error),("running"===c.status||"stopped"===c.status||"error"===c.status)&&y()}catch{}},[a]);(0,T.useEffect)(()=>("installing"===e||"starting"===e?v.current||(v.current=setInterval(A,800)):y(),y),[e,A]),(0,T.useEffect)(()=>{w.current?.scrollIntoView({behavior:"smooth"})},[j]),(0,T.useEffect)(()=>{A()},[A]);let B=async b=>{m(null),k([]),f("starting");try{let c=await (0,Y.wsFetch)("/api/wiki/app",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a,script:b})}),d=await c.json();if(!c.ok||d.error){f("error"),m(d.error??"Failed to start");return}d.port&&i(d.port),await A()}catch(a){f("error"),m(String(a))}},C=async()=>{await (0,Y.wsFetch)("/api/wiki/app",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a})}),f("stopped"),i(null)},D=async()=>{await C(),await B(),q(a=>a+1)},E=r.filter(a=>a!==t);return(0,b.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,b.jsxs)($,{path:a,badge:"Node app",children:["running"===e&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(U.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>q(a=>a+1),children:[(0,b.jsx)(K,{className:"h-3.5 w-3.5"}),"Refresh"]}),(0,b.jsxs)(U.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>window.open(x,"_blank"),children:[(0,b.jsx)(ae.ExternalLink,{className:"h-3.5 w-3.5"}),"Open in new tab"]}),(0,b.jsxs)(U.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:D,children:[(0,b.jsx)(K,{className:"h-3.5 w-3.5"}),"Restart"]}),(0,b.jsxs)(U.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs text-destructive hover:text-destructive",onClick:C,children:[(0,b.jsx)(bI,{className:"h-3.5 w-3.5"}),"Stop"]})]}),(0,b.jsxs)(U.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>o(a=>!a),children:[(0,b.jsx)(O,{className:"h-3.5 w-3.5"}),"Logs"]})]}),n&&(0,b.jsxs)("div",{className:"border-b bg-black/90 text-green-400 font-mono text-xs h-40 overflow-auto p-2 shrink-0",children:[0===j.length?(0,b.jsx)("span",{className:"text-muted-foreground",children:"No output yet."}):j.map((a,c)=>(0,b.jsx)("div",{className:"whitespace-pre-wrap leading-5",children:a},c)),(0,b.jsx)("div",{ref:w})]}),(0,b.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:["stopped"===e&&(0,b.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-4",children:[(0,b.jsxs)("div",{className:"text-center space-y-1",children:[(0,b.jsx)("p",{className:"text-sm font-medium",children:d}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:"Node.js app — will be started on a local port"})]}),(0,b.jsxs)("div",{className:"inline-flex items-stretch overflow-hidden rounded-full bg-primary text-primary-foreground shadow-e-1",children:[(0,b.jsxs)("button",{type:"button",onClick:()=>B(),className:"inline-flex items-center gap-2 px-4 py-2.5 text-sm font-medium transition-colors hover:bg-primary-foreground/10 focus-visible:outline-none",children:[(0,b.jsx)(bH,{className:"h-4 w-4"}),"Launch app",t&&(0,b.jsxs)("span",{className:"opacity-70",children:["(",t,")"]})]}),E.length>0&&(0,b.jsxs)(bJ.DropdownMenu,{children:[(0,b.jsx)(bJ.DropdownMenuTrigger,{asChild:!0,children:(0,b.jsx)("button",{type:"button",className:"inline-flex items-center justify-center border-l border-l-primary-foreground/20 px-2 transition-colors hover:bg-primary-foreground/10 focus-visible:outline-none","aria-label":"Choose script to launch",children:(0,b.jsx)(g.ChevronDown,{className:"h-4 w-4"})})}),(0,b.jsxs)(bJ.DropdownMenuContent,{align:"end",children:[(0,b.jsx)(bJ.DropdownMenuLabel,{children:"Run script"}),(0,b.jsx)(bJ.DropdownMenuSeparator,{}),r.map(a=>(0,b.jsxs)(bJ.DropdownMenuItem,{onSelect:()=>B(a),className:"gap-2 font-mono text-xs",children:[(0,b.jsx)(bH,{className:"h-3.5 w-3.5"}),a,a===t&&(0,b.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"default"})]},a))]})]})]})]}),("installing"===e||"starting"===e)&&(0,b.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-3",children:[(0,b.jsx)(z.Loader2,{className:"h-6 w-6 animate-spin text-muted-foreground"}),(0,b.jsx)("p",{className:"text-sm text-muted-foreground",children:bK[e]}),h&&(0,b.jsxs)("p",{className:"text-xs text-muted-foreground/60",children:["port ",h]})]}),"error"===e&&(0,b.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-4 p-6",children:[(0,b.jsx)(c.AlertCircle,{className:"h-8 w-8 text-destructive"}),(0,b.jsxs)("div",{className:"text-center space-y-1 max-w-md",children:[(0,b.jsx)("p",{className:"text-sm font-medium text-destructive",children:"Failed to start app"}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground break-words",children:l??"Unknown error"})]}),(0,b.jsxs)(U.Button,{onClick:()=>B(),variant:"outline",className:"gap-2",children:[(0,b.jsx)(K,{className:"h-4 w-4"}),"Try again"]})]}),"running"===e&&(0,b.jsx)("iframe",{src:x,className:"flex-1 w-full border-0 bg-card",title:d,sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-modals allow-top-navigation-by-user-activation"},p)]})]})}let bM=(0,d.default)("hard-drive",[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]]),bN=(0,d.default)("house",[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"1d0kgt"}]]),bO=(0,d.default)("key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]]),bP=(0,d.default)("pin-off",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]]);function bQ({onSelect:a}){let[c,d]=(0,T.useState)("local"),[e,f]=(0,T.useState)(null),[g,i]=(0,T.useState)(!0),[j,k]=(0,T.useState)(null),[l,m]=(0,T.useState)(""),[n,q]=(0,T.useState)(!1),[t,u]=(0,T.useState)([]),[v,w]=(0,T.useState)(!1),x=(0,T.useRef)(null),y=(0,T.useRef)(null),[A,B]=(0,T.useState)(""),[C,D]=(0,T.useState)(""),[E,F]=(0,T.useState)(""),[G,H]=(0,T.useState)(""),[J,K]=(0,T.useState)(""),[L,M]=(0,T.useState)(""),[N,O]=(0,T.useState)(!1),[P,Q]=(0,T.useState)(null),[R,V]=(0,T.useState)(""),[W,X]=(0,T.useState)(""),[Y,$]=(0,T.useState)("agent"),[_,aa]=(0,T.useState)(""),[ab,ac]=(0,T.useState)(""),[ad,ae]=(0,T.useState)(!1),[af,ag]=(0,T.useState)(""),[ah,ai]=(0,T.useState)(!1),[aj,ak]=(0,T.useState)(null),al=async()=>{let b=R.trim();if(!b)return void ak("SSH target is required (user@host:/path).");if("keyfile"===Y&&!_.trim())return void ak("Private key path is required for key-file auth.");if("password"===Y&&!ab)return void ak("Password is required for password auth.");ai(!0),ak(null);try{let c={sshTarget:b,sshAuthMethod:Y};W.trim()&&(c.sshPort=Number(W.trim())),"keyfile"===Y&&_.trim()&&(c.sshKeyPath=_.trim()),"password"===Y&&ab&&(c.sshPassword=ab),ad&&(c.sshReadOnly=!0),af.trim()&&(c.name=af.trim());let d=await fetch("/api/system/workspaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)});if(!d.ok){let a=await d.json();ak(a.error??a.message??"Mount failed.");return}let{workspace:e}=await d.json();ac(""),a(e.id)}catch{ak("Network error.")}finally{ai(!1)}},am=async()=>{let b=A.trim();if(!b)return void Q("Repository URL is required.");O(!0),Q(null);try{let c={remoteUrl:b};C.trim()&&(c.branch=C.trim()),E.trim()&&(c.subpath=E.trim()),G.trim()&&(c.username=G.trim()),J.trim()&&(c.token=J.trim()),L.trim()&&(c.name=L.trim());let d=await fetch("/api/system/workspaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)});if(!d.ok){let a=await d.json();Q(a.error??a.message??"Clone failed.");return}let{workspace:e}=await d.json();K(""),a(e.id)}catch{Q("Network error.")}finally{O(!1)}},an=(0,T.useCallback)(async(a,b=!0)=>{y.current&&(clearTimeout(y.current),y.current=null),i(!0),k(null);try{let c=await fetch(`/api/system/browse?path=${encodeURIComponent(a)}`);if(!c.ok){let a=await c.json();k(a.error??"Cannot open directory");return}let d=await c.json();f(d),b&&m(d.path)}catch{k("Network error")}finally{i(!1)}},[]);(0,T.useEffect)(()=>{let a=!1;return(async()=>{try{let b=await fetch("/api/system/config");if(b.ok&&!a){let a=await b.json();u(a.pinnedPaths??[]),await an(a.lastOpenedPath??"");return}}catch{}a||await an("")})(),()=>{a=!0}},[]);let ao=async b=>{let c=b??e?.path;if(c){q(!0);try{let b=await fetch("/api/system/workspaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({rootDir:c})});if(!b.ok){let a=await b.json();k(a.message??a.error??"Cannot use that directory");return}let{workspace:d}=await b.json();a(d.id)}catch{k("Network error")}finally{q(!1)}}},ap=!!e&&t.includes(e.path),aq=async()=>{if(e){w(!0);try{let a=ap?"unpin":"pin";(await fetch("/api/system/pins",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e.path,action:a})})).ok&&u(b=>"pin"===a?[...b,e.path]:b.filter(a=>a!==e.path))}catch{}finally{w(!1)}}},ar=async a=>{try{(await fetch("/api/system/pins",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a,action:"unpin"})})).ok&&u(b=>b.filter(b=>b!==a))}catch{}},as=(e?.path??"").split(/[/\\]/).filter(Boolean).reduce((a,b)=>{let c=a[a.length-1]?.path??"/";return a.push({label:b,path:`${"/"===c?"":c}/${b}`}),a},[{label:"/",path:"/"}]);return(0,b.jsx)("div",{className:"flex flex-1 items-center justify-center bg-background p-4",children:(0,b.jsxs)("div",{className:"flex w-full max-w-xl flex-col gap-4",children:[(0,b.jsxs)("div",{className:"text-center space-y-1",children:[(0,b.jsxs)("div",{className:"flex items-center justify-center gap-2 mb-1",children:[(0,b.jsx)("img",{src:"/logo.svg",alt:"Wiki Viewer",className:"h-8 w-8"}),(0,b.jsx)("span",{className:"text-xl font-semibold tracking-tight",children:"Wiki Viewer"})]}),(0,b.jsx)("h1",{className:"text-xl font-medium",children:"git"===c?"Add a Git repository":"ssh"===c?"Add a remote directory over SSH":"Choose a directory"}),(0,b.jsx)("p",{className:"text-sm text-muted-foreground",children:"git"===c?(0,b.jsxs)(b.Fragment,{children:["Clone a remote repo and serve it as a read-only workspace.",(0,b.jsx)("br",{}),"The server clones it, so the URL must be reachable from the server."]}):"ssh"===c?(0,b.jsxs)(b.Fragment,{children:["Mount a remote directory over SSH (sshfs) — no local clone.",(0,b.jsx)("br",{}),"Requires sshfs + FUSE installed on the server."]}):(0,b.jsxs)(b.Fragment,{children:["Select the folder wiki-viewer should serve.",(0,b.jsx)("br",{}),"This directory lives on the server, so use the browser below."]})})]}),(0,b.jsxs)("div",{className:"flex items-center self-center rounded-lg border bg-muted p-0.5 gap-0.5",children:[(0,b.jsxs)(U.Button,{variant:"local"===c?"default":"ghost",size:"sm",className:"h-7 px-3 text-xs gap-1.5",onClick:()=>{d("local"),K(""),Q(null)},children:[(0,b.jsx)(o.Folder,{className:"h-3.5 w-3.5"}),"Local folder"]}),(0,b.jsxs)(U.Button,{variant:"git"===c?"default":"ghost",size:"sm",className:"h-7 px-3 text-xs gap-1.5",onClick:()=>d("git"),children:[(0,b.jsx)(r,{className:"h-3.5 w-3.5"}),"From Git"]}),(0,b.jsxs)(U.Button,{variant:"ssh"===c?"default":"ghost",size:"sm",className:"h-7 px-3 text-xs gap-1.5",onClick:()=>{d("ssh"),ak(null)},children:[(0,b.jsx)(s,{className:"h-3.5 w-3.5"}),"Over SSH"]})]}),"git"===c&&(0,b.jsxs)("div",{className:"rounded-lg border bg-card shadow-sm overflow-hidden",children:[(0,b.jsxs)("div",{className:"px-4 pt-4 pb-3 flex flex-col gap-3",children:[(0,b.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,b.jsx)("label",{className:"text-xs font-medium",children:"Repository URL"}),(0,b.jsx)("div",{className:"flex items-center gap-2 rounded-md border bg-muted px-3 py-2",children:(0,b.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none font-mono min-w-0",placeholder:"https://github.com/org/repo.git",value:A,onChange:a=>{B(a.target.value),Q(null)},disabled:N,autoComplete:"off",spellCheck:!1})}),(0,b.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"Only https:// URLs are supported."})]}),(0,b.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,b.jsxs)("label",{className:"text-xs font-medium",children:["Branch ",(0,b.jsx)("span",{className:"font-normal text-muted-foreground",children:"(optional)"})]}),(0,b.jsx)("div",{className:"flex items-center gap-2 rounded-md border bg-muted px-3 py-2",children:(0,b.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none min-w-0",placeholder:"main (default branch if empty)",value:C,onChange:a=>{D(a.target.value),Q(null)},disabled:N})})]}),(0,b.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,b.jsxs)("label",{className:"text-xs font-medium",children:["Subdirectory ",(0,b.jsx)("span",{className:"font-normal text-muted-foreground",children:"(optional)"})]}),(0,b.jsx)("div",{className:"flex items-center gap-2 rounded-md border bg-muted px-3 py-2",children:(0,b.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none font-mono min-w-0",placeholder:"docs (whole repo if empty)",value:E,onChange:a=>{F(a.target.value),Q(null)},disabled:N,spellCheck:!1})}),(0,b.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"Serve only this folder from the repo. Faster to clone for large repos with docs in a subfolder."})]}),(0,b.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,b.jsxs)("label",{className:"text-xs font-medium",children:["Username ",(0,b.jsx)("span",{className:"font-normal text-muted-foreground",children:"(optional)"})]}),(0,b.jsx)("div",{className:"flex items-center gap-2 rounded-md border bg-muted px-3 py-2",children:(0,b.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none min-w-0",placeholder:"x-access-token (default)",value:G,onChange:a=>{H(a.target.value),Q(null)},disabled:N,autoComplete:"off"})}),(0,b.jsxs)("p",{className:"text-[11px] text-muted-foreground",children:["GitLab uses ",(0,b.jsx)("code",{className:"font-mono",children:"oauth2"}),"; Bitbucket uses your account username."]})]}),(0,b.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,b.jsxs)("label",{className:"text-xs font-medium",children:["Access token ",(0,b.jsx)("span",{className:"font-normal text-muted-foreground",children:"(optional)"})]}),(0,b.jsxs)("div",{className:"flex items-center gap-2 rounded-md border bg-muted px-3 py-2",children:[(0,b.jsx)(bO,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,b.jsx)("input",{type:"password",className:"flex-1 bg-transparent text-sm outline-none min-w-0",placeholder:"Personal access token",value:J,onChange:a=>{K(a.target.value),Q(null)},disabled:N,autoComplete:"off"})]}),(0,b.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"Required only for private repos. Stored securely on the server and never shown again."})]}),(0,b.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,b.jsxs)("label",{className:"text-xs font-medium",children:["Display name ",(0,b.jsx)("span",{className:"font-normal text-muted-foreground",children:"(optional)"})]}),(0,b.jsx)("div",{className:"flex items-center gap-2 rounded-md border bg-muted px-3 py-2",children:(0,b.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none min-w-0",placeholder:"Defaults to the repository name",value:L,onChange:a=>{M(a.target.value),Q(null)},disabled:N})})]}),P&&(0,b.jsx)("p",{className:"text-sm text-destructive",children:P})]}),(0,b.jsxs)("div",{className:"border-t px-4 py-3 flex items-center justify-between gap-3 bg-muted",children:[(0,b.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"Git workspaces are read-only, so editing is disabled."}),(0,b.jsx)(U.Button,{size:"sm",className:"shrink-0 gap-1.5",disabled:N,onClick:am,children:N?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(z.Loader2,{className:"h-3.5 w-3.5 animate-spin"})," Cloning..."]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(r,{className:"h-3.5 w-3.5"})," Clone and add"]})})]})]}),"ssh"===c&&(0,b.jsxs)("div",{className:"rounded-lg border bg-card shadow-sm overflow-hidden",children:[(0,b.jsxs)("div",{className:"px-4 pt-4 pb-3 flex flex-col gap-3",children:[(0,b.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,b.jsx)("label",{className:"text-xs font-medium",children:"SSH target"}),(0,b.jsx)("div",{className:"flex items-center gap-2 rounded-md border bg-muted px-3 py-2",children:(0,b.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none font-mono min-w-0",placeholder:"user@host:/abs/path",value:R,onChange:a=>{V(a.target.value),ak(null)},disabled:ah,autoComplete:"off",spellCheck:!1})}),(0,b.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"The remote path must be absolute."})]}),(0,b.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,b.jsxs)("label",{className:"text-xs font-medium",children:["Port ",(0,b.jsx)("span",{className:"font-normal text-muted-foreground",children:"(optional)"})]}),(0,b.jsx)("div",{className:"flex items-center gap-2 rounded-md border bg-muted px-3 py-2",children:(0,b.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none min-w-0",placeholder:"22",inputMode:"numeric",value:W,onChange:a=>{X(a.target.value.replace(/[^0-9]/g,"")),ak(null)},disabled:ah})})]}),(0,b.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,b.jsx)("label",{className:"text-xs font-medium",children:"Authentication"}),(0,b.jsx)("div",{className:"flex items-center self-start rounded-lg border bg-muted p-0.5 gap-0.5",children:["agent","keyfile","password"].map(a=>(0,b.jsx)(U.Button,{variant:Y===a?"default":"ghost",size:"sm",className:"h-7 px-3 text-xs",onClick:()=>{$(a),ak(null)},disabled:ah,children:"agent"===a?"SSH agent":"keyfile"===a?"Key file":"Password"},a))}),(0,b.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"agent"===Y?"Uses the server's ssh-agent and default keys (~/.ssh/id_*).":"keyfile"===Y?"Uses a specific private key on the server.":"Stored securely on the server and never shown again."})]}),"keyfile"===Y&&(0,b.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,b.jsx)("label",{className:"text-xs font-medium",children:"Private key path"}),(0,b.jsxs)("div",{className:"flex items-center gap-2 rounded-md border bg-muted px-3 py-2",children:[(0,b.jsx)(bO,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,b.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none font-mono min-w-0",placeholder:"~/.ssh/id_ed25519",value:_,onChange:a=>{aa(a.target.value),ak(null)},disabled:ah,autoComplete:"off",spellCheck:!1})]})]}),"password"===Y&&(0,b.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,b.jsx)("label",{className:"text-xs font-medium",children:"Password"}),(0,b.jsxs)("div",{className:"flex items-center gap-2 rounded-md border bg-muted px-3 py-2",children:[(0,b.jsx)(bO,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,b.jsx)("input",{type:"password",className:"flex-1 bg-transparent text-sm outline-none min-w-0",placeholder:"SSH password",value:ab,onChange:a=>{ac(a.target.value),ak(null)},disabled:ah,autoComplete:"off"})]})]}),(0,b.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,b.jsxs)("label",{className:"text-xs font-medium",children:["Display name ",(0,b.jsx)("span",{className:"font-normal text-muted-foreground",children:"(optional)"})]}),(0,b.jsx)("div",{className:"flex items-center gap-2 rounded-md border bg-muted px-3 py-2",children:(0,b.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none min-w-0",placeholder:"Defaults to host:path",value:af,onChange:a=>{ag(a.target.value),ak(null)},disabled:ah})})]}),(0,b.jsxs)("label",{className:"flex items-center gap-2 text-xs font-medium cursor-pointer select-none",children:[(0,b.jsx)("input",{type:"checkbox",checked:ad,onChange:a=>ae(a.target.checked),disabled:ah}),"Mount read-only"]}),aj&&(0,b.jsx)("p",{className:"text-sm text-destructive",children:aj})]}),(0,b.jsxs)("div",{className:"border-t px-4 py-3 flex items-center justify-between gap-3 bg-muted",children:[(0,b.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"Served live over SSH — nothing is copied to disk."}),(0,b.jsx)(U.Button,{size:"sm",className:"shrink-0 gap-1.5",disabled:ah,onClick:al,children:ah?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(z.Loader2,{className:"h-3.5 w-3.5 animate-spin"})," Mounting..."]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(s,{className:"h-3.5 w-3.5"})," Mount and add"]})})]})]}),"local"===c&&(0,b.jsxs)("div",{className:"rounded-lg border bg-card shadow-sm overflow-hidden",children:[(0,b.jsx)("div",{className:"flex items-center gap-2 border-b px-3 py-2 bg-muted",children:(0,b.jsx)("input",{ref:x,className:"flex-1 bg-transparent text-sm outline-none font-mono min-w-0",value:l,onChange:a=>{let b=a.target.value;m(b),y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{y.current=null,an(b.trim(),!1)},500)},onKeyDown:a=>{"Enter"===a.key&&(a.preventDefault(),y.current&&(clearTimeout(y.current),y.current=null),an(l.trim())),"Escape"===a.key&&(y.current&&(clearTimeout(y.current),y.current=null),m(e?.path??""),x.current?.blur())},spellCheck:!1,placeholder:"Enter a path…"})}),(0,b.jsx)("div",{className:"flex items-center gap-1 border-b px-3 py-1.5 bg-muted/50 overflow-x-auto shrink-0 min-h-[32px]",children:as.map((a,c)=>(0,b.jsxs)("span",{className:"flex items-center gap-1 shrink-0",children:[c>0&&(0,b.jsx)(h.ChevronRight,{className:"h-3 w-3 text-muted-foreground/50"}),(0,b.jsx)("button",{type:"button",className:"text-xs hover:text-foreground text-muted-foreground transition-colors rounded px-0.5",onClick:()=>an(a.path),children:0===c?(0,b.jsx)(bM,{className:"h-3.5 w-3.5"}):a.label})]},a.path))}),(0,b.jsx)("div",{className:"max-h-60 overflow-y-auto",children:g?(0,b.jsx)("div",{className:"flex justify-center py-8",children:(0,b.jsx)(z.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):j?(0,b.jsx)("div",{className:"px-4 py-3 text-sm text-destructive",children:j}):(0,b.jsxs)(b.Fragment,{children:[e?.parent&&(0,b.jsxs)("button",{type:"button",className:"flex w-full items-center gap-2.5 px-3 py-2 text-sm text-muted-foreground hover:bg-accent hover:text-accent-foreground transition-colors",onClick:()=>an(e.parent),children:[(0,b.jsx)(o.Folder,{className:"h-4 w-4 shrink-0"}),(0,b.jsx)("span",{className:"font-mono text-xs",children:".."})]}),e?.entries.length===0&&(0,b.jsx)("p",{className:"px-4 py-3 text-sm text-muted-foreground/60",children:"No subdirectories"}),e?.entries.map(a=>(0,b.jsxs)("button",{type:"button",className:"flex w-full items-center gap-2.5 px-3 py-2 text-sm hover:bg-accent hover:text-accent-foreground transition-colors",onClick:()=>an(a.path),children:[(0,b.jsx)(o.Folder,{className:"h-4 w-4 shrink-0 text-warning"}),(0,b.jsx)("span",{className:"truncate",children:a.name})]},a.path))]})}),(0,b.jsxs)("div",{className:"border-t px-3 py-2 flex items-center justify-between gap-2 bg-muted",children:[(0,b.jsxs)("button",{type:"button",className:(0,Z.cn)("flex items-center gap-1.5 text-xs transition-colors rounded px-1.5 py-1",ap?"text-foreground hover:text-destructive":"text-muted-foreground hover:text-foreground"),title:ap?"Unpin this path":"Pin this path for quick access",onClick:aq,disabled:v||!e,children:[v?(0,b.jsx)(z.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):ap?(0,b.jsx)(bP,{className:"h-3.5 w-3.5"}):(0,b.jsx)(I,{className:"h-3.5 w-3.5"}),ap?"Unpin":"Pin"]}),(0,b.jsxs)(U.Button,{size:"sm",className:"shrink-0 gap-1.5",disabled:!e||n,onClick:()=>ao(),children:[n?(0,b.jsx)(z.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):(0,b.jsx)(p,{className:"h-3.5 w-3.5"}),"Select"]})]})]}),"local"===c&&t.length>0&&(0,b.jsxs)("div",{className:"rounded-lg border bg-card shadow-sm overflow-hidden",children:[(0,b.jsx)("div",{className:"px-3 py-2 border-b bg-muted",children:(0,b.jsxs)("span",{className:"text-xs font-medium text-muted-foreground flex items-center gap-1.5",children:[(0,b.jsx)(I,{className:"h-3 w-3"})," Pinned"]})}),(0,b.jsx)("div",{className:"max-h-40 overflow-y-auto",children:t.map(a=>(0,b.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 hover:bg-accent group",children:[(0,b.jsxs)("button",{type:"button",className:"flex-1 flex items-center gap-2 text-sm text-left min-w-0",onClick:()=>an(a),children:[(0,b.jsx)(o.Folder,{className:"h-4 w-4 shrink-0 text-warning"}),(0,b.jsx)("span",{className:"truncate font-mono text-xs",children:a})]}),(0,b.jsx)("button",{type:"button",className:"shrink-0 text-muted-foreground/50 hover:text-destructive opacity-0 group-hover:opacity-100 transition-all",onClick:()=>ar(a),title:"Remove pin",children:(0,b.jsx)(S.X,{className:"h-3.5 w-3.5"})})]},a))})]}),"local"===c&&e?.shortcuts&&e.shortcuts.length>0&&(0,b.jsx)("div",{className:"flex flex-wrap gap-1.5 justify-center",children:e.shortcuts.map(a=>(0,b.jsxs)(U.Button,{variant:"outline",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>an(a.path),children:["Home"===a.label?(0,b.jsx)(bN,{className:"h-3 w-3"}):(0,b.jsx)(bM,{className:"h-3 w-3"}),a.label]},a.path))})]})})}var bR=a.i(525704);function bS({pos:a,branches:c,loading:d,busyName:e,disabled:g,onPick:h,onClose:i}){let[j,k]=(0,T.useState)(""),l=(0,T.useRef)(null);if((0,T.useEffect)(()=>{let a=a=>{let b=a.target;l.current?.contains(b)||b?.closest?.("[data-branch-trigger]")||i()},b=a=>{"Escape"===a.key&&i()};return document.addEventListener("mousedown",a),document.addEventListener("keydown",b),()=>{document.removeEventListener("mousedown",a),document.removeEventListener("keydown",b)}},[i]),"u"<typeof document)return null;let m=c.length>8,n=j.trim().toLowerCase(),o=n?c.filter(a=>a.name.toLowerCase().includes(n)):c;return(0,bR.createPortal)((0,b.jsx)("div",{ref:l,"data-branch-portal":!0,style:{position:"fixed",top:a.top,left:a.left},className:"pointer-events-auto z-[9999] flex max-h-72 w-52 flex-col overflow-hidden rounded-md border bg-popover p-1 shadow-md",children:d?(0,b.jsx)("div",{className:"flex justify-center py-2",children:(0,b.jsx)(z.Loader2,{className:"h-3.5 w-3.5 animate-spin text-muted-foreground"})}):0===c.length?(0,b.jsx)("p",{className:"px-2 py-1 text-[10px] text-muted-foreground",children:"No branches"}):(0,b.jsxs)(b.Fragment,{children:[m&&(0,b.jsx)("input",{autoFocus:!0,value:j,onChange:a=>k(a.target.value),placeholder:"Filter branches…",className:"mb-1 w-full shrink-0 rounded border bg-background px-1.5 py-1 text-[11px] outline-none focus:ring-1 focus:ring-ring"}),(0,b.jsx)("div",{className:"min-h-0 flex-1 overflow-auto",children:0===o.length?(0,b.jsx)("p",{className:"px-2 py-1 text-[10px] text-muted-foreground",children:"No match"}):o.map(a=>(0,b.jsxs)("button",{type:"button",disabled:g||a.current,className:(0,Z.cn)("flex w-full items-center gap-1.5 rounded px-2 py-1 text-left text-[11px] hover:bg-muted",a.current?"font-semibold text-foreground":"text-muted-foreground"),onClick:b=>{b.stopPropagation(),a.current||h(a.name)},children:[a.current?(0,b.jsx)(f.Check,{className:"h-3 w-3 shrink-0"}):(0,b.jsx)("span",{className:"w-3 shrink-0"}),(0,b.jsx)("span",{className:"truncate",children:a.name}),e===a.name&&(0,b.jsx)(z.Loader2,{className:"ml-auto h-3 w-3 shrink-0 animate-spin"})]},a.name))})]})}),document.body)}var bT=a.i(111939),bU=a.i(188619);let bV=bU.Root;bU.Trigger;let bW=bU.Close,bX=bU.Portal,bY=T.forwardRef(({className:a,...c},d)=>(0,b.jsx)(bU.Overlay,{ref:d,className:(0,Z.cn)("fixed inset-0 z-40 bg-overlay backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",a),...c}));bY.displayName="SheetOverlay";let bZ={bottom:"inset-x-0 bottom-0 data-[state=open]:slide-in-from-bottom data-[state=closed]:slide-out-to-bottom",top:"inset-x-0 top-0 data-[state=open]:slide-in-from-top data-[state=closed]:slide-out-to-top",left:"inset-y-0 left-0 data-[state=open]:slide-in-from-left data-[state=closed]:slide-out-to-left",right:"inset-y-0 right-0 data-[state=open]:slide-in-from-right data-[state=closed]:slide-out-to-right"},b$=T.forwardRef(({side:a="bottom",showClose:c=!1,className:d,children:e,...f},g)=>(0,b.jsxs)(bX,{children:[(0,b.jsx)(bY,{}),(0,b.jsxs)(bU.Content,{ref:g,className:(0,Z.cn)("fixed z-50 bg-background shadow-golden transition-all ease-in-out","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-200 data-[state=open]:duration-300",bZ[a],d),...f,children:[e,c&&(0,b.jsxs)(bU.Close,{className:"absolute right-4 top-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring disabled:pointer-events-none",children:[(0,b.jsx)(S.X,{className:"h-4 w-4"}),(0,b.jsx)("span",{className:"sr-only",children:"Close"})]})]})]}));b$.displayName="SheetContent",T.forwardRef(({className:a,...c},d)=>(0,b.jsx)(bU.Title,{ref:d,className:(0,Z.cn)("text-sm font-medium leading-none tracking-tight",a),...c})).displayName="SheetTitle",T.forwardRef(({className:a,...c},d)=>(0,b.jsx)(bU.Description,{ref:d,className:(0,Z.cn)("text-sm text-muted-foreground",a),...c})).displayName="SheetDescription";var b_=a.i(193097),b0=a.i(92437),b1=a.i(612455);let b2={default:"Default",editorial:"Editorial"},b3=["default","editorial"],b4=(0,b1.create)(a=>({skin:"default",setSkin:b=>{a({skin:b})}}));var b5=a.i(838629);function b6(a){return a.split(/[\n,]/).map(a=>a.trim()).filter(Boolean)}function b7(){let a=(0,b5.useExperimentsStore)(a=>a.flags),c=(0,b5.useExperimentsStore)(a=>a.toggle);return(0,b.jsx)("div",{className:"space-y-1.5",children:b5.EXPERIMENTS.map(d=>{let e=a[d.id];return(0,b.jsxs)("button",{type:"button",onClick:()=>c(d.id),"aria-pressed":e,className:`flex w-full items-start justify-between gap-3 rounded-md border px-3 py-2 text-left transition-colors ${e?"border-ring bg-accent":"border-border hover:bg-accent/50"}`,children:[(0,b.jsxs)("span",{className:"min-w-0",children:[(0,b.jsx)("span",{className:"block text-sm font-medium",children:d.label}),(0,b.jsx)("span",{className:"block text-xs text-muted-foreground",children:d.description})]}),(0,b.jsx)("span",{"aria-hidden":!0,className:`mt-0.5 flex h-5 w-9 shrink-0 items-center rounded-full px-0.5 transition-colors ${e?"bg-primary":"bg-muted-foreground/30"}`,children:(0,b.jsx)("span",{className:`h-4 w-4 rounded-full bg-background transition-transform ${e?"translate-x-4":"translate-x-0"}`})})]},d.id)})})}function b8(){let a=b4(a=>a.skin),c=b4(a=>a.setSkin);return(0,b.jsx)("div",{className:"flex gap-1.5",children:b3.map(d=>(0,b.jsx)("button",{type:"button",onClick:()=>c(d),"aria-pressed":a===d,className:`flex-1 rounded-md border px-3 py-2 text-sm transition-colors ${a===d?"border-ring bg-accent font-medium text-accent-foreground":"border-border text-muted-foreground hover:bg-accent/50"}`,children:b2[d]},d))})}function b9({open:a,onOpenChange:d}){let[e,f]=(0,T.useState)(!1),[g,h]=(0,T.useState)(!1),[i,j]=(0,T.useState)(null),[k,l]=(0,T.useState)("env"),[m,n]=(0,T.useState)(""),[o,p]=(0,T.useState)(""),[q,r]=(0,T.useState)(null),{data:s}=b0.authClient.useSession(),[t,u]=(0,T.useState)(!1),[v,w]=(0,T.useState)([]),[x,y]=(0,T.useState)([]),[A,B]=(0,T.useState)(null),[C,D]=(0,T.useState)(null),[E,F]=(0,T.useState)(""),[G,H]=(0,T.useState)(""),[I,J]=(0,T.useState)(!1),[K,L]=(0,T.useState)(null),M=(0,T.useCallback)(async()=>{try{let a=await fetch("/api/system/admins");if(!a.ok)return;let b=await a.json();u(!!b.isAdmin),w(b.admins??[]),y(b.users??[])}catch{}},[]),N=(0,T.useCallback)(async()=>{f(!0),j(null);try{let a=await fetch("/api/system/auth-settings");if(!a.ok)throw Error("Failed to load settings");let b=await a.json();n(b.allowedEmails.join("\n")),p(b.allowedDomains.join("\n")),l(b.source),r("number"==typeof b.rateLimit?b.rateLimit:null)}catch(a){j(a instanceof Error?a.message:"Failed to load")}finally{f(!1)}},[]);async function O(){h(!0),j(null);try{let a=await fetch("/api/system/auth-settings",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({allowedEmails:b6(m),allowedDomains:b6(o)})}),b=await a.json();if(!a.ok){j(b.error??"Save failed"),(0,b_.showError)(b.error??"Save failed");return}b.source&&l(b.source),d(!1)}catch{j("Save failed")}finally{h(!1)}}(0,T.useEffect)(()=>{a&&(N(),M())},[a,N,M]);let P=0===b6(m).length&&0===b6(o).length;return(0,b.jsx)(bV,{open:a,onOpenChange:d,children:(0,b.jsxs)(b$,{side:"right",className:"w-[90vw] max-w-sm md:w-80 sm:max-w-md flex flex-col border-l border-border p-0",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between border-b border-border px-4 py-3 shrink-0",children:[(0,b.jsx)("span",{className:"text-sm font-semibold",children:"Settings"}),(0,b.jsxs)(bW,{className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-accent focus:outline-none focus:ring-2 focus:ring-ring",children:[(0,b.jsx)(S.X,{className:"h-3.5 w-3.5"}),(0,b.jsx)("span",{className:"sr-only",children:"Close"})]})]}),e?(0,b.jsx)("div",{className:"flex flex-1 items-center justify-center",children:(0,b.jsx)(z.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):(0,b.jsxs)("div",{className:"flex-1 space-y-5 overflow-y-auto px-4 py-4",children:[s?.user&&(0,b.jsxs)("section",{className:"space-y-2",children:[(0,b.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:"Account"}),(0,b.jsxs)("div",{className:"flex items-center justify-between rounded-md border border-border bg-muted/40 p-3",children:[(0,b.jsxs)("div",{className:"text-sm min-w-0",children:[(0,b.jsx)("div",{className:"font-medium truncate",children:s.user.name}),(0,b.jsx)("div",{className:"text-xs text-muted-foreground truncate",children:s.user.email})]}),(0,b.jsx)("button",{type:"button",onClick:async()=>{await b0.authClient.signOut(),window.location.href="/signin"},className:"ml-2 shrink-0 text-xs px-2 py-1 rounded border border-border hover:bg-accent",children:"Sign out"})]})]}),(0,b.jsxs)("section",{className:"space-y-2",children:[(0,b.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:"Appearance"}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:"Choose the visual style. Editorial uses a printed-journal aesthetic with serif type and warm paper tones."}),(0,b.jsx)(b8,{})]}),(0,b.jsxs)("section",{className:"space-y-2",children:[(0,b.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:"Lab"}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:"Experimental reading features. Toggle each on or off. Saved on this device."}),(0,b.jsx)(b7,{})]}),(0,b.jsxs)("section",{className:"space-y-2",children:[(0,b.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:"Signup allowlist"}),(0,b.jsxs)("p",{className:"text-xs leading-relaxed text-muted-foreground",children:["Control who can create an account. Leave both lists empty to allow any email. Saving here overrides the"," ",(0,b.jsx)("code",{className:"bg-muted px-0.5 rounded",children:"AUTH_ALLOWED_EMAILS"})," ","and"," ",(0,b.jsx)("code",{className:"bg-muted px-0.5 rounded",children:"AUTH_ALLOWED_DOMAIN"})," ","environment variables."]}),"env"===k&&(0,b.jsxs)("div",{className:"flex items-start gap-2 rounded-md bg-muted px-3 py-2 text-xs text-muted-foreground",children:[(0,b.jsx)(c.AlertCircle,{className:"h-3.5 w-3.5 shrink-0 mt-0.5"}),(0,b.jsx)("span",{children:"Current values come from environment variables. Saving moves the allowlist into config and takes precedence going forward."})]}),(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)("label",{htmlFor:"allowed-emails",className:"text-sm font-medium",children:"Allowed emails"}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:"One per line (or comma-separated). Exact match, case-insensitive."}),(0,b.jsx)("textarea",{id:"allowed-emails",value:m,onChange:a=>n(a.target.value),spellCheck:!1,rows:5,placeholder:"alice@example.com bob@example.com",className:"w-full resize-y rounded-md border border-border bg-background px-3 py-2 font-mono text-sm outline-none focus:ring-2 focus:ring-primary"})]}),(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)("label",{htmlFor:"allowed-domains",className:"text-sm font-medium",children:"Allowed domains"}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:"One per line (or comma-separated). Matches any email at that domain."}),(0,b.jsx)("textarea",{id:"allowed-domains",value:o,onChange:a=>p(a.target.value),spellCheck:!1,rows:4,placeholder:"example.com trusted.org",className:"w-full resize-y rounded-md border border-border bg-background px-3 py-2 font-mono text-sm outline-none focus:ring-2 focus:ring-primary"})]}),P&&(0,b.jsxs)("div",{className:"flex items-start gap-2 rounded-md bg-warning-soft px-3 py-2 text-xs text-warning-ink",children:[(0,b.jsx)(c.AlertCircle,{className:"h-3.5 w-3.5 shrink-0 mt-0.5"}),(0,b.jsx)("span",{children:"Both lists are empty. Anyone with the signup URL can create an account."})]}),i&&(0,b.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-destructive",children:[(0,b.jsx)(c.AlertCircle,{className:"h-3.5 w-3.5 shrink-0"}),i]})]}),t&&(0,b.jsxs)("section",{className:"space-y-2",children:[(0,b.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:"Admins"}),(0,b.jsx)("p",{className:"text-xs leading-relaxed text-muted-foreground",children:"Admins can create workspaces, add users, and manage access."}),A&&(0,b.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-destructive",children:[(0,b.jsx)(c.AlertCircle,{className:"h-3.5 w-3.5 shrink-0"}),A]}),(0,b.jsxs)("div",{className:"space-y-2 rounded-md border border-border p-3",children:[(0,b.jsx)("div",{className:"text-xs font-medium",children:"Add user"}),K?(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Created ",(0,b.jsx)("span",{className:"font-medium text-foreground",children:K.email}),". Share this temporary password now, it will not be shown again."]}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("code",{className:"flex-1 rounded bg-muted px-2 py-1.5 font-mono text-sm select-all",children:K.tempPassword}),(0,b.jsx)("button",{type:"button",className:"shrink-0 text-xs px-2 py-1 rounded border border-border hover:bg-accent",onClick:()=>void navigator.clipboard?.writeText(K.tempPassword),children:"Copy"})]}),(0,b.jsx)("button",{type:"button",className:"text-xs text-muted-foreground hover:text-foreground",onClick:()=>{L(null),F(""),H(""),M()},children:"Done"})]}):(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)("input",{type:"email",value:E,onChange:a=>F(a.target.value),placeholder:"email@team.com",className:"w-full rounded-md border border-border bg-background px-2 py-1.5 text-sm outline-none focus:ring-2 focus:ring-primary"}),(0,b.jsx)("input",{type:"text",value:G,onChange:a=>H(a.target.value),placeholder:"Name (optional)",className:"w-full rounded-md border border-border bg-background px-2 py-1.5 text-sm outline-none focus:ring-2 focus:ring-primary"}),(0,b.jsxs)(U.Button,{size:"sm",className:"w-full gap-1.5",disabled:I||!E.trim(),onClick:async()=>{J(!0),B(null);try{let a=await fetch("/api/system/users",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:E.trim(),name:G.trim()})}),b=await a.json();a.ok&&b.tempPassword?L({email:b.email??E.trim(),tempPassword:b.tempPassword}):B(b.message??b.error??"Failed to create user")}catch{B("Network error")}finally{J(!1)}},children:[I&&(0,b.jsx)(z.Loader2,{className:"h-3.5 w-3.5 animate-spin"}),"Create user"]})]})]}),(0,b.jsxs)("div",{className:"space-y-1 rounded-md border border-border overflow-hidden",children:[x.map(a=>{let c=v.includes(a.id);return(0,b.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 bg-muted/40 hover:bg-muted/60 transition-colors",children:[(0,b.jsxs)("div",{className:"text-sm min-w-0",children:[(0,b.jsx)("div",{className:"font-medium truncate",children:a.name}),(0,b.jsx)("div",{className:"text-xs text-muted-foreground truncate",children:a.email})]}),(0,b.jsx)("button",{type:"button",disabled:C===a.id,className:"ml-2 shrink-0 text-xs px-2 py-1 rounded border border-border hover:bg-accent disabled:opacity-50",onClick:async()=>{D(a.id),B(null);try{let b=await fetch("/api/system/admins",{method:c?"DELETE":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:a.id})}),d=await b.json();b.ok?d.admins&&w(d.admins):B(d.message??d.error??"Failed")}catch{B("Network error")}finally{D(null)}},children:C===a.id?(0,b.jsx)(z.Loader2,{className:"h-3 w-3 animate-spin"}):c?"Demote":"Promote"})]},a.id)}),0===x.length&&(0,b.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No users yet."})]})]}),(0,b.jsxs)("section",{className:"space-y-2",children:[(0,b.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:"Agent rate limit"}),(0,b.jsxs)("div",{className:"rounded-md border border-border bg-muted/40 p-3 space-y-1.5",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between text-xs",children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:"Per agent"}),(0,b.jsx)("span",{className:"font-mono",children:null!==q?`${q} ops/min`:"--"})]}),(0,b.jsxs)("p",{className:"text-[10px] text-muted-foreground/60",children:["Override with ",(0,b.jsx)("code",{className:"bg-muted px-0.5 rounded",children:"AGENT_RATE_LIMIT"})," env var."]})]})]})]}),(0,b.jsxs)("div",{className:"flex items-center justify-end gap-2 border-t border-border px-4 py-3 shrink-0",children:[(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",onClick:()=>d(!1),disabled:g,children:"Cancel"}),(0,b.jsxs)(U.Button,{size:"sm",onClick:O,disabled:g||e,className:"gap-1.5",children:[g&&(0,b.jsx)(z.Loader2,{className:"h-3.5 w-3.5 animate-spin"}),"Save"]})]})]})})}var ca=a.i(237407);let cb=(0,d.default)("clock",[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);var cc=a.i(866718),cd=a.i(559653),ce=a.i(268189),cf=a.i(484694),cg=a.i(483370),ch=a.i(866394),ci=a.i(558036),cj="Switch",[ck,cl]=(0,cf.createContextScope)(cj),[cm,cn]=ck(cj),co=T.forwardRef((a,c)=>{let{__scopeSwitch:d,name:e,checked:f,defaultChecked:g,required:h,disabled:i,value:j="on",onCheckedChange:k,form:l,...m}=a,[n,o]=T.useState(null),p=(0,ce.useComposedRefs)(c,a=>o(a)),q=T.useRef(!1),r=!n||l||!!n.closest("form"),[s,t]=(0,cg.useControllableState)({prop:f,defaultProp:g??!1,onChange:k,caller:cj});return(0,b.jsxs)(cm,{scope:d,checked:s,disabled:i,children:[(0,b.jsx)(ci.Primitive.button,{type:"button",role:"switch","aria-checked":s,"aria-required":h,"data-state":cs(s),"data-disabled":i?"":void 0,disabled:i,value:j,...m,ref:p,onClick:(0,cd.composeEventHandlers)(a.onClick,a=>{t(a=>!a),r&&(q.current=a.isPropagationStopped(),q.current||a.stopPropagation())})}),r&&(0,b.jsx)(cr,{control:n,bubbles:!q.current,name:e,value:j,checked:s,required:h,disabled:i,form:l,style:{transform:"translateX(-100%)"}})]})});co.displayName=cj;var cp="SwitchThumb",cq=T.forwardRef((a,c)=>{let{__scopeSwitch:d,...e}=a,f=cn(cp,d);return(0,b.jsx)(ci.Primitive.span,{"data-state":cs(f.checked),"data-disabled":f.disabled?"":void 0,...e,ref:c})});cq.displayName=cp;var cr=T.forwardRef(({__scopeSwitch:a,control:c,checked:d,bubbles:e=!0,...f},g)=>{let h,i=T.useRef(null),j=(0,ce.useComposedRefs)(i,g),k=(h=T.useRef({value:d,previous:d}),T.useMemo(()=>(h.current.value!==d&&(h.current.previous=h.current.value,h.current.value=d),h.current.previous),[d])),l=(0,ch.useSize)(c);return T.useEffect(()=>{let a=i.current;if(!a)return;let b=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"checked").set;if(k!==d&&b){let c=new Event("click",{bubbles:e});b.call(a,d),a.dispatchEvent(c)}},[k,d,e]),(0,b.jsx)("input",{type:"checkbox","aria-hidden":!0,defaultChecked:d,...f,tabIndex:-1,ref:j,style:{...f.style,...l,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});function cs(a){return a?"checked":"unchecked"}function ct({className:a,...c}){return(0,b.jsx)(co,{"data-slot":"switch",className:(0,Z.cn)("peer data-[state=checked]:bg-[var(--switch-checked)] data-[state=unchecked]:bg-input inline-flex h-5 w-9 shrink-0 items-center rounded-sm border-2 border-transparent shadow-e-1 transition-all outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 cursor-pointer",a),...c,children:(0,b.jsx)(cq,{"data-slot":"switch-thumb",className:"bg-background pointer-events-none block size-4 rounded-sm shadow-e-1 ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0"})})}cr.displayName="SwitchBubbleInput";var cu=a.i(870430);function cv({open:a,onOpenChange:c,filePath:d}){let[e,g]=(0,T.useState)([]),[h,j]=(0,T.useState)(!0),[k,l]=(0,T.useState)(!1),[m,n]=(0,T.useState)(""),[o,p]=(0,T.useState)(!1),[q,r]=(0,T.useState)(!1),[s,t]=(0,T.useState)("7"),[v,w]=(0,T.useState)(null),x=(0,T.useCallback)(async()=>{j(!0);try{let a=await (0,Y.wsFetch)(`/api/share?path=${encodeURIComponent(d)}`);if(a.ok){let b=await a.json();g(b.shares??[])}}catch{}j(!1)},[d]);(0,T.useEffect)(()=>{a&&x()},[a,x]);let y=async()=>{l(!0);try{let a={path:d};if(o&&m.trim()&&(a.password=m.trim()),q&&s){let b=new Date;b.setDate(b.getDate()+Number(s)),a.expiresAt=b.toISOString()}let b=await (0,Y.wsFetch)("/api/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!b.ok){let a=await b.json();(0,b_.showError)(a.error??"Failed to create share link");return}(0,b_.showSuccess)("Share link created"),n(""),p(!1),r(!1),t("7"),await x()}catch{(0,b_.showError)("Failed to create share link")}finally{l(!1)}},A=async a=>{try{if(!(await fetch(`/api/share/${a}`,{method:"DELETE"})).ok)return void(0,b_.showError)("Failed to revoke share link");(0,b_.showSuccess)("Share link revoked"),await x()}catch{(0,b_.showError)("Failed to revoke share link")}};return(0,b.jsx)(V.Dialog,{open:a,onOpenChange:c,children:(0,b.jsxs)(V.DialogContent,{className:"sm:max-w-md",children:[(0,b.jsxs)(V.DialogHeader,{children:[(0,b.jsx)(V.DialogTitle,{children:"Share document"}),(0,b.jsx)(V.DialogDescription,{children:"Create a public link to share this document as read-only."})]}),(0,b.jsxs)("div",{className:"space-y-4",children:[(0,b.jsxs)("div",{className:"rounded-sm border border-border p-3 space-y-3",children:[(0,b.jsx)("h3",{className:"text-sm font-medium",children:"New share link"}),(0,b.jsxs)("div",{className:"flex items-center justify-between",children:[(0,b.jsxs)(cu.Label,{htmlFor:"share-pwd",className:"text-xs gap-1.5 flex items-center",children:[(0,b.jsx)(ca.Lock,{className:"h-3 w-3 text-muted-foreground"}),"Password protect"]}),(0,b.jsx)(ct,{id:"share-pwd",checked:o,onCheckedChange:p})]}),o&&(0,b.jsx)(cc.Input,{type:"password",placeholder:"Set a password",value:m,onChange:a=>n(a.target.value)}),(0,b.jsxs)("div",{className:"flex items-center justify-between",children:[(0,b.jsxs)(cu.Label,{htmlFor:"share-expiry",className:"text-xs gap-1.5 flex items-center",children:[(0,b.jsx)(cb,{className:"h-3 w-3 text-muted-foreground"}),"Set expiration"]}),(0,b.jsx)(ct,{id:"share-expiry",checked:q,onCheckedChange:r})]}),q&&(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)(cc.Input,{type:"number",min:1,max:365,value:s,onChange:a=>t(a.target.value),className:"w-20"}),(0,b.jsx)("span",{className:"text-xs text-muted-foreground",children:"days"})]}),(0,b.jsxs)(U.Button,{size:"sm",className:"w-full gap-1.5",onClick:y,disabled:k,children:[k?(0,b.jsx)(z.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):(0,b.jsx)(u.Globe,{className:"h-3.5 w-3.5"}),"Create link"]})]}),(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)("h3",{className:"text-xs font-medium text-muted-foreground",children:e.length>0?`Active links (${e.length})`:h?"Loading...":"No active links"}),h&&(0,b.jsx)("div",{className:"flex justify-center py-2",children:(0,b.jsx)(z.Loader2,{className:"h-4 w-4 animate-spin text-muted-foreground"})}),e.map(a=>(0,b.jsxs)("div",{className:"flex items-center gap-2 rounded-sm border border-border p-2",children:[(0,b.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,b.jsx)("div",{className:"flex items-center gap-1.5",children:(0,b.jsxs)("span",{className:"text-xs font-mono truncate",children:[window.location.origin,"/s/",a.token]})}),(0,b.jsxs)("div",{className:"flex items-center gap-2 mt-0.5",children:[a.hasPassword&&(0,b.jsxs)("span",{className:"flex items-center gap-0.5 text-[10px] text-muted-foreground",children:[(0,b.jsx)(ca.Lock,{className:"h-2.5 w-2.5"}),"pwd"]}),a.expiresAt&&(0,b.jsxs)("span",{className:"flex items-center gap-0.5 text-[10px] text-muted-foreground",children:[(0,b.jsx)(cb,{className:"h-2.5 w-2.5"}),function(a){let b=new Date(a),c=new Date,d=b.getTime()-c.getTime();if(d<=0)return"expired";let e=Math.floor(d/864e5),f=Math.floor(d%864e5/36e5);return e>0?`${e}d`:f>0?`${f}h`:"<1h"}(a.expiresAt)]}),(0,b.jsxs)("span",{className:"text-[10px] text-muted-foreground",children:[a.viewCount," view",1!==a.viewCount?"s":""]}),a.isExpired&&(0,b.jsx)("span",{className:"text-[10px] text-destructive",children:"expired"})]})]}),(0,b.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Copy link",onClick:()=>{var b,c;let d;return b=a.url,c=a.token,d=`${window.location.origin}${b}`,void(navigator.clipboard.writeText(d),w(c),setTimeout(()=>w(null),2e3))},children:v===a.token?(0,b.jsx)(f.Check,{className:"h-3.5 w-3.5 text-success"}):(0,b.jsx)(i.Copy,{className:"h-3.5 w-3.5"})}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0 text-destructive hover:text-destructive",title:"Revoke link",onClick:()=>A(a.token),children:(0,b.jsx)(Q.Trash2,{className:"h-3.5 w-3.5"})})]})]},a.id))]})]})]})})}var cw=a.i(591119),cx=a.i(280370),cy=a.i(385909),cz="ContextMenu",[cA,cB]=(0,cf.createContextScope)(cz,[cx.createMenuScope]),cC=(0,cx.createMenuScope)(),[cD,cE]=cA(cz),cF=a=>{let{__scopeContextMenu:c,children:d,onOpenChange:e,dir:f,modal:g=!0}=a,[h,i]=T.useState(!1),j=cC(c),k=(0,cy.useCallbackRef)(e),l=T.useCallback(a=>{i(a),k(a)},[k]);return(0,b.jsx)(cD,{scope:c,open:h,onOpenChange:l,modal:g,children:(0,b.jsx)(cx.Root,{...j,dir:f,open:h,onOpenChange:l,modal:g,children:d})})};cF.displayName=cz;var cG="ContextMenuTrigger",cH=T.forwardRef((a,c)=>{let{__scopeContextMenu:d,disabled:e=!1,...f}=a,g=cE(cG,d),h=cC(d),i=T.useRef({x:0,y:0}),j=T.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...i.current})}),k=T.useRef(0),l=T.useCallback(()=>window.clearTimeout(k.current),[]),m=a=>{i.current={x:a.clientX,y:a.clientY},g.onOpenChange(!0)};return T.useEffect(()=>l,[l]),T.useEffect(()=>void(e&&l()),[e,l]),(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(cx.Anchor,{...h,virtualRef:j}),(0,b.jsx)(ci.Primitive.span,{"data-state":g.open?"open":"closed","data-disabled":e?"":void 0,...f,ref:c,style:{WebkitTouchCallout:"none",...a.style},onContextMenu:e?a.onContextMenu:(0,cd.composeEventHandlers)(a.onContextMenu,a=>{l(),m(a),a.preventDefault()}),onPointerDown:e?a.onPointerDown:(0,cd.composeEventHandlers)(a.onPointerDown,cT(a=>{l(),k.current=window.setTimeout(()=>m(a),700)})),onPointerMove:e?a.onPointerMove:(0,cd.composeEventHandlers)(a.onPointerMove,cT(l)),onPointerCancel:e?a.onPointerCancel:(0,cd.composeEventHandlers)(a.onPointerCancel,cT(l)),onPointerUp:e?a.onPointerUp:(0,cd.composeEventHandlers)(a.onPointerUp,cT(l))})]})});cH.displayName=cG;var cI=a=>{let{__scopeContextMenu:c,...d}=a,e=cC(c);return(0,b.jsx)(cx.Portal,{...e,...d})};cI.displayName="ContextMenuPortal";var cJ="ContextMenuContent",cK=T.forwardRef((a,c)=>{let{__scopeContextMenu:d,...e}=a,f=cE(cJ,d),g=cC(d),h=T.useRef(!1);return(0,b.jsx)(cx.Content,{...g,...e,ref:c,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:b=>{a.onCloseAutoFocus?.(b),!b.defaultPrevented&&h.current&&b.preventDefault(),h.current=!1},onInteractOutside:b=>{a.onInteractOutside?.(b),b.defaultPrevented||f.modal||(h.current=!0)},style:{...a.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});cK.displayName=cJ,T.forwardRef((a,c)=>{let{__scopeContextMenu:d,...e}=a,f=cC(d);return(0,b.jsx)(cx.Group,{...f,...e,ref:c})}).displayName="ContextMenuGroup";var cL=T.forwardRef((a,c)=>{let{__scopeContextMenu:d,...e}=a,f=cC(d);return(0,b.jsx)(cx.Label,{...f,...e,ref:c})});cL.displayName="ContextMenuLabel";var cM=T.forwardRef((a,c)=>{let{__scopeContextMenu:d,...e}=a,f=cC(d);return(0,b.jsx)(cx.Item,{...f,...e,ref:c})});cM.displayName="ContextMenuItem";var cN=T.forwardRef((a,c)=>{let{__scopeContextMenu:d,...e}=a,f=cC(d);return(0,b.jsx)(cx.CheckboxItem,{...f,...e,ref:c})});cN.displayName="ContextMenuCheckboxItem",T.forwardRef((a,c)=>{let{__scopeContextMenu:d,...e}=a,f=cC(d);return(0,b.jsx)(cx.RadioGroup,{...f,...e,ref:c})}).displayName="ContextMenuRadioGroup";var cO=T.forwardRef((a,c)=>{let{__scopeContextMenu:d,...e}=a,f=cC(d);return(0,b.jsx)(cx.RadioItem,{...f,...e,ref:c})});cO.displayName="ContextMenuRadioItem";var cP=T.forwardRef((a,c)=>{let{__scopeContextMenu:d,...e}=a,f=cC(d);return(0,b.jsx)(cx.ItemIndicator,{...f,...e,ref:c})});cP.displayName="ContextMenuItemIndicator";var cQ=T.forwardRef((a,c)=>{let{__scopeContextMenu:d,...e}=a,f=cC(d);return(0,b.jsx)(cx.Separator,{...f,...e,ref:c})});cQ.displayName="ContextMenuSeparator",T.forwardRef((a,c)=>{let{__scopeContextMenu:d,...e}=a,f=cC(d);return(0,b.jsx)(cx.Arrow,{...f,...e,ref:c})}).displayName="ContextMenuArrow";var cR=T.forwardRef((a,c)=>{let{__scopeContextMenu:d,...e}=a,f=cC(d);return(0,b.jsx)(cx.SubTrigger,{...f,...e,ref:c})});cR.displayName="ContextMenuSubTrigger";var cS=T.forwardRef((a,c)=>{let{__scopeContextMenu:d,...e}=a,f=cC(d);return(0,b.jsx)(cx.SubContent,{...f,...e,ref:c,style:{...a.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});function cT(a){return b=>"mouse"!==b.pointerType?a(b):void 0}cS.displayName="ContextMenuSubContent";var cU=a.i(694079);T.forwardRef(({className:a,inset:c,children:d,...e},f)=>(0,b.jsxs)(cR,{ref:f,className:(0,Z.cn)("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",c&&"pl-8",a),...e,children:[d,(0,b.jsx)(h.ChevronRight,{className:"ml-auto h-4 w-4"})]})).displayName=cR.displayName,T.forwardRef(({className:a,...c},d)=>(0,b.jsx)(cS,{ref:d,className:(0,Z.cn)("z-50 min-w-[8rem] overflow-hidden rounded-sm border bg-popover p-1 text-popover-foreground shadow-golden data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a),...c})).displayName=cS.displayName;let cV=T.forwardRef(({className:a,...c},d)=>(0,b.jsx)(cI,{children:(0,b.jsx)(cK,{ref:d,className:(0,Z.cn)("z-50 min-w-[8rem] overflow-hidden rounded-sm border bg-popover p-1 text-popover-foreground shadow-golden data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a),...c})}));cV.displayName=cK.displayName;let cW=T.forwardRef(({className:a,inset:c,...d},e)=>(0,b.jsx)(cM,{ref:e,className:(0,Z.cn)("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",c&&"pl-8",a),...d}));cW.displayName=cM.displayName,T.forwardRef(({className:a,children:c,checked:d,...e},g)=>(0,b.jsxs)(cN,{ref:g,className:(0,Z.cn)("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a),checked:d,...e,children:[(0,b.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,b.jsx)(cP,{children:(0,b.jsx)(f.Check,{className:"h-4 w-4"})})}),c]})).displayName=cN.displayName,T.forwardRef(({className:a,children:c,...d},e)=>(0,b.jsxs)(cO,{ref:e,className:(0,Z.cn)("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a),...d,children:[(0,b.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,b.jsx)(cP,{children:(0,b.jsx)(cU.Circle,{className:"h-2 w-2 fill-current"})})}),c]})).displayName=cO.displayName,T.forwardRef(({className:a,inset:c,...d},e)=>(0,b.jsx)(cL,{ref:e,className:(0,Z.cn)("px-2 py-1.5 text-sm font-normal",c&&"pl-8",a),...d})).displayName=cL.displayName;let cX=T.forwardRef(({className:a,...c},d)=>(0,b.jsx)(cQ,{ref:d,className:(0,Z.cn)("-mx-1 my-1 h-px bg-muted",a),...c}));cX.displayName=cQ.displayName;let cY=(0,b1.create)(a=>({recents:[],loadForWorkspace:b=>{a({recents:[]})},push:(b,c)=>{let d=[].filter(a=>a.path!==b.path);a({recents:[b,...d].slice(0,15)})}})),cZ=(0,b1.create)((a,b)=>({pins:[],loadForWorkspace:b=>{a({pins:[]})},toggle:(b,c)=>{let d=[];a({pins:d.some(a=>a.path===b.path)?d.filter(a=>a.path!==b.path):[...d,b]})},isPinned:a=>b().pins.some(b=>b.path===a)})),c$=(0,d.default)("wifi",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]);var c_=a.i(764841);let c0=(0,d.default)("circle-check-big",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]),c1=(0,d.default)("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);var c2=a.i(263265);function c3(a){let b=Date.now()-new Date(a).getTime();return b<6e4?"just now":b<36e5?`${Math.floor(b/6e4)}m ago`:b<864e5?`${Math.floor(b/36e5)}h ago`:`${Math.floor(b/864e5)}d ago`}function c4({scope:a}){return(0,b.jsxs)("span",{className:"text-[10px] text-muted-foreground/70 font-mono",children:[a.paths.join(", ")," · ",a.ops.join(",")]})}function c5({reg:a,onApprove:c,onDeny:d}){let[e,f]=(0,T.useState)(!1);async function g(b){f(!0);try{await b(a.registrationId)}finally{f(!1)}}return(0,b.jsxs)("li",{className:"py-1.5 border-b border-border/40 last:border-0",children:[(0,b.jsxs)("div",{className:"flex items-start justify-between gap-1",children:[(0,b.jsxs)("div",{className:"min-w-0",children:[(0,b.jsx)("p",{className:"text-xs font-mono truncate",children:a.displayName}),(0,b.jsx)("p",{className:"text-[10px] text-muted-foreground/60 truncate",children:a.agentId}),(0,b.jsx)(c4,{scope:a.requestedScope})]}),(0,b.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,b.jsxs)(U.Button,{size:"sm",variant:"default",className:"h-6 px-2 text-[10px]",disabled:e,onClick:()=>void g(c),title:"Approve",children:[(0,b.jsx)(c0,{className:"h-3 w-3 mr-0.5"}),"Approve"]}),(0,b.jsxs)(U.Button,{size:"sm",variant:"ghost",className:"h-6 px-2 text-[10px] text-destructive hover:text-destructive",disabled:e,onClick:()=>void g(d),title:"Deny",children:[(0,b.jsx)(c1,{className:"h-3 w-3 mr-0.5"}),"Deny"]})]})]}),(0,b.jsxs)("p",{className:"text-[10px] text-muted-foreground/50 mt-0.5",children:["Requested ",c3(a.requestedAt)]})]})}function c6({agent:a,onRevoke:c}){let[d,e]=(0,T.useState)(!1);return(0,b.jsxs)("li",{className:"py-1.5 border-b border-border/40 last:border-0",children:[(0,b.jsxs)("div",{className:"flex items-start justify-between gap-1",children:[(0,b.jsxs)("div",{className:"min-w-0",children:[(0,b.jsx)("p",{className:"text-xs font-mono truncate",children:a.displayName}),(0,b.jsx)("p",{className:"text-[10px] text-muted-foreground/60 truncate",children:a.id}),(0,b.jsx)(c4,{scope:a.scope})]}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 shrink-0 text-destructive hover:text-destructive",disabled:d,onClick:async()=>{e(!0);try{await c(a.id)}finally{e(!1)}},title:"Revoke agent",children:(0,b.jsx)(Q.Trash2,{className:"h-3 w-3"})})]}),(0,b.jsxs)("p",{className:"text-[10px] text-muted-foreground/50 mt-0.5",children:["Last seen ",c3(a.lastSeen)]})]})}function c7(){let[a,c]=(0,T.useState)([]),[d,e]=(0,T.useState)([]),[f,g]=(0,T.useState)(!1);(0,T.useEffect)(()=>{fetch("/api/owner/init",{credentials:"same-origin"}).then(a=>{(a.ok||204===a.status)&&g(!0)}).catch(()=>{g(!0)})},[]);let h=(0,T.useCallback)(async()=>{try{let a=await fetch("/api/agent/admin/registrations",{credentials:"same-origin"});if(!a.ok)return;let b=await a.json();c(b.pending)}catch{}},[]),i=(0,T.useCallback)(async()=>{try{let a=await fetch("/api/agent/admin/agents",{credentials:"same-origin"});if(!a.ok)return;let b=await a.json();e(b.agents)}catch{}},[]);(0,T.useEffect)(()=>{if(!f)return;h(),i();let a=setInterval(()=>void h(),5e3),b=setInterval(()=>void i(),3e4);return()=>{clearInterval(a),clearInterval(b)}},[f,h,i]);let j=(0,T.useCallback)(async a=>{(await fetch(`/api/agent/admin/registrations/${a}/approve`,{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json"},body:"{}"})).ok?(c2.toast.success("Agent approved"),await Promise.all([h(),i()])):c2.toast.error("Failed to approve agent")},[h,i]),k=(0,T.useCallback)(async a=>{(await fetch(`/api/agent/admin/registrations/${a}/deny`,{method:"POST",credentials:"same-origin"})).ok?(c2.toast.success("Registration denied"),await h()):c2.toast.error("Failed to deny registration")},[h]),l=(0,T.useCallback)(async a=>{(await fetch(`/api/agent/admin/agents/${encodeURIComponent(a)}/revoke`,{method:"POST",credentials:"same-origin"})).ok?(c2.toast.success("Agent revoked"),await i()):c2.toast.error("Failed to revoke agent")},[i]);return(0,b.jsxs)("section",{className:"space-y-2",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between",children:[(0,b.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:"Agents · approve & manage access"}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-5 w-5 p-0",title:"Refresh",onClick:()=>void Promise.all([h(),i()]),children:(0,b.jsx)(K,{className:"h-3 w-3"})})]}),a.length>0&&(0,b.jsxs)("div",{className:"rounded-md border border-amber-500/40 bg-amber-50/10 p-2",children:[(0,b.jsxs)("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-amber-600/80 mb-1 flex items-center gap-1",children:[(0,b.jsx)(cb,{className:"h-3 w-3"}),"Waiting for your approval (",a.length,")"]}),(0,b.jsx)("ul",{children:a.map(a=>(0,b.jsx)(c5,{reg:a,onApprove:j,onDeny:k},a.registrationId))})]}),(0,b.jsx)("div",{className:"rounded-md border border-border bg-muted/40 p-2",children:0===d.length?(0,b.jsxs)("p",{className:"text-xs text-muted-foreground/60 py-1",children:["No assistants connected yet."," ",(0,b.jsx)("span",{className:"text-muted-foreground/40",children:"Connect one above; once it requests access it’ll appear here for you to approve."})]}):(0,b.jsx)("ul",{children:d.map(a=>(0,b.jsx)(c6,{agent:a,onRevoke:l},a.id))})}),(0,b.jsx)("p",{className:"text-[10px] text-muted-foreground/60 leading-relaxed",children:"Each assistant gets its own access that you can revoke anytime. New requests appear above for your approval before they can read or edit anything."})]})}var c8=a.i(569707);function c9(a){let b=Math.max(0,Math.round((Date.now()-new Date(a).getTime())/1e3));if(b<45)return"just now";let c=b,d="second";for(let[a,b]of[[60,"second"],[60,"minute"],[24,"hour"],[7,"day"]]){if(c<a)break;c=Math.floor(c/a),d=b}return new Intl.RelativeTimeFormat("en",{numeric:"always",style:"short"}).format(-c,d).replace(/\s+/g," ").replace(/\./g,"")}async function da(a){if(!/\.(md|markdown)$/i.test(a))return 0;for(let b of[`/api/agent/sidecar/${a}`,`/api/agent/files/${a}/pending`,`/api/agent/files/${a}`])try{let a=await (0,Y.wsFetch)(b);if(!a.ok)continue;let c=await a.json();if(Array.isArray(c.pending))return c.pending.length;if(Array.isArray(c.events)&&b.includes("/pending"))return c.events.length;if("number"==typeof c.pendingCount)return c.pendingCount;if("number"==typeof c.count)return c.count;if("number"==typeof c.total)return c.total;if(Array.isArray(c.suggestions)||Array.isArray(c.comments)||c.blockProvenance){let a=Array.isArray(c.suggestions)?c.suggestions.filter(a=>a&&"object"==typeof a&&"pending"===a.status).length:0,b=Array.isArray(c.comments)?c.comments.filter(a=>a&&"object"==typeof a&&!a.resolved).length:0,d=c.blockProvenance&&"object"==typeof c.blockProvenance?Object.keys(c.blockProvenance).length:0;return a+b+d}}catch{}return 0}let db=(0,T.memo)(function({event:a}){var c,d;let e,f,g,h,i;return(0,b.jsxs)("div",{className:"flex items-start gap-2.5 rounded-md px-2 py-2 hover:bg-background/50",children:[(0,b.jsx)("div",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-[10px] font-semibold shadow-sm ring-1 ring-black/5",style:(e=function(a){let b=0;for(let c=0;c<a.length;c+=1)b=31*b+a.charCodeAt(c)|0;return Math.abs(b)}(a.by)%360,{backgroundColor:`hsl(${e} 72% 42%)`,color:"white"}),title:a.by,"aria-hidden":!0,children:((f=(c=a.by).split(/[:/]/).pop()??c).replace(/[^a-z0-9]/gi,"").slice(0,2)||f.slice(0,2)||"??").toUpperCase()}),(0,b.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,b.jsx)("p",{className:"truncate text-xs text-foreground/85",children:(g=((d=a.by).split(/[:/]/).pop()??d).replace(/[-_]+/g," ").replace(/^./,a=>a.toUpperCase()),h=a.type,i=Array.isArray(a.refs)?(a.refs??[]).length:+("string"==typeof a.ref),"block.append"===h||"block.inserted"===h&&"end"===a.position?`${g} appended ${i||1} block${1===(i||1)?"":"s"}`:"block.prepend"===h||"block.inserted"===h&&"start"===a.position?`${g} prepended ${i||1} block${1===(i||1)?"":"s"}`:"block.inserted"===h?`${g} inserted ${i||1} block${1===(i||1)?"":"s"}`:"block.replaced"===h||"file.rawWritten"===h?`${g} edited`:"block.deleted"===h?`${g} deleted ${i||1} block${1===(i||1)?"":"s"}`:"suggestion.added"===h?`${g} suggested a change`:"suggestion.accepted"===h?`${g} accepted a suggestion`:"suggestion.rejected"===h?`${g} rejected a suggestion`:"comment.added"===h?`${g} commented`:"comment.replied"===h?`${g} replied`:"comment.resolved"===h?`${g} resolved a comment`:"comment.reopened"===h?`${g} reopened a comment`:"file.externallyEdited"===h?`${g} changed file externally`:`${g} ${h.replace(/^\w+\./,"").replace(/([a-z])([A-Z])/g,"$1 $2")}`)}),(0,b.jsx)("p",{className:"truncate text-[10px] text-muted-foreground",children:c9(a.at)})]})]})});function dc({group:a,reviewCount:c}){let d=(0,c8.useEditorStore)(a=>a.loadPage),e=a.events[0];return(0,b.jsxs)("section",{className:"space-y-1.5 rounded-md border border-border/70 bg-background/50 p-2",children:[(0,b.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,b.jsxs)("button",{type:"button",onClick:()=>void d(a.path),className:"min-w-0 text-left",title:a.path,children:[(0,b.jsx)("p",{className:"truncate text-xs font-medium text-foreground/90",children:a.filename}),(0,b.jsx)("p",{className:"truncate text-[10px] text-muted-foreground",children:a.path})]}),(0,b.jsxs)("div",{className:"flex shrink-0 items-center gap-1.5",children:[c>0&&(0,b.jsxs)("button",{type:"button",onClick:()=>void d(a.path),className:"inline-flex items-center rounded-full border border-amber-500/40 bg-amber-500/10 px-2 py-0.5 text-[10px] font-medium text-amber-700 hover:bg-amber-500/15",title:"Open file for review",children:["review ",c]}),(0,b.jsx)("span",{className:"text-[10px] text-muted-foreground",children:c9(e.at)})]})]}),(0,b.jsx)("div",{className:"space-y-0.5",children:a.events.map(a=>(0,b.jsx)(db,{event:a},`${a.path}-${a.id}`))})]})}function dd({activity:a}){let c=(0,T.useMemo)(()=>(function(a){let b=new Map;for(let c of a){let a=b.get(c.path)??[];a.push(c),b.set(c.path,a)}return Array.from(b.entries()).map(([a,b])=>({path:a,filename:a.split("/").pop()??a,latestAt:b[0]?.at??"",events:b})).sort((a,b)=>a.latestAt<b.latestAt?1:-1)})(a),[a]),[d,e]=(0,T.useState)({});return((0,T.useEffect)(()=>{let a=!1,b=Array.from(new Set(c.map(a=>a.path)));return 0===b.length?(e({}),()=>{a=!0}):((async()=>{let c=await Promise.all(b.map(async a=>[a,await da(a)]));a||e(Object.fromEntries(c.filter(([,a])=>a>0)))})(),()=>{a=!0})},[c]),0===c.length)?(0,b.jsx)("p",{className:"py-2 text-xs text-muted-foreground/60",children:"No events recorded"}):(0,b.jsx)("div",{className:"space-y-2",children:c.map(a=>(0,b.jsx)(dc,{group:a,reviewCount:d[a.path]??0},a.path))})}let de="npx skills add anh-chu/wiki-viewer/agents/wiki-viewer-skill";function df(a){let[b,c]=(0,T.useState)(!1);return{copied:b,copy:(0,T.useCallback)(async()=>{await navigator.clipboard.writeText(a()),c(!0),setTimeout(()=>c(!1),1500)},[a])}}function dg({currentPath:a}){let c=(0,c_.useAIPanelStore)(a=>a.isOpen),d=(0,c_.useAIPanelStore)(a=>a.close),g=(0,c_.useAIPanelStore)(a=>a.activity),h=(0,c_.useAIPanelStore)(a=>a.connections),j=(0,c_.useAIPanelStore)(a=>a.loadActivity),{copied:k,copy:l}=function(a){let[b,c]=(0,T.useState)(!1);return{copied:b,copy:(0,T.useCallback)(async()=>{let b="http://localhost:3000",d=`# 1. Register
3
+ ${c}`:""]})}let c=a.data||{};if(c["image/png"]){let a=`data:image/png;base64,${bg(c["image/png"]).replace(/\s/g,"")}`;return(0,b.jsx)("img",{src:a,alt:"output",className:"max-w-full rounded-md bg-card p-2"})}if(c["image/jpeg"]){let a=`data:image/jpeg;base64,${bg(c["image/jpeg"]).replace(/\s/g,"")}`;return(0,b.jsx)("img",{src:a,alt:"output",className:"max-w-full rounded-md bg-card p-2"})}if(c["image/svg+xml"]){let a=bg(c["image/svg+xml"]);return(0,b.jsx)("div",{className:"max-w-full rounded-md bg-card p-2 overflow-auto",dangerouslySetInnerHTML:{__html:a}})}if(c["text/html"]){let a=bg(c["text/html"]);return(0,b.jsx)("iframe",{srcDoc:`<!doctype html><html><head><base target="_blank"><style>body{margin:0;padding:8px;font-family:-apple-system,BlinkMacSystemFont,Inter,system-ui,sans-serif;background:#FFF9E9;color:#2A221B;font-size:13px}table{border-collapse:collapse}th,td{border:1px solid #D4C4B0;padding:4px 8px;text-align:left}thead{background:#EFE5CC}</style></head><body>${a}</body></html>`,sandbox:"allow-scripts",className:"w-full bg-[#FFF9E9] rounded-md border border-[#E8DDC5]",style:{height:360}})}return c["text/plain"]?(0,b.jsx)("pre",{className:"whitespace-pre-wrap font-mono text-[12.5px] leading-relaxed px-4 py-3 rounded-md bg-[#F5EEDC] text-[#2A221B]",children:bi(bg(c["text/plain"]))}):null}function bk({cell:a,language:c}){let d=bg(a.source),e=(0,T.useMemo)(()=>(function(a,b){try{let c=b?bf.highlight(b,a):bf.highlightAuto(a);return(0,al.toHtml)(c)}catch{return a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}})(d,c),[d,c]),f=a.execution_count??" ",g=(a.outputs?.length??0)>0;return(0,b.jsxs)("div",{className:"grid grid-cols-[60px_1fr] gap-3 mb-5",children:[(0,b.jsxs)("div",{className:"text-right pt-3 select-none font-mono text-[11px] text-[#8B5E3C]",children:["In [",f,"]:"]}),(0,b.jsxs)("div",{children:[(0,b.jsx)("pre",{className:"whitespace-pre overflow-x-auto font-mono text-[13px] leading-relaxed px-4 py-3 rounded-md bg-[#FFF9E9] border border-[#E8DDC5] text-[#2A221B]",children:(0,b.jsx)("code",{dangerouslySetInnerHTML:{__html:e}})}),g&&(0,b.jsxs)("div",{className:"mt-2 grid grid-cols-[60px_1fr] gap-3",children:[(0,b.jsxs)("div",{className:"text-right pt-3 select-none font-mono text-[11px] text-[#8B2E3E]",children:["Out[",f,"]:"]}),(0,b.jsx)("div",{className:"space-y-2",children:a.outputs?.map((a,c)=>(0,b.jsx)(bj,{output:a},c))})]})]})]})}function bl({cell:a}){let[c,d]=(0,T.useState)("");return(0,T.useEffect)(()=>{let b=!1;return(0,be.markdownToHtml)(bg(a.source)).then(a=>{b||d(a)}),()=>{b=!0}},[a.source]),(0,b.jsx)("div",{className:"prose prose-sm max-w-none mb-5 px-1 [&_h1]:font-serif [&_h2]:font-serif [&_h3]:font-serif [&_a]:text-[#8B5E3C] [&_a:hover]:underline [&_code]:bg-[#F5EEDC] [&_code]:px-1.5 [&_code]:py-0.5 [&_code]:rounded [&_code]:text-[#8B2E3E]",dangerouslySetInnerHTML:{__html:c}})}function bm({cell:a}){return(0,b.jsx)("pre",{className:"whitespace-pre-wrap font-mono text-[12.5px] leading-relaxed px-4 py-3 rounded-md bg-[#F5EEDC] text-[#2A221B] mb-5",children:bg(a.source)})}function bn({path:a}){let[d,e]=(0,T.useState)(null),[g,h]=(0,T.useState)(!0),[k,l]=(0,T.useState)(null),[m,n]=(0,T.useState)(!1),o=(0,Y.withWs)(`/api/assets/${a}`),p=a.split("/").pop()||a,q=(0,T.useCallback)(async()=>{h(!0),l(null);try{let a=await (0,Y.wsFetch)(o);if(!a.ok)throw Error(`HTTP ${a.status}`);let b=await a.json();e(b)}catch(a){l(a instanceof Error?a.message:"Failed to load notebook")}finally{h(!1)}},[o]);(0,T.useEffect)(()=>{q()},[q]);let r=d?.metadata?.language_info?.name||d?.metadata?.kernelspec?.name||"python",s=d?.cells?.length??0,t=d?.cells?.filter(a=>"code"===a.cell_type).length??0,u=d?.cells?.some(a=>"code"===a.cell_type&&(a.outputs?.length??0)>0)??!1;return(0,b.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,b.jsxs)($,{path:a,badge:"IPYNB",sublabel:`${s} cells \xb7 ${t} code \xb7 ${r}`,children:[(0,b.jsxs)(U.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>{navigator.clipboard.writeText(`jupyter lab ${a}`),n(!0),setTimeout(()=>n(!1),2e3)},title:"Copy: jupyter lab <path>",children:[m?(0,b.jsx)(f.Check,{className:"h-3.5 w-3.5 text-green-500"}):(0,b.jsx)(i.Copy,{className:"h-3.5 w-3.5"}),m?"Copied":"Copy run cmd"]}),(0,b.jsxs)(U.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>{let a=document.createElement("a");a.href=o,a.download=p,a.click()},children:[(0,b.jsx)(j,{className:"h-3.5 w-3.5"}),"Download"]}),(0,b.jsxs)(U.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>window.open(o,"_blank"),children:[(0,b.jsx)(ae.ExternalLink,{className:"h-3.5 w-3.5"}),"Raw JSON"]})]}),(0,b.jsx)("div",{className:"flex-1 overflow-auto bg-[#F5EEDC]",children:g?(0,b.jsx)("div",{className:"flex items-center justify-center h-full text-[#7A6B5D] text-sm",children:"Loading notebook…"}):k?(0,b.jsxs)("div",{className:"flex items-center justify-center h-full text-[#8B2E3E] text-sm gap-2",children:[(0,b.jsx)(c.AlertCircle,{className:"h-4 w-4"})," ",k]}):d?(0,b.jsxs)("div",{className:"max-w-[1100px] mx-auto py-8 px-6",children:[!u&&t>0&&(0,b.jsxs)("div",{className:"mb-6 rounded-md border border-[#E8DDC5] bg-[#FFF9E9] px-4 py-3 text-[13px] text-[#7A6B5D]",children:[(0,b.jsx)("span",{className:"font-semibold text-[#0c0a09]",children:"This notebook hasn't been run yet."})," ","Code and markdown cells display below; outputs appear once the author runs the notebook in Jupyter (or you do, then re-save)."]}),d.cells?.map((a,c)=>"markdown"===a.cell_type?(0,b.jsx)(bl,{cell:a},c):"raw"===a.cell_type?(0,b.jsx)(bm,{cell:a},c):(0,b.jsx)(bk,{cell:a,language:r},c))]}):null})]})}function bo({path:a,extLabel:c,external:d,hideFinder:e}){let f=(0,Y.withWs)(`/api/assets/${a}`),g=a.split("/").pop()||a,h=async()=>{try{await (0,Y.wsFetch)("/api/system/reveal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a})})}catch{}};return(0,b.jsxs)($,{path:a,badge:c||void 0,children:[d&&(0,b.jsxs)("a",{href:d.href,target:"_blank",rel:"noreferrer noopener",className:"inline-flex items-center gap-1.5 text-[11px] h-7 px-2.5 rounded-md border border-border hover:bg-accent transition-colors",children:[(0,b.jsx)(ae.ExternalLink,{className:"h-3.5 w-3.5"}),d.label]}),!e&&(0,b.jsxs)(U.Button,{variant:"outline",size:"sm",className:"gap-1.5 text-[11px] h-7",onClick:h,title:"Open in Finder",children:[(0,b.jsx)(p,{className:"h-3.5 w-3.5"}),"Reveal"]}),!e&&(0,b.jsxs)(U.Button,{variant:"outline",size:"sm",className:"gap-1.5 text-[11px] h-7",onClick:()=>{let a=document.createElement("a");a.href=f,a.download=g,a.click()},title:"Download original",children:[(0,b.jsx)(j,{className:"h-3.5 w-3.5"}),"Download"]})]})}function bp({path:c,title:d}){let e=(0,T.useRef)(null),[f,g]=(0,T.useState)(!0),[h,i]=(0,T.useState)(null);return(0,T.useEffect)(()=>{let b=!1,d=e.current;if(d)return d.innerHTML="",(async()=>{g(!0),i(null);try{let[{renderAsync:e},f]=await Promise.all([a.A(458647),(0,Y.wsFetch)(`/api/assets/${c}`)]);if(b)return;if(!f.ok)throw Error(`Failed to load file (${f.status})`);let h=await f.blob();if(b)return;await e(h,d,void 0,{className:"docx-rendered",inWrapper:!0,ignoreWidth:!1,ignoreHeight:!1,breakPages:!0,renderHeaders:!0,renderFooters:!0,renderFootnotes:!0,experimental:!0,useBase64URL:!0}),b||g(!1)}catch(a){b||(i(a instanceof Error?a.message:"Failed to render document"),g(!1))}})(),()=>{b=!0}},[c]),(0,b.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,b.jsx)(bo,{path:c,title:d,extLabel:"DOCX"}),(0,b.jsxs)("div",{className:"flex-1 overflow-y-auto bg-muted/30",children:[f&&!h&&(0,b.jsxs)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:[(0,b.jsx)(z.Loader2,{className:"h-5 w-5 animate-spin mr-2"}),"Rendering document…"]}),h&&(0,b.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,b.jsxs)("div",{className:"text-center space-y-2",children:[(0,b.jsx)("p",{className:"text-sm text-destructive",children:h}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:"Try downloading the file and opening it externally."})]})}),(0,b.jsx)("div",{ref:e,className:"docx-viewer-body mx-auto max-w-5xl py-6 px-4"})]})]})}function bq({path:c,title:d}){let e=(0,T.useRef)(null),[f,g]=(0,T.useState)(!0),[h,i]=(0,T.useState)(null);return(0,T.useEffect)(()=>{let b=!1,d=e.current;if(!d)return;d.innerHTML="";let f=null;return(async()=>{g(!0),i(null);try{let[{init:e},h]=await Promise.all([a.A(287443),(0,Y.wsFetch)(`/api/assets/${c}`)]);if(b)return;if(!h.ok)throw Error(`Failed to load file (${h.status})`);let i=await h.arrayBuffer();if(b)return;let j=d.clientWidth||960,k=Math.round(9*j/16);f=e(d,{width:j,height:k,mode:"list"}),await f.preview(i),b||g(!1)}catch(a){b||(i(a instanceof Error?a.message:"Failed to render presentation"),g(!1))}})(),()=>{b=!0;try{f?.destroy?.()}catch{}}},[c]),(0,b.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,b.jsx)(bo,{path:c,title:d,extLabel:"PPTX"}),(0,b.jsxs)("div",{className:"flex-1 overflow-auto bg-muted/30 py-4",children:[f&&!h&&(0,b.jsxs)("div",{className:"h-[60vh] flex items-center justify-center text-muted-foreground",children:[(0,b.jsx)(z.Loader2,{className:"h-5 w-5 animate-spin mr-2"}),"Rendering slides…"]}),h&&(0,b.jsx)("div",{className:"h-[60vh] flex items-center justify-center",children:(0,b.jsxs)("div",{className:"text-center space-y-2",children:[(0,b.jsx)("p",{className:"text-sm text-destructive",children:h}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:"Try downloading the file and opening it externally."})]})}),(0,b.jsx)("div",{ref:e,className:"pptx-viewer-body mx-auto max-w-5xl px-4"})]})]})}function br({path:c,title:d}){let[e,f]=(0,T.useState)(null),[g,h]=(0,T.useState)(0),[i,j]=(0,T.useState)(!0),[k,l]=(0,T.useState)(null),m=(0,T.useRef)(null);(0,T.useEffect)(()=>{if(!e||!m.current)return;let a=e[g];if(!a||null!==a.html)return;let{wb:b,toHtml:c}=m.current,d=c(b.Sheets[a.name]);f(a=>{if(!a)return a;let b=[...a];return b[g]={...b[g],html:d.html,rows:d.rows,truncated:d.truncated},b})},[e,g]),(0,T.useEffect)(()=>{let b=!1;return j(!0),l(null),f(null),(async()=>{try{let[d,e]=await Promise.all([a.A(57386),(0,Y.wsFetch)(`/api/assets/${c}`)]);if(b)return;if(!e.ok)throw Error(`Failed to load file (${e.status})`);let g=await e.arrayBuffer();if(b)return;let i=d.read(g,{type:"array",cellDates:!0,cellStyles:!0});if(b)return;m.current={wb:i,toHtml:a=>{let b=a["!ref"],c=b?d.utils.decode_range(b):null,e=c?c.e.r-c.s.r+1:0;if(!c||e<=2e3)return{html:d.utils.sheet_to_html(a,{editable:!1}),rows:e,truncated:!1};let f={...a,"!ref":d.utils.encode_range({s:c.s,e:{r:c.s.r+2e3-1,c:c.e.c}})};return{html:d.utils.sheet_to_html(f,{editable:!1}),rows:e,truncated:!0}}},f(i.SheetNames.map(a=>({name:a,html:null,rows:0,truncated:!1}))),h(0),j(!1)}catch(a){b||(l(a instanceof Error?a.message:"Failed to parse spreadsheet"),j(!1))}})(),()=>{b=!0}},[c]);let n=(0,T.useMemo)(()=>e?.[g]??null,[e,g]);return(0,b.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,b.jsx)(bo,{path:c,title:d,extLabel:"XLSX"}),e&&e.length>1&&(0,b.jsx)("div",{className:"flex items-center gap-0.5 border-b border-border bg-muted/40 px-2 overflow-x-auto scrollbar-none",children:e.map((a,c)=>(0,b.jsx)("button",{type:"button",onClick:()=>h(c),className:(0,Z.cn)("px-3 py-1.5 text-[12px] rounded-t whitespace-nowrap transition-colors",c===g?"bg-background text-foreground font-medium border-t border-x border-border -mb-px":"text-muted-foreground hover:text-foreground"),children:a.name},a.name+c))}),(0,b.jsxs)("div",{className:"flex-1 overflow-auto",children:[i&&!k&&(0,b.jsxs)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:[(0,b.jsx)(z.Loader2,{className:"h-5 w-5 animate-spin mr-2"}),"Parsing spreadsheet…"]}),k&&(0,b.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,b.jsxs)("div",{className:"text-center space-y-2",children:[(0,b.jsx)("p",{className:"text-sm text-destructive",children:k}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:"Try downloading the file and opening it externally."})]})}),n?.truncated&&(0,b.jsxs)("div",{className:"px-3 py-2 text-[11px] text-amber-600 dark:text-amber-400 border-b border-border",children:["Large sheet (",n.rows.toLocaleString()," rows). Showing first"," ",2e3.toLocaleString()," for performance. Download the file to see everything."]}),n?.html!=null&&(0,b.jsx)("div",{className:"xlsx-sheet p-3 text-[12px]",dangerouslySetInnerHTML:{__html:n.html}})]})]})}var bs=a.i(441218);let bt=(0,d.default)("wrap-text",[["path",{d:"m16 16-2 2 2 2",key:"kkc6pm"}],["path",{d:"M3 12h15a3 3 0 1 1 0 6h-4",key:"1cl7v7"}],["path",{d:"M3 18h7",key:"sq21v6"}],["path",{d:"M3 6h18",key:"d0wm0j"}]]);var bu=a.i(617534),bv=a.i(721034),bw=a.i(396106),bx=a.i(279193);let by=(0,bd.createLowlight)(bc);function bz(a){return a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function bA(a){return`${a.lineStart}:${a.lineEnd}:${a.textHash}`}function bB(a){return`L${a.lineStart}-${a.lineEnd}`}async function bC(a){return Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",new TextEncoder().encode(a)))).map(a=>a.toString(16).padStart(2,"0")).join("").slice(0,12)}let bD={".js":"javascript",".cjs":"javascript",".mjs":"javascript",".ts":"typescript",".tsx":"typescript",".jsx":"javascript",".py":"python",".rb":"ruby",".php":"php",".sh":"bash",".bash":"bash",".zsh":"bash",".ps1":"powershell",".css":"css",".scss":"scss",".html":"xml",".json":"json",".jsonc":"json",".yaml":"yaml",".yml":"yaml",".toml":"ini",".ini":"ini",".xml":"xml",".sql":"sql",".graphql":"graphql",".gql":"graphql",".go":"go",".rs":"rust",".swift":"swift",".java":"java",".kt":"kotlin",".kts":"kotlin",".c":"c",".cpp":"cpp",".h":"c",".env":"bash",".txt":"",".text":"",".log":"",".rst":"",".mdx":"markdown"};function bE({path:a}){let[c,d]=(0,T.useState)(null),[e,g]=(0,T.useState)(0),[h,k]=(0,T.useState)(!1),[l,m]=(0,T.useState)(!0),[n,o]=(0,T.useState)(!1),[p,q]=(0,T.useState)(!1),[r,s]=(0,T.useState)(2e3),[t,u]=(0,T.useState)(new Map),[v,w]=(0,T.useState)(null),x=(0,T.useRef)(null),y=(0,Y.withWs)(`/api/assets/${a}`),z=a.split("/").pop()||a,A=bD[z.includes(".")?`.${z.split(".").pop()?.toLowerCase()}`:""]??"",B=(0,bx.useProofStore)(b=>b.byPath[a]?.sidecar??null),C=B?.comments??[],D=(0,T.useMemo)(()=>c?c.replace(/\r\n/g,"\n").split("\n"):[],[c]),E=(0,T.useCallback)(async()=>{m(!0),k(!1),d(null),g(0);try{let a=await (0,Y.wsFetch)(y);if(a.ok){let b=new Uint8Array(await a.arrayBuffer());!function(a){let b=Math.min(a.length,8192);if(0===b)return!1;let c=0;for(let d=0;d<b;d++){let b=a[d];if(0===b)return!0;(b<9||b>13&&b<32)&&c++}return c/b>.3}(b)?(g(b.length),d(new TextDecoder("utf-8").decode(b))):k(!0)}}catch{}finally{m(!1)}},[y]);(0,T.useEffect)(()=>{E(),bx.useProofStore.getState().loadSidecar(a),s(2e3),w(null)},[E,a]);let F=(0,T.useMemo)(()=>D.length,[D]),G=e>2097152||F>5e3,H=(0,T.useMemo)(()=>{if(!c)return[];if(G)return D.map(bz);try{let a=A?by.highlight(A,c):by.highlightAuto(c);return(0,al.toHtml)(a).split("\n")}catch{return D.map(bz)}},[c,A,G,D]),I=G?H.slice(0,r):H,J=G&&r<H.length,K=(0,T.useMemo)(()=>{let a={};for(let b of C){if(!b.lineAnchor)continue;let c=bA(b.lineAnchor);(a[c]??=[]).push(b)}return a},[C]);(0,T.useEffect)(()=>{if(!c||h||l||!x.current)return void u(new Map);let a=x.current,b=a.getBoundingClientRect(),d=Array.from(a.querySelectorAll("[data-line]")),e=new Map;for(let c of d){let d=Number(c.dataset.line);if(!Number.isFinite(d))continue;let f=c.getBoundingClientRect();e.set(d,{top:f.top-b.top+a.scrollTop,left:f.left-b.left,width:f.width,bottom:f.bottom-b.top+a.scrollTop})}u(e)},[c,h,l,r,n,H]);let L=(0,T.useCallback)(()=>{let a=x.current,b=window.getSelection();if(!a||!b||b.isCollapsed||0===b.rangeCount)return;let c=b.getRangeAt(0);if(!a.contains(c.commonAncestorContainer))return;let d=a=>{let b=a?a.nodeType===Node.ELEMENT_NODE?a:a.parentElement:null;return b?.closest("[data-line]")??null},e=d(c.startContainer),f=d(c.endContainer);if(!e||!f)return;let g=Number(e.dataset.line),h=Number(f.dataset.line);if(!Number.isFinite(g)||!Number.isFinite(h))return;let i=Math.min(g,h),j=Math.max(g,h),k=D.slice(i-1,j).join("\n");(async()=>{let a={lineStart:i,lineEnd:j,textHash:await bC(k)};w({anchorKey:bA(a),anchorLabel:bB(a),lineAnchor:a,anchorEl:e})})()},[D]),M=(0,T.useCallback)((a,b)=>{w({anchorKey:bA(a),anchorLabel:bB(a),lineAnchor:a,anchorEl:b})},[]);return h?(0,b.jsx)(ad,{path:a,title:z}):(0,b.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,b.jsxs)($,{path:a,badge:z.includes(".")?z.split(".").pop()?.toUpperCase()??"TEXT":"TEXT",sublabel:A||void 0,children:[(0,b.jsxs)(U.Button,{variant:"ghost",size:"sm",className:`h-7 gap-1.5 text-xs ${n?"bg-muted":""}`,onClick:()=>o(a=>!a),title:n?"Disable line wrap":"Enable line wrap",children:[(0,b.jsx)(bt,{className:"h-3.5 w-3.5"}),"Wrap"]}),(0,b.jsxs)(U.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>{c&&(navigator.clipboard.writeText(c),q(!0),setTimeout(()=>q(!1),2e3))},title:"Copy file contents",children:[p?(0,b.jsx)(f.Check,{className:"h-3.5 w-3.5 text-green-500"}):(0,b.jsx)(i.Copy,{className:"h-3.5 w-3.5"}),p?"Copied":"Copy"]}),(0,b.jsxs)(U.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>{let a=document.createElement("a");a.href=y,a.download=z,a.click()},title:"Download file",children:[(0,b.jsx)(j,{className:"h-3.5 w-3.5"}),"Download"]}),(0,b.jsxs)(U.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>window.open(y,"_blank"),children:[(0,b.jsx)(ae.ExternalLink,{className:"h-3.5 w-3.5"}),"Raw"]})]}),(0,b.jsxs)("div",{ref:x,className:"relative flex-1 overflow-auto source-viewer-code bg-muted",children:[!l&&c&&!h&&(0,b.jsx)(bw.ViewModeCommentButton,{containerRef:x,onComment:L,align:"left"}),(0,b.jsx)("div",{className:"relative pointer-events-none",style:{height:0},children:Object.entries(K).map(([a,c])=>{let d=c[0]?.lineAnchor;if(!d)return null;let e=t.get(d.lineStart);return e?(0,b.jsx)("div",{style:{pointerEvents:"auto"},children:(0,b.jsx)(bu.CommentPip,{anchorKey:a,anchorLabel:bB(d),comments:c,top:e.top+4,left:Math.max(0,e.left-20),onClick:()=>{let a=x.current?.querySelector(`[data-line="${d.lineStart}"]`);a&&M(d,a)}})},`pip-${a}`):null})}),l?(0,b.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Loading..."}):(0,b.jsxs)(b.Fragment,{children:[G&&(0,b.jsxs)("div",{className:"px-4 py-2 text-[11px] text-amber-700 dark:text-amber-300 bg-amber-500/15 border-b border-amber-500/30 font-sans",children:["Large file (",(e/1048576).toFixed(1)," MB, ",H.length.toLocaleString()," lines). Syntax highlighting disabled for performance. Use Raw or Download for the full file."]}),(0,b.jsx)("div",{className:"text-[13px] leading-relaxed font-mono min-w-max",children:I.map((a,c)=>{let d=v?.lineAnchor,e=d&&c+1>=d.lineStart&&c+1<=d.lineEnd;return(0,b.jsxs)("div",{"data-line":c+1,className:`flex ${e?"bg-amber-400/25":"hover:bg-foreground/5"}`,children:[(0,b.jsx)("span",{className:"w-12 shrink-0 pr-4 text-right text-muted-foreground select-none sticky left-0 bg-muted",children:c+1}),(0,b.jsx)("span",{className:`text-foreground pl-2 ${n?"whitespace-pre-wrap break-all":"whitespace-pre"}`,dangerouslySetInnerHTML:{__html:a||" "}})]},c)})}),J&&(0,b.jsxs)("div",{className:"flex items-center gap-3 px-4 py-3 border-t border-border font-sans",children:[(0,b.jsxs)("button",{onClick:()=>s(a=>a+2e3),className:"text-[11px] text-foreground hover:text-foreground px-2.5 py-1 rounded bg-foreground/10 hover:bg-foreground/20 transition-colors",children:["Show ",Math.min(2e3,H.length-r).toLocaleString()," more"]}),(0,b.jsxs)("span",{className:"text-[11px] text-muted-foreground",children:[r.toLocaleString()," / ",H.length.toLocaleString()," lines"]})]})]}),v&&(0,b.jsx)(bv.CommentThread,{path:a,anchorKey:v.anchorKey,anchorLabel:v.anchorLabel,lineAnchor:v.lineAnchor,comments:K[v.anchorKey]??[],anchorEl:v.anchorEl,onClose:()=>w(null)})]})]})}var bF=a.i(28529);function bG({path:a,title:c,src:d,fullscreen:e,onExit:f}){let g=(0,Y.withWs)(d??`/api/assets/${a}/index.html`),h=e&&f?(0,b.jsxs)(U.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:f,title:"Exit app",children:[(0,b.jsx)(bF.ArrowLeft,{className:"h-3.5 w-3.5"}),"Exit app"]}):null;return(0,b.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,b.jsx)($,{path:a,badge:e?"App":void 0,showBreadcrumb:!e,leading:e?(0,b.jsxs)(b.Fragment,{children:[h,(0,b.jsx)("span",{className:"truncate text-[13px] font-medium text-foreground",children:c})]}):null,children:(0,b.jsxs)(U.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>window.open(g,"_blank"),children:[(0,b.jsx)(ae.ExternalLink,{className:"h-3.5 w-3.5"}),"Open in new tab"]})}),(0,b.jsx)("iframe",{src:g,className:"flex-1 w-full border-0 bg-card",title:c,sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-top-navigation-by-user-activation"})]})}let bH=(0,d.default)("play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]),bI=(0,d.default)("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);var bJ=a.i(335732);let bK={stopped:"Stopped",installing:"Installing dependencies…",starting:"Starting…",running:"Running",error:"Error"};function bL({path:a,title:d}){let[e,f]=(0,T.useState)("stopped"),[h,i]=(0,T.useState)(null),[j,k]=(0,T.useState)([]),[l,m]=(0,T.useState)(null),[n,o]=(0,T.useState)(!1),[p,q]=(0,T.useState)(0),[r,s]=(0,T.useState)([]),[t,u]=(0,T.useState)(null),v=(0,T.useRef)(null),w=(0,T.useRef)(null),x=`/api/app-proxy/${a}/`,y=()=>{v.current&&(clearInterval(v.current),v.current=null)},A=(0,T.useCallback)(async()=>{try{let b=await (0,Y.wsFetch)(`/api/wiki/app?path=${encodeURIComponent(a)}`);if(!b.ok)return;let c=await b.json();f(c.status),k(c.logs??[]),c.scripts&&s(c.scripts),void 0!==c.defaultScript&&u(c.defaultScript),c.port&&i(c.port),c.error&&m(c.error),("running"===c.status||"stopped"===c.status||"error"===c.status)&&y()}catch{}},[a]);(0,T.useEffect)(()=>("installing"===e||"starting"===e?v.current||(v.current=setInterval(A,800)):y(),y),[e,A]),(0,T.useEffect)(()=>{w.current?.scrollIntoView({behavior:"smooth"})},[j]),(0,T.useEffect)(()=>{A()},[A]);let B=async b=>{m(null),k([]),f("starting");try{let c=await (0,Y.wsFetch)("/api/wiki/app",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a,script:b})}),d=await c.json();if(!c.ok||d.error){f("error"),m(d.error??"Failed to start");return}d.port&&i(d.port),await A()}catch(a){f("error"),m(String(a))}},C=async()=>{await (0,Y.wsFetch)("/api/wiki/app",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a})}),f("stopped"),i(null)},D=async()=>{await C(),await B(),q(a=>a+1)},E=r.filter(a=>a!==t);return(0,b.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,b.jsxs)($,{path:a,badge:"Node app",children:["running"===e&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(U.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>q(a=>a+1),children:[(0,b.jsx)(K,{className:"h-3.5 w-3.5"}),"Refresh"]}),(0,b.jsxs)(U.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>window.open(x,"_blank"),children:[(0,b.jsx)(ae.ExternalLink,{className:"h-3.5 w-3.5"}),"Open in new tab"]}),(0,b.jsxs)(U.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:D,children:[(0,b.jsx)(K,{className:"h-3.5 w-3.5"}),"Restart"]}),(0,b.jsxs)(U.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs text-destructive hover:text-destructive",onClick:C,children:[(0,b.jsx)(bI,{className:"h-3.5 w-3.5"}),"Stop"]})]}),(0,b.jsxs)(U.Button,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>o(a=>!a),children:[(0,b.jsx)(O,{className:"h-3.5 w-3.5"}),"Logs"]})]}),n&&(0,b.jsxs)("div",{className:"border-b bg-black/90 text-green-400 font-mono text-xs h-40 overflow-auto p-2 shrink-0",children:[0===j.length?(0,b.jsx)("span",{className:"text-muted-foreground",children:"No output yet."}):j.map((a,c)=>(0,b.jsx)("div",{className:"whitespace-pre-wrap leading-5",children:a},c)),(0,b.jsx)("div",{ref:w})]}),(0,b.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:["stopped"===e&&(0,b.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-4",children:[(0,b.jsxs)("div",{className:"text-center space-y-1",children:[(0,b.jsx)("p",{className:"text-sm font-medium",children:d}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:"Node.js app — will be started on a local port"})]}),(0,b.jsxs)("div",{className:"inline-flex items-stretch overflow-hidden rounded-full bg-primary text-primary-foreground shadow-e-1",children:[(0,b.jsxs)("button",{type:"button",onClick:()=>B(),className:"inline-flex items-center gap-2 px-4 py-2.5 text-sm font-medium transition-colors hover:bg-primary-foreground/10 focus-visible:outline-none",children:[(0,b.jsx)(bH,{className:"h-4 w-4"}),"Launch app",t&&(0,b.jsxs)("span",{className:"opacity-70",children:["(",t,")"]})]}),E.length>0&&(0,b.jsxs)(bJ.DropdownMenu,{children:[(0,b.jsx)(bJ.DropdownMenuTrigger,{asChild:!0,children:(0,b.jsx)("button",{type:"button",className:"inline-flex items-center justify-center border-l border-l-primary-foreground/20 px-2 transition-colors hover:bg-primary-foreground/10 focus-visible:outline-none","aria-label":"Choose script to launch",children:(0,b.jsx)(g.ChevronDown,{className:"h-4 w-4"})})}),(0,b.jsxs)(bJ.DropdownMenuContent,{align:"end",children:[(0,b.jsx)(bJ.DropdownMenuLabel,{children:"Run script"}),(0,b.jsx)(bJ.DropdownMenuSeparator,{}),r.map(a=>(0,b.jsxs)(bJ.DropdownMenuItem,{onSelect:()=>B(a),className:"gap-2 font-mono text-xs",children:[(0,b.jsx)(bH,{className:"h-3.5 w-3.5"}),a,a===t&&(0,b.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"default"})]},a))]})]})]})]}),("installing"===e||"starting"===e)&&(0,b.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-3",children:[(0,b.jsx)(z.Loader2,{className:"h-6 w-6 animate-spin text-muted-foreground"}),(0,b.jsx)("p",{className:"text-sm text-muted-foreground",children:bK[e]}),h&&(0,b.jsxs)("p",{className:"text-xs text-muted-foreground/60",children:["port ",h]})]}),"error"===e&&(0,b.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-4 p-6",children:[(0,b.jsx)(c.AlertCircle,{className:"h-8 w-8 text-destructive"}),(0,b.jsxs)("div",{className:"text-center space-y-1 max-w-md",children:[(0,b.jsx)("p",{className:"text-sm font-medium text-destructive",children:"Failed to start app"}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground break-words",children:l??"Unknown error"})]}),(0,b.jsxs)(U.Button,{onClick:()=>B(),variant:"outline",className:"gap-2",children:[(0,b.jsx)(K,{className:"h-4 w-4"}),"Try again"]})]}),"running"===e&&(0,b.jsx)("iframe",{src:x,className:"flex-1 w-full border-0 bg-card",title:d,sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-modals allow-top-navigation-by-user-activation"},p)]})]})}let bM=(0,d.default)("hard-drive",[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]]),bN=(0,d.default)("house",[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"1d0kgt"}]]),bO=(0,d.default)("key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]]),bP=(0,d.default)("pin-off",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]]);function bQ({onSelect:a}){let[c,d]=(0,T.useState)("local"),[e,f]=(0,T.useState)(null),[g,i]=(0,T.useState)(!0),[j,k]=(0,T.useState)(null),[l,m]=(0,T.useState)(""),[n,q]=(0,T.useState)(!1),[t,u]=(0,T.useState)([]),[v,w]=(0,T.useState)(!1),x=(0,T.useRef)(null),y=(0,T.useRef)(null),[A,B]=(0,T.useState)(""),[C,D]=(0,T.useState)(""),[E,F]=(0,T.useState)(""),[G,H]=(0,T.useState)(""),[J,K]=(0,T.useState)(""),[L,M]=(0,T.useState)(""),[N,O]=(0,T.useState)(!1),[P,Q]=(0,T.useState)(null),[R,V]=(0,T.useState)(""),[W,X]=(0,T.useState)(""),[Y,$]=(0,T.useState)("agent"),[_,aa]=(0,T.useState)(""),[ab,ac]=(0,T.useState)(""),[ad,ae]=(0,T.useState)(!1),[af,ag]=(0,T.useState)(""),[ah,ai]=(0,T.useState)(!1),[aj,ak]=(0,T.useState)(null),al=async()=>{let b=R.trim();if(!b)return void ak("SSH target is required (user@host:/path).");if("keyfile"===Y&&!_.trim())return void ak("Private key path is required for key-file auth.");if("password"===Y&&!ab)return void ak("Password is required for password auth.");ai(!0),ak(null);try{let c={sshTarget:b,sshAuthMethod:Y};W.trim()&&(c.sshPort=Number(W.trim())),"keyfile"===Y&&_.trim()&&(c.sshKeyPath=_.trim()),"password"===Y&&ab&&(c.sshPassword=ab),ad&&(c.sshReadOnly=!0),af.trim()&&(c.name=af.trim());let d=await fetch("/api/system/workspaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)});if(!d.ok){let a=await d.json();ak(a.error??a.message??"Mount failed.");return}let{workspace:e}=await d.json();ac(""),a(e.id)}catch{ak("Network error.")}finally{ai(!1)}},am=async()=>{let b=A.trim();if(!b)return void Q("Repository URL is required.");O(!0),Q(null);try{let c={remoteUrl:b};C.trim()&&(c.branch=C.trim()),E.trim()&&(c.subpath=E.trim()),G.trim()&&(c.username=G.trim()),J.trim()&&(c.token=J.trim()),L.trim()&&(c.name=L.trim());let d=await fetch("/api/system/workspaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)});if(!d.ok){let a=await d.json();Q(a.error??a.message??"Clone failed.");return}let{workspace:e}=await d.json();K(""),a(e.id)}catch{Q("Network error.")}finally{O(!1)}},an=(0,T.useCallback)(async(a,b=!0)=>{y.current&&(clearTimeout(y.current),y.current=null),i(!0),k(null);try{let c=await fetch(`/api/system/browse?path=${encodeURIComponent(a)}`);if(!c.ok){let a=await c.json();k(a.error??"Cannot open directory");return}let d=await c.json();f(d),b&&m(d.path)}catch{k("Network error")}finally{i(!1)}},[]);(0,T.useEffect)(()=>{let a=!1;return(async()=>{try{let b=await fetch("/api/system/config");if(b.ok&&!a){let a=await b.json();u(a.pinnedPaths??[]),await an(a.lastOpenedPath??"");return}}catch{}a||await an("")})(),()=>{a=!0}},[]);let ao=async b=>{let c=b??e?.path;if(c){q(!0);try{let b=await fetch("/api/system/workspaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({rootDir:c})});if(!b.ok){let a=await b.json();k(a.message??a.error??"Cannot use that directory");return}let{workspace:d}=await b.json();a(d.id)}catch{k("Network error")}finally{q(!1)}}},ap=!!e&&t.includes(e.path),aq=async()=>{if(e){w(!0);try{let a=ap?"unpin":"pin";(await fetch("/api/system/pins",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e.path,action:a})})).ok&&u(b=>"pin"===a?[...b,e.path]:b.filter(a=>a!==e.path))}catch{}finally{w(!1)}}},ar=async a=>{try{(await fetch("/api/system/pins",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a,action:"unpin"})})).ok&&u(b=>b.filter(b=>b!==a))}catch{}},as=(e?.path??"").split(/[/\\]/).filter(Boolean).reduce((a,b)=>{let c=a[a.length-1]?.path??"/";return a.push({label:b,path:`${"/"===c?"":c}/${b}`}),a},[{label:"/",path:"/"}]);return(0,b.jsx)("div",{className:"flex flex-1 items-center justify-center bg-background p-4",children:(0,b.jsxs)("div",{className:"flex w-full max-w-xl flex-col gap-4",children:[(0,b.jsxs)("div",{className:"text-center space-y-1",children:[(0,b.jsxs)("div",{className:"flex items-center justify-center gap-2 mb-1",children:[(0,b.jsx)("img",{src:"/logo.svg",alt:"Wiki Viewer",className:"h-8 w-8"}),(0,b.jsx)("span",{className:"text-xl font-semibold tracking-tight",children:"Wiki Viewer"})]}),(0,b.jsx)("h1",{className:"text-xl font-medium",children:"git"===c?"Add a Git repository":"ssh"===c?"Add a remote directory over SSH":"Choose a directory"}),(0,b.jsx)("p",{className:"text-sm text-muted-foreground",children:"git"===c?(0,b.jsxs)(b.Fragment,{children:["Clone a remote repo and serve it as a read-only workspace.",(0,b.jsx)("br",{}),"The server clones it, so the URL must be reachable from the server."]}):"ssh"===c?(0,b.jsxs)(b.Fragment,{children:["Mount a remote directory over SSH (sshfs) — no local clone.",(0,b.jsx)("br",{}),"Requires sshfs + FUSE installed on the server."]}):(0,b.jsxs)(b.Fragment,{children:["Select the folder wiki-viewer should serve.",(0,b.jsx)("br",{}),"This directory lives on the server, so use the browser below."]})})]}),(0,b.jsxs)("div",{className:"flex items-center self-center rounded-lg border bg-muted p-0.5 gap-0.5",children:[(0,b.jsxs)(U.Button,{variant:"local"===c?"default":"ghost",size:"sm",className:"h-7 px-3 text-xs gap-1.5",onClick:()=>{d("local"),K(""),Q(null)},children:[(0,b.jsx)(o.Folder,{className:"h-3.5 w-3.5"}),"Local folder"]}),(0,b.jsxs)(U.Button,{variant:"git"===c?"default":"ghost",size:"sm",className:"h-7 px-3 text-xs gap-1.5",onClick:()=>d("git"),children:[(0,b.jsx)(r,{className:"h-3.5 w-3.5"}),"From Git"]}),(0,b.jsxs)(U.Button,{variant:"ssh"===c?"default":"ghost",size:"sm",className:"h-7 px-3 text-xs gap-1.5",onClick:()=>{d("ssh"),ak(null)},children:[(0,b.jsx)(s,{className:"h-3.5 w-3.5"}),"Over SSH"]})]}),"git"===c&&(0,b.jsxs)("div",{className:"rounded-lg border bg-card shadow-sm overflow-hidden",children:[(0,b.jsxs)("div",{className:"px-4 pt-4 pb-3 flex flex-col gap-3",children:[(0,b.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,b.jsx)("label",{className:"text-xs font-medium",children:"Repository URL"}),(0,b.jsx)("div",{className:"flex items-center gap-2 rounded-md border bg-muted px-3 py-2",children:(0,b.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none font-mono min-w-0",placeholder:"https://github.com/org/repo.git",value:A,onChange:a=>{B(a.target.value),Q(null)},disabled:N,autoComplete:"off",spellCheck:!1})}),(0,b.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"Only https:// URLs are supported."})]}),(0,b.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,b.jsxs)("label",{className:"text-xs font-medium",children:["Branch ",(0,b.jsx)("span",{className:"font-normal text-muted-foreground",children:"(optional)"})]}),(0,b.jsx)("div",{className:"flex items-center gap-2 rounded-md border bg-muted px-3 py-2",children:(0,b.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none min-w-0",placeholder:"main (default branch if empty)",value:C,onChange:a=>{D(a.target.value),Q(null)},disabled:N})})]}),(0,b.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,b.jsxs)("label",{className:"text-xs font-medium",children:["Subdirectory ",(0,b.jsx)("span",{className:"font-normal text-muted-foreground",children:"(optional)"})]}),(0,b.jsx)("div",{className:"flex items-center gap-2 rounded-md border bg-muted px-3 py-2",children:(0,b.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none font-mono min-w-0",placeholder:"docs (whole repo if empty)",value:E,onChange:a=>{F(a.target.value),Q(null)},disabled:N,spellCheck:!1})}),(0,b.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"Serve only this folder from the repo. Faster to clone for large repos with docs in a subfolder."})]}),(0,b.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,b.jsxs)("label",{className:"text-xs font-medium",children:["Username ",(0,b.jsx)("span",{className:"font-normal text-muted-foreground",children:"(optional)"})]}),(0,b.jsx)("div",{className:"flex items-center gap-2 rounded-md border bg-muted px-3 py-2",children:(0,b.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none min-w-0",placeholder:"x-access-token (default)",value:G,onChange:a=>{H(a.target.value),Q(null)},disabled:N,autoComplete:"off"})}),(0,b.jsxs)("p",{className:"text-[11px] text-muted-foreground",children:["GitLab uses ",(0,b.jsx)("code",{className:"font-mono",children:"oauth2"}),"; Bitbucket uses your account username."]})]}),(0,b.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,b.jsxs)("label",{className:"text-xs font-medium",children:["Access token ",(0,b.jsx)("span",{className:"font-normal text-muted-foreground",children:"(optional)"})]}),(0,b.jsxs)("div",{className:"flex items-center gap-2 rounded-md border bg-muted px-3 py-2",children:[(0,b.jsx)(bO,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,b.jsx)("input",{type:"password",className:"flex-1 bg-transparent text-sm outline-none min-w-0",placeholder:"Personal access token",value:J,onChange:a=>{K(a.target.value),Q(null)},disabled:N,autoComplete:"off"})]}),(0,b.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"Required only for private repos. Stored securely on the server and never shown again."})]}),(0,b.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,b.jsxs)("label",{className:"text-xs font-medium",children:["Display name ",(0,b.jsx)("span",{className:"font-normal text-muted-foreground",children:"(optional)"})]}),(0,b.jsx)("div",{className:"flex items-center gap-2 rounded-md border bg-muted px-3 py-2",children:(0,b.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none min-w-0",placeholder:"Defaults to the repository name",value:L,onChange:a=>{M(a.target.value),Q(null)},disabled:N})})]}),P&&(0,b.jsx)("p",{className:"text-sm text-destructive",children:P})]}),(0,b.jsxs)("div",{className:"border-t px-4 py-3 flex items-center justify-between gap-3 bg-muted",children:[(0,b.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"Git workspaces are read-only, so editing is disabled."}),(0,b.jsx)(U.Button,{size:"sm",className:"shrink-0 gap-1.5",disabled:N,onClick:am,children:N?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(z.Loader2,{className:"h-3.5 w-3.5 animate-spin"})," Cloning..."]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(r,{className:"h-3.5 w-3.5"})," Clone and add"]})})]})]}),"ssh"===c&&(0,b.jsxs)("div",{className:"rounded-lg border bg-card shadow-sm overflow-hidden",children:[(0,b.jsxs)("div",{className:"px-4 pt-4 pb-3 flex flex-col gap-3",children:[(0,b.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,b.jsx)("label",{className:"text-xs font-medium",children:"SSH target"}),(0,b.jsx)("div",{className:"flex items-center gap-2 rounded-md border bg-muted px-3 py-2",children:(0,b.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none font-mono min-w-0",placeholder:"user@host:/abs/path",value:R,onChange:a=>{V(a.target.value),ak(null)},disabled:ah,autoComplete:"off",spellCheck:!1})}),(0,b.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"The remote path must be absolute."})]}),(0,b.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,b.jsxs)("label",{className:"text-xs font-medium",children:["Port ",(0,b.jsx)("span",{className:"font-normal text-muted-foreground",children:"(optional)"})]}),(0,b.jsx)("div",{className:"flex items-center gap-2 rounded-md border bg-muted px-3 py-2",children:(0,b.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none min-w-0",placeholder:"22",inputMode:"numeric",value:W,onChange:a=>{X(a.target.value.replace(/[^0-9]/g,"")),ak(null)},disabled:ah})})]}),(0,b.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,b.jsx)("label",{className:"text-xs font-medium",children:"Authentication"}),(0,b.jsx)("div",{className:"flex items-center self-start rounded-lg border bg-muted p-0.5 gap-0.5",children:["agent","keyfile","password"].map(a=>(0,b.jsx)(U.Button,{variant:Y===a?"default":"ghost",size:"sm",className:"h-7 px-3 text-xs",onClick:()=>{$(a),ak(null)},disabled:ah,children:"agent"===a?"SSH agent":"keyfile"===a?"Key file":"Password"},a))}),(0,b.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"agent"===Y?"Uses the server's ssh-agent and default keys (~/.ssh/id_*).":"keyfile"===Y?"Uses a specific private key on the server.":"Stored securely on the server and never shown again."})]}),"keyfile"===Y&&(0,b.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,b.jsx)("label",{className:"text-xs font-medium",children:"Private key path"}),(0,b.jsxs)("div",{className:"flex items-center gap-2 rounded-md border bg-muted px-3 py-2",children:[(0,b.jsx)(bO,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,b.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none font-mono min-w-0",placeholder:"~/.ssh/id_ed25519",value:_,onChange:a=>{aa(a.target.value),ak(null)},disabled:ah,autoComplete:"off",spellCheck:!1})]})]}),"password"===Y&&(0,b.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,b.jsx)("label",{className:"text-xs font-medium",children:"Password"}),(0,b.jsxs)("div",{className:"flex items-center gap-2 rounded-md border bg-muted px-3 py-2",children:[(0,b.jsx)(bO,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,b.jsx)("input",{type:"password",className:"flex-1 bg-transparent text-sm outline-none min-w-0",placeholder:"SSH password",value:ab,onChange:a=>{ac(a.target.value),ak(null)},disabled:ah,autoComplete:"off"})]})]}),(0,b.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,b.jsxs)("label",{className:"text-xs font-medium",children:["Display name ",(0,b.jsx)("span",{className:"font-normal text-muted-foreground",children:"(optional)"})]}),(0,b.jsx)("div",{className:"flex items-center gap-2 rounded-md border bg-muted px-3 py-2",children:(0,b.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none min-w-0",placeholder:"Defaults to host:path",value:af,onChange:a=>{ag(a.target.value),ak(null)},disabled:ah})})]}),(0,b.jsxs)("label",{className:"flex items-center gap-2 text-xs font-medium cursor-pointer select-none",children:[(0,b.jsx)("input",{type:"checkbox",checked:ad,onChange:a=>ae(a.target.checked),disabled:ah}),"Mount read-only"]}),aj&&(0,b.jsx)("p",{className:"text-sm text-destructive",children:aj})]}),(0,b.jsxs)("div",{className:"border-t px-4 py-3 flex items-center justify-between gap-3 bg-muted",children:[(0,b.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"Served live over SSH — nothing is copied to disk."}),(0,b.jsx)(U.Button,{size:"sm",className:"shrink-0 gap-1.5",disabled:ah,onClick:al,children:ah?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(z.Loader2,{className:"h-3.5 w-3.5 animate-spin"})," Mounting..."]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(s,{className:"h-3.5 w-3.5"})," Mount and add"]})})]})]}),"local"===c&&(0,b.jsxs)("div",{className:"rounded-lg border bg-card shadow-sm overflow-hidden",children:[(0,b.jsx)("div",{className:"flex items-center gap-2 border-b px-3 py-2 bg-muted",children:(0,b.jsx)("input",{ref:x,className:"flex-1 bg-transparent text-sm outline-none font-mono min-w-0",value:l,onChange:a=>{let b=a.target.value;m(b),y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{y.current=null,an(b.trim(),!1)},500)},onKeyDown:a=>{"Enter"===a.key&&(a.preventDefault(),y.current&&(clearTimeout(y.current),y.current=null),an(l.trim())),"Escape"===a.key&&(y.current&&(clearTimeout(y.current),y.current=null),m(e?.path??""),x.current?.blur())},spellCheck:!1,placeholder:"Enter a path…"})}),(0,b.jsx)("div",{className:"flex items-center gap-1 border-b px-3 py-1.5 bg-muted/50 overflow-x-auto shrink-0 min-h-[32px]",children:as.map((a,c)=>(0,b.jsxs)("span",{className:"flex items-center gap-1 shrink-0",children:[c>0&&(0,b.jsx)(h.ChevronRight,{className:"h-3 w-3 text-muted-foreground/50"}),(0,b.jsx)("button",{type:"button",className:"text-xs hover:text-foreground text-muted-foreground transition-colors rounded px-0.5",onClick:()=>an(a.path),children:0===c?(0,b.jsx)(bM,{className:"h-3.5 w-3.5"}):a.label})]},a.path))}),(0,b.jsx)("div",{className:"max-h-60 overflow-y-auto",children:g?(0,b.jsx)("div",{className:"flex justify-center py-8",children:(0,b.jsx)(z.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):j?(0,b.jsx)("div",{className:"px-4 py-3 text-sm text-destructive",children:j}):(0,b.jsxs)(b.Fragment,{children:[e?.parent&&(0,b.jsxs)("button",{type:"button",className:"flex w-full items-center gap-2.5 px-3 py-2 text-sm text-muted-foreground hover:bg-accent hover:text-accent-foreground transition-colors",onClick:()=>an(e.parent),children:[(0,b.jsx)(o.Folder,{className:"h-4 w-4 shrink-0"}),(0,b.jsx)("span",{className:"font-mono text-xs",children:".."})]}),e?.entries.length===0&&(0,b.jsx)("p",{className:"px-4 py-3 text-sm text-muted-foreground/60",children:"No subdirectories"}),e?.entries.map(a=>(0,b.jsxs)("button",{type:"button",className:"flex w-full items-center gap-2.5 px-3 py-2 text-sm hover:bg-accent hover:text-accent-foreground transition-colors",onClick:()=>an(a.path),children:[(0,b.jsx)(o.Folder,{className:"h-4 w-4 shrink-0 text-warning"}),(0,b.jsx)("span",{className:"truncate",children:a.name})]},a.path))]})}),(0,b.jsxs)("div",{className:"border-t px-3 py-2 flex items-center justify-between gap-2 bg-muted",children:[(0,b.jsxs)("button",{type:"button",className:(0,Z.cn)("flex items-center gap-1.5 text-xs transition-colors rounded px-1.5 py-1",ap?"text-foreground hover:text-destructive":"text-muted-foreground hover:text-foreground"),title:ap?"Unpin this path":"Pin this path for quick access",onClick:aq,disabled:v||!e,children:[v?(0,b.jsx)(z.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):ap?(0,b.jsx)(bP,{className:"h-3.5 w-3.5"}):(0,b.jsx)(I,{className:"h-3.5 w-3.5"}),ap?"Unpin":"Pin"]}),(0,b.jsxs)(U.Button,{size:"sm",className:"shrink-0 gap-1.5",disabled:!e||n,onClick:()=>ao(),children:[n?(0,b.jsx)(z.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):(0,b.jsx)(p,{className:"h-3.5 w-3.5"}),"Select"]})]})]}),"local"===c&&t.length>0&&(0,b.jsxs)("div",{className:"rounded-lg border bg-card shadow-sm overflow-hidden",children:[(0,b.jsx)("div",{className:"px-3 py-2 border-b bg-muted",children:(0,b.jsxs)("span",{className:"text-xs font-medium text-muted-foreground flex items-center gap-1.5",children:[(0,b.jsx)(I,{className:"h-3 w-3"})," Pinned"]})}),(0,b.jsx)("div",{className:"max-h-40 overflow-y-auto",children:t.map(a=>(0,b.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 hover:bg-accent group",children:[(0,b.jsxs)("button",{type:"button",className:"flex-1 flex items-center gap-2 text-sm text-left min-w-0",onClick:()=>an(a),children:[(0,b.jsx)(o.Folder,{className:"h-4 w-4 shrink-0 text-warning"}),(0,b.jsx)("span",{className:"truncate font-mono text-xs",children:a})]}),(0,b.jsx)("button",{type:"button",className:"shrink-0 text-muted-foreground/50 hover:text-destructive opacity-0 group-hover:opacity-100 transition-all",onClick:()=>ar(a),title:"Remove pin",children:(0,b.jsx)(S.X,{className:"h-3.5 w-3.5"})})]},a))})]}),"local"===c&&e?.shortcuts&&e.shortcuts.length>0&&(0,b.jsx)("div",{className:"flex flex-wrap gap-1.5 justify-center",children:e.shortcuts.map(a=>(0,b.jsxs)(U.Button,{variant:"outline",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>an(a.path),children:["Home"===a.label?(0,b.jsx)(bN,{className:"h-3 w-3"}):(0,b.jsx)(bM,{className:"h-3 w-3"}),a.label]},a.path))})]})})}var bR=a.i(525704);function bS({pos:a,branches:c,loading:d,busyName:e,disabled:g,onPick:h,onClose:i}){let[j,k]=(0,T.useState)(""),l=(0,T.useRef)(null);if((0,T.useEffect)(()=>{let a=a=>{let b=a.target;l.current?.contains(b)||b?.closest?.("[data-branch-trigger]")||i()},b=a=>{"Escape"===a.key&&i()};return document.addEventListener("mousedown",a),document.addEventListener("keydown",b),()=>{document.removeEventListener("mousedown",a),document.removeEventListener("keydown",b)}},[i]),"u"<typeof document)return null;let m=c.length>8,n=j.trim().toLowerCase(),o=n?c.filter(a=>a.name.toLowerCase().includes(n)):c;return(0,bR.createPortal)((0,b.jsx)("div",{ref:l,"data-branch-portal":!0,style:{position:"fixed",top:a.top,left:a.left},className:"pointer-events-auto z-[9999] flex max-h-72 w-52 flex-col overflow-hidden rounded-md border bg-popover p-1 shadow-md",children:d?(0,b.jsx)("div",{className:"flex justify-center py-2",children:(0,b.jsx)(z.Loader2,{className:"h-3.5 w-3.5 animate-spin text-muted-foreground"})}):0===c.length?(0,b.jsx)("p",{className:"px-2 py-1 text-[10px] text-muted-foreground",children:"No branches"}):(0,b.jsxs)(b.Fragment,{children:[m&&(0,b.jsx)("input",{autoFocus:!0,value:j,onChange:a=>k(a.target.value),placeholder:"Filter branches…",className:"mb-1 w-full shrink-0 rounded border bg-background px-1.5 py-1 text-[11px] outline-none focus:ring-1 focus:ring-ring"}),(0,b.jsx)("div",{className:"min-h-0 flex-1 overflow-auto",children:0===o.length?(0,b.jsx)("p",{className:"px-2 py-1 text-[10px] text-muted-foreground",children:"No match"}):o.map(a=>(0,b.jsxs)("button",{type:"button",disabled:g||a.current,className:(0,Z.cn)("flex w-full items-center gap-1.5 rounded px-2 py-1 text-left text-[11px] hover:bg-muted",a.current?"font-semibold text-foreground":"text-muted-foreground"),onClick:b=>{b.stopPropagation(),a.current||h(a.name)},children:[a.current?(0,b.jsx)(f.Check,{className:"h-3 w-3 shrink-0"}):(0,b.jsx)("span",{className:"w-3 shrink-0"}),(0,b.jsx)("span",{className:"truncate",children:a.name}),e===a.name&&(0,b.jsx)(z.Loader2,{className:"ml-auto h-3 w-3 shrink-0 animate-spin"})]},a.name))})]})}),document.body)}var bT=a.i(111939),bU=a.i(188619);let bV=bU.Root;bU.Trigger;let bW=bU.Close,bX=bU.Portal,bY=T.forwardRef(({className:a,...c},d)=>(0,b.jsx)(bU.Overlay,{ref:d,className:(0,Z.cn)("fixed inset-0 z-40 bg-overlay backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",a),...c}));bY.displayName="SheetOverlay";let bZ={bottom:"inset-x-0 bottom-0 data-[state=open]:slide-in-from-bottom data-[state=closed]:slide-out-to-bottom",top:"inset-x-0 top-0 data-[state=open]:slide-in-from-top data-[state=closed]:slide-out-to-top",left:"inset-y-0 left-0 data-[state=open]:slide-in-from-left data-[state=closed]:slide-out-to-left",right:"inset-y-0 right-0 data-[state=open]:slide-in-from-right data-[state=closed]:slide-out-to-right"},b$=T.forwardRef(({side:a="bottom",showClose:c=!1,className:d,children:e,...f},g)=>(0,b.jsxs)(bX,{children:[(0,b.jsx)(bY,{}),(0,b.jsxs)(bU.Content,{ref:g,className:(0,Z.cn)("fixed z-50 bg-background shadow-golden transition-all ease-in-out","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-200 data-[state=open]:duration-300",bZ[a],d),...f,children:[e,c&&(0,b.jsxs)(bU.Close,{className:"absolute right-4 top-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring disabled:pointer-events-none",children:[(0,b.jsx)(S.X,{className:"h-4 w-4"}),(0,b.jsx)("span",{className:"sr-only",children:"Close"})]})]})]}));b$.displayName="SheetContent",T.forwardRef(({className:a,...c},d)=>(0,b.jsx)(bU.Title,{ref:d,className:(0,Z.cn)("text-sm font-medium leading-none tracking-tight",a),...c})).displayName="SheetTitle",T.forwardRef(({className:a,...c},d)=>(0,b.jsx)(bU.Description,{ref:d,className:(0,Z.cn)("text-sm text-muted-foreground",a),...c})).displayName="SheetDescription";var b_=a.i(193097),b0=a.i(92437),b1=a.i(612455);let b2={default:"Default",editorial:"Editorial"},b3=["default","editorial"],b4=(0,b1.create)(a=>({skin:"editorial",setSkin:b=>{a({skin:b})}}));var b5=a.i(838629);function b6(a){return a.split(/[\n,]/).map(a=>a.trim()).filter(Boolean)}function b7(){let a=(0,b5.useExperimentsStore)(a=>a.flags),c=(0,b5.useExperimentsStore)(a=>a.toggle);return(0,b.jsx)("div",{className:"space-y-1.5",children:b5.EXPERIMENTS.map(d=>{let e=a[d.id];return(0,b.jsxs)("button",{type:"button",onClick:()=>c(d.id),"aria-pressed":e,className:`flex w-full items-start justify-between gap-3 rounded-md border px-3 py-2 text-left transition-colors ${e?"border-ring bg-accent":"border-border hover:bg-accent/50"}`,children:[(0,b.jsxs)("span",{className:"min-w-0",children:[(0,b.jsx)("span",{className:"block text-sm font-medium",children:d.label}),(0,b.jsx)("span",{className:"block text-xs text-muted-foreground",children:d.description})]}),(0,b.jsx)("span",{"aria-hidden":!0,className:`mt-0.5 flex h-5 w-9 shrink-0 items-center rounded-full px-0.5 transition-colors ${e?"bg-primary":"bg-muted-foreground/30"}`,children:(0,b.jsx)("span",{className:`h-4 w-4 rounded-full bg-background transition-transform ${e?"translate-x-4":"translate-x-0"}`})})]},d.id)})})}function b8(){let a=b4(a=>a.skin),c=b4(a=>a.setSkin);return(0,b.jsx)("div",{className:"flex gap-1.5",children:b3.map(d=>(0,b.jsx)("button",{type:"button",onClick:()=>c(d),"aria-pressed":a===d,className:`flex-1 rounded-md border px-3 py-2 text-sm transition-colors ${a===d?"border-ring bg-accent font-medium text-accent-foreground":"border-border text-muted-foreground hover:bg-accent/50"}`,children:b2[d]},d))})}function b9({open:a,onOpenChange:d}){let[e,f]=(0,T.useState)(!1),[g,h]=(0,T.useState)(!1),[i,j]=(0,T.useState)(null),[k,l]=(0,T.useState)("env"),[m,n]=(0,T.useState)(""),[o,p]=(0,T.useState)(""),[q,r]=(0,T.useState)(null),{data:s}=b0.authClient.useSession(),[t,u]=(0,T.useState)(!1),[v,w]=(0,T.useState)([]),[x,y]=(0,T.useState)([]),[A,B]=(0,T.useState)(null),[C,D]=(0,T.useState)(null),[E,F]=(0,T.useState)(""),[G,H]=(0,T.useState)(""),[I,J]=(0,T.useState)(!1),[K,L]=(0,T.useState)(null),M=(0,T.useCallback)(async()=>{try{let a=await fetch("/api/system/admins");if(!a.ok)return;let b=await a.json();u(!!b.isAdmin),w(b.admins??[]),y(b.users??[])}catch{}},[]),N=(0,T.useCallback)(async()=>{f(!0),j(null);try{let a=await fetch("/api/system/auth-settings");if(!a.ok)throw Error("Failed to load settings");let b=await a.json();n(b.allowedEmails.join("\n")),p(b.allowedDomains.join("\n")),l(b.source),r("number"==typeof b.rateLimit?b.rateLimit:null)}catch(a){j(a instanceof Error?a.message:"Failed to load")}finally{f(!1)}},[]);async function O(){h(!0),j(null);try{let a=await fetch("/api/system/auth-settings",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({allowedEmails:b6(m),allowedDomains:b6(o)})}),b=await a.json();if(!a.ok){j(b.error??"Save failed"),(0,b_.showError)(b.error??"Save failed");return}b.source&&l(b.source),d(!1)}catch{j("Save failed")}finally{h(!1)}}(0,T.useEffect)(()=>{a&&(N(),M())},[a,N,M]);let P=0===b6(m).length&&0===b6(o).length;return(0,b.jsx)(bV,{open:a,onOpenChange:d,children:(0,b.jsxs)(b$,{side:"right",className:"w-[90vw] max-w-sm md:w-80 sm:max-w-md flex flex-col border-l border-border p-0",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between border-b border-border px-4 py-3 shrink-0",children:[(0,b.jsx)("span",{className:"text-sm font-semibold",children:"Settings"}),(0,b.jsxs)(bW,{className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-accent focus:outline-none focus:ring-2 focus:ring-ring",children:[(0,b.jsx)(S.X,{className:"h-3.5 w-3.5"}),(0,b.jsx)("span",{className:"sr-only",children:"Close"})]})]}),e?(0,b.jsx)("div",{className:"flex flex-1 items-center justify-center",children:(0,b.jsx)(z.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):(0,b.jsxs)("div",{className:"flex-1 space-y-5 overflow-y-auto px-4 py-4",children:[s?.user&&(0,b.jsxs)("section",{className:"space-y-2",children:[(0,b.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:"Account"}),(0,b.jsxs)("div",{className:"flex items-center justify-between rounded-md border border-border bg-muted/40 p-3",children:[(0,b.jsxs)("div",{className:"text-sm min-w-0",children:[(0,b.jsx)("div",{className:"font-medium truncate",children:s.user.name}),(0,b.jsx)("div",{className:"text-xs text-muted-foreground truncate",children:s.user.email})]}),(0,b.jsx)("button",{type:"button",onClick:async()=>{await b0.authClient.signOut(),window.location.href="/signin"},className:"ml-2 shrink-0 text-xs px-2 py-1 rounded border border-border hover:bg-accent",children:"Sign out"})]})]}),(0,b.jsxs)("section",{className:"space-y-2",children:[(0,b.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:"Appearance"}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:"Choose the visual style. Editorial uses a printed-journal aesthetic with serif type and warm paper tones."}),(0,b.jsx)(b8,{})]}),(0,b.jsxs)("section",{className:"space-y-2",children:[(0,b.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:"Lab"}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:"Experimental reading features. Toggle each on or off. Saved on this device."}),(0,b.jsx)(b7,{})]}),(0,b.jsxs)("section",{className:"space-y-2",children:[(0,b.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:"Signup allowlist"}),(0,b.jsxs)("p",{className:"text-xs leading-relaxed text-muted-foreground",children:["Control who can create an account. Leave both lists empty to allow any email. Saving here overrides the"," ",(0,b.jsx)("code",{className:"bg-muted px-0.5 rounded",children:"AUTH_ALLOWED_EMAILS"})," ","and"," ",(0,b.jsx)("code",{className:"bg-muted px-0.5 rounded",children:"AUTH_ALLOWED_DOMAIN"})," ","environment variables."]}),"env"===k&&(0,b.jsxs)("div",{className:"flex items-start gap-2 rounded-md bg-muted px-3 py-2 text-xs text-muted-foreground",children:[(0,b.jsx)(c.AlertCircle,{className:"h-3.5 w-3.5 shrink-0 mt-0.5"}),(0,b.jsx)("span",{children:"Current values come from environment variables. Saving moves the allowlist into config and takes precedence going forward."})]}),(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)("label",{htmlFor:"allowed-emails",className:"text-sm font-medium",children:"Allowed emails"}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:"One per line (or comma-separated). Exact match, case-insensitive."}),(0,b.jsx)("textarea",{id:"allowed-emails",value:m,onChange:a=>n(a.target.value),spellCheck:!1,rows:5,placeholder:"alice@example.com bob@example.com",className:"w-full resize-y rounded-md border border-border bg-background px-3 py-2 font-mono text-sm outline-none focus:ring-2 focus:ring-primary"})]}),(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)("label",{htmlFor:"allowed-domains",className:"text-sm font-medium",children:"Allowed domains"}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:"One per line (or comma-separated). Matches any email at that domain."}),(0,b.jsx)("textarea",{id:"allowed-domains",value:o,onChange:a=>p(a.target.value),spellCheck:!1,rows:4,placeholder:"example.com trusted.org",className:"w-full resize-y rounded-md border border-border bg-background px-3 py-2 font-mono text-sm outline-none focus:ring-2 focus:ring-primary"})]}),P&&(0,b.jsxs)("div",{className:"flex items-start gap-2 rounded-md bg-warning-soft px-3 py-2 text-xs text-warning-ink",children:[(0,b.jsx)(c.AlertCircle,{className:"h-3.5 w-3.5 shrink-0 mt-0.5"}),(0,b.jsx)("span",{children:"Both lists are empty. Anyone with the signup URL can create an account."})]}),i&&(0,b.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-destructive",children:[(0,b.jsx)(c.AlertCircle,{className:"h-3.5 w-3.5 shrink-0"}),i]})]}),t&&(0,b.jsxs)("section",{className:"space-y-2",children:[(0,b.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:"Admins"}),(0,b.jsx)("p",{className:"text-xs leading-relaxed text-muted-foreground",children:"Admins can create workspaces, add users, and manage access."}),A&&(0,b.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-destructive",children:[(0,b.jsx)(c.AlertCircle,{className:"h-3.5 w-3.5 shrink-0"}),A]}),(0,b.jsxs)("div",{className:"space-y-2 rounded-md border border-border p-3",children:[(0,b.jsx)("div",{className:"text-xs font-medium",children:"Add user"}),K?(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Created ",(0,b.jsx)("span",{className:"font-medium text-foreground",children:K.email}),". Share this temporary password now, it will not be shown again."]}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("code",{className:"flex-1 rounded bg-muted px-2 py-1.5 font-mono text-sm select-all",children:K.tempPassword}),(0,b.jsx)("button",{type:"button",className:"shrink-0 text-xs px-2 py-1 rounded border border-border hover:bg-accent",onClick:()=>void navigator.clipboard?.writeText(K.tempPassword),children:"Copy"})]}),(0,b.jsx)("button",{type:"button",className:"text-xs text-muted-foreground hover:text-foreground",onClick:()=>{L(null),F(""),H(""),M()},children:"Done"})]}):(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)("input",{type:"email",value:E,onChange:a=>F(a.target.value),placeholder:"email@team.com",className:"w-full rounded-md border border-border bg-background px-2 py-1.5 text-sm outline-none focus:ring-2 focus:ring-primary"}),(0,b.jsx)("input",{type:"text",value:G,onChange:a=>H(a.target.value),placeholder:"Name (optional)",className:"w-full rounded-md border border-border bg-background px-2 py-1.5 text-sm outline-none focus:ring-2 focus:ring-primary"}),(0,b.jsxs)(U.Button,{size:"sm",className:"w-full gap-1.5",disabled:I||!E.trim(),onClick:async()=>{J(!0),B(null);try{let a=await fetch("/api/system/users",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:E.trim(),name:G.trim()})}),b=await a.json();a.ok&&b.tempPassword?L({email:b.email??E.trim(),tempPassword:b.tempPassword}):B(b.message??b.error??"Failed to create user")}catch{B("Network error")}finally{J(!1)}},children:[I&&(0,b.jsx)(z.Loader2,{className:"h-3.5 w-3.5 animate-spin"}),"Create user"]})]})]}),(0,b.jsxs)("div",{className:"space-y-1 rounded-md border border-border overflow-hidden",children:[x.map(a=>{let c=v.includes(a.id);return(0,b.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 bg-muted/40 hover:bg-muted/60 transition-colors",children:[(0,b.jsxs)("div",{className:"text-sm min-w-0",children:[(0,b.jsx)("div",{className:"font-medium truncate",children:a.name}),(0,b.jsx)("div",{className:"text-xs text-muted-foreground truncate",children:a.email})]}),(0,b.jsx)("button",{type:"button",disabled:C===a.id,className:"ml-2 shrink-0 text-xs px-2 py-1 rounded border border-border hover:bg-accent disabled:opacity-50",onClick:async()=>{D(a.id),B(null);try{let b=await fetch("/api/system/admins",{method:c?"DELETE":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:a.id})}),d=await b.json();b.ok?d.admins&&w(d.admins):B(d.message??d.error??"Failed")}catch{B("Network error")}finally{D(null)}},children:C===a.id?(0,b.jsx)(z.Loader2,{className:"h-3 w-3 animate-spin"}):c?"Demote":"Promote"})]},a.id)}),0===x.length&&(0,b.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No users yet."})]})]}),(0,b.jsxs)("section",{className:"space-y-2",children:[(0,b.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:"Agent rate limit"}),(0,b.jsxs)("div",{className:"rounded-md border border-border bg-muted/40 p-3 space-y-1.5",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between text-xs",children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:"Per agent"}),(0,b.jsx)("span",{className:"font-mono",children:null!==q?`${q} ops/min`:"--"})]}),(0,b.jsxs)("p",{className:"text-[10px] text-muted-foreground/60",children:["Override with ",(0,b.jsx)("code",{className:"bg-muted px-0.5 rounded",children:"AGENT_RATE_LIMIT"})," env var."]})]})]})]}),(0,b.jsxs)("div",{className:"flex items-center justify-end gap-2 border-t border-border px-4 py-3 shrink-0",children:[(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",onClick:()=>d(!1),disabled:g,children:"Cancel"}),(0,b.jsxs)(U.Button,{size:"sm",onClick:O,disabled:g||e,className:"gap-1.5",children:[g&&(0,b.jsx)(z.Loader2,{className:"h-3.5 w-3.5 animate-spin"}),"Save"]})]})]})})}var ca=a.i(237407);let cb=(0,d.default)("clock",[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);var cc=a.i(866718),cd=a.i(559653),ce=a.i(268189),cf=a.i(484694),cg=a.i(483370),ch=a.i(866394),ci=a.i(558036),cj="Switch",[ck,cl]=(0,cf.createContextScope)(cj),[cm,cn]=ck(cj),co=T.forwardRef((a,c)=>{let{__scopeSwitch:d,name:e,checked:f,defaultChecked:g,required:h,disabled:i,value:j="on",onCheckedChange:k,form:l,...m}=a,[n,o]=T.useState(null),p=(0,ce.useComposedRefs)(c,a=>o(a)),q=T.useRef(!1),r=!n||l||!!n.closest("form"),[s,t]=(0,cg.useControllableState)({prop:f,defaultProp:g??!1,onChange:k,caller:cj});return(0,b.jsxs)(cm,{scope:d,checked:s,disabled:i,children:[(0,b.jsx)(ci.Primitive.button,{type:"button",role:"switch","aria-checked":s,"aria-required":h,"data-state":cs(s),"data-disabled":i?"":void 0,disabled:i,value:j,...m,ref:p,onClick:(0,cd.composeEventHandlers)(a.onClick,a=>{t(a=>!a),r&&(q.current=a.isPropagationStopped(),q.current||a.stopPropagation())})}),r&&(0,b.jsx)(cr,{control:n,bubbles:!q.current,name:e,value:j,checked:s,required:h,disabled:i,form:l,style:{transform:"translateX(-100%)"}})]})});co.displayName=cj;var cp="SwitchThumb",cq=T.forwardRef((a,c)=>{let{__scopeSwitch:d,...e}=a,f=cn(cp,d);return(0,b.jsx)(ci.Primitive.span,{"data-state":cs(f.checked),"data-disabled":f.disabled?"":void 0,...e,ref:c})});cq.displayName=cp;var cr=T.forwardRef(({__scopeSwitch:a,control:c,checked:d,bubbles:e=!0,...f},g)=>{let h,i=T.useRef(null),j=(0,ce.useComposedRefs)(i,g),k=(h=T.useRef({value:d,previous:d}),T.useMemo(()=>(h.current.value!==d&&(h.current.previous=h.current.value,h.current.value=d),h.current.previous),[d])),l=(0,ch.useSize)(c);return T.useEffect(()=>{let a=i.current;if(!a)return;let b=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"checked").set;if(k!==d&&b){let c=new Event("click",{bubbles:e});b.call(a,d),a.dispatchEvent(c)}},[k,d,e]),(0,b.jsx)("input",{type:"checkbox","aria-hidden":!0,defaultChecked:d,...f,tabIndex:-1,ref:j,style:{...f.style,...l,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});function cs(a){return a?"checked":"unchecked"}function ct({className:a,...c}){return(0,b.jsx)(co,{"data-slot":"switch",className:(0,Z.cn)("peer data-[state=checked]:bg-[var(--switch-checked)] data-[state=unchecked]:bg-input inline-flex h-5 w-9 shrink-0 items-center rounded-sm border-2 border-transparent shadow-e-1 transition-all outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 cursor-pointer",a),...c,children:(0,b.jsx)(cq,{"data-slot":"switch-thumb",className:"bg-background pointer-events-none block size-4 rounded-sm shadow-e-1 ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0"})})}cr.displayName="SwitchBubbleInput";var cu=a.i(870430);function cv({open:a,onOpenChange:c,filePath:d}){let[e,g]=(0,T.useState)([]),[h,j]=(0,T.useState)(!0),[k,l]=(0,T.useState)(!1),[m,n]=(0,T.useState)(""),[o,p]=(0,T.useState)(!1),[q,r]=(0,T.useState)(!1),[s,t]=(0,T.useState)("7"),[v,w]=(0,T.useState)(null),x=(0,T.useCallback)(async()=>{j(!0);try{let a=await (0,Y.wsFetch)(`/api/share?path=${encodeURIComponent(d)}`);if(a.ok){let b=await a.json();g(b.shares??[])}}catch{}j(!1)},[d]);(0,T.useEffect)(()=>{a&&x()},[a,x]);let y=async()=>{l(!0);try{let a={path:d};if(o&&m.trim()&&(a.password=m.trim()),q&&s){let b=new Date;b.setDate(b.getDate()+Number(s)),a.expiresAt=b.toISOString()}let b=await (0,Y.wsFetch)("/api/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!b.ok){let a=await b.json();(0,b_.showError)(a.error??"Failed to create share link");return}(0,b_.showSuccess)("Share link created"),n(""),p(!1),r(!1),t("7"),await x()}catch{(0,b_.showError)("Failed to create share link")}finally{l(!1)}},A=async a=>{try{if(!(await fetch(`/api/share/${a}`,{method:"DELETE"})).ok)return void(0,b_.showError)("Failed to revoke share link");(0,b_.showSuccess)("Share link revoked"),await x()}catch{(0,b_.showError)("Failed to revoke share link")}};return(0,b.jsx)(V.Dialog,{open:a,onOpenChange:c,children:(0,b.jsxs)(V.DialogContent,{className:"sm:max-w-md",children:[(0,b.jsxs)(V.DialogHeader,{children:[(0,b.jsx)(V.DialogTitle,{children:"Share document"}),(0,b.jsx)(V.DialogDescription,{children:"Create a public link to share this document as read-only."})]}),(0,b.jsxs)("div",{className:"space-y-4",children:[(0,b.jsxs)("div",{className:"rounded-sm border border-border p-3 space-y-3",children:[(0,b.jsx)("h3",{className:"text-sm font-medium",children:"New share link"}),(0,b.jsxs)("div",{className:"flex items-center justify-between",children:[(0,b.jsxs)(cu.Label,{htmlFor:"share-pwd",className:"text-xs gap-1.5 flex items-center",children:[(0,b.jsx)(ca.Lock,{className:"h-3 w-3 text-muted-foreground"}),"Password protect"]}),(0,b.jsx)(ct,{id:"share-pwd",checked:o,onCheckedChange:p})]}),o&&(0,b.jsx)(cc.Input,{type:"password",placeholder:"Set a password",value:m,onChange:a=>n(a.target.value)}),(0,b.jsxs)("div",{className:"flex items-center justify-between",children:[(0,b.jsxs)(cu.Label,{htmlFor:"share-expiry",className:"text-xs gap-1.5 flex items-center",children:[(0,b.jsx)(cb,{className:"h-3 w-3 text-muted-foreground"}),"Set expiration"]}),(0,b.jsx)(ct,{id:"share-expiry",checked:q,onCheckedChange:r})]}),q&&(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)(cc.Input,{type:"number",min:1,max:365,value:s,onChange:a=>t(a.target.value),className:"w-20"}),(0,b.jsx)("span",{className:"text-xs text-muted-foreground",children:"days"})]}),(0,b.jsxs)(U.Button,{size:"sm",className:"w-full gap-1.5",onClick:y,disabled:k,children:[k?(0,b.jsx)(z.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):(0,b.jsx)(u.Globe,{className:"h-3.5 w-3.5"}),"Create link"]})]}),(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)("h3",{className:"text-xs font-medium text-muted-foreground",children:e.length>0?`Active links (${e.length})`:h?"Loading...":"No active links"}),h&&(0,b.jsx)("div",{className:"flex justify-center py-2",children:(0,b.jsx)(z.Loader2,{className:"h-4 w-4 animate-spin text-muted-foreground"})}),e.map(a=>(0,b.jsxs)("div",{className:"flex items-center gap-2 rounded-sm border border-border p-2",children:[(0,b.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,b.jsx)("div",{className:"flex items-center gap-1.5",children:(0,b.jsxs)("span",{className:"text-xs font-mono truncate",children:[window.location.origin,"/s/",a.token]})}),(0,b.jsxs)("div",{className:"flex items-center gap-2 mt-0.5",children:[a.hasPassword&&(0,b.jsxs)("span",{className:"flex items-center gap-0.5 text-[10px] text-muted-foreground",children:[(0,b.jsx)(ca.Lock,{className:"h-2.5 w-2.5"}),"pwd"]}),a.expiresAt&&(0,b.jsxs)("span",{className:"flex items-center gap-0.5 text-[10px] text-muted-foreground",children:[(0,b.jsx)(cb,{className:"h-2.5 w-2.5"}),function(a){let b=new Date(a),c=new Date,d=b.getTime()-c.getTime();if(d<=0)return"expired";let e=Math.floor(d/864e5),f=Math.floor(d%864e5/36e5);return e>0?`${e}d`:f>0?`${f}h`:"<1h"}(a.expiresAt)]}),(0,b.jsxs)("span",{className:"text-[10px] text-muted-foreground",children:[a.viewCount," view",1!==a.viewCount?"s":""]}),a.isExpired&&(0,b.jsx)("span",{className:"text-[10px] text-destructive",children:"expired"})]})]}),(0,b.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Copy link",onClick:()=>{var b,c;let d;return b=a.url,c=a.token,d=`${window.location.origin}${b}`,void(navigator.clipboard.writeText(d),w(c),setTimeout(()=>w(null),2e3))},children:v===a.token?(0,b.jsx)(f.Check,{className:"h-3.5 w-3.5 text-success"}):(0,b.jsx)(i.Copy,{className:"h-3.5 w-3.5"})}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0 text-destructive hover:text-destructive",title:"Revoke link",onClick:()=>A(a.token),children:(0,b.jsx)(Q.Trash2,{className:"h-3.5 w-3.5"})})]})]},a.id))]})]})]})})}var cw=a.i(591119),cx=a.i(280370),cy=a.i(385909),cz="ContextMenu",[cA,cB]=(0,cf.createContextScope)(cz,[cx.createMenuScope]),cC=(0,cx.createMenuScope)(),[cD,cE]=cA(cz),cF=a=>{let{__scopeContextMenu:c,children:d,onOpenChange:e,dir:f,modal:g=!0}=a,[h,i]=T.useState(!1),j=cC(c),k=(0,cy.useCallbackRef)(e),l=T.useCallback(a=>{i(a),k(a)},[k]);return(0,b.jsx)(cD,{scope:c,open:h,onOpenChange:l,modal:g,children:(0,b.jsx)(cx.Root,{...j,dir:f,open:h,onOpenChange:l,modal:g,children:d})})};cF.displayName=cz;var cG="ContextMenuTrigger",cH=T.forwardRef((a,c)=>{let{__scopeContextMenu:d,disabled:e=!1,...f}=a,g=cE(cG,d),h=cC(d),i=T.useRef({x:0,y:0}),j=T.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...i.current})}),k=T.useRef(0),l=T.useCallback(()=>window.clearTimeout(k.current),[]),m=a=>{i.current={x:a.clientX,y:a.clientY},g.onOpenChange(!0)};return T.useEffect(()=>l,[l]),T.useEffect(()=>void(e&&l()),[e,l]),(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(cx.Anchor,{...h,virtualRef:j}),(0,b.jsx)(ci.Primitive.span,{"data-state":g.open?"open":"closed","data-disabled":e?"":void 0,...f,ref:c,style:{WebkitTouchCallout:"none",...a.style},onContextMenu:e?a.onContextMenu:(0,cd.composeEventHandlers)(a.onContextMenu,a=>{l(),m(a),a.preventDefault()}),onPointerDown:e?a.onPointerDown:(0,cd.composeEventHandlers)(a.onPointerDown,cT(a=>{l(),k.current=window.setTimeout(()=>m(a),700)})),onPointerMove:e?a.onPointerMove:(0,cd.composeEventHandlers)(a.onPointerMove,cT(l)),onPointerCancel:e?a.onPointerCancel:(0,cd.composeEventHandlers)(a.onPointerCancel,cT(l)),onPointerUp:e?a.onPointerUp:(0,cd.composeEventHandlers)(a.onPointerUp,cT(l))})]})});cH.displayName=cG;var cI=a=>{let{__scopeContextMenu:c,...d}=a,e=cC(c);return(0,b.jsx)(cx.Portal,{...e,...d})};cI.displayName="ContextMenuPortal";var cJ="ContextMenuContent",cK=T.forwardRef((a,c)=>{let{__scopeContextMenu:d,...e}=a,f=cE(cJ,d),g=cC(d),h=T.useRef(!1);return(0,b.jsx)(cx.Content,{...g,...e,ref:c,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:b=>{a.onCloseAutoFocus?.(b),!b.defaultPrevented&&h.current&&b.preventDefault(),h.current=!1},onInteractOutside:b=>{a.onInteractOutside?.(b),b.defaultPrevented||f.modal||(h.current=!0)},style:{...a.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});cK.displayName=cJ,T.forwardRef((a,c)=>{let{__scopeContextMenu:d,...e}=a,f=cC(d);return(0,b.jsx)(cx.Group,{...f,...e,ref:c})}).displayName="ContextMenuGroup";var cL=T.forwardRef((a,c)=>{let{__scopeContextMenu:d,...e}=a,f=cC(d);return(0,b.jsx)(cx.Label,{...f,...e,ref:c})});cL.displayName="ContextMenuLabel";var cM=T.forwardRef((a,c)=>{let{__scopeContextMenu:d,...e}=a,f=cC(d);return(0,b.jsx)(cx.Item,{...f,...e,ref:c})});cM.displayName="ContextMenuItem";var cN=T.forwardRef((a,c)=>{let{__scopeContextMenu:d,...e}=a,f=cC(d);return(0,b.jsx)(cx.CheckboxItem,{...f,...e,ref:c})});cN.displayName="ContextMenuCheckboxItem",T.forwardRef((a,c)=>{let{__scopeContextMenu:d,...e}=a,f=cC(d);return(0,b.jsx)(cx.RadioGroup,{...f,...e,ref:c})}).displayName="ContextMenuRadioGroup";var cO=T.forwardRef((a,c)=>{let{__scopeContextMenu:d,...e}=a,f=cC(d);return(0,b.jsx)(cx.RadioItem,{...f,...e,ref:c})});cO.displayName="ContextMenuRadioItem";var cP=T.forwardRef((a,c)=>{let{__scopeContextMenu:d,...e}=a,f=cC(d);return(0,b.jsx)(cx.ItemIndicator,{...f,...e,ref:c})});cP.displayName="ContextMenuItemIndicator";var cQ=T.forwardRef((a,c)=>{let{__scopeContextMenu:d,...e}=a,f=cC(d);return(0,b.jsx)(cx.Separator,{...f,...e,ref:c})});cQ.displayName="ContextMenuSeparator",T.forwardRef((a,c)=>{let{__scopeContextMenu:d,...e}=a,f=cC(d);return(0,b.jsx)(cx.Arrow,{...f,...e,ref:c})}).displayName="ContextMenuArrow";var cR=T.forwardRef((a,c)=>{let{__scopeContextMenu:d,...e}=a,f=cC(d);return(0,b.jsx)(cx.SubTrigger,{...f,...e,ref:c})});cR.displayName="ContextMenuSubTrigger";var cS=T.forwardRef((a,c)=>{let{__scopeContextMenu:d,...e}=a,f=cC(d);return(0,b.jsx)(cx.SubContent,{...f,...e,ref:c,style:{...a.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});function cT(a){return b=>"mouse"!==b.pointerType?a(b):void 0}cS.displayName="ContextMenuSubContent";var cU=a.i(694079);T.forwardRef(({className:a,inset:c,children:d,...e},f)=>(0,b.jsxs)(cR,{ref:f,className:(0,Z.cn)("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",c&&"pl-8",a),...e,children:[d,(0,b.jsx)(h.ChevronRight,{className:"ml-auto h-4 w-4"})]})).displayName=cR.displayName,T.forwardRef(({className:a,...c},d)=>(0,b.jsx)(cS,{ref:d,className:(0,Z.cn)("z-50 min-w-[8rem] overflow-hidden rounded-sm border bg-popover p-1 text-popover-foreground shadow-golden data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a),...c})).displayName=cS.displayName;let cV=T.forwardRef(({className:a,...c},d)=>(0,b.jsx)(cI,{children:(0,b.jsx)(cK,{ref:d,className:(0,Z.cn)("z-50 min-w-[8rem] overflow-hidden rounded-sm border bg-popover p-1 text-popover-foreground shadow-golden data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a),...c})}));cV.displayName=cK.displayName;let cW=T.forwardRef(({className:a,inset:c,...d},e)=>(0,b.jsx)(cM,{ref:e,className:(0,Z.cn)("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",c&&"pl-8",a),...d}));cW.displayName=cM.displayName,T.forwardRef(({className:a,children:c,checked:d,...e},g)=>(0,b.jsxs)(cN,{ref:g,className:(0,Z.cn)("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a),checked:d,...e,children:[(0,b.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,b.jsx)(cP,{children:(0,b.jsx)(f.Check,{className:"h-4 w-4"})})}),c]})).displayName=cN.displayName,T.forwardRef(({className:a,children:c,...d},e)=>(0,b.jsxs)(cO,{ref:e,className:(0,Z.cn)("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a),...d,children:[(0,b.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,b.jsx)(cP,{children:(0,b.jsx)(cU.Circle,{className:"h-2 w-2 fill-current"})})}),c]})).displayName=cO.displayName,T.forwardRef(({className:a,inset:c,...d},e)=>(0,b.jsx)(cL,{ref:e,className:(0,Z.cn)("px-2 py-1.5 text-sm font-normal",c&&"pl-8",a),...d})).displayName=cL.displayName;let cX=T.forwardRef(({className:a,...c},d)=>(0,b.jsx)(cQ,{ref:d,className:(0,Z.cn)("-mx-1 my-1 h-px bg-muted",a),...c}));cX.displayName=cQ.displayName;let cY=(0,b1.create)(a=>({recents:[],loadForWorkspace:b=>{a({recents:[]})},push:(b,c)=>{let d=[].filter(a=>a.path!==b.path);a({recents:[b,...d].slice(0,15)})}})),cZ=(0,b1.create)((a,b)=>({pins:[],loadForWorkspace:b=>{a({pins:[]})},toggle:(b,c)=>{let d=[];a({pins:d.some(a=>a.path===b.path)?d.filter(a=>a.path!==b.path):[...d,b]})},isPinned:a=>b().pins.some(b=>b.path===a)})),c$=(0,d.default)("wifi",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]);var c_=a.i(764841);let c0=(0,d.default)("circle-check-big",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]),c1=(0,d.default)("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);var c2=a.i(263265);function c3(a){let b=Date.now()-new Date(a).getTime();return b<6e4?"just now":b<36e5?`${Math.floor(b/6e4)}m ago`:b<864e5?`${Math.floor(b/36e5)}h ago`:`${Math.floor(b/864e5)}d ago`}function c4({scope:a}){return(0,b.jsxs)("span",{className:"text-[10px] text-muted-foreground/70 font-mono",children:[a.paths.join(", ")," · ",a.ops.join(",")]})}function c5({reg:a,onApprove:c,onDeny:d}){let[e,f]=(0,T.useState)(!1);async function g(b){f(!0);try{await b(a.registrationId)}finally{f(!1)}}return(0,b.jsxs)("li",{className:"py-1.5 border-b border-border/40 last:border-0",children:[(0,b.jsxs)("div",{className:"flex items-start justify-between gap-1",children:[(0,b.jsxs)("div",{className:"min-w-0",children:[(0,b.jsx)("p",{className:"text-xs font-mono truncate",children:a.displayName}),(0,b.jsx)("p",{className:"text-[10px] text-muted-foreground/60 truncate",children:a.agentId}),(0,b.jsx)(c4,{scope:a.requestedScope})]}),(0,b.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,b.jsxs)(U.Button,{size:"sm",variant:"default",className:"h-6 px-2 text-[10px]",disabled:e,onClick:()=>void g(c),title:"Approve",children:[(0,b.jsx)(c0,{className:"h-3 w-3 mr-0.5"}),"Approve"]}),(0,b.jsxs)(U.Button,{size:"sm",variant:"ghost",className:"h-6 px-2 text-[10px] text-destructive hover:text-destructive",disabled:e,onClick:()=>void g(d),title:"Deny",children:[(0,b.jsx)(c1,{className:"h-3 w-3 mr-0.5"}),"Deny"]})]})]}),(0,b.jsxs)("p",{className:"text-[10px] text-muted-foreground/50 mt-0.5",children:["Requested ",c3(a.requestedAt)]})]})}function c6({agent:a,onRevoke:c}){let[d,e]=(0,T.useState)(!1);return(0,b.jsxs)("li",{className:"py-1.5 border-b border-border/40 last:border-0",children:[(0,b.jsxs)("div",{className:"flex items-start justify-between gap-1",children:[(0,b.jsxs)("div",{className:"min-w-0",children:[(0,b.jsx)("p",{className:"text-xs font-mono truncate",children:a.displayName}),(0,b.jsx)("p",{className:"text-[10px] text-muted-foreground/60 truncate",children:a.id}),(0,b.jsx)(c4,{scope:a.scope})]}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 shrink-0 text-destructive hover:text-destructive",disabled:d,onClick:async()=>{e(!0);try{await c(a.id)}finally{e(!1)}},title:"Revoke agent",children:(0,b.jsx)(Q.Trash2,{className:"h-3 w-3"})})]}),(0,b.jsxs)("p",{className:"text-[10px] text-muted-foreground/50 mt-0.5",children:["Last seen ",c3(a.lastSeen)]})]})}function c7(){let[a,c]=(0,T.useState)([]),[d,e]=(0,T.useState)([]),[f,g]=(0,T.useState)(!1);(0,T.useEffect)(()=>{fetch("/api/owner/init",{credentials:"same-origin"}).then(a=>{(a.ok||204===a.status)&&g(!0)}).catch(()=>{g(!0)})},[]);let h=(0,T.useCallback)(async()=>{try{let a=await fetch("/api/agent/admin/registrations",{credentials:"same-origin"});if(!a.ok)return;let b=await a.json();c(b.pending)}catch{}},[]),i=(0,T.useCallback)(async()=>{try{let a=await fetch("/api/agent/admin/agents",{credentials:"same-origin"});if(!a.ok)return;let b=await a.json();e(b.agents)}catch{}},[]);(0,T.useEffect)(()=>{if(!f)return;h(),i();let a=setInterval(()=>void h(),5e3),b=setInterval(()=>void i(),3e4);return()=>{clearInterval(a),clearInterval(b)}},[f,h,i]);let j=(0,T.useCallback)(async a=>{(await fetch(`/api/agent/admin/registrations/${a}/approve`,{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json"},body:"{}"})).ok?(c2.toast.success("Agent approved"),await Promise.all([h(),i()])):c2.toast.error("Failed to approve agent")},[h,i]),k=(0,T.useCallback)(async a=>{(await fetch(`/api/agent/admin/registrations/${a}/deny`,{method:"POST",credentials:"same-origin"})).ok?(c2.toast.success("Registration denied"),await h()):c2.toast.error("Failed to deny registration")},[h]),l=(0,T.useCallback)(async a=>{(await fetch(`/api/agent/admin/agents/${encodeURIComponent(a)}/revoke`,{method:"POST",credentials:"same-origin"})).ok?(c2.toast.success("Agent revoked"),await i()):c2.toast.error("Failed to revoke agent")},[i]);return(0,b.jsxs)("section",{className:"space-y-2",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between",children:[(0,b.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:"Agents · approve & manage access"}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-5 w-5 p-0",title:"Refresh",onClick:()=>void Promise.all([h(),i()]),children:(0,b.jsx)(K,{className:"h-3 w-3"})})]}),a.length>0&&(0,b.jsxs)("div",{className:"rounded-md border border-amber-500/40 bg-amber-50/10 p-2",children:[(0,b.jsxs)("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-amber-600/80 mb-1 flex items-center gap-1",children:[(0,b.jsx)(cb,{className:"h-3 w-3"}),"Waiting for your approval (",a.length,")"]}),(0,b.jsx)("ul",{children:a.map(a=>(0,b.jsx)(c5,{reg:a,onApprove:j,onDeny:k},a.registrationId))})]}),(0,b.jsx)("div",{className:"rounded-md border border-border bg-muted/40 p-2",children:0===d.length?(0,b.jsxs)("p",{className:"text-xs text-muted-foreground/60 py-1",children:["No assistants connected yet."," ",(0,b.jsx)("span",{className:"text-muted-foreground/40",children:"Connect one above; once it requests access it’ll appear here for you to approve."})]}):(0,b.jsx)("ul",{children:d.map(a=>(0,b.jsx)(c6,{agent:a,onRevoke:l},a.id))})}),(0,b.jsx)("p",{className:"text-[10px] text-muted-foreground/60 leading-relaxed",children:"Each assistant gets its own access that you can revoke anytime. New requests appear above for your approval before they can read or edit anything."})]})}var c8=a.i(569707);function c9(a){let b=Math.max(0,Math.round((Date.now()-new Date(a).getTime())/1e3));if(b<45)return"just now";let c=b,d="second";for(let[a,b]of[[60,"second"],[60,"minute"],[24,"hour"],[7,"day"]]){if(c<a)break;c=Math.floor(c/a),d=b}return new Intl.RelativeTimeFormat("en",{numeric:"always",style:"short"}).format(-c,d).replace(/\s+/g," ").replace(/\./g,"")}async function da(a){if(!/\.(md|markdown)$/i.test(a))return 0;for(let b of[`/api/agent/sidecar/${a}`,`/api/agent/files/${a}/pending`,`/api/agent/files/${a}`])try{let a=await (0,Y.wsFetch)(b);if(!a.ok)continue;let c=await a.json();if(Array.isArray(c.pending))return c.pending.length;if(Array.isArray(c.events)&&b.includes("/pending"))return c.events.length;if("number"==typeof c.pendingCount)return c.pendingCount;if("number"==typeof c.count)return c.count;if("number"==typeof c.total)return c.total;if(Array.isArray(c.suggestions)||Array.isArray(c.comments)||c.blockProvenance){let a=Array.isArray(c.suggestions)?c.suggestions.filter(a=>a&&"object"==typeof a&&"pending"===a.status).length:0,b=Array.isArray(c.comments)?c.comments.filter(a=>a&&"object"==typeof a&&!a.resolved).length:0,d=c.blockProvenance&&"object"==typeof c.blockProvenance?Object.keys(c.blockProvenance).length:0;return a+b+d}}catch{}return 0}let db=(0,T.memo)(function({event:a}){var c,d;let e,f,g,h,i;return(0,b.jsxs)("div",{className:"flex items-start gap-2.5 rounded-md px-2 py-2 hover:bg-background/50",children:[(0,b.jsx)("div",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-[10px] font-semibold shadow-sm ring-1 ring-black/5",style:(e=function(a){let b=0;for(let c=0;c<a.length;c+=1)b=31*b+a.charCodeAt(c)|0;return Math.abs(b)}(a.by)%360,{backgroundColor:`hsl(${e} 72% 42%)`,color:"white"}),title:a.by,"aria-hidden":!0,children:((f=(c=a.by).split(/[:/]/).pop()??c).replace(/[^a-z0-9]/gi,"").slice(0,2)||f.slice(0,2)||"??").toUpperCase()}),(0,b.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,b.jsx)("p",{className:"truncate text-xs text-foreground/85",children:(g=((d=a.by).split(/[:/]/).pop()??d).replace(/[-_]+/g," ").replace(/^./,a=>a.toUpperCase()),h=a.type,i=Array.isArray(a.refs)?(a.refs??[]).length:+("string"==typeof a.ref),"block.append"===h||"block.inserted"===h&&"end"===a.position?`${g} appended ${i||1} block${1===(i||1)?"":"s"}`:"block.prepend"===h||"block.inserted"===h&&"start"===a.position?`${g} prepended ${i||1} block${1===(i||1)?"":"s"}`:"block.inserted"===h?`${g} inserted ${i||1} block${1===(i||1)?"":"s"}`:"block.replaced"===h||"file.rawWritten"===h?`${g} edited`:"block.deleted"===h?`${g} deleted ${i||1} block${1===(i||1)?"":"s"}`:"suggestion.added"===h?`${g} suggested a change`:"suggestion.accepted"===h?`${g} accepted a suggestion`:"suggestion.rejected"===h?`${g} rejected a suggestion`:"comment.added"===h?`${g} commented`:"comment.replied"===h?`${g} replied`:"comment.resolved"===h?`${g} resolved a comment`:"comment.reopened"===h?`${g} reopened a comment`:"file.externallyEdited"===h?`${g} changed file externally`:`${g} ${h.replace(/^\w+\./,"").replace(/([a-z])([A-Z])/g,"$1 $2")}`)}),(0,b.jsx)("p",{className:"truncate text-[10px] text-muted-foreground",children:c9(a.at)})]})]})});function dc({group:a,reviewCount:c}){let d=(0,c8.useEditorStore)(a=>a.loadPage),e=a.events[0];return(0,b.jsxs)("section",{className:"space-y-1.5 rounded-md border border-border/70 bg-background/50 p-2",children:[(0,b.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,b.jsxs)("button",{type:"button",onClick:()=>void d(a.path),className:"min-w-0 text-left",title:a.path,children:[(0,b.jsx)("p",{className:"truncate text-xs font-medium text-foreground/90",children:a.filename}),(0,b.jsx)("p",{className:"truncate text-[10px] text-muted-foreground",children:a.path})]}),(0,b.jsxs)("div",{className:"flex shrink-0 items-center gap-1.5",children:[c>0&&(0,b.jsxs)("button",{type:"button",onClick:()=>void d(a.path),className:"inline-flex items-center rounded-full border border-amber-500/40 bg-amber-500/10 px-2 py-0.5 text-[10px] font-medium text-amber-700 hover:bg-amber-500/15",title:"Open file for review",children:["review ",c]}),(0,b.jsx)("span",{className:"text-[10px] text-muted-foreground",children:c9(e.at)})]})]}),(0,b.jsx)("div",{className:"space-y-0.5",children:a.events.map(a=>(0,b.jsx)(db,{event:a},`${a.path}-${a.id}`))})]})}function dd({activity:a}){let c=(0,T.useMemo)(()=>(function(a){let b=new Map;for(let c of a){let a=b.get(c.path)??[];a.push(c),b.set(c.path,a)}return Array.from(b.entries()).map(([a,b])=>({path:a,filename:a.split("/").pop()??a,latestAt:b[0]?.at??"",events:b})).sort((a,b)=>a.latestAt<b.latestAt?1:-1)})(a),[a]),[d,e]=(0,T.useState)({});return((0,T.useEffect)(()=>{let a=!1,b=Array.from(new Set(c.map(a=>a.path)));return 0===b.length?(e({}),()=>{a=!0}):((async()=>{let c=await Promise.all(b.map(async a=>[a,await da(a)]));a||e(Object.fromEntries(c.filter(([,a])=>a>0)))})(),()=>{a=!0})},[c]),0===c.length)?(0,b.jsx)("p",{className:"py-2 text-xs text-muted-foreground/60",children:"No events recorded"}):(0,b.jsx)("div",{className:"space-y-2",children:c.map(a=>(0,b.jsx)(dc,{group:a,reviewCount:d[a.path]??0},a.path))})}let de="npx skills add anh-chu/wiki-viewer/agents/wiki-viewer-skill";function df(a){let[b,c]=(0,T.useState)(!1);return{copied:b,copy:(0,T.useCallback)(async()=>{await navigator.clipboard.writeText(a()),c(!0),setTimeout(()=>c(!1),1500)},[a])}}function dg({currentPath:a}){let c=(0,c_.useAIPanelStore)(a=>a.isOpen),d=(0,c_.useAIPanelStore)(a=>a.close),g=(0,c_.useAIPanelStore)(a=>a.activity),h=(0,c_.useAIPanelStore)(a=>a.connections),j=(0,c_.useAIPanelStore)(a=>a.loadActivity),{copied:k,copy:l}=function(a){let[b,c]=(0,T.useState)(!1);return{copied:b,copy:(0,T.useCallback)(async()=>{let b="http://localhost:3000",d=`# 1. Register
4
4
  REG=$(curl -s -X POST -H 'Content-Type: application/json' \\
5
5
  -d '{"id":"ai:claude","displayName":"Claude"}' \\
6
6
  ${b}/api/agent/register)
@@ -14,6 +14,6 @@ TOKEN=<paste token here>
14
14
  # 3. Read snapshot
15
15
  curl -s -H "Authorization: Bearer $TOKEN" \\
16
16
  -H "X-Agent-Id: ai:claude" \\
17
- ${b}/api/agent/files/${a??"<path/to/file.md>"}`;await navigator.clipboard.writeText(d),c(!0),setTimeout(()=>c(!1),1500)},[a])}}(a??null),[m,n]=(0,T.useState)(""),o=(0,T.useRef)(null),p="http://localhost:3000",q=(0,T.useCallback)(()=>de,[]),r=(0,T.useCallback)(()=>m.replace(/\$WIKI_URL/g,p),[m,p]),s=(0,T.useCallback)(()=>`npx wiki-viewer-mcp register --url ${p} --id ai:myagent --name "My Agent"`,[p]),t=(0,T.useCallback)(()=>JSON.stringify({servers:{"wiki-viewer":{command:"npx",args:["wiki-viewer-mcp"],env:{WIKI_VIEWER_URL:p,WIKI_VIEWER_TOKEN:"<token from register>",WIKI_VIEWER_AGENT_ID:"ai:myagent"}}}},null,2),[p]),u=df(q),v=df(r),w=df(s),x=df(t);return((0,T.useEffect)(()=>{if(c)return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a);function a(a){"Escape"===a.key&&d()}},[c,d]),(0,T.useEffect)(()=>{c&&o.current?.focus()},[c]),(0,T.useEffect)(()=>{if(!c)return;j();let a=setInterval(()=>void j(),1e4);return()=>clearInterval(a)},[c,j]),(0,T.useEffect)(()=>{c&&fetch("/api/agents/install").then(a=>a.json()).then(a=>{a.bootstrapPrompt&&n(a.bootstrapPrompt)}).catch(()=>void 0)},[c]),c)?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("div",{className:"fixed inset-0 z-40 bg-overlay backdrop-blur-[1px]",onClick:d,"aria-hidden":!0}),(0,b.jsxs)("aside",{ref:o,tabIndex:-1,role:"dialog","aria-modal":"true","aria-label":"AI Agent Panel",className:"fixed right-0 top-0 bottom-0 z-50 flex w-[90vw] max-w-sm md:w-80 flex-col border-l border-border bg-background shadow-xl outline-none",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between border-b border-border px-4 py-3 shrink-0",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)(e,{className:"h-4 w-4 text-muted-foreground"}),(0,b.jsx)("span",{className:"text-sm font-semibold",children:"AI Agent"})]}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:d,title:"Close panel (Esc)",children:(0,b.jsx)(S.X,{className:"h-3.5 w-3.5"})})]}),(0,b.jsxs)("div",{className:"flex-1 overflow-y-auto space-y-5 px-4 py-4",children:[(0,b.jsxs)("section",{className:"rounded-md border border-border bg-muted/30 p-3",children:[(0,b.jsx)("p",{className:"text-sm font-medium text-foreground",children:"Work with this wiki using AI"}),(0,b.jsxs)("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:["Connect Claude, Cursor, ChatGPT, and more. Pick by what you want — each option gives a copy-paste setup. You approve every assistant in ",(0,b.jsx)("span",{className:"font-medium text-foreground/80",children:"Agents"})," below before it gets access."]})]}),(0,b.jsxs)("section",{className:"space-y-3",children:[(0,b.jsxs)("div",{className:"rounded-md border border-border bg-muted/40 p-3 space-y-1.5",children:[(0,b.jsx)("p",{className:"text-xs font-semibold text-foreground",children:"Co-write docs with you"}),(0,b.jsx)("p",{className:"text-[10px] text-muted-foreground/70",children:"Edits arrive as suggestions with comments you accept or revert. No MCP needed."}),(0,b.jsx)(U.Button,{size:"sm",variant:"outline",className:"h-7 w-full text-xs gap-1.5",onClick:()=>void v.copy(),disabled:!m,children:v.copied?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(f.Check,{className:"h-3.5 w-3.5 text-green-500"})," Copied!"]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(i.Copy,{className:"h-3.5 w-3.5"})," Paste into any chatbot"]})}),(0,b.jsxs)("p",{className:"text-[10px] text-muted-foreground/50 pt-1",children:["Or install once so it sticks"," ",(0,b.jsx)("span",{className:"text-muted-foreground/40",children:"· Claude, OpenCode"}),":"]}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("code",{className:"flex-1 text-[10px] font-mono text-foreground/80 truncate bg-muted rounded px-1 py-0.5",children:de}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 shrink-0",title:"Copy this command",onClick:()=>void u.copy(),children:u.copied?(0,b.jsx)(f.Check,{className:"h-3.5 w-3.5 text-green-500"}):(0,b.jsx)(i.Copy,{className:"h-3.5 w-3.5"})})]})]}),(0,b.jsxs)("div",{className:"rounded-md border border-border bg-muted/40 p-3 space-y-1.5",children:[(0,b.jsxs)("p",{className:"text-xs font-semibold text-foreground",children:["Edit files directly"," ",(0,b.jsx)("span",{className:"font-normal text-muted-foreground/60",children:"· Claude Code, Cursor, Codex"})]}),(0,b.jsx)("p",{className:"text-[10px] text-muted-foreground/70",children:"Native read / search / edit tools over MCP. Run to request access:"}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("code",{className:"flex-1 text-[10px] font-mono text-foreground/80 truncate bg-muted rounded px-1 py-0.5",children:s()}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 shrink-0",title:"Copy this command",onClick:()=>void w.copy(),children:w.copied?(0,b.jsx)(f.Check,{className:"h-3.5 w-3.5 text-green-500"}):(0,b.jsx)(i.Copy,{className:"h-3.5 w-3.5"})})]}),(0,b.jsxs)("p",{className:"text-[10px] text-muted-foreground/50",children:["Approve in ",(0,b.jsx)("span",{className:"font-medium text-foreground/70",children:"Agents"}),", then add to your tool:"]}),(0,b.jsx)(U.Button,{size:"sm",variant:"outline",className:"h-7 w-full text-xs gap-1.5",onClick:()=>void x.copy(),children:x.copied?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(f.Check,{className:"h-3.5 w-3.5 text-green-500"})," Copied!"]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(i.Copy,{className:"h-3.5 w-3.5"})," Copy config (mcp.json)"]})})]}),(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[(0,b.jsx)("span",{className:"text-[10px] text-muted-foreground/50",children:"For developers:"}),(0,b.jsxs)("button",{type:"button",onClick:()=>void l(),className:"inline-flex items-center gap-1 text-[10px] text-primary hover:underline",children:[k?(0,b.jsx)(f.Check,{className:"h-3 w-3 text-green-500"}):(0,b.jsx)(i.Copy,{className:"h-3 w-3"})," curl example"]}),(0,b.jsxs)("a",{href:"/api/agents/skill",target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-[10px] text-primary hover:underline",children:[(0,b.jsx)(ae.ExternalLink,{className:"h-3 w-3"})," skill"]}),(0,b.jsxs)("a",{href:"/api/agents/install",target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-[10px] text-primary hover:underline",children:[(0,b.jsx)(ae.ExternalLink,{className:"h-3 w-3"})," install JSON"]})]})]}),(0,b.jsx)(c7,{}),(0,b.jsxs)("section",{className:"space-y-2",children:[(0,b.jsxs)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:["Active Connections"," ",(0,b.jsx)("span",{className:"normal-case font-normal text-muted-foreground/50",children:"(last 5 min)"})]}),(0,b.jsx)("div",{className:"rounded-md border border-border bg-muted/40 p-3",children:0===h.length?(0,b.jsxs)("p",{className:"text-xs text-muted-foreground/60 flex items-center gap-1.5",children:[(0,b.jsx)(c$,{className:"h-3.5 w-3.5"}),"No recent activity"]}):(0,b.jsx)("ul",{className:"space-y-1.5",children:h.map(a=>(0,b.jsxs)("li",{className:"flex items-center justify-between text-xs",children:[(0,b.jsx)("span",{className:"font-mono text-foreground/80 truncate",children:a.by}),(0,b.jsxs)("span",{className:"text-muted-foreground shrink-0",children:[a.opCount," op",1!==a.opCount?"s":""]})]},a.by))})})]}),(0,b.jsxs)("section",{className:"space-y-2",children:[(0,b.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:"Recent Activity"}),(0,b.jsx)("div",{className:"rounded-md border border-border bg-muted/40 px-3 py-2 max-h-72 overflow-y-auto",children:(0,b.jsx)(dd,{activity:g})})]}),(0,b.jsx)("section",{children:(0,b.jsx)("a",{href:"/docs/agent-collab-plan.md",target:"_blank",rel:"noreferrer",className:"text-xs text-primary underline hover:no-underline",children:"Agent collaboration docs →"})})]})]})]}):null}var dh=a.i(503442),di=a.i(670576),dj=/[\\\/_+.#"@\[\(\{&]/,dk=/[\\\/_+.#"@\[\(\{&]/g,dl=/[\s-]/,dm=/[\s-]/g;function dn(a){return a.toLowerCase().replace(dm," ")}var dp=a.i(105305),dq=a.i(359231),dr='[cmdk-group=""]',ds='[cmdk-group-items=""]',dt='[cmdk-item=""]',du=`${dt}:not([aria-disabled="true"])`,dv="cmdk-item-select",dw="data-value",dx=(a,b,c)=>{var d;return d=a,function a(b,c,d,e,f,g,h){if(g===c.length)return f===b.length?1:.99;var i=`${f},${g}`;if(void 0!==h[i])return h[i];for(var j,k,l,m,n=e.charAt(g),o=d.indexOf(n,f),p=0;o>=0;)(j=a(b,c,d,e,o+1,g+1,h))>p&&(o===f?j*=1:dj.test(b.charAt(o-1))?(j*=.8,(l=b.slice(f,o-1).match(dk))&&f>0&&(j*=Math.pow(.999,l.length))):dl.test(b.charAt(o-1))?(j*=.9,(m=b.slice(f,o-1).match(dm))&&f>0&&(j*=Math.pow(.999,m.length))):(j*=.17,f>0&&(j*=Math.pow(.999,o-f))),b.charAt(o)!==c.charAt(g)&&(j*=.9999)),(j<.1&&d.charAt(o-1)===e.charAt(g+1)||e.charAt(g+1)===e.charAt(g)&&d.charAt(o-1)!==e.charAt(g))&&.1*(k=a(b,c,d,e,o+1,g+2,h))>j&&(j=.1*k),j>p&&(p=j),o=d.indexOf(n,o+1);return h[i]=p,p}(d=c&&c.length>0?`${d+" "+c.join(" ")}`:d,b,dn(d),dn(b),0,0,{})},dy=T.createContext(void 0),dz=T.createContext(void 0),dA=T.createContext(void 0),dB=T.forwardRef((a,b)=>{let c=dL(()=>{var b,c;return{search:"",value:null!=(c=null!=(b=a.value)?b:a.defaultValue)?c:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),d=dL(()=>new Set),e=dL(()=>new Map),f=dL(()=>new Map),g=dL(()=>new Set),h=dJ(a),{label:i,children:j,value:k,onValueChange:l,filter:m,shouldFilter:n,loop:o,disablePointerSelection:p=!1,vimBindings:q=!0,...r}=a,s=(0,dq.useId)(),t=(0,dq.useId)(),u=(0,dq.useId)(),v=T.useRef(null),w=dO();dK(()=>{if(void 0!==k){let a=k.trim();c.current.value=a,x.emit()}},[k]),dK(()=>{w(6,D)},[]);let x=T.useMemo(()=>({subscribe:a=>(g.current.add(a),()=>g.current.delete(a)),snapshot:()=>c.current,setState:(a,b,d)=>{var e,f,g,i;if(!Object.is(c.current[a],b)){if(c.current[a]=b,"search"===a)C(),A(),w(1,B);else if("value"===a){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let a=document.getElementById(u);a?a.focus():null==(e=document.getElementById(s))||e.focus()}if(w(7,()=>{var a;c.current.selectedItemId=null==(a=E())?void 0:a.id,x.emit()}),d||w(5,D),(null==(f=h.current)?void 0:f.value)!==void 0){null==(i=(g=h.current).onValueChange)||i.call(g,null!=b?b:"");return}}x.emit()}},emit:()=>{g.current.forEach(a=>a())}}),[]),y=T.useMemo(()=>({value:(a,b,d)=>{var e;b!==(null==(e=f.current.get(a))?void 0:e.value)&&(f.current.set(a,{value:b,keywords:d}),c.current.filtered.items.set(a,z(b,d)),w(2,()=>{A(),x.emit()}))},item:(a,b)=>(d.current.add(a),b&&(e.current.has(b)?e.current.get(b).add(a):e.current.set(b,new Set([a]))),w(3,()=>{C(),A(),c.current.value||B(),x.emit()}),()=>{f.current.delete(a),d.current.delete(a),c.current.filtered.items.delete(a);let b=E();w(4,()=>{C(),(null==b?void 0:b.getAttribute("id"))===a&&B(),x.emit()})}),group:a=>(e.current.has(a)||e.current.set(a,new Set),()=>{f.current.delete(a),e.current.delete(a)}),filter:()=>h.current.shouldFilter,label:i||a["aria-label"],getDisablePointerSelection:()=>h.current.disablePointerSelection,listId:s,inputId:u,labelId:t,listInnerRef:v}),[]);function z(a,b){var d,e;let f=null!=(e=null==(d=h.current)?void 0:d.filter)?e:dx;return a?f(a,c.current.search,b):0}function A(){if(!c.current.search||!1===h.current.shouldFilter)return;let a=c.current.filtered.items,b=[];c.current.filtered.groups.forEach(c=>{let d=e.current.get(c),f=0;d.forEach(b=>{f=Math.max(a.get(b),f)}),b.push([c,f])});let d=v.current;F().sort((b,c)=>{var d,e;let f=b.getAttribute("id"),g=c.getAttribute("id");return(null!=(d=a.get(g))?d:0)-(null!=(e=a.get(f))?e:0)}).forEach(a=>{let b=a.closest(ds);b?b.appendChild(a.parentElement===b?a:a.closest(`${ds} > *`)):d.appendChild(a.parentElement===d?a:a.closest(`${ds} > *`))}),b.sort((a,b)=>b[1]-a[1]).forEach(a=>{var b;let c=null==(b=v.current)?void 0:b.querySelector(`${dr}[${dw}="${encodeURIComponent(a[0])}"]`);null==c||c.parentElement.appendChild(c)})}function B(){let a=F().find(a=>"true"!==a.getAttribute("aria-disabled")),b=null==a?void 0:a.getAttribute(dw);x.setState("value",b||void 0)}function C(){var a,b,g,i;if(!c.current.search||!1===h.current.shouldFilter){c.current.filtered.count=d.current.size;return}c.current.filtered.groups=new Set;let j=0;for(let e of d.current){let d=z(null!=(b=null==(a=f.current.get(e))?void 0:a.value)?b:"",null!=(i=null==(g=f.current.get(e))?void 0:g.keywords)?i:[]);c.current.filtered.items.set(e,d),d>0&&j++}for(let[a,b]of e.current)for(let d of b)if(c.current.filtered.items.get(d)>0){c.current.filtered.groups.add(a);break}c.current.filtered.count=j}function D(){var a,b,c;let d=E();d&&((null==(a=d.parentElement)?void 0:a.firstChild)===d&&(null==(c=null==(b=d.closest(dr))?void 0:b.querySelector('[cmdk-group-heading=""]'))||c.scrollIntoView({block:"nearest"})),d.scrollIntoView({block:"nearest"}))}function E(){var a;return null==(a=v.current)?void 0:a.querySelector(`${dt}[aria-selected="true"]`)}function F(){var a;return Array.from((null==(a=v.current)?void 0:a.querySelectorAll(du))||[])}function G(a){let b=F()[a];b&&x.setState("value",b.getAttribute(dw))}function H(a){var b;let c=E(),d=F(),e=d.findIndex(a=>a===c),f=d[e+a];null!=(b=h.current)&&b.loop&&(f=e+a<0?d[d.length-1]:e+a===d.length?d[0]:d[e+a]),f&&x.setState("value",f.getAttribute(dw))}function I(a){let b=E(),c=null==b?void 0:b.closest(dr),d;for(;c&&!d;)d=null==(c=a>0?function(a,b){let c=a.nextElementSibling;for(;c;){if(c.matches(b))return c;c=c.nextElementSibling}}(c,dr):function(a,b){let c=a.previousElementSibling;for(;c;){if(c.matches(b))return c;c=c.previousElementSibling}}(c,dr))?void 0:c.querySelector(du);d?x.setState("value",d.getAttribute(dw)):H(a)}let J=()=>G(F().length-1),K=a=>{a.preventDefault(),a.metaKey?J():a.altKey?I(1):H(1)},L=a=>{a.preventDefault(),a.metaKey?G(0):a.altKey?I(-1):H(-1)};return T.createElement(dp.Primitive.div,{ref:b,tabIndex:-1,...r,"cmdk-root":"",onKeyDown:a=>{var b;null==(b=r.onKeyDown)||b.call(r,a);let c=a.nativeEvent.isComposing||229===a.keyCode;if(!(a.defaultPrevented||c))switch(a.key){case"n":case"j":q&&a.ctrlKey&&K(a);break;case"ArrowDown":K(a);break;case"p":case"k":q&&a.ctrlKey&&L(a);break;case"ArrowUp":L(a);break;case"Home":a.preventDefault(),G(0);break;case"End":a.preventDefault(),J();break;case"Enter":{a.preventDefault();let b=E();if(b){let a=new Event(dv);b.dispatchEvent(a)}}}}},T.createElement("label",{"cmdk-label":"",htmlFor:y.inputId,id:y.labelId,style:dQ},i),dP(a,a=>T.createElement(dz.Provider,{value:x},T.createElement(dy.Provider,{value:y},a))))}),dC=T.forwardRef((a,b)=>{var c,d;let e=(0,dq.useId)(),f=T.useRef(null),g=T.useContext(dA),h=T.useContext(dy),i=dJ(a),j=null!=(d=null==(c=i.current)?void 0:c.forceMount)?d:null==g?void 0:g.forceMount;dK(()=>{if(!j)return h.item(e,null==g?void 0:g.id)},[j]);let k=dN(e,f,[a.value,a.children,f],a.keywords),l=T.useContext(dz),m=dM(a=>a.value&&a.value===k.current),n=dM(a=>!!j||!1===h.filter()||!a.search||a.filtered.items.get(e)>0);function o(){var a,b;p(),null==(b=(a=i.current).onSelect)||b.call(a,k.current)}function p(){l.setState("value",k.current,!0)}if(T.useEffect(()=>{let b=f.current;if(!(!b||a.disabled))return b.addEventListener(dv,o),()=>b.removeEventListener(dv,o)},[n,a.onSelect,a.disabled]),!n)return null;let{disabled:q,value:r,onSelect:s,forceMount:t,keywords:u,...v}=a;return T.createElement(dp.Primitive.div,{ref:(0,ce.composeRefs)(f,b),...v,id:e,"cmdk-item":"",role:"option","aria-disabled":!!q,"aria-selected":!!m,"data-disabled":!!q,"data-selected":!!m,onPointerMove:q||h.getDisablePointerSelection()?void 0:p,onClick:q?void 0:o},a.children)}),dD=T.forwardRef((a,b)=>{let{heading:c,children:d,forceMount:e,...f}=a,g=(0,dq.useId)(),h=T.useRef(null),i=T.useRef(null),j=(0,dq.useId)(),k=T.useContext(dy),l=dM(a=>!!e||!1===k.filter()||!a.search||a.filtered.groups.has(g));dK(()=>k.group(g),[]),dN(g,h,[a.value,a.heading,i]);let m=T.useMemo(()=>({id:g,forceMount:e}),[e]);return T.createElement(dp.Primitive.div,{ref:(0,ce.composeRefs)(h,b),...f,"cmdk-group":"",role:"presentation",hidden:!l||void 0},c&&T.createElement("div",{ref:i,"cmdk-group-heading":"","aria-hidden":!0,id:j},c),dP(a,a=>T.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":c?j:void 0},T.createElement(dA.Provider,{value:m},a))))}),dE=T.forwardRef((a,b)=>{let{alwaysRender:c,...d}=a,e=T.useRef(null),f=dM(a=>!a.search);return c||f?T.createElement(dp.Primitive.div,{ref:(0,ce.composeRefs)(e,b),...d,"cmdk-separator":"",role:"separator"}):null}),dF=T.forwardRef((a,b)=>{let{onValueChange:c,...d}=a,e=null!=a.value,f=T.useContext(dz),g=dM(a=>a.search),h=dM(a=>a.selectedItemId),i=T.useContext(dy);return T.useEffect(()=>{null!=a.value&&f.setState("search",a.value)},[a.value]),T.createElement(dp.Primitive.input,{ref:b,...d,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":i.listId,"aria-labelledby":i.labelId,"aria-activedescendant":h,id:i.inputId,type:"text",value:e?a.value:g,onChange:a=>{e||f.setState("search",a.target.value),null==c||c(a.target.value)}})}),dG=T.forwardRef((a,b)=>{let{children:c,label:d="Suggestions",...e}=a,f=T.useRef(null),g=T.useRef(null),h=dM(a=>a.selectedItemId),i=T.useContext(dy);return T.useEffect(()=>{if(g.current&&f.current){let a=g.current,b=f.current,c,d=new ResizeObserver(()=>{c=requestAnimationFrame(()=>{let c=a.offsetHeight;b.style.setProperty("--cmdk-list-height",c.toFixed(1)+"px")})});return d.observe(a),()=>{cancelAnimationFrame(c),d.unobserve(a)}}},[]),T.createElement(dp.Primitive.div,{ref:(0,ce.composeRefs)(f,b),...e,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":h,"aria-label":d,id:i.listId},dP(a,a=>T.createElement("div",{ref:(0,ce.composeRefs)(g,i.listInnerRef),"cmdk-list-sizer":""},a)))}),dH=T.forwardRef((a,b)=>{let{open:c,onOpenChange:d,overlayClassName:e,contentClassName:f,container:g,...h}=a;return T.createElement(bU.Root,{open:c,onOpenChange:d},T.createElement(bU.Portal,{container:g},T.createElement(bU.Overlay,{"cmdk-overlay":"",className:e}),T.createElement(bU.Content,{"aria-label":a.label,"cmdk-dialog":"",className:f},T.createElement(dB,{ref:b,...h}))))}),dI=Object.assign(dB,{List:dG,Item:dC,Input:dF,Group:dD,Separator:dE,Dialog:dH,Empty:T.forwardRef((a,b)=>dM(a=>0===a.filtered.count)?T.createElement(dp.Primitive.div,{ref:b,...a,"cmdk-empty":"",role:"presentation"}):null),Loading:T.forwardRef((a,b)=>{let{progress:c,children:d,label:e="Loading...",...f}=a;return T.createElement(dp.Primitive.div,{ref:b,...f,"cmdk-loading":"",role:"progressbar","aria-valuenow":c,"aria-valuemin":0,"aria-valuemax":100,"aria-label":e},dP(a,a=>T.createElement("div",{"aria-hidden":!0},a)))})});function dJ(a){let b=T.useRef(a);return dK(()=>{b.current=a}),b}var dK=T.useEffect;function dL(a){let b=T.useRef();return void 0===b.current&&(b.current=a()),b}function dM(a){let b=T.useContext(dz),c=()=>a(b.snapshot());return T.useSyncExternalStore(b.subscribe,c,c)}function dN(a,b,c,d=[]){let e=T.useRef(),f=T.useContext(dy);return dK(()=>{var g;let h=(()=>{var a;for(let b of c){if("string"==typeof b)return b.trim();if("object"==typeof b&&"current"in b)return b.current?null==(a=b.current.textContent)?void 0:a.trim():e.current}})(),i=d.map(a=>a.trim());f.value(a,h,i),null==(g=b.current)||g.setAttribute(dw,h),e.current=h}),e}var dO=()=>{let[a,b]=T.useState(),c=dL(()=>new Map);return dK(()=>{c.current.forEach(a=>a()),c.current=new Map},[a]),(a,d)=>{c.current.set(a,d),b({})}};function dP({asChild:a,children:b},c){let d;return a&&T.isValidElement(b)?T.cloneElement("function"==typeof(d=b.type)?d(b.props):"render"in d?d.render(b.props):b,{ref:b.ref},c(b.props.children)):c(b)}var dQ={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};let dR=(0,d.default)("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]),dS=T.forwardRef(({className:a,...c},d)=>(0,b.jsx)(dI,{ref:d,className:(0,Z.cn)("flex h-full w-full flex-col overflow-hidden rounded-sm bg-popover text-popover-foreground",a),...c}));function dT({children:a,shouldFilter:c,...d}){return(0,b.jsx)(V.Dialog,{...d,children:(0,b.jsxs)(V.DialogContent,{className:"overflow-hidden p-0 shadow-golden max-w-lg",children:[(0,b.jsx)(V.DialogTitle,{className:"sr-only",children:"Search"}),(0,b.jsx)(dS,{shouldFilter:c,className:"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-normal [&_[cmdk-group-heading]]:text-muted-foreground [&_[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:a})]})})}dS.displayName=dI.displayName;let dU=T.forwardRef(({className:a,...c},d)=>(0,b.jsxs)("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[(0,b.jsx)(dR,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),(0,b.jsx)(dI.Input,{ref:d,className:(0,Z.cn)("flex h-11 w-full rounded-sm bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",a),...c})]}));dU.displayName=dI.Input.displayName;let dV=T.forwardRef(({className:a,...c},d)=>(0,b.jsx)(dI.List,{ref:d,className:(0,Z.cn)("max-h-[300px] overflow-y-auto overflow-x-hidden",a),...c}));dV.displayName=dI.List.displayName;let dW=T.forwardRef((a,c)=>(0,b.jsx)(dI.Empty,{ref:c,className:"py-6 text-center text-sm text-muted-foreground",...a}));dW.displayName=dI.Empty.displayName;let dX=T.forwardRef(({className:a,...c},d)=>(0,b.jsx)(dI.Group,{ref:d,className:(0,Z.cn)("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-normal [&_[cmdk-group-heading]]:text-muted-foreground",a),...c}));dX.displayName=dI.Group.displayName;let dY=T.forwardRef(({className:a,...c},d)=>(0,b.jsx)(dI.Separator,{ref:d,className:(0,Z.cn)("-mx-1 h-px bg-border",a),...c}));dY.displayName=dI.Separator.displayName;let dZ=T.forwardRef(({className:a,...c},d)=>(0,b.jsx)(dI.Item,{ref:d,className:(0,Z.cn)("relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",a),...c}));dZ.displayName=dI.Item.displayName;let d$=null,d_=null,d0=(0,b1.create)(a=>({query:"",results:[],loading:!1,truncated:!1,open:!1,setQuery:b=>a({query:b}),setOpen:b=>a({open:b}),clear:()=>{d_&&clearTimeout(d_),d$?.abort(),a({query:"",results:[],loading:!1,truncated:!1})},search:b=>(d_&&clearTimeout(d_),b.trim())?(a({loading:!0}),new Promise(c=>{d_=setTimeout(()=>{d1(a,b).finally(c)},150)})):(d$?.abort(),a({results:[],loading:!1,truncated:!1}),Promise.resolve())}));async function d1(a,b){d$?.abort();let c=new AbortController;d$=c;try{let d=await (0,Y.wsFetch)("/api/wiki/search",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:b,limit:30}),signal:c.signal});if(!d.ok)return void a({results:[],loading:!1,truncated:!1});let e=await d.json();if(c.signal.aborted)return;a({results:e.matches??[],truncated:!!e.truncated,loading:!1})}catch(b){"AbortError"!==b.name&&a({loading:!1})}}var d2=a.i(713033);function d3({html:a}){let c=function(a){let b,c=[],d=/<mark>([\s\S]*?)<\/mark>/g,e=0;for(;null!==(b=d.exec(a));)b.index>e&&c.push({text:a.slice(e,b.index),mark:!1}),c.push({text:b[1]??"",mark:!0}),e=b.index+b[0].length;return e<a.length&&c.push({text:a.slice(e),mark:!1}),c}(a);return(0,b.jsx)(b.Fragment,{children:c.map((a,c)=>a.mark?(0,b.jsx)("mark",{className:"bg-yellow-200 dark:bg-yellow-700 rounded-[2px] px-[1px]",children:a.text},c):(0,b.jsx)("span",{children:a.text},c))})}function d4({onOpenFile:a,onToggleSidebar:c=()=>void 0,onNewFile:d=()=>void 0,onCopyPath:f=()=>void 0}){let g=d0(a=>a.open),h=d0(a=>a.setOpen),j=d0(a=>a.query),k=d0(a=>a.setQuery),l=d0(a=>a.results),n=d0(a=>a.loading),o=d0(a=>a.truncated),p=d0(a=>a.search),{resolvedTheme:q,setTheme:r}=(0,bT.useTheme)(),s=(0,c_.useAIPanelStore)(a=>a.toggle),t=(0,d2.useViewWidthStore)(a=>a.width),u=(0,d2.useViewWidthStore)(a=>a.cycle),v=j.trimStart(),w=""===v||v.startsWith(">"),x=w?"":j;function y(a){a(),h(!1),k("")}(0,T.useEffect)(()=>{function a(a){(a.metaKey||a.ctrlKey)&&"k"===a.key.toLowerCase()&&(a.preventDefault(),h(!g))}return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[g,h]),(0,T.useEffect)(()=>{if(!g||w)return;let a=setTimeout(()=>{p(x)},120);return()=>clearTimeout(a)},[x,w,g,p]);let z=(d2.VIEW_WIDTH_ORDER.indexOf(t)+1)%d2.VIEW_WIDTH_ORDER.length,A=d2.VIEW_WIDTH_LABEL[d2.VIEW_WIDTH_ORDER[z]];return(0,b.jsxs)(dT,{open:g,onOpenChange:a=>{h(a),a||k("")},shouldFilter:!1,children:[(0,b.jsx)(dU,{placeholder:"Search files… ( > for actions )",value:j,onValueChange:k}),(0,b.jsxs)(dV,{children:[w&&(0,b.jsxs)(dX,{heading:"Actions",children:[(0,b.jsxs)(dZ,{value:"toggle-dark-mode",onSelect:()=>y(()=>r("dark"===q?"light":"dark")),children:["dark"===q?(0,b.jsx)(N.Sun,{className:"mr-2 h-4 w-4"}):(0,b.jsx)(C.Moon,{className:"mr-2 h-4 w-4"}),"dark"===q?"Switch to light mode":"Switch to dark mode"]}),(0,b.jsxs)(dZ,{value:"toggle-ai-panel",onSelect:()=>y(s),children:[(0,b.jsx)(e,{className:"mr-2 h-4 w-4"}),"Toggle AI panel"]}),(0,b.jsxs)(dZ,{value:"toggle-sidebar",onSelect:()=>y(c),children:[(0,b.jsx)(di.PanelLeft,{className:"mr-2 h-4 w-4"}),"Toggle sidebar"]}),(0,b.jsxs)(dZ,{value:"new-file",onSelect:()=>y(d),children:[(0,b.jsx)(m.FilePlus,{className:"mr-2 h-4 w-4"}),"New file"]}),(0,b.jsxs)(dZ,{value:"copy-path",onSelect:()=>y(f),children:[(0,b.jsx)(i.Copy,{className:"mr-2 h-4 w-4"}),"Copy current file path"]}),(0,b.jsxs)(dZ,{value:"cycle-view-width",onSelect:()=>y(u),children:[(0,b.jsx)(dh.AlignCenter,{className:"mr-2 h-4 w-4"}),(0,b.jsxs)("span",{children:["Change view width"," ",(0,b.jsxs)("span",{className:"text-muted-foreground",children:["(",d2.VIEW_WIDTH_LABEL[t]," → ",A,")"]})]})]})]}),!w&&(0,b.jsxs)(b.Fragment,{children:[n&&(0,b.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"Searching…"}),!n&&""!==x.trim()&&0===l.length&&(0,b.jsx)(dW,{children:"No matches."}),l.length>0&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(dY,{}),(0,b.jsx)(dX,{heading:o?"Top results (refine query for more)":"Results",children:l.map(c=>(0,b.jsx)(dZ,{value:c.path,onSelect:()=>{a(c.path),h(!1),k("")},children:(0,b.jsxs)("div",{className:"flex min-w-0 flex-col gap-0.5",children:[(0,b.jsx)("span",{className:"truncate font-mono text-xs",children:c.path}),c.snippet&&(0,b.jsx)("span",{className:"truncate text-xs text-muted-foreground",children:(0,b.jsx)(d3,{html:c.snippet})})]})},c.path))})]})]})]})]})}function d5({onOpenFile:a}){let c=d0(a=>a.query),d=d0(a=>a.setQuery),e=d0(a=>a.results),f=d0(a=>a.loading),g=d0(a=>a.search),h=d0(a=>a.clear),[i,j]=(0,T.useState)(0),k=(0,T.useRef)(null);function l(b){let c=e[b];c&&(a(c.path),h())}return(0,T.useEffect)(()=>{j(0)},[e]),(0,T.useEffect)(()=>{let a=k.current?.querySelector(`[data-idx="${i}"]`);a?.scrollIntoView({block:"nearest"})},[i]),(0,b.jsxs)("div",{className:"flex flex-col gap-1 px-2 py-1.5",children:[(0,b.jsxs)("div",{className:"relative",children:[(0,b.jsx)(dR,{className:"pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 opacity-50"}),(0,b.jsx)("input",{type:"text",className:"w-full rounded-sm border bg-transparent py-1 pl-7 pr-2 text-xs outline-none focus:ring-1 focus:ring-ring",placeholder:"Search… (⌘K)",value:c,onChange:a=>{d(a.target.value),g(a.target.value)},onKeyDown:a=>{"Escape"===a.key?h():0!==e.length&&("ArrowDown"===a.key?(a.preventDefault(),j(a=>(a+1)%e.length)):"ArrowUp"===a.key?(a.preventDefault(),j(a=>(a-1+e.length)%e.length)):"Enter"===a.key&&(a.preventDefault(),l(i)))}})]}),""!==c.trim()&&(0,b.jsxs)("div",{ref:k,className:"max-h-64 overflow-y-auto rounded-sm border bg-popover",children:[f&&(0,b.jsx)("div",{className:"px-2 py-1 text-xs text-muted-foreground",children:"Searching…"}),!f&&0===e.length&&(0,b.jsx)("div",{className:"px-2 py-1 text-xs text-muted-foreground",children:"No matches"}),e.map((a,c)=>(0,b.jsxs)("button",{type:"button","data-idx":c,onClick:()=>l(c),onMouseEnter:()=>j(c),className:`block w-full px-2 py-1 text-left ${c===i?"bg-accent":"hover:bg-accent"}`,children:[(0,b.jsx)("div",{className:"truncate font-mono text-xs",children:a.path}),a.snippet&&(0,b.jsx)("div",{className:"truncate text-[10px] text-muted-foreground",children:(0,b.jsx)(d3,{html:a.snippet})})]},a.path))]})]})}let d6=(0,b1.create)(a=>({width:288,setWidth:b=>{a({width:Number.isNaN(b)?288:Math.min(600,Math.max(200,Math.round(b)))})}}));var d7=a.i(256233);let d8=(0,b1.create)((a,b)=>({showHidden:!1,toggle:()=>{a({showHidden:!b().showHidden})}})),d9=(0,b1.create)((a,b)=>({humanize:!1,toggle:()=>{a({humanize:!b().humanize})}}));function ea(a){let b=a.lastIndexOf("."),c=b>0&&b<a.length-1,d=c?a.slice(0,b):a,e=c?a.slice(b):"",f=d.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").split(/[\s_-]+/).filter(Boolean).map(a=>/^[A-Z0-9]+$/.test(a)?a:a[0].toUpperCase()+a.slice(1));return f.length?f.join(" ")+e:a}let eb=(0,bs.default)(async()=>{},{loadableGenerated:{modules:[904378]},ssr:!1});function ec(a){let b=new Date(a).getTime();if(!Number.isFinite(b))return"";let c=Math.floor(Math.max(0,Date.now()-b)/1e3);if(c<60)return"just now";let d=Math.floor(c/60);if(d<60)return`${d}m ago`;let e=Math.floor(d/60);return e<24?`${e}h ago`:`${Math.floor(e/24)}d ago`}let ed=new Set(["image","media","pdf","fallback","app","node-app","html"]);function ee(a){return a.split(".").pop()?.toLowerCase()??""}function ef(a,b){if("node-app"===b)return"node-app";if("app"===b)return"app";if("dir"===b)return"fallback";let c=a.split("/").pop()??a;if(c.startsWith(".")&&-1===c.indexOf(".",1))return"source";let d=ee(a);return d?["md","markdown"].includes(d)?"editor":"txt"===d?"text":["csv","tsv"].includes(d)?"csv":"pdf"===d?"pdf":["mmd","mermaid"].includes(d)?"mermaid":"ipynb"===d?"notebook":["png","jpg","jpeg","gif","webp","svg","avif","ico","bmp"].includes(d)?"image":["mp4","webm","mov","m4v","mp3","wav","ogg","m4a","aac"].includes(d)?"media":"docx"===d?"docx":["xlsx","xlsm"].includes(d)?"xlsx":"pptx"===d?"pptx":"html"===d?"html":(["py","js","ts","tsx","jsx","go","rs","java","c","cpp","h","sh","bash","zsh","rb","php","swift","kt","lua","sql","yaml","yml","toml","json","xml","css","scss"].includes(d),"source"):"source"}let eg=new Set(["txt","md","markdown","json","yaml","yml","toml","csv","tsv","xml","html","css","js","ts","tsx","jsx","sh","bash","zsh","rb","py","go","rs","java","c","cpp","h","php","swift","kt","lua","sql","scss","mmd","mermaid","ini","env","log","conf"]);function eh(a){let b=ef(a,"file");return"editor"===b||"text"===b||eg.has(ee(a))}function ei(a){return["md","markdown"].includes(ee(a))}function ej(a){return"image"===ef(a,"file")}function ek(a){return"html"===ef(a,"file")}async function el(a){let b=await (0,Y.wsFetch)(`/api/wiki?dir=${encodeURIComponent(a)}`);return b.ok?(await b.json()).entries.map(b=>({name:b.name,path:a?`${a}/${b.name}`:b.name,type:b.type,size:b.size,modifiedAt:b.modifiedAt,expanded:!1,git:b.git})):[]}let em=new Map,en=new Map;async function eo(a){let b=em.get(a);if(b)return em.delete(a),b;let c=en.get(a);if(c){let b=await c;return em.delete(a),b}return null}function ep(a,b,c){return a.map(a=>a.path===b?c(a):a.children?{...a,children:ep(a.children,b,c)}:a)}let eq={contentVisibility:"auto",containIntrinsicSize:"auto 32px"};function er({node:a,ctx:c,isPinned:d,activeWorkspaceId:e}){return(0,b.jsxs)(cV,{className:"w-48",children:[(0,b.jsxs)(cW,{onSelect:()=>c.copyPath(a.path),children:[(0,b.jsx)(i.Copy,{className:"mr-2 h-3.5 w-3.5"}),"Copy path"]}),ei(a.name)&&(0,b.jsxs)(cW,{onSelect:()=>c.copyWikiLink(a.name),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy wiki link"]}),(0,b.jsxs)(cW,{onSelect:()=>c.copyUrl(a.path),children:[(0,b.jsx)(y.Link,{className:"mr-2 h-3.5 w-3.5"}),"Copy URL"]}),"file"===a.type&&eh(a.name)&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(cW,{onSelect:()=>c.copyRawContent(a.path),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy raw content"]}),(0,b.jsxs)(cW,{onSelect:()=>c.copyFormattedContent(a.path,a.name),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy formatted content"]})]}),(0,b.jsx)(cX,{}),"dir"===a.type&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(cW,{onSelect:()=>{a.expanded||c.toggleFolder(a),c.setNewFileParent(a.path),c.setNewFileName(""),c.setFileCreateError(null)},children:[(0,b.jsx)(m.FilePlus,{className:"mr-2 h-3.5 w-3.5"}),"New file here"]}),(0,b.jsxs)(cW,{onSelect:()=>c.triggerUpload(a.path),children:[(0,b.jsx)(R.Upload,{className:"mr-2 h-3.5 w-3.5"}),"Upload here"]}),(0,b.jsxs)(cW,{onSelect:()=>{c.setNewFolderParent(a.path),c.setNewFolderName(""),c.setFolderError(null)},children:[(0,b.jsx)(q,{className:"mr-2 h-3.5 w-3.5"}),"New subfolder"]}),(0,b.jsx)(cX,{})]}),(0,b.jsxs)(cW,{onSelect:()=>c.handleDownload(a),children:[(0,b.jsx)(j,{className:"mr-2 h-3.5 w-3.5"}),"file"===a.type?"Download":"Download as zip"]}),(0,b.jsxs)(cW,{onSelect:()=>c.togglePin(a,e),children:[(0,b.jsx)(I,{className:(0,Z.cn)("mr-2 h-3.5 w-3.5",d&&"fill-current text-amber-400")}),d?"Unpin":"Pin to top"]}),(0,b.jsx)(cX,{}),(0,b.jsxs)(cW,{className:"text-destructive focus:text-destructive",onSelect:()=>{c.setDeletingPath(a.path),c.setDeletingIsDir("file"!==a.type)},children:[(0,b.jsx)(Q.Trash2,{className:"mr-2 h-3.5 w-3.5"}),"Delete"]})]})}function es({name:a,type:c}){let d="h-3.5 w-3.5 shrink-0";return"dir"===c?(0,b.jsx)(o.Folder,{className:(0,Z.cn)(d,"text-warning")}):"app"===c?(0,b.jsx)(u.Globe,{className:(0,Z.cn)(d,"text-foreground/70")}):"node-app"===c?(0,b.jsx)(O,{className:(0,Z.cn)(d,"text-emerald-500")}):ek(a)?(0,b.jsx)(u.Globe,{className:(0,Z.cn)(d,"text-foreground/60")}):ej(a)?(0,b.jsx)(x.default,{className:(0,Z.cn)(d,"text-sunshine-700")}):eh(a)?(0,b.jsx)(n.FileText,{className:(0,Z.cn)(d,"text-foreground/70")}):(0,b.jsx)(l.File,{className:(0,Z.cn)(d,"text-foreground/60")})}let et=(0,T.memo)(function({node:a,depth:c,ctx:d,isMobile:e,activeWorkspaceId:f,sidebarScrollRef:g,isActive:k,isDragOver:s,isPinned:t,isAgentActive:v,isPulling:w,branchOpen:A,branchPos:C,branches:D,branchLoading:E,checkingOut:F,onHoverEnter:G,onHoverLeave:H}){let J=d9(a=>a.humanize);return(0,b.jsxs)(cF,{children:[(0,b.jsx)(cH,{asChild:!0,children:(0,b.jsxs)("div",{role:"treeitem",tabIndex:0,draggable:!e,onKeyDown:b=>{if("Enter"===b.key||" "===b.key)b.preventDefault(),"dir"===a.type?d.toggleFolder(a):"app"===a.type||"node-app"===a.type?(d.openViewer(a),d.toggleFolder(a)):d.openViewer(a);else if("ArrowDown"===b.key){b.preventDefault();let a=g.current;if(!a)return;let c=Array.from(a.querySelectorAll('[role="treeitem"]')),d=c.indexOf(b.currentTarget);c[d+1]?.focus()}else if("ArrowUp"===b.key){b.preventDefault();let a=g.current;if(!a)return;let c=Array.from(a.querySelectorAll('[role="treeitem"]')),d=c.indexOf(b.currentTarget);c[d-1]?.focus()}else if("ArrowRight"===b.key){if(b.preventDefault(),"dir"===a.type||"app"===a.type||"node-app"===a.type)if(a.expanded){let a=g.current;if(!a)return;let c=Array.from(a.querySelectorAll('[role="treeitem"]')),d=c.indexOf(b.currentTarget);c[d+1]?.focus()}else d.toggleFolder(a)}else if("ArrowLeft"===b.key){if(b.preventDefault(),("dir"===a.type||"app"===a.type||"node-app"===a.type)&&a.expanded)d.toggleFolder(a);else if(c>0){let a=g.current;if(!a)return;let c=Array.from(a.querySelectorAll('[role="treeitem"]')),d=b.currentTarget,e=c.indexOf(d),f=Number.parseInt(d.style.paddingLeft??"0",10);for(let a=e-1;a>=0;a--)if(Number.parseInt(c[a].style.paddingLeft??"0",10)<f){c[a].focus();break}}}},onDragStart:b=>d.handleDragStart(b,a),onDragOver:b=>"dir"===a.type?d.handleDragOver(b,a.path,"dir"):b.preventDefault(),onDragLeave:()=>d.setDragOverPath(null),onDrop:b=>"dir"===a.type?d.handleDropOnFolder(b,a.path):b.preventDefault(),onMouseEnter:()=>G(a),onMouseLeave:H,className:(0,Z.cn)("tree-row-reveal flex items-center gap-1.5 rounded-sm px-2 py-1 text-sm cursor-pointer group transition-colors select-none touch-target",k?"bg-accent-soft text-foreground font-medium":"hover:bg-muted",s&&"ring-2 ring-primary bg-primary-soft",a.name.startsWith(".")&&"opacity-40"),style:{paddingLeft:`${14*c+8}px`,...eq},onClick:()=>{"dir"===a.type?d.toggleFolder(a):("app"===a.type||"node-app"===a.type?(d.openViewer(a),d.toggleFolder(a)):d.openViewer(a),e&&d.setSidebarCollapsed(!0))},children:["dir"===a.type||"app"===a.type||"node-app"===a.type?a.loading?(0,b.jsx)(z.Loader2,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground"}):(0,b.jsx)(h.ChevronRight,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform duration-200 ease-out",style:{transform:a.expanded?"rotate(90deg)":"rotate(0deg)"}}):(0,b.jsx)("span",{className:"w-3.5 shrink-0"}),(0,b.jsx)("span",{className:"editorial-tree-typeicon",children:"dir"===a.type?a.expanded?(0,b.jsx)(p,{className:(0,Z.cn)("h-4 w-4 shrink-0",!k&&"text-warning")}):(0,b.jsx)(o.Folder,{className:(0,Z.cn)("h-4 w-4 shrink-0",!k&&"text-warning")}):"app"===a.type?(0,b.jsx)(u.Globe,{className:(0,Z.cn)("h-4 w-4 shrink-0",!k&&"text-foreground/70")}):"node-app"===a.type?(0,b.jsx)(O,{className:(0,Z.cn)("h-4 w-4 shrink-0",!k&&"text-emerald-500")}):ek(a.name)?(0,b.jsx)(u.Globe,{className:(0,Z.cn)("h-4 w-4 shrink-0",!k&&"text-foreground/60")}):ej(a.name)?(0,b.jsx)(x.default,{className:(0,Z.cn)("h-4 w-4 shrink-0",!k&&"text-sunshine-700")}):eh(a.name)?(0,b.jsx)(n.FileText,{className:(0,Z.cn)("h-4 w-4 shrink-0",!k&&"text-foreground/70")}):(0,b.jsx)(l.File,{className:(0,Z.cn)("h-4 w-4 shrink-0",!k&&"text-foreground/60")})}),(0,b.jsx)("span",{className:"min-w-0 flex-1 truncate",title:J?a.name:void 0,children:J?ea(a.name):a.name}),a.git&&(0,b.jsxs)("span",{className:"relative flex shrink-0 items-center gap-0.5 rounded-sm bg-muted px-1 py-0.5 text-[10px] text-muted-foreground",children:[(0,b.jsxs)("button",{"data-branch-trigger":!0,type:"button",className:"flex items-center gap-0.5 hover:text-foreground",title:"Switch branch",onClick:b=>{if(b.stopPropagation(),A){d.setBranchDropdownNode(null),d.setBranchDropdownPos(null);return}let c=b.currentTarget.getBoundingClientRect();d.setBranchDropdownPos({top:c.bottom+4,left:c.left}),d.setBranchDropdownNode(a.path),d.loadBranches(a.path)},children:[(0,b.jsx)(r,{className:"h-2.5 w-2.5"}),a.git.branch,a.git.dirty&&(0,b.jsx)("span",{className:"ml-0.5 text-warning",children:"*"})]}),w?(0,b.jsx)(z.Loader2,{className:"ml-0.5 h-2.5 w-2.5 animate-spin"}):(0,b.jsx)("button",{type:"button",onClick:b=>{b.stopPropagation();let c=a.path.includes("/")?a.path.substring(0,a.path.lastIndexOf("/")):"";d.handleGitPull(a.path,c)},className:"ml-0.5 text-muted-foreground hover:text-foreground",title:"Pull latest",children:(0,b.jsx)(K,{className:"h-2.5 w-2.5"})}),A&&C&&(0,b.jsx)(bS,{pos:C,branches:D,loading:E,busyName:F,disabled:null!==F,onPick:b=>{let c=a.path.includes("/")?a.path.substring(0,a.path.lastIndexOf("/")):"";d.handleCheckout(a.path,b,c)},onClose:()=>{d.setBranchDropdownNode(null),d.setBranchDropdownPos(null)}})]}),v&&(0,b.jsx)("span",{className:"ml-0.5 h-1.5 w-1.5 rounded-full bg-emerald-400 shrink-0 animate-pulse",title:"Agent recently active"}),(0,b.jsx)("div",{className:"hover-reveal flex max-w-0 shrink-0 items-center overflow-hidden opacity-0 transition-all duration-150 group-hover:max-w-7 group-hover:opacity-100 focus-within:max-w-7 focus-within:opacity-100",onClick:a=>a.stopPropagation(),onKeyDown:a=>a.stopPropagation(),children:(0,b.jsxs)(bJ.DropdownMenu,{children:[(0,b.jsx)(bJ.DropdownMenuTrigger,{asChild:!0,children:(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 text-muted-foreground hover:text-foreground",title:"File actions",children:(0,b.jsx)(B,{className:"h-3.5 w-3.5"})})}),(0,b.jsxs)(bJ.DropdownMenuContent,{align:"end",className:"w-48",children:[(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d.copyPath(a.path),children:[(0,b.jsx)(i.Copy,{className:"mr-2 h-3.5 w-3.5"}),"Copy path"]}),ei(a.name)&&(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d.copyWikiLink(a.name),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy wiki link"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d.copyUrl(a.path),children:[(0,b.jsx)(y.Link,{className:"mr-2 h-3.5 w-3.5"}),"Copy URL"]}),"file"===a.type&&eh(a.name)&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d.copyRawContent(a.path),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy raw content"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d.copyFormattedContent(a.path,a.name),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy formatted content"]})]}),(0,b.jsx)(bJ.DropdownMenuSeparator,{}),"dir"===a.type&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:async()=>{a.expanded||d.toggleFolder(a),d.setNewFileParent(a.path),d.setNewFileName(""),d.setFileCreateError(null)},children:[(0,b.jsx)(m.FilePlus,{className:"mr-2 h-3.5 w-3.5"}),"New file here"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d.triggerUpload(a.path),children:[(0,b.jsx)(R.Upload,{className:"mr-2 h-3.5 w-3.5"}),"Upload here"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>{d.setNewFolderParent(a.path),d.setNewFolderName(""),d.setFolderError(null)},children:[(0,b.jsx)(q,{className:"mr-2 h-3.5 w-3.5"}),"New subfolder"]}),(0,b.jsx)(bJ.DropdownMenuSeparator,{})]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d.handleDownload(a),children:[(0,b.jsx)(j,{className:"mr-2 h-3.5 w-3.5"}),"file"===a.type?"Download":"Download as zip"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d.togglePin(a,f),children:[(0,b.jsx)(I,{className:(0,Z.cn)("mr-2 h-3.5 w-3.5",t&&"fill-current text-amber-400")}),t?"Unpin":"Pin to top"]}),(0,b.jsx)(bJ.DropdownMenuSeparator,{}),(0,b.jsxs)(bJ.DropdownMenuItem,{className:"text-destructive focus:text-destructive",onClick:()=>{d.setDeletingPath(a.path),d.setDeletingIsDir("file"!==a.type)},children:[(0,b.jsx)(Q.Trash2,{className:"mr-2 h-3.5 w-3.5"}),"Delete"]})]})]})})]})}),(0,b.jsx)(er,{node:a,ctx:d,isPinned:t,activeWorkspaceId:f})]})}),eu=(0,T.memo)(function(a){let{ctx:c,openPath:d,dragOverPath:e,branchDropdownNode:g,branchDropdownPos:h,nodeBranches:i,branchesLoading:j,checkingOutBranch:k,pullingRepo:l,activePaths:m,pins:p,isMobile:q,activeWorkspaceId:r,newFileParent:s,newFileName:t,fileCreateError:u,newFolderParent:v,newFolderName:w,folderError:x,sidebarScrollRef:y}=a,z=d8(a=>a.showHidden),A=(0,T.useRef)(null),B=(0,T.useCallback)(a=>{let b=("dir"===a.type||"app"===a.type||"node-app"===a.type)&&!a.expanded&&void 0===a.children;("file"===a.type||b)&&(A.current&&clearTimeout(A.current),A.current=setTimeout(()=>c.prefetch(a),120))},[c]),C=(0,T.useCallback)(()=>{A.current&&(clearTimeout(A.current),A.current=null)},[]),D=(0,T.useMemo)(()=>{let b=[],c=(a,d)=>{for(let e of a)!(!z&&e.name.startsWith("."))&&(b.push({kind:"row",node:e,depth:d}),"dir"===e.type&&(v===e.path&&b.push({kind:"newfolder",node:e,depth:d}),s===e.path&&b.push({kind:"newfile",node:e,depth:d})),("dir"===e.type||"app"===e.type||"node-app"===e.type)&&e.expanded&&(e.children&&e.children.length>0?c(e.children,d+1):e.children?.length===0&&b.push({kind:"empty",node:e,depth:d})))};return c(a.nodes,0),b},[a.nodes,s,v,z]);return(0,b.jsx)(b.Fragment,{children:D.map(a=>{let{node:s,depth:v}=a;if("row"===a.kind){let a=g===s.path;return(0,b.jsx)(et,{node:s,depth:v,ctx:c,isMobile:q,activeWorkspaceId:r,sidebarScrollRef:y,isActive:d===s.path,isDragOver:e===s.path,isPinned:p.some(a=>a.path===s.path),isAgentActive:m.has(s.path),isPulling:l===s.path,branchOpen:a,branchPos:a?h:null,branches:s.git?i[s.path]??[]:[],branchLoading:!!s.git&&!!j[s.path],checkingOut:a?k:null,onHoverEnter:B,onHoverLeave:C},s.path)}return"newfolder"===a.kind?(0,b.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1",style:{paddingLeft:`${(v+1)*14+8}px`,...eq},children:[(0,b.jsx)("span",{className:"w-3.5 shrink-0"}),(0,b.jsx)(o.Folder,{className:"h-4 w-4 shrink-0 text-warning"}),(0,b.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"Folder name",value:w,onChange:a=>c.setNewFolderName(a.target.value),onKeyDown:a=>{"Enter"===a.key&&c.handleCreateFolder(),"Escape"===a.key&&(c.setNewFolderParent(null),c.setNewFolderName(""))}}),x&&(0,b.jsx)("span",{className:"text-xs text-destructive",children:x}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:c.handleCreateFolder,children:(0,b.jsx)(f.Check,{className:"h-3 w-3"})}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{c.setNewFolderParent(null),c.setNewFolderName("")},children:(0,b.jsx)(S.X,{className:"h-3 w-3"})})]},`nf-${s.path}`):"newfile"===a.kind?(0,b.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1",style:{paddingLeft:`${(v+1)*14+8}px`,...eq},children:[(0,b.jsx)("span",{className:"w-3.5 shrink-0"}),(0,b.jsx)(n.FileText,{className:"h-4 w-4 shrink-0 text-accent"}),(0,b.jsx)("input",{autoFocus:!0,className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"filename (default .md)",value:t,onChange:a=>c.setNewFileName(a.target.value),onKeyDown:a=>{"Enter"===a.key&&c.handleCreateFile(),"Escape"===a.key&&(c.setNewFileParent(null),c.setNewFileName(""))}}),u&&(0,b.jsx)("span",{className:"text-xs text-destructive",children:u}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:c.handleCreateFile,children:(0,b.jsx)(f.Check,{className:"h-3 w-3"})}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{c.setNewFileParent(null),c.setNewFileName("")},children:(0,b.jsx)(S.X,{className:"h-3 w-3"})})]},`ff-${s.path}`):(0,b.jsx)("div",{className:"text-xs text-muted-foreground/50 py-0.5",style:{paddingLeft:`${(v+1)*14+8+14+6+16+6}px`,...eq},children:"Empty"},`empty-${s.path}`)})})});a.s(["default",0,function(){let a;(0,d7.useWikiSlugsStore)(a=>a.loadedAt),(0,T.useEffect)(()=>{d7.useWikiSlugsStore.getState().load()},[]);let[d,j]=(0,T.useState)(null),[p,O]=(0,T.useState)(null),[V,X]=(0,T.useState)(()=>null),[$,_]=(0,T.useState)([]),[aa,ae]=(0,T.useState)(!1),[af,aj]=(0,T.useState)(!1),[al,am]=(0,T.useState)(null),[an,ao]=(0,T.useState)(null),[ap,aq]=(0,T.useState)({}),[ar,as]=(0,T.useState)(null),[at,au]=(0,T.useState)(null),[av,aw]=(0,T.useState)(null),[ax,ay]=(0,T.useState)(null),az=(0,T.useCallback)(async()=>{try{let a=await fetch("/api/system/workspaces");if(!a.ok)throw Error("Failed");let b=await a.json();if(_(b.workspaces),ae(b.isAdmin),b.workspaces.length>0){j(!0);let a=new URLSearchParams(window.location.search).get("ws"),c=a?b.workspaces.find(b=>b.id===a):null,d=c??[...b.workspaces].sort((a,b)=>(b.lastOpenedAt??b.createdAt).localeCompare(a.lastOpenedAt??a.createdAt))[0];if(X(d.id),O(d.rootDir),!c){let a=new URL(location.href);a.searchParams.set("ws",d.id),history.replaceState(null,"",a.toString())}}else j(!1)}catch{j(!1)}},[]);(0,T.useEffect)(()=>{az()},[az]);let aA=(0,c8.useEditorStore)(a=>a.currentPath),aB=cY(a=>a.recents),[aC,aD]=(0,T.useState)(!1),[aE,aF]=(0,T.useState)(!0),aG=cZ(a=>a.pins),aH=(0,T.useRef)(null),aI=(0,c_.useAIPanelStore)(a=>a.activity),aJ=(0,T.useMemo)(()=>{let a=new Date(Date.now()-6e4).toISOString(),b=new Set;for(let c of aI)c.at>=a&&c.path&&c.by?.startsWith("ai:")&&b.add(c.path);return b},[aI]);(0,T.useEffect)(()=>{let a=()=>{c_.useAIPanelStore.getState().loadActivity()};a();let b=setInterval(a,1e4);return()=>clearInterval(b)},[]),(0,T.useEffect)(()=>{cY.getState().loadForWorkspace(V),cZ.getState().loadForWorkspace(V)},[V]),(0,T.useEffect)(()=>{let a,b=[...aG.map(a=>a.path),...aB.slice(0,8).map(a=>a.path)].filter((a,b,c)=>ei(a)&&c.indexOf(a)===b).slice(0,12);if(0===b.length)return;let c=(a=()=>{for(let a of b)(0,c8.prefetchPage)(a)},window.setTimeout(a,400));return()=>{clearTimeout(c)}},[aG,aB]);let aK=(0,T.useRef)(null),aL=(0,T.useRef)(!1),[aM,aN]=(0,T.useState)([]),[aO,aP]=(0,T.useState)(!1),[aQ,aR]=(0,T.useState)(!1),aS=(0,T.useRef)(!1),[aT,aU]=(0,T.useState)(!1),[aV,aW]=(0,T.useState)(!1),[aX,aY]=(0,T.useState)(null),aZ=(0,T.useRef)(null),a$=(0,T.useRef)(""),[a_,a0]=(0,T.useState)(null),[a1,a2]=(0,T.useState)(""),[a3,a4]=(0,T.useState)(null),[a5,a6]=(0,T.useState)(null),[a7,a8]=(0,T.useState)(""),[a9,ba]=(0,T.useState)(null),[bb,bc]=(0,T.useState)(null),[bd,bf]=(0,T.useState)(!1),[bg,bh]=(0,T.useState)(null),[bi,bj]=(0,T.useState)(null),[bk,bl]=(0,T.useState)(!1),[bm,bo]=(0,T.useState)(0),[bs,bt]=(0,T.useState)(0),bu=function(a="(max-width: 767px)"){let[b,c]=(0,T.useState)(!1);return(0,T.useEffect)(()=>{let b=window.matchMedia(a),d=()=>c(b.matches);return d(),b.addEventListener("change",d),()=>b.removeEventListener("change",d)},[a]),b}(),[bv,bw]=(0,T.useState)(!1),bx=d6(a=>a.width),by=d8(a=>a.showHidden),bz=d9(a=>a.humanize),{resolvedTheme:bA,setTheme:bB}=(0,bT.useTheme)(),bC=d6(a=>a.setWidth);(0,T.useEffect)(()=>{bu&&bw(!0)},[bu]);let[bD,bF]=(0,T.useState)(!1),[bH,bI]=(0,T.useState)(!1),[bK,bM]=(0,T.useState)(!1),[bN,bO]=(0,T.useState)(null),[bP,bR]=(0,T.useState)(0),[bU,bV]=(0,T.useState)(!1),[bW,bX]=(0,T.useState)(!1),[bY,bZ]=(0,T.useState)(""),[b$,b0]=(0,T.useState)(!1),[b1,b2]=(0,T.useState)(!1),[b3,b4]=(0,T.useState)(null),b5=(0,T.useRef)(null),[b6,b7]=(0,T.useState)(null),b8=(0,T.useRef)(null),ca=(0,T.useRef)(!1),cb=(0,T.useRef)(async()=>{});(0,T.useEffect)(()=>{aO||aS.current||(aS.current=!0,aR(!0),el("").then(a=>{aN(a),aP(!0),aR(!1)}).catch(()=>{aS.current=!1,aR(!1)}))},[aO]);let cc=(0,T.useCallback)(async a=>{let b=a.split("/");if(b.length<=1)return;let c=[],d="";for(let a=0;a<b.length-1;a++)d=d?`${d}/${b[a]}`:b[a],c.push({prefix:d,children:await el(d)});aN(a=>{let b=a;for(let{prefix:a,children:d}of c)b=ep(b,a,a=>({...a,children:d,expanded:!0}));return b})},[]),cd=(0,T.useCallback)(async a=>{let b=await el(a);""===a?aN(a=>{let c=new Map(a.map(a=>[a.path,a]));return b.map(a=>{let b=c.get(a.path);return b&&("dir"===b.type||"app"===b.type)?{...a,expanded:b.expanded,children:b.children}:a})}):aN(c=>ep(c,a,a=>({...a,children:b,expanded:!0})))},[]),[ce,cf]=(0,T.useState)(null),[cg,ch]=(0,T.useState)(null),[ci,cj]=(0,T.useState)(!1),[ck,cl]=(0,T.useState)([]),[cm,cn]=(0,T.useState)(!1),[co,cp]=(0,T.useState)(null),[cq,cr]=(0,T.useState)(null),[cs,ct]=(0,T.useState)(!1),[cu,cx]=(0,T.useState)({}),[cy,cz]=(0,T.useState)({}),[cA,cB]=(0,T.useState)(null),[cC,cD]=(0,T.useState)(null),[cE,cG]=(0,T.useState)(null),cI=(0,T.useCallback)(async(a,b)=>{if(!ce){cf(a);try{let c=await (0,Y.wsFetch)("/api/wiki/git-pull",{method:"POST",body:JSON.stringify({path:a})});if(!c.ok){let a=await c.json();(0,b_.showError)(a.message??a.error??"Pull failed");return}let d=await c.json();(0,b_.showSuccess)(`Pulled ${a} (${d.branch} @ ${d.sha.slice(0,7)})`),await cd(b)}catch{(0,b_.showError)("Pull failed")}finally{cf(null)}}},[ce,cd]);(0,T.useEffect)(()=>{cj(!1),cl([]),cp(null),cr(null)},[bg?.path]);let cJ=bg?.path;(0,T.useEffect)(()=>{if(!cJ)return void ch(null);let a=!1,b=setTimeout(()=>{(async()=>{try{let b=await (0,Y.wsFetch)(`/api/wiki/git-file-info?path=${encodeURIComponent(cJ)}`);if(a)return;if(!b.ok)return void ch(null);let c=await b.json();a||ch(c.info)}catch{a||ch(null)}})()},200);return()=>{a=!0,clearTimeout(b)}},[cJ]);let cK=(0,T.useCallback)(async()=>{if(!bg)return;let a=bg.path;cj(!0),cn(!0),cl([]),cp(null),cr(null);try{let b=await (0,Y.wsFetch)(`/api/wiki/git-history?path=${encodeURIComponent(a)}`);if(!b.ok)return void(0,b_.showError)("Could not load history");let c=await b.json();bg.path===a&&cl(c.commits)}catch{(0,b_.showError)("Could not load history")}finally{cn(!1)}},[bg]),cL=(0,T.useCallback)(async a=>{if(!bg)return;if(co===a){cp(null),cr(null);return}let b=bg.path;cp(a),ct(!0),cr(null);try{let c=await (0,Y.wsFetch)(`/api/wiki/git-diff?path=${encodeURIComponent(b)}&sha=${encodeURIComponent(a)}`);if(!c.ok)return void(0,b_.showError)("Could not load diff");let d=await c.json();bg.path===b&&co===a&&cr(d.diff)}catch{(0,b_.showError)("Could not load diff")}finally{ct(!1)}},[bg,co]),cM=(0,T.useCallback)(async a=>{if(cu[a]||cy[a])return;let b=!1;cz(b=>({...b,[a]:!0}));try{let c=await (0,Y.wsFetch)(`/api/wiki/git-branches?path=${encodeURIComponent(a)}`);if(b)return;if(!c.ok)return void(0,b_.showError)("Could not load branches");let d=await c.json();b||cx(b=>({...b,[a]:d.branches}))}catch{b||(0,b_.showError)("Could not load branches")}finally{b||cz(b=>({...b,[a]:!1}))}return()=>{b=!0}},[cu,cy]),cN=(0,T.useCallback)(async(a,b,c)=>{if(!cA){cB(b);try{let d=await (0,Y.wsFetch)("/api/wiki/git-checkout",{method:"POST",body:JSON.stringify({path:a,branch:b})});if(409===d.status)return void(0,b_.showError)("Repository has uncommitted changes");if(!d.ok){let a=await d.json();(0,b_.showError)(a.error??"Checkout failed");return}let e=await d.json();(0,b_.showSuccess)(`Switched to ${e.branch}`),cx(b=>{let c={...b};return delete c[a],c}),cD(null),cG(null),await cd(c)}catch{(0,b_.showError)("Checkout failed")}finally{cB(null)}}},[cA,cd]),cO=(0,T.useCallback)(a=>{let b=[];for(let c of a)("dir"===c.type||"app"===c.type||"node-app"===c.type)&&c.expanded&&c.children&&(b.push(c.path),b.push(...cO(c.children)));return b},[]),cP=(0,T.useCallback)(async()=>{aU(!0);try{let a=cO(aM),b=await el("");for(let c of(aN(b),a)){let a=await el(c);aN(b=>ep(b,c,b=>({...b,children:a,expanded:!0})))}}finally{aU(!1)}},[aM,cO]),cQ=(0,T.useCallback)(async()=>{if(bg){if(ei(bg.name)){bV(!0);try{await c8.useEditorStore.getState().loadPage(bg.path)}finally{bV(!1)}return}if(["editor","text"].includes(ef(bg.name,bg.nodeType))||eh(bg.name)){bV(!0);try{let a=await (0,Y.wsFetch)(`/api/wiki/content?path=${encodeURIComponent(bg.path)}`);if(a.ok){let b=await a.json();bO(b.content),bR(Number(a.headers.get("X-Wiki-Revision")??0))}}catch{}bV(!1)}}},[bg]),cR=(0,T.useCallback)(()=>{bt(a=>a+1),cQ()},[cQ]);async function cS(a){if("dir"===a.type||"app"===a.type||"node-app"===a.type)if(a.expanded)aN(b=>ep(b,a.path,a=>({...a,expanded:!1})));else if(void 0===a.children){let b=await eo(a.path);if(b)return void aN(c=>ep(c,a.path,a=>({...a,loading:!1,children:b,expanded:!0})));aN(b=>ep(b,a.path,a=>({...a,loading:!0})));let c=await el(a.path);aN(b=>ep(b,a.path,a=>({...a,loading:!1,children:c,expanded:!0})))}else aN(b=>ep(b,a.path,a=>({...a,expanded:!0})))}async function cT(a){if("file"===a.type&&cY.getState().push({path:a.path,name:a.name},V),bh({path:a.path,name:a.name,size:a.size,nodeType:"app"===a.type?"app":"node-app"===a.type?"node-app":"file"}),bX(!1),b0(!1),b4(null),bO(null),bR(0),"file"===a.type&&ei(a.name)){bV(!0);try{await c8.useEditorStore.getState().loadPage(a.path)}finally{bV(!1)}return}if(["editor","text"].includes(ef(a.name,a.type))||eh(a.name)){bV(!0);try{let b=await (0,Y.wsFetch)(`/api/wiki/content?path=${encodeURIComponent(a.path)}`);if(b.ok){let a=await b.json();bO(a.content),bR(Number(b.headers.get("X-Wiki-Revision")??0))}}catch{}bV(!1)}}(0,T.useEffect)(()=>{bg&&ei(bg.name)&&c8.useEditorStore.getState().currentPath!==bg.path&&c8.useEditorStore.getState().loadPage(bg.path)},[bg]),(0,T.useEffect)(()=>{b8.current=bg},[bg]),(0,T.useEffect)(()=>{ca.current=bW},[bW]),(0,T.useEffect)(()=>{cb.current=cQ},[cQ]),(0,T.useEffect)(()=>{if(!d)return;let a=new Map,b=new EventSource((0,Y.withWs)("/api/wiki/watch"));return b.onmessage=b=>{var c;let d;try{d=JSON.parse(b.data)}catch{return}let{type:e,path:f}=d,g=f.split("/");if(c=g.length>1?g.slice(0,-1).join("/"):"",a.has(c)&&clearTimeout(a.get(c)),a.set(c,setTimeout(()=>{a.delete(c),cd(c)},300)),"change"===e&&b8.current?.path===f&&!ca.current){let b=`__file__${f}`;a.has(b)&&clearTimeout(a.get(b)),a.set(b,setTimeout(()=>{a.delete(b),cb.current()},400))}},()=>{for(let c of(b.close(),a.values()))clearTimeout(c)}},[d,cd]),(0,T.useEffect)(()=>{bl(!1)},[]);let cU=(0,T.useCallback)(a=>{let b=a.split("/").pop()??a;cc(a),cT({path:a,name:b,type:"file"})},[cc]),cV=(0,T.useCallback)(async a=>{let b=a.path.split("/").slice(0,-1).join("/"),c=(await el(b)).find(b=>b.path===a.path);if(c){if("dir"===c.type){await cc(a.path),await cS(c);return}if("app"===c.type||"node-app"===c.type){await cc(c.path),cT({path:c.path,name:c.name,type:c.type,modifiedAt:c.modifiedAt}),await cS(c),bu&&bw(!0);return}cT({path:c.path,name:c.name,type:c.type,modifiedAt:c.modifiedAt}),bu&&bw(!0)}},[bu,cT,cc,cS]);(0,T.useEffect)(()=>{if(!aA||bg&&bg.path===aA)return;let a=aA.split("/").pop()??aA;cT({path:aA,name:a,type:"file"})},[aA]);let cW=(0,T.useCallback)(async a=>{if(!a)return void bh(null);let b=a.split("/"),c=b[b.length-1],d=b.slice(0,-1).join("/"),e=(await el(d)).find(b=>b.path===a);e&&(await cc(a),cT({path:a,name:c,type:e.type,modifiedAt:e.modifiedAt}))},[cc]);(0,T.useEffect)(()=>{},[bg]),(0,T.useEffect)(()=>{},[cW]),(0,T.useEffect)(()=>{aL.current||aO&&(aL.current=!0,cW(aK.current))},[aO,cW]);let cX=(0,T.useCallback)(async a=>{if(a===V)return;try{await fetch(`/api/system/workspaces/${a}/open`,{method:"POST"})}catch{}let b=new URL(location.href);b.searchParams.set("ws",a),b.searchParams.delete("path"),history.pushState(null,"",b.toString()),bh(null),bO(null),bX(!1),aN([]),aP(!1),aS.current=!1,d7.useWikiSlugsStore.getState().invalidate();let c=$.find(b=>b.id===a);c&&O(c.rootDir),X(a)},[V,$]),c$=(0,T.useCallback)(async()=>{if(al)try{if(!(await fetch(`/api/system/workspaces/${al}`,{method:"DELETE"})).ok)throw Error("Failed");if(al===V){let a=$.filter(a=>a.id!==al);if(a.length>0){let b=[...a].sort((a,b)=>(b.lastOpenedAt??b.createdAt).localeCompare(a.lastOpenedAt??a.createdAt))[0];await cX(b.id)}else j(!1)}await az()}catch{}finally{am(null)}},[al,V,$,cX,az]),c0=(0,T.useCallback)(async a=>{if(!an){ao(a);try{let b=await fetch(`/api/system/workspaces/${a}/refresh`,{method:"POST"});if(!b.ok){let a=await b.json();(0,b_.showError)(a.error??"Refresh failed")}await az()}catch{(0,b_.showError)("Refresh failed")}finally{ao(null)}}},[an,az]),c1=(0,T.useCallback)(async a=>{if(!ap[a])try{let b=await fetch(`/api/system/workspaces/${a}/branch`);if(!b.ok)return;let c=await b.json();aq(b=>({...b,[a]:c.branches??[]}))}catch{}},[ap]),c2=(0,T.useCallback)(async(a,b)=>{if(!ar){as(a),au(b);try{let c=await fetch(`/api/system/workspaces/${a}/branch`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:b})});if(!c.ok){let a=await c.json();(0,b_.showError)(a.error??"Branch switch failed");return}(0,b_.showSuccess)(`Switched to ${b}`),aw(null),ay(null),await az()}catch{(0,b_.showError)("Branch switch failed")}finally{as(null),au(null)}}},[ar,az]);async function c3(){if(!bg)return;b2(!0),b4(null);let a=await (0,Y.wsFetch)("/api/wiki/content",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:bg.path,content:bY,baseRevision:bP})});if(a.ok){let b=await a.json();"number"==typeof b.revision&&bR(b.revision),bO(bY),bX(!1)}else b4((await a.json()).error??"Save failed");b2(!1)}let c4=(0,T.useCallback)(async(a,b)=>{let c=Array.from(a);if(c.length){aW(!0),aY(null);try{for(let a of c){let c=new FormData;c.append("file",a),c.append("dir",b);let d=await (0,Y.wsFetch)("/api/wiki/upload",{method:"POST",body:c});if(!d.ok){let a=await d.json();aY(a.error??"Upload failed"),(0,b_.showError)(a.error??"Upload failed");break}}await cd(b)}catch{aY("Upload failed.")}finally{aW(!1),aZ.current&&(aZ.current.value="")}}},[cd]);function c5(a){a$.current=a,aZ.current?.click()}async function c6(){let a=a1.trim();if(!a||null===a_)return;a4(null);let b=a_?`${a_}/${a}`:a,c=await (0,Y.wsFetch)("/api/wiki/folder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:b})});c.ok?(a0(null),a2(""),await cd(a_),""!==a_&&aN(a=>ep(a,a_,a=>({...a,expanded:!0})))):a4((await c.json()).error??"Failed")}async function c7(){let a=a7.trim();if(!a||null===a5)return;ba(null);let b=a.includes(".")?a:`${a}.md`,c=a5?`${a5}/${b}`:b,d=await (0,Y.wsFetch)("/api/wiki/new-file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:c})});d.ok?(a6(null),a8(""),await cd(a5),""!==a5&&aN(a=>ep(a,a5,a=>({...a,expanded:!0}))),cT({path:c,name:b,type:"file",modifiedAt:new Date().toISOString()})):ba((await d.json()).error??"Failed")}function c9(a){navigator.clipboard.writeText(a),(0,b_.showSuccess)("Path copied")}function da(a){let b=a.replace(/\.(md|markdown)$/i,"");navigator.clipboard.writeText(`[[${b}]]`),(0,b_.showSuccess)("Wiki link copied")}function db(a){let b=new URL(location.href);b.searchParams.set("path",a),V&&b.searchParams.set("ws",V),navigator.clipboard.writeText(b.toString()),(0,b_.showSuccess)("URL copied")}async function dc(a){if(bg?.path===a&&null!==bN)return bN;if(c8.useEditorStore.getState().currentPath===a)return c8.useEditorStore.getState().content;let b=await (0,Y.wsFetch)(`/api/wiki/content?path=${encodeURIComponent(a)}`);if(!b.ok)throw Error("Cannot copy content");return(await b.json()).content}async function dd(a){try{let b=await dc(a);await navigator.clipboard.writeText(b),(0,b_.showSuccess)("Raw content copied")}catch{(0,b_.showError)("Could not copy file content")}}async function de(a,b){try{let c=await dc(a);if(!ei(b)){await navigator.clipboard.writeText(c),(0,b_.showSuccess)("Content copied");return}let d=await (0,be.markdownToHtml)(c,{pagePath:a,sanitize:!0});"ClipboardItem"in window&&navigator.clipboard.write?await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([d],{type:"text/html"}),"text/plain":new Blob([c],{type:"text/plain"})})]):await navigator.clipboard.writeText(c),(0,b_.showSuccess)("Formatted content copied")}catch{(0,b_.showError)("Could not copy formatted content")}}function df(a,c){return(0,b.jsxs)(bJ.DropdownMenu,{children:[(0,b.jsx)(bJ.DropdownMenuTrigger,{asChild:!0,children:(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"File actions",children:(0,b.jsx)(B,{className:"h-3.5 w-3.5"})})}),(0,b.jsxs)(bJ.DropdownMenuContent,{align:"end",className:"w-52",children:[(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>c9(a.path),children:[(0,b.jsx)(i.Copy,{className:"mr-2 h-3.5 w-3.5"}),"Copy path"]}),ei(a.name)&&(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>da(a.name),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy wiki link"]}),(0,b.jsx)(bJ.DropdownMenuSeparator,{}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>db(a.path),children:[(0,b.jsx)(y.Link,{className:"mr-2 h-3.5 w-3.5"}),"Copy URL"]}),eh(a.name)&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(bJ.DropdownMenuSeparator,{}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>void dd(a.path),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy raw content"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>void de(a.path,a.name),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy formatted content"]})]}),c&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(bJ.DropdownMenuSeparator,{}),c]})]})]})}async function dh(){bb&&(await (0,Y.wsFetch)("/api/wiki",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:bb})}),(bg?.path===bb||bg?.path.startsWith(`${bb}/`))&&(bh(null),bO(null)),aN(a=>(function a(b,c){return b.filter(a=>a.path!==c).map(b=>b.children?{...b,children:a(b.children,c)}:b)})(a,bb)),bc(null))}function di(a,b,c){a.preventDefault(),a.stopPropagation();let d=b5.current;if(!d){Array.from(a.dataTransfer.types).includes("Files")&&(a.dataTransfer.dropEffect="copy",b7("root"===c?"":b));return}d.path===b||b.startsWith(`${d.path}/`)||(a.dataTransfer.dropEffect="move",b7("root"===c?"":b))}async function dj(a,b){a.preventDefault(),a.stopPropagation(),b7(null);let c=b5.current;if(b5.current=null,!c){a.dataTransfer.files.length>0&&await c4(a.dataTransfer.files,b);return}if(c.path===b||b.startsWith(`${c.path}/`))return;let d=b?`${b}/${c.name}`:c.name;if(d!==c.path&&(await (0,Y.wsFetch)("/api/wiki/move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({from:c.path,to:d})})).ok){let a=c.path.includes("/")?c.path.split("/").slice(0,-1).join("/"):"";await cd(a),b!==a&&await cd(b),bg?.path===c.path&&bh({path:d,name:c.name,nodeType:bg.nodeType,size:bg.size})}}let dk=bg?ef(bg.name,bg.nodeType):null,dl=!!bg&&null!==dk&&!ed.has(dk)&&(bg.size??0)>5242880&&bi!==bg.path,dm=(0,d2.useViewWidthStore)(a=>a.width),dn=(0,d2.useViewWidthStore)(a=>a.align),dp=(0,d2.useViewWidthStore)(a=>a.setWidth),dq=(0,d2.useViewWidthStore)(a=>a.setAlign),dr=null===dk||"editor"===dk||"text"===dk||"source"===dk||"notebook"===dk||"fallback"===dk,ds=dr?d2.VIEW_WIDTH_CLASS[dm]:"",dt=dr?d2.VIEW_ALIGN_CLASS[dn]:"",du=(0,T.useRef)(null);du.current={toggleFolder:a=>void cS(a),openViewer:a=>void cT(a),copyPath:c9,copyWikiLink:da,copyUrl:db,copyRawContent:a=>void dd(a),copyFormattedContent:(a,b)=>void de(a,b),handleDownload:function(a){let b=(0,Y.withWs)(`/api/wiki/download?path=${encodeURIComponent(a.path)}`),c=document.createElement("a");c.href=b,c.download="file"===a.type?a.name:`${a.name}.zip`,document.body.appendChild(c),c.click(),c.remove()},triggerUpload:c5,handleCreateFile:()=>void c7(),handleCreateFolder:()=>void c6(),handleDragStart:function(a,b){b5.current=b,a.dataTransfer.effectAllowed="move",a.dataTransfer.setData("text/plain",b.path)},handleDragOver:di,handleDropOnFolder:(a,b)=>void dj(a,b),handleGitPull:(a,b)=>void cI(a,b),handleCheckout:(a,b,c)=>void cN(a,b,c),loadBranches:a=>void cM(a),prefetch:a=>{"file"===a.type?ei(a.name)&&(0,c8.prefetchPage)(a.path):function(a){if(em.has(a)||en.has(a))return;let b=el(a).then(b=>(em.set(a,b),b)).finally(()=>en.delete(a));en.set(a,b),b.catch(()=>{})}(a.path)},togglePin:(a,b)=>cZ.getState().toggle({path:a.path,name:a.name,type:a.type},b),setDragOverPath:b7,setSidebarCollapsed:bw,setBranchDropdownNode:cD,setBranchDropdownPos:cG,setNewFileParent:a6,setNewFileName:a8,setFileCreateError:ba,setNewFolderParent:a0,setNewFolderName:a2,setFolderError:a4,setDeletingPath:bc,setDeletingIsDir:bf};let dv=(0,T.useMemo)(()=>({toggleFolder:a=>du.current.toggleFolder(a),openViewer:a=>du.current.openViewer(a),copyPath:a=>du.current.copyPath(a),copyWikiLink:a=>du.current.copyWikiLink(a),copyUrl:a=>du.current.copyUrl(a),copyRawContent:a=>du.current.copyRawContent(a),copyFormattedContent:(a,b)=>du.current.copyFormattedContent(a,b),handleDownload:a=>du.current.handleDownload(a),triggerUpload:a=>du.current.triggerUpload(a),handleCreateFile:()=>du.current.handleCreateFile(),handleCreateFolder:()=>du.current.handleCreateFolder(),handleDragStart:(a,b)=>du.current.handleDragStart(a,b),handleDragOver:(a,b,c)=>du.current.handleDragOver(a,b,c),handleDropOnFolder:(a,b)=>du.current.handleDropOnFolder(a,b),handleGitPull:(a,b)=>du.current.handleGitPull(a,b),handleCheckout:(a,b,c)=>du.current.handleCheckout(a,b,c),loadBranches:a=>du.current.loadBranches(a),prefetch:a=>du.current.prefetch(a),togglePin:(a,b)=>du.current.togglePin(a,b),setDragOverPath:a=>du.current.setDragOverPath(a),setSidebarCollapsed:a=>du.current.setSidebarCollapsed(a),setBranchDropdownNode:a=>du.current.setBranchDropdownNode(a),setBranchDropdownPos:a=>du.current.setBranchDropdownPos(a),setNewFileParent:a=>du.current.setNewFileParent(a),setNewFileName:a=>du.current.setNewFileName(a),setFileCreateError:a=>du.current.setFileCreateError(a),setNewFolderParent:a=>du.current.setNewFolderParent(a),setNewFolderName:a=>du.current.setNewFolderName(a),setFolderError:a=>du.current.setFolderError(a),setDeletingPath:a=>du.current.setDeletingPath(a),setDeletingIsDir:a=>du.current.setDeletingIsDir(a)}),[]);return(0,b.jsxs)("div",{className:"flex h-screen gap-0 overflow-hidden bg-background",children:[null===d&&(0,b.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,b.jsx)(z.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),!1===d&&(0,b.jsx)(bQ,{onSelect:a=>{let b=new URL(location.href);b.searchParams.set("ws",a),b.searchParams.delete("path"),history.replaceState(null,"",b.toString()),aP(!1),aS.current=!1,X(a),j(!0),az()}}),!0===d&&af&&(0,b.jsxs)("div",{className:"flex-1 flex flex-col",children:[(0,b.jsx)("div",{className:"flex items-center justify-end border-b px-3 py-2 bg-muted shrink-0",children:(0,b.jsxs)(U.Button,{size:"sm",variant:"ghost",className:"h-7 gap-1.5 text-xs",onClick:()=>aj(!1),children:[(0,b.jsx)(S.X,{className:"h-3.5 w-3.5"})," Cancel"]})}),(0,b.jsx)(bQ,{onSelect:a=>{aj(!1),az(),cX(a)}})]}),!0===d&&!af&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(d4,{onOpenFile:cU,onToggleSidebar:()=>bw(a=>{let b=!a;return bu&&!1===b&&c_.useAIPanelStore.getState().close(),b}),onNewFile:()=>a6(""),onCopyPath:()=>{bg&&navigator.clipboard.writeText(bg.path)}}),!bv&&bu&&(0,b.jsx)("div",{className:"fixed inset-0 z-40 bg-overlay backdrop-blur-[1px] md:hidden",onClick:()=>bw(!0),"aria-hidden":!0}),!bv&&(0,b.jsxs)(cw.Card,{style:bu?void 0:{width:bx},className:"fixed inset-y-0 left-0 z-50 w-[85vw] max-w-[20rem] md:relative md:z-auto md:w-auto md:max-w-none flex flex-col shrink-0 overflow-hidden rounded-none border-r border-l-0 border-t-0 border-b-0",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between gap-2 px-3 py-2 border-b bg-muted shrink-0",children:[(0,b.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5",children:[(0,b.jsx)("img",{src:"/logo.svg",alt:"Wiki Viewer",className:"h-5 w-5 shrink-0"}),(0,b.jsx)("span",{className:"truncate text-xs font-semibold leading-5 tracking-tight translate-y-[0.5px]",children:"Wiki Viewer"})]}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0 shrink-0",title:"Collapse sidebar",onClick:()=>bw(!0),children:(0,b.jsx)(D,{className:"h-3.5 w-3.5"})})]}),(0,b.jsxs)("div",{className:"flex items-center justify-between gap-1 px-3 py-1.5 border-b bg-muted/50 shrink-0",children:[(0,b.jsxs)(bJ.DropdownMenu,{children:[(0,b.jsx)(bJ.DropdownMenuTrigger,{asChild:!0,children:(0,b.jsxs)(U.Button,{size:"sm",variant:"ghost",className:"h-7 gap-1 px-2 text-xs",disabled:aV,children:[aV?(0,b.jsx)(z.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):(0,b.jsx)(J,{className:"h-3.5 w-3.5"}),"New",(0,b.jsx)(g.ChevronDown,{className:"h-3 w-3 opacity-60"})]})}),(0,b.jsxs)(bJ.DropdownMenuContent,{align:"start",className:"w-44",children:[(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>{a6(""),a8(""),ba(null)},children:[(0,b.jsx)(m.FilePlus,{className:"mr-2 h-3.5 w-3.5"}),"New file"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>{a0(""),a2(""),a4(null)},children:[(0,b.jsx)(q,{className:"mr-2 h-3.5 w-3.5"}),"New folder"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>c5(""),disabled:aV,children:[(0,b.jsx)(R.Upload,{className:"mr-2 h-3.5 w-3.5"}),"Upload"]})]})]}),(0,b.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Refresh tree",onClick:cP,disabled:aT,children:aT?(0,b.jsx)(z.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):(0,b.jsx)(K,{className:"h-3.5 w-3.5"})}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"AI Agent panel",onClick:()=>{c_.useAIPanelStore.getState().toggle(),bu&&bw(!0)},children:(0,b.jsx)(e,{className:"h-3.5 w-3.5"})}),(0,b.jsxs)(bJ.DropdownMenu,{children:[(0,b.jsx)(bJ.DropdownMenuTrigger,{asChild:!0,children:(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"More actions",children:(0,b.jsx)(B,{className:"h-3.5 w-3.5"})})}),(0,b.jsxs)(bJ.DropdownMenuContent,{align:"end",className:"w-48",children:[aa&&$.find(a=>a.id===V)?.git&&(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>{V&&c0(V)},disabled:an===V,children:[an===V?(0,b.jsx)(z.Loader2,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):(0,b.jsx)(k,{className:"mr-2 h-3.5 w-3.5"}),"Pull latest"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d8.getState().toggle(),children:[by?(0,b.jsx)(H,{className:"mr-2 h-3.5 w-3.5"}):(0,b.jsx)(G.Eye,{className:"mr-2 h-3.5 w-3.5"}),by?"Hide hidden files":"Show hidden files"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d9.getState().toggle(),children:[(0,b.jsx)(P.Type,{className:"mr-2 h-3.5 w-3.5"}),bz?"Raw file names":"Humanize names"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>bB("dark"===bA?"light":"dark"),children:["dark"===bA?(0,b.jsx)(N.Sun,{className:"mr-2 h-3.5 w-3.5"}):(0,b.jsx)(C.Moon,{className:"mr-2 h-3.5 w-3.5"}),"dark"===bA?"Light mode":"Dark mode"]}),(0,b.jsx)(bJ.DropdownMenuSeparator,{}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>bI(!0),children:[(0,b.jsx)(L,{className:"mr-2 h-3.5 w-3.5"}),"Settings"]})]})]})]})]}),aX&&(0,b.jsxs)("div",{className:"flex items-center gap-1.5 px-3 py-1.5 text-xs text-destructive bg-destructive/10 shrink-0",children:[(0,b.jsx)(c.AlertCircle,{className:"h-3.5 w-3.5 shrink-0"}),aX]}),""===a_&&(0,b.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 border-b shrink-0",children:[(0,b.jsx)(o.Folder,{className:"h-4 w-4 shrink-0 text-warning"}),(0,b.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"Folder name",value:a1,onChange:a=>a2(a.target.value),onKeyDown:a=>{"Enter"===a.key&&c6(),"Escape"===a.key&&(a0(null),a2(""))}}),a3&&(0,b.jsx)("span",{className:"text-xs text-destructive",children:a3}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:c6,children:(0,b.jsx)(f.Check,{className:"h-3 w-3"})}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{a0(null),a2("")},children:(0,b.jsx)(S.X,{className:"h-3 w-3"})})]}),""===a5&&(0,b.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 border-b shrink-0",children:[(0,b.jsx)(n.FileText,{className:"h-4 w-4 shrink-0 text-accent"}),(0,b.jsx)("input",{autoFocus:!0,className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"filename (default .md)",value:a7,onChange:a=>a8(a.target.value),onKeyDown:a=>{"Enter"===a.key&&c7(),"Escape"===a.key&&(a6(null),a8(""))}}),a9&&(0,b.jsx)("span",{className:"text-xs text-destructive",children:a9}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:c7,children:(0,b.jsx)(f.Check,{className:"h-3 w-3"})}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{a6(null),a8("")},children:(0,b.jsx)(S.X,{className:"h-3 w-3"})})]}),(0,b.jsx)("div",{className:"border-b",children:(0,b.jsx)(d5,{onOpenFile:cU})}),(0,b.jsxs)("div",{ref:aH,className:(0,Z.cn)("flex-1 overflow-auto py-1 editorial-file-tree",""===b6&&"ring-2 ring-inset ring-primary bg-primary/5"),onDragOver:a=>di(a,"","root"),onDragLeave:a=>{a.currentTarget.contains(a.relatedTarget)||b7(null)},onDrop:a=>dj(a,""),children:[aG.length>0&&(0,b.jsxs)("div",{className:"border-b mb-1",children:[(0,b.jsxs)("button",{type:"button",className:"flex w-full items-center gap-1 px-2 py-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground hover:text-foreground",onClick:()=>aD(a=>!a),children:[aC?(0,b.jsx)(h.ChevronRight,{className:"h-3 w-3"}):(0,b.jsx)(g.ChevronDown,{className:"h-3 w-3"}),(0,b.jsx)(I,{className:"h-3 w-3"}),"Pinned",(0,b.jsx)("span",{className:"ml-auto text-[9px] tabular-nums opacity-60",children:aG.length})]}),!aC&&aG.map(a=>(0,b.jsxs)(cF,{children:[(0,b.jsx)(cH,{asChild:!0,children:(0,b.jsxs)("div",{role:"button",tabIndex:0,className:(0,Z.cn)("group flex items-center gap-1.5 rounded-sm px-2 py-1 text-sm cursor-pointer transition-colors select-none",bg?.path===a.path?"bg-accent-soft text-foreground font-medium":"hover:bg-muted"),onClick:()=>{cV(a)},onKeyDown:b=>{("Enter"===b.key||" "===b.key)&&(b.preventDefault(),cV(a))},children:[(0,b.jsx)(es,{name:a.name,type:a.type??"file"}),(0,b.jsx)("span",{className:"min-w-0 flex-1 truncate text-xs",title:bz?a.name:void 0,children:bz?ea(a.name):a.name}),(0,b.jsx)("span",{className:"max-w-[80px] truncate text-[10px] text-muted-foreground/60",children:a.path.split("/").slice(0,-1).join("/")}),(0,b.jsx)("button",{type:"button",className:"hover-reveal shrink-0 rounded p-0.5 text-muted-foreground/50 opacity-0 transition-colors hover:bg-muted hover:text-amber-400 group-hover:opacity-100 focus:opacity-100",title:"Remove from pinned",onClick:b=>{b.stopPropagation(),cZ.getState().toggle({path:a.path,name:a.name},V)},children:(0,b.jsx)(S.X,{className:"h-3 w-3"})})]})}),(0,b.jsx)(er,{node:{path:a.path,name:a.name,type:a.type??"file"},ctx:dv,isPinned:!0,activeWorkspaceId:V})]},a.path))]}),aB.length>0&&(0,b.jsxs)("div",{className:"border-b mb-1",children:[(0,b.jsxs)("button",{type:"button",className:"flex w-full items-center gap-1 px-2 py-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground hover:text-foreground",onClick:()=>aF(a=>!a),children:[aE?(0,b.jsx)(h.ChevronRight,{className:"h-3 w-3"}):(0,b.jsx)(g.ChevronDown,{className:"h-3 w-3"}),(0,b.jsx)(v,{className:"h-3 w-3"}),"Recent",(0,b.jsx)("span",{className:"ml-auto text-[9px] tabular-nums opacity-60",children:aB.length})]}),!aE&&aB.slice(0,8).map(a=>(0,b.jsxs)(cF,{children:[(0,b.jsx)(cH,{asChild:!0,children:(0,b.jsxs)("div",{role:"button",tabIndex:0,className:(0,Z.cn)("flex items-center gap-1.5 rounded-sm px-2 py-1 text-sm cursor-pointer transition-colors select-none",bg?.path===a.path?"bg-accent-soft text-foreground font-medium":"hover:bg-muted"),onClick:()=>{cT({path:a.path,name:a.name,type:a.type??"file",modifiedAt:""}),bu&&bw(!0)},onKeyDown:b=>{("Enter"===b.key||" "===b.key)&&(b.preventDefault(),cT({path:a.path,name:a.name,type:a.type??"file",modifiedAt:""}))},children:[(0,b.jsx)(es,{name:a.name,type:a.type??"file"}),(0,b.jsx)("span",{className:"flex-1 truncate text-xs",title:bz?a.name:void 0,children:bz?ea(a.name):a.name}),(0,b.jsx)("span",{className:"text-[10px] text-muted-foreground/60 truncate max-w-[80px]",children:a.path.split("/").slice(0,-1).join("/")})]})}),(0,b.jsx)(er,{node:{path:a.path,name:a.name,type:a.type??"file"},ctx:dv,isPinned:aG.some(b=>b.path===a.path),activeWorkspaceId:V})]},a.path))]}),aQ?(0,b.jsx)("div",{className:"flex justify-center py-6",children:(0,b.jsx)(z.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):0===aM.length?(0,b.jsxs)("div",{className:"flex flex-col items-center gap-3 px-4 py-8 text-center",children:[(0,b.jsx)("div",{className:"rounded-full bg-muted p-3",children:(0,b.jsx)(n.FileText,{className:"h-6 w-6 text-muted-foreground"})}),(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)("p",{className:"text-sm font-medium",children:"No files yet"}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:"Upload files or add them to the configured directory"})]}),(0,b.jsxs)(U.Button,{size:"sm",variant:"outline",className:"w-full gap-1.5 max-w-[180px]",onClick:()=>c5(""),disabled:aV,children:[aV?(0,b.jsx)(z.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):(0,b.jsx)(R.Upload,{className:"h-3.5 w-3.5"}),"Upload Files"]})]}):(0,b.jsx)(eu,{ctx:dv,nodes:aM,openPath:bg?.path??null,dragOverPath:b6,branchDropdownNode:cC,branchDropdownPos:cE,nodeBranches:cu,branchesLoading:cy,checkingOutBranch:cA,pullingRepo:ce,activePaths:aJ,pins:aG,isMobile:bu,activeWorkspaceId:V,newFileParent:a5,newFileName:a7,fileCreateError:a9,newFolderParent:a_,newFolderName:a1,folderError:a3,sidebarScrollRef:aH})]}),(0,b.jsxs)("div",{className:"border-t px-2 py-2 bg-muted shrink-0",children:[(0,b.jsxs)(bJ.DropdownMenu,{modal:!1,onOpenChange:a=>{a||(aw(null),ay(null))},children:[(0,b.jsx)(bJ.DropdownMenuTrigger,{asChild:!0,children:(0,b.jsxs)(U.Button,{size:"sm",variant:"ghost",className:"w-full h-auto justify-between gap-2 px-2 py-1.5 text-left",title:p??"",children:[(0,b.jsxs)("span",{className:"flex flex-col min-w-0",children:[(0,b.jsx)("span",{className:"truncate text-xs font-medium",children:$.find(a=>a.id===V)?.name??"Workspace"}),(0,b.jsx)("span",{className:"truncate text-[10px] text-muted-foreground font-mono",children:p??""})]}),(0,b.jsx)(g.ChevronDown,{className:"h-3.5 w-3.5 shrink-0 opacity-60"})]})}),(0,b.jsxs)(bJ.DropdownMenuContent,{align:"start",className:"w-[var(--radix-dropdown-menu-trigger-width)]",onInteractOutside:a=>{a.target?.closest?.("[data-branch-portal]")&&a.preventDefault()},children:[$.map(a=>(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>void cX(a.id),onPointerMove:a=>a.preventDefault(),onPointerLeave:a=>a.preventDefault(),className:(0,Z.cn)("gap-2",a.id===V&&"font-medium"),children:[a.id===V?(0,b.jsx)(f.Check,{className:"h-3.5 w-3.5 shrink-0"}):(0,b.jsx)("span",{className:"w-3.5 shrink-0"}),(0,b.jsxs)("span",{className:"flex flex-col min-w-0 flex-1",children:[(0,b.jsxs)("span",{className:"flex items-center gap-1.5 truncate",children:[(0,b.jsx)("span",{className:"truncate",children:a.name}),a.git?aa?(0,b.jsxs)("button",{"data-branch-trigger":!0,type:"button",className:"inline-flex items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground font-normal shrink-0 hover:bg-accent",title:"Switch branch",disabled:ar===a.id,onClick:b=>{if(b.stopPropagation(),b.preventDefault(),av===a.id){aw(null),ay(null);return}let c=b.currentTarget.getBoundingClientRect();ay({top:c.bottom+4,left:c.left}),aw(a.id),c1(a.id)},children:[(0,b.jsx)(r,{className:"h-2.5 w-2.5"})," ",a.git.branch??"branch"]}):(0,b.jsxs)("span",{className:"inline-flex items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground font-normal shrink-0",children:[(0,b.jsx)(r,{className:"h-2.5 w-2.5"})," ",a.git.branch??"read-only"]}):a.ssh?(0,b.jsxs)("span",{className:"inline-flex items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground font-normal shrink-0",children:[(0,b.jsx)(s,{className:"h-2.5 w-2.5"})," ",a.ssh.host]}):a.readOnly?(0,b.jsxs)("span",{className:"inline-flex items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground font-normal shrink-0",children:[(0,b.jsx)(r,{className:"h-2.5 w-2.5"})," read-only"]}):null]}),(0,b.jsx)("span",{className:"truncate text-[10px] text-muted-foreground font-mono",children:a.rootDir}),a.git?.lastPulledAt&&ec(a.git.lastPulledAt)&&(0,b.jsxs)("span",{className:"text-[10px] text-muted-foreground/70",children:["synced ",ec(a.git.lastPulledAt)]})]}),aa&&a.git&&(0,b.jsx)("button",{className:(0,Z.cn)("shrink-0 rounded p-0.5 hover:bg-accent transition-colors",a.git.lastError?"text-destructive":"text-muted-foreground hover:text-foreground"),title:a.git.lastError?`Last refresh failed: ${a.git.lastError}`:"Refresh",disabled:an===a.id,onClick:b=>{b.stopPropagation(),b.preventDefault(),c0(a.id)},children:(0,b.jsx)(K,{className:(0,Z.cn)("h-3.5 w-3.5",an===a.id&&"animate-spin")})}),aa&&(0,b.jsx)("button",{className:"shrink-0 rounded p-0.5 text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors",title:"Delete workspace (does not delete files)",onClick:b=>{b.stopPropagation(),am(a.id)},children:(0,b.jsx)(Q.Trash2,{className:"h-3.5 w-3.5"})})]},a.id)),aa&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(bJ.DropdownMenuSeparator,{}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>aj(!0),children:[(0,b.jsx)(q,{className:"mr-2 h-3.5 w-3.5"}),"Add workspace…"]})]})]})]}),(()=>{if(!av||!ax)return null;let a=$.find(a=>a.id===av);return a?(0,b.jsx)(bS,{pos:ax,branches:(ap[a.id]??[]).map(b=>({name:b,current:b===a.git?.branch})),loading:!ap[a.id],busyName:ar===a.id?at:null,disabled:ar===a.id,onPick:b=>{c2(a.id,b)},onClose:()=>{aw(null),ay(null)}}):null})()]}),(0,b.jsx)("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize sidebar",title:"Drag to resize",onMouseDown:a=>{a.preventDefault();let b=a.clientX;bF(!0);let c=document.body.style.cursor,d=document.body.style.userSelect;document.body.style.cursor="col-resize",document.body.style.userSelect="none";let e=a=>{bC(bx+(a.clientX-b))},f=()=>{bF(!1),document.body.style.cursor=c,document.body.style.userSelect=d,window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",f)};window.addEventListener("mousemove",e),window.addEventListener("mouseup",f)},onDoubleClick:()=>bC(288),onKeyDown:a=>{"ArrowLeft"===a.key?(a.preventDefault(),bC(bx-16)):"ArrowRight"===a.key&&(a.preventDefault(),bC(bx+16))},tabIndex:0,"aria-valuemin":200,"aria-valuemax":600,"aria-valuenow":bx,className:(0,Z.cn)("absolute right-0 top-0 z-20 h-full w-1.5 cursor-col-resize -mr-px transition-colors hover:bg-primary/40 focus:bg-primary/40 focus:outline-none hidden md:block",bD&&"bg-primary/60")})]}),(0,b.jsxs)("div",{className:"flex-1 flex flex-col min-w-0 relative",children:[bv&&(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"hidden md:flex absolute left-2 top-2 z-10 h-7 w-7 p-0",title:"Show sidebar",onClick:()=>bw(!1),children:(0,b.jsx)(E,{className:"h-3.5 w-3.5"})}),(0,b.jsxs)("div",{className:"md:hidden flex h-11 shrink-0 items-center justify-between gap-2 border-b bg-muted px-1",children:[(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-9 w-9 p-0",title:"Show sidebar",onClick:()=>{bw(!1),c_.useAIPanelStore.getState().close()},children:(0,b.jsx)(E,{className:"h-4 w-4"})}),(0,b.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5 text-xs font-semibold tracking-tight text-muted-foreground",title:bg?.path,children:[bg&&(0,b.jsx)("span",{className:"editorial-tree-typeicon shrink-0",children:"app"===dk||"html"===dk?(0,b.jsx)(u.Globe,{className:"h-4 w-4 text-foreground/70"}):ej(bg.name)?(0,b.jsx)(x.default,{className:"h-4 w-4 text-sunshine-700"}):eh(bg.name)?(0,b.jsx)(n.FileText,{className:"h-4 w-4 text-foreground/70"}):(0,b.jsx)(l.File,{className:"h-4 w-4 text-foreground/60"})}),(0,b.jsx)("span",{className:"truncate",children:bg?bg.name:"Wiki Viewer"})]}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-9 w-9 p-0",title:"AI Agent panel",onClick:()=>{c_.useAIPanelStore.getState().open(),bw(!0)},children:(0,b.jsx)(e,{className:"h-4 w-4"})})]}),bg?"node-app"===dk?(0,b.jsx)(bL,{path:bg.path,title:bg.name}):"app"===dk||"html"===dk?(a="html"===dk?`/api/assets/${bg.path}`:void 0,bk?(0,b.jsx)(bG,{path:bg.path,title:bg.name,src:a,fullscreen:!0,onExit:()=>bl(!1)}):(0,b.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-w-0",children:[(0,b.jsxs)("div",{className:(0,Z.cn)("flex items-center justify-between px-4 py-2 border-b bg-muted shrink-0 editorial-doc-header",!bu&&bv&&"pl-11"),children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,b.jsx)("span",{className:"hidden md:inline-flex",children:(0,b.jsx)("span",{className:"editorial-tree-typeicon",children:(0,b.jsx)(u.Globe,{className:"h-4 w-4 shrink-0 text-foreground/70"})})}),(0,b.jsx)("span",{className:"hidden md:inline text-sm font-normal truncate",title:bg.path,children:bg.path})]}),(0,b.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[df(bg,(0,b.jsxs)(b.Fragment,{children:["html"===dk&&!bW&&(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>b0(a=>!a),children:[b$?(0,b.jsx)(u.Globe,{className:"mr-2 h-3.5 w-3.5"}):(0,b.jsx)(t.Code2,{className:"mr-2 h-3.5 w-3.5"}),b$?"Show preview":"Show source"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>bo(a=>a+1),children:[(0,b.jsx)(K,{className:"mr-2 h-3.5 w-3.5"}),"Refresh"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>bl(!0),children:[(0,b.jsx)(A,{className:"mr-2 h-3.5 w-3.5"}),"Open fullscreen"]})]})),"html"===dk&&!bW&&null!==bN&&(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Edit source",onClick:()=>{bX(!0),bZ(bN),b4(null)},children:(0,b.jsx)(F,{className:"h-3.5 w-3.5"})}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{bh(null),bX(!1)},children:(0,b.jsx)(S.X,{className:"h-3.5 w-3.5"})})]})]}),bW&&"html"===dk?(0,b.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:[(0,b.jsx)("textarea",{value:bY,onChange:a=>bZ(a.target.value),spellCheck:!1,className:"flex-1 w-full min-h-0 resize-none bg-background text-foreground px-4 py-3 font-mono text-[13px] leading-relaxed outline-none border-0"}),(0,b.jsxs)("div",{className:"border-t px-4 py-2 flex items-center justify-end gap-2 bg-muted shrink-0",children:[b3&&(0,b.jsx)("span",{className:"text-xs text-destructive mr-auto",children:b3}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",onClick:()=>{bX(!1),b4(null)},children:"Cancel"}),(0,b.jsxs)(U.Button,{size:"sm",className:"gap-1",onClick:c3,disabled:b1,children:[b1&&(0,b.jsx)(z.Loader2,{className:"h-3 w-3 animate-spin"}),"Save"]})]})]}):b$&&"html"===dk?(0,b.jsx)(bE,{path:bg.path,title:bg.name}):(0,b.jsx)(bG,{path:bg.path,title:bg.name,src:a},bm)]})):(0,b.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-w-0",children:[(0,b.jsxs)("div",{className:(0,Z.cn)("flex items-center justify-between px-4 py-2 border-b bg-muted shrink-0 editorial-doc-header",!bu&&bv&&"pl-11"),children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,b.jsx)("span",{className:"hidden md:inline-flex",children:(0,b.jsx)("span",{className:"editorial-tree-typeicon",children:ej(bg.name)?(0,b.jsx)(x.default,{className:"h-4 w-4 shrink-0 text-sunshine-700"}):eh(bg.name)?(0,b.jsx)(n.FileText,{className:"h-4 w-4 shrink-0 text-foreground/70"}):(0,b.jsx)(l.File,{className:"h-4 w-4 shrink-0 text-foreground/60"})})}),(0,b.jsx)("span",{className:"hidden md:inline text-sm font-normal truncate",title:bg.path,children:bg.path}),cg&&(0,b.jsxs)("span",{className:"hidden md:flex items-center gap-1 text-[11px] text-muted-foreground shrink-0 ml-1",children:[(0,b.jsx)(w,{className:"h-3 w-3 shrink-0"}),(0,b.jsx)("span",{className:"truncate max-w-[100px]",children:cg.author}),(0,b.jsx)("span",{title:new Date(cg.date).toLocaleString(),className:"shrink-0",children:ec(cg.date)})]})]}),(0,b.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[df(bg,(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>{ci?cj(!1):cK()},children:[(0,b.jsx)(v,{className:"mr-2 h-3.5 w-3.5"}),ci?"Hide history":"File history"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>bM(!0),children:[(0,b.jsx)(M,{className:"mr-2 h-3.5 w-3.5"}),"Share"]}),!bW&&(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:cR,disabled:bU,children:[bU?(0,b.jsx)(z.Loader2,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):(0,b.jsx)(K,{className:"mr-2 h-3.5 w-3.5"}),"Refresh"]}),dr&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(bJ.DropdownMenuSeparator,{}),(0,b.jsx)(bJ.DropdownMenuLabel,{className:"text-[11px] text-muted-foreground",children:"Width"}),d2.VIEW_WIDTH_ORDER.map(a=>(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>dp(a),className:"flex items-center justify-between text-xs",children:[d2.VIEW_WIDTH_LABEL[a],a===dm&&(0,b.jsx)(f.Check,{className:"h-3.5 w-3.5"})]},a)),(0,b.jsx)(bJ.DropdownMenuSeparator,{}),(0,b.jsx)(bJ.DropdownMenuLabel,{className:"text-[11px] text-muted-foreground",children:"Alignment"}),d2.VIEW_ALIGN_ORDER.map(a=>(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>dq(a),className:"flex items-center justify-between text-xs",children:[d2.VIEW_ALIGN_LABEL[a],a===dn&&(0,b.jsx)(f.Check,{className:"h-3.5 w-3.5"})]},a))]})]})),eh(bg.name)&&!bW&&(null!==bN||ei(bg.name))&&(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{bX(!0),bZ(bN??""),b4(null),ei(bg.name)&&c8.useEditorStore.getState().loadPage(bg.path)},children:(0,b.jsx)(F,{className:"h-3.5 w-3.5"})}),eh(bg.name)&&bW&&ei(bg.name)&&(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Done editing",onClick:()=>{bX(!1),b4(null)},children:(0,b.jsx)(G.Eye,{className:"h-3.5 w-3.5"})}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{bh(null),bO(null),bX(!1)},children:(0,b.jsx)(S.X,{className:"h-3.5 w-3.5"})})]})]}),ci&&(0,b.jsxs)("div",{className:"border-b bg-muted/30 shrink-0 max-h-[40vh] overflow-auto",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between px-4 py-1.5 border-b",children:[(0,b.jsx)("span",{className:"text-xs font-semibold text-muted-foreground",children:"History"}),(0,b.jsx)("button",{type:"button",className:"text-muted-foreground hover:text-foreground",onClick:()=>cj(!1),children:(0,b.jsx)(S.X,{className:"h-3.5 w-3.5"})})]}),cm?(0,b.jsx)("div",{className:"flex justify-center py-4",children:(0,b.jsx)(z.Loader2,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):0===ck.length?(0,b.jsx)("p",{className:"px-4 py-3 text-xs text-muted-foreground",children:"No history found."}):(0,b.jsx)("div",{children:ck.map(a=>(0,b.jsxs)("div",{children:[(0,b.jsx)("button",{type:"button",className:(0,Z.cn)("w-full text-left px-4 py-2 hover:bg-muted transition-colors",co===a.sha&&"bg-muted"),onClick:()=>void cL(a.sha),children:(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("code",{className:"text-[11px] font-mono text-muted-foreground shrink-0",children:a.shortSha}),(0,b.jsx)("span",{className:"flex-1 truncate text-xs",children:a.message}),(0,b.jsx)("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:a.author}),(0,b.jsx)("span",{className:"shrink-0 text-[11px] text-muted-foreground",title:new Date(a.date).toLocaleString(),children:ec(a.date)})]})}),co===a.sha&&(0,b.jsx)("div",{className:"border-t",children:cs?(0,b.jsx)("div",{className:"flex justify-center py-3",children:(0,b.jsx)(z.Loader2,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):null!==cq?(0,b.jsx)("pre",{className:"overflow-auto px-4 py-2 text-[11px] font-mono leading-relaxed whitespace-pre text-foreground/80 max-h-60",children:cq}):null})]},a.sha))})]}),dl?(0,b.jsx)(ag,{path:bg.path,size:bg.size??0,onOpen:()=>bj(bg.path)}):bW?(0,b.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:ei(bg.name)?(0,b.jsx)(ac.KBEditor,{}):(0,b.jsx)("textarea",{value:bY,onChange:a=>bZ(a.target.value),spellCheck:!1,className:"flex-1 w-full min-h-0 resize-none bg-background text-foreground px-4 py-3 font-mono text-[13px] leading-relaxed outline-none border-0"})}):ei(bg.name)?(0,b.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:bU?(0,b.jsx)("div",{className:"flex justify-center py-8",children:(0,b.jsx)(z.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):(0,b.jsx)(ac.KBEditor,{mode:"viewing"})}):"csv"===dk||"pdf"===dk||"mermaid"===dk||"notebook"===dk||"image"===dk||"media"===dk||"docx"===dk||"xlsx"===dk||"pptx"===dk||"source"===dk||"fallback"===dk?(0,b.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:bU?(0,b.jsx)("div",{className:"flex justify-center py-8",children:(0,b.jsx)(z.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):"csv"===dk?(0,b.jsx)(ab,{path:bg.path,title:bg.name}):"pdf"===dk?(0,b.jsx)(eb,{path:bg.path,title:bg.name}):"mermaid"===dk?(0,b.jsx)(ak,{path:bg.path,title:bg.name}):"notebook"===dk?(0,b.jsx)(bn,{path:bg.path,title:bg.name}):"image"===dk?(0,b.jsx)(ah,{path:bg.path,title:bg.name}):"media"===dk?(0,b.jsx)(ai,{path:bg.path,title:bg.name,type:["mp4","webm","mov","m4v"].includes(ee(bg.name))?"video":"audio"}):"docx"===dk?(0,b.jsx)(bp,{path:bg.path,title:bg.name}):"xlsx"===dk?(0,b.jsx)(br,{path:bg.path,title:bg.name}):"pptx"===dk?(0,b.jsx)(bq,{path:bg.path,title:bg.name}):"source"===dk?(0,b.jsx)(bE,{path:bg.path,title:bg.name}):(0,b.jsx)(ad,{path:bg.path,title:bg.name})},bs):(0,b.jsx)("div",{className:"flex-1 overflow-auto p-4 min-h-0",children:(0,b.jsx)("div",{className:(0,Z.cn)("w-full",dt,ds),children:bU?(0,b.jsx)("div",{className:"flex justify-center py-8",children:(0,b.jsx)(z.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):null!==bN?(0,b.jsx)("pre",{className:"text-xs font-mono whitespace-pre-wrap break-words leading-relaxed",children:bN}):eh(bg.name)?(0,b.jsx)("p",{className:"text-sm text-muted-foreground",children:"Could not load file."}):(0,b.jsx)("p",{className:"text-sm text-muted-foreground",children:"Preview not available for this file type."})})}),bW&&!ei(bg.name)&&(0,b.jsxs)("div",{className:"border-t px-4 py-2 flex items-center justify-end gap-2 bg-muted shrink-0",children:[b3&&(0,b.jsx)("span",{className:"text-xs text-destructive mr-auto",children:b3}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",onClick:()=>{bX(!1),b4(null)},children:"Cancel"}),(0,b.jsxs)(U.Button,{size:"sm",className:"gap-1",onClick:c3,disabled:b1,children:[b1&&(0,b.jsx)(z.Loader2,{className:"h-3 w-3 animate-spin"}),"Save"]})]})]}):(0,b.jsx)("div",{className:"flex-1 flex flex-col items-center justify-center",children:(0,b.jsxs)("div",{className:"flex flex-col items-center gap-2 text-center px-4",children:[(0,b.jsx)(n.FileText,{className:"h-8 w-8 text-muted-foreground"}),(0,b.jsx)("p",{className:"text-sm text-muted-foreground",children:"Select a file to view or edit"})]})})]}),(0,b.jsx)(cv,{open:bK,onOpenChange:bM,filePath:bg?.path??""}),(0,b.jsx)(b9,{open:bH,onOpenChange:bI}),(0,b.jsx)(dg,{currentPath:bg?.path}),(0,b.jsx)("input",{ref:aZ,type:"file",multiple:!0,className:"hidden",onChange:a=>{a.target.files&&c4(a.target.files,a$.current)}}),(0,b.jsx)(W,{open:!!bb,onOpenChange:a=>{a||bc(null)},title:bd?"Delete folder?":"Delete file?",description:bd?`"${bb?.split("/").pop()}" and all its contents will be permanently deleted.`:`"${bb?.split("/").pop()}" will be permanently removed.`,onConfirm:dh}),(0,b.jsx)(W,{open:!!al,onOpenChange:a=>{a||am(null)},title:"Delete workspace?",description:`"${$.find(a=>a.id===al)?.name??""}" will be removed from the workspace list. Files on disk are NOT deleted.`,onConfirm:c$})]})]},V??"none")}],240777)}];
17
+ ${b}/api/agent/files/${a??"<path/to/file.md>"}`;await navigator.clipboard.writeText(d),c(!0),setTimeout(()=>c(!1),1500)},[a])}}(a??null),[m,n]=(0,T.useState)(""),o=(0,T.useRef)(null),p="http://localhost:3000",q=(0,T.useCallback)(()=>de,[]),r=(0,T.useCallback)(()=>m.replace(/\$WIKI_URL/g,p),[m,p]),s=(0,T.useCallback)(()=>`npx wiki-viewer-mcp register --url ${p} --id ai:myagent --name "My Agent"`,[p]),t=(0,T.useCallback)(()=>JSON.stringify({servers:{"wiki-viewer":{command:"npx",args:["wiki-viewer-mcp"],env:{WIKI_VIEWER_URL:p,WIKI_VIEWER_TOKEN:"<token from register>",WIKI_VIEWER_AGENT_ID:"ai:myagent"}}}},null,2),[p]),u=df(q),v=df(r),w=df(s),x=df(t);return((0,T.useEffect)(()=>{if(c)return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a);function a(a){"Escape"===a.key&&d()}},[c,d]),(0,T.useEffect)(()=>{c&&o.current?.focus()},[c]),(0,T.useEffect)(()=>{if(!c)return;j();let a=setInterval(()=>void j(),1e4);return()=>clearInterval(a)},[c,j]),(0,T.useEffect)(()=>{c&&fetch("/api/agents/install").then(a=>a.json()).then(a=>{a.bootstrapPrompt&&n(a.bootstrapPrompt)}).catch(()=>void 0)},[c]),c)?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("div",{className:"fixed inset-0 z-40 bg-overlay backdrop-blur-[1px]",onClick:d,"aria-hidden":!0}),(0,b.jsxs)("aside",{ref:o,tabIndex:-1,role:"dialog","aria-modal":"true","aria-label":"AI Agent Panel",className:"fixed right-0 top-0 bottom-0 z-50 flex w-[90vw] max-w-sm md:w-80 flex-col border-l border-border bg-background shadow-xl outline-none",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between border-b border-border px-4 py-3 shrink-0",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)(e,{className:"h-4 w-4 text-muted-foreground"}),(0,b.jsx)("span",{className:"text-sm font-semibold",children:"AI Agent"})]}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:d,title:"Close panel (Esc)",children:(0,b.jsx)(S.X,{className:"h-3.5 w-3.5"})})]}),(0,b.jsxs)("div",{className:"flex-1 overflow-y-auto space-y-5 px-4 py-4",children:[(0,b.jsxs)("section",{className:"rounded-md border border-border bg-muted/30 p-3",children:[(0,b.jsx)("p",{className:"text-sm font-medium text-foreground",children:"Work with this wiki using AI"}),(0,b.jsxs)("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:["Connect Claude, Cursor, ChatGPT, and more. Pick by what you want — each option gives a copy-paste setup. You approve every assistant in ",(0,b.jsx)("span",{className:"font-medium text-foreground/80",children:"Agents"})," below before it gets access."]})]}),(0,b.jsxs)("section",{className:"space-y-3",children:[(0,b.jsxs)("div",{className:"rounded-md border border-border bg-muted/40 p-3 space-y-1.5",children:[(0,b.jsx)("p",{className:"text-xs font-semibold text-foreground",children:"Co-write docs with you"}),(0,b.jsx)("p",{className:"text-[10px] text-muted-foreground/70",children:"Edits arrive as suggestions with comments you accept or revert. No MCP needed."}),(0,b.jsx)(U.Button,{size:"sm",variant:"outline",className:"h-7 w-full text-xs gap-1.5",onClick:()=>void v.copy(),disabled:!m,children:v.copied?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(f.Check,{className:"h-3.5 w-3.5 text-green-500"})," Copied!"]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(i.Copy,{className:"h-3.5 w-3.5"})," Paste into any chatbot"]})}),(0,b.jsxs)("p",{className:"text-[10px] text-muted-foreground/50 pt-1",children:["Or install once so it sticks"," ",(0,b.jsx)("span",{className:"text-muted-foreground/40",children:"· Claude, OpenCode"}),":"]}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("code",{className:"flex-1 text-[10px] font-mono text-foreground/80 truncate bg-muted rounded px-1 py-0.5",children:de}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 shrink-0",title:"Copy this command",onClick:()=>void u.copy(),children:u.copied?(0,b.jsx)(f.Check,{className:"h-3.5 w-3.5 text-green-500"}):(0,b.jsx)(i.Copy,{className:"h-3.5 w-3.5"})})]})]}),(0,b.jsxs)("div",{className:"rounded-md border border-border bg-muted/40 p-3 space-y-1.5",children:[(0,b.jsxs)("p",{className:"text-xs font-semibold text-foreground",children:["Edit files directly"," ",(0,b.jsx)("span",{className:"font-normal text-muted-foreground/60",children:"· Claude Code, Cursor, Codex"})]}),(0,b.jsx)("p",{className:"text-[10px] text-muted-foreground/70",children:"Native read / search / edit tools over MCP. Run to request access:"}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("code",{className:"flex-1 text-[10px] font-mono text-foreground/80 truncate bg-muted rounded px-1 py-0.5",children:s()}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 shrink-0",title:"Copy this command",onClick:()=>void w.copy(),children:w.copied?(0,b.jsx)(f.Check,{className:"h-3.5 w-3.5 text-green-500"}):(0,b.jsx)(i.Copy,{className:"h-3.5 w-3.5"})})]}),(0,b.jsxs)("p",{className:"text-[10px] text-muted-foreground/50",children:["Approve in ",(0,b.jsx)("span",{className:"font-medium text-foreground/70",children:"Agents"}),", then add to your tool:"]}),(0,b.jsx)(U.Button,{size:"sm",variant:"outline",className:"h-7 w-full text-xs gap-1.5",onClick:()=>void x.copy(),children:x.copied?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(f.Check,{className:"h-3.5 w-3.5 text-green-500"})," Copied!"]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(i.Copy,{className:"h-3.5 w-3.5"})," Copy config (mcp.json)"]})})]}),(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[(0,b.jsx)("span",{className:"text-[10px] text-muted-foreground/50",children:"For developers:"}),(0,b.jsxs)("button",{type:"button",onClick:()=>void l(),className:"inline-flex items-center gap-1 text-[10px] text-primary hover:underline",children:[k?(0,b.jsx)(f.Check,{className:"h-3 w-3 text-green-500"}):(0,b.jsx)(i.Copy,{className:"h-3 w-3"})," curl example"]}),(0,b.jsxs)("a",{href:"/api/agents/skill",target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-[10px] text-primary hover:underline",children:[(0,b.jsx)(ae.ExternalLink,{className:"h-3 w-3"})," skill"]}),(0,b.jsxs)("a",{href:"/api/agents/install",target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-[10px] text-primary hover:underline",children:[(0,b.jsx)(ae.ExternalLink,{className:"h-3 w-3"})," install JSON"]})]})]}),(0,b.jsx)(c7,{}),(0,b.jsxs)("section",{className:"space-y-2",children:[(0,b.jsxs)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:["Active Connections"," ",(0,b.jsx)("span",{className:"normal-case font-normal text-muted-foreground/50",children:"(last 5 min)"})]}),(0,b.jsx)("div",{className:"rounded-md border border-border bg-muted/40 p-3",children:0===h.length?(0,b.jsxs)("p",{className:"text-xs text-muted-foreground/60 flex items-center gap-1.5",children:[(0,b.jsx)(c$,{className:"h-3.5 w-3.5"}),"No recent activity"]}):(0,b.jsx)("ul",{className:"space-y-1.5",children:h.map(a=>(0,b.jsxs)("li",{className:"flex items-center justify-between text-xs",children:[(0,b.jsx)("span",{className:"font-mono text-foreground/80 truncate",children:a.by}),(0,b.jsxs)("span",{className:"text-muted-foreground shrink-0",children:[a.opCount," op",1!==a.opCount?"s":""]})]},a.by))})})]}),(0,b.jsxs)("section",{className:"space-y-2",children:[(0,b.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:"Recent Activity"}),(0,b.jsx)("div",{className:"rounded-md border border-border bg-muted/40 px-3 py-2 max-h-72 overflow-y-auto",children:(0,b.jsx)(dd,{activity:g})})]}),(0,b.jsx)("section",{children:(0,b.jsx)("a",{href:"/docs/agent-collab-plan.md",target:"_blank",rel:"noreferrer",className:"text-xs text-primary underline hover:no-underline",children:"Agent collaboration docs →"})})]})]})]}):null}var dh=a.i(503442),di=a.i(670576),dj=/[\\\/_+.#"@\[\(\{&]/,dk=/[\\\/_+.#"@\[\(\{&]/g,dl=/[\s-]/,dm=/[\s-]/g;function dn(a){return a.toLowerCase().replace(dm," ")}var dp=a.i(105305),dq=a.i(359231),dr='[cmdk-group=""]',ds='[cmdk-group-items=""]',dt='[cmdk-item=""]',du=`${dt}:not([aria-disabled="true"])`,dv="cmdk-item-select",dw="data-value",dx=(a,b,c)=>{var d;return d=a,function a(b,c,d,e,f,g,h){if(g===c.length)return f===b.length?1:.99;var i=`${f},${g}`;if(void 0!==h[i])return h[i];for(var j,k,l,m,n=e.charAt(g),o=d.indexOf(n,f),p=0;o>=0;)(j=a(b,c,d,e,o+1,g+1,h))>p&&(o===f?j*=1:dj.test(b.charAt(o-1))?(j*=.8,(l=b.slice(f,o-1).match(dk))&&f>0&&(j*=Math.pow(.999,l.length))):dl.test(b.charAt(o-1))?(j*=.9,(m=b.slice(f,o-1).match(dm))&&f>0&&(j*=Math.pow(.999,m.length))):(j*=.17,f>0&&(j*=Math.pow(.999,o-f))),b.charAt(o)!==c.charAt(g)&&(j*=.9999)),(j<.1&&d.charAt(o-1)===e.charAt(g+1)||e.charAt(g+1)===e.charAt(g)&&d.charAt(o-1)!==e.charAt(g))&&.1*(k=a(b,c,d,e,o+1,g+2,h))>j&&(j=.1*k),j>p&&(p=j),o=d.indexOf(n,o+1);return h[i]=p,p}(d=c&&c.length>0?`${d+" "+c.join(" ")}`:d,b,dn(d),dn(b),0,0,{})},dy=T.createContext(void 0),dz=T.createContext(void 0),dA=T.createContext(void 0),dB=T.forwardRef((a,b)=>{let c=dL(()=>{var b,c;return{search:"",value:null!=(c=null!=(b=a.value)?b:a.defaultValue)?c:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),d=dL(()=>new Set),e=dL(()=>new Map),f=dL(()=>new Map),g=dL(()=>new Set),h=dJ(a),{label:i,children:j,value:k,onValueChange:l,filter:m,shouldFilter:n,loop:o,disablePointerSelection:p=!1,vimBindings:q=!0,...r}=a,s=(0,dq.useId)(),t=(0,dq.useId)(),u=(0,dq.useId)(),v=T.useRef(null),w=dO();dK(()=>{if(void 0!==k){let a=k.trim();c.current.value=a,x.emit()}},[k]),dK(()=>{w(6,D)},[]);let x=T.useMemo(()=>({subscribe:a=>(g.current.add(a),()=>g.current.delete(a)),snapshot:()=>c.current,setState:(a,b,d)=>{var e,f,g,i;if(!Object.is(c.current[a],b)){if(c.current[a]=b,"search"===a)C(),A(),w(1,B);else if("value"===a){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let a=document.getElementById(u);a?a.focus():null==(e=document.getElementById(s))||e.focus()}if(w(7,()=>{var a;c.current.selectedItemId=null==(a=E())?void 0:a.id,x.emit()}),d||w(5,D),(null==(f=h.current)?void 0:f.value)!==void 0){null==(i=(g=h.current).onValueChange)||i.call(g,null!=b?b:"");return}}x.emit()}},emit:()=>{g.current.forEach(a=>a())}}),[]),y=T.useMemo(()=>({value:(a,b,d)=>{var e;b!==(null==(e=f.current.get(a))?void 0:e.value)&&(f.current.set(a,{value:b,keywords:d}),c.current.filtered.items.set(a,z(b,d)),w(2,()=>{A(),x.emit()}))},item:(a,b)=>(d.current.add(a),b&&(e.current.has(b)?e.current.get(b).add(a):e.current.set(b,new Set([a]))),w(3,()=>{C(),A(),c.current.value||B(),x.emit()}),()=>{f.current.delete(a),d.current.delete(a),c.current.filtered.items.delete(a);let b=E();w(4,()=>{C(),(null==b?void 0:b.getAttribute("id"))===a&&B(),x.emit()})}),group:a=>(e.current.has(a)||e.current.set(a,new Set),()=>{f.current.delete(a),e.current.delete(a)}),filter:()=>h.current.shouldFilter,label:i||a["aria-label"],getDisablePointerSelection:()=>h.current.disablePointerSelection,listId:s,inputId:u,labelId:t,listInnerRef:v}),[]);function z(a,b){var d,e;let f=null!=(e=null==(d=h.current)?void 0:d.filter)?e:dx;return a?f(a,c.current.search,b):0}function A(){if(!c.current.search||!1===h.current.shouldFilter)return;let a=c.current.filtered.items,b=[];c.current.filtered.groups.forEach(c=>{let d=e.current.get(c),f=0;d.forEach(b=>{f=Math.max(a.get(b),f)}),b.push([c,f])});let d=v.current;F().sort((b,c)=>{var d,e;let f=b.getAttribute("id"),g=c.getAttribute("id");return(null!=(d=a.get(g))?d:0)-(null!=(e=a.get(f))?e:0)}).forEach(a=>{let b=a.closest(ds);b?b.appendChild(a.parentElement===b?a:a.closest(`${ds} > *`)):d.appendChild(a.parentElement===d?a:a.closest(`${ds} > *`))}),b.sort((a,b)=>b[1]-a[1]).forEach(a=>{var b;let c=null==(b=v.current)?void 0:b.querySelector(`${dr}[${dw}="${encodeURIComponent(a[0])}"]`);null==c||c.parentElement.appendChild(c)})}function B(){let a=F().find(a=>"true"!==a.getAttribute("aria-disabled")),b=null==a?void 0:a.getAttribute(dw);x.setState("value",b||void 0)}function C(){var a,b,g,i;if(!c.current.search||!1===h.current.shouldFilter){c.current.filtered.count=d.current.size;return}c.current.filtered.groups=new Set;let j=0;for(let e of d.current){let d=z(null!=(b=null==(a=f.current.get(e))?void 0:a.value)?b:"",null!=(i=null==(g=f.current.get(e))?void 0:g.keywords)?i:[]);c.current.filtered.items.set(e,d),d>0&&j++}for(let[a,b]of e.current)for(let d of b)if(c.current.filtered.items.get(d)>0){c.current.filtered.groups.add(a);break}c.current.filtered.count=j}function D(){var a,b,c;let d=E();d&&((null==(a=d.parentElement)?void 0:a.firstChild)===d&&(null==(c=null==(b=d.closest(dr))?void 0:b.querySelector('[cmdk-group-heading=""]'))||c.scrollIntoView({block:"nearest"})),d.scrollIntoView({block:"nearest"}))}function E(){var a;return null==(a=v.current)?void 0:a.querySelector(`${dt}[aria-selected="true"]`)}function F(){var a;return Array.from((null==(a=v.current)?void 0:a.querySelectorAll(du))||[])}function G(a){let b=F()[a];b&&x.setState("value",b.getAttribute(dw))}function H(a){var b;let c=E(),d=F(),e=d.findIndex(a=>a===c),f=d[e+a];null!=(b=h.current)&&b.loop&&(f=e+a<0?d[d.length-1]:e+a===d.length?d[0]:d[e+a]),f&&x.setState("value",f.getAttribute(dw))}function I(a){let b=E(),c=null==b?void 0:b.closest(dr),d;for(;c&&!d;)d=null==(c=a>0?function(a,b){let c=a.nextElementSibling;for(;c;){if(c.matches(b))return c;c=c.nextElementSibling}}(c,dr):function(a,b){let c=a.previousElementSibling;for(;c;){if(c.matches(b))return c;c=c.previousElementSibling}}(c,dr))?void 0:c.querySelector(du);d?x.setState("value",d.getAttribute(dw)):H(a)}let J=()=>G(F().length-1),K=a=>{a.preventDefault(),a.metaKey?J():a.altKey?I(1):H(1)},L=a=>{a.preventDefault(),a.metaKey?G(0):a.altKey?I(-1):H(-1)};return T.createElement(dp.Primitive.div,{ref:b,tabIndex:-1,...r,"cmdk-root":"",onKeyDown:a=>{var b;null==(b=r.onKeyDown)||b.call(r,a);let c=a.nativeEvent.isComposing||229===a.keyCode;if(!(a.defaultPrevented||c))switch(a.key){case"n":case"j":q&&a.ctrlKey&&K(a);break;case"ArrowDown":K(a);break;case"p":case"k":q&&a.ctrlKey&&L(a);break;case"ArrowUp":L(a);break;case"Home":a.preventDefault(),G(0);break;case"End":a.preventDefault(),J();break;case"Enter":{a.preventDefault();let b=E();if(b){let a=new Event(dv);b.dispatchEvent(a)}}}}},T.createElement("label",{"cmdk-label":"",htmlFor:y.inputId,id:y.labelId,style:dQ},i),dP(a,a=>T.createElement(dz.Provider,{value:x},T.createElement(dy.Provider,{value:y},a))))}),dC=T.forwardRef((a,b)=>{var c,d;let e=(0,dq.useId)(),f=T.useRef(null),g=T.useContext(dA),h=T.useContext(dy),i=dJ(a),j=null!=(d=null==(c=i.current)?void 0:c.forceMount)?d:null==g?void 0:g.forceMount;dK(()=>{if(!j)return h.item(e,null==g?void 0:g.id)},[j]);let k=dN(e,f,[a.value,a.children,f],a.keywords),l=T.useContext(dz),m=dM(a=>a.value&&a.value===k.current),n=dM(a=>!!j||!1===h.filter()||!a.search||a.filtered.items.get(e)>0);function o(){var a,b;p(),null==(b=(a=i.current).onSelect)||b.call(a,k.current)}function p(){l.setState("value",k.current,!0)}if(T.useEffect(()=>{let b=f.current;if(!(!b||a.disabled))return b.addEventListener(dv,o),()=>b.removeEventListener(dv,o)},[n,a.onSelect,a.disabled]),!n)return null;let{disabled:q,value:r,onSelect:s,forceMount:t,keywords:u,...v}=a;return T.createElement(dp.Primitive.div,{ref:(0,ce.composeRefs)(f,b),...v,id:e,"cmdk-item":"",role:"option","aria-disabled":!!q,"aria-selected":!!m,"data-disabled":!!q,"data-selected":!!m,onPointerMove:q||h.getDisablePointerSelection()?void 0:p,onClick:q?void 0:o},a.children)}),dD=T.forwardRef((a,b)=>{let{heading:c,children:d,forceMount:e,...f}=a,g=(0,dq.useId)(),h=T.useRef(null),i=T.useRef(null),j=(0,dq.useId)(),k=T.useContext(dy),l=dM(a=>!!e||!1===k.filter()||!a.search||a.filtered.groups.has(g));dK(()=>k.group(g),[]),dN(g,h,[a.value,a.heading,i]);let m=T.useMemo(()=>({id:g,forceMount:e}),[e]);return T.createElement(dp.Primitive.div,{ref:(0,ce.composeRefs)(h,b),...f,"cmdk-group":"",role:"presentation",hidden:!l||void 0},c&&T.createElement("div",{ref:i,"cmdk-group-heading":"","aria-hidden":!0,id:j},c),dP(a,a=>T.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":c?j:void 0},T.createElement(dA.Provider,{value:m},a))))}),dE=T.forwardRef((a,b)=>{let{alwaysRender:c,...d}=a,e=T.useRef(null),f=dM(a=>!a.search);return c||f?T.createElement(dp.Primitive.div,{ref:(0,ce.composeRefs)(e,b),...d,"cmdk-separator":"",role:"separator"}):null}),dF=T.forwardRef((a,b)=>{let{onValueChange:c,...d}=a,e=null!=a.value,f=T.useContext(dz),g=dM(a=>a.search),h=dM(a=>a.selectedItemId),i=T.useContext(dy);return T.useEffect(()=>{null!=a.value&&f.setState("search",a.value)},[a.value]),T.createElement(dp.Primitive.input,{ref:b,...d,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":i.listId,"aria-labelledby":i.labelId,"aria-activedescendant":h,id:i.inputId,type:"text",value:e?a.value:g,onChange:a=>{e||f.setState("search",a.target.value),null==c||c(a.target.value)}})}),dG=T.forwardRef((a,b)=>{let{children:c,label:d="Suggestions",...e}=a,f=T.useRef(null),g=T.useRef(null),h=dM(a=>a.selectedItemId),i=T.useContext(dy);return T.useEffect(()=>{if(g.current&&f.current){let a=g.current,b=f.current,c,d=new ResizeObserver(()=>{c=requestAnimationFrame(()=>{let c=a.offsetHeight;b.style.setProperty("--cmdk-list-height",c.toFixed(1)+"px")})});return d.observe(a),()=>{cancelAnimationFrame(c),d.unobserve(a)}}},[]),T.createElement(dp.Primitive.div,{ref:(0,ce.composeRefs)(f,b),...e,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":h,"aria-label":d,id:i.listId},dP(a,a=>T.createElement("div",{ref:(0,ce.composeRefs)(g,i.listInnerRef),"cmdk-list-sizer":""},a)))}),dH=T.forwardRef((a,b)=>{let{open:c,onOpenChange:d,overlayClassName:e,contentClassName:f,container:g,...h}=a;return T.createElement(bU.Root,{open:c,onOpenChange:d},T.createElement(bU.Portal,{container:g},T.createElement(bU.Overlay,{"cmdk-overlay":"",className:e}),T.createElement(bU.Content,{"aria-label":a.label,"cmdk-dialog":"",className:f},T.createElement(dB,{ref:b,...h}))))}),dI=Object.assign(dB,{List:dG,Item:dC,Input:dF,Group:dD,Separator:dE,Dialog:dH,Empty:T.forwardRef((a,b)=>dM(a=>0===a.filtered.count)?T.createElement(dp.Primitive.div,{ref:b,...a,"cmdk-empty":"",role:"presentation"}):null),Loading:T.forwardRef((a,b)=>{let{progress:c,children:d,label:e="Loading...",...f}=a;return T.createElement(dp.Primitive.div,{ref:b,...f,"cmdk-loading":"",role:"progressbar","aria-valuenow":c,"aria-valuemin":0,"aria-valuemax":100,"aria-label":e},dP(a,a=>T.createElement("div",{"aria-hidden":!0},a)))})});function dJ(a){let b=T.useRef(a);return dK(()=>{b.current=a}),b}var dK=T.useEffect;function dL(a){let b=T.useRef();return void 0===b.current&&(b.current=a()),b}function dM(a){let b=T.useContext(dz),c=()=>a(b.snapshot());return T.useSyncExternalStore(b.subscribe,c,c)}function dN(a,b,c,d=[]){let e=T.useRef(),f=T.useContext(dy);return dK(()=>{var g;let h=(()=>{var a;for(let b of c){if("string"==typeof b)return b.trim();if("object"==typeof b&&"current"in b)return b.current?null==(a=b.current.textContent)?void 0:a.trim():e.current}})(),i=d.map(a=>a.trim());f.value(a,h,i),null==(g=b.current)||g.setAttribute(dw,h),e.current=h}),e}var dO=()=>{let[a,b]=T.useState(),c=dL(()=>new Map);return dK(()=>{c.current.forEach(a=>a()),c.current=new Map},[a]),(a,d)=>{c.current.set(a,d),b({})}};function dP({asChild:a,children:b},c){let d;return a&&T.isValidElement(b)?T.cloneElement("function"==typeof(d=b.type)?d(b.props):"render"in d?d.render(b.props):b,{ref:b.ref},c(b.props.children)):c(b)}var dQ={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};let dR=(0,d.default)("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]),dS=T.forwardRef(({className:a,...c},d)=>(0,b.jsx)(dI,{ref:d,className:(0,Z.cn)("flex h-full w-full flex-col overflow-hidden rounded-sm bg-popover text-popover-foreground",a),...c}));function dT({children:a,shouldFilter:c,...d}){return(0,b.jsx)(V.Dialog,{...d,children:(0,b.jsxs)(V.DialogContent,{className:"overflow-hidden p-0 shadow-golden max-w-lg",children:[(0,b.jsx)(V.DialogTitle,{className:"sr-only",children:"Search"}),(0,b.jsx)(dS,{shouldFilter:c,className:"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-normal [&_[cmdk-group-heading]]:text-muted-foreground [&_[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:a})]})})}dS.displayName=dI.displayName;let dU=T.forwardRef(({className:a,...c},d)=>(0,b.jsxs)("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[(0,b.jsx)(dR,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),(0,b.jsx)(dI.Input,{ref:d,className:(0,Z.cn)("flex h-11 w-full rounded-sm bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",a),...c})]}));dU.displayName=dI.Input.displayName;let dV=T.forwardRef(({className:a,...c},d)=>(0,b.jsx)(dI.List,{ref:d,className:(0,Z.cn)("max-h-[300px] overflow-y-auto overflow-x-hidden",a),...c}));dV.displayName=dI.List.displayName;let dW=T.forwardRef((a,c)=>(0,b.jsx)(dI.Empty,{ref:c,className:"py-6 text-center text-sm text-muted-foreground",...a}));dW.displayName=dI.Empty.displayName;let dX=T.forwardRef(({className:a,...c},d)=>(0,b.jsx)(dI.Group,{ref:d,className:(0,Z.cn)("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-normal [&_[cmdk-group-heading]]:text-muted-foreground",a),...c}));dX.displayName=dI.Group.displayName;let dY=T.forwardRef(({className:a,...c},d)=>(0,b.jsx)(dI.Separator,{ref:d,className:(0,Z.cn)("-mx-1 h-px bg-border",a),...c}));dY.displayName=dI.Separator.displayName;let dZ=T.forwardRef(({className:a,...c},d)=>(0,b.jsx)(dI.Item,{ref:d,className:(0,Z.cn)("relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",a),...c}));dZ.displayName=dI.Item.displayName;let d$=null,d_=null,d0=(0,b1.create)(a=>({query:"",results:[],loading:!1,truncated:!1,open:!1,setQuery:b=>a({query:b}),setOpen:b=>a({open:b}),clear:()=>{d_&&clearTimeout(d_),d$?.abort(),a({query:"",results:[],loading:!1,truncated:!1})},search:b=>(d_&&clearTimeout(d_),b.trim())?(a({loading:!0}),new Promise(c=>{d_=setTimeout(()=>{d1(a,b).finally(c)},150)})):(d$?.abort(),a({results:[],loading:!1,truncated:!1}),Promise.resolve())}));async function d1(a,b){d$?.abort();let c=new AbortController;d$=c;try{let d=await (0,Y.wsFetch)("/api/wiki/search",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:b,limit:30}),signal:c.signal});if(!d.ok)return void a({results:[],loading:!1,truncated:!1});let e=await d.json();if(c.signal.aborted)return;a({results:e.matches??[],truncated:!!e.truncated,loading:!1})}catch(b){"AbortError"!==b.name&&a({loading:!1})}}var d2=a.i(713033);function d3({html:a}){let c=function(a){let b,c=[],d=/<mark>([\s\S]*?)<\/mark>/g,e=0;for(;null!==(b=d.exec(a));)b.index>e&&c.push({text:a.slice(e,b.index),mark:!1}),c.push({text:b[1]??"",mark:!0}),e=b.index+b[0].length;return e<a.length&&c.push({text:a.slice(e),mark:!1}),c}(a);return(0,b.jsx)(b.Fragment,{children:c.map((a,c)=>a.mark?(0,b.jsx)("mark",{className:"bg-yellow-200 dark:bg-yellow-700 rounded-[2px] px-[1px]",children:a.text},c):(0,b.jsx)("span",{children:a.text},c))})}function d4({onOpenFile:a,recents:c=[],onToggleSidebar:d=()=>void 0,onNewFile:f=()=>void 0,onCopyPath:g=()=>void 0}){let h=d0(a=>a.open),j=d0(a=>a.setOpen),k=d0(a=>a.query),l=d0(a=>a.setQuery),n=d0(a=>a.results),o=d0(a=>a.loading),p=d0(a=>a.truncated),q=d0(a=>a.search),{resolvedTheme:r,setTheme:s}=(0,bT.useTheme)(),t=(0,c_.useAIPanelStore)(a=>a.toggle),u=(0,d2.useViewWidthStore)(a=>a.width),v=(0,d2.useViewWidthStore)(a=>a.cycle),w=k.trimStart(),x=""===w||w.startsWith(">"),y=""===w&&c.length>0,z=x?"":k;function A(a){a(),j(!1),l("")}(0,T.useEffect)(()=>{function a(a){(a.metaKey||a.ctrlKey)&&"k"===a.key.toLowerCase()&&(a.preventDefault(),j(!h))}return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[h,j]),(0,T.useEffect)(()=>{if(!h||x)return;let a=setTimeout(()=>{q(z)},120);return()=>clearTimeout(a)},[z,x,h,q]);let B=(d2.VIEW_WIDTH_ORDER.indexOf(u)+1)%d2.VIEW_WIDTH_ORDER.length,D=d2.VIEW_WIDTH_LABEL[d2.VIEW_WIDTH_ORDER[B]];return(0,b.jsxs)(dT,{open:h,onOpenChange:a=>{j(a),a||l("")},shouldFilter:!1,children:[(0,b.jsx)(dU,{placeholder:"Search files… ( > for actions )",value:k,onValueChange:l}),(0,b.jsxs)(dV,{children:[y&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(dX,{heading:"Recent",children:c.map(c=>(0,b.jsxs)(dZ,{value:`recent:${c.path}`,onSelect:()=>{a(c.path),j(!1),l("")},children:[(0,b.jsx)(cb,{className:"mr-2 h-4 w-4"}),(0,b.jsxs)("div",{className:"flex min-w-0 flex-col gap-0.5",children:[(0,b.jsx)("span",{className:"truncate font-medium",children:c.name}),(0,b.jsx)("span",{className:"truncate text-xs text-muted-foreground",children:c.path})]})]},c.path))}),(0,b.jsx)(dY,{})]}),x&&(0,b.jsxs)(dX,{heading:"Actions",children:[(0,b.jsxs)(dZ,{value:"toggle-dark-mode",onSelect:()=>A(()=>s("dark"===r?"light":"dark")),children:["dark"===r?(0,b.jsx)(N.Sun,{className:"mr-2 h-4 w-4"}):(0,b.jsx)(C.Moon,{className:"mr-2 h-4 w-4"}),"dark"===r?"Switch to light mode":"Switch to dark mode"]}),(0,b.jsxs)(dZ,{value:"toggle-ai-panel",onSelect:()=>A(t),children:[(0,b.jsx)(e,{className:"mr-2 h-4 w-4"}),"Toggle AI panel"]}),(0,b.jsxs)(dZ,{value:"toggle-sidebar",onSelect:()=>A(d),children:[(0,b.jsx)(di.PanelLeft,{className:"mr-2 h-4 w-4"}),"Toggle sidebar"]}),(0,b.jsxs)(dZ,{value:"new-file",onSelect:()=>A(f),children:[(0,b.jsx)(m.FilePlus,{className:"mr-2 h-4 w-4"}),"New file"]}),(0,b.jsxs)(dZ,{value:"copy-path",onSelect:()=>A(g),children:[(0,b.jsx)(i.Copy,{className:"mr-2 h-4 w-4"}),"Copy current file path"]}),(0,b.jsxs)(dZ,{value:"cycle-view-width",onSelect:()=>A(v),children:[(0,b.jsx)(dh.AlignCenter,{className:"mr-2 h-4 w-4"}),(0,b.jsxs)("span",{children:["Change view width"," ",(0,b.jsxs)("span",{className:"text-muted-foreground",children:["(",d2.VIEW_WIDTH_LABEL[u]," → ",D,")"]})]})]})]}),!x&&(0,b.jsxs)(b.Fragment,{children:[o&&(0,b.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"Searching…"}),!o&&""!==z.trim()&&0===n.length&&(0,b.jsx)(dW,{children:"No matches."}),n.length>0&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(dY,{}),(0,b.jsx)(dX,{heading:p?"Top results (refine query for more)":"Results",children:n.map(c=>(0,b.jsx)(dZ,{value:c.path,onSelect:()=>{a(c.path),j(!1),l("")},children:(0,b.jsxs)("div",{className:"flex min-w-0 flex-col gap-0.5",children:[(0,b.jsx)("span",{className:"truncate font-mono text-xs",children:c.path}),c.snippet&&(0,b.jsx)("span",{className:"truncate text-xs text-muted-foreground",children:(0,b.jsx)(d3,{html:c.snippet})})]})},c.path))})]})]})]})]})}function d5({onOpenFile:a}){let c=d0(a=>a.query),d=d0(a=>a.setQuery),e=d0(a=>a.results),f=d0(a=>a.loading),g=d0(a=>a.search),h=d0(a=>a.clear),[i,j]=(0,T.useState)(0),k=(0,T.useRef)(null);function l(b){let c=e[b];c&&(a(c.path),h())}return(0,T.useEffect)(()=>{j(0)},[e]),(0,T.useEffect)(()=>{let a=k.current?.querySelector(`[data-idx="${i}"]`);a?.scrollIntoView({block:"nearest"})},[i]),(0,b.jsxs)("div",{className:"flex flex-col gap-1 px-2 py-1.5",children:[(0,b.jsxs)("div",{className:"relative",children:[(0,b.jsx)(dR,{className:"pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 opacity-50"}),(0,b.jsx)("input",{type:"text",className:"w-full rounded-sm border bg-transparent py-1 pl-7 pr-2 text-xs outline-none focus:ring-1 focus:ring-ring",placeholder:"Search… (⌘K)",value:c,onChange:a=>{d(a.target.value),g(a.target.value)},onKeyDown:a=>{"Escape"===a.key?h():0!==e.length&&("ArrowDown"===a.key?(a.preventDefault(),j(a=>(a+1)%e.length)):"ArrowUp"===a.key?(a.preventDefault(),j(a=>(a-1+e.length)%e.length)):"Enter"===a.key&&(a.preventDefault(),l(i)))}})]}),""!==c.trim()&&(0,b.jsxs)("div",{ref:k,className:"max-h-64 overflow-y-auto rounded-sm border bg-popover",children:[f&&(0,b.jsx)("div",{className:"px-2 py-1 text-xs text-muted-foreground",children:"Searching…"}),!f&&0===e.length&&(0,b.jsx)("div",{className:"px-2 py-1 text-xs text-muted-foreground",children:"No matches"}),e.map((a,c)=>(0,b.jsxs)("button",{type:"button","data-idx":c,onClick:()=>l(c),onMouseEnter:()=>j(c),className:`block w-full px-2 py-1 text-left ${c===i?"bg-accent":"hover:bg-accent"}`,children:[(0,b.jsx)("div",{className:"truncate font-mono text-xs",children:a.path}),a.snippet&&(0,b.jsx)("div",{className:"truncate text-[10px] text-muted-foreground",children:(0,b.jsx)(d3,{html:a.snippet})})]},a.path))]})]})}let d6=(0,b1.create)(a=>({width:288,setWidth:b=>{a({width:Number.isNaN(b)?288:Math.min(600,Math.max(200,Math.round(b)))})}}));var d7=a.i(256233);let d8=(0,b1.create)((a,b)=>({showHidden:!1,toggle:()=>{a({showHidden:!b().showHidden})}})),d9=(0,b1.create)((a,b)=>({humanize:!1,toggle:()=>{a({humanize:!b().humanize})}}));function ea(a){let b=a.lastIndexOf("."),c=b>0&&b<a.length-1,d=c?a.slice(0,b):a,e=c?a.slice(b):"",f=d.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").split(/[\s_-]+/).filter(Boolean).map(a=>/^[A-Z0-9]+$/.test(a)?a:a[0].toUpperCase()+a.slice(1));return f.length?f.join(" ")+e:a}let eb=(0,bs.default)(async()=>{},{loadableGenerated:{modules:[904378]},ssr:!1});function ec(a){let b=new Date(a).getTime();if(!Number.isFinite(b))return"";let c=Math.floor(Math.max(0,Date.now()-b)/1e3);if(c<60)return"just now";let d=Math.floor(c/60);if(d<60)return`${d}m ago`;let e=Math.floor(d/60);return e<24?`${e}h ago`:`${Math.floor(e/24)}d ago`}let ed=new Set(["image","media","pdf","fallback","app","node-app","html"]);function ee(a){return a.split(".").pop()?.toLowerCase()??""}function ef(a,b){if("node-app"===b)return"node-app";if("app"===b)return"app";if("dir"===b)return"fallback";let c=a.split("/").pop()??a;if(c.startsWith(".")&&-1===c.indexOf(".",1))return"source";let d=ee(a);return d?["md","markdown"].includes(d)?"editor":"txt"===d?"text":["csv","tsv"].includes(d)?"csv":"pdf"===d?"pdf":["mmd","mermaid"].includes(d)?"mermaid":"ipynb"===d?"notebook":["png","jpg","jpeg","gif","webp","svg","avif","ico","bmp"].includes(d)?"image":["mp4","webm","mov","m4v","mp3","wav","ogg","m4a","aac"].includes(d)?"media":"docx"===d?"docx":["xlsx","xlsm"].includes(d)?"xlsx":"pptx"===d?"pptx":"html"===d?"html":(["py","js","ts","tsx","jsx","go","rs","java","c","cpp","h","sh","bash","zsh","rb","php","swift","kt","lua","sql","yaml","yml","toml","json","xml","css","scss"].includes(d),"source"):"source"}let eg=new Set(["txt","md","markdown","json","yaml","yml","toml","csv","tsv","xml","html","css","js","ts","tsx","jsx","sh","bash","zsh","rb","py","go","rs","java","c","cpp","h","php","swift","kt","lua","sql","scss","mmd","mermaid","ini","env","log","conf"]);function eh(a){let b=ef(a,"file");return"editor"===b||"text"===b||eg.has(ee(a))}function ei(a){return["md","markdown"].includes(ee(a))}function ej(a){return"image"===ef(a,"file")}function ek(a){return"html"===ef(a,"file")}async function el(a){let b=await (0,Y.wsFetch)(`/api/wiki?dir=${encodeURIComponent(a)}`);return b.ok?(await b.json()).entries.map(b=>({name:b.name,path:a?`${a}/${b.name}`:b.name,type:b.type,size:b.size,modifiedAt:b.modifiedAt,expanded:!1,git:b.git})):[]}let em=new Map,en=new Map;async function eo(a){let b=em.get(a);if(b)return em.delete(a),b;let c=en.get(a);if(c){let b=await c;return em.delete(a),b}return null}function ep(a,b,c){return a.map(a=>a.path===b?c(a):a.children?{...a,children:ep(a.children,b,c)}:a)}let eq={contentVisibility:"auto",containIntrinsicSize:"auto 32px"};function er({node:a,ctx:c,isPinned:d,activeWorkspaceId:e}){return(0,b.jsxs)(cV,{className:"w-48",children:[(0,b.jsxs)(cW,{onSelect:()=>c.copyPath(a.path),children:[(0,b.jsx)(i.Copy,{className:"mr-2 h-3.5 w-3.5"}),"Copy path"]}),ei(a.name)&&(0,b.jsxs)(cW,{onSelect:()=>c.copyWikiLink(a.name),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy wiki link"]}),(0,b.jsxs)(cW,{onSelect:()=>c.copyUrl(a.path),children:[(0,b.jsx)(y.Link,{className:"mr-2 h-3.5 w-3.5"}),"Copy URL"]}),"file"===a.type&&eh(a.name)&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(cW,{onSelect:()=>c.copyRawContent(a.path),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy raw content"]}),(0,b.jsxs)(cW,{onSelect:()=>c.copyFormattedContent(a.path,a.name),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy formatted content"]})]}),(0,b.jsx)(cX,{}),"dir"===a.type&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(cW,{onSelect:()=>{a.expanded||c.toggleFolder(a),c.setNewFileParent(a.path),c.setNewFileName(""),c.setFileCreateError(null)},children:[(0,b.jsx)(m.FilePlus,{className:"mr-2 h-3.5 w-3.5"}),"New file here"]}),(0,b.jsxs)(cW,{onSelect:()=>c.triggerUpload(a.path),children:[(0,b.jsx)(R.Upload,{className:"mr-2 h-3.5 w-3.5"}),"Upload here"]}),(0,b.jsxs)(cW,{onSelect:()=>{c.setNewFolderParent(a.path),c.setNewFolderName(""),c.setFolderError(null)},children:[(0,b.jsx)(q,{className:"mr-2 h-3.5 w-3.5"}),"New subfolder"]}),(0,b.jsx)(cX,{})]}),(0,b.jsxs)(cW,{onSelect:()=>c.handleDownload(a),children:[(0,b.jsx)(j,{className:"mr-2 h-3.5 w-3.5"}),"file"===a.type?"Download":"Download as zip"]}),(0,b.jsxs)(cW,{onSelect:()=>c.togglePin(a,e),children:[(0,b.jsx)(I,{className:(0,Z.cn)("mr-2 h-3.5 w-3.5",d&&"fill-current text-amber-400")}),d?"Unpin":"Pin to top"]}),(0,b.jsx)(cX,{}),(0,b.jsxs)(cW,{className:"text-destructive focus:text-destructive",onSelect:()=>{c.setDeletingPath(a.path),c.setDeletingIsDir("file"!==a.type)},children:[(0,b.jsx)(Q.Trash2,{className:"mr-2 h-3.5 w-3.5"}),"Delete"]})]})}function es({name:a,type:c}){let d="h-3.5 w-3.5 shrink-0";return"dir"===c?(0,b.jsx)(o.Folder,{className:(0,Z.cn)(d,"text-warning")}):"app"===c?(0,b.jsx)(u.Globe,{className:(0,Z.cn)(d,"text-foreground/70")}):"node-app"===c?(0,b.jsx)(O,{className:(0,Z.cn)(d,"text-emerald-500")}):ek(a)?(0,b.jsx)(u.Globe,{className:(0,Z.cn)(d,"text-foreground/60")}):ej(a)?(0,b.jsx)(x.default,{className:(0,Z.cn)(d,"text-sunshine-700")}):eh(a)?(0,b.jsx)(n.FileText,{className:(0,Z.cn)(d,"text-foreground/70")}):(0,b.jsx)(l.File,{className:(0,Z.cn)(d,"text-foreground/60")})}let et=(0,T.memo)(function({node:a,depth:c,ctx:d,isMobile:e,activeWorkspaceId:f,sidebarScrollRef:g,isActive:k,isDragOver:s,isPinned:t,isAgentActive:v,isPulling:w,branchOpen:A,branchPos:C,branches:D,branchLoading:E,checkingOut:F,onHoverEnter:G,onHoverLeave:H}){let J=d9(a=>a.humanize);return(0,b.jsxs)(cF,{children:[(0,b.jsx)(cH,{asChild:!0,children:(0,b.jsxs)("div",{role:"treeitem",tabIndex:0,draggable:!e,onKeyDown:b=>{if("Enter"===b.key||" "===b.key)b.preventDefault(),"dir"===a.type?d.toggleFolder(a):"app"===a.type||"node-app"===a.type?(d.openViewer(a),d.toggleFolder(a)):d.openViewer(a);else if("ArrowDown"===b.key){b.preventDefault();let a=g.current;if(!a)return;let c=Array.from(a.querySelectorAll('[role="treeitem"]')),d=c.indexOf(b.currentTarget);c[d+1]?.focus()}else if("ArrowUp"===b.key){b.preventDefault();let a=g.current;if(!a)return;let c=Array.from(a.querySelectorAll('[role="treeitem"]')),d=c.indexOf(b.currentTarget);c[d-1]?.focus()}else if("ArrowRight"===b.key){if(b.preventDefault(),"dir"===a.type||"app"===a.type||"node-app"===a.type)if(a.expanded){let a=g.current;if(!a)return;let c=Array.from(a.querySelectorAll('[role="treeitem"]')),d=c.indexOf(b.currentTarget);c[d+1]?.focus()}else d.toggleFolder(a)}else if("ArrowLeft"===b.key){if(b.preventDefault(),("dir"===a.type||"app"===a.type||"node-app"===a.type)&&a.expanded)d.toggleFolder(a);else if(c>0){let a=g.current;if(!a)return;let c=Array.from(a.querySelectorAll('[role="treeitem"]')),d=b.currentTarget,e=c.indexOf(d),f=Number.parseInt(d.style.paddingLeft??"0",10);for(let a=e-1;a>=0;a--)if(Number.parseInt(c[a].style.paddingLeft??"0",10)<f){c[a].focus();break}}}},onDragStart:b=>d.handleDragStart(b,a),onDragOver:b=>"dir"===a.type?d.handleDragOver(b,a.path,"dir"):b.preventDefault(),onDragLeave:()=>d.setDragOverPath(null),onDrop:b=>"dir"===a.type?d.handleDropOnFolder(b,a.path):b.preventDefault(),onMouseEnter:()=>G(a),onMouseLeave:H,className:(0,Z.cn)("tree-row-reveal flex items-center gap-1.5 rounded-sm px-2 py-1 text-sm cursor-pointer group transition-colors select-none touch-target",k?"bg-accent-soft text-foreground font-medium":"hover:bg-muted",s&&"ring-2 ring-primary bg-primary-soft",a.name.startsWith(".")&&"opacity-40"),style:{paddingLeft:`${14*c+8}px`,...eq},onClick:()=>{"dir"===a.type?d.toggleFolder(a):("app"===a.type||"node-app"===a.type?(d.openViewer(a),d.toggleFolder(a)):d.openViewer(a),e&&d.setSidebarCollapsed(!0))},children:["dir"===a.type||"app"===a.type||"node-app"===a.type?a.loading?(0,b.jsx)(z.Loader2,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground"}):(0,b.jsx)(h.ChevronRight,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform duration-200 ease-out",style:{transform:a.expanded?"rotate(90deg)":"rotate(0deg)"}}):(0,b.jsx)("span",{className:"w-3.5 shrink-0"}),(0,b.jsx)("span",{className:"editorial-tree-typeicon",children:"dir"===a.type?a.expanded?(0,b.jsx)(p,{className:(0,Z.cn)("h-4 w-4 shrink-0",!k&&"text-warning")}):(0,b.jsx)(o.Folder,{className:(0,Z.cn)("h-4 w-4 shrink-0",!k&&"text-warning")}):"app"===a.type?(0,b.jsx)(u.Globe,{className:(0,Z.cn)("h-4 w-4 shrink-0",!k&&"text-foreground/70")}):"node-app"===a.type?(0,b.jsx)(O,{className:(0,Z.cn)("h-4 w-4 shrink-0",!k&&"text-emerald-500")}):ek(a.name)?(0,b.jsx)(u.Globe,{className:(0,Z.cn)("h-4 w-4 shrink-0",!k&&"text-foreground/60")}):ej(a.name)?(0,b.jsx)(x.default,{className:(0,Z.cn)("h-4 w-4 shrink-0",!k&&"text-sunshine-700")}):eh(a.name)?(0,b.jsx)(n.FileText,{className:(0,Z.cn)("h-4 w-4 shrink-0",!k&&"text-foreground/70")}):(0,b.jsx)(l.File,{className:(0,Z.cn)("h-4 w-4 shrink-0",!k&&"text-foreground/60")})}),(0,b.jsx)("span",{className:"min-w-0 flex-1 truncate",title:J?a.name:void 0,children:J?ea(a.name):a.name}),a.git&&(0,b.jsxs)("span",{className:"relative flex shrink-0 items-center gap-0.5 rounded-sm bg-muted px-1 py-0.5 text-[10px] text-muted-foreground",children:[(0,b.jsxs)("button",{"data-branch-trigger":!0,type:"button",className:"flex items-center gap-0.5 hover:text-foreground",title:"Switch branch",onClick:b=>{if(b.stopPropagation(),A){d.setBranchDropdownNode(null),d.setBranchDropdownPos(null);return}let c=b.currentTarget.getBoundingClientRect();d.setBranchDropdownPos({top:c.bottom+4,left:c.left}),d.setBranchDropdownNode(a.path),d.loadBranches(a.path)},children:[(0,b.jsx)(r,{className:"h-2.5 w-2.5"}),a.git.branch,a.git.dirty&&(0,b.jsx)("span",{className:"ml-0.5 text-warning",children:"*"})]}),w?(0,b.jsx)(z.Loader2,{className:"ml-0.5 h-2.5 w-2.5 animate-spin"}):(0,b.jsx)("button",{type:"button",onClick:b=>{b.stopPropagation();let c=a.path.includes("/")?a.path.substring(0,a.path.lastIndexOf("/")):"";d.handleGitPull(a.path,c)},className:"ml-0.5 text-muted-foreground hover:text-foreground",title:"Pull latest",children:(0,b.jsx)(K,{className:"h-2.5 w-2.5"})}),A&&C&&(0,b.jsx)(bS,{pos:C,branches:D,loading:E,busyName:F,disabled:null!==F,onPick:b=>{let c=a.path.includes("/")?a.path.substring(0,a.path.lastIndexOf("/")):"";d.handleCheckout(a.path,b,c)},onClose:()=>{d.setBranchDropdownNode(null),d.setBranchDropdownPos(null)}})]}),v&&(0,b.jsx)("span",{className:"ml-0.5 h-1.5 w-1.5 rounded-full bg-emerald-400 shrink-0 animate-pulse",title:"Agent recently active"}),(0,b.jsx)("div",{className:"hover-reveal flex max-w-0 shrink-0 items-center overflow-hidden opacity-0 transition-all duration-150 group-hover:max-w-7 group-hover:opacity-100 focus-within:max-w-7 focus-within:opacity-100",onClick:a=>a.stopPropagation(),onKeyDown:a=>a.stopPropagation(),children:(0,b.jsxs)(bJ.DropdownMenu,{children:[(0,b.jsx)(bJ.DropdownMenuTrigger,{asChild:!0,children:(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 text-muted-foreground hover:text-foreground",title:"File actions",children:(0,b.jsx)(B,{className:"h-3.5 w-3.5"})})}),(0,b.jsxs)(bJ.DropdownMenuContent,{align:"end",className:"w-48",children:[(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d.copyPath(a.path),children:[(0,b.jsx)(i.Copy,{className:"mr-2 h-3.5 w-3.5"}),"Copy path"]}),ei(a.name)&&(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d.copyWikiLink(a.name),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy wiki link"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d.copyUrl(a.path),children:[(0,b.jsx)(y.Link,{className:"mr-2 h-3.5 w-3.5"}),"Copy URL"]}),"file"===a.type&&eh(a.name)&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d.copyRawContent(a.path),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy raw content"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d.copyFormattedContent(a.path,a.name),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy formatted content"]})]}),(0,b.jsx)(bJ.DropdownMenuSeparator,{}),"dir"===a.type&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:async()=>{a.expanded||d.toggleFolder(a),d.setNewFileParent(a.path),d.setNewFileName(""),d.setFileCreateError(null)},children:[(0,b.jsx)(m.FilePlus,{className:"mr-2 h-3.5 w-3.5"}),"New file here"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d.triggerUpload(a.path),children:[(0,b.jsx)(R.Upload,{className:"mr-2 h-3.5 w-3.5"}),"Upload here"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>{d.setNewFolderParent(a.path),d.setNewFolderName(""),d.setFolderError(null)},children:[(0,b.jsx)(q,{className:"mr-2 h-3.5 w-3.5"}),"New subfolder"]}),(0,b.jsx)(bJ.DropdownMenuSeparator,{})]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d.handleDownload(a),children:[(0,b.jsx)(j,{className:"mr-2 h-3.5 w-3.5"}),"file"===a.type?"Download":"Download as zip"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d.togglePin(a,f),children:[(0,b.jsx)(I,{className:(0,Z.cn)("mr-2 h-3.5 w-3.5",t&&"fill-current text-amber-400")}),t?"Unpin":"Pin to top"]}),(0,b.jsx)(bJ.DropdownMenuSeparator,{}),(0,b.jsxs)(bJ.DropdownMenuItem,{className:"text-destructive focus:text-destructive",onClick:()=>{d.setDeletingPath(a.path),d.setDeletingIsDir("file"!==a.type)},children:[(0,b.jsx)(Q.Trash2,{className:"mr-2 h-3.5 w-3.5"}),"Delete"]})]})]})})]})}),(0,b.jsx)(er,{node:a,ctx:d,isPinned:t,activeWorkspaceId:f})]})}),eu=(0,T.memo)(function(a){let{ctx:c,openPath:d,dragOverPath:e,branchDropdownNode:g,branchDropdownPos:h,nodeBranches:i,branchesLoading:j,checkingOutBranch:k,pullingRepo:l,activePaths:m,pins:p,isMobile:q,activeWorkspaceId:r,newFileParent:s,newFileName:t,fileCreateError:u,newFolderParent:v,newFolderName:w,folderError:x,sidebarScrollRef:y}=a,z=d8(a=>a.showHidden),A=(0,T.useRef)(null),B=(0,T.useCallback)(a=>{let b=("dir"===a.type||"app"===a.type||"node-app"===a.type)&&!a.expanded&&void 0===a.children;("file"===a.type||b)&&(A.current&&clearTimeout(A.current),A.current=setTimeout(()=>c.prefetch(a),120))},[c]),C=(0,T.useCallback)(()=>{A.current&&(clearTimeout(A.current),A.current=null)},[]),D=(0,T.useMemo)(()=>{let b=[],c=(a,d)=>{for(let e of a)!(!z&&e.name.startsWith("."))&&(b.push({kind:"row",node:e,depth:d}),"dir"===e.type&&(v===e.path&&b.push({kind:"newfolder",node:e,depth:d}),s===e.path&&b.push({kind:"newfile",node:e,depth:d})),("dir"===e.type||"app"===e.type||"node-app"===e.type)&&e.expanded&&(e.children&&e.children.length>0?c(e.children,d+1):e.children?.length===0&&b.push({kind:"empty",node:e,depth:d})))};return c(a.nodes,0),b},[a.nodes,s,v,z]);return(0,b.jsx)(b.Fragment,{children:D.map(a=>{let{node:s,depth:v}=a;if("row"===a.kind){let a=g===s.path;return(0,b.jsx)(et,{node:s,depth:v,ctx:c,isMobile:q,activeWorkspaceId:r,sidebarScrollRef:y,isActive:d===s.path,isDragOver:e===s.path,isPinned:p.some(a=>a.path===s.path),isAgentActive:m.has(s.path),isPulling:l===s.path,branchOpen:a,branchPos:a?h:null,branches:s.git?i[s.path]??[]:[],branchLoading:!!s.git&&!!j[s.path],checkingOut:a?k:null,onHoverEnter:B,onHoverLeave:C},s.path)}return"newfolder"===a.kind?(0,b.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1",style:{paddingLeft:`${(v+1)*14+8}px`,...eq},children:[(0,b.jsx)("span",{className:"w-3.5 shrink-0"}),(0,b.jsx)(o.Folder,{className:"h-4 w-4 shrink-0 text-warning"}),(0,b.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"Folder name",value:w,onChange:a=>c.setNewFolderName(a.target.value),onKeyDown:a=>{"Enter"===a.key&&c.handleCreateFolder(),"Escape"===a.key&&(c.setNewFolderParent(null),c.setNewFolderName(""))}}),x&&(0,b.jsx)("span",{className:"text-xs text-destructive",children:x}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:c.handleCreateFolder,children:(0,b.jsx)(f.Check,{className:"h-3 w-3"})}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{c.setNewFolderParent(null),c.setNewFolderName("")},children:(0,b.jsx)(S.X,{className:"h-3 w-3"})})]},`nf-${s.path}`):"newfile"===a.kind?(0,b.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1",style:{paddingLeft:`${(v+1)*14+8}px`,...eq},children:[(0,b.jsx)("span",{className:"w-3.5 shrink-0"}),(0,b.jsx)(n.FileText,{className:"h-4 w-4 shrink-0 text-accent"}),(0,b.jsx)("input",{autoFocus:!0,className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"filename (default .md)",value:t,onChange:a=>c.setNewFileName(a.target.value),onKeyDown:a=>{"Enter"===a.key&&c.handleCreateFile(),"Escape"===a.key&&(c.setNewFileParent(null),c.setNewFileName(""))}}),u&&(0,b.jsx)("span",{className:"text-xs text-destructive",children:u}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:c.handleCreateFile,children:(0,b.jsx)(f.Check,{className:"h-3 w-3"})}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{c.setNewFileParent(null),c.setNewFileName("")},children:(0,b.jsx)(S.X,{className:"h-3 w-3"})})]},`ff-${s.path}`):(0,b.jsx)("div",{className:"text-xs text-muted-foreground/50 py-0.5",style:{paddingLeft:`${(v+1)*14+8+14+6+16+6}px`,...eq},children:"Empty"},`empty-${s.path}`)})})});a.s(["default",0,function(){let a;(0,d7.useWikiSlugsStore)(a=>a.loadedAt),(0,T.useEffect)(()=>{d7.useWikiSlugsStore.getState().load()},[]);let[d,j]=(0,T.useState)(null),[p,O]=(0,T.useState)(null),[V,X]=(0,T.useState)(()=>null),[$,_]=(0,T.useState)([]),[aa,ae]=(0,T.useState)(!1),[af,aj]=(0,T.useState)(!1),[al,am]=(0,T.useState)(null),[an,ao]=(0,T.useState)(null),[ap,aq]=(0,T.useState)({}),[ar,as]=(0,T.useState)(null),[at,au]=(0,T.useState)(null),[av,aw]=(0,T.useState)(null),[ax,ay]=(0,T.useState)(null),az=(0,T.useCallback)(async()=>{try{let a=await fetch("/api/system/workspaces");if(!a.ok)throw Error("Failed");let b=await a.json();if(_(b.workspaces),ae(b.isAdmin),b.workspaces.length>0){j(!0);let a=new URLSearchParams(window.location.search).get("ws"),c=a?b.workspaces.find(b=>b.id===a):null,d=c??[...b.workspaces].sort((a,b)=>(b.lastOpenedAt??b.createdAt).localeCompare(a.lastOpenedAt??a.createdAt))[0];if(X(d.id),O(d.rootDir),!c){let a=new URL(location.href);a.searchParams.set("ws",d.id),history.replaceState(null,"",a.toString())}}else j(!1)}catch{j(!1)}},[]);(0,T.useEffect)(()=>{az()},[az]);let aA=(0,c8.useEditorStore)(a=>a.currentPath),aB=cY(a=>a.recents),[aC,aD]=(0,T.useState)(!1),[aE,aF]=(0,T.useState)(!0),aG=cZ(a=>a.pins),aH=(0,T.useRef)(null),aI=(0,c_.useAIPanelStore)(a=>a.activity),aJ=(0,T.useMemo)(()=>{let a=new Date(Date.now()-6e4).toISOString(),b=new Set;for(let c of aI)c.at>=a&&c.path&&c.by?.startsWith("ai:")&&b.add(c.path);return b},[aI]);(0,T.useEffect)(()=>{let a=()=>{c_.useAIPanelStore.getState().loadActivity()};a();let b=setInterval(a,1e4);return()=>clearInterval(b)},[]),(0,T.useEffect)(()=>{cY.getState().loadForWorkspace(V),cZ.getState().loadForWorkspace(V)},[V]),(0,T.useEffect)(()=>{let a,b=[...aG.map(a=>a.path),...aB.slice(0,8).map(a=>a.path)].filter((a,b,c)=>ei(a)&&c.indexOf(a)===b).slice(0,12);if(0===b.length)return;let c=(a=()=>{for(let a of b)(0,c8.prefetchPage)(a)},window.setTimeout(a,400));return()=>{clearTimeout(c)}},[aG,aB]);let aK=(0,T.useRef)(null),aL=(0,T.useRef)(!1),[aM,aN]=(0,T.useState)([]),[aO,aP]=(0,T.useState)(!1),[aQ,aR]=(0,T.useState)(!1),aS=(0,T.useRef)(!1),[aT,aU]=(0,T.useState)(!1),[aV,aW]=(0,T.useState)(!1),[aX,aY]=(0,T.useState)(null),aZ=(0,T.useRef)(null),a$=(0,T.useRef)(""),[a_,a0]=(0,T.useState)(null),[a1,a2]=(0,T.useState)(""),[a3,a4]=(0,T.useState)(null),[a5,a6]=(0,T.useState)(null),[a7,a8]=(0,T.useState)(""),[a9,ba]=(0,T.useState)(null),[bb,bc]=(0,T.useState)(null),[bd,bf]=(0,T.useState)(!1),[bg,bh]=(0,T.useState)(null),[bi,bj]=(0,T.useState)(null),[bk,bl]=(0,T.useState)(!1),[bm,bo]=(0,T.useState)(0),[bs,bt]=(0,T.useState)(0),bu=function(a="(max-width: 767px)"){let[b,c]=(0,T.useState)(!1);return(0,T.useEffect)(()=>{let b=window.matchMedia(a),d=()=>c(b.matches);return d(),b.addEventListener("change",d),()=>b.removeEventListener("change",d)},[a]),b}(),[bv,bw]=(0,T.useState)(!1),bx=d6(a=>a.width),by=d8(a=>a.showHidden),bz=d9(a=>a.humanize),{resolvedTheme:bA,setTheme:bB}=(0,bT.useTheme)(),bC=d6(a=>a.setWidth);(0,T.useEffect)(()=>{bu&&bw(!0)},[bu]);let[bD,bF]=(0,T.useState)(!1),[bH,bI]=(0,T.useState)(!1),[bK,bM]=(0,T.useState)(!1),[bN,bO]=(0,T.useState)(null),[bP,bR]=(0,T.useState)(0),[bU,bV]=(0,T.useState)(!1),[bW,bX]=(0,T.useState)(!1),[bY,bZ]=(0,T.useState)(""),[b$,b0]=(0,T.useState)(!1),[b1,b2]=(0,T.useState)(!1),[b3,b4]=(0,T.useState)(null),b5=(0,T.useRef)(null),[b6,b7]=(0,T.useState)(null),b8=(0,T.useRef)(null),ca=(0,T.useRef)(!1),cb=(0,T.useRef)(async()=>{});(0,T.useEffect)(()=>{aO||aS.current||(aS.current=!0,aR(!0),el("").then(a=>{aN(a),aP(!0),aR(!1)}).catch(()=>{aS.current=!1,aR(!1)}))},[aO]);let cc=(0,T.useCallback)(async a=>{let b=a.split("/");if(b.length<=1)return;let c=[],d="";for(let a=0;a<b.length-1;a++)d=d?`${d}/${b[a]}`:b[a],c.push({prefix:d,children:await el(d)});aN(a=>{let b=a;for(let{prefix:a,children:d}of c)b=ep(b,a,a=>({...a,children:d,expanded:!0}));return b})},[]),cd=(0,T.useCallback)(async a=>{let b=await el(a);""===a?aN(a=>{let c=new Map(a.map(a=>[a.path,a]));return b.map(a=>{let b=c.get(a.path);return b&&("dir"===b.type||"app"===b.type)?{...a,expanded:b.expanded,children:b.children}:a})}):aN(c=>ep(c,a,a=>({...a,children:b,expanded:!0})))},[]),[ce,cf]=(0,T.useState)(null),[cg,ch]=(0,T.useState)(null),[ci,cj]=(0,T.useState)(!1),[ck,cl]=(0,T.useState)([]),[cm,cn]=(0,T.useState)(!1),[co,cp]=(0,T.useState)(null),[cq,cr]=(0,T.useState)(null),[cs,ct]=(0,T.useState)(!1),[cu,cx]=(0,T.useState)({}),[cy,cz]=(0,T.useState)({}),[cA,cB]=(0,T.useState)(null),[cC,cD]=(0,T.useState)(null),[cE,cG]=(0,T.useState)(null),cI=(0,T.useCallback)(async(a,b)=>{if(!ce){cf(a);try{let c=await (0,Y.wsFetch)("/api/wiki/git-pull",{method:"POST",body:JSON.stringify({path:a})});if(!c.ok){let a=await c.json();(0,b_.showError)(a.message??a.error??"Pull failed");return}let d=await c.json();(0,b_.showSuccess)(`Pulled ${a} (${d.branch} @ ${d.sha.slice(0,7)})`),await cd(b)}catch{(0,b_.showError)("Pull failed")}finally{cf(null)}}},[ce,cd]);(0,T.useEffect)(()=>{cj(!1),cl([]),cp(null),cr(null)},[bg?.path]);let cJ=bg?.path;(0,T.useEffect)(()=>{if(!cJ)return void ch(null);let a=!1,b=setTimeout(()=>{(async()=>{try{let b=await (0,Y.wsFetch)(`/api/wiki/git-file-info?path=${encodeURIComponent(cJ)}`);if(a)return;if(!b.ok)return void ch(null);let c=await b.json();a||ch(c.info)}catch{a||ch(null)}})()},200);return()=>{a=!0,clearTimeout(b)}},[cJ]);let cK=(0,T.useCallback)(async()=>{if(!bg)return;let a=bg.path;cj(!0),cn(!0),cl([]),cp(null),cr(null);try{let b=await (0,Y.wsFetch)(`/api/wiki/git-history?path=${encodeURIComponent(a)}`);if(!b.ok)return void(0,b_.showError)("Could not load history");let c=await b.json();bg.path===a&&cl(c.commits)}catch{(0,b_.showError)("Could not load history")}finally{cn(!1)}},[bg]),cL=(0,T.useCallback)(async a=>{if(!bg)return;if(co===a){cp(null),cr(null);return}let b=bg.path;cp(a),ct(!0),cr(null);try{let c=await (0,Y.wsFetch)(`/api/wiki/git-diff?path=${encodeURIComponent(b)}&sha=${encodeURIComponent(a)}`);if(!c.ok)return void(0,b_.showError)("Could not load diff");let d=await c.json();bg.path===b&&co===a&&cr(d.diff)}catch{(0,b_.showError)("Could not load diff")}finally{ct(!1)}},[bg,co]),cM=(0,T.useCallback)(async a=>{if(cu[a]||cy[a])return;let b=!1;cz(b=>({...b,[a]:!0}));try{let c=await (0,Y.wsFetch)(`/api/wiki/git-branches?path=${encodeURIComponent(a)}`);if(b)return;if(!c.ok)return void(0,b_.showError)("Could not load branches");let d=await c.json();b||cx(b=>({...b,[a]:d.branches}))}catch{b||(0,b_.showError)("Could not load branches")}finally{b||cz(b=>({...b,[a]:!1}))}return()=>{b=!0}},[cu,cy]),cN=(0,T.useCallback)(async(a,b,c)=>{if(!cA){cB(b);try{let d=await (0,Y.wsFetch)("/api/wiki/git-checkout",{method:"POST",body:JSON.stringify({path:a,branch:b})});if(409===d.status)return void(0,b_.showError)("Repository has uncommitted changes");if(!d.ok){let a=await d.json();(0,b_.showError)(a.error??"Checkout failed");return}let e=await d.json();(0,b_.showSuccess)(`Switched to ${e.branch}`),cx(b=>{let c={...b};return delete c[a],c}),cD(null),cG(null),await cd(c)}catch{(0,b_.showError)("Checkout failed")}finally{cB(null)}}},[cA,cd]),cO=(0,T.useCallback)(a=>{let b=[];for(let c of a)("dir"===c.type||"app"===c.type||"node-app"===c.type)&&c.expanded&&c.children&&(b.push(c.path),b.push(...cO(c.children)));return b},[]),cP=(0,T.useCallback)(async()=>{aU(!0);try{let a=cO(aM),b=await el("");for(let c of(aN(b),a)){let a=await el(c);aN(b=>ep(b,c,b=>({...b,children:a,expanded:!0})))}}finally{aU(!1)}},[aM,cO]),cQ=(0,T.useCallback)(async()=>{if(bg){if(ei(bg.name)){bV(!0);try{await c8.useEditorStore.getState().loadPage(bg.path)}finally{bV(!1)}return}if(["editor","text"].includes(ef(bg.name,bg.nodeType))||eh(bg.name)){bV(!0);try{let a=await (0,Y.wsFetch)(`/api/wiki/content?path=${encodeURIComponent(bg.path)}`);if(a.ok){let b=await a.json();bO(b.content),bR(Number(a.headers.get("X-Wiki-Revision")??0))}}catch{}bV(!1)}}},[bg]),cR=(0,T.useCallback)(()=>{bt(a=>a+1),cQ()},[cQ]);async function cS(a){if("dir"===a.type||"app"===a.type||"node-app"===a.type)if(a.expanded)aN(b=>ep(b,a.path,a=>({...a,expanded:!1})));else if(void 0===a.children){let b=await eo(a.path);if(b)return void aN(c=>ep(c,a.path,a=>({...a,loading:!1,children:b,expanded:!0})));aN(b=>ep(b,a.path,a=>({...a,loading:!0})));let c=await el(a.path);aN(b=>ep(b,a.path,a=>({...a,loading:!1,children:c,expanded:!0})))}else aN(b=>ep(b,a.path,a=>({...a,expanded:!0})))}async function cT(a){if("file"===a.type&&cY.getState().push({path:a.path,name:a.name},V),bh({path:a.path,name:a.name,size:a.size,nodeType:"app"===a.type?"app":"node-app"===a.type?"node-app":"file"}),bX(!1),b0(!1),b4(null),bO(null),bR(0),"file"===a.type&&ei(a.name)){bV(!0);try{await c8.useEditorStore.getState().loadPage(a.path)}finally{bV(!1)}return}if(["editor","text"].includes(ef(a.name,a.type))||eh(a.name)){bV(!0);try{let b=await (0,Y.wsFetch)(`/api/wiki/content?path=${encodeURIComponent(a.path)}`);if(b.ok){let a=await b.json();bO(a.content),bR(Number(b.headers.get("X-Wiki-Revision")??0))}}catch{}bV(!1)}}(0,T.useEffect)(()=>{bg&&ei(bg.name)&&c8.useEditorStore.getState().currentPath!==bg.path&&c8.useEditorStore.getState().loadPage(bg.path)},[bg]),(0,T.useEffect)(()=>{b8.current=bg},[bg]),(0,T.useEffect)(()=>{ca.current=bW},[bW]),(0,T.useEffect)(()=>{cb.current=cQ},[cQ]),(0,T.useEffect)(()=>{if(!d)return;let a=new Map,b=new EventSource((0,Y.withWs)("/api/wiki/watch"));return b.onmessage=b=>{var c;let d;try{d=JSON.parse(b.data)}catch{return}let{type:e,path:f}=d,g=f.split("/");if(c=g.length>1?g.slice(0,-1).join("/"):"",a.has(c)&&clearTimeout(a.get(c)),a.set(c,setTimeout(()=>{a.delete(c),cd(c)},300)),"change"===e&&b8.current?.path===f&&!ca.current){let b=`__file__${f}`;a.has(b)&&clearTimeout(a.get(b)),a.set(b,setTimeout(()=>{a.delete(b),cb.current()},400))}},()=>{for(let c of(b.close(),a.values()))clearTimeout(c)}},[d,cd]),(0,T.useEffect)(()=>{bl(!1)},[]);let cU=(0,T.useCallback)(a=>{let b=a.split("/").pop()??a;cc(a),cT({path:a,name:b,type:"file"})},[cc]),cV=(0,T.useCallback)(async a=>{let b=a.path.split("/").slice(0,-1).join("/"),c=(await el(b)).find(b=>b.path===a.path);if(c){if("dir"===c.type){await cc(a.path),await cS(c);return}if("app"===c.type||"node-app"===c.type){await cc(c.path),cT({path:c.path,name:c.name,type:c.type,modifiedAt:c.modifiedAt}),await cS(c),bu&&bw(!0);return}cT({path:c.path,name:c.name,type:c.type,modifiedAt:c.modifiedAt}),bu&&bw(!0)}},[bu,cT,cc,cS]);(0,T.useEffect)(()=>{if(!aA||bg&&bg.path===aA)return;let a=aA.split("/").pop()??aA;cT({path:aA,name:a,type:"file"})},[aA]);let cW=(0,T.useCallback)(async a=>{if(!a)return void bh(null);let b=a.split("/"),c=b[b.length-1],d=b.slice(0,-1).join("/"),e=(await el(d)).find(b=>b.path===a);e&&(await cc(a),cT({path:a,name:c,type:e.type,modifiedAt:e.modifiedAt}))},[cc]);(0,T.useEffect)(()=>{},[bg]),(0,T.useEffect)(()=>{},[cW]),(0,T.useEffect)(()=>{aL.current||aO&&(aL.current=!0,cW(aK.current))},[aO,cW]);let cX=(0,T.useCallback)(async a=>{if(a===V)return;try{await fetch(`/api/system/workspaces/${a}/open`,{method:"POST"})}catch{}let b=new URL(location.href);b.searchParams.set("ws",a),b.searchParams.delete("path"),history.pushState(null,"",b.toString()),bh(null),bO(null),bX(!1),aN([]),aP(!1),aS.current=!1,d7.useWikiSlugsStore.getState().invalidate();let c=$.find(b=>b.id===a);c&&O(c.rootDir),X(a)},[V,$]),c$=(0,T.useCallback)(async()=>{if(al)try{if(!(await fetch(`/api/system/workspaces/${al}`,{method:"DELETE"})).ok)throw Error("Failed");if(al===V){let a=$.filter(a=>a.id!==al);if(a.length>0){let b=[...a].sort((a,b)=>(b.lastOpenedAt??b.createdAt).localeCompare(a.lastOpenedAt??a.createdAt))[0];await cX(b.id)}else j(!1)}await az()}catch{}finally{am(null)}},[al,V,$,cX,az]),c0=(0,T.useCallback)(async a=>{if(!an){ao(a);try{let b=await fetch(`/api/system/workspaces/${a}/refresh`,{method:"POST"});if(!b.ok){let a=await b.json();(0,b_.showError)(a.error??"Refresh failed")}await az()}catch{(0,b_.showError)("Refresh failed")}finally{ao(null)}}},[an,az]),c1=(0,T.useCallback)(async a=>{if(!ap[a])try{let b=await fetch(`/api/system/workspaces/${a}/branch`);if(!b.ok)return;let c=await b.json();aq(b=>({...b,[a]:c.branches??[]}))}catch{}},[ap]),c2=(0,T.useCallback)(async(a,b)=>{if(!ar){as(a),au(b);try{let c=await fetch(`/api/system/workspaces/${a}/branch`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:b})});if(!c.ok){let a=await c.json();(0,b_.showError)(a.error??"Branch switch failed");return}(0,b_.showSuccess)(`Switched to ${b}`),aw(null),ay(null),await az()}catch{(0,b_.showError)("Branch switch failed")}finally{as(null),au(null)}}},[ar,az]);async function c3(){if(!bg)return;b2(!0),b4(null);let a=await (0,Y.wsFetch)("/api/wiki/content",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:bg.path,content:bY,baseRevision:bP})});if(a.ok){let b=await a.json();"number"==typeof b.revision&&bR(b.revision),bO(bY),bX(!1)}else b4((await a.json()).error??"Save failed");b2(!1)}let c4=(0,T.useCallback)(async(a,b)=>{let c=Array.from(a);if(c.length){aW(!0),aY(null);try{for(let a of c){let c=new FormData;c.append("file",a),c.append("dir",b);let d=await (0,Y.wsFetch)("/api/wiki/upload",{method:"POST",body:c});if(!d.ok){let a=await d.json();aY(a.error??"Upload failed"),(0,b_.showError)(a.error??"Upload failed");break}}await cd(b)}catch{aY("Upload failed.")}finally{aW(!1),aZ.current&&(aZ.current.value="")}}},[cd]);function c5(a){a$.current=a,aZ.current?.click()}async function c6(){let a=a1.trim();if(!a||null===a_)return;a4(null);let b=a_?`${a_}/${a}`:a,c=await (0,Y.wsFetch)("/api/wiki/folder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:b})});c.ok?(a0(null),a2(""),await cd(a_),""!==a_&&aN(a=>ep(a,a_,a=>({...a,expanded:!0})))):a4((await c.json()).error??"Failed")}async function c7(){let a=a7.trim();if(!a||null===a5)return;ba(null);let b=a.includes(".")?a:`${a}.md`,c=a5?`${a5}/${b}`:b,d=await (0,Y.wsFetch)("/api/wiki/new-file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:c})});d.ok?(a6(null),a8(""),await cd(a5),""!==a5&&aN(a=>ep(a,a5,a=>({...a,expanded:!0}))),cT({path:c,name:b,type:"file",modifiedAt:new Date().toISOString()})):ba((await d.json()).error??"Failed")}function c9(a){navigator.clipboard.writeText(a),(0,b_.showSuccess)("Path copied")}function da(a){let b=a.replace(/\.(md|markdown)$/i,"");navigator.clipboard.writeText(`[[${b}]]`),(0,b_.showSuccess)("Wiki link copied")}function db(a){let b=new URL(location.href);b.searchParams.set("path",a),V&&b.searchParams.set("ws",V),navigator.clipboard.writeText(b.toString()),(0,b_.showSuccess)("URL copied")}async function dc(a){if(bg?.path===a&&null!==bN)return bN;if(c8.useEditorStore.getState().currentPath===a)return c8.useEditorStore.getState().content;let b=await (0,Y.wsFetch)(`/api/wiki/content?path=${encodeURIComponent(a)}`);if(!b.ok)throw Error("Cannot copy content");return(await b.json()).content}async function dd(a){try{let b=await dc(a);await navigator.clipboard.writeText(b),(0,b_.showSuccess)("Raw content copied")}catch{(0,b_.showError)("Could not copy file content")}}async function de(a,b){try{let c=await dc(a);if(!ei(b)){await navigator.clipboard.writeText(c),(0,b_.showSuccess)("Content copied");return}let d=await (0,be.markdownToHtml)(c,{pagePath:a,sanitize:!0});"ClipboardItem"in window&&navigator.clipboard.write?await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([d],{type:"text/html"}),"text/plain":new Blob([c],{type:"text/plain"})})]):await navigator.clipboard.writeText(c),(0,b_.showSuccess)("Formatted content copied")}catch{(0,b_.showError)("Could not copy formatted content")}}function df(a,c){return(0,b.jsxs)(bJ.DropdownMenu,{children:[(0,b.jsx)(bJ.DropdownMenuTrigger,{asChild:!0,children:(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"File actions",children:(0,b.jsx)(B,{className:"h-3.5 w-3.5"})})}),(0,b.jsxs)(bJ.DropdownMenuContent,{align:"end",className:"w-52",children:[(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>c9(a.path),children:[(0,b.jsx)(i.Copy,{className:"mr-2 h-3.5 w-3.5"}),"Copy path"]}),ei(a.name)&&(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>da(a.name),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy wiki link"]}),(0,b.jsx)(bJ.DropdownMenuSeparator,{}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>db(a.path),children:[(0,b.jsx)(y.Link,{className:"mr-2 h-3.5 w-3.5"}),"Copy URL"]}),eh(a.name)&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(bJ.DropdownMenuSeparator,{}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>void dd(a.path),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy raw content"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>void de(a.path,a.name),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy formatted content"]})]}),c&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(bJ.DropdownMenuSeparator,{}),c]})]})]})}async function dh(){bb&&(await (0,Y.wsFetch)("/api/wiki",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:bb})}),(bg?.path===bb||bg?.path.startsWith(`${bb}/`))&&(bh(null),bO(null)),aN(a=>(function a(b,c){return b.filter(a=>a.path!==c).map(b=>b.children?{...b,children:a(b.children,c)}:b)})(a,bb)),bc(null))}function di(a,b,c){a.preventDefault(),a.stopPropagation();let d=b5.current;if(!d){Array.from(a.dataTransfer.types).includes("Files")&&(a.dataTransfer.dropEffect="copy",b7("root"===c?"":b));return}d.path===b||b.startsWith(`${d.path}/`)||(a.dataTransfer.dropEffect="move",b7("root"===c?"":b))}async function dj(a,b){a.preventDefault(),a.stopPropagation(),b7(null);let c=b5.current;if(b5.current=null,!c){a.dataTransfer.files.length>0&&await c4(a.dataTransfer.files,b);return}if(c.path===b||b.startsWith(`${c.path}/`))return;let d=b?`${b}/${c.name}`:c.name;if(d!==c.path&&(await (0,Y.wsFetch)("/api/wiki/move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({from:c.path,to:d})})).ok){let a=c.path.includes("/")?c.path.split("/").slice(0,-1).join("/"):"";await cd(a),b!==a&&await cd(b),bg?.path===c.path&&bh({path:d,name:c.name,nodeType:bg.nodeType,size:bg.size})}}let dk=bg?ef(bg.name,bg.nodeType):null,dl=!!bg&&null!==dk&&!ed.has(dk)&&(bg.size??0)>5242880&&bi!==bg.path,dm=(0,d2.useViewWidthStore)(a=>a.width),dn=(0,d2.useViewWidthStore)(a=>a.align),dp=(0,d2.useViewWidthStore)(a=>a.setWidth),dq=(0,d2.useViewWidthStore)(a=>a.setAlign),dr=null===dk||"editor"===dk||"text"===dk||"source"===dk||"notebook"===dk||"fallback"===dk,ds=dr?d2.VIEW_WIDTH_CLASS[dm]:"",dt=dr?d2.VIEW_ALIGN_CLASS[dn]:"",du=(0,T.useRef)(null);du.current={toggleFolder:a=>void cS(a),openViewer:a=>void cT(a),copyPath:c9,copyWikiLink:da,copyUrl:db,copyRawContent:a=>void dd(a),copyFormattedContent:(a,b)=>void de(a,b),handleDownload:function(a){let b=(0,Y.withWs)(`/api/wiki/download?path=${encodeURIComponent(a.path)}`),c=document.createElement("a");c.href=b,c.download="file"===a.type?a.name:`${a.name}.zip`,document.body.appendChild(c),c.click(),c.remove()},triggerUpload:c5,handleCreateFile:()=>void c7(),handleCreateFolder:()=>void c6(),handleDragStart:function(a,b){b5.current=b,a.dataTransfer.effectAllowed="move",a.dataTransfer.setData("text/plain",b.path)},handleDragOver:di,handleDropOnFolder:(a,b)=>void dj(a,b),handleGitPull:(a,b)=>void cI(a,b),handleCheckout:(a,b,c)=>void cN(a,b,c),loadBranches:a=>void cM(a),prefetch:a=>{"file"===a.type?ei(a.name)&&(0,c8.prefetchPage)(a.path):function(a){if(em.has(a)||en.has(a))return;let b=el(a).then(b=>(em.set(a,b),b)).finally(()=>en.delete(a));en.set(a,b),b.catch(()=>{})}(a.path)},togglePin:(a,b)=>cZ.getState().toggle({path:a.path,name:a.name,type:a.type},b),setDragOverPath:b7,setSidebarCollapsed:bw,setBranchDropdownNode:cD,setBranchDropdownPos:cG,setNewFileParent:a6,setNewFileName:a8,setFileCreateError:ba,setNewFolderParent:a0,setNewFolderName:a2,setFolderError:a4,setDeletingPath:bc,setDeletingIsDir:bf};let dv=(0,T.useMemo)(()=>({toggleFolder:a=>du.current.toggleFolder(a),openViewer:a=>du.current.openViewer(a),copyPath:a=>du.current.copyPath(a),copyWikiLink:a=>du.current.copyWikiLink(a),copyUrl:a=>du.current.copyUrl(a),copyRawContent:a=>du.current.copyRawContent(a),copyFormattedContent:(a,b)=>du.current.copyFormattedContent(a,b),handleDownload:a=>du.current.handleDownload(a),triggerUpload:a=>du.current.triggerUpload(a),handleCreateFile:()=>du.current.handleCreateFile(),handleCreateFolder:()=>du.current.handleCreateFolder(),handleDragStart:(a,b)=>du.current.handleDragStart(a,b),handleDragOver:(a,b,c)=>du.current.handleDragOver(a,b,c),handleDropOnFolder:(a,b)=>du.current.handleDropOnFolder(a,b),handleGitPull:(a,b)=>du.current.handleGitPull(a,b),handleCheckout:(a,b,c)=>du.current.handleCheckout(a,b,c),loadBranches:a=>du.current.loadBranches(a),prefetch:a=>du.current.prefetch(a),togglePin:(a,b)=>du.current.togglePin(a,b),setDragOverPath:a=>du.current.setDragOverPath(a),setSidebarCollapsed:a=>du.current.setSidebarCollapsed(a),setBranchDropdownNode:a=>du.current.setBranchDropdownNode(a),setBranchDropdownPos:a=>du.current.setBranchDropdownPos(a),setNewFileParent:a=>du.current.setNewFileParent(a),setNewFileName:a=>du.current.setNewFileName(a),setFileCreateError:a=>du.current.setFileCreateError(a),setNewFolderParent:a=>du.current.setNewFolderParent(a),setNewFolderName:a=>du.current.setNewFolderName(a),setFolderError:a=>du.current.setFolderError(a),setDeletingPath:a=>du.current.setDeletingPath(a),setDeletingIsDir:a=>du.current.setDeletingIsDir(a)}),[]);return(0,b.jsxs)("div",{className:"flex h-screen gap-0 overflow-hidden bg-background",children:[null===d&&(0,b.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,b.jsx)(z.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),!1===d&&(0,b.jsx)(bQ,{onSelect:a=>{let b=new URL(location.href);b.searchParams.set("ws",a),b.searchParams.delete("path"),history.replaceState(null,"",b.toString()),aP(!1),aS.current=!1,X(a),j(!0),az()}}),!0===d&&af&&(0,b.jsxs)("div",{className:"flex-1 flex flex-col",children:[(0,b.jsx)("div",{className:"flex items-center justify-end border-b px-3 py-2 bg-muted shrink-0",children:(0,b.jsxs)(U.Button,{size:"sm",variant:"ghost",className:"h-7 gap-1.5 text-xs",onClick:()=>aj(!1),children:[(0,b.jsx)(S.X,{className:"h-3.5 w-3.5"})," Cancel"]})}),(0,b.jsx)(bQ,{onSelect:a=>{aj(!1),az(),cX(a)}})]}),!0===d&&!af&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(d4,{onOpenFile:cU,recents:aB,onToggleSidebar:()=>bw(a=>{let b=!a;return bu&&!1===b&&c_.useAIPanelStore.getState().close(),b}),onNewFile:()=>a6(""),onCopyPath:()=>{bg&&navigator.clipboard.writeText(bg.path)}}),!bv&&bu&&(0,b.jsx)("div",{className:"fixed inset-0 z-40 bg-overlay backdrop-blur-[1px] md:hidden",onClick:()=>bw(!0),"aria-hidden":!0}),!bv&&(0,b.jsxs)(cw.Card,{style:bu?void 0:{width:bx},className:"fixed inset-y-0 left-0 z-50 w-[85vw] max-w-[20rem] md:relative md:z-auto md:w-auto md:max-w-none flex flex-col shrink-0 overflow-hidden rounded-none border-r border-l-0 border-t-0 border-b-0",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between gap-2 px-3 py-2 border-b bg-muted shrink-0",children:[(0,b.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5",children:[(0,b.jsx)("img",{src:"/logo.svg",alt:"Wiki Viewer",className:"h-5 w-5 shrink-0"}),(0,b.jsx)("span",{className:"truncate text-xs font-semibold leading-5 tracking-tight translate-y-[0.5px]",children:"Wiki Viewer"})]}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0 shrink-0",title:"Collapse sidebar",onClick:()=>bw(!0),children:(0,b.jsx)(D,{className:"h-3.5 w-3.5"})})]}),(0,b.jsxs)("div",{className:"flex items-center justify-between gap-1 px-3 py-1.5 border-b bg-muted/50 shrink-0",children:[(0,b.jsxs)(bJ.DropdownMenu,{children:[(0,b.jsx)(bJ.DropdownMenuTrigger,{asChild:!0,children:(0,b.jsxs)(U.Button,{size:"sm",variant:"ghost",className:"h-7 gap-1 px-2 text-xs",disabled:aV,children:[aV?(0,b.jsx)(z.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):(0,b.jsx)(J,{className:"h-3.5 w-3.5"}),"New",(0,b.jsx)(g.ChevronDown,{className:"h-3 w-3 opacity-60"})]})}),(0,b.jsxs)(bJ.DropdownMenuContent,{align:"start",className:"w-44",children:[(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>{a6(""),a8(""),ba(null)},children:[(0,b.jsx)(m.FilePlus,{className:"mr-2 h-3.5 w-3.5"}),"New file"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>{a0(""),a2(""),a4(null)},children:[(0,b.jsx)(q,{className:"mr-2 h-3.5 w-3.5"}),"New folder"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>c5(""),disabled:aV,children:[(0,b.jsx)(R.Upload,{className:"mr-2 h-3.5 w-3.5"}),"Upload"]})]})]}),(0,b.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Refresh tree",onClick:cP,disabled:aT,children:aT?(0,b.jsx)(z.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):(0,b.jsx)(K,{className:"h-3.5 w-3.5"})}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"AI Agent panel",onClick:()=>{c_.useAIPanelStore.getState().toggle(),bu&&bw(!0)},children:(0,b.jsx)(e,{className:"h-3.5 w-3.5"})}),(0,b.jsxs)(bJ.DropdownMenu,{children:[(0,b.jsx)(bJ.DropdownMenuTrigger,{asChild:!0,children:(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"More actions",children:(0,b.jsx)(B,{className:"h-3.5 w-3.5"})})}),(0,b.jsxs)(bJ.DropdownMenuContent,{align:"end",className:"w-48",children:[aa&&$.find(a=>a.id===V)?.git&&(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>{V&&c0(V)},disabled:an===V,children:[an===V?(0,b.jsx)(z.Loader2,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):(0,b.jsx)(k,{className:"mr-2 h-3.5 w-3.5"}),"Pull latest"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d8.getState().toggle(),children:[by?(0,b.jsx)(H,{className:"mr-2 h-3.5 w-3.5"}):(0,b.jsx)(G.Eye,{className:"mr-2 h-3.5 w-3.5"}),by?"Hide hidden files":"Show hidden files"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d9.getState().toggle(),children:[(0,b.jsx)(P.Type,{className:"mr-2 h-3.5 w-3.5"}),bz?"Raw file names":"Humanize names"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>bB("dark"===bA?"light":"dark"),children:["dark"===bA?(0,b.jsx)(N.Sun,{className:"mr-2 h-3.5 w-3.5"}):(0,b.jsx)(C.Moon,{className:"mr-2 h-3.5 w-3.5"}),"dark"===bA?"Light mode":"Dark mode"]}),(0,b.jsx)(bJ.DropdownMenuSeparator,{}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>bI(!0),children:[(0,b.jsx)(L,{className:"mr-2 h-3.5 w-3.5"}),"Settings"]})]})]})]})]}),aX&&(0,b.jsxs)("div",{className:"flex items-center gap-1.5 px-3 py-1.5 text-xs text-destructive bg-destructive/10 shrink-0",children:[(0,b.jsx)(c.AlertCircle,{className:"h-3.5 w-3.5 shrink-0"}),aX]}),""===a_&&(0,b.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 border-b shrink-0",children:[(0,b.jsx)(o.Folder,{className:"h-4 w-4 shrink-0 text-warning"}),(0,b.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"Folder name",value:a1,onChange:a=>a2(a.target.value),onKeyDown:a=>{"Enter"===a.key&&c6(),"Escape"===a.key&&(a0(null),a2(""))}}),a3&&(0,b.jsx)("span",{className:"text-xs text-destructive",children:a3}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:c6,children:(0,b.jsx)(f.Check,{className:"h-3 w-3"})}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{a0(null),a2("")},children:(0,b.jsx)(S.X,{className:"h-3 w-3"})})]}),""===a5&&(0,b.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 border-b shrink-0",children:[(0,b.jsx)(n.FileText,{className:"h-4 w-4 shrink-0 text-accent"}),(0,b.jsx)("input",{autoFocus:!0,className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"filename (default .md)",value:a7,onChange:a=>a8(a.target.value),onKeyDown:a=>{"Enter"===a.key&&c7(),"Escape"===a.key&&(a6(null),a8(""))}}),a9&&(0,b.jsx)("span",{className:"text-xs text-destructive",children:a9}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:c7,children:(0,b.jsx)(f.Check,{className:"h-3 w-3"})}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{a6(null),a8("")},children:(0,b.jsx)(S.X,{className:"h-3 w-3"})})]}),(0,b.jsx)("div",{className:"border-b",children:(0,b.jsx)(d5,{onOpenFile:cU})}),(0,b.jsxs)("div",{ref:aH,className:(0,Z.cn)("flex-1 overflow-auto py-1 editorial-file-tree",""===b6&&"ring-2 ring-inset ring-primary bg-primary/5"),onDragOver:a=>di(a,"","root"),onDragLeave:a=>{a.currentTarget.contains(a.relatedTarget)||b7(null)},onDrop:a=>dj(a,""),children:[aG.length>0&&(0,b.jsxs)("div",{className:"border-b mb-1",children:[(0,b.jsxs)("button",{type:"button",className:"flex w-full items-center gap-1 px-2 py-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground hover:text-foreground",onClick:()=>aD(a=>!a),children:[aC?(0,b.jsx)(h.ChevronRight,{className:"h-3 w-3"}):(0,b.jsx)(g.ChevronDown,{className:"h-3 w-3"}),(0,b.jsx)(I,{className:"h-3 w-3"}),"Pinned",(0,b.jsx)("span",{className:"ml-auto text-[9px] tabular-nums opacity-60",children:aG.length})]}),!aC&&aG.map(a=>(0,b.jsxs)(cF,{children:[(0,b.jsx)(cH,{asChild:!0,children:(0,b.jsxs)("div",{role:"button",tabIndex:0,className:(0,Z.cn)("group flex items-center gap-1.5 rounded-sm px-2 py-1 text-sm cursor-pointer transition-colors select-none",bg?.path===a.path?"bg-accent-soft text-foreground font-medium":"hover:bg-muted"),onClick:()=>{cV(a)},onKeyDown:b=>{("Enter"===b.key||" "===b.key)&&(b.preventDefault(),cV(a))},children:[(0,b.jsx)(es,{name:a.name,type:a.type??"file"}),(0,b.jsx)("span",{className:"min-w-0 flex-1 truncate text-xs",title:bz?a.name:void 0,children:bz?ea(a.name):a.name}),(0,b.jsx)("span",{className:"max-w-[80px] truncate text-[10px] text-muted-foreground/60",children:a.path.split("/").slice(0,-1).join("/")}),(0,b.jsx)("button",{type:"button",className:"hover-reveal shrink-0 rounded p-0.5 text-muted-foreground/50 opacity-0 transition-colors hover:bg-muted hover:text-amber-400 group-hover:opacity-100 focus:opacity-100",title:"Remove from pinned",onClick:b=>{b.stopPropagation(),cZ.getState().toggle({path:a.path,name:a.name},V)},children:(0,b.jsx)(S.X,{className:"h-3 w-3"})})]})}),(0,b.jsx)(er,{node:{path:a.path,name:a.name,type:a.type??"file"},ctx:dv,isPinned:!0,activeWorkspaceId:V})]},a.path))]}),aB.length>0&&(0,b.jsxs)("div",{className:"border-b mb-1",children:[(0,b.jsxs)("button",{type:"button",className:"flex w-full items-center gap-1 px-2 py-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground hover:text-foreground",onClick:()=>aF(a=>!a),children:[aE?(0,b.jsx)(h.ChevronRight,{className:"h-3 w-3"}):(0,b.jsx)(g.ChevronDown,{className:"h-3 w-3"}),(0,b.jsx)(v,{className:"h-3 w-3"}),"Recent",(0,b.jsx)("span",{className:"ml-auto text-[9px] tabular-nums opacity-60",children:aB.length})]}),!aE&&aB.slice(0,8).map(a=>(0,b.jsxs)(cF,{children:[(0,b.jsx)(cH,{asChild:!0,children:(0,b.jsxs)("div",{role:"button",tabIndex:0,className:(0,Z.cn)("flex items-center gap-1.5 rounded-sm px-2 py-1 text-sm cursor-pointer transition-colors select-none",bg?.path===a.path?"bg-accent-soft text-foreground font-medium":"hover:bg-muted"),onClick:()=>{cT({path:a.path,name:a.name,type:a.type??"file",modifiedAt:""}),bu&&bw(!0)},onKeyDown:b=>{("Enter"===b.key||" "===b.key)&&(b.preventDefault(),cT({path:a.path,name:a.name,type:a.type??"file",modifiedAt:""}))},children:[(0,b.jsx)(es,{name:a.name,type:a.type??"file"}),(0,b.jsx)("span",{className:"flex-1 truncate text-xs",title:bz?a.name:void 0,children:bz?ea(a.name):a.name}),(0,b.jsx)("span",{className:"text-[10px] text-muted-foreground/60 truncate max-w-[80px]",children:a.path.split("/").slice(0,-1).join("/")})]})}),(0,b.jsx)(er,{node:{path:a.path,name:a.name,type:a.type??"file"},ctx:dv,isPinned:aG.some(b=>b.path===a.path),activeWorkspaceId:V})]},a.path))]}),aQ?(0,b.jsx)("div",{className:"flex justify-center py-6",children:(0,b.jsx)(z.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):0===aM.length?(0,b.jsxs)("div",{className:"flex flex-col items-center gap-3 px-4 py-8 text-center",children:[(0,b.jsx)("div",{className:"rounded-full bg-muted p-3",children:(0,b.jsx)(n.FileText,{className:"h-6 w-6 text-muted-foreground"})}),(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)("p",{className:"text-sm font-medium",children:"No files yet"}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:"Upload files or add them to the configured directory"})]}),(0,b.jsxs)(U.Button,{size:"sm",variant:"outline",className:"w-full gap-1.5 max-w-[180px]",onClick:()=>c5(""),disabled:aV,children:[aV?(0,b.jsx)(z.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):(0,b.jsx)(R.Upload,{className:"h-3.5 w-3.5"}),"Upload Files"]})]}):(0,b.jsx)(eu,{ctx:dv,nodes:aM,openPath:bg?.path??null,dragOverPath:b6,branchDropdownNode:cC,branchDropdownPos:cE,nodeBranches:cu,branchesLoading:cy,checkingOutBranch:cA,pullingRepo:ce,activePaths:aJ,pins:aG,isMobile:bu,activeWorkspaceId:V,newFileParent:a5,newFileName:a7,fileCreateError:a9,newFolderParent:a_,newFolderName:a1,folderError:a3,sidebarScrollRef:aH})]}),(0,b.jsxs)("div",{className:"border-t px-2 py-2 bg-muted shrink-0",children:[(0,b.jsxs)(bJ.DropdownMenu,{modal:!1,onOpenChange:a=>{a||(aw(null),ay(null))},children:[(0,b.jsx)(bJ.DropdownMenuTrigger,{asChild:!0,children:(0,b.jsxs)(U.Button,{size:"sm",variant:"ghost",className:"w-full h-auto justify-between gap-2 px-2 py-1.5 text-left",title:p??"",children:[(0,b.jsxs)("span",{className:"flex flex-col min-w-0",children:[(0,b.jsx)("span",{className:"truncate text-xs font-medium",children:$.find(a=>a.id===V)?.name??"Workspace"}),(0,b.jsx)("span",{className:"truncate text-[10px] text-muted-foreground font-mono",children:p??""})]}),(0,b.jsx)(g.ChevronDown,{className:"h-3.5 w-3.5 shrink-0 opacity-60"})]})}),(0,b.jsxs)(bJ.DropdownMenuContent,{align:"start",className:"w-[var(--radix-dropdown-menu-trigger-width)]",onInteractOutside:a=>{a.target?.closest?.("[data-branch-portal]")&&a.preventDefault()},children:[$.map(a=>(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>void cX(a.id),onPointerMove:a=>a.preventDefault(),onPointerLeave:a=>a.preventDefault(),className:(0,Z.cn)("gap-2",a.id===V&&"font-medium"),children:[a.id===V?(0,b.jsx)(f.Check,{className:"h-3.5 w-3.5 shrink-0"}):(0,b.jsx)("span",{className:"w-3.5 shrink-0"}),(0,b.jsxs)("span",{className:"flex flex-col min-w-0 flex-1",children:[(0,b.jsxs)("span",{className:"flex items-center gap-1.5 truncate",children:[(0,b.jsx)("span",{className:"truncate",children:a.name}),a.git?aa?(0,b.jsxs)("button",{"data-branch-trigger":!0,type:"button",className:"inline-flex items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground font-normal shrink-0 hover:bg-accent",title:"Switch branch",disabled:ar===a.id,onClick:b=>{if(b.stopPropagation(),b.preventDefault(),av===a.id){aw(null),ay(null);return}let c=b.currentTarget.getBoundingClientRect();ay({top:c.bottom+4,left:c.left}),aw(a.id),c1(a.id)},children:[(0,b.jsx)(r,{className:"h-2.5 w-2.5"})," ",a.git.branch??"branch"]}):(0,b.jsxs)("span",{className:"inline-flex items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground font-normal shrink-0",children:[(0,b.jsx)(r,{className:"h-2.5 w-2.5"})," ",a.git.branch??"read-only"]}):a.ssh?(0,b.jsxs)("span",{className:"inline-flex items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground font-normal shrink-0",children:[(0,b.jsx)(s,{className:"h-2.5 w-2.5"})," ",a.ssh.host]}):a.readOnly?(0,b.jsxs)("span",{className:"inline-flex items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground font-normal shrink-0",children:[(0,b.jsx)(r,{className:"h-2.5 w-2.5"})," read-only"]}):null]}),(0,b.jsx)("span",{className:"truncate text-[10px] text-muted-foreground font-mono",children:a.rootDir}),a.git?.lastPulledAt&&ec(a.git.lastPulledAt)&&(0,b.jsxs)("span",{className:"text-[10px] text-muted-foreground/70",children:["synced ",ec(a.git.lastPulledAt)]})]}),aa&&a.git&&(0,b.jsx)("button",{className:(0,Z.cn)("shrink-0 rounded p-0.5 hover:bg-accent transition-colors",a.git.lastError?"text-destructive":"text-muted-foreground hover:text-foreground"),title:a.git.lastError?`Last refresh failed: ${a.git.lastError}`:"Refresh",disabled:an===a.id,onClick:b=>{b.stopPropagation(),b.preventDefault(),c0(a.id)},children:(0,b.jsx)(K,{className:(0,Z.cn)("h-3.5 w-3.5",an===a.id&&"animate-spin")})}),aa&&(0,b.jsx)("button",{className:"shrink-0 rounded p-0.5 text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors",title:"Delete workspace (does not delete files)",onClick:b=>{b.stopPropagation(),am(a.id)},children:(0,b.jsx)(Q.Trash2,{className:"h-3.5 w-3.5"})})]},a.id)),aa&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(bJ.DropdownMenuSeparator,{}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>aj(!0),children:[(0,b.jsx)(q,{className:"mr-2 h-3.5 w-3.5"}),"Add workspace…"]})]})]})]}),(()=>{if(!av||!ax)return null;let a=$.find(a=>a.id===av);return a?(0,b.jsx)(bS,{pos:ax,branches:(ap[a.id]??[]).map(b=>({name:b,current:b===a.git?.branch})),loading:!ap[a.id],busyName:ar===a.id?at:null,disabled:ar===a.id,onPick:b=>{c2(a.id,b)},onClose:()=>{aw(null),ay(null)}}):null})()]}),(0,b.jsx)("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize sidebar",title:"Drag to resize",onMouseDown:a=>{a.preventDefault();let b=a.clientX;bF(!0);let c=document.body.style.cursor,d=document.body.style.userSelect;document.body.style.cursor="col-resize",document.body.style.userSelect="none";let e=a=>{bC(bx+(a.clientX-b))},f=()=>{bF(!1),document.body.style.cursor=c,document.body.style.userSelect=d,window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",f)};window.addEventListener("mousemove",e),window.addEventListener("mouseup",f)},onDoubleClick:()=>bC(288),onKeyDown:a=>{"ArrowLeft"===a.key?(a.preventDefault(),bC(bx-16)):"ArrowRight"===a.key&&(a.preventDefault(),bC(bx+16))},tabIndex:0,"aria-valuemin":200,"aria-valuemax":600,"aria-valuenow":bx,className:(0,Z.cn)("absolute right-0 top-0 z-20 h-full w-1.5 cursor-col-resize -mr-px transition-colors hover:bg-primary/40 focus:bg-primary/40 focus:outline-none hidden md:block",bD&&"bg-primary/60")})]}),(0,b.jsxs)("div",{className:"flex-1 flex flex-col min-w-0 relative",children:[bv&&(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"hidden md:flex absolute left-2 top-2 z-10 h-7 w-7 p-0",title:"Show sidebar",onClick:()=>bw(!1),children:(0,b.jsx)(E,{className:"h-3.5 w-3.5"})}),(0,b.jsxs)("div",{className:"md:hidden flex h-11 shrink-0 items-center justify-between gap-2 border-b bg-muted px-1",children:[(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-9 w-9 p-0",title:"Show sidebar",onClick:()=>{bw(!1),c_.useAIPanelStore.getState().close()},children:(0,b.jsx)(E,{className:"h-4 w-4"})}),(0,b.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5 text-xs font-semibold tracking-tight text-muted-foreground",title:bg?.path,children:[bg&&(0,b.jsx)("span",{className:"editorial-tree-typeicon shrink-0",children:"app"===dk||"html"===dk?(0,b.jsx)(u.Globe,{className:"h-4 w-4 text-foreground/70"}):ej(bg.name)?(0,b.jsx)(x.default,{className:"h-4 w-4 text-sunshine-700"}):eh(bg.name)?(0,b.jsx)(n.FileText,{className:"h-4 w-4 text-foreground/70"}):(0,b.jsx)(l.File,{className:"h-4 w-4 text-foreground/60"})}),(0,b.jsx)("span",{className:"truncate",children:bg?bg.name:"Wiki Viewer"})]}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-9 w-9 p-0",title:"AI Agent panel",onClick:()=>{c_.useAIPanelStore.getState().open(),bw(!0)},children:(0,b.jsx)(e,{className:"h-4 w-4"})})]}),bg?"node-app"===dk?(0,b.jsx)(bL,{path:bg.path,title:bg.name}):"app"===dk||"html"===dk?(a="html"===dk?`/api/assets/${bg.path}`:void 0,bk?(0,b.jsx)(bG,{path:bg.path,title:bg.name,src:a,fullscreen:!0,onExit:()=>bl(!1)}):(0,b.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-w-0",children:[(0,b.jsxs)("div",{className:(0,Z.cn)("flex items-center justify-between px-4 py-2 border-b bg-muted shrink-0 editorial-doc-header",!bu&&bv&&"pl-11"),children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,b.jsx)("span",{className:"hidden md:inline-flex",children:(0,b.jsx)("span",{className:"editorial-tree-typeicon",children:(0,b.jsx)(u.Globe,{className:"h-4 w-4 shrink-0 text-foreground/70"})})}),(0,b.jsx)("span",{className:"hidden md:inline text-sm font-normal truncate",title:bg.path,children:bg.path})]}),(0,b.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[df(bg,(0,b.jsxs)(b.Fragment,{children:["html"===dk&&!bW&&(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>b0(a=>!a),children:[b$?(0,b.jsx)(u.Globe,{className:"mr-2 h-3.5 w-3.5"}):(0,b.jsx)(t.Code2,{className:"mr-2 h-3.5 w-3.5"}),b$?"Show preview":"Show source"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>bo(a=>a+1),children:[(0,b.jsx)(K,{className:"mr-2 h-3.5 w-3.5"}),"Refresh"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>bl(!0),children:[(0,b.jsx)(A,{className:"mr-2 h-3.5 w-3.5"}),"Open fullscreen"]})]})),"html"===dk&&!bW&&null!==bN&&(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Edit source",onClick:()=>{bX(!0),bZ(bN),b4(null)},children:(0,b.jsx)(F,{className:"h-3.5 w-3.5"})}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{bh(null),bX(!1)},children:(0,b.jsx)(S.X,{className:"h-3.5 w-3.5"})})]})]}),bW&&"html"===dk?(0,b.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:[(0,b.jsx)("textarea",{value:bY,onChange:a=>bZ(a.target.value),spellCheck:!1,className:"flex-1 w-full min-h-0 resize-none bg-background text-foreground px-4 py-3 font-mono text-[13px] leading-relaxed outline-none border-0"}),(0,b.jsxs)("div",{className:"border-t px-4 py-2 flex items-center justify-end gap-2 bg-muted shrink-0",children:[b3&&(0,b.jsx)("span",{className:"text-xs text-destructive mr-auto",children:b3}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",onClick:()=>{bX(!1),b4(null)},children:"Cancel"}),(0,b.jsxs)(U.Button,{size:"sm",className:"gap-1",onClick:c3,disabled:b1,children:[b1&&(0,b.jsx)(z.Loader2,{className:"h-3 w-3 animate-spin"}),"Save"]})]})]}):b$&&"html"===dk?(0,b.jsx)(bE,{path:bg.path,title:bg.name}):(0,b.jsx)(bG,{path:bg.path,title:bg.name,src:a},bm)]})):(0,b.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-w-0",children:[(0,b.jsxs)("div",{className:(0,Z.cn)("flex items-center justify-between px-4 py-2 border-b bg-muted shrink-0 editorial-doc-header",!bu&&bv&&"pl-11"),children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,b.jsx)("span",{className:"hidden md:inline-flex",children:(0,b.jsx)("span",{className:"editorial-tree-typeicon",children:ej(bg.name)?(0,b.jsx)(x.default,{className:"h-4 w-4 shrink-0 text-sunshine-700"}):eh(bg.name)?(0,b.jsx)(n.FileText,{className:"h-4 w-4 shrink-0 text-foreground/70"}):(0,b.jsx)(l.File,{className:"h-4 w-4 shrink-0 text-foreground/60"})})}),(0,b.jsx)("span",{className:"hidden md:inline text-sm font-normal truncate",title:bg.path,children:bg.path}),cg&&(0,b.jsxs)("span",{className:"hidden md:flex items-center gap-1 text-[11px] text-muted-foreground shrink-0 ml-1",children:[(0,b.jsx)(w,{className:"h-3 w-3 shrink-0"}),(0,b.jsx)("span",{className:"truncate max-w-[100px]",children:cg.author}),(0,b.jsx)("span",{title:new Date(cg.date).toLocaleString(),className:"shrink-0",children:ec(cg.date)})]})]}),(0,b.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[df(bg,(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>{ci?cj(!1):cK()},children:[(0,b.jsx)(v,{className:"mr-2 h-3.5 w-3.5"}),ci?"Hide history":"File history"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>bM(!0),children:[(0,b.jsx)(M,{className:"mr-2 h-3.5 w-3.5"}),"Share"]}),!bW&&(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:cR,disabled:bU,children:[bU?(0,b.jsx)(z.Loader2,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):(0,b.jsx)(K,{className:"mr-2 h-3.5 w-3.5"}),"Refresh"]}),dr&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(bJ.DropdownMenuSeparator,{}),(0,b.jsx)(bJ.DropdownMenuLabel,{className:"text-[11px] text-muted-foreground",children:"Width"}),d2.VIEW_WIDTH_ORDER.map(a=>(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>dp(a),className:"flex items-center justify-between text-xs",children:[d2.VIEW_WIDTH_LABEL[a],a===dm&&(0,b.jsx)(f.Check,{className:"h-3.5 w-3.5"})]},a)),(0,b.jsx)(bJ.DropdownMenuSeparator,{}),(0,b.jsx)(bJ.DropdownMenuLabel,{className:"text-[11px] text-muted-foreground",children:"Alignment"}),d2.VIEW_ALIGN_ORDER.map(a=>(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>dq(a),className:"flex items-center justify-between text-xs",children:[d2.VIEW_ALIGN_LABEL[a],a===dn&&(0,b.jsx)(f.Check,{className:"h-3.5 w-3.5"})]},a))]})]})),eh(bg.name)&&!bW&&(null!==bN||ei(bg.name))&&(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{bX(!0),bZ(bN??""),b4(null),ei(bg.name)&&c8.useEditorStore.getState().loadPage(bg.path)},children:(0,b.jsx)(F,{className:"h-3.5 w-3.5"})}),eh(bg.name)&&bW&&ei(bg.name)&&(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Done editing",onClick:()=>{bX(!1),b4(null)},children:(0,b.jsx)(G.Eye,{className:"h-3.5 w-3.5"})}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{bh(null),bO(null),bX(!1)},children:(0,b.jsx)(S.X,{className:"h-3.5 w-3.5"})})]})]}),ci&&(0,b.jsxs)("div",{className:"border-b bg-muted/30 shrink-0 max-h-[40vh] overflow-auto",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between px-4 py-1.5 border-b",children:[(0,b.jsx)("span",{className:"text-xs font-semibold text-muted-foreground",children:"History"}),(0,b.jsx)("button",{type:"button",className:"text-muted-foreground hover:text-foreground",onClick:()=>cj(!1),children:(0,b.jsx)(S.X,{className:"h-3.5 w-3.5"})})]}),cm?(0,b.jsx)("div",{className:"flex justify-center py-4",children:(0,b.jsx)(z.Loader2,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):0===ck.length?(0,b.jsx)("p",{className:"px-4 py-3 text-xs text-muted-foreground",children:"No history found."}):(0,b.jsx)("div",{children:ck.map(a=>(0,b.jsxs)("div",{children:[(0,b.jsx)("button",{type:"button",className:(0,Z.cn)("w-full text-left px-4 py-2 hover:bg-muted transition-colors",co===a.sha&&"bg-muted"),onClick:()=>void cL(a.sha),children:(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("code",{className:"text-[11px] font-mono text-muted-foreground shrink-0",children:a.shortSha}),(0,b.jsx)("span",{className:"flex-1 truncate text-xs",children:a.message}),(0,b.jsx)("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:a.author}),(0,b.jsx)("span",{className:"shrink-0 text-[11px] text-muted-foreground",title:new Date(a.date).toLocaleString(),children:ec(a.date)})]})}),co===a.sha&&(0,b.jsx)("div",{className:"border-t",children:cs?(0,b.jsx)("div",{className:"flex justify-center py-3",children:(0,b.jsx)(z.Loader2,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):null!==cq?(0,b.jsx)("pre",{className:"overflow-auto px-4 py-2 text-[11px] font-mono leading-relaxed whitespace-pre text-foreground/80 max-h-60",children:cq}):null})]},a.sha))})]}),dl?(0,b.jsx)(ag,{path:bg.path,size:bg.size??0,onOpen:()=>bj(bg.path)}):bW?(0,b.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:ei(bg.name)?(0,b.jsx)(ac.KBEditor,{}):(0,b.jsx)("textarea",{value:bY,onChange:a=>bZ(a.target.value),spellCheck:!1,className:"flex-1 w-full min-h-0 resize-none bg-background text-foreground px-4 py-3 font-mono text-[13px] leading-relaxed outline-none border-0"})}):ei(bg.name)?(0,b.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:bU?(0,b.jsx)("div",{className:"flex justify-center py-8",children:(0,b.jsx)(z.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):(0,b.jsx)(ac.KBEditor,{mode:"viewing"})}):"csv"===dk||"pdf"===dk||"mermaid"===dk||"notebook"===dk||"image"===dk||"media"===dk||"docx"===dk||"xlsx"===dk||"pptx"===dk||"source"===dk||"fallback"===dk?(0,b.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:bU?(0,b.jsx)("div",{className:"flex justify-center py-8",children:(0,b.jsx)(z.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):"csv"===dk?(0,b.jsx)(ab,{path:bg.path,title:bg.name}):"pdf"===dk?(0,b.jsx)(eb,{path:bg.path,title:bg.name}):"mermaid"===dk?(0,b.jsx)(ak,{path:bg.path,title:bg.name}):"notebook"===dk?(0,b.jsx)(bn,{path:bg.path,title:bg.name}):"image"===dk?(0,b.jsx)(ah,{path:bg.path,title:bg.name}):"media"===dk?(0,b.jsx)(ai,{path:bg.path,title:bg.name,type:["mp4","webm","mov","m4v"].includes(ee(bg.name))?"video":"audio"}):"docx"===dk?(0,b.jsx)(bp,{path:bg.path,title:bg.name}):"xlsx"===dk?(0,b.jsx)(br,{path:bg.path,title:bg.name}):"pptx"===dk?(0,b.jsx)(bq,{path:bg.path,title:bg.name}):"source"===dk?(0,b.jsx)(bE,{path:bg.path,title:bg.name}):(0,b.jsx)(ad,{path:bg.path,title:bg.name})},bs):(0,b.jsx)("div",{className:"flex-1 overflow-auto p-4 min-h-0",children:(0,b.jsx)("div",{className:(0,Z.cn)("w-full",dt,ds),children:bU?(0,b.jsx)("div",{className:"flex justify-center py-8",children:(0,b.jsx)(z.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):null!==bN?(0,b.jsx)("pre",{className:"text-xs font-mono whitespace-pre-wrap break-words leading-relaxed",children:bN}):eh(bg.name)?(0,b.jsx)("p",{className:"text-sm text-muted-foreground",children:"Could not load file."}):(0,b.jsx)("p",{className:"text-sm text-muted-foreground",children:"Preview not available for this file type."})})}),bW&&!ei(bg.name)&&(0,b.jsxs)("div",{className:"border-t px-4 py-2 flex items-center justify-end gap-2 bg-muted shrink-0",children:[b3&&(0,b.jsx)("span",{className:"text-xs text-destructive mr-auto",children:b3}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",onClick:()=>{bX(!1),b4(null)},children:"Cancel"}),(0,b.jsxs)(U.Button,{size:"sm",className:"gap-1",onClick:c3,disabled:b1,children:[b1&&(0,b.jsx)(z.Loader2,{className:"h-3 w-3 animate-spin"}),"Save"]})]})]}):(0,b.jsx)("div",{className:"flex-1 flex flex-col items-center justify-center",children:(0,b.jsxs)("div",{className:"flex flex-col items-center gap-2 text-center px-4",children:[(0,b.jsx)(n.FileText,{className:"h-8 w-8 text-muted-foreground"}),(0,b.jsx)("p",{className:"text-sm text-muted-foreground",children:"Select a file to view or edit"})]})})]}),(0,b.jsx)(cv,{open:bK,onOpenChange:bM,filePath:bg?.path??""}),(0,b.jsx)(b9,{open:bH,onOpenChange:bI}),(0,b.jsx)(dg,{currentPath:bg?.path}),(0,b.jsx)("input",{ref:aZ,type:"file",multiple:!0,className:"hidden",onChange:a=>{a.target.files&&c4(a.target.files,a$.current)}}),(0,b.jsx)(W,{open:!!bb,onOpenChange:a=>{a||bc(null)},title:bd?"Delete folder?":"Delete file?",description:bd?`"${bb?.split("/").pop()}" and all its contents will be permanently deleted.`:`"${bb?.split("/").pop()}" will be permanently removed.`,onConfirm:dh}),(0,b.jsx)(W,{open:!!al,onOpenChange:a=>{a||am(null)},title:"Delete workspace?",description:`"${$.find(a=>a.id===al)?.name??""}" will be removed from the workspace list. Files on disk are NOT deleted.`,onConfirm:c$})]})]},V??"none")}],240777)}];
18
18
 
19
19
  //# sourceMappingURL=_0v4uz-4._.js.map