@bytespell/shella 0.1.6 → 0.1.7

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 (113) hide show
  1. package/dist/public/assets/{_baseUniq-ofDPcIU7.js → _baseUniq-D9TYleYv.js} +1 -1
  2. package/{public/assets/arc-CN1QbtAQ.js → dist/public/assets/arc-Bqkc3LZm.js} +1 -1
  3. package/{public/assets/architectureDiagram-VXUJARFQ-B7xrwB3a.js → dist/public/assets/architectureDiagram-VXUJARFQ-C7pQ9eBc.js} +1 -1
  4. package/{public/assets/blockDiagram-VD42YOAC-ByLGlNws.js → dist/public/assets/blockDiagram-VD42YOAC-C47kjU51.js} +1 -1
  5. package/dist/public/assets/{c4Diagram-YG6GDRKO-YpYx4Aj8.js → c4Diagram-YG6GDRKO-hYDGImzM.js} +1 -1
  6. package/dist/public/assets/channel-CZbjQww4.js +1 -0
  7. package/dist/public/assets/{chunk-4BX2VUAB-D0zp96k1.js → chunk-4BX2VUAB-d6tzfYU_.js} +1 -1
  8. package/dist/public/assets/{chunk-55IACEB6-C5GJeIrO.js → chunk-55IACEB6-hAlvgHob.js} +1 -1
  9. package/{public/assets/chunk-B4BG7PRW-Ci17wd3H.js → dist/public/assets/chunk-B4BG7PRW-DcHYkNpL.js} +1 -1
  10. package/{public/assets/chunk-DI55MBZ5-B2XMqfQC.js → dist/public/assets/chunk-DI55MBZ5-DmYTN3pZ.js} +1 -1
  11. package/dist/public/assets/{chunk-FMBD7UC4-Crk5_wey.js → chunk-FMBD7UC4-D7fqP24E.js} +1 -1
  12. package/dist/public/assets/{chunk-QN33PNHL-DqQoCDuG.js → chunk-QN33PNHL-DHEaHAkH.js} +1 -1
  13. package/dist/public/assets/{chunk-QZHKN3VN-DtbXtmmy.js → chunk-QZHKN3VN-CUEecr31.js} +1 -1
  14. package/dist/public/assets/{chunk-TZMSLE5B-Boi_YcuZ.js → chunk-TZMSLE5B-CQC5olzQ.js} +1 -1
  15. package/dist/public/assets/classDiagram-2ON5EDUG-DdwUVrxi.js +1 -0
  16. package/dist/public/assets/classDiagram-v2-WZHVMYZB-DdwUVrxi.js +1 -0
  17. package/dist/public/assets/clone-OD5JE1Cw.js +1 -0
  18. package/dist/public/assets/{code-block-IT6T5CEO-BAcnOjsj.js → code-block-IT6T5CEO-BNFAFcIE.js} +1 -1
  19. package/dist/public/assets/{cose-bilkent-S5V4N54A-DAIcBIuP.js → cose-bilkent-S5V4N54A-XGPrPsXQ.js} +1 -1
  20. package/dist/public/assets/{dagre-6UL2VRFP-zz51dmH0.js → dagre-6UL2VRFP-BcyWIYPE.js} +1 -1
  21. package/dist/public/assets/{diagram-PSM6KHXK-bVpD6rI7.js → diagram-PSM6KHXK-CBJyRzHu.js} +1 -1
  22. package/dist/public/assets/{diagram-QEK2KX5R-I8YB5Wm0.js → diagram-QEK2KX5R-BBxj1vYL.js} +1 -1
  23. package/dist/public/assets/{diagram-S2PKOQOG-D1xlOPWJ.js → diagram-S2PKOQOG-BTSvV1S3.js} +1 -1
  24. package/{public/assets/erDiagram-Q2GNP2WA-DEdjbB3m.js → dist/public/assets/erDiagram-Q2GNP2WA-Cmcj_23w.js} +1 -1
  25. package/{public/assets/flowDiagram-NV44I4VS-BBCU2dfK.js → dist/public/assets/flowDiagram-NV44I4VS-CshqyJY8.js} +1 -1
  26. package/dist/public/assets/{ganttDiagram-JELNMOA3-B0jnifD_.js → ganttDiagram-JELNMOA3-o7FTrO1I.js} +1 -1
  27. package/dist/public/assets/{gitGraphDiagram-NY62KEGX-BX21wvJS.js → gitGraphDiagram-NY62KEGX-DMYNojPU.js} +1 -1
  28. package/dist/public/assets/{graph-BE95p5Ca.js → graph-C1exCUhk.js} +1 -1
  29. package/dist/public/assets/index-Bk8vmlSI.css +1 -0
  30. package/dist/public/assets/{index-CbxztLlk.js → index-DpDVi1Yh.js} +3 -3
  31. package/dist/public/assets/{infoDiagram-WHAUD3N6-CrU0UXwW.js → infoDiagram-WHAUD3N6-BtpyTGJr.js} +1 -1
  32. package/dist/public/assets/{journeyDiagram-XKPGCS4Q-DzukVB-1.js → journeyDiagram-XKPGCS4Q-Ca9OoHtc.js} +1 -1
  33. package/{public/assets/kanban-definition-3W4ZIXB7-CJVLdxxJ.js → dist/public/assets/kanban-definition-3W4ZIXB7-CsE7CD0y.js} +1 -1
  34. package/dist/public/assets/{layout-CM_3juMX.js → layout-BPf4wWku.js} +1 -1
  35. package/dist/public/assets/{linear-BXRjo7t5.js → linear-Hmh70sq7.js} +1 -1
  36. package/dist/public/assets/{mermaid.core-Hp60xAyJ.js → mermaid.core-E3JM4XVX.js} +5 -5
  37. package/dist/public/assets/{min-oqogeQSX.js → min-6ojrcLrh.js} +1 -1
  38. package/dist/public/assets/{mindmap-definition-VGOIOE7T-CCgMWgfM.js → mindmap-definition-VGOIOE7T-BjpBHYC_.js} +1 -1
  39. package/dist/public/assets/{pieDiagram-ADFJNKIX-DAkNkjx-.js → pieDiagram-ADFJNKIX-D6FIx46U.js} +1 -1
  40. package/{public/assets/quadrantDiagram-AYHSOK5B-CPEqSA2x.js → dist/public/assets/quadrantDiagram-AYHSOK5B-Dc3CfRHY.js} +1 -1
  41. package/dist/public/assets/{requirementDiagram-UZGBJVZJ-jOv297_A.js → requirementDiagram-UZGBJVZJ-tmNqVojO.js} +1 -1
  42. package/{public/assets/sankeyDiagram-TZEHDZUN-CwvAKmpc.js → dist/public/assets/sankeyDiagram-TZEHDZUN-C2bvNED8.js} +1 -1
  43. package/dist/public/assets/{sequenceDiagram-WL72ISMW-D_WZ2ogT.js → sequenceDiagram-WL72ISMW-DoNmZswJ.js} +1 -1
  44. package/{public/assets/stateDiagram-FKZM4ZOC-tqYMmK3v.js → dist/public/assets/stateDiagram-FKZM4ZOC-B8Lk-Kak.js} +1 -1
  45. package/dist/public/assets/stateDiagram-v2-4FDKWEC3-Cvy-UNc6.js +1 -0
  46. package/{public/assets/timeline-definition-IT6M3QCI-BIqJkdQ0.js → dist/public/assets/timeline-definition-IT6M3QCI-UdDQrtnd.js} +1 -1
  47. package/dist/public/assets/{treemap-KMMF4GRG-CmJM6xaw.js → treemap-KMMF4GRG-Dkfqpf3u.js} +1 -1
  48. package/dist/public/assets/{xychartDiagram-PRI3JC2R-D7-tZ8iR.js → xychartDiagram-PRI3JC2R-BiR50II_.js} +1 -1
  49. package/dist/public/favicon.svg +4 -0
  50. package/dist/public/index.html +2 -2
  51. package/package.json +1 -1
  52. package/public/assets/{_baseUniq-ofDPcIU7.js → _baseUniq-D9TYleYv.js} +1 -1
  53. package/{dist/public/assets/arc-CN1QbtAQ.js → public/assets/arc-Bqkc3LZm.js} +1 -1
  54. package/{dist/public/assets/architectureDiagram-VXUJARFQ-B7xrwB3a.js → public/assets/architectureDiagram-VXUJARFQ-C7pQ9eBc.js} +1 -1
  55. package/{dist/public/assets/blockDiagram-VD42YOAC-ByLGlNws.js → public/assets/blockDiagram-VD42YOAC-C47kjU51.js} +1 -1
  56. package/public/assets/{c4Diagram-YG6GDRKO-YpYx4Aj8.js → c4Diagram-YG6GDRKO-hYDGImzM.js} +1 -1
  57. package/public/assets/channel-CZbjQww4.js +1 -0
  58. package/public/assets/{chunk-4BX2VUAB-D0zp96k1.js → chunk-4BX2VUAB-d6tzfYU_.js} +1 -1
  59. package/public/assets/{chunk-55IACEB6-C5GJeIrO.js → chunk-55IACEB6-hAlvgHob.js} +1 -1
  60. package/{dist/public/assets/chunk-B4BG7PRW-Ci17wd3H.js → public/assets/chunk-B4BG7PRW-DcHYkNpL.js} +1 -1
  61. package/{dist/public/assets/chunk-DI55MBZ5-B2XMqfQC.js → public/assets/chunk-DI55MBZ5-DmYTN3pZ.js} +1 -1
  62. package/public/assets/{chunk-FMBD7UC4-Crk5_wey.js → chunk-FMBD7UC4-D7fqP24E.js} +1 -1
  63. package/public/assets/{chunk-QN33PNHL-DqQoCDuG.js → chunk-QN33PNHL-DHEaHAkH.js} +1 -1
  64. package/public/assets/{chunk-QZHKN3VN-DtbXtmmy.js → chunk-QZHKN3VN-CUEecr31.js} +1 -1
  65. package/public/assets/{chunk-TZMSLE5B-Boi_YcuZ.js → chunk-TZMSLE5B-CQC5olzQ.js} +1 -1
  66. package/public/assets/classDiagram-2ON5EDUG-DdwUVrxi.js +1 -0
  67. package/public/assets/classDiagram-v2-WZHVMYZB-DdwUVrxi.js +1 -0
  68. package/public/assets/clone-OD5JE1Cw.js +1 -0
  69. package/public/assets/{code-block-IT6T5CEO-BAcnOjsj.js → code-block-IT6T5CEO-BNFAFcIE.js} +1 -1
  70. package/public/assets/{cose-bilkent-S5V4N54A-DAIcBIuP.js → cose-bilkent-S5V4N54A-XGPrPsXQ.js} +1 -1
  71. package/public/assets/{dagre-6UL2VRFP-zz51dmH0.js → dagre-6UL2VRFP-BcyWIYPE.js} +1 -1
  72. package/public/assets/{diagram-PSM6KHXK-bVpD6rI7.js → diagram-PSM6KHXK-CBJyRzHu.js} +1 -1
  73. package/public/assets/{diagram-QEK2KX5R-I8YB5Wm0.js → diagram-QEK2KX5R-BBxj1vYL.js} +1 -1
  74. package/public/assets/{diagram-S2PKOQOG-D1xlOPWJ.js → diagram-S2PKOQOG-BTSvV1S3.js} +1 -1
  75. package/{dist/public/assets/erDiagram-Q2GNP2WA-DEdjbB3m.js → public/assets/erDiagram-Q2GNP2WA-Cmcj_23w.js} +1 -1
  76. package/{dist/public/assets/flowDiagram-NV44I4VS-BBCU2dfK.js → public/assets/flowDiagram-NV44I4VS-CshqyJY8.js} +1 -1
  77. package/public/assets/{ganttDiagram-JELNMOA3-B0jnifD_.js → ganttDiagram-JELNMOA3-o7FTrO1I.js} +1 -1
  78. package/public/assets/{gitGraphDiagram-NY62KEGX-BX21wvJS.js → gitGraphDiagram-NY62KEGX-DMYNojPU.js} +1 -1
  79. package/public/assets/{graph-BE95p5Ca.js → graph-C1exCUhk.js} +1 -1
  80. package/public/assets/index-Bk8vmlSI.css +1 -0
  81. package/public/assets/{index-CbxztLlk.js → index-DpDVi1Yh.js} +3 -3
  82. package/public/assets/{infoDiagram-WHAUD3N6-CrU0UXwW.js → infoDiagram-WHAUD3N6-BtpyTGJr.js} +1 -1
  83. package/public/assets/{journeyDiagram-XKPGCS4Q-DzukVB-1.js → journeyDiagram-XKPGCS4Q-Ca9OoHtc.js} +1 -1
  84. package/{dist/public/assets/kanban-definition-3W4ZIXB7-CJVLdxxJ.js → public/assets/kanban-definition-3W4ZIXB7-CsE7CD0y.js} +1 -1
  85. package/public/assets/{layout-CM_3juMX.js → layout-BPf4wWku.js} +1 -1
  86. package/public/assets/{linear-BXRjo7t5.js → linear-Hmh70sq7.js} +1 -1
  87. package/public/assets/{mermaid.core-Hp60xAyJ.js → mermaid.core-E3JM4XVX.js} +5 -5
  88. package/public/assets/{min-oqogeQSX.js → min-6ojrcLrh.js} +1 -1
  89. package/public/assets/{mindmap-definition-VGOIOE7T-CCgMWgfM.js → mindmap-definition-VGOIOE7T-BjpBHYC_.js} +1 -1
  90. package/public/assets/{pieDiagram-ADFJNKIX-DAkNkjx-.js → pieDiagram-ADFJNKIX-D6FIx46U.js} +1 -1
  91. package/{dist/public/assets/quadrantDiagram-AYHSOK5B-CPEqSA2x.js → public/assets/quadrantDiagram-AYHSOK5B-Dc3CfRHY.js} +1 -1
  92. package/public/assets/{requirementDiagram-UZGBJVZJ-jOv297_A.js → requirementDiagram-UZGBJVZJ-tmNqVojO.js} +1 -1
  93. package/{dist/public/assets/sankeyDiagram-TZEHDZUN-CwvAKmpc.js → public/assets/sankeyDiagram-TZEHDZUN-C2bvNED8.js} +1 -1
  94. package/public/assets/{sequenceDiagram-WL72ISMW-D_WZ2ogT.js → sequenceDiagram-WL72ISMW-DoNmZswJ.js} +1 -1
  95. package/{dist/public/assets/stateDiagram-FKZM4ZOC-tqYMmK3v.js → public/assets/stateDiagram-FKZM4ZOC-B8Lk-Kak.js} +1 -1
  96. package/public/assets/stateDiagram-v2-4FDKWEC3-Cvy-UNc6.js +1 -0
  97. package/{dist/public/assets/timeline-definition-IT6M3QCI-BIqJkdQ0.js → public/assets/timeline-definition-IT6M3QCI-UdDQrtnd.js} +1 -1
  98. package/public/assets/{treemap-KMMF4GRG-CmJM6xaw.js → treemap-KMMF4GRG-Dkfqpf3u.js} +1 -1
  99. package/public/assets/{xychartDiagram-PRI3JC2R-D7-tZ8iR.js → xychartDiagram-PRI3JC2R-BiR50II_.js} +1 -1
  100. package/public/favicon.svg +4 -0
  101. package/public/index.html +2 -2
  102. package/dist/public/assets/channel-BtuRdvAy.js +0 -1
  103. package/dist/public/assets/classDiagram-2ON5EDUG-CDjYhjfv.js +0 -1
  104. package/dist/public/assets/classDiagram-v2-WZHVMYZB-CDjYhjfv.js +0 -1
  105. package/dist/public/assets/clone-C8pGQ3Xy.js +0 -1
  106. package/dist/public/assets/index-CA2Ed_I8.css +0 -1
  107. package/dist/public/assets/stateDiagram-v2-4FDKWEC3-BF0ecSBs.js +0 -1
  108. package/public/assets/channel-BtuRdvAy.js +0 -1
  109. package/public/assets/classDiagram-2ON5EDUG-CDjYhjfv.js +0 -1
  110. package/public/assets/classDiagram-v2-WZHVMYZB-CDjYhjfv.js +0 -1
  111. package/public/assets/clone-C8pGQ3Xy.js +0 -1
  112. package/public/assets/index-CA2Ed_I8.css +0 -1
  113. package/public/assets/stateDiagram-v2-4FDKWEC3-BF0ecSBs.js +0 -1
@@ -374,13 +374,13 @@ ${t}</tr>
374
374
  `}tablecell(t){let n=this.parser.parseInline(t.tokens),r=t.header?"th":"td";return(t.align?`<${r} align="${t.align}">`:`<${r}>`)+n+`</${r}>
375
375
  `}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${Li(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:n,tokens:r}){let i=this.parser.parseInline(r),a=mw(t);if(a===null)return i;t=a;let o='<a href="'+t+'"';return n&&(o+=' title="'+Li(n)+'"'),o+=">"+i+"</a>",o}image({href:t,title:n,text:r,tokens:i}){i&&(r=this.parser.parseInline(i,this.parser.textRenderer));let a=mw(t);if(a===null)return Li(r);t=a;let o=`<img src="${t}" alt="${r}"`;return n&&(o+=` title="${Li(n)}"`),o+=">",o}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:Li(t.text)}},C4=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}},vi=class Ev{options;renderer;textRenderer;constructor(t){this.options=t||Zo,this.options.renderer=this.options.renderer||new em,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new C4}static parse(t,n){return new Ev(n).parse(t)}static parseInline(t,n){return new Ev(n).parseInline(t)}parse(t,n=!0){let r="";for(let i=0;i<t.length;i++){let a=t[i];if(this.options.extensions?.renderers?.[a.type]){let u=a,c=this.options.extensions.renderers[u.type].call({parser:this},u);if(c!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(u.type)){r+=c||"";continue}}let o=a;switch(o.type){case"space":{r+=this.renderer.space(o);continue}case"hr":{r+=this.renderer.hr(o);continue}case"heading":{r+=this.renderer.heading(o);continue}case"code":{r+=this.renderer.code(o);continue}case"table":{r+=this.renderer.table(o);continue}case"blockquote":{r+=this.renderer.blockquote(o);continue}case"list":{r+=this.renderer.list(o);continue}case"html":{r+=this.renderer.html(o);continue}case"def":{r+=this.renderer.def(o);continue}case"paragraph":{r+=this.renderer.paragraph(o);continue}case"text":{let u=o,c=this.renderer.text(u);for(;i+1<t.length&&t[i+1].type==="text";)u=t[++i],c+=`
376
376
  `+this.renderer.text(u);n?r+=this.renderer.paragraph({type:"paragraph",raw:c,text:c,tokens:[{type:"text",raw:c,text:c,escaped:!0}]}):r+=c;continue}default:{let u='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(u),"";throw new Error(u)}}}return r}parseInline(t,n=this.renderer){let r="";for(let i=0;i<t.length;i++){let a=t[i];if(this.options.extensions?.renderers?.[a.type]){let u=this.options.extensions.renderers[a.type].call({parser:this},a);if(u!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){r+=u||"";continue}}let o=a;switch(o.type){case"escape":{r+=n.text(o);break}case"html":{r+=n.html(o);break}case"link":{r+=n.link(o);break}case"image":{r+=n.image(o);break}case"strong":{r+=n.strong(o);break}case"em":{r+=n.em(o);break}case"codespan":{r+=n.codespan(o);break}case"br":{r+=n.br(o);break}case"del":{r+=n.del(o);break}case"text":{r+=n.text(o);break}default:{let u='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(u),"";throw new Error(u)}}}return r}},t0=class{options;block;constructor(t){this.options=t||Zo}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(){return this.block?ni.lex:ni.lexInline}provideParser(){return this.block?vi.parse:vi.parseInline}},sJ=class{defaults=y4();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=vi;Renderer=em;TextRenderer=C4;Lexer=ni;Tokenizer=Jh;Hooks=t0;constructor(...t){this.use(...t)}walkTokens(t,n){let r=[];for(let i of t)switch(r=r.concat(n.call(this,i)),i.type){case"table":{let a=i;for(let o of a.header)r=r.concat(this.walkTokens(o.tokens,n));for(let o of a.rows)for(let u of o)r=r.concat(this.walkTokens(u.tokens,n));break}case"list":{let a=i;r=r.concat(this.walkTokens(a.items,n));break}default:{let a=i;this.defaults.extensions?.childTokens?.[a.type]?this.defaults.extensions.childTokens[a.type].forEach(o=>{let u=a[o].flat(1/0);r=r.concat(this.walkTokens(u,n))}):a.tokens&&(r=r.concat(this.walkTokens(a.tokens,n)))}}return r}use(...t){let n=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(r=>{let i={...r};if(i.async=this.defaults.async||i.async||!1,r.extensions&&(r.extensions.forEach(a=>{if(!a.name)throw new Error("extension name required");if("renderer"in a){let o=n.renderers[a.name];o?n.renderers[a.name]=function(...u){let c=a.renderer.apply(this,u);return c===!1&&(c=o.apply(this,u)),c}:n.renderers[a.name]=a.renderer}if("tokenizer"in a){if(!a.level||a.level!=="block"&&a.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let o=n[a.level];o?o.unshift(a.tokenizer):n[a.level]=[a.tokenizer],a.start&&(a.level==="block"?n.startBlock?n.startBlock.push(a.start):n.startBlock=[a.start]:a.level==="inline"&&(n.startInline?n.startInline.push(a.start):n.startInline=[a.start]))}"childTokens"in a&&a.childTokens&&(n.childTokens[a.name]=a.childTokens)}),i.extensions=n),r.renderer){let a=this.defaults.renderer||new em(this.defaults);for(let o in r.renderer){if(!(o in a))throw new Error(`renderer '${o}' does not exist`);if(["options","parser"].includes(o))continue;let u=o,c=r.renderer[u],f=a[u];a[u]=(...h)=>{let m=c.apply(a,h);return m===!1&&(m=f.apply(a,h)),m||""}}i.renderer=a}if(r.tokenizer){let a=this.defaults.tokenizer||new Jh(this.defaults);for(let o in r.tokenizer){if(!(o in a))throw new Error(`tokenizer '${o}' does not exist`);if(["options","rules","lexer"].includes(o))continue;let u=o,c=r.tokenizer[u],f=a[u];a[u]=(...h)=>{let m=c.apply(a,h);return m===!1&&(m=f.apply(a,h)),m}}i.tokenizer=a}if(r.hooks){let a=this.defaults.hooks||new t0;for(let o in r.hooks){if(!(o in a))throw new Error(`hook '${o}' does not exist`);if(["options","block"].includes(o))continue;let u=o,c=r.hooks[u],f=a[u];t0.passThroughHooks.has(o)?a[u]=h=>{if(this.defaults.async&&t0.passThroughHooksRespectAsync.has(o))return(async()=>{let g=await c.call(a,h);return f.call(a,g)})();let m=c.call(a,h);return f.call(a,m)}:a[u]=(...h)=>{if(this.defaults.async)return(async()=>{let g=await c.apply(a,h);return g===!1&&(g=await f.apply(a,h)),g})();let m=c.apply(a,h);return m===!1&&(m=f.apply(a,h)),m}}i.hooks=a}if(r.walkTokens){let a=this.defaults.walkTokens,o=r.walkTokens;i.walkTokens=function(u){let c=[];return c.push(o.call(this,u)),a&&(c=c.concat(a.call(this,u))),c}}this.defaults={...this.defaults,...i}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,n){return ni.lex(t,n??this.defaults)}parser(t,n){return vi.parse(t,n??this.defaults)}parseMarkdown(t){return(n,r)=>{let i={...r},a={...this.defaults,...i},o=this.onError(!!a.silent,!!a.async);if(this.defaults.async===!0&&i.async===!1)return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof n>"u"||n===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(a.hooks&&(a.hooks.options=a,a.hooks.block=t),a.async)return(async()=>{let u=a.hooks?await a.hooks.preprocess(n):n,c=await(a.hooks?await a.hooks.provideLexer():t?ni.lex:ni.lexInline)(u,a),f=a.hooks?await a.hooks.processAllTokens(c):c;a.walkTokens&&await Promise.all(this.walkTokens(f,a.walkTokens));let h=await(a.hooks?await a.hooks.provideParser():t?vi.parse:vi.parseInline)(f,a);return a.hooks?await a.hooks.postprocess(h):h})().catch(o);try{a.hooks&&(n=a.hooks.preprocess(n));let u=(a.hooks?a.hooks.provideLexer():t?ni.lex:ni.lexInline)(n,a);a.hooks&&(u=a.hooks.processAllTokens(u)),a.walkTokens&&this.walkTokens(u,a.walkTokens);let c=(a.hooks?a.hooks.provideParser():t?vi.parse:vi.parseInline)(u,a);return a.hooks&&(c=a.hooks.postprocess(c)),c}catch(u){return o(u)}}}onError(t,n){return r=>{if(r.message+=`
