@seqyuan/annovibe 0.8.23 → 0.8.24

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 (57) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-path-routes-manifest.json +7 -7
  3. package/.next/build-manifest.json +2 -2
  4. package/.next/prerender-manifest.json +3 -3
  5. package/.next/required-server-files.js +1 -1
  6. package/.next/required-server-files.json +1 -1
  7. package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  8. package/.next/server/app/_global-error.html +1 -1
  9. package/.next/server/app/_global-error.rsc +1 -1
  10. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  11. package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  12. package/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  13. package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  14. package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  15. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  16. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  17. package/.next/server/app/_not-found.html +1 -1
  18. package/.next/server/app/_not-found.rsc +1 -1
  19. package/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
  20. package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  21. package/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
  22. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  23. package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  24. package/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  25. package/.next/server/app/api/apps/[id]/[[...path]]/route.js +2 -2
  26. package/.next/server/app/api/apps/route.js +2 -2
  27. package/.next/server/app/api/internal/runtime/route.js +1 -1
  28. package/.next/server/app/api/version/route.js +1 -1
  29. package/.next/server/app/index.html +1 -1
  30. package/.next/server/app/index.rsc +2 -2
  31. package/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
  32. package/.next/server/app/index.segments/_full.segment.rsc +2 -2
  33. package/.next/server/app/index.segments/_head.segment.rsc +1 -1
  34. package/.next/server/app/index.segments/_index.segment.rsc +1 -1
  35. package/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  36. package/.next/server/app/login/page_client-reference-manifest.js +1 -1
  37. package/.next/server/app/login.html +1 -1
  38. package/.next/server/app/login.rsc +1 -1
  39. package/.next/server/app/login.segments/_full.segment.rsc +1 -1
  40. package/.next/server/app/login.segments/_head.segment.rsc +1 -1
  41. package/.next/server/app/login.segments/_index.segment.rsc +1 -1
  42. package/.next/server/app/login.segments/_tree.segment.rsc +1 -1
  43. package/.next/server/app/login.segments/login/__PAGE__.segment.rsc +1 -1
  44. package/.next/server/app/login.segments/login.segment.rsc +1 -1
  45. package/.next/server/app/page.js +2 -2
  46. package/.next/server/app/page_client-reference-manifest.js +1 -1
  47. package/.next/server/app-paths-manifest.json +7 -7
  48. package/.next/server/middleware-build-manifest.js +1 -1
  49. package/.next/server/pages/404.html +1 -1
  50. package/.next/server/pages/500.html +1 -1
  51. package/.next/server/server-reference-manifest.json +1 -1
  52. package/.next/static/chunks/app/{page-c63ff970773f1496.js → page-e6bf6ff10f57135c.js} +2 -2
  53. package/.next/trace +75 -75
  54. package/.next/trace-build +1 -1
  55. package/package.json +1 -1
  56. /package/.next/static/{TFhJ1NtMURrrsapy9bEy4 → CzkRIupKhJuGvzwryyncq}/_buildManifest.js +0 -0
  57. /package/.next/static/{TFhJ1NtMURrrsapy9bEy4 → CzkRIupKhJuGvzwryyncq}/_ssgManifest.js +0 -0
