@jait/gateway 0.1.477 → 0.1.478

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 (65) hide show
  1. package/dist/services/git.d.ts +9 -0
  2. package/dist/services/git.d.ts.map +1 -1
  3. package/dist/services/git.js +19 -4
  4. package/dist/services/git.js.map +1 -1
  5. package/dist/tools/homeassistant-tools.d.ts +18 -0
  6. package/dist/tools/homeassistant-tools.d.ts.map +1 -0
  7. package/dist/tools/homeassistant-tools.js +210 -0
  8. package/dist/tools/homeassistant-tools.js.map +1 -0
  9. package/package.json +1 -1
  10. package/web-dist/assets/{_basePickBy-BlH3VSG_.js → _basePickBy-CtzswvYr.js} +1 -1
  11. package/web-dist/assets/{_baseUniq-C76REEdE.js → _baseUniq-BV8j8R0m.js} +1 -1
  12. package/web-dist/assets/{arc-Ci7Y5-uI.js → arc-DYblKoMs.js} +1 -1
  13. package/web-dist/assets/{architectureDiagram-2XIMDMQ5-CB1I42fi.js → architectureDiagram-2XIMDMQ5-DdYS2_FZ.js} +1 -1
  14. package/web-dist/assets/{blockDiagram-WCTKOSBZ-Ck9FbYo9.js → blockDiagram-WCTKOSBZ-CHV7p7YD.js} +1 -1
  15. package/web-dist/assets/{c4Diagram-IC4MRINW-CHW6f5Qe.js → c4Diagram-IC4MRINW-DX6Shx7D.js} +1 -1
  16. package/web-dist/assets/channel-D4Mqh1zG.js +1 -0
  17. package/web-dist/assets/{chunk-4BX2VUAB-BRGmnck_.js → chunk-4BX2VUAB-CYUKMj7j.js} +1 -1
  18. package/web-dist/assets/{chunk-55IACEB6-rETTuU6z.js → chunk-55IACEB6-C_pAOqtV.js} +1 -1
  19. package/web-dist/assets/{chunk-FMBD7UC4-DktgxKPB.js → chunk-FMBD7UC4-CIZqHR5k.js} +1 -1
  20. package/web-dist/assets/{chunk-JSJVCQXG-Dfliu4AK.js → chunk-JSJVCQXG-DYHQrpzJ.js} +1 -1
  21. package/web-dist/assets/{chunk-KX2RTZJC-S3sGjO49.js → chunk-KX2RTZJC-BgqsEdiW.js} +1 -1
  22. package/web-dist/assets/{chunk-NQ4KR5QH-DHscTcf9.js → chunk-NQ4KR5QH-D2WvBqlM.js} +1 -1
  23. package/web-dist/assets/{chunk-QZHKN3VN-B-4VzoBj.js → chunk-QZHKN3VN-DQicMYR9.js} +1 -1
  24. package/web-dist/assets/{chunk-WL4C6EOR-DZWybiNk.js → chunk-WL4C6EOR-By7qDLjO.js} +1 -1
  25. package/web-dist/assets/classDiagram-VBA2DB6C-6vAu_D6k.js +1 -0
  26. package/web-dist/assets/classDiagram-v2-RAHNMMFH-6vAu_D6k.js +1 -0
  27. package/web-dist/assets/clone-VFeIDFpO.js +1 -0
  28. package/web-dist/assets/{cose-bilkent-S5V4N54A-B9xY0Kqy.js → cose-bilkent-S5V4N54A-CAb2XzjW.js} +1 -1
  29. package/web-dist/assets/{dagre-KLK3FWXG-DvVqKE-N.js → dagre-KLK3FWXG-DIu0KirA.js} +1 -1
  30. package/web-dist/assets/{diagram-E7M64L7V-BFxtLr_J.js → diagram-E7M64L7V-CuPAALFE.js} +1 -1
  31. package/web-dist/assets/{diagram-IFDJBPK2-9oSdzt-l.js → diagram-IFDJBPK2-BsEbvT5C.js} +1 -1
  32. package/web-dist/assets/{diagram-P4PSJMXO-CnefTtmg.js → diagram-P4PSJMXO-DQbRSXfR.js} +1 -1
  33. package/web-dist/assets/{erDiagram-INFDFZHY-B_jfKATM.js → erDiagram-INFDFZHY-B6cJ6aKk.js} +1 -1
  34. package/web-dist/assets/{flowDiagram-PKNHOUZH-H0hHU5_y.js → flowDiagram-PKNHOUZH-DnKunoWE.js} +1 -1
  35. package/web-dist/assets/{ganttDiagram-A5KZAMGK-DvgDjtyk.js → ganttDiagram-A5KZAMGK-BR7KrsV2.js} +1 -1
  36. package/web-dist/assets/{gitGraphDiagram-K3NZZRJ6-CfKN67ux.js → gitGraphDiagram-K3NZZRJ6-C-ErQxYo.js} +1 -1
  37. package/web-dist/assets/{graph-QTTPZYmF.js → graph-D7YxCgKd.js} +1 -1
  38. package/web-dist/assets/{index-nl08IRlA.css → index-CMhCaoMH.css} +1 -1
  39. package/web-dist/assets/{index-B2KqDTs1.js → index-CiiwCpdd.js} +1 -1
  40. package/web-dist/assets/{index-DDA9TJcJ.js → index-D633QnFF.js} +5 -5
  41. package/web-dist/assets/{index-B7NGRcGF.js → index-XVcTRbqO.js} +1 -1
  42. package/web-dist/assets/{infoDiagram-LFFYTUFH-DfbwpZJy.js → infoDiagram-LFFYTUFH-CbKsgryz.js} +1 -1
  43. package/web-dist/assets/{ishikawaDiagram-PHBUUO56-DFAbvEqY.js → ishikawaDiagram-PHBUUO56-BnvFJhGI.js} +1 -1
  44. package/web-dist/assets/{journeyDiagram-4ABVD52K-D7_IzKwt.js → journeyDiagram-4ABVD52K-DUD5gNjq.js} +1 -1
  45. package/web-dist/assets/{kanban-definition-K7BYSVSG-ZHQe-znY.js → kanban-definition-K7BYSVSG-DXzciomb.js} +1 -1
  46. package/web-dist/assets/{layout-CMZdvQRl.js → layout-C9r4P4eW.js} +1 -1
  47. package/web-dist/assets/{linear-B-QauWje.js → linear-BAVnYIxH.js} +1 -1
  48. package/web-dist/assets/{mindmap-definition-YRQLILUH-ivr0jipJ.js → mindmap-definition-YRQLILUH-DXQhtB98.js} +1 -1
  49. package/web-dist/assets/{pieDiagram-SKSYHLDU-BocSJCkn.js → pieDiagram-SKSYHLDU-BZwj0of8.js} +1 -1
  50. package/web-dist/assets/{quadrantDiagram-337W2JSQ-CPufpGVV.js → quadrantDiagram-337W2JSQ-ClIxI022.js} +1 -1
  51. package/web-dist/assets/{requirementDiagram-Z7DCOOCP-WXSlOcDd.js → requirementDiagram-Z7DCOOCP-IFfsBq00.js} +1 -1
  52. package/web-dist/assets/{sankeyDiagram-WA2Y5GQK-BlMmJCU5.js → sankeyDiagram-WA2Y5GQK-an0KnQCU.js} +1 -1
  53. package/web-dist/assets/{sequenceDiagram-2WXFIKYE-D6tIU8do.js → sequenceDiagram-2WXFIKYE-B_luBYr6.js} +1 -1
  54. package/web-dist/assets/{stateDiagram-RAJIS63D-DiKyETyd.js → stateDiagram-RAJIS63D-D-WYrcjl.js} +1 -1
  55. package/web-dist/assets/stateDiagram-v2-FVOUBMTO-B2ATdc9J.js +1 -0
  56. package/web-dist/assets/{timeline-definition-YZTLITO2-0HBRmTgM.js → timeline-definition-YZTLITO2-CqnYRrYr.js} +1 -1
  57. package/web-dist/assets/{treemap-KZPCXAKY-DNlJvzbh.js → treemap-KZPCXAKY-OjDH3ivT.js} +1 -1
  58. package/web-dist/assets/{vennDiagram-LZ73GAT5-CttEpptN.js → vennDiagram-LZ73GAT5-DL7r5f3I.js} +1 -1
  59. package/web-dist/assets/{xychartDiagram-JWTSCODW-BlqNihqM.js → xychartDiagram-JWTSCODW-ClidW0sx.js} +1 -1
  60. package/web-dist/index.html +2 -2
  61. package/web-dist/assets/channel-BnjEy0x0.js +0 -1
  62. package/web-dist/assets/classDiagram-VBA2DB6C-BMhQiG2d.js +0 -1
  63. package/web-dist/assets/classDiagram-v2-RAHNMMFH-BMhQiG2d.js +0 -1
  64. package/web-dist/assets/clone-Dvn132Py.js +0 -1
  65. package/web-dist/assets/stateDiagram-v2-FVOUBMTO-CwYz7g9Z.js +0 -1
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./angular-html-DA-rfuFy.js","./html-pp8916En.js","./javascript-wDzz0qaB.js","./css-CLj8gQPS.js","./angular-ts-BrjP3tb8.js","./scss-D5BDwBP9.js","./astro-HNnZUWAn.js","./json-Cp-IABpG.js","./typescript-BPQ3VLAy.js","./postcss-CXtECtnM.js","./tsx-COt5Ahok.js","./blade-BjGOyj-B.js","./html-derivative-DlHx6ybY.js","./xml-sdJ4AIDG.js","./java-CylS5w8V.js","./sql-BLtJtn59.js","./coffee-Ch7k5sss.js","./cpp-CofmeUqb.js","./regexp-CDVJQ6XC.js","./glsl-DplSGwfg.js","./c-BIGW1oBm.js","./graphql-ChdNCCLP.js","./jsx-g9-lgVsj.js","./haml-D5jkg6IW.js","./handlebars-BpdQsYii.js","./yaml-Buea-lGh.js","./http-jrhK8wxY.js","./shellscript-Yzrsuije.js","./hurl-irOxFIW8.js","./csv-fuZLfV_i.js","./jinja-f2NsQr07.js","./jison-wvAkD_A8.js","./julia-CxzCAyBv.js","./python-B6aJPvgy.js","./r-Dspwwk_N.js","./marko-DjSrsDqO.js","./less-B1dDrJ26.js","./mdc-DTYItulj.js","./markdown-Cvjx9yec.js","./php-R6g_5hLQ.js","./pug-DKIMFp6K.js","./svelte-Cy7k_4gC.js","./ts-tags-DQrlYJgV.js","./vue-D2xRrEX4.js","./vue-html-AaS7Mt5G.js","./vue-vine-BoDAl6tE.js","./stylus-BEDo0Tqx.js","./dagre-KLK3FWXG-DvVqKE-N.js","./graph-QTTPZYmF.js","./_baseUniq-C76REEdE.js","./layout-CMZdvQRl.js","./_basePickBy-BlH3VSG_.js","./clone-Dvn132Py.js","./cose-bilkent-S5V4N54A-B9xY0Kqy.js","./cytoscape.esm-BQaXIfA_.js","./c4Diagram-IC4MRINW-CHW6f5Qe.js","./chunk-JSJVCQXG-Dfliu4AK.js","./flowDiagram-PKNHOUZH-H0hHU5_y.js","./chunk-FMBD7UC4-DktgxKPB.js","./chunk-55IACEB6-rETTuU6z.js","./chunk-KX2RTZJC-S3sGjO49.js","./channel-BnjEy0x0.js","./erDiagram-INFDFZHY-B_jfKATM.js","./gitGraphDiagram-K3NZZRJ6-CfKN67ux.js","./chunk-4BX2VUAB-BRGmnck_.js","./chunk-QZHKN3VN-B-4VzoBj.js","./treemap-KZPCXAKY-DNlJvzbh.js","./ganttDiagram-A5KZAMGK-DvgDjtyk.js","./linear-B-QauWje.js","./defaultLocale-DX6XiGOO.js","./infoDiagram-LFFYTUFH-DfbwpZJy.js","./pieDiagram-SKSYHLDU-BocSJCkn.js","./arc-Ci7Y5-uI.js","./quadrantDiagram-337W2JSQ-CPufpGVV.js","./xychartDiagram-JWTSCODW-BlqNihqM.js","./requirementDiagram-Z7DCOOCP-WXSlOcDd.js","./sequenceDiagram-2WXFIKYE-D6tIU8do.js","./classDiagram-VBA2DB6C-BMhQiG2d.js","./chunk-WL4C6EOR-DZWybiNk.js","./classDiagram-v2-RAHNMMFH-BMhQiG2d.js","./stateDiagram-RAJIS63D-DiKyETyd.js","./chunk-NQ4KR5QH-DHscTcf9.js","./stateDiagram-v2-FVOUBMTO-CwYz7g9Z.js","./journeyDiagram-4ABVD52K-D7_IzKwt.js","./timeline-definition-YZTLITO2-0HBRmTgM.js","./mindmap-definition-YRQLILUH-ivr0jipJ.js","./kanban-definition-K7BYSVSG-ZHQe-znY.js","./diagram-P4PSJMXO-CnefTtmg.js","./diagram-IFDJBPK2-9oSdzt-l.js","./blockDiagram-WCTKOSBZ-Ck9FbYo9.js","./architectureDiagram-2XIMDMQ5-CB1I42fi.js","./diagram-E7M64L7V-BFxtLr_J.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./angular-html-DA-rfuFy.js","./html-pp8916En.js","./javascript-wDzz0qaB.js","./css-CLj8gQPS.js","./angular-ts-BrjP3tb8.js","./scss-D5BDwBP9.js","./astro-HNnZUWAn.js","./json-Cp-IABpG.js","./typescript-BPQ3VLAy.js","./postcss-CXtECtnM.js","./tsx-COt5Ahok.js","./blade-BjGOyj-B.js","./html-derivative-DlHx6ybY.js","./xml-sdJ4AIDG.js","./java-CylS5w8V.js","./sql-BLtJtn59.js","./coffee-Ch7k5sss.js","./cpp-CofmeUqb.js","./regexp-CDVJQ6XC.js","./glsl-DplSGwfg.js","./c-BIGW1oBm.js","./graphql-ChdNCCLP.js","./jsx-g9-lgVsj.js","./haml-D5jkg6IW.js","./handlebars-BpdQsYii.js","./yaml-Buea-lGh.js","./http-jrhK8wxY.js","./shellscript-Yzrsuije.js","./hurl-irOxFIW8.js","./csv-fuZLfV_i.js","./jinja-f2NsQr07.js","./jison-wvAkD_A8.js","./julia-CxzCAyBv.js","./python-B6aJPvgy.js","./r-Dspwwk_N.js","./marko-DjSrsDqO.js","./less-B1dDrJ26.js","./mdc-DTYItulj.js","./markdown-Cvjx9yec.js","./php-R6g_5hLQ.js","./pug-DKIMFp6K.js","./svelte-Cy7k_4gC.js","./ts-tags-DQrlYJgV.js","./vue-D2xRrEX4.js","./vue-html-AaS7Mt5G.js","./vue-vine-BoDAl6tE.js","./stylus-BEDo0Tqx.js","./dagre-KLK3FWXG-DIu0KirA.js","./graph-D7YxCgKd.js","./_baseUniq-BV8j8R0m.js","./layout-C9r4P4eW.js","./_basePickBy-CtzswvYr.js","./clone-VFeIDFpO.js","./cose-bilkent-S5V4N54A-CAb2XzjW.js","./cytoscape.esm-BQaXIfA_.js","./c4Diagram-IC4MRINW-DX6Shx7D.js","./chunk-JSJVCQXG-DYHQrpzJ.js","./flowDiagram-PKNHOUZH-DnKunoWE.js","./chunk-FMBD7UC4-CIZqHR5k.js","./chunk-55IACEB6-C_pAOqtV.js","./chunk-KX2RTZJC-BgqsEdiW.js","./channel-D4Mqh1zG.js","./erDiagram-INFDFZHY-B6cJ6aKk.js","./gitGraphDiagram-K3NZZRJ6-C-ErQxYo.js","./chunk-4BX2VUAB-CYUKMj7j.js","./chunk-QZHKN3VN-DQicMYR9.js","./treemap-KZPCXAKY-OjDH3ivT.js","./ganttDiagram-A5KZAMGK-BR7KrsV2.js","./linear-BAVnYIxH.js","./defaultLocale-DX6XiGOO.js","./infoDiagram-LFFYTUFH-CbKsgryz.js","./pieDiagram-SKSYHLDU-BZwj0of8.js","./arc-DYblKoMs.js","./quadrantDiagram-337W2JSQ-ClIxI022.js","./xychartDiagram-JWTSCODW-ClidW0sx.js","./requirementDiagram-Z7DCOOCP-IFfsBq00.js","./sequenceDiagram-2WXFIKYE-B_luBYr6.js","./classDiagram-VBA2DB6C-6vAu_D6k.js","./chunk-WL4C6EOR-By7qDLjO.js","./classDiagram-v2-RAHNMMFH-6vAu_D6k.js","./stateDiagram-RAJIS63D-D-WYrcjl.js","./chunk-NQ4KR5QH-D2WvBqlM.js","./stateDiagram-v2-FVOUBMTO-B2ATdc9J.js","./journeyDiagram-4ABVD52K-DUD5gNjq.js","./timeline-definition-YZTLITO2-CqnYRrYr.js","./mindmap-definition-YRQLILUH-DXQhtB98.js","./kanban-definition-K7BYSVSG-DXzciomb.js","./diagram-P4PSJMXO-DQbRSXfR.js","./diagram-IFDJBPK2-BsEbvT5C.js","./blockDiagram-WCTKOSBZ-CHV7p7YD.js","./architectureDiagram-2XIMDMQ5-DdYS2_FZ.js","./diagram-E7M64L7V-CuPAALFE.js"])))=>i.map(i=>d[i]);
2
2
  var Rfe=Object.defineProperty;var Pfe=(e,r,n)=>r in e?Rfe(e,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[r]=n;var Ge=(e,r,n)=>Pfe(e,typeof r!="symbol"?r+"":r,n);function Lfe(e,r){for(var n=0;n<r.length;n++){const i=r[n];if(typeof i!="string"&&!Array.isArray(i)){for(const s in i)if(s!=="default"&&!(s in e)){const o=Object.getOwnPropertyDescriptor(i,s);o&&Object.defineProperty(e,s,o.get?o:{enumerable:!0,get:()=>i[s]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(s);new MutationObserver(s=>{for(const o of s)if(o.type==="childList")for(const a of o.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&i(a)}).observe(document,{childList:!0,subtree:!0});function n(s){const o={};return s.integrity&&(o.integrity=s.integrity),s.referrerPolicy&&(o.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?o.credentials="include":s.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function i(s){if(s.ep)return;s.ep=!0;const o=n(s);fetch(s.href,o)}})();function my(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Qvt(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var r=e.default;if(typeof r=="function"){var n=function i(){return this instanceof i?Reflect.construct(r,arguments,this.constructor):r.apply(this,arguments)};n.prototype=r.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(i){var s=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(n,i,s.get?s:{enumerable:!0,get:function(){return e[i]}})}),n}var G6={exports:{}},wb={};/**
3
3
  * @license React
4
4
  * react-jsx-runtime.production.js
@@ -922,7 +922,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
922
922
  monaco.config({ paths: { vs: '...' } })
923
923
 
924
924
  For more please check the link https://github.com/suren-atoyan/monaco-loader#config
925
- `},lF=_$e(C$e)(Gee),j$e={config:S$e},N$e=function(){for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];return function(s){return n.reduceRight(function(o,a){return a(o)},s)}};function Kee(e,r){return Object.keys(r).forEach(function(n){r[n]instanceof Object&&e[n]&&Object.assign(r[n],Kee(e[n],r[n]))}),sF(sF({},e),r)}var T$e={type:"cancelation",msg:"operation is manually canceled"};function ME(e){var r=!1,n=new Promise(function(i,s){e.then(function(o){return r?s(T$e):i(o)}),e.catch(s)});return n.cancel=function(){return r=!0},n}var E$e=["monaco"],A$e=x$e.create({config:b$e,isInitialized:!1,resolve:null,reject:null,monaco:null}),Yee=t$e(A$e,2),nk=Yee[0],bN=Yee[1];function O$e(e){var r=j$e.config(e),n=r.monaco,i=QLe(r,E$e);bN(function(s){return{config:Kee(s.config,i),monaco:n}})}function M$e(){var e=nk(function(r){var n=r.monaco,i=r.isInitialized,s=r.resolve;return{monaco:n,isInitialized:i,resolve:s}});if(!e.isInitialized){if(bN({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),ME(RE);if(window.monaco&&window.monaco.editor)return Xee(window.monaco),e.resolve(window.monaco),ME(RE);N$e(R$e,L$e)($$e)}return ME(RE)}function R$e(e){return document.body.appendChild(e)}function P$e(e){var r=document.createElement("script");return e&&(r.src=e),r}function L$e(e){var r=nk(function(i){var s=i.config,o=i.reject;return{config:s,reject:o}}),n=P$e("".concat(r.config.paths.vs,"/loader.js"));return n.onload=function(){return e()},n.onerror=r.reject,n}function $$e(){var e=nk(function(n){var i=n.config,s=n.resolve,o=n.reject;return{config:i,resolve:s,reject:o}}),r=window.require;r.config(e.config),r(["vs/editor/editor.main"],function(n){var i=n.m||n;Xee(i),e.resolve(i)},function(n){e.reject(n)})}function Xee(e){nk().monaco||bN({monaco:e})}function D$e(){return nk(function(e){var r=e.monaco;return r})}var RE=new Promise(function(e,r){return bN({resolve:e,reject:r})}),_N={config:O$e,init:M$e,__getMonacoInstance:D$e};const Jee=Object.freeze(JSON.parse('{"colors":{"actionBar.toggledBackground":"#383a49","activityBarBadge.background":"#007ACC","checkbox.border":"#6B6B6B","editor.background":"#1E1E1E","editor.foreground":"#D4D4D4","editor.inactiveSelectionBackground":"#3A3D41","editor.selectionHighlightBackground":"#ADD6FF26","editorIndentGuide.activeBackground1":"#707070","editorIndentGuide.background1":"#404040","input.placeholderForeground":"#A6A6A6","list.activeSelectionIconForeground":"#FFF","list.dropBackground":"#383B3D","menu.background":"#252526","menu.border":"#454545","menu.foreground":"#CCCCCC","menu.selectionBackground":"#0078d4","menu.separatorBackground":"#454545","ports.iconRunningProcessForeground":"#369432","sideBarSectionHeader.background":"#0000","sideBarSectionHeader.border":"#ccc3","sideBarTitle.foreground":"#BBBBBB","statusBarItem.remoteBackground":"#16825D","statusBarItem.remoteForeground":"#FFF","tab.lastPinnedBorder":"#ccc3","tab.selectedBackground":"#222222","tab.selectedForeground":"#ffffffa0","terminal.inactiveSelectionBackground":"#3A3D41","widget.border":"#303031"},"displayName":"Dark Plus","name":"dark-plus","semanticHighlighting":true,"semanticTokenColors":{"customLiteral":"#DCDCAA","newOperator":"#C586C0","numberLiteral":"#b5cea8","stringLiteral":"#ce9178"},"tokenColors":[{"scope":["meta.embedded","source.groovy.embedded","string meta.image.inline.markdown","variable.legacy.builtin.python"],"settings":{"foreground":"#D4D4D4"}},{"scope":"emphasis","settings":{"fontStyle":"italic"}},{"scope":"strong","settings":{"fontStyle":"bold"}},{"scope":"header","settings":{"foreground":"#000080"}},{"scope":"comment","settings":{"foreground":"#6A9955"}},{"scope":"constant.language","settings":{"foreground":"#569cd6"}},{"scope":["constant.numeric","variable.other.enummember","keyword.operator.plus.exponent","keyword.operator.minus.exponent"],"settings":{"foreground":"#b5cea8"}},{"scope":"constant.regexp","settings":{"foreground":"#646695"}},{"scope":"entity.name.tag","settings":{"foreground":"#569cd6"}},{"scope":["entity.name.tag.css","entity.name.tag.less"],"settings":{"foreground":"#d7ba7d"}},{"scope":"entity.other.attribute-name","settings":{"foreground":"#9cdcfe"}},{"scope":["entity.other.attribute-name.class.css","source.css entity.other.attribute-name.class","entity.other.attribute-name.id.css","entity.other.attribute-name.parent-selector.css","entity.other.attribute-name.parent.less","source.css entity.other.attribute-name.pseudo-class","entity.other.attribute-name.pseudo-element.css","source.css.less entity.other.attribute-name.id","entity.other.attribute-name.scss"],"settings":{"foreground":"#d7ba7d"}},{"scope":"invalid","settings":{"foreground":"#f44747"}},{"scope":"markup.underline","settings":{"fontStyle":"underline"}},{"scope":"markup.bold","settings":{"fontStyle":"bold","foreground":"#569cd6"}},{"scope":"markup.heading","settings":{"fontStyle":"bold","foreground":"#569cd6"}},{"scope":"markup.italic","settings":{"fontStyle":"italic"}},{"scope":"markup.strikethrough","settings":{"fontStyle":"strikethrough"}},{"scope":"markup.inserted","settings":{"foreground":"#b5cea8"}},{"scope":"markup.deleted","settings":{"foreground":"#ce9178"}},{"scope":"markup.changed","settings":{"foreground":"#569cd6"}},{"scope":"punctuation.definition.quote.begin.markdown","settings":{"foreground":"#6A9955"}},{"scope":"punctuation.definition.list.begin.markdown","settings":{"foreground":"#6796e6"}},{"scope":"markup.inline.raw","settings":{"foreground":"#ce9178"}},{"scope":"punctuation.definition.tag","settings":{"foreground":"#808080"}},{"scope":["meta.preprocessor","entity.name.function.preprocessor"],"settings":{"foreground":"#569cd6"}},{"scope":"meta.preprocessor.string","settings":{"foreground":"#ce9178"}},{"scope":"meta.preprocessor.numeric","settings":{"foreground":"#b5cea8"}},{"scope":"meta.structure.dictionary.key.python","settings":{"foreground":"#9cdcfe"}},{"scope":"meta.diff.header","settings":{"foreground":"#569cd6"}},{"scope":"storage","settings":{"foreground":"#569cd6"}},{"scope":"storage.type","settings":{"foreground":"#569cd6"}},{"scope":["storage.modifier","keyword.operator.noexcept"],"settings":{"foreground":"#569cd6"}},{"scope":["string","meta.embedded.assembly"],"settings":{"foreground":"#ce9178"}},{"scope":"string.tag","settings":{"foreground":"#ce9178"}},{"scope":"string.value","settings":{"foreground":"#ce9178"}},{"scope":"string.regexp","settings":{"foreground":"#d16969"}},{"scope":["punctuation.definition.template-expression.begin","punctuation.definition.template-expression.end","punctuation.section.embedded"],"settings":{"foreground":"#569cd6"}},{"scope":["meta.template.expression"],"settings":{"foreground":"#d4d4d4"}},{"scope":["support.type.vendored.property-name","support.type.property-name","source.css variable","source.coffee.embedded"],"settings":{"foreground":"#9cdcfe"}},{"scope":"keyword","settings":{"foreground":"#569cd6"}},{"scope":"keyword.control","settings":{"foreground":"#569cd6"}},{"scope":"keyword.operator","settings":{"foreground":"#d4d4d4"}},{"scope":["keyword.operator.new","keyword.operator.expression","keyword.operator.cast","keyword.operator.sizeof","keyword.operator.alignof","keyword.operator.typeid","keyword.operator.alignas","keyword.operator.instanceof","keyword.operator.logical.python","keyword.operator.wordlike"],"settings":{"foreground":"#569cd6"}},{"scope":"keyword.other.unit","settings":{"foreground":"#b5cea8"}},{"scope":["punctuation.section.embedded.begin.php","punctuation.section.embedded.end.php"],"settings":{"foreground":"#569cd6"}},{"scope":"support.function.git-rebase","settings":{"foreground":"#9cdcfe"}},{"scope":"constant.sha.git-rebase","settings":{"foreground":"#b5cea8"}},{"scope":["storage.modifier.import.java","variable.language.wildcard.java","storage.modifier.package.java"],"settings":{"foreground":"#d4d4d4"}},{"scope":"variable.language","settings":{"foreground":"#569cd6"}},{"scope":["entity.name.function","support.function","support.constant.handlebars","source.powershell variable.other.member","entity.name.operator.custom-literal"],"settings":{"foreground":"#DCDCAA"}},{"scope":["support.class","support.type","entity.name.type","entity.name.namespace","entity.other.attribute","entity.name.scope-resolution","entity.name.class","storage.type.numeric.go","storage.type.byte.go","storage.type.boolean.go","storage.type.string.go","storage.type.uintptr.go","storage.type.error.go","storage.type.rune.go","storage.type.cs","storage.type.generic.cs","storage.type.modifier.cs","storage.type.variable.cs","storage.type.annotation.java","storage.type.generic.java","storage.type.java","storage.type.object.array.java","storage.type.primitive.array.java","storage.type.primitive.java","storage.type.token.java","storage.type.groovy","storage.type.annotation.groovy","storage.type.parameters.groovy","storage.type.generic.groovy","storage.type.object.array.groovy","storage.type.primitive.array.groovy","storage.type.primitive.groovy"],"settings":{"foreground":"#4EC9B0"}},{"scope":["meta.type.cast.expr","meta.type.new.expr","support.constant.math","support.constant.dom","support.constant.json","entity.other.inherited-class","punctuation.separator.namespace.ruby"],"settings":{"foreground":"#4EC9B0"}},{"scope":["keyword.control","source.cpp keyword.operator.new","keyword.operator.delete","keyword.other.using","keyword.other.directive.using","keyword.other.operator","entity.name.operator"],"settings":{"foreground":"#C586C0"}},{"scope":["variable","meta.definition.variable.name","support.variable","entity.name.variable","constant.other.placeholder"],"settings":{"foreground":"#9CDCFE"}},{"scope":["variable.other.constant","variable.other.enummember"],"settings":{"foreground":"#4FC1FF"}},{"scope":["meta.object-literal.key"],"settings":{"foreground":"#9CDCFE"}},{"scope":["support.constant.property-value","support.constant.font-name","support.constant.media-type","support.constant.media","constant.other.color.rgb-value","constant.other.rgb-value","support.constant.color"],"settings":{"foreground":"#CE9178"}},{"scope":["punctuation.definition.group.regexp","punctuation.definition.group.assertion.regexp","punctuation.definition.character-class.regexp","punctuation.character.set.begin.regexp","punctuation.character.set.end.regexp","keyword.operator.negation.regexp","support.other.parenthesis.regexp"],"settings":{"foreground":"#CE9178"}},{"scope":["constant.character.character-class.regexp","constant.other.character-class.set.regexp","constant.other.character-class.regexp","constant.character.set.regexp"],"settings":{"foreground":"#d16969"}},{"scope":["keyword.operator.or.regexp","keyword.control.anchor.regexp"],"settings":{"foreground":"#DCDCAA"}},{"scope":"keyword.operator.quantifier.regexp","settings":{"foreground":"#d7ba7d"}},{"scope":["constant.character","constant.other.option"],"settings":{"foreground":"#569cd6"}},{"scope":"constant.character.escape","settings":{"foreground":"#d7ba7d"}},{"scope":"entity.name.label","settings":{"foreground":"#C8C8C8"}}],"type":"dark"}')),I$e=Object.freeze(Object.defineProperty({__proto__:null,default:Jee},Symbol.toStringTag,{value:"Module"})),B$e=["editor theme","vscode theme","monaco theme","workbench colors"],PE=new Set,$w="dark-plus",cF=new WeakSet,uF=Jee,z$e={"editor.background":"#0B0C0E","editorGutter.background":"#0B0C0E","editorStickyScroll.background":"#0B0C0E","editorStickyScrollGutter.background":"#0B0C0E","minimap.background":"#0B0C0E","editor.lineHighlightBackground":"#151922","editorWidget.background":"#16181D","editorHoverWidget.background":"#16181D","editorWidget.border":"#363B44","editorHoverWidget.border":"#363B44","editorGroupHeader.tabsBackground":"#0B0C0E"},F$e={base:"vs-dark",inherit:!1,rules:[...Qee(uF.tokenColors??[]),...K$e()],colors:{...ete(uF.colors??{}),...z$e}};function H$e(){return B$e}function Zee(e){var r,n;(n=(r=e==null?void 0:e.editor)==null?void 0:r.defineTheme)==null||n.call(r,$w,F$e)}function W$e(e){!e||typeof e!="object"||cF.has(e)||(cF.add(e),Promise.all([nt(()=>import("./index-B7NGRcGF.js"),[],import.meta.url),nt(()=>import("./index-B2KqDTs1.js"),[],import.meta.url)]).then(async([{shikiToMonaco:r},{createHighlighter:n}])=>{var l,u,d;const i=e.languages,s=new Set(((l=i==null?void 0:i.getLanguages)==null?void 0:l.call(i).map(h=>h.id))??[]);for(const h of["javascript","typescript","json","css","html","markdown","python","yaml","diff"])s.has(h)||((u=i==null?void 0:i.register)==null||u.call(i,{id:h}),s.add(h));const o=await n({themes:["dark-plus"],langs:["javascript","typescript","jsx","tsx","json","css","html","markdown","python","yaml","diff"]});r(o,e),Zee(e);const a=e.editor;typeof document<"u"&&document.documentElement.dataset.monacoTheme===$w&&((d=a==null?void 0:a.setTheme)==null||d.call(a,$w))}).catch(r=>{console.error("Failed to initialize Shiki Monaco Dark Plus theme:",r)}))}function U$e(e){var a;const r=V$e(e.text),n=ete(r.colors??{}),i=X$e(r,n),s=((a=r.name)==null?void 0:a.trim())||e.sourceLabel.trim()||"Imported Theme",o=`jait-vscode-${nDe(s)}-${e.id}`;return{id:e.id,name:s,sourceLabel:e.sourceLabel,importedAt:e.importedAt??new Date().toISOString(),colorMode:i,monacoThemeName:o,monacoThemeData:{base:i==="dark"?"vs-dark":"vs",inherit:!0,rules:Qee(r.tokenColors??[]),colors:n},cssVariables:Y$e(n),rawColors:n,hasInclude:typeof r.include=="string"&&r.include.trim().length>0}}function V$e(e){const r=rDe(tDe(e)),n=JSON.parse(r);if(!n||typeof n!="object"||Array.isArray(n))throw new Error("Theme file must contain a JSON object.");return n}function q$e(e,r){var n;!r||!((n=e==null?void 0:e.editor)!=null&&n.defineTheme)||e.editor.defineTheme(r.monacoThemeName,r.monacoThemeData)}function G$e(e){if(typeof document>"u")return;const r=document.documentElement;r.classList.toggle("dark",e.colorMode==="dark"),r.dataset.monacoTheme=e.monacoThemeName;for(const n of PE)r.style.removeProperty(n);if(PE.clear(),!!e.theme)for(const[n,i]of Object.entries(e.theme.cssVariables))r.style.setProperty(n,i),PE.add(n)}function Qee(e){var n;const r=[];for(const i of e){const s=i.settings??{},o=J$e(i.scope);if(o.length===0)continue;const a=hF(s.foreground),l=hF(s.background),u=((n=s.fontStyle)==null?void 0:n.trim())||void 0;for(const d of o)r.push({token:d,foreground:a,background:l,fontStyle:u})}return r}function K$e(){return[{token:"",foreground:"D4D4D4",background:"1E1E1E"},{token:"invalid",foreground:"F44747"},{token:"emphasis",fontStyle:"italic"},{token:"strong",fontStyle:"bold"},{token:"comment",foreground:"6A9955"},{token:"constant",foreground:"569CD6"},{token:"number",foreground:"B5CEA8"},{token:"regexp",foreground:"D16969"},{token:"string",foreground:"CE9178"},{token:"string.key.json",foreground:"9CDCFE"},{token:"string.value.json",foreground:"CE9178"},{token:"keyword",foreground:"569CD6"},{token:"keyword.flow",foreground:"C586C0"},{token:"keyword.operator",foreground:"D4D4D4"},{token:"keyword.operator.new",foreground:"C586C0"},{token:"operator",foreground:"D4D4D4"},{token:"type",foreground:"4EC9B0"},{token:"type.identifier",foreground:"4EC9B0"},{token:"class",foreground:"4EC9B0"},{token:"interface",foreground:"4EC9B0"},{token:"enum",foreground:"4EC9B0"},{token:"namespace",foreground:"4EC9B0"},{token:"identifier",foreground:"9CDCFE"},{token:"identifier.function",foreground:"DCDCAA"},{token:"function",foreground:"DCDCAA"},{token:"member",foreground:"DCDCAA"},{token:"method",foreground:"DCDCAA"},{token:"property",foreground:"9CDCFE"},{token:"variable",foreground:"9CDCFE"},{token:"variable.parameter",foreground:"9CDCFE"},{token:"parameter",foreground:"9CDCFE"},{token:"delimiter",foreground:"D4D4D4"},{token:"delimiter.html",foreground:"808080"},{token:"delimiter.xml",foreground:"808080"},{token:"tag",foreground:"569CD6"},{token:"attribute.name",foreground:"9CDCFE"},{token:"attribute.value",foreground:"CE9178"}]}function Y$e(e){const r={},n=oi(e,["editor.background","sideBar.background","panel.background"]),i=oi(e,["editor.foreground","foreground"]),s=oi(e,["sideBar.background","panel.background","editorWidget.background"]),o=oi(e,["panel.background","tab.inactiveBackground","editorGroupHeader.tabsBackground"]),a=oi(e,["list.hoverBackground","tab.activeBackground","editor.lineHighlightBackground"]),l=oi(e,["button.background","focusBorder","textLink.foreground"]),u=oi(e,["widget.border","panel.border","sideBar.border","contrastBorder"]);Ei(r,"--background",n),Ei(r,"--foreground",i),Ei(r,"--card",s),Ei(r,"--card-foreground",oi(e,["sideBar.foreground","foreground"])??i),Ei(r,"--popover",oi(e,["editorWidget.background","panel.background"])??s),Ei(r,"--popover-foreground",oi(e,["editorWidget.foreground","foreground"])??i),Ei(r,"--primary",l),Ei(r,"--primary-foreground",dF(l)),Ei(r,"--secondary",oi(e,["tab.inactiveBackground","panel.background"])??o),Ei(r,"--secondary-foreground",oi(e,["tab.inactiveForeground","foreground"])??i),Ei(r,"--muted",o),Ei(r,"--muted-foreground",oi(e,["descriptionForeground","input.placeholderForeground","disabledForeground"])),Ei(r,"--accent",a),Ei(r,"--accent-foreground",oi(e,["list.activeSelectionForeground","foreground"])??i),Ei(r,"--destructive",oi(e,["inputValidation.errorBackground","errorForeground","list.errorForeground"])),Ei(r,"--destructive-foreground",dF(oi(e,["inputValidation.errorBackground","errorForeground"]))),Ei(r,"--border",u),Ei(r,"--input",oi(e,["input.background","editorWidget.background","dropdown.background"])??u),Ei(r,"--ring",oi(e,["focusBorder","button.background","textLink.foreground"])??l),Ei(r,"--scrollbar-track",oi(e,["editor.background","sideBar.background","panel.background"])??n),Ei(r,"--scrollbar-thumb",oi(e,["scrollbarSlider.background","scrollbar.shadow"])),Ei(r,"--scrollbar-thumb-hover",oi(e,["scrollbarSlider.hoverBackground","scrollbarSlider.activeBackground","scrollbarSlider.background"])),Ei(r,"--toast-bg",oi(e,["notifications.background","editorWidget.background","panel.background"])??s,!0),Ei(r,"--toast-border",oi(e,["notifications.border","widget.border","panel.border"])??u,!0),Ei(r,"--toast-success-accent",oi(e,["testing.iconPassed","terminal.ansiGreen"])),Ei(r,"--toast-info-accent",oi(e,["textLink.foreground","focusBorder"])??l),Ei(r,"--toast-warning-accent",oi(e,["editorWarning.foreground","terminal.ansiYellow"])),Ei(r,"--toast-error-accent",oi(e,["editorError.foreground","terminal.ansiRed"]));const d=oi(e,["editorGroupHeader.tabsBackground","tab.inactiveBackground","sideBar.background"]);d&&(r["--tab-bg"]=d);const h=oi(e,["activityBarBadge.background","button.background","focusBorder"]),f=oi(e,["textLink.foreground","terminal.ansiBlue"]),g=oi(e,["editorWarning.foreground","terminal.ansiYellow"]),v=oi(e,["terminal.ansiMagenta","badge.background"]);return h&&(r["--ctx-system"]=h),f&&(r["--ctx-history"]=f),g&&(r["--ctx-tool-results"]=g),v&&(r["--ctx-tools"]=v),r}function Ei(e,r,n,i=!1){if(!n)return;const s=Z$e(n,i);s&&(e[r]=s)}function dF(e){const r=U9(e);return r?(.2126*r.r+.7152*r.g+.0722*r.b)/255>.55?"0 0% 7%":"0 0% 100%":null}function X$e(e,r){if(e.type==="light"||e.type==="hc-light")return"light";if(e.type==="dark"||e.type==="hc-dark")return"dark";const n=U9(r["editor.background"]??r["sideBar.background"]??"");return n&&(.2126*n.r+.7152*n.g+.0722*n.b)/255>.55?"light":"dark"}function ete(e){const r={};for(const[n,i]of Object.entries(e))typeof i=="string"&&i.trim()&&(r[n]=i.trim());return r}function J$e(e){return Array.isArray(e)?e.flatMap(r=>r.split(",")).map(r=>r.trim()).filter(Boolean):typeof e!="string"?[]:e.split(",").map(r=>r.trim()).filter(Boolean)}function hF(e){if(!e)return;const r=e.trim();if(r.startsWith("#"))return tte(r).slice(1)}function oi(e,r){for(const n of r){const i=e[n];if(typeof i=="string"&&i.trim())return i.trim()}return null}function Z$e(e,r=!1){const n=U9(e);if(!n)return null;const i=n.r/255,s=n.g/255,o=n.b/255,a=Math.max(i,s,o),l=Math.min(i,s,o),u=a-l,d=(a+l)/2;let h=0;u!==0&&(a===i?h=(s-o)/u%6:a===s?h=(o-i)/u+2:h=(i-s)/u+4,h*=60),h<0&&(h+=360);const f=u===0?0:u/(1-Math.abs(2*d-1)),g=`${Math.round(h)} ${Math.round(f*100)}% ${Math.round(d*100)}%`;return r&&n.a<1?`${g} / ${Number(n.a.toFixed(3))}`:g}function U9(e){if(!e)return null;const r=e.trim();if(!r)return null;if(r.startsWith("#"))return Q$e(r);const n=r.match(/^rgba?\(([^)]+)\)$/i);if(!n)return null;const i=n[1].split(",").map(u=>u.trim());if(i.length<3)return null;const s=LE(i[0]),o=LE(i[1]),a=LE(i[2]),l=i[3]==null?1:eDe(i[3]);return s==null||o==null||a==null||l==null?null:{r:s,g:o,b:a,a:l}}function Q$e(e){const r=tte(e).slice(1);return r.length===6?{r:Number.parseInt(r.slice(0,2),16),g:Number.parseInt(r.slice(2,4),16),b:Number.parseInt(r.slice(4,6),16),a:1}:r.length===8?{r:Number.parseInt(r.slice(0,2),16),g:Number.parseInt(r.slice(2,4),16),b:Number.parseInt(r.slice(4,6),16),a:Number.parseInt(r.slice(6,8),16)/255}:null}function LE(e){if(e.endsWith("%")){const n=Number.parseFloat(e.slice(0,-1));return Number.isFinite(n)?fF(Math.round(n/100*255)):null}const r=Number.parseFloat(e);return Number.isFinite(r)?fF(Math.round(r)):null}function eDe(e){const r=Number.parseFloat(e);return Number.isFinite(r)?Math.max(0,Math.min(1,r)):null}function fF(e){return Math.max(0,Math.min(255,e))}function tte(e){const r=e.trim().slice(1);return r.length===3||r.length===4?`#${r.split("").map(n=>`${n}${n}`).join("").toLowerCase()}`:`#${r.toLowerCase()}`}function tDe(e){let r="",n=!1,i=!1,s=!1,o=!1;for(let a=0;a<e.length;a+=1){const l=e[a],u=e[a+1];if(i){l===`
925
+ `},lF=_$e(C$e)(Gee),j$e={config:S$e},N$e=function(){for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];return function(s){return n.reduceRight(function(o,a){return a(o)},s)}};function Kee(e,r){return Object.keys(r).forEach(function(n){r[n]instanceof Object&&e[n]&&Object.assign(r[n],Kee(e[n],r[n]))}),sF(sF({},e),r)}var T$e={type:"cancelation",msg:"operation is manually canceled"};function ME(e){var r=!1,n=new Promise(function(i,s){e.then(function(o){return r?s(T$e):i(o)}),e.catch(s)});return n.cancel=function(){return r=!0},n}var E$e=["monaco"],A$e=x$e.create({config:b$e,isInitialized:!1,resolve:null,reject:null,monaco:null}),Yee=t$e(A$e,2),nk=Yee[0],bN=Yee[1];function O$e(e){var r=j$e.config(e),n=r.monaco,i=QLe(r,E$e);bN(function(s){return{config:Kee(s.config,i),monaco:n}})}function M$e(){var e=nk(function(r){var n=r.monaco,i=r.isInitialized,s=r.resolve;return{monaco:n,isInitialized:i,resolve:s}});if(!e.isInitialized){if(bN({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),ME(RE);if(window.monaco&&window.monaco.editor)return Xee(window.monaco),e.resolve(window.monaco),ME(RE);N$e(R$e,L$e)($$e)}return ME(RE)}function R$e(e){return document.body.appendChild(e)}function P$e(e){var r=document.createElement("script");return e&&(r.src=e),r}function L$e(e){var r=nk(function(i){var s=i.config,o=i.reject;return{config:s,reject:o}}),n=P$e("".concat(r.config.paths.vs,"/loader.js"));return n.onload=function(){return e()},n.onerror=r.reject,n}function $$e(){var e=nk(function(n){var i=n.config,s=n.resolve,o=n.reject;return{config:i,resolve:s,reject:o}}),r=window.require;r.config(e.config),r(["vs/editor/editor.main"],function(n){var i=n.m||n;Xee(i),e.resolve(i)},function(n){e.reject(n)})}function Xee(e){nk().monaco||bN({monaco:e})}function D$e(){return nk(function(e){var r=e.monaco;return r})}var RE=new Promise(function(e,r){return bN({resolve:e,reject:r})}),_N={config:O$e,init:M$e,__getMonacoInstance:D$e};const Jee=Object.freeze(JSON.parse('{"colors":{"actionBar.toggledBackground":"#383a49","activityBarBadge.background":"#007ACC","checkbox.border":"#6B6B6B","editor.background":"#1E1E1E","editor.foreground":"#D4D4D4","editor.inactiveSelectionBackground":"#3A3D41","editor.selectionHighlightBackground":"#ADD6FF26","editorIndentGuide.activeBackground1":"#707070","editorIndentGuide.background1":"#404040","input.placeholderForeground":"#A6A6A6","list.activeSelectionIconForeground":"#FFF","list.dropBackground":"#383B3D","menu.background":"#252526","menu.border":"#454545","menu.foreground":"#CCCCCC","menu.selectionBackground":"#0078d4","menu.separatorBackground":"#454545","ports.iconRunningProcessForeground":"#369432","sideBarSectionHeader.background":"#0000","sideBarSectionHeader.border":"#ccc3","sideBarTitle.foreground":"#BBBBBB","statusBarItem.remoteBackground":"#16825D","statusBarItem.remoteForeground":"#FFF","tab.lastPinnedBorder":"#ccc3","tab.selectedBackground":"#222222","tab.selectedForeground":"#ffffffa0","terminal.inactiveSelectionBackground":"#3A3D41","widget.border":"#303031"},"displayName":"Dark Plus","name":"dark-plus","semanticHighlighting":true,"semanticTokenColors":{"customLiteral":"#DCDCAA","newOperator":"#C586C0","numberLiteral":"#b5cea8","stringLiteral":"#ce9178"},"tokenColors":[{"scope":["meta.embedded","source.groovy.embedded","string meta.image.inline.markdown","variable.legacy.builtin.python"],"settings":{"foreground":"#D4D4D4"}},{"scope":"emphasis","settings":{"fontStyle":"italic"}},{"scope":"strong","settings":{"fontStyle":"bold"}},{"scope":"header","settings":{"foreground":"#000080"}},{"scope":"comment","settings":{"foreground":"#6A9955"}},{"scope":"constant.language","settings":{"foreground":"#569cd6"}},{"scope":["constant.numeric","variable.other.enummember","keyword.operator.plus.exponent","keyword.operator.minus.exponent"],"settings":{"foreground":"#b5cea8"}},{"scope":"constant.regexp","settings":{"foreground":"#646695"}},{"scope":"entity.name.tag","settings":{"foreground":"#569cd6"}},{"scope":["entity.name.tag.css","entity.name.tag.less"],"settings":{"foreground":"#d7ba7d"}},{"scope":"entity.other.attribute-name","settings":{"foreground":"#9cdcfe"}},{"scope":["entity.other.attribute-name.class.css","source.css entity.other.attribute-name.class","entity.other.attribute-name.id.css","entity.other.attribute-name.parent-selector.css","entity.other.attribute-name.parent.less","source.css entity.other.attribute-name.pseudo-class","entity.other.attribute-name.pseudo-element.css","source.css.less entity.other.attribute-name.id","entity.other.attribute-name.scss"],"settings":{"foreground":"#d7ba7d"}},{"scope":"invalid","settings":{"foreground":"#f44747"}},{"scope":"markup.underline","settings":{"fontStyle":"underline"}},{"scope":"markup.bold","settings":{"fontStyle":"bold","foreground":"#569cd6"}},{"scope":"markup.heading","settings":{"fontStyle":"bold","foreground":"#569cd6"}},{"scope":"markup.italic","settings":{"fontStyle":"italic"}},{"scope":"markup.strikethrough","settings":{"fontStyle":"strikethrough"}},{"scope":"markup.inserted","settings":{"foreground":"#b5cea8"}},{"scope":"markup.deleted","settings":{"foreground":"#ce9178"}},{"scope":"markup.changed","settings":{"foreground":"#569cd6"}},{"scope":"punctuation.definition.quote.begin.markdown","settings":{"foreground":"#6A9955"}},{"scope":"punctuation.definition.list.begin.markdown","settings":{"foreground":"#6796e6"}},{"scope":"markup.inline.raw","settings":{"foreground":"#ce9178"}},{"scope":"punctuation.definition.tag","settings":{"foreground":"#808080"}},{"scope":["meta.preprocessor","entity.name.function.preprocessor"],"settings":{"foreground":"#569cd6"}},{"scope":"meta.preprocessor.string","settings":{"foreground":"#ce9178"}},{"scope":"meta.preprocessor.numeric","settings":{"foreground":"#b5cea8"}},{"scope":"meta.structure.dictionary.key.python","settings":{"foreground":"#9cdcfe"}},{"scope":"meta.diff.header","settings":{"foreground":"#569cd6"}},{"scope":"storage","settings":{"foreground":"#569cd6"}},{"scope":"storage.type","settings":{"foreground":"#569cd6"}},{"scope":["storage.modifier","keyword.operator.noexcept"],"settings":{"foreground":"#569cd6"}},{"scope":["string","meta.embedded.assembly"],"settings":{"foreground":"#ce9178"}},{"scope":"string.tag","settings":{"foreground":"#ce9178"}},{"scope":"string.value","settings":{"foreground":"#ce9178"}},{"scope":"string.regexp","settings":{"foreground":"#d16969"}},{"scope":["punctuation.definition.template-expression.begin","punctuation.definition.template-expression.end","punctuation.section.embedded"],"settings":{"foreground":"#569cd6"}},{"scope":["meta.template.expression"],"settings":{"foreground":"#d4d4d4"}},{"scope":["support.type.vendored.property-name","support.type.property-name","source.css variable","source.coffee.embedded"],"settings":{"foreground":"#9cdcfe"}},{"scope":"keyword","settings":{"foreground":"#569cd6"}},{"scope":"keyword.control","settings":{"foreground":"#569cd6"}},{"scope":"keyword.operator","settings":{"foreground":"#d4d4d4"}},{"scope":["keyword.operator.new","keyword.operator.expression","keyword.operator.cast","keyword.operator.sizeof","keyword.operator.alignof","keyword.operator.typeid","keyword.operator.alignas","keyword.operator.instanceof","keyword.operator.logical.python","keyword.operator.wordlike"],"settings":{"foreground":"#569cd6"}},{"scope":"keyword.other.unit","settings":{"foreground":"#b5cea8"}},{"scope":["punctuation.section.embedded.begin.php","punctuation.section.embedded.end.php"],"settings":{"foreground":"#569cd6"}},{"scope":"support.function.git-rebase","settings":{"foreground":"#9cdcfe"}},{"scope":"constant.sha.git-rebase","settings":{"foreground":"#b5cea8"}},{"scope":["storage.modifier.import.java","variable.language.wildcard.java","storage.modifier.package.java"],"settings":{"foreground":"#d4d4d4"}},{"scope":"variable.language","settings":{"foreground":"#569cd6"}},{"scope":["entity.name.function","support.function","support.constant.handlebars","source.powershell variable.other.member","entity.name.operator.custom-literal"],"settings":{"foreground":"#DCDCAA"}},{"scope":["support.class","support.type","entity.name.type","entity.name.namespace","entity.other.attribute","entity.name.scope-resolution","entity.name.class","storage.type.numeric.go","storage.type.byte.go","storage.type.boolean.go","storage.type.string.go","storage.type.uintptr.go","storage.type.error.go","storage.type.rune.go","storage.type.cs","storage.type.generic.cs","storage.type.modifier.cs","storage.type.variable.cs","storage.type.annotation.java","storage.type.generic.java","storage.type.java","storage.type.object.array.java","storage.type.primitive.array.java","storage.type.primitive.java","storage.type.token.java","storage.type.groovy","storage.type.annotation.groovy","storage.type.parameters.groovy","storage.type.generic.groovy","storage.type.object.array.groovy","storage.type.primitive.array.groovy","storage.type.primitive.groovy"],"settings":{"foreground":"#4EC9B0"}},{"scope":["meta.type.cast.expr","meta.type.new.expr","support.constant.math","support.constant.dom","support.constant.json","entity.other.inherited-class","punctuation.separator.namespace.ruby"],"settings":{"foreground":"#4EC9B0"}},{"scope":["keyword.control","source.cpp keyword.operator.new","keyword.operator.delete","keyword.other.using","keyword.other.directive.using","keyword.other.operator","entity.name.operator"],"settings":{"foreground":"#C586C0"}},{"scope":["variable","meta.definition.variable.name","support.variable","entity.name.variable","constant.other.placeholder"],"settings":{"foreground":"#9CDCFE"}},{"scope":["variable.other.constant","variable.other.enummember"],"settings":{"foreground":"#4FC1FF"}},{"scope":["meta.object-literal.key"],"settings":{"foreground":"#9CDCFE"}},{"scope":["support.constant.property-value","support.constant.font-name","support.constant.media-type","support.constant.media","constant.other.color.rgb-value","constant.other.rgb-value","support.constant.color"],"settings":{"foreground":"#CE9178"}},{"scope":["punctuation.definition.group.regexp","punctuation.definition.group.assertion.regexp","punctuation.definition.character-class.regexp","punctuation.character.set.begin.regexp","punctuation.character.set.end.regexp","keyword.operator.negation.regexp","support.other.parenthesis.regexp"],"settings":{"foreground":"#CE9178"}},{"scope":["constant.character.character-class.regexp","constant.other.character-class.set.regexp","constant.other.character-class.regexp","constant.character.set.regexp"],"settings":{"foreground":"#d16969"}},{"scope":["keyword.operator.or.regexp","keyword.control.anchor.regexp"],"settings":{"foreground":"#DCDCAA"}},{"scope":"keyword.operator.quantifier.regexp","settings":{"foreground":"#d7ba7d"}},{"scope":["constant.character","constant.other.option"],"settings":{"foreground":"#569cd6"}},{"scope":"constant.character.escape","settings":{"foreground":"#d7ba7d"}},{"scope":"entity.name.label","settings":{"foreground":"#C8C8C8"}}],"type":"dark"}')),I$e=Object.freeze(Object.defineProperty({__proto__:null,default:Jee},Symbol.toStringTag,{value:"Module"})),B$e=["editor theme","vscode theme","monaco theme","workbench colors"],PE=new Set,$w="dark-plus",cF=new WeakSet,uF=Jee,z$e={"editor.background":"#0B0C0E","editorGutter.background":"#0B0C0E","editorStickyScroll.background":"#0B0C0E","editorStickyScrollGutter.background":"#0B0C0E","minimap.background":"#0B0C0E","editor.lineHighlightBackground":"#151922","editorWidget.background":"#16181D","editorHoverWidget.background":"#16181D","editorWidget.border":"#363B44","editorHoverWidget.border":"#363B44","editorGroupHeader.tabsBackground":"#0B0C0E"},F$e={base:"vs-dark",inherit:!1,rules:[...Qee(uF.tokenColors??[]),...K$e()],colors:{...ete(uF.colors??{}),...z$e}};function H$e(){return B$e}function Zee(e){var r,n;(n=(r=e==null?void 0:e.editor)==null?void 0:r.defineTheme)==null||n.call(r,$w,F$e)}function W$e(e){!e||typeof e!="object"||cF.has(e)||(cF.add(e),Promise.all([nt(()=>import("./index-XVcTRbqO.js"),[],import.meta.url),nt(()=>import("./index-CiiwCpdd.js"),[],import.meta.url)]).then(async([{shikiToMonaco:r},{createHighlighter:n}])=>{var l,u,d;const i=e.languages,s=new Set(((l=i==null?void 0:i.getLanguages)==null?void 0:l.call(i).map(h=>h.id))??[]);for(const h of["javascript","typescript","json","css","html","markdown","python","yaml","diff"])s.has(h)||((u=i==null?void 0:i.register)==null||u.call(i,{id:h}),s.add(h));const o=await n({themes:["dark-plus"],langs:["javascript","typescript","jsx","tsx","json","css","html","markdown","python","yaml","diff"]});r(o,e),Zee(e);const a=e.editor;typeof document<"u"&&document.documentElement.dataset.monacoTheme===$w&&((d=a==null?void 0:a.setTheme)==null||d.call(a,$w))}).catch(r=>{console.error("Failed to initialize Shiki Monaco Dark Plus theme:",r)}))}function U$e(e){var a;const r=V$e(e.text),n=ete(r.colors??{}),i=X$e(r,n),s=((a=r.name)==null?void 0:a.trim())||e.sourceLabel.trim()||"Imported Theme",o=`jait-vscode-${nDe(s)}-${e.id}`;return{id:e.id,name:s,sourceLabel:e.sourceLabel,importedAt:e.importedAt??new Date().toISOString(),colorMode:i,monacoThemeName:o,monacoThemeData:{base:i==="dark"?"vs-dark":"vs",inherit:!0,rules:Qee(r.tokenColors??[]),colors:n},cssVariables:Y$e(n),rawColors:n,hasInclude:typeof r.include=="string"&&r.include.trim().length>0}}function V$e(e){const r=rDe(tDe(e)),n=JSON.parse(r);if(!n||typeof n!="object"||Array.isArray(n))throw new Error("Theme file must contain a JSON object.");return n}function q$e(e,r){var n;!r||!((n=e==null?void 0:e.editor)!=null&&n.defineTheme)||e.editor.defineTheme(r.monacoThemeName,r.monacoThemeData)}function G$e(e){if(typeof document>"u")return;const r=document.documentElement;r.classList.toggle("dark",e.colorMode==="dark"),r.dataset.monacoTheme=e.monacoThemeName;for(const n of PE)r.style.removeProperty(n);if(PE.clear(),!!e.theme)for(const[n,i]of Object.entries(e.theme.cssVariables))r.style.setProperty(n,i),PE.add(n)}function Qee(e){var n;const r=[];for(const i of e){const s=i.settings??{},o=J$e(i.scope);if(o.length===0)continue;const a=hF(s.foreground),l=hF(s.background),u=((n=s.fontStyle)==null?void 0:n.trim())||void 0;for(const d of o)r.push({token:d,foreground:a,background:l,fontStyle:u})}return r}function K$e(){return[{token:"",foreground:"D4D4D4",background:"1E1E1E"},{token:"invalid",foreground:"F44747"},{token:"emphasis",fontStyle:"italic"},{token:"strong",fontStyle:"bold"},{token:"comment",foreground:"6A9955"},{token:"constant",foreground:"569CD6"},{token:"number",foreground:"B5CEA8"},{token:"regexp",foreground:"D16969"},{token:"string",foreground:"CE9178"},{token:"string.key.json",foreground:"9CDCFE"},{token:"string.value.json",foreground:"CE9178"},{token:"keyword",foreground:"569CD6"},{token:"keyword.flow",foreground:"C586C0"},{token:"keyword.operator",foreground:"D4D4D4"},{token:"keyword.operator.new",foreground:"C586C0"},{token:"operator",foreground:"D4D4D4"},{token:"type",foreground:"4EC9B0"},{token:"type.identifier",foreground:"4EC9B0"},{token:"class",foreground:"4EC9B0"},{token:"interface",foreground:"4EC9B0"},{token:"enum",foreground:"4EC9B0"},{token:"namespace",foreground:"4EC9B0"},{token:"identifier",foreground:"9CDCFE"},{token:"identifier.function",foreground:"DCDCAA"},{token:"function",foreground:"DCDCAA"},{token:"member",foreground:"DCDCAA"},{token:"method",foreground:"DCDCAA"},{token:"property",foreground:"9CDCFE"},{token:"variable",foreground:"9CDCFE"},{token:"variable.parameter",foreground:"9CDCFE"},{token:"parameter",foreground:"9CDCFE"},{token:"delimiter",foreground:"D4D4D4"},{token:"delimiter.html",foreground:"808080"},{token:"delimiter.xml",foreground:"808080"},{token:"tag",foreground:"569CD6"},{token:"attribute.name",foreground:"9CDCFE"},{token:"attribute.value",foreground:"CE9178"}]}function Y$e(e){const r={},n=oi(e,["editor.background","sideBar.background","panel.background"]),i=oi(e,["editor.foreground","foreground"]),s=oi(e,["sideBar.background","panel.background","editorWidget.background"]),o=oi(e,["panel.background","tab.inactiveBackground","editorGroupHeader.tabsBackground"]),a=oi(e,["list.hoverBackground","tab.activeBackground","editor.lineHighlightBackground"]),l=oi(e,["button.background","focusBorder","textLink.foreground"]),u=oi(e,["widget.border","panel.border","sideBar.border","contrastBorder"]);Ei(r,"--background",n),Ei(r,"--foreground",i),Ei(r,"--card",s),Ei(r,"--card-foreground",oi(e,["sideBar.foreground","foreground"])??i),Ei(r,"--popover",oi(e,["editorWidget.background","panel.background"])??s),Ei(r,"--popover-foreground",oi(e,["editorWidget.foreground","foreground"])??i),Ei(r,"--primary",l),Ei(r,"--primary-foreground",dF(l)),Ei(r,"--secondary",oi(e,["tab.inactiveBackground","panel.background"])??o),Ei(r,"--secondary-foreground",oi(e,["tab.inactiveForeground","foreground"])??i),Ei(r,"--muted",o),Ei(r,"--muted-foreground",oi(e,["descriptionForeground","input.placeholderForeground","disabledForeground"])),Ei(r,"--accent",a),Ei(r,"--accent-foreground",oi(e,["list.activeSelectionForeground","foreground"])??i),Ei(r,"--destructive",oi(e,["inputValidation.errorBackground","errorForeground","list.errorForeground"])),Ei(r,"--destructive-foreground",dF(oi(e,["inputValidation.errorBackground","errorForeground"]))),Ei(r,"--border",u),Ei(r,"--input",oi(e,["input.background","editorWidget.background","dropdown.background"])??u),Ei(r,"--ring",oi(e,["focusBorder","button.background","textLink.foreground"])??l),Ei(r,"--scrollbar-track",oi(e,["editor.background","sideBar.background","panel.background"])??n),Ei(r,"--scrollbar-thumb",oi(e,["scrollbarSlider.background","scrollbar.shadow"])),Ei(r,"--scrollbar-thumb-hover",oi(e,["scrollbarSlider.hoverBackground","scrollbarSlider.activeBackground","scrollbarSlider.background"])),Ei(r,"--toast-bg",oi(e,["notifications.background","editorWidget.background","panel.background"])??s,!0),Ei(r,"--toast-border",oi(e,["notifications.border","widget.border","panel.border"])??u,!0),Ei(r,"--toast-success-accent",oi(e,["testing.iconPassed","terminal.ansiGreen"])),Ei(r,"--toast-info-accent",oi(e,["textLink.foreground","focusBorder"])??l),Ei(r,"--toast-warning-accent",oi(e,["editorWarning.foreground","terminal.ansiYellow"])),Ei(r,"--toast-error-accent",oi(e,["editorError.foreground","terminal.ansiRed"]));const d=oi(e,["editorGroupHeader.tabsBackground","tab.inactiveBackground","sideBar.background"]);d&&(r["--tab-bg"]=d);const h=oi(e,["activityBarBadge.background","button.background","focusBorder"]),f=oi(e,["textLink.foreground","terminal.ansiBlue"]),g=oi(e,["editorWarning.foreground","terminal.ansiYellow"]),v=oi(e,["terminal.ansiMagenta","badge.background"]);return h&&(r["--ctx-system"]=h),f&&(r["--ctx-history"]=f),g&&(r["--ctx-tool-results"]=g),v&&(r["--ctx-tools"]=v),r}function Ei(e,r,n,i=!1){if(!n)return;const s=Z$e(n,i);s&&(e[r]=s)}function dF(e){const r=U9(e);return r?(.2126*r.r+.7152*r.g+.0722*r.b)/255>.55?"0 0% 7%":"0 0% 100%":null}function X$e(e,r){if(e.type==="light"||e.type==="hc-light")return"light";if(e.type==="dark"||e.type==="hc-dark")return"dark";const n=U9(r["editor.background"]??r["sideBar.background"]??"");return n&&(.2126*n.r+.7152*n.g+.0722*n.b)/255>.55?"light":"dark"}function ete(e){const r={};for(const[n,i]of Object.entries(e))typeof i=="string"&&i.trim()&&(r[n]=i.trim());return r}function J$e(e){return Array.isArray(e)?e.flatMap(r=>r.split(",")).map(r=>r.trim()).filter(Boolean):typeof e!="string"?[]:e.split(",").map(r=>r.trim()).filter(Boolean)}function hF(e){if(!e)return;const r=e.trim();if(r.startsWith("#"))return tte(r).slice(1)}function oi(e,r){for(const n of r){const i=e[n];if(typeof i=="string"&&i.trim())return i.trim()}return null}function Z$e(e,r=!1){const n=U9(e);if(!n)return null;const i=n.r/255,s=n.g/255,o=n.b/255,a=Math.max(i,s,o),l=Math.min(i,s,o),u=a-l,d=(a+l)/2;let h=0;u!==0&&(a===i?h=(s-o)/u%6:a===s?h=(o-i)/u+2:h=(i-s)/u+4,h*=60),h<0&&(h+=360);const f=u===0?0:u/(1-Math.abs(2*d-1)),g=`${Math.round(h)} ${Math.round(f*100)}% ${Math.round(d*100)}%`;return r&&n.a<1?`${g} / ${Number(n.a.toFixed(3))}`:g}function U9(e){if(!e)return null;const r=e.trim();if(!r)return null;if(r.startsWith("#"))return Q$e(r);const n=r.match(/^rgba?\(([^)]+)\)$/i);if(!n)return null;const i=n[1].split(",").map(u=>u.trim());if(i.length<3)return null;const s=LE(i[0]),o=LE(i[1]),a=LE(i[2]),l=i[3]==null?1:eDe(i[3]);return s==null||o==null||a==null||l==null?null:{r:s,g:o,b:a,a:l}}function Q$e(e){const r=tte(e).slice(1);return r.length===6?{r:Number.parseInt(r.slice(0,2),16),g:Number.parseInt(r.slice(2,4),16),b:Number.parseInt(r.slice(4,6),16),a:1}:r.length===8?{r:Number.parseInt(r.slice(0,2),16),g:Number.parseInt(r.slice(2,4),16),b:Number.parseInt(r.slice(4,6),16),a:Number.parseInt(r.slice(6,8),16)/255}:null}function LE(e){if(e.endsWith("%")){const n=Number.parseFloat(e.slice(0,-1));return Number.isFinite(n)?fF(Math.round(n/100*255)):null}const r=Number.parseFloat(e);return Number.isFinite(r)?fF(Math.round(r)):null}function eDe(e){const r=Number.parseFloat(e);return Number.isFinite(r)?Math.max(0,Math.min(1,r)):null}function fF(e){return Math.max(0,Math.min(255,e))}function tte(e){const r=e.trim().slice(1);return r.length===3||r.length===4?`#${r.split("").map(n=>`${n}${n}`).join("").toLowerCase()}`:`#${r.toLowerCase()}`}function tDe(e){let r="",n=!1,i=!1,s=!1,o=!1;for(let a=0;a<e.length;a+=1){const l=e[a],u=e[a+1];if(i){l===`
926
926
  `&&(i=!1,r+=l);continue}if(s){l==="*"&&u==="/"&&(s=!1,a+=1);continue}if(n){r+=l,o?o=!1:l==="\\"?o=!0:l==='"'&&(n=!1);continue}if(l==='"'){n=!0,r+=l;continue}if(l==="/"&&u==="/"){i=!0,a+=1;continue}if(l==="/"&&u==="*"){s=!0,a+=1;continue}r+=l}return r}function rDe(e){return e.replace(/,\s*([}\]])/g,"$1")}function nDe(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40)||"theme"}function pF(){if(typeof document>"u")return"vs";const e=document.documentElement;return e.dataset.monacoTheme??(e.classList.contains("dark")?$w:"vs")}function ik(){const[e,r]=y.useState(pF);return y.useEffect(()=>{if(typeof document>"u")return;const n=document.documentElement,i=()=>r(pF());i();const s=new MutationObserver(i);return s.observe(n,{attributes:!0,attributeFilter:["class","data-monaco-theme"]}),()=>s.disconnect()},[]),e}const V9="jait:vscode-theme-store",o5=new Set;let Qd=nte(),mF=!1;function rte(){if(typeof window>"u")return null;try{return window.localStorage}catch{return null}}function nte(){const e=rte();if(!e)return{importedThemes:[],activeThemeId:null};let r=null;try{r=e.getItem(V9)}catch{return{importedThemes:[],activeThemeId:null}}if(!r)return{importedThemes:[],activeThemeId:null};try{const n=JSON.parse(r),i=Array.isArray(n.importedThemes)?n.importedThemes.filter(o=>!!(o&&typeof o.id=="string"&&typeof o.monacoThemeName=="string")):[],s=typeof n.activeThemeId=="string"?n.activeThemeId:null;return{importedThemes:i,activeThemeId:i.some(o=>o.id===s)?s:null}}catch{return{importedThemes:[],activeThemeId:null}}}function q9(e){Qd=e;const r=rte();if(r)try{r.setItem(V9,JSON.stringify(e))}catch{}for(const n of o5)n()}function iDe(e){return!mF&&typeof window<"u"&&(mF=!0,window.addEventListener("storage",r=>{if(r.key===V9){Qd=nte();for(const n of o5)n()}})),o5.add(e),()=>o5.delete(e)}function gF(){return Qd}function ite(){const e=y.useSyncExternalStore(iDe,gF,gF);return{...e,activeTheme:e.importedThemes.find(r=>r.id===e.activeThemeId)??null}}function ste(){return Qd.importedThemes.find(e=>e.id===Qd.activeThemeId)??null}function sDe(e,r){const n=`${Date.now().toString(36)}-${lDe(e+r)}`,i=U$e({id:n,sourceLabel:e,text:r});return q9({importedThemes:[...Qd.importedThemes.filter(s=>s.id!==n),i],activeThemeId:n}),i}function gj(e){q9({...Qd,activeThemeId:e&&Qd.importedThemes.some(r=>r.id===e)?e:null})}function oDe(e){q9({importedThemes:Qd.importedThemes.filter(r=>r.id!==e),activeThemeId:Qd.activeThemeId===e?null:Qd.activeThemeId})}function aDe(e){Zee(e);const r=ste();r?q$e(e,r):W$e(e)}function fc(e,r){var n,i;aDe(e),r&&((i=(n=e==null?void 0:e.editor)==null?void 0:n.setTheme)==null||i.call(n,r))}function lDe(e){let r=0;for(let n=0;n<e.length;n+=1)r=(r<<5)-r+e.charCodeAt(n)|0;return Math.abs(r).toString(36)}function C1(e,r){return Math.max(1,e||r||1)}function Dw({original:e,modified:r,language:n,modelKey:i,className:s,editorClassName:o,renderSideBySide:a=!1,emptyMessage:l="Files are identical.",options:u}){const d=y.useRef(null),h=y.useRef(null),f=y.useRef(null),g=y.useRef(null),v=y.useRef({original:null,modified:null}),[b,_]=y.useState(!1),[w,S]=y.useState([]),[C,j]=y.useState(0),E=ik(),A=y.useRef(E);y.useEffect(()=>{A.current=E},[E]);const N=y.useMemo(()=>`inmemory://jait-diff/${encodeURIComponent(i??`${n}:${e.length}:${r.length}`)}`,[n,i,r.length,e.length]),P=y.useMemo(()=>({readOnly:!0,renderSideBySide:a,minimap:{enabled:!1},"semanticHighlighting.enabled":!0,fontSize:13,automaticLayout:!0,scrollBeyondLastLine:!1,renderOverviewRuler:!0,ignoreTrimWhitespace:!1,...u}),[u,a]),H=y.useCallback(()=>{var D;const B=h.current;if(!B)return;const W=((D=B.getLineChanges)==null?void 0:D.call(B))??[];S(W.map(O=>({originalStartLineNumber:O.originalStartLineNumber,originalEndLineNumber:O.originalEndLineNumber,modifiedStartLineNumber:O.modifiedStartLineNumber,modifiedEndLineNumber:O.modifiedEndLineNumber})))},[]);y.useEffect(()=>{let B=!1;const W=_N.init();return W.then(D=>{if(B||!d.current)return;f.current=D,fc(D,A.current);const O=D.editor.createDiffEditor(d.current,{automaticLayout:!0,...P});h.current=O,g.current=O.onDidUpdateDiff(()=>H()),_(!0),H()}).catch(D=>{!B&&(D==null?void 0:D.type)!=="cancelation"&&console.error("Monaco initialization: error:",D)}),()=>{var I,R,$,U,Y,z;B=!0,(I=g.current)==null||I.dispose(),g.current=null;const D=h.current,O=v.current;try{D==null||D.setModel(null)}catch{}(R=D==null?void 0:D.dispose)==null||R.call(D),(U=($=O.original)==null?void 0:$.dispose)==null||U.call($),(z=(Y=O.modified)==null?void 0:Y.dispose)==null||z.call(Y),v.current={original:null,modified:null},h.current=null,f.current=null,_(!1),W.cancel()}},[H]),y.useEffect(()=>{j(0)},[e,r,n]),y.useEffect(()=>{var U,Y;const B=h.current,W=f.current;if(!b||!B||!W)return;const D=v.current,O=W.Uri.parse(`${N}.original`),I=W.Uri.parse(`${N}.modified`);(U=W.editor.getModel(O))==null||U.dispose(),(Y=W.editor.getModel(I))==null||Y.dispose();const R=W.editor.createModel(e,n,O),$=W.editor.createModel(r,n,I);return B.setModel({original:R,modified:$}),v.current={original:R,modified:$},H(),()=>{var z,V,Q,q;try{B.setModel(null)}catch{}(V=(z=D.original)==null?void 0:z.dispose)==null||V.call(z),(q=(Q=D.modified)==null?void 0:Q.dispose)==null||q.call(Q),R.dispose(),$.dispose(),(v.current.original===R||v.current.modified===$)&&(v.current={original:null,modified:null})}},[b,n,N,r,e,H]),y.useEffect(()=>{const B=f.current;B&&fc(B,E)},[E]),y.useEffect(()=>{var B,W;(W=(B=h.current)==null?void 0:B.updateOptions)==null||W.call(B,P)},[P]),y.useEffect(()=>{w.length!==0&&j(B=>Math.min(B,w.length-1))},[w]),y.useEffect(()=>{const B=h.current;if(!B||w.length===0)return;const W=w[C];if(!W)return;const D=B.getModifiedEditor(),O=B.getOriginalEditor();try{W.modifiedStartLineNumber>0||W.modifiedEndLineNumber>0?D.revealLineInCenter(C1(W.modifiedStartLineNumber,W.modifiedEndLineNumber)):O.revealLineInCenter(C1(W.originalStartLineNumber,W.originalEndLineNumber))}catch{}},[C,w]),y.useEffect(()=>{const B=h.current,W=f.current;if(!B||!W||w.length===0)return;const D=w[C];if(!D)return;const O=[];(D.originalStartLineNumber>0||D.originalEndLineNumber>0)&&O.push({editor:B.getOriginalEditor(),range:new W.Range(C1(D.originalStartLineNumber,D.originalEndLineNumber),1,C1(D.originalEndLineNumber,D.originalStartLineNumber),1)}),(D.modifiedStartLineNumber>0||D.modifiedEndLineNumber>0)&&O.push({editor:B.getModifiedEditor(),range:new W.Range(C1(D.modifiedStartLineNumber,D.modifiedEndLineNumber),1,C1(D.modifiedEndLineNumber,D.modifiedStartLineNumber),1)});const I=O.map(({editor:R,range:$})=>R.deltaDecorations([],[{range:$,options:{isWholeLine:!0,className:"diff-change-active"}}]));return()=>{var R;for(let $=0;$<O.length;$++)try{(R=O[$])==null||R.editor.deltaDecorations(I[$]??[],[])}catch{}}},[C,w]);const K=y.useCallback(()=>{j(B=>Math.max(B-1,0))},[]),F=y.useCallback(()=>{j(B=>Math.min(B+1,w.length-1))},[w.length]);return c.jsxs("div",{className:Ae("relative min-h-0",s),children:[c.jsx("div",{className:Ae("h-full min-h-0",o),children:c.jsx("div",{ref:d,className:"h-full min-h-0"})}),!b&&c.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-sm text-muted-foreground",children:"Loading diff..."}),w.length>1&&c.jsxs("div",{className:"absolute right-3 top-1/2 z-10 flex -translate-y-1/2 flex-col gap-1.5",children:[c.jsx(_e,{size:"sm",variant:"secondary",className:"h-9 w-9 rounded-full border bg-background/90 p-0 shadow-lg backdrop-blur-sm hover:bg-background",onClick:K,disabled:C===0,title:"Previous change",children:c.jsx(pR,{className:"h-5 w-5"})}),c.jsxs("span",{className:"text-center font-medium tabular-nums text-2xs text-muted-foreground",children:[C+1,"/",w.length]}),c.jsx(_e,{size:"sm",variant:"secondary",className:"h-9 w-9 rounded-full border bg-background/90 p-0 shadow-lg backdrop-blur-sm hover:bg-background",onClick:F,disabled:C===w.length-1,title:"Next change",children:c.jsx(Ml,{className:"h-5 w-5"})})]}),w.length===0&&e===r&&b&&c.jsx("div",{className:"pointer-events-none absolute inset-x-3 bottom-3 rounded-md border bg-background/90 px-3 py-2 text-center text-xs text-muted-foreground shadow-sm",children:l}),c.jsx("style",{children:`
927
927
  .diff-change-active { outline: 1px solid rgba(99, 102, 241, 0.5); outline-offset: -1px; }
928
928
  `})]})}var cDe={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},$E=cDe,uDe={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},dDe=uDe;function hDe({children:e}){return zt.createElement("div",{style:dDe.container},e)}var fDe=hDe,pDe=fDe;function mDe({width:e,height:r,isEditorReady:n,loading:i,_ref:s,className:o,wrapperProps:a}){return zt.createElement("section",{style:{...$E.wrapper,width:e,height:r},...a},!n&&zt.createElement(pDe,null,i),zt.createElement("div",{ref:s,style:{...$E.fullWidth,...!n&&$E.hide},className:o}))}var gDe=mDe,ote=y.memo(gDe);function yDe(e){y.useEffect(e,[])}var ate=yDe;function vDe(e,r,n=!0){let i=y.useRef(!0);y.useEffect(i.current||!n?()=>{i.current=!1}:e,r)}var Yc=vDe;function i2(){}function G1(e,r,n,i){return xDe(e,i)||bDe(e,r,n,i)}function xDe(e,r){return e.editor.getModel(lte(e,r))}function bDe(e,r,n,i){return e.editor.createModel(r,n,i?lte(e,i):void 0)}function lte(e,r){return e.Uri.parse(r)}function _De({original:e,modified:r,language:n,originalLanguage:i,modifiedLanguage:s,originalModelPath:o,modifiedModelPath:a,keepCurrentOriginalModel:l=!1,keepCurrentModifiedModel:u=!1,theme:d="light",loading:h="Loading...",options:f={},height:g="100%",width:v="100%",className:b,wrapperProps:_={},beforeMount:w=i2,onMount:S=i2}){let[C,j]=y.useState(!1),[E,A]=y.useState(!0),N=y.useRef(null),P=y.useRef(null),H=y.useRef(null),K=y.useRef(S),F=y.useRef(w),B=y.useRef(!1);ate(()=>{let I=_N.init();return I.then(R=>(P.current=R)&&A(!1)).catch(R=>(R==null?void 0:R.type)!=="cancelation"&&console.error("Monaco initialization: error:",R)),()=>N.current?O():I.cancel()}),Yc(()=>{if(N.current&&P.current){let I=N.current.getOriginalEditor(),R=G1(P.current,e||"",i||n||"text",o||"");R!==I.getModel()&&I.setModel(R)}},[o],C),Yc(()=>{if(N.current&&P.current){let I=N.current.getModifiedEditor(),R=G1(P.current,r||"",s||n||"text",a||"");R!==I.getModel()&&I.setModel(R)}},[a],C),Yc(()=>{let I=N.current.getModifiedEditor();I.getOption(P.current.editor.EditorOption.readOnly)?I.setValue(r||""):r!==I.getValue()&&(I.executeEdits("",[{range:I.getModel().getFullModelRange(),text:r||"",forceMoveMarkers:!0}]),I.pushUndoStop())},[r],C),Yc(()=>{var I,R;(R=(I=N.current)==null?void 0:I.getModel())==null||R.original.setValue(e||"")},[e],C),Yc(()=>{let{original:I,modified:R}=N.current.getModel();P.current.editor.setModelLanguage(I,i||n||"text"),P.current.editor.setModelLanguage(R,s||n||"text")},[n,i,s],C),Yc(()=>{var I;(I=P.current)==null||I.editor.setTheme(d)},[d],C),Yc(()=>{var I;(I=N.current)==null||I.updateOptions(f)},[f],C);let W=y.useCallback(()=>{var $;if(!P.current)return;F.current(P.current);let I=G1(P.current,e||"",i||n||"text",o||""),R=G1(P.current,r||"",s||n||"text",a||"");($=N.current)==null||$.setModel({original:I,modified:R})},[n,r,s,e,i,o,a]),D=y.useCallback(()=>{var I;!B.current&&H.current&&(N.current=P.current.editor.createDiffEditor(H.current,{automaticLayout:!0,...f}),W(),(I=P.current)==null||I.editor.setTheme(d),j(!0),B.current=!0)},[f,d,W]);y.useEffect(()=>{C&&K.current(N.current,P.current)},[C]),y.useEffect(()=>{!E&&!C&&D()},[E,C,D]);function O(){var R,$,U,Y;let I=(R=N.current)==null?void 0:R.getModel();l||(($=I==null?void 0:I.original)==null||$.dispose()),u||((U=I==null?void 0:I.modified)==null||U.dispose()),(Y=N.current)==null||Y.dispose()}return zt.createElement(ote,{width:v,height:g,isEditorReady:C,loading:h,_ref:H,className:b,wrapperProps:_})}var wDe=_De,SDe=y.memo(wDe);function kDe(e){let r=y.useRef();return y.useEffect(()=>{r.current=e},[e]),r.current}var CDe=kDe,JC=new Map;function jDe({defaultValue:e,defaultLanguage:r,defaultPath:n,value:i,language:s,path:o,theme:a="light",line:l,loading:u="Loading...",options:d={},overrideServices:h={},saveViewState:f=!0,keepCurrentModel:g=!1,width:v="100%",height:b="100%",className:_,wrapperProps:w={},beforeMount:S=i2,onMount:C=i2,onChange:j,onValidate:E=i2}){let[A,N]=y.useState(!1),[P,H]=y.useState(!0),K=y.useRef(null),F=y.useRef(null),B=y.useRef(null),W=y.useRef(C),D=y.useRef(S),O=y.useRef(),I=y.useRef(i),R=CDe(o),$=y.useRef(!1),U=y.useRef(!1);ate(()=>{let V=_N.init();return V.then(Q=>(K.current=Q)&&H(!1)).catch(Q=>(Q==null?void 0:Q.type)!=="cancelation"&&console.error("Monaco initialization: error:",Q)),()=>F.current?z():V.cancel()}),Yc(()=>{var Q,q,re,ee;let V=G1(K.current,e||i||"",r||s||"",o||n||"");V!==((Q=F.current)==null?void 0:Q.getModel())&&(f&&JC.set(R,(q=F.current)==null?void 0:q.saveViewState()),(re=F.current)==null||re.setModel(V),f&&((ee=F.current)==null||ee.restoreViewState(JC.get(o))))},[o],A),Yc(()=>{var V;(V=F.current)==null||V.updateOptions(d)},[d],A),Yc(()=>{!F.current||i===void 0||(F.current.getOption(K.current.editor.EditorOption.readOnly)?F.current.setValue(i):i!==F.current.getValue()&&(U.current=!0,F.current.executeEdits("",[{range:F.current.getModel().getFullModelRange(),text:i,forceMoveMarkers:!0}]),F.current.pushUndoStop(),U.current=!1))},[i],A),Yc(()=>{var Q,q;let V=(Q=F.current)==null?void 0:Q.getModel();V&&s&&((q=K.current)==null||q.editor.setModelLanguage(V,s))},[s],A),Yc(()=>{var V;l!==void 0&&((V=F.current)==null||V.revealLine(l))},[l],A),Yc(()=>{var V;(V=K.current)==null||V.editor.setTheme(a)},[a],A);let Y=y.useCallback(()=>{var V;if(!(!B.current||!K.current)&&!$.current){D.current(K.current);let Q=o||n,q=G1(K.current,i||e||"",r||s||"",Q||"");F.current=(V=K.current)==null?void 0:V.editor.create(B.current,{model:q,automaticLayout:!0,...d},h),f&&F.current.restoreViewState(JC.get(Q)),K.current.editor.setTheme(a),l!==void 0&&F.current.revealLine(l),N(!0),$.current=!0}},[e,r,n,i,s,o,d,h,f,a,l]);y.useEffect(()=>{A&&W.current(F.current,K.current)},[A]),y.useEffect(()=>{!P&&!A&&Y()},[P,A,Y]),I.current=i,y.useEffect(()=>{var V,Q;A&&j&&((V=O.current)==null||V.dispose(),O.current=(Q=F.current)==null?void 0:Q.onDidChangeModelContent(q=>{U.current||j(F.current.getValue(),q)}))},[A,j]),y.useEffect(()=>{if(A){let V=K.current.editor.onDidChangeMarkers(Q=>{var re;let q=(re=F.current.getModel())==null?void 0:re.uri;if(q&&Q.find(ee=>ee.path===q.path)){let ee=K.current.editor.getModelMarkers({resource:q});E==null||E(ee)}});return()=>{V==null||V.dispose()}}return()=>{}},[A,E]);function z(){var V,Q;(V=O.current)==null||V.dispose(),g?f&&JC.set(o,F.current.saveViewState()):(Q=F.current.getModel())==null||Q.dispose(),F.current.dispose()}return zt.createElement(ote,{width:v,height:b,isEditorReady:A,loading:u,_ref:B,className:_,wrapperProps:w})}var NDe=jDe,TDe=y.memo(NDe),sk=TDe;const EDe=Kn();function ADe(){return Gm()}function ODe(e=!1){const r={};e&&(r["Content-Type"]="application/json");const n=ADe();return n&&(r.Authorization=`Bearer ${n}`),r}async function Gi(e,r){const n=await fetch(`${EDe}/api/git/${e}`,{method:"POST",headers:ODe(!0),body:JSON.stringify(r)});if(!n.ok){const i=await n.json().catch(()=>({}));throw new Error(i.error||`Git ${e} failed: ${n.statusText}`)}return n.json()}const $s={status(e,r){return Gi("status",{cwd:e,...r?{branch:r}:{}})},listBranches(e){return Gi("branches",{cwd:e})},pull(e){return Gi("pull",{cwd:e})},sync(e){return Gi("sync",{cwd:e})},fetch(e,r=!1){return Gi("fetch",{cwd:e,all:r})},runStackedAction(e,r,n){return Gi("run-stacked-action",{cwd:e,action:r,...n!=null&&n.commitMessage?{commitMessage:n.commitMessage}:{},...n!=null&&n.featureBranch?{featureBranch:!0}:{},...n!=null&&n.baseBranch?{baseBranch:n.baseBranch}:{}})},checkout(e,r){return Gi("checkout",{cwd:e,branch:r})},createBranch(e,r,n){return Gi("create-branch",{cwd:e,branch:r,baseBranch:n})},discard(e,r){return Gi("discard",{cwd:e,paths:r})},stage(e,r){return Gi("stage",{cwd:e,paths:r})},unstage(e,r){return Gi("unstage",{cwd:e,paths:r})},init(e){return Gi("init",{cwd:e})},diff(e){return Gi("diff",{cwd:e})},diffStats(e,r,n){return Gi("diff-stats",{cwd:e,...r?{baseBranch:r}:{},...n?{branch:n}:{}})},fileDiffs(e,r,n){return Gi("file-diffs",{cwd:e,...r?{baseBranch:r}:{},...n?{branch:n}:{}}).then(i=>i.files)},createWorktree(e,r,n,i){return Gi("create-worktree",{cwd:e,baseBranch:r,newBranch:n,...i?{path:i}:{}})},removeWorktree(e,r,n=!1){return Gi("remove-worktree",{cwd:e,path:r,force:n})},ghStatus(e){return Gi("gh-status",{...e?{cwd:e}:{}})},ghAuth(e,r){return Gi("gh-auth",{token:e,...r?{cwd:r}:{}})},forgeStatus(e,r){return Gi("forge-status",{...e?{cwd:e}:{},...r?{remoteUrl:r}:{}})},forgeAuth(e,r,n){return Gi("forge-auth",{token:e,...r?{cwd:r}:{},...n?{remoteUrl:n}:{}})},forgePrChecks(e,r,n){return Gi("forge-pr-checks",{cwd:e,branch:r,...n?{remoteUrl:n}:{}})},identity(e){return Gi("identity",{cwd:e})},setIdentity(e,r,n){return Gi("identity",{cwd:e,name:r,email:n})},prChecks(e,r){return Gi("pr-checks",{cwd:e,branch:r})},generateCommitMessage(e,r,n){return Gi("generate-commit-message",{cwd:e,...r?{provider:r}:{},...n?{model:n}:{}})}};var cte=Object.defineProperty,X=(e,r)=>cte(e,"name",{value:r,configurable:!0}),MDe=(e,r)=>{for(var n in r)cte(e,n,{get:r[n],enumerable:!0})},Qf={trace:0,debug:1,info:2,warn:3,error:4,fatal:5},Ot={trace:X((...e)=>{},"trace"),debug:X((...e)=>{},"debug"),info:X((...e)=>{},"info"),warn:X((...e)=>{},"warn"),error:X((...e)=>{},"error"),fatal:X((...e)=>{},"fatal")},G9=X(function(e="fatal"){let r=Qf.fatal;typeof e=="string"?e.toLowerCase()in Qf&&(r=Qf[e]):typeof e=="number"&&(r=e),Ot.trace=()=>{},Ot.debug=()=>{},Ot.info=()=>{},Ot.warn=()=>{},Ot.error=()=>{},Ot.fatal=()=>{},r<=Qf.fatal&&(Ot.fatal=console.error?console.error.bind(console,Mu("FATAL"),"color: orange"):console.log.bind(console,"\x1B[35m",Mu("FATAL"))),r<=Qf.error&&(Ot.error=console.error?console.error.bind(console,Mu("ERROR"),"color: orange"):console.log.bind(console,"\x1B[31m",Mu("ERROR"))),r<=Qf.warn&&(Ot.warn=console.warn?console.warn.bind(console,Mu("WARN"),"color: orange"):console.log.bind(console,"\x1B[33m",Mu("WARN"))),r<=Qf.info&&(Ot.info=console.info?console.info.bind(console,Mu("INFO"),"color: lightblue"):console.log.bind(console,"\x1B[34m",Mu("INFO"))),r<=Qf.debug&&(Ot.debug=console.debug?console.debug.bind(console,Mu("DEBUG"),"color: lightgreen"):console.log.bind(console,"\x1B[32m",Mu("DEBUG"))),r<=Qf.trace&&(Ot.trace=console.debug?console.debug.bind(console,Mu("TRACE"),"color: lightgreen"):console.log.bind(console,"\x1B[32m",Mu("TRACE")))},"setLogLevel"),Mu=X(e=>`%c${Z8e().format("ss.SSS")} : ${e} : `,"format");const a5={min:{r:0,g:0,b:0,s:0,l:0,a:0},max:{r:255,g:255,b:255,h:360,s:100,l:100,a:1},clamp:{r:e=>e>=255?255:e<0?0:e,g:e=>e>=255?255:e<0?0:e,b:e=>e>=255?255:e<0?0:e,h:e=>e%360,s:e=>e>=100?100:e<0?0:e,l:e=>e>=100?100:e<0?0:e,a:e=>e>=1?1:e<0?0:e},toLinear:e=>{const r=e/255;return e>.03928?Math.pow((r+.055)/1.055,2.4):r/12.92},hue2rgb:(e,r,n)=>(n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(r-e)*6*n:n<1/2?r:n<2/3?e+(r-e)*(2/3-n)*6:e),hsl2rgb:({h:e,s:r,l:n},i)=>{if(!r)return n*2.55;e/=360,r/=100,n/=100;const s=n<.5?n*(1+r):n+r-n*r,o=2*n-s;switch(i){case"r":return a5.hue2rgb(o,s,e+1/3)*255;case"g":return a5.hue2rgb(o,s,e)*255;case"b":return a5.hue2rgb(o,s,e-1/3)*255}},rgb2hsl:({r:e,g:r,b:n},i)=>{e/=255,r/=255,n/=255;const s=Math.max(e,r,n),o=Math.min(e,r,n),a=(s+o)/2;if(i==="l")return a*100;if(s===o)return 0;const l=s-o,u=a>.5?l/(2-s-o):l/(s+o);if(i==="s")return u*100;switch(s){case e:return((r-n)/l+(r<n?6:0))*60;case r:return((n-e)/l+2)*60;case n:return((e-r)/l+4)*60;default:return-1}}},RDe={clamp:(e,r,n)=>r>n?Math.min(r,Math.max(n,e)):Math.min(n,Math.max(r,e)),round:e=>Math.round(e*1e10)/1e10},PDe={dec2hex:e=>{const r=Math.round(e).toString(16);return r.length>1?r:`0${r}`}},bn={channel:a5,lang:RDe,unit:PDe},$m={};for(let e=0;e<=255;e++)$m[e]=bn.unit.dec2hex(e);const Ka={ALL:0,RGB:1,HSL:2};class LDe{constructor(){this.type=Ka.ALL}get(){return this.type}set(r){if(this.type&&this.type!==r)throw new Error("Cannot change both RGB and HSL channels at the same time");this.type=r}reset(){this.type=Ka.ALL}is(r){return this.type===r}}class $De{constructor(r,n){this.color=n,this.changed=!1,this.data=r,this.type=new LDe}set(r,n){return this.color=n,this.changed=!1,this.data=r,this.type.type=Ka.ALL,this}_ensureHSL(){const r=this.data,{h:n,s:i,l:s}=r;n===void 0&&(r.h=bn.channel.rgb2hsl(r,"h")),i===void 0&&(r.s=bn.channel.rgb2hsl(r,"s")),s===void 0&&(r.l=bn.channel.rgb2hsl(r,"l"))}_ensureRGB(){const r=this.data,{r:n,g:i,b:s}=r;n===void 0&&(r.r=bn.channel.hsl2rgb(r,"r")),i===void 0&&(r.g=bn.channel.hsl2rgb(r,"g")),s===void 0&&(r.b=bn.channel.hsl2rgb(r,"b"))}get r(){const r=this.data,n=r.r;return!this.type.is(Ka.HSL)&&n!==void 0?n:(this._ensureHSL(),bn.channel.hsl2rgb(r,"r"))}get g(){const r=this.data,n=r.g;return!this.type.is(Ka.HSL)&&n!==void 0?n:(this._ensureHSL(),bn.channel.hsl2rgb(r,"g"))}get b(){const r=this.data,n=r.b;return!this.type.is(Ka.HSL)&&n!==void 0?n:(this._ensureHSL(),bn.channel.hsl2rgb(r,"b"))}get h(){const r=this.data,n=r.h;return!this.type.is(Ka.RGB)&&n!==void 0?n:(this._ensureRGB(),bn.channel.rgb2hsl(r,"h"))}get s(){const r=this.data,n=r.s;return!this.type.is(Ka.RGB)&&n!==void 0?n:(this._ensureRGB(),bn.channel.rgb2hsl(r,"s"))}get l(){const r=this.data,n=r.l;return!this.type.is(Ka.RGB)&&n!==void 0?n:(this._ensureRGB(),bn.channel.rgb2hsl(r,"l"))}get a(){return this.data.a}set r(r){this.type.set(Ka.RGB),this.changed=!0,this.data.r=r}set g(r){this.type.set(Ka.RGB),this.changed=!0,this.data.g=r}set b(r){this.type.set(Ka.RGB),this.changed=!0,this.data.b=r}set h(r){this.type.set(Ka.HSL),this.changed=!0,this.data.h=r}set s(r){this.type.set(Ka.HSL),this.changed=!0,this.data.s=r}set l(r){this.type.set(Ka.HSL),this.changed=!0,this.data.l=r}set a(r){this.changed=!0,this.data.a=r}}const wN=new $De({r:0,g:0,b:0,a:0},"transparent"),ov={re:/^#((?:[a-f0-9]{2}){2,4}|[a-f0-9]{3})$/i,parse:e=>{if(e.charCodeAt(0)!==35)return;const r=e.match(ov.re);if(!r)return;const n=r[1],i=parseInt(n,16),s=n.length,o=s%4===0,a=s>4,l=a?1:17,u=a?8:4,d=o?0:-1,h=a?255:15;return wN.set({r:(i>>u*(d+3)&h)*l,g:(i>>u*(d+2)&h)*l,b:(i>>u*(d+1)&h)*l,a:o?(i&h)*l/255:1},e)},stringify:e=>{const{r,g:n,b:i,a:s}=e;return s<1?`#${$m[Math.round(r)]}${$m[Math.round(n)]}${$m[Math.round(i)]}${$m[Math.round(s*255)]}`:`#${$m[Math.round(r)]}${$m[Math.round(n)]}${$m[Math.round(i)]}`}},M0={re:/^hsla?\(\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e-?\d+)?(?:deg|grad|rad|turn)?)\s*?(?:,|\s)\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e-?\d+)?%)\s*?(?:,|\s)\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e-?\d+)?%)(?:\s*?(?:,|\/)\s*?\+?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e-?\d+)?(%)?))?\s*?\)$/i,hueRe:/^(.+?)(deg|grad|rad|turn)$/i,_hue2deg:e=>{const r=e.match(M0.hueRe);if(r){const[,n,i]=r;switch(i){case"grad":return bn.channel.clamp.h(parseFloat(n)*.9);case"rad":return bn.channel.clamp.h(parseFloat(n)*180/Math.PI);case"turn":return bn.channel.clamp.h(parseFloat(n)*360)}}return bn.channel.clamp.h(parseFloat(e))},parse:e=>{const r=e.charCodeAt(0);if(r!==104&&r!==72)return;const n=e.match(M0.re);if(!n)return;const[,i,s,o,a,l]=n;return wN.set({h:M0._hue2deg(i),s:bn.channel.clamp.s(parseFloat(s)),l:bn.channel.clamp.l(parseFloat(o)),a:a?bn.channel.clamp.a(l?parseFloat(a)/100:parseFloat(a)):1},e)},stringify:e=>{const{h:r,s:n,l:i,a:s}=e;return s<1?`hsla(${bn.lang.round(r)}, ${bn.lang.round(n)}%, ${bn.lang.round(i)}%, ${s})`:`hsl(${bn.lang.round(r)}, ${bn.lang.round(n)}%, ${bn.lang.round(i)}%)`}},s2={colors:{aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyanaqua:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",transparent:"#00000000",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},parse:e=>{e=e.toLowerCase();const r=s2.colors[e];if(r)return ov.parse(r)},stringify:e=>{const r=ov.stringify(e);for(const n in s2.colors)if(s2.colors[n]===r)return n}},E_={re:/^rgba?\(\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e\d+)?(%?))\s*?(?:,|\s)\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e\d+)?(%?))\s*?(?:,|\s)\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e\d+)?(%?))(?:\s*?(?:,|\/)\s*?\+?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e\d+)?(%?)))?\s*?\)$/i,parse:e=>{const r=e.charCodeAt(0);if(r!==114&&r!==82)return;const n=e.match(E_.re);if(!n)return;const[,i,s,o,a,l,u,d,h]=n;return wN.set({r:bn.channel.clamp.r(s?parseFloat(i)*2.55:parseFloat(i)),g:bn.channel.clamp.g(a?parseFloat(o)*2.55:parseFloat(o)),b:bn.channel.clamp.b(u?parseFloat(l)*2.55:parseFloat(l)),a:d?bn.channel.clamp.a(h?parseFloat(d)/100:parseFloat(d)):1},e)},stringify:e=>{const{r,g:n,b:i,a:s}=e;return s<1?`rgba(${bn.lang.round(r)}, ${bn.lang.round(n)}, ${bn.lang.round(i)}, ${bn.lang.round(s)})`:`rgb(${bn.lang.round(r)}, ${bn.lang.round(n)}, ${bn.lang.round(i)})`}},df={format:{keyword:s2,hex:ov,rgb:E_,rgba:E_,hsl:M0,hsla:M0},parse:e=>{if(typeof e!="string")return e;const r=ov.parse(e)||E_.parse(e)||M0.parse(e)||s2.parse(e);if(r)return r;throw new Error(`Unsupported color format: "${e}"`)},stringify:e=>!e.changed&&e.color?e.color:e.type.is(Ka.HSL)||e.data.r===void 0?M0.stringify(e):e.a<1||!Number.isInteger(e.r)||!Number.isInteger(e.g)||!Number.isInteger(e.b)?E_.stringify(e):ov.stringify(e)},ute=(e,r)=>{const n=df.parse(e);for(const i in r)n[i]=bn.channel.clamp[i](r[i]);return df.stringify(n)},o2=(e,r,n=0,i=1)=>{if(typeof e!="number")return ute(e,{a:r});const s=wN.set({r:bn.channel.clamp.r(e),g:bn.channel.clamp.g(r),b:bn.channel.clamp.b(n),a:bn.channel.clamp.a(i)});return df.stringify(s)},DDe=e=>{const{r,g:n,b:i}=df.parse(e),s=.2126*bn.channel.toLinear(r)+.7152*bn.channel.toLinear(n)+.0722*bn.channel.toLinear(i);return bn.lang.round(s)},IDe=e=>DDe(e)>=.5,ok=e=>!IDe(e),dte=(e,r,n)=>{const i=df.parse(e),s=i[r],o=bn.channel.clamp[r](s+n);return s!==o&&(i[r]=o),df.stringify(i)},Nr=(e,r)=>dte(e,"l",r),Zr=(e,r)=>dte(e,"l",-r),Ie=(e,r)=>{const n=df.parse(e),i={};for(const s in r)r[s]&&(i[s]=n[s]+r[s]);return ute(e,i)},BDe=(e,r,n=50)=>{const{r:i,g:s,b:o,a}=df.parse(e),{r:l,g:u,b:d,a:h}=df.parse(r),f=n/100,g=f*2-1,v=a-h,_=((g*v===-1?g:(g+v)/(1+g*v))+1)/2,w=1-_,S=i*_+l*w,C=s*_+u*w,j=o*_+d*w,E=a*f+h*(1-f);return o2(S,C,j,E)},ar=(e,r=100)=>{const n=df.parse(e);return n.r=255-n.r,n.g=255-n.g,n.b=255-n.b,BDe(n,e,r)};/*! @license DOMPurify 3.3.2 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.2/LICENSE */const{entries:hte,setPrototypeOf:yF,isFrozen:zDe,getPrototypeOf:FDe,getOwnPropertyDescriptor:HDe}=Object;let{freeze:Al,seal:id,create:l5}=Object,{apply:sO,construct:oO}=typeof Reflect<"u"&&Reflect;Al||(Al=function(r){return r});id||(id=function(r){return r});sO||(sO=function(r,n){for(var i=arguments.length,s=new Array(i>2?i-2:0),o=2;o<i;o++)s[o-2]=arguments[o];return r.apply(n,s)});oO||(oO=function(r){for(var n=arguments.length,i=new Array(n>1?n-1:0),s=1;s<n;s++)i[s-1]=arguments[s];return new r(...i)});const ZC=Ol(Array.prototype.forEach),WDe=Ol(Array.prototype.lastIndexOf),vF=Ol(Array.prototype.pop),Db=Ol(Array.prototype.push),UDe=Ol(Array.prototype.splice),c5=Ol(String.prototype.toLowerCase),DE=Ol(String.prototype.toString),IE=Ol(String.prototype.match),Ib=Ol(String.prototype.replace),VDe=Ol(String.prototype.indexOf),qDe=Ol(String.prototype.trim),Gc=Ol(Object.prototype.hasOwnProperty),xl=Ol(RegExp.prototype.test),Bb=GDe(TypeError);function Ol(e){return function(r){r instanceof RegExp&&(r.lastIndex=0);for(var n=arguments.length,i=new Array(n>1?n-1:0),s=1;s<n;s++)i[s-1]=arguments[s];return sO(e,r,i)}}function GDe(e){return function(){for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];return oO(e,n)}}function In(e,r){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:c5;yF&&yF(e,null);let i=r.length;for(;i--;){let s=r[i];if(typeof s=="string"){const o=n(s);o!==s&&(zDe(r)||(r[i]=o),s=o)}e[s]=!0}return e}function KDe(e){for(let r=0;r<e.length;r++)Gc(e,r)||(e[r]=null);return e}function Wh(e){const r=l5(null);for(const[n,i]of hte(e))Gc(e,n)&&(Array.isArray(i)?r[n]=KDe(i):i&&typeof i=="object"&&i.constructor===Object?r[n]=Wh(i):r[n]=i);return r}function zb(e,r){for(;e!==null;){const i=HDe(e,r);if(i){if(i.get)return Ol(i.get);if(typeof i.value=="function")return Ol(i.value)}e=FDe(e)}function n(){return null}return n}const xF=Al(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),BE=Al(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),zE=Al(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),YDe=Al(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),FE=Al(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),XDe=Al(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),bF=Al(["#text"]),_F=Al(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),HE=Al(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),wF=Al(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),QC=Al(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),JDe=id(/\{\{[\w\W]*|[\w\W]*\}\}/gm),ZDe=id(/<%[\w\W]*|[\w\W]*%>/gm),QDe=id(/\$\{[\w\W]*/gm),eIe=id(/^data-[\-\w.\u00B7-\uFFFF]+$/),tIe=id(/^aria-[\-\w]+$/),fte=id(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),rIe=id(/^(?:\w+script|data):/i),nIe=id(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),pte=id(/^html$/i),iIe=id(/^[a-z][.\w]*(-[.\w]+)+$/i);var SF=Object.freeze({__proto__:null,ARIA_ATTR:tIe,ATTR_WHITESPACE:nIe,CUSTOM_ELEMENT:iIe,DATA_ATTR:eIe,DOCTYPE_NAME:pte,ERB_EXPR:ZDe,IS_ALLOWED_URI:fte,IS_SCRIPT_OR_DATA:rIe,MUSTACHE_EXPR:JDe,TMPLIT_EXPR:QDe});const Fb={element:1,text:3,progressingInstruction:7,comment:8,document:9},sIe=function(){return typeof window>"u"?null:window},oIe=function(r,n){if(typeof r!="object"||typeof r.createPolicy!="function")return null;let i=null;const s="data-tt-policy-suffix";n&&n.hasAttribute(s)&&(i=n.getAttribute(s));const o="dompurify"+(i?"#"+i:"");try{return r.createPolicy(o,{createHTML(a){return a},createScriptURL(a){return a}})}catch{return console.warn("TrustedTypes policy "+o+" could not be created."),null}},kF=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function mte(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:sIe();const r=Ke=>mte(Ke);if(r.version="3.3.2",r.removed=[],!e||!e.document||e.document.nodeType!==Fb.document||!e.Element)return r.isSupported=!1,r;let{document:n}=e;const i=n,s=i.currentScript,{DocumentFragment:o,HTMLTemplateElement:a,Node:l,Element:u,NodeFilter:d,NamedNodeMap:h=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:f,DOMParser:g,trustedTypes:v}=e,b=u.prototype,_=zb(b,"cloneNode"),w=zb(b,"remove"),S=zb(b,"nextSibling"),C=zb(b,"childNodes"),j=zb(b,"parentNode");if(typeof a=="function"){const Ke=n.createElement("template");Ke.content&&Ke.content.ownerDocument&&(n=Ke.content.ownerDocument)}let E,A="";const{implementation:N,createNodeIterator:P,createDocumentFragment:H,getElementsByTagName:K}=n,{importNode:F}=i;let B=kF();r.isSupported=typeof hte=="function"&&typeof j=="function"&&N&&N.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:W,ERB_EXPR:D,TMPLIT_EXPR:O,DATA_ATTR:I,ARIA_ATTR:R,IS_SCRIPT_OR_DATA:$,ATTR_WHITESPACE:U,CUSTOM_ELEMENT:Y}=SF;let{IS_ALLOWED_URI:z}=SF,V=null;const Q=In({},[...xF,...BE,...zE,...FE,...bF]);let q=null;const re=In({},[..._F,...HE,...wF,...QC]);let ee=Object.seal(l5(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),ne=null,ae=null;const te=Object.seal(l5(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let ue=!0,he=!0,we=!1,pe=!0,qe=!1,se=!0,it=!1,Ye=!1,ht=!1,qt=!1,Nt=!1,Xt=!1,Wt=!0,gt=!1;const Re="user-content-";let kt=!0,Pt=!1,Ne={},ze=null;const Qe=In({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let lt=null;const yt=In({},["audio","video","img","source","image","track"]);let Tt=null;const dr=In({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),De="http://www.w3.org/1998/Math/MathML",je="http://www.w3.org/2000/svg",be="http://www.w3.org/1999/xhtml";let Be=be,at=!1,Ve=null;const Mt=In({},[De,je,be],DE);let It=In({},["mi","mo","mn","ms","mtext"]),rr=In({},["annotation-xml"]);const nr=In({},["title","style","font","a","script"]);let Ut=null;const Se=["application/xhtml+xml","text/html"],Fe="text/html";let et=null,St=null;const Xe=n.createElement("form"),Lt=function(me){return me instanceof RegExp||me instanceof Function},Et=function(){let me=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(St&&St===me)){if((!me||typeof me!="object")&&(me={}),me=Wh(me),Ut=Se.indexOf(me.PARSER_MEDIA_TYPE)===-1?Fe:me.PARSER_MEDIA_TYPE,et=Ut==="application/xhtml+xml"?DE:c5,V=Gc(me,"ALLOWED_TAGS")?In({},me.ALLOWED_TAGS,et):Q,q=Gc(me,"ALLOWED_ATTR")?In({},me.ALLOWED_ATTR,et):re,Ve=Gc(me,"ALLOWED_NAMESPACES")?In({},me.ALLOWED_NAMESPACES,DE):Mt,Tt=Gc(me,"ADD_URI_SAFE_ATTR")?In(Wh(dr),me.ADD_URI_SAFE_ATTR,et):dr,lt=Gc(me,"ADD_DATA_URI_TAGS")?In(Wh(yt),me.ADD_DATA_URI_TAGS,et):yt,ze=Gc(me,"FORBID_CONTENTS")?In({},me.FORBID_CONTENTS,et):Qe,ne=Gc(me,"FORBID_TAGS")?In({},me.FORBID_TAGS,et):Wh({}),ae=Gc(me,"FORBID_ATTR")?In({},me.FORBID_ATTR,et):Wh({}),Ne=Gc(me,"USE_PROFILES")?me.USE_PROFILES:!1,ue=me.ALLOW_ARIA_ATTR!==!1,he=me.ALLOW_DATA_ATTR!==!1,we=me.ALLOW_UNKNOWN_PROTOCOLS||!1,pe=me.ALLOW_SELF_CLOSE_IN_ATTR!==!1,qe=me.SAFE_FOR_TEMPLATES||!1,se=me.SAFE_FOR_XML!==!1,it=me.WHOLE_DOCUMENT||!1,qt=me.RETURN_DOM||!1,Nt=me.RETURN_DOM_FRAGMENT||!1,Xt=me.RETURN_TRUSTED_TYPE||!1,ht=me.FORCE_BODY||!1,Wt=me.SANITIZE_DOM!==!1,gt=me.SANITIZE_NAMED_PROPS||!1,kt=me.KEEP_CONTENT!==!1,Pt=me.IN_PLACE||!1,z=me.ALLOWED_URI_REGEXP||fte,Be=me.NAMESPACE||be,It=me.MATHML_TEXT_INTEGRATION_POINTS||It,rr=me.HTML_INTEGRATION_POINTS||rr,ee=me.CUSTOM_ELEMENT_HANDLING||{},me.CUSTOM_ELEMENT_HANDLING&&Lt(me.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(ee.tagNameCheck=me.CUSTOM_ELEMENT_HANDLING.tagNameCheck),me.CUSTOM_ELEMENT_HANDLING&&Lt(me.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(ee.attributeNameCheck=me.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),me.CUSTOM_ELEMENT_HANDLING&&typeof me.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(ee.allowCustomizedBuiltInElements=me.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),qe&&(he=!1),Nt&&(qt=!0),Ne&&(V=In({},bF),q=l5(null),Ne.html===!0&&(In(V,xF),In(q,_F)),Ne.svg===!0&&(In(V,BE),In(q,HE),In(q,QC)),Ne.svgFilters===!0&&(In(V,zE),In(q,HE),In(q,QC)),Ne.mathMl===!0&&(In(V,FE),In(q,wF),In(q,QC))),Gc(me,"ADD_TAGS")||(te.tagCheck=null),Gc(me,"ADD_ATTR")||(te.attributeCheck=null),me.ADD_TAGS&&(typeof me.ADD_TAGS=="function"?te.tagCheck=me.ADD_TAGS:(V===Q&&(V=Wh(V)),In(V,me.ADD_TAGS,et))),me.ADD_ATTR&&(typeof me.ADD_ATTR=="function"?te.attributeCheck=me.ADD_ATTR:(q===re&&(q=Wh(q)),In(q,me.ADD_ATTR,et))),me.ADD_URI_SAFE_ATTR&&In(Tt,me.ADD_URI_SAFE_ATTR,et),me.FORBID_CONTENTS&&(ze===Qe&&(ze=Wh(ze)),In(ze,me.FORBID_CONTENTS,et)),me.ADD_FORBID_CONTENTS&&(ze===Qe&&(ze=Wh(ze)),In(ze,me.ADD_FORBID_CONTENTS,et)),kt&&(V["#text"]=!0),it&&In(V,["html","head","body"]),V.table&&(In(V,["tbody"]),delete ne.tbody),me.TRUSTED_TYPES_POLICY){if(typeof me.TRUSTED_TYPES_POLICY.createHTML!="function")throw Bb('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof me.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Bb('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');E=me.TRUSTED_TYPES_POLICY,A=E.createHTML("")}else E===void 0&&(E=oIe(v,s)),E!==null&&typeof A=="string"&&(A=E.createHTML(""));Al&&Al(me),St=me}},Ft=In({},[...BE,...zE,...YDe]),ye=In({},[...FE,...XDe]),st=function(me){let dt=j(me);(!dt||!dt.tagName)&&(dt={namespaceURI:Be,tagName:"template"});const wt=c5(me.tagName),fr=c5(dt.tagName);return Ve[me.namespaceURI]?me.namespaceURI===je?dt.namespaceURI===be?wt==="svg":dt.namespaceURI===De?wt==="svg"&&(fr==="annotation-xml"||It[fr]):!!Ft[wt]:me.namespaceURI===De?dt.namespaceURI===be?wt==="math":dt.namespaceURI===je?wt==="math"&&rr[fr]:!!ye[wt]:me.namespaceURI===be?dt.namespaceURI===je&&!rr[fr]||dt.namespaceURI===De&&!It[fr]?!1:!ye[wt]&&(nr[wt]||!Ft[wt]):!!(Ut==="application/xhtml+xml"&&Ve[me.namespaceURI]):!1},ir=function(me){Db(r.removed,{element:me});try{j(me).removeChild(me)}catch{w(me)}},At=function(me,dt){try{Db(r.removed,{attribute:dt.getAttributeNode(me),from:dt})}catch{Db(r.removed,{attribute:null,from:dt})}if(dt.removeAttribute(me),me==="is")if(qt||Nt)try{ir(dt)}catch{}else try{dt.setAttribute(me,"")}catch{}},hr=function(me){let dt=null,wt=null;if(ht)me="<remove></remove>"+me;else{const qr=IE(me,/^[\r\n\t ]+/);wt=qr&&qr[0]}Ut==="application/xhtml+xml"&&Be===be&&(me='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+me+"</body></html>");const fr=E?E.createHTML(me):me;if(Be===be)try{dt=new g().parseFromString(fr,Ut)}catch{}if(!dt||!dt.documentElement){dt=N.createDocument(Be,"template",null);try{dt.documentElement.innerHTML=at?A:fr}catch{}}const vr=dt.body||dt.documentElement;return me&&wt&&vr.insertBefore(n.createTextNode(wt),vr.childNodes[0]||null),Be===be?K.call(dt,it?"html":"body")[0]:it?dt.documentElement:vr},Vr=function(me){return P.call(me.ownerDocument||me,me,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT|d.SHOW_PROCESSING_INSTRUCTION|d.SHOW_CDATA_SECTION,null)},br=function(me){return me instanceof f&&(typeof me.nodeName!="string"||typeof me.textContent!="string"||typeof me.removeChild!="function"||!(me.attributes instanceof h)||typeof me.removeAttribute!="function"||typeof me.setAttribute!="function"||typeof me.namespaceURI!="string"||typeof me.insertBefore!="function"||typeof me.hasChildNodes!="function")},Rr=function(me){return typeof l=="function"&&me instanceof l};function mt(Ke,me,dt){ZC(Ke,wt=>{wt.call(r,me,dt,St)})}const sr=function(me){let dt=null;if(mt(B.beforeSanitizeElements,me,null),br(me))return ir(me),!0;const wt=et(me.nodeName);if(mt(B.uponSanitizeElement,me,{tagName:wt,allowedTags:V}),se&&me.hasChildNodes()&&!Rr(me.firstElementChild)&&xl(/<[/\w!]/g,me.innerHTML)&&xl(/<[/\w!]/g,me.textContent)||me.nodeType===Fb.progressingInstruction||se&&me.nodeType===Fb.comment&&xl(/<[/\w]/g,me.data))return ir(me),!0;if(!(te.tagCheck instanceof Function&&te.tagCheck(wt))&&(!V[wt]||ne[wt])){if(!ne[wt]&&xt(wt)&&(ee.tagNameCheck instanceof RegExp&&xl(ee.tagNameCheck,wt)||ee.tagNameCheck instanceof Function&&ee.tagNameCheck(wt)))return!1;if(kt&&!ze[wt]){const fr=j(me)||me.parentNode,vr=C(me)||me.childNodes;if(vr&&fr){const qr=vr.length;for(let Hn=qr-1;Hn>=0;--Hn){const Mi=_(vr[Hn],!0);Mi.__removalCount=(me.__removalCount||0)+1,fr.insertBefore(Mi,S(me))}}}return ir(me),!0}return me instanceof u&&!st(me)||(wt==="noscript"||wt==="noembed"||wt==="noframes")&&xl(/<\/no(script|embed|frames)/i,me.innerHTML)?(ir(me),!0):(qe&&me.nodeType===Fb.text&&(dt=me.textContent,ZC([W,D,O],fr=>{dt=Ib(dt,fr," ")}),me.textContent!==dt&&(Db(r.removed,{element:me.cloneNode()}),me.textContent=dt)),mt(B.afterSanitizeElements,me,null),!1)},xe=function(me,dt,wt){if(ae[dt]||Wt&&(dt==="id"||dt==="name")&&(wt in n||wt in Xe))return!1;if(!(he&&!ae[dt]&&xl(I,dt))){if(!(ue&&xl(R,dt))){if(!(te.attributeCheck instanceof Function&&te.attributeCheck(dt,me))){if(!q[dt]||ae[dt]){if(!(xt(me)&&(ee.tagNameCheck instanceof RegExp&&xl(ee.tagNameCheck,me)||ee.tagNameCheck instanceof Function&&ee.tagNameCheck(me))&&(ee.attributeNameCheck instanceof RegExp&&xl(ee.attributeNameCheck,dt)||ee.attributeNameCheck instanceof Function&&ee.attributeNameCheck(dt,me))||dt==="is"&&ee.allowCustomizedBuiltInElements&&(ee.tagNameCheck instanceof RegExp&&xl(ee.tagNameCheck,wt)||ee.tagNameCheck instanceof Function&&ee.tagNameCheck(wt))))return!1}else if(!Tt[dt]){if(!xl(z,Ib(wt,U,""))){if(!((dt==="src"||dt==="xlink:href"||dt==="href")&&me!=="script"&&VDe(wt,"data:")===0&&lt[me])){if(!(we&&!xl($,Ib(wt,U,"")))){if(wt)return!1}}}}}}}return!0},xt=function(me){return me!=="annotation-xml"&&IE(me,Y)},Je=function(me){mt(B.beforeSanitizeAttributes,me,null);const{attributes:dt}=me;if(!dt||br(me))return;const wt={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:q,forceKeepAttr:void 0};let fr=dt.length;for(;fr--;){const vr=dt[fr],{name:qr,namespaceURI:Hn,value:Mi}=vr,Ri=et(qr),Hi=Mi;let He=qr==="value"?Hi:qDe(Hi);if(wt.attrName=Ri,wt.attrValue=He,wt.keepAttr=!0,wt.forceKeepAttr=void 0,mt(B.uponSanitizeAttribute,me,wt),He=wt.attrValue,gt&&(Ri==="id"||Ri==="name")&&(At(qr,me),He=Re+He),se&&xl(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,He)){At(qr,me);continue}if(Ri==="attributename"&&IE(He,"href")){At(qr,me);continue}if(wt.forceKeepAttr)continue;if(!wt.keepAttr){At(qr,me);continue}if(!pe&&xl(/\/>/i,He)){At(qr,me);continue}qe&&ZC([W,D,O],Kt=>{He=Ib(He,Kt," ")});const Le=et(me.nodeName);if(!xe(Le,Ri,He)){At(qr,me);continue}if(E&&typeof v=="object"&&typeof v.getAttributeType=="function"&&!Hn)switch(v.getAttributeType(Le,Ri)){case"TrustedHTML":{He=E.createHTML(He);break}case"TrustedScriptURL":{He=E.createScriptURL(He);break}}if(He!==Hi)try{Hn?me.setAttributeNS(Hn,qr,He):me.setAttribute(qr,He),br(me)?ir(me):vF(r.removed)}catch{At(qr,me)}}mt(B.afterSanitizeAttributes,me,null)},Rt=function Ke(me){let dt=null;const wt=Vr(me);for(mt(B.beforeSanitizeShadowDOM,me,null);dt=wt.nextNode();)mt(B.uponSanitizeShadowNode,dt,null),sr(dt),Je(dt),dt.content instanceof o&&Ke(dt.content);mt(B.afterSanitizeShadowDOM,me,null)};return r.sanitize=function(Ke){let me=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},dt=null,wt=null,fr=null,vr=null;if(at=!Ke,at&&(Ke="<!-->"),typeof Ke!="string"&&!Rr(Ke))if(typeof Ke.toString=="function"){if(Ke=Ke.toString(),typeof Ke!="string")throw Bb("dirty is not a string, aborting")}else throw Bb("toString is not a function");if(!r.isSupported)return Ke;if(Ye||Et(me),r.removed=[],typeof Ke=="string"&&(Pt=!1),Pt){if(Ke.nodeName){const Mi=et(Ke.nodeName);if(!V[Mi]||ne[Mi])throw Bb("root node is forbidden and cannot be sanitized in-place")}}else if(Ke instanceof l)dt=hr("<!---->"),wt=dt.ownerDocument.importNode(Ke,!0),wt.nodeType===Fb.element&&wt.nodeName==="BODY"||wt.nodeName==="HTML"?dt=wt:dt.appendChild(wt);else{if(!qt&&!qe&&!it&&Ke.indexOf("<")===-1)return E&&Xt?E.createHTML(Ke):Ke;if(dt=hr(Ke),!dt)return qt?null:Xt?A:""}dt&&ht&&ir(dt.firstChild);const qr=Vr(Pt?Ke:dt);for(;fr=qr.nextNode();)sr(fr),Je(fr),fr.content instanceof o&&Rt(fr.content);if(Pt)return Ke;if(qt){if(Nt)for(vr=H.call(dt.ownerDocument);dt.firstChild;)vr.appendChild(dt.firstChild);else vr=dt;return(q.shadowroot||q.shadowrootmode)&&(vr=F.call(i,vr,!0)),vr}let Hn=it?dt.outerHTML:dt.innerHTML;return it&&V["!doctype"]&&dt.ownerDocument&&dt.ownerDocument.doctype&&dt.ownerDocument.doctype.name&&xl(pte,dt.ownerDocument.doctype.name)&&(Hn="<!DOCTYPE "+dt.ownerDocument.doctype.name+`>
@@ -1167,8 +1167,8 @@ Please report this to https://github.com/markedjs/marked.`,r){let s="<p>An error
1167
1167
  node : x:${e.x} y:${e.y} w:${e.width} h:${e.height}`);const i=e.x,s=e.y,o=Math.abs(i-n.x),a=e.width/2;let l=n.x<r.x?a-o:a+o;const u=e.height/2,d=Math.abs(r.y-n.y),h=Math.abs(r.x-n.x);if(Math.abs(s-r.y)*a>Math.abs(i-r.x)*u){let f=n.y<r.y?r.y-u-s:s-u-r.y;l=h*f/d;const g={x:n.x<r.x?n.x+l:n.x-h+l,y:n.y<r.y?n.y+d-f:n.y-d+f};return l===0&&(g.x=r.x,g.y=r.y),h===0&&(g.x=r.x),d===0&&(g.y=r.y),Ot.debug(`abc89 top/bottom calc, Q ${d}, q ${f}, R ${h}, r ${l}`,g),g}else{n.x<r.x?l=r.x-a-i:l=i-a-r.x;let f=d*l/h,g=n.x<r.x?n.x+h-l:n.x-h+l,v=n.y<r.y?n.y+f:n.y-f;return Ot.debug(`sides calc abc89, Q ${d}, q ${f}, R ${h}, r ${l}`,{_x:g,_y:v}),l===0&&(g=r.x,v=r.y),h===0&&(g=r.x),d===0&&(v=r.y),{x:g,y:v}}},"intersection"),qH=X((e,r)=>{Ot.warn("abc88 cutPathAtIntersect",e,r);let n=[],i=e[0],s=!1;return e.forEach(o=>{if(Ot.info("abc88 checking point",o,r),!CYe(r,o)&&!s){const a=jYe(r,i,o);Ot.debug("abc88 inside",o,i,a),Ot.debug("abc88 intersection",a,r);let l=!1;n.forEach(u=>{l=l||u.x===a.x&&u.y===a.y}),n.some(u=>u.x===a.x&&u.y===a.y)?Ot.warn("abc88 no intersect",a,n):n.push(a),s=!0}else Ot.warn("abc88 outside",o,i),i=o,s||n.push(o)}),Ot.debug("returning points",n),n},"cutPathAtIntersect");function $oe(e){const r=[],n=[];for(let i=1;i<e.length-1;i++){const s=e[i-1],o=e[i],a=e[i+1];(s.x===o.x&&o.y===a.y&&Math.abs(o.x-a.x)>5&&Math.abs(o.y-s.y)>5||s.y===o.y&&o.x===a.x&&Math.abs(o.x-s.x)>5&&Math.abs(o.y-a.y)>5)&&(r.push(o),n.push(i))}return{cornerPoints:r,cornerPointPositions:n}}X($oe,"extractCornerPoints");var GH=X(function(e,r,n){const i=r.x-e.x,s=r.y-e.y,o=Math.sqrt(i*i+s*s),a=n/o;return{x:r.x-a*i,y:r.y-a*s}},"findAdjacentPoint"),NYe=X(function(e){const{cornerPointPositions:r}=$oe(e),n=[];for(let i=0;i<e.length;i++)if(r.includes(i)){const s=e[i-1],o=e[i+1],a=e[i],l=GH(s,a,5),u=GH(o,a,5),d=u.x-l.x,h=u.y-l.y;n.push(l);const f=Math.sqrt(2)*2;let g={x:a.x,y:a.y};if(Math.abs(o.x-s.x)>10&&Math.abs(o.y-s.y)>=10){Ot.debug("Corner point fixing",Math.abs(o.x-s.x),Math.abs(o.y-s.y));const v=5;a.x===l.x?g={x:d<0?l.x-v+f:l.x+v-f,y:h<0?l.y-f:l.y+f}:g={x:d<0?l.x-f:l.x+f,y:h<0?l.y-v+f:l.y+v-f}}else Ot.debug("Corner point skipping fixing",Math.abs(o.x-s.x),Math.abs(o.y-s.y));n.push(g,u)}else n.push(e[i]);return n},"fixCorners"),TYe=X((e,r,n)=>{const i=e-r-n,s=2,o=2,a=s+o,l=Math.floor(i/a),u=Array(l).fill(`${s} ${o}`).join(" ");return`0 ${r} ${u} ${n}`},"generateDashArray"),EYe=X(function(e,r,n,i,s,o,a,l=!1){var R;const{handDrawnSeed:u}=hi();let d=r.points,h=!1;const f=s;var g=o;const v=[];for(const $ in r.cssCompiledStyles)$ie($)||v.push(r.cssCompiledStyles[$]);Ot.debug("UIO intersect check",r.points,g.x,f.x),g.intersect&&f.intersect&&!l&&(d=d.slice(1,r.points.length-1),d.unshift(f.intersect(d[0])),Ot.debug("Last point UIO",r.start,"-->",r.end,d[d.length-1],g,g.intersect(d[d.length-1])),d.push(g.intersect(d[d.length-1])));const b=btoa(JSON.stringify(d));r.toCluster&&(Ot.info("to cluster abc88",n.get(r.toCluster)),d=qH(r.points,n.get(r.toCluster).node),h=!0),r.fromCluster&&(Ot.debug("from cluster abc88",n.get(r.fromCluster),JSON.stringify(d,null,2)),d=qH(d.reverse(),n.get(r.fromCluster).node).reverse(),h=!0);let _=d.filter($=>!Number.isNaN($.y));const w=wYe(r.curve);w!=="rounded"&&(_=NYe(_));let S=c2;switch(w){case"linear":S=c2;break;case"basis":S=wO;break;case"cardinal":S=gre;break;case"bumpX":S=dre;break;case"bumpY":S=hre;break;case"catmullRom":S=vre;break;case"monotoneX":S=kre;break;case"monotoneY":S=Cre;break;case"natural":S=Nre;break;case"step":S=Tre;break;case"stepAfter":S=Are;break;case"stepBefore":S=Ere;break;case"rounded":S=c2;break;default:S=wO}const{x:C,y:j}=CUe(r),E=tWe().x(C).y(j).curve(S);let A;switch(r.thickness){case"normal":A="edge-thickness-normal";break;case"thick":A="edge-thickness-thick";break;case"invisible":A="edge-thickness-invisible";break;default:A="edge-thickness-normal"}switch(r.pattern){case"solid":A+=" edge-pattern-solid";break;case"dotted":A+=" edge-pattern-dotted";break;case"dashed":A+=" edge-pattern-dashed";break;default:A+=" edge-pattern-solid"}let N,P=w==="rounded"?Doe(Ioe(_,r),5):E(_);const H=Array.isArray(r.style)?r.style:[r.style];let K=H.find($=>$==null?void 0:$.startsWith("stroke:")),F="";r.animate&&(F="edge-animation-fast"),r.animation&&(F="edge-animation-"+r.animation);let B=!1;if(r.look==="handDrawn"){const $=Mr.svg(e);Object.assign([],_);const U=$.path(P,{roughness:.3,seed:u});A+=" transition",N=nn(U).select("path").attr("id",r.id).attr("class"," "+A+(r.classes?" "+r.classes:"")+(F?" "+F:"")).attr("style",H?H.reduce((z,V)=>z+";"+V,""):"");let Y=N.attr("d");N.attr("d",Y),e.node().appendChild(N.node())}else{const $=v.join(";"),U=H?H.reduce((re,ee)=>re+ee+";",""):"",Y=($?$+";"+U+";":U)+";"+(H?H.reduce((re,ee)=>re+";"+ee,""):"");N=e.append("path").attr("d",P).attr("id",r.id).attr("class"," "+A+(r.classes?" "+r.classes:"")+(F?" "+F:"")).attr("style",Y),K=(R=Y.match(/stroke:([^;]+)/))==null?void 0:R[1],B=r.animate===!0||!!r.animation||$.includes("animation");const z=N.node(),V=typeof z.getTotalLength=="function"?z.getTotalLength():0,Q=lH[r.arrowTypeStart]||0,q=lH[r.arrowTypeEnd]||0;if(r.look==="neo"&&!B){const ee=`stroke-dasharray: ${r.pattern==="dotted"||r.pattern==="dashed"?TYe(V,Q,q):`0 ${Q} ${V-Q-q} ${q}`}; stroke-dashoffset: 0;`;N.attr("style",ee+N.attr("style"))}}N.attr("data-edge",!0),N.attr("data-et","edge"),N.attr("data-id",r.id),N.attr("data-points",b),r.showPoints&&_.forEach($=>{e.append("circle").style("stroke","red").style("fill","red").attr("r",1).attr("cx",$.x).attr("cy",$.y)});let W="";(hi().flowchart.arrowMarkerAbsolute||hi().state.arrowMarkerAbsolute)&&(W=window.location.protocol+"//"+window.location.host+window.location.pathname+window.location.search,W=W.replace(/\(/g,"\\(").replace(/\)/g,"\\)")),Ot.info("arrowTypeStart",r.arrowTypeStart),Ot.info("arrowTypeEnd",r.arrowTypeEnd),bYe(N,r,W,a,i,K);const D=Math.floor(d.length/2),O=d[D];Wd.isLabelCoordinateInPath(O,N.attr("d"))||(h=!0);let I={};return h&&(I.updatedPath=d),I.originalPath=r.points,I},"insertEdge");function Doe(e,r){if(e.length<2)return"";let n="";const i=e.length,s=1e-5;for(let o=0;o<i;o++){const a=e[o],l=e[o-1],u=e[o+1];if(o===0)n+=`M${a.x},${a.y}`;else if(o===i-1)n+=`L${a.x},${a.y}`;else{const d=a.x-l.x,h=a.y-l.y,f=u.x-a.x,g=u.y-a.y,v=Math.hypot(d,h),b=Math.hypot(f,g);if(v<s||b<s){n+=`L${a.x},${a.y}`;continue}const _=d/v,w=h/v,S=f/b,C=g/b,j=_*S+w*C,E=Math.max(-1,Math.min(1,j)),A=Math.acos(E);if(A<s||Math.abs(Math.PI-A)<s){n+=`L${a.x},${a.y}`;continue}const N=Math.min(r/Math.sin(A/2),v/2,b/2),P=a.x-_*N,H=a.y-w*N,K=a.x+S*N,F=a.y+C*N;n+=`L${P},${H}`,n+=`Q${a.x},${a.y} ${K},${F}`}}return n}X(Doe,"generateRoundedPath");function XO(e,r){if(!e||!r)return{angle:0,deltaX:0,deltaY:0};const n=r.x-e.x,i=r.y-e.y;return{angle:Math.atan2(i,n),deltaX:n,deltaY:i}}X(XO,"calculateDeltaAndAngle");function Ioe(e,r){const n=e.map(s=>({...s}));if(e.length>=2&&Ya[r.arrowTypeStart]){const s=Ya[r.arrowTypeStart],o=e[0],a=e[1],{angle:l}=XO(o,a),u=s*Math.cos(l),d=s*Math.sin(l);n[0].x=o.x+u,n[0].y=o.y+d}const i=e.length;if(i>=2&&Ya[r.arrowTypeEnd]){const s=Ya[r.arrowTypeEnd],o=e[i-1],a=e[i-2],{angle:l}=XO(a,o),u=s*Math.cos(l),d=s*Math.sin(l);n[i-1].x=o.x-u,n[i-1].y=o.y-d}return n}X(Ioe,"applyMarkerOffsetsToPoints");var AYe=X((e,r,n,i)=>{r.forEach(s=>{qYe[s](e,n,i)})},"insertMarkers"),OYe=X((e,r,n)=>{Ot.trace("Making markers for ",n),e.append("defs").append("marker").attr("id",n+"_"+r+"-extensionStart").attr("class","marker extension "+r).attr("refX",18).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("path").attr("d","M 1,7 L18,13 V 1 Z"),e.append("defs").append("marker").attr("id",n+"_"+r+"-extensionEnd").attr("class","marker extension "+r).attr("refX",1).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 1,1 V 13 L18,7 Z")},"extension"),MYe=X((e,r,n)=>{e.append("defs").append("marker").attr("id",n+"_"+r+"-compositionStart").attr("class","marker composition "+r).attr("refX",18).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L1,7 L9,1 Z"),e.append("defs").append("marker").attr("id",n+"_"+r+"-compositionEnd").attr("class","marker composition "+r).attr("refX",1).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L1,7 L9,1 Z")},"composition"),RYe=X((e,r,n)=>{e.append("defs").append("marker").attr("id",n+"_"+r+"-aggregationStart").attr("class","marker aggregation "+r).attr("refX",18).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L1,7 L9,1 Z"),e.append("defs").append("marker").attr("id",n+"_"+r+"-aggregationEnd").attr("class","marker aggregation "+r).attr("refX",1).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L1,7 L9,1 Z")},"aggregation"),PYe=X((e,r,n)=>{e.append("defs").append("marker").attr("id",n+"_"+r+"-dependencyStart").attr("class","marker dependency "+r).attr("refX",6).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("path").attr("d","M 5,7 L9,13 L1,7 L9,1 Z"),e.append("defs").append("marker").attr("id",n+"_"+r+"-dependencyEnd").attr("class","marker dependency "+r).attr("refX",13).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L14,7 L9,1 Z")},"dependency"),LYe=X((e,r,n)=>{e.append("defs").append("marker").attr("id",n+"_"+r+"-lollipopStart").attr("class","marker lollipop "+r).attr("refX",13).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("circle").attr("fill","transparent").attr("cx",7).attr("cy",7).attr("r",6),e.append("defs").append("marker").attr("id",n+"_"+r+"-lollipopEnd").attr("class","marker lollipop "+r).attr("refX",1).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("circle").attr("fill","transparent").attr("cx",7).attr("cy",7).attr("r",6)},"lollipop"),$Ye=X((e,r,n)=>{e.append("marker").attr("id",n+"_"+r+"-pointEnd").attr("class","marker "+r).attr("viewBox","0 0 10 10").attr("refX",5).attr("refY",5).attr("markerUnits","userSpaceOnUse").attr("markerWidth",8).attr("markerHeight",8).attr("orient","auto").append("path").attr("d","M 0 0 L 10 5 L 0 10 z").attr("class","arrowMarkerPath").style("stroke-width",1).style("stroke-dasharray","1,0"),e.append("marker").attr("id",n+"_"+r+"-pointStart").attr("class","marker "+r).attr("viewBox","0 0 10 10").attr("refX",4.5).attr("refY",5).attr("markerUnits","userSpaceOnUse").attr("markerWidth",8).attr("markerHeight",8).attr("orient","auto").append("path").attr("d","M 0 5 L 10 10 L 10 0 z").attr("class","arrowMarkerPath").style("stroke-width",1).style("stroke-dasharray","1,0")},"point"),DYe=X((e,r,n)=>{e.append("marker").attr("id",n+"_"+r+"-circleEnd").attr("class","marker "+r).attr("viewBox","0 0 10 10").attr("refX",11).attr("refY",5).attr("markerUnits","userSpaceOnUse").attr("markerWidth",11).attr("markerHeight",11).attr("orient","auto").append("circle").attr("cx","5").attr("cy","5").attr("r","5").attr("class","arrowMarkerPath").style("stroke-width",1).style("stroke-dasharray","1,0"),e.append("marker").attr("id",n+"_"+r+"-circleStart").attr("class","marker "+r).attr("viewBox","0 0 10 10").attr("refX",-1).attr("refY",5).attr("markerUnits","userSpaceOnUse").attr("markerWidth",11).attr("markerHeight",11).attr("orient","auto").append("circle").attr("cx","5").attr("cy","5").attr("r","5").attr("class","arrowMarkerPath").style("stroke-width",1).style("stroke-dasharray","1,0")},"circle"),IYe=X((e,r,n)=>{e.append("marker").attr("id",n+"_"+r+"-crossEnd").attr("class","marker cross "+r).attr("viewBox","0 0 11 11").attr("refX",12).attr("refY",5.2).attr("markerUnits","userSpaceOnUse").attr("markerWidth",11).attr("markerHeight",11).attr("orient","auto").append("path").attr("d","M 1,1 l 9,9 M 10,1 l -9,9").attr("class","arrowMarkerPath").style("stroke-width",2).style("stroke-dasharray","1,0"),e.append("marker").attr("id",n+"_"+r+"-crossStart").attr("class","marker cross "+r).attr("viewBox","0 0 11 11").attr("refX",-1).attr("refY",5.2).attr("markerUnits","userSpaceOnUse").attr("markerWidth",11).attr("markerHeight",11).attr("orient","auto").append("path").attr("d","M 1,1 l 9,9 M 10,1 l -9,9").attr("class","arrowMarkerPath").style("stroke-width",2).style("stroke-dasharray","1,0")},"cross"),BYe=X((e,r,n)=>{e.append("defs").append("marker").attr("id",n+"_"+r+"-barbEnd").attr("refX",19).attr("refY",7).attr("markerWidth",20).attr("markerHeight",14).attr("markerUnits","userSpaceOnUse").attr("orient","auto").append("path").attr("d","M 19,7 L9,13 L14,7 L9,1 Z")},"barb"),zYe=X((e,r,n)=>{e.append("defs").append("marker").attr("id",n+"_"+r+"-onlyOneStart").attr("class","marker onlyOne "+r).attr("refX",0).attr("refY",9).attr("markerWidth",18).attr("markerHeight",18).attr("orient","auto").append("path").attr("d","M9,0 L9,18 M15,0 L15,18"),e.append("defs").append("marker").attr("id",n+"_"+r+"-onlyOneEnd").attr("class","marker onlyOne "+r).attr("refX",18).attr("refY",9).attr("markerWidth",18).attr("markerHeight",18).attr("orient","auto").append("path").attr("d","M3,0 L3,18 M9,0 L9,18")},"only_one"),FYe=X((e,r,n)=>{const i=e.append("defs").append("marker").attr("id",n+"_"+r+"-zeroOrOneStart").attr("class","marker zeroOrOne "+r).attr("refX",0).attr("refY",9).attr("markerWidth",30).attr("markerHeight",18).attr("orient","auto");i.append("circle").attr("fill","white").attr("cx",21).attr("cy",9).attr("r",6),i.append("path").attr("d","M9,0 L9,18");const s=e.append("defs").append("marker").attr("id",n+"_"+r+"-zeroOrOneEnd").attr("class","marker zeroOrOne "+r).attr("refX",30).attr("refY",9).attr("markerWidth",30).attr("markerHeight",18).attr("orient","auto");s.append("circle").attr("fill","white").attr("cx",9).attr("cy",9).attr("r",6),s.append("path").attr("d","M21,0 L21,18")},"zero_or_one"),HYe=X((e,r,n)=>{e.append("defs").append("marker").attr("id",n+"_"+r+"-oneOrMoreStart").attr("class","marker oneOrMore "+r).attr("refX",18).attr("refY",18).attr("markerWidth",45).attr("markerHeight",36).attr("orient","auto").append("path").attr("d","M0,18 Q 18,0 36,18 Q 18,36 0,18 M42,9 L42,27"),e.append("defs").append("marker").attr("id",n+"_"+r+"-oneOrMoreEnd").attr("class","marker oneOrMore "+r).attr("refX",27).attr("refY",18).attr("markerWidth",45).attr("markerHeight",36).attr("orient","auto").append("path").attr("d","M3,9 L3,27 M9,18 Q27,0 45,18 Q27,36 9,18")},"one_or_more"),WYe=X((e,r,n)=>{const i=e.append("defs").append("marker").attr("id",n+"_"+r+"-zeroOrMoreStart").attr("class","marker zeroOrMore "+r).attr("refX",18).attr("refY",18).attr("markerWidth",57).attr("markerHeight",36).attr("orient","auto");i.append("circle").attr("fill","white").attr("cx",48).attr("cy",18).attr("r",6),i.append("path").attr("d","M0,18 Q18,0 36,18 Q18,36 0,18");const s=e.append("defs").append("marker").attr("id",n+"_"+r+"-zeroOrMoreEnd").attr("class","marker zeroOrMore "+r).attr("refX",39).attr("refY",18).attr("markerWidth",57).attr("markerHeight",36).attr("orient","auto");s.append("circle").attr("fill","white").attr("cx",9).attr("cy",18).attr("r",6),s.append("path").attr("d","M21,18 Q39,0 57,18 Q39,36 21,18")},"zero_or_more"),UYe=X((e,r,n)=>{e.append("defs").append("marker").attr("id",n+"_"+r+"-requirement_arrowEnd").attr("refX",20).attr("refY",10).attr("markerWidth",20).attr("markerHeight",20).attr("orient","auto").append("path").attr("d",`M0,0
1168
1168
  L20,10
1169
1169
  M20,10
1170
- L0,20`)},"requirement_arrow"),VYe=X((e,r,n)=>{const i=e.append("defs").append("marker").attr("id",n+"_"+r+"-requirement_containsStart").attr("refX",0).attr("refY",10).attr("markerWidth",20).attr("markerHeight",20).attr("orient","auto").append("g");i.append("circle").attr("cx",10).attr("cy",10).attr("r",9).attr("fill","none"),i.append("line").attr("x1",1).attr("x2",19).attr("y1",10).attr("y2",10),i.append("line").attr("y1",1).attr("y2",19).attr("x1",10).attr("x2",10)},"requirement_contains"),qYe={extension:OYe,composition:MYe,aggregation:RYe,dependency:PYe,lollipop:LYe,point:$Ye,circle:DYe,cross:IYe,barb:BYe,only_one:zYe,zero_or_one:FYe,one_or_more:HYe,zero_or_more:WYe,requirement_arrow:UYe,requirement_contains:VYe},GYe=AYe,KYe={common:lk,getConfig:rl,insertCluster:eYe,insertEdge:EYe,insertEdgeLabel:SYe,insertMarkers:GYe,insertNode:Loe,interpolateToCurve:NP,labelHelper:un,log:Ot,positionEdgeLabel:kYe},Jw={},Boe=X(e=>{for(const r of e)Jw[r.name]=r},"registerLayoutLoaders"),YYe=X(()=>{Boe([{name:"dagre",loader:X(async()=>await nt(()=>import("./dagre-KLK3FWXG-DvVqKE-N.js"),__vite__mapDeps([47,48,49,50,51,52]),import.meta.url),"loader")},{name:"cose-bilkent",loader:X(async()=>await nt(()=>import("./cose-bilkent-S5V4N54A-B9xY0Kqy.js"),__vite__mapDeps([53,54]),import.meta.url),"loader")}])},"registerDefaultLayoutLoaders");YYe();var Jxt=X(async(e,r)=>{if(!(e.layoutAlgorithm in Jw))throw new Error(`Unknown layout algorithm: ${e.layoutAlgorithm}`);const n=Jw[e.layoutAlgorithm];return(await n.loader()).render(e,r,KYe,{algorithm:n.algorithm})},"render"),Zxt=X((e="",{fallback:r="dagre"}={})=>{if(e in Jw)return e;if(r in Jw)return Ot.warn(`Layout algorithm ${e} is not registered. Using ${r} as fallback.`),r;throw new Error(`Both layout algorithms ${e} and ${r} are not registered.`)},"getRegisteredLayoutAlgorithm"),XYe=mie(Object.keys,Object),JYe=Object.prototype,ZYe=JYe.hasOwnProperty;function QYe(e){if(!$N(e))return XYe(e);var r=[];for(var n in Object(e))ZYe.call(e,n)&&n!="constructor"&&r.push(n);return r}var JO=jy(hh,"DataView"),ZO=jy(hh,"Promise"),QO=jy(hh,"Set"),e7=jy(hh,"WeakMap"),KH="[object Map]",eXe="[object Object]",YH="[object Promise]",XH="[object Set]",JH="[object WeakMap]",ZH="[object DataView]",tXe=Cy(JO),rXe=Cy(Yw),nXe=Cy(ZO),iXe=Cy(QO),sXe=Cy(e7),k0=ky;(JO&&k0(new JO(new ArrayBuffer(1)))!=ZH||Yw&&k0(new Yw)!=KH||ZO&&k0(ZO.resolve())!=YH||QO&&k0(new QO)!=XH||e7&&k0(new e7)!=JH)&&(k0=function(e){var r=ky(e),n=r==eXe?e.constructor:void 0,i=n?Cy(n):"";if(i)switch(i){case tXe:return ZH;case rXe:return KH;case nXe:return YH;case iXe:return XH;case sXe:return JH}return r});var oXe="[object Map]",aXe="[object Set]",lXe=Object.prototype,cXe=lXe.hasOwnProperty;function QH(e){if(e==null)return!0;if(DN(e)&&(zj(e)||typeof e=="string"||typeof e.splice=="function"||CP(e)||jP(e)||Bj(e)))return!e.length;var r=k0(e);if(r==oXe||r==aXe)return!e.size;if($N(e))return!QYe(e).length;for(var n in e)if(cXe.call(e,n))return!1;return!0}var zoe="c4",uXe=X(e=>/^\s*C4Context|C4Container|C4Component|C4Dynamic|C4Deployment/.test(e),"detector"),dXe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./c4Diagram-IC4MRINW-CHW6f5Qe.js");return{diagram:r}},__vite__mapDeps([55,56]),import.meta.url);return{id:zoe,diagram:e}},"loader"),hXe={id:zoe,detector:uXe,loader:dXe},fXe=hXe,Foe="flowchart",pXe=X((e,r)=>{var n,i;return((n=r==null?void 0:r.flowchart)==null?void 0:n.defaultRenderer)==="dagre-wrapper"||((i=r==null?void 0:r.flowchart)==null?void 0:i.defaultRenderer)==="elk"?!1:/^\s*graph/.test(e)},"detector"),mXe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./flowDiagram-PKNHOUZH-H0hHU5_y.js");return{diagram:r}},__vite__mapDeps([57,58,56,59,60,61]),import.meta.url);return{id:Foe,diagram:e}},"loader"),gXe={id:Foe,detector:pXe,loader:mXe},yXe=gXe,Hoe="flowchart-v2",vXe=X((e,r)=>{var n,i,s;return((n=r==null?void 0:r.flowchart)==null?void 0:n.defaultRenderer)==="dagre-d3"?!1:(((i=r==null?void 0:r.flowchart)==null?void 0:i.defaultRenderer)==="elk"&&(r.layout="elk"),/^\s*graph/.test(e)&&((s=r==null?void 0:r.flowchart)==null?void 0:s.defaultRenderer)==="dagre-wrapper"?!0:/^\s*flowchart/.test(e))},"detector"),xXe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./flowDiagram-PKNHOUZH-H0hHU5_y.js");return{diagram:r}},__vite__mapDeps([57,58,56,59,60,61]),import.meta.url);return{id:Hoe,diagram:e}},"loader"),bXe={id:Hoe,detector:vXe,loader:xXe},_Xe=bXe,Woe="er",wXe=X(e=>/^\s*erDiagram/.test(e),"detector"),SXe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./erDiagram-INFDFZHY-B_jfKATM.js");return{diagram:r}},__vite__mapDeps([62,59,60,61]),import.meta.url);return{id:Woe,diagram:e}},"loader"),kXe={id:Woe,detector:wXe,loader:SXe},CXe=kXe,Uoe="gitGraph",jXe=X(e=>/^\s*gitGraph/.test(e),"detector"),NXe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./gitGraphDiagram-K3NZZRJ6-CfKN67ux.js");return{diagram:r}},__vite__mapDeps([63,64,65,66,49,51,52]),import.meta.url);return{id:Uoe,diagram:e}},"loader"),TXe={id:Uoe,detector:jXe,loader:NXe},EXe=TXe,Voe="gantt",AXe=X(e=>/^\s*gantt/.test(e),"detector"),OXe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./ganttDiagram-A5KZAMGK-DvgDjtyk.js");return{diagram:r}},__vite__mapDeps([67,68,69]),import.meta.url);return{id:Voe,diagram:e}},"loader"),MXe={id:Voe,detector:AXe,loader:OXe},RXe=MXe,qoe="info",PXe=X(e=>/^\s*info/.test(e),"detector"),LXe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./infoDiagram-LFFYTUFH-DfbwpZJy.js");return{diagram:r}},__vite__mapDeps([70,66,49,51,52]),import.meta.url);return{id:qoe,diagram:e}},"loader"),$Xe={id:qoe,detector:PXe,loader:LXe},Goe="pie",DXe=X(e=>/^\s*pie/.test(e),"detector"),IXe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./pieDiagram-SKSYHLDU-BocSJCkn.js");return{diagram:r}},__vite__mapDeps([71,64,66,49,51,52,72]),import.meta.url);return{id:Goe,diagram:e}},"loader"),BXe={id:Goe,detector:DXe,loader:IXe},Koe="quadrantChart",zXe=X(e=>/^\s*quadrantChart/.test(e),"detector"),FXe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./quadrantDiagram-337W2JSQ-CPufpGVV.js");return{diagram:r}},__vite__mapDeps([73,68,69]),import.meta.url);return{id:Koe,diagram:e}},"loader"),HXe={id:Koe,detector:zXe,loader:FXe},WXe=HXe,Yoe="xychart",UXe=X(e=>/^\s*xychart(-beta)?/.test(e),"detector"),VXe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./xychartDiagram-JWTSCODW-BlqNihqM.js");return{diagram:r}},__vite__mapDeps([74,68,69]),import.meta.url);return{id:Yoe,diagram:e}},"loader"),qXe={id:Yoe,detector:UXe,loader:VXe},GXe=qXe,Xoe="requirement",KXe=X(e=>/^\s*requirement(Diagram)?/.test(e),"detector"),YXe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./requirementDiagram-Z7DCOOCP-WXSlOcDd.js");return{diagram:r}},__vite__mapDeps([75,59,60]),import.meta.url);return{id:Xoe,diagram:e}},"loader"),XXe={id:Xoe,detector:KXe,loader:YXe},JXe=XXe,Joe="sequence",ZXe=X(e=>/^\s*sequenceDiagram/.test(e),"detector"),QXe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./sequenceDiagram-2WXFIKYE-D6tIU8do.js");return{diagram:r}},__vite__mapDeps([76,56,65]),import.meta.url);return{id:Joe,diagram:e}},"loader"),eJe={id:Joe,detector:ZXe,loader:QXe},tJe=eJe,Zoe="class",rJe=X((e,r)=>{var n;return((n=r==null?void 0:r.class)==null?void 0:n.defaultRenderer)==="dagre-wrapper"?!1:/^\s*classDiagram/.test(e)},"detector"),nJe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./classDiagram-VBA2DB6C-BMhQiG2d.js");return{diagram:r}},__vite__mapDeps([77,78,58,56,59,60]),import.meta.url);return{id:Zoe,diagram:e}},"loader"),iJe={id:Zoe,detector:rJe,loader:nJe},sJe=iJe,Qoe="classDiagram",oJe=X((e,r)=>{var n;return/^\s*classDiagram/.test(e)&&((n=r==null?void 0:r.class)==null?void 0:n.defaultRenderer)==="dagre-wrapper"?!0:/^\s*classDiagram-v2/.test(e)},"detector"),aJe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./classDiagram-v2-RAHNMMFH-BMhQiG2d.js");return{diagram:r}},__vite__mapDeps([79,78,58,56,59,60]),import.meta.url);return{id:Qoe,diagram:e}},"loader"),lJe={id:Qoe,detector:oJe,loader:aJe},cJe=lJe,eae="state",uJe=X((e,r)=>{var n;return((n=r==null?void 0:r.state)==null?void 0:n.defaultRenderer)==="dagre-wrapper"?!1:/^\s*stateDiagram/.test(e)},"detector"),dJe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./stateDiagram-RAJIS63D-DiKyETyd.js");return{diagram:r}},__vite__mapDeps([80,81,59,60,48,49,50,51]),import.meta.url);return{id:eae,diagram:e}},"loader"),hJe={id:eae,detector:uJe,loader:dJe},fJe=hJe,tae="stateDiagram",pJe=X((e,r)=>{var n;return!!(/^\s*stateDiagram-v2/.test(e)||/^\s*stateDiagram/.test(e)&&((n=r==null?void 0:r.state)==null?void 0:n.defaultRenderer)==="dagre-wrapper")},"detector"),mJe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./stateDiagram-v2-FVOUBMTO-CwYz7g9Z.js");return{diagram:r}},__vite__mapDeps([82,81,59,60]),import.meta.url);return{id:tae,diagram:e}},"loader"),gJe={id:tae,detector:pJe,loader:mJe},yJe=gJe,rae="journey",vJe=X(e=>/^\s*journey/.test(e),"detector"),xJe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./journeyDiagram-4ABVD52K-D7_IzKwt.js");return{diagram:r}},__vite__mapDeps([83,58,56,72]),import.meta.url);return{id:rae,diagram:e}},"loader"),bJe={id:rae,detector:vJe,loader:xJe},_Je=bJe,wJe=X((e,r,n)=>{Ot.debug(`rendering svg for syntax error
1171
- `);const i=yWe(r),s=i.append("g");i.attr("viewBox","0 0 2412 512"),Ote(i,100,512,!0),s.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"),s.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"),s.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"),s.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"),s.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"),s.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"),s.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"),s.append("text").attr("class","error-text").attr("x",1250).attr("y",400).attr("font-size","100px").style("text-anchor","middle").text(`mermaid version ${n}`)},"draw"),nae={draw:wJe},SJe=nae,kJe={db:{},renderer:nae,parser:{parse:X(()=>{},"parse")}},CJe=kJe,iae="flowchart-elk",jJe=X((e,r={})=>{var n;return/^\s*flowchart-elk/.test(e)||/^\s*(flowchart|graph)/.test(e)&&((n=r==null?void 0:r.flowchart)==null?void 0:n.defaultRenderer)==="elk"?(r.layout="elk",!0):!1},"detector"),NJe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./flowDiagram-PKNHOUZH-H0hHU5_y.js");return{diagram:r}},__vite__mapDeps([57,58,56,59,60,61]),import.meta.url);return{id:iae,diagram:e}},"loader"),TJe={id:iae,detector:jJe,loader:NJe},EJe=TJe,sae="timeline",AJe=X(e=>/^\s*timeline/.test(e),"detector"),OJe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./timeline-definition-YZTLITO2-0HBRmTgM.js");return{diagram:r}},__vite__mapDeps([84,72]),import.meta.url);return{id:sae,diagram:e}},"loader"),MJe={id:sae,detector:AJe,loader:OJe},RJe=MJe,oae="mindmap",PJe=X(e=>/^\s*mindmap/.test(e),"detector"),LJe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./mindmap-definition-YRQLILUH-ivr0jipJ.js");return{diagram:r}},__vite__mapDeps([85,59,60]),import.meta.url);return{id:oae,diagram:e}},"loader"),$Je={id:oae,detector:PJe,loader:LJe},DJe=$Je,aae="kanban",IJe=X(e=>/^\s*kanban/.test(e),"detector"),BJe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./kanban-definition-K7BYSVSG-ZHQe-znY.js");return{diagram:r}},__vite__mapDeps([86,58]),import.meta.url);return{id:aae,diagram:e}},"loader"),zJe={id:aae,detector:IJe,loader:BJe},FJe=zJe,lae="sankey",HJe=X(e=>/^\s*sankey(-beta)?/.test(e),"detector"),WJe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./sankeyDiagram-WA2Y5GQK-BlMmJCU5.js");return{diagram:r}},[],import.meta.url);return{id:lae,diagram:e}},"loader"),UJe={id:lae,detector:HJe,loader:WJe},VJe=UJe,cae="packet",qJe=X(e=>/^\s*packet(-beta)?/.test(e),"detector"),GJe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./diagram-P4PSJMXO-CnefTtmg.js");return{diagram:r}},__vite__mapDeps([87,64,66,49,51,52]),import.meta.url);return{id:cae,diagram:e}},"loader"),KJe={id:cae,detector:qJe,loader:GJe},uae="radar",YJe=X(e=>/^\s*radar-beta/.test(e),"detector"),XJe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./diagram-IFDJBPK2-9oSdzt-l.js");return{diagram:r}},__vite__mapDeps([88,64,66,49,51,52]),import.meta.url);return{id:uae,diagram:e}},"loader"),JJe={id:uae,detector:YJe,loader:XJe},dae="block",ZJe=X(e=>/^\s*block(-beta)?/.test(e),"detector"),QJe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./blockDiagram-WCTKOSBZ-Ck9FbYo9.js");return{diagram:r}},__vite__mapDeps([89,58,52,49,48,61]),import.meta.url);return{id:dae,diagram:e}},"loader"),eZe={id:dae,detector:ZJe,loader:QJe},tZe=eZe,hae="architecture",rZe=X(e=>/^\s*architecture/.test(e),"detector"),nZe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./architectureDiagram-2XIMDMQ5-CB1I42fi.js");return{diagram:r}},__vite__mapDeps([90,64,66,49,51,52,54]),import.meta.url);return{id:hae,diagram:e}},"loader"),iZe={id:hae,detector:rZe,loader:nZe},sZe=iZe,fae="ishikawa",oZe=X(e=>/^\s*ishikawa(-beta)?\b/i.test(e),"detector"),aZe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./ishikawaDiagram-PHBUUO56-DFAbvEqY.js");return{diagram:r}},[],import.meta.url);return{id:fae,diagram:e}},"loader"),lZe={id:fae,detector:oZe,loader:aZe},pae="venn",cZe=X(e=>/^\s*venn-beta/.test(e),"detector"),uZe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./vennDiagram-LZ73GAT5-CttEpptN.js");return{diagram:r}},[],import.meta.url);return{id:pae,diagram:e}},"loader"),dZe={id:pae,detector:cZe,loader:uZe},hZe=dZe,mae="treemap",fZe=X(e=>/^\s*treemap/.test(e),"detector"),pZe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./diagram-E7M64L7V-BFxtLr_J.js");return{diagram:r}},__vite__mapDeps([91,60,64,66,49,51,52,69]),import.meta.url);return{id:mae,diagram:e}},"loader"),mZe={id:mae,detector:fZe,loader:pZe},eW=!1,VN=X(()=>{eW||(eW=!0,_j("error",CJe,e=>e.toLowerCase().trim()==="error"),_j("---",{db:{clear:X(()=>{},"clear")},styles:{},renderer:{draw:X(()=>{},"draw")},parser:{parse:X(()=>{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")},"parse")},init:X(()=>null,"init")},e=>e.toLowerCase().trimStart().startsWith("---")),aO(EJe,DJe,sZe),aO(fXe,FJe,cJe,sJe,CXe,RXe,$Xe,BXe,JXe,tJe,_Xe,yXe,RJe,EXe,yJe,fJe,_Je,WXe,VJe,KJe,GXe,tZe,JJe,lZe,mZe,hZe))},"addDiagrams"),gZe=X(async()=>{Ot.debug("Loading registered diagrams");const r=(await Promise.allSettled(Object.entries(ry).map(async([n,{detector:i,loader:s}])=>{if(s)try{dO(n)}catch{try{const{diagram:o,id:a}=await s();_j(a,o,i)}catch(o){throw Ot.error(`Failed to load external diagram with key ${n}. Removing from detectors.`),delete ry[n],o}}}))).filter(n=>n.status==="rejected");if(r.length>0){Ot.error(`Failed to load ${r.length} external diagrams`);for(const n of r)Ot.error(n);throw new Error(`Failed to load ${r.length} external diagrams`)}},"loadRegisteredDiagrams"),yZe="graphics-document document";function gae(e,r){e.attr("role",yZe),r!==""&&e.attr("aria-roledescription",r)}X(gae,"setA11yDiagramInfo");function yae(e,r,n,i){if(e.insert!==void 0){if(n){const s=`chart-desc-${i}`;e.attr("aria-describedby",s),e.insert("desc",":first-child").attr("id",s).text(n)}if(r){const s=`chart-title-${i}`;e.attr("aria-labelledby",s),e.insert("title",":first-child").attr("id",s).text(r)}}}X(yae,"addSVGa11yTitleDescription");var q0,t7=(q0=class{constructor(r,n,i,s,o){this.type=r,this.text=n,this.db=i,this.parser=s,this.renderer=o}static async fromText(r,n={}){var d,h;const i=rl(),s=K9(r,i);r=bGe(r)+`
1170
+ L0,20`)},"requirement_arrow"),VYe=X((e,r,n)=>{const i=e.append("defs").append("marker").attr("id",n+"_"+r+"-requirement_containsStart").attr("refX",0).attr("refY",10).attr("markerWidth",20).attr("markerHeight",20).attr("orient","auto").append("g");i.append("circle").attr("cx",10).attr("cy",10).attr("r",9).attr("fill","none"),i.append("line").attr("x1",1).attr("x2",19).attr("y1",10).attr("y2",10),i.append("line").attr("y1",1).attr("y2",19).attr("x1",10).attr("x2",10)},"requirement_contains"),qYe={extension:OYe,composition:MYe,aggregation:RYe,dependency:PYe,lollipop:LYe,point:$Ye,circle:DYe,cross:IYe,barb:BYe,only_one:zYe,zero_or_one:FYe,one_or_more:HYe,zero_or_more:WYe,requirement_arrow:UYe,requirement_contains:VYe},GYe=AYe,KYe={common:lk,getConfig:rl,insertCluster:eYe,insertEdge:EYe,insertEdgeLabel:SYe,insertMarkers:GYe,insertNode:Loe,interpolateToCurve:NP,labelHelper:un,log:Ot,positionEdgeLabel:kYe},Jw={},Boe=X(e=>{for(const r of e)Jw[r.name]=r},"registerLayoutLoaders"),YYe=X(()=>{Boe([{name:"dagre",loader:X(async()=>await nt(()=>import("./dagre-KLK3FWXG-DIu0KirA.js"),__vite__mapDeps([47,48,49,50,51,52]),import.meta.url),"loader")},{name:"cose-bilkent",loader:X(async()=>await nt(()=>import("./cose-bilkent-S5V4N54A-CAb2XzjW.js"),__vite__mapDeps([53,54]),import.meta.url),"loader")}])},"registerDefaultLayoutLoaders");YYe();var Jxt=X(async(e,r)=>{if(!(e.layoutAlgorithm in Jw))throw new Error(`Unknown layout algorithm: ${e.layoutAlgorithm}`);const n=Jw[e.layoutAlgorithm];return(await n.loader()).render(e,r,KYe,{algorithm:n.algorithm})},"render"),Zxt=X((e="",{fallback:r="dagre"}={})=>{if(e in Jw)return e;if(r in Jw)return Ot.warn(`Layout algorithm ${e} is not registered. Using ${r} as fallback.`),r;throw new Error(`Both layout algorithms ${e} and ${r} are not registered.`)},"getRegisteredLayoutAlgorithm"),XYe=mie(Object.keys,Object),JYe=Object.prototype,ZYe=JYe.hasOwnProperty;function QYe(e){if(!$N(e))return XYe(e);var r=[];for(var n in Object(e))ZYe.call(e,n)&&n!="constructor"&&r.push(n);return r}var JO=jy(hh,"DataView"),ZO=jy(hh,"Promise"),QO=jy(hh,"Set"),e7=jy(hh,"WeakMap"),KH="[object Map]",eXe="[object Object]",YH="[object Promise]",XH="[object Set]",JH="[object WeakMap]",ZH="[object DataView]",tXe=Cy(JO),rXe=Cy(Yw),nXe=Cy(ZO),iXe=Cy(QO),sXe=Cy(e7),k0=ky;(JO&&k0(new JO(new ArrayBuffer(1)))!=ZH||Yw&&k0(new Yw)!=KH||ZO&&k0(ZO.resolve())!=YH||QO&&k0(new QO)!=XH||e7&&k0(new e7)!=JH)&&(k0=function(e){var r=ky(e),n=r==eXe?e.constructor:void 0,i=n?Cy(n):"";if(i)switch(i){case tXe:return ZH;case rXe:return KH;case nXe:return YH;case iXe:return XH;case sXe:return JH}return r});var oXe="[object Map]",aXe="[object Set]",lXe=Object.prototype,cXe=lXe.hasOwnProperty;function QH(e){if(e==null)return!0;if(DN(e)&&(zj(e)||typeof e=="string"||typeof e.splice=="function"||CP(e)||jP(e)||Bj(e)))return!e.length;var r=k0(e);if(r==oXe||r==aXe)return!e.size;if($N(e))return!QYe(e).length;for(var n in e)if(cXe.call(e,n))return!1;return!0}var zoe="c4",uXe=X(e=>/^\s*C4Context|C4Container|C4Component|C4Dynamic|C4Deployment/.test(e),"detector"),dXe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./c4Diagram-IC4MRINW-DX6Shx7D.js");return{diagram:r}},__vite__mapDeps([55,56]),import.meta.url);return{id:zoe,diagram:e}},"loader"),hXe={id:zoe,detector:uXe,loader:dXe},fXe=hXe,Foe="flowchart",pXe=X((e,r)=>{var n,i;return((n=r==null?void 0:r.flowchart)==null?void 0:n.defaultRenderer)==="dagre-wrapper"||((i=r==null?void 0:r.flowchart)==null?void 0:i.defaultRenderer)==="elk"?!1:/^\s*graph/.test(e)},"detector"),mXe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./flowDiagram-PKNHOUZH-DnKunoWE.js");return{diagram:r}},__vite__mapDeps([57,58,56,59,60,61]),import.meta.url);return{id:Foe,diagram:e}},"loader"),gXe={id:Foe,detector:pXe,loader:mXe},yXe=gXe,Hoe="flowchart-v2",vXe=X((e,r)=>{var n,i,s;return((n=r==null?void 0:r.flowchart)==null?void 0:n.defaultRenderer)==="dagre-d3"?!1:(((i=r==null?void 0:r.flowchart)==null?void 0:i.defaultRenderer)==="elk"&&(r.layout="elk"),/^\s*graph/.test(e)&&((s=r==null?void 0:r.flowchart)==null?void 0:s.defaultRenderer)==="dagre-wrapper"?!0:/^\s*flowchart/.test(e))},"detector"),xXe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./flowDiagram-PKNHOUZH-DnKunoWE.js");return{diagram:r}},__vite__mapDeps([57,58,56,59,60,61]),import.meta.url);return{id:Hoe,diagram:e}},"loader"),bXe={id:Hoe,detector:vXe,loader:xXe},_Xe=bXe,Woe="er",wXe=X(e=>/^\s*erDiagram/.test(e),"detector"),SXe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./erDiagram-INFDFZHY-B6cJ6aKk.js");return{diagram:r}},__vite__mapDeps([62,59,60,61]),import.meta.url);return{id:Woe,diagram:e}},"loader"),kXe={id:Woe,detector:wXe,loader:SXe},CXe=kXe,Uoe="gitGraph",jXe=X(e=>/^\s*gitGraph/.test(e),"detector"),NXe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./gitGraphDiagram-K3NZZRJ6-C-ErQxYo.js");return{diagram:r}},__vite__mapDeps([63,64,65,66,49,51,52]),import.meta.url);return{id:Uoe,diagram:e}},"loader"),TXe={id:Uoe,detector:jXe,loader:NXe},EXe=TXe,Voe="gantt",AXe=X(e=>/^\s*gantt/.test(e),"detector"),OXe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./ganttDiagram-A5KZAMGK-BR7KrsV2.js");return{diagram:r}},__vite__mapDeps([67,68,69]),import.meta.url);return{id:Voe,diagram:e}},"loader"),MXe={id:Voe,detector:AXe,loader:OXe},RXe=MXe,qoe="info",PXe=X(e=>/^\s*info/.test(e),"detector"),LXe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./infoDiagram-LFFYTUFH-CbKsgryz.js");return{diagram:r}},__vite__mapDeps([70,66,49,51,52]),import.meta.url);return{id:qoe,diagram:e}},"loader"),$Xe={id:qoe,detector:PXe,loader:LXe},Goe="pie",DXe=X(e=>/^\s*pie/.test(e),"detector"),IXe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./pieDiagram-SKSYHLDU-BZwj0of8.js");return{diagram:r}},__vite__mapDeps([71,64,66,49,51,52,72]),import.meta.url);return{id:Goe,diagram:e}},"loader"),BXe={id:Goe,detector:DXe,loader:IXe},Koe="quadrantChart",zXe=X(e=>/^\s*quadrantChart/.test(e),"detector"),FXe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./quadrantDiagram-337W2JSQ-ClIxI022.js");return{diagram:r}},__vite__mapDeps([73,68,69]),import.meta.url);return{id:Koe,diagram:e}},"loader"),HXe={id:Koe,detector:zXe,loader:FXe},WXe=HXe,Yoe="xychart",UXe=X(e=>/^\s*xychart(-beta)?/.test(e),"detector"),VXe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./xychartDiagram-JWTSCODW-ClidW0sx.js");return{diagram:r}},__vite__mapDeps([74,68,69]),import.meta.url);return{id:Yoe,diagram:e}},"loader"),qXe={id:Yoe,detector:UXe,loader:VXe},GXe=qXe,Xoe="requirement",KXe=X(e=>/^\s*requirement(Diagram)?/.test(e),"detector"),YXe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./requirementDiagram-Z7DCOOCP-IFfsBq00.js");return{diagram:r}},__vite__mapDeps([75,59,60]),import.meta.url);return{id:Xoe,diagram:e}},"loader"),XXe={id:Xoe,detector:KXe,loader:YXe},JXe=XXe,Joe="sequence",ZXe=X(e=>/^\s*sequenceDiagram/.test(e),"detector"),QXe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./sequenceDiagram-2WXFIKYE-B_luBYr6.js");return{diagram:r}},__vite__mapDeps([76,56,65]),import.meta.url);return{id:Joe,diagram:e}},"loader"),eJe={id:Joe,detector:ZXe,loader:QXe},tJe=eJe,Zoe="class",rJe=X((e,r)=>{var n;return((n=r==null?void 0:r.class)==null?void 0:n.defaultRenderer)==="dagre-wrapper"?!1:/^\s*classDiagram/.test(e)},"detector"),nJe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./classDiagram-VBA2DB6C-6vAu_D6k.js");return{diagram:r}},__vite__mapDeps([77,78,58,56,59,60]),import.meta.url);return{id:Zoe,diagram:e}},"loader"),iJe={id:Zoe,detector:rJe,loader:nJe},sJe=iJe,Qoe="classDiagram",oJe=X((e,r)=>{var n;return/^\s*classDiagram/.test(e)&&((n=r==null?void 0:r.class)==null?void 0:n.defaultRenderer)==="dagre-wrapper"?!0:/^\s*classDiagram-v2/.test(e)},"detector"),aJe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./classDiagram-v2-RAHNMMFH-6vAu_D6k.js");return{diagram:r}},__vite__mapDeps([79,78,58,56,59,60]),import.meta.url);return{id:Qoe,diagram:e}},"loader"),lJe={id:Qoe,detector:oJe,loader:aJe},cJe=lJe,eae="state",uJe=X((e,r)=>{var n;return((n=r==null?void 0:r.state)==null?void 0:n.defaultRenderer)==="dagre-wrapper"?!1:/^\s*stateDiagram/.test(e)},"detector"),dJe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./stateDiagram-RAJIS63D-D-WYrcjl.js");return{diagram:r}},__vite__mapDeps([80,81,59,60,48,49,50,51]),import.meta.url);return{id:eae,diagram:e}},"loader"),hJe={id:eae,detector:uJe,loader:dJe},fJe=hJe,tae="stateDiagram",pJe=X((e,r)=>{var n;return!!(/^\s*stateDiagram-v2/.test(e)||/^\s*stateDiagram/.test(e)&&((n=r==null?void 0:r.state)==null?void 0:n.defaultRenderer)==="dagre-wrapper")},"detector"),mJe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./stateDiagram-v2-FVOUBMTO-B2ATdc9J.js");return{diagram:r}},__vite__mapDeps([82,81,59,60]),import.meta.url);return{id:tae,diagram:e}},"loader"),gJe={id:tae,detector:pJe,loader:mJe},yJe=gJe,rae="journey",vJe=X(e=>/^\s*journey/.test(e),"detector"),xJe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./journeyDiagram-4ABVD52K-DUD5gNjq.js");return{diagram:r}},__vite__mapDeps([83,58,56,72]),import.meta.url);return{id:rae,diagram:e}},"loader"),bJe={id:rae,detector:vJe,loader:xJe},_Je=bJe,wJe=X((e,r,n)=>{Ot.debug(`rendering svg for syntax error
1171
+ `);const i=yWe(r),s=i.append("g");i.attr("viewBox","0 0 2412 512"),Ote(i,100,512,!0),s.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"),s.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"),s.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"),s.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"),s.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"),s.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"),s.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"),s.append("text").attr("class","error-text").attr("x",1250).attr("y",400).attr("font-size","100px").style("text-anchor","middle").text(`mermaid version ${n}`)},"draw"),nae={draw:wJe},SJe=nae,kJe={db:{},renderer:nae,parser:{parse:X(()=>{},"parse")}},CJe=kJe,iae="flowchart-elk",jJe=X((e,r={})=>{var n;return/^\s*flowchart-elk/.test(e)||/^\s*(flowchart|graph)/.test(e)&&((n=r==null?void 0:r.flowchart)==null?void 0:n.defaultRenderer)==="elk"?(r.layout="elk",!0):!1},"detector"),NJe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./flowDiagram-PKNHOUZH-DnKunoWE.js");return{diagram:r}},__vite__mapDeps([57,58,56,59,60,61]),import.meta.url);return{id:iae,diagram:e}},"loader"),TJe={id:iae,detector:jJe,loader:NJe},EJe=TJe,sae="timeline",AJe=X(e=>/^\s*timeline/.test(e),"detector"),OJe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./timeline-definition-YZTLITO2-CqnYRrYr.js");return{diagram:r}},__vite__mapDeps([84,72]),import.meta.url);return{id:sae,diagram:e}},"loader"),MJe={id:sae,detector:AJe,loader:OJe},RJe=MJe,oae="mindmap",PJe=X(e=>/^\s*mindmap/.test(e),"detector"),LJe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./mindmap-definition-YRQLILUH-DXQhtB98.js");return{diagram:r}},__vite__mapDeps([85,59,60]),import.meta.url);return{id:oae,diagram:e}},"loader"),$Je={id:oae,detector:PJe,loader:LJe},DJe=$Je,aae="kanban",IJe=X(e=>/^\s*kanban/.test(e),"detector"),BJe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./kanban-definition-K7BYSVSG-DXzciomb.js");return{diagram:r}},__vite__mapDeps([86,58]),import.meta.url);return{id:aae,diagram:e}},"loader"),zJe={id:aae,detector:IJe,loader:BJe},FJe=zJe,lae="sankey",HJe=X(e=>/^\s*sankey(-beta)?/.test(e),"detector"),WJe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./sankeyDiagram-WA2Y5GQK-an0KnQCU.js");return{diagram:r}},[],import.meta.url);return{id:lae,diagram:e}},"loader"),UJe={id:lae,detector:HJe,loader:WJe},VJe=UJe,cae="packet",qJe=X(e=>/^\s*packet(-beta)?/.test(e),"detector"),GJe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./diagram-P4PSJMXO-DQbRSXfR.js");return{diagram:r}},__vite__mapDeps([87,64,66,49,51,52]),import.meta.url);return{id:cae,diagram:e}},"loader"),KJe={id:cae,detector:qJe,loader:GJe},uae="radar",YJe=X(e=>/^\s*radar-beta/.test(e),"detector"),XJe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./diagram-IFDJBPK2-BsEbvT5C.js");return{diagram:r}},__vite__mapDeps([88,64,66,49,51,52]),import.meta.url);return{id:uae,diagram:e}},"loader"),JJe={id:uae,detector:YJe,loader:XJe},dae="block",ZJe=X(e=>/^\s*block(-beta)?/.test(e),"detector"),QJe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./blockDiagram-WCTKOSBZ-CHV7p7YD.js");return{diagram:r}},__vite__mapDeps([89,58,52,49,48,61]),import.meta.url);return{id:dae,diagram:e}},"loader"),eZe={id:dae,detector:ZJe,loader:QJe},tZe=eZe,hae="architecture",rZe=X(e=>/^\s*architecture/.test(e),"detector"),nZe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./architectureDiagram-2XIMDMQ5-DdYS2_FZ.js");return{diagram:r}},__vite__mapDeps([90,64,66,49,51,52,54]),import.meta.url);return{id:hae,diagram:e}},"loader"),iZe={id:hae,detector:rZe,loader:nZe},sZe=iZe,fae="ishikawa",oZe=X(e=>/^\s*ishikawa(-beta)?\b/i.test(e),"detector"),aZe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./ishikawaDiagram-PHBUUO56-BnvFJhGI.js");return{diagram:r}},[],import.meta.url);return{id:fae,diagram:e}},"loader"),lZe={id:fae,detector:oZe,loader:aZe},pae="venn",cZe=X(e=>/^\s*venn-beta/.test(e),"detector"),uZe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./vennDiagram-LZ73GAT5-DL7r5f3I.js");return{diagram:r}},[],import.meta.url);return{id:pae,diagram:e}},"loader"),dZe={id:pae,detector:cZe,loader:uZe},hZe=dZe,mae="treemap",fZe=X(e=>/^\s*treemap/.test(e),"detector"),pZe=X(async()=>{const{diagram:e}=await nt(async()=>{const{diagram:r}=await import("./diagram-E7M64L7V-CuPAALFE.js");return{diagram:r}},__vite__mapDeps([91,60,64,66,49,51,52,69]),import.meta.url);return{id:mae,diagram:e}},"loader"),mZe={id:mae,detector:fZe,loader:pZe},eW=!1,VN=X(()=>{eW||(eW=!0,_j("error",CJe,e=>e.toLowerCase().trim()==="error"),_j("---",{db:{clear:X(()=>{},"clear")},styles:{},renderer:{draw:X(()=>{},"draw")},parser:{parse:X(()=>{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")},"parse")},init:X(()=>null,"init")},e=>e.toLowerCase().trimStart().startsWith("---")),aO(EJe,DJe,sZe),aO(fXe,FJe,cJe,sJe,CXe,RXe,$Xe,BXe,JXe,tJe,_Xe,yXe,RJe,EXe,yJe,fJe,_Je,WXe,VJe,KJe,GXe,tZe,JJe,lZe,mZe,hZe))},"addDiagrams"),gZe=X(async()=>{Ot.debug("Loading registered diagrams");const r=(await Promise.allSettled(Object.entries(ry).map(async([n,{detector:i,loader:s}])=>{if(s)try{dO(n)}catch{try{const{diagram:o,id:a}=await s();_j(a,o,i)}catch(o){throw Ot.error(`Failed to load external diagram with key ${n}. Removing from detectors.`),delete ry[n],o}}}))).filter(n=>n.status==="rejected");if(r.length>0){Ot.error(`Failed to load ${r.length} external diagrams`);for(const n of r)Ot.error(n);throw new Error(`Failed to load ${r.length} external diagrams`)}},"loadRegisteredDiagrams"),yZe="graphics-document document";function gae(e,r){e.attr("role",yZe),r!==""&&e.attr("aria-roledescription",r)}X(gae,"setA11yDiagramInfo");function yae(e,r,n,i){if(e.insert!==void 0){if(n){const s=`chart-desc-${i}`;e.attr("aria-describedby",s),e.insert("desc",":first-child").attr("id",s).text(n)}if(r){const s=`chart-title-${i}`;e.attr("aria-labelledby",s),e.insert("title",":first-child").attr("id",s).text(r)}}}X(yae,"addSVGa11yTitleDescription");var q0,t7=(q0=class{constructor(r,n,i,s,o){this.type=r,this.text=n,this.db=i,this.parser=s,this.renderer=o}static async fromText(r,n={}){var d,h;const i=rl(),s=K9(r,i);r=bGe(r)+`
1172
1172
  `;try{dO(s)}catch{const f=lIe(s);if(!f)throw new yte(`Diagram ${s} not found.`);const{id:g,diagram:v}=await f();_j(g,v)}const{db:o,parser:a,renderer:l,init:u}=dO(s);return a.parser&&(a.parser.yy=o),(d=o.clear)==null||d.call(o),u==null||u(i),n.title&&((h=o.setDiagramTitle)==null||h.call(o,n.title)),await a.parse(r),new q0(s,r,o,a,l)}async render(r,n){await this.renderer.draw(this.text,r,n,this)}getParser(){return this.parser}getType(){return this.type}},X(q0,"Diagram"),q0),tW=[],vZe=X(()=>{tW.forEach(e=>{e()}),tW=[]},"attachFunctions"),xZe=X(e=>e.replace(/^\s*%%(?!{)[^\n]+\n?/gm,"").trimStart(),"cleanupComments");function vae(e){const r=e.match(gte);if(!r)return{text:e,metadata:{}};let n=kUe(r[1],{schema:SUe})??{};n=typeof n=="object"&&!Array.isArray(n)?n:{};const i={};return n.displayMode&&(i.displayMode=n.displayMode.toString()),n.title&&(i.title=n.title.toString()),n.config&&(i.config=n.config),{text:e.slice(r[0].length),metadata:i}}X(vae,"extractFrontMatter");var bZe=X(e=>e.replace(/\r\n?/g,`
1173
1173
  `).replace(/<(\w+)([^>]*)>/g,(r,n,i)=>"<"+n+i.replace(/="([^"]*)"/g,"='$1'")+">"),"cleanupText"),_Ze=X(e=>{const{text:r,metadata:n}=vae(e),{displayMode:i,title:s,config:o={}}=n;return i&&(o.gantt||(o.gantt={}),o.gantt.displayMode=i),{title:s,config:o,text:r}},"processFrontmatter"),wZe=X(e=>{const r=Wd.detectInit(e)??{},n=Wd.detectDirective(e,"wrap");return Array.isArray(n)?r.wrap=n.some(({type:i})=>i==="wrap"):(n==null?void 0:n.type)==="wrap"&&(r.wrap=!0),{text:aGe(e),directive:r}},"processDirectives");function KP(e){const r=bZe(e),n=_Ze(r),i=wZe(n.text),s=MP(n.config,i.directive);return e=xZe(i.text),{code:e,title:n.title,config:s}}X(KP,"preprocessDiagram");function xae(e){const r=new TextEncoder().encode(e),n=Array.from(r,i=>String.fromCodePoint(i)).join("");return btoa(n)}X(xae,"toBase64");var SZe=5e4,kZe="graph TB;a[Maximum text size in diagram exceeded];style a fill:#faa",CZe="sandbox",jZe="loose",NZe="http://www.w3.org/2000/svg",TZe="http://www.w3.org/1999/xlink",EZe="http://www.w3.org/1999/xhtml",AZe="100%",OZe="100%",MZe="border:0;margin:0;",RZe="margin:0",PZe="allow-top-navigation-by-user-activation allow-popups",LZe='The "iframe" tag is not supported by your browser.',$Ze=["foreignobject"],DZe=["dominant-baseline"];function YP(e){const r=KP(e);return xj(),kIe(r.config??{}),r}X(YP,"processAndSetConfigs");async function bae(e,r){VN();try{const{code:n,config:i}=YP(e);return{diagramType:(await wae(n)).type,config:i}}catch(n){if(r!=null&&r.suppressErrors)return!1;throw n}}X(bae,"parse");var rW=X((e,r,n=[])=>`
1174
1174
  .${e} ${r} { ${n.join(" !important; ")} !important; }`,"cssImportantStyles"),IZe=X((e,r=new Map)=>{let n="";if(e.themeCSS!==void 0&&(n+=`
@@ -1212,7 +1212,7 @@ ${e.themeCSS}`),e.fontFamily!==void 0&&(n+=`
1212
1212
  `),projectId:i??null,sessionId:n??null,sourceType:Jet,sourceId:r,sourceSurface:"chat",tags:["memory-feedback","feedback",o.tag]}}function ttt(e){return e.content.length>0||e.userDisplayText.length>0||e.userDisplaySegments.length>0||e.imageAttachmentCount>0}function rtt(){return["fixed left-1/2 bottom-[max(0.75rem,env(safe-area-inset-bottom))] z-50","w-[min(42rem,calc(100vw-1rem))] max-w-[calc(100vw-1rem)] -translate-x-1/2","md:static md:w-full md:max-w-3xl md:translate-x-0"].join(" ")}function ntt(e){return["space-y-3 origin-bottom transition-opacity duration-150 ease-out",e?"opacity-100":"opacity-0"].join(" ")}const itt=3;function FW(e,r){return!!(e&&e!=="jait"&&r.length>=itt)}const HW=/<pre[^>]*><code>([\s\S]*)<\/code><\/pre>/;function WW(){return c.jsx("span",{className:"inline-flex items-center gap-1",children:[0,1,2].map(e=>c.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current animate-pulse",style:{animationDelay:`${e*160}ms`}},e))})}function stt(e){const r=e.toLowerCase();return!r||r==="text"||r==="plain"?"txt":r==="shell"||r==="sh"?"bash":r}function ott({code:e,language:r,className:n}){const[i,s]=y.useState(null);return y.useEffect(()=>{let o=!1;const a=setTimeout(()=>{(async()=>{var h,f;const u=document.documentElement.classList.contains("dark")?"github-dark":"github-light",d=stt(r);try{const g=await $B(e,{lang:d,theme:u});if(o)return;s(((h=g.match(HW))==null?void 0:h[1])??null)}catch{try{const g=await $B(e,{lang:"txt",theme:u});if(o)return;s(((f=g.match(HW))==null?void 0:f[1])??null)}catch{o||s(null)}}})()},150);return()=>{o=!0,clearTimeout(a)}},[e,r]),i?c.jsx("code",{className:Ae(n,"whitespace-pre"),dangerouslySetInnerHTML:{__html:i}}):c.jsx("code",{className:Ae(n,"whitespace-pre"),children:e})}function cle(e){return"prose dark:prose-invert max-w-none break-words [overflow-wrap:anywhere] prose-pre:bg-muted prose-pre:border prose-pre:max-w-full prose-pre:overflow-x-auto prose-code:before:content-none prose-code:after:content-none prose-p:leading-relaxed [font-size:0.9rem]"}function att(e){const r=e.replace(/\\/g,"/"),n=r.split("/");return n[n.length-1]??r}function ltt({href:e,target:r,onOpenPath:n}){const i=att(r.path),s=r.line?`L${r.line}${r.column?`:${r.column}`:""}`:null;return c.jsxs("a",{href:e,className:Ae("not-prose inline-flex max-w-full items-center gap-1.5 rounded-md border border-border/70 bg-muted/45 px-2 py-1 align-middle text-xs font-medium leading-none text-foreground no-underline transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"),title:r.path,onClick:o=>{o.preventDefault(),n(r.path,r.line,r.column)},children:[c.jsx(Zo,{filename:i,className:"h-3.5 w-3.5 shrink-0"}),c.jsx("span",{className:"max-w-[220px] truncate",children:i}),s?c.jsx("span",{className:"shrink-0 rounded bg-background/80 px-1 py-0.5 text-2xs text-muted-foreground",children:s}):null]})}function ule(e){return{pre:({children:r})=>c.jsx(c.Fragment,{children:r}),code:({node:r,className:n,children:i,ref:s,...o})=>{var l,u;if(!(((l=r==null?void 0:r.position)==null?void 0:l.start.line)===((u=r==null?void 0:r.position)==null?void 0:u.end.line)&&!n)){const d=typeof n=="string"&&n.replace(/^language-/,"").split(" ")[0]||"text",h=String(i??"").replace(/\n$/,"");return c.jsxs(GEe,{code:h,language:d,children:[c.jsxs(KEe,{children:[c.jsx(YEe,{children:c.jsx(XEe,{children:d})}),c.jsx(JEe,{children:c.jsx(ZEe,{})})]}),c.jsx("div",{className:"overflow-x-auto px-3 py-2 text-sm",children:c.jsx(ott,{code:h,language:d,className:n})})]})}return c.jsx("code",{className:Ae("not-prose inline-flex max-w-full items-baseline rounded-md border border-border/70 bg-muted/45 px-2 py-1 align-middle font-mono text-xs font-medium leading-[1.2] text-foreground","shadow-[inset_0_1px_0_hsl(var(--background)/0.55)]"),...o,children:c.jsx("span",{className:"max-w-[32rem] truncate sm:max-w-[40rem]",children:i})})},a:({href:r,ref:n,...i})=>{if(!e)return c.jsx("a",{href:r,...i,children:i.children});const s=Yet(r);return s?c.jsx(ltt,{href:r,target:s,onOpenPath:e}):c.jsx("a",{href:r,...i,children:i.children})},img:({src:r,alt:n,ref:i,...s})=>{const o=typeof r=="string"?$ae(r):null;return o?c.jsx("a",{href:o,target:"_blank",rel:"noreferrer",className:"not-prose block overflow-hidden rounded-xl border border-border/60 bg-muted/20 no-underline",children:c.jsx("img",{src:o,alt:n??"Chat image",loading:"lazy",className:"max-h-[28rem] w-full object-contain bg-background/80",...s})}):c.jsx("span",{className:"inline-flex rounded-md border border-dashed border-border/70 px-2 py-1 text-xs text-muted-foreground",children:"image unavailable"})}}}function ctt({content:e,compact:r,onOpenPath:n}){const i=y.useMemo(()=>ule(n),[n]);return c.jsx("div",{className:cle(),children:c.jsx(qZ,{remarkPlugins:[GZ],components:i,children:e})})}function utt({content:e,compact:r,onOpenPath:n}){const i=y.useMemo(()=>ule(n),[n]),s=({blockMatch:a})=>c.jsx(qZ,{remarkPlugins:[GZ],components:i,children:a.output}),{blockMatches:o}=Ije({llmOutput:e,blocks:[],fallbackBlock:{component:s,lookBack:Nje()},isStreamFinished:!1});return c.jsx("div",{className:cle(),children:o.map((a,l)=>{const u=a.block.component;return c.jsx(u,{blockMatch:a},l)})})}const y7=y.memo(function({content:r,compact:n,isStreaming:i,preferLlmUi:s,onOpenPath:o}){return s&&i?c.jsx(utt,{content:r,compact:n,onOpenPath:o}):c.jsx(ctt,{content:r,compact:n,onOpenPath:o})});y7.displayName="AssistantMarkdown";function dtt({messageId:e,messageIndex:r,messageFromEnd:n,role:i,content:s,contextFlow:o,displayContent:a,referencedFiles:l,displaySegments:u,attachments:d,thinking:h,thinkingDuration:f,toolCalls:g,segments:v,isStreaming:b,compact:_,preferLlmUi:w,provider:S,threadControlThreads:C,onOpenTerminal:j,renderInlineSecretPrompt:E,onEditMessage:A,editComposer:N,onOpenPath:P,onOpenDiff:H,onOpenMemorySource:K,onMemoryFeedback:F}){const B=i==="user",W=_g(),{userDisplayText:D,userDisplaySegments:O}=y.useMemo(()=>{if(!B)return{userDisplayText:s,userDisplaySegments:[]};if(u!=null&&u.length)return{userDisplayText:J0(u),userDisplaySegments:u};if(a){const Fe=lj(a,l);return{userDisplayText:a,userDisplaySegments:Fe}}const Se=JA(s);return{userDisplayText:Se.text,userDisplaySegments:Se.displaySegments}},[B,s,a,l,u]),[I,R]=y.useState(!1),[$,U]=y.useState(!1),[Y,z]=y.useState(!1),[V,Q]=y.useState(!1),[q,re]=y.useState(!1),[ee,ne]=y.useState(!1),[ae,te]=y.useState(null),[ue,he]=y.useState(""),[we,pe]=y.useState([]),[qe,se]=y.useState(null),[it,Ye]=y.useState(null),ht=y.useMemo(()=>{if(!B)return[];const Se=Gs(it??O).flatMap(Fe=>Fe.type==="image"?[{name:Fe.name,mimeType:Fe.mimeType,data:Fe.data,preview:`data:${Fe.mimeType};base64,${Fe.data}`}]:[]);return Se.length>0?Se:d??[]},[d,B,it,O]),qt=B&&ttt({content:s,userDisplayText:qe??D,userDisplaySegments:it??O,imageAttachmentCount:ht.length}),Nt=y.useRef(null),Xt=y.useRef(null),Wt=y.useRef(null),gt=y.useRef(null);y.useEffect(()=>()=>{Nt.current!==null&&window.clearTimeout(Nt.current),Xt.current!==null&&window.clearTimeout(Xt.current)},[]),y.useEffect(()=>{Y||(he(D),pe(O))},[Y,O,D]),y.useEffect(()=>{if(!it&&qe==null)return;const Se=qe===D,Fe=it===O||JSON.stringify(it??[])===JSON.stringify(O);Se&&Fe&&(se(null),Ye(null))},[it,qe,O,D]),y.useEffect(()=>{var Fe;if(!Y){Q(!1);return}const Se=window.requestAnimationFrame(()=>{Q(!0)});return(Fe=gt.current)==null||Fe.focus(),()=>window.cancelAnimationFrame(Se)},[Y]);const Re=()=>{var Fe;const Se=[];if(g&&g.length>0)for(const et of g){const St=et.tool.replace(/_/g,"."),Xe=Object.entries(et.args).filter(([,Ft])=>Ft!=null&&Ft!=="").map(([Ft,ye])=>`${Ft}: ${typeof ye=="string"?ye:JSON.stringify(ye)}`).join(", "),Lt=et.status==="success"?"✓":et.status==="error"?"✗":"…",Et=et.completedAt&&et.startedAt?Jae(et.startedAt,et.completedAt):"";if(Se.push(`[${Lt} ${St}] ${Xe}`),(Fe=et.result)!=null&&Fe.message){const Ft=et.result.message.length>500?et.result.message.slice(0,500)+"…":et.result.message;Se.push(Ft)}Et&&Se.push(`Duration: ${Et}`),Se.push("")}return s&&Se.push(B?zQ(O)||D:s),Se.join(`
1213
1213
  `).trim()},kt=async()=>{const Se=Re();if(!Se)return;const Fe=B?FQ(O):null;try{Fe&&typeof ClipboardItem<"u"&&navigator.clipboard.write?await navigator.clipboard.write([new ClipboardItem({"text/plain":new Blob([Se],{type:"text/plain"}),[aj]:new Blob([Fe],{type:aj})})]):await navigator.clipboard.writeText(Se)}catch{const et=document.createElement("textarea");et.value=Se,et.style.position="fixed",et.style.opacity="0",document.body.appendChild(et),et.focus(),et.select(),document.execCommand("copy"),document.body.removeChild(et)}R(!0),Nt.current!==null&&window.clearTimeout(Nt.current),Nt.current=window.setTimeout(()=>R(!1),1200)},Pt=B&&!!e&&!!A,Ne=Pt,ze=b&&!h&&!(typeof s=="string"?s:"").trim(),Qe=B||!b,lt=!B&&!!e&&!!F&&!b,yt=(ae==null?void 0:ae.status)==="saving",Tt=y.useCallback(()=>{!Pt||q||(he(D),pe(O),z(!0))},[Pt,q,O,D]),dr=y.useCallback(()=>{he(D),pe(O),z(!1)},[O,D]),De=()=>{var Fe;!Pt||Y||typeof window<"u"&&(Fe=window.getSelection())!=null&&Fe.toString().trim()||Tt()},je=y.useCallback(async(Se,Fe)=>{if(!Pt||!e||!A||q)return;const et=C8e(Se??ue,Fe??we,O);if(et){se(et.text),Ye(et.displaySegments),z(!1),re(!0);try{await A(e,et.text,r,n,{referencedFiles:et.referencedFiles,displaySegments:et.displaySegments})}catch(St){throw se(null),Ye(null),z(!0),St}finally{re(!1)}}},[Pt,ue,we,q,e,n,r,A]),be=async(Se,Fe)=>{if(!Pt||!e||!A)return;const et=Se.trim();et&&await A(e,et,r,n,{referencedFiles:(Fe??O).filter(St=>St.type==="file").map(St=>({path:St.path,name:St.name})),displaySegments:Fe??O})},Be=async()=>{if(Ne){U(!0);try{await be(D,O)}finally{U(!1)}}},at=async Se=>{if(!(!lt||!e||yt)&&await W({title:"Memorize this?",description:"This saves a memory feedback item with this assistant message as context. Future agents can use it when reviewing or updating memory for this chat and project.",confirmLabel:"Memorize",cancelLabel:"Cancel"})){te({kind:Se,status:"saving"});try{await(F==null?void 0:F({messageId:e,kind:Se,content:s})),te({kind:Se,status:"saved"}),Xt.current!==null&&window.clearTimeout(Xt.current),Xt.current=window.setTimeout(()=>te(null),1200)}catch{te(null)}}},Ve=(Se,Fe)=>(ae==null?void 0:ae.kind)!==Se?Fe:ae.status==="saving"?c.jsx(Vt,{className:"h-3.5 w-3.5 animate-spin"}):c.jsx(fs,{className:"h-3.5 w-3.5"}),Mt=Se=>Y||!Qe||!s?null:c.jsx("div",{className:Ae("absolute z-10 rounded-full border border-border/70 bg-background p-1","right-1 bottom-[.25rem]","opacity-0 transition-opacity group-hover/message:opacity-100 focus-within:opacity-100","touch-device:opacity-80",I&&"opacity-100"),children:c.jsxs(e8e,{children:[Pt?c.jsx(Ob,{onClick:Tt,"aria-label":"Edit message",tooltip:"Edit message",className:"h-6 w-6",children:c.jsx(bR,{className:"h-3.5 w-3.5"})}):null,Ne?c.jsx(Ob,{onClick:Fe=>{Fe.preventDefault(),Fe.stopPropagation(),Be()},disabled:$,"aria-label":"Retry from this message",tooltip:"Retry from this message",className:"h-6 w-6",children:c.jsx(_Y,{className:Ae("h-3.5 w-3.5",$&&"animate-spin")})}):null,!B&&o?c.jsx(Ob,{onClick:Fe=>{Fe.preventDefault(),Fe.stopPropagation(),ne(!0)},"aria-label":"View LLM context",tooltip:"View LLM context",className:"h-6 w-6",children:c.jsx(Zh,{className:"h-3.5 w-3.5"})}):null,lt?c.jsx(Ob,{onClick:Fe=>{Fe.preventDefault(),Fe.stopPropagation(),at("should_have_remembered")},disabled:yt,"aria-label":zW("should_have_remembered"),tooltip:zW("should_have_remembered"),className:"h-6 w-6",children:Ve("should_have_remembered",c.jsx(Ja,{className:"h-3.5 w-3.5"}))}):null,c.jsx(Ob,{onClick:kt,"aria-label":I?"Copied":"Copy message",tooltip:I?"Copied":"Copy message",className:"h-6 w-6",children:I?c.jsx(fs,{className:"h-3.5 w-3.5"}):c.jsx(ac,{className:"h-3.5 w-3.5"})})]})}),It=B?null:Mt(),rr=!B&&(v==null?void 0:v.some(Se=>Se.type==="thinking"&&Se.content.trim())),nr=B?[]:Xet(o),Ut=nr.length>0?c.jsxs("div",{className:"not-prose flex min-w-0 flex-wrap items-center gap-1.5 text-xs text-muted-foreground",children:[c.jsxs("button",{type:"button",className:"inline-flex max-w-full items-center gap-1.5 rounded-md border border-amber-500/30 bg-amber-500/10 px-2 py-1 font-medium text-amber-700 transition-colors hover:bg-amber-500/15 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 dark:text-amber-200",onClick:Se=>{Se.preventDefault(),Se.stopPropagation(),ne(!0)},title:"Open retrieved memory context",children:[c.jsx(Ja,{className:"h-3.5 w-3.5 shrink-0"}),c.jsx("span",{children:"Memory"}),c.jsx("span",{className:"rounded bg-background/75 px-1 text-2xs",children:nr.length})]}),nr.slice(0,3).map(Se=>{const Fe={memoryId:Se.id,sourceType:Se.sourceType,sourceId:Se.sourceId,sourceSurface:Se.sourceSurface},et=!!(K&&Se.sourceSurface==="chat"&&Se.sourceId);return c.jsxs("button",{type:"button",className:"inline-flex max-w-[220px] items-center gap-1.5 rounded-md border border-border/70 bg-muted/45 px-2 py-1 text-foreground transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",onClick:St=>{St.preventDefault(),St.stopPropagation(),et?K==null||K(Fe):ne(!0)},title:Se.source||Se.id,children:[et?c.jsx(Ud,{className:"h-3.5 w-3.5 shrink-0"}):c.jsx(Ja,{className:"h-3.5 w-3.5 shrink-0"}),c.jsx("span",{className:"truncate",children:Se.source||Se.id})]},Se.id)})]}):null;return c.jsxs(c.Fragment,{children:[c.jsx(QEe,{from:i,className:Ae(_?"py-2":"py-4"),children:c.jsxs("div",{className:Ae("min-w-0 max-w-[85%] space-y-2",B&&"order-1"),children:[!B&&h&&!rr&&c.jsx(WB,{content:h,isStreaming:!!b&&!s,duration:f}),!B&&v&&v.length>0?c.jsxs("div",{className:"relative min-w-0 max-w-full select-text break-words [overflow-wrap:anywhere]",children:[v.map((Se,Fe)=>{if(Se.type==="toolGroup"){const et=(g??[]).filter(Xe=>Se.callIds.includes(Xe.callId)),St=v.slice(Fe+1).some(Xe=>Xe.type==="text"&&typeof Xe.content=="string"&&Xe.content.trim());return et.length>0?FW(S,et)?c.jsx(m7,{provider:S,calls:et,isStreaming:!!b&&Fe===v.length-1,threadControlThreads:C,onOpenTerminal:j,onOpenDiff:H,renderInlineSecretPrompt:E},`tg-${Fe}`):c.jsx(p7,{calls:et,collapsible:St,threadControlThreads:C,onOpenTerminal:j,onOpenDiff:H,renderInlineSecretPrompt:E},`tg-${Fe}`):null}return Se.type==="thinking"?Se.content.trim()?c.jsx(WB,{content:Se.content,isStreaming:!!b&&Fe===v.length-1,duration:f},`th-${Fe}`):null:Se.type==="error"?c.jsxs("div",{className:"flex items-start gap-2.5 rounded-lg border border-red-500/40 bg-red-500/10 px-3 py-2.5 text-sm text-red-600 dark:text-red-400",children:[c.jsx(ev,{className:"mt-0.5 h-4 w-4 shrink-0"}),c.jsx("span",{className:"min-w-0 break-words",children:Se.content})]},`err-${Fe}`):typeof Se.content=="string"&&Se.content.trim()?c.jsx(qT,{"data-message-from":"assistant",className:"max-w-full bg-card/78",children:c.jsx(y7,{content:Se.content,compact:_,isStreaming:!!b&&Fe===v.length-1,preferLlmUi:w,onOpenPath:P})},`ts-${Fe}`):null}),b&&!s&&!v.some(Se=>Se.type==="text"&&typeof Se.content=="string"&&Se.content.trim())&&c.jsx("div",{className:"flex items-center gap-3 px-1 py-1 text-sm text-muted-foreground",children:c.jsx(WW,{})}),It,Ut]}):c.jsxs(c.Fragment,{children:[g&&g.length>0&&(FW(S,g)?c.jsx(m7,{provider:S,calls:g,isStreaming:b,threadControlThreads:C,onOpenTerminal:j,onOpenDiff:H,renderInlineSecretPrompt:E}):c.jsx(p7,{calls:g,collapsible:S!=="jait",threadControlThreads:C,onOpenTerminal:j,onOpenDiff:H,renderInlineSecretPrompt:E})),qt||s?B?Y?c.jsx("div",{className:rtt(),onClick:Se=>Se.stopPropagation(),children:c.jsx("div",{className:ntt(V),children:c.jsx(N_,{ref:gt,draftStateKey:`edit:${e??"user-message"}`,value:ue,segments:we,onChange:Se=>{var Fe;he(Se),pe(((Fe=gt.current)==null?void 0:Fe.getSegments())??[])},onSubmit:(Se,Fe,et)=>{const St=et??[],Xe=J0(St)||ue;pe(St),je(Xe,St)},disabled:q,controlsDisabled:q,placeholder:"Edit message...",onVoiceInput:N==null?void 0:N.onVoiceInput,voiceRecording:N==null?void 0:N.voiceRecording,voiceLevels:N==null?void 0:N.voiceLevels,voiceTranscribing:N==null?void 0:N.voiceTranscribing,onVoiceStop:N==null?void 0:N.onVoiceStop,mode:N==null?void 0:N.mode,onModeChange:N==null?void 0:N.onModeChange,provider:N==null?void 0:N.provider,onProviderChange:N==null?void 0:N.onProviderChange,responseStyle:N==null?void 0:N.responseStyle,onResponseStyleChange:N==null?void 0:N.onResponseStyleChange,providerRuntimeMode:N==null?void 0:N.providerRuntimeMode,onProviderRuntimeModeChange:N==null?void 0:N.onProviderRuntimeModeChange,cliModel:N==null?void 0:N.cliModel,onCliModelChange:N==null?void 0:N.onCliModelChange,sessionInfo:N==null?void 0:N.sessionInfo,projectNodeId:N==null?void 0:N.projectNodeId,availableFiles:(N==null?void 0:N.availableFiles)??Z0(O),onSearchFiles:N==null?void 0:N.onSearchFiles,projectOpen:(N==null?void 0:N.projectOpen)??Z0(O).length>0,footerTrailingContent:c.jsx(_e,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0 rounded-lg",onClick:dr,disabled:q,"aria-label":"Cancel editing message",title:"Cancel editing",children:c.jsx(Vn,{className:"h-3.5 w-3.5"})}),className:"rounded-lg border-primary/20 bg-primary/[0.08] dark:!bg-primary/[0.08] shadow-none [&_.text-muted-foreground]:text-muted-foreground [&>div]:!bg-transparent [&_[contenteditable='true']]:!bg-transparent"},`edit-${e??"user-message"}`)})}):c.jsxs("div",{className:"relative w-fit max-w-full",children:[c.jsx(qT,{ref:Wt,"data-message-from":"user",className:Ae("min-w-0 rounded-lg bg-muted px-4 py-3 break-words [overflow-wrap:anywhere]",Pt&&!Y&&"cursor-text transition-colors hover:bg-muted/80","leading-relaxed [font-size:0.9rem]"),onClick:De,title:Pt&&!Y?"Click to edit message":void 0,children:c.jsxs("div",{className:"min-w-0 space-y-3",children:[c.jsx("div",{className:"min-w-0 whitespace-pre-wrap break-words [overflow-wrap:anywhere]",children:(it??O).length>0?(it??O).map((Se,Fe)=>Se.type==="text"?c.jsx("span",{children:Se.text},`text-${Fe}`):Se.type==="file"?c.jsxs("span",{className:"mx-[2px] inline-flex items-center gap-1.5 rounded-md border border-border/70 bg-muted/45 px-2 py-1 text-xs font-medium leading-none text-foreground align-middle select-none",title:Se.path,children:[c.jsx(Zo,{filename:Se.name,className:"h-3.5 w-3.5 shrink-0"}),c.jsx("span",{className:"max-w-[180px] truncate",children:Se.lineRange?`${Se.name}:${z2(Se.lineRange).replace(/^lines? /,"")}`:Se.name})]},`${Se.path}-${Fe}`):Se.type==="project"?c.jsxs("span",{className:"mx-[2px] inline-flex items-center gap-1.5 rounded-md border border-border/70 bg-muted/45 px-2 py-1 text-xs font-medium leading-none text-foreground align-middle select-none",title:Se.path,children:[c.jsx(mN,{name:Se.name,className:"h-3.5 w-3.5 shrink-0"}),c.jsx("span",{className:"max-w-[180px] truncate",children:Se.name})]},`${Se.path}-${Fe}`):Se.type==="terminal"?c.jsxs("span",{className:"mx-[2px] inline-flex items-center gap-1.5 rounded-md border border-border/70 bg-muted/45 px-2 py-1 text-xs font-medium leading-none text-foreground align-middle select-none",title:Se.projectRoot?`${Se.terminalId} · ${Se.projectRoot}`:Se.terminalId,children:[c.jsx("span",{className:"inline-flex h-3.5 w-3.5 items-center justify-center rounded-sm bg-muted-foreground/15 text-2xs font-bold uppercase text-muted-foreground",children:"T"}),c.jsx("span",{className:"max-w-[180px] truncate",children:Se.lineRange?`${Se.name}:${z2(Se.lineRange).replace(/^lines? /,"")}`:Se.name})]},`${Se.terminalId}-${Fe}`):null):qe??D}),ht.length>0&&c.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:ht.map((Se,Fe)=>{const et=Se.preview??`data:${Se.mimeType};base64,${Se.data}`;return c.jsxs(El,{children:[c.jsx(Hve,{asChild:!0,children:c.jsxs("button",{type:"button",className:"group block overflow-hidden rounded-lg border border-primary/10 bg-background/65 text-left transition-colors hover:border-primary/25 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:ring-offset-background","aria-label":`Expand image ${Se.name}`,children:[c.jsxs("span",{className:"relative block",children:[c.jsx("img",{src:et,alt:Se.name,className:"max-h-72 w-full object-cover transition-opacity group-hover:opacity-85"}),c.jsx("span",{className:"pointer-events-none absolute inset-0 flex items-center justify-center opacity-0 transition-opacity group-hover:opacity-100",children:c.jsx("span",{className:"rounded-full bg-black/65 px-3 py-1.5 text-xs font-medium text-white",children:"Click to expand"})})]}),c.jsx("span",{className:"block truncate border-t border-border/60 px-2 py-1 text-xs text-muted-foreground",children:Se.name})]})}),c.jsxs(sl,{className:"max-h-[92vh] max-w-[96vw] gap-2 overflow-hidden p-2",showCloseButton:!0,children:[c.jsx(ol,{className:"mr-8 truncate px-1 text-sm font-medium",children:Se.name}),c.jsx("img",{src:et,alt:Se.name,className:"max-h-[82vh] w-full object-contain"})]})]},`${Se.name}-${Fe}`)})})]})}),Mt()]}):c.jsxs("div",{className:"relative min-w-0 max-w-full break-words [overflow-wrap:anywhere]",children:[c.jsx(qT,{"data-message-from":"assistant",className:"min-w-0 max-w-full break-words [overflow-wrap:anywhere]",children:c.jsx(y7,{content:s,compact:_,isStreaming:b,preferLlmUi:w,onOpenPath:P})}),It,Ut]}):ze?c.jsx("div",{className:"flex items-center gap-3 px-1 py-1 text-sm text-muted-foreground",children:c.jsx(WW,{})}):null]})]})}),c.jsx(Vet,{open:ee,onOpenChange:ne,contextFlow:o,responseContent:s})]})}const v7=y.memo(dtt,(e,r)=>{const{messageFromEnd:n,messageIndex:i,...s}=e,{messageFromEnd:o,messageIndex:a,...l}=r,u=Object.keys(l);return u.length===Object.keys(s).length&&u.every(d=>Object.is(s[d],l[d]))});v7.displayName="Message";function htt(e){if(!(e!=null&&e.metadata))return{};try{const r=JSON.parse(e.metadata);return r&&typeof r=="object"&&!Array.isArray(r)?r:{}}catch{return{}}}function dle(e){const r=htt(e),n=r.repositoryId??r.repoId;return typeof n=="string"&&n.trim()?n.trim():null}function UW(e,r){const n=dle(e);return n?r.find(i=>i.id===n)??null:null}function ftt(e,r){return!e||e==="gateway"?!1:!r.has(e)}function VW(e){const r=new Date(e),i=new Date().getTime()-r.getTime();return i<6e4?"just now":i<36e5?`${Math.floor(i/6e4)}m ago`:i<864e5?`${Math.floor(i/36e5)}h ago`:r.toLocaleDateString()}function ptt({platform:e}){switch(e){case"windows":case"macos":case"linux":return c.jsx(el,{className:"h-2.5 w-2.5"});case"android":case"ios":return c.jsx(B4,{className:"h-2.5 w-2.5"});default:return c.jsx(wi,{className:"h-2.5 w-2.5"})}}function mtt({projects:e,personalSessions:r=[],activeProjectId:n,activeSessionId:i,loading:s=!1,hasMoreProjects:o=!1,showFewerProjects:a=!1,onSelectProject:l,onSelectPersonalSession:u,onNewPersonalSession:d,onCreateProject:h,onRemoveProject:f,onChangeDirectory:g,onAssignRepository:v,onShowMore:b,onShowFewer:_,sessionInfo:w,nodes:S=[],repositories:C=[]}){const j=y.useMemo(()=>new Set(S.filter(K=>!K.isGateway).map(K=>K.id)),[S]),[E,A]=y.useState(""),N=E.trim().toLowerCase(),P=y.useMemo(()=>N?e.filter(K=>{const F=UW(K,C),B=K.nodeId&&K.nodeId!=="gateway"?S.find(D=>D.id===K.nodeId):null;return[K.title,K.rootPath,F==null?void 0:F.name,B==null?void 0:B.name,...K.sessions.flatMap(D=>[D.name,D.projectPath])].some(D=>D==null?void 0:D.toLowerCase().includes(N))}):e,[S,N,C,e]),H=y.useMemo(()=>N?r.filter(K=>[K.name,K.projectPath].some(F=>F==null?void 0:F.toLowerCase().includes(N))):r,[N,r]);return c.jsxs("div",{className:"flex flex-col h-full",children:[c.jsxs("div",{className:"flex h-[35px] shrink-0 items-center gap-2 px-2.5 border-b",children:[c.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 rounded-md bg-muted/60 px-2 py-1",children:[c.jsx(tl,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),c.jsx("input",{type:"search",value:E,onChange:K=>A(K.target.value),placeholder:"Search chats and projects","aria-label":"Search chats and projects",className:"min-w-0 flex-1 bg-transparent text-xs outline-none placeholder:text-muted-foreground"})]}),c.jsxs(vn,{children:[c.jsx(pn,{asChild:!0,children:c.jsx(_e,{variant:"ghost",size:"icon",className:"h-6 w-6 shrink-0",onClick:h,children:c.jsx(qs,{className:"h-3.5 w-3.5"})})}),c.jsx(mn,{side:"right",children:"New project"})]})]}),s?c.jsx("div",{className:"flex flex-1 items-center justify-center",children:c.jsx(Vt,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex max-h-[50%] min-h-0 shrink-0 flex-col border-b",children:[c.jsx("div",{className:"flex h-7 shrink-0 items-center justify-between px-3",children:c.jsx("span",{className:"text-2xs font-medium text-muted-foreground",children:"Projects"})}),c.jsx(Jc,{className:"min-h-0 flex-1",children:c.jsxs("div",{className:"space-y-0.5 px-1.5 pb-1.5",children:[e.length===0&&c.jsxs("p",{className:"text-xs text-muted-foreground text-center py-4",children:["No projects yet.",c.jsx("br",{}),c.jsx("button",{onClick:h,className:"underline underline-offset-2 hover:text-foreground mt-1 inline-block",children:"Choose project folder"})]}),e.length>0&&P.length===0&&c.jsx("p",{className:"text-xs text-muted-foreground text-center py-4",children:"No matching projects."}),P.map(K=>{const F=K.id===n,B=K.nodeId&&K.nodeId!=="gateway"?S.find(O=>O.id===K.nodeId):null,W=ftt(K.nodeId,j),D=UW(K,C);return c.jsxs("div",{className:`group grid w-full grid-cols-[auto,minmax(0,1fr),auto] items-start gap-1.5 px-1.5 py-1.5 text-sm transition-colors ${W||F?"cursor-default":"cursor-pointer"} ${F?"rounded-md bg-secondary/70":W?"opacity-50":"hover:rounded-md hover:bg-muted/40"}`,draggable:!!K.rootPath,onDragStart:O=>{if(!K.rootPath){O.preventDefault();return}O.dataTransfer.effectAllowed="copy",O.dataTransfer.setData(Vee,JSON.stringify(RLe(K.rootPath,K.title||void 0)))},onClick:()=>{!W&&!F&&l(K.id)},children:[F?c.jsx(nf,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-primary"}):c.jsx(gR,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground"}),c.jsxs("div",{className:"min-w-0 overflow-hidden",children:[c.jsxs("div",{className:"flex min-w-0 items-center gap-1 overflow-hidden",children:[c.jsx("span",{className:"min-w-0 truncate text-xs font-medium",children:K.title||"Untitled Project"}),D&&c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"shrink-0 text-2xs text-muted-foreground",children:"·"}),c.jsxs("span",{className:"flex min-w-0 items-center gap-1 text-2xs text-muted-foreground",children:[c.jsx(pp,{className:"h-2.5 w-2.5 shrink-0"}),c.jsx("span",{className:"truncate",children:D.name})]})]})]}),c.jsxs("div",{className:"flex min-w-0 items-center gap-1 overflow-hidden text-2xs text-muted-foreground",children:[c.jsx("span",{className:"min-w-0 truncate",children:K.rootPath||"No folder linked"}),c.jsx("span",{className:"shrink-0",children:"·"}),c.jsx("span",{className:"shrink-0",children:VW(K.lastActiveAt)})]}),W&&c.jsxs("div",{className:"mt-0.5 flex items-center gap-1 text-2xs text-orange-500",children:[c.jsx(Ove,{className:"h-2.5 w-2.5 shrink-0"}),c.jsx("span",{className:"truncate",children:"Node offline"})]}),B&&!W&&c.jsx("div",{className:"mt-0.5 flex min-w-0 items-center gap-1 text-2xs",children:c.jsxs("span",{className:"inline-flex max-w-full items-center gap-0.5 rounded bg-muted px-1 py-0.5 text-muted-foreground",children:[c.jsx(ptt,{platform:B.platform}),c.jsx("span",{className:"truncate max-w-[80px]",children:B.name})]})}),F&&w&&c.jsxs("div",{className:"mt-0.5 flex min-w-0 items-center gap-1 text-2xs text-blue-500",children:[c.jsx("span",{className:"truncate",children:w.provider}),c.jsx("span",{className:"shrink-0 text-muted-foreground",children:"·"}),c.jsx(el,{className:"h-2.5 w-2.5 shrink-0"}),c.jsx("span",{className:"truncate",children:w.isRemote&&w.remoteNode?w.remoteNode.nodeName:"Gateway"})]})]}),c.jsxs("div",{className:"flex shrink-0 self-start gap-0.5",children:[v&&c.jsxs(vn,{children:[c.jsx(pn,{asChild:!0,children:c.jsx(_e,{variant:"ghost",size:"icon","aria-label":D?`Repository: ${D.name}`:"Assign repository",disabled:!K.rootPath,className:`h-5.5 w-5.5 shrink-0 opacity-100 transition-opacity sm:opacity-0 sm:group-hover:opacity-100 ${D?"text-primary hover:text-primary":"text-muted-foreground hover:text-foreground"}`,onClick:O=>{O.stopPropagation(),v(K.id)},children:c.jsx(pp,{className:"h-3 w-3"})})}),c.jsx(mn,{side:"right",children:D?`Repository: ${D.name}`:"Assign repository"})]}),c.jsxs(vn,{children:[c.jsx(pn,{asChild:!0,children:c.jsx(_e,{variant:"ghost",size:"icon","aria-label":"Change directory",className:"h-5.5 w-5.5 shrink-0 opacity-100 text-muted-foreground transition-opacity hover:text-foreground sm:opacity-0 sm:group-hover:opacity-100",onClick:O=>{O.stopPropagation(),g(K.id)},children:c.jsx(Lye,{className:"h-3 w-3"})})}),c.jsx(mn,{side:"right",children:"Change directory"})]}),c.jsxs(vn,{children:[c.jsx(pn,{asChild:!0,children:c.jsx(_e,{variant:"ghost",size:"icon","aria-label":"Archive project",className:"h-5.5 w-5.5 shrink-0 opacity-100 text-muted-foreground transition-opacity hover:text-destructive sm:opacity-0 sm:group-hover:opacity-100",onClick:O=>{O.stopPropagation(),f(K.id)},children:c.jsx(hR,{className:"h-3 w-3"})})}),c.jsx(mn,{side:"right",children:"Archive project"})]})]})]},K.id)}),!N&&o&&b&&c.jsx("button",{className:"w-full px-2 py-2 text-left text-xs text-muted-foreground transition-colors hover:text-foreground",onClick:b,children:"Show more projects"}),!N&&a&&_&&c.jsx("button",{className:"w-full px-2 py-2 text-left text-xs text-muted-foreground transition-colors hover:text-foreground",onClick:_,children:"Show fewer projects"})]})})]}),c.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[c.jsxs("div",{className:"flex h-7 shrink-0 items-center justify-between px-3",children:[c.jsx("span",{className:"text-2xs font-medium text-muted-foreground",children:"Personal chats"}),d&&c.jsxs(vn,{children:[c.jsx(pn,{asChild:!0,children:c.jsx(_e,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:d,children:c.jsx(qs,{className:"h-3 w-3"})})}),c.jsx(mn,{side:"right",children:"New personal chat"})]})]}),c.jsx(Jc,{className:"min-h-0 flex-1",children:c.jsxs("div",{className:"space-y-0.5 px-1.5 pb-1.5",children:[r.length===0&&c.jsxs("p",{className:"text-xs text-muted-foreground text-center py-4",children:["No personal chats yet.",d&&c.jsxs(c.Fragment,{children:[c.jsx("br",{}),c.jsx("button",{onClick:d,className:"underline underline-offset-2 hover:text-foreground mt-1 inline-block",children:"Start a chat"})]})]}),r.length>0&&H.length===0&&c.jsx("p",{className:"text-xs text-muted-foreground text-center py-4",children:"No matching personal chats."}),H.map(K=>{const F=n===null&&K.id===i;return c.jsxs("div",{className:`group flex items-center gap-1.5 rounded-md px-1.5 py-1 transition-colors text-sm ${F?"bg-secondary/70 cursor-default":"cursor-pointer hover:bg-muted/40"}`,onClick:()=>{!F&&u&&u(K.id)},children:[c.jsx(Ud,{className:`h-3.5 w-3.5 shrink-0 ${F?"text-primary":"text-muted-foreground"}`}),c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsx("div",{className:"truncate text-xs font-medium",children:K.name||"Personal chat"}),c.jsx("div",{className:"text-2xs text-muted-foreground",children:VW(K.lastActiveAt??K.createdAt)})]})]},K.id)})]})})]})]})]})}function gtt(e){const r=new Date(e),i=new Date().getTime()-r.getTime();return i<6e4?"just now":i<36e5?`${Math.floor(i/6e4)}m ago`:i<864e5?`${Math.floor(i/36e5)}h ago`:r.toLocaleDateString()}function ytt({sessions:e,activeSessionId:r,projectTitle:n,onSelectSession:i,onNewSession:s,onOpenChange:o,showTitle:a=!0,triggerLabel:l=null}){const[u,d]=y.useState(!1),h=e.find(g=>g.id===r)??e[0]??null,f=g=>{d(g),o==null||o(g)};return c.jsxs("div",{className:a?"flex min-w-0 flex-1 items-center justify-between gap-1.5":"flex items-center gap-1.5",children:[a?c.jsx("span",{className:"min-w-0 truncate text-sm font-semibold leading-tight",children:h!=null&&h.name&&h.name!=="New Chat"?h.name:""}):null,c.jsxs(Ku,{open:u,onOpenChange:f,children:[c.jsxs(vn,{children:[c.jsx(pn,{asChild:!0,children:c.jsx(Yu,{asChild:!0,children:c.jsxs(_e,{variant:"ghost",size:l?"sm":"icon",className:l?"h-7 shrink-0 rounded-md px-2 text-xs text-muted-foreground hover:text-foreground":"h-6 w-6 shrink-0 rounded-md text-muted-foreground hover:text-foreground",children:[c.jsx(B5,{className:"h-3.5 w-3.5"}),l?c.jsx("span",{children:l}):null]})})}),c.jsx(mn,{side:"bottom",children:l??"Sessions"})]}),c.jsxs(tu,{align:"start",className:"w-[min(28rem,calc(100vw-1rem))] p-0",children:[c.jsxs("div",{className:"flex items-center justify-between border-b px-3 py-2",children:[c.jsxs("div",{children:[c.jsx("div",{className:"text-sm font-medium",children:"Sessions"}),c.jsx("div",{className:"text-xs text-muted-foreground",children:n||"Current project"})]}),c.jsxs(_e,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>{s(),d(!1)},children:[c.jsx(y1e,{className:"mr-1 h-3 w-3"}),"New chat"]})]}),c.jsx("div",{className:"max-h-[min(28rem,70vh)] overflow-y-auto p-2",children:e.length===0?c.jsx("div",{className:"px-3 py-6 text-center text-sm text-muted-foreground",children:"No sessions yet."}):c.jsx("div",{className:"space-y-0.5",children:e.map(g=>{const v=g.id===r;return c.jsxs("button",{type:"button",className:`flex w-full items-start gap-2 rounded-md px-3 py-2 text-left transition-colors ${v?"bg-secondary text-secondary-foreground":"hover:bg-muted/50"}`,onClick:()=>{i(g.id),d(!1)},children:[v?c.jsx(fs,{className:"mt-0.5 h-3 w-3 shrink-0 text-primary"}):c.jsx("span",{className:"mt-1 h-2 w-2 shrink-0 rounded-full bg-muted-foreground/50"}),c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx("span",{className:"truncate text-xs font-medium",children:g.name||"Untitled"}),g.status==="archived"&&c.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border px-1.5 py-0 text-2xs text-muted-foreground",children:[c.jsx(hR,{className:"h-2.5 w-2.5"}),"Archived"]})]}),c.jsx("div",{className:"text-2xs text-muted-foreground",children:gtt(g.lastActiveAt)})]})]},g.id)})})})]})]})]})}function vtt({suggestions:e,onSelect:r,className:n}){return c.jsx("div",{className:Ae("flex flex-wrap gap-2 justify-center",n),children:e.map(i=>c.jsx("button",{onClick:()=>r(i),className:"px-4 py-2 text-sm rounded-full border bg-background text-muted-foreground hover:bg-accent hover:text-accent-foreground transition-colors",children:i},i))})}const xtt=M4("inline-flex items-center rounded-md border px-2 py-0.5 text-xs font-medium leading-4 transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground",success:"border-transparent bg-green-500/15 text-green-700 dark:text-green-400",warning:"border-transparent bg-yellow-500/15 text-yellow-700 dark:text-yellow-400"}},defaultVariants:{variant:"default"}});function $r({className:e,variant:r,...n}){return c.jsx("div",{className:Ae(xtt({variant:r}),e),...n})}const gn=y.forwardRef(({className:e,...r},n)=>c.jsx("div",{ref:n,className:Ae("rounded-xl border border-border/70 bg-card text-card-foreground shadow-sm",e),...r}));gn.displayName="Card";const hle=y.forwardRef(({className:e,...r},n)=>c.jsx("div",{ref:n,className:Ae("flex flex-col space-y-1.5 p-6",e),...r}));hle.displayName="CardHeader";const fle=y.forwardRef(({className:e,...r},n)=>c.jsx("h3",{ref:n,className:Ae("font-semibold leading-none tracking-tight",e),...r}));fle.displayName="CardTitle";const btt=y.forwardRef(({className:e,...r},n)=>c.jsx("p",{ref:n,className:Ae("text-sm text-muted-foreground",e),...r}));btt.displayName="CardDescription";const Kc=y.forwardRef(({className:e,...r},n)=>c.jsx("div",{ref:n,className:Ae("p-6 pt-0",e),...r}));Kc.displayName="CardContent";const _tt=y.forwardRef(({className:e,...r},n)=>c.jsx("div",{ref:n,className:Ae("flex items-center p-6 pt-0",e),...r}));_tt.displayName="CardFooter";const wtt={pending:{icon:xg,label:"Pending",color:"text-muted-foreground"},approved:{icon:Vt,label:"Running",color:"text-blue-500"},rejected:{icon:Vn,label:"Rejected",color:"text-destructive"},executed:{icon:uo,label:"Done",color:"text-green-500"},failed:{icon:ia,label:"Failed",color:"text-destructive"}};function Stt({action:e,expanded:r,onToggle:n}){const i=wtt[e.status],s=i.icon;return c.jsxs("div",{className:"border rounded-md",children:[c.jsxs("button",{type:"button",className:"flex items-center gap-3 w-full px-3 py-2.5 text-left hover:bg-muted/50 transition-colors",onClick:n,children:[c.jsx(s,{className:Ae("h-4 w-4 shrink-0",i.color,e.status==="approved"&&"animate-spin")}),c.jsxs("span",{className:"flex-1 min-w-0",children:[c.jsx("span",{className:"font-mono text-sm font-medium",children:e.tool}),c.jsxs("span",{className:"text-xs text-muted-foreground ml-2",children:["Step ",e.order+1]})]}),c.jsx($r,{variant:"outline",className:"text-2xs px-1.5 py-0",children:i.label}),r?c.jsx(Ml,{className:"h-4 w-4 text-muted-foreground"}):c.jsx(Cs,{className:"h-4 w-4 text-muted-foreground"})]}),r&&c.jsxs("div",{className:"px-3 pb-3 pt-1 border-t bg-muted/30",children:[c.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:e.description}),c.jsx("pre",{className:"text-xs bg-background rounded p-2 overflow-x-auto max-h-48",children:JSON.stringify(e.args,null,2)}),e.result&&c.jsx("div",{className:Ae("mt-2 text-xs rounded p-2",e.result.ok?"bg-green-500/10 text-green-700 dark:text-green-400":"bg-destructive/10 text-destructive"),children:e.result.message})]})]})}function ktt({plan:e,onApprove:r,onReject:n,isExecuting:i,className:s}){const[o,a]=y.useState(new Set),l=g=>{a(v=>{const b=new Set(v);return b.has(g)?b.delete(g):b.add(g),b})},u=e.actions.filter(g=>g.status==="pending").length,d=e.actions.filter(g=>g.status==="executed").length,h=e.actions.filter(g=>g.status==="failed").length,f=u===0;return c.jsxs(gn,{className:Ae("p-4 space-y-3",s),children:[c.jsxs("div",{className:"flex items-start justify-between gap-3",children:[c.jsxs("div",{children:[c.jsxs("h3",{className:"text-sm font-medium flex items-center gap-2",children:[c.jsx(Ctt,{className:"h-4 w-4"}),"Plan",c.jsxs($r,{variant:"secondary",className:"text-2xs px-1.5 py-0",children:[e.actions.length," step",e.actions.length!==1?"s":""]})]}),c.jsx("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:e.summary})]}),f&&c.jsx($r,{variant:h>0?"destructive":"success",className:"shrink-0",children:h>0?`${h} failed`:"Complete"})]}),c.jsx("div",{className:"space-y-1.5",children:e.actions.map(g=>c.jsx(Stt,{action:g,expanded:o.has(g.id),onToggle:()=>l(g.id)},g.id))}),u>0&&c.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[c.jsx(_e,{size:"sm",onClick:()=>r(),disabled:i,children:i?c.jsxs(c.Fragment,{children:[c.jsx(Vt,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Executing..."]}):c.jsxs(c.Fragment,{children:[c.jsx(DS,{className:"h-3.5 w-3.5 mr-1.5"}),"Execute all (",u,")"]})}),c.jsxs(_e,{size:"sm",variant:"outline",onClick:n,disabled:i,children:[c.jsx(Vn,{className:"h-3.5 w-3.5 mr-1.5"}),"Reject"]})]}),f&&!i&&c.jsxs("p",{className:"text-xs text-muted-foreground",children:[d>0&&`${d} action${d!==1?"s":""} executed.`,h>0&&` ${h} failed.`]})]})}function Ctt({className:e}){return c.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,children:[c.jsx("rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1"}),c.jsx("path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"}),c.jsx("path",{d:"M12 11h4"}),c.jsx("path",{d:"M12 16h4"}),c.jsx("path",{d:"M8 11h.01"}),c.jsx("path",{d:"M8 16h.01"})]})}function jtt(e){return e.find(r=>r.status==="in-progress")??null}function ple(e){return e.length>0&&e.every(r=>r.status==="completed")}function Ntt(e){const r=jtt(e),n=ple(e);return{headerLabel:r?r.title:n?"All tasks completed":"Tasks",showHeaderSpinner:!!r,showHeaderCompleted:!r&&n}}function u8({items:e,className:r,onClear:n}){const[i,s]=y.useState(!1),o=y.useMemo(()=>ple(e),[e]),a=y.useMemo(()=>Ntt(e),[e]);if(e.length===0)return null;const l=e.filter(g=>g.status==="completed").length,u=e.length,d=u>0?Math.round(l/u*100):0,h=i?"Tasks":a.headerLabel,f=o?"bg-green-500":"bg-primary";return c.jsxs("div",{className:Ae("rounded-lg border bg-muted/30 p-3 space-y-2",r),children:[c.jsxs("button",{type:"button",onClick:()=>s(g=>!g),className:"flex items-center gap-2 w-full text-left",children:[c.jsx(Ml,{className:Ae("h-3 w-3 shrink-0 text-muted-foreground transition-transform duration-200",!i&&"-rotate-90")}),!i&&a.showHeaderSpinner&&c.jsx(Vt,{className:"h-3.5 w-3.5 shrink-0 text-primary animate-spin"}),!i&&a.showHeaderCompleted&&c.jsx(uo,{className:"h-3.5 w-3.5 shrink-0 text-green-500"}),c.jsx("span",{className:"min-w-0 truncate text-xs font-medium text-foreground",children:h}),c.jsx("div",{className:"flex-1 h-1.5 rounded-full bg-muted overflow-hidden",children:c.jsx("div",{className:Ae("h-full rounded-full transition-all duration-300",f),style:{width:`${d}%`}})}),c.jsxs("span",{className:"text-2xs text-muted-foreground tabular-nums",children:[l,"/",u]}),n&&c.jsx("button",{type:"button",onClick:g=>{g.stopPropagation(),n()},className:"shrink-0 p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",title:"Clear todo list",children:c.jsx(Vn,{className:"h-3 w-3"})})]}),i&&c.jsx("div",{className:"space-y-1",children:e.map(g=>c.jsxs("div",{className:Ae("flex items-start gap-2 text-xs py-0.5",g.status==="completed"&&"text-muted-foreground"),children:[g.status==="completed"?c.jsx(uo,{className:"h-3.5 w-3.5 shrink-0 mt-0.5 text-green-500"}):g.status==="in-progress"?c.jsx(Vt,{className:"h-3.5 w-3.5 shrink-0 mt-0.5 text-primary animate-spin"}):c.jsx(mR,{className:"h-3.5 w-3.5 shrink-0 mt-0.5 text-muted-foreground/50"}),c.jsx("span",{className:Ae("flex-1 min-w-0",g.status==="completed"&&"line-through"),children:g.title})]},g.id))})]})}function Ttt({files:e,onAccept:r,onReject:n,onAcceptAll:i,onRejectAll:s,onFileClick:o,className:a}){const l=y.useRef(null),[u,d]=y.useState(!1),[h,f]=y.useState(!1);if(y.useEffect(()=>{const C=l.current;if(!C||typeof ResizeObserver>"u")return;const j=()=>{d(C.clientWidth<560)};j();const E=new ResizeObserver(()=>j());return E.observe(C),()=>E.disconnect()},[]),e.length===0)return null;const g=e.filter(C=>C.state==="undecided").length,v=e.reduce((C,j)=>C+(j.insertions??0),0),b=e.reduce((C,j)=>C+(j.deletions??0),0),_=e.some(C=>C.insertions!==void 0||C.deletions!==void 0),w=_?null:`${e.length} ${e.length===1?"file":"files"}`,S=({insertions:C,deletions:j})=>c.jsxs("span",{className:"shrink-0 whitespace-nowrap text-2xs tabular-nums",children:[c.jsxs("span",{className:"text-green-600 dark:text-green-400",children:["+",C]}),c.jsxs("span",{className:"ml-1 text-red-600 dark:text-red-400",children:["-",j]})]});return c.jsxs("div",{ref:l,className:Ae("overflow-hidden rounded-lg border bg-muted/30",a),children:[c.jsxs("div",{className:Ae("flex items-center justify-between gap-2 bg-muted/20 px-3 py-2",h&&"border-b"),children:[c.jsxs("button",{type:"button",className:"flex min-w-0 items-center gap-1.5 text-left",onClick:()=>f(C=>!C),"aria-expanded":h,children:[c.jsx(Cs,{className:Ae("h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform",h&&"rotate-90")}),c.jsx(Yh,{className:"h-3.5 w-3.5 text-muted-foreground"}),c.jsx("span",{className:"truncate text-xs font-medium",children:"Files changed"}),_&&c.jsx(S,{insertions:v,deletions:b}),w&&c.jsx("span",{className:"shrink-0 whitespace-nowrap text-2xs tabular-nums text-muted-foreground",children:w}),h&&g>0&&c.jsxs("span",{className:"shrink-0 text-2xs text-amber-500 dark:text-amber-400",children:[g," pending"]})]}),g>0&&c.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-1",children:[c.jsxs(_e,{size:u?"icon":"sm",variant:"ghost",className:Ae("h-6 shrink-0 text-xs",u?"w-6 p-0":"px-2"),onClick:i,title:"Keep all","aria-label":"Keep all",children:[c.jsx(fs,{className:Ae("h-3 w-3 shrink-0",!u&&"mr-1")}),!u&&"Keep all"]}),c.jsxs(_e,{size:u?"icon":"sm",variant:"ghost",className:Ae("h-6 shrink-0 text-xs",u?"w-6 p-0":"px-2"),onClick:s,title:"Undo all","aria-label":"Undo all",children:[c.jsx(Uu,{className:Ae("h-3 w-3 shrink-0",!u&&"mr-1")}),!u&&"Undo all"]})]})]}),h&&c.jsx("div",{className:"divide-y",children:e.map(C=>c.jsxs("div",{className:Ae("flex items-center gap-2 px-3 py-1.5 text-xs",C.state==="accepted"&&"bg-green-500/5",C.state==="rejected"&&"bg-red-500/5 text-muted-foreground"),children:[c.jsx(Zo,{filename:C.name,className:"h-3.5 w-3.5 shrink-0"}),c.jsx("button",{type:"button",className:Ae("min-w-0 flex-1 truncate text-left hover:underline cursor-pointer",C.state==="rejected"&&"line-through"),title:`Review diff for ${C.path}`,onClick:()=>o==null?void 0:o(C.path),children:C.path}),_&&c.jsx(S,{insertions:C.insertions??0,deletions:C.deletions??0}),C.state==="undecided"&&c.jsxs("div",{className:"ml-auto flex items-center gap-0.5 shrink-0",children:[c.jsx("button",{type:"button",className:"p-1 rounded hover:bg-primary/10 text-primary transition-colors",onClick:()=>o==null?void 0:o(C.path),title:"Review changes",children:c.jsx(Sp,{className:"h-3 w-3"})}),c.jsx("button",{type:"button",className:"p-1 rounded hover:bg-green-500/20 text-green-600 dark:text-green-400 transition-colors",onClick:()=>r==null?void 0:r(C.path),title:"Keep all changes",children:c.jsx(fs,{className:"h-3 w-3"})}),c.jsx("button",{type:"button",className:"p-1 rounded hover:bg-red-500/20 text-red-600 dark:text-red-400 transition-colors",onClick:()=>n==null?void 0:n(C.path),title:"Undo all changes",children:c.jsx(Uu,{className:"h-3 w-3"})})]}),C.state==="accepted"&&c.jsx("span",{className:"text-2xs text-green-600 dark:text-green-400 shrink-0",children:"Kept"}),C.state==="rejected"&&c.jsx("span",{className:"text-2xs text-red-500 shrink-0",children:"Undone"})]},C.path))})]})}function Ett(e,r,n,i){const s=e.findIndex(u=>u.id===r);if(s<0)return e;const o=[...e],[a]=o.splice(s,1);if(!a)return e;if(n==null)return o.push(a),o;const l=o.findIndex(u=>u.id===n);return l<0?e:(o.splice(l+(i==="after"?1:0),0,a),o)}function Att({item:e,index:r}){return c.jsxs("div",{className:"flex items-start gap-2 rounded-lg border border-border/40 bg-background px-3 py-2 text-sm shadow-2xl ring-1 ring-primary/10",children:[c.jsx("div",{className:"mt-0.5 shrink-0 rounded p-0.5 text-muted-foreground",children:r===0?c.jsx(yR,{className:"h-3.5 w-3.5 text-primary"}):c.jsx(Cs,{className:"h-3.5 w-3.5 text-muted-foreground"})}),c.jsx("div",{className:"mt-0.5 shrink-0 rounded p-0.5 text-muted-foreground",children:c.jsx(D4,{className:"h-3.5 w-3.5"})}),c.jsxs("div",{className:"min-w-0 flex-1",children:[r===0?c.jsx("span",{className:"mb-0.5 block text-2xs font-medium uppercase tracking-wider text-primary/70",children:"Next"}):c.jsxs("span",{className:"mb-0.5 block text-2xs font-medium uppercase tracking-wider text-muted-foreground",children:["Queued #",r+1]}),c.jsx("span",{className:"whitespace-pre-wrap break-words text-foreground",children:e.displayContent??e.content})]})]})}function Ott({item:e,index:r,onRemove:n,onEdit:i,onReorder:s,onSteer:o,onSendToParallelThread:a,dragActive:l,dropBefore:u,dropAfter:d,onDragStart:h}){const[f,g]=y.useState(!1),[v,b]=y.useState(!0),[_,w]=y.useState(e.displayContent??e.content),S=y.useRef(null),C=f||!l;y.useEffect(()=>{if(f){const N=S.current;N&&(N.focus(),N.setSelectionRange(N.value.length,N.value.length))}},[f]),y.useEffect(()=>{f||w(e.displayContent??e.content)},[e.content,e.displayContent,f]);const j=y.useCallback(()=>{const N=_.trim(),P=e.displayContent??e.content;N&&N!==P&&(i==null||i(e.id,N)),g(!1)},[_,e.content,e.displayContent,e.id,i]),E=y.useCallback(()=>{w(e.displayContent??e.content),g(!1)},[e.content,e.displayContent]),A=y.useCallback(N=>{N.key==="Enter"&&!N.shiftKey?(N.preventDefault(),j()):N.key==="Escape"&&E()},[j,E]);return c.jsxs(c.Fragment,{children:[u&&c.jsx("div",{className:"relative h-0",children:c.jsx("div",{className:"absolute inset-x-2 -top-px h-0.5 rounded-full bg-primary shadow-[0_0_0_1px_hsl(var(--background))]"})}),c.jsxs("div",{"data-queue-id":e.id,className:Ae("group flex cursor-grab touch-none items-start gap-2 rounded-lg border border-border/40 bg-muted/50 px-3 py-2 text-sm transition-all duration-150 ease-out hover:bg-muted/70 active:cursor-grabbing",l&&"border-dashed border-primary/35 bg-primary/5 opacity-0"),onPointerDown:N=>{f||!s||N.target.closest('button, textarea, input, a, [data-no-drag="true"]')||h==null||h(e.id,N)},children:[c.jsx("button",{type:"button","data-no-drag":"true",className:"mt-0.5 shrink-0 rounded p-0.5 text-muted-foreground hover:bg-foreground/10 hover:text-foreground transition-colors",onClick:()=>b(N=>!N),"aria-label":v?"Expand queued message":"Collapse queued message",title:v?"Expand queued message":"Collapse queued message",children:v?c.jsx(Cs,{className:"h-3.5 w-3.5"}):r===0?c.jsx(yR,{className:"h-3.5 w-3.5 text-primary"}):c.jsx(Ml,{className:"h-3.5 w-3.5 text-muted-foreground"})}),s&&!f&&c.jsx("div",{className:"mt-0.5 shrink-0 rounded p-0.5 text-muted-foreground cursor-grab active:cursor-grabbing touch-none",title:"Drag to reorder","aria-label":"Drag to reorder",children:c.jsx(D4,{className:"h-3.5 w-3.5"})}),c.jsxs("div",{className:"flex-1 min-w-0",children:[r===0&&!f&&c.jsx("span",{className:"text-2xs font-medium uppercase tracking-wider text-primary/70 block mb-0.5",children:"Next"}),r>0&&!f&&c.jsxs("span",{className:"text-2xs font-medium uppercase tracking-wider text-muted-foreground block mb-0.5",children:["Queued #",r+1]}),f?c.jsx("textarea",{ref:S,value:_,onChange:N=>w(N.target.value),onKeyDown:A,onBlur:j,rows:Math.min(_.split(`
1214
1214
  `).length,5),className:"w-full resize-none rounded border border-primary/30 bg-background px-2 py-1 text-sm outline-none focus:border-primary focus:ring-1 focus:ring-primary/20"}):v?c.jsx("span",{className:"block truncate text-foreground",children:e.displayContent??e.content}):c.jsx("span",{className:"whitespace-pre-wrap break-words text-foreground",children:e.displayContent??e.content})]}),c.jsx("div",{className:Ae("mt-0.5 flex shrink-0 items-center gap-0.5 transition-opacity",o?"opacity-100":C?"opacity-0 group-hover:opacity-100":"opacity-0"),children:f?c.jsxs(c.Fragment,{children:[c.jsx("button",{type:"button","data-no-drag":"true",className:"p-1 rounded hover:bg-primary/10 text-primary transition-colors",onClick:j,title:"Save",children:c.jsx(fs,{className:"h-3.5 w-3.5"})}),c.jsx("button",{type:"button","data-no-drag":"true",className:"p-1 rounded hover:bg-foreground/10 text-muted-foreground transition-colors",onClick:E,title:"Cancel",children:c.jsx(Vn,{className:"h-3.5 w-3.5"})})]}):c.jsxs(c.Fragment,{children:[i&&c.jsx("button",{type:"button","data-no-drag":"true",className:"p-1 rounded hover:bg-foreground/10 text-muted-foreground transition-colors",onClick:()=>g(!0),title:"Edit message",children:c.jsx(bR,{className:"h-3 w-3"})}),o&&c.jsxs("button",{type:"button","data-no-drag":"true",className:"inline-flex h-6 items-center gap-1 rounded border border-primary/25 bg-primary/5 px-1.5 text-2xs font-medium text-primary transition-colors hover:bg-primary/10",onClick:()=>o(e.id),title:"Steer with message",children:[c.jsx("span",{children:"Steer"}),c.jsx(O0e,{className:"h-3 w-3"})]}),a&&c.jsx("button",{type:"button","data-no-drag":"true",className:"p-1 rounded hover:bg-primary/10 text-muted-foreground hover:text-primary transition-colors",onClick:()=>a(e.id),title:"Send to parallel thread",children:c.jsx(pp,{className:"h-3 w-3"})}),c.jsx("button",{type:"button","data-no-drag":"true",className:"p-1 rounded hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors",onClick:()=>n==null?void 0:n(e.id),title:"Remove from queue",children:c.jsx(Vn,{className:"h-3.5 w-3.5"})})]})})]}),d&&c.jsx("div",{className:"relative h-0",children:c.jsx("div",{className:"absolute inset-x-2 -top-px h-0.5 rounded-full bg-primary shadow-[0_0_0_1px_hsl(var(--background))]"})})]})}function qW({items:e,onRemove:r,onEdit:n,onReorder:i,onSteer:s,onSendToParallelThread:o,className:a}){const l=y.useRef(null),u=y.useRef(null),[d,h]=y.useState(null),[f,g]=y.useState(null),[v,b]=y.useState(null);y.useEffect(()=>{if(d&&!e.some(j=>j.id===d)){h(null),g(null),b(null);return}f!=null&&f.targetId&&!e.some(j=>j.id===f.targetId)&&g(d?{targetId:d,placement:"before"}:null)},[d,f,e]),y.useEffect(()=>{var H;if(!d||!v)return;document.body.style.cursor="grabbing",document.body.style.userSelect="none",document.body.style.touchAction="none";const j=(K,F)=>{var O,I;const B=Array.from(((O=l.current)==null?void 0:O.querySelectorAll("[data-queue-id]"))??[]);if(B.length===0){g(null);return}const W=B.filter(R=>R.dataset.queueId&&R.dataset.queueId!==d);if(W.length===0){g({targetId:null,placement:"after"});return}for(const R of W){const $=R.dataset.queueId;if(!$)continue;const U=R.getBoundingClientRect(),Y=U.top+U.height/2;if(F<Y){g({targetId:$,placement:"before"});return}}const D=((I=W[W.length-1])==null?void 0:I.dataset.queueId)??null;g(D?{targetId:D,placement:"after"}:{targetId:null,placement:"after"})},E=K=>{K.pointerId===v.pointerId&&(b(F=>F&&{...F,x:K.clientX,y:K.clientY}),j(K.clientX,K.clientY))},A=K=>{var B,W;if(K&&K.pointerId!==v.pointerId)return;d&&f&&f.targetId!==d&&(i==null||i(d,f.targetId,f.placement));const F=u.current;(B=F==null?void 0:F.hasPointerCapture)!=null&&B.call(F,v.pointerId)&&((W=F.releasePointerCapture)==null||W.call(F,v.pointerId)),u.current=null,h(null),g(null),b(null)},N=()=>{A()},P=()=>{A()};return window.addEventListener("pointermove",E),window.addEventListener("pointerup",A),window.addEventListener("pointercancel",A),window.addEventListener("blur",P),(H=u.current)==null||H.addEventListener("lostpointercapture",N),()=>{var K;document.body.style.cursor="",document.body.style.userSelect="",document.body.style.touchAction="",window.removeEventListener("pointermove",E),window.removeEventListener("pointerup",A),window.removeEventListener("pointercancel",A),window.removeEventListener("blur",P),(K=u.current)==null||K.removeEventListener("lostpointercapture",N)}},[v,d,f,i]);const _=y.useCallback((j,E)=>{var P;if(!i||E.button!==0&&E.pointerType!=="touch"&&E.pointerType!=="pen")return;E.preventDefault();const A=E.currentTarget.closest("[data-queue-id]");if(!A)return;u.current=A,(P=A.setPointerCapture)==null||P.call(A,E.pointerId);const N=A.getBoundingClientRect();h(j),g({targetId:j,placement:"before"}),b({id:j,pointerId:E.pointerId,x:E.clientX,y:E.clientY,offsetX:E.clientX-N.left,offsetY:E.clientY-N.top,width:N.width,height:N.height})},[i]);if(e.length===0)return null;const w=d&&f&&(f.targetId!==d||f.placement==="after")?Ett(e,d,f.targetId,f.placement):e,S=v?w.findIndex(j=>j.id===v.id):-1,C=S>=0?w[S]:null;return c.jsxs("div",{ref:l,className:Ae("space-y-1.5",a),children:[c.jsx("div",{className:"flex items-center gap-1.5 px-0.5",children:c.jsxs("span",{className:"text-xs font-medium text-muted-foreground",children:[e.length," queued message",e.length!==1?"s":""]})}),w.map((j,E)=>c.jsx(Ott,{item:j,index:E,onRemove:r,onEdit:n,onReorder:i,onSteer:s,onSendToParallelThread:o,dragActive:d===j.id,dropBefore:!!(d&&(f==null?void 0:f.targetId)===j.id&&f.placement==="before"&&d!==j.id),dropAfter:!!(d&&(f==null?void 0:f.targetId)===j.id&&f.placement==="after"&&d!==j.id),onDragStart:_},j.id)),v&&C&&c.jsx("div",{className:"pointer-events-none fixed z-50",style:{left:`${v.x-v.offsetX}px`,top:`${v.y-v.offsetY}px`,width:`${v.width}px`,minHeight:`${v.height}px`},children:c.jsx("div",{className:"scale-[1.01] opacity-95",children:c.jsx(Att,{item:C,index:S})})})]})}function Mtt({usage:e}){const[r,n]=y.useState(!1),i=e&&e.limit>0?Math.round(e.ratio*100):0,s=y.useMemo(()=>{if(!e||e.total===0)return[];const g=e.total;return[{label:"System",tokens:e.system,pct:Math.round(e.system/g*100),color:"var(--ctx-system)"},{label:"History",tokens:e.history,pct:Math.round(e.history/g*100),color:"var(--ctx-history)"},{label:"Tool Results",tokens:e.toolResults,pct:Math.round(e.toolResults/g*100),color:"var(--ctx-tool-results)"},{label:"Tools",tokens:e.tools,pct:Math.round(e.tools/g*100),color:"var(--ctx-tools)"}].filter(v=>v.tokens>0)},[e]),o=22,a=3,l=(o-a)/2,u=2*Math.PI*l,d=y.useMemo(()=>{if(!e||e.limit<=0)return[];const g=[];let v=0;for(const b of s){const w=b.tokens/e.limit*u;g.push({offset:v,length:w,color:b.color}),v+=w}return g},[s,e,u]),h=i>=90?"text-red-500":i>=75?"text-amber-500":"text-emerald-500",f=g=>g>=1e3?`${(g/1e3).toFixed(1)}k`:String(g);return!e||e.limit<=0?null:c.jsxs(c.Fragment,{children:[c.jsxs(vn,{children:[c.jsx(pn,{asChild:!0,children:c.jsxs("button",{type:"button",onClick:()=>n(!0),className:"flex items-center gap-1.5 px-1.5 py-1 rounded-md hover:bg-muted/50 cursor-pointer transition-colors",children:[c.jsxs("svg",{width:o,height:o,viewBox:`0 0 ${o} ${o}`,className:`-rotate-90 ${h}`,children:[c.jsx("circle",{cx:o/2,cy:o/2,r:l,fill:"none",stroke:"currentColor",strokeWidth:a,opacity:.15}),d.map((g,v)=>c.jsx("circle",{cx:o/2,cy:o/2,r:l,fill:"none",stroke:g.color,strokeWidth:a,strokeDasharray:`${g.length} ${u-g.length}`,strokeDashoffset:-g.offset,strokeLinecap:"round",opacity:.85},v))]}),c.jsxs("span",{className:"text-2xs tabular-nums text-muted-foreground",children:[i,"%"]})]})}),c.jsx(mn,{side:"bottom",className:"max-w-[220px] bg-popover text-popover-foreground border shadow-md",children:c.jsxs("div",{className:"space-y-1.5",children:[c.jsxs("div",{className:"flex items-center justify-between text-xs font-medium",children:[c.jsx("span",{children:"Context Window"}),c.jsxs("span",{className:"tabular-nums",children:[f(e.total)," / ",f(e.limit)]})]}),c.jsx("div",{className:"w-full h-1.5 rounded-full bg-muted overflow-hidden",children:c.jsx("div",{className:`h-full rounded-full transition-all ${i>=90?"bg-red-500":i>=75?"bg-amber-500":"bg-emerald-500"}`,style:{width:`${Math.min(i,100)}%`}})}),c.jsx("div",{className:"space-y-0.5",children:s.map(g=>c.jsxs("div",{className:"flex items-center justify-between text-xs",children:[c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx("span",{className:"inline-block w-2 h-2 rounded-full",style:{backgroundColor:g.color}}),c.jsx("span",{className:"text-muted-foreground",children:g.label})]}),c.jsxs("span",{className:"tabular-nums text-muted-foreground",children:[g.pct,"%"]})]},g.label))}),e.pruned&&c.jsx("div",{className:"text-2xs text-amber-500 pt-0.5 border-t border-border",children:"Old messages pruned to fit context"})]})})]}),c.jsx(El,{open:r,onOpenChange:n,children:c.jsxs(sl,{className:"max-w-sm",children:[c.jsxs(pc,{children:[c.jsx(ol,{className:"text-sm",children:"Context Window Breakdown"}),c.jsxs(rd,{className:"text-xs",children:[f(e.total)," / ",f(e.limit)," tokens used (",i,"%)"]})]}),c.jsxs("div",{className:"space-y-3 pt-1",children:[c.jsx("div",{className:"w-full h-2 rounded-full bg-muted overflow-hidden",children:c.jsx("div",{className:`h-full rounded-full transition-all ${i>=90?"bg-red-500":i>=75?"bg-amber-500":"bg-emerald-500"}`,style:{width:`${Math.min(i,100)}%`}})}),c.jsx("div",{className:"space-y-2",children:s.map(g=>c.jsxs("div",{className:"flex items-center justify-between text-sm",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"inline-block w-2.5 h-2.5 rounded-full",style:{backgroundColor:g.color}}),c.jsx("span",{children:g.label})]}),c.jsxs("div",{className:"text-muted-foreground tabular-nums",children:[c.jsx("span",{className:"font-medium text-foreground",children:f(g.tokens)})," ",c.jsxs("span",{className:"text-xs",children:["(",g.pct,"%)"]})]})]},g.label))}),e.pruned&&c.jsx("div",{className:"rounded-md border border-amber-500/20 bg-amber-500/5 p-2 text-xs text-amber-600",children:"Older messages were pruned to fit within the context window limit."})]})]})})]})}const W1=Kn(),Rtt=_y();function Ptt(e){const[r,n]=y.useState([]),i=y.useRef(async()=>{}),s=y.useRef(e);s.current=e;const o=y.useCallback(async()=>{try{const d=e?`${W1}/api/consent/pending/${e}`:`${W1}/api/consent/pending`,f=await(await fetch(d)).json();n(f.requests)}catch{}},[e]);i.current=o,y.useEffect(()=>{o()},[o]),y.useEffect(()=>{let d=!1;const h=new WebSocket(Rtt);return h.onmessage=f=>{if(!d)try{const g=JSON.parse(f.data);if(g.type==="consent.required"){const v=g.payload,b=s.current;(!b||v.sessionId===b)&&n(_=>[..._,v])}if(g.type==="consent.resolved"){const v=g.payload;n(b=>b.filter(_=>_.id!==v.requestId))}}catch{}},h.onopen=()=>{d||i.current()},()=>{if(d=!0,h.onopen=()=>{try{h.close()}catch{}},h.onmessage=null,h.onerror=null,h.onclose=null,h.readyState===WebSocket.OPEN)try{h.close()}catch{}}},[]);const a=y.useCallback(async d=>{try{await fetch(`${W1}/api/consent/${d}/approve`,{method:"POST"}),n(h=>h.filter(f=>f.id!==d))}catch{}},[]),l=y.useCallback(async(d,h)=>{try{await fetch(`${W1}/api/consent/${d}/reject`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reason:h})}),n(f=>f.filter(g=>g.id!==d))}catch{}},[]),u=y.useCallback(async(d,h)=>{try{const g=await(await fetch(`${W1}/api/consent/pending/${d}/approve-all`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reason:h})})).json(),v=new Set(g.requestIds??[]);return v.size>0?n(b=>b.filter(_=>!v.has(_.id))):n(b=>b.filter(_=>_.sessionId!==d)),!0}catch{return!1}},[]);return{queue:r,approve:a,reject:l,approveAllForSession:u,refresh:o}}function Ltt(){const[e,r]=y.useState(null),n=y.useCallback(async()=>{try{const s=await(await fetch(`${W1}/api/consent/policy`)).json();r(s)}catch{r(null)}},[]);return y.useEffect(()=>{n()},[n]),{policy:e,refresh:n}}function GW({risk:e}){const r={low:"bg-green-500/10 text-green-600 dark:text-green-400",medium:"bg-yellow-500/10 text-yellow-600 dark:text-yellow-400",high:"bg-red-500/10 text-red-600 dark:text-red-400"},i={low:I4,medium:SY,high:vA}[e];return c.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium ${r[e]}`,children:[c.jsx(i,{className:"h-3 w-3"}),e]})}function KW({level:e}){const r={none:"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400",once:"bg-blue-500/10 text-blue-600 dark:text-blue-400",always:"bg-amber-500/10 text-amber-700 dark:text-amber-300",dangerous:"bg-red-500/10 text-red-600 dark:text-red-400"};return c.jsx("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium ${r[e]}`,children:e})}function YW({expiresAt:e}){const[r,n]=y.useState("");return y.useEffect(()=>{const i=()=>{const o=new Date(e).getTime()-Date.now();if(o<=0){n("expired");return}const a=Math.ceil(o/1e3);a>60?n(`${Math.ceil(a/60)}m`):n(`${a}s`)};i();const s=setInterval(i,1e3);return()=>clearInterval(s)},[e]),c.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-muted-foreground",children:[c.jsx(xg,{className:"h-3 w-3"}),r]})}function XW({toolName:e}){return e.startsWith("terminal.")?c.jsx(Vs,{className:"h-4 w-4"}):e.startsWith("file.")?c.jsx(Yh,{className:"h-4 w-4"}):c.jsx(xY,{className:"h-4 w-4"})}function $tt({preview:e,toolName:r}){const n=e.command,i=e.path,s=e.content;return n?c.jsxs("div",{className:"rounded-md bg-muted p-3 font-mono text-xs leading-relaxed overflow-x-auto",children:[c.jsx("span",{className:"text-muted-foreground",children:"$ "}),n]}):i?c.jsxs("div",{className:"rounded-md bg-muted p-3 text-xs leading-relaxed overflow-x-auto",children:[c.jsxs("div",{className:"text-muted-foreground mb-1",children:[r,": ",i]}),s&&c.jsx("pre",{className:"font-mono whitespace-pre-wrap",children:s.length>500?s.slice(0,500)+"...":s})]}):c.jsx("div",{className:"rounded-md bg-muted p-3 font-mono text-xs leading-relaxed overflow-x-auto",children:JSON.stringify(e,null,2)})}function Dtt({request:e,onApprove:r,onReject:n,compact:i=!1}){const[s,o]=y.useState(!1),a=async()=>{o(!0),r(e.id)},l=async()=>{o(!0),n(e.id)};return i?c.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 rounded-lg border bg-card",children:[c.jsx(XW,{toolName:e.toolName}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-xs font-medium truncate",children:e.toolName}),c.jsx(GW,{risk:e.risk}),c.jsx(KW,{level:e.policy.consentLevel}),c.jsx(YW,{expiresAt:e.expiresAt})]}),c.jsx("p",{className:"text-xs text-muted-foreground truncate",children:e.summary})]}),c.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[c.jsxs("button",{onClick:a,disabled:s,className:"inline-flex items-center gap-1 px-2.5 py-1 rounded-md text-xs font-medium bg-green-500/10 text-green-600 dark:text-green-400 hover:bg-green-500/20 disabled:opacity-50 transition-colors",children:[c.jsx(KD,{className:"h-3 w-3"}),"Approve"]}),c.jsxs("button",{onClick:l,disabled:s,className:"inline-flex items-center gap-1 px-2.5 py-1 rounded-md text-xs font-medium bg-red-500/10 text-red-600 dark:text-red-400 hover:bg-red-500/20 disabled:opacity-50 transition-colors",children:[c.jsx(vA,{className:"h-3 w-3"}),"Reject"]})]})]}):c.jsxs("div",{className:"rounded-lg border bg-card shadow-sm overflow-hidden",children:[c.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b bg-muted/30",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(XW,{toolName:e.toolName}),c.jsx("span",{className:"text-sm font-medium",children:e.toolName}),c.jsx(GW,{risk:e.risk}),c.jsx(KW,{level:e.policy.consentLevel})]}),c.jsx(YW,{expiresAt:e.expiresAt})]}),c.jsxs("div",{className:"p-4 space-y-3",children:[c.jsx("p",{className:"text-sm text-foreground",children:e.summary}),c.jsxs("div",{className:"space-y-1",children:[c.jsx("p",{className:"text-xs text-muted-foreground",children:e.policy.description}),!e.policy.knownTool&&c.jsx("p",{className:"text-xs text-red-600 dark:text-red-400",children:"Unknown tool: blocked behind dangerous consent until added to the active profile."})]}),c.jsx($tt,{preview:e.preview,toolName:e.toolName})]}),c.jsxs("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t bg-muted/20",children:[c.jsxs("button",{onClick:l,disabled:s,className:"inline-flex items-center gap-1.5 px-4 py-2 rounded-md text-xs font-medium bg-red-500/10 text-red-600 dark:text-red-400 hover:bg-red-500/20 disabled:opacity-50 transition-colors",children:[c.jsx(vA,{className:"h-3.5 w-3.5"}),"Reject"]}),c.jsxs("button",{onClick:a,disabled:s,className:"inline-flex items-center gap-1.5 px-4 py-2 rounded-md text-xs font-medium bg-green-500/10 text-green-600 dark:text-green-400 hover:bg-green-500/20 disabled:opacity-50 transition-colors",children:[c.jsx(KD,{className:"h-3.5 w-3.5"}),"Approve"]})]})]})}function Itt({status:e}){const r={running:{icon:Vt,label:"Running",color:"bg-blue-500/10 text-blue-600 dark:text-blue-400"},"awaiting-approval":{icon:SY,label:"Awaiting Approval",color:"bg-yellow-500/10 text-yellow-600 dark:text-yellow-400"},"needs-input":{icon:xg,label:"Needs Input",color:"bg-orange-500/10 text-orange-600 dark:text-orange-400"},completed:{icon:uo,label:"Completed",color:"bg-green-500/10 text-green-600 dark:text-green-400"},failed:{icon:sh,label:"Failed",color:"bg-red-500/10 text-red-600 dark:text-red-400"}},{icon:n,label:i,color:s}=r[e];return c.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium ${s}`,children:[c.jsx(n,{className:`h-3 w-3 ${e==="running"?"animate-spin":""}`}),i]})}function Btt({className:e="",compact:r=!1,sessionId:n,onApproveAllEnabled:i}){const{queue:s,approve:o,reject:a,approveAllForSession:l}=Ptt(n),{policy:u}=Ltt(),[d,h]=y.useState(!1),f=y.useMemo(()=>n?s.filter(v=>v.sessionId===n):s,[s,n]),g=async()=>{if(!n||d)return;h(!0),await l(n)&&(i==null||i()),h(!1)};return f.length===0?null:c.jsxs("div",{className:`space-y-2 ${e}`,children:[c.jsxs("div",{className:"flex items-center justify-between px-1",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Itt,{status:"awaiting-approval"}),c.jsxs("div",{className:"flex flex-col",children:[c.jsxs("span",{className:"text-xs text-muted-foreground",children:[f.length," pending ",f.length===1?"request":"requests"]}),u&&c.jsxs("span",{className:"text-xs text-muted-foreground",children:["Profile: ",c.jsx("span",{className:"font-medium text-foreground",children:u.activeProfileName??"custom"})," ","• ",u.toolCount," configured tools • unknown tools require dangerous consent"]})]})]}),n&&f.length>0&&c.jsx("button",{onClick:g,disabled:d,className:"text-xs text-green-600 hover:text-green-500 dark:text-green-400 dark:hover:text-green-300 disabled:opacity-50 disabled:cursor-not-allowed",children:d?"Approving...":"Approve all in this session"})]}),c.jsx("div",{className:"space-y-2",children:f.map(v=>c.jsx(Dtt,{request:v,onApprove:o,onReject:a,compact:r},v.id))})]})}const JW=5e3;let ztt=0,Y1=[],t4=new Set;function d8(e,r){Y1.push({id:ztt++,ts:Date.now(),type:e,raw:r}),Y1.length>JW&&(Y1=Y1.slice(-JW)),t4.forEach(n=>n())}function Ftt(){Y1=[],t4.forEach(e=>e())}function Htt(){const[,e]=y.useState(0);return y.useEffect(()=>{const r=()=>e(n=>n+1);return t4.add(r),()=>{t4.delete(r)}},[]),Y1}const Wtt={request:"text-orange-400",token:"text-gray-400",tool_call_delta:"text-blue-400",tool_start:"text-yellow-400",tool_output:"text-green-400",tool_result:"text-emerald-400",thinking:"text-purple-400",done:"text-gray-500",error:"text-red-400"},h8=20;function Utt({onClose:e}){const r=Htt(),n=y.useRef(null),[i,s]=y.useState(!0),[o,a]=y.useState(""),[l,u]=y.useState(!1),[d,h]=y.useState(new Set),f=y.useCallback(w=>{h(S=>{const C=new Set(S);return C.has(w)?C.delete(w):C.add(w),C})},[]),g=o?r.filter(w=>w.type.includes(o)||w.raw.includes(o)):r,v=WR({count:g.length,getScrollElement:()=>n.current,estimateSize:()=>h8,overscan:30}),b=()=>{const w=g.map(S=>`${new Date(S.ts).toISOString().slice(11,23)} ${S.type} ${S.raw}`).join(`
1215
- `);navigator.clipboard.writeText(w),u(!0),setTimeout(()=>u(!1),1500)};y.useEffect(()=>{i&&g.length>0&&v.scrollToIndex(g.length-1,{align:"end"})},[g.length,i]);const _=y.useCallback(()=>{const w=n.current;if(!w)return;const S=w.scrollHeight-w.scrollTop-w.clientHeight<40;s(S)},[]);return c.jsxs("div",{className:"flex flex-col h-full bg-[#0d1117] text-[#c9d1d9] text-xs font-mono",children:[c.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-zinc-700/60 shrink-0",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-xs font-semibold text-zinc-400 uppercase tracking-wider",children:"SSE Debug"}),c.jsxs("span",{className:"text-2xs text-zinc-500",children:[g.length,"/",r.length]})]}),c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx("input",{type:"text",placeholder:"Filter...",value:o,onChange:w=>a(w.target.value),className:"h-5 w-28 px-1.5 text-2xs rounded bg-zinc-800 border border-zinc-700 text-zinc-300 placeholder-zinc-500 focus:outline-none focus:border-blue-500"}),c.jsx(_e,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:b,title:"Copy all events",children:l?c.jsx(fs,{className:"h-3 w-3 text-green-400"}):c.jsx(ac,{className:"h-3 w-3"})}),c.jsx(_e,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:Ftt,children:c.jsx(Tl,{className:"h-3 w-3"})}),c.jsx(_e,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:e,children:c.jsx(Vn,{className:"h-3 w-3"})})]})]}),c.jsx("div",{ref:n,onScroll:_,className:"flex-1 overflow-y-auto overflow-x-hidden",children:c.jsx("div",{style:{height:`${v.getTotalSize()}px`,position:"relative",width:"100%"},children:v.getVirtualItems().map(w=>{const S=g[w.index],C=new Date(S.ts).toISOString().slice(11,23),j=Wtt[S.type]??"text-zinc-400",E=S.raw.length>120,A=d.has(S.id),N=E&&!A?S.raw.slice(0,120)+"…":S.raw;return c.jsxs("div",{"data-index":w.index,ref:v.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${w.start}px)`},className:Ae("flex gap-2 px-2 hover:bg-zinc-800/50 leading-tight cursor-pointer select-none",A?"items-start py-1 bg-zinc-800/30":"items-center"),onClick:()=>f(S.id),children:[c.jsx("span",{className:"text-zinc-600 shrink-0 w-20",style:{minHeight:h8},children:C}),c.jsx("span",{className:Ae("shrink-0 w-28 text-right",j),style:{minHeight:h8},children:S.type}),c.jsxs("span",{className:Ae("text-zinc-400 min-w-0",A?"break-all whitespace-pre-wrap":"truncate"),children:[N,E&&!A&&c.jsx("span",{className:"text-zinc-600 ml-1",children:"▸"})]})]},S.id)})})}),!i&&c.jsx("div",{className:"absolute bottom-2 right-4",children:c.jsx(_e,{variant:"outline",size:"icon",className:"h-6 w-6 rounded-full bg-zinc-800 border-zinc-600",onClick:()=>{s(!0),v.scrollToIndex(g.length-1,{align:"end"})},children:c.jsx(dY,{className:"h-3 w-3"})})})]})}function Vtt(e,r=[]){let n=[];function i(o,a){const l=y.createContext(a),u=n.length;n=[...n,a];const d=f=>{var S;const{scope:g,children:v,...b}=f,_=((S=g==null?void 0:g[e])==null?void 0:S[u])||l,w=y.useMemo(()=>b,Object.values(b));return c.jsx(_.Provider,{value:w,children:v})};d.displayName=o+"Provider";function h(f,g){var _;const v=((_=g==null?void 0:g[e])==null?void 0:_[u])||l,b=y.useContext(v);if(b)return b;if(a!==void 0)return a;throw new Error(`\`${f}\` must be used within \`${o}\``)}return[d,h]}const s=()=>{const o=n.map(a=>y.createContext(a));return function(l){const u=(l==null?void 0:l[e])||o;return y.useMemo(()=>({[`__scope${e}`]:{...l,[e]:u}}),[l,u])}};return s.scopeName=e,[i,qtt(s,...r)]}function qtt(...e){const r=e[0];if(e.length===1)return r;const n=()=>{const i=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(o){const a=i.reduce((l,{useScope:u,scopeName:d})=>{const f=u(o)[`__scope${d}`];return{...l,...f}},{});return y.useMemo(()=>({[`__scope${r.scopeName}`]:a}),[a])}};return n.scopeName=r.scopeName,n}function mle(e){const r=y.useRef({value:e,previous:e});return y.useMemo(()=>(r.current.value!==e&&(r.current.previous=r.current.value,r.current.value=e),r.current.previous),[e])}function Gtt(e){const r=Ktt(e),n=y.forwardRef((i,s)=>{const{children:o,...a}=i,l=y.Children.toArray(o),u=l.find(Xtt);if(u){const d=u.props.children,h=l.map(f=>f===u?y.Children.count(d)>1?y.Children.only(null):y.isValidElement(d)?d.props.children:null:f);return c.jsx(r,{...a,ref:s,children:y.isValidElement(d)?y.cloneElement(d,void 0,h):null})}return c.jsx(r,{...a,ref:s,children:o})});return n.displayName=`${e}.Slot`,n}function Ktt(e){const r=y.forwardRef((n,i)=>{const{children:s,...o}=n;if(y.isValidElement(s)){const a=Ztt(s),l=Jtt(o,s.props);return s.type!==y.Fragment&&(l.ref=i?ho(i,a):a),y.cloneElement(s,l)}return y.Children.count(s)>1?y.Children.only(null):null});return r.displayName=`${e}.SlotClone`,r}var Ytt=Symbol("radix.slottable");function Xtt(e){return y.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Ytt}function Jtt(e,r){const n={...r};for(const i in r){const s=e[i],o=r[i];/^on[A-Z]/.test(i)?s&&o?n[i]=(...l)=>{const u=o(...l);return s(...l),u}:s&&(n[i]=s):i==="style"?n[i]={...s,...o}:i==="className"&&(n[i]=[s,o].filter(Boolean).join(" "))}return{...e,...n}}function Ztt(e){var i,s;let r=(i=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:i.get,n=r&&"isReactWarning"in r&&r.isReactWarning;return n?e.ref:(r=(s=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:s.get,n=r&&"isReactWarning"in r&&r.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Qtt=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],gle=Qtt.reduce((e,r)=>{const n=Gtt(`Primitive.${r}`),i=y.forwardRef((s,o)=>{const{asChild:a,...l}=s,u=a?n:r;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(u,{...l,ref:o})});return i.displayName=`Primitive.${r}`,{...e,[r]:i}},{}),YN="Switch",[ert]=Vtt(YN),[trt,rrt]=ert(YN),yle=y.forwardRef((e,r)=>{const{__scopeSwitch:n,name:i,checked:s,defaultChecked:o,required:a,disabled:l,value:u="on",onCheckedChange:d,form:h,...f}=e,[g,v]=y.useState(null),b=li(r,j=>v(j)),_=y.useRef(!1),w=g?h||!!g.closest("form"):!0,[S,C]=wp({prop:s,defaultProp:o??!1,onChange:d,caller:YN});return c.jsxs(trt,{scope:n,checked:S,disabled:l,children:[c.jsx(gle.button,{type:"button",role:"switch","aria-checked":S,"aria-required":a,"data-state":_le(S),"data-disabled":l?"":void 0,disabled:l,value:u,...f,ref:b,onClick:kr(e.onClick,j=>{C(E=>!E),w&&(_.current=j.isPropagationStopped(),_.current||j.stopPropagation())})}),w&&c.jsx(ble,{control:g,bubbles:!_.current,name:i,value:u,checked:S,required:a,disabled:l,form:h,style:{transform:"translateX(-100%)"}})]})});yle.displayName=YN;var vle="SwitchThumb",xle=y.forwardRef((e,r)=>{const{__scopeSwitch:n,...i}=e,s=rrt(vle,n);return c.jsx(gle.span,{"data-state":_le(s.checked),"data-disabled":s.disabled?"":void 0,...i,ref:r})});xle.displayName=vle;var nrt="SwitchBubbleInput",ble=y.forwardRef(({__scopeSwitch:e,control:r,checked:n,bubbles:i=!0,...s},o)=>{const a=y.useRef(null),l=li(a,o),u=mle(n),d=YY(r);return y.useEffect(()=>{const h=a.current;if(!h)return;const f=window.HTMLInputElement.prototype,v=Object.getOwnPropertyDescriptor(f,"checked").set;if(u!==n&&v){const b=new Event("click",{bubbles:i});v.call(h,n),h.dispatchEvent(b)}},[u,n,i]),c.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...s,tabIndex:-1,ref:l,style:{...s.style,...d,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});ble.displayName=nrt;function _le(e){return e?"checked":"unchecked"}var wle=yle,irt=xle;const Ap=y.forwardRef(({className:e,...r},n)=>c.jsx(wle,{className:Ae("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...r,ref:n,children:c.jsx(irt,{className:Ae("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}));Ap.displayName=wle.displayName;const x7=[{label:"Every minute",value:"* * * * *",description:"Runs every minute"},{label:"Every 5 minutes",value:"*/5 * * * *",description:"Runs every 5 minutes"},{label:"Every 15 minutes",value:"*/15 * * * *",description:"Runs every 15 minutes"},{label:"Every 30 minutes",value:"*/30 * * * *",description:"Runs every 30 minutes"},{label:"Hourly",value:"0 * * * *",description:"Runs at the start of every hour"},{label:"Every 2 hours",value:"0 */2 * * *",description:"Runs every 2 hours"},{label:"Daily at midnight",value:"0 0 * * *",description:"Runs at 00:00 every day"},{label:"Daily at 9am",value:"0 9 * * *",description:"Runs at 09:00 every day"},{label:"Daily at 6pm",value:"0 18 * * *",description:"Runs at 18:00 every day"},{label:"Weekly (Sunday)",value:"0 0 * * 0",description:"Runs at midnight every Sunday"},{label:"Weekly (Monday)",value:"0 9 * * 1",description:"Runs at 9am every Monday"},{label:"Monthly",value:"0 0 1 * *",description:"Runs at midnight on the 1st of each month"}];function XN(e){return e.trim().split(/\s+/).join(" ")}function Qc(e){if(!/^\d+$/.test(e))return null;const r=Number.parseInt(e,10);return Number.isNaN(r)?null:r}function Sle(e){const r=XN(e),n=r.split(" ");if(n.length!==5)return r;const[i,s,o,a,l]=n,u=x7.find(h=>h.value===r);if(u)return u.description;const d=[];if(i==="*"&&s==="*"?d.push("Every minute"):i.startsWith("*/")?d.push(`Every ${i.slice(2)} minutes`):s==="*"?d.push(`At minute ${i} of every hour`):i==="0"?d.push(`At ${s}:00`):d.push(`At ${s}:${i.padStart(2,"0")}`),l!=="*"){const h=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],f=Qc(l);f!==null&&f>=0&&f<=6&&d.push(`on ${h[f]}`)}if(o!=="*"&&d.push(`on day ${o}`),a!=="*"){const h=["","January","February","March","April","May","June","July","August","September","October","November","December"],f=Qc(a);f!==null&&f>=1&&f<=12&&d.push(`in ${h[f]}`)}return d.join(" ")}function kle(e){const r=XN(e).split(" ");if(r.length!==5)return{valid:!1,error:"Cron expression must have 5 parts (minute hour day month weekday)"};const[n,i,s,o,a]=r,l=[{name:"minute",value:n,min:0,max:59},{name:"hour",value:i,min:0,max:23},{name:"day",value:s,min:1,max:31},{name:"month",value:o,min:1,max:12},{name:"weekday",value:a,min:0,max:6}];for(const u of l)if(!srt(u.value,u.min,u.max))return{valid:!1,error:`Invalid ${u.name}: ${u.value}`};return{valid:!0}}function srt(e,r,n){if(e==="*")return!0;if(e.startsWith("*/")){const s=Qc(e.slice(2));return s!==null&&s>0&&s<=n}if(e.includes("-")){const s=e.split("-");if(s.length!==2)return!1;const o=Qc(s[0]??""),a=Qc(s[1]??"");return o!==null&&a!==null&&o>=r&&a<=n&&o<=a}if(e.includes(","))return e.split(",").every(s=>{const o=Qc(s);return o!==null&&o>=r&&o<=n});const i=Qc(e);return i!==null&&i>=r&&i<=n}function ort(e){try{if(!kle(e).valid)return null;const r=new Date,n=XN(e).split(" "),[i,s]=n;if(i==="*"&&s==="*"){const o=new Date(r);return o.setMinutes(r.getMinutes()+1,0,0),o}if(i.startsWith("*/")){const o=Qc(i.slice(2));if(o===null||o<=0)return null;const a=new Date(r),l=Math.ceil(r.getMinutes()/o)*o;return l>=60?(a.setHours(a.getHours()+1),a.setMinutes(l%60)):a.setMinutes(l),a.setSeconds(0),a.setMilliseconds(0),a<=r&&a.setMinutes(a.getMinutes()+o),a}if(i!=="*"&&s==="*"){const o=Qc(i);if(o===null)return null;const a=new Date(r);return a.setMinutes(o,0,0),a<=r&&a.setHours(a.getHours()+1),a}if(i!=="*"&&s.startsWith("*/")){const o=Qc(i),a=Qc(s.slice(2));if(o===null||a===null||a<=0)return null;const l=new Date(r);l.setMinutes(o,0,0);const u=r.getHours(),d=u%a;let h=d===0?u:u+(a-d);return l.setHours(h),l<=r&&(h+=a,l.setHours(h)),l}if(i!=="*"&&s!=="*"){const o=Qc(i),a=Qc(s);if(o===null||a===null)return null;const l=new Date(r);return l.setHours(a),l.setMinutes(o),l.setSeconds(0),l.setMilliseconds(0),l<=r&&l.setDate(l.getDate()+1),l}return null}catch{return null}}function art(e){const r=new Date,n=e.getTime()-r.getTime();if(n<6e4)return"now";const i=Math.floor(n/6e4);if(i<60)return`in ${i}m`;const s=Math.floor(n/36e5);return s<24?`in ${s}h`:`in ${Math.floor(n/864e5)}d`}function lrt({job:e,recentRun:r,onToggle:n,onTrigger:i,onDelete:s,onEdit:o,onViewHistory:a,isLoading:l=!1}){const[u,d]=y.useState(!1),[h,f]=y.useState(!1),g=async w=>{d(!0);try{await n(e.id,w)}finally{d(!1)}},v=async()=>{f(!0);try{await i(e.id)}finally{f(!1)}},b=e.enabled?ort(e.cron_expression):null,_={agent_task:"Agent Task",system_job:"System Job"};return c.jsxs(gn,{"data-testid":`job-card-${e.id}`,className:Ae("transition-opacity",l&&"opacity-50",!e.enabled&&"opacity-75"),children:[c.jsx(hle,{className:"space-y-3 pb-3",children:c.jsxs("div",{className:"flex flex-col gap-3 md:flex-row md:items-start md:justify-between",children:[c.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[e.job_type==="agent_task"&&e.model&&e.provider&&c.jsx(hj,{provider:e.provider,model:e.model,size:32}),c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsx(fle,{className:"truncate text-base md:text-lg",children:e.name}),c.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2",children:[c.jsx($r,{variant:e.job_type==="agent_task"?"default":"secondary",children:_[e.job_type]}),e.provider&&c.jsx($r,{variant:"outline",className:"text-xs",children:e.provider})]})]})]}),c.jsxs("div",{className:"flex items-center justify-between rounded-md border bg-muted/20 px-3 py-2 md:min-w-[92px] md:justify-end md:border-0 md:bg-transparent md:p-0",children:[c.jsx("span",{className:"text-xs text-muted-foreground md:hidden",children:e.enabled?"Enabled":"Paused"}),c.jsx(Ap,{checked:e.enabled,onCheckedChange:g,disabled:u})]})]})}),c.jsxs(Kc,{className:"space-y-3 pt-0",children:[c.jsxs("div",{className:"flex flex-col gap-1 text-sm text-muted-foreground md:flex-row md:items-center md:gap-2",children:[c.jsx(xg,{className:"h-4 w-4"}),c.jsx("span",{className:"break-all font-mono",children:e.cron_expression}),c.jsxs("span",{className:"text-xs md:text-xs",children:["(",Sle(e.cron_expression),")"]})]}),b&&c.jsxs("div",{className:"text-sm text-muted-foreground",children:["Next run: ",b.toLocaleString()," (",art(b),")"]}),e.prompt&&c.jsxs("div",{className:"line-clamp-2 text-sm italic text-muted-foreground",children:['"',e.prompt,'"']}),r&&c.jsxs("div",{className:"flex flex-col gap-1 text-sm md:flex-row md:items-center md:gap-2",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[r.status==="completed"&&c.jsxs(c.Fragment,{children:[c.jsx(uo,{className:"h-4 w-4 text-green-500"}),c.jsx("span",{className:"text-green-600 dark:text-green-400",children:"Last run succeeded"})]}),r.status==="failed"&&c.jsxs(c.Fragment,{children:[c.jsx(ia,{className:"h-4 w-4 text-red-500"}),c.jsx("span",{className:"text-red-600 dark:text-red-400",children:"Last run failed"})]}),r.status==="running"&&c.jsxs(c.Fragment,{children:[c.jsx(Vt,{className:"h-4 w-4 animate-spin text-blue-500"}),c.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:"Running now..."})]})]}),r.started_at&&c.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(r.started_at).toLocaleString()})]}),c.jsxs("div",{className:"grid grid-cols-2 gap-2 border-t pt-3 md:grid-cols-[minmax(0,1fr)_auto_auto_auto] md:items-center",children:[c.jsxs(_e,{variant:"outline",size:"sm",onClick:v,disabled:h||!e.enabled,"data-testid":`job-trigger-${e.id}`,className:"w-full md:justify-self-start",children:[h?c.jsx(Vt,{className:"h-4 w-4 mr-1 animate-spin"}):c.jsx(DS,{className:"h-4 w-4 mr-1"}),"Run Now"]}),c.jsxs(_e,{variant:"ghost",size:"sm",onClick:()=>a(e),"data-testid":`job-history-${e.id}`,className:"w-full md:w-auto",children:[c.jsx(B5,{className:"h-4 w-4 mr-1"}),c.jsx("span",{className:"md:hidden lg:inline",children:"History"})]}),c.jsx(_e,{variant:"ghost",size:"icon",onClick:()=>o(e),"aria-label":`Edit job ${e.name}`,"data-testid":`job-edit-${e.id}`,className:"h-8 w-full md:w-8",children:c.jsx(fve,{className:"h-4 w-4"})}),c.jsx(_e,{variant:"ghost",size:"icon",onClick:()=>s(e.id),className:"h-8 w-full text-destructive hover:bg-destructive/10 hover:text-destructive md:w-8","aria-label":`Delete job ${e.name}`,"data-testid":`job-delete-${e.id}`,children:c.jsx(Tl,{className:"h-4 w-4"})})]})]})]})}function ZW(e,[r,n]){return Math.min(n,Math.max(r,e))}function crt(e,r=[]){let n=[];function i(o,a){const l=y.createContext(a),u=n.length;n=[...n,a];const d=f=>{var S;const{scope:g,children:v,...b}=f,_=((S=g==null?void 0:g[e])==null?void 0:S[u])||l,w=y.useMemo(()=>b,Object.values(b));return c.jsx(_.Provider,{value:w,children:v})};d.displayName=o+"Provider";function h(f,g){var _;const v=((_=g==null?void 0:g[e])==null?void 0:_[u])||l,b=y.useContext(v);if(b)return b;if(a!==void 0)return a;throw new Error(`\`${f}\` must be used within \`${o}\``)}return[d,h]}const s=()=>{const o=n.map(a=>y.createContext(a));return function(l){const u=(l==null?void 0:l[e])||o;return y.useMemo(()=>({[`__scope${e}`]:{...l,[e]:u}}),[l,u])}};return s.scopeName=e,[i,urt(s,...r)]}function urt(...e){const r=e[0];if(e.length===1)return r;const n=()=>{const i=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(o){const a=i.reduce((l,{useScope:u,scopeName:d})=>{const f=u(o)[`__scope${d}`];return{...l,...f}},{});return y.useMemo(()=>({[`__scope${r.scopeName}`]:a}),[a])}};return n.scopeName=r.scopeName,n}function Cle(e){const r=drt(e),n=y.forwardRef((i,s)=>{const{children:o,...a}=i,l=y.Children.toArray(o),u=l.find(frt);if(u){const d=u.props.children,h=l.map(f=>f===u?y.Children.count(d)>1?y.Children.only(null):y.isValidElement(d)?d.props.children:null:f);return c.jsx(r,{...a,ref:s,children:y.isValidElement(d)?y.cloneElement(d,void 0,h):null})}return c.jsx(r,{...a,ref:s,children:o})});return n.displayName=`${e}.Slot`,n}function drt(e){const r=y.forwardRef((n,i)=>{const{children:s,...o}=n;if(y.isValidElement(s)){const a=mrt(s),l=prt(o,s.props);return s.type!==y.Fragment&&(l.ref=i?ho(i,a):a),y.cloneElement(s,l)}return y.Children.count(s)>1?y.Children.only(null):null});return r.displayName=`${e}.SlotClone`,r}var hrt=Symbol("radix.slottable");function frt(e){return y.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===hrt}function prt(e,r){const n={...r};for(const i in r){const s=e[i],o=r[i];/^on[A-Z]/.test(i)?s&&o?n[i]=(...l)=>{const u=o(...l);return s(...l),u}:s&&(n[i]=s):i==="style"?n[i]={...s,...o}:i==="className"&&(n[i]=[s,o].filter(Boolean).join(" "))}return{...e,...n}}function mrt(e){var i,s;let r=(i=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:i.get,n=r&&"isReactWarning"in r&&r.isReactWarning;return n?e.ref:(r=(s=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:s.get,n=r&&"isReactWarning"in r&&r.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var grt=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],uu=grt.reduce((e,r)=>{const n=Cle(`Primitive.${r}`),i=y.forwardRef((s,o)=>{const{asChild:a,...l}=s,u=a?n:r;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(u,{...l,ref:o})});return i.displayName=`Primitive.${r}`,{...e,[r]:i}},{});function yrt(e){const r=vrt(e),n=y.forwardRef((i,s)=>{const{children:o,...a}=i,l=y.Children.toArray(o),u=l.find(brt);if(u){const d=u.props.children,h=l.map(f=>f===u?y.Children.count(d)>1?y.Children.only(null):y.isValidElement(d)?d.props.children:null:f);return c.jsx(r,{...a,ref:s,children:y.isValidElement(d)?y.cloneElement(d,void 0,h):null})}return c.jsx(r,{...a,ref:s,children:o})});return n.displayName=`${e}.Slot`,n}function vrt(e){const r=y.forwardRef((n,i)=>{const{children:s,...o}=n;if(y.isValidElement(s)){const a=wrt(s),l=_rt(o,s.props);return s.type!==y.Fragment&&(l.ref=i?ho(i,a):a),y.cloneElement(s,l)}return y.Children.count(s)>1?y.Children.only(null):null});return r.displayName=`${e}.SlotClone`,r}var xrt=Symbol("radix.slottable");function brt(e){return y.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===xrt}function _rt(e,r){const n={...r};for(const i in r){const s=e[i],o=r[i];/^on[A-Z]/.test(i)?s&&o?n[i]=(...l)=>{const u=o(...l);return s(...l),u}:s&&(n[i]=s):i==="style"?n[i]={...s,...o}:i==="className"&&(n[i]=[s,o].filter(Boolean).join(" "))}return{...e,...n}}function wrt(e){var i,s;let r=(i=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:i.get,n=r&&"isReactWarning"in r&&r.isReactWarning;return n?e.ref:(r=(s=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:s.get,n=r&&"isReactWarning"in r&&r.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Srt=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],krt=Srt.reduce((e,r)=>{const n=yrt(`Primitive.${r}`),i=y.forwardRef((s,o)=>{const{asChild:a,...l}=s,u=a?n:r;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(u,{...l,ref:o})});return i.displayName=`Primitive.${r}`,{...e,[r]:i}},{}),jle=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),Crt="VisuallyHidden",jrt=y.forwardRef((e,r)=>c.jsx(krt.span,{...e,ref:r,style:{...jle,...e.style}}));jrt.displayName=Crt;var Nrt=[" ","Enter","ArrowUp","ArrowDown"],Trt=[" ","Enter"],cy="Select",[JN,ZN,Ert]=SR(cy),[ux]=crt(cy,[Ert,Jv]),QN=Jv(),[Art,Ng]=ux(cy),[Ort,Mrt]=ux(cy),Nle=e=>{const{__scopeSelect:r,children:n,open:i,defaultOpen:s,onOpenChange:o,value:a,defaultValue:l,onValueChange:u,dir:d,name:h,autoComplete:f,disabled:g,required:v,form:b}=e,_=QN(r),[w,S]=y.useState(null),[C,j]=y.useState(null),[E,A]=y.useState(!1),N=z4(d),[P,H]=wp({prop:i,defaultProp:s??!1,onChange:o,caller:cy}),[K,F]=wp({prop:a,defaultProp:l,onChange:u,caller:cy}),B=y.useRef(null),W=w?b||!!w.closest("form"):!0,[D,O]=y.useState(new Set),I=Array.from(D).map(R=>R.props.value).join(";");return c.jsx(MR,{..._,children:c.jsxs(Art,{required:v,scope:r,trigger:w,onTriggerChange:S,valueNode:C,onValueNodeChange:j,valueNodeHasChildren:E,onValueNodeHasChildrenChange:A,contentId:Xu(),value:K,onValueChange:F,open:P,onOpenChange:H,dir:N,triggerPointerDownPosRef:B,disabled:g,children:[c.jsx(JN.Provider,{scope:r,children:c.jsx(Ort,{scope:e.__scopeSelect,onNativeOptionAdd:y.useCallback(R=>{O($=>new Set($).add(R))},[]),onNativeOptionRemove:y.useCallback(R=>{O($=>{const U=new Set($);return U.delete(R),U})},[]),children:n})}),W?c.jsxs(Jle,{"aria-hidden":!0,required:v,tabIndex:-1,name:h,autoComplete:f,value:K,onChange:R=>F(R.target.value),disabled:g,form:b,children:[K===void 0?c.jsx("option",{value:""}):null,Array.from(D)]},I):null]})})};Nle.displayName=cy;var Tle="SelectTrigger",Ele=y.forwardRef((e,r)=>{const{__scopeSelect:n,disabled:i=!1,...s}=e,o=QN(n),a=Ng(Tle,n),l=a.disabled||i,u=li(r,a.onTriggerChange),d=ZN(n),h=y.useRef("touch"),[f,g,v]=Qle(_=>{const w=d().filter(j=>!j.disabled),S=w.find(j=>j.value===a.value),C=ece(w,_,S);C!==void 0&&a.onValueChange(C.value)}),b=_=>{l||(a.onOpenChange(!0),v()),_&&(a.triggerPointerDownPosRef.current={x:Math.round(_.pageX),y:Math.round(_.pageY)})};return c.jsx(V4,{asChild:!0,...o,children:c.jsx(uu.button,{type:"button",role:"combobox","aria-controls":a.contentId,"aria-expanded":a.open,"aria-required":a.required,"aria-autocomplete":"none",dir:a.dir,"data-state":a.open?"open":"closed",disabled:l,"data-disabled":l?"":void 0,"data-placeholder":Zle(a.value)?"":void 0,...s,ref:u,onClick:kr(s.onClick,_=>{_.currentTarget.focus(),h.current!=="mouse"&&b(_)}),onPointerDown:kr(s.onPointerDown,_=>{h.current=_.pointerType;const w=_.target;w.hasPointerCapture(_.pointerId)&&w.releasePointerCapture(_.pointerId),_.button===0&&_.ctrlKey===!1&&_.pointerType==="mouse"&&(b(_),_.preventDefault())}),onKeyDown:kr(s.onKeyDown,_=>{const w=f.current!=="";!(_.ctrlKey||_.altKey||_.metaKey)&&_.key.length===1&&g(_.key),!(w&&_.key===" ")&&Nrt.includes(_.key)&&(b(),_.preventDefault())})})})});Ele.displayName=Tle;var Ale="SelectValue",Ole=y.forwardRef((e,r)=>{const{__scopeSelect:n,className:i,style:s,children:o,placeholder:a="",...l}=e,u=Ng(Ale,n),{onValueNodeHasChildrenChange:d}=u,h=o!==void 0,f=li(r,u.onValueNodeChange);return co(()=>{d(h)},[d,h]),c.jsx(uu.span,{...l,ref:f,style:{pointerEvents:"none"},children:Zle(u.value)?c.jsx(c.Fragment,{children:a}):o})});Ole.displayName=Ale;var Rrt="SelectIcon",Mle=y.forwardRef((e,r)=>{const{__scopeSelect:n,children:i,...s}=e;return c.jsx(uu.span,{"aria-hidden":!0,...s,ref:r,children:i||"▼"})});Mle.displayName=Rrt;var Prt="SelectPortal",Rle=e=>c.jsx(PS,{asChild:!0,...e});Rle.displayName=Prt;var uy="SelectContent",Ple=y.forwardRef((e,r)=>{const n=Ng(uy,e.__scopeSelect),[i,s]=y.useState();if(co(()=>{s(new DocumentFragment)},[]),!n.open){const o=i;return o?gy.createPortal(c.jsx(Lle,{scope:e.__scopeSelect,children:c.jsx(JN.Slot,{scope:e.__scopeSelect,children:c.jsx("div",{children:e.children})})}),o):null}return c.jsx($le,{...e,ref:r})});Ple.displayName=uy;var Ld=10,[Lle,Tg]=ux(uy),Lrt="SelectContentImpl",$rt=Cle("SelectContent.RemoveScroll"),$le=y.forwardRef((e,r)=>{const{__scopeSelect:n,position:i="item-aligned",onCloseAutoFocus:s,onEscapeKeyDown:o,onPointerDownOutside:a,side:l,sideOffset:u,align:d,alignOffset:h,arrowPadding:f,collisionBoundary:g,collisionPadding:v,sticky:b,hideWhenDetached:_,avoidCollisions:w,...S}=e,C=Ng(uy,n),[j,E]=y.useState(null),[A,N]=y.useState(null),P=li(r,ae=>E(ae)),[H,K]=y.useState(null),[F,B]=y.useState(null),W=ZN(n),[D,O]=y.useState(!1),I=y.useRef(!1);y.useEffect(()=>{if(j)return L4(j)},[j]),R4();const R=y.useCallback(ae=>{const[te,...ue]=W().map(pe=>pe.ref.current),[he]=ue.slice(-1),we=document.activeElement;for(const pe of ae)if(pe===we||(pe==null||pe.scrollIntoView({block:"nearest"}),pe===te&&A&&(A.scrollTop=0),pe===he&&A&&(A.scrollTop=A.scrollHeight),pe==null||pe.focus(),document.activeElement!==we))return},[W,A]),$=y.useCallback(()=>R([H,j]),[R,H,j]);y.useEffect(()=>{D&&$()},[D,$]);const{onOpenChange:U,triggerPointerDownPosRef:Y}=C;y.useEffect(()=>{if(j){let ae={x:0,y:0};const te=he=>{var we,pe;ae={x:Math.abs(Math.round(he.pageX)-(((we=Y.current)==null?void 0:we.x)??0)),y:Math.abs(Math.round(he.pageY)-(((pe=Y.current)==null?void 0:pe.y)??0))}},ue=he=>{ae.x<=10&&ae.y<=10?he.preventDefault():j.contains(he.target)||U(!1),document.removeEventListener("pointermove",te),Y.current=null};return Y.current!==null&&(document.addEventListener("pointermove",te),document.addEventListener("pointerup",ue,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",te),document.removeEventListener("pointerup",ue,{capture:!0})}}},[j,U,Y]),y.useEffect(()=>{const ae=()=>U(!1);return window.addEventListener("blur",ae),window.addEventListener("resize",ae),()=>{window.removeEventListener("blur",ae),window.removeEventListener("resize",ae)}},[U]);const[z,V]=Qle(ae=>{const te=W().filter(we=>!we.disabled),ue=te.find(we=>we.ref.current===document.activeElement),he=ece(te,ae,ue);he&&setTimeout(()=>he.ref.current.focus())}),Q=y.useCallback((ae,te,ue)=>{const he=!I.current&&!ue;(C.value!==void 0&&C.value===te||he)&&(K(ae),he&&(I.current=!0))},[C.value]),q=y.useCallback(()=>j==null?void 0:j.focus(),[j]),re=y.useCallback((ae,te,ue)=>{const he=!I.current&&!ue;(C.value!==void 0&&C.value===te||he)&&B(ae)},[C.value]),ee=i==="popper"?b7:Dle,ne=ee===b7?{side:l,sideOffset:u,align:d,alignOffset:h,arrowPadding:f,collisionBoundary:g,collisionPadding:v,sticky:b,hideWhenDetached:_,avoidCollisions:w}:{};return c.jsx(Lle,{scope:n,content:j,viewport:A,onViewportChange:N,itemRefCallback:Q,selectedItem:H,onItemLeave:q,itemTextRefCallback:re,focusSelectedItem:$,selectedItemText:F,position:i,isPositioned:D,searchRef:z,children:c.jsx($S,{as:$rt,allowPinchZoom:!0,children:c.jsx(RS,{asChild:!0,trapped:C.open,onMountAutoFocus:ae=>{ae.preventDefault()},onUnmountAutoFocus:kr(s,ae=>{var te;(te=C.trigger)==null||te.focus({preventScroll:!0}),ae.preventDefault()}),children:c.jsx(MS,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:a,onFocusOutside:ae=>ae.preventDefault(),onDismiss:()=>C.onOpenChange(!1),children:c.jsx(ee,{role:"listbox",id:C.contentId,"data-state":C.open?"open":"closed",dir:C.dir,onContextMenu:ae=>ae.preventDefault(),...S,...ne,onPlaced:()=>O(!0),ref:P,style:{display:"flex",flexDirection:"column",outline:"none",...S.style},onKeyDown:kr(S.onKeyDown,ae=>{const te=ae.ctrlKey||ae.altKey||ae.metaKey;if(ae.key==="Tab"&&ae.preventDefault(),!te&&ae.key.length===1&&V(ae.key),["ArrowUp","ArrowDown","Home","End"].includes(ae.key)){let he=W().filter(we=>!we.disabled).map(we=>we.ref.current);if(["ArrowUp","End"].includes(ae.key)&&(he=he.slice().reverse()),["ArrowUp","ArrowDown"].includes(ae.key)){const we=ae.target,pe=he.indexOf(we);he=he.slice(pe+1)}setTimeout(()=>R(he)),ae.preventDefault()}})})})})})})});$le.displayName=Lrt;var Drt="SelectItemAlignedPosition",Dle=y.forwardRef((e,r)=>{const{__scopeSelect:n,onPlaced:i,...s}=e,o=Ng(uy,n),a=Tg(uy,n),[l,u]=y.useState(null),[d,h]=y.useState(null),f=li(r,P=>h(P)),g=ZN(n),v=y.useRef(!1),b=y.useRef(!0),{viewport:_,selectedItem:w,selectedItemText:S,focusSelectedItem:C}=a,j=y.useCallback(()=>{if(o.trigger&&o.valueNode&&l&&d&&_&&w&&S){const P=o.trigger.getBoundingClientRect(),H=d.getBoundingClientRect(),K=o.valueNode.getBoundingClientRect(),F=S.getBoundingClientRect();if(o.dir!=="rtl"){const we=F.left-H.left,pe=K.left-we,qe=P.left-pe,se=P.width+qe,it=Math.max(se,H.width),Ye=window.innerWidth-Ld,ht=ZW(pe,[Ld,Math.max(Ld,Ye-it)]);l.style.minWidth=se+"px",l.style.left=ht+"px"}else{const we=H.right-F.right,pe=window.innerWidth-K.right-we,qe=window.innerWidth-P.right-pe,se=P.width+qe,it=Math.max(se,H.width),Ye=window.innerWidth-Ld,ht=ZW(pe,[Ld,Math.max(Ld,Ye-it)]);l.style.minWidth=se+"px",l.style.right=ht+"px"}const B=g(),W=window.innerHeight-Ld*2,D=_.scrollHeight,O=window.getComputedStyle(d),I=parseInt(O.borderTopWidth,10),R=parseInt(O.paddingTop,10),$=parseInt(O.borderBottomWidth,10),U=parseInt(O.paddingBottom,10),Y=I+R+D+U+$,z=Math.min(w.offsetHeight*5,Y),V=window.getComputedStyle(_),Q=parseInt(V.paddingTop,10),q=parseInt(V.paddingBottom,10),re=P.top+P.height/2-Ld,ee=W-re,ne=w.offsetHeight/2,ae=w.offsetTop+ne,te=I+R+ae,ue=Y-te;if(te<=re){const we=B.length>0&&w===B[B.length-1].ref.current;l.style.bottom="0px";const pe=d.clientHeight-_.offsetTop-_.offsetHeight,qe=Math.max(ee,ne+(we?q:0)+pe+$),se=te+qe;l.style.height=se+"px"}else{const we=B.length>0&&w===B[0].ref.current;l.style.top="0px";const qe=Math.max(re,I+_.offsetTop+(we?Q:0)+ne)+ue;l.style.height=qe+"px",_.scrollTop=te-re+_.offsetTop}l.style.margin=`${Ld}px 0`,l.style.minHeight=z+"px",l.style.maxHeight=W+"px",i==null||i(),requestAnimationFrame(()=>v.current=!0)}},[g,o.trigger,o.valueNode,l,d,_,w,S,o.dir,i]);co(()=>j(),[j]);const[E,A]=y.useState();co(()=>{d&&A(window.getComputedStyle(d).zIndex)},[d]);const N=y.useCallback(P=>{P&&b.current===!0&&(j(),C==null||C(),b.current=!1)},[j,C]);return c.jsx(Brt,{scope:n,contentWrapper:l,shouldExpandOnScrollRef:v,onScrollButtonChange:N,children:c.jsx("div",{ref:u,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:E},children:c.jsx(uu.div,{...s,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...s.style}})})})});Dle.displayName=Drt;var Irt="SelectPopperPosition",b7=y.forwardRef((e,r)=>{const{__scopeSelect:n,align:i="start",collisionPadding:s=Ld,...o}=e,a=QN(n);return c.jsx(RR,{...a,...o,ref:r,align:i,collisionPadding:s,style:{boxSizing:"border-box",...o.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});b7.displayName=Irt;var[Brt,eL]=ux(uy,{}),_7="SelectViewport",Ile=y.forwardRef((e,r)=>{const{__scopeSelect:n,nonce:i,...s}=e,o=Tg(_7,n),a=eL(_7,n),l=li(r,o.onViewportChange),u=y.useRef(0);return c.jsxs(c.Fragment,{children:[c.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:i}),c.jsx(JN.Slot,{scope:n,children:c.jsx(uu.div,{"data-radix-select-viewport":"",role:"presentation",...s,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...s.style},onScroll:kr(s.onScroll,d=>{const h=d.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:g}=a;if(g!=null&&g.current&&f){const v=Math.abs(u.current-h.scrollTop);if(v>0){const b=window.innerHeight-Ld*2,_=parseFloat(f.style.minHeight),w=parseFloat(f.style.height),S=Math.max(_,w);if(S<b){const C=S+v,j=Math.min(b,C),E=C-j;f.style.height=j+"px",f.style.bottom==="0px"&&(h.scrollTop=E>0?E:0,f.style.justifyContent="flex-end")}}}u.current=h.scrollTop})})})]})});Ile.displayName=_7;var Ble="SelectGroup",[zrt,Frt]=ux(Ble),Hrt=y.forwardRef((e,r)=>{const{__scopeSelect:n,...i}=e,s=Xu();return c.jsx(zrt,{scope:n,id:s,children:c.jsx(uu.div,{role:"group","aria-labelledby":s,...i,ref:r})})});Hrt.displayName=Ble;var zle="SelectLabel",Fle=y.forwardRef((e,r)=>{const{__scopeSelect:n,...i}=e,s=Frt(zle,n);return c.jsx(uu.div,{id:s.id,...i,ref:r})});Fle.displayName=zle;var r4="SelectItem",[Wrt,Hle]=ux(r4),Wle=y.forwardRef((e,r)=>{const{__scopeSelect:n,value:i,disabled:s=!1,textValue:o,...a}=e,l=Ng(r4,n),u=Tg(r4,n),d=l.value===i,[h,f]=y.useState(o??""),[g,v]=y.useState(!1),b=li(r,C=>{var j;return(j=u.itemRefCallback)==null?void 0:j.call(u,C,i,s)}),_=Xu(),w=y.useRef("touch"),S=()=>{s||(l.onValueChange(i),l.onOpenChange(!1))};if(i==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return c.jsx(Wrt,{scope:n,value:i,disabled:s,textId:_,isSelected:d,onItemTextChange:y.useCallback(C=>{f(j=>j||((C==null?void 0:C.textContent)??"").trim())},[]),children:c.jsx(JN.ItemSlot,{scope:n,value:i,disabled:s,textValue:h,children:c.jsx(uu.div,{role:"option","aria-labelledby":_,"data-highlighted":g?"":void 0,"aria-selected":d&&g,"data-state":d?"checked":"unchecked","aria-disabled":s||void 0,"data-disabled":s?"":void 0,tabIndex:s?void 0:-1,...a,ref:b,onFocus:kr(a.onFocus,()=>v(!0)),onBlur:kr(a.onBlur,()=>v(!1)),onClick:kr(a.onClick,()=>{w.current!=="mouse"&&S()}),onPointerUp:kr(a.onPointerUp,()=>{w.current==="mouse"&&S()}),onPointerDown:kr(a.onPointerDown,C=>{w.current=C.pointerType}),onPointerMove:kr(a.onPointerMove,C=>{var j;w.current=C.pointerType,s?(j=u.onItemLeave)==null||j.call(u):w.current==="mouse"&&C.currentTarget.focus({preventScroll:!0})}),onPointerLeave:kr(a.onPointerLeave,C=>{var j;C.currentTarget===document.activeElement&&((j=u.onItemLeave)==null||j.call(u))}),onKeyDown:kr(a.onKeyDown,C=>{var E;((E=u.searchRef)==null?void 0:E.current)!==""&&C.key===" "||(Trt.includes(C.key)&&S(),C.key===" "&&C.preventDefault())})})})})});Wle.displayName=r4;var I_="SelectItemText",Ule=y.forwardRef((e,r)=>{const{__scopeSelect:n,className:i,style:s,...o}=e,a=Ng(I_,n),l=Tg(I_,n),u=Hle(I_,n),d=Mrt(I_,n),[h,f]=y.useState(null),g=li(r,S=>f(S),u.onItemTextChange,S=>{var C;return(C=l.itemTextRefCallback)==null?void 0:C.call(l,S,u.value,u.disabled)}),v=h==null?void 0:h.textContent,b=y.useMemo(()=>c.jsx("option",{value:u.value,disabled:u.disabled,children:v},u.value),[u.disabled,u.value,v]),{onNativeOptionAdd:_,onNativeOptionRemove:w}=d;return co(()=>(_(b),()=>w(b)),[_,w,b]),c.jsxs(c.Fragment,{children:[c.jsx(uu.span,{id:u.textId,...o,ref:g}),u.isSelected&&a.valueNode&&!a.valueNodeHasChildren?gy.createPortal(o.children,a.valueNode):null]})});Ule.displayName=I_;var Vle="SelectItemIndicator",qle=y.forwardRef((e,r)=>{const{__scopeSelect:n,...i}=e;return Hle(Vle,n).isSelected?c.jsx(uu.span,{"aria-hidden":!0,...i,ref:r}):null});qle.displayName=Vle;var w7="SelectScrollUpButton",Gle=y.forwardRef((e,r)=>{const n=Tg(w7,e.__scopeSelect),i=eL(w7,e.__scopeSelect),[s,o]=y.useState(!1),a=li(r,i.onScrollButtonChange);return co(()=>{if(n.viewport&&n.isPositioned){let l=function(){const d=u.scrollTop>0;o(d)};const u=n.viewport;return l(),u.addEventListener("scroll",l),()=>u.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),s?c.jsx(Yle,{...e,ref:a,onAutoScroll:()=>{const{viewport:l,selectedItem:u}=n;l&&u&&(l.scrollTop=l.scrollTop-u.offsetHeight)}}):null});Gle.displayName=w7;var S7="SelectScrollDownButton",Kle=y.forwardRef((e,r)=>{const n=Tg(S7,e.__scopeSelect),i=eL(S7,e.__scopeSelect),[s,o]=y.useState(!1),a=li(r,i.onScrollButtonChange);return co(()=>{if(n.viewport&&n.isPositioned){let l=function(){const d=u.scrollHeight-u.clientHeight,h=Math.ceil(u.scrollTop)<d;o(h)};const u=n.viewport;return l(),u.addEventListener("scroll",l),()=>u.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),s?c.jsx(Yle,{...e,ref:a,onAutoScroll:()=>{const{viewport:l,selectedItem:u}=n;l&&u&&(l.scrollTop=l.scrollTop+u.offsetHeight)}}):null});Kle.displayName=S7;var Yle=y.forwardRef((e,r)=>{const{__scopeSelect:n,onAutoScroll:i,...s}=e,o=Tg("SelectScrollButton",n),a=y.useRef(null),l=ZN(n),u=y.useCallback(()=>{a.current!==null&&(window.clearInterval(a.current),a.current=null)},[]);return y.useEffect(()=>()=>u(),[u]),co(()=>{var h;const d=l().find(f=>f.ref.current===document.activeElement);(h=d==null?void 0:d.ref.current)==null||h.scrollIntoView({block:"nearest"})},[l]),c.jsx(uu.div,{"aria-hidden":!0,...s,ref:r,style:{flexShrink:0,...s.style},onPointerDown:kr(s.onPointerDown,()=>{a.current===null&&(a.current=window.setInterval(i,50))}),onPointerMove:kr(s.onPointerMove,()=>{var d;(d=o.onItemLeave)==null||d.call(o),a.current===null&&(a.current=window.setInterval(i,50))}),onPointerLeave:kr(s.onPointerLeave,()=>{u()})})}),Urt="SelectSeparator",Xle=y.forwardRef((e,r)=>{const{__scopeSelect:n,...i}=e;return c.jsx(uu.div,{"aria-hidden":!0,...i,ref:r})});Xle.displayName=Urt;var k7="SelectArrow",Vrt=y.forwardRef((e,r)=>{const{__scopeSelect:n,...i}=e,s=QN(n),o=Ng(k7,n),a=Tg(k7,n);return o.open&&a.position==="popper"?c.jsx(PR,{...s,...i,ref:r}):null});Vrt.displayName=k7;var qrt="SelectBubbleInput",Jle=y.forwardRef(({__scopeSelect:e,value:r,...n},i)=>{const s=y.useRef(null),o=li(i,s),a=mle(r);return y.useEffect(()=>{const l=s.current;if(!l)return;const u=window.HTMLSelectElement.prototype,h=Object.getOwnPropertyDescriptor(u,"value").set;if(a!==r&&h){const f=new Event("change",{bubbles:!0});h.call(l,r),l.dispatchEvent(f)}},[a,r]),c.jsx(uu.select,{...n,style:{...jle,...n.style},ref:o,defaultValue:r})});Jle.displayName=qrt;function Zle(e){return e===""||e===void 0}function Qle(e){const r=ih(e),n=y.useRef(""),i=y.useRef(0),s=y.useCallback(a=>{const l=n.current+a;r(l),(function u(d){n.current=d,window.clearTimeout(i.current),d!==""&&(i.current=window.setTimeout(()=>u(""),1e3))})(l)},[r]),o=y.useCallback(()=>{n.current="",window.clearTimeout(i.current)},[]);return y.useEffect(()=>()=>window.clearTimeout(i.current),[]),[n,s,o]}function ece(e,r,n){const s=r.length>1&&Array.from(r).every(d=>d===r[0])?r[0]:r,o=n?e.indexOf(n):-1;let a=Grt(e,Math.max(o,0));s.length===1&&(a=a.filter(d=>d!==n));const u=a.find(d=>d.textValue.toLowerCase().startsWith(s.toLowerCase()));return u!==n?u:void 0}function Grt(e,r){return e.map((n,i)=>e[(r+i)%e.length])}var Krt=Nle,tce=Ele,Yrt=Ole,Xrt=Mle,Jrt=Rle,rce=Ple,Zrt=Ile,nce=Fle,ice=Wle,Qrt=Ule,ent=qle,sce=Gle,oce=Kle,ace=Xle;const th=Krt,rh=Yrt,Zu=y.forwardRef(({className:e,children:r,...n},i)=>c.jsxs(tce,{ref:i,className:Ae("flex h-10 w-full items-center justify-between whitespace-nowrap rounded-lg border border-input bg-background/90 px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring/60 focus:ring-offset-2 focus:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[r,c.jsx(Xrt,{asChild:!0,children:c.jsx(Ml,{className:"h-4 w-4 opacity-50"})})]}));Zu.displayName=tce.displayName;const lce=y.forwardRef(({className:e,...r},n)=>c.jsx(sce,{ref:n,className:Ae("flex cursor-default items-center justify-center py-1",e),...r,children:c.jsx(pR,{className:"h-4 w-4"})}));lce.displayName=sce.displayName;const cce=y.forwardRef(({className:e,...r},n)=>c.jsx(oce,{ref:n,className:Ae("flex cursor-default items-center justify-center py-1",e),...r,children:c.jsx(Ml,{className:"h-4 w-4"})}));cce.displayName=oce.displayName;const Qu=y.forwardRef(({className:e,children:r,position:n="popper",...i},s)=>c.jsx(Jrt,{children:c.jsxs(rce,{ref:s,className:Ae("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-xl border border-border/70 bg-popover text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...i,children:[c.jsx(lce,{}),c.jsx(Zrt,{className:Ae("p-1",n==="popper"&&"w-full min-w-[var(--radix-select-trigger-width)]"),children:r}),c.jsx(cce,{})]})}));Qu.displayName=rce.displayName;const tnt=y.forwardRef(({className:e,...r},n)=>c.jsx(nce,{ref:n,className:Ae("px-2 py-1.5 text-sm font-semibold",e),...r}));tnt.displayName=nce.displayName;const Ls=y.forwardRef(({className:e,children:r,...n},i)=>c.jsxs(ice,{ref:i,className:Ae("relative flex w-full cursor-default select-none items-center rounded-md py-2 pl-2.5 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[c.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(ent,{children:c.jsx(fs,{className:"h-4 w-4"})})}),c.jsx(Qrt,{children:r})]}));Ls.displayName=ice.displayName;const rnt=y.forwardRef(({className:e,...r},n)=>c.jsx(ace,{ref:n,className:Ae("-mx-1 my-1 h-px bg-muted",e),...r}));rnt.displayName=ace.displayName;const Nm=Kn();class tL{getToken(){return Gm()}getHeaders(r=!1){const n={};r&&(n["Content-Type"]="application/json");const i=this.getToken();return i&&(n.Authorization=`Bearer ${i}`),n}async listJobsPage(r=1,n=20,i=!0){const s=new URLSearchParams({page:r.toString(),size:n.toString(),include_disabled:i.toString()}),o=await fetch(`${Nm}/api/jobs?${s}`,{headers:this.getHeaders()});if(!o.ok)throw new Error(`Failed to list jobs: ${o.statusText}`);const a=await o.json();if(Array.isArray(a))return{items:a,total:a.length,page:1,size:a.length};const l=a&&typeof a=="object"?a:{},u=Array.isArray(l.items)?l.items:[],d=typeof l.total=="number"?l.total:u.length,h=typeof l.page=="number"?l.page:r,f=typeof l.size=="number"?l.size:n;return{items:u,total:d,page:h,size:f}}async listJobs(r=1,n=100,i=!0){return(await this.listJobsPage(r,n,i)).items}async getJob(r){const n=await fetch(`${Nm}/api/jobs/${r}`,{headers:this.getHeaders()});if(!n.ok)throw new Error(`Failed to get job: ${n.statusText}`);return n.json()}async createJob(r){const n=await fetch(`${Nm}/api/jobs`,{method:"POST",headers:this.getHeaders(!0),body:JSON.stringify(r)});if(!n.ok){const i=await n.json().catch(()=>({detail:n.statusText}));throw new Error(i.detail||"Failed to create job")}return n.json()}async updateJob(r,n){const i=await fetch(`${Nm}/api/jobs/${r}`,{method:"PATCH",headers:this.getHeaders(!0),body:JSON.stringify(n)});if(!i.ok){const s=await i.json().catch(()=>({detail:i.statusText}));throw new Error(s.detail||"Failed to update job")}return i.json()}async deleteJob(r){const n=await fetch(`${Nm}/api/jobs/${r}`,{method:"DELETE",headers:this.getHeaders()});if(!n.ok)throw new Error(`Failed to delete job: ${n.statusText}`)}async triggerJob(r){const n=await fetch(`${Nm}/api/jobs/${r}/trigger`,{method:"POST",headers:this.getHeaders(!0),body:JSON.stringify({})});if(!n.ok){const i=await n.json().catch(()=>({detail:n.statusText}));throw new Error(i.detail||`Failed to trigger job: ${n.statusText}`)}return n.json()}async getJobRuns(r,n=20,i=1){const s=new URLSearchParams({page:i.toString(),size:n.toString()}),o=await fetch(`${Nm}/api/jobs/${r}/runs?${s}`,{headers:this.getHeaders()});if(!o.ok)throw new Error(`Failed to get job runs: ${o.statusText}`);const a=await o.json();return Array.isArray(a)?a:a.items??[]}async getAvailableProviders(){const r=await fetch(`${Nm}/api/jobs/providers/available`,{headers:this.getHeaders()});if(!r.ok)throw new Error(`Failed to get providers: ${r.statusText}`);const n=await r.json();return n.providers&&!Array.isArray(n.providers)?n.providers:n}}const x3=new tL;function nnt({isOpen:e,onClose:r,onCreated:n,editJob:i,onUpdated:s}){const[o,a]=y.useState(!1),[l,u]=y.useState(null),[d,h]=y.useState({}),[f,g]=y.useState(""),[v,b]=y.useState("agent_task"),[_,w]=y.useState("0 * * * *"),[S,C]=y.useState(""),[j,E]=y.useState(!1),[A,N]=y.useState(!0),[P,H]=y.useState(""),[K,F]=y.useState(""),[B,W]=y.useState(""),[D,O]=y.useState(""),[I,R]=y.useState("");y.useEffect(()=>{x3.getAvailableProviders().then(h).catch(console.error)},[]);const $=V=>{if(g(V.name),b(V.job_type),w(V.cron_expression),N(V.enabled),H(V.provider||""),F(V.model||""),W(V.prompt||""),V.job_type==="system_job"){const re=V.payload&&typeof V.payload=="object"?V.payload:void 0,ee=typeof(re==null?void 0:re.command)=="string"?re.command:void 0,ne=typeof V.tool_name=="string"?V.tool_name:"";O(ee||ne);const ae=re==null?void 0:re.args;if(ae&&typeof ae=="object")try{R(JSON.stringify(ae,null,2))}catch{R("")}else R("")}else R(""),O("");const Q=(V.cron_expression||"").trim(),q=x7.some(re=>re.value===Q);E(!q),C(q?"":Q)};y.useEffect(()=>{if(i){$(i);let V=!1;return x3.getJob(i.id).then(Q=>{V||$(Q)}).catch(()=>{}),()=>{V=!0}}else g(""),b("agent_task"),w("0 * * * *"),C(""),E(!1),N(!0),H(""),F(""),W(""),O(""),R("")},[i,e]);const U=j?S:_,Y=kle(U),z=async V=>{if(V.preventDefault(),u(null),!Y.valid){u(Y.error||"Invalid cron expression");return}const Q=XN(U),q={name:f,job_type:v,cron_expression:Q,enabled:A};if(v==="agent_task"){if(!P||!K||!B){u("Provider, model, and prompt are required for agent tasks");return}q.provider=P,q.model=K,q.prompt=B}else{if(!D){u("Command is required for system jobs");return}const re={command:D};if(I)try{re.args=JSON.parse(I)}catch{u("Args must be valid JSON");return}q.payload=re}a(!0);try{if(i){const re=await x3.updateJob(i.id,q);s==null||s(re)}else{const re=await x3.createJob(q);n(re)}r()}catch(re){u(re instanceof Error?re.message:"Failed to save job")}finally{a(!1)}};return e?c.jsx("div",{className:"fixed inset-0 z-50 flex items-end justify-center bg-black/50 sm:items-center",children:c.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"create-job-dialog-title","data-testid":"create-job-dialog",className:"h-[92dvh] w-full overflow-y-auto border border-border bg-background text-foreground shadow-xl sm:h-auto sm:max-h-[90vh] sm:max-w-2xl sm:rounded-lg",children:[c.jsxs("div",{className:"flex items-center justify-between border-b px-4 py-3 sm:p-4",children:[c.jsx("h2",{id:"create-job-dialog-title",className:"text-lg font-semibold sm:text-xl",children:i?"Edit Job":"Create New Job"}),c.jsx(_e,{variant:"ghost",size:"sm",onClick:r,"aria-label":"Close dialog",children:c.jsx(Vn,{className:"h-5 w-5"})})]}),c.jsxs("form",{onSubmit:z,className:"space-y-5 p-4 sm:space-y-6",children:[c.jsxs(Y0,{value:v,onValueChange:V=>b(V),children:[c.jsxs(ag,{className:"grid h-auto w-full grid-cols-2",children:[c.jsx(so,{value:"agent_task",children:"Agent Task"}),c.jsx(so,{value:"system_job",children:"System Job"})]}),c.jsxs(oo,{value:"agent_task",className:"space-y-4 mt-4",children:[c.jsxs("div",{children:[c.jsx(di,{htmlFor:"provider",children:"Provider"}),c.jsxs(th,{value:P,onValueChange:V=>{H(V),F("")},children:[c.jsx(Zu,{"data-testid":"provider-select",children:c.jsx(rh,{placeholder:"Select provider"})}),c.jsx(Qu,{children:Object.entries(d).map(([V,Q])=>c.jsx(Ls,{value:V,children:c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(hj,{provider:V,size:20}),c.jsx("span",{children:Q.name})]})},V))})]})]}),P&&d[P]&&c.jsxs("div",{children:[c.jsx(di,{htmlFor:"model",children:"Model"}),c.jsxs(th,{value:K,onValueChange:F,children:[c.jsx(Zu,{"data-testid":"model-select",children:c.jsx(rh,{placeholder:"Select model"})}),c.jsx(Qu,{children:d[P].models.map(V=>c.jsx(Ls,{value:V,children:c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(hj,{provider:P,model:V,size:20}),c.jsx("span",{children:V})]})},V))})]})]}),c.jsxs("div",{children:[c.jsx(di,{htmlFor:"prompt",children:"Prompt"}),c.jsx(jp,{id:"prompt",value:B,onChange:V=>W(V.target.value),placeholder:"What should the agent do?",rows:4})]})]}),c.jsxs(oo,{value:"system_job",className:"space-y-4 mt-4",children:[c.jsxs("div",{children:[c.jsx(di,{htmlFor:"command",children:"Command"}),c.jsx(Pn,{id:"command",value:D,onChange:V=>O(V.target.value),placeholder:"e.g., cleanup_old_files"})]}),c.jsxs("div",{children:[c.jsx(di,{htmlFor:"args",children:"Arguments (JSON)"}),c.jsx(jp,{id:"args",value:I,onChange:V=>R(V.target.value),placeholder:'{"days": 30}',rows:3})]})]})]}),c.jsxs("div",{className:"border-t pt-4 space-y-4",children:[c.jsxs("div",{children:[c.jsx(di,{htmlFor:"name",children:"Job Name"}),c.jsx(Pn,{id:"name",value:f,onChange:V=>g(V.target.value),placeholder:"My scheduled job",required:!0})]}),c.jsxs("div",{children:[c.jsxs("div",{className:"mb-2 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[c.jsx(di,{children:"Schedule"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(di,{htmlFor:"custom-schedule",className:"text-sm text-muted-foreground",children:"Custom"}),c.jsx(Ap,{id:"custom-schedule",checked:j,onCheckedChange:E})]})]}),j?c.jsxs("div",{children:[c.jsx(Pn,{value:S,onChange:V=>C(V.target.value),placeholder:"* * * * *",className:Y.valid?"":"border-red-500"}),S&&c.jsx("p",{className:`text-sm mt-1 ${Y.valid?"text-muted-foreground":"text-red-500"}`,children:Y.valid?Sle(S):Y.error})]}):c.jsxs(th,{value:_,onValueChange:w,children:[c.jsx(Zu,{"data-testid":"schedule-select",children:c.jsx(rh,{})}),c.jsx(Qu,{children:x7.map(V=>c.jsx(Ls,{value:V.value,children:c.jsxs("div",{className:"flex flex-col",children:[c.jsx("span",{children:V.label}),c.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:V.value})]})},V.value))})]})]}),c.jsxs("div",{className:"flex items-center justify-between gap-3",children:[c.jsxs("div",{children:[c.jsx(di,{htmlFor:"enabled",children:"Enabled"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Job will run according to schedule"})]}),c.jsx(Ap,{id:"enabled",checked:A,onCheckedChange:N})]})]}),l&&c.jsxs("div",{className:"flex items-center gap-2 text-destructive text-sm bg-destructive/10 p-3 rounded-md",children:[c.jsx(ia,{className:"h-4 w-4"}),l]}),c.jsxs("div",{className:"grid grid-cols-1 gap-3 border-t pt-4 sm:flex sm:justify-end",children:[c.jsx(_e,{type:"button",variant:"outline",onClick:r,className:"w-full sm:w-auto",children:"Cancel"}),c.jsxs(_e,{type:"submit",disabled:o,className:"w-full sm:w-auto",children:[o&&c.jsx(Vt,{className:"h-4 w-4 mr-2 animate-spin"}),i?"Save Changes":"Create Job"]})]})]})]})}):null}const int=new tL;function snt({job:e,isOpen:r,onClose:n}){const[i,s]=y.useState([]),[o,a]=y.useState(!1),[l,u]=y.useState(null),d=async()=>{if(e){a(!0),u(null);try{const v=await int.getJobRuns(e.id,50);s(v)}catch(v){u(v instanceof Error?v.message:"Failed to load history")}finally{a(!1)}}};if(y.useEffect(()=>{r&&e&&d()},[r,e==null?void 0:e.id]),!r||!e)return null;const h=v=>{switch(v){case"completed":return c.jsx(uo,{className:"h-4 w-4 text-green-500"});case"failed":return c.jsx(ia,{className:"h-4 w-4 text-red-500"});case"running":return c.jsx(Vt,{className:"h-4 w-4 text-blue-500 animate-spin"});case"pending":return c.jsx(xg,{className:"h-4 w-4 text-yellow-500"});default:return null}},f=v=>{const b={completed:"default",failed:"destructive",running:"secondary",pending:"outline"};return c.jsx($r,{variant:b[v]||"outline",children:v})},g=(v,b)=>{if(!b)return"—";const _=new Date(v),S=new Date(b).getTime()-_.getTime();return S<1e3?`${S}ms`:S<6e4?`${(S/1e3).toFixed(1)}s`:`${(S/6e4).toFixed(1)}m`};return c.jsx("div",{className:"fixed inset-0 z-50 flex items-end justify-center bg-black/50 sm:items-center",children:c.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"job-history-dialog-title","data-testid":"job-history-dialog",className:"flex h-[92dvh] w-full flex-col overflow-hidden border border-border bg-background text-foreground shadow-xl sm:h-auto sm:max-h-[90vh] sm:max-w-3xl sm:rounded-lg",children:[c.jsxs("div",{className:"flex items-start justify-between gap-3 border-b px-4 py-3 sm:p-4",children:[c.jsxs("div",{className:"min-w-0",children:[c.jsx("h2",{id:"job-history-dialog-title",className:"text-lg font-semibold sm:text-xl",children:"Job History"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:e.name})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(_e,{variant:"outline",size:"sm",onClick:d,disabled:o,children:c.jsx(io,{className:`h-4 w-4 ${o?"animate-spin":""}`})}),c.jsx(_e,{variant:"ghost",size:"sm",onClick:n,"aria-label":"Close history dialog",children:c.jsx(Vn,{className:"h-5 w-5"})})]})]}),c.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[l&&c.jsxs("div",{className:"flex items-center gap-2 text-destructive text-sm bg-destructive/10 p-3 rounded-md mb-4",children:[c.jsx(ia,{className:"h-4 w-4"}),l]}),o&&i.length===0?c.jsx("div",{className:"flex items-center justify-center py-12",children:c.jsx(Vt,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):i.length===0?c.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"No runs yet. This job hasn't been executed."}):c.jsx("div",{className:"space-y-3",children:i.map(v=>c.jsxs("div",{className:"border border-border rounded-lg p-4 hover:bg-muted/40 transition-colors",children:[c.jsxs("div",{className:"mb-2 flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[c.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[h(v.status),f(v.status),v.triggered_by&&c.jsxs("span",{className:"text-xs text-muted-foreground",children:["by ",v.triggered_by]})]}),c.jsxs("div",{className:"text-sm text-muted-foreground",children:["Duration: ",g(v.started_at,v.completed_at)]})]}),c.jsxs("div",{className:"mb-2 text-sm text-muted-foreground",children:[c.jsx("span",{className:"font-medium",children:"Started:"})," ",v.started_at?new Date(v.started_at).toLocaleString():"Not started",v.completed_at&&c.jsxs(c.Fragment,{children:[" → ",c.jsx("span",{className:"font-medium",children:"Completed:"})," ",new Date(v.completed_at).toLocaleString()]})]}),v.status==="completed"&&v.result&&c.jsxs("details",{className:"mt-2",children:[c.jsx("summary",{className:"text-sm text-green-600 dark:text-green-400 cursor-pointer hover:underline",children:"View result"}),c.jsx("pre",{className:"mt-2 p-2 bg-muted rounded text-xs overflow-x-auto",children:typeof v.result=="string"?v.result:JSON.stringify(v.result,null,2)})]}),v.status==="failed"&&v.error&&c.jsxs("div",{className:"mt-2 p-2 bg-destructive/10 rounded text-sm text-destructive",children:[c.jsx("strong",{children:"Error:"})," ",v.error]})]},v.id))})]})]})})}const e_=new tL,ont=20,ant=[10,20,50,100];function lnt(){const e=_g(),[r,n]=y.useState([]),[i,s]=y.useState({}),[o,a]=y.useState(0),[l,u]=y.useState(1),[d,h]=y.useState(ont),[f,g]=y.useState(!0),[v,b]=y.useState(null),[_,w]=y.useState(!1),[S,C]=y.useState(null),[j,E]=y.useState(null),A=y.useCallback(async($,U)=>{g(!0),b(null);try{const Y=await e_.listJobsPage($,U,!0);n(Y.items),a(Y.total),u(Y.page),h(Y.size);const z={};await Promise.all(Y.items.map(async V=>{try{const Q=await e_.getJobRuns(V.id,1);z[V.id]=Q[0]||null}catch{z[V.id]=null}})),s(V=>({...V,...z}))}catch(Y){b(Y instanceof Error?Y.message:"Failed to load jobs")}finally{g(!1)}},[]);y.useEffect(()=>{A(l,d)},[A,l,d]);const N=async($,U)=>{try{const Y=await e_.updateJob($,{enabled:U});n(z=>z.map(V=>V.id===$?Y:V))}catch(Y){b(Y instanceof Error?Y.message:"Failed to update job")}},P=async $=>{try{const U=await e_.triggerJob($);s(Y=>({...Y,[$]:U}))}catch(U){b(U instanceof Error?U.message:"Failed to trigger job")}},H=async $=>{if(await e({title:"Delete job",description:"Are you sure you want to delete this job?",confirmLabel:"Delete",variant:"destructive"}))try{await e_.deleteJob($);const Y=Math.max(0,o-1),z=Math.max(1,Math.ceil(Y/d)),V=Math.min(l,z);u(V),await A(V,d)}catch(Y){b(Y instanceof Error?Y.message:"Failed to delete job")}},K=$=>{u(1),A(1,d),w(!1)},F=$=>{n(U=>U.map(Y=>Y.id===$.id?$:Y)),C(null)},B=Math.max(1,Math.ceil(o/d)),W=o===0?0:(l-1)*d+1,D=Math.min(o,l*d),O=r.filter($=>$.enabled).length,I=r.filter($=>$.job_type==="agent_task").length,R=r.filter($=>$.job_type==="system_job").length;return c.jsxs("div",{className:"container mx-auto max-w-6xl px-3 py-4 sm:px-4 sm:py-6",children:[c.jsxs("div",{className:"mb-6 flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[c.jsxs("div",{className:"min-w-0",children:[c.jsxs("h1",{className:"flex items-center gap-2 text-xl font-bold sm:text-2xl",children:[c.jsx(Q_,{className:"h-6 w-6"}),"Scheduled Jobs"]}),c.jsx("p",{className:"mt-1 text-sm text-muted-foreground sm:text-base",children:"Manage your automated tasks and agent schedules"})]}),c.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[c.jsxs(_e,{variant:"outline",onClick:()=>void A(l,d),disabled:f,className:"w-full sm:w-auto",children:[c.jsx(io,{className:`h-4 w-4 mr-2 ${f?"animate-spin":""}`}),"Refresh"]}),c.jsxs(_e,{onClick:()=>w(!0),className:"w-full sm:w-auto",children:[c.jsx(qs,{className:"h-4 w-4 mr-2"}),"New Job"]})]})]}),c.jsxs("div",{className:"mb-6 grid grid-cols-2 gap-2 sm:flex sm:flex-wrap sm:items-center sm:gap-4",children:[c.jsxs($r,{variant:"outline",className:"justify-center px-3 py-1 text-xs sm:text-sm",children:[o," total"]}),c.jsxs($r,{variant:"default",className:"justify-center px-3 py-1 text-xs sm:text-sm",children:[O," enabled on page"]}),c.jsxs($r,{variant:"secondary",className:"justify-center px-3 py-1 text-xs sm:text-sm",children:[I," agent tasks on page"]}),c.jsxs($r,{variant:"secondary",className:"justify-center px-3 py-1 text-xs sm:text-sm",children:[R," system jobs on page"]})]}),v&&c.jsxs("div",{className:"flex items-center gap-2 text-destructive text-sm bg-destructive/10 p-3 rounded-md mb-4",children:[c.jsx(ia,{className:"h-4 w-4"}),v,c.jsx(_e,{variant:"ghost",size:"sm",className:"ml-auto",onClick:()=>b(null),children:"Dismiss"})]}),f&&r.length===0?c.jsx("div",{className:"flex items-center justify-center py-24",children:c.jsx(Vt,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):r.length===0?c.jsxs("div",{className:"rounded-lg border-2 border-dashed px-4 py-16 text-center sm:py-24",children:[c.jsx(Q_,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),c.jsx("h3",{className:"text-lg font-medium mb-2",children:"No scheduled jobs yet"}),c.jsx("p",{className:"text-muted-foreground mb-4",children:"Create your first job to automate tasks or schedule agent prompts"}),c.jsxs(_e,{onClick:()=>w(!0),children:[c.jsx(qs,{className:"h-4 w-4 mr-2"}),"Create Your First Job"]})]}):c.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:r.map($=>c.jsx(lrt,{job:$,recentRun:i[$.id],onToggle:N,onTrigger:P,onDelete:H,onEdit:C,onViewHistory:E},$.id))}),c.jsxs("div",{className:"mt-6 flex flex-col gap-3 border-t pt-4 sm:flex-row sm:flex-wrap sm:items-center sm:justify-between",children:[c.jsxs("div",{className:"text-sm text-muted-foreground",children:["Showing ",W,"–",D," of ",o]}),c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground",htmlFor:"jobs-page-size",children:"Per page"}),c.jsx("select",{id:"jobs-page-size",className:"h-9 rounded-md border bg-background px-2 text-sm",value:d,onChange:$=>{const U=Number.parseInt($.target.value,10);!Number.isFinite(U)||U<=0||(u(1),h(U))},children:ant.map($=>c.jsx("option",{value:$,children:$},$))}),c.jsxs("div",{className:"grid grid-cols-[1fr_auto_1fr] items-center gap-2 sm:flex sm:items-center",children:[c.jsxs(_e,{variant:"outline",size:"sm",disabled:l<=1||f,onClick:()=>u($=>Math.max(1,$-1)),className:"w-full",children:[c.jsx(wv,{className:"h-4 w-4 mr-1"}),"Prev"]}),c.jsxs("span",{className:"text-center text-sm text-muted-foreground tabular-nums",children:["Page ",l," / ",B]}),c.jsxs(_e,{variant:"outline",size:"sm",disabled:l>=B||f,onClick:()=>u($=>Math.min(B,$+1)),className:"w-full",children:["Next",c.jsx(Cs,{className:"h-4 w-4 ml-1"})]})]})]})]}),c.jsx(nnt,{isOpen:_||!!S,onClose:()=>{w(!1),C(null)},onCreated:K,editJob:S,onUpdated:F}),c.jsx(snt,{job:j,isOpen:!!j,onClose:()=>E(null)})]})}const C7="jait.todo.selected-repo.v1";function QW(e){const r=e.trim().replace(/\\/g,"/").replace(/\/+$/,"");return/^[A-Za-z]:\//.test(r)?r.toLowerCase():r}function eU(e){if(e&&typeof e=="object"&&!Array.isArray(e)){const r=e;return{repoId:typeof r.repoId=="string"&&r.repoId.trim()?r.repoId.trim():null,localPath:typeof r.localPath=="string"&&r.localPath.trim()?r.localPath.trim():null}}return typeof e=="string"?{repoId:e.trim()||null,localPath:null}:{repoId:null,localPath:null}}function cnt(e){try{return eU(JSON.parse(e))}catch{return eU(e)}}function unt(){var e;if(typeof window>"u")return{repoId:null,localPath:null};try{const r=(e=window.localStorage.getItem(C7))==null?void 0:e.trim();return r?cnt(r):{repoId:null,localPath:null}}catch{return{repoId:null,localPath:null}}}function dnt(e,r){if(!(typeof window>"u"))try{const n=(e==null?void 0:e.trim())||null;if(!n){window.localStorage.removeItem(C7);return}window.localStorage.setItem(C7,JSON.stringify({repoId:n,localPath:(r==null?void 0:r.trim())||null}))}catch{}}function hnt(e,r,n=unt()){var i;if(e.length===0)return r;if(n.repoId&&e.some(s=>s.id===n.repoId))return n.repoId;if(n.localPath){const s=QW(n.localPath),o=e.find(a=>QW(a.localPath)===s);if(o)return o.id}return r&&e.some(s=>s.id===r)?r:((i=e[0])==null?void 0:i.id)??null}function fnt(e){return`[${e}] Generating title…`}function pnt({repo:e,providerId:r,runtimeMode:n,model:i,workingDirectory:s,branch:o}){return{title:fnt(e.name),providerId:r,runtimeMode:n,...i?{model:i}:{},kind:"delivery",workingDirectory:s,branch:o,prBaseBranch:e.defaultBranch}}function mnt(e,r){return{message:r.message,titleTask:r.message,titlePrefix:`[${e}] `}}const uce="jait.todo.order.v1",dce="jait.todo.filters.v1",b3=8,f8=[{value:"open",label:"Open"},{value:"in_progress",label:"In progress"},{value:"done",label:"Done"}],t_=[{value:"low",label:"Low"},{value:"normal",label:"Normal"},{value:"high",label:"High"}];function $0(e){switch(e){case"done":return{label:"Done",iconClassName:"text-emerald-500",itemClassName:"border-emerald-500/20 bg-emerald-500/[0.04]"};case"in_progress":return{label:"In progress",iconClassName:"text-sky-500",itemClassName:"border-sky-500/20 bg-sky-500/[0.035]"};case"open":default:return{label:"Open",iconClassName:"text-muted-foreground",itemClassName:"bg-card/40"}}}function hce(e){switch(e){case"high":return"text-amber-500";case"low":return"text-muted-foreground/70";case"normal":default:return"text-primary/70"}}function B_({status:e,className:r}){const n=$0(e);return e==="done"?c.jsx(uo,{className:Ae("h-5 w-5",n.iconClassName,r)}):e==="in_progress"?c.jsx(pY,{className:Ae("h-5 w-5",n.iconClassName,r)}):c.jsx(mR,{className:Ae("h-5 w-5",n.iconClassName,r)})}function tU({priority:e,className:r}){return c.jsx(gY,{className:Ae("h-4 w-4",hce(e),r)})}function O1({label:e,children:r}){return c.jsxs(vn,{children:[c.jsx(pn,{asChild:!0,children:r}),c.jsx(mn,{children:e})]})}function fce(){if(typeof window>"u")return{};try{const e=JSON.parse(window.localStorage.getItem(uce)??"{}");return!e||typeof e!="object"||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(r=>typeof r[0]=="string"&&Array.isArray(r[1])&&r[1].every(n=>typeof n=="string")))}catch{return{}}}function rU(e,r){if(!(typeof window>"u"||!e))try{const n=fce();n[e]=r.map(i=>i.id),window.localStorage.setItem(uce,JSON.stringify(n))}catch{}}function gnt(e,r){const n=fce()[e];if(!(n!=null&&n.length))return r;const i=new Map(n.map((o,a)=>[o,a])),s=new Map(r.map((o,a)=>[o.id,a]));return[...r].sort((o,a)=>{const l=i.get(o.id),u=i.get(a.id);return l!=null&&u!=null?l-u:l!=null?-1:u!=null?1:(s.get(o.id)??0)-(s.get(a.id)??0)})}function ynt(){return{search:"",tags:[],savedTagFilters:[]}}function pce(e){return Array.isArray(e)?e.flatMap(r=>{if(!r||typeof r!="object")return[];const n=r,i=uc(Array.isArray(n.tags)?n.tags.filter(a=>typeof a=="string"):[]);if(i.length===0)return[];const s=typeof n.name=="string"&&n.name.trim()?n.name.trim():i.join(" + ");return[{id:typeof n.id=="string"&&n.id.trim()?n.id.trim():i.join("|"),name:s,tags:i}]}).slice(0,24):[]}function mce(){if(typeof window>"u")return{};try{const e=JSON.parse(window.localStorage.getItem(dce)??"{}");if(!e||typeof e!="object"||Array.isArray(e))return{};const r=Object.entries(e).flatMap(([n,i])=>{if(!i||typeof i!="object"||Array.isArray(i))return[];const s=i;return[[n,{search:typeof s.search=="string"?s.search:"",tags:uc(Array.isArray(s.tags)?s.tags.filter(o=>typeof o=="string"):[]),savedTagFilters:pce(s.savedTagFilters)}]]});return Object.fromEntries(r)}catch{return{}}}function vnt(e){return mce()[e]??ynt()}function xnt(e,r){if(!(typeof window>"u"||!e))try{const n=mce();n[e]={search:r.search,tags:uc(r.tags),savedTagFilters:pce(r.savedTagFilters)},window.localStorage.setItem(dce,JSON.stringify(n))}catch{}}function nU(e,r,n,i){const s=e.findIndex(u=>u.id===r);if(s<0)return e;const o=[...e],[a]=o.splice(s,1);if(!a)return e;if(n==null)return o.push(a),o;const l=o.findIndex(u=>u.id===n);return l<0?e:(o.splice(l+(i==="after"?1:0),0,a),o)}function iU(){if(!(typeof window>"u"))try{const e=window.AudioContext||window.webkitAudioContext;if(!e)return;const r=new e,n=r.currentTime,i=r.createGain();i.gain.setValueAtTime(1e-4,n),i.gain.exponentialRampToValueAtTime(.08,n+.012),i.gain.exponentialRampToValueAtTime(1e-4,n+.34),i.connect(r.destination);for(const[s,o]of[660,880].entries()){const a=r.createOscillator();a.type="sine",a.frequency.setValueAtTime(o,n+s*.08),a.connect(i),a.start(n+s*.08),a.stop(n+.22+s*.08)}window.setTimeout(()=>void r.close(),450)}catch{}}function bnt({todo:e}){const r=$0(e.status);return c.jsxs("div",{className:Ae("flex items-start gap-2 rounded-lg border bg-background px-3 py-2 text-sm shadow-2xl ring-1 ring-primary/10",r.itemClassName),children:[c.jsx(D4,{className:"mt-1 h-4 w-4 shrink-0 text-muted-foreground"}),c.jsx(B_,{status:e.status,className:"mt-0.5 shrink-0"}),c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsxs("div",{className:"mb-1 flex items-center gap-1.5 text-[11px] font-medium uppercase text-muted-foreground",children:[c.jsx("span",{children:r.label}),c.jsx(gY,{className:Ae("h-3 w-3",hce(e.priority))}),c.jsx("span",{children:e.priority})]}),c.jsx("span",{className:Ae("whitespace-pre-wrap break-words text-foreground",e.status==="done"&&"text-muted-foreground line-through"),children:e.message})]})]})}function g2(e){if(Array.isArray(e))return e;if(!e)return[];try{const r=JSON.parse(e);return Array.isArray(r)?r.filter(n=>typeof n=="string"):[]}catch{return e.split(",").map(r=>r.trim()).filter(Boolean)}}function _nt(e){return[...new Set(e.split(",").map(r=>r.trim().toLowerCase()).filter(Boolean))]}function uc(e){return[...new Set(e.map(r=>r.trim().toLowerCase()).filter(Boolean))]}function _5(e){const r=e.getFullYear(),n=`${e.getMonth()+1}`.padStart(2,"0"),i=`${e.getDate()}`.padStart(2,"0");return`${r}-${n}-${i}`}function gce(e){return new Intl.DateTimeFormat(void 0,{month:"long",year:"numeric"}).format(e)}function yce(e){if(!e)return null;const[r,n,i]=e.split("-").map(Number);return!r||!n||!i?null:new Date(r,n-1,i)}function dv(e){const r=yce(e);return r?new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",year:"numeric"}).format(r):"No due date"}function vce(e){if(!e)return"";const r=new Date(e);return Number.isNaN(r.getTime())?"":new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(r)}function sU(e,r){const n=uc(e).sort(),i=uc(r).sort();return n.length===i.length&&n.every((s,o)=>s===i[o])}function wnt(e){if(!e)return[];try{const r=JSON.parse(e);return Array.isArray(r)?r.flatMap(n=>{if(!n||typeof n!="object")return[];const i=n;if(typeof i.completedAt!="string")return[];const s=i.previousStatus==="open"||i.previousStatus==="in_progress"||i.previousStatus==="done"?i.previousStatus:null;return[{completedAt:i.completedAt,previousStatus:s}]}):[]}catch{return[]}}function Snt(e){const r=$0(e.status),n=g2(e.tags);return[e.message,r.label,e.status,e.priority,e.dueDate,dv(e.dueDate),n.join(" "),e.sourceThreadTitle,e.createdAt,e.updatedAt,e.completedAt,vce(e.completedAt)].filter(Boolean).join(" ").toLowerCase()}function knt(e,r){const n=r.trim().toLowerCase().split(/\s+/).filter(Boolean);if(n.length===0)return!0;const i=Snt(e);return n.every(s=>i.includes(s))}function Cnt(e){return e.flatMap(r=>{const n=g2(r.tags),i=wnt(r.completionHistory);return(i.length>0?i:r.completedAt?[{completedAt:r.completedAt,previousStatus:null}]:[]).map(o=>({...o,todoId:r.id,message:r.message,tags:n}))}).sort((r,n)=>new Date(n.completedAt).getTime()-new Date(r.completedAt).getTime())}function jnt(e){return[...e].sort((r,n)=>{const i=r.status==="done",s=n.status==="done";return i!==s?i?1:-1:0})}function xce(e){const r=new Date(e.getFullYear(),e.getMonth(),1),n=new Date(r);return n.setDate(r.getDate()-r.getDay()),Array.from({length:42},(i,s)=>{const o=new Date(n);return o.setDate(n.getDate()+s),o})}function j7({value:e,onChange:r,placeholder:n="Add date",className:i,iconOnly:s=!1}){const o=yce(e),[a,l]=y.useState(!1),[u,d]=y.useState(()=>o??new Date),h=f=>{r(f),l(!1)};return y.useEffect(()=>{o&&d(o)},[o==null?void 0:o.getTime()]),c.jsxs(E9,{open:a,onOpenChange:l,children:[c.jsx(A9,{asChild:!0,children:c.jsxs(_e,{type:"button",variant:"outline",className:Ae(s?"h-8 w-8 justify-center px-0":"h-10 w-full justify-start gap-2 px-3 text-left font-normal",!e&&"text-muted-foreground",i),title:e?`Due ${dv(e)}`:n,"aria-label":e?`Due ${dv(e)}`:n,children:[c.jsx(fR,{className:"h-4 w-4 shrink-0"}),!s&&c.jsx("span",{className:"truncate",children:e?dv(e):n})]})}),c.jsxs(O9,{align:"start",className:"w-[19rem] p-3",children:[c.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[c.jsx(_e,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>d(new Date(u.getFullYear(),u.getMonth()-1,1)),"aria-label":"Previous month",children:c.jsx(wv,{className:"h-4 w-4"})}),c.jsx("div",{className:"text-sm font-medium",children:gce(u)}),c.jsx(_e,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>d(new Date(u.getFullYear(),u.getMonth()+1,1)),"aria-label":"Next month",children:c.jsx(Cs,{className:"h-4 w-4"})})]}),c.jsx("div",{className:"grid grid-cols-7 gap-1 text-center text-[11px] font-medium text-muted-foreground",children:["S","M","T","W","T","F","S"].map((f,g)=>c.jsx("div",{className:"py-1",children:f},`${f}-${g}`))}),c.jsx("div",{className:"grid grid-cols-7 gap-1",children:xce(u).map(f=>{const g=_5(f),v=e===g,b=g===_5(new Date),_=f.getMonth()!==u.getMonth();return c.jsx(_e,{type:"button",variant:v?"secondary":"ghost",size:"icon",className:Ae("h-8 w-8 rounded-md text-xs font-normal",_&&"text-muted-foreground/55",b&&!v&&"border border-border"),onClick:()=>h(g),children:f.getDate()},g)})}),c.jsxs("div",{className:"mt-3 flex items-center justify-between gap-2 border-t pt-3",children:[c.jsx(_e,{type:"button",variant:"ghost",size:"sm",className:"h-8 px-2 text-xs",onClick:()=>h(_5(new Date)),children:"Today"}),c.jsxs(_e,{type:"button",variant:"ghost",size:"sm",className:"h-8 px-2 text-xs",onClick:()=>h(null),children:[c.jsx(Vn,{className:"mr-1 h-3.5 w-3.5"}),"Clear"]})]})]})]})}function Nnt({value:e,onChange:r,className:n,iconOnly:i=!1}){const[s,o]=y.useState(!!e);return y.useEffect(()=>{e&&o(!0)},[e]),s?c.jsx(j7,{value:e,onChange:a=>{r(a),a||o(!1)},className:n,iconOnly:i}):c.jsxs(_e,{type:"button",variant:"outline",className:Ae(i?"h-8 w-8 justify-center px-0 text-muted-foreground":"h-10 justify-start gap-2 text-muted-foreground",n),onClick:()=>o(!0),title:"Add date","aria-label":"Add date",children:[c.jsx(fR,{className:"h-4 w-4"}),!i&&"Add date"]})}function M1({value:e,onChange:r,options:n,placeholder:i,disabled:s,className:o,triggerLabel:a,triggerIcon:l}){var d;const u=((d=n.find(h=>h.value===e))==null?void 0:d.label)??i??e;return c.jsxs(th,{value:e,onValueChange:h=>r(h),disabled:s,children:[c.jsx(Zu,{className:o,title:a?`${a}: ${u}`:u,"aria-label":a?`${a}: ${u}`:u,children:l||c.jsx(rh,{placeholder:i})}),c.jsx(Qu,{children:n.map(h=>c.jsx(Ls,{value:h.value,children:h.label},h.value))})]})}function _3({value:e,onChange:r,placeholder:n="Add tag...",commitOnBlur:i=!1,className:s,inputClassName:o}){const[a,l]=y.useState(""),u=uc(e),d=()=>{const f=_nt(a);f.length!==0&&(r(uc([...u,...f])),l(""))},h=f=>{r(u.filter(g=>g!==f))};return c.jsxs("div",{className:Ae("flex min-h-10 w-full flex-wrap items-center gap-1.5 rounded-lg border border-input bg-background/90 px-2 py-1.5 shadow-sm focus-within:ring-2 focus-within:ring-ring/60 focus-within:ring-offset-2 focus-within:ring-offset-background",s),children:[u.map(f=>c.jsxs($r,{variant:"secondary",className:"h-6 gap-1 rounded-md px-2 text-xs",children:[c.jsx("span",{children:f}),c.jsx("button",{type:"button",className:"-mr-1 inline-flex h-4 w-4 items-center justify-center rounded-sm text-muted-foreground hover:bg-foreground/10 hover:text-foreground",onClick:()=>h(f),"aria-label":`Remove ${f} tag`,children:c.jsx(Vn,{className:"h-3 w-3"})})]},f)),c.jsx("input",{value:a,onChange:f=>{const g=f.target.value;if(g.includes(",")){const v=g.split(","),b=v.pop()??"",_=uc([...u,...v]);(_.length!==u.length||_.some((w,S)=>w!==u[S]))&&r(_),l(b.trimStart());return}l(g)},onKeyDown:f=>{f.key==="Enter"||f.key===","?(f.preventDefault(),d()):f.key==="Backspace"&&!a&&u.length>0&&(f.preventDefault(),r(u.slice(0,-1)))},onBlur:()=>{i&&d()},className:Ae("h-6 min-w-28 flex-1 bg-transparent px-1 text-sm outline-none placeholder:text-muted-foreground",o),placeholder:u.length===0?n:""})]})}function Tnt({provider:e="jait",model:r=null,runtimeMode:n="full-access"}){var sr;const[i,s]=y.useState([]),[o,a]=y.useState(""),[l,u]=y.useState([]),[d,h]=y.useState("list"),[f,g]=y.useState("all"),[v,b]=y.useState(""),[_,w]=y.useState([]),[S,C]=y.useState([]),[j,E]=y.useState(null),[A,N]=y.useState(()=>new Date),[P,H]=y.useState(""),[K,F]=y.useState("open"),[B,W]=y.useState("normal"),[D,O]=y.useState(null),[I,R]=y.useState([]),[$,U]=y.useState(()=>new Set),[Y,z]=y.useState([]),[V,Q]=y.useState("normal"),[q,re]=y.useState(null),[ee,ne]=y.useState(!0),[ae,te]=y.useState(!1),[ue,he]=y.useState(!1),[we,pe]=y.useState(()=>new Set),[qe,se]=y.useState(null),[it,Ye]=y.useState(!1),[ht,qt]=y.useState(0),Nt=y.useRef(null),Xt=y.useRef(null),[Wt,gt]=y.useState(null),[Re,kt]=y.useState(null),[Pt,Ne]=y.useState(null),ze=y.useCallback(async()=>{const xe=await xr.listRepos();s(xe),a(xt=>hnt(xe,xt)??"")},[]),Qe=y.useCallback(async xe=>{if(!xe){u([]),ne(!1);return}ne(!0),se(null);try{u(gnt(xe,await xr.listJaitTodos(xe)))}catch(xt){se(xt instanceof Error?xt.message:"Failed to load todo list")}finally{ne(!1)}},[]);y.useEffect(()=>{(async()=>{ne(!0),se(null);try{await ze()}catch(xe){se(xe instanceof Error?xe.message:"Failed to load repositories"),ne(!1)}})()},[ze]),y.useEffect(()=>{Qe(o)},[Qe,o]),y.useEffect(()=>{if(!o){b(""),w([]),C([]),E(null),U(new Set);return}const xe=vnt(o);b(xe.search),w(xe.tags),C(xe.savedTagFilters),E(o),U(new Set)},[o]),y.useEffect(()=>{!o||j!==o||xnt(o,{search:v,tags:_,savedTagFilters:S})},[j,v,o,S,_]);const lt=y.useMemo(()=>jnt(l.filter(xe=>{if(f!=="all"&&xe.status!==f)return!1;const xt=g2(xe.tags);return!(_.length>0&&!_.every(Je=>xt.includes(Je))||!knt(xe,v))})),[v,f,_,l]),yt=y.useMemo(()=>({open:l.filter(xe=>xe.status==="open").length,inProgress:l.filter(xe=>xe.status==="in_progress").length,done:l.filter(xe=>xe.status==="done").length}),[l]),Tt=i.find(xe=>xe.id===o),dr=y.useMemo(()=>i.map(xe=>({value:xe.id,label:xe.name})),[i]),De=y.useMemo(()=>l.filter(xe=>$.has(xe.id)),[$,l]),je=y.useMemo(()=>lt.filter(xe=>$.has(xe.id)).length,[lt,$]),be=lt.length>0&&je===lt.length,Be=S.find(xe=>sU(xe.tags,_))??null,at=y.useMemo(()=>Cnt(l),[l]),Ve=Math.max(1,Math.ceil(at.length/b3)),Mt=at.slice(ht*b3,ht*b3+b3);y.useEffect(()=>{qt(xe=>Math.min(xe,Ve-1))},[Ve]),y.useEffect(()=>{U(xe=>{const xt=new Set(l.map(Rt=>Rt.id)),Je=new Set([...xe].filter(Rt=>xt.has(Rt)));return Je.size===xe.size?xe:Je})},[l]);const It=y.useCallback(xe=>{a(xe);const xt=i.find(Je=>Je.id===xe);dnt(xe,(xt==null?void 0:xt.localPath)??null)},[i]);y.useEffect(()=>{if(ee||!Tt||d!=="list")return;const xe=window.requestAnimationFrame(()=>{var xt,Je;(xt=Nt.current)==null||xt.focus(),(Je=Nt.current)==null||Je.select()});return()=>window.cancelAnimationFrame(xe)},[ee,d,Tt==null?void 0:Tt.id]);const rr=y.useCallback(async()=>{const xe=P.trim();if(!(!o||!xe)){te(!0),se(null);try{const xt=await xr.createJaitTodo(o,{message:xe,status:K,priority:B,dueDate:D,tags:I});u(Je=>{const Rt=[xt,...Je];return rU(o,Rt),Rt}),H(""),F("open"),W("normal"),O(null),R([]),window.requestAnimationFrame(()=>{var Je;return(Je=Nt.current)==null?void 0:Je.focus()})}catch(xt){se(xt instanceof Error?xt.message:"Failed to add todo")}finally{te(!1)}}},[D,P,B,K,I,o]),nr=y.useCallback(xe=>{xe.key==="Enter"&&!xe.shiftKey&&(xe.preventDefault(),rr())},[rr]),Ut=async(xe,xt)=>{u(Je=>Je.map(Rt=>Rt.id===xe.id?{...Rt,...xt,tags:xt.tags?JSON.stringify(xt.tags):Rt.tags}:Rt));try{const Je=await xr.updateJaitTodo(xe.id,xt);u(Rt=>Rt.map(Ke=>Ke.id===xe.id?Je:Ke))}catch(Je){se(Je instanceof Error?Je.message:"Failed to update todo"),Qe(o)}},Se=async(xe,xt)=>{xe.status!=="done"&&xt==="done"&&iU(),await Ut(xe,{status:xt})},Fe=async xe=>{const xt=l;u(Je=>Je.filter(Rt=>Rt.id!==xe)),U(Je=>{const Rt=new Set(Je);return Rt.delete(xe),Rt});try{await xr.deleteJaitTodo(xe)}catch(Je){u(xt),se(Je instanceof Error?Je.message:"Failed to remove todo")}},et=y.useCallback((xe,xt)=>{U(Je=>{const Rt=new Set(Je);return xt?Rt.add(xe):Rt.delete(xe),Rt})},[]),St=y.useCallback(xe=>{U(xt=>{const Je=new Set(xt);for(const Rt of lt)xe?Je.add(Rt.id):Je.delete(Rt.id);return Je})},[lt]),Xe=y.useCallback(()=>{const xe=uc(_);if(xe.length===0)return;const xt=xe.join("|");C(Je=>Je.some(Rt=>Rt.id===xt||sU(Rt.tags,xe))?Je:[...Je,{id:xt,name:xe.join(" + "),tags:xe}])},[_]),Lt=y.useCallback(()=>{Be&&C(xe=>xe.filter(xt=>xt.id!==Be.id))},[Be]),Et=async(xe,xt)=>{if(De.length!==0){he(!0),se(null);try{const Je=await Promise.all(De.map(Ke=>xr.updateJaitTodo(Ke.id,xe(Ke)))),Rt=new Map(Je.map(Ke=>[Ke.id,Ke]));u(Ke=>Ke.map(me=>Rt.get(me.id)??me))}catch(Je){se(Je instanceof Error?Je.message:xt),Qe(o)}finally{he(!1)}}},Ft=async xe=>{xe==="done"&&De.some(xt=>xt.status!=="done")&&iU(),await Et(()=>({status:xe}),"Failed to update selected todo statuses")},ye=async xe=>{await Et(()=>({priority:xe}),"Failed to update selected todo priorities")},st=async xe=>{await Et(()=>({dueDate:xe}),"Failed to update selected todo due dates")},ir=async()=>{const xe=uc(Y);xe.length!==0&&(await Et(xt=>({tags:uc([...g2(xt.tags),...xe])}),"Failed to update selected todo tags"),z([]))},At=async()=>{if(De.length===0)return;const xe=l,xt=new Set(De.map(Je=>Je.id));u(Je=>Je.filter(Rt=>!xt.has(Rt.id))),U(new Set),he(!0),se(null);try{await Promise.all([...xt].map(Je=>xr.deleteJaitTodo(Je)))}catch(Je){u(xe),se(Je instanceof Error?Je.message:"Failed to remove selected todos")}finally{he(!1)}},hr=async xe=>{if(!(!Tt||we.has(xe.id))){pe(xt=>new Set(xt).add(xe.id)),se(null);try{const xt=`jait/${Math.random().toString(16).slice(2,10)}`,Je=Tt.defaultBranch;let Rt;try{Rt=(await $s.createWorktree(Tt.localPath,Je,xt)).path}catch{try{await $s.createBranch(Tt.localPath,xt,Je)}catch{}}const Ke=await xr.createThread(pnt({repo:Tt,providerId:e,runtimeMode:n,model:r,workingDirectory:Rt??Tt.localPath,branch:xt}));await xr.startThread(Ke.id,mnt(Tt.name,xe)),xe.status!=="done"&&await Ut(xe,{status:"in_progress"})}catch(xt){se(xt instanceof Error?xt.message:"Failed to run todo as thread")}finally{pe(xt=>{const Je=new Set(xt);return Je.delete(xe.id),Je})}}},Vr=y.useMemo(()=>{const xe=new Map;for(const xt of lt)xt.dueDate&&xe.set(xt.dueDate,[...xe.get(xt.dueDate)??[],xt]);return xe},[lt]);y.useEffect(()=>{if(Wt&&!lt.some(xe=>xe.id===Wt)){gt(null),kt(null),Ne(null);return}Re!=null&&Re.targetId&&!lt.some(xe=>xe.id===Re.targetId)&&kt(Wt?{targetId:Wt,placement:"before"}:null)},[Wt,Re,lt]),y.useEffect(()=>{var me;if(!Wt||!Pt)return;document.body.style.cursor="grabbing",document.body.style.userSelect="none",document.body.style.touchAction="none";const xe=dt=>{var qr;const fr=Array.from(document.querySelectorAll("[data-todo-id]")).filter(Hn=>Hn.dataset.todoId&&Hn.dataset.todoId!==Wt);if(fr.length===0){kt({targetId:null,placement:"after"});return}for(const Hn of fr){const Mi=Hn.dataset.todoId;if(!Mi)continue;const Ri=Hn.getBoundingClientRect();if(dt<Ri.top+Ri.height/2){kt({targetId:Mi,placement:"before"});return}}const vr=((qr=fr[fr.length-1])==null?void 0:qr.dataset.todoId)??null;kt(vr?{targetId:vr,placement:"after"}:{targetId:null,placement:"after"})},xt=dt=>{var fr,vr;if(dt&&dt.pointerId!==Pt.pointerId)return;Re&&Re.targetId!==Wt&&u(qr=>{const Hn=nU(qr,Wt,Re.targetId,Re.placement);return Hn===qr?qr:(rU(o,Hn),Hn)});const wt=Xt.current;(fr=wt==null?void 0:wt.hasPointerCapture)!=null&&fr.call(wt,Pt.pointerId)&&((vr=wt.releasePointerCapture)==null||vr.call(wt,Pt.pointerId)),Xt.current=null,gt(null),kt(null),Ne(null)},Je=dt=>{dt.pointerId===Pt.pointerId&&(Ne(wt=>wt&&{...wt,x:dt.clientX,y:dt.clientY}),xe(dt.clientY))},Rt=()=>xt(),Ke=()=>xt();return window.addEventListener("pointermove",Je),window.addEventListener("pointerup",xt),window.addEventListener("pointercancel",xt),window.addEventListener("blur",Ke),(me=Xt.current)==null||me.addEventListener("lostpointercapture",Rt),()=>{var dt;document.body.style.cursor="",document.body.style.userSelect="",document.body.style.touchAction="",window.removeEventListener("pointermove",Je),window.removeEventListener("pointerup",xt),window.removeEventListener("pointercancel",xt),window.removeEventListener("blur",Ke),(dt=Xt.current)==null||dt.removeEventListener("lostpointercapture",Rt)}},[Pt,Wt,Re,o]);const br=y.useCallback((xe,xt)=>{var Ke;if(xt.button!==0&&xt.pointerType!=="touch"&&xt.pointerType!=="pen")return;xt.preventDefault();const Je=xt.currentTarget.closest("[data-todo-id]");if(!Je)return;Xt.current=Je,(Ke=Je.setPointerCapture)==null||Ke.call(Je,xt.pointerId);const Rt=Je.getBoundingClientRect();gt(xe),kt({targetId:xe,placement:"before"}),Ne({id:xe,pointerId:xt.pointerId,x:xt.clientX,y:xt.clientY,offsetX:xt.clientX-Rt.left,offsetY:xt.clientY-Rt.top,width:Rt.width,height:Rt.height})},[]),Rr=Wt&&Re&&(Re.targetId!==Wt||Re.placement==="after")?nU(lt,Wt,Re.targetId,Re.placement):lt,mt=Pt?Rr.find(xe=>xe.id===Pt.id):null;return c.jsxs("div",{className:"mx-auto flex max-w-7xl flex-col gap-4 px-3 py-4 sm:px-4 sm:py-6",children:[c.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[c.jsxs("div",{className:"min-w-0",children:[c.jsxs("h1",{className:"flex items-center gap-2 text-xl font-bold sm:text-2xl",children:[c.jsx(Vm,{className:"h-6 w-6"}),"Todo"]}),c.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Global repo follow-up work, saved from agents or added directly here."})]}),c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsxs(th,{value:o||void 0,onValueChange:It,disabled:i.length===0,children:[c.jsx(Zu,{className:"h-10 min-w-56",children:c.jsx(rh,{placeholder:"Select repository"})}),c.jsx(Qu,{children:dr.map(xe=>c.jsx(Ls,{value:xe.value,children:xe.label},xe.value))})]}),c.jsxs(_e,{variant:"outline",onClick:()=>void Qe(o),disabled:ee||!o,children:[c.jsx(io,{className:Ae("mr-2 h-4 w-4",ee&&"animate-spin")}),"Refresh"]}),c.jsxs(_e,{variant:"outline",onClick:()=>Ye(!0),disabled:at.length===0,children:[c.jsx(B5,{className:"mr-2 h-4 w-4"}),"History",at.length>0&&c.jsx($r,{variant:"secondary",className:"ml-1 px-1.5",children:at.length})]})]})]}),c.jsxs("div",{className:"grid grid-cols-2 gap-2 sm:flex sm:flex-wrap",children:[c.jsxs($r,{variant:"outline",className:"justify-center gap-1.5 px-3 py-1",children:[c.jsx(Vm,{className:"h-3.5 w-3.5 text-primary/70"}),l.length," total"]}),c.jsxs($r,{variant:"secondary",className:"justify-center gap-1.5 px-3 py-1",children:[c.jsx(mR,{className:"h-3.5 w-3.5 text-muted-foreground"}),yt.open," open"]}),c.jsxs($r,{variant:"secondary",className:"justify-center gap-1.5 px-3 py-1",children:[c.jsx(pY,{className:"h-3.5 w-3.5 text-sky-500"}),yt.inProgress," active"]}),c.jsxs($r,{variant:"secondary",className:"justify-center gap-1.5 px-3 py-1",children:[c.jsx(uo,{className:"h-3.5 w-3.5 text-emerald-500"}),yt.done," done"]})]}),qe&&c.jsxs("div",{className:"flex items-center gap-2 rounded-md bg-destructive/10 p-3 text-sm text-destructive",children:[c.jsx(ia,{className:"h-4 w-4"}),qe,c.jsx(_e,{variant:"ghost",size:"sm",className:"ml-auto",onClick:()=>se(null),children:"Dismiss"})]}),c.jsx("div",{className:"rounded-lg border p-3",children:c.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-start",children:[c.jsxs("div",{className:"min-w-0 flex-1 rounded-lg border border-input bg-background/90 shadow-sm focus-within:ring-2 focus-within:ring-ring/60 focus-within:ring-offset-2 focus-within:ring-offset-background",children:[c.jsx(jp,{ref:Nt,value:P,onChange:xe=>H(xe.target.value),onKeyDown:nr,placeholder:"Add a future agent prompt or repo task...",className:"min-h-20 resize-y border-0 bg-transparent shadow-none focus-visible:ring-0 focus-visible:ring-offset-0"}),c.jsx(_3,{value:I,onChange:R,placeholder:"Add tags...",className:"min-h-9 rounded-none rounded-b-lg border-x-0 border-b-0 border-t bg-transparent px-2 py-1 shadow-none focus-within:ring-0 focus-within:ring-offset-0",inputClassName:"text-xs"})]}),c.jsxs("div",{className:"flex flex-wrap items-center gap-1 text-xs text-muted-foreground lg:max-w-44 lg:justify-end",children:[c.jsx(O1,{label:`Status: ${$0(K).label}`,children:c.jsx(M1,{value:K,onChange:F,options:f8,triggerLabel:"Status",triggerIcon:c.jsx(B_,{status:K,className:"h-4 w-4"}),className:"h-8 w-8 justify-center rounded-md border-transparent bg-transparent px-0 text-muted-foreground shadow-none hover:bg-accent hover:text-foreground focus:ring-1 focus:ring-ring/50 focus:ring-offset-0 [&>svg:last-child]:hidden"})}),c.jsx(O1,{label:`Priority: ${((sr=t_.find(xe=>xe.value===B))==null?void 0:sr.label)??B}`,children:c.jsx(M1,{value:B,onChange:W,options:t_,triggerLabel:"Priority",triggerIcon:c.jsx(tU,{priority:B}),className:"h-8 w-8 justify-center rounded-md border-transparent bg-transparent px-0 text-muted-foreground shadow-none hover:bg-accent hover:text-foreground focus:ring-1 focus:ring-ring/50 focus:ring-offset-0 [&>svg:last-child]:hidden"})}),c.jsx(O1,{label:D?`Due ${dv(D)}`:"Add date",children:c.jsx(Nnt,{value:D,onChange:O,iconOnly:!0,className:"rounded-md border-transparent bg-transparent text-muted-foreground shadow-none hover:bg-accent hover:text-foreground focus:ring-1 focus:ring-ring/50 focus:ring-offset-0"})}),c.jsxs(_e,{onClick:()=>void rr(),disabled:ae||!o||!P.trim(),size:"sm",children:[ae?c.jsx(Vt,{className:"mr-2 h-4 w-4 animate-spin"}):c.jsx(qs,{className:"mr-2 h-4 w-4"}),"Add"]})]})]})}),c.jsxs("div",{className:"grid gap-3 rounded-lg border p-3",children:[c.jsxs("div",{className:"grid gap-2 lg:grid-cols-[minmax(14rem,1fr)_11rem_minmax(14rem,1fr)_13rem_auto]",children:[c.jsxs("div",{className:"relative",children:[c.jsx(tl,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),c.jsx(Pn,{value:v,onChange:xe=>b(xe.target.value),placeholder:"Search todo metadata...",className:"h-10 pl-9"})]}),c.jsx(M1,{value:f,onChange:g,options:[{value:"all",label:"All statuses"},...f8],className:"h-10"}),c.jsx(_3,{value:_,onChange:xe=>w(uc(xe)),placeholder:"Filter tags...",className:"min-h-10"}),c.jsxs(th,{value:(Be==null?void 0:Be.id)??"custom",onValueChange:xe=>{if(xe==="custom"){w([]);return}const xt=S.find(Je=>Je.id===xe);xt&&w(xt.tags)},children:[c.jsx(Zu,{className:"h-10",children:c.jsx(rh,{placeholder:"Saved filters"})}),c.jsxs(Qu,{children:[c.jsx(Ls,{value:"custom",children:"Unsaved filter"}),S.map(xe=>c.jsx(Ls,{value:xe.id,children:xe.name},xe.id))]})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(_e,{variant:"outline",size:"icon",className:"h-10 w-10",onClick:Xe,disabled:_.length===0||!!Be,"aria-label":"Save tag filter",children:c.jsx(N2,{className:"h-4 w-4"})}),c.jsx(_e,{variant:"outline",size:"icon",className:"h-10 w-10",onClick:Lt,disabled:!Be,"aria-label":"Delete saved tag filter",children:c.jsx(Tl,{className:"h-4 w-4"})})]})]}),c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:flex-wrap sm:items-center sm:justify-between",children:[c.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm text-muted-foreground",children:[c.jsxs($r,{variant:"outline",className:"gap-1.5",children:[c.jsx(D0e,{className:"h-3.5 w-3.5"}),S.length," saved"]}),c.jsxs("span",{children:[lt.length," shown"]}),(v||_.length>0||f!=="all")&&c.jsxs(_e,{variant:"ghost",size:"sm",className:"h-8 px-2",onClick:()=>{b(""),w([]),g("all")},children:[c.jsx(Vn,{className:"mr-1 h-3.5 w-3.5"}),"Clear"]})]}),c.jsxs("div",{className:"grid grid-cols-2 gap-2 sm:flex",children:[c.jsxs(_e,{variant:d==="list"?"secondary":"outline",onClick:()=>h("list"),children:[c.jsx(Vm,{className:"mr-2 h-4 w-4"}),"List"]}),c.jsxs(_e,{variant:d==="calendar"?"secondary":"outline",onClick:()=>h("calendar"),children:[c.jsx(fR,{className:"mr-2 h-4 w-4"}),"Calendar"]})]})]})]}),De.length>0&&c.jsxs("div",{className:"grid gap-3 rounded-lg border p-3",children:[c.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[c.jsxs($r,{variant:"secondary",children:[De.length," selected"]}),c.jsx(_e,{variant:"outline",size:"sm",onClick:()=>void Ft("open"),disabled:ue,children:"Open"}),c.jsx(_e,{variant:"outline",size:"sm",onClick:()=>void Ft("in_progress"),disabled:ue,children:"In progress"}),c.jsx(_e,{variant:"outline",size:"sm",onClick:()=>void Ft("done"),disabled:ue,children:"Done"}),c.jsx(M1,{value:V,onChange:xe=>{Q(xe),ye(xe)},options:t_,className:"h-9 w-32"}),c.jsx(j7,{value:q,onChange:xe=>{re(xe),st(xe)},placeholder:"Due date",className:"h-9 w-36"}),c.jsx(_e,{variant:"outline",size:"sm",onClick:()=>void st(null),disabled:ue,children:"Clear date"})]}),c.jsxs("div",{className:"grid gap-2 md:grid-cols-[minmax(14rem,1fr)_auto_auto]",children:[c.jsx(_3,{value:Y,onChange:z,placeholder:"Add tags to selected...",className:"min-h-9"}),c.jsxs(_e,{variant:"outline",size:"sm",onClick:()=>void ir(),disabled:ue||Y.length===0,children:[c.jsx(qs,{className:"mr-2 h-4 w-4"}),"Add tags"]}),c.jsxs(_e,{variant:"outline",size:"sm",onClick:()=>void At(),disabled:ue,children:[ue?c.jsx(Vt,{className:"mr-2 h-4 w-4 animate-spin"}):c.jsx(Tl,{className:"mr-2 h-4 w-4"}),"Remove"]})]})]}),c.jsx(El,{open:it,onOpenChange:Ye,children:c.jsxs(sl,{className:"max-h-[85vh] max-w-2xl overflow-hidden p-0",children:[c.jsxs(pc,{className:"border-b px-4 py-3",children:[c.jsxs(ol,{className:"flex items-center gap-2 text-base",children:[c.jsx(B5,{className:"h-4 w-4 text-muted-foreground"}),"Completion history"]}),c.jsxs(rd,{children:[at.length," completed event",at.length===1?"":"s"]})]}),c.jsx("div",{className:"grid max-h-[56vh] gap-2 overflow-y-auto px-4 py-3",children:Mt.map(xe=>c.jsxs("div",{className:"min-w-0 rounded-md border bg-card/40 px-3 py-2",children:[c.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[c.jsx(uo,{className:"h-3.5 w-3.5 text-emerald-500"}),c.jsx("span",{children:vce(xe.completedAt)}),xe.previousStatus&&c.jsxs("span",{children:["from ",$0(xe.previousStatus).label]})]}),c.jsx("div",{className:"mt-1 text-sm",children:xe.message}),xe.tags.length>0&&c.jsx("div",{className:"mt-1 flex flex-wrap gap-1",children:xe.tags.slice(0,6).map(xt=>c.jsx($r,{variant:"secondary",className:"h-5 rounded px-1.5 text-[11px]",children:xt},xt))})]},`${xe.todoId}-${xe.completedAt}`))}),c.jsxs(bg,{className:"flex-row items-center justify-between border-t px-4 py-3 sm:justify-between sm:space-x-0",children:[c.jsxs("div",{className:"text-xs text-muted-foreground",children:["Page ",ht+1," of ",Ve]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(_e,{variant:"outline",size:"sm",onClick:()=>qt(xe=>Math.max(0,xe-1)),disabled:ht===0,children:[c.jsx(wv,{className:"mr-1 h-4 w-4"}),"Prev"]}),c.jsxs(_e,{variant:"outline",size:"sm",onClick:()=>qt(xe=>Math.min(Ve-1,xe+1)),disabled:ht>=Ve-1,children:["Next",c.jsx(Cs,{className:"ml-1 h-4 w-4"})]})]})]})]})}),ee&&l.length===0?c.jsx("div",{className:"flex items-center justify-center py-24",children:c.jsx(Vt,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):Tt?d==="calendar"?c.jsxs("div",{className:"rounded-lg border",children:[c.jsxs("div",{className:"flex items-center justify-between border-b px-3 py-2",children:[c.jsxs(_e,{variant:"outline",size:"sm",onClick:()=>N(new Date(A.getFullYear(),A.getMonth()-1,1)),children:[c.jsx(wv,{className:"mr-1 h-4 w-4"}),"Prev"]}),c.jsx("div",{className:"font-medium",children:gce(A)}),c.jsxs(_e,{variant:"outline",size:"sm",onClick:()=>N(new Date(A.getFullYear(),A.getMonth()+1,1)),children:["Next",c.jsx(Cs,{className:"ml-1 h-4 w-4"})]})]}),c.jsx("div",{className:"grid grid-cols-7 border-b text-center text-xs text-muted-foreground",children:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].map(xe=>c.jsx("div",{className:"py-2",children:xe},xe))}),c.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-7",children:xce(A).map(xe=>{const xt=_5(xe),Je=Vr.get(xt)??[],Rt=xe.getMonth()!==A.getMonth();return c.jsxs("div",{className:"min-h-32 border-b p-2 sm:border-r [&:nth-child(7n)]:border-r-0",children:[c.jsx("div",{className:Ae("mb-2 text-xs font-medium",Rt&&"text-muted-foreground"),children:xe.getDate()}),c.jsx("div",{className:"space-y-1",children:Je.map(Ke=>{const me=$0(Ke.status);return c.jsxs("button",{className:Ae("flex w-full items-start gap-1.5 rounded-md border px-2 py-1 text-left text-xs hover:bg-accent",me.itemClassName),onClick:()=>void Se(Ke,Ke.status==="done"?"open":"done"),children:[c.jsx(B_,{status:Ke.status,className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),c.jsx("span",{className:Ke.status==="done"?"line-through text-muted-foreground":"",children:Ke.message})]},Ke.id)})})]},xt)})})]}):lt.length===0?c.jsxs("div",{className:"rounded-lg border-2 border-dashed px-4 py-16 text-center",children:[c.jsx(xve,{className:"mx-auto mb-4 h-10 w-10 text-muted-foreground"}),c.jsx("h3",{className:"mb-2 text-lg font-medium",children:"No todo items match"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Change filters or add the first repo-wide item."})]}):c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 rounded-lg border bg-card/40 px-3 py-2 text-sm text-muted-foreground",children:[c.jsxs("label",{className:"inline-flex items-center gap-2",children:[c.jsx("input",{type:"checkbox",className:"h-4 w-4 rounded border-input",checked:be,onChange:xe=>St(xe.target.checked)}),c.jsx("span",{children:je>0?`${je} selected in view`:"Select visible"})]}),c.jsxs("span",{children:[Rr.length," item",Rr.length===1?"":"s"]})]}),Rr.map(xe=>{var dt;const xt=g2(xe.tags),Je=$0(xe.status),Rt=we.has(xe.id),Ke=!!(Wt&&(Re==null?void 0:Re.targetId)===xe.id&&Re.placement==="before"&&Wt!==xe.id),me=!!(Wt&&(Re==null?void 0:Re.targetId)===xe.id&&Re.placement==="after"&&Wt!==xe.id);return c.jsxs("div",{className:"space-y-3",children:[Ke&&c.jsx("div",{className:"relative h-0",children:c.jsx("div",{className:"absolute inset-x-2 -top-px h-0.5 rounded-full bg-primary shadow-[0_0_0_1px_hsl(var(--background))]"})}),c.jsxs("div",{"data-todo-id":xe.id,className:Ae("group rounded-lg border p-2 transition-all duration-150 ease-out sm:p-3",Je.itemClassName,Wt&&"touch-none",Wt===xe.id&&"border-dashed border-primary/35 bg-primary/5 opacity-0"),children:[c.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_auto] items-start gap-2",children:[c.jsxs("div",{className:"flex flex-col items-center gap-1",children:[c.jsx("input",{"data-no-drag":"true",type:"checkbox",className:"h-4 w-4 rounded border-input",checked:$.has(xe.id),onChange:wt=>et(xe.id,wt.target.checked),"aria-label":"Select todo"}),c.jsx("div",{className:"shrink-0 cursor-grab touch-none rounded p-0.5 text-muted-foreground transition-colors hover:bg-foreground/10 hover:text-foreground active:cursor-grabbing",title:"Drag to reorder","aria-label":"Drag to reorder",onPointerDown:wt=>br(xe.id,wt),children:c.jsx(D4,{className:"h-4 w-4"})}),c.jsx("button",{className:"h-6 w-6 shrink-0 rounded text-muted-foreground hover:text-foreground",onClick:()=>void Se(xe,xe.status==="done"?"open":"done"),"aria-label":"Toggle todo status",children:c.jsx(B_,{status:xe.status})})]}),c.jsxs("div",{className:"min-w-0 flex-1 rounded-lg border border-input bg-background/90 shadow-sm focus-within:ring-2 focus-within:ring-ring/60 focus-within:ring-offset-2 focus-within:ring-offset-background",children:[c.jsx(jp,{className:Ae("min-h-20 resize-y border-0 bg-transparent shadow-none focus-visible:ring-0 focus-visible:ring-offset-0",xe.status==="done"&&"text-muted-foreground line-through"),defaultValue:xe.message,onBlur:wt=>{const fr=wt.target.value.trim();fr&&fr!==xe.message&&Ut(xe,{message:fr})}}),c.jsx(_3,{value:xt,onChange:wt=>{const fr=uc(wt);JSON.stringify(fr)!==JSON.stringify(uc(xt))&&Ut(xe,{tags:fr})},placeholder:"Add tags...",commitOnBlur:!0,className:"min-h-9 rounded-none rounded-b-lg border-x-0 border-b-0 border-t bg-transparent px-2 py-1 shadow-none focus-within:ring-0 focus-within:ring-offset-0",inputClassName:"text-xs"})]}),c.jsxs("div",{className:"grid w-[4.25rem] grid-cols-2 gap-0.5 text-xs text-muted-foreground",children:[c.jsx(O1,{label:`Status: ${Je.label}`,children:c.jsx(M1,{value:xe.status,onChange:wt=>void Se(xe,wt),options:f8,triggerLabel:"Status",triggerIcon:c.jsx(B_,{status:xe.status,className:"h-4 w-4"}),className:"h-8 w-8 justify-center rounded-md border-transparent bg-transparent px-0 text-muted-foreground shadow-none hover:bg-accent hover:text-foreground focus:ring-1 focus:ring-ring/50 focus:ring-offset-0 [&>svg:last-child]:hidden"})}),c.jsx(O1,{label:`Priority: ${((dt=t_.find(wt=>wt.value===xe.priority))==null?void 0:dt.label)??xe.priority}`,children:c.jsx(M1,{value:xe.priority,onChange:wt=>void Ut(xe,{priority:wt}),options:t_,triggerLabel:"Priority",triggerIcon:c.jsx(tU,{priority:xe.priority}),className:"h-8 w-8 justify-center rounded-md border-transparent bg-transparent px-0 text-muted-foreground shadow-none hover:bg-accent hover:text-foreground focus:ring-1 focus:ring-ring/50 focus:ring-offset-0 [&>svg:last-child]:hidden"})}),c.jsx(O1,{label:xe.dueDate?`Due ${dv(xe.dueDate)}`:"Date",children:c.jsx(j7,{value:xe.dueDate??null,onChange:wt=>void Ut(xe,{dueDate:wt}),placeholder:"Date",iconOnly:!0,className:"rounded-md border-transparent bg-transparent text-muted-foreground shadow-none hover:bg-accent hover:text-foreground focus:ring-1 focus:ring-ring/50 focus:ring-offset-0"})}),c.jsx(_e,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",onClick:()=>void hr(xe),disabled:Rt||!Tt,title:"Run todo as thread","aria-label":"Run todo as thread",children:Rt?c.jsx(Vt,{className:"h-4 w-4 animate-spin"}):c.jsx(DS,{className:"h-4 w-4"})}),c.jsx(_e,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",onClick:()=>void Fe(xe.id),"aria-label":"Remove todo",children:c.jsx(Tl,{className:"h-4 w-4"})})]})]}),c.jsx("div",{className:"mt-2 flex justify-end",children:xe.sourceThreadTitle&&c.jsxs("span",{className:"text-xs text-muted-foreground",children:["Suggested by `",xe.sourceThreadTitle,"`"]})})]}),me&&c.jsx("div",{className:"relative h-0",children:c.jsx("div",{className:"absolute inset-x-2 -top-px h-0.5 rounded-full bg-primary shadow-[0_0_0_1px_hsl(var(--background))]"})})]},xe.id)}),Pt&&mt&&c.jsx("div",{className:"pointer-events-none fixed z-50",style:{left:`${Pt.x-Pt.offsetX}px`,top:`${Pt.y-Pt.offsetY}px`,width:`${Pt.width}px`,minHeight:`${Pt.height}px`},children:c.jsx("div",{className:"scale-[1.01] opacity-95",children:c.jsx(bnt,{todo:mt})})})]}):c.jsx("div",{className:"rounded-lg border-2 border-dashed px-4 py-16 text-center text-sm text-muted-foreground",children:"Add a repository in manager mode before creating todo items."})]})}var Ent="Separator",oU="horizontal",Ant=["horizontal","vertical"],bce=y.forwardRef((e,r)=>{const{decorative:n,orientation:i=oU,...s}=e,o=Ont(i)?i:oU,l=n?{role:"none"}:{"aria-orientation":o==="vertical"?o:void 0,role:"separator"};return c.jsx(IS.div,{"data-orientation":o,...l,...s,ref:r})});bce.displayName=Ent;function Ont(e){return Ant.includes(e)}var _ce=bce;const w5=y.forwardRef(({className:e,orientation:r="horizontal",decorative:n=!0,...i},s)=>c.jsx(_ce,{ref:s,decorative:n,orientation:r,className:Ae("shrink-0 bg-border",r==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...i}));w5.displayName=_ce.displayName;function Mnt(e){if(Array.isArray(e))return e;if(!e)return[];try{const r=JSON.parse(e);return Array.isArray(r)?r.filter(n=>typeof n=="string"):[]}catch{return e.split(",").map(r=>r.trim()).filter(Boolean)}}function Rnt(e){return[...new Set(e.split(",").map(r=>r.trim().toLowerCase()).filter(Boolean))]}function r_(e){if(!e)return"No activity";const r=new Date(e);return Number.isNaN(r.getTime())?e:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(r)}function Pnt(){const[e,r]=y.useState(null),[n,i]=y.useState("active"),[s,o]=y.useState("all"),[a,l]=y.useState(""),[u,d]=y.useState(""),[h,f]=y.useState("none"),[g,v]=y.useState([]),[b,_]=y.useState(""),[w,S]=y.useState(""),[C,j]=y.useState(""),[E,A]=y.useState(!0),[N,P]=y.useState(!1),[H,K]=y.useState(!1),[F,B]=y.useState(null),W=y.useCallback(async()=>{A(!0),B(null);try{r(await xr.getRemindersSnapshot({status:n,limit:200})),v(await xr.listUserSecrets())}catch(ee){B(ee instanceof Error?ee.message:"Failed to load memory")}finally{A(!1)}},[n]);y.useEffect(()=>{W()},[W]);const D=(e==null?void 0:e.projects)??[],O=y.useMemo(()=>{const ee=(e==null?void 0:e.reminders)??[];return s==="all"?ee:ee.filter(ne=>ne.projectId===s)},[e==null?void 0:e.reminders,s]),I=(e==null?void 0:e.threads)??[],R=y.useMemo(()=>new Map(D.map(ee=>[ee.id,ee])),[D]),$=y.useMemo(()=>{const ee=new Map;for(const ne of D)for(const ae of ne.sessions)ee.set(ae.id,{name:ae.name,projectId:ae.projectId});return ee},[D]),U=y.useMemo(()=>({reminders:(e==null?void 0:e.reminders.length)??0,projects:D.length,sessions:D.reduce((ee,ne)=>ee+ne.sessions.length,0),threads:I.length}),[e==null?void 0:e.reminders.length,I.length,D]),Y=async()=>{const ee=a.trim();if(ee){P(!0),B(null);try{const ne=await xr.createReminder({content:ee,projectId:h==="none"?null:h,tags:Rnt(u),sourceType:"user",sourceSurface:"web"});r(ae=>ae&&{...ae,reminders:[ne,...ae.reminders]}),l(""),d("")}catch(ne){B(ne instanceof Error?ne.message:"Failed to add memory")}finally{P(!1)}}},z=async(ee,ne)=>{r(ae=>ae&&{...ae,reminders:ae.reminders.map(te=>te.id===ee.id?{...te,...ne,tags:ne.tags?JSON.stringify(ne.tags):te.tags}:te)});try{const ae=await xr.updateReminder(ee.id,ne);r(te=>te&&{...te,reminders:te.reminders.map(ue=>ue.id===ee.id?ae:ue)})}catch(ae){B(ae instanceof Error?ae.message:"Failed to update memory"),W()}},V=async ee=>{const ne=e;r(ae=>ae&&{...ae,reminders:ae.reminders.filter(te=>te.id!==ee)});try{await xr.deleteReminder(ee)}catch(ae){r(ne),B(ae instanceof Error?ae.message:"Failed to delete memory")}},Q=async()=>{const ee=b.trim(),ne=w.trim();if(!(!ee||!ne||!C)){P(!0),B(null);try{const ae=await xr.createUserSecret({type:"ssh-password",key:ne,label:ee,value:C});v(te=>[ae,...te.filter(ue=>ue.id!==ae.id)]),_(""),S(""),j("")}catch(ae){B(ae instanceof Error?ae.message:"Failed to save secret")}finally{P(!1)}}},q=async ee=>{const ne=g;v(ae=>ae.filter(te=>te.id!==ee));try{await xr.deleteUserSecret(ee)}catch(ae){v(ne),B(ae instanceof Error?ae.message:"Failed to delete secret")}},re=async()=>{B(null);try{const ee=await xr.exportMemoryMarkdown({status:n,projectId:s,limit:500});await navigator.clipboard.writeText(ee),K(!0),window.setTimeout(()=>K(!1),1400)}catch(ee){B(ee instanceof Error?ee.message:"Failed to copy memory export")}};return c.jsxs("div",{className:"mx-auto flex max-w-7xl flex-col gap-4 px-3 py-4 sm:px-4 sm:py-6",children:[c.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[c.jsxs("div",{className:"min-w-0",children:[c.jsxs("h1",{className:"flex items-center gap-2 text-xl font-bold sm:text-2xl",children:[c.jsx(Ja,{className:"h-6 w-6"}),"Memory"]}),c.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Agent-readable memory with project chat history and completed thread context."})]}),c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsxs(th,{value:n,onValueChange:ee=>i(ee),children:[c.jsx(Zu,{className:"h-10 w-full sm:w-40",children:c.jsx(rh,{})}),c.jsxs(Qu,{children:[c.jsx(Ls,{value:"active",children:"Active"}),c.jsx(Ls,{value:"archived",children:"Archived"}),c.jsx(Ls,{value:"all",children:"All"})]})]}),c.jsxs(_e,{variant:"outline",onClick:()=>void W(),disabled:E,children:[c.jsx(io,{className:Ae("mr-2 h-4 w-4",E&&"animate-spin")}),"Refresh"]}),c.jsxs(_e,{variant:"outline",onClick:()=>void re(),children:[c.jsx(ac,{className:"mr-2 h-4 w-4"}),H?"Copied":"Copy Markdown"]})]})]}),c.jsxs("div",{className:"grid grid-cols-2 gap-2 sm:flex sm:flex-wrap",children:[c.jsxs($r,{variant:"outline",className:"justify-center px-3 py-1",children:[U.reminders," memories"]}),c.jsxs($r,{variant:"secondary",className:"justify-center px-3 py-1",children:[U.projects," projects"]}),c.jsxs($r,{variant:"secondary",className:"justify-center px-3 py-1",children:[U.sessions," chats"]}),c.jsxs($r,{variant:"secondary",className:"justify-center px-3 py-1",children:[U.threads," threads"]}),c.jsxs($r,{variant:"secondary",className:"justify-center px-3 py-1",children:[g.length," secrets"]})]}),F&&c.jsx(gn,{className:"border-destructive/30 bg-destructive/10 shadow-none",children:c.jsxs(Kc,{className:"flex items-center gap-2 p-3 text-sm text-destructive",children:[c.jsx(ia,{className:"h-4 w-4 shrink-0"}),c.jsx("span",{className:"min-w-0 flex-1",children:F}),c.jsx(_e,{variant:"ghost",size:"sm",className:"shrink-0",onClick:()=>B(null),children:"Dismiss"})]})}),c.jsx(gn,{children:c.jsxs(Kc,{className:"grid gap-3 p-3 lg:grid-cols-[minmax(0,1fr)_220px_220px_auto] lg:items-end",children:[c.jsxs("div",{className:"min-w-0 space-y-2",children:[c.jsx(di,{htmlFor:"new-reminder-content",children:"Memory"}),c.jsx(jp,{id:"new-reminder-content",value:a,onChange:ee=>l(ee.target.value),placeholder:"Add agent-readable memory...",className:"min-h-20 lg:min-h-10"})]}),c.jsxs("div",{className:"min-w-0 space-y-2",children:[c.jsx(di,{children:"Project"}),c.jsxs(th,{value:h,onValueChange:f,children:[c.jsx(Zu,{className:"h-10",children:c.jsx(rh,{placeholder:"Project"})}),c.jsxs(Qu,{children:[c.jsx(Ls,{value:"none",children:"No project"}),D.map(ee=>c.jsx(Ls,{value:ee.id,children:ee.title||ee.rootPath||"Untitled project"},ee.id))]})]})]}),c.jsxs("div",{className:"min-w-0 space-y-2",children:[c.jsx(di,{htmlFor:"new-reminder-tags",children:"Tags"}),c.jsx(Pn,{id:"new-reminder-tags",value:u,onChange:ee=>d(ee.target.value),placeholder:"tags, comma separated"})]}),c.jsxs(_e,{onClick:()=>void Y(),disabled:N||!a.trim(),className:"lg:self-end",children:[N?c.jsx(Vt,{className:"mr-2 h-4 w-4 animate-spin"}):c.jsx(qs,{className:"mr-2 h-4 w-4"}),"Add"]})]})}),c.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,1fr)_420px]",children:[c.jsxs("div",{className:"min-w-0 space-y-3",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[c.jsx("h2",{className:"text-sm font-semibold uppercase tracking-normal text-muted-foreground",children:"Memory List"}),c.jsxs(th,{value:s,onValueChange:o,children:[c.jsx(Zu,{className:"h-10 w-full sm:w-64",children:c.jsx(rh,{})}),c.jsxs(Qu,{children:[c.jsx(Ls,{value:"all",children:"All projects"}),D.map(ee=>c.jsx(Ls,{value:ee.id,children:ee.title||ee.rootPath||"Untitled project"},ee.id))]})]})]}),E&&!e?c.jsx("div",{className:"flex items-center justify-center py-24",children:c.jsx(Vt,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):O.length===0?c.jsx(gn,{className:"border-2 border-dashed shadow-none",children:c.jsxs(Kc,{className:"px-4 py-16 text-center",children:[c.jsx(Ja,{className:"mx-auto mb-4 h-10 w-10 text-muted-foreground"}),c.jsx("h3",{className:"mb-2 text-lg font-medium",children:"No memory matches"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Change filters or add the first memory entry."})]})}):O.map(ee=>{const ne=ee.projectId?R.get(ee.projectId):null,ae=ee.sessionId?$.get(ee.sessionId):null,te=Mnt(ee.tags),ue=`${ee.sourceType}:${ee.sourceId||"none"}@${ee.sourceSurface}`;return c.jsx(gn,{children:c.jsxs(Kc,{className:"p-3",children:[c.jsx(jp,{className:"min-h-20",defaultValue:ee.content,onBlur:he=>{const we=he.target.value.trim();we&&we!==ee.content&&z(ee,{content:we})}}),c.jsxs("div",{className:"mt-3 flex flex-col gap-2 text-xs text-muted-foreground sm:flex-row sm:flex-wrap sm:items-center",children:[c.jsxs("span",{className:"inline-flex items-center gap-1",children:[c.jsx(Pve,{className:"h-3.5 w-3.5"}),ne?ne.title||ne.rootPath||"Project":"Global memory"]}),ae&&c.jsxs("span",{className:"inline-flex items-center gap-1",children:[c.jsx(Ud,{className:"h-3.5 w-3.5"}),ae.name||"Chat"]}),c.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1",title:ue,children:[c.jsx(Ud,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"truncate",children:ue})]}),c.jsxs("span",{className:"inline-flex items-center gap-1",title:"Usage count",children:[c.jsx(k0e,{className:"h-3.5 w-3.5"}),ee.usageCount??0," uses"]}),c.jsxs("span",{className:"inline-flex items-center gap-1",children:[c.jsx(FD,{className:"h-3.5 w-3.5"}),"Updated ",r_(ee.updatedAt)]}),c.jsxs("span",{className:"inline-flex items-center gap-1",children:[c.jsx(FD,{className:"h-3.5 w-3.5"}),"Retrieved ",r_(ee.lastRetrievedAt)]})]}),te.length>0&&c.jsx("div",{className:"mt-3 flex flex-wrap gap-1.5",children:te.map(he=>c.jsx($r,{variant:"secondary",className:"rounded-md",children:he},he))}),c.jsx(w5,{className:"my-3"}),c.jsxs("div",{className:"flex flex-wrap gap-2",children:[c.jsxs(_e,{variant:"outline",size:"sm",onClick:()=>void z(ee,{status:ee.status==="active"?"archived":"active"}),children:[ee.status==="active"?c.jsx(hR,{className:"mr-2 h-4 w-4"}):c.jsx(uo,{className:"mr-2 h-4 w-4"}),ee.status==="active"?"Archive":"Restore"]}),c.jsxs(_e,{variant:"outline",size:"sm",onClick:()=>void V(ee.id),children:[c.jsx(Tl,{className:"mr-2 h-4 w-4"}),"Delete"]})]})]})},ee.id)})]}),c.jsx("div",{className:"min-w-0",children:c.jsxs(Y0,{defaultValue:"projects",className:"min-w-0",children:[c.jsxs(ag,{className:"grid w-full grid-cols-3",children:[c.jsx(so,{value:"projects",children:"Projects"}),c.jsx(so,{value:"threads",children:"Threads"}),c.jsx(so,{value:"secrets",children:"Secrets"})]}),c.jsx(oo,{value:"projects",className:"mt-3",children:c.jsx(Jc,{className:"max-h-[42rem] pr-1",children:c.jsxs("div",{className:"space-y-2",children:[D.map(ee=>c.jsx(gn,{children:c.jsxs(Kc,{className:"p-3",children:[c.jsxs("div",{className:"flex items-start justify-between gap-3",children:[c.jsxs("div",{className:"min-w-0",children:[c.jsx("div",{className:"truncate text-sm font-medium",children:ee.title||ee.rootPath||"Untitled project"}),c.jsx("div",{className:"truncate text-xs text-muted-foreground",children:ee.rootPath||ee.nodeId||"No path"})]}),c.jsx($r,{variant:"outline",className:"shrink-0",children:ee.reminderCount})]}),c.jsx(w5,{className:"my-3"}),c.jsxs("div",{className:"space-y-1.5",children:[ee.sessions.slice(0,6).map(ne=>c.jsxs("div",{className:"flex items-center justify-between gap-2 text-xs",children:[c.jsx("span",{className:"min-w-0 truncate",children:ne.name||"Chat"}),c.jsx("span",{className:"shrink-0 text-muted-foreground",children:r_(ne.lastActiveAt)})]},ne.id)),ee.sessions.length===0&&c.jsx("div",{className:"text-xs text-muted-foreground",children:"No chats yet"})]})]})},ee.id)),D.length===0&&c.jsx(gn,{className:"border-2 border-dashed shadow-none",children:c.jsx(Kc,{className:"p-6 text-center text-sm text-muted-foreground",children:"No projects yet"})})]})})}),c.jsx(oo,{value:"threads",className:"mt-3",children:c.jsx(Jc,{className:"max-h-[42rem] pr-1",children:c.jsxs("div",{className:"space-y-2",children:[I.slice(0,12).map(ee=>c.jsx(gn,{children:c.jsx(Kc,{className:"p-3",children:c.jsxs("div",{className:"flex items-start justify-between gap-3",children:[c.jsxs("div",{className:"min-w-0",children:[c.jsx("div",{className:"truncate text-sm font-medium",children:ee.title}),c.jsxs("div",{className:"truncate text-xs text-muted-foreground",children:[ee.providerId," · ",r_(ee.updatedAt)]})]}),c.jsx($r,{variant:ee.status==="completed"?"secondary":"outline",className:"shrink-0",children:ee.status})]})})},ee.id)),I.length===0&&c.jsx(gn,{className:"border-2 border-dashed shadow-none",children:c.jsx(Kc,{className:"p-6 text-center text-sm text-muted-foreground",children:"No past threads yet"})})]})})}),c.jsx(oo,{value:"secrets",className:"mt-3",children:c.jsx(gn,{children:c.jsxs(Kc,{className:"space-y-3 p-3",children:[c.jsxs("div",{className:"grid gap-2",children:[c.jsx(Pn,{value:b,onChange:ee=>_(ee.target.value),placeholder:"Label"}),c.jsx(Pn,{value:w,onChange:ee=>S(ee.target.value),placeholder:"SSH key, for example jakob@192.168.178.53:22"}),c.jsx(Pn,{type:"password",value:C,onChange:ee=>j(ee.target.value),placeholder:"Password"}),c.jsxs(_e,{onClick:()=>void Q(),disabled:N||!b.trim()||!w.trim()||!C,children:[N?c.jsx(Vt,{className:"mr-2 h-4 w-4 animate-spin"}):c.jsx(Qye,{className:"mr-2 h-4 w-4"}),"Save Secret"]})]}),c.jsx(w5,{}),c.jsx(Jc,{className:"max-h-[30rem] pr-1",children:c.jsxs("div",{className:"space-y-2",children:[g.map(ee=>c.jsx(gn,{children:c.jsx(Kc,{className:"p-3",children:c.jsxs("div",{className:"flex items-start justify-between gap-3",children:[c.jsxs("div",{className:"min-w-0",children:[c.jsx("div",{className:"truncate text-sm font-medium",children:ee.label}),c.jsxs("div",{className:"truncate text-xs text-muted-foreground",children:[ee.type," · ",ee.key]}),c.jsxs("div",{className:"mt-1 text-xs text-muted-foreground",children:["Last used ",r_(ee.lastUsedAt)]})]}),c.jsx(_e,{variant:"ghost",size:"sm",className:"shrink-0",onClick:()=>void q(ee.id),children:c.jsx(Tl,{className:"h-4 w-4"})})]})})},ee.id)),g.length===0&&c.jsx(gn,{className:"border-2 border-dashed shadow-none",children:c.jsx(Kc,{className:"p-6 text-center text-sm text-muted-foreground",children:"No saved secrets"})})]})})]})})})]})})]})]})}function aU({status:e}){switch(e){case"A":case"?":return c.jsx(G3,{className:"h-3.5 w-3.5 text-green-500 shrink-0"});case"D":return c.jsx(Mye,{className:"h-3.5 w-3.5 text-red-500 shrink-0"});case"R":return c.jsx(Tye,{className:"h-3.5 w-3.5 text-blue-500 shrink-0"});default:return c.jsx(mY,{className:"h-3.5 w-3.5 text-yellow-500 shrink-0"})}}function lU(e){switch(e){case"A":return"Added";case"?":return"Untracked";case"D":return"Deleted";case"R":return"Renamed";default:return"Modified"}}function Lnt({cwd:e,baseBranch:r,branch:n,onClose:i}){const[s,o]=y.useState([]),[a,l]=y.useState(!0),[u,d]=y.useState(0),[h,f]=y.useState(()=>typeof window<"u"&&window.innerWidth<960);y.useEffect(()=>{let _=!1;return l(!0),$s.fileDiffs(e,r,n).then(w=>{_||(o(w),d(0))}).catch(()=>{_||o([])}).finally(()=>{_||l(!1)}),()=>{_=!0}},[r,n,e]),y.useEffect(()=>{const _=()=>f(window.innerWidth<960);return _(),window.addEventListener("resize",_),()=>window.removeEventListener("resize",_)},[]);const g=s[u]??null,v=g?p2(g.path):"plaintext",b=y.useCallback(_=>{_.key==="Escape"?i():_.key==="ArrowDown"||_.key==="j"?(_.preventDefault(),d(w=>Math.min(w+1,s.length-1))):(_.key==="ArrowUp"||_.key==="k")&&(_.preventDefault(),d(w=>Math.max(w-1,0)))},[i,s.length]);return c.jsx("div",{className:"fixed inset-0 z-[100] bg-background/80 backdrop-blur-sm flex items-center justify-center p-4",onKeyDown:b,tabIndex:-1,children:c.jsxs("div",{className:"bg-popover border rounded-lg shadow-xl w-full max-w-6xl h-[85vh] flex flex-col",children:[c.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 border-b shrink-0",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(mY,{className:"h-4 w-4 text-muted-foreground"}),c.jsx("h3",{className:"text-sm font-medium",children:"Changes"}),!a&&c.jsxs("span",{className:"text-xs text-muted-foreground",children:[s.length," file",s.length!==1?"s":""," changed"]})]}),c.jsx(_e,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:i,children:c.jsx(Vn,{className:"h-4 w-4"})})]}),a?c.jsx("div",{className:"flex-1 flex items-center justify-center",children:c.jsx(Vt,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):s.length===0?c.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"No changes detected."}):c.jsxs("div",{className:Ae("flex-1 flex min-h-0",h&&"flex-col"),children:[c.jsxs("div",{className:Ae("border-r flex flex-col shrink-0 bg-muted/20",h?"w-full border-r-0 border-b max-h-40":"w-56"),children:[c.jsx("div",{className:"px-3 py-2 border-b",children:c.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Files"})}),c.jsx("div",{className:"flex-1 overflow-y-auto",children:s.map((_,w)=>c.jsxs("button",{className:Ae("flex items-center gap-2 w-full px-3 py-1.5 text-left text-xs hover:bg-accent/50 transition-colors",w===u&&"bg-accent"),onClick:()=>d(w),title:`${_.path} (${lU(_.status)})`,children:[c.jsx(aU,{status:_.status}),c.jsx("span",{className:"truncate font-mono",children:_.path.split(/[/\\]/).pop()})]},_.path))})]}),c.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b bg-muted/10 shrink-0",children:[c.jsx(aU,{status:(g==null?void 0:g.status)??"M"}),c.jsx("span",{className:"text-xs font-mono text-muted-foreground truncate",children:g==null?void 0:g.path}),c.jsx("span",{className:Ae("text-2xs px-1.5 py-0.5 rounded font-medium",(g==null?void 0:g.status)==="A"||(g==null?void 0:g.status)==="?"?"bg-green-500/10 text-green-500":(g==null?void 0:g.status)==="D"?"bg-red-500/10 text-red-500":"bg-yellow-500/10 text-yellow-500"),children:lU((g==null?void 0:g.status)??"M")})]}),c.jsx("div",{className:"flex-1 min-h-0",children:g&&c.jsx(Dw,{original:g.original,modified:g.modified,language:v,modelKey:g.path,className:"h-full",editorClassName:"h-full",renderSideBySide:!h,options:{readOnly:!0,minimap:{enabled:!1},renderOverviewRuler:!0,ignoreTrimWhitespace:!1,enableSplitViewResizing:!0}},g.path)})]})]})]})})}const cU={github:{placeholder:"ghp_... or github_pat_...",createUrl:"https://github.com/settings/tokens/new?scopes=repo,read:org,workflow&description=Jait+CLI",createLabel:"Create a GitHub token",scopes:"repo, read:org, and workflow",cliName:"gh",cliUrl:"https://cli.github.com"},gitlab:{placeholder:"glpat-...",createUrl:"https://gitlab.com/-/user_settings/personal_access_tokens",createLabel:"Create a GitLab token",scopes:"api and write_repository",cliName:"glab",cliUrl:"https://gitlab.com/gitlab-org/cli"},gitea:{placeholder:"your-gitea-token",createUrl:"",createLabel:"Create a token in your Gitea settings",scopes:"repo access",cliName:"tea",cliUrl:"https://gitea.com/gitea/tea"},"azure-devops":{placeholder:"your-azure-devops-pat",createUrl:"https://dev.azure.com/_usersSettings/tokens",createLabel:"Create an Azure DevOps PAT",scopes:"Code (Read & Write)",cliName:"az",cliUrl:"https://learn.microsoft.com/en-us/cli/azure/install-azure-cli"},bitbucket:{placeholder:"your-bitbucket-app-password",createUrl:"https://bitbucket.org/account/settings/app-passwords/",createLabel:"Create a Bitbucket app password",scopes:"Repositories (Read/Write) and Pull Requests (Read/Write)"}};function $nt({open:e,onOpenChange:r,cwd:n,remoteUrl:i,onReady:s}){const[o,a]=y.useState("checking"),[l,u]=y.useState(null),[d,h]=y.useState(""),[f,g]=y.useState(null),v=(l==null?void 0:l.provider)??"github",b=(l==null?void 0:l.forgeName)??"Git Forge",_=cU[v]??cU.github,w=y.useCallback(async()=>{a("checking"),g(null);try{const j=await $s.forgeStatus(n,i);u(j),!j.installed&&!j.authenticated?a("not-installed"):j.authenticated?a("success"):a("not-authenticated")}catch(j){g(j instanceof Error?j.message:"Failed to check forge status"),a("error")}},[n,i]);y.useEffect(()=>{e&&(w(),h(""))},[e,w]);const S=y.useCallback(async()=>{if(d.trim()){a("authenticating"),g(null);try{const j=await $s.forgeAuth(d.trim(),n,i);j.ok?(u(E=>E&&{...E,authenticated:!0,username:j.username}),a("success"),h("")):(g(j.error??"Authentication failed — check your token permissions."),a("not-authenticated"))}catch(j){g(j instanceof Error?j.message:"Authentication failed"),a("not-authenticated")}}},[d,n,i]),C=y.useCallback(()=>{r(!1),s==null||s()},[r,s]);return c.jsx(El,{open:e,onOpenChange:r,children:c.jsxs(sl,{className:"max-w-md",children:[c.jsxs(pc,{children:[c.jsxs(ol,{children:[b," Setup"]}),c.jsxs(rd,{children:["Pull request creation requires authentication with ",b,"."]})]}),o==="checking"&&c.jsxs("div",{className:"flex items-center gap-3 py-4",children:[c.jsx(Vt,{className:"h-5 w-5 animate-spin text-muted-foreground"}),c.jsxs("span",{className:"text-sm text-muted-foreground",children:["Checking ",b," status…"]})]}),(o==="not-installed"||o==="not-authenticated")&&c.jsxs("div",{className:"space-y-4 py-2",children:[c.jsxs("div",{className:"flex items-start gap-3",children:[c.jsx(sh,{className:`h-5 w-5 mt-0.5 shrink-0 ${o==="not-installed"?"text-red-500":"text-amber-500"}`}),c.jsxs("div",{className:"space-y-1",children:[c.jsx("p",{className:"text-sm font-medium",children:o==="not-installed"?`${b} CLI not detected`:`${b} is not authenticated`}),c.jsxs("p",{className:"text-xs text-muted-foreground",children:["Paste a Personal Access Token with ",_.scopes," scope to sign in."]})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(di,{htmlFor:"forge-token",className:"text-xs",children:"Personal Access Token"}),c.jsx(Pn,{id:"forge-token",type:"password",placeholder:_.placeholder,value:d,onChange:j=>h(j.target.value),onKeyDown:j=>{j.key==="Enter"&&S()},autoFocus:!0}),c.jsxs("p",{className:"text-2xs text-muted-foreground",children:[_.createUrl?c.jsx("a",{href:_.createUrl,target:"_blank",rel:"noopener noreferrer",className:"underline hover:text-foreground",children:_.createLabel}):c.jsx("span",{children:_.createLabel})," ","with ",c.jsx("code",{className:"text-2xs",children:_.scopes})," permissions."]})]}),o==="not-installed"&&_.cliName&&_.cliUrl&&c.jsxs("p",{className:"text-2xs text-muted-foreground",children:["Optionally install the ",c.jsx("code",{className:"text-2xs",children:_.cliName})," CLI:"," ",c.jsx("a",{href:_.cliUrl,target:"_blank",rel:"noopener noreferrer",className:"underline hover:text-foreground",children:_.cliUrl})]}),f&&c.jsx("p",{className:"text-xs text-red-500",children:f})]}),o==="authenticating"&&c.jsxs("div",{className:"flex items-center gap-3 py-4",children:[c.jsx(Vt,{className:"h-5 w-5 animate-spin text-muted-foreground"}),c.jsxs("span",{className:"text-sm text-muted-foreground",children:["Authenticating with ",b,"…"]})]}),o==="success"&&c.jsxs("div",{className:"flex items-start gap-3 py-4",children:[c.jsx(uo,{className:"h-5 w-5 text-green-500 mt-0.5 shrink-0"}),c.jsxs("div",{className:"space-y-1",children:[c.jsxs("p",{className:"text-sm font-medium",children:["Authenticated",l!=null&&l.username?` as ${l.username}`:""," on ",b]}),c.jsx("p",{className:"text-xs text-muted-foreground",children:"You can now create pull requests."})]})]}),o==="error"&&c.jsxs("div",{className:"flex items-start gap-3 py-4",children:[c.jsx(sh,{className:"h-5 w-5 text-red-500 mt-0.5 shrink-0"}),c.jsxs("div",{className:"space-y-1",children:[c.jsx("p",{className:"text-sm font-medium",children:"Something went wrong"}),f&&c.jsx("p",{className:"text-xs text-muted-foreground",children:f})]})]}),c.jsxs(bg,{children:[(o==="not-installed"||o==="not-authenticated"||o==="error")&&c.jsxs(c.Fragment,{children:[o==="error"&&c.jsx(_e,{variant:"outline",size:"sm",onClick:()=>void w(),children:"Re-check"}),c.jsx(_e,{size:"sm",disabled:!d.trim(),onClick:()=>void S(),children:"Sign in"})]}),o==="success"&&c.jsx(_e,{size:"sm",onClick:C,children:"Continue"})]})]})})}const Dnt=$nt;function wce(e,r,n,i){return e?r==="creating"||r==="open"||r==="merged"||r==="closed"||i!=null&&i.branch&&i.branch!==e?!0:n==="completed"?!((i==null?void 0:i.branch)===e&&i.hasWorkingTreeChanges):!1:!1}function uU(e,r,n,i,s){return r?wce(r,n,i,s)?{baseBranch:e,branch:r}:{baseBranch:e}:{}}function Int(e){return e!=="creating"}function dU(e,r,n){return e==null||r==null||n==null?null:{insertions:r,deletions:n,hasChanges:e>0}}function Bnt(e,r,n){return e?e.hasWorkingTreeChanges||!(n==="merged"||n==="closed")?!0:!!r:!1}function znt({hasRepository:e,threadKind:r,threadStatus:n,threadBranch:i,prUrl:s,prState:o}){return!e||r!=="delivery"?!1:!!(i||n==="completed"||s||o==="creating"||o==="open")}function Fnt({insertions:e,deletions:r}){return c.jsxs("span",{className:"inline-flex items-center gap-1 font-medium tabular-nums",children:[c.jsxs("span",{className:"text-green-600 dark:text-green-400",children:["+",e]}),c.jsxs("span",{className:"text-red-600 dark:text-red-400",children:["-",r]})]})}function rL({threadId:e,cwd:r,branch:n,baseBranch:i,threadTitle:s,prUrl:o,prState:a,threadStatus:l,threadKind:u="delivery",showStatusBadge:d=!0,changeFiles:h,changeInsertions:f,changeDeletions:g}){var ue;const v=ex(),b=dU(h,f,g),[_,w]=y.useState(!1),[S,C]=y.useState(!1),[j,E]=y.useState(!1),[A,N]=y.useState(null),[P,H]=y.useState(()=>b),K=y.useRef(!1),F=y.useRef(!1),[B,W]=y.useState(o?{url:o,kind:"created"}:null);y.useEffect(()=>{W(he=>o?{url:o,kind:"created"}:(he==null?void 0:he.kind)==="create"?he:null)},[o]),y.useEffect(()=>{let he=!1;return Int(a)?((async()=>{try{const pe=await $s.status(r,n??void 0);if(he)return;N(pe);const qe=dU(h,f,g);if(qe){H(qe);return}const se=uU(i,n,a,l,pe),it=n?await $s.diffStats(r,se.baseBranch,se.branch).catch(()=>null):null;if(he)return;if(it){H({insertions:it.insertions,deletions:it.deletions,hasChanges:it.hasChanges});return}if(n){H(null);return}H({insertions:pe.index.insertions+pe.workingTree.insertions,deletions:pe.index.deletions+pe.workingTree.deletions,hasChanges:pe.hasWorkingTreeChanges})}catch{he||(N(null),H(null))}})(),()=>{he=!0}):void 0},[i,n,g,h,f,r,a,o,l]);const[D,O]=y.useState(null),I=y.useRef(null);y.useEffect(()=>{if(!n||!o||a==="merged"||a==="closed"){O(null),I.current&&(clearInterval(I.current),I.current=null);return}const he=async()=>{try{const we=await $s.prChecks(r,n);if(!we||we.length===0){O(null);return}const pe=we.some(se=>se.conclusion==="failure"||se.conclusion==="cancelled"),qe=we.some(se=>se.state==="PENDING"||se.state==="QUEUED"||se.state==="IN_PROGRESS"||!se.conclusion);O(pe?"failing":qe?"pending":"passing")}catch{}};return he(),I.current=setInterval(he,15e3),()=>{I.current&&(clearInterval(I.current),I.current=null)}},[n,r,o,a]);const R=B??(o?{url:o,kind:"created"}:null)??((ue=A==null?void 0:A.pr)!=null&&ue.url?{url:A.pr.url,kind:"created"}:null),$=a==="creating"&&(R==null?void 0:R.kind)==="created"?"open":a,U=wce(n,$,l,A),Y=uU(i,n,$,l,A),z=$==="creating",V=b??P,Q=U?!!(V!=null&&V.hasChanges):Bnt(A,n,$),q=z&&!R?"Creating PR...":R?R.kind==="created"?"Open PR":"Open PR Page":"Create Pull Request",re=z&&!R?"Creating pull request":R?q:"Create pull request",ee=u==="delivery"&&(R!=null||l==="completed"),ne=_||z,ae=y.useCallback(async()=>{if(R){window.open(R.url,"_blank");return}if(l!=="completed"){An.error("Thread not completed",{description:"Finish the thread before creating a pull request."});return}if(u!=="delivery"){An.error("PR creation unavailable",{description:"Delegation threads are helper workers and do not create pull requests."});return}if(w(!0),!F.current)try{if((await $s.status(r)).prProvider==="github"){const we=await $s.ghStatus(r);if(!we.installed||!we.authenticated){w(!1),K.current=!0,E(!0);return}}}catch{}F.current=!1;try{const he=s.replace(/^\[.*?\]\s*/,""),we=await xr.createPullRequest(e,{commitMessage:he,baseBranch:i}),pe=we.result;we.pushFailed?we.resumed?An.info("Push failed — thread resumed",{description:"The agent is investigating the push failure and will fix the issue."}):An.error("Push failed",{description:we.error??"Git push failed. Re-open the thread to fix the issue."}):pe.pr.url?W({url:pe.pr.url,kind:"created"}):pe.push.createPrUrl&&W({url:pe.push.createPrUrl,kind:"create"})}catch(he){An.error("Failed",{description:he instanceof Error?he.message:"Unknown error"})}finally{w(!1)}},[i,r,e,u,l,s,R]),te=y.useCallback(()=>{K.current&&(K.current=!1,F.current=!0,ae())},[ae]);return c.jsxs(c.Fragment,{children:[c.jsx(Dnt,{open:j,onOpenChange:E,cwd:r,onReady:te}),c.jsxs("div",{className:"inline-flex items-center gap-1",children:[Q&&V&&c.jsxs(_e,{variant:"ghost",size:"sm",className:"h-7 gap-1 px-2 text-xs sm:h-6 sm:text-2xs",onClick:()=>C(!0),title:"View changes","aria-label":`View changes: +${V.insertions} -${V.deletions}`,children:[c.jsx(Fnt,{insertions:V.insertions,deletions:V.deletions}),!v&&"Changes"]}),c.jsxs(_e,{variant:"ghost",size:"sm",className:"h-7 min-w-8 gap-1 px-2 text-xs sm:h-6 sm:min-w-7 sm:text-2xs",disabled:ne||!ee,onClick:ae,title:u!=="delivery"?"Delegation threads do not create pull requests.":!R&&l!=="completed"?"Finish the thread before creating a pull request.":re,"aria-label":re,children:[ne?c.jsx(Vt,{className:"h-3.5 w-3.5 animate-spin sm:h-3 sm:w-3"}):c.jsx(Wye,{className:"h-3.5 w-3.5 sm:h-3 sm:w-3"}),!v&&q]}),d&&R&&c.jsx($r,{variant:"outline",className:`h-5 px-1.5 text-2xs font-medium ${$==="merged"?"border-purple-500/40 text-purple-700 bg-purple-500/10 dark:text-purple-300 dark:bg-purple-500/20 dark:border-purple-400/40":$==="closed"?"border-red-500/40 text-red-700 bg-red-500/10 dark:text-red-300 dark:bg-red-500/20 dark:border-red-400/40":$==="creating"?"border-amber-500/40 text-amber-700 bg-amber-500/10 dark:text-amber-300 dark:bg-amber-500/20 dark:border-amber-400/40":R.kind==="created"?"border-green-500/40 text-green-700 dark:text-green-300 dark:border-green-400/40":"border-amber-500/40 text-amber-700 dark:text-amber-300 dark:border-amber-400/40"}`,children:$==="merged"?"PR merged":$==="closed"?"PR closed":$==="creating"?"PR creating":R.kind==="created"?"PR open":"PR ready to open"}),d&&(R==null?void 0:R.kind)==="created"&&$==="open"&&D&&c.jsxs($r,{variant:"outline",className:`h-5 px-1.5 text-2xs font-medium inline-flex items-center gap-0.5 ${D==="failing"?"border-red-500/40 text-red-700 bg-red-500/10 dark:text-red-300 dark:bg-red-500/20 dark:border-red-400/40":D==="pending"?"border-amber-500/40 text-amber-700 bg-amber-500/10 dark:text-amber-300 dark:bg-amber-500/20 dark:border-amber-400/40":"border-green-500/40 text-green-700 bg-green-500/10 dark:text-green-300 dark:bg-green-500/20 dark:border-green-400/40"}`,children:[D==="failing"?c.jsx(sh,{className:"h-3 w-3"}):D==="pending"?c.jsx(xg,{className:"h-3 w-3"}):c.jsx(uo,{className:"h-3 w-3"}),D==="failing"?"Checks failing":D==="pending"?"Checks pending":"Checks passed"]})]}),S&&c.jsx(Lnt,{cwd:r,baseBranch:Y.baseBranch,branch:Y.branch,onClose:()=>C(!1)})]})}const Hnt={bundled:"bg-sky-500/10 text-sky-600",user:"bg-amber-500/10 text-amber-600",project:"bg-emerald-500/10 text-emerald-600",plugin:"bg-fuchsia-500/10 text-fuchsia-600"},Wnt=[{pattern:/\b(debug|bug|troubleshoot|fix)\b/i,icon:pA},{pattern:/\b(review|audit|security|secure|vuln)\b/i,icon:d1e},{pattern:/\b(test|qa|spec)\b/i,icon:wve},{pattern:/\b(perf|performance|optimi[sz]e|latency|profil)\b/i,icon:mA},{pattern:/\b(arch|design|system|topology|diagram)\b/i,icon:oc},{pattern:/\b(research|investigate|search|explore)\b/i,icon:tl},{pattern:/\b(data|analysis|analytics|report)\b/i,icon:mA},{pattern:/\b(code|generate|scaffold|tool|workflow)\b/i,icon:_R}];function Unt(e){const r=`${e.id} ${e.name} ${e.description}`,n=Wnt.find(({pattern:i})=>i.test(r));return{icon:(n==null?void 0:n.icon)??P0e,className:Hnt[e.source]}}function Vnt(e){return e.open&&!e.attemptedLoad&&e.skillsLength===0&&!e.loading}const qnt=Kn();function Gnt({token:e,threadId:r,selectedSkillIds:n}){const[i,s]=y.useState(!1),[o,a]=y.useState([]),[l,u]=y.useState(!1),[d,h]=y.useState(null),[f,g]=y.useState(!1),[v,b]=y.useState(!1),_=y.useCallback(async()=>{u(!0),h(null);try{const A={};e&&(A.Authorization=`Bearer ${e}`);const N=await fetch(`${qnt}/api/skills`,{headers:A});if(!N.ok)throw new Error(`Failed to load skills (HTTP ${N.status})`);const P=await N.json();a(P)}catch(A){h(A instanceof Error?A.message:"Failed to load skills")}finally{u(!1),g(!0)}},[e]);y.useEffect(()=>{Vnt({open:i,attemptedLoad:f,skillsLength:o.length,loading:l})&&_()},[f,_,l,i,o.length]);const w=y.useMemo(()=>o.filter(A=>A.enabled),[o]),S=n??w.map(A=>A.id),C=n===null,j=y.useCallback(async A=>{b(!0);try{await xr.updateThread(r,{skillIds:A})}finally{b(!1)}},[r]),E=y.useCallback(async(A,N)=>{const P=N?[...new Set([...S,A])]:S.filter(H=>H!==A);await j(P)},[S,j]);return c.jsxs(E9,{open:i,onOpenChange:s,children:[c.jsx(A9,{asChild:!0,children:c.jsxs(_e,{variant:"ghost",size:"sm",className:"h-6 gap-1 px-2 text-[10px] text-muted-foreground",children:[c.jsx(r1e,{className:"h-3 w-3"}),C?"Skills:auto":`Skills:${(n==null?void 0:n.length)??0}`]})}),c.jsxs(O9,{align:"end",className:"w-80 space-y-3 p-3",children:[c.jsxs("div",{className:"flex items-start justify-between gap-2",children:[c.jsxs("div",{children:[c.jsx("p",{className:"text-sm font-medium",children:"Thread skills"}),c.jsx("p",{className:"text-xs text-muted-foreground",children:C?"Uses globally enabled skills.":"Uses only pinned skills for this thread."})]}),C?c.jsx($r,{variant:"secondary",className:"text-[10px]",children:"global"}):c.jsx($r,{variant:"outline",className:"text-[10px]",children:"custom"})]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(_e,{size:"sm",variant:C?"secondary":"outline",className:"h-7 text-xs",disabled:v,onClick:()=>void j(null),children:"Global"}),c.jsx(_e,{size:"sm",variant:!C&&((n==null?void 0:n.length)??0)===0?"secondary":"outline",className:"h-7 text-xs",disabled:v,onClick:()=>void j([]),children:"None"})]}),l?c.jsxs("div",{className:"flex items-center gap-2 py-4 text-sm text-muted-foreground",children:[c.jsx(Vt,{className:"h-4 w-4 animate-spin"}),"Loading skills..."]}):d?c.jsxs("div",{className:"space-y-3 rounded-lg border border-destructive/50 bg-destructive/5 p-3",children:[c.jsxs("div",{className:"flex items-start gap-2 text-sm text-destructive",children:[c.jsx(ia,{className:"mt-0.5 h-4 w-4 shrink-0"}),c.jsx("span",{children:d})]}),c.jsx(_e,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:()=>{g(!1),_()},children:"Retry"})]}):w.length===0?c.jsx("div",{className:"rounded-lg border border-dashed p-4 text-xs text-muted-foreground",children:"No enabled skills. Install/enable ClawHub skills in Settings."}):c.jsx("div",{className:"max-h-64 space-y-2 overflow-y-auto pr-1",children:w.map(A=>{const N=S.includes(A.id),P=Unt(A),H=P.icon;return c.jsxs("div",{className:"flex items-start gap-3 rounded-lg border p-2.5",children:[c.jsx("div",{className:`mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-md ${P.className}`,children:c.jsx(H,{className:"h-3.5 w-3.5"})}),c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsx("p",{className:"truncate text-sm font-medium",children:A.name}),c.jsx("p",{className:"line-clamp-2 text-xs text-muted-foreground",children:A.description})]}),c.jsx(Ap,{checked:N,disabled:v||C,onCheckedChange:K=>{E(A.id,K)}})]},A.id)})})]})]})}function Knt({open:e,onOpenChange:r,repoId:n,repoName:i}){const s=_g(),[o,a]=y.useState(""),[l,u]=y.useState(""),[d,h]=y.useState(!1),[f,g]=y.useState(!1),[v,b]=y.useState(!1),[_,w]=y.useState(null),S=o!==l,C=ik();y.useEffect(()=>{if(!e||!n)return;let P=!1;return h(!0),w(null),xr.getRepoStrategy(n).then(H=>{P||(a(H),u(H))}).catch(H=>{P||w(H instanceof Error?H.message:"Failed to load strategy")}).finally(()=>{P||h(!1)}),()=>{P=!0}},[e,n]);const j=y.useCallback(async()=>{g(!0),w(null);try{const P=await xr.updateRepoStrategy(n,o);u(P),a(P)}catch(P){w(P instanceof Error?P.message:"Failed to save strategy")}finally{g(!1)}},[n,o]),E=y.useCallback(async()=>{b(!0),w(null);try{const P=await xr.generateRepoStrategy(n);P&&a(P)}catch(P){w(P instanceof Error?P.message:"Failed to generate strategy")}finally{b(!1)}},[n]),A=y.useCallback(()=>{a(l)},[l]),N=y.useCallback(P=>{if(P||!S){r(P);return}(async()=>await s({title:"Discard changes",description:"You have unsaved changes. Discard them?",confirmLabel:"Discard",variant:"destructive"})&&r(!1))()},[s,S,r]);return c.jsx(El,{open:e,onOpenChange:N,children:c.jsxs(sl,{className:"flex max-h-[85vh] w-full max-w-3xl flex-col gap-0 overflow-hidden p-0",children:[c.jsx(pc,{className:"shrink-0 border-b px-4 py-3",children:c.jsxs(ol,{className:"flex items-center gap-2 text-sm",children:[c.jsx("span",{children:"Strategy"}),c.jsx("span",{className:"text-muted-foreground",children:"—"}),c.jsx("span",{className:"font-normal text-muted-foreground",children:i}),S&&c.jsx("span",{className:"ml-1 rounded bg-amber-500/10 px-1.5 py-0.5 text-2xs text-amber-600 dark:text-amber-400",children:"unsaved"})]})}),c.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[d?c.jsx("div",{className:"flex flex-1 items-center justify-center py-12",children:c.jsx(Vt,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):c.jsxs("div",{className:"relative min-h-0 flex-1",children:[c.jsx(sk,{height:"55vh",language:"markdown",beforeMount:P=>fc(P,C),theme:C,value:o,onChange:P=>a(P??""),options:{minimap:{enabled:!1},"semanticHighlighting.enabled":!0,lineNumbers:"off",wordWrap:"on",fontSize:13,padding:{top:12,bottom:12},scrollBeyondLastLine:!1,renderLineHighlight:"none",overviewRulerLanes:0,folding:!0,tabSize:2}}),!o.trim()&&c.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center px-8 text-center",children:c.jsxs("div",{className:"max-w-md space-y-2",children:[c.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Add repository guidance for your agents"}),c.jsxs("p",{className:"text-xs leading-5 text-muted-foreground/80",children:["This works like a ",c.jsx("code",{children:"CLAUDE.md"})," or ",c.jsx("code",{children:"AGENTS.md"})," file: describe build commands, test workflow, code conventions, and repo-specific rules."]})]})})]}),_&&c.jsx("div",{className:"border-t bg-destructive/5 px-4 py-2 text-xs text-destructive",children:_})]}),c.jsx(bg,{className:"shrink-0 border-t px-4 py-3",children:c.jsxs("div",{className:"flex w-full items-center justify-between",children:[c.jsxs("div",{className:"flex gap-2",children:[c.jsxs(_e,{variant:"outline",size:"sm",className:"gap-1.5 text-xs",disabled:v||d,onClick:E,children:[v?c.jsx(Vt,{className:"h-3.5 w-3.5 animate-spin"}):c.jsx(T2,{className:"h-3.5 w-3.5"}),"Generate template"]}),S&&c.jsxs(_e,{variant:"ghost",size:"sm",className:"gap-1.5 text-xs",onClick:A,children:[c.jsx(_Y,{className:"h-3.5 w-3.5"}),"Reset"]})]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(_e,{variant:"ghost",size:"sm",className:"text-xs",onClick:()=>r(!1),children:"Cancel"}),c.jsxs(_e,{size:"sm",className:"gap-1.5 text-xs",disabled:!S||f||d,onClick:j,children:[f?c.jsx(Vt,{className:"h-3.5 w-3.5 animate-spin"}):c.jsx(N2,{className:"h-3.5 w-3.5"}),"Save"]})]})]})})]})})}const Ynt={proposed:{label:"Proposed",color:"text-blue-600 dark:text-blue-400",bg:"bg-blue-500/10"},approved:{label:"Ready",color:"text-green-600 dark:text-green-400",bg:"bg-green-500/10"},running:{label:"Running",color:"text-amber-600 dark:text-amber-400",bg:"bg-amber-500/10"},completed:{label:"Done",color:"text-emerald-600 dark:text-emerald-400",bg:"bg-emerald-500/10"},skipped:{label:"Skipped",color:"text-muted-foreground",bg:"bg-muted/50"}};function Xnt({status:e}){const r=Ynt[e];return c.jsx("span",{className:`inline-flex items-center rounded-full px-1.5 py-0.5 text-2xs font-medium ${r.color} ${r.bg}`,children:r.label})}function Jnt({open:e,onOpenChange:r,repoId:n,repoName:i,defaultBranch:s,repoLocalPath:o,provider:a,model:l,onStartThread:u}){const d=_g(),[h,f]=y.useState([]),[g,v]=y.useState(null),[b,_]=y.useState(!1),[w,S]=y.useState(!1),[C,j]=y.useState(null),[E,A]=y.useState(""),[N,P]=y.useState(new Set),[H,K]=y.useState(null),[F,B]=y.useState(""),[W,D]=y.useState(""),O=h.find(te=>te.id===g)??h[0]??null;y.useEffect(()=>{if(!e||!n)return;let te=!1;return _(!0),j(null),xr.listPlans(n).then(ue=>{te||(f(ue),ue.length>0&&!g&&v(ue[0].id))}).catch(ue=>{te||j(ue instanceof Error?ue.message:"Failed to load plans")}).finally(()=>{te||_(!1)}),()=>{te=!0}},[e,n]);const I=y.useCallback(async()=>{j(null);try{const te=await xr.createPlan(n,{title:"New Plan"});f(ue=>[te,...ue]),v(te.id)}catch(te){j(te instanceof Error?te.message:"Failed to create plan")}},[n]),R=y.useCallback(async()=>{if(O){S(!0),j(null);try{const te=await xr.generatePlanTasks(O.id,{prompt:E||void 0,provider:a,model:a==="jait"?null:l??null});f(ue=>ue.map(he=>he.id===te.plan.id?te.plan:he)),A("")}catch(te){j(te instanceof Error?te.message:"Failed to generate tasks")}finally{S(!1)}}},[O,E,l,a]),$=y.useCallback(async(te,ue)=>{if(!O)return;const he=O.tasks.map(we=>we.id===te?{...we,status:ue}:we);try{const we=await xr.updatePlan(O.id,{tasks:he});f(pe=>pe.map(qe=>qe.id===we.id?we:qe))}catch(we){j(we instanceof Error?we.message:"Failed to update task")}},[O]),U=y.useCallback(async te=>{if(!O)return;const ue=O.tasks.filter(he=>he.id!==te);try{const he=await xr.updatePlan(O.id,{tasks:ue});f(we=>we.map(pe=>pe.id===he.id?he:pe))}catch(he){j(he instanceof Error?he.message:"Failed to remove task")}},[O]),Y=y.useCallback(async()=>{if(!O||!H)return;const te=O.tasks.map(ue=>ue.id===H?{...ue,title:F,description:W}:ue);try{const ue=await xr.updatePlan(O.id,{tasks:te});f(he=>he.map(we=>we.id===ue.id?ue:we)),K(null)}catch(ue){j(ue instanceof Error?ue.message:"Failed to save task")}},[O,H,F,W]),z=y.useCallback(async te=>{if(O){j(null);try{await xr.startPlanTask(O.id,te.id),u(te,O,{name:i,localPath:o,defaultBranch:s}),f(ue=>ue.map(he=>he.id===O.id?{...he,tasks:he.tasks.map(we=>we.id===te.id?{...we,status:"running"}:we)}:he))}catch(ue){j(ue instanceof Error?ue.message:"Failed to start task")}}},[O,i,o,s,u]),V=y.useCallback(async()=>{if(!O)return;j(null);const te=O.tasks.filter(he=>he.status==="approved"||he.status==="proposed");if(te.length===0){j("No tasks to start. Approve some tasks first, or generate new ones.");return}const ue=O.tasks.map(he=>he.status==="proposed"?{...he,status:"approved"}:he);try{const he=await xr.updatePlan(O.id,{tasks:ue,status:"active"});f(we=>we.map(pe=>pe.id===he.id?he:pe))}catch{}for(const he of te)try{u(he,O,{name:i,localPath:o,defaultBranch:s}),f(we=>we.map(pe=>pe.id===O.id?{...pe,tasks:pe.tasks.map(qe=>qe.id===he.id?{...qe,status:"running"}:qe)}:pe)),await new Promise(we=>setTimeout(we,500))}catch{}},[O,i,o,s,u]),Q=y.useCallback(async()=>{if(!(!O||!await d({title:"Delete plan",description:`Delete plan "${O.title}"?`,confirmLabel:"Delete",variant:"destructive"})))try{await xr.deletePlan(O.id),f(ue=>ue.filter(he=>he.id!==O.id)),v(null)}catch(ue){j(ue instanceof Error?ue.message:"Failed to delete plan")}},[O,d]),q=te=>{P(ue=>{const he=new Set(ue);return he.has(te)?he.delete(te):he.add(te),he})},re=te=>{K(te.id),B(te.title),D(te.description),P(ue=>new Set(ue).add(te.id))},ee=(O==null?void 0:O.tasks.filter(te=>te.status==="approved"||te.status==="proposed").length)??0,ne=(O==null?void 0:O.tasks.filter(te=>te.status==="completed").length)??0,ae=(O==null?void 0:O.tasks.length)??0;return c.jsx(El,{open:e,onOpenChange:r,children:c.jsxs(sl,{className:"flex max-h-[85vh] w-full max-w-2xl flex-col gap-0 overflow-hidden p-0",children:[c.jsx(pc,{className:"shrink-0 border-b px-4 py-3",children:c.jsxs(ol,{className:"flex items-center gap-2 text-sm",children:[c.jsx("span",{children:"Plans"}),c.jsx("span",{className:"text-muted-foreground",children:"—"}),c.jsx("span",{className:"font-normal text-muted-foreground",children:i}),O&&ae>0&&c.jsxs("span",{className:"ml-auto text-2xs text-muted-foreground",children:[ne,"/",ae," done"]})]})}),c.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[b?c.jsx("div",{className:"flex flex-1 items-center justify-center py-12",children:c.jsx(Vt,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):O?c.jsxs(c.Fragment,{children:[h.length>1&&c.jsxs("div",{className:"flex items-center gap-2 border-b px-4 py-2",children:[c.jsx("select",{className:"flex-1 rounded border bg-transparent px-2 py-1 text-xs",value:O.id,onChange:te=>v(te.target.value),children:h.map(te=>c.jsxs("option",{value:te.id,children:[te.title," (",te.tasks.length," tasks)"]},te.id))}),c.jsx(_e,{variant:"ghost",size:"sm",className:"h-6 px-2 text-2xs",onClick:I,children:c.jsx(qs,{className:"h-3 w-3"})})]}),c.jsxs("div",{className:"flex items-center gap-2 border-b px-4 py-2",children:[c.jsx(Pn,{placeholder:"Describe what you want to accomplish…",className:"h-8 flex-1 text-xs",value:E,onChange:te=>A(te.target.value),onKeyDown:te=>{te.key==="Enter"&&!te.shiftKey&&(te.preventDefault(),R())}}),c.jsxs(_e,{variant:"outline",size:"sm",className:"h-8 gap-1.5 text-xs",disabled:w,onClick:()=>void R(),children:[w?c.jsx(Vt,{className:"h-3.5 w-3.5 animate-spin"}):c.jsx(T2,{className:"h-3.5 w-3.5"}),"Generate"]})]}),c.jsx("div",{className:"flex-1 overflow-y-auto",children:O.tasks.length===0?c.jsx("div",{className:"flex flex-col items-center justify-center gap-2 py-8",children:c.jsx("p",{className:"text-xs text-muted-foreground",children:"No tasks yet. Use the prompt above to generate tasks, or add them manually."})}):c.jsx("div",{className:"divide-y",children:O.tasks.map(te=>{const ue=N.has(te.id),he=H===te.id,we=te.status==="proposed"||te.status==="approved",pe=te.status==="proposed"||te.status==="approved";return c.jsxs("div",{className:"px-4 py-2.5",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("button",{type:"button",className:"shrink-0 rounded p-0.5 text-muted-foreground hover:text-foreground",onClick:()=>q(te.id),children:ue?c.jsx(Ml,{className:"h-3.5 w-3.5"}):c.jsx(Cs,{className:"h-3.5 w-3.5"})}),c.jsx(Xnt,{status:te.status}),he?c.jsx(Pn,{className:"h-6 flex-1 text-xs",value:F,onChange:qe=>B(qe.target.value),onKeyDown:qe=>{qe.key==="Enter"&&Y(),qe.key==="Escape"&&K(null)},autoFocus:!0}):c.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[c.jsx("span",{className:`min-w-0 flex-1 truncate text-xs ${te.status==="skipped"?"line-through text-muted-foreground":"font-medium"}`,children:te.title}),te.skillCandidate&&c.jsx("span",{className:"inline-flex shrink-0 items-center rounded-full bg-violet-500/10 px-1.5 py-0.5 text-[10px] font-medium text-violet-600 dark:text-violet-400",children:"skill"})]}),c.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[we&&c.jsx("button",{type:"button",title:"Start thread",className:"rounded p-1 text-green-600 hover:bg-green-500/10 dark:text-green-400",onClick:()=>void z(te),children:c.jsx(DS,{className:"h-3.5 w-3.5",fill:"currentColor"})}),te.status==="proposed"&&c.jsx("button",{type:"button",title:"Approve",className:"rounded p-1 text-green-600 hover:bg-green-500/10 dark:text-green-400",onClick:()=>void $(te.id,"approved"),children:c.jsx(fs,{className:"h-3.5 w-3.5"})}),pe&&c.jsx("button",{type:"button",title:"Skip",className:"rounded p-1 text-muted-foreground hover:bg-muted",onClick:()=>void $(te.id,"skipped"),children:c.jsx(cve,{className:"h-3.5 w-3.5"})}),!he&&(te.status==="proposed"||te.status==="approved")&&c.jsx("button",{type:"button",title:"Edit",className:"rounded p-1 text-muted-foreground hover:bg-muted",onClick:()=>re(te),children:c.jsx(bR,{className:"h-3 w-3"})}),he&&c.jsx("button",{type:"button",title:"Save",className:"rounded p-1 text-green-600 hover:bg-green-500/10",onClick:()=>void Y(),children:c.jsx(fs,{className:"h-3.5 w-3.5"})}),(te.status==="proposed"||te.status==="approved"||te.status==="skipped")&&c.jsx("button",{type:"button",title:"Remove",className:"rounded p-1 text-muted-foreground hover:text-destructive",onClick:()=>void U(te.id),children:c.jsx(Tl,{className:"h-3 w-3"})})]})]}),ue&&c.jsxs("div",{className:"mt-2 pl-6",children:[he?c.jsx("textarea",{className:"w-full rounded border bg-transparent px-2 py-1.5 text-xs leading-relaxed focus:outline-none focus:ring-1 focus:ring-primary",rows:4,value:W,onChange:qe=>D(qe.target.value)}):c.jsx("p",{className:"whitespace-pre-wrap text-xs leading-relaxed text-muted-foreground",children:te.description||"No description."}),te.threadId&&c.jsxs("p",{className:"mt-1 text-2xs text-muted-foreground",children:["Thread: ",c.jsx("code",{className:"rounded bg-muted px-1",children:te.threadId.slice(-8)})]}),(te.skillCandidate||te.skillRationale||te.skillTitle)&&c.jsxs("div",{className:"mt-2 rounded-md border border-violet-500/20 bg-violet-500/5 px-2 py-1.5 text-[10px] text-muted-foreground",children:[c.jsxs("p",{children:["Skill eval: ",te.skillCandidate?"yes":"no",te.skillTitle?` · ${te.skillTitle}`:""]}),te.skillRationale&&c.jsx("p",{className:"mt-1 whitespace-pre-wrap",children:te.skillRationale})]})]})]},te.id)})})})]}):c.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 py-12",children:[c.jsx("p",{className:"text-sm text-muted-foreground",children:"No plans yet for this repository."}),c.jsxs(_e,{size:"sm",className:"gap-1.5 text-xs",onClick:I,children:[c.jsx(qs,{className:"h-3.5 w-3.5"}),"Create plan"]})]}),C&&c.jsx("div",{className:"border-t bg-destructive/5 px-4 py-2 text-xs text-destructive",children:C})]}),c.jsx(bg,{className:"shrink-0 border-t px-4 py-3",children:c.jsxs("div",{className:"flex w-full items-center justify-between",children:[c.jsxs("div",{className:"flex gap-2",children:[!O&&c.jsxs(_e,{size:"sm",className:"gap-1.5 text-xs",onClick:I,children:[c.jsx(qs,{className:"h-3.5 w-3.5"}),"New plan"]}),O&&c.jsxs(_e,{variant:"ghost",size:"sm",className:"gap-1.5 text-xs text-destructive hover:text-destructive",onClick:()=>void Q(),children:[c.jsx(Tl,{className:"h-3.5 w-3.5"}),"Delete plan"]})]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(_e,{variant:"ghost",size:"sm",className:"text-xs",onClick:()=>r(!1),children:"Close"}),O&&ee>0&&c.jsxs(_e,{size:"sm",className:"gap-1.5 text-xs",onClick:()=>void V(),children:[c.jsx(tye,{className:"h-3.5 w-3.5"}),"Start all (",ee,")"]})]})]})})]})})}function Znt(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const r=e;return typeof r.id!="string"||typeof r.scope!="string"||r.scope!=="project"&&r.scope!=="contact"?null:{id:r.id,scope:r.scope,source:typeof r.source=="string"?r.source:"",sourceType:typeof r.sourceType=="string"?r.sourceType:void 0,sourceId:typeof r.sourceId=="string"?r.sourceId:void 0,sourceSurface:typeof r.sourceSurface=="string"?r.sourceSurface:void 0,updatedAt:typeof r.updatedAt=="string"?r.updatedAt:"",content:typeof r.content=="string"?r.content:""}}function p8(e){return Array.isArray(e)?e.filter(r=>typeof r=="string"):[]}function N7(e){const r=e.memory&&typeof e.memory=="object"&&!Array.isArray(e.memory)?e.memory:null,n=Array.isArray(r==null?void 0:r.retrieved)?r.retrieved.map(Znt).filter(s=>!!s):[],i=r?{query:typeof r.query=="string"?r.query:"",retrieved:n,injectedIds:p8(r.injectedIds),ignoredIds:p8(r.ignoredIds),savedIds:p8(r.savedIds)}:void 0;return{provider:String(e.provider??"jait"),model:typeof e.model=="string"?e.model:void 0,rounds:Array.isArray(e.rounds)?e.rounds:[],note:typeof e.note=="string"?e.note:void 0,...i?{memory:i}:{}}}function zv(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function Us(e){return typeof e=="string"&&e.trim()?e:null}function Sce(e){if(typeof e!="string")return null;try{const r=JSON.parse(e);return zv(r)}catch{return null}}function z_(...e){const r={};for(const n of e)if(n)for(const[i,s]of Object.entries(n))s!=null&&s!==""&&(r[i]=s);return r}function m8(e,r){const n=zv(e.args),i=zv(e.data),s=Sce(e.message),o=r.replace("_","."),a=z_(i,s);return Object.keys(n??{}).length>0?z_(a,n):o==="edit"||o.startsWith("file.")?z_(a,{path:Us(e.path)??Us(e.file)??Us(e.name)??Us(i==null?void 0:i.path)??Us(i==null?void 0:i.file)??"",search:e.search??(i==null?void 0:i.search),replace:e.replace??(i==null?void 0:i.replace),content:e.content??(i==null?void 0:i.content)}):o==="web"||o.startsWith("web.")||o.startsWith("browser.")?z_(a,{url:Us(e.url)??Us(i==null?void 0:i.url)??Us(i==null?void 0:i.finalUrl)??"",query:Us(e.query)??Us(e.name)??Us(i==null?void 0:i.query)??"",content:e.content??(i==null?void 0:i.content)}):a}function Qnt(e,r){const n=Us(e.message)??Us(e.output)??Us(e.content)??Us(e.text)??Us(e.summary);if(n)return n;const i=zv(e.data),s=Us(i==null?void 0:i.message)??Us(i==null?void 0:i.output)??Us(i==null?void 0:i.content)??Us(i==null?void 0:i.text)??Us(i==null?void 0:i.summary);return s||r}function eit(e){const r=[];let n=null,i=[];const s=new Map;let o=[];function a(){o.length>0&&(i.push({type:"toolGroup",callIds:[...o]}),o=[])}function l(){n&&(a(),i.length>0&&(n.segments=[...i]),r.push(n),n=null,i=[])}function u(d){return(!n||n.role!=="assistant")&&(l(),n={id:d,role:"assistant",content:"",toolCalls:[]},i=[]),n}for(const d of e){const h=d.payload??{};switch(d.kind){case"message":{const f=h.role,g=typeof h.content=="string"?h.content:d.summary,v=Array.isArray(h.referencedFiles)?h.referencedFiles.flatMap(_=>{if(!_||typeof _!="object")return[];const w=typeof _.path=="string"?_.path:null,S=typeof _.name=="string"?_.name:null;return w&&S?[{path:w,name:S}]:[]}):void 0,b=cj(h.displaySegments);if(f==="user")l(),r.push({id:d.id,role:"user",content:g,displayContent:b.length>0?J0(b):g,referencedFiles:v,displaySegments:b.length>0?b:void 0});else{const _=u(d.id);a();const w=g??"";w&&(_.content+=(_.content?`
1215
+ `);navigator.clipboard.writeText(w),u(!0),setTimeout(()=>u(!1),1500)};y.useEffect(()=>{i&&g.length>0&&v.scrollToIndex(g.length-1,{align:"end"})},[g.length,i]);const _=y.useCallback(()=>{const w=n.current;if(!w)return;const S=w.scrollHeight-w.scrollTop-w.clientHeight<40;s(S)},[]);return c.jsxs("div",{className:"flex flex-col h-full bg-[#0d1117] text-[#c9d1d9] text-xs font-mono",children:[c.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-zinc-700/60 shrink-0",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-xs font-semibold text-zinc-400 uppercase tracking-wider",children:"SSE Debug"}),c.jsxs("span",{className:"text-2xs text-zinc-500",children:[g.length,"/",r.length]})]}),c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx("input",{type:"text",placeholder:"Filter...",value:o,onChange:w=>a(w.target.value),className:"h-5 w-28 px-1.5 text-2xs rounded bg-zinc-800 border border-zinc-700 text-zinc-300 placeholder-zinc-500 focus:outline-none focus:border-blue-500"}),c.jsx(_e,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:b,title:"Copy all events",children:l?c.jsx(fs,{className:"h-3 w-3 text-green-400"}):c.jsx(ac,{className:"h-3 w-3"})}),c.jsx(_e,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:Ftt,children:c.jsx(Tl,{className:"h-3 w-3"})}),c.jsx(_e,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:e,children:c.jsx(Vn,{className:"h-3 w-3"})})]})]}),c.jsx("div",{ref:n,onScroll:_,className:"flex-1 overflow-y-auto overflow-x-hidden",children:c.jsx("div",{style:{height:`${v.getTotalSize()}px`,position:"relative",width:"100%"},children:v.getVirtualItems().map(w=>{const S=g[w.index],C=new Date(S.ts).toISOString().slice(11,23),j=Wtt[S.type]??"text-zinc-400",E=S.raw.length>120,A=d.has(S.id),N=E&&!A?S.raw.slice(0,120)+"…":S.raw;return c.jsxs("div",{"data-index":w.index,ref:v.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${w.start}px)`},className:Ae("flex gap-2 px-2 hover:bg-zinc-800/50 leading-tight cursor-pointer select-none",A?"items-start py-1 bg-zinc-800/30":"items-center"),onClick:()=>f(S.id),children:[c.jsx("span",{className:"text-zinc-600 shrink-0 w-20",style:{minHeight:h8},children:C}),c.jsx("span",{className:Ae("shrink-0 w-28 text-right",j),style:{minHeight:h8},children:S.type}),c.jsxs("span",{className:Ae("text-zinc-400 min-w-0",A?"break-all whitespace-pre-wrap":"truncate"),children:[N,E&&!A&&c.jsx("span",{className:"text-zinc-600 ml-1",children:"▸"})]})]},S.id)})})}),!i&&c.jsx("div",{className:"absolute bottom-2 right-4",children:c.jsx(_e,{variant:"outline",size:"icon",className:"h-6 w-6 rounded-full bg-zinc-800 border-zinc-600",onClick:()=>{s(!0),v.scrollToIndex(g.length-1,{align:"end"})},children:c.jsx(dY,{className:"h-3 w-3"})})})]})}function Vtt(e,r=[]){let n=[];function i(o,a){const l=y.createContext(a),u=n.length;n=[...n,a];const d=f=>{var S;const{scope:g,children:v,...b}=f,_=((S=g==null?void 0:g[e])==null?void 0:S[u])||l,w=y.useMemo(()=>b,Object.values(b));return c.jsx(_.Provider,{value:w,children:v})};d.displayName=o+"Provider";function h(f,g){var _;const v=((_=g==null?void 0:g[e])==null?void 0:_[u])||l,b=y.useContext(v);if(b)return b;if(a!==void 0)return a;throw new Error(`\`${f}\` must be used within \`${o}\``)}return[d,h]}const s=()=>{const o=n.map(a=>y.createContext(a));return function(l){const u=(l==null?void 0:l[e])||o;return y.useMemo(()=>({[`__scope${e}`]:{...l,[e]:u}}),[l,u])}};return s.scopeName=e,[i,qtt(s,...r)]}function qtt(...e){const r=e[0];if(e.length===1)return r;const n=()=>{const i=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(o){const a=i.reduce((l,{useScope:u,scopeName:d})=>{const f=u(o)[`__scope${d}`];return{...l,...f}},{});return y.useMemo(()=>({[`__scope${r.scopeName}`]:a}),[a])}};return n.scopeName=r.scopeName,n}function mle(e){const r=y.useRef({value:e,previous:e});return y.useMemo(()=>(r.current.value!==e&&(r.current.previous=r.current.value,r.current.value=e),r.current.previous),[e])}function Gtt(e){const r=Ktt(e),n=y.forwardRef((i,s)=>{const{children:o,...a}=i,l=y.Children.toArray(o),u=l.find(Xtt);if(u){const d=u.props.children,h=l.map(f=>f===u?y.Children.count(d)>1?y.Children.only(null):y.isValidElement(d)?d.props.children:null:f);return c.jsx(r,{...a,ref:s,children:y.isValidElement(d)?y.cloneElement(d,void 0,h):null})}return c.jsx(r,{...a,ref:s,children:o})});return n.displayName=`${e}.Slot`,n}function Ktt(e){const r=y.forwardRef((n,i)=>{const{children:s,...o}=n;if(y.isValidElement(s)){const a=Ztt(s),l=Jtt(o,s.props);return s.type!==y.Fragment&&(l.ref=i?ho(i,a):a),y.cloneElement(s,l)}return y.Children.count(s)>1?y.Children.only(null):null});return r.displayName=`${e}.SlotClone`,r}var Ytt=Symbol("radix.slottable");function Xtt(e){return y.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Ytt}function Jtt(e,r){const n={...r};for(const i in r){const s=e[i],o=r[i];/^on[A-Z]/.test(i)?s&&o?n[i]=(...l)=>{const u=o(...l);return s(...l),u}:s&&(n[i]=s):i==="style"?n[i]={...s,...o}:i==="className"&&(n[i]=[s,o].filter(Boolean).join(" "))}return{...e,...n}}function Ztt(e){var i,s;let r=(i=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:i.get,n=r&&"isReactWarning"in r&&r.isReactWarning;return n?e.ref:(r=(s=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:s.get,n=r&&"isReactWarning"in r&&r.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Qtt=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],gle=Qtt.reduce((e,r)=>{const n=Gtt(`Primitive.${r}`),i=y.forwardRef((s,o)=>{const{asChild:a,...l}=s,u=a?n:r;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(u,{...l,ref:o})});return i.displayName=`Primitive.${r}`,{...e,[r]:i}},{}),YN="Switch",[ert]=Vtt(YN),[trt,rrt]=ert(YN),yle=y.forwardRef((e,r)=>{const{__scopeSwitch:n,name:i,checked:s,defaultChecked:o,required:a,disabled:l,value:u="on",onCheckedChange:d,form:h,...f}=e,[g,v]=y.useState(null),b=li(r,j=>v(j)),_=y.useRef(!1),w=g?h||!!g.closest("form"):!0,[S,C]=wp({prop:s,defaultProp:o??!1,onChange:d,caller:YN});return c.jsxs(trt,{scope:n,checked:S,disabled:l,children:[c.jsx(gle.button,{type:"button",role:"switch","aria-checked":S,"aria-required":a,"data-state":_le(S),"data-disabled":l?"":void 0,disabled:l,value:u,...f,ref:b,onClick:kr(e.onClick,j=>{C(E=>!E),w&&(_.current=j.isPropagationStopped(),_.current||j.stopPropagation())})}),w&&c.jsx(ble,{control:g,bubbles:!_.current,name:i,value:u,checked:S,required:a,disabled:l,form:h,style:{transform:"translateX(-100%)"}})]})});yle.displayName=YN;var vle="SwitchThumb",xle=y.forwardRef((e,r)=>{const{__scopeSwitch:n,...i}=e,s=rrt(vle,n);return c.jsx(gle.span,{"data-state":_le(s.checked),"data-disabled":s.disabled?"":void 0,...i,ref:r})});xle.displayName=vle;var nrt="SwitchBubbleInput",ble=y.forwardRef(({__scopeSwitch:e,control:r,checked:n,bubbles:i=!0,...s},o)=>{const a=y.useRef(null),l=li(a,o),u=mle(n),d=YY(r);return y.useEffect(()=>{const h=a.current;if(!h)return;const f=window.HTMLInputElement.prototype,v=Object.getOwnPropertyDescriptor(f,"checked").set;if(u!==n&&v){const b=new Event("click",{bubbles:i});v.call(h,n),h.dispatchEvent(b)}},[u,n,i]),c.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...s,tabIndex:-1,ref:l,style:{...s.style,...d,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});ble.displayName=nrt;function _le(e){return e?"checked":"unchecked"}var wle=yle,irt=xle;const Ap=y.forwardRef(({className:e,...r},n)=>c.jsx(wle,{className:Ae("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...r,ref:n,children:c.jsx(irt,{className:Ae("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}));Ap.displayName=wle.displayName;const x7=[{label:"Every minute",value:"* * * * *",description:"Runs every minute"},{label:"Every 5 minutes",value:"*/5 * * * *",description:"Runs every 5 minutes"},{label:"Every 15 minutes",value:"*/15 * * * *",description:"Runs every 15 minutes"},{label:"Every 30 minutes",value:"*/30 * * * *",description:"Runs every 30 minutes"},{label:"Hourly",value:"0 * * * *",description:"Runs at the start of every hour"},{label:"Every 2 hours",value:"0 */2 * * *",description:"Runs every 2 hours"},{label:"Daily at midnight",value:"0 0 * * *",description:"Runs at 00:00 every day"},{label:"Daily at 9am",value:"0 9 * * *",description:"Runs at 09:00 every day"},{label:"Daily at 6pm",value:"0 18 * * *",description:"Runs at 18:00 every day"},{label:"Weekly (Sunday)",value:"0 0 * * 0",description:"Runs at midnight every Sunday"},{label:"Weekly (Monday)",value:"0 9 * * 1",description:"Runs at 9am every Monday"},{label:"Monthly",value:"0 0 1 * *",description:"Runs at midnight on the 1st of each month"}];function XN(e){return e.trim().split(/\s+/).join(" ")}function Qc(e){if(!/^\d+$/.test(e))return null;const r=Number.parseInt(e,10);return Number.isNaN(r)?null:r}function Sle(e){const r=XN(e),n=r.split(" ");if(n.length!==5)return r;const[i,s,o,a,l]=n,u=x7.find(h=>h.value===r);if(u)return u.description;const d=[];if(i==="*"&&s==="*"?d.push("Every minute"):i.startsWith("*/")?d.push(`Every ${i.slice(2)} minutes`):s==="*"?d.push(`At minute ${i} of every hour`):i==="0"?d.push(`At ${s}:00`):d.push(`At ${s}:${i.padStart(2,"0")}`),l!=="*"){const h=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],f=Qc(l);f!==null&&f>=0&&f<=6&&d.push(`on ${h[f]}`)}if(o!=="*"&&d.push(`on day ${o}`),a!=="*"){const h=["","January","February","March","April","May","June","July","August","September","October","November","December"],f=Qc(a);f!==null&&f>=1&&f<=12&&d.push(`in ${h[f]}`)}return d.join(" ")}function kle(e){const r=XN(e).split(" ");if(r.length!==5)return{valid:!1,error:"Cron expression must have 5 parts (minute hour day month weekday)"};const[n,i,s,o,a]=r,l=[{name:"minute",value:n,min:0,max:59},{name:"hour",value:i,min:0,max:23},{name:"day",value:s,min:1,max:31},{name:"month",value:o,min:1,max:12},{name:"weekday",value:a,min:0,max:6}];for(const u of l)if(!srt(u.value,u.min,u.max))return{valid:!1,error:`Invalid ${u.name}: ${u.value}`};return{valid:!0}}function srt(e,r,n){if(e==="*")return!0;if(e.startsWith("*/")){const s=Qc(e.slice(2));return s!==null&&s>0&&s<=n}if(e.includes("-")){const s=e.split("-");if(s.length!==2)return!1;const o=Qc(s[0]??""),a=Qc(s[1]??"");return o!==null&&a!==null&&o>=r&&a<=n&&o<=a}if(e.includes(","))return e.split(",").every(s=>{const o=Qc(s);return o!==null&&o>=r&&o<=n});const i=Qc(e);return i!==null&&i>=r&&i<=n}function ort(e){try{if(!kle(e).valid)return null;const r=new Date,n=XN(e).split(" "),[i,s]=n;if(i==="*"&&s==="*"){const o=new Date(r);return o.setMinutes(r.getMinutes()+1,0,0),o}if(i.startsWith("*/")){const o=Qc(i.slice(2));if(o===null||o<=0)return null;const a=new Date(r),l=Math.ceil(r.getMinutes()/o)*o;return l>=60?(a.setHours(a.getHours()+1),a.setMinutes(l%60)):a.setMinutes(l),a.setSeconds(0),a.setMilliseconds(0),a<=r&&a.setMinutes(a.getMinutes()+o),a}if(i!=="*"&&s==="*"){const o=Qc(i);if(o===null)return null;const a=new Date(r);return a.setMinutes(o,0,0),a<=r&&a.setHours(a.getHours()+1),a}if(i!=="*"&&s.startsWith("*/")){const o=Qc(i),a=Qc(s.slice(2));if(o===null||a===null||a<=0)return null;const l=new Date(r);l.setMinutes(o,0,0);const u=r.getHours(),d=u%a;let h=d===0?u:u+(a-d);return l.setHours(h),l<=r&&(h+=a,l.setHours(h)),l}if(i!=="*"&&s!=="*"){const o=Qc(i),a=Qc(s);if(o===null||a===null)return null;const l=new Date(r);return l.setHours(a),l.setMinutes(o),l.setSeconds(0),l.setMilliseconds(0),l<=r&&l.setDate(l.getDate()+1),l}return null}catch{return null}}function art(e){const r=new Date,n=e.getTime()-r.getTime();if(n<6e4)return"now";const i=Math.floor(n/6e4);if(i<60)return`in ${i}m`;const s=Math.floor(n/36e5);return s<24?`in ${s}h`:`in ${Math.floor(n/864e5)}d`}function lrt({job:e,recentRun:r,onToggle:n,onTrigger:i,onDelete:s,onEdit:o,onViewHistory:a,isLoading:l=!1}){const[u,d]=y.useState(!1),[h,f]=y.useState(!1),g=async w=>{d(!0);try{await n(e.id,w)}finally{d(!1)}},v=async()=>{f(!0);try{await i(e.id)}finally{f(!1)}},b=e.enabled?ort(e.cron_expression):null,_={agent_task:"Agent Task",system_job:"System Job"};return c.jsxs(gn,{"data-testid":`job-card-${e.id}`,className:Ae("transition-opacity",l&&"opacity-50",!e.enabled&&"opacity-75"),children:[c.jsx(hle,{className:"space-y-3 pb-3",children:c.jsxs("div",{className:"flex flex-col gap-3 md:flex-row md:items-start md:justify-between",children:[c.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[e.job_type==="agent_task"&&e.model&&e.provider&&c.jsx(hj,{provider:e.provider,model:e.model,size:32}),c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsx(fle,{className:"truncate text-base md:text-lg",children:e.name}),c.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2",children:[c.jsx($r,{variant:e.job_type==="agent_task"?"default":"secondary",children:_[e.job_type]}),e.provider&&c.jsx($r,{variant:"outline",className:"text-xs",children:e.provider})]})]})]}),c.jsxs("div",{className:"flex items-center justify-between rounded-md border bg-muted/20 px-3 py-2 md:min-w-[92px] md:justify-end md:border-0 md:bg-transparent md:p-0",children:[c.jsx("span",{className:"text-xs text-muted-foreground md:hidden",children:e.enabled?"Enabled":"Paused"}),c.jsx(Ap,{checked:e.enabled,onCheckedChange:g,disabled:u})]})]})}),c.jsxs(Kc,{className:"space-y-3 pt-0",children:[c.jsxs("div",{className:"flex flex-col gap-1 text-sm text-muted-foreground md:flex-row md:items-center md:gap-2",children:[c.jsx(xg,{className:"h-4 w-4"}),c.jsx("span",{className:"break-all font-mono",children:e.cron_expression}),c.jsxs("span",{className:"text-xs md:text-xs",children:["(",Sle(e.cron_expression),")"]})]}),b&&c.jsxs("div",{className:"text-sm text-muted-foreground",children:["Next run: ",b.toLocaleString()," (",art(b),")"]}),e.prompt&&c.jsxs("div",{className:"line-clamp-2 text-sm italic text-muted-foreground",children:['"',e.prompt,'"']}),r&&c.jsxs("div",{className:"flex flex-col gap-1 text-sm md:flex-row md:items-center md:gap-2",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[r.status==="completed"&&c.jsxs(c.Fragment,{children:[c.jsx(uo,{className:"h-4 w-4 text-green-500"}),c.jsx("span",{className:"text-green-600 dark:text-green-400",children:"Last run succeeded"})]}),r.status==="failed"&&c.jsxs(c.Fragment,{children:[c.jsx(ia,{className:"h-4 w-4 text-red-500"}),c.jsx("span",{className:"text-red-600 dark:text-red-400",children:"Last run failed"})]}),r.status==="running"&&c.jsxs(c.Fragment,{children:[c.jsx(Vt,{className:"h-4 w-4 animate-spin text-blue-500"}),c.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:"Running now..."})]})]}),r.started_at&&c.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(r.started_at).toLocaleString()})]}),c.jsxs("div",{className:"grid grid-cols-2 gap-2 border-t pt-3 md:grid-cols-[minmax(0,1fr)_auto_auto_auto] md:items-center",children:[c.jsxs(_e,{variant:"outline",size:"sm",onClick:v,disabled:h||!e.enabled,"data-testid":`job-trigger-${e.id}`,className:"w-full md:justify-self-start",children:[h?c.jsx(Vt,{className:"h-4 w-4 mr-1 animate-spin"}):c.jsx(DS,{className:"h-4 w-4 mr-1"}),"Run Now"]}),c.jsxs(_e,{variant:"ghost",size:"sm",onClick:()=>a(e),"data-testid":`job-history-${e.id}`,className:"w-full md:w-auto",children:[c.jsx(B5,{className:"h-4 w-4 mr-1"}),c.jsx("span",{className:"md:hidden lg:inline",children:"History"})]}),c.jsx(_e,{variant:"ghost",size:"icon",onClick:()=>o(e),"aria-label":`Edit job ${e.name}`,"data-testid":`job-edit-${e.id}`,className:"h-8 w-full md:w-8",children:c.jsx(fve,{className:"h-4 w-4"})}),c.jsx(_e,{variant:"ghost",size:"icon",onClick:()=>s(e.id),className:"h-8 w-full text-destructive hover:bg-destructive/10 hover:text-destructive md:w-8","aria-label":`Delete job ${e.name}`,"data-testid":`job-delete-${e.id}`,children:c.jsx(Tl,{className:"h-4 w-4"})})]})]})]})}function ZW(e,[r,n]){return Math.min(n,Math.max(r,e))}function crt(e,r=[]){let n=[];function i(o,a){const l=y.createContext(a),u=n.length;n=[...n,a];const d=f=>{var S;const{scope:g,children:v,...b}=f,_=((S=g==null?void 0:g[e])==null?void 0:S[u])||l,w=y.useMemo(()=>b,Object.values(b));return c.jsx(_.Provider,{value:w,children:v})};d.displayName=o+"Provider";function h(f,g){var _;const v=((_=g==null?void 0:g[e])==null?void 0:_[u])||l,b=y.useContext(v);if(b)return b;if(a!==void 0)return a;throw new Error(`\`${f}\` must be used within \`${o}\``)}return[d,h]}const s=()=>{const o=n.map(a=>y.createContext(a));return function(l){const u=(l==null?void 0:l[e])||o;return y.useMemo(()=>({[`__scope${e}`]:{...l,[e]:u}}),[l,u])}};return s.scopeName=e,[i,urt(s,...r)]}function urt(...e){const r=e[0];if(e.length===1)return r;const n=()=>{const i=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(o){const a=i.reduce((l,{useScope:u,scopeName:d})=>{const f=u(o)[`__scope${d}`];return{...l,...f}},{});return y.useMemo(()=>({[`__scope${r.scopeName}`]:a}),[a])}};return n.scopeName=r.scopeName,n}function Cle(e){const r=drt(e),n=y.forwardRef((i,s)=>{const{children:o,...a}=i,l=y.Children.toArray(o),u=l.find(frt);if(u){const d=u.props.children,h=l.map(f=>f===u?y.Children.count(d)>1?y.Children.only(null):y.isValidElement(d)?d.props.children:null:f);return c.jsx(r,{...a,ref:s,children:y.isValidElement(d)?y.cloneElement(d,void 0,h):null})}return c.jsx(r,{...a,ref:s,children:o})});return n.displayName=`${e}.Slot`,n}function drt(e){const r=y.forwardRef((n,i)=>{const{children:s,...o}=n;if(y.isValidElement(s)){const a=mrt(s),l=prt(o,s.props);return s.type!==y.Fragment&&(l.ref=i?ho(i,a):a),y.cloneElement(s,l)}return y.Children.count(s)>1?y.Children.only(null):null});return r.displayName=`${e}.SlotClone`,r}var hrt=Symbol("radix.slottable");function frt(e){return y.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===hrt}function prt(e,r){const n={...r};for(const i in r){const s=e[i],o=r[i];/^on[A-Z]/.test(i)?s&&o?n[i]=(...l)=>{const u=o(...l);return s(...l),u}:s&&(n[i]=s):i==="style"?n[i]={...s,...o}:i==="className"&&(n[i]=[s,o].filter(Boolean).join(" "))}return{...e,...n}}function mrt(e){var i,s;let r=(i=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:i.get,n=r&&"isReactWarning"in r&&r.isReactWarning;return n?e.ref:(r=(s=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:s.get,n=r&&"isReactWarning"in r&&r.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var grt=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],uu=grt.reduce((e,r)=>{const n=Cle(`Primitive.${r}`),i=y.forwardRef((s,o)=>{const{asChild:a,...l}=s,u=a?n:r;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(u,{...l,ref:o})});return i.displayName=`Primitive.${r}`,{...e,[r]:i}},{});function yrt(e){const r=vrt(e),n=y.forwardRef((i,s)=>{const{children:o,...a}=i,l=y.Children.toArray(o),u=l.find(brt);if(u){const d=u.props.children,h=l.map(f=>f===u?y.Children.count(d)>1?y.Children.only(null):y.isValidElement(d)?d.props.children:null:f);return c.jsx(r,{...a,ref:s,children:y.isValidElement(d)?y.cloneElement(d,void 0,h):null})}return c.jsx(r,{...a,ref:s,children:o})});return n.displayName=`${e}.Slot`,n}function vrt(e){const r=y.forwardRef((n,i)=>{const{children:s,...o}=n;if(y.isValidElement(s)){const a=wrt(s),l=_rt(o,s.props);return s.type!==y.Fragment&&(l.ref=i?ho(i,a):a),y.cloneElement(s,l)}return y.Children.count(s)>1?y.Children.only(null):null});return r.displayName=`${e}.SlotClone`,r}var xrt=Symbol("radix.slottable");function brt(e){return y.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===xrt}function _rt(e,r){const n={...r};for(const i in r){const s=e[i],o=r[i];/^on[A-Z]/.test(i)?s&&o?n[i]=(...l)=>{const u=o(...l);return s(...l),u}:s&&(n[i]=s):i==="style"?n[i]={...s,...o}:i==="className"&&(n[i]=[s,o].filter(Boolean).join(" "))}return{...e,...n}}function wrt(e){var i,s;let r=(i=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:i.get,n=r&&"isReactWarning"in r&&r.isReactWarning;return n?e.ref:(r=(s=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:s.get,n=r&&"isReactWarning"in r&&r.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Srt=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],krt=Srt.reduce((e,r)=>{const n=yrt(`Primitive.${r}`),i=y.forwardRef((s,o)=>{const{asChild:a,...l}=s,u=a?n:r;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(u,{...l,ref:o})});return i.displayName=`Primitive.${r}`,{...e,[r]:i}},{}),jle=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),Crt="VisuallyHidden",jrt=y.forwardRef((e,r)=>c.jsx(krt.span,{...e,ref:r,style:{...jle,...e.style}}));jrt.displayName=Crt;var Nrt=[" ","Enter","ArrowUp","ArrowDown"],Trt=[" ","Enter"],cy="Select",[JN,ZN,Ert]=SR(cy),[ux]=crt(cy,[Ert,Jv]),QN=Jv(),[Art,Ng]=ux(cy),[Ort,Mrt]=ux(cy),Nle=e=>{const{__scopeSelect:r,children:n,open:i,defaultOpen:s,onOpenChange:o,value:a,defaultValue:l,onValueChange:u,dir:d,name:h,autoComplete:f,disabled:g,required:v,form:b}=e,_=QN(r),[w,S]=y.useState(null),[C,j]=y.useState(null),[E,A]=y.useState(!1),N=z4(d),[P,H]=wp({prop:i,defaultProp:s??!1,onChange:o,caller:cy}),[K,F]=wp({prop:a,defaultProp:l,onChange:u,caller:cy}),B=y.useRef(null),W=w?b||!!w.closest("form"):!0,[D,O]=y.useState(new Set),I=Array.from(D).map(R=>R.props.value).join(";");return c.jsx(MR,{..._,children:c.jsxs(Art,{required:v,scope:r,trigger:w,onTriggerChange:S,valueNode:C,onValueNodeChange:j,valueNodeHasChildren:E,onValueNodeHasChildrenChange:A,contentId:Xu(),value:K,onValueChange:F,open:P,onOpenChange:H,dir:N,triggerPointerDownPosRef:B,disabled:g,children:[c.jsx(JN.Provider,{scope:r,children:c.jsx(Ort,{scope:e.__scopeSelect,onNativeOptionAdd:y.useCallback(R=>{O($=>new Set($).add(R))},[]),onNativeOptionRemove:y.useCallback(R=>{O($=>{const U=new Set($);return U.delete(R),U})},[]),children:n})}),W?c.jsxs(Jle,{"aria-hidden":!0,required:v,tabIndex:-1,name:h,autoComplete:f,value:K,onChange:R=>F(R.target.value),disabled:g,form:b,children:[K===void 0?c.jsx("option",{value:""}):null,Array.from(D)]},I):null]})})};Nle.displayName=cy;var Tle="SelectTrigger",Ele=y.forwardRef((e,r)=>{const{__scopeSelect:n,disabled:i=!1,...s}=e,o=QN(n),a=Ng(Tle,n),l=a.disabled||i,u=li(r,a.onTriggerChange),d=ZN(n),h=y.useRef("touch"),[f,g,v]=Qle(_=>{const w=d().filter(j=>!j.disabled),S=w.find(j=>j.value===a.value),C=ece(w,_,S);C!==void 0&&a.onValueChange(C.value)}),b=_=>{l||(a.onOpenChange(!0),v()),_&&(a.triggerPointerDownPosRef.current={x:Math.round(_.pageX),y:Math.round(_.pageY)})};return c.jsx(V4,{asChild:!0,...o,children:c.jsx(uu.button,{type:"button",role:"combobox","aria-controls":a.contentId,"aria-expanded":a.open,"aria-required":a.required,"aria-autocomplete":"none",dir:a.dir,"data-state":a.open?"open":"closed",disabled:l,"data-disabled":l?"":void 0,"data-placeholder":Zle(a.value)?"":void 0,...s,ref:u,onClick:kr(s.onClick,_=>{_.currentTarget.focus(),h.current!=="mouse"&&b(_)}),onPointerDown:kr(s.onPointerDown,_=>{h.current=_.pointerType;const w=_.target;w.hasPointerCapture(_.pointerId)&&w.releasePointerCapture(_.pointerId),_.button===0&&_.ctrlKey===!1&&_.pointerType==="mouse"&&(b(_),_.preventDefault())}),onKeyDown:kr(s.onKeyDown,_=>{const w=f.current!=="";!(_.ctrlKey||_.altKey||_.metaKey)&&_.key.length===1&&g(_.key),!(w&&_.key===" ")&&Nrt.includes(_.key)&&(b(),_.preventDefault())})})})});Ele.displayName=Tle;var Ale="SelectValue",Ole=y.forwardRef((e,r)=>{const{__scopeSelect:n,className:i,style:s,children:o,placeholder:a="",...l}=e,u=Ng(Ale,n),{onValueNodeHasChildrenChange:d}=u,h=o!==void 0,f=li(r,u.onValueNodeChange);return co(()=>{d(h)},[d,h]),c.jsx(uu.span,{...l,ref:f,style:{pointerEvents:"none"},children:Zle(u.value)?c.jsx(c.Fragment,{children:a}):o})});Ole.displayName=Ale;var Rrt="SelectIcon",Mle=y.forwardRef((e,r)=>{const{__scopeSelect:n,children:i,...s}=e;return c.jsx(uu.span,{"aria-hidden":!0,...s,ref:r,children:i||"▼"})});Mle.displayName=Rrt;var Prt="SelectPortal",Rle=e=>c.jsx(PS,{asChild:!0,...e});Rle.displayName=Prt;var uy="SelectContent",Ple=y.forwardRef((e,r)=>{const n=Ng(uy,e.__scopeSelect),[i,s]=y.useState();if(co(()=>{s(new DocumentFragment)},[]),!n.open){const o=i;return o?gy.createPortal(c.jsx(Lle,{scope:e.__scopeSelect,children:c.jsx(JN.Slot,{scope:e.__scopeSelect,children:c.jsx("div",{children:e.children})})}),o):null}return c.jsx($le,{...e,ref:r})});Ple.displayName=uy;var Ld=10,[Lle,Tg]=ux(uy),Lrt="SelectContentImpl",$rt=Cle("SelectContent.RemoveScroll"),$le=y.forwardRef((e,r)=>{const{__scopeSelect:n,position:i="item-aligned",onCloseAutoFocus:s,onEscapeKeyDown:o,onPointerDownOutside:a,side:l,sideOffset:u,align:d,alignOffset:h,arrowPadding:f,collisionBoundary:g,collisionPadding:v,sticky:b,hideWhenDetached:_,avoidCollisions:w,...S}=e,C=Ng(uy,n),[j,E]=y.useState(null),[A,N]=y.useState(null),P=li(r,ae=>E(ae)),[H,K]=y.useState(null),[F,B]=y.useState(null),W=ZN(n),[D,O]=y.useState(!1),I=y.useRef(!1);y.useEffect(()=>{if(j)return L4(j)},[j]),R4();const R=y.useCallback(ae=>{const[te,...ue]=W().map(pe=>pe.ref.current),[he]=ue.slice(-1),we=document.activeElement;for(const pe of ae)if(pe===we||(pe==null||pe.scrollIntoView({block:"nearest"}),pe===te&&A&&(A.scrollTop=0),pe===he&&A&&(A.scrollTop=A.scrollHeight),pe==null||pe.focus(),document.activeElement!==we))return},[W,A]),$=y.useCallback(()=>R([H,j]),[R,H,j]);y.useEffect(()=>{D&&$()},[D,$]);const{onOpenChange:U,triggerPointerDownPosRef:Y}=C;y.useEffect(()=>{if(j){let ae={x:0,y:0};const te=he=>{var we,pe;ae={x:Math.abs(Math.round(he.pageX)-(((we=Y.current)==null?void 0:we.x)??0)),y:Math.abs(Math.round(he.pageY)-(((pe=Y.current)==null?void 0:pe.y)??0))}},ue=he=>{ae.x<=10&&ae.y<=10?he.preventDefault():j.contains(he.target)||U(!1),document.removeEventListener("pointermove",te),Y.current=null};return Y.current!==null&&(document.addEventListener("pointermove",te),document.addEventListener("pointerup",ue,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",te),document.removeEventListener("pointerup",ue,{capture:!0})}}},[j,U,Y]),y.useEffect(()=>{const ae=()=>U(!1);return window.addEventListener("blur",ae),window.addEventListener("resize",ae),()=>{window.removeEventListener("blur",ae),window.removeEventListener("resize",ae)}},[U]);const[z,V]=Qle(ae=>{const te=W().filter(we=>!we.disabled),ue=te.find(we=>we.ref.current===document.activeElement),he=ece(te,ae,ue);he&&setTimeout(()=>he.ref.current.focus())}),Q=y.useCallback((ae,te,ue)=>{const he=!I.current&&!ue;(C.value!==void 0&&C.value===te||he)&&(K(ae),he&&(I.current=!0))},[C.value]),q=y.useCallback(()=>j==null?void 0:j.focus(),[j]),re=y.useCallback((ae,te,ue)=>{const he=!I.current&&!ue;(C.value!==void 0&&C.value===te||he)&&B(ae)},[C.value]),ee=i==="popper"?b7:Dle,ne=ee===b7?{side:l,sideOffset:u,align:d,alignOffset:h,arrowPadding:f,collisionBoundary:g,collisionPadding:v,sticky:b,hideWhenDetached:_,avoidCollisions:w}:{};return c.jsx(Lle,{scope:n,content:j,viewport:A,onViewportChange:N,itemRefCallback:Q,selectedItem:H,onItemLeave:q,itemTextRefCallback:re,focusSelectedItem:$,selectedItemText:F,position:i,isPositioned:D,searchRef:z,children:c.jsx($S,{as:$rt,allowPinchZoom:!0,children:c.jsx(RS,{asChild:!0,trapped:C.open,onMountAutoFocus:ae=>{ae.preventDefault()},onUnmountAutoFocus:kr(s,ae=>{var te;(te=C.trigger)==null||te.focus({preventScroll:!0}),ae.preventDefault()}),children:c.jsx(MS,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:a,onFocusOutside:ae=>ae.preventDefault(),onDismiss:()=>C.onOpenChange(!1),children:c.jsx(ee,{role:"listbox",id:C.contentId,"data-state":C.open?"open":"closed",dir:C.dir,onContextMenu:ae=>ae.preventDefault(),...S,...ne,onPlaced:()=>O(!0),ref:P,style:{display:"flex",flexDirection:"column",outline:"none",...S.style},onKeyDown:kr(S.onKeyDown,ae=>{const te=ae.ctrlKey||ae.altKey||ae.metaKey;if(ae.key==="Tab"&&ae.preventDefault(),!te&&ae.key.length===1&&V(ae.key),["ArrowUp","ArrowDown","Home","End"].includes(ae.key)){let he=W().filter(we=>!we.disabled).map(we=>we.ref.current);if(["ArrowUp","End"].includes(ae.key)&&(he=he.slice().reverse()),["ArrowUp","ArrowDown"].includes(ae.key)){const we=ae.target,pe=he.indexOf(we);he=he.slice(pe+1)}setTimeout(()=>R(he)),ae.preventDefault()}})})})})})})});$le.displayName=Lrt;var Drt="SelectItemAlignedPosition",Dle=y.forwardRef((e,r)=>{const{__scopeSelect:n,onPlaced:i,...s}=e,o=Ng(uy,n),a=Tg(uy,n),[l,u]=y.useState(null),[d,h]=y.useState(null),f=li(r,P=>h(P)),g=ZN(n),v=y.useRef(!1),b=y.useRef(!0),{viewport:_,selectedItem:w,selectedItemText:S,focusSelectedItem:C}=a,j=y.useCallback(()=>{if(o.trigger&&o.valueNode&&l&&d&&_&&w&&S){const P=o.trigger.getBoundingClientRect(),H=d.getBoundingClientRect(),K=o.valueNode.getBoundingClientRect(),F=S.getBoundingClientRect();if(o.dir!=="rtl"){const we=F.left-H.left,pe=K.left-we,qe=P.left-pe,se=P.width+qe,it=Math.max(se,H.width),Ye=window.innerWidth-Ld,ht=ZW(pe,[Ld,Math.max(Ld,Ye-it)]);l.style.minWidth=se+"px",l.style.left=ht+"px"}else{const we=H.right-F.right,pe=window.innerWidth-K.right-we,qe=window.innerWidth-P.right-pe,se=P.width+qe,it=Math.max(se,H.width),Ye=window.innerWidth-Ld,ht=ZW(pe,[Ld,Math.max(Ld,Ye-it)]);l.style.minWidth=se+"px",l.style.right=ht+"px"}const B=g(),W=window.innerHeight-Ld*2,D=_.scrollHeight,O=window.getComputedStyle(d),I=parseInt(O.borderTopWidth,10),R=parseInt(O.paddingTop,10),$=parseInt(O.borderBottomWidth,10),U=parseInt(O.paddingBottom,10),Y=I+R+D+U+$,z=Math.min(w.offsetHeight*5,Y),V=window.getComputedStyle(_),Q=parseInt(V.paddingTop,10),q=parseInt(V.paddingBottom,10),re=P.top+P.height/2-Ld,ee=W-re,ne=w.offsetHeight/2,ae=w.offsetTop+ne,te=I+R+ae,ue=Y-te;if(te<=re){const we=B.length>0&&w===B[B.length-1].ref.current;l.style.bottom="0px";const pe=d.clientHeight-_.offsetTop-_.offsetHeight,qe=Math.max(ee,ne+(we?q:0)+pe+$),se=te+qe;l.style.height=se+"px"}else{const we=B.length>0&&w===B[0].ref.current;l.style.top="0px";const qe=Math.max(re,I+_.offsetTop+(we?Q:0)+ne)+ue;l.style.height=qe+"px",_.scrollTop=te-re+_.offsetTop}l.style.margin=`${Ld}px 0`,l.style.minHeight=z+"px",l.style.maxHeight=W+"px",i==null||i(),requestAnimationFrame(()=>v.current=!0)}},[g,o.trigger,o.valueNode,l,d,_,w,S,o.dir,i]);co(()=>j(),[j]);const[E,A]=y.useState();co(()=>{d&&A(window.getComputedStyle(d).zIndex)},[d]);const N=y.useCallback(P=>{P&&b.current===!0&&(j(),C==null||C(),b.current=!1)},[j,C]);return c.jsx(Brt,{scope:n,contentWrapper:l,shouldExpandOnScrollRef:v,onScrollButtonChange:N,children:c.jsx("div",{ref:u,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:E},children:c.jsx(uu.div,{...s,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...s.style}})})})});Dle.displayName=Drt;var Irt="SelectPopperPosition",b7=y.forwardRef((e,r)=>{const{__scopeSelect:n,align:i="start",collisionPadding:s=Ld,...o}=e,a=QN(n);return c.jsx(RR,{...a,...o,ref:r,align:i,collisionPadding:s,style:{boxSizing:"border-box",...o.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});b7.displayName=Irt;var[Brt,eL]=ux(uy,{}),_7="SelectViewport",Ile=y.forwardRef((e,r)=>{const{__scopeSelect:n,nonce:i,...s}=e,o=Tg(_7,n),a=eL(_7,n),l=li(r,o.onViewportChange),u=y.useRef(0);return c.jsxs(c.Fragment,{children:[c.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:i}),c.jsx(JN.Slot,{scope:n,children:c.jsx(uu.div,{"data-radix-select-viewport":"",role:"presentation",...s,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...s.style},onScroll:kr(s.onScroll,d=>{const h=d.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:g}=a;if(g!=null&&g.current&&f){const v=Math.abs(u.current-h.scrollTop);if(v>0){const b=window.innerHeight-Ld*2,_=parseFloat(f.style.minHeight),w=parseFloat(f.style.height),S=Math.max(_,w);if(S<b){const C=S+v,j=Math.min(b,C),E=C-j;f.style.height=j+"px",f.style.bottom==="0px"&&(h.scrollTop=E>0?E:0,f.style.justifyContent="flex-end")}}}u.current=h.scrollTop})})})]})});Ile.displayName=_7;var Ble="SelectGroup",[zrt,Frt]=ux(Ble),Hrt=y.forwardRef((e,r)=>{const{__scopeSelect:n,...i}=e,s=Xu();return c.jsx(zrt,{scope:n,id:s,children:c.jsx(uu.div,{role:"group","aria-labelledby":s,...i,ref:r})})});Hrt.displayName=Ble;var zle="SelectLabel",Fle=y.forwardRef((e,r)=>{const{__scopeSelect:n,...i}=e,s=Frt(zle,n);return c.jsx(uu.div,{id:s.id,...i,ref:r})});Fle.displayName=zle;var r4="SelectItem",[Wrt,Hle]=ux(r4),Wle=y.forwardRef((e,r)=>{const{__scopeSelect:n,value:i,disabled:s=!1,textValue:o,...a}=e,l=Ng(r4,n),u=Tg(r4,n),d=l.value===i,[h,f]=y.useState(o??""),[g,v]=y.useState(!1),b=li(r,C=>{var j;return(j=u.itemRefCallback)==null?void 0:j.call(u,C,i,s)}),_=Xu(),w=y.useRef("touch"),S=()=>{s||(l.onValueChange(i),l.onOpenChange(!1))};if(i==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return c.jsx(Wrt,{scope:n,value:i,disabled:s,textId:_,isSelected:d,onItemTextChange:y.useCallback(C=>{f(j=>j||((C==null?void 0:C.textContent)??"").trim())},[]),children:c.jsx(JN.ItemSlot,{scope:n,value:i,disabled:s,textValue:h,children:c.jsx(uu.div,{role:"option","aria-labelledby":_,"data-highlighted":g?"":void 0,"aria-selected":d&&g,"data-state":d?"checked":"unchecked","aria-disabled":s||void 0,"data-disabled":s?"":void 0,tabIndex:s?void 0:-1,...a,ref:b,onFocus:kr(a.onFocus,()=>v(!0)),onBlur:kr(a.onBlur,()=>v(!1)),onClick:kr(a.onClick,()=>{w.current!=="mouse"&&S()}),onPointerUp:kr(a.onPointerUp,()=>{w.current==="mouse"&&S()}),onPointerDown:kr(a.onPointerDown,C=>{w.current=C.pointerType}),onPointerMove:kr(a.onPointerMove,C=>{var j;w.current=C.pointerType,s?(j=u.onItemLeave)==null||j.call(u):w.current==="mouse"&&C.currentTarget.focus({preventScroll:!0})}),onPointerLeave:kr(a.onPointerLeave,C=>{var j;C.currentTarget===document.activeElement&&((j=u.onItemLeave)==null||j.call(u))}),onKeyDown:kr(a.onKeyDown,C=>{var E;((E=u.searchRef)==null?void 0:E.current)!==""&&C.key===" "||(Trt.includes(C.key)&&S(),C.key===" "&&C.preventDefault())})})})})});Wle.displayName=r4;var I_="SelectItemText",Ule=y.forwardRef((e,r)=>{const{__scopeSelect:n,className:i,style:s,...o}=e,a=Ng(I_,n),l=Tg(I_,n),u=Hle(I_,n),d=Mrt(I_,n),[h,f]=y.useState(null),g=li(r,S=>f(S),u.onItemTextChange,S=>{var C;return(C=l.itemTextRefCallback)==null?void 0:C.call(l,S,u.value,u.disabled)}),v=h==null?void 0:h.textContent,b=y.useMemo(()=>c.jsx("option",{value:u.value,disabled:u.disabled,children:v},u.value),[u.disabled,u.value,v]),{onNativeOptionAdd:_,onNativeOptionRemove:w}=d;return co(()=>(_(b),()=>w(b)),[_,w,b]),c.jsxs(c.Fragment,{children:[c.jsx(uu.span,{id:u.textId,...o,ref:g}),u.isSelected&&a.valueNode&&!a.valueNodeHasChildren?gy.createPortal(o.children,a.valueNode):null]})});Ule.displayName=I_;var Vle="SelectItemIndicator",qle=y.forwardRef((e,r)=>{const{__scopeSelect:n,...i}=e;return Hle(Vle,n).isSelected?c.jsx(uu.span,{"aria-hidden":!0,...i,ref:r}):null});qle.displayName=Vle;var w7="SelectScrollUpButton",Gle=y.forwardRef((e,r)=>{const n=Tg(w7,e.__scopeSelect),i=eL(w7,e.__scopeSelect),[s,o]=y.useState(!1),a=li(r,i.onScrollButtonChange);return co(()=>{if(n.viewport&&n.isPositioned){let l=function(){const d=u.scrollTop>0;o(d)};const u=n.viewport;return l(),u.addEventListener("scroll",l),()=>u.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),s?c.jsx(Yle,{...e,ref:a,onAutoScroll:()=>{const{viewport:l,selectedItem:u}=n;l&&u&&(l.scrollTop=l.scrollTop-u.offsetHeight)}}):null});Gle.displayName=w7;var S7="SelectScrollDownButton",Kle=y.forwardRef((e,r)=>{const n=Tg(S7,e.__scopeSelect),i=eL(S7,e.__scopeSelect),[s,o]=y.useState(!1),a=li(r,i.onScrollButtonChange);return co(()=>{if(n.viewport&&n.isPositioned){let l=function(){const d=u.scrollHeight-u.clientHeight,h=Math.ceil(u.scrollTop)<d;o(h)};const u=n.viewport;return l(),u.addEventListener("scroll",l),()=>u.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),s?c.jsx(Yle,{...e,ref:a,onAutoScroll:()=>{const{viewport:l,selectedItem:u}=n;l&&u&&(l.scrollTop=l.scrollTop+u.offsetHeight)}}):null});Kle.displayName=S7;var Yle=y.forwardRef((e,r)=>{const{__scopeSelect:n,onAutoScroll:i,...s}=e,o=Tg("SelectScrollButton",n),a=y.useRef(null),l=ZN(n),u=y.useCallback(()=>{a.current!==null&&(window.clearInterval(a.current),a.current=null)},[]);return y.useEffect(()=>()=>u(),[u]),co(()=>{var h;const d=l().find(f=>f.ref.current===document.activeElement);(h=d==null?void 0:d.ref.current)==null||h.scrollIntoView({block:"nearest"})},[l]),c.jsx(uu.div,{"aria-hidden":!0,...s,ref:r,style:{flexShrink:0,...s.style},onPointerDown:kr(s.onPointerDown,()=>{a.current===null&&(a.current=window.setInterval(i,50))}),onPointerMove:kr(s.onPointerMove,()=>{var d;(d=o.onItemLeave)==null||d.call(o),a.current===null&&(a.current=window.setInterval(i,50))}),onPointerLeave:kr(s.onPointerLeave,()=>{u()})})}),Urt="SelectSeparator",Xle=y.forwardRef((e,r)=>{const{__scopeSelect:n,...i}=e;return c.jsx(uu.div,{"aria-hidden":!0,...i,ref:r})});Xle.displayName=Urt;var k7="SelectArrow",Vrt=y.forwardRef((e,r)=>{const{__scopeSelect:n,...i}=e,s=QN(n),o=Ng(k7,n),a=Tg(k7,n);return o.open&&a.position==="popper"?c.jsx(PR,{...s,...i,ref:r}):null});Vrt.displayName=k7;var qrt="SelectBubbleInput",Jle=y.forwardRef(({__scopeSelect:e,value:r,...n},i)=>{const s=y.useRef(null),o=li(i,s),a=mle(r);return y.useEffect(()=>{const l=s.current;if(!l)return;const u=window.HTMLSelectElement.prototype,h=Object.getOwnPropertyDescriptor(u,"value").set;if(a!==r&&h){const f=new Event("change",{bubbles:!0});h.call(l,r),l.dispatchEvent(f)}},[a,r]),c.jsx(uu.select,{...n,style:{...jle,...n.style},ref:o,defaultValue:r})});Jle.displayName=qrt;function Zle(e){return e===""||e===void 0}function Qle(e){const r=ih(e),n=y.useRef(""),i=y.useRef(0),s=y.useCallback(a=>{const l=n.current+a;r(l),(function u(d){n.current=d,window.clearTimeout(i.current),d!==""&&(i.current=window.setTimeout(()=>u(""),1e3))})(l)},[r]),o=y.useCallback(()=>{n.current="",window.clearTimeout(i.current)},[]);return y.useEffect(()=>()=>window.clearTimeout(i.current),[]),[n,s,o]}function ece(e,r,n){const s=r.length>1&&Array.from(r).every(d=>d===r[0])?r[0]:r,o=n?e.indexOf(n):-1;let a=Grt(e,Math.max(o,0));s.length===1&&(a=a.filter(d=>d!==n));const u=a.find(d=>d.textValue.toLowerCase().startsWith(s.toLowerCase()));return u!==n?u:void 0}function Grt(e,r){return e.map((n,i)=>e[(r+i)%e.length])}var Krt=Nle,tce=Ele,Yrt=Ole,Xrt=Mle,Jrt=Rle,rce=Ple,Zrt=Ile,nce=Fle,ice=Wle,Qrt=Ule,ent=qle,sce=Gle,oce=Kle,ace=Xle;const th=Krt,rh=Yrt,Zu=y.forwardRef(({className:e,children:r,...n},i)=>c.jsxs(tce,{ref:i,className:Ae("flex h-10 w-full items-center justify-between whitespace-nowrap rounded-lg border border-input bg-background/90 px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring/60 focus:ring-offset-2 focus:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[r,c.jsx(Xrt,{asChild:!0,children:c.jsx(Ml,{className:"h-4 w-4 opacity-50"})})]}));Zu.displayName=tce.displayName;const lce=y.forwardRef(({className:e,...r},n)=>c.jsx(sce,{ref:n,className:Ae("flex cursor-default items-center justify-center py-1",e),...r,children:c.jsx(pR,{className:"h-4 w-4"})}));lce.displayName=sce.displayName;const cce=y.forwardRef(({className:e,...r},n)=>c.jsx(oce,{ref:n,className:Ae("flex cursor-default items-center justify-center py-1",e),...r,children:c.jsx(Ml,{className:"h-4 w-4"})}));cce.displayName=oce.displayName;const Qu=y.forwardRef(({className:e,children:r,position:n="popper",...i},s)=>c.jsx(Jrt,{children:c.jsxs(rce,{ref:s,className:Ae("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-xl border border-border/70 bg-popover text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...i,children:[c.jsx(lce,{}),c.jsx(Zrt,{className:Ae("p-1",n==="popper"&&"w-full min-w-[var(--radix-select-trigger-width)]"),children:r}),c.jsx(cce,{})]})}));Qu.displayName=rce.displayName;const tnt=y.forwardRef(({className:e,...r},n)=>c.jsx(nce,{ref:n,className:Ae("px-2 py-1.5 text-sm font-semibold",e),...r}));tnt.displayName=nce.displayName;const Ls=y.forwardRef(({className:e,children:r,...n},i)=>c.jsxs(ice,{ref:i,className:Ae("relative flex w-full cursor-default select-none items-center rounded-md py-2 pl-2.5 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[c.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(ent,{children:c.jsx(fs,{className:"h-4 w-4"})})}),c.jsx(Qrt,{children:r})]}));Ls.displayName=ice.displayName;const rnt=y.forwardRef(({className:e,...r},n)=>c.jsx(ace,{ref:n,className:Ae("-mx-1 my-1 h-px bg-muted",e),...r}));rnt.displayName=ace.displayName;const Nm=Kn();class tL{getToken(){return Gm()}getHeaders(r=!1){const n={};r&&(n["Content-Type"]="application/json");const i=this.getToken();return i&&(n.Authorization=`Bearer ${i}`),n}async listJobsPage(r=1,n=20,i=!0){const s=new URLSearchParams({page:r.toString(),size:n.toString(),include_disabled:i.toString()}),o=await fetch(`${Nm}/api/jobs?${s}`,{headers:this.getHeaders()});if(!o.ok)throw new Error(`Failed to list jobs: ${o.statusText}`);const a=await o.json();if(Array.isArray(a))return{items:a,total:a.length,page:1,size:a.length};const l=a&&typeof a=="object"?a:{},u=Array.isArray(l.items)?l.items:[],d=typeof l.total=="number"?l.total:u.length,h=typeof l.page=="number"?l.page:r,f=typeof l.size=="number"?l.size:n;return{items:u,total:d,page:h,size:f}}async listJobs(r=1,n=100,i=!0){return(await this.listJobsPage(r,n,i)).items}async getJob(r){const n=await fetch(`${Nm}/api/jobs/${r}`,{headers:this.getHeaders()});if(!n.ok)throw new Error(`Failed to get job: ${n.statusText}`);return n.json()}async createJob(r){const n=await fetch(`${Nm}/api/jobs`,{method:"POST",headers:this.getHeaders(!0),body:JSON.stringify(r)});if(!n.ok){const i=await n.json().catch(()=>({detail:n.statusText}));throw new Error(i.detail||"Failed to create job")}return n.json()}async updateJob(r,n){const i=await fetch(`${Nm}/api/jobs/${r}`,{method:"PATCH",headers:this.getHeaders(!0),body:JSON.stringify(n)});if(!i.ok){const s=await i.json().catch(()=>({detail:i.statusText}));throw new Error(s.detail||"Failed to update job")}return i.json()}async deleteJob(r){const n=await fetch(`${Nm}/api/jobs/${r}`,{method:"DELETE",headers:this.getHeaders()});if(!n.ok)throw new Error(`Failed to delete job: ${n.statusText}`)}async triggerJob(r){const n=await fetch(`${Nm}/api/jobs/${r}/trigger`,{method:"POST",headers:this.getHeaders(!0),body:JSON.stringify({})});if(!n.ok){const i=await n.json().catch(()=>({detail:n.statusText}));throw new Error(i.detail||`Failed to trigger job: ${n.statusText}`)}return n.json()}async getJobRuns(r,n=20,i=1){const s=new URLSearchParams({page:i.toString(),size:n.toString()}),o=await fetch(`${Nm}/api/jobs/${r}/runs?${s}`,{headers:this.getHeaders()});if(!o.ok)throw new Error(`Failed to get job runs: ${o.statusText}`);const a=await o.json();return Array.isArray(a)?a:a.items??[]}async getAvailableProviders(){const r=await fetch(`${Nm}/api/jobs/providers/available`,{headers:this.getHeaders()});if(!r.ok)throw new Error(`Failed to get providers: ${r.statusText}`);const n=await r.json();return n.providers&&!Array.isArray(n.providers)?n.providers:n}}const x3=new tL;function nnt({isOpen:e,onClose:r,onCreated:n,editJob:i,onUpdated:s}){const[o,a]=y.useState(!1),[l,u]=y.useState(null),[d,h]=y.useState({}),[f,g]=y.useState(""),[v,b]=y.useState("agent_task"),[_,w]=y.useState("0 * * * *"),[S,C]=y.useState(""),[j,E]=y.useState(!1),[A,N]=y.useState(!0),[P,H]=y.useState(""),[K,F]=y.useState(""),[B,W]=y.useState(""),[D,O]=y.useState(""),[I,R]=y.useState("");y.useEffect(()=>{x3.getAvailableProviders().then(h).catch(console.error)},[]);const $=V=>{if(g(V.name),b(V.job_type),w(V.cron_expression),N(V.enabled),H(V.provider||""),F(V.model||""),W(V.prompt||""),V.job_type==="system_job"){const re=V.payload&&typeof V.payload=="object"?V.payload:void 0,ee=typeof(re==null?void 0:re.command)=="string"?re.command:void 0,ne=typeof V.tool_name=="string"?V.tool_name:"";O(ee||ne);const ae=re==null?void 0:re.args;if(ae&&typeof ae=="object")try{R(JSON.stringify(ae,null,2))}catch{R("")}else R("")}else R(""),O("");const Q=(V.cron_expression||"").trim(),q=x7.some(re=>re.value===Q);E(!q),C(q?"":Q)};y.useEffect(()=>{if(i){$(i);let V=!1;return x3.getJob(i.id).then(Q=>{V||$(Q)}).catch(()=>{}),()=>{V=!0}}else g(""),b("agent_task"),w("0 * * * *"),C(""),E(!1),N(!0),H(""),F(""),W(""),O(""),R("")},[i,e]);const U=j?S:_,Y=kle(U),z=async V=>{if(V.preventDefault(),u(null),!Y.valid){u(Y.error||"Invalid cron expression");return}const Q=XN(U),q={name:f,job_type:v,cron_expression:Q,enabled:A};if(v==="agent_task"){if(!P||!K||!B){u("Provider, model, and prompt are required for agent tasks");return}q.provider=P,q.model=K,q.prompt=B}else{if(!D){u("Command is required for system jobs");return}const re={command:D};if(I)try{re.args=JSON.parse(I)}catch{u("Args must be valid JSON");return}q.payload=re}a(!0);try{if(i){const re=await x3.updateJob(i.id,q);s==null||s(re)}else{const re=await x3.createJob(q);n(re)}r()}catch(re){u(re instanceof Error?re.message:"Failed to save job")}finally{a(!1)}};return e?c.jsx("div",{className:"fixed inset-0 z-50 flex items-end justify-center bg-black/50 sm:items-center",children:c.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"create-job-dialog-title","data-testid":"create-job-dialog",className:"h-[92dvh] w-full overflow-y-auto border border-border bg-background text-foreground shadow-xl sm:h-auto sm:max-h-[90vh] sm:max-w-2xl sm:rounded-lg",children:[c.jsxs("div",{className:"flex items-center justify-between border-b px-4 py-3 sm:p-4",children:[c.jsx("h2",{id:"create-job-dialog-title",className:"text-lg font-semibold sm:text-xl",children:i?"Edit Job":"Create New Job"}),c.jsx(_e,{variant:"ghost",size:"sm",onClick:r,"aria-label":"Close dialog",children:c.jsx(Vn,{className:"h-5 w-5"})})]}),c.jsxs("form",{onSubmit:z,className:"space-y-5 p-4 sm:space-y-6",children:[c.jsxs(Y0,{value:v,onValueChange:V=>b(V),children:[c.jsxs(ag,{className:"grid h-auto w-full grid-cols-2",children:[c.jsx(so,{value:"agent_task",children:"Agent Task"}),c.jsx(so,{value:"system_job",children:"System Job"})]}),c.jsxs(oo,{value:"agent_task",className:"space-y-4 mt-4",children:[c.jsxs("div",{children:[c.jsx(di,{htmlFor:"provider",children:"Provider"}),c.jsxs(th,{value:P,onValueChange:V=>{H(V),F("")},children:[c.jsx(Zu,{"data-testid":"provider-select",children:c.jsx(rh,{placeholder:"Select provider"})}),c.jsx(Qu,{children:Object.entries(d).map(([V,Q])=>c.jsx(Ls,{value:V,children:c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(hj,{provider:V,size:20}),c.jsx("span",{children:Q.name})]})},V))})]})]}),P&&d[P]&&c.jsxs("div",{children:[c.jsx(di,{htmlFor:"model",children:"Model"}),c.jsxs(th,{value:K,onValueChange:F,children:[c.jsx(Zu,{"data-testid":"model-select",children:c.jsx(rh,{placeholder:"Select model"})}),c.jsx(Qu,{children:d[P].models.map(V=>c.jsx(Ls,{value:V,children:c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(hj,{provider:P,model:V,size:20}),c.jsx("span",{children:V})]})},V))})]})]}),c.jsxs("div",{children:[c.jsx(di,{htmlFor:"prompt",children:"Prompt"}),c.jsx(jp,{id:"prompt",value:B,onChange:V=>W(V.target.value),placeholder:"What should the agent do?",rows:4})]})]}),c.jsxs(oo,{value:"system_job",className:"space-y-4 mt-4",children:[c.jsxs("div",{children:[c.jsx(di,{htmlFor:"command",children:"Command"}),c.jsx(Pn,{id:"command",value:D,onChange:V=>O(V.target.value),placeholder:"e.g., cleanup_old_files"})]}),c.jsxs("div",{children:[c.jsx(di,{htmlFor:"args",children:"Arguments (JSON)"}),c.jsx(jp,{id:"args",value:I,onChange:V=>R(V.target.value),placeholder:'{"days": 30}',rows:3})]})]})]}),c.jsxs("div",{className:"border-t pt-4 space-y-4",children:[c.jsxs("div",{children:[c.jsx(di,{htmlFor:"name",children:"Job Name"}),c.jsx(Pn,{id:"name",value:f,onChange:V=>g(V.target.value),placeholder:"My scheduled job",required:!0})]}),c.jsxs("div",{children:[c.jsxs("div",{className:"mb-2 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[c.jsx(di,{children:"Schedule"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(di,{htmlFor:"custom-schedule",className:"text-sm text-muted-foreground",children:"Custom"}),c.jsx(Ap,{id:"custom-schedule",checked:j,onCheckedChange:E})]})]}),j?c.jsxs("div",{children:[c.jsx(Pn,{value:S,onChange:V=>C(V.target.value),placeholder:"* * * * *",className:Y.valid?"":"border-red-500"}),S&&c.jsx("p",{className:`text-sm mt-1 ${Y.valid?"text-muted-foreground":"text-red-500"}`,children:Y.valid?Sle(S):Y.error})]}):c.jsxs(th,{value:_,onValueChange:w,children:[c.jsx(Zu,{"data-testid":"schedule-select",children:c.jsx(rh,{})}),c.jsx(Qu,{children:x7.map(V=>c.jsx(Ls,{value:V.value,children:c.jsxs("div",{className:"flex flex-col",children:[c.jsx("span",{children:V.label}),c.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:V.value})]})},V.value))})]})]}),c.jsxs("div",{className:"flex items-center justify-between gap-3",children:[c.jsxs("div",{children:[c.jsx(di,{htmlFor:"enabled",children:"Enabled"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Job will run according to schedule"})]}),c.jsx(Ap,{id:"enabled",checked:A,onCheckedChange:N})]})]}),l&&c.jsxs("div",{className:"flex items-center gap-2 text-destructive text-sm bg-destructive/10 p-3 rounded-md",children:[c.jsx(ia,{className:"h-4 w-4"}),l]}),c.jsxs("div",{className:"grid grid-cols-1 gap-3 border-t pt-4 sm:flex sm:justify-end",children:[c.jsx(_e,{type:"button",variant:"outline",onClick:r,className:"w-full sm:w-auto",children:"Cancel"}),c.jsxs(_e,{type:"submit",disabled:o,className:"w-full sm:w-auto",children:[o&&c.jsx(Vt,{className:"h-4 w-4 mr-2 animate-spin"}),i?"Save Changes":"Create Job"]})]})]})]})}):null}const int=new tL;function snt({job:e,isOpen:r,onClose:n}){const[i,s]=y.useState([]),[o,a]=y.useState(!1),[l,u]=y.useState(null),d=async()=>{if(e){a(!0),u(null);try{const v=await int.getJobRuns(e.id,50);s(v)}catch(v){u(v instanceof Error?v.message:"Failed to load history")}finally{a(!1)}}};if(y.useEffect(()=>{r&&e&&d()},[r,e==null?void 0:e.id]),!r||!e)return null;const h=v=>{switch(v){case"completed":return c.jsx(uo,{className:"h-4 w-4 text-green-500"});case"failed":return c.jsx(ia,{className:"h-4 w-4 text-red-500"});case"running":return c.jsx(Vt,{className:"h-4 w-4 text-blue-500 animate-spin"});case"pending":return c.jsx(xg,{className:"h-4 w-4 text-yellow-500"});default:return null}},f=v=>{const b={completed:"default",failed:"destructive",running:"secondary",pending:"outline"};return c.jsx($r,{variant:b[v]||"outline",children:v})},g=(v,b)=>{if(!b)return"—";const _=new Date(v),S=new Date(b).getTime()-_.getTime();return S<1e3?`${S}ms`:S<6e4?`${(S/1e3).toFixed(1)}s`:`${(S/6e4).toFixed(1)}m`};return c.jsx("div",{className:"fixed inset-0 z-50 flex items-end justify-center bg-black/50 sm:items-center",children:c.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"job-history-dialog-title","data-testid":"job-history-dialog",className:"flex h-[92dvh] w-full flex-col overflow-hidden border border-border bg-background text-foreground shadow-xl sm:h-auto sm:max-h-[90vh] sm:max-w-3xl sm:rounded-lg",children:[c.jsxs("div",{className:"flex items-start justify-between gap-3 border-b px-4 py-3 sm:p-4",children:[c.jsxs("div",{className:"min-w-0",children:[c.jsx("h2",{id:"job-history-dialog-title",className:"text-lg font-semibold sm:text-xl",children:"Job History"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:e.name})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(_e,{variant:"outline",size:"sm",onClick:d,disabled:o,children:c.jsx(io,{className:`h-4 w-4 ${o?"animate-spin":""}`})}),c.jsx(_e,{variant:"ghost",size:"sm",onClick:n,"aria-label":"Close history dialog",children:c.jsx(Vn,{className:"h-5 w-5"})})]})]}),c.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[l&&c.jsxs("div",{className:"flex items-center gap-2 text-destructive text-sm bg-destructive/10 p-3 rounded-md mb-4",children:[c.jsx(ia,{className:"h-4 w-4"}),l]}),o&&i.length===0?c.jsx("div",{className:"flex items-center justify-center py-12",children:c.jsx(Vt,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):i.length===0?c.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"No runs yet. This job hasn't been executed."}):c.jsx("div",{className:"space-y-3",children:i.map(v=>c.jsxs("div",{className:"border border-border rounded-lg p-4 hover:bg-muted/40 transition-colors",children:[c.jsxs("div",{className:"mb-2 flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[c.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[h(v.status),f(v.status),v.triggered_by&&c.jsxs("span",{className:"text-xs text-muted-foreground",children:["by ",v.triggered_by]})]}),c.jsxs("div",{className:"text-sm text-muted-foreground",children:["Duration: ",g(v.started_at,v.completed_at)]})]}),c.jsxs("div",{className:"mb-2 text-sm text-muted-foreground",children:[c.jsx("span",{className:"font-medium",children:"Started:"})," ",v.started_at?new Date(v.started_at).toLocaleString():"Not started",v.completed_at&&c.jsxs(c.Fragment,{children:[" → ",c.jsx("span",{className:"font-medium",children:"Completed:"})," ",new Date(v.completed_at).toLocaleString()]})]}),v.status==="completed"&&v.result&&c.jsxs("details",{className:"mt-2",children:[c.jsx("summary",{className:"text-sm text-green-600 dark:text-green-400 cursor-pointer hover:underline",children:"View result"}),c.jsx("pre",{className:"mt-2 p-2 bg-muted rounded text-xs overflow-x-auto",children:typeof v.result=="string"?v.result:JSON.stringify(v.result,null,2)})]}),v.status==="failed"&&v.error&&c.jsxs("div",{className:"mt-2 p-2 bg-destructive/10 rounded text-sm text-destructive",children:[c.jsx("strong",{children:"Error:"})," ",v.error]})]},v.id))})]})]})})}const e_=new tL,ont=20,ant=[10,20,50,100];function lnt(){const e=_g(),[r,n]=y.useState([]),[i,s]=y.useState({}),[o,a]=y.useState(0),[l,u]=y.useState(1),[d,h]=y.useState(ont),[f,g]=y.useState(!0),[v,b]=y.useState(null),[_,w]=y.useState(!1),[S,C]=y.useState(null),[j,E]=y.useState(null),A=y.useCallback(async($,U)=>{g(!0),b(null);try{const Y=await e_.listJobsPage($,U,!0);n(Y.items),a(Y.total),u(Y.page),h(Y.size);const z={};await Promise.all(Y.items.map(async V=>{try{const Q=await e_.getJobRuns(V.id,1);z[V.id]=Q[0]||null}catch{z[V.id]=null}})),s(V=>({...V,...z}))}catch(Y){b(Y instanceof Error?Y.message:"Failed to load jobs")}finally{g(!1)}},[]);y.useEffect(()=>{A(l,d)},[A,l,d]);const N=async($,U)=>{try{const Y=await e_.updateJob($,{enabled:U});n(z=>z.map(V=>V.id===$?Y:V))}catch(Y){b(Y instanceof Error?Y.message:"Failed to update job")}},P=async $=>{try{const U=await e_.triggerJob($);s(Y=>({...Y,[$]:U}))}catch(U){b(U instanceof Error?U.message:"Failed to trigger job")}},H=async $=>{if(await e({title:"Delete job",description:"Are you sure you want to delete this job?",confirmLabel:"Delete",variant:"destructive"}))try{await e_.deleteJob($);const Y=Math.max(0,o-1),z=Math.max(1,Math.ceil(Y/d)),V=Math.min(l,z);u(V),await A(V,d)}catch(Y){b(Y instanceof Error?Y.message:"Failed to delete job")}},K=$=>{u(1),A(1,d),w(!1)},F=$=>{n(U=>U.map(Y=>Y.id===$.id?$:Y)),C(null)},B=Math.max(1,Math.ceil(o/d)),W=o===0?0:(l-1)*d+1,D=Math.min(o,l*d),O=r.filter($=>$.enabled).length,I=r.filter($=>$.job_type==="agent_task").length,R=r.filter($=>$.job_type==="system_job").length;return c.jsxs("div",{className:"container mx-auto max-w-6xl px-3 py-4 sm:px-4 sm:py-6",children:[c.jsxs("div",{className:"mb-6 flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[c.jsxs("div",{className:"min-w-0",children:[c.jsxs("h1",{className:"flex items-center gap-2 text-xl font-bold sm:text-2xl",children:[c.jsx(Q_,{className:"h-6 w-6"}),"Scheduled Jobs"]}),c.jsx("p",{className:"mt-1 text-sm text-muted-foreground sm:text-base",children:"Manage your automated tasks and agent schedules"})]}),c.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[c.jsxs(_e,{variant:"outline",onClick:()=>void A(l,d),disabled:f,className:"w-full sm:w-auto",children:[c.jsx(io,{className:`h-4 w-4 mr-2 ${f?"animate-spin":""}`}),"Refresh"]}),c.jsxs(_e,{onClick:()=>w(!0),className:"w-full sm:w-auto",children:[c.jsx(qs,{className:"h-4 w-4 mr-2"}),"New Job"]})]})]}),c.jsxs("div",{className:"mb-6 grid grid-cols-2 gap-2 sm:flex sm:flex-wrap sm:items-center sm:gap-4",children:[c.jsxs($r,{variant:"outline",className:"justify-center px-3 py-1 text-xs sm:text-sm",children:[o," total"]}),c.jsxs($r,{variant:"default",className:"justify-center px-3 py-1 text-xs sm:text-sm",children:[O," enabled on page"]}),c.jsxs($r,{variant:"secondary",className:"justify-center px-3 py-1 text-xs sm:text-sm",children:[I," agent tasks on page"]}),c.jsxs($r,{variant:"secondary",className:"justify-center px-3 py-1 text-xs sm:text-sm",children:[R," system jobs on page"]})]}),v&&c.jsxs("div",{className:"flex items-center gap-2 text-destructive text-sm bg-destructive/10 p-3 rounded-md mb-4",children:[c.jsx(ia,{className:"h-4 w-4"}),v,c.jsx(_e,{variant:"ghost",size:"sm",className:"ml-auto",onClick:()=>b(null),children:"Dismiss"})]}),f&&r.length===0?c.jsx("div",{className:"flex items-center justify-center py-24",children:c.jsx(Vt,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):r.length===0?c.jsxs("div",{className:"rounded-lg border-2 border-dashed px-4 py-16 text-center sm:py-24",children:[c.jsx(Q_,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),c.jsx("h3",{className:"text-lg font-medium mb-2",children:"No scheduled jobs yet"}),c.jsx("p",{className:"text-muted-foreground mb-4",children:"Create your first job to automate tasks or schedule agent prompts"}),c.jsxs(_e,{onClick:()=>w(!0),children:[c.jsx(qs,{className:"h-4 w-4 mr-2"}),"Create Your First Job"]})]}):c.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:r.map($=>c.jsx(lrt,{job:$,recentRun:i[$.id],onToggle:N,onTrigger:P,onDelete:H,onEdit:C,onViewHistory:E},$.id))}),c.jsxs("div",{className:"mt-6 flex flex-col gap-3 border-t pt-4 sm:flex-row sm:flex-wrap sm:items-center sm:justify-between",children:[c.jsxs("div",{className:"text-sm text-muted-foreground",children:["Showing ",W,"–",D," of ",o]}),c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsx("label",{className:"text-sm text-muted-foreground",htmlFor:"jobs-page-size",children:"Per page"}),c.jsx("select",{id:"jobs-page-size",className:"h-9 rounded-md border bg-background px-2 text-sm",value:d,onChange:$=>{const U=Number.parseInt($.target.value,10);!Number.isFinite(U)||U<=0||(u(1),h(U))},children:ant.map($=>c.jsx("option",{value:$,children:$},$))}),c.jsxs("div",{className:"grid grid-cols-[1fr_auto_1fr] items-center gap-2 sm:flex sm:items-center",children:[c.jsxs(_e,{variant:"outline",size:"sm",disabled:l<=1||f,onClick:()=>u($=>Math.max(1,$-1)),className:"w-full",children:[c.jsx(wv,{className:"h-4 w-4 mr-1"}),"Prev"]}),c.jsxs("span",{className:"text-center text-sm text-muted-foreground tabular-nums",children:["Page ",l," / ",B]}),c.jsxs(_e,{variant:"outline",size:"sm",disabled:l>=B||f,onClick:()=>u($=>Math.min(B,$+1)),className:"w-full",children:["Next",c.jsx(Cs,{className:"h-4 w-4 ml-1"})]})]})]})]}),c.jsx(nnt,{isOpen:_||!!S,onClose:()=>{w(!1),C(null)},onCreated:K,editJob:S,onUpdated:F}),c.jsx(snt,{job:j,isOpen:!!j,onClose:()=>E(null)})]})}const C7="jait.todo.selected-repo.v1";function QW(e){const r=e.trim().replace(/\\/g,"/").replace(/\/+$/,"");return/^[A-Za-z]:\//.test(r)?r.toLowerCase():r}function eU(e){if(e&&typeof e=="object"&&!Array.isArray(e)){const r=e;return{repoId:typeof r.repoId=="string"&&r.repoId.trim()?r.repoId.trim():null,localPath:typeof r.localPath=="string"&&r.localPath.trim()?r.localPath.trim():null}}return typeof e=="string"?{repoId:e.trim()||null,localPath:null}:{repoId:null,localPath:null}}function cnt(e){try{return eU(JSON.parse(e))}catch{return eU(e)}}function unt(){var e;if(typeof window>"u")return{repoId:null,localPath:null};try{const r=(e=window.localStorage.getItem(C7))==null?void 0:e.trim();return r?cnt(r):{repoId:null,localPath:null}}catch{return{repoId:null,localPath:null}}}function dnt(e,r){if(!(typeof window>"u"))try{const n=(e==null?void 0:e.trim())||null;if(!n){window.localStorage.removeItem(C7);return}window.localStorage.setItem(C7,JSON.stringify({repoId:n,localPath:(r==null?void 0:r.trim())||null}))}catch{}}function hnt(e,r,n=unt()){var i;if(e.length===0)return r;if(n.repoId&&e.some(s=>s.id===n.repoId))return n.repoId;if(n.localPath){const s=QW(n.localPath),o=e.find(a=>QW(a.localPath)===s);if(o)return o.id}return r&&e.some(s=>s.id===r)?r:((i=e[0])==null?void 0:i.id)??null}function fnt(e){return`[${e}] Generating title…`}function pnt({repo:e,providerId:r,runtimeMode:n,model:i,workingDirectory:s,branch:o}){return{title:fnt(e.name),providerId:r,runtimeMode:n,...i?{model:i}:{},kind:"delivery",workingDirectory:s,branch:o,prBaseBranch:e.defaultBranch}}function mnt(e,r){return{message:r.message,titleTask:r.message,titlePrefix:`[${e}] `}}const uce="jait.todo.order.v1",dce="jait.todo.filters.v1",b3=8,f8=[{value:"open",label:"Open"},{value:"in_progress",label:"In progress"},{value:"done",label:"Done"}],t_=[{value:"low",label:"Low"},{value:"normal",label:"Normal"},{value:"high",label:"High"}];function $0(e){switch(e){case"done":return{label:"Done",iconClassName:"text-emerald-500",itemClassName:"border-emerald-500/20 bg-emerald-500/[0.04]"};case"in_progress":return{label:"In progress",iconClassName:"text-sky-500",itemClassName:"border-sky-500/20 bg-sky-500/[0.035]"};case"open":default:return{label:"Open",iconClassName:"text-muted-foreground",itemClassName:"bg-card/40"}}}function hce(e){switch(e){case"high":return"text-amber-500";case"low":return"text-muted-foreground/70";case"normal":default:return"text-primary/70"}}function B_({status:e,className:r}){const n=$0(e);return e==="done"?c.jsx(uo,{className:Ae("h-5 w-5",n.iconClassName,r)}):e==="in_progress"?c.jsx(pY,{className:Ae("h-5 w-5",n.iconClassName,r)}):c.jsx(mR,{className:Ae("h-5 w-5",n.iconClassName,r)})}function tU({priority:e,className:r}){return c.jsx(gY,{className:Ae("h-4 w-4",hce(e),r)})}function O1({label:e,children:r}){return c.jsxs(vn,{children:[c.jsx(pn,{asChild:!0,children:r}),c.jsx(mn,{children:e})]})}function fce(){if(typeof window>"u")return{};try{const e=JSON.parse(window.localStorage.getItem(uce)??"{}");return!e||typeof e!="object"||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(r=>typeof r[0]=="string"&&Array.isArray(r[1])&&r[1].every(n=>typeof n=="string")))}catch{return{}}}function rU(e,r){if(!(typeof window>"u"||!e))try{const n=fce();n[e]=r.map(i=>i.id),window.localStorage.setItem(uce,JSON.stringify(n))}catch{}}function gnt(e,r){const n=fce()[e];if(!(n!=null&&n.length))return r;const i=new Map(n.map((o,a)=>[o,a])),s=new Map(r.map((o,a)=>[o.id,a]));return[...r].sort((o,a)=>{const l=i.get(o.id),u=i.get(a.id);return l!=null&&u!=null?l-u:l!=null?-1:u!=null?1:(s.get(o.id)??0)-(s.get(a.id)??0)})}function ynt(){return{search:"",tags:[],savedTagFilters:[]}}function pce(e){return Array.isArray(e)?e.flatMap(r=>{if(!r||typeof r!="object")return[];const n=r,i=uc(Array.isArray(n.tags)?n.tags.filter(a=>typeof a=="string"):[]);if(i.length===0)return[];const s=typeof n.name=="string"&&n.name.trim()?n.name.trim():i.join(" + ");return[{id:typeof n.id=="string"&&n.id.trim()?n.id.trim():i.join("|"),name:s,tags:i}]}).slice(0,24):[]}function mce(){if(typeof window>"u")return{};try{const e=JSON.parse(window.localStorage.getItem(dce)??"{}");if(!e||typeof e!="object"||Array.isArray(e))return{};const r=Object.entries(e).flatMap(([n,i])=>{if(!i||typeof i!="object"||Array.isArray(i))return[];const s=i;return[[n,{search:typeof s.search=="string"?s.search:"",tags:uc(Array.isArray(s.tags)?s.tags.filter(o=>typeof o=="string"):[]),savedTagFilters:pce(s.savedTagFilters)}]]});return Object.fromEntries(r)}catch{return{}}}function vnt(e){return mce()[e]??ynt()}function xnt(e,r){if(!(typeof window>"u"||!e))try{const n=mce();n[e]={search:r.search,tags:uc(r.tags),savedTagFilters:pce(r.savedTagFilters)},window.localStorage.setItem(dce,JSON.stringify(n))}catch{}}function nU(e,r,n,i){const s=e.findIndex(u=>u.id===r);if(s<0)return e;const o=[...e],[a]=o.splice(s,1);if(!a)return e;if(n==null)return o.push(a),o;const l=o.findIndex(u=>u.id===n);return l<0?e:(o.splice(l+(i==="after"?1:0),0,a),o)}function iU(){if(!(typeof window>"u"))try{const e=window.AudioContext||window.webkitAudioContext;if(!e)return;const r=new e,n=r.currentTime,i=r.createGain();i.gain.setValueAtTime(1e-4,n),i.gain.exponentialRampToValueAtTime(.08,n+.012),i.gain.exponentialRampToValueAtTime(1e-4,n+.34),i.connect(r.destination);for(const[s,o]of[660,880].entries()){const a=r.createOscillator();a.type="sine",a.frequency.setValueAtTime(o,n+s*.08),a.connect(i),a.start(n+s*.08),a.stop(n+.22+s*.08)}window.setTimeout(()=>void r.close(),450)}catch{}}function bnt({todo:e}){const r=$0(e.status);return c.jsxs("div",{className:Ae("flex items-start gap-2 rounded-lg border bg-background px-3 py-2 text-sm shadow-2xl ring-1 ring-primary/10",r.itemClassName),children:[c.jsx(D4,{className:"mt-1 h-4 w-4 shrink-0 text-muted-foreground"}),c.jsx(B_,{status:e.status,className:"mt-0.5 shrink-0"}),c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsxs("div",{className:"mb-1 flex items-center gap-1.5 text-[11px] font-medium uppercase text-muted-foreground",children:[c.jsx("span",{children:r.label}),c.jsx(gY,{className:Ae("h-3 w-3",hce(e.priority))}),c.jsx("span",{children:e.priority})]}),c.jsx("span",{className:Ae("whitespace-pre-wrap break-words text-foreground",e.status==="done"&&"text-muted-foreground line-through"),children:e.message})]})]})}function g2(e){if(Array.isArray(e))return e;if(!e)return[];try{const r=JSON.parse(e);return Array.isArray(r)?r.filter(n=>typeof n=="string"):[]}catch{return e.split(",").map(r=>r.trim()).filter(Boolean)}}function _nt(e){return[...new Set(e.split(",").map(r=>r.trim().toLowerCase()).filter(Boolean))]}function uc(e){return[...new Set(e.map(r=>r.trim().toLowerCase()).filter(Boolean))]}function _5(e){const r=e.getFullYear(),n=`${e.getMonth()+1}`.padStart(2,"0"),i=`${e.getDate()}`.padStart(2,"0");return`${r}-${n}-${i}`}function gce(e){return new Intl.DateTimeFormat(void 0,{month:"long",year:"numeric"}).format(e)}function yce(e){if(!e)return null;const[r,n,i]=e.split("-").map(Number);return!r||!n||!i?null:new Date(r,n-1,i)}function dv(e){const r=yce(e);return r?new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",year:"numeric"}).format(r):"No due date"}function vce(e){if(!e)return"";const r=new Date(e);return Number.isNaN(r.getTime())?"":new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(r)}function sU(e,r){const n=uc(e).sort(),i=uc(r).sort();return n.length===i.length&&n.every((s,o)=>s===i[o])}function wnt(e){if(!e)return[];try{const r=JSON.parse(e);return Array.isArray(r)?r.flatMap(n=>{if(!n||typeof n!="object")return[];const i=n;if(typeof i.completedAt!="string")return[];const s=i.previousStatus==="open"||i.previousStatus==="in_progress"||i.previousStatus==="done"?i.previousStatus:null;return[{completedAt:i.completedAt,previousStatus:s}]}):[]}catch{return[]}}function Snt(e){const r=$0(e.status),n=g2(e.tags);return[e.message,r.label,e.status,e.priority,e.dueDate,dv(e.dueDate),n.join(" "),e.sourceThreadTitle,e.createdAt,e.updatedAt,e.completedAt,vce(e.completedAt)].filter(Boolean).join(" ").toLowerCase()}function knt(e,r){const n=r.trim().toLowerCase().split(/\s+/).filter(Boolean);if(n.length===0)return!0;const i=Snt(e);return n.every(s=>i.includes(s))}function Cnt(e){return e.flatMap(r=>{const n=g2(r.tags),i=wnt(r.completionHistory);return(i.length>0?i:r.completedAt?[{completedAt:r.completedAt,previousStatus:null}]:[]).map(o=>({...o,todoId:r.id,message:r.message,tags:n}))}).sort((r,n)=>new Date(n.completedAt).getTime()-new Date(r.completedAt).getTime())}function jnt(e){return[...e].sort((r,n)=>{const i=r.status==="done",s=n.status==="done";return i!==s?i?1:-1:0})}function xce(e){const r=new Date(e.getFullYear(),e.getMonth(),1),n=new Date(r);return n.setDate(r.getDate()-r.getDay()),Array.from({length:42},(i,s)=>{const o=new Date(n);return o.setDate(n.getDate()+s),o})}function j7({value:e,onChange:r,placeholder:n="Add date",className:i,iconOnly:s=!1}){const o=yce(e),[a,l]=y.useState(!1),[u,d]=y.useState(()=>o??new Date),h=f=>{r(f),l(!1)};return y.useEffect(()=>{o&&d(o)},[o==null?void 0:o.getTime()]),c.jsxs(E9,{open:a,onOpenChange:l,children:[c.jsx(A9,{asChild:!0,children:c.jsxs(_e,{type:"button",variant:"outline",className:Ae(s?"h-8 w-8 justify-center px-0":"h-10 w-full justify-start gap-2 px-3 text-left font-normal",!e&&"text-muted-foreground",i),title:e?`Due ${dv(e)}`:n,"aria-label":e?`Due ${dv(e)}`:n,children:[c.jsx(fR,{className:"h-4 w-4 shrink-0"}),!s&&c.jsx("span",{className:"truncate",children:e?dv(e):n})]})}),c.jsxs(O9,{align:"start",className:"w-[19rem] p-3",children:[c.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[c.jsx(_e,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>d(new Date(u.getFullYear(),u.getMonth()-1,1)),"aria-label":"Previous month",children:c.jsx(wv,{className:"h-4 w-4"})}),c.jsx("div",{className:"text-sm font-medium",children:gce(u)}),c.jsx(_e,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>d(new Date(u.getFullYear(),u.getMonth()+1,1)),"aria-label":"Next month",children:c.jsx(Cs,{className:"h-4 w-4"})})]}),c.jsx("div",{className:"grid grid-cols-7 gap-1 text-center text-[11px] font-medium text-muted-foreground",children:["S","M","T","W","T","F","S"].map((f,g)=>c.jsx("div",{className:"py-1",children:f},`${f}-${g}`))}),c.jsx("div",{className:"grid grid-cols-7 gap-1",children:xce(u).map(f=>{const g=_5(f),v=e===g,b=g===_5(new Date),_=f.getMonth()!==u.getMonth();return c.jsx(_e,{type:"button",variant:v?"secondary":"ghost",size:"icon",className:Ae("h-8 w-8 rounded-md text-xs font-normal",_&&"text-muted-foreground/55",b&&!v&&"border border-border"),onClick:()=>h(g),children:f.getDate()},g)})}),c.jsxs("div",{className:"mt-3 flex items-center justify-between gap-2 border-t pt-3",children:[c.jsx(_e,{type:"button",variant:"ghost",size:"sm",className:"h-8 px-2 text-xs",onClick:()=>h(_5(new Date)),children:"Today"}),c.jsxs(_e,{type:"button",variant:"ghost",size:"sm",className:"h-8 px-2 text-xs",onClick:()=>h(null),children:[c.jsx(Vn,{className:"mr-1 h-3.5 w-3.5"}),"Clear"]})]})]})]})}function Nnt({value:e,onChange:r,className:n,iconOnly:i=!1}){const[s,o]=y.useState(!!e);return y.useEffect(()=>{e&&o(!0)},[e]),s?c.jsx(j7,{value:e,onChange:a=>{r(a),a||o(!1)},className:n,iconOnly:i}):c.jsxs(_e,{type:"button",variant:"outline",className:Ae(i?"h-8 w-8 justify-center px-0 text-muted-foreground":"h-10 justify-start gap-2 text-muted-foreground",n),onClick:()=>o(!0),title:"Add date","aria-label":"Add date",children:[c.jsx(fR,{className:"h-4 w-4"}),!i&&"Add date"]})}function M1({value:e,onChange:r,options:n,placeholder:i,disabled:s,className:o,triggerLabel:a,triggerIcon:l}){var d;const u=((d=n.find(h=>h.value===e))==null?void 0:d.label)??i??e;return c.jsxs(th,{value:e,onValueChange:h=>r(h),disabled:s,children:[c.jsx(Zu,{className:o,title:a?`${a}: ${u}`:u,"aria-label":a?`${a}: ${u}`:u,children:l||c.jsx(rh,{placeholder:i})}),c.jsx(Qu,{children:n.map(h=>c.jsx(Ls,{value:h.value,children:h.label},h.value))})]})}function _3({value:e,onChange:r,placeholder:n="Add tag...",commitOnBlur:i=!1,className:s,inputClassName:o}){const[a,l]=y.useState(""),u=uc(e),d=()=>{const f=_nt(a);f.length!==0&&(r(uc([...u,...f])),l(""))},h=f=>{r(u.filter(g=>g!==f))};return c.jsxs("div",{className:Ae("flex min-h-10 w-full flex-wrap items-center gap-1.5 rounded-lg border border-input bg-background/90 px-2 py-1.5 shadow-sm focus-within:ring-2 focus-within:ring-ring/60 focus-within:ring-offset-2 focus-within:ring-offset-background",s),children:[u.map(f=>c.jsxs($r,{variant:"secondary",className:"h-6 gap-1 rounded-md px-2 text-xs",children:[c.jsx("span",{children:f}),c.jsx("button",{type:"button",className:"-mr-1 inline-flex h-4 w-4 items-center justify-center rounded-sm text-muted-foreground hover:bg-foreground/10 hover:text-foreground",onClick:()=>h(f),"aria-label":`Remove ${f} tag`,children:c.jsx(Vn,{className:"h-3 w-3"})})]},f)),c.jsx("input",{value:a,onChange:f=>{const g=f.target.value;if(g.includes(",")){const v=g.split(","),b=v.pop()??"",_=uc([...u,...v]);(_.length!==u.length||_.some((w,S)=>w!==u[S]))&&r(_),l(b.trimStart());return}l(g)},onKeyDown:f=>{f.key==="Enter"||f.key===","?(f.preventDefault(),d()):f.key==="Backspace"&&!a&&u.length>0&&(f.preventDefault(),r(u.slice(0,-1)))},onBlur:()=>{i&&d()},className:Ae("h-6 min-w-28 flex-1 bg-transparent px-1 text-sm outline-none placeholder:text-muted-foreground",o),placeholder:u.length===0?n:""})]})}function Tnt({provider:e="jait",model:r=null,runtimeMode:n="full-access"}){var sr;const[i,s]=y.useState([]),[o,a]=y.useState(""),[l,u]=y.useState([]),[d,h]=y.useState("list"),[f,g]=y.useState("all"),[v,b]=y.useState(""),[_,w]=y.useState([]),[S,C]=y.useState([]),[j,E]=y.useState(null),[A,N]=y.useState(()=>new Date),[P,H]=y.useState(""),[K,F]=y.useState("open"),[B,W]=y.useState("normal"),[D,O]=y.useState(null),[I,R]=y.useState([]),[$,U]=y.useState(()=>new Set),[Y,z]=y.useState([]),[V,Q]=y.useState("normal"),[q,re]=y.useState(null),[ee,ne]=y.useState(!0),[ae,te]=y.useState(!1),[ue,he]=y.useState(!1),[we,pe]=y.useState(()=>new Set),[qe,se]=y.useState(null),[it,Ye]=y.useState(!1),[ht,qt]=y.useState(0),Nt=y.useRef(null),Xt=y.useRef(null),[Wt,gt]=y.useState(null),[Re,kt]=y.useState(null),[Pt,Ne]=y.useState(null),ze=y.useCallback(async()=>{const xe=await xr.listRepos();s(xe),a(xt=>hnt(xe,xt)??"")},[]),Qe=y.useCallback(async xe=>{if(!xe){u([]),ne(!1);return}ne(!0),se(null);try{u(gnt(xe,await xr.listJaitTodos(xe)))}catch(xt){se(xt instanceof Error?xt.message:"Failed to load todo list")}finally{ne(!1)}},[]);y.useEffect(()=>{(async()=>{ne(!0),se(null);try{await ze()}catch(xe){se(xe instanceof Error?xe.message:"Failed to load repositories"),ne(!1)}})()},[ze]),y.useEffect(()=>{Qe(o)},[Qe,o]),y.useEffect(()=>{if(!o){b(""),w([]),C([]),E(null),U(new Set);return}const xe=vnt(o);b(xe.search),w(xe.tags),C(xe.savedTagFilters),E(o),U(new Set)},[o]),y.useEffect(()=>{!o||j!==o||xnt(o,{search:v,tags:_,savedTagFilters:S})},[j,v,o,S,_]);const lt=y.useMemo(()=>jnt(l.filter(xe=>{if(f!=="all"&&xe.status!==f)return!1;const xt=g2(xe.tags);return!(_.length>0&&!_.every(Je=>xt.includes(Je))||!knt(xe,v))})),[v,f,_,l]),yt=y.useMemo(()=>({open:l.filter(xe=>xe.status==="open").length,inProgress:l.filter(xe=>xe.status==="in_progress").length,done:l.filter(xe=>xe.status==="done").length}),[l]),Tt=i.find(xe=>xe.id===o),dr=y.useMemo(()=>i.map(xe=>({value:xe.id,label:xe.name})),[i]),De=y.useMemo(()=>l.filter(xe=>$.has(xe.id)),[$,l]),je=y.useMemo(()=>lt.filter(xe=>$.has(xe.id)).length,[lt,$]),be=lt.length>0&&je===lt.length,Be=S.find(xe=>sU(xe.tags,_))??null,at=y.useMemo(()=>Cnt(l),[l]),Ve=Math.max(1,Math.ceil(at.length/b3)),Mt=at.slice(ht*b3,ht*b3+b3);y.useEffect(()=>{qt(xe=>Math.min(xe,Ve-1))},[Ve]),y.useEffect(()=>{U(xe=>{const xt=new Set(l.map(Rt=>Rt.id)),Je=new Set([...xe].filter(Rt=>xt.has(Rt)));return Je.size===xe.size?xe:Je})},[l]);const It=y.useCallback(xe=>{a(xe);const xt=i.find(Je=>Je.id===xe);dnt(xe,(xt==null?void 0:xt.localPath)??null)},[i]);y.useEffect(()=>{if(ee||!Tt||d!=="list")return;const xe=window.requestAnimationFrame(()=>{var xt,Je;(xt=Nt.current)==null||xt.focus(),(Je=Nt.current)==null||Je.select()});return()=>window.cancelAnimationFrame(xe)},[ee,d,Tt==null?void 0:Tt.id]);const rr=y.useCallback(async()=>{const xe=P.trim();if(!(!o||!xe)){te(!0),se(null);try{const xt=await xr.createJaitTodo(o,{message:xe,status:K,priority:B,dueDate:D,tags:I});u(Je=>{const Rt=[xt,...Je];return rU(o,Rt),Rt}),H(""),F("open"),W("normal"),O(null),R([]),window.requestAnimationFrame(()=>{var Je;return(Je=Nt.current)==null?void 0:Je.focus()})}catch(xt){se(xt instanceof Error?xt.message:"Failed to add todo")}finally{te(!1)}}},[D,P,B,K,I,o]),nr=y.useCallback(xe=>{xe.key==="Enter"&&!xe.shiftKey&&(xe.preventDefault(),rr())},[rr]),Ut=async(xe,xt)=>{u(Je=>Je.map(Rt=>Rt.id===xe.id?{...Rt,...xt,tags:xt.tags?JSON.stringify(xt.tags):Rt.tags}:Rt));try{const Je=await xr.updateJaitTodo(xe.id,xt);u(Rt=>Rt.map(Ke=>Ke.id===xe.id?Je:Ke))}catch(Je){se(Je instanceof Error?Je.message:"Failed to update todo"),Qe(o)}},Se=async(xe,xt)=>{xe.status!=="done"&&xt==="done"&&iU(),await Ut(xe,{status:xt})},Fe=async xe=>{const xt=l;u(Je=>Je.filter(Rt=>Rt.id!==xe)),U(Je=>{const Rt=new Set(Je);return Rt.delete(xe),Rt});try{await xr.deleteJaitTodo(xe)}catch(Je){u(xt),se(Je instanceof Error?Je.message:"Failed to remove todo")}},et=y.useCallback((xe,xt)=>{U(Je=>{const Rt=new Set(Je);return xt?Rt.add(xe):Rt.delete(xe),Rt})},[]),St=y.useCallback(xe=>{U(xt=>{const Je=new Set(xt);for(const Rt of lt)xe?Je.add(Rt.id):Je.delete(Rt.id);return Je})},[lt]),Xe=y.useCallback(()=>{const xe=uc(_);if(xe.length===0)return;const xt=xe.join("|");C(Je=>Je.some(Rt=>Rt.id===xt||sU(Rt.tags,xe))?Je:[...Je,{id:xt,name:xe.join(" + "),tags:xe}])},[_]),Lt=y.useCallback(()=>{Be&&C(xe=>xe.filter(xt=>xt.id!==Be.id))},[Be]),Et=async(xe,xt)=>{if(De.length!==0){he(!0),se(null);try{const Je=await Promise.all(De.map(Ke=>xr.updateJaitTodo(Ke.id,xe(Ke)))),Rt=new Map(Je.map(Ke=>[Ke.id,Ke]));u(Ke=>Ke.map(me=>Rt.get(me.id)??me))}catch(Je){se(Je instanceof Error?Je.message:xt),Qe(o)}finally{he(!1)}}},Ft=async xe=>{xe==="done"&&De.some(xt=>xt.status!=="done")&&iU(),await Et(()=>({status:xe}),"Failed to update selected todo statuses")},ye=async xe=>{await Et(()=>({priority:xe}),"Failed to update selected todo priorities")},st=async xe=>{await Et(()=>({dueDate:xe}),"Failed to update selected todo due dates")},ir=async()=>{const xe=uc(Y);xe.length!==0&&(await Et(xt=>({tags:uc([...g2(xt.tags),...xe])}),"Failed to update selected todo tags"),z([]))},At=async()=>{if(De.length===0)return;const xe=l,xt=new Set(De.map(Je=>Je.id));u(Je=>Je.filter(Rt=>!xt.has(Rt.id))),U(new Set),he(!0),se(null);try{await Promise.all([...xt].map(Je=>xr.deleteJaitTodo(Je)))}catch(Je){u(xe),se(Je instanceof Error?Je.message:"Failed to remove selected todos")}finally{he(!1)}},hr=async xe=>{if(!(!Tt||we.has(xe.id))){pe(xt=>new Set(xt).add(xe.id)),se(null);try{const xt=`jait/${Math.random().toString(16).slice(2,10)}`,Je=Tt.defaultBranch;let Rt;try{Rt=(await $s.createWorktree(Tt.localPath,Je,xt)).path}catch{try{await $s.createBranch(Tt.localPath,xt,Je)}catch{}}const Ke=await xr.createThread(pnt({repo:Tt,providerId:e,runtimeMode:n,model:r,workingDirectory:Rt??Tt.localPath,branch:xt}));await xr.startThread(Ke.id,mnt(Tt.name,xe)),xe.status!=="done"&&await Ut(xe,{status:"in_progress"})}catch(xt){se(xt instanceof Error?xt.message:"Failed to run todo as thread")}finally{pe(xt=>{const Je=new Set(xt);return Je.delete(xe.id),Je})}}},Vr=y.useMemo(()=>{const xe=new Map;for(const xt of lt)xt.dueDate&&xe.set(xt.dueDate,[...xe.get(xt.dueDate)??[],xt]);return xe},[lt]);y.useEffect(()=>{if(Wt&&!lt.some(xe=>xe.id===Wt)){gt(null),kt(null),Ne(null);return}Re!=null&&Re.targetId&&!lt.some(xe=>xe.id===Re.targetId)&&kt(Wt?{targetId:Wt,placement:"before"}:null)},[Wt,Re,lt]),y.useEffect(()=>{var me;if(!Wt||!Pt)return;document.body.style.cursor="grabbing",document.body.style.userSelect="none",document.body.style.touchAction="none";const xe=dt=>{var qr;const fr=Array.from(document.querySelectorAll("[data-todo-id]")).filter(Hn=>Hn.dataset.todoId&&Hn.dataset.todoId!==Wt);if(fr.length===0){kt({targetId:null,placement:"after"});return}for(const Hn of fr){const Mi=Hn.dataset.todoId;if(!Mi)continue;const Ri=Hn.getBoundingClientRect();if(dt<Ri.top+Ri.height/2){kt({targetId:Mi,placement:"before"});return}}const vr=((qr=fr[fr.length-1])==null?void 0:qr.dataset.todoId)??null;kt(vr?{targetId:vr,placement:"after"}:{targetId:null,placement:"after"})},xt=dt=>{var fr,vr;if(dt&&dt.pointerId!==Pt.pointerId)return;Re&&Re.targetId!==Wt&&u(qr=>{const Hn=nU(qr,Wt,Re.targetId,Re.placement);return Hn===qr?qr:(rU(o,Hn),Hn)});const wt=Xt.current;(fr=wt==null?void 0:wt.hasPointerCapture)!=null&&fr.call(wt,Pt.pointerId)&&((vr=wt.releasePointerCapture)==null||vr.call(wt,Pt.pointerId)),Xt.current=null,gt(null),kt(null),Ne(null)},Je=dt=>{dt.pointerId===Pt.pointerId&&(Ne(wt=>wt&&{...wt,x:dt.clientX,y:dt.clientY}),xe(dt.clientY))},Rt=()=>xt(),Ke=()=>xt();return window.addEventListener("pointermove",Je),window.addEventListener("pointerup",xt),window.addEventListener("pointercancel",xt),window.addEventListener("blur",Ke),(me=Xt.current)==null||me.addEventListener("lostpointercapture",Rt),()=>{var dt;document.body.style.cursor="",document.body.style.userSelect="",document.body.style.touchAction="",window.removeEventListener("pointermove",Je),window.removeEventListener("pointerup",xt),window.removeEventListener("pointercancel",xt),window.removeEventListener("blur",Ke),(dt=Xt.current)==null||dt.removeEventListener("lostpointercapture",Rt)}},[Pt,Wt,Re,o]);const br=y.useCallback((xe,xt)=>{var Ke;if(xt.button!==0&&xt.pointerType!=="touch"&&xt.pointerType!=="pen")return;xt.preventDefault();const Je=xt.currentTarget.closest("[data-todo-id]");if(!Je)return;Xt.current=Je,(Ke=Je.setPointerCapture)==null||Ke.call(Je,xt.pointerId);const Rt=Je.getBoundingClientRect();gt(xe),kt({targetId:xe,placement:"before"}),Ne({id:xe,pointerId:xt.pointerId,x:xt.clientX,y:xt.clientY,offsetX:xt.clientX-Rt.left,offsetY:xt.clientY-Rt.top,width:Rt.width,height:Rt.height})},[]),Rr=Wt&&Re&&(Re.targetId!==Wt||Re.placement==="after")?nU(lt,Wt,Re.targetId,Re.placement):lt,mt=Pt?Rr.find(xe=>xe.id===Pt.id):null;return c.jsxs("div",{className:"mx-auto flex max-w-7xl flex-col gap-4 px-3 py-4 sm:px-4 sm:py-6",children:[c.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[c.jsxs("div",{className:"min-w-0",children:[c.jsxs("h1",{className:"flex items-center gap-2 text-xl font-bold sm:text-2xl",children:[c.jsx(Vm,{className:"h-6 w-6"}),"Todo"]}),c.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Global repo follow-up work, saved from agents or added directly here."})]}),c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsxs(th,{value:o||void 0,onValueChange:It,disabled:i.length===0,children:[c.jsx(Zu,{className:"h-10 min-w-56",children:c.jsx(rh,{placeholder:"Select repository"})}),c.jsx(Qu,{children:dr.map(xe=>c.jsx(Ls,{value:xe.value,children:xe.label},xe.value))})]}),c.jsxs(_e,{variant:"outline",onClick:()=>void Qe(o),disabled:ee||!o,children:[c.jsx(io,{className:Ae("mr-2 h-4 w-4",ee&&"animate-spin")}),"Refresh"]}),c.jsxs(_e,{variant:"outline",onClick:()=>Ye(!0),disabled:at.length===0,children:[c.jsx(B5,{className:"mr-2 h-4 w-4"}),"History",at.length>0&&c.jsx($r,{variant:"secondary",className:"ml-1 px-1.5",children:at.length})]})]})]}),c.jsxs("div",{className:"grid grid-cols-2 gap-2 sm:flex sm:flex-wrap",children:[c.jsxs($r,{variant:"outline",className:"justify-center gap-1.5 px-3 py-1",children:[c.jsx(Vm,{className:"h-3.5 w-3.5 text-primary/70"}),l.length," total"]}),c.jsxs($r,{variant:"secondary",className:"justify-center gap-1.5 px-3 py-1",children:[c.jsx(mR,{className:"h-3.5 w-3.5 text-muted-foreground"}),yt.open," open"]}),c.jsxs($r,{variant:"secondary",className:"justify-center gap-1.5 px-3 py-1",children:[c.jsx(pY,{className:"h-3.5 w-3.5 text-sky-500"}),yt.inProgress," active"]}),c.jsxs($r,{variant:"secondary",className:"justify-center gap-1.5 px-3 py-1",children:[c.jsx(uo,{className:"h-3.5 w-3.5 text-emerald-500"}),yt.done," done"]})]}),qe&&c.jsxs("div",{className:"flex items-center gap-2 rounded-md bg-destructive/10 p-3 text-sm text-destructive",children:[c.jsx(ia,{className:"h-4 w-4"}),qe,c.jsx(_e,{variant:"ghost",size:"sm",className:"ml-auto",onClick:()=>se(null),children:"Dismiss"})]}),c.jsx("div",{className:"rounded-lg border p-3",children:c.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-start",children:[c.jsxs("div",{className:"min-w-0 flex-1 rounded-lg border border-input bg-background/90 shadow-sm focus-within:ring-2 focus-within:ring-ring/60 focus-within:ring-offset-2 focus-within:ring-offset-background",children:[c.jsx(jp,{ref:Nt,value:P,onChange:xe=>H(xe.target.value),onKeyDown:nr,placeholder:"Add a future agent prompt or repo task...",className:"min-h-20 resize-y border-0 bg-transparent shadow-none focus-visible:ring-0 focus-visible:ring-offset-0"}),c.jsx(_3,{value:I,onChange:R,placeholder:"Add tags...",className:"min-h-9 rounded-none rounded-b-lg border-x-0 border-b-0 border-t bg-transparent px-2 py-1 shadow-none focus-within:ring-0 focus-within:ring-offset-0",inputClassName:"text-xs"})]}),c.jsxs("div",{className:"flex flex-wrap items-center gap-1 text-xs text-muted-foreground lg:w-auto lg:flex-nowrap",children:[c.jsx(O1,{label:`Status: ${$0(K).label}`,children:c.jsx(M1,{value:K,onChange:F,options:f8,triggerLabel:"Status",triggerIcon:c.jsx(B_,{status:K,className:"h-4 w-4"}),className:"h-8 w-8 justify-center rounded-md border-transparent bg-transparent px-0 text-muted-foreground shadow-none hover:bg-accent hover:text-foreground focus:ring-1 focus:ring-ring/50 focus:ring-offset-0 [&>svg:last-child]:hidden"})}),c.jsx(O1,{label:`Priority: ${((sr=t_.find(xe=>xe.value===B))==null?void 0:sr.label)??B}`,children:c.jsx(M1,{value:B,onChange:W,options:t_,triggerLabel:"Priority",triggerIcon:c.jsx(tU,{priority:B}),className:"h-8 w-8 justify-center rounded-md border-transparent bg-transparent px-0 text-muted-foreground shadow-none hover:bg-accent hover:text-foreground focus:ring-1 focus:ring-ring/50 focus:ring-offset-0 [&>svg:last-child]:hidden"})}),c.jsx(O1,{label:D?`Due ${dv(D)}`:"Add date",children:c.jsx(Nnt,{value:D,onChange:O,iconOnly:!0,className:"rounded-md border-transparent bg-transparent text-muted-foreground shadow-none hover:bg-accent hover:text-foreground focus:ring-1 focus:ring-ring/50 focus:ring-offset-0"})}),c.jsxs(_e,{onClick:()=>void rr(),disabled:ae||!o||!P.trim(),size:"sm",children:[ae?c.jsx(Vt,{className:"mr-2 h-4 w-4 animate-spin"}):c.jsx(qs,{className:"mr-2 h-4 w-4"}),"Add"]})]})]})}),c.jsxs("div",{className:"grid gap-3 rounded-lg border p-3",children:[c.jsxs("div",{className:"grid gap-2 lg:grid-cols-[minmax(14rem,1fr)_11rem_minmax(14rem,1fr)_13rem_auto]",children:[c.jsxs("div",{className:"relative",children:[c.jsx(tl,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),c.jsx(Pn,{value:v,onChange:xe=>b(xe.target.value),placeholder:"Search todo metadata...",className:"h-10 pl-9"})]}),c.jsx(M1,{value:f,onChange:g,options:[{value:"all",label:"All statuses"},...f8],className:"h-10"}),c.jsx(_3,{value:_,onChange:xe=>w(uc(xe)),placeholder:"Filter tags...",className:"min-h-10"}),c.jsxs(th,{value:(Be==null?void 0:Be.id)??"custom",onValueChange:xe=>{if(xe==="custom"){w([]);return}const xt=S.find(Je=>Je.id===xe);xt&&w(xt.tags)},children:[c.jsx(Zu,{className:"h-10",children:c.jsx(rh,{placeholder:"Saved filters"})}),c.jsxs(Qu,{children:[c.jsx(Ls,{value:"custom",children:"Unsaved filter"}),S.map(xe=>c.jsx(Ls,{value:xe.id,children:xe.name},xe.id))]})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(_e,{variant:"outline",size:"icon",className:"h-10 w-10",onClick:Xe,disabled:_.length===0||!!Be,"aria-label":"Save tag filter",children:c.jsx(N2,{className:"h-4 w-4"})}),c.jsx(_e,{variant:"outline",size:"icon",className:"h-10 w-10",onClick:Lt,disabled:!Be,"aria-label":"Delete saved tag filter",children:c.jsx(Tl,{className:"h-4 w-4"})})]})]}),c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:flex-wrap sm:items-center sm:justify-between",children:[c.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm text-muted-foreground",children:[c.jsxs($r,{variant:"outline",className:"gap-1.5",children:[c.jsx(D0e,{className:"h-3.5 w-3.5"}),S.length," saved"]}),c.jsxs("span",{children:[lt.length," shown"]}),(v||_.length>0||f!=="all")&&c.jsxs(_e,{variant:"ghost",size:"sm",className:"h-8 px-2",onClick:()=>{b(""),w([]),g("all")},children:[c.jsx(Vn,{className:"mr-1 h-3.5 w-3.5"}),"Clear"]})]}),c.jsxs("div",{className:"grid grid-cols-2 gap-2 sm:flex",children:[c.jsxs(_e,{variant:d==="list"?"secondary":"outline",onClick:()=>h("list"),children:[c.jsx(Vm,{className:"mr-2 h-4 w-4"}),"List"]}),c.jsxs(_e,{variant:d==="calendar"?"secondary":"outline",onClick:()=>h("calendar"),children:[c.jsx(fR,{className:"mr-2 h-4 w-4"}),"Calendar"]})]})]})]}),De.length>0&&c.jsxs("div",{className:"grid gap-3 rounded-lg border p-3",children:[c.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[c.jsxs($r,{variant:"secondary",children:[De.length," selected"]}),c.jsx(_e,{variant:"outline",size:"sm",onClick:()=>void Ft("open"),disabled:ue,children:"Open"}),c.jsx(_e,{variant:"outline",size:"sm",onClick:()=>void Ft("in_progress"),disabled:ue,children:"In progress"}),c.jsx(_e,{variant:"outline",size:"sm",onClick:()=>void Ft("done"),disabled:ue,children:"Done"}),c.jsx(M1,{value:V,onChange:xe=>{Q(xe),ye(xe)},options:t_,className:"h-9 w-32"}),c.jsx(j7,{value:q,onChange:xe=>{re(xe),st(xe)},placeholder:"Due date",className:"h-9 w-36"}),c.jsx(_e,{variant:"outline",size:"sm",onClick:()=>void st(null),disabled:ue,children:"Clear date"})]}),c.jsxs("div",{className:"grid gap-2 md:grid-cols-[minmax(14rem,1fr)_auto_auto]",children:[c.jsx(_3,{value:Y,onChange:z,placeholder:"Add tags to selected...",className:"min-h-9"}),c.jsxs(_e,{variant:"outline",size:"sm",onClick:()=>void ir(),disabled:ue||Y.length===0,children:[c.jsx(qs,{className:"mr-2 h-4 w-4"}),"Add tags"]}),c.jsxs(_e,{variant:"outline",size:"sm",onClick:()=>void At(),disabled:ue,children:[ue?c.jsx(Vt,{className:"mr-2 h-4 w-4 animate-spin"}):c.jsx(Tl,{className:"mr-2 h-4 w-4"}),"Remove"]})]})]}),c.jsx(El,{open:it,onOpenChange:Ye,children:c.jsxs(sl,{className:"max-h-[85vh] max-w-2xl overflow-hidden p-0",children:[c.jsxs(pc,{className:"border-b px-4 py-3",children:[c.jsxs(ol,{className:"flex items-center gap-2 text-base",children:[c.jsx(B5,{className:"h-4 w-4 text-muted-foreground"}),"Completion history"]}),c.jsxs(rd,{children:[at.length," completed event",at.length===1?"":"s"]})]}),c.jsx("div",{className:"grid max-h-[56vh] gap-2 overflow-y-auto px-4 py-3",children:Mt.map(xe=>c.jsxs("div",{className:"min-w-0 rounded-md border bg-card/40 px-3 py-2",children:[c.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[c.jsx(uo,{className:"h-3.5 w-3.5 text-emerald-500"}),c.jsx("span",{children:vce(xe.completedAt)}),xe.previousStatus&&c.jsxs("span",{children:["from ",$0(xe.previousStatus).label]})]}),c.jsx("div",{className:"mt-1 text-sm",children:xe.message}),xe.tags.length>0&&c.jsx("div",{className:"mt-1 flex flex-wrap gap-1",children:xe.tags.slice(0,6).map(xt=>c.jsx($r,{variant:"secondary",className:"h-5 rounded px-1.5 text-[11px]",children:xt},xt))})]},`${xe.todoId}-${xe.completedAt}`))}),c.jsxs(bg,{className:"flex-row items-center justify-between border-t px-4 py-3 sm:justify-between sm:space-x-0",children:[c.jsxs("div",{className:"text-xs text-muted-foreground",children:["Page ",ht+1," of ",Ve]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(_e,{variant:"outline",size:"sm",onClick:()=>qt(xe=>Math.max(0,xe-1)),disabled:ht===0,children:[c.jsx(wv,{className:"mr-1 h-4 w-4"}),"Prev"]}),c.jsxs(_e,{variant:"outline",size:"sm",onClick:()=>qt(xe=>Math.min(Ve-1,xe+1)),disabled:ht>=Ve-1,children:["Next",c.jsx(Cs,{className:"ml-1 h-4 w-4"})]})]})]})]})}),ee&&l.length===0?c.jsx("div",{className:"flex items-center justify-center py-24",children:c.jsx(Vt,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):Tt?d==="calendar"?c.jsxs("div",{className:"rounded-lg border",children:[c.jsxs("div",{className:"flex items-center justify-between border-b px-3 py-2",children:[c.jsxs(_e,{variant:"outline",size:"sm",onClick:()=>N(new Date(A.getFullYear(),A.getMonth()-1,1)),children:[c.jsx(wv,{className:"mr-1 h-4 w-4"}),"Prev"]}),c.jsx("div",{className:"font-medium",children:gce(A)}),c.jsxs(_e,{variant:"outline",size:"sm",onClick:()=>N(new Date(A.getFullYear(),A.getMonth()+1,1)),children:["Next",c.jsx(Cs,{className:"ml-1 h-4 w-4"})]})]}),c.jsx("div",{className:"grid grid-cols-7 border-b text-center text-xs text-muted-foreground",children:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].map(xe=>c.jsx("div",{className:"py-2",children:xe},xe))}),c.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-7",children:xce(A).map(xe=>{const xt=_5(xe),Je=Vr.get(xt)??[],Rt=xe.getMonth()!==A.getMonth();return c.jsxs("div",{className:"min-h-32 border-b p-2 sm:border-r [&:nth-child(7n)]:border-r-0",children:[c.jsx("div",{className:Ae("mb-2 text-xs font-medium",Rt&&"text-muted-foreground"),children:xe.getDate()}),c.jsx("div",{className:"space-y-1",children:Je.map(Ke=>{const me=$0(Ke.status);return c.jsxs("button",{className:Ae("flex w-full items-start gap-1.5 rounded-md border px-2 py-1 text-left text-xs hover:bg-accent",me.itemClassName),onClick:()=>void Se(Ke,Ke.status==="done"?"open":"done"),children:[c.jsx(B_,{status:Ke.status,className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),c.jsx("span",{className:Ke.status==="done"?"line-through text-muted-foreground":"",children:Ke.message})]},Ke.id)})})]},xt)})})]}):lt.length===0?c.jsxs("div",{className:"rounded-lg border-2 border-dashed px-4 py-16 text-center",children:[c.jsx(xve,{className:"mx-auto mb-4 h-10 w-10 text-muted-foreground"}),c.jsx("h3",{className:"mb-2 text-lg font-medium",children:"No todo items match"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Change filters or add the first repo-wide item."})]}):c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 rounded-lg border bg-card/40 px-3 py-2 text-sm text-muted-foreground",children:[c.jsxs("label",{className:"inline-flex items-center gap-2",children:[c.jsx("input",{type:"checkbox",className:"h-4 w-4 rounded border-input",checked:be,onChange:xe=>St(xe.target.checked)}),c.jsx("span",{children:je>0?`${je} selected in view`:"Select visible"})]}),c.jsxs("span",{children:[Rr.length," item",Rr.length===1?"":"s"]})]}),Rr.map(xe=>{var dt;const xt=g2(xe.tags),Je=$0(xe.status),Rt=we.has(xe.id),Ke=!!(Wt&&(Re==null?void 0:Re.targetId)===xe.id&&Re.placement==="before"&&Wt!==xe.id),me=!!(Wt&&(Re==null?void 0:Re.targetId)===xe.id&&Re.placement==="after"&&Wt!==xe.id);return c.jsxs("div",{className:"space-y-3",children:[Ke&&c.jsx("div",{className:"relative h-0",children:c.jsx("div",{className:"absolute inset-x-2 -top-px h-0.5 rounded-full bg-primary shadow-[0_0_0_1px_hsl(var(--background))]"})}),c.jsxs("div",{"data-todo-id":xe.id,className:Ae("group rounded-lg border p-2 transition-all duration-150 ease-out sm:p-3",Je.itemClassName,Wt&&"touch-none",Wt===xe.id&&"border-dashed border-primary/35 bg-primary/5 opacity-0"),children:[c.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_auto] items-start gap-2",children:[c.jsxs("div",{className:"flex flex-col items-center gap-1",children:[c.jsx("input",{"data-no-drag":"true",type:"checkbox",className:"h-4 w-4 rounded border-input",checked:$.has(xe.id),onChange:wt=>et(xe.id,wt.target.checked),"aria-label":"Select todo"}),c.jsx("div",{className:"shrink-0 cursor-grab touch-none rounded p-0.5 text-muted-foreground transition-colors hover:bg-foreground/10 hover:text-foreground active:cursor-grabbing",title:"Drag to reorder","aria-label":"Drag to reorder",onPointerDown:wt=>br(xe.id,wt),children:c.jsx(D4,{className:"h-4 w-4"})}),c.jsx("button",{className:"h-6 w-6 shrink-0 rounded text-muted-foreground hover:text-foreground",onClick:()=>void Se(xe,xe.status==="done"?"open":"done"),"aria-label":"Toggle todo status",children:c.jsx(B_,{status:xe.status})})]}),c.jsxs("div",{className:"min-w-0 flex-1 rounded-lg border border-input bg-background/90 shadow-sm focus-within:ring-2 focus-within:ring-ring/60 focus-within:ring-offset-2 focus-within:ring-offset-background",children:[c.jsx(jp,{className:Ae("min-h-20 resize-y border-0 bg-transparent shadow-none focus-visible:ring-0 focus-visible:ring-offset-0",xe.status==="done"&&"text-muted-foreground line-through"),defaultValue:xe.message,onBlur:wt=>{const fr=wt.target.value.trim();fr&&fr!==xe.message&&Ut(xe,{message:fr})}}),c.jsx(_3,{value:xt,onChange:wt=>{const fr=uc(wt);JSON.stringify(fr)!==JSON.stringify(uc(xt))&&Ut(xe,{tags:fr})},placeholder:"Add tags...",commitOnBlur:!0,className:"min-h-9 rounded-none rounded-b-lg border-x-0 border-b-0 border-t bg-transparent px-2 py-1 shadow-none focus-within:ring-0 focus-within:ring-offset-0",inputClassName:"text-xs"})]}),c.jsxs("div",{className:"grid w-[4.25rem] grid-cols-2 gap-0.5 text-xs text-muted-foreground",children:[c.jsx(O1,{label:`Status: ${Je.label}`,children:c.jsx(M1,{value:xe.status,onChange:wt=>void Se(xe,wt),options:f8,triggerLabel:"Status",triggerIcon:c.jsx(B_,{status:xe.status,className:"h-4 w-4"}),className:"h-8 w-8 justify-center rounded-md border-transparent bg-transparent px-0 text-muted-foreground shadow-none hover:bg-accent hover:text-foreground focus:ring-1 focus:ring-ring/50 focus:ring-offset-0 [&>svg:last-child]:hidden"})}),c.jsx(O1,{label:`Priority: ${((dt=t_.find(wt=>wt.value===xe.priority))==null?void 0:dt.label)??xe.priority}`,children:c.jsx(M1,{value:xe.priority,onChange:wt=>void Ut(xe,{priority:wt}),options:t_,triggerLabel:"Priority",triggerIcon:c.jsx(tU,{priority:xe.priority}),className:"h-8 w-8 justify-center rounded-md border-transparent bg-transparent px-0 text-muted-foreground shadow-none hover:bg-accent hover:text-foreground focus:ring-1 focus:ring-ring/50 focus:ring-offset-0 [&>svg:last-child]:hidden"})}),c.jsx(O1,{label:xe.dueDate?`Due ${dv(xe.dueDate)}`:"Date",children:c.jsx(j7,{value:xe.dueDate??null,onChange:wt=>void Ut(xe,{dueDate:wt}),placeholder:"Date",iconOnly:!0,className:"rounded-md border-transparent bg-transparent text-muted-foreground shadow-none hover:bg-accent hover:text-foreground focus:ring-1 focus:ring-ring/50 focus:ring-offset-0"})}),c.jsx(_e,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",onClick:()=>void hr(xe),disabled:Rt||!Tt,title:"Run todo as thread","aria-label":"Run todo as thread",children:Rt?c.jsx(Vt,{className:"h-4 w-4 animate-spin"}):c.jsx(DS,{className:"h-4 w-4"})}),c.jsx(_e,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",onClick:()=>void Fe(xe.id),"aria-label":"Remove todo",children:c.jsx(Tl,{className:"h-4 w-4"})})]})]}),c.jsx("div",{className:"mt-2 flex justify-end",children:xe.sourceThreadTitle&&c.jsxs("span",{className:"text-xs text-muted-foreground",children:["Suggested by `",xe.sourceThreadTitle,"`"]})})]}),me&&c.jsx("div",{className:"relative h-0",children:c.jsx("div",{className:"absolute inset-x-2 -top-px h-0.5 rounded-full bg-primary shadow-[0_0_0_1px_hsl(var(--background))]"})})]},xe.id)}),Pt&&mt&&c.jsx("div",{className:"pointer-events-none fixed z-50",style:{left:`${Pt.x-Pt.offsetX}px`,top:`${Pt.y-Pt.offsetY}px`,width:`${Pt.width}px`,minHeight:`${Pt.height}px`},children:c.jsx("div",{className:"scale-[1.01] opacity-95",children:c.jsx(bnt,{todo:mt})})})]}):c.jsx("div",{className:"rounded-lg border-2 border-dashed px-4 py-16 text-center text-sm text-muted-foreground",children:"Add a repository in manager mode before creating todo items."})]})}var Ent="Separator",oU="horizontal",Ant=["horizontal","vertical"],bce=y.forwardRef((e,r)=>{const{decorative:n,orientation:i=oU,...s}=e,o=Ont(i)?i:oU,l=n?{role:"none"}:{"aria-orientation":o==="vertical"?o:void 0,role:"separator"};return c.jsx(IS.div,{"data-orientation":o,...l,...s,ref:r})});bce.displayName=Ent;function Ont(e){return Ant.includes(e)}var _ce=bce;const w5=y.forwardRef(({className:e,orientation:r="horizontal",decorative:n=!0,...i},s)=>c.jsx(_ce,{ref:s,decorative:n,orientation:r,className:Ae("shrink-0 bg-border",r==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...i}));w5.displayName=_ce.displayName;function Mnt(e){if(Array.isArray(e))return e;if(!e)return[];try{const r=JSON.parse(e);return Array.isArray(r)?r.filter(n=>typeof n=="string"):[]}catch{return e.split(",").map(r=>r.trim()).filter(Boolean)}}function Rnt(e){return[...new Set(e.split(",").map(r=>r.trim().toLowerCase()).filter(Boolean))]}function r_(e){if(!e)return"No activity";const r=new Date(e);return Number.isNaN(r.getTime())?e:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(r)}function Pnt(){const[e,r]=y.useState(null),[n,i]=y.useState("active"),[s,o]=y.useState("all"),[a,l]=y.useState(""),[u,d]=y.useState(""),[h,f]=y.useState("none"),[g,v]=y.useState([]),[b,_]=y.useState(""),[w,S]=y.useState(""),[C,j]=y.useState(""),[E,A]=y.useState(!0),[N,P]=y.useState(!1),[H,K]=y.useState(!1),[F,B]=y.useState(null),W=y.useCallback(async()=>{A(!0),B(null);try{r(await xr.getRemindersSnapshot({status:n,limit:200})),v(await xr.listUserSecrets())}catch(ee){B(ee instanceof Error?ee.message:"Failed to load memory")}finally{A(!1)}},[n]);y.useEffect(()=>{W()},[W]);const D=(e==null?void 0:e.projects)??[],O=y.useMemo(()=>{const ee=(e==null?void 0:e.reminders)??[];return s==="all"?ee:ee.filter(ne=>ne.projectId===s)},[e==null?void 0:e.reminders,s]),I=(e==null?void 0:e.threads)??[],R=y.useMemo(()=>new Map(D.map(ee=>[ee.id,ee])),[D]),$=y.useMemo(()=>{const ee=new Map;for(const ne of D)for(const ae of ne.sessions)ee.set(ae.id,{name:ae.name,projectId:ae.projectId});return ee},[D]),U=y.useMemo(()=>({reminders:(e==null?void 0:e.reminders.length)??0,projects:D.length,sessions:D.reduce((ee,ne)=>ee+ne.sessions.length,0),threads:I.length}),[e==null?void 0:e.reminders.length,I.length,D]),Y=async()=>{const ee=a.trim();if(ee){P(!0),B(null);try{const ne=await xr.createReminder({content:ee,projectId:h==="none"?null:h,tags:Rnt(u),sourceType:"user",sourceSurface:"web"});r(ae=>ae&&{...ae,reminders:[ne,...ae.reminders]}),l(""),d("")}catch(ne){B(ne instanceof Error?ne.message:"Failed to add memory")}finally{P(!1)}}},z=async(ee,ne)=>{r(ae=>ae&&{...ae,reminders:ae.reminders.map(te=>te.id===ee.id?{...te,...ne,tags:ne.tags?JSON.stringify(ne.tags):te.tags}:te)});try{const ae=await xr.updateReminder(ee.id,ne);r(te=>te&&{...te,reminders:te.reminders.map(ue=>ue.id===ee.id?ae:ue)})}catch(ae){B(ae instanceof Error?ae.message:"Failed to update memory"),W()}},V=async ee=>{const ne=e;r(ae=>ae&&{...ae,reminders:ae.reminders.filter(te=>te.id!==ee)});try{await xr.deleteReminder(ee)}catch(ae){r(ne),B(ae instanceof Error?ae.message:"Failed to delete memory")}},Q=async()=>{const ee=b.trim(),ne=w.trim();if(!(!ee||!ne||!C)){P(!0),B(null);try{const ae=await xr.createUserSecret({type:"ssh-password",key:ne,label:ee,value:C});v(te=>[ae,...te.filter(ue=>ue.id!==ae.id)]),_(""),S(""),j("")}catch(ae){B(ae instanceof Error?ae.message:"Failed to save secret")}finally{P(!1)}}},q=async ee=>{const ne=g;v(ae=>ae.filter(te=>te.id!==ee));try{await xr.deleteUserSecret(ee)}catch(ae){v(ne),B(ae instanceof Error?ae.message:"Failed to delete secret")}},re=async()=>{B(null);try{const ee=await xr.exportMemoryMarkdown({status:n,projectId:s,limit:500});await navigator.clipboard.writeText(ee),K(!0),window.setTimeout(()=>K(!1),1400)}catch(ee){B(ee instanceof Error?ee.message:"Failed to copy memory export")}};return c.jsxs("div",{className:"mx-auto flex max-w-7xl flex-col gap-4 px-3 py-4 sm:px-4 sm:py-6",children:[c.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[c.jsxs("div",{className:"min-w-0",children:[c.jsxs("h1",{className:"flex items-center gap-2 text-xl font-bold sm:text-2xl",children:[c.jsx(Ja,{className:"h-6 w-6"}),"Memory"]}),c.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Agent-readable memory with project chat history and completed thread context."})]}),c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[c.jsxs(th,{value:n,onValueChange:ee=>i(ee),children:[c.jsx(Zu,{className:"h-10 w-full sm:w-40",children:c.jsx(rh,{})}),c.jsxs(Qu,{children:[c.jsx(Ls,{value:"active",children:"Active"}),c.jsx(Ls,{value:"archived",children:"Archived"}),c.jsx(Ls,{value:"all",children:"All"})]})]}),c.jsxs(_e,{variant:"outline",onClick:()=>void W(),disabled:E,children:[c.jsx(io,{className:Ae("mr-2 h-4 w-4",E&&"animate-spin")}),"Refresh"]}),c.jsxs(_e,{variant:"outline",onClick:()=>void re(),children:[c.jsx(ac,{className:"mr-2 h-4 w-4"}),H?"Copied":"Copy Markdown"]})]})]}),c.jsxs("div",{className:"grid grid-cols-2 gap-2 sm:flex sm:flex-wrap",children:[c.jsxs($r,{variant:"outline",className:"justify-center px-3 py-1",children:[U.reminders," memories"]}),c.jsxs($r,{variant:"secondary",className:"justify-center px-3 py-1",children:[U.projects," projects"]}),c.jsxs($r,{variant:"secondary",className:"justify-center px-3 py-1",children:[U.sessions," chats"]}),c.jsxs($r,{variant:"secondary",className:"justify-center px-3 py-1",children:[U.threads," threads"]}),c.jsxs($r,{variant:"secondary",className:"justify-center px-3 py-1",children:[g.length," secrets"]})]}),F&&c.jsx(gn,{className:"border-destructive/30 bg-destructive/10 shadow-none",children:c.jsxs(Kc,{className:"flex items-center gap-2 p-3 text-sm text-destructive",children:[c.jsx(ia,{className:"h-4 w-4 shrink-0"}),c.jsx("span",{className:"min-w-0 flex-1",children:F}),c.jsx(_e,{variant:"ghost",size:"sm",className:"shrink-0",onClick:()=>B(null),children:"Dismiss"})]})}),c.jsx(gn,{children:c.jsxs(Kc,{className:"grid gap-3 p-3 lg:grid-cols-[minmax(0,1fr)_220px_220px_auto] lg:items-end",children:[c.jsxs("div",{className:"min-w-0 space-y-2",children:[c.jsx(di,{htmlFor:"new-reminder-content",children:"Memory"}),c.jsx(jp,{id:"new-reminder-content",value:a,onChange:ee=>l(ee.target.value),placeholder:"Add agent-readable memory...",className:"min-h-20 lg:min-h-10"})]}),c.jsxs("div",{className:"min-w-0 space-y-2",children:[c.jsx(di,{children:"Project"}),c.jsxs(th,{value:h,onValueChange:f,children:[c.jsx(Zu,{className:"h-10",children:c.jsx(rh,{placeholder:"Project"})}),c.jsxs(Qu,{children:[c.jsx(Ls,{value:"none",children:"No project"}),D.map(ee=>c.jsx(Ls,{value:ee.id,children:ee.title||ee.rootPath||"Untitled project"},ee.id))]})]})]}),c.jsxs("div",{className:"min-w-0 space-y-2",children:[c.jsx(di,{htmlFor:"new-reminder-tags",children:"Tags"}),c.jsx(Pn,{id:"new-reminder-tags",value:u,onChange:ee=>d(ee.target.value),placeholder:"tags, comma separated"})]}),c.jsxs(_e,{onClick:()=>void Y(),disabled:N||!a.trim(),className:"lg:self-end",children:[N?c.jsx(Vt,{className:"mr-2 h-4 w-4 animate-spin"}):c.jsx(qs,{className:"mr-2 h-4 w-4"}),"Add"]})]})}),c.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,1fr)_420px]",children:[c.jsxs("div",{className:"min-w-0 space-y-3",children:[c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[c.jsx("h2",{className:"text-sm font-semibold uppercase tracking-normal text-muted-foreground",children:"Memory List"}),c.jsxs(th,{value:s,onValueChange:o,children:[c.jsx(Zu,{className:"h-10 w-full sm:w-64",children:c.jsx(rh,{})}),c.jsxs(Qu,{children:[c.jsx(Ls,{value:"all",children:"All projects"}),D.map(ee=>c.jsx(Ls,{value:ee.id,children:ee.title||ee.rootPath||"Untitled project"},ee.id))]})]})]}),E&&!e?c.jsx("div",{className:"flex items-center justify-center py-24",children:c.jsx(Vt,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):O.length===0?c.jsx(gn,{className:"border-2 border-dashed shadow-none",children:c.jsxs(Kc,{className:"px-4 py-16 text-center",children:[c.jsx(Ja,{className:"mx-auto mb-4 h-10 w-10 text-muted-foreground"}),c.jsx("h3",{className:"mb-2 text-lg font-medium",children:"No memory matches"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Change filters or add the first memory entry."})]})}):O.map(ee=>{const ne=ee.projectId?R.get(ee.projectId):null,ae=ee.sessionId?$.get(ee.sessionId):null,te=Mnt(ee.tags),ue=`${ee.sourceType}:${ee.sourceId||"none"}@${ee.sourceSurface}`;return c.jsx(gn,{children:c.jsxs(Kc,{className:"p-3",children:[c.jsx(jp,{className:"min-h-20",defaultValue:ee.content,onBlur:he=>{const we=he.target.value.trim();we&&we!==ee.content&&z(ee,{content:we})}}),c.jsxs("div",{className:"mt-3 flex flex-col gap-2 text-xs text-muted-foreground sm:flex-row sm:flex-wrap sm:items-center",children:[c.jsxs("span",{className:"inline-flex items-center gap-1",children:[c.jsx(Pve,{className:"h-3.5 w-3.5"}),ne?ne.title||ne.rootPath||"Project":"Global memory"]}),ae&&c.jsxs("span",{className:"inline-flex items-center gap-1",children:[c.jsx(Ud,{className:"h-3.5 w-3.5"}),ae.name||"Chat"]}),c.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1",title:ue,children:[c.jsx(Ud,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"truncate",children:ue})]}),c.jsxs("span",{className:"inline-flex items-center gap-1",title:"Usage count",children:[c.jsx(k0e,{className:"h-3.5 w-3.5"}),ee.usageCount??0," uses"]}),c.jsxs("span",{className:"inline-flex items-center gap-1",children:[c.jsx(FD,{className:"h-3.5 w-3.5"}),"Updated ",r_(ee.updatedAt)]}),c.jsxs("span",{className:"inline-flex items-center gap-1",children:[c.jsx(FD,{className:"h-3.5 w-3.5"}),"Retrieved ",r_(ee.lastRetrievedAt)]})]}),te.length>0&&c.jsx("div",{className:"mt-3 flex flex-wrap gap-1.5",children:te.map(he=>c.jsx($r,{variant:"secondary",className:"rounded-md",children:he},he))}),c.jsx(w5,{className:"my-3"}),c.jsxs("div",{className:"flex flex-wrap gap-2",children:[c.jsxs(_e,{variant:"outline",size:"sm",onClick:()=>void z(ee,{status:ee.status==="active"?"archived":"active"}),children:[ee.status==="active"?c.jsx(hR,{className:"mr-2 h-4 w-4"}):c.jsx(uo,{className:"mr-2 h-4 w-4"}),ee.status==="active"?"Archive":"Restore"]}),c.jsxs(_e,{variant:"outline",size:"sm",onClick:()=>void V(ee.id),children:[c.jsx(Tl,{className:"mr-2 h-4 w-4"}),"Delete"]})]})]})},ee.id)})]}),c.jsx("div",{className:"min-w-0",children:c.jsxs(Y0,{defaultValue:"projects",className:"min-w-0",children:[c.jsxs(ag,{className:"grid w-full grid-cols-3",children:[c.jsx(so,{value:"projects",children:"Projects"}),c.jsx(so,{value:"threads",children:"Threads"}),c.jsx(so,{value:"secrets",children:"Secrets"})]}),c.jsx(oo,{value:"projects",className:"mt-3",children:c.jsx(Jc,{className:"max-h-[42rem] pr-1",children:c.jsxs("div",{className:"space-y-2",children:[D.map(ee=>c.jsx(gn,{children:c.jsxs(Kc,{className:"p-3",children:[c.jsxs("div",{className:"flex items-start justify-between gap-3",children:[c.jsxs("div",{className:"min-w-0",children:[c.jsx("div",{className:"truncate text-sm font-medium",children:ee.title||ee.rootPath||"Untitled project"}),c.jsx("div",{className:"truncate text-xs text-muted-foreground",children:ee.rootPath||ee.nodeId||"No path"})]}),c.jsx($r,{variant:"outline",className:"shrink-0",children:ee.reminderCount})]}),c.jsx(w5,{className:"my-3"}),c.jsxs("div",{className:"space-y-1.5",children:[ee.sessions.slice(0,6).map(ne=>c.jsxs("div",{className:"flex items-center justify-between gap-2 text-xs",children:[c.jsx("span",{className:"min-w-0 truncate",children:ne.name||"Chat"}),c.jsx("span",{className:"shrink-0 text-muted-foreground",children:r_(ne.lastActiveAt)})]},ne.id)),ee.sessions.length===0&&c.jsx("div",{className:"text-xs text-muted-foreground",children:"No chats yet"})]})]})},ee.id)),D.length===0&&c.jsx(gn,{className:"border-2 border-dashed shadow-none",children:c.jsx(Kc,{className:"p-6 text-center text-sm text-muted-foreground",children:"No projects yet"})})]})})}),c.jsx(oo,{value:"threads",className:"mt-3",children:c.jsx(Jc,{className:"max-h-[42rem] pr-1",children:c.jsxs("div",{className:"space-y-2",children:[I.slice(0,12).map(ee=>c.jsx(gn,{children:c.jsx(Kc,{className:"p-3",children:c.jsxs("div",{className:"flex items-start justify-between gap-3",children:[c.jsxs("div",{className:"min-w-0",children:[c.jsx("div",{className:"truncate text-sm font-medium",children:ee.title}),c.jsxs("div",{className:"truncate text-xs text-muted-foreground",children:[ee.providerId," · ",r_(ee.updatedAt)]})]}),c.jsx($r,{variant:ee.status==="completed"?"secondary":"outline",className:"shrink-0",children:ee.status})]})})},ee.id)),I.length===0&&c.jsx(gn,{className:"border-2 border-dashed shadow-none",children:c.jsx(Kc,{className:"p-6 text-center text-sm text-muted-foreground",children:"No past threads yet"})})]})})}),c.jsx(oo,{value:"secrets",className:"mt-3",children:c.jsx(gn,{children:c.jsxs(Kc,{className:"space-y-3 p-3",children:[c.jsxs("div",{className:"grid gap-2",children:[c.jsx(Pn,{value:b,onChange:ee=>_(ee.target.value),placeholder:"Label"}),c.jsx(Pn,{value:w,onChange:ee=>S(ee.target.value),placeholder:"SSH key, for example jakob@192.168.178.53:22"}),c.jsx(Pn,{type:"password",value:C,onChange:ee=>j(ee.target.value),placeholder:"Password"}),c.jsxs(_e,{onClick:()=>void Q(),disabled:N||!b.trim()||!w.trim()||!C,children:[N?c.jsx(Vt,{className:"mr-2 h-4 w-4 animate-spin"}):c.jsx(Qye,{className:"mr-2 h-4 w-4"}),"Save Secret"]})]}),c.jsx(w5,{}),c.jsx(Jc,{className:"max-h-[30rem] pr-1",children:c.jsxs("div",{className:"space-y-2",children:[g.map(ee=>c.jsx(gn,{children:c.jsx(Kc,{className:"p-3",children:c.jsxs("div",{className:"flex items-start justify-between gap-3",children:[c.jsxs("div",{className:"min-w-0",children:[c.jsx("div",{className:"truncate text-sm font-medium",children:ee.label}),c.jsxs("div",{className:"truncate text-xs text-muted-foreground",children:[ee.type," · ",ee.key]}),c.jsxs("div",{className:"mt-1 text-xs text-muted-foreground",children:["Last used ",r_(ee.lastUsedAt)]})]}),c.jsx(_e,{variant:"ghost",size:"sm",className:"shrink-0",onClick:()=>void q(ee.id),children:c.jsx(Tl,{className:"h-4 w-4"})})]})})},ee.id)),g.length===0&&c.jsx(gn,{className:"border-2 border-dashed shadow-none",children:c.jsx(Kc,{className:"p-6 text-center text-sm text-muted-foreground",children:"No saved secrets"})})]})})]})})})]})})]})]})}function aU({status:e}){switch(e){case"A":case"?":return c.jsx(G3,{className:"h-3.5 w-3.5 text-green-500 shrink-0"});case"D":return c.jsx(Mye,{className:"h-3.5 w-3.5 text-red-500 shrink-0"});case"R":return c.jsx(Tye,{className:"h-3.5 w-3.5 text-blue-500 shrink-0"});default:return c.jsx(mY,{className:"h-3.5 w-3.5 text-yellow-500 shrink-0"})}}function lU(e){switch(e){case"A":return"Added";case"?":return"Untracked";case"D":return"Deleted";case"R":return"Renamed";default:return"Modified"}}function Lnt({cwd:e,baseBranch:r,branch:n,onClose:i}){const[s,o]=y.useState([]),[a,l]=y.useState(!0),[u,d]=y.useState(0),[h,f]=y.useState(()=>typeof window<"u"&&window.innerWidth<960);y.useEffect(()=>{let _=!1;return l(!0),$s.fileDiffs(e,r,n).then(w=>{_||(o(w),d(0))}).catch(()=>{_||o([])}).finally(()=>{_||l(!1)}),()=>{_=!0}},[r,n,e]),y.useEffect(()=>{const _=()=>f(window.innerWidth<960);return _(),window.addEventListener("resize",_),()=>window.removeEventListener("resize",_)},[]);const g=s[u]??null,v=g?p2(g.path):"plaintext",b=y.useCallback(_=>{_.key==="Escape"?i():_.key==="ArrowDown"||_.key==="j"?(_.preventDefault(),d(w=>Math.min(w+1,s.length-1))):(_.key==="ArrowUp"||_.key==="k")&&(_.preventDefault(),d(w=>Math.max(w-1,0)))},[i,s.length]);return c.jsx("div",{className:"fixed inset-0 z-[100] bg-background/80 backdrop-blur-sm flex items-center justify-center p-4",onKeyDown:b,tabIndex:-1,children:c.jsxs("div",{className:"bg-popover border rounded-lg shadow-xl w-full max-w-6xl h-[85vh] flex flex-col",children:[c.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 border-b shrink-0",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(mY,{className:"h-4 w-4 text-muted-foreground"}),c.jsx("h3",{className:"text-sm font-medium",children:"Changes"}),!a&&c.jsxs("span",{className:"text-xs text-muted-foreground",children:[s.length," file",s.length!==1?"s":""," changed"]})]}),c.jsx(_e,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:i,children:c.jsx(Vn,{className:"h-4 w-4"})})]}),a?c.jsx("div",{className:"flex-1 flex items-center justify-center",children:c.jsx(Vt,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):s.length===0?c.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"No changes detected."}):c.jsxs("div",{className:Ae("flex-1 flex min-h-0",h&&"flex-col"),children:[c.jsxs("div",{className:Ae("border-r flex flex-col shrink-0 bg-muted/20",h?"w-full border-r-0 border-b max-h-40":"w-56"),children:[c.jsx("div",{className:"px-3 py-2 border-b",children:c.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Files"})}),c.jsx("div",{className:"flex-1 overflow-y-auto",children:s.map((_,w)=>c.jsxs("button",{className:Ae("flex items-center gap-2 w-full px-3 py-1.5 text-left text-xs hover:bg-accent/50 transition-colors",w===u&&"bg-accent"),onClick:()=>d(w),title:`${_.path} (${lU(_.status)})`,children:[c.jsx(aU,{status:_.status}),c.jsx("span",{className:"truncate font-mono",children:_.path.split(/[/\\]/).pop()})]},_.path))})]}),c.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b bg-muted/10 shrink-0",children:[c.jsx(aU,{status:(g==null?void 0:g.status)??"M"}),c.jsx("span",{className:"text-xs font-mono text-muted-foreground truncate",children:g==null?void 0:g.path}),c.jsx("span",{className:Ae("text-2xs px-1.5 py-0.5 rounded font-medium",(g==null?void 0:g.status)==="A"||(g==null?void 0:g.status)==="?"?"bg-green-500/10 text-green-500":(g==null?void 0:g.status)==="D"?"bg-red-500/10 text-red-500":"bg-yellow-500/10 text-yellow-500"),children:lU((g==null?void 0:g.status)??"M")})]}),c.jsx("div",{className:"flex-1 min-h-0",children:g&&c.jsx(Dw,{original:g.original,modified:g.modified,language:v,modelKey:g.path,className:"h-full",editorClassName:"h-full",renderSideBySide:!h,options:{readOnly:!0,minimap:{enabled:!1},renderOverviewRuler:!0,ignoreTrimWhitespace:!1,enableSplitViewResizing:!0}},g.path)})]})]})]})})}const cU={github:{placeholder:"ghp_... or github_pat_...",createUrl:"https://github.com/settings/tokens/new?scopes=repo,read:org,workflow&description=Jait+CLI",createLabel:"Create a GitHub token",scopes:"repo, read:org, and workflow",cliName:"gh",cliUrl:"https://cli.github.com"},gitlab:{placeholder:"glpat-...",createUrl:"https://gitlab.com/-/user_settings/personal_access_tokens",createLabel:"Create a GitLab token",scopes:"api and write_repository",cliName:"glab",cliUrl:"https://gitlab.com/gitlab-org/cli"},gitea:{placeholder:"your-gitea-token",createUrl:"",createLabel:"Create a token in your Gitea settings",scopes:"repo access",cliName:"tea",cliUrl:"https://gitea.com/gitea/tea"},"azure-devops":{placeholder:"your-azure-devops-pat",createUrl:"https://dev.azure.com/_usersSettings/tokens",createLabel:"Create an Azure DevOps PAT",scopes:"Code (Read & Write)",cliName:"az",cliUrl:"https://learn.microsoft.com/en-us/cli/azure/install-azure-cli"},bitbucket:{placeholder:"your-bitbucket-app-password",createUrl:"https://bitbucket.org/account/settings/app-passwords/",createLabel:"Create a Bitbucket app password",scopes:"Repositories (Read/Write) and Pull Requests (Read/Write)"}};function $nt({open:e,onOpenChange:r,cwd:n,remoteUrl:i,onReady:s}){const[o,a]=y.useState("checking"),[l,u]=y.useState(null),[d,h]=y.useState(""),[f,g]=y.useState(null),v=(l==null?void 0:l.provider)??"github",b=(l==null?void 0:l.forgeName)??"Git Forge",_=cU[v]??cU.github,w=y.useCallback(async()=>{a("checking"),g(null);try{const j=await $s.forgeStatus(n,i);u(j),!j.installed&&!j.authenticated?a("not-installed"):j.authenticated?a("success"):a("not-authenticated")}catch(j){g(j instanceof Error?j.message:"Failed to check forge status"),a("error")}},[n,i]);y.useEffect(()=>{e&&(w(),h(""))},[e,w]);const S=y.useCallback(async()=>{if(d.trim()){a("authenticating"),g(null);try{const j=await $s.forgeAuth(d.trim(),n,i);j.ok?(u(E=>E&&{...E,authenticated:!0,username:j.username}),a("success"),h("")):(g(j.error??"Authentication failed — check your token permissions."),a("not-authenticated"))}catch(j){g(j instanceof Error?j.message:"Authentication failed"),a("not-authenticated")}}},[d,n,i]),C=y.useCallback(()=>{r(!1),s==null||s()},[r,s]);return c.jsx(El,{open:e,onOpenChange:r,children:c.jsxs(sl,{className:"max-w-md",children:[c.jsxs(pc,{children:[c.jsxs(ol,{children:[b," Setup"]}),c.jsxs(rd,{children:["Pull request creation requires authentication with ",b,"."]})]}),o==="checking"&&c.jsxs("div",{className:"flex items-center gap-3 py-4",children:[c.jsx(Vt,{className:"h-5 w-5 animate-spin text-muted-foreground"}),c.jsxs("span",{className:"text-sm text-muted-foreground",children:["Checking ",b," status…"]})]}),(o==="not-installed"||o==="not-authenticated")&&c.jsxs("div",{className:"space-y-4 py-2",children:[c.jsxs("div",{className:"flex items-start gap-3",children:[c.jsx(sh,{className:`h-5 w-5 mt-0.5 shrink-0 ${o==="not-installed"?"text-red-500":"text-amber-500"}`}),c.jsxs("div",{className:"space-y-1",children:[c.jsx("p",{className:"text-sm font-medium",children:o==="not-installed"?`${b} CLI not detected`:`${b} is not authenticated`}),c.jsxs("p",{className:"text-xs text-muted-foreground",children:["Paste a Personal Access Token with ",_.scopes," scope to sign in."]})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(di,{htmlFor:"forge-token",className:"text-xs",children:"Personal Access Token"}),c.jsx(Pn,{id:"forge-token",type:"password",placeholder:_.placeholder,value:d,onChange:j=>h(j.target.value),onKeyDown:j=>{j.key==="Enter"&&S()},autoFocus:!0}),c.jsxs("p",{className:"text-2xs text-muted-foreground",children:[_.createUrl?c.jsx("a",{href:_.createUrl,target:"_blank",rel:"noopener noreferrer",className:"underline hover:text-foreground",children:_.createLabel}):c.jsx("span",{children:_.createLabel})," ","with ",c.jsx("code",{className:"text-2xs",children:_.scopes})," permissions."]})]}),o==="not-installed"&&_.cliName&&_.cliUrl&&c.jsxs("p",{className:"text-2xs text-muted-foreground",children:["Optionally install the ",c.jsx("code",{className:"text-2xs",children:_.cliName})," CLI:"," ",c.jsx("a",{href:_.cliUrl,target:"_blank",rel:"noopener noreferrer",className:"underline hover:text-foreground",children:_.cliUrl})]}),f&&c.jsx("p",{className:"text-xs text-red-500",children:f})]}),o==="authenticating"&&c.jsxs("div",{className:"flex items-center gap-3 py-4",children:[c.jsx(Vt,{className:"h-5 w-5 animate-spin text-muted-foreground"}),c.jsxs("span",{className:"text-sm text-muted-foreground",children:["Authenticating with ",b,"…"]})]}),o==="success"&&c.jsxs("div",{className:"flex items-start gap-3 py-4",children:[c.jsx(uo,{className:"h-5 w-5 text-green-500 mt-0.5 shrink-0"}),c.jsxs("div",{className:"space-y-1",children:[c.jsxs("p",{className:"text-sm font-medium",children:["Authenticated",l!=null&&l.username?` as ${l.username}`:""," on ",b]}),c.jsx("p",{className:"text-xs text-muted-foreground",children:"You can now create pull requests."})]})]}),o==="error"&&c.jsxs("div",{className:"flex items-start gap-3 py-4",children:[c.jsx(sh,{className:"h-5 w-5 text-red-500 mt-0.5 shrink-0"}),c.jsxs("div",{className:"space-y-1",children:[c.jsx("p",{className:"text-sm font-medium",children:"Something went wrong"}),f&&c.jsx("p",{className:"text-xs text-muted-foreground",children:f})]})]}),c.jsxs(bg,{children:[(o==="not-installed"||o==="not-authenticated"||o==="error")&&c.jsxs(c.Fragment,{children:[o==="error"&&c.jsx(_e,{variant:"outline",size:"sm",onClick:()=>void w(),children:"Re-check"}),c.jsx(_e,{size:"sm",disabled:!d.trim(),onClick:()=>void S(),children:"Sign in"})]}),o==="success"&&c.jsx(_e,{size:"sm",onClick:C,children:"Continue"})]})]})})}const Dnt=$nt;function wce(e,r,n,i){return e?r==="creating"||r==="open"||r==="merged"||r==="closed"||i!=null&&i.branch&&i.branch!==e?!0:n==="completed"?!((i==null?void 0:i.branch)===e&&i.hasWorkingTreeChanges):!1:!1}function uU(e,r,n,i,s){return r?wce(r,n,i,s)?{baseBranch:e,branch:r}:{baseBranch:e}:{}}function Int(e){return e!=="creating"}function dU(e,r,n){return e==null||r==null||n==null?null:{insertions:r,deletions:n,hasChanges:e>0}}function Bnt(e,r,n){return e?e.hasWorkingTreeChanges||!(n==="merged"||n==="closed")?!0:!!r:!1}function znt({hasRepository:e,threadKind:r,threadStatus:n,threadBranch:i,prUrl:s,prState:o}){return!e||r!=="delivery"?!1:!!(i||n==="completed"||s||o==="creating"||o==="open")}function Fnt({insertions:e,deletions:r}){return c.jsxs("span",{className:"inline-flex items-center gap-1 font-medium tabular-nums",children:[c.jsxs("span",{className:"text-green-600 dark:text-green-400",children:["+",e]}),c.jsxs("span",{className:"text-red-600 dark:text-red-400",children:["-",r]})]})}function rL({threadId:e,cwd:r,branch:n,baseBranch:i,threadTitle:s,prUrl:o,prState:a,threadStatus:l,threadKind:u="delivery",showStatusBadge:d=!0,changeFiles:h,changeInsertions:f,changeDeletions:g}){var ue;const v=ex(),b=dU(h,f,g),[_,w]=y.useState(!1),[S,C]=y.useState(!1),[j,E]=y.useState(!1),[A,N]=y.useState(null),[P,H]=y.useState(()=>b),K=y.useRef(!1),F=y.useRef(!1),[B,W]=y.useState(o?{url:o,kind:"created"}:null);y.useEffect(()=>{W(he=>o?{url:o,kind:"created"}:(he==null?void 0:he.kind)==="create"?he:null)},[o]),y.useEffect(()=>{let he=!1;return Int(a)?((async()=>{try{const pe=await $s.status(r,n??void 0);if(he)return;N(pe);const qe=dU(h,f,g);if(qe){H(qe);return}const se=uU(i,n,a,l,pe),it=n?await $s.diffStats(r,se.baseBranch,se.branch).catch(()=>null):null;if(he)return;if(it){H({insertions:it.insertions,deletions:it.deletions,hasChanges:it.hasChanges});return}if(n){H(null);return}H({insertions:pe.index.insertions+pe.workingTree.insertions,deletions:pe.index.deletions+pe.workingTree.deletions,hasChanges:pe.hasWorkingTreeChanges})}catch{he||(N(null),H(null))}})(),()=>{he=!0}):void 0},[i,n,g,h,f,r,a,o,l]);const[D,O]=y.useState(null),I=y.useRef(null);y.useEffect(()=>{if(!n||!o||a==="merged"||a==="closed"){O(null),I.current&&(clearInterval(I.current),I.current=null);return}const he=async()=>{try{const we=await $s.prChecks(r,n);if(!we||we.length===0){O(null);return}const pe=we.some(se=>se.conclusion==="failure"||se.conclusion==="cancelled"),qe=we.some(se=>se.state==="PENDING"||se.state==="QUEUED"||se.state==="IN_PROGRESS"||!se.conclusion);O(pe?"failing":qe?"pending":"passing")}catch{}};return he(),I.current=setInterval(he,15e3),()=>{I.current&&(clearInterval(I.current),I.current=null)}},[n,r,o,a]);const R=B??(o?{url:o,kind:"created"}:null)??((ue=A==null?void 0:A.pr)!=null&&ue.url?{url:A.pr.url,kind:"created"}:null),$=a==="creating"&&(R==null?void 0:R.kind)==="created"?"open":a,U=wce(n,$,l,A),Y=uU(i,n,$,l,A),z=$==="creating",V=b??P,Q=U?!!(V!=null&&V.hasChanges):Bnt(A,n,$),q=z&&!R?"Creating PR...":R?R.kind==="created"?"Open PR":"Open PR Page":"Create Pull Request",re=z&&!R?"Creating pull request":R?q:"Create pull request",ee=u==="delivery"&&(R!=null||l==="completed"),ne=_||z,ae=y.useCallback(async()=>{if(R){window.open(R.url,"_blank");return}if(l!=="completed"){An.error("Thread not completed",{description:"Finish the thread before creating a pull request."});return}if(u!=="delivery"){An.error("PR creation unavailable",{description:"Delegation threads are helper workers and do not create pull requests."});return}if(w(!0),!F.current)try{if((await $s.status(r)).prProvider==="github"){const we=await $s.ghStatus(r);if(!we.installed||!we.authenticated){w(!1),K.current=!0,E(!0);return}}}catch{}F.current=!1;try{const he=s.replace(/^\[.*?\]\s*/,""),we=await xr.createPullRequest(e,{commitMessage:he,baseBranch:i}),pe=we.result;we.pushFailed?we.resumed?An.info("Push failed — thread resumed",{description:"The agent is investigating the push failure and will fix the issue."}):An.error("Push failed",{description:we.error??"Git push failed. Re-open the thread to fix the issue."}):pe.pr.url?W({url:pe.pr.url,kind:"created"}):pe.push.createPrUrl&&W({url:pe.push.createPrUrl,kind:"create"})}catch(he){An.error("Failed",{description:he instanceof Error?he.message:"Unknown error"})}finally{w(!1)}},[i,r,e,u,l,s,R]),te=y.useCallback(()=>{K.current&&(K.current=!1,F.current=!0,ae())},[ae]);return c.jsxs(c.Fragment,{children:[c.jsx(Dnt,{open:j,onOpenChange:E,cwd:r,onReady:te}),c.jsxs("div",{className:"inline-flex items-center gap-1",children:[Q&&V&&c.jsxs(_e,{variant:"ghost",size:"sm",className:"h-7 gap-1 px-2 text-xs sm:h-6 sm:text-2xs",onClick:()=>C(!0),title:"View changes","aria-label":`View changes: +${V.insertions} -${V.deletions}`,children:[c.jsx(Fnt,{insertions:V.insertions,deletions:V.deletions}),!v&&"Changes"]}),c.jsxs(_e,{variant:"ghost",size:"sm",className:"h-7 min-w-8 gap-1 px-2 text-xs sm:h-6 sm:min-w-7 sm:text-2xs",disabled:ne||!ee,onClick:ae,title:u!=="delivery"?"Delegation threads do not create pull requests.":!R&&l!=="completed"?"Finish the thread before creating a pull request.":re,"aria-label":re,children:[ne?c.jsx(Vt,{className:"h-3.5 w-3.5 animate-spin sm:h-3 sm:w-3"}):c.jsx(Wye,{className:"h-3.5 w-3.5 sm:h-3 sm:w-3"}),!v&&q]}),d&&R&&c.jsx($r,{variant:"outline",className:`h-5 px-1.5 text-2xs font-medium ${$==="merged"?"border-purple-500/40 text-purple-700 bg-purple-500/10 dark:text-purple-300 dark:bg-purple-500/20 dark:border-purple-400/40":$==="closed"?"border-red-500/40 text-red-700 bg-red-500/10 dark:text-red-300 dark:bg-red-500/20 dark:border-red-400/40":$==="creating"?"border-amber-500/40 text-amber-700 bg-amber-500/10 dark:text-amber-300 dark:bg-amber-500/20 dark:border-amber-400/40":R.kind==="created"?"border-green-500/40 text-green-700 dark:text-green-300 dark:border-green-400/40":"border-amber-500/40 text-amber-700 dark:text-amber-300 dark:border-amber-400/40"}`,children:$==="merged"?"PR merged":$==="closed"?"PR closed":$==="creating"?"PR creating":R.kind==="created"?"PR open":"PR ready to open"}),d&&(R==null?void 0:R.kind)==="created"&&$==="open"&&D&&c.jsxs($r,{variant:"outline",className:`h-5 px-1.5 text-2xs font-medium inline-flex items-center gap-0.5 ${D==="failing"?"border-red-500/40 text-red-700 bg-red-500/10 dark:text-red-300 dark:bg-red-500/20 dark:border-red-400/40":D==="pending"?"border-amber-500/40 text-amber-700 bg-amber-500/10 dark:text-amber-300 dark:bg-amber-500/20 dark:border-amber-400/40":"border-green-500/40 text-green-700 bg-green-500/10 dark:text-green-300 dark:bg-green-500/20 dark:border-green-400/40"}`,children:[D==="failing"?c.jsx(sh,{className:"h-3 w-3"}):D==="pending"?c.jsx(xg,{className:"h-3 w-3"}):c.jsx(uo,{className:"h-3 w-3"}),D==="failing"?"Checks failing":D==="pending"?"Checks pending":"Checks passed"]})]}),S&&c.jsx(Lnt,{cwd:r,baseBranch:Y.baseBranch,branch:Y.branch,onClose:()=>C(!1)})]})}const Hnt={bundled:"bg-sky-500/10 text-sky-600",user:"bg-amber-500/10 text-amber-600",project:"bg-emerald-500/10 text-emerald-600",plugin:"bg-fuchsia-500/10 text-fuchsia-600"},Wnt=[{pattern:/\b(debug|bug|troubleshoot|fix)\b/i,icon:pA},{pattern:/\b(review|audit|security|secure|vuln)\b/i,icon:d1e},{pattern:/\b(test|qa|spec)\b/i,icon:wve},{pattern:/\b(perf|performance|optimi[sz]e|latency|profil)\b/i,icon:mA},{pattern:/\b(arch|design|system|topology|diagram)\b/i,icon:oc},{pattern:/\b(research|investigate|search|explore)\b/i,icon:tl},{pattern:/\b(data|analysis|analytics|report)\b/i,icon:mA},{pattern:/\b(code|generate|scaffold|tool|workflow)\b/i,icon:_R}];function Unt(e){const r=`${e.id} ${e.name} ${e.description}`,n=Wnt.find(({pattern:i})=>i.test(r));return{icon:(n==null?void 0:n.icon)??P0e,className:Hnt[e.source]}}function Vnt(e){return e.open&&!e.attemptedLoad&&e.skillsLength===0&&!e.loading}const qnt=Kn();function Gnt({token:e,threadId:r,selectedSkillIds:n}){const[i,s]=y.useState(!1),[o,a]=y.useState([]),[l,u]=y.useState(!1),[d,h]=y.useState(null),[f,g]=y.useState(!1),[v,b]=y.useState(!1),_=y.useCallback(async()=>{u(!0),h(null);try{const A={};e&&(A.Authorization=`Bearer ${e}`);const N=await fetch(`${qnt}/api/skills`,{headers:A});if(!N.ok)throw new Error(`Failed to load skills (HTTP ${N.status})`);const P=await N.json();a(P)}catch(A){h(A instanceof Error?A.message:"Failed to load skills")}finally{u(!1),g(!0)}},[e]);y.useEffect(()=>{Vnt({open:i,attemptedLoad:f,skillsLength:o.length,loading:l})&&_()},[f,_,l,i,o.length]);const w=y.useMemo(()=>o.filter(A=>A.enabled),[o]),S=n??w.map(A=>A.id),C=n===null,j=y.useCallback(async A=>{b(!0);try{await xr.updateThread(r,{skillIds:A})}finally{b(!1)}},[r]),E=y.useCallback(async(A,N)=>{const P=N?[...new Set([...S,A])]:S.filter(H=>H!==A);await j(P)},[S,j]);return c.jsxs(E9,{open:i,onOpenChange:s,children:[c.jsx(A9,{asChild:!0,children:c.jsxs(_e,{variant:"ghost",size:"sm",className:"h-6 gap-1 px-2 text-[10px] text-muted-foreground",children:[c.jsx(r1e,{className:"h-3 w-3"}),C?"Skills:auto":`Skills:${(n==null?void 0:n.length)??0}`]})}),c.jsxs(O9,{align:"end",className:"w-80 space-y-3 p-3",children:[c.jsxs("div",{className:"flex items-start justify-between gap-2",children:[c.jsxs("div",{children:[c.jsx("p",{className:"text-sm font-medium",children:"Thread skills"}),c.jsx("p",{className:"text-xs text-muted-foreground",children:C?"Uses globally enabled skills.":"Uses only pinned skills for this thread."})]}),C?c.jsx($r,{variant:"secondary",className:"text-[10px]",children:"global"}):c.jsx($r,{variant:"outline",className:"text-[10px]",children:"custom"})]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(_e,{size:"sm",variant:C?"secondary":"outline",className:"h-7 text-xs",disabled:v,onClick:()=>void j(null),children:"Global"}),c.jsx(_e,{size:"sm",variant:!C&&((n==null?void 0:n.length)??0)===0?"secondary":"outline",className:"h-7 text-xs",disabled:v,onClick:()=>void j([]),children:"None"})]}),l?c.jsxs("div",{className:"flex items-center gap-2 py-4 text-sm text-muted-foreground",children:[c.jsx(Vt,{className:"h-4 w-4 animate-spin"}),"Loading skills..."]}):d?c.jsxs("div",{className:"space-y-3 rounded-lg border border-destructive/50 bg-destructive/5 p-3",children:[c.jsxs("div",{className:"flex items-start gap-2 text-sm text-destructive",children:[c.jsx(ia,{className:"mt-0.5 h-4 w-4 shrink-0"}),c.jsx("span",{children:d})]}),c.jsx(_e,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:()=>{g(!1),_()},children:"Retry"})]}):w.length===0?c.jsx("div",{className:"rounded-lg border border-dashed p-4 text-xs text-muted-foreground",children:"No enabled skills. Install/enable ClawHub skills in Settings."}):c.jsx("div",{className:"max-h-64 space-y-2 overflow-y-auto pr-1",children:w.map(A=>{const N=S.includes(A.id),P=Unt(A),H=P.icon;return c.jsxs("div",{className:"flex items-start gap-3 rounded-lg border p-2.5",children:[c.jsx("div",{className:`mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-md ${P.className}`,children:c.jsx(H,{className:"h-3.5 w-3.5"})}),c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsx("p",{className:"truncate text-sm font-medium",children:A.name}),c.jsx("p",{className:"line-clamp-2 text-xs text-muted-foreground",children:A.description})]}),c.jsx(Ap,{checked:N,disabled:v||C,onCheckedChange:K=>{E(A.id,K)}})]},A.id)})})]})]})}function Knt({open:e,onOpenChange:r,repoId:n,repoName:i}){const s=_g(),[o,a]=y.useState(""),[l,u]=y.useState(""),[d,h]=y.useState(!1),[f,g]=y.useState(!1),[v,b]=y.useState(!1),[_,w]=y.useState(null),S=o!==l,C=ik();y.useEffect(()=>{if(!e||!n)return;let P=!1;return h(!0),w(null),xr.getRepoStrategy(n).then(H=>{P||(a(H),u(H))}).catch(H=>{P||w(H instanceof Error?H.message:"Failed to load strategy")}).finally(()=>{P||h(!1)}),()=>{P=!0}},[e,n]);const j=y.useCallback(async()=>{g(!0),w(null);try{const P=await xr.updateRepoStrategy(n,o);u(P),a(P)}catch(P){w(P instanceof Error?P.message:"Failed to save strategy")}finally{g(!1)}},[n,o]),E=y.useCallback(async()=>{b(!0),w(null);try{const P=await xr.generateRepoStrategy(n);P&&a(P)}catch(P){w(P instanceof Error?P.message:"Failed to generate strategy")}finally{b(!1)}},[n]),A=y.useCallback(()=>{a(l)},[l]),N=y.useCallback(P=>{if(P||!S){r(P);return}(async()=>await s({title:"Discard changes",description:"You have unsaved changes. Discard them?",confirmLabel:"Discard",variant:"destructive"})&&r(!1))()},[s,S,r]);return c.jsx(El,{open:e,onOpenChange:N,children:c.jsxs(sl,{className:"flex max-h-[85vh] w-full max-w-3xl flex-col gap-0 overflow-hidden p-0",children:[c.jsx(pc,{className:"shrink-0 border-b px-4 py-3",children:c.jsxs(ol,{className:"flex items-center gap-2 text-sm",children:[c.jsx("span",{children:"Strategy"}),c.jsx("span",{className:"text-muted-foreground",children:"—"}),c.jsx("span",{className:"font-normal text-muted-foreground",children:i}),S&&c.jsx("span",{className:"ml-1 rounded bg-amber-500/10 px-1.5 py-0.5 text-2xs text-amber-600 dark:text-amber-400",children:"unsaved"})]})}),c.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[d?c.jsx("div",{className:"flex flex-1 items-center justify-center py-12",children:c.jsx(Vt,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):c.jsxs("div",{className:"relative min-h-0 flex-1",children:[c.jsx(sk,{height:"55vh",language:"markdown",beforeMount:P=>fc(P,C),theme:C,value:o,onChange:P=>a(P??""),options:{minimap:{enabled:!1},"semanticHighlighting.enabled":!0,lineNumbers:"off",wordWrap:"on",fontSize:13,padding:{top:12,bottom:12},scrollBeyondLastLine:!1,renderLineHighlight:"none",overviewRulerLanes:0,folding:!0,tabSize:2}}),!o.trim()&&c.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center px-8 text-center",children:c.jsxs("div",{className:"max-w-md space-y-2",children:[c.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Add repository guidance for your agents"}),c.jsxs("p",{className:"text-xs leading-5 text-muted-foreground/80",children:["This works like a ",c.jsx("code",{children:"CLAUDE.md"})," or ",c.jsx("code",{children:"AGENTS.md"})," file: describe build commands, test workflow, code conventions, and repo-specific rules."]})]})})]}),_&&c.jsx("div",{className:"border-t bg-destructive/5 px-4 py-2 text-xs text-destructive",children:_})]}),c.jsx(bg,{className:"shrink-0 border-t px-4 py-3",children:c.jsxs("div",{className:"flex w-full items-center justify-between",children:[c.jsxs("div",{className:"flex gap-2",children:[c.jsxs(_e,{variant:"outline",size:"sm",className:"gap-1.5 text-xs",disabled:v||d,onClick:E,children:[v?c.jsx(Vt,{className:"h-3.5 w-3.5 animate-spin"}):c.jsx(T2,{className:"h-3.5 w-3.5"}),"Generate template"]}),S&&c.jsxs(_e,{variant:"ghost",size:"sm",className:"gap-1.5 text-xs",onClick:A,children:[c.jsx(_Y,{className:"h-3.5 w-3.5"}),"Reset"]})]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(_e,{variant:"ghost",size:"sm",className:"text-xs",onClick:()=>r(!1),children:"Cancel"}),c.jsxs(_e,{size:"sm",className:"gap-1.5 text-xs",disabled:!S||f||d,onClick:j,children:[f?c.jsx(Vt,{className:"h-3.5 w-3.5 animate-spin"}):c.jsx(N2,{className:"h-3.5 w-3.5"}),"Save"]})]})]})})]})})}const Ynt={proposed:{label:"Proposed",color:"text-blue-600 dark:text-blue-400",bg:"bg-blue-500/10"},approved:{label:"Ready",color:"text-green-600 dark:text-green-400",bg:"bg-green-500/10"},running:{label:"Running",color:"text-amber-600 dark:text-amber-400",bg:"bg-amber-500/10"},completed:{label:"Done",color:"text-emerald-600 dark:text-emerald-400",bg:"bg-emerald-500/10"},skipped:{label:"Skipped",color:"text-muted-foreground",bg:"bg-muted/50"}};function Xnt({status:e}){const r=Ynt[e];return c.jsx("span",{className:`inline-flex items-center rounded-full px-1.5 py-0.5 text-2xs font-medium ${r.color} ${r.bg}`,children:r.label})}function Jnt({open:e,onOpenChange:r,repoId:n,repoName:i,defaultBranch:s,repoLocalPath:o,provider:a,model:l,onStartThread:u}){const d=_g(),[h,f]=y.useState([]),[g,v]=y.useState(null),[b,_]=y.useState(!1),[w,S]=y.useState(!1),[C,j]=y.useState(null),[E,A]=y.useState(""),[N,P]=y.useState(new Set),[H,K]=y.useState(null),[F,B]=y.useState(""),[W,D]=y.useState(""),O=h.find(te=>te.id===g)??h[0]??null;y.useEffect(()=>{if(!e||!n)return;let te=!1;return _(!0),j(null),xr.listPlans(n).then(ue=>{te||(f(ue),ue.length>0&&!g&&v(ue[0].id))}).catch(ue=>{te||j(ue instanceof Error?ue.message:"Failed to load plans")}).finally(()=>{te||_(!1)}),()=>{te=!0}},[e,n]);const I=y.useCallback(async()=>{j(null);try{const te=await xr.createPlan(n,{title:"New Plan"});f(ue=>[te,...ue]),v(te.id)}catch(te){j(te instanceof Error?te.message:"Failed to create plan")}},[n]),R=y.useCallback(async()=>{if(O){S(!0),j(null);try{const te=await xr.generatePlanTasks(O.id,{prompt:E||void 0,provider:a,model:a==="jait"?null:l??null});f(ue=>ue.map(he=>he.id===te.plan.id?te.plan:he)),A("")}catch(te){j(te instanceof Error?te.message:"Failed to generate tasks")}finally{S(!1)}}},[O,E,l,a]),$=y.useCallback(async(te,ue)=>{if(!O)return;const he=O.tasks.map(we=>we.id===te?{...we,status:ue}:we);try{const we=await xr.updatePlan(O.id,{tasks:he});f(pe=>pe.map(qe=>qe.id===we.id?we:qe))}catch(we){j(we instanceof Error?we.message:"Failed to update task")}},[O]),U=y.useCallback(async te=>{if(!O)return;const ue=O.tasks.filter(he=>he.id!==te);try{const he=await xr.updatePlan(O.id,{tasks:ue});f(we=>we.map(pe=>pe.id===he.id?he:pe))}catch(he){j(he instanceof Error?he.message:"Failed to remove task")}},[O]),Y=y.useCallback(async()=>{if(!O||!H)return;const te=O.tasks.map(ue=>ue.id===H?{...ue,title:F,description:W}:ue);try{const ue=await xr.updatePlan(O.id,{tasks:te});f(he=>he.map(we=>we.id===ue.id?ue:we)),K(null)}catch(ue){j(ue instanceof Error?ue.message:"Failed to save task")}},[O,H,F,W]),z=y.useCallback(async te=>{if(O){j(null);try{await xr.startPlanTask(O.id,te.id),u(te,O,{name:i,localPath:o,defaultBranch:s}),f(ue=>ue.map(he=>he.id===O.id?{...he,tasks:he.tasks.map(we=>we.id===te.id?{...we,status:"running"}:we)}:he))}catch(ue){j(ue instanceof Error?ue.message:"Failed to start task")}}},[O,i,o,s,u]),V=y.useCallback(async()=>{if(!O)return;j(null);const te=O.tasks.filter(he=>he.status==="approved"||he.status==="proposed");if(te.length===0){j("No tasks to start. Approve some tasks first, or generate new ones.");return}const ue=O.tasks.map(he=>he.status==="proposed"?{...he,status:"approved"}:he);try{const he=await xr.updatePlan(O.id,{tasks:ue,status:"active"});f(we=>we.map(pe=>pe.id===he.id?he:pe))}catch{}for(const he of te)try{u(he,O,{name:i,localPath:o,defaultBranch:s}),f(we=>we.map(pe=>pe.id===O.id?{...pe,tasks:pe.tasks.map(qe=>qe.id===he.id?{...qe,status:"running"}:qe)}:pe)),await new Promise(we=>setTimeout(we,500))}catch{}},[O,i,o,s,u]),Q=y.useCallback(async()=>{if(!(!O||!await d({title:"Delete plan",description:`Delete plan "${O.title}"?`,confirmLabel:"Delete",variant:"destructive"})))try{await xr.deletePlan(O.id),f(ue=>ue.filter(he=>he.id!==O.id)),v(null)}catch(ue){j(ue instanceof Error?ue.message:"Failed to delete plan")}},[O,d]),q=te=>{P(ue=>{const he=new Set(ue);return he.has(te)?he.delete(te):he.add(te),he})},re=te=>{K(te.id),B(te.title),D(te.description),P(ue=>new Set(ue).add(te.id))},ee=(O==null?void 0:O.tasks.filter(te=>te.status==="approved"||te.status==="proposed").length)??0,ne=(O==null?void 0:O.tasks.filter(te=>te.status==="completed").length)??0,ae=(O==null?void 0:O.tasks.length)??0;return c.jsx(El,{open:e,onOpenChange:r,children:c.jsxs(sl,{className:"flex max-h-[85vh] w-full max-w-2xl flex-col gap-0 overflow-hidden p-0",children:[c.jsx(pc,{className:"shrink-0 border-b px-4 py-3",children:c.jsxs(ol,{className:"flex items-center gap-2 text-sm",children:[c.jsx("span",{children:"Plans"}),c.jsx("span",{className:"text-muted-foreground",children:"—"}),c.jsx("span",{className:"font-normal text-muted-foreground",children:i}),O&&ae>0&&c.jsxs("span",{className:"ml-auto text-2xs text-muted-foreground",children:[ne,"/",ae," done"]})]})}),c.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[b?c.jsx("div",{className:"flex flex-1 items-center justify-center py-12",children:c.jsx(Vt,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):O?c.jsxs(c.Fragment,{children:[h.length>1&&c.jsxs("div",{className:"flex items-center gap-2 border-b px-4 py-2",children:[c.jsx("select",{className:"flex-1 rounded border bg-transparent px-2 py-1 text-xs",value:O.id,onChange:te=>v(te.target.value),children:h.map(te=>c.jsxs("option",{value:te.id,children:[te.title," (",te.tasks.length," tasks)"]},te.id))}),c.jsx(_e,{variant:"ghost",size:"sm",className:"h-6 px-2 text-2xs",onClick:I,children:c.jsx(qs,{className:"h-3 w-3"})})]}),c.jsxs("div",{className:"flex items-center gap-2 border-b px-4 py-2",children:[c.jsx(Pn,{placeholder:"Describe what you want to accomplish…",className:"h-8 flex-1 text-xs",value:E,onChange:te=>A(te.target.value),onKeyDown:te=>{te.key==="Enter"&&!te.shiftKey&&(te.preventDefault(),R())}}),c.jsxs(_e,{variant:"outline",size:"sm",className:"h-8 gap-1.5 text-xs",disabled:w,onClick:()=>void R(),children:[w?c.jsx(Vt,{className:"h-3.5 w-3.5 animate-spin"}):c.jsx(T2,{className:"h-3.5 w-3.5"}),"Generate"]})]}),c.jsx("div",{className:"flex-1 overflow-y-auto",children:O.tasks.length===0?c.jsx("div",{className:"flex flex-col items-center justify-center gap-2 py-8",children:c.jsx("p",{className:"text-xs text-muted-foreground",children:"No tasks yet. Use the prompt above to generate tasks, or add them manually."})}):c.jsx("div",{className:"divide-y",children:O.tasks.map(te=>{const ue=N.has(te.id),he=H===te.id,we=te.status==="proposed"||te.status==="approved",pe=te.status==="proposed"||te.status==="approved";return c.jsxs("div",{className:"px-4 py-2.5",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("button",{type:"button",className:"shrink-0 rounded p-0.5 text-muted-foreground hover:text-foreground",onClick:()=>q(te.id),children:ue?c.jsx(Ml,{className:"h-3.5 w-3.5"}):c.jsx(Cs,{className:"h-3.5 w-3.5"})}),c.jsx(Xnt,{status:te.status}),he?c.jsx(Pn,{className:"h-6 flex-1 text-xs",value:F,onChange:qe=>B(qe.target.value),onKeyDown:qe=>{qe.key==="Enter"&&Y(),qe.key==="Escape"&&K(null)},autoFocus:!0}):c.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[c.jsx("span",{className:`min-w-0 flex-1 truncate text-xs ${te.status==="skipped"?"line-through text-muted-foreground":"font-medium"}`,children:te.title}),te.skillCandidate&&c.jsx("span",{className:"inline-flex shrink-0 items-center rounded-full bg-violet-500/10 px-1.5 py-0.5 text-[10px] font-medium text-violet-600 dark:text-violet-400",children:"skill"})]}),c.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[we&&c.jsx("button",{type:"button",title:"Start thread",className:"rounded p-1 text-green-600 hover:bg-green-500/10 dark:text-green-400",onClick:()=>void z(te),children:c.jsx(DS,{className:"h-3.5 w-3.5",fill:"currentColor"})}),te.status==="proposed"&&c.jsx("button",{type:"button",title:"Approve",className:"rounded p-1 text-green-600 hover:bg-green-500/10 dark:text-green-400",onClick:()=>void $(te.id,"approved"),children:c.jsx(fs,{className:"h-3.5 w-3.5"})}),pe&&c.jsx("button",{type:"button",title:"Skip",className:"rounded p-1 text-muted-foreground hover:bg-muted",onClick:()=>void $(te.id,"skipped"),children:c.jsx(cve,{className:"h-3.5 w-3.5"})}),!he&&(te.status==="proposed"||te.status==="approved")&&c.jsx("button",{type:"button",title:"Edit",className:"rounded p-1 text-muted-foreground hover:bg-muted",onClick:()=>re(te),children:c.jsx(bR,{className:"h-3 w-3"})}),he&&c.jsx("button",{type:"button",title:"Save",className:"rounded p-1 text-green-600 hover:bg-green-500/10",onClick:()=>void Y(),children:c.jsx(fs,{className:"h-3.5 w-3.5"})}),(te.status==="proposed"||te.status==="approved"||te.status==="skipped")&&c.jsx("button",{type:"button",title:"Remove",className:"rounded p-1 text-muted-foreground hover:text-destructive",onClick:()=>void U(te.id),children:c.jsx(Tl,{className:"h-3 w-3"})})]})]}),ue&&c.jsxs("div",{className:"mt-2 pl-6",children:[he?c.jsx("textarea",{className:"w-full rounded border bg-transparent px-2 py-1.5 text-xs leading-relaxed focus:outline-none focus:ring-1 focus:ring-primary",rows:4,value:W,onChange:qe=>D(qe.target.value)}):c.jsx("p",{className:"whitespace-pre-wrap text-xs leading-relaxed text-muted-foreground",children:te.description||"No description."}),te.threadId&&c.jsxs("p",{className:"mt-1 text-2xs text-muted-foreground",children:["Thread: ",c.jsx("code",{className:"rounded bg-muted px-1",children:te.threadId.slice(-8)})]}),(te.skillCandidate||te.skillRationale||te.skillTitle)&&c.jsxs("div",{className:"mt-2 rounded-md border border-violet-500/20 bg-violet-500/5 px-2 py-1.5 text-[10px] text-muted-foreground",children:[c.jsxs("p",{children:["Skill eval: ",te.skillCandidate?"yes":"no",te.skillTitle?` · ${te.skillTitle}`:""]}),te.skillRationale&&c.jsx("p",{className:"mt-1 whitespace-pre-wrap",children:te.skillRationale})]})]})]},te.id)})})})]}):c.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 py-12",children:[c.jsx("p",{className:"text-sm text-muted-foreground",children:"No plans yet for this repository."}),c.jsxs(_e,{size:"sm",className:"gap-1.5 text-xs",onClick:I,children:[c.jsx(qs,{className:"h-3.5 w-3.5"}),"Create plan"]})]}),C&&c.jsx("div",{className:"border-t bg-destructive/5 px-4 py-2 text-xs text-destructive",children:C})]}),c.jsx(bg,{className:"shrink-0 border-t px-4 py-3",children:c.jsxs("div",{className:"flex w-full items-center justify-between",children:[c.jsxs("div",{className:"flex gap-2",children:[!O&&c.jsxs(_e,{size:"sm",className:"gap-1.5 text-xs",onClick:I,children:[c.jsx(qs,{className:"h-3.5 w-3.5"}),"New plan"]}),O&&c.jsxs(_e,{variant:"ghost",size:"sm",className:"gap-1.5 text-xs text-destructive hover:text-destructive",onClick:()=>void Q(),children:[c.jsx(Tl,{className:"h-3.5 w-3.5"}),"Delete plan"]})]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(_e,{variant:"ghost",size:"sm",className:"text-xs",onClick:()=>r(!1),children:"Close"}),O&&ee>0&&c.jsxs(_e,{size:"sm",className:"gap-1.5 text-xs",onClick:()=>void V(),children:[c.jsx(tye,{className:"h-3.5 w-3.5"}),"Start all (",ee,")"]})]})]})})]})})}function Znt(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const r=e;return typeof r.id!="string"||typeof r.scope!="string"||r.scope!=="project"&&r.scope!=="contact"?null:{id:r.id,scope:r.scope,source:typeof r.source=="string"?r.source:"",sourceType:typeof r.sourceType=="string"?r.sourceType:void 0,sourceId:typeof r.sourceId=="string"?r.sourceId:void 0,sourceSurface:typeof r.sourceSurface=="string"?r.sourceSurface:void 0,updatedAt:typeof r.updatedAt=="string"?r.updatedAt:"",content:typeof r.content=="string"?r.content:""}}function p8(e){return Array.isArray(e)?e.filter(r=>typeof r=="string"):[]}function N7(e){const r=e.memory&&typeof e.memory=="object"&&!Array.isArray(e.memory)?e.memory:null,n=Array.isArray(r==null?void 0:r.retrieved)?r.retrieved.map(Znt).filter(s=>!!s):[],i=r?{query:typeof r.query=="string"?r.query:"",retrieved:n,injectedIds:p8(r.injectedIds),ignoredIds:p8(r.ignoredIds),savedIds:p8(r.savedIds)}:void 0;return{provider:String(e.provider??"jait"),model:typeof e.model=="string"?e.model:void 0,rounds:Array.isArray(e.rounds)?e.rounds:[],note:typeof e.note=="string"?e.note:void 0,...i?{memory:i}:{}}}function zv(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function Us(e){return typeof e=="string"&&e.trim()?e:null}function Sce(e){if(typeof e!="string")return null;try{const r=JSON.parse(e);return zv(r)}catch{return null}}function z_(...e){const r={};for(const n of e)if(n)for(const[i,s]of Object.entries(n))s!=null&&s!==""&&(r[i]=s);return r}function m8(e,r){const n=zv(e.args),i=zv(e.data),s=Sce(e.message),o=r.replace("_","."),a=z_(i,s);return Object.keys(n??{}).length>0?z_(a,n):o==="edit"||o.startsWith("file.")?z_(a,{path:Us(e.path)??Us(e.file)??Us(e.name)??Us(i==null?void 0:i.path)??Us(i==null?void 0:i.file)??"",search:e.search??(i==null?void 0:i.search),replace:e.replace??(i==null?void 0:i.replace),content:e.content??(i==null?void 0:i.content)}):o==="web"||o.startsWith("web.")||o.startsWith("browser.")?z_(a,{url:Us(e.url)??Us(i==null?void 0:i.url)??Us(i==null?void 0:i.finalUrl)??"",query:Us(e.query)??Us(e.name)??Us(i==null?void 0:i.query)??"",content:e.content??(i==null?void 0:i.content)}):a}function Qnt(e,r){const n=Us(e.message)??Us(e.output)??Us(e.content)??Us(e.text)??Us(e.summary);if(n)return n;const i=zv(e.data),s=Us(i==null?void 0:i.message)??Us(i==null?void 0:i.output)??Us(i==null?void 0:i.content)??Us(i==null?void 0:i.text)??Us(i==null?void 0:i.summary);return s||r}function eit(e){const r=[];let n=null,i=[];const s=new Map;let o=[];function a(){o.length>0&&(i.push({type:"toolGroup",callIds:[...o]}),o=[])}function l(){n&&(a(),i.length>0&&(n.segments=[...i]),r.push(n),n=null,i=[])}function u(d){return(!n||n.role!=="assistant")&&(l(),n={id:d,role:"assistant",content:"",toolCalls:[]},i=[]),n}for(const d of e){const h=d.payload??{};switch(d.kind){case"message":{const f=h.role,g=typeof h.content=="string"?h.content:d.summary,v=Array.isArray(h.referencedFiles)?h.referencedFiles.flatMap(_=>{if(!_||typeof _!="object")return[];const w=typeof _.path=="string"?_.path:null,S=typeof _.name=="string"?_.name:null;return w&&S?[{path:w,name:S}]:[]}):void 0,b=cj(h.displaySegments);if(f==="user")l(),r.push({id:d.id,role:"user",content:g,displayContent:b.length>0?J0(b):g,referencedFiles:v,displaySegments:b.length>0?b:void 0});else{const _=u(d.id);a();const w=g??"";w&&(_.content+=(_.content?`
1216
1216
  `:"")+w,i.push({type:"text",content:w}))}break}case"tool.start":{const f=u(d.id),g=h.callId??d.id,v=h.tool??"unknown";if(s.has(g))break;const b={callId:g,parentCallId:h.parentCallId,tool:v,args:nu(v,m8(h,v)),status:"running",startedAt:new Date(d.createdAt).getTime()};f.toolCalls=f.toolCalls??[],f.toolCalls.push(b),s.set(g,b),o.push(g);break}case"tool.output":{const f=h.callId;if(f&&s.has(f)){const g=s.get(f);g.streamingOutput=(g.streamingOutput??"")+(h.content??"")}break}case"tool.result":case"tool.error":{const f=h.callId,g=h.tool??"unknown",v=typeof h.ok=="boolean"?h.ok:d.kind==="tool.result",b=Qnt(h,d.summary),_=h.data!==void 0?h.data:Sce(h.message);let w=f?s.get(f):void 0;if(!w){const S=u(d.id),C=f??d.id;w={callId:C,parentCallId:h.parentCallId,tool:g,args:nu(g,m8(h,g),zv(_)??void 0),status:v?"success":"error",startedAt:new Date(d.createdAt).getTime()},S.toolCalls=S.toolCalls??[],S.toolCalls.push(w),s.set(C,w),o.push(C)}w.args=nu(w.tool,z_(w.args,m8(h,g)),zv(_)??void 0),w.parentCallId=w.parentCallId??h.parentCallId,w.status=v?"success":"error",w.result={ok:v,message:b,..._!==void 0?{data:_}:{}},w.completedAt=new Date(d.createdAt).getTime();break}case"tool.approval":{const f=u(d.id),g=h.requestId??d.id,v={callId:g,parentCallId:h.parentCallId,tool:h.tool??"unknown",args:nu(String(h.tool??"unknown"),h.args??{}),status:"pending",startedAt:new Date(d.createdAt).getTime()};f.toolCalls=f.toolCalls??[],f.toolCalls.push(v),s.set(g,v),o.push(g);break}case"skill.active":{const f=u(d.id),g=Array.isArray(h.names)?h.names.join(", "):"unknown",v=Array.isArray(h.skills)?h.skills:[],b=d.id,_={callId:b,parentCallId:h.parentCallId,tool:"skill",args:{skills:v.map(w=>w.name).join(", ")},status:"success",startedAt:new Date(d.createdAt).getTime(),completedAt:new Date(d.createdAt).getTime(),result:{ok:!0,message:`Using skills: ${g}`}};f.toolCalls=f.toolCalls??[],f.toolCalls.push(_),s.set(b,_),o.push(b);break}case"context_flow":{const f=N7(h),g=n;if(g&&g.role==="assistant")g.contextFlow=f;else for(let v=r.length-1;v>=0;v--){const b=r[v];if(b&&b.role==="assistant"){b.contextFlow=f;break}}break}case"session":{l();break}case"error":{const f=u(d.id);a();const g=`**Error:** ${d.summary}`;f.content+=(f.content?`
1217
1217
  `:"")+g,i.push({type:"text",content:g});break}case"thinking":{const f=typeof h.content=="string"?h.content:typeof h.text=="string"?h.text:typeof h.message=="string"?h.message:d.summary;if(f){const g=u(d.id);a(),g.thinking=(g.thinking??"")+f;const v=i[i.length-1];(v==null?void 0:v.type)==="thinking"?v.content+=f:i.push({type:"thinking",content:f})}break}default:{const g=(typeof h.content=="string"?h.content:typeof h.text=="string"?h.text:typeof h.message=="string"?h.message:null)??(d.kind==="activity"?d.summary:null);if(h.role==="user"&&g)l(),r.push({id:d.id,role:"user",content:g});else if(g){const b=u(d.id);a(),b.content+=(b.content?`
1218
1218
  `:"")+g,i.push({type:"text",content:g})}break}}}return l(),r}const hU=Kn(),fU={core:{variant:"default",label:"core"},standard:{variant:"secondary",label:"standard"},external:{variant:"warning",label:"external"}},pU=["meta","terminal","filesystem","os","agent","browser","web","surfaces","scheduler","memory","voice","screen","gateway","external"];function tit({token:e}){const[r,n]=y.useState([]),[i,s]=y.useState(!0),[o,a]=y.useState(!1),[l,u]=y.useState(null),[d,h]=y.useState("");y.useEffect(()=>{if(!e)return;let w=!1;return(async()=>{try{const S=await fetch(`${hU}/auth/settings/tools`,{headers:{Authorization:`Bearer ${e}`}});if(!w)if(S.ok){const C=await S.json();n(C.tools)}else u(`Failed to load tools (${S.status})`)}catch{w||u("Failed to load tools")}finally{w||s(!1)}})(),()=>{w=!0}},[e]);const f=y.useCallback(async(w,S)=>{if(e){n(C=>C.map(j=>j.name===w?{...j,enabled:S}:j)),a(!0),u(null);try{const C=r.map(E=>E.name===w?{...E,enabled:S}:E).filter(E=>!E.enabled&&!E.locked).map(E=>E.name);if(!(await fetch(`${hU}/auth/settings/tools`,{method:"PATCH",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:JSON.stringify({disabled_tools:C})})).ok)throw new Error("Failed to save")}catch{n(C=>C.map(j=>j.name===w?{...j,enabled:!S}:j)),u("Failed to update tool setting")}finally{a(!1)}}},[e,r]),g=new Map,v=d.trim().toLowerCase();for(const w of r){if(v&&!`${w.name} ${w.description} ${w.category}`.toLowerCase().includes(v))continue;const S=w.category;g.has(S)||g.set(S,[]),g.get(S).push(w)}const b=[...g.keys()].sort((w,S)=>{const C=pU.indexOf(w),j=pU.indexOf(S);return(C===-1?999:C)-(j===-1?999:j)}),_={total:r.length,enabled:r.filter(w=>w.enabled).length,core:r.filter(w=>w.tier==="core").length,standard:r.filter(w=>w.tier==="standard").length,external:r.filter(w=>w.tier==="external").length};return i?c.jsx(gn,{className:"p-5",children:c.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading tools..."})}):c.jsxs(gn,{className:"p-5 space-y-4",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-base font-medium",children:"Tools"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage which tools are available to the AI agent. Core tools are always enabled. Standard tools can be toggled. External (MCP) tools are discovered on demand."})]}),c.jsxs("div",{className:"flex items-center gap-3 text-sm text-muted-foreground",children:[c.jsxs("span",{className:"flex items-center gap-1",children:[c.jsx(I4,{className:"h-3.5 w-3.5"}),_.core," core"]}),c.jsxs("span",{className:"flex items-center gap-1",children:[c.jsx(_R,{className:"h-3.5 w-3.5"}),_.standard," standard"]}),c.jsxs("span",{className:"flex items-center gap-1",children:[c.jsx(j2,{className:"h-3.5 w-3.5"}),_.external," external"]}),c.jsxs("span",{className:"ml-auto",children:[_.enabled,"/",_.total," enabled"]})]}),c.jsxs("div",{className:"relative",children:[c.jsx(tl,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),c.jsx(Pn,{placeholder:"Filter tools...",value:d,onChange:w=>h(w.target.value),className:"pl-9"})]}),l&&c.jsx("p",{className:"text-sm text-destructive",children:l}),c.jsxs("div",{className:"space-y-5",children:[b.map(w=>{const S=g.get(w);return c.jsxs("div",{children:[c.jsx("h3",{className:"text-sm font-medium text-muted-foreground uppercase tracking-wide mb-2",children:w}),c.jsx("div",{className:"space-y-1",children:S.map(C=>{const j=fU[C.tier]??fU.standard;return c.jsxs("div",{className:"flex items-center gap-3 py-2 px-3 rounded-md hover:bg-muted/50 transition-colors",children:[c.jsx(Ap,{checked:C.enabled,onCheckedChange:E=>{f(C.name,E)},disabled:C.locked||o,"aria-label":`Toggle ${C.name}`}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"font-mono text-sm font-medium",children:C.name}),c.jsx($r,{variant:j.variant,className:"text-2xs px-1.5 py-0",children:j.label}),C.source==="mcp"&&c.jsx($r,{variant:"outline",className:"text-2xs px-1.5 py-0",children:"MCP"})]}),c.jsx("p",{className:"text-xs text-muted-foreground truncate",children:C.description})]})]},C.name)})})]},w)}),b.length===0&&c.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:v?"No tools match your filter.":"No tools available."})]})]})}const F_=Kn(),rit={installed:{variant:"secondary",label:"installed"},enabled:{variant:"default",label:"enabled"},disabled:{variant:"outline",label:"disabled"},error:{variant:"destructive",label:"error"}};function kce(e){return y.useCallback(()=>{const r={"Content-Type":"application/json"};return e&&(r.Authorization=`Bearer ${e}`),r},[e])}function nit({token:e}){const[r,n]=y.useState([]),[i,s]=y.useState(!0),[o,a]=y.useState(null),[l,u]=y.useState(""),[d,h]=y.useState(null),f=kce(e),g=y.useCallback(async()=>{s(!0),a(null);try{const C=await fetch(`${F_}/api/plugins`,{headers:f()});if(!C.ok)throw new Error(`Failed to load extensions (HTTP ${C.status})`);const j=await C.json();n(j)}catch(C){a(C instanceof Error?C.message:"Failed to load extensions")}finally{s(!1)}},[f]);y.useEffect(()=>{g()},[g]);const v=y.useCallback(async(C,j)=>{h(C);try{const E=j?"enable":"disable",A=await fetch(`${F_}/api/plugins/${encodeURIComponent(C)}/${E}`,{method:"POST",headers:f()});if(!A.ok){const N=await A.json().catch(()=>({}));throw new Error(N.error??`Failed to ${E} (HTTP ${A.status})`)}await g()}catch(E){a(E instanceof Error?E.message:"Action failed")}finally{h(null)}},[f,g]),b=y.useCallback(async C=>{h(C);try{const j=await fetch(`${F_}/api/plugins/${encodeURIComponent(C)}`,{method:"DELETE",headers:f()});if(!j.ok){const E=await j.json().catch(()=>({}));throw new Error(E.error??`Failed to uninstall (HTTP ${j.status})`)}await g()}catch(j){a(j instanceof Error?j.message:"Action failed")}finally{h(null)}},[f,g]),_=y.useCallback(async()=>{s(!0);try{const C=await fetch(`${F_}/api/plugins/scan`,{method:"POST",headers:f()});if(!C.ok)throw new Error(`Scan failed (HTTP ${C.status})`);const j=await C.json();n(j)}catch(C){a(C instanceof Error?C.message:"Scan failed")}finally{s(!1)}},[f]),w=l.toLowerCase(),S=r.filter(C=>w?C.id.toLowerCase().includes(w)||C.displayName.toLowerCase().includes(w)||(C.description??"").toLowerCase().includes(w)||(C.author??"").toLowerCase().includes(w):!0);return i&&r.length===0?c.jsx(gn,{className:"p-5",children:c.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading extensions..."})}):c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex gap-2",children:[c.jsxs("div",{className:"relative flex-1",children:[c.jsx(tl,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),c.jsx(Pn,{value:l,onChange:C=>u(C.target.value),placeholder:"Filter extensions...",className:"pl-9"})]}),c.jsxs(_e,{variant:"outline",size:"sm",onClick:()=>void _(),disabled:i,children:[c.jsx(io,{className:`mr-1.5 h-3.5 w-3.5 ${i?"animate-spin":""}`}),"Scan"]})]}),o&&c.jsxs(gn,{className:"flex items-start gap-2 border-destructive/50 bg-destructive/5 p-4",children:[c.jsx(ia,{className:"mt-0.5 h-4 w-4 shrink-0 text-destructive"}),c.jsx("p",{className:"text-sm text-destructive",children:o})]}),S.length===0&&!i&&c.jsxs(gn,{className:"p-8 text-center",children:[c.jsx(j2,{className:"mx-auto h-8 w-8 text-muted-foreground/40"}),c.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:r.length===0?"No extensions installed. Drop plugin folders into ~/.jait/extensions/ and click Scan.":"No extensions match your filter."})]}),S.map(C=>{const j=rit[C.status],E=C.status==="enabled",A=d===C.id;return c.jsxs(gn,{className:"flex items-start gap-4 p-4",children:[c.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-muted",children:c.jsx(j2,{className:"h-5 w-5 text-muted-foreground"})}),c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"font-medium",children:C.displayName}),c.jsx($r,{variant:j.variant,className:"text-2xs",children:j.label}),c.jsxs("span",{className:"text-xs text-muted-foreground",children:["v",C.version]})]}),C.description&&c.jsx("p",{className:"mt-0.5 text-sm text-muted-foreground line-clamp-2",children:C.description}),C.author&&c.jsxs("p",{className:"mt-0.5 text-xs text-muted-foreground",children:["by ",C.author]}),C.error&&c.jsx("p",{className:"mt-1 text-xs text-destructive",children:C.error}),c.jsx("p",{className:"mt-0.5 text-2xs text-muted-foreground/60 font-mono",children:C.id})]}),c.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[c.jsx(Ap,{checked:E,disabled:A,onCheckedChange:N=>void v(C.id,N),"aria-label":E?"Disable":"Enable"}),c.jsx(_e,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",disabled:A,onClick:()=>void b(C.id),title:"Uninstall",children:c.jsx(Tl,{className:"h-4 w-4"})})]})]},C.id)})]})}function iit({token:e}){const[r,n]=y.useState([]),[i,s]=y.useState(!0),[o,a]=y.useState(null),l=kce(e),u=y.useCallback(async()=>{s(!0),a(null);try{const d=await fetch(`${F_}/api/store/packages?limit=50`,{headers:l()});if(!d.ok)throw new Error(`Failed to browse ClawHub (HTTP ${d.status})`);const h=await d.json();n(h.items??[])}catch(d){a(d instanceof Error?d.message:"Failed to load marketplace")}finally{s(!1)}},[l]);return y.useEffect(()=>{u()},[u]),c.jsxs("div",{className:"space-y-4",children:[c.jsxs(gn,{className:"bg-muted/30 p-4 text-sm text-muted-foreground",children:["Browse OpenClaw plugins on"," ",c.jsx("a",{href:"https://clawhub.ai/plugins",target:"_blank",rel:"noopener noreferrer",className:"underline hover:text-foreground",children:"ClawHub"}),". To install, download the plugin and place it in"," ",c.jsx("code",{className:"rounded bg-muted px-1 py-0.5 text-xs",children:"~/.jait/extensions/"}),", then click Scan on the Installed tab."]}),o&&c.jsxs(gn,{className:"flex items-start gap-2 border-destructive/50 bg-destructive/5 p-4",children:[c.jsx(ia,{className:"mt-0.5 h-4 w-4 shrink-0 text-destructive"}),c.jsx("p",{className:"text-sm text-destructive",children:o})]}),i&&r.length===0&&c.jsxs(gn,{className:"flex items-center justify-center gap-2 p-8",children:[c.jsx(Vt,{className:"h-5 w-5 animate-spin text-muted-foreground"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading from ClawHub..."})]}),!i&&r.length===0&&c.jsxs(gn,{className:"p-8 text-center",children:[c.jsx(j2,{className:"mx-auto h-8 w-8 text-muted-foreground/40"}),c.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"No packages available."})]}),r.map((d,h)=>{const f=d.displayName??d.name??"Unknown",g=d.description??"",v=d.type??"plugin";return c.jsxs(gn,{className:"flex items-start gap-3 p-4",children:[c.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-muted",children:c.jsx(j2,{className:"h-4 w-4 text-muted-foreground"})}),c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"font-medium",children:f}),d.version&&c.jsxs("span",{className:"text-xs text-muted-foreground",children:["v",d.version]}),c.jsx($r,{variant:"outline",className:"text-2xs",children:v})]}),c.jsx("p",{className:"mt-0.5 text-sm text-muted-foreground line-clamp-2",children:g}),d.author&&c.jsxs("p",{className:"mt-0.5 text-xs text-muted-foreground",children:["by @",d.author]})]}),c.jsx("a",{href:`https://clawhub.ai/plugins/${encodeURIComponent(d.name??"")}`,target:"_blank",rel:"noopener noreferrer",children:c.jsxs(_e,{variant:"outline",size:"sm",className:"h-7 text-xs",children:[c.jsx(Sp,{className:"mr-1 h-3 w-3"}),"View"]})})]},d.name??h)})]})}function sit({token:e}){return c.jsxs(Y0,{defaultValue:"installed",className:"space-y-4",children:[c.jsxs(gn,{className:"space-y-3 p-5",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-base font-medium",children:"Extensions"}),c.jsxs("p",{className:"text-sm text-muted-foreground",children:["Manage plugins and extensions. Browse the"," ",c.jsx("a",{href:"https://clawhub.ai/plugins",target:"_blank",rel:"noopener noreferrer",className:"underline hover:text-foreground",children:"ClawHub"})," ","marketplace or drop plugins into"," ",c.jsx("code",{className:"rounded bg-muted px-1 py-0.5 text-xs",children:"~/.jait/extensions/"}),"."]})]}),c.jsxs(ag,{children:[c.jsx(so,{value:"installed",children:"Installed"}),c.jsx(so,{value:"marketplace",children:"Marketplace"})]})]}),c.jsx(oo,{value:"installed",className:"mt-0 space-y-4",children:c.jsx(nit,{token:e})}),c.jsx(oo,{value:"marketplace",className:"mt-0 space-y-4",children:c.jsx(iit,{token:e})})]})}const n4=Kn();function mU(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}const gU={bundled:{variant:"default",label:"bundled"},user:{variant:"secondary",label:"user"},project:{variant:"outline",label:"project"},plugin:{variant:"secondary",label:"plugin"}};function Cce(e){return y.useCallback(()=>{const r={"Content-Type":"application/json"};return e&&(r.Authorization=`Bearer ${e}`),r},[e])}function oit({token:e}){const[r,n]=y.useState([]),[i,s]=y.useState(!0),[o,a]=y.useState(null),[l,u]=y.useState(""),[d,h]=y.useState(null),f=Cce(e),g=y.useCallback(async()=>{s(!0),a(null);try{const w=await fetch(`${n4}/api/skills`,{headers:f()});if(!w.ok)throw new Error(`Failed to load skills (HTTP ${w.status})`);const S=await w.json();n(S)}catch(w){a(w instanceof Error?w.message:"Failed to load skills")}finally{s(!1)}},[f]);y.useEffect(()=>{g()},[g]);const v=y.useCallback(async(w,S)=>{h(w);try{const C=await fetch(`${n4}/api/skills/${encodeURIComponent(w)}`,{method:"PATCH",headers:f(),body:JSON.stringify({enabled:S})});if(!C.ok)throw new Error(`Failed to update skill (HTTP ${C.status})`);n(j=>j.map(E=>E.id===w?{...E,enabled:S}:E))}catch(C){a(C instanceof Error?C.message:"Action failed")}finally{h(null)}},[f]),b=l.toLowerCase(),_=r.filter(w=>b?w.id.toLowerCase().includes(b)||w.name.toLowerCase().includes(b)||w.description.toLowerCase().includes(b)||w.source.includes(b):!0);return i&&r.length===0?c.jsx(gn,{className:"p-5",children:c.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading skills..."})}):c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"relative",children:[c.jsx(tl,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),c.jsx(Pn,{value:l,onChange:w=>u(w.target.value),placeholder:"Filter installed skills...",className:"pl-9"})]}),o&&c.jsxs(gn,{className:"flex items-start gap-2 border-destructive/50 bg-destructive/5 p-4",children:[c.jsx(ia,{className:"mt-0.5 h-4 w-4 shrink-0 text-destructive"}),c.jsx("p",{className:"text-sm text-destructive",children:o})]}),_.length===0&&!i&&c.jsxs(gn,{className:"p-8 text-center",children:[c.jsx(D5,{className:"mx-auto h-8 w-8 text-muted-foreground/40"}),c.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:r.length===0?"No skills discovered. Install from the Marketplace or create a SKILL.md in ~/.jait/skills/.":"No skills match your filter."})]}),_.map(w=>{const S=gU[w.source]??gU.user,C=d===w.id;return c.jsxs(gn,{className:"flex items-start gap-3 p-4",children:[c.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-muted",children:c.jsx(D5,{className:"h-4 w-4 text-muted-foreground"})}),c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"font-medium",children:w.name}),c.jsx($r,{variant:S.variant,className:"text-2xs",children:S.label})]}),c.jsx("p",{className:"mt-0.5 text-sm text-muted-foreground line-clamp-2",children:w.description}),c.jsx("p",{className:"mt-0.5 text-2xs text-muted-foreground/60 font-mono truncate",children:w.filePath})]}),c.jsx(Ap,{checked:w.enabled,disabled:C,onCheckedChange:j=>void v(w.id,j),"aria-label":w.enabled?"Disable":"Enable",className:"shrink-0"})]},w.id)})]})}function ait({token:e}){const[r,n]=y.useState([]),[i,s]=y.useState(!0),[o,a]=y.useState(null),[l,u]=y.useState(""),[d,h]=y.useState("tool workflow agent"),[f,g]=y.useState(null),v=y.useRef(null),b=Cce(e),_=y.useCallback(async(C,j)=>{s(!0),a(null);try{const E=new URLSearchParams;C?E.set("q",C):E.set("sort",j??"tool workflow agent"),E.set("limit","25");const A=await fetch(`${n4}/api/store/skills?${E}`,{headers:b()});if(!A.ok)throw new Error(`Failed to browse ClawHub (HTTP ${A.status})`);const N=await A.json();n(N.results??[])}catch(E){a(E instanceof Error?E.message:"Failed to load marketplace")}finally{s(!1)}},[b]);y.useEffect(()=>{_(void 0,d)},[_,d]);const w=y.useCallback(C=>{u(C),v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{_(C||void 0,d)},400)},[_,d]),S=y.useCallback(async C=>{g(C),a(null);try{const j=await fetch(`${n4}/api/store/skills/${encodeURIComponent(C)}/install`,{method:"POST",headers:b(),body:JSON.stringify({})});if(!j.ok){const E=await j.json().catch(()=>({}));throw new Error(E.error??`Install failed (HTTP ${j.status})`)}n(E=>E.map(A=>A.slug===C?{...A,installed:!0}:A))}catch(j){a(j instanceof Error?j.message:"Install failed")}finally{g(null)}},[b]);return c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex gap-2",children:[c.jsxs("div",{className:"relative flex-1",children:[c.jsx(tl,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),c.jsx(Pn,{value:l,onChange:C=>w(C.target.value),placeholder:"Search ClawHub skills...",className:"pl-9"})]}),c.jsxs("select",{value:d,onChange:C=>h(C.target.value),className:"h-9 rounded-md border bg-background px-3 text-sm",children:[c.jsx("option",{value:"tool workflow agent",children:"Popular"}),c.jsx("option",{value:"memory learning self-improving",children:"Memory"}),c.jsx("option",{value:"search web browser automation",children:"Search"}),c.jsx("option",{value:"git github code development",children:"Development"}),c.jsx("option",{value:"calendar slack obsidian productivity",children:"Productivity"})]})]}),o&&c.jsxs(gn,{className:"flex items-start gap-2 border-destructive/50 bg-destructive/5 p-4",children:[c.jsx(ia,{className:"mt-0.5 h-4 w-4 shrink-0 text-destructive"}),c.jsx("p",{className:"text-sm text-destructive",children:o})]}),i&&r.length===0&&c.jsxs(gn,{className:"flex items-center justify-center gap-2 p-8",children:[c.jsx(Vt,{className:"h-5 w-5 animate-spin text-muted-foreground"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading from ClawHub..."})]}),!i&&r.length===0&&c.jsxs(gn,{className:"p-8 text-center",children:[c.jsx(tl,{className:"mx-auto h-8 w-8 text-muted-foreground/40"}),c.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:l?"No skills match your search.":"No skills available."})]}),r.map(C=>{var B,W,D;const j=C.slug??"",E=C.displayName??j,A=C.summary??"",N=((B=C.latestVersion)==null?void 0:B.version)??C.version??"",P=((W=C.stats)==null?void 0:W.stars)??0,H=((D=C.stats)==null?void 0:D.downloads)??0,K=C.installed===!0,F=f===j;return c.jsxs(gn,{className:"flex items-start gap-3 p-4",children:[c.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-muted",children:c.jsx(D5,{className:"h-4 w-4 text-muted-foreground"})}),c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"font-medium",children:E}),N&&c.jsxs("span",{className:"text-xs text-muted-foreground",children:["v",N]})]}),c.jsx("p",{className:"mt-0.5 text-sm text-muted-foreground line-clamp-2",children:A}),c.jsxs("div",{className:"mt-1 flex items-center gap-3 text-xs text-muted-foreground",children:[P>0&&c.jsxs("span",{className:"flex items-center gap-0.5",children:[c.jsx(gve,{className:"h-3 w-3"}),mU(P)]}),H>0&&c.jsxs("span",{className:"flex items-center gap-0.5",children:[c.jsx(Zm,{className:"h-3 w-3"}),mU(H)]}),c.jsxs("a",{href:`https://clawhub.ai/skills?focus=search&q=${encodeURIComponent(j)}`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-0.5 hover:text-foreground",children:[c.jsx(Sp,{className:"h-3 w-3"}),"ClawHub"]})]})]}),c.jsx("div",{className:"shrink-0",children:K?c.jsxs($r,{variant:"secondary",className:"flex items-center gap-1 text-2xs",children:[c.jsx(fs,{className:"h-3 w-3"}),"Installed"]}):c.jsxs(_e,{size:"sm",variant:"outline",disabled:F,onClick:()=>void S(j),className:"h-7 text-xs",children:[F?c.jsx(Vt,{className:"mr-1 h-3 w-3 animate-spin"}):c.jsx(Zm,{className:"mr-1 h-3 w-3"}),"Install"]})})]},j)})]})}function lit({token:e}){return c.jsxs(Y0,{defaultValue:"installed",className:"space-y-4",children:[c.jsxs(gn,{className:"space-y-3 p-5",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-base font-medium",children:"Skills"}),c.jsxs("p",{className:"text-sm text-muted-foreground",children:["Specialized instruction sets that teach the AI how to use specific tools and workflows. Install from"," ",c.jsx("a",{href:"https://clawhub.ai/skills",target:"_blank",rel:"noopener noreferrer",className:"underline hover:text-foreground",children:"ClawHub"})," ","or place SKILL.md files in"," ",c.jsx("code",{className:"rounded bg-muted px-1 py-0.5 text-xs",children:"~/.jait/skills/"}),"."]})]}),c.jsxs(ag,{children:[c.jsx(so,{value:"installed",children:"Installed"}),c.jsx(so,{value:"marketplace",children:"Marketplace"})]})]}),c.jsx(oo,{value:"installed",className:"mt-0 space-y-4",children:c.jsx(oit,{token:e})}),c.jsx(oo,{value:"marketplace",className:"mt-0 space-y-4",children:c.jsx(ait,{token:e})})]})}function cit({events:e}){return c.jsx(Jc,{className:"h-full w-full",children:c.jsx("div",{className:"p-4 space-y-2",children:e.length===0?c.jsx("p",{className:"text-sm text-muted-foreground",children:"No activity yet."}):e.map(r=>c.jsxs("div",{className:"rounded-md border p-3",children:[c.jsxs("div",{className:"flex items-center justify-between gap-2",children:[c.jsx("p",{className:"text-sm font-medium",children:r.title}),c.jsx("span",{className:"text-xs text-muted-foreground",children:r.source})]}),c.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:r.detail})]},r.id))})})}function n_(e){return e.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&#39;")}function uit(e,r){const n=r.trim();if(!n)return n_(e);const i=e.toLowerCase(),s=n.toLowerCase();let o=0,a=i.indexOf(s);if(a===-1)return n_(e);let l="";for(;a!==-1;){a>o&&(l+=n_(e.slice(o,a)));const u=a+n.length;l+=`<mark class="rounded bg-yellow-200/80 px-0.5 text-inherit dark:bg-yellow-500/30">${n_(e.slice(a,u))}</mark>`,o=u,a=i.indexOf(s,o)}return o<e.length&&(l+=n_(e.slice(o))),l}var dx="Perplexity",dit=.75,hit=.2,jce="#22B8CD",fit=jce,pit="#000",mit=.75;function eS(e){"@babel/helpers - typeof";return eS=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},eS(e)}var git=["size","style"];function yU(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);r&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,i)}return n}function g8(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?yU(Object(n),!0).forEach(function(i){yit(e,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):yU(Object(n)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(n,i))})}return e}function yit(e,r,n){return r=vit(r),r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function vit(e){var r=xit(e,"string");return eS(r)=="symbol"?r:String(r)}function xit(e,r){if(eS(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var i=n.call(e,r);if(eS(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function bit(e,r){if(e==null)return{};var n=_it(e,r),i,s;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(s=0;s<o.length;s++)i=o[s],!(r.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(e,i)&&(n[i]=e[i])}return n}function _it(e,r){if(e==null)return{};var n={},i=Object.keys(e),s,o;for(o=0;o<i.length;o++)s=i[o],!(r.indexOf(s)>=0)&&(n[s]=e[s]);return n}var nL=y.memo(function(e){var r=e.size,n=r===void 0?"1em":r,i=e.style,s=bit(e,git);return c.jsxs("svg",g8(g8({fill:"currentColor",fillRule:"evenodd",height:n,style:g8({flex:"none",lineHeight:1},i),viewBox:"0 0 24 24",width:n,xmlns:"http://www.w3.org/2000/svg"},s),{},{children:[c.jsx("title",{children:dx}),c.jsx("path",{d:"M19.785 0v7.272H22.5V17.62h-2.935V24l-7.037-6.194v6.145h-1.091v-6.152L4.392 24v-6.465H1.5V7.188h2.884V0l7.053 6.494V.19h1.09v6.49L19.786 0zm-7.257 9.044v7.319l5.946 5.234V14.44l-5.946-5.397zm-1.099-.08l-5.946 5.398v7.235l5.946-5.234V8.965zm8.136 7.58h1.844V8.349H13.46l6.105 5.54v2.655zm-8.982-8.28H2.59v8.195h1.8v-2.576l6.192-5.62zM5.475 2.476v4.71h5.115l-5.115-4.71zm13.219 0l-5.115 4.71h5.115v-4.71z"})]}))});function tS(e){"@babel/helpers - typeof";return tS=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},tS(e)}function vU(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);r&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,i)}return n}function wit(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?vU(Object(n),!0).forEach(function(i){Sit(e,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):vU(Object(n)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(n,i))})}return e}function Sit(e,r,n){return r=kit(r),r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function kit(e){var r=Cit(e,"string");return tS(r)=="symbol"?r:String(r)}function Cit(e,r){if(tS(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var i=n.call(e,r);if(tS(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function jit(e){if(e==null)throw new TypeError("Cannot destructure "+e)}var Nit=y.memo(function(e){var r=Object.assign({},(jit(e),e));return c.jsx(gc,wit({Icon:nL,"aria-label":dx,background:fit,color:pit,iconMultiple:mit},r))});function rS(e){"@babel/helpers - typeof";return rS=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},rS(e)}var Tit=["size","style"];function xU(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);r&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,i)}return n}function y8(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?xU(Object(n),!0).forEach(function(i){Eit(e,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):xU(Object(n)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(n,i))})}return e}function Eit(e,r,n){return r=Ait(r),r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function Ait(e){var r=Oit(e,"string");return rS(r)=="symbol"?r:String(r)}function Oit(e,r){if(rS(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var i=n.call(e,r);if(rS(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function Mit(e,r){if(e==null)return{};var n=Rit(e,r),i,s;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(s=0;s<o.length;s++)i=o[s],!(r.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(e,i)&&(n[i]=e[i])}return n}function Rit(e,r){if(e==null)return{};var n={},i=Object.keys(e),s,o;for(o=0;o<i.length;o++)s=i[o],!(r.indexOf(s)>=0)&&(n[s]=e[s]);return n}var Nce=y.memo(function(e){var r=e.size,n=r===void 0?"1em":r,i=e.style,s=Mit(e,Tit);return c.jsxs("svg",y8(y8({height:n,style:y8({flex:"none",lineHeight:1},i),viewBox:"0 0 24 24",width:n,xmlns:"http://www.w3.org/2000/svg"},s),{},{children:[c.jsx("title",{children:dx}),c.jsx("path",{d:"M19.785 0v7.272H22.5V17.62h-2.935V24l-7.037-6.194v6.145h-1.091v-6.152L4.392 24v-6.465H1.5V7.188h2.884V0l7.053 6.494V.19h1.09v6.49L19.786 0zm-7.257 9.044v7.319l5.946 5.234V14.44l-5.946-5.397zm-1.099-.08l-5.946 5.398v7.235l5.946-5.234V8.965zm8.136 7.58h1.844V8.349H13.46l6.105 5.54v2.655zm-8.982-8.28H2.59v8.195h1.8v-2.576l6.192-5.62zM5.475 2.476v4.71h5.115l-5.115-4.71zm13.219 0l-5.115 4.71h5.115v-4.71z",fill:"#22B8CD",fillRule:"nonzero"})]}))});function nS(e){"@babel/helpers - typeof";return nS=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},nS(e)}var Pit=["size","style"];function bU(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);r&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,i)}return n}function v8(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?bU(Object(n),!0).forEach(function(i){Lit(e,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):bU(Object(n)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(n,i))})}return e}function Lit(e,r,n){return r=$it(r),r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function $it(e){var r=Dit(e,"string");return nS(r)=="symbol"?r:String(r)}function Dit(e,r){if(nS(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var i=n.call(e,r);if(nS(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function Iit(e,r){if(e==null)return{};var n=Bit(e,r),i,s;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(s=0;s<o.length;s++)i=o[s],!(r.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(e,i)&&(n[i]=e[i])}return n}function Bit(e,r){if(e==null)return{};var n={},i=Object.keys(e),s,o;for(o=0;o<i.length;o++)s=i[o],!(r.indexOf(s)>=0)&&(n[s]=e[s]);return n}var Tce=y.memo(function(e){var r=e.size,n=r===void 0?"1em":r,i=e.style,s=Iit(e,Pit);return c.jsxs("svg",v8(v8({fill:"currentColor",fillRule:"evenodd",height:n,style:v8({flex:"none",lineHeight:1},i),viewBox:"0 0 117 24",xmlns:"http://www.w3.org/2000/svg"},s),{},{children:[c.jsx("title",{children:dx}),c.jsx("path",{d:"M38.542 5.218h1.151V7.59h-1.49c-1.167 0-2.036.281-2.612.843-.575.563-.863 1.485-.863 2.768v7.773h-2.351V5.271h2.351v2.187c0 .123.062.185.184.185.069 0 .121-.017.157-.053a.58.58 0 00.104-.211c.453-1.44 1.577-2.16 3.371-2.16h-.002zm15.36 2.938c.617 1.098.928 2.42.928 3.966 0 1.545-.309 2.867-.928 3.965-.62 1.098-1.42 1.92-2.404 2.464a6.446 6.446 0 01-3.174.817c-2.23 0-3.797-.896-4.703-2.688-.069-.14-.157-.211-.262-.211-.105 0-.157.052-.157.158v7.352h-2.351V5.271h2.351v2.345c0 .106.052.159.157.159.105 0 .191-.07.262-.211.906-1.793 2.473-2.689 4.703-2.689 1.132 0 2.19.272 3.174.817.984.545 1.785 1.366 2.404 2.464zm-1.424 3.966c0-1.617-.43-2.877-1.292-3.781-.862-.904-1.998-1.357-3.41-1.357-1.413 0-2.548.453-3.41 1.357-.863.905-1.179 2.166-1.179 3.78 0 1.616.316 2.878 1.178 3.782.863.905 2 1.356 3.41 1.356 1.411 0 2.549-.453 3.411-1.356.862-.904 1.292-2.166 1.292-3.781zM15.05 8.177c.618 1.098.928 2.42.928 3.965 0 1.546-.308 2.868-.928 3.966-.619 1.098-1.42 1.919-2.403 2.464a6.448 6.448 0 01-3.175.817c-2.23 0-3.797-.896-4.702-2.688-.07-.14-.158-.212-.262-.212-.105 0-.158.053-.158.159V24H2V5.292h2.351v2.345c0 .106.053.159.158.159.104 0 .19-.07.261-.212.906-1.792 2.473-2.688 4.703-2.688 1.132 0 2.19.272 3.175.817.983.545 1.784 1.366 2.403 2.464h-.002zm-1.423 3.965c0-1.616-.43-2.877-1.293-3.78-.862-.904-1.998-1.357-3.41-1.357-1.412 0-2.548.453-3.41 1.357-.862.905-1.178 2.165-1.178 3.78 0 1.615.316 2.878 1.178 3.781.862.906 1.998 1.357 3.41 1.357 1.412 0 2.548-.453 3.41-1.357.863-.903 1.293-2.166 1.293-3.78zm14.422 2.481h2.482c-.33 1.283-1.006 2.395-2.023 3.334-1.02.94-2.479 1.41-4.378 1.41-1.429 0-2.686-.295-3.775-.884a6.13 6.13 0 01-2.521-2.516c-.593-1.089-.889-2.372-.889-3.847 0-1.476.288-2.758.863-3.847.574-1.089 1.38-1.928 2.417-2.517 1.036-.588 2.25-.883 3.644-.883 1.393 0 2.547.29 3.514.87.968.58 1.69 1.349 2.168 2.305.48.959.719 2.008.719 3.15v1.58H19.427c.086 1.37.544 2.46 1.37 3.268.828.807 1.939 1.213 3.332 1.213 1.132 0 2-.232 2.6-.698.601-.466 1.04-1.111 1.32-1.938zm-8.595-3.82h8.204c0-1.194-.305-2.13-.914-2.807-.61-.676-1.568-1.015-2.874-1.015-1.22 0-2.217.33-2.99.988-.775.659-1.25 1.604-1.424 2.832l-.002.002zm37.238 8.17h2.352V0H56.69v18.974-.002zM89.316 3.774h2.747V.81h-2.747v2.966zm9.688 13.156c-.426.043-.684.066-.77.066a.39.39 0 01-.289-.106.395.395 0 01-.104-.29c0-.087.022-.348.065-.778.043-.43.066-1.094.066-1.988V7.279h3.354l-.66-2.008h-2.692v-3.69h-2.352v3.688h-2.557v2.008h2.557v7.214c0 1.512.367 2.636 1.098 3.374.732.737 1.846 1.107 3.345 1.107h1.83v-2.107h-.915c-.889 0-1.547.022-1.974.066h-.002zm13.759-11.662l-3.893 11.498c-.053.141-.135.326-.402.326-.268 0-.35-.185-.402-.326l-3.893-11.498h-2.398l4.508 13.703h1.594a.81.81 0 01.235.026c.053.017.096.06.131.133.07.105.06.264-.026.473l-.731 2.002c-.105.264-.305.396-.6.396-.106 0-.349-.023-.732-.066a13.71 13.71 0 00-1.49-.066h-1.907v2.107h2.508c1.463 0 2.344-.25 3.102-.75.757-.5 1.345-1.383 1.764-2.65L115 5.795v-.526h-2.237v.001zm-31.127 5.113L77.953 5.27h-2.588v.527l4.415 5.93-5.382 6.72v.526h2.64l4.285-5.507 3.998 5.507h2.535v-.526l-4.677-6.324 5.07-6.298v-.553h-2.64l-3.971 5.113-.002-.002zm7.931 8.59h2.351v-13.7h-2.35v13.702-.002zm-15.062-4.349c-.331 1.283-1.006 2.395-2.024 3.334-1.02.94-2.479 1.41-4.377 1.41-1.43 0-2.686-.295-3.775-.884a6.13 6.13 0 01-2.522-2.516c-.593-1.089-.888-2.372-.888-3.847 0-1.476.288-2.758.862-3.847.574-1.089 1.38-1.928 2.417-2.517 1.036-.588 2.25-.883 3.644-.883 1.394 0 2.547.29 3.515.87.967.58 1.689 1.349 2.168 2.305.479.959.718 2.008.718 3.15v1.58H63.401c.086 1.37.544 2.46 1.371 3.268.827.807 1.938 1.213 3.332 1.213 1.132 0 2-.232 2.6-.698.6-.466 1.04-1.111 1.319-1.938h2.482zm-11.078-3.82h8.205c0-1.194-.305-2.13-.915-2.807-.61-.676-1.568-1.015-2.873-1.015-1.22 0-2.217.33-2.991.988-.775.659-1.25 1.604-1.424 2.832l-.002.002z"})]}))});function iS(e){"@babel/helpers - typeof";return iS=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},iS(e)}var zit=["type"];function _U(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);r&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,i)}return n}function Fit(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?_U(Object(n),!0).forEach(function(i){Hit(e,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):_U(Object(n)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(n,i))})}return e}function Hit(e,r,n){return r=Wit(r),r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function Wit(e){var r=Uit(e,"string");return iS(r)=="symbol"?r:String(r)}function Uit(e,r){if(iS(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var i=n.call(e,r);if(iS(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function Vit(e,r){if(e==null)return{};var n=qit(e,r),i,s;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(s=0;s<o.length;s++)i=o[s],!(r.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(e,i)&&(n[i]=e[i])}return n}function qit(e,r){if(e==null)return{};var n={},i=Object.keys(e),s,o;for(o=0;o<i.length;o++)s=i[o],!(r.indexOf(s)>=0)&&(n[s]=e[s]);return n}var Git=y.memo(function(e){var r=e.type,n=r===void 0?"mono":r,i=Vit(e,zit),s=n==="color"?Nce:nL;return c.jsx(yc,Fit({Icon:s,Text:Tce,"aria-label":dx,spaceMultiple:hit,textMultiple:dit},i))}),Ey=nL;Ey.Color=Nce;Ey.Text=Tce;Ey.Combine=Git;Ey.Avatar=Nit;Ey.colorPrimary=jce;Ey.title=dx;var vk="OpenRouter",Kit=1,Yit=.4,iL="#6566F1",Xit=iL,Jit="#fff",Zit=.75;function sS(e){"@babel/helpers - typeof";return sS=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},sS(e)}var Qit=["size","style"];function wU(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);r&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,i)}return n}function x8(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?wU(Object(n),!0).forEach(function(i){est(e,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):wU(Object(n)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(n,i))})}return e}function est(e,r,n){return r=tst(r),r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function tst(e){var r=rst(e,"string");return sS(r)=="symbol"?r:String(r)}function rst(e,r){if(sS(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var i=n.call(e,r);if(sS(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function nst(e,r){if(e==null)return{};var n=ist(e,r),i,s;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(s=0;s<o.length;s++)i=o[s],!(r.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(e,i)&&(n[i]=e[i])}return n}function ist(e,r){if(e==null)return{};var n={},i=Object.keys(e),s,o;for(o=0;o<i.length;o++)s=i[o],!(r.indexOf(s)>=0)&&(n[s]=e[s]);return n}var sL=y.memo(function(e){var r=e.size,n=r===void 0?"1em":r,i=e.style,s=nst(e,Qit);return c.jsxs("svg",x8(x8({fill:"currentColor",fillRule:"evenodd",height:n,style:x8({flex:"none",lineHeight:1},i),viewBox:"0 0 24 24",width:n,xmlns:"http://www.w3.org/2000/svg"},s),{},{children:[c.jsx("title",{children:vk}),c.jsx("path",{d:"M16.804 1.957l7.22 4.105v.087L16.73 10.21l.017-2.117-.821-.03c-1.059-.028-1.611.002-2.268.11-1.064.175-2.038.577-3.147 1.352L8.345 11.03c-.284.195-.495.336-.68.455l-.515.322-.397.234.385.23.53.338c.476.314 1.17.796 2.701 1.866 1.11.775 2.083 1.177 3.147 1.352l.3.045c.694.091 1.375.094 2.825.033l.022-2.159 7.22 4.105v.087L16.589 22l.014-1.862-.635.022c-1.386.042-2.137.002-3.138-.162-1.694-.28-3.26-.926-4.881-2.059l-2.158-1.5a21.997 21.997 0 00-.755-.498l-.467-.28a55.927 55.927 0 00-.76-.43C2.908 14.73.563 14.116 0 14.116V9.888l.14.004c.564-.007 2.91-.622 3.809-1.124l1.016-.58.438-.274c.428-.28 1.072-.726 2.686-1.853 1.621-1.133 3.186-1.78 4.881-2.059 1.152-.19 1.974-.213 3.814-.138l.02-1.907z"})]}))});function oS(e){"@babel/helpers - typeof";return oS=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},oS(e)}function SU(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);r&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,i)}return n}function sst(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?SU(Object(n),!0).forEach(function(i){ost(e,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):SU(Object(n)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(n,i))})}return e}function ost(e,r,n){return r=ast(r),r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function ast(e){var r=lst(e,"string");return oS(r)=="symbol"?r:String(r)}function lst(e,r){if(oS(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var i=n.call(e,r);if(oS(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function cst(e){if(e==null)throw new TypeError("Cannot destructure "+e)}var ust=y.memo(function(e){var r=Object.assign({},(cst(e),e));return c.jsx(gc,sst({Icon:sL,"aria-label":vk,background:Xit,color:Jit,iconMultiple:Zit},r))});function aS(e){"@babel/helpers - typeof";return aS=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},aS(e)}var dst=["size","style"];function kU(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);r&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,i)}return n}function b8(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?kU(Object(n),!0).forEach(function(i){hst(e,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):kU(Object(n)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(n,i))})}return e}function hst(e,r,n){return r=fst(r),r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function fst(e){var r=pst(e,"string");return aS(r)=="symbol"?r:String(r)}function pst(e,r){if(aS(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var i=n.call(e,r);if(aS(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function mst(e,r){if(e==null)return{};var n=gst(e,r),i,s;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(s=0;s<o.length;s++)i=o[s],!(r.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(e,i)&&(n[i]=e[i])}return n}function gst(e,r){if(e==null)return{};var n={},i=Object.keys(e),s,o;for(o=0;o<i.length;o++)s=i[o],!(r.indexOf(s)>=0)&&(n[s]=e[s]);return n}var Ece=y.memo(function(e){var r=e.size,n=r===void 0?"1em":r,i=e.style,s=mst(e,dst);return c.jsxs("svg",b8(b8({fill:"currentColor",fillRule:"evenodd",height:n,style:b8({flex:"none",lineHeight:1},i),viewBox:"0 0 143 24",xmlns:"http://www.w3.org/2000/svg"},s),{},{children:[c.jsx("title",{children:vk}),c.jsx("path",{d:"M9.623 2c1.46 0 2.763.35 3.91 1.05 1.149.699 2.053 1.7 2.714 3.002.66 1.303.991 2.861.991 4.675 0 1.814-.33 3.372-.991 4.675-.66 1.302-1.565 2.303-2.713 3.003-1.148.7-2.452 1.049-3.91 1.049-1.465 0-2.772-.35-3.92-1.05-1.148-.699-2.052-1.701-2.713-3.007-.66-1.305-.991-2.862-.991-4.67 0-1.814.33-3.372.991-4.675.66-1.302 1.565-2.303 2.713-3.003C6.852 2.35 8.16 2 9.624 2zm0 2.34c-.974 0-1.844.244-2.61.734-.765.489-1.37 1.208-1.813 2.156-.443.949-.664 2.114-.664 3.497s.221 2.548.664 3.497c.444.948 1.048 1.667 1.813 2.156.766.49 1.636.735 2.61.735.97 0 1.838-.245 2.606-.735.768-.489 1.374-1.208 1.817-2.156.443-.949.665-2.114.665-3.497s-.222-2.548-.665-3.497c-.443-.948-1.049-1.667-1.817-2.156-.768-.49-1.637-.735-2.606-.735zm16.32 1.974c1.024 0 1.938.26 2.742.78s1.436 1.269 1.896 2.248c.46.979.69 2.156.69 3.534 0 1.377-.23 2.556-.686 3.538-.457.981-1.085 1.736-1.883 2.264-.799.529-1.71.793-2.734.793-.771 0-1.4-.13-1.887-.39-.488-.26-.869-.564-1.144-.913a6.908 6.908 0 01-.636-.929h-.149V24h-2.47V6.48h2.412v2.065h.207c.143-.265.35-.572.62-.92.27-.349.643-.655 1.123-.917.479-.263 1.112-.394 1.9-.394zm-.528 2.107c-.716 0-1.32.185-1.813.556-.493.37-.866.887-1.12 1.55-.253.665-.38 1.439-.38 2.324 0 .896.13 1.68.389 2.356.259.674.633 1.201 1.123 1.58s1.09.568 1.8.568c.738 0 1.355-.198 1.85-.593.496-.395.872-.933 1.128-1.613.256-.68.384-1.447.384-2.298 0-.84-.125-1.596-.376-2.265-.25-.67-.625-1.197-1.123-1.584-.498-.388-1.12-.581-1.862-.581zm13.387-2.107c.716 0 1.41.119 2.082.356a5.037 5.037 0 011.809 1.12c.534.51.955 1.169 1.263 1.979.309.81.463 1.793.463 2.949v.88l-9.016-.001.002.105c.03.732.178 1.364.445 1.895.3.597.72 1.052 1.26 1.364.539.313 1.17.469 1.89.469.469 0 .895-.068 1.28-.203a2.716 2.716 0 001-.61c.281-.271.496-.606.644-1.004l2.338.423a4.247 4.247 0 01-1.004 1.813c-.482.517-1.084.918-1.808 1.203-.725.284-1.549.427-2.474.427-1.25 0-2.325-.27-3.225-.809-.9-.54-1.594-1.3-2.082-2.281-.487-.982-.73-2.134-.73-3.455 0-1.306.243-2.456.73-3.451.488-.996 1.17-1.773 2.049-2.331.878-.559 1.906-.838 3.084-.838zm.017 2.049c-.694 0-1.298.17-1.813.51-.515.34-.911.782-1.19 1.327a3.778 3.778 0 00-.39 1.303l-.02.236h6.593c0-.653-.132-1.232-.397-1.738a3.022 3.022 0 00-1.11-1.199c-.477-.293-1.034-.44-1.673-.44zm10.29 3.293v7.566H46.64V6.48h2.37v2.074h.158a3.63 3.63 0 011.375-1.626c.625-.41 1.413-.614 2.366-.614.864 0 1.622.18 2.271.543.65.362 1.154.9 1.512 1.614.358.713.537 1.595.537 2.646v8.105h-2.47v-7.806c0-.924-.24-1.647-.718-2.17-.48-.522-1.137-.784-1.974-.784-.573 0-1.081.125-1.524.374a2.65 2.65 0 00-1.05 1.09c-.255.479-.383 1.055-.383 1.73zm17.122-9.424c1.31 0 2.4.227 3.266.68.868.454 1.516 1.08 1.945 1.88.43.799.645 1.72.645 2.766 0 1.04-.216 1.954-.649 2.742-.432.788-1.082 1.4-1.949 1.837a5.1 5.1 0 01-.501.22l3.743 6.865h-2.907l-3.436-6.43h-3.634v6.43h-2.552V2.232h6.029zm-.273 2.199h-3.204v6.155h3.237c.826 0 1.5-.119 2.02-.357s.901-.583 1.144-1.037c.242-.453.363-.998.363-1.634 0-.641-.122-1.197-.367-1.667-.246-.47-.628-.831-1.148-1.083-.52-.252-1.202-.377-2.045-.377zM79.66 6.314c1.19 0 2.227.273 3.114.821.886.548 1.575 1.316 2.065 2.306s.735 2.146.735 3.468c0 1.316-.245 2.466-.735 3.45-.49.985-1.179 1.751-2.065 2.299-.887.547-1.924.82-3.114.82s-2.227-.273-3.113-.82c-.887-.548-1.575-1.314-2.065-2.298-.49-.985-.735-2.135-.735-3.451 0-1.322.245-2.478.735-3.468.49-.99 1.178-1.758 2.065-2.306.886-.548 1.924-.821 3.113-.821zm.008 2.074c-.776 0-1.419.207-1.928.622-.51.415-.887.963-1.132 1.646a6.602 6.602 0 00-.367 2.244c0 .819.122 1.568.367 2.249.245.68.623 1.225 1.132 1.634.51.41 1.152.614 1.928.614.771 0 1.41-.205 1.917-.614.506-.41.882-.954 1.127-1.634.245-.68.367-1.43.367-2.249 0-.813-.122-1.56-.367-2.244-.245-.683-.62-1.231-1.127-1.646-.507-.415-1.146-.622-1.917-.622zm16.164 5.55V6.48h2.477v12.742h-2.428v-2.207h-.132a3.956 3.956 0 01-1.4 1.697c-.641.45-1.438.676-2.391.676-.815 0-1.535-.181-2.16-.544-.625-.362-1.115-.9-1.47-1.613-.355-.714-.533-1.596-.533-2.647V6.48h2.47v7.806c0 .868.24 1.56.718 2.074.48.514 1.102.771 1.867.771.462 0 .924-.116 1.383-.348.46-.232.843-.584 1.148-1.054.306-.47.456-1.067.45-1.792zm8.58-10.511v3.052h2.602v1.992h-2.602v7.01c0 .48.072.841.215 1.082.144.24.33.404.558.49.228.085.478.128.747.128.199 0 .372-.014.52-.041l.348-.067.446 2.05a4.42 4.42 0 01-.612.17c-.264.057-.594.09-.99.095a4.331 4.331 0 01-1.818-.349 3.12 3.12 0 01-1.362-1.128c-.347-.509-.52-1.148-.52-1.916l-.002-7.525h-1.857V6.48h1.857l.001-3.053h2.47zm9.961 2.887c.716 0 1.41.119 2.081.356a5.037 5.037 0 011.81 1.12c.533.51.954 1.169 1.263 1.979.308.81.462 1.793.462 2.949v.88l-9.016-.001.003.105c.03.732.178 1.364.445 1.895.3.597.72 1.052 1.259 1.364.54.313 1.17.469 1.891.469.468 0 .895-.068 1.28-.203a2.716 2.716 0 001-.61c.28-.271.495-.606.644-1.004l2.337.423a4.247 4.247 0 01-1.003 1.813c-.482.517-1.085.918-1.809 1.203-.724.284-1.548.427-2.473.427-1.25 0-2.325-.27-3.226-.809-.9-.54-1.594-1.3-2.08-2.281-.488-.982-.732-2.134-.732-3.455 0-1.306.244-2.456.731-3.451.487-.996 1.17-1.773 2.048-2.331.879-.559 1.907-.838 3.085-.838zm.017 2.049c-.694 0-1.298.17-1.813.51-.515.34-.911.782-1.19 1.327a3.778 3.778 0 00-.39 1.303l-.02.236h6.592c0-.653-.132-1.232-.396-1.738a3.022 3.022 0 00-1.11-1.199c-.477-.293-1.035-.44-1.673-.44zm7.821 10.859V6.48h2.387v2.024h.132a3.092 3.092 0 011.227-1.622 3.485 3.485 0 011.994-.593l.396.01.153.006c.212.011.379.025.5.042v2.372c-.1-.027-.275-.059-.529-.095a5.4 5.4 0 00-.76-.054c-.583 0-1.102.123-1.556.37a2.799 2.799 0 00-1.078 1.02 2.79 2.79 0 00-.397 1.48v7.782h-2.469z"})]}))});function lS(e){"@babel/helpers - typeof";return lS=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},lS(e)}var yst=["type","iconProps"];function CU(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);r&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,i)}return n}function jU(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?CU(Object(n),!0).forEach(function(i){vst(e,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):CU(Object(n)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(n,i))})}return e}function vst(e,r,n){return r=xst(r),r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function xst(e){var r=bst(e,"string");return lS(r)=="symbol"?r:String(r)}function bst(e,r){if(lS(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var i=n.call(e,r);if(lS(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function _st(e,r){if(e==null)return{};var n=wst(e,r),i,s;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(s=0;s<o.length;s++)i=o[s],!(r.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(e,i)&&(n[i]=e[i])}return n}function wst(e,r){if(e==null)return{};var n={},i=Object.keys(e),s,o;for(o=0;o<i.length;o++)s=i[o],!(r.indexOf(s)>=0)&&(n[s]=e[s]);return n}var Sst=y.memo(function(e){var r=e.type,n=r===void 0?"mono":r,i=e.iconProps,s=_st(e,yst);return c.jsx(yc,jU({Icon:sL,Text:Ece,"aria-label":vk,iconProps:jU({color:n==="color"?iL:void 0},i),spaceMultiple:Yit,textMultiple:Kit},s))}),hx=sL;hx.Text=Ece;hx.Combine=Sst;hx.Avatar=ust;hx.colorPrimary=iL;hx.title=vk;var xk="Grok",kst=.75,Cst=.25,Ace="#fff",jst=Ace,Nst="#000",Tst=.65;function cS(e){"@babel/helpers - typeof";return cS=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},cS(e)}var Est=["size","style"];function NU(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);r&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,i)}return n}function _8(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?NU(Object(n),!0).forEach(function(i){Ast(e,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):NU(Object(n)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(n,i))})}return e}function Ast(e,r,n){return r=Ost(r),r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function Ost(e){var r=Mst(e,"string");return cS(r)=="symbol"?r:String(r)}function Mst(e,r){if(cS(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var i=n.call(e,r);if(cS(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function Rst(e,r){if(e==null)return{};var n=Pst(e,r),i,s;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(s=0;s<o.length;s++)i=o[s],!(r.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(e,i)&&(n[i]=e[i])}return n}function Pst(e,r){if(e==null)return{};var n={},i=Object.keys(e),s,o;for(o=0;o<i.length;o++)s=i[o],!(r.indexOf(s)>=0)&&(n[s]=e[s]);return n}var Oce=y.memo(function(e){var r=e.size,n=r===void 0?"1em":r,i=e.style,s=Rst(e,Est);return c.jsxs("svg",_8(_8({fill:"currentColor",fillRule:"evenodd",height:n,style:_8({flex:"none",lineHeight:1},i),viewBox:"0 0 24 24",width:n,xmlns:"http://www.w3.org/2000/svg"},s),{},{children:[c.jsx("title",{children:xk}),c.jsx("path",{d:"M6.469 8.776L16.512 23h-4.464L2.005 8.776H6.47zm-.004 7.9l2.233 3.164L6.467 23H2l4.465-6.324zM22 2.582V23h-3.659V7.764L22 2.582zM22 1l-9.952 14.095-2.233-3.163L17.533 1H22z"})]}))});function uS(e){"@babel/helpers - typeof";return uS=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},uS(e)}function TU(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);r&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,i)}return n}function Lst(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?TU(Object(n),!0).forEach(function(i){$st(e,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):TU(Object(n)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(n,i))})}return e}function $st(e,r,n){return r=Dst(r),r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function Dst(e){var r=Ist(e,"string");return uS(r)=="symbol"?r:String(r)}function Ist(e,r){if(uS(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var i=n.call(e,r);if(uS(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function Bst(e){if(e==null)throw new TypeError("Cannot destructure "+e)}var Mce=y.memo(function(e){var r=Object.assign({},(Bst(e),e));return c.jsx(gc,Lst({Icon:Oce,"aria-label":xk,background:jst,color:Nst,iconMultiple:Tst},r))});function dS(e){"@babel/helpers - typeof";return dS=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},dS(e)}var zst=["size","style"];function EU(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);r&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,i)}return n}function w8(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?EU(Object(n),!0).forEach(function(i){Fst(e,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):EU(Object(n)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(n,i))})}return e}function Fst(e,r,n){return r=Hst(r),r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function Hst(e){var r=Wst(e,"string");return dS(r)=="symbol"?r:String(r)}function Wst(e,r){if(dS(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var i=n.call(e,r);if(dS(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function Ust(e,r){if(e==null)return{};var n=Vst(e,r),i,s;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(s=0;s<o.length;s++)i=o[s],!(r.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(e,i)&&(n[i]=e[i])}return n}function Vst(e,r){if(e==null)return{};var n={},i=Object.keys(e),s,o;for(o=0;o<i.length;o++)s=i[o],!(r.indexOf(s)>=0)&&(n[s]=e[s]);return n}var Rce=y.memo(function(e){var r=e.size,n=r===void 0?"1em":r,i=e.style,s=Ust(e,zst);return c.jsxs("svg",w8(w8({fill:"currentColor",fillRule:"evenodd",height:n,style:w8({flex:"none",lineHeight:1},i),viewBox:"0 0 41 24",xmlns:"http://www.w3.org/2000/svg"},s),{},{children:[c.jsx("title",{children:xk}),c.jsx("path",{d:"M36.867 2h2.577v20h-2.577V2zM23.875 2h2.717l7.759 20H31.55l-2.101-5.574h-8.571L18.777 22h-2.69l7.788-20zm4.79 12.185l-3.53-9.272-3.473 9.272h7.003zM7.35 14.381L2.504 7.518h2.857l3.446 5.126 3.585-5.126h2.605l-4.762 6.835L15.501 22h-2.829l-3.977-5.854L4.689 22H2l5.35-7.619z"})]}))});function hS(e){"@babel/helpers - typeof";return hS=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},hS(e)}function AU(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);r&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,i)}return n}function qst(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?AU(Object(n),!0).forEach(function(i){Gst(e,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):AU(Object(n)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(n,i))})}return e}function Gst(e,r,n){return r=Kst(r),r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function Kst(e){var r=Yst(e,"string");return hS(r)=="symbol"?r:String(r)}function Yst(e,r){if(hS(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var i=n.call(e,r);if(hS(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function Xst(e){if(e==null)throw new TypeError("Cannot destructure "+e)}var Jst=y.memo(function(e){var r=Object.assign({},(Xst(e),e));return c.jsx(yc,qst({Icon:Mce,Text:Rce,"aria-label":xk,iconProps:{shape:"square"},spaceMultiple:Cst,textMultiple:kst},r))}),fx=Oce;fx.Text=Rce;fx.Combine=Jst;fx.Avatar=Mce;fx.colorPrimary=Ace;fx.title=xk;var bk="MoonshotAI",Zst=.75,Qst=.4,Pce="#16191E",eot=Pce,tot="#fff",rot=.75;function fS(e){"@babel/helpers - typeof";return fS=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},fS(e)}var not=["size","style"];function OU(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);r&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,i)}return n}function S8(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?OU(Object(n),!0).forEach(function(i){iot(e,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):OU(Object(n)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(n,i))})}return e}function iot(e,r,n){return r=sot(r),r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function sot(e){var r=oot(e,"string");return fS(r)=="symbol"?r:String(r)}function oot(e,r){if(fS(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var i=n.call(e,r);if(fS(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function aot(e,r){if(e==null)return{};var n=lot(e,r),i,s;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(s=0;s<o.length;s++)i=o[s],!(r.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(e,i)&&(n[i]=e[i])}return n}function lot(e,r){if(e==null)return{};var n={},i=Object.keys(e),s,o;for(o=0;o<i.length;o++)s=i[o],!(r.indexOf(s)>=0)&&(n[s]=e[s]);return n}var oL=y.memo(function(e){var r=e.size,n=r===void 0?"1em":r,i=e.style,s=aot(e,not);return c.jsxs("svg",S8(S8({fill:"currentColor",fillRule:"evenodd",height:n,style:S8({flex:"none",lineHeight:1},i),viewBox:"0 0 24 24",width:n,xmlns:"http://www.w3.org/2000/svg"},s),{},{children:[c.jsx("title",{children:bk}),c.jsx("path",{d:"M1.052 16.916l9.539 2.552a21.007 21.007 0 00.06 2.033l5.956 1.593a11.997 11.997 0 01-5.586.865l-.18-.016-.044-.004-.084-.009-.094-.01a11.605 11.605 0 01-.157-.02l-.107-.014-.11-.016a11.962 11.962 0 01-.32-.051l-.042-.008-.075-.013-.107-.02-.07-.015-.093-.019-.075-.016-.095-.02-.097-.023-.094-.022-.068-.017-.088-.022-.09-.024-.095-.025-.082-.023-.109-.03-.062-.02-.084-.025-.093-.028-.105-.034-.058-.019-.08-.026-.09-.031-.066-.024a6.293 6.293 0 01-.044-.015l-.068-.025-.101-.037-.057-.022-.08-.03-.087-.035-.088-.035-.079-.032-.095-.04-.063-.028-.063-.027a5.655 5.655 0 01-.041-.018l-.066-.03-.103-.047-.052-.024-.096-.046-.062-.03-.084-.04-.086-.044-.093-.047-.052-.027-.103-.055-.057-.03-.058-.032a6.49 6.49 0 01-.046-.026l-.094-.053-.06-.034-.051-.03-.072-.041-.082-.05-.093-.056-.052-.032-.084-.053-.061-.039-.079-.05-.07-.047-.053-.035a7.785 7.785 0 01-.054-.036l-.044-.03-.044-.03a6.066 6.066 0 01-.04-.028l-.057-.04-.076-.054-.069-.05-.074-.054-.056-.042-.076-.057-.076-.059-.086-.067-.045-.035-.064-.052-.074-.06-.089-.073-.046-.039-.046-.039a7.516 7.516 0 01-.043-.037l-.045-.04-.061-.053-.07-.062-.068-.06-.062-.058-.067-.062-.053-.05-.088-.084a13.28 13.28 0 01-.099-.097l-.029-.028-.041-.042-.069-.07-.05-.051-.05-.053a6.457 6.457 0 01-.168-.179l-.08-.088-.062-.07-.071-.08-.042-.049-.053-.062-.058-.068-.046-.056a7.175 7.175 0 01-.027-.033l-.045-.055-.066-.082-.041-.052-.05-.064-.02-.025a11.99 11.99 0 01-1.44-2.402zm-1.02-5.794l11.353 3.037a20.468 20.468 0 00-.469 2.011l10.817 2.894a12.076 12.076 0 01-1.845 2.005L.657 15.923l-.016-.046-.035-.104a11.965 11.965 0 01-.05-.153l-.007-.023a11.896 11.896 0 01-.207-.741l-.03-.126-.018-.08-.021-.097-.018-.081-.018-.09-.017-.084-.018-.094c-.026-.141-.05-.283-.071-.426l-.017-.118-.011-.083-.013-.102a12.01 12.01 0 01-.019-.161l-.005-.047a12.12 12.12 0 01-.034-2.145zm1.593-5.15l11.948 3.196c-.368.605-.705 1.231-1.01 1.875l11.295 3.022c-.142.82-.368 1.612-.668 2.365l-11.55-3.09L.124 10.26l.015-.1.008-.049.01-.067.015-.087.018-.098c.026-.148.056-.295.088-.442l.028-.124.02-.085.024-.097c.022-.09.045-.18.07-.268l.028-.102.023-.083.03-.1.025-.082.03-.096.026-.082.031-.095a11.896 11.896 0 011.01-2.232zm4.442-4.4L17.352 4.59a20.77 20.77 0 00-1.688 1.721l7.823 2.093c.267.852.442 1.744.513 2.665L2.106 5.213l.045-.065.027-.04.04-.055.046-.065.055-.076.054-.072.064-.086.05-.065.057-.073.055-.07.06-.074.055-.069.065-.077.054-.066.066-.077.053-.06.072-.082.053-.06.067-.074.054-.058.073-.078.058-.06.063-.067.168-.17.1-.098.059-.056.076-.071a12.084 12.084 0 012.272-1.677zM12.017 0h.097l.082.001.069.001.054.002.068.002.046.001.076.003.047.002.06.003.054.002.087.005.105.007.144.011.088.007.044.004.077.008.082.008.047.005.102.012.05.006.108.014.081.01.042.006.065.01.207.032.07.012.065.011.14.026.092.018.11.022.046.01.075.016.041.01L14.7.3l.042.01.065.015.049.012.071.017.096.024.112.03.113.03.113.032.05.015.07.02.078.024.073.023.05.016.05.016.076.025.099.033.102.036.048.017.064.023.093.034.11.041.116.045.1.04.047.02.06.024.041.018.063.026.04.018.057.025.11.048.1.046.074.035.075.036.06.028.092.046.091.045.102.052.053.028.049.026.046.024.06.033.041.022.052.029.088.05.106.06.087.051.057.034.053.032.096.059.088.055.098.062.036.024.064.041.084.056.04.027.062.042.062.043.023.017c.054.037.108.075.161.114l.083.06.065.048.056.043.086.065.082.064.04.03.05.041.086.069.079.065.085.071c.712.6 1.353 1.283 1.909 2.031L7.222.994l.062-.027.065-.028.081-.034.086-.035c.113-.045.227-.09.341-.131l.096-.035.093-.033.084-.03.096-.031c.087-.03.176-.058.264-.085l.091-.027.086-.025.102-.03.085-.023.1-.026L9.04.37l.09-.023.091-.022.095-.022.09-.02.098-.021.091-.02.095-.018.092-.018.1-.018.091-.016.098-.017.092-.014.097-.015.092-.013.102-.013.091-.012.105-.012.09-.01.105-.01c.093-.01.186-.018.28-.024l.106-.008.09-.005.11-.006.093-.004.1-.004.097-.002.099-.002.197-.002z"})]}))});function pS(e){"@babel/helpers - typeof";return pS=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},pS(e)}function MU(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);r&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,i)}return n}function cot(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?MU(Object(n),!0).forEach(function(i){uot(e,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):MU(Object(n)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(n,i))})}return e}function uot(e,r,n){return r=dot(r),r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function dot(e){var r=hot(e,"string");return pS(r)=="symbol"?r:String(r)}function hot(e,r){if(pS(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var i=n.call(e,r);if(pS(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function fot(e){if(e==null)throw new TypeError("Cannot destructure "+e)}var pot=y.memo(function(e){var r=Object.assign({},(fot(e),e));return c.jsx(gc,cot({Icon:oL,"aria-label":bk,background:eot,color:tot,iconMultiple:rot},r))});function mS(e){"@babel/helpers - typeof";return mS=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},mS(e)}var mot=["size","style"];function RU(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);r&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,i)}return n}function k8(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?RU(Object(n),!0).forEach(function(i){got(e,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):RU(Object(n)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(n,i))})}return e}function got(e,r,n){return r=yot(r),r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function yot(e){var r=vot(e,"string");return mS(r)=="symbol"?r:String(r)}function vot(e,r){if(mS(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var i=n.call(e,r);if(mS(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function xot(e,r){if(e==null)return{};var n=bot(e,r),i,s;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(s=0;s<o.length;s++)i=o[s],!(r.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(e,i)&&(n[i]=e[i])}return n}function bot(e,r){if(e==null)return{};var n={},i=Object.keys(e),s,o;for(o=0;o<i.length;o++)s=i[o],!(r.indexOf(s)>=0)&&(n[s]=e[s]);return n}var Lce=y.memo(function(e){var r=e.size,n=r===void 0?"1em":r,i=e.style,s=xot(e,mot);return c.jsxs("svg",k8(k8({fill:"currentColor",fillRule:"evenodd",height:n,style:k8({flex:"none",lineHeight:1},i),viewBox:"0 0 171 24",xmlns:"http://www.w3.org/2000/svg"},s),{},{children:[c.jsx("title",{children:bk}),c.jsx("path",{d:"M165.484 2H169v19.507h-3.516V2zm-35.707 0v5.26h3.186v3.507h-3.186v10.74h-3.516v-10.74h-2.966V7.26h2.966V2h3.516zm-24.598 11.023v8.498h-3.345v-8.804c.008-2.1-2.109-2.895-3.109-2.895l-.064.001c-1.073.026-3.521.694-3.54 3.863v7.835h-3.468V2.014L95.14 2v6.918c1.228-1.986 3.93-2.243 4.755-2.243.926 0 1.768.155 2.525.465.757.31 1.378.783 1.864 1.42.413.54.665 1.096.757 1.667.092.571.138 1.503.138 2.796zM89.29 9.507l-2.362 2.41c-2.911-2.41-6.647-2.136-7.196-.93-.55 1.205 2.444 1.484 4.734 1.98l.634.146c1.731.408 4.603 1.274 4.52 4.12-.11 3.78-4.23 4.767-6.867 4.767-2.637 0-5.933-1.808-7.636-3.342l2.527-2.63c2.582 2.63 7.142 2.958 7.856 1.534.714-1.425-1.263-1.48-4.834-1.973-3.175-.438-4.837-2.85-4.813-4.13.034-1.843 1.543-4.85 6.31-4.886 3.227-.025 5.425.961 7.127 2.934zm-22.617.386l-.033.001c-1.905.083-3.443 1.453-3.458 3.746v7.867h-3.83V7.185h3.702v2.061l.088-.12c.591-.8 2.07-2.555 4.796-2.523 2.675.032 5.696 1.95 5.696 5.17v9.734H69.69v-8.813c-.01-2.197-2.102-2.824-3.016-2.8zm-33.14-3.29c4.247 0 7.69 3.434 7.69 7.671s-3.443 7.671-7.69 7.671c-4.248 0-7.692-3.434-7.692-7.671s3.444-7.671 7.691-7.671zm0 3.726a3.95 3.95 0 00-3.956 3.945 3.95 3.95 0 003.955 3.945 3.95 3.95 0 003.956-3.945 3.95 3.95 0 00-3.956-3.945zm16.7-3.726c4.247 0 7.69 3.434 7.69 7.671s-3.443 7.671-7.69 7.671c-4.248 0-7.692-3.434-7.692-7.671s3.444-7.671 7.691-7.671zm0 3.726a3.95 3.95 0 00-3.956 3.945 3.95 3.95 0 003.955 3.945 3.95 3.95 0 003.956-3.945 3.95 3.95 0 00-3.956-3.945zm64.382-3.726c4.248 0 7.69 3.434 7.69 7.671s-3.442 7.671-7.69 7.671c-4.247 0-7.69-3.434-7.69-7.671s3.443-7.671 7.69-7.671zm0 3.726a3.95 3.95 0 00-3.955 3.945 3.95 3.95 0 003.955 3.945 3.95 3.95 0 003.955-3.945 3.95 3.95 0 00-3.955-3.945zM2 21.616V2l10.987 7.89L23.919 2v19.616h-3.79V9.452l-7.17 5.26-7.169-5.26v12.164H2zM153.344 2l10.492 19.507h-4.138l-1.833-3.288h-5.235l-1.789-3.46-3.632 6.748h-4.358L153.344 2zm0 8.11l-2.478 4.602h5.044l-2.566-4.602z"})]}))});function gS(e){"@babel/helpers - typeof";return gS=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},gS(e)}function PU(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);r&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,i)}return n}function _ot(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?PU(Object(n),!0).forEach(function(i){wot(e,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):PU(Object(n)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(n,i))})}return e}function wot(e,r,n){return r=Sot(r),r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function Sot(e){var r=kot(e,"string");return gS(r)=="symbol"?r:String(r)}function kot(e,r){if(gS(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var i=n.call(e,r);if(gS(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function Cot(e){if(e==null)throw new TypeError("Cannot destructure "+e)}var jot=y.memo(function(e){var r=Object.assign({},(Cot(e),e));return c.jsx(yc,_ot({Icon:oL,Text:Lce,"aria-label":bk,spaceMultiple:Qst,textMultiple:Zst},r))}),px=oL;px.Text=Lce;px.Combine=jot;px.Avatar=pot;px.colorPrimary=Pce;px.title=bk;var mx="Kimi",Not=.7,Tot=.25,$ce="#000",Eot=$ce,Aot="#fff",Oot=.6;function yS(e){"@babel/helpers - typeof";return yS=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},yS(e)}var Mot=["size","style"];function LU(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);r&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,i)}return n}function C8(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?LU(Object(n),!0).forEach(function(i){Rot(e,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):LU(Object(n)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(n,i))})}return e}function Rot(e,r,n){return r=Pot(r),r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function Pot(e){var r=Lot(e,"string");return yS(r)=="symbol"?r:String(r)}function Lot(e,r){if(yS(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var i=n.call(e,r);if(yS(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function $ot(e,r){if(e==null)return{};var n=Dot(e,r),i,s;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(s=0;s<o.length;s++)i=o[s],!(r.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(e,i)&&(n[i]=e[i])}return n}function Dot(e,r){if(e==null)return{};var n={},i=Object.keys(e),s,o;for(o=0;o<i.length;o++)s=i[o],!(r.indexOf(s)>=0)&&(n[s]=e[s]);return n}var Dce=y.memo(function(e){var r=e.size,n=r===void 0?"1em":r,i=e.style,s=$ot(e,Mot);return c.jsxs("svg",C8(C8({height:n,style:C8({flex:"none",lineHeight:1},i),viewBox:"0 0 24 24",width:n,xmlns:"http://www.w3.org/2000/svg"},s),{},{children:[c.jsx("title",{children:mx}),c.jsx("path",{d:"M21.846 0a1.923 1.923 0 110 3.846H20.15a.226.226 0 01-.227-.226V1.923C19.923.861 20.784 0 21.846 0z",fill:"#1783FF"}),c.jsx("path",{d:"M11.065 11.199l7.257-7.2c.137-.136.06-.41-.116-.41H14.3a.164.164 0 00-.117.051l-7.82 7.756c-.122.12-.302.013-.302-.179V3.82c0-.127-.083-.23-.185-.23H3.186c-.103 0-.186.103-.186.23V19.77c0 .128.083.23.186.23h2.69c.103 0 .186-.102.186-.23v-3.25c0-.069.025-.135.069-.178l2.424-2.406a.158.158 0 01.205-.023l6.484 4.772a7.677 7.677 0 003.453 1.283c.108.012.2-.095.2-.23v-3.06c0-.117-.07-.212-.164-.227a5.028 5.028 0 01-2.027-.807l-5.613-4.064c-.117-.078-.132-.279-.028-.381z",fill:"#fff"})]}))});function vS(e){"@babel/helpers - typeof";return vS=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},vS(e)}function $U(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);r&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,i)}return n}function Iot(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?$U(Object(n),!0).forEach(function(i){Bot(e,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):$U(Object(n)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(n,i))})}return e}function Bot(e,r,n){return r=zot(r),r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function zot(e){var r=Fot(e,"string");return vS(r)=="symbol"?r:String(r)}function Fot(e,r){if(vS(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var i=n.call(e,r);if(vS(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function Hot(e){if(e==null)throw new TypeError("Cannot destructure "+e)}var Ice=y.memo(function(e){var r=Object.assign({},(Hot(e),e));return c.jsx(gc,Iot({Icon:Dce,"aria-label":mx,background:Eot,color:Aot,iconMultiple:Oot},r))});function xS(e){"@babel/helpers - typeof";return xS=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},xS(e)}var Wot=["size","style"];function DU(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);r&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,i)}return n}function j8(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?DU(Object(n),!0).forEach(function(i){Uot(e,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):DU(Object(n)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(n,i))})}return e}function Uot(e,r,n){return r=Vot(r),r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function Vot(e){var r=qot(e,"string");return xS(r)=="symbol"?r:String(r)}function qot(e,r){if(xS(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var i=n.call(e,r);if(xS(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function Got(e,r){if(e==null)return{};var n=Kot(e,r),i,s;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(s=0;s<o.length;s++)i=o[s],!(r.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(e,i)&&(n[i]=e[i])}return n}function Kot(e,r){if(e==null)return{};var n={},i=Object.keys(e),s,o;for(o=0;o<i.length;o++)s=i[o],!(r.indexOf(s)>=0)&&(n[s]=e[s]);return n}var Bce=y.memo(function(e){var r=e.size,n=r===void 0?"1em":r,i=e.style,s=Got(e,Wot);return c.jsxs("svg",j8(j8({fill:"currentColor",fillRule:"evenodd",height:n,style:j8({flex:"none",lineHeight:1},i),viewBox:"0 0 64 24",xmlns:"http://www.w3.org/2000/svg"},s),{},{children:[c.jsx("title",{children:mx}),c.jsx("path",{d:"M24.353 21.58c0 .232.188.42.42.42h2.69a.42.42 0 00.42-.42V2.42a.42.42 0 00-.42-.42h-2.69a.42.42 0 00-.42.42v19.16zM58.47 21.58c0 .232.188.42.42.42h2.691a.42.42 0 00.419-.42V2.42a.42.42 0 00-.419-.42H58.89a.42.42 0 00-.42.42v19.16zM47.786 2a.42.42 0 00-.408.32L43.4 18.633c-.066.267-.38.267-.444 0L38.976 2.32A.417.417 0 0038.57 2H31.83a.418.418 0 00-.418.42v19.16c0 .232.188.42.42.42h2.988c.231 0 .419-.182.419-.414V5.471c0-.322.378-.389.454-.079l3.974 16.288a.42.42 0 00.407.32h6.208a.42.42 0 00.407-.32L50.66 5.394c.076-.31.455-.243.455.079V21.58c0 .231.187.419.419.419h2.987a.42.42 0 00.42-.42V2.42a.42.42 0 00-.42-.42h-6.735zM11.55 11.273l8.115-8.565A.42.42 0 0019.36 2h-3.776a.42.42 0 00-.298.124l-9.303 9.39c-.144.146-.357.016-.357-.218V2.42a.42.42 0 00-.42-.42H2.42a.42.42 0 00-.42.42v19.16c0 .232.188.42.42.42h2.786a.42.42 0 00.42-.42v-3.82c0-.085.03-.166.081-.219l2.87-2.931c.07-.07.166-.081.243-.029l7.678 5.816c1.123.778 2.552 1.288 3.861 1.5a.403.403 0 00.464-.404v-3.461c0-.206-.15-.38-.35-.423-.76-.164-1.604-.474-2.244-.918l-6.647-4.953c-.138-.095-.155-.34-.033-.465z"})]}))});function bS(e){"@babel/helpers - typeof";return bS=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},bS(e)}var Yot=["iconProps"];function IU(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);r&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,i)}return n}function BU(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?IU(Object(n),!0).forEach(function(i){Xot(e,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):IU(Object(n)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(n,i))})}return e}function Xot(e,r,n){return r=Jot(r),r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function Jot(e){var r=Zot(e,"string");return bS(r)=="symbol"?r:String(r)}function Zot(e,r){if(bS(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var i=n.call(e,r);if(bS(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function Qot(e,r){if(e==null)return{};var n=eat(e,r),i,s;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(s=0;s<o.length;s++)i=o[s],!(r.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(e,i)&&(n[i]=e[i])}return n}function eat(e,r){if(e==null)return{};var n={},i=Object.keys(e),s,o;for(o=0;o<i.length;o++)s=i[o],!(r.indexOf(s)>=0)&&(n[s]=e[s]);return n}var tat=y.memo(function(e){var r=e.iconProps,n=Qot(e,Yot);return c.jsx(yc,BU({Icon:Ice,Text:Bce,"aria-label":mx,iconProps:BU({shape:"square"},r),spaceMultiple:Tot,textMultiple:Not},n))});function _S(e){"@babel/helpers - typeof";return _S=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},_S(e)}var rat=["size","style"];function zU(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);r&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,i)}return n}function N8(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?zU(Object(n),!0).forEach(function(i){nat(e,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):zU(Object(n)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(n,i))})}return e}function nat(e,r,n){return r=iat(r),r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function iat(e){var r=sat(e,"string");return _S(r)=="symbol"?r:String(r)}function sat(e,r){if(_S(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var i=n.call(e,r);if(_S(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function oat(e,r){if(e==null)return{};var n=aat(e,r),i,s;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(s=0;s<o.length;s++)i=o[s],!(r.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(e,i)&&(n[i]=e[i])}return n}function aat(e,r){if(e==null)return{};var n={},i=Object.keys(e),s,o;for(o=0;o<i.length;o++)s=i[o],!(r.indexOf(s)>=0)&&(n[s]=e[s]);return n}var lat=y.memo(function(e){var r=e.size,n=r===void 0?"1em":r,i=e.style,s=oat(e,rat);return c.jsxs("svg",N8(N8({fill:"currentColor",fillRule:"evenodd",height:n,style:N8({flex:"none",lineHeight:1},i),viewBox:"0 0 24 24",width:n,xmlns:"http://www.w3.org/2000/svg"},s),{},{children:[c.jsx("title",{children:mx}),c.jsx("path",{d:"M21.846 0a1.923 1.923 0 110 3.846H20.15a.226.226 0 01-.227-.226V1.923C19.923.861 20.784 0 21.846 0z"}),c.jsx("path",{d:"M11.065 11.199l7.257-7.2c.137-.136.06-.41-.116-.41H14.3a.164.164 0 00-.117.051l-7.82 7.756c-.122.12-.302.013-.302-.179V3.82c0-.127-.083-.23-.185-.23H3.186c-.103 0-.186.103-.186.23V19.77c0 .128.083.23.186.23h2.69c.103 0 .186-.102.186-.23v-3.25c0-.069.025-.135.069-.178l2.424-2.406a.158.158 0 01.205-.023l6.484 4.772a7.677 7.677 0 003.453 1.283c.108.012.2-.095.2-.23v-3.06c0-.117-.07-.212-.164-.227a5.028 5.028 0 01-2.027-.807l-5.613-4.064c-.117-.078-.132-.279-.028-.381z"})]}))}),Ay=lat;Ay.Color=Dce;Ay.Text=Bce;Ay.Combine=tat;Ay.Avatar=Ice;Ay.colorPrimary=$ce;Ay.title=mx;const zce=[{label:"OpenAI / Jait",fields:["OPENAI_API_KEY","OPENAI_BASE_URL","OPENAI_MODEL","OPENAI_TRANSCRIBE_MODEL","OPENAI_WEB_SEARCH_MODEL"]},{label:"Ollama",fields:["OLLAMA_URL","OLLAMA_MODEL"]},{label:"Perplexity",fields:["PERPLEXITY_API_KEY","PERPLEXITY_MODEL","PERPLEXITY_OPENROUTER_MODEL"]},{label:"OpenRouter",fields:["OPENROUTER_API_KEY"]},{label:"xAI / Grok",fields:["XAI_API_KEY","GROK_MODEL"]},{label:"Google Gemini",fields:["GEMINI_API_KEY","GEMINI_MODEL"]},{label:"Moonshot / Kimi",fields:["MOONSHOT_API_KEY","KIMI_BASE_URL","KIMI_MODEL"]},{label:"Brave Search",fields:["BRAVE_API_KEY"]},{label:"Speech / Home Assistant",fields:["WHISPER_URL","HA_URL","HA_TOKEN","HA_STT_ENTITY","ELEVENLABS_API_KEY","ELEVENLABS_STT_MODEL","ELEVENLABS_STT_URL","ELEVENLABS_LANGUAGE_CODE"]}],FU=zce.flatMap(e=>e.fields),cat={OPENAI:us,PERPLEXITY:Ey,OPENROUTER:hx,XAI:fx,GEMINI:Np,ELEVENLABS:bY,MOONSHOT:px,KIMI:Ay,GROK:Sy,OLLAMA:wy,HA:yY};function uat(e){const r=e.split("_")[0];return cat[r]??null}function dat(e){return e.endsWith("_KEY")||e.endsWith("_URL")}const hat=Kn(),HU={jait:"Jait",codex:"Codex","claude-code":"Claude Code"};function fat(e){const r=e.auth;return e.id==="jait"||!r?!1:r.login||r.logout||r.authenticated!==null}function pat({username:e,token:r,apiKeys:n,onSaveApiKeys:i,sttProvider:s,onSttProviderChange:o,jaitBackend:a,onJaitBackendChange:l,onClearArchive:u,onClearArchivedProjects:d,onFetchArchivedProjects:h,onRestoreProject:f,activityEvents:g,updateInfo:v,updateChecking:b,onCheckUpdate:_,onApplyUpdate:w,updateApplying:S,platform:C}){const[j,E]=y.useState(n),[A,N]=y.useState(!1),[P,H]=y.useState(!1),[K,F]=y.useState(!1),[B,W]=y.useState([]),[D,O]=y.useState(!1),[I,R]=y.useState(null),[$,U]=y.useState(null),[Y,z]=y.useState(null),[V,Q]=y.useState({}),[q,re]=y.useState({}),[ee,ne]=y.useState([]),[ae,te]=y.useState(!1),[ue,he]=y.useState(null),[we,pe]=y.useState("general"),[qe,se]=y.useState(""),it=y.useRef(null),{importedThemes:Ye,activeTheme:ht}=ite(),[qt,Nt]=y.useState(!1),[Xt,Wt]=y.useState(null);y.useEffect(()=>{var ye;C!=="electron"||!((ye=window.jaitDesktop)!=null&&ye.getInfo)||window.jaitDesktop.getInfo().then(st=>{st.appVersion&&Wt(st.appVersion)})},[C]),y.useEffect(()=>{var ye;C!=="electron"||!((ye=window.jaitDesktop)!=null&&ye.getSetting)||window.jaitDesktop.getSetting("closeOnWindowClose",!1).then(st=>{Nt(st===!0)})},[C]),y.useEffect(()=>{E(n)},[n]);const gt=FU.some(ye=>(j[ye]??"")!==(n[ye]??"")),Re=y.useCallback(async()=>{if(r){te(!0);try{const{providers:ye}=await xr.listProvidersFresh();ne(ye.filter(fat))}catch{ne([])}finally{te(!1)}}},[r]);y.useEffect(()=>{Re()},[Re]);const kt=async ye=>{var ir;const st=((ir=ee.find(At=>At.id===ye))==null?void 0:ir.name)??HU[ye]??ye;he(ye),z(null),U(null);try{const At=await xr.logoutProvider(ye);U(At.message||`${st} logout completed.`),await Re()}catch(At){z(At instanceof Error?At.message:`Failed to log out from ${st}.`)}finally{he(null)}},Pt=y.useCallback(()=>{E(n),U(null),z(null)},[n]);y.useEffect(()=>{if(!r)return;let ye=!1;return(async()=>{try{const st=await fetch(`${hat}/auth/settings/env-status`,{headers:{Authorization:`Bearer ${r}`}});if(st.ok&&!ye){const ir=await st.json();Q(ir.env_set)}}catch{}})(),()=>{ye=!0}},[r]);const Ne=y.useCallback(ye=>{re(st=>({...st,[ye]:!st[ye]}))},[]),ze=async()=>{N(!0),z(null),U(null);try{await i(j),U("API keys saved.")}catch(ye){z(ye instanceof Error?ye.message:"Failed to save API keys")}finally{N(!1)}},Qe=async()=>{H(!0),z(null),U(null);try{const ye=await u();U(`Cleared ${ye} archived session(s).`)}catch(ye){z(ye instanceof Error?ye.message:"Failed to clear archive")}finally{H(!1)}},lt=async()=>{F(!0),z(null),U(null);try{const ye=await d();W([]),U(`Cleared ${ye} archived project(s).`)}catch(ye){z(ye instanceof Error?ye.message:"Failed to clear archived projects")}finally{F(!1)}},yt=y.useCallback(async()=>{O(!0);try{const ye=await h();W(ye)}finally{O(!1)}},[h]),Tt=async ye=>{R(ye);try{await f(ye)?(W(ir=>ir.filter(At=>At.id!==ye)),U("Project restored.")):z("Failed to restore project.")}catch{z("Failed to restore project.")}finally{R(null)}},dr=y.useCallback(async ye=>{var ir;const st=(ir=ye.target.files)==null?void 0:ir[0];if(ye.target.value="",!!st){z(null),U(null);try{const At=sDe(st.name,await st.text());U(At.hasInclude?`Imported theme "${At.name}". Relative "include" files are not resolved yet.`:`Imported theme "${At.name}".`)}catch(At){z(At instanceof Error?At.message:"Failed to import theme")}}},[]);function De(ye){var At;const st=!!((At=j[ye])!=null&&At.trim()),ir=!!V[ye];return st?c.jsx($r,{variant:"default",className:"text-2xs px-1.5 py-0",children:"user"}):ir?c.jsx($r,{variant:"success",className:"text-2xs px-1.5 py-0",children:".env"}):c.jsx($r,{variant:"outline",className:"text-2xs px-1.5 py-0 text-muted-foreground",children:"empty"})}const je=qe.trim().toLowerCase(),be=(...ye)=>!je||ye.some(st=>st==null?void 0:st.toLowerCase().includes(je)),Be=ye=>c.jsx("span",{dangerouslySetInnerHTML:{__html:uit(ye,qe)}}),at=be("software update version gateway desktop release download install",v==null?void 0:v.currentVersion,v==null?void 0:v.latestVersion,Xt),Ve=C==="electron"&&be("desktop tray close window quit minimize app",Xt),Mt=C!=="web"&&be("gateway connection url domain ip server host network",Kn()),It=be("session archive archived clear delete messages history"),rr=be("project archive archived clear delete projects remove"),nr=be("jait backend provider openai openrouter model api llm",a),Ut=be("provider accounts login logout codex claude gemini opencode copilot authentication",...ee.map(ye=>{var st;return`${ye.name} ${((st=ye.auth)==null?void 0:st.detail)??""}`})),Se=be("speech stt input microphone whisper wyoming home assistant transcription gpt openai elevenlabs scribe",s,j.WHISPER_URL,j.HA_URL,j.HA_TOKEN,j.HA_STT_ENTITY,j.OPENAI_TRANSCRIBE_MODEL,j.ELEVENLABS_API_KEY,j.ELEVENLABS_STT_MODEL,j.ELEVENLABS_STT_URL,j.ELEVENLABS_LANGUAGE_CODE),Fe=FU.filter(ye=>be(ye,ye.replaceAll("_"," "),j[ye])),et=be("tools permissions mcp core standard external toggle meta terminal filesystem os agent browser web surfaces scheduler memory voice screen gateway"),St=be("activity recent messages terminal sessions feed history"),Xe=be("extensions plugins store install uninstall enable disable"),Lt=be("skills instructions prompts specialized workflows SKILL.md"),Et=be(...H$e(),"import json token colors workbench sidebar tabs"),Ft=c.jsx(gn,{className:"p-5",children:c.jsxs("p",{className:"text-sm text-muted-foreground",children:["No settings match ",c.jsx("span",{className:"font-medium text-foreground",children:qe}),"."]})});return c.jsxs("div",{className:"mx-auto w-full max-w-5xl space-y-6 p-4 sm:p-6",children:[c.jsxs("div",{className:"flex flex-col gap-4 md:flex-row md:items-end md:justify-between",children:[c.jsxs("div",{children:[c.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Settings"}),c.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:["Signed in as ",c.jsx("span",{className:"font-medium text-foreground",children:e})]})]}),c.jsxs("div",{className:"relative w-full md:max-w-sm",children:[c.jsx(tl,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),c.jsx(Pn,{value:qe,onChange:ye=>se(ye.target.value),placeholder:"Search settings...",className:"pl-9"})]})]}),c.jsxs(Y0,{value:we,onValueChange:ye=>pe(ye),className:"space-y-4",children:[c.jsxs(ag,{className:"flex h-auto w-full flex-wrap justify-start gap-1 rounded-xl bg-muted/70 p-1",children:[c.jsx(so,{value:"general",className:"flex-1 sm:flex-none",children:"General"}),c.jsx(so,{value:"api",className:"flex-1 sm:flex-none",children:"API"}),c.jsx(so,{value:"tools",className:"flex-1 sm:flex-none",children:"Tools"}),c.jsx(so,{value:"extensions",className:"flex-1 sm:flex-none",children:"Extensions"}),c.jsx(so,{value:"skills",className:"flex-1 sm:flex-none",children:"Skills"}),c.jsx(so,{value:"activity",className:"flex-1 sm:flex-none",children:"Activity"})]}),c.jsxs(oo,{value:"general",className:"space-y-6",children:[at&&c.jsxs(gn,{className:"space-y-4 p-5",children:[c.jsxs("div",{children:[c.jsxs("h2",{className:"flex items-center gap-2 text-base font-medium",children:[c.jsx(fY,{className:"h-4 w-4"}),Be("Software Update")]}),c.jsxs("p",{className:"text-sm text-muted-foreground",children:[v?c.jsxs(c.Fragment,{children:["Gateway ",c.jsxs("span",{className:"font-mono font-medium text-foreground",children:["v",v.currentVersion]})]}):"Check for the latest Jait version.",Xt&&c.jsxs(c.Fragment,{children:[" · Desktop app ",c.jsxs("span",{className:"font-mono font-medium text-foreground",children:["v",Xt]})]})]})]}),c.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[c.jsxs(_e,{variant:"outline",size:"sm",onClick:_,disabled:b||S,children:[b?c.jsx(Vt,{className:"mr-1.5 h-4 w-4 animate-spin"}):null,b?"Checking...":"Check for updates"]}),(v==null?void 0:v.hasUpdate)&&c.jsxs(c.Fragment,{children:[c.jsxs(_e,{size:"sm",onClick:w,disabled:S,children:[S?c.jsx(Vt,{className:"mr-1.5 h-4 w-4 animate-spin"}):c.jsx(Zm,{className:"mr-1.5 h-4 w-4"}),S?"Updating...":`Update gateway to v${v.latestVersion}`]}),C==="electron"?c.jsxs(_e,{size:"sm",variant:"outline",onClick:async()=>{const ye=window.jaitDesktop;(await ye.checkForUpdate()).updateAvailable&&(await ye.downloadUpdate(),await ye.installUpdate())},children:[c.jsx(Zm,{className:"mr-1.5 h-4 w-4"}),"Update desktop app"]}):C!=="web"&&c.jsx(_e,{size:"sm",variant:"outline",asChild:!0,children:c.jsxs("a",{href:"https://github.com/Widev-e-U/Jait/releases/latest",target:"_blank",rel:"noopener noreferrer",children:[c.jsx(Zm,{className:"mr-1.5 h-4 w-4"}),"Download latest APK"]})})]})]}),v&&!v.hasUpdate&&c.jsxs("p",{className:"flex items-center gap-1.5 text-sm text-green-600 dark:text-green-400",children:[c.jsx(uo,{className:"h-3.5 w-3.5"}),"You're on the latest version."]}),(v==null?void 0:v.hasUpdate)&&c.jsxs("p",{className:"flex items-center gap-1.5 text-sm text-amber-600 dark:text-amber-400",children:[c.jsx(ia,{className:"h-3.5 w-3.5"}),"Version ",v.latestVersion," is available",C!=="web"?" — download from jait.dev":"","."]})]}),Et&&c.jsxs(gn,{className:"space-y-4 p-5",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-base font-medium",children:Be("Editor theme")}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Import a VS Code theme JSON file and apply its Monaco token colors plus a mapped shell palette."})]}),c.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[c.jsx("input",{ref:it,type:"file",accept:".json,application/json",className:"hidden",onChange:ye=>{dr(ye)}}),c.jsx(_e,{variant:"outline",size:"sm",onClick:()=>{var ye;return(ye=it.current)==null?void 0:ye.click()},children:"Import theme JSON"}),c.jsx(_e,{variant:"ghost",size:"sm",disabled:!ht,onClick:()=>gj(null),children:"Use built-in theme"})]}),c.jsx("p",{className:"text-xs text-muted-foreground",children:"Imported themes stay local to this device. The quick light/system/dark toggle falls back to the built-in theme set."}),Ye.length>0?c.jsx("div",{className:"space-y-2",children:Ye.map(ye=>{const st=(ht==null?void 0:ht.id)===ye.id;return c.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-lg border px-3 py-2",children:[c.jsxs("div",{className:"min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("p",{className:"truncate text-sm font-medium",children:ye.name}),c.jsx($r,{variant:st?"default":"outline",className:"h-5 px-1.5 text-2xs",children:st?"active":ye.colorMode})]}),c.jsx("p",{className:"truncate text-xs text-muted-foreground",children:ye.sourceLabel})]}),c.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[!st&&c.jsx(_e,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>gj(ye.id),children:"Apply"}),c.jsx(_e,{variant:"ghost",size:"sm",className:"h-7 text-xs text-destructive hover:text-destructive",onClick:()=>oDe(ye.id),children:"Remove"})]})]},ye.id)})}):c.jsx("p",{className:"text-sm text-muted-foreground",children:"No imported themes yet."})]}),Ve&&c.jsxs(gn,{className:"space-y-4 p-5",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-base font-medium",children:Be("Desktop")}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Settings specific to the desktop application."})]}),c.jsxs("div",{className:"flex max-w-md items-center justify-between gap-4",children:[c.jsxs("div",{children:[c.jsx(di,{htmlFor:"close-on-window-close",children:"Quit on window close"}),c.jsx("p",{className:"text-xs text-muted-foreground",children:"When off, closing the window minimizes Jait to the system tray."})]}),c.jsx(Ap,{id:"close-on-window-close",checked:qt,onCheckedChange:ye=>{var st;Nt(ye),(st=window.jaitDesktop)==null||st.setSetting("closeOnWindowClose",ye)}})]})]}),Mt&&c.jsxs(gn,{className:"space-y-4 p-5",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-base font-medium",children:Be("Gateway connection")}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Desktop and mobile clients can connect to a different Jait gateway."})]}),c.jsxs("p",{className:"text-xs text-muted-foreground",children:["Current gateway: ",c.jsx("code",{className:"rounded bg-muted px-1 py-0.5 text-xs",children:Kn()})]})]}),It&&c.jsxs(gn,{className:"space-y-4 p-5",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-base font-medium",children:Be("Session archive")}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Permanently remove archived sessions and their messages from your account."})]}),c.jsx("div",{children:c.jsx(_e,{variant:"destructive",onClick:()=>{Qe()},disabled:P,children:P?"Clearing...":"Clear archived sessions"})})]}),rr&&c.jsxs(gn,{className:"space-y-4 p-5",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-base font-medium",children:Be("Project archive")}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Restore or permanently remove archived projects and their sessions."})]}),c.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:flex-wrap",children:[c.jsx(_e,{className:"w-full sm:w-auto",variant:"outline",onClick:()=>{yt()},disabled:D,children:D?c.jsxs(c.Fragment,{children:[c.jsx(Vt,{className:"mr-2 h-3.5 w-3.5 animate-spin"})," Loading..."]}):"Show archived projects"}),c.jsx(_e,{className:"w-full sm:w-auto",variant:"destructive",onClick:()=>{lt()},disabled:K,children:K?"Clearing...":"Clear all archived"})]}),B.length>0&&c.jsx("div",{className:"space-y-2",children:B.map(ye=>c.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-lg border px-3 py-2",children:[c.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[c.jsx(gR,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),c.jsxs("div",{className:"min-w-0",children:[c.jsx("p",{className:"text-sm font-medium truncate",children:ye.title||ye.rootPath||ye.id}),ye.rootPath&&ye.title&&c.jsx("p",{className:"text-xs text-muted-foreground truncate",children:ye.rootPath})]})]}),c.jsxs(_e,{variant:"outline",size:"sm",className:"shrink-0 h-7 text-xs",onClick:()=>{Tt(ye.id)},disabled:I===ye.id,children:[I===ye.id?c.jsx(Vt,{className:"mr-1.5 h-3 w-3 animate-spin"}):c.jsx(j0e,{className:"mr-1.5 h-3 w-3"}),"Restore"]})]},ye.id))})]}),nr&&c.jsxs(gn,{className:"space-y-4 p-5",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-base font-medium",children:Be("Jait LLM Backend")}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose which API backend the Jait provider uses for model inference."})]}),c.jsxs("div",{className:"max-w-sm",children:[c.jsx(di,{htmlFor:"jait-backend",className:"mb-1.5 block",children:"Backend provider"}),c.jsxs(th,{value:a,onValueChange:ye=>{l(ye)},children:[c.jsx(Zu,{id:"jait-backend",children:c.jsx(rh,{placeholder:"Select backend"})}),c.jsxs(Qu,{children:[c.jsx(Ls,{value:"openai",children:"OpenAI (direct)"}),c.jsx(Ls,{value:"openrouter",children:"OpenRouter"}),c.jsx(Ls,{value:"ollama",children:"Ollama (local)"})]})]}),c.jsx("p",{className:"mt-1.5 text-xs text-muted-foreground",children:a==="openrouter"?"Models will be fetched from OpenRouter. Set your OPENROUTER_API_KEY in the API tab.":a==="ollama"?"Models will be fetched from your local Ollama instance. Set OLLAMA_URL in the API tab if not running on localhost:11434.":"Uses your OPENAI_API_KEY and OPENAI_BASE_URL."})]})]}),Ut&&c.jsxs(gn,{className:"space-y-4 p-5",children:[c.jsxs("div",{className:"flex items-start justify-between gap-3",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-base font-medium",children:Be("Provider accounts")}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage CLI provider sessions. Login is started from the provider picker; logout is handled here."})]}),c.jsxs(_e,{variant:"outline",size:"sm",onClick:()=>{Re()},disabled:ae,children:[ae?c.jsx(Vt,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):c.jsx(io,{className:"mr-1.5 h-3.5 w-3.5"}),"Refresh"]})]}),c.jsx("div",{className:"space-y-2",children:ee.length===0&&!ae?c.jsx("p",{className:"text-sm text-muted-foreground",children:"No provider account actions are available on this gateway."}):ee.map(ye=>{const st=ye.auth,ir=ye.id,At=(st==null?void 0:st.authenticated)===!0,hr=(st==null?void 0:st.authenticated)===!1,Vr=ue===ir;return c.jsxs("div",{className:"flex flex-col gap-3 rounded-lg border px-3 py-3 sm:flex-row sm:items-center sm:justify-between",children:[c.jsxs("div",{className:"min-w-0",children:[c.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[c.jsx("p",{className:"text-sm font-medium",children:HU[ir]??ye.name}),c.jsx($r,{variant:At?"success":"outline",className:"text-2xs",children:At?"signed in":(st==null?void 0:st.authenticated)===!1?"signed out":"unknown"})]}),(st==null?void 0:st.detail)&&c.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:st.detail})]}),(st==null?void 0:st.logout)&&c.jsxs(_e,{className:"w-full sm:w-auto",variant:"outline",size:"sm",onClick:()=>{kt(ir)},disabled:Vr||ue!==null||hr,children:[Vr?c.jsx(Vt,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):c.jsx(gA,{className:"mr-1.5 h-3.5 w-3.5"}),"Logout"]})]},ye.id)})})]}),Se&&c.jsxs(gn,{className:"space-y-4 p-5",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-base font-medium",children:Be("Spracheingabe (Speech-to-Text)")}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Wähle aus, wie gesprochene Sprache in Text umgewandelt wird, bevor sie als Nachricht gesendet wird."})]}),c.jsxs("div",{className:"max-w-sm",children:[c.jsx(di,{htmlFor:"stt-provider",className:"mb-1.5 block",children:"STT-Anbieter"}),c.jsxs(th,{value:s,onValueChange:ye=>{o(ye)},children:[c.jsx(Zu,{id:"stt-provider",children:c.jsx(rh,{placeholder:"STT-Anbieter wählen"})}),c.jsxs(Qu,{children:[c.jsx(Ls,{value:"whisper",children:"Faster Whisper (lokal)"}),c.jsx(Ls,{value:"gpt",children:"GPT (OpenAI)"}),c.jsx(Ls,{value:"elevenlabs",children:"ElevenLabs Scribe"}),c.jsx(Ls,{value:"wyoming",children:"Wyoming / Whisper (Home Assistant)"})]})]})]}),s==="whisper"&&c.jsx("div",{className:"max-w-sm space-y-3 border-l-2 border-primary/20 pl-4",children:c.jsxs("p",{className:"text-xs text-muted-foreground",children:["Uses a local Faster Whisper server for free, offline transcription. Start the server with ",c.jsx("code",{className:"rounded bg-muted px-1 py-0.5 text-2xs",children:"python whisper-server/server.py"})," from the gateway package. Optionally set ",c.jsx("code",{className:"rounded bg-muted px-1 py-0.5 text-2xs",children:"WHISPER_URL"})," in API keys below (defaults to ",c.jsx("code",{className:"rounded bg-muted px-1 py-0.5 text-2xs",children:"http://localhost:8178"}),")."]})}),s==="wyoming"&&c.jsx("div",{className:"max-w-sm space-y-3 border-l-2 border-primary/20 pl-4",children:c.jsxs("p",{className:"text-xs text-muted-foreground",children:["Configure your Home Assistant Wyoming/Whisper STT integration. Set these values in the API keys section below: ",c.jsx("code",{className:"rounded bg-muted px-1 py-0.5 text-2xs",children:"HA_URL"}),", ",c.jsx("code",{className:"rounded bg-muted px-1 py-0.5 text-2xs",children:"HA_TOKEN"}),", and optionally ",c.jsx("code",{className:"rounded bg-muted px-1 py-0.5 text-2xs",children:"HA_STT_ENTITY"})," (defaults to ",c.jsx("code",{className:"rounded bg-muted px-1 py-0.5 text-2xs",children:"stt.faster_whisper"}),")."]})}),s==="gpt"&&c.jsx("div",{className:"max-w-sm space-y-3 border-l-2 border-primary/20 pl-4",children:c.jsxs("p",{className:"text-xs text-muted-foreground",children:["Uses OpenAI audio transcription. Set ",c.jsx("code",{className:"rounded bg-muted px-1 py-0.5 text-2xs",children:"OPENAI_API_KEY"})," and optionally ",c.jsx("code",{className:"rounded bg-muted px-1 py-0.5 text-2xs",children:"OPENAI_TRANSCRIBE_MODEL"})," (defaults to ",c.jsx("code",{className:"rounded bg-muted px-1 py-0.5 text-2xs",children:"gpt-4o-mini-transcribe"}),")."]})}),s==="elevenlabs"&&c.jsx("div",{className:"max-w-sm space-y-3 border-l-2 border-primary/20 pl-4",children:c.jsxs("p",{className:"text-xs text-muted-foreground",children:["Uses ElevenLabs Speech to Text. Set ",c.jsx("code",{className:"rounded bg-muted px-1 py-0.5 text-2xs",children:"ELEVENLABS_API_KEY"})," and optionally ",c.jsx("code",{className:"rounded bg-muted px-1 py-0.5 text-2xs",children:"ELEVENLABS_STT_MODEL"})," (defaults to ",c.jsx("code",{className:"rounded bg-muted px-1 py-0.5 text-2xs",children:"scribe_v2"}),") and ",c.jsx("code",{className:"rounded bg-muted px-1 py-0.5 text-2xs",children:"ELEVENLABS_LANGUAGE_CODE"}),"."]})})]}),!Et&&!at&&!Ve&&!Mt&&!It&&!rr&&!nr&&!Ut&&!Se&&Ft]}),c.jsx(oo,{value:"api",className:"space-y-6 pb-20",children:Fe.length>0?c.jsxs(c.Fragment,{children:[c.jsx("p",{className:"text-sm text-muted-foreground",children:"Values stored here are user-specific and override environment defaults for your account."}),zce.map(ye=>{const st=ye.fields.filter(At=>Fe.includes(At));if(st.length===0)return null;const ir=uat(st[0]);return c.jsx(XS,{defaultOpen:!1,children:c.jsxs(gn,{className:"p-0 overflow-hidden",children:[c.jsxs(JS,{className:"flex w-full items-center gap-2 px-5 py-3.5 text-left hover:bg-muted/50 transition-colors group",children:[c.jsx(Cs,{className:"h-4 w-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-90"}),ir?c.jsx(ir,{size:16,className:"text-muted-foreground"}):c.jsx(bY,{className:"h-4 w-4 text-muted-foreground"}),c.jsx("span",{className:"text-sm font-semibold",children:Be(ye.label)})]}),c.jsx(ZS,{children:c.jsx("div",{className:"grid gap-4 px-5 pb-5 md:grid-cols-2",children:st.map(At=>{const hr=dat(At),Vr=!!q[At];return c.jsxs("div",{className:"space-y-1.5",children:[c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx(di,{htmlFor:`api-${At}`,className:"font-mono text-xs",children:Be(At)}),De(At)]}),c.jsxs("div",{className:"relative",children:[c.jsx(Pn,{id:`api-${At}`,type:hr&&!Vr?"password":"text",value:j[At]??"",onChange:br=>{E(Rr=>({...Rr,[At]:br.target.value}))},placeholder:V[At]?"(set via .env)":"(empty)",className:hr?"pr-9":""}),hr&&c.jsx("button",{type:"button",className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors",onClick:()=>Ne(At),tabIndex:-1,"aria-label":Vr?"Hide value":"Show value",children:Vr?c.jsx(Id,{className:"h-4 w-4"}):c.jsx(Zh,{className:"h-4 w-4"})})]})]},At)})})})]})},ye.label)}),c.jsx("div",{className:"fixed bottom-0 left-0 right-0 z-30 border-t bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80",children:c.jsxs("div",{className:"mx-auto flex max-w-5xl items-center gap-3 px-4 py-3 sm:px-6",children:[c.jsx(_e,{onClick:()=>{ze()},disabled:A||!gt,children:A?"Saving...":"Save API settings"}),c.jsx(_e,{variant:"ghost",onClick:Pt,disabled:!gt,children:"Discard"}),$&&c.jsx("span",{className:"text-sm text-muted-foreground",children:$}),Y&&c.jsx("span",{className:"text-sm text-destructive",children:Y})]})})]}):Ft}),c.jsx(oo,{value:"tools",className:"space-y-6",children:et?c.jsx(tit,{token:r}):Ft}),c.jsx(oo,{value:"extensions",className:"space-y-6",children:Xe?c.jsx(sit,{token:r}):Ft}),c.jsx(oo,{value:"skills",className:"space-y-6",children:Lt?c.jsx(lit,{token:r}):Ft}),c.jsxs(oo,{value:"activity",className:"space-y-6",children:[St&&g&&g.length>0&&c.jsxs(gn,{className:"p-5 space-y-4",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-base font-medium",children:Be("Recent activity")}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Recent chat messages and terminal sessions."})]}),c.jsx(cit,{events:g})]}),St&&(!g||g.length===0)&&c.jsx(gn,{className:"p-5",children:c.jsx("p",{className:"text-sm text-muted-foreground",children:"No recent activity yet."})}),!St&&Ft]})]})]})}function mat(e,r){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var i,s,o,a,l=[],u=!0,d=!1;try{if(o=(n=n.call(e)).next,r===0){if(Object(n)!==n)return;u=!1}else for(;!(u=(i=o.call(n)).done)&&(l.push(i.value),l.length!==r);u=!0);}catch(h){d=!0,s=h}finally{try{if(!u&&n.return!=null&&(a=n.return(),Object(a)!==a))return}finally{if(d)throw s}}return l}}function gat(e,r,n){return r=kat(r),r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function WU(e,r){return xat(e)||mat(e,r)||Fce(e,r)||wat()}function yat(e){return vat(e)||bat(e)||Fce(e)||_at()}function vat(e){if(Array.isArray(e))return T7(e)}function xat(e){if(Array.isArray(e))return e}function bat(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function Fce(e,r){if(e){if(typeof e=="string")return T7(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return T7(e,r)}}function T7(e,r){(r==null||r>e.length)&&(r=e.length);for(var n=0,i=new Array(r);n<r;n++)i[n]=e[n];return i}function _at(){throw new TypeError(`Invalid attempt to spread non-iterable instance.