377
- Please report this to https://github.com/markedjs/marked.`,t){let i="<p>An error occurred:</p><pre>"+Li(r.message+"",!0)+"</pre>";return n?Promise.resolve(i):i}if(n)return Promise.reject(r);throw r}}},Po=new sJ;function Dt(e,t){return Po.parse(e,t)}Dt.options=Dt.setOptions=function(e){return Po.setOptions(e),Dt.defaults=Po.defaults,kC(Dt.defaults),Dt};Dt.getDefaults=y4;Dt.defaults=Zo;Dt.use=function(...e){return Po.use(...e),Dt.defaults=Po.defaults,kC(Dt.defaults),Dt};Dt.walkTokens=function(e,t){return Po.walkTokens(e,t)};Dt.parseInline=Po.parseInline;Dt.Parser=vi;Dt.parser=vi.parse;Dt.Renderer=em;Dt.TextRenderer=C4;Dt.Lexer=ni;Dt.lexer=ni.lex;Dt.Tokenizer=Jh;Dt.Hooks=t0;Dt.parse=Dt;Dt.options;Dt.setOptions;Dt.use;Dt.walkTokens;Dt.parseInline;vi.parse;ni.lex;var it=(...e)=>bC(h4(e)),du=(e,t,n)=>{let r=typeof t=="string"?new Blob([t],{type:n}):t,i=URL.createObjectURL(r),a=document.createElement("a");a.href=i,a.download=e,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)},oJ=C.createContext({code:""}),zC=()=>C.useContext(oJ),bw=({onCopy:e,onError:t,timeout:n=2e3,children:r,className:i,code:a,...o})=>{let[u,c]=C.useState(!1),f=C.useRef(0),{code:h}=zC(),{isAnimating:m}=C.useContext(Ti),g=a??h,b=async()=>{var E;if(typeof window>"u"||!((E=navigator?.clipboard)!=null&&E.writeText)){t?.(new Error("Clipboard API not available"));return}try{u||(await navigator.clipboard.writeText(g),c(!0),e?.(),f.current=window.setTimeout(()=>c(!1),n))}catch(A){t?.(A)}};C.useEffect(()=>()=>{window.clearTimeout(f.current)},[]);let y=u?nC:rC;return _.jsx("button",{className:it("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",i),"data-streamdown":"code-block-copy-button",disabled:m,onClick:b,title:"Copy Code",type:"button",...o,children:r??_.jsx(y,{size:14})})},vw={"1c":"1c","1c-query":"1cq",abap:"abap","actionscript-3":"as",ada:"ada",adoc:"adoc","angular-html":"html","angular-ts":"ts",apache:"conf",apex:"cls",apl:"apl",applescript:"applescript",ara:"ara",asciidoc:"adoc",asm:"asm",astro:"astro",awk:"awk",ballerina:"bal",bash:"sh",bat:"bat",batch:"bat",be:"be",beancount:"beancount",berry:"berry",bibtex:"bib",bicep:"bicep",blade:"blade.php",bsl:"bsl",c:"c","c#":"cs","c++":"cpp",cadence:"cdc",cairo:"cairo",cdc:"cdc",clarity:"clar",clj:"clj",clojure:"clj","closure-templates":"soy",cmake:"cmake",cmd:"cmd",cobol:"cob",codeowners:"CODEOWNERS",codeql:"ql",coffee:"coffee",coffeescript:"coffee","common-lisp":"lisp",console:"sh",coq:"v",cpp:"cpp",cql:"cql",crystal:"cr",cs:"cs",csharp:"cs",css:"css",csv:"csv",cue:"cue",cypher:"cql",d:"d",dart:"dart",dax:"dax",desktop:"desktop",diff:"diff",docker:"dockerfile",dockerfile:"dockerfile",dotenv:"env","dream-maker":"dm",edge:"edge",elisp:"el",elixir:"ex",elm:"elm","emacs-lisp":"el",erb:"erb",erl:"erl",erlang:"erl",f:"f","f#":"fs",f03:"f03",f08:"f08",f18:"f18",f77:"f77",f90:"f90",f95:"f95",fennel:"fnl",fish:"fish",fluent:"ftl",for:"for","fortran-fixed-form":"f","fortran-free-form":"f90",fs:"fs",fsharp:"fs",fsl:"fsl",ftl:"ftl",gdresource:"tres",gdscript:"gd",gdshader:"gdshader",genie:"gs",gherkin:"feature","git-commit":"gitcommit","git-rebase":"gitrebase",gjs:"js",gleam:"gleam","glimmer-js":"js","glimmer-ts":"ts",glsl:"glsl",gnuplot:"plt",go:"go",gql:"gql",graphql:"graphql",groovy:"groovy",gts:"gts",hack:"hack",haml:"haml",handlebars:"hbs",haskell:"hs",haxe:"hx",hbs:"hbs",hcl:"hcl",hjson:"hjson",hlsl:"hlsl",hs:"hs",html:"html","html-derivative":"html",http:"http",hxml:"hxml",hy:"hy",imba:"imba",ini:"ini",jade:"jade",java:"java",javascript:"js",jinja:"jinja",jison:"jison",jl:"jl",js:"js",json:"json",json5:"json5",jsonc:"jsonc",jsonl:"jsonl",jsonnet:"jsonnet",jssm:"jssm",jsx:"jsx",julia:"jl",kotlin:"kt",kql:"kql",kt:"kt",kts:"kts",kusto:"kql",latex:"tex",lean:"lean",lean4:"lean",less:"less",liquid:"liquid",lisp:"lisp",lit:"lit",llvm:"ll",log:"log",logo:"logo",lua:"lua",luau:"luau",make:"mak",makefile:"mak",markdown:"md",marko:"marko",matlab:"m",md:"md",mdc:"mdc",mdx:"mdx",mediawiki:"wiki",mermaid:"mmd",mips:"s",mipsasm:"s",mmd:"mmd",mojo:"mojo",move:"move",nar:"nar",narrat:"narrat",nextflow:"nf",nf:"nf",nginx:"conf",nim:"nim",nix:"nix",nu:"nu",nushell:"nu",objc:"m","objective-c":"m","objective-cpp":"mm",ocaml:"ml",pascal:"pas",perl:"pl",perl6:"p6",php:"php",plsql:"pls",po:"po",polar:"polar",postcss:"pcss",pot:"pot",potx:"potx",powerquery:"pq",powershell:"ps1",prisma:"prisma",prolog:"pl",properties:"properties",proto:"proto",protobuf:"proto",ps:"ps",ps1:"ps1",pug:"pug",puppet:"pp",purescript:"purs",py:"py",python:"py",ql:"ql",qml:"qml",qmldir:"qmldir",qss:"qss",r:"r",racket:"rkt",raku:"raku",razor:"cshtml",rb:"rb",reg:"reg",regex:"regex",regexp:"regexp",rel:"rel",riscv:"s",rs:"rs",rst:"rst",ruby:"rb",rust:"rs",sas:"sas",sass:"sass",scala:"scala",scheme:"scm",scss:"scss",sdbl:"sdbl",sh:"sh",shader:"shader",shaderlab:"shader",shell:"sh",shellscript:"sh",shellsession:"sh",smalltalk:"st",solidity:"sol",soy:"soy",sparql:"rq",spl:"spl",splunk:"spl",sql:"sql","ssh-config":"config",stata:"do",styl:"styl",stylus:"styl",svelte:"svelte",swift:"swift","system-verilog":"sv",systemd:"service",talon:"talon",talonscript:"talon",tasl:"tasl",tcl:"tcl",templ:"templ",terraform:"tf",tex:"tex",tf:"tf",tfvars:"tfvars",toml:"toml",ts:"ts","ts-tags":"ts",tsp:"tsp",tsv:"tsv",tsx:"tsx",turtle:"ttl",twig:"twig",typ:"typ",typescript:"ts",typespec:"tsp",typst:"typ",v:"v",vala:"vala",vb:"vb",verilog:"v",vhdl:"vhdl",vim:"vim",viml:"vim",vimscript:"vim",vue:"vue","vue-html":"html","vue-vine":"vine",vy:"vy",vyper:"vy",wasm:"wasm",wenyan:"wy",wgsl:"wgsl",wiki:"wiki",wikitext:"wiki",wit:"wit",wl:"wl",wolfram:"wl",xml:"xml",xsl:"xsl",yaml:"yaml",yml:"yml",zenscript:"zs",zig:"zig",zsh:"zsh",文言:"wy"},lJ=({onDownload:e,onError:t,language:n,children:r,className:i,code:a,...o})=>{let{code:u}=zC(),{isAnimating:c}=C.useContext(Ti),f=a??u,h=`file.${n&&n in vw?vw[n]:"txt"}`,m="text/plain",g=()=>{try{du(h,f,m),e?.()}catch(b){t?.(b)}};return _.jsx("button",{className:it("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",i),"data-streamdown":"code-block-download-button",disabled:c,onClick:g,title:"Download file",type:"button",...o,children:r??_.jsx(Ym,{size:14})})},yw=()=>_.jsxs("div",{className:"w-full divide-y divide-border overflow-hidden rounded-xl border border-border",children:[_.jsx("div",{className:"h-[46px] w-full bg-muted/80"}),_.jsx("div",{className:"flex w-full items-center justify-center p-4",children:_.jsx(pQ,{className:"size-4 animate-spin"})})]}),uJ=/\.[^/.]+$/,cJ=({node:e,className:t,src:n,alt:r,...i})=>{let a=async()=>{if(n)try{let o=await(await fetch(n)).blob(),u=new URL(n,window.location.origin).pathname.split("/").pop()||"",c=u.split(".").pop(),f=u.includes(".")&&c!==void 0&&c.length<=4,h="";if(f)h=u;else{let m=o.type,g="png";m.includes("jpeg")||m.includes("jpg")?g="jpg":m.includes("png")?g="png":m.includes("svg")?g="svg":m.includes("gif")?g="gif":m.includes("webp")&&(g="webp"),h=`${(r||u||"image").replace(uJ,"")}.${g}`}du(h,o,o.type)}catch(o){console.error("Failed to download image:",o)}};return n?_.jsxs("div",{className:"group relative my-4 inline-block","data-streamdown":"image-wrapper",children:[_.jsx("img",{alt:r,className:it("max-w-full rounded-lg",t),"data-streamdown":"image",src:n,...i}),_.jsx("div",{className:"pointer-events-none absolute inset-0 hidden rounded-lg bg-black/10 group-hover:block"}),_.jsx("button",{className:it("absolute right-2 bottom-2 flex h-8 w-8 cursor-pointer items-center justify-center rounded-md border border-border bg-background/90 shadow-sm backdrop-blur-sm transition-all duration-200 hover:bg-background","opacity-0 group-hover:opacity-100"),onClick:a,title:"Download image",type:"button",children:_.jsx(Ym,{size:14})})]}):null},jC=async e=>{let t={startOnLoad:!1,theme:"default",securityLevel:"strict",fontFamily:"monospace",suppressErrorRendering:!0,...e},n=(await U(async()=>{const{default:r}=await import("./mermaid.core-Hp60xAyJ.js").then(i=>i.bA);return{default:r}},[])).default;return n.initialize(t),n},dJ=(e,t)=>{var n;let r=(n=void 0)!=null?n:5;return new Promise((i,a)=>{let o="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(e))),u=new Image;u.crossOrigin="anonymous",u.onload=()=>{let c=document.createElement("canvas"),f=u.width*r,h=u.height*r;c.width=f,c.height=h;let m=c.getContext("2d");if(!m){a(new Error("Failed to create 2D canvas context for PNG export"));return}m.drawImage(u,0,0,f,h),c.toBlob(g=>{if(!g){a(new Error("Failed to create PNG blob"));return}i(g)},"image/png")},u.onerror=()=>a(new Error("Failed to load SVG image")),u.src=o})},fJ=({chart:e,children:t,className:n,onDownload:r,config:i,onError:a})=>{let[o,u]=C.useState(!1),c=C.useRef(null),{isAnimating:f}=C.useContext(Ti),h=async m=>{try{if(m==="mmd"){du("diagram.mmd",e,"text/plain"),u(!1),r?.(m);return}let g=await jC(i),b=e.split("").reduce((A,k)=>(A<<5)-A+k.charCodeAt(0)|0,0),y=`mermaid-${Math.abs(b)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:E}=await g.render(y,e);if(!E){a?.(new Error("SVG not found. Please wait for the diagram to render."));return}if(m==="svg"){du("diagram.svg",E,"image/svg+xml"),u(!1),r?.(m);return}if(m==="png"){let A=await dJ(E);du("diagram.png",A,"image/png"),r?.(m),u(!1);return}}catch(g){a?.(g)}};return C.useEffect(()=>{let m=g=>{c.current&&!c.current.contains(g.target)&&u(!1)};return document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m)}},[]),_.jsxs("div",{className:"relative",ref:c,children:[_.jsx("button",{className:it("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",n),disabled:f,onClick:()=>u(!o),title:"Download diagram",type:"button",children:t??_.jsx(Ym,{size:14})}),o&&_.jsxs("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg",children:[_.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>h("svg"),title:"Download diagram as SVG",type:"button",children:"SVG"}),_.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>h("png"),title:"Download diagram as PNG",type:"button",children:"PNG"}),_.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>h("mmd"),title:"Download diagram as MMD",type:"button",children:"MMD"})]})]})},v0=0,hJ=()=>{v0+=1,v0===1&&(document.body.style.overflow="hidden")},mJ=()=>{v0=Math.max(0,v0-1),v0===0&&(document.body.style.overflow="")},pJ=({chart:e,config:t,onFullscreen:n,onExit:r,className:i,...a})=>{let[o,u]=C.useState(!1),{isAnimating:c,controls:f}=C.useContext(Ti),h=(()=>{if(typeof f=="boolean")return f;let g=f.mermaid;return g===!1?!1:g===!0||g===void 0?!0:g.panZoom!==!1})(),m=()=>{u(!o)};return C.useEffect(()=>{if(o){hJ();let g=b=>{b.key==="Escape"&&u(!1)};return document.addEventListener("keydown",g),()=>{document.removeEventListener("keydown",g),mJ()}}},[o]),C.useEffect(()=>{o?n?.():r&&r()},[o,n,r]),_.jsxs(_.Fragment,{children:[_.jsx("button",{className:it("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",i),disabled:c,onClick:m,title:"View fullscreen",type:"button",...a,children:_.jsx(bQ,{size:14})}),o&&_.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm",onClick:m,onKeyDown:g=>{g.key==="Escape"&&m()},role:"button",tabIndex:0,children:[_.jsx("button",{className:"absolute top-4 right-4 z-10 rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground",onClick:m,title:"Exit fullscreen",type:"button",children:_.jsx(EQ,{size:20})}),_.jsx("div",{className:"flex h-full w-full items-center justify-center p-4",onClick:g=>g.stopPropagation(),onKeyDown:g=>g.stopPropagation(),role:"presentation",children:_.jsx(gk,{chart:e,className:"h-full w-full [&>div]:h-full [&>div]:overflow-hidden [&_svg]:h-auto [&_svg]:w-auto",config:t,fullscreen:!0,showControls:h})})]})]})},HC=e=>{var t,n;let r=[],i=[],a=e.querySelectorAll("thead th");for(let u of a)r.push(((t=u.textContent)==null?void 0:t.trim())||"");let o=e.querySelectorAll("tbody tr");for(let u of o){let c=[],f=u.querySelectorAll("td");for(let h of f)c.push(((n=h.textContent)==null?void 0:n.trim())||"");i.push(c)}return{headers:r,rows:i}},UC=e=>{let{headers:t,rows:n}=e,r=u=>{let c=!1,f=!1;for(let h=0;h<u.length;h+=1){let m=u[h];if(m==='"'){c=!0,f=!0;break}(m===","||m===`
377
+ Please report this to https://github.com/markedjs/marked.`,t){let i="<p>An error occurred:</p><pre>"+Li(r.message+"",!0)+"</pre>";return n?Promise.resolve(i):i}if(n)return Promise.reject(r);throw r}}},Po=new sJ;function Dt(e,t){return Po.parse(e,t)}Dt.options=Dt.setOptions=function(e){return Po.setOptions(e),Dt.defaults=Po.defaults,kC(Dt.defaults),Dt};Dt.getDefaults=y4;Dt.defaults=Zo;Dt.use=function(...e){return Po.use(...e),Dt.defaults=Po.defaults,kC(Dt.defaults),Dt};Dt.walkTokens=function(e,t){return Po.walkTokens(e,t)};Dt.parseInline=Po.parseInline;Dt.Parser=vi;Dt.parser=vi.parse;Dt.Renderer=em;Dt.TextRenderer=C4;Dt.Lexer=ni;Dt.lexer=ni.lex;Dt.Tokenizer=Jh;Dt.Hooks=t0;Dt.parse=Dt;Dt.options;Dt.setOptions;Dt.use;Dt.walkTokens;Dt.parseInline;vi.parse;ni.lex;var it=(...e)=>bC(h4(e)),du=(e,t,n)=>{let r=typeof t=="string"?new Blob([t],{type:n}):t,i=URL.createObjectURL(r),a=document.createElement("a");a.href=i,a.download=e,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)},oJ=C.createContext({code:""}),zC=()=>C.useContext(oJ),bw=({onCopy:e,onError:t,timeout:n=2e3,children:r,className:i,code:a,...o})=>{let[u,c]=C.useState(!1),f=C.useRef(0),{code:h}=zC(),{isAnimating:m}=C.useContext(Ti),g=a??h,b=async()=>{var E;if(typeof window>"u"||!((E=navigator?.clipboard)!=null&&E.writeText)){t?.(new Error("Clipboard API not available"));return}try{u||(await navigator.clipboard.writeText(g),c(!0),e?.(),f.current=window.setTimeout(()=>c(!1),n))}catch(A){t?.(A)}};C.useEffect(()=>()=>{window.clearTimeout(f.current)},[]);let y=u?nC:rC;return _.jsx("button",{className:it("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",i),"data-streamdown":"code-block-copy-button",disabled:m,onClick:b,title:"Copy Code",type:"button",...o,children:r??_.jsx(y,{size:14})})},vw={"1c":"1c","1c-query":"1cq",abap:"abap","actionscript-3":"as",ada:"ada",adoc:"adoc","angular-html":"html","angular-ts":"ts",apache:"conf",apex:"cls",apl:"apl",applescript:"applescript",ara:"ara",asciidoc:"adoc",asm:"asm",astro:"astro",awk:"awk",ballerina:"bal",bash:"sh",bat:"bat",batch:"bat",be:"be",beancount:"beancount",berry:"berry",bibtex:"bib",bicep:"bicep",blade:"blade.php",bsl:"bsl",c:"c","c#":"cs","c++":"cpp",cadence:"cdc",cairo:"cairo",cdc:"cdc",clarity:"clar",clj:"clj",clojure:"clj","closure-templates":"soy",cmake:"cmake",cmd:"cmd",cobol:"cob",codeowners:"CODEOWNERS",codeql:"ql",coffee:"coffee",coffeescript:"coffee","common-lisp":"lisp",console:"sh",coq:"v",cpp:"cpp",cql:"cql",crystal:"cr",cs:"cs",csharp:"cs",css:"css",csv:"csv",cue:"cue",cypher:"cql",d:"d",dart:"dart",dax:"dax",desktop:"desktop",diff:"diff",docker:"dockerfile",dockerfile:"dockerfile",dotenv:"env","dream-maker":"dm",edge:"edge",elisp:"el",elixir:"ex",elm:"elm","emacs-lisp":"el",erb:"erb",erl:"erl",erlang:"erl",f:"f","f#":"fs",f03:"f03",f08:"f08",f18:"f18",f77:"f77",f90:"f90",f95:"f95",fennel:"fnl",fish:"fish",fluent:"ftl",for:"for","fortran-fixed-form":"f","fortran-free-form":"f90",fs:"fs",fsharp:"fs",fsl:"fsl",ftl:"ftl",gdresource:"tres",gdscript:"gd",gdshader:"gdshader",genie:"gs",gherkin:"feature","git-commit":"gitcommit","git-rebase":"gitrebase",gjs:"js",gleam:"gleam","glimmer-js":"js","glimmer-ts":"ts",glsl:"glsl",gnuplot:"plt",go:"go",gql:"gql",graphql:"graphql",groovy:"groovy",gts:"gts",hack:"hack",haml:"haml",handlebars:"hbs",haskell:"hs",haxe:"hx",hbs:"hbs",hcl:"hcl",hjson:"hjson",hlsl:"hlsl",hs:"hs",html:"html","html-derivative":"html",http:"http",hxml:"hxml",hy:"hy",imba:"imba",ini:"ini",jade:"jade",java:"java",javascript:"js",jinja:"jinja",jison:"jison",jl:"jl",js:"js",json:"json",json5:"json5",jsonc:"jsonc",jsonl:"jsonl",jsonnet:"jsonnet",jssm:"jssm",jsx:"jsx",julia:"jl",kotlin:"kt",kql:"kql",kt:"kt",kts:"kts",kusto:"kql",latex:"tex",lean:"lean",lean4:"lean",less:"less",liquid:"liquid",lisp:"lisp",lit:"lit",llvm:"ll",log:"log",logo:"logo",lua:"lua",luau:"luau",make:"mak",makefile:"mak",markdown:"md",marko:"marko",matlab:"m",md:"md",mdc:"mdc",mdx:"mdx",mediawiki:"wiki",mermaid:"mmd",mips:"s",mipsasm:"s",mmd:"mmd",mojo:"mojo",move:"move",nar:"nar",narrat:"narrat",nextflow:"nf",nf:"nf",nginx:"conf",nim:"nim",nix:"nix",nu:"nu",nushell:"nu",objc:"m","objective-c":"m","objective-cpp":"mm",ocaml:"ml",pascal:"pas",perl:"pl",perl6:"p6",php:"php",plsql:"pls",po:"po",polar:"polar",postcss:"pcss",pot:"pot",potx:"potx",powerquery:"pq",powershell:"ps1",prisma:"prisma",prolog:"pl",properties:"properties",proto:"proto",protobuf:"proto",ps:"ps",ps1:"ps1",pug:"pug",puppet:"pp",purescript:"purs",py:"py",python:"py",ql:"ql",qml:"qml",qmldir:"qmldir",qss:"qss",r:"r",racket:"rkt",raku:"raku",razor:"cshtml",rb:"rb",reg:"reg",regex:"regex",regexp:"regexp",rel:"rel",riscv:"s",rs:"rs",rst:"rst",ruby:"rb",rust:"rs",sas:"sas",sass:"sass",scala:"scala",scheme:"scm",scss:"scss",sdbl:"sdbl",sh:"sh",shader:"shader",shaderlab:"shader",shell:"sh",shellscript:"sh",shellsession:"sh",smalltalk:"st",solidity:"sol",soy:"soy",sparql:"rq",spl:"spl",splunk:"spl",sql:"sql","ssh-config":"config",stata:"do",styl:"styl",stylus:"styl",svelte:"svelte",swift:"swift","system-verilog":"sv",systemd:"service",talon:"talon",talonscript:"talon",tasl:"tasl",tcl:"tcl",templ:"templ",terraform:"tf",tex:"tex",tf:"tf",tfvars:"tfvars",toml:"toml",ts:"ts","ts-tags":"ts",tsp:"tsp",tsv:"tsv",tsx:"tsx",turtle:"ttl",twig:"twig",typ:"typ",typescript:"ts",typespec:"tsp",typst:"typ",v:"v",vala:"vala",vb:"vb",verilog:"v",vhdl:"vhdl",vim:"vim",viml:"vim",vimscript:"vim",vue:"vue","vue-html":"html","vue-vine":"vine",vy:"vy",vyper:"vy",wasm:"wasm",wenyan:"wy",wgsl:"wgsl",wiki:"wiki",wikitext:"wiki",wit:"wit",wl:"wl",wolfram:"wl",xml:"xml",xsl:"xsl",yaml:"yaml",yml:"yml",zenscript:"zs",zig:"zig",zsh:"zsh",文言:"wy"},lJ=({onDownload:e,onError:t,language:n,children:r,className:i,code:a,...o})=>{let{code:u}=zC(),{isAnimating:c}=C.useContext(Ti),f=a??u,h=`file.${n&&n in vw?vw[n]:"txt"}`,m="text/plain",g=()=>{try{du(h,f,m),e?.()}catch(b){t?.(b)}};return _.jsx("button",{className:it("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",i),"data-streamdown":"code-block-download-button",disabled:c,onClick:g,title:"Download file",type:"button",...o,children:r??_.jsx(Ym,{size:14})})},yw=()=>_.jsxs("div",{className:"w-full divide-y divide-border overflow-hidden rounded-xl border border-border",children:[_.jsx("div",{className:"h-[46px] w-full bg-muted/80"}),_.jsx("div",{className:"flex w-full items-center justify-center p-4",children:_.jsx(pQ,{className:"size-4 animate-spin"})})]}),uJ=/\.[^/.]+$/,cJ=({node:e,className:t,src:n,alt:r,...i})=>{let a=async()=>{if(n)try{let o=await(await fetch(n)).blob(),u=new URL(n,window.location.origin).pathname.split("/").pop()||"",c=u.split(".").pop(),f=u.includes(".")&&c!==void 0&&c.length<=4,h="";if(f)h=u;else{let m=o.type,g="png";m.includes("jpeg")||m.includes("jpg")?g="jpg":m.includes("png")?g="png":m.includes("svg")?g="svg":m.includes("gif")?g="gif":m.includes("webp")&&(g="webp"),h=`${(r||u||"image").replace(uJ,"")}.${g}`}du(h,o,o.type)}catch(o){console.error("Failed to download image:",o)}};return n?_.jsxs("div",{className:"group relative my-4 inline-block","data-streamdown":"image-wrapper",children:[_.jsx("img",{alt:r,className:it("max-w-full rounded-lg",t),"data-streamdown":"image",src:n,...i}),_.jsx("div",{className:"pointer-events-none absolute inset-0 hidden rounded-lg bg-black/10 group-hover:block"}),_.jsx("button",{className:it("absolute right-2 bottom-2 flex h-8 w-8 cursor-pointer items-center justify-center rounded-md border border-border bg-background/90 shadow-sm backdrop-blur-sm transition-all duration-200 hover:bg-background","opacity-0 group-hover:opacity-100"),onClick:a,title:"Download image",type:"button",children:_.jsx(Ym,{size:14})})]}):null},jC=async e=>{let t={startOnLoad:!1,theme:"default",securityLevel:"strict",fontFamily:"monospace",suppressErrorRendering:!0,...e},n=(await U(async()=>{const{default:r}=await import("./mermaid.core-E3JM4XVX.js").then(i=>i.bA);return{default:r}},[])).default;return n.initialize(t),n},dJ=(e,t)=>{var n;let r=(n=void 0)!=null?n:5;return new Promise((i,a)=>{let o="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(e))),u=new Image;u.crossOrigin="anonymous",u.onload=()=>{let c=document.createElement("canvas"),f=u.width*r,h=u.height*r;c.width=f,c.height=h;let m=c.getContext("2d");if(!m){a(new Error("Failed to create 2D canvas context for PNG export"));return}m.drawImage(u,0,0,f,h),c.toBlob(g=>{if(!g){a(new Error("Failed to create PNG blob"));return}i(g)},"image/png")},u.onerror=()=>a(new Error("Failed to load SVG image")),u.src=o})},fJ=({chart:e,children:t,className:n,onDownload:r,config:i,onError:a})=>{let[o,u]=C.useState(!1),c=C.useRef(null),{isAnimating:f}=C.useContext(Ti),h=async m=>{try{if(m==="mmd"){du("diagram.mmd",e,"text/plain"),u(!1),r?.(m);return}let g=await jC(i),b=e.split("").reduce((A,k)=>(A<<5)-A+k.charCodeAt(0)|0,0),y=`mermaid-${Math.abs(b)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:E}=await g.render(y,e);if(!E){a?.(new Error("SVG not found. Please wait for the diagram to render."));return}if(m==="svg"){du("diagram.svg",E,"image/svg+xml"),u(!1),r?.(m);return}if(m==="png"){let A=await dJ(E);du("diagram.png",A,"image/png"),r?.(m),u(!1);return}}catch(g){a?.(g)}};return C.useEffect(()=>{let m=g=>{c.current&&!c.current.contains(g.target)&&u(!1)};return document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m)}},[]),_.jsxs("div",{className:"relative",ref:c,children:[_.jsx("button",{className:it("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",n),disabled:f,onClick:()=>u(!o),title:"Download diagram",type:"button",children:t??_.jsx(Ym,{size:14})}),o&&_.jsxs("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg",children:[_.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>h("svg"),title:"Download diagram as SVG",type:"button",children:"SVG"}),_.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>h("png"),title:"Download diagram as PNG",type:"button",children:"PNG"}),_.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>h("mmd"),title:"Download diagram as MMD",type:"button",children:"MMD"})]})]})},v0=0,hJ=()=>{v0+=1,v0===1&&(document.body.style.overflow="hidden")},mJ=()=>{v0=Math.max(0,v0-1),v0===0&&(document.body.style.overflow="")},pJ=({chart:e,config:t,onFullscreen:n,onExit:r,className:i,...a})=>{let[o,u]=C.useState(!1),{isAnimating:c,controls:f}=C.useContext(Ti),h=(()=>{if(typeof f=="boolean")return f;let g=f.mermaid;return g===!1?!1:g===!0||g===void 0?!0:g.panZoom!==!1})(),m=()=>{u(!o)};return C.useEffect(()=>{if(o){hJ();let g=b=>{b.key==="Escape"&&u(!1)};return document.addEventListener("keydown",g),()=>{document.removeEventListener("keydown",g),mJ()}}},[o]),C.useEffect(()=>{o?n?.():r&&r()},[o,n,r]),_.jsxs(_.Fragment,{children:[_.jsx("button",{className:it("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",i),disabled:c,onClick:m,title:"View fullscreen",type:"button",...a,children:_.jsx(bQ,{size:14})}),o&&_.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm",onClick:m,onKeyDown:g=>{g.key==="Escape"&&m()},role:"button",tabIndex:0,children:[_.jsx("button",{className:"absolute top-4 right-4 z-10 rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground",onClick:m,title:"Exit fullscreen",type:"button",children:_.jsx(EQ,{size:20})}),_.jsx("div",{className:"flex h-full w-full items-center justify-center p-4",onClick:g=>g.stopPropagation(),onKeyDown:g=>g.stopPropagation(),role:"presentation",children:_.jsx(gk,{chart:e,className:"h-full w-full [&>div]:h-full [&>div]:overflow-hidden [&_svg]:h-auto [&_svg]:w-auto",config:t,fullscreen:!0,showControls:h})})]})]})},HC=e=>{var t,n;let r=[],i=[],a=e.querySelectorAll("thead th");for(let u of a)r.push(((t=u.textContent)==null?void 0:t.trim())||"");let o=e.querySelectorAll("tbody tr");for(let u of o){let c=[],f=u.querySelectorAll("td");for(let h of f)c.push(((n=h.textContent)==null?void 0:n.trim())||"");i.push(c)}return{headers:r,rows:i}},UC=e=>{let{headers:t,rows:n}=e,r=u=>{let c=!1,f=!1;for(let h=0;h<u.length;h+=1){let m=u[h];if(m==='"'){c=!0,f=!0;break}(m===","||m===`
378
378
  `)&&(c=!0)}return c?f?`"${u.replace(/"/g,'""')}"`:`"${u}"`:u},i=t.length>0?n.length+1:n.length,a=new Array(i),o=0;t.length>0&&(a[o]=t.map(r).join(","),o+=1);for(let u of n)a[o]=u.map(r).join(","),o+=1;return a.join(`
379
379
  `)},gJ=e=>{let{headers:t,rows:n}=e,r=u=>{let c=!1;for(let h=0;h<u.length;h+=1){let m=u[h];if(m===" "||m===`
380
380
  `||m==="\r"){c=!0;break}}if(!c)return u;let f=[];for(let h=0;h<u.length;h+=1){let m=u[h];m===" "?f.push("\\t"):m===`
381
381
  `?f.push("\\n"):m==="\r"?f.push("\\r"):f.push(m)}return f.join("")},i=t.length>0?n.length+1:n.length,a=new Array(i),o=0;t.length>0&&(a[o]=t.map(r).join(" "),o+=1);for(let u of n)a[o]=u.map(r).join(" "),o+=1;return a.join(`
382
382
  `)},B2=e=>{let t=!1;for(let r=0;r<e.length;r+=1){let i=e[r];if(i==="\\"||i==="|"){t=!0;break}}if(!t)return e;let n=[];for(let r=0;r<e.length;r+=1){let i=e[r];i==="\\"?n.push("\\\\"):i==="|"?n.push("\\|"):n.push(i)}return n.join("")},bJ=e=>{let{headers:t,rows:n}=e;if(t.length===0)return"";let r=new Array(n.length+2),i=0,a=t.map(u=>B2(u));r[i]=`| ${a.join(" | ")} |`,i+=1;let o=new Array(t.length);for(let u=0;u<t.length;u+=1)o[u]="---";r[i]=`| ${o.join(" | ")} |`,i+=1;for(let u of n)if(u.length<t.length){let c=new Array(t.length);for(let f=0;f<t.length;f+=1)c[f]=f<u.length?B2(u[f]):"";r[i]=`| ${c.join(" | ")} |`,i+=1}else{let c=u.map(f=>B2(f));r[i]=`| ${c.join(" | ")} |`,i+=1}return r.join(`