@@ -1,4 +1,4 @@
1
- (()=>{var a={};a.id=8974,a.ids=[8974],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},478:(a,b,c)=>{Promise.resolve().then(c.bind(c,13832))},2414:(a,b)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.default=void 0,b.default={'code[class*="language-"]':{color:"#c5c8c6",textShadow:"0 1px rgba(0, 0, 0, 0.3)",fontFamily:"Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace",direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none"},'pre[class*="language-"]':{color:"#c5c8c6",textShadow:"0 1px rgba(0, 0, 0, 0.3)",fontFamily:"Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace",direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",padding:"1em",margin:".5em 0",overflow:"auto",borderRadius:"0.3em",background:"#1d1f21"},':not(pre) > code[class*="language-"]':{background:"#1d1f21",padding:".1em",borderRadius:".3em"},comment:{color:"#7C7C7C"},prolog:{color:"#7C7C7C"},doctype:{color:"#7C7C7C"},cdata:{color:"#7C7C7C"},punctuation:{color:"#c5c8c6"},".namespace":{Opacity:".7"},property:{color:"#96CBFE"},keyword:{color:"#96CBFE"},tag:{color:"#96CBFE"},"class-name":{color:"#FFFFB6",textDecoration:"underline"},boolean:{color:"#99CC99"},constant:{color:"#99CC99"},symbol:{color:"#f92672"},deleted:{color:"#f92672"},number:{color:"#FF73FD"},selector:{color:"#A8FF60"},"attr-name":{color:"#A8FF60"},string:{color:"#A8FF60"},char:{color:"#A8FF60"},builtin:{color:"#A8FF60"},inserted:{color:"#A8FF60"},variable:{color:"#C6C5FE"},operator:{color:"#EDEDED"},entity:{color:"#FFFFB6",cursor:"help"},url:{color:"#96CBFE"},".language-css .token.string":{color:"#87C38A"},".style .token.string":{color:"#87C38A"},atrule:{color:"#F9EE98"},"attr-value":{color:"#F9EE98"},function:{color:"#DAD085"},regex:{color:"#E9C062"},important:{color:"#fd971f",fontWeight:"bold"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"}}},3174:(a,b)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.camelCase=void 0;var c=/^--[a-zA-Z0-9_-]+$/,d=/-([a-z])/g,e=/^[^-]+$/,f=/^-(webkit|moz|ms|o|khtml)-/,g=/^-(ms)-/,h=function(a,b){return b.toUpperCase()},i=function(a,b){return"".concat(b,"-")};b.camelCase=function(a,b){var j;return(void 0===b&&(b={}),!(j=a)||e.test(j)||c.test(j))?a:(a=a.toLowerCase(),(a=b.reactCompat?a.replace(g,i):a.replace(f,i)).replace(d,h))}},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},3531:(a,b)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.default=void 0,b.default={'code[class*="language-"]':{color:"#d6deeb",fontFamily:'Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace',textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",wordWrap:"normal",lineHeight:"1.5",fontSize:"1em",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none"},'pre[class*="language-"]':{color:"white",fontFamily:'Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace',textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",wordWrap:"normal",lineHeight:"1.5",fontSize:"1em",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",padding:"1em",margin:"0.5em 0",overflow:"auto",background:"#011627"},'pre[class*="language-"]::-moz-selection':{textShadow:"none",background:"rgba(29, 59, 83, 0.99)"},'pre[class*="language-"] ::-moz-selection':{textShadow:"none",background:"rgba(29, 59, 83, 0.99)"},'code[class*="language-"]::-moz-selection':{textShadow:"none",background:"rgba(29, 59, 83, 0.99)"},'code[class*="language-"] ::-moz-selection':{textShadow:"none",background:"rgba(29, 59, 83, 0.99)"},'pre[class*="language-"]::selection':{textShadow:"none",background:"rgba(29, 59, 83, 0.99)"},'pre[class*="language-"] ::selection':{textShadow:"none",background:"rgba(29, 59, 83, 0.99)"},'code[class*="language-"]::selection':{textShadow:"none",background:"rgba(29, 59, 83, 0.99)"},'code[class*="language-"] ::selection':{textShadow:"none",background:"rgba(29, 59, 83, 0.99)"},':not(pre) > code[class*="language-"]':{color:"white",background:"#011627",padding:"0.1em",borderRadius:"0.3em",whiteSpace:"normal"},comment:{color:"rgb(99, 119, 119)",fontStyle:"italic"},prolog:{color:"rgb(99, 119, 119)",fontStyle:"italic"},cdata:{color:"rgb(99, 119, 119)",fontStyle:"italic"},punctuation:{color:"rgb(199, 146, 234)"},".namespace":{color:"rgb(178, 204, 214)"},deleted:{color:"rgba(239, 83, 80, 0.56)",fontStyle:"italic"},symbol:{color:"rgb(128, 203, 196)"},property:{color:"rgb(128, 203, 196)"},tag:{color:"rgb(127, 219, 202)"},operator:{color:"rgb(127, 219, 202)"},keyword:{color:"rgb(127, 219, 202)"},boolean:{color:"rgb(255, 88, 116)"},number:{color:"rgb(247, 140, 108)"},constant:{color:"rgb(130, 170, 255)"},function:{color:"rgb(130, 170, 255)"},builtin:{color:"rgb(130, 170, 255)"},char:{color:"rgb(130, 170, 255)"},selector:{color:"rgb(199, 146, 234)",fontStyle:"italic"},doctype:{color:"rgb(199, 146, 234)",fontStyle:"italic"},"attr-name":{color:"rgb(173, 219, 103)",fontStyle:"italic"},inserted:{color:"rgb(173, 219, 103)",fontStyle:"italic"},string:{color:"rgb(173, 219, 103)"},url:{color:"rgb(173, 219, 103)"},entity:{color:"rgb(173, 219, 103)"},".language-css .token.string":{color:"rgb(173, 219, 103)"},".style .token.string":{color:"rgb(173, 219, 103)"},"class-name":{color:"rgb(255, 203, 139)"},atrule:{color:"rgb(255, 203, 139)"},"attr-value":{color:"rgb(255, 203, 139)"},regex:{color:"rgb(214, 222, 235)"},important:{color:"rgb(214, 222, 235)",fontWeight:"bold"},variable:{color:"rgb(214, 222, 235)"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"}}},4899:(a,b)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.default=void 0,b.default={'code[class*="language-"]':{color:"#111b27",background:"none",fontFamily:'Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace',textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",wordWrap:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none"},'pre[class*="language-"]':{color:"#111b27",background:"#e3eaf2",fontFamily:'Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace',textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",wordWrap:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",padding:"1em",margin:"0.5em 0",overflow:"auto"},'pre[class*="language-"]::-moz-selection':{background:"#8da1b9"},'pre[class*="language-"] ::-moz-selection':{background:"#8da1b9"},'code[class*="language-"]::-moz-selection':{background:"#8da1b9"},'code[class*="language-"] ::-moz-selection':{background:"#8da1b9"},'pre[class*="language-"]::selection':{background:"#8da1b9"},'pre[class*="language-"] ::selection':{background:"#8da1b9"},'code[class*="language-"]::selection':{background:"#8da1b9"},'code[class*="language-"] ::selection':{background:"#8da1b9"},':not(pre) > code[class*="language-"]':{background:"#e3eaf2",padding:"0.1em 0.3em",borderRadius:"0.3em",whiteSpace:"normal"},comment:{color:"#3c526d"},prolog:{color:"#3c526d"},doctype:{color:"#3c526d"},cdata:{color:"#3c526d"},punctuation:{color:"#111b27"},"delimiter.important":{color:"#006d6d",fontWeight:"inherit"},"selector.parent":{color:"#006d6d"},tag:{color:"#006d6d"},"tag.punctuation":{color:"#006d6d"},"attr-name":{color:"#755f00"},boolean:{color:"#755f00"},"boolean.important":{color:"#755f00"},number:{color:"#755f00"},constant:{color:"#755f00"},"selector.attribute":{color:"#755f00"},"class-name":{color:"#005a8e"},key:{color:"#005a8e"},parameter:{color:"#005a8e"},property:{color:"#005a8e"},"property-access":{color:"#005a8e"},variable:{color:"#005a8e"},"attr-value":{color:"#116b00"},inserted:{color:"#116b00"},color:{color:"#116b00"},"selector.value":{color:"#116b00"},string:{color:"#116b00"},"string.url-link":{color:"#116b00"},builtin:{color:"#af00af"},"keyword-array":{color:"#af00af"},package:{color:"#af00af"},regex:{color:"#af00af"},function:{color:"#7c00aa"},"selector.class":{color:"#7c00aa"},"selector.id":{color:"#7c00aa"},"atrule.rule":{color:"#a04900"},combinator:{color:"#a04900"},keyword:{color:"#a04900"},operator:{color:"#a04900"},"pseudo-class":{color:"#a04900"},"pseudo-element":{color:"#a04900"},selector:{color:"#a04900"},unit:{color:"#a04900"},deleted:{color:"#c22f2e"},important:{color:"#c22f2e",fontWeight:"bold"},"keyword-this":{color:"#005a8e",fontWeight:"bold"},this:{color:"#005a8e",fontWeight:"bold"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"},entity:{cursor:"help"},".language-markdown .token.title":{color:"#005a8e",fontWeight:"bold"},".language-markdown .token.title .token.punctuation":{color:"#005a8e",fontWeight:"bold"},".language-markdown .token.blockquote.punctuation":{color:"#af00af"},".language-markdown .token.code":{color:"#006d6d"},".language-markdown .token.hr.punctuation":{color:"#005a8e"},".language-markdown .token.url > .token.content":{color:"#116b00"},".language-markdown .token.url-link":{color:"#755f00"},".language-markdown .token.list.punctuation":{color:"#af00af"},".language-markdown .token.table-header":{color:"#111b27"},".language-json .token.operator":{color:"#111b27"},".language-scss .token.variable":{color:"#006d6d"},"token.tab:not(:empty):before":{color:"#3c526d"},"token.cr:before":{color:"#3c526d"},"token.lf:before":{color:"#3c526d"},"token.space:before":{color:"#3c526d"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > a":{color:"#e3eaf2",background:"#005a8e"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > button":{color:"#e3eaf2",background:"#005a8e"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > a:hover":{color:"#e3eaf2",background:"#005a8eda",textDecoration:"none"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > a:focus":{color:"#e3eaf2",background:"#005a8eda",textDecoration:"none"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > button:hover":{color:"#e3eaf2",background:"#005a8eda",textDecoration:"none"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > button:focus":{color:"#e3eaf2",background:"#005a8eda",textDecoration:"none"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > span":{color:"#e3eaf2",background:"#3c526d"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > span:hover":{color:"#e3eaf2",background:"#3c526d"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > span:focus":{color:"#e3eaf2",background:"#3c526d"},".line-highlight.line-highlight":{background:"linear-gradient(to right, #8da1b92f 70%, #8da1b925)"},".line-highlight.line-highlight:before":{backgroundColor:"#3c526d",color:"#e3eaf2",boxShadow:"0 1px #8da1b9"},".line-highlight.line-highlight[data-end]:after":{backgroundColor:"#3c526d",color:"#e3eaf2",boxShadow:"0 1px #8da1b9"},"pre[id].linkable-line-numbers.linkable-line-numbers span.line-numbers-rows > span:hover:before":{backgroundColor:"#3c526d1f"},".line-numbers.line-numbers .line-numbers-rows":{borderRight:"1px solid #8da1b97a",background:"#d0dae77a"},".line-numbers .line-numbers-rows > span:before":{color:"#3c526dda"},".rainbow-braces .token.token.punctuation.brace-level-1":{color:"#755f00"},".rainbow-braces .token.token.punctuation.brace-level-5":{color:"#755f00"},".rainbow-braces .token.token.punctuation.brace-level-9":{color:"#755f00"},".rainbow-braces .token.token.punctuation.brace-level-2":{color:"#af00af"},".rainbow-braces .token.token.punctuation.brace-level-6":{color:"#af00af"},".rainbow-braces .token.token.punctuation.brace-level-10":{color:"#af00af"},".rainbow-braces .token.token.punctuation.brace-level-3":{color:"#005a8e"},".rainbow-braces .token.token.punctuation.brace-level-7":{color:"#005a8e"},".rainbow-braces .token.token.punctuation.brace-level-11":{color:"#005a8e"},".rainbow-braces .token.token.punctuation.brace-level-4":{color:"#7c00aa"},".rainbow-braces .token.token.punctuation.brace-level-8":{color:"#7c00aa"},".rainbow-braces .token.token.punctuation.brace-level-12":{color:"#7c00aa"},"pre.diff-highlight > code .token.token.deleted:not(.prefix)":{backgroundColor:"#c22f2e1f"},"pre > code.diff-highlight .token.token.deleted:not(.prefix)":{backgroundColor:"#c22f2e1f"},"pre.diff-highlight > code .token.token.inserted:not(.prefix)":{backgroundColor:"#116b001f"},"pre > code.diff-highlight .token.token.inserted:not(.prefix)":{backgroundColor:"#116b001f"},".command-line .command-line-prompt":{borderRight:"1px solid #8da1b97a"},".command-line .command-line-prompt > span:before":{color:"#3c526dda"}}},5206:(a,b,c)=>{Promise.resolve().then(c.bind(c,35790))},5482:(a,b)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.default=void 0,b.default={'code[class*="language-"]':{color:"#a9b7c6",fontFamily:"Consolas, Monaco, 'Andale Mono', monospace",direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none"},'pre[class*="language-"]':{color:"#a9b7c6",fontFamily:"Consolas, Monaco, 'Andale Mono', monospace",direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",padding:"1em",margin:".5em 0",overflow:"auto",background:"#2b2b2b"},'pre[class*="language-"]::-moz-selection':{color:"inherit",background:"rgba(33, 66, 131, .85)"},'pre[class*="language-"] ::-moz-selection':{color:"inherit",background:"rgba(33, 66, 131, .85)"},'code[class*="language-"]::-moz-selection':{color:"inherit",background:"rgba(33, 66, 131, .85)"},'code[class*="language-"] ::-moz-selection':{color:"inherit",background:"rgba(33, 66, 131, .85)"},'pre[class*="language-"]::selection':{color:"inherit",background:"rgba(33, 66, 131, .85)"},'pre[class*="language-"] ::selection':{color:"inherit",background:"rgba(33, 66, 131, .85)"},'code[class*="language-"]::selection':{color:"inherit",background:"rgba(33, 66, 131, .85)"},'code[class*="language-"] ::selection':{color:"inherit",background:"rgba(33, 66, 131, .85)"},':not(pre) > code[class*="language-"]':{background:"#2b2b2b",padding:".1em",borderRadius:".3em"},comment:{color:"#808080"},prolog:{color:"#808080"},cdata:{color:"#808080"},delimiter:{color:"#cc7832"},boolean:{color:"#cc7832"},keyword:{color:"#cc7832"},selector:{color:"#cc7832"},important:{color:"#cc7832"},atrule:{color:"#cc7832"},operator:{color:"#a9b7c6"},punctuation:{color:"#a9b7c6"},"attr-name":{color:"#a9b7c6"},tag:{color:"#e8bf6a"},"tag.punctuation":{color:"#e8bf6a"},doctype:{color:"#e8bf6a"},builtin:{color:"#e8bf6a"},entity:{color:"#6897bb"},number:{color:"#6897bb"},symbol:{color:"#6897bb"},property:{color:"#9876aa"},constant:{color:"#9876aa"},variable:{color:"#9876aa"},string:{color:"#6a8759"},char:{color:"#6a8759"},"attr-value":{color:"#a5c261"},"attr-value.punctuation":{color:"#a5c261"},"attr-value.punctuation:first-child":{color:"#a9b7c6"},url:{color:"#287bde",textDecoration:"underline"},function:{color:"#ffc66d"},regex:{background:"#364135"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"},inserted:{background:"#294436"},deleted:{background:"#484a4a"},"code.language-css .token.property":{color:"#a9b7c6"},"code.language-css .token.property + .token.punctuation":{color:"#a9b7c6"},"code.language-css .token.id":{color:"#ffc66d"},"code.language-css .token.selector > .token.class":{color:"#ffc66d"},"code.language-css .token.selector > .token.attribute":{color:"#ffc66d"},"code.language-css .token.selector > .token.pseudo-class":{color:"#ffc66d"},"code.language-css .token.selector > .token.pseudo-element":{color:"#ffc66d"}}},5827:a=>{"use strict";var b=Object.prototype.hasOwnProperty,c=Object.prototype.toString,d=Object.defineProperty,e=Object.getOwnPropertyDescriptor,f=function(a){return"function"==typeof Array.isArray?Array.isArray(a):"[object Array]"===c.call(a)},g=function(a){if(!a||"[object Object]"!==c.call(a))return!1;var d,e=b.call(a,"constructor"),f=a.constructor&&a.constructor.prototype&&b.call(a.constructor.prototype,"isPrototypeOf");if(a.constructor&&!e&&!f)return!1;for(d in a);return void 0===d||b.call(a,d)},h=function(a,b){d&&"__proto__"===b.name?d(a,b.name,{enumerable:!0,configurable:!0,value:b.newValue,writable:!0}):a[b.name]=b.newValue},i=function(a,c){if("__proto__"===c){if(!b.call(a,c))return;else if(e)return e(a,c).value}return a[c]};a.exports=function a(){var b,c,d,e,j,k,l=arguments[0],m=1,n=arguments.length,o=!1;for("boolean"==typeof l&&(o=l,l=arguments[1]||{},m=2),(null==l||"object"!=typeof l&&"function"!=typeof l)&&(l={});m<n;++m)if(b=arguments[m],null!=b)for(c in b)d=i(l,c),l!==(e=i(b,c))&&(o&&e&&(g(e)||(j=f(e)))?(j?(j=!1,k=d&&f(d)?d:[]):k=d&&g(d)?d:{},h(l,{name:c,newValue:a(o,k,e)})):void 0!==e&&h(l,{name:c,newValue:e}));return l}},8760:(a,b)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.default=void 0,b.default={'code[class*="language-"]':{color:"#f8f8f2",background:"none",textShadow:"0 1px rgba(0, 0, 0, 0.3)",fontFamily:"Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",wordWrap:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none"},'pre[class*="language-"]':{color:"#f8f8f2",background:"#282a36",textShadow:"0 1px rgba(0, 0, 0, 0.3)",fontFamily:"Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",wordWrap:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",padding:"1em",margin:".5em 0",overflow:"auto",borderRadius:"0.3em"},':not(pre) > code[class*="language-"]':{background:"#282a36",padding:".1em",borderRadius:".3em",whiteSpace:"normal"},comment:{color:"#6272a4"},prolog:{color:"#6272a4"},doctype:{color:"#6272a4"},cdata:{color:"#6272a4"},punctuation:{color:"#f8f8f2"},".namespace":{Opacity:".7"},property:{color:"#ff79c6"},tag:{color:"#ff79c6"},constant:{color:"#ff79c6"},symbol:{color:"#ff79c6"},deleted:{color:"#ff79c6"},boolean:{color:"#bd93f9"},number:{color:"#bd93f9"},selector:{color:"#50fa7b"},"attr-name":{color:"#50fa7b"},string:{color:"#50fa7b"},char:{color:"#50fa7b"},builtin:{color:"#50fa7b"},inserted:{color:"#50fa7b"},operator:{color:"#f8f8f2"},entity:{color:"#f8f8f2",cursor:"help"},url:{color:"#f8f8f2"},".language-css .token.string":{color:"#f8f8f2"},".style .token.string":{color:"#f8f8f2"},variable:{color:"#f8f8f2"},atrule:{color:"#f1fa8c"},"attr-value":{color:"#f1fa8c"},function:{color:"#f1fa8c"},"class-name":{color:"#f1fa8c"},keyword:{color:"#8be9fd"},regex:{color:"#ffb86c"},important:{color:"#ffb86c",fontWeight:"bold"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"}}},10017:(a,b)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.default=void 0,b.default={'code[class*="language-"]':{color:"#657b83",fontFamily:"Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace",fontSize:"1em",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",wordWrap:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none"},'pre[class*="language-"]':{color:"#657b83",fontFamily:"Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace",fontSize:"1em",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",wordWrap:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",padding:"1em",margin:".5em 0",overflow:"auto",borderRadius:"0.3em",backgroundColor:"#fdf6e3"},'pre[class*="language-"]::-moz-selection':{background:"#073642"},'pre[class*="language-"] ::-moz-selection':{background:"#073642"},'code[class*="language-"]::-moz-selection':{background:"#073642"},'code[class*="language-"] ::-moz-selection':{background:"#073642"},'pre[class*="language-"]::selection':{background:"#073642"},'pre[class*="language-"] ::selection':{background:"#073642"},'code[class*="language-"]::selection':{background:"#073642"},'code[class*="language-"] ::selection':{background:"#073642"},':not(pre) > code[class*="language-"]':{backgroundColor:"#fdf6e3",padding:".1em",borderRadius:".3em"},comment:{color:"#93a1a1"},prolog:{color:"#93a1a1"},doctype:{color:"#93a1a1"},cdata:{color:"#93a1a1"},punctuation:{color:"#586e75"},namespace:{Opacity:".7"},property:{color:"#268bd2"},tag:{color:"#268bd2"},boolean:{color:"#268bd2"},number:{color:"#268bd2"},constant:{color:"#268bd2"},symbol:{color:"#268bd2"},deleted:{color:"#268bd2"},selector:{color:"#2aa198"},"attr-name":{color:"#2aa198"},string:{color:"#2aa198"},char:{color:"#2aa198"},builtin:{color:"#2aa198"},url:{color:"#2aa198"},inserted:{color:"#2aa198"},entity:{color:"#657b83",background:"#eee8d5",cursor:"help"},atrule:{color:"#859900"},"attr-value":{color:"#859900"},keyword:{color:"#859900"},function:{color:"#b58900"},"class-name":{color:"#b58900"},regex:{color:"#cb4b16"},important:{color:"#cb4b16",fontWeight:"bold"},variable:{color:"#cb4b16"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"}}},10754:(a,b)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.default=void 0,b.default={'code[class*="language-"]':{textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",wordWrap:"normal",color:"#c3cee3",background:"#263238",fontFamily:"Roboto Mono, monospace",fontSize:"1em",lineHeight:"1.5em",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none"},'pre[class*="language-"]':{textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",wordWrap:"normal",color:"#c3cee3",background:"#263238",fontFamily:"Roboto Mono, monospace",fontSize:"1em",lineHeight:"1.5em",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",overflow:"auto",position:"relative",margin:"0.5em 0",padding:"1.25em 1em"},'code[class*="language-"]::-moz-selection':{background:"#363636"},'pre[class*="language-"]::-moz-selection':{background:"#363636"},'code[class*="language-"] ::-moz-selection':{background:"#363636"},'pre[class*="language-"] ::-moz-selection':{background:"#363636"},'code[class*="language-"]::selection':{background:"#363636"},'pre[class*="language-"]::selection':{background:"#363636"},'code[class*="language-"] ::selection':{background:"#363636"},'pre[class*="language-"] ::selection':{background:"#363636"},':not(pre) > code[class*="language-"]':{whiteSpace:"normal",borderRadius:"0.2em",padding:"0.1em"},".language-css > code":{color:"#fd9170"},".language-sass > code":{color:"#fd9170"},".language-scss > code":{color:"#fd9170"},'[class*="language-"] .namespace':{Opacity:"0.7"},atrule:{color:"#c792ea"},"attr-name":{color:"#ffcb6b"},"attr-value":{color:"#c3e88d"},attribute:{color:"#c3e88d"},boolean:{color:"#c792ea"},builtin:{color:"#ffcb6b"},cdata:{color:"#80cbc4"},char:{color:"#80cbc4"},class:{color:"#ffcb6b"},"class-name":{color:"#f2ff00"},color:{color:"#f2ff00"},comment:{color:"#546e7a"},constant:{color:"#c792ea"},deleted:{color:"#f07178"},doctype:{color:"#546e7a"},entity:{color:"#f07178"},function:{color:"#c792ea"},hexcode:{color:"#f2ff00"},id:{color:"#c792ea",fontWeight:"bold"},important:{color:"#c792ea",fontWeight:"bold"},inserted:{color:"#80cbc4"},keyword:{color:"#c792ea",fontStyle:"italic"},number:{color:"#fd9170"},operator:{color:"#89ddff"},prolog:{color:"#546e7a"},property:{color:"#80cbc4"},"pseudo-class":{color:"#c3e88d"},"pseudo-element":{color:"#c3e88d"},punctuation:{color:"#89ddff"},regex:{color:"#f2ff00"},selector:{color:"#f07178"},string:{color:"#c3e88d"},symbol:{color:"#c792ea"},tag:{color:"#f07178"},unit:{color:"#f07178"},url:{color:"#fd9170"},variable:{color:"#f07178"}}},10846:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},11642:(a,b,c)=>{Promise.resolve().then(c.t.bind(c,95547,23))},13832:(a,b,c)=>{"use strict";let d,e,f;c.d(b,{AppShell:()=>Ab});var g,h,i,j,k,l,m,n,o,p,q,r={};c.r(r),c.d(r,{boolean:()=>a7,booleanish:()=>a8,commaOrSpaceSeparated:()=>bd,commaSeparated:()=>bc,number:()=>ba,overloadedBoolean:()=>a9,spaceSeparated:()=>bb});var s={};c.r(s),c.d(s,{attentionMarkers:()=>dc,contentInitial:()=>c6,disable:()=>dd,document:()=>c5,flow:()=>c8,flowInitial:()=>c7,insideSpan:()=>db,string:()=>c9,text:()=>da});var t=c(48249),u=c(67484),v=c.n(u),w=c(19099);let x="var(--text-dim)";function y({size:a=14,open:b=!1}){return b?(0,t.jsxs)("svg",{width:a,height:a,viewBox:"0 0 16 16",fill:"none",children:[(0,t.jsx)("path",{d:"M1 4.5A1 1 0 0 1 2 3.5H5.5L7 5h7.5v1H1V4.5Z",fill:x}),(0,t.jsx)("path",{d:"M1 6h14.5L14 13H2L1 6Z",stroke:x,strokeWidth:"1",fill:x,fillOpacity:"0.12"})]}):(0,t.jsx)("svg",{width:a,height:a,viewBox:"0 0 16 16",fill:"none",children:(0,t.jsx)("path",{d:"M1 4.5A1 1 0 0 1 2 3.5H5.5L7 5H14a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V4.5Z",stroke:x,strokeWidth:"1",fill:x,fillOpacity:"0.1"})})}function z({size:a=14}){return(0,t.jsxs)("svg",{width:a,height:a,viewBox:"0 0 16 16",fill:"none",children:[(0,t.jsx)("path",{d:"M3 2h7l3 3v9H3V2Z",stroke:x,strokeWidth:"1",fill:x,fillOpacity:"0.08"}),(0,t.jsx)("path",{d:"M10 2v3h3",stroke:x,strokeWidth:"1",fill:"none",strokeLinejoin:"round"})]})}function A({label:a,size:b=14}){let c=b/14;return(0,t.jsxs)("svg",{width:b,height:b,viewBox:"0 0 14 14",fill:"none",children:[(0,t.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:x,strokeWidth:"0.9",fill:x,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M8.5 1v3h3",stroke:x,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,t.jsx)("text",{x:"7",y:"9.5",textAnchor:"middle",fontSize:3.4*c,fontFamily:"var(--font-mono), monospace",fontWeight:"600",fill:x,letterSpacing:"0",children:a})]})}function B({size:a=14}){return(0,t.jsx)(A,{label:"TS",size:a})}function C({size:a=14}){return(0,t.jsx)(A,{label:"TSX",size:a})}function D({size:a=14}){return(0,t.jsx)(A,{label:"JS",size:a})}function E({size:a=14}){return(0,t.jsx)(A,{label:"JSX",size:a})}function F({size:a=14}){return(0,t.jsx)(A,{label:"PY",size:a})}function G({size:a=14}){return(0,t.jsx)(A,{label:"{}",size:a})}function H({size:a=14}){return(0,t.jsx)(A,{label:"CSS",size:a})}function I({size:a=14}){return(0,t.jsx)(A,{label:"SC",size:a})}function J({size:a=14}){return(0,t.jsx)(A,{label:"HTM",size:a})}function K({size:a=14}){return(0,t.jsxs)("svg",{width:a,height:a,viewBox:"0 0 14 14",fill:"none",children:[(0,t.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:x,strokeWidth:"0.9",fill:x,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M8.5 1v3h3",stroke:x,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M3.5 9.5V7l1.5 1.5L6.5 7v2.5",stroke:x,strokeWidth:"0.9",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),(0,t.jsx)("path",{d:"M8 7v2.5M7 9l1 1.5 1-1.5",stroke:x,strokeWidth:"0.9",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]})}function L({size:a=14}){return(0,t.jsx)(A,{label:"YML",size:a})}function M({size:a=14}){return(0,t.jsx)(A,{label:"TOM",size:a})}function N({size:a=14}){return(0,t.jsxs)("svg",{width:a,height:a,viewBox:"0 0 14 14",fill:"none",children:[(0,t.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:x,strokeWidth:"0.9",fill:x,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M8.5 1v3h3",stroke:x,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M4 7.5l2 1.5-2 1.5",stroke:x,strokeWidth:"0.95",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),(0,t.jsx)("path",{d:"M7.5 10.5h2.5",stroke:x,strokeWidth:"0.95",strokeLinecap:"round"})]})}function O({size:a=14}){return(0,t.jsx)(A,{label:"RS",size:a})}function P({size:a=14}){return(0,t.jsx)(A,{label:"GO",size:a})}function Q({size:a=14}){return(0,t.jsx)(A,{label:"SQL",size:a})}function R({size:a=14}){return(0,t.jsx)(A,{label:"GQL",size:a})}function S({size:a=14}){return(0,t.jsx)(A,{label:"TF",size:a})}function T({size:a=14}){return(0,t.jsxs)("svg",{width:a,height:a,viewBox:"0 0 14 14",fill:"none",children:[(0,t.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:x,strokeWidth:"0.9",fill:x,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M8.5 1v3h3",stroke:x,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,t.jsx)("rect",{x:"3.5",y:"6.5",width:"2",height:"1.5",rx:"0.3",stroke:x,strokeWidth:"0.8"}),(0,t.jsx)("rect",{x:"6",y:"6.5",width:"2",height:"1.5",rx:"0.3",stroke:x,strokeWidth:"0.8"}),(0,t.jsx)("rect",{x:"3.5",y:"8.5",width:"2",height:"1.5",rx:"0.3",stroke:x,strokeWidth:"0.8"})]})}function U({size:a=14}){return(0,t.jsxs)("svg",{width:a,height:a,viewBox:"0 0 14 14",fill:"none",children:[(0,t.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:x,strokeWidth:"0.9",fill:x,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M8.5 1v3h3",stroke:x,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,t.jsx)("circle",{cx:"5.5",cy:"8.5",r:"1.5",stroke:x,strokeWidth:"0.9"}),(0,t.jsx)("path",{d:"M7 8.5h2.5M8.5 8.5v1.5",stroke:x,strokeWidth:"0.9",strokeLinecap:"round"})]})}function V({size:a=14}){return(0,t.jsxs)("svg",{width:a,height:a,viewBox:"0 0 14 14",fill:"none",children:[(0,t.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:x,strokeWidth:"0.9",fill:x,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M8.5 1v3h3",stroke:x,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,t.jsx)("circle",{cx:"5",cy:"6.5",r:"1",stroke:x,strokeWidth:"0.85"}),(0,t.jsx)("circle",{cx:"9",cy:"6.5",r:"1",stroke:x,strokeWidth:"0.85"}),(0,t.jsx)("circle",{cx:"5",cy:"10",r:"1",stroke:x,strokeWidth:"0.85"}),(0,t.jsx)("path",{d:"M5 7.5V9",stroke:x,strokeWidth:"0.85",strokeLinecap:"round"}),(0,t.jsx)("path",{d:"M9 7.5v.5a2 2 0 0 1-2 2H6",stroke:x,strokeWidth:"0.85",strokeLinecap:"round",fill:"none"})]})}function W({size:a=14}){return(0,t.jsxs)("svg",{width:a,height:a,viewBox:"0 0 14 14",fill:"none",children:[(0,t.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:x,strokeWidth:"0.9",fill:x,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M8.5 1v3h3",stroke:x,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,t.jsx)("rect",{x:"4.5",y:"8.5",width:"5",height:"3",rx:"0.6",stroke:x,strokeWidth:"0.9"}),(0,t.jsx)("path",{d:"M5.5 8.5V7.5a1.5 1.5 0 0 1 3 0v1",stroke:x,strokeWidth:"0.9",strokeLinecap:"round",fill:"none"})]})}function X({size:a=14}){return(0,t.jsxs)("svg",{width:a,height:a,viewBox:"0 0 14 14",fill:"none",children:[(0,t.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:x,strokeWidth:"0.9",fill:x,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M8.5 1v3h3",stroke:x,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,t.jsx)("circle",{cx:"7",cy:"8.5",r:"1.3",stroke:x,strokeWidth:"0.9"}),(0,t.jsx)("path",{d:"M7 6.5v.7M7 10.3v.7M5 8.5h.7M8.3 8.5H9M5.5 6.9l.5.5M8.5 9.6l-.5-.5M5.5 10.1l.5-.5M8.5 7.4l-.5.5",stroke:x,strokeWidth:"0.8",strokeLinecap:"round"})]})}function Y(a,b=14){let c=a.toLowerCase(),d=c.split(".").pop()??"";if("dockerfile"===c||c.startsWith("dockerfile."))return(0,t.jsx)(T,{size:b});if(".env"===c||c.startsWith(".env."))return(0,t.jsx)(U,{size:b});if(".gitignore"===c||".gitattributes"===c||".gitmodules"===c)return(0,t.jsx)(V,{size:b});if("package-lock.json"===c||"yarn.lock"===c||"bun.lock"===c||"pnpm-lock.yaml"===c||"cargo.lock"===c)return(0,t.jsx)(W,{size:b});if(c.endsWith(".config.ts")||c.endsWith(".config.js")||c.endsWith(".config.mjs")||c.endsWith(".config.cjs")||[".eslintrc",".eslintrc.js",".eslintrc.json",".eslintrc.yml","eslint.config.mjs","eslint.config.js"].includes(c))return(0,t.jsx)(X,{size:b});switch(d){case"ts":return(0,t.jsx)(B,{size:b});case"tsx":return(0,t.jsx)(C,{size:b});case"js":case"mjs":case"cjs":return(0,t.jsx)(D,{size:b});case"jsx":return(0,t.jsx)(E,{size:b});case"py":return(0,t.jsx)(F,{size:b});case"json":case"jsonl":return(0,t.jsx)(G,{size:b});case"css":case"less":return(0,t.jsx)(H,{size:b});case"scss":return(0,t.jsx)(I,{size:b});case"html":case"htm":return(0,t.jsx)(J,{size:b});case"md":case"mdx":return(0,t.jsx)(K,{size:b});case"yaml":case"yml":return(0,t.jsx)(L,{size:b});case"toml":return(0,t.jsx)(M,{size:b});case"sh":case"bash":case"zsh":case"fish":return(0,t.jsx)(N,{size:b});case"rs":return(0,t.jsx)(O,{size:b});case"go":return(0,t.jsx)(P,{size:b});case"sql":return(0,t.jsx)(Q,{size:b});case"graphql":case"gql":return(0,t.jsx)(R,{size:b});case"tf":case"hcl":return(0,t.jsx)(S,{size:b});case"lock":return(0,t.jsx)(W,{size:b});default:return(0,t.jsx)(z,{size:b})}}function Z(a){return/^[a-zA-Z]:[\\/]/.test(a)||a.startsWith("\\\\")?a.replace(/\\/g,"/"):a}function $(a){return Z(a).split("/").filter(Boolean).map(encodeURIComponent).join("/")}function _(a){let b=Z(a).replace(/\/+$/,"");return b.split("/").pop()??b}function aa(a,b){if(!b)return a;let c=Z(a),d=Z(b).replace(/\/$/,"");return c.startsWith(d+"/")?c.slice(d.length+1):a}async function ab(a){let b=$(a),c=await fetch(`/api/files/${b}?type=list`);return c.ok?((await c.json()).entries??[]).map(b=>{var c;return{name:b.name,fullPath:(c=b.name,`${Z(a).replace(/\/$/,"")}/${c}`),isDir:b.isDir,size:b.size,children:b.isDir?[]:void 0,loaded:!b.isDir}}):[]}function ac(a,b){let c=b.trim().toLowerCase();return!!(!c||a.name.toLowerCase().includes(c))||(a.children??[]).some(a=>ac(a,c))}function ad(a){return!!Array.from(a.types).includes("Files")||Array.from(a.items).some(a=>"file"===a.kind)}function ae(a){return Array.from(a.files).filter(a=>!!a.name)}function af(a,b){return a===b?".":aa(a,b)}function ag({node:a,depth:b,cwd:c,onOpenFile:d,onExploreFile:e,onAtMention:f,expandedPaths:g,onToggleExpanded:h,onUploadFiles:i,uploadTargetPath:j,refreshKey:k,searchQuery:l}){let m=!!l?.trim(),n=m?a.isDir:g.has(a.fullPath),[o,p]=(0,u.useState)(a.children??[]),[q,r]=(0,u.useState)(a.loaded??!1),[s,v]=(0,u.useState)(!1),[w,x]=(0,u.useState)(!1),[z,A]=(0,u.useState)(!1),B=a.isDir&&(z||j===a.fullPath),C=!!f&&w,D=!!e&&w&&!a.isDir&&a.name.toLowerCase().endsWith(".h5ad"),E=C||D,F=m?o.filter(a=>ac(a,l??"")):o,G=(0,u.useCallback)(async(b=!1)=>{if(!q||b){v(!0);try{let b=await ab(a.fullPath);p(b),r(!0)}catch{}finally{v(!1)}}},[q,a.fullPath]);(0,u.useRef)(q);let H=(0,u.useCallback)(()=>{if(a.isDir){let b=!n;h(a.fullPath,b),b&&!q&&G()}else d(a.fullPath,a.name)},[a.isDir,a.fullPath,a.name,q,n,G,d,h]),I=(0,u.useCallback)(b=>{a.isDir&&ad(b.dataTransfer)&&(b.preventDefault(),b.stopPropagation(),b.dataTransfer.dropEffect="copy",A(!0))},[a.isDir]),J=(0,u.useCallback)(b=>{a.isDir&&ad(b.dataTransfer)&&(b.preventDefault(),b.stopPropagation(),b.dataTransfer.dropEffect="copy")},[a.isDir]),K=(0,u.useCallback)(b=>{if(!a.isDir)return;let c=b.relatedTarget;c instanceof Node&&b.currentTarget.contains(c)||A(!1)},[a.isDir]),L=(0,u.useCallback)(b=>{if(!a.isDir||!ad(b.dataTransfer))return;b.preventDefault(),b.stopPropagation(),A(!1);let c=ae(b.dataTransfer);c.length>0&&(i(c,a.fullPath),n||h(a.fullPath,!0),q||G())},[G,q,a.fullPath,a.isDir,h,i,n]);return(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{onClick:H,onMouseEnter:()=>x(!0),onMouseLeave:()=>x(!1),onDragEnter:I,onDragOver:J,onDragLeave:K,onDrop:L,style:{position:"relative",display:"flex",alignItems:"center",gap:4,paddingLeft:8+14*b,paddingRight:E?C&&D?146:82:8,height:24,cursor:"pointer",background:B?"rgba(37,99,235,0.14)":w?"var(--bg-hover)":"transparent",outline:B?"1px solid rgba(37,99,235,0.42)":"none",outlineOffset:-1,borderRadius:4,userSelect:"none",transition:"background 0.12s, outline-color 0.12s"},children:[a.isDir&&(0,t.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--text-dim)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,transform:n?"rotate(90deg)":"none",transition:"transform 0.1s"},children:(0,t.jsx)("polyline",{points:"3 2 7 5 3 8"})}),!a.isDir&&(0,t.jsx)("span",{style:{width:10,flexShrink:0}}),(0,t.jsx)("span",{style:{flexShrink:0,display:"flex",alignItems:"center"},children:a.isDir?(0,t.jsx)(y,{size:14,open:n}):Y(a.name,14)}),(0,t.jsx)("span",{style:{fontSize:12,color:"var(--text)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},title:a.fullPath,children:a.name}),s&&(0,t.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-dim)",strokeWidth:"2",strokeLinecap:"round",children:(0,t.jsx)("path",{d:"M12 2v4M12 18v4M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83M2 12h4M18 12h4"})}),E&&(0,t.jsxs)("div",{style:{position:"absolute",right:4,top:"50%",transform:"translateY(-50%)",display:"flex",alignItems:"center",gap:4},children:[D&&(0,t.jsxs)("button",{onClick:b=>{b.stopPropagation(),e?.(a.fullPath,a.name)},title:"Explore H5AD",style:{display:"flex",alignItems:"center",justifyContent:"center",gap:4,padding:"0 8px",height:20,background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:4,color:"var(--accent)",cursor:"pointer",fontSize:11,fontWeight:600,whiteSpace:"nowrap"},children:[(0,t.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.1",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("circle",{cx:"11",cy:"11",r:"7"}),(0,t.jsx)("path",{d:"M16 16l4 4"}),(0,t.jsx)("path",{d:"M8.5 11h5"}),(0,t.jsx)("path",{d:"M11 8.5v5"})]}),"@explore"]}),C&&(0,t.jsxs)("button",{onClick:b=>{b.stopPropagation(),f?.(aa(a.fullPath,c))},title:"Insert path into chat",style:{display:"flex",alignItems:"center",justifyContent:"center",gap:4,padding:"0 8px",height:20,background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:4,color:"var(--accent)",cursor:"pointer",fontSize:11,fontWeight:600,whiteSpace:"nowrap"},children:[(0,t.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("circle",{cx:"12",cy:"12",r:"4"}),(0,t.jsx)("path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8"})]}),"@mention"]})]})]}),a.isDir&&n&&(0,t.jsxs)("div",{children:[F.map(a=>(0,t.jsx)(ag,{node:a,depth:b+1,cwd:c,onOpenFile:d,onExploreFile:e,onAtMention:f,expandedPaths:g,onToggleExpanded:h,onUploadFiles:i,uploadTargetPath:j,refreshKey:k,searchQuery:l},a.fullPath)),0===F.length&&q&&!m&&(0,t.jsx)("div",{style:{paddingLeft:8+(b+1)*14,fontSize:11,color:"var(--text-dim)",height:22,display:"flex",alignItems:"center"},children:"empty"})]})]})}function ah({cwd:a,onOpenFile:b,onExploreFile:c,refreshKey:d,onAtMention:e,searchQuery:f="",onSearchChange:g}){let[h,i]=(0,u.useState)([]),[j,k]=(0,u.useState)(!0),[l,m]=(0,u.useState)(null),[n,o]=(0,u.useState)(new Set),[p,q]=(0,u.useState)(!1),[r,s]=(0,u.useState)(null),[v,w]=(0,u.useState)(null);(0,u.useRef)(null);let x=(0,u.useRef)(null),y=(0,u.useRef)(0),z=(0,u.useCallback)((a,b)=>(k(b),m(null),ab(a).then(a=>i(a)).catch(a=>m(String(a))).finally(()=>k(!1))),[]),A=(0,u.useCallback)((a,b)=>{o(c=>{let d=new Set(c);return b?d.add(a):d.delete(a),d})},[]),B=(0,u.useCallback)(()=>{z(a,0===h.length)},[a,h.length,z]),C=(0,u.useCallback)(()=>{x.current&&clearTimeout(x.current),x.current=setTimeout(()=>w(null),5e3)},[]),D=(0,u.useCallback)((b,c)=>{if(0===b.length)return;y.current=0,q(!1),x.current&&clearTimeout(x.current);let d=b.reduce((a,b)=>a+b.size,0),e=af(c,a);s(c),w({phase:"uploading",targetPath:c,fileCount:b.length,loaded:0,total:d,message:`Uploading ${b.length} file${1===b.length?"":"s"} to ${e}`});let f=new FormData;b.forEach(a=>f.append("files",a,a.name));let g=new XMLHttpRequest,h=$(c);g.open("POST",`/api/files/${h}?type=upload`),g.upload.onprogress=a=>{a.lengthComputable&&w(b=>b?{...b,loaded:a.loaded,total:a.total}:b)},g.onload=()=>{s(null);let a={};try{a=JSON.parse(g.responseText)}catch{a={}}if(g.status>=200&&g.status<300){let f=a.uploaded??[],g=a.failed??[],h=[...f.filter(a=>a.name!==a.originalName).slice(0,3).map(a=>`${a.originalName} saved as ${a.name}`),...g.slice(0,3).map(a=>`${a.name}: ${a.error}`)];w({phase:g.length>0?"warning":"success",targetPath:c,fileCount:b.length,loaded:d,total:d,message:g.length>0?`Uploaded ${f.length}, ${g.length} failed`:`Uploaded ${f.length} file${1===f.length?"":"s"} to ${e}`,details:h}),B(),C()}else{let e=a.error??`Upload failed (HTTP ${g.status})`;w({phase:(g.status,"error"),targetPath:c,fileCount:b.length,loaded:0,total:d,message:e,details:403===g.status?["Check directory write permission or project access."]:void 0}),C()}},g.onerror=()=>{s(null),w({phase:"error",targetPath:c,fileCount:b.length,loaded:0,total:d,message:"Upload failed due to a network error"}),C()},g.onabort=()=>{s(null),w({phase:"error",targetPath:c,fileCount:b.length,loaded:0,total:d,message:"Upload canceled"}),C()},g.send(f)},[a,B,C]),E=(0,u.useCallback)(a=>{ad(a.dataTransfer)&&(a.preventDefault(),y.current+=1,q(!0))},[]),F=(0,u.useCallback)(a=>{ad(a.dataTransfer)&&(a.preventDefault(),a.dataTransfer.dropEffect="copy")},[]),G=(0,u.useCallback)(()=>{y.current-=1,y.current<=0&&(y.current=0,q(!1))},[]),H=(0,u.useCallback)(b=>{if(!ad(b.dataTransfer))return;b.preventDefault(),y.current=0,q(!1);let c=ae(b.dataTransfer);c.length>0&&D(c,a)},[a,D]),I=f.trim()?h.filter(a=>ac(a,f)):h,J=f.trim().length>0;return j?(0,t.jsx)(ai,{cwd:a,isDraggingFiles:p,uploadState:v,onDragEnter:E,onDragOver:F,onDragLeave:G,onDrop:H,children:(0,t.jsx)("div",{style:{padding:"8px 12px",fontSize:11,color:"var(--text-dim)"},children:"Loading files..."})}):l?(0,t.jsx)(ai,{cwd:a,isDraggingFiles:p,uploadState:v,onDragEnter:E,onDragOver:F,onDragLeave:G,onDrop:H,children:(0,t.jsx)("div",{style:{padding:"8px 12px",fontSize:11,color:"#f87171"},children:l})}):(0,t.jsx)(ai,{cwd:a,isDraggingFiles:p,uploadState:v,onDragEnter:E,onDragOver:F,onDragLeave:G,onDrop:H,children:(0,t.jsxs)("div",{style:{padding:"2px 4px"},children:[I.map(g=>(0,t.jsx)(ag,{node:g,depth:0,cwd:a,onOpenFile:b,onExploreFile:c,onAtMention:e,expandedPaths:n,onToggleExpanded:A,onUploadFiles:D,uploadTargetPath:r,refreshKey:d,searchQuery:f},g.fullPath)),0===I.length&&(0,t.jsx)("div",{style:{padding:"8px 12px",fontSize:11,color:"var(--text-dim)"},children:J?"No matching files":"No files found"})]})})}function ai({cwd:a,isDraggingFiles:b,uploadState:c,onDragEnter:d,onDragOver:e,onDragLeave:f,onDrop:g,children:h}){let i=c&&c.total>0?Math.max(0,Math.min(100,Math.round(c.loaded/c.total*100))):c?.phase==="uploading"?8:100,j=c?.phase==="success"?"#22c55e":c?.phase==="warning"?"#f59e0b":c?.phase==="error"?"#ef4444":"var(--accent)";return(0,t.jsxs)("div",{onDragEnter:d,onDragOver:e,onDragLeave:f,onDrop:g,style:{position:"relative",display:"flex",flexDirection:"column",minHeight:"100%",outline:b?"1px solid rgba(37,99,235,0.45)":"none",outlineOffset:-1,background:b?"rgba(37,99,235,0.04)":void 0,transition:"background 0.12s, outline-color 0.12s"},children:[(0,t.jsx)("div",{style:{flex:1,minHeight:0},children:h}),b&&(0,t.jsx)("div",{style:{pointerEvents:"none",position:"absolute",inset:6,top:42,border:"1px dashed rgba(37,99,235,0.62)",borderRadius:8,background:"rgba(37,99,235,0.07)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:2},children:(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"7px 10px",border:"1px solid var(--border)",borderRadius:6,background:"var(--bg-panel)",color:"var(--text)",fontSize:12,boxShadow:"0 8px 24px rgba(0,0,0,0.16)"},children:[(0,t.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,t.jsx)("polyline",{points:"17 8 12 3 7 8"}),(0,t.jsx)("line",{x1:"12",y1:"3",x2:"12",y2:"15"})]}),"Drop to upload into ",af(a,a)]})}),c&&(0,t.jsxs)("div",{style:{margin:"6px",padding:"7px 8px",border:"1px solid var(--border)",borderRadius:6,background:"var(--bg-panel)",boxShadow:"0 8px 24px rgba(0,0,0,0.12)"},children:[(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:7,minWidth:0},children:[(0,t.jsx)("span",{style:{width:8,height:8,borderRadius:999,background:j,flexShrink:0}}),(0,t.jsx)("span",{title:c.message,style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--text)",fontSize:11,fontWeight:600},children:c.message}),(0,t.jsx)("span",{style:{color:"var(--text-dim)",fontSize:10,flexShrink:0},children:"uploading"===c.phase?`${i}%`:function(a){if(!Number.isFinite(a)||a<=0)return"0 B";let b=["B","KB","MB","GB"],c=a,d=0;for(;c>=1024&&d<b.length-1;)c/=1024,d+=1;return`${c>=10||0===d?Math.round(c):c.toFixed(1)} ${b[d]}`}(c.total)})]}),(0,t.jsx)("div",{style:{marginTop:6,height:3,borderRadius:999,background:"var(--bg)",overflow:"hidden"},children:(0,t.jsx)("div",{style:{width:`${i}%`,height:"100%",borderRadius:999,background:j,transition:"width 0.15s ease"}})}),c.details&&c.details.length>0&&(0,t.jsx)("div",{style:{marginTop:5,display:"grid",gap:2},children:c.details.map(a=>(0,t.jsx)("div",{title:a,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--text-dim)",fontSize:10},children:a},a))})]})]})}function aj(a,b){let c=b&&a.startsWith(b)?"~"+a.slice(b.length):a,d=c.includes("/")?"/":"\\",e=c.split(d).filter(Boolean);return e.length<=2?c:"..."+d+e.slice(-2).join(d)}function ak(a){let b=new Date(a);return Number.isNaN(b.getTime())?"":b.toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function al({open:a,cwd:b,homeDir:c,onClose:d,onSelectSession:e}){let[f,g]=(0,u.useState)(""),[h,i]=(0,u.useState)("current"),[j,k]=(0,u.useState)([]),[l,m]=(0,u.useState)(!1),[n,o]=(0,u.useState)(null),[p,q]=(0,u.useState)(!1),r=(0,u.useRef)(null);if(!a)return null;let s=f.trim(),v=j.reduce((a,b)=>a+b.matches.length,0);return(0,t.jsx)("div",{role:"dialog","aria-modal":"true","aria-label":"Search conversation history",style:{position:"fixed",inset:0,zIndex:500,display:"flex",alignItems:"flex-start",justifyContent:"center",padding:"8vh 16px 16px",background:"rgba(0,0,0,0.28)"},onMouseDown:a=>{a.target===a.currentTarget&&d()},children:(0,t.jsxs)("div",{style:{width:"min(760px, 100%)",maxHeight:"78vh",display:"flex",flexDirection:"column",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:10,boxShadow:"0 16px 48px rgba(0,0,0,0.24)",overflow:"hidden"},children:[(0,t.jsxs)("div",{style:{padding:12,borderBottom:"1px solid var(--border)"},children:[(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,flex:1,minWidth:0,background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:8,padding:"0 10px"},children:[(0,t.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 16 16",fill:"none",stroke:"var(--text-dim)",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,t.jsx)("circle",{cx:"7",cy:"7",r:"4.5"}),(0,t.jsx)("path",{d:"M10.5 10.5 13.5 13.5"})]}),(0,t.jsx)("input",{ref:r,value:f,onChange:a=>g(a.target.value),placeholder:"Search conversation history...",style:{flex:1,minWidth:0,height:38,background:"transparent",border:"none",outline:"none",color:"var(--text)",fontSize:14}})]}),(0,t.jsx)("button",{type:"button",onClick:d,title:"Close",style:{width:34,height:34,display:"inline-flex",alignItems:"center",justifyContent:"center",background:"none",border:"none",borderRadius:7,color:"var(--text-dim)",cursor:"pointer"},onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="var(--text)"},onMouseLeave:a=>{a.currentTarget.style.background="none",a.currentTarget.style.color="var(--text-dim)"},children:(0,t.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[(0,t.jsx)("path",{d:"M4 4 12 12"}),(0,t.jsx)("path",{d:"M12 4 4 12"})]})})]}),(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:10},children:[(0,t.jsx)("div",{style:{display:"inline-flex",padding:2,background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:7},children:[{value:"current",label:"Current project",disabled:!b},{value:"all",label:"All history",disabled:!1}].map(a=>(0,t.jsx)("button",{type:"button",disabled:a.disabled,onClick:()=>i(a.value),style:{height:24,padding:"0 9px",background:h===a.value?"var(--bg-selected)":"transparent",border:"none",borderRadius:5,color:a.disabled?"var(--text-dim)":h===a.value?"var(--text)":"var(--text-muted)",cursor:a.disabled?"not-allowed":"pointer",fontSize:11,fontWeight:500},children:a.label},a.value))}),(0,t.jsx)("div",{style:{flex:1,minWidth:0,color:"var(--text-dim)",fontSize:11,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:"current"===h&&b?aj(b,c):"Searching every saved session"})]})]}),(0,t.jsxs)("div",{style:{flex:1,overflowY:"auto",minHeight:180},children:[s.length<2&&(0,t.jsx)("div",{style:{padding:28,textAlign:"center",color:"var(--text-muted)",fontSize:13},children:"Type at least 2 characters to search saved conversations."}),s.length>=2&&l&&0===j.length&&(0,t.jsx)("div",{style:{padding:28,textAlign:"center",color:"var(--text-muted)",fontSize:13},children:"Searching..."}),n&&(0,t.jsx)("div",{style:{padding:18,color:"#ef4444",fontSize:13},children:n}),s.length>=2&&!l&&!n&&0===j.length&&(0,t.jsx)("div",{style:{padding:28,textAlign:"center",color:"var(--text-muted)",fontSize:13},children:"No matching conversations found."}),j.map(a=>(0,t.jsxs)("div",{style:{borderBottom:"1px solid var(--border)"},children:[(0,t.jsxs)("button",{type:"button",onClick:()=>{e(a.session),d()},style:{width:"100%",display:"flex",alignItems:"center",gap:10,padding:"10px 12px",background:"var(--bg-panel)",border:"none",borderBottom:"1px solid var(--border)",color:"var(--text)",cursor:"pointer",textAlign:"left"},onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:a=>{a.currentTarget.style.background="var(--bg-panel)"},children:[(0,t.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,minWidth:0},children:[(0,t.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:13,fontWeight:600},children:a.session.name||a.session.firstMessage||"(no messages)"}),(0,t.jsx)("span",{style:{flexShrink:0,color:"var(--text-dim)",fontSize:11},children:ak(a.session.modified)})]}),(0,t.jsx)("div",{style:{marginTop:2,color:"var(--text-dim)",fontSize:11,fontFamily:"var(--font-mono)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:aj(a.session.cwd,c)})]}),a.matchCount>a.matches.length&&(0,t.jsxs)("span",{style:{flexShrink:0,color:"var(--text-muted)",fontSize:11},children:[a.matchCount," matches"]})]}),a.matches.map(b=>(0,t.jsxs)("button",{type:"button",onClick:()=>{e(a.session),d()},style:{width:"100%",padding:"9px 14px 9px 28px",background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",textAlign:"left"},onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:a=>{a.currentTarget.style.background="none"},children:[(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:3},children:[(0,t.jsx)("span",{style:{minWidth:54,color:"user"===b.role?"var(--accent)":"var(--text-dim)",fontSize:11,fontWeight:600,textTransform:"capitalize"},children:b.role}),(0,t.jsx)("span",{style:{color:"var(--text-dim)",fontSize:11},children:ak(b.timestamp)})]}),(0,t.jsx)("div",{style:{fontSize:12,lineHeight:1.45,color:"var(--text-muted)"},children:function(a,b){let c=b.trim();if(!c)return a;let d=a.toLowerCase().indexOf(c.toLowerCase());return d<0?a:(0,t.jsxs)(t.Fragment,{children:[a.slice(0,d),(0,t.jsx)("mark",{style:{background:"rgba(37,99,235,0.16)",color:"var(--text)",borderRadius:3,padding:"0 2px"},children:a.slice(d,d+c.length)}),a.slice(d+c.length)]})}(b.snippet,s)})]},b.entryId))]},a.session.id))]}),(0,t.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",padding:"8px 12px",borderTop:"1px solid var(--border)",color:"var(--text-dim)",fontSize:11},children:[(0,t.jsx)("span",{children:v>0?`${v}${p?"+":""} results`:"Esc to close"}),l&&j.length>0&&(0,t.jsx)("span",{children:"Updating..."})]})]})})}function am({open:a,initialPath:b,onClose:c,onSelect:d}){let[e,f]=(0,u.useState)(""),[g,h]=(0,u.useState)(null),[i,j]=(0,u.useState)([]),[k,l]=(0,u.useState)([]),[m,n]=(0,u.useState)(""),[o,p]=(0,u.useState)(!1),[q,r]=(0,u.useState)(null),s=(0,u.useCallback)(async a=>{p(!0),r(null);try{let b=a?`/api/projects/browse?dir=${encodeURIComponent(a)}`:"/api/projects/browse",c=await fetch(b),d=await c.json();if(!c.ok||d.error)throw Error(d.error??`HTTP ${c.status}`);f(d.current??""),h(d.parent??null),j(d.directories??[]),l(d.drives??[]),n(d.current??"")}catch(a){r(a instanceof Error?a.message:String(a))}finally{p(!1)}},[]);return a?(0,t.jsx)("div",{onMouseDown:a=>{a.target===a.currentTarget&&c()},style:{position:"fixed",inset:0,zIndex:1200,display:"flex",alignItems:"center",justifyContent:"center",padding:18,background:"rgba(0,0,0,0.34)"},children:(0,t.jsxs)("div",{style:{width:"min(560px, 100%)",maxHeight:"min(720px, 88dvh)",display:"flex",flexDirection:"column",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:10,boxShadow:"0 12px 40px rgba(0,0,0,0.25)",overflow:"hidden"},children:[(0,t.jsxs)("div",{style:{height:48,padding:"0 14px",display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid var(--border)"},children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{style:{color:"var(--text)",fontSize:14,fontWeight:750},children:"Select project path"}),(0,t.jsx)("div",{style:{marginTop:2,color:"var(--text-dim)",fontSize:11},children:"Server filesystem"})]}),(0,t.jsx)("button",{type:"button",onClick:c,"aria-label":"Close",title:"Close",style:{width:30,height:30,border:"none",borderRadius:6,background:"transparent",color:"var(--text-muted)",cursor:"pointer",fontSize:20,lineHeight:1},onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="var(--text)"},onMouseLeave:a=>{a.currentTarget.style.background="transparent",a.currentTarget.style.color="var(--text-muted)"},children:"x"})]}),(0,t.jsx)("div",{style:{padding:12,borderBottom:"1px solid var(--border)"},children:(0,t.jsxs)("form",{onSubmit:a=>{a.preventDefault(),m.trim()&&s(m.trim())},style:{display:"flex",gap:8},children:[(0,t.jsx)("input",{value:m,onChange:a=>n(a.target.value),placeholder:"/path/to/project",style:{flex:1,minWidth:0,height:32,padding:"0 10px",border:"1px solid var(--border)",borderRadius:6,background:"var(--bg-panel)",color:"var(--text)",fontFamily:"var(--font-mono)",fontSize:12,outline:"none"}}),(0,t.jsx)("button",{type:"submit",style:{height:32,padding:"0 11px",border:"1px solid var(--border)",borderRadius:6,background:"var(--bg-panel)",color:"var(--text-muted)",cursor:"pointer",fontSize:12},children:"Go"})]})}),(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px",borderBottom:"1px solid var(--border)",background:"var(--bg-panel)"},children:[(0,t.jsx)("button",{type:"button",onClick:()=>g&&void s(g),disabled:!g,style:{width:28,height:28,border:"1px solid var(--border)",borderRadius:6,background:g?"var(--bg)":"transparent",color:g?"var(--text-muted)":"var(--text-dim)",cursor:g?"pointer":"default",padding:0},title:"Up",children:(0,t.jsx)("svg",{width:"13",height:"13",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:(0,t.jsx)("polyline",{points:"2 6.5 5 3.5 8 6.5"})})}),k.length>0&&(0,t.jsxs)("select",{value:k.find(a=>e.toLowerCase().startsWith(a.toLowerCase()))??"",onChange:a=>{a.target.value&&s(a.target.value)},style:{height:28,border:"1px solid var(--border)",borderRadius:6,background:"var(--bg)",color:"var(--text-muted)",fontSize:12},children:[(0,t.jsx)("option",{value:"",children:"Drive"}),k.map(a=>(0,t.jsx)("option",{value:a,children:a},a))]}),(0,t.jsx)("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--text-dim)",fontFamily:"var(--font-mono)",fontSize:11},title:e,children:e})]}),(0,t.jsx)("div",{style:{flex:1,minHeight:220,maxHeight:360,overflowY:"auto",padding:6},children:o?(0,t.jsx)("div",{style:{padding:18,color:"var(--text-muted)",fontSize:12},children:"Loading..."}):q?(0,t.jsx)("div",{style:{padding:18,color:"#f87171",fontSize:12},children:q}):0===i.length?(0,t.jsx)("div",{style:{padding:18,color:"var(--text-muted)",fontSize:12},children:"No subdirectories"}):i.map(a=>(0,t.jsxs)("button",{type:"button",onClick:()=>void s(a.path),style:{width:"100%",display:"flex",alignItems:"center",gap:9,padding:"8px 9px",border:"none",borderRadius:6,background:"transparent",color:"var(--text-muted)",cursor:"pointer",textAlign:"left",fontSize:12},onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="var(--text)"},onMouseLeave:a=>{a.currentTarget.style.background="transparent",a.currentTarget.style.color="var(--text-muted)"},title:a.path,children:[(0,t.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--accent)",flexShrink:0},children:(0,t.jsx)("path",{d:"M3 6.5A2.5 2.5 0 0 1 5.5 4H10l2 2.5h6.5A2.5 2.5 0 0 1 21 9v8.5A2.5 2.5 0 0 1 18.5 20h-13A2.5 2.5 0 0 1 3 17.5v-11Z"})}),(0,t.jsx)("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a.name}),(0,t.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--text-dim)",flexShrink:0},children:(0,t.jsx)("polyline",{points:"3.5 2 6.5 5 3.5 8"})})]},a.path))}),(0,t.jsxs)("div",{style:{padding:12,borderTop:"1px solid var(--border)",display:"flex",alignItems:"center",justifyContent:"space-between",gap:10},children:[(0,t.jsx)("div",{style:{minWidth:0,color:"var(--text-dim)",fontFamily:"var(--font-mono)",fontSize:11,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:e,children:e}),(0,t.jsxs)("div",{style:{display:"flex",gap:7,flexShrink:0},children:[(0,t.jsx)("button",{type:"button",onClick:c,style:{height:32,padding:"0 12px",border:"1px solid var(--border)",borderRadius:6,background:"var(--bg-panel)",color:"var(--text-muted)",cursor:"pointer",fontSize:12},children:"Cancel"}),(0,t.jsx)("button",{type:"button",onClick:()=>e&&d(e),disabled:!e,style:{height:32,padding:"0 12px",border:"none",borderRadius:6,background:e?"var(--accent)":"var(--bg-hover)",color:e?"#fff":"var(--text-dim)",cursor:e?"pointer":"default",fontSize:12,fontWeight:650},children:"Select"})]})]})]})}):null}let an="AnnoVibe";async function ao(a,b){let c=`${a}: HTTP ${b.status}`;try{let d=await b.json();return"string"==typeof d.error&&d.error?`${a}: ${d.error}`:c}catch{return c}}function ap(a){let b=new Date(a),c=new Date().getTime()-b.getTime(),d=Math.floor(c/6e4),e=Math.floor(c/36e5),f=Math.floor(c/864e5);return d<1?"just now":d<60?`${d}m ago`:e<24?`${e}h ago`:f<7?`${f}d ago`:b.toLocaleDateString()}function aq(a,b){let c=b&&a.startsWith(b)?"~"+a.slice(b.length):a,d=c.includes("/")?"/":"\\",e=c.split(d).filter(Boolean);return e.length<=2?c:"…/"+e.slice(-2).join(d)}function ar(a,b){if(!a)return"No Project";let c=a.replace(/[\\/]+$/,""),d=c.includes("/")?"/":"\\";return c.split(d).filter(Boolean).pop()||aq(a,b)}function as(a){return a.lastAccessed??a.created??""}function at(){let[a,b]=(0,u.useState)(!1),[c,d]=(0,u.useState)(!1),e=(0,u.useRef)(null),f=function(a){let[b,c]=(0,u.useState)(a);return(0,u.useRef)(null),(0,u.useRef)(0),b}(a?"v0.8.23":an),g=(0,u.useCallback)(a=>{b(a),d(!0),setTimeout(()=>d(!1),(a?6:8)*4*(1e3/60)+100)},[]),h=(0,u.useCallback)(()=>{e.current&&clearTimeout(e.current);let b=!a;g(b),b&&(e.current=setTimeout(()=>g(!1),3e3))},[a,g]);return(0,t.jsx)("button",{onClick:h,style:{background:"none",border:"none",padding:0,cursor:"default",fontWeight:700,fontSize:15,letterSpacing:"-0.01em",color:a?"var(--accent)":"var(--text)",fontFamily:"var(--font-mono)",minWidth:"9ch"},children:f})}function au({selectedSessionId:a,onSelectSession:b,onNewSession:c,initialSessionId:d,onInitialRestoreDone:e,refreshKey:f,onSessionDeleted:g,selectedCwd:h,onCwdChange:i,onOpenFile:j,onExploreFile:k,explorerRefreshKey:l,onAtMention:m}){let[n,o]=(0,u.useState)([]),[p,q]=(0,u.useState)([]),[r,s]=(0,u.useState)(!0),[v,w]=(0,u.useState)(null),[x,y]=(0,u.useState)(null),[z,A]=(0,u.useState)(""),[B,C]=(0,u.useState)(!1),[D,E]=(0,u.useState)(null),[F,G]=(0,u.useState)(!1),[H,I]=(0,u.useState)(!1),[J,K]=(0,u.useState)(!1),[L,M]=(0,u.useState)(!0),N=(0,u.useRef)(!1),O=(0,u.useRef)(!1),P=(0,u.useRef)(null),[Q,R]=(0,u.useState)(!0),[S,T]=(0,u.useState)(0),[U,V]=(0,u.useState)(""),W=(0,u.useCallback)(async(a=!1)=>{try{a&&(w(null),s(!0));let[b,c]=await Promise.all([fetch("/api/sessions"),fetch("/api/projects")]);if(!b.ok)throw Error(await ao("sessions",b));if(!c.ok)throw Error(await ao("projects",c));let d=await b.json(),e=await c.json();o(d.sessions),q(e.projects),w(null)}catch(a){w(String(a))}finally{a&&s(!1)}},[]),X=(0,u.useCallback)(()=>{M(a=>!a),C(!1),E(null),W(!0)},[W]);(0,u.useRef)(!1);let Y=(0,u.useRef)(!1),Z=(0,u.useCallback)(async(a,b=!1)=>{try{let c=await fetch("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,create:b})}),d=await c.json();if(!c.ok||d.error)return E(d.error??`HTTP ${c.status}`),!1;return W(!1),!0}catch(a){return E(a instanceof Error?a.message:String(a)),!1}},[W]),$=(0,u.useCallback)(a=>{fetch("/api/projects",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,touch:!0})}).catch(()=>{})},[]),_=(0,u.useCallback)(a=>{O.current=!0,y(a),K(!1),R(!0),V(""),T(a=>a+1),i?.(a),$(a)},[i,$]),aa=(0,u.useCallback)(async()=>{try{let a=await fetch("/api/default-cwd",{method:"POST"}),b=await a.json();b.cwd&&(await Z(b.cwd,!1),_(b.cwd),C(!1))}catch{}},[_,Z]),ab=(0,u.useCallback)(async a=>{await Z(a,!1)&&(_(a),G(!1),E(null),C(!1))},[_,Z]),ac=h??x,ad=(0,u.useCallback)(a=>{if(!a)return void C(!0);let b="function"==typeof crypto.randomUUID?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}-${Math.random().toString(36).slice(2)}`;c?.(b,a)},[c]),ae=(0,u.useCallback)(()=>{ad(ac)},[ad,ac]),af=(0,u.useMemo)(()=>[...ac&&!p.some(a=>a.cwd===ac)?[{cwd:ac,displayName:ar(ac,z),chatCount:n.filter(a=>a.cwd===ac).length,lastAccessed:null,created:null,exists:!0,source:"manual"}]:[],...p].sort((a,b)=>{if(ac&&a.cwd===ac)return -1;if(ac&&b.cwd===ac)return 1;let c=as(a),d=as(b);return c!==d?d.localeCompare(c):a.displayName.localeCompare(b.displayName)}),[n,ac,z,p]),ag=(0,u.useMemo)(()=>n.filter(a=>a.cwd===ac).sort((a,b)=>b.modified.localeCompare(a.modified)),[n,ac]),ai=ac?af.find(a=>a.cwd===ac):void 0,aj=ac?af.find(a=>a.cwd===ac)?.displayName||ar(ac,z):"Open project...",ak=ai?.chatCount??ag.length,an=(0,u.useMemo)(()=>(function(a){let b=new Map;for(let c of a)b.set(c.id,{session:c,children:[]});let c=new Map;for(let b of a)b.parentSessionId&&c.set(b.id,b.parentSessionId);let d=[];for(let a of b.values()){let e=function(a){let d=c.get(a),e=new Set;for(;d&&!e.has(d);){if(e.add(d),b.has(d))return d;d=c.get(d)}return null}(a.session.id);e?b.get(e).children.push(a):d.push(a)}let e=a=>{a.sort((a,b)=>b.session.modified.localeCompare(a.session.modified)),a.forEach(a=>e(a.children))};return e(d),d})(ag),[ag]),aw=an.length,ax=an;if(aw>10&&!J){ax=an.slice(0,10);let b=an.find(b=>(function a(b,c){return!!c&&(b.session.id===c||b.children.some(b=>a(b,c)))})(b,a));b&&!ax.includes(b)&&(ax=[...ax,b])}let ay=aw-ax.length,az=(0,u.useCallback)((a,c=!1)=>{a.cwd!==ac&&(N.current=!0,y(a.cwd)),$(a.cwd),b(a,c)},[b,ac,$]);return(0,t.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},children:[(0,t.jsxs)("div",{style:{padding:"12px 10px 10px",borderBottom:"1px solid var(--border)",flexShrink:0},children:[(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:8},children:[(0,t.jsx)(at,{}),(0,t.jsxs)("div",{style:{display:"flex",gap:6},children:[(0,t.jsxs)("button",{onClick:ae,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:5,background:"var(--bg-hover)",border:"1px solid var(--border)",color:"var(--text-muted)",cursor:"pointer",height:32,paddingLeft:10,paddingRight:12,borderRadius:7,fontSize:12,fontWeight:500,letterSpacing:"-0.01em",flexShrink:0,transition:"background 0.12s, color 0.12s, border-color 0.12s"},title:ac?`New session in ${ac}`:"Select a project first",onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-selected)",a.currentTarget.style.color="var(--accent)",a.currentTarget.style.borderColor="rgba(37,99,235,0.35)"},onMouseLeave:a=>{a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="var(--text-muted)",a.currentTarget.style.borderColor="var(--border)"},children:[(0,t.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",children:[(0,t.jsx)("line",{x1:"6",y1:"1",x2:"6",y2:"11"}),(0,t.jsx)("line",{x1:"1",y1:"6",x2:"11",y2:"6"})]}),"New"]}),(0,t.jsx)("button",{onClick:()=>I(!0),style:{display:"flex",alignItems:"center",justifyContent:"center",background:"var(--bg-hover)",border:"1px solid var(--border)",color:"var(--text-muted)",cursor:"pointer",width:32,height:32,borderRadius:7,padding:0,flexShrink:0,transition:"background 0.12s, color 0.12s, border-color 0.12s"},title:"Search conversations",onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-selected)",a.currentTarget.style.color="var(--accent)",a.currentTarget.style.borderColor="rgba(37,99,235,0.35)"},onMouseLeave:a=>{a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="var(--text-muted)",a.currentTarget.style.borderColor="var(--border)"},children:(0,t.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("circle",{cx:"7",cy:"7",r:"4.4"}),(0,t.jsx)("path",{d:"M10.4 10.4 13.2 13.2"})]})})]})]}),(0,t.jsxs)("div",{ref:P,style:{position:"relative"},children:[(0,t.jsxs)("button",{type:"button",onClick:X,title:"Toggle and refresh project conversations","aria-expanded":L,style:{width:"100%",display:"flex",alignItems:"center",gap:6,padding:"6px 0",background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:11,fontWeight:600,letterSpacing:"0.05em",textTransform:"uppercase",textAlign:"left"},children:[(0,t.jsx)("svg",{width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:L?"rotate(90deg)":"none",transition:"transform 0.15s",flexShrink:0},children:(0,t.jsx)("polyline",{points:"3 2 7 5 3 8"})}),(0,t.jsx)("span",{style:{flex:1},children:"Project"}),r&&(0,t.jsx)("span",{style:{color:"var(--text-dim)",fontSize:10,fontWeight:500,letterSpacing:0,textTransform:"none"},children:"Refreshing..."})]}),L&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("button",{onClick:()=>C(a=>!a),style:{width:"100%",display:"flex",alignItems:"center",gap:9,padding:"8px 10px",background:ac?"var(--bg-hover)":"rgba(37,99,235,0.06)",border:ac?"1px solid var(--border)":"1px solid rgba(37,99,235,0.4)",borderRadius:7,cursor:"pointer",fontSize:12,color:"var(--text)",textAlign:"left",transition:"border-color 0.15s, background 0.15s"},children:[(0,t.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",style:{color:ac?"var(--accent)":"var(--text-dim)",flexShrink:0},children:(0,t.jsx)("path",{d:"M3 6.5A2.5 2.5 0 0 1 5.5 4H10l2 2.5h6.5A2.5 2.5 0 0 1 21 9v8.5A2.5 2.5 0 0 1 18.5 20h-13A2.5 2.5 0 0 1 3 17.5v-11Z"})}),(0,t.jsxs)("span",{style:{flex:1,minWidth:0},children:[(0,t.jsx)("span",{style:{display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:12,fontWeight:650,color:ac?"var(--text)":"var(--text-dim)"},children:ac?aj:d&&!Y.current?"":"Open project..."}),ac&&(0,t.jsx)("span",{style:{display:"block",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-dim)"},title:ac,children:aq(ac,z)})]}),ac&&(0,t.jsxs)("span",{style:{flexShrink:0,color:"var(--text-dim)",fontSize:10,whiteSpace:"nowrap"},children:[ak," chats"]}),(0,t.jsx)("svg",{width:"11",height:"11",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--text-dim)",flexShrink:0,transform:B?"rotate(180deg)":"none",transition:"transform 0.15s"},children:(0,t.jsx)("polyline",{points:"2 3.5 5 6.5 8 3.5"})})]}),B&&(0,t.jsxs)("div",{style:{position:"absolute",top:"calc(100% + 4px)",left:0,right:0,zIndex:100,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,boxShadow:"0 6px 20px rgba(0,0,0,0.10)",overflow:"hidden"},children:[(0,t.jsxs)("div",{style:{maxHeight:260,overflowY:"auto"},children:[0===af.length&&(0,t.jsx)("div",{style:{padding:"10px 12px",color:"var(--text-muted)",fontSize:12},children:"No projects yet"}),af.map(a=>{let b=a.cwd===ac,c=as(a);return(0,t.jsxs)("button",{onClick:()=>{_(a.cwd),E(null),C(!1)},style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"8px 10px",background:b?"var(--bg-selected)":"none",border:"none",borderBottom:"1px solid var(--border)",color:b?"var(--text)":"var(--text-muted)",cursor:"pointer",textAlign:"left",fontSize:11},title:a.cwd,children:[b?(0,t.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:(0,t.jsx)("polyline",{points:"1.5 5 4 7.5 8.5 2.5"})}):(0,t.jsx)("span",{style:{width:10,flexShrink:0}}),(0,t.jsxs)("span",{style:{flex:1,minWidth:0},children:[(0,t.jsx)("span",{style:{display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:b?"var(--text)":"var(--text-muted)",fontWeight:b?650:500},children:a.displayName}),(0,t.jsxs)("span",{style:{display:"block",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--text-dim)",fontSize:10},children:[a.chatCount," chats",c?` / ${ap(c)}`:"",a.exists?"":" / missing"]})]})]},a.cwd)})]}),(0,t.jsxs)("div",{style:{borderTop:af.length>0?"1px solid var(--border)":"none"},children:[(0,t.jsxs)("button",{onClick:a=>{a.stopPropagation(),aa()},style:{display:"flex",alignItems:"center",gap:7,width:"100%",padding:"8px 10px",background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",textAlign:"left",fontSize:11},children:[(0,t.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.1",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:(0,t.jsx)("path",{d:"M1 3A1 1 0 0 1 2 2H4L5 3.5H8.5a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5h-7A.5.5 0 0 1 1 8V3Z"})}),(0,t.jsx)("span",{children:"Use default directory"})]}),(0,t.jsxs)("button",{onClick:a=>{a.stopPropagation(),E(null),G(!0)},style:{display:"flex",alignItems:"center",gap:7,width:"100%",padding:"8px 10px",background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",textAlign:"left",fontSize:11},children:[(0,t.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.1",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[(0,t.jsx)("path",{d:"M1 3A1 1 0 0 1 2 2h1.5L4.5 3H8a1 1 0 0 1 1 1v4a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V3Z"}),(0,t.jsx)("path",{d:"M5 4.5v3M3.5 6h3"})]}),(0,t.jsx)("span",{children:"Select project path..."})]}),D&&(0,t.jsx)("div",{style:{padding:"0 10px 8px 27px",color:"#f87171",fontSize:10,lineHeight:1.4},children:D})]})]})]})]})]}),(0,t.jsx)(al,{open:H,cwd:ac,homeDir:z,onClose:()=>I(!1),onSelectSession:a=>{az(a)}}),L&&(0,t.jsx)(t.Fragment,{children:(0,t.jsxs)("div",{style:{flex:Q&&ac?"1 1 0":"1 1 auto",overflowY:"auto",padding:"6px 8px 8px",minHeight:120},children:[r&&(0,t.jsx)("div",{style:{padding:"16px 14px",color:"var(--text-muted)",fontSize:12},children:"Loading..."}),v&&(0,t.jsx)("div",{style:{padding:"12px 14px",color:"#f87171",fontSize:12},children:v}),!r&&!v&&!ac&&(0,t.jsx)("div",{style:{padding:"16px 14px",color:"var(--text-muted)",fontSize:12},children:"Open or create a project to start chatting."}),!r&&!v&&ac&&(0,t.jsxs)(t.Fragment,{children:[0===ag.length?(0,t.jsx)("button",{type:"button",onClick:()=>ad(ac),style:{width:"100%",padding:"12px",background:"transparent",border:"none",color:"var(--text-muted)",cursor:"pointer",textAlign:"left",fontSize:12},onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="var(--text)"},onMouseLeave:a=>{a.currentTarget.style.background="transparent",a.currentTarget.style.color="var(--text-muted)"},children:"Start a new session in this project"}):ax.map(b=>(0,t.jsx)(av,{node:b,selectedSessionId:a,onSelectSession:az,onRenamed:W,onSessionDeleted:a=>{g?.(a),W()},depth:0},b.session.id)),(J||ay>0)&&aw>10&&(0,t.jsx)("button",{type:"button",onClick:()=>K(a=>!a),style:{width:"100%",padding:"6px 10px",background:"transparent",border:"none",color:"var(--text-dim)",cursor:"pointer",fontSize:11,textAlign:"center"},children:J?"Show less":`Show ${Math.max(0,ay)} more`})]})]})}),ac&&(0,t.jsxs)("div",{style:{borderTop:"1px solid var(--border)",display:"flex",flexDirection:"column",flex:Q?"1 1 0":"0 0 auto",minHeight:0,overflow:"hidden"},children:[(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",flexShrink:0,gap:0,padding:"2px 4px"},children:[(0,t.jsxs)("button",{onClick:()=>{R(a=>!a),T(a=>a+1)},style:{display:"flex",alignItems:"center",gap:6,padding:"6px 6px 6px 6px",background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:11,fontWeight:600,letterSpacing:"0.05em",textTransform:"uppercase",textAlign:"left",flexShrink:0},children:[(0,t.jsx)("svg",{width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:Q?"rotate(90deg)":"none",transition:"transform 0.15s",flexShrink:0},children:(0,t.jsx)("polyline",{points:"3 2 7 5 3 8"})}),"Explorer"]}),(0,t.jsxs)("div",{style:{position:"relative",flex:1,minWidth:0},children:[(0,t.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",style:{position:"absolute",left:8,top:"50%",transform:"translateY(-50%)",color:"var(--text-dim)",pointerEvents:"none"},children:[(0,t.jsx)("circle",{cx:"7",cy:"7",r:"4.4"}),(0,t.jsx)("path",{d:"M10.4 10.4 13.2 13.2"})]}),(0,t.jsx)("input",{value:U,onChange:a=>V(a.target.value),placeholder:"Filter files...",style:{width:"100%",height:28,boxSizing:"border-box",padding:"0 26px 0 26px",borderRadius:6,border:"1px solid var(--border)",background:"var(--bg)",color:"var(--text)",fontSize:12,outline:"none"}}),U&&(0,t.jsx)("button",{type:"button",onClick:()=>V(""),title:"Clear filter",style:{position:"absolute",right:4,top:"50%",transform:"translateY(-50%)",width:20,height:20,display:"flex",alignItems:"center",justifyContent:"center",border:"none",borderRadius:4,background:"transparent",color:"var(--text-dim)",cursor:"pointer",padding:0},children:(0,t.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[(0,t.jsx)("line",{x1:"2",y1:"2",x2:"8",y2:"8"}),(0,t.jsx)("line",{x1:"8",y1:"2",x2:"2",y2:"8"})]})})]})]}),Q&&(0,t.jsx)("div",{style:{flex:1,overflowY:"auto",overflowX:"hidden"},children:(0,t.jsx)(ah,{cwd:ac,onOpenFile:j??(()=>{}),onExploreFile:k,refreshKey:S,onAtMention:m,searchQuery:U,onSearchChange:V})})]}),(0,t.jsx)(am,{open:F,initialPath:ac||z||null,onClose:()=>G(!1),onSelect:a=>void ab(a)})]})}function av({node:a,selectedSessionId:b,onSelectSession:c,onRenamed:d,onSessionDeleted:e,depth:f}){let[g,h]=(0,u.useState)(!1),i=a.children.length>0;return(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{style:{position:"relative"},children:[f>0&&(0,t.jsx)("div",{style:{position:"absolute",left:12*f+6,top:0,bottom:0,width:1,background:"var(--border)",pointerEvents:"none"}}),(0,t.jsx)(aw,{session:a.session,isSelected:a.session.id===b,onClick:()=>c(a.session),onRenamed:d,onDeleted:a=>e?.(a),depth:f,hasChildren:i,collapsed:g,onToggleCollapse:()=>h(a=>!a)})]}),i&&!g&&(0,t.jsx)("div",{children:a.children.map(a=>(0,t.jsx)(av,{node:a,selectedSessionId:b,onSelectSession:c,onRenamed:d,onSessionDeleted:e,depth:f+1},a.session.id))})]})}function aw({session:a,isSelected:b,onClick:c,onRenamed:d,onDeleted:e,depth:f=0,hasChildren:g=!1,collapsed:h=!1,onToggleCollapse:i}){let[j,k]=(0,u.useState)(!1),[l,m]=(0,u.useState)(!1),[n,o]=(0,u.useState)(""),[p,q]=(0,u.useState)(!1),[r,s]=(0,u.useState)(!1),v=(0,u.useRef)(null),w=a.name||a.firstMessage.slice(0,50)||a.id.slice(0,12),x=(0,u.useCallback)(b=>{b.stopPropagation(),o(a.name??""),m(!0),setTimeout(()=>v.current?.select(),0)},[a.name]),y=(0,u.useCallback)(async()=>{let b=n.trim();if(m(!1),b!==(a.name??""))try{await fetch(`/api/sessions/${encodeURIComponent(a.id)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:b})}),d?.()}catch{}},[n,a.id,a.name,d]),z=(0,u.useCallback)(a=>{a.stopPropagation(),q(!0)},[]),A=(0,u.useCallback)(async b=>{b.stopPropagation(),q(!1),s(!0);try{await fetch(`/api/sessions/${encodeURIComponent(a.id)}`,{method:"DELETE"}),e?.(a.id)}catch{s(!1)}},[a.id,e]),B=(0,u.useCallback)(a=>{a.stopPropagation(),q(!1)},[]);return(0,t.jsx)("div",{onClick:p||l?void 0:c,onMouseEnter:()=>k(!0),onMouseLeave:()=>{k(!1)},style:{height:54,display:"flex",alignItems:"center",paddingLeft:f>0?12*f+14:14,paddingRight:8,cursor:p||l?"default":"pointer",background:p?"rgba(239,68,68,0.06)":b?"var(--bg-selected)":j?"var(--bg-hover)":"transparent",borderLeft:p?"2px solid #ef4444":b?"2px solid var(--accent)":"2px solid transparent",transition:"background 0.1s",opacity:r?.5:1,gap:6,overflow:"hidden"},children:p?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{style:{flex:1,minWidth:0,fontSize:12,color:"var(--text)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:["Delete ",(0,t.jsxs)("span",{style:{fontWeight:600},children:["“",w.slice(0,22),w.length>22?"…":"","”"]}),"?"]}),(0,t.jsxs)("div",{style:{display:"flex",gap:5,flexShrink:0},children:[(0,t.jsxs)("button",{onClick:A,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:4,height:30,padding:"0 11px",background:"#ef4444",border:"none",borderRadius:6,color:"#fff",cursor:"pointer",fontSize:12,fontWeight:600,whiteSpace:"nowrap"},children:[(0,t.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,t.jsx)("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),(0,t.jsx)("path",{d:"M10 11v6M14 11v6"}),(0,t.jsx)("path",{d:"M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"})]}),"Delete"]}),(0,t.jsx)("button",{onClick:B,style:{display:"flex",alignItems:"center",justifyContent:"center",height:30,padding:"0 11px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:6,color:"var(--text-muted)",cursor:"pointer",fontSize:12,fontWeight:500,whiteSpace:"nowrap"},children:"Cancel"})]})]}):l?(0,t.jsx)("input",{ref:v,value:n,onChange:a=>o(a.target.value),onBlur:y,onKeyDown:a=>{"Enter"===a.key&&y(),"Escape"===a.key&&m(!1)},autoFocus:!0,style:{flex:1,fontSize:12,padding:"5px 8px",border:"1px solid var(--accent)",borderRadius:5,outline:"none",background:"var(--bg)",color:"var(--text)",height:30}}):(0,t.jsxs)(t.Fragment,{children:[f>0&&(0,t.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-dim)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[(0,t.jsx)("line",{x1:"6",y1:"3",x2:"6",y2:"15"}),(0,t.jsx)("circle",{cx:"18",cy:"6",r:"3"}),(0,t.jsx)("circle",{cx:"6",cy:"18",r:"3"}),(0,t.jsx)("path",{d:"M18 9a9 9 0 0 1-9 9"})]}),(0,t.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,t.jsx)("div",{style:{fontSize:12,fontWeight:b?500:400,lineHeight:1.4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--text)"},title:w,children:w}),(0,t.jsxs)("div",{style:{marginTop:2,display:"flex",gap:8,color:"var(--text-dim)",fontSize:11},children:[(0,t.jsx)("span",{title:a.modified,children:ap(a.modified)}),(0,t.jsxs)("span",{children:[a.messageCount," msgs"]})]})]}),g&&(0,t.jsx)("button",{onClick:a=>{a.stopPropagation(),i?.()},title:h?"Expand forks":"Collapse forks",style:{display:"flex",alignItems:"center",justifyContent:"center",width:20,height:20,padding:0,flexShrink:0,background:"none",border:"none",color:"var(--text-dim)",cursor:"pointer",transform:h?"rotate(-90deg)":"none",transition:"transform 0.15s"},children:(0,t.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:(0,t.jsx)("polyline",{points:"2 3.5 5 6.5 8 3.5"})})}),j&&(0,t.jsxs)("div",{style:{display:"flex",gap:4,flexShrink:0},children:[(0,t.jsx)("button",{onClick:x,title:"Rename",style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,padding:0,background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:7,color:"var(--text-muted)",cursor:"pointer",flexShrink:0,transition:"background 0.12s, color 0.12s, border-color 0.12s"},onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-selected)",a.currentTarget.style.color="var(--accent)",a.currentTarget.style.borderColor="rgba(37,99,235,0.35)"},onMouseLeave:a=>{a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="var(--text-muted)",a.currentTarget.style.borderColor="var(--border)"},children:(0,t.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,t.jsx)("path",{d:"M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"})})}),(0,t.jsx)("button",{onClick:z,title:"Delete",style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,padding:0,background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:7,color:"var(--text-muted)",cursor:"pointer",flexShrink:0,transition:"background 0.12s, color 0.12s, border-color 0.12s"},onMouseEnter:a=>{a.currentTarget.style.background="rgba(239,68,68,0.08)",a.currentTarget.style.color="#ef4444",a.currentTarget.style.borderColor="rgba(239,68,68,0.35)"},onMouseLeave:a=>{a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="var(--text-muted)",a.currentTarget.style.borderColor="var(--border)"},children:(0,t.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,t.jsx)("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),(0,t.jsx)("path",{d:"M10 11v6M14 11v6"}),(0,t.jsx)("path",{d:"M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"})]})})]})]})})}let ax=new Set;function ay(a){return ax.add(a),()=>{ax.delete(a)}}function az(){return"u"<typeof document?"light":document.documentElement.classList.contains("dark")?"dark":"light"}function aA(){return"light"}function aB(){let a=(0,u.useSyncExternalStore)(ay,az,aA);return{theme:a,toggleTheme:(0,u.useCallback)(a=>{let b="dark"===az()?"light":"dark",c=()=>{"dark"===b?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark");try{localStorage.setItem("pi-theme",b)}catch{}ax.forEach(a=>a())},d=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;if("function"!=typeof document.startViewTransition||d)return void c();let e=a?.x??window.innerWidth/2,f=a?.y??window.innerHeight/2,g=Math.hypot(Math.max(e,window.innerWidth-e),Math.max(f,window.innerHeight-f));document.startViewTransition(c).ready.then(()=>{document.documentElement.animate({clipPath:[`circle(0px at ${e}px ${f}px)`,`circle(${g}px at ${e}px ${f}px)`]},{duration:450,easing:"cubic-bezier(0.22, 0.61, 0.36, 1)",pseudoElement:"::view-transition-new(root)"})}).catch(()=>{})},[]),isDark:"dark"===a}}function aC(a){let b,c=[],d=/`{1,3}show-widget`{0,3}\s*(?:\n\s*`{3}(?:json|html)?\s*)?\n?/g,e=0,f=!1;for(;null!==(b=d.exec(a));){f=!0;let g=a.slice(e,b.index).trim();g&&c.push({type:"text",content:g});let h=b.index+b[0].length,i=a.indexOf("```",h),j=a.indexOf("{",h);if(-1!==j&&j<=h+200&&(-1===i||j<i)){let b=function(a,b){let c=0,d=!1,e=!1;for(let f=b;f<a.length;f++){let b=a[f];if(e){e=!1;continue}if("\\"===b&&d){e=!0;continue}if('"'===b){d=!d;continue}if(!d&&("{"===b&&c++,"}"===b)&&0==--c)return f}return -1}(a,j);if(-1===b){let b=function(a){try{let b=aD(a);if(b)return b}catch{}let b=a.indexOf('"widget_code"');if(-1===b)return null;let c=a.indexOf(":",b+13);if(-1===c)return null;let d=a.indexOf('"',c+1);if(-1===d)return null;let e=a.slice(d+1);(e=e.replace(/"\s*\}\s*$/,"")).endsWith("\\")&&(e=e.slice(0,-1));let f=a.match(/"title"\s*:\s*"([^"]*?)"/)?.[1],g=aE(e.replace(/\\\\/g,"\0BACKSLASH\0").replace(/\\n/g,"\n").replace(/\\t/g," ").replace(/\\r/g,"\r").replace(/\\"/g,'"').replace(/\\u([0-9a-fA-F]{4})/g,(a,b)=>String.fromCharCode(parseInt(b,16))).replace(/\x00BACKSLASH\x00/g,"\\"));return g.code.trim()?{title:f,code:g.code,showOverlay:g.truncated}:null}(a.slice(j));b&&c.push({type:"widget",...b,partial:!0}),e=a.length;break}let f=aD(a.slice(j,b+1).trim());f&&c.push({type:"widget",...f});let g=b+1,h=a.slice(g,g+16).match(/^\s*\n?`{1,3}\s*/);h&&(g+=h[0].length),e=g,d.lastIndex=g;continue}if(-1!==i){let b=a.slice(h,i).trim(),f=aD(b);f?c.push({type:"widget",...f}):b&&c.push({type:"text",content:b}),d.lastIndex=e=i+3}else{let b=aD(a.slice(h).trim());if(b){let a=aE(b.code);c.push({type:"widget",title:b.title,code:a.code,partial:!0,showOverlay:a.truncated})}e=a.length;break}}let g=a.slice(e).trim();return g&&c.push({type:"text",content:g}),!f&&0===c.length&&a.trim()&&c.push({type:"text",content:a}),c}function aD(a){if(a.startsWith("{")){if(!a.endsWith("}"))return null;try{let b=JSON.parse(a),c=b.widget_code??b.code;if(c)return{title:b.title,code:c}}catch{return null}}return/<(!DOCTYPE|html|svg|canvas|script|style|div)/i.test(a)?{code:a}:null}function aE(a){let b=a.lastIndexOf("<script");if(-1===b)return{code:a,truncated:!1};let c=a.slice(b);return/<script[\s\S]*?<\/script>/i.test(c)?{code:a,truncated:!1}:{code:a.slice(0,b).trim(),truncated:!0}}let aF=/<(iframe|object|embed|meta|link|base|form)[\s>][\s\S]*?<\/\1>/gi,aG=/<(iframe|object|embed|meta|link|base)\b[^>]*\/?>/gi;function aH(a){return a.replace(aF,"").replace(aG,"")}let aI=["--bg","--bg-panel","--bg-hover","--bg-selected","--border","--text","--text-muted","--text-dim","--accent","--accent-hover"],aJ=["--bg","--bg-panel","--bg-hover","--bg-selected","--border","--text","--text-muted","--text-dim","--accent","--accent-hover"];async function aK(a){if(navigator.clipboard?.writeText)return void await navigator.clipboard.writeText(a);let b=document.createElement("textarea");b.value=a,b.style.position="fixed",b.style.inset="0",b.style.opacity="0",document.body.appendChild(b),b.focus(),b.select();let c=document.execCommand("copy");if(document.body.removeChild(b),!c)throw Error("Clipboard copy failed.")}async function aL(a){let b=await aM(a.code);if(b)return b;if(a.capture)return function(a){if(!a.html)throw Error("The widget did not provide capturable HTML.");let b=aP({width:a.bodyWidth||640,height:a.bodyHeight||360}),c=function(a){let b=document.createElement("template");b.innerHTML=aH(a.html||"");let c=document.createElement("div");for(let d of(c.appendChild(b.content.cloneNode(!0)),Array.from(c.querySelectorAll("img[data-canvas-export]")))){let b=Number(d.getAttribute("data-canvas-export")),c=Number.isFinite(b)?a.canvases?.[b]:null;if(!c?.dataUrl){d.remove();continue}d.setAttribute("src",c.dataUrl),d.setAttribute("width",String(c.width)),d.setAttribute("height",String(c.height)),d.setAttribute("style",function(a,b){let c=new Map;for(let b of(a||"").split(";")){let[a,...d]=b.split(":");a?.trim()&&d.length>0&&c.set(a.trim(),d.join(":").trim())}for(let[a,d]of Object.entries(b))c.set(a,d);return Array.from(c.entries()).map(([a,b])=>a+":"+b).join(";")}(d.getAttribute("style"),{width:c.width+"px",height:c.height+"px",display:"block"}))}return aN(c),Array.from(c.childNodes).map(a=>new XMLSerializer().serializeToString(a)).join("")}(a);if(!c.trim())throw Error("The widget capture was empty.");let d=[a.styles||"","#__widget_export_root{"+function(){if("u"<typeof document)return"";let a=getComputedStyle(document.documentElement);return aJ.map(b=>{let c=a.getPropertyValue(b).trim();return c?b+":"+c+";":""}).join("")}()+'font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",system-ui,sans-serif;font-size:14px;line-height:1.6;color:var(--text,#1a1a1a);background:transparent;}',"#__widget_export_root *{box-sizing:border-box;}\n#__widget_export_root svg{max-width:100%;height:auto;display:block;}"].join("\n");return aR(aS('<svg xmlns="http://www.w3.org/2000/svg" width="'+b.width+'" height="'+b.height+'" viewBox="0 0 '+b.width+" "+b.height+'"><defs><style><![CDATA['+d.replace(/\]\]>/g,"]]]]><![CDATA[>")+']]></style></defs><foreignObject x="0" y="0" width="100%" height="100%">'+('<div xmlns="http://www.w3.org/1999/xhtml" id="__widget_export_root" style="width:'+b.width+"px;min-height:")+b.height+'px;overflow:visible;">'+c+"</div></foreignObject></svg>"),b.width,b.height)}(a.capture);throw Error("PNG export needs a rendered widget capture.")}async function aM(a){var b;let c,d,e,f,g=function(a){let b=aH(a).trim();if(!/^<\s*(style|svg)\b/i.test(b))return null;let c=new DOMParser().parseFromString(b,"text/html"),d=Array.from(c.body.children),e=d.filter(a=>"svg"===a.tagName.toLowerCase()),f=d.filter(a=>"style"!==a.tagName.toLowerCase());if(1!==e.length||1!==f.length)return null;let g=e[0].cloneNode(!0),h=Array.from(c.body.querySelectorAll("style")).map(a=>a.textContent||"").join("\n").trim();if(h){let a=document.createElementNS("http://www.w3.org/2000/svg","style");a.textContent=h,g.insertBefore(a,g.firstChild)}return g}(a);if(!g)return null;aN(g),g.setAttribute("xmlns","http://www.w3.org/2000/svg");let h=aP((c=function(a){if(!a)return null;let b=a.trim().split(/[\s,]+/).map(Number);return 4!==b.length||b.some(a=>!Number.isFinite(a))||b[2]<=0||b[3]<=0?null:{width:b[2],height:b[3]}}((b=g).getAttribute("viewBox")),d=aO(b.getAttribute("width"))??c?.width??640,e=c?c.height/c.width:.5625,f=aO(b.getAttribute("height"))??c?.height??d*e,{width:d,height:f}));return g.setAttribute("width",String(h.width)),g.setAttribute("height",String(h.height)),g.getAttribute("viewBox")||g.setAttribute("viewBox","0 0 "+h.width+" "+h.height),aR(aS(new XMLSerializer().serializeToString(g)),h.width,h.height)}function aN(a){for(let b of Array.from(a.querySelectorAll("script, iframe, object, embed, meta, link, base, form")))b.remove();for(let b of[a,...Array.from(a.querySelectorAll("*"))])for(let a of Array.from(b.attributes)){let c=a.name.toLowerCase(),d=a.value.trim();if(c.startsWith("on")){b.removeAttribute(a.name);continue}("href"===c||"src"===c||c.endsWith(":href"))&&/^\s*(javascript|data:text\/html)/i.test(d)&&b.removeAttribute(a.name)}}function aO(a){if(!a||a.includes("%"))return null;let b=Number.parseFloat(a);return Number.isFinite(b)&&b>0?b:null}function aP(a){let b=aQ(Math.ceil(a.width||640),240,2e3),c=aQ(Math.ceil(a.height||360),80,4e3),d=b*c;if(d>8e6){let a=Math.sqrt(8e6/d);b=Math.max(240,Math.floor(b*a)),c=Math.max(80,Math.floor(c*a))}return{width:b,height:c}}function aQ(a,b,c){return Math.min(Math.max(a,b),c)}function aR(a,b,c){return new Promise((d,e)=>{let f=new Image,g=URL.createObjectURL(new Blob([a],{type:"image/svg+xml;charset=utf-8"}));f.onload=()=>{URL.revokeObjectURL(g);try{let a=document.createElement("canvas"),g=Math.min(window.devicePixelRatio||1,2);a.width=Math.ceil(b*g),a.height=Math.ceil(c*g),a.style.width=b+"px",a.style.height=c+"px";let h=a.getContext("2d");if(!h)throw Error("Canvas is not available.");h.scale(g,g),h.drawImage(f,0,0,b,c),a.toBlob(a=>{a?d(a):e(Error("Canvas export returned no image."))},"image/png")}catch(a){e(a instanceof Error?a:Error("PNG export failed."))}},f.onerror=()=>{URL.revokeObjectURL(g),e(Error("The browser could not render this widget as PNG."))},f.src=g})}function aS(a){if("u"<typeof document)return a;let b=getComputedStyle(document.documentElement);return a.replace(/var\(\s*(--[a-zA-Z0-9_-]+)(?:\s*,\s*([^)]+))?\)/g,(a,c,d)=>b.getPropertyValue(c).trim()||d?.trim()||"#000")}let aT=/cdnjs\.cloudflare\.com|cdn\.jsdelivr\.net|unpkg\.com|esm\.sh/,aU=new Map;function aV(a){return a.slice(0,200)}function aW({code:a,isStreaming:b,title:c,showOverlay:d,onSendMessage:e}){let{isDark:f}=aB(),g=(0,u.useRef)(null);(0,u.useRef)(null);let h=(0,u.useRef)(null),i=(0,u.useRef)(new Map),j=(0,u.useRef)(""),[k,l]=(0,u.useState)(!1),[m,n]=(0,u.useState)(()=>aU.get(aV(a))??0),[o,p]=(0,u.useState)(!1),[q,r]=(0,u.useState)(!1),[s,v]=(0,u.useState)(null),[w,x]=(0,u.useState)(!1),[y,z]=(0,u.useState)(!1);(0,u.useRef)("");let A=(0,u.useRef)((aU.get(aV(a))??0)>0);(0,u.useRef)(!1);let B=(0,u.useRef)(f),C=(0,u.useMemo)(()=>aT.test(a),[a]),D=(0,u.useMemo)(()=>{let a;return function(a="",b=!1){return`<!DOCTYPE html>
1
+ (()=>{var a={};a.id=8974,a.ids=[8974],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},478:(a,b,c)=>{Promise.resolve().then(c.bind(c,13832))},2414:(a,b)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.default=void 0,b.default={'code[class*="language-"]':{color:"#c5c8c6",textShadow:"0 1px rgba(0, 0, 0, 0.3)",fontFamily:"Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace",direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none"},'pre[class*="language-"]':{color:"#c5c8c6",textShadow:"0 1px rgba(0, 0, 0, 0.3)",fontFamily:"Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace",direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",padding:"1em",margin:".5em 0",overflow:"auto",borderRadius:"0.3em",background:"#1d1f21"},':not(pre) > code[class*="language-"]':{background:"#1d1f21",padding:".1em",borderRadius:".3em"},comment:{color:"#7C7C7C"},prolog:{color:"#7C7C7C"},doctype:{color:"#7C7C7C"},cdata:{color:"#7C7C7C"},punctuation:{color:"#c5c8c6"},".namespace":{Opacity:".7"},property:{color:"#96CBFE"},keyword:{color:"#96CBFE"},tag:{color:"#96CBFE"},"class-name":{color:"#FFFFB6",textDecoration:"underline"},boolean:{color:"#99CC99"},constant:{color:"#99CC99"},symbol:{color:"#f92672"},deleted:{color:"#f92672"},number:{color:"#FF73FD"},selector:{color:"#A8FF60"},"attr-name":{color:"#A8FF60"},string:{color:"#A8FF60"},char:{color:"#A8FF60"},builtin:{color:"#A8FF60"},inserted:{color:"#A8FF60"},variable:{color:"#C6C5FE"},operator:{color:"#EDEDED"},entity:{color:"#FFFFB6",cursor:"help"},url:{color:"#96CBFE"},".language-css .token.string":{color:"#87C38A"},".style .token.string":{color:"#87C38A"},atrule:{color:"#F9EE98"},"attr-value":{color:"#F9EE98"},function:{color:"#DAD085"},regex:{color:"#E9C062"},important:{color:"#fd971f",fontWeight:"bold"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"}}},3174:(a,b)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.camelCase=void 0;var c=/^--[a-zA-Z0-9_-]+$/,d=/-([a-z])/g,e=/^[^-]+$/,f=/^-(webkit|moz|ms|o|khtml)-/,g=/^-(ms)-/,h=function(a,b){return b.toUpperCase()},i=function(a,b){return"".concat(b,"-")};b.camelCase=function(a,b){var j;return(void 0===b&&(b={}),!(j=a)||e.test(j)||c.test(j))?a:(a=a.toLowerCase(),(a=b.reactCompat?a.replace(g,i):a.replace(f,i)).replace(d,h))}},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},3531:(a,b)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.default=void 0,b.default={'code[class*="language-"]':{color:"#d6deeb",fontFamily:'Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace',textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",wordWrap:"normal",lineHeight:"1.5",fontSize:"1em",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none"},'pre[class*="language-"]':{color:"white",fontFamily:'Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace',textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",wordWrap:"normal",lineHeight:"1.5",fontSize:"1em",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",padding:"1em",margin:"0.5em 0",overflow:"auto",background:"#011627"},'pre[class*="language-"]::-moz-selection':{textShadow:"none",background:"rgba(29, 59, 83, 0.99)"},'pre[class*="language-"] ::-moz-selection':{textShadow:"none",background:"rgba(29, 59, 83, 0.99)"},'code[class*="language-"]::-moz-selection':{textShadow:"none",background:"rgba(29, 59, 83, 0.99)"},'code[class*="language-"] ::-moz-selection':{textShadow:"none",background:"rgba(29, 59, 83, 0.99)"},'pre[class*="language-"]::selection':{textShadow:"none",background:"rgba(29, 59, 83, 0.99)"},'pre[class*="language-"] ::selection':{textShadow:"none",background:"rgba(29, 59, 83, 0.99)"},'code[class*="language-"]::selection':{textShadow:"none",background:"rgba(29, 59, 83, 0.99)"},'code[class*="language-"] ::selection':{textShadow:"none",background:"rgba(29, 59, 83, 0.99)"},':not(pre) > code[class*="language-"]':{color:"white",background:"#011627",padding:"0.1em",borderRadius:"0.3em",whiteSpace:"normal"},comment:{color:"rgb(99, 119, 119)",fontStyle:"italic"},prolog:{color:"rgb(99, 119, 119)",fontStyle:"italic"},cdata:{color:"rgb(99, 119, 119)",fontStyle:"italic"},punctuation:{color:"rgb(199, 146, 234)"},".namespace":{color:"rgb(178, 204, 214)"},deleted:{color:"rgba(239, 83, 80, 0.56)",fontStyle:"italic"},symbol:{color:"rgb(128, 203, 196)"},property:{color:"rgb(128, 203, 196)"},tag:{color:"rgb(127, 219, 202)"},operator:{color:"rgb(127, 219, 202)"},keyword:{color:"rgb(127, 219, 202)"},boolean:{color:"rgb(255, 88, 116)"},number:{color:"rgb(247, 140, 108)"},constant:{color:"rgb(130, 170, 255)"},function:{color:"rgb(130, 170, 255)"},builtin:{color:"rgb(130, 170, 255)"},char:{color:"rgb(130, 170, 255)"},selector:{color:"rgb(199, 146, 234)",fontStyle:"italic"},doctype:{color:"rgb(199, 146, 234)",fontStyle:"italic"},"attr-name":{color:"rgb(173, 219, 103)",fontStyle:"italic"},inserted:{color:"rgb(173, 219, 103)",fontStyle:"italic"},string:{color:"rgb(173, 219, 103)"},url:{color:"rgb(173, 219, 103)"},entity:{color:"rgb(173, 219, 103)"},".language-css .token.string":{color:"rgb(173, 219, 103)"},".style .token.string":{color:"rgb(173, 219, 103)"},"class-name":{color:"rgb(255, 203, 139)"},atrule:{color:"rgb(255, 203, 139)"},"attr-value":{color:"rgb(255, 203, 139)"},regex:{color:"rgb(214, 222, 235)"},important:{color:"rgb(214, 222, 235)",fontWeight:"bold"},variable:{color:"rgb(214, 222, 235)"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"}}},4899:(a,b)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.default=void 0,b.default={'code[class*="language-"]':{color:"#111b27",background:"none",fontFamily:'Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace',textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",wordWrap:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none"},'pre[class*="language-"]':{color:"#111b27",background:"#e3eaf2",fontFamily:'Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace',textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",wordWrap:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",padding:"1em",margin:"0.5em 0",overflow:"auto"},'pre[class*="language-"]::-moz-selection':{background:"#8da1b9"},'pre[class*="language-"] ::-moz-selection':{background:"#8da1b9"},'code[class*="language-"]::-moz-selection':{background:"#8da1b9"},'code[class*="language-"] ::-moz-selection':{background:"#8da1b9"},'pre[class*="language-"]::selection':{background:"#8da1b9"},'pre[class*="language-"] ::selection':{background:"#8da1b9"},'code[class*="language-"]::selection':{background:"#8da1b9"},'code[class*="language-"] ::selection':{background:"#8da1b9"},':not(pre) > code[class*="language-"]':{background:"#e3eaf2",padding:"0.1em 0.3em",borderRadius:"0.3em",whiteSpace:"normal"},comment:{color:"#3c526d"},prolog:{color:"#3c526d"},doctype:{color:"#3c526d"},cdata:{color:"#3c526d"},punctuation:{color:"#111b27"},"delimiter.important":{color:"#006d6d",fontWeight:"inherit"},"selector.parent":{color:"#006d6d"},tag:{color:"#006d6d"},"tag.punctuation":{color:"#006d6d"},"attr-name":{color:"#755f00"},boolean:{color:"#755f00"},"boolean.important":{color:"#755f00"},number:{color:"#755f00"},constant:{color:"#755f00"},"selector.attribute":{color:"#755f00"},"class-name":{color:"#005a8e"},key:{color:"#005a8e"},parameter:{color:"#005a8e"},property:{color:"#005a8e"},"property-access":{color:"#005a8e"},variable:{color:"#005a8e"},"attr-value":{color:"#116b00"},inserted:{color:"#116b00"},color:{color:"#116b00"},"selector.value":{color:"#116b00"},string:{color:"#116b00"},"string.url-link":{color:"#116b00"},builtin:{color:"#af00af"},"keyword-array":{color:"#af00af"},package:{color:"#af00af"},regex:{color:"#af00af"},function:{color:"#7c00aa"},"selector.class":{color:"#7c00aa"},"selector.id":{color:"#7c00aa"},"atrule.rule":{color:"#a04900"},combinator:{color:"#a04900"},keyword:{color:"#a04900"},operator:{color:"#a04900"},"pseudo-class":{color:"#a04900"},"pseudo-element":{color:"#a04900"},selector:{color:"#a04900"},unit:{color:"#a04900"},deleted:{color:"#c22f2e"},important:{color:"#c22f2e",fontWeight:"bold"},"keyword-this":{color:"#005a8e",fontWeight:"bold"},this:{color:"#005a8e",fontWeight:"bold"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"},entity:{cursor:"help"},".language-markdown .token.title":{color:"#005a8e",fontWeight:"bold"},".language-markdown .token.title .token.punctuation":{color:"#005a8e",fontWeight:"bold"},".language-markdown .token.blockquote.punctuation":{color:"#af00af"},".language-markdown .token.code":{color:"#006d6d"},".language-markdown .token.hr.punctuation":{color:"#005a8e"},".language-markdown .token.url > .token.content":{color:"#116b00"},".language-markdown .token.url-link":{color:"#755f00"},".language-markdown .token.list.punctuation":{color:"#af00af"},".language-markdown .token.table-header":{color:"#111b27"},".language-json .token.operator":{color:"#111b27"},".language-scss .token.variable":{color:"#006d6d"},"token.tab:not(:empty):before":{color:"#3c526d"},"token.cr:before":{color:"#3c526d"},"token.lf:before":{color:"#3c526d"},"token.space:before":{color:"#3c526d"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > a":{color:"#e3eaf2",background:"#005a8e"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > button":{color:"#e3eaf2",background:"#005a8e"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > a:hover":{color:"#e3eaf2",background:"#005a8eda",textDecoration:"none"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > a:focus":{color:"#e3eaf2",background:"#005a8eda",textDecoration:"none"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > button:hover":{color:"#e3eaf2",background:"#005a8eda",textDecoration:"none"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > button:focus":{color:"#e3eaf2",background:"#005a8eda",textDecoration:"none"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > span":{color:"#e3eaf2",background:"#3c526d"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > span:hover":{color:"#e3eaf2",background:"#3c526d"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > span:focus":{color:"#e3eaf2",background:"#3c526d"},".line-highlight.line-highlight":{background:"linear-gradient(to right, #8da1b92f 70%, #8da1b925)"},".line-highlight.line-highlight:before":{backgroundColor:"#3c526d",color:"#e3eaf2",boxShadow:"0 1px #8da1b9"},".line-highlight.line-highlight[data-end]:after":{backgroundColor:"#3c526d",color:"#e3eaf2",boxShadow:"0 1px #8da1b9"},"pre[id].linkable-line-numbers.linkable-line-numbers span.line-numbers-rows > span:hover:before":{backgroundColor:"#3c526d1f"},".line-numbers.line-numbers .line-numbers-rows":{borderRight:"1px solid #8da1b97a",background:"#d0dae77a"},".line-numbers .line-numbers-rows > span:before":{color:"#3c526dda"},".rainbow-braces .token.token.punctuation.brace-level-1":{color:"#755f00"},".rainbow-braces .token.token.punctuation.brace-level-5":{color:"#755f00"},".rainbow-braces .token.token.punctuation.brace-level-9":{color:"#755f00"},".rainbow-braces .token.token.punctuation.brace-level-2":{color:"#af00af"},".rainbow-braces .token.token.punctuation.brace-level-6":{color:"#af00af"},".rainbow-braces .token.token.punctuation.brace-level-10":{color:"#af00af"},".rainbow-braces .token.token.punctuation.brace-level-3":{color:"#005a8e"},".rainbow-braces .token.token.punctuation.brace-level-7":{color:"#005a8e"},".rainbow-braces .token.token.punctuation.brace-level-11":{color:"#005a8e"},".rainbow-braces .token.token.punctuation.brace-level-4":{color:"#7c00aa"},".rainbow-braces .token.token.punctuation.brace-level-8":{color:"#7c00aa"},".rainbow-braces .token.token.punctuation.brace-level-12":{color:"#7c00aa"},"pre.diff-highlight > code .token.token.deleted:not(.prefix)":{backgroundColor:"#c22f2e1f"},"pre > code.diff-highlight .token.token.deleted:not(.prefix)":{backgroundColor:"#c22f2e1f"},"pre.diff-highlight > code .token.token.inserted:not(.prefix)":{backgroundColor:"#116b001f"},"pre > code.diff-highlight .token.token.inserted:not(.prefix)":{backgroundColor:"#116b001f"},".command-line .command-line-prompt":{borderRight:"1px solid #8da1b97a"},".command-line .command-line-prompt > span:before":{color:"#3c526dda"}}},5206:(a,b,c)=>{Promise.resolve().then(c.bind(c,35790))},5482:(a,b)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.default=void 0,b.default={'code[class*="language-"]':{color:"#a9b7c6",fontFamily:"Consolas, Monaco, 'Andale Mono', monospace",direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none"},'pre[class*="language-"]':{color:"#a9b7c6",fontFamily:"Consolas, Monaco, 'Andale Mono', monospace",direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",padding:"1em",margin:".5em 0",overflow:"auto",background:"#2b2b2b"},'pre[class*="language-"]::-moz-selection':{color:"inherit",background:"rgba(33, 66, 131, .85)"},'pre[class*="language-"] ::-moz-selection':{color:"inherit",background:"rgba(33, 66, 131, .85)"},'code[class*="language-"]::-moz-selection':{color:"inherit",background:"rgba(33, 66, 131, .85)"},'code[class*="language-"] ::-moz-selection':{color:"inherit",background:"rgba(33, 66, 131, .85)"},'pre[class*="language-"]::selection':{color:"inherit",background:"rgba(33, 66, 131, .85)"},'pre[class*="language-"] ::selection':{color:"inherit",background:"rgba(33, 66, 131, .85)"},'code[class*="language-"]::selection':{color:"inherit",background:"rgba(33, 66, 131, .85)"},'code[class*="language-"] ::selection':{color:"inherit",background:"rgba(33, 66, 131, .85)"},':not(pre) > code[class*="language-"]':{background:"#2b2b2b",padding:".1em",borderRadius:".3em"},comment:{color:"#808080"},prolog:{color:"#808080"},cdata:{color:"#808080"},delimiter:{color:"#cc7832"},boolean:{color:"#cc7832"},keyword:{color:"#cc7832"},selector:{color:"#cc7832"},important:{color:"#cc7832"},atrule:{color:"#cc7832"},operator:{color:"#a9b7c6"},punctuation:{color:"#a9b7c6"},"attr-name":{color:"#a9b7c6"},tag:{color:"#e8bf6a"},"tag.punctuation":{color:"#e8bf6a"},doctype:{color:"#e8bf6a"},builtin:{color:"#e8bf6a"},entity:{color:"#6897bb"},number:{color:"#6897bb"},symbol:{color:"#6897bb"},property:{color:"#9876aa"},constant:{color:"#9876aa"},variable:{color:"#9876aa"},string:{color:"#6a8759"},char:{color:"#6a8759"},"attr-value":{color:"#a5c261"},"attr-value.punctuation":{color:"#a5c261"},"attr-value.punctuation:first-child":{color:"#a9b7c6"},url:{color:"#287bde",textDecoration:"underline"},function:{color:"#ffc66d"},regex:{background:"#364135"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"},inserted:{background:"#294436"},deleted:{background:"#484a4a"},"code.language-css .token.property":{color:"#a9b7c6"},"code.language-css .token.property + .token.punctuation":{color:"#a9b7c6"},"code.language-css .token.id":{color:"#ffc66d"},"code.language-css .token.selector > .token.class":{color:"#ffc66d"},"code.language-css .token.selector > .token.attribute":{color:"#ffc66d"},"code.language-css .token.selector > .token.pseudo-class":{color:"#ffc66d"},"code.language-css .token.selector > .token.pseudo-element":{color:"#ffc66d"}}},5827:a=>{"use strict";var b=Object.prototype.hasOwnProperty,c=Object.prototype.toString,d=Object.defineProperty,e=Object.getOwnPropertyDescriptor,f=function(a){return"function"==typeof Array.isArray?Array.isArray(a):"[object Array]"===c.call(a)},g=function(a){if(!a||"[object Object]"!==c.call(a))return!1;var d,e=b.call(a,"constructor"),f=a.constructor&&a.constructor.prototype&&b.call(a.constructor.prototype,"isPrototypeOf");if(a.constructor&&!e&&!f)return!1;for(d in a);return void 0===d||b.call(a,d)},h=function(a,b){d&&"__proto__"===b.name?d(a,b.name,{enumerable:!0,configurable:!0,value:b.newValue,writable:!0}):a[b.name]=b.newValue},i=function(a,c){if("__proto__"===c){if(!b.call(a,c))return;else if(e)return e(a,c).value}return a[c]};a.exports=function a(){var b,c,d,e,j,k,l=arguments[0],m=1,n=arguments.length,o=!1;for("boolean"==typeof l&&(o=l,l=arguments[1]||{},m=2),(null==l||"object"!=typeof l&&"function"!=typeof l)&&(l={});m<n;++m)if(b=arguments[m],null!=b)for(c in b)d=i(l,c),l!==(e=i(b,c))&&(o&&e&&(g(e)||(j=f(e)))?(j?(j=!1,k=d&&f(d)?d:[]):k=d&&g(d)?d:{},h(l,{name:c,newValue:a(o,k,e)})):void 0!==e&&h(l,{name:c,newValue:e}));return l}},8760:(a,b)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.default=void 0,b.default={'code[class*="language-"]':{color:"#f8f8f2",background:"none",textShadow:"0 1px rgba(0, 0, 0, 0.3)",fontFamily:"Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",wordWrap:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none"},'pre[class*="language-"]':{color:"#f8f8f2",background:"#282a36",textShadow:"0 1px rgba(0, 0, 0, 0.3)",fontFamily:"Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",wordWrap:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",padding:"1em",margin:".5em 0",overflow:"auto",borderRadius:"0.3em"},':not(pre) > code[class*="language-"]':{background:"#282a36",padding:".1em",borderRadius:".3em",whiteSpace:"normal"},comment:{color:"#6272a4"},prolog:{color:"#6272a4"},doctype:{color:"#6272a4"},cdata:{color:"#6272a4"},punctuation:{color:"#f8f8f2"},".namespace":{Opacity:".7"},property:{color:"#ff79c6"},tag:{color:"#ff79c6"},constant:{color:"#ff79c6"},symbol:{color:"#ff79c6"},deleted:{color:"#ff79c6"},boolean:{color:"#bd93f9"},number:{color:"#bd93f9"},selector:{color:"#50fa7b"},"attr-name":{color:"#50fa7b"},string:{color:"#50fa7b"},char:{color:"#50fa7b"},builtin:{color:"#50fa7b"},inserted:{color:"#50fa7b"},operator:{color:"#f8f8f2"},entity:{color:"#f8f8f2",cursor:"help"},url:{color:"#f8f8f2"},".language-css .token.string":{color:"#f8f8f2"},".style .token.string":{color:"#f8f8f2"},variable:{color:"#f8f8f2"},atrule:{color:"#f1fa8c"},"attr-value":{color:"#f1fa8c"},function:{color:"#f1fa8c"},"class-name":{color:"#f1fa8c"},keyword:{color:"#8be9fd"},regex:{color:"#ffb86c"},important:{color:"#ffb86c",fontWeight:"bold"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"}}},10017:(a,b)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.default=void 0,b.default={'code[class*="language-"]':{color:"#657b83",fontFamily:"Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace",fontSize:"1em",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",wordWrap:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none"},'pre[class*="language-"]':{color:"#657b83",fontFamily:"Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace",fontSize:"1em",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",wordWrap:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",padding:"1em",margin:".5em 0",overflow:"auto",borderRadius:"0.3em",backgroundColor:"#fdf6e3"},'pre[class*="language-"]::-moz-selection':{background:"#073642"},'pre[class*="language-"] ::-moz-selection':{background:"#073642"},'code[class*="language-"]::-moz-selection':{background:"#073642"},'code[class*="language-"] ::-moz-selection':{background:"#073642"},'pre[class*="language-"]::selection':{background:"#073642"},'pre[class*="language-"] ::selection':{background:"#073642"},'code[class*="language-"]::selection':{background:"#073642"},'code[class*="language-"] ::selection':{background:"#073642"},':not(pre) > code[class*="language-"]':{backgroundColor:"#fdf6e3",padding:".1em",borderRadius:".3em"},comment:{color:"#93a1a1"},prolog:{color:"#93a1a1"},doctype:{color:"#93a1a1"},cdata:{color:"#93a1a1"},punctuation:{color:"#586e75"},namespace:{Opacity:".7"},property:{color:"#268bd2"},tag:{color:"#268bd2"},boolean:{color:"#268bd2"},number:{color:"#268bd2"},constant:{color:"#268bd2"},symbol:{color:"#268bd2"},deleted:{color:"#268bd2"},selector:{color:"#2aa198"},"attr-name":{color:"#2aa198"},string:{color:"#2aa198"},char:{color:"#2aa198"},builtin:{color:"#2aa198"},url:{color:"#2aa198"},inserted:{color:"#2aa198"},entity:{color:"#657b83",background:"#eee8d5",cursor:"help"},atrule:{color:"#859900"},"attr-value":{color:"#859900"},keyword:{color:"#859900"},function:{color:"#b58900"},"class-name":{color:"#b58900"},regex:{color:"#cb4b16"},important:{color:"#cb4b16",fontWeight:"bold"},variable:{color:"#cb4b16"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"}}},10754:(a,b)=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b.default=void 0,b.default={'code[class*="language-"]':{textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",wordWrap:"normal",color:"#c3cee3",background:"#263238",fontFamily:"Roboto Mono, monospace",fontSize:"1em",lineHeight:"1.5em",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none"},'pre[class*="language-"]':{textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",wordWrap:"normal",color:"#c3cee3",background:"#263238",fontFamily:"Roboto Mono, monospace",fontSize:"1em",lineHeight:"1.5em",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",overflow:"auto",position:"relative",margin:"0.5em 0",padding:"1.25em 1em"},'code[class*="language-"]::-moz-selection':{background:"#363636"},'pre[class*="language-"]::-moz-selection':{background:"#363636"},'code[class*="language-"] ::-moz-selection':{background:"#363636"},'pre[class*="language-"] ::-moz-selection':{background:"#363636"},'code[class*="language-"]::selection':{background:"#363636"},'pre[class*="language-"]::selection':{background:"#363636"},'code[class*="language-"] ::selection':{background:"#363636"},'pre[class*="language-"] ::selection':{background:"#363636"},':not(pre) > code[class*="language-"]':{whiteSpace:"normal",borderRadius:"0.2em",padding:"0.1em"},".language-css > code":{color:"#fd9170"},".language-sass > code":{color:"#fd9170"},".language-scss > code":{color:"#fd9170"},'[class*="language-"] .namespace':{Opacity:"0.7"},atrule:{color:"#c792ea"},"attr-name":{color:"#ffcb6b"},"attr-value":{color:"#c3e88d"},attribute:{color:"#c3e88d"},boolean:{color:"#c792ea"},builtin:{color:"#ffcb6b"},cdata:{color:"#80cbc4"},char:{color:"#80cbc4"},class:{color:"#ffcb6b"},"class-name":{color:"#f2ff00"},color:{color:"#f2ff00"},comment:{color:"#546e7a"},constant:{color:"#c792ea"},deleted:{color:"#f07178"},doctype:{color:"#546e7a"},entity:{color:"#f07178"},function:{color:"#c792ea"},hexcode:{color:"#f2ff00"},id:{color:"#c792ea",fontWeight:"bold"},important:{color:"#c792ea",fontWeight:"bold"},inserted:{color:"#80cbc4"},keyword:{color:"#c792ea",fontStyle:"italic"},number:{color:"#fd9170"},operator:{color:"#89ddff"},prolog:{color:"#546e7a"},property:{color:"#80cbc4"},"pseudo-class":{color:"#c3e88d"},"pseudo-element":{color:"#c3e88d"},punctuation:{color:"#89ddff"},regex:{color:"#f2ff00"},selector:{color:"#f07178"},string:{color:"#c3e88d"},symbol:{color:"#c792ea"},tag:{color:"#f07178"},unit:{color:"#f07178"},url:{color:"#fd9170"},variable:{color:"#f07178"}}},10846:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},11642:(a,b,c)=>{Promise.resolve().then(c.t.bind(c,95547,23))},13832:(a,b,c)=>{"use strict";let d,e,f;c.d(b,{AppShell:()=>Ab});var g,h,i,j,k,l,m,n,o,p,q,r={};c.r(r),c.d(r,{boolean:()=>a7,booleanish:()=>a8,commaOrSpaceSeparated:()=>bd,commaSeparated:()=>bc,number:()=>ba,overloadedBoolean:()=>a9,spaceSeparated:()=>bb});var s={};c.r(s),c.d(s,{attentionMarkers:()=>dc,contentInitial:()=>c6,disable:()=>dd,document:()=>c5,flow:()=>c8,flowInitial:()=>c7,insideSpan:()=>db,string:()=>c9,text:()=>da});var t=c(48249),u=c(67484),v=c.n(u),w=c(19099);let x="var(--text-dim)";function y({size:a=14,open:b=!1}){return b?(0,t.jsxs)("svg",{width:a,height:a,viewBox:"0 0 16 16",fill:"none",children:[(0,t.jsx)("path",{d:"M1 4.5A1 1 0 0 1 2 3.5H5.5L7 5h7.5v1H1V4.5Z",fill:x}),(0,t.jsx)("path",{d:"M1 6h14.5L14 13H2L1 6Z",stroke:x,strokeWidth:"1",fill:x,fillOpacity:"0.12"})]}):(0,t.jsx)("svg",{width:a,height:a,viewBox:"0 0 16 16",fill:"none",children:(0,t.jsx)("path",{d:"M1 4.5A1 1 0 0 1 2 3.5H5.5L7 5H14a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V4.5Z",stroke:x,strokeWidth:"1",fill:x,fillOpacity:"0.1"})})}function z({size:a=14}){return(0,t.jsxs)("svg",{width:a,height:a,viewBox:"0 0 16 16",fill:"none",children:[(0,t.jsx)("path",{d:"M3 2h7l3 3v9H3V2Z",stroke:x,strokeWidth:"1",fill:x,fillOpacity:"0.08"}),(0,t.jsx)("path",{d:"M10 2v3h3",stroke:x,strokeWidth:"1",fill:"none",strokeLinejoin:"round"})]})}function A({label:a,size:b=14}){let c=b/14;return(0,t.jsxs)("svg",{width:b,height:b,viewBox:"0 0 14 14",fill:"none",children:[(0,t.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:x,strokeWidth:"0.9",fill:x,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M8.5 1v3h3",stroke:x,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,t.jsx)("text",{x:"7",y:"9.5",textAnchor:"middle",fontSize:3.4*c,fontFamily:"var(--font-mono), monospace",fontWeight:"600",fill:x,letterSpacing:"0",children:a})]})}function B({size:a=14}){return(0,t.jsx)(A,{label:"TS",size:a})}function C({size:a=14}){return(0,t.jsx)(A,{label:"TSX",size:a})}function D({size:a=14}){return(0,t.jsx)(A,{label:"JS",size:a})}function E({size:a=14}){return(0,t.jsx)(A,{label:"JSX",size:a})}function F({size:a=14}){return(0,t.jsx)(A,{label:"PY",size:a})}function G({size:a=14}){return(0,t.jsx)(A,{label:"{}",size:a})}function H({size:a=14}){return(0,t.jsx)(A,{label:"CSS",size:a})}function I({size:a=14}){return(0,t.jsx)(A,{label:"SC",size:a})}function J({size:a=14}){return(0,t.jsx)(A,{label:"HTM",size:a})}function K({size:a=14}){return(0,t.jsxs)("svg",{width:a,height:a,viewBox:"0 0 14 14",fill:"none",children:[(0,t.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:x,strokeWidth:"0.9",fill:x,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M8.5 1v3h3",stroke:x,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M3.5 9.5V7l1.5 1.5L6.5 7v2.5",stroke:x,strokeWidth:"0.9",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),(0,t.jsx)("path",{d:"M8 7v2.5M7 9l1 1.5 1-1.5",stroke:x,strokeWidth:"0.9",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]})}function L({size:a=14}){return(0,t.jsx)(A,{label:"YML",size:a})}function M({size:a=14}){return(0,t.jsx)(A,{label:"TOM",size:a})}function N({size:a=14}){return(0,t.jsxs)("svg",{width:a,height:a,viewBox:"0 0 14 14",fill:"none",children:[(0,t.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:x,strokeWidth:"0.9",fill:x,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M8.5 1v3h3",stroke:x,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M4 7.5l2 1.5-2 1.5",stroke:x,strokeWidth:"0.95",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),(0,t.jsx)("path",{d:"M7.5 10.5h2.5",stroke:x,strokeWidth:"0.95",strokeLinecap:"round"})]})}function O({size:a=14}){return(0,t.jsx)(A,{label:"RS",size:a})}function P({size:a=14}){return(0,t.jsx)(A,{label:"GO",size:a})}function Q({size:a=14}){return(0,t.jsx)(A,{label:"SQL",size:a})}function R({size:a=14}){return(0,t.jsx)(A,{label:"GQL",size:a})}function S({size:a=14}){return(0,t.jsx)(A,{label:"TF",size:a})}function T({size:a=14}){return(0,t.jsxs)("svg",{width:a,height:a,viewBox:"0 0 14 14",fill:"none",children:[(0,t.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:x,strokeWidth:"0.9",fill:x,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M8.5 1v3h3",stroke:x,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,t.jsx)("rect",{x:"3.5",y:"6.5",width:"2",height:"1.5",rx:"0.3",stroke:x,strokeWidth:"0.8"}),(0,t.jsx)("rect",{x:"6",y:"6.5",width:"2",height:"1.5",rx:"0.3",stroke:x,strokeWidth:"0.8"}),(0,t.jsx)("rect",{x:"3.5",y:"8.5",width:"2",height:"1.5",rx:"0.3",stroke:x,strokeWidth:"0.8"})]})}function U({size:a=14}){return(0,t.jsxs)("svg",{width:a,height:a,viewBox:"0 0 14 14",fill:"none",children:[(0,t.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:x,strokeWidth:"0.9",fill:x,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M8.5 1v3h3",stroke:x,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,t.jsx)("circle",{cx:"5.5",cy:"8.5",r:"1.5",stroke:x,strokeWidth:"0.9"}),(0,t.jsx)("path",{d:"M7 8.5h2.5M8.5 8.5v1.5",stroke:x,strokeWidth:"0.9",strokeLinecap:"round"})]})}function V({size:a=14}){return(0,t.jsxs)("svg",{width:a,height:a,viewBox:"0 0 14 14",fill:"none",children:[(0,t.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:x,strokeWidth:"0.9",fill:x,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M8.5 1v3h3",stroke:x,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,t.jsx)("circle",{cx:"5",cy:"6.5",r:"1",stroke:x,strokeWidth:"0.85"}),(0,t.jsx)("circle",{cx:"9",cy:"6.5",r:"1",stroke:x,strokeWidth:"0.85"}),(0,t.jsx)("circle",{cx:"5",cy:"10",r:"1",stroke:x,strokeWidth:"0.85"}),(0,t.jsx)("path",{d:"M5 7.5V9",stroke:x,strokeWidth:"0.85",strokeLinecap:"round"}),(0,t.jsx)("path",{d:"M9 7.5v.5a2 2 0 0 1-2 2H6",stroke:x,strokeWidth:"0.85",strokeLinecap:"round",fill:"none"})]})}function W({size:a=14}){return(0,t.jsxs)("svg",{width:a,height:a,viewBox:"0 0 14 14",fill:"none",children:[(0,t.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:x,strokeWidth:"0.9",fill:x,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M8.5 1v3h3",stroke:x,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,t.jsx)("rect",{x:"4.5",y:"8.5",width:"5",height:"3",rx:"0.6",stroke:x,strokeWidth:"0.9"}),(0,t.jsx)("path",{d:"M5.5 8.5V7.5a1.5 1.5 0 0 1 3 0v1",stroke:x,strokeWidth:"0.9",strokeLinecap:"round",fill:"none"})]})}function X({size:a=14}){return(0,t.jsxs)("svg",{width:a,height:a,viewBox:"0 0 14 14",fill:"none",children:[(0,t.jsx)("path",{d:"M2.5 1h6l3 3v9h-9V1Z",stroke:x,strokeWidth:"0.9",fill:x,fillOpacity:"0.07",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M8.5 1v3h3",stroke:x,strokeWidth:"0.9",fill:"none",strokeLinejoin:"round"}),(0,t.jsx)("circle",{cx:"7",cy:"8.5",r:"1.3",stroke:x,strokeWidth:"0.9"}),(0,t.jsx)("path",{d:"M7 6.5v.7M7 10.3v.7M5 8.5h.7M8.3 8.5H9M5.5 6.9l.5.5M8.5 9.6l-.5-.5M5.5 10.1l.5-.5M8.5 7.4l-.5.5",stroke:x,strokeWidth:"0.8",strokeLinecap:"round"})]})}function Y(a,b=14){let c=a.toLowerCase(),d=c.split(".").pop()??"";if("dockerfile"===c||c.startsWith("dockerfile."))return(0,t.jsx)(T,{size:b});if(".env"===c||c.startsWith(".env."))return(0,t.jsx)(U,{size:b});if(".gitignore"===c||".gitattributes"===c||".gitmodules"===c)return(0,t.jsx)(V,{size:b});if("package-lock.json"===c||"yarn.lock"===c||"bun.lock"===c||"pnpm-lock.yaml"===c||"cargo.lock"===c)return(0,t.jsx)(W,{size:b});if(c.endsWith(".config.ts")||c.endsWith(".config.js")||c.endsWith(".config.mjs")||c.endsWith(".config.cjs")||[".eslintrc",".eslintrc.js",".eslintrc.json",".eslintrc.yml","eslint.config.mjs","eslint.config.js"].includes(c))return(0,t.jsx)(X,{size:b});switch(d){case"ts":return(0,t.jsx)(B,{size:b});case"tsx":return(0,t.jsx)(C,{size:b});case"js":case"mjs":case"cjs":return(0,t.jsx)(D,{size:b});case"jsx":return(0,t.jsx)(E,{size:b});case"py":return(0,t.jsx)(F,{size:b});case"json":case"jsonl":return(0,t.jsx)(G,{size:b});case"css":case"less":return(0,t.jsx)(H,{size:b});case"scss":return(0,t.jsx)(I,{size:b});case"html":case"htm":return(0,t.jsx)(J,{size:b});case"md":case"mdx":return(0,t.jsx)(K,{size:b});case"yaml":case"yml":return(0,t.jsx)(L,{size:b});case"toml":return(0,t.jsx)(M,{size:b});case"sh":case"bash":case"zsh":case"fish":return(0,t.jsx)(N,{size:b});case"rs":return(0,t.jsx)(O,{size:b});case"go":return(0,t.jsx)(P,{size:b});case"sql":return(0,t.jsx)(Q,{size:b});case"graphql":case"gql":return(0,t.jsx)(R,{size:b});case"tf":case"hcl":return(0,t.jsx)(S,{size:b});case"lock":return(0,t.jsx)(W,{size:b});default:return(0,t.jsx)(z,{size:b})}}function Z(a){return/^[a-zA-Z]:[\\/]/.test(a)||a.startsWith("\\\\")?a.replace(/\\/g,"/"):a}function $(a){return Z(a).split("/").filter(Boolean).map(encodeURIComponent).join("/")}function _(a){let b=Z(a).replace(/\/+$/,"");return b.split("/").pop()??b}function aa(a,b){if(!b)return a;let c=Z(a),d=Z(b).replace(/\/$/,"");return c.startsWith(d+"/")?c.slice(d.length+1):a}async function ab(a){let b=$(a),c=await fetch(`/api/files/${b}?type=list`);return c.ok?((await c.json()).entries??[]).map(b=>{var c;return{name:b.name,fullPath:(c=b.name,`${Z(a).replace(/\/$/,"")}/${c}`),isDir:b.isDir,size:b.size,children:b.isDir?[]:void 0,loaded:!b.isDir}}):[]}function ac(a,b){let c=b.trim().toLowerCase();return!!(!c||a.name.toLowerCase().includes(c))||(a.children??[]).some(a=>ac(a,c))}function ad(a){return!!Array.from(a.types).includes("Files")||Array.from(a.items).some(a=>"file"===a.kind)}function ae(a){return Array.from(a.files).filter(a=>!!a.name)}function af(a,b){return a===b?".":aa(a,b)}function ag({node:a,depth:b,cwd:c,onOpenFile:d,onExploreFile:e,onAtMention:f,expandedPaths:g,onToggleExpanded:h,onUploadFiles:i,uploadTargetPath:j,refreshKey:k,searchQuery:l}){let m=!!l?.trim(),n=m?a.isDir:g.has(a.fullPath),[o,p]=(0,u.useState)(a.children??[]),[q,r]=(0,u.useState)(a.loaded??!1),[s,v]=(0,u.useState)(!1),[w,x]=(0,u.useState)(!1),[z,A]=(0,u.useState)(!1),B=a.isDir&&(z||j===a.fullPath),C=!!f&&w,D=!!e&&w&&!a.isDir&&a.name.toLowerCase().endsWith(".h5ad"),E=C||D,F=m?o.filter(a=>ac(a,l??"")):o,G=(0,u.useCallback)(async(b=!1)=>{if(!q||b){v(!0);try{let b=await ab(a.fullPath);p(b),r(!0)}catch{}finally{v(!1)}}},[q,a.fullPath]);(0,u.useRef)(q);let H=(0,u.useCallback)(()=>{if(a.isDir){let b=!n;h(a.fullPath,b),b&&!q&&G()}else d(a.fullPath,a.name)},[a.isDir,a.fullPath,a.name,q,n,G,d,h]),I=(0,u.useCallback)(b=>{a.isDir&&ad(b.dataTransfer)&&(b.preventDefault(),b.stopPropagation(),b.dataTransfer.dropEffect="copy",A(!0))},[a.isDir]),J=(0,u.useCallback)(b=>{a.isDir&&ad(b.dataTransfer)&&(b.preventDefault(),b.stopPropagation(),b.dataTransfer.dropEffect="copy")},[a.isDir]),K=(0,u.useCallback)(b=>{if(!a.isDir)return;let c=b.relatedTarget;c instanceof Node&&b.currentTarget.contains(c)||A(!1)},[a.isDir]),L=(0,u.useCallback)(b=>{if(!a.isDir||!ad(b.dataTransfer))return;b.preventDefault(),b.stopPropagation(),A(!1);let c=ae(b.dataTransfer);c.length>0&&(i(c,a.fullPath),n||h(a.fullPath,!0),q||G())},[G,q,a.fullPath,a.isDir,h,i,n]);return(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{onClick:H,onMouseEnter:()=>x(!0),onMouseLeave:()=>x(!1),onDragEnter:I,onDragOver:J,onDragLeave:K,onDrop:L,style:{position:"relative",display:"flex",alignItems:"center",gap:4,paddingLeft:8+14*b,paddingRight:E?C&&D?146:82:8,height:24,cursor:"pointer",background:B?"rgba(37,99,235,0.14)":w?"var(--bg-hover)":"transparent",outline:B?"1px solid rgba(37,99,235,0.42)":"none",outlineOffset:-1,borderRadius:4,userSelect:"none",transition:"background 0.12s, outline-color 0.12s"},children:[a.isDir&&(0,t.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--text-dim)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,transform:n?"rotate(90deg)":"none",transition:"transform 0.1s"},children:(0,t.jsx)("polyline",{points:"3 2 7 5 3 8"})}),!a.isDir&&(0,t.jsx)("span",{style:{width:10,flexShrink:0}}),(0,t.jsx)("span",{style:{flexShrink:0,display:"flex",alignItems:"center"},children:a.isDir?(0,t.jsx)(y,{size:14,open:n}):Y(a.name,14)}),(0,t.jsx)("span",{style:{fontSize:12,color:"var(--text)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},title:a.fullPath,children:a.name}),s&&(0,t.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-dim)",strokeWidth:"2",strokeLinecap:"round",children:(0,t.jsx)("path",{d:"M12 2v4M12 18v4M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83M2 12h4M18 12h4"})}),E&&(0,t.jsxs)("div",{style:{position:"absolute",right:4,top:"50%",transform:"translateY(-50%)",display:"flex",alignItems:"center",gap:4},children:[D&&(0,t.jsxs)("button",{onClick:b=>{b.stopPropagation(),e?.(a.fullPath,a.name)},title:"Explore H5AD",style:{display:"flex",alignItems:"center",justifyContent:"center",gap:4,padding:"0 8px",height:20,background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:4,color:"var(--accent)",cursor:"pointer",fontSize:11,fontWeight:600,whiteSpace:"nowrap"},children:[(0,t.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.1",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("circle",{cx:"11",cy:"11",r:"7"}),(0,t.jsx)("path",{d:"M16 16l4 4"}),(0,t.jsx)("path",{d:"M8.5 11h5"}),(0,t.jsx)("path",{d:"M11 8.5v5"})]}),"@explore"]}),C&&(0,t.jsxs)("button",{onClick:b=>{b.stopPropagation(),f?.(aa(a.fullPath,c))},title:"Insert path into chat",style:{display:"flex",alignItems:"center",justifyContent:"center",gap:4,padding:"0 8px",height:20,background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:4,color:"var(--accent)",cursor:"pointer",fontSize:11,fontWeight:600,whiteSpace:"nowrap"},children:[(0,t.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("circle",{cx:"12",cy:"12",r:"4"}),(0,t.jsx)("path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8"})]}),"@mention"]})]})]}),a.isDir&&n&&(0,t.jsxs)("div",{children:[F.map(a=>(0,t.jsx)(ag,{node:a,depth:b+1,cwd:c,onOpenFile:d,onExploreFile:e,onAtMention:f,expandedPaths:g,onToggleExpanded:h,onUploadFiles:i,uploadTargetPath:j,refreshKey:k,searchQuery:l},a.fullPath)),0===F.length&&q&&!m&&(0,t.jsx)("div",{style:{paddingLeft:8+(b+1)*14,fontSize:11,color:"var(--text-dim)",height:22,display:"flex",alignItems:"center"},children:"empty"})]})]})}function ah({cwd:a,onOpenFile:b,onExploreFile:c,refreshKey:d,onAtMention:e,searchQuery:f="",onSearchChange:g}){let[h,i]=(0,u.useState)([]),[j,k]=(0,u.useState)(!0),[l,m]=(0,u.useState)(null),[n,o]=(0,u.useState)(new Set),[p,q]=(0,u.useState)(!1),[r,s]=(0,u.useState)(null),[v,w]=(0,u.useState)(null);(0,u.useRef)(null);let x=(0,u.useRef)(null),y=(0,u.useRef)(0),z=(0,u.useCallback)((a,b)=>(k(b),m(null),ab(a).then(a=>i(a)).catch(a=>m(String(a))).finally(()=>k(!1))),[]),A=(0,u.useCallback)((a,b)=>{o(c=>{let d=new Set(c);return b?d.add(a):d.delete(a),d})},[]),B=(0,u.useCallback)(()=>{z(a,0===h.length)},[a,h.length,z]),C=(0,u.useCallback)(()=>{x.current&&clearTimeout(x.current),x.current=setTimeout(()=>w(null),5e3)},[]),D=(0,u.useCallback)((b,c)=>{if(0===b.length)return;y.current=0,q(!1),x.current&&clearTimeout(x.current);let d=b.reduce((a,b)=>a+b.size,0),e=af(c,a);s(c),w({phase:"uploading",targetPath:c,fileCount:b.length,loaded:0,total:d,message:`Uploading ${b.length} file${1===b.length?"":"s"} to ${e}`});let f=new FormData;b.forEach(a=>f.append("files",a,a.name));let g=new XMLHttpRequest,h=$(c);g.open("POST",`/api/files/${h}?type=upload`),g.upload.onprogress=a=>{a.lengthComputable&&w(b=>b?{...b,loaded:a.loaded,total:a.total}:b)},g.onload=()=>{s(null);let a={};try{a=JSON.parse(g.responseText)}catch{a={}}if(g.status>=200&&g.status<300){let f=a.uploaded??[],g=a.failed??[],h=[...f.filter(a=>a.name!==a.originalName).slice(0,3).map(a=>`${a.originalName} saved as ${a.name}`),...g.slice(0,3).map(a=>`${a.name}: ${a.error}`)];w({phase:g.length>0?"warning":"success",targetPath:c,fileCount:b.length,loaded:d,total:d,message:g.length>0?`Uploaded ${f.length}, ${g.length} failed`:`Uploaded ${f.length} file${1===f.length?"":"s"} to ${e}`,details:h}),B(),C()}else{let e=a.error??`Upload failed (HTTP ${g.status})`;w({phase:(g.status,"error"),targetPath:c,fileCount:b.length,loaded:0,total:d,message:e,details:403===g.status?["Check directory write permission or project access."]:void 0}),C()}},g.onerror=()=>{s(null),w({phase:"error",targetPath:c,fileCount:b.length,loaded:0,total:d,message:"Upload failed due to a network error"}),C()},g.onabort=()=>{s(null),w({phase:"error",targetPath:c,fileCount:b.length,loaded:0,total:d,message:"Upload canceled"}),C()},g.send(f)},[a,B,C]),E=(0,u.useCallback)(a=>{ad(a.dataTransfer)&&(a.preventDefault(),y.current+=1,q(!0))},[]),F=(0,u.useCallback)(a=>{ad(a.dataTransfer)&&(a.preventDefault(),a.dataTransfer.dropEffect="copy")},[]),G=(0,u.useCallback)(()=>{y.current-=1,y.current<=0&&(y.current=0,q(!1))},[]),H=(0,u.useCallback)(b=>{if(!ad(b.dataTransfer))return;b.preventDefault(),y.current=0,q(!1);let c=ae(b.dataTransfer);c.length>0&&D(c,a)},[a,D]),I=f.trim()?h.filter(a=>ac(a,f)):h,J=f.trim().length>0;return j?(0,t.jsx)(ai,{cwd:a,isDraggingFiles:p,uploadState:v,onDragEnter:E,onDragOver:F,onDragLeave:G,onDrop:H,children:(0,t.jsx)("div",{style:{padding:"8px 12px",fontSize:11,color:"var(--text-dim)"},children:"Loading files..."})}):l?(0,t.jsx)(ai,{cwd:a,isDraggingFiles:p,uploadState:v,onDragEnter:E,onDragOver:F,onDragLeave:G,onDrop:H,children:(0,t.jsx)("div",{style:{padding:"8px 12px",fontSize:11,color:"#f87171"},children:l})}):(0,t.jsx)(ai,{cwd:a,isDraggingFiles:p,uploadState:v,onDragEnter:E,onDragOver:F,onDragLeave:G,onDrop:H,children:(0,t.jsxs)("div",{style:{padding:"2px 4px"},children:[I.map(g=>(0,t.jsx)(ag,{node:g,depth:0,cwd:a,onOpenFile:b,onExploreFile:c,onAtMention:e,expandedPaths:n,onToggleExpanded:A,onUploadFiles:D,uploadTargetPath:r,refreshKey:d,searchQuery:f},g.fullPath)),0===I.length&&(0,t.jsx)("div",{style:{padding:"8px 12px",fontSize:11,color:"var(--text-dim)"},children:J?"No matching files":"No files found"})]})})}function ai({cwd:a,isDraggingFiles:b,uploadState:c,onDragEnter:d,onDragOver:e,onDragLeave:f,onDrop:g,children:h}){let i=c&&c.total>0?Math.max(0,Math.min(100,Math.round(c.loaded/c.total*100))):c?.phase==="uploading"?8:100,j=c?.phase==="success"?"#22c55e":c?.phase==="warning"?"#f59e0b":c?.phase==="error"?"#ef4444":"var(--accent)";return(0,t.jsxs)("div",{onDragEnter:d,onDragOver:e,onDragLeave:f,onDrop:g,style:{position:"relative",display:"flex",flexDirection:"column",minHeight:"100%",outline:b?"1px solid rgba(37,99,235,0.45)":"none",outlineOffset:-1,background:b?"rgba(37,99,235,0.04)":void 0,transition:"background 0.12s, outline-color 0.12s"},children:[(0,t.jsx)("div",{style:{flex:1,minHeight:0},children:h}),b&&(0,t.jsx)("div",{style:{pointerEvents:"none",position:"absolute",inset:6,top:42,border:"1px dashed rgba(37,99,235,0.62)",borderRadius:8,background:"rgba(37,99,235,0.07)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:2},children:(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"7px 10px",border:"1px solid var(--border)",borderRadius:6,background:"var(--bg-panel)",color:"var(--text)",fontSize:12,boxShadow:"0 8px 24px rgba(0,0,0,0.16)"},children:[(0,t.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,t.jsx)("polyline",{points:"17 8 12 3 7 8"}),(0,t.jsx)("line",{x1:"12",y1:"3",x2:"12",y2:"15"})]}),"Drop to upload into ",af(a,a)]})}),c&&(0,t.jsxs)("div",{style:{margin:"6px",padding:"7px 8px",border:"1px solid var(--border)",borderRadius:6,background:"var(--bg-panel)",boxShadow:"0 8px 24px rgba(0,0,0,0.12)"},children:[(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:7,minWidth:0},children:[(0,t.jsx)("span",{style:{width:8,height:8,borderRadius:999,background:j,flexShrink:0}}),(0,t.jsx)("span",{title:c.message,style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--text)",fontSize:11,fontWeight:600},children:c.message}),(0,t.jsx)("span",{style:{color:"var(--text-dim)",fontSize:10,flexShrink:0},children:"uploading"===c.phase?`${i}%`:function(a){if(!Number.isFinite(a)||a<=0)return"0 B";let b=["B","KB","MB","GB"],c=a,d=0;for(;c>=1024&&d<b.length-1;)c/=1024,d+=1;return`${c>=10||0===d?Math.round(c):c.toFixed(1)} ${b[d]}`}(c.total)})]}),(0,t.jsx)("div",{style:{marginTop:6,height:3,borderRadius:999,background:"var(--bg)",overflow:"hidden"},children:(0,t.jsx)("div",{style:{width:`${i}%`,height:"100%",borderRadius:999,background:j,transition:"width 0.15s ease"}})}),c.details&&c.details.length>0&&(0,t.jsx)("div",{style:{marginTop:5,display:"grid",gap:2},children:c.details.map(a=>(0,t.jsx)("div",{title:a,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--text-dim)",fontSize:10},children:a},a))})]})]})}function aj(a,b){let c=b&&a.startsWith(b)?"~"+a.slice(b.length):a,d=c.includes("/")?"/":"\\",e=c.split(d).filter(Boolean);return e.length<=2?c:"..."+d+e.slice(-2).join(d)}function ak(a){let b=new Date(a);return Number.isNaN(b.getTime())?"":b.toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function al({open:a,cwd:b,homeDir:c,onClose:d,onSelectSession:e}){let[f,g]=(0,u.useState)(""),[h,i]=(0,u.useState)("current"),[j,k]=(0,u.useState)([]),[l,m]=(0,u.useState)(!1),[n,o]=(0,u.useState)(null),[p,q]=(0,u.useState)(!1),r=(0,u.useRef)(null);if(!a)return null;let s=f.trim(),v=j.reduce((a,b)=>a+b.matches.length,0);return(0,t.jsx)("div",{role:"dialog","aria-modal":"true","aria-label":"Search conversation history",style:{position:"fixed",inset:0,zIndex:500,display:"flex",alignItems:"flex-start",justifyContent:"center",padding:"8vh 16px 16px",background:"rgba(0,0,0,0.28)"},onMouseDown:a=>{a.target===a.currentTarget&&d()},children:(0,t.jsxs)("div",{style:{width:"min(760px, 100%)",maxHeight:"78vh",display:"flex",flexDirection:"column",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:10,boxShadow:"0 16px 48px rgba(0,0,0,0.24)",overflow:"hidden"},children:[(0,t.jsxs)("div",{style:{padding:12,borderBottom:"1px solid var(--border)"},children:[(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,flex:1,minWidth:0,background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:8,padding:"0 10px"},children:[(0,t.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 16 16",fill:"none",stroke:"var(--text-dim)",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,t.jsx)("circle",{cx:"7",cy:"7",r:"4.5"}),(0,t.jsx)("path",{d:"M10.5 10.5 13.5 13.5"})]}),(0,t.jsx)("input",{ref:r,value:f,onChange:a=>g(a.target.value),placeholder:"Search conversation history...",style:{flex:1,minWidth:0,height:38,background:"transparent",border:"none",outline:"none",color:"var(--text)",fontSize:14}})]}),(0,t.jsx)("button",{type:"button",onClick:d,title:"Close",style:{width:34,height:34,display:"inline-flex",alignItems:"center",justifyContent:"center",background:"none",border:"none",borderRadius:7,color:"var(--text-dim)",cursor:"pointer"},onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="var(--text)"},onMouseLeave:a=>{a.currentTarget.style.background="none",a.currentTarget.style.color="var(--text-dim)"},children:(0,t.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[(0,t.jsx)("path",{d:"M4 4 12 12"}),(0,t.jsx)("path",{d:"M12 4 4 12"})]})})]}),(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:10},children:[(0,t.jsx)("div",{style:{display:"inline-flex",padding:2,background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:7},children:[{value:"current",label:"Current project",disabled:!b},{value:"all",label:"All history",disabled:!1}].map(a=>(0,t.jsx)("button",{type:"button",disabled:a.disabled,onClick:()=>i(a.value),style:{height:24,padding:"0 9px",background:h===a.value?"var(--bg-selected)":"transparent",border:"none",borderRadius:5,color:a.disabled?"var(--text-dim)":h===a.value?"var(--text)":"var(--text-muted)",cursor:a.disabled?"not-allowed":"pointer",fontSize:11,fontWeight:500},children:a.label},a.value))}),(0,t.jsx)("div",{style:{flex:1,minWidth:0,color:"var(--text-dim)",fontSize:11,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:"current"===h&&b?aj(b,c):"Searching every saved session"})]})]}),(0,t.jsxs)("div",{style:{flex:1,overflowY:"auto",minHeight:180},children:[s.length<2&&(0,t.jsx)("div",{style:{padding:28,textAlign:"center",color:"var(--text-muted)",fontSize:13},children:"Type at least 2 characters to search saved conversations."}),s.length>=2&&l&&0===j.length&&(0,t.jsx)("div",{style:{padding:28,textAlign:"center",color:"var(--text-muted)",fontSize:13},children:"Searching..."}),n&&(0,t.jsx)("div",{style:{padding:18,color:"#ef4444",fontSize:13},children:n}),s.length>=2&&!l&&!n&&0===j.length&&(0,t.jsx)("div",{style:{padding:28,textAlign:"center",color:"var(--text-muted)",fontSize:13},children:"No matching conversations found."}),j.map(a=>(0,t.jsxs)("div",{style:{borderBottom:"1px solid var(--border)"},children:[(0,t.jsxs)("button",{type:"button",onClick:()=>{e(a.session),d()},style:{width:"100%",display:"flex",alignItems:"center",gap:10,padding:"10px 12px",background:"var(--bg-panel)",border:"none",borderBottom:"1px solid var(--border)",color:"var(--text)",cursor:"pointer",textAlign:"left"},onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:a=>{a.currentTarget.style.background="var(--bg-panel)"},children:[(0,t.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,minWidth:0},children:[(0,t.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:13,fontWeight:600},children:a.session.name||a.session.firstMessage||"(no messages)"}),(0,t.jsx)("span",{style:{flexShrink:0,color:"var(--text-dim)",fontSize:11},children:ak(a.session.modified)})]}),(0,t.jsx)("div",{style:{marginTop:2,color:"var(--text-dim)",fontSize:11,fontFamily:"var(--font-mono)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:aj(a.session.cwd,c)})]}),a.matchCount>a.matches.length&&(0,t.jsxs)("span",{style:{flexShrink:0,color:"var(--text-muted)",fontSize:11},children:[a.matchCount," matches"]})]}),a.matches.map(b=>(0,t.jsxs)("button",{type:"button",onClick:()=>{e(a.session),d()},style:{width:"100%",padding:"9px 14px 9px 28px",background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",textAlign:"left"},onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-hover)"},onMouseLeave:a=>{a.currentTarget.style.background="none"},children:[(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:3},children:[(0,t.jsx)("span",{style:{minWidth:54,color:"user"===b.role?"var(--accent)":"var(--text-dim)",fontSize:11,fontWeight:600,textTransform:"capitalize"},children:b.role}),(0,t.jsx)("span",{style:{color:"var(--text-dim)",fontSize:11},children:ak(b.timestamp)})]}),(0,t.jsx)("div",{style:{fontSize:12,lineHeight:1.45,color:"var(--text-muted)"},children:function(a,b){let c=b.trim();if(!c)return a;let d=a.toLowerCase().indexOf(c.toLowerCase());return d<0?a:(0,t.jsxs)(t.Fragment,{children:[a.slice(0,d),(0,t.jsx)("mark",{style:{background:"rgba(37,99,235,0.16)",color:"var(--text)",borderRadius:3,padding:"0 2px"},children:a.slice(d,d+c.length)}),a.slice(d+c.length)]})}(b.snippet,s)})]},b.entryId))]},a.session.id))]}),(0,t.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",padding:"8px 12px",borderTop:"1px solid var(--border)",color:"var(--text-dim)",fontSize:11},children:[(0,t.jsx)("span",{children:v>0?`${v}${p?"+":""} results`:"Esc to close"}),l&&j.length>0&&(0,t.jsx)("span",{children:"Updating..."})]})]})})}function am({open:a,initialPath:b,onClose:c,onSelect:d}){let[e,f]=(0,u.useState)(""),[g,h]=(0,u.useState)(null),[i,j]=(0,u.useState)([]),[k,l]=(0,u.useState)([]),[m,n]=(0,u.useState)(""),[o,p]=(0,u.useState)(!1),[q,r]=(0,u.useState)(null),s=(0,u.useCallback)(async a=>{p(!0),r(null);try{let b=a?`/api/projects/browse?dir=${encodeURIComponent(a)}`:"/api/projects/browse",c=await fetch(b),d=await c.json();if(!c.ok||d.error)throw Error(d.error??`HTTP ${c.status}`);f(d.current??""),h(d.parent??null),j(d.directories??[]),l(d.drives??[]),n(d.current??"")}catch(a){r(a instanceof Error?a.message:String(a))}finally{p(!1)}},[]);return a?(0,t.jsx)("div",{onMouseDown:a=>{a.target===a.currentTarget&&c()},style:{position:"fixed",inset:0,zIndex:1200,display:"flex",alignItems:"center",justifyContent:"center",padding:18,background:"rgba(0,0,0,0.34)"},children:(0,t.jsxs)("div",{style:{width:"min(560px, 100%)",maxHeight:"min(720px, 88dvh)",display:"flex",flexDirection:"column",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:10,boxShadow:"0 12px 40px rgba(0,0,0,0.25)",overflow:"hidden"},children:[(0,t.jsxs)("div",{style:{height:48,padding:"0 14px",display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid var(--border)"},children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{style:{color:"var(--text)",fontSize:14,fontWeight:750},children:"Select project path"}),(0,t.jsx)("div",{style:{marginTop:2,color:"var(--text-dim)",fontSize:11},children:"Server filesystem"})]}),(0,t.jsx)("button",{type:"button",onClick:c,"aria-label":"Close",title:"Close",style:{width:30,height:30,border:"none",borderRadius:6,background:"transparent",color:"var(--text-muted)",cursor:"pointer",fontSize:20,lineHeight:1},onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="var(--text)"},onMouseLeave:a=>{a.currentTarget.style.background="transparent",a.currentTarget.style.color="var(--text-muted)"},children:"x"})]}),(0,t.jsx)("div",{style:{padding:12,borderBottom:"1px solid var(--border)"},children:(0,t.jsxs)("form",{onSubmit:a=>{a.preventDefault(),m.trim()&&s(m.trim())},style:{display:"flex",gap:8},children:[(0,t.jsx)("input",{value:m,onChange:a=>n(a.target.value),placeholder:"/path/to/project",style:{flex:1,minWidth:0,height:32,padding:"0 10px",border:"1px solid var(--border)",borderRadius:6,background:"var(--bg-panel)",color:"var(--text)",fontFamily:"var(--font-mono)",fontSize:12,outline:"none"}}),(0,t.jsx)("button",{type:"submit",style:{height:32,padding:"0 11px",border:"1px solid var(--border)",borderRadius:6,background:"var(--bg-panel)",color:"var(--text-muted)",cursor:"pointer",fontSize:12},children:"Go"})]})}),(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px",borderBottom:"1px solid var(--border)",background:"var(--bg-panel)"},children:[(0,t.jsx)("button",{type:"button",onClick:()=>g&&void s(g),disabled:!g,style:{width:28,height:28,border:"1px solid var(--border)",borderRadius:6,background:g?"var(--bg)":"transparent",color:g?"var(--text-muted)":"var(--text-dim)",cursor:g?"pointer":"default",padding:0},title:"Up",children:(0,t.jsx)("svg",{width:"13",height:"13",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:(0,t.jsx)("polyline",{points:"2 6.5 5 3.5 8 6.5"})})}),k.length>0&&(0,t.jsxs)("select",{value:k.find(a=>e.toLowerCase().startsWith(a.toLowerCase()))??"",onChange:a=>{a.target.value&&s(a.target.value)},style:{height:28,border:"1px solid var(--border)",borderRadius:6,background:"var(--bg)",color:"var(--text-muted)",fontSize:12},children:[(0,t.jsx)("option",{value:"",children:"Drive"}),k.map(a=>(0,t.jsx)("option",{value:a,children:a},a))]}),(0,t.jsx)("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--text-dim)",fontFamily:"var(--font-mono)",fontSize:11},title:e,children:e})]}),(0,t.jsx)("div",{style:{flex:1,minHeight:220,maxHeight:360,overflowY:"auto",padding:6},children:o?(0,t.jsx)("div",{style:{padding:18,color:"var(--text-muted)",fontSize:12},children:"Loading..."}):q?(0,t.jsx)("div",{style:{padding:18,color:"#f87171",fontSize:12},children:q}):0===i.length?(0,t.jsx)("div",{style:{padding:18,color:"var(--text-muted)",fontSize:12},children:"No subdirectories"}):i.map(a=>(0,t.jsxs)("button",{type:"button",onClick:()=>void s(a.path),style:{width:"100%",display:"flex",alignItems:"center",gap:9,padding:"8px 9px",border:"none",borderRadius:6,background:"transparent",color:"var(--text-muted)",cursor:"pointer",textAlign:"left",fontSize:12},onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="var(--text)"},onMouseLeave:a=>{a.currentTarget.style.background="transparent",a.currentTarget.style.color="var(--text-muted)"},title:a.path,children:[(0,t.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--accent)",flexShrink:0},children:(0,t.jsx)("path",{d:"M3 6.5A2.5 2.5 0 0 1 5.5 4H10l2 2.5h6.5A2.5 2.5 0 0 1 21 9v8.5A2.5 2.5 0 0 1 18.5 20h-13A2.5 2.5 0 0 1 3 17.5v-11Z"})}),(0,t.jsx)("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a.name}),(0,t.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--text-dim)",flexShrink:0},children:(0,t.jsx)("polyline",{points:"3.5 2 6.5 5 3.5 8"})})]},a.path))}),(0,t.jsxs)("div",{style:{padding:12,borderTop:"1px solid var(--border)",display:"flex",alignItems:"center",justifyContent:"space-between",gap:10},children:[(0,t.jsx)("div",{style:{minWidth:0,color:"var(--text-dim)",fontFamily:"var(--font-mono)",fontSize:11,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:e,children:e}),(0,t.jsxs)("div",{style:{display:"flex",gap:7,flexShrink:0},children:[(0,t.jsx)("button",{type:"button",onClick:c,style:{height:32,padding:"0 12px",border:"1px solid var(--border)",borderRadius:6,background:"var(--bg-panel)",color:"var(--text-muted)",cursor:"pointer",fontSize:12},children:"Cancel"}),(0,t.jsx)("button",{type:"button",onClick:()=>e&&d(e),disabled:!e,style:{height:32,padding:"0 12px",border:"none",borderRadius:6,background:e?"var(--accent)":"var(--bg-hover)",color:e?"#fff":"var(--text-dim)",cursor:e?"pointer":"default",fontSize:12,fontWeight:650},children:"Select"})]})]})]})}):null}let an="AnnoVibe";async function ao(a,b){let c=`${a}: HTTP ${b.status}`;try{let d=await b.json();return"string"==typeof d.error&&d.error?`${a}: ${d.error}`:c}catch{return c}}function ap(a){let b=new Date(a),c=new Date().getTime()-b.getTime(),d=Math.floor(c/6e4),e=Math.floor(c/36e5),f=Math.floor(c/864e5);return d<1?"just now":d<60?`${d}m ago`:e<24?`${e}h ago`:f<7?`${f}d ago`:b.toLocaleDateString()}function aq(a,b){let c=b&&a.startsWith(b)?"~"+a.slice(b.length):a,d=c.includes("/")?"/":"\\",e=c.split(d).filter(Boolean);return e.length<=2?c:"…/"+e.slice(-2).join(d)}function ar(a,b){if(!a)return"No Project";let c=a.replace(/[\\/]+$/,""),d=c.includes("/")?"/":"\\";return c.split(d).filter(Boolean).pop()||aq(a,b)}function as(a){return a.lastAccessed??a.created??""}function at(){let[a,b]=(0,u.useState)(!1),[c,d]=(0,u.useState)(!1),e=(0,u.useRef)(null),f=function(a){let[b,c]=(0,u.useState)(a);return(0,u.useRef)(null),(0,u.useRef)(0),b}(a?"v0.8.24":an),g=(0,u.useCallback)(a=>{b(a),d(!0),setTimeout(()=>d(!1),(a?6:8)*4*(1e3/60)+100)},[]),h=(0,u.useCallback)(()=>{e.current&&clearTimeout(e.current);let b=!a;g(b),b&&(e.current=setTimeout(()=>g(!1),3e3))},[a,g]);return(0,t.jsx)("button",{onClick:h,style:{background:"none",border:"none",padding:0,cursor:"default",fontWeight:700,fontSize:15,letterSpacing:"-0.01em",color:a?"var(--accent)":"var(--text)",fontFamily:"var(--font-mono)",minWidth:"9ch"},children:f})}function au({selectedSessionId:a,onSelectSession:b,onNewSession:c,initialSessionId:d,onInitialRestoreDone:e,refreshKey:f,onSessionDeleted:g,selectedCwd:h,onCwdChange:i,onOpenFile:j,onExploreFile:k,explorerRefreshKey:l,onAtMention:m}){let[n,o]=(0,u.useState)([]),[p,q]=(0,u.useState)([]),[r,s]=(0,u.useState)(!0),[v,w]=(0,u.useState)(null),[x,y]=(0,u.useState)(null),[z,A]=(0,u.useState)(""),[B,C]=(0,u.useState)(!1),[D,E]=(0,u.useState)(null),[F,G]=(0,u.useState)(!1),[H,I]=(0,u.useState)(!1),[J,K]=(0,u.useState)(!1),[L,M]=(0,u.useState)(!0),N=(0,u.useRef)(!1),O=(0,u.useRef)(!1),P=(0,u.useRef)(null),[Q,R]=(0,u.useState)(!0),[S,T]=(0,u.useState)(0),[U,V]=(0,u.useState)(""),W=(0,u.useCallback)(async(a=!1)=>{try{a&&(w(null),s(!0));let[b,c]=await Promise.all([fetch("/api/sessions"),fetch("/api/projects")]);if(!b.ok)throw Error(await ao("sessions",b));if(!c.ok)throw Error(await ao("projects",c));let d=await b.json(),e=await c.json();o(d.sessions),q(e.projects),w(null)}catch(a){w(String(a))}finally{a&&s(!1)}},[]),X=(0,u.useCallback)(()=>{M(a=>!a),C(!1),E(null),W(!0)},[W]);(0,u.useRef)(!1);let Y=(0,u.useRef)(!1),Z=(0,u.useCallback)(async(a,b=!1)=>{try{let c=await fetch("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,create:b})}),d=await c.json();if(!c.ok||d.error)return E(d.error??`HTTP ${c.status}`),!1;return W(!1),!0}catch(a){return E(a instanceof Error?a.message:String(a)),!1}},[W]),$=(0,u.useCallback)(a=>{fetch("/api/projects",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:a,touch:!0})}).catch(()=>{})},[]),_=(0,u.useCallback)(a=>{O.current=!0,y(a),K(!1),R(!0),V(""),T(a=>a+1),i?.(a),$(a)},[i,$]),aa=(0,u.useCallback)(async()=>{try{let a=await fetch("/api/default-cwd",{method:"POST"}),b=await a.json();b.cwd&&(await Z(b.cwd,!1),_(b.cwd),C(!1))}catch{}},[_,Z]),ab=(0,u.useCallback)(async a=>{await Z(a,!1)&&(_(a),G(!1),E(null),C(!1))},[_,Z]),ac=h??x,ad=(0,u.useCallback)(a=>{if(!a)return void C(!0);let b="function"==typeof crypto.randomUUID?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}-${Math.random().toString(36).slice(2)}`;c?.(b,a)},[c]),ae=(0,u.useCallback)(()=>{ad(ac)},[ad,ac]),af=(0,u.useMemo)(()=>[...ac&&!p.some(a=>a.cwd===ac)?[{cwd:ac,displayName:ar(ac,z),chatCount:n.filter(a=>a.cwd===ac).length,lastAccessed:null,created:null,exists:!0,source:"manual"}]:[],...p].sort((a,b)=>{if(ac&&a.cwd===ac)return -1;if(ac&&b.cwd===ac)return 1;let c=as(a),d=as(b);return c!==d?d.localeCompare(c):a.displayName.localeCompare(b.displayName)}),[n,ac,z,p]),ag=(0,u.useMemo)(()=>n.filter(a=>a.cwd===ac).sort((a,b)=>b.modified.localeCompare(a.modified)),[n,ac]),ai=ac?af.find(a=>a.cwd===ac):void 0,aj=ac?af.find(a=>a.cwd===ac)?.displayName||ar(ac,z):"Open project...",ak=ai?.chatCount??ag.length,an=(0,u.useMemo)(()=>(function(a){let b=new Map;for(let c of a)b.set(c.id,{session:c,children:[]});let c=new Map;for(let b of a)b.parentSessionId&&c.set(b.id,b.parentSessionId);let d=[];for(let a of b.values()){let e=function(a){let d=c.get(a),e=new Set;for(;d&&!e.has(d);){if(e.add(d),b.has(d))return d;d=c.get(d)}return null}(a.session.id);e?b.get(e).children.push(a):d.push(a)}let e=a=>{a.sort((a,b)=>b.session.modified.localeCompare(a.session.modified)),a.forEach(a=>e(a.children))};return e(d),d})(ag),[ag]),aw=an.length,ax=an;if(aw>10&&!J){ax=an.slice(0,10);let b=an.find(b=>(function a(b,c){return!!c&&(b.session.id===c||b.children.some(b=>a(b,c)))})(b,a));b&&!ax.includes(b)&&(ax=[...ax,b])}let ay=aw-ax.length,az=(0,u.useCallback)((a,c=!1)=>{a.cwd!==ac&&(N.current=!0,y(a.cwd)),$(a.cwd),b(a,c)},[b,ac,$]);return(0,t.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},children:[(0,t.jsxs)("div",{style:{padding:"12px 10px 10px",borderBottom:"1px solid var(--border)",flexShrink:0},children:[(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:8},children:[(0,t.jsx)(at,{}),(0,t.jsxs)("div",{style:{display:"flex",gap:6},children:[(0,t.jsxs)("button",{onClick:ae,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:5,background:"var(--bg-hover)",border:"1px solid var(--border)",color:"var(--text-muted)",cursor:"pointer",height:32,paddingLeft:10,paddingRight:12,borderRadius:7,fontSize:12,fontWeight:500,letterSpacing:"-0.01em",flexShrink:0,transition:"background 0.12s, color 0.12s, border-color 0.12s"},title:ac?`New session in ${ac}`:"Select a project first",onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-selected)",a.currentTarget.style.color="var(--accent)",a.currentTarget.style.borderColor="rgba(37,99,235,0.35)"},onMouseLeave:a=>{a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="var(--text-muted)",a.currentTarget.style.borderColor="var(--border)"},children:[(0,t.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",children:[(0,t.jsx)("line",{x1:"6",y1:"1",x2:"6",y2:"11"}),(0,t.jsx)("line",{x1:"1",y1:"6",x2:"11",y2:"6"})]}),"New"]}),(0,t.jsx)("button",{onClick:()=>I(!0),style:{display:"flex",alignItems:"center",justifyContent:"center",background:"var(--bg-hover)",border:"1px solid var(--border)",color:"var(--text-muted)",cursor:"pointer",width:32,height:32,borderRadius:7,padding:0,flexShrink:0,transition:"background 0.12s, color 0.12s, border-color 0.12s"},title:"Search conversations",onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-selected)",a.currentTarget.style.color="var(--accent)",a.currentTarget.style.borderColor="rgba(37,99,235,0.35)"},onMouseLeave:a=>{a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="var(--text-muted)",a.currentTarget.style.borderColor="var(--border)"},children:(0,t.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("circle",{cx:"7",cy:"7",r:"4.4"}),(0,t.jsx)("path",{d:"M10.4 10.4 13.2 13.2"})]})})]})]}),(0,t.jsxs)("div",{ref:P,style:{position:"relative"},children:[(0,t.jsxs)("button",{type:"button",onClick:X,title:"Toggle and refresh project conversations","aria-expanded":L,style:{width:"100%",display:"flex",alignItems:"center",gap:6,padding:"6px 0",background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:11,fontWeight:600,letterSpacing:"0.05em",textTransform:"uppercase",textAlign:"left"},children:[(0,t.jsx)("svg",{width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:L?"rotate(90deg)":"none",transition:"transform 0.15s",flexShrink:0},children:(0,t.jsx)("polyline",{points:"3 2 7 5 3 8"})}),(0,t.jsx)("span",{style:{flex:1},children:"Project"}),r&&(0,t.jsx)("span",{style:{color:"var(--text-dim)",fontSize:10,fontWeight:500,letterSpacing:0,textTransform:"none"},children:"Refreshing..."})]}),L&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("button",{onClick:()=>C(a=>!a),style:{width:"100%",display:"flex",alignItems:"center",gap:9,padding:"8px 10px",background:ac?"var(--bg-hover)":"rgba(37,99,235,0.06)",border:ac?"1px solid var(--border)":"1px solid rgba(37,99,235,0.4)",borderRadius:7,cursor:"pointer",fontSize:12,color:"var(--text)",textAlign:"left",transition:"border-color 0.15s, background 0.15s"},children:[(0,t.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",style:{color:ac?"var(--accent)":"var(--text-dim)",flexShrink:0},children:(0,t.jsx)("path",{d:"M3 6.5A2.5 2.5 0 0 1 5.5 4H10l2 2.5h6.5A2.5 2.5 0 0 1 21 9v8.5A2.5 2.5 0 0 1 18.5 20h-13A2.5 2.5 0 0 1 3 17.5v-11Z"})}),(0,t.jsxs)("span",{style:{flex:1,minWidth:0},children:[(0,t.jsx)("span",{style:{display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:12,fontWeight:650,color:ac?"var(--text)":"var(--text-dim)"},children:ac?aj:d&&!Y.current?"":"Open project..."}),ac&&(0,t.jsx)("span",{style:{display:"block",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-dim)"},title:ac,children:aq(ac,z)})]}),ac&&(0,t.jsxs)("span",{style:{flexShrink:0,color:"var(--text-dim)",fontSize:10,whiteSpace:"nowrap"},children:[ak," chats"]}),(0,t.jsx)("svg",{width:"11",height:"11",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--text-dim)",flexShrink:0,transform:B?"rotate(180deg)":"none",transition:"transform 0.15s"},children:(0,t.jsx)("polyline",{points:"2 3.5 5 6.5 8 3.5"})})]}),B&&(0,t.jsxs)("div",{style:{position:"absolute",top:"calc(100% + 4px)",left:0,right:0,zIndex:100,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,boxShadow:"0 6px 20px rgba(0,0,0,0.10)",overflow:"hidden"},children:[(0,t.jsxs)("div",{style:{maxHeight:260,overflowY:"auto"},children:[0===af.length&&(0,t.jsx)("div",{style:{padding:"10px 12px",color:"var(--text-muted)",fontSize:12},children:"No projects yet"}),af.map(a=>{let b=a.cwd===ac,c=as(a);return(0,t.jsxs)("button",{onClick:()=>{_(a.cwd),E(null),C(!1)},style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"8px 10px",background:b?"var(--bg-selected)":"none",border:"none",borderBottom:"1px solid var(--border)",color:b?"var(--text)":"var(--text-muted)",cursor:"pointer",textAlign:"left",fontSize:11},title:a.cwd,children:[b?(0,t.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:(0,t.jsx)("polyline",{points:"1.5 5 4 7.5 8.5 2.5"})}):(0,t.jsx)("span",{style:{width:10,flexShrink:0}}),(0,t.jsxs)("span",{style:{flex:1,minWidth:0},children:[(0,t.jsx)("span",{style:{display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:b?"var(--text)":"var(--text-muted)",fontWeight:b?650:500},children:a.displayName}),(0,t.jsxs)("span",{style:{display:"block",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--text-dim)",fontSize:10},children:[a.chatCount," chats",c?` / ${ap(c)}`:"",a.exists?"":" / missing"]})]})]},a.cwd)})]}),(0,t.jsxs)("div",{style:{borderTop:af.length>0?"1px solid var(--border)":"none"},children:[(0,t.jsxs)("button",{onClick:a=>{a.stopPropagation(),aa()},style:{display:"flex",alignItems:"center",gap:7,width:"100%",padding:"8px 10px",background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",textAlign:"left",fontSize:11},children:[(0,t.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.1",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:(0,t.jsx)("path",{d:"M1 3A1 1 0 0 1 2 2H4L5 3.5H8.5a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5h-7A.5.5 0 0 1 1 8V3Z"})}),(0,t.jsx)("span",{children:"Use default directory"})]}),(0,t.jsxs)("button",{onClick:a=>{a.stopPropagation(),E(null),G(!0)},style:{display:"flex",alignItems:"center",gap:7,width:"100%",padding:"8px 10px",background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",textAlign:"left",fontSize:11},children:[(0,t.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.1",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[(0,t.jsx)("path",{d:"M1 3A1 1 0 0 1 2 2h1.5L4.5 3H8a1 1 0 0 1 1 1v4a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V3Z"}),(0,t.jsx)("path",{d:"M5 4.5v3M3.5 6h3"})]}),(0,t.jsx)("span",{children:"Select project path..."})]}),D&&(0,t.jsx)("div",{style:{padding:"0 10px 8px 27px",color:"#f87171",fontSize:10,lineHeight:1.4},children:D})]})]})]})]})]}),(0,t.jsx)(al,{open:H,cwd:ac,homeDir:z,onClose:()=>I(!1),onSelectSession:a=>{az(a)}}),L&&(0,t.jsx)(t.Fragment,{children:(0,t.jsxs)("div",{style:{flex:Q&&ac?"1 1 0":"1 1 auto",overflowY:"auto",padding:"6px 8px 8px",minHeight:120},children:[r&&(0,t.jsx)("div",{style:{padding:"16px 14px",color:"var(--text-muted)",fontSize:12},children:"Loading..."}),v&&(0,t.jsx)("div",{style:{padding:"12px 14px",color:"#f87171",fontSize:12},children:v}),!r&&!v&&!ac&&(0,t.jsx)("div",{style:{padding:"16px 14px",color:"var(--text-muted)",fontSize:12},children:"Open or create a project to start chatting."}),!r&&!v&&ac&&(0,t.jsxs)(t.Fragment,{children:[0===ag.length?(0,t.jsx)("button",{type:"button",onClick:()=>ad(ac),style:{width:"100%",padding:"12px",background:"transparent",border:"none",color:"var(--text-muted)",cursor:"pointer",textAlign:"left",fontSize:12},onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="var(--text)"},onMouseLeave:a=>{a.currentTarget.style.background="transparent",a.currentTarget.style.color="var(--text-muted)"},children:"Start a new session in this project"}):ax.map(b=>(0,t.jsx)(av,{node:b,selectedSessionId:a,onSelectSession:az,onRenamed:W,onSessionDeleted:a=>{g?.(a),W()},depth:0},b.session.id)),(J||ay>0)&&aw>10&&(0,t.jsx)("button",{type:"button",onClick:()=>K(a=>!a),style:{width:"100%",padding:"6px 10px",background:"transparent",border:"none",color:"var(--text-dim)",cursor:"pointer",fontSize:11,textAlign:"center"},children:J?"Show less":`Show ${Math.max(0,ay)} more`})]})]})}),ac&&(0,t.jsxs)("div",{style:{borderTop:"1px solid var(--border)",display:"flex",flexDirection:"column",flex:Q?"1 1 0":"0 0 auto",minHeight:0,overflow:"hidden"},children:[(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",flexShrink:0,gap:0,padding:"2px 4px"},children:[(0,t.jsxs)("button",{onClick:()=>{R(a=>!a),T(a=>a+1)},style:{display:"flex",alignItems:"center",gap:6,padding:"6px 6px 6px 6px",background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:11,fontWeight:600,letterSpacing:"0.05em",textTransform:"uppercase",textAlign:"left",flexShrink:0},children:[(0,t.jsx)("svg",{width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:Q?"rotate(90deg)":"none",transition:"transform 0.15s",flexShrink:0},children:(0,t.jsx)("polyline",{points:"3 2 7 5 3 8"})}),"Explorer"]}),(0,t.jsxs)("div",{style:{position:"relative",flex:1,minWidth:0},children:[(0,t.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",style:{position:"absolute",left:8,top:"50%",transform:"translateY(-50%)",color:"var(--text-dim)",pointerEvents:"none"},children:[(0,t.jsx)("circle",{cx:"7",cy:"7",r:"4.4"}),(0,t.jsx)("path",{d:"M10.4 10.4 13.2 13.2"})]}),(0,t.jsx)("input",{value:U,onChange:a=>V(a.target.value),placeholder:"Filter files...",style:{width:"100%",height:28,boxSizing:"border-box",padding:"0 26px 0 26px",borderRadius:6,border:"1px solid var(--border)",background:"var(--bg)",color:"var(--text)",fontSize:12,outline:"none"}}),U&&(0,t.jsx)("button",{type:"button",onClick:()=>V(""),title:"Clear filter",style:{position:"absolute",right:4,top:"50%",transform:"translateY(-50%)",width:20,height:20,display:"flex",alignItems:"center",justifyContent:"center",border:"none",borderRadius:4,background:"transparent",color:"var(--text-dim)",cursor:"pointer",padding:0},children:(0,t.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[(0,t.jsx)("line",{x1:"2",y1:"2",x2:"8",y2:"8"}),(0,t.jsx)("line",{x1:"8",y1:"2",x2:"2",y2:"8"})]})})]})]}),Q&&(0,t.jsx)("div",{style:{flex:1,overflowY:"auto",overflowX:"hidden"},children:(0,t.jsx)(ah,{cwd:ac,onOpenFile:j??(()=>{}),onExploreFile:k,refreshKey:S,onAtMention:m,searchQuery:U,onSearchChange:V})})]}),(0,t.jsx)(am,{open:F,initialPath:ac||z||null,onClose:()=>G(!1),onSelect:a=>void ab(a)})]})}function av({node:a,selectedSessionId:b,onSelectSession:c,onRenamed:d,onSessionDeleted:e,depth:f}){let[g,h]=(0,u.useState)(!1),i=a.children.length>0;return(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{style:{position:"relative"},children:[f>0&&(0,t.jsx)("div",{style:{position:"absolute",left:12*f+6,top:0,bottom:0,width:1,background:"var(--border)",pointerEvents:"none"}}),(0,t.jsx)(aw,{session:a.session,isSelected:a.session.id===b,onClick:()=>c(a.session),onRenamed:d,onDeleted:a=>e?.(a),depth:f,hasChildren:i,collapsed:g,onToggleCollapse:()=>h(a=>!a)})]}),i&&!g&&(0,t.jsx)("div",{children:a.children.map(a=>(0,t.jsx)(av,{node:a,selectedSessionId:b,onSelectSession:c,onRenamed:d,onSessionDeleted:e,depth:f+1},a.session.id))})]})}function aw({session:a,isSelected:b,onClick:c,onRenamed:d,onDeleted:e,depth:f=0,hasChildren:g=!1,collapsed:h=!1,onToggleCollapse:i}){let[j,k]=(0,u.useState)(!1),[l,m]=(0,u.useState)(!1),[n,o]=(0,u.useState)(""),[p,q]=(0,u.useState)(!1),[r,s]=(0,u.useState)(!1),v=(0,u.useRef)(null),w=a.name||a.firstMessage.slice(0,50)||a.id.slice(0,12),x=(0,u.useCallback)(b=>{b.stopPropagation(),o(a.name??""),m(!0),setTimeout(()=>v.current?.select(),0)},[a.name]),y=(0,u.useCallback)(async()=>{let b=n.trim();if(m(!1),b!==(a.name??""))try{await fetch(`/api/sessions/${encodeURIComponent(a.id)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:b})}),d?.()}catch{}},[n,a.id,a.name,d]),z=(0,u.useCallback)(a=>{a.stopPropagation(),q(!0)},[]),A=(0,u.useCallback)(async b=>{b.stopPropagation(),q(!1),s(!0);try{await fetch(`/api/sessions/${encodeURIComponent(a.id)}`,{method:"DELETE"}),e?.(a.id)}catch{s(!1)}},[a.id,e]),B=(0,u.useCallback)(a=>{a.stopPropagation(),q(!1)},[]);return(0,t.jsx)("div",{onClick:p||l?void 0:c,onMouseEnter:()=>k(!0),onMouseLeave:()=>{k(!1)},style:{height:54,display:"flex",alignItems:"center",paddingLeft:f>0?12*f+14:14,paddingRight:8,cursor:p||l?"default":"pointer",background:p?"rgba(239,68,68,0.06)":b?"var(--bg-selected)":j?"var(--bg-hover)":"transparent",borderLeft:p?"2px solid #ef4444":b?"2px solid var(--accent)":"2px solid transparent",transition:"background 0.1s",opacity:r?.5:1,gap:6,overflow:"hidden"},children:p?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{style:{flex:1,minWidth:0,fontSize:12,color:"var(--text)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:["Delete ",(0,t.jsxs)("span",{style:{fontWeight:600},children:["“",w.slice(0,22),w.length>22?"…":"","”"]}),"?"]}),(0,t.jsxs)("div",{style:{display:"flex",gap:5,flexShrink:0},children:[(0,t.jsxs)("button",{onClick:A,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:4,height:30,padding:"0 11px",background:"#ef4444",border:"none",borderRadius:6,color:"#fff",cursor:"pointer",fontSize:12,fontWeight:600,whiteSpace:"nowrap"},children:[(0,t.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,t.jsx)("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),(0,t.jsx)("path",{d:"M10 11v6M14 11v6"}),(0,t.jsx)("path",{d:"M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"})]}),"Delete"]}),(0,t.jsx)("button",{onClick:B,style:{display:"flex",alignItems:"center",justifyContent:"center",height:30,padding:"0 11px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:6,color:"var(--text-muted)",cursor:"pointer",fontSize:12,fontWeight:500,whiteSpace:"nowrap"},children:"Cancel"})]})]}):l?(0,t.jsx)("input",{ref:v,value:n,onChange:a=>o(a.target.value),onBlur:y,onKeyDown:a=>{"Enter"===a.key&&y(),"Escape"===a.key&&m(!1)},autoFocus:!0,style:{flex:1,fontSize:12,padding:"5px 8px",border:"1px solid var(--accent)",borderRadius:5,outline:"none",background:"var(--bg)",color:"var(--text)",height:30}}):(0,t.jsxs)(t.Fragment,{children:[f>0&&(0,t.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-dim)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[(0,t.jsx)("line",{x1:"6",y1:"3",x2:"6",y2:"15"}),(0,t.jsx)("circle",{cx:"18",cy:"6",r:"3"}),(0,t.jsx)("circle",{cx:"6",cy:"18",r:"3"}),(0,t.jsx)("path",{d:"M18 9a9 9 0 0 1-9 9"})]}),(0,t.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,t.jsx)("div",{style:{fontSize:12,fontWeight:b?500:400,lineHeight:1.4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--text)"},title:w,children:w}),(0,t.jsxs)("div",{style:{marginTop:2,display:"flex",gap:8,color:"var(--text-dim)",fontSize:11},children:[(0,t.jsx)("span",{title:a.modified,children:ap(a.modified)}),(0,t.jsxs)("span",{children:[a.messageCount," msgs"]})]})]}),g&&(0,t.jsx)("button",{onClick:a=>{a.stopPropagation(),i?.()},title:h?"Expand forks":"Collapse forks",style:{display:"flex",alignItems:"center",justifyContent:"center",width:20,height:20,padding:0,flexShrink:0,background:"none",border:"none",color:"var(--text-dim)",cursor:"pointer",transform:h?"rotate(-90deg)":"none",transition:"transform 0.15s"},children:(0,t.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:(0,t.jsx)("polyline",{points:"2 3.5 5 6.5 8 3.5"})})}),j&&(0,t.jsxs)("div",{style:{display:"flex",gap:4,flexShrink:0},children:[(0,t.jsx)("button",{onClick:x,title:"Rename",style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,padding:0,background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:7,color:"var(--text-muted)",cursor:"pointer",flexShrink:0,transition:"background 0.12s, color 0.12s, border-color 0.12s"},onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-selected)",a.currentTarget.style.color="var(--accent)",a.currentTarget.style.borderColor="rgba(37,99,235,0.35)"},onMouseLeave:a=>{a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="var(--text-muted)",a.currentTarget.style.borderColor="var(--border)"},children:(0,t.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,t.jsx)("path",{d:"M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"})})}),(0,t.jsx)("button",{onClick:z,title:"Delete",style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,padding:0,background:"var(--bg-hover)",border:"1px solid var(--border)",borderRadius:7,color:"var(--text-muted)",cursor:"pointer",flexShrink:0,transition:"background 0.12s, color 0.12s, border-color 0.12s"},onMouseEnter:a=>{a.currentTarget.style.background="rgba(239,68,68,0.08)",a.currentTarget.style.color="#ef4444",a.currentTarget.style.borderColor="rgba(239,68,68,0.35)"},onMouseLeave:a=>{a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="var(--text-muted)",a.currentTarget.style.borderColor="var(--border)"},children:(0,t.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,t.jsx)("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),(0,t.jsx)("path",{d:"M10 11v6M14 11v6"}),(0,t.jsx)("path",{d:"M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"})]})})]})]})})}let ax=new Set;function ay(a){return ax.add(a),()=>{ax.delete(a)}}function az(){return"u"<typeof document?"light":document.documentElement.classList.contains("dark")?"dark":"light"}function aA(){return"light"}function aB(){let a=(0,u.useSyncExternalStore)(ay,az,aA);return{theme:a,toggleTheme:(0,u.useCallback)(a=>{let b="dark"===az()?"light":"dark",c=()=>{"dark"===b?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark");try{localStorage.setItem("pi-theme",b)}catch{}ax.forEach(a=>a())},d=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;if("function"!=typeof document.startViewTransition||d)return void c();let e=a?.x??window.innerWidth/2,f=a?.y??window.innerHeight/2,g=Math.hypot(Math.max(e,window.innerWidth-e),Math.max(f,window.innerHeight-f));document.startViewTransition(c).ready.then(()=>{document.documentElement.animate({clipPath:[`circle(0px at ${e}px ${f}px)`,`circle(${g}px at ${e}px ${f}px)`]},{duration:450,easing:"cubic-bezier(0.22, 0.61, 0.36, 1)",pseudoElement:"::view-transition-new(root)"})}).catch(()=>{})},[]),isDark:"dark"===a}}function aC(a){let b,c=[],d=/`{1,3}show-widget`{0,3}\s*(?:\n\s*`{3}(?:json|html)?\s*)?\n?/g,e=0,f=!1;for(;null!==(b=d.exec(a));){f=!0;let g=a.slice(e,b.index).trim();g&&c.push({type:"text",content:g});let h=b.index+b[0].length,i=a.indexOf("```",h),j=a.indexOf("{",h);if(-1!==j&&j<=h+200&&(-1===i||j<i)){let b=function(a,b){let c=0,d=!1,e=!1;for(let f=b;f<a.length;f++){let b=a[f];if(e){e=!1;continue}if("\\"===b&&d){e=!0;continue}if('"'===b){d=!d;continue}if(!d&&("{"===b&&c++,"}"===b)&&0==--c)return f}return -1}(a,j);if(-1===b){let b=function(a){try{let b=aD(a);if(b)return b}catch{}let b=a.indexOf('"widget_code"');if(-1===b)return null;let c=a.indexOf(":",b+13);if(-1===c)return null;let d=a.indexOf('"',c+1);if(-1===d)return null;let e=a.slice(d+1);(e=e.replace(/"\s*\}\s*$/,"")).endsWith("\\")&&(e=e.slice(0,-1));let f=a.match(/"title"\s*:\s*"([^"]*?)"/)?.[1],g=aE(e.replace(/\\\\/g,"\0BACKSLASH\0").replace(/\\n/g,"\n").replace(/\\t/g," ").replace(/\\r/g,"\r").replace(/\\"/g,'"').replace(/\\u([0-9a-fA-F]{4})/g,(a,b)=>String.fromCharCode(parseInt(b,16))).replace(/\x00BACKSLASH\x00/g,"\\"));return g.code.trim()?{title:f,code:g.code,showOverlay:g.truncated}:null}(a.slice(j));b&&c.push({type:"widget",...b,partial:!0}),e=a.length;break}let f=aD(a.slice(j,b+1).trim());f&&c.push({type:"widget",...f});let g=b+1,h=a.slice(g,g+16).match(/^\s*\n?`{1,3}\s*/);h&&(g+=h[0].length),e=g,d.lastIndex=g;continue}if(-1!==i){let b=a.slice(h,i).trim(),f=aD(b);f?c.push({type:"widget",...f}):b&&c.push({type:"text",content:b}),d.lastIndex=e=i+3}else{let b=aD(a.slice(h).trim());if(b){let a=aE(b.code);c.push({type:"widget",title:b.title,code:a.code,partial:!0,showOverlay:a.truncated})}e=a.length;break}}let g=a.slice(e).trim();return g&&c.push({type:"text",content:g}),!f&&0===c.length&&a.trim()&&c.push({type:"text",content:a}),c}function aD(a){if(a.startsWith("{")){if(!a.endsWith("}"))return null;try{let b=JSON.parse(a),c=b.widget_code??b.code;if(c)return{title:b.title,code:c}}catch{return null}}return/<(!DOCTYPE|html|svg|canvas|script|style|div)/i.test(a)?{code:a}:null}function aE(a){let b=a.lastIndexOf("<script");if(-1===b)return{code:a,truncated:!1};let c=a.slice(b);return/<script[\s\S]*?<\/script>/i.test(c)?{code:a,truncated:!1}:{code:a.slice(0,b).trim(),truncated:!0}}let aF=/<(iframe|object|embed|meta|link|base|form)[\s>][\s\S]*?<\/\1>/gi,aG=/<(iframe|object|embed|meta|link|base)\b[^>]*\/?>/gi;function aH(a){return a.replace(aF,"").replace(aG,"")}let aI=["--bg","--bg-panel","--bg-hover","--bg-selected","--border","--text","--text-muted","--text-dim","--accent","--accent-hover"],aJ=["--bg","--bg-panel","--bg-hover","--bg-selected","--border","--text","--text-muted","--text-dim","--accent","--accent-hover"];async function aK(a){if(navigator.clipboard?.writeText)return void await navigator.clipboard.writeText(a);let b=document.createElement("textarea");b.value=a,b.style.position="fixed",b.style.inset="0",b.style.opacity="0",document.body.appendChild(b),b.focus(),b.select();let c=document.execCommand("copy");if(document.body.removeChild(b),!c)throw Error("Clipboard copy failed.")}async function aL(a){let b=await aM(a.code);if(b)return b;if(a.capture)return function(a){if(!a.html)throw Error("The widget did not provide capturable HTML.");let b=aP({width:a.bodyWidth||640,height:a.bodyHeight||360}),c=function(a){let b=document.createElement("template");b.innerHTML=aH(a.html||"");let c=document.createElement("div");for(let d of(c.appendChild(b.content.cloneNode(!0)),Array.from(c.querySelectorAll("img[data-canvas-export]")))){let b=Number(d.getAttribute("data-canvas-export")),c=Number.isFinite(b)?a.canvases?.[b]:null;if(!c?.dataUrl){d.remove();continue}d.setAttribute("src",c.dataUrl),d.setAttribute("width",String(c.width)),d.setAttribute("height",String(c.height)),d.setAttribute("style",function(a,b){let c=new Map;for(let b of(a||"").split(";")){let[a,...d]=b.split(":");a?.trim()&&d.length>0&&c.set(a.trim(),d.join(":").trim())}for(let[a,d]of Object.entries(b))c.set(a,d);return Array.from(c.entries()).map(([a,b])=>a+":"+b).join(";")}(d.getAttribute("style"),{width:c.width+"px",height:c.height+"px",display:"block"}))}return aN(c),Array.from(c.childNodes).map(a=>new XMLSerializer().serializeToString(a)).join("")}(a);if(!c.trim())throw Error("The widget capture was empty.");let d=[a.styles||"","#__widget_export_root{"+function(){if("u"<typeof document)return"";let a=getComputedStyle(document.documentElement);return aJ.map(b=>{let c=a.getPropertyValue(b).trim();return c?b+":"+c+";":""}).join("")}()+'font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",system-ui,sans-serif;font-size:14px;line-height:1.6;color:var(--text,#1a1a1a);background:transparent;}',"#__widget_export_root *{box-sizing:border-box;}\n#__widget_export_root svg{max-width:100%;height:auto;display:block;}"].join("\n");return aR(aS('<svg xmlns="http://www.w3.org/2000/svg" width="'+b.width+'" height="'+b.height+'" viewBox="0 0 '+b.width+" "+b.height+'"><defs><style><![CDATA['+d.replace(/\]\]>/g,"]]]]><![CDATA[>")+']]></style></defs><foreignObject x="0" y="0" width="100%" height="100%">'+('<div xmlns="http://www.w3.org/1999/xhtml" id="__widget_export_root" style="width:'+b.width+"px;min-height:")+b.height+'px;overflow:visible;">'+c+"</div></foreignObject></svg>"),b.width,b.height)}(a.capture);throw Error("PNG export needs a rendered widget capture.")}async function aM(a){var b;let c,d,e,f,g=function(a){let b=aH(a).trim();if(!/^<\s*(style|svg)\b/i.test(b))return null;let c=new DOMParser().parseFromString(b,"text/html"),d=Array.from(c.body.children),e=d.filter(a=>"svg"===a.tagName.toLowerCase()),f=d.filter(a=>"style"!==a.tagName.toLowerCase());if(1!==e.length||1!==f.length)return null;let g=e[0].cloneNode(!0),h=Array.from(c.body.querySelectorAll("style")).map(a=>a.textContent||"").join("\n").trim();if(h){let a=document.createElementNS("http://www.w3.org/2000/svg","style");a.textContent=h,g.insertBefore(a,g.firstChild)}return g}(a);if(!g)return null;aN(g),g.setAttribute("xmlns","http://www.w3.org/2000/svg");let h=aP((c=function(a){if(!a)return null;let b=a.trim().split(/[\s,]+/).map(Number);return 4!==b.length||b.some(a=>!Number.isFinite(a))||b[2]<=0||b[3]<=0?null:{width:b[2],height:b[3]}}((b=g).getAttribute("viewBox")),d=aO(b.getAttribute("width"))??c?.width??640,e=c?c.height/c.width:.5625,f=aO(b.getAttribute("height"))??c?.height??d*e,{width:d,height:f}));return g.setAttribute("width",String(h.width)),g.setAttribute("height",String(h.height)),g.getAttribute("viewBox")||g.setAttribute("viewBox","0 0 "+h.width+" "+h.height),aR(aS(new XMLSerializer().serializeToString(g)),h.width,h.height)}function aN(a){for(let b of Array.from(a.querySelectorAll("script, iframe, object, embed, meta, link, base, form")))b.remove();for(let b of[a,...Array.from(a.querySelectorAll("*"))])for(let a of Array.from(b.attributes)){let c=a.name.toLowerCase(),d=a.value.trim();if(c.startsWith("on")){b.removeAttribute(a.name);continue}("href"===c||"src"===c||c.endsWith(":href"))&&/^\s*(javascript|data:text\/html)/i.test(d)&&b.removeAttribute(a.name)}}function aO(a){if(!a||a.includes("%"))return null;let b=Number.parseFloat(a);return Number.isFinite(b)&&b>0?b:null}function aP(a){let b=aQ(Math.ceil(a.width||640),240,2e3),c=aQ(Math.ceil(a.height||360),80,4e3),d=b*c;if(d>8e6){let a=Math.sqrt(8e6/d);b=Math.max(240,Math.floor(b*a)),c=Math.max(80,Math.floor(c*a))}return{width:b,height:c}}function aQ(a,b,c){return Math.min(Math.max(a,b),c)}function aR(a,b,c){return new Promise((d,e)=>{let f=new Image,g=URL.createObjectURL(new Blob([a],{type:"image/svg+xml;charset=utf-8"}));f.onload=()=>{URL.revokeObjectURL(g);try{let a=document.createElement("canvas"),g=Math.min(window.devicePixelRatio||1,2);a.width=Math.ceil(b*g),a.height=Math.ceil(c*g),a.style.width=b+"px",a.style.height=c+"px";let h=a.getContext("2d");if(!h)throw Error("Canvas is not available.");h.scale(g,g),h.drawImage(f,0,0,b,c),a.toBlob(a=>{a?d(a):e(Error("Canvas export returned no image."))},"image/png")}catch(a){e(a instanceof Error?a:Error("PNG export failed."))}},f.onerror=()=>{URL.revokeObjectURL(g),e(Error("The browser could not render this widget as PNG."))},f.src=g})}function aS(a){if("u"<typeof document)return a;let b=getComputedStyle(document.documentElement);return a.replace(/var\(\s*(--[a-zA-Z0-9_-]+)(?:\s*,\s*([^)]+))?\)/g,(a,c,d)=>b.getPropertyValue(c).trim()||d?.trim()||"#000")}let aT=/cdnjs\.cloudflare\.com|cdn\.jsdelivr\.net|unpkg\.com|esm\.sh/,aU=new Map;function aV(a){return a.slice(0,200)}function aW({code:a,isStreaming:b,title:c,showOverlay:d,onSendMessage:e}){let{isDark:f}=aB(),g=(0,u.useRef)(null);(0,u.useRef)(null);let h=(0,u.useRef)(null),i=(0,u.useRef)(new Map),j=(0,u.useRef)(""),[k,l]=(0,u.useState)(!1),[m,n]=(0,u.useState)(()=>aU.get(aV(a))??0),[o,p]=(0,u.useState)(!1),[q,r]=(0,u.useState)(!1),[s,v]=(0,u.useState)(null),[w,x]=(0,u.useState)(!1),[y,z]=(0,u.useState)(!1);(0,u.useRef)("");let A=(0,u.useRef)((aU.get(aV(a))??0)>0);(0,u.useRef)(!1);let B=(0,u.useRef)(f),C=(0,u.useMemo)(()=>aT.test(a),[a]),D=(0,u.useMemo)(()=>{let a;return function(a="",b=!1){return`<!DOCTYPE html>
2
2
  <html class="${b?"dark":""}">
3
3
  <head>
4
4
  <meta charset="utf-8">
@@ -246,7 +246,7 @@ ${c}`)}return e.join("\n\n")}async function ls(a){let b=(await c.e(7890).then(c.
246
246
  ${e}`}).join("\n\n")}async function lu(a){let b=(await c.e(7890).then(c.t.bind(c,55509,23))).default,d=await b.loadAsync(a),e=Object.keys(d.files).map(a=>({name:a,match:/^ppt\/slides\/slide(\d+)\.xml$/i.exec(a)})).filter(a=>null!==a.match).sort((a,b)=>Number(a.match[1])-Number(b.match[1])),f=[];for(let{name:a,match:b}of e){let c=[...(await d.file(a).async("string")).matchAll(/<a:t[^>]*>([\s\S]*?)<\/a:t>/g)].map(a=>lq(a[1]).trim()).filter(Boolean);c.length&&f.push(`Slide ${b[1]}
247
247
  ${c.join("\n")}`)}return f.join("\n\n")}async function lv(a,b){let c=a.name.split(".").pop()?.toLowerCase()??"";try{let d,e="";if(a.type.startsWith("text/")||["csv","tsv","md","txt","json","xml"].includes(c))e=new TextDecoder("utf-8").decode(b);else if("pdf"===c||"application/pdf"===a.type)e=await lr(b);else if("docx"===c)e=await ls(b);else if("xlsx"===c)e=await lt(b);else{if("pptx"!==c)return{extractionError:"Text extraction is not supported for this file type"};e=await lu(b)}let{text:f,truncated:g}=(d=e.replace(/\r\n/g,"\n").replace(/\n{4,}/g,"\n\n\n").trim()).length<=6e4?{text:d,truncated:!1}:{text:`${d.slice(0,6e4)}
248
248
 
249
- [truncated after 60000 characters]`,truncated:!0};if(!f)return{extractionError:"No extractable text found"};return{extractedText:f,truncated:g}}catch(a){return{extractionError:a instanceof Error?a.message:String(a)}}}let lw=(0,u.forwardRef)(function({onSend:a,onAbort:b,onSteer:c,onFollowUp:d,isStreaming:e,model:f,modelNames:g,modelList:h,onModelChange:i,onCompact:j,onAbortCompaction:k,isCompacting:l,compactError:m,toolPreset:n,onToolPresetChange:o,thinkingLevel:p,onThinkingLevelChange:q,availableThinkingLevels:r,thinkingLevelMap:s,retryInfo:v,soundEnabled:w,onSoundToggle:x,cornerBadge:y},z){let A,B,C,[D,E]=(0,u.useState)(""),[F,G]=(0,u.useState)(!1),[H,I]=(0,u.useState)(null),[J,K]=(0,u.useState)(!1),[L,M]=(0,u.useState)(!1),[N,O]=(0,u.useState)(null),[P,Q]=(0,u.useState)([]),[R,S]=(0,u.useState)([]),T=(0,u.useRef)(null),U=(0,u.useRef)(null),V=(0,u.useRef)(null),W=(0,u.useRef)(null),X=(0,u.useRef)(null),Y=(0,u.useRef)(null),Z=(0,u.useRef)(null);(0,u.useImperativeHandle)(z,()=>({insertIfEmpty(a){let b=T.current;(b?b.value:D).trim()||(E(a),requestAnimationFrame(()=>{b&&(b.focus(),b.style.height="auto",b.style.height=`${Math.min(b.scrollHeight,200)}px`)}))},insertText(a){let b=T.current;if(!b)return void E(b=>b+(b?" ":"")+a);let c=b.selectionStart??b.value.length,d=b.selectionEnd??b.value.length,e=b.value.slice(0,c),f=b.value.slice(d),g=e.length>0&&!e.endsWith(" ")?" ":"";E(e+g+a+f),requestAnimationFrame(()=>{if(!b)return;let d=c+g.length+a.length;b.setSelectionRange(d,d),b.focus(),b.style.height="auto",b.style.height=`${Math.min(b.scrollHeight,200)}px`})},addImages(a){$(a)},addFiles(a){_(a)}}));let $=(0,u.useCallback)(async a=>{let b=a.filter(a=>a.type.startsWith("image/"));if(!b.length)return;let c=await Promise.all(b.map(a=>new Promise((b,c)=>{let d=new FileReader;d.onload=()=>{b({data:d.result.split(",")[1],mimeType:a.type,previewUrl:URL.createObjectURL(a)})},d.onerror=c,d.readAsDataURL(a)})));Q(a=>[...a,...c])},[]),_=(0,u.useCallback)(async a=>{let b=a.filter(a=>a.type.startsWith("image/")),c=a.filter(a=>!a.type.startsWith("image/"));if(b.length&&$(b),c.length){let a=await Promise.all(c.map(a=>new Promise((b,c)=>{let d=new FileReader;d.onload=async()=>{let c=d.result,e=await lv(a,c);b({data:c,fileName:a.name,mimeType:a.type||"application/octet-stream",size:a.size,...e})},d.onerror=c,d.readAsArrayBuffer(a)})));S(b=>[...b,...a])}},[$]),aa=(0,u.useCallback)(a=>{Q(b=>{let c=[...b];return URL.revokeObjectURL(c[a].previewUrl),c.splice(a,1),c})},[]),ab=(0,u.useCallback)(a=>{S(b=>{let c=[...b];return c.splice(a,1),c})},[]),ac=(0,u.useCallback)(()=>{Q(a=>(a.forEach(a=>URL.revokeObjectURL(a.previewUrl)),[])),S([])},[]),ad=(0,u.useCallback)(()=>{let b=D.trim();(b||P.length||R.length)&&!e&&(a(b,P.length?P:void 0,R.length?R:void 0),E(""),ac(),T.current&&(T.current.style.height="auto"))},[D,P,R,e,a,ac]),ae=(0,u.useCallback)(a=>{let b=D.trim();if(!b&&!P.length&&!R.length)return;let e=P.length?P:void 0,f=R.length?R:void 0;"steer"===a&&c?c(b,e,f):"followup"===a&&d&&d(b,e,f),E(""),ac(),T.current&&(T.current.style.height="auto")},[D,P,R,c,d,ac]),af=(0,u.useCallback)(a=>{"Enter"!==a.key||a.shiftKey||a.nativeEvent.isComposing||(a.preventDefault(),e&&(c||d)?ae(c?"steer":"followup"):ad())},[e,c,d,ae,ad]),ag=(0,u.useCallback)(()=>{let a=T.current;a&&(a.style.height="auto",a.style.height=`${Math.min(a.scrollHeight,200)}px`)},[]),ah=(0,u.useCallback)(a=>{let b=Array.from(a.clipboardData?.items??[]).filter(a=>"file"===a.kind&&(a.type.startsWith("image/")||a.type.includes("pdf")||a.type.includes("officedocument")||a.type.includes("msword")||a.type.includes("ms-")));b.length&&(a.preventDefault(),_(b.map(a=>a.getAsFile()).filter(a=>null!==a)))},[_]),ai=h&&h.length>0?h.map(a=>({provider:a.provider,modelId:a.id,name:a.name})):Object.entries(g??{}).map(([a,b])=>({provider:f?.provider??"unknown",modelId:a,name:b})),aj=[];for(let a of ai){let b=aj.find(b=>b.provider===a.provider);b?b.options.push(a):aj.push({provider:a.provider,options:[a]})}let ak=f?ai.find(a=>a.modelId===f.modelId&&a.provider===f.provider)?.name??f.modelId:ai.length>0?ai[0].name:null;return(0,u.useEffect)(()=>{let a=a=>{U.current&&!U.current.contains(a.target)&&V.current&&!V.current.contains(a.target)&&G(!1),W.current&&!W.current.contains(a.target)&&K(!1),X.current&&!X.current.contains(a.target)&&M(!1)};return document.addEventListener("mousedown",a),()=>document.removeEventListener("mousedown",a)},[]),(0,u.useEffect)(()=>{if(!o)return;let a=!1;return fetch("/api/subagents/status").then(a=>a.ok?a.json():null).then(b=>{a||O(!!b?.ready)}).catch(()=>{a||O(!1)}),()=>{a=!0}},[o]),(0,t.jsxs)("div",{style:{flexShrink:0,background:"transparent",padding:"0 16px 8px",paddingRight:52},children:[(0,t.jsx)("input",{ref:Y,type:"file",accept:"image/*",multiple:!0,style:{display:"none"},onChange:a=>{$(Array.from(a.target.files??[])),a.target.value=""}}),(0,t.jsx)("input",{ref:Z,type:"file",accept:".pdf,.docx,.xlsx,.pptx,.doc,.xls,.ppt,application/pdf,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.openxmlformats-officedocument.presentationml.presentation",multiple:!0,style:{display:"none"},onChange:a=>{_(Array.from(a.target.files??[])),a.target.value=""}}),(0,t.jsxs)("div",{style:{maxWidth:820,margin:"0 auto",position:"relative"},children:[y&&(0,t.jsx)("div",{style:{position:"absolute",right:8,top:-22,display:"flex",alignItems:"center",justifyContent:"flex-end",maxWidth:"min(320px, 60vw)",minHeight:18,zIndex:2,fontFamily:"var(--font-mono)",overflow:"hidden"},children:y}),v&&(0,t.jsxs)("div",{style:{marginBottom:8,padding:"5px 10px",background:"rgba(234,179,8,0.08)",border:"1px solid rgba(234,179,8,0.25)",borderRadius:6,fontSize:12,color:"rgba(180,130,0,0.9)",display:"flex",alignItems:"center",gap:6},children:[(0,t.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[(0,t.jsx)("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),(0,t.jsx)("path",{d:"M3 3v5h5"})]}),"Retrying (",v.attempt,"/",v.maxAttempts,")…",v.errorMessage&&(0,t.jsxs)("span",{style:{opacity:.7,marginLeft:4},children:["— ",v.errorMessage]})]}),(P.length>0||R.length>0)&&(0,t.jsxs)("div",{style:{display:"flex",gap:6,marginBottom:6,flexWrap:"wrap",alignItems:"flex-end"},children:[P.map((a,b)=>(0,t.jsxs)("div",{style:{position:"relative",flexShrink:0},children:[(0,t.jsx)("img",{src:a.previewUrl,alt:"",style:{width:56,height:56,objectFit:"cover",borderRadius:6,border:"1px solid var(--border)",display:"block"}}),(0,t.jsx)("button",{onClick:()=>aa(b),style:{position:"absolute",top:-4,right:-4,width:16,height:16,borderRadius:"50%",background:"var(--bg-panel)",border:"1px solid var(--border)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",padding:0,color:"var(--text-muted)"},children:(0,t.jsxs)("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:[(0,t.jsx)("line",{x1:"1",y1:"1",x2:"7",y2:"7"}),(0,t.jsx)("line",{x1:"7",y1:"1",x2:"1",y2:"7"})]})})]},`img-${b}`)),R.map((a,b)=>(0,t.jsx)(lp,{doc:a,onRemove:()=>ab(b)},`doc-${b}`))]}),(0,t.jsxs)("div",{style:{display:"flex",gap:8,alignItems:"center",background:"var(--bg)",border:`1px solid ${e&&(c||d)?"rgba(234,179,8,0.4)":"color-mix(in srgb, var(--border) 70%, transparent)"}`,borderRadius:14,padding:"10px 10px 10px 14px",boxShadow:"0 1px 2px rgba(15,23,42,0.04), 0 8px 24px -12px rgba(15,23,42,0.10)",transition:"border-color 0.15s, background 0.15s, box-shadow 0.15s"},children:[(0,t.jsx)("textarea",{ref:T,value:D,onChange:a=>E(a.target.value),onKeyDown:af,onInput:ag,onPaste:ah,placeholder:e&&(c||d)?"Steer 立即注入 / Follow-up 排队…":e?"Agent is running…":"Message…",rows:1,style:{flex:1,background:"none",border:"none",outline:"none",resize:"none",color:"var(--text)",fontSize:14,lineHeight:1.6,fontFamily:"inherit",minHeight:24,maxHeight:200,overflow:"auto"}}),e?(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,flexShrink:0,alignSelf:"flex-end"},children:[c&&(0,t.jsxs)("button",{onClick:()=>ae("steer"),disabled:!D.trim()&&!P.length&&!R.length,title:"打断 Agent 当前运行,立即注入消息",style:{display:"flex",alignItems:"center",gap:5,padding:"7px 12px",background:D.trim()||P.length||R.length?"rgba(234,179,8,0.12)":"none",border:"1px solid rgba(234,179,8,0.35)",borderRadius:8,color:D.trim()||P.length||R.length?"rgba(180,130,0,1)":"var(--text-dim)",cursor:D.trim()||P.length||R.length?"pointer":"not-allowed",fontSize:13,fontWeight:600,letterSpacing:"-0.01em",transition:"background 0.12s"},children:[(0,t.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("path",{d:"M5 1 L9 5 L5 9"}),(0,t.jsx)("line",{x1:"1",y1:"5",x2:"9",y2:"5"})]}),"Steer"]}),d&&(0,t.jsxs)("button",{onClick:()=>ae("followup"),disabled:!D.trim()&&!P.length&&!R.length,title:"在 Agent 完成后排队发送",style:{display:"flex",alignItems:"center",gap:5,padding:"7px 12px",background:D.trim()||P.length||R.length?"rgba(129,140,248,0.12)":"none",border:"1px solid rgba(129,140,248,0.35)",borderRadius:8,color:D.trim()||P.length||R.length?"rgba(99,102,241,1)":"var(--text-dim)",cursor:D.trim()||P.length||R.length?"pointer":"not-allowed",fontSize:13,fontWeight:600,letterSpacing:"-0.01em",transition:"background 0.12s"},children:[(0,t.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("line",{x1:"5",y1:"1",x2:"5",y2:"6"}),(0,t.jsx)("polyline",{points:"2.5 3.5 5 1 7.5 3.5"}),(0,t.jsx)("line",{x1:"2",y1:"9",x2:"8",y2:"9"})]}),"Follow-up"]})]}):(0,t.jsxs)("button",{onClick:ad,disabled:!D.trim()&&!P.length&&!R.length,style:{flexShrink:0,alignSelf:"flex-end",display:"flex",alignItems:"center",gap:6,padding:"7px 14px",background:D.trim()||P.length||R.length?"var(--accent)":"var(--bg-panel)",border:"none",borderRadius:8,color:D.trim()||P.length||R.length?"#fff":"var(--text-dim)",cursor:D.trim()||P.length||R.length?"pointer":"not-allowed",fontSize:13,fontWeight:600,letterSpacing:"-0.01em",boxShadow:D.trim()||P.length||R.length?"0 1px 3px rgba(37,99,235,0.25)":"none",transition:"background 0.15s, box-shadow 0.15s"},children:[(0,t.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("line",{x1:"2",y1:"7",x2:"11",y2:"7"}),(0,t.jsx)("polyline",{points:"7.5 3 12 7 7.5 11"})]}),"Send"]})]}),(0,t.jsxs)("div",{className:"chat-input-toolbar",style:{marginTop:8,display:"flex",alignItems:"center",gap:6},children:[(0,t.jsxs)("div",{className:"chat-input-toolbar-left",style:{flex:"0 0 auto",display:"flex",alignItems:"center",gap:2},children:[(0,t.jsx)("button",{onClick:()=>Y.current?.click(),disabled:e,title:"Attach image (right-click for document)",style:{flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,padding:0,background:"none",border:"none",borderRadius:9,color:P.length||R.length?"var(--accent)":"var(--text-muted)",cursor:e?"not-allowed":"pointer",opacity:e?.5:1,transition:"background 0.12s, color 0.12s"},onMouseEnter:a=>{e||(a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color=P.length||R.length?"var(--accent)":"var(--text)")},onMouseLeave:a=>{a.currentTarget.style.background="none",a.currentTarget.style.color=P.length||R.length?"var(--accent)":"var(--text-muted)"},onContextMenu:a=>{a.preventDefault(),Z.current?.click()},children:(0,t.jsx)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:(0,t.jsx)("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"})})}),ai.length>0&&ak&&i&&(0,t.jsxs)("div",{ref:U,style:{position:"relative"},children:[(0,t.jsxs)("button",{onClick:a=>{let b=a.currentTarget.getBoundingClientRect();I({top:b.top,left:b.left,width:b.width}),G(a=>!a)},disabled:e,style:{display:"flex",alignItems:"center",gap:6,padding:"8px 12px",height:32,maxWidth:220,overflow:"hidden",background:F?"var(--bg-hover)":"none",border:"none",borderRadius:9,color:"var(--text-muted)",cursor:e?"not-allowed":"pointer",fontSize:12,opacity:e?.5:1,transition:"background 0.12s, color 0.12s"},onMouseEnter:a=>{e||(a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="var(--text)")},onMouseLeave:a=>{a.currentTarget.style.background=F?"var(--bg-hover)":"none",a.currentTarget.style.color="var(--text-muted)"},children:[(0,t.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}),(0,t.jsx)("rect",{x:"9",y:"9",width:"6",height:"6"}),(0,t.jsx)("line",{x1:"9",y1:"1",x2:"9",y2:"4"}),(0,t.jsx)("line",{x1:"15",y1:"1",x2:"15",y2:"4"}),(0,t.jsx)("line",{x1:"9",y1:"20",x2:"9",y2:"23"}),(0,t.jsx)("line",{x1:"15",y1:"20",x2:"15",y2:"23"}),(0,t.jsx)("line",{x1:"20",y1:"9",x2:"23",y2:"9"}),(0,t.jsx)("line",{x1:"20",y1:"14",x2:"23",y2:"14"}),(0,t.jsx)("line",{x1:"1",y1:"9",x2:"4",y2:"9"}),(0,t.jsx)("line",{x1:"1",y1:"14",x2:"4",y2:"14"})]}),(0,t.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0},children:ak})]}),F&&H&&(B=(A=window.visualViewport?.height??window.innerHeight)-H.top+6,C=Math.max(120,Math.min(H.top-8,.6*A)),(0,t.jsx)("div",{ref:V,style:{position:"fixed",bottom:B,left:H.left,zIndex:500,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,boxShadow:"0 -4px 16px rgba(0,0,0,0.10)",overflow:"hidden",width:"max-content",minWidth:H.width,maxHeight:C,overflowY:"auto"},children:aj.map((a,b)=>(0,t.jsxs)("div",{children:[aj.length>1&&(0,t.jsx)("div",{style:{padding:"6px 12px 4px",fontSize:10,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.07em",borderTop:b>0?"1px solid var(--border)":"none"},children:a.provider}),a.options.map(a=>{let b=a.modelId===f?.modelId&&a.provider===f?.provider;return(0,t.jsxs)("button",{onClick:()=>{G(!1),b||i(a.provider,a.modelId)},style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"7px 12px",background:b?"var(--bg-selected)":"none",border:"none",color:b?"var(--text)":"var(--text-muted)",cursor:"pointer",fontSize:12,textAlign:"left",fontWeight:b?600:400,whiteSpace:"nowrap"},onMouseEnter:a=>{b||(a.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:a=>{b||(a.currentTarget.style.background="none")},children:[b?(0,t.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:(0,t.jsx)("polyline",{points:"1.5 5 4 7.5 8.5 2.5"})}):(0,t.jsx)("span",{style:{width:10,flexShrink:0}}),a.name]},`${a.provider}:${a.modelId}`)})]},a.provider))}))]})]}),(0,t.jsx)("div",{className:"chat-input-toolbar-spacer",style:{flex:1}}),(0,t.jsxs)("div",{className:"chat-input-toolbar-right",style:{flex:"0 0 auto",display:"flex",alignItems:"center",gap:2,marginLeft:"auto"},children:[!e&&q&&(0,t.jsxs)("div",{ref:X,style:{position:"relative"},children:[(0,t.jsxs)("button",{onClick:()=>!e&&M(a=>!a),disabled:e,title:"切换推理强度",style:{display:"flex",alignItems:"center",gap:5,padding:"8px 12px",height:32,background:L?"var(--bg-hover)":"none",border:"none",borderRadius:9,color:"var(--text-muted)",cursor:e?"not-allowed":"pointer",fontSize:12,opacity:e?.5:1,transition:"background 0.12s, color 0.12s"},onMouseEnter:a=>{e||(a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="var(--text)")},onMouseLeave:a=>{a.currentTarget.style.background=L?"var(--bg-hover)":"none",a.currentTarget.style.color="var(--text-muted)"},children:[(0,t.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("path",{d:"M9.5 2A5.5 5.5 0 0 0 4 7.5c0 1.7.78 3.21 2 4.21V14a1 1 0 0 0 1 1h5a1 1 0 0 0 1-1v-2.29c1.22-1 2-2.51 2-4.21A5.5 5.5 0 0 0 9.5 2z"}),(0,t.jsx)("line",{x1:"7",y1:"18",x2:"12",y2:"18"}),(0,t.jsx)("line",{x1:"8",y1:"21",x2:"11",y2:"21"})]}),(0,t.jsx)("span",{children:(()=>{let a=p??"auto";if("auto"===a||!s)return a;let b=s[a];return null!=b?b:a})()})]}),L&&(0,t.jsx)("div",{style:{position:"absolute",bottom:"calc(100% + 6px)",right:0,zIndex:100,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,boxShadow:"0 -4px 16px rgba(0,0,0,0.10)",overflow:"hidden",minWidth:180},children:ln.filter(a=>!r||"auto"===a||r.includes(a)).map(a=>{let b=(p??"auto")===a,c=lo[a],d="auto"!==a&&s?s[a]:void 0,e=null!=d&&d!==a?d:a,f=null!=d&&d!==a;return(0,t.jsxs)("button",{onClick:()=>{M(!1),b||q(a)},style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"7px 12px",background:b?"var(--bg-selected)":"none",border:"none",color:b?"var(--text)":"var(--text-muted)",cursor:"pointer",fontSize:12,textAlign:"left",fontWeight:b?600:400,whiteSpace:"nowrap"},onMouseEnter:a=>{b||(a.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:a=>{b||(a.currentTarget.style.background="none")},children:[b?(0,t.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:(0,t.jsx)("polyline",{points:"1.5 5 4 7.5 8.5 2.5"})}):(0,t.jsx)("span",{style:{width:10,flexShrink:0}}),(0,t.jsxs)("span",{style:{flex:1},children:[e,f&&(0,t.jsxs)("span",{style:{fontSize:10,color:"var(--text-dim)",fontFamily:"var(--font-mono)",marginLeft:5},children:["(",a,")"]})]}),(0,t.jsx)("span",{style:{fontSize:11,color:"var(--text-dim)",marginLeft:8},children:c})]},a)})})]}),!e&&o&&(0,t.jsxs)("div",{ref:W,style:{position:"relative"},children:[(0,t.jsxs)("button",{onClick:()=>!e&&K(a=>!a),disabled:e,title:"切换工具预设",style:{display:"flex",alignItems:"center",gap:5,padding:"8px 12px",height:32,background:J?"var(--bg-hover)":"none",border:"none",borderRadius:9,color:"var(--text-muted)",cursor:e?"not-allowed":"pointer",fontSize:12,opacity:e?.5:1,transition:"background 0.12s, color 0.12s"},onMouseEnter:a=>{e||(a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="var(--text)")},onMouseLeave:a=>{a.currentTarget.style.background=J?"var(--bg-hover)":"none",a.currentTarget.style.color="var(--text-muted)"},children:[(0,t.jsx)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,t.jsx)("path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"})}),(0,t.jsx)("span",{children:Object.entries(ll).find(([,a])=>a===(n??"full"))?.[0]??"full"})]}),J&&(0,t.jsx)("div",{style:{position:"absolute",bottom:"calc(100% + 6px)",right:0,zIndex:100,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,boxShadow:"0 -4px 16px rgba(0,0,0,0.10)",overflow:"hidden",minWidth:120},children:lk.map(a=>{let b=ll[a],c=(n??"full")===b,d="agent"===a&&!1===N,e=d?"需安装 pi-subagents":lm[a];return(0,t.jsxs)("button",{onClick:()=>{!d&&(K(!1),c||o(b))},disabled:d,title:d?"运行 pi install npm:pi-subagents 后再启用":void 0,style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"7px 12px",background:c?"var(--bg-selected)":"none",border:"none",color:c?"var(--text)":"var(--text-muted)",cursor:d?"not-allowed":"pointer",fontSize:12,textAlign:"left",fontWeight:c?600:400,opacity:d?.5:1,whiteSpace:"nowrap"},onMouseEnter:a=>{c||d||(a.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:a=>{c||(a.currentTarget.style.background="none")},children:[c?(0,t.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:(0,t.jsx)("polyline",{points:"1.5 5 4 7.5 8.5 2.5"})}):(0,t.jsx)("span",{style:{width:10,flexShrink:0}}),(0,t.jsx)("span",{style:{flex:1},children:a}),(0,t.jsx)("span",{style:{fontSize:11,color:"var(--text-dim)",marginLeft:8},children:e})]},a)})})]}),!e&&j&&(0,t.jsxs)("div",{style:{position:"relative"},children:[m&&(0,t.jsx)("div",{style:{position:"absolute",bottom:"calc(100% + 6px)",right:0,background:"#1f2937",color:"#f87171",fontSize:11,padding:"4px 8px",borderRadius:5,whiteSpace:"nowrap",pointerEvents:"none",boxShadow:"0 2px 8px rgba(0,0,0,0.2)",zIndex:50},children:m}),(0,t.jsx)("button",{onClick:l?k:j,disabled:e&&!l,style:{display:"flex",alignItems:"center",gap:5,padding:"8px 12px",height:32,background:l?"rgba(239,68,68,0.08)":"none",border:"none",borderRadius:9,color:l?"#ef4444":"var(--text-muted)",cursor:e&&!l?"not-allowed":"pointer",fontSize:12,opacity:e&&!l?.5:1,transition:"background 0.12s, color 0.12s"},onMouseEnter:a=>{(!e||l)&&(a.currentTarget.style.background=l?"rgba(239,68,68,0.16)":"var(--bg-hover)",a.currentTarget.style.color=l?"#ef4444":"var(--text)")},onMouseLeave:a=>{a.currentTarget.style.background=l?"rgba(239,68,68,0.08)":"none",a.currentTarget.style.color=l?"#ef4444":"var(--text-muted)"},title:l?"停止压缩":"压缩上下文",children:l?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:(0,t.jsx)("rect",{x:"2",y:"2",width:"6",height:"6",rx:"1",fill:"currentColor"})}),"Compacting…"]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("polyline",{points:"4 14 10 14 10 20"}),(0,t.jsx)("polyline",{points:"20 10 14 10 14 4"}),(0,t.jsx)("line",{x1:"10",y1:"14",x2:"3",y2:"21"}),(0,t.jsx)("line",{x1:"21",y1:"3",x2:"14",y2:"10"})]}),"Compact"]})})]}),e&&(0,t.jsxs)("button",{onClick:b,title:"停止 Agent",style:{display:"flex",alignItems:"center",gap:6,padding:"8px 14px",height:32,background:"rgba(239,68,68,0.08)",border:"1px solid rgba(239,68,68,0.3)",borderRadius:9,color:"#ef4444",cursor:"pointer",fontSize:12,fontWeight:600,whiteSpace:"nowrap",letterSpacing:"-0.01em",transition:"background 0.12s"},onMouseEnter:a=>{a.currentTarget.style.background="rgba(239,68,68,0.16)"},onMouseLeave:a=>{a.currentTarget.style.background="rgba(239,68,68,0.08)"},children:[(0,t.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:(0,t.jsx)("rect",{x:"1.5",y:"1.5",width:"7",height:"7",rx:"1.5",fill:"currentColor"})}),"Stop"]}),void 0!==x&&(0,t.jsx)("button",{onClick:x,title:w?"关闭完成提示音":"开启完成提示音",style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,padding:0,background:"none",border:"none",borderRadius:9,color:w?"var(--text-muted)":"var(--text-dim)",cursor:"pointer",opacity:w?1:.55,transition:"background 0.12s, color 0.12s, opacity 0.12s"},onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="var(--text)",a.currentTarget.style.opacity="1"},onMouseLeave:a=>{a.currentTarget.style.background="none",a.currentTarget.style.color=w?"var(--text-muted)":"var(--text-dim)",a.currentTarget.style.opacity=w?"1":"0.55"},children:w?(0,t.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),(0,t.jsx)("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07"}),(0,t.jsx)("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14"})]}):(0,t.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),(0,t.jsx)("line",{x1:"23",y1:"9",x2:"17",y2:"15"}),(0,t.jsx)("line",{x1:"17",y1:"9",x2:"23",y2:"15"})]})})]})]})]})]})});function lx(a){return"user"===a.role?{bg:"rgba(37,99,235,0.18)",border:"rgba(37,99,235,0.7)"}:{bg:"rgba(107,114,128,0.12)",border:"rgba(107,114,128,0.5)"}}function ly({messages:a,streamingMessage:b,scrollContainer:c,messageRefs:d}){let[e,f]=(0,u.useState)(0),[g,h]=(0,u.useState)(1),[i,j]=(0,u.useState)(!1),[k,l]=(0,u.useState)([]),[m,n]=(0,u.useState)(!1),[o,p]=(0,u.useState)(null),q=(0,u.useRef)(!1),r=(0,u.useRef)(null),s=(0,u.useMemo)(()=>b?[...a,b]:a,[a,b]),v=(0,u.useRef)(s);v.current=s;let w=(0,u.useRef)(null);w.current=()=>{let a=c.current;if(!a)return;let b=a.scrollHeight,e=a.clientHeight,g=b-e;j(g>20),g<=0?(f(0),h(1)):(f(a.scrollTop/g),h(e/b));let i=d.current,k=[],m=0,n=v.current;for(let c=0;c<n.length;c++){let d=n[c];if("user"!==d.role&&"assistant"!==d.role)continue;let e=i?.[m];if(m++,("user"===d.role||"assistant"===d.role&&(d.content??[]).some(a=>"text"===a.type))&&e&&b>0){let c=e.getBoundingClientRect(),f=a.getBoundingClientRect(),g=c.top-f.top+a.scrollTop,h=c.height;k.push({topRatio:g/b,heightRatio:h/b,msg:d,index:k.length})}}l(k)},(0,u.useCallback)(()=>w.current(),[]);let x=(0,u.useCallback)(a=>{let b=c.current;if(!b)return;let d=b.scrollHeight-b.clientHeight;d<=0||(b.scrollTop=Math.max(0,Math.min(1-g,a))/(1-g)*d)},[c,g]),y=(0,u.useCallback)(a=>{if(!i)return;q.current=!0;let b=a.currentTarget.getBoundingClientRect(),c=(a.clientY-b.top)/b.height,d=c-e*(1-g),f=d>=0&&d<=g?d:g/2;x(c-f);let h=a=>{q.current&&x((a.clientY-b.top)/b.height-f)},j=()=>{q.current=!1,window.removeEventListener("mousemove",h),window.removeEventListener("mouseup",j)};window.addEventListener("mousemove",h),window.addEventListener("mouseup",j)},[i,g,e,x]),z=r.current?.clientHeight??600,A=(0,u.useMemo)(()=>{if(!m||0===k.length)return[];let a=k.map(a=>Math.round(a.topRatio*z-11));for(let b=0;b<10;b++){for(let b=1;b<a.length;b++){let c=a[b-1]+22+2;a[b]<c&&(a[b]=c)}for(let b=a.length-2;b>=0;b--){let c=a[b+1]-22-2;a[b]>c&&(a[b]=c)}}for(let b=0;b<a.length;b++)a[b]=Math.max(0,Math.min(z-22,a[b]));return a},[m,k,z]);if(!i)return null;let B=e*(1-g)*100,C=100*g,D=null!==o&&k.length>0?k.reduce((a,b)=>Math.abs(b.topRatio-o)<Math.abs(k[a].topRatio-o)?b.index:a,0):null;return(0,t.jsxs)("div",{ref:r,onMouseDown:y,onMouseEnter:()=>n(!0),onMouseLeave:()=>{n(!1),p(null)},onMouseMove:a=>{let b=a.currentTarget.getBoundingClientRect();p((a.clientY-b.top)/b.height)},style:{width:36,flexShrink:0,position:"relative",cursor:"default",userSelect:"none",borderLeft:"1px solid var(--border)",background:"var(--bg-panel)",overflow:"visible"},children:[(0,t.jsx)("div",{style:{position:"absolute",left:0,right:0,top:`${B}%`,height:`${C}%`,background:"rgba(100,100,100,0.1)",borderTop:"1px solid rgba(100,100,100,0.2)",borderBottom:"1px solid rgba(100,100,100,0.2)",pointerEvents:"none",zIndex:1}}),k.map(a=>{let b=lx(a.msg),c=m&&D===a.index,d="user"===a.msg.role,e=100*a.topRatio;return(0,t.jsx)("div",{style:{position:"absolute",top:`${e}%`,transform:"translateY(-50%)",left:0,right:0,height:"12px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",zIndex:2},children:(0,t.jsx)("div",{style:{width:d?8:6,height:d?8:6,borderRadius:d?2:"50%",background:b.bg,border:`1.5px solid ${b.border}`,flexShrink:0,transition:"transform 0.1s",transform:c?"scale(1.6)":"scale(1)"}})},a.index)}),(0,t.jsx)("div",{style:{position:"absolute",left:"50%",top:0,bottom:0,width:1,background:"var(--border)",transform:"translateX(-50%)",zIndex:0}}),m&&k.map((a,b)=>{let c=function(a){if("user"===a.role){let b=a.content;return"string"==typeof b?b.slice(0,200):Array.isArray(b)?b.filter(a=>"text"===a.type&&a.text).map(a=>a.text).join("\n").slice(0,200):""}if("assistant"===a.role){let b=a.content??[],c=b.filter(a=>"text"===a.type).map(a=>a.text).join(" ");if(c)return c.slice(0,200);let d=b.filter(a=>"toolCall"===a.type).map(a=>a.toolName);if(d.length)return d.join(", ")}return""}(a.msg),d=lx(a.msg),e=D===a.index;return c&&0!==A.length?(0,t.jsx)("div",{style:{position:"absolute",top:A[b],right:"100%",marginRight:6,background:"var(--bg)",borderTop:`1px solid ${e?d.border:"var(--border)"}`,borderRight:`1px solid ${e?d.border:"var(--border)"}`,borderBottom:`1px solid ${e?d.border:"var(--border)"}`,borderLeft:`2px solid ${d.border}`,borderRadius:4,padding:"2px 7px",width:200,zIndex:100,pointerEvents:"none",opacity:e?1:.45,transition:"top 0.1s, opacity 0.1s"},children:(0,t.jsx)("div",{style:{fontSize:11,color:e?"var(--text)":"var(--text-muted)",lineHeight:1.4,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:c})},a.index):null})]})}function lz(a){return"object"==typeof a&&null!==a&&!Array.isArray(a)}function lA(a,b=220){if(!a)return;let c=a.trim();if(c)return c.length>b?`${c.slice(0,b)}...`:c}function lB(...a){for(let b of a)if("string"==typeof b&&b.trim())return b}function lC(...a){for(let b of a)if("number"==typeof b&&Number.isFinite(b))return b}function lD(a){let b=new Map;for(let c of a){if("custom"===c.role&&"subagent-notify"===c.customType&&"string"==typeof c.content){let a=c.content.match(/^Background task (completed|failed|paused):\s*\*\*(.+?)\*\*(?:\s+\((.+?)\))?/);if(a){let d=`bg-${a[2]}-${c.timestamp??""}`;b.set(d,{id:d,agent:a[2],status:a[1],task:a[3],summary:lA(c.content.split("\n").slice(3).join("\n")),timestamp:c.timestamp})}}if("assistant"===c.role){let a=c.content;if(!a)continue;for(let d of a)if("toolCall"===d.type&&"subagent"===d.toolName&&d.input){let a=d.input,e=a.agent??(a.chain?"chain":a.tasks?"parallel":a.action??"subagent"),f="string"==typeof a.task?a.task:void 0,g=d.toolCallId??`sub-${e}-${c.timestamp??Date.now()}`;b.set(g,{id:g,agent:e,status:"running",task:f,timestamp:c.timestamp})}}if("toolResult"===c.role){if(c.toolName&&"subagent"!==c.toolName||!c.toolCallId||!b.has(c.toolCallId))continue;let a=b.get(c.toolCallId),d=c.content.filter(a=>"text"===a.type).map(a=>a.text).join("\n");b.set(c.toolCallId,function(a,b,c){let d;if(!lz(b))return{...a,summary:lA(c)};let e=Array.isArray(b.results)?b.results.filter(lz):[],f=e[0],g=f?.progressSummary,h=f&&(d=f.artifactPaths)?Object.values(d).filter(a=>"string"==typeof a&&a.trim().length>0):[],i=lB(f?.finalOutput,f?.output,c);return{...a,mode:lB(b.mode),runId:lB(b.runId),agent:lB(f?.agent,a.agent)??a.agent,task:lB(f?.task,a.task),summary:lA(i),model:lB(f?.model),durationMs:lC(g?.durationMs),toolCount:lC(g?.toolCount),tokens:lC(g?.tokens),outputPath:lB(f?.savedOutputPath,f?.artifactPaths?.outputPath),sessionFile:lB(f?.sessionFile,f?.artifactPaths?.jsonlPath),artifacts:h,resultCount:e.length||void 0}}({...a,status:function(a){if(a.isError)return"failed";let b=a.details;return lz(b)&&Array.isArray(b.results)&&b.results.some(a=>lz(a)&&"number"==typeof a.exitCode&&0!==a.exitCode)?"failed":"completed"}(c)},c.details,d))}}return Array.from(b.values()).sort((a,b)=>(b.timestamp??0)-(a.timestamp??0))}function lE({messages:a,runs:b}){let c=(0,u.useMemo)(()=>lD(a??[]),[a]),d=b??c,e=d.filter(a=>"running"===a.status),f=d.filter(a=>"running"!==a.status);return 0===d.length?null:(0,t.jsxs)("div",{style:{height:"100%",overflow:"auto",padding:12},children:[e.length>0&&(0,t.jsx)(lF,{title:`Active (${e.length})`,runs:e}),f.length>0&&(0,t.jsx)(lF,{title:`Completed (${f.length})`,runs:f,compact:e.length>0})]})}function lF({title:a,runs:b,compact:c}){return(0,t.jsxs)("div",{style:{marginBottom:c?10:16},children:[(0,t.jsx)("div",{style:{fontSize:11,fontWeight:600,color:"var(--text-dim)",marginBottom:8,textTransform:"uppercase",letterSpacing:"0.05em"},children:a}),b.map(a=>(0,t.jsx)(lG,{run:a},a.id))]})}function lG({run:a}){let[b,c]=(0,u.useState)(!1),d="running"===a.status,e="completed"===a.status?"#22c55e":"failed"===a.status?"#ef4444":d?"var(--accent)":"var(--text-dim)",f="failed"===a.status?"rgba(248,113,113,0.35)":d?"rgba(99,102,241,0.25)":"var(--border)",g="failed"===a.status?"rgba(248,113,113,0.05)":d?"rgba(99,102,241,0.05)":"var(--bg-panel)",h=[a.mode,a.resultCount&&a.resultCount>1?`${a.resultCount} results`:void 0,void 0!==a.toolCount?`${a.toolCount} tools`:void 0,void 0!==a.tokens?`${a.tokens.toLocaleString()} tok`:void 0,void 0!==a.durationMs?`${Math.round(a.durationMs/1e3)}s`:void 0].filter(Boolean).join(" \xb7 "),i=!!(a.summary||a.outputPath||a.sessionFile||a.artifacts?.length||a.model||a.runId);return(0,t.jsxs)("div",{style:{borderRadius:6,border:`1px solid ${f}`,background:g,marginBottom:6,fontSize:12,overflow:"hidden"},children:[(0,t.jsxs)("button",{onClick:()=>i&&c(a=>!a),style:{display:"flex",alignItems:"center",gap:7,width:"100%",border:"none",background:"transparent",padding:"8px 10px",color:"var(--text-muted)",textAlign:"left",cursor:i?"pointer":"default"},children:[(0,t.jsx)(lH,{running:d,color:e}),(0,t.jsx)("span",{style:{fontWeight:650,color:"var(--text)",minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a.agent}),(0,t.jsx)("span",{style:{color:e,fontSize:10,fontWeight:700,flexShrink:0},children:a.status}),h&&(0,t.jsx)("span",{style:{color:"var(--text-dim)",fontSize:10,marginLeft:"auto",whiteSpace:"nowrap"},children:h}),i&&(0,t.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--text-dim)",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,transform:b?"rotate(180deg)":"none",transition:"transform 0.15s"},children:(0,t.jsx)("polyline",{points:"2 3.5 5 6.5 8 3.5"})})]}),a.task&&(0,t.jsx)("div",{style:{padding:"0 10px 8px 25px",color:"var(--text-muted)",fontSize:11,lineHeight:1.4},children:lA(a.task,150)}),b&&i&&(0,t.jsxs)("div",{style:{borderTop:`1px solid ${f}`,background:"var(--bg)",padding:"8px 10px",display:"flex",flexDirection:"column",gap:7},children:[a.summary&&(0,t.jsx)("pre",{style:{margin:0,color:"var(--text-muted)",fontSize:11,lineHeight:1.45,whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:160,overflow:"auto"},children:a.summary}),(0,t.jsx)(lI,{run:a})]})]})}function lH({running:a,color:b}){return(0,t.jsx)("span",{style:{width:8,height:8,borderRadius:"50%",background:b,display:"inline-block",animation:a?"pulse 1.5s infinite":void 0,flexShrink:0}})}function lI({run:a}){let b=[a.model?["model",a.model]:void 0,a.runId?["run",a.runId]:void 0,a.outputPath?["output",a.outputPath]:void 0,a.sessionFile?["session",a.sessionFile]:void 0,...(a.artifacts??[]).slice(0,4).map((a,b)=>[`artifact ${b+1}`,a])].filter(Boolean);return 0===b.length?null:(0,t.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:3},children:b.map(([a,b])=>(0,t.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"58px minmax(0, 1fr)",gap:6,fontSize:10},children:[(0,t.jsx)("span",{style:{color:"var(--text-dim)",textTransform:"uppercase"},children:a}),(0,t.jsx)("span",{style:{color:"var(--text-muted)",fontFamily:"var(--font-mono)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:b,children:b})]},`${a}:${b}`))})}function lJ(a){if("assistant"!==a.role)return a;let b=a.content;if(!Array.isArray(b))return a;let c=b.map(a=>("object"!=typeof a||null===a||Array.isArray(a)||"toolCall"!==a.type?null:{type:"toolCall",toolCallId:"string"==typeof a.toolCallId?a.toolCallId:"string"==typeof a.id?a.id:"",toolName:"string"==typeof a.toolName?a.toolName:"string"==typeof a.name?a.name:"",input:"object"!=typeof a.input||null===a.input||Array.isArray(a.input)?"object"!=typeof a.arguments||null===a.arguments||Array.isArray(a.arguments)?{}:a.arguments:a.input})??a);return{...a,content:c}}async function lK(a,b){let c=await fetch(`/api/agent/${encodeURIComponent(a)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),d=await c.json().catch(()=>({}));if(!c.ok||d.error)throw Error(d.error??`HTTP ${c.status}`);return d.data}var lL=c(29947);function lM(a,b){switch(b.type){case"start":return{isStreaming:!0,streamingMessage:null};case"update":return{isStreaming:!0,streamingMessage:b.message};case"end":case"reset":return{isStreaming:!1,streamingMessage:null};default:return a}}function lN(a){if("user"!==a.role)return null;var b=a.content;if("string"==typeof b)return`text:${b}`;if(!Array.isArray(b))try{return`other:${JSON.stringify(b)}`}catch{return"other:"}let c=b.map(a=>{if(!a||"object"!=typeof a)return a;if("text"===a.type)return{type:"text",text:a.text};if("image"===a.type){let b=a.source&&"object"==typeof a.source?a.source:{};return{type:"image",mimeType:b.media_type??a.mimeType,data:b.data??a.data,url:b.url}}return a});try{return`blocks:${JSON.stringify(c)}`}catch{return"blocks:"}}function lO(a){if(!a.role)return null;try{return`${a.role}:${JSON.stringify(a)}`}catch{return null}}let lP=["image/","application/pdf","application/vnd.openxmlformats-officedocument","application/msword","application/vnd.ms-"];function lQ(a){return lP.some(b=>a.type.startsWith(b))}let lR=["annotate and analyze.","vibe code bioinformatics.","turn data into figures.","inspect your project.","build a reproducible report.","run R/Python plots.","summarize that paper.","review the pipeline.","compare markers.","draft methods.","find the next analysis step."];function lS({phrases:a}){let[b,c]=(0,u.useState)(()=>Math.floor(Math.random()*a.length)),[d,e]=(0,u.useState)(""),[f,g]=(0,u.useState)(!1),[h,i]=(0,u.useState)(!0);return(0,t.jsxs)("span",{style:{color:"var(--text-muted)",fontWeight:400},children:[d,(0,t.jsx)("span",{style:{opacity:+!!h,color:"var(--accent)",marginLeft:1},children:"▍"})]})}function lT({status:a}){let b=a?.current??"0.8.23"??"0.0.0";if(a?.updateAvailable){let c=a.latest?`v${a.latest}`:"latest";return(0,t.jsxs)("span",{title:`Current v${b}; latest ${c}; run ${a.updateCommand}`,style:{display:"block",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:11,color:"var(--accent)"},children:["Update: ",(0,t.jsx)("code",{style:{fontFamily:"var(--font-mono)",color:"var(--accent)"},children:a.updateCommand})]})}return(0,t.jsxs)("span",{title:`AnnoVibe v${b}`,style:{fontSize:11,color:"var(--text-dim)",whiteSpace:"nowrap"},children:["v",b]})}function lU({session:a,newSessionCwd:b,onAgentEnd:d,onSessionCreated:e,onSessionForked:f,modelsRefreshKey:g,chatInputRef:h,onBranchDataChange:i,onSystemPromptChange:j,onSessionStatsChange:k,onContextUsageChange:l,onReportUpdated:m,generativeUI:n}){var o;let p,{data:q,loading:r,error:s,messages:v,entryIds:w,streamState:x,activeLeafId:y,agentRunning:z,modelNames:A,modelList:B,modelThinkingLevels:C,modelThinkingLevelMaps:D,toolPreset:E,thinkingLevel:F,retryInfo:G,contextUsage:H,forkingEntryId:I,isCompacting:J,compactError:K,displayModel:L,sessionStats:M,agentPhase:N,agentError:O,isNew:P,messagesEndRef:Q,scrollContainerRef:R,lastUserMsgRef:S,handleSend:T,handleAbort:U,handleFork:V,handleNavigate:W,handleModelChange:X,handleCompact:Y,handleSteer:Z,handleFollowUp:$,handleAbortCompaction:_,handleToolPresetChange:aa,handleThinkingLevelChange:ab,handleAgentEventRef:ac}=function(a){let{session:b,newSessionCwd:d,onAgentEnd:e,onSessionCreated:f,onSessionForked:g,modelsRefreshKey:h,onBranchDataChange:i,onSystemPromptChange:j}=a,k=null===b&&null!==d,[l,m]=(0,u.useState)(null),[n,o]=(0,u.useState)(!k),[p,q]=(0,u.useState)(null),[r,s]=(0,u.useState)(null),[t,v]=(0,u.useState)([]),[w,x]=(0,u.useState)([]),[y,z]=(0,u.useReducer)(lM,{isStreaming:!1,streamingMessage:null}),[A,B]=(0,u.useState)(!1),[C,D]=(0,u.useState)({}),[E,F]=(0,u.useState)([]),[G,H]=(0,u.useState)({}),[I,J]=(0,u.useState)({}),[K,L]=(0,u.useState)(null),[M,N]=(0,u.useState)("full"),[O,P]=(0,u.useState)("auto"),[Q,R]=(0,u.useState)(null),[S,T]=(0,u.useState)(null),[U,V]=(0,u.useState)(null),[W,X]=(0,u.useState)(null),[Y,Z]=(0,u.useState)(null),[$,_]=(0,u.useState)(null),[aa,ab]=(0,u.useState)(!1),[ac,ad]=(0,u.useState)(null),[ae,af]=(0,u.useState)(null),[ag,ah]=(0,u.useState)(null),ai=(0,u.useRef)(null),aj=(0,u.useRef)(b?.id??null),ak=(0,u.useRef)(!1),al=(0,u.useRef)(null),am=(0,u.useRef)(!1),an=(0,u.useRef)(null),ao=(0,u.useRef)(!1),ap=(0,u.useRef)(null),aq=(0,u.useRef)(null),ar=(0,u.useRef)(new Map),as=(0,u.useRef)(new Set),at=a.setNewSessionModel??L,au=a.setToolPreset??N,av=Y??l?.context.model??$??null,aw=k?K:av,ax=(0,u.useCallback)(a=>a?.length?a.map((a,b)=>{let c=`Attachment ${b+1}: ${a.fileName} (${a.mimeType||"application/octet-stream"}, ${a.size} bytes)`;if(a.extractedText){let b=a.truncated?"\n[The extracted text was truncated before sending.]":"";return`${c}
249
+ [truncated after 60000 characters]`,truncated:!0};if(!f)return{extractionError:"No extractable text found"};return{extractedText:f,truncated:g}}catch(a){return{extractionError:a instanceof Error?a.message:String(a)}}}let lw=(0,u.forwardRef)(function({onSend:a,onAbort:b,onSteer:c,onFollowUp:d,isStreaming:e,model:f,modelNames:g,modelList:h,onModelChange:i,onCompact:j,onAbortCompaction:k,isCompacting:l,compactError:m,toolPreset:n,onToolPresetChange:o,thinkingLevel:p,onThinkingLevelChange:q,availableThinkingLevels:r,thinkingLevelMap:s,retryInfo:v,soundEnabled:w,onSoundToggle:x,cornerBadge:y},z){let A,B,C,[D,E]=(0,u.useState)(""),[F,G]=(0,u.useState)(!1),[H,I]=(0,u.useState)(null),[J,K]=(0,u.useState)(!1),[L,M]=(0,u.useState)(!1),[N,O]=(0,u.useState)(null),[P,Q]=(0,u.useState)([]),[R,S]=(0,u.useState)([]),T=(0,u.useRef)(null),U=(0,u.useRef)(null),V=(0,u.useRef)(null),W=(0,u.useRef)(null),X=(0,u.useRef)(null),Y=(0,u.useRef)(null),Z=(0,u.useRef)(null);(0,u.useImperativeHandle)(z,()=>({insertIfEmpty(a){let b=T.current;(b?b.value:D).trim()||(E(a),requestAnimationFrame(()=>{b&&(b.focus(),b.style.height="auto",b.style.height=`${Math.min(b.scrollHeight,200)}px`)}))},insertText(a){let b=T.current;if(!b)return void E(b=>b+(b?" ":"")+a);let c=b.selectionStart??b.value.length,d=b.selectionEnd??b.value.length,e=b.value.slice(0,c),f=b.value.slice(d),g=e.length>0&&!e.endsWith(" ")?" ":"";E(e+g+a+f),requestAnimationFrame(()=>{if(!b)return;let d=c+g.length+a.length;b.setSelectionRange(d,d),b.focus(),b.style.height="auto",b.style.height=`${Math.min(b.scrollHeight,200)}px`})},addImages(a){$(a)},addFiles(a){_(a)}}));let $=(0,u.useCallback)(async a=>{let b=a.filter(a=>a.type.startsWith("image/"));if(!b.length)return;let c=await Promise.all(b.map(a=>new Promise((b,c)=>{let d=new FileReader;d.onload=()=>{b({data:d.result.split(",")[1],mimeType:a.type,previewUrl:URL.createObjectURL(a)})},d.onerror=c,d.readAsDataURL(a)})));Q(a=>[...a,...c])},[]),_=(0,u.useCallback)(async a=>{let b=a.filter(a=>a.type.startsWith("image/")),c=a.filter(a=>!a.type.startsWith("image/"));if(b.length&&$(b),c.length){let a=await Promise.all(c.map(a=>new Promise((b,c)=>{let d=new FileReader;d.onload=async()=>{let c=d.result,e=await lv(a,c);b({data:c,fileName:a.name,mimeType:a.type||"application/octet-stream",size:a.size,...e})},d.onerror=c,d.readAsArrayBuffer(a)})));S(b=>[...b,...a])}},[$]),aa=(0,u.useCallback)(a=>{Q(b=>{let c=[...b];return URL.revokeObjectURL(c[a].previewUrl),c.splice(a,1),c})},[]),ab=(0,u.useCallback)(a=>{S(b=>{let c=[...b];return c.splice(a,1),c})},[]),ac=(0,u.useCallback)(()=>{Q(a=>(a.forEach(a=>URL.revokeObjectURL(a.previewUrl)),[])),S([])},[]),ad=(0,u.useCallback)(()=>{let b=D.trim();(b||P.length||R.length)&&!e&&(a(b,P.length?P:void 0,R.length?R:void 0),E(""),ac(),T.current&&(T.current.style.height="auto"))},[D,P,R,e,a,ac]),ae=(0,u.useCallback)(a=>{let b=D.trim();if(!b&&!P.length&&!R.length)return;let e=P.length?P:void 0,f=R.length?R:void 0;"steer"===a&&c?c(b,e,f):"followup"===a&&d&&d(b,e,f),E(""),ac(),T.current&&(T.current.style.height="auto")},[D,P,R,c,d,ac]),af=(0,u.useCallback)(a=>{"Enter"!==a.key||a.shiftKey||a.nativeEvent.isComposing||(a.preventDefault(),e&&(c||d)?ae(c?"steer":"followup"):ad())},[e,c,d,ae,ad]),ag=(0,u.useCallback)(()=>{let a=T.current;a&&(a.style.height="auto",a.style.height=`${Math.min(a.scrollHeight,200)}px`)},[]),ah=(0,u.useCallback)(a=>{let b=Array.from(a.clipboardData?.items??[]).filter(a=>"file"===a.kind&&(a.type.startsWith("image/")||a.type.includes("pdf")||a.type.includes("officedocument")||a.type.includes("msword")||a.type.includes("ms-")));b.length&&(a.preventDefault(),_(b.map(a=>a.getAsFile()).filter(a=>null!==a)))},[_]),ai=h&&h.length>0?h.map(a=>({provider:a.provider,modelId:a.id,name:a.name})):Object.entries(g??{}).map(([a,b])=>({provider:f?.provider??"unknown",modelId:a,name:b})),aj=[];for(let a of ai){let b=aj.find(b=>b.provider===a.provider);b?b.options.push(a):aj.push({provider:a.provider,options:[a]})}let ak=f?ai.find(a=>a.modelId===f.modelId&&a.provider===f.provider)?.name??f.modelId:ai.length>0?ai[0].name:null;return(0,u.useEffect)(()=>{let a=a=>{U.current&&!U.current.contains(a.target)&&V.current&&!V.current.contains(a.target)&&G(!1),W.current&&!W.current.contains(a.target)&&K(!1),X.current&&!X.current.contains(a.target)&&M(!1)};return document.addEventListener("mousedown",a),()=>document.removeEventListener("mousedown",a)},[]),(0,u.useEffect)(()=>{if(!o)return;let a=!1;return fetch("/api/subagents/status").then(a=>a.ok?a.json():null).then(b=>{a||O(!!b?.ready)}).catch(()=>{a||O(!1)}),()=>{a=!0}},[o]),(0,t.jsxs)("div",{style:{flexShrink:0,background:"transparent",padding:"0 16px 8px",paddingRight:52},children:[(0,t.jsx)("input",{ref:Y,type:"file",accept:"image/*",multiple:!0,style:{display:"none"},onChange:a=>{$(Array.from(a.target.files??[])),a.target.value=""}}),(0,t.jsx)("input",{ref:Z,type:"file",accept:".pdf,.docx,.xlsx,.pptx,.doc,.xls,.ppt,application/pdf,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.openxmlformats-officedocument.presentationml.presentation",multiple:!0,style:{display:"none"},onChange:a=>{_(Array.from(a.target.files??[])),a.target.value=""}}),(0,t.jsxs)("div",{style:{maxWidth:820,margin:"0 auto",position:"relative"},children:[y&&(0,t.jsx)("div",{style:{position:"absolute",right:8,top:-22,display:"flex",alignItems:"center",justifyContent:"flex-end",maxWidth:"min(320px, 60vw)",minHeight:18,zIndex:2,fontFamily:"var(--font-mono)",overflow:"hidden"},children:y}),v&&(0,t.jsxs)("div",{style:{marginBottom:8,padding:"5px 10px",background:"rgba(234,179,8,0.08)",border:"1px solid rgba(234,179,8,0.25)",borderRadius:6,fontSize:12,color:"rgba(180,130,0,0.9)",display:"flex",alignItems:"center",gap:6},children:[(0,t.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[(0,t.jsx)("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),(0,t.jsx)("path",{d:"M3 3v5h5"})]}),"Retrying (",v.attempt,"/",v.maxAttempts,")…",v.errorMessage&&(0,t.jsxs)("span",{style:{opacity:.7,marginLeft:4},children:["— ",v.errorMessage]})]}),(P.length>0||R.length>0)&&(0,t.jsxs)("div",{style:{display:"flex",gap:6,marginBottom:6,flexWrap:"wrap",alignItems:"flex-end"},children:[P.map((a,b)=>(0,t.jsxs)("div",{style:{position:"relative",flexShrink:0},children:[(0,t.jsx)("img",{src:a.previewUrl,alt:"",style:{width:56,height:56,objectFit:"cover",borderRadius:6,border:"1px solid var(--border)",display:"block"}}),(0,t.jsx)("button",{onClick:()=>aa(b),style:{position:"absolute",top:-4,right:-4,width:16,height:16,borderRadius:"50%",background:"var(--bg-panel)",border:"1px solid var(--border)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",padding:0,color:"var(--text-muted)"},children:(0,t.jsxs)("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:[(0,t.jsx)("line",{x1:"1",y1:"1",x2:"7",y2:"7"}),(0,t.jsx)("line",{x1:"7",y1:"1",x2:"1",y2:"7"})]})})]},`img-${b}`)),R.map((a,b)=>(0,t.jsx)(lp,{doc:a,onRemove:()=>ab(b)},`doc-${b}`))]}),(0,t.jsxs)("div",{style:{display:"flex",gap:8,alignItems:"center",background:"var(--bg)",border:`1px solid ${e&&(c||d)?"rgba(234,179,8,0.4)":"color-mix(in srgb, var(--border) 70%, transparent)"}`,borderRadius:14,padding:"10px 10px 10px 14px",boxShadow:"0 1px 2px rgba(15,23,42,0.04), 0 8px 24px -12px rgba(15,23,42,0.10)",transition:"border-color 0.15s, background 0.15s, box-shadow 0.15s"},children:[(0,t.jsx)("textarea",{ref:T,value:D,onChange:a=>E(a.target.value),onKeyDown:af,onInput:ag,onPaste:ah,placeholder:e&&(c||d)?"Steer 立即注入 / Follow-up 排队…":e?"Agent is running…":"Message…",rows:1,style:{flex:1,background:"none",border:"none",outline:"none",resize:"none",color:"var(--text)",fontSize:14,lineHeight:1.6,fontFamily:"inherit",minHeight:24,maxHeight:200,overflow:"auto"}}),e?(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,flexShrink:0,alignSelf:"flex-end"},children:[c&&(0,t.jsxs)("button",{onClick:()=>ae("steer"),disabled:!D.trim()&&!P.length&&!R.length,title:"打断 Agent 当前运行,立即注入消息",style:{display:"flex",alignItems:"center",gap:5,padding:"7px 12px",background:D.trim()||P.length||R.length?"rgba(234,179,8,0.12)":"none",border:"1px solid rgba(234,179,8,0.35)",borderRadius:8,color:D.trim()||P.length||R.length?"rgba(180,130,0,1)":"var(--text-dim)",cursor:D.trim()||P.length||R.length?"pointer":"not-allowed",fontSize:13,fontWeight:600,letterSpacing:"-0.01em",transition:"background 0.12s"},children:[(0,t.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("path",{d:"M5 1 L9 5 L5 9"}),(0,t.jsx)("line",{x1:"1",y1:"5",x2:"9",y2:"5"})]}),"Steer"]}),d&&(0,t.jsxs)("button",{onClick:()=>ae("followup"),disabled:!D.trim()&&!P.length&&!R.length,title:"在 Agent 完成后排队发送",style:{display:"flex",alignItems:"center",gap:5,padding:"7px 12px",background:D.trim()||P.length||R.length?"rgba(129,140,248,0.12)":"none",border:"1px solid rgba(129,140,248,0.35)",borderRadius:8,color:D.trim()||P.length||R.length?"rgba(99,102,241,1)":"var(--text-dim)",cursor:D.trim()||P.length||R.length?"pointer":"not-allowed",fontSize:13,fontWeight:600,letterSpacing:"-0.01em",transition:"background 0.12s"},children:[(0,t.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("line",{x1:"5",y1:"1",x2:"5",y2:"6"}),(0,t.jsx)("polyline",{points:"2.5 3.5 5 1 7.5 3.5"}),(0,t.jsx)("line",{x1:"2",y1:"9",x2:"8",y2:"9"})]}),"Follow-up"]})]}):(0,t.jsxs)("button",{onClick:ad,disabled:!D.trim()&&!P.length&&!R.length,style:{flexShrink:0,alignSelf:"flex-end",display:"flex",alignItems:"center",gap:6,padding:"7px 14px",background:D.trim()||P.length||R.length?"var(--accent)":"var(--bg-panel)",border:"none",borderRadius:8,color:D.trim()||P.length||R.length?"#fff":"var(--text-dim)",cursor:D.trim()||P.length||R.length?"pointer":"not-allowed",fontSize:13,fontWeight:600,letterSpacing:"-0.01em",boxShadow:D.trim()||P.length||R.length?"0 1px 3px rgba(37,99,235,0.25)":"none",transition:"background 0.15s, box-shadow 0.15s"},children:[(0,t.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("line",{x1:"2",y1:"7",x2:"11",y2:"7"}),(0,t.jsx)("polyline",{points:"7.5 3 12 7 7.5 11"})]}),"Send"]})]}),(0,t.jsxs)("div",{className:"chat-input-toolbar",style:{marginTop:8,display:"flex",alignItems:"center",gap:6},children:[(0,t.jsxs)("div",{className:"chat-input-toolbar-left",style:{flex:"0 0 auto",display:"flex",alignItems:"center",gap:2},children:[(0,t.jsx)("button",{onClick:()=>Y.current?.click(),disabled:e,title:"Attach image (right-click for document)",style:{flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,padding:0,background:"none",border:"none",borderRadius:9,color:P.length||R.length?"var(--accent)":"var(--text-muted)",cursor:e?"not-allowed":"pointer",opacity:e?.5:1,transition:"background 0.12s, color 0.12s"},onMouseEnter:a=>{e||(a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color=P.length||R.length?"var(--accent)":"var(--text)")},onMouseLeave:a=>{a.currentTarget.style.background="none",a.currentTarget.style.color=P.length||R.length?"var(--accent)":"var(--text-muted)"},onContextMenu:a=>{a.preventDefault(),Z.current?.click()},children:(0,t.jsx)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:(0,t.jsx)("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"})})}),ai.length>0&&ak&&i&&(0,t.jsxs)("div",{ref:U,style:{position:"relative"},children:[(0,t.jsxs)("button",{onClick:a=>{let b=a.currentTarget.getBoundingClientRect();I({top:b.top,left:b.left,width:b.width}),G(a=>!a)},disabled:e,style:{display:"flex",alignItems:"center",gap:6,padding:"8px 12px",height:32,maxWidth:220,overflow:"hidden",background:F?"var(--bg-hover)":"none",border:"none",borderRadius:9,color:"var(--text-muted)",cursor:e?"not-allowed":"pointer",fontSize:12,opacity:e?.5:1,transition:"background 0.12s, color 0.12s"},onMouseEnter:a=>{e||(a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="var(--text)")},onMouseLeave:a=>{a.currentTarget.style.background=F?"var(--bg-hover)":"none",a.currentTarget.style.color="var(--text-muted)"},children:[(0,t.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}),(0,t.jsx)("rect",{x:"9",y:"9",width:"6",height:"6"}),(0,t.jsx)("line",{x1:"9",y1:"1",x2:"9",y2:"4"}),(0,t.jsx)("line",{x1:"15",y1:"1",x2:"15",y2:"4"}),(0,t.jsx)("line",{x1:"9",y1:"20",x2:"9",y2:"23"}),(0,t.jsx)("line",{x1:"15",y1:"20",x2:"15",y2:"23"}),(0,t.jsx)("line",{x1:"20",y1:"9",x2:"23",y2:"9"}),(0,t.jsx)("line",{x1:"20",y1:"14",x2:"23",y2:"14"}),(0,t.jsx)("line",{x1:"1",y1:"9",x2:"4",y2:"9"}),(0,t.jsx)("line",{x1:"1",y1:"14",x2:"4",y2:"14"})]}),(0,t.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0},children:ak})]}),F&&H&&(B=(A=window.visualViewport?.height??window.innerHeight)-H.top+6,C=Math.max(120,Math.min(H.top-8,.6*A)),(0,t.jsx)("div",{ref:V,style:{position:"fixed",bottom:B,left:H.left,zIndex:500,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,boxShadow:"0 -4px 16px rgba(0,0,0,0.10)",overflow:"hidden",width:"max-content",minWidth:H.width,maxHeight:C,overflowY:"auto"},children:aj.map((a,b)=>(0,t.jsxs)("div",{children:[aj.length>1&&(0,t.jsx)("div",{style:{padding:"6px 12px 4px",fontSize:10,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.07em",borderTop:b>0?"1px solid var(--border)":"none"},children:a.provider}),a.options.map(a=>{let b=a.modelId===f?.modelId&&a.provider===f?.provider;return(0,t.jsxs)("button",{onClick:()=>{G(!1),b||i(a.provider,a.modelId)},style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"7px 12px",background:b?"var(--bg-selected)":"none",border:"none",color:b?"var(--text)":"var(--text-muted)",cursor:"pointer",fontSize:12,textAlign:"left",fontWeight:b?600:400,whiteSpace:"nowrap"},onMouseEnter:a=>{b||(a.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:a=>{b||(a.currentTarget.style.background="none")},children:[b?(0,t.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:(0,t.jsx)("polyline",{points:"1.5 5 4 7.5 8.5 2.5"})}):(0,t.jsx)("span",{style:{width:10,flexShrink:0}}),a.name]},`${a.provider}:${a.modelId}`)})]},a.provider))}))]})]}),(0,t.jsx)("div",{className:"chat-input-toolbar-spacer",style:{flex:1}}),(0,t.jsxs)("div",{className:"chat-input-toolbar-right",style:{flex:"0 0 auto",display:"flex",alignItems:"center",gap:2,marginLeft:"auto"},children:[!e&&q&&(0,t.jsxs)("div",{ref:X,style:{position:"relative"},children:[(0,t.jsxs)("button",{onClick:()=>!e&&M(a=>!a),disabled:e,title:"切换推理强度",style:{display:"flex",alignItems:"center",gap:5,padding:"8px 12px",height:32,background:L?"var(--bg-hover)":"none",border:"none",borderRadius:9,color:"var(--text-muted)",cursor:e?"not-allowed":"pointer",fontSize:12,opacity:e?.5:1,transition:"background 0.12s, color 0.12s"},onMouseEnter:a=>{e||(a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="var(--text)")},onMouseLeave:a=>{a.currentTarget.style.background=L?"var(--bg-hover)":"none",a.currentTarget.style.color="var(--text-muted)"},children:[(0,t.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("path",{d:"M9.5 2A5.5 5.5 0 0 0 4 7.5c0 1.7.78 3.21 2 4.21V14a1 1 0 0 0 1 1h5a1 1 0 0 0 1-1v-2.29c1.22-1 2-2.51 2-4.21A5.5 5.5 0 0 0 9.5 2z"}),(0,t.jsx)("line",{x1:"7",y1:"18",x2:"12",y2:"18"}),(0,t.jsx)("line",{x1:"8",y1:"21",x2:"11",y2:"21"})]}),(0,t.jsx)("span",{children:(()=>{let a=p??"auto";if("auto"===a||!s)return a;let b=s[a];return null!=b?b:a})()})]}),L&&(0,t.jsx)("div",{style:{position:"absolute",bottom:"calc(100% + 6px)",right:0,zIndex:100,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,boxShadow:"0 -4px 16px rgba(0,0,0,0.10)",overflow:"hidden",minWidth:180},children:ln.filter(a=>!r||"auto"===a||r.includes(a)).map(a=>{let b=(p??"auto")===a,c=lo[a],d="auto"!==a&&s?s[a]:void 0,e=null!=d&&d!==a?d:a,f=null!=d&&d!==a;return(0,t.jsxs)("button",{onClick:()=>{M(!1),b||q(a)},style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"7px 12px",background:b?"var(--bg-selected)":"none",border:"none",color:b?"var(--text)":"var(--text-muted)",cursor:"pointer",fontSize:12,textAlign:"left",fontWeight:b?600:400,whiteSpace:"nowrap"},onMouseEnter:a=>{b||(a.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:a=>{b||(a.currentTarget.style.background="none")},children:[b?(0,t.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:(0,t.jsx)("polyline",{points:"1.5 5 4 7.5 8.5 2.5"})}):(0,t.jsx)("span",{style:{width:10,flexShrink:0}}),(0,t.jsxs)("span",{style:{flex:1},children:[e,f&&(0,t.jsxs)("span",{style:{fontSize:10,color:"var(--text-dim)",fontFamily:"var(--font-mono)",marginLeft:5},children:["(",a,")"]})]}),(0,t.jsx)("span",{style:{fontSize:11,color:"var(--text-dim)",marginLeft:8},children:c})]},a)})})]}),!e&&o&&(0,t.jsxs)("div",{ref:W,style:{position:"relative"},children:[(0,t.jsxs)("button",{onClick:()=>!e&&K(a=>!a),disabled:e,title:"切换工具预设",style:{display:"flex",alignItems:"center",gap:5,padding:"8px 12px",height:32,background:J?"var(--bg-hover)":"none",border:"none",borderRadius:9,color:"var(--text-muted)",cursor:e?"not-allowed":"pointer",fontSize:12,opacity:e?.5:1,transition:"background 0.12s, color 0.12s"},onMouseEnter:a=>{e||(a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="var(--text)")},onMouseLeave:a=>{a.currentTarget.style.background=J?"var(--bg-hover)":"none",a.currentTarget.style.color="var(--text-muted)"},children:[(0,t.jsx)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,t.jsx)("path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"})}),(0,t.jsx)("span",{children:Object.entries(ll).find(([,a])=>a===(n??"full"))?.[0]??"full"})]}),J&&(0,t.jsx)("div",{style:{position:"absolute",bottom:"calc(100% + 6px)",right:0,zIndex:100,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,boxShadow:"0 -4px 16px rgba(0,0,0,0.10)",overflow:"hidden",minWidth:120},children:lk.map(a=>{let b=ll[a],c=(n??"full")===b,d="agent"===a&&!1===N,e=d?"需安装 pi-subagents":lm[a];return(0,t.jsxs)("button",{onClick:()=>{!d&&(K(!1),c||o(b))},disabled:d,title:d?"运行 pi install npm:pi-subagents 后再启用":void 0,style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"7px 12px",background:c?"var(--bg-selected)":"none",border:"none",color:c?"var(--text)":"var(--text-muted)",cursor:d?"not-allowed":"pointer",fontSize:12,textAlign:"left",fontWeight:c?600:400,opacity:d?.5:1,whiteSpace:"nowrap"},onMouseEnter:a=>{c||d||(a.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:a=>{c||(a.currentTarget.style.background="none")},children:[c?(0,t.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:(0,t.jsx)("polyline",{points:"1.5 5 4 7.5 8.5 2.5"})}):(0,t.jsx)("span",{style:{width:10,flexShrink:0}}),(0,t.jsx)("span",{style:{flex:1},children:a}),(0,t.jsx)("span",{style:{fontSize:11,color:"var(--text-dim)",marginLeft:8},children:e})]},a)})})]}),!e&&j&&(0,t.jsxs)("div",{style:{position:"relative"},children:[m&&(0,t.jsx)("div",{style:{position:"absolute",bottom:"calc(100% + 6px)",right:0,background:"#1f2937",color:"#f87171",fontSize:11,padding:"4px 8px",borderRadius:5,whiteSpace:"nowrap",pointerEvents:"none",boxShadow:"0 2px 8px rgba(0,0,0,0.2)",zIndex:50},children:m}),(0,t.jsx)("button",{onClick:l?k:j,disabled:e&&!l,style:{display:"flex",alignItems:"center",gap:5,padding:"8px 12px",height:32,background:l?"rgba(239,68,68,0.08)":"none",border:"none",borderRadius:9,color:l?"#ef4444":"var(--text-muted)",cursor:e&&!l?"not-allowed":"pointer",fontSize:12,opacity:e&&!l?.5:1,transition:"background 0.12s, color 0.12s"},onMouseEnter:a=>{(!e||l)&&(a.currentTarget.style.background=l?"rgba(239,68,68,0.16)":"var(--bg-hover)",a.currentTarget.style.color=l?"#ef4444":"var(--text)")},onMouseLeave:a=>{a.currentTarget.style.background=l?"rgba(239,68,68,0.08)":"none",a.currentTarget.style.color=l?"#ef4444":"var(--text-muted)"},title:l?"停止压缩":"压缩上下文",children:l?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:(0,t.jsx)("rect",{x:"2",y:"2",width:"6",height:"6",rx:"1",fill:"currentColor"})}),"Compacting…"]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("polyline",{points:"4 14 10 14 10 20"}),(0,t.jsx)("polyline",{points:"20 10 14 10 14 4"}),(0,t.jsx)("line",{x1:"10",y1:"14",x2:"3",y2:"21"}),(0,t.jsx)("line",{x1:"21",y1:"3",x2:"14",y2:"10"})]}),"Compact"]})})]}),e&&(0,t.jsxs)("button",{onClick:b,title:"停止 Agent",style:{display:"flex",alignItems:"center",gap:6,padding:"8px 14px",height:32,background:"rgba(239,68,68,0.08)",border:"1px solid rgba(239,68,68,0.3)",borderRadius:9,color:"#ef4444",cursor:"pointer",fontSize:12,fontWeight:600,whiteSpace:"nowrap",letterSpacing:"-0.01em",transition:"background 0.12s"},onMouseEnter:a=>{a.currentTarget.style.background="rgba(239,68,68,0.16)"},onMouseLeave:a=>{a.currentTarget.style.background="rgba(239,68,68,0.08)"},children:[(0,t.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:(0,t.jsx)("rect",{x:"1.5",y:"1.5",width:"7",height:"7",rx:"1.5",fill:"currentColor"})}),"Stop"]}),void 0!==x&&(0,t.jsx)("button",{onClick:x,title:w?"关闭完成提示音":"开启完成提示音",style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,padding:0,background:"none",border:"none",borderRadius:9,color:w?"var(--text-muted)":"var(--text-dim)",cursor:"pointer",opacity:w?1:.55,transition:"background 0.12s, color 0.12s, opacity 0.12s"},onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-hover)",a.currentTarget.style.color="var(--text)",a.currentTarget.style.opacity="1"},onMouseLeave:a=>{a.currentTarget.style.background="none",a.currentTarget.style.color=w?"var(--text-muted)":"var(--text-dim)",a.currentTarget.style.opacity=w?"1":"0.55"},children:w?(0,t.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),(0,t.jsx)("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07"}),(0,t.jsx)("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14"})]}):(0,t.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),(0,t.jsx)("line",{x1:"23",y1:"9",x2:"17",y2:"15"}),(0,t.jsx)("line",{x1:"17",y1:"9",x2:"23",y2:"15"})]})})]})]})]})]})});function lx(a){return"user"===a.role?{bg:"rgba(37,99,235,0.18)",border:"rgba(37,99,235,0.7)"}:{bg:"rgba(107,114,128,0.12)",border:"rgba(107,114,128,0.5)"}}function ly({messages:a,streamingMessage:b,scrollContainer:c,messageRefs:d}){let[e,f]=(0,u.useState)(0),[g,h]=(0,u.useState)(1),[i,j]=(0,u.useState)(!1),[k,l]=(0,u.useState)([]),[m,n]=(0,u.useState)(!1),[o,p]=(0,u.useState)(null),q=(0,u.useRef)(!1),r=(0,u.useRef)(null),s=(0,u.useMemo)(()=>b?[...a,b]:a,[a,b]),v=(0,u.useRef)(s);v.current=s;let w=(0,u.useRef)(null);w.current=()=>{let a=c.current;if(!a)return;let b=a.scrollHeight,e=a.clientHeight,g=b-e;j(g>20),g<=0?(f(0),h(1)):(f(a.scrollTop/g),h(e/b));let i=d.current,k=[],m=0,n=v.current;for(let c=0;c<n.length;c++){let d=n[c];if("user"!==d.role&&"assistant"!==d.role)continue;let e=i?.[m];if(m++,("user"===d.role||"assistant"===d.role&&(d.content??[]).some(a=>"text"===a.type))&&e&&b>0){let c=e.getBoundingClientRect(),f=a.getBoundingClientRect(),g=c.top-f.top+a.scrollTop,h=c.height;k.push({topRatio:g/b,heightRatio:h/b,msg:d,index:k.length})}}l(k)},(0,u.useCallback)(()=>w.current(),[]);let x=(0,u.useCallback)(a=>{let b=c.current;if(!b)return;let d=b.scrollHeight-b.clientHeight;d<=0||(b.scrollTop=Math.max(0,Math.min(1-g,a))/(1-g)*d)},[c,g]),y=(0,u.useCallback)(a=>{if(!i)return;q.current=!0;let b=a.currentTarget.getBoundingClientRect(),c=(a.clientY-b.top)/b.height,d=c-e*(1-g),f=d>=0&&d<=g?d:g/2;x(c-f);let h=a=>{q.current&&x((a.clientY-b.top)/b.height-f)},j=()=>{q.current=!1,window.removeEventListener("mousemove",h),window.removeEventListener("mouseup",j)};window.addEventListener("mousemove",h),window.addEventListener("mouseup",j)},[i,g,e,x]),z=r.current?.clientHeight??600,A=(0,u.useMemo)(()=>{if(!m||0===k.length)return[];let a=k.map(a=>Math.round(a.topRatio*z-11));for(let b=0;b<10;b++){for(let b=1;b<a.length;b++){let c=a[b-1]+22+2;a[b]<c&&(a[b]=c)}for(let b=a.length-2;b>=0;b--){let c=a[b+1]-22-2;a[b]>c&&(a[b]=c)}}for(let b=0;b<a.length;b++)a[b]=Math.max(0,Math.min(z-22,a[b]));return a},[m,k,z]);if(!i)return null;let B=e*(1-g)*100,C=100*g,D=null!==o&&k.length>0?k.reduce((a,b)=>Math.abs(b.topRatio-o)<Math.abs(k[a].topRatio-o)?b.index:a,0):null;return(0,t.jsxs)("div",{ref:r,onMouseDown:y,onMouseEnter:()=>n(!0),onMouseLeave:()=>{n(!1),p(null)},onMouseMove:a=>{let b=a.currentTarget.getBoundingClientRect();p((a.clientY-b.top)/b.height)},style:{width:36,flexShrink:0,position:"relative",cursor:"default",userSelect:"none",borderLeft:"1px solid var(--border)",background:"var(--bg-panel)",overflow:"visible"},children:[(0,t.jsx)("div",{style:{position:"absolute",left:0,right:0,top:`${B}%`,height:`${C}%`,background:"rgba(100,100,100,0.1)",borderTop:"1px solid rgba(100,100,100,0.2)",borderBottom:"1px solid rgba(100,100,100,0.2)",pointerEvents:"none",zIndex:1}}),k.map(a=>{let b=lx(a.msg),c=m&&D===a.index,d="user"===a.msg.role,e=100*a.topRatio;return(0,t.jsx)("div",{style:{position:"absolute",top:`${e}%`,transform:"translateY(-50%)",left:0,right:0,height:"12px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",zIndex:2},children:(0,t.jsx)("div",{style:{width:d?8:6,height:d?8:6,borderRadius:d?2:"50%",background:b.bg,border:`1.5px solid ${b.border}`,flexShrink:0,transition:"transform 0.1s",transform:c?"scale(1.6)":"scale(1)"}})},a.index)}),(0,t.jsx)("div",{style:{position:"absolute",left:"50%",top:0,bottom:0,width:1,background:"var(--border)",transform:"translateX(-50%)",zIndex:0}}),m&&k.map((a,b)=>{let c=function(a){if("user"===a.role){let b=a.content;return"string"==typeof b?b.slice(0,200):Array.isArray(b)?b.filter(a=>"text"===a.type&&a.text).map(a=>a.text).join("\n").slice(0,200):""}if("assistant"===a.role){let b=a.content??[],c=b.filter(a=>"text"===a.type).map(a=>a.text).join(" ");if(c)return c.slice(0,200);let d=b.filter(a=>"toolCall"===a.type).map(a=>a.toolName);if(d.length)return d.join(", ")}return""}(a.msg),d=lx(a.msg),e=D===a.index;return c&&0!==A.length?(0,t.jsx)("div",{style:{position:"absolute",top:A[b],right:"100%",marginRight:6,background:"var(--bg)",borderTop:`1px solid ${e?d.border:"var(--border)"}`,borderRight:`1px solid ${e?d.border:"var(--border)"}`,borderBottom:`1px solid ${e?d.border:"var(--border)"}`,borderLeft:`2px solid ${d.border}`,borderRadius:4,padding:"2px 7px",width:200,zIndex:100,pointerEvents:"none",opacity:e?1:.45,transition:"top 0.1s, opacity 0.1s"},children:(0,t.jsx)("div",{style:{fontSize:11,color:e?"var(--text)":"var(--text-muted)",lineHeight:1.4,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:c})},a.index):null})]})}function lz(a){return"object"==typeof a&&null!==a&&!Array.isArray(a)}function lA(a,b=220){if(!a)return;let c=a.trim();if(c)return c.length>b?`${c.slice(0,b)}...`:c}function lB(...a){for(let b of a)if("string"==typeof b&&b.trim())return b}function lC(...a){for(let b of a)if("number"==typeof b&&Number.isFinite(b))return b}function lD(a){let b=new Map;for(let c of a){if("custom"===c.role&&"subagent-notify"===c.customType&&"string"==typeof c.content){let a=c.content.match(/^Background task (completed|failed|paused):\s*\*\*(.+?)\*\*(?:\s+\((.+?)\))?/);if(a){let d=`bg-${a[2]}-${c.timestamp??""}`;b.set(d,{id:d,agent:a[2],status:a[1],task:a[3],summary:lA(c.content.split("\n").slice(3).join("\n")),timestamp:c.timestamp})}}if("assistant"===c.role){let a=c.content;if(!a)continue;for(let d of a)if("toolCall"===d.type&&"subagent"===d.toolName&&d.input){let a=d.input,e=a.agent??(a.chain?"chain":a.tasks?"parallel":a.action??"subagent"),f="string"==typeof a.task?a.task:void 0,g=d.toolCallId??`sub-${e}-${c.timestamp??Date.now()}`;b.set(g,{id:g,agent:e,status:"running",task:f,timestamp:c.timestamp})}}if("toolResult"===c.role){if(c.toolName&&"subagent"!==c.toolName||!c.toolCallId||!b.has(c.toolCallId))continue;let a=b.get(c.toolCallId),d=c.content.filter(a=>"text"===a.type).map(a=>a.text).join("\n");b.set(c.toolCallId,function(a,b,c){let d;if(!lz(b))return{...a,summary:lA(c)};let e=Array.isArray(b.results)?b.results.filter(lz):[],f=e[0],g=f?.progressSummary,h=f&&(d=f.artifactPaths)?Object.values(d).filter(a=>"string"==typeof a&&a.trim().length>0):[],i=lB(f?.finalOutput,f?.output,c);return{...a,mode:lB(b.mode),runId:lB(b.runId),agent:lB(f?.agent,a.agent)??a.agent,task:lB(f?.task,a.task),summary:lA(i),model:lB(f?.model),durationMs:lC(g?.durationMs),toolCount:lC(g?.toolCount),tokens:lC(g?.tokens),outputPath:lB(f?.savedOutputPath,f?.artifactPaths?.outputPath),sessionFile:lB(f?.sessionFile,f?.artifactPaths?.jsonlPath),artifacts:h,resultCount:e.length||void 0}}({...a,status:function(a){if(a.isError)return"failed";let b=a.details;return lz(b)&&Array.isArray(b.results)&&b.results.some(a=>lz(a)&&"number"==typeof a.exitCode&&0!==a.exitCode)?"failed":"completed"}(c)},c.details,d))}}return Array.from(b.values()).sort((a,b)=>(b.timestamp??0)-(a.timestamp??0))}function lE({messages:a,runs:b}){let c=(0,u.useMemo)(()=>lD(a??[]),[a]),d=b??c,e=d.filter(a=>"running"===a.status),f=d.filter(a=>"running"!==a.status);return 0===d.length?null:(0,t.jsxs)("div",{style:{height:"100%",overflow:"auto",padding:12},children:[e.length>0&&(0,t.jsx)(lF,{title:`Active (${e.length})`,runs:e}),f.length>0&&(0,t.jsx)(lF,{title:`Completed (${f.length})`,runs:f,compact:e.length>0})]})}function lF({title:a,runs:b,compact:c}){return(0,t.jsxs)("div",{style:{marginBottom:c?10:16},children:[(0,t.jsx)("div",{style:{fontSize:11,fontWeight:600,color:"var(--text-dim)",marginBottom:8,textTransform:"uppercase",letterSpacing:"0.05em"},children:a}),b.map(a=>(0,t.jsx)(lG,{run:a},a.id))]})}function lG({run:a}){let[b,c]=(0,u.useState)(!1),d="running"===a.status,e="completed"===a.status?"#22c55e":"failed"===a.status?"#ef4444":d?"var(--accent)":"var(--text-dim)",f="failed"===a.status?"rgba(248,113,113,0.35)":d?"rgba(99,102,241,0.25)":"var(--border)",g="failed"===a.status?"rgba(248,113,113,0.05)":d?"rgba(99,102,241,0.05)":"var(--bg-panel)",h=[a.mode,a.resultCount&&a.resultCount>1?`${a.resultCount} results`:void 0,void 0!==a.toolCount?`${a.toolCount} tools`:void 0,void 0!==a.tokens?`${a.tokens.toLocaleString()} tok`:void 0,void 0!==a.durationMs?`${Math.round(a.durationMs/1e3)}s`:void 0].filter(Boolean).join(" \xb7 "),i=!!(a.summary||a.outputPath||a.sessionFile||a.artifacts?.length||a.model||a.runId);return(0,t.jsxs)("div",{style:{borderRadius:6,border:`1px solid ${f}`,background:g,marginBottom:6,fontSize:12,overflow:"hidden"},children:[(0,t.jsxs)("button",{onClick:()=>i&&c(a=>!a),style:{display:"flex",alignItems:"center",gap:7,width:"100%",border:"none",background:"transparent",padding:"8px 10px",color:"var(--text-muted)",textAlign:"left",cursor:i?"pointer":"default"},children:[(0,t.jsx)(lH,{running:d,color:e}),(0,t.jsx)("span",{style:{fontWeight:650,color:"var(--text)",minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a.agent}),(0,t.jsx)("span",{style:{color:e,fontSize:10,fontWeight:700,flexShrink:0},children:a.status}),h&&(0,t.jsx)("span",{style:{color:"var(--text-dim)",fontSize:10,marginLeft:"auto",whiteSpace:"nowrap"},children:h}),i&&(0,t.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"var(--text-dim)",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,transform:b?"rotate(180deg)":"none",transition:"transform 0.15s"},children:(0,t.jsx)("polyline",{points:"2 3.5 5 6.5 8 3.5"})})]}),a.task&&(0,t.jsx)("div",{style:{padding:"0 10px 8px 25px",color:"var(--text-muted)",fontSize:11,lineHeight:1.4},children:lA(a.task,150)}),b&&i&&(0,t.jsxs)("div",{style:{borderTop:`1px solid ${f}`,background:"var(--bg)",padding:"8px 10px",display:"flex",flexDirection:"column",gap:7},children:[a.summary&&(0,t.jsx)("pre",{style:{margin:0,color:"var(--text-muted)",fontSize:11,lineHeight:1.45,whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:160,overflow:"auto"},children:a.summary}),(0,t.jsx)(lI,{run:a})]})]})}function lH({running:a,color:b}){return(0,t.jsx)("span",{style:{width:8,height:8,borderRadius:"50%",background:b,display:"inline-block",animation:a?"pulse 1.5s infinite":void 0,flexShrink:0}})}function lI({run:a}){let b=[a.model?["model",a.model]:void 0,a.runId?["run",a.runId]:void 0,a.outputPath?["output",a.outputPath]:void 0,a.sessionFile?["session",a.sessionFile]:void 0,...(a.artifacts??[]).slice(0,4).map((a,b)=>[`artifact ${b+1}`,a])].filter(Boolean);return 0===b.length?null:(0,t.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:3},children:b.map(([a,b])=>(0,t.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"58px minmax(0, 1fr)",gap:6,fontSize:10},children:[(0,t.jsx)("span",{style:{color:"var(--text-dim)",textTransform:"uppercase"},children:a}),(0,t.jsx)("span",{style:{color:"var(--text-muted)",fontFamily:"var(--font-mono)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:b,children:b})]},`${a}:${b}`))})}function lJ(a){if("assistant"!==a.role)return a;let b=a.content;if(!Array.isArray(b))return a;let c=b.map(a=>("object"!=typeof a||null===a||Array.isArray(a)||"toolCall"!==a.type?null:{type:"toolCall",toolCallId:"string"==typeof a.toolCallId?a.toolCallId:"string"==typeof a.id?a.id:"",toolName:"string"==typeof a.toolName?a.toolName:"string"==typeof a.name?a.name:"",input:"object"!=typeof a.input||null===a.input||Array.isArray(a.input)?"object"!=typeof a.arguments||null===a.arguments||Array.isArray(a.arguments)?{}:a.arguments:a.input})??a);return{...a,content:c}}async function lK(a,b){let c=await fetch(`/api/agent/${encodeURIComponent(a)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),d=await c.json().catch(()=>({}));if(!c.ok||d.error)throw Error(d.error??`HTTP ${c.status}`);return d.data}var lL=c(29947);function lM(a,b){switch(b.type){case"start":return{isStreaming:!0,streamingMessage:null};case"update":return{isStreaming:!0,streamingMessage:b.message};case"end":case"reset":return{isStreaming:!1,streamingMessage:null};default:return a}}function lN(a){if("user"!==a.role)return null;var b=a.content;if("string"==typeof b)return`text:${b}`;if(!Array.isArray(b))try{return`other:${JSON.stringify(b)}`}catch{return"other:"}let c=b.map(a=>{if(!a||"object"!=typeof a)return a;if("text"===a.type)return{type:"text",text:a.text};if("image"===a.type){let b=a.source&&"object"==typeof a.source?a.source:{};return{type:"image",mimeType:b.media_type??a.mimeType,data:b.data??a.data,url:b.url}}return a});try{return`blocks:${JSON.stringify(c)}`}catch{return"blocks:"}}function lO(a){if(!a.role)return null;try{return`${a.role}:${JSON.stringify(a)}`}catch{return null}}let lP=["image/","application/pdf","application/vnd.openxmlformats-officedocument","application/msword","application/vnd.ms-"];function lQ(a){return lP.some(b=>a.type.startsWith(b))}let lR=["annotate and analyze.","vibe code bioinformatics.","turn data into figures.","inspect your project.","build a reproducible report.","run R/Python plots.","summarize that paper.","review the pipeline.","compare markers.","draft methods.","find the next analysis step."];function lS({phrases:a}){let[b,c]=(0,u.useState)(()=>Math.floor(Math.random()*a.length)),[d,e]=(0,u.useState)(""),[f,g]=(0,u.useState)(!1),[h,i]=(0,u.useState)(!0);return(0,t.jsxs)("span",{style:{color:"var(--text-muted)",fontWeight:400},children:[d,(0,t.jsx)("span",{style:{opacity:+!!h,color:"var(--accent)",marginLeft:1},children:"▍"})]})}function lT({status:a}){let b=a?.current??"0.8.24"??"0.0.0";if(a?.updateAvailable){let c=a.latest?`v${a.latest}`:"latest";return(0,t.jsxs)("span",{title:`Current v${b}; latest ${c}; run ${a.updateCommand}`,style:{display:"block",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:11,color:"var(--accent)"},children:["Update: ",(0,t.jsx)("code",{style:{fontFamily:"var(--font-mono)",color:"var(--accent)"},children:a.updateCommand})]})}return(0,t.jsxs)("span",{title:`AnnoVibe v${b}`,style:{fontSize:11,color:"var(--text-dim)",whiteSpace:"nowrap"},children:["v",b]})}function lU({session:a,newSessionCwd:b,onAgentEnd:d,onSessionCreated:e,onSessionForked:f,modelsRefreshKey:g,chatInputRef:h,onBranchDataChange:i,onSystemPromptChange:j,onSessionStatsChange:k,onContextUsageChange:l,onReportUpdated:m,generativeUI:n}){var o;let p,{data:q,loading:r,error:s,messages:v,entryIds:w,streamState:x,activeLeafId:y,agentRunning:z,modelNames:A,modelList:B,modelThinkingLevels:C,modelThinkingLevelMaps:D,toolPreset:E,thinkingLevel:F,retryInfo:G,contextUsage:H,forkingEntryId:I,isCompacting:J,compactError:K,displayModel:L,sessionStats:M,agentPhase:N,agentError:O,isNew:P,messagesEndRef:Q,scrollContainerRef:R,lastUserMsgRef:S,handleSend:T,handleAbort:U,handleFork:V,handleNavigate:W,handleModelChange:X,handleCompact:Y,handleSteer:Z,handleFollowUp:$,handleAbortCompaction:_,handleToolPresetChange:aa,handleThinkingLevelChange:ab,handleAgentEventRef:ac}=function(a){let{session:b,newSessionCwd:d,onAgentEnd:e,onSessionCreated:f,onSessionForked:g,modelsRefreshKey:h,onBranchDataChange:i,onSystemPromptChange:j}=a,k=null===b&&null!==d,[l,m]=(0,u.useState)(null),[n,o]=(0,u.useState)(!k),[p,q]=(0,u.useState)(null),[r,s]=(0,u.useState)(null),[t,v]=(0,u.useState)([]),[w,x]=(0,u.useState)([]),[y,z]=(0,u.useReducer)(lM,{isStreaming:!1,streamingMessage:null}),[A,B]=(0,u.useState)(!1),[C,D]=(0,u.useState)({}),[E,F]=(0,u.useState)([]),[G,H]=(0,u.useState)({}),[I,J]=(0,u.useState)({}),[K,L]=(0,u.useState)(null),[M,N]=(0,u.useState)("full"),[O,P]=(0,u.useState)("auto"),[Q,R]=(0,u.useState)(null),[S,T]=(0,u.useState)(null),[U,V]=(0,u.useState)(null),[W,X]=(0,u.useState)(null),[Y,Z]=(0,u.useState)(null),[$,_]=(0,u.useState)(null),[aa,ab]=(0,u.useState)(!1),[ac,ad]=(0,u.useState)(null),[ae,af]=(0,u.useState)(null),[ag,ah]=(0,u.useState)(null),ai=(0,u.useRef)(null),aj=(0,u.useRef)(b?.id??null),ak=(0,u.useRef)(!1),al=(0,u.useRef)(null),am=(0,u.useRef)(!1),an=(0,u.useRef)(null),ao=(0,u.useRef)(!1),ap=(0,u.useRef)(null),aq=(0,u.useRef)(null),ar=(0,u.useRef)(new Map),as=(0,u.useRef)(new Set),at=a.setNewSessionModel??L,au=a.setToolPreset??N,av=Y??l?.context.model??$??null,aw=k?K:av,ax=(0,u.useCallback)(a=>a?.length?a.map((a,b)=>{let c=`Attachment ${b+1}: ${a.fileName} (${a.mimeType||"application/octet-stream"}, ${a.size} bytes)`;if(a.extractedText){let b=a.truncated?"\n[The extracted text was truncated before sending.]":"";return`${c}
250
250
  ${b}
251
251
  ${a.extractedText}`.trim()}return`${c}
252
252
  [Text extraction unavailable: ${a.extractionError??"unsupported file type"}]`}).join("\n\n---\n\n"):"",[]),ay=(0,u.useCallback)(a=>{let b=lN(a);if(!b)return;let c=ar.current;c.set(b,(c.get(b)??0)+1)},[]),az=(0,u.useCallback)(a=>{let b=lN(a);if(!b)return!1;let c=ar.current,d=c.get(b)??0;return!(d<=0)&&(1===d?c.delete(b):c.set(b,d-1),!0)},[]),aA=(()=>{let a={input:0,output:0,cacheRead:0,cacheWrite:0},b=0;for(let c of t){if("assistant"!==c.role)continue;let d=c.usage;d&&(a.input+=d.input??0,a.output+=d.output??0,a.cacheRead+=d.cacheRead??0,a.cacheWrite+=d.cacheWrite??0,b+=d.cost?.total??0)}return a.input+a.output+a.cacheRead+a.cacheWrite>0?{tokens:a,cost:b}:null})(),aB=(0,u.useCallback)(async(a,b=!1,c=!1)=>{try{b&&o(!0);let d=c?`/api/sessions/${encodeURIComponent(a)}?includeState`:`/api/sessions/${encodeURIComponent(a)}`,e=await fetch(d);if(aj.current&&aj.current!==a)return null;if(404===e.status)return b&&(m(null),s(null),v([]),q(null)),null;if(!e.ok)throw Error(`HTTP ${e.status}`);let f=await e.json();return m(f),s(f.leafId),v(f.context.messages),x(f.context.entryIds??[]),ar.current.clear(),as.current=new Set(f.context.messages.map(lO).filter(a=>!!a)),Z(null),q(null),!f.agentState?.state?.thinkingLevel&&f.context.thinkingLevel&&"off"!==f.context.thinkingLevel&&P(f.context.thinkingLevel),f.agentState??null}catch(a){return q(String(a)),null}finally{b&&o(!1)}},[]),aC=(0,u.useCallback)(async(a,b)=>{try{let c=b?`/api/sessions/${encodeURIComponent(a)}/context?leafId=${encodeURIComponent(b)}`:`/api/sessions/${encodeURIComponent(a)}/context`,d=await fetch(c);if(!d.ok)throw Error(`HTTP ${d.status}`);let e=await d.json();v(e.context.messages),x(e.context.entryIds??[]),ar.current.clear()}catch(a){console.error("Failed to load context:",a)}},[]),aD=(0,u.useCallback)(async a=>{try{let b=await lK(a,{type:"get_tools"});if(b){let{getPresetFromTools:a}=await c.e(8065).then(c.bind(c,98065));au(a(b))}}catch(a){console.error("Failed to load tools:",a)}},[au]),aE=(0,u.useCallback)((a,b={})=>{ai.current&&(ai.current.close(),ai.current=null);let c=new EventSource(`/api/agent/${encodeURIComponent(a)}/events${b.replay?"?replay=1":""}`);ai.current=c,c.onmessage=a=>{try{let b=JSON.parse(a.data);al.current?.(b)}catch{}},c.onerror=()=>{ai.current===c&&ak.current&&(c.close(),ai.current=null,setTimeout(()=>{ak.current&&aE(a)},1e3))}},[]);al.current=(0,u.useCallback)(a=>{switch(a.type){case"agent_start":ah(null),B(!0),af({kind:"waiting_model"}),z({type:"start"});break;case"agent_end":B(!1),af(null),R(null),z({type:"end"}),aj.current&&(aB(aj.current),fetch(`/api/agent/${encodeURIComponent(aj.current)}`).then(a=>a.json()).then(a=>{a.state?.contextUsage!==void 0&&T(a.state.contextUsage??null),a.state?.systemPrompt!==void 0&&V(a.state.systemPrompt??null)}).catch(()=>{})),e?.();break;case"message_start":case"message_update":{let b=a.message;if(b){let a=lJ(b);as.current.has(lO(a)??"")||z({type:"update",message:a})}af(null);break}case"message_end":{let b=a.message;if(b){let a=lJ(b),c=lO(a),d=!!c&&as.current.has(c);c&&as.current.add(c),d||"user"===a.role&&az(a)||v(b=>[...b,a])}z({type:"reset"}),af({kind:"waiting_model"});break}case"tool_execution_start":{let b=a.toolCallId,c=a.toolName;af(a=>{let d=a?.kind==="running_tools"?[...a.tools]:[];return d.some(a=>a.id===b)||d.push({id:b,name:c}),{kind:"running_tools",tools:d}});break}case"tool_execution_end":{let b=a.toolCallId;af(a=>{if(a?.kind!=="running_tools")return a;let c=a.tools.filter(a=>a.id!==b);return 0===c.length?{kind:"waiting_model"}:{kind:"running_tools",tools:c}});break}case"auto_retry_start":R({attempt:a.attempt,maxAttempts:a.maxAttempts,errorMessage:a.errorMessage});break;case"auto_retry_end":R(null);break;case"auto_compaction_start":case"compaction_start":ab(!0),ad(null);break;case"auto_compaction_end":case"compaction_end":ab(!1),a.errorMessage?ad(a.errorMessage):!a.aborted&&aj.current&&aB(aj.current)}},[az,aB,e]);let aF=(0,u.useCallback)(async(a,c,e)=>{if(!a.trim()&&!c?.length&&!e?.length||A)return;let g=ax(e),h=a.trim()?g?`${a}