orbitchat 2.1.2 → 2.1.3

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 (45) hide show
  1. package/README.md +3 -3
  2. package/bin/orbitchat.js +6 -6
  3. package/dist/assets/{api-C_xfxXTe.js → api-CSbNIWZU.js} +1 -1
  4. package/dist/assets/{api-DphNnWRS.js → api-wWN3AN9F.js} +1 -1
  5. package/dist/assets/{arc-CvECY7sY-CteLXMyT.js → arc-CvECY7sY-D_JeAPDF.js} +1 -1
  6. package/dist/assets/{blockDiagram-c4efeb88-NvaZhZFT-BF7Jw6AF.js → blockDiagram-c4efeb88-NvaZhZFT-jebni1KA.js} +1 -1
  7. package/dist/assets/{c4Diagram-c83219d4-gPr1eF38-O9OcyqsQ.js → c4Diagram-c83219d4-gPr1eF38-Crko8syr.js} +1 -1
  8. package/dist/assets/channel-6PI3wNcc-CLVDgLrs.js +1 -0
  9. package/dist/assets/{classDiagram-beda092f-B8axaKGu-CnDHALya.js → classDiagram-beda092f-B8axaKGu-B0xqesVY.js} +1 -1
  10. package/dist/assets/{classDiagram-v2-2358418a-DPdf2DxR-D5LZKxzJ.js → classDiagram-v2-2358418a-DPdf2DxR-BVldiIQV.js} +1 -1
  11. package/dist/assets/clone-D01vUIhD-BFXrzyc_.js +1 -0
  12. package/dist/assets/{createText-1719965b-D9Y3vUMn-tpBGu7Uj.js → createText-1719965b-D9Y3vUMn-DGImntyt.js} +1 -1
  13. package/dist/assets/{edges-96097737-Zc6U9nQz-CYaK82dg.js → edges-96097737-Zc6U9nQz-Cyf2bYRt.js} +1 -1
  14. package/dist/assets/{erDiagram-0228fc6a-BLw8FsIp-hR-rEYLl.js → erDiagram-0228fc6a-BLw8FsIp-K7hty7n7.js} +1 -1
  15. package/dist/assets/{flowDb-c6c81e3f-DXVkMlSE-Dfm8piuo.js → flowDb-c6c81e3f-DXVkMlSE-Dlo_gb5q.js} +1 -1
  16. package/dist/assets/{flowDiagram-50d868cf-mkkB0hFd-hkUvxhtI.js → flowDiagram-50d868cf-mkkB0hFd-DyocKKmv.js} +1 -1
  17. package/dist/assets/flowDiagram-v2-4f6560a1-BRIhxQ3y-M3Kb-HpF.js +1 -0
  18. package/dist/assets/{flowchart-elk-definition-6af322e1-D9IbjnSJ-DDmMX5g7.js → flowchart-elk-definition-6af322e1-D9IbjnSJ-9Mck6Jvy.js} +1 -1
  19. package/dist/assets/{ganttDiagram-a2739b55-Cqs5_Zht-C2T02Tao.js → ganttDiagram-a2739b55-Cqs5_Zht-B9aZYss_.js} +1 -1
  20. package/dist/assets/{gitGraphDiagram-82fe8481-txBzFn40-DTjPLNM5.js → gitGraphDiagram-82fe8481-txBzFn40-D1K5om9l.js} +1 -1
  21. package/dist/assets/{graph-BZahQKIN-C4DT9AZV.js → graph-BZahQKIN-DEelLLhs.js} +1 -1
  22. package/dist/assets/{index-5325376f-DsNDppci-B4kOQBsS.js → index-5325376f-DsNDppci-Ct3KjfvA.js} +1 -1
  23. package/dist/assets/{index-XQdtexiT.js → index-Blk4CAFt.js} +6 -6
  24. package/dist/assets/{infoDiagram-8eee0895-SbmhgTjv-CQEw8uWZ.js → infoDiagram-8eee0895-SbmhgTjv-C9kXGFlX.js} +1 -1
  25. package/dist/assets/{journeyDiagram-c64418c1-C7AiwbKr-BzGlouWF.js → journeyDiagram-c64418c1-C7AiwbKr-Uzs60Xyr.js} +1 -1
  26. package/dist/assets/{layout-j-hMNqAM-CZK4t-Wu.js → layout-j-hMNqAM-C6qV8Soc.js} +1 -1
  27. package/dist/assets/{mindmap-definition-8da855dc-B1WjnfxE-bWS9Lud_.js → mindmap-definition-8da855dc-B1WjnfxE-BtUcqAXe.js} +1 -1
  28. package/dist/assets/{pieDiagram-a8764435-zrkaw4r--BbYH30QV.js → pieDiagram-a8764435-zrkaw4r--KTFILwx0.js} +1 -1
  29. package/dist/assets/{quadrantDiagram-1e28029f-C2Wa5n16-pT8UyjnW.js → quadrantDiagram-1e28029f-C2Wa5n16-QeGvwqfN.js} +1 -1
  30. package/dist/assets/{requirementDiagram-08caed73-BtHxx079-C0E62fgL.js → requirementDiagram-08caed73-BtHxx079-DmZZ94rA.js} +1 -1
  31. package/dist/assets/{sankeyDiagram-a04cb91d-DXlmqTKB-BJoGKmtH.js → sankeyDiagram-a04cb91d-DXlmqTKB-DgLDkAoH.js} +1 -1
  32. package/dist/assets/{sequenceDiagram-c5b8d532-BVQF3vcA-D3Ci0ZOB.js → sequenceDiagram-c5b8d532-BVQF3vcA-DaOYr80F.js} +1 -1
  33. package/dist/assets/{stateDiagram-1ecb1508-Dybc3i2m-17lEs8Wr.js → stateDiagram-1ecb1508-Dybc3i2m-Czv1eXAW.js} +1 -1
  34. package/dist/assets/{stateDiagram-v2-c2b004d7-Bp8rRkv2-CYqkFKft.js → stateDiagram-v2-c2b004d7-Bp8rRkv2-DprArMIU.js} +1 -1
  35. package/dist/assets/{styles-b4e223ce-BSiU4oYL-B3R_Qfty.js → styles-b4e223ce-BSiU4oYL-DMNXjBbh.js} +1 -1
  36. package/dist/assets/{styles-ca3715f6-DU7x0doE-BZiYRust.js → styles-ca3715f6-DU7x0doE-DSr9SLc9.js} +1 -1
  37. package/dist/assets/{styles-d45a18b0-B_CU21kM-CXjthFs4.js → styles-d45a18b0-B_CU21kM-Bm6W-cue.js} +1 -1
  38. package/dist/assets/{svgDrawCommon-b86b1483-sbEe2n2v-Dk1e24P9.js → svgDrawCommon-b86b1483-sbEe2n2v-3oBPXUwC.js} +1 -1
  39. package/dist/assets/{timeline-definition-faaaa080-b82QCnJ9-fscP9KLE.js → timeline-definition-faaaa080-b82QCnJ9-EH-DzRfv.js} +1 -1
  40. package/dist/assets/{xychartDiagram-f5964ef8-BtRcO0uy-9WZJM-Px.js → xychartDiagram-f5964ef8-BtRcO0uy-zTA5EBg7.js} +1 -1
  41. package/dist/index.html +1 -1
  42. package/package.json +1 -1
  43. package/dist/assets/channel-6PI3wNcc-Pm__Umqs.js +0 -1
  44. package/dist/assets/clone-D01vUIhD-C-wvvMPl.js +0 -1
  45. package/dist/assets/flowDiagram-v2-4f6560a1-BRIhxQ3y-yyJiLNqK.js +0 -1
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/c4Diagram-c83219d4-gPr1eF38-O9OcyqsQ.js","assets/svgDrawCommon-b86b1483-sbEe2n2v-Dk1e24P9.js","assets/flowDiagram-50d868cf-mkkB0hFd-hkUvxhtI.js","assets/flowDb-c6c81e3f-DXVkMlSE-Dfm8piuo.js","assets/graph-BZahQKIN-C4DT9AZV.js","assets/layout-j-hMNqAM-CZK4t-Wu.js","assets/styles-d45a18b0-B_CU21kM-CXjthFs4.js","assets/index-5325376f-DsNDppci-B4kOQBsS.js","assets/clone-D01vUIhD-C-wvvMPl.js","assets/edges-96097737-Zc6U9nQz-CYaK82dg.js","assets/createText-1719965b-D9Y3vUMn-tpBGu7Uj.js","assets/channel-6PI3wNcc-Pm__Umqs.js","assets/flowDiagram-v2-4f6560a1-BRIhxQ3y-yyJiLNqK.js","assets/erDiagram-0228fc6a-BLw8FsIp-hR-rEYLl.js","assets/pieDiagram-a8764435-zrkaw4r--BbYH30QV.js","assets/arc-CvECY7sY-CteLXMyT.js","assets/xychartDiagram-f5964ef8-BtRcO0uy-9WZJM-Px.js","assets/requirementDiagram-08caed73-BtHxx079-C0E62fgL.js","assets/sequenceDiagram-c5b8d532-BVQF3vcA-D3Ci0ZOB.js","assets/classDiagram-beda092f-B8axaKGu-CnDHALya.js","assets/styles-b4e223ce-BSiU4oYL-B3R_Qfty.js","assets/classDiagram-v2-2358418a-DPdf2DxR-D5LZKxzJ.js","assets/stateDiagram-1ecb1508-Dybc3i2m-17lEs8Wr.js","assets/styles-ca3715f6-DU7x0doE-BZiYRust.js","assets/stateDiagram-v2-c2b004d7-Bp8rRkv2-CYqkFKft.js","assets/journeyDiagram-c64418c1-C7AiwbKr-BzGlouWF.js","assets/flowchart-elk-definition-6af322e1-D9IbjnSJ-DDmMX5g7.js","assets/timeline-definition-faaaa080-b82QCnJ9-fscP9KLE.js","assets/mindmap-definition-8da855dc-B1WjnfxE-bWS9Lud_.js","assets/sankeyDiagram-a04cb91d-DXlmqTKB-BJoGKmtH.js","assets/Tableau10-D7jGxypv-Cyu9clx1.js","assets/blockDiagram-c4efeb88-NvaZhZFT-BF7Jw6AF.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/c4Diagram-c83219d4-gPr1eF38-Crko8syr.js","assets/svgDrawCommon-b86b1483-sbEe2n2v-3oBPXUwC.js","assets/flowDiagram-50d868cf-mkkB0hFd-DyocKKmv.js","assets/flowDb-c6c81e3f-DXVkMlSE-Dlo_gb5q.js","assets/graph-BZahQKIN-DEelLLhs.js","assets/layout-j-hMNqAM-C6qV8Soc.js","assets/styles-d45a18b0-B_CU21kM-Bm6W-cue.js","assets/index-5325376f-DsNDppci-Ct3KjfvA.js","assets/clone-D01vUIhD-BFXrzyc_.js","assets/edges-96097737-Zc6U9nQz-Cyf2bYRt.js","assets/createText-1719965b-D9Y3vUMn-DGImntyt.js","assets/channel-6PI3wNcc-CLVDgLrs.js","assets/flowDiagram-v2-4f6560a1-BRIhxQ3y-M3Kb-HpF.js","assets/erDiagram-0228fc6a-BLw8FsIp-K7hty7n7.js","assets/pieDiagram-a8764435-zrkaw4r--KTFILwx0.js","assets/arc-CvECY7sY-D_JeAPDF.js","assets/xychartDiagram-f5964ef8-BtRcO0uy-zTA5EBg7.js","assets/requirementDiagram-08caed73-BtHxx079-DmZZ94rA.js","assets/sequenceDiagram-c5b8d532-BVQF3vcA-DaOYr80F.js","assets/classDiagram-beda092f-B8axaKGu-B0xqesVY.js","assets/styles-b4e223ce-BSiU4oYL-DMNXjBbh.js","assets/classDiagram-v2-2358418a-DPdf2DxR-BVldiIQV.js","assets/stateDiagram-1ecb1508-Dybc3i2m-Czv1eXAW.js","assets/styles-ca3715f6-DU7x0doE-DSr9SLc9.js","assets/stateDiagram-v2-c2b004d7-Bp8rRkv2-DprArMIU.js","assets/journeyDiagram-c64418c1-C7AiwbKr-Uzs60Xyr.js","assets/flowchart-elk-definition-6af322e1-D9IbjnSJ-9Mck6Jvy.js","assets/timeline-definition-faaaa080-b82QCnJ9-EH-DzRfv.js","assets/mindmap-definition-8da855dc-B1WjnfxE-BtUcqAXe.js","assets/sankeyDiagram-a04cb91d-DXlmqTKB-DgLDkAoH.js","assets/Tableau10-D7jGxypv-Cyu9clx1.js","assets/blockDiagram-c4efeb88-NvaZhZFT-jebni1KA.js"])))=>i.map(i=>d[i]);
2
2
  var Ere=Object.defineProperty;var _re=(e,t,r)=>t in e?Ere(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var ai=(e,t,r)=>_re(e,typeof t!="symbol"?t+"":t,r);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))n(a);new MutationObserver(a=>{for(const i of a)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&n(o)}).observe(document,{childList:!0,subtree:!0});function r(a){const i={};return a.integrity&&(i.integrity=a.integrity),a.referrerPolicy&&(i.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?i.credentials="include":a.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function n(a){if(a.ep)return;a.ep=!0;const i=r(a);fetch(a.href,i)}})();function Are(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var HU={exports:{}},Ny={},qU={exports:{}},Jt={};/**
3
3
  * @license React
4
4
  * react.production.min.js
@@ -842,7 +842,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
842
842
  </div>
843
843
  `:`<div>${n}</div>`).join("").replace(Ak,(n,a)=>r.renderToString(a,{throwOnError:!0,displayMode:!0,output:bF()?"mathml":"htmlAndMathml"}).replace(/\n/g," ").replace(/<annotation.*<\/annotation>/g,""))},a_e=async(e,t)=>k0(await n_e(e,t),t),e9={getRows:GEe,sanitizeText:k0,sanitizeTextOrArray:KEe,hasBreaks:YEe,splitBreaks:ZEe,lineBreakRegex:Ch,removeScript:JY,getUrl:QEe,evaluate:tZ,getMax:JEe,getMin:e_e},Ta=(e,t)=>t?Ce(e,{s:-40,l:10}):Ce(e,{s:-40,l:-10}),Mb="#ffffff",Lb="#f2f2f2";let i_e=class{constructor(){this.background="#f4f4f4",this.primaryColor="#fff4dd",this.noteBkgColor="#fff5ad",this.noteTextColor="#333",this.THEME_COLOR_LIMIT=12,this.fontFamily='"trebuchet ms", verdana, arial, sans-serif',this.fontSize="16px"}updateColors(){var e,t,r,n,a,i,o,s,l,u,c;if(this.primaryTextColor=this.primaryTextColor||(this.darkMode?"#eee":"#333"),this.secondaryColor=this.secondaryColor||Ce(this.primaryColor,{h:-120}),this.tertiaryColor=this.tertiaryColor||Ce(this.primaryColor,{h:180,l:5}),this.primaryBorderColor=this.primaryBorderColor||Ta(this.primaryColor,this.darkMode),this.secondaryBorderColor=this.secondaryBorderColor||Ta(this.secondaryColor,this.darkMode),this.tertiaryBorderColor=this.tertiaryBorderColor||Ta(this.tertiaryColor,this.darkMode),this.noteBorderColor=this.noteBorderColor||Ta(this.noteBkgColor,this.darkMode),this.noteBkgColor=this.noteBkgColor||"#fff5ad",this.noteTextColor=this.noteTextColor||"#333",this.secondaryTextColor=this.secondaryTextColor||ct(this.secondaryColor),this.tertiaryTextColor=this.tertiaryTextColor||ct(this.tertiaryColor),this.lineColor=this.lineColor||ct(this.background),this.arrowheadColor=this.arrowheadColor||ct(this.background),this.textColor=this.textColor||this.primaryTextColor,this.border2=this.border2||this.tertiaryBorderColor,this.nodeBkg=this.nodeBkg||this.primaryColor,this.mainBkg=this.mainBkg||this.primaryColor,this.nodeBorder=this.nodeBorder||this.primaryBorderColor,this.clusterBkg=this.clusterBkg||this.tertiaryColor,this.clusterBorder=this.clusterBorder||this.tertiaryBorderColor,this.defaultLinkColor=this.defaultLinkColor||this.lineColor,this.titleColor=this.titleColor||this.tertiaryTextColor,this.edgeLabelBackground=this.edgeLabelBackground||(this.darkMode?Ot(this.secondaryColor,30):this.secondaryColor),this.nodeTextColor=this.nodeTextColor||this.primaryTextColor,this.actorBorder=this.actorBorder||this.primaryBorderColor,this.actorBkg=this.actorBkg||this.mainBkg,this.actorTextColor=this.actorTextColor||this.primaryTextColor,this.actorLineColor=this.actorLineColor||"grey",this.labelBoxBkgColor=this.labelBoxBkgColor||this.actorBkg,this.signalColor=this.signalColor||this.textColor,this.signalTextColor=this.signalTextColor||this.textColor,this.labelBoxBorderColor=this.labelBoxBorderColor||this.actorBorder,this.labelTextColor=this.labelTextColor||this.actorTextColor,this.loopTextColor=this.loopTextColor||this.actorTextColor,this.activationBorderColor=this.activationBorderColor||Ot(this.secondaryColor,10),this.activationBkgColor=this.activationBkgColor||this.secondaryColor,this.sequenceNumberColor=this.sequenceNumberColor||ct(this.lineColor),this.sectionBkgColor=this.sectionBkgColor||this.tertiaryColor,this.altSectionBkgColor=this.altSectionBkgColor||"white",this.sectionBkgColor=this.sectionBkgColor||this.secondaryColor,this.sectionBkgColor2=this.sectionBkgColor2||this.primaryColor,this.excludeBkgColor=this.excludeBkgColor||"#eeeeee",this.taskBorderColor=this.taskBorderColor||this.primaryBorderColor,this.taskBkgColor=this.taskBkgColor||this.primaryColor,this.activeTaskBorderColor=this.activeTaskBorderColor||this.primaryColor,this.activeTaskBkgColor=this.activeTaskBkgColor||_t(this.primaryColor,23),this.gridColor=this.gridColor||"lightgrey",this.doneTaskBkgColor=this.doneTaskBkgColor||"lightgrey",this.doneTaskBorderColor=this.doneTaskBorderColor||"grey",this.critBorderColor=this.critBorderColor||"#ff8888",this.critBkgColor=this.critBkgColor||"red",this.todayLineColor=this.todayLineColor||"red",this.taskTextColor=this.taskTextColor||this.textColor,this.taskTextOutsideColor=this.taskTextOutsideColor||this.textColor,this.taskTextLightColor=this.taskTextLightColor||this.textColor,this.taskTextColor=this.taskTextColor||this.primaryTextColor,this.taskTextDarkColor=this.taskTextDarkColor||this.textColor,this.taskTextClickableColor=this.taskTextClickableColor||"#003163",this.personBorder=this.personBorder||this.primaryBorderColor,this.personBkg=this.personBkg||this.mainBkg,this.transitionColor=this.transitionColor||this.lineColor,this.transitionLabelColor=this.transitionLabelColor||this.textColor,this.stateLabelColor=this.stateLabelColor||this.stateBkg||this.primaryTextColor,this.stateBkg=this.stateBkg||this.mainBkg,this.labelBackgroundColor=this.labelBackgroundColor||this.stateBkg,this.compositeBackground=this.compositeBackground||this.background||this.tertiaryColor,this.altBackground=this.altBackground||this.tertiaryColor,this.compositeTitleBackground=this.compositeTitleBackground||this.mainBkg,this.compositeBorder=this.compositeBorder||this.nodeBorder,this.innerEndBackground=this.nodeBorder,this.errorBkgColor=this.errorBkgColor||this.tertiaryColor,this.errorTextColor=this.errorTextColor||this.tertiaryTextColor,this.transitionColor=this.transitionColor||this.lineColor,this.specialStateColor=this.lineColor,this.cScale0=this.cScale0||this.primaryColor,this.cScale1=this.cScale1||this.secondaryColor,this.cScale2=this.cScale2||this.tertiaryColor,this.cScale3=this.cScale3||Ce(this.primaryColor,{h:30}),this.cScale4=this.cScale4||Ce(this.primaryColor,{h:60}),this.cScale5=this.cScale5||Ce(this.primaryColor,{h:90}),this.cScale6=this.cScale6||Ce(this.primaryColor,{h:120}),this.cScale7=this.cScale7||Ce(this.primaryColor,{h:150}),this.cScale8=this.cScale8||Ce(this.primaryColor,{h:210,l:150}),this.cScale9=this.cScale9||Ce(this.primaryColor,{h:270}),this.cScale10=this.cScale10||Ce(this.primaryColor,{h:300}),this.cScale11=this.cScale11||Ce(this.primaryColor,{h:330}),this.darkMode)for(let p=0;p<this.THEME_COLOR_LIMIT;p++)this["cScale"+p]=Ot(this["cScale"+p],75);else for(let p=0;p<this.THEME_COLOR_LIMIT;p++)this["cScale"+p]=Ot(this["cScale"+p],25);for(let p=0;p<this.THEME_COLOR_LIMIT;p++)this["cScaleInv"+p]=this["cScaleInv"+p]||ct(this["cScale"+p]);for(let p=0;p<this.THEME_COLOR_LIMIT;p++)this.darkMode?this["cScalePeer"+p]=this["cScalePeer"+p]||_t(this["cScale"+p],10):this["cScalePeer"+p]=this["cScalePeer"+p]||Ot(this["cScale"+p],10);this.scaleLabelColor=this.scaleLabelColor||this.labelTextColor;for(let p=0;p<this.THEME_COLOR_LIMIT;p++)this["cScaleLabel"+p]=this["cScaleLabel"+p]||this.scaleLabelColor;const d=this.darkMode?-4:-1;for(let p=0;p<5;p++)this["surface"+p]=this["surface"+p]||Ce(this.mainBkg,{h:180,s:-15,l:d*(5+p*3)}),this["surfacePeer"+p]=this["surfacePeer"+p]||Ce(this.mainBkg,{h:180,s:-15,l:d*(8+p*3)});this.classText=this.classText||this.textColor,this.fillType0=this.fillType0||this.primaryColor,this.fillType1=this.fillType1||this.secondaryColor,this.fillType2=this.fillType2||Ce(this.primaryColor,{h:64}),this.fillType3=this.fillType3||Ce(this.secondaryColor,{h:64}),this.fillType4=this.fillType4||Ce(this.primaryColor,{h:-64}),this.fillType5=this.fillType5||Ce(this.secondaryColor,{h:-64}),this.fillType6=this.fillType6||Ce(this.primaryColor,{h:128}),this.fillType7=this.fillType7||Ce(this.secondaryColor,{h:128}),this.pie1=this.pie1||this.primaryColor,this.pie2=this.pie2||this.secondaryColor,this.pie3=this.pie3||this.tertiaryColor,this.pie4=this.pie4||Ce(this.primaryColor,{l:-10}),this.pie5=this.pie5||Ce(this.secondaryColor,{l:-10}),this.pie6=this.pie6||Ce(this.tertiaryColor,{l:-10}),this.pie7=this.pie7||Ce(this.primaryColor,{h:60,l:-10}),this.pie8=this.pie8||Ce(this.primaryColor,{h:-60,l:-10}),this.pie9=this.pie9||Ce(this.primaryColor,{h:120,l:0}),this.pie10=this.pie10||Ce(this.primaryColor,{h:60,l:-20}),this.pie11=this.pie11||Ce(this.primaryColor,{h:-60,l:-20}),this.pie12=this.pie12||Ce(this.primaryColor,{h:120,l:-10}),this.pieTitleTextSize=this.pieTitleTextSize||"25px",this.pieTitleTextColor=this.pieTitleTextColor||this.taskTextDarkColor,this.pieSectionTextSize=this.pieSectionTextSize||"17px",this.pieSectionTextColor=this.pieSectionTextColor||this.textColor,this.pieLegendTextSize=this.pieLegendTextSize||"17px",this.pieLegendTextColor=this.pieLegendTextColor||this.taskTextDarkColor,this.pieStrokeColor=this.pieStrokeColor||"black",this.pieStrokeWidth=this.pieStrokeWidth||"2px",this.pieOuterStrokeWidth=this.pieOuterStrokeWidth||"2px",this.pieOuterStrokeColor=this.pieOuterStrokeColor||"black",this.pieOpacity=this.pieOpacity||"0.7",this.quadrant1Fill=this.quadrant1Fill||this.primaryColor,this.quadrant2Fill=this.quadrant2Fill||Ce(this.primaryColor,{r:5,g:5,b:5}),this.quadrant3Fill=this.quadrant3Fill||Ce(this.primaryColor,{r:10,g:10,b:10}),this.quadrant4Fill=this.quadrant4Fill||Ce(this.primaryColor,{r:15,g:15,b:15}),this.quadrant1TextFill=this.quadrant1TextFill||this.primaryTextColor,this.quadrant2TextFill=this.quadrant2TextFill||Ce(this.primaryTextColor,{r:-5,g:-5,b:-5}),this.quadrant3TextFill=this.quadrant3TextFill||Ce(this.primaryTextColor,{r:-10,g:-10,b:-10}),this.quadrant4TextFill=this.quadrant4TextFill||Ce(this.primaryTextColor,{r:-15,g:-15,b:-15}),this.quadrantPointFill=this.quadrantPointFill||_h(this.quadrant1Fill)?_t(this.quadrant1Fill):Ot(this.quadrant1Fill),this.quadrantPointTextFill=this.quadrantPointTextFill||this.primaryTextColor,this.quadrantXAxisTextFill=this.quadrantXAxisTextFill||this.primaryTextColor,this.quadrantYAxisTextFill=this.quadrantYAxisTextFill||this.primaryTextColor,this.quadrantInternalBorderStrokeFill=this.quadrantInternalBorderStrokeFill||this.primaryBorderColor,this.quadrantExternalBorderStrokeFill=this.quadrantExternalBorderStrokeFill||this.primaryBorderColor,this.quadrantTitleFill=this.quadrantTitleFill||this.primaryTextColor,this.xyChart={backgroundColor:((e=this.xyChart)==null?void 0:e.backgroundColor)||this.background,titleColor:((t=this.xyChart)==null?void 0:t.titleColor)||this.primaryTextColor,xAxisTitleColor:((r=this.xyChart)==null?void 0:r.xAxisTitleColor)||this.primaryTextColor,xAxisLabelColor:((n=this.xyChart)==null?void 0:n.xAxisLabelColor)||this.primaryTextColor,xAxisTickColor:((a=this.xyChart)==null?void 0:a.xAxisTickColor)||this.primaryTextColor,xAxisLineColor:((i=this.xyChart)==null?void 0:i.xAxisLineColor)||this.primaryTextColor,yAxisTitleColor:((o=this.xyChart)==null?void 0:o.yAxisTitleColor)||this.primaryTextColor,yAxisLabelColor:((s=this.xyChart)==null?void 0:s.yAxisLabelColor)||this.primaryTextColor,yAxisTickColor:((l=this.xyChart)==null?void 0:l.yAxisTickColor)||this.primaryTextColor,yAxisLineColor:((u=this.xyChart)==null?void 0:u.yAxisLineColor)||this.primaryTextColor,plotColorPalette:((c=this.xyChart)==null?void 0:c.plotColorPalette)||"#FFF4DD,#FFD8B1,#FFA07A,#ECEFF1,#D6DBDF,#C3E0A8,#FFB6A4,#FFD74D,#738FA7,#FFFFF0"},this.requirementBackground=this.requirementBackground||this.primaryColor,this.requirementBorderColor=this.requirementBorderColor||this.primaryBorderColor,this.requirementBorderSize=this.requirementBorderSize||"1",this.requirementTextColor=this.requirementTextColor||this.primaryTextColor,this.relationColor=this.relationColor||this.lineColor,this.relationLabelBackground=this.relationLabelBackground||(this.darkMode?Ot(this.secondaryColor,30):this.secondaryColor),this.relationLabelColor=this.relationLabelColor||this.actorTextColor,this.git0=this.git0||this.primaryColor,this.git1=this.git1||this.secondaryColor,this.git2=this.git2||this.tertiaryColor,this.git3=this.git3||Ce(this.primaryColor,{h:-30}),this.git4=this.git4||Ce(this.primaryColor,{h:-60}),this.git5=this.git5||Ce(this.primaryColor,{h:-90}),this.git6=this.git6||Ce(this.primaryColor,{h:60}),this.git7=this.git7||Ce(this.primaryColor,{h:120}),this.darkMode?(this.git0=_t(this.git0,25),this.git1=_t(this.git1,25),this.git2=_t(this.git2,25),this.git3=_t(this.git3,25),this.git4=_t(this.git4,25),this.git5=_t(this.git5,25),this.git6=_t(this.git6,25),this.git7=_t(this.git7,25)):(this.git0=Ot(this.git0,25),this.git1=Ot(this.git1,25),this.git2=Ot(this.git2,25),this.git3=Ot(this.git3,25),this.git4=Ot(this.git4,25),this.git5=Ot(this.git5,25),this.git6=Ot(this.git6,25),this.git7=Ot(this.git7,25)),this.gitInv0=this.gitInv0||ct(this.git0),this.gitInv1=this.gitInv1||ct(this.git1),this.gitInv2=this.gitInv2||ct(this.git2),this.gitInv3=this.gitInv3||ct(this.git3),this.gitInv4=this.gitInv4||ct(this.git4),this.gitInv5=this.gitInv5||ct(this.git5),this.gitInv6=this.gitInv6||ct(this.git6),this.gitInv7=this.gitInv7||ct(this.git7),this.branchLabelColor=this.branchLabelColor||(this.darkMode?"black":this.labelTextColor),this.gitBranchLabel0=this.gitBranchLabel0||this.branchLabelColor,this.gitBranchLabel1=this.gitBranchLabel1||this.branchLabelColor,this.gitBranchLabel2=this.gitBranchLabel2||this.branchLabelColor,this.gitBranchLabel3=this.gitBranchLabel3||this.branchLabelColor,this.gitBranchLabel4=this.gitBranchLabel4||this.branchLabelColor,this.gitBranchLabel5=this.gitBranchLabel5||this.branchLabelColor,this.gitBranchLabel6=this.gitBranchLabel6||this.branchLabelColor,this.gitBranchLabel7=this.gitBranchLabel7||this.branchLabelColor,this.tagLabelColor=this.tagLabelColor||this.primaryTextColor,this.tagLabelBackground=this.tagLabelBackground||this.primaryColor,this.tagLabelBorder=this.tagBorder||this.primaryBorderColor,this.tagLabelFontSize=this.tagLabelFontSize||"10px",this.commitLabelColor=this.commitLabelColor||this.secondaryTextColor,this.commitLabelBackground=this.commitLabelBackground||this.secondaryColor,this.commitLabelFontSize=this.commitLabelFontSize||"10px",this.attributeBackgroundColorOdd=this.attributeBackgroundColorOdd||Mb,this.attributeBackgroundColorEven=this.attributeBackgroundColorEven||Lb}calculate(e){if(typeof e!="object"){this.updateColors();return}const t=Object.keys(e);t.forEach(r=>{this[r]=e[r]}),this.updateColors(),t.forEach(r=>{this[r]=e[r]})}};const o_e=e=>{const t=new i_e;return t.calculate(e),t};let s_e=class{constructor(){this.background="#333",this.primaryColor="#1f2020",this.secondaryColor=_t(this.primaryColor,16),this.tertiaryColor=Ce(this.primaryColor,{h:-160}),this.primaryBorderColor=ct(this.background),this.secondaryBorderColor=Ta(this.secondaryColor,this.darkMode),this.tertiaryBorderColor=Ta(this.tertiaryColor,this.darkMode),this.primaryTextColor=ct(this.primaryColor),this.secondaryTextColor=ct(this.secondaryColor),this.tertiaryTextColor=ct(this.tertiaryColor),this.lineColor=ct(this.background),this.textColor=ct(this.background),this.mainBkg="#1f2020",this.secondBkg="calculated",this.mainContrastColor="lightgrey",this.darkTextColor=_t(ct("#323D47"),10),this.lineColor="calculated",this.border1="#81B1DB",this.border2=up(255,255,255,.25),this.arrowheadColor="calculated",this.fontFamily='"trebuchet ms", verdana, arial, sans-serif',this.fontSize="16px",this.labelBackground="#181818",this.textColor="#ccc",this.THEME_COLOR_LIMIT=12,this.nodeBkg="calculated",this.nodeBorder="calculated",this.clusterBkg="calculated",this.clusterBorder="calculated",this.defaultLinkColor="calculated",this.titleColor="#F9FFFE",this.edgeLabelBackground="calculated",this.actorBorder="calculated",this.actorBkg="calculated",this.actorTextColor="calculated",this.actorLineColor="calculated",this.signalColor="calculated",this.signalTextColor="calculated",this.labelBoxBkgColor="calculated",this.labelBoxBorderColor="calculated",this.labelTextColor="calculated",this.loopTextColor="calculated",this.noteBorderColor="calculated",this.noteBkgColor="#fff5ad",this.noteTextColor="calculated",this.activationBorderColor="calculated",this.activationBkgColor="calculated",this.sequenceNumberColor="black",this.sectionBkgColor=Ot("#EAE8D9",30),this.altSectionBkgColor="calculated",this.sectionBkgColor2="#EAE8D9",this.excludeBkgColor=Ot(this.sectionBkgColor,10),this.taskBorderColor=up(255,255,255,70),this.taskBkgColor="calculated",this.taskTextColor="calculated",this.taskTextLightColor="calculated",this.taskTextOutsideColor="calculated",this.taskTextClickableColor="#003163",this.activeTaskBorderColor=up(255,255,255,50),this.activeTaskBkgColor="#81B1DB",this.gridColor="calculated",this.doneTaskBkgColor="calculated",this.doneTaskBorderColor="grey",this.critBorderColor="#E83737",this.critBkgColor="#E83737",this.taskTextDarkColor="calculated",this.todayLineColor="#DB5757",this.personBorder=this.primaryBorderColor,this.personBkg=this.mainBkg,this.labelColor="calculated",this.errorBkgColor="#a44141",this.errorTextColor="#ddd"}updateColors(){var e,t,r,n,a,i,o,s,l,u,c;this.secondBkg=_t(this.mainBkg,16),this.lineColor=this.mainContrastColor,this.arrowheadColor=this.mainContrastColor,this.nodeBkg=this.mainBkg,this.nodeBorder=this.border1,this.clusterBkg=this.secondBkg,this.clusterBorder=this.border2,this.defaultLinkColor=this.lineColor,this.edgeLabelBackground=_t(this.labelBackground,25),this.actorBorder=this.border1,this.actorBkg=this.mainBkg,this.actorTextColor=this.mainContrastColor,this.actorLineColor=this.mainContrastColor,this.signalColor=this.mainContrastColor,this.signalTextColor=this.mainContrastColor,this.labelBoxBkgColor=this.actorBkg,this.labelBoxBorderColor=this.actorBorder,this.labelTextColor=this.mainContrastColor,this.loopTextColor=this.mainContrastColor,this.noteBorderColor=this.secondaryBorderColor,this.noteBkgColor=this.secondBkg,this.noteTextColor=this.secondaryTextColor,this.activationBorderColor=this.border1,this.activationBkgColor=this.secondBkg,this.altSectionBkgColor=this.background,this.taskBkgColor=_t(this.mainBkg,23),this.taskTextColor=this.darkTextColor,this.taskTextLightColor=this.mainContrastColor,this.taskTextOutsideColor=this.taskTextLightColor,this.gridColor=this.mainContrastColor,this.doneTaskBkgColor=this.mainContrastColor,this.taskTextDarkColor=this.darkTextColor,this.transitionColor=this.transitionColor||this.lineColor,this.transitionLabelColor=this.transitionLabelColor||this.textColor,this.stateLabelColor=this.stateLabelColor||this.stateBkg||this.primaryTextColor,this.stateBkg=this.stateBkg||this.mainBkg,this.labelBackgroundColor=this.labelBackgroundColor||this.stateBkg,this.compositeBackground=this.compositeBackground||this.background||this.tertiaryColor,this.altBackground=this.altBackground||"#555",this.compositeTitleBackground=this.compositeTitleBackground||this.mainBkg,this.compositeBorder=this.compositeBorder||this.nodeBorder,this.innerEndBackground=this.primaryBorderColor,this.specialStateColor="#f4f4f4",this.errorBkgColor=this.errorBkgColor||this.tertiaryColor,this.errorTextColor=this.errorTextColor||this.tertiaryTextColor,this.fillType0=this.primaryColor,this.fillType1=this.secondaryColor,this.fillType2=Ce(this.primaryColor,{h:64}),this.fillType3=Ce(this.secondaryColor,{h:64}),this.fillType4=Ce(this.primaryColor,{h:-64}),this.fillType5=Ce(this.secondaryColor,{h:-64}),this.fillType6=Ce(this.primaryColor,{h:128}),this.fillType7=Ce(this.secondaryColor,{h:128}),this.cScale1=this.cScale1||"#0b0000",this.cScale2=this.cScale2||"#4d1037",this.cScale3=this.cScale3||"#3f5258",this.cScale4=this.cScale4||"#4f2f1b",this.cScale5=this.cScale5||"#6e0a0a",this.cScale6=this.cScale6||"#3b0048",this.cScale7=this.cScale7||"#995a01",this.cScale8=this.cScale8||"#154706",this.cScale9=this.cScale9||"#161722",this.cScale10=this.cScale10||"#00296f",this.cScale11=this.cScale11||"#01629c",this.cScale12=this.cScale12||"#010029",this.cScale0=this.cScale0||this.primaryColor,this.cScale1=this.cScale1||this.secondaryColor,this.cScale2=this.cScale2||this.tertiaryColor,this.cScale3=this.cScale3||Ce(this.primaryColor,{h:30}),this.cScale4=this.cScale4||Ce(this.primaryColor,{h:60}),this.cScale5=this.cScale5||Ce(this.primaryColor,{h:90}),this.cScale6=this.cScale6||Ce(this.primaryColor,{h:120}),this.cScale7=this.cScale7||Ce(this.primaryColor,{h:150}),this.cScale8=this.cScale8||Ce(this.primaryColor,{h:210}),this.cScale9=this.cScale9||Ce(this.primaryColor,{h:270}),this.cScale10=this.cScale10||Ce(this.primaryColor,{h:300}),this.cScale11=this.cScale11||Ce(this.primaryColor,{h:330});for(let d=0;d<this.THEME_COLOR_LIMIT;d++)this["cScaleInv"+d]=this["cScaleInv"+d]||ct(this["cScale"+d]);for(let d=0;d<this.THEME_COLOR_LIMIT;d++)this["cScalePeer"+d]=this["cScalePeer"+d]||_t(this["cScale"+d],10);for(let d=0;d<5;d++)this["surface"+d]=this["surface"+d]||Ce(this.mainBkg,{h:30,s:-30,l:-(-10+d*4)}),this["surfacePeer"+d]=this["surfacePeer"+d]||Ce(this.mainBkg,{h:30,s:-30,l:-(-7+d*4)});this.scaleLabelColor=this.scaleLabelColor||(this.darkMode?"black":this.labelTextColor);for(let d=0;d<this.THEME_COLOR_LIMIT;d++)this["cScaleLabel"+d]=this["cScaleLabel"+d]||this.scaleLabelColor;for(let d=0;d<this.THEME_COLOR_LIMIT;d++)this["pie"+d]=this["cScale"+d];this.pieTitleTextSize=this.pieTitleTextSize||"25px",this.pieTitleTextColor=this.pieTitleTextColor||this.taskTextDarkColor,this.pieSectionTextSize=this.pieSectionTextSize||"17px",this.pieSectionTextColor=this.pieSectionTextColor||this.textColor,this.pieLegendTextSize=this.pieLegendTextSize||"17px",this.pieLegendTextColor=this.pieLegendTextColor||this.taskTextDarkColor,this.pieStrokeColor=this.pieStrokeColor||"black",this.pieStrokeWidth=this.pieStrokeWidth||"2px",this.pieOuterStrokeWidth=this.pieOuterStrokeWidth||"2px",this.pieOuterStrokeColor=this.pieOuterStrokeColor||"black",this.pieOpacity=this.pieOpacity||"0.7",this.quadrant1Fill=this.quadrant1Fill||this.primaryColor,this.quadrant2Fill=this.quadrant2Fill||Ce(this.primaryColor,{r:5,g:5,b:5}),this.quadrant3Fill=this.quadrant3Fill||Ce(this.primaryColor,{r:10,g:10,b:10}),this.quadrant4Fill=this.quadrant4Fill||Ce(this.primaryColor,{r:15,g:15,b:15}),this.quadrant1TextFill=this.quadrant1TextFill||this.primaryTextColor,this.quadrant2TextFill=this.quadrant2TextFill||Ce(this.primaryTextColor,{r:-5,g:-5,b:-5}),this.quadrant3TextFill=this.quadrant3TextFill||Ce(this.primaryTextColor,{r:-10,g:-10,b:-10}),this.quadrant4TextFill=this.quadrant4TextFill||Ce(this.primaryTextColor,{r:-15,g:-15,b:-15}),this.quadrantPointFill=this.quadrantPointFill||_h(this.quadrant1Fill)?_t(this.quadrant1Fill):Ot(this.quadrant1Fill),this.quadrantPointTextFill=this.quadrantPointTextFill||this.primaryTextColor,this.quadrantXAxisTextFill=this.quadrantXAxisTextFill||this.primaryTextColor,this.quadrantYAxisTextFill=this.quadrantYAxisTextFill||this.primaryTextColor,this.quadrantInternalBorderStrokeFill=this.quadrantInternalBorderStrokeFill||this.primaryBorderColor,this.quadrantExternalBorderStrokeFill=this.quadrantExternalBorderStrokeFill||this.primaryBorderColor,this.quadrantTitleFill=this.quadrantTitleFill||this.primaryTextColor,this.xyChart={backgroundColor:((e=this.xyChart)==null?void 0:e.backgroundColor)||this.background,titleColor:((t=this.xyChart)==null?void 0:t.titleColor)||this.primaryTextColor,xAxisTitleColor:((r=this.xyChart)==null?void 0:r.xAxisTitleColor)||this.primaryTextColor,xAxisLabelColor:((n=this.xyChart)==null?void 0:n.xAxisLabelColor)||this.primaryTextColor,xAxisTickColor:((a=this.xyChart)==null?void 0:a.xAxisTickColor)||this.primaryTextColor,xAxisLineColor:((i=this.xyChart)==null?void 0:i.xAxisLineColor)||this.primaryTextColor,yAxisTitleColor:((o=this.xyChart)==null?void 0:o.yAxisTitleColor)||this.primaryTextColor,yAxisLabelColor:((s=this.xyChart)==null?void 0:s.yAxisLabelColor)||this.primaryTextColor,yAxisTickColor:((l=this.xyChart)==null?void 0:l.yAxisTickColor)||this.primaryTextColor,yAxisLineColor:((u=this.xyChart)==null?void 0:u.yAxisLineColor)||this.primaryTextColor,plotColorPalette:((c=this.xyChart)==null?void 0:c.plotColorPalette)||"#3498db,#2ecc71,#e74c3c,#f1c40f,#bdc3c7,#ffffff,#34495e,#9b59b6,#1abc9c,#e67e22"},this.classText=this.primaryTextColor,this.requirementBackground=this.requirementBackground||this.primaryColor,this.requirementBorderColor=this.requirementBorderColor||this.primaryBorderColor,this.requirementBorderSize=this.requirementBorderSize||"1",this.requirementTextColor=this.requirementTextColor||this.primaryTextColor,this.relationColor=this.relationColor||this.lineColor,this.relationLabelBackground=this.relationLabelBackground||(this.darkMode?Ot(this.secondaryColor,30):this.secondaryColor),this.relationLabelColor=this.relationLabelColor||this.actorTextColor,this.git0=_t(this.secondaryColor,20),this.git1=_t(this.pie2||this.secondaryColor,20),this.git2=_t(this.pie3||this.tertiaryColor,20),this.git3=_t(this.pie4||Ce(this.primaryColor,{h:-30}),20),this.git4=_t(this.pie5||Ce(this.primaryColor,{h:-60}),20),this.git5=_t(this.pie6||Ce(this.primaryColor,{h:-90}),10),this.git6=_t(this.pie7||Ce(this.primaryColor,{h:60}),10),this.git7=_t(this.pie8||Ce(this.primaryColor,{h:120}),20),this.gitInv0=this.gitInv0||ct(this.git0),this.gitInv1=this.gitInv1||ct(this.git1),this.gitInv2=this.gitInv2||ct(this.git2),this.gitInv3=this.gitInv3||ct(this.git3),this.gitInv4=this.gitInv4||ct(this.git4),this.gitInv5=this.gitInv5||ct(this.git5),this.gitInv6=this.gitInv6||ct(this.git6),this.gitInv7=this.gitInv7||ct(this.git7),this.gitBranchLabel0=this.gitBranchLabel0||ct(this.labelTextColor),this.gitBranchLabel1=this.gitBranchLabel1||this.labelTextColor,this.gitBranchLabel2=this.gitBranchLabel2||this.labelTextColor,this.gitBranchLabel3=this.gitBranchLabel3||ct(this.labelTextColor),this.gitBranchLabel4=this.gitBranchLabel4||this.labelTextColor,this.gitBranchLabel5=this.gitBranchLabel5||this.labelTextColor,this.gitBranchLabel6=this.gitBranchLabel6||this.labelTextColor,this.gitBranchLabel7=this.gitBranchLabel7||this.labelTextColor,this.tagLabelColor=this.tagLabelColor||this.primaryTextColor,this.tagLabelBackground=this.tagLabelBackground||this.primaryColor,this.tagLabelBorder=this.tagBorder||this.primaryBorderColor,this.tagLabelFontSize=this.tagLabelFontSize||"10px",this.commitLabelColor=this.commitLabelColor||this.secondaryTextColor,this.commitLabelBackground=this.commitLabelBackground||this.secondaryColor,this.commitLabelFontSize=this.commitLabelFontSize||"10px",this.attributeBackgroundColorOdd=this.attributeBackgroundColorOdd||_t(this.background,12),this.attributeBackgroundColorEven=this.attributeBackgroundColorEven||_t(this.background,2)}calculate(e){if(typeof e!="object"){this.updateColors();return}const t=Object.keys(e);t.forEach(r=>{this[r]=e[r]}),this.updateColors(),t.forEach(r=>{this[r]=e[r]})}};const l_e=e=>{const t=new s_e;return t.calculate(e),t};let u_e=class{constructor(){this.background="#f4f4f4",this.primaryColor="#ECECFF",this.secondaryColor=Ce(this.primaryColor,{h:120}),this.secondaryColor="#ffffde",this.tertiaryColor=Ce(this.primaryColor,{h:-160}),this.primaryBorderColor=Ta(this.primaryColor,this.darkMode),this.secondaryBorderColor=Ta(this.secondaryColor,this.darkMode),this.tertiaryBorderColor=Ta(this.tertiaryColor,this.darkMode),this.primaryTextColor=ct(this.primaryColor),this.secondaryTextColor=ct(this.secondaryColor),this.tertiaryTextColor=ct(this.tertiaryColor),this.lineColor=ct(this.background),this.textColor=ct(this.background),this.background="white",this.mainBkg="#ECECFF",this.secondBkg="#ffffde",this.lineColor="#333333",this.border1="#9370DB",this.border2="#aaaa33",this.arrowheadColor="#333333",this.fontFamily='"trebuchet ms", verdana, arial, sans-serif',this.fontSize="16px",this.labelBackground="#e8e8e8",this.textColor="#333",this.THEME_COLOR_LIMIT=12,this.nodeBkg="calculated",this.nodeBorder="calculated",this.clusterBkg="calculated",this.clusterBorder="calculated",this.defaultLinkColor="calculated",this.titleColor="calculated",this.edgeLabelBackground="calculated",this.actorBorder="calculated",this.actorBkg="calculated",this.actorTextColor="black",this.actorLineColor="grey",this.signalColor="calculated",this.signalTextColor="calculated",this.labelBoxBkgColor="calculated",this.labelBoxBorderColor="calculated",this.labelTextColor="calculated",this.loopTextColor="calculated",this.noteBorderColor="calculated",this.noteBkgColor="#fff5ad",this.noteTextColor="calculated",this.activationBorderColor="#666",this.activationBkgColor="#f4f4f4",this.sequenceNumberColor="white",this.sectionBkgColor="calculated",this.altSectionBkgColor="calculated",this.sectionBkgColor2="calculated",this.excludeBkgColor="#eeeeee",this.taskBorderColor="calculated",this.taskBkgColor="calculated",this.taskTextLightColor="calculated",this.taskTextColor=this.taskTextLightColor,this.taskTextDarkColor="calculated",this.taskTextOutsideColor=this.taskTextDarkColor,this.taskTextClickableColor="calculated",this.activeTaskBorderColor="calculated",this.activeTaskBkgColor="calculated",this.gridColor="calculated",this.doneTaskBkgColor="calculated",this.doneTaskBorderColor="calculated",this.critBorderColor="calculated",this.critBkgColor="calculated",this.todayLineColor="calculated",this.sectionBkgColor=up(102,102,255,.49),this.altSectionBkgColor="white",this.sectionBkgColor2="#fff400",this.taskBorderColor="#534fbc",this.taskBkgColor="#8a90dd",this.taskTextLightColor="white",this.taskTextColor="calculated",this.taskTextDarkColor="black",this.taskTextOutsideColor="calculated",this.taskTextClickableColor="#003163",this.activeTaskBorderColor="#534fbc",this.activeTaskBkgColor="#bfc7ff",this.gridColor="lightgrey",this.doneTaskBkgColor="lightgrey",this.doneTaskBorderColor="grey",this.critBorderColor="#ff8888",this.critBkgColor="red",this.todayLineColor="red",this.personBorder=this.primaryBorderColor,this.personBkg=this.mainBkg,this.labelColor="black",this.errorBkgColor="#552222",this.errorTextColor="#552222",this.updateColors()}updateColors(){var e,t,r,n,a,i,o,s,l,u,c;this.cScale0=this.cScale0||this.primaryColor,this.cScale1=this.cScale1||this.secondaryColor,this.cScale2=this.cScale2||this.tertiaryColor,this.cScale3=this.cScale3||Ce(this.primaryColor,{h:30}),this.cScale4=this.cScale4||Ce(this.primaryColor,{h:60}),this.cScale5=this.cScale5||Ce(this.primaryColor,{h:90}),this.cScale6=this.cScale6||Ce(this.primaryColor,{h:120}),this.cScale7=this.cScale7||Ce(this.primaryColor,{h:150}),this.cScale8=this.cScale8||Ce(this.primaryColor,{h:210}),this.cScale9=this.cScale9||Ce(this.primaryColor,{h:270}),this.cScale10=this.cScale10||Ce(this.primaryColor,{h:300}),this.cScale11=this.cScale11||Ce(this.primaryColor,{h:330}),this.cScalePeer1=this.cScalePeer1||Ot(this.secondaryColor,45),this.cScalePeer2=this.cScalePeer2||Ot(this.tertiaryColor,40);for(let d=0;d<this.THEME_COLOR_LIMIT;d++)this["cScale"+d]=Ot(this["cScale"+d],10),this["cScalePeer"+d]=this["cScalePeer"+d]||Ot(this["cScale"+d],25);for(let d=0;d<this.THEME_COLOR_LIMIT;d++)this["cScaleInv"+d]=this["cScaleInv"+d]||Ce(this["cScale"+d],{h:180});for(let d=0;d<5;d++)this["surface"+d]=this["surface"+d]||Ce(this.mainBkg,{h:30,l:-(5+d*5)}),this["surfacePeer"+d]=this["surfacePeer"+d]||Ce(this.mainBkg,{h:30,l:-(7+d*5)});if(this.scaleLabelColor=this.scaleLabelColor!=="calculated"&&this.scaleLabelColor?this.scaleLabelColor:this.labelTextColor,this.labelTextColor!=="calculated"){this.cScaleLabel0=this.cScaleLabel0||ct(this.labelTextColor),this.cScaleLabel3=this.cScaleLabel3||ct(this.labelTextColor);for(let d=0;d<this.THEME_COLOR_LIMIT;d++)this["cScaleLabel"+d]=this["cScaleLabel"+d]||this.labelTextColor}this.nodeBkg=this.mainBkg,this.nodeBorder=this.border1,this.clusterBkg=this.secondBkg,this.clusterBorder=this.border2,this.defaultLinkColor=this.lineColor,this.titleColor=this.textColor,this.edgeLabelBackground=this.labelBackground,this.actorBorder=_t(this.border1,23),this.actorBkg=this.mainBkg,this.labelBoxBkgColor=this.actorBkg,this.signalColor=this.textColor,this.signalTextColor=this.textColor,this.labelBoxBorderColor=this.actorBorder,this.labelTextColor=this.actorTextColor,this.loopTextColor=this.actorTextColor,this.noteBorderColor=this.border2,this.noteTextColor=this.actorTextColor,this.taskTextColor=this.taskTextLightColor,this.taskTextOutsideColor=this.taskTextDarkColor,this.transitionColor=this.transitionColor||this.lineColor,this.transitionLabelColor=this.transitionLabelColor||this.textColor,this.stateLabelColor=this.stateLabelColor||this.stateBkg||this.primaryTextColor,this.stateBkg=this.stateBkg||this.mainBkg,this.labelBackgroundColor=this.labelBackgroundColor||this.stateBkg,this.compositeBackground=this.compositeBackground||this.background||this.tertiaryColor,this.altBackground=this.altBackground||"#f0f0f0",this.compositeTitleBackground=this.compositeTitleBackground||this.mainBkg,this.compositeBorder=this.compositeBorder||this.nodeBorder,this.innerEndBackground=this.nodeBorder,this.specialStateColor=this.lineColor,this.errorBkgColor=this.errorBkgColor||this.tertiaryColor,this.errorTextColor=this.errorTextColor||this.tertiaryTextColor,this.transitionColor=this.transitionColor||this.lineColor,this.classText=this.primaryTextColor,this.fillType0=this.primaryColor,this.fillType1=this.secondaryColor,this.fillType2=Ce(this.primaryColor,{h:64}),this.fillType3=Ce(this.secondaryColor,{h:64}),this.fillType4=Ce(this.primaryColor,{h:-64}),this.fillType5=Ce(this.secondaryColor,{h:-64}),this.fillType6=Ce(this.primaryColor,{h:128}),this.fillType7=Ce(this.secondaryColor,{h:128}),this.pie1=this.pie1||this.primaryColor,this.pie2=this.pie2||this.secondaryColor,this.pie3=this.pie3||Ce(this.tertiaryColor,{l:-40}),this.pie4=this.pie4||Ce(this.primaryColor,{l:-10}),this.pie5=this.pie5||Ce(this.secondaryColor,{l:-30}),this.pie6=this.pie6||Ce(this.tertiaryColor,{l:-20}),this.pie7=this.pie7||Ce(this.primaryColor,{h:60,l:-20}),this.pie8=this.pie8||Ce(this.primaryColor,{h:-60,l:-40}),this.pie9=this.pie9||Ce(this.primaryColor,{h:120,l:-40}),this.pie10=this.pie10||Ce(this.primaryColor,{h:60,l:-40}),this.pie11=this.pie11||Ce(this.primaryColor,{h:-90,l:-40}),this.pie12=this.pie12||Ce(this.primaryColor,{h:120,l:-30}),this.pieTitleTextSize=this.pieTitleTextSize||"25px",this.pieTitleTextColor=this.pieTitleTextColor||this.taskTextDarkColor,this.pieSectionTextSize=this.pieSectionTextSize||"17px",this.pieSectionTextColor=this.pieSectionTextColor||this.textColor,this.pieLegendTextSize=this.pieLegendTextSize||"17px",this.pieLegendTextColor=this.pieLegendTextColor||this.taskTextDarkColor,this.pieStrokeColor=this.pieStrokeColor||"black",this.pieStrokeWidth=this.pieStrokeWidth||"2px",this.pieOuterStrokeWidth=this.pieOuterStrokeWidth||"2px",this.pieOuterStrokeColor=this.pieOuterStrokeColor||"black",this.pieOpacity=this.pieOpacity||"0.7",this.quadrant1Fill=this.quadrant1Fill||this.primaryColor,this.quadrant2Fill=this.quadrant2Fill||Ce(this.primaryColor,{r:5,g:5,b:5}),this.quadrant3Fill=this.quadrant3Fill||Ce(this.primaryColor,{r:10,g:10,b:10}),this.quadrant4Fill=this.quadrant4Fill||Ce(this.primaryColor,{r:15,g:15,b:15}),this.quadrant1TextFill=this.quadrant1TextFill||this.primaryTextColor,this.quadrant2TextFill=this.quadrant2TextFill||Ce(this.primaryTextColor,{r:-5,g:-5,b:-5}),this.quadrant3TextFill=this.quadrant3TextFill||Ce(this.primaryTextColor,{r:-10,g:-10,b:-10}),this.quadrant4TextFill=this.quadrant4TextFill||Ce(this.primaryTextColor,{r:-15,g:-15,b:-15}),this.quadrantPointFill=this.quadrantPointFill||_h(this.quadrant1Fill)?_t(this.quadrant1Fill):Ot(this.quadrant1Fill),this.quadrantPointTextFill=this.quadrantPointTextFill||this.primaryTextColor,this.quadrantXAxisTextFill=this.quadrantXAxisTextFill||this.primaryTextColor,this.quadrantYAxisTextFill=this.quadrantYAxisTextFill||this.primaryTextColor,this.quadrantInternalBorderStrokeFill=this.quadrantInternalBorderStrokeFill||this.primaryBorderColor,this.quadrantExternalBorderStrokeFill=this.quadrantExternalBorderStrokeFill||this.primaryBorderColor,this.quadrantTitleFill=this.quadrantTitleFill||this.primaryTextColor,this.xyChart={backgroundColor:((e=this.xyChart)==null?void 0:e.backgroundColor)||this.background,titleColor:((t=this.xyChart)==null?void 0:t.titleColor)||this.primaryTextColor,xAxisTitleColor:((r=this.xyChart)==null?void 0:r.xAxisTitleColor)||this.primaryTextColor,xAxisLabelColor:((n=this.xyChart)==null?void 0:n.xAxisLabelColor)||this.primaryTextColor,xAxisTickColor:((a=this.xyChart)==null?void 0:a.xAxisTickColor)||this.primaryTextColor,xAxisLineColor:((i=this.xyChart)==null?void 0:i.xAxisLineColor)||this.primaryTextColor,yAxisTitleColor:((o=this.xyChart)==null?void 0:o.yAxisTitleColor)||this.primaryTextColor,yAxisLabelColor:((s=this.xyChart)==null?void 0:s.yAxisLabelColor)||this.primaryTextColor,yAxisTickColor:((l=this.xyChart)==null?void 0:l.yAxisTickColor)||this.primaryTextColor,yAxisLineColor:((u=this.xyChart)==null?void 0:u.yAxisLineColor)||this.primaryTextColor,plotColorPalette:((c=this.xyChart)==null?void 0:c.plotColorPalette)||"#ECECFF,#8493A6,#FFC3A0,#DCDDE1,#B8E994,#D1A36F,#C3CDE6,#FFB6C1,#496078,#F8F3E3"},this.requirementBackground=this.requirementBackground||this.primaryColor,this.requirementBorderColor=this.requirementBorderColor||this.primaryBorderColor,this.requirementBorderSize=this.requirementBorderSize||"1",this.requirementTextColor=this.requirementTextColor||this.primaryTextColor,this.relationColor=this.relationColor||this.lineColor,this.relationLabelBackground=this.relationLabelBackground||this.labelBackground,this.relationLabelColor=this.relationLabelColor||this.actorTextColor,this.git0=this.git0||this.primaryColor,this.git1=this.git1||this.secondaryColor,this.git2=this.git2||this.tertiaryColor,this.git3=this.git3||Ce(this.primaryColor,{h:-30}),this.git4=this.git4||Ce(this.primaryColor,{h:-60}),this.git5=this.git5||Ce(this.primaryColor,{h:-90}),this.git6=this.git6||Ce(this.primaryColor,{h:60}),this.git7=this.git7||Ce(this.primaryColor,{h:120}),this.darkMode?(this.git0=_t(this.git0,25),this.git1=_t(this.git1,25),this.git2=_t(this.git2,25),this.git3=_t(this.git3,25),this.git4=_t(this.git4,25),this.git5=_t(this.git5,25),this.git6=_t(this.git6,25),this.git7=_t(this.git7,25)):(this.git0=Ot(this.git0,25),this.git1=Ot(this.git1,25),this.git2=Ot(this.git2,25),this.git3=Ot(this.git3,25),this.git4=Ot(this.git4,25),this.git5=Ot(this.git5,25),this.git6=Ot(this.git6,25),this.git7=Ot(this.git7,25)),this.gitInv0=this.gitInv0||Ot(ct(this.git0),25),this.gitInv1=this.gitInv1||ct(this.git1),this.gitInv2=this.gitInv2||ct(this.git2),this.gitInv3=this.gitInv3||ct(this.git3),this.gitInv4=this.gitInv4||ct(this.git4),this.gitInv5=this.gitInv5||ct(this.git5),this.gitInv6=this.gitInv6||ct(this.git6),this.gitInv7=this.gitInv7||ct(this.git7),this.gitBranchLabel0=this.gitBranchLabel0||ct(this.labelTextColor),this.gitBranchLabel1=this.gitBranchLabel1||this.labelTextColor,this.gitBranchLabel2=this.gitBranchLabel2||this.labelTextColor,this.gitBranchLabel3=this.gitBranchLabel3||ct(this.labelTextColor),this.gitBranchLabel4=this.gitBranchLabel4||this.labelTextColor,this.gitBranchLabel5=this.gitBranchLabel5||this.labelTextColor,this.gitBranchLabel6=this.gitBranchLabel6||this.labelTextColor,this.gitBranchLabel7=this.gitBranchLabel7||this.labelTextColor,this.tagLabelColor=this.tagLabelColor||this.primaryTextColor,this.tagLabelBackground=this.tagLabelBackground||this.primaryColor,this.tagLabelBorder=this.tagBorder||this.primaryBorderColor,this.tagLabelFontSize=this.tagLabelFontSize||"10px",this.commitLabelColor=this.commitLabelColor||this.secondaryTextColor,this.commitLabelBackground=this.commitLabelBackground||this.secondaryColor,this.commitLabelFontSize=this.commitLabelFontSize||"10px",this.attributeBackgroundColorOdd=this.attributeBackgroundColorOdd||Mb,this.attributeBackgroundColorEven=this.attributeBackgroundColorEven||Lb}calculate(e){if(typeof e!="object"){this.updateColors();return}const t=Object.keys(e);t.forEach(r=>{this[r]=e[r]}),this.updateColors(),t.forEach(r=>{this[r]=e[r]})}};const c_e=e=>{const t=new u_e;return t.calculate(e),t};let d_e=class{constructor(){this.background="#f4f4f4",this.primaryColor="#cde498",this.secondaryColor="#cdffb2",this.background="white",this.mainBkg="#cde498",this.secondBkg="#cdffb2",this.lineColor="green",this.border1="#13540c",this.border2="#6eaa49",this.arrowheadColor="green",this.fontFamily='"trebuchet ms", verdana, arial, sans-serif',this.fontSize="16px",this.tertiaryColor=_t("#cde498",10),this.primaryBorderColor=Ta(this.primaryColor,this.darkMode),this.secondaryBorderColor=Ta(this.secondaryColor,this.darkMode),this.tertiaryBorderColor=Ta(this.tertiaryColor,this.darkMode),this.primaryTextColor=ct(this.primaryColor),this.secondaryTextColor=ct(this.secondaryColor),this.tertiaryTextColor=ct(this.primaryColor),this.lineColor=ct(this.background),this.textColor=ct(this.background),this.THEME_COLOR_LIMIT=12,this.nodeBkg="calculated",this.nodeBorder="calculated",this.clusterBkg="calculated",this.clusterBorder="calculated",this.defaultLinkColor="calculated",this.titleColor="#333",this.edgeLabelBackground="#e8e8e8",this.actorBorder="calculated",this.actorBkg="calculated",this.actorTextColor="black",this.actorLineColor="grey",this.signalColor="#333",this.signalTextColor="#333",this.labelBoxBkgColor="calculated",this.labelBoxBorderColor="#326932",this.labelTextColor="calculated",this.loopTextColor="calculated",this.noteBorderColor="calculated",this.noteBkgColor="#fff5ad",this.noteTextColor="calculated",this.activationBorderColor="#666",this.activationBkgColor="#f4f4f4",this.sequenceNumberColor="white",this.sectionBkgColor="#6eaa49",this.altSectionBkgColor="white",this.sectionBkgColor2="#6eaa49",this.excludeBkgColor="#eeeeee",this.taskBorderColor="calculated",this.taskBkgColor="#487e3a",this.taskTextLightColor="white",this.taskTextColor="calculated",this.taskTextDarkColor="black",this.taskTextOutsideColor="calculated",this.taskTextClickableColor="#003163",this.activeTaskBorderColor="calculated",this.activeTaskBkgColor="calculated",this.gridColor="lightgrey",this.doneTaskBkgColor="lightgrey",this.doneTaskBorderColor="grey",this.critBorderColor="#ff8888",this.critBkgColor="red",this.todayLineColor="red",this.personBorder=this.primaryBorderColor,this.personBkg=this.mainBkg,this.labelColor="black",this.errorBkgColor="#552222",this.errorTextColor="#552222"}updateColors(){var e,t,r,n,a,i,o,s,l,u,c;this.actorBorder=Ot(this.mainBkg,20),this.actorBkg=this.mainBkg,this.labelBoxBkgColor=this.actorBkg,this.labelTextColor=this.actorTextColor,this.loopTextColor=this.actorTextColor,this.noteBorderColor=this.border2,this.noteTextColor=this.actorTextColor,this.cScale0=this.cScale0||this.primaryColor,this.cScale1=this.cScale1||this.secondaryColor,this.cScale2=this.cScale2||this.tertiaryColor,this.cScale3=this.cScale3||Ce(this.primaryColor,{h:30}),this.cScale4=this.cScale4||Ce(this.primaryColor,{h:60}),this.cScale5=this.cScale5||Ce(this.primaryColor,{h:90}),this.cScale6=this.cScale6||Ce(this.primaryColor,{h:120}),this.cScale7=this.cScale7||Ce(this.primaryColor,{h:150}),this.cScale8=this.cScale8||Ce(this.primaryColor,{h:210}),this.cScale9=this.cScale9||Ce(this.primaryColor,{h:270}),this.cScale10=this.cScale10||Ce(this.primaryColor,{h:300}),this.cScale11=this.cScale11||Ce(this.primaryColor,{h:330}),this.cScalePeer1=this.cScalePeer1||Ot(this.secondaryColor,45),this.cScalePeer2=this.cScalePeer2||Ot(this.tertiaryColor,40);for(let d=0;d<this.THEME_COLOR_LIMIT;d++)this["cScale"+d]=Ot(this["cScale"+d],10),this["cScalePeer"+d]=this["cScalePeer"+d]||Ot(this["cScale"+d],25);for(let d=0;d<this.THEME_COLOR_LIMIT;d++)this["cScaleInv"+d]=this["cScaleInv"+d]||Ce(this["cScale"+d],{h:180});this.scaleLabelColor=this.scaleLabelColor!=="calculated"&&this.scaleLabelColor?this.scaleLabelColor:this.labelTextColor;for(let d=0;d<this.THEME_COLOR_LIMIT;d++)this["cScaleLabel"+d]=this["cScaleLabel"+d]||this.scaleLabelColor;for(let d=0;d<5;d++)this["surface"+d]=this["surface"+d]||Ce(this.mainBkg,{h:30,s:-30,l:-(5+d*5)}),this["surfacePeer"+d]=this["surfacePeer"+d]||Ce(this.mainBkg,{h:30,s:-30,l:-(8+d*5)});this.nodeBkg=this.mainBkg,this.nodeBorder=this.border1,this.clusterBkg=this.secondBkg,this.clusterBorder=this.border2,this.defaultLinkColor=this.lineColor,this.taskBorderColor=this.border1,this.taskTextColor=this.taskTextLightColor,this.taskTextOutsideColor=this.taskTextDarkColor,this.activeTaskBorderColor=this.taskBorderColor,this.activeTaskBkgColor=this.mainBkg,this.transitionColor=this.transitionColor||this.lineColor,this.transitionLabelColor=this.transitionLabelColor||this.textColor,this.stateLabelColor=this.stateLabelColor||this.stateBkg||this.primaryTextColor,this.stateBkg=this.stateBkg||this.mainBkg,this.labelBackgroundColor=this.labelBackgroundColor||this.stateBkg,this.compositeBackground=this.compositeBackground||this.background||this.tertiaryColor,this.altBackground=this.altBackground||"#f0f0f0",this.compositeTitleBackground=this.compositeTitleBackground||this.mainBkg,this.compositeBorder=this.compositeBorder||this.nodeBorder,this.innerEndBackground=this.primaryBorderColor,this.specialStateColor=this.lineColor,this.errorBkgColor=this.errorBkgColor||this.tertiaryColor,this.errorTextColor=this.errorTextColor||this.tertiaryTextColor,this.transitionColor=this.transitionColor||this.lineColor,this.classText=this.primaryTextColor,this.fillType0=this.primaryColor,this.fillType1=this.secondaryColor,this.fillType2=Ce(this.primaryColor,{h:64}),this.fillType3=Ce(this.secondaryColor,{h:64}),this.fillType4=Ce(this.primaryColor,{h:-64}),this.fillType5=Ce(this.secondaryColor,{h:-64}),this.fillType6=Ce(this.primaryColor,{h:128}),this.fillType7=Ce(this.secondaryColor,{h:128}),this.pie1=this.pie1||this.primaryColor,this.pie2=this.pie2||this.secondaryColor,this.pie3=this.pie3||this.tertiaryColor,this.pie4=this.pie4||Ce(this.primaryColor,{l:-30}),this.pie5=this.pie5||Ce(this.secondaryColor,{l:-30}),this.pie6=this.pie6||Ce(this.tertiaryColor,{h:40,l:-40}),this.pie7=this.pie7||Ce(this.primaryColor,{h:60,l:-10}),this.pie8=this.pie8||Ce(this.primaryColor,{h:-60,l:-10}),this.pie9=this.pie9||Ce(this.primaryColor,{h:120,l:0}),this.pie10=this.pie10||Ce(this.primaryColor,{h:60,l:-50}),this.pie11=this.pie11||Ce(this.primaryColor,{h:-60,l:-50}),this.pie12=this.pie12||Ce(this.primaryColor,{h:120,l:-50}),this.pieTitleTextSize=this.pieTitleTextSize||"25px",this.pieTitleTextColor=this.pieTitleTextColor||this.taskTextDarkColor,this.pieSectionTextSize=this.pieSectionTextSize||"17px",this.pieSectionTextColor=this.pieSectionTextColor||this.textColor,this.pieLegendTextSize=this.pieLegendTextSize||"17px",this.pieLegendTextColor=this.pieLegendTextColor||this.taskTextDarkColor,this.pieStrokeColor=this.pieStrokeColor||"black",this.pieStrokeWidth=this.pieStrokeWidth||"2px",this.pieOuterStrokeWidth=this.pieOuterStrokeWidth||"2px",this.pieOuterStrokeColor=this.pieOuterStrokeColor||"black",this.pieOpacity=this.pieOpacity||"0.7",this.quadrant1Fill=this.quadrant1Fill||this.primaryColor,this.quadrant2Fill=this.quadrant2Fill||Ce(this.primaryColor,{r:5,g:5,b:5}),this.quadrant3Fill=this.quadrant3Fill||Ce(this.primaryColor,{r:10,g:10,b:10}),this.quadrant4Fill=this.quadrant4Fill||Ce(this.primaryColor,{r:15,g:15,b:15}),this.quadrant1TextFill=this.quadrant1TextFill||this.primaryTextColor,this.quadrant2TextFill=this.quadrant2TextFill||Ce(this.primaryTextColor,{r:-5,g:-5,b:-5}),this.quadrant3TextFill=this.quadrant3TextFill||Ce(this.primaryTextColor,{r:-10,g:-10,b:-10}),this.quadrant4TextFill=this.quadrant4TextFill||Ce(this.primaryTextColor,{r:-15,g:-15,b:-15}),this.quadrantPointFill=this.quadrantPointFill||_h(this.quadrant1Fill)?_t(this.quadrant1Fill):Ot(this.quadrant1Fill),this.quadrantPointTextFill=this.quadrantPointTextFill||this.primaryTextColor,this.quadrantXAxisTextFill=this.quadrantXAxisTextFill||this.primaryTextColor,this.quadrantYAxisTextFill=this.quadrantYAxisTextFill||this.primaryTextColor,this.quadrantInternalBorderStrokeFill=this.quadrantInternalBorderStrokeFill||this.primaryBorderColor,this.quadrantExternalBorderStrokeFill=this.quadrantExternalBorderStrokeFill||this.primaryBorderColor,this.quadrantTitleFill=this.quadrantTitleFill||this.primaryTextColor,this.xyChart={backgroundColor:((e=this.xyChart)==null?void 0:e.backgroundColor)||this.background,titleColor:((t=this.xyChart)==null?void 0:t.titleColor)||this.primaryTextColor,xAxisTitleColor:((r=this.xyChart)==null?void 0:r.xAxisTitleColor)||this.primaryTextColor,xAxisLabelColor:((n=this.xyChart)==null?void 0:n.xAxisLabelColor)||this.primaryTextColor,xAxisTickColor:((a=this.xyChart)==null?void 0:a.xAxisTickColor)||this.primaryTextColor,xAxisLineColor:((i=this.xyChart)==null?void 0:i.xAxisLineColor)||this.primaryTextColor,yAxisTitleColor:((o=this.xyChart)==null?void 0:o.yAxisTitleColor)||this.primaryTextColor,yAxisLabelColor:((s=this.xyChart)==null?void 0:s.yAxisLabelColor)||this.primaryTextColor,yAxisTickColor:((l=this.xyChart)==null?void 0:l.yAxisTickColor)||this.primaryTextColor,yAxisLineColor:((u=this.xyChart)==null?void 0:u.yAxisLineColor)||this.primaryTextColor,plotColorPalette:((c=this.xyChart)==null?void 0:c.plotColorPalette)||"#CDE498,#FF6B6B,#A0D2DB,#D7BDE2,#F0F0F0,#FFC3A0,#7FD8BE,#FF9A8B,#FAF3E0,#FFF176"},this.requirementBackground=this.requirementBackground||this.primaryColor,this.requirementBorderColor=this.requirementBorderColor||this.primaryBorderColor,this.requirementBorderSize=this.requirementBorderSize||"1",this.requirementTextColor=this.requirementTextColor||this.primaryTextColor,this.relationColor=this.relationColor||this.lineColor,this.relationLabelBackground=this.relationLabelBackground||this.edgeLabelBackground,this.relationLabelColor=this.relationLabelColor||this.actorTextColor,this.git0=this.git0||this.primaryColor,this.git1=this.git1||this.secondaryColor,this.git2=this.git2||this.tertiaryColor,this.git3=this.git3||Ce(this.primaryColor,{h:-30}),this.git4=this.git4||Ce(this.primaryColor,{h:-60}),this.git5=this.git5||Ce(this.primaryColor,{h:-90}),this.git6=this.git6||Ce(this.primaryColor,{h:60}),this.git7=this.git7||Ce(this.primaryColor,{h:120}),this.darkMode?(this.git0=_t(this.git0,25),this.git1=_t(this.git1,25),this.git2=_t(this.git2,25),this.git3=_t(this.git3,25),this.git4=_t(this.git4,25),this.git5=_t(this.git5,25),this.git6=_t(this.git6,25),this.git7=_t(this.git7,25)):(this.git0=Ot(this.git0,25),this.git1=Ot(this.git1,25),this.git2=Ot(this.git2,25),this.git3=Ot(this.git3,25),this.git4=Ot(this.git4,25),this.git5=Ot(this.git5,25),this.git6=Ot(this.git6,25),this.git7=Ot(this.git7,25)),this.gitInv0=this.gitInv0||ct(this.git0),this.gitInv1=this.gitInv1||ct(this.git1),this.gitInv2=this.gitInv2||ct(this.git2),this.gitInv3=this.gitInv3||ct(this.git3),this.gitInv4=this.gitInv4||ct(this.git4),this.gitInv5=this.gitInv5||ct(this.git5),this.gitInv6=this.gitInv6||ct(this.git6),this.gitInv7=this.gitInv7||ct(this.git7),this.gitBranchLabel0=this.gitBranchLabel0||ct(this.labelTextColor),this.gitBranchLabel1=this.gitBranchLabel1||this.labelTextColor,this.gitBranchLabel2=this.gitBranchLabel2||this.labelTextColor,this.gitBranchLabel3=this.gitBranchLabel3||ct(this.labelTextColor),this.gitBranchLabel4=this.gitBranchLabel4||this.labelTextColor,this.gitBranchLabel5=this.gitBranchLabel5||this.labelTextColor,this.gitBranchLabel6=this.gitBranchLabel6||this.labelTextColor,this.gitBranchLabel7=this.gitBranchLabel7||this.labelTextColor,this.tagLabelColor=this.tagLabelColor||this.primaryTextColor,this.tagLabelBackground=this.tagLabelBackground||this.primaryColor,this.tagLabelBorder=this.tagBorder||this.primaryBorderColor,this.tagLabelFontSize=this.tagLabelFontSize||"10px",this.commitLabelColor=this.commitLabelColor||this.secondaryTextColor,this.commitLabelBackground=this.commitLabelBackground||this.secondaryColor,this.commitLabelFontSize=this.commitLabelFontSize||"10px",this.attributeBackgroundColorOdd=this.attributeBackgroundColorOdd||Mb,this.attributeBackgroundColorEven=this.attributeBackgroundColorEven||Lb}calculate(e){if(typeof e!="object"){this.updateColors();return}const t=Object.keys(e);t.forEach(r=>{this[r]=e[r]}),this.updateColors(),t.forEach(r=>{this[r]=e[r]})}};const p_e=e=>{const t=new d_e;return t.calculate(e),t};class h_e{constructor(){this.primaryColor="#eee",this.contrast="#707070",this.secondaryColor=_t(this.contrast,55),this.background="#ffffff",this.tertiaryColor=Ce(this.primaryColor,{h:-160}),this.primaryBorderColor=Ta(this.primaryColor,this.darkMode),this.secondaryBorderColor=Ta(this.secondaryColor,this.darkMode),this.tertiaryBorderColor=Ta(this.tertiaryColor,this.darkMode),this.primaryTextColor=ct(this.primaryColor),this.secondaryTextColor=ct(this.secondaryColor),this.tertiaryTextColor=ct(this.tertiaryColor),this.lineColor=ct(this.background),this.textColor=ct(this.background),this.mainBkg="#eee",this.secondBkg="calculated",this.lineColor="#666",this.border1="#999",this.border2="calculated",this.note="#ffa",this.text="#333",this.critical="#d42",this.done="#bbb",this.arrowheadColor="#333333",this.fontFamily='"trebuchet ms", verdana, arial, sans-serif',this.fontSize="16px",this.THEME_COLOR_LIMIT=12,this.nodeBkg="calculated",this.nodeBorder="calculated",this.clusterBkg="calculated",this.clusterBorder="calculated",this.defaultLinkColor="calculated",this.titleColor="calculated",this.edgeLabelBackground="white",this.actorBorder="calculated",this.actorBkg="calculated",this.actorTextColor="calculated",this.actorLineColor="calculated",this.signalColor="calculated",this.signalTextColor="calculated",this.labelBoxBkgColor="calculated",this.labelBoxBorderColor="calculated",this.labelTextColor="calculated",this.loopTextColor="calculated",this.noteBorderColor="calculated",this.noteBkgColor="calculated",this.noteTextColor="calculated",this.activationBorderColor="#666",this.activationBkgColor="#f4f4f4",this.sequenceNumberColor="white",this.sectionBkgColor="calculated",this.altSectionBkgColor="white",this.sectionBkgColor2="calculated",this.excludeBkgColor="#eeeeee",this.taskBorderColor="calculated",this.taskBkgColor="calculated",this.taskTextLightColor="white",this.taskTextColor="calculated",this.taskTextDarkColor="calculated",this.taskTextOutsideColor="calculated",this.taskTextClickableColor="#003163",this.activeTaskBorderColor="calculated",this.activeTaskBkgColor="calculated",this.gridColor="calculated",this.doneTaskBkgColor="calculated",this.doneTaskBorderColor="calculated",this.critBkgColor="calculated",this.critBorderColor="calculated",this.todayLineColor="calculated",this.personBorder=this.primaryBorderColor,this.personBkg=this.mainBkg,this.labelColor="black",this.errorBkgColor="#552222",this.errorTextColor="#552222"}updateColors(){var t,r,n,a,i,o,s,l,u,c,d;this.secondBkg=_t(this.contrast,55),this.border2=this.contrast,this.actorBorder=_t(this.border1,23),this.actorBkg=this.mainBkg,this.actorTextColor=this.text,this.actorLineColor=this.lineColor,this.signalColor=this.text,this.signalTextColor=this.text,this.labelBoxBkgColor=this.actorBkg,this.labelBoxBorderColor=this.actorBorder,this.labelTextColor=this.text,this.loopTextColor=this.text,this.noteBorderColor="#999",this.noteBkgColor="#666",this.noteTextColor="#fff",this.cScale0=this.cScale0||"#555",this.cScale1=this.cScale1||"#F4F4F4",this.cScale2=this.cScale2||"#555",this.cScale3=this.cScale3||"#BBB",this.cScale4=this.cScale4||"#777",this.cScale5=this.cScale5||"#999",this.cScale6=this.cScale6||"#DDD",this.cScale7=this.cScale7||"#FFF",this.cScale8=this.cScale8||"#DDD",this.cScale9=this.cScale9||"#BBB",this.cScale10=this.cScale10||"#999",this.cScale11=this.cScale11||"#777";for(let p=0;p<this.THEME_COLOR_LIMIT;p++)this["cScaleInv"+p]=this["cScaleInv"+p]||ct(this["cScale"+p]);for(let p=0;p<this.THEME_COLOR_LIMIT;p++)this.darkMode?this["cScalePeer"+p]=this["cScalePeer"+p]||_t(this["cScale"+p],10):this["cScalePeer"+p]=this["cScalePeer"+p]||Ot(this["cScale"+p],10);this.scaleLabelColor=this.scaleLabelColor||(this.darkMode?"black":this.labelTextColor),this.cScaleLabel0=this.cScaleLabel0||this.cScale1,this.cScaleLabel2=this.cScaleLabel2||this.cScale1;for(let p=0;p<this.THEME_COLOR_LIMIT;p++)this["cScaleLabel"+p]=this["cScaleLabel"+p]||this.scaleLabelColor;for(let p=0;p<5;p++)this["surface"+p]=this["surface"+p]||Ce(this.mainBkg,{l:-(5+p*5)}),this["surfacePeer"+p]=this["surfacePeer"+p]||Ce(this.mainBkg,{l:-(8+p*5)});this.nodeBkg=this.mainBkg,this.nodeBorder=this.border1,this.clusterBkg=this.secondBkg,this.clusterBorder=this.border2,this.defaultLinkColor=this.lineColor,this.titleColor=this.text,this.sectionBkgColor=_t(this.contrast,30),this.sectionBkgColor2=_t(this.contrast,30),this.taskBorderColor=Ot(this.contrast,10),this.taskBkgColor=this.contrast,this.taskTextColor=this.taskTextLightColor,this.taskTextDarkColor=this.text,this.taskTextOutsideColor=this.taskTextDarkColor,this.activeTaskBorderColor=this.taskBorderColor,this.activeTaskBkgColor=this.mainBkg,this.gridColor=_t(this.border1,30),this.doneTaskBkgColor=this.done,this.doneTaskBorderColor=this.lineColor,this.critBkgColor=this.critical,this.critBorderColor=Ot(this.critBkgColor,10),this.todayLineColor=this.critBkgColor,this.transitionColor=this.transitionColor||"#000",this.transitionLabelColor=this.transitionLabelColor||this.textColor,this.stateLabelColor=this.stateLabelColor||this.stateBkg||this.primaryTextColor,this.stateBkg=this.stateBkg||this.mainBkg,this.labelBackgroundColor=this.labelBackgroundColor||this.stateBkg,this.compositeBackground=this.compositeBackground||this.background||this.tertiaryColor,this.altBackground=this.altBackground||"#f4f4f4",this.compositeTitleBackground=this.compositeTitleBackground||this.mainBkg,this.stateBorder=this.stateBorder||"#000",this.innerEndBackground=this.primaryBorderColor,this.specialStateColor="#222",this.errorBkgColor=this.errorBkgColor||this.tertiaryColor,this.errorTextColor=this.errorTextColor||this.tertiaryTextColor,this.classText=this.primaryTextColor,this.fillType0=this.primaryColor,this.fillType1=this.secondaryColor,this.fillType2=Ce(this.primaryColor,{h:64}),this.fillType3=Ce(this.secondaryColor,{h:64}),this.fillType4=Ce(this.primaryColor,{h:-64}),this.fillType5=Ce(this.secondaryColor,{h:-64}),this.fillType6=Ce(this.primaryColor,{h:128}),this.fillType7=Ce(this.secondaryColor,{h:128});for(let p=0;p<this.THEME_COLOR_LIMIT;p++)this["pie"+p]=this["cScale"+p];this.pie12=this.pie0,this.pieTitleTextSize=this.pieTitleTextSize||"25px",this.pieTitleTextColor=this.pieTitleTextColor||this.taskTextDarkColor,this.pieSectionTextSize=this.pieSectionTextSize||"17px",this.pieSectionTextColor=this.pieSectionTextColor||this.textColor,this.pieLegendTextSize=this.pieLegendTextSize||"17px",this.pieLegendTextColor=this.pieLegendTextColor||this.taskTextDarkColor,this.pieStrokeColor=this.pieStrokeColor||"black",this.pieStrokeWidth=this.pieStrokeWidth||"2px",this.pieOuterStrokeWidth=this.pieOuterStrokeWidth||"2px",this.pieOuterStrokeColor=this.pieOuterStrokeColor||"black",this.pieOpacity=this.pieOpacity||"0.7",this.quadrant1Fill=this.quadrant1Fill||this.primaryColor,this.quadrant2Fill=this.quadrant2Fill||Ce(this.primaryColor,{r:5,g:5,b:5}),this.quadrant3Fill=this.quadrant3Fill||Ce(this.primaryColor,{r:10,g:10,b:10}),this.quadrant4Fill=this.quadrant4Fill||Ce(this.primaryColor,{r:15,g:15,b:15}),this.quadrant1TextFill=this.quadrant1TextFill||this.primaryTextColor,this.quadrant2TextFill=this.quadrant2TextFill||Ce(this.primaryTextColor,{r:-5,g:-5,b:-5}),this.quadrant3TextFill=this.quadrant3TextFill||Ce(this.primaryTextColor,{r:-10,g:-10,b:-10}),this.quadrant4TextFill=this.quadrant4TextFill||Ce(this.primaryTextColor,{r:-15,g:-15,b:-15}),this.quadrantPointFill=this.quadrantPointFill||_h(this.quadrant1Fill)?_t(this.quadrant1Fill):Ot(this.quadrant1Fill),this.quadrantPointTextFill=this.quadrantPointTextFill||this.primaryTextColor,this.quadrantXAxisTextFill=this.quadrantXAxisTextFill||this.primaryTextColor,this.quadrantYAxisTextFill=this.quadrantYAxisTextFill||this.primaryTextColor,this.quadrantInternalBorderStrokeFill=this.quadrantInternalBorderStrokeFill||this.primaryBorderColor,this.quadrantExternalBorderStrokeFill=this.quadrantExternalBorderStrokeFill||this.primaryBorderColor,this.quadrantTitleFill=this.quadrantTitleFill||this.primaryTextColor,this.xyChart={backgroundColor:((t=this.xyChart)==null?void 0:t.backgroundColor)||this.background,titleColor:((r=this.xyChart)==null?void 0:r.titleColor)||this.primaryTextColor,xAxisTitleColor:((n=this.xyChart)==null?void 0:n.xAxisTitleColor)||this.primaryTextColor,xAxisLabelColor:((a=this.xyChart)==null?void 0:a.xAxisLabelColor)||this.primaryTextColor,xAxisTickColor:((i=this.xyChart)==null?void 0:i.xAxisTickColor)||this.primaryTextColor,xAxisLineColor:((o=this.xyChart)==null?void 0:o.xAxisLineColor)||this.primaryTextColor,yAxisTitleColor:((s=this.xyChart)==null?void 0:s.yAxisTitleColor)||this.primaryTextColor,yAxisLabelColor:((l=this.xyChart)==null?void 0:l.yAxisLabelColor)||this.primaryTextColor,yAxisTickColor:((u=this.xyChart)==null?void 0:u.yAxisTickColor)||this.primaryTextColor,yAxisLineColor:((c=this.xyChart)==null?void 0:c.yAxisLineColor)||this.primaryTextColor,plotColorPalette:((d=this.xyChart)==null?void 0:d.plotColorPalette)||"#EEE,#6BB8E4,#8ACB88,#C7ACD6,#E8DCC2,#FFB2A8,#FFF380,#7E8D91,#FFD8B1,#FAF3E0"},this.requirementBackground=this.requirementBackground||this.primaryColor,this.requirementBorderColor=this.requirementBorderColor||this.primaryBorderColor,this.requirementBorderSize=this.requirementBorderSize||"1",this.requirementTextColor=this.requirementTextColor||this.primaryTextColor,this.relationColor=this.relationColor||this.lineColor,this.relationLabelBackground=this.relationLabelBackground||this.edgeLabelBackground,this.relationLabelColor=this.relationLabelColor||this.actorTextColor,this.git0=Ot(this.pie1,25)||this.primaryColor,this.git1=this.pie2||this.secondaryColor,this.git2=this.pie3||this.tertiaryColor,this.git3=this.pie4||Ce(this.primaryColor,{h:-30}),this.git4=this.pie5||Ce(this.primaryColor,{h:-60}),this.git5=this.pie6||Ce(this.primaryColor,{h:-90}),this.git6=this.pie7||Ce(this.primaryColor,{h:60}),this.git7=this.pie8||Ce(this.primaryColor,{h:120}),this.gitInv0=this.gitInv0||ct(this.git0),this.gitInv1=this.gitInv1||ct(this.git1),this.gitInv2=this.gitInv2||ct(this.git2),this.gitInv3=this.gitInv3||ct(this.git3),this.gitInv4=this.gitInv4||ct(this.git4),this.gitInv5=this.gitInv5||ct(this.git5),this.gitInv6=this.gitInv6||ct(this.git6),this.gitInv7=this.gitInv7||ct(this.git7),this.branchLabelColor=this.branchLabelColor||this.labelTextColor,this.gitBranchLabel0=this.branchLabelColor,this.gitBranchLabel1="white",this.gitBranchLabel2=this.branchLabelColor,this.gitBranchLabel3="white",this.gitBranchLabel4=this.branchLabelColor,this.gitBranchLabel5=this.branchLabelColor,this.gitBranchLabel6=this.branchLabelColor,this.gitBranchLabel7=this.branchLabelColor,this.tagLabelColor=this.tagLabelColor||this.primaryTextColor,this.tagLabelBackground=this.tagLabelBackground||this.primaryColor,this.tagLabelBorder=this.tagBorder||this.primaryBorderColor,this.tagLabelFontSize=this.tagLabelFontSize||"10px",this.commitLabelColor=this.commitLabelColor||this.secondaryTextColor,this.commitLabelBackground=this.commitLabelBackground||this.secondaryColor,this.commitLabelFontSize=this.commitLabelFontSize||"10px",this.attributeBackgroundColorOdd=this.attributeBackgroundColorOdd||Mb,this.attributeBackgroundColorEven=this.attributeBackgroundColorEven||Lb}calculate(t){if(typeof t!="object"){this.updateColors();return}const r=Object.keys(t);r.forEach(n=>{this[n]=t[n]}),this.updateColors(),r.forEach(n=>{this[n]=t[n]})}}const f_e=e=>{const t=new h_e;return t.calculate(e),t},Es={base:{getThemeVariables:o_e},dark:{getThemeVariables:l_e},default:{getThemeVariables:c_e},forest:{getThemeVariables:p_e},neutral:{getThemeVariables:f_e}},os={flowchart:{useMaxWidth:!0,titleTopMargin:25,subGraphTitleMargin:{top:0,bottom:0},diagramPadding:8,htmlLabels:!0,nodeSpacing:50,rankSpacing:50,curve:"basis",padding:15,defaultRenderer:"dagre-wrapper",wrappingWidth:200},sequence:{useMaxWidth:!0,hideUnusedParticipants:!1,activationWidth:10,diagramMarginX:50,diagramMarginY:10,actorMargin:50,width:150,height:65,boxMargin:10,boxTextMargin:5,noteMargin:10,messageMargin:35,messageAlign:"center",mirrorActors:!0,forceMenus:!1,bottomMarginAdj:1,rightAngles:!1,showSequenceNumbers:!1,actorFontSize:14,actorFontFamily:'"Open Sans", sans-serif',actorFontWeight:400,noteFontSize:14,noteFontFamily:'"trebuchet ms", verdana, arial, sans-serif',noteFontWeight:400,noteAlign:"center",messageFontSize:16,messageFontFamily:'"trebuchet ms", verdana, arial, sans-serif',messageFontWeight:400,wrap:!1,wrapPadding:10,labelBoxWidth:50,labelBoxHeight:20},gantt:{useMaxWidth:!0,titleTopMargin:25,barHeight:20,barGap:4,topPadding:50,rightPadding:75,leftPadding:75,gridLineStartPadding:35,fontSize:11,sectionFontSize:11,numberSectionStyles:4,axisFormat:"%Y-%m-%d",topAxis:!1,displayMode:"",weekday:"sunday"},journey:{useMaxWidth:!0,diagramMarginX:50,diagramMarginY:10,leftMargin:150,width:150,height:50,boxMargin:10,boxTextMargin:5,noteMargin:10,messageMargin:35,messageAlign:"center",bottomMarginAdj:1,rightAngles:!1,taskFontSize:14,taskFontFamily:'"Open Sans", sans-serif',taskMargin:50,activationWidth:10,textPlacement:"fo",actorColours:["#8FBC8F","#7CFC00","#00FFFF","#20B2AA","#B0E0E6","#FFFFE0"],sectionFills:["#191970","#8B008B","#4B0082","#2F4F4F","#800000","#8B4513","#00008B"],sectionColours:["#fff"]},class:{useMaxWidth:!0,titleTopMargin:25,arrowMarkerAbsolute:!1,dividerMargin:10,padding:5,textHeight:10,defaultRenderer:"dagre-wrapper",htmlLabels:!1},state:{useMaxWidth:!0,titleTopMargin:25,dividerMargin:10,sizeUnit:5,padding:8,textHeight:10,titleShift:-15,noteMargin:10,forkWidth:70,forkHeight:7,miniPadding:2,fontSizeFactor:5.02,fontSize:24,labelHeight:16,edgeLengthFactor:"20",compositTitleSize:35,radius:5,defaultRenderer:"dagre-wrapper"},er:{useMaxWidth:!0,titleTopMargin:25,diagramPadding:20,layoutDirection:"TB",minEntityWidth:100,minEntityHeight:75,entityPadding:15,stroke:"gray",fill:"honeydew",fontSize:12},pie:{useMaxWidth:!0,textPosition:.75},quadrantChart:{useMaxWidth:!0,chartWidth:500,chartHeight:500,titleFontSize:20,titlePadding:10,quadrantPadding:5,xAxisLabelPadding:5,yAxisLabelPadding:5,xAxisLabelFontSize:16,yAxisLabelFontSize:16,quadrantLabelFontSize:16,quadrantTextTopPadding:5,pointTextPadding:5,pointLabelFontSize:12,pointRadius:5,xAxisPosition:"top",yAxisPosition:"left",quadrantInternalBorderStrokeWidth:1,quadrantExternalBorderStrokeWidth:2},xyChart:{useMaxWidth:!0,width:700,height:500,titleFontSize:20,titlePadding:10,showTitle:!0,xAxis:{$ref:"#/$defs/XYChartAxisConfig",showLabel:!0,labelFontSize:14,labelPadding:5,showTitle:!0,titleFontSize:16,titlePadding:5,showTick:!0,tickLength:5,tickWidth:2,showAxisLine:!0,axisLineWidth:2},yAxis:{$ref:"#/$defs/XYChartAxisConfig",showLabel:!0,labelFontSize:14,labelPadding:5,showTitle:!0,titleFontSize:16,titlePadding:5,showTick:!0,tickLength:5,tickWidth:2,showAxisLine:!0,axisLineWidth:2},chartOrientation:"vertical",plotReservedSpacePercent:50},requirement:{useMaxWidth:!0,rect_fill:"#f9f9f9",text_color:"#333",rect_border_size:"0.5px",rect_border_color:"#bbb",rect_min_width:200,rect_min_height:200,fontSize:14,rect_padding:10,line_height:20},mindmap:{useMaxWidth:!0,padding:10,maxNodeWidth:200},timeline:{useMaxWidth:!0,diagramMarginX:50,diagramMarginY:10,leftMargin:150,width:150,height:50,boxMargin:10,boxTextMargin:5,noteMargin:10,messageMargin:35,messageAlign:"center",bottomMarginAdj:1,rightAngles:!1,taskFontSize:14,taskFontFamily:'"Open Sans", sans-serif',taskMargin:50,activationWidth:10,textPlacement:"fo",actorColours:["#8FBC8F","#7CFC00","#00FFFF","#20B2AA","#B0E0E6","#FFFFE0"],sectionFills:["#191970","#8B008B","#4B0082","#2F4F4F","#800000","#8B4513","#00008B"],sectionColours:["#fff"],disableMulticolor:!1},gitGraph:{useMaxWidth:!0,titleTopMargin:25,diagramPadding:8,nodeLabel:{width:75,height:100,x:-25,y:0},mainBranchName:"main",mainBranchOrder:0,showCommitLabel:!0,showBranches:!0,rotateCommitLabel:!0,parallelCommits:!1,arrowMarkerAbsolute:!1},c4:{useMaxWidth:!0,diagramMarginX:50,diagramMarginY:10,c4ShapeMargin:50,c4ShapePadding:20,width:216,height:60,boxMargin:10,c4ShapeInRow:4,nextLinePaddingX:0,c4BoundaryInRow:2,personFontSize:14,personFontFamily:'"Open Sans", sans-serif',personFontWeight:"normal",external_personFontSize:14,external_personFontFamily:'"Open Sans", sans-serif',external_personFontWeight:"normal",systemFontSize:14,systemFontFamily:'"Open Sans", sans-serif',systemFontWeight:"normal",external_systemFontSize:14,external_systemFontFamily:'"Open Sans", sans-serif',external_systemFontWeight:"normal",system_dbFontSize:14,system_dbFontFamily:'"Open Sans", sans-serif',system_dbFontWeight:"normal",external_system_dbFontSize:14,external_system_dbFontFamily:'"Open Sans", sans-serif',external_system_dbFontWeight:"normal",system_queueFontSize:14,system_queueFontFamily:'"Open Sans", sans-serif',system_queueFontWeight:"normal",external_system_queueFontSize:14,external_system_queueFontFamily:'"Open Sans", sans-serif',external_system_queueFontWeight:"normal",boundaryFontSize:14,boundaryFontFamily:'"Open Sans", sans-serif',boundaryFontWeight:"normal",messageFontSize:12,messageFontFamily:'"Open Sans", sans-serif',messageFontWeight:"normal",containerFontSize:14,containerFontFamily:'"Open Sans", sans-serif',containerFontWeight:"normal",external_containerFontSize:14,external_containerFontFamily:'"Open Sans", sans-serif',external_containerFontWeight:"normal",container_dbFontSize:14,container_dbFontFamily:'"Open Sans", sans-serif',container_dbFontWeight:"normal",external_container_dbFontSize:14,external_container_dbFontFamily:'"Open Sans", sans-serif',external_container_dbFontWeight:"normal",container_queueFontSize:14,container_queueFontFamily:'"Open Sans", sans-serif',container_queueFontWeight:"normal",external_container_queueFontSize:14,external_container_queueFontFamily:'"Open Sans", sans-serif',external_container_queueFontWeight:"normal",componentFontSize:14,componentFontFamily:'"Open Sans", sans-serif',componentFontWeight:"normal",external_componentFontSize:14,external_componentFontFamily:'"Open Sans", sans-serif',external_componentFontWeight:"normal",component_dbFontSize:14,component_dbFontFamily:'"Open Sans", sans-serif',component_dbFontWeight:"normal",external_component_dbFontSize:14,external_component_dbFontFamily:'"Open Sans", sans-serif',external_component_dbFontWeight:"normal",component_queueFontSize:14,component_queueFontFamily:'"Open Sans", sans-serif',component_queueFontWeight:"normal",external_component_queueFontSize:14,external_component_queueFontFamily:'"Open Sans", sans-serif',external_component_queueFontWeight:"normal",wrap:!0,wrapPadding:10,person_bg_color:"#08427B",person_border_color:"#073B6F",external_person_bg_color:"#686868",external_person_border_color:"#8A8A8A",system_bg_color:"#1168BD",system_border_color:"#3C7FC0",system_db_bg_color:"#1168BD",system_db_border_color:"#3C7FC0",system_queue_bg_color:"#1168BD",system_queue_border_color:"#3C7FC0",external_system_bg_color:"#999999",external_system_border_color:"#8A8A8A",external_system_db_bg_color:"#999999",external_system_db_border_color:"#8A8A8A",external_system_queue_bg_color:"#999999",external_system_queue_border_color:"#8A8A8A",container_bg_color:"#438DD5",container_border_color:"#3C7FC0",container_db_bg_color:"#438DD5",container_db_border_color:"#3C7FC0",container_queue_bg_color:"#438DD5",container_queue_border_color:"#3C7FC0",external_container_bg_color:"#B3B3B3",external_container_border_color:"#A6A6A6",external_container_db_bg_color:"#B3B3B3",external_container_db_border_color:"#A6A6A6",external_container_queue_bg_color:"#B3B3B3",external_container_queue_border_color:"#A6A6A6",component_bg_color:"#85BBF0",component_border_color:"#78A8D8",component_db_bg_color:"#85BBF0",component_db_border_color:"#78A8D8",component_queue_bg_color:"#85BBF0",component_queue_border_color:"#78A8D8",external_component_bg_color:"#CCCCCC",external_component_border_color:"#BFBFBF",external_component_db_bg_color:"#CCCCCC",external_component_db_border_color:"#BFBFBF",external_component_queue_bg_color:"#CCCCCC",external_component_queue_border_color:"#BFBFBF"},sankey:{useMaxWidth:!0,width:600,height:400,linkColor:"gradient",nodeAlignment:"justify",showValues:!0,prefix:"",suffix:""},block:{useMaxWidth:!0,padding:8},theme:"default",maxTextSize:5e4,maxEdges:500,darkMode:!1,fontFamily:'"trebuchet ms", verdana, arial, sans-serif;',logLevel:5,securityLevel:"strict",startOnLoad:!0,arrowMarkerAbsolute:!1,secure:["secure","securityLevel","startOnLoad","maxTextSize","maxEdges"],legacyMathML:!1,deterministicIds:!1,fontSize:16},rZ={...os,deterministicIDSeed:void 0,themeCSS:void 0,themeVariables:Es.default.getThemeVariables(),sequence:{...os.sequence,messageFont:function(){return{fontFamily:this.messageFontFamily,fontSize:this.messageFontSize,fontWeight:this.messageFontWeight}},noteFont:function(){return{fontFamily:this.noteFontFamily,fontSize:this.noteFontSize,fontWeight:this.noteFontWeight}},actorFont:function(){return{fontFamily:this.actorFontFamily,fontSize:this.actorFontSize,fontWeight:this.actorFontWeight}}},gantt:{...os.gantt,tickInterval:void 0,useWidth:void 0},c4:{...os.c4,useWidth:void 0,personFont:function(){return{fontFamily:this.personFontFamily,fontSize:this.personFontSize,fontWeight:this.personFontWeight}},external_personFont:function(){return{fontFamily:this.external_personFontFamily,fontSize:this.external_personFontSize,fontWeight:this.external_personFontWeight}},systemFont:function(){return{fontFamily:this.systemFontFamily,fontSize:this.systemFontSize,fontWeight:this.systemFontWeight}},external_systemFont:function(){return{fontFamily:this.external_systemFontFamily,fontSize:this.external_systemFontSize,fontWeight:this.external_systemFontWeight}},system_dbFont:function(){return{fontFamily:this.system_dbFontFamily,fontSize:this.system_dbFontSize,fontWeight:this.system_dbFontWeight}},external_system_dbFont:function(){return{fontFamily:this.external_system_dbFontFamily,fontSize:this.external_system_dbFontSize,fontWeight:this.external_system_dbFontWeight}},system_queueFont:function(){return{fontFamily:this.system_queueFontFamily,fontSize:this.system_queueFontSize,fontWeight:this.system_queueFontWeight}},external_system_queueFont:function(){return{fontFamily:this.external_system_queueFontFamily,fontSize:this.external_system_queueFontSize,fontWeight:this.external_system_queueFontWeight}},containerFont:function(){return{fontFamily:this.containerFontFamily,fontSize:this.containerFontSize,fontWeight:this.containerFontWeight}},external_containerFont:function(){return{fontFamily:this.external_containerFontFamily,fontSize:this.external_containerFontSize,fontWeight:this.external_containerFontWeight}},container_dbFont:function(){return{fontFamily:this.container_dbFontFamily,fontSize:this.container_dbFontSize,fontWeight:this.container_dbFontWeight}},external_container_dbFont:function(){return{fontFamily:this.external_container_dbFontFamily,fontSize:this.external_container_dbFontSize,fontWeight:this.external_container_dbFontWeight}},container_queueFont:function(){return{fontFamily:this.container_queueFontFamily,fontSize:this.container_queueFontSize,fontWeight:this.container_queueFontWeight}},external_container_queueFont:function(){return{fontFamily:this.external_container_queueFontFamily,fontSize:this.external_container_queueFontSize,fontWeight:this.external_container_queueFontWeight}},componentFont:function(){return{fontFamily:this.componentFontFamily,fontSize:this.componentFontSize,fontWeight:this.componentFontWeight}},external_componentFont:function(){return{fontFamily:this.external_componentFontFamily,fontSize:this.external_componentFontSize,fontWeight:this.external_componentFontWeight}},component_dbFont:function(){return{fontFamily:this.component_dbFontFamily,fontSize:this.component_dbFontSize,fontWeight:this.component_dbFontWeight}},external_component_dbFont:function(){return{fontFamily:this.external_component_dbFontFamily,fontSize:this.external_component_dbFontSize,fontWeight:this.external_component_dbFontWeight}},component_queueFont:function(){return{fontFamily:this.component_queueFontFamily,fontSize:this.component_queueFontSize,fontWeight:this.component_queueFontWeight}},external_component_queueFont:function(){return{fontFamily:this.external_component_queueFontFamily,fontSize:this.external_component_queueFontSize,fontWeight:this.external_component_queueFontWeight}},boundaryFont:function(){return{fontFamily:this.boundaryFontFamily,fontSize:this.boundaryFontSize,fontWeight:this.boundaryFontWeight}},messageFont:function(){return{fontFamily:this.messageFontFamily,fontSize:this.messageFontSize,fontWeight:this.messageFontWeight}}},pie:{...os.pie,useWidth:984},xyChart:{...os.xyChart,useWidth:void 0},requirement:{...os.requirement,useWidth:void 0},gitGraph:{...os.gitGraph,useMaxWidth:!1},sankey:{...os.sankey,useMaxWidth:!1}},nZ=(e,t="")=>Object.keys(e).reduce((r,n)=>Array.isArray(e[n])?r:typeof e[n]=="object"&&e[n]!==null?[...r,t+n,...nZ(e[n],"")]:[...r,t+n],[]),m_e=new Set(nZ(rZ,"")),g_e=rZ,$g=e=>{if(It.debug("sanitizeDirective called with",e),!(typeof e!="object"||e==null)){if(Array.isArray(e)){e.forEach(t=>$g(t));return}for(const t of Object.keys(e)){if(It.debug("Checking key",t),t.startsWith("__")||t.includes("proto")||t.includes("constr")||!m_e.has(t)||e[t]==null){It.debug("sanitize deleting key: ",t),delete e[t];continue}if(typeof e[t]=="object"){It.debug("sanitizing object",t),$g(e[t]);continue}const r=["themeCSS","fontFamily","altFontFamily"];for(const n of r)t.includes(n)&&(It.debug("sanitizing css option",t),e[t]=y_e(e[t]))}if(e.themeVariables)for(const t of Object.keys(e.themeVariables)){const r=e.themeVariables[t];r!=null&&r.match&&!r.match(/^[\d "#%(),.;A-Za-z]+$/)&&(e.themeVariables[t]="")}It.debug("After sanitization",e)}},y_e=e=>{let t=0,r=0;for(const n of e){if(t<r)return"{ /* ERROR: Unbalanced CSS */ }";n==="{"?t++:n==="}"&&r++}return t!==r?"{ /* ERROR: Unbalanced CSS */ }":e},aZ=/^-{3}\s*[\n\r](.*?)[\n\r]-{3}\s*[\n\r]+/s,dp=/%{2}{\s*(?:(\w+)\s*:|(\w+))\s*(?:(\w+)|((?:(?!}%{2}).|\r?\n)*))?\s*(?:}%{2})?/gi,b_e=/\s*%%.*\n/gm;class iZ extends Error{constructor(t){super(t),this.name="UnknownDiagramError"}}const E0={},Pb=function(e,t){e=e.replace(aZ,"").replace(dp,"").replace(b_e,`
844
844
  `);for(const[r,{detector:n}]of Object.entries(E0))if(n(e,t))return r;throw new iZ(`No diagram type detected matching given configuration for text: ${e}`)},oZ=(...e)=>{for(const{id:t,detector:r,loader:n}of e)sZ(t,r,n)},sZ=(e,t,r)=>{E0[e]?It.error(`Detector with key ${e} already exists`):E0[e]={detector:t,loader:r},It.debug(`Detector with key ${e} added${r?" with loader":""}`)},v_e=e=>E0[e].loader,Tk=(e,t,{depth:r=2,clobber:n=!1}={})=>{const a={depth:r,clobber:n};return Array.isArray(t)&&!Array.isArray(e)?(t.forEach(i=>Tk(e,i,a)),e):Array.isArray(t)&&Array.isArray(e)?(t.forEach(i=>{e.includes(i)||e.push(i)}),e):e===void 0||r<=0?e!=null&&typeof e=="object"&&typeof t=="object"?Object.assign(e,t):t:(t!==void 0&&typeof e=="object"&&typeof t=="object"&&Object.keys(t).forEach(i=>{typeof t[i]=="object"&&(e[i]===void 0||typeof e[i]=="object")?(e[i]===void 0&&(e[i]=Array.isArray(t[i])?[]:{}),e[i]=Tk(e[i],t[i],{depth:r-1,clobber:n})):(n||typeof e[i]!="object"&&typeof t[i]!="object")&&(e[i]=t[i])}),e)},ha=Tk,x_e="​",w_e={curveBasis:sY,curveBasisClosed:uY,curveBasisOpen:dY,curveBumpX:nY,curveBumpY:aY,curveBundle:J7e,curveCardinalClosed:tSe,curveCardinalOpen:rSe,curveCardinal:eSe,curveCatmullRomClosed:aSe,curveCatmullRomOpen:iSe,curveCatmullRom:nSe,curveLinear:Eh,curveLinearClosed:yY,curveMonotoneX:xY,curveMonotoneY:wY,curveNatural:kY,curveStep:EY,curveStepAfter:AY,curveStepBefore:_Y},S_e=/\s*(?:(\w+)(?=:):|(\w+))\s*(?:(\w+)|((?:(?!}%{2}).|\r?\n)*))?\s*(?:}%{2})?/gi,k_e=function(e,t){const r=lZ(e,/(?:init\b)|(?:initialize\b)/);let n={};if(Array.isArray(r)){const o=r.map(s=>s.args);$g(o),n=ha(n,[...o])}else n=r.args;if(!n)return;let a=Pb(e,t);const i="config";return n[i]!==void 0&&(a==="flowchart-v2"&&(a="flowchart"),n[a]=n[i],delete n[i]),n},lZ=function(e,t=null){try{const r=new RegExp(`[%]{2}(?![{]${S_e.source})(?=[}][%]{2}).*
845
- `,"ig");e=e.trim().replace(r,"").replace(/'/gm,'"'),It.debug(`Detecting diagram directive${t!==null?" type:"+t:""} based on the text:${e}`);let n;const a=[];for(;(n=dp.exec(e))!==null;)if(n.index===dp.lastIndex&&dp.lastIndex++,n&&!t||t&&n[1]&&n[1].match(t)||t&&n[2]&&n[2].match(t)){const i=n[1]?n[1]:n[2],o=n[3]?n[3].trim():n[4]?JSON.parse(n[4].trim()):null;a.push({type:i,args:o})}return a.length===0?{type:e,args:null}:a.length===1?a[0]:a}catch(r){return It.error(`ERROR: ${r.message} - Unable to parse directive type: '${t}' based on the text: '${e}'`),{type:void 0,args:null}}},E_e=function(e){return e.replace(dp,"")},__e=function(e,t){for(const[r,n]of t.entries())if(n.match(e))return r;return-1};function A_e(e,t){if(!e)return t;const r=`curve${e.charAt(0).toUpperCase()+e.slice(1)}`;return w_e[r]??t}function T_e(e,t){const r=e.trim();if(r)return t.securityLevel!=="loose"?f2e.sanitizeUrl(r):r}const C_e=(e,...t)=>{const r=e.split("."),n=r.length-1,a=r[n];let i=window;for(let o=0;o<n;o++)if(i=i[r[o]],!i){It.error(`Function name: ${e} not found in window`);return}i[a](...t)};function uZ(e,t){return!e||!t?0:Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function I_e(e){let t,r=0;e.forEach(a=>{r+=uZ(a,t),t=a});const n=r/2;return t9(e,n)}function O_e(e){return e.length===1?e[0]:I_e(e)}const xF=(e,t=2)=>{const r=Math.pow(10,t);return Math.round(e*r)/r},t9=(e,t)=>{let r,n=t;for(const a of e){if(r){const i=uZ(a,r);if(i<n)n-=i;else{const o=n/i;if(o<=0)return r;if(o>=1)return{x:a.x,y:a.y};if(o>0&&o<1)return{x:xF((1-o)*r.x+o*a.x,5),y:xF((1-o)*r.y+o*a.y,5)}}}r=a}throw new Error("Could not find a suitable point for the given distance")},N_e=(e,t,r)=>{It.info(`our points ${JSON.stringify(t)}`),t[0]!==r&&(t=t.reverse());const n=t9(t,25),a=e?10:5,i=Math.atan2(t[0].y-n.y,t[0].x-n.x),o={x:0,y:0};return o.x=Math.sin(i)*a+(t[0].x+n.x)/2,o.y=-Math.cos(i)*a+(t[0].y+n.y)/2,o};function R_e(e,t,r){const n=structuredClone(r);It.info("our points",n),t!=="start_left"&&t!=="start_right"&&n.reverse();const a=25+e,i=t9(n,a),o=10+e*.5,s=Math.atan2(n[0].y-i.y,n[0].x-i.x),l={x:0,y:0};return t==="start_left"?(l.x=Math.sin(s+Math.PI)*o+(n[0].x+i.x)/2,l.y=-Math.cos(s+Math.PI)*o+(n[0].y+i.y)/2):t==="end_right"?(l.x=Math.sin(s-Math.PI)*o+(n[0].x+i.x)/2-5,l.y=-Math.cos(s-Math.PI)*o+(n[0].y+i.y)/2-5):t==="end_left"?(l.x=Math.sin(s)*o+(n[0].x+i.x)/2-5,l.y=-Math.cos(s)*o+(n[0].y+i.y)/2-5):(l.x=Math.sin(s)*o+(n[0].x+i.x)/2,l.y=-Math.cos(s)*o+(n[0].y+i.y)/2),l}function M_e(e){let t="",r="";for(const n of e)n!==void 0&&(n.startsWith("color:")||n.startsWith("text-align:")?r=r+n+";":t=t+n+";");return{style:t,labelStyle:r}}let wF=0;const L_e=()=>(wF++,"id-"+Math.random().toString(36).substr(2,12)+"-"+wF);function P_e(e){let t="";const r="0123456789abcdef",n=r.length;for(let a=0;a<e;a++)t+=r.charAt(Math.floor(Math.random()*n));return t}const D_e=e=>P_e(e.length),F_e=function(){return{x:0,y:0,fill:void 0,anchor:"start",style:"#666",width:100,height:100,textMargin:0,rx:0,ry:0,valign:void 0,text:""}},B_e=function(e,t){const r=t.text.replace(e9.lineBreakRegex," "),[,n]=n9(t.fontSize),a=e.append("text");a.attr("x",t.x),a.attr("y",t.y),a.style("text-anchor",t.anchor),a.style("font-family",t.fontFamily),a.style("font-size",n),a.style("font-weight",t.fontWeight),a.attr("fill",t.fill),t.class!==void 0&&a.attr("class",t.class);const i=a.append("tspan");return i.attr("x",t.x+t.textMargin*2),i.attr("fill",t.fill),i.text(r),a},z_e=Ah((e,t,r)=>{if(!e||(r=Object.assign({fontSize:12,fontWeight:400,fontFamily:"Arial",joinWith:"<br/>"},r),e9.lineBreakRegex.test(e)))return e;const n=e.split(" "),a=[];let i="";return n.forEach((o,s)=>{const l=Ug(`${o} `,r),u=Ug(i,r);if(l>t){const{hyphenatedStrings:c,remainingWord:d}=j_e(o,t,"-",r);a.push(i,...c),i=d}else u+l>=t?(a.push(i),i=o):i=[i,o].filter(Boolean).join(" ");s+1===n.length&&a.push(i)}),a.filter(o=>o!=="").join(r.joinWith)},(e,t,r)=>`${e}${t}${r.fontSize}${r.fontWeight}${r.fontFamily}${r.joinWith}`),j_e=Ah((e,t,r="-",n)=>{n=Object.assign({fontSize:12,fontWeight:400,fontFamily:"Arial",margin:0},n);const a=[...e],i=[];let o="";return a.forEach((s,l)=>{const u=`${o}${s}`;if(Ug(u,n)>=t){const c=l+1,d=a.length===c,p=`${u}${r}`;i.push(d?u:p),o=""}else o=u}),{hyphenatedStrings:i,remainingWord:o}},(e,t,r="-",n)=>`${e}${t}${r}${n.fontSize}${n.fontWeight}${n.fontFamily}`);function $_e(e,t){return r9(e,t).height}function Ug(e,t){return r9(e,t).width}const r9=Ah((e,t)=>{const{fontSize:r=12,fontFamily:n="Arial",fontWeight:a=400}=t;if(!e)return{width:0,height:0};const[,i]=n9(r),o=["sans-serif",n],s=e.split(e9.lineBreakRegex),l=[],u=Oi("body");if(!u.remove)return{width:0,height:0,lineHeight:0};const c=u.append("svg");for(const p of o){let h=0;const g={width:0,height:0,lineHeight:0};for(const b of s){const w=F_e();w.text=b||x_e;const x=B_e(c,w).style("font-size",i).style("font-weight",a).style("font-family",p),v=(x._groups||x)[0][0].getBBox();if(v.width===0&&v.height===0)throw new Error("svg element not in render tree");g.width=Math.round(Math.max(g.width,v.width)),h=Math.round(v.height),g.height+=h,g.lineHeight=Math.round(Math.max(g.lineHeight,h))}l.push(g)}c.remove();const d=isNaN(l[1].height)||isNaN(l[1].width)||isNaN(l[1].lineHeight)||l[0].height>l[1].height&&l[0].width>l[1].width&&l[0].lineHeight>l[1].lineHeight?0:1;return l[d]},(e,t)=>`${e}${t.fontSize}${t.fontWeight}${t.fontFamily}`);class U_e{constructor(t=!1,r){this.count=0,this.count=r?r.length:0,this.next=t?()=>this.count++:()=>Date.now()}}let Yf;const H_e=function(e){return Yf=Yf||document.createElement("div"),e=escape(e).replace(/%26/g,"&").replace(/%23/g,"#").replace(/%3B/g,";"),Yf.innerHTML=e,unescape(Yf.textContent)};function cZ(e){return"str"in e}const q_e=(e,t,r,n)=>{var a;if(!n)return;const i=(a=e.node())==null?void 0:a.getBBox();i&&e.append("text").text(n).attr("x",i.x+i.width/2).attr("y",-r).attr("class",t)},n9=e=>{if(typeof e=="number")return[e,e+"px"];const t=parseInt(e??"",10);return Number.isNaN(t)?[void 0,void 0]:e===String(t)?[t,e+"px"]:[t,e]};function dZ(e,t){return hEe({},e,t)}const pp={assignWithDepth:ha,wrapLabel:z_e,calculateTextHeight:$_e,calculateTextWidth:Ug,calculateTextDimensions:r9,cleanAndMerge:dZ,detectInit:k_e,detectDirective:lZ,isSubstringInArray:__e,interpolateToCurve:A_e,calcLabelPosition:O_e,calcCardinalityPosition:N_e,calcTerminalLabelPosition:R_e,formatUrl:T_e,getStylesFromArray:M_e,generateId:L_e,random:D_e,runFunc:C_e,entityDecode:H_e,insertTitle:q_e,parseFontSize:n9,InitIDGenerator:U_e},G_e=function(e){let t=e;return t=t.replace(/style.*:\S*#.*;/g,function(r){return r.substring(0,r.length-1)}),t=t.replace(/classDef.*:\S*#.*;/g,function(r){return r.substring(0,r.length-1)}),t=t.replace(/#\w+;/g,function(r){const n=r.substring(1,r.length-1);return/^\+?\d+$/.test(n)?"fl°°"+n+"¶ß":"fl°"+n+"¶ß"}),t},V_e=function(e){return e.replace(/fl°°/g,"&#").replace(/fl°/g,"&").replace(/¶ß/g,";")},SF="10.9.5",_0=Object.freeze(g_e);let Ha=ha({},_0),pZ,A0=[],hp=ha({},_0);const Db=(e,t)=>{let r=ha({},e),n={};for(const a of t)mZ(a),n=ha(n,a);if(r=ha(r,n),n.theme&&n.theme in Es){const a=ha({},pZ),i=ha(a.themeVariables||{},n.themeVariables);r.theme&&r.theme in Es&&(r.themeVariables=Es[r.theme].getThemeVariables(i))}return hp=r,gZ(hp),hp},W_e=e=>(Ha=ha({},_0),Ha=ha(Ha,e),e.theme&&Es[e.theme]&&(Ha.themeVariables=Es[e.theme].getThemeVariables(e.themeVariables)),Db(Ha,A0),Ha),K_e=e=>{pZ=ha({},e)},Y_e=e=>(Ha=ha(Ha,e),Db(Ha,A0),Ha),hZ=()=>ha({},Ha),fZ=e=>(gZ(e),ha(hp,e),Bo()),Bo=()=>ha({},hp),mZ=e=>{e&&(["secure",...Ha.secure??[]].forEach(t=>{Object.hasOwn(e,t)&&(It.debug(`Denied attempt to modify a secure key ${t}`,e[t]),delete e[t])}),Object.keys(e).forEach(t=>{t.startsWith("__")&&delete e[t]}),Object.keys(e).forEach(t=>{typeof e[t]=="string"&&(e[t].includes("<")||e[t].includes(">")||e[t].includes("url(data:"))&&delete e[t],typeof e[t]=="object"&&mZ(e[t])}))},Z_e=e=>{$g(e),e.fontFamily&&(!e.themeVariables||!e.themeVariables.fontFamily)&&(e.themeVariables={fontFamily:e.fontFamily}),A0.push(e),Db(Ha,A0)},Hg=(e=Ha)=>{A0=[],Db(e,A0)},X_e={LAZY_LOAD_DEPRECATED:"The configuration options lazyLoadedDiagrams and loadExternalDiagramsAtStartup are deprecated. Please use registerExternalDiagrams instead."},kF={},Q_e=e=>{kF[e]||(It.warn(X_e[e]),kF[e]=!0)},gZ=e=>{e&&(e.lazyLoadedDiagrams||e.loadExternalDiagramsAtStartup)&&Q_e("LAZY_LOAD_DEPRECATED")},yZ="c4",J_e=e=>/^\s*C4Context|C4Container|C4Component|C4Dynamic|C4Deployment/.test(e),e9e=async()=>{const{diagram:e}=await Lr(async()=>{const{diagram:t}=await import("./c4Diagram-c83219d4-gPr1eF38-O9OcyqsQ.js");return{diagram:t}},__vite__mapDeps([0,1]));return{id:yZ,diagram:e}},t9e={id:yZ,detector:J_e,loader:e9e},r9e=t9e,bZ="flowchart",n9e=(e,t)=>{var r,n;return((r=t==null?void 0:t.flowchart)==null?void 0:r.defaultRenderer)==="dagre-wrapper"||((n=t==null?void 0:t.flowchart)==null?void 0:n.defaultRenderer)==="elk"?!1:/^\s*graph/.test(e)},a9e=async()=>{const{diagram:e}=await Lr(async()=>{const{diagram:t}=await import("./flowDiagram-50d868cf-mkkB0hFd-hkUvxhtI.js");return{diagram:t}},__vite__mapDeps([2,3,4,5,6,7,8,9,10,11]));return{id:bZ,diagram:e}},i9e={id:bZ,detector:n9e,loader:a9e},o9e=i9e,vZ="flowchart-v2",s9e=(e,t)=>{var r,n,a;return((r=t==null?void 0:t.flowchart)==null?void 0:r.defaultRenderer)==="dagre-d3"||((n=t==null?void 0:t.flowchart)==null?void 0:n.defaultRenderer)==="elk"?!1:/^\s*graph/.test(e)&&((a=t==null?void 0:t.flowchart)==null?void 0:a.defaultRenderer)==="dagre-wrapper"?!0:/^\s*flowchart/.test(e)},l9e=async()=>{const{diagram:e}=await Lr(async()=>{const{diagram:t}=await import("./flowDiagram-v2-4f6560a1-BRIhxQ3y-yyJiLNqK.js");return{diagram:t}},__vite__mapDeps([12,3,6,4,7,5,8,9,10,11]));return{id:vZ,diagram:e}},u9e={id:vZ,detector:s9e,loader:l9e},c9e=u9e,xZ="er",d9e=e=>/^\s*erDiagram/.test(e),p9e=async()=>{const{diagram:e}=await Lr(async()=>{const{diagram:t}=await import("./erDiagram-0228fc6a-BLw8FsIp-hR-rEYLl.js");return{diagram:t}},__vite__mapDeps([13,4,5]));return{id:xZ,diagram:e}},h9e={id:xZ,detector:d9e,loader:p9e},f9e=h9e,wZ="gitGraph",m9e=e=>/^\s*gitGraph/.test(e),g9e=async()=>{const{diagram:e}=await Lr(async()=>{const{diagram:t}=await import("./gitGraphDiagram-82fe8481-txBzFn40-DTjPLNM5.js");return{diagram:t}},[]);return{id:wZ,diagram:e}},y9e={id:wZ,detector:m9e,loader:g9e},b9e=y9e,SZ="gantt",v9e=e=>/^\s*gantt/.test(e),x9e=async()=>{const{diagram:e}=await Lr(async()=>{const{diagram:t}=await import("./ganttDiagram-a2739b55-Cqs5_Zht-C2T02Tao.js");return{diagram:t}},[]);return{id:SZ,diagram:e}},w9e={id:SZ,detector:v9e,loader:x9e},S9e=w9e,kZ="info",k9e=e=>/^\s*info/.test(e),E9e=async()=>{const{diagram:e}=await Lr(async()=>{const{diagram:t}=await import("./infoDiagram-8eee0895-SbmhgTjv-CQEw8uWZ.js");return{diagram:t}},[]);return{id:kZ,diagram:e}},_9e={id:kZ,detector:k9e,loader:E9e},EZ="pie",A9e=e=>/^\s*pie/.test(e),T9e=async()=>{const{diagram:e}=await Lr(async()=>{const{diagram:t}=await import("./pieDiagram-a8764435-zrkaw4r--BbYH30QV.js");return{diagram:t}},__vite__mapDeps([14,15]));return{id:EZ,diagram:e}},C9e={id:EZ,detector:A9e,loader:T9e},_Z="quadrantChart",I9e=e=>/^\s*quadrantChart/.test(e),O9e=async()=>{const{diagram:e}=await Lr(async()=>{const{diagram:t}=await import("./quadrantDiagram-1e28029f-C2Wa5n16-pT8UyjnW.js");return{diagram:t}},[]);return{id:_Z,diagram:e}},N9e={id:_Z,detector:I9e,loader:O9e},R9e=N9e,AZ="xychart",M9e=e=>/^\s*xychart-beta/.test(e),L9e=async()=>{const{diagram:e}=await Lr(async()=>{const{diagram:t}=await import("./xychartDiagram-f5964ef8-BtRcO0uy-9WZJM-Px.js");return{diagram:t}},__vite__mapDeps([16,10]));return{id:AZ,diagram:e}},P9e={id:AZ,detector:M9e,loader:L9e},D9e=P9e,TZ="requirement",F9e=e=>/^\s*requirement(Diagram)?/.test(e),B9e=async()=>{const{diagram:e}=await Lr(async()=>{const{diagram:t}=await import("./requirementDiagram-08caed73-BtHxx079-C0E62fgL.js");return{diagram:t}},__vite__mapDeps([17,4,5]));return{id:TZ,diagram:e}},z9e={id:TZ,detector:F9e,loader:B9e},j9e=z9e,CZ="sequence",$9e=e=>/^\s*sequenceDiagram/.test(e),U9e=async()=>{const{diagram:e}=await Lr(async()=>{const{diagram:t}=await import("./sequenceDiagram-c5b8d532-BVQF3vcA-D3Ci0ZOB.js");return{diagram:t}},__vite__mapDeps([18,1]));return{id:CZ,diagram:e}},H9e={id:CZ,detector:$9e,loader:U9e},q9e=H9e,IZ="class",G9e=(e,t)=>{var r;return((r=t==null?void 0:t.class)==null?void 0:r.defaultRenderer)==="dagre-wrapper"?!1:/^\s*classDiagram/.test(e)},V9e=async()=>{const{diagram:e}=await Lr(async()=>{const{diagram:t}=await import("./classDiagram-beda092f-B8axaKGu-CnDHALya.js");return{diagram:t}},__vite__mapDeps([19,20,4,5]));return{id:IZ,diagram:e}},W9e={id:IZ,detector:G9e,loader:V9e},K9e=W9e,OZ="classDiagram",Y9e=(e,t)=>{var r;return/^\s*classDiagram/.test(e)&&((r=t==null?void 0:t.class)==null?void 0:r.defaultRenderer)==="dagre-wrapper"?!0:/^\s*classDiagram-v2/.test(e)},Z9e=async()=>{const{diagram:e}=await Lr(async()=>{const{diagram:t}=await import("./classDiagram-v2-2358418a-DPdf2DxR-D5LZKxzJ.js");return{diagram:t}},__vite__mapDeps([21,20,4,7,5,8,9,10]));return{id:OZ,diagram:e}},X9e={id:OZ,detector:Y9e,loader:Z9e},Q9e=X9e,NZ="state",J9e=(e,t)=>{var r;return((r=t==null?void 0:t.state)==null?void 0:r.defaultRenderer)==="dagre-wrapper"?!1:/^\s*stateDiagram/.test(e)},eAe=async()=>{const{diagram:e}=await Lr(async()=>{const{diagram:t}=await import("./stateDiagram-1ecb1508-Dybc3i2m-17lEs8Wr.js");return{diagram:t}},__vite__mapDeps([22,23,4,5]));return{id:NZ,diagram:e}},tAe={id:NZ,detector:J9e,loader:eAe},rAe=tAe,RZ="stateDiagram",nAe=(e,t)=>{var r;return!!(/^\s*stateDiagram-v2/.test(e)||/^\s*stateDiagram/.test(e)&&((r=t==null?void 0:t.state)==null?void 0:r.defaultRenderer)==="dagre-wrapper")},aAe=async()=>{const{diagram:e}=await Lr(async()=>{const{diagram:t}=await import("./stateDiagram-v2-c2b004d7-Bp8rRkv2-CYqkFKft.js");return{diagram:t}},__vite__mapDeps([24,23,4,7,5,8,9,10]));return{id:RZ,diagram:e}},iAe={id:RZ,detector:nAe,loader:aAe},oAe=iAe,MZ="journey",sAe=e=>/^\s*journey/.test(e),lAe=async()=>{const{diagram:e}=await Lr(async()=>{const{diagram:t}=await import("./journeyDiagram-c64418c1-C7AiwbKr-BzGlouWF.js");return{diagram:t}},__vite__mapDeps([25,1,15]));return{id:MZ,diagram:e}},uAe={id:MZ,detector:sAe,loader:lAe},cAe=uAe,dAe=function(e,t){for(let r of t)e.attr(r[0],r[1])},pAe=function(e,t,r){let n=new Map;return r?(n.set("width","100%"),n.set("style",`max-width: ${t}px;`)):(n.set("height",e),n.set("width",t)),n},LZ=function(e,t,r,n){const a=pAe(t,r,n);dAe(e,a)},hAe=function(e,t,r,n){const a=t.node().getBBox(),i=a.width,o=a.height;It.info(`SVG bounds: ${i}x${o}`,a);let s=0,l=0;It.info(`Graph bounds: ${s}x${l}`,e),s=i+r*2,l=o+r*2,It.info(`Calculated bounds: ${s}x${l}`),LZ(t,l,s,n);const u=`${a.x-r} ${a.y-r} ${a.width+2*r} ${a.height+2*r}`;t.attr("viewBox",u)},Pm={},fAe=(e,t,r)=>{let n="";return e in Pm&&Pm[e]?n=Pm[e](r):It.warn(`No theme found for ${e}`),` & {
845
+ `,"ig");e=e.trim().replace(r,"").replace(/'/gm,'"'),It.debug(`Detecting diagram directive${t!==null?" type:"+t:""} based on the text:${e}`);let n;const a=[];for(;(n=dp.exec(e))!==null;)if(n.index===dp.lastIndex&&dp.lastIndex++,n&&!t||t&&n[1]&&n[1].match(t)||t&&n[2]&&n[2].match(t)){const i=n[1]?n[1]:n[2],o=n[3]?n[3].trim():n[4]?JSON.parse(n[4].trim()):null;a.push({type:i,args:o})}return a.length===0?{type:e,args:null}:a.length===1?a[0]:a}catch(r){return It.error(`ERROR: ${r.message} - Unable to parse directive type: '${t}' based on the text: '${e}'`),{type:void 0,args:null}}},E_e=function(e){return e.replace(dp,"")},__e=function(e,t){for(const[r,n]of t.entries())if(n.match(e))return r;return-1};function A_e(e,t){if(!e)return t;const r=`curve${e.charAt(0).toUpperCase()+e.slice(1)}`;return w_e[r]??t}function T_e(e,t){const r=e.trim();if(r)return t.securityLevel!=="loose"?f2e.sanitizeUrl(r):r}const C_e=(e,...t)=>{const r=e.split("."),n=r.length-1,a=r[n];let i=window;for(let o=0;o<n;o++)if(i=i[r[o]],!i){It.error(`Function name: ${e} not found in window`);return}i[a](...t)};function uZ(e,t){return!e||!t?0:Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function I_e(e){let t,r=0;e.forEach(a=>{r+=uZ(a,t),t=a});const n=r/2;return t9(e,n)}function O_e(e){return e.length===1?e[0]:I_e(e)}const xF=(e,t=2)=>{const r=Math.pow(10,t);return Math.round(e*r)/r},t9=(e,t)=>{let r,n=t;for(const a of e){if(r){const i=uZ(a,r);if(i<n)n-=i;else{const o=n/i;if(o<=0)return r;if(o>=1)return{x:a.x,y:a.y};if(o>0&&o<1)return{x:xF((1-o)*r.x+o*a.x,5),y:xF((1-o)*r.y+o*a.y,5)}}}r=a}throw new Error("Could not find a suitable point for the given distance")},N_e=(e,t,r)=>{It.info(`our points ${JSON.stringify(t)}`),t[0]!==r&&(t=t.reverse());const n=t9(t,25),a=e?10:5,i=Math.atan2(t[0].y-n.y,t[0].x-n.x),o={x:0,y:0};return o.x=Math.sin(i)*a+(t[0].x+n.x)/2,o.y=-Math.cos(i)*a+(t[0].y+n.y)/2,o};function R_e(e,t,r){const n=structuredClone(r);It.info("our points",n),t!=="start_left"&&t!=="start_right"&&n.reverse();const a=25+e,i=t9(n,a),o=10+e*.5,s=Math.atan2(n[0].y-i.y,n[0].x-i.x),l={x:0,y:0};return t==="start_left"?(l.x=Math.sin(s+Math.PI)*o+(n[0].x+i.x)/2,l.y=-Math.cos(s+Math.PI)*o+(n[0].y+i.y)/2):t==="end_right"?(l.x=Math.sin(s-Math.PI)*o+(n[0].x+i.x)/2-5,l.y=-Math.cos(s-Math.PI)*o+(n[0].y+i.y)/2-5):t==="end_left"?(l.x=Math.sin(s)*o+(n[0].x+i.x)/2-5,l.y=-Math.cos(s)*o+(n[0].y+i.y)/2-5):(l.x=Math.sin(s)*o+(n[0].x+i.x)/2,l.y=-Math.cos(s)*o+(n[0].y+i.y)/2),l}function M_e(e){let t="",r="";for(const n of e)n!==void 0&&(n.startsWith("color:")||n.startsWith("text-align:")?r=r+n+";":t=t+n+";");return{style:t,labelStyle:r}}let wF=0;const L_e=()=>(wF++,"id-"+Math.random().toString(36).substr(2,12)+"-"+wF);function P_e(e){let t="";const r="0123456789abcdef",n=r.length;for(let a=0;a<e;a++)t+=r.charAt(Math.floor(Math.random()*n));return t}const D_e=e=>P_e(e.length),F_e=function(){return{x:0,y:0,fill:void 0,anchor:"start",style:"#666",width:100,height:100,textMargin:0,rx:0,ry:0,valign:void 0,text:""}},B_e=function(e,t){const r=t.text.replace(e9.lineBreakRegex," "),[,n]=n9(t.fontSize),a=e.append("text");a.attr("x",t.x),a.attr("y",t.y),a.style("text-anchor",t.anchor),a.style("font-family",t.fontFamily),a.style("font-size",n),a.style("font-weight",t.fontWeight),a.attr("fill",t.fill),t.class!==void 0&&a.attr("class",t.class);const i=a.append("tspan");return i.attr("x",t.x+t.textMargin*2),i.attr("fill",t.fill),i.text(r),a},z_e=Ah((e,t,r)=>{if(!e||(r=Object.assign({fontSize:12,fontWeight:400,fontFamily:"Arial",joinWith:"<br/>"},r),e9.lineBreakRegex.test(e)))return e;const n=e.split(" "),a=[];let i="";return n.forEach((o,s)=>{const l=Ug(`${o} `,r),u=Ug(i,r);if(l>t){const{hyphenatedStrings:c,remainingWord:d}=j_e(o,t,"-",r);a.push(i,...c),i=d}else u+l>=t?(a.push(i),i=o):i=[i,o].filter(Boolean).join(" ");s+1===n.length&&a.push(i)}),a.filter(o=>o!=="").join(r.joinWith)},(e,t,r)=>`${e}${t}${r.fontSize}${r.fontWeight}${r.fontFamily}${r.joinWith}`),j_e=Ah((e,t,r="-",n)=>{n=Object.assign({fontSize:12,fontWeight:400,fontFamily:"Arial",margin:0},n);const a=[...e],i=[];let o="";return a.forEach((s,l)=>{const u=`${o}${s}`;if(Ug(u,n)>=t){const c=l+1,d=a.length===c,p=`${u}${r}`;i.push(d?u:p),o=""}else o=u}),{hyphenatedStrings:i,remainingWord:o}},(e,t,r="-",n)=>`${e}${t}${r}${n.fontSize}${n.fontWeight}${n.fontFamily}`);function $_e(e,t){return r9(e,t).height}function Ug(e,t){return r9(e,t).width}const r9=Ah((e,t)=>{const{fontSize:r=12,fontFamily:n="Arial",fontWeight:a=400}=t;if(!e)return{width:0,height:0};const[,i]=n9(r),o=["sans-serif",n],s=e.split(e9.lineBreakRegex),l=[],u=Oi("body");if(!u.remove)return{width:0,height:0,lineHeight:0};const c=u.append("svg");for(const p of o){let h=0;const g={width:0,height:0,lineHeight:0};for(const b of s){const w=F_e();w.text=b||x_e;const x=B_e(c,w).style("font-size",i).style("font-weight",a).style("font-family",p),v=(x._groups||x)[0][0].getBBox();if(v.width===0&&v.height===0)throw new Error("svg element not in render tree");g.width=Math.round(Math.max(g.width,v.width)),h=Math.round(v.height),g.height+=h,g.lineHeight=Math.round(Math.max(g.lineHeight,h))}l.push(g)}c.remove();const d=isNaN(l[1].height)||isNaN(l[1].width)||isNaN(l[1].lineHeight)||l[0].height>l[1].height&&l[0].width>l[1].width&&l[0].lineHeight>l[1].lineHeight?0:1;return l[d]},(e,t)=>`${e}${t.fontSize}${t.fontWeight}${t.fontFamily}`);class U_e{constructor(t=!1,r){this.count=0,this.count=r?r.length:0,this.next=t?()=>this.count++:()=>Date.now()}}let Yf;const H_e=function(e){return Yf=Yf||document.createElement("div"),e=escape(e).replace(/%26/g,"&").replace(/%23/g,"#").replace(/%3B/g,";"),Yf.innerHTML=e,unescape(Yf.textContent)};function cZ(e){return"str"in e}const q_e=(e,t,r,n)=>{var a;if(!n)return;const i=(a=e.node())==null?void 0:a.getBBox();i&&e.append("text").text(n).attr("x",i.x+i.width/2).attr("y",-r).attr("class",t)},n9=e=>{if(typeof e=="number")return[e,e+"px"];const t=parseInt(e??"",10);return Number.isNaN(t)?[void 0,void 0]:e===String(t)?[t,e+"px"]:[t,e]};function dZ(e,t){return hEe({},e,t)}const pp={assignWithDepth:ha,wrapLabel:z_e,calculateTextHeight:$_e,calculateTextWidth:Ug,calculateTextDimensions:r9,cleanAndMerge:dZ,detectInit:k_e,detectDirective:lZ,isSubstringInArray:__e,interpolateToCurve:A_e,calcLabelPosition:O_e,calcCardinalityPosition:N_e,calcTerminalLabelPosition:R_e,formatUrl:T_e,getStylesFromArray:M_e,generateId:L_e,random:D_e,runFunc:C_e,entityDecode:H_e,insertTitle:q_e,parseFontSize:n9,InitIDGenerator:U_e},G_e=function(e){let t=e;return t=t.replace(/style.*:\S*#.*;/g,function(r){return r.substring(0,r.length-1)}),t=t.replace(/classDef.*:\S*#.*;/g,function(r){return r.substring(0,r.length-1)}),t=t.replace(/#\w+;/g,function(r){const n=r.substring(1,r.length-1);return/^\+?\d+$/.test(n)?"fl°°"+n+"¶ß":"fl°"+n+"¶ß"}),t},V_e=function(e){return e.replace(/fl°°/g,"&#").replace(/fl°/g,"&").replace(/¶ß/g,";")},SF="10.9.5",_0=Object.freeze(g_e);let Ha=ha({},_0),pZ,A0=[],hp=ha({},_0);const Db=(e,t)=>{let r=ha({},e),n={};for(const a of t)mZ(a),n=ha(n,a);if(r=ha(r,n),n.theme&&n.theme in Es){const a=ha({},pZ),i=ha(a.themeVariables||{},n.themeVariables);r.theme&&r.theme in Es&&(r.themeVariables=Es[r.theme].getThemeVariables(i))}return hp=r,gZ(hp),hp},W_e=e=>(Ha=ha({},_0),Ha=ha(Ha,e),e.theme&&Es[e.theme]&&(Ha.themeVariables=Es[e.theme].getThemeVariables(e.themeVariables)),Db(Ha,A0),Ha),K_e=e=>{pZ=ha({},e)},Y_e=e=>(Ha=ha(Ha,e),Db(Ha,A0),Ha),hZ=()=>ha({},Ha),fZ=e=>(gZ(e),ha(hp,e),Bo()),Bo=()=>ha({},hp),mZ=e=>{e&&(["secure",...Ha.secure??[]].forEach(t=>{Object.hasOwn(e,t)&&(It.debug(`Denied attempt to modify a secure key ${t}`,e[t]),delete e[t])}),Object.keys(e).forEach(t=>{t.startsWith("__")&&delete e[t]}),Object.keys(e).forEach(t=>{typeof e[t]=="string"&&(e[t].includes("<")||e[t].includes(">")||e[t].includes("url(data:"))&&delete e[t],typeof e[t]=="object"&&mZ(e[t])}))},Z_e=e=>{$g(e),e.fontFamily&&(!e.themeVariables||!e.themeVariables.fontFamily)&&(e.themeVariables={fontFamily:e.fontFamily}),A0.push(e),Db(Ha,A0)},Hg=(e=Ha)=>{A0=[],Db(e,A0)},X_e={LAZY_LOAD_DEPRECATED:"The configuration options lazyLoadedDiagrams and loadExternalDiagramsAtStartup are deprecated. Please use registerExternalDiagrams instead."},kF={},Q_e=e=>{kF[e]||(It.warn(X_e[e]),kF[e]=!0)},gZ=e=>{e&&(e.lazyLoadedDiagrams||e.loadExternalDiagramsAtStartup)&&Q_e("LAZY_LOAD_DEPRECATED")},yZ="c4",J_e=e=>/^\s*C4Context|C4Container|C4Component|C4Dynamic|C4Deployment/.test(e),e9e=async()=>{const{diagram:e}=await Lr(async()=>{const{diagram:t}=await import("./c4Diagram-c83219d4-gPr1eF38-Crko8syr.js");return{diagram:t}},__vite__mapDeps([0,1]));return{id:yZ,diagram:e}},t9e={id:yZ,detector:J_e,loader:e9e},r9e=t9e,bZ="flowchart",n9e=(e,t)=>{var r,n;return((r=t==null?void 0:t.flowchart)==null?void 0:r.defaultRenderer)==="dagre-wrapper"||((n=t==null?void 0:t.flowchart)==null?void 0:n.defaultRenderer)==="elk"?!1:/^\s*graph/.test(e)},a9e=async()=>{const{diagram:e}=await Lr(async()=>{const{diagram:t}=await import("./flowDiagram-50d868cf-mkkB0hFd-DyocKKmv.js");return{diagram:t}},__vite__mapDeps([2,3,4,5,6,7,8,9,10,11]));return{id:bZ,diagram:e}},i9e={id:bZ,detector:n9e,loader:a9e},o9e=i9e,vZ="flowchart-v2",s9e=(e,t)=>{var r,n,a;return((r=t==null?void 0:t.flowchart)==null?void 0:r.defaultRenderer)==="dagre-d3"||((n=t==null?void 0:t.flowchart)==null?void 0:n.defaultRenderer)==="elk"?!1:/^\s*graph/.test(e)&&((a=t==null?void 0:t.flowchart)==null?void 0:a.defaultRenderer)==="dagre-wrapper"?!0:/^\s*flowchart/.test(e)},l9e=async()=>{const{diagram:e}=await Lr(async()=>{const{diagram:t}=await import("./flowDiagram-v2-4f6560a1-BRIhxQ3y-M3Kb-HpF.js");return{diagram:t}},__vite__mapDeps([12,3,6,4,7,5,8,9,10,11]));return{id:vZ,diagram:e}},u9e={id:vZ,detector:s9e,loader:l9e},c9e=u9e,xZ="er",d9e=e=>/^\s*erDiagram/.test(e),p9e=async()=>{const{diagram:e}=await Lr(async()=>{const{diagram:t}=await import("./erDiagram-0228fc6a-BLw8FsIp-K7hty7n7.js");return{diagram:t}},__vite__mapDeps([13,4,5]));return{id:xZ,diagram:e}},h9e={id:xZ,detector:d9e,loader:p9e},f9e=h9e,wZ="gitGraph",m9e=e=>/^\s*gitGraph/.test(e),g9e=async()=>{const{diagram:e}=await Lr(async()=>{const{diagram:t}=await import("./gitGraphDiagram-82fe8481-txBzFn40-D1K5om9l.js");return{diagram:t}},[]);return{id:wZ,diagram:e}},y9e={id:wZ,detector:m9e,loader:g9e},b9e=y9e,SZ="gantt",v9e=e=>/^\s*gantt/.test(e),x9e=async()=>{const{diagram:e}=await Lr(async()=>{const{diagram:t}=await import("./ganttDiagram-a2739b55-Cqs5_Zht-B9aZYss_.js");return{diagram:t}},[]);return{id:SZ,diagram:e}},w9e={id:SZ,detector:v9e,loader:x9e},S9e=w9e,kZ="info",k9e=e=>/^\s*info/.test(e),E9e=async()=>{const{diagram:e}=await Lr(async()=>{const{diagram:t}=await import("./infoDiagram-8eee0895-SbmhgTjv-C9kXGFlX.js");return{diagram:t}},[]);return{id:kZ,diagram:e}},_9e={id:kZ,detector:k9e,loader:E9e},EZ="pie",A9e=e=>/^\s*pie/.test(e),T9e=async()=>{const{diagram:e}=await Lr(async()=>{const{diagram:t}=await import("./pieDiagram-a8764435-zrkaw4r--KTFILwx0.js");return{diagram:t}},__vite__mapDeps([14,15]));return{id:EZ,diagram:e}},C9e={id:EZ,detector:A9e,loader:T9e},_Z="quadrantChart",I9e=e=>/^\s*quadrantChart/.test(e),O9e=async()=>{const{diagram:e}=await Lr(async()=>{const{diagram:t}=await import("./quadrantDiagram-1e28029f-C2Wa5n16-QeGvwqfN.js");return{diagram:t}},[]);return{id:_Z,diagram:e}},N9e={id:_Z,detector:I9e,loader:O9e},R9e=N9e,AZ="xychart",M9e=e=>/^\s*xychart-beta/.test(e),L9e=async()=>{const{diagram:e}=await Lr(async()=>{const{diagram:t}=await import("./xychartDiagram-f5964ef8-BtRcO0uy-zTA5EBg7.js");return{diagram:t}},__vite__mapDeps([16,10]));return{id:AZ,diagram:e}},P9e={id:AZ,detector:M9e,loader:L9e},D9e=P9e,TZ="requirement",F9e=e=>/^\s*requirement(Diagram)?/.test(e),B9e=async()=>{const{diagram:e}=await Lr(async()=>{const{diagram:t}=await import("./requirementDiagram-08caed73-BtHxx079-DmZZ94rA.js");return{diagram:t}},__vite__mapDeps([17,4,5]));return{id:TZ,diagram:e}},z9e={id:TZ,detector:F9e,loader:B9e},j9e=z9e,CZ="sequence",$9e=e=>/^\s*sequenceDiagram/.test(e),U9e=async()=>{const{diagram:e}=await Lr(async()=>{const{diagram:t}=await import("./sequenceDiagram-c5b8d532-BVQF3vcA-DaOYr80F.js");return{diagram:t}},__vite__mapDeps([18,1]));return{id:CZ,diagram:e}},H9e={id:CZ,detector:$9e,loader:U9e},q9e=H9e,IZ="class",G9e=(e,t)=>{var r;return((r=t==null?void 0:t.class)==null?void 0:r.defaultRenderer)==="dagre-wrapper"?!1:/^\s*classDiagram/.test(e)},V9e=async()=>{const{diagram:e}=await Lr(async()=>{const{diagram:t}=await import("./classDiagram-beda092f-B8axaKGu-B0xqesVY.js");return{diagram:t}},__vite__mapDeps([19,20,4,5]));return{id:IZ,diagram:e}},W9e={id:IZ,detector:G9e,loader:V9e},K9e=W9e,OZ="classDiagram",Y9e=(e,t)=>{var r;return/^\s*classDiagram/.test(e)&&((r=t==null?void 0:t.class)==null?void 0:r.defaultRenderer)==="dagre-wrapper"?!0:/^\s*classDiagram-v2/.test(e)},Z9e=async()=>{const{diagram:e}=await Lr(async()=>{const{diagram:t}=await import("./classDiagram-v2-2358418a-DPdf2DxR-BVldiIQV.js");return{diagram:t}},__vite__mapDeps([21,20,4,7,5,8,9,10]));return{id:OZ,diagram:e}},X9e={id:OZ,detector:Y9e,loader:Z9e},Q9e=X9e,NZ="state",J9e=(e,t)=>{var r;return((r=t==null?void 0:t.state)==null?void 0:r.defaultRenderer)==="dagre-wrapper"?!1:/^\s*stateDiagram/.test(e)},eAe=async()=>{const{diagram:e}=await Lr(async()=>{const{diagram:t}=await import("./stateDiagram-1ecb1508-Dybc3i2m-Czv1eXAW.js");return{diagram:t}},__vite__mapDeps([22,23,4,5]));return{id:NZ,diagram:e}},tAe={id:NZ,detector:J9e,loader:eAe},rAe=tAe,RZ="stateDiagram",nAe=(e,t)=>{var r;return!!(/^\s*stateDiagram-v2/.test(e)||/^\s*stateDiagram/.test(e)&&((r=t==null?void 0:t.state)==null?void 0:r.defaultRenderer)==="dagre-wrapper")},aAe=async()=>{const{diagram:e}=await Lr(async()=>{const{diagram:t}=await import("./stateDiagram-v2-c2b004d7-Bp8rRkv2-DprArMIU.js");return{diagram:t}},__vite__mapDeps([24,23,4,7,5,8,9,10]));return{id:RZ,diagram:e}},iAe={id:RZ,detector:nAe,loader:aAe},oAe=iAe,MZ="journey",sAe=e=>/^\s*journey/.test(e),lAe=async()=>{const{diagram:e}=await Lr(async()=>{const{diagram:t}=await import("./journeyDiagram-c64418c1-C7AiwbKr-Uzs60Xyr.js");return{diagram:t}},__vite__mapDeps([25,1,15]));return{id:MZ,diagram:e}},uAe={id:MZ,detector:sAe,loader:lAe},cAe=uAe,dAe=function(e,t){for(let r of t)e.attr(r[0],r[1])},pAe=function(e,t,r){let n=new Map;return r?(n.set("width","100%"),n.set("style",`max-width: ${t}px;`)):(n.set("height",e),n.set("width",t)),n},LZ=function(e,t,r,n){const a=pAe(t,r,n);dAe(e,a)},hAe=function(e,t,r,n){const a=t.node().getBBox(),i=a.width,o=a.height;It.info(`SVG bounds: ${i}x${o}`,a);let s=0,l=0;It.info(`Graph bounds: ${s}x${l}`,e),s=i+r*2,l=o+r*2,It.info(`Calculated bounds: ${s}x${l}`),LZ(t,l,s,n);const u=`${a.x-r} ${a.y-r} ${a.width+2*r} ${a.height+2*r}`;t.attr("viewBox",u)},Pm={},fAe=(e,t,r)=>{let n="";return e in Pm&&Pm[e]?n=Pm[e](r):It.warn(`No theme found for ${e}`),` & {
846
846
  font-family: ${r.fontFamily};
847
847
  font-size: ${r.fontSize};
848
848
  fill: ${r.textColor}
@@ -893,7 +893,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
893
893
  ${t}
894
894
  `},mAe=(e,t)=>{t!==void 0&&(Pm[e]=t)},gAe=fAe;let a9="",i9="",o9="";const s9=e=>k0(e,Bo()),yAe=()=>{a9="",o9="",i9=""},bAe=e=>{a9=s9(e).replace(/^\s+/g,"")},vAe=()=>a9,xAe=e=>{o9=s9(e).replace(/\n\s+/g,`
895
895
  `)},wAe=()=>o9,SAe=e=>{i9=s9(e)},kAe=()=>i9,EAe=Object.freeze(Object.defineProperty({__proto__:null,clear:yAe,getAccDescription:wAe,getAccTitle:vAe,getDiagramTitle:kAe,setAccDescription:xAe,setAccTitle:bAe,setDiagramTitle:SAe},Symbol.toStringTag,{value:"Module"})),_Ae=It,AAe=J_,l9=Bo,VVe=fZ,WVe=_0,TAe=e=>k0(e,l9()),CAe=hAe,IAe=()=>EAe,qg={},Gg=(e,t,r)=>{var n;if(qg[e])throw new Error(`Diagram ${e} already registered.`);qg[e]=t,r&&sZ(e,r),mAe(e,t.styles),(n=t.injectUtils)==null||n.call(t,_Ae,AAe,l9,TAe,CAe,IAe(),()=>{})},u9=e=>{if(e in qg)return qg[e];throw new OAe(e)};class OAe extends Error{constructor(t){super(`Diagram ${t} not found.`)}}const NAe=e=>{var t;const{securityLevel:r}=l9();let n=Oi("body");if(r==="sandbox"){const a=((t=Oi(`#i${e}`).node())==null?void 0:t.contentDocument)??document;n=Oi(a.body)}return n.select(`#${e}`)},RAe=(e,t,r)=>{It.debug(`rendering svg for syntax error
896
- `);const n=NAe(t),a=n.append("g");n.attr("viewBox","0 0 2412 512"),LZ(n,100,512,!0),a.append("path").attr("class","error-icon").attr("d","m411.313,123.313c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32-9.375,9.375-20.688-20.688c-12.484-12.5-32.766-12.5-45.25,0l-16,16c-1.261,1.261-2.304,2.648-3.31,4.051-21.739-8.561-45.324-13.426-70.065-13.426-105.867,0-192,86.133-192,192s86.133,192 192,192 192-86.133 192-192c0-24.741-4.864-48.327-13.426-70.065 1.402-1.007 2.79-2.049 4.051-3.31l16-16c12.5-12.492 12.5-32.758 0-45.25l-20.688-20.688 9.375-9.375 32.001-31.999zm-219.313,100.687c-52.938,0-96,43.063-96,96 0,8.836-7.164,16-16,16s-16-7.164-16-16c0-70.578 57.422-128 128-128 8.836,0 16,7.164 16,16s-7.164,16-16,16z"),a.append("path").attr("class","error-icon").attr("d","m459.02,148.98c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l16,16c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16.001-16z"),a.append("path").attr("class","error-icon").attr("d","m340.395,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16-16c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l15.999,16z"),a.append("path").attr("class","error-icon").attr("d","m400,64c8.844,0 16-7.164 16-16v-32c0-8.836-7.156-16-16-16-8.844,0-16,7.164-16,16v32c0,8.836 7.156,16 16,16z"),a.append("path").attr("class","error-icon").attr("d","m496,96.586h-32c-8.844,0-16,7.164-16,16 0,8.836 7.156,16 16,16h32c8.844,0 16-7.164 16-16 0-8.836-7.156-16-16-16z"),a.append("path").attr("class","error-icon").attr("d","m436.98,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688l32-32c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32c-6.251,6.25-6.251,16.375-0.001,22.625z"),a.append("text").attr("class","error-text").attr("x",1440).attr("y",250).attr("font-size","150px").style("text-anchor","middle").text("Syntax error in text"),a.append("text").attr("class","error-text").attr("x",1250).attr("y",400).attr("font-size","100px").style("text-anchor","middle").text(`mermaid version ${r}`)},PZ={draw:RAe},MAe=PZ,LAe={db:{},renderer:PZ,parser:{parser:{yy:{}},parse:()=>{}}},PAe=LAe,DZ="flowchart-elk",DAe=(e,t)=>{var r;return!!(/^\s*flowchart-elk/.test(e)||/^\s*flowchart|graph/.test(e)&&((r=t==null?void 0:t.flowchart)==null?void 0:r.defaultRenderer)==="elk")},FAe=async()=>{const{diagram:e}=await Lr(async()=>{const{diagram:t}=await import("./flowchart-elk-definition-6af322e1-D9IbjnSJ-DDmMX5g7.js");return{diagram:t}},__vite__mapDeps([26,3,9,10]));return{id:DZ,diagram:e}},BAe={id:DZ,detector:DAe,loader:FAe},zAe=BAe,FZ="timeline",jAe=e=>/^\s*timeline/.test(e),$Ae=async()=>{const{diagram:e}=await Lr(async()=>{const{diagram:t}=await import("./timeline-definition-faaaa080-b82QCnJ9-fscP9KLE.js");return{diagram:t}},__vite__mapDeps([27,15]));return{id:FZ,diagram:e}},UAe={id:FZ,detector:jAe,loader:$Ae},HAe=UAe,BZ="mindmap",qAe=e=>/^\s*mindmap/.test(e),GAe=async()=>{const{diagram:e}=await Lr(async()=>{const{diagram:t}=await import("./mindmap-definition-8da855dc-B1WjnfxE-bWS9Lud_.js");return{diagram:t}},__vite__mapDeps([28,10]));return{id:BZ,diagram:e}},VAe={id:BZ,detector:qAe,loader:GAe},WAe=VAe,zZ="sankey",KAe=e=>/^\s*sankey-beta/.test(e),YAe=async()=>{const{diagram:e}=await Lr(async()=>{const{diagram:t}=await import("./sankeyDiagram-a04cb91d-DXlmqTKB-BJoGKmtH.js");return{diagram:t}},__vite__mapDeps([29,30]));return{id:zZ,diagram:e}},ZAe={id:zZ,detector:KAe,loader:YAe},XAe=ZAe,jZ="block",QAe=e=>/^\s*block-beta/.test(e),JAe=async()=>{const{diagram:e}=await Lr(async()=>{const{diagram:t}=await import("./blockDiagram-c4efeb88-NvaZhZFT-BF7Jw6AF.js");return{diagram:t}},__vite__mapDeps([31,8,4,9,10,11,30]));return{id:jZ,diagram:e}},eTe={id:jZ,detector:QAe,loader:JAe},tTe=eTe;let EF=!1;const c9=()=>{EF||(EF=!0,Gg("error",PAe,e=>e.toLowerCase().trim()==="error"),Gg("---",{db:{clear:()=>{}},styles:{},renderer:{draw:()=>{}},parser:{parser:{yy:{}},parse:()=>{throw new Error("Diagrams beginning with --- are not valid. If you were trying to use a YAML front-matter, please ensure that you've correctly opened and closed the YAML front-matter with un-indented `---` blocks")}},init:()=>null},e=>e.toLowerCase().trimStart().startsWith("---")),oZ(r9e,Q9e,K9e,f9e,S9e,_9e,C9e,j9e,q9e,zAe,c9e,o9e,WAe,HAe,b9e,oAe,rAe,cAe,R9e,XAe,D9e,tTe))};class $Z{constructor(t,r={}){this.text=t,this.metadata=r,this.type="graph",this.text=G_e(t),this.text+=`
896
+ `);const n=NAe(t),a=n.append("g");n.attr("viewBox","0 0 2412 512"),LZ(n,100,512,!0),a.append("path").attr("class","error-icon").attr("d","m411.313,123.313c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32-9.375,9.375-20.688-20.688c-12.484-12.5-32.766-12.5-45.25,0l-16,16c-1.261,1.261-2.304,2.648-3.31,4.051-21.739-8.561-45.324-13.426-70.065-13.426-105.867,0-192,86.133-192,192s86.133,192 192,192 192-86.133 192-192c0-24.741-4.864-48.327-13.426-70.065 1.402-1.007 2.79-2.049 4.051-3.31l16-16c12.5-12.492 12.5-32.758 0-45.25l-20.688-20.688 9.375-9.375 32.001-31.999zm-219.313,100.687c-52.938,0-96,43.063-96,96 0,8.836-7.164,16-16,16s-16-7.164-16-16c0-70.578 57.422-128 128-128 8.836,0 16,7.164 16,16s-7.164,16-16,16z"),a.append("path").attr("class","error-icon").attr("d","m459.02,148.98c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l16,16c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16.001-16z"),a.append("path").attr("class","error-icon").attr("d","m340.395,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16-16c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l15.999,16z"),a.append("path").attr("class","error-icon").attr("d","m400,64c8.844,0 16-7.164 16-16v-32c0-8.836-7.156-16-16-16-8.844,0-16,7.164-16,16v32c0,8.836 7.156,16 16,16z"),a.append("path").attr("class","error-icon").attr("d","m496,96.586h-32c-8.844,0-16,7.164-16,16 0,8.836 7.156,16 16,16h32c8.844,0 16-7.164 16-16 0-8.836-7.156-16-16-16z"),a.append("path").attr("class","error-icon").attr("d","m436.98,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688l32-32c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32c-6.251,6.25-6.251,16.375-0.001,22.625z"),a.append("text").attr("class","error-text").attr("x",1440).attr("y",250).attr("font-size","150px").style("text-anchor","middle").text("Syntax error in text"),a.append("text").attr("class","error-text").attr("x",1250).attr("y",400).attr("font-size","100px").style("text-anchor","middle").text(`mermaid version ${r}`)},PZ={draw:RAe},MAe=PZ,LAe={db:{},renderer:PZ,parser:{parser:{yy:{}},parse:()=>{}}},PAe=LAe,DZ="flowchart-elk",DAe=(e,t)=>{var r;return!!(/^\s*flowchart-elk/.test(e)||/^\s*flowchart|graph/.test(e)&&((r=t==null?void 0:t.flowchart)==null?void 0:r.defaultRenderer)==="elk")},FAe=async()=>{const{diagram:e}=await Lr(async()=>{const{diagram:t}=await import("./flowchart-elk-definition-6af322e1-D9IbjnSJ-9Mck6Jvy.js");return{diagram:t}},__vite__mapDeps([26,3,9,10]));return{id:DZ,diagram:e}},BAe={id:DZ,detector:DAe,loader:FAe},zAe=BAe,FZ="timeline",jAe=e=>/^\s*timeline/.test(e),$Ae=async()=>{const{diagram:e}=await Lr(async()=>{const{diagram:t}=await import("./timeline-definition-faaaa080-b82QCnJ9-EH-DzRfv.js");return{diagram:t}},__vite__mapDeps([27,15]));return{id:FZ,diagram:e}},UAe={id:FZ,detector:jAe,loader:$Ae},HAe=UAe,BZ="mindmap",qAe=e=>/^\s*mindmap/.test(e),GAe=async()=>{const{diagram:e}=await Lr(async()=>{const{diagram:t}=await import("./mindmap-definition-8da855dc-B1WjnfxE-BtUcqAXe.js");return{diagram:t}},__vite__mapDeps([28,10]));return{id:BZ,diagram:e}},VAe={id:BZ,detector:qAe,loader:GAe},WAe=VAe,zZ="sankey",KAe=e=>/^\s*sankey-beta/.test(e),YAe=async()=>{const{diagram:e}=await Lr(async()=>{const{diagram:t}=await import("./sankeyDiagram-a04cb91d-DXlmqTKB-DgLDkAoH.js");return{diagram:t}},__vite__mapDeps([29,30]));return{id:zZ,diagram:e}},ZAe={id:zZ,detector:KAe,loader:YAe},XAe=ZAe,jZ="block",QAe=e=>/^\s*block-beta/.test(e),JAe=async()=>{const{diagram:e}=await Lr(async()=>{const{diagram:t}=await import("./blockDiagram-c4efeb88-NvaZhZFT-jebni1KA.js");return{diagram:t}},__vite__mapDeps([31,8,4,9,10,11,30]));return{id:jZ,diagram:e}},eTe={id:jZ,detector:QAe,loader:JAe},tTe=eTe;let EF=!1;const c9=()=>{EF||(EF=!0,Gg("error",PAe,e=>e.toLowerCase().trim()==="error"),Gg("---",{db:{clear:()=>{}},styles:{},renderer:{draw:()=>{}},parser:{parser:{yy:{}},parse:()=>{throw new Error("Diagrams beginning with --- are not valid. If you were trying to use a YAML front-matter, please ensure that you've correctly opened and closed the YAML front-matter with un-indented `---` blocks")}},init:()=>null},e=>e.toLowerCase().trimStart().startsWith("---")),oZ(r9e,Q9e,K9e,f9e,S9e,_9e,C9e,j9e,q9e,zAe,c9e,o9e,WAe,HAe,b9e,oAe,rAe,cAe,R9e,XAe,D9e,tTe))};class $Z{constructor(t,r={}){this.text=t,this.metadata=r,this.type="graph",this.text=G_e(t),this.text+=`
897
897
  `;const n=Bo();try{this.type=Pb(t,n)}catch(i){this.type="error",this.detectError=i}const a=u9(this.type);It.debug("Type "+this.type),this.db=a.db,this.renderer=a.renderer,this.parser=a.parser,this.parser.parser.yy=this.db,this.init=a.init,this.parse()}parse(){var t,r,n,a,i;if(this.detectError)throw this.detectError;(r=(t=this.db).clear)==null||r.call(t);const o=Bo();(n=this.init)==null||n.call(this,o),this.metadata.title&&((i=(a=this.db).setDiagramTitle)==null||i.call(a,this.metadata.title)),this.parser.parse(this.text)}async render(t,r){await this.renderer.draw(this.text,t,r,this)}getParser(){return this.parser}getType(){return this.type}}const rTe=async(e,t={})=>{const r=Pb(e,Bo());try{u9(r)}catch{const n=v_e(r);if(!n)throw new iZ(`Diagram ${r} not found.`);const{id:a,diagram:i}=await n();Gg(a,i)}return new $Z(e,t)};let _F=[];const nTe=()=>{_F.forEach(e=>{e()}),_F=[]},aTe="graphics-document document";function iTe(e,t){e.attr("role",aTe),t!==""&&e.attr("aria-roledescription",t)}function oTe(e,t,r,n){if(e.insert!==void 0){if(r){const a=`chart-desc-${n}`;e.attr("aria-describedby",a),e.insert("desc",":first-child").attr("id",a).text(r)}if(t){const a=`chart-title-${n}`;e.attr("aria-labelledby",a),e.insert("title",":first-child").attr("id",a).text(t)}}}const sTe=e=>e.replace(/^\s*%%(?!{)[^\n]+\n?/gm,"").trimStart();/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */function UZ(e){return typeof e>"u"||e===null}function lTe(e){return typeof e=="object"&&e!==null}function uTe(e){return Array.isArray(e)?e:UZ(e)?[]:[e]}function cTe(e,t){var r,n,a,i;if(t)for(i=Object.keys(t),r=0,n=i.length;r<n;r+=1)a=i[r],e[a]=t[a];return e}function dTe(e,t){var r="",n;for(n=0;n<t;n+=1)r+=e;return r}function pTe(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var hTe=UZ,fTe=lTe,mTe=uTe,gTe=dTe,yTe=pTe,bTe=cTe,Ea={isNothing:hTe,isObject:fTe,toArray:mTe,repeat:gTe,isNegativeZero:yTe,extend:bTe};function HZ(e,t){var r="",n=e.reason||"(unknown reason)";return e.mark?(e.mark.name&&(r+='in "'+e.mark.name+'" '),r+="("+(e.mark.line+1)+":"+(e.mark.column+1)+")",!t&&e.mark.snippet&&(r+=`
898
898
 
899
899
  `+e.mark.snippet),n+" "+r):n}function Zp(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=HZ(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}Zp.prototype=Object.create(Error.prototype);Zp.prototype.constructor=Zp;Zp.prototype.toString=function(e){return this.name+": "+HZ(this,e)};var fs=Zp;function s7(e,t,r,n,a){var i="",o="",s=Math.floor(a/2)-1;return n-t>s&&(i=" ... ",t=n-s+i.length),r-n>s&&(o=" ...",r=n+s-o.length),{str:i+e.slice(t,r).replace(/\t/g,"→")+o,pos:n-t+i.length}}function l7(e,t){return Ea.repeat(" ",t-e.length)+e}function vTe(e,t){if(t=Object.create(t||null),!e.buffer)return null;t.maxLength||(t.maxLength=79),typeof t.indent!="number"&&(t.indent=1),typeof t.linesBefore!="number"&&(t.linesBefore=3),typeof t.linesAfter!="number"&&(t.linesAfter=2);for(var r=/\r?\n|\r|\0/g,n=[0],a=[],i,o=-1;i=r.exec(e.buffer);)a.push(i.index),n.push(i.index+i[0].length),e.position<=i.index&&o<0&&(o=n.length-2);o<0&&(o=n.length-1);var s="",l,u,c=Math.min(e.line+t.linesAfter,a.length).toString().length,d=t.maxLength-(t.indent+c+3);for(l=1;l<=t.linesBefore&&!(o-l<0);l++)u=s7(e.buffer,n[o-l],a[o-l],e.position-(n[o]-n[o-l]),d),s=Ea.repeat(" ",t.indent)+l7((e.line-l+1).toString(),c)+" | "+u.str+`
@@ -987,9 +987,9 @@ ${e.themeCSS}`),e.fontFamily!==void 0&&(n+=`
987
987
  * This source code is licensed under the MIT license found in the
988
988
  * LICENSE file in the root directory of this source tree.
989
989
  */var gU;function Eqe(){if(gU)return E7;gU=1;var e=Vn;function t(l,u){return l===u&&(l!==0||1/l===1/u)||l!==l&&u!==u}var r=typeof Object.is=="function"?Object.is:t,n=e.useSyncExternalStore,a=e.useRef,i=e.useEffect,o=e.useMemo,s=e.useDebugValue;return E7.useSyncExternalStoreWithSelector=function(l,u,c,d,p){var h=a(null);if(h.current===null){var g={hasValue:!1,value:null};h.current=g}else g=h.current;h=o(function(){function w(I){if(!x){if(x=!0,v=I,I=d(I),p!==void 0&&g.hasValue){var _=g.value;if(p(_,I))return k=_}return k=I}if(_=k,r(v,I))return _;var P=d(I);return p!==void 0&&p(_,P)?(v=I,_):(v=I,k=P)}var x=!1,v,k,T=c===void 0?null:c;return[function(){return w(u())},T===null?void 0:function(){return w(T())}]},[u,c,d,p]);var b=n(l,h[0],h[1]);return i(function(){g.hasValue=!0,g.value=b},[b]),s(b),b},E7}var yU;function _qe(){return yU||(yU=1,mU.exports=Eqe()),mU.exports}_qe();function Aqe(e){e()}function Tqe(){let e=null,t=null;return{clear(){e=null,t=null},notify(){Aqe(()=>{let r=e;for(;r;)r.callback(),r=r.next})},get(){const r=[];let n=e;for(;n;)r.push(n),n=n.next;return r},subscribe(r){let n=!0;const a=t={callback:r,next:null,prev:t};return a.prev?a.prev.next=a:e=a,function(){!n||e===null||(n=!1,a.next?a.next.prev=a.prev:t=a.prev,a.prev?a.prev.next=a.next:e=a.next)}}}}var bU={notify(){},get:()=>[]};function Cqe(e,t){let r,n=bU,a=0,i=!1;function o(b){c();const w=n.subscribe(b);let x=!1;return()=>{x||(x=!0,w(),d())}}function s(){n.notify()}function l(){g.onStateChange&&g.onStateChange()}function u(){return i}function c(){a++,r||(r=e.subscribe(l),n=Tqe())}function d(){a--,r&&a===0&&(r(),r=void 0,n.clear(),n=bU)}function p(){i||(i=!0,c())}function h(){i&&(i=!1,d())}const g={addNestedSub:o,notifyNestedSubs:s,handleChangeWrapper:l,isSubscribed:u,trySubscribe:p,tryUnsubscribe:h,getListeners:()=>n};return g}var Iqe=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Oqe=Iqe(),Nqe=()=>typeof navigator<"u"&&navigator.product==="ReactNative",Rqe=Nqe(),Mqe=()=>Oqe||Rqe?E.useLayoutEffect:E.useEffect,Lqe=Mqe(),vU=Symbol.for("react-redux-context"),xU=typeof globalThis<"u"?globalThis:{};function Pqe(){if(!E.createContext)return{};const e=xU[vU]??(xU[vU]=new Map);let t=e.get(E.createContext);return t||(t=E.createContext(null),e.set(E.createContext,t)),t}var Dqe=Pqe();function Fqe(e){const{children:t,context:r,serverState:n,store:a}=e,i=E.useMemo(()=>{const l=Cqe(a);return{store:a,subscription:l,getServerState:n?()=>n:void 0}},[a,n]),o=E.useMemo(()=>a.getState(),[a]);Lqe(()=>{const{subscription:l}=i;return l.onStateChange=l.notifyNestedSubs,l.trySubscribe(),o!==a.getState()&&l.notifyNestedSubs(),()=>{l.tryUnsubscribe(),l.onStateChange=void 0}},[i,o]);const s=r||Dqe;return E.createElement(s.Provider,{value:i},t)}var Bqe=Fqe,zqe=(e,t)=>t,CA=Ie([zqe,er,YQ,zn,zJ,Zs,mDe,Bn],SDe),IA=e=>{var t=e.currentTarget.getBoundingClientRect(),r=t.width/e.currentTarget.offsetWidth,n=t.height/e.currentTarget.offsetHeight;return{chartX:Math.round((e.clientX-t.left)/r),chartY:Math.round((e.clientY-t.top)/n)}},Qee=Vi("mouseClick"),Jee=Nh();Jee.startListening({actionCreator:Qee,effect:(e,t)=>{var r=e.payload,n=CA(t.getState(),IA(r));(n==null?void 0:n.activeIndex)!=null&&t.dispatch(bPe({activeIndex:n.activeIndex,activeDataKey:void 0,activeCoordinate:n.activeCoordinate}))}});var m8=Vi("mouseMove"),ete=Nh();ete.startListening({actionCreator:m8,effect:(e,t)=>{var r=e.payload,n=t.getState(),a=uA(n,n.tooltip.settings.shared),i=CA(n,IA(r));a==="axis"&&((i==null?void 0:i.activeIndex)!=null?t.dispatch(OJ({activeIndex:i.activeIndex,activeDataKey:void 0,activeCoordinate:i.activeCoordinate})):t.dispatch(IJ()))}});var wU={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,barSize:void 0,className:void 0,maxBarSize:void 0,stackOffset:"none",syncId:void 0,syncMethod:"index",baseValue:void 0},tte=ti({name:"rootProps",initialState:wU,reducers:{updateOptions:(e,t)=>{var r;e.accessibilityLayer=t.payload.accessibilityLayer,e.barCategoryGap=t.payload.barCategoryGap,e.barGap=(r=t.payload.barGap)!==null&&r!==void 0?r:wU.barGap,e.barSize=t.payload.barSize,e.maxBarSize=t.payload.maxBarSize,e.stackOffset=t.payload.stackOffset,e.syncId=t.payload.syncId,e.syncMethod=t.payload.syncMethod,e.className=t.payload.className,e.baseValue=t.payload.baseValue}}}),jqe=tte.reducer,{updateOptions:$qe}=tte.actions,rte=ti({name:"polarOptions",initialState:null,reducers:{updatePolarOptions:(e,t)=>t.payload}}),{updatePolarOptions:Uqe}=rte.actions,Hqe=rte.reducer,nte=Vi("keyDown"),ate=Vi("focus"),OA=Nh();OA.startListening({actionCreator:nte,effect:(e,t)=>{var r=t.getState(),n=r.rootProps.accessibilityLayer!==!1;if(n){var{keyboardInteraction:a}=r.tooltip,i=e.payload;if(!(i!=="ArrowRight"&&i!=="ArrowLeft"&&i!=="Enter")){var o=Number(cA(a,ed(r))),s=Zs(r);if(i==="Enter"){var l=hy(r,"axis","hover",String(a.index));t.dispatch(Jk({active:!a.active,activeIndex:a.index,activeDataKey:a.dataKey,activeCoordinate:l}));return}var u=uPe(r),c=u==="left-to-right"?1:-1,d=i==="ArrowRight"?1:-1,p=o+d*c;if(!(s==null||p>=s.length||p<0)){var h=hy(r,"axis","hover",String(p));t.dispatch(Jk({active:!0,activeIndex:p.toString(),activeDataKey:void 0,activeCoordinate:h}))}}}}});OA.startListening({actionCreator:ate,effect:(e,t)=>{var r=t.getState(),n=r.rootProps.accessibilityLayer!==!1;if(n){var{keyboardInteraction:a}=r.tooltip;if(!a.active&&a.index==null){var i="0",o=hy(r,"axis","hover",String(i));t.dispatch(Jk({activeDataKey:void 0,active:!0,activeIndex:i,activeCoordinate:o}))}}}});var Ci=Vi("externalEvent"),ite=Nh();ite.startListening({actionCreator:Ci,effect:(e,t)=>{if(e.payload.handler!=null){var r=t.getState(),n={activeCoordinate:eDe(r),activeDataKey:HJ(r),activeIndex:$s(r),activeLabel:UJ(r),activeTooltipIndex:$s(r),isTooltipActive:tDe(r)};e.payload.handler(n,e.payload.reactEvent)}}});var qqe=Ie([J0],e=>e.tooltipItemPayloads),Gqe=Ie([qqe,Bh,(e,t,r)=>t,(e,t,r)=>r],(e,t,r,n)=>{var a=e.find(s=>s.settings.dataKey===n);if(a!=null){var{positions:i}=a;if(i!=null){var o=t(i,r);return o}}}),ote=Vi("touchMove"),ste=Nh();ste.startListening({actionCreator:ote,effect:(e,t)=>{var r=e.payload;if(!(r.touches==null||r.touches.length===0)){var n=t.getState(),a=uA(n,n.tooltip.settings.shared);if(a==="axis"){var i=CA(n,IA({clientX:r.touches[0].clientX,clientY:r.touches[0].clientY,currentTarget:r.currentTarget}));(i==null?void 0:i.activeIndex)!=null&&t.dispatch(OJ({activeIndex:i.activeIndex,activeDataKey:void 0,activeCoordinate:i.activeCoordinate}))}else if(a==="item"){var o,s=r.touches[0];if(document.elementFromPoint==null)return;var l=document.elementFromPoint(s.clientX,s.clientY);if(!l||!l.getAttribute)return;var u=l.getAttribute(C9),c=(o=l.getAttribute(I9))!==null&&o!==void 0?o:void 0,d=Gqe(t.getState(),u,c);t.dispatch(CJ({activeDataKey:c,activeIndex:u,activeCoordinate:d}))}}}});var Vqe=RX({brush:b$e,cartesianAxis:Xze,chartData:JDe,errorBars:gje,graphicalItems:lze,layout:mRe,legend:p6e,options:KDe,polarAxis:kBe,polarOptions:Hqe,referenceElements:I$e,rootProps:jqe,tooltip:vPe,zIndex:DDe}),Wqe=function(e){return jNe({reducer:Vqe,preloadedState:e,middleware:t=>t({serializableCheck:!1}).concat([Jee.middleware,ete.middleware,OA.middleware,ite.middleware,ste.middleware]),enhancers:t=>{var r=t;return typeof t=="function"&&(r=t()),r.concat(qX({type:"raf"}))},devTools:Yo.devToolsEnabled})};function lte(e){var{preloadedState:t,children:r,reduxStoreName:n}=e,a=xn(),i=E.useRef(null);if(a)return r;i.current==null&&(i.current=Wqe(t));var o=S9;return E.createElement(Bqe,{context:o,store:i.current},r)}function ute(e){var{layout:t,margin:r}=e,n=Pr(),a=xn();return E.useEffect(()=>{a||(n(pRe(t)),n(dRe(r)))},[n,a,t,r]),null}function cte(e){var t=Pr();return E.useEffect(()=>{t($qe(e))},[t,e]),null}function SU(e){var{zIndex:t,isPanorama:r}=e,n=r?"recharts-zindex-panorama-":"recharts-zindex-",a=wee("".concat(n).concat(t)),i=Pr();return E.useLayoutEffect(()=>(i(LDe({zIndex:t,elementId:a,isPanorama:r})),()=>{i(PDe({zIndex:t,isPanorama:r}))}),[i,t,a,r]),E.createElement("g",{id:a})}function kU(e){var{children:t,isPanorama:r}=e,n=yt(EDe);if(!n||n.length===0)return t;var a=n.filter(o=>o<0),i=n.filter(o=>o>0);return E.createElement(E.Fragment,null,a.map(o=>E.createElement(SU,{key:o,zIndex:o,isPanorama:r})),t,i.map(o=>E.createElement(SU,{key:o,zIndex:o,isPanorama:r})))}var Kqe=["children"];function Yqe(e,t){if(e==null)return{};var r,n,a=Zqe(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}function Zqe(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}function Ay(){return Ay=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Ay.apply(null,arguments)}var Xqe={width:"100%",height:"100%",display:"block"},Qqe=E.forwardRef((e,t)=>{var r=R9(),n=M9(),a=gQ();if(!zo(r)||!zo(n))return null;var{children:i,otherAttributes:o,title:s,desc:l}=e,u,c;return o!=null&&(typeof o.tabIndex=="number"?u=o.tabIndex:u=a?0:void 0,typeof o.role=="string"?c=o.role:c=a?"application":void 0),E.createElement(g9,Ay({},o,{title:s,desc:l,role:c,tabIndex:u,width:r,height:n,style:Xqe,ref:t}),i)}),Jqe=e=>{var{children:t}=e,r=yt(Kb);if(!r)return null;var{width:n,height:a,y:i,x:o}=r;return E.createElement(g9,{width:n,height:a,x:o,y:i},t)},EU=E.forwardRef((e,t)=>{var{children:r}=e,n=Yqe(e,Kqe),a=xn();return a?E.createElement(Jqe,null,E.createElement(kU,{isPanorama:!0},r)):E.createElement(Qqe,Ay({ref:t},n),E.createElement(kU,{isPanorama:!1},r))});function eGe(){var e=Pr(),[t,r]=E.useState(null),n=yt(RRe);return E.useEffect(()=>{if(t!=null){var a=t.getBoundingClientRect(),i=a.width/t.offsetWidth;Ar(i)&&i!==n&&e(fRe(i))}},[t,e,n]),r}function _U(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function tGe(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?_U(Object(r),!0).forEach(function(n){rGe(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):_U(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function rGe(e,t,r){return(t=nGe(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function nGe(e){var t=aGe(e,"string");return typeof t=="symbol"?t:t+""}function aGe(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Wu(){return Wu=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Wu.apply(null,arguments)}var iGe=()=>(lFe(),null);function Ty(e){if(typeof e=="number")return e;if(typeof e=="string"){var t=parseFloat(e);if(!Number.isNaN(t))return t}return 0}var oGe=E.forwardRef((e,t)=>{var r,n,a=E.useRef(null),[i,o]=E.useState({containerWidth:Ty((r=e.style)===null||r===void 0?void 0:r.width),containerHeight:Ty((n=e.style)===null||n===void 0?void 0:n.height)}),s=E.useCallback((u,c)=>{o(d=>{var p=Math.round(u),h=Math.round(c);return d.containerWidth===p&&d.containerHeight===h?d:{containerWidth:p,containerHeight:h}})},[]),l=E.useCallback(u=>{if(typeof t=="function"&&t(u),u!=null&&typeof ResizeObserver<"u"){var{width:c,height:d}=u.getBoundingClientRect();s(c,d);var p=g=>{var{width:b,height:w}=g[0].contentRect;s(b,w)},h=new ResizeObserver(p);h.observe(u),a.current=h}},[t,s]);return E.useEffect(()=>()=>{var u=a.current;u!=null&&u.disconnect()},[s]),E.createElement(E.Fragment,null,E.createElement(Yb,{width:i.containerWidth,height:i.containerHeight}),E.createElement("div",Wu({ref:l},e)))}),sGe=E.forwardRef((e,t)=>{var{width:r,height:n}=e,[a,i]=E.useState({containerWidth:Ty(r),containerHeight:Ty(n)}),o=E.useCallback((l,u)=>{i(c=>{var d=Math.round(l),p=Math.round(u);return c.containerWidth===d&&c.containerHeight===p?c:{containerWidth:d,containerHeight:p}})},[]),s=E.useCallback(l=>{if(typeof t=="function"&&t(l),l!=null){var{width:u,height:c}=l.getBoundingClientRect();o(u,c)}},[t,o]);return E.createElement(E.Fragment,null,E.createElement(Yb,{width:a.containerWidth,height:a.containerHeight}),E.createElement("div",Wu({ref:s},e)))}),lGe=E.forwardRef((e,t)=>{var{width:r,height:n}=e;return E.createElement(E.Fragment,null,E.createElement(Yb,{width:r,height:n}),E.createElement("div",Wu({ref:t},e)))}),uGe=E.forwardRef((e,t)=>{var{width:r,height:n}=e;return Bs(r)||Bs(n)?E.createElement(sGe,Wu({},e,{ref:t})):E.createElement(lGe,Wu({},e,{ref:t}))});function cGe(e){return e===!0?oGe:uGe}var dGe=E.forwardRef((e,t)=>{var{children:r,className:n,height:a,onClick:i,onContextMenu:o,onDoubleClick:s,onMouseDown:l,onMouseEnter:u,onMouseLeave:c,onMouseMove:d,onMouseUp:p,onTouchEnd:h,onTouchMove:g,onTouchStart:b,style:w,width:x,responsive:v,dispatchTouchEvents:k=!0}=e,T=E.useRef(null),I=Pr(),[_,P]=E.useState(null),[z,j]=E.useState(null),D=eGe(),B=N9(),J=(B==null?void 0:B.width)>0?B.width:x,ye=(B==null?void 0:B.height)>0?B.height:a,ee=E.useCallback(me=>{D(me),typeof t=="function"&&t(me),P(me),j(me),me!=null&&(T.current=me)},[D,t,P,j]),ie=E.useCallback(me=>{I(Qee(me)),I(Ci({handler:i,reactEvent:me}))},[I,i]),se=E.useCallback(me=>{I(m8(me)),I(Ci({handler:u,reactEvent:me}))},[I,u]),ue=E.useCallback(me=>{I(IJ()),I(Ci({handler:c,reactEvent:me}))},[I,c]),Q=E.useCallback(me=>{I(m8(me)),I(Ci({handler:d,reactEvent:me}))},[I,d]),te=E.useCallback(()=>{I(ate())},[I]),H=E.useCallback(me=>{I(nte(me.key))},[I]),le=E.useCallback(me=>{I(Ci({handler:o,reactEvent:me}))},[I,o]),ve=E.useCallback(me=>{I(Ci({handler:s,reactEvent:me}))},[I,s]),V=E.useCallback(me=>{I(Ci({handler:l,reactEvent:me}))},[I,l]),ge=E.useCallback(me=>{I(Ci({handler:p,reactEvent:me}))},[I,p]),ke=E.useCallback(me=>{I(Ci({handler:b,reactEvent:me}))},[I,b]),ze=E.useCallback(me=>{k&&I(ote(me)),I(Ci({handler:g,reactEvent:me}))},[I,k,g]),Ee=E.useCallback(me=>{I(Ci({handler:h,reactEvent:me}))},[I,h]),Ve=cGe(v);return E.createElement(QJ.Provider,{value:_},E.createElement(cX.Provider,{value:z},E.createElement(Ve,{width:J??(w==null?void 0:w.width),height:ye??(w==null?void 0:w.height),className:rr("recharts-wrapper",n),style:tGe({position:"relative",cursor:"default",width:J,height:ye},w),onClick:ie,onContextMenu:le,onDoubleClick:ve,onFocus:te,onKeyDown:H,onMouseDown:V,onMouseEnter:se,onMouseLeave:ue,onMouseMove:Q,onMouseUp:ge,onTouchEnd:Ee,onTouchMove:ze,onTouchStart:ke,ref:ee},E.createElement(iGe,null),r)))}),pGe=["width","height","responsive","children","className","style","compact","title","desc"];function hGe(e,t){if(e==null)return{};var r,n,a=fGe(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}function fGe(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}var dte=E.forwardRef((e,t)=>{var{width:r,height:n,responsive:a,children:i,className:o,style:s,compact:l,title:u,desc:c}=e,d=hGe(e,pGe),p=na(d);return l?E.createElement(E.Fragment,null,E.createElement(Yb,{width:r,height:n}),E.createElement(EU,{otherAttributes:p,title:u,desc:c},i)):E.createElement(dGe,{className:o,style:s,width:r,height:n,responsive:a??!1,onClick:e.onClick,onMouseLeave:e.onMouseLeave,onMouseEnter:e.onMouseEnter,onMouseMove:e.onMouseMove,onMouseDown:e.onMouseDown,onMouseUp:e.onMouseUp,onContextMenu:e.onContextMenu,onDoubleClick:e.onDoubleClick,onTouchStart:e.onTouchStart,onTouchMove:e.onTouchMove,onTouchEnd:e.onTouchEnd},E.createElement(EU,{otherAttributes:p,title:u,desc:c,ref:t},E.createElement(O$e,null,i)))});function g8(){return g8=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},g8.apply(null,arguments)}var mGe={top:5,right:5,bottom:5,left:5},gGe={accessibilityLayer:!0,layout:"horizontal",stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:mGe,reverseStackOrder:!1,syncMethod:"index",responsive:!1},Gh=E.forwardRef(function(e,t){var r,n=Wr(e.categoricalChartProps,gGe),{chartName:a,defaultTooltipEventType:i,validateTooltipEventTypes:o,tooltipPayloadSearcher:s,categoricalChartProps:l}=e,u={chartName:a,defaultTooltipEventType:i,validateTooltipEventTypes:o,tooltipPayloadSearcher:s,eventEmitter:void 0};return E.createElement(lte,{preloadedState:{options:u},reduxStoreName:(r=l.id)!==null&&r!==void 0?r:a},E.createElement(Iee,{chartData:l.data}),E.createElement(ute,{layout:n.layout,margin:n.margin}),E.createElement(cte,{baseValue:n.baseValue,accessibilityLayer:n.accessibilityLayer,barCategoryGap:n.barCategoryGap,maxBarSize:n.maxBarSize,stackOffset:n.stackOffset,barGap:n.barGap,barSize:n.barSize,syncId:n.syncId,syncMethod:n.syncMethod,className:n.className}),E.createElement(dte,g8({},n,{ref:t})))}),yGe=["axis"],bGe=E.forwardRef((e,t)=>E.createElement(Gh,{chartName:"LineChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:yGe,tooltipPayloadSearcher:td,categoricalChartProps:e,ref:t})),vGe=["axis","item"],xGe=E.forwardRef((e,t)=>E.createElement(Gh,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:vGe,tooltipPayloadSearcher:td,categoricalChartProps:e,ref:t}));function wGe(e){var t=Pr();return E.useEffect(()=>{t(Uqe(e))},[t,e]),null}var SGe=["layout"];function y8(){return y8=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},y8.apply(null,arguments)}function kGe(e,t){if(e==null)return{};var r,n,a=EGe(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}function EGe(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}var _Ge={top:5,right:5,bottom:5,left:5},AGe={accessibilityLayer:!0,stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:_Ge,reverseStackOrder:!1,syncMethod:"index",layout:"radial",responsive:!1},TGe=E.forwardRef(function(e,t){var r,n=Wr(e.categoricalChartProps,AGe),{layout:a}=n,i=kGe(n,SGe),{chartName:o,defaultTooltipEventType:s,validateTooltipEventTypes:l,tooltipPayloadSearcher:u}=e,c={chartName:o,defaultTooltipEventType:s,validateTooltipEventTypes:l,tooltipPayloadSearcher:u,eventEmitter:void 0};return E.createElement(lte,{preloadedState:{options:c},reduxStoreName:(r=n.id)!==null&&r!==void 0?r:o},E.createElement(Iee,{chartData:n.data}),E.createElement(ute,{layout:a,margin:n.margin}),E.createElement(cte,{baseValue:void 0,accessibilityLayer:n.accessibilityLayer,barCategoryGap:n.barCategoryGap,maxBarSize:n.maxBarSize,stackOffset:n.stackOffset,barGap:n.barGap,barSize:n.barSize,syncId:n.syncId,syncMethod:n.syncMethod,className:n.className}),E.createElement(wGe,{cx:n.cx,cy:n.cy,startAngle:n.startAngle,endAngle:n.endAngle,innerRadius:n.innerRadius,outerRadius:n.outerRadius}),E.createElement(dte,y8({},i,{ref:t})))}),CGe=["item"],IGe={layout:"centric",startAngle:0,endAngle:360,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"},OGe=E.forwardRef((e,t)=>{var r=Wr(e,IGe);return E.createElement(TGe,{chartName:"PieChart",defaultTooltipEventType:"item",validateTooltipEventTypes:CGe,tooltipPayloadSearcher:td,categoricalChartProps:r,ref:t})}),NGe=["item"],RGe=E.forwardRef((e,t)=>E.createElement(Gh,{chartName:"ScatterChart",defaultTooltipEventType:"item",validateTooltipEventTypes:NGe,tooltipPayloadSearcher:td,categoricalChartProps:e,ref:t})),MGe=["axis"],LGe=E.forwardRef((e,t)=>E.createElement(Gh,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:MGe,tooltipPayloadSearcher:td,categoricalChartProps:e,ref:t})),PGe=["axis"],DGe=E.forwardRef((e,t)=>E.createElement(Gh,{chartName:"ComposedChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:PGe,tooltipPayloadSearcher:td,categoricalChartProps:e,ref:t}));const b8=["#3b82f6","#8b5cf6","#ec4899","#f59e0b","#10b981","#06b6d4","#6366f1","#ef4444"],gp=e=>{try{return JSON.parse(e)}catch{return null}},AU=e=>e.replace(/^['"]|['"]$/g,""),_7=e=>{const t=e.trim();return t?gp(t)||(t.startsWith("[")&&t.endsWith("]")?t.slice(1,-1).split(",").map(n=>AU(n.trim())).filter(Boolean):t.split(",").map(n=>AU(n.trim())).filter(Boolean)):[]},A7=e=>{const t=e.trim().replace(/px$/i,"");if(!t)return;const r=Number(t);return Number.isNaN(r)?void 0:r},FGe=e=>{const t=e.trim();return t?gp(t)||{format:t}:void 0},TU=(e,t,r)=>{const n=t.trim();if(!n)return;const a=r.trim();if(!a.length)return;const i=n.toLowerCase(),o=a.toLowerCase(),s=()=>(e.formatter||(e.formatter={}),e.formatter);switch(i){case"type":e.type=a;return;case"title":e.title=a;return;case"description":e.description=a;return;case"xaxislabel":e.xAxisLabel=a;return;case"yaxislabel":e.yAxisLabel=a;return;case"yaxisrightlabel":e.yAxisRightLabel=a;return;case"stacked":e.stacked=o==="true";return;case"showlegend":e.showLegend=o==="true";return;case"showgrid":e.showGrid=o==="true";return;case"height":{const l=A7(a);typeof l=="number"&&(e.height=l);return}case"width":{const l=A7(a);typeof l=="number"&&(e.width=l);return}case"xkey":e.xKey=a;return;case"valueformat":{const l=s();l.format=a;return}case"valueprefix":{const l=s();l.prefix=a;return}case"valuesuffix":{const l=s();l.suffix=a;return}case"valuecurrency":{const l=s();l.currency=a;return}case"valuedecimals":{const l=A7(a);if(typeof l=="number"){const u=s();u.decimals=l}return}case"formatter":{const l=FGe(a);l&&(e.formatter={...e.formatter,...l});return}case"colors":e.colors=_7(a);return;case"labels":e.labels=_7(a);return;case"datakeys":e.dataKeys=_7(a);return;case"data":{const l=gp(a);l&&(e.data=l);return}case"series":{const l=gp(a);l&&(e.series=l);return}case"referencelines":{const l=gp(a);l&&(e.referenceLines=l);return}default:return}},BGe=(e,t)=>{try{if(t==="chart-json")return JSON.parse(e);const r=e.trim().split(`
990
- `),n={colors:b8};if(r.some(a=>a.includes("|"))){const a=r.filter(s=>s.includes("|")),i=a[0].split("|").map(s=>s.trim()).filter(Boolean),o=a.slice(2);n.data=o.map(s=>{const l=s.split("|").map(c=>c.trim()).filter(Boolean);if(!l.length)return null;const u={};return i.forEach((c,d)=>{const p=l[d];typeof p>"u"||(u[c]=p!==""&&!Number.isNaN(Number(p))?Number(p):p)}),u}).filter(Boolean),n.xKey=i[0],n.dataKeys=i.slice(1);for(const s of r){if(s.includes("|"))break;const[l,...u]=s.split(":");!l||!u.length||TU(n,l,u.join(":"))}}else{for(const a of r){const[i,...o]=a.split(":");!i||!o.length||TU(n,i,o.join(":"))}if(Array.isArray(n.data)&&typeof n.data[0]=="number"){const a=n.labels||n.data.map((i,o)=>`Item ${o+1}`);n.data=n.data.map((i,o)=>({name:a[o],value:i})),n.xKey="name",n.dataKeys=["value"]}}return n.data=n.data??[],(!n.colors||n.colors.length===0)&&(n.colors=b8),n}catch(r){return console.error("Failed to parse chart config:",r),null}},CU=(e,t)=>{if(typeof e!="number"||Number.isNaN(e))return e??"";if(!t)return new Intl.NumberFormat().format(e);const{format:r="number",currency:n="USD",decimals:a,minimumFractionDigits:i,maximumFractionDigits:o,prefix:s="",suffix:l=""}=t,u={};typeof a=="number"&&!Number.isNaN(a)?(u.minimumFractionDigits=a,u.maximumFractionDigits=a):(typeof i=="number"&&(u.minimumFractionDigits=i),typeof o=="number"&&(u.maximumFractionDigits=o)),r==="currency"?(u.style="currency",u.currency=n||"USD"):r==="percent"?u.style="percent":r==="compact"?u.notation="compact":u.maximumFractionDigits||(u.maximumFractionDigits=2);const c=new Intl.NumberFormat(void 0,u).format(e);return`${s}${c}${l}`},zGe=(e,t)=>{const r=e.dataKeys&&e.dataKeys.length?e.dataKeys.map(i=>({key:i})):[{key:"value"}],n=(e.series&&e.series.length?e.series:r).filter(i=>!!i.key),a=e.type==="line"?"line":e.type==="area"?"area":e.type==="scatter"?"scatter":"bar";return n.map((i,o)=>{const s=e.type==="composed"&&i.type||a;return{...i,type:s,key:i.key,name:i.name??i.key,color:i.color??t[o%t.length],yAxisId:i.yAxisId??"left",stackId:typeof i.stackId<"u"?i.stackId:e.stacked?"stack":void 0,strokeWidth:i.strokeWidth??(s==="line"?2:1),dot:typeof i.dot=="boolean"?i.dot:!0,opacity:i.opacity??(s==="area"?.55:1)}})},jGe=e=>e!=null&&e.length?e.filter(t=>typeof t.y<"u"||typeof t.x<"u").map((t,r)=>{const n=a=>a==="start"?"insideStart":a==="middle"?"middle":"end";return Be.jsx(Lee,{y:t.y,x:t.x,stroke:t.color||"#9ca3af",strokeDasharray:t.strokeDasharray||"4 4",label:t.label?{value:t.label,position:n(t.position),fill:t.color||"#4b5563"}:void 0},`reference-${r}`)}):null,IU=(e,t)=>{const r=e.filter(a=>a.yAxisId===t);if(!r.length)return;const n=r.map(a=>a.name||a.key).filter(a=>!!a);return n.length?Array.from(new Set(n)).join(" / "):void 0},ss=(e,t)=>{if(!e)return null;const r=t==="right"?20:-20,n=t==="right"?"insideRight":"insideLeft";return Be.jsx(ps,{value:e,angle:t==="right"?90:-90,position:n,style:{textAnchor:"middle",fill:"#374151",fontSize:12,fontWeight:500},offset:r})},$Ge=({code:e,language:t})=>{var r,n;const[a,i]=E.useState(null),[o,s]=E.useState(null);if(E.useEffect(()=>{const D=BGe(e,t);if(!D){s(null),i("Failed to parse chart configuration");return}if(!Array.isArray(D.data)||D.data.length===0){s(null),i("Chart data is empty");return}if(!D.type){s(null),i("Chart type is required (bar, line, pie, area, scatter, composed)");return}i(null),s(D)},[e,t]),a)return Be.jsxs("div",{className:"graph-error",children:[Be.jsx("div",{className:"graph-error-title",children:"Chart Rendering Error"}),Be.jsx("div",{className:"graph-error-message",children:a}),Be.jsx("pre",{style:{marginTop:"8px",fontSize:"0.8em",opacity:.7},children:Be.jsx("code",{children:e})})]});if(!o)return Be.jsx("div",{className:"graph-container chart-container",children:Be.jsx("div",{children:"Loading chart..."})});const l=o.colors&&o.colors.length?o.colors:b8,u=o.height||320,c=zGe(o,l),d=c.some(D=>D.yAxisId==="right"),p=o.showLegend??(o.type==="pie"||c.length>1),h=o.showGrid??!0,g=jGe(o.referenceLines),b=IU(c,"left"),w=IU(c,"right"),x=o.yAxisLabel??b??"Value",v=d?o.yAxisRightLabel??w??"Value":void 0,k={backgroundColor:"#ffffff",border:"1px solid #ccc",borderRadius:"4px",padding:"8px",color:"#000000"},T={color:"#000000",fontWeight:600,marginBottom:"4px"},I={color:"#000000"},_=(D,B)=>typeof D=="number"?[CU(D,o.formatter),B]:[D,B],P=D=>{if(typeof D!="number")return String(D??"");const B=CU(D,o.formatter);return String(B??"")},z=o.xAxisLabel?{value:o.xAxisLabel,position:"insideBottom",offset:-5}:void 0,j={left:x?80:10,right:v?80:10,top:10,bottom:20};return Be.jsxs("div",{className:"graph-container chart-container",style:{flexDirection:"column",alignItems:"stretch"},children:[o.title&&Be.jsx("h4",{style:{textAlign:"center",marginBottom:o.description?"4px":"12px",marginTop:0,color:"#000000",fontWeight:600},children:o.title}),o.description&&Be.jsx("p",{style:{textAlign:"center",marginTop:0,marginBottom:"12px",color:"#4b5563",fontSize:"0.9rem"},children:o.description}),Be.jsxs(o6e,{width:"100%",height:u,children:[o.type==="bar"&&Be.jsxs(xGe,{data:o.data,margin:j,children:[h&&Be.jsx(Ec,{strokeDasharray:"3 3"}),Be.jsx(_c,{dataKey:o.xKey||"name",label:z}),Be.jsx(wo,{yAxisId:"left",tickFormatter:P,children:ss(x,"left")}),d&&Be.jsx(wo,{yAxisId:"right",orientation:"right",tickFormatter:P,children:ss(v,"right")}),Be.jsx(wc,{contentStyle:k,labelStyle:T,itemStyle:I,formatter:_}),p&&Be.jsx(ou,{}),g,c.map(D=>Be.jsx(s8,{dataKey:D.key,fill:D.color,stackId:D.stackId,yAxisId:D.yAxisId,radius:[4,4,0,0]},D.key))]}),o.type==="line"&&Be.jsxs(bGe,{data:o.data,margin:j,children:[h&&Be.jsx(Ec,{strokeDasharray:"3 3"}),Be.jsx(_c,{dataKey:o.xKey||"name",label:z}),Be.jsx(wo,{yAxisId:"left",tickFormatter:P,children:ss(x,"left")}),d&&Be.jsx(wo,{yAxisId:"right",orientation:"right",tickFormatter:P,children:ss(v,"right")}),Be.jsx(wc,{contentStyle:k,labelStyle:T,itemStyle:I,formatter:_}),p&&Be.jsx(ou,{}),g,c.map(D=>Be.jsx(u8,{type:"monotone",dataKey:D.key,stroke:D.color,yAxisId:D.yAxisId,strokeWidth:D.strokeWidth,dot:D.dot},D.key))]}),o.type==="area"&&Be.jsxs(LGe,{data:o.data,margin:j,children:[h&&Be.jsx(Ec,{strokeDasharray:"3 3"}),Be.jsx(_c,{dataKey:o.xKey||"name",label:z}),Be.jsx(wo,{yAxisId:"left",tickFormatter:P,children:ss(x,"left")}),d&&Be.jsx(wo,{yAxisId:"right",orientation:"right",tickFormatter:P,children:ss(v,"right")}),Be.jsx(wc,{contentStyle:k,labelStyle:T,itemStyle:I,formatter:_}),p&&Be.jsx(ou,{}),g,c.map(D=>Be.jsx(c8,{type:"monotone",dataKey:D.key,stroke:D.color,yAxisId:D.yAxisId,fill:D.color,fillOpacity:D.opacity,stackId:D.stackId},D.key))]}),o.type==="composed"&&Be.jsxs(DGe,{data:o.data,margin:j,children:[h&&Be.jsx(Ec,{strokeDasharray:"3 3"}),Be.jsx(_c,{dataKey:o.xKey||"name",label:z}),Be.jsx(wo,{yAxisId:"left",tickFormatter:P,children:ss(x,"left")}),d&&Be.jsx(wo,{yAxisId:"right",orientation:"right",tickFormatter:P,children:ss(v,"right")}),Be.jsx(wc,{contentStyle:k,labelStyle:T,itemStyle:I,formatter:_}),p&&Be.jsx(ou,{}),g,c.map(D=>{switch(D.type){case"line":return Be.jsx(u8,{type:"monotone",dataKey:D.key,stroke:D.color,yAxisId:D.yAxisId,strokeWidth:D.strokeWidth,dot:D.dot},D.key);case"area":return Be.jsx(c8,{type:"monotone",dataKey:D.key,stroke:D.color,yAxisId:D.yAxisId,fill:D.color,fillOpacity:D.opacity,stackId:D.stackId},D.key);case"scatter":return Be.jsx(p8,{dataKey:D.key,fill:D.color,yAxisId:D.yAxisId},D.key);default:return Be.jsx(s8,{dataKey:D.key,fill:D.color,stackId:D.stackId,yAxisId:D.yAxisId,radius:[4,4,0,0]},D.key)}})]}),o.type==="pie"&&Be.jsxs(OGe,{children:[Be.jsx(kee,{data:o.data,dataKey:((r=o.dataKeys)==null?void 0:r[0])||"value",nameKey:o.xKey||"name",cx:"50%",cy:"50%",outerRadius:u/3,label:!0,children:o.data.map((D,B)=>Be.jsx(rd,{fill:l[B%l.length]},`cell-${B}`))}),Be.jsx(wc,{contentStyle:k,itemStyle:I,formatter:_}),p&&Be.jsx(ou,{})]}),o.type==="scatter"&&Be.jsxs(RGe,{margin:j,children:[h&&Be.jsx(Ec,{strokeDasharray:"3 3"}),Be.jsx(_c,{dataKey:o.xKey||"x",label:z}),Be.jsx(wo,{dataKey:((n=o.dataKeys)==null?void 0:n[0])||"y",tickFormatter:P,children:ss(x,"left")}),Be.jsx(wc,{contentStyle:k,labelStyle:T,itemStyle:I,formatter:_}),p&&Be.jsx(ou,{}),g,Be.jsx(p8,{name:"Data",data:o.data,fill:l[0]})]})]})]})},OU=({code:e})=>{const[t,r]=E.useState(!1),n=async()=>{try{await navigator.clipboard.writeText(e),r(!0),setTimeout(()=>r(!1),2e3)}catch{const a=document.createElement("textarea");a.value=e,a.style.position="fixed",a.style.opacity="0",document.body.appendChild(a),a.select();try{document.execCommand("copy"),r(!0),setTimeout(()=>r(!1),2e3)}catch(i){console.error("Failed to copy code:",i)}document.body.removeChild(a)}};return Be.jsxs("button",{className:"code-copy-button",onClick:n,title:t?"Copied!":"Copy code","aria-label":t?"Copied!":"Copy code to clipboard",children:[t?Be.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Be.jsx("path",{d:"M13.5 4.5L6 12L2.5 8.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}):Be.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[Be.jsx("path",{d:"M5.5 4.5H3.5C2.94772 4.5 2.5 4.94772 2.5 5.5V12.5C2.5 13.0523 2.94772 13.5 3.5 13.5H10.5C11.0523 13.5 11.5 13.0523 11.5 12.5V10.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),Be.jsx("path",{d:"M6.5 2.5H12.5C13.0523 2.5 13.5 2.94772 13.5 3.5V9.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),Be.jsx("path",{d:"M9.5 6.5L13.5 2.5L9.5 2.5V6.5Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),Be.jsx("span",{className:"code-copy-button-text",children:t?"Copied!":"Copy"})]})},UGe=({inline:e,className:t="",children:r,enableGraphs:n=!0,enableMermaid:a=!0,enablePlantUML:i=!0,enableSVG:o=!0,enableCharts:s=!0,plantUMLServerUrl:l,enableSyntaxHighlighting:u=!0,syntaxTheme:c="dark"})=>{if(e)return Be.jsx("code",{className:t,children:r});const d=/language-(\w+)/.exec(t||""),p=d?d[1].toLowerCase():"",h=String(r).replace(/\n$/,"");if(s&&(p==="chart"||p==="chart-json"||p==="chart-table"))return Be.jsx($Ge,{code:h,language:p});if(n){if(p==="mermaid"&&a)return Be.jsx(RIe,{code:h});if((p==="plantuml"||p==="puml")&&i)return Be.jsx(FIe,{code:h,serverUrl:l});if(p==="svg"&&o)return Be.jsx(BIe,{code:h})}if(u&&p){const g=c==="light"?o2e:s2e;return Be.jsxs("div",{className:"syntax-highlighted-wrapper code-block-container",children:[Be.jsx(OU,{code:h}),Be.jsx(qW,{language:p,style:g,customStyle:{margin:"12px 0",borderRadius:"6px",fontSize:"0.9em"},showLineNumbers:!1,children:h})]})}return Be.jsxs("div",{className:`markdown-code-block code-block-container ${t}`.trim(),children:[Be.jsx(OU,{code:h}),Be.jsx("pre",{style:{margin:0,padding:0,background:"transparent",border:"none"},children:Be.jsx("code",{children:h})})]})},NU=new Set(["div","pre","blockquote","ul","ol","table","thead","tbody","tr","td","th","h1","h2","h3","h4","h5","h6","section","article","figure"]),HGe=({children:e,href:t,...r})=>Be.jsx("a",{...r,href:t,target:"_blank",rel:"noopener noreferrer",children:e}),RU=({content:e,className:t="",disableMath:r=!1,enableGraphs:n=!0,enableMermaid:a=!0,enablePlantUML:i=!0,enableSVG:o=!0,enableCharts:s=!0,plantUMLServerUrl:l,enableSyntaxHighlighting:u=!0,syntaxTheme:c="dark"})=>{const d=Sfe(e);if(!d)return null;const p=r?[QO]:[QO,[sde,{singleDollarTextMath:!0}]],h=[];r||h.push([zde,{throwOnError:!1,errorColor:"#cc0000",strict:!1,trust:!0,macros:{"\\RR":"\\mathbb{R}","\\NN":"\\mathbb{N}","\\ZZ":"\\mathbb{Z}","\\QQ":"\\mathbb{Q}","\\CC":"\\mathbb{C}","\\dx":"\\,dx","\\dy":"\\,dy","\\dt":"\\,dt","\\dz":"\\,dz"}}]);const g={a:HGe,code:b=>{const{className:w,children:x,...v}=b,k=w&&/language-/.test(w),T="inline"in b&&typeof b.inline=="boolean"&&b.inline||!k,I=k;return Be.jsx(UGe,{inline:T,className:w,enableGraphs:n,enableMermaid:a,enablePlantUML:i,enableSVG:o,enableCharts:s,plantUMLServerUrl:l,enableSyntaxHighlighting:u,syntaxTheme:c,"data-block-code":I?"true":void 0,...v,children:x})},p:({node:b,...w})=>{var x;const v=Vn.Children.toArray(w.children).filter(T=>!(typeof T=="string"&&T.trim()==="")).some(T=>{var I;return Vn.isValidElement(T)?((I=T.props)==null?void 0:I["data-block-code"])==="true"?!0:typeof T.type=="string"?NU.has(T.type):!1:!1}),k=(x=b==null?void 0:b.children)==null?void 0:x.some(T=>{var I;if(T.type==="code")return!0;if(T.type==="element"){if(NU.has(T.tagName))return!0;if(T.tagName==="code"){const _=(I=T.properties)==null?void 0:I.className;return Array.isArray(_)?_.some(P=>typeof P=="string"&&P.startsWith("language-")):!0}}return!1});return v||k?Be.jsx(Be.Fragment,{children:w.children}):Be.jsx("p",{...w})}};return Be.jsx("div",{className:`markdown-content ${t}`,children:Be.jsx(Que,{remarkPlugins:p,rehypePlugins:h,components:g,children:d})})},MU="schmitech-markdown-renderer-styles",qGe=()=>{if(typeof document>"u"||document.getElementById(MU))return;const e=document.createElement("style");e.id=MU,e.textContent=Die,document.head.appendChild(e)};qGe();const mt=(...e)=>{},Yr=(...e)=>{},N0=(...e)=>{},$n=(...e)=>{console.error(...e)},GGe={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1,VITE_API_URL:"http://localhost:3000",VITE_CONSOLE_DEBUG:"false",VITE_DEFAULT_KEY:"default-key",VITE_ENABLE_AUDIO_OUTPUT:"true",VITE_ENABLE_CONVERSATION_THREADS:"true",VITE_ENABLE_FEEDBACK_BUTTONS:"false",VITE_ENABLE_UPLOAD_BUTTON:"true",VITE_GITHUB_OWNER:"schmitech",VITE_GITHUB_REPO:"orbit",VITE_LOCALE:"en-US",VITE_MAX_CONVERSATIONS:"10",VITE_MAX_FILES_PER_CONVERSATION:"5",VITE_MAX_FILE_SIZE_MB:"50",VITE_MAX_MESSAGES_PER_CONVERSATION:"1000",VITE_MAX_MESSAGE_LENGTH:"500",VITE_MAX_TOTAL_FILES:"100",VITE_MAX_TOTAL_MESSAGES:"10000",VITE_SHOW_GITHUB_STATS:"true",VITE_USE_LOCAL_API:"true"},Ku="http://localhost:3000";function VGe(e){return typeof e=="object"&&e!==null}const WGe={apiUrl:"VITE_API_URL",defaultKey:"VITE_DEFAULT_KEY",useLocalApi:"VITE_USE_LOCAL_API",localApiPath:"VITE_LOCAL_API_PATH",consoleDebug:"VITE_CONSOLE_DEBUG",enableUploadButton:"VITE_ENABLE_UPLOAD_BUTTON",enableAudioOutput:"VITE_ENABLE_AUDIO_OUTPUT",enableFeedbackButtons:"VITE_ENABLE_FEEDBACK_BUTTONS",enableConversationThreads:"VITE_ENABLE_CONVERSATION_THREADS",showGitHubStats:"VITE_SHOW_GITHUB_STATS",githubOwner:"VITE_GITHUB_OWNER",githubRepo:"VITE_GITHUB_REPO",maxFilesPerConversation:"VITE_MAX_FILES_PER_CONVERSATION",maxFileSizeMB:"VITE_MAX_FILE_SIZE_MB",maxTotalFiles:"VITE_MAX_TOTAL_FILES",maxConversations:"VITE_MAX_CONVERSATIONS",maxMessagesPerConversation:"VITE_MAX_MESSAGES_PER_CONVERSATION",maxTotalMessages:"VITE_MAX_TOTAL_MESSAGES",maxMessageLength:"VITE_MAX_MESSAGE_LENGTH"};function gn(e,t,r="string"){if(!(e==="showGitHubStats"||e==="githubOwner"||e==="githubRepo")){if(typeof window<"u"&&VGe(window.ORBIT_CHAT_CONFIG)){const o=window.ORBIT_CHAT_CONFIG[e];if(o!=null)return o}if(typeof window<"u"){const o=window;switch(e){case"apiUrl":if(o.CHATBOT_API_URL)return o.CHATBOT_API_URL;break;case"defaultKey":if(o.CHATBOT_API_KEY)return o.CHATBOT_API_KEY;break}}}const a=WGe[e],i=a?GGe[a]:void 0;if(i!=null&&i!==""){if(r==="boolean")return i==="true";if(r==="number"||r==="numberOrNull"){const o=parseInt(i,10);if(!isNaN(o))return r==="numberOrNull"&&o===0?null:o}else return i}return t}function lm(e,t){if(e===void 0||e==="")return t===0?null:t;const r=parseInt(e,10);return isNaN(r)||r<0?t===0?null:t:r===0?null:r}function T7(e,t){if(e===void 0||e==="")return t;const r=parseInt(e,10);return isNaN(r)||r<0?t:r}const ca={apiUrl:gn("apiUrl",Ku,"string"),defaultKey:gn("defaultKey","default-key","string"),useLocalApi:gn("useLocalApi",!1,"boolean"),localApiPath:gn("localApiPath",void 0,"string"),consoleDebug:gn("consoleDebug",!1,"boolean"),enableUploadButton:gn("enableUploadButton",!1,"boolean"),enableAudioOutput:gn("enableAudioOutput",!1,"boolean"),enableFeedbackButtons:gn("enableFeedbackButtons",!1,"boolean"),enableConversationThreads:gn("enableConversationThreads",!0,"boolean"),showGitHubStats:gn("showGitHubStats",!0,"boolean"),githubOwner:gn("githubOwner","schmitech","string"),githubRepo:gn("githubRepo","orbit","string"),maxFilesPerConversation:(()=>{const e=gn("maxFilesPerConversation","5","string");return T7(e,5)})(),maxFileSizeMB:(()=>{const e=gn("maxFileSizeMB","50","string");return T7(e,50)})(),maxTotalFiles:(()=>{const e=gn("maxTotalFiles","100","string");return lm(e,100)})(),maxConversations:(()=>{const e=gn("maxConversations","10","string");return lm(e,10)})(),maxMessagesPerConversation:(()=>{const e=gn("maxMessagesPerConversation","1000","string");return lm(e,1e3)})(),maxTotalMessages:(()=>{const e=gn("maxTotalMessages","10000","string");return lm(e,1e4)})(),maxMessageLength:(()=>{const e=gn("maxMessageLength","1000","string");return T7(e,1e3)})()};function ea(){return gn("apiUrl",Ku,"string")}function hs(e){const t=e==null?void 0:e.trim();return t&&t.length>0?t:ea()}function Cu(){return gn("defaultKey","default-key","string")}function KGe(){return ca.useLocalApi}function YGe(){return ca.localApiPath}function ZGe(){return ca.enableUploadButton}function XGe(){return ca.enableAudioOutput}function QGe(){return ca.enableFeedbackButtons}function JGe(){return ca.enableConversationThreads}function eVe(){return ca.showGitHubStats}function LU(){return ca.githubOwner}function PU(){return ca.githubRepo}function tVe({audio:e,audioFormat:t="mp3",autoPlay:r=!1,maxSizeMB:n=10}){const a=E.useRef(null),[i,o]=E.useState(!1),[s,l]=E.useState(0),[u,c]=E.useState(0),[d,p]=E.useState(!0),[h,g]=E.useState(null),[b,w]=E.useState(null);E.useEffect(()=>{if(!e)return;let j=null,D=!0;return(async()=>{try{p(!0),g(null),w(null);const ye=e.length*3/4/(1024*1024);if(ye>n)throw new Error(`Audio file too large (${ye.toFixed(1)}MB > ${n}MB limit)`);if(ye>2&&(w(`Large audio file (${ye.toFixed(1)}MB) - may take time to load`),mt("[AudioPlayer] Large audio file detected",{sizeMB:ye.toFixed(2)})),!/^[A-Za-z0-9+/=]+$/.test(e.replace(/\s/g,"")))throw new Error("Invalid base64 audio data");const ee=atob(e),ie=new Uint8Array(ee.length);for(let Q=0;Q<ee.length;Q++)ie[Q]=ee.charCodeAt(Q);const se=t==="mp3"?"audio/mpeg":t==="wav"?"audio/wav":t==="ogg"?"audio/ogg":t==="opus"?"audio/opus":t==="webm"?"audio/webm":`audio/${t}`,ue=new Blob([ie],{type:se});if(j=URL.createObjectURL(ue),!D||!a.current){j&&URL.revokeObjectURL(j);return}a.current.src=j,p(!1),mt("[AudioPlayer] Audio loaded successfully",{format:t,mimeType:se,size:ue.size}),r&&a.current&&a.current.play().catch(Q=>{N0("[AudioPlayer] Auto-play failed:",Q)})}catch{D&&(g("Failed to load audio"),p(!1))}})(),()=>{D=!1,j&&URL.revokeObjectURL(j)}},[e,t,r]);const x=()=>{a.current&&l(a.current.duration)},v=()=>{a.current&&c(a.current.currentTime)},k=()=>o(!0),T=()=>o(!1),I=()=>{o(!1),c(0)},_=()=>{a.current&&(i?a.current.pause():a.current.play().catch(j=>{g("Playback failed")}))},P=j=>{if(!a.current)return;const D=parseFloat(j.target.value);a.current.currentTime=D,c(D)},z=j=>{if(!isFinite(j))return"0:00";const D=Math.floor(j/60),B=Math.floor(j%60);return`${D}:${B.toString().padStart(2,"0")}`};return h?G.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-red-300 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-700 dark:bg-red-900/20 dark:text-red-400",children:[G.jsx(ug,{className:"h-4 w-4"}),G.jsx("span",{children:h})]}):G.jsxs("div",{className:"mt-3 flex flex-col gap-1",children:[b&&G.jsxs("div",{className:"text-xs text-amber-600 dark:text-amber-400 px-1",children:["⚠️ ",b]}),G.jsxs("div",{className:"flex items-center gap-3 rounded-md border border-gray-300 bg-white px-3 py-2 dark:border-[#4a4b54] dark:bg-[#343541]",children:[G.jsx("audio",{ref:a,onLoadedMetadata:x,onTimeUpdate:v,onPlay:k,onPause:T,onEnded:I}),G.jsx("button",{onClick:_,disabled:d,className:"flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-full bg-gray-200 hover:bg-gray-300 disabled:opacity-50 dark:bg-[#4a4b54] dark:hover:bg-[#565869]",title:i?"Pause":"Play",children:d?G.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-gray-400 border-t-transparent"}):i?G.jsx(yie,{className:"h-4 w-4 text-gray-700 dark:text-[#ececf1]"}):G.jsx(vie,{className:"h-4 w-4 text-gray-700 dark:text-[#ececf1]"})}),G.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[G.jsx("span",{className:"text-xs text-gray-500 dark:text-[#bfc2cd]",children:z(u)}),G.jsx("input",{type:"range",min:"0",max:s||0,value:u,onChange:P,disabled:d||!s,className:"flex-1 cursor-pointer accent-gray-600 dark:accent-[#bfc2cd]",style:{background:s?`linear-gradient(to right, rgb(75 85 99) 0%, rgb(75 85 99) ${u/s*100}%, rgb(229 231 235) ${u/s*100}%, rgb(229 231 235) 100%)`:"rgb(229 231 235)"}}),G.jsx("span",{className:"text-xs text-gray-500 dark:text-[#bfc2cd]",children:z(s)})]}),G.jsx(ug,{className:"h-4 w-4 text-gray-500 dark:text-[#bfc2cd]"})]})]})}function pte(e){if(!e||e.length<1e3)return!1;const t=/^[A-Za-z0-9+/=]+$/,r=e.replace(/\s+/g,"");if(r.length>1e4&&t.test(r)){const n=/\b(the|and|for|are|but|not|you|all|can|function|const|let|var|class|return|import|export|async|await|if|else|while|true|false|null|undefined|http|https|www|error|data|response|request|api|json|xml|html|css|js|py|java|cpp|def|print|console|log)\b/i.test(e),a=/[#*`\[\](){}|<>]/.test(e),i=/[.,;:!?'"()-]/.test(e);if(!n&&!a&&!i)return!0}return!!(r.length>5e4&&t.test(r)&&e.replace(/[A-Za-z0-9+/=\s]/g,"").length<10)}function yp(e){if(!e)return e;if(pte(e))return"";const t=/([A-Za-z0-9+/=]{10000,})/g;return e.replace(t,n=>{const a=n.replace(/\s+/g,"");if(a.length>1e4&&/^[A-Za-z0-9+/=]+$/.test(a)){const i=/\b(function|const|let|var|class|return|import|export|if|else|while|for|true|false|null|def|print)\b/i.test(n),o=/[#*`\[\](){}|<>]/.test(n),s=/[.,;:!?'"()-]/.test(n);if(!i&&!o&&!s)return""}return n}).trim()}function v8(e,t=5e4){return!e||e.length<=t?e:pte(e)?"":e.substring(0,t)+`
990
+ `),n={colors:b8};if(r.some(a=>a.includes("|"))){const a=r.filter(s=>s.includes("|")),i=a[0].split("|").map(s=>s.trim()).filter(Boolean),o=a.slice(2);n.data=o.map(s=>{const l=s.split("|").map(c=>c.trim()).filter(Boolean);if(!l.length)return null;const u={};return i.forEach((c,d)=>{const p=l[d];typeof p>"u"||(u[c]=p!==""&&!Number.isNaN(Number(p))?Number(p):p)}),u}).filter(Boolean),n.xKey=i[0],n.dataKeys=i.slice(1);for(const s of r){if(s.includes("|"))break;const[l,...u]=s.split(":");!l||!u.length||TU(n,l,u.join(":"))}}else{for(const a of r){const[i,...o]=a.split(":");!i||!o.length||TU(n,i,o.join(":"))}if(Array.isArray(n.data)&&typeof n.data[0]=="number"){const a=n.labels||n.data.map((i,o)=>`Item ${o+1}`);n.data=n.data.map((i,o)=>({name:a[o],value:i})),n.xKey="name",n.dataKeys=["value"]}}return n.data=n.data??[],(!n.colors||n.colors.length===0)&&(n.colors=b8),n}catch(r){return console.error("Failed to parse chart config:",r),null}},CU=(e,t)=>{if(typeof e!="number"||Number.isNaN(e))return e??"";if(!t)return new Intl.NumberFormat().format(e);const{format:r="number",currency:n="USD",decimals:a,minimumFractionDigits:i,maximumFractionDigits:o,prefix:s="",suffix:l=""}=t,u={};typeof a=="number"&&!Number.isNaN(a)?(u.minimumFractionDigits=a,u.maximumFractionDigits=a):(typeof i=="number"&&(u.minimumFractionDigits=i),typeof o=="number"&&(u.maximumFractionDigits=o)),r==="currency"?(u.style="currency",u.currency=n||"USD"):r==="percent"?u.style="percent":r==="compact"?u.notation="compact":u.maximumFractionDigits||(u.maximumFractionDigits=2);const c=new Intl.NumberFormat(void 0,u).format(e);return`${s}${c}${l}`},zGe=(e,t)=>{const r=e.dataKeys&&e.dataKeys.length?e.dataKeys.map(i=>({key:i})):[{key:"value"}],n=(e.series&&e.series.length?e.series:r).filter(i=>!!i.key),a=e.type==="line"?"line":e.type==="area"?"area":e.type==="scatter"?"scatter":"bar";return n.map((i,o)=>{const s=e.type==="composed"&&i.type||a;return{...i,type:s,key:i.key,name:i.name??i.key,color:i.color??t[o%t.length],yAxisId:i.yAxisId??"left",stackId:typeof i.stackId<"u"?i.stackId:e.stacked?"stack":void 0,strokeWidth:i.strokeWidth??(s==="line"?2:1),dot:typeof i.dot=="boolean"?i.dot:!0,opacity:i.opacity??(s==="area"?.55:1)}})},jGe=e=>e!=null&&e.length?e.filter(t=>typeof t.y<"u"||typeof t.x<"u").map((t,r)=>{const n=a=>a==="start"?"insideStart":a==="middle"?"middle":"end";return Be.jsx(Lee,{y:t.y,x:t.x,stroke:t.color||"#9ca3af",strokeDasharray:t.strokeDasharray||"4 4",label:t.label?{value:t.label,position:n(t.position),fill:t.color||"#4b5563"}:void 0},`reference-${r}`)}):null,IU=(e,t)=>{const r=e.filter(a=>a.yAxisId===t);if(!r.length)return;const n=r.map(a=>a.name||a.key).filter(a=>!!a);return n.length?Array.from(new Set(n)).join(" / "):void 0},ss=(e,t)=>{if(!e)return null;const r=t==="right"?20:-20,n=t==="right"?"insideRight":"insideLeft";return Be.jsx(ps,{value:e,angle:t==="right"?90:-90,position:n,style:{textAnchor:"middle",fill:"#374151",fontSize:12,fontWeight:500},offset:r})},$Ge=({code:e,language:t})=>{var r,n;const[a,i]=E.useState(null),[o,s]=E.useState(null);if(E.useEffect(()=>{const D=BGe(e,t);if(!D){s(null),i("Failed to parse chart configuration");return}if(!Array.isArray(D.data)||D.data.length===0){s(null),i("Chart data is empty");return}if(!D.type){s(null),i("Chart type is required (bar, line, pie, area, scatter, composed)");return}i(null),s(D)},[e,t]),a)return Be.jsxs("div",{className:"graph-error",children:[Be.jsx("div",{className:"graph-error-title",children:"Chart Rendering Error"}),Be.jsx("div",{className:"graph-error-message",children:a}),Be.jsx("pre",{style:{marginTop:"8px",fontSize:"0.8em",opacity:.7},children:Be.jsx("code",{children:e})})]});if(!o)return Be.jsx("div",{className:"graph-container chart-container",children:Be.jsx("div",{children:"Loading chart..."})});const l=o.colors&&o.colors.length?o.colors:b8,u=o.height||320,c=zGe(o,l),d=c.some(D=>D.yAxisId==="right"),p=o.showLegend??(o.type==="pie"||c.length>1),h=o.showGrid??!0,g=jGe(o.referenceLines),b=IU(c,"left"),w=IU(c,"right"),x=o.yAxisLabel??b??"Value",v=d?o.yAxisRightLabel??w??"Value":void 0,k={backgroundColor:"#ffffff",border:"1px solid #ccc",borderRadius:"4px",padding:"8px",color:"#000000"},T={color:"#000000",fontWeight:600,marginBottom:"4px"},I={color:"#000000"},_=(D,B)=>typeof D=="number"?[CU(D,o.formatter),B]:[D,B],P=D=>{if(typeof D!="number")return String(D??"");const B=CU(D,o.formatter);return String(B??"")},z=o.xAxisLabel?{value:o.xAxisLabel,position:"insideBottom",offset:-5}:void 0,j={left:x?80:10,right:v?80:10,top:10,bottom:20};return Be.jsxs("div",{className:"graph-container chart-container",style:{flexDirection:"column",alignItems:"stretch"},children:[o.title&&Be.jsx("h4",{style:{textAlign:"center",marginBottom:o.description?"4px":"12px",marginTop:0,color:"#000000",fontWeight:600},children:o.title}),o.description&&Be.jsx("p",{style:{textAlign:"center",marginTop:0,marginBottom:"12px",color:"#4b5563",fontSize:"0.9rem"},children:o.description}),Be.jsxs(o6e,{width:"100%",height:u,children:[o.type==="bar"&&Be.jsxs(xGe,{data:o.data,margin:j,children:[h&&Be.jsx(Ec,{strokeDasharray:"3 3"}),Be.jsx(_c,{dataKey:o.xKey||"name",label:z}),Be.jsx(wo,{yAxisId:"left",tickFormatter:P,children:ss(x,"left")}),d&&Be.jsx(wo,{yAxisId:"right",orientation:"right",tickFormatter:P,children:ss(v,"right")}),Be.jsx(wc,{contentStyle:k,labelStyle:T,itemStyle:I,formatter:_}),p&&Be.jsx(ou,{}),g,c.map(D=>Be.jsx(s8,{dataKey:D.key,fill:D.color,stackId:D.stackId,yAxisId:D.yAxisId,radius:[4,4,0,0]},D.key))]}),o.type==="line"&&Be.jsxs(bGe,{data:o.data,margin:j,children:[h&&Be.jsx(Ec,{strokeDasharray:"3 3"}),Be.jsx(_c,{dataKey:o.xKey||"name",label:z}),Be.jsx(wo,{yAxisId:"left",tickFormatter:P,children:ss(x,"left")}),d&&Be.jsx(wo,{yAxisId:"right",orientation:"right",tickFormatter:P,children:ss(v,"right")}),Be.jsx(wc,{contentStyle:k,labelStyle:T,itemStyle:I,formatter:_}),p&&Be.jsx(ou,{}),g,c.map(D=>Be.jsx(u8,{type:"monotone",dataKey:D.key,stroke:D.color,yAxisId:D.yAxisId,strokeWidth:D.strokeWidth,dot:D.dot},D.key))]}),o.type==="area"&&Be.jsxs(LGe,{data:o.data,margin:j,children:[h&&Be.jsx(Ec,{strokeDasharray:"3 3"}),Be.jsx(_c,{dataKey:o.xKey||"name",label:z}),Be.jsx(wo,{yAxisId:"left",tickFormatter:P,children:ss(x,"left")}),d&&Be.jsx(wo,{yAxisId:"right",orientation:"right",tickFormatter:P,children:ss(v,"right")}),Be.jsx(wc,{contentStyle:k,labelStyle:T,itemStyle:I,formatter:_}),p&&Be.jsx(ou,{}),g,c.map(D=>Be.jsx(c8,{type:"monotone",dataKey:D.key,stroke:D.color,yAxisId:D.yAxisId,fill:D.color,fillOpacity:D.opacity,stackId:D.stackId},D.key))]}),o.type==="composed"&&Be.jsxs(DGe,{data:o.data,margin:j,children:[h&&Be.jsx(Ec,{strokeDasharray:"3 3"}),Be.jsx(_c,{dataKey:o.xKey||"name",label:z}),Be.jsx(wo,{yAxisId:"left",tickFormatter:P,children:ss(x,"left")}),d&&Be.jsx(wo,{yAxisId:"right",orientation:"right",tickFormatter:P,children:ss(v,"right")}),Be.jsx(wc,{contentStyle:k,labelStyle:T,itemStyle:I,formatter:_}),p&&Be.jsx(ou,{}),g,c.map(D=>{switch(D.type){case"line":return Be.jsx(u8,{type:"monotone",dataKey:D.key,stroke:D.color,yAxisId:D.yAxisId,strokeWidth:D.strokeWidth,dot:D.dot},D.key);case"area":return Be.jsx(c8,{type:"monotone",dataKey:D.key,stroke:D.color,yAxisId:D.yAxisId,fill:D.color,fillOpacity:D.opacity,stackId:D.stackId},D.key);case"scatter":return Be.jsx(p8,{dataKey:D.key,fill:D.color,yAxisId:D.yAxisId},D.key);default:return Be.jsx(s8,{dataKey:D.key,fill:D.color,stackId:D.stackId,yAxisId:D.yAxisId,radius:[4,4,0,0]},D.key)}})]}),o.type==="pie"&&Be.jsxs(OGe,{children:[Be.jsx(kee,{data:o.data,dataKey:((r=o.dataKeys)==null?void 0:r[0])||"value",nameKey:o.xKey||"name",cx:"50%",cy:"50%",outerRadius:u/3,label:!0,children:o.data.map((D,B)=>Be.jsx(rd,{fill:l[B%l.length]},`cell-${B}`))}),Be.jsx(wc,{contentStyle:k,itemStyle:I,formatter:_}),p&&Be.jsx(ou,{})]}),o.type==="scatter"&&Be.jsxs(RGe,{margin:j,children:[h&&Be.jsx(Ec,{strokeDasharray:"3 3"}),Be.jsx(_c,{dataKey:o.xKey||"x",label:z}),Be.jsx(wo,{dataKey:((n=o.dataKeys)==null?void 0:n[0])||"y",tickFormatter:P,children:ss(x,"left")}),Be.jsx(wc,{contentStyle:k,labelStyle:T,itemStyle:I,formatter:_}),p&&Be.jsx(ou,{}),g,Be.jsx(p8,{name:"Data",data:o.data,fill:l[0]})]})]})]})},OU=({code:e})=>{const[t,r]=E.useState(!1),n=async()=>{try{await navigator.clipboard.writeText(e),r(!0),setTimeout(()=>r(!1),2e3)}catch{const a=document.createElement("textarea");a.value=e,a.style.position="fixed",a.style.opacity="0",document.body.appendChild(a),a.select();try{document.execCommand("copy"),r(!0),setTimeout(()=>r(!1),2e3)}catch(i){console.error("Failed to copy code:",i)}document.body.removeChild(a)}};return Be.jsxs("button",{className:"code-copy-button",onClick:n,title:t?"Copied!":"Copy code","aria-label":t?"Copied!":"Copy code to clipboard",children:[t?Be.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Be.jsx("path",{d:"M13.5 4.5L6 12L2.5 8.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}):Be.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[Be.jsx("path",{d:"M5.5 4.5H3.5C2.94772 4.5 2.5 4.94772 2.5 5.5V12.5C2.5 13.0523 2.94772 13.5 3.5 13.5H10.5C11.0523 13.5 11.5 13.0523 11.5 12.5V10.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),Be.jsx("path",{d:"M6.5 2.5H12.5C13.0523 2.5 13.5 2.94772 13.5 3.5V9.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),Be.jsx("path",{d:"M9.5 6.5L13.5 2.5L9.5 2.5V6.5Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),Be.jsx("span",{className:"code-copy-button-text",children:t?"Copied!":"Copy"})]})},UGe=({inline:e,className:t="",children:r,enableGraphs:n=!0,enableMermaid:a=!0,enablePlantUML:i=!0,enableSVG:o=!0,enableCharts:s=!0,plantUMLServerUrl:l,enableSyntaxHighlighting:u=!0,syntaxTheme:c="dark"})=>{if(e)return Be.jsx("code",{className:t,children:r});const d=/language-(\w+)/.exec(t||""),p=d?d[1].toLowerCase():"",h=String(r).replace(/\n$/,"");if(s&&(p==="chart"||p==="chart-json"||p==="chart-table"))return Be.jsx($Ge,{code:h,language:p});if(n){if(p==="mermaid"&&a)return Be.jsx(RIe,{code:h});if((p==="plantuml"||p==="puml")&&i)return Be.jsx(FIe,{code:h,serverUrl:l});if(p==="svg"&&o)return Be.jsx(BIe,{code:h})}if(u&&p){const g=c==="light"?o2e:s2e;return Be.jsxs("div",{className:"syntax-highlighted-wrapper code-block-container",children:[Be.jsx(OU,{code:h}),Be.jsx(qW,{language:p,style:g,customStyle:{margin:"12px 0",borderRadius:"6px",fontSize:"0.9em"},showLineNumbers:!1,children:h})]})}return Be.jsxs("div",{className:`markdown-code-block code-block-container ${t}`.trim(),children:[Be.jsx(OU,{code:h}),Be.jsx("pre",{style:{margin:0,padding:0,background:"transparent",border:"none"},children:Be.jsx("code",{children:h})})]})},NU=new Set(["div","pre","blockquote","ul","ol","table","thead","tbody","tr","td","th","h1","h2","h3","h4","h5","h6","section","article","figure"]),HGe=({children:e,href:t,...r})=>Be.jsx("a",{...r,href:t,target:"_blank",rel:"noopener noreferrer",children:e}),RU=({content:e,className:t="",disableMath:r=!1,enableGraphs:n=!0,enableMermaid:a=!0,enablePlantUML:i=!0,enableSVG:o=!0,enableCharts:s=!0,plantUMLServerUrl:l,enableSyntaxHighlighting:u=!0,syntaxTheme:c="dark"})=>{const d=Sfe(e);if(!d)return null;const p=r?[QO]:[QO,[sde,{singleDollarTextMath:!0}]],h=[];r||h.push([zde,{throwOnError:!1,errorColor:"#cc0000",strict:!1,trust:!0,macros:{"\\RR":"\\mathbb{R}","\\NN":"\\mathbb{N}","\\ZZ":"\\mathbb{Z}","\\QQ":"\\mathbb{Q}","\\CC":"\\mathbb{C}","\\dx":"\\,dx","\\dy":"\\,dy","\\dt":"\\,dt","\\dz":"\\,dz"}}]);const g={a:HGe,code:b=>{const{className:w,children:x,...v}=b,k=w&&/language-/.test(w),T="inline"in b&&typeof b.inline=="boolean"&&b.inline||!k,I=k;return Be.jsx(UGe,{inline:T,className:w,enableGraphs:n,enableMermaid:a,enablePlantUML:i,enableSVG:o,enableCharts:s,plantUMLServerUrl:l,enableSyntaxHighlighting:u,syntaxTheme:c,"data-block-code":I?"true":void 0,...v,children:x})},p:({node:b,...w})=>{var x;const v=Vn.Children.toArray(w.children).filter(T=>!(typeof T=="string"&&T.trim()==="")).some(T=>{var I;return Vn.isValidElement(T)?((I=T.props)==null?void 0:I["data-block-code"])==="true"?!0:typeof T.type=="string"?NU.has(T.type):!1:!1}),k=(x=b==null?void 0:b.children)==null?void 0:x.some(T=>{var I;if(T.type==="code")return!0;if(T.type==="element"){if(NU.has(T.tagName))return!0;if(T.tagName==="code"){const _=(I=T.properties)==null?void 0:I.className;return Array.isArray(_)?_.some(P=>typeof P=="string"&&P.startsWith("language-")):!0}}return!1});return v||k?Be.jsx(Be.Fragment,{children:w.children}):Be.jsx("p",{...w})}};return Be.jsx("div",{className:`markdown-content ${t}`,children:Be.jsx(Que,{remarkPlugins:p,rehypePlugins:h,components:g,children:d})})},MU="schmitech-markdown-renderer-styles",qGe=()=>{if(typeof document>"u"||document.getElementById(MU))return;const e=document.createElement("style");e.id=MU,e.textContent=Die,document.head.appendChild(e)};qGe();const mt=(...e)=>{},Yr=(...e)=>{},N0=(...e)=>{},$n=(...e)=>{console.error(...e)},GGe={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1,VITE_API_URL:"http://localhost:3000",VITE_CONSOLE_DEBUG:"false",VITE_DEFAULT_KEY:"default-key",VITE_ENABLE_AUDIO_OUTPUT:"true",VITE_ENABLE_CONVERSATION_THREADS:"true",VITE_ENABLE_FEEDBACK:"false",VITE_ENABLE_UPLOAD:"true",VITE_GITHUB_OWNER:"schmitech",VITE_GITHUB_REPO:"orbit",VITE_LOCALE:"en-US",VITE_MAX_CONVERSATIONS:"10",VITE_MAX_FILES_PER_CONVERSATION:"5",VITE_MAX_FILE_SIZE_MB:"50",VITE_MAX_MESSAGES_PER_CONVERSATION:"1000",VITE_MAX_MESSAGE_LENGTH:"500",VITE_MAX_TOTAL_FILES:"100",VITE_MAX_TOTAL_MESSAGES:"10000",VITE_SHOW_GITHUB_STATS:"true",VITE_USE_LOCAL_API:"true"},Ku="http://localhost:3000";function VGe(e){return typeof e=="object"&&e!==null}const WGe={apiUrl:"VITE_API_URL",defaultKey:"VITE_DEFAULT_KEY",useLocalApi:"VITE_USE_LOCAL_API",localApiPath:"VITE_LOCAL_API_PATH",consoleDebug:"VITE_CONSOLE_DEBUG",enableUploadButton:"VITE_ENABLE_UPLOAD",enableAudioOutput:"VITE_ENABLE_AUDIO_OUTPUT",enableFeedbackButtons:"VITE_ENABLE_FEEDBACK",enableConversationThreads:"VITE_ENABLE_CONVERSATION_THREADS",showGitHubStats:"VITE_SHOW_GITHUB_STATS",githubOwner:"VITE_GITHUB_OWNER",githubRepo:"VITE_GITHUB_REPO",maxFilesPerConversation:"VITE_MAX_FILES_PER_CONVERSATION",maxFileSizeMB:"VITE_MAX_FILE_SIZE_MB",maxTotalFiles:"VITE_MAX_TOTAL_FILES",maxConversations:"VITE_MAX_CONVERSATIONS",maxMessagesPerConversation:"VITE_MAX_MESSAGES_PER_CONVERSATION",maxTotalMessages:"VITE_MAX_TOTAL_MESSAGES",maxMessageLength:"VITE_MAX_MESSAGE_LENGTH"};function gn(e,t,r="string"){if(!(e==="showGitHubStats"||e==="githubOwner"||e==="githubRepo")){if(typeof window<"u"&&VGe(window.ORBIT_CHAT_CONFIG)){const o=window.ORBIT_CHAT_CONFIG[e];if(o!=null)return o}if(typeof window<"u"){const o=window;switch(e){case"apiUrl":if(o.CHATBOT_API_URL)return o.CHATBOT_API_URL;break;case"defaultKey":if(o.CHATBOT_API_KEY)return o.CHATBOT_API_KEY;break}}}const a=WGe[e],i=a?GGe[a]:void 0;if(i!=null&&i!==""){if(r==="boolean")return i==="true";if(r==="number"||r==="numberOrNull"){const o=parseInt(i,10);if(!isNaN(o))return r==="numberOrNull"&&o===0?null:o}else return i}return t}function lm(e,t){if(e===void 0||e==="")return t===0?null:t;const r=parseInt(e,10);return isNaN(r)||r<0?t===0?null:t:r===0?null:r}function T7(e,t){if(e===void 0||e==="")return t;const r=parseInt(e,10);return isNaN(r)||r<0?t:r}const ca={apiUrl:gn("apiUrl",Ku,"string"),defaultKey:gn("defaultKey","default-key","string"),useLocalApi:gn("useLocalApi",!1,"boolean"),localApiPath:gn("localApiPath",void 0,"string"),consoleDebug:gn("consoleDebug",!1,"boolean"),enableUploadButton:gn("enableUploadButton",!1,"boolean"),enableAudioOutput:gn("enableAudioOutput",!1,"boolean"),enableFeedbackButtons:gn("enableFeedbackButtons",!1,"boolean"),enableConversationThreads:gn("enableConversationThreads",!0,"boolean"),showGitHubStats:gn("showGitHubStats",!0,"boolean"),githubOwner:gn("githubOwner","schmitech","string"),githubRepo:gn("githubRepo","orbit","string"),maxFilesPerConversation:(()=>{const e=gn("maxFilesPerConversation","5","string");return T7(e,5)})(),maxFileSizeMB:(()=>{const e=gn("maxFileSizeMB","50","string");return T7(e,50)})(),maxTotalFiles:(()=>{const e=gn("maxTotalFiles","100","string");return lm(e,100)})(),maxConversations:(()=>{const e=gn("maxConversations","10","string");return lm(e,10)})(),maxMessagesPerConversation:(()=>{const e=gn("maxMessagesPerConversation","1000","string");return lm(e,1e3)})(),maxTotalMessages:(()=>{const e=gn("maxTotalMessages","10000","string");return lm(e,1e4)})(),maxMessageLength:(()=>{const e=gn("maxMessageLength","1000","string");return T7(e,1e3)})()};function ea(){return gn("apiUrl",Ku,"string")}function hs(e){const t=e==null?void 0:e.trim();return t&&t.length>0?t:ea()}function Cu(){return gn("defaultKey","default-key","string")}function KGe(){return ca.useLocalApi}function YGe(){return ca.localApiPath}function ZGe(){return ca.enableUploadButton}function XGe(){return ca.enableAudioOutput}function QGe(){return ca.enableFeedbackButtons}function JGe(){return ca.enableConversationThreads}function eVe(){return ca.showGitHubStats}function LU(){return ca.githubOwner}function PU(){return ca.githubRepo}function tVe({audio:e,audioFormat:t="mp3",autoPlay:r=!1,maxSizeMB:n=10}){const a=E.useRef(null),[i,o]=E.useState(!1),[s,l]=E.useState(0),[u,c]=E.useState(0),[d,p]=E.useState(!0),[h,g]=E.useState(null),[b,w]=E.useState(null);E.useEffect(()=>{if(!e)return;let j=null,D=!0;return(async()=>{try{p(!0),g(null),w(null);const ye=e.length*3/4/(1024*1024);if(ye>n)throw new Error(`Audio file too large (${ye.toFixed(1)}MB > ${n}MB limit)`);if(ye>2&&(w(`Large audio file (${ye.toFixed(1)}MB) - may take time to load`),mt("[AudioPlayer] Large audio file detected",{sizeMB:ye.toFixed(2)})),!/^[A-Za-z0-9+/=]+$/.test(e.replace(/\s/g,"")))throw new Error("Invalid base64 audio data");const ee=atob(e),ie=new Uint8Array(ee.length);for(let Q=0;Q<ee.length;Q++)ie[Q]=ee.charCodeAt(Q);const se=t==="mp3"?"audio/mpeg":t==="wav"?"audio/wav":t==="ogg"?"audio/ogg":t==="opus"?"audio/opus":t==="webm"?"audio/webm":`audio/${t}`,ue=new Blob([ie],{type:se});if(j=URL.createObjectURL(ue),!D||!a.current){j&&URL.revokeObjectURL(j);return}a.current.src=j,p(!1),mt("[AudioPlayer] Audio loaded successfully",{format:t,mimeType:se,size:ue.size}),r&&a.current&&a.current.play().catch(Q=>{N0("[AudioPlayer] Auto-play failed:",Q)})}catch{D&&(g("Failed to load audio"),p(!1))}})(),()=>{D=!1,j&&URL.revokeObjectURL(j)}},[e,t,r]);const x=()=>{a.current&&l(a.current.duration)},v=()=>{a.current&&c(a.current.currentTime)},k=()=>o(!0),T=()=>o(!1),I=()=>{o(!1),c(0)},_=()=>{a.current&&(i?a.current.pause():a.current.play().catch(j=>{g("Playback failed")}))},P=j=>{if(!a.current)return;const D=parseFloat(j.target.value);a.current.currentTime=D,c(D)},z=j=>{if(!isFinite(j))return"0:00";const D=Math.floor(j/60),B=Math.floor(j%60);return`${D}:${B.toString().padStart(2,"0")}`};return h?G.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-red-300 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-700 dark:bg-red-900/20 dark:text-red-400",children:[G.jsx(ug,{className:"h-4 w-4"}),G.jsx("span",{children:h})]}):G.jsxs("div",{className:"mt-3 flex flex-col gap-1",children:[b&&G.jsxs("div",{className:"text-xs text-amber-600 dark:text-amber-400 px-1",children:["⚠️ ",b]}),G.jsxs("div",{className:"flex items-center gap-3 rounded-md border border-gray-300 bg-white px-3 py-2 dark:border-[#4a4b54] dark:bg-[#343541]",children:[G.jsx("audio",{ref:a,onLoadedMetadata:x,onTimeUpdate:v,onPlay:k,onPause:T,onEnded:I}),G.jsx("button",{onClick:_,disabled:d,className:"flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-full bg-gray-200 hover:bg-gray-300 disabled:opacity-50 dark:bg-[#4a4b54] dark:hover:bg-[#565869]",title:i?"Pause":"Play",children:d?G.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-gray-400 border-t-transparent"}):i?G.jsx(yie,{className:"h-4 w-4 text-gray-700 dark:text-[#ececf1]"}):G.jsx(vie,{className:"h-4 w-4 text-gray-700 dark:text-[#ececf1]"})}),G.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[G.jsx("span",{className:"text-xs text-gray-500 dark:text-[#bfc2cd]",children:z(u)}),G.jsx("input",{type:"range",min:"0",max:s||0,value:u,onChange:P,disabled:d||!s,className:"flex-1 cursor-pointer accent-gray-600 dark:accent-[#bfc2cd]",style:{background:s?`linear-gradient(to right, rgb(75 85 99) 0%, rgb(75 85 99) ${u/s*100}%, rgb(229 231 235) ${u/s*100}%, rgb(229 231 235) 100%)`:"rgb(229 231 235)"}}),G.jsx("span",{className:"text-xs text-gray-500 dark:text-[#bfc2cd]",children:z(s)})]}),G.jsx(ug,{className:"h-4 w-4 text-gray-500 dark:text-[#bfc2cd]"})]})]})}function pte(e){if(!e||e.length<1e3)return!1;const t=/^[A-Za-z0-9+/=]+$/,r=e.replace(/\s+/g,"");if(r.length>1e4&&t.test(r)){const n=/\b(the|and|for|are|but|not|you|all|can|function|const|let|var|class|return|import|export|async|await|if|else|while|true|false|null|undefined|http|https|www|error|data|response|request|api|json|xml|html|css|js|py|java|cpp|def|print|console|log)\b/i.test(e),a=/[#*`\[\](){}|<>]/.test(e),i=/[.,;:!?'"()-]/.test(e);if(!n&&!a&&!i)return!0}return!!(r.length>5e4&&t.test(r)&&e.replace(/[A-Za-z0-9+/=\s]/g,"").length<10)}function yp(e){if(!e)return e;if(pte(e))return"";const t=/([A-Za-z0-9+/=]{10000,})/g;return e.replace(t,n=>{const a=n.replace(/\s+/g,"");if(a.length>1e4&&/^[A-Za-z0-9+/=]+$/.test(a)){const i=/\b(function|const|let|var|class|return|import|export|if|else|while|for|true|false|null|def|print)\b/i.test(n),o=/[#*`\[\](){}|<>]/.test(n),s=/[.,;:!?'"()-]/.test(n);if(!i&&!o&&!s)return""}return n}).trim()}function v8(e,t=5e4){return!e||e.length<=t?e:pte(e)?"":e.substring(0,t)+`
991
991
 
992
- ... (content truncated due to length)`}const Er={maxFilesPerConversation:ca.maxFilesPerConversation,maxFileSizeMB:ca.maxFileSizeMB,maxTotalFiles:ca.maxTotalFiles,maxConversations:ca.maxConversations,maxMessagesPerConversation:ca.maxMessagesPerConversation,maxTotalMessages:ca.maxTotalMessages,maxMessageLength:ca.maxMessageLength},rVe=[];function nVe({message:e,onRegenerate:t,onStartThread:r,onSendThreadMessage:n,threadMessages:a,sessionId:i,isThreadSendDisabled:o}){var V,ge;const[s,l]=E.useState(!1),[u,c]=E.useState(null),[d,p]=E.useState(""),[h,g]=E.useState(!1),[b,w]=E.useState(!1),x=E.useRef(((V=e.threadInfo)==null?void 0:V.thread_id)||null),v=E.useRef(null),k=e.role==="assistant",T=a??rVe,I=T.length,_=T.some(ke=>ke.isStreaming),P="en-US",z=JGe(),j=Er.maxMessageLength;E.useEffect(()=>{var ke,ze;!x.current&&((ke=e.threadInfo)!=null&&ke.thread_id)&&g(!0),x.current=((ze=e.threadInfo)==null?void 0:ze.thread_id)||null},[(ge=e.threadInfo)==null?void 0:ge.thread_id]),E.useEffect(()=>{e.threadInfo||(p(""),g(!1),w(!1))},[e.threadInfo]),E.useEffect(()=>{I>0&&g(!0)},[I]);const D=E.useMemo(()=>{const ke=e.timestamp instanceof Date?e.timestamp:new Date(e.timestamp),ze=ke.toLocaleDateString(P,{weekday:"short"}),Ee=ke.toLocaleDateString(P,{month:"short"}),Ve=ke.getDate().toString().padStart(2,"0"),me=ke.getFullYear(),je=ke.toLocaleTimeString(P,{hour:"2-digit",minute:"2-digit",hour12:!0});return`${ze}, ${Ee} ${Ve}, ${me} ${je}`},[e.timestamp,P]),B=k?"markdown-content prose prose-slate dark:prose-invert max-w-none":"markdown-content prose prose-invert max-w-none",J=k?"bg-gradient-to-br from-blue-100 to-blue-200 text-blue-900 dark:from-[#1f2a36] dark:to-[#1a2230] dark:text-[#c5d7ff]":"bg-gradient-to-br from-emerald-100 to-emerald-200 text-emerald-900 dark:from-[#0f1f17] dark:to-[#0b1712] dark:text-[#c7f5df]",ye=`message-bubble min-w-0 break-words leading-relaxed ${k?"border border-blue-100/80 bg-transparent text-[#0f172a] shadow-[0_15px_35px_-20px_rgba(15,23,42,0.25)] dark:border-[#1f2a36] dark:bg-transparent dark:text-[#e5edff]":"border border-emerald-100 bg-transparent text-[#1c3226] shadow-[0_12px_30px_-18px_rgba(15,52,33,0.25)] dark:border-[#1a2b21] dark:bg-transparent dark:text-[#dffbea]"} rounded-2xl px-4 py-3`,ee=k?"border-blue-100 bg-white/80 dark:border-[#1f2a36] dark:bg-white/5":"border-emerald-100 bg-white/80 dark:border-[#1a2b21] dark:bg-white/5",ie=async()=>{try{await navigator.clipboard.writeText(e.content),l(!0),setTimeout(()=>l(!1),2e3)}catch{}},se=ke=>{c(u===ke?null:ke)},ue=E.useCallback(ke=>(ke instanceof Date?ke:new Date(ke)).toLocaleTimeString(P,{hour:"2-digit",minute:"2-digit"}),[P]),Q=async()=>{if(!n||!e.threadInfo)return;const ke=d.trim();if(ke){w(!0);try{await n(e.threadInfo.thread_id,e.id,ke),p("")}catch{}finally{w(!1)}}},te=ke=>{ke.key==="Enter"&&!ke.shiftKey&&(ke.preventDefault(),Q())},H=!e.threadInfo||!n||o||_||b;E.useEffect(()=>{if(v.current){const ze=v.current;ze.style.height="auto";const Ee=ze.scrollHeight;ze.style.height=`${Math.min(Ee,120)}px`,ze.style.overflowY=Ee>120?"auto":"hidden"}},[d]);const le=E.useMemo(()=>e.isStreaming&&(!e.content||e.content==="…")?G.jsxs("div",{className:"flex items-center gap-1.5 py-1",children:[G.jsx("span",{className:"inline-block h-2.5 w-2.5 animate-bounce rounded-full bg-gray-400 dark:bg-[#bfc2cd]",style:{animationDelay:"0ms"}}),G.jsx("span",{className:"inline-block h-2.5 w-2.5 animate-bounce rounded-full bg-gray-400 dark:bg-[#bfc2cd]",style:{animationDelay:"150ms"}}),G.jsx("span",{className:"inline-block h-2.5 w-2.5 animate-bounce rounded-full bg-gray-400 dark:bg-[#bfc2cd]",style:{animationDelay:"300ms"}})]}):G.jsx(RU,{content:v8(yp(e.content||""))}),[e.content,e.isStreaming]),ve=E.useMemo(()=>T.map(ke=>{const ze=ke.role==="assistant",Ee=ke.isStreaming&&(!ke.content||ke.content==="…")?G.jsxs("div",{className:"flex items-center gap-1.5 py-1",children:[G.jsx("span",{className:"inline-block h-2 w-2 animate-bounce rounded-full bg-gray-400 dark:bg-[#bfc2cd]",style:{animationDelay:"0ms"}}),G.jsx("span",{className:"inline-block h-2 w-2 animate-bounce rounded-full bg-gray-400 dark:bg-[#bfc2cd]",style:{animationDelay:"150ms"}}),G.jsx("span",{className:"inline-block h-2 w-2 animate-bounce rounded-full bg-gray-400 dark:bg-[#bfc2cd]",style:{animationDelay:"300ms"}})]}):G.jsx(RU,{content:v8(yp(ke.content||""))});return G.jsxs("div",{className:"flex items-start gap-3",children:[G.jsx("div",{className:`mt-0.5 flex h-7 w-7 flex-shrink-0 items-center justify-center rounded-full ${ze?"bg-blue-100 text-blue-700 dark:bg-[#1f2a36] dark:text-[#c5d7ff]":"bg-emerald-100 text-emerald-700 dark:bg-[#1f2a36] dark:text-[#9ef0d5]"}`,children:ze?G.jsx(JC,{className:"h-3.5 w-3.5"}):G.jsx(rI,{className:"h-3.5 w-3.5"})}),G.jsxs("div",{className:"flex-1 rounded-2xl border border-white/70 bg-white/90 px-4 py-3 text-sm shadow-sm dark:border-white/5 dark:bg-white/5 backdrop-blur",children:[G.jsxs("div",{className:"mb-1 flex items-center justify-between text-[11px] font-semibold uppercase tracking-wide text-blue-900/70 dark:text-[#c5d7ff]",children:[G.jsx("span",{children:ze?"Assistant":"You"}),G.jsx("span",{children:ue(ke.timestamp)})]}),G.jsx("div",{className:"prose prose-slate max-w-none text-sm text-[#353740] dark:prose-invert dark:text-[#ececf1]",children:Ee})]})]},ke.id)}),[ue,T]);return G.jsxs("div",{className:"group flex items-start gap-3 px-1 animate-fadeIn min-w-0 sm:px-0",children:[G.jsx("div",{className:`flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-full self-start -mt-2 ml-1 shadow-sm ring-2 ring-white/50 dark:ring-white/10 sm:-mt-3 sm:ml-2 ${J}`,children:k?G.jsx(JC,{className:"h-5 w-5"}):G.jsx(rI,{className:"h-5 w-5"})}),G.jsxs("div",{className:"flex-1 min-w-0 space-y-2",children:[G.jsxs("div",{className:"flex flex-col gap-1.5 mb-1",children:[G.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-gray-700 dark:text-[#ececf1]",children:k?"Assistant":"You"}),G.jsx("span",{className:"text-xs text-gray-500 dark:text-[#bfc2cd]",children:D})]}),G.jsxs("div",{className:ye,children:[G.jsx("div",{className:B,children:le}),e.attachments&&e.attachments.length>0&&G.jsx("div",{className:"mt-3 space-y-2",children:e.attachments.map(ke=>G.jsxs("div",{className:`flex items-center gap-3 rounded-xl border p-3 ${ee}`,children:[G.jsx(uie,{className:"h-4 w-4 text-gray-500 dark:text-[#bfc2cd]"}),G.jsxs("div",{className:"min-w-0 flex-1",children:[G.jsx("p",{className:"truncate text-sm font-medium text-[#353740] dark:text-[#ececf1]",children:ke.filename}),G.jsxs("p",{className:"text-xs text-gray-500 dark:text-[#bfc2cd]",children:[(ke.file_size/1024).toFixed(1)," KB"]})]})]},ke.file_id))}),e.audio&&k&&!e.isStreaming&&G.jsx(tVe,{audio:e.audio,audioFormat:e.audioFormat,autoPlay:!1})]}),k&&!e.isStreaming&&G.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs text-gray-500 transition-opacity dark:text-[#bfc2cd] sm:opacity-0 sm:group-hover:opacity-100",children:[G.jsxs("button",{onClick:ie,className:"inline-flex items-center gap-1 rounded px-2 py-1 hover:bg-gray-200 dark:hover:bg-[#3c3f4a]",title:"Copy message",children:[G.jsx(oie,{className:"h-4 w-4"}),"Copy"]}),t&&G.jsxs("button",{onClick:()=>t(e.id),className:"inline-flex items-center gap-1 rounded px-2 py-1 hover:bg-gray-200 dark:hover:bg-[#3c3f4a]",title:"Regenerate response",children:[G.jsx(Sie,{className:"h-4 w-4"}),"Retry"]}),z&&r&&e.supportsThreading&&!e.threadInfo&&i&&G.jsxs("button",{onClick:()=>r(e.id,i),className:"inline-flex items-center gap-1 rounded px-2 py-1 hover:bg-gray-200 dark:hover:bg-[#3c3f4a]",title:"Start thread for follow-up questions",children:[G.jsx(np,{className:"h-4 w-4"}),"Start Thread"]}),QGe()&&G.jsxs("div",{className:"flex items-center gap-1",children:[G.jsx("button",{onClick:()=>se("up"),className:`rounded p-1 hover:bg-gray-200 dark:hover:bg-[#3c3f4a] ${u==="up"?"text-[#353740] dark:text-[#ececf1]":""}`,title:"Good response",children:G.jsx(Aie,{className:"h-4 w-4"})}),G.jsx("button",{onClick:()=>se("down"),className:`rounded p-1 hover:bg-gray-200 dark:hover:bg-[#3c3f4a] ${u==="down"?"text-[#353740] dark:text-[#ececf1]":""}`,title:"Poor response",children:G.jsx(_ie,{className:"h-4 w-4"})})]}),s&&G.jsx("span",{children:"Copied"})]}),z&&e.threadInfo&&G.jsxs("div",{className:"ml-12 mt-4 rounded-xl border border-blue-100/80 bg-blue-50/70 p-4 text-sm shadow-sm ring-1 ring-blue-100/60 dark:border-[#1f2a36] dark:bg-[#0f1821] dark:ring-[#1f2a36]",children:[G.jsxs("div",{className:"flex items-center justify-between text-sm font-semibold text-blue-900 dark:text-[#c5d7ff]",children:[G.jsxs("div",{className:"inline-flex items-center gap-2 uppercase tracking-wide",children:[G.jsx(np,{className:"h-3.5 w-3.5"}),G.jsxs("span",{children:["Thread replies",I>0?` (${I})`:""]})]}),G.jsx("button",{onClick:()=>g(ke=>!ke),className:"inline-flex items-center gap-2 rounded-full border border-blue-200/80 px-3 py-1.5 text-xs uppercase tracking-wide text-blue-900 transition hover:bg-white/70 dark:border-[#233449] dark:text-[#c5d7ff] dark:hover:bg-white/10",children:h?G.jsxs(G.Fragment,{children:["Hide ",G.jsx(iie,{className:"h-3 w-3"})]}):G.jsxs(G.Fragment,{children:["Show ",G.jsx(aie,{className:"h-3 w-3"})]})})]}),h&&G.jsxs(G.Fragment,{children:[G.jsx("div",{className:"mt-3 space-y-3",children:ve}),G.jsx("div",{className:"mt-3 rounded-xl border border-white/80 bg-white/95 p-3 shadow-sm dark:border-white/10 dark:bg-white/10",children:G.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[G.jsx("textarea",{ref:v,className:"flex-1 min-w-0 resize-none rounded-md border border-transparent bg-transparent px-3 py-1.5 text-sm text-[#353740] placeholder-gray-600 outline-none transition focus:border-gray-400 focus:ring-1 focus:ring-gray-300 disabled:opacity-60 dark:text-[#ececf1] dark:placeholder-[#bfc2cd] dark:focus:border-[#8e8ea0] dark:focus:ring-[#8e8ea0]",placeholder:I>0?"Reply in thread...":"Ask a follow-up...",value:d,onChange:ke=>p(ke.target.value),onKeyDown:te,disabled:H,rows:1,maxLength:j,style:{minHeight:"38px",maxHeight:"120px",border:"none",outline:"none",boxShadow:"none",WebkitAppearance:"none",MozAppearance:"none",appearance:"none"}}),G.jsxs("div",{className:"flex items-center gap-2",children:[d.length>0&&G.jsx("div",{className:"text-xs text-gray-500 dark:text-[#bfc2cd] whitespace-nowrap",children:G.jsxs("span",{className:d.length>=j?"text-red-600 font-semibold":"",children:[d.length,"/",j]})}),G.jsx("button",{type:"button",onClick:Q,disabled:H||d.trim().length===0,className:`flex h-9 w-9 items-center justify-center rounded-full transition ${d.trim().length>0&&!H?"bg-[#10a37f] text-white hover:bg-[#0f8f6f]":"bg-gray-200 text-gray-400 dark:bg-[#2f313a] dark:text-[#6b6f7a]"} disabled:cursor-not-allowed`,title:"Send thread message",children:b?G.jsx(Zc,{className:"h-4 w-4 animate-spin"}):G.jsx(aG,{className:"h-4 w-4"})})]})]})})]})]})]})]})}function aVe(e=800,t=100,r="sine"){try{const n=window.AudioContext||window.webkitAudioContext;if(!n){mt("[SoundEffects] AudioContext not supported in this browser");return}const a=new n,i=a.createOscillator(),o=a.createGain();i.connect(o),o.connect(a.destination),i.frequency.value=e,i.type=r,o.gain.setValueAtTime(.3,a.currentTime),o.gain.exponentialRampToValueAtTime(.01,a.currentTime+t/1e3),i.start(a.currentTime),i.stop(a.currentTime+t/1e3)}catch{}}const iVe={messageSent:{frequency:600,duration:80,type:"sine"},messageReceived:{frequency:800,duration:100,type:"sine"},success:{frequency:1e3,duration:150,type:"sine"},error:{frequency:400,duration:200,type:"square"},notification:{frequency:700,duration:120,type:"sine"}};function sl(e,t){if(!t)return;const r=iVe[e];if(r)try{aVe(r.frequency,r.duration,r.type),mt(`[SoundEffects] Playing ${e} sound effect`)}catch{}}function oVe({messages:e,onRegenerate:t,onStartThread:r,onSendThreadMessage:n,sessionId:a,isLoading:i}){const o=E.useRef(null),s=E.useRef(null),l=E.useRef(e.length),u=E.useRef(""),c=E.useRef(i),[d,p]=E.useState(!0),{settings:h}=Ky(),{topLevelMessages:g,threadLookup:b}=E.useMemo(()=>{const v=new Map,k=[];return e.forEach(T=>{if(T.isThreadMessage&&T.parentMessageId){const I=v.get(T.parentMessageId)||[];v.set(T.parentMessageId,[...I,T])}else k.push(T)}),{topLevelMessages:k,threadLookup:v}},[e]),w=()=>{if(!s.current)return;const{scrollTop:v,scrollHeight:k,clientHeight:T}=s.current,_=k-v-T<200;p(_)},x=(v="smooth")=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{o.current?o.current.scrollIntoView({behavior:v}):s.current&&(s.current.scrollTop=s.current.scrollHeight)})})};return E.useEffect(()=>{const v=e.length,k=l.current,T=v>k,I=e[e.length-1],_=(I==null?void 0:I.content)||"",P=_!==u.current;T||I!=null&&I.isStreaming||P&&(I==null?void 0:I.role)==="assistant"?(x(T?"auto":"smooth"),p(!0)):d&&P&&x("smooth"),l.current=v,u.current=_},[e,d]),E.useEffect(()=>{i&&(x("auto"),p(!0))},[i]),E.useEffect(()=>{if(c.current&&!i){const v=e[e.length-1];(v==null?void 0:v.role)==="assistant"&&v.content&&sl("messageReceived",h.soundEnabled)}c.current=i},[i,e,h.soundEnabled]),g.length===0?G.jsx("div",{className:"flex-1 flex items-center justify-center px-4 sm:px-6",children:G.jsxs("div",{className:"text-center text-lg text-gray-500 dark:text-[#bfc2cd]",children:[G.jsx("p",{className:"text-xl",children:"Your messages will appear here."}),G.jsx("p",{className:"mt-1 text-lg",children:"Start the conversation by sending a prompt below."})]})}):G.jsx("div",{ref:s,className:"flex-1 overflow-y-auto py-6",onScroll:w,children:G.jsxs("div",{className:"space-y-6 px-3 sm:px-4",children:[g.map(v=>G.jsx(nVe,{message:v,onRegenerate:t,onStartThread:r,onSendThreadMessage:n,threadMessages:b.get(v.id),sessionId:a,isThreadSendDisabled:i},v.id)),G.jsx("div",{ref:o,className:"h-8"})]})})}const sVe=2e3;function lVe(e,t){const[r,n]=E.useState(!1),[a,i]=E.useState(null),o=E.useRef(null),s=E.useRef(""),l=E.useRef(!1),u=E.useRef(null),c=E.useCallback(()=>{if(!s.current)return;const x=s.current;s.current="",e(" "+x)},[e]),d=typeof window<"u"&&("webkitSpeechRecognition"in window||"SpeechRecognition"in window),p=E.useCallback(()=>{!t||l.current||(l.current=!0,t())},[t]),h=E.useCallback(()=>{u.current!==null&&(clearTimeout(u.current),u.current=null)},[]),g=E.useCallback(()=>{h(),u.current=setTimeout(()=>{o.current?o.current.stop():p()},sVe)},[h,p]),b=E.useCallback(()=>{if(!d){i("Speech recognition is not supported in this browser. Please try Chrome, Edge, or Safari.");return}if(!r)try{l.current=!1;const x=window.SpeechRecognition||window.webkitSpeechRecognition,v=new x;v.continuous=!0,v.interimResults=!0,v.lang=navigator.language||"en-US",v.maxAlternatives=1,v.onstart=()=>{n(!0),i(null),mt("Speech recognition started"),g()},v.onresult=k=>{let T="",I="";for(let _=k.resultIndex;_<k.results.length;_++){const P=k.results[_][0].transcript;k.results[_].isFinal?T+=P:I+=P}I&&(s.current=I),T&&(s.current="",e(" "+T)),g()},v.onend=()=>{h(),c(),n(!1),o.current=null,mt("Speech recognition ended"),p()},v.onerror=k=>{switch(h(),N0("Speech recognition error:",k.error),n(!1),o.current=null,s.current="",p(),k.error){case"no-speech":i("No speech detected. Please try again.");break;case"audio-capture":i("Microphone access denied. Please allow microphone access and try again.");break;case"not-allowed":i("Microphone access not allowed. Please enable microphone permissions.");break;case"network":i("Network error occurred. Please check your connection.");break;default:i(`Speech recognition error: ${k.error}`)}},v.start(),o.current=v}catch{i("Failed to start speech recognition. Please try again."),n(!1)}},[d,e,r,c,p,g,h]),w=E.useCallback(()=>{if(o.current){const x=o.current;x.onend=null,x.onerror=null,x.onresult=null,x.onstart=null;try{x.stop()}catch{}o.current=null}h(),c(),n(!1),i(null),p()},[h,c,p]);return{isListening:r,isSupported:d,startListening:b,stopListening:w,error:a}}const uVe="2.1.2",cVe={"@schmitech/chatbot-api":"^2.1.1"},hte={version:uVe,dependencies:cVe},fte=hte.version,DU=hte.dependencies["@schmitech/chatbot-api"];async function x8(){try{return(await Lr(()=>import("./api-C_xfxXTe.js"),[])).version||DU}catch{return DU}}async function mte(){const e=await x8();return{appVersion:fte,apiVersion:e,isLocalApi:!0}}let Sc=null;async function dVe(e){return e==="@local-node-api/api.mjs"?Lr(()=>import("./api-DphNnWRS.js"),[]):import(e)}async function pVe(){if(Sc)return Sc;const e=KGe(),t=YGe();try{if(e){let r;t?t.startsWith("/")?r=t.startsWith("/src/")?`.${t.substring(4)}${t.endsWith(".mjs")?"":"/api.mjs"}`:"@local-node-api/api.mjs":t.startsWith("../")||t.startsWith("./")?r=t.endsWith(".mjs")?t:`${t}/api.mjs`:r=`./${t}${t.endsWith(".mjs")?"":"/api.mjs"}`:r="@local-node-api/api.mjs",mt(`🔧 Loading local API from: ${r}`);const n=await dVe(r);Sc={configureApi:n.configureApi,streamChat:n.streamChat,ApiClient:n.ApiClient},mt("✅ Local API loaded successfully")}else{mt("📦 Loading npm package API");const r=await Lr(()=>import("./api-C_xfxXTe.js"),[]),n=async function*(o,s,l,u,c,d,p,h,g,b,w){yield*r.streamChat(o,s,l,u,c,d,p,h,g,b,w)};class a{constructor(s){ai(this,"client");this.client=new r.ApiClient(s)}async*streamChat(s,l,u,c,d,p,h,g,b,w,x){yield*this.client.streamChat(s,l,u,c,d,p,h,g,b,w,x)}get createThread(){var s;return(s=this.client.createThread)==null?void 0:s.bind(this.client)}get getThreadInfo(){var s;return(s=this.client.getThreadInfo)==null?void 0:s.bind(this.client)}get deleteThread(){var s;return(s=this.client.deleteThread)==null?void 0:s.bind(this.client)}get clearConversationHistory(){var s;return(s=this.client.clearConversationHistory)==null?void 0:s.bind(this.client)}get deleteConversationWithFiles(){var s;return(s=this.client.deleteConversationWithFiles)==null?void 0:s.bind(this.client)}get getSessionId(){var s;return(s=this.client.getSessionId)==null?void 0:s.bind(this.client)}get uploadFile(){var s;return(s=this.client.uploadFile)==null?void 0:s.bind(this.client)}get listFiles(){var s;return(s=this.client.listFiles)==null?void 0:s.bind(this.client)}get getFileInfo(){var s;return(s=this.client.getFileInfo)==null?void 0:s.bind(this.client)}get queryFile(){var s;return(s=this.client.queryFile)==null?void 0:s.bind(this.client)}get deleteFile(){var s;return(s=this.client.deleteFile)==null?void 0:s.bind(this.client)}get validateApiKey(){var s;return(s=this.client.validateApiKey)==null?void 0:s.bind(this.client)}get getAdapterInfo(){var s;return(s=this.client.getAdapterInfo)==null?void 0:s.bind(this.client)}}Sc={configureApi:r.configureApi,streamChat:n,ApiClient:a};const i=await x8();mt(`✅ NPM package API loaded successfully (v${i})`)}}catch(r){if(e)try{const n=await Lr(()=>import("./api-C_xfxXTe.js"),[]),a=async function*(s,l,u,c,d,p,h,g,b,w,x){yield*n.streamChat(s,l,u,c,d,p,h,g,b,w,x)};class i{constructor(l){ai(this,"client");this.client=new n.ApiClient(l)}async*streamChat(l,u,c,d,p,h,g,b,w,x,v){yield*this.client.streamChat(l,u,c,d,p,h,g,b,w,x,v)}get createThread(){var l;return(l=this.client.createThread)==null?void 0:l.bind(this.client)}get getThreadInfo(){var l;return(l=this.client.getThreadInfo)==null?void 0:l.bind(this.client)}get deleteThread(){var l;return(l=this.client.deleteThread)==null?void 0:l.bind(this.client)}get clearConversationHistory(){var l;return(l=this.client.clearConversationHistory)==null?void 0:l.bind(this.client)}get deleteConversationWithFiles(){var l;return(l=this.client.deleteConversationWithFiles)==null?void 0:l.bind(this.client)}get getSessionId(){var l;return(l=this.client.getSessionId)==null?void 0:l.bind(this.client)}get uploadFile(){var l;return(l=this.client.uploadFile)==null?void 0:l.bind(this.client)}get listFiles(){var l;return(l=this.client.listFiles)==null?void 0:l.bind(this.client)}get getFileInfo(){var l;return(l=this.client.getFileInfo)==null?void 0:l.bind(this.client)}get queryFile(){var l;return(l=this.client.queryFile)==null?void 0:l.bind(this.client)}get deleteFile(){var l;return(l=this.client.deleteFile)==null?void 0:l.bind(this.client)}get validateApiKey(){var l;return(l=this.client.validateApiKey)==null?void 0:l.bind(this.client)}get getAdapterInfo(){var l;return(l=this.client.getAdapterInfo)==null?void 0:l.bind(this.client)}}Sc={configureApi:n.configureApi,streamChat:a,ApiClient:i};const o=await x8();mt(`✅ Fallback to NPM package successful (v${o})`)}catch{throw new Error("Failed to load both local and npm API packages")}else throw r}return Sc}async function Un(){return await pVe()}const um=Cu(),hVe=()=>{try{if(typeof window>"u"||!window.localStorage)return null;const e=window.localStorage.getItem("chat-api-url");return e&&e===Ku?(window.localStorage.removeItem("chat-api-url"),null):e}catch{return null}},Dd=e=>{const t=e==null?void 0:e.trim();if(t)return t;const r=hVe();return r&&r!==Ku?r:ea()};class yu{static async uploadFile(t,r,n,a){try{const i=Er.maxFileSizeMB*1024*1024;if(t.size>i)throw new Error(`File size exceeds maximum limit of ${Er.maxFileSizeMB}MB`);if(!(["application/pdf","text/plain","text/markdown","text/csv","application/json","text/html","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel","application/vnd.ms-excel.sheet.macroEnabled.12","text/x-python","text/x-python-script","text/x-java-source","text/x-java","text/x-sql","text/javascript","application/javascript","text/typescript","application/typescript","text/x-c++src","text/x-csrc","text/x-c","text/x-go","text/x-rust","text/x-ruby","text/x-php","text/x-shellscript","text/x-sh","text/yaml","text/x-yaml","text/xml","application/xml","text/css","text/x-scss","text/x-sass","text/x-less","image/png","image/jpeg","image/tiff","audio/wav","audio/mpeg","audio/mp3","audio/mp4","audio/ogg","audio/flac","audio/webm","audio/x-m4a","audio/aac","text/vtt"].includes(t.type)||/\.(pdf|txt|md|csv|json|html|docx|pptx|xlsx|py|java|sql|js|mjs|ts|tsx|cpp|cxx|cc|c|h|hpp|go|rs|rb|php|sh|bash|zsh|yaml|yml|xml|css|scss|sass|less|png|jpe?g|tiff?|wav|mp3|mp4|ogg|flac|webm|m4a|aac|vtt)$/i.test(t.name)||(t.type==="application/x-zip-compressed"||t.type==="application/zip")&&/\.xlsx$/i.test(t.name)))throw new Error(`File type not supported: ${t.type||"unknown"}`);r&&r({filename:t.name,progress:0,status:"uploading"});const l=await Un(),u=Dd(a),c=n||localStorage.getItem("chat-api-key")||window.CHATBOT_API_KEY||um;if(!c||c==="your-api-key-here")throw new Error(`API key not configured or invalid. Please:
992
+ ... (content truncated due to length)`}const Er={maxFilesPerConversation:ca.maxFilesPerConversation,maxFileSizeMB:ca.maxFileSizeMB,maxTotalFiles:ca.maxTotalFiles,maxConversations:ca.maxConversations,maxMessagesPerConversation:ca.maxMessagesPerConversation,maxTotalMessages:ca.maxTotalMessages,maxMessageLength:ca.maxMessageLength},rVe=[];function nVe({message:e,onRegenerate:t,onStartThread:r,onSendThreadMessage:n,threadMessages:a,sessionId:i,isThreadSendDisabled:o}){var V,ge;const[s,l]=E.useState(!1),[u,c]=E.useState(null),[d,p]=E.useState(""),[h,g]=E.useState(!1),[b,w]=E.useState(!1),x=E.useRef(((V=e.threadInfo)==null?void 0:V.thread_id)||null),v=E.useRef(null),k=e.role==="assistant",T=a??rVe,I=T.length,_=T.some(ke=>ke.isStreaming),P="en-US",z=JGe(),j=Er.maxMessageLength;E.useEffect(()=>{var ke,ze;!x.current&&((ke=e.threadInfo)!=null&&ke.thread_id)&&g(!0),x.current=((ze=e.threadInfo)==null?void 0:ze.thread_id)||null},[(ge=e.threadInfo)==null?void 0:ge.thread_id]),E.useEffect(()=>{e.threadInfo||(p(""),g(!1),w(!1))},[e.threadInfo]),E.useEffect(()=>{I>0&&g(!0)},[I]);const D=E.useMemo(()=>{const ke=e.timestamp instanceof Date?e.timestamp:new Date(e.timestamp),ze=ke.toLocaleDateString(P,{weekday:"short"}),Ee=ke.toLocaleDateString(P,{month:"short"}),Ve=ke.getDate().toString().padStart(2,"0"),me=ke.getFullYear(),je=ke.toLocaleTimeString(P,{hour:"2-digit",minute:"2-digit",hour12:!0});return`${ze}, ${Ee} ${Ve}, ${me} ${je}`},[e.timestamp,P]),B=k?"markdown-content prose prose-slate dark:prose-invert max-w-none":"markdown-content prose prose-invert max-w-none",J=k?"bg-gradient-to-br from-blue-100 to-blue-200 text-blue-900 dark:from-[#1f2a36] dark:to-[#1a2230] dark:text-[#c5d7ff]":"bg-gradient-to-br from-emerald-100 to-emerald-200 text-emerald-900 dark:from-[#0f1f17] dark:to-[#0b1712] dark:text-[#c7f5df]",ye=`message-bubble min-w-0 break-words leading-relaxed ${k?"border border-blue-100/80 bg-transparent text-[#0f172a] shadow-[0_15px_35px_-20px_rgba(15,23,42,0.25)] dark:border-[#1f2a36] dark:bg-transparent dark:text-[#e5edff]":"border border-emerald-100 bg-transparent text-[#1c3226] shadow-[0_12px_30px_-18px_rgba(15,52,33,0.25)] dark:border-[#1a2b21] dark:bg-transparent dark:text-[#dffbea]"} rounded-2xl px-4 py-3`,ee=k?"border-blue-100 bg-white/80 dark:border-[#1f2a36] dark:bg-white/5":"border-emerald-100 bg-white/80 dark:border-[#1a2b21] dark:bg-white/5",ie=async()=>{try{await navigator.clipboard.writeText(e.content),l(!0),setTimeout(()=>l(!1),2e3)}catch{}},se=ke=>{c(u===ke?null:ke)},ue=E.useCallback(ke=>(ke instanceof Date?ke:new Date(ke)).toLocaleTimeString(P,{hour:"2-digit",minute:"2-digit"}),[P]),Q=async()=>{if(!n||!e.threadInfo)return;const ke=d.trim();if(ke){w(!0);try{await n(e.threadInfo.thread_id,e.id,ke),p("")}catch{}finally{w(!1)}}},te=ke=>{ke.key==="Enter"&&!ke.shiftKey&&(ke.preventDefault(),Q())},H=!e.threadInfo||!n||o||_||b;E.useEffect(()=>{if(v.current){const ze=v.current;ze.style.height="auto";const Ee=ze.scrollHeight;ze.style.height=`${Math.min(Ee,120)}px`,ze.style.overflowY=Ee>120?"auto":"hidden"}},[d]);const le=E.useMemo(()=>e.isStreaming&&(!e.content||e.content==="…")?G.jsxs("div",{className:"flex items-center gap-1.5 py-1",children:[G.jsx("span",{className:"inline-block h-2.5 w-2.5 animate-bounce rounded-full bg-gray-400 dark:bg-[#bfc2cd]",style:{animationDelay:"0ms"}}),G.jsx("span",{className:"inline-block h-2.5 w-2.5 animate-bounce rounded-full bg-gray-400 dark:bg-[#bfc2cd]",style:{animationDelay:"150ms"}}),G.jsx("span",{className:"inline-block h-2.5 w-2.5 animate-bounce rounded-full bg-gray-400 dark:bg-[#bfc2cd]",style:{animationDelay:"300ms"}})]}):G.jsx(RU,{content:v8(yp(e.content||""))}),[e.content,e.isStreaming]),ve=E.useMemo(()=>T.map(ke=>{const ze=ke.role==="assistant",Ee=ke.isStreaming&&(!ke.content||ke.content==="…")?G.jsxs("div",{className:"flex items-center gap-1.5 py-1",children:[G.jsx("span",{className:"inline-block h-2 w-2 animate-bounce rounded-full bg-gray-400 dark:bg-[#bfc2cd]",style:{animationDelay:"0ms"}}),G.jsx("span",{className:"inline-block h-2 w-2 animate-bounce rounded-full bg-gray-400 dark:bg-[#bfc2cd]",style:{animationDelay:"150ms"}}),G.jsx("span",{className:"inline-block h-2 w-2 animate-bounce rounded-full bg-gray-400 dark:bg-[#bfc2cd]",style:{animationDelay:"300ms"}})]}):G.jsx(RU,{content:v8(yp(ke.content||""))});return G.jsxs("div",{className:"flex items-start gap-3",children:[G.jsx("div",{className:`mt-0.5 flex h-7 w-7 flex-shrink-0 items-center justify-center rounded-full ${ze?"bg-blue-100 text-blue-700 dark:bg-[#1f2a36] dark:text-[#c5d7ff]":"bg-emerald-100 text-emerald-700 dark:bg-[#1f2a36] dark:text-[#9ef0d5]"}`,children:ze?G.jsx(JC,{className:"h-3.5 w-3.5"}):G.jsx(rI,{className:"h-3.5 w-3.5"})}),G.jsxs("div",{className:"flex-1 rounded-2xl border border-white/70 bg-white/90 px-4 py-3 text-sm shadow-sm dark:border-white/5 dark:bg-white/5 backdrop-blur",children:[G.jsxs("div",{className:"mb-1 flex items-center justify-between text-[11px] font-semibold uppercase tracking-wide text-blue-900/70 dark:text-[#c5d7ff]",children:[G.jsx("span",{children:ze?"Assistant":"You"}),G.jsx("span",{children:ue(ke.timestamp)})]}),G.jsx("div",{className:"prose prose-slate max-w-none text-sm text-[#353740] dark:prose-invert dark:text-[#ececf1]",children:Ee})]})]},ke.id)}),[ue,T]);return G.jsxs("div",{className:"group flex items-start gap-3 px-1 animate-fadeIn min-w-0 sm:px-0",children:[G.jsx("div",{className:`flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-full self-start -mt-2 ml-1 shadow-sm ring-2 ring-white/50 dark:ring-white/10 sm:-mt-3 sm:ml-2 ${J}`,children:k?G.jsx(JC,{className:"h-5 w-5"}):G.jsx(rI,{className:"h-5 w-5"})}),G.jsxs("div",{className:"flex-1 min-w-0 space-y-2",children:[G.jsxs("div",{className:"flex flex-col gap-1.5 mb-1",children:[G.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-gray-700 dark:text-[#ececf1]",children:k?"Assistant":"You"}),G.jsx("span",{className:"text-xs text-gray-500 dark:text-[#bfc2cd]",children:D})]}),G.jsxs("div",{className:ye,children:[G.jsx("div",{className:B,children:le}),e.attachments&&e.attachments.length>0&&G.jsx("div",{className:"mt-3 space-y-2",children:e.attachments.map(ke=>G.jsxs("div",{className:`flex items-center gap-3 rounded-xl border p-3 ${ee}`,children:[G.jsx(uie,{className:"h-4 w-4 text-gray-500 dark:text-[#bfc2cd]"}),G.jsxs("div",{className:"min-w-0 flex-1",children:[G.jsx("p",{className:"truncate text-sm font-medium text-[#353740] dark:text-[#ececf1]",children:ke.filename}),G.jsxs("p",{className:"text-xs text-gray-500 dark:text-[#bfc2cd]",children:[(ke.file_size/1024).toFixed(1)," KB"]})]})]},ke.file_id))}),e.audio&&k&&!e.isStreaming&&G.jsx(tVe,{audio:e.audio,audioFormat:e.audioFormat,autoPlay:!1})]}),k&&!e.isStreaming&&G.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs text-gray-500 transition-opacity dark:text-[#bfc2cd] sm:opacity-0 sm:group-hover:opacity-100",children:[G.jsxs("button",{onClick:ie,className:"inline-flex items-center gap-1 rounded px-2 py-1 hover:bg-gray-200 dark:hover:bg-[#3c3f4a]",title:"Copy message",children:[G.jsx(oie,{className:"h-4 w-4"}),"Copy"]}),t&&G.jsxs("button",{onClick:()=>t(e.id),className:"inline-flex items-center gap-1 rounded px-2 py-1 hover:bg-gray-200 dark:hover:bg-[#3c3f4a]",title:"Regenerate response",children:[G.jsx(Sie,{className:"h-4 w-4"}),"Retry"]}),z&&r&&e.supportsThreading&&!e.threadInfo&&i&&G.jsxs("button",{onClick:()=>r(e.id,i),className:"inline-flex items-center gap-1 rounded px-2 py-1 hover:bg-gray-200 dark:hover:bg-[#3c3f4a]",title:"Start thread for follow-up questions",children:[G.jsx(np,{className:"h-4 w-4"}),"Start Thread"]}),QGe()&&G.jsxs("div",{className:"flex items-center gap-1",children:[G.jsx("button",{onClick:()=>se("up"),className:`rounded p-1 hover:bg-gray-200 dark:hover:bg-[#3c3f4a] ${u==="up"?"text-[#353740] dark:text-[#ececf1]":""}`,title:"Good response",children:G.jsx(Aie,{className:"h-4 w-4"})}),G.jsx("button",{onClick:()=>se("down"),className:`rounded p-1 hover:bg-gray-200 dark:hover:bg-[#3c3f4a] ${u==="down"?"text-[#353740] dark:text-[#ececf1]":""}`,title:"Poor response",children:G.jsx(_ie,{className:"h-4 w-4"})})]}),s&&G.jsx("span",{children:"Copied"})]}),z&&e.threadInfo&&G.jsxs("div",{className:"ml-12 mt-4 rounded-xl border border-blue-100/80 bg-blue-50/70 p-4 text-sm shadow-sm ring-1 ring-blue-100/60 dark:border-[#1f2a36] dark:bg-[#0f1821] dark:ring-[#1f2a36]",children:[G.jsxs("div",{className:"flex items-center justify-between text-sm font-semibold text-blue-900 dark:text-[#c5d7ff]",children:[G.jsxs("div",{className:"inline-flex items-center gap-2 uppercase tracking-wide",children:[G.jsx(np,{className:"h-3.5 w-3.5"}),G.jsxs("span",{children:["Thread replies",I>0?` (${I})`:""]})]}),G.jsx("button",{onClick:()=>g(ke=>!ke),className:"inline-flex items-center gap-2 rounded-full border border-blue-200/80 px-3 py-1.5 text-xs uppercase tracking-wide text-blue-900 transition hover:bg-white/70 dark:border-[#233449] dark:text-[#c5d7ff] dark:hover:bg-white/10",children:h?G.jsxs(G.Fragment,{children:["Hide ",G.jsx(iie,{className:"h-3 w-3"})]}):G.jsxs(G.Fragment,{children:["Show ",G.jsx(aie,{className:"h-3 w-3"})]})})]}),h&&G.jsxs(G.Fragment,{children:[G.jsx("div",{className:"mt-3 space-y-3",children:ve}),G.jsx("div",{className:"mt-3 rounded-xl border border-white/80 bg-white/95 p-3 shadow-sm dark:border-white/10 dark:bg-white/10",children:G.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[G.jsx("textarea",{ref:v,className:"flex-1 min-w-0 resize-none rounded-md border border-transparent bg-transparent px-3 py-1.5 text-sm text-[#353740] placeholder-gray-600 outline-none transition focus:border-gray-400 focus:ring-1 focus:ring-gray-300 disabled:opacity-60 dark:text-[#ececf1] dark:placeholder-[#bfc2cd] dark:focus:border-[#8e8ea0] dark:focus:ring-[#8e8ea0]",placeholder:I>0?"Reply in thread...":"Ask a follow-up...",value:d,onChange:ke=>p(ke.target.value),onKeyDown:te,disabled:H,rows:1,maxLength:j,style:{minHeight:"38px",maxHeight:"120px",border:"none",outline:"none",boxShadow:"none",WebkitAppearance:"none",MozAppearance:"none",appearance:"none"}}),G.jsxs("div",{className:"flex items-center gap-2",children:[d.length>0&&G.jsx("div",{className:"text-xs text-gray-500 dark:text-[#bfc2cd] whitespace-nowrap",children:G.jsxs("span",{className:d.length>=j?"text-red-600 font-semibold":"",children:[d.length,"/",j]})}),G.jsx("button",{type:"button",onClick:Q,disabled:H||d.trim().length===0,className:`flex h-9 w-9 items-center justify-center rounded-full transition ${d.trim().length>0&&!H?"bg-[#10a37f] text-white hover:bg-[#0f8f6f]":"bg-gray-200 text-gray-400 dark:bg-[#2f313a] dark:text-[#6b6f7a]"} disabled:cursor-not-allowed`,title:"Send thread message",children:b?G.jsx(Zc,{className:"h-4 w-4 animate-spin"}):G.jsx(aG,{className:"h-4 w-4"})})]})]})})]})]})]})]})}function aVe(e=800,t=100,r="sine"){try{const n=window.AudioContext||window.webkitAudioContext;if(!n){mt("[SoundEffects] AudioContext not supported in this browser");return}const a=new n,i=a.createOscillator(),o=a.createGain();i.connect(o),o.connect(a.destination),i.frequency.value=e,i.type=r,o.gain.setValueAtTime(.3,a.currentTime),o.gain.exponentialRampToValueAtTime(.01,a.currentTime+t/1e3),i.start(a.currentTime),i.stop(a.currentTime+t/1e3)}catch{}}const iVe={messageSent:{frequency:600,duration:80,type:"sine"},messageReceived:{frequency:800,duration:100,type:"sine"},success:{frequency:1e3,duration:150,type:"sine"},error:{frequency:400,duration:200,type:"square"},notification:{frequency:700,duration:120,type:"sine"}};function sl(e,t){if(!t)return;const r=iVe[e];if(r)try{aVe(r.frequency,r.duration,r.type),mt(`[SoundEffects] Playing ${e} sound effect`)}catch{}}function oVe({messages:e,onRegenerate:t,onStartThread:r,onSendThreadMessage:n,sessionId:a,isLoading:i}){const o=E.useRef(null),s=E.useRef(null),l=E.useRef(e.length),u=E.useRef(""),c=E.useRef(i),[d,p]=E.useState(!0),{settings:h}=Ky(),{topLevelMessages:g,threadLookup:b}=E.useMemo(()=>{const v=new Map,k=[];return e.forEach(T=>{if(T.isThreadMessage&&T.parentMessageId){const I=v.get(T.parentMessageId)||[];v.set(T.parentMessageId,[...I,T])}else k.push(T)}),{topLevelMessages:k,threadLookup:v}},[e]),w=()=>{if(!s.current)return;const{scrollTop:v,scrollHeight:k,clientHeight:T}=s.current,_=k-v-T<200;p(_)},x=(v="smooth")=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{o.current?o.current.scrollIntoView({behavior:v}):s.current&&(s.current.scrollTop=s.current.scrollHeight)})})};return E.useEffect(()=>{const v=e.length,k=l.current,T=v>k,I=e[e.length-1],_=(I==null?void 0:I.content)||"",P=_!==u.current;T||I!=null&&I.isStreaming||P&&(I==null?void 0:I.role)==="assistant"?(x(T?"auto":"smooth"),p(!0)):d&&P&&x("smooth"),l.current=v,u.current=_},[e,d]),E.useEffect(()=>{i&&(x("auto"),p(!0))},[i]),E.useEffect(()=>{if(c.current&&!i){const v=e[e.length-1];(v==null?void 0:v.role)==="assistant"&&v.content&&sl("messageReceived",h.soundEnabled)}c.current=i},[i,e,h.soundEnabled]),g.length===0?G.jsx("div",{className:"flex-1 flex items-center justify-center px-4 sm:px-6",children:G.jsxs("div",{className:"text-center text-lg text-gray-500 dark:text-[#bfc2cd]",children:[G.jsx("p",{className:"text-xl",children:"Your messages will appear here."}),G.jsx("p",{className:"mt-1 text-lg",children:"Start the conversation by sending a prompt below."})]})}):G.jsx("div",{ref:s,className:"flex-1 overflow-y-auto py-6",onScroll:w,children:G.jsxs("div",{className:"space-y-6 px-3 sm:px-4",children:[g.map(v=>G.jsx(nVe,{message:v,onRegenerate:t,onStartThread:r,onSendThreadMessage:n,threadMessages:b.get(v.id),sessionId:a,isThreadSendDisabled:i},v.id)),G.jsx("div",{ref:o,className:"h-8"})]})})}const sVe=2e3;function lVe(e,t){const[r,n]=E.useState(!1),[a,i]=E.useState(null),o=E.useRef(null),s=E.useRef(""),l=E.useRef(!1),u=E.useRef(null),c=E.useCallback(()=>{if(!s.current)return;const x=s.current;s.current="",e(" "+x)},[e]),d=typeof window<"u"&&("webkitSpeechRecognition"in window||"SpeechRecognition"in window),p=E.useCallback(()=>{!t||l.current||(l.current=!0,t())},[t]),h=E.useCallback(()=>{u.current!==null&&(clearTimeout(u.current),u.current=null)},[]),g=E.useCallback(()=>{h(),u.current=setTimeout(()=>{o.current?o.current.stop():p()},sVe)},[h,p]),b=E.useCallback(()=>{if(!d){i("Speech recognition is not supported in this browser. Please try Chrome, Edge, or Safari.");return}if(!r)try{l.current=!1;const x=window.SpeechRecognition||window.webkitSpeechRecognition,v=new x;v.continuous=!0,v.interimResults=!0,v.lang=navigator.language||"en-US",v.maxAlternatives=1,v.onstart=()=>{n(!0),i(null),mt("Speech recognition started"),g()},v.onresult=k=>{let T="",I="";for(let _=k.resultIndex;_<k.results.length;_++){const P=k.results[_][0].transcript;k.results[_].isFinal?T+=P:I+=P}I&&(s.current=I),T&&(s.current="",e(" "+T)),g()},v.onend=()=>{h(),c(),n(!1),o.current=null,mt("Speech recognition ended"),p()},v.onerror=k=>{switch(h(),N0("Speech recognition error:",k.error),n(!1),o.current=null,s.current="",p(),k.error){case"no-speech":i("No speech detected. Please try again.");break;case"audio-capture":i("Microphone access denied. Please allow microphone access and try again.");break;case"not-allowed":i("Microphone access not allowed. Please enable microphone permissions.");break;case"network":i("Network error occurred. Please check your connection.");break;default:i(`Speech recognition error: ${k.error}`)}},v.start(),o.current=v}catch{i("Failed to start speech recognition. Please try again."),n(!1)}},[d,e,r,c,p,g,h]),w=E.useCallback(()=>{if(o.current){const x=o.current;x.onend=null,x.onerror=null,x.onresult=null,x.onstart=null;try{x.stop()}catch{}o.current=null}h(),c(),n(!1),i(null),p()},[h,c,p]);return{isListening:r,isSupported:d,startListening:b,stopListening:w,error:a}}const uVe="2.1.3",cVe={"@schmitech/chatbot-api":"^2.1.1"},hte={version:uVe,dependencies:cVe},fte=hte.version,DU=hte.dependencies["@schmitech/chatbot-api"];async function x8(){try{return(await Lr(()=>import("./api-wWN3AN9F.js"),[])).version||DU}catch{return DU}}async function mte(){const e=await x8();return{appVersion:fte,apiVersion:e,isLocalApi:!0}}let Sc=null;async function dVe(e){return e==="@local-node-api/api.mjs"?Lr(()=>import("./api-CSbNIWZU.js"),[]):import(e)}async function pVe(){if(Sc)return Sc;const e=KGe(),t=YGe();try{if(e){let r;t?t.startsWith("/")?r=t.startsWith("/src/")?`.${t.substring(4)}${t.endsWith(".mjs")?"":"/api.mjs"}`:"@local-node-api/api.mjs":t.startsWith("../")||t.startsWith("./")?r=t.endsWith(".mjs")?t:`${t}/api.mjs`:r=`./${t}${t.endsWith(".mjs")?"":"/api.mjs"}`:r="@local-node-api/api.mjs",mt(`🔧 Loading local API from: ${r}`);const n=await dVe(r);Sc={configureApi:n.configureApi,streamChat:n.streamChat,ApiClient:n.ApiClient},mt("✅ Local API loaded successfully")}else{mt("📦 Loading npm package API");const r=await Lr(()=>import("./api-wWN3AN9F.js"),[]),n=async function*(o,s,l,u,c,d,p,h,g,b,w){yield*r.streamChat(o,s,l,u,c,d,p,h,g,b,w)};class a{constructor(s){ai(this,"client");this.client=new r.ApiClient(s)}async*streamChat(s,l,u,c,d,p,h,g,b,w,x){yield*this.client.streamChat(s,l,u,c,d,p,h,g,b,w,x)}get createThread(){var s;return(s=this.client.createThread)==null?void 0:s.bind(this.client)}get getThreadInfo(){var s;return(s=this.client.getThreadInfo)==null?void 0:s.bind(this.client)}get deleteThread(){var s;return(s=this.client.deleteThread)==null?void 0:s.bind(this.client)}get clearConversationHistory(){var s;return(s=this.client.clearConversationHistory)==null?void 0:s.bind(this.client)}get deleteConversationWithFiles(){var s;return(s=this.client.deleteConversationWithFiles)==null?void 0:s.bind(this.client)}get getSessionId(){var s;return(s=this.client.getSessionId)==null?void 0:s.bind(this.client)}get uploadFile(){var s;return(s=this.client.uploadFile)==null?void 0:s.bind(this.client)}get listFiles(){var s;return(s=this.client.listFiles)==null?void 0:s.bind(this.client)}get getFileInfo(){var s;return(s=this.client.getFileInfo)==null?void 0:s.bind(this.client)}get queryFile(){var s;return(s=this.client.queryFile)==null?void 0:s.bind(this.client)}get deleteFile(){var s;return(s=this.client.deleteFile)==null?void 0:s.bind(this.client)}get validateApiKey(){var s;return(s=this.client.validateApiKey)==null?void 0:s.bind(this.client)}get getAdapterInfo(){var s;return(s=this.client.getAdapterInfo)==null?void 0:s.bind(this.client)}}Sc={configureApi:r.configureApi,streamChat:n,ApiClient:a};const i=await x8();mt(`✅ NPM package API loaded successfully (v${i})`)}}catch(r){if(e)try{const n=await Lr(()=>import("./api-wWN3AN9F.js"),[]),a=async function*(s,l,u,c,d,p,h,g,b,w,x){yield*n.streamChat(s,l,u,c,d,p,h,g,b,w,x)};class i{constructor(l){ai(this,"client");this.client=new n.ApiClient(l)}async*streamChat(l,u,c,d,p,h,g,b,w,x,v){yield*this.client.streamChat(l,u,c,d,p,h,g,b,w,x,v)}get createThread(){var l;return(l=this.client.createThread)==null?void 0:l.bind(this.client)}get getThreadInfo(){var l;return(l=this.client.getThreadInfo)==null?void 0:l.bind(this.client)}get deleteThread(){var l;return(l=this.client.deleteThread)==null?void 0:l.bind(this.client)}get clearConversationHistory(){var l;return(l=this.client.clearConversationHistory)==null?void 0:l.bind(this.client)}get deleteConversationWithFiles(){var l;return(l=this.client.deleteConversationWithFiles)==null?void 0:l.bind(this.client)}get getSessionId(){var l;return(l=this.client.getSessionId)==null?void 0:l.bind(this.client)}get uploadFile(){var l;return(l=this.client.uploadFile)==null?void 0:l.bind(this.client)}get listFiles(){var l;return(l=this.client.listFiles)==null?void 0:l.bind(this.client)}get getFileInfo(){var l;return(l=this.client.getFileInfo)==null?void 0:l.bind(this.client)}get queryFile(){var l;return(l=this.client.queryFile)==null?void 0:l.bind(this.client)}get deleteFile(){var l;return(l=this.client.deleteFile)==null?void 0:l.bind(this.client)}get validateApiKey(){var l;return(l=this.client.validateApiKey)==null?void 0:l.bind(this.client)}get getAdapterInfo(){var l;return(l=this.client.getAdapterInfo)==null?void 0:l.bind(this.client)}}Sc={configureApi:n.configureApi,streamChat:a,ApiClient:i};const o=await x8();mt(`✅ Fallback to NPM package successful (v${o})`)}catch{throw new Error("Failed to load both local and npm API packages")}else throw r}return Sc}async function Un(){return await pVe()}const um=Cu(),hVe=()=>{try{if(typeof window>"u"||!window.localStorage)return null;const e=window.localStorage.getItem("chat-api-url");return e&&e===Ku?(window.localStorage.removeItem("chat-api-url"),null):e}catch{return null}},Dd=e=>{const t=e==null?void 0:e.trim();if(t)return t;const r=hVe();return r&&r!==Ku?r:ea()};class yu{static async uploadFile(t,r,n,a){try{const i=Er.maxFileSizeMB*1024*1024;if(t.size>i)throw new Error(`File size exceeds maximum limit of ${Er.maxFileSizeMB}MB`);if(!(["application/pdf","text/plain","text/markdown","text/csv","application/json","text/html","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel","application/vnd.ms-excel.sheet.macroEnabled.12","text/x-python","text/x-python-script","text/x-java-source","text/x-java","text/x-sql","text/javascript","application/javascript","text/typescript","application/typescript","text/x-c++src","text/x-csrc","text/x-c","text/x-go","text/x-rust","text/x-ruby","text/x-php","text/x-shellscript","text/x-sh","text/yaml","text/x-yaml","text/xml","application/xml","text/css","text/x-scss","text/x-sass","text/x-less","image/png","image/jpeg","image/tiff","audio/wav","audio/mpeg","audio/mp3","audio/mp4","audio/ogg","audio/flac","audio/webm","audio/x-m4a","audio/aac","text/vtt"].includes(t.type)||/\.(pdf|txt|md|csv|json|html|docx|pptx|xlsx|py|java|sql|js|mjs|ts|tsx|cpp|cxx|cc|c|h|hpp|go|rs|rb|php|sh|bash|zsh|yaml|yml|xml|css|scss|sass|less|png|jpe?g|tiff?|wav|mp3|mp4|ogg|flac|webm|m4a|aac|vtt)$/i.test(t.name)||(t.type==="application/x-zip-compressed"||t.type==="application/zip")&&/\.xlsx$/i.test(t.name)))throw new Error(`File type not supported: ${t.type||"unknown"}`);r&&r({filename:t.name,progress:0,status:"uploading"});const l=await Un(),u=Dd(a),c=n||localStorage.getItem("chat-api-key")||window.CHATBOT_API_KEY||um;if(!c||c==="your-api-key-here")throw new Error(`API key not configured or invalid. Please:
993
993
  1. Open Settings (⚙️ icon) in the top-right corner
994
994
  2. Enter a valid API key
995
995
  3. To create an API key: POST to /admin/api-keys with admin credentials
@@ -1000,7 +1000,7 @@ ${e.themeCSS}`),e.fontFamily!==void 0&&(n+=`
1000
1000
  Example: curl -X POST ${u}/admin/api-keys \\
1001
1001
  -H "Authorization: Bearer <admin-token>" \\
1002
1002
  -H "Content-Type: application/json" \\
1003
- -d '{"client_name": "chat-app", "adapter_name": "file-document-qa"}'`}else o.includes("API key not configured")&&(o=i.message);throw r&&r({filename:t.name,progress:0,status:"error",error:o}),new Error(o)}}static async uploadFiles(t,r){const n=t.map(async(a,i)=>{try{return await this.uploadFile(a,o=>{r&&r(i,o)})}catch(o){throw $n(`Failed to upload file ${a.name}:`,o),o}});return Promise.all(n)}static async listFiles(t,r){try{const n=await Un(),a=Dd(r),i=t||localStorage.getItem("chat-api-key")||window.CHATBOT_API_KEY||um;if(!i||i==="your-api-key-here"||i==="orbit-123456789")throw new Error("API key not configured");const o=new n.ApiClient({apiUrl:a,apiKey:i,sessionId:null});if(!o.listFiles)throw new Error("File listing is not available. Please use the local API build or update the npm package.");return(await o.listFiles()).map(l=>({file_id:l.file_id,filename:l.filename,mime_type:l.mime_type,file_size:l.file_size,upload_timestamp:l.upload_timestamp,processing_status:l.processing_status,chunk_count:l.chunk_count}))}catch(n){throw $n("Failed to list files:",n),new Error(n.message||"Failed to list files")}}static async getFileInfo(t,r,n){try{const a=await Un(),i=Dd(n),o=r||localStorage.getItem("chat-api-key")||window.CHATBOT_API_KEY||um;if(!o||o==="your-api-key-here"||o==="orbit-123456789")throw new Error("API key not configured");const s=new a.ApiClient({apiUrl:i,apiKey:o,sessionId:null});if(!s.getFileInfo)throw new Error("File info retrieval is not available. Please use the local API build or update the npm package.");const l=await s.getFileInfo(t);return{file_id:l.file_id,filename:l.filename,mime_type:l.mime_type,file_size:l.file_size,upload_timestamp:l.upload_timestamp,processing_status:l.processing_status,chunk_count:l.chunk_count}}catch(a){throw a.message&&(a.message.includes("404")||a.message.includes("File not found"))?new Error(`File ${t} was deleted`):($n(`Failed to get file info for ${t}:`,a),new Error(a.message||`Failed to get file info: ${t}`))}}static async pollFileStatus(t,r=30,n=2e3,a){for(let i=0;i<r;i++)try{if(a&&!a())throw new Error("Polling cancelled - component unmounted");const o=await this.getFileInfo(t);if(o.processing_status==="completed")return o;if(o.processing_status==="error"||o.processing_status==="failed")throw new Error(`File processing failed for ${t}`);i<r-1&&await new Promise(s=>setTimeout(s,n))}catch(o){if(o.message&&(o.message.includes("404")||o.message.includes("File not found")||o.message.includes("was deleted")))throw new Error(`File ${t} was deleted during upload`);if(o.message&&o.message.includes("component unmounted"))throw o;if(i<r-1){await new Promise(s=>setTimeout(s,n));continue}throw o}throw new Error(`File processing timeout: ${t} did not complete within ${r*n/1e3} seconds`)}static async deleteFile(t,r,n){try{const a=await Un(),i=Dd(n),o=r||localStorage.getItem("chat-api-key")||window.CHATBOT_API_KEY||um;if(!o||o==="your-api-key-here"||o==="orbit-123456789")throw new Error("API key not configured");const s=new a.ApiClient({apiUrl:i,apiKey:o,sessionId:null});if(!s.deleteFile)throw new Error("File deletion is not available. Please use the local API build or update the npm package.");return await s.deleteFile(t)}catch(a){if(a.message&&(a.message.includes("404")||a.message.includes("File not found")||a.message.includes("Not Found")))return{message:"File already deleted",file_id:t};throw $n(`Failed to delete file ${t}:`,a),new Error(a.message||`Failed to delete file: ${t}`)}}}const FU=e=>{let t;const r=new Set,n=(u,c)=>{const d=typeof u=="function"?u(t):u;if(!Object.is(d,t)){const p=t;t=c??(typeof d!="object"||d===null)?d:Object.assign({},t,d),r.forEach(h=>h(t,p))}},a=()=>t,s={setState:n,getState:a,getInitialState:()=>l,subscribe:u=>(r.add(u),()=>r.delete(u))},l=t=e(n,a,s);return s},fVe=e=>e?FU(e):FU,mVe=e=>e;function gVe(e,t=mVe){const r=Vn.useSyncExternalStore(e.subscribe,Vn.useCallback(()=>t(e.getState()),[e,t]),Vn.useCallback(()=>t(e.getInitialState()),[e,t]));return Vn.useDebugValue(r),r}const BU=e=>{const t=fVe(e),r=n=>gVe(t,n);return Object.assign(r,t),r},yVe=e=>e?BU(e):BU;class bVe{constructor(){ai(this,"audioQueue",[]);ai(this,"isPlaying",!1);ai(this,"currentAudio",null);ai(this,"audioContext",null);ai(this,"isEnabled",!1);ai(this,"onPlaybackStart",null);ai(this,"onPlaybackEnd",null);ai(this,"onChunkPlayed",null);ai(this,"blobUrls",[]);ai(this,"suppressPlaybackErrors",!1)}async enableAudio(){try{try{const t=new Audio("data:audio/wav;base64,UklGRigAAABXQVZFZm10IBAAAAABAAEARKwAAIhYAQACABAAZGF0YQAAAAA=");t.volume=0,await t.play(),t.pause()}catch{mt("[AudioStreamManager] Silent audio unlock deferred (will work on next interaction)")}return this.isEnabled=!0,mt("[AudioStreamManager] Audio playback enabled"),!0}catch{return!1}}disableAudio(){!this.isEnabled&&!this.isPlaying||(this.isEnabled=!1,this.stop())}async ensureAudioContext(){if(!this.audioContext&&typeof AudioContext<"u")try{return this.audioContext=new AudioContext,this.audioContext.state==="suspended"&&await this.audioContext.resume(),!0}catch{return!1}if(this.audioContext&&this.audioContext.state==="suspended")try{await this.audioContext.resume()}catch{return!1}return!0}isAudioEnabled(){return this.isEnabled}setOnPlaybackStart(t){this.onPlaybackStart=t}setOnPlaybackEnd(t){this.onPlaybackEnd=t}setOnChunkPlayed(t){this.onChunkPlayed=t}async addChunk(t){if(!this.isEnabled){mt(`[AudioStreamManager] Audio disabled, dropping chunk ${t.chunkIndex}`);return}mt(`[AudioStreamManager] Adding chunk ${t.chunkIndex} to queue`),this.audioQueue.push(t),this.audioQueue.sort((r,n)=>r.chunkIndex-n.chunkIndex),this.isPlaying||this.playNextChunk()}async playNextChunk(){var r,n;if(this.audioQueue.length===0){this.isPlaying=!1,this.onPlaybackEnd&&this.onPlaybackEnd();return}if(!this.isEnabled){this.audioQueue=[],this.isPlaying=!1;return}this.suppressPlaybackErrors=!1,await this.ensureAudioContext(),this.isPlaying=!0;const t=this.audioQueue.shift();try{if(!this.isPlaying)return;if(this.onPlaybackStart&&t.chunkIndex===0&&this.onPlaybackStart(),mt(`[AudioStreamManager] Playing chunk ${t.chunkIndex}`),!t.audio||t.audio.length===0)throw new Error(`Empty audio data for chunk ${t.chunkIndex}`);let a;try{a=atob(t.audio)}catch(d){throw new Error(`Failed to decode base64 audio for chunk ${t.chunkIndex}: ${d instanceof Error?d.message:String(d)}`)}if(a.length===0)throw new Error(`Decoded audio data is empty for chunk ${t.chunkIndex}`);const i=new Uint8Array(a.length);for(let d=0;d<a.length;d++)i[d]=a.charCodeAt(d);const o=t.audioFormat==="mp3"?"audio/mpeg":t.audioFormat==="wav"?"audio/wav":t.audioFormat==="ogg"?"audio/ogg":t.audioFormat==="opus"?"audio/ogg; codecs=opus":t.audioFormat==="webm"?"audio/webm":`audio/${t.audioFormat}`,s=new Blob([i],{type:o}),l=URL.createObjectURL(s);this.blobUrls.push(l);const u=new Audio;u.src=l,this.currentAudio=u;const c=()=>{u.src&&(u.src=""),URL.revokeObjectURL(l),this.blobUrls=this.blobUrls.filter(d=>d!==l)};await new Promise((d,p)=>{let h=!1;const g=()=>{var v;if(h)return;const w=u.error,x=w?{code:w.code,message:w.message||`MediaError code ${w.code}`,MEDIA_ERR_ABORTED:w.code===MediaError.MEDIA_ERR_ABORTED,MEDIA_ERR_NETWORK:w.code===MediaError.MEDIA_ERR_NETWORK,MEDIA_ERR_DECODE:w.code===MediaError.MEDIA_ERR_DECODE,MEDIA_ERR_SRC_NOT_SUPPORTED:w.code===MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED}:"Unknown error";if(this.suppressPlaybackErrors){h=!0,c(),d();return}h=!0,console.error(`[AudioStreamManager] Error playing chunk ${t.chunkIndex}:`,x,{audioFormat:t.audioFormat,chunkIndex:t.chunkIndex,audioLength:t.audio.length,mimeType:o,audioContextState:(v=this.audioContext)==null?void 0:v.state,audioSrc:u.src,audioReadyState:u.readyState}),N0(`[AudioStreamManager] Error playing chunk ${t.chunkIndex}:`,x),c(),p(new Error(`Audio playback error: ${JSON.stringify(x)}`))};u.addEventListener("error",g,{once:!0});const b=async()=>{var w;if(!h)try{u.addEventListener("ended",()=>{h||(h=!0,mt(`[AudioStreamManager] Chunk ${t.chunkIndex} finished`),this.onChunkPlayed&&this.onChunkPlayed(t.chunkIndex),c(),d())},{once:!0});const x=u.play();x&&await x}catch(x){if(h)return;if(this.suppressPlaybackErrors){h=!0,c(),d();return}h=!0,console.error(`[AudioStreamManager] Audio.play() rejected for chunk ${t.chunkIndex}:`,x,{audioFormat:t.audioFormat,chunkIndex:t.chunkIndex,audioContextState:(w=this.audioContext)==null?void 0:w.state,isEnabled:this.isEnabled,audioSrc:u.src,audioReadyState:u.readyState}),c(),p(x)}};u.readyState>=HTMLMediaElement.HAVE_CURRENT_DATA?b():u.addEventListener("canplay",b,{once:!0})}),this.currentAudio=null,this.playNextChunk()}catch(a){if(this.suppressPlaybackErrors)return;const i=a instanceof Error?a.message:String(a);console.error(`[AudioStreamManager] Failed to play chunk ${t.chunkIndex}:`,i,a,{audioFormat:t.audioFormat,chunkIndex:t.chunkIndex,audioLength:(r=t.audio)==null?void 0:r.length,audioContextState:(n=this.audioContext)==null?void 0:n.state,isEnabled:this.isEnabled}),N0(`[AudioStreamManager] Failed to play chunk ${t.chunkIndex}:`,a),this.playNextChunk()}}stop(){this.suppressPlaybackErrors=!0,this.isPlaying=!1,this.audioQueue=[],this.currentAudio&&(this.currentAudio.pause(),this.currentAudio.src="",this.currentAudio=null),this.blobUrls.forEach(t=>URL.revokeObjectURL(t)),this.blobUrls=[]}reset(){this.stop()}getQueueSize(){return this.audioQueue.length}isCurrentlyPlaying(){return this.isPlaying}}const bu=new bVe,Hn=Cu(),Cy=()=>{const e=localStorage.getItem("chatbot-session-id");if(e)return e;const t=`session_${Date.now()}_${Math.random().toString(36).substr(2,9)}`;return localStorage.setItem("chatbot-session-id",t),t},vVe=e=>{localStorage.setItem("chatbot-session-id",e)};let xVe=0;const C7=e=>{const t=Date.now(),r=++xVe,n=Math.random().toString(36).substr(2,9);return`msg_${t}_${r}_${n}_${e}`},xl=()=>{const e=Date.now(),t=Math.random().toString(36).substr(2,9);return`session_${e}_${t}`};let Iy=!1,Oy="";async function il(){if(Iy&&Oy)return!0;try{const e=await Un(),t=localStorage.getItem("chat-api-url");t&&t===Ku&&localStorage.removeItem("chat-api-url");const r=t&&t!==Ku?t:ea(),n=localStorage.getItem("chat-api-key")||Hn,a=Cy();return e.configureApi(r,n,a),Oy=r,Iy=!0,!0}catch(e){return $n("Failed to configure API:",e),!1}}const fr=yVe((e,t)=>({conversations:[],currentConversationId:null,isLoading:!1,error:null,sessionId:Cy(),getSessionId:()=>t().sessionId,configureApiSettings:async(r,n,a)=>{const i=t(),o=i.conversations.find(l=>l.id===i.currentConversationId),s=(o==null?void 0:o.sessionId)||a||Cy();a&&vVe(a),e({sessionId:s});try{const l=await Un();let u;if(n&&n.trim())try{const c=new l.ApiClient({apiUrl:r,apiKey:n,sessionId:null});if(typeof c.validateApiKey=="function"){mt("Validating API key before configuration...");const d=await c.validateApiKey();mt("API key validation successful:",{exists:d.exists,active:d.active,adapter_name:d.adapter_name,client_name:d.client_name})}else Yr("API key validation not available (validateApiKey method not found)");if(typeof c.getAdapterInfo=="function")try{u=await c.getAdapterInfo(),mt("Adapter info loaded:",u)}catch(d){Yr("Failed to load adapter info:",d)}}catch(c){throw c instanceof Error?c:new Error(`API key validation failed: ${(c==null?void 0:c.message)||"Unknown error"}`)}if(l.configureApi(r,n||"",s),Oy=r,Iy=!0,o&&n&&n.trim())e(c=>({conversations:c.conversations.map(d=>d.id===o.id?{...d,apiKey:n,apiUrl:r,adapterInfo:u,updatedAt:new Date}:d)})),setTimeout(()=>{const c=t();localStorage.setItem("chat-state",JSON.stringify({conversations:c.conversations,currentConversationId:c.currentConversationId}))},0);else if(n&&n.trim()){const c=`conv_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,d=xl(),p={id:c,sessionId:d,title:"New Chat",messages:[],createdAt:new Date,updatedAt:new Date,apiKey:n,apiUrl:r,adapterInfo:u};e(h=>{let g=[p,...h.conversations];const b=Er.maxConversations;return b!==null&&g.length>b&&(g=g.slice(0,b)),{conversations:g,currentConversationId:c,sessionId:d}}),setTimeout(()=>{const h=t();localStorage.setItem("chat-state",JSON.stringify({conversations:h.conversations,currentConversationId:h.currentConversationId}))},0)}}catch(l){throw e({isLoading:!1}),l instanceof Error?l:new Error("Failed to configure API settings")}r&&r!==Ku?localStorage.setItem("chat-api-url",r):localStorage.removeItem("chat-api-url"),n&&localStorage.setItem("chat-api-key",n),e({isLoading:!1})},createConversation:()=>{const r=t(),n=Er.maxConversations,a=r.conversations.length,i=r.currentConversationId?r.conversations.find(d=>d.id===r.currentConversationId):null;if(n!==null&&a>=n){const d=`Maximum of ${n} conversations reached. Please delete an existing conversation before starting a new one.`;throw e({error:d}),new Error(d)}if(i&&i.messages.length===0){const d="Finish or delete the current conversation before starting a new one.";throw e({error:d}),new Error(d)}const o=`conv_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,s=xl(),l=ea(),u=Hn,c={id:o,sessionId:s,title:"New Chat",messages:[],createdAt:new Date,updatedAt:new Date,apiKey:u,apiUrl:l};return e(d=>{let p=[c,...d.conversations];const h=Er.maxConversations;return h!==null&&p.length>h&&(p=p.slice(0,h)),{conversations:p,currentConversationId:o,sessionId:s}}),il().then(d=>{d&&Un().then(p=>{p.configureApi(l,u,s);try{const h=new p.ApiClient({apiUrl:l,apiKey:u,sessionId:null});typeof h.getAdapterInfo=="function"&&h.getAdapterInfo().then(g=>{mt("✅ Adapter info loaded for default key in new conversation:",g);const b=fr.getState();fr.setState({conversations:b.conversations.map(w=>w.id===o?{...w,adapterInfo:g,updatedAt:new Date}:w)})}).catch(g=>{Yr("Failed to load adapter info for default key in new conversation:",g)})}catch{}})}),setTimeout(()=>{const d=t();localStorage.setItem("chat-state",JSON.stringify({conversations:d.conversations,currentConversationId:d.currentConversationId}))},0),o},selectConversation:async r=>{const n=t().conversations.find(a=>a.id===r);if(n){const a=n.messages.some(l=>l.role==="assistant"&&l.isStreaming);e({currentConversationId:r,sessionId:n.sessionId,isLoading:a});const i=n.apiUrl||ea(),o=n.apiKey||Hn;if(await il()){const l=await Un();if(l.configureApi(i,o,n.sessionId),!n.adapterInfo)try{const u=new l.ApiClient({apiUrl:i,apiKey:o,sessionId:null});if(typeof u.getAdapterInfo=="function"){const c=await u.getAdapterInfo();mt("Adapter info loaded for conversation:",c),e(d=>({conversations:d.conversations.map(p=>p.id===r?{...p,adapterInfo:c,updatedAt:new Date}:p)})),setTimeout(()=>{const d=t();localStorage.setItem("chat-state",JSON.stringify({conversations:d.conversations,currentConversationId:d.currentConversationId}))},0)}}catch{}}}setTimeout(()=>{const a=t();localStorage.setItem("chat-state",JSON.stringify({conversations:a.conversations,currentConversationId:a.currentConversationId}))},0)},deleteConversation:async r=>{var i,o;const n=t(),a=n.conversations.find(s=>s.id===r);if(mt(`🗑️ Deleting conversation ${r}:`,{conversationId:r,sessionId:a==null?void 0:a.sessionId,title:a==null?void 0:a.title,messageCount:a==null?void 0:a.messages.length,fileCount:((i=a==null?void 0:a.attachedFiles)==null?void 0:i.length)||0}),n.currentConversationId===r&&bu.stop(),a!=null&&a.sessionId)try{if(!await il())$n("Failed to configure API for conversation deletion");else{const l=a.apiUrl||ea(),u=a.apiKey||Hn;mt(`🔑 Using conversation's API key for deletion: ${u.substring(0,8)}... (conversation: ${r})`);const c=await Un(),d=new c.ApiClient({apiUrl:l,apiKey:u,sessionId:a.sessionId}),p=((o=a==null?void 0:a.attachedFiles)==null?void 0:o.map(h=>h.file_id))||[];if(mt(`🔧 Calling deleteConversationWithFiles for session: ${a.sessionId}`),mt(`🔧 File IDs to delete: ${p.join(", ")||"none"}`),d.deleteConversationWithFiles){const h=await d.deleteConversationWithFiles(a.sessionId,p);mt(`✅ Deleted conversation and files for session: ${a.sessionId}`,h),mt(` - Deleted ${h.deleted_messages} messages`),mt(` - Deleted ${h.deleted_files} files`),h.file_deletion_errors&&h.file_deletion_errors.length>0&&Yr(` - Errors deleting files: ${h.file_deletion_errors.join(", ")}`)}else Yr("⚠️ deleteConversationWithFiles method not available on API client")}}catch(s){$n("Failed to clear conversation history from server:",s)}e(s=>{var c;const l=s.conversations.filter(d=>d.id!==r);let u=s.currentConversationId===r?((c=l[0])==null?void 0:c.id)||null:s.currentConversationId;if(l.length===0){const d=`conv_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,p=xl(),h=ea(),g={id:d,sessionId:p,title:"New Chat",messages:[],createdAt:new Date,updatedAt:new Date,apiKey:Hn,apiUrl:h};return il().then(b=>{b&&Un().then(w=>{w.configureApi(h,Hn,p);try{const x=new w.ApiClient({apiUrl:h,apiKey:Hn,sessionId:null});typeof x.validateApiKey=="function"&&x.validateApiKey().then(()=>{mt("✅ Default API key validated after creating new conversation")}).catch(()=>{Yr("Failed to validate default API key")}),typeof x.getAdapterInfo=="function"&&x.getAdapterInfo().then(v=>{mt("✅ Adapter info loaded for default key:",v);const k=fr.getState();fr.setState({conversations:k.conversations.map(T=>T.id===d?{...T,adapterInfo:v,updatedAt:new Date}:T)})}).catch(()=>{Yr("Failed to load adapter info for default key")})}catch{}})}),setTimeout(()=>{localStorage.setItem("chat-state",JSON.stringify({conversations:[g],currentConversationId:d}))},0),{conversations:[g],currentConversationId:d,sessionId:p}}return setTimeout(()=>{localStorage.setItem("chat-state",JSON.stringify({conversations:l,currentConversationId:u}))},0),{conversations:l,currentConversationId:u}})},deleteAllConversations:async()=>{const n=[...t().conversations];bu.stop();const a=n.map(async u=>{var c;if(u!=null&&u.sessionId)try{if(!await il()){$n("Failed to configure API for conversation deletion");return}const p=hs(u.apiUrl),h=u.apiKey||Hn,g=await Un(),b=new g.ApiClient({apiUrl:p,apiKey:h,sessionId:u.sessionId}),w=((c=u==null?void 0:u.attachedFiles)==null?void 0:c.map(x=>x.file_id))||[];b.deleteConversationWithFiles?(await b.deleteConversationWithFiles(u.sessionId,w),mt(`✅ Deleted conversation ${u.id} and files`)):Yr(`deleteConversationWithFiles not available for conversation ${u.id}`)}catch(d){$n(`Failed to delete conversation ${u.id} from server:`,d)}});Promise.allSettled(a).then(u=>{const c=u.filter(d=>d.status==="rejected");c.length>0&&$n(`Some conversations failed to delete from server: ${c.length}`,c)});const i=`conv_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,o=xl(),s=ea(),l={id:i,sessionId:o,title:"New Chat",messages:[],createdAt:new Date,updatedAt:new Date,apiKey:Hn,apiUrl:s};il().then(u=>{u&&Un().then(c=>{c.configureApi(s,Hn,o);try{const d=new c.ApiClient({apiUrl:s,apiKey:Hn,sessionId:null});typeof d.validateApiKey=="function"&&d.validateApiKey().then(()=>{mt("✅ Default API key validated after clearing all conversations")}).catch(()=>{Yr("Failed to validate default API key")}),typeof d.getAdapterInfo=="function"&&d.getAdapterInfo().then(p=>{mt("✅ Adapter info loaded for default key:",p);const h=fr.getState();fr.setState({conversations:h.conversations.map(g=>g.id===i?{...g,adapterInfo:p,updatedAt:new Date}:g)})}).catch(()=>{Yr("Failed to load adapter info for default key")})}catch{}})}),e({conversations:[l],currentConversationId:i,sessionId:o}),setTimeout(()=>{localStorage.setItem("chat-state",JSON.stringify({conversations:[l],currentConversationId:i}))},0)},sendMessage:async(r,n,a)=>{var i,o,s,l,u,c,d,p,h,g,b;try{if(t().isLoading){Yr("Another request is already in progress");return}if(!await il())throw new Error("API not properly configured. Please configure API settings first.");let x=t().currentConversationId;x||(x=t().createConversation());const v=t().conversations.find(ee=>ee.id===x);if(!v)throw new Error("Conversation not found");const k=n?n.map(ee=>{var se;const ie=(se=v==null?void 0:v.attachedFiles)==null?void 0:se.find(ue=>ue.file_id===ee);return ie||{file_id:ee,filename:"",mime_type:"",file_size:0}}).filter(ee=>ee!==void 0):[];k.length>0&&k.forEach(ee=>{t().addFileToConversation(x,ee)});const T=a||null;let I,_=null;if(T){if(I=v.messages.find(ee=>{var ie;return((ie=ee.threadInfo)==null?void 0:ie.thread_id)===T}),!I)throw new Error("Thread metadata not found. Please recreate the thread from this message.");if(_=((i=I.threadInfo)==null?void 0:i.thread_session_id)||null,!_)throw new Error("Thread session is missing. Please recreate the thread from this message.")}const P={id:C7("user"),content:r,role:"user",timestamp:new Date,attachments:k.length>0?k:void 0},z=C7("assistant"),j={id:z,content:"",role:"assistant",timestamp:new Date,isStreaming:!0};T&&I&&(P.isThreadMessage=!0,P.threadId=T,P.parentMessageId=I.id,j.isThreadMessage=!0,j.threadId=T,j.parentMessageId=I.id);let D=!1,B=!1;if(e(ee=>{const ie=ee.conversations.find(te=>te.id===x),se=(ie==null?void 0:ie.messages.filter(te=>te.role==="assistant"&&te.isStreaming))||[];se.length>0&&Yr(`Cleaning up ${se.length} existing streaming messages`);let ue=ee.conversations.map(te=>{if(te.id!==x){const V=Er.maxMessagesPerConversation;if(V!==null){const ge=te.messages.filter(ke=>!(ke.role==="assistant"&&ke.isStreaming));if(ge.length>=V){D=!0;const ke=Math.max(1,V-1),ze=ge.slice(-ke),Ee=te.messages.filter(Ve=>Ve.role==="assistant"&&Ve.isStreaming);return{...te,messages:[...ze,...Ee]}}}return te}const H=te.messages.filter(V=>!(V.role==="assistant"&&V.isStreaming)),le=Er.maxMessagesPerConversation;let ve=H;if(le!==null&&H.length>=le){D=!0;const V=Math.max(1,le-1);ve=H.slice(-V)}return{...te,messages:[...ve,P,j],updatedAt:new Date,title:te.messages.length===0?r.slice(0,50)+(r.length>50?"...":""):te.title}});const Q=Er.maxTotalMessages;if(Q!==null){const te=ue.reduce((H,le)=>H+le.messages.filter(ve=>!(ve.role==="assistant"&&ve.isStreaming)).length,0);if(te>Q){B=!0;let H=te-Q;const le=[...ue].sort((ve,V)=>ve.updatedAt.getTime()-V.updatedAt.getTime());for(const ve of le){if(H<=0)break;const V=ve.messages.filter(ge=>!(ge.role==="assistant"&&ge.isStreaming));if(V.length>0){const ge=Math.min(H,V.length),ke=ve.messages.filter(Ve=>Ve.role==="assistant"&&Ve.isStreaming),ze=[...V.slice(ge),...ke],Ee=ue.findIndex(Ve=>Ve.id===ve.id);Ee!==-1&&(ue[Ee]={...ve,messages:ze}),H-=ge}}}}return{conversations:ue,isLoading:!0,error:null}}),D||B){const ee=[];D&&Er.maxMessagesPerConversation!==null&&ee.push(`Only the most recent ${Er.maxMessagesPerConversation} messages are kept per conversation. Older messages in this chat were removed automatically.`),B&&Er.maxTotalMessages!==null&&ee.push(`There is a workspace limit of ${Er.maxTotalMessages} total messages. Older conversations were trimmed to stay within that limit.`),ee.length>0&&e({error:ee.join(" ")})}const J=x;let ye=!1;bu.reset();try{const ee=t().conversations.find(me=>me.id===J);if(!ee)throw new Error("Conversation not found");if(!ee.apiKey)throw Yr(`[sendMessage] Conversation ${J} has no API key`),new Error("API key not configured for this conversation. Please configure API settings first.");mt(`[sendMessage] Using API key for conversation ${J}: ${ee.apiKey.substring(0,8)}...`);const ie=hs(ee.apiUrl),se=ee.apiKey,ue=a||null,Q=_||ee.sessionId,te=await Un();te.configureApi(ie,se,Q),ue&&Q!==ee.sessionId&&mt(`[chatStore] Thread mode: using thread session ${Q} (original: ${ee.sessionId})`),mt("[chatStore] Starting streamChat with fileIds:",n);const H=t().conversations.find(me=>me.id===J),le=((s=(o=H==null?void 0:H.adapterInfo)==null?void 0:o.adapter_name)==null?void 0:s.includes("voice"))||((u=(l=H==null?void 0:H.adapterInfo)==null?void 0:l.adapter_name)==null?void 0:u.includes("audio"))||((d=(c=H==null?void 0:H.adapterInfo)==null?void 0:c.adapter_name)==null?void 0:d.includes("multilingual")),ve=()=>{try{const me=localStorage.getItem("chat-settings");if(me)return JSON.parse(me).voiceEnabled===!0}catch(me){Yr("Failed to read global voice setting:",me)}return!1},V=H==null?void 0:H.audioSettings,ge=ve(),ke=(V==null?void 0:V.enabled)??ge??le,ze=(V==null?void 0:V.ttsVoice)||"alloy",Ee=(V==null?void 0:V.language)||"en-US",Ve=V==null?void 0:V.audioFormat;mt("[chatStore] Audio settings:",{returnAudio:ke,ttsVoice:ze,language:Ee,audioFormat:Ve,isVoiceAdapter:le,adapterName:(p=H==null?void 0:H.adapterInfo)==null?void 0:p.adapter_name});for await(const me of te.streamChat(r,!0,n,ue||void 0,void 0,void 0,Ee,ke,ze)){if(mt("[chatStore] Received stream chunk:",{text:(h=me.text)==null?void 0:h.substring(0,50),done:me.done,hasAudio:!!me.audio,hasAudioChunk:!!me.audio_chunk,audioFormat:me.audioFormat,audioLength:(g=me.audio)==null?void 0:g.length,chunkIndex:me.chunk_index}),me.audio_chunk){mt("[chatStore] Received audio chunk:",{chunk_index:me.chunk_index,audioFormat:me.audioFormat,audioLength:(b=me.audio_chunk)==null?void 0:b.length});const je=me.chunk_index??0;bu.addChunk({audio:me.audio_chunk,audioFormat:me.audioFormat||"opus",chunkIndex:je})}if(me.text){const je=yp(me.text);je?(t().appendToLastMessage(je,J),ye=!0,await new Promise(qe=>setTimeout(qe,30))):me.text.length>100&&Yr("[chatStore] Filtered out potential base64 audio data from message content")}if(me.audio&&me.done&&e(je=>({conversations:je.conversations.map(qe=>{if(qe.id!==J)return qe;const Le=[...qe.messages],Xe=Le[Le.length-1];return Xe&&Xe.role==="assistant"&&(Le[Le.length-1]={...Xe,audio:me.audio,audioFormat:me.audioFormat||"mp3"}),{...qe,messages:Le,updatedAt:new Date}})})),me.done){mt("[chatStore] Stream completed, receivedAnyText:",ye),mt("[chatStore] Done chunk received:",{hasThreading:!!me.threading,threading:me.threading,assistantMessageId:z});const je=me.threading;je&&je.supports_threading&&(e(qe=>({conversations:qe.conversations.map(Le=>Le.id!==J?Le:{...Le,messages:Le.messages.map(Xe=>Xe.id===z?{...Xe,supportsThreading:!0,databaseMessageId:je.message_id}:Xe),updatedAt:new Date})})),mt(`[chatStore] Message ${z} marked as supporting threading`,{message_id:je.message_id,session_id:je.session_id,databaseMessageId:je.message_id}));break}}ye||(Yr("[chatStore] No text received from stream, showing error message"),t().appendToLastMessage("No response received from the server. Please try again later.",J))}catch(ee){$n("Chat API error:",ee),t().appendToLastMessage("Sorry, there was an error processing your request.",J)}e(ee=>{const ie=ee.conversations.map(Q=>Q.id===J?{...Q,messages:Q.messages.map(te=>te.id===z?{...te,isStreaming:!1}:te),updatedAt:new Date}:Q),se=ie.find(Q=>Q.id===ee.currentConversationId),ue=se?se.messages.some(Q=>Q.role==="assistant"&&Q.isStreaming):!1;return{conversations:ie,isLoading:ue}}),setTimeout(()=>{const ee=t();localStorage.setItem("chat-state",JSON.stringify({conversations:ee.conversations,currentConversationId:ee.currentConversationId}))},0)}catch(w){$n("Chat store error:",w),e(()=>({isLoading:!1,error:`Failed to send message: ${w instanceof Error?w.message:"Unknown error"}`}))}},createThread:async(r,n)=>{try{const a=t().conversations.find(h=>h.sessionId===n);if(!a)throw new Error("Conversation not found for session");const i=a.messages.find(h=>h.id===r);if(!i)throw new Error("Message not found");const o=i.databaseMessageId||r,s=hs(a.apiUrl||ea()),l=a.apiKey||Hn,u=await Un(),c=new u.ApiClient({apiUrl:s,apiKey:l,sessionId:n}),p=await new(await Lr(async()=>{const{ThreadService:h}=await import("./threadService-B9Db3n0J.js");return{ThreadService:h}},[])).ThreadService(c).createThread(o,n);e(h=>({conversations:h.conversations.map(g=>g.sessionId!==n?g:{...g,messages:g.messages.map(b=>b.id===r?{...b,threadInfo:p,supportsThreading:!0}:b),currentThreadId:void 0,currentThreadSessionId:void 0})})),mt(`[chatStore] Created thread ${p.thread_id} for message ${r}`)}catch(a){throw $n("Failed to create thread:",a),a}},appendToLastMessage:(r,n)=>{const a=yp(r);if(!a&&r)return;const i=v8(a);e(o=>{const s=n||o.currentConversationId;return{conversations:o.conversations.map(l=>{if(l.id!==s)return l;const u=[...l.messages],c=u[u.length-1];return c&&c.role==="assistant"&&c.isStreaming&&(u[u.length-1]={...c,content:c.content+i}),{...l,messages:u,updatedAt:new Date}})}})},regenerateResponse:async r=>{var n,a,i,o,s,l;try{if(t().isLoading){Yr("Another request is already in progress");return}if(!await il())throw new Error("API not properly configured");const c=t(),d=c.conversations.find(x=>x.id===c.currentConversationId);if(!d)return;const p=d.messages.findIndex(x=>x.id===r);if(p===-1)return;const h=d.messages[p-1];if(!h||h.role!=="user")return;const g=C7("assistant");e(x=>({conversations:x.conversations.map(v=>v.id===x.currentConversationId?{...v,messages:[...v.messages.slice(0,p),{id:g,content:"",role:"assistant",timestamp:new Date,isStreaming:!0}],updatedAt:new Date}:v),isLoading:!0,error:null}));const b=c.currentConversationId;if(!b)throw new Error("No conversation selected");let w=!1;try{const x=t().conversations.find(B=>B.id===b);if(!x)throw new Error("Conversation not found");if(!x.apiKey)throw new Error("API key not configured for this conversation. Please configure API settings first.");if(x.sessionId){const B=hs(x.apiUrl),J=x.apiKey;(await Un()).configureApi(B,J,x.sessionId)}const v=await Un(),k=t().conversations.find(B=>B.id===b),T=((a=(n=k==null?void 0:k.adapterInfo)==null?void 0:n.adapter_name)==null?void 0:a.includes("voice"))||((o=(i=k==null?void 0:k.adapterInfo)==null?void 0:i.adapter_name)==null?void 0:o.includes("audio"))||((l=(s=k==null?void 0:k.adapterInfo)==null?void 0:s.adapter_name)==null?void 0:l.includes("multilingual")),I=()=>{try{const B=localStorage.getItem("chat-settings");if(B)return JSON.parse(B).voiceEnabled===!0}catch(B){Yr("Failed to read global voice setting:",B)}return!1},_=k==null?void 0:k.audioSettings,P=I(),z=(_==null?void 0:_.enabled)??P??T,j=(_==null?void 0:_.ttsVoice)||"alloy",D=(_==null?void 0:_.language)||"en-US";for await(const B of v.streamChat(h.content,!0,void 0,void 0,void 0,void 0,D,z,j)){if(B.text){const J=yp(B.text);J?(t().appendToLastMessage(J,b),w=!0,await new Promise(ye=>setTimeout(ye,30))):B.text.length>100&&Yr("[chatStore] Filtered out potential base64 audio data from regenerated message content")}if(B.audio&&B.done&&e(J=>({conversations:J.conversations.map(ye=>{if(ye.id!==b)return ye;const ee=[...ye.messages],ie=ee[ee.length-1];return ie&&ie.role==="assistant"&&(ee[ee.length-1]={...ie,audio:B.audio,audioFormat:B.audioFormat||"mp3"}),{...ye,messages:ee,updatedAt:new Date}})})),B.done)break}w||t().appendToLastMessage("No response received from the server. Please try again later.",b)}catch(x){$n("Regenerate API error:",x),t().appendToLastMessage("Sorry, there was an error regenerating the response.",b)}e(x=>{const v=x.conversations.map(I=>I.id===b?{...I,messages:I.messages.map(_=>_.id===g?{..._,isStreaming:!1}:_),updatedAt:new Date}:I),k=v.find(I=>I.id===x.currentConversationId),T=k?k.messages.some(I=>I.role==="assistant"&&I.isStreaming):!1;return{conversations:v,isLoading:T}})}catch(u){$n("Regenerate error:",u),e({isLoading:!1,error:`Failed to regenerate response: ${u instanceof Error?u.message:"Unknown error"}`})}},updateConversationTitle:(r,n)=>{e(a=>({conversations:a.conversations.map(i=>i.id===r?{...i,title:n,updatedAt:new Date}:i)})),setTimeout(()=>{const a=t();localStorage.setItem("chat-state",JSON.stringify({conversations:a.conversations,currentConversationId:a.currentConversationId}))},0)},clearError:()=>{e({error:null})},cleanupStreamingMessages:()=>{e(r=>({conversations:r.conversations.map(n=>(n.id===r.currentConversationId,n)),isLoading:!1}))},canCreateNewConversation:()=>{const r=t(),n=Er.maxConversations;if(!r.currentConversationId)return n===null||r.conversations.length<n;const a=r.conversations.find(i=>i.id===r.currentConversationId);return a&&a.messages.length>0?n===null||r.conversations.length<n:!1},getConversationCount:()=>t().conversations.length,addFileToConversation:(r,n)=>{mt("[chatStore] addFileToConversation called",{conversationId:r,fileId:n.file_id,filename:n.filename}),e(a=>{var s,l;const i={conversations:a.conversations.map(u=>u.id===r?{...u,attachedFiles:[...(u.attachedFiles||[]).filter(c=>c.file_id!==n.file_id),n],updatedAt:new Date}:u)},o=i.conversations.find(u=>u.id===r);return mt(`[chatStore] Updated conversation ${r}`,{hasConversation:!!o,attachedFilesCount:((s=o==null?void 0:o.attachedFiles)==null?void 0:s.length)||0,attachedFiles:(l=o==null?void 0:o.attachedFiles)==null?void 0:l.map(u=>({file_id:u.file_id,filename:u.filename}))}),i}),setTimeout(()=>{const a=t();localStorage.setItem("chat-state",JSON.stringify({conversations:a.conversations,currentConversationId:a.currentConversationId}))},0)},removeFileFromConversation:async(r,n)=>{try{const a=t().conversations.find(s=>s.id===r);if(!a)throw new Error("Conversation not found");if(!a.apiKey)throw new Error("API key not configured for this conversation. Cannot delete file.");const i=a.apiKey,o=hs(a.apiUrl);mt(`[chatStore] Calling FileUploadService.deleteFile for ${n}`),await yu.deleteFile(n,i,o),mt(`[chatStore] Successfully deleted file ${n} from server`)}catch(a){a.message&&(a.message.includes("404")||a.message.includes("File not found"))}e(a=>({conversations:a.conversations.map(i=>i.id===r?{...i,attachedFiles:(i.attachedFiles||[]).filter(o=>o.file_id!==n),updatedAt:new Date}:i)})),setTimeout(()=>{const a=t();localStorage.setItem("chat-state",JSON.stringify({conversations:a.conversations,currentConversationId:a.currentConversationId}))},0)},loadConversationFiles:async r=>{try{const n=t().conversations.find(c=>c.id===r);if(!n)return;if(!n.apiKey){mt(`Skipping file load for conversation ${r}: API key not configured`);return}const a=n.apiKey,i=hs(n.apiUrl);if(new Set((n.attachedFiles||[]).map(c=>c.file_id)).size===0){mt(`No files to sync for conversation ${r}`);return}const l=(await yu.listFiles(a,i)).map(c=>({file_id:c.file_id,filename:c.filename,mime_type:c.mime_type,file_size:c.file_size,upload_timestamp:c.upload_timestamp,processing_status:c.processing_status,chunk_count:c.chunk_count})),u=new Map(l.map(c=>[c.file_id,c]));e(c=>{const d=c.conversations.find(h=>h.id===r);if(!d)return c;const p=(d.attachedFiles||[]).map(h=>u.get(h.file_id)||h).filter(h=>u.has(h.file_id)||!h.processing_status||h.processing_status==="processing");return{conversations:c.conversations.map(h=>h.id===r?{...h,attachedFiles:p,updatedAt:new Date}:h)}}),setTimeout(()=>{const c=t();localStorage.setItem("chat-state",JSON.stringify({conversations:c.conversations,currentConversationId:c.currentConversationId}))},0)}catch(n){$n(`Failed to load files for conversation ${r}:`,n)}},syncConversationFiles:async r=>{await t().loadConversationFiles(r)}})),wVe=async()=>{var s;const e=localStorage.getItem("chat-state");let t=Cy(),r=!1;if(e)try{const l=JSON.parse(e);if(l.conversations=l.conversations.map(c=>({...c,sessionId:c.sessionId||xl(),createdAt:new Date(c.createdAt),updatedAt:new Date(c.updatedAt),attachedFiles:c.attachedFiles||[],apiKey:c.apiKey||Hn,apiUrl:hs(c.apiUrl),adapterInfo:c.adapterInfo||void 0,currentThreadId:void 0,currentThreadSessionId:void 0,messages:c.messages.filter(d=>!(d.role==="assistant"&&d.isStreaming)).map(d=>({...d,timestamp:new Date(d.timestamp),isStreaming:!1}))})),r=l.conversations&&l.conversations.length>0,l.currentConversationId&&l.conversations){const c=l.conversations.find(d=>d.id===l.currentConversationId);c&&c.sessionId&&(t=c.sessionId)}if(!l.conversations||l.conversations.length===0){const c=`conv_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,d=xl(),p={id:c,sessionId:d,title:"New Chat",messages:[],createdAt:new Date,updatedAt:new Date,apiKey:Hn,apiUrl:ea()};fr.setState({conversations:[p],currentConversationId:c,sessionId:d}),t=d}else fr.setState({conversations:l.conversations||[],currentConversationId:l.currentConversationId||((s=l.conversations[0])==null?void 0:s.id)||null,sessionId:t}),!l.currentConversationId&&l.conversations.length>0&&(fr.setState({currentConversationId:l.conversations[0].id,sessionId:l.conversations[0].sessionId||t}),t=l.conversations[0].sessionId||t);const u=fr.getState().conversations;mt("📋 Loaded conversations:",u.map(c=>{var d;return{id:c.id,title:c.title,sessionId:c.sessionId,messageCount:((d=c.messages)==null?void 0:d.length)||0}})),setTimeout(()=>{fr.getState().cleanupStreamingMessages()},100)}catch(l){$n("Failed to load chat state:",l);const u=`conv_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,c=xl(),d=ea(),p={id:u,sessionId:c,title:"New Chat",messages:[],createdAt:new Date,updatedAt:new Date,apiKey:Hn,apiUrl:d};fr.setState({conversations:[p],currentConversationId:u,sessionId:c}),t=c}else{const l=`conv_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,u=xl(),c=ea(),d={id:l,sessionId:u,title:"New Chat",messages:[],createdAt:new Date,updatedAt:new Date,apiKey:Hn,apiUrl:c};fr.setState({conversations:[d],currentConversationId:l,sessionId:u}),t=u}const n=fr.getState(),a=n.currentConversationId?n.conversations.find(l=>l.id===n.currentConversationId):null,i=r&&(a!=null&&a.apiKey)?a.apiKey:Hn,o=r&&(a!=null&&a.apiUrl)?a.apiUrl:ea();try{const l=await Un();if(l.configureApi(o,i,t),Oy=o,Iy=!0,i===Hn)try{const u=new l.ApiClient({apiUrl:o,apiKey:i,sessionId:null});if(typeof u.validateApiKey=="function"&&(await u.validateApiKey(),mt("✅ Default API key validated on startup")),typeof u.getAdapterInfo=="function"){const c=await u.getAdapterInfo();mt("✅ Adapter info loaded for default key:",c);const d=fr.getState();d.currentConversationId&&fr.setState({conversations:d.conversations.map(p=>p.id===d.currentConversationId?{...p,adapterInfo:c,updatedAt:new Date}:p)})}}catch(u){Yr("Failed to validate default API key on startup:",u)}}catch(l){$n("Failed to initialize API:",l)}};typeof window<"u"&&wVe();const SVe=Cu(),kVe=new Map,EVe=new Map,_Ve=new Map;function AVe({conversationId:e,onFilesSelected:t,onUploadError:r,onClose:n,onUploadingChange:a,onUploadSuccess:i,maxFiles:o=Er.maxFilesPerConversation,disabled:s=!1}){const[l,u]=E.useState(!1),[c,d]=E.useState(0),p=E.useRef(null),h=E.useRef(_Ve),g=E.useRef(new Map),b=E.useRef(!0),w=E.useRef(kVe),x=E.useRef(EVe),v=E.useRef(e),k=fr(le=>le.conversations),T=E.useMemo(()=>{if(!e)return new Map;const le=w.current.get(e);return le?new Map(le):new Map},[e,c]),I=E.useMemo(()=>{if(!e)return[];const le=x.current.get(e);return le?[...le]:[]},[e,c]),_=E.useCallback(le=>{if(!le){a==null||a(null,!1),d(ge=>ge+1);return}const ve=w.current.get(le)||new Map,V=k.find(ge=>ge.id===le);if(V&&V.attachedFiles){const ge=V.attachedFiles.filter(Ee=>!Ee.processing_status||Ee.processing_status==="processing"||Ee.processing_status==="uploading"),ke=new Map(ve);let ze=!1;ge.forEach(Ee=>{if(!Array.from(ve.values()).find(me=>me.fileId===Ee.file_id)){const me=`${le}-${Ee.filename}-${Ee.file_id}`;ke.set(me,{filename:Ee.filename,progress:Ee.processing_status==="uploading"?50:90,status:Ee.processing_status||"processing",fileId:Ee.file_id}),ze=!0}}),ze||ke.size>0?(w.current.set(le,ke),a==null||a(le,!0)):(w.current.delete(le),a==null||a(le,!1))}else ve.size>0?w.current.set(le,ve):w.current.delete(le),a==null||a(le,ve.size>0);d(ge=>ge+1)},[k,a]);E.useEffect(()=>{v.current=e,_(e)},[e,_]),E.useEffect(()=>{e&&_(e)},[k,e,_]);const P=E.useCallback((le,ve)=>{if(!le)return;const V=w.current.get(le)||new Map,ge=ve(new Map(V));ge.size>0?w.current.set(le,ge):w.current.delete(le),a==null||a(le,ge.size>0),d(ke=>ke+1)},[a]),z=E.useCallback((le,ve)=>{if(!le)return;const V=x.current.get(le)||[],ge=ve([...V||[]]),ke=new Set(V.map(ze=>ze.file_id));if(x.current.set(le,ge),t(le,ge),i){const ze=ge.filter(Ee=>!ke.has(Ee.file_id));ze.length>0&&i(le,ze)}d(ze=>ze+1)},[t,i]),j=fr(le=>le.removeFileFromConversation),D=fr(le=>le.addFileToConversation);E.useEffect(()=>(b.current=!0,()=>{b.current=!1}),[]),E.useEffect(()=>()=>{b.current=!1,g.current.forEach(le=>le.abort()),setTimeout(()=>{const le=fr.getState(),ve=new Map(le.conversations.map(ge=>[ge.id,ge])),V=[];h.current.forEach((ge,ke)=>{var ze;if(ge){const Ee=ve.get(ge);if(new Set(((ze=Ee==null?void 0:Ee.attachedFiles)==null?void 0:ze.map(me=>me.file_id))||[]).has(ke)){h.current.delete(ke);return}}V.push({fileId:ke,conversationId:ge||null})}),V.length>0&&(n==null||n(),V.forEach(async({fileId:ge,conversationId:ke})=>{var ze,Ee;try{ke?await j(ke,ge):await yu.deleteFile(ge)}catch(Ve){!((ze=Ve.message)!=null&&ze.includes("404"))&&((Ee=Ve.message)!=null&&Ee.includes("File not found"))}}))},300)},[j,n]);const B=E.useCallback(async le=>{if(!le||le.length===0)return;const ve=Array.from(le),V=fr.getState(),ge=e||V.currentConversationId;if(!ge){r==null||r("Please select or create a conversation before uploading files.");return}const ke=V.conversations.find(me=>me.id===ge);if(!ke){r==null||r("Conversation not found. Please try again.");return}if((x.current.get(ge)||[]).length+ve.length>o){const me=`Maximum ${o} files allowed per conversation. Please remove some files first.`;r==null||r(me);return}if(Er.maxTotalFiles!==null&&V.conversations.reduce((qe,Le)=>{var Xe;return qe+(((Xe=Le.attachedFiles)==null?void 0:Xe.length)||0)},0)+ve.length>Er.maxTotalFiles){const qe=`Maximum ${Er.maxTotalFiles} total files allowed across all conversations. Please remove some files from other conversations first.`;r==null||r(qe);return}if(!ke.apiKey||ke.apiKey===SVe){r==null||r("API key not configured for this conversation. Please configure API settings first.");return}const Ee=ke.apiKey,Ve=hs(ke.apiUrl);for(let me=0;me<ve.length;me++){const je=ve[me],qe=new AbortController;g.current.set(je.name,qe);const Le=`${ge}-${je.name}-${Date.now()}-${me}`;let Xe=null;try{const ht=await yu.uploadFile(je,st=>{if(P(ge,dt=>(dt.set(Le,st),dt)),st.fileId&&!Xe){Xe=st.fileId,h.current.set(st.fileId,ge);const dt={file_id:st.fileId,filename:je.name,mime_type:je.type||"application/octet-stream",file_size:je.size,processing_status:st.status==="uploading"?"uploading":st.status==="processing"?"processing":st.status==="completed"?"completed":void 0};mt(`[FileUpload] Adding file ${st.fileId} to conversation ${ge} immediately (status: ${dt.processing_status})`),D(ge,dt)}},Ee,Ve).catch(st=>{if(st.message&&st.message.includes("was deleted")){Xe&&h.current.delete(Xe);const dt=st.message.match(/File\s+([\w-]+)\s+was deleted/);return dt&&dt[1]&&h.current.delete(dt[1]),mt(`File ${je.name} was deleted during upload`),null}throw st});ht?(h.current.set(ht.file_id,ge),mt(`[FileUpload] Updating file ${ht.file_id} in conversation ${ge} with final status`),D(ge,ht),ht.processing_status==="completed"?P(ge,st=>(st.delete(Le),st)):P(ge,st=>{const dt=st.get(Le);return dt&&st.set(Le,{...dt,progress:90,status:"processing",fileId:ht.file_id}),st}),z(ge,st=>{if(new Set(st.map(Pt=>Pt.file_id)).has(ht.file_id))return st;const St=[...st,ht];return mt(`[FileUpload] Updated uploadedFiles for ${ge}: ${St.length} files`,St),St})):(Yr(`Upload completed for ${je.name} but uploadedAttachment is null`),P(ge,st=>(st.delete(Le),st)))}catch(ht){if(ht.name==="AbortError"||qe.signal.aborted){mt(`Upload cancelled for ${je.name}`),Xe&&h.current.delete(Xe);continue}if(ht.message&&ht.message.includes("was deleted")){mt(`File ${je.name} was deleted during upload`),Xe&&h.current.delete(Xe);const st=ht.message.match(/File\s+([\w-]+)\s+was deleted/);st&&st[1]&&h.current.delete(st[1]);continue}b.current?(N0(`Failed to upload file ${je.name}:`,ht),N0(`File type: ${je.type}, File name: ${je.name}`),r==null||r(ht.message||`Failed to upload ${je.name}`)):Yr(`Upload error for ${je.name} (component unmounted):`,ht.message),Xe&&h.current.delete(Xe)}finally{g.current.delete(je.name)}}},[e,o,r,z,P]),J=E.useCallback(le=>{le.preventDefault(),le.stopPropagation(),s||u(!0)},[s]),ye=E.useCallback(le=>{le.preventDefault(),le.stopPropagation(),u(!1)},[]),ee=E.useCallback(le=>{if(le.preventDefault(),le.stopPropagation(),u(!1),s)return;const ve=le.dataTransfer.files;B(ve)},[s,B]),ie=E.useCallback(le=>{const ve=le.target.files;B(ve),p.current&&(p.current.value="")},[B]);E.useCallback(async le=>{const ve=fr.getState(),V=e||ve.currentConversationId;if(!V){h.current.delete(le);try{await yu.deleteFile(le)}catch{}return}z(V,ge=>ge.filter(ke=>ke.file_id!==le)),h.current.delete(le);try{await j(V,le),mt(`[FileUpload] Successfully removed file ${le} from conversation ${V}`)}catch{try{await yu.deleteFile(le)}catch{}}},[e,j,z]);const se=E.useCallback(()=>{!s&&p.current&&p.current.click()},[s]),ue=T.size>0,Q=I.length>0,te=E.useMemo(()=>{const le=new Map;return k.forEach(ve=>{le.set(ve.id,ve.title||"Conversation")}),le},[k]),H=E.useMemo(()=>{const le=[];return w.current.forEach((ve,V)=>{V!==e&&ve.size>0&&le.push({conversationId:V,uploads:Array.from(ve.entries()).map(([ge,ke])=>({key:ge,progress:ke}))})}),le},[e,c]);return G.jsxs("div",{className:"w-full max-w-full overflow-hidden space-y-3",children:[!ue&&!Q&&G.jsxs("div",{onClick:se,onDragOver:J,onDragLeave:ye,onDrop:ee,className:`
1003
+ -d '{"client_name": "chat-app", "adapter_name": "file-document-qa"}'`}else o.includes("API key not configured")&&(o=i.message);throw r&&r({filename:t.name,progress:0,status:"error",error:o}),new Error(o)}}static async uploadFiles(t,r){const n=t.map(async(a,i)=>{try{return await this.uploadFile(a,o=>{r&&r(i,o)})}catch(o){throw $n(`Failed to upload file ${a.name}:`,o),o}});return Promise.all(n)}static async listFiles(t,r){try{const n=await Un(),a=Dd(r),i=t||localStorage.getItem("chat-api-key")||window.CHATBOT_API_KEY||um;if(!i||i==="your-api-key-here"||i==="orbit-123456789")throw new Error("API key not configured");const o=new n.ApiClient({apiUrl:a,apiKey:i,sessionId:null});if(!o.listFiles)throw new Error("File listing is not available. Please use the local API build or update the npm package.");return(await o.listFiles()).map(l=>({file_id:l.file_id,filename:l.filename,mime_type:l.mime_type,file_size:l.file_size,upload_timestamp:l.upload_timestamp,processing_status:l.processing_status,chunk_count:l.chunk_count}))}catch(n){throw $n("Failed to list files:",n),new Error(n.message||"Failed to list files")}}static async getFileInfo(t,r,n){try{const a=await Un(),i=Dd(n),o=r||localStorage.getItem("chat-api-key")||window.CHATBOT_API_KEY||um;if(!o||o==="your-api-key-here"||o==="orbit-123456789")throw new Error("API key not configured");const s=new a.ApiClient({apiUrl:i,apiKey:o,sessionId:null});if(!s.getFileInfo)throw new Error("File info retrieval is not available. Please use the local API build or update the npm package.");const l=await s.getFileInfo(t);return{file_id:l.file_id,filename:l.filename,mime_type:l.mime_type,file_size:l.file_size,upload_timestamp:l.upload_timestamp,processing_status:l.processing_status,chunk_count:l.chunk_count}}catch(a){throw a.message&&(a.message.includes("404")||a.message.includes("File not found"))?new Error(`File ${t} was deleted`):($n(`Failed to get file info for ${t}:`,a),new Error(a.message||`Failed to get file info: ${t}`))}}static async pollFileStatus(t,r=30,n=2e3,a){for(let i=0;i<r;i++)try{if(a&&!a())throw new Error("Polling cancelled - component unmounted");const o=await this.getFileInfo(t);if(o.processing_status==="completed")return o;if(o.processing_status==="error"||o.processing_status==="failed")throw new Error(`File processing failed for ${t}`);i<r-1&&await new Promise(s=>setTimeout(s,n))}catch(o){if(o.message&&(o.message.includes("404")||o.message.includes("File not found")||o.message.includes("was deleted")))throw new Error(`File ${t} was deleted during upload`);if(o.message&&o.message.includes("component unmounted"))throw o;if(i<r-1){await new Promise(s=>setTimeout(s,n));continue}throw o}throw new Error(`File processing timeout: ${t} did not complete within ${r*n/1e3} seconds`)}static async deleteFile(t,r,n){try{const a=await Un(),i=Dd(n),o=r||localStorage.getItem("chat-api-key")||window.CHATBOT_API_KEY||um;if(!o||o==="your-api-key-here"||o==="orbit-123456789")throw new Error("API key not configured");const s=new a.ApiClient({apiUrl:i,apiKey:o,sessionId:null});if(!s.deleteFile)throw new Error("File deletion is not available. Please use the local API build or update the npm package.");return await s.deleteFile(t)}catch(a){if(a.message&&(a.message.includes("404")||a.message.includes("File not found")||a.message.includes("Not Found")))return{message:"File already deleted",file_id:t};throw $n(`Failed to delete file ${t}:`,a),new Error(a.message||`Failed to delete file: ${t}`)}}}const FU=e=>{let t;const r=new Set,n=(u,c)=>{const d=typeof u=="function"?u(t):u;if(!Object.is(d,t)){const p=t;t=c??(typeof d!="object"||d===null)?d:Object.assign({},t,d),r.forEach(h=>h(t,p))}},a=()=>t,s={setState:n,getState:a,getInitialState:()=>l,subscribe:u=>(r.add(u),()=>r.delete(u))},l=t=e(n,a,s);return s},fVe=e=>e?FU(e):FU,mVe=e=>e;function gVe(e,t=mVe){const r=Vn.useSyncExternalStore(e.subscribe,Vn.useCallback(()=>t(e.getState()),[e,t]),Vn.useCallback(()=>t(e.getInitialState()),[e,t]));return Vn.useDebugValue(r),r}const BU=e=>{const t=fVe(e),r=n=>gVe(t,n);return Object.assign(r,t),r},yVe=e=>e?BU(e):BU;class bVe{constructor(){ai(this,"audioQueue",[]);ai(this,"isPlaying",!1);ai(this,"currentAudio",null);ai(this,"audioContext",null);ai(this,"isEnabled",!1);ai(this,"onPlaybackStart",null);ai(this,"onPlaybackEnd",null);ai(this,"onChunkPlayed",null);ai(this,"blobUrls",[]);ai(this,"suppressPlaybackErrors",!1)}async enableAudio(){try{try{const t=new Audio("data:audio/wav;base64,UklGRigAAABXQVZFZm10IBAAAAABAAEARKwAAIhYAQACABAAZGF0YQAAAAA=");t.volume=0,await t.play(),t.pause()}catch{mt("[AudioStreamManager] Silent audio unlock deferred (will work on next interaction)")}return this.isEnabled=!0,mt("[AudioStreamManager] Audio playback enabled"),!0}catch{return!1}}disableAudio(){!this.isEnabled&&!this.isPlaying||(this.isEnabled=!1,this.stop())}async ensureAudioContext(){if(!this.audioContext&&typeof AudioContext<"u")try{return this.audioContext=new AudioContext,this.audioContext.state==="suspended"&&await this.audioContext.resume(),!0}catch{return!1}if(this.audioContext&&this.audioContext.state==="suspended")try{await this.audioContext.resume()}catch{return!1}return!0}isAudioEnabled(){return this.isEnabled}setOnPlaybackStart(t){this.onPlaybackStart=t}setOnPlaybackEnd(t){this.onPlaybackEnd=t}setOnChunkPlayed(t){this.onChunkPlayed=t}async addChunk(t){if(!this.isEnabled){mt(`[AudioStreamManager] Audio disabled, dropping chunk ${t.chunkIndex}`);return}mt(`[AudioStreamManager] Adding chunk ${t.chunkIndex} to queue`),this.audioQueue.push(t),this.audioQueue.sort((r,n)=>r.chunkIndex-n.chunkIndex),this.isPlaying||this.playNextChunk()}async playNextChunk(){var r,n;if(this.audioQueue.length===0){this.isPlaying=!1,this.onPlaybackEnd&&this.onPlaybackEnd();return}if(!this.isEnabled){this.audioQueue=[],this.isPlaying=!1;return}this.suppressPlaybackErrors=!1,await this.ensureAudioContext(),this.isPlaying=!0;const t=this.audioQueue.shift();try{if(!this.isPlaying)return;if(this.onPlaybackStart&&t.chunkIndex===0&&this.onPlaybackStart(),mt(`[AudioStreamManager] Playing chunk ${t.chunkIndex}`),!t.audio||t.audio.length===0)throw new Error(`Empty audio data for chunk ${t.chunkIndex}`);let a;try{a=atob(t.audio)}catch(d){throw new Error(`Failed to decode base64 audio for chunk ${t.chunkIndex}: ${d instanceof Error?d.message:String(d)}`)}if(a.length===0)throw new Error(`Decoded audio data is empty for chunk ${t.chunkIndex}`);const i=new Uint8Array(a.length);for(let d=0;d<a.length;d++)i[d]=a.charCodeAt(d);const o=t.audioFormat==="mp3"?"audio/mpeg":t.audioFormat==="wav"?"audio/wav":t.audioFormat==="ogg"?"audio/ogg":t.audioFormat==="opus"?"audio/ogg; codecs=opus":t.audioFormat==="webm"?"audio/webm":`audio/${t.audioFormat}`,s=new Blob([i],{type:o}),l=URL.createObjectURL(s);this.blobUrls.push(l);const u=new Audio;u.src=l,this.currentAudio=u;const c=()=>{u.src&&(u.src=""),URL.revokeObjectURL(l),this.blobUrls=this.blobUrls.filter(d=>d!==l)};await new Promise((d,p)=>{let h=!1;const g=()=>{var v;if(h)return;const w=u.error,x=w?{code:w.code,message:w.message||`MediaError code ${w.code}`,MEDIA_ERR_ABORTED:w.code===MediaError.MEDIA_ERR_ABORTED,MEDIA_ERR_NETWORK:w.code===MediaError.MEDIA_ERR_NETWORK,MEDIA_ERR_DECODE:w.code===MediaError.MEDIA_ERR_DECODE,MEDIA_ERR_SRC_NOT_SUPPORTED:w.code===MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED}:"Unknown error";if(this.suppressPlaybackErrors){h=!0,c(),d();return}h=!0,console.error(`[AudioStreamManager] Error playing chunk ${t.chunkIndex}:`,x,{audioFormat:t.audioFormat,chunkIndex:t.chunkIndex,audioLength:t.audio.length,mimeType:o,audioContextState:(v=this.audioContext)==null?void 0:v.state,audioSrc:u.src,audioReadyState:u.readyState}),N0(`[AudioStreamManager] Error playing chunk ${t.chunkIndex}:`,x),c(),p(new Error(`Audio playback error: ${JSON.stringify(x)}`))};u.addEventListener("error",g,{once:!0});const b=async()=>{var w;if(!h)try{u.addEventListener("ended",()=>{h||(h=!0,mt(`[AudioStreamManager] Chunk ${t.chunkIndex} finished`),this.onChunkPlayed&&this.onChunkPlayed(t.chunkIndex),c(),d())},{once:!0});const x=u.play();x&&await x}catch(x){if(h)return;if(this.suppressPlaybackErrors){h=!0,c(),d();return}h=!0,console.error(`[AudioStreamManager] Audio.play() rejected for chunk ${t.chunkIndex}:`,x,{audioFormat:t.audioFormat,chunkIndex:t.chunkIndex,audioContextState:(w=this.audioContext)==null?void 0:w.state,isEnabled:this.isEnabled,audioSrc:u.src,audioReadyState:u.readyState}),c(),p(x)}};u.readyState>=HTMLMediaElement.HAVE_CURRENT_DATA?b():u.addEventListener("canplay",b,{once:!0})}),this.currentAudio=null,this.playNextChunk()}catch(a){if(this.suppressPlaybackErrors)return;const i=a instanceof Error?a.message:String(a);console.error(`[AudioStreamManager] Failed to play chunk ${t.chunkIndex}:`,i,a,{audioFormat:t.audioFormat,chunkIndex:t.chunkIndex,audioLength:(r=t.audio)==null?void 0:r.length,audioContextState:(n=this.audioContext)==null?void 0:n.state,isEnabled:this.isEnabled}),N0(`[AudioStreamManager] Failed to play chunk ${t.chunkIndex}:`,a),this.playNextChunk()}}stop(){this.suppressPlaybackErrors=!0,this.isPlaying=!1,this.audioQueue=[],this.currentAudio&&(this.currentAudio.pause(),this.currentAudio.src="",this.currentAudio=null),this.blobUrls.forEach(t=>URL.revokeObjectURL(t)),this.blobUrls=[]}reset(){this.stop()}getQueueSize(){return this.audioQueue.length}isCurrentlyPlaying(){return this.isPlaying}}const bu=new bVe,Hn=Cu(),Cy=()=>{const e=localStorage.getItem("chatbot-session-id");if(e)return e;const t=`session_${Date.now()}_${Math.random().toString(36).substr(2,9)}`;return localStorage.setItem("chatbot-session-id",t),t},vVe=e=>{localStorage.setItem("chatbot-session-id",e)};let xVe=0;const C7=e=>{const t=Date.now(),r=++xVe,n=Math.random().toString(36).substr(2,9);return`msg_${t}_${r}_${n}_${e}`},xl=()=>{const e=Date.now(),t=Math.random().toString(36).substr(2,9);return`session_${e}_${t}`};let Iy=!1,Oy="";async function il(){if(Iy&&Oy)return!0;try{const e=await Un(),t=localStorage.getItem("chat-api-url");t&&t===Ku&&localStorage.removeItem("chat-api-url");const r=t&&t!==Ku?t:ea(),n=localStorage.getItem("chat-api-key")||Hn,a=Cy();return e.configureApi(r,n,a),Oy=r,Iy=!0,!0}catch(e){return $n("Failed to configure API:",e),!1}}const fr=yVe((e,t)=>({conversations:[],currentConversationId:null,isLoading:!1,error:null,sessionId:Cy(),getSessionId:()=>t().sessionId,configureApiSettings:async(r,n,a)=>{const i=t(),o=i.conversations.find(l=>l.id===i.currentConversationId),s=(o==null?void 0:o.sessionId)||a||Cy();a&&vVe(a),e({sessionId:s});try{const l=await Un();let u;if(n&&n.trim())try{const c=new l.ApiClient({apiUrl:r,apiKey:n,sessionId:null});if(typeof c.validateApiKey=="function"){mt("Validating API key before configuration...");const d=await c.validateApiKey();mt("API key validation successful:",{exists:d.exists,active:d.active,adapter_name:d.adapter_name,client_name:d.client_name})}else Yr("API key validation not available (validateApiKey method not found)");if(typeof c.getAdapterInfo=="function")try{u=await c.getAdapterInfo(),mt("Adapter info loaded:",u)}catch(d){Yr("Failed to load adapter info:",d)}}catch(c){throw c instanceof Error?c:new Error(`API key validation failed: ${(c==null?void 0:c.message)||"Unknown error"}`)}if(l.configureApi(r,n||"",s),Oy=r,Iy=!0,o&&n&&n.trim())e(c=>({conversations:c.conversations.map(d=>d.id===o.id?{...d,apiKey:n,apiUrl:r,adapterInfo:u,updatedAt:new Date}:d)})),setTimeout(()=>{const c=t();localStorage.setItem("chat-state",JSON.stringify({conversations:c.conversations,currentConversationId:c.currentConversationId}))},0);else if(n&&n.trim()){const c=`conv_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,d=xl(),p={id:c,sessionId:d,title:"New Chat",messages:[],createdAt:new Date,updatedAt:new Date,apiKey:n,apiUrl:r,adapterInfo:u};e(h=>{let g=[p,...h.conversations];const b=Er.maxConversations;return b!==null&&g.length>b&&(g=g.slice(0,b)),{conversations:g,currentConversationId:c,sessionId:d}}),setTimeout(()=>{const h=t();localStorage.setItem("chat-state",JSON.stringify({conversations:h.conversations,currentConversationId:h.currentConversationId}))},0)}}catch(l){throw e({isLoading:!1}),l instanceof Error?l:new Error("Failed to configure API settings")}r&&r!==Ku?localStorage.setItem("chat-api-url",r):localStorage.removeItem("chat-api-url"),n&&localStorage.setItem("chat-api-key",n),e({isLoading:!1})},createConversation:()=>{const r=t(),n=Er.maxConversations,a=r.conversations.length,i=r.currentConversationId?r.conversations.find(d=>d.id===r.currentConversationId):null;if(n!==null&&a>=n){const d=`Maximum of ${n} conversations reached. Please delete an existing conversation before starting a new one.`;throw e({error:d}),new Error(d)}if(i&&i.messages.length===0){const d="Finish or delete the current conversation before starting a new one.";throw e({error:d}),new Error(d)}const o=`conv_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,s=xl(),l=ea(),u=Hn,c={id:o,sessionId:s,title:"New Chat",messages:[],createdAt:new Date,updatedAt:new Date,apiKey:u,apiUrl:l};return e(d=>{let p=[c,...d.conversations];const h=Er.maxConversations;return h!==null&&p.length>h&&(p=p.slice(0,h)),{conversations:p,currentConversationId:o,sessionId:s}}),il().then(d=>{d&&Un().then(p=>{p.configureApi(l,u,s);try{const h=new p.ApiClient({apiUrl:l,apiKey:u,sessionId:null});typeof h.getAdapterInfo=="function"&&h.getAdapterInfo().then(g=>{mt("✅ Adapter info loaded for default key in new conversation:",g);const b=fr.getState();fr.setState({conversations:b.conversations.map(w=>w.id===o?{...w,adapterInfo:g,updatedAt:new Date}:w)})}).catch(g=>{Yr("Failed to load adapter info for default key in new conversation:",g)})}catch{}})}),setTimeout(()=>{const d=t();localStorage.setItem("chat-state",JSON.stringify({conversations:d.conversations,currentConversationId:d.currentConversationId}))},0),o},selectConversation:async r=>{const n=t().conversations.find(a=>a.id===r);if(n){const a=n.messages.some(l=>l.role==="assistant"&&l.isStreaming);e({currentConversationId:r,sessionId:n.sessionId,isLoading:a});const i=n.apiUrl||ea(),o=n.apiKey||Hn;if(await il()){const l=await Un();if(l.configureApi(i,o,n.sessionId),!n.adapterInfo)try{const u=new l.ApiClient({apiUrl:i,apiKey:o,sessionId:null});if(typeof u.getAdapterInfo=="function"){const c=await u.getAdapterInfo();mt("Adapter info loaded for conversation:",c),e(d=>({conversations:d.conversations.map(p=>p.id===r?{...p,adapterInfo:c,updatedAt:new Date}:p)})),setTimeout(()=>{const d=t();localStorage.setItem("chat-state",JSON.stringify({conversations:d.conversations,currentConversationId:d.currentConversationId}))},0)}}catch{}}}setTimeout(()=>{const a=t();localStorage.setItem("chat-state",JSON.stringify({conversations:a.conversations,currentConversationId:a.currentConversationId}))},0)},deleteConversation:async r=>{var i,o;const n=t(),a=n.conversations.find(s=>s.id===r);if(mt(`🗑️ Deleting conversation ${r}:`,{conversationId:r,sessionId:a==null?void 0:a.sessionId,title:a==null?void 0:a.title,messageCount:a==null?void 0:a.messages.length,fileCount:((i=a==null?void 0:a.attachedFiles)==null?void 0:i.length)||0}),n.currentConversationId===r&&bu.stop(),a!=null&&a.sessionId)try{if(!await il())$n("Failed to configure API for conversation deletion");else{const l=a.apiUrl||ea(),u=a.apiKey||Hn;mt(`🔑 Using conversation's API key for deletion: ${u.substring(0,8)}... (conversation: ${r})`);const c=await Un(),d=new c.ApiClient({apiUrl:l,apiKey:u,sessionId:a.sessionId}),p=((o=a==null?void 0:a.attachedFiles)==null?void 0:o.map(h=>h.file_id))||[];if(mt(`🔧 Calling deleteConversationWithFiles for session: ${a.sessionId}`),mt(`🔧 File IDs to delete: ${p.join(", ")||"none"}`),d.deleteConversationWithFiles){const h=await d.deleteConversationWithFiles(a.sessionId,p);mt(`✅ Deleted conversation and files for session: ${a.sessionId}`,h),mt(` - Deleted ${h.deleted_messages} messages`),mt(` - Deleted ${h.deleted_files} files`),h.file_deletion_errors&&h.file_deletion_errors.length>0&&Yr(` - Errors deleting files: ${h.file_deletion_errors.join(", ")}`)}else Yr("⚠️ deleteConversationWithFiles method not available on API client")}}catch(s){$n("Failed to clear conversation history from server:",s)}e(s=>{var c;const l=s.conversations.filter(d=>d.id!==r);let u=s.currentConversationId===r?((c=l[0])==null?void 0:c.id)||null:s.currentConversationId;if(l.length===0){const d=`conv_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,p=xl(),h=ea(),g={id:d,sessionId:p,title:"New Chat",messages:[],createdAt:new Date,updatedAt:new Date,apiKey:Hn,apiUrl:h};return il().then(b=>{b&&Un().then(w=>{w.configureApi(h,Hn,p);try{const x=new w.ApiClient({apiUrl:h,apiKey:Hn,sessionId:null});typeof x.validateApiKey=="function"&&x.validateApiKey().then(()=>{mt("✅ Default API key validated after creating new conversation")}).catch(()=>{Yr("Failed to validate default API key")}),typeof x.getAdapterInfo=="function"&&x.getAdapterInfo().then(v=>{mt("✅ Adapter info loaded for default key:",v);const k=fr.getState();fr.setState({conversations:k.conversations.map(T=>T.id===d?{...T,adapterInfo:v,updatedAt:new Date}:T)})}).catch(()=>{Yr("Failed to load adapter info for default key")})}catch{}})}),setTimeout(()=>{localStorage.setItem("chat-state",JSON.stringify({conversations:[g],currentConversationId:d}))},0),{conversations:[g],currentConversationId:d,sessionId:p}}return setTimeout(()=>{localStorage.setItem("chat-state",JSON.stringify({conversations:l,currentConversationId:u}))},0),{conversations:l,currentConversationId:u}})},deleteAllConversations:async()=>{const n=[...t().conversations];bu.stop();const a=n.map(async u=>{var c;if(u!=null&&u.sessionId)try{if(!await il()){$n("Failed to configure API for conversation deletion");return}const p=hs(u.apiUrl),h=u.apiKey||Hn,g=await Un(),b=new g.ApiClient({apiUrl:p,apiKey:h,sessionId:u.sessionId}),w=((c=u==null?void 0:u.attachedFiles)==null?void 0:c.map(x=>x.file_id))||[];b.deleteConversationWithFiles?(await b.deleteConversationWithFiles(u.sessionId,w),mt(`✅ Deleted conversation ${u.id} and files`)):Yr(`deleteConversationWithFiles not available for conversation ${u.id}`)}catch(d){$n(`Failed to delete conversation ${u.id} from server:`,d)}});Promise.allSettled(a).then(u=>{const c=u.filter(d=>d.status==="rejected");c.length>0&&$n(`Some conversations failed to delete from server: ${c.length}`,c)});const i=`conv_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,o=xl(),s=ea(),l={id:i,sessionId:o,title:"New Chat",messages:[],createdAt:new Date,updatedAt:new Date,apiKey:Hn,apiUrl:s};il().then(u=>{u&&Un().then(c=>{c.configureApi(s,Hn,o);try{const d=new c.ApiClient({apiUrl:s,apiKey:Hn,sessionId:null});typeof d.validateApiKey=="function"&&d.validateApiKey().then(()=>{mt("✅ Default API key validated after clearing all conversations")}).catch(()=>{Yr("Failed to validate default API key")}),typeof d.getAdapterInfo=="function"&&d.getAdapterInfo().then(p=>{mt("✅ Adapter info loaded for default key:",p);const h=fr.getState();fr.setState({conversations:h.conversations.map(g=>g.id===i?{...g,adapterInfo:p,updatedAt:new Date}:g)})}).catch(()=>{Yr("Failed to load adapter info for default key")})}catch{}})}),e({conversations:[l],currentConversationId:i,sessionId:o}),setTimeout(()=>{localStorage.setItem("chat-state",JSON.stringify({conversations:[l],currentConversationId:i}))},0)},sendMessage:async(r,n,a)=>{var i,o,s,l,u,c,d,p,h,g,b;try{if(t().isLoading){Yr("Another request is already in progress");return}if(!await il())throw new Error("API not properly configured. Please configure API settings first.");let x=t().currentConversationId;x||(x=t().createConversation());const v=t().conversations.find(ee=>ee.id===x);if(!v)throw new Error("Conversation not found");const k=n?n.map(ee=>{var se;const ie=(se=v==null?void 0:v.attachedFiles)==null?void 0:se.find(ue=>ue.file_id===ee);return ie||{file_id:ee,filename:"",mime_type:"",file_size:0}}).filter(ee=>ee!==void 0):[];k.length>0&&k.forEach(ee=>{t().addFileToConversation(x,ee)});const T=a||null;let I,_=null;if(T){if(I=v.messages.find(ee=>{var ie;return((ie=ee.threadInfo)==null?void 0:ie.thread_id)===T}),!I)throw new Error("Thread metadata not found. Please recreate the thread from this message.");if(_=((i=I.threadInfo)==null?void 0:i.thread_session_id)||null,!_)throw new Error("Thread session is missing. Please recreate the thread from this message.")}const P={id:C7("user"),content:r,role:"user",timestamp:new Date,attachments:k.length>0?k:void 0},z=C7("assistant"),j={id:z,content:"",role:"assistant",timestamp:new Date,isStreaming:!0};T&&I&&(P.isThreadMessage=!0,P.threadId=T,P.parentMessageId=I.id,j.isThreadMessage=!0,j.threadId=T,j.parentMessageId=I.id);let D=!1,B=!1;if(e(ee=>{const ie=ee.conversations.find(te=>te.id===x),se=(ie==null?void 0:ie.messages.filter(te=>te.role==="assistant"&&te.isStreaming))||[];se.length>0&&Yr(`Cleaning up ${se.length} existing streaming messages`);let ue=ee.conversations.map(te=>{if(te.id!==x){const V=Er.maxMessagesPerConversation;if(V!==null){const ge=te.messages.filter(ke=>!(ke.role==="assistant"&&ke.isStreaming));if(ge.length>=V){D=!0;const ke=Math.max(1,V-1),ze=ge.slice(-ke),Ee=te.messages.filter(Ve=>Ve.role==="assistant"&&Ve.isStreaming);return{...te,messages:[...ze,...Ee]}}}return te}const H=te.messages.filter(V=>!(V.role==="assistant"&&V.isStreaming)),le=Er.maxMessagesPerConversation;let ve=H;if(le!==null&&H.length>=le){D=!0;const V=Math.max(1,le-1);ve=H.slice(-V)}return{...te,messages:[...ve,P,j],updatedAt:new Date,title:te.messages.length===0?r.slice(0,50)+(r.length>50?"...":""):te.title}});const Q=Er.maxTotalMessages;if(Q!==null){const te=ue.reduce((H,le)=>H+le.messages.filter(ve=>!(ve.role==="assistant"&&ve.isStreaming)).length,0);if(te>Q){B=!0;let H=te-Q;const le=[...ue].sort((ve,V)=>ve.updatedAt.getTime()-V.updatedAt.getTime());for(const ve of le){if(H<=0)break;const V=ve.messages.filter(ge=>!(ge.role==="assistant"&&ge.isStreaming));if(V.length>0){const ge=Math.min(H,V.length),ke=ve.messages.filter(Ve=>Ve.role==="assistant"&&Ve.isStreaming),ze=[...V.slice(ge),...ke],Ee=ue.findIndex(Ve=>Ve.id===ve.id);Ee!==-1&&(ue[Ee]={...ve,messages:ze}),H-=ge}}}}return{conversations:ue,isLoading:!0,error:null}}),D||B){const ee=[];D&&Er.maxMessagesPerConversation!==null&&ee.push(`Only the most recent ${Er.maxMessagesPerConversation} messages are kept per conversation. Older messages in this chat were removed automatically.`),B&&Er.maxTotalMessages!==null&&ee.push(`There is a workspace limit of ${Er.maxTotalMessages} total messages. Older conversations were trimmed to stay within that limit.`),ee.length>0&&e({error:ee.join(" ")})}const J=x;let ye=!1;bu.reset();try{const ee=t().conversations.find(me=>me.id===J);if(!ee)throw new Error("Conversation not found");if(!ee.apiKey)throw Yr(`[sendMessage] Conversation ${J} has no API key`),new Error("API key not configured for this conversation. Please configure API settings first.");mt(`[sendMessage] Using API key for conversation ${J}: ${ee.apiKey.substring(0,8)}...`);const ie=hs(ee.apiUrl),se=ee.apiKey,ue=a||null,Q=_||ee.sessionId,te=await Un();te.configureApi(ie,se,Q),ue&&Q!==ee.sessionId&&mt(`[chatStore] Thread mode: using thread session ${Q} (original: ${ee.sessionId})`),mt("[chatStore] Starting streamChat with fileIds:",n);const H=t().conversations.find(me=>me.id===J),le=((s=(o=H==null?void 0:H.adapterInfo)==null?void 0:o.adapter_name)==null?void 0:s.includes("voice"))||((u=(l=H==null?void 0:H.adapterInfo)==null?void 0:l.adapter_name)==null?void 0:u.includes("audio"))||((d=(c=H==null?void 0:H.adapterInfo)==null?void 0:c.adapter_name)==null?void 0:d.includes("multilingual")),ve=()=>{try{const me=localStorage.getItem("chat-settings");if(me)return JSON.parse(me).voiceEnabled===!0}catch(me){Yr("Failed to read global voice setting:",me)}return!1},V=H==null?void 0:H.audioSettings,ge=ve(),ke=(V==null?void 0:V.enabled)??ge??le,ze=(V==null?void 0:V.ttsVoice)||void 0,Ee=(V==null?void 0:V.language)||"en-US",Ve=V==null?void 0:V.audioFormat;mt("[chatStore] Audio settings:",{returnAudio:ke,ttsVoice:ze,language:Ee,audioFormat:Ve,isVoiceAdapter:le,adapterName:(p=H==null?void 0:H.adapterInfo)==null?void 0:p.adapter_name});for await(const me of te.streamChat(r,!0,n,ue||void 0,void 0,void 0,Ee,ke,ze)){if(mt("[chatStore] Received stream chunk:",{text:(h=me.text)==null?void 0:h.substring(0,50),done:me.done,hasAudio:!!me.audio,hasAudioChunk:!!me.audio_chunk,audioFormat:me.audioFormat,audioLength:(g=me.audio)==null?void 0:g.length,chunkIndex:me.chunk_index}),me.audio_chunk){mt("[chatStore] Received audio chunk:",{chunk_index:me.chunk_index,audioFormat:me.audioFormat,audioLength:(b=me.audio_chunk)==null?void 0:b.length});const je=me.chunk_index??0;bu.addChunk({audio:me.audio_chunk,audioFormat:me.audioFormat||"opus",chunkIndex:je})}if(me.text){const je=yp(me.text);je?(t().appendToLastMessage(je,J),ye=!0,await new Promise(qe=>setTimeout(qe,30))):me.text.length>100&&Yr("[chatStore] Filtered out potential base64 audio data from message content")}if(me.audio&&me.done&&e(je=>({conversations:je.conversations.map(qe=>{if(qe.id!==J)return qe;const Le=[...qe.messages],Xe=Le[Le.length-1];return Xe&&Xe.role==="assistant"&&(Le[Le.length-1]={...Xe,audio:me.audio,audioFormat:me.audioFormat||"mp3"}),{...qe,messages:Le,updatedAt:new Date}})})),me.done){mt("[chatStore] Stream completed, receivedAnyText:",ye),mt("[chatStore] Done chunk received:",{hasThreading:!!me.threading,threading:me.threading,assistantMessageId:z});const je=me.threading;je&&je.supports_threading&&(e(qe=>({conversations:qe.conversations.map(Le=>Le.id!==J?Le:{...Le,messages:Le.messages.map(Xe=>Xe.id===z?{...Xe,supportsThreading:!0,databaseMessageId:je.message_id}:Xe),updatedAt:new Date})})),mt(`[chatStore] Message ${z} marked as supporting threading`,{message_id:je.message_id,session_id:je.session_id,databaseMessageId:je.message_id}));break}}ye||(Yr("[chatStore] No text received from stream, showing error message"),t().appendToLastMessage("No response received from the server. Please try again later.",J))}catch(ee){$n("Chat API error:",ee),t().appendToLastMessage("Sorry, there was an error processing your request.",J)}e(ee=>{const ie=ee.conversations.map(Q=>Q.id===J?{...Q,messages:Q.messages.map(te=>te.id===z?{...te,isStreaming:!1}:te),updatedAt:new Date}:Q),se=ie.find(Q=>Q.id===ee.currentConversationId),ue=se?se.messages.some(Q=>Q.role==="assistant"&&Q.isStreaming):!1;return{conversations:ie,isLoading:ue}}),setTimeout(()=>{const ee=t();localStorage.setItem("chat-state",JSON.stringify({conversations:ee.conversations,currentConversationId:ee.currentConversationId}))},0)}catch(w){$n("Chat store error:",w),e(()=>({isLoading:!1,error:`Failed to send message: ${w instanceof Error?w.message:"Unknown error"}`}))}},createThread:async(r,n)=>{try{const a=t().conversations.find(h=>h.sessionId===n);if(!a)throw new Error("Conversation not found for session");const i=a.messages.find(h=>h.id===r);if(!i)throw new Error("Message not found");const o=i.databaseMessageId||r,s=hs(a.apiUrl||ea()),l=a.apiKey||Hn,u=await Un(),c=new u.ApiClient({apiUrl:s,apiKey:l,sessionId:n}),p=await new(await Lr(async()=>{const{ThreadService:h}=await import("./threadService-B9Db3n0J.js");return{ThreadService:h}},[])).ThreadService(c).createThread(o,n);e(h=>({conversations:h.conversations.map(g=>g.sessionId!==n?g:{...g,messages:g.messages.map(b=>b.id===r?{...b,threadInfo:p,supportsThreading:!0}:b),currentThreadId:void 0,currentThreadSessionId:void 0})})),mt(`[chatStore] Created thread ${p.thread_id} for message ${r}`)}catch(a){throw $n("Failed to create thread:",a),a}},appendToLastMessage:(r,n)=>{const a=yp(r);if(!a&&r)return;const i=v8(a);e(o=>{const s=n||o.currentConversationId;return{conversations:o.conversations.map(l=>{if(l.id!==s)return l;const u=[...l.messages],c=u[u.length-1];return c&&c.role==="assistant"&&c.isStreaming&&(u[u.length-1]={...c,content:c.content+i}),{...l,messages:u,updatedAt:new Date}})}})},regenerateResponse:async r=>{var n,a,i,o,s,l;try{if(t().isLoading){Yr("Another request is already in progress");return}if(!await il())throw new Error("API not properly configured");const c=t(),d=c.conversations.find(x=>x.id===c.currentConversationId);if(!d)return;const p=d.messages.findIndex(x=>x.id===r);if(p===-1)return;const h=d.messages[p-1];if(!h||h.role!=="user")return;const g=C7("assistant");e(x=>({conversations:x.conversations.map(v=>v.id===x.currentConversationId?{...v,messages:[...v.messages.slice(0,p),{id:g,content:"",role:"assistant",timestamp:new Date,isStreaming:!0}],updatedAt:new Date}:v),isLoading:!0,error:null}));const b=c.currentConversationId;if(!b)throw new Error("No conversation selected");let w=!1;try{const x=t().conversations.find(B=>B.id===b);if(!x)throw new Error("Conversation not found");if(!x.apiKey)throw new Error("API key not configured for this conversation. Please configure API settings first.");if(x.sessionId){const B=hs(x.apiUrl),J=x.apiKey;(await Un()).configureApi(B,J,x.sessionId)}const v=await Un(),k=t().conversations.find(B=>B.id===b),T=((a=(n=k==null?void 0:k.adapterInfo)==null?void 0:n.adapter_name)==null?void 0:a.includes("voice"))||((o=(i=k==null?void 0:k.adapterInfo)==null?void 0:i.adapter_name)==null?void 0:o.includes("audio"))||((l=(s=k==null?void 0:k.adapterInfo)==null?void 0:s.adapter_name)==null?void 0:l.includes("multilingual")),I=()=>{try{const B=localStorage.getItem("chat-settings");if(B)return JSON.parse(B).voiceEnabled===!0}catch(B){Yr("Failed to read global voice setting:",B)}return!1},_=k==null?void 0:k.audioSettings,P=I(),z=(_==null?void 0:_.enabled)??P??T,j=(_==null?void 0:_.ttsVoice)||void 0,D=(_==null?void 0:_.language)||"en-US";for await(const B of v.streamChat(h.content,!0,void 0,void 0,void 0,void 0,D,z,j)){if(B.text){const J=yp(B.text);J?(t().appendToLastMessage(J,b),w=!0,await new Promise(ye=>setTimeout(ye,30))):B.text.length>100&&Yr("[chatStore] Filtered out potential base64 audio data from regenerated message content")}if(B.audio&&B.done&&e(J=>({conversations:J.conversations.map(ye=>{if(ye.id!==b)return ye;const ee=[...ye.messages],ie=ee[ee.length-1];return ie&&ie.role==="assistant"&&(ee[ee.length-1]={...ie,audio:B.audio,audioFormat:B.audioFormat||"mp3"}),{...ye,messages:ee,updatedAt:new Date}})})),B.done)break}w||t().appendToLastMessage("No response received from the server. Please try again later.",b)}catch(x){$n("Regenerate API error:",x),t().appendToLastMessage("Sorry, there was an error regenerating the response.",b)}e(x=>{const v=x.conversations.map(I=>I.id===b?{...I,messages:I.messages.map(_=>_.id===g?{..._,isStreaming:!1}:_),updatedAt:new Date}:I),k=v.find(I=>I.id===x.currentConversationId),T=k?k.messages.some(I=>I.role==="assistant"&&I.isStreaming):!1;return{conversations:v,isLoading:T}})}catch(u){$n("Regenerate error:",u),e({isLoading:!1,error:`Failed to regenerate response: ${u instanceof Error?u.message:"Unknown error"}`})}},updateConversationTitle:(r,n)=>{e(a=>({conversations:a.conversations.map(i=>i.id===r?{...i,title:n,updatedAt:new Date}:i)})),setTimeout(()=>{const a=t();localStorage.setItem("chat-state",JSON.stringify({conversations:a.conversations,currentConversationId:a.currentConversationId}))},0)},clearError:()=>{e({error:null})},cleanupStreamingMessages:()=>{e(r=>({conversations:r.conversations.map(n=>(n.id===r.currentConversationId,n)),isLoading:!1}))},canCreateNewConversation:()=>{const r=t(),n=Er.maxConversations;if(!r.currentConversationId)return n===null||r.conversations.length<n;const a=r.conversations.find(i=>i.id===r.currentConversationId);return a&&a.messages.length>0?n===null||r.conversations.length<n:!1},getConversationCount:()=>t().conversations.length,addFileToConversation:(r,n)=>{mt("[chatStore] addFileToConversation called",{conversationId:r,fileId:n.file_id,filename:n.filename}),e(a=>{var s,l;const i={conversations:a.conversations.map(u=>u.id===r?{...u,attachedFiles:[...(u.attachedFiles||[]).filter(c=>c.file_id!==n.file_id),n],updatedAt:new Date}:u)},o=i.conversations.find(u=>u.id===r);return mt(`[chatStore] Updated conversation ${r}`,{hasConversation:!!o,attachedFilesCount:((s=o==null?void 0:o.attachedFiles)==null?void 0:s.length)||0,attachedFiles:(l=o==null?void 0:o.attachedFiles)==null?void 0:l.map(u=>({file_id:u.file_id,filename:u.filename}))}),i}),setTimeout(()=>{const a=t();localStorage.setItem("chat-state",JSON.stringify({conversations:a.conversations,currentConversationId:a.currentConversationId}))},0)},removeFileFromConversation:async(r,n)=>{try{const a=t().conversations.find(s=>s.id===r);if(!a)throw new Error("Conversation not found");if(!a.apiKey)throw new Error("API key not configured for this conversation. Cannot delete file.");const i=a.apiKey,o=hs(a.apiUrl);mt(`[chatStore] Calling FileUploadService.deleteFile for ${n}`),await yu.deleteFile(n,i,o),mt(`[chatStore] Successfully deleted file ${n} from server`)}catch(a){a.message&&(a.message.includes("404")||a.message.includes("File not found"))}e(a=>({conversations:a.conversations.map(i=>i.id===r?{...i,attachedFiles:(i.attachedFiles||[]).filter(o=>o.file_id!==n),updatedAt:new Date}:i)})),setTimeout(()=>{const a=t();localStorage.setItem("chat-state",JSON.stringify({conversations:a.conversations,currentConversationId:a.currentConversationId}))},0)},loadConversationFiles:async r=>{try{const n=t().conversations.find(c=>c.id===r);if(!n)return;if(!n.apiKey){mt(`Skipping file load for conversation ${r}: API key not configured`);return}const a=n.apiKey,i=hs(n.apiUrl);if(new Set((n.attachedFiles||[]).map(c=>c.file_id)).size===0){mt(`No files to sync for conversation ${r}`);return}const l=(await yu.listFiles(a,i)).map(c=>({file_id:c.file_id,filename:c.filename,mime_type:c.mime_type,file_size:c.file_size,upload_timestamp:c.upload_timestamp,processing_status:c.processing_status,chunk_count:c.chunk_count})),u=new Map(l.map(c=>[c.file_id,c]));e(c=>{const d=c.conversations.find(h=>h.id===r);if(!d)return c;const p=(d.attachedFiles||[]).map(h=>u.get(h.file_id)||h).filter(h=>u.has(h.file_id)||!h.processing_status||h.processing_status==="processing");return{conversations:c.conversations.map(h=>h.id===r?{...h,attachedFiles:p,updatedAt:new Date}:h)}}),setTimeout(()=>{const c=t();localStorage.setItem("chat-state",JSON.stringify({conversations:c.conversations,currentConversationId:c.currentConversationId}))},0)}catch(n){$n(`Failed to load files for conversation ${r}:`,n)}},syncConversationFiles:async r=>{await t().loadConversationFiles(r)}})),wVe=async()=>{var s;const e=localStorage.getItem("chat-state");let t=Cy(),r=!1;if(e)try{const l=JSON.parse(e);if(l.conversations=l.conversations.map(c=>({...c,sessionId:c.sessionId||xl(),createdAt:new Date(c.createdAt),updatedAt:new Date(c.updatedAt),attachedFiles:c.attachedFiles||[],apiKey:c.apiKey||Hn,apiUrl:hs(c.apiUrl),adapterInfo:c.adapterInfo||void 0,currentThreadId:void 0,currentThreadSessionId:void 0,messages:c.messages.filter(d=>!(d.role==="assistant"&&d.isStreaming)).map(d=>({...d,timestamp:new Date(d.timestamp),isStreaming:!1}))})),r=l.conversations&&l.conversations.length>0,l.currentConversationId&&l.conversations){const c=l.conversations.find(d=>d.id===l.currentConversationId);c&&c.sessionId&&(t=c.sessionId)}if(!l.conversations||l.conversations.length===0){const c=`conv_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,d=xl(),p={id:c,sessionId:d,title:"New Chat",messages:[],createdAt:new Date,updatedAt:new Date,apiKey:Hn,apiUrl:ea()};fr.setState({conversations:[p],currentConversationId:c,sessionId:d}),t=d}else fr.setState({conversations:l.conversations||[],currentConversationId:l.currentConversationId||((s=l.conversations[0])==null?void 0:s.id)||null,sessionId:t}),!l.currentConversationId&&l.conversations.length>0&&(fr.setState({currentConversationId:l.conversations[0].id,sessionId:l.conversations[0].sessionId||t}),t=l.conversations[0].sessionId||t);const u=fr.getState().conversations;mt("📋 Loaded conversations:",u.map(c=>{var d;return{id:c.id,title:c.title,sessionId:c.sessionId,messageCount:((d=c.messages)==null?void 0:d.length)||0}})),setTimeout(()=>{fr.getState().cleanupStreamingMessages()},100)}catch(l){$n("Failed to load chat state:",l);const u=`conv_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,c=xl(),d=ea(),p={id:u,sessionId:c,title:"New Chat",messages:[],createdAt:new Date,updatedAt:new Date,apiKey:Hn,apiUrl:d};fr.setState({conversations:[p],currentConversationId:u,sessionId:c}),t=c}else{const l=`conv_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,u=xl(),c=ea(),d={id:l,sessionId:u,title:"New Chat",messages:[],createdAt:new Date,updatedAt:new Date,apiKey:Hn,apiUrl:c};fr.setState({conversations:[d],currentConversationId:l,sessionId:u}),t=u}const n=fr.getState(),a=n.currentConversationId?n.conversations.find(l=>l.id===n.currentConversationId):null,i=r&&(a!=null&&a.apiKey)?a.apiKey:Hn,o=r&&(a!=null&&a.apiUrl)?a.apiUrl:ea();try{const l=await Un();if(l.configureApi(o,i,t),Oy=o,Iy=!0,i===Hn)try{const u=new l.ApiClient({apiUrl:o,apiKey:i,sessionId:null});if(typeof u.validateApiKey=="function"&&(await u.validateApiKey(),mt("✅ Default API key validated on startup")),typeof u.getAdapterInfo=="function"){const c=await u.getAdapterInfo();mt("✅ Adapter info loaded for default key:",c);const d=fr.getState();d.currentConversationId&&fr.setState({conversations:d.conversations.map(p=>p.id===d.currentConversationId?{...p,adapterInfo:c,updatedAt:new Date}:p)})}}catch(u){Yr("Failed to validate default API key on startup:",u)}}catch(l){$n("Failed to initialize API:",l)}};typeof window<"u"&&wVe();const SVe=Cu(),kVe=new Map,EVe=new Map,_Ve=new Map;function AVe({conversationId:e,onFilesSelected:t,onUploadError:r,onClose:n,onUploadingChange:a,onUploadSuccess:i,maxFiles:o=Er.maxFilesPerConversation,disabled:s=!1}){const[l,u]=E.useState(!1),[c,d]=E.useState(0),p=E.useRef(null),h=E.useRef(_Ve),g=E.useRef(new Map),b=E.useRef(!0),w=E.useRef(kVe),x=E.useRef(EVe),v=E.useRef(e),k=fr(le=>le.conversations),T=E.useMemo(()=>{if(!e)return new Map;const le=w.current.get(e);return le?new Map(le):new Map},[e,c]),I=E.useMemo(()=>{if(!e)return[];const le=x.current.get(e);return le?[...le]:[]},[e,c]),_=E.useCallback(le=>{if(!le){a==null||a(null,!1),d(ge=>ge+1);return}const ve=w.current.get(le)||new Map,V=k.find(ge=>ge.id===le);if(V&&V.attachedFiles){const ge=V.attachedFiles.filter(Ee=>!Ee.processing_status||Ee.processing_status==="processing"||Ee.processing_status==="uploading"),ke=new Map(ve);let ze=!1;ge.forEach(Ee=>{if(!Array.from(ve.values()).find(me=>me.fileId===Ee.file_id)){const me=`${le}-${Ee.filename}-${Ee.file_id}`;ke.set(me,{filename:Ee.filename,progress:Ee.processing_status==="uploading"?50:90,status:Ee.processing_status||"processing",fileId:Ee.file_id}),ze=!0}}),ze||ke.size>0?(w.current.set(le,ke),a==null||a(le,!0)):(w.current.delete(le),a==null||a(le,!1))}else ve.size>0?w.current.set(le,ve):w.current.delete(le),a==null||a(le,ve.size>0);d(ge=>ge+1)},[k,a]);E.useEffect(()=>{v.current=e,_(e)},[e,_]),E.useEffect(()=>{e&&_(e)},[k,e,_]);const P=E.useCallback((le,ve)=>{if(!le)return;const V=w.current.get(le)||new Map,ge=ve(new Map(V));ge.size>0?w.current.set(le,ge):w.current.delete(le),a==null||a(le,ge.size>0),d(ke=>ke+1)},[a]),z=E.useCallback((le,ve)=>{if(!le)return;const V=x.current.get(le)||[],ge=ve([...V||[]]),ke=new Set(V.map(ze=>ze.file_id));if(x.current.set(le,ge),t(le,ge),i){const ze=ge.filter(Ee=>!ke.has(Ee.file_id));ze.length>0&&i(le,ze)}d(ze=>ze+1)},[t,i]),j=fr(le=>le.removeFileFromConversation),D=fr(le=>le.addFileToConversation);E.useEffect(()=>(b.current=!0,()=>{b.current=!1}),[]),E.useEffect(()=>()=>{b.current=!1,g.current.forEach(le=>le.abort()),setTimeout(()=>{const le=fr.getState(),ve=new Map(le.conversations.map(ge=>[ge.id,ge])),V=[];h.current.forEach((ge,ke)=>{var ze;if(ge){const Ee=ve.get(ge);if(new Set(((ze=Ee==null?void 0:Ee.attachedFiles)==null?void 0:ze.map(me=>me.file_id))||[]).has(ke)){h.current.delete(ke);return}}V.push({fileId:ke,conversationId:ge||null})}),V.length>0&&(n==null||n(),V.forEach(async({fileId:ge,conversationId:ke})=>{var ze,Ee;try{ke?await j(ke,ge):await yu.deleteFile(ge)}catch(Ve){!((ze=Ve.message)!=null&&ze.includes("404"))&&((Ee=Ve.message)!=null&&Ee.includes("File not found"))}}))},300)},[j,n]);const B=E.useCallback(async le=>{if(!le||le.length===0)return;const ve=Array.from(le),V=fr.getState(),ge=e||V.currentConversationId;if(!ge){r==null||r("Please select or create a conversation before uploading files.");return}const ke=V.conversations.find(me=>me.id===ge);if(!ke){r==null||r("Conversation not found. Please try again.");return}if((x.current.get(ge)||[]).length+ve.length>o){const me=`Maximum ${o} files allowed per conversation. Please remove some files first.`;r==null||r(me);return}if(Er.maxTotalFiles!==null&&V.conversations.reduce((qe,Le)=>{var Xe;return qe+(((Xe=Le.attachedFiles)==null?void 0:Xe.length)||0)},0)+ve.length>Er.maxTotalFiles){const qe=`Maximum ${Er.maxTotalFiles} total files allowed across all conversations. Please remove some files from other conversations first.`;r==null||r(qe);return}if(!ke.apiKey||ke.apiKey===SVe){r==null||r("API key not configured for this conversation. Please configure API settings first.");return}const Ee=ke.apiKey,Ve=hs(ke.apiUrl);for(let me=0;me<ve.length;me++){const je=ve[me],qe=new AbortController;g.current.set(je.name,qe);const Le=`${ge}-${je.name}-${Date.now()}-${me}`;let Xe=null;try{const ht=await yu.uploadFile(je,st=>{if(P(ge,dt=>(dt.set(Le,st),dt)),st.fileId&&!Xe){Xe=st.fileId,h.current.set(st.fileId,ge);const dt={file_id:st.fileId,filename:je.name,mime_type:je.type||"application/octet-stream",file_size:je.size,processing_status:st.status==="uploading"?"uploading":st.status==="processing"?"processing":st.status==="completed"?"completed":void 0};mt(`[FileUpload] Adding file ${st.fileId} to conversation ${ge} immediately (status: ${dt.processing_status})`),D(ge,dt)}},Ee,Ve).catch(st=>{if(st.message&&st.message.includes("was deleted")){Xe&&h.current.delete(Xe);const dt=st.message.match(/File\s+([\w-]+)\s+was deleted/);return dt&&dt[1]&&h.current.delete(dt[1]),mt(`File ${je.name} was deleted during upload`),null}throw st});ht?(h.current.set(ht.file_id,ge),mt(`[FileUpload] Updating file ${ht.file_id} in conversation ${ge} with final status`),D(ge,ht),ht.processing_status==="completed"?P(ge,st=>(st.delete(Le),st)):P(ge,st=>{const dt=st.get(Le);return dt&&st.set(Le,{...dt,progress:90,status:"processing",fileId:ht.file_id}),st}),z(ge,st=>{if(new Set(st.map(Pt=>Pt.file_id)).has(ht.file_id))return st;const St=[...st,ht];return mt(`[FileUpload] Updated uploadedFiles for ${ge}: ${St.length} files`,St),St})):(Yr(`Upload completed for ${je.name} but uploadedAttachment is null`),P(ge,st=>(st.delete(Le),st)))}catch(ht){if(ht.name==="AbortError"||qe.signal.aborted){mt(`Upload cancelled for ${je.name}`),Xe&&h.current.delete(Xe);continue}if(ht.message&&ht.message.includes("was deleted")){mt(`File ${je.name} was deleted during upload`),Xe&&h.current.delete(Xe);const st=ht.message.match(/File\s+([\w-]+)\s+was deleted/);st&&st[1]&&h.current.delete(st[1]);continue}b.current?(N0(`Failed to upload file ${je.name}:`,ht),N0(`File type: ${je.type}, File name: ${je.name}`),r==null||r(ht.message||`Failed to upload ${je.name}`)):Yr(`Upload error for ${je.name} (component unmounted):`,ht.message),Xe&&h.current.delete(Xe)}finally{g.current.delete(je.name)}}},[e,o,r,z,P]),J=E.useCallback(le=>{le.preventDefault(),le.stopPropagation(),s||u(!0)},[s]),ye=E.useCallback(le=>{le.preventDefault(),le.stopPropagation(),u(!1)},[]),ee=E.useCallback(le=>{if(le.preventDefault(),le.stopPropagation(),u(!1),s)return;const ve=le.dataTransfer.files;B(ve)},[s,B]),ie=E.useCallback(le=>{const ve=le.target.files;B(ve),p.current&&(p.current.value="")},[B]);E.useCallback(async le=>{const ve=fr.getState(),V=e||ve.currentConversationId;if(!V){h.current.delete(le);try{await yu.deleteFile(le)}catch{}return}z(V,ge=>ge.filter(ke=>ke.file_id!==le)),h.current.delete(le);try{await j(V,le),mt(`[FileUpload] Successfully removed file ${le} from conversation ${V}`)}catch{try{await yu.deleteFile(le)}catch{}}},[e,j,z]);const se=E.useCallback(()=>{!s&&p.current&&p.current.click()},[s]),ue=T.size>0,Q=I.length>0,te=E.useMemo(()=>{const le=new Map;return k.forEach(ve=>{le.set(ve.id,ve.title||"Conversation")}),le},[k]),H=E.useMemo(()=>{const le=[];return w.current.forEach((ve,V)=>{V!==e&&ve.size>0&&le.push({conversationId:V,uploads:Array.from(ve.entries()).map(([ge,ke])=>({key:ge,progress:ke}))})}),le},[e,c]);return G.jsxs("div",{className:"w-full max-w-full overflow-hidden space-y-3",children:[!ue&&!Q&&G.jsxs("div",{onClick:se,onDragOver:J,onDragLeave:ye,onDrop:ee,className:`
1004
1004
  relative w-full max-w-full border-2 border-dashed rounded-xl p-3 sm:p-4 transition-all cursor-pointer
1005
1005
  ${l?"border-emerald-500 bg-emerald-50 dark:bg-emerald-900/20 dark:border-emerald-400":s?"border-slate-200 dark:border-slate-700 bg-slate-50 dark:bg-slate-800/50 cursor-not-allowed opacity-50":"border-slate-300 dark:border-slate-600 bg-white dark:bg-slate-900/50 hover:border-emerald-400 hover:bg-emerald-50/30 dark:hover:bg-emerald-900/10"}
1006
1006
  `,children:[G.jsx("input",{ref:p,type:"file",multiple:!0,onChange:ie,className:"hidden",disabled:s,accept:".pdf,.doc,.docx,.txt,.md,.csv,.json,.html,.pptx,.xlsx,.py,.java,.sql,.js,.mjs,.ts,.tsx,.cpp,.cxx,.cc,.c,.h,.hpp,.go,.rs,.rb,.php,.sh,.bash,.zsh,.yaml,.yml,.xml,.css,.scss,.sass,.less,.png,.jpg,.jpeg,.tiff,.wav,.mp3,.mp4,.ogg,.flac,.webm,.m4a,.aac,.vtt"}),G.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 text-center",children:[G.jsx(Oie,{className:`w-6 h-6 ${l?"text-emerald-600 dark:text-emerald-400":"text-slate-400 dark:text-slate-500"}`}),G.jsxs("div",{className:"px-2",children:[G.jsx("p",{className:"text-xs sm:text-sm font-medium text-slate-700 dark:text-slate-300",children:s?"File upload disabled":l?"Drop files here":"Click or drag files to upload"}),G.jsxs("p",{className:"text-[10px] sm:text-xs text-slate-500 dark:text-slate-400 mt-0.5 px-1",children:["PDF, DOCX, TXT, CSV, JSON, HTML, code files (.py, .js, .ts, .java, .sql, etc.), images, audio (max ",o," files)"]})]})]})]}),ue&&G.jsx("div",{className:"w-full max-w-full overflow-hidden space-y-2",children:Array.from(T.values()).map(le=>G.jsxs("div",{className:"w-full max-w-full flex items-center gap-3 p-3 bg-slate-50 dark:bg-slate-800/50 rounded-lg overflow-hidden",children:[G.jsx(Zc,{className:"w-4 h-4 text-emerald-600 dark:text-emerald-400 animate-spin flex-shrink-0"}),G.jsxs("div",{className:"flex-1 min-w-0 overflow-hidden",children:[G.jsx("p",{className:"text-sm font-medium text-slate-700 dark:text-slate-300 truncate",children:le.filename}),G.jsx("div",{className:"mt-1 bg-slate-200 dark:bg-slate-700 rounded-full h-1.5",children:G.jsx("div",{className:"bg-emerald-600 dark:bg-emerald-400 h-1.5 rounded-full transition-all duration-300",style:{width:`${le.progress}%`}})})]}),G.jsx("span",{className:"text-xs text-slate-500 dark:text-slate-400",children:le.status==="uploading"?"Uploading...":le.status==="processing"?"Processing...":le.status==="completed"?"Done":"Error"})]},le.filename))}),H.length>0&&G.jsxs("div",{className:"w-full max-w-full space-y-3 rounded-lg border border-slate-200 bg-white p-3 dark:border-slate-700 dark:bg-slate-900/40",children:[G.jsx("p",{className:"text-xs font-semibold text-slate-600 dark:text-slate-300",children:"Uploads in other conversations"}),H.map(({conversationId:le,uploads:ve})=>G.jsxs("div",{className:"space-y-2",children:[G.jsx("div",{className:"text-xs font-medium text-slate-500 dark:text-slate-400",children:te.get(le)||"Conversation"}),ve.map(({key:V,progress:ge})=>G.jsxs("div",{className:"w-full max-w-full flex items-center gap-3 p-3 bg-slate-50 dark:bg-slate-800/50 rounded-lg overflow-hidden",children:[G.jsx(Zc,{className:"w-4 h-4 text-emerald-600 dark:text-emerald-400 animate-spin flex-shrink-0"}),G.jsxs("div",{className:"flex-1 min-w-0 overflow-hidden",children:[G.jsx("p",{className:"text-sm font-medium text-slate-700 dark:text-slate-300 truncate",children:ge.filename}),G.jsx("div",{className:"mt-1 bg-slate-200 dark:bg-slate-700 rounded-full h-1.5",children:G.jsx("div",{className:"bg-emerald-600 dark:bg-emerald-400 h-1.5 rounded-full transition-all duration-300",style:{width:`${ge.progress}%`}})})]}),G.jsx("span",{className:"text-xs text-slate-500 dark:text-slate-400",children:ge.status==="uploading"?"Uploading...":ge.status==="processing"?"Processing...":ge.status==="completed"?"Done":"Error"})]},V))]},le))]})]})}const zU={"image/jpeg":"jpg","image/jpg":"jpg","image/png":"png","image/tiff":"tiff","image/tif":"tif","image/gif":"gif","image/webp":"webp","application/pdf":"pdf","application/vnd.openxmlformats-officedocument.wordprocessingml.document":"docx","application/msword":"doc","text/plain":"txt","text/markdown":"md","application/json":"json"};function TVe(e){if(!e)return"bin";if(zU[e])return zU[e];const t=e.split("/");return t.length===2&&t[1]?t[1]:"bin"}function CVe(e){return e.replace(/[^a-zA-Z0-9._-]/g,"_").replace(/_+/g,"_")||"pasted-file"}function IVe(e){const t=e.lastIndexOf(".");return t===-1||t===e.length-1?null:e.slice(t+1).toLowerCase()}function OVe(e){const t=e.lastIndexOf(".");return t===-1?e:e.slice(0,t)}function NVe(e,t){const r=Date.now(),n=e.name&&e.name.trim().length>0?e.name.trim():"pasted-file",a=CVe(OVe(n)),o=IVe(n)||TVe(e.type),s=`${a}-${r}-${t}.${o}`;return new File([e],s,{type:e.type||"application/octet-stream"})}function jU({onSend:e,disabled:t=!1,placeholder:r="Ask me anything...",isCentered:n=!1}){var Fe;const[a,i]=E.useState(""),[o,s]=E.useState(!1),[l,u]=E.useState(!1),[c,d]=E.useState(!1),[p,h]=E.useState([]),[g,b]=E.useState({}),[w,x]=E.useState(new Map),[v,k]=E.useState(!1),[T,I]=E.useState(!1),[_,P]=E.useState(null),[z,j]=E.useState(null),[D,B]=E.useState(null),J=E.useRef(null),ye=E.useRef(new Set),ee=E.useRef(""),ie=E.useRef(!1),se=E.useRef(0),ue=E.useRef(null),{settings:Q,updateSettings:te}=Ky(),H=E.useCallback((F,Ae)=>{F&&b(Qe=>{if(Qe[F]===Ae)return Qe;const O={...Qe};return Ae?O[F]=!0:delete O[F],O})},[]),[le,ve]=E.useState(0),{createConversation:V,currentConversationId:ge,removeFileFromConversation:ke,conversations:ze,isLoading:Ee,syncConversationFiles:Ve}=fr(),me=ze.find(F=>F.id===ge),je=E.useCallback(()=>{ve(F=>F+1)},[]),{isListening:qe,isSupported:Le,startListening:Xe,stopListening:ht,error:st}=lVe(F=>{i(Ae=>{const Qe=(Ae+F).slice(0,Er.maxMessageLength);return ee.current=Qe,Qe})},je),dt=XGe(),St=dt&&Le,Pt=ZGe(),dn=(me==null?void 0:me.attachedFiles)||[],Yt=((Fe=me==null?void 0:me.adapterInfo)==null?void 0:Fe.isFileSupported)??!1,vr=p.some(F=>F.processing_status?F.processing_status!=="completed"&&F.processing_status!=="error"&&F.processing_status!=="failed":!0)||dn.some(F=>F.processing_status?F.processing_status!=="completed"&&F.processing_status!=="error"&&F.processing_status!=="failed":!0),$t=ge?!!g[ge]:!1,Dt=Object.values(g).some(Boolean),Ft=t||vr||$t,nr=Pt&&Yt,Me=!nr||Ft;E.useEffect(()=>{if(J.current){J.current.style.height="auto";const Ae=J.current.scrollHeight;J.current.style.height=`${Math.min(Ae,120)}px`,J.current.style.overflowY=Ae>120?"auto":"hidden"}},[a]),E.useEffect(()=>{!Ft&&J.current&&J.current.focus()},[Ft]);const $e=E.useRef(Ee);E.useEffect(()=>{$e.current&&!Ee&&!Ft&&J.current&&setTimeout(()=>{J.current&&J.current.focus()},100),$e.current=Ee},[Ee,Ft]),E.useEffect(()=>{if(!St||(le>se.current&&(ie.current=!0,se.current=le),!ie.current||le===0))return;const F=setTimeout(()=>{const Ae=ee.current.trim(),Qe=fr.getState();if(mt("[MessageInput] Auto-send check after voice completion:",{hasMessage:!!Ae,isInputDisabled:Ft,isComposing:o,isLoading:Qe.isLoading}),!Ae){ie.current=!1;return}if(!Ft&&!o&&!Qe.isLoading){const O=Qe.conversations.find(W=>W.id===Qe.currentConversationId),Oe=((O==null?void 0:O.attachedFiles)||[]).map(W=>W.file_id);e(Ae,Oe.length>0?Oe:void 0),ie.current=!1,i(""),ee.current="",J.current&&(J.current.style.height="auto",J.current.style.overflowY="hidden")}},400);return()=>clearTimeout(F)},[St,le,Ft,o,e]),E.useEffect(()=>{$t&&c&&d(!1)},[$t,c]),E.useEffect(()=>{!$t&&p.length},[$t,p.length,c]);const at=E.useCallback((F,Ae)=>{setTimeout(()=>{let Qe=fr.getState(),O=Ae||Qe.currentConversationId;if(O||(O=V(),Qe=fr.getState(),O=Qe.currentConversationId||O),!O)return;const we=new Set(F.map(W=>W.file_id)),Oe=[];ye.current.forEach((W,he)=>{const[,..._e]=he.split("-"),nt=_e.join("-");we.has(nt)||Oe.push(he)}),Oe.forEach(W=>ye.current.delete(W)),F.forEach(W=>{const he=`${O}-${W.file_id}`;ye.current.has(he)||(ye.current.add(he),mt(`[MessageInput] Adding file ${W.file_id} to conversation ${O}`),Qe.addFileToConversation(O,W))})},0)},[V]);E.useEffect(()=>{if(ge!==ue.current)if(ue.current=ge||null,ge&&me){const F=me.attachedFiles||[];h(F.map(Ae=>({...Ae})))}else h([])},[ge,me]),E.useEffect(()=>{if(ge&&me){const F=me.attachedFiles||[];F.length>0?h(Ae=>{const Qe=new Set(Ae.map(we=>we.file_id)),O=F.filter(we=>!Qe.has(we.file_id));return O.length>0?(mt(`[MessageInput] Syncing ${O.length} missing files from conversation to UI`),[...Ae,...O]):Ae}):F.length===0&&p.length>0&&h([])}},[ge,me,ze,p.length]),E.useEffect(()=>{if(!ge||!me||!me.apiKey)return;const F=me.attachedFiles||[],Ae=F.length>0,Qe=F.filter(we=>!we.processing_status||we.processing_status==="processing"||we.processing_status==="uploading");if(Ae&&(mt(`[MessageInput] Syncing ${F.length} files for conversation ${ge}...`),Ve(ge).catch(we=>{})),Qe.length===0)return;mt(`[MessageInput] Found ${Qe.length} files still processing, starting poll...`);const O=setInterval(async()=>{const Oe=fr.getState().conversations.find(_e=>_e.id===ge);if(!Oe){clearInterval(O);return}if((Oe.attachedFiles||[]).filter(_e=>!_e.processing_status||_e.processing_status==="processing"||_e.processing_status==="uploading").length===0){clearInterval(O);return}try{await Ve(ge)}catch{}},3e3);return()=>{clearInterval(O)}},[ge,me,Ve]),E.useEffect(()=>{b(F=>{const Ae=new Set(ze.map(we=>we.id));let Qe=!1;const O={...F};return Object.keys(O).forEach(we=>{Ae.has(we)||(delete O[we],Qe=!0)}),Qe?O:F})},[ze]);const Tt=F=>{if(F.preventDefault(),(a.trim()||p.length>0)&&!Ft&&!o){qe&&ht();const Qe=((me==null?void 0:me.attachedFiles)||[]).map(O=>O.file_id);e(a.trim(),Qe.length>0?Qe:void 0),sl("messageSent",Q.soundEnabled),i(""),ee.current="",h([]),d(!1),J.current&&(J.current.style.height="auto",J.current.style.overflowY="hidden")}},Ct=E.useCallback(F=>{if(!F||F.length===0)return;const Ae=F.length===1?`File "${F[0].filename}" uploaded successfully`:`${F.length} files uploaded successfully`;sl("success",Q.soundEnabled),j(Ae),setTimeout(()=>{j(null)},6e3)},[Q.soundEnabled]),Mt=E.useCallback((F,Ae)=>{mt(`[MessageInput] handleFilesSelected called with ${Ae.length} files for conversation ${F}:`,Ae),F&&(F===ge&&h(Ae),at(Ae,F))},[ge,at]),Ge=E.useCallback((F,Ae)=>{F===ge&&Ct(Ae)},[ge,Ct]),zt=async F=>{const Ae=p.find(O=>O.file_id===F),Qe=(Ae==null?void 0:Ae.filename)||"File";if(h(O=>O.filter(we=>we.file_id!==F)),ge){const O=`${ge}-${F}`;ye.current.delete(O)}if(ge)try{await ke(ge,F),sl("success",Q.soundEnabled),B(`File "${Qe}" removed successfully`),setTimeout(()=>{B(null)},3e3)}catch{sl("error",Q.soundEnabled)}else sl("success",Q.soundEnabled),B(`File "${Qe}" removed successfully`),setTimeout(()=>{B(null)},3e3)},ar=F=>{F.key==="Enter"&&!F.shiftKey&&!o&&(F.preventDefault(),Tt(F))},Xt=()=>{qe?ht():Xe()},X=()=>{te({voiceEnabled:!Q.voiceEnabled})},Ue=E.useCallback(async F=>{if(!Pt||!l||!Yt||Ft)return;const Ae=F.clipboardData;if(!Ae||!Ae.items)return;const O=Array.from(Ae.items).filter(W=>W.kind==="file");if(O.length===0)return;const we=[];if(O.forEach((W,he)=>{const _e=W.getAsFile();_e&&we.push(NVe(_e,he))}),we.length===0)return;F.preventDefault(),P(null),j(null);let Oe=null;try{const W=fr.getState(),he=W.conversations.find(re=>re.id===W.currentConversationId);if(((he==null?void 0:he.attachedFiles)||[]).length+we.length>Er.maxFilesPerConversation)throw new Error(`Maximum ${Er.maxFilesPerConversation} files allowed per conversation. Please remove some files first.`);if(Er.maxTotalFiles!==null&&W.conversations.reduce((gt,We)=>{var Lt;return gt+(((Lt=We.attachedFiles)==null?void 0:Lt.length)||0)},0)+we.length>Er.maxTotalFiles)throw new Error(`Maximum ${Er.maxTotalFiles} total files allowed across all conversations. Please remove some files from other conversations first.`);if(!he||!he.apiKey||he.apiKey===Cu())throw new Error("API key not configured for this conversation. Please configure API settings first.");const A=he.apiKey,R=hs(he.apiUrl);Oe=he.id,H(Oe,!0);const Pe=[],$=[];for(let re=0;re<we.length;re++){const gt=we[re],We=gt.name||`Clipboard file ${re+1}`,Lt=`${We}-${Date.now()}-${re}`;x(Bt=>{const Sr=new Map(Bt);return Sr.set(Lt,{filename:We,progress:0,status:"uploading"}),Sr});const or=Bt=>{x(Sr=>{const oe=new Map(Sr),ce=oe.get(Lt);return ce&&oe.set(Lt,{...ce,filename:We,progress:Bt.progress,status:Bt.status,fileId:Bt.fileId}),oe})},kt=()=>new Promise(Bt=>{x(Sr=>{const oe=new Map(Sr),ce=oe.get(Lt);return ce&&oe.set(Lt,{...ce,progress:100,status:"completed"}),oe}),setTimeout(()=>{x(Sr=>{const oe=new Map(Sr);return oe.delete(Lt),oe}),Bt()},2500)});mt(`[MessageInput] Pasting file: ${gt.name}, type: ${gt.type||"unknown"}, size: ${gt.size}`);const xr=await yu.uploadFile(gt,Bt=>{mt(`[MessageInput] Paste upload progress for ${gt.name}: ${Bt.progress}% - ${Bt.status}`),or(Bt)},A,R);Pe.push(xr),$.push(kt())}if(Pe.length>0){let re=Pe;if(Oe&&Oe===ge){const gt=new Set(p.map(Lt=>Lt.file_id)),We=Pe.filter(Lt=>!gt.has(Lt.file_id));We.length>0?(h(Lt=>[...Lt,...We]),re=We):re=[]}re.length>0&&at(re,Oe),await Promise.all($),Ct(Pe)}}catch(W){const he=W instanceof Error?W.message:"Failed to paste file";sl("error",Q.soundEnabled),P(he),setTimeout(()=>{P(null)},5e3),x(new Map)}finally{H(Oe,!1)}},[p,ge,l,Yt,Ft,H,Q.soundEnabled,Ct,at,Pt]),He=vr||$t?"Files are uploading/processing, please wait...":nr?"Message ORBIT or drop files here":r;E.useEffect(()=>{!dt||!st||sl("error",Q.soundEnabled)},[dt,Q.soundEnabled,st]);const it=n?"max-w-3xl":"max-w-5xl",be=n?"flex justify-center":"";return G.jsx("div",{className:`bg-white px-3 py-4 dark:bg-[#212121] sm:px-4 ${be}`,children:G.jsxs("div",{className:`mx-auto w-full ${it}`,children:[st&&dt&&G.jsx("div",{className:"mb-3 w-full rounded-md border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-600/40 dark:bg-red-900/30 dark:text-red-200",children:st}),_&&G.jsx("div",{className:"mb-3 w-full rounded-md border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-600/40 dark:bg-red-900/30 dark:text-red-200",children:_}),z&&G.jsxs("div",{className:"mb-3 w-full flex items-center gap-2 rounded-md border border-green-200 bg-green-50 px-3 py-2 text-sm text-green-700 dark:border-green-600/40 dark:bg-green-900/30 dark:text-green-200",children:[G.jsx(eI,{className:"h-4 w-4 flex-shrink-0"}),G.jsx("span",{children:z})]}),D&&G.jsxs("div",{className:"mb-3 w-full flex items-center gap-2 rounded-md border border-green-200 bg-green-50 px-3 py-2 text-sm text-green-700 dark:border-green-600/40 dark:bg-green-900/30 dark:text-green-200",children:[G.jsx(eI,{className:"h-4 w-4 flex-shrink-0"}),G.jsx("span",{children:D})]}),G.jsxs("form",{onSubmit:Tt,className:"flex w-full flex-col gap-3",children:[G.jsxs("div",{className:`flex flex-wrap gap-2 rounded-lg border px-3 py-3 shadow-sm transition-all sm:flex-nowrap sm:px-4 ${l?"border-gray-400 shadow-md dark:border-[#565869] dark:shadow-lg":"border-gray-300 dark:border-[#40414f]"} bg-gray-50 dark:bg-[#2d2f39]`,children:[Pt&&G.jsx("button",{type:"button",onClick:F=>{F.preventDefault(),Me||d(!c)},disabled:Me,onMouseEnter:()=>k(!0),onMouseLeave:()=>k(!1),className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition-colors ${c||p.length>0?"bg-gray-100 text-[#353740] dark:bg-[#565869] dark:text-[#ececf1]":Me?"cursor-not-allowed text-gray-300 dark:text-[#6b6f7a]":"text-gray-500 hover:bg-gray-100 hover:text-[#353740] dark:text-[#bfc2cd] dark:hover:bg-[#565869]"}`,title:Yt?Ft?"Files are uploading/processing. Please wait...":p.length>0?`${p.length} file(s) attached`:"Attach files":"File upload not supported by this adapter",children:Me&&v?G.jsx(Xc,{className:"h-4 w-4"}):G.jsx(iG,{className:"h-4 w-4"})}),G.jsx("textarea",{ref:J,value:a,onChange:F=>i(F.target.value),onKeyDown:ar,onPaste:Ue,onCompositionStart:()=>s(!0),onCompositionEnd:()=>s(!1),onFocus:()=>u(!0),onBlur:()=>u(!1),placeholder:He,disabled:Ft,rows:1,maxLength:Er.maxMessageLength,className:"flex-1 min-w-[150px] resize-none bg-transparent py-1 text-sm text-[#353740] placeholder-gray-600 focus:outline-none dark:text-[#ececf1] dark:placeholder-[#bfc2cd]",style:{minHeight:"24px",maxHeight:"120px",border:"none",outline:"none",boxShadow:"none",WebkitAppearance:"none",MozAppearance:"none",appearance:"none",caretColor:a.trim()||l?"inherit":"transparent"}}),G.jsxs("div",{className:"flex flex-shrink-0 flex-wrap items-center justify-end gap-2",children:[a.length>0&&G.jsx("div",{className:"min-w-[72px] text-right text-xs text-gray-500 dark:text-[#bfc2cd]",children:G.jsxs("span",{className:a.length>=Er.maxMessageLength?"text-red-600 font-semibold":"",children:[a.length,"/",Er.maxMessageLength]})}),dt&&G.jsxs(G.Fragment,{children:[G.jsx("button",{type:"button",onClick:X,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition-colors ${Q.voiceEnabled?"bg-blue-50 text-blue-600 dark:bg-blue-900/40 dark:text-blue-300":"text-gray-500 hover:bg-gray-100 hover:text-[#353740] dark:text-[#bfc2cd] dark:hover:bg-[#565869]"}`,title:Q.voiceEnabled?"Voice responses enabled - Click to disable":"Enable voice responses (text-to-speech)",children:Q.voiceEnabled?G.jsx(ug,{className:"h-5 w-5"}):G.jsx(Nie,{className:"h-5 w-5"})}),St&&G.jsx("button",{type:"button",onClick:Xt,disabled:Ft,onMouseEnter:()=>I(!0),onMouseLeave:()=>I(!1),className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition-colors ${qe?"bg-red-50 text-red-600 dark:bg-red-900/40 dark:text-red-300":Ft?"cursor-not-allowed text-gray-300 dark:text-[#6b6f7a]":"text-gray-500 hover:bg-gray-100 hover:text-[#353740] dark:text-[#bfc2cd] dark:hover:bg-[#565869]"}`,title:Ft?"Files are uploading/processing. Please wait...":qe?"Stop recording":"Start voice input",children:qe||Ft&&T?G.jsx(die,{className:"h-5 w-5"}):G.jsx(pie,{className:"h-5 w-5"})})]}),(vr||$t)&&G.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center",children:G.jsx(Zc,{className:"h-4 w-4 animate-spin text-gray-500 dark:text-[#bfc2cd]"})}),G.jsx("button",{type:"submit",disabled:!a.trim()&&p.length===0||Ft||o,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition-colors ${(a.trim()||p.length>0)&&!Ft&&!o?"bg-black text-white hover:bg-gray-800 dark:bg-white dark:text-black dark:hover:bg-gray-200":"bg-gray-200 text-gray-400 dark:bg-[#565869] dark:text-[#6b6f7a]"}`,title:"Send message",children:G.jsx(aG,{className:"h-4 w-4"})})]})]}),p.length>0&&G.jsx("div",{className:"flex flex-wrap gap-2",children:p.map(F=>{const Ae=!F.processing_status||F.processing_status==="processing"||F.processing_status==="uploading";return G.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-gray-200 bg-white px-2 py-1 text-xs dark:border-[#4a4b54] dark:bg-[#2d2f39]",children:[Ae&&G.jsx(Zc,{className:"h-3 w-3 animate-spin text-emerald-600 dark:text-emerald-400 flex-shrink-0"}),G.jsx("span",{className:"truncate max-w-[150px] text-[#353740] dark:text-[#ececf1]",children:F.filename}),Ae&&G.jsx("span",{className:"text-xs text-gray-500 dark:text-[#bfc2cd]",children:F.processing_status==="uploading"?"Uploading...":"Processing..."}),!t&&G.jsx("button",{onClick:()=>zt(F.file_id),className:"text-gray-500 hover:text-red-600 dark:text-[#bfc2cd] dark:hover:text-red-300",title:"Remove file",children:G.jsx(Xc,{className:"h-3 w-3"})})]},F.file_id)})}),Pt&&(Yt||Dt)&&G.jsxs("div",{className:`rounded-md border border-gray-200 bg-white p-3 dark:border-[#4a4b54] dark:bg-[#2d2f39] ${!c&&!$t&&w.size===0&&!Dt?"hidden":""}`,children:[c&&G.jsxs("div",{className:"mb-2 flex items-center justify-between text-sm text-[#353740] dark:text-[#ececf1]",children:[G.jsx("span",{children:"Upload files"}),G.jsx("button",{onClick:()=>d(!1),className:"rounded p-1 text-gray-500 hover:bg-gray-100 hover:text-[#353740] dark:text-[#bfc2cd] dark:hover:bg-[#3c3f4a]",title:"Close",children:G.jsx(Xc,{className:"h-4 w-4"})})]}),($t||w.size>0)&&!c&&w.size===0&&G.jsx("div",{className:"mb-2 text-sm text-[#353740] dark:text-[#ececf1]",children:"Uploading files…"}),w.size>0&&G.jsx("div",{className:"mb-2 space-y-2",children:Array.from(w.entries()).map(([F,Ae])=>G.jsxs("div",{className:"w-full max-w-full flex items-center gap-3 p-3 bg-gray-50 dark:bg-[#1f1f24] rounded-lg overflow-hidden",children:[G.jsx(Zc,{className:"w-4 h-4 text-emerald-600 dark:text-emerald-400 animate-spin flex-shrink-0"}),G.jsxs("div",{className:"flex-1 min-w-0 overflow-hidden",children:[G.jsx("p",{className:"text-sm font-medium text-[#353740] dark:text-[#ececf1] truncate",children:Ae.filename}),G.jsx("div",{className:"mt-1 bg-gray-200 dark:bg-[#3c3f4a] rounded-full h-1.5",children:G.jsx("div",{className:"bg-emerald-600 dark:bg-emerald-400 h-1.5 rounded-full transition-all duration-300",style:{width:`${Ae.progress??0}%`}})})]}),G.jsx("span",{className:"text-xs text-gray-500 dark:text-[#bfc2cd]",children:Ae.status==="uploading"?"Uploading...":Ae.status==="processing"?"Processing...":Ae.status==="completed"?"Done":"Pending"})]},F))}),G.jsx(AVe,{conversationId:ge,onFilesSelected:Mt,onUploadError:F=>{},onUploadingChange:H,onUploadSuccess:Ge,maxFiles:Er.maxFilesPerConversation,disabled:Me})]}),G.jsx("div",{className:"h-4",children:St&&qe&&G.jsxs("span",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-[#bfc2cd]",children:[G.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-red-500"}),"Listening..."]})})]})]})})}function RVe({onOpenSettings:e,onOpenSidebar:t}){const{conversations:r,currentConversationId:n,sendMessage:a,regenerateResponse:i,isLoading:o,configureApiSettings:s,error:l,clearError:u,createThread:c}=fr(),{settings:d}=Ky(),[p,h]=E.useState(!1),[g,b]=E.useState(()=>ea()),[w,x]=E.useState(()=>Cu()),[v,k]=E.useState(!1),[T,I]=E.useState(!1),[_,P]=E.useState(null),[z,j]=E.useState(!1),D=r.find(se=>se.id===n),B=!D||D.messages.length===0;E.useEffect(()=>{let se=null;const ue=()=>{se&&(se(),se=null)};if(d.voiceEnabled){if(bu.isAudioEnabled())return ue;const Q=()=>{ue();const te=async()=>{ue(),await bu.enableAudio()||Q()};document.addEventListener("pointerdown",te,{once:!0}),document.addEventListener("keydown",te,{once:!0}),se=()=>{document.removeEventListener("pointerdown",te),document.removeEventListener("keydown",te)}};return Q(),ue}return ue(),bu.disableAudio(),ue},[d.voiceEnabled]);const J=(se,ue,Q)=>{a(se,ue,Q)},ye=async(se,ue,Q)=>{await a(Q,void 0,se)},ee=async()=>{if(!(!D||!D.apiKey)){j(!0);try{const se=await Un(),ue=D.apiUrl||ea(),Q=D.apiKey,te=new se.ApiClient({apiUrl:ue,apiKey:Q,sessionId:null});if(typeof te.getAdapterInfo=="function"){const H=await te.getAdapterInfo();mt("Adapter info refreshed:",H),fr.setState(le=>({conversations:le.conversations.map(ve=>ve.id===n?{...ve,adapterInfo:H,updatedAt:new Date}:ve)})),setTimeout(()=>{const le=fr.getState();localStorage.setItem("chat-state",JSON.stringify({conversations:le.conversations,currentConversationId:le.currentConversationId}))},0)}}catch{}finally{j(!1)}}},ie=async()=>{if(g&&w){I(!0),P(null);try{await s(g,w),u(),P(null),k(!1),h(!1)}catch(se){const ue=se instanceof Error?se.message:"Failed to configure API settings";P(ue)}finally{I(!1)}}};return G.jsx("div",{className:"flex-1 flex flex-col",children:G.jsx("div",{className:"flex h-full w-full flex-col px-3 sm:px-6",children:G.jsxs("div",{className:"mx-auto flex h-full w-full max-w-5xl flex-col",children:[p&&G.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 px-4",children:G.jsxs("div",{className:"w-full max-w-md rounded-lg border border-gray-200 bg-white p-6 shadow-lg dark:border-[#444654] dark:bg-[#202123]",children:[G.jsx("h2",{className:"text-lg font-medium text-[#353740] dark:text-[#ececf1] mb-4",children:"Configure API Settings"}),G.jsxs("div",{className:"space-y-5",children:[G.jsxs("div",{children:[G.jsx("label",{className:"block text-sm font-medium text-[#353740] dark:text-[#d1d5db] mb-2",children:"API URL"}),G.jsx("input",{type:"text",value:g,onChange:se=>b(se.target.value),className:"w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-sm text-[#353740] focus:border-gray-400 focus:outline-none dark:border-[#4a4b54] dark:bg-[#343541] dark:text-[#ececf1]",placeholder:"https://api.example.com"})]}),G.jsxs("div",{children:[G.jsx("label",{className:"block text-sm font-medium text-[#353740] dark:text-[#d1d5db] mb-2",children:"API Key"}),G.jsxs("div",{className:"relative",children:[G.jsx("input",{type:v?"text":"password",value:w,onChange:se=>{x(se.target.value),P(null)},className:"w-full rounded-md border border-gray-300 bg-white px-3 py-2 pr-10 text-sm text-[#353740] focus:border-gray-400 focus:outline-none dark:border-[#4a4b54] dark:bg-[#343541] dark:text-[#ececf1]",placeholder:"your-api-key",disabled:T}),G.jsx("button",{type:"button",onClick:()=>k(!v),className:"absolute right-2 top-1/2 -translate-y-1/2 rounded p-1 text-gray-500 hover:text-gray-700 dark:text-[#d1d5db] dark:hover:text-white","aria-label":v?"Hide API key":"Show API key",disabled:T,children:v?G.jsx(sie,{className:"h-4 w-4"}):G.jsx(lie,{className:"h-4 w-4"})})]})]}),_&&G.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-600/40 dark:bg-red-900/30 dark:text-red-200",children:_}),G.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[G.jsx("button",{onClick:()=>{const se=(D==null?void 0:D.apiUrl)||ea(),ue=(D==null?void 0:D.apiKey)||Cu();b(se),x(ue),P(null),k(!1),h(!1)},className:"rounded-md border border-transparent px-4 py-2 text-sm text-gray-600 hover:border-gray-300 hover:text-gray-900 dark:text-[#d1d5db] dark:hover:text-white disabled:cursor-not-allowed disabled:opacity-50",disabled:T,children:"Cancel"}),G.jsx("button",{onClick:ie,disabled:!g||!w||T,className:"rounded-md bg-[#343541] px-4 py-2 text-sm font-medium text-white hover:bg-[#282b32] disabled:cursor-not-allowed disabled:opacity-50 dark:bg-[#565869] dark:hover:bg-[#6b6f7a]",children:T?"Validating...":"Configure"})]})]})]})}),l&&G.jsx("div",{className:"mt-6 rounded-md border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700 dark:border-red-600/40 dark:bg-red-900/30 dark:text-red-200",children:G.jsxs("div",{className:"flex items-start justify-between",children:[G.jsx("p",{children:l}),G.jsx("button",{onClick:u,className:"ml-4 rounded p-1 text-red-500 hover:bg-red-100 hover:text-red-700 dark:text-red-200 dark:hover:bg-red-800/40","aria-label":"Dismiss error",children:"×"})]})}),t&&G.jsxs("div",{className:"mb-4 flex items-center justify-between gap-3 md:hidden",children:[G.jsxs("button",{onClick:t,className:"inline-flex items-center gap-2 rounded-md border border-gray-300 px-3 py-2 text-sm font-medium text-gray-700 hover:bg-gray-50 hover:border-gray-400 transition-colors dark:border-[#4a4b54] dark:text-[#ececf1] dark:hover:bg-[#343541]","aria-label":"Open conversations menu",children:[G.jsx(cie,{className:"h-4 w-4"}),"Chats"]}),G.jsx("button",{onClick:e,className:"inline-flex items-center justify-center rounded-md bg-[#343541] p-2 text-white hover:bg-[#282b32] transition-colors dark:bg-[#565869] dark:hover:bg-[#6b6f7a]","aria-label":"Open settings",children:G.jsx(tI,{className:"h-4 w-4"})})]}),G.jsx("div",{className:"border-b border-gray-200 dark:border-[#4a4b54] pb-6 pt-6",children:G.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[G.jsx("div",{className:"min-w-0 flex-1",children:(D==null?void 0:D.adapterInfo)&&G.jsxs("div",{className:"mb-4",children:[G.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-3",children:[G.jsxs("div",{className:"inline-flex items-center gap-2 px-2.5 py-1 rounded-md bg-gray-100 dark:bg-[#343541] border border-gray-200 dark:border-[#4a4b54]",children:[G.jsx("span",{className:"text-xs font-medium text-gray-600 dark:text-[#bfc2cd] uppercase tracking-wide",children:"Agent"}),G.jsx("span",{className:"text-sm font-semibold text-[#353740] dark:text-[#ececf1]",children:D.adapterInfo.client_name})]}),D.adapterInfo.model&&G.jsxs("div",{className:"inline-flex items-center gap-2 px-2.5 py-1 rounded-md bg-gray-100 dark:bg-[#343541] border border-gray-200 dark:border-[#4a4b54]",children:[G.jsx("span",{className:"text-xs font-medium text-gray-600 dark:text-[#bfc2cd] uppercase tracking-wide",children:"Model"}),G.jsx("span",{className:"text-sm font-semibold text-[#353740] dark:text-[#ececf1]",children:D.adapterInfo.model})]}),G.jsx("button",{onClick:ee,disabled:z||!(D!=null&&D.apiKey),className:"inline-flex items-center gap-1.5 px-2 py-1 rounded-md text-xs text-gray-600 hover:text-gray-900 hover:bg-gray-200 dark:text-[#bfc2cd] dark:hover:text-white dark:hover:bg-[#4a4b54] transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:"Refresh adapter info",children:G.jsx(wie,{className:`h-4 w-4 ${z?"animate-spin":""}`})})]}),G.jsx("h1",{className:"text-2xl font-semibold text-[#353740] dark:text-[#ececf1] mb-2",children:(D==null?void 0:D.title)||"New Chat"}),D&&G.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500 dark:text-[#bfc2cd]",children:[G.jsx("span",{className:"font-medium",children:D.messages.length}),G.jsxs("span",{children:["Updated ",D.updatedAt.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})]})]})]})}),G.jsxs("div",{className:"flex w-full flex-wrap items-center gap-3 sm:w-auto sm:flex-nowrap sm:justify-end",children:[G.jsxs("span",{className:"text-sm text-gray-500 dark:text-[#bfc2cd] sm:text-right",children:["v",fte]}),G.jsx("button",{onClick:()=>{const se=ea(),ue=D==null?void 0:D.apiUrl,Q=ue&&ue!==se?ue:se,te=(D==null?void 0:D.apiKey)||Cu();b(Q),x(te),P(null),k(!1),h(!0)},disabled:!B,className:"w-full rounded-md border border-gray-300 px-3 py-2 text-sm font-medium text-gray-700 hover:bg-gray-50 hover:border-gray-400 transition-colors disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-transparent disabled:hover:border-gray-300 dark:border-[#4a4b54] dark:text-[#ececf1] dark:hover:bg-[#3c3f4a] dark:hover:border-[#6b6f7a] dark:disabled:hover:bg-transparent dark:disabled:hover:border-[#4a4b54] sm:w-auto",title:B?"Configure API settings":"API key cannot be changed once conversation has started. Create a new conversation to use a different API key.",children:"Configure API"}),G.jsx("button",{onClick:e,className:"hidden rounded-md bg-[#343541] p-2 text-white hover:bg-[#282b32] transition-colors dark:bg-[#565869] dark:hover:bg-[#6b6f7a] md:inline-flex",title:"Settings",children:G.jsx(tI,{className:"h-4 w-4"})})]})]})}),!D||D.messages.length===0?G.jsx("div",{className:"flex-1 flex flex-col items-center justify-center min-h-0 px-4",children:G.jsxs("div",{className:"w-full max-w-3xl mx-auto text-center space-y-3",children:[G.jsx("div",{className:"space-y-1.5",children:G.jsx("h2",{className:"text-2xl font-medium text-[#353740] dark:text-[#ececf1]",children:"How can I assist you today?"})}),G.jsx("div",{className:"w-full",children:G.jsx(jU,{onSend:J,disabled:o||!D||!D.apiKey,placeholder:"Message ORBIT...",isCentered:!0})})]})}):G.jsxs(G.Fragment,{children:[G.jsx(oVe,{messages:D.messages,onRegenerate:i,onStartThread:async(se,ue)=>{try{await c(se,ue)}catch{}},onSendThreadMessage:ye,sessionId:D.sessionId,isLoading:o}),G.jsx(jU,{onSend:J,disabled:o||!D||!D.apiKey,placeholder:"Message ORBIT..."})]})]})})})}function $U({isOpen:e,onClose:t,onConfirm:r,title:n,message:a,confirmText:i="Confirm",cancelText:o="Cancel",type:s="danger",isLoading:l=!1}){if(!e)return null;const u=()=>{l||r()},d=(()=>{switch(s){case"danger":return{icon:"text-red-500",iconBg:"bg-red-100 dark:bg-red-900/20",confirmButton:"bg-red-600 hover:bg-red-700 focus:ring-red-500",border:"border-red-200 dark:border-red-800"};case"warning":return{icon:"text-amber-500",iconBg:"bg-amber-100 dark:bg-amber-900/20",confirmButton:"bg-amber-600 hover:bg-amber-700 focus:ring-amber-500",border:"border-amber-200 dark:border-amber-800"};default:return{icon:"text-blue-500",iconBg:"bg-blue-100 dark:bg-blue-900/20",confirmButton:"bg-blue-600 hover:bg-blue-700 focus:ring-blue-500",border:"border-blue-200 dark:border-blue-800"}}})();return G.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center p-4 z-50 animate-fadeIn",children:G.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-2xl shadow-2xl w-full max-w-md transform animate-fadeIn",children:[G.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[G.jsxs("div",{className:"flex items-center gap-3",children:[G.jsx("div",{className:`w-10 h-10 rounded-full ${d.iconBg} flex items-center justify-center`,children:G.jsx(nie,{className:`w-5 h-5 ${d.icon}`})}),G.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:n})]}),G.jsx("button",{onClick:t,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",children:G.jsx(Xc,{className:"w-5 h-5 text-gray-500 dark:text-gray-400"})})]}),G.jsx("div",{className:"p-6",children:G.jsx("p",{className:"text-gray-600 dark:text-gray-300 leading-relaxed",children:a})}),G.jsxs("div",{className:"flex items-center justify-end gap-3 p-6 border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50 rounded-b-2xl",children:[G.jsx("button",{onClick:t,disabled:l,className:"px-4 py-2.5 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 rounded-lg transition-colors font-medium disabled:opacity-50 disabled:cursor-not-allowed",children:o}),G.jsx("button",{onClick:u,disabled:l,className:`px-4 py-2.5 text-white rounded-lg transition-all font-medium shadow-sm hover:shadow-md transform hover:scale-105 active:scale-95 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-white dark:focus:ring-offset-gray-800 disabled:opacity-50 disabled:cursor-not-allowed disabled:transform-none ${d.confirmButton}`,children:l?G.jsxs("div",{className:"flex items-center gap-2",children:[G.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}),"Clearing..."]}):i})]})]})})}const MVe=(e,t)=>{const[r,n]=E.useState({stars:0,forks:0,license:"Apache-2.0",description:"An adaptable, open-source context-aware inference engine designed for privacy, control, and independence from proprietary models.",isLoading:!0,error:null});return E.useEffect(()=>{(async()=>{var i;try{const o=await fetch(`https://api.github.com/repos/${e}/${t}`);if(!o.ok)throw new Error(`GitHub API error: ${o.status}`);const s=await o.json();n({stars:s.stargazers_count||0,forks:s.forks_count||0,license:((i=s.license)==null?void 0:i.name)||"Apache-2.0",description:s.description||"An adaptable, open-source context-aware inference engine designed for privacy, control, and independence from proprietary models.",isLoading:!1,error:null})}catch(o){console.warn("Failed to fetch GitHub stats:",o),n({stars:104,forks:19,license:"Apache-2.0",description:"An adaptable, open-source context-aware inference engine designed for privacy, control, and independence from proprietary models.",isLoading:!1,error:o instanceof Error?o.message:"Failed to fetch stats"})}})()},[e,t]),r},cm=100;function UU({onRequestClose:e}){const{conversations:t,currentConversationId:r,createConversation:n,selectConversation:a,deleteConversation:i,deleteAllConversations:o,updateConversationTitle:s,canCreateNewConversation:l,getConversationCount:u}=fr(),c=t.find(Ee=>Ee.id===r),[d,p]=E.useState(""),[h,g]=E.useState(null),[b,w]=E.useState(""),[x,v]=E.useState({isOpen:!1,conversationId:"",conversationTitle:"",isDeleting:!1}),[k,T]=E.useState({isOpen:!1,isDeleting:!1}),I=t.filter(Ee=>Ee.title.toLowerCase().includes(d.toLowerCase())||Ee.messages.some(Ve=>Ve.content.toLowerCase().includes(d.toLowerCase()))),_=l(),P=u(),z=Er.maxConversations,j=z!==null&&P>=z,D=c?c.messages.length===0:!1,B=z!==null?`${P}/${z} conversations`:`${P} conversation${P===1?"":"s"}`,J=_?"Start a new conversation":j?`Maximum ${z} conversations reached. Delete a conversation to create a new one.`:D?"Current conversation is empty. Send a message first to create a new conversation.":"Finish your current conversation before starting a new one.",ye=eVe(),ee=MVe(LU(),PU()),ie=()=>{try{n(),e==null||e()}catch(Ee){Yr("Cannot create new conversation:",Ee instanceof Error?Ee.message:"Unknown error")}},se=async Ee=>{try{await a(Ee),e==null||e()}catch{}},ue=(Ee,Ve)=>{Ee.stopPropagation(),v({isOpen:!0,conversationId:Ve.id,conversationTitle:Ve.title,isDeleting:!1})},Q=async()=>{v(Ee=>({...Ee,isDeleting:!0}));try{await i(x.conversationId),v({isOpen:!1,conversationId:"",conversationTitle:"",isDeleting:!1})}catch{v({isOpen:!1,conversationId:"",conversationTitle:"",isDeleting:!1})}},te=()=>{v({isOpen:!1,conversationId:"",conversationTitle:"",isDeleting:!1})},H=(Ee,Ve)=>{Ee.stopPropagation(),g(Ve.id),w(Ve.title.slice(0,cm))},le=Ee=>{const Ve=b.slice(0,cm).trim();Ve&&s(Ee,Ve),g(null),w("")},ve=()=>{g(null),w("")},V=()=>{T({isOpen:!0,isDeleting:!1})},ge=async()=>{T(Ee=>({...Ee,isDeleting:!0}));try{await o(),T({isOpen:!1,isDeleting:!1})}catch{T({isOpen:!1,isDeleting:!1})}},ke=()=>{T({isOpen:!1,isDeleting:!1})},ze=Ee=>{const Ve=Ee.toLocaleDateString([],{year:"numeric",month:"short",day:"numeric"}),me=Ee.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});return`${Ve} · ${me}`};return G.jsxs(G.Fragment,{children:[G.jsxs("div",{className:"flex h-full w-full md:w-72 flex-col border-r border-b border-gray-200 bg-gray-50 dark:border-[#4a4b54] dark:bg-[#202123]",children:[G.jsxs("div",{className:"border-b border-gray-200 p-4 dark:border-[#4a4b54]",children:[G.jsxs("button",{onClick:ie,disabled:!_,className:`flex w-full items-center justify-center gap-2 rounded-md px-3 py-2 text-sm font-medium ${_?"bg-[#343541] text-white hover:bg-[#2c2f36] dark:bg-[#565869] dark:hover:bg-[#6b6f7a]":"cursor-not-allowed bg-gray-200 text-gray-500 dark:bg-[#3c3f4a] dark:text-[#6b6f7a]"}`,title:J,children:[G.jsx(xie,{className:"h-4 w-4"}),"New Conversation"]}),G.jsxs("div",{className:"mt-3 space-y-2",children:[G.jsx("div",{className:"text-center",children:G.jsx("span",{className:"text-xs text-gray-500 dark:text-[#bfc2cd]",children:B})}),t.length>0&&G.jsxs("button",{onClick:V,className:"flex w-full items-center justify-center gap-2 rounded-md border border-red-300 px-3 py-2 text-sm font-medium text-red-600 hover:bg-red-50 hover:border-red-400 dark:border-red-600/40 dark:text-red-400 dark:hover:bg-red-900/20 dark:hover:border-red-500/60 transition-colors",title:"Delete all conversations",children:[G.jsx(Cie,{className:"h-4 w-4"}),"Clear All"]})]})]}),G.jsx("div",{className:"border-b border-gray-200 px-4 py-3 dark:border-[#4a4b54]",children:G.jsxs("div",{className:"relative flex items-center",children:[G.jsx(kie,{className:"pointer-events-none absolute left-3 h-4 w-4 text-gray-400"}),G.jsx("input",{type:"text",placeholder:"Search conversations",value:d,onChange:Ee=>p(Ee.target.value),className:"w-full rounded-md border border-gray-300 bg-white py-2 pl-9 pr-3 text-sm text-[#353740] placeholder-gray-400 focus:border-gray-400 focus:outline-none dark:border-[#4a4b54] dark:bg-[#343541] dark:text-[#ececf1]"})]})}),G.jsx("div",{className:"flex-1 overflow-y-auto px-3 py-3",children:I.length===0?G.jsxs("div",{className:"rounded-md border border-dashed border-gray-300 p-6 text-center text-sm text-gray-500 dark:border-[#4a4b54] dark:text-[#bfc2cd]",children:[G.jsx(np,{className:"mx-auto mb-3 h-6 w-6 text-gray-400 dark:text-[#6b6f7a]"}),G.jsx("p",{children:d?"No conversations found":"No conversations yet"})]}):G.jsx("div",{className:"space-y-2",children:I.map(Ee=>G.jsxs("div",{onClick:()=>se(Ee.id),className:`group flex cursor-pointer items-start gap-3 rounded-xl border px-3 py-3 text-left transition ${r===Ee.id?"border-[#343541] bg-white shadow-sm dark:border-[#6b6f7a] dark:bg-[#2c2f36]":"border-transparent bg-gray-100/70 hover:border-gray-300 hover:bg-white dark:bg-[#252830] dark:hover:border-[#4a4b54] dark:hover:bg-[#2f323c]"}`,children:[G.jsx("div",{className:`rounded-xl p-2 shadow-sm ${r===Ee.id?"bg-[#eceefc] text-[#1d2559] dark:bg-[#3b4055] dark:text-white":"bg-white text-gray-500 dark:bg-[#3a3d46] dark:text-[#bfc2cd]"}`,children:G.jsx(np,{className:"h-4 w-4"})}),h===Ee.id?G.jsx("input",{type:"text",value:b,onChange:Ve=>w(Ve.target.value.slice(0,cm)),onKeyDown:Ve=>{Ve.key==="Enter"&&le(Ee.id),Ve.key==="Escape"&&ve()},onBlur:()=>le(Ee.id),maxLength:cm,className:"flex-1 border-none bg-transparent text-sm text-[#353740] focus:outline-none dark:text-[#ececf1]",autoFocus:!0}):G.jsxs("div",{className:"flex-1 min-w-0 space-y-1",children:[G.jsx("h3",{className:`truncate text-sm font-semibold ${r===Ee.id?"text-[#1f2937] dark:text-white":"text-gray-700 dark:text-[#d4d7e2]"}`,children:Ee.title}),G.jsxs("div",{className:"flex items-center gap-1.5 pr-1 text-[11px] text-gray-500 dark:text-[#a6acc5]",children:[G.jsx("span",{className:"whitespace-nowrap leading-none",children:ze(Ee.updatedAt)}),G.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 rounded-full bg-white/80 px-2 py-0.5 font-medium text-gray-600 shadow-sm dark:bg-white/10 dark:text-[#e5e7f4] leading-none",children:[G.jsx(np,{className:"h-3 w-3"}),Ee.messages.length]}),Ee.attachedFiles&&Ee.attachedFiles.length>0&&G.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 rounded-full bg-white/80 px-2 py-0.5 font-medium text-gray-600 shadow-sm dark:bg-white/10 dark:text-[#e5e7f4] leading-none",children:[G.jsx(iG,{className:"h-3 w-3"}),Ee.attachedFiles.length]})]})]}),h!==Ee.id&&G.jsxs("div",{className:"flex items-center gap-1 opacity-0 transition-opacity group-hover:opacity-100",children:[G.jsx("button",{onClick:Ve=>H(Ve,Ee),className:"rounded-full p-2 text-gray-500 hover:bg-gray-200 hover:text-[#353740] dark:text-[#bfc2cd] dark:hover:bg-[#3c3f4a]",title:"Rename conversation",children:G.jsx(bie,{className:"h-4 w-4"})}),G.jsx("button",{onClick:Ve=>ue(Ve,Ee),className:"rounded-full p-2 text-red-500 hover:bg-red-50 dark:text-red-300 dark:hover:bg-red-900/30",title:"Delete conversation",children:G.jsx(Tie,{className:"h-4 w-4"})})]})]},Ee.id))})}),ye&&G.jsx("div",{className:"border-t border-gray-200 p-4 dark:border-[#4a4b54]",children:G.jsxs("div",{className:"text-center",children:[G.jsxs("div",{className:"flex items-center justify-center gap-2 mb-3",children:[G.jsx("svg",{className:"w-5 h-5 text-gray-600 dark:text-[#bfc2cd]",fill:"currentColor",viewBox:"0 0 24 24",children:G.jsx("path",{d:"M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"})}),G.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-[#ececf1]",children:"Powered by ORBIT"})]}),ee.isLoading?G.jsxs("div",{className:"flex items-center justify-center gap-2 text-xs text-gray-500 dark:text-[#bfc2cd] mb-3",children:[G.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-gray-400"}),G.jsx("span",{children:"Loading stats..."})]}):ee.error?G.jsx("div",{className:"flex items-center justify-center gap-2 text-xs text-red-500 dark:text-red-400 mb-3",children:G.jsx("span",{children:"⚠️ Failed to load stats"})}):G.jsxs("div",{className:"flex items-center justify-center gap-4 text-xs text-gray-500 dark:text-[#bfc2cd] mb-3",children:[G.jsxs("div",{className:"flex items-center gap-1",children:[G.jsx("svg",{className:"w-4 h-4 text-yellow-500",fill:"currentColor",viewBox:"0 0 24 24",children:G.jsx("path",{d:"M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z"})}),G.jsxs("span",{children:[ee.stars.toLocaleString()," stars"]})]}),G.jsxs("div",{className:"flex items-center gap-1",children:[G.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 16 16",children:G.jsx("path",{d:"M5 3.25a.75.75 0 11-1.5 0 .75.75 0 011.5 0zm0 2.122a2.25 2.25 0 10-1.5 0v.878A2.25 2.25 0 005.75 8.5h1.5v2.128a2.251 2.251 0 101.5 0V8.5h1.5a2.25 2.25 0 002.25-2.25v-.878a2.25 2.25 0 10-1.5 0v.878a.75.75 0 01-.75.75H4.5A.75.75 0 013 6.25v-.878zm3.75 7.378a.75.75 0 11-1.5 0 .75.75 0 011.5 0zm3-8.75a.75.75 0 100-1.5.75.75 0 000 1.5z"})}),G.jsxs("span",{children:[ee.forks.toLocaleString()," forks"]})]})]}),G.jsxs("a",{href:`https://github.com/${LU()}/${PU()}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-blue-600 hover:text-blue-800 dark:text-blue-400 dark:hover:text-blue-300 transition-colors",children:[G.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 24 24",children:G.jsx("path",{d:"M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"})}),"View on GitHub"]})]})})]}),G.jsx($U,{isOpen:x.isOpen,onClose:te,onConfirm:Q,title:"Delete Conversation",message:`Are you sure you want to delete "${x.conversationTitle}"? This will clear the conversation history from both the server and your local storage. This action cannot be undone.`,confirmText:"Delete",cancelText:"Cancel",type:"danger",isLoading:x.isDeleting}),G.jsx($U,{isOpen:k.isOpen,onClose:ke,onConfirm:ge,title:"Clear All Conversations",message:`Are you sure you want to delete all ${P} conversation${P!==1?"s":""}? This will clear all conversation history from both the server and your local storage. This action cannot be undone.`,confirmText:"Clear All",cancelText:"Cancel",type:"danger",isLoading:k.isDeleting})]})}function LVe({isOpen:e,onClose:t}){const{theme:r,updateTheme:n}=Jae(),{settings:a,updateSettings:i}=Ky(),[o,s]=E.useState(null);if(E.useEffect(()=>{e&&mte().then(s)},[e]),!e)return null;const l=p=>{n({mode:p})},u=p=>{n({fontSize:p})},c=()=>{n({highContrast:!r.highContrast})},d=()=>{i({soundEnabled:!a.soundEnabled})};return G.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center p-4 z-50",children:G.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-2xl shadow-2xl w-full max-w-md max-h-[90vh] overflow-hidden",children:[G.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-600",children:[G.jsx("h2",{className:"text-xl font-semibold text-gray-900 dark:text-gray-100",children:"Settings"}),G.jsx("button",{onClick:t,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",children:G.jsx(Xc,{className:"w-5 h-5 text-gray-500 dark:text-gray-400"})})]}),G.jsxs("div",{className:"p-6 space-y-6 overflow-y-auto",children:[G.jsxs("div",{className:"space-y-4",children:[G.jsxs("h3",{className:"text-lg font-medium text-gray-900 dark:text-gray-100 flex items-center gap-2",children:[G.jsx(gie,{className:"w-5 h-5"}),"Appearance"]}),G.jsxs("div",{className:"space-y-2",children:[G.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Theme"}),G.jsx("div",{className:"grid grid-cols-3 gap-2",children:[{value:"light",label:"Light",icon:Eie},{value:"dark",label:"Dark",icon:fie},{value:"system",label:"System",icon:hie}].map(({value:p,label:h,icon:g})=>G.jsxs("button",{onClick:()=>l(p),className:`flex flex-col items-center gap-2 p-3 rounded-lg border-2 transition-all duration-200 ${r.mode===p?"border-blue-500 bg-blue-50 dark:bg-blue-900/20 text-blue-700 dark:text-blue-300":"border-gray-200 dark:border-gray-600 hover:border-gray-300 dark:hover:border-gray-500 text-gray-700 dark:text-gray-300"}`,children:[G.jsx(g,{className:"w-5 h-5"}),G.jsx("span",{className:"text-sm font-medium",children:h})]},p))})]}),G.jsxs("div",{className:"flex items-center justify-between",children:[G.jsxs("div",{children:[G.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"High Contrast"}),G.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Improve readability with enhanced contrast"})]}),G.jsx("button",{onClick:c,className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${r.highContrast?"bg-blue-600":"bg-gray-200 dark:bg-gray-600"}`,children:G.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${r.highContrast?"translate-x-6":"translate-x-1"}`})})]}),G.jsxs("div",{className:"space-y-2",children:[G.jsxs("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 flex items-center gap-2",children:[G.jsx(Iie,{className:"w-4 h-4"}),"Font Size"]}),G.jsx("div",{className:"grid grid-cols-3 gap-2",children:[{value:"small",label:"Small"},{value:"medium",label:"Medium"},{value:"large",label:"Large"}].map(({value:p,label:h})=>G.jsx("button",{onClick:()=>u(p),className:`p-2 rounded-lg border-2 transition-colors text-center ${r.fontSize===p?"border-blue-500 bg-blue-50 dark:bg-blue-900/20":"border-gray-200 dark:border-gray-600 hover:border-gray-300 dark:hover:border-gray-500"}`,children:G.jsx("span",{className:`font-medium ${p==="small"?"text-sm":p==="large"?"text-lg":"text-base"}`,children:h})},p))})]})]}),G.jsxs("div",{className:"space-y-4",children:[G.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Chat Preferences"}),G.jsxs("div",{className:"flex items-center justify-between",children:[G.jsxs("div",{className:"flex items-center gap-2",children:[G.jsx(ug,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"}),G.jsxs("div",{children:[G.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Sound Effects"}),G.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Play sounds for notifications and events"})]})]}),G.jsx("button",{onClick:d,className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${a.soundEnabled?"bg-blue-600":"bg-gray-200 dark:bg-gray-600"}`,children:G.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${a.soundEnabled?"translate-x-6":"translate-x-1"}`})})]})]}),G.jsxs("div",{className:"space-y-2 pt-4 border-t border-gray-200 dark:border-gray-600",children:[G.jsxs("h3",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 flex items-center gap-2",children:[G.jsx(mie,{className:"w-4 h-4"}),"About"]}),G.jsxs("div",{className:"space-y-1",children:[G.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:["AI Chat Application v",(o==null?void 0:o.appVersion)||"1.0.0"]}),G.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:["API Package: @schmitech/chatbot-api v",(o==null?void 0:o.apiVersion)||"^0.5.3",(o==null?void 0:o.isLocalApi)&&G.jsx("span",{className:"ml-1 px-1.5 py-0.5 bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 rounded text-xs font-medium",children:"Local"})]}),G.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Built with React, TypeScript, and Tailwind CSS"})]})]})]})]})})}function PVe(){const[e,t]=E.useState(!1),[r,n]=E.useState(!1);return G.jsx(Qae,{children:G.jsx(eie,{children:G.jsxs("div",{className:"min-h-screen flex flex-col md:flex-row bg-white dark:bg-[#212121] text-slate-900 dark:text-slate-100",children:[G.jsx("div",{className:"hidden md:flex md:min-h-screen",children:G.jsx(UU,{})}),G.jsx("div",{className:"flex-1 flex justify-center w-full",children:G.jsx(RVe,{onOpenSettings:()=>t(!0),onOpenSidebar:()=>n(!0)})}),G.jsx(LVe,{isOpen:e,onClose:()=>t(!1)}),r&&G.jsxs("div",{className:"fixed inset-0 z-50 flex md:hidden",children:[G.jsx("div",{className:"absolute inset-0 bg-black/60",onClick:()=>n(!1),"aria-hidden":"true"}),G.jsxs("div",{className:"relative z-10 h-full w-[min(18rem,85vw)]",children:[G.jsx(UU,{onRequestClose:()=>n(!1)}),G.jsx("button",{onClick:()=>n(!1),className:"absolute -right-3 top-3 rounded-full bg-white/90 p-2 text-gray-600 shadow dark:bg-[#2d2f39] dark:text-[#ececf1]","aria-label":"Close menu",children:G.jsx(Xc,{className:"h-4 w-4"})})]})]})]})})})}mte().then(e=>{mt(`📱 App Version: v${e.appVersion}`),mt(`📦 API Package: @schmitech/chatbot-api v${e.apiVersion}`),mt(`🔧 API Mode: ${e.isLocalApi?"Local":"NPM Package"}`)});tG(document.getElementById("root")).render(G.jsx(E.StrictMode,{children:G.jsx(PVe,{})}));export{CAe as $,kwe as A,_we as B,Swe as C,wAe as D,d8e as E,Oi as F,k0 as G,Ng as H,bAe as I,LZ as J,F7e as K,SAe as L,kAe as M,vAe as N,It as O,ha as P,$_e as Q,xAe as R,l9 as S,f2e as T,kh as U,qVe as V,ZP as W,M_ as X,D2e as Y,z_e as Z,Lr as _,Ug as a,UVe as a$,N_ as a0,fu as a1,Og as a2,cK as a3,Ga as a4,v5e as a5,g_ as a6,sK as a7,wh as a8,FVe as a9,VY as aA,F8e as aB,K_ as aC,HY as aD,$8e as aE,nEe as aF,Hke as aG,Ch as aH,cg as aI,vl as aJ,WVe as aK,_h as aL,_t as aM,Ot as aN,EAe as aO,j_ as aP,v0 as aQ,XK as aR,Mg as aS,BD as aT,FD as aU,mo as aV,$Ve as aW,BVe as aX,zVe as aY,jVe as aZ,HVe as a_,Zi as aa,NAe as ab,dZ as ac,n9 as ad,k_ as ae,g_e as af,qr as ag,$_ as ah,Sb as ai,c_e as aj,Bo as ak,E_ as al,GVe as am,vF as an,x_e as ao,L_e as ap,cEe as aq,uEe as ar,rEe as as,jg as at,Ob as au,dEe as av,qY as aw,Ab as ax,nc as ay,hEe as az,M_e as b,Ut as b0,Fo as b1,K8e as b2,LEe as b3,Kke as b4,au as b5,Y_ as b6,Gke as b7,Xke as b8,$0 as b9,U8e as ba,Wke as bb,Vke as bc,sF as bd,Th as be,kk as bf,Kl as bg,Fg as bh,j0 as bi,zY as bj,zg as bk,Z_ as bl,rF as bm,Ah as bn,r8e as bo,o7 as bp,FY as bq,V_e as br,l2e as bs,xE as bt,A_e as c,Eh as d,tY as e,VVe as f,a_e as g,yi as h,oK as i,yAe as j,hAe as k,sY as l,D_e as m,XP as n,up as o,e9 as p,TK as q,p2e as r,W_ as s,UK as t,pp as u,tZ as v,P_ as w,bb as x,Ewe as y,y0 as z};