383
- `)},vJ=({children:e,className:t,onCopy:n,onError:r,timeout:i=2e3})=>{let[a,o]=C.useState(!1),[u,c]=C.useState(!1),f=C.useRef(null),h=C.useRef(0),{isAnimating:m}=C.useContext(Ti),g=async y=>{var E,A;if(typeof window>"u"||!((E=navigator?.clipboard)!=null&&E.write)){r?.(new Error("Clipboard API not available"));return}try{let k=(A=f.current)==null?void 0:A.closest('[data-streamdown="table-wrapper"]'),S=k?.querySelector("table");if(!S){r?.(new Error("Table not found"));return}let R=HC(S),L=y==="csv"?UC(R):gJ(R),M=new ClipboardItem({"text/plain":new Blob([L],{type:"text/plain"}),"text/html":new Blob([S.outerHTML],{type:"text/html"})});await navigator.clipboard.write([M]),c(!0),o(!1),n?.(y),h.current=window.setTimeout(()=>c(!1),i)}catch(k){r?.(k)}};C.useEffect(()=>{let y=E=>{f.current&&!f.current.contains(E.target)&&o(!1)};return document.addEventListener("mousedown",y),()=>{document.removeEventListener("mousedown",y),window.clearTimeout(h.current)}},[]);let b=u?nC:rC;return _.jsxs("div",{className:"relative",ref:f,children:[_.jsx("button",{className:it("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:m,onClick:()=>o(!a),title:"Copy table",type:"button",children:e??_.jsx(b,{size:14})}),a&&_.jsxs("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg",children:[_.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>g("csv"),title:"Copy table as CSV",type:"button",children:"CSV"}),_.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>g("tsv"),title:"Copy table as TSV",type:"button",children:"TSV"})]})]})},yJ=({children:e,className:t,onDownload:n,onError:r})=>{let[i,a]=C.useState(!1),o=C.useRef(null),{isAnimating:u}=C.useContext(Ti),c=f=>{var h;try{let m=(h=o.current)==null?void 0:h.closest('[data-streamdown="table-wrapper"]'),g=m?.querySelector("table");if(!g){r?.(new Error("Table not found"));return}let b=HC(g),y=f==="csv"?UC(b):bJ(b);du(`table.${f==="csv"?"csv":"md"}`,y,f==="csv"?"text/csv":"text/markdown"),a(!1),n?.(f)}catch(m){r?.(m)}};return C.useEffect(()=>{let f=h=>{o.current&&!o.current.contains(h.target)&&a(!1)};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f)}},[]),_.jsxs("div",{className:"relative",ref:o,children:[_.jsx("button",{className:it("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:u,onClick:()=>a(!i),title:"Download table",type:"button",children:e??_.jsx(Ym,{size:14})}),i&&_.jsxs("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg",children:[_.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>c("csv"),title:"Download table as CSV",type:"button",children:"CSV"}),_.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>c("markdown"),title:"Download table as Markdown",type:"button",children:"Markdown"})]})]})},xJ=({children:e,className:t,showControls:n,...r})=>_.jsxs("div",{className:"my-4 flex flex-col space-y-2","data-streamdown":"table-wrapper",children:[n&&_.jsxs("div",{className:"flex items-center justify-end gap-1",children:[_.jsx(vJ,{}),_.jsx(yJ,{})]}),_.jsx("div",{className:"overflow-x-auto",children:_.jsx("table",{className:it("w-full border-collapse border border-border",t),"data-streamdown":"table",...r,children:e})})]}),EJ=C.lazy(()=>U(()=>import("./code-block-IT6T5CEO-BAcnOjsj.js"),[]).then(e=>({default:e.CodeBlock}))),wJ=C.lazy(()=>U(()=>Promise.resolve().then(()=>vfe),void 0).then(e=>({default:e.Mermaid}))),_J=/language-([^\s]+)/;function Km(e,t){if(!(e!=null&&e.position||t!=null&&t.position))return!0;if(!(e!=null&&e.position&&t!=null&&t.position))return!1;let n=e.position.start,r=t.position.start,i=e.position.end,a=t.position.end;return n?.line===r?.line&&n?.column===r?.column&&i?.line===a?.line&&i?.column===a?.column}function en(e,t){return e.className===t.className&&Km(e.node,t.node)}var wv=(e,t)=>typeof e=="boolean"?e:e[t]!==!1,rh=(e,t)=>{if(typeof e=="boolean")return e;let n=e.mermaid;return n===!1?!1:n===!0||n===void 0?!0:n[t]!==!1},k4=C.memo(({children:e,className:t,node:n,...r})=>_.jsx("ol",{className:it("list-inside list-decimal whitespace-normal",t),"data-streamdown":"ordered-list",...r,children:e}),(e,t)=>en(e,t));k4.displayName="MarkdownOl";var $C=C.memo(({children:e,className:t,node:n,...r})=>_.jsx("li",{className:it("py-1 [&>p]:inline",t),"data-streamdown":"list-item",...r,children:e}),(e,t)=>e.className===t.className&&Km(e.node,t.node));$C.displayName="MarkdownLi";var qC=C.memo(({children:e,className:t,node:n,...r})=>_.jsx("ul",{className:it("list-inside list-disc whitespace-normal",t),"data-streamdown":"unordered-list",...r,children:e}),(e,t)=>en(e,t));qC.displayName="MarkdownUl";var VC=C.memo(({className:e,node:t,...n})=>_.jsx("hr",{className:it("my-6 border-border",e),"data-streamdown":"horizontal-rule",...n}),(e,t)=>en(e,t));VC.displayName="MarkdownHr";var GC=C.memo(({children:e,className:t,node:n,...r})=>_.jsx("span",{className:it("font-semibold",t),"data-streamdown":"strong",...r,children:e}),(e,t)=>en(e,t));GC.displayName="MarkdownStrong";var YC=C.memo(({children:e,className:t,href:n,node:r,...i})=>{let a=n==="streamdown:incomplete-link";return _.jsx("a",{className:it("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":a,"data-streamdown":"link",href:n,rel:"noreferrer",target:"_blank",...i,children:e})},(e,t)=>en(e,t)&&e.href===t.href);YC.displayName="MarkdownA";var WC=C.memo(({children:e,className:t,node:n,...r})=>_.jsx("h1",{className:it("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...r,children:e}),(e,t)=>en(e,t));WC.displayName="MarkdownH1";var QC=C.memo(({children:e,className:t,node:n,...r})=>_.jsx("h2",{className:it("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...r,children:e}),(e,t)=>en(e,t));QC.displayName="MarkdownH2";var XC=C.memo(({children:e,className:t,node:n,...r})=>_.jsx("h3",{className:it("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...r,children:e}),(e,t)=>en(e,t));XC.displayName="MarkdownH3";var KC=C.memo(({children:e,className:t,node:n,...r})=>_.jsx("h4",{className:it("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...r,children:e}),(e,t)=>en(e,t));KC.displayName="MarkdownH4";var ZC=C.memo(({children:e,className:t,node:n,...r})=>_.jsx("h5",{className:it("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...r,children:e}),(e,t)=>en(e,t));ZC.displayName="MarkdownH5";var JC=C.memo(({children:e,className:t,node:n,...r})=>_.jsx("h6",{className:it("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...r,children:e}),(e,t)=>en(e,t));JC.displayName="MarkdownH6";var ek=C.memo(({children:e,className:t,node:n,...r})=>{let{controls:i}=C.useContext(Ti),a=wv(i,"table");return _.jsx(xJ,{className:t,"data-streamdown":"table-wrapper",showControls:a,...r,children:e})},(e,t)=>en(e,t));ek.displayName="MarkdownTable";var tk=C.memo(({children:e,className:t,node:n,...r})=>_.jsx("thead",{className:it("bg-muted/80",t),"data-streamdown":"table-header",...r,children:e}),(e,t)=>en(e,t));tk.displayName="MarkdownThead";var nk=C.memo(({children:e,className:t,node:n,...r})=>_.jsx("tbody",{className:it("divide-y divide-border bg-muted/40",t),"data-streamdown":"table-body",...r,children:e}),(e,t)=>en(e,t));nk.displayName="MarkdownTbody";var rk=C.memo(({children:e,className:t,node:n,...r})=>_.jsx("tr",{className:it("border-border border-b",t),"data-streamdown":"table-row",...r,children:e}),(e,t)=>en(e,t));rk.displayName="MarkdownTr";var ik=C.memo(({children:e,className:t,node:n,...r})=>_.jsx("th",{className:it("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",t),"data-streamdown":"table-header-cell",...r,children:e}),(e,t)=>en(e,t));ik.displayName="MarkdownTh";var ak=C.memo(({children:e,className:t,node:n,...r})=>_.jsx("td",{className:it("px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...r,children:e}),(e,t)=>en(e,t));ak.displayName="MarkdownTd";var sk=C.memo(({children:e,className:t,node:n,...r})=>_.jsx("blockquote",{className:it("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",t),"data-streamdown":"blockquote",...r,children:e}),(e,t)=>en(e,t));sk.displayName="MarkdownBlockquote";var ok=C.memo(({children:e,className:t,node:n,...r})=>_.jsx("sup",{className:it("text-sm",t),"data-streamdown":"superscript",...r,children:e}),(e,t)=>en(e,t));ok.displayName="MarkdownSup";var lk=C.memo(({children:e,className:t,node:n,...r})=>_.jsx("sub",{className:it("text-sm",t),"data-streamdown":"subscript",...r,children:e}),(e,t)=>en(e,t));lk.displayName="MarkdownSub";var uk=C.memo(({children:e,className:t,node:n,...r})=>{if("data-footnotes"in r){let i=o=>{var u,c;if(!C.isValidElement(o))return!1;let f=Array.isArray(o.props.children)?o.props.children:[o.props.children],h=!1,m=!1;for(let g of f)if(g){if(typeof g=="string")g.trim()!==""&&(h=!0);else if(C.isValidElement(g))if(((u=g.props)==null?void 0:u["data-footnote-backref"])!==void 0)m=!0;else{let b=Array.isArray(g.props.children)?g.props.children:[g.props.children];for(let y of b){if(typeof y=="string"&&y.trim()!==""){h=!0;break}if(C.isValidElement(y)&&((c=y.props)==null?void 0:c["data-footnote-backref"])===void 0){h=!0;break}}}}return m&&!h},a=Array.isArray(e)?e.map(o=>{if(!C.isValidElement(o))return o;if(o.type===k4){let u=(Array.isArray(o.props.children)?o.props.children:[o.props.children]).filter(c=>!i(c));return u.length===0?null:{...o,props:{...o.props,children:u}}}return o}):e;return(Array.isArray(a)?a.some(o=>o!==null):a!==null)?_.jsx("section",{className:t,...r,children:a}):null}return _.jsx("section",{className:t,...r,children:e})},(e,t)=>en(e,t));uk.displayName="MarkdownSection";var TJ=({node:e,className:t,children:n,...r})=>{var i,a,o;let u=((i=e?.position)==null?void 0:i.start.line)===((a=e?.position)==null?void 0:a.end.line),{mermaid:c,controls:f}=C.useContext(Ti);if(u)return _.jsx("code",{className:it("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...r,children:n});let h=t?.match(_J),m=(o=h?.at(1))!=null?o:"",g="";if(C.isValidElement(n)&&n.props&&typeof n.props=="object"&&"children"in n.props&&typeof n.props.children=="string"?g=n.props.children:typeof n=="string"&&(g=n),m==="mermaid"){let y=wv(f,"mermaid"),E=rh(f,"download"),A=rh(f,"copy"),k=rh(f,"fullscreen"),S=rh(f,"panZoom");return _.jsx(C.Suspense,{fallback:_.jsx(yw,{}),children:_.jsxs("div",{className:it("group relative my-4 h-auto rounded-xl border p-4",t),"data-streamdown":"mermaid-block",children:[y&&(E||A||k)&&_.jsxs("div",{className:"flex items-center justify-end gap-2",children:[E&&_.jsx(fJ,{chart:g,config:c?.config}),A&&_.jsx(bw,{code:g}),k&&_.jsx(pJ,{chart:g,config:c?.config})]}),_.jsx(wJ,{chart:g,config:c?.config,showControls:S})]})})}let b=wv(f,"code");return _.jsx(C.Suspense,{fallback:_.jsx(yw,{}),children:_.jsx(EJ,{className:it("overflow-x-auto border-border border-t",t),code:g,language:m,children:b&&_.jsxs(_.Fragment,{children:[_.jsx(lJ,{code:g,language:m}),_.jsx(bw,{})]})})})},ck=C.memo(TJ,(e,t)=>e.className===t.className&&Km(e.node,t.node));ck.displayName="MarkdownCode";var dk=C.memo(cJ,(e,t)=>e.className===t.className&&Km(e.node,t.node));dk.displayName="MarkdownImg";var fk=C.memo(({children:e,className:t,node:n,...r})=>{var i;let a=(Array.isArray(e)?e:[e]).filter(o=>o!=null&&o!=="");return a.length===1&&C.isValidElement(a[0])&&((i=a[0].props.node)==null?void 0:i.tagName)==="img"?_.jsx(_.Fragment,{children:e}):_.jsx("p",{className:t,...r,children:e})},(e,t)=>en(e,t));fk.displayName="MarkdownParagraph";var SJ={ol:k4,li:$C,ul:qC,hr:VC,strong:GC,a:YC,h1:WC,h2:QC,h3:XC,h4:KC,h5:ZC,h6:JC,table:ek,thead:tk,tbody:nk,tr:rk,th:ik,td:ak,blockquote:sk,code:ck,img:dk,pre:({children:e})=>e,sup:ok,sub:lk,p:fk,section:uk},xw=[],Ew={allowDangerousHtml:!0},ih=new WeakMap,AJ=class{constructor(){this.cache=new Map,this.keyCache=new WeakMap,this.maxSize=100}generateCacheKey(e){let t=this.keyCache.get(e);if(t)return t;let n=e.rehypePlugins,r=e.remarkPlugins,i=e.remarkRehypeOptions;if(!(n||r||i)){let h="default";return this.keyCache.set(e,h),h}let a=h=>{if(!h||h.length===0)return"";let m="";for(let g=0;g<h.length;g+=1){let b=h[g];if(g>0&&(m+=","),Array.isArray(b)){let[y,E]=b;if(typeof y=="function"){let A=ih.get(y);A||(A=y.name,ih.set(y,A)),m+=A}else m+=String(y);m+=":",m+=JSON.stringify(E)}else if(typeof b=="function"){let y=ih.get(b);y||(y=b.name,ih.set(b,y)),m+=y}else m+=String(b)}return m},o=a(n),u=a(r),c=i?JSON.stringify(i):"",f=`${u}::${o}::${c}`;return this.keyCache.set(e,f),f}get(e){let t=this.generateCacheKey(e),n=this.cache.get(t);return n&&(this.cache.delete(t),this.cache.set(t,n)),n}set(e,t){let n=this.generateCacheKey(e);if(this.cache.size>=this.maxSize){let r=this.cache.keys().next().value;r&&this.cache.delete(r)}this.cache.set(n,t)}clear(){this.cache.clear()}},ww=new AJ,hk=e=>{let t=CJ(e),n=e.children||"";return NJ(t.runSync(t.parse(n),n),e)},CJ=e=>{let t=ww.get(e);if(t)return t;let n=kJ(e);return ww.set(e,n),n},kJ=e=>{let t=e.rehypePlugins||xw,n=e.remarkPlugins||xw,r=e.remarkRehypeOptions?{...Ew,...e.remarkRehypeOptions}:Ew;return xZ().use(yK).use(n).use(tZ,r).use(t)},NJ=(e,t)=>CX(e,{Fragment:_.Fragment,components:t.components,ignoreInvalidStyle:!0,jsx:_.jsx,jsxs:_.jsxs,passKeys:!0,passNode:!0}),RJ=/\[\^[^\]\s]{1,200}\](?!:)/,OJ=/\[\^[^\]\s]{1,200}\]:/,MJ=/<\/(\w+)>/,DJ=/<(\w+)[\s>]/,F2=e=>{let t=0;for(;t<e.length&&(e[t]===" "||e[t]===" "||e[t]===`
383
+ `)},vJ=({children:e,className:t,onCopy:n,onError:r,timeout:i=2e3})=>{let[a,o]=C.useState(!1),[u,c]=C.useState(!1),f=C.useRef(null),h=C.useRef(0),{isAnimating:m}=C.useContext(Ti),g=async y=>{var E,A;if(typeof window>"u"||!((E=navigator?.clipboard)!=null&&E.write)){r?.(new Error("Clipboard API not available"));return}try{let k=(A=f.current)==null?void 0:A.closest('[data-streamdown="table-wrapper"]'),S=k?.querySelector("table");if(!S){r?.(new Error("Table not found"));return}let R=HC(S),L=y==="csv"?UC(R):gJ(R),M=new ClipboardItem({"text/plain":new Blob([L],{type:"text/plain"}),"text/html":new Blob([S.outerHTML],{type:"text/html"})});await navigator.clipboard.write([M]),c(!0),o(!1),n?.(y),h.current=window.setTimeout(()=>c(!1),i)}catch(k){r?.(k)}};C.useEffect(()=>{let y=E=>{f.current&&!f.current.contains(E.target)&&o(!1)};return document.addEventListener("mousedown",y),()=>{document.removeEventListener("mousedown",y),window.clearTimeout(h.current)}},[]);let b=u?nC:rC;return _.jsxs("div",{className:"relative",ref:f,children:[_.jsx("button",{className:it("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:m,onClick:()=>o(!a),title:"Copy table",type:"button",children:e??_.jsx(b,{size:14})}),a&&_.jsxs("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg",children:[_.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>g("csv"),title:"Copy table as CSV",type:"button",children:"CSV"}),_.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>g("tsv"),title:"Copy table as TSV",type:"button",children:"TSV"})]})]})},yJ=({children:e,className:t,onDownload:n,onError:r})=>{let[i,a]=C.useState(!1),o=C.useRef(null),{isAnimating:u}=C.useContext(Ti),c=f=>{var h;try{let m=(h=o.current)==null?void 0:h.closest('[data-streamdown="table-wrapper"]'),g=m?.querySelector("table");if(!g){r?.(new Error("Table not found"));return}let b=HC(g),y=f==="csv"?UC(b):bJ(b);du(`table.${f==="csv"?"csv":"md"}`,y,f==="csv"?"text/csv":"text/markdown"),a(!1),n?.(f)}catch(m){r?.(m)}};return C.useEffect(()=>{let f=h=>{o.current&&!o.current.contains(h.target)&&a(!1)};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f)}},[]),_.jsxs("div",{className:"relative",ref:o,children:[_.jsx("button",{className:it("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:u,onClick:()=>a(!i),title:"Download table",type:"button",children:e??_.jsx(Ym,{size:14})}),i&&_.jsxs("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg",children:[_.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>c("csv"),title:"Download table as CSV",type:"button",children:"CSV"}),_.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>c("markdown"),title:"Download table as Markdown",type:"button",children:"Markdown"})]})]})},xJ=({children:e,className:t,showControls:n,...r})=>_.jsxs("div",{className:"my-4 flex flex-col space-y-2","data-streamdown":"table-wrapper",children:[n&&_.jsxs("div",{className:"flex items-center justify-end gap-1",children:[_.jsx(vJ,{}),_.jsx(yJ,{})]}),_.jsx("div",{className:"overflow-x-auto",children:_.jsx("table",{className:it("w-full border-collapse border border-border",t),"data-streamdown":"table",...r,children:e})})]}),EJ=C.lazy(()=>U(()=>import("./code-block-IT6T5CEO-BNFAFcIE.js"),[]).then(e=>({default:e.CodeBlock}))),wJ=C.lazy(()=>U(()=>Promise.resolve().then(()=>vfe),void 0).then(e=>({default:e.Mermaid}))),_J=/language-([^\s]+)/;function Km(e,t){if(!(e!=null&&e.position||t!=null&&t.position))return!0;if(!(e!=null&&e.position&&t!=null&&t.position))return!1;let n=e.position.start,r=t.position.start,i=e.position.end,a=t.position.end;return n?.line===r?.line&&n?.column===r?.column&&i?.line===a?.line&&i?.column===a?.column}function en(e,t){return e.className===t.className&&Km(e.node,t.node)}var wv=(e,t)=>typeof e=="boolean"?e:e[t]!==!1,rh=(e,t)=>{if(typeof e=="boolean")return e;let n=e.mermaid;return n===!1?!1:n===!0||n===void 0?!0:n[t]!==!1},k4=C.memo(({children:e,className:t,node:n,...r})=>_.jsx("ol",{className:it("list-inside list-decimal whitespace-normal",t),"data-streamdown":"ordered-list",...r,children:e}),(e,t)=>en(e,t));k4.displayName="MarkdownOl";var $C=C.memo(({children:e,className:t,node:n,...r})=>_.jsx("li",{className:it("py-1 [&>p]:inline",t),"data-streamdown":"list-item",...r,children:e}),(e,t)=>e.className===t.className&&Km(e.node,t.node));$C.displayName="MarkdownLi";var qC=C.memo(({children:e,className:t,node:n,...r})=>_.jsx("ul",{className:it("list-inside list-disc whitespace-normal",t),"data-streamdown":"unordered-list",...r,children:e}),(e,t)=>en(e,t));qC.displayName="MarkdownUl";var VC=C.memo(({className:e,node:t,...n})=>_.jsx("hr",{className:it("my-6 border-border",e),"data-streamdown":"horizontal-rule",...n}),(e,t)=>en(e,t));VC.displayName="MarkdownHr";var GC=C.memo(({children:e,className:t,node:n,...r})=>_.jsx("span",{className:it("font-semibold",t),"data-streamdown":"strong",...r,children:e}),(e,t)=>en(e,t));GC.displayName="MarkdownStrong";var YC=C.memo(({children:e,className:t,href:n,node:r,...i})=>{let a=n==="streamdown:incomplete-link";return _.jsx("a",{className:it("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":a,"data-streamdown":"link",href:n,rel:"noreferrer",target:"_blank",...i,children:e})},(e,t)=>en(e,t)&&e.href===t.href);YC.displayName="MarkdownA";var WC=C.memo(({children:e,className:t,node:n,...r})=>_.jsx("h1",{className:it("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...r,children:e}),(e,t)=>en(e,t));WC.displayName="MarkdownH1";var QC=C.memo(({children:e,className:t,node:n,...r})=>_.jsx("h2",{className:it("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...r,children:e}),(e,t)=>en(e,t));QC.displayName="MarkdownH2";var XC=C.memo(({children:e,className:t,node:n,...r})=>_.jsx("h3",{className:it("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...r,children:e}),(e,t)=>en(e,t));XC.displayName="MarkdownH3";var KC=C.memo(({children:e,className:t,node:n,...r})=>_.jsx("h4",{className:it("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...r,children:e}),(e,t)=>en(e,t));KC.displayName="MarkdownH4";var ZC=C.memo(({children:e,className:t,node:n,...r})=>_.jsx("h5",{className:it("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...r,children:e}),(e,t)=>en(e,t));ZC.displayName="MarkdownH5";var JC=C.memo(({children:e,className:t,node:n,...r})=>_.jsx("h6",{className:it("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...r,children:e}),(e,t)=>en(e,t));JC.displayName="MarkdownH6";var ek=C.memo(({children:e,className:t,node:n,...r})=>{let{controls:i}=C.useContext(Ti),a=wv(i,"table");return _.jsx(xJ,{className:t,"data-streamdown":"table-wrapper",showControls:a,...r,children:e})},(e,t)=>en(e,t));ek.displayName="MarkdownTable";var tk=C.memo(({children:e,className:t,node:n,...r})=>_.jsx("thead",{className:it("bg-muted/80",t),"data-streamdown":"table-header",...r,children:e}),(e,t)=>en(e,t));tk.displayName="MarkdownThead";var nk=C.memo(({children:e,className:t,node:n,...r})=>_.jsx("tbody",{className:it("divide-y divide-border bg-muted/40",t),"data-streamdown":"table-body",...r,children:e}),(e,t)=>en(e,t));nk.displayName="MarkdownTbody";var rk=C.memo(({children:e,className:t,node:n,...r})=>_.jsx("tr",{className:it("border-border border-b",t),"data-streamdown":"table-row",...r,children:e}),(e,t)=>en(e,t));rk.displayName="MarkdownTr";var ik=C.memo(({children:e,className:t,node:n,...r})=>_.jsx("th",{className:it("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",t),"data-streamdown":"table-header-cell",...r,children:e}),(e,t)=>en(e,t));ik.displayName="MarkdownTh";var ak=C.memo(({children:e,className:t,node:n,...r})=>_.jsx("td",{className:it("px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...r,children:e}),(e,t)=>en(e,t));ak.displayName="MarkdownTd";var sk=C.memo(({children:e,className:t,node:n,...r})=>_.jsx("blockquote",{className:it("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",t),"data-streamdown":"blockquote",...r,children:e}),(e,t)=>en(e,t));sk.displayName="MarkdownBlockquote";var ok=C.memo(({children:e,className:t,node:n,...r})=>_.jsx("sup",{className:it("text-sm",t),"data-streamdown":"superscript",...r,children:e}),(e,t)=>en(e,t));ok.displayName="MarkdownSup";var lk=C.memo(({children:e,className:t,node:n,...r})=>_.jsx("sub",{className:it("text-sm",t),"data-streamdown":"subscript",...r,children:e}),(e,t)=>en(e,t));lk.displayName="MarkdownSub";var uk=C.memo(({children:e,className:t,node:n,...r})=>{if("data-footnotes"in r){let i=o=>{var u,c;if(!C.isValidElement(o))return!1;let f=Array.isArray(o.props.children)?o.props.children:[o.props.children],h=!1,m=!1;for(let g of f)if(g){if(typeof g=="string")g.trim()!==""&&(h=!0);else if(C.isValidElement(g))if(((u=g.props)==null?void 0:u["data-footnote-backref"])!==void 0)m=!0;else{let b=Array.isArray(g.props.children)?g.props.children:[g.props.children];for(let y of b){if(typeof y=="string"&&y.trim()!==""){h=!0;break}if(C.isValidElement(y)&&((c=y.props)==null?void 0:c["data-footnote-backref"])===void 0){h=!0;break}}}}return m&&!h},a=Array.isArray(e)?e.map(o=>{if(!C.isValidElement(o))return o;if(o.type===k4){let u=(Array.isArray(o.props.children)?o.props.children:[o.props.children]).filter(c=>!i(c));return u.length===0?null:{...o,props:{...o.props,children:u}}}return o}):e;return(Array.isArray(a)?a.some(o=>o!==null):a!==null)?_.jsx("section",{className:t,...r,children:a}):null}return _.jsx("section",{className:t,...r,children:e})},(e,t)=>en(e,t));uk.displayName="MarkdownSection";var TJ=({node:e,className:t,children:n,...r})=>{var i,a,o;let u=((i=e?.position)==null?void 0:i.start.line)===((a=e?.position)==null?void 0:a.end.line),{mermaid:c,controls:f}=C.useContext(Ti);if(u)return _.jsx("code",{className:it("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...r,children:n});let h=t?.match(_J),m=(o=h?.at(1))!=null?o:"",g="";if(C.isValidElement(n)&&n.props&&typeof n.props=="object"&&"children"in n.props&&typeof n.props.children=="string"?g=n.props.children:typeof n=="string"&&(g=n),m==="mermaid"){let y=wv(f,"mermaid"),E=rh(f,"download"),A=rh(f,"copy"),k=rh(f,"fullscreen"),S=rh(f,"panZoom");return _.jsx(C.Suspense,{fallback:_.jsx(yw,{}),children:_.jsxs("div",{className:it("group relative my-4 h-auto rounded-xl border p-4",t),"data-streamdown":"mermaid-block",children:[y&&(E||A||k)&&_.jsxs("div",{className:"flex items-center justify-end gap-2",children:[E&&_.jsx(fJ,{chart:g,config:c?.config}),A&&_.jsx(bw,{code:g}),k&&_.jsx(pJ,{chart:g,config:c?.config})]}),_.jsx(wJ,{chart:g,config:c?.config,showControls:S})]})})}let b=wv(f,"code");return _.jsx(C.Suspense,{fallback:_.jsx(yw,{}),children:_.jsx(EJ,{className:it("overflow-x-auto border-border border-t",t),code:g,language:m,children:b&&_.jsxs(_.Fragment,{children:[_.jsx(lJ,{code:g,language:m}),_.jsx(bw,{})]})})})},ck=C.memo(TJ,(e,t)=>e.className===t.className&&Km(e.node,t.node));ck.displayName="MarkdownCode";var dk=C.memo(cJ,(e,t)=>e.className===t.className&&Km(e.node,t.node));dk.displayName="MarkdownImg";var fk=C.memo(({children:e,className:t,node:n,...r})=>{var i;let a=(Array.isArray(e)?e:[e]).filter(o=>o!=null&&o!=="");return a.length===1&&C.isValidElement(a[0])&&((i=a[0].props.node)==null?void 0:i.tagName)==="img"?_.jsx(_.Fragment,{children:e}):_.jsx("p",{className:t,...r,children:e})},(e,t)=>en(e,t));fk.displayName="MarkdownParagraph";var SJ={ol:k4,li:$C,ul:qC,hr:VC,strong:GC,a:YC,h1:WC,h2:QC,h3:XC,h4:KC,h5:ZC,h6:JC,table:ek,thead:tk,tbody:nk,tr:rk,th:ik,td:ak,blockquote:sk,code:ck,img:dk,pre:({children:e})=>e,sup:ok,sub:lk,p:fk,section:uk},xw=[],Ew={allowDangerousHtml:!0},ih=new WeakMap,AJ=class{constructor(){this.cache=new Map,this.keyCache=new WeakMap,this.maxSize=100}generateCacheKey(e){let t=this.keyCache.get(e);if(t)return t;let n=e.rehypePlugins,r=e.remarkPlugins,i=e.remarkRehypeOptions;if(!(n||r||i)){let h="default";return this.keyCache.set(e,h),h}let a=h=>{if(!h||h.length===0)return"";let m="";for(let g=0;g<h.length;g+=1){let b=h[g];if(g>0&&(m+=","),Array.isArray(b)){let[y,E]=b;if(typeof y=="function"){let A=ih.get(y);A||(A=y.name,ih.set(y,A)),m+=A}else m+=String(y);m+=":",m+=JSON.stringify(E)}else if(typeof b=="function"){let y=ih.get(b);y||(y=b.name,ih.set(b,y)),m+=y}else m+=String(b)}return m},o=a(n),u=a(r),c=i?JSON.stringify(i):"",f=`${u}::${o}::${c}`;return this.keyCache.set(e,f),f}get(e){let t=this.generateCacheKey(e),n=this.cache.get(t);return n&&(this.cache.delete(t),this.cache.set(t,n)),n}set(e,t){let n=this.generateCacheKey(e);if(this.cache.size>=this.maxSize){let r=this.cache.keys().next().value;r&&this.cache.delete(r)}this.cache.set(n,t)}clear(){this.cache.clear()}},ww=new AJ,hk=e=>{let t=CJ(e),n=e.children||"";return NJ(t.runSync(t.parse(n),n),e)},CJ=e=>{let t=ww.get(e);if(t)return t;let n=kJ(e);return ww.set(e,n),n},kJ=e=>{let t=e.rehypePlugins||xw,n=e.remarkPlugins||xw,r=e.remarkRehypeOptions?{...Ew,...e.remarkRehypeOptions}:Ew;return xZ().use(yK).use(n).use(tZ,r).use(t)},NJ=(e,t)=>CX(e,{Fragment:_.Fragment,components:t.components,ignoreInvalidStyle:!0,jsx:_.jsx,jsxs:_.jsxs,passKeys:!0,passNode:!0}),RJ=/\[\^[^\]\s]{1,200}\](?!:)/,OJ=/\[\^[^\]\s]{1,200}\]:/,MJ=/<\/(\w+)>/,DJ=/<(\w+)[\s>]/,F2=e=>{let t=0;for(;t<e.length&&(e[t]===" "||e[t]===" "||e[t]===`
384
384
  `||e[t]==="\r");)t+=1;return t+1<e.length&&e[t]==="$"&&e[t+1]==="$"},IJ=e=>{let t=e.length-1;for(;t>=0&&(e[t]===" "||e[t]===" "||e[t]===`
385
385
  `||e[t]==="\r");)t-=1;return t>=1&&e[t]==="$"&&e[t-1]==="$"},z2=e=>{let t=0;for(let n=0;n<e.length-1;n+=1)e[n]==="$"&&e[n+1]==="$"&&(t+=1,n+=1);return t},LJ=e=>{let t=RJ.test(e),n=OJ.test(e);if(t||n)return[e];let r=ni.lex(e,{gfm:!0}),i=[],a=[];for(let o of r){let u=o.raw,c=i.length;if(a.length>0){if(i[c-1]+=u,o.type==="html"){let f=u.match(MJ);if(f){let h=f[1];a.at(-1)===h&&a.pop()}}continue}if(o.type==="html"&&o.block){let f=u.match(DJ);if(f){let h=f[1];u.includes(`</${h}>`)||a.push(h)}}if(u.trim()==="$$"&&c>0){let f=i[c-1],h=F2(f),m=z2(f);if(h&&m%2===1){i[c-1]=f+u;continue}}if(c>0&&IJ(u)){let f=i[c-1],h=F2(f),m=z2(f),g=z2(u);if(h&&m%2===1&&!F2(u)&&g===1){i[c-1]=f+u;continue}}i.push(u)}return i},PJ={raw:Q$,katex:[rv,{errorColor:"var(--color-muted-foreground)"}],sanitize:[aq,{}],harden:[lF,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],allowedProtocols:["*"],defaultOrigin:void 0,allowDataImages:!0}]},BJ={gfm:[cW,{}],math:[fv,{singleDollarTextMath:!1}],cjkFriendly:[Mq,{}],cjkFriendlyGfmStrikethrough:[Iq,{}]},FJ=Object.values(PJ),zJ=Object.values(BJ),jJ={shikiTheme:["github-light","github-dark"],controls:!0,isAnimating:!1,mode:"streaming",mermaid:void 0},Ti=C.createContext(jJ),mk=C.memo(({content:e,shouldParseIncompleteMarkdown:t,...n})=>{let r=C.useMemo(()=>typeof e=="string"&&t?aQ(e.trim()):e,[e,t]);return _.jsx(hk,{...n,children:r})},(e,t)=>{if(e.content!==t.content||e.shouldParseIncompleteMarkdown!==t.shouldParseIncompleteMarkdown||e.index!==t.index)return!1;if(e.components!==t.components){let n=Object.keys(e.components||{}),r=Object.keys(t.components||{});if(n.length!==r.length||n.some(i=>{var a,o;return((a=e.components)==null?void 0:a[i])!==((o=t.components)==null?void 0:o[i])}))return!1}return!(e.rehypePlugins!==t.rehypePlugins||e.remarkPlugins!==t.remarkPlugins)});mk.displayName="Block";var HJ=["github-light","github-dark"],pk=C.memo(({children:e,mode:t="streaming",parseIncompleteMarkdown:n=!0,components:r,rehypePlugins:i=FJ,remarkPlugins:a=zJ,className:o,shikiTheme:u=HJ,mermaid:c,controls:f=!0,isAnimating:h=!1,BlockComponent:m=mk,parseMarkdownIntoBlocksFn:g=LJ,...b})=>{let y=C.useId(),[E,A]=C.useTransition(),[k,S]=C.useState([]),R=C.useMemo(()=>g(typeof e=="string"?e:""),[e,g]);C.useEffect(()=>{t==="streaming"?A(()=>{S(R)}):S(R)},[R,t]);let L=t==="streaming"?k:R,M=C.useMemo(()=>L.map((j,J)=>`${y}-${J}`),[L.length,y]),I=C.useMemo(()=>({shikiTheme:u,controls:f,isAnimating:h,mode:t,mermaid:c}),[u,f,h,t,c]),P=C.useMemo(()=>({...SJ,...r}),[r]);return C.useEffect(()=>{if(!(Array.isArray(i)&&i.some(X=>Array.isArray(X)?X[0]===rv:X===rv)))return;let j=!1;if(Array.isArray(a)){let X=a.find(pe=>Array.isArray(pe)?pe[0]===fv:pe===fv);X&&Array.isArray(X)&&X[1]&&(j=X[1].singleDollarTextMath===!0)}let J=typeof e=="string"?e:"",$=J.includes("$$"),te=j&&(/[^$]\$[^$]/.test(J)||/^\$[^$]/.test(J)||/[^$]\$$/.test(J));($||te)&&U(()=>Promise.resolve({}),__vite__mapDeps([0]))},[i,a,e]),t==="static"?_.jsx(Ti.Provider,{value:I,children:_.jsx("div",{className:it("space-y-4 whitespace-normal",o),children:_.jsx(hk,{components:P,rehypePlugins:i,remarkPlugins:a,...b,children:e})})}):_.jsx(Ti.Provider,{value:I,children:_.jsx("div",{className:it("space-y-4 whitespace-normal",o),children:L.map((j,J)=>_.jsx(m,{components:P,content:j,index:J,rehypePlugins:i,remarkPlugins:a,shouldParseIncompleteMarkdown:n,...b},M[J]))})})},(e,t)=>e.children===t.children&&e.shikiTheme===t.shikiTheme&&e.isAnimating===t.isAnimating&&e.mode===t.mode);pk.displayName="Streamdown";var UJ=({children:e,className:t,minZoom:n=.5,maxZoom:r=3,zoomStep:i=.1,showControls:a=!0,initialZoom:o=1,fullscreen:u=!1})=>{let c=C.useRef(null),f=C.useRef(null),[h,m]=C.useState(o),[g,b]=C.useState({x:0,y:0}),[y,E]=C.useState(!1),[A,k]=C.useState({x:0,y:0}),[S,R]=C.useState({x:0,y:0}),L=C.useCallback(X=>{m(pe=>Math.max(n,Math.min(r,pe+X)))},[n,r]),M=C.useCallback(()=>{L(i)},[L,i]),I=C.useCallback(()=>{L(-i)},[L,i]),P=C.useCallback(()=>{m(o),b({x:0,y:0})},[o]),j=C.useCallback(X=>{X.preventDefault();let pe=X.deltaY>0?-i:i;L(pe)},[L,i]),J=C.useCallback(X=>{if(X.button!==0||X.isPrimary===!1)return;E(!0),k({x:X.clientX,y:X.clientY}),R(g);let pe=X.currentTarget;pe instanceof HTMLElement&&pe.setPointerCapture(X.pointerId)},[g]),$=C.useCallback(X=>{if(!y)return;X.preventDefault();let pe=X.clientX-A.x,ne=X.clientY-A.y;b({x:S.x+pe,y:S.y+ne})},[y,A,S]),te=C.useCallback(X=>{E(!1);let pe=X.currentTarget;pe instanceof HTMLElement&&pe.releasePointerCapture(X.pointerId)},[]);return C.useEffect(()=>{let X=c.current;if(X)return X.addEventListener("wheel",j,{passive:!1}),()=>{X.removeEventListener("wheel",j)}},[j]),C.useEffect(()=>{let X=f.current;if(X&&y)return document.body.style.userSelect="none",X.addEventListener("pointermove",$,{passive:!1}),X.addEventListener("pointerup",te),X.addEventListener("pointercancel",te),()=>{document.body.style.userSelect="",X.removeEventListener("pointermove",$),X.removeEventListener("pointerup",te),X.removeEventListener("pointercancel",te)}},[y,$,te]),_.jsxs("div",{className:it("relative",u?"h-full w-full":"w-full",t),ref:c,style:{cursor:y?"grabbing":"grab"},children:[a&&_.jsxs("div",{className:it("absolute z-10 flex flex-col gap-1 rounded-md border border-border bg-background/90 p-1 shadow-sm backdrop-blur-sm",u?"bottom-4 left-4":"bottom-2 left-2"),children:[_.jsx("button",{className:"flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",disabled:h>=r,onClick:M,title:"Zoom in",type:"button",children:_.jsx(_Q,{size:16})}),_.jsx("button",{className:"flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",disabled:h<=n,onClick:I,title:"Zoom out",type:"button",children:_.jsx(SQ,{size:16})}),_.jsx("button",{className:"flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",onClick:P,title:"Reset zoom and pan",type:"button",children:_.jsx(yQ,{size:16})})]}),_.jsx("div",{className:it("origin-center transition-transform duration-150 ease-out",u&&"flex w-full items-center justify-center"),onPointerDown:J,ref:f,role:"application",style:{transform:`translate(${g.x}px, ${g.y}px) scale(${h})`,transformOrigin:"center center",touchAction:"none",willChange:"transform"},children:e})]})},gk=({chart:e,className:t,config:n,fullscreen:r=!1,showControls:i=!0})=>{let[a,o]=C.useState(null),[u,c]=C.useState(!0),[f,h]=C.useState(""),[m,g]=C.useState(""),[b,y]=C.useState(0),{mermaid:E}=C.useContext(Ti),A=E?.errorComponent;if(C.useEffect(()=>{(async()=>{try{o(null),c(!0);let S=await jC(n),R=e.split("").reduce((I,P)=>(I<<5)-I+P.charCodeAt(0)|0,0),L=`mermaid-${Math.abs(R)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:M}=await S.render(L,e);h(M),g(M)}catch(S){if(!(m||f)){let R=S instanceof Error?S.message:"Failed to render Mermaid chart";o(R)}}finally{c(!1)}})()},[e,n,b]),u&&!f&&!m)return _.jsx("div",{className:it("my-4 flex justify-center p-4",t),children:_.jsxs("div",{className:"flex items-center space-x-2 text-muted-foreground",children:[_.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-current border-b-2"}),_.jsx("span",{className:"text-sm",children:"Loading diagram..."})]})});if(a&&!f&&!m){let S=()=>y(R=>R+1);return A?_.jsx(A,{chart:e,error:a,retry:S}):_.jsxs("div",{className:it("rounded-lg border border-red-200 bg-red-50 p-4",t),children:[_.jsxs("p",{className:"font-mono text-red-700 text-sm",children:["Mermaid Error: ",a]}),_.jsxs("details",{className:"mt-2",children:[_.jsx("summary",{className:"cursor-pointer text-red-600 text-xs",children:"Show Code"}),_.jsx("pre",{className:"mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs",children:e})]})]})}let k=f||m;return _.jsx(UJ,{className:it(r?"h-full w-full overflow-hidden":"my-4 overflow-hidden",t),fullscreen:r,maxZoom:3,minZoom:.5,showControls:i,zoomStep:.1,children:_.jsx("div",{"aria-label":"Mermaid chart",className:it("flex justify-center",r&&"h-full w-full items-center"),dangerouslySetInnerHTML:{__html:k},role:"img"})})};async function $J(e){if(navigator.clipboard?.writeText)return navigator.clipboard.writeText(e);const t=document.createElement("span");t.textContent=e,t.style.whiteSpace="pre",t.style.userSelect="all",document.body.appendChild(t);const n=window.getSelection(),r=document.createRange();n?.removeAllRanges(),r.selectNode(t),n?.addRange(r);let i=!1;try{i=document.execCommand("copy")}finally{n?.removeAllRanges(),document.body.removeChild(t)}if(!i)throw new Error("Copy to clipboard failed")}function qJ(e=2e3){const[t,n]=C.useState(!1),[r,i]=C.useState(null);return{copy:C.useCallback(async o=>{i(null);try{await $J(o),n(!0),setTimeout(()=>n(!1),e)}catch(u){throw i(u),u}},[e]),isCopied:t,error:r}}const _w=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Tw=h4,Zm=(e,t)=>n=>{var r;if(t?.variants==null)return Tw(e,n?.class,n?.className);const{variants:i,defaultVariants:a}=t,o=Object.keys(i).map(f=>{const h=n?.[f],m=a?.[f];if(h===null)return null;const g=_w(h)||_w(m);return i[f][g]}),u=n&&Object.entries(n).reduce((f,h)=>{let[m,g]=h;return g===void 0||(f[m]=g),f},{}),c=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((f,h)=>{let{class:m,className:g,...b}=h;return Object.entries(b).every(y=>{let[E,A]=y;return Array.isArray(A)?A.includes({...a,...u}[E]):{...a,...u}[E]===A})?[...f,m,g]:f},[]);return Tw(e,o,c,n?.class,n?.className)};var Bu=oT();const VJ=Am(Bu);function Sw(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Jm(...e){return t=>{let n=!1;const r=e.map(i=>{const a=Sw(i,t);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let i=0;i<r.length;i++){const a=r[i];typeof a=="function"?a():Sw(e[i],null)}}}}function Ft(...e){return C.useCallback(Jm(...e),e)}function Rn(e){const t=YJ(e),n=C.forwardRef((r,i)=>{const{children:a,...o}=r,u=C.Children.toArray(a),c=u.find(QJ);if(c){const f=c.props.children,h=u.map(m=>m===c?C.Children.count(f)>1?C.Children.only(null):C.isValidElement(f)?f.props.children:null:m);return _.jsx(t,{...o,ref:i,children:C.isValidElement(f)?C.cloneElement(f,void 0,h):null})}return _.jsx(t,{...o,ref:i,children:a})});return n.displayName=`${e}.Slot`,n}var GJ=Rn("Slot");function YJ(e){const t=C.forwardRef((n,r)=>{const{children:i,...a}=n;if(C.isValidElement(i)){const o=KJ(i),u=XJ(a,i.props);return i.type!==C.Fragment&&(u.ref=r?Jm(r,o):o),C.cloneElement(i,u)}return C.Children.count(i)>1?C.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var WJ=Symbol("radix.slottable");function QJ(e){return C.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===WJ}function XJ(e,t){const n={...t};for(const r in t){const i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...u)=>{const c=a(...u);return i(...u),c}:i&&(n[r]=i):r==="style"?n[r]={...i,...a}:r==="className"&&(n[r]=[i,a].filter(Boolean).join(" "))}return{...e,...n}}function KJ(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var ZJ=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],JJ=ZJ.reduce((e,t)=>{const n=Rn(`Primitive.${t}`),r=C.forwardRef((i,a)=>{const{asChild:o,...u}=i,c=o?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),_.jsx(c,{...u,ref:a})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),bk=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),eee="VisuallyHidden",tee=C.forwardRef((e,t)=>_.jsx(JJ.span,{...e,ref:t,style:{...bk,...e.style}}));tee.displayName=eee;function nee(e,t){const n=C.createContext(t),r=a=>{const{children:o,...u}=a,c=C.useMemo(()=>u,Object.values(u));return _.jsx(n.Provider,{value:c,children:o})};r.displayName=e+"Provider";function i(a){const o=C.useContext(n);if(o)return o;if(t!==void 0)return t;throw new Error(`\`${a}\` must be used within \`${e}\``)}return[r,i]}function Jo(e,t=[]){let n=[];function r(a,o){const u=C.createContext(o),c=n.length;n=[...n,o];const f=m=>{const{scope:g,children:b,...y}=m,E=g?.[e]?.[c]||u,A=C.useMemo(()=>y,Object.values(y));return _.jsx(E.Provider,{value:A,children:b})};f.displayName=a+"Provider";function h(m,g){const b=g?.[e]?.[c]||u,y=C.useContext(b);if(y)return y;if(o!==void 0)return o;throw new Error(`\`${m}\` must be used within \`${a}\``)}return[f,h]}const i=()=>{const a=n.map(o=>C.createContext(o));return function(u){const c=u?.[e]||a;return C.useMemo(()=>({[`__scope${e}`]:{...u,[e]:c}}),[u,c])}};return i.scopeName=e,[r,ree(i,...t)]}function ree(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(a){const o=r.reduce((u,{useScope:c,scopeName:f})=>{const m=c(a)[`__scope${f}`];return{...u,...m}},{});return C.useMemo(()=>({[`__scope${t.scopeName}`]:o}),[o])}};return n.scopeName=t.scopeName,n}function N4(e){const t=e+"CollectionProvider",[n,r]=Jo(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=E=>{const{scope:A,children:k}=E,S=Jr.useRef(null),R=Jr.useRef(new Map).current;return _.jsx(i,{scope:A,itemMap:R,collectionRef:S,children:k})};o.displayName=t;const u=e+"CollectionSlot",c=Rn(u),f=Jr.forwardRef((E,A)=>{const{scope:k,children:S}=E,R=a(u,k),L=Ft(A,R.collectionRef);return _.jsx(c,{ref:L,children:S})});f.displayName=u;const h=e+"CollectionItemSlot",m="data-radix-collection-item",g=Rn(h),b=Jr.forwardRef((E,A)=>{const{scope:k,children:S,...R}=E,L=Jr.useRef(null),M=Ft(A,L),I=a(h,k);return Jr.useEffect(()=>(I.itemMap.set(L,{ref:L,...R}),()=>{I.itemMap.delete(L)})),_.jsx(g,{[m]:"",ref:M,children:S})});b.displayName=h;function y(E){const A=a(e+"CollectionConsumer",E);return Jr.useCallback(()=>{const S=A.collectionRef.current;if(!S)return[];const R=Array.from(S.querySelectorAll(`[${m}]`));return Array.from(A.itemMap.values()).sort((I,P)=>R.indexOf(I.ref.current)-R.indexOf(P.ref.current))},[A.collectionRef,A.itemMap])}return[{Provider:o,Slot:f,ItemSlot:b},y,r]}function $e(e,t,{checkForDefaultPrevented:n=!0}={}){return function(i){if(e?.(i),n===!1||!i.defaultPrevented)return t?.(i)}}var Vn=globalThis?.document?C.useLayoutEffect:()=>{},iee=hy[" useInsertionEffect ".trim().toString()]||Vn;function xu({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[i,a,o]=aee({defaultProp:t,onChange:n}),u=e!==void 0,c=u?e:i;{const h=C.useRef(e!==void 0);C.useEffect(()=>{const m=h.current;m!==u&&console.warn(`${r} is changing from ${m?"controlled":"uncontrolled"} to ${u?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),h.current=u},[u,r])}const f=C.useCallback(h=>{if(u){const m=see(h)?h(e):h;m!==e&&o.current?.(m)}else a(h)},[u,e,a,o]);return[c,f]}function aee({defaultProp:e,onChange:t}){const[n,r]=C.useState(e),i=C.useRef(n),a=C.useRef(t);return iee(()=>{a.current=t},[t]),C.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}function see(e){return typeof e=="function"}function oee(e,t){return C.useReducer((n,r)=>t[n][r]??n,e)}var Ys=e=>{const{present:t,children:n}=e,r=lee(t),i=typeof n=="function"?n({present:r.isPresent}):C.Children.only(n),a=Ft(r.ref,uee(i));return typeof n=="function"||r.isPresent?C.cloneElement(i,{ref:a}):null};Ys.displayName="Presence";function lee(e){const[t,n]=C.useState(),r=C.useRef(null),i=C.useRef(e),a=C.useRef("none"),o=e?"mounted":"unmounted",[u,c]=oee(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return C.useEffect(()=>{const f=ah(r.current);a.current=u==="mounted"?f:"none"},[u]),Vn(()=>{const f=r.current,h=i.current;if(h!==e){const g=a.current,b=ah(f);e?c("MOUNT"):b==="none"||f?.display==="none"?c("UNMOUNT"):c(h&&g!==b?"ANIMATION_OUT":"UNMOUNT"),i.current=e}},[e,c]),Vn(()=>{if(t){let f;const h=t.ownerDocument.defaultView??window,m=b=>{const E=ah(r.current).includes(CSS.escape(b.animationName));if(b.target===t&&E&&(c("ANIMATION_END"),!i.current)){const A=t.style.animationFillMode;t.style.animationFillMode="forwards",f=h.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=A)})}},g=b=>{b.target===t&&(a.current=ah(r.current))};return t.addEventListener("animationstart",g),t.addEventListener("animationcancel",m),t.addEventListener("animationend",m),()=>{h.clearTimeout(f),t.removeEventListener("animationstart",g),t.removeEventListener("animationcancel",m),t.removeEventListener("animationend",m)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(u),ref:C.useCallback(f=>{r.current=f?getComputedStyle(f):null,n(f)},[])}}function ah(e){return e?.animationName||"none"}function uee(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var cee=hy[" useId ".trim().toString()]||(()=>{}),dee=0;function _i(e){const[t,n]=C.useState(cee());return Vn(()=>{n(r=>r??String(dee++))},[e]),e||(t?`radix-${t}`:"")}var fee=C.createContext(void 0);function R4(e){const t=C.useContext(fee);return e||t||"ltr"}var hee=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],vk=hee.reduce((e,t)=>{const n=Rn(`Primitive.${t}`),r=C.forwardRef((i,a)=>{const{asChild:o,...u}=i,c=o?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),_.jsx(c,{...u,ref:a})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function mee(e,t){e&&Bu.flushSync(()=>e.dispatchEvent(t))}function Si(e){const t=C.useRef(e);return C.useEffect(()=>{t.current=e}),C.useMemo(()=>(...n)=>t.current?.(...n),[])}function pee(e,t=globalThis?.document){const n=Si(e);C.useEffect(()=>{const r=i=>{i.key==="Escape"&&n(i)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var gee="DismissableLayer",_v="dismissableLayer.update",bee="dismissableLayer.pointerDownOutside",vee="dismissableLayer.focusOutside",Aw,yk=C.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),ep=C.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:a,onInteractOutside:o,onDismiss:u,...c}=e,f=C.useContext(yk),[h,m]=C.useState(null),g=h?.ownerDocument??globalThis?.document,[,b]=C.useState({}),y=Ft(t,P=>m(P)),E=Array.from(f.layers),[A]=[...f.layersWithOutsidePointerEventsDisabled].slice(-1),k=E.indexOf(A),S=h?E.indexOf(h):-1,R=f.layersWithOutsidePointerEventsDisabled.size>0,L=S>=k,M=Eee(P=>{const j=P.target,J=[...f.branches].some($=>$.contains(j));!L||J||(i?.(P),o?.(P),P.defaultPrevented||u?.())},g),I=wee(P=>{const j=P.target;[...f.branches].some($=>$.contains(j))||(a?.(P),o?.(P),P.defaultPrevented||u?.())},g);return pee(P=>{S===f.layers.size-1&&(r?.(P),!P.defaultPrevented&&u&&(P.preventDefault(),u()))},g),C.useEffect(()=>{if(h)return n&&(f.layersWithOutsidePointerEventsDisabled.size===0&&(Aw=g.body.style.pointerEvents,g.body.style.pointerEvents="none"),f.layersWithOutsidePointerEventsDisabled.add(h)),f.layers.add(h),Cw(),()=>{n&&f.layersWithOutsidePointerEventsDisabled.size===1&&(g.body.style.pointerEvents=Aw)}},[h,g,n,f]),C.useEffect(()=>()=>{h&&(f.layers.delete(h),f.layersWithOutsidePointerEventsDisabled.delete(h),Cw())},[h,f]),C.useEffect(()=>{const P=()=>b({});return document.addEventListener(_v,P),()=>document.removeEventListener(_v,P)},[]),_.jsx(vk.div,{...c,ref:y,style:{pointerEvents:R?L?"auto":"none":void 0,...e.style},onFocusCapture:$e(e.onFocusCapture,I.onFocusCapture),onBlurCapture:$e(e.onBlurCapture,I.onBlurCapture),onPointerDownCapture:$e(e.onPointerDownCapture,M.onPointerDownCapture)})});ep.displayName=gee;var yee="DismissableLayerBranch",xee=C.forwardRef((e,t)=>{const n=C.useContext(yk),r=C.useRef(null),i=Ft(t,r);return C.useEffect(()=>{const a=r.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),_.jsx(vk.div,{...e,ref:i})});xee.displayName=yee;function Eee(e,t=globalThis?.document){const n=Si(e),r=C.useRef(!1),i=C.useRef(()=>{});return C.useEffect(()=>{const a=u=>{if(u.target&&!r.current){let c=function(){xk(bee,n,f,{discrete:!0})};const f={originalEvent:u};u.pointerType==="touch"?(t.removeEventListener("click",i.current),i.current=c,t.addEventListener("click",i.current,{once:!0})):c()}else t.removeEventListener("click",i.current);r.current=!1},o=window.setTimeout(()=>{t.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(o),t.removeEventListener("pointerdown",a),t.removeEventListener("click",i.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function wee(e,t=globalThis?.document){const n=Si(e),r=C.useRef(!1);return C.useEffect(()=>{const i=a=>{a.target&&!r.current&&xk(vee,n,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",i),()=>t.removeEventListener("focusin",i)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Cw(){const e=new CustomEvent(_v);document.dispatchEvent(e)}function xk(e,t,n,{discrete:r}){const i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?mee(i,a):i.dispatchEvent(a)}var _ee=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Tee=_ee.reduce((e,t)=>{const n=Rn(`Primitive.${t}`),r=C.forwardRef((i,a)=>{const{asChild:o,...u}=i,c=o?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),_.jsx(c,{...u,ref:a})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),j2="focusScope.autoFocusOnMount",H2="focusScope.autoFocusOnUnmount",kw={bubbles:!1,cancelable:!0},See="FocusScope",tp=C.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[u,c]=C.useState(null),f=Si(i),h=Si(a),m=C.useRef(null),g=Ft(t,E=>c(E)),b=C.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;C.useEffect(()=>{if(r){let E=function(R){if(b.paused||!u)return;const L=R.target;u.contains(L)?m.current=L:Cs(m.current,{select:!0})},A=function(R){if(b.paused||!u)return;const L=R.relatedTarget;L!==null&&(u.contains(L)||Cs(m.current,{select:!0}))},k=function(R){if(document.activeElement===document.body)for(const M of R)M.removedNodes.length>0&&Cs(u)};document.addEventListener("focusin",E),document.addEventListener("focusout",A);const S=new MutationObserver(k);return u&&S.observe(u,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",E),document.removeEventListener("focusout",A),S.disconnect()}}},[r,u,b.paused]),C.useEffect(()=>{if(u){Rw.add(b);const E=document.activeElement;if(!u.contains(E)){const k=new CustomEvent(j2,kw);u.addEventListener(j2,f),u.dispatchEvent(k),k.defaultPrevented||(Aee(Oee(Ek(u)),{select:!0}),document.activeElement===E&&Cs(u))}return()=>{u.removeEventListener(j2,f),setTimeout(()=>{const k=new CustomEvent(H2,kw);u.addEventListener(H2,h),u.dispatchEvent(k),k.defaultPrevented||Cs(E??document.body,{select:!0}),u.removeEventListener(H2,h),Rw.remove(b)},0)}}},[u,f,h,b]);const y=C.useCallback(E=>{if(!n&&!r||b.paused)return;const A=E.key==="Tab"&&!E.altKey&&!E.ctrlKey&&!E.metaKey,k=document.activeElement;if(A&&k){const S=E.currentTarget,[R,L]=Cee(S);R&&L?!E.shiftKey&&k===L?(E.preventDefault(),n&&Cs(R,{select:!0})):E.shiftKey&&k===R&&(E.preventDefault(),n&&Cs(L,{select:!0})):k===S&&E.preventDefault()}},[n,r,b.paused]);return _.jsx(Tee.div,{tabIndex:-1,...o,ref:g,onKeyDown:y})});tp.displayName=See;function Aee(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Cs(r,{select:t}),document.activeElement!==n)return}function Cee(e){const t=Ek(e),n=Nw(t,e),r=Nw(t.reverse(),e);return[n,r]}function Ek(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Nw(e,t){for(const n of e)if(!kee(n,{upTo:t}))return n}function kee(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Nee(e){return e instanceof HTMLInputElement&&"select"in e}function Cs(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Nee(e)&&t&&e.select()}}var Rw=Ree();function Ree(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=Ow(e,t),e.unshift(t)},remove(t){e=Ow(e,t),e[0]?.resume()}}}function Ow(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Oee(e){return e.filter(t=>t.tagName!=="A")}var Mee=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Dee=Mee.reduce((e,t)=>{const n=Rn(`Primitive.${t}`),r=C.forwardRef((i,a)=>{const{asChild:o,...u}=i,c=o?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),_.jsx(c,{...u,ref:a})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),Iee="Portal",np=C.forwardRef((e,t)=>{const{container:n,...r}=e,[i,a]=C.useState(!1);Vn(()=>a(!0),[]);const o=n||i&&globalThis?.document?.body;return o?VJ.createPortal(_.jsx(Dee.div,{...r,ref:t}),o):null});np.displayName=Iee;var Lee=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ud=Lee.reduce((e,t)=>{const n=Rn(`Primitive.${t}`),r=C.forwardRef((i,a)=>{const{asChild:o,...u}=i,c=o?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),_.jsx(c,{...u,ref:a})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),U2=0;function O4(){C.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Mw()),document.body.insertAdjacentElement("beforeend",e[1]??Mw()),U2++,()=>{U2===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),U2--}},[])}function Mw(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Vi=function(){return Vi=Object.assign||function(t){for(var n,r=1,i=arguments.length;r<i;r++){n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},Vi.apply(this,arguments)};function wk(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function Pee(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||(a=Array.prototype.slice.call(t,0,r)),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var Ah="right-scroll-bar-position",Ch="width-before-scroll-bar",Bee="with-scroll-bars-hidden",Fee="--removed-body-scroll-bar-size";function $2(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function zee(e,t){var n=C.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var i=n.value;i!==r&&(n.value=r,n.callback(r,i))}}}})[0];return n.callback=t,n.facade}var jee=typeof window<"u"?C.useLayoutEffect:C.useEffect,Dw=new WeakMap;function Hee(e,t){var n=zee(null,function(r){return e.forEach(function(i){return $2(i,r)})});return jee(function(){var r=Dw.get(n);if(r){var i=new Set(r),a=new Set(e),o=n.current;i.forEach(function(u){a.has(u)||$2(u,null)}),a.forEach(function(u){i.has(u)||$2(u,o)})}Dw.set(n,e)},[e]),n}function Uee(e){return e}function $ee(e,t){t===void 0&&(t=Uee);var n=[],r=!1,i={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(a){var o=t(a,r);return n.push(o),function(){n=n.filter(function(u){return u!==o})}},assignSyncMedium:function(a){for(r=!0;n.length;){var o=n;n=[],o.forEach(a)}n={push:function(u){return a(u)},filter:function(){return n}}},assignMedium:function(a){r=!0;var o=[];if(n.length){var u=n;n=[],u.forEach(a),o=n}var c=function(){var h=o;o=[],h.forEach(a)},f=function(){return Promise.resolve().then(c)};f(),n={push:function(h){o.push(h),f()},filter:function(h){return o=o.filter(h),n}}}};return i}function qee(e){e===void 0&&(e={});var t=$ee(null);return t.options=Vi({async:!0,ssr:!1},e),t}var _k=function(e){var t=e.sideCar,n=wk(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return C.createElement(r,Vi({},n))};_k.isSideCarExport=!0;function Vee(e,t){return e.useMedium(t),_k}var Tk=qee(),q2=function(){},rp=C.forwardRef(function(e,t){var n=C.useRef(null),r=C.useState({onScrollCapture:q2,onWheelCapture:q2,onTouchMoveCapture:q2}),i=r[0],a=r[1],o=e.forwardProps,u=e.children,c=e.className,f=e.removeScrollBar,h=e.enabled,m=e.shards,g=e.sideCar,b=e.noRelative,y=e.noIsolation,E=e.inert,A=e.allowPinchZoom,k=e.as,S=k===void 0?"div":k,R=e.gapMode,L=wk(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),M=g,I=Hee([n,t]),P=Vi(Vi({},L),i);return C.createElement(C.Fragment,null,h&&C.createElement(M,{sideCar:Tk,removeScrollBar:f,shards:m,noRelative:b,noIsolation:y,inert:E,setCallbacks:a,allowPinchZoom:!!A,lockRef:n,gapMode:R}),o?C.cloneElement(C.Children.only(u),Vi(Vi({},P),{ref:I})):C.createElement(S,Vi({},P,{className:c,ref:I}),u))});rp.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};rp.classNames={fullWidth:Ch,zeroRight:Ah};var Gee=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Yee(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Gee();return t&&e.setAttribute("nonce",t),e}function Wee(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Qee(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Xee=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Yee())&&(Wee(t,n),Qee(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Kee=function(){var e=Xee();return function(t,n){C.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Sk=function(){var e=Kee(),t=function(n){var r=n.styles,i=n.dynamic;return e(r,i),null};return t},Zee={left:0,top:0,right:0,gap:0},V2=function(e){return parseInt(e||"",10)||0},Jee=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],i=t[e==="padding"?"paddingRight":"marginRight"];return[V2(n),V2(r),V2(i)]},ete=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Zee;var t=Jee(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},tte=Sk(),fu="data-scroll-locked",nte=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,u=e.gap;return n===void 0&&(n="margin"),`
386
386
  .`.concat(Bee,` {
@@ -1698,4 +1698,4 @@ ${O0e}
1698
1698
  `,g+=`@@ -0,0 +1,${m.length} @@
1699
1699
  `;for(const b of m)g+=`+${b}
1700
1700
  `;return g})(),c=i?i.split(`
1701
- `).length:0,f=r?`Write ${r}`:e.title,h=Hu("write");return u||o?_.jsxs("div",{className:"text-tool-foreground my-1 text-xs",children:[_.jsxs("div",{className:"mb-1 flex items-center gap-2",children:[a!=="completed"&&a!=="failed"&&_.jsx(Ap,{status:a}),_.jsx(h,{className:"size-3"}),_.jsx("span",{children:f}),c>0&&_.jsxs("span",{className:"text-diff-add flex items-center",children:[_.jsx(T0,{className:"size-2.5"}),c]}),o&&_.jsx(X0,{className:"text-destructive size-3"})]}),u&&_.jsx(eM,{patch:u,fileName:r}),e.error&&_.jsx("div",{className:"text-destructive mt-1 text-[11px]",children:e.error})]}):_.jsx(Vu,{toolCall:e,status:a,icon:_.jsx(h,{className:"size-3"}),title:f})}function lde({toolCall:e,status:t}){const n=e.input?.subagent_type,r=e.input?.description,i=n?`${n.charAt(0).toUpperCase()+n.slice(1)} Task`:e.title||"Task",a=r?`"${r}"`:void 0,o=Hu("task");return _.jsx(Vu,{toolCall:e,status:t,icon:_.jsx(o,{className:"size-3"}),title:i,subtitle:a,children:e.output&&_.jsx(z0,{className:"text-muted-foreground mt-1 text-[11px]",children:_.jsx("pre",{className:"break-words whitespace-pre-wrap",children:e.output})})})}function ude({toolCall:e,status:t}){const n=tM(e),r=Hu(n);return _.jsxs(Vu,{toolCall:e,status:t,icon:_.jsx(r,{className:"size-3"}),title:e.title,children:[e.output&&_.jsx(z0,{className:"text-muted-foreground mt-1 text-[11px]",children:_.jsx("pre",{className:"break-words whitespace-pre-wrap",children:e.output})}),e.error&&_.jsx("div",{className:"text-destructive mt-1 text-[11px]",children:e.error})]})}const cde={bash:Z_,shell:Z_,edit:ade,read:sde,write:ode,task:lde},dde=C.memo(function({toolCall:t,isStreaming:n=!1}){const i=!n&&(t.status==="pending"||t.status==="in_progress")?"failed":t.status,a=tM(t),o=cde[a];if(o)return _.jsx(o,{toolCall:t,status:i});if(!ide(t)){const u=Hu(a);return _.jsxs("div",{className:"text-tool-foreground my-0.5 flex items-start gap-1.5 text-xs",children:[_.jsx("div",{className:"mt-0.5 shrink-0",children:_.jsx(u,{className:"size-3"})}),_.jsxs("div",{className:"flex items-center gap-1.5",children:[_.jsx("span",{className:"truncate",children:t.title}),i==="failed"&&_.jsx(X0,{className:"text-destructive size-3"}),i!=="completed"&&i!=="failed"&&_.jsx(Ap,{status:i})]})]})}return _.jsx(ude,{toolCall:t,status:i})}),ny=C.forwardRef(({className:e,role:t,children:n,...r},i)=>{const a=t==="user"?"border-l-[color:var(--accent)]":"border-l-[color:var(--tool-foreground)]",o=t==="user"?"bg-accent/5 dark:bg-accent/5":"";return _.jsx("div",{ref:i,className:Ge("border-l-2","py-2 pl-2",a,o,e),...r,children:n})});ny.displayName="MessageCard";const fde=({className:e,...t})=>_.jsx(_u,{className:Ge("relative flex-1 overflow-y-hidden",e),initial:"smooth",resize:"smooth",role:"log",...t}),hde=({className:e,...t})=>_.jsx(_u.Content,{className:Ge("flex flex-col gap-8 p-4",e),...t});function mde({className:e}){const{isAtBottom:t,scrollToBottom:n}=o3(),r=C.useCallback(()=>{n()},[n]);return t?null:_.jsx(ui,{className:Ge("absolute bottom-4 left-[50%] translate-x-[-50%]","min-h-[44px] min-w-[44px]","border-accent text-accent hover:bg-accent/20",e),onClick:r,size:"icon",type:"button",variant:"outline",children:_.jsx("span",{className:"text-sm select-none",children:"↓"})})}function pde({onScrollToBottom:e}){const{scrollToBottom:t}=o3();return C.useEffect(()=>{e(t)},[t,e]),null}function gde({text:e}){const{copy:t,isCopied:n}=qJ(),r=()=>{e&&t(e)},i=n?_y:pB;return _.jsx(ui,{variant:"ghost",size:"icon",onClick:r,className:"text-muted-foreground hover:text-foreground size-6",children:_.jsx(i,{className:"size-3"})})}function J_({copyText:e}){return _.jsx("div",{className:"border-border/10 mt-2 -ml-1.5 flex items-center gap-1 border-b pt-2 pb-2",children:_.jsx(gde,{text:e})})}function bde(){return _.jsxs("span",{className:"text-muted-foreground text-xs",children:[_.jsx("span",{className:"animate-pulse",children:"."}),_.jsx("span",{className:"animate-pulse",style:{animationDelay:"0.2s"},children:"."}),_.jsx("span",{className:"animate-pulse",style:{animationDelay:"0.4s"},children:"."})]})}function vde({content:e}){return e.trim()?_.jsxs("div",{className:"text-muted-foreground my-1 flex items-start gap-1.5 text-xs",children:[_.jsx(rB,{className:"mt-0.5 size-3 shrink-0"}),_.jsx("div",{className:"text-muted-foreground text-xs italic",children:e})]}):null}function yde({message:e,isStreaming:t=!1}){const n=e.role==="user";if(e.role==="thought")return _.jsx("div",{className:"px-2 pt-2",children:_.jsx(vde,{content:e.content})});if(n)return _.jsx("div",{className:"px-2 pt-2",children:_.jsx(ny,{role:"user",className:"w-full",children:_.jsx("div",{className:"flex items-start gap-2",children:_.jsxs("div",{className:"min-w-0 flex-1 overflow-hidden",children:[_.jsx("p",{className:"text-foreground inline text-sm break-words whitespace-pre-wrap",children:e.content}),_.jsx(J_,{copyText:e.content})]})})})});const i=!e.content&&!e.toolCalls?.length;return _.jsx("div",{className:"px-2 pt-2",children:_.jsx(ny,{role:"agent",className:"w-full",children:_.jsx("div",{className:"flex items-start gap-2",children:_.jsx("div",{className:"min-w-0 flex-1 overflow-hidden",children:i?_.jsx(bde,{}):_.jsxs(_.Fragment,{children:[e.content&&_.jsx(pk,{className:"streamdown-content",mode:t?"streaming":"static",isAnimating:t,controls:{table:!1,code:!1},shikiTheme:tde,children:e.content}),e.toolCalls?.map(a=>_.jsx(dde,{toolCall:a,isStreaming:t},a.id)),e.content&&_.jsx(J_,{copyText:e.content})]})})})})})}const xde=C.memo(function({messages:t,isStreaming:n=!1,onScrollToBottom:r}){const i=[...t].reverse().findIndex(o=>o.role==="agent"),a=i>=0?t.length-1-i:-1;return _.jsxs(fde,{className:"[&>div]:overflow-auto",initial:"instant",children:[_.jsx(hde,{className:"gap-0 px-0",children:t.map((o,u)=>_.jsx(yde,{message:o,isStreaming:n&&u===a},o.id))}),_.jsx(mde,{}),r&&_.jsx(pde,{onScrollToBottom:r})]})}),Ede=C.memo(function({permission:t,onSelect:n}){return _.jsxs("div",{className:"p-4 border-t bg-yellow-50 dark:bg-yellow-900/20",children:[_.jsxs("div",{className:"font-medium mb-2",children:["Permission Required: ",t.title]}),_.jsx("div",{className:"flex gap-2 flex-wrap",children:t.options.map(r=>_.jsx("button",{onClick:()=>n(r.optionId),className:"px-3 py-1 bg-white dark:bg-gray-800 border rounded hover:bg-gray-50 dark:hover:bg-gray-700",children:r.name},r.optionId))})]})});function wde(){const[e,t]=C.useState(()=>typeof window>"u"?!1:window.matchMedia("(pointer: coarse)").matches);return C.useEffect(()=>{const n=window.matchMedia("(pointer: coarse)"),r=i=>{t(i.matches)};return n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),e}function _de(e,t=140){const n=Ht(i=>i.setBottomBarCollapsed),r=C.useRef(null);C.useEffect(()=>{const i=window.visualViewport;if(!i)return;const a=()=>{const u=e.current;if(!u)return;if(document.activeElement===u||u.contains(document.activeElement)){r.current===null&&(r.current=i.height);const f=r.current-i.height;n(f>t)}else r.current=null,n(!1)},o=()=>{r.current=null,n(!1)};return i.addEventListener("resize",a),e.current?.addEventListener("blur",o),()=>{i.removeEventListener("resize",a),e.current?.removeEventListener("blur",o)}},[e,t,n])}function yh(e,t,n){return{onMutate:async r=>{await e.windows.list.cancel();const i=e.windows.list.getData();return i&&e.windows.list.setData(void 0,t(i,r)),{previous:i}},onError:(r,i,a)=>{a?.previous&&e.windows.list.setData(void 0,a.previous)},onSettled:n?.skipInvalidate?void 0:()=>{e.windows.list.invalidate()}}}function eT(e){return{type:"leaf",paneId:e}}function Tde(e,t,n,r=50){return{type:"branch",direction:e,ratio:r,first:t,second:n}}function ry(e,t,n=[]){if(e.type==="leaf")return e.paneId===t?n:null;const r=ry(e.first,t,[...n,"first"]);return r||ry(e.second,t,[...n,"second"])}function iy(e,t,n){return e.type==="leaf"?e.paneId===t?n:e:{...e,first:iy(e.first,t,n),second:iy(e.second,t,n)}}function Sde(e,t,n,r){const i=eT(t),a=eT(n),o=Tde(r,i,a);return iy(e,t,o)}function Ade(e,t,n){const r=ry(e,t);if(!r)return null;let i=e;const a=[];for(const o of r)i.type==="branch"&&(a.push({node:i,childSide:o}),i=o==="first"?i.first:i.second);for(let o=a.length-1;o>=0;o--){const{node:u,childSide:c}=a[o],f=u.direction==="horizontal",h=u.direction==="vertical";if(n==="left"&&f&&c==="second"||n==="right"&&f&&c==="first"||n==="up"&&h&&c==="second"||n==="down"&&h&&c==="first"){const g=c==="first"?u.second:u.first;return ay(g,n)}}return null}function ay(e,t){if(e.type==="leaf")return e.paneId;const n=e.direction==="horizontal";if(t==="left"||t==="up"){const r=e.first;return ay(r,t)}else{const r=e.second;return ay(r,t)}}function nl(){const e=jt.useUtils(),t=jt.windows.delete.useMutation(yh(e,(g,{id:b})=>{const y=g.windows.filter(E=>E.id!==b);return{...g,windows:y,activeWindowId:g.activeWindowId===b?y[y.length-1]?.id??null:g.activeWindowId}})),n=jt.windows.setActive.useMutation(yh(e,(g,{id:b})=>({...g,activeWindowId:b}),{skipInvalidate:!0})),r=jt.windows.update.useMutation(yh(e,(g,{id:b,title:y})=>({...g,windows:g.windows.map(E=>E.id===b&&y?{...E,title:y}:E)}))),i=jt.windows.create.useMutation({onMutate:async g=>{await e.windows.list.cancel();const b=e.windows.list.getData();return b&&e.windows.list.setData(void 0,{...b,windows:[...b.windows,{id:g.id,title:g.title,hasCustomTitle:!!g.title,directory:g.directory??"",agentConfigId:g.agentConfigId??"",sessionId:null,model:null,mode:null,createdAt:new Date().toISOString(),lastAccessedAt:new Date().toISOString(),isOptimistic:!0}]}),{previous:b}},onSuccess:async g=>{await new Promise(b=>setTimeout(b,300)),e.windows.list.setData(void 0,b=>b&&{...b,windows:b.windows.map(y=>y.id===g.id?g:y),activeWindowId:g.id})},onError:(g,b,y)=>{y?.previous&&e.windows.list.setData(void 0,y.previous)}}),a=jt.agents.cancel.useMutation(),o=jt.layout.split.useMutation({onMutate:async({windowId:g,paneId:b,direction:y,newPaneId:E,newSessionId:A})=>{await e.windows.list.cancel();const k=e.windows.list.getData();if(!k)return{prev:k};const S=k.windows.find(I=>I.id===g),R=S?.panes.find(I=>I.id===b);if(!S||!R||!E)return{prev:k};const L=new Date().toISOString(),M={id:E,windowId:g,sessionId:null,createdAt:L,session:R.session?{...R.session,id:"__optimistic__",model:null,mode:null,createdAt:L}:null};return e.windows.list.setData(void 0,{...k,windows:k.windows.map(I=>I.id!==g?I:{...I,layout:Sde(I.layout,b,E,y),activePaneId:E,panes:[...I.panes,M]})}),Ht.getState().initPane(E),{prev:k,newPaneId:E}},onError:(g,b,y)=>{y?.prev&&e.windows.list.setData(void 0,y.prev),y?.newPaneId&&Ht.getState().deletePane(y.newPaneId)},onSuccess:(g,b,y)=>{y?.newPaneId&&y.newPaneId!==g.newPane.id&&(Ht.getState().initPane(g.newPane.id),Ht.getState().deletePane(y.newPaneId)),e.windows.list.setData(void 0,E=>E&&{...E,windows:E.windows.map(A=>A.id!==b.windowId?A:{...A,layout:g.layout,activePaneId:g.newPane.id,panes:A.panes.map(k=>k.id===y?.newPaneId?g.newPane:k)})})}}),u=jt.layout.closePane.useMutation({onSuccess:()=>{e.windows.list.invalidate()}}),c=jt.agents.setMode.useMutation({onSuccess:(g,{paneId:b,modeId:y})=>{b&&Ht.getState().setCurrentModeId(b,y)}}),f=jt.layout.setActivePane.useMutation(yh(e,(g,{windowId:b,paneId:y})=>({...g,windows:g.windows.map(E=>E.id===b?{...E,activePaneId:y}:E)}),{skipInvalidate:!0})),h=C.useRef({utils:e,createMutation:i,deleteMutation:t,setActiveMutation:n,renameMutation:r,cancelMutation:a,splitMutation:o,closePaneMutation:u,setActivePaneMutation:f,setModeMutation:c});return h.current={utils:e,createMutation:i,deleteMutation:t,setActiveMutation:n,renameMutation:r,cancelMutation:a,splitMutation:o,closePaneMutation:u,setActivePaneMutation:f,setModeMutation:c},C.useMemo(()=>({createWindow:g=>{h.current.createMutation.mutate({id:Ia(),...g})},createWindowWithDefaults:()=>{const b=h.current.utils.windows.list.getData()?.lastUsedAgentConfigId??void 0;h.current.createMutation.mutate({id:Ia(),title:"",agentConfigId:b})},closeWindow:g=>{const b=g??h.current.utils.windows.list.getData()?.activeWindowId;b&&h.current.deleteMutation.mutate({id:b})},closeActiveWindow:()=>{const g=h.current.utils.windows.list.getData()?.activeWindowId;g&&h.current.deleteMutation.mutate({id:g})},switchToWindow:g=>{h.current.setActiveMutation.mutate({id:g})},switchToWindowByIndex:g=>{const b=h.current.utils.windows.list.getData()?.windows;b?.[g]&&h.current.setActiveMutation.mutate({id:b[g].id})},previousWindow:()=>{const g=h.current.utils.windows.list.getData();if(!g?.windows.length||!g.activeWindowId)return;const y=(g.windows.findIndex(E=>E.id===g.activeWindowId)+1)%g.windows.length;h.current.setActiveMutation.mutate({id:g.windows[y].id})},nextWindow:()=>{const g=h.current.utils.windows.list.getData();if(!g?.windows.length||!g.activeWindowId)return;const y=(g.windows.findIndex(E=>E.id===g.activeWindowId)-1+g.windows.length)%g.windows.length;h.current.setActiveMutation.mutate({id:g.windows[y].id})},renameWindow:(g,b)=>{h.current.renameMutation.mutate({id:g,title:b})},cancelPrompt:g=>{const b=g??h.current.utils.windows.list.getData()?.activeWindowId;b&&h.current.cancelMutation.mutate({paneId:b})},splitPane:(g,b)=>{const y=h.current.utils.windows.list.getData(),E=y?.windows.find(k=>k.id===y.activeWindowId),A=b??E?.activePaneId;A&&E&&h.current.splitMutation.mutate({windowId:E.id,paneId:A,direction:g,newPaneId:Ia(),newSessionId:Ia()})},closePane:g=>{const b=h.current.utils.windows.list.getData(),y=b?.windows.find(A=>A.id===b.activeWindowId),E=g??y?.activePaneId;E&&y&&h.current.closePaneMutation.mutate({windowId:y.id,paneId:E})},navigatePane:g=>{const b=h.current.utils.windows.list.getData(),y=b?.windows.find(A=>A.id===b.activeWindowId);if(!y?.activePaneId)return;const E=Ade(y.layout,y.activePaneId,g);E&&h.current.setActivePaneMutation.mutate({windowId:y.id,paneId:E})},setActivePane:g=>{const b=h.current.utils.windows.list.getData(),y=b?.windows.find(E=>E.id===b.activeWindowId);y&&h.current.setActivePaneMutation.mutate({windowId:y.id,paneId:g})},cycleMode:()=>{const g=h.current.utils.windows.list.getData(),y=g?.windows.find(L=>L.id===g.activeWindowId)?.activePaneId;if(!y)return;const E=Ht.getState().windows.get(y),A=E?.availableModes??[],k=E?.currentModeId;if(A.length<2)return;const R=(A.findIndex(L=>L.id===k)+1)%A.length;h.current.setModeMutation.mutate({paneId:y,modeId:A[R].id})}}),[])}function Cb({className:e,type:t,...n}){return _.jsx("input",{type:t,"data-slot":"input",className:Ge("dark:bg-input/30 border-input focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 disabled:bg-input/50 dark:disabled:bg-input/80 file:text-foreground placeholder:text-muted-foreground h-8 w-full min-w-0 rounded-none border bg-transparent px-2.5 py-1 text-xs transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-xs file:font-medium focus-visible:ring-1 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:ring-1 md:text-xs",e),...n})}function Cde({className:e,...t}){return _.jsx("textarea",{"data-slot":"textarea",className:Ge("border-input dark:bg-input/30 focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 disabled:bg-input/50 dark:disabled:bg-input/80 placeholder:text-muted-foreground flex field-sizing-content min-h-16 w-full rounded-none border bg-transparent px-2.5 py-2 text-xs transition-colors outline-none focus-visible:ring-1 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:ring-1 md:text-xs",e),...t})}function kde({className:e,...t}){return _.jsx("div",{"data-slot":"input-group",role:"group",className:Ge("border-input dark:bg-input/30 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[[data-slot][aria-invalid=true]]:border-destructive dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-disabled:bg-input/50 dark:has-disabled:bg-input/80 group/input-group relative flex h-8 w-full min-w-0 items-center rounded-none border transition-colors outline-none has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:ring-1 has-[[data-slot][aria-invalid=true]]:ring-1 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5 [[data-slot=combobox-content]_&]:focus-within:border-inherit [[data-slot=combobox-content]_&]:focus-within:ring-0",e),...t})}const Nde=Zm("text-muted-foreground h-auto gap-2 py-1.5 text-xs font-medium group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-none [&>svg:not([class*='size-'])]:size-4 flex cursor-text items-center justify-center select-none",{variants:{align:{"inline-start":"pl-2 has-[>button]:ml-[-0.3rem] has-[>kbd]:ml-[-0.15rem] order-first","inline-end":"pr-2 has-[>button]:mr-[-0.3rem] has-[>kbd]:mr-[-0.15rem] order-last","block-start":"px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2 order-first w-full justify-start","block-end":"px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2 order-last w-full justify-start"}},defaultVariants:{align:"inline-start"}});function Rde({className:e,align:t="inline-start",...n}){return _.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":t,className:Ge(Nde({align:t}),e),onClick:r=>{r.target.closest("button")||r.currentTarget.parentElement?.querySelector("input")?.focus()},...n})}const Ode=Zm("gap-2 text-xs shadow-none flex items-center",{variants:{size:{xs:"h-6 gap-1 rounded-none px-1.5 [&>svg:not([class*='size-'])]:size-3.5",sm:"","icon-xs":"size-6 rounded-none p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function tT({className:e,type:t="button",variant:n="ghost",size:r="xs",...i}){return _.jsx(ui,{type:t,"data-size":r,variant:n,className:Ge(Ode({size:r}),e),...i})}function Mde({className:e,...t}){return _.jsx(Cde,{"data-slot":"input-group-control",className:Ge("flex-1 resize-none rounded-none border-0 bg-transparent py-2 shadow-none ring-0 focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0 dark:bg-transparent dark:disabled:bg-transparent",e),...t})}function Dde({paneId:e,partialPath:t,onSelect:n,onDismiss:r}){const[i,a]=C.useState(0),o=C.useRef(null),{data:u,isLoading:c}=jt.files.listForAutocomplete.useQuery({paneId:e,partialPath:t,limit:10},{enabled:t.length>0,staleTime:1e3,refetchOnWindowFocus:!1});C.useEffect(()=>{a(0)},[u]),C.useEffect(()=>{if(!o.current)return;const m=o.current.querySelectorAll("[data-index]")[i];m&&m.scrollIntoView({block:"nearest"})},[i]);const f=C.useCallback(h=>{if(u?.length)switch(h.key){case"ArrowDown":h.preventDefault(),h.stopPropagation(),a(m=>Math.min(m+1,u.length-1));break;case"ArrowUp":h.preventDefault(),h.stopPropagation(),a(m=>Math.max(m-1,0));break;case"Enter":case"Tab":if(h.preventDefault(),h.stopPropagation(),u[i]){const m=u[i];n(m.path,m.isDirectory)}break;case"Escape":h.preventDefault(),h.stopPropagation(),r();break}},[u,i,n,r]);return C.useEffect(()=>(window.addEventListener("keydown",f,!0),()=>window.removeEventListener("keydown",f,!0)),[f]),!u?.length&&!c?null:_.jsx("div",{ref:o,className:"absolute right-0 bottom-full left-0 z-50 mb-1 bg-popover border rounded-md shadow-lg max-h-60 overflow-auto",children:c?_.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"Loading..."}):u?.map((h,m)=>_.jsxs("div",{"data-index":m,className:Ge("px-3 py-1.5 cursor-pointer flex items-center gap-2 text-xs",m===i&&"bg-accent/10"),onClick:()=>n(h.path,h.isDirectory),onMouseEnter:()=>a(m),children:[h.isDirectory?_.jsx(kB,{className:"size-3.5 text-muted-foreground"}):_.jsx(wB,{className:"size-3.5 text-muted-foreground"}),_.jsx("span",{className:"truncate",children:h.path})]},h.path))})}function Ide({commands:e,partial:t,onSelect:n,onDismiss:r}){const[i,a]=C.useState(0),o=C.useRef(null),u=e.filter(f=>f.name.toLowerCase().startsWith(t.toLowerCase()));C.useEffect(()=>{a(0)},[t]),C.useEffect(()=>{if(!o.current)return;const h=o.current.querySelectorAll("[data-index]")[i];h&&h.scrollIntoView({block:"nearest"})},[i]);const c=C.useCallback(f=>{if(u.length)switch(f.key){case"ArrowDown":f.preventDefault(),f.stopPropagation(),a(h=>Math.min(h+1,u.length-1));break;case"ArrowUp":f.preventDefault(),f.stopPropagation(),a(h=>Math.max(h-1,0));break;case"Enter":case"Tab":f.preventDefault(),f.stopPropagation(),u[i]&&n(u[i]);break;case"Escape":f.preventDefault(),f.stopPropagation(),r();break}},[u,i,n,r]);return C.useEffect(()=>(window.addEventListener("keydown",c,!0),()=>window.removeEventListener("keydown",c,!0)),[c]),u.length?_.jsx("div",{ref:o,className:"absolute right-0 bottom-full left-0 z-50 mb-1 bg-popover border rounded-md shadow-lg max-h-60 overflow-auto",children:u.map((f,h)=>_.jsxs("div",{"data-index":h,className:Ge("px-3 py-2 cursor-pointer",h===i&&"bg-accent/10"),onClick:()=>n(f),onMouseEnter:()=>a(h),children:[_.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[_.jsx(au,{className:"size-3.5 text-muted-foreground"}),_.jsxs("span",{className:"font-medium",children:["/",f.name]})]}),_.jsx("div",{className:"text-xs text-muted-foreground ml-5 mt-0.5",children:f.description})]},f.name))}):null}function Lde({windowId:e,placeholder:t="Type a message...",disabled:n=!1,submitDisabled:r=!1,isStreaming:i=!1,onSubmit:a}){const o=wde(),[u,c]=C.useState(!1),[f,h]=C.useState(null),[m,g]=C.useState(null),b=C.useRef(null),y=C.useRef(null),{cancelPrompt:E}=nl(),A=C.useRef([]).current,k=Ht(ne=>ne.windows.get(e)?.availableCommands)??A;_de(b,140);const S=Ht(ne=>ne.windows.get(e)?.inputDraft??""),R=Ht(ne=>ne.setInputDraft);C.useEffect(()=>{try{const ne=localStorage.getItem(`shella-draft-${e}`);ne&&ne!==S&&(console.log(`[Draft] Loading persisted draft for window ${e}:`,ne.slice(0,50)+(ne.length>50?"...":"")),R(e,ne))}catch(ne){console.warn("[Draft] Failed to load draft from localStorage:",ne)}},[e]);const L=S.trim().length>0&&!n&&!r,M=C.useCallback((ne,se)=>{const ee=ne.slice(0,se).match(/@(\.{0,2}[\w\/.\-]*)$/);ee&&ee[1].length>0?h({active:!0,startIndex:ee.index,partialPath:ee[1]}):h(null)},[]),I=C.useCallback(ne=>{ne.startsWith("/")&&!ne.includes(" ")?(g(ne.slice(1)),h(null)):g(null)},[]),P=ne=>{const se=ne.target.value;R(e,se),se.startsWith("/")&&!se.includes(" ")?I(se):(g(null),M(se,ne.target.selectionStart??se.length))},j=C.useCallback((ne,se)=>{if(!f)return;const Y=S.slice(0,f.startIndex),ee=S.slice(f.startIndex+f.partialPath.length+1),ae=se?`@${ne}/`:`@${ne} `,ge=Y+ae+ee;if(R(e,ge),se){const q=Y.length+ae.length;M(ge,q)}else h(null);b.current?.focus()},[S,f,e,R,M]),J=C.useCallback(()=>{h(null)},[]),$=C.useCallback(ne=>{const se=ne.input?`/${ne.name} `:`/${ne.name}`;R(e,se),g(null),b.current?.focus()},[e,R]),te=C.useCallback(()=>{g(null)},[]),X=()=>{const ne=S.trim();!ne||n||r||(a(ne),b.current?.focus())},pe=ne=>{(f?.active||m!==null)&&["Enter","Tab","Escape","ArrowUp","ArrowDown"].includes(ne.key)||ne.key==="Enter"&&(u||ne.nativeEvent.isComposing||ne.shiftKey||o||(ne.preventDefault(),L&&X()))};return _.jsxs("div",{ref:y,className:"relative",children:[f?.active&&_.jsx(Dde,{paneId:e,partialPath:f.partialPath,onSelect:j,onDismiss:J}),m!==null&&k.length>0&&_.jsx(Ide,{commands:k,partial:m,onSelect:$,onDismiss:te}),_.jsxs(kde,{className:"overflow-hidden",children:[_.jsx(Mde,{ref:b,value:S,onChange:P,onKeyDown:pe,onCompositionStart:()=>c(!0),onCompositionEnd:()=>c(!1),placeholder:t,disabled:n,className:Ge("field-sizing-content max-h-48 min-h-12")}),_.jsx(Rde,{align:"inline-end",children:i?_.jsx(tT,{type:"button",size:"icon-sm",variant:"ghost",onClick:()=>E(e),"aria-label":"Cancel",children:_.jsx(HB,{className:"size-4 fill-current"})}):_.jsx(tT,{type:"button",size:"icon-sm",variant:"ghost",disabled:!L,onClick:X,"aria-label":"Send message",children:_.jsx(eB,{className:"size-4"})})})]})]})}function sy({...e}){return _.jsx(bae,{"data-slot":"select",...e})}function oy({...e}){return _.jsx(yae,{"data-slot":"select-value",...e})}function ly({className:e,size:t="default",children:n,...r}){return _.jsxs(vae,{"data-slot":"select-trigger","data-size":t,className:Ge("border-input data-[placeholder]:text-muted-foreground dark:bg-input/30 dark:hover:bg-input/50 focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 flex w-fit items-center justify-between gap-1.5 rounded-none border bg-transparent py-2 pr-2 pl-2.5 text-xs whitespace-nowrap transition-colors outline-none select-none focus-visible:ring-1 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:ring-1 data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=sm]:rounded-none *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...r,children:[n,_.jsx(xae,{asChild:!0,children:_.jsx(Ty,{className:"text-muted-foreground pointer-events-none size-4"})})]})}function uy({className:e,children:t,position:n="item-aligned",align:r="center",...i}){return _.jsx(Eae,{children:_.jsxs(wae,{"data-slot":"select-content",className:Ge("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-none border shadow-md",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,align:r,...i,children:[_.jsx(Pde,{}),_.jsx(_ae,{"data-position":n,className:Ge("data-[position=popper]:h-[var(--radix-select-trigger-height)] data-[position=popper]:w-full data-[position=popper]:min-w-[var(--radix-select-trigger-width)]",n==="popper"&&""),children:t}),_.jsx(Bde,{})]})})}function cy({className:e,children:t,...n}){return _.jsxs(Tae,{"data-slot":"select-item",className:Ge("focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground relative flex w-full cursor-default items-center gap-2 rounded-none py-2 pr-8 pl-2 text-xs outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",e),...n,children:[_.jsx("span",{className:"pointer-events-none absolute right-2 flex size-4 items-center justify-center",children:_.jsx(Aae,{children:_.jsx(_y,{className:"pointer-events-none"})})}),_.jsx(Sae,{children:t})]})}function Pde({className:e,...t}){return _.jsx(Cae,{"data-slot":"select-scroll-up-button",className:Ge("bg-popover z-10 flex cursor-default items-center justify-center py-1 [&_svg:not([class*='size-'])]:size-4",e),...t,children:_.jsx(lB,{})})}function Bde({className:e,...t}){return _.jsx(kae,{"data-slot":"select-scroll-down-button",className:Ge("bg-popover z-10 flex cursor-default items-center justify-center py-1 [&_svg:not([class*='size-'])]:size-4",e),...t,children:_.jsx(Ty,{})})}const Fde="min-w-[100px]",zde="min-w-[80px]";function jde({windowId:e,disabled:t=!1}){const[n]=cm({duration:150}),[r]=cm({duration:150}),i=Ht(C.useMemo(()=>M=>M.windows.get(e),[e])),a=i?.availableModels??[],o=i?.availableModes??[],u=i?.currentModelId,c=i?.currentModeId,f=Ht(M=>M.setCurrentModelId),h=Ht(M=>M.setCurrentModeId),m=jt.agents.setMode.useMutation({onSuccess:(M,I)=>{h(e,I.modeId)}}),g=jt.agents.setModel.useMutation({onSuccess:(M,I)=>{f(e,I.modelId)}}),b=M=>{g.mutate({paneId:e,modelId:M})},y=M=>{m.mutate({paneId:e,modeId:M})},E=a.find(M=>M.modelId===u)??a[0],A=o.find(M=>M.id===c)??o[0],k=a.length>0,S=o.length>0,R=a.length>1,L=o.length>1;return _.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 text-xs min-h-[28px]",children:[_.jsx("div",{ref:n,className:Ge("flex items-center h-6",Fde),children:k?R?_.jsxs(sy,{value:E?.modelId,onValueChange:b,disabled:t||g.isPending,children:[_.jsx(ly,{size:"sm",className:Ge("h-6 min-w-0 w-auto gap-1 border-none bg-transparent px-1.5","hover:bg-accent/50 focus:ring-0 focus-visible:ring-0",t&&"opacity-50 cursor-not-allowed"),children:_.jsx(oy,{})}),_.jsx(uy,{children:a.map(M=>_.jsx(cy,{value:M.modelId,children:M.name},M.modelId))})]}):_.jsx("span",{className:"text-muted-foreground px-1.5 h-6 flex items-center",children:E?.name}):_.jsxs("span",{className:"text-muted-foreground/50 px-1.5 h-6 flex items-center gap-1",children:[_.jsx(ko,{className:"size-3 animate-spin"}),_.jsx("span",{children:"Loading..."})]})}),_.jsx("span",{className:"text-muted-foreground/50",children:"·"}),_.jsx("div",{ref:r,className:Ge("flex items-center h-6",zde),children:S?L?_.jsxs(sy,{value:A?.id,onValueChange:y,disabled:t||m.isPending,children:[_.jsx(ly,{size:"sm",className:Ge("h-6 min-w-0 w-auto gap-1 border-none bg-transparent px-1.5","hover:bg-accent/50 focus:ring-0 focus-visible:ring-0",t&&"opacity-50 cursor-not-allowed"),children:_.jsx(oy,{})}),_.jsx(uy,{children:o.map(M=>_.jsx(cy,{value:M.id,children:M.name},M.id))})]}):_.jsx("span",{className:"text-muted-foreground px-1.5 h-6 flex items-center",children:A?.name}):_.jsx("span",{className:"text-muted-foreground/50 px-1.5 h-6 flex items-center",children:"Loading..."})})]})}const Hde=C.memo(function({entries:t,className:n}){if(t.length===0)return null;const r=t.filter(a=>a.status==="completed").length,i=t.length;return _.jsx("div",{className:Ge("border-b bg-muted/30",n),children:_.jsxs("div",{className:"px-3 py-2",children:[_.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[_.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Plan"}),_.jsxs("span",{className:"text-xs text-muted-foreground",children:[r,"/",i]})]}),_.jsx("ul",{className:"space-y-1",children:t.map((a,o)=>_.jsx(Ude,{entry:a},o))})]})})}),Ude=C.memo(function({entry:t}){const{status:n,content:r,activeForm:i,priority:a}=t,o=n==="in_progress"&&i?i:r,u=()=>{switch(n){case"completed":return _.jsx(nS,{className:"h-3.5 w-3.5 text-green-500 flex-shrink-0"});case"in_progress":return _.jsx(ko,{className:"h-3.5 w-3.5 text-blue-500 animate-spin flex-shrink-0"});default:return _.jsx(fB,{className:"h-3.5 w-3.5 text-muted-foreground/50 flex-shrink-0"})}},c=a&&a!=="medium";return _.jsxs("li",{className:Ge("flex items-start gap-2 text-xs",n==="completed"&&"text-muted-foreground line-through",n==="in_progress"&&"text-foreground font-medium",n==="pending"&&"text-muted-foreground"),children:[_.jsx(u,{}),_.jsx("span",{className:"flex-1 min-w-0 break-words",children:o}),c&&_.jsx("span",{className:Ge("text-[10px] px-1 rounded flex-shrink-0",a==="high"&&"bg-red-500/20 text-red-600 dark:text-red-400",a==="low"&&"bg-gray-500/20 text-gray-600 dark:text-gray-400"),children:a})]})});function nM({...e}){return _.jsx(Ote,{"data-slot":"dialog",...e})}function $de({...e}){return _.jsx(Mte,{"data-slot":"dialog-trigger",...e})}function qde({...e}){return _.jsx(Dte,{"data-slot":"dialog-portal",...e})}function Vde({...e}){return _.jsx(P4,{"data-slot":"dialog-close",...e})}function Gde({className:e,...t}){return _.jsx(Ite,{"data-slot":"dialog-overlay",className:Ge("data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs",e),...t})}function rM({className:e,children:t,showCloseButton:n=!0,...r}){return _.jsxs(qde,{children:[_.jsx(Gde,{}),_.jsxs(Lte,{"data-slot":"dialog-content",className:Ge("bg-background data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 ring-foreground/10 fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-none p-4 text-xs/relaxed ring-1 duration-100 sm:max-w-sm",e),...r,children:[t,n&&_.jsx(P4,{"data-slot":"dialog-close",asChild:!0,children:_.jsxs(ui,{variant:"ghost",className:"absolute top-2 right-2",size:"icon-sm",children:[_.jsx(qB,{}),_.jsx("span",{className:"sr-only",children:"Close"})]})})]})]})}function iM({className:e,...t}){return _.jsx("div",{"data-slot":"dialog-header",className:Ge("flex flex-col gap-1 text-left",e),...t})}function aM({className:e,showCloseButton:t=!1,children:n,...r}){return _.jsxs("div",{"data-slot":"dialog-footer",className:Ge("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...r,children:[n,t&&_.jsx(P4,{asChild:!0,children:_.jsx(ui,{variant:"outline",children:"Close"})})]})}function sM({className:e,...t}){return _.jsx(Pte,{"data-slot":"dialog-title",className:Ge("text-sm font-medium",e),...t})}function Yde({className:e,...t}){return _.jsx(Gie,{"data-slot":"label",className:Ge("flex items-center gap-2 text-xs leading-none select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",e),...t})}const Wde=Zm("data-[invalid=true]:text-destructive gap-2 group/field flex w-full",{variants:{orientation:{vertical:"flex-col [&>*]:w-full [&>.sr-only]:w-auto",horizontal:"flex-row items-center [&>[data-slot=field-label]]:flex-auto has-[>[data-slot=field-content]]:items-start has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",responsive:"flex-col [&>*]:w-full [&>.sr-only]:w-auto @md/field-group:flex-row @md/field-group:items-center @md/field-group:[&>*]:w-auto @md/field-group:[&>[data-slot=field-label]]:flex-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px"}},defaultVariants:{orientation:"vertical"}});function kb({className:e,orientation:t="vertical",...n}){return _.jsx("div",{role:"group","data-slot":"field","data-orientation":t,className:Ge(Wde({orientation:t}),e),...n})}function Nb({className:e,...t}){return _.jsx(Yde,{"data-slot":"field-label",className:Ge("has-data-checked:bg-primary/5 has-data-checked:border-primary dark:has-data-checked:bg-primary/10 group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-[>[data-slot=field]]:rounded-none has-[>[data-slot=field]]:border [&>*]:data-[slot=field]:p-2","has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col",e),...t})}function Qde({className:e,...t}){return _.jsx("p",{"data-slot":"field-description",className:Ge("text-muted-foreground text-left text-xs/relaxed leading-normal font-normal group-has-[[data-orientation=horizontal]]/field:text-balance [[data-variant=legend]+&]:-mt-1.5","last:mt-0 nth-last-2:-mt-1","[&>a:hover]:text-primary [&>a]:underline [&>a]:underline-offset-4",e),...t})}function Xde({className:e,children:t,errors:n,...r}){const i=C.useMemo(()=>{if(t)return t;if(!n?.length)return null;const a=[...new Map(n.map(o=>[o?.message,o])).values()];return a?.length==1?a[0]?.message:_.jsx("ul",{className:"ml-4 flex list-disc flex-col gap-1",children:a.map((o,u)=>o?.message&&_.jsx("li",{children:o.message},u))})},[t,n]);return i?_.jsx("div",{role:"alert","data-slot":"field-error",className:Ge("text-destructive text-xs font-normal",e),...r,children:i}):null}function dy({children:e,open:t,onOpenChange:n}){const[r,i]=C.useState(!1),[a,o]=C.useState(""),[u,c]=C.useState(""),[f,h]=C.useState(""),[m,g]=C.useState(null),b=t!==void 0,y=b?t:r,E=b?n??(()=>{}):i,A=jt.useUtils(),k=jt.agentConfigs.create.useMutation({onMutate:async M=>{await A.windows.list.cancel();const I=A.windows.list.getData();if(I){const P={id:crypto.randomUUID(),name:M.name,command:M.command,args:M.args??[],env:M.env??{},createdAt:new Date().toISOString()};A.windows.list.setData(void 0,{...I,agentConfigs:[...I.agentConfigs,P]})}return{previous:I}},onError:(M,I,P)=>{P?.previous&&A.windows.list.setData(void 0,P.previous),g("Failed to create agent")},onSettled:()=>{A.windows.list.invalidate()},onSuccess:()=>{S(),E(!1)}}),S=()=>{o(""),c(""),h(""),g(null)},R=M=>{M.preventDefault(),g(null);const I=a.trim(),P=u.trim();if(!I){g("Name is required");return}if(!P){g("Command is required");return}const j=f.trim().split(/\s+/).filter(J=>J.length>0);k.mutate({name:I,command:P,args:j})},L=M=>{E(M),M||S()};return _.jsxs(nM,{open:y,onOpenChange:L,children:[e&&_.jsx($de,{asChild:!0,children:e}),_.jsxs(rM,{children:[_.jsx(iM,{children:_.jsx(sM,{children:"Add Agent"})}),_.jsxs("form",{onSubmit:R,className:"flex flex-col gap-4",children:[_.jsxs(kb,{children:[_.jsx(Nb,{htmlFor:"agent-name",children:"Name"}),_.jsx(Cb,{id:"agent-name",value:a,onChange:M=>o(M.target.value),placeholder:"My Custom Agent",autoFocus:!0})]}),_.jsxs(kb,{children:[_.jsx(Nb,{htmlFor:"agent-command",children:"Command"}),_.jsx(Cb,{id:"agent-command",value:u,onChange:M=>c(M.target.value),placeholder:"/usr/local/bin/my-agent"})]}),_.jsxs(kb,{children:[_.jsx(Nb,{htmlFor:"agent-args",children:"Arguments"}),_.jsx(Cb,{id:"agent-args",value:f,onChange:M=>h(M.target.value),placeholder:"--model sonnet --verbose"}),_.jsx(Qde,{children:"Space-separated arguments (optional)"})]}),m&&_.jsx(Xde,{children:m}),_.jsxs(aM,{children:[_.jsx(Vde,{asChild:!0,children:_.jsx(ui,{type:"button",variant:"outline",children:"Cancel"})}),_.jsx(ui,{type:"submit",disabled:k.isPending,children:k.isPending?"Adding...":"Add Agent"})]})]})]})]})}function Kde({paneId:e,currentAgentConfigId:t,onSwitch:n,disabled:r=!1}){const i=jt.useUtils(),{data:a}=jt.windows.list.useQuery(),o=a?.agentConfigs??[],u=o.find(h=>h.id===t)??o[0],c=jt.agents.switchAgent.useMutation({onMutate:async({paneId:h,agentConfigId:m})=>{await i.windows.list.cancel();const g=i.windows.list.getData();return g&&i.windows.list.setData(void 0,{...g,windows:g.windows.map(b=>({...b,panes:b.panes.map(y=>y.id===h?{...y,session:y.session?{...y.session,agentConfigId:m}:null}:y)})),lastUsedAgentConfigId:m}),{previous:g}},onSuccess:()=>{n?.()},onError:(h,m,g)=>{g?.previous&&i.windows.list.setData(void 0,g.previous)},onSettled:()=>{i.windows.list.invalidate()}}),f=h=>{h!==t&&c.mutate({paneId:e,agentConfigId:h})};return o.length<=1?_.jsxs("div",{className:"flex flex-col gap-2",children:[u&&_.jsx("span",{className:"text-muted-foreground text-sm",children:u.name}),_.jsx(dy,{children:_.jsxs(ui,{className:"touch-manipulation",children:[_.jsx(T0,{className:"h-4 w-4"}),"Add Agent"]})})]}):_.jsxs("div",{className:"flex flex-col gap-2",children:[_.jsxs(sy,{value:t,onValueChange:f,disabled:r||c.isPending,children:[_.jsx(ly,{size:"sm",className:Ge("h-10 min-w-0 w-auto gap-1.5 border-border/50 bg-background/50 px-3","hover:bg-accent/50 focus:ring-0 focus-visible:ring-0",r&&"opacity-50 cursor-not-allowed"),children:_.jsx(oy,{placeholder:"Select agent"})}),_.jsx(uy,{children:o.map(h=>_.jsx(cy,{value:h.id,children:h.name},h.id))})]}),_.jsx(dy,{children:_.jsxs(ui,{className:"touch-manipulation",children:[_.jsx(T0,{className:"h-4 w-4"}),"Add Agent"]})})]})}const Zde=[],Jde=C.memo(function({pane:t}){const n=C.useRef(!1),r=t.id,i=C.useRef(null),o=t.session?.id==="__optimistic__",{flushAndReady:u,resetForRestart:c}=JB(r,!o),f=Ht(ee=>ee.resetWindow),h=Ht(C.useMemo(()=>ee=>ee.windows.get(r),[r])),m=h?.messages??[],g=h?.isStreaming??!1,b=h?.isReady??!1,y=h?.pendingPermission??null,E=h?.planEntries??Zde,A=Ht(ee=>ee.clearInputDraft),k=Ht(ee=>ee.handleUpdate),S=Ht(ee=>ee.batchApply),R=Ht(ee=>ee.setAvailableModels),L=Ht(ee=>ee.setAvailableModes),M=jt.agents.start.useMutation({onSuccess:ee=>{ee.replayEvents&&ee.replayEvents.length>0&&S(r,ee.replayEvents),ee.models&&R(r,ee.models),ee.modes&&L(r,ee.modes),u()},onError:ee=>{console.error("Failed to start agent:",ee),k(r,{amuxEvent:"error",message:ee.message})}}),I=jt.agents.prompt.useMutation({onError:ee=>{console.error("Prompt error:",ee),k(r,{amuxEvent:"error",message:ee.message})}}),P=jt.agents.respondPermission.useMutation(),j=M.error;C.useEffect(()=>{n.current||o||(n.current=!0,M.mutate({paneId:r}))},[r,o]);const J=C.useCallback(ee=>{!ee||g||!b||(A(r),I.mutate({paneId:r,message:ee}),i.current?.())},[r,g,b,I,A]),$=C.useCallback(ee=>{i.current=ee},[]),te=C.useCallback(ee=>{y&&P.mutate({paneId:r,requestId:y.requestId,optionId:ee})},[r,y,P]),X=C.useCallback(()=>{c(),f(r),n.current=!1,M.mutate({paneId:r})},[r,c,f,M]),pe=()=>j?"Agent failed to start":g?"Agent is working...":"Type a message...",se=(t.session?.directory??"/").split("/").filter(Boolean).pop()??"shella",Y=m.length===0;return _.jsxs("div",{className:"h-full flex flex-col bg-background",children:[E.length>0&&_.jsx(Hde,{entries:E}),Y?_.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-4",children:[_.jsx("div",{className:"text-muted-foreground text-sm",children:se}),_.jsx(Kde,{paneId:r,currentAgentConfigId:t.session?.agentConfigId??"",onSwitch:X}),_.jsxs("div",{className:"h-5 flex items-center justify-center",children:[!b&&!j&&_.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground text-xs",children:[_.jsx(ko,{className:"h-3 w-3 animate-spin"}),"Initializing agent..."]}),j&&_.jsx("div",{className:"text-destructive text-xs",children:"Failed to start agent"})]})]}):_.jsx(xde,{messages:m,isStreaming:g,onScrollToBottom:$}),y&&_.jsx(Ede,{permission:y,onSelect:te}),_.jsxs("div",{className:"border-t",children:[_.jsx(jde,{windowId:r,disabled:g||!b||!!j}),_.jsx("div",{className:"p-2",children:_.jsx(Lde,{windowId:r,placeholder:pe(),disabled:!!j,submitDisabled:g||!b||!!j,isStreaming:g,onSubmit:J})})]})]})}),efe=C.memo(function e({node:t,panes:n,activePaneId:r,onResizeStart:i,onResizeEnd:a}){const[o,u]=C.useState(()=>t.type==="branch"?t.ratio:50),c=C.useRef(null),f=C.useRef(!1),{setActivePane:h}=nl(),m=C.useCallback(b=>{if(t.type!=="branch")return;b.preventDefault(),f.current=!0,i?.();const y=c.current;if(!y)return;const E=t.direction==="horizontal",A=y.getBoundingClientRect(),k=R=>{if(!f.current)return;const L=E?(R.clientX-A.left)/A.width:(R.clientY-A.top)/A.height,M=Math.max(10,Math.min(90,L*100));u(M)},S=()=>{f.current=!1,a?.(),document.removeEventListener("mousemove",k),document.removeEventListener("mouseup",S)};document.addEventListener("mousemove",k),document.addEventListener("mouseup",S)},[t,i,a]);if(t.type==="leaf"){const b=n.find(k=>k.id===t.paneId);if(!b)return _.jsx("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:"Pane not found"});const y=b.isOptimistic,E=b.id===r,A=()=>{!E&&!y&&h(b.id)};return _.jsx("div",{className:Ge("h-full box-border border-2 transition-all duration-150",E?"border-primary/50":"border-transparent opacity-60"),onClick:A,children:y?_.jsx("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:_.jsx(ko,{className:"h-4 w-4 animate-spin"})}):_.jsx(Jde,{pane:b})})}const g=t.direction==="horizontal";return _.jsxs("div",{ref:c,className:Ge("h-full flex",g?"flex-row":"flex-col"),children:[_.jsx("div",{style:{[g?"width":"height"]:`${o}%`,flexShrink:0},children:_.jsx(e,{node:t.first,panes:n,activePaneId:r,onResizeStart:i,onResizeEnd:a})}),_.jsx("div",{className:Ge("flex-shrink-0 bg-border hover:bg-primary/50 transition-colors cursor-col-resize",g?"w-1 cursor-col-resize":"h-1 cursor-row-resize"),onMouseDown:m}),_.jsx("div",{className:"flex-1 min-w-0 min-h-0",children:_.jsx(e,{node:t.second,panes:n,activePaneId:r,onResizeStart:i,onResizeEnd:a})})]})}),tfe=C.memo(function({layout:t,panes:n,activePaneId:r,onResizeStart:i,onResizeEnd:a}){return _.jsx("div",{className:"h-full",children:_.jsx(efe,{node:t,panes:n,activePaneId:r,onResizeStart:i,onResizeEnd:a})})}),nfe=C.memo(function({windows:t,activeWindowId:n}){const r=t.filter(i=>!i.isOptimistic);return _.jsx("div",{className:"relative flex-1",children:r.map(i=>_.jsx("div",{className:"absolute inset-0",style:{visibility:i.id===n?"visible":"hidden",zIndex:i.id===n?1:0},children:_.jsx(tfe,{layout:i.layout,panes:i.panes,activePaneId:i.activePaneId})},i.id))})});function rfe({onLongPress:e,onClick:t,onContextMenu:n,delay:r=500,movementThreshold:i=10}){const a=C.useRef(null),o=C.useRef(null),u=C.useRef(!1),[c,f]=C.useState(!1),h=C.useCallback(()=>{a.current&&(clearTimeout(a.current),a.current=null)},[]),m=C.useCallback(A=>{u.current=!1,o.current={x:A.clientX,y:A.clientY},f(!0),a.current=setTimeout(()=>{u.current=!0,f(!1),navigator.vibrate&&navigator.vibrate(50),e()},r)},[e,r]),g=C.useCallback(()=>{h(),f(!1),!u.current&&t&&t()},[h,t]),b=C.useCallback(A=>{if(!o.current)return;const k=Math.abs(A.clientX-o.current.x),S=Math.abs(A.clientY-o.current.y);Math.sqrt(k*k+S*S)>i&&(h(),f(!1))},[h,i]),y=C.useCallback(()=>{h(),f(!1)},[h]),E=C.useCallback(A=>{A.preventDefault(),n?.()},[n]);return{handlers:{onPointerDown:m,onPointerUp:g,onPointerMove:b,onPointerCancel:y,onContextMenu:E},isPressing:c}}function oM({...e}){return _.jsx(Rie,{"data-slot":"dropdown-menu",...e})}function lM({...e}){return _.jsx(Oie,{"data-slot":"dropdown-menu-trigger",...e})}function uM({className:e,align:t="start",sideOffset:n=4,...r}){return _.jsx(Mie,{children:_.jsx(Die,{"data-slot":"dropdown-menu-content",sideOffset:n,align:t,className:Ge("data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 ring-foreground/10 bg-popover text-popover-foreground z-50 max-h-(--radix-dropdown-menu-content-available-height) w-(--radix-dropdown-menu-trigger-width) min-w-32 origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-none shadow-md ring-1 duration-100 data-[state=closed]:overflow-hidden",e),...r})})}function mr({className:e,inset:t,variant:n="default",...r}){return _.jsx(Lie,{"data-slot":"dropdown-menu-item","data-inset":t,"data-variant":n,className:Ge("focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:text-destructive not-data-[variant=destructive]:focus:**:text-accent-foreground group/dropdown-menu-item relative flex cursor-default items-center gap-2 rounded-none px-2 py-2 text-xs outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...r})}function ife({...e}){return _.jsx(Pie,{"data-slot":"dropdown-menu-radio-group",...e})}function Rb({className:e,children:t,...n}){return _.jsxs(Bie,{"data-slot":"dropdown-menu-radio-item",className:Ge("focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-none py-2 pr-8 pl-2 text-xs outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...n,children:[_.jsx("span",{className:"pointer-events-none absolute right-2 flex items-center justify-center","data-slot":"dropdown-menu-radio-item-indicator",children:_.jsx(Fie,{children:_.jsx(_y,{})})}),t]})}function nT({className:e,inset:t,...n}){return _.jsx(Iie,{"data-slot":"dropdown-menu-label","data-inset":t,className:Ge("text-muted-foreground px-2 py-2 text-xs data-[inset]:pl-8",e),...n})}function Dh({className:e,...t}){return _.jsx(zie,{"data-slot":"dropdown-menu-separator",className:Ge("bg-border -mx-1 h-px",e),...t})}function pi({className:e,...t}){return _.jsx("span",{"data-slot":"dropdown-menu-shortcut",className:Ge("text-muted-foreground group-focus/dropdown-menu-item:text-accent-foreground ml-auto text-xs tracking-widest",e),...t})}function rT({...e}){return _.jsx(jie,{"data-slot":"dropdown-menu-sub",...e})}function iT({className:e,inset:t,children:n,...r}){return _.jsxs(Hie,{"data-slot":"dropdown-menu-sub-trigger","data-inset":t,className:Ge("focus:bg-accent focus:text-accent-foreground data-open:bg-accent data-open:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground flex cursor-default items-center gap-2 rounded-none px-2 py-2 text-xs outline-hidden select-none data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...r,children:[n,_.jsx(tS,{className:"ml-auto"})]})}function aT({className:e,...t}){return _.jsx(Uie,{"data-slot":"dropdown-menu-sub-content",className:Ge("data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 ring-foreground/10 bg-popover text-popover-foreground z-50 min-w-[96px] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-none shadow-lg ring-1 duration-100",e),...t})}const afe=C.memo(function({windowId:t,currentTitle:n="",open:r,onOpenChange:i}){const{closeWindow:a,renameWindow:o}=nl(),[u,c]=C.useState(!1),[f,h]=C.useState(""),m=C.useRef(null),g=()=>{a(t)},b=()=>{h(n),i(!1),c(!0)},y=C.useCallback(()=>{f.trim()&&o(t,f.trim()),c(!1)},[t,f,o]),E=C.useCallback(A=>{A.key==="Enter"&&(A.preventDefault(),y())},[y]);return C.useEffect(()=>{u&&setTimeout(()=>m.current?.select(),0)},[u]),_.jsxs(_.Fragment,{children:[_.jsxs(oM,{open:r,onOpenChange:i,children:[_.jsx(lM,{asChild:!0,children:_.jsx("div",{className:"pointer-events-none absolute inset-0"})}),_.jsxs(uM,{side:"top",align:"center",className:"min-w-32",children:[_.jsx(mr,{onClick:b,children:"Rename"}),_.jsx(Dh,{}),_.jsx(mr,{variant:"destructive",onClick:g,children:"Close Window"})]})]}),_.jsx(nM,{open:u,onOpenChange:c,children:_.jsxs(rM,{showCloseButton:!1,className:"sm:max-w-xs",children:[_.jsx(iM,{children:_.jsx(sM,{children:"Rename Window"})}),_.jsx("input",{ref:m,type:"text",value:f,onChange:A=>h(A.target.value),onKeyDown:E,className:"w-full px-3 py-2 text-sm border rounded bg-background focus:outline-none focus:ring-2 focus:ring-primary",placeholder:"Window title"}),_.jsxs(aM,{children:[_.jsx(ui,{variant:"outline",size:"sm",onClick:()=>c(!1),children:"Cancel"}),_.jsx(ui,{size:"sm",onClick:y,children:"Rename"})]})]})})]})}),sfe=C.memo(function({window:t,isActive:n,onSwitchTo:r}){const i=KB(t.activePaneId),a=ZB(t.activePaneId),o=t.hasCustomTitle?t.title:t.panes?.[0]?.session?.title??null,u=!o,[c,f]=C.useState(!1),h=C.useCallback(()=>{r(t.id)},[t.id,r]),{handlers:m,isPressing:g}=rfe({onLongPress:()=>f(!0),onContextMenu:()=>f(!0),onClick:h,delay:500}),b=u?"":a?"border-l-yellow-500":i?"border-l-primary animate-pulse":"border-l-transparent";return _.jsxs("div",{className:"relative",children:[_.jsx("div",{...m,className:Ge("flex items-start gap-1 max-w-48 cursor-pointer select-none bg-background/50 hover:bg-background/80 transition-all",u?"px-3 py-2 text-sm border-2 border-dashed border-muted-foreground/40 text-muted-foreground rounded":n?"px-3.5 py-2.5 text-sm border-b-[3px] border-l-2 border-b-primary bg-background shadow-sm":"px-3.5 py-2.5 text-sm border-b-[3px] border-l-2 border-b-transparent text-muted-foreground",!u&&b,g&&"opacity-70 scale-95 transition-transform"),children:_.jsx("span",{className:Ge("line-clamp-2 flex-1 min-w-0 min-h-[2.5rem] leading-5",u&&"min-w-12 text-center flex items-center justify-center"),children:u?"new":o})}),_.jsx(afe,{windowId:t.id,currentTitle:o??t.title,open:c,onOpenChange:f})]})}),ofe=C.memo(function({windows:t,activeWindowId:n}){const[r]=cm({duration:300}),{switchToWindow:i}=nl();return _.jsx("div",{ref:r,className:"flex flex-row-reverse justify-end items-start gap-1.5 py-0.5",children:t.map(a=>_.jsx(sfe,{window:a,isActive:a.id===n,onSwitchTo:i},a.id))})}),lfe={theme:"system",setTheme:()=>null},cM=C.createContext(lfe);function ufe({children:e,defaultTheme:t="dark",storageKey:n="shella-theme",...r}){const[i,a]=C.useState(()=>localStorage.getItem(n)||t);C.useEffect(()=>{const u=window.document.documentElement;if(u.classList.remove("light","dark"),i==="system"){const c=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";u.classList.add(c);return}u.classList.add(i)},[i]);const o={theme:i,setTheme:u=>{localStorage.setItem(n,u),a(u)}};return _.jsx(cM.Provider,{...r,value:o,children:e})}const cfe=()=>{const e=C.useContext(cM);if(e===void 0)throw new Error("useTheme must be used within a ThemeProvider");return e},dfe=C.memo(function(){const{theme:t,setTheme:n}=cfe(),[r,i]=C.useState(!1),a=nl();return _.jsxs(_.Fragment,{children:[_.jsxs(oM,{children:[_.jsx(lM,{asChild:!0,children:_.jsx(ui,{variant:"ghost",size:"icon","data-tid":"top-bar-menu",children:_.jsx(LB,{className:"size-4"})})}),_.jsxs(uM,{side:"bottom",align:"end",className:"w-56",children:[_.jsxs(mr,{onSelect:()=>i(!0),children:[_.jsx(T0,{className:"size-4"}),"Add Agent"]}),_.jsx(Dh,{}),_.jsx(nT,{children:"Window"}),_.jsxs(mr,{onSelect:()=>a.createWindowWithDefaults(),children:["New Window",_.jsx(pi,{children:"^B c"})]}),_.jsxs(mr,{onSelect:()=>a.closeWindow(),children:["Close Window",_.jsx(pi,{children:"^B &"})]}),_.jsxs(mr,{onSelect:()=>a.previousWindow(),children:["Previous Window",_.jsx(pi,{children:"^B p"})]}),_.jsxs(mr,{onSelect:()=>a.nextWindow(),children:["Next Window",_.jsx(pi,{children:"^B n"})]}),_.jsx(Dh,{}),_.jsx(nT,{children:"Pane"}),_.jsxs(mr,{onSelect:()=>a.splitPane("vertical"),children:["Split Horizontal",_.jsx(pi,{children:'^B "'})]}),_.jsxs(mr,{onSelect:()=>a.splitPane("horizontal"),children:["Split Vertical",_.jsx(pi,{children:"^B %"})]}),_.jsxs(mr,{onSelect:()=>a.closePane(),children:["Close Pane",_.jsx(pi,{children:"^B x"})]}),_.jsxs(rT,{children:[_.jsx(iT,{children:"Navigate"}),_.jsxs(aT,{children:[_.jsxs(mr,{onSelect:()=>a.navigatePane("left"),children:["Left",_.jsx(pi,{children:"^B h"})]}),_.jsxs(mr,{onSelect:()=>a.navigatePane("down"),children:["Down",_.jsx(pi,{children:"^B j"})]}),_.jsxs(mr,{onSelect:()=>a.navigatePane("up"),children:["Up",_.jsx(pi,{children:"^B k"})]}),_.jsxs(mr,{onSelect:()=>a.navigatePane("right"),children:["Right",_.jsx(pi,{children:"^B l"})]})]})]}),_.jsx(Dh,{}),_.jsxs(rT,{children:[_.jsx(iT,{children:"Theme"}),_.jsx(aT,{children:_.jsxs(ife,{value:t,onValueChange:o=>n(o),children:[_.jsx(Rb,{value:"light",children:"Light"}),_.jsx(Rb,{value:"dark",children:"Dark"}),_.jsx(Rb,{value:"system",children:"System"})]})})]})]})]}),_.jsx(dy,{open:r,onOpenChange:i})]})});function ffe(){return _.jsx("div",{className:"bg-bar-background",children:_.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[_.jsx("div",{className:"text-sm font-semibold",children:"shella"}),_.jsx(dfe,{})]})})}function hfe({addButton:e,children:t}){const n=Ht(r=>r.bottomBarCollapsed);return _.jsxs("nav",{className:Ge("bg-bar-background flex transition-[max-height,opacity,padding] duration-200 ease-out",n?"pointer-events-none max-h-0 overflow-hidden opacity-0":"max-h-[120px] opacity-100"),children:[_.jsx("div",{className:"flex shrink-0 items-center pt-2 pb-[calc(0.5rem+env(safe-area-inset-bottom))] pl-2",children:e}),_.jsx("div",{className:"min-w-0 flex-1 overflow-x-auto px-2 pt-2 pb-[calc(0.5rem+env(safe-area-inset-bottom))]",children:t})]})}function mfe({children:e}){return _.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:e})}const pfe=1500;function gfe(){const e=nl(),t=C.useRef(e);t.current=e,C.useEffect(()=>{let n=!1,r;const i=a=>{const{current:o}=t;if(a.ctrlKey&&a.key==="b"){a.preventDefault(),n=!0,clearTimeout(r),r=setTimeout(()=>{n=!1},pfe);return}if(n){switch(n=!1,clearTimeout(r),a.preventDefault(),a.key){case"c":o.createWindowWithDefaults();break;case"n":o.nextWindow();break;case"p":o.previousWindow();break;case"&":case"7":o.closeWindow();break;case"x":o.closePane();break;case'"':case"'":o.splitPane("vertical");break;case"%":case"5":o.splitPane("horizontal");break;case"h":o.navigatePane("left");break;case"j":o.navigatePane("down");break;case"k":o.navigatePane("up");break;case"l":o.navigatePane("right");break}return}if(a.shiftKey&&a.key==="Tab"){a.preventDefault(),o.cycleMode();return}const u=a.target;u.tagName==="INPUT"||u.tagName==="TEXTAREA"||u.isContentEditable||a.key==="Escape"&&o.cancelPrompt()};return window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i),clearTimeout(r)}},[])}function bfe(){const{data:e,isLoading:t}=jt.windows.list.useQuery(),{createWindowWithDefaults:n}=nl();if(gfe(),t||!e)return _.jsx("div",{className:"flex h-dvh flex-col bg-background text-foreground items-center justify-center",children:_.jsx("div",{className:"text-muted-foreground",children:"Loading..."})});if(e.windows.length===0)return _.jsx("div",{className:"flex h-dvh flex-col bg-background text-foreground items-center justify-center",children:_.jsxs("div",{className:"text-center",children:[_.jsx("h1",{className:"text-2xl font-bold mb-2",children:"shella"}),_.jsx("p",{className:"text-muted-foreground mb-4",children:"No windows yet"}),_.jsx("button",{onClick:n,className:"px-4 py-2 bg-primary text-primary-foreground rounded hover:bg-primary/90",children:"New Window"})]})});const r=e.activeWindowId&&e.windows.some(a=>a.id===e.activeWindowId)?e.activeWindowId:e.windows[0]?.id??null,i=_.jsx("button",{onClick:n,className:"flex items-center justify-center w-11 h-11 text-2xl font-medium text-primary active:text-primary/60 active:scale-95 transition-all select-none touch-manipulation",title:"New window (Cmd+K N)",children:"+"});return _.jsxs("div",{className:"flex h-dvh flex-col bg-background text-foreground",children:[_.jsx(ffe,{}),_.jsx(mfe,{children:_.jsx(nfe,{windows:e.windows,activeWindowId:r})}),_.jsx(hfe,{addButton:i,children:_.jsx(ofe,{windows:e.windows,activeWindowId:r})})]})}const sT=new sL({defaultOptions:{queries:{staleTime:1e3*60,refetchOnWindowFocus:!1}}});II.createRoot(document.getElementById("root")).render(_.jsx(C.StrictMode,{children:_.jsx(jt.Provider,{client:YP,queryClient:sT,children:_.jsx(oL,{client:sT,children:_.jsx(ufe,{defaultTheme:"dark",children:_.jsx(bfe,{})})})})}));const vfe=Object.freeze(Object.defineProperty({__proto__:null,Mermaid:gk},Symbol.toStringTag,{value:"Module"}));export{Ti as C,oJ as D,U as _,Bce as a,wO as b,Kle as c,_fe as d,Am as g,_ as j,Dt as k,C as r,it as u};
1701
+ `).length:0,f=r?`Write ${r}`:e.title,h=Hu("write");return u||o?_.jsxs("div",{className:"text-tool-foreground my-1 text-xs",children:[_.jsxs("div",{className:"mb-1 flex items-center gap-2",children:[a!=="completed"&&a!=="failed"&&_.jsx(Ap,{status:a}),_.jsx(h,{className:"size-3"}),_.jsx("span",{children:f}),c>0&&_.jsxs("span",{className:"text-diff-add flex items-center",children:[_.jsx(T0,{className:"size-2.5"}),c]}),o&&_.jsx(X0,{className:"text-destructive size-3"})]}),u&&_.jsx(eM,{patch:u,fileName:r}),e.error&&_.jsx("div",{className:"text-destructive mt-1 text-[11px]",children:e.error})]}):_.jsx(Vu,{toolCall:e,status:a,icon:_.jsx(h,{className:"size-3"}),title:f})}function lde({toolCall:e,status:t}){const n=e.input?.subagent_type,r=e.input?.description,i=n?`${n.charAt(0).toUpperCase()+n.slice(1)} Task`:e.title||"Task",a=r?`"${r}"`:void 0,o=Hu("task");return _.jsx(Vu,{toolCall:e,status:t,icon:_.jsx(o,{className:"size-3"}),title:i,subtitle:a,children:e.output&&_.jsx(z0,{className:"text-muted-foreground mt-1 text-[11px]",children:_.jsx("pre",{className:"break-words whitespace-pre-wrap",children:e.output})})})}function ude({toolCall:e,status:t}){const n=tM(e),r=Hu(n);return _.jsxs(Vu,{toolCall:e,status:t,icon:_.jsx(r,{className:"size-3"}),title:e.title,children:[e.output&&_.jsx(z0,{className:"text-muted-foreground mt-1 text-[11px]",children:_.jsx("pre",{className:"break-words whitespace-pre-wrap",children:e.output})}),e.error&&_.jsx("div",{className:"text-destructive mt-1 text-[11px]",children:e.error})]})}const cde={bash:Z_,shell:Z_,edit:ade,read:sde,write:ode,task:lde},dde=C.memo(function({toolCall:t,isStreaming:n=!1}){const i=!n&&(t.status==="pending"||t.status==="in_progress")?"failed":t.status,a=tM(t),o=cde[a];if(o)return _.jsx(o,{toolCall:t,status:i});if(!ide(t)){const u=Hu(a);return _.jsxs("div",{className:"text-tool-foreground my-0.5 flex items-start gap-1.5 text-xs",children:[_.jsx("div",{className:"mt-0.5 shrink-0",children:_.jsx(u,{className:"size-3"})}),_.jsxs("div",{className:"flex items-center gap-1.5",children:[_.jsx("span",{className:"truncate",children:t.title}),i==="failed"&&_.jsx(X0,{className:"text-destructive size-3"}),i!=="completed"&&i!=="failed"&&_.jsx(Ap,{status:i})]})]})}return _.jsx(ude,{toolCall:t,status:i})}),ny=C.forwardRef(({className:e,role:t,children:n,...r},i)=>{const a=t==="user"?"border-l-[color:var(--accent)]":"border-l-[color:var(--tool-foreground)]",o=t==="user"?"bg-accent/5 dark:bg-accent/5":"";return _.jsx("div",{ref:i,className:Ge("border-l-2","py-2 pl-2",a,o,e),...r,children:n})});ny.displayName="MessageCard";const fde=({className:e,...t})=>_.jsx(_u,{className:Ge("relative flex-1 overflow-y-hidden",e),initial:"smooth",resize:"smooth",role:"log",...t}),hde=({className:e,...t})=>_.jsx(_u.Content,{className:Ge("flex flex-col gap-8 p-4",e),...t});function mde({className:e}){const{isAtBottom:t,scrollToBottom:n}=o3(),r=C.useCallback(()=>{n()},[n]);return t?null:_.jsx(ui,{className:Ge("absolute bottom-4 left-[50%] translate-x-[-50%]","min-h-[44px] min-w-[44px]","border-accent text-accent hover:bg-accent/20",e),onClick:r,size:"icon",type:"button",variant:"outline",children:_.jsx("span",{className:"text-sm select-none",children:"↓"})})}function pde({onScrollToBottom:e}){const{scrollToBottom:t}=o3();return C.useEffect(()=>{e(t)},[t,e]),null}function gde({text:e}){const{copy:t,isCopied:n}=qJ(),r=()=>{e&&t(e)},i=n?_y:pB;return _.jsx(ui,{variant:"ghost",size:"icon",onClick:r,className:"text-muted-foreground hover:text-foreground size-6",children:_.jsx(i,{className:"size-3"})})}function J_({copyText:e}){return _.jsx("div",{className:"border-border/10 mt-2 -ml-1.5 flex items-center gap-1 border-b pt-2 pb-2",children:_.jsx(gde,{text:e})})}function bde(){return _.jsxs("span",{className:"text-muted-foreground text-xs",children:[_.jsx("span",{className:"animate-pulse",children:"."}),_.jsx("span",{className:"animate-pulse",style:{animationDelay:"0.2s"},children:"."}),_.jsx("span",{className:"animate-pulse",style:{animationDelay:"0.4s"},children:"."})]})}function vde({content:e}){return e.trim()?_.jsxs("div",{className:"text-muted-foreground my-1 flex items-start gap-1.5 text-xs",children:[_.jsx(rB,{className:"mt-0.5 size-3 shrink-0"}),_.jsx("div",{className:"text-muted-foreground text-xs italic",children:e})]}):null}function yde({message:e,isStreaming:t=!1}){const n=e.role==="user";if(e.role==="thought")return _.jsx("div",{className:"px-2 pt-2",children:_.jsx(vde,{content:e.content})});if(n)return _.jsx("div",{className:"px-2 pt-2",children:_.jsx(ny,{role:"user",className:"w-full",children:_.jsx("div",{className:"flex items-start gap-2",children:_.jsxs("div",{className:"min-w-0 flex-1 overflow-hidden",children:[_.jsx("p",{className:"text-foreground inline text-sm break-words whitespace-pre-wrap",children:e.content}),_.jsx(J_,{copyText:e.content})]})})})});const i=!e.content&&!e.toolCalls?.length;return _.jsx("div",{className:"px-2 pt-2",children:_.jsx(ny,{role:"agent",className:"w-full",children:_.jsx("div",{className:"flex items-start gap-2",children:_.jsx("div",{className:"min-w-0 flex-1 overflow-hidden",children:i?_.jsx(bde,{}):_.jsxs(_.Fragment,{children:[e.content&&_.jsx(pk,{className:"streamdown-content",mode:t?"streaming":"static",isAnimating:t,controls:{table:!1,code:!1},shikiTheme:tde,children:e.content}),e.toolCalls?.map(a=>_.jsx(dde,{toolCall:a,isStreaming:t},a.id)),e.content&&_.jsx(J_,{copyText:e.content})]})})})})})}const xde=C.memo(function({messages:t,isStreaming:n=!1,onScrollToBottom:r}){const i=[...t].reverse().findIndex(o=>o.role==="agent"),a=i>=0?t.length-1-i:-1;return _.jsxs(fde,{className:"[&>div]:overflow-auto",initial:"instant",children:[_.jsx(hde,{className:"gap-0 px-0",children:t.map((o,u)=>_.jsx(yde,{message:o,isStreaming:n&&u===a},o.id))}),_.jsx(mde,{}),r&&_.jsx(pde,{onScrollToBottom:r})]})}),Ede=C.memo(function({permission:t,onSelect:n}){return _.jsxs("div",{className:"p-4 border-t bg-yellow-50 dark:bg-yellow-900/20",children:[_.jsxs("div",{className:"font-medium mb-2",children:["Permission Required: ",t.title]}),_.jsx("div",{className:"flex gap-2 flex-wrap",children:t.options.map(r=>_.jsx("button",{onClick:()=>n(r.optionId),className:"px-3 py-1 bg-white dark:bg-gray-800 border rounded hover:bg-gray-50 dark:hover:bg-gray-700",children:r.name},r.optionId))})]})});function wde(){const[e,t]=C.useState(()=>typeof window>"u"?!1:window.matchMedia("(pointer: coarse)").matches);return C.useEffect(()=>{const n=window.matchMedia("(pointer: coarse)"),r=i=>{t(i.matches)};return n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),e}function _de(e,t=140){const n=Ht(i=>i.setBottomBarCollapsed),r=C.useRef(null);C.useEffect(()=>{const i=window.visualViewport;if(!i)return;const a=()=>{const u=e.current;if(!u)return;if(document.activeElement===u||u.contains(document.activeElement)){r.current===null&&(r.current=i.height);const f=r.current-i.height;n(f>t)}else r.current=null,n(!1)},o=()=>{r.current=null,n(!1)};return i.addEventListener("resize",a),e.current?.addEventListener("blur",o),()=>{i.removeEventListener("resize",a),e.current?.removeEventListener("blur",o)}},[e,t,n])}function yh(e,t,n){return{onMutate:async r=>{await e.windows.list.cancel();const i=e.windows.list.getData();return i&&e.windows.list.setData(void 0,t(i,r)),{previous:i}},onError:(r,i,a)=>{a?.previous&&e.windows.list.setData(void 0,a.previous)},onSettled:n?.skipInvalidate?void 0:()=>{e.windows.list.invalidate()}}}function eT(e){return{type:"leaf",paneId:e}}function Tde(e,t,n,r=50){return{type:"branch",direction:e,ratio:r,first:t,second:n}}function ry(e,t,n=[]){if(e.type==="leaf")return e.paneId===t?n:null;const r=ry(e.first,t,[...n,"first"]);return r||ry(e.second,t,[...n,"second"])}function iy(e,t,n){return e.type==="leaf"?e.paneId===t?n:e:{...e,first:iy(e.first,t,n),second:iy(e.second,t,n)}}function Sde(e,t,n,r){const i=eT(t),a=eT(n),o=Tde(r,i,a);return iy(e,t,o)}function Ade(e,t,n){const r=ry(e,t);if(!r)return null;let i=e;const a=[];for(const o of r)i.type==="branch"&&(a.push({node:i,childSide:o}),i=o==="first"?i.first:i.second);for(let o=a.length-1;o>=0;o--){const{node:u,childSide:c}=a[o],f=u.direction==="horizontal",h=u.direction==="vertical";if(n==="left"&&f&&c==="second"||n==="right"&&f&&c==="first"||n==="up"&&h&&c==="second"||n==="down"&&h&&c==="first"){const g=c==="first"?u.second:u.first;return ay(g,n)}}return null}function ay(e,t){if(e.type==="leaf")return e.paneId;const n=e.direction==="horizontal";if(t==="left"||t==="up"){const r=e.first;return ay(r,t)}else{const r=e.second;return ay(r,t)}}function nl(){const e=jt.useUtils(),t=jt.windows.delete.useMutation(yh(e,(g,{id:b})=>{const y=g.windows.filter(E=>E.id!==b);return{...g,windows:y,activeWindowId:g.activeWindowId===b?y[y.length-1]?.id??null:g.activeWindowId}})),n=jt.windows.setActive.useMutation(yh(e,(g,{id:b})=>({...g,activeWindowId:b}),{skipInvalidate:!0})),r=jt.windows.update.useMutation(yh(e,(g,{id:b,title:y})=>({...g,windows:g.windows.map(E=>E.id===b&&y?{...E,title:y}:E)}))),i=jt.windows.create.useMutation({onMutate:async g=>{await e.windows.list.cancel();const b=e.windows.list.getData();return b&&e.windows.list.setData(void 0,{...b,windows:[...b.windows,{id:g.id,title:g.title,hasCustomTitle:!!g.title,directory:g.directory??"",agentConfigId:g.agentConfigId??"",sessionId:null,model:null,mode:null,createdAt:new Date().toISOString(),lastAccessedAt:new Date().toISOString(),isOptimistic:!0}]}),{previous:b}},onSuccess:async g=>{await new Promise(b=>setTimeout(b,300)),e.windows.list.setData(void 0,b=>b&&{...b,windows:b.windows.map(y=>y.id===g.id?g:y),activeWindowId:g.id})},onError:(g,b,y)=>{y?.previous&&e.windows.list.setData(void 0,y.previous)}}),a=jt.agents.cancel.useMutation(),o=jt.layout.split.useMutation({onMutate:async({windowId:g,paneId:b,direction:y,newPaneId:E,newSessionId:A})=>{await e.windows.list.cancel();const k=e.windows.list.getData();if(!k)return{prev:k};const S=k.windows.find(I=>I.id===g),R=S?.panes.find(I=>I.id===b);if(!S||!R||!E)return{prev:k};const L=new Date().toISOString(),M={id:E,windowId:g,sessionId:null,createdAt:L,session:R.session?{...R.session,id:"__optimistic__",model:null,mode:null,createdAt:L}:null};return e.windows.list.setData(void 0,{...k,windows:k.windows.map(I=>I.id!==g?I:{...I,layout:Sde(I.layout,b,E,y),activePaneId:E,panes:[...I.panes,M]})}),Ht.getState().initPane(E),{prev:k,newPaneId:E}},onError:(g,b,y)=>{y?.prev&&e.windows.list.setData(void 0,y.prev),y?.newPaneId&&Ht.getState().deletePane(y.newPaneId)},onSuccess:(g,b,y)=>{y?.newPaneId&&y.newPaneId!==g.newPane.id&&(Ht.getState().initPane(g.newPane.id),Ht.getState().deletePane(y.newPaneId)),e.windows.list.setData(void 0,E=>E&&{...E,windows:E.windows.map(A=>A.id!==b.windowId?A:{...A,layout:g.layout,activePaneId:g.newPane.id,panes:A.panes.map(k=>k.id===y?.newPaneId?g.newPane:k)})})}}),u=jt.layout.closePane.useMutation({onSuccess:()=>{e.windows.list.invalidate()}}),c=jt.agents.setMode.useMutation({onSuccess:(g,{paneId:b,modeId:y})=>{b&&Ht.getState().setCurrentModeId(b,y)}}),f=jt.layout.setActivePane.useMutation(yh(e,(g,{windowId:b,paneId:y})=>({...g,windows:g.windows.map(E=>E.id===b?{...E,activePaneId:y}:E)}),{skipInvalidate:!0})),h=C.useRef({utils:e,createMutation:i,deleteMutation:t,setActiveMutation:n,renameMutation:r,cancelMutation:a,splitMutation:o,closePaneMutation:u,setActivePaneMutation:f,setModeMutation:c});return h.current={utils:e,createMutation:i,deleteMutation:t,setActiveMutation:n,renameMutation:r,cancelMutation:a,splitMutation:o,closePaneMutation:u,setActivePaneMutation:f,setModeMutation:c},C.useMemo(()=>({createWindow:g=>{h.current.createMutation.mutate({id:Ia(),...g})},createWindowWithDefaults:()=>{const b=h.current.utils.windows.list.getData()?.lastUsedAgentConfigId??void 0;h.current.createMutation.mutate({id:Ia(),title:"",agentConfigId:b})},closeWindow:g=>{const b=g??h.current.utils.windows.list.getData()?.activeWindowId;b&&h.current.deleteMutation.mutate({id:b})},closeActiveWindow:()=>{const g=h.current.utils.windows.list.getData()?.activeWindowId;g&&h.current.deleteMutation.mutate({id:g})},switchToWindow:g=>{h.current.setActiveMutation.mutate({id:g})},switchToWindowByIndex:g=>{const b=h.current.utils.windows.list.getData()?.windows;b?.[g]&&h.current.setActiveMutation.mutate({id:b[g].id})},previousWindow:()=>{const g=h.current.utils.windows.list.getData();if(!g?.windows.length||!g.activeWindowId)return;const y=(g.windows.findIndex(E=>E.id===g.activeWindowId)+1)%g.windows.length;h.current.setActiveMutation.mutate({id:g.windows[y].id})},nextWindow:()=>{const g=h.current.utils.windows.list.getData();if(!g?.windows.length||!g.activeWindowId)return;const y=(g.windows.findIndex(E=>E.id===g.activeWindowId)-1+g.windows.length)%g.windows.length;h.current.setActiveMutation.mutate({id:g.windows[y].id})},renameWindow:(g,b)=>{h.current.renameMutation.mutate({id:g,title:b})},cancelPrompt:g=>{const b=g??h.current.utils.windows.list.getData()?.activeWindowId;b&&h.current.cancelMutation.mutate({paneId:b})},splitPane:(g,b)=>{const y=h.current.utils.windows.list.getData(),E=y?.windows.find(k=>k.id===y.activeWindowId),A=b??E?.activePaneId;A&&E&&h.current.splitMutation.mutate({windowId:E.id,paneId:A,direction:g,newPaneId:Ia(),newSessionId:Ia()})},closePane:g=>{const b=h.current.utils.windows.list.getData(),y=b?.windows.find(A=>A.id===b.activeWindowId),E=g??y?.activePaneId;E&&y&&h.current.closePaneMutation.mutate({windowId:y.id,paneId:E})},navigatePane:g=>{const b=h.current.utils.windows.list.getData(),y=b?.windows.find(A=>A.id===b.activeWindowId);if(!y?.activePaneId)return;const E=Ade(y.layout,y.activePaneId,g);E&&h.current.setActivePaneMutation.mutate({windowId:y.id,paneId:E})},setActivePane:g=>{const b=h.current.utils.windows.list.getData(),y=b?.windows.find(E=>E.id===b.activeWindowId);y&&h.current.setActivePaneMutation.mutate({windowId:y.id,paneId:g})},cycleMode:()=>{const g=h.current.utils.windows.list.getData(),y=g?.windows.find(L=>L.id===g.activeWindowId)?.activePaneId;if(!y)return;const E=Ht.getState().windows.get(y),A=E?.availableModes??[],k=E?.currentModeId;if(A.length<2)return;const R=(A.findIndex(L=>L.id===k)+1)%A.length;h.current.setModeMutation.mutate({paneId:y,modeId:A[R].id})}}),[])}function Cb({className:e,type:t,...n}){return _.jsx("input",{type:t,"data-slot":"input",className:Ge("dark:bg-input/30 border-input focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 disabled:bg-input/50 dark:disabled:bg-input/80 file:text-foreground placeholder:text-muted-foreground h-8 w-full min-w-0 rounded-none border bg-transparent px-2.5 py-1 text-xs transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-xs file:font-medium focus-visible:ring-1 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:ring-1 md:text-xs",e),...n})}function Cde({className:e,...t}){return _.jsx("textarea",{"data-slot":"textarea",className:Ge("border-input dark:bg-input/30 focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 disabled:bg-input/50 dark:disabled:bg-input/80 placeholder:text-muted-foreground flex field-sizing-content min-h-16 w-full rounded-none border bg-transparent px-2.5 py-2 text-xs transition-colors outline-none focus-visible:ring-1 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:ring-1 md:text-xs",e),...t})}function kde({className:e,...t}){return _.jsx("div",{"data-slot":"input-group",role:"group",className:Ge("border-input dark:bg-input/30 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[[data-slot][aria-invalid=true]]:border-destructive dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-disabled:bg-input/50 dark:has-disabled:bg-input/80 group/input-group relative flex h-8 w-full min-w-0 items-center rounded-none border transition-colors outline-none has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:ring-1 has-[[data-slot][aria-invalid=true]]:ring-1 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5 [[data-slot=combobox-content]_&]:focus-within:border-inherit [[data-slot=combobox-content]_&]:focus-within:ring-0",e),...t})}const Nde=Zm("text-muted-foreground h-auto gap-2 py-1.5 text-xs font-medium group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-none [&>svg:not([class*='size-'])]:size-4 flex cursor-text items-center justify-center select-none",{variants:{align:{"inline-start":"pl-2 has-[>button]:ml-[-0.3rem] has-[>kbd]:ml-[-0.15rem] order-first","inline-end":"pr-2 has-[>button]:mr-[-0.3rem] has-[>kbd]:mr-[-0.15rem] order-last","block-start":"px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2 order-first w-full justify-start","block-end":"px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2 order-last w-full justify-start"}},defaultVariants:{align:"inline-start"}});function Rde({className:e,align:t="inline-start",...n}){return _.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":t,className:Ge(Nde({align:t}),e),onClick:r=>{r.target.closest("button")||r.currentTarget.parentElement?.querySelector("input")?.focus()},...n})}const Ode=Zm("gap-2 text-xs shadow-none flex items-center",{variants:{size:{xs:"h-6 gap-1 rounded-none px-1.5 [&>svg:not([class*='size-'])]:size-3.5",sm:"","icon-xs":"size-6 rounded-none p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function tT({className:e,type:t="button",variant:n="ghost",size:r="xs",...i}){return _.jsx(ui,{type:t,"data-size":r,variant:n,className:Ge(Ode({size:r}),e),...i})}function Mde({className:e,...t}){return _.jsx(Cde,{"data-slot":"input-group-control",className:Ge("flex-1 resize-none rounded-none border-0 bg-transparent py-2 shadow-none ring-0 focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0 dark:bg-transparent dark:disabled:bg-transparent",e),...t})}function Dde({paneId:e,partialPath:t,onSelect:n,onDismiss:r}){const[i,a]=C.useState(0),o=C.useRef(null),{data:u,isLoading:c}=jt.files.listForAutocomplete.useQuery({paneId:e,partialPath:t,limit:10},{enabled:t.length>0,staleTime:1e3,refetchOnWindowFocus:!1});C.useEffect(()=>{a(0)},[u]),C.useEffect(()=>{if(!o.current)return;const m=o.current.querySelectorAll("[data-index]")[i];m&&m.scrollIntoView({block:"nearest"})},[i]);const f=C.useCallback(h=>{if(u?.length)switch(h.key){case"ArrowDown":h.preventDefault(),h.stopPropagation(),a(m=>Math.min(m+1,u.length-1));break;case"ArrowUp":h.preventDefault(),h.stopPropagation(),a(m=>Math.max(m-1,0));break;case"Enter":case"Tab":if(h.preventDefault(),h.stopPropagation(),u[i]){const m=u[i];n(m.path,m.isDirectory)}break;case"Escape":h.preventDefault(),h.stopPropagation(),r();break}},[u,i,n,r]);return C.useEffect(()=>(window.addEventListener("keydown",f,!0),()=>window.removeEventListener("keydown",f,!0)),[f]),!u?.length&&!c?null:_.jsx("div",{ref:o,className:"absolute right-0 bottom-full left-0 z-50 mb-1 bg-popover border rounded-md shadow-lg max-h-60 overflow-auto",children:c?_.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"Loading..."}):u?.map((h,m)=>_.jsxs("div",{"data-index":m,className:Ge("px-3 py-1.5 cursor-pointer flex items-center gap-2 text-xs",m===i&&"bg-accent/10"),onClick:()=>n(h.path,h.isDirectory),onMouseEnter:()=>a(m),children:[h.isDirectory?_.jsx(kB,{className:"size-3.5 text-muted-foreground"}):_.jsx(wB,{className:"size-3.5 text-muted-foreground"}),_.jsx("span",{className:"truncate",children:h.path})]},h.path))})}function Ide({commands:e,partial:t,onSelect:n,onDismiss:r}){const[i,a]=C.useState(0),o=C.useRef(null),u=e.filter(f=>f.name.toLowerCase().startsWith(t.toLowerCase()));C.useEffect(()=>{a(0)},[t]),C.useEffect(()=>{if(!o.current)return;const h=o.current.querySelectorAll("[data-index]")[i];h&&h.scrollIntoView({block:"nearest"})},[i]);const c=C.useCallback(f=>{if(u.length)switch(f.key){case"ArrowDown":f.preventDefault(),f.stopPropagation(),a(h=>Math.min(h+1,u.length-1));break;case"ArrowUp":f.preventDefault(),f.stopPropagation(),a(h=>Math.max(h-1,0));break;case"Enter":case"Tab":f.preventDefault(),f.stopPropagation(),u[i]&&n(u[i]);break;case"Escape":f.preventDefault(),f.stopPropagation(),r();break}},[u,i,n,r]);return C.useEffect(()=>(window.addEventListener("keydown",c,!0),()=>window.removeEventListener("keydown",c,!0)),[c]),u.length?_.jsx("div",{ref:o,className:"absolute right-0 bottom-full left-0 z-50 mb-1 bg-popover border rounded-md shadow-lg max-h-60 overflow-auto",children:u.map((f,h)=>_.jsxs("div",{"data-index":h,className:Ge("px-3 py-2 cursor-pointer",h===i&&"bg-accent/10"),onClick:()=>n(f),onMouseEnter:()=>a(h),children:[_.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[_.jsx(au,{className:"size-3.5 text-muted-foreground"}),_.jsxs("span",{className:"font-medium",children:["/",f.name]})]}),_.jsx("div",{className:"text-xs text-muted-foreground ml-5 mt-0.5",children:f.description})]},f.name))}):null}function Lde({windowId:e,placeholder:t="Type a message...",disabled:n=!1,submitDisabled:r=!1,isStreaming:i=!1,onSubmit:a}){const o=wde(),[u,c]=C.useState(!1),[f,h]=C.useState(null),[m,g]=C.useState(null),b=C.useRef(null),y=C.useRef(null),{cancelPrompt:E}=nl(),A=C.useRef([]).current,k=Ht(ne=>ne.windows.get(e)?.availableCommands)??A;_de(b,140);const S=Ht(ne=>ne.windows.get(e)?.inputDraft??""),R=Ht(ne=>ne.setInputDraft);C.useEffect(()=>{try{const ne=localStorage.getItem(`shella-draft-${e}`);ne&&ne!==S&&(console.log(`[Draft] Loading persisted draft for window ${e}:`,ne.slice(0,50)+(ne.length>50?"...":"")),R(e,ne))}catch(ne){console.warn("[Draft] Failed to load draft from localStorage:",ne)}},[e]);const L=S.trim().length>0&&!n&&!r,M=C.useCallback((ne,se)=>{const ee=ne.slice(0,se).match(/@(\.{0,2}[\w\/.\-]*)$/);ee&&ee[1].length>0?h({active:!0,startIndex:ee.index,partialPath:ee[1]}):h(null)},[]),I=C.useCallback(ne=>{ne.startsWith("/")&&!ne.includes(" ")?(g(ne.slice(1)),h(null)):g(null)},[]),P=ne=>{const se=ne.target.value;R(e,se),se.startsWith("/")&&!se.includes(" ")?I(se):(g(null),M(se,ne.target.selectionStart??se.length))},j=C.useCallback((ne,se)=>{if(!f)return;const Y=S.slice(0,f.startIndex),ee=S.slice(f.startIndex+f.partialPath.length+1),ae=se?`@${ne}/`:`@${ne} `,ge=Y+ae+ee;if(R(e,ge),se){const q=Y.length+ae.length;M(ge,q)}else h(null);b.current?.focus()},[S,f,e,R,M]),J=C.useCallback(()=>{h(null)},[]),$=C.useCallback(ne=>{const se=ne.input?`/${ne.name} `:`/${ne.name}`;R(e,se),g(null),b.current?.focus()},[e,R]),te=C.useCallback(()=>{g(null)},[]),X=()=>{const ne=S.trim();!ne||n||r||(a(ne),b.current?.focus())},pe=ne=>{(f?.active||m!==null)&&["Enter","Tab","Escape","ArrowUp","ArrowDown"].includes(ne.key)||ne.key==="Enter"&&(u||ne.nativeEvent.isComposing||ne.shiftKey||o||(ne.preventDefault(),L&&X()))};return _.jsxs("div",{ref:y,className:"relative",children:[f?.active&&_.jsx(Dde,{paneId:e,partialPath:f.partialPath,onSelect:j,onDismiss:J}),m!==null&&k.length>0&&_.jsx(Ide,{commands:k,partial:m,onSelect:$,onDismiss:te}),_.jsxs(kde,{className:"overflow-hidden",children:[_.jsx(Mde,{ref:b,value:S,onChange:P,onKeyDown:pe,onCompositionStart:()=>c(!0),onCompositionEnd:()=>c(!1),placeholder:t,disabled:n,className:Ge("field-sizing-content max-h-48 min-h-12")}),_.jsx(Rde,{align:"inline-end",children:i?_.jsx(tT,{type:"button",size:"icon-sm",variant:"ghost",onClick:()=>E(e),"aria-label":"Cancel",children:_.jsx(HB,{className:"size-4 fill-current"})}):_.jsx(tT,{type:"button",size:"icon-sm",variant:"ghost",disabled:!L,onClick:X,"aria-label":"Send message",children:_.jsx(eB,{className:"size-4"})})})]})]})}function sy({...e}){return _.jsx(bae,{"data-slot":"select",...e})}function oy({...e}){return _.jsx(yae,{"data-slot":"select-value",...e})}function ly({className:e,size:t="default",children:n,...r}){return _.jsxs(vae,{"data-slot":"select-trigger","data-size":t,className:Ge("border-input data-[placeholder]:text-muted-foreground dark:bg-input/30 dark:hover:bg-input/50 focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 flex w-fit items-center justify-between gap-1.5 rounded-none border bg-transparent py-2 pr-2 pl-2.5 text-xs whitespace-nowrap transition-colors outline-none select-none focus-visible:ring-1 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:ring-1 data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=sm]:rounded-none *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...r,children:[n,_.jsx(xae,{asChild:!0,children:_.jsx(Ty,{className:"text-muted-foreground pointer-events-none size-4"})})]})}function uy({className:e,children:t,position:n="item-aligned",align:r="center",...i}){return _.jsx(Eae,{children:_.jsxs(wae,{"data-slot":"select-content",className:Ge("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-none border shadow-md",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,align:r,...i,children:[_.jsx(Pde,{}),_.jsx(_ae,{"data-position":n,className:Ge("data-[position=popper]:h-[var(--radix-select-trigger-height)] data-[position=popper]:w-full data-[position=popper]:min-w-[var(--radix-select-trigger-width)]",n==="popper"&&""),children:t}),_.jsx(Bde,{})]})})}function cy({className:e,children:t,...n}){return _.jsxs(Tae,{"data-slot":"select-item",className:Ge("focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground relative flex w-full cursor-default items-center gap-2 rounded-none py-2 pr-8 pl-2 text-xs outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",e),...n,children:[_.jsx("span",{className:"pointer-events-none absolute right-2 flex size-4 items-center justify-center",children:_.jsx(Aae,{children:_.jsx(_y,{className:"pointer-events-none"})})}),_.jsx(Sae,{children:t})]})}function Pde({className:e,...t}){return _.jsx(Cae,{"data-slot":"select-scroll-up-button",className:Ge("bg-popover z-10 flex cursor-default items-center justify-center py-1 [&_svg:not([class*='size-'])]:size-4",e),...t,children:_.jsx(lB,{})})}function Bde({className:e,...t}){return _.jsx(kae,{"data-slot":"select-scroll-down-button",className:Ge("bg-popover z-10 flex cursor-default items-center justify-center py-1 [&_svg:not([class*='size-'])]:size-4",e),...t,children:_.jsx(Ty,{})})}const Fde="min-w-[100px]",zde="min-w-[80px]";function jde({windowId:e,disabled:t=!1}){const[n]=cm({duration:150}),[r]=cm({duration:150}),i=Ht(C.useMemo(()=>M=>M.windows.get(e),[e])),a=i?.availableModels??[],o=i?.availableModes??[],u=i?.currentModelId,c=i?.currentModeId,f=Ht(M=>M.setCurrentModelId),h=Ht(M=>M.setCurrentModeId),m=jt.agents.setMode.useMutation({onSuccess:(M,I)=>{h(e,I.modeId)}}),g=jt.agents.setModel.useMutation({onSuccess:(M,I)=>{f(e,I.modelId)}}),b=M=>{g.mutate({paneId:e,modelId:M})},y=M=>{m.mutate({paneId:e,modeId:M})},E=a.find(M=>M.modelId===u)??a[0],A=o.find(M=>M.id===c)??o[0],k=a.length>0,S=o.length>0,R=a.length>1,L=o.length>1;return _.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 text-xs min-h-[28px]",children:[_.jsx("div",{ref:n,className:Ge("flex items-center h-6",Fde),children:k?R?_.jsxs(sy,{value:E?.modelId,onValueChange:b,disabled:t||g.isPending,children:[_.jsx(ly,{size:"sm",className:Ge("h-6 min-w-0 w-auto gap-1 border-none bg-transparent px-1.5","hover:bg-accent/50 focus:ring-0 focus-visible:ring-0",t&&"opacity-50 cursor-not-allowed"),children:_.jsx(oy,{})}),_.jsx(uy,{children:a.map(M=>_.jsx(cy,{value:M.modelId,children:M.name},M.modelId))})]}):_.jsx("span",{className:"text-muted-foreground px-1.5 h-6 flex items-center",children:E?.name}):_.jsxs("span",{className:"text-muted-foreground/50 px-1.5 h-6 flex items-center gap-1",children:[_.jsx(ko,{className:"size-3 animate-spin"}),_.jsx("span",{children:"Loading..."})]})}),_.jsx("span",{className:"text-muted-foreground/50",children:"·"}),_.jsx("div",{ref:r,className:Ge("flex items-center h-6",zde),children:S?L?_.jsxs(sy,{value:A?.id,onValueChange:y,disabled:t||m.isPending,children:[_.jsx(ly,{size:"sm",className:Ge("h-6 min-w-0 w-auto gap-1 border-none bg-transparent px-1.5","hover:bg-accent/50 focus:ring-0 focus-visible:ring-0",t&&"opacity-50 cursor-not-allowed"),children:_.jsx(oy,{})}),_.jsx(uy,{children:o.map(M=>_.jsx(cy,{value:M.id,children:M.name},M.id))})]}):_.jsx("span",{className:"text-muted-foreground px-1.5 h-6 flex items-center",children:A?.name}):_.jsx("span",{className:"text-muted-foreground/50 px-1.5 h-6 flex items-center",children:"Loading..."})})]})}const Hde=C.memo(function({entries:t,className:n}){if(t.length===0)return null;const r=t.filter(a=>a.status==="completed").length,i=t.length;return _.jsx("div",{className:Ge("border-b bg-muted/30",n),children:_.jsxs("div",{className:"px-3 py-2",children:[_.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[_.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Plan"}),_.jsxs("span",{className:"text-xs text-muted-foreground",children:[r,"/",i]})]}),_.jsx("ul",{className:"space-y-1",children:t.map((a,o)=>_.jsx(Ude,{entry:a},o))})]})})}),Ude=C.memo(function({entry:t}){const{status:n,content:r,activeForm:i,priority:a}=t,o=n==="in_progress"&&i?i:r,u=()=>{switch(n){case"completed":return _.jsx(nS,{className:"h-3.5 w-3.5 text-green-500 flex-shrink-0"});case"in_progress":return _.jsx(ko,{className:"h-3.5 w-3.5 text-blue-500 animate-spin flex-shrink-0"});default:return _.jsx(fB,{className:"h-3.5 w-3.5 text-muted-foreground/50 flex-shrink-0"})}},c=a&&a!=="medium";return _.jsxs("li",{className:Ge("flex items-start gap-2 text-xs",n==="completed"&&"text-muted-foreground line-through",n==="in_progress"&&"text-foreground font-medium",n==="pending"&&"text-muted-foreground"),children:[_.jsx(u,{}),_.jsx("span",{className:"flex-1 min-w-0 break-words",children:o}),c&&_.jsx("span",{className:Ge("text-[10px] px-1 rounded flex-shrink-0",a==="high"&&"bg-red-500/20 text-red-600 dark:text-red-400",a==="low"&&"bg-gray-500/20 text-gray-600 dark:text-gray-400"),children:a})]})});function nM({...e}){return _.jsx(Ote,{"data-slot":"dialog",...e})}function $de({...e}){return _.jsx(Mte,{"data-slot":"dialog-trigger",...e})}function qde({...e}){return _.jsx(Dte,{"data-slot":"dialog-portal",...e})}function Vde({...e}){return _.jsx(P4,{"data-slot":"dialog-close",...e})}function Gde({className:e,...t}){return _.jsx(Ite,{"data-slot":"dialog-overlay",className:Ge("data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs",e),...t})}function rM({className:e,children:t,showCloseButton:n=!0,...r}){return _.jsxs(qde,{children:[_.jsx(Gde,{}),_.jsxs(Lte,{"data-slot":"dialog-content",className:Ge("bg-background data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 ring-foreground/10 fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-none p-4 text-xs/relaxed ring-1 duration-100 sm:max-w-sm",e),...r,children:[t,n&&_.jsx(P4,{"data-slot":"dialog-close",asChild:!0,children:_.jsxs(ui,{variant:"ghost",className:"absolute top-2 right-2",size:"icon-sm",children:[_.jsx(qB,{}),_.jsx("span",{className:"sr-only",children:"Close"})]})})]})]})}function iM({className:e,...t}){return _.jsx("div",{"data-slot":"dialog-header",className:Ge("flex flex-col gap-1 text-left",e),...t})}function aM({className:e,showCloseButton:t=!1,children:n,...r}){return _.jsxs("div",{"data-slot":"dialog-footer",className:Ge("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...r,children:[n,t&&_.jsx(P4,{asChild:!0,children:_.jsx(ui,{variant:"outline",children:"Close"})})]})}function sM({className:e,...t}){return _.jsx(Pte,{"data-slot":"dialog-title",className:Ge("text-sm font-medium",e),...t})}function Yde({className:e,...t}){return _.jsx(Gie,{"data-slot":"label",className:Ge("flex items-center gap-2 text-xs leading-none select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",e),...t})}const Wde=Zm("data-[invalid=true]:text-destructive gap-2 group/field flex w-full",{variants:{orientation:{vertical:"flex-col [&>*]:w-full [&>.sr-only]:w-auto",horizontal:"flex-row items-center [&>[data-slot=field-label]]:flex-auto has-[>[data-slot=field-content]]:items-start has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",responsive:"flex-col [&>*]:w-full [&>.sr-only]:w-auto @md/field-group:flex-row @md/field-group:items-center @md/field-group:[&>*]:w-auto @md/field-group:[&>[data-slot=field-label]]:flex-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px"}},defaultVariants:{orientation:"vertical"}});function kb({className:e,orientation:t="vertical",...n}){return _.jsx("div",{role:"group","data-slot":"field","data-orientation":t,className:Ge(Wde({orientation:t}),e),...n})}function Nb({className:e,...t}){return _.jsx(Yde,{"data-slot":"field-label",className:Ge("has-data-checked:bg-primary/5 has-data-checked:border-primary dark:has-data-checked:bg-primary/10 group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-[>[data-slot=field]]:rounded-none has-[>[data-slot=field]]:border [&>*]:data-[slot=field]:p-2","has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col",e),...t})}function Qde({className:e,...t}){return _.jsx("p",{"data-slot":"field-description",className:Ge("text-muted-foreground text-left text-xs/relaxed leading-normal font-normal group-has-[[data-orientation=horizontal]]/field:text-balance [[data-variant=legend]+&]:-mt-1.5","last:mt-0 nth-last-2:-mt-1","[&>a:hover]:text-primary [&>a]:underline [&>a]:underline-offset-4",e),...t})}function Xde({className:e,children:t,errors:n,...r}){const i=C.useMemo(()=>{if(t)return t;if(!n?.length)return null;const a=[...new Map(n.map(o=>[o?.message,o])).values()];return a?.length==1?a[0]?.message:_.jsx("ul",{className:"ml-4 flex list-disc flex-col gap-1",children:a.map((o,u)=>o?.message&&_.jsx("li",{children:o.message},u))})},[t,n]);return i?_.jsx("div",{role:"alert","data-slot":"field-error",className:Ge("text-destructive text-xs font-normal",e),...r,children:i}):null}function dy({children:e,open:t,onOpenChange:n}){const[r,i]=C.useState(!1),[a,o]=C.useState(""),[u,c]=C.useState(""),[f,h]=C.useState(""),[m,g]=C.useState(null),b=t!==void 0,y=b?t:r,E=b?n??(()=>{}):i,A=jt.useUtils(),k=jt.agentConfigs.create.useMutation({onMutate:async M=>{await A.windows.list.cancel();const I=A.windows.list.getData();if(I){const P={id:crypto.randomUUID(),name:M.name,command:M.command,args:M.args??[],env:M.env??{},createdAt:new Date().toISOString()};A.windows.list.setData(void 0,{...I,agentConfigs:[...I.agentConfigs,P]})}return{previous:I}},onError:(M,I,P)=>{P?.previous&&A.windows.list.setData(void 0,P.previous),g("Failed to create agent")},onSettled:()=>{A.windows.list.invalidate()},onSuccess:()=>{S(),E(!1)}}),S=()=>{o(""),c(""),h(""),g(null)},R=M=>{M.preventDefault(),g(null);const I=a.trim(),P=u.trim();if(!I){g("Name is required");return}if(!P){g("Command is required");return}const j=f.trim().split(/\s+/).filter(J=>J.length>0);k.mutate({name:I,command:P,args:j})},L=M=>{E(M),M||S()};return _.jsxs(nM,{open:y,onOpenChange:L,children:[e&&_.jsx($de,{asChild:!0,children:e}),_.jsxs(rM,{children:[_.jsx(iM,{children:_.jsx(sM,{children:"Add Agent"})}),_.jsxs("form",{onSubmit:R,className:"flex flex-col gap-4",children:[_.jsxs(kb,{children:[_.jsx(Nb,{htmlFor:"agent-name",children:"Name"}),_.jsx(Cb,{id:"agent-name",value:a,onChange:M=>o(M.target.value),placeholder:"My Custom Agent",autoFocus:!0})]}),_.jsxs(kb,{children:[_.jsx(Nb,{htmlFor:"agent-command",children:"Command"}),_.jsx(Cb,{id:"agent-command",value:u,onChange:M=>c(M.target.value),placeholder:"/usr/local/bin/my-agent"})]}),_.jsxs(kb,{children:[_.jsx(Nb,{htmlFor:"agent-args",children:"Arguments"}),_.jsx(Cb,{id:"agent-args",value:f,onChange:M=>h(M.target.value),placeholder:"--model sonnet --verbose"}),_.jsx(Qde,{children:"Space-separated arguments (optional)"})]}),m&&_.jsx(Xde,{children:m}),_.jsxs(aM,{children:[_.jsx(Vde,{asChild:!0,children:_.jsx(ui,{type:"button",variant:"outline",children:"Cancel"})}),_.jsx(ui,{type:"submit",disabled:k.isPending,children:k.isPending?"Adding...":"Add Agent"})]})]})]})]})}function Kde({paneId:e,currentAgentConfigId:t,onSwitch:n,disabled:r=!1}){const i=jt.useUtils(),{data:a}=jt.windows.list.useQuery(),o=a?.agentConfigs??[],u=o.find(h=>h.id===t)??o[0],c=jt.agents.switchAgent.useMutation({onMutate:async({paneId:h,agentConfigId:m})=>{await i.windows.list.cancel();const g=i.windows.list.getData();return g&&i.windows.list.setData(void 0,{...g,windows:g.windows.map(b=>({...b,panes:b.panes.map(y=>y.id===h?{...y,session:y.session?{...y.session,agentConfigId:m}:null}:y)})),lastUsedAgentConfigId:m}),{previous:g}},onSuccess:()=>{n?.()},onError:(h,m,g)=>{g?.previous&&i.windows.list.setData(void 0,g.previous)},onSettled:()=>{i.windows.list.invalidate()}}),f=h=>{h!==t&&c.mutate({paneId:e,agentConfigId:h})};return o.length<=1?_.jsxs("div",{className:"flex flex-col gap-2",children:[u&&_.jsx("span",{className:"text-muted-foreground text-sm",children:u.name}),_.jsx(dy,{children:_.jsxs(ui,{className:"touch-manipulation",children:[_.jsx(T0,{className:"h-4 w-4"}),"Add Agent"]})})]}):_.jsxs("div",{className:"flex flex-col gap-2",children:[_.jsxs(sy,{value:t,onValueChange:f,disabled:r||c.isPending,children:[_.jsx(ly,{size:"sm",className:Ge("h-10 min-w-0 w-auto gap-1.5 border-border/50 bg-background/50 px-3","hover:bg-accent/50 focus:ring-0 focus-visible:ring-0",r&&"opacity-50 cursor-not-allowed"),children:_.jsx(oy,{placeholder:"Select agent"})}),_.jsx(uy,{children:o.map(h=>_.jsx(cy,{value:h.id,children:h.name},h.id))})]}),_.jsx(dy,{children:_.jsxs(ui,{className:"touch-manipulation",children:[_.jsx(T0,{className:"h-4 w-4"}),"Add Agent"]})})]})}const Zde=[],Jde=C.memo(function({pane:t}){const n=C.useRef(!1),r=t.id,i=C.useRef(null),o=t.session?.id==="__optimistic__",{flushAndReady:u,resetForRestart:c}=JB(r,!o),f=Ht(ee=>ee.resetWindow),h=Ht(C.useMemo(()=>ee=>ee.windows.get(r),[r])),m=h?.messages??[],g=h?.isStreaming??!1,b=h?.isReady??!1,y=h?.pendingPermission??null,E=h?.planEntries??Zde,A=Ht(ee=>ee.clearInputDraft),k=Ht(ee=>ee.handleUpdate),S=Ht(ee=>ee.batchApply),R=Ht(ee=>ee.setAvailableModels),L=Ht(ee=>ee.setAvailableModes),M=jt.agents.start.useMutation({onSuccess:ee=>{ee.replayEvents&&ee.replayEvents.length>0&&S(r,ee.replayEvents),ee.models&&R(r,ee.models),ee.modes&&L(r,ee.modes),u()},onError:ee=>{console.error("Failed to start agent:",ee),k(r,{amuxEvent:"error",message:ee.message})}}),I=jt.agents.prompt.useMutation({onError:ee=>{console.error("Prompt error:",ee),k(r,{amuxEvent:"error",message:ee.message})}}),P=jt.agents.respondPermission.useMutation(),j=M.error;C.useEffect(()=>{n.current||o||(n.current=!0,M.mutate({paneId:r}))},[r,o]);const J=C.useCallback(ee=>{!ee||g||!b||(A(r),I.mutate({paneId:r,message:ee}),i.current?.())},[r,g,b,I,A]),$=C.useCallback(ee=>{i.current=ee},[]),te=C.useCallback(ee=>{y&&P.mutate({paneId:r,requestId:y.requestId,optionId:ee})},[r,y,P]),X=C.useCallback(()=>{c(),f(r),n.current=!1,M.mutate({paneId:r})},[r,c,f,M]),pe=()=>j?"Agent failed to start":g?"Agent is working...":"Type a message...",se=(t.session?.directory??"/").split("/").filter(Boolean).pop(),Y=m.length===0;return _.jsxs("div",{className:"h-full flex flex-col bg-background",children:[E.length>0&&_.jsx(Hde,{entries:E}),Y?_.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-4",children:[se&&_.jsx("div",{className:"text-muted-foreground text-sm",children:se}),_.jsx(Kde,{paneId:r,currentAgentConfigId:t.session?.agentConfigId??"",onSwitch:X}),_.jsxs("div",{className:"h-5 flex items-center justify-center",children:[!b&&!j&&_.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground text-xs",children:[_.jsx(ko,{className:"h-3 w-3 animate-spin"}),"Initializing agent..."]}),j&&_.jsx("div",{className:"text-destructive text-xs",children:"Failed to start agent"})]})]}):_.jsx(xde,{messages:m,isStreaming:g,onScrollToBottom:$}),y&&_.jsx(Ede,{permission:y,onSelect:te}),_.jsxs("div",{className:"border-t",children:[_.jsx(jde,{windowId:r,disabled:g||!b||!!j}),_.jsx("div",{className:"p-2",children:_.jsx(Lde,{windowId:r,placeholder:pe(),disabled:!!j,submitDisabled:g||!b||!!j,isStreaming:g,onSubmit:J})})]})]})}),efe=C.memo(function e({node:t,panes:n,activePaneId:r,onResizeStart:i,onResizeEnd:a}){const[o,u]=C.useState(()=>t.type==="branch"?t.ratio:50),c=C.useRef(null),f=C.useRef(!1),{setActivePane:h}=nl(),m=C.useCallback(b=>{if(t.type!=="branch")return;b.preventDefault(),f.current=!0,i?.();const y=c.current;if(!y)return;const E=t.direction==="horizontal",A=y.getBoundingClientRect(),k=R=>{if(!f.current)return;const L=E?(R.clientX-A.left)/A.width:(R.clientY-A.top)/A.height,M=Math.max(10,Math.min(90,L*100));u(M)},S=()=>{f.current=!1,a?.(),document.removeEventListener("mousemove",k),document.removeEventListener("mouseup",S)};document.addEventListener("mousemove",k),document.addEventListener("mouseup",S)},[t,i,a]);if(t.type==="leaf"){const b=n.find(k=>k.id===t.paneId);if(!b)return _.jsx("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:"Pane not found"});const y=b.isOptimistic,E=b.id===r,A=()=>{!E&&!y&&h(b.id)};return _.jsx("div",{className:Ge("h-full box-border border-2 transition-all duration-150",E?"border-primary/50":"border-transparent opacity-60"),onClick:A,children:y?_.jsx("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:_.jsx(ko,{className:"h-4 w-4 animate-spin"})}):_.jsx(Jde,{pane:b})})}const g=t.direction==="horizontal";return _.jsxs("div",{ref:c,className:Ge("h-full flex",g?"flex-row":"flex-col"),children:[_.jsx("div",{style:{[g?"width":"height"]:`${o}%`,flexShrink:0},children:_.jsx(e,{node:t.first,panes:n,activePaneId:r,onResizeStart:i,onResizeEnd:a})}),_.jsx("div",{className:Ge("flex-shrink-0 bg-border hover:bg-primary/50 transition-colors cursor-col-resize",g?"w-1 cursor-col-resize":"h-1 cursor-row-resize"),onMouseDown:m}),_.jsx("div",{className:"flex-1 min-w-0 min-h-0",children:_.jsx(e,{node:t.second,panes:n,activePaneId:r,onResizeStart:i,onResizeEnd:a})})]})}),tfe=C.memo(function({layout:t,panes:n,activePaneId:r,onResizeStart:i,onResizeEnd:a}){return _.jsx("div",{className:"h-full",children:_.jsx(efe,{node:t,panes:n,activePaneId:r,onResizeStart:i,onResizeEnd:a})})}),nfe=C.memo(function({windows:t,activeWindowId:n}){const r=t.filter(i=>!i.isOptimistic);return _.jsx("div",{className:"relative flex-1",children:r.map(i=>_.jsx("div",{className:"absolute inset-0",style:{visibility:i.id===n?"visible":"hidden",zIndex:i.id===n?1:0},children:_.jsx(tfe,{layout:i.layout,panes:i.panes,activePaneId:i.activePaneId})},i.id))})});function rfe({onLongPress:e,onClick:t,onContextMenu:n,delay:r=500,movementThreshold:i=10}){const a=C.useRef(null),o=C.useRef(null),u=C.useRef(!1),[c,f]=C.useState(!1),h=C.useCallback(()=>{a.current&&(clearTimeout(a.current),a.current=null)},[]),m=C.useCallback(A=>{u.current=!1,o.current={x:A.clientX,y:A.clientY},f(!0),a.current=setTimeout(()=>{u.current=!0,f(!1),navigator.vibrate&&navigator.vibrate(50),e()},r)},[e,r]),g=C.useCallback(()=>{h(),f(!1),!u.current&&t&&t()},[h,t]),b=C.useCallback(A=>{if(!o.current)return;const k=Math.abs(A.clientX-o.current.x),S=Math.abs(A.clientY-o.current.y);Math.sqrt(k*k+S*S)>i&&(h(),f(!1))},[h,i]),y=C.useCallback(()=>{h(),f(!1)},[h]),E=C.useCallback(A=>{A.preventDefault(),n?.()},[n]);return{handlers:{onPointerDown:m,onPointerUp:g,onPointerMove:b,onPointerCancel:y,onContextMenu:E},isPressing:c}}function oM({...e}){return _.jsx(Rie,{"data-slot":"dropdown-menu",...e})}function lM({...e}){return _.jsx(Oie,{"data-slot":"dropdown-menu-trigger",...e})}function uM({className:e,align:t="start",sideOffset:n=4,...r}){return _.jsx(Mie,{children:_.jsx(Die,{"data-slot":"dropdown-menu-content",sideOffset:n,align:t,className:Ge("data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 ring-foreground/10 bg-popover text-popover-foreground z-50 max-h-(--radix-dropdown-menu-content-available-height) w-(--radix-dropdown-menu-trigger-width) min-w-32 origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-none shadow-md ring-1 duration-100 data-[state=closed]:overflow-hidden",e),...r})})}function mr({className:e,inset:t,variant:n="default",...r}){return _.jsx(Lie,{"data-slot":"dropdown-menu-item","data-inset":t,"data-variant":n,className:Ge("focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:text-destructive not-data-[variant=destructive]:focus:**:text-accent-foreground group/dropdown-menu-item relative flex cursor-default items-center gap-2 rounded-none px-2 py-2 text-xs outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...r})}function ife({...e}){return _.jsx(Pie,{"data-slot":"dropdown-menu-radio-group",...e})}function Rb({className:e,children:t,...n}){return _.jsxs(Bie,{"data-slot":"dropdown-menu-radio-item",className:Ge("focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-none py-2 pr-8 pl-2 text-xs outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...n,children:[_.jsx("span",{className:"pointer-events-none absolute right-2 flex items-center justify-center","data-slot":"dropdown-menu-radio-item-indicator",children:_.jsx(Fie,{children:_.jsx(_y,{})})}),t]})}function nT({className:e,inset:t,...n}){return _.jsx(Iie,{"data-slot":"dropdown-menu-label","data-inset":t,className:Ge("text-muted-foreground px-2 py-2 text-xs data-[inset]:pl-8",e),...n})}function Dh({className:e,...t}){return _.jsx(zie,{"data-slot":"dropdown-menu-separator",className:Ge("bg-border -mx-1 h-px",e),...t})}function pi({className:e,...t}){return _.jsx("span",{"data-slot":"dropdown-menu-shortcut",className:Ge("text-muted-foreground group-focus/dropdown-menu-item:text-accent-foreground ml-auto text-xs tracking-widest",e),...t})}function rT({...e}){return _.jsx(jie,{"data-slot":"dropdown-menu-sub",...e})}function iT({className:e,inset:t,children:n,...r}){return _.jsxs(Hie,{"data-slot":"dropdown-menu-sub-trigger","data-inset":t,className:Ge("focus:bg-accent focus:text-accent-foreground data-open:bg-accent data-open:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground flex cursor-default items-center gap-2 rounded-none px-2 py-2 text-xs outline-hidden select-none data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...r,children:[n,_.jsx(tS,{className:"ml-auto"})]})}function aT({className:e,...t}){return _.jsx(Uie,{"data-slot":"dropdown-menu-sub-content",className:Ge("data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 ring-foreground/10 bg-popover text-popover-foreground z-50 min-w-[96px] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-none shadow-lg ring-1 duration-100",e),...t})}const afe=C.memo(function({windowId:t,currentTitle:n="",open:r,onOpenChange:i}){const{closeWindow:a,renameWindow:o}=nl(),[u,c]=C.useState(!1),[f,h]=C.useState(""),m=C.useRef(null),g=()=>{a(t)},b=()=>{h(n),i(!1),c(!0)},y=C.useCallback(()=>{f.trim()&&o(t,f.trim()),c(!1)},[t,f,o]),E=C.useCallback(A=>{A.key==="Enter"&&(A.preventDefault(),y())},[y]);return C.useEffect(()=>{u&&setTimeout(()=>m.current?.select(),0)},[u]),_.jsxs(_.Fragment,{children:[_.jsxs(oM,{open:r,onOpenChange:i,children:[_.jsx(lM,{asChild:!0,children:_.jsx("div",{className:"pointer-events-none absolute inset-0"})}),_.jsxs(uM,{side:"top",align:"center",className:"min-w-32",children:[_.jsx(mr,{onClick:b,children:"Rename"}),_.jsx(Dh,{}),_.jsx(mr,{variant:"destructive",onClick:g,children:"Close Window"})]})]}),_.jsx(nM,{open:u,onOpenChange:c,children:_.jsxs(rM,{showCloseButton:!1,className:"sm:max-w-xs",children:[_.jsx(iM,{children:_.jsx(sM,{children:"Rename Window"})}),_.jsx("input",{ref:m,type:"text",value:f,onChange:A=>h(A.target.value),onKeyDown:E,className:"w-full px-3 py-2 text-sm border rounded bg-background focus:outline-none focus:ring-2 focus:ring-primary",placeholder:"Window title"}),_.jsxs(aM,{children:[_.jsx(ui,{variant:"outline",size:"sm",onClick:()=>c(!1),children:"Cancel"}),_.jsx(ui,{size:"sm",onClick:y,children:"Rename"})]})]})})]})}),sfe=C.memo(function({window:t,isActive:n,onSwitchTo:r}){const i=KB(t.activePaneId),a=ZB(t.activePaneId),o=t.hasCustomTitle?t.title:t.panes?.[0]?.session?.title??null,u=!o,[c,f]=C.useState(!1),h=C.useCallback(()=>{r(t.id)},[t.id,r]),{handlers:m,isPressing:g}=rfe({onLongPress:()=>f(!0),onContextMenu:()=>f(!0),onClick:h,delay:500}),b=u?"":a?"border-l-yellow-500":i?"border-l-primary animate-pulse":"border-l-transparent";return _.jsxs("div",{className:"relative",children:[_.jsx("div",{...m,className:Ge("flex items-start gap-1 max-w-48 cursor-pointer select-none bg-background/50 hover:bg-background/80 transition-all",u?"px-3 py-2 text-sm border-2 border-dashed border-muted-foreground/40 text-muted-foreground rounded":n?"px-3.5 py-2.5 text-sm border-b-[3px] border-l-2 border-b-primary bg-background shadow-sm":"px-3.5 py-2.5 text-sm border-b-[3px] border-l-2 border-b-transparent text-muted-foreground",!u&&b,g&&"opacity-70 scale-95 transition-transform"),children:_.jsx("span",{className:Ge("line-clamp-2 flex-1 min-w-0 min-h-[2.5rem] leading-5",u&&"min-w-12 text-center flex items-center justify-center"),children:u?"new":o})}),_.jsx(afe,{windowId:t.id,currentTitle:o??t.title,open:c,onOpenChange:f})]})}),ofe=C.memo(function({windows:t,activeWindowId:n}){const[r]=cm({duration:300}),{switchToWindow:i}=nl();return _.jsx("div",{ref:r,className:"flex flex-row-reverse justify-end items-start gap-1.5 py-0.5",children:t.map(a=>_.jsx(sfe,{window:a,isActive:a.id===n,onSwitchTo:i},a.id))})}),lfe={theme:"system",setTheme:()=>null},cM=C.createContext(lfe);function ufe({children:e,defaultTheme:t="dark",storageKey:n="shella-theme",...r}){const[i,a]=C.useState(()=>localStorage.getItem(n)||t);C.useEffect(()=>{const u=window.document.documentElement;if(u.classList.remove("light","dark"),i==="system"){const c=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";u.classList.add(c);return}u.classList.add(i)},[i]);const o={theme:i,setTheme:u=>{localStorage.setItem(n,u),a(u)}};return _.jsx(cM.Provider,{...r,value:o,children:e})}const cfe=()=>{const e=C.useContext(cM);if(e===void 0)throw new Error("useTheme must be used within a ThemeProvider");return e},dfe=C.memo(function(){const{theme:t,setTheme:n}=cfe(),[r,i]=C.useState(!1),a=nl();return _.jsxs(_.Fragment,{children:[_.jsxs(oM,{children:[_.jsx(lM,{asChild:!0,children:_.jsx(ui,{variant:"ghost",size:"icon","data-tid":"top-bar-menu",children:_.jsx(LB,{className:"size-4"})})}),_.jsxs(uM,{side:"bottom",align:"end",className:"w-56",children:[_.jsxs(mr,{onSelect:()=>i(!0),children:[_.jsx(T0,{className:"size-4"}),"Add Agent"]}),_.jsx(Dh,{}),_.jsx(nT,{children:"Window"}),_.jsxs(mr,{onSelect:()=>a.createWindowWithDefaults(),children:["New Window",_.jsx(pi,{children:"^B c"})]}),_.jsxs(mr,{onSelect:()=>a.closeWindow(),children:["Close Window",_.jsx(pi,{children:"^B &"})]}),_.jsxs(mr,{onSelect:()=>a.previousWindow(),children:["Previous Window",_.jsx(pi,{children:"^B p"})]}),_.jsxs(mr,{onSelect:()=>a.nextWindow(),children:["Next Window",_.jsx(pi,{children:"^B n"})]}),_.jsx(Dh,{}),_.jsx(nT,{children:"Pane"}),_.jsxs(mr,{onSelect:()=>a.splitPane("vertical"),children:["Split Horizontal",_.jsx(pi,{children:'^B "'})]}),_.jsxs(mr,{onSelect:()=>a.splitPane("horizontal"),children:["Split Vertical",_.jsx(pi,{children:"^B %"})]}),_.jsxs(mr,{onSelect:()=>a.closePane(),children:["Close Pane",_.jsx(pi,{children:"^B x"})]}),_.jsxs(rT,{children:[_.jsx(iT,{children:"Navigate"}),_.jsxs(aT,{children:[_.jsxs(mr,{onSelect:()=>a.navigatePane("left"),children:["Left",_.jsx(pi,{children:"^B h"})]}),_.jsxs(mr,{onSelect:()=>a.navigatePane("down"),children:["Down",_.jsx(pi,{children:"^B j"})]}),_.jsxs(mr,{onSelect:()=>a.navigatePane("up"),children:["Up",_.jsx(pi,{children:"^B k"})]}),_.jsxs(mr,{onSelect:()=>a.navigatePane("right"),children:["Right",_.jsx(pi,{children:"^B l"})]})]})]}),_.jsx(Dh,{}),_.jsxs(rT,{children:[_.jsx(iT,{children:"Theme"}),_.jsx(aT,{children:_.jsxs(ife,{value:t,onValueChange:o=>n(o),children:[_.jsx(Rb,{value:"light",children:"Light"}),_.jsx(Rb,{value:"dark",children:"Dark"}),_.jsx(Rb,{value:"system",children:"System"})]})})]})]})]}),_.jsx(dy,{open:r,onOpenChange:i})]})});function ffe(){return _.jsx("div",{className:"bg-bar-background",children:_.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[_.jsx("img",{src:"/favicon.svg",alt:"shella",className:"h-5 w-5"}),_.jsx(dfe,{})]})})}function hfe({addButton:e,children:t}){const n=Ht(r=>r.bottomBarCollapsed);return _.jsxs("nav",{className:Ge("bg-bar-background flex transition-[max-height,opacity,padding] duration-200 ease-out",n?"pointer-events-none max-h-0 overflow-hidden opacity-0":"max-h-[120px] opacity-100"),children:[_.jsx("div",{className:"flex shrink-0 items-center pt-2 pb-[calc(0.5rem+env(safe-area-inset-bottom))] pl-2",children:e}),_.jsx("div",{className:"min-w-0 flex-1 overflow-x-auto px-2 pt-2 pb-[calc(0.5rem+env(safe-area-inset-bottom))]",children:t})]})}function mfe({children:e}){return _.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:e})}const pfe=1500;function gfe(){const e=nl(),t=C.useRef(e);t.current=e,C.useEffect(()=>{let n=!1,r;const i=a=>{const{current:o}=t;if(a.ctrlKey&&a.key==="b"){a.preventDefault(),n=!0,clearTimeout(r),r=setTimeout(()=>{n=!1},pfe);return}if(n){switch(n=!1,clearTimeout(r),a.preventDefault(),a.key){case"c":o.createWindowWithDefaults();break;case"n":o.nextWindow();break;case"p":o.previousWindow();break;case"&":case"7":o.closeWindow();break;case"x":o.closePane();break;case'"':case"'":o.splitPane("vertical");break;case"%":case"5":o.splitPane("horizontal");break;case"h":o.navigatePane("left");break;case"j":o.navigatePane("down");break;case"k":o.navigatePane("up");break;case"l":o.navigatePane("right");break}return}if(a.shiftKey&&a.key==="Tab"){a.preventDefault(),o.cycleMode();return}const u=a.target;u.tagName==="INPUT"||u.tagName==="TEXTAREA"||u.isContentEditable||a.key==="Escape"&&o.cancelPrompt()};return window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i),clearTimeout(r)}},[])}function bfe(){const{data:e,isLoading:t}=jt.windows.list.useQuery(),{createWindowWithDefaults:n}=nl();if(gfe(),t||!e)return _.jsx("div",{className:"flex h-dvh flex-col bg-background text-foreground items-center justify-center",children:_.jsx("div",{className:"text-muted-foreground",children:"Loading..."})});if(e.windows.length===0)return _.jsx("div",{className:"flex h-dvh flex-col bg-background text-foreground items-center justify-center",children:_.jsxs("div",{className:"text-center",children:[_.jsx("h1",{className:"text-2xl font-bold mb-2",children:"shella"}),_.jsx("p",{className:"text-muted-foreground mb-4",children:"No windows yet"}),_.jsx("button",{onClick:n,className:"px-4 py-2 bg-primary text-primary-foreground rounded hover:bg-primary/90",children:"New Window"})]})});const r=e.activeWindowId&&e.windows.some(a=>a.id===e.activeWindowId)?e.activeWindowId:e.windows[0]?.id??null,i=_.jsx("button",{onClick:n,className:"flex items-center justify-center w-11 h-11 text-2xl font-medium text-primary active:text-primary/60 active:scale-95 transition-all select-none touch-manipulation",title:"New window (Cmd+K N)",children:"+"});return _.jsxs("div",{className:"flex h-dvh flex-col bg-background text-foreground",children:[_.jsx(ffe,{}),_.jsx(mfe,{children:_.jsx(nfe,{windows:e.windows,activeWindowId:r})}),_.jsx(hfe,{addButton:i,children:_.jsx(ofe,{windows:e.windows,activeWindowId:r})})]})}const sT=new sL({defaultOptions:{queries:{staleTime:1e3*60,refetchOnWindowFocus:!1}}});II.createRoot(document.getElementById("root")).render(_.jsx(C.StrictMode,{children:_.jsx(jt.Provider,{client:YP,queryClient:sT,children:_.jsx(oL,{client:sT,children:_.jsx(ufe,{defaultTheme:"dark",children:_.jsx(bfe,{})})})})}));const vfe=Object.freeze(Object.defineProperty({__proto__:null,Mermaid:gk},Symbol.toStringTag,{value:"Module"}));export{Ti as C,oJ as D,U as _,Bce as a,wO as b,Kle as c,_fe as d,Am as g,_ as j,Dt as k,C as r,it as u};