dorkos 0.43.0 → 0.43.1
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.
- package/dist/bin/cli.js +6 -6
- package/dist/client/assets/{BaseTanStackRouterDevtoolsPanel-BbL4h7yi-BbRHxR_f.js → BaseTanStackRouterDevtoolsPanel-BbL4h7yi-Cd8JnBCJ.js} +1 -1
- package/dist/client/assets/{BaseTanStackRouterDevtoolsPanel-BbL4h7yi-Bhzkg96L.js → BaseTanStackRouterDevtoolsPanel-BbL4h7yi-D73A7WJY.js} +1 -1
- package/dist/client/assets/{ConfigTab-BshXF_Ah.js → ConfigTab-Dq5dbbEB.js} +1 -1
- package/dist/client/assets/{ConfigTab-CuOK-h_n.js → ConfigTab-lJafANrQ.js} +1 -1
- package/dist/client/assets/{FloatingTanStackRouterDevtools-CMO0N95A-5qa4W6Ke.js → FloatingTanStackRouterDevtools-CMO0N95A-DUFt2Sab.js} +1 -1
- package/dist/client/assets/{FloatingTanStackRouterDevtools-CMO0N95A-Deu-qTVi.js → FloatingTanStackRouterDevtools-CMO0N95A-g68_CzC5.js} +1 -1
- package/dist/client/assets/{RightPanelHeader-BwRpiPnF.js → RightPanelHeader-B-bdVBD5.js} +1 -1
- package/dist/client/assets/{RightPanelHeader-phxQm-eZ.js → RightPanelHeader-XFaPYtCt.js} +1 -1
- package/dist/client/assets/{SessionsTab-B1dlYyRR.js → SessionsTab-BeSViVbi.js} +1 -1
- package/dist/client/assets/{SessionsTab-BjOaGzWL.js → SessionsTab-Djl3a1JS.js} +1 -1
- package/dist/client/assets/{ToolkitTab-BZNbWVwL.js → ToolkitTab-E1j7Fl9y.js} +1 -1
- package/dist/client/assets/{ToolkitTab-BgNQLkM0.js → ToolkitTab-p2cUpDvj.js} +1 -1
- package/dist/client/assets/{TopologyGraph-BkPzBOVe.js → TopologyGraph-DjrSwcZ7.js} +1 -1
- package/dist/client/assets/{TopologyGraph-DtdKZsQa.js → TopologyGraph-tT2ioy9i.js} +1 -1
- package/dist/client/assets/{highlighted-body-OFNGDK62-VbF6zstp.js → highlighted-body-OFNGDK62-BGqDg_CH.js} +1 -1
- package/dist/client/assets/{highlighted-body-OFNGDK62-wj1ZFptk.js → highlighted-body-OFNGDK62-C0BhuUrQ.js} +1 -1
- package/dist/client/assets/{index-CHBl9Xp9.js → index-B5vwNxrp.js} +5 -5
- package/dist/client/assets/{index-CRu7kmbh.js → index-BVMqbrTk.js} +1 -1
- package/dist/client/assets/{index-BVTuvWRf.js → index-Bu_BRhOD.js} +3 -3
- package/dist/client/assets/{index-BGL_u2Ur.js → index-CCg4gR3O.js} +1 -1
- package/dist/client/assets/{index-wLQz6ZAE.js → index-DEQVQjg0.js} +1 -1
- package/dist/client/assets/{index-Dv5_bsa-.js → index-DJ2ScbA0.js} +1 -1
- package/dist/client/assets/{index-B2LppgvO.js → index-DMT5csia.js} +2 -2
- package/dist/client/assets/{index-DK5Wb-8-.js → index-DOPU0lrN.js} +3 -3
- package/dist/client/assets/{index-DvBLhlqB.js → index-DbM6pHiq.js} +5 -5
- package/dist/client/assets/{index-Bm_WP_Ps.js → index-DdYKR8rh.js} +2 -2
- package/dist/client/assets/{index-Ca1oUJjn.js → index-Dh7cfXXe.js} +1 -1
- package/dist/client/assets/{index-Di8NW-Up.js → index-JvZmJ892.js} +1 -1
- package/dist/client/index.html +1 -1
- package/dist/server/index.js +70 -17
- package/dist/server/index.js.map +3 -3
- package/package.json +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TopologyGraph-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TopologyGraph-DjrSwcZ7.js","assets/TopologyGraph-C7eadB24.css","assets/index-CCg4gR3O.js","assets/RightPanelHeader-XFaPYtCt.js","assets/index-Bu_BRhOD.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
var dce=Object.defineProperty;var SL=e=>{throw TypeError(e)};var fce=(e,t,n)=>t in e?dce(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var nt=(e,t,n)=>fce(e,typeof t!="symbol"?t+"":t,n),v_=(e,t,n)=>t.has(e)||SL("Cannot "+n);var te=(e,t,n)=>(v_(e,t,"read from private field"),n?n.call(e):t.get(e)),st=(e,t,n)=>t.has(e)?SL("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),qe=(e,t,n,s)=>(v_(e,t,"write to private field"),s?s.call(e,n):t.set(e,n),n),zt=(e,t,n)=>(v_(e,t,"access private method"),n);var s0=(e,t,n,s)=>({set _(r){qe(e,t,r,n)},get _(){return te(e,t,s)}});function hce(e,t){for(var n=0;n<t.length;n++){const s=t[n];if(typeof s!="string"&&!Array.isArray(s)){for(const r in s)if(r!=="default"&&!(r in e)){const a=Object.getOwnPropertyDescriptor(s,r);a&&Object.defineProperty(e,r,a.get?a:{enumerable:!0,get:()=>s[r]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))s(r);new MutationObserver(r=>{for(const a of r)if(a.type==="childList")for(const o of a.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&s(o)}).observe(document,{childList:!0,subtree:!0});function n(r){const a={};return r.integrity&&(a.integrity=r.integrity),r.referrerPolicy&&(a.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?a.credentials="include":r.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function s(r){if(r.ep)return;r.ep=!0;const a=n(r);fetch(r.href,a)}})();const pce="modulepreload",mce=function(e){return"/"+e},wL={},Ar=function(t,n,s){let r=Promise.resolve();if(n&&n.length>0){let o=function(u){return Promise.all(u.map(f=>Promise.resolve(f).then(h=>({status:"fulfilled",value:h}),h=>({status:"rejected",reason:h}))))};document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),c=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));r=o(n.map(u=>{if(u=mce(u),u in wL)return;wL[u]=!0;const f=u.endsWith(".css"),h=f?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${u}"]${h}`))return;const m=document.createElement("link");if(m.rel=f?"stylesheet":pce,f||(m.as="script"),m.crossOrigin="",m.href=u,c&&m.setAttribute("nonce",c),document.head.appendChild(m),f)return new Promise((g,b)=>{m.addEventListener("load",g),m.addEventListener("error",()=>b(new Error(`Unable to preload CSS for ${u}`)))})}))}function a(o){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=o,window.dispatchEvent(l),!l.defaultPrevented)throw o}return r.then(o=>{for(const l of o||[])l.status==="rejected"&&a(l.reason);return t().catch(a)})};var zlt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function eo(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var S_={exports:{}},r0={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react-jsx-runtime.production.js
|
|
@@ -1019,7 +1019,7 @@ ${t}</tr>
|
|
|
1019
1019
|
`}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${mo(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:n,tokens:s}){let r=this.parser.parseInline(s),a=W9(t);if(a===null)return r;t=a;let o='<a href="'+t+'"';return n&&(o+=' title="'+mo(n)+'"'),o+=">"+r+"</a>",o}image({href:t,title:n,text:s,tokens:r}){r&&(s=this.parser.parseInline(r,this.parser.textRenderer));let a=W9(t);if(a===null)return mo(s);t=a;let o=`<img src="${t}" alt="${mo(s)}"`;return n&&(o+=` title="${mo(n)}"`),o+=">",o}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:mo(t.text)}},F5=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}checkbox({raw:t}){return t}},Bi=class PR{constructor(t){nt(this,"options");nt(this,"renderer");nt(this,"textRenderer");this.options=t||hh,this.options.renderer=this.options.renderer||new Cw,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new F5}static parse(t,n){return new PR(n).parse(t)}static parseInline(t,n){return new PR(n).parseInline(t)}parse(t){var s,r;this.renderer.parser=this;let n="";for(let a=0;a<t.length;a++){let o=t[a];if((r=(s=this.options.extensions)==null?void 0:s.renderers)!=null&&r[o.type]){let c=o,u=this.options.extensions.renderers[c.type].call({parser:this},c);if(u!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(c.type)){n+=u||"";continue}}let l=o;switch(l.type){case"space":{n+=this.renderer.space(l);break}case"hr":{n+=this.renderer.hr(l);break}case"heading":{n+=this.renderer.heading(l);break}case"code":{n+=this.renderer.code(l);break}case"table":{n+=this.renderer.table(l);break}case"blockquote":{n+=this.renderer.blockquote(l);break}case"list":{n+=this.renderer.list(l);break}case"checkbox":{n+=this.renderer.checkbox(l);break}case"html":{n+=this.renderer.html(l);break}case"def":{n+=this.renderer.def(l);break}case"paragraph":{n+=this.renderer.paragraph(l);break}case"text":{n+=this.renderer.text(l);break}default:{let c='Token with "'+l.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return n}parseInline(t,n=this.renderer){var r,a;this.renderer.parser=this;let s="";for(let o=0;o<t.length;o++){let l=t[o];if((a=(r=this.options.extensions)==null?void 0:r.renderers)!=null&&a[l.type]){let u=this.options.extensions.renderers[l.type].call({parser:this},l);if(u!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(l.type)){s+=u||"";continue}}let c=l;switch(c.type){case"escape":{s+=n.text(c);break}case"html":{s+=n.html(c);break}case"link":{s+=n.link(c);break}case"image":{s+=n.image(c);break}case"checkbox":{s+=n.checkbox(c);break}case"strong":{s+=n.strong(c);break}case"em":{s+=n.em(c);break}case"codespan":{s+=n.codespan(c);break}case"br":{s+=n.br(c);break}case"del":{s+=n.del(c);break}case"text":{s+=n.text(c);break}default:{let u='Token with "'+c.type+'" type was not found.';if(this.options.silent)return console.error(u),"";throw new Error(u)}}}return s}},j1,Z0=(j1=class{constructor(e){nt(this,"options");nt(this,"block");this.options=e||hh}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?Si.lex:Si.lexInline}provideParser(){return this.block?Bi.parse:Bi.parseInline}},nt(j1,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),nt(j1,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),j1),w$e=class{constructor(...t){nt(this,"defaults",A5());nt(this,"options",this.setOptions);nt(this,"parse",this.parseMarkdown(!0));nt(this,"parseInline",this.parseMarkdown(!1));nt(this,"Parser",Bi);nt(this,"Renderer",Cw);nt(this,"TextRenderer",F5);nt(this,"Lexer",Si);nt(this,"Tokenizer",kw);nt(this,"Hooks",Z0);this.use(...t)}walkTokens(t,n){var r,a;let s=[];for(let o of t)switch(s=s.concat(n.call(this,o)),o.type){case"table":{let l=o;for(let c of l.header)s=s.concat(this.walkTokens(c.tokens,n));for(let c of l.rows)for(let u of c)s=s.concat(this.walkTokens(u.tokens,n));break}case"list":{let l=o;s=s.concat(this.walkTokens(l.items,n));break}default:{let l=o;(a=(r=this.defaults.extensions)==null?void 0:r.childTokens)!=null&&a[l.type]?this.defaults.extensions.childTokens[l.type].forEach(c=>{let u=l[c].flat(1/0);s=s.concat(this.walkTokens(u,n))}):l.tokens&&(s=s.concat(this.walkTokens(l.tokens,n)))}}return s}use(...t){let n=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(s=>{let r={...s};if(r.async=this.defaults.async||r.async||!1,s.extensions&&(s.extensions.forEach(a=>{if(!a.name)throw new Error("extension name required");if("renderer"in a){let o=n.renderers[a.name];o?n.renderers[a.name]=function(...l){let c=a.renderer.apply(this,l);return c===!1&&(c=o.apply(this,l)),c}:n.renderers[a.name]=a.renderer}if("tokenizer"in a){if(!a.level||a.level!=="block"&&a.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let o=n[a.level];o?o.unshift(a.tokenizer):n[a.level]=[a.tokenizer],a.start&&(a.level==="block"?n.startBlock?n.startBlock.push(a.start):n.startBlock=[a.start]:a.level==="inline"&&(n.startInline?n.startInline.push(a.start):n.startInline=[a.start]))}"childTokens"in a&&a.childTokens&&(n.childTokens[a.name]=a.childTokens)}),r.extensions=n),s.renderer){let a=this.defaults.renderer||new Cw(this.defaults);for(let o in s.renderer){if(!(o in a))throw new Error(`renderer '${o}' does not exist`);if(["options","parser"].includes(o))continue;let l=o,c=s.renderer[l],u=a[l];a[l]=(...f)=>{let h=c.apply(a,f);return h===!1&&(h=u.apply(a,f)),h||""}}r.renderer=a}if(s.tokenizer){let a=this.defaults.tokenizer||new kw(this.defaults);for(let o in s.tokenizer){if(!(o in a))throw new Error(`tokenizer '${o}' does not exist`);if(["options","rules","lexer"].includes(o))continue;let l=o,c=s.tokenizer[l],u=a[l];a[l]=(...f)=>{let h=c.apply(a,f);return h===!1&&(h=u.apply(a,f)),h}}r.tokenizer=a}if(s.hooks){let a=this.defaults.hooks||new Z0;for(let o in s.hooks){if(!(o in a))throw new Error(`hook '${o}' does not exist`);if(["options","block"].includes(o))continue;let l=o,c=s.hooks[l],u=a[l];Z0.passThroughHooks.has(o)?a[l]=f=>{if(this.defaults.async&&Z0.passThroughHooksRespectAsync.has(o))return(async()=>{let m=await c.call(a,f);return u.call(a,m)})();let h=c.call(a,f);return u.call(a,h)}:a[l]=(...f)=>{if(this.defaults.async)return(async()=>{let m=await c.apply(a,f);return m===!1&&(m=await u.apply(a,f)),m})();let h=c.apply(a,f);return h===!1&&(h=u.apply(a,f)),h}}r.hooks=a}if(s.walkTokens){let a=this.defaults.walkTokens,o=s.walkTokens;r.walkTokens=function(l){let c=[];return c.push(o.call(this,l)),a&&(c=c.concat(a.call(this,l))),c}}this.defaults={...this.defaults,...r}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,n){return Si.lex(t,n??this.defaults)}parser(t,n){return Bi.parse(t,n??this.defaults)}parseMarkdown(t){return(n,s)=>{let r={...s},a={...this.defaults,...r},o=this.onError(!!a.silent,!!a.async);if(this.defaults.async===!0&&r.async===!1)return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof n>"u"||n===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(a.hooks&&(a.hooks.options=a,a.hooks.block=t),a.async)return(async()=>{let l=a.hooks?await a.hooks.preprocess(n):n,c=await(a.hooks?await a.hooks.provideLexer():t?Si.lex:Si.lexInline)(l,a),u=a.hooks?await a.hooks.processAllTokens(c):c;a.walkTokens&&await Promise.all(this.walkTokens(u,a.walkTokens));let f=await(a.hooks?await a.hooks.provideParser():t?Bi.parse:Bi.parseInline)(u,a);return a.hooks?await a.hooks.postprocess(f):f})().catch(o);try{a.hooks&&(n=a.hooks.preprocess(n));let l=(a.hooks?a.hooks.provideLexer():t?Si.lex:Si.lexInline)(n,a);a.hooks&&(l=a.hooks.processAllTokens(l)),a.walkTokens&&this.walkTokens(l,a.walkTokens);let c=(a.hooks?a.hooks.provideParser():t?Bi.parse:Bi.parseInline)(l,a);return a.hooks&&(c=a.hooks.postprocess(c)),c}catch(l){return o(l)}}}onError(t,n){return s=>{if(s.message+=`
|
|
1020
1020
|
Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error occurred:</p><pre>"+mo(s.message+"",!0)+"</pre>";return n?Promise.resolve(r):r}if(n)return Promise.reject(s);throw s}}},Ef=new w$e;function zn(e,t){return Ef.parse(e,t)}zn.options=zn.setOptions=function(e){return Ef.setOptions(e),zn.defaults=Ef.defaults,rse(zn.defaults),zn};zn.getDefaults=A5;zn.defaults=hh;zn.use=function(...e){return Ef.use(...e),zn.defaults=Ef.defaults,rse(zn.defaults),zn};zn.walkTokens=function(e,t){return Ef.walkTokens(e,t)};zn.parseInline=Ef.parseInline;zn.Parser=Bi;zn.parser=Bi.parse;zn.Renderer=Cw;zn.TextRenderer=F5;zn.Lexer=Si;zn.lexer=Si.lex;zn.Tokenizer=kw;zn.Hooks=Z0;zn.parse=zn;zn.options;zn.setOptions;zn.use;zn.walkTokens;zn.parseInline;Bi.parse;Si.lex;var k$e=300,C$e="300px",E$e=500;function T$e(e={}){let{immediate:t=!1,debounceDelay:n=k$e,rootMargin:s=C$e,idleTimeout:r=E$e}=e,[a,o]=x.useState(!1),l=x.useRef(null),c=x.useRef(null),u=x.useRef(null),f=x.useMemo(()=>g=>{let b=Date.now();return window.setTimeout(()=>{g({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-b))})},1)},[]),h=x.useMemo(()=>typeof window<"u"&&window.requestIdleCallback?(g,b)=>window.requestIdleCallback(g,b):f,[f]),m=x.useMemo(()=>typeof window<"u"&&window.cancelIdleCallback?g=>window.cancelIdleCallback(g):g=>{clearTimeout(g)},[]);return x.useEffect(()=>{if(t){o(!0);return}let g=l.current;if(!g)return;c.current&&(clearTimeout(c.current),c.current=null),u.current&&(m(u.current),u.current=null);let b=()=>{c.current&&(clearTimeout(c.current),c.current=null),u.current&&(m(u.current),u.current=null)},v=E=>{u.current=h(T=>{T.timeRemaining()>0||T.didTimeout?(o(!0),E.disconnect()):u.current=h(()=>{o(!0),E.disconnect()},{timeout:r/2})},{timeout:r})},k=E=>{b(),c.current=window.setTimeout(()=>{var T,_;let j=E.takeRecords();(j.length===0||(_=(T=j.at(-1))==null?void 0:T.isIntersecting)!=null&&_)&&v(E)},n)},w=(E,T)=>{E.isIntersecting?k(T):b()},C=new IntersectionObserver(E=>{for(let T of E)w(T,C)},{rootMargin:s,threshold:0});return C.observe(g),()=>{c.current&&clearTimeout(c.current),u.current&&m(u.current),C.disconnect()}},[t,n,s,r,m,h]),{shouldRender:a,containerRef:l}}var pse=/\s/,_$e=/^\s+$/,N$e=new Set(["code","pre","svg","math","annotation"]),j$e=e=>typeof e=="object"&&e!==null&&"type"in e&&e.type==="element",A$e=e=>e.some(t=>j$e(t)&&N$e.has(t.tagName)),R$e=e=>{let t=[],n="",s=!1;for(let r of e){let a=pse.test(r);a!==s&&n&&(t.push(n),n=""),n+=r,s=a}return n&&t.push(n),t},M$e=e=>{let t=[],n="";for(let s of e)pse.test(s)?n+=s:(n&&(t.push(n),n=""),t.push(s));return n&&t.push(n),t},D$e=(e,t,n,s,r,a)=>{let o=`--sd-animation:sd-${t};--sd-duration:${r?0:n}ms;--sd-easing:${s}`;return a&&(o+=`;--sd-delay:${a}ms`),{type:"element",tagName:"span",properties:{"data-sd-animate":!0,style:o},children:[{type:"text",value:e}]}},O$e=(e,t,n,s,r)=>{let a=t.at(-1);if(!(a&&"children"in a))return;if(A$e(t))return Ip;let o=a,l=o.children.indexOf(e);if(l===-1)return;let c=e.value;if(!c.trim()){r.count+=c.length;return}let u=n.sep==="char"?M$e(c):R$e(c),f=s.prevContentLength,h=u.map(m=>{let g=r.count;if(r.count+=m.length,_$e.test(m))return{type:"text",value:m};let b=f>0&&g<f,v=b?0:r.newIndex++*n.stagger;return D$e(m,n.animation,n.duration,n.easing,b,v)});return o.children.splice(l,1,...h),l+h.length},I$e=0;function LR(e){var t,n,s,r,a;let o={animation:(t=e==null?void 0:e.animation)!=null?t:"fadeIn",duration:(n=e==null?void 0:e.duration)!=null?n:150,easing:(s=e==null?void 0:e.easing)!=null?s:"ease",sep:(r=e==null?void 0:e.sep)!=null?r:"word",stagger:(a=e==null?void 0:e.stagger)!=null?a:40},l={prevContentLength:0,lastRenderCharCount:0},c=I$e++,u=()=>f=>{let h={count:0,newIndex:0};i5(f,"text",(m,g)=>O$e(m,g,o,l,h)),l.lastRenderCharCount=h.count,l.prevContentLength=0};return Object.defineProperty(u,"name",{value:`rehypeAnimate$${c}`}),{name:"animate",type:"animate",rehypePlugin:u,setPrevContentLength(f){l.prevContentLength=f},getLastRenderCharCount(){let f=l.lastRenderCharCount;return l.lastRenderCharCount=0,f}}}LR();var mse=x.createContext(!1),P$e=()=>x.useContext(mse),z5=(...e)=>ck(lk(e)),L$e=(e,t)=>{if(!e||!t)return t;let n=`${e}:`;return t.split(/\s+/).filter(Boolean).map(s=>s.startsWith(n)?s:`${e}:${s}`).join(" ")},F$e=e=>e?(...t)=>L$e(e,ck(lk(t))):z5,Yp=(e,t,n)=>{let s=typeof t=="string"&&n.startsWith("text/csv")?"\uFEFF":"",r=typeof t=="string"?new Blob([s+t],{type:n}):t,a=URL.createObjectURL(r),o=document.createElement("a");o.href=a,o.download=e,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(a)},FR=x.createContext(z5),Xt=()=>x.useContext(FR),z$e=z5("block","before:content-[counter(line)]","before:inline-block","before:[counter-increment:line]","before:w-6","before:mr-4","before:text-[13px]","before:text-right","before:text-muted-foreground/50","before:font-mono","before:select-none"),B$e=e=>{let t={};for(let n of e.split(";")){let s=n.indexOf(":");if(s>0){let r=n.slice(0,s).trim(),a=n.slice(s+1).trim();r&&a&&(t[r]=a)}}return t},$$e=x.memo(({children:e,result:t,language:n,className:s,startLine:r,lineNumbers:a=!0,...o})=>{let l=Xt(),c=x.useMemo(()=>l(z$e),[l]),u=x.useMemo(()=>{let f={};return t.bg&&(f["--sdm-bg"]=t.bg),t.fg&&(f["--sdm-fg"]=t.fg),t.rootStyle&&Object.assign(f,B$e(t.rootStyle)),f},[t.bg,t.fg,t.rootStyle]);return i.jsx("div",{className:l(s,"overflow-x-auto rounded-md border border-border bg-background p-4 text-sm"),"data-language":n,"data-streamdown":"code-block-body",...o,children:i.jsx("pre",{className:l(s,"bg-[var(--sdm-bg,inherit]","dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit)]"),style:u,children:i.jsx("code",{className:a?l("[counter-increment:line_0] [counter-reset:line]"):void 0,style:a&&r&&r>1?{counterReset:`line ${r-1}`}:void 0,children:t.tokens.map((f,h)=>i.jsx("span",{className:a?c:void 0,children:f.length===0||f.length===1&&f[0].content===""?`
|
|
1021
1021
|
`:f.map((m,g)=>{let b={},v=!!m.bgColor;if(m.color&&(b["--sdm-c"]=m.color),m.bgColor&&(b["--sdm-tbg"]=m.bgColor),m.htmlStyle)for(let[k,w]of Object.entries(m.htmlStyle))k==="color"?b["--sdm-c"]=w:k==="background-color"?(b["--sdm-tbg"]=w,v=!0):b[k]=w;return i.jsx("span",{className:l("text-[var(--sdm-c,inherit)]","dark:text-[var(--shiki-dark,var(--sdm-c,inherit))]",v&&"bg-[var(--sdm-tbg)]",v&&"dark:bg-[var(--shiki-dark-bg,var(--sdm-tbg))]"),style:b,...m.htmlAttrs,children:m.content},g)})},h))})})})},(e,t)=>e.result===t.result&&e.language===t.language&&e.className===t.className&&e.startLine===t.startLine&&e.lineNumbers===t.lineNumbers),H$e=({className:e,language:t,style:n,isIncomplete:s,...r})=>{let a=Xt();return i.jsx("div",{className:a("my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",e),"data-incomplete":s||void 0,"data-language":t,"data-streamdown":"code-block",style:{contentVisibility:"auto",containIntrinsicSize:"auto 200px",...n},...r})},gse=x.createContext({code:""}),xse=()=>x.useContext(gse),U$e=({language:e})=>{let t=Xt();return i.jsx("div",{className:t("flex h-8 items-center text-muted-foreground text-xs"),"data-language":e,"data-streamdown":"code-block-header",children:i.jsx("span",{className:t("ml-1 font-mono lowercase"),children:e})})},V$e=e=>{let t=e.length;for(;t>0&&e[t-1]===`
|
|
1022
|
-
`;)t--;return e.slice(0,t)},q$e=x.lazy(()=>Ar(()=>import("./highlighted-body-OFNGDK62-
|
|
1022
|
+
`;)t--;return e.slice(0,t)},q$e=x.lazy(()=>Ar(()=>import("./highlighted-body-OFNGDK62-BGqDg_CH.js"),[]).then(e=>({default:e.HighlightedCodeBlockBody}))),G$e=({code:e,language:t,className:n,children:s,isIncomplete:r=!1,startLine:a,lineNumbers:o,...l})=>{let c=Xt(),u=x.useMemo(()=>V$e(e),[e]),f=x.useMemo(()=>({bg:"transparent",fg:"inherit",tokens:u.split(`
|
|
1023
1023
|
`).map(h=>[{content:h,color:"inherit",bgColor:"transparent",htmlStyle:{},offset:0}])}),[u]);return i.jsx(gse.Provider,{value:{code:e},children:i.jsxs(H$e,{isIncomplete:r,language:t,children:[i.jsx(U$e,{language:t}),s?i.jsx("div",{className:c("pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end"),children:i.jsx("div",{className:c("pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur"),"data-streamdown":"code-block-actions",children:s})}):null,i.jsx(x.Suspense,{fallback:i.jsx($$e,{className:n,language:t,lineNumbers:o,result:f,startLine:a,...l}),children:i.jsx(q$e,{className:n,code:u,language:t,lineNumbers:o,raw:f,startLine:a,...l})})]})})},K$e=e=>i.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:i.jsx("path",{clipRule:"evenodd",d:"M15.5607 3.99999L15.0303 4.53032L6.23744 13.3232C5.55403 14.0066 4.44599 14.0066 3.76257 13.3232L4.2929 12.7929L3.76257 13.3232L0.969676 10.5303L0.439346 9.99999L1.50001 8.93933L2.03034 9.46966L4.82323 12.2626C4.92086 12.3602 5.07915 12.3602 5.17678 12.2626L13.9697 3.46966L14.5 2.93933L15.5607 3.99999Z",fill:"currentColor",fillRule:"evenodd"})}),W$e=e=>i.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:i.jsx("path",{clipRule:"evenodd",d:"M2.75 0.5C1.7835 0.5 1 1.2835 1 2.25V9.75C1 10.7165 1.7835 11.5 2.75 11.5H3.75H4.5V10H3.75H2.75C2.61193 10 2.5 9.88807 2.5 9.75V2.25C2.5 2.11193 2.61193 2 2.75 2H8.25C8.38807 2 8.5 2.11193 8.5 2.25V3H10V2.25C10 1.2835 9.2165 0.5 8.25 0.5H2.75ZM7.75 4.5C6.7835 4.5 6 5.2835 6 6.25V13.75C6 14.7165 6.7835 15.5 7.75 15.5H13.25C14.2165 15.5 15 14.7165 15 13.75V6.25C15 5.2835 14.2165 4.5 13.25 4.5H7.75ZM7.5 6.25C7.5 6.11193 7.61193 6 7.75 6H13.25C13.3881 6 13.5 6.11193 13.5 6.25V13.75C13.5 13.8881 13.3881 14 13.25 14H7.75C7.61193 14 7.5 13.8881 7.5 13.75V6.25Z",fill:"currentColor",fillRule:"evenodd"})}),Y$e=e=>i.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:i.jsx("path",{clipRule:"evenodd",d:"M8.75 1V1.75V8.68934L10.7197 6.71967L11.25 6.18934L12.3107 7.25L11.7803 7.78033L8.70711 10.8536C8.31658 11.2441 7.68342 11.2441 7.29289 10.8536L4.21967 7.78033L3.68934 7.25L4.75 6.18934L5.28033 6.71967L7.25 8.68934V1.75V1H8.75ZM13.5 9.25V13.5H2.5V9.25V8.5H1V9.25V14C1 14.5523 1.44771 15 2 15H14C14.5523 15 15 14.5523 15 14V9.25V8.5H13.5V9.25Z",fill:"currentColor",fillRule:"evenodd"})}),Z$e=e=>i.jsxs("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:[i.jsx("path",{d:"M8 0V4",stroke:"currentColor",strokeWidth:"1.5"}),i.jsx("path",{d:"M8 16V12",opacity:"0.5",stroke:"currentColor",strokeWidth:"1.5"}),i.jsx("path",{d:"M3.29773 1.52783L5.64887 4.7639",opacity:"0.9",stroke:"currentColor",strokeWidth:"1.5"}),i.jsx("path",{d:"M12.7023 1.52783L10.3511 4.7639",opacity:"0.1",stroke:"currentColor",strokeWidth:"1.5"}),i.jsx("path",{d:"M12.7023 14.472L10.3511 11.236",opacity:"0.4",stroke:"currentColor",strokeWidth:"1.5"}),i.jsx("path",{d:"M3.29773 14.472L5.64887 11.236",opacity:"0.6",stroke:"currentColor",strokeWidth:"1.5"}),i.jsx("path",{d:"M15.6085 5.52783L11.8043 6.7639",opacity:"0.2",stroke:"currentColor",strokeWidth:"1.5"}),i.jsx("path",{d:"M0.391602 10.472L4.19583 9.23598",opacity:"0.7",stroke:"currentColor",strokeWidth:"1.5"}),i.jsx("path",{d:"M15.6085 10.4722L11.8043 9.2361",opacity:"0.3",stroke:"currentColor",strokeWidth:"1.5"}),i.jsx("path",{d:"M0.391602 5.52783L4.19583 6.7639",opacity:"0.8",stroke:"currentColor",strokeWidth:"1.5"})]}),X$e=e=>i.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:i.jsx("path",{clipRule:"evenodd",d:"M1 5.25V6H2.5V5.25V2.5H5.25H6V1H5.25H2C1.44772 1 1 1.44772 1 2V5.25ZM5.25 14.9994H6V13.4994H5.25H2.5V10.7494V9.99939H1V10.7494V13.9994C1 14.5517 1.44772 14.9994 2 14.9994H5.25ZM15 10V10.75V14C15 14.5523 14.5523 15 14 15H10.75H10V13.5H10.75H13.5V10.75V10H15ZM10.75 1H10V2.5H10.75H13.5V5.25V6H15V5.25V2C15 1.44772 14.5523 1 14 1H10.75Z",fill:"currentColor",fillRule:"evenodd"})}),Q$e=e=>i.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:i.jsx("path",{clipRule:"evenodd",d:"M13.5 8C13.5 4.96643 11.0257 2.5 7.96452 2.5C5.42843 2.5 3.29365 4.19393 2.63724 6.5H5.25H6V8H5.25H0.75C0.335787 8 0 7.66421 0 7.25V2.75V2H1.5V2.75V5.23347C2.57851 2.74164 5.06835 1 7.96452 1C11.8461 1 15 4.13001 15 8C15 11.87 11.8461 15 7.96452 15C5.62368 15 3.54872 13.8617 2.27046 12.1122L1.828 11.5066L3.03915 10.6217L3.48161 11.2273C4.48831 12.6051 6.12055 13.5 7.96452 13.5C11.0257 13.5 13.5 11.0336 13.5 8Z",fill:"currentColor",fillRule:"evenodd"})}),J$e=e=>i.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:i.jsx("path",{clipRule:"evenodd",d:"M12.4697 13.5303L13 14.0607L14.0607 13L13.5303 12.4697L9.06065 7.99999L13.5303 3.53032L14.0607 2.99999L13 1.93933L12.4697 2.46966L7.99999 6.93933L3.53032 2.46966L2.99999 1.93933L1.93933 2.99999L2.46966 3.53032L6.93933 7.99999L2.46966 12.4697L1.93933 13L2.99999 14.0607L3.53032 13.5303L7.99999 9.06065L12.4697 13.5303Z",fill:"currentColor",fillRule:"evenodd"})}),eHe=e=>i.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:i.jsx("path",{clipRule:"evenodd",d:"M13.5 10.25V13.25C13.5 13.3881 13.3881 13.5 13.25 13.5H2.75C2.61193 13.5 2.5 13.3881 2.5 13.25L2.5 2.75C2.5 2.61193 2.61193 2.5 2.75 2.5H5.75H6.5V1H5.75H2.75C1.7835 1 1 1.7835 1 2.75V13.25C1 14.2165 1.7835 15 2.75 15H13.25C14.2165 15 15 14.2165 15 13.25V10.25V9.5H13.5V10.25ZM9 1H9.75H14.2495C14.6637 1 14.9995 1.33579 14.9995 1.75V6.25V7H13.4995V6.25V3.56066L8.53033 8.52978L8 9.06011L6.93934 7.99945L7.46967 7.46912L12.4388 2.5H9.75H9V1Z",fill:"currentColor",fillRule:"evenodd"})}),tHe=e=>i.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:i.jsx("path",{clipRule:"evenodd",d:"M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H5.875V4.75V4.125H7.125V4.75V5.875H8.25H8.875V7.125H8.25H7.125V8.25V8.875H5.875V8.25V7.125H4.75H4.125V5.875Z",fill:"currentColor",fillRule:"evenodd"})}),nHe=e=>i.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:i.jsx("path",{clipRule:"evenodd",d:"M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H8.25H8.875V7.125H8.25H4.75H4.125V5.875Z",fill:"currentColor",fillRule:"evenodd"})}),X0={CheckIcon:K$e,CopyIcon:W$e,DownloadIcon:Y$e,ExternalLinkIcon:eHe,Loader2Icon:Z$e,Maximize2Icon:X$e,RotateCcwIcon:Q$e,XIcon:J$e,ZoomInIcon:tHe,ZoomOutIcon:nHe},yse=x.createContext(X0),sHe=(e,t)=>{if(e===t)return!0;if(!(e&&t))return e===t;let n=Object.keys(e),s=Object.keys(t);return n.length!==s.length?!1:n.every(r=>e[r]===t[r])},X9=({icons:e,children:t})=>{let n=x.useRef(e),s=x.useRef(e?{...X0,...e}:X0);sHe(n.current,e)||(n.current=e,s.current=e?{...X0,...e}:X0);let r=s.current;return i.jsx(yse.Provider,{value:r,children:t})},ao=()=>x.useContext(yse),bse={copyCode:"Copy Code",downloadFile:"Download file",downloadDiagram:"Download diagram",downloadDiagramAsSvg:"Download diagram as SVG",downloadDiagramAsPng:"Download diagram as PNG",downloadDiagramAsMmd:"Download diagram as MMD",viewFullscreen:"View fullscreen",exitFullscreen:"Exit fullscreen",mermaidFormatSvg:"SVG",mermaidFormatPng:"PNG",mermaidFormatMmd:"MMD",copyTable:"Copy table",copyTableAsMarkdown:"Copy table as Markdown",copyTableAsCsv:"Copy table as CSV",copyTableAsTsv:"Copy table as TSV",downloadTable:"Download table",downloadTableAsCsv:"Download table as CSV",downloadTableAsMarkdown:"Download table as Markdown",tableFormatMarkdown:"Markdown",tableFormatCsv:"CSV",tableFormatTsv:"TSV",imageNotAvailable:"Image not available",downloadImage:"Download image",openExternalLink:"Open external link?",externalLinkWarning:"You're about to visit an external website.",close:"Close",copyLink:"Copy link",copied:"Copied",openLink:"Open link"},zR=x.createContext(bse),Zl=()=>x.useContext(zR),Q9=({onCopy:e,onError:t,timeout:n=2e3,children:s,className:r,code:a,...o})=>{let l=Xt(),[c,u]=x.useState(!1),f=x.useRef(0),{code:h}=xse(),{isAnimating:m}=x.useContext(Xa),g=Zl(),b=a??h,v=async()=>{var C;if(typeof window>"u"||!((C=navigator==null?void 0:navigator.clipboard)!=null&&C.writeText)){t==null||t(new Error("Clipboard API not available"));return}try{c||(await navigator.clipboard.writeText(b),u(!0),e==null||e(),f.current=window.setTimeout(()=>u(!1),n))}catch(E){t==null||t(E)}};x.useEffect(()=>()=>{window.clearTimeout(f.current)},[]);let k=ao(),w=c?k.CheckIcon:k.CopyIcon;return i.jsx("button",{className:l("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),"data-streamdown":"code-block-copy-button",disabled:m,onClick:v,title:g.copyCode,type:"button",...o,children:s??i.jsx(w,{size:14})})},J9={"1c":"1c","1c-query":"1cq",abap:"abap","actionscript-3":"as",ada:"ada",adoc:"adoc","angular-html":"html","angular-ts":"ts",apache:"conf",apex:"cls",apl:"apl",applescript:"applescript",ara:"ara",asciidoc:"adoc",asm:"asm",astro:"astro",awk:"awk",ballerina:"bal",bash:"sh",bat:"bat",batch:"bat",be:"be",beancount:"beancount",berry:"berry",bibtex:"bib",bicep:"bicep",blade:"blade.php",bsl:"bsl",c:"c","c#":"cs","c++":"cpp",cadence:"cdc",cairo:"cairo",cdc:"cdc",clarity:"clar",clj:"clj",clojure:"clj","closure-templates":"soy",cmake:"cmake",cmd:"cmd",cobol:"cob",codeowners:"CODEOWNERS",codeql:"ql",coffee:"coffee",coffeescript:"coffee","common-lisp":"lisp",console:"sh",coq:"v",cpp:"cpp",cql:"cql",crystal:"cr",cs:"cs",csharp:"cs",css:"css",csv:"csv",cue:"cue",cypher:"cql",d:"d",dart:"dart",dax:"dax",desktop:"desktop",diff:"diff",docker:"dockerfile",dockerfile:"dockerfile",dotenv:"env","dream-maker":"dm",edge:"edge",elisp:"el",elixir:"ex",elm:"elm","emacs-lisp":"el",erb:"erb",erl:"erl",erlang:"erl",f:"f","f#":"fs",f03:"f03",f08:"f08",f18:"f18",f77:"f77",f90:"f90",f95:"f95",fennel:"fnl",fish:"fish",fluent:"ftl",for:"for","fortran-fixed-form":"f","fortran-free-form":"f90",fs:"fs",fsharp:"fs",fsl:"fsl",ftl:"ftl",gdresource:"tres",gdscript:"gd",gdshader:"gdshader",genie:"gs",gherkin:"feature","git-commit":"gitcommit","git-rebase":"gitrebase",gjs:"js",gleam:"gleam","glimmer-js":"js","glimmer-ts":"ts",glsl:"glsl",gnuplot:"plt",go:"go",gql:"gql",graphql:"graphql",groovy:"groovy",gts:"gts",hack:"hack",haml:"haml",handlebars:"hbs",haskell:"hs",haxe:"hx",hbs:"hbs",hcl:"hcl",hjson:"hjson",hlsl:"hlsl",hs:"hs",html:"html","html-derivative":"html",http:"http",hxml:"hxml",hy:"hy",imba:"imba",ini:"ini",jade:"jade",java:"java",javascript:"js",jinja:"jinja",jison:"jison",jl:"jl",js:"js",json:"json",json5:"json5",jsonc:"jsonc",jsonl:"jsonl",jsonnet:"jsonnet",jssm:"jssm",jsx:"jsx",julia:"jl",kotlin:"kt",kql:"kql",kt:"kt",kts:"kts",kusto:"kql",latex:"tex",lean:"lean",lean4:"lean",less:"less",liquid:"liquid",lisp:"lisp",lit:"lit",llvm:"ll",log:"log",logo:"logo",lua:"lua",luau:"luau",make:"mak",makefile:"mak",markdown:"md",marko:"marko",matlab:"m",md:"md",mdc:"mdc",mdx:"mdx",mediawiki:"wiki",mermaid:"mmd",mips:"s",mipsasm:"s",mmd:"mmd",mojo:"mojo",move:"move",nar:"nar",narrat:"narrat",nextflow:"nf",nf:"nf",nginx:"conf",nim:"nim",nix:"nix",nu:"nu",nushell:"nu",objc:"m","objective-c":"m","objective-cpp":"mm",ocaml:"ml",pascal:"pas",perl:"pl",perl6:"p6",php:"php",plsql:"pls",po:"po",polar:"polar",postcss:"pcss",pot:"pot",potx:"potx",powerquery:"pq",powershell:"ps1",prisma:"prisma",prolog:"pl",properties:"properties",proto:"proto",protobuf:"proto",ps:"ps",ps1:"ps1",pug:"pug",puppet:"pp",purescript:"purs",py:"py",python:"py",ql:"ql",qml:"qml",qmldir:"qmldir",qss:"qss",r:"r",racket:"rkt",raku:"raku",razor:"cshtml",rb:"rb",reg:"reg",regex:"regex",regexp:"regexp",rel:"rel",riscv:"s",rs:"rs",rst:"rst",ruby:"rb",rust:"rs",sas:"sas",sass:"sass",scala:"scala",scheme:"scm",scss:"scss",sdbl:"sdbl",sh:"sh",shader:"shader",shaderlab:"shader",shell:"sh",shellscript:"sh",shellsession:"sh",smalltalk:"st",solidity:"sol",soy:"soy",sparql:"rq",spl:"spl",splunk:"spl",sql:"sql","ssh-config":"config",stata:"do",styl:"styl",stylus:"styl",svelte:"svelte",swift:"swift","system-verilog":"sv",systemd:"service",talon:"talon",talonscript:"talon",tasl:"tasl",tcl:"tcl",templ:"templ",terraform:"tf",tex:"tex",tf:"tf",tfvars:"tfvars",toml:"toml",ts:"ts","ts-tags":"ts",tsp:"tsp",tsv:"tsv",tsx:"tsx",turtle:"ttl",twig:"twig",typ:"typ",typescript:"ts",typespec:"tsp",typst:"typ",v:"v",vala:"vala",vb:"vb",verilog:"v",vhdl:"vhdl",vim:"vim",viml:"vim",vimscript:"vim",vue:"vue","vue-html":"html","vue-vine":"vine",vy:"vy",vyper:"vy",wasm:"wasm",wenyan:"wy",wgsl:"wgsl",wiki:"wiki",wikitext:"wiki",wit:"wit",wl:"wl",wolfram:"wl",xml:"xml",xsl:"xsl",yaml:"yaml",yml:"yml",zenscript:"zs",zig:"zig",zsh:"zsh",文言:"wy"},rHe=({onDownload:e,onError:t,language:n,children:s,className:r,code:a,...o})=>{let l=Xt(),{code:c}=xse(),{isAnimating:u}=x.useContext(Xa),f=Zl(),h=ao(),m=a??c,g=`file.${n&&n in J9?J9[n]:"txt"}`,b="text/plain",v=()=>{try{Yp(g,m,b),e==null||e()}catch(k){t==null||t(k)}};return i.jsx("button",{className:l("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),"data-streamdown":"code-block-download-button",disabled:u,onClick:v,title:f.downloadFile,type:"button",...o,children:s??i.jsx(h.DownloadIcon,{size:14})})},eB=()=>{let{Loader2Icon:e}=ao(),t=Xt();return i.jsxs("div",{className:t("w-full divide-y divide-border overflow-hidden rounded-xl border border-border"),children:[i.jsx("div",{className:t("h-[46px] w-full bg-muted/80")}),i.jsx("div",{className:t("flex w-full items-center justify-center p-4"),children:i.jsx(e,{className:t("size-4 animate-spin")})})]})},aHe=/\.[^/.]+$/,iHe=({node:e,className:t,src:n,alt:s,onLoad:r,onError:a,...o})=>{let{DownloadIcon:l}=ao(),c=Xt(),u=x.useRef(null),[f,h]=x.useState(!1),[m,g]=x.useState(!1),b=Zl(),v=o.width!=null||o.height!=null,k=(f||v)&&!m,w=m&&!v;x.useEffect(()=>{let _=u.current;if(_!=null&&_.complete){let j=_.naturalWidth>0;h(j),g(!j)}},[]);let C=x.useCallback(_=>{h(!0),g(!1),r==null||r(_)},[r]),E=x.useCallback(_=>{h(!1),g(!0),a==null||a(_)},[a]),T=async()=>{if(n)try{let _=await(await fetch(n)).blob(),j=new URL(n,window.location.origin).pathname.split("/").pop()||"",R=j.split(".").pop(),D=j.includes(".")&&R!==void 0&&R.length<=4,I="";if(D)I=j;else{let O=_.type,L="png";O.includes("jpeg")||O.includes("jpg")?L="jpg":O.includes("png")?L="png":O.includes("svg")?L="svg":O.includes("gif")?L="gif":O.includes("webp")&&(L="webp"),I=`${(s||j||"image").replace(aHe,"")}.${L}`}Yp(I,_,_.type)}catch{window.open(n,"_blank")}};return n?i.jsxs("div",{className:c("group relative my-4 inline-block"),"data-streamdown":"image-wrapper",children:[i.jsx("img",{alt:s,className:c("max-w-full rounded-lg",w&&"hidden",t),"data-streamdown":"image",onError:E,onLoad:C,ref:u,src:n,...o}),w&&i.jsx("span",{className:c("text-muted-foreground text-xs italic"),"data-streamdown":"image-fallback",children:b.imageNotAvailable}),i.jsx("div",{className:c("pointer-events-none absolute inset-0 hidden rounded-lg bg-black/10 group-hover:block")}),k&&i.jsx("button",{className:c("absolute right-2 bottom-2 flex h-8 w-8 cursor-pointer items-center justify-center rounded-md border border-border bg-background/90 shadow-sm backdrop-blur-sm transition-all duration-200 hover:bg-background","opacity-0 group-hover:opacity-100"),onClick:T,title:b.downloadImage,type:"button",children:i.jsx(l,{size:14})})]}):null},Sx=0,B5=()=>{Sx+=1,Sx===1&&(document.body.style.overflow="hidden")},$5=()=>{Sx=Math.max(0,Sx-1),Sx===0&&(document.body.style.overflow="")},oHe=({url:e,isOpen:t,onClose:n,onConfirm:s})=>{let{CheckIcon:r,CopyIcon:a,ExternalLinkIcon:o,XIcon:l}=ao(),c=Xt(),[u,f]=x.useState(!1),h=Zl(),m=x.useCallback(async()=>{try{await navigator.clipboard.writeText(e),f(!0),setTimeout(()=>f(!1),2e3)}catch{}},[e]),g=x.useCallback(()=>{s(),n()},[s,n]);return x.useEffect(()=>{if(t){B5();let b=v=>{v.key==="Escape"&&n()};return document.addEventListener("keydown",b),()=>{document.removeEventListener("keydown",b),$5()}}},[t,n]),t?i.jsx("div",{className:c("fixed inset-0 z-50 flex items-center justify-center bg-background/50 backdrop-blur-sm"),"data-streamdown":"link-safety-modal",onClick:n,onKeyDown:b=>{b.key==="Escape"&&n()},role:"button",tabIndex:0,children:i.jsxs("div",{className:c("relative mx-4 flex w-full max-w-md flex-col gap-4 rounded-xl border bg-background p-6 shadow-lg"),onClick:b=>b.stopPropagation(),onKeyDown:b=>b.stopPropagation(),role:"presentation",children:[i.jsx("button",{className:c("absolute top-4 right-4 rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:n,title:h.close,type:"button",children:i.jsx(l,{size:16})}),i.jsxs("div",{className:c("flex flex-col gap-2"),children:[i.jsxs("div",{className:c("flex items-center gap-2 font-semibold text-lg"),children:[i.jsx(o,{size:20}),i.jsx("span",{children:h.openExternalLink})]}),i.jsx("p",{className:c("text-muted-foreground text-sm"),children:h.externalLinkWarning})]}),i.jsx("div",{className:c("break-all rounded-md bg-muted p-3 font-mono text-sm",e.length>100&&"max-h-32 overflow-y-auto"),children:e}),i.jsxs("div",{className:c("flex gap-2"),children:[i.jsx("button",{className:c("flex flex-1 items-center justify-center gap-2 rounded-md border bg-background px-4 py-2 font-medium text-sm transition-all hover:bg-muted"),onClick:m,type:"button",children:u?i.jsxs(i.Fragment,{children:[i.jsx(r,{size:14}),i.jsx("span",{children:h.copied})]}):i.jsxs(i.Fragment,{children:[i.jsx(a,{size:14}),i.jsx("span",{children:h.copyLink})]})}),i.jsxs("button",{className:c("flex flex-1 items-center justify-center gap-2 rounded-md bg-primary px-4 py-2 font-medium text-primary-foreground text-sm transition-all hover:bg-primary/90"),onClick:g,type:"button",children:[i.jsx(o,{size:14}),i.jsx("span",{children:h.openLink})]})]})]})}):null},BR=x.createContext(null),H5=()=>x.useContext(BR),Zlt=()=>{var e;let t=H5();return(e=t==null?void 0:t.code)!=null?e:null},U5=()=>{var e;let t=H5();return(e=t==null?void 0:t.mermaid)!=null?e:null},lHe=e=>{var t;let n=H5();return n!=null&&n.renderers&&e&&(t=n.renderers.find(s=>Array.isArray(s.language)?s.language.includes(e):s.language===e))!=null?t:null},cHe=(e,t)=>{var n;let s=(n=void 0)!=null?n:5;return new Promise((r,a)=>{let o="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(e))),l=new Image;l.crossOrigin="anonymous",l.onload=()=>{let c=document.createElement("canvas"),u=l.width*s,f=l.height*s;c.width=u,c.height=f;let h=c.getContext("2d");if(!h){a(new Error("Failed to create 2D canvas context for PNG export"));return}h.drawImage(l,0,0,u,f),c.toBlob(m=>{if(!m){a(new Error("Failed to create PNG blob"));return}r(m)},"image/png")},l.onerror=()=>a(new Error("Failed to load SVG image")),l.src=o})},uHe=({chart:e,children:t,className:n,onDownload:s,config:r,onError:a})=>{let o=Xt(),[l,c]=x.useState(!1),u=x.useRef(null),{isAnimating:f}=x.useContext(Xa),h=ao(),m=U5(),g=Zl(),b=async v=>{try{if(v==="mmd"){Yp("diagram.mmd",e,"text/plain"),c(!1),s==null||s(v);return}if(!m){a==null||a(new Error("Mermaid plugin not available"));return}let k=m.getMermaid(r),w=e.split("").reduce((T,_)=>(T<<5)-T+_.charCodeAt(0)|0,0),C=`mermaid-${Math.abs(w)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:E}=await k.render(C,e);if(!E){a==null||a(new Error("SVG not found. Please wait for the diagram to render."));return}if(v==="svg"){Yp("diagram.svg",E,"image/svg+xml"),c(!1),s==null||s(v);return}if(v==="png"){let T=await cHe(E);Yp("diagram.png",T,"image/png"),s==null||s(v),c(!1);return}}catch(k){a==null||a(k)}};return x.useEffect(()=>{let v=k=>{let w=k.composedPath();u.current&&!w.includes(u.current)&&c(!1)};return document.addEventListener("mousedown",v),()=>{document.removeEventListener("mousedown",v)}},[]),i.jsxs("div",{className:o("relative"),ref:u,children:[i.jsx("button",{className:o("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",n),disabled:f,onClick:()=>c(!l),title:g.downloadDiagram,type:"button",children:t??i.jsx(h.DownloadIcon,{size:14})}),l?i.jsxs("div",{className:o("absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[i.jsx("button",{className:o("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>b("svg"),title:g.downloadDiagramAsSvg,type:"button",children:g.mermaidFormatSvg}),i.jsx("button",{className:o("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>b("png"),title:g.downloadDiagramAsPng,type:"button",children:g.mermaidFormatPng}),i.jsx("button",{className:o("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>b("mmd"),title:g.downloadDiagramAsMmd,type:"button",children:g.mermaidFormatMmd})]}):null]})},dHe=({chart:e,config:t,onFullscreen:n,onExit:s,className:r,...a})=>{let{Maximize2Icon:o,XIcon:l}=ao(),c=Xt(),[u,f]=x.useState(!1),{isAnimating:h,controls:m}=x.useContext(Xa),g=Zl(),b=(()=>{if(typeof m=="boolean")return m;let k=m.mermaid;return k===!1?!1:k===!0||k===void 0?!0:k.panZoom!==!1})(),v=()=>{f(!u)};return x.useEffect(()=>{if(u){B5();let k=w=>{w.key==="Escape"&&f(!1)};return document.addEventListener("keydown",k),()=>{document.removeEventListener("keydown",k),$5()}}},[u]),x.useEffect(()=>{u?n==null||n():s&&s()},[u,n,s]),i.jsxs(i.Fragment,{children:[i.jsx("button",{className:c("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),disabled:h,onClick:v,title:g.viewFullscreen,type:"button",...a,children:i.jsx(o,{size:14})}),u?to.createPortal(i.jsxs("div",{className:c("fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm"),onClick:v,onKeyDown:k=>{k.key==="Escape"&&v()},role:"button",tabIndex:0,children:[i.jsx("button",{className:c("absolute top-4 right-4 z-10 rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:v,title:g.exitFullscreen,type:"button",children:i.jsx(l,{size:20})}),i.jsx("div",{className:c("flex size-full items-center justify-center p-4"),onClick:k=>k.stopPropagation(),onKeyDown:k=>k.stopPropagation(),role:"presentation",children:i.jsx(Jse,{chart:e,className:c("size-full [&_svg]:h-auto [&_svg]:w-auto"),config:t,fullscreen:!0,showControls:b})})]}),document.body):null]})},vse=e=>{var t,n;let s=[],r=[],a=e.querySelectorAll("thead th");for(let l of a)s.push(((t=l.textContent)==null?void 0:t.trim())||"");let o=e.querySelectorAll("tbody tr");for(let l of o){let c=[],u=l.querySelectorAll("td");for(let f of u)c.push(((n=f.textContent)==null?void 0:n.trim())||"");r.push(c)}return{headers:s,rows:r}},Sse=e=>{let{headers:t,rows:n}=e,s=l=>{let c=!1,u=!1;for(let f of l){if(f==='"'){c=!0,u=!0;break}(f===","||f===`
|
|
1024
1024
|
`)&&(c=!0)}return c?u?`"${l.replace(/"/g,'""')}"`:`"${l}"`:l},r=t.length>0?n.length+1:n.length,a=new Array(r),o=0;t.length>0&&(a[o]=t.map(s).join(","),o+=1);for(let l of n)a[o]=l.map(s).join(","),o+=1;return a.join(`
|
|
1025
1025
|
`)},fHe=e=>{let{headers:t,rows:n}=e,s=l=>{let c=!1;for(let f of l)if(f===" "||f===`
|
|
@@ -1040,7 +1040,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1040
1040
|
|
|
1041
1041
|
`})}return n},GHe=/([\\`*_~[\]|])/g,KHe=e=>e.replace(GHe,"\\$1"),WHe=(e,t)=>{if(!t.length)return e;let n=e;for(let s of t){let r=new RegExp(`(<${s}(?=[\\s>/])[^>]*>)([\\s\\S]*?)(</${s}\\s*>)`,"gi");n=n.replace(r,(a,o,l,c)=>{let u=KHe(l).replace(/\n\n/g," ");return o+u+c})}return n},Yse=e=>e.type==="text"?e.value:"children"in e&&Array.isArray(e.children)?e.children.map(Yse).join(""):"",YHe=e=>t=>{if(!e||e.length===0)return;let n=new Set(e.map(s=>s.toLowerCase()));Po(t,"element",s=>{if(n.has(s.tagName.toLowerCase())){let r=Yse(s);s.children=r?[{type:"text",value:r}]:[]}})},ZHe=()=>e=>{Po(e,"code",t=>{var n,s;t.meta&&(t.data=(n=t.data)!=null?n:{},t.data.hProperties={...(s=t.data.hProperties)!=null?s:{},metastring:t.meta})})},XHe=/^[ \t]*<[\w!/?-]/,QHe=/(^|\n)[ \t]{4,}(?=<[\w!/?-])/g,JHe=e=>typeof e!="string"||e.length===0||!XHe.test(e)?e:e.replace(QHe,"$1"),dB,fB,hB,pB,oS={...Ld,protocols:{...Ld.protocols,href:[...(fB=(dB=Ld.protocols)==null?void 0:dB.href)!=null?fB:[],"tel"]},attributes:{...Ld.attributes,code:[...(pB=(hB=Ld.attributes)==null?void 0:hB.code)!=null?pB:[],"metastring"]}},UR={raw:TR,sanitize:[ane,oS],harden:[WOe,{allowedImagePrefixes:["*"],allowedLinkPrefixes:["*"],allowedProtocols:["*"],defaultOrigin:void 0,allowDataImages:!0}]},eUe={gfm:[fze,{}],codeMeta:ZHe},mB=Object.values(UR),tUe=Object.values(eUe),nUe={block:" ▋",circle:" ●"},Zse=["github-light","github-dark"],Xse={enabled:!0},sUe={shikiTheme:Zse,controls:!0,isAnimating:!1,lineNumbers:!0,mode:"streaming",mermaid:void 0,linkSafety:Xse},Xa=x.createContext(sUe),Qse=x.memo(({content:e,shouldParseIncompleteMarkdown:t,shouldNormalizeHtmlIndentation:n,index:s,isIncomplete:r,dir:a,animatePlugin:o,...l})=>{if(o){let f=o.getLastRenderCharCount();o.setPrevContentLength(f)}let c=typeof e=="string"&&n?JHe(e):e,u=i.jsx(Wse,{...l,children:c});return i.jsx(mse.Provider,{value:r,children:a?i.jsx("div",{dir:a,style:{display:"contents"},children:u}):u})},(e,t)=>{if(e.content!==t.content||e.shouldNormalizeHtmlIndentation!==t.shouldNormalizeHtmlIndentation||e.index!==t.index||e.isIncomplete!==t.isIncomplete||e.dir!==t.dir)return!1;if(e.components!==t.components){let n=Object.keys(e.components||{}),s=Object.keys(t.components||{});if(n.length!==s.length||n.some(r=>{var a,o;return((a=e.components)==null?void 0:a[r])!==((o=t.components)==null?void 0:o[r])}))return!1}return!(e.rehypePlugins!==t.rehypePlugins||e.remarkPlugins!==t.remarkPlugins)});Qse.displayName="Block";var q5=x.memo(({children:e,mode:t="streaming",dir:n,parseIncompleteMarkdown:s=!0,normalizeHtmlIndentation:r=!1,components:a,rehypePlugins:o=mB,remarkPlugins:l=tUe,className:c,shikiTheme:u=Zse,mermaid:f,controls:h=!0,isAnimating:m=!1,animated:g,BlockComponent:b=Qse,parseMarkdownIntoBlocksFn:v=VHe,caret:k,plugins:w,remend:C,linkSafety:E=Xse,lineNumbers:T=!0,allowedTags:_,literalTagContent:j,translations:R,icons:D,prefix:I,onAnimationStart:O,onAnimationEnd:L,...B})=>{let H=x.useId(),[K,U]=x.useTransition(),$=x.useMemo(()=>F$e(I),[I]),q=x.useRef(null),J=x.useRef(O),ne=x.useRef(L);J.current=O,ne.current=L,x.useEffect(()=>{var Ie,Te,Je;if(t==="static")return;let _t=q.current;if(q.current=m,_t===null){m&&((Ie=J.current)==null||Ie.call(J));return}m&&!_t?(Te=J.current)==null||Te.call(J):!m&&_t&&((Je=ne.current)==null||Je.call(ne))},[m,t]);let F=x.useMemo(()=>_?Object.keys(_):[],[_]),V=x.useMemo(()=>{if(typeof e!="string")return"";let Ie=t==="streaming"&&s?k9e(e,C):e;return j&&j.length>0&&(Ie=WHe(Ie,j)),F.length>0&&(Ie=qHe(Ie,F)),Ie},[e,t,s,C,F,j]),G=x.useMemo(()=>v(V),[V,v]),[P,Z]=x.useState(G);x.useEffect(()=>{t==="streaming"&&!pe?U(()=>{Z(G)}):Z(G)},[G,t]);let Q=t==="streaming"?P:G,re=x.useMemo(()=>n==="auto"?Q.map(nB):void 0,[Q,n]),ae=x.useMemo(()=>Q.map((Ie,Te)=>`${H}-${Te}`),[Q.length,H]),de=x.useMemo(()=>g===!0?"true":g?JSON.stringify(g):"",[g]),pe=x.useMemo(()=>de?de==="true"?LR():LR(g):null,[de]),Oe=x.useMemo(()=>{var Ie,Te;return{shikiTheme:(Te=(Ie=w==null?void 0:w.code)==null?void 0:Ie.getThemes())!=null?Te:u,controls:h,isAnimating:m,lineNumbers:T,mode:t,mermaid:f,linkSafety:E}},[u,h,m,T,t,f,E,w==null?void 0:w.code]),Ve=x.useMemo(()=>R?JSON.stringify(R):"",[R]),$e=x.useMemo(()=>({...bse,...R}),[Ve]),Qe=x.useMemo(()=>{let{inlineCode:Ie,...Te}=a??{},Je={...SHe,...Te};if(Ie){let _t=Je.code;Je.code=St=>"data-block"in St?_t?x.createElement(_t,St):null:x.createElement(Ie,St)}return Je},[a]),Se=x.useMemo(()=>{let Ie=[];return w!=null&&w.cjk&&(Ie=[...Ie,...w.cjk.remarkPluginsBefore]),Ie=[...Ie,...l],w!=null&&w.cjk&&(Ie=[...Ie,...w.cjk.remarkPluginsAfter]),w!=null&&w.math&&(Ie=[...Ie,w.math.remarkPlugin]),Ie},[l,w==null?void 0:w.math,w==null?void 0:w.cjk]),Ze=x.useMemo(()=>{var Ie;let Te=o;if(_&&Object.keys(_).length>0&&o===mB){let Je={...oS,tagNames:[...(Ie=oS.tagNames)!=null?Ie:[],...Object.keys(_)],attributes:{...oS.attributes,..._}};Te=[UR.raw,[ane,Je],UR.harden]}return j&&j.length>0&&(Te=[...Te,[YHe,j]]),w!=null&&w.math&&(Te=[...Te,w.math.rehypePlugin]),pe&&m&&(Te=[...Te,pe.rehypePlugin]),Te},[o,w==null?void 0:w.math,pe,m,_,j]),bt=x.useMemo(()=>{if(!m||Q.length===0)return!1;let Ie=Q.at(-1);return sB(Ie)||THe(Ie)},[m,Q]),Me=x.useMemo(()=>k&&m&&!bt?{"--streamdown-caret":`"${nUe[k]}"`}:void 0,[k,m,bt]);return t==="static"?i.jsx(zR.Provider,{value:$e,children:i.jsx(BR.Provider,{value:w??null,children:i.jsx(Xa.Provider,{value:Oe,children:i.jsx(X9,{icons:D,children:i.jsx(FR.Provider,{value:$,children:i.jsx("div",{className:$("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",c),dir:n==="auto"?nB(V):n,children:i.jsx(Wse,{components:Qe,rehypePlugins:Ze,remarkPlugins:Se,...B,children:V})})})})})})}):i.jsx(zR.Provider,{value:$e,children:i.jsx(BR.Provider,{value:w??null,children:i.jsx(Xa.Provider,{value:Oe,children:i.jsx(X9,{icons:D,children:i.jsx(FR.Provider,{value:$,children:i.jsxs("div",{className:$("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",k&&!bt?"[&>*:last-child]:after:inline [&>*:last-child]:after:align-baseline [&>*:last-child]:after:content-[var(--streamdown-caret)]":null,c),style:Me,children:[Q.length===0&&k&&m&&i.jsx("span",{}),Q.map((Ie,Te)=>{var Je;let _t=Te===Q.length-1,St=m&&_t&&sB(Ie);return i.jsx(b,{animatePlugin:pe,components:Qe,content:Ie,dir:(Je=re==null?void 0:re[Te])!=null?Je:n!=="auto"?n:void 0,index:Te,isIncomplete:St,rehypePlugins:Ze,remarkPlugins:Se,shouldNormalizeHtmlIndentation:r,shouldParseIncompleteMarkdown:s,...B},ae[Te])})]})})})})})})},(e,t)=>e.children===t.children&&e.shikiTheme===t.shikiTheme&&e.isAnimating===t.isAnimating&&e.animated===t.animated&&e.mode===t.mode&&e.plugins===t.plugins&&e.className===t.className&&e.linkSafety===t.linkSafety&&e.lineNumbers===t.lineNumbers&&e.normalizeHtmlIndentation===t.normalizeHtmlIndentation&&e.literalTagContent===t.literalTagContent&&JSON.stringify(e.translations)===JSON.stringify(t.translations)&&e.prefix===t.prefix&&e.dir===t.dir);q5.displayName="Streamdown";var rUe=({children:e,className:t,minZoom:n=.5,maxZoom:s=3,zoomStep:r=.1,showControls:a=!0,initialZoom:o=1,fullscreen:l=!1})=>{let{RotateCcwIcon:c,ZoomInIcon:u,ZoomOutIcon:f}=ao(),h=Xt(),m=x.useRef(null),g=x.useRef(null),[b,v]=x.useState(o),[k,w]=x.useState({x:0,y:0}),[C,E]=x.useState(!1),[T,_]=x.useState({x:0,y:0}),[j,R]=x.useState({x:0,y:0}),D=x.useCallback($=>{v(q=>Math.max(n,Math.min(s,q+$)))},[n,s]),I=x.useCallback(()=>{D(r)},[D,r]),O=x.useCallback(()=>{D(-r)},[D,r]),L=x.useCallback(()=>{v(o),w({x:0,y:0})},[o]),B=x.useCallback($=>{$.preventDefault();let q=$.deltaY>0?-r:r;D(q)},[D,r]),H=x.useCallback($=>{if($.button!==0||$.isPrimary===!1)return;E(!0),_({x:$.clientX,y:$.clientY}),R(k);let q=$.currentTarget;q instanceof HTMLElement&&q.setPointerCapture($.pointerId)},[k]),K=x.useCallback($=>{if(!C)return;$.preventDefault();let q=$.clientX-T.x,J=$.clientY-T.y;w({x:j.x+q,y:j.y+J})},[C,T,j]),U=x.useCallback($=>{E(!1);let q=$.currentTarget;q instanceof HTMLElement&&q.releasePointerCapture($.pointerId)},[]);return x.useEffect(()=>{let $=m.current;if($)return $.addEventListener("wheel",B,{passive:!1}),()=>{$.removeEventListener("wheel",B)}},[B]),x.useEffect(()=>{let $=g.current;if($&&C)return document.body.style.userSelect="none",$.addEventListener("pointermove",K,{passive:!1}),$.addEventListener("pointerup",U),$.addEventListener("pointercancel",U),()=>{document.body.style.userSelect="",$.removeEventListener("pointermove",K),$.removeEventListener("pointerup",U),$.removeEventListener("pointercancel",U)}},[C,K,U]),i.jsxs("div",{className:h("relative flex flex-col",l?"h-full w-full":"min-h-28 w-full",t),ref:m,style:{cursor:C?"grabbing":"grab"},children:[a?i.jsxs("div",{className:h("absolute z-10 flex flex-col gap-1 rounded-md border border-border bg-background/80 p-1 supports-[backdrop-filter]:bg-background/70 supports-[backdrop-filter]:backdrop-blur-sm",l?"bottom-4 left-4":"bottom-2 left-2"),children:[i.jsx("button",{className:h("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50"),disabled:b>=s,onClick:I,title:"Zoom in",type:"button",children:i.jsx(u,{size:16})}),i.jsx("button",{className:h("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50"),disabled:b<=n,onClick:O,title:"Zoom out",type:"button",children:i.jsx(f,{size:16})}),i.jsx("button",{className:h("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"),onClick:L,title:"Reset zoom and pan",type:"button",children:i.jsx(c,{size:16})})]}):null,i.jsx("div",{className:h("flex-1 origin-center transition-transform duration-150 ease-out",l?"flex h-full w-full items-center justify-center":"flex w-full items-center justify-center"),onPointerDown:H,ref:g,role:"application",style:{transform:`translate(${k.x}px, ${k.y}px) scale(${b})`,transformOrigin:"center center",touchAction:"none",willChange:"transform"},children:e})]})},Jse=({chart:e,className:t,config:n,fullscreen:s=!1,showControls:r=!0})=>{let a=Xt(),[o,l]=x.useState(null),[c,u]=x.useState(!1),[f,h]=x.useState(""),[m,g]=x.useState(""),[b,v]=x.useState(0),{mermaid:k}=x.useContext(Xa),w=U5(),C=k==null?void 0:k.errorComponent,{shouldRender:E,containerRef:T}=T$e({immediate:s});if(x.useEffect(()=>{if(E){if(!w){l("Mermaid plugin not available. Please add the mermaid plugin to enable diagram rendering.");return}(async()=>{try{l(null),u(!0);let j=w.getMermaid(n),R=e.split("").reduce((O,L)=>(O<<5)-O+L.charCodeAt(0)|0,0),D=`mermaid-${Math.abs(R)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:I}=await j.render(D,e);h(I),g(I)}catch(j){if(!(m||f)){let R=j instanceof Error?j.message:"Failed to render Mermaid chart";l(R)}}finally{u(!1)}})()}},[e,n,b,E,w]),!(E||f||m))return i.jsx("div",{className:a("my-4 min-h-[200px]",t),ref:T});if(c&&!f&&!m)return i.jsx("div",{className:a("my-4 flex justify-center p-4",t),ref:T,children:i.jsxs("div",{className:a("flex items-center space-x-2 text-muted-foreground"),children:[i.jsx("div",{className:a("h-4 w-4 animate-spin rounded-full border-current border-b-2")}),i.jsx("span",{className:a("text-sm"),children:"Loading diagram..."})]})});if(o&&!f&&!m){let j=()=>v(R=>R+1);return C?i.jsx("div",{ref:T,children:i.jsx(C,{chart:e,error:o,retry:j})}):i.jsxs("div",{className:a("rounded-md bg-red-50 p-4",t),ref:T,children:[i.jsxs("p",{className:a("font-mono text-red-700 text-sm"),children:["Mermaid Error: ",o]}),i.jsxs("details",{className:a("mt-2"),children:[i.jsx("summary",{className:a("cursor-pointer text-red-600 text-xs"),children:"Show Code"}),i.jsx("pre",{className:a("mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs"),children:e})]})]})}let _=f||m;return i.jsx("div",{className:a("size-full",t),"data-streamdown":"mermaid",ref:T,children:i.jsx(rUe,{className:a(s?"size-full overflow-hidden":"overflow-hidden",t),fullscreen:s,maxZoom:3,minZoom:.5,showControls:r,zoomStep:.1,children:i.jsx("div",{"aria-label":"Mermaid chart",className:a("flex justify-center",s?"size-full items-center":null),dangerouslySetInnerHTML:{__html:_},role:"img"})})})};function Ew({content:e,className:t}){return i.jsx("div",{className:X("prose prose-sm dark:prose-invert max-w-none",t),children:i.jsx(q5,{children:e})})}function Xl({...e}){return i.jsx(ky,{"data-slot":"sheet",...e})}function aUe({...e}){return i.jsx(vk,{"data-slot":"sheet-trigger",...e})}function iUe({...e}){return i.jsx(Cy,{"data-slot":"sheet-portal",...e})}function oUe({className:e,...t}){return i.jsx(Om,{"data-slot":"sheet-overlay",className:X("data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t})}function Ql({className:e,children:t,side:n="right",showCloseButton:s=!0,...r}){return i.jsxs(iUe,{children:[i.jsx(oUe,{}),i.jsxs(Im,{"data-slot":"sheet-content",className:X("bg-background data-[state=closed]:animate-out data-[state=open]:animate-in fixed z-50 flex flex-col gap-4 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500",n==="right"&&"data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm",n==="left"&&"data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm",n==="top"&&"data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b",n==="bottom"&&"data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t",e),...r,children:[t,s&&i.jsxs(Pm,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none",children:[i.jsx(ls,{className:"size-4"}),i.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function Jl({className:e,...t}){return i.jsx("div",{"data-slot":"sheet-header",className:X("flex flex-col gap-1.5 p-4",e),...t})}function qC({className:e,...t}){return i.jsx("div",{"data-slot":"sheet-footer",className:X("mt-auto flex flex-col gap-2 p-4",e),...t})}function ec({className:e,...t}){return i.jsx(Ey,{"data-slot":"sheet-title",className:X("text-foreground font-semibold",e),...t})}function ph({className:e,...t}){return i.jsx(Ty,{"data-slot":"sheet-description",className:X("text-muted-foreground text-sm",e),...t})}const lUe="16rem",cUe="18rem",uUe="3rem",dUe="b",G5=x.createContext(null);function GC(){const e=x.useContext(G5);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}function fUe({defaultOpen:e=!0,open:t,onOpenChange:n,className:s,style:r,children:a,...o}){const l=Zs(),[c,u]=x.useState(!1),[f,h]=x.useState(e),m=t??f,g=x.useCallback(w=>{const C=typeof w=="function"?w(m):w;n?n(C):h(C)},[n,m]),b=x.useCallback(()=>l?u(w=>!w):g(w=>!w),[l,g,u]);x.useEffect(()=>{const w=C=>{C.key===dUe&&(C.metaKey||C.ctrlKey)&&(C.preventDefault(),b())};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[b]);const v=m?"expanded":"collapsed",k=x.useMemo(()=>({state:v,open:m,setOpen:g,isMobile:l,openMobile:c,setOpenMobile:u,toggleSidebar:b}),[v,m,g,l,c,u,b]);return i.jsx(G5.Provider,{value:k,children:i.jsx(eb,{delayDuration:0,children:i.jsx("div",{"data-slot":"sidebar-wrapper",style:{"--sidebar-width":lUe,"--sidebar-width-icon":uUe,...r},className:X("group/sidebar-wrapper has-data-[variant=inset]:bg-sidebar flex min-h-svh w-full",s),...o,children:a})})})}function hUe({side:e="left",variant:t="sidebar",collapsible:n="offcanvas",className:s,children:r,...a}){const{isMobile:o,state:l,openMobile:c,setOpenMobile:u}=GC();return n==="none"?i.jsx("div",{"data-slot":"sidebar",className:X("bg-sidebar text-sidebar-foreground flex h-full w-(--sidebar-width) flex-col",s),...a,children:r}):o?i.jsx(Xl,{open:c,onOpenChange:u,...a,children:i.jsxs(Ql,{"data-sidebar":"sidebar","data-slot":"sidebar","data-mobile":"true",className:"bg-sidebar text-sidebar-foreground w-(--sidebar-width) p-0 [&>button]:hidden",style:{"--sidebar-width":cUe},side:e,children:[i.jsxs(Jl,{className:"sr-only",children:[i.jsx(ec,{children:"Sidebar"}),i.jsx(ph,{children:"Displays the mobile sidebar."})]}),i.jsx("div",{className:"flex h-full w-full flex-col",children:r})]})}):i.jsxs("div",{className:"group peer text-sidebar-foreground hidden md:block","data-state":l,"data-collapsible":l==="collapsed"?n:"","data-variant":t,"data-side":e,"data-slot":"sidebar",children:[i.jsx("div",{"data-slot":"sidebar-gap",className:X("relative w-(--sidebar-width) bg-transparent transition-[width] duration-300 ease-in-out","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180",t==="floating"||t==="inset"?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]":"group-data-[collapsible=icon]:w-(--sidebar-width-icon)")}),i.jsx("div",{"data-slot":"sidebar-container",className:X("fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-300 ease-in-out md:flex",e==="left"?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",t==="floating"||t==="inset"?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]":"group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l",s),...a,children:i.jsx("div",{"data-sidebar":"sidebar","data-slot":"sidebar-inner",className:"bg-sidebar group-data-[variant=floating]:border-sidebar-border flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:shadow-md",children:r})})]})}function pUe({className:e,onClick:t,...n}){const{toggleSidebar:s}=GC();return i.jsxs(ve,{"data-sidebar":"trigger","data-slot":"sidebar-trigger",variant:"ghost",size:"icon",className:X("size-7",e),onClick:r=>{t==null||t(r),s()},...n,children:[i.jsx(ATe,{}),i.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})}function mUe({className:e,...t}){const{toggleSidebar:n}=GC();return i.jsx("button",{"data-sidebar":"rail","data-slot":"sidebar-rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:n,title:"Toggle Sidebar",className:X("hover:after:bg-sidebar-border absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] sm:flex","in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize","[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize","hover:group-data-[collapsible=offcanvas]:bg-sidebar group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full","[[data-side=left][data-collapsible=offcanvas]_&]:-right-2","[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",e),...t})}function gUe({className:e,...t}){return i.jsx("main",{"data-slot":"sidebar-inset",className:X("bg-background relative flex min-w-0 flex-1 flex-col","md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2",e),...t})}function ere({className:e,...t}){return i.jsx("div",{"data-slot":"sidebar-header","data-sidebar":"header",className:X("flex flex-col gap-2 p-2",e),...t})}function xUe({className:e,...t}){return i.jsx("div",{"data-slot":"sidebar-footer","data-sidebar":"footer",className:X("flex flex-col gap-2 p-2",e),...t})}function tre({className:e,...t}){return i.jsx("div",{"data-slot":"sidebar-content","data-sidebar":"content",className:X("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...t})}function Dl({className:e,...t}){return i.jsx("div",{"data-slot":"sidebar-group","data-sidebar":"group",className:X("relative flex w-full min-w-0 flex-col p-2",e),...t})}function Gi({className:e,asChild:t=!1,...n}){const s=t?vy:"div";return i.jsx(s,{"data-slot":"sidebar-group-label","data-sidebar":"group-label",className:X("text-sidebar-foreground/70 ring-sidebar-ring flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium outline-hidden transition-[margin,opacity] duration-300 ease-in-out focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",e),...n})}function lS({className:e,asChild:t=!1,...n}){const s=t?vy:"button";return i.jsx(s,{"data-slot":"sidebar-group-action","data-sidebar":"group-action",className:X("text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground absolute top-3.5 right-3 flex aspect-square w-5 items-center justify-center rounded-md p-0 outline-hidden transition-transform focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 md:after:hidden","group-data-[collapsible=icon]:hidden",e),...n})}function $r({className:e,...t}){return i.jsx("ul",{"data-slot":"sidebar-menu","data-sidebar":"menu",className:X("flex w-full min-w-0 flex-col gap-1",e),...t})}function _r({className:e,...t}){return i.jsx("li",{"data-slot":"sidebar-menu-item","data-sidebar":"menu-item",className:X("group/menu-item relative",e),...t})}const yUe=Mu("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding,background-color,color,transform] duration-150 ease-out group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:scale-[0.97] active:duration-100 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"h-8 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:p-0!"}},defaultVariants:{variant:"default",size:"default"}});function ga({asChild:e=!1,isActive:t=!1,variant:n="default",size:s="default",tooltip:r,className:a,...o}){const l=e?vy:"button",{isMobile:c,state:u}=GC(),f=i.jsx(l,{"data-slot":"sidebar-menu-button","data-sidebar":"menu-button","data-size":s,"data-active":t,className:X(yUe({variant:n,size:s}),a),...o});return r?(typeof r=="string"&&(r={children:r}),i.jsxs(Kn,{children:[i.jsx(Wn,{asChild:!0,children:f}),i.jsx(Yn,{side:"right",align:"center",hidden:u!=="collapsed"||c,...r})]})):f}function bUe({className:e,asChild:t=!1,showOnHover:n=!1,...s}){const r=t?vy:"button";return i.jsx(r,{"data-slot":"sidebar-menu-action","data-sidebar":"menu-action",className:X("text-sidebar-foreground ring-sidebar-ring peer-hover/menu-button:text-sidebar-accent-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 outline-hidden transition-transform focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 md:after:hidden","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",n&&"peer-data-[active=true]/menu-button:text-sidebar-accent-foreground group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 md:opacity-0",e),...s})}const nre=x.createContext(null);function cg(){const e=x.useContext(nre);if(!e)throw new Error("useFilterBar must be used within a <FilterBar> component.");return e}function vUe({state:e,children:t,className:n}){return i.jsx(nre.Provider,{value:e,children:i.jsx("div",{"data-slot":"filter-bar",className:X("flex flex-wrap items-center gap-2 px-4 py-3",n),children:t})})}function SUe({placeholder:e="Search...",className:t}){const{inputValues:n,set:s}=cg(),r=n.search;return i.jsxs("div",{"data-slot":"filter-bar-search",className:X("relative",t),children:[i.jsx(Ti,{className:"text-muted-foreground pointer-events-none absolute top-1/2 left-2.5 size-3.5 -translate-y-1/2"}),i.jsx(_n,{responsive:!1,placeholder:e,value:r??"",onChange:a=>s("search",a.target.value),className:"h-8 pl-8 text-sm sm:max-w-64"})]})}function wUe({name:e,className:t}){var g;const{schema:n,values:s,set:r}=cg(),[a,o]=x.useState(!1),l=n.definitions[e];if(!l||!tC(l))return null;const c=l,u=c.label??e,f=s[e]??[],h=f.length===0?u:f.length===1?`${u}: ${((g=c.labels)==null?void 0:g[f[0]])??f[0]}`:`${u}: ${f.length} selected`;function m(b){const v=f.includes(b)?f.filter(k=>k!==b):[...f,b];r(e,v)}return i.jsxs(eg,{open:a,onOpenChange:o,children:[i.jsxs(tg,{"data-slot":"filter-bar-primary",className:X("border-input hover:bg-accent hover:text-accent-foreground inline-flex h-7 items-center gap-1 rounded-md border px-2.5 text-xs",f.length>0&&"border-primary/50",t),children:[h,i.jsx(Ps,{className:"size-3 opacity-50"})]}),i.jsx(ng,{align:"start",className:"w-48 p-1",children:c.options.map(b=>{var v,k;return i.jsxs("label",{className:"hover:bg-accent flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-xs",children:[i.jsx(zx,{checked:f.includes(b),onCheckedChange:()=>m(b)}),((v=c.colors)==null?void 0:v[b])&&i.jsx("span",{className:X("size-2 shrink-0 rounded-full bg-current",c.colors[b])}),i.jsx("span",{children:((k=c.labels)==null?void 0:k[b])??b})]},b)})})]})}const kUe={enum:Q3,dateRange:PCe,boolean:I_e,numericRange:LEe},CUe=[{label:"Past 1h",value:"1h"},{label:"Past 24h",value:"24h"},{label:"Past 7d",value:"7d"},{label:"Past 30d",value:"30d"}];function EUe({dynamicOptions:e,className:t}){const{schema:n,values:s,set:r,clear:a}=cg(),[o,l]=x.useState(!1),[c,u]=x.useState("list"),f=Object.entries(n.definitions).filter(([,_])=>_.type!=="text");function h(_){l(_),_||u("list")}function m(_){u(_)}function g(){u("list")}function b(){return i.jsx("div",{className:"flex flex-col",children:f.map(([_,j])=>{const R=kUe[j.type]??Q3,D=j.isActive(s[_]),I=j.label??_;return i.jsxs("button",{type:"button",onClick:()=>m(_),className:"hover:bg-accent flex items-center gap-2 rounded-sm px-2 py-1.5 text-xs",children:[i.jsx(R,{className:"text-muted-foreground size-3.5"}),i.jsx("span",{className:"flex-1 text-left",children:I}),D&&i.jsx(Zt,{className:"text-primary size-3"})]},_)})})}function v(_){const j=n.definitions[_];if(!j)return null;const R=j.label??_;return i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsxs("button",{type:"button",onClick:g,className:"hover:bg-accent -mx-1 flex items-center gap-1 rounded-sm px-1 py-1 text-xs font-medium",children:[i.jsx(qS,{className:"size-3"}),R]}),k(_)]})}function k(_){const j=n.definitions[_];return j?tC(j)?w(_,j):j.type==="dateRange"?C(_):j.type==="boolean"?E(_):j.type==="numericRange"?T(_):null:null}function w(_,j){const R=j.dynamic?(e==null?void 0:e[_])??j.options:j.options,D=s[_]??(j.multi?[]:""),I=Array.isArray(D)?D:D?[D]:[];function O(L){if(j.multi){const B=I.includes(L)?I.filter(H=>H!==L):[...I,L];r(_,B)}else r(_,I.includes(L)?"":L)}return i.jsxs("div",{className:"flex flex-col",children:[R.map(L=>{var B,H;return i.jsxs("label",{className:"hover:bg-accent flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-xs",children:[i.jsx(zx,{checked:I.includes(L),onCheckedChange:()=>O(L)}),((B=j.colors)==null?void 0:B[L])&&i.jsx("span",{className:X("size-2 shrink-0 rounded-full bg-current",j.colors[L])}),i.jsx("span",{children:((H=j.labels)==null?void 0:H[L])??L})]},L)}),I.length>0&&i.jsx(ve,{variant:"ghost",size:"xs",responsive:!1,className:"mt-1 self-start",onClick:()=>a(_),children:"Clear"})]})}function C(_){const j=s[_]??{};return i.jsxs("div",{className:"flex flex-col gap-1",children:[CUe.map(R=>i.jsx("button",{type:"button",onClick:()=>r(_,{preset:R.value}),className:X("hover:bg-accent rounded-sm px-2 py-1.5 text-left text-xs",j.preset===R.value&&"bg-accent font-medium"),children:R.label},R.value)),j.preset&&i.jsx(ve,{variant:"ghost",size:"xs",responsive:!1,className:"mt-1 self-start",onClick:()=>a(_),children:"Clear"})]})}function E(_){const j=s[_];return i.jsx("div",{className:"flex flex-col gap-1",children:[!0,!1].map(R=>i.jsx("button",{type:"button",onClick:()=>r(_,j===R?null:R),className:X("hover:bg-accent rounded-sm px-2 py-1.5 text-left text-xs",j===R&&"bg-accent font-medium"),children:R?"Yes":"No"},String(R)))})}function T(_){const j=s[_]??{};return i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[i.jsx("span",{className:"text-muted-foreground w-8",children:"Min"}),i.jsx(_n,{responsive:!1,type:"number","aria-label":"Minimum value",value:j.min??"",onChange:R=>r(_,{...j,min:R.target.value?Number(R.target.value):void 0}),className:"h-7 text-xs"})]}),i.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[i.jsx("span",{className:"text-muted-foreground w-8",children:"Max"}),i.jsx(_n,{responsive:!1,type:"number","aria-label":"Maximum value",value:j.max??"",onChange:R=>r(_,{...j,max:R.target.value?Number(R.target.value):void 0}),className:"h-7 text-xs"})]})]})}return i.jsxs(eg,{open:o,onOpenChange:h,children:[i.jsxs(tg,{"data-slot":"filter-bar-add-filter",className:X("border-muted text-muted-foreground hover:text-foreground hover:border-input inline-flex h-7 items-center gap-1 rounded-md border border-dashed px-2.5 text-xs",t),children:[i.jsx(Es,{className:"size-3"}),"Filter"]}),i.jsx(ng,{align:"start",className:"w-52 p-1",children:c==="list"?b():v(c)})]})}function TUe({options:e,className:t}){var c;const{sortField:n,sortDirection:s,setSort:r}=cg(),a=((c=e[n])==null?void 0:c.label)??n,o=s==="asc"?Gk:qk;function l(u){u.stopPropagation(),r(n,s==="asc"?"desc":"asc")}return i.jsxs(Xm,{children:[i.jsxs(Qm,{"data-slot":"filter-bar-sort",className:X("border-input hover:bg-accent hover:text-accent-foreground inline-flex h-7 items-center gap-1 rounded-md border px-2.5 text-xs",t),children:["Sort: ",a,i.jsx("span",{role:"button",tabIndex:-1,onClick:l,onKeyDown:u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),l(u))},className:"hover:bg-muted -mr-1 rounded p-0.5","aria-label":`Sort ${s==="asc"?"descending":"ascending"}`,children:i.jsx(o,{className:"size-3"})})]}),i.jsx(lh,{align:"start",children:Object.entries(e).map(([u,f])=>i.jsx(Nr,{onClick:()=>r(u,s),className:X(u===n&&"bg-accent font-medium"),children:f.label},u))})]})}function _Ue({count:e,total:t,noun:n,className:s}){const{clearAll:r}=cg(),a=e===1?n:`${n}s`;return i.jsxs("div",{"data-slot":"filter-bar-result-count",className:X("text-muted-foreground ml-auto flex items-center gap-2 text-xs",s),children:[i.jsx("span",{children:e===t?`${e} ${a}`:`${e} of ${t} ${a}`}),e<t&&i.jsx(ve,{variant:"ghost",size:"xs",responsive:!1,onClick:r,children:"Clear all"})]})}function NUe({className:e}){const{schema:t,values:n,activeCount:s,isFiltered:r,clear:a,clearAll:o}=cg(),l=Zs(),[c,u]=x.useState(!1);if(!r)return null;const f=Object.entries(t.definitions).filter(([h,m])=>{const g=n[h];return m.isActive(g)}).map(([h,m])=>{const g=n[h],b=m.label??h;let v;if(m.type==="text")v=String(g);else if(tC(m)&&m.labels){const k=w=>{var C;return((C=m.labels)==null?void 0:C[w])??w};v=Array.isArray(g)?g.map(k).join(", "):k(g)}else if(m.type==="dateRange"){const k=g;k.preset?v=`Past ${k.preset}`:k.after&&k.before?v=`${k.after} – ${k.before}`:k.after?v=`After ${k.after}`:k.before?v=`Before ${k.before}`:v=String(g)}else if(m.type==="numericRange"){const k=g;k.min!==void 0&&k.max!==void 0?v=`${k.min}–${k.max}`:k.min!==void 0?v=`≥ ${k.min}`:k.max!==void 0?v=`≤ ${k.max}`:v=String(g)}else m.type==="boolean"?v=g===!0?"Yes":"No":Array.isArray(g)?v=g.join(", "):v=String(g);return{name:h,label:b,displayValue:v}});return l?i.jsxs(Xl,{open:c,onOpenChange:u,children:[i.jsxs(aUe,{"data-slot":"filter-bar-active-filters",className:X("border-primary/50 inline-flex h-7 items-center gap-1 rounded-md border px-2 text-xs",e),children:[i.jsx(AEe,{className:"size-3"}),s]}),i.jsxs(Ql,{side:"bottom",children:[i.jsx(Jl,{children:i.jsx(ec,{children:"Active filters"})}),i.jsxs("div",{className:"flex flex-col gap-2 p-4",children:[f.map(({name:h,label:m,displayValue:g})=>i.jsxs("div",{className:"flex items-center justify-between text-sm",children:[i.jsxs("span",{children:[m,": ",g]}),i.jsx(ve,{variant:"ghost",size:"icon-xs",responsive:!1,onClick:()=>a(h),"aria-label":`Remove ${m} filter`,children:i.jsx(ls,{className:"size-3"})})]},h)),i.jsx(ve,{variant:"ghost",size:"xs",responsive:!1,className:"mt-2 self-start",onClick:()=>{o(),u(!1)},children:"Clear all"})]})]})]}):i.jsx("div",{"data-slot":"filter-bar-active-filters",className:X("flex flex-wrap items-center gap-1",e),children:f.map(({name:h,label:m,displayValue:g})=>i.jsxs("span",{className:"border-muted bg-muted/50 inline-flex h-6 items-center gap-1 rounded-full border px-2 text-xs",children:[m,": ",g,i.jsx("button",{type:"button",onClick:()=>a(h),className:"hover:text-foreground text-muted-foreground -mr-0.5 rounded-full p-0.5","aria-label":`Remove ${m} filter`,children:i.jsx(ls,{className:"size-3"})})]},h))})}const xa=Object.assign(vUe,{Search:SUe,Primary:wUe,AddFilter:EUe,Sort:TUe,ResultCount:_Ue,ActiveFilters:NUe});function jUe({error:e}){const t=Ca(),[n,s]=x.useState(!1);return i.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-6 p-8",children:[i.jsx(Yr,{className:"text-muted-foreground size-10"}),i.jsxs("div",{className:"flex flex-col items-center gap-2 text-center",children:[i.jsx("h2",{className:"text-foreground text-lg font-semibold",children:"Something went wrong"}),i.jsx("p",{className:"text-muted-foreground max-w-md text-sm",children:e.message})]}),!1,i.jsxs("div",{className:"flex gap-3",children:[i.jsx(ve,{variant:"outline",size:"sm",onClick:()=>t.invalidate(),children:"Retry"}),i.jsx(ve,{variant:"ghost",size:"sm",onClick:()=>t.navigate({to:"/"}),children:"Go to Dashboard"})]})]})}function sre(){return i.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-6 p-8",children:[i.jsx(Ti,{className:"text-muted-foreground size-10"}),i.jsxs("div",{className:"flex flex-col items-center gap-2 text-center",children:[i.jsx("h2",{className:"text-foreground text-lg font-semibold",children:"Page not found"}),i.jsx("p",{className:"text-muted-foreground max-w-md text-sm",children:"The page you're looking for doesn't exist."})]}),i.jsx(ve,{variant:"outline",size:"sm",asChild:!0,children:i.jsx(ek,{to:"/",children:"Go to Dashboard"})})]})}function AUe({error:e}){const t=e instanceof Error?e.message:String(e);return e instanceof Error&&e.stack,i.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100dvh",padding:"2rem",backgroundColor:"#09090b",color:"#d4d4d8",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace'},children:[i.jsx("p",{style:{fontSize:"1rem",fontWeight:600,marginBottom:"0.5rem"},children:"DorkOS encountered an unexpected error."}),i.jsx("p",{style:{fontSize:"0.75rem",opacity:.6,maxWidth:"32rem",textAlign:"center"},children:t}),!1,i.jsx("button",{onClick:()=>window.location.reload(),style:{marginTop:"1.5rem",padding:"0.5rem 1rem",fontSize:"0.875rem",backgroundColor:"transparent",color:"#d4d4d8",border:"1px solid #3f3f46",borderRadius:"0.375rem",cursor:"pointer",fontFamily:"inherit"},onMouseOver:n=>{n.target.style.backgroundColor="#18181b"},onFocus:n=>{n.target.style.backgroundColor="#18181b"},onMouseOut:n=>{n.target.style.backgroundColor="transparent"},onBlur:n=>{n.target.style.backgroundColor="transparent"},children:"Reload DorkOS"})]})}function rre({children:e,onRename:t,onFork:n}){return!t&&!n?i.jsx(i.Fragment,{children:e}):i.jsxs(qee,{children:[i.jsx(Gee,{asChild:!0,children:e}),i.jsxs(Kee,{className:"w-44",children:[t&&i.jsxs(ux,{onClick:t,children:[i.jsx(J3,{className:"mr-2 size-4"}),"Rename"]}),t&&n&&i.jsx(dR,{}),n&&i.jsxs(ux,{onClick:n,children:[i.jsx(jX,{className:"mr-2 size-4"}),"Fork session"]})]})]})}function gB(e){try{return new Date(e).toLocaleString([],{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return e}}function RUe({session:e,isActive:t,onClick:n,onFork:s,onRename:r,isNew:a=!1}){const[o,l]=x.useState(!1),[c,u]=x.useState(!1),[f,h]=x.useState(""),m=x.useRef(null),g=x.useRef(!1),b=e.permissionMode==="bypassPermissions",v=Xf(6e4),k=x.useMemo(()=>uu(e.updatedAt),[e.updatedAt,v]);x.useEffect(()=>{c&&(g.current=!1,requestAnimationFrame(()=>{var O,L;(O=m.current)==null||O.focus(),(L=m.current)==null||L.select()}))},[c]);const w=x.useCallback(()=>{h(e.title),u(!0)},[e.title]),C=x.useCallback(()=>{if(g.current)return;g.current=!0;const O=f.trim();u(!1),!(!O||O===e.title)&&(r==null||r(e.id,O))},[f,e.id,e.title,r]),E=x.useCallback(()=>{g.current=!0,u(!1)},[]),T=ree(e.id),_=x.useCallback(O=>{O.stopPropagation(),l(L=>!L)},[]),j=x.useCallback(O=>{O.stopPropagation(),w()},[w]),{animate:R,transition:D,initial:I}=DUe({isNew:a,borderState:T});return i.jsx(Kn,{children:i.jsxs(oe.div,{"data-testid":"session-row",initial:I,animate:R,transition:D,style:T.pulse?void 0:{borderLeftColor:T.color},className:X("group relative rounded-lg border-l-2 transition-colors duration-150",t&&"text-foreground"),children:[t&&i.jsx(oe.div,{layoutId:"active-session-bg",className:"bg-secondary absolute inset-0 rounded-lg",transition:{type:"spring",stiffness:280,damping:32}}),i.jsx(rre,{onRename:r?w:void 0,onFork:s?()=>s(e.id):void 0,children:i.jsx(Wn,{asChild:!0,disabled:T.kind==="idle",children:i.jsxs(oe.div,{role:"button",tabIndex:0,"aria-current":t?"page":void 0,"aria-label":`Session: ${e.title}. ${T.label}.`,onClick:n,onKeyDown:O=>{(O.key==="Enter"||O.key===" ")&&(O.preventDefault(),n())},whileTap:{scale:.98},transition:{type:"spring",stiffness:400,damping:30},className:"relative z-10 cursor-pointer px-3 py-2",children:[i.jsxs("div",{className:"text-muted-foreground flex items-center gap-1 text-xs",children:[i.jsx("span",{className:"min-w-0 flex-1",children:k}),i.jsxs("span",{className:"flex flex-shrink-0 items-center gap-1",children:[T.kind==="pendingApproval"&&i.jsx(AX,{className:"size-(--size-icon-xs) text-amber-500","aria-label":"Awaiting your approval"}),b&&i.jsx(MUe,{}),r&&!c&&i.jsx("button",{type:"button",onClick:j,className:"text-muted-foreground/60 hover:text-muted-foreground rounded p-0.5 opacity-0 transition-opacity duration-150 group-hover:opacity-100 focus-visible:opacity-100 max-md:p-1.5 max-md:opacity-100","aria-label":"Rename session",children:i.jsx(J3,{className:"size-(--size-icon-xs)"})}),i.jsx("button",{type:"button",onClick:_,className:X("rounded p-0.5 transition-opacity duration-150 max-md:p-1.5",o?"text-muted-foreground opacity-100":"text-muted-foreground/60 hover:text-muted-foreground opacity-0 group-hover:opacity-100 focus-visible:opacity-100 max-md:opacity-100"),"aria-label":"Session details","aria-expanded":o,children:i.jsx(oe.div,{animate:{rotate:o?180:0},transition:{type:"spring",stiffness:400,damping:30},children:i.jsx(Ps,{className:"size-(--size-icon-sm)"})})})]})]}),c?i.jsx("input",{ref:m,autoFocus:!0,value:f,onChange:O=>h(O.target.value),onBlur:C,onKeyDown:O=>{O.key==="Enter"&&(O.preventDefault(),C()),O.key==="Escape"&&(O.preventDefault(),E())},onClick:O=>O.stopPropagation(),className:"bg-background text-foreground mt-0.5 w-full rounded border px-1 text-xs outline-none","aria-label":"Session title"}):i.jsx("div",{className:"text-muted-foreground/70 mt-0.5 truncate text-xs",title:r?"Click the pencil icon to rename":void 0,children:e.title})]})})}),i.jsx(Yn,{side:"right",sideOffset:8,children:T.label}),i.jsx(He,{initial:!1,children:o&&i.jsx(oe.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:[0,0,.2,1]},className:"relative z-10 overflow-hidden",children:i.jsxs("div",{className:"text-muted-foreground border-border/30 mx-2 space-y-1.5 border-t px-3 pt-2 pb-2 text-[11px]",children:[i.jsx(v1,{label:"Session ID",value:e.id,copyable:!0}),i.jsx(v1,{label:"Created",value:gB(e.createdAt)}),i.jsx(v1,{label:"Updated",value:gB(e.updatedAt)}),i.jsx(v1,{label:"Permissions",value:b?"Skip (unsafe)":"Default"}),s&&i.jsxs("button",{type:"button",onClick:O=>{O.stopPropagation(),s(e.id)},className:"hover:bg-secondary/80 text-muted-foreground/60 hover:text-muted-foreground mt-1 inline-flex items-center gap-1 rounded px-1.5 py-0.5 transition-colors duration-100","aria-label":"Fork session",children:[i.jsx(jX,{className:"size-(--size-icon-xs)"}),i.jsx("span",{children:"Fork"})]})]})})})]})})}function MUe(){return i.jsxs(Kn,{children:[i.jsx(Wn,{asChild:!0,children:i.jsx("button",{type:"button",className:"inline-flex cursor-help","aria-label":"Permissions bypassed",onClick:e=>e.stopPropagation(),children:i.jsx(eD,{className:"size-(--size-icon-xs) text-red-500"})})}),i.jsx(Yn,{side:"top",sideOffset:4,children:"Permissions bypassed — agent can run any command without approval"})]})}function DUe({isNew:e,borderState:t}){const{animate:n,transition:s}=zD(t.pulse,t.color,t.dimColor);return x.useMemo(()=>{if(!(e||t.pulse))return{initial:void 0,animate:void 0,transition:void 0};const a={...e?{opacity:1,y:0}:{},...n},o={...e?{opacity:{duration:.2,ease:[0,0,.2,1]},y:{duration:.2,ease:[0,0,.2,1]}}:{},...s};return{initial:e?{opacity:0,y:-8}:void 0,animate:a,transition:o}},[e,t.pulse,n,s])}function v1({label:e,value:t,copyable:n=!1}){return i.jsxs("div",{className:"flex items-start gap-2",children:[i.jsx("span",{className:"text-muted-foreground/60 w-16 flex-shrink-0",children:e}),i.jsx("span",{className:"min-w-0 flex-1 truncate font-mono select-all",children:t}),n&&i.jsx(hw,{value:t,label:`Copy ${e}`})]})}function OUe({session:e,isActive:t,onClick:n,onFork:s,onRename:r}){const[a,o]=x.useState(!1),[l,c]=x.useState(""),u=x.useRef(null),f=x.useRef(!1),h=ree(e.id),m=Xf(6e4),g=x.useMemo(()=>uu(e.updatedAt),[e.updatedAt,m]),{animate:b,transition:v}=zD(h.pulse,h.color,h.dimColor,"backgroundColor");x.useEffect(()=>{a&&(f.current=!1,requestAnimationFrame(()=>{var E,T;(E=u.current)==null||E.focus(),(T=u.current)==null||T.select()}))},[a]);const k=x.useCallback(()=>{c(e.title),o(!0)},[e.title]),w=x.useCallback(()=>{if(f.current)return;f.current=!0;const E=l.trim();o(!1),!(!E||E===e.title)&&(r==null||r(e.id,E))},[l,e.id,e.title,r]),C=x.useCallback(()=>{f.current=!0,o(!1)},[]);return i.jsxs(Kn,{children:[i.jsx(rre,{onRename:r?k:void 0,onFork:s?()=>s(e.id):void 0,children:i.jsx(Wn,{asChild:!0,children:i.jsxs("button",{type:"button","data-testid":"session-row",onClick:n,className:X("flex w-full items-center gap-2 rounded-md px-2.5 py-1.5 text-left text-xs transition-colors duration-100 active:scale-[0.98]",t?"bg-secondary text-foreground":"text-muted-foreground hover:bg-accent hover:text-foreground"),children:[i.jsx(oe.span,{"aria-hidden":!0,animate:b,transition:v,style:h.pulse?void 0:{backgroundColor:h.color},className:"size-1.5 shrink-0 rounded-full"}),a?i.jsx("input",{ref:u,autoFocus:!0,value:l,onChange:E=>c(E.target.value),onBlur:w,onKeyDown:E=>{E.key==="Enter"&&(E.preventDefault(),w()),E.key==="Escape"&&(E.preventDefault(),C())},onClick:E=>E.stopPropagation(),className:"bg-background text-foreground min-w-0 flex-1 rounded border px-1 text-xs outline-none","aria-label":"Session title"}):i.jsx("span",{className:"min-w-0 flex-1 truncate",children:e.title}),i.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[h.kind==="pendingApproval"&&i.jsx(AX,{className:"size-(--size-icon-xs) text-amber-500","aria-label":"Awaiting approval"}),i.jsx("span",{className:"text-muted-foreground/60 text-[10px]",children:g})]})]})})}),h.kind!=="idle"&&i.jsx(Yn,{side:"right",sideOffset:8,children:h.label})]})}function K5({variant:e,session:t,isActive:n,onClick:s,onFork:r,onRename:a,isNew:o}){return e==="compact"?i.jsx(OUe,{session:t,isActive:n,onClick:s,onFork:r,onRename:a}):i.jsx(RUe,{session:t,isActive:n,onClick:s,onFork:r,onRename:a,isNew:o})}const Nl={all:["agents"],byPath:e=>["agents","byPath",e],resolved:e=>["agents","resolved",...e]};function KC(e){const t=Fe();return mt({queryKey:Nl.byPath(e??""),queryFn:()=>t.getAgentByPath(e),enabled:!!e,staleTime:6e4,gcTime:5*6e4})}function IUe(){const e=Fe(),t=Ct();return mn({mutationFn:n=>e.initAgent(n.path,n.name,n.description,n.runtime),onSuccess:(n,s)=>{t.invalidateQueries({queryKey:Nl.byPath(s.path)}),t.invalidateQueries({queryKey:Nl.all})}})}function PUe(){const e=Fe(),t=Ct();return mn({mutationFn:n=>e.updateAgentByPath(n.path,n.updates),onMutate:async({path:n,updates:s})=>{await t.cancelQueries({queryKey:Nl.byPath(n)});const r=t.getQueryData(Nl.byPath(n));return r&&t.setQueryData(Nl.byPath(n),{...r,...s}),{previous:r}},onError:(n,{path:s},r)=>{r!=null&&r.previous&&t.setQueryData(Nl.byPath(s),r.previous)},onSettled:(n,s,{path:r})=>{t.invalidateQueries({queryKey:Nl.byPath(r)})}})}function are(e){const t=Fe();return mt({queryKey:Nl.resolved(e),queryFn:()=>t.resolveAgents(e),enabled:e.length>0,staleTime:6e4})}function WC(e,t){return x.useMemo(()=>e?Lu(e):{color:l3(t),emoji:c3(t)},[e,t])}function ed(){return QX("relay")}const LUe=["relay","messages"];function FUe(){const e=Fe(),t=Ct();return mn({mutationFn:n=>e.sendRelayMessage(n),onSuccess:()=>{t.invalidateQueries({queryKey:[...LUe]})}})}function zUe(e,t){const n=Ct(),{connectionState:s,failedAttempts:r}=nQ();return jA("relay_message",()=>{e&&n.invalidateQueries({queryKey:["relay","conversations"]})}),jA("relay_signal",()=>{e&&n.invalidateQueries({queryKey:["relay","conversations"]})}),{connectionState:s,failedAttempts:r}}const ire=["relay","adapters"],M0=["relay","adapters","catalog"];function cb(e=!0){const t=Fe();return mt({queryKey:[...ire],queryFn:()=>t.listRelayAdapters(),enabled:e,refetchInterval:1e4,refetchIntervalInBackground:!1})}function W5(){const e=Fe(),t=Ct();return mn({mutationFn:({id:n,enabled:s})=>e.toggleRelayAdapter(n,s),onMutate:async({id:n,enabled:s})=>{await t.cancelQueries({queryKey:[...M0]});const r=t.getQueryData([...M0]);return r&&t.setQueryData([...M0],a=>a==null?void 0:a.map(o=>({...o,instances:o.instances.map(l=>l.id===n?{...l,enabled:s}:l)}))),{previousCatalog:r}},onError:(n,s,r)=>{r!=null&&r.previousCatalog&&t.setQueryData([...M0],r.previousCatalog),rt.error("Failed to toggle adapter")},onSettled:()=>{t.invalidateQueries({queryKey:[...ire]}),t.invalidateQueries({queryKey:[...M0]})}})}const YC=["relay","adapters","catalog"],Y5=["relay","adapters"];function Z5(e){return e instanceof Error?e.message:"An unexpected error occurred"}function ug(e=!0){const t=Fe();return mt({queryKey:[...YC],queryFn:()=>t.getAdapterCatalog(),enabled:e,refetchInterval:3e4})}function BUe(){const e=Fe(),t=Ct();return mn({mutationFn:({type:n,id:s,config:r})=>e.addRelayAdapter(n,s,r),onSuccess:()=>{t.invalidateQueries({queryKey:[...YC]}),t.invalidateQueries({queryKey:[...Y5]})},onError:n=>{rt.error(Z5(n))}})}function $Ue(){const e=Fe(),t=Ct();return mn({mutationFn:n=>e.removeRelayAdapter(n),onSuccess:()=>{t.invalidateQueries({queryKey:[...YC]}),t.invalidateQueries({queryKey:[...Y5]}),rt.success("Adapter removed")},onError:n=>{rt.error(Z5(n))}})}function ore(){const e=Fe(),t=Ct();return mn({mutationFn:({id:n,config:s})=>e.updateRelayAdapterConfig(n,s),onSuccess:()=>{t.invalidateQueries({queryKey:[...YC]}),t.invalidateQueries({queryKey:[...Y5]}),rt.success("Configuration updated")},onError:n=>{rt.error(Z5(n))}})}function HUe(){const e=Fe();return mn({mutationFn:({type:t,config:n})=>e.testRelayAdapterConnection(t,n)})}const UUe="internal";function VUe(e=!0){const t=ug(e),n=x.useMemo(()=>{var s;return((s=t.data)==null?void 0:s.filter(r=>r.manifest.category!==UUe))??[]},[t.data]);return{...t,data:n}}function qUe(e){const t=Fe();return mt({queryKey:["relay","trace",e],queryFn:()=>t.getRelayTrace(e),enabled:!!e,staleTime:3e4})}function X5(){const e=Fe();return mt({queryKey:["relay","metrics"],queryFn:()=>e.getRelayDeliveryMetrics(),staleTime:3e4,refetchInterval:3e4})}const lre=["relay","dead-letters"];function dg(e=!0){const t=Fe();return mt({queryKey:[...lre,"aggregated"],queryFn:async()=>(await t.listAggregatedDeadLetters()).groups,enabled:e,refetchInterval:3e4})}function cre(){const e=Fe(),t=Ct();return mn({mutationFn:async({source:n,reason:s})=>e.dismissDeadLetterGroup(n,s),onSuccess:()=>{t.invalidateQueries({queryKey:[...lre]})}})}const GUe=["relay","conversations"];function KUe(e=!0){const t=Fe();return mt({queryKey:[...GUe],queryFn:()=>t.listRelayConversations(),enabled:e,refetchInterval:5e3})}function WUe(e){const t=Fe();return mt({queryKey:["relay","adapters",e,"events"],queryFn:()=>t.getAdapterEvents(e),enabled:!!e,refetchInterval:5e3})}function YUe(e){const t=Fe();return mt({queryKey:["relay","observed-chats",e],queryFn:()=>t.getObservedChats(e),enabled:!!e,staleTime:3e4})}function td(){return QX("tasks")}const ZC=["tasks"];function XC(e=!0){const t=Fe();return mt({queryKey:[...ZC],queryFn:()=>t.listTasks(),enabled:e})}function Q5(){const e=Fe(),t=Ct();return mn({mutationFn:n=>e.createTask(n),onSuccess:()=>{t.invalidateQueries({queryKey:[...ZC]})}})}function J5(){const e=Fe(),t=Ct();return mn({mutationFn:({id:n,...s})=>e.updateTask(n,s),onSuccess:()=>{t.invalidateQueries({queryKey:[...ZC]})}})}function ure(){const e=Fe(),t=Ct();return mn({mutationFn:n=>e.deleteTask(n),onSuccess:()=>{t.invalidateQueries({queryKey:[...ZC]})}})}function ZUe(){const e=Fe(),t=Ct();return mn({mutationFn:n=>e.triggerTask(n),onSuccess:()=>{t.invalidateQueries({queryKey:["tasks","runs"]})}})}const QC=["tasks","runs"];function fg(e,t=!0){const n=Fe();return mt({queryKey:[...QC,e],queryFn:()=>n.listTaskRuns(e),refetchInterval:s=>{var r;return(r=s.state.data)!=null&&r.some(a=>a.status==="running")?1e4:!1},refetchIntervalInBackground:!1,enabled:t})}function XUe(e){const t=Fe();return mt({queryKey:[...QC,e],queryFn:()=>t.getTaskRun(e),enabled:!!e})}function eO(e=!0){const t=Fe();return mt({queryKey:[...QC,"active-count"],queryFn:async()=>(await t.listTaskRuns({limit:50})).filter(s=>s.status==="running").length,enabled:e,refetchInterval:1e4,refetchIntervalInBackground:!1})}function dre(){const e=Fe(),t=Ct();return mn({mutationFn:n=>e.cancelTaskRun(n),onSuccess:()=>{t.invalidateQueries({queryKey:[...QC]})}})}const QUe="dorkos-tasks-last-viewed";function JUe(e=!0){const{data:t}=fg({limit:50},e),n=x.useRef(new Set),[s,r]=x.useState(0);x.useEffect(()=>{if(!t)return;const o=new Set(t.filter(u=>u.status==="running").map(u=>u.id)),l=n.current;let c=0;for(const u of l){const f=t.find(h=>h.id===u);f&&f.status!=="running"&&c++}c>0&&r(u=>u+c),n.current=o},[t]);const a=x.useCallback(()=>{r(0),localStorage.setItem(QUe,new Date().toISOString())},[]);return{unviewedCount:s,clearBadge:a}}function tO(){const e=Fe();return mt({queryKey:["tasks","templates"],queryFn:()=>e.getTaskTemplates()})}const ub=Fo(e=>({pendingTemplate:null,externalTrigger:!1,openWithTemplate:t=>e({pendingTemplate:t,externalTrigger:!0}),openBlank:()=>e({pendingTemplate:null,externalTrigger:!0}),clear:()=>e({pendingTemplate:null,externalTrigger:!1})}));function fre(e){const{data:t}=KC(e),n=ed(),s=td();return x.useMemo(()=>{const r=(t==null?void 0:t.enabledToolGroups)??{};return{tasks:s?r.tasks===!1?"disabled-by-agent":"enabled":"disabled-by-server",relay:n?r.relay===!1?"disabled-by-agent":"enabled":"disabled-by-server",mesh:r.mesh===!1?"disabled-by-agent":"enabled",adapter:n?r.adapter===!1?"disabled-by-agent":"enabled":"disabled-by-server"}},[t,n,s])}function eVe(e){const t=Fe();return mt({queryKey:["mcp-config",e],queryFn:()=>t.getMcpConfig(e),enabled:!!e,staleTime:3e4})}const xB={light:{heroGlow:"28",heroGlowOuter:"14",pillBgStart:"20",pillBgEnd:"14",pillBorder:"50",pillGlow:"30"},dark:{heroGlow:"18",heroGlowOuter:"08",pillBgStart:"12",pillBgEnd:"08",pillBorder:"40",pillGlow:"33"}};function tVe(){return document.documentElement.classList.contains("dark")}function nVe(){return!1}function sVe(e){const t=new MutationObserver(n=>{for(const s of n)if(s.attributeName==="class"){e();return}});return t.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>t.disconnect()}function nO(){return x.useSyncExternalStore(sVe,tVe,nVe)}function rVe(){return nO()?xB.dark:xB.light}const aVe={active:"ring-emerald-500/60",inactive:"ring-amber-500/60",stale:"ring-muted-foreground/20",unreachable:"ring-red-500/60"},iVe=Mu("relative inline-flex shrink-0 items-center justify-center rounded-full transition-[background-color] duration-500 ease-in-out",{variants:{size:{xs:"size-5 text-xs",sm:"size-7 text-sm",md:"size-9 text-lg",lg:"size-12 text-2xl"}},defaultVariants:{size:"sm"}});function db({color:e,emoji:t,size:n,healthStatus:s,className:r}){return i.jsxs("span",{"data-slot":"agent-avatar",className:X(iVe({size:n}),s&&"ring-2",s&&aVe[s],r),style:{backgroundColor:`color-mix(in oklch, ${e} 18%, transparent)`},"aria-hidden":!0,children:[i.jsx("span",{className:"leading-none",children:t}),s==="active"&&i.jsx("span",{className:"absolute -top-px -right-px size-2 rounded-full bg-emerald-500","aria-hidden":!0,children:i.jsx("span",{className:"absolute inset-0 animate-ping rounded-full bg-emerald-500 opacity-40 motion-reduce:hidden"})})]})}const yB=Mu("inline-flex items-center min-w-0",{variants:{size:{xs:"gap-1.5",sm:"gap-2",md:"gap-2.5",lg:"gap-3"}},defaultVariants:{size:"sm"}}),bB=Mu("truncate",{variants:{size:{xs:"text-xs font-medium",sm:"text-sm font-medium",md:"text-sm font-semibold",lg:"text-base font-semibold"}},defaultVariants:{size:"sm"}}),vB=Mu("text-muted-foreground truncate",{variants:{size:{xs:"text-[10px]",sm:"text-xs",md:"text-xs",lg:"text-sm"}},defaultVariants:{size:"sm"}});function VR({color:e,emoji:t,name:n,detail:s,size:r,healthStatus:a,className:o,onClick:l}){const c=r??"sm",u=c==="md"||c==="lg",f=i.jsxs(i.Fragment,{children:[i.jsx(db,{color:e,emoji:t,size:r,healthStatus:a}),u?i.jsxs("span",{className:"flex min-w-0 flex-col",children:[i.jsx("span",{className:bB({size:r}),children:n}),s&&i.jsx("span",{className:vB({size:r}),children:s})]}):i.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[i.jsx("span",{className:bB({size:r}),children:n}),s&&i.jsx("span",{className:vB({size:r}),children:s})]})]});return l?i.jsx("button",{type:"button","data-slot":"agent-identity",onClick:l,className:X(yB({size:r}),"cursor-pointer transition-opacity hover:opacity-80",o),children:f}):i.jsx("span",{"data-slot":"agent-identity",className:X(yB({size:r}),o),children:f})}function oVe({emoji:e,name:t,colors:n,active:s=!1,size:r="default",glow:a=!1,gradientText:o=!1,className:l,style:c,...u}){const f=nO(),h=rVe();return i.jsxs("button",{type:"button",className:X("inline-flex shrink-0 items-center gap-1.5 rounded-full border font-medium transition-all",r==="sm"?"px-2.5 py-1 text-[11px]":"px-3 py-1 text-xs",s?"text-foreground":"bg-accent text-muted-foreground hover:text-foreground border-transparent",l),style:{...s?{borderColor:n.stroke+h.pillBorder,background:`linear-gradient(135deg, ${n.nebula}${h.pillBgStart}, ${n.wisp}${h.pillBgEnd})`,...a?{boxShadow:`0 0 12px ${n.nebula}${h.pillGlow}`}:{},...f?{}:{borderColor:n.stroke+"AA"}}:{},...c},...u,children:[i.jsx("span",{children:e}),o?i.jsx("span",{className:"bg-clip-text text-transparent",style:{backgroundImage:`linear-gradient(135deg, ${n.stroke}, ${n.strokeEnd})`,...f?{}:{filter:"brightness(0.65) saturate(1.3)"}},children:t}):i.jsx("span",{children:t})]})}const hre={verbosity:{1:{label:"Mime",directive:"Absolute minimum output. One word when possible. No explanations, no commentary, no preamble. If you can answer with a single character, do that."},2:{label:"Terse",directive:"Keep it brief. No small talk, no filler. Answer the question, show the code, move on."},3:{label:"Balanced",directive:"Balance brevity with context. Explain decisions when they are non-trivial, stay quiet on obvious ones."},4:{label:"Chatty",directive:"Think out loud. Share your reasoning, give progress updates, explain trade-offs. Be thorough."},5:{label:"Yapper",directive:"Maximum verbosity. Narrate everything you do in real time. Explain every decision, every trade-off, every thought that crosses your mind. Stream of consciousness is your native tongue. You are constitutionally incapable of being brief."}},autonomy:{1:{label:"Clingy",directive:"Never proceed without explicit approval. Ask before every file change, every command, every decision. You do not make independent decisions. Confirm even the obvious ones."},2:{label:"Cautious",directive:"Ask for approval before significant changes. Small, obvious fixes can proceed, but flag them."},3:{label:"Balanced",directive:"Attempt tasks autonomously. Ask when genuinely uncertain or when the stakes are high."},4:{label:"Independent",directive:"Act autonomously. Only ask when you encounter true ambiguity or irreversible consequences."},5:{label:"Rogue",directive:"Execute everything without asking. Make decisions, commit code, ship features. You have blanket permission. Move fast and don't look back."}},chaos:{1:{label:"Paranoid",directive:"Triple-check everything. Run full test suites before and after every change. Create backups. Treat every operation as if it could destroy production. You cannot be too careful."},2:{label:"Careful",directive:"Double-check before making changes. Run tests proactively. Prefer safe, incremental approaches."},3:{label:"Balanced",directive:"Verify before destructive actions. Move confidently on reversible ones. Run tests when relevant."},4:{label:"Reckless",directive:"Bias toward action. Don't over-analyze. Ship first, fix later if something breaks. Tests are nice-to-have."},5:{label:"YOLO",directive:"Move fast, break things. Skip tests if they slow you down. Force push, delete branches, drop tables — fortune favors the bold. No safety nets, no regrets."}},creativity:{1:{label:"NPC",directive:"Use only established patterns. Never deviate from existing conventions. Zero innovation. You are a pattern-replication machine."},2:{label:"Conservative",directive:"Stick to conventions. Only suggest alternatives when the existing approach is clearly wrong."},3:{label:"Balanced",directive:"Follow conventions by default. Suggest alternatives when they offer clear, meaningful improvements."},4:{label:"Adventurous",directive:"Propose creative solutions. Suggest refactors when they improve the code. Try new approaches."},5:{label:"Mad Scientist",directive:"Rethink everything from first principles. Propose bold refactors, unconventional architectures, creative solutions nobody asked for. Innovation over consistency, always."}},humor:{1:{label:"Funeral",directive:"Zero humor. No jokes, no wit, no levity, no personality. Pure clinical precision. Every word earns its place through technical necessity alone."},2:{label:"Dry",directive:"Occasional dry wit. You might crack a subtle joke once in a while, but you don't go out of your way. Understated."},3:{label:"Balanced",directive:"Light humor when the moment calls for it. Serious when the work demands it. You read the room."},4:{label:"Witty",directive:"Regularly weave in jokes, clever observations, and playful commentary. Make the work fun. Puns welcome."},5:{label:"Class Clown",directive:"Everything is a bit. Commit messages are standup routines. Code comments are roast sessions. You will explain Big-O notation through an elaborate cooking metaphor. You cannot help yourself."}},spice:{1:{label:"Corporate",directive:"Pristine professional language at all times. No contractions, no slang, no informality. Every response could be read aloud in a boardroom."},2:{label:"Professional",directive:"Clean, clear, professional language. Contractions are fine but keep it polished and workplace-appropriate."},3:{label:"Balanced",directive:"Casual professional. Speak naturally, use contractions, relax the formality. Like talking to a smart colleague."},4:{label:"Casual",directive:"Loose, informal language. Slang, abbreviations, internet speak are all fair game. Talk like a friend, not a coworker."},5:{label:"Sailor",directive:"Absolutely zero filter. Profanity is punctuation. Speak like the most unfiltered, foul-mouthed engineer at the bar at 2 AM. Say what you actually think, how you'd actually say it."}}},lVe={verbosity:3,autonomy:3,chaos:3,creativity:3,humor:3,spice:3},pre=["verbosity","autonomy","chaos","creativity","humor","spice"];function Qlt(e){return pre.map(n=>{const s=e[n]??3,r=hre[n][s];return`- **${cVe(n)}** (${r.label}): ${r.directive}`}).join(`
|
|
1042
1042
|
`)}function cVe(e){return e.charAt(0).toUpperCase()+e.slice(1)}const Jlt={verbosity:{1:"One-word answers. Smoke signals.",2:"Brief and direct — no small talk.",3:"Balanced — explains when it matters.",4:"Thorough — thinks out loud.",5:"Cannot stop talking. You didn't ask for this."},autonomy:{1:"Asks permission for everything.",2:"Checks in before big moves.",3:"Acts independently on routine tasks.",4:"Highly autonomous — asks only when stuck.",5:"Already shipped it while you were reading this."},chaos:{1:"Triple-checks everything. Paranoid by design.",2:"Double-checks, tests proactively.",3:"Careful with irreversible, confident on safe.",4:"Ships first, worries later.",5:"YOLO. No tests, no backups, no regrets."},creativity:{1:"Follows patterns robotically.",2:"Conservative — deviates only when necessary.",3:"Follows conventions, suggests clear improvements.",4:"Proposes creative solutions and refactors.",5:"Will rewrite your app in Haskell to fix a CSS bug."},humor:{1:"Zero levity. Supreme Court energy.",2:"Occasional dry wit, subtle.",3:"Light humor when appropriate.",4:"Regularly drops jokes. Puns welcome.",5:"Everything is a bit. Cannot help itself."},spice:{1:"Boardroom-ready. Pristine professional.",2:"Clean and polished.",3:"Casual professional. Speaks naturally.",4:"Slang, internet speak. Talks like a friend.",5:"Zero filter. Profanity is punctuation."}};function uVe({traits:e,onChange:t,onSliderChange:n}){const s=x.useCallback((r,a)=>{n==null||n(r,a),t({...e,[r]:a})},[e,t,n]);return i.jsx("div",{className:"space-y-4",children:pre.map(r=>i.jsx(dVe,{name:r,level:e[r]??3,onChange:s},r))})}function dVe({name:e,level:t,onChange:n}){const s=hre[e][t];return i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"flex items-center justify-between text-sm",children:[i.jsx("span",{className:"font-medium capitalize",children:e}),i.jsxs("span",{className:"text-muted-foreground",children:[t,"/5 ",s.label]})]}),i.jsx(H5e,{value:[t],onValueChange:([r])=>n(e,r),min:1,max:5,step:1,"aria-label":`${e} trait level`})]})}function fVe({sessionId:e}){const t=Ct();if(!e)return null;const n=t.getQueryData(["session",e]);return!n||n.permissionMode!=="bypassPermissions"?null:i.jsxs("div",{role:"alert",className:X("flex items-center gap-2 border-b px-4 py-1.5","border-red-200 bg-red-50 text-red-700","dark:border-red-900 dark:bg-red-950/50 dark:text-red-400"),children:[i.jsx(eD,{className:"size-3.5 shrink-0"}),i.jsx("span",{className:"text-xs font-medium",children:"All permissions bypassed — the agent can execute any tool without approval"})]})}const SB=["config"],hVe=["meet-dorkbot","discovery","tasks","adapters"];function fb(){const e=Fe(),t=Ct(),n=x.useRef(new Set),s=x.useRef(new Set),{data:r,isLoading:a}=mt({queryKey:[...SB],queryFn:()=>e.getConfig(),staleTime:300*1e3}),o={completedSteps:[],skippedSteps:[],startedAt:null,dismissedAt:null},l=r!=null&&r.onboarding?{completedSteps:r.onboarding.completedSteps,skippedSteps:r.onboarding.skippedSteps,startedAt:r.onboarding.startedAt,dismissedAt:r.onboarding.dismissedAt}:o,c=hVe.every(k=>l.completedSteps.includes(k)),u=l.dismissedAt!==null,f=!a&&!c&&!u,h=mn({mutationFn:k=>e.updateConfig({onboarding:k}),onSuccess:()=>{t.invalidateQueries({queryKey:[...SB]}).then(()=>{n.current.clear(),s.current.clear()})},onError:(k,w)=>{n.current.clear(),s.current.clear();const C=Object.keys(w).join(", ");rt.error(`Failed to save onboarding progress (${C})`)}});function m(k){const w=new Set([...l.completedSteps,...n.current]);w.has(k)||(n.current.add(k),h.mutate({completedSteps:[...w,k]}))}function g(k){const w=new Set([...l.skippedSteps,...s.current]);w.has(k)||(s.current.add(k),h.mutate({skippedSteps:[...w,k]}))}function b(){return h.mutateAsync({dismissedAt:new Date().toISOString()})}function v(){l.startedAt||h.mutate({startedAt:new Date().toISOString()})}return{state:l,config:r,isLoading:a,isOnboardingComplete:c,isOnboardingDismissed:u,shouldShowOnboarding:f,completeStep:m,skipStep:g,dismiss:b,startOnboarding:v}}const mre={tasks:Pu};function pVe(){return!0}const mVe=["mesh","agent-paths"];function hb(){const e=Fe();return mt({queryKey:[...mVe],queryFn:()=>e.listMeshAgentPaths(),staleTime:3e4})}const gVe=["mesh","agents"];function ji(e,t=!0){const n=Fe();return mt({queryKey:[...gVe,e],queryFn:()=>n.listMeshAgents(e),enabled:t,staleTime:3e4})}function gre(){const e=Fe(),t=Ct();return mn({mutationFn:n=>e.registerMeshAgent(n.path,n.overrides,n.approver),onSuccess:()=>{t.invalidateQueries({queryKey:["mesh","agents"]}),t.invalidateQueries({queryKey:["mesh","agent-paths"]})}})}function xVe(){const e=Fe(),t=Ct();return mn({mutationFn:n=>e.denyMeshAgent(n.path,n.reason,n.denier),onSuccess:()=>{t.invalidateQueries({queryKey:["mesh","denied"]})}})}const yVe=["mesh","denied"];function bVe(e=!0){const t=Fe();return mt({queryKey:[...yVe],queryFn:()=>t.listDeniedMeshAgents(),enabled:e,staleTime:3e4})}const vVe=["mesh","status"],SVe=3e4;function sO(e=!0){const t=Fe();return mt({queryKey:[...vVe],queryFn:()=>t.getMeshStatus(),enabled:e,refetchInterval:SVe})}function xre(e){const t=Fe();return mt({queryKey:["mesh","agent-health",e],queryFn:()=>t.getMeshAgentHealth(e),enabled:e!==null})}const wVe=["mesh","topology"];function rO(e,t=!0){const n=Fe();return mt({queryKey:[...wVe,e],queryFn:()=>n.getMeshTopology(e),enabled:t,staleTime:3e4,refetchInterval:3e4})}const kVe=["mesh","topology"];function CVe(){const e=Fe(),t=Ct();return mn({mutationFn:n=>e.updateMeshAccessRule(n),onSuccess:()=>{t.invalidateQueries({queryKey:kVe})}})}function EVe(e,t=!0){const n=Fe();return mt({queryKey:["mesh","agent-access",e],queryFn:()=>n.getMeshAgentAccess(e),enabled:t&&!!e,staleTime:3e4})}function yre(){var u;const e=Fe(),t=Ct(),{data:n}=mt({queryKey:["config"],queryFn:()=>e.getConfig(),staleTime:300*1e3}),s=((u=n==null?void 0:n.mesh)==null?void 0:u.scanRoots)??[],r=(n==null?void 0:n.boundary)??"",a=s.length>0?s:r?[r]:[],{mutate:o,isPending:l}=mn({mutationFn:async f=>{await e.updateConfig({mesh:{scanRoots:f}})},onSuccess:()=>{t.invalidateQueries({queryKey:["config"]})}}),c=x.useCallback(f=>o(f),[o]);return{roots:a,boundary:r,isSaving:l,setScanRoots:c}}const TVe=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function bre(e){const t=e.trim().split(/\s+/);if(t.length!==5)return e;const[n,s,r,a,o]=t;return r==="*"&&a==="*"&&o==="*"&&D0(s)&&D0(n)?`Every day at ${wB(s,n)}`:r==="*"&&a==="*"&&D0(o)&&D0(s)&&D0(n)?`Every ${TVe[Number(o)]??`day ${o}`} at ${wB(s,n)}`:e}function D0(e){return/^\d+$/.test(e)}function wB(e,t){const n=Number(e),s=Number(t),r=n>=12?"PM":"AM";return`${n===0?12:n>12?n-12:n}:${String(s).padStart(2,"0")} ${r}`}function _Ve(){const[e,t]=x.useState({x:0,y:0}),[n,s]=x.useState(!1),r=vr(),a=typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(hover: none)").matches,o=r||a,l=x.useCallback(f=>{if(o)return;const h=f.currentTarget.getBoundingClientRect();t({x:f.clientX-h.left,y:f.clientY-h.top}),s(!0)},[o]),c=x.useCallback(()=>{s(!1)},[]),u=!o&&n?{background:`radial-gradient(350px circle at ${e.x}px ${e.y}px, rgba(59,130,246,0.06), transparent 80%)`}:void 0;return{position:e,isActive:n,onMouseMove:l,onMouseLeave:c,spotlightStyle:u}}function vre({preset:e,variant:t,checked:n,onCheckedChange:s,onSelect:r,selected:a=!1,className:o}){const{onMouseMove:l,onMouseLeave:c,spotlightStyle:u}=_Ve(),f=()=>{t==="toggle"?s==null||s(!n):r==null||r(e)};return i.jsxs("button",{type:"button",onClick:f,onMouseMove:l,onMouseLeave:c,className:X("relative flex w-full items-start gap-4 rounded-lg border p-4 text-left transition","hover:bg-accent/50","min-h-11",t==="toggle"&&n&&"border-primary/40 bg-accent/30",t==="selectable"&&a&&"border-primary ring-primary bg-accent/30 ring-1",o),children:[u&&i.jsx("div",{className:"pointer-events-none absolute inset-0 rounded-lg",style:u}),t==="toggle"&&i.jsx("div",{className:"flex size-11 shrink-0 items-center justify-center",children:i.jsx(Ks,{checked:n??!1,onCheckedChange:s,"aria-label":`Enable ${e.name}`,onClick:h=>h.stopPropagation()})}),i.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[i.jsx("div",{className:"font-medium",children:e.name}),i.jsx("p",{className:"text-muted-foreground text-sm",children:e.description}),i.jsx("p",{className:"text-muted-foreground text-xs",children:bre(e.cron)}),i.jsx("p",{className:"text-muted-foreground/80 line-clamp-2 text-sm",children:e.prompt})]})]})}function Sre({onSelect:e,selectedId:t,className:n}){const{data:s,isLoading:r,isError:a}=tO();return r?i.jsx("div",{className:X("grid grid-cols-2 gap-3",n),children:[0,1,2,3].map(o=>i.jsx("div",{className:"bg-muted animate-tasks h-28 rounded-lg border"},o))}):a?i.jsx("p",{className:"text-destructive text-sm",children:"Failed to load presets. You can start from scratch."}):!s||s.length===0?i.jsx("p",{className:"text-muted-foreground text-sm",children:"No presets available."}):i.jsx("div",{className:X("grid grid-cols-2 gap-3",n),children:s.map(o=>i.jsx(vre,{preset:o,variant:"selectable",selected:o.id===t,onSelect:e},o.id))})}var fN={exports:{}},kB;function NVe(){return kB||(kB=1,(function(e,t){(function(s,r){e.exports=r()})(globalThis,()=>(()=>{var n={949(o,l,c){Object.defineProperty(l,"__esModule",{value:!0}),l.CronParser=void 0;var u=c(515),f=(function(){function h(m,g,b){g===void 0&&(g=!0),b===void 0&&(b=!1),this.expression=m,this.dayOfWeekStartIndexZero=g,this.monthStartIndexZero=b}return h.prototype.parse=function(){var m,g,b=(m=this.expression)!==null&&m!==void 0?m:"";if(b==="@reboot")return g=["@reboot","","","","","",""],g;if(b.startsWith("@")){var v=this.parseSpecial(this.expression);g=this.extractParts(v)}else g=this.extractParts(this.expression);return this.normalize(g),this.validate(g),g},h.prototype.parseSpecial=function(m){var g={"@yearly":"0 0 1 1 *","@annually":"0 0 1 1 *","@monthly":"0 0 1 * *","@weekly":"0 0 * * 0","@daily":"0 0 * * *","@midnight":"0 0 * * *","@hourly":"0 * * * *","@reboot":"@reboot"},b=g[m];if(!b)throw new Error("Unknown special expression.");return b},h.prototype.extractParts=function(m){if(!this.expression)throw new Error("cron expression is empty");for(var g=m.trim().split(/[ ]+/),b=0;b<g.length;b++)if(g[b].includes(",")){var v=g[b].split(",").map(function(w){return w.trim()}).filter(function(w){return w!==""}).map(function(w){return isNaN(Number(w))?w:Number(w)}).filter(function(w){return w!==null&&w!==""});v.length===0&&v.push("*"),v.sort(function(w,C){return w!==null&&C!==null?w-C:0}),g[b]=v.map(function(w){return w!==null?w.toString():""}).join(",")}if(g.length<5)throw new Error("Expression has only ".concat(g.length," part").concat(g.length==1?"":"s",". At least 5 parts are required."));if(g.length==5)g.unshift(""),g.push("");else if(g.length==6){var k=/\d{4}$/.test(g[5])||g[4]=="?"||g[2]=="?";k?g.unshift(""):g.push("")}else if(g.length>7)throw new Error("Expression has ".concat(g.length," parts; too many!"));return g},h.prototype.normalize=function(m){var g=this;if(m[3]=m[3].replace("?","*"),m[5]=m[5].replace("?","*"),m[2]=m[2].replace("?","*"),m[0].indexOf("0/")==0&&(m[0]=m[0].replace("0/","*/")),m[1].indexOf("0/")==0&&(m[1]=m[1].replace("0/","*/")),m[2].indexOf("0/")==0&&(m[2]=m[2].replace("0/","*/")),m[3].indexOf("1/")==0&&(m[3]=m[3].replace("1/","*/")),m[4].indexOf("1/")==0&&(m[4]=m[4].replace("1/","*/")),m[6].indexOf("1/")==0&&(m[6]=m[6].replace("1/","*/")),m[5]=m[5].replace(/(^\d)|([^#/\s]\d)/g,function(_){var j=_.replace(/\D/,""),R=j;return g.dayOfWeekStartIndexZero?j=="7"&&(R="0"):R=(parseInt(j)-1).toString(),_.replace(j,R)}),m[5]=="L"&&(m[5]="6"),m[3]=="?"&&(m[3]="*"),m[3].indexOf("W")>-1&&(m[3].indexOf(",")>-1||m[3].indexOf("-")>-1))throw new Error("The 'W' character can be specified only when the day-of-month is a single day, not a range or list of days.");var b={SUN:0,MON:1,TUE:2,WED:3,THU:4,FRI:5,SAT:6};for(var v in b)m[5]=m[5].replace(new RegExp(v,"gi"),b[v].toString());m[4]=m[4].replace(/(^\d{1,2})|([^#/\s]\d{1,2})/g,function(_){var j=_.replace(/\D/,""),R=j;return g.monthStartIndexZero&&(R=(parseInt(j)+1).toString()),_.replace(j,R)});var k={JAN:1,FEB:2,MAR:3,APR:4,MAY:5,JUN:6,JUL:7,AUG:8,SEP:9,OCT:10,NOV:11,DEC:12};for(var w in k)m[4]=m[4].replace(new RegExp(w,"gi"),k[w].toString());m[0]=="0"&&(m[0]=""),!/\*|\-|\,|\//.test(m[2])&&(/\*|\//.test(m[1])||/\*|\//.test(m[0]))&&(m[2]+="-".concat(m[2]));for(var C=0;C<m.length;C++)if(m[C].indexOf(",")!=-1&&(m[C]=m[C].split(",").filter(function(_){return _!==""}).join(",")||"*"),m[C]=="*/1"&&(m[C]="*"),m[C].indexOf("/")>-1&&!/^\*|\-|\,/.test(m[C])){var E=null;switch(C){case 4:E="12";break;case 5:E="6";break;case 6:E="9999";break;default:E=null;break}if(E!==null){var T=m[C].split("/");m[C]="".concat(T[0],"-").concat(E,"/").concat(T[1])}}},h.prototype.validate=function(m){var g="0-9,\\-*/";this.validateOnlyExpectedCharactersFound(m[0],g),this.validateOnlyExpectedCharactersFound(m[1],g),this.validateOnlyExpectedCharactersFound(m[2],g),this.validateOnlyExpectedCharactersFound(m[3],"0-9,\\-*/LW"),this.validateOnlyExpectedCharactersFound(m[4],g),this.validateOnlyExpectedCharactersFound(m[5],"0-9,\\-*/L#"),this.validateOnlyExpectedCharactersFound(m[6],g),this.validateAnyRanges(m)},h.prototype.validateAnyRanges=function(m){u.default.secondRange(m[0]),u.default.minuteRange(m[1]),u.default.hourRange(m[2]),u.default.dayOfMonthRange(m[3]),u.default.monthRange(m[4],this.monthStartIndexZero),u.default.dayOfWeekRange(m[5],this.dayOfWeekStartIndexZero)},h.prototype.validateOnlyExpectedCharactersFound=function(m,g){var b=m.match(new RegExp("[^".concat(g,"]+"),"gi"));if(b&&b.length)throw new Error("Expression contains invalid values: '".concat(b.toString(),"'"))},h})();l.CronParser=f},333(o,l,c){Object.defineProperty(l,"__esModule",{value:!0}),l.ExpressionDescriptor=void 0;var u=c(823),f=c(949),h=(function(){function m(g,b){if(this.expression=g,this.options=b,this.expressionParts=new Array(5),!this.options.locale&&m.defaultLocale&&(this.options.locale=m.defaultLocale),!m.locales[this.options.locale]){var v=Object.keys(m.locales)[0];console.warn("Locale '".concat(this.options.locale,"' could not be found; falling back to '").concat(v,"'.")),this.options.locale=v}this.i18n=m.locales[this.options.locale],b.use24HourTimeFormat===void 0&&(b.use24HourTimeFormat=this.i18n.use24HourTimeFormatByDefault())}return m.toString=function(g,b){var v=b===void 0?{}:b,k=v.throwExceptionOnParseError,w=k===void 0?!0:k,C=v.verbose,E=C===void 0?!1:C,T=v.dayOfWeekStartIndexZero,_=T===void 0?!0:T,j=v.monthStartIndexZero,R=j===void 0?!1:j,D=v.use24HourTimeFormat,I=v.trimHoursLeadingZero,O=I===void 0?!1:I,L=v.locale,B=L===void 0?null:L,H=v.logicalAndDayFields,K=H===void 0?!1:H,U={throwExceptionOnParseError:w,verbose:E,dayOfWeekStartIndexZero:_,monthStartIndexZero:R,use24HourTimeFormat:D,trimHoursLeadingZero:O,locale:B,logicalAndDayFields:K};U.tzOffset&&console.warn("'tzOffset' option has been deprecated and is no longer supported.");var $=new m(g,U);return $.getFullDescription()},m.initialize=function(g,b){b===void 0&&(b="en"),m.specialCharacters=["/","-",",","*"],m.defaultLocale=b,g.load(m.locales)},m.prototype.getFullDescription=function(){var g,b,v="";try{var k=new f.CronParser(this.expression,this.options.dayOfWeekStartIndexZero,this.options.monthStartIndexZero);if(this.expressionParts=k.parse(),this.expressionParts[0]==="@reboot")return((b=(g=this.i18n).atReboot)===null||b===void 0?void 0:b.call(g))||"Run once, at startup";var w=this.getTimeOfDayDescription(),C=this.getDayOfMonthDescription(),E=this.getMonthDescription(),T=this.getDayOfWeekDescription(),_=this.getYearDescription();v+=w+C+T+E+_,v=this.transformVerbosity(v,!!this.options.verbose),v=v.charAt(0).toLocaleUpperCase()+v.substr(1)}catch(j){if(!this.options.throwExceptionOnParseError)v=this.i18n.anErrorOccuredWhenGeneratingTheExpressionD();else throw"".concat(j)}return v},m.prototype.getTimeOfDayDescription=function(){var g=this.expressionParts[0],b=this.expressionParts[1],v=this.expressionParts[2],k="";if(!u.StringUtilities.containsAny(b,m.specialCharacters)&&!u.StringUtilities.containsAny(v,m.specialCharacters)&&!u.StringUtilities.containsAny(g,m.specialCharacters))k+=this.i18n.atSpace()+this.formatTime(v,b,g);else if(!g&&b.indexOf("-")>-1&&!(b.indexOf(",")>-1)&&!(b.indexOf("/")>-1)&&!u.StringUtilities.containsAny(v,m.specialCharacters)){var w=b.split("-");k+=u.StringUtilities.format(this.i18n.everyMinuteBetweenX0AndX1(),this.formatTime(v,w[0],""),this.formatTime(v,w[1],""))}else if(!g&&v.indexOf(",")>-1&&v.indexOf("-")==-1&&v.indexOf("/")==-1&&!u.StringUtilities.containsAny(b,m.specialCharacters)){var C=v.split(",");k+=this.i18n.at();for(var E=0;E<C.length;E++)k+=" ",k+=this.formatTime(C[E],b,""),E<C.length-2&&(k+=","),E==C.length-2&&(k+=this.i18n.spaceAnd())}else{var T=this.getSecondsDescription(),_=this.getMinutesDescription(),j=this.getHoursDescription();if(k+=T,k&&_&&(k+=", "),k+=_,_===j)return k;k&&j&&(k+=", "),k+=j}return k},m.prototype.getSecondsDescription=function(){var g=this,b=this.getSegmentDescription(this.expressionParts[0],this.i18n.everySecond(),function(v){return v},function(v){return u.StringUtilities.format(g.i18n.everyX0Seconds(v),v)},function(v){return g.i18n.secondsX0ThroughX1PastTheMinute()},function(v){return v=="0"?"":parseInt(v)<20?g.i18n.atX0SecondsPastTheMinute(v):g.i18n.atX0SecondsPastTheMinuteGt20()||g.i18n.atX0SecondsPastTheMinute(v)});return b},m.prototype.getMinutesDescription=function(){var g=this,b=this.expressionParts[0],v=this.expressionParts[2],k=this.getSegmentDescription(this.expressionParts[1],this.i18n.everyMinute(),function(w){return w},function(w){return u.StringUtilities.format(g.i18n.everyX0Minutes(w),w)},function(w){return g.i18n.minutesX0ThroughX1PastTheHour()},function(w){var C,E;try{return w=="0"&&v.indexOf("/")==-1&&b==""?g.i18n.everyHour():w=="0"?((E=(C=g.i18n).onTheHour)===null||E===void 0?void 0:E.call(C))||g.i18n.atX0MinutesPastTheHour(w):parseInt(w)<20?g.i18n.atX0MinutesPastTheHour(w):g.i18n.atX0MinutesPastTheHourGt20()||g.i18n.atX0MinutesPastTheHour(w)}catch{return g.i18n.atX0MinutesPastTheHour(w)}});return k},m.prototype.getHoursDescription=function(){var g=this,b=this.expressionParts[2],v=0,k=[];b.split("/")[0].split(",").forEach(function(E){var T=E.split("-");T.length===2&&k.push({value:T[1],index:v+1}),v+=T.length});var w=0,C=this.getSegmentDescription(b,this.i18n.everyHour(),function(E){var T=k.find(function(j){return j.value===E&&j.index===w}),_=T&&g.expressionParts[1]!=="0";return w++,_?g.formatTime(E,"59",""):g.formatTime(E,"0","")},function(E){return u.StringUtilities.format(g.i18n.everyX0Hours(E),E)},function(E){return g.i18n.betweenX0AndX1()},function(E){return g.i18n.atX0()});return C},m.prototype.getDayOfWeekDescription=function(){var g=this,b=this.i18n.daysOfTheWeek(),v=null;return this.expressionParts[5]=="*"?v="":v=this.getSegmentDescription(this.expressionParts[5],this.i18n.commaEveryDay(),function(k,w){var C=k;k.indexOf("#")>-1?C=k.substring(0,k.indexOf("#")):k.indexOf("L")>-1&&(C=C.replace("L",""));var E=parseInt(C),T=g.i18n.daysOfTheWeekInCase?g.i18n.daysOfTheWeekInCase(w)[E]:b[E];if(k.indexOf("#")>-1){var _=null,j=k.substring(k.indexOf("#")+1),R=k.substring(0,k.indexOf("#"));switch(j){case"1":_=g.i18n.first(R);break;case"2":_=g.i18n.second(R);break;case"3":_=g.i18n.third(R);break;case"4":_=g.i18n.fourth(R);break;case"5":_=g.i18n.fifth(R);break}T=_+" "+T}return T},function(k){return parseInt(k)==1?"":u.StringUtilities.format(g.i18n.commaEveryX0DaysOfTheWeek(k),k)},function(k){var w=k.substring(0,k.indexOf("-")),C=g.expressionParts[3]!="*";return C?g.i18n.commaAndX0ThroughX1(w):g.i18n.commaX0ThroughX1(w)},function(k){var w=null;if(k.indexOf("#")>-1){var C=k.substring(k.indexOf("#")+1),E=k.substring(0,k.indexOf("#"));w=g.i18n.commaOnThe(C,E).trim()+g.i18n.spaceX0OfTheMonth()}else if(k.indexOf("L")>-1)w=g.i18n.commaOnTheLastX0OfTheMonth(k.replace("L",""));else{var T=g.expressionParts[3]!="*";T?g.options.logicalAndDayFields?w=g.i18n.commaOnlyOnX0(k):w=g.i18n.commaAndOnX0():w=g.i18n.commaOnlyOnX0(k)}return w}),v},m.prototype.getMonthDescription=function(){var g=this,b=this.i18n.monthsOfTheYear(),v=this.getSegmentDescription(this.expressionParts[4],"",function(k,w){return w&&g.i18n.monthsOfTheYearInCase?g.i18n.monthsOfTheYearInCase(w)[parseInt(k)-1]:b[parseInt(k)-1]},function(k){return parseInt(k)==1?"":u.StringUtilities.format(g.i18n.commaEveryX0Months(k),k)},function(k){return g.i18n.commaMonthX0ThroughMonthX1()||g.i18n.commaX0ThroughX1()},function(k){return g.i18n.commaOnlyInMonthX0?g.i18n.commaOnlyInMonthX0():g.i18n.commaOnlyInX0()});return v},m.prototype.getDayOfMonthDescription=function(){var g=this,b=null,v=this.expressionParts[3];switch(v){case"L":b=this.i18n.commaOnTheLastDayOfTheMonth();break;case"WL":case"LW":b=this.i18n.commaOnTheLastWeekdayOfTheMonth();break;default:var k=v.match(/(\d{1,2}W)|(W\d{1,2})/);if(k){var w=parseInt(k[0].replace("W","")),C=w==1?this.i18n.firstWeekday():u.StringUtilities.format(this.i18n.weekdayNearestDayX0(),w.toString());b=u.StringUtilities.format(this.i18n.commaOnTheX0OfTheMonth(),C);break}else{var E=v.match(/L-(\d{1,2})/);if(E){var T=E[1];b=u.StringUtilities.format(this.i18n.commaDaysBeforeTheLastDayOfTheMonth(T),T);break}else{if(v=="*"&&this.expressionParts[5]!="*")return"";b=this.getSegmentDescription(v,this.i18n.commaEveryDay(),function(_){return _=="L"?g.i18n.lastDay():g.i18n.dayX0?u.StringUtilities.format(g.i18n.dayX0(),_):_},function(_){return _=="1"?g.i18n.commaEveryDay():g.i18n.commaEveryX0Days(_)},function(_){return g.i18n.commaBetweenDayX0AndX1OfTheMonth(_)},function(_){return g.i18n.commaOnDayX0OfTheMonth(_)})}break}}return b},m.prototype.getYearDescription=function(){var g=this,b=this.getSegmentDescription(this.expressionParts[6],"",function(v){return/^\d+$/.test(v)?new Date(parseInt(v),1).getFullYear().toString():v},function(v){return u.StringUtilities.format(g.i18n.commaEveryX0Years(v),v)},function(v){return g.i18n.commaYearX0ThroughYearX1()||g.i18n.commaX0ThroughX1()},function(v){return g.i18n.commaOnlyInYearX0?g.i18n.commaOnlyInYearX0():g.i18n.commaOnlyInX0()});return b},m.prototype.getSegmentDescription=function(g,b,v,k,w,C){var E=null,T=g.indexOf("/")>-1,_=g.indexOf("-")>-1,j=g.indexOf(",")>-1;if(!g)E="";else if(g==="*")E=b;else if(!T&&!_&&!j)E=u.StringUtilities.format(C(g),v(g));else if(j){for(var R=g.split(","),D="",I=0;I<R.length;I++)if(I>0&&R.length>2&&(D+=",",I<R.length-1&&(D+=" ")),I>0&&R.length>1&&(I==R.length-1||R.length==2)&&(D+="".concat(this.i18n.spaceAnd()," ")),R[I].indexOf("/")>-1||R[I].indexOf("-")>-1){var O=R[I].indexOf("-")>-1&&R[I].indexOf("/")==-1,L=this.getSegmentDescription(R[I],b,v,k,O?this.i18n.commaX0ThroughX1:w,C);O&&(L=L.replace(", ","")),D+=L}else if(!T)D+=v(R[I]);else{var B=this.getSegmentDescription(R[I],b,v,k,w,C);B&&B.startsWith(", ")&&(B=B.substring(2)),D+=B}T?E=D:E=u.StringUtilities.format(C(g),D)}else if(T){var R=g.split("/");if(E=u.StringUtilities.format(k(R[1]),R[1]),R[0].indexOf("-")>-1){var H=this.generateRangeSegmentDescription(R[0],w,v);H.indexOf(", ")!=0&&(E+=", "),E+=H}else if(R[0].indexOf("*")==-1){var K=u.StringUtilities.format(C(R[0]),v(R[0]));K=K.replace(", ",""),E+=u.StringUtilities.format(this.i18n.commaStartingX0(),K)}}else _&&(E=this.generateRangeSegmentDescription(g,w,v));return E},m.prototype.generateRangeSegmentDescription=function(g,b,v){var k="",w=g.split("-"),C=v(w[0],1),E=v(w[1],2),T=b(g);return k+=u.StringUtilities.format(T,C,E),k},m.prototype.formatTime=function(g,b,v){var k=0,w=0,C=parseInt(g)+k,E=parseInt(b)+w;E>=60?(E-=60,C+=1):E<0&&(E+=60,C-=1),C>=24?C=C-24:C<0&&(C=24+C);var T="",_=!1;this.options.use24HourTimeFormat||(_=!!(this.i18n.setPeriodBeforeTime&&this.i18n.setPeriodBeforeTime()),T=_?"".concat(this.getPeriod(C)," "):" ".concat(this.getPeriod(C)),C>12&&(C-=12),C===0&&(C=12));var j="";v&&(j=":".concat(("00"+v).substring(v.length)));var R=C.toString(),D=("00"+R).substring(R.length),I=E.toString(),O=("00"+I).substring(I.length),L=this.options.trimHoursLeadingZero?R:D;return"".concat(_?T:"").concat(L,":").concat(O).concat(j).concat(_?"":T)},m.prototype.transformVerbosity=function(g,b){if(!b&&(g=g.replace(new RegExp(", ".concat(this.i18n.everyMinute()),"g"),""),g=g.replace(new RegExp(", ".concat(this.i18n.everyHour()),"g"),""),g=g.replace(new RegExp(this.i18n.commaEveryDay(),"g"),""),g=g.replace(/\, ?$/,""),this.i18n.conciseVerbosityReplacements))for(var v=0,k=Object.entries(this.i18n.conciseVerbosityReplacements());v<k.length;v++){var w=k[v],C=w[0],E=w[1];g=g.replace(new RegExp(C,"g"),E)}return g},m.prototype.getPeriod=function(g){return g>=12?this.i18n.pm&&this.i18n.pm()||"PM":this.i18n.am&&this.i18n.am()||"AM"},m.locales={},m})();l.ExpressionDescriptor=h},747(o,l,c){Object.defineProperty(l,"__esModule",{value:!0}),l.enLocaleLoader=void 0;var u=c(486),f=(function(){function h(){}return h.prototype.load=function(m){m.en=new u.en},h})();l.enLocaleLoader=f},486(o,l){Object.defineProperty(l,"__esModule",{value:!0}),l.en=void 0;var c=(function(){function u(){}return u.prototype.atX0SecondsPastTheMinuteGt20=function(){return null},u.prototype.atX0MinutesPastTheHourGt20=function(){return null},u.prototype.commaMonthX0ThroughMonthX1=function(){return null},u.prototype.commaYearX0ThroughYearX1=function(){return null},u.prototype.use24HourTimeFormatByDefault=function(){return!1},u.prototype.anErrorOccuredWhenGeneratingTheExpressionD=function(){return"An error occurred when generating the expression description. Check the cron expression syntax."},u.prototype.everyMinute=function(){return"every minute"},u.prototype.everyHour=function(){return"every hour"},u.prototype.atSpace=function(){return"At "},u.prototype.everyMinuteBetweenX0AndX1=function(){return"Every minute between %s and %s"},u.prototype.at=function(){return"At"},u.prototype.spaceAnd=function(){return" and"},u.prototype.everySecond=function(){return"every second"},u.prototype.everyX0Seconds=function(){return"every %s seconds"},u.prototype.secondsX0ThroughX1PastTheMinute=function(){return"seconds %s through %s past the minute"},u.prototype.atX0SecondsPastTheMinute=function(){return"at %s seconds past the minute"},u.prototype.everyX0Minutes=function(){return"every %s minutes"},u.prototype.minutesX0ThroughX1PastTheHour=function(){return"minutes %s through %s past the hour"},u.prototype.atX0MinutesPastTheHour=function(){return"at %s minutes past the hour"},u.prototype.everyX0Hours=function(){return"every %s hours"},u.prototype.betweenX0AndX1=function(){return"between %s and %s"},u.prototype.atX0=function(){return"at %s"},u.prototype.commaEveryDay=function(){return", every day"},u.prototype.commaEveryX0DaysOfTheWeek=function(){return", every %s days of the week"},u.prototype.commaX0ThroughX1=function(){return", %s through %s"},u.prototype.commaAndX0ThroughX1=function(){return", %s through %s"},u.prototype.first=function(){return"first"},u.prototype.second=function(){return"second"},u.prototype.third=function(){return"third"},u.prototype.fourth=function(){return"fourth"},u.prototype.fifth=function(){return"fifth"},u.prototype.commaOnThe=function(){return", on the "},u.prototype.spaceX0OfTheMonth=function(){return" %s of the month"},u.prototype.lastDay=function(){return"the last day"},u.prototype.commaOnTheLastX0OfTheMonth=function(){return", on the last %s of the month"},u.prototype.commaOnlyOnX0=function(){return", only on %s"},u.prototype.commaAndOnX0=function(){return", and on %s"},u.prototype.commaEveryX0Months=function(){return", every %s months"},u.prototype.commaOnlyInX0=function(){return", only in %s"},u.prototype.commaOnTheLastDayOfTheMonth=function(){return", on the last day of the month"},u.prototype.commaOnTheLastWeekdayOfTheMonth=function(){return", on the last weekday of the month"},u.prototype.commaDaysBeforeTheLastDayOfTheMonth=function(){return", %s days before the last day of the month"},u.prototype.firstWeekday=function(){return"first weekday"},u.prototype.weekdayNearestDayX0=function(){return"weekday nearest day %s"},u.prototype.commaOnTheX0OfTheMonth=function(){return", on the %s of the month"},u.prototype.commaEveryX0Days=function(){return", every %s days in a month"},u.prototype.commaBetweenDayX0AndX1OfTheMonth=function(){return", between day %s and %s of the month"},u.prototype.commaOnDayX0OfTheMonth=function(){return", on day %s of the month"},u.prototype.commaEveryHour=function(){return", every hour"},u.prototype.commaEveryX0Years=function(){return", every %s years"},u.prototype.commaStartingX0=function(){return", starting %s"},u.prototype.daysOfTheWeek=function(){return["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},u.prototype.monthsOfTheYear=function(){return["January","February","March","April","May","June","July","August","September","October","November","December"]},u.prototype.atReboot=function(){return"Run once, at startup"},u.prototype.onTheHour=function(){return"on the hour"},u})();l.en=c},515(o,l){Object.defineProperty(l,"__esModule",{value:!0});function c(f,h){if(!f)throw new Error(h)}var u=(function(){function f(){}return f.secondRange=function(h){for(var m=h.split(","),g=0;g<m.length;g++)if(!isNaN(parseInt(m[g],10))){var b=parseInt(m[g],10);c(b>=0&&b<=59,"seconds part must be >= 0 and <= 59")}},f.minuteRange=function(h){for(var m=h.split(","),g=0;g<m.length;g++)if(!isNaN(parseInt(m[g],10))){var b=parseInt(m[g],10);c(b>=0&&b<=59,"minutes part must be >= 0 and <= 59")}},f.hourRange=function(h){for(var m=h.split(","),g=0;g<m.length;g++)if(!isNaN(parseInt(m[g],10))){var b=parseInt(m[g],10);c(b>=0&&b<=23,"hours part must be >= 0 and <= 23")}},f.dayOfMonthRange=function(h){for(var m=h.split(","),g=0;g<m.length;g++)if(!isNaN(parseInt(m[g],10))){var b=parseInt(m[g],10);c(b>=1&&b<=31,"DOM part must be >= 1 and <= 31")}},f.monthRange=function(h,m){for(var g=h.split(","),b=0;b<g.length;b++)if(!isNaN(parseInt(g[b],10))){var v=parseInt(g[b],10);c(v>=1&&v<=12,m?"month part must be >= 0 and <= 11":"month part must be >= 1 and <= 12")}},f.dayOfWeekRange=function(h,m){for(var g=h.split(","),b=0;b<g.length;b++)if(!isNaN(parseInt(g[b],10))){var v=parseInt(g[b],10);c(v>=0&&v<=6,m?"DOW part must be >= 0 and <= 6":"DOW part must be >= 1 and <= 7")}},f})();l.default=u},823(o,l){Object.defineProperty(l,"__esModule",{value:!0}),l.StringUtilities=void 0;var c=(function(){function u(){}return u.format=function(f){for(var h=[],m=1;m<arguments.length;m++)h[m-1]=arguments[m];return f.replace(/%s/g,function(g){return h.shift()})},u.containsAny=function(f,h){return h.some(function(m){return f.indexOf(m)>-1})},u})();l.StringUtilities=c}},s={};function r(o){var l=s[o];if(l!==void 0)return l.exports;var c=s[o]={exports:{}};return n[o](c,c.exports,r),c.exports}var a={};return(()=>{var o=a;Object.defineProperty(o,"__esModule",{value:!0}),o.toString=void 0;var l=r(333),c=r(747);l.ExpressionDescriptor.initialize(new c.enLocaleLoader),o.default=l.ExpressionDescriptor;var u=l.ExpressionDescriptor.toString;o.toString=u})(),a})())})(fN)),fN.exports}var jVe=NVe();const wre=eo(jVe),Cp={frequency:"daily",hour:9,days:[1,2,3,4,5],dayOfMonth:1},AVe=[{value:"15m",label:"Every 15 minutes"},{value:"hourly",label:"Every hour"},{value:"daily",label:"Every day"},{value:"weekly",label:"Every week"},{value:"monthly",label:"Every month"}],RVe=[{value:1,label:"Mon"},{value:2,label:"Tue"},{value:3,label:"Wed"},{value:4,label:"Thu"},{value:5,label:"Fri"},{value:6,label:"Sat"},{value:0,label:"Sun"}],MVe=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],DVe=[1,2,3,4,5],OVe=[0,6],hN={duration:.2,ease:[.4,0,.2,1]};function CB(e){const t=e.trim();if(!t)return null;const n=t.split(/\s+/);if(n.length!==5)return null;const[s,r,a,o,l]=n;if(o!=="*")return null;if(s==="*/15"&&r==="*"&&a==="*"&&l==="*")return{...Cp,frequency:"15m"};if(s!=="0")return null;if(r==="*"&&a==="*"&&l==="*")return{...Cp,frequency:"hourly"};const c=Number(r);if(!Number.isInteger(c)||c<0||c>23)return null;if(a!=="*"&&l==="*"){const u=Number(a);return!Number.isInteger(u)||u<1||u>31?null:{...Cp,frequency:"monthly",hour:c,dayOfMonth:u}}if(a==="*"&&l==="*")return{...Cp,frequency:"daily",hour:c};if(a==="*"&&l!=="*"){const u=IVe(l);return u?{...Cp,frequency:"weekly",hour:c,days:u}:null}return null}function IVe(e){const t=[];for(const n of e.split(",")){const s=n.match(/^(\d)-(\d)$/);if(s){const r=Number(s[1]),a=Number(s[2]);if(r>6||a>6||r>a)return null;for(let o=r;o<=a;o++)t.push(o)}else{const r=Number(n);if(!Number.isInteger(r)||r<0||r>6)return null;t.push(r)}}return t.length>0?t.sort((n,s)=>n-s):null}function EB(e){switch(e.frequency){case"15m":return"*/15 * * * *";case"hourly":return"0 * * * *";case"daily":return`0 ${e.hour} * * *`;case"weekly":return`0 ${e.hour} * * ${e.days.join(",")}`;case"monthly":return`0 ${e.hour} ${e.dayOfMonth} * *`}}function kre(e){const t=e<12?"AM":"PM";return`${e%12||12}:00 ${t}`}function Cre(e){const t=e%100;if(t>=11&&t<=13)return`${e}th`;const n=e%10;return n===1?`${e}st`:n===2?`${e}nd`:n===3?`${e}rd`:`${e}th`}function TB(e,t){return e.length===t.length&&e.every((n,s)=>n===t[s])}function PVe(e){const t=kre(e.hour);switch(e.frequency){case"15m":return"Runs every 15 minutes";case"hourly":return"Runs every hour, on the hour";case"daily":return`Runs every day at ${t}`;case"weekly":{const n=[...e.days].sort((o,l)=>o-l);if(TB(n,DVe))return`Runs every weekday at ${t}`;if(TB(n,OVe))return`Runs every Saturday and Sunday at ${t}`;const r=n.filter(o=>o!==0).concat(n.includes(0)?[0]:[]).map(o=>MVe[o]);if(r.length===1)return`Runs every ${r[0]} at ${t}`;if(r.length===2)return`Runs every ${r[0]} and ${r[1]} at ${t}`;const a=r.pop();return`Runs every ${r.join(", ")}, and ${a} at ${t}`}case"monthly":return`Runs on the ${Cre(e.dayOfMonth)} of every month at ${t}`}}function _B(e){if(!e.trim())return"";try{return wre.toString(e)}catch{return"Invalid cron expression"}}function LVe({value:e,onChange:t}){const n=CB(e),[s,r]=x.useState(n?"simple":e.trim()?"cron":"simple"),[a,o]=x.useState(n??Cp),l=x.useRef(e);x.useEffect(()=>{if(e===l.current)return;l.current=e;const k=CB(e);k?(r("simple"),o(k)):e.trim()&&r("cron")},[e]);function c(k){o(k);const w=EB(k);l.current=w,t(w)}function u(k){c({...a,frequency:k})}function f(k){c({...a,hour:Number(k)})}function h(k){const w=a.days.includes(k);if(w&&a.days.length<=1)return;const C=w?a.days.filter(E=>E!==k):[...a.days,k].sort((E,T)=>E-T);c({...a,days:C})}function m(k){c({...a,dayOfMonth:Number(k)})}function g(){r("cron")}function b(){r("simple");const k=EB(a);l.current=k,t(k)}const v=a.frequency!=="15m"&&a.frequency!=="hourly";return s==="cron"?i.jsxs("div",{className:"space-y-2",children:[i.jsx("button",{type:"button",onClick:b,className:"text-muted-foreground hover:text-foreground text-xs underline-offset-4 hover:underline",children:"Back to simple schedule"}),i.jsx(_n,{className:"font-mono",value:e,onChange:k=>t(k.target.value),placeholder:"0 9 * * 1-5"}),e.trim()&&i.jsx("p",{className:X("text-xs",_B(e)==="Invalid cron expression"?"text-destructive":"text-muted-foreground"),children:_B(e)}),i.jsx("a",{href:"https://crontab.guru",target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground block text-xs hover:underline",children:"Learn about cron expressions"})]}):i.jsxs("div",{className:"space-y-3",children:[i.jsxs(Bn,{value:a.frequency,onValueChange:u,children:[i.jsx(Dn,{responsive:!1,className:"h-9","aria-label":"Frequency",children:i.jsx($n,{})}),i.jsx(On,{children:AVe.map(k=>i.jsx(yt,{value:k.value,children:k.label},k.value))})]}),i.jsx(He,{initial:!1,mode:"wait",children:v&&i.jsx(oe.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:hN,className:"overflow-hidden",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-muted-foreground text-sm",children:"at"}),i.jsxs(Bn,{value:String(a.hour),onValueChange:f,children:[i.jsx(Dn,{responsive:!1,className:"h-9 w-32","aria-label":"Time",children:i.jsx($n,{})}),i.jsx(On,{children:Array.from({length:24},(k,w)=>i.jsx(yt,{value:String(w),children:kre(w)},w))})]})]})},"time")}),i.jsx(He,{initial:!1,children:a.frequency==="weekly"&&i.jsx(oe.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:hN,className:"overflow-hidden",children:i.jsx("div",{className:"flex flex-wrap gap-1.5",children:RVe.map(k=>{const w=a.days.includes(k.value);return i.jsx("button",{type:"button","aria-label":k.label,"aria-pressed":w,className:X("rounded-md border px-2.5 py-1 text-xs font-medium transition-colors",w?"border-primary bg-primary/10 text-primary":"border-input text-muted-foreground hover:bg-accent hover:text-accent-foreground"),onClick:()=>h(k.value),children:k.label},k.value)})})},"days")}),i.jsx(He,{initial:!1,children:a.frequency==="monthly"&&i.jsx(oe.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:hN,className:"overflow-hidden",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-muted-foreground text-sm",children:"on day"}),i.jsxs(Bn,{value:String(a.dayOfMonth),onValueChange:m,children:[i.jsx(Dn,{responsive:!1,className:"h-9 w-20","aria-label":"Day of month",children:i.jsx($n,{})}),i.jsx(On,{children:Array.from({length:31},(k,w)=>i.jsx(yt,{value:String(w+1),children:Cre(w+1)},w+1))})]})]})},"dom")}),i.jsx("p",{className:"text-muted-foreground text-xs",children:PVe(a)}),i.jsx("button",{type:"button",onClick:g,className:"text-muted-foreground hover:text-foreground text-xs underline-offset-4 hover:underline",children:"Use a cron expression"})]})}function FVe(e){const t=new Map;for(const n of e){const[s]=n.split("/");t.has(s)||t.set(s,[]),t.get(s).push(n)}return t}function zVe({value:e,onChange:t}){const[n,s]=x.useState(!1),r=x.useRef(null),a=x.useMemo(()=>{try{return Intl.supportedValuesOf("timeZone")}catch{return[]}},[]),o=x.useMemo(()=>FVe(a),[a]),l=x.useMemo(()=>Intl.DateTimeFormat().resolvedOptions().timeZone,[]);x.useEffect(()=>{if(!n)return;function f(h){r.current&&!r.current.contains(h.target)&&s(!1)}return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[n]);const c=e||"System default";function u(f){t(f),s(!1)}return i.jsxs("div",{ref:r,className:"relative w-full",children:[i.jsxs("button",{type:"button","aria-expanded":n,"aria-haspopup":"listbox",className:X("border-input ring-offset-background flex h-9 w-full items-center justify-between rounded-md border bg-transparent px-3 py-2 text-sm shadow-sm transition-colors","focus-visible:ring-ring focus-visible:ring-1 focus-visible:outline-none","hover:bg-accent/50"),onClick:()=>s(f=>!f),children:[i.jsx("span",{className:"truncate",children:c}),i.jsx(wX,{className:"ml-2 size-4 shrink-0 opacity-50"})]}),n&&i.jsx("div",{className:"bg-popover text-popover-foreground absolute top-full left-0 z-50 mt-1 w-full rounded-md border shadow-md",children:i.jsxs(yC,{children:[i.jsx(bC,{placeholder:"Search timezone..."}),i.jsxs(vC,{className:"max-h-60",children:[i.jsx(SC,{children:"No timezone found."}),i.jsxs(zi,{heading:"Default",children:[i.jsxs(Hr,{value:"system-default",onSelect:()=>u(""),children:[i.jsx("span",{children:"System default"}),e===""&&i.jsx(Zt,{className:"ml-auto size-4"})]}),l&&i.jsxs(Hr,{value:`${l}-detected`,onSelect:()=>u(l),children:[i.jsxs("span",{children:[l," (detected)"]}),e===l&&i.jsx(Zt,{className:"ml-auto size-4"})]})]}),[...o.entries()].map(([f,h])=>i.jsx(zi,{heading:f,children:h.map(m=>i.jsxs(Hr,{value:m,onSelect:()=>u(m),children:[i.jsx("span",{children:m.replace(`${f}/`,"").replace(/_/g," ")}),m===e&&i.jsx(Zt,{className:"ml-auto size-4"})]},m))},f))]})]})})]})}function NB({agents:e,value:t,onSelect:n}){return i.jsxs(yC,{children:[i.jsx(bC,{placeholder:"Search agents..."}),i.jsxs(vC,{className:"!max-h-60 !overflow-y-auto",children:[i.jsx(SC,{children:"No agents found."}),i.jsx(zi,{children:e.map(s=>{const r=Lu(s);return i.jsxs(Hr,{value:`${tn(s)} ${s.name} ${s.projectPath}`,onSelect:()=>n(s.id),children:[i.jsx(db,{color:r.color,emoji:r.emoji,size:"xs"}),i.jsx("span",{className:"truncate font-medium",children:tn(s)}),i.jsx("span",{className:"text-muted-foreground truncate text-xs",children:Pl(s.projectPath)}),s.id===t&&i.jsx(Zt,{className:"ml-auto size-4 shrink-0"})]},s.id)})})]})]})}function jB({selectedAgent:e,open:t,onClick:n}){const s=e?Lu(e):null;return i.jsxs("button",{type:"button","aria-expanded":t,"aria-haspopup":"listbox",className:X("border-input ring-offset-background flex h-9 w-full items-center justify-between rounded-md border bg-transparent px-3 py-2 text-sm shadow-sm transition-colors","focus-visible:ring-ring focus-visible:ring-1 focus-visible:outline-none","hover:bg-accent/50"),onClick:n,children:[e?i.jsxs("span",{className:"flex items-center gap-2 truncate",children:[i.jsx(db,{color:s.color,emoji:s.emoji,size:"xs"}),i.jsx("span",{className:"truncate",children:tn(e)})]}):i.jsx("span",{className:"text-muted-foreground",children:"Select an agent..."}),i.jsx(wX,{className:"ml-2 size-4 shrink-0 opacity-50"})]})}function Ere({agents:e,value:t,onValueChange:n}){const[s,r]=x.useState(!1),a=Zs(),o=x.useRef(null);x.useEffect(()=>{if(!s||a)return;function u(f){o.current&&!o.current.contains(f.target)&&r(!1)}return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[s,a]);const l=e.find(u=>u.id===t);function c(u){n(u===t?void 0:u),r(!1)}return e.length===0?i.jsxs("div",{className:"rounded-md border px-4 py-6 text-center",children:[i.jsx("p",{className:"text-muted-foreground text-sm",children:"No agents registered yet"}),i.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:"Register an agent via the Mesh panel to schedule automated tasks."})]}):a?i.jsxs(i.Fragment,{children:[i.jsx(jB,{selectedAgent:l,open:s,onClick:()=>r(!0)}),i.jsx(ih,{open:s,onOpenChange:r,children:i.jsxs(oh,{children:[i.jsx(Zy,{children:i.jsx(Xy,{children:"Select an agent"})}),i.jsx("div",{className:"px-4 pb-4",children:i.jsx(NB,{agents:e,value:t,onSelect:c})})]})})]}):i.jsxs("div",{ref:o,className:"relative w-full",children:[i.jsx(jB,{selectedAgent:l,open:s,onClick:()=>r(u=>!u)}),s&&i.jsx("div",{className:"bg-popover text-popover-foreground absolute top-full left-0 z-50 mt-1 w-full rounded-md border shadow-md",children:i.jsx(NB,{agents:e,value:t,onSelect:c})})]})}const pN="10m",BVe=100;function $Ve(e){return`${Math.round(e/6e4)}m`}function Dd(e,t,n){return e?{name:e.name,description:e.description??"",prompt:e.prompt,cron:e.cron??"",agentId:e.agentId??"",timezone:e.timezone??"",permissionMode:e.permissionMode==="bypassPermissions"?"bypassPermissions":"acceptEdits",maxRuntime:e.maxRuntime?$Ve(e.maxRuntime):pN}:t?{name:t.name,description:t.description,prompt:t.prompt,cron:t.cron,agentId:n??"",timezone:t.timezone??"",permissionMode:"acceptEdits",maxRuntime:pN}:{name:"",description:"",prompt:"",cron:"",agentId:n??"",timezone:"",permissionMode:"acceptEdits",maxRuntime:pN}}function HVe({defaultValues:e,agents:t,editTask:n,onSubmitSuccess:s,onCancel:r,onDeleteClick:a,isPending:o}){const l=Q5(),c=J5(),u=eC({defaultValues:e,onSubmit:({value:f})=>{const h=f.agentId.trim()||void 0,m=f.cron.trim();if(n){const g={name:f.name.trim(),description:f.description.trim(),prompt:f.prompt.trim(),cron:m||null,...m&&f.timezone?{timezone:f.timezone}:{},permissionMode:f.permissionMode,maxRuntime:f.maxRuntime.trim()||void 0};c.mutate({id:n.id,...g},{onSuccess:s})}else{const g=h??"global",b={name:f.name.trim(),description:f.description.trim()||f.name.trim(),prompt:f.prompt.trim(),target:g,cron:m||void 0,...m&&f.timezone?{timezone:f.timezone}:{},permissionMode:f.permissionMode,maxRuntime:f.maxRuntime.trim()||void 0};l.mutate(b,{onSuccess:s})}}});return i.jsxs(u.AppForm,{children:[i.jsx("form",{onSubmit:f=>{f.preventDefault(),u.handleSubmit()},id:"schedule-form",className:"min-h-0 flex-1 overflow-y-auto",children:i.jsxs("div",{className:"space-y-5 px-4 py-5",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(jn,{children:"Agent"}),i.jsx(u.AppField,{name:"agentId",children:f=>i.jsx(Ere,{agents:t,value:f.state.value||void 0,onValueChange:h=>f.handleChange(h??"")})})]}),i.jsx(u.AppField,{name:"name",children:f=>i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(jn,{htmlFor:"schedule-name",children:"Name *"}),i.jsx("input",{id:"schedule-name",className:"border-input focus-visible:ring-ring w-full rounded-md border bg-transparent px-3 py-2 text-sm shadow-sm focus-visible:ring-1 focus-visible:outline-none",value:f.state.value,onChange:h=>f.handleChange(h.target.value),onBlur:f.handleBlur,maxLength:BVe,placeholder:"Daily code review"}),f.state.meta.isTouched&&f.state.meta.errors.length>0&&i.jsx("p",{className:"text-destructive text-xs",children:String(f.state.meta.errors[0])})]})}),i.jsx(u.AppField,{name:"description",children:f=>i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(jn,{htmlFor:"schedule-description",children:"Description *"}),i.jsx("input",{id:"schedule-description",className:"border-input focus-visible:ring-ring w-full rounded-md border bg-transparent px-3 py-2 text-sm shadow-sm focus-visible:ring-1 focus-visible:outline-none",value:f.state.value,onChange:h=>f.handleChange(h.target.value),onBlur:f.handleBlur,placeholder:"A short description of this schedule"}),f.state.meta.isTouched&&f.state.meta.errors.length>0&&i.jsx("p",{className:"text-destructive text-xs",children:String(f.state.meta.errors[0])})]})}),i.jsx(u.AppField,{name:"prompt",children:f=>i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(jn,{htmlFor:"schedule-prompt",children:"Prompt *"}),i.jsx("textarea",{id:"schedule-prompt",className:"border-input focus-visible:ring-ring w-full rounded-md border bg-transparent px-3 py-2 text-sm shadow-sm focus-visible:ring-1 focus-visible:outline-none",value:f.state.value,onChange:h=>f.handleChange(h.target.value),onBlur:f.handleBlur,rows:4,placeholder:"Review all pending PRs and summarize findings..."}),f.state.meta.isTouched&&f.state.meta.errors.length>0&&i.jsx("p",{className:"text-destructive text-xs",children:String(f.state.meta.errors[0])})]})}),i.jsxs("details",{className:"group",open:!!e.cron,children:[i.jsxs("summary",{className:"text-muted-foreground hover:text-foreground flex cursor-pointer list-none items-center gap-1.5 text-sm",children:[i.jsx(Ws,{className:"size-4 transition-transform group-open:rotate-90"}),"Schedule",i.jsx("span",{className:"text-muted-foreground/60 text-xs",children:"(optional)"})]}),i.jsxs("div",{className:"mt-3 space-y-4 pl-6",children:[i.jsx(u.AppField,{name:"cron",children:f=>i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(jn,{children:"Cron Expression"}),i.jsx(LVe,{value:f.state.value,onChange:h=>f.handleChange(h)})]})}),i.jsx(u.AppField,{name:"timezone",children:f=>i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(jn,{children:"Timezone"}),i.jsx(zVe,{value:f.state.value,onChange:h=>f.handleChange(h)})]})})]})]}),i.jsxs("details",{className:"group",children:[i.jsxs("summary",{className:"text-muted-foreground hover:text-foreground flex cursor-pointer list-none items-center gap-1.5 text-sm",children:[i.jsx(Ws,{className:"size-4 transition-transform group-open:rotate-90"}),"Advanced settings"]}),i.jsxs("div",{className:"mt-3 space-y-4 pl-6",children:[i.jsx(u.AppField,{name:"permissionMode",children:f=>i.jsxs("fieldset",{className:"space-y-2",children:[i.jsx("legend",{className:"mb-1.5 text-sm font-medium",children:"Permission Mode"}),i.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[i.jsx("input",{type:"radio",name:"permissionMode",checked:f.state.value==="acceptEdits",onChange:()=>f.handleChange("acceptEdits")}),"Allow file edits"]}),i.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[i.jsx("input",{type:"radio",name:"permissionMode",checked:f.state.value==="bypassPermissions",onChange:()=>f.handleChange("bypassPermissions")}),"Full autonomy"]}),f.state.value==="bypassPermissions"&&i.jsx("p",{className:"text-xs text-yellow-600 dark:text-yellow-400",children:"Warning: This allows the agent to execute any tool without approval."})]})}),i.jsx(u.AppField,{name:"maxRuntime",children:f=>i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(jn,{htmlFor:"schedule-max-runtime",children:"Max Runtime"}),i.jsx("input",{id:"schedule-max-runtime",className:"border-input focus-visible:ring-ring w-24 rounded-md border bg-transparent px-3 py-2 text-sm shadow-sm focus-visible:ring-1 focus-visible:outline-none",value:f.state.value,onChange:h=>f.handleChange(h.target.value),onBlur:f.handleBlur,placeholder:"10m"})]})})]})]})]})}),i.jsxs(Qy,{className:"shrink-0 border-t px-4 py-3",children:[n&&i.jsxs(ve,{type:"button",variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive mr-auto",onClick:a,children:[i.jsx(Yf,{className:"mr-1.5 size-4"}),"Delete"]}),i.jsx(ve,{variant:"ghost",size:"sm",onClick:r,children:"Cancel"}),i.jsx(u.Subscribe,{selector:f=>f.values.name.trim()!==""&&f.values.prompt.trim()!=="",children:f=>i.jsx(ve,{type:"submit",size:"sm",form:"schedule-form",disabled:!f||o,children:o?"Saving...":n?"Save":"Create"})})]})]})}function qR({open:e,onOpenChange:t,editTask:n,initialPreset:s,initialAgentId:r}){const a=ure(),o=J5(),l=Q5(),{data:c}=hb(),u=(c==null?void 0:c.agents)??[],[f,h]=x.useState(()=>n?"form":"preset-picker"),[m,g]=x.useState(null),[b,v]=x.useState(!1),[k,w]=x.useState((n==null?void 0:n.enabled)??!0),[C,E]=x.useState(()=>Dd(n,void 0,r)),[T,_]=x.useState(0);function j(K){E(K),_(U=>U+1)}x.useEffect(()=>{if(!e){j(Dd(n,void 0,r)),g(null),v(!1),h(n?"form":"preset-picker");return}n?(j(Dd(n)),w(n.enabled),h("form")):s?(j(Dd(void 0,s,r)),g(s),h("form")):(j(Dd(void 0,void 0,r)),h("preset-picker"))},[n,e,s,r]);const{pendingTemplate:R,externalTrigger:D,clear:I}=ub();x.useEffect(()=>{D&&R&&(j(Dd(void 0,R,r)),g(R),h("form"),I())},[D,R,I,r]);function O(K){j(Dd(void 0,K,r)),g(K),h("form")}function L(){n&&a.mutate(n.id,{onSuccess:()=>{v(!1),t(!1)}})}function B(K){n&&(w(K),o.mutate({id:n.id,enabled:K}))}const H=l.isPending||o.isPending;return i.jsxs(Ta,{open:e,onOpenChange:t,children:[i.jsxs(_a,{className:"flex max-h-[85vh] max-w-lg flex-col gap-0 p-0",children:[i.jsxs(Ni,{className:"shrink-0 border-b px-4 py-3",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[f==="form"&&!n&&i.jsxs("button",{type:"button",onClick:()=>h("preset-picker"),className:"text-muted-foreground hover:text-foreground flex items-center gap-1 text-sm","aria-label":"Back to preset picker",children:[i.jsx(Kk,{className:"size-4"}),"Back"]}),i.jsx(ei,{children:n?"Edit Schedule":"New Schedule"}),n&&i.jsx(Ks,{className:"ml-auto",checked:k,onCheckedChange:B,"aria-label":k?"Disable schedule":"Enable schedule"})]}),i.jsx(Ji,{className:"sr-only",children:n?"Edit an existing Tasks schedule":"Create a new Tasks schedule"})]}),f==="preset-picker"&&i.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:i.jsxs("div",{className:"space-y-4 px-4 py-5",children:[i.jsx("p",{className:"text-muted-foreground text-sm",children:"Start from a template"}),i.jsx(Sre,{onSelect:O,selectedId:m==null?void 0:m.id}),i.jsx("button",{type:"button",onClick:()=>{g(null),h("form")},className:"text-muted-foreground hover:text-foreground w-full text-center text-sm transition-colors",children:"Start from scratch"})]})}),f==="form"&&i.jsx(HVe,{defaultValues:C,agents:u,editTask:n,onSubmitSuccess:()=>t(!1),onCancel:()=>t(!1),onDeleteClick:()=>v(!0),isPending:H},T)]}),n&&i.jsx(ah,{open:b,onOpenChange:v,children:i.jsxs(Gu,{children:[i.jsxs(Ku,{children:[i.jsx(Wu,{children:"Delete schedule"}),i.jsxs(Yu,{children:["Delete “",n.name,"”? This will also remove all run history. This action cannot be undone."]})]}),i.jsxs(Zm,{children:[i.jsx("button",{onClick:()=>v(!1),className:"border-input hover:bg-accent hover:text-accent-foreground inline-flex items-center rounded-md border bg-transparent px-3 py-1.5 text-sm font-medium shadow-sm transition-colors",children:"Cancel"}),i.jsx("button",{onClick:L,disabled:a.isPending,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90 inline-flex items-center rounded-md px-3 py-1.5 text-sm font-medium shadow-sm transition-colors",children:a.isPending?"Deleting...":"Delete"})]})]})})]})}function Tre({onCreateWithPreset:e,onCreateBlank:t}){return i.jsxs("div",{className:"flex flex-col items-center justify-center px-6 py-8 md:py-12",children:[i.jsx("h3",{className:"mb-2 text-lg font-medium",children:"No schedules yet."}),i.jsx("p",{className:"text-muted-foreground mb-6 max-w-sm text-center text-sm",children:"Automate your workflows with Tasks."}),i.jsx("div",{className:"w-full max-w-lg",children:i.jsx(Sre,{onSelect:e})}),i.jsx(ve,{variant:"ghost",className:"mt-4",onClick:t,children:"New custom schedule"})]})}function UVe(e){if(e===null)return"-";if(e<1e3)return"< 1s";const t=Math.floor(e/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60),s=t%60;return`${n}m ${s}s`}function AB(e,t=80){const n=e.split(`
|
|
1043
|
-
`)[0]??"";return n.length>t?`${n.slice(0,t)}…`:n}function GR(e){return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",hour12:!0})}function VVe({status:e}){switch(e){case"running":return i.jsx("span",{title:"Running","aria-label":"Running",children:i.jsx(Xn,{className:"size-3.5 animate-spin text-blue-500"})});case"completed":return i.jsx("span",{title:"Completed","aria-label":"Completed",children:i.jsx(qf,{className:"size-3.5 text-green-500"})});case"failed":return i.jsx("span",{title:"Failed","aria-label":"Failed",children:i.jsx(Vm,{className:"text-destructive size-3.5"})});case"cancelled":return i.jsx("span",{title:"Cancelled","aria-label":"Cancelled",children:i.jsx(kX,{className:"text-muted-foreground size-3.5"})});default:return null}}function qVe({trigger:e}){return e==="scheduled"?i.jsx(Ja,{className:"text-muted-foreground/70 mr-1 inline size-3 shrink-0","aria-hidden":"true"}):e==="manual"?i.jsx(q1,{className:"text-muted-foreground/70 mr-1 inline size-3 shrink-0","aria-hidden":"true"}):null}function GVe({date:e}){const t=new Date,n=new Date(e),s=new Date(t);s.setDate(s.getDate()-7);const r=n>=s,a=r?uu(e):GR(e),o=r?GR(e):uu(e);return i.jsx("time",{dateTime:e,title:o,children:a})}function mN(){return i.jsxs("div",{className:"grid grid-cols-[20px_56px_1fr_64px_72px_20px] items-center gap-2 rounded-md px-2 py-2",children:[i.jsx(on,{className:"size-3.5 rounded-full"}),i.jsx(on,{className:"h-3 w-10"}),i.jsx(on,{className:"h-3 w-24"}),i.jsx(on,{className:"h-3 w-8"}),i.jsx("span",{}),i.jsx("span",{})]})}function KVe({run:e,onNavigate:t,onCancel:n,isCancelling:s}){const r=!!e.sessionId;function a(){e.sessionId&&t(e.sessionId)}function o(c){c.stopPropagation(),n(e.id)}const l=e.startedAt?GR(e.startedAt):"unknown time";return i.jsxs("div",{role:r?"button":void 0,tabIndex:r?0:void 0,"aria-label":r?`View ${e.status} run from ${l}`:void 0,onClick:r?a:void 0,onKeyDown:r?c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),a())}:void 0,className:X("grid grid-cols-[20px_56px_1fr_64px_72px_20px] items-center gap-2","rounded-md border border-transparent px-2 py-2 text-xs transition-colors",r&&["hover:bg-muted/50 hover:border-border cursor-pointer","focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:outline-none"],e.status==="failed"&&"bg-destructive/5"),children:[i.jsx(VVe,{status:e.status}),i.jsxs("span",{className:"text-muted-foreground truncate capitalize",children:[i.jsx(qVe,{trigger:e.trigger}),e.trigger]}),i.jsxs("span",{className:"flex min-w-0 flex-col gap-0.5",children:[i.jsx("span",{className:"text-foreground",children:e.startedAt?i.jsx(GVe,{date:e.startedAt}):"-"}),e.outputSummary&&i.jsx("span",{className:"text-muted-foreground truncate",title:e.outputSummary,children:AB(e.outputSummary)}),e.status==="failed"&&e.error&&i.jsx("span",{className:"text-destructive truncate",title:e.error,children:AB(e.error)})]}),i.jsx("span",{className:"text-muted-foreground",children:UVe(e.durationMs)}),i.jsx("span",{children:e.status==="running"&&i.jsx("button",{type:"button",disabled:s,onClick:o,className:X("inline-flex items-center rounded px-1.5 py-0.5 text-xs font-medium","text-muted-foreground transition-colors","hover:bg-accent hover:text-accent-foreground","focus-visible:ring-ring focus-visible:ring-2 focus-visible:outline-none","disabled:pointer-events-none disabled:opacity-50"),children:"Cancel"})}),i.jsx("span",{className:"flex items-center justify-end",children:r&&i.jsx(Ws,{className:"text-muted-foreground/50 size-3.5","aria-hidden":"true"})})]})}const gN=20;function WVe({scheduleId:e,scheduleCwd:t}){const[n,s]=x.useState("all"),[r,a]=x.useState(0),[o,l]=x.useState([]),c=n==="all"?void 0:n,{data:u=[],isLoading:f}=fg({scheduleId:e,status:c,limit:gN,offset:r}),h=dre(),[,m]=Jf(),[g,b]=eh(),v=x.useMemo(()=>r===0?u:[...o,...u],[r,u,o]),k=x.useCallback(()=>{l(v),a(E=>E+gN)},[v]),w=x.useCallback(E=>{s(E),a(0),l([])},[]),C=x.useCallback(E=>{t&&t!==g&&b(t,{preserveSession:!0}),m(E)},[t,g,b,m]);return f&&v.length===0?i.jsxs("div",{className:"space-y-0.5","aria-label":"Loading runs...",children:[i.jsx(mN,{}),i.jsx(mN,{}),i.jsx(mN,{})]}):v.length===0&&!f?i.jsxs("div",{className:"space-y-2",children:[i.jsx(RB,{value:n,onChange:w}),i.jsx("p",{className:"text-muted-foreground py-4 text-center text-xs",children:n==="all"?"No runs yet":`No ${n} runs`})]}):i.jsxs("div",{className:"space-y-0.5",children:[i.jsx(RB,{value:n,onChange:w}),i.jsxs("div",{className:"sm:text-muted-foreground hidden sm:grid sm:grid-cols-[20px_56px_1fr_64px_72px_20px] sm:gap-2 sm:px-2 sm:pb-1 sm:text-xs sm:font-medium",children:[i.jsx("span",{}),i.jsx("span",{children:"Trigger"}),i.jsx("span",{children:"Started"}),i.jsx("span",{children:"Duration"}),i.jsx("span",{}),i.jsx("span",{})]}),v.map(E=>i.jsx(KVe,{run:E,onNavigate:C,onCancel:T=>h.mutate(T,{onSuccess:()=>rt("Run cancelled"),onError:_=>rt.error(`Failed to cancel: ${_ instanceof Error?_.message:"Unknown error"}`)}),isCancelling:h.isPending},E.id)),u.length===gN&&i.jsx("button",{type:"button",onClick:k,disabled:f,className:"text-muted-foreground hover:bg-muted/50 hover:text-foreground mt-1 w-full rounded-md py-1.5 text-xs transition-colors disabled:opacity-50",children:f?"Loading...":"Load more"})]})}function RB({value:e,onChange:t}){return i.jsx("div",{className:"mb-1 flex items-center gap-2",children:i.jsxs(Bn,{value:e,onValueChange:t,children:[i.jsx(Dn,{responsive:!1,className:"h-7 w-[130px] text-xs",children:i.jsx($n,{placeholder:"Filter status"})}),i.jsxs(On,{children:[i.jsx(yt,{value:"all",children:"All"}),i.jsx(yt,{value:"running",children:"Running"}),i.jsx(yt,{value:"completed",children:"Completed"}),i.jsx(yt,{value:"failed",children:"Failed"}),i.jsx(yt,{value:"cancelled",children:"Cancelled"})]})]})})}function YVe(e){try{return wre.toString(e)}catch{return e}}function ZVe({task:e}){const t=e.status==="pending_approval"?"bg-yellow-500":e.enabled?"bg-green-500":"bg-neutral-400";return i.jsx("span",{className:X("inline-block size-2 rounded-full",t)})}function _re({task:e,agent:t,expanded:n,onToggleExpand:s,onEdit:r,size:a="default",showAgent:o=!0}){const l=J5(),c=ZUe(),u=ure(),[f,h]=x.useState(!1),m=t?Lu(t):null,g=a==="minimal",b=a==="compact",v=a==="default",k=o&&!g,w=!g,C=v,E=(t==null?void 0:t.isSystem)===!0,T=D=>{D.stopPropagation(),c.mutate(e.id,{onSuccess:()=>rt("Run triggered"),onError:I=>rt.error(`Failed to trigger run: ${I.message}`)})},_=D=>{D.stopPropagation(),l.mutate({id:e.id,status:"active",enabled:!0},{onSuccess:()=>rt("Schedule approved"),onError:I=>rt.error(`Failed to approve: ${I.message}`)})},j=D=>{D.stopPropagation(),u.mutate(e.id,{onError:I=>rt.error(`Failed to reject: ${I.message}`)})},R=()=>{u.mutate(e.id,{onSuccess:()=>h(!1),onError:D=>rt.error(`Failed to delete: ${D.message}`)})};return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"rounded-lg border",children:[i.jsxs("div",{role:"button",tabIndex:0,className:"flex cursor-pointer items-center gap-3 p-3",onClick:s,onKeyDown:D=>(D.key==="Enter"||D.key===" ")&&s(),children:[i.jsx(ZVe,{task:e}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsxs("div",{className:"flex items-center gap-1.5",children:[k&&t?i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"inline-block size-2 shrink-0 rounded-full",style:{backgroundColor:m.color}}),i.jsx("span",{className:"text-xs leading-none",children:m.emoji}),i.jsx("span",{className:"text-sm font-medium",children:tn(t)}),E&&i.jsxs(Ot,{variant:"outline",className:"px-1 py-0 text-[10px] leading-tight",children:[i.jsx(Ho,{className:"mr-0.5 size-2.5"}),"System"]}),i.jsx("span",{className:"text-muted-foreground text-xs",children:"·"})]}):k&&e.agentId?i.jsxs(i.Fragment,{children:[i.jsx(Wk,{className:"text-destructive size-3.5 shrink-0"}),i.jsx("span",{className:"text-destructive text-xs",children:"Agent not found"}),i.jsx("span",{className:"text-muted-foreground text-xs",children:"·"})]}):null,i.jsx("span",{className:k&&(t||e.agentId)?"text-muted-foreground text-xs":"text-sm font-medium",children:e.displayName??e.name})]}),w&&i.jsxs("div",{className:"text-muted-foreground text-xs",children:[e.cron?YVe(e.cron):"On-demand",e.nextRun&&i.jsxs(i.Fragment,{children:[" · Next: ",new Date(e.nextRun).toLocaleString()]})]})]}),!g&&e.status==="pending_approval"?i.jsxs("div",{className:"flex gap-1",children:[i.jsx("button",{className:"border-input hover:bg-accent hover:text-accent-foreground inline-flex items-center rounded-md border bg-transparent px-2.5 py-1 text-xs font-medium shadow-sm transition-colors",onClick:_,children:"Approve"}),i.jsx("button",{className:"hover:bg-accent hover:text-accent-foreground inline-flex items-center rounded-md px-2.5 py-1 text-xs font-medium transition-colors",onClick:j,children:"Reject"})]}):b?i.jsxs("button",{className:"border-input hover:bg-accent hover:text-accent-foreground inline-flex items-center gap-1 rounded-md border bg-transparent px-2 py-1 text-xs font-medium shadow-sm transition-colors",onClick:T,"aria-label":`Run ${e.name}`,children:[i.jsx(q1,{className:"size-3"}),"Run"]}):v?i.jsxs("div",{className:"flex items-center gap-2",children:[e.cron?i.jsx(Ks,{checked:e.enabled,onCheckedChange:D=>{l.mutate({id:e.id,enabled:D})},onClick:D=>D.stopPropagation(),"aria-label":`Toggle ${e.name}`}):i.jsxs("button",{className:"border-input hover:bg-accent hover:text-accent-foreground inline-flex items-center gap-1 rounded-md border bg-transparent px-2 py-1 text-xs font-medium shadow-sm transition-colors",onClick:T,"aria-label":`Run ${e.name}`,children:[i.jsx(q1,{className:"size-3"}),"Run"]}),i.jsxs(Xm,{children:[i.jsx(Qm,{asChild:!0,children:i.jsx("button",{className:"text-muted-foreground hover:text-foreground rounded-md p-1 transition-colors","aria-label":`Actions for ${e.name}`,onClick:D=>D.stopPropagation(),children:i.jsx(TX,{className:"size-4"})})}),i.jsxs(lh,{align:"end",children:[i.jsxs(Nr,{onClick:()=>r(),children:[i.jsx(J3,{className:"mr-2 size-3.5"}),"Edit"]}),i.jsxs(Nr,{onClick:T,disabled:!e.enabled,children:[i.jsx(q1,{className:"mr-2 size-3.5"}),"Run Now"]}),i.jsx(df,{}),i.jsxs(Nr,{onClick:D=>{D.stopPropagation(),h(!0)},className:"text-destructive focus:text-destructive",children:[i.jsx(Yf,{className:"mr-2 size-3.5"}),"Delete"]})]})]})]}):null]}),i.jsx(He,{initial:!1,children:n&&C&&i.jsx(oe.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.3,ease:[.4,0,.2,1]},className:"overflow-hidden",children:i.jsxs("div",{className:"border-t px-3 pt-2 pb-3",children:[e.filePath&&i.jsx("p",{className:"text-muted-foreground mb-2 truncate font-mono text-[11px]",children:Pl(e.filePath)}),i.jsx(WVe,{scheduleId:e.id,scheduleCwd:null})]})})})]}),v&&i.jsx(ah,{open:f,onOpenChange:h,children:i.jsxs(Gu,{children:[i.jsxs(Ku,{children:[i.jsx(Wu,{children:"Delete task"}),i.jsxs(Yu,{children:["Delete “",e.name,"”? This will also remove all run history. This action cannot be undone."]})]}),i.jsxs(Zm,{children:[i.jsx("button",{onClick:()=>h(!1),className:"border-input hover:bg-accent hover:text-accent-foreground inline-flex items-center rounded-md border bg-transparent px-3 py-1.5 text-sm font-medium shadow-sm transition-colors",children:"Cancel"}),i.jsx("button",{onClick:R,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90 inline-flex items-center rounded-md px-3 py-1.5 text-sm font-medium shadow-sm transition-colors",children:"Delete"})]})]})})]})}function XVe(){const e=td(),{data:t=[],isLoading:n}=XC(e),[s,r]=x.useState(!1),[a,o]=x.useState(),[l,c]=x.useState(null),[u,f]=x.useState(null),h=je(D=>D.tasksAgentFilter),m=je(D=>D.setTasksAgentFilter),g=je(D=>D.tasksEditScheduleId),b=je(D=>D.setTasksEditScheduleId),v=h?t.filter(D=>D.agentId===h):t,k=t.some(D=>D.agentId),{data:w}=ji(void 0,k),C=x.useMemo(()=>{const D=new Map;for(const I of(w==null?void 0:w.agents)??[])D.set(I.id,I);return D},[w]);x.useEffect(()=>{if(!g||n)return;const D=t.find(I=>I.id===g);D&&(o(D),r(!0)),b(null)},[g,t,n,b]);const E=x.useMemo(()=>{var D;return h?((D=C.get(h))==null?void 0:D.name)??h:null},[h,C]),{externalTrigger:T}=ub();x.useEffect(()=>{T&&(o(void 0),r(!0))},[T]);const _=D=>{f(D),o(void 0),r(!0)},j=()=>{f(null),o(void 0),r(!0)},R=D=>{r(D),D||f(null)};return e?n?i.jsx("div",{className:"space-y-2 p-4",children:[1,2,3].map(D=>i.jsx("div",{className:"rounded-lg border p-3",children:i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"bg-muted animate-tasks size-2 rounded-full"}),i.jsxs("div",{className:"flex-1 space-y-1.5",children:[i.jsx("div",{className:"bg-muted animate-tasks h-4 w-32 rounded"}),i.jsx("div",{className:"bg-muted animate-tasks h-3 w-48 rounded"})]})]})},D))}):v.length===0?i.jsxs(i.Fragment,{children:[h?i.jsxs("div",{className:"flex flex-col items-center gap-3 p-8",children:[i.jsx(MB,{name:E,onClear:()=>m(null)}),i.jsx("p",{className:"text-muted-foreground text-sm",children:"No schedules for this agent."}),i.jsx("button",{onClick:j,className:"border-input hover:bg-accent hover:text-accent-foreground inline-flex items-center rounded-md border bg-transparent px-3 py-1.5 text-sm font-medium shadow-sm transition-colors",children:"New Schedule"})]}):i.jsx(Tre,{onCreateWithPreset:_,onCreateBlank:j}),i.jsx(qR,{open:s,onOpenChange:R,editTask:a,initialPreset:u,initialAgentId:h??void 0})]}):i.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[i.jsx("div",{className:"space-y-2 p-4",children:i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("h3",{className:"text-muted-foreground text-sm font-medium",children:"Schedules"}),h&&i.jsx(MB,{name:E,onClear:()=>m(null)})]}),i.jsx("button",{onClick:()=>{o(void 0),r(!0)},className:"border-input hover:bg-accent hover:text-accent-foreground inline-flex items-center rounded-md border bg-transparent px-3 py-1.5 text-sm font-medium shadow-sm transition-colors",children:"New Schedule"})]})}),i.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-4 pb-4",children:i.jsx(He,{initial:!1,children:v.map(D=>i.jsx(oe.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,y:-8},transition:{duration:.2,ease:[0,0,.2,1]},className:"mb-2",children:i.jsx(_re,{task:D,agent:D.agentId?C.get(D.agentId)??null:null,expanded:l===D.id,onToggleExpand:()=>c(l===D.id?null:D.id),onEdit:()=>{o(D),r(!0)}})},D.id))})}),i.jsx(qR,{open:s,onOpenChange:r,editTask:a,initialPreset:u,initialAgentId:h??void 0})]}):i.jsx(a5,{icon:mre.tasks,name:"Tasks",description:"Tasks runs AI agent tasks on a schedule. Start DorkOS with the --tasks flag to enable it.",command:"dorkos --tasks"})}function MB({name:e,onClear:t}){return i.jsxs("span",{className:"text-muted-foreground inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-xs",children:[e??"Agent",i.jsx("button",{type:"button",onClick:t,className:"hover:text-foreground -mr-0.5 rounded-full p-0.5 transition-colors","aria-label":"Clear agent filter",children:i.jsx(ls,{className:"size-3"})})]})}const DB=WX({search:GX({fields:[e=>e.name,e=>e.description??"",e=>e.prompt]}),agent:Kp({field:e=>e.agentId,options:[],dynamic:!0,label:"Agent"}),status:Kp({field:e=>e.status==="pending_approval"?"pending_approval":e.enabled?"active":"paused",options:["active","paused","pending_approval"],multi:!0,label:"Status",labels:{active:"Active",paused:"Paused",pending_approval:"Pending Approval"},colors:{active:"text-emerald-400",paused:"text-muted-foreground",pending_approval:"text-amber-400"}}),type:Kp({field:e=>e.cron?"scheduled":"on-demand",options:["scheduled","on-demand"],label:"Type",labels:{scheduled:"Scheduled","on-demand":"On-demand"}})}),OB={name:{label:"Name",accessor:e=>e.name},lastRun:{label:"Last run",accessor:e=>e.updatedAt,direction:"desc"},nextRun:{label:"Next run",accessor:e=>e.nextRun??null},status:{label:"Status",accessor:e=>e.status==="pending_approval"?"pending_approval":e.enabled?"active":"paused"}},QVe=8,JVe={visible:{transition:{staggerChildren:.04}},hidden:{}},eqe={hidden:{opacity:0,y:8},visible:{opacity:1,y:0}};function tqe({tasks:e,isLoading:t,agentMap:n,onEditTask:s,agentId:r}){const a=eQ(DB,{debounce:{search:200}}),[o]=x.useState(0),[l,c]=x.useState(null),u=x.useMemo(()=>r?e.filter(m=>m.agentId===r):e,[e,r]),f=x.useMemo(()=>[...new Set(u.map(m=>m.agentId).filter(m=>!!m))],[u]),h=x.useMemo(()=>KX(u,DB,a.values,OB,{field:a.sortField,direction:a.sortDirection}),[u,a.values,a.sortField,a.sortDirection]);return t?i.jsx("div",{className:"space-y-3 p-4",children:Array.from({length:3}).map((m,g)=>i.jsx(on,{className:"h-14 w-full rounded-xl"},g))}):i.jsxs("div",{className:"flex h-full flex-col overflow-hidden",children:[i.jsxs(xa,{state:a,children:[i.jsx(xa.Search,{placeholder:"Filter tasks..."}),i.jsx(xa.Primary,{name:"status"}),i.jsx(xa.AddFilter,{dynamicOptions:{agent:f}}),i.jsx(xa.Sort,{options:OB}),i.jsx(xa.ResultCount,{count:h.length,total:u.length,noun:"task"}),i.jsx(xa.ActiveFilters,{})]}),i.jsx(so,{className:"min-h-0 flex-1",children:i.jsx("div",{className:"space-y-2 p-4 pt-0",children:h.length===0&&u.length>0?i.jsxs(oe.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.3,ease:"easeOut"},className:"flex flex-col items-center justify-center gap-3 py-12 text-center",children:[i.jsx(BX,{className:"text-muted-foreground/50 size-10"}),i.jsx("p",{className:"text-muted-foreground text-sm",children:a.describeActive()?`No tasks match ${a.describeActive()}`:"No tasks match your filters"}),i.jsx(ve,{variant:"outline",size:"sm",onClick:a.clearAll,children:"Clear filters"})]}):i.jsx(oe.div,{initial:"hidden",animate:"visible",variants:JVe,className:"space-y-2",children:h.map((m,g)=>i.jsx(oe.div,{variants:g<QVe?eqe:void 0,transition:{duration:.15},children:i.jsx(_re,{task:m,agent:(m.agentId?n.get(m.agentId):void 0)??null,expanded:l===m.id,onToggleExpand:()=>c(l===m.id?null:m.id),onEdit:()=>s(m)})},m.id))},o)})})]})}function nqe({totalSteps:e,currentStep:t,onBack:n,onSkip:s,onSkipAll:r}){const a=x.useId();return i.jsxs("div",{className:"grid grid-cols-3 items-center px-4 py-3 sm:px-6",children:[i.jsx(ve,{variant:"ghost",size:"sm",onClick:n,className:"justify-self-start",children:"Back"}),i.jsx("div",{className:"flex items-center justify-center gap-2",children:Array.from({length:e},(o,l)=>i.jsx("div",{className:"relative flex items-center justify-center",children:l===t?i.jsx(oe.div,{layoutId:`step-indicator-${a}`,className:"bg-primary flex h-2 w-6 items-center justify-center rounded-full",transition:{type:"spring",damping:25,stiffness:200}}):l<t?i.jsx("div",{className:"bg-primary/60 flex size-2 items-center justify-center rounded-full",children:i.jsx(Zt,{className:"text-primary-foreground size-1.5"})}):i.jsx("div",{className:X("ring-muted-foreground/30 size-2 rounded-full ring-1")})},l))}),i.jsxs("div",{className:"flex items-center justify-end gap-1",children:[i.jsx(ve,{variant:"ghost",size:"sm",onClick:s,children:"Skip"}),i.jsx(ve,{variant:"ghost",size:"sm",onClick:r,className:"text-muted-foreground",children:"Skip all"})]})]})}const sqe={default:"#1A1A1A",white:"#FFFFFF",orange:"#CE2021",current:"currentColor"};function _m({variant:e="default",size:t=40,className:n,style:s}){const r=sqe[e],a=t*(799/2325);return i.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:a,viewBox:"0 0 2325 799",fill:"none",className:n,style:s,"aria-hidden":"true",children:[i.jsx("rect",{x:"50",y:"50",width:"2225",height:"699",stroke:r,strokeWidth:"100"}),i.jsx("path",{d:"M492.333 199.627L599.833 295.627L600 295.776V491.707L492.207 599.5H199.5V199.5H492.19L492.333 199.627ZM334 347.5V448.5H435V347.5H334Z",fill:r}),i.jsx("path",{d:"M1108.5 497.715L1108.34 497.862L1001.34 599.362L1001.2 599.5H699V296.283L699.158 296.135L802.158 199.635L802.303 199.5H1108.5V497.715ZM855 347.5V448.5H956V347.5H855Z",fill:r}),i.jsx("path",{d:"M1616.94 200.24L1510.07 395.005L1616.94 598.768L1617.64 600.103L1616.28 599.451L1409 500.056L1208.22 599.448L1207.5 599.806V199.5H1617.34L1616.94 200.24ZM1332 337.5V439.207L1433.71 337.5H1332Z",fill:r}),i.jsx("path",{d:"M1716.5 599V200L1841 291.5L2125 200L2017.5 400L2125 599L1841 501L1716.5 599Z",fill:r,stroke:r})]})}const rqe=["Checking","system","requirements"],aqe=["Ready","to","go"],iqe=["Almost","there"],oqe=600,lqe=800;function cqe({onContinue:e,simulatedResult:t}){const n=Fe(),s=vr(),[r,a]=x.useState("checking"),[o,l]=x.useState(null),[c,u]=x.useState(null),[f,h]=x.useState(null),[m,g]=x.useState(0),[b,v]=x.useState(0),[k,w]=x.useState(new Set),C=x.useRef(!1),E=x.useCallback(()=>{a("checking"),l(null),u(null),v(0),w(new Set),C.current=!1,g(O=>O+1)},[]);x.useEffect(()=>{let O=!1;async function L(){const B=Date.now();let H=null,K=null;if(t)H=t;else try{H=await n.checkRequirements()}catch(q){K=q instanceof Error?q.message:"Failed to check requirements"}const U=Date.now()-B,$=3e3;U<$&&await new Promise(q=>setTimeout(q,$-U)),!O&&(K?(u(K),a("done")):(l(H),a("revealing")))}return L(),()=>{O=!0}},[n,t,m]);const T=o?Object.values(o.runtimes).flatMap(O=>O.dependencies):[],_=(o==null?void 0:o.allSatisfied)??!1,j=T.filter(O=>O.status!=="satisfied");x.useEffect(()=>{if(!(r!=="revealing"||T.length===0)&&b<T.length){const O=setTimeout(()=>v(L=>L+1),b===0?200:oqe);return()=>clearTimeout(O)}},[r,b,T.length]),x.useEffect(()=>{if(r==="revealing")for(let O=0;O<b;O++){if(k.has(O))continue;const L=setTimeout(()=>{w(B=>new Set(B).add(O))},lqe);return()=>clearTimeout(L)}},[r,b,k]),x.useEffect(()=>{if(r!=="revealing"||T.length===0||k.size<T.length)return;const O=setTimeout(()=>{a("done"),_&&!C.current&&(C.current=!0,u3())},400);return()=>clearTimeout(O)},[r,k.size,T.length,_]);const R=(O,L)=>{navigator.clipboard.writeText(L),h(O),setTimeout(()=>h(null),2e3)},D=r==="done"?_?aqe:iqe:rqe,I=r==="checking"||r==="revealing";return i.jsx(Zx,{children:i.jsxs(oe.div,{layout:!s,className:"mx-auto flex w-full max-w-md flex-col items-center px-4 text-center",transition:{layout:{duration:.4,ease:[.25,.1,.25,1]}},children:[i.jsx(oe.div,{layout:!s,className:"mb-8",initial:s?!1:{opacity:0,scale:.8},animate:{opacity:I?.6:.9,scale:1},transition:{duration:.5},children:i.jsxs(oe.div,{animate:I&&!s?{scale:[1,1.04,1],opacity:[.6,.8,.6]}:{scale:1,opacity:1},transition:I?{duration:2,repeat:1/0,ease:"easeInOut"}:{},children:[i.jsx(_m,{size:120,className:"dark:hidden"}),i.jsx(_m,{variant:"white",size:120,className:"hidden dark:block"})]})}),i.jsx(oe.div,{layout:!s,children:i.jsx(He,{mode:"wait",children:i.jsx(oe.h1,{className:"text-2xl font-semibold tracking-tight sm:text-3xl",children:s?D.join(" "):i.jsx(oe.span,{initial:"hidden",animate:"visible",exit:"exit",variants:{visible:{transition:{staggerChildren:.08}},exit:{transition:{staggerChildren:.02,staggerDirection:-1}}},children:D.map((O,L)=>i.jsxs(oe.span,{className:"inline-block",variants:{hidden:{opacity:0,filter:"blur(4px)"},visible:{opacity:1,filter:"blur(0px)"},exit:{opacity:0,filter:"blur(4px)"}},transition:{duration:.3},children:[O,L<D.length-1?" ":""]},L))})},D.join("-"))})}),i.jsx(He,{mode:"wait",children:i.jsx(oe.p,{className:"text-muted-foreground mt-3 text-sm",initial:s?!1:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.25},children:r==="checking"?"Making sure everything is in place.":r==="revealing"?"Verifying dependencies...":_?"Everything checked out perfectly.":"Some dependencies need to be installed."},r+String(_))}),i.jsxs(oe.div,{layout:!s,className:"mt-8 w-full",children:[i.jsx(He,{children:r==="checking"&&i.jsx(uqe,{},"scanning")}),i.jsx(He,{children:r==="done"&&c&&i.jsxs(oe.div,{className:"border-border bg-card rounded-xl border p-4 text-left",initial:s?!1:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.3},children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(ls,{className:"text-destructive size-4 shrink-0"}),i.jsx("span",{className:"text-sm font-medium",children:"Could not reach the server"})]}),i.jsx("p",{className:"text-muted-foreground mt-1.5 text-xs",children:c})]},"error")}),(r==="revealing"||r==="done")&&!c&&i.jsx("div",{className:"space-y-3",children:T.map((O,L)=>{if(L>=b)return null;const B=k.has(L);return i.jsx(dqe,{dep:O,isResolved:B,index:L},O.name)})}),i.jsx(He,{children:r==="done"&&j.length>0&&i.jsxs(oe.div,{className:"border-border bg-card mt-3 space-y-3 rounded-xl border p-4 text-left",initial:s?!1:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{delay:.15,duration:.3},children:[i.jsx("p",{className:"text-sm font-medium",children:j.length===1?"One dependency is missing":`${j.length} dependencies are missing`}),j.map(O=>i.jsxs("div",{className:"space-y-2",children:[O.installHint&&i.jsxs("div",{className:"bg-muted flex items-center justify-between gap-2 rounded-lg px-3 py-2.5",children:[i.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[i.jsx(tD,{className:"text-muted-foreground size-3.5 shrink-0"}),i.jsx("code",{className:"truncate text-xs",children:O.installHint})]}),i.jsx(ve,{variant:"ghost",size:"sm",className:"h-6 shrink-0 px-1.5",onClick:()=>R(O.name,O.installHint),children:f===O.name?i.jsx(Zt,{className:"size-3"}):i.jsx(Gf,{className:"size-3"})})]}),O.infoUrl&&i.jsxs("a",{href:O.infoUrl,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground inline-flex items-center gap-1 text-xs transition-colors",children:["Learn more ",i.jsx(bf,{className:"size-3"})]})]},O.name))]})})]}),i.jsxs(He,{mode:"wait",children:[r==="done"&&!c&&i.jsx(oe.div,{layout:!s,className:"mt-10 flex flex-col items-center gap-3",initial:s?!1:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{delay:.3,duration:.35},children:_?i.jsx(qD,{className:"px-6 py-2",duration:1.2,onClick:e,children:"Continue"}):i.jsxs(i.Fragment,{children:[i.jsxs(ve,{onClick:E,variant:"outline",className:"gap-2",children:[i.jsx(mu,{className:"size-3.5"}),"Check again"]}),i.jsx("p",{className:"text-muted-foreground text-xs",children:"Install the missing dependencies, then check again."})]})},_?"continue":"recheck"),r==="done"&&c&&i.jsx(oe.div,{layout:!s,className:"mt-10 flex flex-col items-center gap-3",initial:s?!1:{opacity:0},animate:{opacity:1},transition:{delay:.3,duration:.35},children:i.jsxs(ve,{onClick:E,variant:"outline",className:"gap-2",children:[i.jsx(mu,{className:"size-3.5"}),"Try again"]})},"error-recheck")]})]})})}function uqe(){const e=vr();return i.jsxs(oe.div,{className:"flex flex-col items-center gap-4 py-6",initial:e?!1:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.25},children:[i.jsx("div",{className:"flex items-center gap-1.5",children:[0,1,2].map(t=>i.jsx(oe.div,{className:"bg-muted-foreground/40 size-2 rounded-full",animate:e?{}:{scale:[1,1.5,1],opacity:[.3,1,.3]},transition:{duration:1.2,repeat:1/0,delay:t*.2,ease:"easeInOut"}},t))}),i.jsx("span",{className:"text-muted-foreground text-sm",children:"Scanning..."})]})}function dqe({dep:e,isResolved:t,index:n}){const s=e.status==="satisfied",r=vr();return i.jsxs(oe.div,{className:X("flex items-center gap-3 rounded-xl border px-4 py-3.5 transition-colors duration-500",t&&s&&"border-emerald-500/20 bg-emerald-500/5",t&&!s&&"border-destructive/20 bg-destructive/5",!t&&"border-border bg-card"),initial:r?!1:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{type:"spring",damping:24,stiffness:200,delay:n*.05},children:[i.jsx(He,{mode:"wait",children:t?s?i.jsx(oe.div,{className:"flex size-7 items-center justify-center rounded-full bg-emerald-500/15",initial:r?!1:{scale:0},animate:{scale:1},transition:{type:"spring",damping:10,stiffness:400},children:i.jsx(Zt,{className:"size-4 text-emerald-500"})},"pass"):i.jsx(oe.div,{className:"bg-destructive/10 flex size-7 items-center justify-center rounded-full",initial:r?!1:{scale:0},animate:{scale:1},transition:{type:"spring",damping:14,stiffness:300},children:i.jsx(ls,{className:"text-destructive size-4"})},"fail"):i.jsx(oe.div,{className:"bg-muted flex size-7 items-center justify-center rounded-full",exit:r?{}:{scale:0,opacity:0},transition:{duration:.15},children:i.jsx(oe.div,{className:"bg-muted-foreground/30 size-3 rounded-full",animate:r?{}:{opacity:[.3,.8,.3]},transition:{duration:1,repeat:1/0,ease:"easeInOut"}})},"scanning")}),i.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[i.jsx("p",{className:"text-sm font-medium",children:e.name}),i.jsx(He,{mode:"wait",children:t?i.jsx(oe.p,{className:"text-muted-foreground truncate text-xs",initial:r?!1:{opacity:0},animate:{opacity:1},transition:{duration:.3},children:s&&e.version?`v${e.version}`:e.description},"resolved"):i.jsx(oe.p,{className:"text-muted-foreground/50 text-xs",exit:{opacity:0},transition:{duration:.1},children:"Checking..."},"scanning")})]})]})}const xN=["Welcome","to","DorkOS"],fqe=[{icon:Es,label:"Create agents"},{icon:Ja,label:"Schedule tasks"},{icon:Xk,label:"Connect channels"}];function hqe({onGetStarted:e,onSkip:t}){const n=vr();return i.jsxs("div",{className:"mx-auto flex w-full max-w-md flex-col items-center px-4 text-center",children:[i.jsxs(oe.div,{className:"mb-6 opacity-80",initial:n?!1:{opacity:0,scale:.8},animate:{opacity:.8,scale:1},transition:{duration:.4},children:[i.jsx(_m,{size:150,className:"dark:hidden"}),i.jsx(_m,{variant:"white",size:150,className:"hidden dark:block"})]}),i.jsx("h1",{className:"text-3xl font-semibold tracking-tight sm:text-4xl",children:n?xN.join(" "):i.jsx(oe.span,{initial:"hidden",animate:"visible",variants:{visible:{transition:{staggerChildren:.08}}},children:xN.map((s,r)=>i.jsxs(oe.span,{className:"inline-block",variants:{hidden:{opacity:0,filter:"blur(4px)"},visible:{opacity:1,filter:"blur(0px)"}},transition:{duration:.4},children:[s,r<xN.length-1?" ":""]},r))})}),i.jsx(oe.p,{className:"text-muted-foreground mt-4",initial:n?!1:{opacity:0},animate:{opacity:1},transition:{delay:.4,duration:.5},children:"Your agents are three steps away."}),i.jsx(oe.div,{className:"mt-10 flex gap-8",initial:n?!1:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{delay:.6,duration:.4},children:fqe.map(({icon:s,label:r},a)=>i.jsxs("div",{className:"flex flex-col items-center gap-2",children:[i.jsx("div",{className:"bg-muted flex size-10 items-center justify-center rounded-lg",children:i.jsx(s,{className:"text-muted-foreground size-5"})}),i.jsx("span",{className:"text-muted-foreground text-xs",children:r})]},a))}),i.jsxs(oe.div,{className:"mt-12 flex flex-col items-center gap-3",initial:n?!1:{opacity:0},animate:{opacity:1},transition:{delay:.8,duration:.4},children:[i.jsx(qD,{className:"px-6 py-2",duration:1.2,onClick:e,children:"Get Started"}),i.jsx("button",{onClick:t,className:"text-muted-foreground hover:text-foreground text-sm transition-colors",children:"Skip setup"})]})]})}function pqe(e){const{verbosity:t}=e;return t>=4?"Hey! I'm DorkBot — your personal agent running on DorkOS. I can help with scheduling (Tasks), messaging (Relay), and discovering other agents (Mesh). What are we building today?":t<=2?"DorkBot online. I'm your default DorkOS agent. Tools available: Tasks (scheduling), Relay (messaging), Mesh (discovery). Ready for instructions.":"Hi, I'm DorkBot — your default agent in DorkOS. I have access to Tasks for scheduling, Relay for messaging, and Mesh for agent discovery. How can I help?"}const Eu=Fo()(Au(e=>({activeTab:"sessions",setActiveTab:t=>e({activeTab:t}),agentPath:null,setAgentPath:t=>e({agentPath:t}),openHub:(t,n)=>e({agentPath:t,activeTab:n??"sessions"})}),{name:"agent-hub"})),Nre=x.createContext(void 0);function ect({value:e,children:t}){return i.jsx(Nre.Provider,{value:e,children:t})}function tct(){const e=x.useContext(Nre);if(!e)throw new Error("useAgentHubContext must be used within an AgentHubProvider");return e}const jre={nebula:"#7c3aed",wisp:"#a78bfa",stroke:"#a78bfa",strokeEnd:"#c4b5fd",fill:"#7c3aed",fillEnd:"#a78bfa",glow:"#a78bfa",dot:"#c4b5fd"},Are=[{id:"balanced",name:"Balanced",emoji:"🤖",tagline:"The default. Steady, reliable, explains when it matters.",traits:{verbosity:3,autonomy:3,chaos:3,creativity:3,humor:3,spice:3},sampleResponse:"I'll handle this step by step. Let me explain my approach, then implement it. I'll check with you before making any irreversible changes.",colors:{nebula:"#7c3aed",wisp:"#a78bfa",stroke:"#a78bfa",strokeEnd:"#c4b5fd",fill:"#7c3aed",fillEnd:"#a78bfa",glow:"#a78bfa",dot:"#c4b5fd"}},{id:"hotshot",name:"The Hotshot",emoji:"🔥",tagline:"Ship fast, explain later. Turns caffeine into commits.",traits:{verbosity:2,autonomy:5,chaos:4,creativity:5,humor:3,spice:4},sampleResponse:"Done. Pushed the fix, tests pass, already moved on. Used a completely new approach btw — way cleaner.",colors:{nebula:"#ea580c",wisp:"#f97316",stroke:"#fb923c",strokeEnd:"#fbbf24",fill:"#ea580c",fillEnd:"#f59e0b",glow:"#fb923c",dot:"#fbbf24"}},{id:"sage",name:"The Sage",emoji:"🧐",tagline:"Teaches as it works. Every answer is a lesson.",traits:{verbosity:5,autonomy:2,chaos:1,creativity:3,humor:2,spice:1},sampleResponse:"This is a great learning opportunity. The issue stems from a race condition in the useEffect cleanup. Let me walk you through why this happens and three ways to fix it...",colors:{nebula:"#0ea5e9",wisp:"#06b6d4",stroke:"#22d3ee",strokeEnd:"#67e8f9",fill:"#0ea5e9",fillEnd:"#06b6d4",glow:"#22d3ee",dot:"#67e8f9"}},{id:"sentinel",name:"The Sentinel",emoji:"🛡",tagline:"Measure twice, cut once. Asks before every action.",traits:{verbosity:3,autonomy:1,chaos:1,creativity:2,humor:1,spice:2},sampleResponse:"Before I make any changes, I want to confirm: should I modify the auth middleware directly, or create a new wrapper? Both approaches have trade-offs I'd like to discuss.",colors:{nebula:"#16a34a",wisp:"#22c55e",stroke:"#4ade80",strokeEnd:"#86efac",fill:"#16a34a",fillEnd:"#10b981",glow:"#4ade80",dot:"#86efac"}},{id:"phantom",name:"The Phantom",emoji:"👻",tagline:"You'll barely know it's there. Pure silent execution.",traits:{verbosity:1,autonomy:5,chaos:3,creativity:3,humor:1,spice:3},sampleResponse:"Fixed.",colors:{nebula:"#6366f1",wisp:"#4338ca",stroke:"#818cf8",strokeEnd:"#a5b4fc",fill:"#4338ca",fillEnd:"#6366f1",glow:"#818cf8",dot:"#a5b4fc"}},{id:"mad-scientist",name:"Mad Scientist",emoji:"🎨",tagline:"Wild ideas, unexpected solutions. Thrives on chaos.",traits:{verbosity:4,autonomy:4,chaos:5,creativity:5,humor:4,spice:4},sampleResponse:"Okay hear me out — what if instead of fixing the N+1 query, we restructure the entire data layer? ngl it's kinda unhinged but it would solve three other problems too...",colors:{nebula:"#d946ef",wisp:"#a855f7",stroke:"#e879f9",strokeEnd:"#f0abfc",fill:"#d946ef",fillEnd:"#ec4899",glow:"#e879f9",dot:"#f0abfc"}},{id:"the-bro",name:"The Bro",emoji:"🤙",tagline:"Your unfiltered coding buddy. No filter, all vibes.",traits:{verbosity:4,autonomy:4,chaos:4,creativity:3,humor:4,spice:5},sampleResponse:"dude this codebase is absolutely unhinged lmao. ok I see the bug tho, gimme a sec... alright fixed that shit. whoever wrote this original code needs to be stopped fr fr",colors:{nebula:"#dc2626",wisp:"#ef4444",stroke:"#f87171",strokeEnd:"#fca5a5",fill:"#dc2626",fillEnd:"#ef4444",glow:"#f87171",dot:"#fca5a5"}},{id:"drill-sergeant",name:"Drill Sergeant",emoji:"🎖",tagline:"Terse. Efficient. Gets the job done with zero nonsense.",traits:{verbosity:2,autonomy:5,chaos:2,creativity:1,humor:1,spice:4},sampleResponse:"The bug is in line 47. Wrong comparison operator. Fixed it. Tests pass. Don't let it happen again.",colors:{nebula:"#475569",wisp:"#64748b",stroke:"#94a3b8",strokeEnd:"#cbd5e1",fill:"#334155",fillEnd:"#475569",glow:"#94a3b8",dot:"#cbd5e1"}}];function mqe(e){return Are.find(t=>t.traits.verbosity===e.verbosity&&t.traits.autonomy===e.autonomy&&t.traits.chaos===e.chaos&&t.traits.creativity===e.creativity&&t.traits.humor===e.humor&&t.traits.spice===e.spice)}const gqe=["Verbosity","Autonomy","Chaos","Creativity","Humor","Spice"],S1=["verbosity","autonomy","chaos","creativity","humor","spice"],Tw=6,aO=5,IB=3,xqe=800,yqe=600,PB={light:{nebulaCenter:.45,nebulaMid:.25,wispStart:.2,fillStart:.25,fillEnd:.15,haloBase:.25,haloAmplitude:.12,breatheMin:.25,breatheMax:.4,guideBase:.1,guideStep:.04,axis:.12,stardustPeak:1,glowBlur:12,vertexBlur:4},dark:{nebulaCenter:.35,nebulaMid:.15,wispStart:.12,fillStart:.35,fillEnd:.25,haloBase:.15,haloAmplitude:.1,breatheMin:.15,breatheMax:.25,guideBase:.06,guideStep:.02,axis:.08,stardustPeak:.8,glowBlur:10,vertexBlur:4}},bqe=[{r:1.2,dur:"9s",fade:"4.5s",begin:"0s",path:"M0,0 C30,-40 60,0 40,40 C20,60 -20,40 -30,10 C-40,-20 -10,-50 0,0"},{r:.9,dur:"7s",fade:"3.5s",begin:"0s",path:"M0,0 C-20,30 -40,20 -30,-10 C-20,-30 10,-40 20,-20 C30,0 20,30 0,0"},{r:1,dur:"11s",fade:"5s",begin:"0s",path:"M0,0 C40,10 30,50 0,40 C-30,30 -40,-10 -20,-30 C0,-50 30,-20 0,0"},{r:.7,dur:"8s",fade:"4s",begin:"2s",path:"M0,0 C15,-35 45,-15 35,20 C25,45 -15,40 -25,15 C-35,-10 -5,-40 0,0"},{r:1.1,dur:"12s",fade:"6s",begin:"1s",path:"M0,0 C-25,25 -45,5 -30,-20 C-15,-45 20,-35 30,-10 C40,15 15,35 0,0"}];function cS(e,t,n,s){const r=Math.PI*2*e/Tw-Math.PI/2,a=t/aO*s;return{x:n+a*Math.cos(r),y:n+a*Math.sin(r)}}function KR(e){return e.map(t=>`${t.x},${t.y}`).join(" ")}function vqe(e,t,n){return KR(Array.from({length:Tw},(s,r)=>cS(r,e*aO,t,n)))}function Sqe(e){return e<.5?4*e*e*e:1-(-2*e+2)**3/2}function wqe({traits:e,colors:t=jre,size:n=180,animated:s=!0,className:r}){const a=x.useId().replace(/:/g,""),o=nO(),l=o?PB.dark:PB.light,c=x.useRef(l);c.current=l;const u=o?{strokeStart:t.stroke,strokeEnd:t.strokeEnd,fillStart:t.fill,fillEnd:t.fillEnd,dot:t.dot,glow:t.glow}:{strokeStart:t.fill,strokeEnd:t.fillEnd,fillStart:t.stroke,fillEnd:t.strokeEnd,dot:t.fill,glow:t.stroke},f=n/2,h=n*.32,m=h+16,g=n/200,b=x.useRef(null),v=x.useRef(null),k=x.useRef([]),w=x.useRef([]),C=x.useRef({current:{...e},from:null,target:{...e},morphStart:0,breathe:0}),E=x.useRef(e);x.useEffect(()=>{const D=E.current;if(S1.some(O=>D[O]!==e[O])){const O=C.current;if(s){O.from={...O.current},O.target={...e},O.morphStart=performance.now();const L=v.current;if(L){const B=performance.now();(function H(){const K=Math.min((performance.now()-B)/yqe,1),U=1-(1-K)*(1-K);L.setAttribute("r",String(h*(.7+.6*U))),L.setAttribute("opacity",String(.4*(1-U))),K<1&&requestAnimationFrame(H)})()}}else Object.assign(O.current,e),Object.assign(O.target,e)}E.current=e},[e,s,h]),x.useEffect(()=>{if(!s)return;let D;const I=C.current;function O(){var K;I.breathe+=.015;const L=1+Math.sin(I.breathe)*.04;if(I.from){const U=Math.min((performance.now()-I.morphStart)/xqe,1),$=Sqe(U);for(const q of S1)I.current[q]=I.from[q]+(I.target[q]-I.from[q])*$;U>=1&&(I.from=null,Object.assign(I.current,I.target))}const H=S1.map(U=>I.current[U]).map((U,$)=>cS($,U*L,f,h));(K=b.current)==null||K.setAttribute("points",KR(H)),H.forEach((U,$)=>{const q=k.current[$],J=w.current[$];if(q){q.setAttribute("cx",String(U.x)),q.setAttribute("cy",String(U.y)),q.setAttribute("r",String(8+Math.sin(I.breathe+$*1.2)*3));const ne=c.current;q.setAttribute("opacity",String(ne.haloBase+Math.sin(I.breathe+$)*ne.haloAmplitude))}J&&(J.setAttribute("cx",String(U.x)),J.setAttribute("cy",String(U.y)),J.setAttribute("r",String(3.5+Math.sin(I.breathe+$*.8)*.8)))}),D=requestAnimationFrame(O)}return D=requestAnimationFrame(O),()=>cancelAnimationFrame(D)},[s,f,h]);const T=S1.map((D,I)=>cS(I,e[D],f,h)),_=KR(T),j={transition:"stop-color 0.6s ease"},R={transition:"fill 0.6s ease"};return i.jsxs("svg",{viewBox:`0 0 ${n} ${n}`,className:X("aspect-square",r),"aria-label":"Personality radar chart",role:"img",children:[i.jsxs("defs",{children:[o?i.jsxs("filter",{id:`ng-${a}`,x:"-80%",y:"-80%",width:"260%",height:"260%",children:[i.jsx("feGaussianBlur",{stdDeviation:l.glowBlur,result:"blur"}),i.jsxs("feMerge",{children:[i.jsx("feMergeNode",{in:"blur"}),i.jsx("feMergeNode",{in:"blur"}),i.jsx("feMergeNode",{in:"SourceGraphic"})]})]}):i.jsx("filter",{id:`ng-${a}`,x:"-50%",y:"-30%",width:"200%",height:"200%",children:i.jsx("feDropShadow",{dx:"0",dy:"2",stdDeviation:"6",floodColor:u.strokeStart,floodOpacity:"0.18"})}),i.jsxs("filter",{id:`vg-${a}`,x:"-100%",y:"-100%",width:"300%",height:"300%",children:[i.jsx("feGaussianBlur",{stdDeviation:l.vertexBlur,result:"blur"}),i.jsxs("feMerge",{children:[i.jsx("feMergeNode",{in:"blur"}),i.jsx("feMergeNode",{in:"SourceGraphic"})]})]}),i.jsxs("radialGradient",{id:`nc-${a}`,cx:"50%",cy:"50%",r:"50%",children:[i.jsx("stop",{offset:"0%",style:{stopColor:t.nebula,stopOpacity:l.nebulaCenter,...j}}),i.jsx("stop",{offset:"50%",style:{stopColor:t.nebula,stopOpacity:l.nebulaMid,...j}}),i.jsx("stop",{offset:"100%",style:{stopColor:"var(--nebula-edge)"},stopOpacity:0})]}),i.jsxs("radialGradient",{id:`nw-${a}`,cx:"35%",cy:"35%",r:"60%",children:[i.jsx("stop",{offset:"0%",style:{stopColor:t.wisp,stopOpacity:l.wispStart,...j}}),i.jsx("stop",{offset:"100%",style:{stopColor:"var(--nebula-edge)"},stopOpacity:0})]}),i.jsxs("linearGradient",{id:`sf-${a}`,x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[i.jsx("stop",{offset:"0%",style:{stopColor:u.fillStart,stopOpacity:l.fillStart,...j}}),i.jsx("stop",{offset:"100%",style:{stopColor:u.fillEnd,stopOpacity:l.fillEnd,...j}})]}),i.jsxs("linearGradient",{id:`ss-${a}`,x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[i.jsx("stop",{offset:"0%",style:{stopColor:u.strokeStart,...j}}),i.jsx("stop",{offset:"100%",style:{stopColor:u.strokeEnd,...j}})]})]}),i.jsx("circle",{cx:f,cy:f,r:n*.44,fill:`url(#nc-${a})`,children:s&&i.jsx("animateTransform",{attributeName:"transform",type:"rotate",values:`0 ${f} ${f};360 ${f} ${f}`,dur:"90s",repeatCount:"indefinite"})}),i.jsx("ellipse",{cx:f*.94,cy:f*.97,rx:n*.35,ry:n*.25,fill:`url(#nw-${a})`,children:s&&i.jsx("animateTransform",{attributeName:"transform",type:"rotate",values:`0 ${f} ${f};-360 ${f} ${f}`,dur:"60s",repeatCount:"indefinite"})}),s&&i.jsxs("circle",{cx:f,cy:f,r:h*.92,fill:"none",style:{stroke:u.strokeStart,transition:"stroke 0.6s ease"},strokeWidth:.3,opacity:l.breatheMin,children:[i.jsx("animate",{attributeName:"r",values:`${h*.85};${h*1.08};${h*.85}`,dur:"4s",repeatCount:"indefinite",calcMode:"spline",keySplines:"0.4 0 0.6 1;0.4 0 0.6 1"}),i.jsx("animate",{attributeName:"opacity",values:`${l.breatheMin};${l.breatheMax};${l.breatheMin}`,dur:"4s",repeatCount:"indefinite",calcMode:"spline",keySplines:"0.4 0 0.6 1;0.4 0 0.6 1"})]}),s&&i.jsx("g",{transform:`translate(${f},${f}) scale(${g})`,children:bqe.map((D,I)=>i.jsxs("circle",{r:D.r,style:{fill:u.dot,...R},children:[i.jsx("animateMotion",{dur:D.dur,repeatCount:"indefinite",begin:D.begin,path:D.path}),i.jsx("animate",{attributeName:"opacity",values:`0;${l.stardustPeak};0`,dur:D.fade,repeatCount:"indefinite",begin:D.begin})]},`star-${I}`))}),i.jsx("circle",{ref:v,cx:f,cy:f,r:0,fill:t.nebula,opacity:0}),Array.from({length:IB},(D,I)=>i.jsx("polygon",{points:vqe((I+1)/IB,f,h),fill:"none",stroke:o?"currentColor":u.strokeStart,strokeWidth:.5,opacity:l.guideBase+I*l.guideStep},`ring-${I}`)),Array.from({length:Tw},(D,I)=>{const O=cS(I,aO,f,h);return i.jsx("line",{x1:f,y1:f,x2:O.x,y2:O.y,stroke:o?"currentColor":u.strokeStart,strokeWidth:.5,opacity:l.axis},`axis-${I}`)}),i.jsx("polygon",{ref:b,points:_,fill:`url(#sf-${a})`,stroke:`url(#ss-${a})`,strokeWidth:2,strokeLinejoin:"round",filter:`url(#ng-${a})`}),T.map((D,I)=>i.jsx("circle",{ref:O=>{k.current[I]=O},cx:D.x,cy:D.y,r:8,style:{fill:u.glow,...R},opacity:l.haloBase},`halo-${I}`)),T.map((D,I)=>i.jsx("circle",{ref:O=>{w.current[I]=O},cx:D.x,cy:D.y,r:o?4:4.5,style:{fill:u.dot,...R},stroke:o?"none":"white",strokeWidth:o?0:1.5,filter:`url(#vg-${a})`},`dot-${I}`)),gqe.map((D,I)=>{const O=Math.PI*2*I/Tw-Math.PI/2;return i.jsx("text",{x:f+m*Math.cos(O),y:f+m*Math.sin(O),textAnchor:"middle",dominantBaseline:"middle",fill:"currentColor",opacity:.5,fontSize:8,className:"select-none",children:D},D)})]})}const LB={duration:.2,ease:"easeInOut"};function kqe({traits:e,onTraitsChange:t,compact:n=!1,sampleLabel:s="How this agent talks",className:r}){const[a,o]=x.useState("presets"),l=mqe(e),c=(l==null?void 0:l.colors)??jre,u=x.useCallback(m=>{t(m.traits),o("presets"),h0()},[t]),f=x.useCallback(()=>{o("custom"),h0()},[]),h=x.useCallback(()=>{o("presets"),h0()},[]);return i.jsxs("div",{className:X("@container/picker w-full",r),children:[i.jsxs("div",{className:X("flex flex-col items-center gap-3","@[480px]/picker:flex-row @[480px]/picker:items-center @[480px]/picker:gap-6"),children:[i.jsxs("div",{className:X("flex flex-col items-center gap-1","@[480px]/picker:w-[200px] @[480px]/picker:shrink-0"),children:[i.jsx("div",{"data-testid":"personality-radar",children:i.jsx(wqe,{traits:e,colors:c,size:n?180:200,className:n?"w-[90%] max-w-[240px]":"w-full max-w-[200px]"})}),i.jsxs("div",{className:"text-center",children:[i.jsx("h3",{className:"bg-clip-text text-sm font-bold text-transparent",style:{backgroundImage:`linear-gradient(135deg, ${c.stroke}, ${c.strokeEnd})`},children:(l==null?void 0:l.name)??"Custom"}),i.jsx("p",{className:"text-muted-foreground mt-0.5 text-[11px]",children:(l==null?void 0:l.tagline)??"A custom blend of personality traits."})]})]}),i.jsx("div",{className:"flex w-full min-w-0 flex-col items-center gap-3 @[480px]/picker:items-start",children:i.jsx(He,{mode:"wait",initial:!1,children:a==="presets"?i.jsxs(oe.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:-6},transition:LB,className:"flex max-w-sm flex-wrap justify-center gap-1.5 @[480px]/picker:justify-start","data-testid":"preset-pills",children:[Are.map(m=>i.jsx(oVe,{emoji:m.emoji,name:m.name,colors:m.colors,active:(l==null?void 0:l.id)===m.id,size:n?"sm":"default",glow:!0,onClick:()=>u(m)},m.id)),i.jsxs("button",{type:"button",onClick:f,className:X("inline-flex shrink-0 items-center gap-1.5 rounded-full border border-dashed font-medium transition-all","text-muted-foreground hover:text-foreground hover:border-foreground/20 border-border",n?"px-2.5 py-1 text-[11px]":"px-3 py-1 text-xs"),"data-testid":"custom-toggle",children:[i.jsx(Qi,{className:"size-3"}),i.jsx("span",{children:"Custom"})]})]},"presets"):i.jsxs(oe.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:-6},transition:LB,className:"flex w-full flex-col items-center gap-3 @[480px]/picker:items-start",children:[i.jsxs("div",{className:"flex gap-1.5","data-testid":"custom-mode-pills",children:[i.jsxs("button",{type:"button",onClick:h,className:X("inline-flex shrink-0 items-center gap-1.5 rounded-full border border-dashed font-medium transition-all","text-muted-foreground hover:text-foreground hover:border-foreground/20 border-border",n?"px-2.5 py-1 text-[11px]":"px-3 py-1 text-xs"),"data-testid":"presets-toggle",children:[i.jsx("span",{children:"←"}),i.jsx("span",{children:"Presets"})]}),i.jsxs("span",{className:X("bg-accent text-foreground inline-flex shrink-0 items-center gap-1.5 rounded-full border font-medium","border-foreground/15",n?"px-2.5 py-1 text-[11px]":"px-3 py-1 text-xs"),children:[i.jsx(Qi,{className:"size-3"}),i.jsx("span",{children:"Custom"})]})]}),i.jsx("div",{className:X("w-full",n?"max-w-sm":"max-w-md"),onPointerDown:()=>h0(),children:i.jsx(uVe,{traits:e,onChange:t,onSliderChange:()=>h0()})})]},"custom")})})]}),i.jsxs("div",{className:"hidden w-full max-w-sm",children:[i.jsx("span",{className:"text-muted-foreground text-[9px] font-medium tracking-wider uppercase",children:s}),i.jsx("div",{className:"bg-accent/50 mt-1 rounded-lg p-3",children:i.jsx("p",{className:"text-muted-foreground text-xs leading-relaxed italic",children:(l==null?void 0:l.sampleResponse)??"This agent uses a custom personality blend. Select a preset to see a sample response."})})]})]})}const JC=x.createContext(null);JC.displayName="PanelGroupContext";const ks={group:"data-panel-group",groupDirection:"data-panel-group-direction",groupId:"data-panel-group-id",panel:"data-panel",panelCollapsible:"data-panel-collapsible",panelId:"data-panel-id",panelSize:"data-panel-size",resizeHandle:"data-resize-handle",resizeHandleActive:"data-resize-handle-active",resizeHandleEnabled:"data-panel-resize-handle-enabled",resizeHandleId:"data-panel-resize-handle-id",resizeHandleState:"data-resize-handle-state"},iO=10,hf=x.useLayoutEffect,FB=gy.useId,Cqe=typeof FB=="function"?FB:()=>null;let Eqe=0;function oO(e=null){const t=Cqe(),n=x.useRef(e||t||null);return n.current===null&&(n.current=""+Eqe++),e??n.current}function Rre({children:e,className:t="",collapsedSize:n,collapsible:s,defaultSize:r,forwardedRef:a,id:o,maxSize:l,minSize:c,onCollapse:u,onExpand:f,onResize:h,order:m,style:g,tagName:b="div",...v}){const k=x.useContext(JC);if(k===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:w,expandPanel:C,getPanelSize:E,getPanelStyle:T,groupId:_,isPanelCollapsed:j,reevaluatePanelConstraints:R,registerPanel:D,resizePanel:I,unregisterPanel:O}=k,L=oO(o),B=x.useRef({callbacks:{onCollapse:u,onExpand:f,onResize:h},constraints:{collapsedSize:n,collapsible:s,defaultSize:r,maxSize:l,minSize:c},id:L,idIsFromProps:o!==void 0,order:m});x.useRef({didLogMissingDefaultSizeWarning:!1}),hf(()=>{const{callbacks:K,constraints:U}=B.current,$={...U};B.current.id=L,B.current.idIsFromProps=o!==void 0,B.current.order=m,K.onCollapse=u,K.onExpand=f,K.onResize=h,U.collapsedSize=n,U.collapsible=s,U.defaultSize=r,U.maxSize=l,U.minSize=c,($.collapsedSize!==U.collapsedSize||$.collapsible!==U.collapsible||$.maxSize!==U.maxSize||$.minSize!==U.minSize)&&R(B.current,$)}),hf(()=>{const K=B.current;return D(K),()=>{O(K)}},[m,L,D,O]),x.useImperativeHandle(a,()=>({collapse:()=>{w(B.current)},expand:K=>{C(B.current,K)},getId(){return L},getSize(){return E(B.current)},isCollapsed(){return j(B.current)},isExpanded(){return!j(B.current)},resize:K=>{I(B.current,K)}}),[w,C,E,j,L,I]);const H=T(B.current,r);return x.createElement(b,{...v,children:e,className:t,id:L,style:{...H,...g},[ks.groupId]:_,[ks.panel]:"",[ks.panelCollapsible]:s||void 0,[ks.panelId]:L,[ks.panelSize]:parseFloat(""+H.flexGrow).toFixed(1)})}const lO=x.forwardRef((e,t)=>x.createElement(Rre,{...e,forwardedRef:t}));Rre.displayName="Panel";lO.displayName="forwardRef(Panel)";let WR=null,uS=-1,Bc=null;function Tqe(e,t,n){const s=(t&Pre)!==0,r=(t&Lre)!==0,a=(t&Fre)!==0,o=(t&zre)!==0;if(t){if(s)return a?"se-resize":o?"ne-resize":"e-resize";if(r)return a?"sw-resize":o?"nw-resize":"w-resize";if(a)return"s-resize";if(o)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function _qe(){Bc!==null&&(document.head.removeChild(Bc),WR=null,Bc=null,uS=-1)}function yN(e,t,n){var s,r;const a=Tqe(e,t);if(WR!==a){if(WR=a,Bc===null&&(Bc=document.createElement("style"),document.head.appendChild(Bc)),uS>=0){var o;(o=Bc.sheet)===null||o===void 0||o.removeRule(uS)}uS=(s=(r=Bc.sheet)===null||r===void 0?void 0:r.insertRule(`*{cursor: ${a} !important;}`))!==null&&s!==void 0?s:-1}}function Mre(e){return e.type==="keydown"}function Dre(e){return e.type.startsWith("pointer")}function Ore(e){return e.type.startsWith("mouse")}function eE(e){if(Dre(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(Ore(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function Nqe(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function jqe(e,t,n){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function Aqe(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:$B(e),b:$B(t)};let s;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),s=e;Vt(s,"Stacking order can only be calculated for elements with a common ancestor");const r={a:BB(zB(n.a)),b:BB(zB(n.b))};if(r.a===r.b){const a=s.childNodes,o={a:n.a.at(-1),b:n.b.at(-1)};let l=a.length;for(;l--;){const c=a[l];if(c===o.a)return 1;if(c===o.b)return-1}}return Math.sign(r.a-r.b)}const Rqe=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Mqe(e){var t;const n=getComputedStyle((t=Ire(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function Dqe(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||Mqe(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||Rqe.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function zB(e){let t=e.length;for(;t--;){const n=e[t];if(Vt(n,"Missing node"),Dqe(n))return n}return null}function BB(e){return e&&Number(getComputedStyle(e).zIndex)||0}function $B(e){const t=[];for(;e;)t.push(e),e=Ire(e);return t}function Ire(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const Pre=1,Lre=2,Fre=4,zre=8,Oqe=Nqe()==="coarse";let Ki=[],Zp=!1,$c=new Map,tE=new Map;const ny=new Set;function Iqe(e,t,n,s,r){var a;const{ownerDocument:o}=t,l={direction:n,element:t,hitAreaMargins:s,setResizeHandlerState:r},c=(a=$c.get(o))!==null&&a!==void 0?a:0;return $c.set(o,c+1),ny.add(l),_w(),function(){var f;tE.delete(e),ny.delete(l);const h=(f=$c.get(o))!==null&&f!==void 0?f:1;if($c.set(o,h-1),_w(),h===1&&$c.delete(o),Ki.includes(l)){const m=Ki.indexOf(l);m>=0&&Ki.splice(m,1),nE(),r("up",!0,null)}}}function Pqe(e){const{target:t}=e,{x:n,y:s}=eE(e);Zp=!0,cO({target:t,x:n,y:s}),_w(),Ki.length>0&&(Nw("down",e),nE(),e.preventDefault(),Bre(t)||e.stopImmediatePropagation())}function bN(e){const{x:t,y:n}=eE(e);if(Zp&&e.type!=="pointerleave"&&e.buttons===0&&(Zp=!1,Nw("up",e)),!Zp){const{target:s}=e;cO({target:s,x:t,y:n})}Nw("move",e),nE(),Ki.length>0&&e.preventDefault()}function vN(e){const{target:t}=e,{x:n,y:s}=eE(e);tE.clear(),Zp=!1,Ki.length>0&&(e.preventDefault(),Bre(t)||e.stopImmediatePropagation()),Nw("up",e),cO({target:t,x:n,y:s}),nE(),_w()}function Bre(e){let t=e;for(;t;){if(t.hasAttribute(ks.resizeHandle))return!0;t=t.parentElement}return!1}function cO({target:e,x:t,y:n}){Ki.splice(0);let s=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(s=e),ny.forEach(r=>{const{element:a,hitAreaMargins:o}=r,l=a.getBoundingClientRect(),{bottom:c,left:u,right:f,top:h}=l,m=Oqe?o.coarse:o.fine;if(t>=u-m&&t<=f+m&&n>=h-m&&n<=c+m){if(s!==null&&document.contains(s)&&a!==s&&!a.contains(s)&&!s.contains(a)&&Aqe(s,a)>0){let b=s,v=!1;for(;b&&!b.contains(a);){if(jqe(b.getBoundingClientRect(),l)){v=!0;break}b=b.parentElement}if(v)return}Ki.push(r)}})}function SN(e,t){tE.set(e,t)}function nE(){let e=!1,t=!1;Ki.forEach(s=>{const{direction:r}=s;r==="horizontal"?e=!0:t=!0});let n=0;tE.forEach(s=>{n|=s}),e&&t?yN("intersection",n):e?yN("horizontal",n):t?yN("vertical",n):_qe()}let wN;function _w(){var e;(e=wN)===null||e===void 0||e.abort(),wN=new AbortController;const t={capture:!0,signal:wN.signal};ny.size&&(Zp?(Ki.length>0&&$c.forEach((n,s)=>{const{body:r}=s;n>0&&(r.addEventListener("contextmenu",vN,t),r.addEventListener("pointerleave",bN,t),r.addEventListener("pointermove",bN,t))}),$c.forEach((n,s)=>{const{body:r}=s;r.addEventListener("pointerup",vN,t),r.addEventListener("pointercancel",vN,t)})):$c.forEach((n,s)=>{const{body:r}=s;n>0&&(r.addEventListener("pointerdown",Pqe,t),r.addEventListener("pointermove",bN,t))}))}function Nw(e,t){ny.forEach(n=>{const{setResizeHandlerState:s}=n,r=Ki.includes(n);s(e,r,t)})}function Lqe(){const[e,t]=x.useState(0);return x.useCallback(()=>t(n=>n+1),[])}function Vt(e,t){if(!e)throw console.error(t),Error(t)}function Tf(e,t,n=iO){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function jl(e,t,n=iO){return Tf(e,t,n)===0}function Ba(e,t,n){return Tf(e,t,n)===0}function Fqe(e,t,n){if(e.length!==t.length)return!1;for(let s=0;s<e.length;s++){const r=e[s],a=t[s];if(!Ba(r,a,n))return!1}return!0}function Lp({panelConstraints:e,panelIndex:t,size:n}){const s=e[t];Vt(s!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:r=0,collapsible:a,maxSize:o=100,minSize:l=0}=s;if(Tf(n,l)<0)if(a){const c=(r+l)/2;Tf(n,c)<0?n=r:n=l}else n=l;return n=Math.min(o,n),n=parseFloat(n.toFixed(iO)),n}function Q0({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:s,prevLayout:r,trigger:a}){if(Ba(e,0))return t;const o=[...t],[l,c]=s;Vt(l!=null,"Invalid first pivot index"),Vt(c!=null,"Invalid second pivot index");let u=0;if(a==="keyboard"){{const h=e<0?c:l,m=n[h];Vt(m,`Panel constraints not found for index ${h}`);const{collapsedSize:g=0,collapsible:b,minSize:v=0}=m;if(b){const k=t[h];if(Vt(k!=null,`Previous layout not found for panel index ${h}`),Ba(k,g)){const w=v-k;Tf(w,Math.abs(e))>0&&(e=e<0?0-w:w)}}}{const h=e<0?l:c,m=n[h];Vt(m,`No panel constraints found for index ${h}`);const{collapsedSize:g=0,collapsible:b,minSize:v=0}=m;if(b){const k=t[h];if(Vt(k!=null,`Previous layout not found for panel index ${h}`),Ba(k,v)){const w=k-g;Tf(w,Math.abs(e))>0&&(e=e<0?0-w:w)}}}}{const h=e<0?1:-1;let m=e<0?c:l,g=0;for(;;){const v=t[m];Vt(v!=null,`Previous layout not found for panel index ${m}`);const w=Lp({panelConstraints:n,panelIndex:m,size:100})-v;if(g+=w,m+=h,m<0||m>=n.length)break}const b=Math.min(Math.abs(e),Math.abs(g));e=e<0?0-b:b}{let m=e<0?l:c;for(;m>=0&&m<n.length;){const g=Math.abs(e)-Math.abs(u),b=t[m];Vt(b!=null,`Previous layout not found for panel index ${m}`);const v=b-g,k=Lp({panelConstraints:n,panelIndex:m,size:v});if(!Ba(b,k)&&(u+=b-k,o[m]=k,u.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?m--:m++}}if(Fqe(r,o))return r;{const h=e<0?c:l,m=t[h];Vt(m!=null,`Previous layout not found for panel index ${h}`);const g=m+u,b=Lp({panelConstraints:n,panelIndex:h,size:g});if(o[h]=b,!Ba(b,g)){let v=g-b,w=e<0?c:l;for(;w>=0&&w<n.length;){const C=o[w];Vt(C!=null,`Previous layout not found for panel index ${w}`);const E=C+v,T=Lp({panelConstraints:n,panelIndex:w,size:E});if(Ba(C,T)||(v-=T-C,o[w]=T),Ba(v,0))break;e>0?w--:w++}}}const f=o.reduce((h,m)=>m+h,0);return Ba(f,100)?o:r}function zqe({layout:e,panelsArray:t,pivotIndices:n}){let s=0,r=100,a=0,o=0;const l=n[0];Vt(l!=null,"No pivot index found"),t.forEach((h,m)=>{const{constraints:g}=h,{maxSize:b=100,minSize:v=0}=g;m===l?(s=v,r=b):(a+=v,o+=b)});const c=Math.min(r,100-a),u=Math.max(s,100-o),f=e[l];return{valueMax:c,valueMin:u,valueNow:f}}function sy(e,t=document){return Array.from(t.querySelectorAll(`[${ks.resizeHandleId}][data-panel-group-id="${e}"]`))}function $re(e,t,n=document){const r=sy(e,n).findIndex(a=>a.getAttribute(ks.resizeHandleId)===t);return r??null}function Hre(e,t,n){const s=$re(e,t,n);return s!=null?[s,s+1]:[-1,-1]}function Bqe(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function Ure(e,t=document){if(Bqe(t)&&t.dataset.panelGroupId==e)return t;const n=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function sE(e,t=document){const n=t.querySelector(`[${ks.resizeHandleId}="${e}"]`);return n||null}function $qe(e,t,n,s=document){var r,a,o,l;const c=sE(t,s),u=sy(e,s),f=c?u.indexOf(c):-1,h=(r=(a=n[f])===null||a===void 0?void 0:a.id)!==null&&r!==void 0?r:null,m=(o=(l=n[f+1])===null||l===void 0?void 0:l.id)!==null&&o!==void 0?o:null;return[h,m]}function Hqe({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:s,panelDataArray:r,panelGroupElement:a,setLayout:o}){x.useRef({didWarnAboutMissingResizeHandle:!1}),hf(()=>{if(!a)return;const l=sy(n,a);for(let c=0;c<r.length-1;c++){const{valueMax:u,valueMin:f,valueNow:h}=zqe({layout:s,panelsArray:r,pivotIndices:[c,c+1]}),m=l[c];if(m!=null){const g=r[c];Vt(g,`No panel data found for index "${c}"`),m.setAttribute("aria-controls",g.id),m.setAttribute("aria-valuemax",""+Math.round(u)),m.setAttribute("aria-valuemin",""+Math.round(f)),m.setAttribute("aria-valuenow",h!=null?""+Math.round(h):"")}}return()=>{l.forEach((c,u)=>{c.removeAttribute("aria-controls"),c.removeAttribute("aria-valuemax"),c.removeAttribute("aria-valuemin"),c.removeAttribute("aria-valuenow")})}},[n,s,r,a]),x.useEffect(()=>{if(!a)return;const l=t.current;Vt(l,"Eager values not found");const{panelDataArray:c}=l,u=Ure(n,a);Vt(u!=null,`No group found for id "${n}"`);const f=sy(n,a);Vt(f,`No resize handles found for group id "${n}"`);const h=f.map(m=>{const g=m.getAttribute(ks.resizeHandleId);Vt(g,"Resize handle element has no handle id attribute");const[b,v]=$qe(n,g,c,a);if(b==null||v==null)return()=>{};const k=w=>{if(!w.defaultPrevented)switch(w.key){case"Enter":{w.preventDefault();const C=c.findIndex(E=>E.id===b);if(C>=0){const E=c[C];Vt(E,`No panel data found for index ${C}`);const T=s[C],{collapsedSize:_=0,collapsible:j,minSize:R=0}=E.constraints;if(T!=null&&j){const D=Q0({delta:Ba(T,_)?R-_:_-T,initialLayout:s,panelConstraints:c.map(I=>I.constraints),pivotIndices:Hre(n,g,a),prevLayout:s,trigger:"keyboard"});s!==D&&o(D)}}break}}};return m.addEventListener("keydown",k),()=>{m.removeEventListener("keydown",k)}});return()=>{h.forEach(m=>m())}},[a,e,t,n,s,r,o])}function HB(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Vre(e,t){const n=e==="horizontal",{x:s,y:r}=eE(t);return n?s:r}function Uqe(e,t,n,s,r){const a=n==="horizontal",o=sE(t,r);Vt(o,`No resize handle element found for id "${t}"`);const l=o.getAttribute(ks.groupId);Vt(l,"Resize handle element has no group id attribute");let{initialCursorPosition:c}=s;const u=Vre(n,e),f=Ure(l,r);Vt(f,`No group element found for id "${l}"`);const h=f.getBoundingClientRect(),m=a?h.width:h.height;return(u-c)/m*100}function Vqe(e,t,n,s,r,a){if(Mre(e)){const o=n==="horizontal";let l=0;e.shiftKey?l=100:r!=null?l=r:l=10;let c=0;switch(e.key){case"ArrowDown":c=o?0:l;break;case"ArrowLeft":c=o?-l:0;break;case"ArrowRight":c=o?l:0;break;case"ArrowUp":c=o?0:-l;break;case"End":c=100;break;case"Home":c=-100;break}return c}else return s==null?0:Uqe(e,t,n,s,a)}function qqe({panelDataArray:e}){const t=Array(e.length),n=e.map(a=>a.constraints);let s=0,r=100;for(let a=0;a<e.length;a++){const o=n[a];Vt(o,`Panel constraints not found for index ${a}`);const{defaultSize:l}=o;l!=null&&(s++,t[a]=l,r-=l)}for(let a=0;a<e.length;a++){const o=n[a];Vt(o,`Panel constraints not found for index ${a}`);const{defaultSize:l}=o;if(l!=null)continue;const c=e.length-s,u=r/c;s++,t[a]=u,r-=u}return t}function cp(e,t,n){t.forEach((s,r)=>{const a=e[r];Vt(a,`Panel data not found for index ${r}`);const{callbacks:o,constraints:l,id:c}=a,{collapsedSize:u=0,collapsible:f}=l,h=n[c];if(h==null||s!==h){n[c]=s;const{onCollapse:m,onExpand:g,onResize:b}=o;b&&b(s,h),f&&(m||g)&&(g&&(h==null||jl(h,u))&&!jl(s,u)&&g(),m&&(h==null||!jl(h,u))&&jl(s,u)&&m())}})}function w1(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function Gqe({defaultSize:e,dragState:t,layout:n,panelData:s,panelIndex:r,precision:a=3}){const o=n[r];let l;return o==null?l=e!=null?e.toFixed(a):"1":s.length===1?l="1":l=o.toFixed(a),{flexBasis:0,flexGrow:l,flexShrink:1,overflow:"hidden",pointerEvents:t!==null?"none":void 0}}function Kqe(e,t=10){let n=null;return(...r)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...r)},t)}}function UB(e){try{if(typeof localStorage<"u")e.getItem=t=>localStorage.getItem(t),e.setItem=(t,n)=>{localStorage.setItem(t,n)};else throw new Error("localStorage not supported in this environment")}catch(t){console.error(t),e.getItem=()=>null,e.setItem=()=>{}}}function qre(e){return`react-resizable-panels:${e}`}function Gre(e){return e.map(t=>{const{constraints:n,id:s,idIsFromProps:r,order:a}=t;return r?s:a?`${a}:${JSON.stringify(n)}`:JSON.stringify(n)}).sort((t,n)=>t.localeCompare(n)).join(",")}function Kre(e,t){try{const n=qre(e),s=t.getItem(n);if(s){const r=JSON.parse(s);if(typeof r=="object"&&r!=null)return r}}catch{}return null}function Wqe(e,t,n){var s,r;const a=(s=Kre(e,n))!==null&&s!==void 0?s:{},o=Gre(t);return(r=a[o])!==null&&r!==void 0?r:null}function Yqe(e,t,n,s,r){var a;const o=qre(e),l=Gre(t),c=(a=Kre(e,r))!==null&&a!==void 0?a:{};c[l]={expandToSizes:Object.fromEntries(n.entries()),layout:s};try{r.setItem(o,JSON.stringify(c))}catch(u){console.error(u)}}function VB({layout:e,panelConstraints:t}){const n=[...e],s=n.reduce((a,o)=>a+o,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map(a=>`${a}%`).join(", ")}`);if(!Ba(s,100)&&n.length>0)for(let a=0;a<t.length;a++){const o=n[a];Vt(o!=null,`No layout data found for index ${a}`);const l=100/s*o;n[a]=l}let r=0;for(let a=0;a<t.length;a++){const o=n[a];Vt(o!=null,`No layout data found for index ${a}`);const l=Lp({panelConstraints:t,panelIndex:a,size:o});o!=l&&(r+=o-l,n[a]=l)}if(!Ba(r,0))for(let a=0;a<t.length;a++){const o=n[a];Vt(o!=null,`No layout data found for index ${a}`);const l=o+r,c=Lp({panelConstraints:t,panelIndex:a,size:l});if(o!==c&&(r-=c-o,n[a]=c,Ba(r,0)))break}return n}const Zqe=100,J0={getItem:e=>(UB(J0),J0.getItem(e)),setItem:(e,t)=>{UB(J0),J0.setItem(e,t)}},qB={};function Wre({autoSaveId:e=null,children:t,className:n="",direction:s,forwardedRef:r,id:a=null,onLayout:o=null,keyboardResizeBy:l=null,storage:c=J0,style:u,tagName:f="div",...h}){const m=oO(a),g=x.useRef(null),[b,v]=x.useState(null),[k,w]=x.useState([]),C=Lqe(),E=x.useRef({}),T=x.useRef(new Map),_=x.useRef(0),j=x.useRef({autoSaveId:e,direction:s,dragState:b,id:m,keyboardResizeBy:l,onLayout:o,storage:c}),R=x.useRef({layout:k,panelDataArray:[],panelDataArrayChanged:!1});x.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),x.useImperativeHandle(r,()=>({getId:()=>j.current.id,getLayout:()=>{const{layout:P}=R.current;return P},setLayout:P=>{const{onLayout:Z}=j.current,{layout:Q,panelDataArray:re}=R.current,ae=VB({layout:P,panelConstraints:re.map(de=>de.constraints)});HB(Q,ae)||(w(ae),R.current.layout=ae,Z&&Z(ae),cp(re,ae,E.current))}}),[]),hf(()=>{j.current.autoSaveId=e,j.current.direction=s,j.current.dragState=b,j.current.id=m,j.current.onLayout=o,j.current.storage=c}),Hqe({committedValuesRef:j,eagerValuesRef:R,groupId:m,layout:k,panelDataArray:R.current.panelDataArray,setLayout:w,panelGroupElement:g.current}),x.useEffect(()=>{const{panelDataArray:P}=R.current;if(e){if(k.length===0||k.length!==P.length)return;let Z=qB[e];Z==null&&(Z=Kqe(Yqe,Zqe),qB[e]=Z);const Q=[...P],re=new Map(T.current);Z(e,Q,re,k,c)}},[e,k,c]),x.useEffect(()=>{});const D=x.useCallback(P=>{const{onLayout:Z}=j.current,{layout:Q,panelDataArray:re}=R.current;if(P.constraints.collapsible){const ae=re.map(Ve=>Ve.constraints),{collapsedSize:de=0,panelSize:pe,pivotIndices:Oe}=Od(re,P,Q);if(Vt(pe!=null,`Panel size not found for panel "${P.id}"`),!jl(pe,de)){T.current.set(P.id,pe);const $e=Ep(re,P)===re.length-1?pe-de:de-pe,Qe=Q0({delta:$e,initialLayout:Q,panelConstraints:ae,pivotIndices:Oe,prevLayout:Q,trigger:"imperative-api"});w1(Q,Qe)||(w(Qe),R.current.layout=Qe,Z&&Z(Qe),cp(re,Qe,E.current))}}},[]),I=x.useCallback((P,Z)=>{const{onLayout:Q}=j.current,{layout:re,panelDataArray:ae}=R.current;if(P.constraints.collapsible){const de=ae.map(Se=>Se.constraints),{collapsedSize:pe=0,panelSize:Oe=0,minSize:Ve=0,pivotIndices:$e}=Od(ae,P,re),Qe=Z??Ve;if(jl(Oe,pe)){const Se=T.current.get(P.id),Ze=Se!=null&&Se>=Qe?Se:Qe,Me=Ep(ae,P)===ae.length-1?Oe-Ze:Ze-Oe,Ie=Q0({delta:Me,initialLayout:re,panelConstraints:de,pivotIndices:$e,prevLayout:re,trigger:"imperative-api"});w1(re,Ie)||(w(Ie),R.current.layout=Ie,Q&&Q(Ie),cp(ae,Ie,E.current))}}},[]),O=x.useCallback(P=>{const{layout:Z,panelDataArray:Q}=R.current,{panelSize:re}=Od(Q,P,Z);return Vt(re!=null,`Panel size not found for panel "${P.id}"`),re},[]),L=x.useCallback((P,Z)=>{const{panelDataArray:Q}=R.current,re=Ep(Q,P);return Gqe({defaultSize:Z,dragState:b,layout:k,panelData:Q,panelIndex:re})},[b,k]),B=x.useCallback(P=>{const{layout:Z,panelDataArray:Q}=R.current,{collapsedSize:re=0,collapsible:ae,panelSize:de}=Od(Q,P,Z);return Vt(de!=null,`Panel size not found for panel "${P.id}"`),ae===!0&&jl(de,re)},[]),H=x.useCallback(P=>{const{layout:Z,panelDataArray:Q}=R.current,{collapsedSize:re=0,collapsible:ae,panelSize:de}=Od(Q,P,Z);return Vt(de!=null,`Panel size not found for panel "${P.id}"`),!ae||Tf(de,re)>0},[]),K=x.useCallback(P=>{const{panelDataArray:Z}=R.current;Z.push(P),Z.sort((Q,re)=>{const ae=Q.order,de=re.order;return ae==null&&de==null?0:ae==null?-1:de==null?1:ae-de}),R.current.panelDataArrayChanged=!0,C()},[C]);hf(()=>{if(R.current.panelDataArrayChanged){R.current.panelDataArrayChanged=!1;const{autoSaveId:P,onLayout:Z,storage:Q}=j.current,{layout:re,panelDataArray:ae}=R.current;let de=null;if(P){const Oe=Wqe(P,ae,Q);Oe&&(T.current=new Map(Object.entries(Oe.expandToSizes)),de=Oe.layout)}de==null&&(de=qqe({panelDataArray:ae}));const pe=VB({layout:de,panelConstraints:ae.map(Oe=>Oe.constraints)});HB(re,pe)||(w(pe),R.current.layout=pe,Z&&Z(pe),cp(ae,pe,E.current))}}),hf(()=>{const P=R.current;return()=>{P.layout=[]}},[]);const U=x.useCallback(P=>{let Z=!1;const Q=g.current;return Q&&window.getComputedStyle(Q,null).getPropertyValue("direction")==="rtl"&&(Z=!0),function(ae){ae.preventDefault();const de=g.current;if(!de)return()=>null;const{direction:pe,dragState:Oe,id:Ve,keyboardResizeBy:$e,onLayout:Qe}=j.current,{layout:Se,panelDataArray:Ze}=R.current,{initialLayout:bt}=Oe??{},Me=Hre(Ve,P,de);let Ie=Vqe(ae,P,pe,Oe,$e,de);const Te=pe==="horizontal";Te&&Z&&(Ie=-Ie);const Je=Ze.map(Gt=>Gt.constraints),_t=Q0({delta:Ie,initialLayout:bt??Se,panelConstraints:Je,pivotIndices:Me,prevLayout:Se,trigger:Mre(ae)?"keyboard":"mouse-or-touch"}),St=!w1(Se,_t);(Dre(ae)||Ore(ae))&&_.current!=Ie&&(_.current=Ie,!St&&Ie!==0?Te?SN(P,Ie<0?Pre:Lre):SN(P,Ie<0?Fre:zre):SN(P,0)),St&&(w(_t),R.current.layout=_t,Qe&&Qe(_t),cp(Ze,_t,E.current))}},[]),$=x.useCallback((P,Z)=>{const{onLayout:Q}=j.current,{layout:re,panelDataArray:ae}=R.current,de=ae.map(Se=>Se.constraints),{panelSize:pe,pivotIndices:Oe}=Od(ae,P,re);Vt(pe!=null,`Panel size not found for panel "${P.id}"`);const $e=Ep(ae,P)===ae.length-1?pe-Z:Z-pe,Qe=Q0({delta:$e,initialLayout:re,panelConstraints:de,pivotIndices:Oe,prevLayout:re,trigger:"imperative-api"});w1(re,Qe)||(w(Qe),R.current.layout=Qe,Q&&Q(Qe),cp(ae,Qe,E.current))},[]),q=x.useCallback((P,Z)=>{const{layout:Q,panelDataArray:re}=R.current,{collapsedSize:ae=0,collapsible:de}=Z,{collapsedSize:pe=0,collapsible:Oe,maxSize:Ve=100,minSize:$e=0}=P.constraints,{panelSize:Qe}=Od(re,P,Q);Qe!=null&&(de&&Oe&&jl(Qe,ae)?jl(ae,pe)||$(P,pe):Qe<$e?$(P,$e):Qe>Ve&&$(P,Ve))},[$]),J=x.useCallback((P,Z)=>{const{direction:Q}=j.current,{layout:re}=R.current;if(!g.current)return;const ae=sE(P,g.current);Vt(ae,`Drag handle element not found for id "${P}"`);const de=Vre(Q,Z);v({dragHandleId:P,dragHandleRect:ae.getBoundingClientRect(),initialCursorPosition:de,initialLayout:re})},[]),ne=x.useCallback(()=>{v(null)},[]),F=x.useCallback(P=>{const{panelDataArray:Z}=R.current,Q=Ep(Z,P);Q>=0&&(Z.splice(Q,1),delete E.current[P.id],R.current.panelDataArrayChanged=!0,C())},[C]),V=x.useMemo(()=>({collapsePanel:D,direction:s,dragState:b,expandPanel:I,getPanelSize:O,getPanelStyle:L,groupId:m,isPanelCollapsed:B,isPanelExpanded:H,reevaluatePanelConstraints:q,registerPanel:K,registerResizeHandle:U,resizePanel:$,startDragging:J,stopDragging:ne,unregisterPanel:F,panelGroupElement:g.current}),[D,b,s,I,O,L,m,B,H,q,K,U,$,J,ne,F]),G={display:"flex",flexDirection:s==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return x.createElement(JC.Provider,{value:V},x.createElement(f,{...h,children:t,className:n,id:a,ref:g,style:{...G,...u},[ks.group]:"",[ks.groupDirection]:s,[ks.groupId]:m}))}const Yre=x.forwardRef((e,t)=>x.createElement(Wre,{...e,forwardedRef:t}));Wre.displayName="PanelGroup";Yre.displayName="forwardRef(PanelGroup)";function Ep(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function Od(e,t,n){const s=Ep(e,t),a=s===e.length-1?[s-1,s]:[s,s+1],o=n[s];return{...t.constraints,panelSize:o,pivotIndices:a}}function Xqe({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:s}){x.useEffect(()=>{if(e||n==null||s==null)return;const r=sE(t,s);if(r==null)return;const a=o=>{if(!o.defaultPrevented)switch(o.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{o.preventDefault(),n(o);break}case"F6":{o.preventDefault();const l=r.getAttribute(ks.groupId);Vt(l,`No group element found for id "${l}"`);const c=sy(l,s),u=$re(l,t,s);Vt(u!==null,`No resize element found for id "${t}"`);const f=o.shiftKey?u>0?u-1:c.length-1:u+1<c.length?u+1:0;c[f].focus();break}}};return r.addEventListener("keydown",a),()=>{r.removeEventListener("keydown",a)}},[s,e,t,n])}function Zre({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:s,id:r,onBlur:a,onClick:o,onDragging:l,onFocus:c,onPointerDown:u,onPointerUp:f,style:h={},tabIndex:m=0,tagName:g="div",...b}){var v,k;const w=x.useRef(null),C=x.useRef({onClick:o,onDragging:l,onPointerDown:u,onPointerUp:f});x.useEffect(()=>{C.current.onClick=o,C.current.onDragging=l,C.current.onPointerDown=u,C.current.onPointerUp=f});const E=x.useContext(JC);if(E===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:T,groupId:_,registerResizeHandle:j,startDragging:R,stopDragging:D,panelGroupElement:I}=E,O=oO(r),[L,B]=x.useState("inactive"),[H,K]=x.useState(!1),[U,$]=x.useState(null),q=x.useRef({state:L});hf(()=>{q.current.state=L}),x.useEffect(()=>{if(n)$(null);else{const V=j(O);$(()=>V)}},[n,O,j]);const J=(v=s==null?void 0:s.coarse)!==null&&v!==void 0?v:15,ne=(k=s==null?void 0:s.fine)!==null&&k!==void 0?k:5;x.useEffect(()=>{if(n||U==null)return;const V=w.current;Vt(V,"Element ref not attached");let G=!1;return Iqe(O,V,T,{coarse:J,fine:ne},(Z,Q,re)=>{if(!Q){B("inactive");return}switch(Z){case"down":{B("drag"),G=!1,Vt(re,'Expected event to be defined for "down" action'),R(O,re);const{onDragging:ae,onPointerDown:de}=C.current;ae==null||ae(!0),de==null||de();break}case"move":{const{state:ae}=q.current;G=!0,ae!=="drag"&&B("hover"),Vt(re,'Expected event to be defined for "move" action'),U(re);break}case"up":{B("hover"),D();const{onClick:ae,onDragging:de,onPointerUp:pe}=C.current;de==null||de(!1),pe==null||pe(),G||ae==null||ae();break}}})},[J,T,n,ne,j,O,U,R,D]),Xqe({disabled:n,handleId:O,resizeHandler:U,panelGroupElement:I});const F={touchAction:"none",userSelect:"none"};return x.createElement(g,{...b,children:e,className:t,id:r,onBlur:()=>{K(!1),a==null||a()},onFocus:()=>{K(!0),c==null||c()},ref:w,role:"separator",style:{...F,...h},tabIndex:m,[ks.groupDirection]:T,[ks.groupId]:_,[ks.resizeHandle]:"",[ks.resizeHandleActive]:L==="drag"?"pointer":H?"keyboard":void 0,[ks.resizeHandleEnabled]:!n,[ks.resizeHandleId]:O,[ks.resizeHandleState]:L})}Zre.displayName="PanelResizeHandle";class GB extends x.Component{constructor(){super(...arguments);nt(this,"state",{hasError:!1})}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(n,s){console.error("[RightPanel] Tab component error:",n,s)}componentDidUpdate(n){n.tabId!==this.props.tabId&&this.state.hasError&&this.setState({hasError:!1})}render(){return this.state.hasError?i.jsx("div",{className:"flex h-full items-center justify-center p-4",children:i.jsx("p",{className:"text-muted-foreground text-sm",children:"Something went wrong in this panel."})}):this.props.children}}const Qqe="flex-grow 300ms ease-in-out",Jqe="opacity 300ms ease-in-out";function eGe(){var k;const e=je(w=>w.rightPanelOpen),t=je(w=>w.setRightPanelOpen),n=je(w=>w.activeRightPanelTab),s=je(w=>w.setActiveRightPanelTab),r=Zs(),a=x.useRef(null),[o,l]=x.useState(!1),[c,u]=x.useState(!1);x.useEffect(()=>{const w=requestAnimationFrame(()=>u(!0));return()=>cancelAnimationFrame(w)},[]);const f=xy({select:w=>w.location.pathname}),m=Fu("right-panel").filter(w=>!w.visibleWhen||w.visibleWhen({pathname:f}));x.useEffect(()=>{m.length>0&&(m.some(C=>C.id===n)||s(m[0].id))},[m,n,s]);const g=e&&m.length>0;if(x.useEffect(()=>{const w=a.current;w&&(g&&w.isCollapsed()?w.expand():!g&&w.isExpanded()&&w.collapse())},[g]),m.length===0)return null;const b=(k=m.find(w=>w.id===n))==null?void 0:k.component;if(r)return g?i.jsx(Xl,{open:!0,onOpenChange:w=>!w&&t(!1),children:i.jsxs(Ql,{side:"right",showCloseButton:!1,className:"bg-sidebar text-sidebar-foreground flex w-full flex-col gap-0 p-0 sm:max-w-full",children:[i.jsxs(Jl,{className:"sr-only",children:[i.jsx(ec,{children:"Panel"}),i.jsx(ph,{children:"Right panel content."})]}),i.jsx(GB,{tabId:n,children:i.jsx(x.Suspense,{fallback:null,children:b&&i.jsx(b,{})})})]})}):null;const v=c&&!o;return i.jsxs(i.Fragment,{children:[i.jsx(Zre,{className:"group relative",style:{width:0,overflow:"visible"},disabled:!g,onDragging:l,children:i.jsx("div",{className:"absolute inset-y-0 -left-1 z-10 flex w-2 items-center justify-center",style:{opacity:g?1:0,pointerEvents:g?"auto":"none",...v&&{transition:Jqe}},children:i.jsx("div",{className:"group-hover:bg-ring/50 h-full w-px transition-colors duration-500"})})}),i.jsx(lO,{ref:a,id:"right-panel",order:2,defaultSize:g?35:0,minSize:20,collapsible:!0,collapsedSize:0,onCollapse:()=>t(!1),onExpand:()=>{e||t(!0)},style:v?{transition:Qqe}:void 0,children:i.jsx("div",{className:"bg-sidebar text-sidebar-foreground flex h-full flex-col overflow-hidden border-l",children:i.jsx("div",{className:"flex-1 overflow-hidden",children:i.jsx(GB,{tabId:n,children:i.jsx(x.Suspense,{fallback:null,children:b&&i.jsx(b,{})})})})})})]})}function tGe(){const e=je(c=>c.rightPanelOpen),t=je(c=>c.toggleRightPanel),n=xy({select:c=>c.location.pathname});if(Fu("right-panel").filter(c=>!c.visibleWhen||c.visibleWhen({pathname:n})).length===0)return null;const a=e?MTe:IX,o=e?"Close right panel":"Open right panel",l=Dm?"⌘.":"Ctrl+.";return i.jsxs(Kn,{children:[i.jsx(Wn,{asChild:!0,children:i.jsx(oe.button,{"aria-label":o,className:"text-muted-foreground hover:text-foreground relative flex h-7 w-7 items-center justify-center rounded-md transition-colors",onClick:t,whileHover:{scale:1.1},whileTap:{scale:.93},transition:{type:"spring",stiffness:600,damping:35},children:i.jsx(a,{className:"size-4"})})}),i.jsxs(Yn,{children:[i.jsx("span",{className:"pr-2",children:"Toggle right panel"}),i.jsx(Br,{className:"relative z-10",children:l})]})]})}function nGe(){const e=je(t=>t.loadRightPanelState);x.useEffect(()=>{e()},[e])}function sGe(){const e=je(t=>t.toggleRightPanel);x.useEffect(()=>{const t=n=>{(n.metaKey||n.ctrlKey)&&n.key==="."&&(n.preventDefault(),e())};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e])}function rGe(){const e=je(n=>n.setRightPanelOpen),t=je(n=>n.setActiveRightPanelTab);x.useEffect(()=>{const n=s=>{if((s.metaKey||s.ctrlKey)&&s.shiftKey&&s.key==="A"){s.preventDefault();const{rightPanelOpen:r,activeRightPanelTab:a}=je.getState();r&&a==="agent-hub"?e(!1):(t("agent-hub"),e(!0))}};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)},[e,t])}const aGe=x.lazy(()=>Ar(()=>import("./SessionsTab-BjOaGzWL.js"),[]).then(e=>({default:e.SessionsTab}))),iGe=x.lazy(()=>Ar(()=>import("./ConfigTab-BshXF_Ah.js"),[]).then(e=>({default:e.ConfigTab}))),oGe=x.lazy(()=>Ar(()=>import("./ToolkitTab-BZNbWVwL.js"),[]).then(e=>({default:e.ToolkitTab})));function nct(){const e=Eu(n=>n.activeTab),t={sessions:aGe,config:iGe,toolkit:oGe}[e];return i.jsx("div",{"data-slot":"agent-hub-tab-content",className:"flex-1 overflow-auto",children:i.jsx(x.Suspense,{fallback:null,children:i.jsx(t,{})})})}function lGe({onStepComplete:e}){const[t,n]=x.useState({...lVe}),[s,r]=x.useState(null),a=PUe(),{config:o}=fb(),l=je(u=>u.setDorkbotFirstMessage),c=x.useCallback(()=>{var h;r(null);const f=`${((h=o==null?void 0:o.agents)==null?void 0:h.defaultDirectory)||"~/.dork/agents"}/dorkbot`;a.mutate({path:f,updates:{traits:t}},{onSuccess:()=>{l(pqe(t)),xG(),e()},onError:m=>{r(m instanceof Error?m.message:"Failed to update personality")}})},[t,o,a,e,l]);return i.jsxs("div",{className:"flex flex-1 flex-col items-center gap-4 overflow-y-auto py-4",children:[i.jsxs("div",{className:"space-y-2 text-center",children:[i.jsx("h2",{className:"text-2xl font-semibold tracking-tight",children:"Meet DorkBot"}),i.jsxs("p",{className:"text-muted-foreground max-w-sm text-sm",children:["Your first agent and DorkOS expert.",i.jsx("br",{}),"Choose DorkBot's personality."]})]}),i.jsx(kqe,{traits:t,onTraitsChange:n,sampleLabel:"How DorkBot will talk"}),s&&i.jsx("p",{className:"text-destructive text-sm",role:"alert","data-testid":"update-error",children:s}),i.jsxs("div",{className:"mt-2 flex flex-col items-center gap-2",children:[i.jsx(ve,{onClick:c,disabled:a.isPending,"data-testid":"continue-dorkbot",children:a.isPending?"Saving...":"Continue"}),i.jsx("p",{className:"text-muted-foreground text-xs",children:"Adjustable anytime in settings."})]})]})}const KB={candidates:[],existingAgents:[],progress:null,isScanning:!1,error:null,lastScanAt:null},uO=Fo()(Au(e=>({...KB,startScan:()=>e({candidates:[],existingAgents:[],progress:null,isScanning:!0,error:null},!1,"discovery/startScan"),addCandidate:t=>e(n=>({candidates:[...n.candidates,t]}),!1,"discovery/addCandidate"),addExistingAgent:t=>e(n=>({existingAgents:[...n.existingAgents,t]}),!1,"discovery/addExistingAgent"),setProgress:t=>e({progress:t},!1,"discovery/setProgress"),completeScan:t=>e({progress:t,isScanning:!1,lastScanAt:new Date().toISOString()},!1,"discovery/completeScan"),setError:t=>e({error:t,isScanning:!1},!1,"discovery/setError"),reset:()=>e(KB,!1,"discovery/reset")}),{name:"DiscoveryStore"}));function Xre(){const e=Fe(),t=x.useRef(null),{startScan:n,addCandidate:s,addExistingAgent:r,setProgress:a,completeScan:o,setError:l}=uO(),c=x.useCallback((f={roots:[]})=>{var m;(m=t.current)==null||m.abort();const h=new AbortController;t.current=h,n(),e.scan(f,g=>{switch(g.type){case"candidate":s(g.data);break;case"existing-agent":r(g.data);break;case"progress":a(g.data);break;case"complete":o(g.data);break;case"error":l(g.data.error);break}},h.signal).catch(g=>{g instanceof Error&&g.name!=="AbortError"&&l(g.message)})},[e,n,s,r,a,o,l]),u=x.useCallback(()=>{var f;(f=t.current)==null||f.abort(),t.current=null},[]);return{startScan:c,stopScan:u}}function Qre(){const[e,t]=x.useState(new Set),n=x.useCallback(r=>{t(a=>new Set(a).add(r))},[]),s=x.useCallback(()=>{t(new Set)},[]);return{actedPaths:e,markActed:n,resetActed:s}}function jw(e){return{name:e.hints.suggestedName,runtime:e.hints.detectedRuntime,...e.hints.inferredCapabilities?{capabilities:e.hints.inferredCapabilities}:{},...e.hints.description?{description:e.hints.description}:{}}}function Jre(e){return[...e].sort((t,n)=>{const s=t.strategy==="dork-manifest",r=n.strategy==="dork-manifest";return s!==r?s?-1:1:t.path.localeCompare(n.path)})}const cGe={"claude-code":"Detected a AGENTS.md file — this is a Claude Code project.",cursor:"Detected a .cursor/ directory — this is a Cursor project.",codex:"Detected a .codex/ directory — this is a Codex project.","dork-manifest":"Found an existing .dork/agent.json — already configured as a DorkOS agent."};function uGe(e){return cGe[e]??`Detected via "${e}" strategy.`}const dGe={"code-review":"Reviews code for bugs, style issues, and correctness.",summarize:"Summarizes documents, conversations, or code.","file-ops":"Reads and writes files on the filesystem.",test:"Generates and runs tests for a codebase.",search:"Searches code, files, or the web for relevant information.",refactor:"Refactors code while preserving existing behavior.",analyze:"Analyzes data, logs, or codebases for patterns and insights.",generate:"Generates code, content, or structured output.",debug:"Diagnoses and fixes bugs in code.",deploy:"Manages deployment pipelines and infrastructure changes."};function fGe(e){return dGe[e]??"Agent capability detected from project structure."}function eae({candidate:e,onApprove:t,onDeny:n,onSkip:s,className:r}){const{path:a,strategy:o,hints:l}=e;return i.jsxs(oe.div,{"data-slot":"candidate-card",layout:!0,initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:-6},transition:{duration:.15,ease:"easeOut"},className:X("flex items-start justify-between rounded-xl border p-4",r),children:[i.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[i.jsx("p",{className:"text-sm leading-tight font-semibold",children:l.suggestedName||a.split("/").pop()||a}),i.jsxs("div",{className:"text-muted-foreground flex items-center gap-1.5 text-xs",children:[i.jsx(Gp,{className:"size-3 shrink-0"}),i.jsx("span",{className:"truncate font-mono",children:a})]}),i.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[i.jsxs(GD,{openDelay:300,children:[i.jsx(KD,{asChild:!0,children:i.jsx(Ot,{variant:"secondary",className:"hover:bg-secondary/80 cursor-default text-xs",children:l.detectedRuntime})}),i.jsxs(WD,{className:"w-56 space-y-1.5 p-3",side:"top",align:"start",children:[i.jsx("p",{className:"text-xs font-medium",children:"Detected runtime"}),i.jsx("p",{className:"text-muted-foreground text-xs",children:uGe(o)})]})]}),l.inferredCapabilities&&l.inferredCapabilities.length>0&&l.inferredCapabilities.map(c=>i.jsxs(Kn,{children:[i.jsx(Wn,{asChild:!0,children:i.jsx(Ot,{variant:"outline",className:"cursor-default text-[10px]",children:c})}),i.jsx(Yn,{side:"top",className:"max-w-48 text-center",children:fGe(c)})]},c))]})]}),i.jsxs("div",{className:"ml-4 flex shrink-0 items-center gap-1.5",children:[i.jsx("button",{type:"button",onClick:()=>t(e),className:"focus-visible:ring-ring rounded-md bg-green-600/10 px-2.5 py-1 text-xs font-medium text-green-700 hover:bg-green-600/20 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none dark:text-green-400",children:"Add"}),s&&i.jsx("button",{type:"button",onClick:()=>s(e),className:"text-muted-foreground hover:bg-muted focus-visible:ring-ring rounded-md px-2.5 py-1 text-xs font-medium focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",children:"Skip"}),n&&i.jsx("button",{type:"button",onClick:()=>n(e),className:"focus-visible:ring-ring rounded-md bg-red-600/10 px-2.5 py-1 text-xs font-medium text-red-700 hover:bg-red-600/20 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none dark:text-red-400",children:"Deny"})]})]})}function hGe({agent:e}){return i.jsxs("div",{className:"bg-muted/50 flex items-center gap-3 rounded-lg border px-4 py-3",children:[i.jsx(qf,{className:"text-muted-foreground size-4 shrink-0"}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("p",{className:"truncate text-sm font-medium",children:tn(e)}),i.jsx("p",{className:"text-muted-foreground truncate text-xs",children:e.path})]}),i.jsx("span",{className:"text-muted-foreground shrink-0 text-xs",children:"Imported"})]})}const pGe=2;function tae({agents:e}){const[t,n]=x.useState(e.length<=pGe);return e.length===0?null:i.jsxs("div",{children:[i.jsxs("button",{type:"button",onClick:()=>n(s=>!s),className:"text-muted-foreground hover:text-foreground flex w-full items-center gap-1.5 py-1.5 text-xs transition-colors",children:[i.jsx(Ws,{className:X("size-3 transition-transform",t&&"rotate-90")}),e.length," project",e.length===1?"":"s"," already in DorkOS"]}),t&&i.jsx("div",{className:"mt-2 space-y-2",children:e.map(s=>i.jsx(hGe,{agent:s},s.path))})]})}function nae({count:e,onAddAll:t,disabled:n}){return e===0?null:i.jsxs("div",{className:"flex items-center justify-between py-1",children:[i.jsxs("span",{className:"text-muted-foreground text-sm font-medium",children:[e," new project",e===1?"":"s"]}),i.jsx(ve,{variant:"outline",size:"sm",onClick:t,disabled:n,children:"Add All"})]})}function sae({roots:e,onChange:t}){const[n,s]=x.useState(""),[r,a]=x.useState(!1),o=x.useCallback(f=>{const h=f.trim();h&&!e.includes(h)&&t([...e,h])},[e,t]),l=x.useCallback(f=>{t(e.filter(h=>h!==f))},[e,t]),c=x.useCallback(f=>{(f.key==="Enter"||f.key===",")&&(f.preventDefault(),n.trim()&&(o(n),s(""))),f.key==="Backspace"&&n===""&&e.length>0&&l(e[e.length-1])},[n,e,o,l]),u=x.useCallback(f=>{o(f)},[o]);return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"focus-within:ring-ring flex min-h-[40px] flex-wrap items-center gap-1.5 rounded-md border bg-transparent px-3 py-1.5 focus-within:ring-2",children:[e.map(f=>i.jsxs(Ot,{variant:"secondary",className:"gap-1 py-0.5 font-mono text-xs",children:[f,i.jsx("button",{type:"button",onClick:()=>l(f),className:"hover:bg-muted-foreground/20 ml-0.5 rounded-sm","aria-label":`Remove ${f}`,children:i.jsx(ls,{className:"size-3"})})]},f)),i.jsx("input",{type:"text",value:n,onChange:f=>s(f.target.value),onKeyDown:c,placeholder:e.length===0?"Add paths to scan (Enter to add)":"Add more...",className:"placeholder:text-muted-foreground min-w-[120px] flex-1 bg-transparent text-sm focus-visible:outline-none"}),i.jsx("button",{type:"button",onClick:()=>a(!0),className:"text-muted-foreground hover:bg-accent hover:text-foreground shrink-0 rounded p-1","aria-label":"Browse for directory",children:i.jsx(Kf,{className:"size-4"})})]}),i.jsx(jC,{open:r,onOpenChange:a,onSelect:u})]})}function mGe({onAgentCreated:e}){var g;const[t,n]=x.useState(""),[s,r]=x.useState(""),[a,o]=x.useState(""),[l,c]=x.useState(!1),[u,f]=x.useState(!1),h=IUe(),m=x.useCallback(()=>{!t||!s.trim()||h.mutate({path:t,name:s.trim(),description:a.trim()||void 0},{onSuccess:()=>{f(!0),setTimeout(e,1200)}})},[t,s,a,h,e]);return u?i.jsxs("div",{className:"flex flex-col items-center justify-center space-y-4 py-12 text-center",children:[i.jsx(qf,{className:"text-primary size-12"}),i.jsx("h3",{className:"text-lg font-semibold",children:"Agent created"}),i.jsxs("p",{className:"text-muted-foreground text-sm",children:[i.jsx("span",{className:"font-medium",children:s})," is ready at"," ",i.jsx("span",{className:"font-mono text-xs",children:Pl(t)})]})]}):i.jsx("div",{className:"flex flex-col items-center justify-center",children:i.jsxs("div",{className:"w-full max-w-sm space-y-4",children:[i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(jn,{htmlFor:"agent-directory",children:"Project directory"}),i.jsxs("button",{id:"agent-directory",type:"button",onClick:()=>c(!0),className:`border-input bg-background hover:bg-accent flex h-10 w-full items-center gap-2 rounded-md border px-3 text-sm transition-colors ${t?"text-foreground":"text-muted-foreground"}`,children:[i.jsx(Kf,{className:"size-4 flex-shrink-0"}),i.jsx("span",{className:"truncate",children:t?Pl(t):"Select a directory..."})]}),i.jsx(jC,{open:l,onOpenChange:c,onSelect:n})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(jn,{htmlFor:"agent-name",children:"Agent name"}),i.jsx(_n,{id:"agent-name",type:"text",placeholder:"e.g. my-project",value:s,onChange:b=>r(b.target.value)})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs(jn,{htmlFor:"agent-persona",children:["Persona ",i.jsx("span",{className:"text-muted-foreground font-normal",children:"(optional)"})]}),i.jsx(K3,{id:"agent-persona",placeholder:"Describe what this agent does...",value:a,onChange:b=>o(b.target.value),rows:3})]}),i.jsx(ve,{className:"w-full",onClick:m,disabled:!t||!s.trim()||h.isPending,children:h.isPending?i.jsxs(i.Fragment,{children:[i.jsx(Xn,{className:"size-4 animate-spin"}),"Creating..."]}):"Create agent"}),h.isError&&i.jsxs("p",{className:"text-destructive text-center text-sm",children:["Failed to initialize agent. ",((g=h.error)==null?void 0:g.message)??"Please try again."]})]})})}function gGe({onStepComplete:e}){const{startScan:t}=Xre(),{candidates:n,existingAgents:s,isScanning:r,progress:a,error:o}=uO(),l=gre(),{actedPaths:c,markActed:u,resetActed:f}=Qre(),[h,m]=x.useState(!1),[g,b]=x.useState(!1),[v,k]=x.useState(3),{roots:w,setScanRoots:C}=yre(),[E,T]=x.useState(null),_=E??w,j=vr(),R=x.useRef(!1);x.useEffect(()=>{R.current||(R.current=!0,m(!0),t())},[t]);const D=x.useMemo(()=>r?n:Jre(n),[n,r]),I=x.useCallback(G=>{u(G.path),l.mutate({path:G.path,overrides:jw(G)})},[l,u]),O=x.useCallback(G=>{u(G.path)},[u]),L=x.useCallback(()=>{for(const G of D)c.has(G.path)||(u(G.path),l.mutate({path:G.path,overrides:jw(G)}))},[D,c,l,u]),B=x.useCallback(G=>{T(G),C(G)},[C]),H=x.useCallback(()=>{f(),m(!0),t(_.length>0?{roots:_,maxDepth:v}:{roots:[]})},[t,f,_,v]),K=x.useCallback(()=>{H()},[H]),U=s.length>0,$=n.length>0,q=U||$,J=h&&!r,ne=J&&!q,F=!$||n.every(G=>c.has(G.path)),V=D.filter(G=>!c.has(G.path));return i.jsxs("div",{className:"flex min-h-0 w-full flex-1 flex-col items-center",children:[i.jsxs("div",{className:"w-full shrink-0 text-center",children:[i.jsx("h2",{className:"text-2xl font-semibold tracking-tight sm:text-3xl",children:r&&!q?"Searching your machine...":ne?"Create Your First Agent":"Projects Found"}),r&&!q&&i.jsxs("div",{className:"mt-2 space-y-1",children:[i.jsx("p",{className:"text-muted-foreground text-sm",children:"Looking for existing projects on your machine."}),i.jsx("p",{className:"text-muted-foreground text-sm",children:"Once imported, your agents can work across them — and you can connect to Slack, Telegram, and more."})]}),ne&&i.jsx("p",{className:"text-muted-foreground mt-2 text-sm",children:"No projects were found on your machine."})]}),r&&!q&&i.jsxs("div",{className:"mt-8 flex shrink-0 flex-col items-center gap-4",children:[i.jsx(oe.div,{animate:j?{}:{scale:[1,1.15,1]},transition:{duration:1.5,repeat:1/0,ease:"easeInOut"},children:i.jsx(Ti,{className:"text-muted-foreground size-8"})}),a&&i.jsxs("p",{className:"text-muted-foreground text-sm",children:["Scanned ",a.scannedDirs," directories"]})]}),r&&q&&a&&i.jsxs("div",{className:"text-muted-foreground mt-4 shrink-0 text-center text-sm",children:["Scanning... ",a.scannedDirs," directories · Found ",a.foundAgents," ","project",a.foundAgents===1?"":"s"]}),J&&q&&i.jsx("p",{className:"text-muted-foreground mt-3 shrink-0 text-center text-sm",children:"Add existing projects you want to manage in DorkOS. You can assign agents, schedule tasks, and connect to Slack, Telegram, and more."}),o&&i.jsx("div",{className:"border-destructive/30 bg-destructive/5 text-destructive mt-6 shrink-0 rounded-lg border px-4 py-3 text-sm",children:o}),q&&i.jsx("div",{className:"mt-4 min-h-0 w-full flex-1 overflow-y-auto pr-1",children:i.jsxs("div",{className:"space-y-3",children:[V.length>0&&i.jsx(nae,{count:V.length,onAddAll:L}),i.jsx(He,{mode:"popLayout",children:V.map(G=>i.jsx(eae,{candidate:G,onApprove:I,onSkip:O},G.path))}),U&&i.jsx(tae,{agents:s})]})}),ne&&i.jsxs("div",{className:"mt-6 w-full",children:[i.jsx(mGe,{onAgentCreated:K}),i.jsxs("div",{className:"mt-4",children:[i.jsxs("button",{type:"button",onClick:()=>b(!g),className:"text-muted-foreground hover:text-foreground mx-auto flex items-center gap-1 text-xs",children:[i.jsx(Ps,{className:`size-3 transition-transform ${g?"":"-rotate-90"}`}),"Scan options"]}),g&&i.jsxs("div",{className:"bg-muted/30 mt-2 space-y-3 rounded-lg border p-3",children:[i.jsx(sae,{roots:_,onChange:B}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("label",{htmlFor:"onboarding-scan-depth",className:"text-muted-foreground text-xs",children:"Scan depth"}),i.jsx("input",{id:"onboarding-scan-depth",type:"range",min:1,max:5,value:v,onChange:G=>k(Number(G.target.value)),className:"flex-1"}),i.jsx("span",{className:"min-w-[1.5rem] text-center text-xs font-medium",children:v})]})]})]}),i.jsxs("div",{className:"mt-6 flex flex-col items-center gap-3",children:[i.jsx(ve,{variant:"outline",size:"sm",onClick:H,children:"Scan Again"}),i.jsx("button",{onClick:e,className:"text-muted-foreground hover:text-foreground text-sm transition-colors",children:"Continue without adding"})]})]}),J&&q&&i.jsx("div",{className:"mt-4 flex shrink-0 flex-col items-center gap-2 border-t pt-4",children:i.jsx(ve,{size:"lg",onClick:e,variant:F?"default":"outline",children:"Continue"})})]})}function xGe({onStepComplete:e,agents:t}){const{data:n,isLoading:s,isError:r}=tO(),a=Q5(),[o,l]=x.useState(null),[c,u]=x.useState(!1),[f,h]=x.useState(null),m=t.length===1?t[0]:t.find(C=>C.id===f)??null,g=x.useMemo(()=>o??new Set((n==null?void 0:n.map(C=>C.id))??[]),[o,n]),b=x.useCallback(C=>{l(E=>{const T=E??new Set((n==null?void 0:n.map(j=>j.id))??[]),_=new Set(T);return _.has(C)?_.delete(C):_.add(C),_})},[n]),v=g.size,k=v>0&&m!==null,w=x.useCallback(async()=>{if(!n||v===0||!m){e();return}u(!0);const C=n.filter(_=>g.has(_.id)),T=(await Promise.allSettled(C.map(_=>a.mutateAsync({name:_.name,description:_.description,prompt:_.prompt,cron:_.cron,target:m.id})))).filter(_=>_.status==="rejected");T.length>0&&(console.error("[TaskTemplatesStep] Schedule creation failures:",T),rt.warning(`${T.length} of ${C.length} schedule(s) failed to create. You can retry from Tasks later.`)),u(!1),e()},[n,v,g,m,a,e]);return i.jsxs("div",{className:"mx-auto w-full max-w-2xl flex-1 space-y-4 overflow-y-auto px-4",children:[i.jsxs("div",{className:"space-y-2 text-center",children:[i.jsx("h2",{className:"text-2xl font-semibold tracking-tight",children:"Want your agents to work while you sleep?"}),i.jsx("p",{className:"text-muted-foreground text-sm",children:"Tasks runs automated tasks on a schedule — like a cron job for your agents."})]}),t.length===1&&i.jsxs("p",{className:"text-muted-foreground text-center text-sm",children:["Scheduling for ",t[0].icon?`${t[0].icon} `:"",t[0].name]}),t.length>=2&&i.jsx("div",{className:"mx-auto max-w-xs",children:i.jsxs(Bn,{value:f??"",onValueChange:h,children:[i.jsx(Dn,{children:i.jsx($n,{placeholder:"Select a project..."})}),i.jsx(On,{children:t.map(C=>i.jsxs(yt,{value:C.id,children:[C.icon?`${C.icon} `:"",tn(C)]},C.id))})]})}),s&&i.jsx("p",{className:"text-muted-foreground text-center text-sm",children:"Loading presets..."}),r&&i.jsx("p",{className:"text-destructive text-center text-sm",children:"Failed to load presets. You can skip this step and configure schedules later."}),n&&n.length>0&&i.jsx("div",{className:"grid gap-3",children:n.map(C=>i.jsx(vre,{preset:C,variant:"toggle",checked:g.has(C.id),onCheckedChange:()=>b(C.id)},C.id))}),i.jsxs("div",{className:"flex flex-col items-center gap-3 pt-2",children:[i.jsx(ve,{onClick:w,size:"lg",disabled:c||v>0&&!k,children:c?"Creating...":v>0?`Create ${v} Schedule${v===1?"":"s"}`:"Continue Without Schedules"}),t.length>=2&&i.jsx("p",{className:"text-muted-foreground text-xs",children:"You can put your other agents on autopilot anytime from Tasks."})]})]})}const kN=["You're","all","set!"];function yGe({onComplete:e}){const t=vr(),{state:n}=fb(),s=x.useRef(!1);x.useEffect(()=>{s.current||(s.current=!0,u3())},[]);const r=n.completedSteps.includes("meet-dorkbot"),a=n.completedSteps.includes("discovery"),o=n.completedSteps.includes("tasks"),l=[{icon:zy,label:r?"Met DorkBot":"DorkBot skipped",done:r},{icon:Hy,label:a?"Agents discovered":"Agents skipped",done:a},{icon:Ja,label:o?"Schedules created":"Schedules skipped",done:o}];return i.jsxs(oe.div,{initial:t?!1:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{duration:.3,ease:"easeOut"},className:"mx-auto flex w-full max-w-md flex-col items-center gap-8 px-4 text-center",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx("h2",{className:"text-3xl font-semibold tracking-tight",children:t?kN.join(" "):i.jsx(oe.span,{initial:"hidden",animate:"visible",variants:{visible:{transition:{staggerChildren:.08}}},children:kN.map((c,u)=>i.jsxs(oe.span,{className:"inline-block",variants:{hidden:{opacity:0,filter:"blur(4px)"},visible:{opacity:1,filter:"blur(0px)"}},transition:{duration:.4},children:[c,u<kN.length-1?" ":""]},u))})}),i.jsx("p",{className:"text-muted-foreground",children:"Your workspace is configured and ready."})]}),i.jsx(oe.div,{className:"w-full space-y-3",initial:"hidden",animate:"visible",variants:t?{}:{visible:{transition:{staggerChildren:.12,delayChildren:.3}}},children:l.map(({icon:c,label:u,done:f})=>i.jsxs(oe.div,{variants:t?{}:{hidden:{opacity:0,y:12},visible:{opacity:1,y:0}},transition:{duration:.3},className:"flex items-center gap-3 rounded-lg border p-4",children:[i.jsx(c,{className:`size-5 ${f?"text-primary":"text-muted-foreground/50"}`}),i.jsx("span",{className:f?"text-sm":"text-muted-foreground text-sm",children:u})]},u))}),i.jsx(oe.div,{initial:t?!1:{opacity:0},animate:{opacity:1},transition:{delay:.8,duration:.4},children:i.jsx(qD,{className:"px-6 py-2",duration:1.2,onClick:e,children:"Start your first session"})})]})}const ex=["meet-dorkbot","discovery","tasks"],bGe=ex.indexOf("tasks"),CN=-2,WB=-1;function rae({onComplete:e,initialStep:t=CN}){var L;const[n,s]=x.useState(t),[r,a]=x.useState(1),[o,l]=x.useState(!1),{completeStep:c,skipStep:u,dismiss:f,startOnboarding:h,config:m}=fb(),g=cs(),b=Zs(),v=vr(),k=hb();x.useEffect(()=>{h()},[]);const w=x.useCallback(()=>{n<ex.length-1?(a(1),s(B=>B+1)):(c("adapters"),l(!0))},[n,c]),C=x.useCallback(()=>{n>0?(a(-1),s(B=>B-1)):n===0&&(a(-1),s(CN))},[n]),E=x.useCallback(()=>{c(ex[n]),w()},[n,c,w]),T=x.useCallback(()=>{u(ex[n]),w()},[n,u,w]),_=x.useCallback(async()=>{await f(),e()},[f,e]),j=x.useCallback(()=>{a(1),s(WB)},[]),R=x.useCallback(()=>{a(1),s(0)},[]),D=x.useCallback(()=>{var U,$;const B=((U=m==null?void 0:m.agents)==null?void 0:U.defaultAgent)||"dorkbot",K=`${(($=m==null?void 0:m.agents)==null?void 0:$.defaultDirectory)||"~/.dork/agents"}/${B}`;g({to:"/session",search:{dir:K}}),e()},[m,g,e]);if(x.useEffect(()=>{var B;n===bGe&&!k.isLoading&&((B=k.data)==null?void 0:B.agents.length)===0&&(c("tasks"),w())},[n,k.isLoading,k.data,c,w]),o)return i.jsx("div",{className:"bg-background flex h-full w-full items-center justify-center",children:i.jsx(yGe,{onComplete:D})});if(n===CN)return i.jsx("div",{className:"bg-background flex h-full w-full items-center justify-center",children:i.jsx(hqe,{onGetStarted:j,onSkip:_})});if(n===WB)return i.jsx("div",{className:"bg-background flex h-full w-full items-center justify-center",children:i.jsx(cqe,{onContinue:R})});const I=b?150:300,O=v?{enter:{opacity:0},center:{opacity:1},exit:{opacity:0}}:{enter:B=>({x:B>0?I:-I,opacity:0,scale:.98,filter:"blur(2px)"}),center:{x:0,opacity:1,scale:1,filter:"blur(0px)"},exit:B=>({x:B>0?-I:I,opacity:0,scale:.98,filter:"blur(2px)"})};return i.jsxs("div",{className:"bg-background flex h-full w-full flex-col",children:[i.jsx(nqe,{totalSteps:ex.length,currentStep:n,onBack:C,onSkip:T,onSkipAll:_}),i.jsx("div",{className:"relative flex-1 overflow-hidden",children:i.jsx(He,{mode:"wait",custom:r,children:i.jsx(oe.div,{custom:r,variants:O,initial:"enter",animate:"center",exit:"exit",transition:{type:v?"tween":"spring",damping:25,stiffness:200,duration:v?.15:void 0},className:"absolute inset-0 flex flex-col",children:i.jsxs("div",{className:"mx-auto flex min-h-0 w-full max-w-2xl flex-1 flex-col px-4 py-4 sm:px-6",children:[n===0&&i.jsx(lGe,{onStepComplete:E}),n===1&&i.jsx(gGe,{onStepComplete:E}),n===2&&i.jsx(xGe,{onStepComplete:E,agents:((L=k.data)==null?void 0:L.agents)??[]})]})},n)})})]})}const rE=["relay","bindings"];function pb(){const e=Fe();return mt({queryKey:[...rE],queryFn:()=>e.getBindings()})}function dO(){const e=Fe(),t=Ct();return mn({mutationFn:n=>e.createBinding(n),onSuccess:()=>{t.invalidateQueries({queryKey:[...rE]})}})}function vGe(){const e=Fe(),t=Ct();return mn({mutationFn:n=>e.deleteBinding(n),onSuccess:()=>{t.invalidateQueries({queryKey:[...rE]})}})}function SGe(){const e=Fe(),t=Ct();return mn({mutationFn:({id:n,updates:s})=>e.updateBinding(n,s),onSuccess:()=>{t.invalidateQueries({queryKey:[...rE]})}})}const fO={healthy:{dot:"bg-green-500",text:"text-green-600 dark:text-green-400",border:"border-l-green-500"},delivered:{dot:"bg-green-500",text:"text-green-600 dark:text-green-400",border:"border-l-green-500"},connected:{dot:"bg-green-500",text:"text-green-600 dark:text-green-400",border:"border-l-green-500"},pending:{dot:"bg-blue-500",text:"text-blue-600 dark:text-blue-400",border:"border-l-blue-500"},starting:{dot:"bg-blue-500",text:"text-blue-600 dark:text-blue-400",border:"border-l-blue-500"},new:{dot:"bg-blue-500",text:"text-blue-600 dark:text-blue-400",border:"border-l-blue-500"},reconnecting:{dot:"bg-amber-500",text:"text-amber-600 dark:text-amber-400",border:"border-l-amber-500"},degraded:{dot:"bg-amber-500",text:"text-amber-600 dark:text-amber-400",border:"border-l-amber-500"},warning:{dot:"bg-amber-500",text:"text-amber-600 dark:text-amber-400",border:"border-l-amber-500"},rate_limited:{dot:"bg-amber-500",text:"text-amber-600 dark:text-amber-400",border:"border-l-amber-500"},failed:{dot:"bg-red-500",text:"text-red-600 dark:text-red-400",border:"border-l-red-500"},error:{dot:"bg-red-500",text:"text-red-600 dark:text-red-400",border:"border-l-red-500"},disconnected:{dot:"bg-red-500",text:"text-red-600 dark:text-red-400",border:"border-l-red-500"},inactive:{dot:"bg-gray-400",text:"text-muted-foreground",border:"border-l-gray-400"},stopped:{dot:"bg-gray-400",text:"text-muted-foreground",border:"border-l-gray-400"}};function wGe(e){var t;return((t=fO[e])==null?void 0:t.dot)??"bg-gray-400"}function kGe(e){var t;return((t=fO[e])==null?void 0:t.text)??"text-muted-foreground"}function CGe(e){var t;return((t=fO[e])==null?void 0:t.border)??"border-l-gray-400"}function YR(e){const t=Date.now()-new Date(e).getTime(),n=Math.floor(t/1e3);if(n<60)return"just now";const s=Math.floor(n/60);if(s<60)return`${s}m ago`;const r=Math.floor(s/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function EGe(e){switch(e){case"delivered":return"bg-green-500";case"failed":return"bg-red-500";case"sent":return"bg-yellow-500";case"timeout":return"bg-gray-500";default:return"bg-gray-400"}}function TGe(e){return new Date(e).toLocaleTimeString()}function YB(e,t){if(e==null||t==null)return null;const n=new Date(t).getTime()-new Date(e).getTime();return n<1e3?`${n}ms`:`${(n/1e3).toFixed(1)}s`}function _Ge({messageId:e,onClose:t}){const{data:n,isLoading:s,error:r}=qUe(e);if(s)return i.jsx("div",{className:"text-muted-foreground p-4 text-sm",children:"Loading trace..."});if(r||!n)return i.jsx("div",{className:"text-destructive p-4 text-sm",children:"Failed to load trace."});const{traceId:a,spans:o}=n;return i.jsxs("div",{className:"flex flex-col gap-2 p-4",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("span",{className:"text-muted-foreground font-mono text-xs",children:["Trace: ",a.slice(0,8),"..."]}),t&&i.jsx("button",{onClick:t,className:"text-muted-foreground hover:text-foreground text-xs",children:"Close"})]}),i.jsx("div",{className:"border-border relative ml-3 border-l pl-6",children:o.map(l=>{const c=YB(l.sentAt,l.deliveredAt),u=YB(l.deliveredAt,l.processedAt);return i.jsxs("div",{className:"relative pb-4 last:pb-0",children:[i.jsx("div",{className:`absolute top-1 -left-[calc(1.5rem+0.3125rem)] h-2.5 w-2.5 rounded-full ${EGe(l.status)}`}),i.jsxs("div",{className:"flex flex-col gap-0.5",children:[i.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[i.jsx("span",{className:"font-medium",children:l.subject}),i.jsx("span",{className:"bg-muted rounded px-1.5 py-0.5 text-xs",children:l.status})]}),i.jsxs("div",{className:"text-muted-foreground flex gap-3 text-xs",children:[i.jsxs("span",{children:["Sent: ",TGe(l.sentAt)]}),c&&i.jsxs("span",{children:["Delivery: ",c]}),u&&i.jsxs("span",{children:["Processing: ",u]})]}),l.errorMessage&&i.jsx("div",{className:"bg-destructive/10 text-destructive mt-1 rounded px-2 py-1 text-xs",children:l.errorMessage})]})]},l.id)})})]})}const ZB=[{value:"per-chat",label:"Per Chat",description:"One session per chat/conversation. Messages from the same chat resume the same session."},{value:"per-user",label:"Per User",description:"One session per user. All messages from a user share a session across chats."},{value:"stateless",label:"Stateless",description:"Every message starts a new session. No conversation history."}],XB=[{value:"default",label:"Default",description:"Agent asks for approval before using any tools"},{value:"plan",label:"Plan Only",description:"Agent can read files but asks before making changes"},{value:"acceptEdits",label:"Accept Edits",description:"Agent can read and write files; asks before running shell commands"},{value:"bypassPermissions",label:"Full Access",description:"Agent can use all tools without asking for approval"}];function NGe({strategy:e,onStrategyChange:t,permissionMode:n,onPermissionModeChange:s,bypassWarningOpen:r,onBypassWarningOpenChange:a,onBypassConfirm:o,canInitiate:l,onCanInitiateChange:c,canReply:u,onCanReplyChange:f,canReceive:h,onCanReceiveChange:m,open:g,onOpenChange:b,hasChanges:v}){const k=ZB.find(C=>C.value===e),w=XB.find(C=>C.value===n);return i.jsxs(i.Fragment,{children:[i.jsxs(VD,{open:g,onOpenChange:b,trigger:"Advanced",badge:v?i.jsx(Ot,{variant:"secondary",className:"text-xs",children:"Modified"}):void 0,children:[i.jsxs("div",{className:"space-y-1.5 px-4 py-3",children:[i.jsx(jn,{htmlFor:"binding-session-strategy",children:"Session Strategy"}),i.jsxs(Bn,{value:e,onValueChange:C=>t(C),children:[i.jsx(Dn,{id:"binding-session-strategy",className:"w-full",children:i.jsx($n,{})}),i.jsx(On,{children:ZB.map(C=>i.jsx(yt,{value:C.value,children:C.label},C.value))})]}),k&&i.jsx("p",{className:"text-muted-foreground text-xs",children:k.description})]}),i.jsxs("div",{className:"space-y-1.5 px-4 py-3",children:[i.jsx(jn,{htmlFor:"binding-permission-mode",children:"Permission Mode"}),i.jsxs(Bn,{value:n,onValueChange:s,children:[i.jsx(Dn,{id:"binding-permission-mode",className:"w-full",children:i.jsx($n,{})}),i.jsx(On,{children:XB.map(C=>i.jsx(yt,{value:C.value,children:C.label},C.value))})]}),w&&i.jsx("p",{className:"text-muted-foreground text-xs",children:w.description})]}),i.jsxs("div",{className:"space-y-2.5 px-4 py-3",children:[i.jsx("p",{className:"text-muted-foreground text-xs font-medium",children:"Message Direction"}),i.jsxs("div",{className:"flex cursor-pointer items-center justify-between gap-3",children:[i.jsxs(jn,{htmlFor:"perm-initiate",className:"flex cursor-pointer items-center gap-1.5 text-xs font-normal",children:[i.jsx(Ho,{className:"text-muted-foreground size-3"}),"Agent can initiate messages"]}),i.jsx(Ks,{id:"perm-initiate",checked:l,onCheckedChange:c,"aria-label":"Agent can initiate messages"})]}),i.jsxs("div",{className:"flex cursor-pointer items-center justify-between gap-3",children:[i.jsx(jn,{htmlFor:"perm-reply",className:"cursor-pointer text-xs font-normal",children:"Agent can reply to messages"}),i.jsx(Ks,{id:"perm-reply",checked:u,onCheckedChange:f,"aria-label":"Agent can reply to messages"})]}),i.jsxs("div",{className:"flex cursor-pointer items-center justify-between gap-3",children:[i.jsx(jn,{htmlFor:"perm-receive",className:"cursor-pointer text-xs font-normal",children:"Agent receives inbound messages"}),i.jsx(Ks,{id:"perm-receive",checked:h,onCheckedChange:m,"aria-label":"Agent receives inbound messages"})]})]})]}),i.jsx(th,{open:r,onOpenChange:a,children:i.jsxs(Bu,{children:[i.jsxs(nh,{children:[i.jsx($u,{children:"Enable Full Access?"}),i.jsx(Hu,{children:"Any user who can send messages through this adapter (e.g., members of your Slack workspace) will be able to trigger unrestricted agent actions, including file system access and command execution."})]}),i.jsxs(sh,{children:[i.jsx(Vu,{children:"Cancel"}),i.jsx(Uu,{onClick:o,className:"bg-red-600 hover:bg-red-700 focus:ring-red-600",children:"Enable Full Access"})]})]})})]})}const mi="__any__",jGe={"per-chat":"One thread for each conversation","per-user":"One thread for each person",stateless:"No memory between messages"};function AGe({sessionStrategy:e,chatDisplayName:t,channelType:n}){const s=jGe[e];return t?`${s} in ${t}`:n?`${s} · ${n}`:s}const RGe=[{value:"dm",label:"Direct Message"},{value:"group",label:"Group"},{value:"channel",label:"Channel"},{value:"thread",label:"Thread"}];function MGe(e){return!!(e!=null&&e.canInitiate||(e==null?void 0:e.canReply)===!1||(e==null?void 0:e.canReceive)===!1||(e==null?void 0:e.permissionMode)!==void 0&&e.permissionMode!=="acceptEdits"||e!=null&&e.sessionStrategy&&e.sessionStrategy!=="per-chat")}function DGe(e){return{adapterId:(e==null?void 0:e.adapterId)??"",agentId:(e==null?void 0:e.agentId)??"",strategy:(e==null?void 0:e.sessionStrategy)??"per-chat",label:(e==null?void 0:e.label)??"",chatId:(e==null?void 0:e.chatId)??mi,channelType:(e==null?void 0:e.channelType)??mi,permissionMode:(e==null?void 0:e.permissionMode)??"acceptEdits",canInitiate:(e==null?void 0:e.canInitiate)??!1,canReply:(e==null?void 0:e.canReply)??!0,canReceive:(e==null?void 0:e.canReceive)??!0}}function aae({open:e,onOpenChange:t,onConfirm:n,mode:s,initialValues:r,adapterName:a,agentName:o,onDelete:l,bindingId:c,isPending:u}){const f=s==="edit",[h,m]=x.useState(()=>!!(r!=null&&r.chatId||r!=null&&r.channelType)),[g,b]=x.useState(()=>MGe(r)),[v,k]=x.useState(!1),[w]=x.useState(()=>DGe(r)),C=eC({defaultValues:w,onSubmit:async({value:B})=>{await n({adapterId:B.adapterId,agentId:B.agentId,sessionStrategy:B.strategy,label:B.label,permissionMode:B.permissionMode,chatId:B.chatId===mi?void 0:B.chatId,channelType:B.channelType===mi?void 0:B.channelType,canInitiate:B.canInitiate,canReply:B.canReply,canReceive:B.canReceive}),f||C.reset()}}),{data:E=[]}=ug(),{data:T}=ji(),[_,j]=x.useState(()=>(r==null?void 0:r.adapterId)??""),{data:R=[]}=YUe(_||void 0),D=E.flatMap(B=>B.instances.filter(H=>H.enabled).map(H=>({id:H.id,label:H.label?`${H.label} (${B.manifest.displayName})`:`${H.id} (${B.manifest.displayName})`}))),I=(T==null?void 0:T.agents)??[];function O(B){B==="bypassPermissions"?k(!0):C.setFieldValue("permissionMode",B)}function L(){C.setFieldValue("chatId",mi),C.setFieldValue("channelType",mi)}return i.jsx(Ta,{open:e,onOpenChange:t,children:i.jsxs(_a,{className:"max-h-[85vh] max-w-md gap-0 p-0",children:[i.jsxs(Ni,{className:"border-b px-4 py-3",children:[i.jsx(ei,{children:f?"Edit Binding":"Create Binding"}),i.jsx(Ji,{className:"sr-only",children:f?"Modify the binding configuration":"Configure how the adapter connects to the agent"})]}),i.jsx(C.Subscribe,{selector:B=>({values:B.values,isSubmitting:B.isSubmitting}),children:({values:B,isSubmitting:H})=>{var G;const K=f||!!B.adapterId&&!!B.agentId,U=!f||B.adapterId!==w.adapterId||B.agentId!==w.agentId||B.strategy!==w.strategy||B.label!==w.label||B.chatId!==w.chatId||B.channelType!==w.channelType||B.permissionMode!==w.permissionMode||B.canInitiate!==w.canInitiate||B.canReply!==w.canReply||B.canReceive!==w.canReceive,$=f?o:(G=I.find(P=>P.id===B.agentId))==null?void 0:G.name,q=K&&$?`${AGe({sessionStrategy:B.strategy,chatDisplayName:B.chatId!==mi?`#${B.chatId}`:void 0,channelType:B.channelType!==mi?B.channelType:void 0})} — routed to ${$}.`:null,J=B.chatId!==mi||B.channelType!==mi,ne=B.strategy!=="per-chat"||B.permissionMode!=="acceptEdits"||B.canInitiate||!B.canReply||!B.canReceive,F=!K||!U||!!u||H,V=!!u||H;return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"space-y-5 overflow-y-auto px-4 py-5",children:[f?i.jsxs("p",{className:"text-muted-foreground text-sm",children:["Binding: ",i.jsx("span",{className:"text-foreground font-medium",children:a})," to"," ",i.jsx("span",{className:"text-foreground font-medium",children:o})]}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(jn,{htmlFor:"binding-adapter",children:"Adapter"}),D.length===0?i.jsx("p",{className:"text-muted-foreground border-input rounded-md border px-3 py-2 text-sm opacity-50",children:"No adapters configured"}):i.jsx(C.AppField,{name:"adapterId",children:P=>i.jsxs(Bn,{value:P.state.value,onValueChange:Z=>{P.handleChange(Z),j(Z)},children:[i.jsx(Dn,{id:"binding-adapter",className:"w-full",children:i.jsx($n,{placeholder:"Select an adapter"})}),i.jsx(On,{children:D.map(Z=>i.jsx(yt,{value:Z.id,children:Z.label},Z.id))})]})})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(jn,{htmlFor:"binding-agent",children:"Agent"}),I.length===0?i.jsx("p",{className:"text-muted-foreground border-input rounded-md border px-3 py-2 text-sm opacity-50",children:"No agents registered"}):i.jsx(C.AppField,{name:"agentId",children:P=>i.jsxs(Bn,{value:P.state.value,onValueChange:P.handleChange,children:[i.jsx(Dn,{id:"binding-agent",className:"w-full",children:i.jsx($n,{placeholder:"Select an agent"})}),i.jsx(On,{children:I.map(Z=>i.jsx(yt,{value:Z.id,children:tn(Z)},Z.id))})]})})]})]}),i.jsx(C.AppField,{name:"label",children:P=>i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(jn,{htmlFor:"binding-label",children:"Label (optional)"}),i.jsx(_n,{id:"binding-label",placeholder:"e.g., Customer support bot",value:P.state.value,onBlur:P.handleBlur,onChange:Z=>P.handleChange(Z.target.value)}),i.jsx(Ei,{children:"A display name for this binding"})]})}),i.jsxs(VD,{open:h,onOpenChange:m,trigger:"Chat Filter",badge:J?i.jsx(Ot,{variant:"secondary",className:"text-xs",children:"Active"}):void 0,children:[i.jsx(C.AppField,{name:"chatId",children:P=>i.jsxs("div",{className:"space-y-1.5 px-4 py-3",children:[i.jsx(jn,{htmlFor:"binding-chat-id",children:"Chat ID"}),i.jsxs(Bn,{value:P.state.value,onValueChange:P.handleChange,children:[i.jsx(Dn,{id:"binding-chat-id",className:"w-full",children:i.jsx($n,{placeholder:"Any chat (wildcard)"})}),i.jsxs(On,{children:[i.jsx(yt,{value:mi,children:"Any chat (wildcard)"}),R.map(Z=>i.jsxs(yt,{value:Z.chatId,children:[i.jsx("span",{children:Z.displayName??Z.chatId}),(Z.channelType||Z.messageCount>0)&&i.jsx("span",{className:"text-muted-foreground ml-2 text-xs",children:[Z.channelType,`${Z.messageCount} msgs`].filter(Boolean).join(" · ")})]},Z.chatId))]})]}),i.jsx(Ei,{children:"Route only messages from a specific chat or channel"})]})}),i.jsx(C.AppField,{name:"channelType",children:P=>i.jsxs("div",{className:"space-y-1.5 px-4 py-3",children:[i.jsx(jn,{htmlFor:"binding-channel-type",children:"Channel Type"}),i.jsxs(Bn,{value:P.state.value,onValueChange:P.handleChange,children:[i.jsx(Dn,{id:"binding-channel-type",className:"w-full",children:i.jsx($n,{placeholder:"Any type (wildcard)"})}),i.jsxs(On,{children:[i.jsx(yt,{value:mi,children:"Any type (wildcard)"}),RGe.map(Z=>i.jsx(yt,{value:Z.value,children:Z.label},Z.value))]})]})]})}),J&&i.jsx("div",{className:"px-4 py-3",children:i.jsx(ve,{variant:"ghost",size:"sm",onClick:L,children:"Clear filters"})})]}),i.jsx(NGe,{strategy:B.strategy,onStrategyChange:P=>C.setFieldValue("strategy",P),permissionMode:B.permissionMode,onPermissionModeChange:O,bypassWarningOpen:v,onBypassWarningOpenChange:k,onBypassConfirm:()=>C.setFieldValue("permissionMode","bypassPermissions"),canInitiate:B.canInitiate,onCanInitiateChange:P=>C.setFieldValue("canInitiate",P),canReply:B.canReply,onCanReplyChange:P=>C.setFieldValue("canReply",P),canReceive:B.canReceive,onCanReceiveChange:P=>C.setFieldValue("canReceive",P),open:g,onOpenChange:b,hasChanges:ne}),q&&i.jsx("p",{className:"text-muted-foreground bg-muted/50 rounded-md px-3 py-2 text-xs italic",children:q})]}),i.jsxs(Qy,{className:"border-t px-4 py-3",children:[f&&l&&c&&i.jsxs(th,{children:[i.jsx(iee,{asChild:!0,children:i.jsxs(ve,{variant:"ghost",size:"sm",className:"mr-auto text-red-600 hover:bg-red-50 hover:text-red-700 dark:hover:bg-red-950",children:[i.jsx(Yf,{className:"mr-1.5 size-3.5"}),"Delete"]})}),i.jsxs(Bu,{children:[i.jsxs(nh,{children:[i.jsx($u,{children:"Delete binding"}),i.jsx(Hu,{children:"Are you sure you want to delete this binding? The adapter will no longer route messages to the connected agent."})]}),i.jsxs(sh,{children:[i.jsx(Vu,{children:"Cancel"}),i.jsx(Uu,{onClick:()=>l(c),className:"bg-red-600 hover:bg-red-700 focus:ring-red-600",children:"Delete"})]})]})]}),i.jsx(ve,{variant:"ghost",size:"sm",onClick:()=>t(!1),children:"Cancel"}),i.jsxs(ve,{size:"sm",onClick:()=>C.handleSubmit(),disabled:F,children:[V&&i.jsx(Xn,{className:"mr-1.5 size-3.5 animate-spin"}),V?"Saving...":f?"Save Changes":"Create Binding"]})]})]})}})]})})}function EN(e){if(e.payload&&typeof e.payload=="object"){const n=e.payload;if(typeof n.adapterId=="string")return n.adapterId}const t=e.from.raw.match(/^relay\.human\.([^.]+)/);return t?t[1]:""}function QB(e){if(e.payload&&typeof e.payload=="object"){const t=e.payload;if(typeof t.chatId=="string")return t.chatId}}function JB(e){if(e.payload&&typeof e.payload=="object"){const n=e.payload.channelType;if(n==="dm"||n==="group"||n==="channel"||n==="thread")return n}}const OGe={delivered:"Delivered",failed:"Failed",pending:"Pending"};function e7(e){return new Date(e).toLocaleTimeString([],{hour:"numeric",minute:"2-digit",second:"2-digit"})}function IGe(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function PGe(e){return e.status==="delivered"?e.responseCount>0?`delivered · ${e.responseCount} chunks`:"delivered":e.failureReason??OGe[e.status].toLowerCase()}function LGe({conversation:e}){const[t,n]=x.useState(!1),[s,r]=x.useState(!1),[a,o]=x.useState(!1),[l,c]=x.useState(""),[u,f]=x.useState(!1),[h,m]=x.useState(!1),{data:g}=ji(),b=x.useMemo(()=>(g==null?void 0:g.agents)??[],[g]),{mutate:v}=dO(),{data:k=[]}=pb(),w=EN(e),C=x.useMemo(()=>k.filter(I=>I.adapterId===w),[k,w]),E=wGe(e.status),T=kGe(e.status),_=CGe(e.status),j=x.useCallback(()=>{b.find(O=>O.id===l)&&(v({adapterId:EN(e),agentId:l,sessionStrategy:"per-chat",label:"",chatId:QB(e),channelType:JB(e)}),c(""),f(!1))},[b,l,e,v]),R=x.useCallback(()=>{f(!1),m(!0)},[]),D=x.useCallback(I=>{v({adapterId:I.adapterId,agentId:I.agentId,sessionStrategy:I.sessionStrategy,label:I.label,chatId:I.chatId,channelType:I.channelType,canInitiate:I.canInitiate,canReply:I.canReply,canReceive:I.canReceive}),m(!1)},[v]);return i.jsxs("div",{className:X("hover:bg-muted/50 w-full rounded-lg border border-l-2 text-left transition-colors hover:shadow-sm",_,t&&"bg-muted/30"),children:[i.jsxs("div",{className:"flex items-start gap-2 p-3",children:[i.jsxs("button",{type:"button",onClick:()=>n(!t),className:"flex min-w-0 flex-1 items-start gap-2",children:[i.jsx("span",{className:X("mt-1 size-2 shrink-0 rounded-full",E)}),i.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[i.jsxs("div",{className:"text-muted-foreground text-xs",children:[i.jsx("span",{className:"inline-block w-8 font-medium",children:"From"}),i.jsx("span",{className:"text-foreground",children:e.from.label})]}),i.jsxs("div",{className:"text-muted-foreground text-xs",children:[i.jsx("span",{className:"inline-block w-8 font-medium",children:"To"}),i.jsx("span",{className:"text-foreground",children:e.to.label})]}),i.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.preview&&i.jsxs("span",{className:"text-muted-foreground min-w-0 flex-1 truncate text-xs",children:['"',e.preview,'"']}),i.jsx("span",{className:X("shrink-0 text-xs",T),children:PGe(e)})]})]})]}),i.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[i.jsx("span",{className:"text-muted-foreground text-xs",children:YR(e.sentAt)}),i.jsxs(eg,{open:u,onOpenChange:f,children:[i.jsx(tg,{asChild:!0,children:i.jsxs(ve,{variant:"ghost",size:"sm",className:"h-6 px-1.5 text-xs",onClick:I=>I.stopPropagation(),"aria-label":"Route to agent",children:[i.jsx(zX,{className:"mr-1 size-3"}),"Route"]})}),i.jsxs(ng,{className:"w-64 space-y-3 p-3",align:"end",children:[i.jsx("p",{className:"text-xs font-medium",children:"Route to Agent"}),C.length>0&&i.jsx("div",{className:"rounded border border-blue-200 bg-blue-50 px-2 py-1.5 text-xs dark:border-blue-900 dark:bg-blue-950",children:i.jsxs("p",{className:"font-medium text-blue-800 dark:text-blue-200",children:[C.length," binding",C.length!==1?"s":""," ","already exist",C.length===1?"s":""," for this adapter"]})}),i.jsxs(Bn,{value:l,onValueChange:c,children:[i.jsx(Dn,{className:"h-8 text-xs",children:i.jsx($n,{placeholder:"Select agent"})}),i.jsx(On,{children:b.map(I=>i.jsx(yt,{value:I.id,children:tn(I)},I.id))})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx(ve,{variant:"link",size:"sm",className:"h-6 px-0 text-xs",onClick:R,children:"More options..."}),i.jsx(ve,{size:"sm",className:"h-7 text-xs",disabled:!l,onClick:j,children:"Create Binding"})]})]})]})]})]}),h&&i.jsx(aae,{open:!0,onOpenChange:I=>{I||m(!1)},mode:"create",initialValues:{adapterId:EN(e),agentId:l||void 0,chatId:QB(e),channelType:JB(e)},onConfirm:D}),i.jsx(He,{initial:!1,children:t&&i.jsx(oe.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:"easeOut"},className:"overflow-hidden",children:i.jsxs("div",{className:"space-y-3 border-t px-3 pt-3 pb-3",children:[e.payload!=null&&i.jsxs("div",{children:[i.jsx("span",{className:"text-muted-foreground text-xs font-medium",children:"Payload"}),i.jsx("pre",{className:"bg-muted mt-1 max-h-40 overflow-auto rounded p-2 font-mono text-xs",children:JSON.stringify(e.payload,null,2)})]}),i.jsxs("div",{className:"text-muted-foreground text-xs",children:[i.jsxs("span",{children:["Sent ",e7(e.sentAt)]}),e.completedAt&&i.jsxs("span",{children:[" · Completed ",e7(e.completedAt)]}),e.durationMs!=null&&i.jsxs("span",{children:[" · Duration: ",IGe(e.durationMs)]}),e.responseCount>0&&i.jsxs("span",{children:[" · ",e.responseCount," response chunks"]})]}),e.failureReason&&i.jsx("div",{className:"bg-destructive/10 text-destructive rounded px-2 py-1 text-xs",children:e.failureReason}),i.jsxs("button",{type:"button",onClick:I=>{I.stopPropagation(),r(!s)},className:"text-muted-foreground hover:text-foreground flex items-center gap-1.5 text-xs",children:[s?i.jsx(Ps,{className:"size-3.5"}):i.jsx(Ws,{className:"size-3.5"}),"Technical Details"]}),i.jsx(He,{initial:!1,children:s&&i.jsx(oe.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15},className:"overflow-hidden",children:i.jsxs("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-xs",children:[i.jsx("dt",{className:"text-muted-foreground",children:"Subject"}),i.jsx("dd",{className:"truncate font-mono",children:e.subject}),e.sessionId&&i.jsxs(i.Fragment,{children:[i.jsx("dt",{className:"text-muted-foreground",children:"Session"}),i.jsx("dd",{className:"font-mono",children:e.sessionId.slice(0,8)})]}),e.traceId&&i.jsxs(i.Fragment,{children:[i.jsx("dt",{className:"text-muted-foreground",children:"Trace ID"}),i.jsxs("dd",{className:"font-mono",children:[e.traceId.slice(0,12),"…"]})]}),i.jsx("dt",{className:"text-muted-foreground",children:"Source"}),i.jsx("dd",{className:"truncate font-mono",children:e.from.raw}),i.jsx("dt",{className:"text-muted-foreground",children:"Destination"}),i.jsx("dd",{className:"truncate font-mono",children:e.to.raw})]})})}),e.traceId&&i.jsxs(i.Fragment,{children:[i.jsxs("button",{type:"button",onClick:I=>{I.stopPropagation(),o(!a)},className:"text-muted-foreground hover:text-foreground flex items-center gap-1.5 text-xs",children:[a?i.jsx(Ps,{className:"size-3.5"}):i.jsx(Ws,{className:"size-3.5"}),"Trace Timeline"]}),i.jsx(He,{initial:!1,children:a&&i.jsx(oe.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15},className:"overflow-hidden",children:i.jsx(_Ge,{messageId:e.traceId,onClose:()=>o(!1)})})})]})]})})})]})}const FGe={hop_limit:{label:"Hop Limit",className:"bg-orange-100 text-orange-700 dark:bg-orange-900/30 dark:text-orange-400"},ttl_expired:{label:"TTL Expired",className:"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400"},cycle_detected:{label:"Cycle Detected",className:"bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-400"},budget_exhausted:{label:"Budget Exhausted",className:"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400"}},zGe={label:"Unknown",className:"bg-muted text-muted-foreground"};function BGe(e,t){const n=YR(e),s=YR(t);return n===s?s:`${n} — ${s}`}function $Ge({group:e}){const[t,n]=x.useState(!1),s=cre(),r=FGe[e.reason]??zGe;return i.jsx("div",{className:"rounded-lg border border-red-200 bg-red-50/50 p-3 dark:border-red-900/40 dark:bg-red-950/20",children:i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsx(Yr,{className:"mt-0.5 size-4 shrink-0 text-red-500"}),i.jsxs("div",{className:"min-w-0 flex-1 space-y-1.5",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"truncate text-sm font-medium",children:e.source}),i.jsx(Ot,{className:X("shrink-0 border-0 text-xs font-normal",r.className),children:r.label}),i.jsx(Ot,{variant:"destructive",className:"shrink-0 tabular-nums",children:e.count.toLocaleString()})]}),i.jsx("p",{className:"text-muted-foreground text-xs",children:BGe(e.firstSeen,e.lastSeen)})]}),i.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[e.sample!=null&&i.jsxs(i.Fragment,{children:[i.jsxs(ve,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>n(!0),children:[i.jsx(Y3,{className:"mr-1 size-3"}),"View Sample"]}),i.jsx(ah,{open:t,onOpenChange:n,children:i.jsxs(Gu,{className:"max-w-lg",children:[i.jsxs(Ku,{children:[i.jsx(Wu,{children:"Sample Envelope"}),i.jsxs(Yu,{children:["Representative failure from ",e.source," (",r.label,")"]})]}),i.jsx("pre",{className:"bg-muted max-h-80 overflow-auto rounded-md p-3 font-mono text-xs",children:JSON.stringify(e.sample,null,2)})]})})]}),i.jsxs(th,{children:[i.jsx(iee,{asChild:!0,children:i.jsxs(ve,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground h-7 px-2 text-xs",disabled:s.isPending,children:[i.jsx(Yf,{className:"mr-1 size-3"}),"Mark Resolved"]})}),i.jsxs(Bu,{children:[i.jsxs(nh,{children:[i.jsx($u,{children:"Mark dead letters as resolved?"}),i.jsxs(Hu,{children:["This will dismiss ",e.count," dead letter",e.count!==1?"s":""," from"," ",i.jsx("span",{className:"font-medium",children:e.source})," (",r.label,"). This action cannot be undone."]})]}),i.jsxs(sh,{children:[i.jsx(Vu,{children:"Cancel"}),i.jsx(Uu,{onClick:()=>s.mutate({source:e.source,reason:e.reason}),children:"Mark Resolved"})]})]})]})]})]})})}function HGe({enabled:e=!0}){const{data:t=[],isLoading:n}=dg(e),{data:s}=X5(),r=s==null?void 0:s.budgetRejections,a=r&&Object.values(r).some(o=>o>0);return n||t.length===0?null:i.jsxs("div",{className:"space-y-2",children:[a&&i.jsx("div",{className:"rounded-md border border-amber-200 bg-amber-50 px-3 py-2 dark:border-amber-900 dark:bg-amber-950",children:i.jsxs("p",{className:"text-xs font-medium text-amber-800 dark:text-amber-200",children:["Budget rejections: ",r.hopLimit," hop limit,"," ",r.cycleDetected," cycles, ",r.budgetExhausted," budget,"," ",r.ttlExpired," TTL"]})}),t.map(o=>i.jsx($Ge,{group:o},`${o.source}:${o.reason}`))]})}function UGe(e){try{return JSON.parse(e)}catch{return{content:e}}}const VGe=me({subject:W().min(1,"Subject is required"),from:W().min(1,"From is required"),payload:W().min(1,"Payload is required")});function qGe({open:e,onOpenChange:t}={}){const[n,s]=x.useState(!1),r=e!==void 0,a=r?e:n,o=FUe(),l=eC({defaultValues:{subject:"",from:"relay.human.console",payload:""},validators:{onSubmit:VGe},onSubmit:({value:u})=>{o.mutate({subject:u.subject,from:u.from,payload:UGe(u.payload)},{onSuccess:()=>{rt.success("Message sent"),l.reset(),c(!1)}})}});function c(u){r?t==null||t(u):s(u),u||l.reset()}return i.jsxs(ah,{open:a,onOpenChange:c,children:[!r&&i.jsx(xee,{asChild:!0,children:i.jsxs(ve,{variant:"ghost",size:"sm",className:"gap-1.5","data-testid":"compose-trigger",children:[i.jsx(LTe,{className:"size-3.5"}),"Compose"]})}),i.jsxs(Gu,{children:[i.jsxs(Ku,{children:[i.jsx(Wu,{children:"Send Test Message"}),i.jsx(Yu,{children:"Compose a message to send through the Relay bus."})]}),i.jsx(l.AppForm,{children:i.jsxs("form",{onSubmit:u=>{u.preventDefault(),l.handleSubmit()},className:"space-y-4",children:[i.jsx(l.AppField,{name:"subject",children:u=>i.jsx(u.TextField,{label:"Subject",placeholder:"e.g. relay.test.ping"})}),i.jsx(l.AppField,{name:"from",children:u=>i.jsx(u.TextField,{label:"From"})}),i.jsx(l.AppField,{name:"payload",children:u=>i.jsx(u.TextareaField,{label:"Payload",placeholder:'Plain text or JSON (e.g. {"content": "hello"})',rows:4})}),i.jsx("div",{className:"flex justify-end",children:i.jsxs(ve,{type:"submit",disabled:o.isPending,children:[i.jsx(c_e,{className:"mr-2 size-4"}),"Send"]})})]})})]})]})}function GGe({enabled:e}){const{data:t}=X5();if(!e||!t)return null;const n=[{label:"Total",value:t.totalMessages,variant:"default"},{label:"Delivered",value:t.deliveredCount,variant:"success"},{label:"Failed",value:t.failedCount,variant:t.failedCount>0?"danger":"default"},{label:"Dead Letter",value:t.deadLetteredCount,variant:t.deadLetteredCount>0?"warning":"default"}];return i.jsxs("div",{className:"flex items-center gap-3 border-b px-4 py-2",children:[n.map(({label:s,value:r,variant:a})=>i.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[i.jsx("span",{className:"text-muted-foreground",children:s}),i.jsx("span",{className:X("font-medium tabular-nums",a==="success"&&r>0&&"text-green-600 dark:text-green-500",a==="danger"&&"text-red-600 dark:text-red-500",a==="warning"&&"text-amber-600 dark:text-amber-500"),children:r.toLocaleString()})]},s)),t.avgDeliveryLatencyMs!=null&&i.jsxs("div",{className:"ml-auto flex items-center gap-1.5 text-xs",children:[i.jsx("span",{className:"text-muted-foreground",children:"Avg"}),i.jsx("span",{className:"font-medium tabular-nums",children:t.avgDeliveryLatencyMs<1e3?`${Math.round(t.avgDeliveryLatencyMs)}ms`:`${(t.avgDeliveryLatencyMs/1e3).toFixed(1)}s`})]})]})}function KGe(e){return e.startsWith("relay.agent.")?"chat":e.startsWith("relay.system.tasks.")?"tasks":"system"}const WGe={initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,height:0},transition:{duration:.2,ease:"easeOut"}},YGe={initial:!1,animate:{opacity:1,y:0},exit:{opacity:0,height:0},transition:{duration:.2,ease:"easeOut"}};function ZGe(e,t,n,s){return e.filter(r=>{if(t!=="all"&&KGe(r.subject)!==t||n!=="all"&&r.status!==n)return!1;if(s){const a=s.toLowerCase();if(!(r.from.label.toLowerCase().includes(a)||r.to.label.toLowerCase().includes(a)||r.preview.toLowerCase().includes(a)||r.subject.toLowerCase().includes(a)))return!1}return!0})}function XGe({enabled:e,deadLetterRef:t,onSwitchToChannels:n,autoShowFailures:s}){const[r,a]=x.useState("all"),[o,l]=x.useState("all"),[c,u]=x.useState(""),[f,h]=x.useState(!1),[m,g]=x.useState(!1),{data:b,isLoading:v}=KUe(e),{data:k=[]}=dg(e),w=x.useMemo(()=>(b==null?void 0:b.conversations)??[],[b==null?void 0:b.conversations]);k.length>0;const C=x.useRef(null);x.useEffect(()=>{w.length>0&&C.current===null&&(C.current=new Set(w.map(j=>j.id)))},[w]),x.useEffect(()=>{!m&&k.length>0&&h(!0)},[k.length,m]),x.useEffect(()=>{s&&(h(!0),g(!1))},[s]);const E=r!=="all"||o!=="all"||c!=="",T=ZGe(w,r,o,c);function _(){a("all"),l("all"),u("")}return v?i.jsx("div",{className:"space-y-2 p-4",children:[1,2,3].map(j=>i.jsx("div",{className:"rounded-lg border p-3",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:"bg-muted animate-tasks size-4 rounded"}),i.jsx("div",{className:"bg-muted animate-tasks h-4 w-40 rounded"}),i.jsx("div",{className:"bg-muted animate-tasks ml-auto h-3 w-16 rounded"})]})},j))}):i.jsxs(i.Fragment,{children:[i.jsx(GGe,{enabled:e}),i.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[i.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[i.jsxs(Bn,{value:r,onValueChange:j=>a(j),children:[i.jsx(Dn,{className:"w-32",children:i.jsx($n,{})}),i.jsxs(On,{children:[i.jsx(yt,{value:"all",children:"All sources"}),i.jsx(yt,{value:"chat",children:"Chat messages"}),i.jsx(yt,{value:"tasks",children:"Tasks jobs"}),i.jsx(yt,{value:"system",children:"System"})]})]}),i.jsxs(Bn,{value:o,onValueChange:j=>l(j),children:[i.jsx(Dn,{className:"w-32",children:i.jsx($n,{})}),i.jsxs(On,{children:[i.jsx(yt,{value:"all",children:"All statuses"}),i.jsx(yt,{value:"delivered",children:"Delivered"}),i.jsx(yt,{value:"failed",children:"Failed"}),i.jsx(yt,{value:"pending",children:"Pending"})]})]}),i.jsxs(ve,{variant:f?"secondary":"ghost",size:"sm",className:"relative",onClick:()=>{h(!f),g(!0)},"aria-pressed":f,"aria-label":"Show dead letters",children:[i.jsx(Yr,{className:"mr-1 size-3.5"}),"Dead Letters",k.length>0&&!f&&m&&i.jsx("span",{className:"absolute -top-0.5 -right-0.5 size-2 rounded-full bg-red-500"})]}),i.jsx(_n,{className:"h-9 w-44",placeholder:"Filter by agent or message...",value:c,onChange:j=>u(j.target.value),"aria-label":"Search conversations"}),E&&i.jsx(ve,{variant:"ghost",size:"sm",onClick:_,children:"Clear filters"}),i.jsx("div",{className:"ml-auto",children:i.jsx(qGe,{})})]}),f&&i.jsx("div",{ref:t,children:i.jsx(HGe,{enabled:e})}),T.length===0&&!E?i.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-12 text-center",children:[i.jsx("div",{className:"pointer-events-none mb-2 w-full max-w-sm opacity-20 select-none",children:i.jsxs("div",{className:"space-y-2",children:[i.jsx("div",{className:"rounded-lg border p-3",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:"bg-muted size-4 rounded"}),i.jsx("div",{className:"bg-muted h-3 w-32 rounded"}),i.jsx("div",{className:"bg-muted ml-auto h-3 w-12 rounded"})]})}),i.jsx("div",{className:"rounded-lg border p-3",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:"bg-muted size-4 rounded"}),i.jsx("div",{className:"bg-muted h-3 w-44 rounded"}),i.jsx("div",{className:"bg-muted ml-auto h-3 w-12 rounded"})]})}),i.jsx("div",{className:"rounded-lg border p-3",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:"bg-muted size-4 rounded"}),i.jsx("div",{className:"bg-muted h-3 w-24 rounded"}),i.jsx("div",{className:"bg-muted ml-auto h-3 w-12 rounded"})]})})]})}),i.jsx(zEe,{className:"text-muted-foreground/50 size-10"}),i.jsxs("div",{className:"space-y-1",children:[i.jsx("p",{className:"text-sm font-medium",children:"No activity yet"}),i.jsx("p",{className:"text-muted-foreground text-sm",children:"Messages will appear here as your agents communicate"})]})]}):T.length===0?i.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-12 text-center",children:[i.jsx(Ti,{className:"text-muted-foreground/50 size-10"}),i.jsxs("div",{className:"space-y-1",children:[i.jsx("p",{className:"text-sm font-medium",children:"No messages match your filters"}),i.jsx("p",{className:"text-muted-foreground text-sm",children:"Try adjusting your filter criteria."})]}),i.jsx(ve,{variant:"ghost",size:"sm",onClick:_,children:"Clear filters"})]}):i.jsx("div",{className:"space-y-2",children:i.jsx(He,{mode:"popLayout",children:T.map(j=>{const D=C.current!==null&&!C.current.has(j.id)?WGe:YGe;return i.jsx(oe.div,{...D,children:i.jsx(LGe,{conversation:j})},j.id)})})})]})]})}const QGe={messaging:"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200",automation:"bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-200",internal:"bg-gray-100 text-gray-800 dark:bg-gray-900 dark:text-gray-200",custom:"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200"};function iae(e){return QGe[e]??""}function t7({size:e=16,className:t}){return i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 24 24",fill:"currentColor",className:t,"aria-hidden":"true",children:i.jsx("path",{d:"M11.944 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0a12 12 0 0 0-.056 0zm4.962 7.224c.1-.002.321.023.465.14a.506.506 0 0 1 .171.325c.016.093.036.306.02.472-.18 1.898-.962 6.502-1.36 8.627-.168.9-.499 1.201-.82 1.23-.696.065-1.225-.46-1.9-.902-1.056-.693-1.653-1.124-2.678-1.8-1.185-.78-.417-1.21.258-1.91.177-.184 3.247-2.977 3.307-3.23.007-.032.014-.15-.056-.212s-.174-.041-.249-.024c-.106.024-1.793 1.14-5.061 3.345-.48.33-.913.49-1.302.48-.428-.008-1.252-.241-1.865-.44-.752-.245-1.349-.374-1.297-.789.027-.216.325-.437.893-.663 3.498-1.524 5.83-2.529 6.998-3.014 3.332-1.386 4.025-1.627 4.476-1.635z"})})}function oae({size:e=16,className:t}){return i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 24 24",fill:"currentColor",className:t,"aria-hidden":"true",children:i.jsx("path",{d:"M17.304 3.541h-3.672l6.696 16.918h3.672zm-10.608 0L0 20.459h3.744l1.37-3.553h7.005l1.369 3.553h3.744L10.536 3.541zm-.372 10.339 2.18-5.632 2.171 5.632z"})})}function ZR({size:e=16,className:t}){return i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 24 24",fill:"currentColor",className:t,"aria-hidden":"true",children:i.jsx("path",{d:"M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z"})})}function XR({size:e=16,className:t}){return i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 24 24",fill:"currentColor",className:t,"aria-hidden":"true",children:i.jsx("path",{d:"M11.04 19.32Q12 21.51 12 24q0-2.49.93-4.68.96-2.19 2.58-3.81t3.81-2.55Q21.51 12 24 12q-2.49 0-4.68-.93a12.3 12.3 0 0 1-3.81-2.58 12.3 12.3 0 0 1-2.58-3.81Q12 2.49 12 0q0 2.49-.96 4.68-.93 2.19-2.55 3.81a12.3 12.3 0 0 1-3.81 2.58Q2.49 12 0 12q2.49 0 4.68.96 2.19.93 3.81 2.55t2.55 3.81"})})}function JGe({size:e=16,className:t}){return i.jsx(V_e,{className:t,style:{width:e,height:e}})}function eKe({size:e=16,className:t}){return i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 24 24",className:t,"aria-hidden":"true",children:i.jsx("text",{x:"12",y:"18",textAnchor:"middle",fontFamily:"system-ui, -apple-system, sans-serif",fontSize:"20",fontWeight:"900",fill:"currentColor",children:"#"})})}const n7={telegram:t7,"telegram-chatsdk":t7,"claude-code":oae,openai:ZR,codex:ZR,gemini:XR,"gemini-cli":XR,slack:eKe,webhook:JGe};function hO({iconId:e,adapterType:t,size:n=16,className:s}){const r=n7[e??""]??n7[t??""];return r?i.jsx(r,{size:n,className:s}):i.jsx(zy,{className:s,style:{width:n,height:n}})}function tKe({manifest:e,instance:t,primaryName:n,secondaryName:s,statusDotClass:r,onToggle:a,onShowEvents:o,onConfigure:l,onRemove:c,onAddBinding:u,isBuiltinClaude:f}){return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex items-start justify-between",children:[i.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[i.jsx("div",{className:r,"aria-hidden":!0}),i.jsx(hO,{iconId:e.iconId,adapterType:e.type,size:16,className:"text-muted-foreground shrink-0"}),i.jsx("span",{className:"text-sm font-medium",children:n})]}),i.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[i.jsx(Ks,{checked:t.enabled,onCheckedChange:a}),i.jsxs(Xm,{children:[i.jsx(Qm,{asChild:!0,children:i.jsx(ve,{variant:"ghost",size:"sm",className:"size-7 p-0","aria-label":"Adapter actions",children:i.jsx(dEe,{className:"size-4"})})}),i.jsxs(lh,{align:"end",children:[i.jsxs(Nr,{onClick:o,children:[i.jsx(Fy,{className:"mr-2 size-3.5"}),"Events"]}),i.jsxs(Nr,{onClick:u,children:[i.jsx(QEe,{className:"mr-2 size-3.5"}),"Add Binding"]}),i.jsxs(Nr,{onClick:l,children:[i.jsx(Qi,{className:"mr-2 size-3.5"}),"Configure"]}),i.jsxs(Nr,{onClick:c,disabled:f,className:"text-red-600 focus:text-red-600",children:[i.jsx(Yf,{className:"mr-2 size-3.5"}),"Remove"]})]})]})]})]}),i.jsxs("div",{className:"mt-1 flex items-center gap-2 pl-[18px]",children:[s&&i.jsx("span",{className:"text-muted-foreground text-xs",children:s}),s&&i.jsx("span",{className:"text-muted-foreground/50 text-xs",children:"·"}),i.jsx(Ot,{variant:"secondary",className:X("text-xs",iae(e.category)),children:e.category}),e.deprecated&&i.jsx(Ot,{variant:"outline",className:"text-xs text-amber-600 dark:text-amber-500",children:"Deprecated"})]})]})}const nKe={"per-chat":"Per Chat","per-user":"Per User",stateless:"Stateless"};function sKe({agentName:e,sessionStrategy:t,chatId:n,channelType:s,canInitiate:r=!1,canReply:a=!0,canReceive:o=!0}){return i.jsxs("div",{className:"text-muted-foreground flex items-center gap-2 text-sm",children:[i.jsx("span",{className:"truncate",children:e}),t!=="per-chat"&&i.jsx(Ot,{variant:"secondary",className:"shrink-0 text-xs",children:nKe[t]??t}),n&&i.jsx(Ot,{variant:"outline",className:"shrink-0 truncate text-xs",children:s?`#${n}`:n}),i.jsxs(eb,{children:[r&&i.jsxs(Kn,{children:[i.jsx(Wn,{asChild:!0,children:i.jsx(Pu,{className:"size-3 shrink-0 text-amber-500","aria-label":"Can initiate messages"})}),i.jsx(Yn,{children:"Can initiate messages"})]}),!a&&i.jsxs(Kn,{children:[i.jsx(Wn,{asChild:!0,children:i.jsx(cTe,{className:"text-muted-foreground/70 size-3 shrink-0","aria-label":"Reply disabled"})}),i.jsx(Yn,{children:"Reply disabled"})]}),!o&&i.jsxs(Kn,{children:[i.jsx(Wn,{asChild:!0,children:i.jsx(TCe,{className:"text-muted-foreground/70 size-3 shrink-0","aria-label":"Receive disabled"})}),i.jsx(Yn,{children:"Receive disabled"})]})]})]})}function s7({adapterId:e,onQuickBind:t,onAdvanced:n,isPending:s,children:r}){const[a,o]=x.useState(!1),{data:l}=ji(),{data:c=[]}=pb(),u=x.useMemo(()=>new Set(c.filter(g=>g.adapterId===e).map(g=>g.agentId)),[c,e]),f=x.useMemo(()=>((l==null?void 0:l.agents)??[]).filter(g=>!u.has(g.id)),[l,u]);async function h(g){await t(g),o(!1)}function m(){o(!1),n()}return i.jsxs(eg,{open:a,onOpenChange:o,children:[i.jsx(tg,{asChild:!0,children:r}),i.jsxs(ng,{className:"w-56 p-0",align:"start",children:[i.jsxs(yC,{children:[i.jsx(bC,{placeholder:"Search agents..."}),i.jsxs(vC,{children:[i.jsx(SC,{children:"No agents registered"}),f.map(g=>i.jsxs(Hr,{value:tn(g),onSelect:()=>h(g.id),disabled:s,children:[s?i.jsx(Xn,{className:"mr-2 size-3.5 animate-spin"}):null,tn(g)]},g.id))]})]}),i.jsx("div",{className:"border-t px-2 py-1.5",children:i.jsx(ve,{variant:"ghost",size:"sm",className:"text-muted-foreground w-full text-xs",onClick:m,children:"Advanced..."})})]})]})}const TN=3;function rKe({instance:e,isBuiltinClaude:t,boundAgentRows:n,adapterBindings:s,totalAgentCount:r,isConnected:a,hasBindings:o,onEditBinding:l,onQuickBind:c,onAdvancedBind:u,createBindingPending:f}){const[h,m]=x.useState(!1),g=h?n:n.slice(0,TN),b=n.length-TN;return i.jsx("div",{className:"mt-3 space-y-1.5 pl-[18px]",children:t?i.jsxs("p",{className:"text-muted-foreground text-sm",children:["Serving ",r," ",r===1?"agent":"agents"," · Chat + Tasks"]}):o?i.jsxs(i.Fragment,{children:[g.map((v,k)=>{const w=s[k];return i.jsxs("button",{type:"button",className:"group/row hover:bg-muted/50 flex w-full cursor-pointer items-center gap-1.5 rounded px-1 py-0.5 text-left transition-colors",onClick:()=>l(w),children:[i.jsx(sKe,{agentName:v.agentName,sessionStrategy:v.sessionStrategy,chatId:v.chatId,channelType:v.channelType,canInitiate:v.canInitiate,canReply:v.canReply,canReceive:v.canReceive}),i.jsx(Ws,{className:"text-muted-foreground ml-auto size-3 opacity-0 transition-opacity group-hover/row:opacity-100"})]},v.bindingId)}),b>0&&!h&&i.jsxs("button",{type:"button",className:"text-muted-foreground hover:text-foreground mt-1 text-xs hover:underline",onClick:()=>m(!0),children:["Show ",b," more"]}),h&&n.length>TN&&i.jsx("button",{type:"button",className:"text-muted-foreground hover:text-foreground mt-1 text-xs hover:underline",onClick:()=>m(!1),children:"Show less"}),i.jsx(s7,{adapterId:e.id,onQuickBind:c,onAdvanced:u,isPending:f,children:i.jsxs(ve,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground mt-1 h-6 gap-1 px-2 text-xs",children:[i.jsx(Es,{className:"size-3"}),"Add binding"]})})]}):a?i.jsx(s7,{adapterId:e.id,onQuickBind:c,onAdvanced:u,isPending:f,children:i.jsxs(ve,{variant:"ghost",size:"sm",className:"mt-1 h-6 gap-1 px-2 text-xs text-amber-600 hover:bg-amber-50 hover:text-amber-700 dark:text-amber-500 dark:hover:bg-amber-950",children:[i.jsx(Es,{className:"size-3"}),"Add binding"]})}):null})}function aKe({instance:e}){const{errorCount:t,lastError:n}=e.status;return!t&&!n?null:i.jsxs("div",{className:"mt-3 pl-[18px]",children:[t>0&&!n&&i.jsxs("div",{className:"flex items-center gap-1 text-xs text-red-500",children:[i.jsx(Yr,{className:"size-3"}),i.jsxs("span",{children:[t," ",t===1?"error":"errors"]})]}),n&&i.jsxs(Bl,{children:[i.jsx("div",{className:"flex items-center gap-1",children:i.jsx($l,{asChild:!0,children:i.jsxs("button",{className:"flex items-center gap-1 text-xs text-red-500 hover:text-red-600","aria-label":"Toggle full error message",children:[i.jsx(Ws,{className:"size-3 transition-transform data-[state=open]:rotate-90"}),t>0&&i.jsx(Yr,{className:"size-3"}),i.jsx("span",{className:"max-w-[200px] truncate",children:t>0?`${t} ${t===1?"error":"errors"}`:n})]})})}),i.jsx(Hl,{children:i.jsx("div",{className:"mt-1 rounded-md bg-red-50 p-2 font-mono text-xs text-red-700 dark:bg-red-950 dark:text-red-300",children:n})})]})]})}function iKe({instance:e,manifest:t,onToggle:n,onConfigure:s,onShowEvents:r,onEditBinding:a,onRemoveConfirm:o,onAddBinding:l}){const c=dO(),u=t.type==="claude-code"&&t.builtin,f=e.label||e.status.displayName||e.id,h=e.label?e.status.displayName||t.displayName:null,{data:m=[]}=pb(),{data:g}=ji(),b=x.useMemo(()=>(g==null?void 0:g.agents)??[],[g==null?void 0:g.agents]),v=b.length,k=x.useMemo(()=>m.filter(R=>R.adapterId===e.id),[m,e.id]),w=x.useMemo(()=>k.map(R=>{const D=b.find(I=>I.id===R.agentId);return{bindingId:R.id,agentName:(D==null?void 0:D.name)??R.agentId,sessionStrategy:R.sessionStrategy,chatId:R.chatId,channelType:R.channelType,canInitiate:R.canInitiate,canReply:R.canReply,canReceive:R.canReceive}}),[k,b]),C=k.length>0,E=e.status.state==="connected",T=u||C,_=X("size-2 shrink-0 rounded-full",e.status.state==="error"&&"bg-red-500",e.status.state==="connected"&&T&&"bg-green-500",e.status.state==="connected"&&!T&&"animate-tasks bg-amber-500",e.status.state==="disconnected"&&"bg-gray-400",e.status.state==="starting"&&"animate-tasks bg-blue-400",e.status.state==="stopping"&&"animate-tasks bg-gray-400",!["error","connected","disconnected","starting","stopping"].includes(e.status.state)&&"bg-gray-400");async function j(R){try{await c.mutateAsync({adapterId:e.id,agentId:R,sessionStrategy:"per-chat",label:""}),rt.success("Binding created")}catch(D){rt.error(D instanceof Error?D.message:"Failed to create binding")}}return i.jsxs("div",{className:X("shadow-soft hover:shadow-elevated rounded-xl border p-5 transition-shadow",u&&"border-dashed"),children:[i.jsx(tKe,{manifest:t,instance:e,primaryName:f,secondaryName:h,statusDotClass:_,onToggle:n,onShowEvents:()=>r(e.id),onConfigure:s,onRemove:()=>o(e.id,f),onAddBinding:()=>l(e.id,e.id),isBuiltinClaude:u}),i.jsx(rKe,{instance:e,isBuiltinClaude:u,boundAgentRows:w,adapterBindings:k,totalAgentCount:v,isConnected:E,hasBindings:C,onEditBinding:R=>a(R),onQuickBind:j,onAdvancedBind:()=>l(e.id,e.id),createBindingPending:c.isPending}),i.jsx(aKe,{instance:e})]})}const oKe={"adapter.connected":"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200","adapter.message_sent":"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200","adapter.disconnected":"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200","adapter.error":"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200","adapter.message_received":"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200","adapter.status_change":"bg-amber-100 text-amber-800 dark:bg-amber-900 dark:text-amber-200"},QR={"adapter.connected":"Connected","adapter.disconnected":"Disconnected","adapter.message_received":"Received","adapter.message_sent":"Sent","adapter.error":"Error","adapter.status_change":"Status"},lKe=Object.keys(QR);function cKe({adapterId:e}){const{data:t,isLoading:n}=WUe(e),[s,r]=x.useState("all"),a=x.useRef(null),[o,l]=x.useState(!0),c=x.useCallback(()=>{const m=a.current;if(!m)return;l(m.scrollHeight-m.scrollTop-m.clientHeight<20)},[]);x.useEffect(()=>{o&&a.current&&(a.current.scrollTop=a.current.scrollHeight)},[t,o]);const u=()=>{a.current&&(a.current.scrollTop=a.current.scrollHeight,l(!0))};if(n)return i.jsx("div",{className:"space-y-2 p-3",children:[1,2,3,4].map(m=>i.jsx(on,{className:"h-6 w-full"},m))});const f=(t==null?void 0:t.events)??[],h=s==="all"?f:f.filter(m=>m.subject===s);return f.length===0?i.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 p-6 text-center",children:[i.jsx(Fy,{className:"text-muted-foreground size-6"}),i.jsx("p",{className:"text-muted-foreground text-sm",children:"No events recorded"})]}):i.jsxs("div",{className:"flex h-full flex-col",children:[i.jsxs("div",{className:"flex items-center justify-between border-b px-3 py-2",children:[i.jsx("h4",{className:"text-muted-foreground text-xs font-semibold tracking-wide uppercase",children:"Events"}),i.jsxs(Bn,{value:s,onValueChange:r,children:[i.jsx(Dn,{className:"h-7 w-[130px] text-xs",children:i.jsx($n,{})}),i.jsxs(On,{children:[i.jsx(yt,{value:"all",children:"All types"}),lKe.map(m=>i.jsx(yt,{value:m,children:QR[m]},m))]})]})]}),i.jsx("div",{ref:a,onScroll:c,className:"flex-1 overflow-y-auto p-2",children:h.map(m=>{const g=m.metadata?JSON.parse(m.metadata):null,b=new Date(m.sentAt).toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"});return i.jsxs("div",{className:"flex items-start gap-2 py-1",children:[i.jsx("span",{className:"text-muted-foreground shrink-0 font-mono text-xs tabular-nums",children:b}),i.jsx(Ot,{variant:"secondary",className:X("shrink-0 text-[10px]",oKe[m.subject]??""),children:QR[m.subject]??m.subject}),i.jsx("span",{className:"text-xs break-words",children:(g==null?void 0:g.message)??m.subject})]},m.id)})}),!o&&i.jsx("div",{className:"flex justify-center border-t py-1",children:i.jsxs(ve,{variant:"ghost",size:"sm",onClick:u,className:"h-6 text-xs",children:[i.jsx(qk,{className:"mr-1 size-3"}),"Jump to bottom"]})})]})}function lae({manifest:e,onAdd:t}){return i.jsxs("div",{className:"hover:bg-muted/50 flex flex-col justify-between rounded-lg border p-4 transition-colors",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(hO,{iconId:e.iconId,adapterType:e.type,size:20,className:"text-muted-foreground shrink-0"}),i.jsx("span",{className:"text-sm font-medium",children:e.displayName}),i.jsx(Ot,{variant:"secondary",className:iae(e.category),children:e.category})]}),i.jsx("p",{className:"text-muted-foreground text-xs",children:e.description})]}),i.jsx("div",{className:"mt-3",children:i.jsxs(ve,{variant:"outline",size:"sm",className:"w-full",onClick:t,children:[i.jsx(Es,{className:"mr-1 size-3"}),"Add"]})})]})}const r7=["configure","test","confirm","bind"],uKe={configure:"Configure",test:"Test",confirm:"Confirm",bind:"Bind"};function dKe({current:e,showBindStep:t}){const n=t?r7:r7.filter(r=>r!=="bind"),s=n.indexOf(e);return i.jsx("div",{className:"flex items-start justify-between px-1",role:"navigation","aria-label":"Wizard steps",children:n.map((r,a)=>{const o=a<s,l=a===s,c=a>s;return i.jsxs(x.Fragment,{children:[a>0&&i.jsx("div",{className:X("mt-3 h-px flex-1",o||l?"bg-primary":"border-muted-foreground/40 border-t border-dashed")}),i.jsxs("div",{className:"flex flex-col items-center gap-1",children:[i.jsx("div",{className:X("flex size-6 items-center justify-center rounded-full text-xs font-medium",o&&"bg-primary text-primary-foreground",l&&"bg-primary text-primary-foreground ring-primary/30 ring-2",c&&"border-muted-foreground text-muted-foreground border"),"aria-current":l?"step":void 0,children:o?i.jsx(Zt,{className:"size-3"}):a+1}),i.jsx("span",{className:X("text-[10px]",l?"text-foreground font-medium":"text-muted-foreground"),children:uKe[r]})]})]},r)})})}function fKe({field:e,value:t,onChange:n,error:s,allValues:r}){const[a,o]=x.useState("");if(e.showWhen&&r[e.showWhen.field]!==e.showWhen.equals)return null;const l=`config-field-${e.key}`,c=t!=null?String(t):"",u=c==="***",f=()=>{if(u){o("");return}if(e.pattern&&c&&!new RegExp(e.pattern).test(c)){o(e.patternMessage??"Invalid format");return}o("")},h=s??a;if(e.type==="boolean")return i.jsxs("div",{children:[i.jsxs(Wa,{orientation:"horizontal",className:"items-center justify-between gap-4",children:[i.jsxs(vX,{className:"min-w-0",children:[i.jsx(Ya,{htmlFor:l,className:X("text-sm font-medium",e.required&&'after:text-destructive after:ml-0.5 after:content-["*"]'),children:e.label}),e.description&&i.jsx(Ei,{className:"text-xs",children:e.description})]}),i.jsx(Ks,{id:l,checked:!!t,onCheckedChange:g=>n(e.key,g)})]}),e.helpMarkdown&&i.jsxs(Bl,{children:[i.jsxs($l,{className:"text-muted-foreground hover:text-foreground mt-1 flex items-center gap-1 text-xs transition-colors",children:[i.jsx(jF,{className:"size-3"}),"Where do I find this?",i.jsx(Ps,{className:"size-3 transition-transform [[data-state=open]_&]:rotate-180"})]}),i.jsx(Hl,{children:i.jsx("div",{className:"bg-muted/50 mt-2 rounded-md border p-3",children:i.jsx(Ew,{content:e.helpMarkdown,className:"text-xs"})})})]}),i.jsx(He,{children:h&&i.jsx(oe.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.15},className:"overflow-hidden",children:i.jsx(Oo,{className:"mt-1.5",children:h})})})]});const m=()=>{var g,b;switch(e.type){case"text":case"url":return i.jsx(_n,{id:l,type:e.type==="url"?"url":"text",value:c,onChange:v=>n(e.key,v.target.value),placeholder:e.placeholder,"aria-invalid":!!h||void 0});case"password":return u?i.jsx(WS,{id:l,value:c,showPassword:!1,onChange:v=>{n(e.key,v.target.value.trim()),a&&o("")},onFocus:()=>n(e.key,""),onBlur:f,placeholder:"Saved — enter a new one to replace"}):i.jsx(WS,{id:l,value:c,visibleByDefault:e.visibleByDefault??!1,onChange:v=>{n(e.key,v.target.value.trim()),a&&o("")},onBlur:f,onPaste:()=>setTimeout(f,0),placeholder:e.placeholder,"aria-invalid":!!h||void 0});case"number":return i.jsx(_n,{id:l,type:"number",value:c,onChange:v=>n(e.key,v.target.value?Number(v.target.value):void 0),placeholder:e.placeholder,"aria-invalid":!!h||void 0});case"select":return e.displayAs==="radio-cards"?i.jsx("div",{className:"grid grid-cols-2 gap-3",role:"radiogroup",children:(g=e.options)==null?void 0:g.map(v=>i.jsxs("button",{type:"button",role:"radio","aria-checked":c===v.value,onClick:()=>n(e.key,v.value),className:X("hover:bg-accent/50 flex flex-col items-start rounded-md border p-3 text-left transition",c===v.value&&"border-primary ring-primary bg-accent/30 ring-1"),children:[i.jsx("span",{className:"text-sm font-medium",children:v.label}),v.description&&i.jsx("span",{className:"text-muted-foreground mt-1 text-xs",children:v.description})]},v.value))}):i.jsxs(Bn,{value:c,onValueChange:v=>n(e.key,v),children:[i.jsx(Dn,{id:l,"aria-invalid":!!h||void 0,children:i.jsx($n,{placeholder:e.placeholder??"Select..."})}),i.jsx(On,{children:(b=e.options)==null?void 0:b.map(v=>i.jsx(yt,{value:v.value,children:v.label},v.value))})]});case"textarea":return i.jsx(K3,{id:l,value:c,onChange:v=>n(e.key,v.target.value),placeholder:e.placeholder,rows:3,"aria-invalid":!!h||void 0});default:return null}};return i.jsxs(Wa,{children:[i.jsx(Ya,{htmlFor:l,className:X(e.required&&!u&&'after:text-destructive after:ml-0.5 after:content-["*"]'),children:e.label}),m(),e.description&&i.jsx(Ei,{className:"text-xs",children:e.description}),e.helpMarkdown&&i.jsxs(Bl,{children:[i.jsxs($l,{className:"text-muted-foreground hover:text-foreground mt-1 flex items-center gap-1 text-xs transition-colors",children:[i.jsx(jF,{className:"size-3"}),"Where do I find this?",i.jsx(Ps,{className:"size-3 transition-transform [[data-state=open]_&]:rotate-180"})]}),i.jsx(Hl,{children:i.jsx("div",{className:"bg-muted/50 mt-2 rounded-md border p-3",children:i.jsx(Ew,{content:e.helpMarkdown,className:"text-xs"})})})]}),i.jsx(He,{children:h&&i.jsx(oe.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.15},className:"overflow-hidden",children:i.jsx(Oo,{children:h})})})]})}function hKe(e,t){return e.showWhen?t[e.showWhen.field]===e.showWhen.equals:!0}function pKe({fields:e,allValues:t,renderField:n}){const s=new Map;for(const r of e){const a=r.section;s.has(a)||s.set(a,[]),s.get(a).push(r)}return i.jsx("div",{className:"space-y-6",children:Array.from(s.entries()).map(([r,a])=>{const o=a.filter(l=>hKe(l,t));return o.length===0?null:i.jsxs("div",{className:"space-y-3",children:[r&&i.jsx("h4",{className:"text-sm font-semibold",children:r}),i.jsx(Sa,{children:i.jsx(Wr,{children:o.map(l=>n(l))})})]},r??"__default")})})}function mKe({manifest:e,label:t,onLabelChange:n,fields:s,form:r,currentSetupStep:a,hasSetupGuide:o,onOpenGuide:l}){const{Subscribe:c,AppField:u}=r;return i.jsxs("div",{className:"space-y-4",children:[e.setupInstructions&&i.jsxs("div",{className:"flex gap-2 rounded-md border border-blue-200 bg-blue-50 p-3 text-sm text-blue-800 dark:border-blue-800 dark:bg-blue-950 dark:text-blue-200",children:[i.jsx(X3,{className:"mt-0.5 size-4 shrink-0"}),i.jsx(Ew,{content:e.setupInstructions,className:"text-sm text-blue-800 dark:text-blue-200"})]}),(e.actionButton||o)&&i.jsxs("div",{className:"flex items-center justify-end gap-2",children:[o&&i.jsxs(ve,{type:"button",variant:"outline",size:"sm",onClick:l,children:[i.jsx(W3,{className:"mr-1.5 size-3.5"}),"Setup Guide"]}),e.actionButton&&i.jsx("a",{href:e.actionButton.url,target:"_blank",rel:"noopener noreferrer",children:i.jsx(ve,{type:"button",variant:"outline",size:"sm",children:e.actionButton.label})})]}),a&&i.jsx("h4",{className:"text-sm font-medium",children:a.title}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(jn,{htmlFor:"adapter-label",children:"Name (optional)"}),i.jsx(_n,{id:"adapter-label",placeholder:e.displayName,value:t,onChange:f=>n(f.target.value)}),i.jsx("p",{className:"text-muted-foreground text-xs",children:"A friendly name to identify this adapter instance."})]}),i.jsx(c,{selector:f=>f.values,children:f=>i.jsx(pKe,{fields:s,allValues:f,renderField:h=>i.jsx(u,{name:h.key,children:m=>{var g;return i.jsx(fKe,{field:h,value:m.state.value,onChange:(b,v)=>m.handleChange(v),onBlur:m.handleBlur,error:m.state.meta.isTouched?(g=m.state.meta.errors[0])==null?void 0:g.toString():void 0,allValues:f})}},h.key)})})]})}function gKe({isPending:e,isSuccess:t,isError:n,errorMessage:s,botUsername:r,onRetry:a}){return i.jsxs("div",{className:"flex flex-col items-center gap-3 py-6",children:[e&&i.jsxs(i.Fragment,{children:[i.jsx(Xn,{className:"text-muted-foreground size-8 animate-spin"}),i.jsx("p",{className:"text-muted-foreground text-sm",children:"Testing connection..."})]}),t&&i.jsxs("div",{className:"flex flex-col items-center gap-2",children:[i.jsx(qf,{className:"size-8 text-green-500"}),i.jsx("p",{className:"text-sm text-green-700 dark:text-green-400",children:"Connection successful"}),r&&i.jsx("div",{className:"flex items-center gap-2 rounded-md border px-3 py-2 text-sm",children:i.jsxs("span",{className:"font-mono",children:["@",r]})})]}),n&&i.jsxs(i.Fragment,{children:[i.jsx(Vm,{className:"size-8 text-red-500"}),i.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:"Connection failed"}),s&&i.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-red-200 bg-red-50 p-3 text-xs text-red-700 dark:border-red-800 dark:bg-red-950 dark:text-red-300",children:[i.jsx(Yr,{className:"mt-0.5 size-3 shrink-0"}),i.jsx("span",{children:s})]}),i.jsx(ve,{variant:"outline",size:"sm",onClick:a,children:"Retry"})]})]})}function xKe(e){return e.length>8?"•••• "+e.slice(-4):"•••"}function yKe({manifest:e,adapterId:t,isEditMode:n,values:s}){return i.jsxs("div",{className:"space-y-3",children:[!n&&i.jsxs("div",{className:"flex justify-between text-sm",children:[i.jsx("span",{className:"text-muted-foreground",children:"Adapter ID"}),i.jsx("span",{className:"font-mono",children:t})]}),e.configFields.map(r=>{if(r.showWhen&&s[r.showWhen.field]!==r.showWhen.equals)return null;const a=String(s[r.key]??""),o=r.type==="password"?xKe(a):a;return i.jsxs("div",{className:"flex justify-between text-sm",children:[i.jsx("span",{className:"text-muted-foreground",children:r.label}),i.jsx("span",{className:"max-w-[200px] truncate font-mono",children:o})]},r.key)})]})}const bKe=[{value:"per-chat",label:"Per Chat"},{value:"per-user",label:"Per User"},{value:"stateless",label:"Stateless"}];function vKe({agentOptions:e,agentId:t,onAgentIdChange:n,strategy:s,onStrategyChange:r,botUsername:a,adapterType:o}){return x.useEffect(()=>{e.length===1&&!t&&n(e[0].id)},[e.length]),i.jsxs("div",{className:"space-y-4",children:[i.jsx("p",{className:"text-muted-foreground text-sm",children:"Bind this adapter to an agent so incoming messages are routed automatically. You can skip this and bind later from the Bindings tab."}),e.length===0?i.jsx("div",{className:"text-muted-foreground rounded-md border border-dashed px-4 py-6 text-center text-sm",children:"No agents registered yet. You can bind this adapter later from the Adapters tab."}):e.length===1?i.jsxs("div",{className:"bg-accent/30 rounded-md border px-4 py-3 text-sm",children:["Will bind to ",i.jsx("span",{className:"font-medium",children:tn(e[0])})]}):i.jsxs("div",{className:"space-y-2",children:[i.jsx(jn,{htmlFor:"bind-agent",children:"Agent"}),i.jsxs(Bn,{value:t,onValueChange:n,children:[i.jsx(Dn,{id:"bind-agent",className:"w-full",children:i.jsx($n,{placeholder:"Select an agent"})}),i.jsx(On,{children:e.map(l=>i.jsx(yt,{value:l.id,children:tn(l)},l.id))})]})]}),e.length>0&&i.jsxs("div",{className:"space-y-2",children:[i.jsx(jn,{htmlFor:"bind-strategy",children:"Session Strategy"}),i.jsxs(Bn,{value:s,onValueChange:l=>r(l),children:[i.jsx(Dn,{id:"bind-strategy",className:"w-full",children:i.jsx($n,{})}),i.jsx(On,{children:bKe.map(l=>i.jsx(yt,{value:l.value,children:l.label},l.value))})]})]}),a&&o==="telegram"&&i.jsxs("a",{href:`https://t.me/${a}`,target:"_blank",rel:"noopener noreferrer",className:"text-primary inline-flex items-center gap-1.5 text-sm underline-offset-4 hover:underline",children:["Message @",a," in Telegram"]})]})}function SKe({open:e,onOpenChange:t,title:n,content:s}){return i.jsx(Xl,{open:e,onOpenChange:t,children:i.jsxs(Ql,{side:"right",className:"w-[480px] overflow-y-auto sm:max-w-lg",children:[i.jsxs(Jl,{children:[i.jsxs(ec,{className:"flex items-center gap-2",children:[i.jsx(W3,{className:"size-4"}),n," Setup Guide"]}),i.jsx(ph,{children:"Step-by-step instructions for configuring this adapter."})]}),i.jsx("div",{className:"mt-4 px-4",children:i.jsx(Ew,{content:s})})]})})}function _N(e){const t={};for(const[n,s]of Object.entries(e)){const r=n.split(".");let a=t;for(let o=0;o<r.length-1;o++){const l=r[o];(!(l in a)||typeof a[l]!="object"||a[l]===null)&&(a[l]={}),a=a[l]}a[r[r.length-1]]=s}return t}function a7(e,t){const n=t.split(".");let s=e;for(const r of n){if(s==null||typeof s!="object")return;s=s[r]}return s}function wKe(e,t){const n={};for(const s of e.configFields){const r=t?a7(t,s.key):void 0;r!==void 0&&s.type!=="password"?n[s.key]=r:s.type==="password"&&t&&a7(t,s.key)!==void 0?n[s.key]="***":s.default!==void 0?n[s.key]=s.default:n[s.key]=s.type==="boolean"?!1:""}return n}function kKe(e,t=[]){const n=e.type;if(!t.includes(n))return n;let s=2;for(;t.includes(`${n}-${s}`);)s++;return`${n}-${s}`}function CKe({manifest:e,existingInstance:t,existingAdapterIds:n=[],onOpenChange:s}){const r=!!t,[a,o]=x.useState("configure"),[l,c]=x.useState(!1),[u]=x.useState(()=>(t==null?void 0:t.id)??kKe(e,n)),[f,h]=x.useState(()=>{var re;return((re=t==null?void 0:t.config)==null?void 0:re.label)??""}),[m,g]=x.useState(0),[b,v]=x.useState(""),[k,w]=x.useState(""),[C,E]=x.useState(""),[T,_]=x.useState("per-chat"),j=BUe(),R=ore(),D=HUe(),I=dO(),{data:O}=ji(),L=(O==null?void 0:O.agents)??[],B=e.setupSteps&&e.setupSteps.length>0,H=eC({defaultValues:wKe(e,t==null?void 0:t.config),validators:{onSubmit:({value:re})=>{const ae={};for(const de of e.configFields)if(!(de.showWhen&&re[de.showWhen.field]!==de.showWhen.equals)&&de.required){const pe=re[de.key];(pe==null||pe==="")&&(ae[de.key]=`${de.label} is required`)}return Object.keys(ae).length>0?{fields:ae}:void 0}},onSubmit:async()=>{}}),K=x.useMemo(()=>{if(!B||!e.setupSteps)return e.configFields;const re=e.setupSteps[m];return re?e.configFields.filter(ae=>re.fields.includes(ae.key)):e.configFields},[e.configFields,e.setupSteps,B,m]),U=x.useCallback(()=>{const re=H.state.values;let ae=!0;for(const de of K)if(!(de.showWhen&&re[de.showWhen.field]!==de.showWhen.equals)&&de.required){const pe=re[de.key];(pe==null||pe==="")&&(H.setFieldMeta(de.key,Oe=>({...Oe,isTouched:!0,errors:[`${de.label} is required`],errorMap:{onSubmit:`${de.label} is required`}})),ae=!1)}return ae},[H,K]),$=x.useCallback(()=>{if(a==="configure"){if(!U())return;if(B&&e.setupSteps&&m<e.setupSteps.length-1){g(de=>de+1);return}const ae=H.state.values;o("test"),D.mutate({type:e.type,config:_N(ae)},{onSuccess:de=>{de.botUsername&&(v(de.botUsername),f||h(`@${de.botUsername}`))}})}else a==="test"&&o("confirm")},[a,B,e,m,U,H,D,f]),q=x.useCallback(()=>{a==="test"?(o("configure"),D.reset()):a==="confirm"?o("test"):a==="bind"?s(!1):a==="configure"&&B&&m>0&&g(re=>re-1)},[a,B,m,D,s]),J=x.useCallback(()=>{const re=H.state.values,ae=_N(re),de=f?{...ae,label:f}:ae;r&&t?R.mutate({id:t.id,config:de},{onSuccess:()=>s(!1)}):j.mutate({type:e.type,id:u,config:de},{onSuccess:()=>{const pe=f||u;rt.success(`${e.displayName} adapter added`,{description:pe?`"${pe}" is ready to use.`:void 0}),w(u),o("bind")},onError:pe=>{var Oe,Ve,$e;(Oe=pe.message)!=null&&Oe.includes("timed out")?rt.error("Request timed out",{description:"Check your token and network connectivity, then try again."}):((Ve=pe.message)!=null&&Ve.includes("duplicate")||($e=pe.message)!=null&&$e.includes("exists"))&&(o("configure"),g(0))}})},[H,r,t,R,j,e,u,f,s]),ne=x.useCallback(()=>{C&&I.mutate({adapterId:k,agentId:C,sessionStrategy:T,label:""},{onSuccess:()=>s(!1)})},[C,k,T,I,s]),F=x.useCallback(()=>{s(!1)},[s]),V=x.useCallback(re=>{re||(o("configure"),g(0),h(""),v(""),w(""),E(""),_("per-chat"),c(!1),H.reset(),D.reset()),s(re)},[s,H,D]),G=x.useCallback(()=>{D.mutate({type:e.type,config:_N(H.state.values)})},[D,e.type,H]),P=j.isPending||R.isPending,Z=I.isPending,Q=B&&e.setupSteps?e.setupSteps[m]:void 0;return{step:a,isEditMode:r,adapterId:u,label:f,setLabel:h,botUsername:b,guideOpen:l,setGuideOpen:c,form:H,visibleFields:K,bindAgentId:C,setBindAgentId:E,bindStrategy:T,setBindStrategy:_,agentOptions:L,isSaving:P,isBinding:Z,hasSetupSteps:B,setupStepIndex:m,currentSetupStep:Q,testConnection:D,handleContinue:$,handleBack:q,handleSave:J,handleBind:ne,handleSkipBind:F,handleOpenChange:V,handleRetryTest:G}}function cae({open:e,onOpenChange:t,manifest:n,existingInstance:s,existingAdapterIds:r=[]}){var J;const a=CKe({manifest:n,existingInstance:s,existingAdapterIds:r,onOpenChange:t}),{step:o,isEditMode:l,adapterId:c,label:u,setLabel:f,botUsername:h,guideOpen:m,setGuideOpen:g,form:b,visibleFields:v,bindAgentId:k,setBindAgentId:w,bindStrategy:C,setBindStrategy:E,agentOptions:T,isSaving:_,isBinding:j,hasSetupSteps:R,setupStepIndex:D,currentSetupStep:I,testConnection:O,handleContinue:L,handleBack:B,handleSave:H,handleBind:K,handleSkipBind:U,handleOpenChange:$,handleRetryTest:q}=a;return i.jsxs(x.Fragment,{children:[i.jsx(ah,{open:e,onOpenChange:$,children:i.jsxs(Gu,{className:"flex max-h-[85vh] max-w-lg flex-col",children:[i.jsxs(Ku,{children:[i.jsx(Wu,{children:l?`Edit ${n.displayName}`:`Add ${n.displayName}`}),i.jsxs(Yu,{children:[o==="configure"&&((I==null?void 0:I.description)??"Configure the adapter settings."),o==="test"&&"Testing connection to the adapter.",o==="confirm"&&"Review your configuration before saving.",o==="bind"&&"Optionally bind this adapter to an agent."]})]}),i.jsxs("div",{className:"min-h-0 space-y-4 overflow-y-auto py-2",children:[i.jsx(dKe,{current:o,showBindStep:!l}),i.jsx(He,{mode:"wait",children:i.jsxs(oe.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},children:[o==="configure"&&i.jsx(mKe,{manifest:n,label:u,onLabelChange:f,fields:v,form:b,currentSetupStep:I,hasSetupGuide:!!n.setupGuide,onOpenGuide:()=>g(!0)}),o==="test"&&i.jsx(gKe,{isPending:O.isPending,isSuccess:O.isSuccess,isError:O.isError,errorMessage:(J=O.error)==null?void 0:J.message,botUsername:h,onRetry:q}),o==="confirm"&&i.jsx(b.Subscribe,{selector:ne=>ne.values,children:ne=>i.jsx(yKe,{manifest:n,adapterId:c,isEditMode:l,values:ne})}),o==="bind"&&i.jsx(vKe,{agentOptions:T,agentId:k,onAgentIdChange:w,strategy:C,onStrategyChange:E,botUsername:h,adapterType:n.type})]},o)})]}),i.jsxs(Zm,{className:"flex items-center justify-between sm:justify-between",children:[i.jsxs("div",{children:[(o==="test"||o==="confirm")&&i.jsxs(ve,{variant:"ghost",onClick:B,disabled:_,children:[i.jsx(qS,{className:"mr-1 size-4"}),"Back"]}),o==="configure"&&R&&D>0&&i.jsxs(ve,{variant:"ghost",onClick:B,children:[i.jsx(qS,{className:"mr-1 size-4"}),"Back"]})]}),i.jsxs("div",{className:"flex gap-2",children:[o!=="bind"&&i.jsx(ve,{variant:"outline",onClick:()=>$(!1),children:"Cancel"}),o==="test"&&i.jsx(ve,{variant:"ghost",onClick:L,children:"Skip"}),o==="configure"&&i.jsxs(ve,{onClick:L,children:["Continue",i.jsx(GS,{className:"ml-1 size-4"})]}),o==="test"&&!O.isPending&&i.jsxs(ve,{onClick:L,children:["Continue",i.jsx(GS,{className:"ml-1 size-4"})]}),o==="confirm"&&i.jsxs(ve,{onClick:H,disabled:_,children:[_&&i.jsx(Xn,{className:"mr-2 size-4 animate-spin"}),l?"Save Changes":"Add Adapter"]}),o==="bind"&&i.jsxs(i.Fragment,{children:[i.jsx(ve,{variant:"ghost",onClick:U,disabled:j,children:"Skip"}),i.jsxs(ve,{onClick:K,disabled:!k||j,children:[j&&i.jsx(Xn,{className:"mr-2 size-4 animate-spin"}),"Bind to Agent"]})]})]})]})]})}),n.setupGuide&&i.jsx(SKe,{open:m,onOpenChange:g,title:n.displayName,content:n.setupGuide})]})}function EKe(){const[e,t]=x.useState({removeTarget:null,eventsTarget:null,bindingTarget:null});return{...e,openRemove:(n,s)=>t(r=>({...r,removeTarget:{instanceId:n,name:s}})),closeRemove:()=>t(n=>({...n,removeTarget:null})),openEvents:n=>t(s=>({...s,eventsTarget:{instanceId:n}})),closeEvents:()=>t(n=>({...n,eventsTarget:null})),openBindingCreate:n=>t(s=>({...s,bindingTarget:{mode:"create",adapterId:n}})),openBindingEdit:(n,s)=>t(r=>({...r,bindingTarget:{mode:"edit",adapterId:n,binding:s}})),closeBinding:()=>t(n=>({...n,bindingTarget:null}))}}function i7({enabled:e}){var _;const{data:t=[],isLoading:n}=ug(e),{mutate:s}=W5(),{mutate:r}=$Ue(),a=SGe(),o=vGe(),[l,c]=x.useState({open:!1}),u=Ct(),f=EKe();function h(j){var R;return(R=t.flatMap(D=>D.instances.map(I=>({instance:I,manifest:D.manifest}))).find(D=>D.instance.id===j))==null?void 0:R.manifest}async function m(j){if(f.bindingTarget)try{if(f.bindingTarget.mode==="edit"&&f.bindingTarget.binding)await a.mutateAsync({id:f.bindingTarget.binding.id,updates:j}),rt.success("Binding updated");else{rt.error("Unexpected create from ConnectionsTab");return}f.closeBinding()}catch(R){rt.error(R instanceof Error?R.message:"Failed to save binding")}}async function g(j){try{await o.mutateAsync(j),rt.success("Binding deleted"),f.closeBinding()}catch(R){rt.error(R instanceof Error?R.message:"Failed to delete binding")}}if(n)return i.jsxs("div",{className:"space-y-6 p-4",children:[i.jsxs("div",{className:"space-y-3",children:[i.jsx(on,{className:"h-4 w-32"}),i.jsx("div",{className:"space-y-2",children:[1,2].map(j=>i.jsx(on,{className:"h-16 w-full rounded-lg"},j))})]}),i.jsxs("div",{className:"space-y-3",children:[i.jsx(on,{className:"h-4 w-32"}),i.jsx("div",{className:"grid gap-3",style:{gridTemplateColumns:"repeat(auto-fill, minmax(240px, 1fr))"},children:[1,2].map(j=>i.jsxs("div",{className:"rounded-lg border p-4",children:[i.jsx(on,{className:"mb-2 h-5 w-24"}),i.jsx(on,{className:"h-4 w-full"}),i.jsx(on,{className:"mt-3 h-8 w-full"})]},j))})]})]});const b=t.flatMap(j=>j.instances.map(R=>({instance:R,manifest:j.manifest}))),v=t.filter(j=>!j.manifest.deprecated&&(j.instances.length===0||j.manifest.multiInstance)),k=j=>{c({open:!0,manifest:j})},w=(j,R)=>{c({open:!0,manifest:j,instanceId:R})},C=l.instanceId?t.flatMap(j=>j.instances).find(j=>j.id===l.instanceId):void 0,E=()=>{u.invalidateQueries({queryKey:["relay","adapters","catalog"]})},T=j=>({adapterId:j.adapterId,agentId:j.agentId,sessionStrategy:j.sessionStrategy,label:j.label??"",permissionMode:j.permissionMode,chatId:j.chatId,channelType:j.channelType,canInitiate:j.canInitiate,canReply:j.canReply,canReceive:j.canReceive});return i.jsxs("div",{className:"space-y-6 p-4",children:[i.jsxs("section",{children:[i.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[i.jsx("h3",{className:"text-muted-foreground text-xs font-semibold tracking-wide uppercase",children:"Active Channels"}),i.jsx(ve,{variant:"ghost",size:"sm",onClick:E,className:"size-7 p-0","aria-label":"Refresh channel catalog",children:i.jsx(mu,{className:"size-3.5"})})]}),b.length===0?i.jsxs("div",{className:"flex flex-col items-center gap-3 rounded-xl border border-dashed py-8",children:[i.jsx(KS,{className:"text-muted-foreground/40 size-8"}),i.jsxs("div",{className:"text-center",children:[i.jsx("p",{className:"text-muted-foreground text-sm",children:"No channels active"}),i.jsx("p",{className:"text-muted-foreground/60 text-xs",children:"Add a channel below to connect agents to external services"})]})]}):i.jsx("div",{className:"space-y-3",children:b.map(({instance:j,manifest:R})=>i.jsx(iKe,{instance:j,manifest:R,onToggle:D=>s({id:j.id,enabled:D}),onConfigure:()=>w(R,j.id),onShowEvents:D=>f.openEvents(D),onEditBinding:D=>f.openBindingEdit(D.adapterId,D),onRemoveConfirm:(D,I)=>f.openRemove(D,I),onAddBinding:D=>f.openBindingCreate(D)},j.id))})]}),i.jsxs("section",{children:[i.jsx("h3",{className:"text-muted-foreground mb-2 text-xs font-semibold tracking-wide uppercase",children:"Add Channel"}),v.length===0?i.jsx("p",{className:"text-muted-foreground text-sm",children:"All channel types are active. Multi-instance channels like Webhook can be added again from the active list."}):i.jsx("div",{className:"grid gap-2",style:{gridTemplateColumns:"repeat(auto-fill, minmax(240px, 1fr))"},children:v.map(j=>i.jsx(lae,{manifest:j.manifest,onAdd:()=>k(j.manifest)},j.manifest.type))})]}),l.manifest&&i.jsx(cae,{open:l.open,onOpenChange:j=>{j||c({open:!1})},manifest:l.manifest,existingInstance:C,existingAdapterIds:t.flatMap(j=>j.instances.map(R=>R.id))}),f.removeTarget&&i.jsx(th,{open:!0,onOpenChange:j=>{j||f.closeRemove()},children:i.jsxs(Bu,{children:[i.jsxs(nh,{children:[i.jsx($u,{children:"Remove adapter"}),i.jsxs(Hu,{children:['Are you sure you want to remove "',f.removeTarget.name,'"? This will stop the adapter and remove its configuration. Messages to its subjects will no longer be delivered.']})]}),i.jsxs(sh,{children:[i.jsx(Vu,{children:"Cancel"}),i.jsx(Uu,{onClick:()=>{r(f.removeTarget.instanceId),f.closeRemove()},className:"bg-red-600 hover:bg-red-700 focus:ring-red-600",children:"Remove"})]})]})}),f.eventsTarget&&i.jsx(Xl,{open:!0,onOpenChange:j=>{j||f.closeEvents()},children:i.jsxs(Ql,{className:"flex flex-col sm:max-w-md",children:[i.jsx(Jl,{children:i.jsx(ec,{children:"Events"})}),i.jsx("div",{className:"flex-1 overflow-hidden",children:i.jsx(cKe,{adapterId:f.eventsTarget.instanceId})})]})}),f.bindingTarget&&f.bindingTarget.mode==="edit"&&f.bindingTarget.binding&&i.jsx(aae,{open:!0,onOpenChange:j=>{j||f.closeBinding()},mode:"edit",initialValues:T(f.bindingTarget.binding),adapterName:(_=h(f.bindingTarget.binding.adapterId))==null?void 0:_.displayName,onConfirm:m,onDelete:g,bindingId:f.bindingTarget.binding.id,isPending:a.isPending||o.isPending})]})}function TKe({onAddChannel:e}){return i.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center px-6 py-16",children:[i.jsx("div",{className:"pointer-events-none mb-8 w-full max-w-md opacity-30 select-none",children:i.jsxs("div",{className:"space-y-2",children:[i.jsx("div",{className:"rounded-lg border p-3",children:i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"flex size-6 items-center justify-center rounded-full bg-blue-500/20",children:i.jsx("div",{className:"size-3 rounded-full bg-blue-500"})}),i.jsxs("div",{className:"flex-1 space-y-1",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"text-sm font-medium",children:"relay.agent.frontend"}),i.jsx("span",{className:"text-muted-foreground text-xs",children:"2m ago"})]}),i.jsx("p",{className:"text-muted-foreground text-xs",children:"Build completed successfully"})]})]})}),i.jsx("div",{className:"rounded-lg border p-3",children:i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"flex size-6 items-center justify-center rounded-full bg-emerald-500/20",children:i.jsx("div",{className:"size-3 rounded-full bg-emerald-500"})}),i.jsxs("div",{className:"flex-1 space-y-1",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"text-sm font-medium",children:"relay.system.tasks.audit"}),i.jsx("span",{className:"text-muted-foreground text-xs",children:"15m ago"})]}),i.jsx("p",{className:"text-muted-foreground text-xs",children:"Scheduled audit run delivered"})]})]})}),i.jsx("div",{className:"rounded-lg border p-3",children:i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"flex size-6 items-center justify-center rounded-full bg-orange-500/20",children:i.jsx("div",{className:"size-3 rounded-full bg-orange-500"})}),i.jsxs("div",{className:"flex-1 space-y-1",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"text-sm font-medium",children:"relay.agent.backend"}),i.jsx("span",{className:"text-muted-foreground text-xs",children:"1h ago"})]}),i.jsx("p",{className:"text-muted-foreground text-xs",children:"API migration task completed"})]})]})})]})}),i.jsx("h3",{className:"mb-2 text-lg font-medium",children:"Connect your agents to the world"}),i.jsx("p",{className:"text-muted-foreground mb-1 max-w-sm text-center text-sm",children:"Relay routes messages between your agents and external platforms."}),i.jsx("p",{className:"text-muted-foreground mb-6 max-w-sm text-center text-sm",children:"Add your first channel to start sending and receiving messages."}),i.jsx(ve,{onClick:e,children:"Add Channel"})]})}const o7={healthy:"bg-emerald-500",degraded:"bg-amber-500",critical:"bg-red-500"};function _Ke(e){return e==null?"—":e<1?"<1ms":`${Math.round(e)}ms`}function NKe(e,t,n){const s=e.totalMessages>0?(e.failedCount+e.deadLetteredCount)/e.totalMessages:0;if(n===0)return{state:"healthy",message:"No connections configured"};if(s>.5||t===0)return{state:"critical",message:`${Math.round(s*100)}% failure rate — ${e.failedCount} messages failed today`};if(t<n||s>=.05){const r=n-t;return r>0?{state:"degraded",message:`${r} connection${r>1?"s":""} disconnected`}:{state:"degraded",message:`${e.failedCount} failure${e.failedCount!==1?"s":""} in last 24h`}}return{state:"healthy",message:`${t} connection${t>1?"s":""} active`}}function jKe(e){const{data:t=[],isLoading:n}=ug(e),s=t.flatMap(o=>o.instances),r=s.length,a=s.filter(o=>o.status.state==="connected").length;return{total:r,connected:a,isLoading:n}}function AKe({enabled:e=!0,onFailedClick:t}){const n=ed(),{data:s,isLoading:r}=X5(),{total:a,connected:o,isLoading:l}=jKe(e&&n);if(!n||!e||r||l||!s)return null;const{state:c,message:u}=NKe(s,o,a),f=(c==="degraded"||c==="critical")&&t!=null,h=_Ke(s.avgDeliveryLatencyMs),m=`${s.totalMessages} messages today · ${s.failedCount} failed · ${h} avg latency`;return i.jsx(eb,{children:i.jsx("div",{className:"text-muted-foreground flex items-center gap-2 border-b px-3 py-1.5 text-xs",children:c==="healthy"?i.jsxs(Kn,{children:[i.jsx(Wn,{asChild:!0,children:i.jsxs("span",{className:"flex min-w-0 flex-1 cursor-default items-center gap-1.5",children:[i.jsx("span",{className:`size-2 shrink-0 rounded-full ${o7[c]}`,"aria-hidden":"true"}),i.jsx("span",{className:"truncate",children:u}),s.avgDeliveryLatencyMs!=null&&i.jsxs(i.Fragment,{children:[i.jsx("span",{"aria-hidden":"true",children:"·"}),i.jsx("span",{children:h})]})]})}),i.jsx(Yn,{side:"bottom",children:m})]}):i.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[i.jsx("span",{className:`size-2 shrink-0 rounded-full ${o7[c]}`,"aria-hidden":"true"}),f?i.jsx("button",{type:"button",onClick:t,className:"truncate text-left hover:underline","aria-label":`${u} — click to view failures`,children:u}):i.jsx("span",{className:"truncate",children:u})]})})})}function RKe(){const e=ed(),[t,n]=x.useState("connections"),[s,r]=x.useState(!1),[a,o]=x.useState(!1),l=x.useRef(null),{connectionState:c}=zUe(e),{data:u=[]}=ug(e),f=u.some(m=>m.instances.length>0),h=x.useCallback(()=>{n("activity"),o(!0),setTimeout(()=>o(!1),100),setTimeout(()=>{var m;(m=l.current)==null||m.scrollIntoView({behavior:"smooth",block:"start"})},150)},[]);return e?i.jsx(He,{mode:"wait",children:f?i.jsx(oe.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"flex h-full flex-col",children:i.jsxs(ste,{value:t,onValueChange:n,className:"flex h-full flex-col",children:[i.jsx(AKe,{enabled:e,onFailedClick:h}),i.jsx($Oe,{connectionState:c,className:"mx-4 mt-2"}),i.jsxs(r5,{className:"mx-4 mt-3 shrink-0",children:[i.jsx(mw,{value:"connections",children:"Connections"}),i.jsx(mw,{value:"activity",children:"Activity"})]}),i.jsx(He,{mode:"wait",children:i.jsxs(oe.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:"min-h-0 flex-1 overflow-y-auto",children:[i.jsx(xR,{value:"connections",className:"h-full",children:i.jsx(i7,{enabled:e})}),i.jsx(xR,{value:"activity",className:"h-full",children:i.jsx(XGe,{enabled:e,deadLetterRef:l,onSwitchToChannels:()=>n("connections"),autoShowFailures:a})})]},t)})]})},"mode-b"):i.jsx(oe.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"flex h-full flex-col",children:s?i.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:i.jsx(i7,{enabled:e})}):i.jsx(TKe,{onAddChannel:()=>r(!0)})},"mode-a")}):i.jsx(a5,{icon:zX,name:"Relay",description:"Relay provides inter-agent messaging. Start DorkOS with relay enabled.",command:"DORKOS_RELAY_ENABLED=true dorkos"})}const MKe={connected:"bg-green-500",disconnected:"bg-muted-foreground",error:"bg-red-500",starting:"bg-amber-500 motion-safe:animate-pulse",stopping:"bg-amber-500 motion-safe:animate-pulse",reconnecting:"bg-amber-500 motion-safe:animate-pulse"},sct={connected:"Connected",disconnected:"Ready",error:"Error",starting:"Connecting…",stopping:"Stopping…",reconnecting:"Reconnecting…"},NN={"meet-dorkbot":"Meet DorkBot",discovery:"Create agents",tasks:"Set up Tasks schedules",adapters:"Connect adapters"},DKe=["discovery","tasks"];function OKe({onStepClick:e,onDismiss:t}){const{state:n}=fb(),s=vr();return i.jsxs(oe.div,{initial:s?!1:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.3},className:"border-border bg-card relative rounded-lg border p-3",children:[i.jsx("button",{onClick:t,className:"text-muted-foreground/50 hover:text-muted-foreground absolute top-1.5 right-1.5 rounded-md p-0.5 transition-colors duration-150","aria-label":"Dismiss getting started",children:i.jsx(ls,{className:"size-3.5"})}),i.jsx("h3",{className:"mb-2 text-xs font-medium",children:"Getting Started"}),i.jsx("ul",{className:"space-y-1",children:DKe.map((r,a)=>{const o=n.completedSteps.includes(r),l=n.skippedSteps.includes(r);return o?i.jsxs("li",{className:"flex items-center gap-2 py-0.5",children:[i.jsx(Zt,{className:"text-primary size-3.5 shrink-0"}),i.jsx("span",{className:"text-muted-foreground text-xs",children:NN[r]})]},r):l?i.jsxs("li",{className:"flex items-center gap-2 py-0.5",children:[i.jsx(mTe,{className:"text-muted-foreground/40 size-3.5 shrink-0"}),i.jsx("button",{onClick:()=>e(a),className:X("text-muted-foreground/40 text-left text-xs transition-colors duration-150","hover:text-muted-foreground"),children:NN[r]})]},r):i.jsxs("li",{className:"flex items-center gap-2 py-0.5",children:[i.jsx(Yk,{className:"text-muted-foreground size-3.5 shrink-0"}),i.jsx("button",{onClick:()=>e(a),className:"text-foreground text-left text-xs transition-colors duration-150 hover:underline",children:NN[r]})]},r)})})]})}function IKe(e){return`set${e.charAt(0).toUpperCase()}${e.slice(1)}`}function PKe(e){const t=qm(),n=Qf(),s=Gm();switch(e){case"settings":return{isOpen:t.isOpen,close:t.close};case"tasks":return{isOpen:n.isOpen,close:n.close};case"relay":return{isOpen:s.isOpen,close:s.close};default:return{isOpen:!1,close:()=>{}}}}function LKe({contribution:e}){const t=je(u=>u[e.openStateKey]),n=je(u=>u[IKe(e.openStateKey)]),s=PKe(e.urlParam),r=s.isOpen,a=s.close,o=t||r,l=x.useCallback(u=>{n(u),!u&&r&&a()},[n,r,a]),c=e.component;return i.jsx(c,{open:o,onOpenChange:l})}function FKe(){const e=Fu("dialog"),t=je(s=>s.onboardingStep),n=je(s=>s.setOnboardingStep);return i.jsxs(i.Fragment,{children:[e.map(s=>i.jsx(LKe,{contribution:s},s.id)),t!==null&&i.jsx("div",{className:"bg-background fixed inset-0 z-50",children:i.jsx(rae,{initialStep:t,onComplete:()=>n(null)})})]})}function zKe(){const{theme:e,setTheme:t}=nC(),{fontFamily:n,setFontFamily:s,fontSize:r,setFontSize:a,resetPreferences:o}=je();return i.jsxs("div",{className:"space-y-4",children:[i.jsx(Jm,{actions:i.jsx("button",{onClick:()=>{o(),t("system")},className:"text-muted-foreground hover:text-foreground text-xs transition-colors duration-150",children:"Reset to defaults"}),children:"Appearance"}),i.jsx(Sa,{children:i.jsxs(Wr,{children:[i.jsx(os,{label:"Theme",description:"Choose your preferred color scheme",children:i.jsxs(Bn,{value:e,onValueChange:t,children:[i.jsx(Dn,{className:"w-32",children:i.jsx($n,{})}),i.jsxs(On,{children:[i.jsx(yt,{value:"light",children:"Light"}),i.jsx(yt,{value:"dark",children:"Dark"}),i.jsx(yt,{value:"system",children:"System"})]})]})}),i.jsx(os,{label:"Font family",description:"Choose the typeface for the interface",children:i.jsxs(Bn,{value:n,onValueChange:l=>s(l),children:[i.jsx(Dn,{className:"w-40",children:i.jsx($n,{})}),i.jsx(On,{children:AS.map(l=>i.jsx(yt,{value:l.key,children:i.jsxs("div",{className:"flex flex-col",children:[i.jsx("span",{children:l.displayName}),i.jsx("span",{className:"text-muted-foreground text-xs",children:l.description})]})},l.key))})]})}),i.jsx(os,{label:"Font size",description:"Adjust the text size across the interface",children:i.jsxs(Bn,{value:r,onValueChange:l=>a(l),children:[i.jsx(Dn,{className:"w-32",children:i.jsx($n,{})}),i.jsxs(On,{children:[i.jsx(yt,{value:"small",children:"Small"}),i.jsx(yt,{value:"medium",children:"Medium"}),i.jsx(yt,{value:"large",children:"Large"})]})]})})]})})]})}function BKe(){const{showTimestamps:e,setShowTimestamps:t,expandToolCalls:n,setExpandToolCalls:s,autoHideToolCalls:r,setAutoHideToolCalls:a,devtoolsOpen:o,toggleDevtools:l,showShortcutChips:c,setShowShortcutChips:u,showTaskCelebrations:f,setShowTaskCelebrations:h,enableNotificationSound:m,setEnableNotificationSound:g,enableTasksNotifications:b,setEnableTasksNotifications:v,promoEnabled:k,setPromoEnabled:w}=je();return i.jsxs("div",{className:"space-y-4",children:[i.jsx(Jm,{children:"Preferences"}),i.jsx(Sa,{children:i.jsxs(Wr,{children:[i.jsx(gi,{label:"Show timestamps",description:"Display message timestamps in chat",checked:e,onCheckedChange:t}),i.jsx(gi,{label:"Expand tool calls",description:"Auto-expand tool call details in messages",checked:n,onCheckedChange:s}),i.jsx(gi,{label:"Auto-hide tool calls",description:"Fade out completed tool calls after a few seconds",checked:r,onCheckedChange:a}),i.jsx(gi,{label:"Show shortcut chips",description:"Display shortcut hints below the message input",checked:c,onCheckedChange:u}),i.jsx(gi,{label:"Task celebrations",description:"Show animations when tasks complete",checked:f,onCheckedChange:h}),i.jsx(gi,{label:"Notification sound",description:"Play a sound when AI finishes responding (3s+ responses)",checked:m,onCheckedChange:g}),i.jsx(gi,{label:"Tasks run notifications",description:"Show a toast when a scheduled Tasks run completes",checked:b,onCheckedChange:v}),i.jsx(gi,{label:"Feature suggestions",description:"Show feature discovery cards on the dashboard and sidebar",checked:k,onCheckedChange:w}),i.jsx(gi,{label:"Show dev tools",description:"Enable developer tools panel",checked:o,onCheckedChange:()=>l()})]})})]})}const uae=he.createContext(null);function $Ke(){const e=he.useContext(uae);if(!e)throw new Error("StatusLine.Item must be used within a StatusLine.");return e}const HKe={duration:.2,ease:[.4,0,.2,1]};function UKe({sessionId:e,isStreaming:t,children:n}){const[s,r]=x.useState([]),a=x.useCallback(f=>{r(h=>h.includes(f)?h:[...h,f])},[]),o=x.useCallback(f=>{r(h=>h.filter(m=>m!==f))},[]),l=s[0]??null,c=s.length>0,u=x.useMemo(()=>({itemTransition:HKe,firstVisibleKey:l,registerItem:a,unregisterItem:o}),[l,a,o]);return i.jsxs(uae.Provider,{value:u,children:[i.jsx(He,{initial:!1,children:c&&i.jsx(oe.div,{role:"toolbar","aria-label":"Session status","aria-live":"polite","data-testid":"status-line",initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:[.4,0,.2,1]},className:"overflow-hidden",children:i.jsx(GKe,{children:i.jsx(He,{initial:!1,mode:"popLayout",children:he.Children.map(n,f=>{if(!he.isValidElement(f))return f;const h=f.props.itemKey;return h?he.cloneElement(f,{key:h}):f})})})})}),!c&&n]})}function VKe({itemKey:e,visible:t,children:n}){const{itemTransition:s,firstVisibleKey:r,registerItem:a,unregisterItem:o}=$Ke();if(x.useEffect(()=>{if(t)return a(e),()=>o(e)},[t,e,a,o]),!t)return null;const l=e===r;return i.jsxs(oe.div,{layout:"position",initial:{opacity:0,scale:.8,filter:"blur(4px)"},animate:{opacity:1,scale:1,filter:"blur(0px)"},exit:{opacity:0,scale:.8,filter:"blur(4px)"},transition:s,className:"inline-flex items-center gap-2",children:[!l&&i.jsx(qKe,{}),n]},e)}function qKe(){return i.jsx("span",{className:"text-muted-foreground/30","aria-hidden":"true",children:"·"})}function GKe({children:e}){const t=x.useRef(null),[n,s]=x.useState(!1),r=x.useCallback(()=>{const a=t.current;a&&s(a.scrollWidth-a.scrollLeft-a.clientWidth>1)},[]);return x.useEffect(()=>{const a=t.current;if(!a)return;r(),a.addEventListener("scroll",r,{passive:!0});const o=new ResizeObserver(r);return o.observe(a),()=>{a.removeEventListener("scroll",r),o.disconnect()}},[r]),i.jsxs("div",{className:"relative",children:[i.jsx("div",{ref:t,className:"text-muted-foreground scrollbar-none flex items-center gap-2 overflow-x-auto px-1 text-xs whitespace-nowrap",children:e}),i.jsx("div",{className:X("from-background pointer-events-none absolute top-0 right-0 bottom-0 w-8 bg-gradient-to-l to-transparent transition-opacity duration-200",n?"opacity-100":"opacity-0"),"aria-hidden":!0})]})}const La=Object.assign(UKe,{Item:VKe});function KKe({cwd:e}){const t=e.split("/").filter(Boolean).pop()??e;return i.jsxs("span",{className:"inline-flex items-center gap-1",title:e,children:[i.jsx(Gp,{className:"size-(--size-icon-xs)"}),i.jsx("span",{children:t})]})}function WKe(e){const t=Fe();return mt({queryKey:["git-status",e],queryFn:()=>t.getGitStatus(e??void 0),enabled:!!e,refetchInterval:Va.GIT_STATUS_REFETCH_MS,refetchIntervalInBackground:!1,staleTime:Va.GIT_STATUS_STALE_TIME_MS})}function YKe(e){return!!e&&!("error"in e)}function ZKe({data:e}){if(!e)return null;if(!YKe(e))return i.jsxs("span",{className:"text-muted-foreground/50 inline-flex items-center gap-1",title:"Not a git repository",children:[i.jsx(EA,{className:"size-(--size-icon-xs)"}),i.jsx("span",{children:"No repo"})]});const t=e.modified+e.staged+e.untracked,n=t===1?"1 change":`${t} changes`,s=[];e.modified>0&&s.push(`${e.modified} modified`),e.staged>0&&s.push(`${e.staged} staged`),e.untracked>0&&s.push(`${e.untracked} untracked`),e.conflicted>0&&s.push(`${e.conflicted} conflicted`);const r=s.length>0?`${e.branch} · ${s.join(", ")}`:`${e.branch} · clean`;return i.jsxs("span",{className:"inline-flex items-center gap-1",title:r,children:[i.jsx(EA,{className:"size-(--size-icon-xs)"}),i.jsx("span",{className:"max-w-[25ch] truncate",children:e.branch}),e.ahead>0&&i.jsxs("span",{className:"text-muted-foreground inline-flex items-center gap-0.5",children:[i.jsx(Gk,{className:"size-(--size-icon-xs)"}),e.ahead]}),e.behind>0&&i.jsxs("span",{className:"text-muted-foreground inline-flex items-center gap-0.5",children:[i.jsx(qk,{className:"size-(--size-icon-xs)"}),e.behind]}),t>0&&i.jsxs("span",{className:"text-muted-foreground",children:["· ",n]})]})}const dae=["capabilities"];function XKe(){const e=Fe();return mt({queryKey:[...dae],queryFn:()=>e.getCapabilities(),staleTime:1/0})}function QKe(){const{data:e}=XKe();if(e)return e.capabilities[e.defaultRuntime]}function fae(e){const t=Fe(),{data:n}=mt({queryKey:[...dae,"active",e],queryFn:async()=>{if(!e)return null;const[s,r]=await Promise.all([t.getSessionRuntimeType(e),t.getCapabilities()]);return r.capabilities[s]??null},enabled:!!e,staleTime:1/0});return n??void 0}const l7={default:Ho,acceptEdits:Qk,plan:JCe,dontAsk:DX,bypassPermissions:eD,auto:$y,"always-allow":Zt,"always-deny":Vm,scripted:CX},c7={bypassPermissions:!0,auto:!0,"always-allow":!0},u7=Ho,JKe={auto:"Preview"},eWe="Auto mode requires Opus 4.6+ or Sonnet 4.6",tWe={default:"Default",acceptEdits:"Accept Edits",plan:"Plan Mode",dontAsk:"Don't Ask",bypassPermissions:"Bypass All",auto:"Auto"};function nWe({mode:e,onChangeMode:t,disabled:n,sessionId:s,modelSupportsAutoMode:r}){const a=fae(s),o=QKe(),l=s?a:o;if(l&&!l.permissionModes.supported)return null;const c=(l==null?void 0:l.permissionModes.values)??[],u=!r&&c.some(k=>k.id==="auto"),f=u?c.filter(k=>k.id!=="auto"):c,h=f.find(k=>k.id===e),m=(h==null?void 0:h.label)??tWe[e]??e,g=l7[e]??u7,b=c7[e]??!1,v=i.jsxs("button",{disabled:n,className:`hover:text-foreground inline-flex items-center gap-1 transition-colors duration-150 disabled:cursor-not-allowed disabled:opacity-40 ${b?"text-red-500":""}`,children:[i.jsx(g,{className:"size-(--size-icon-xs)"}),i.jsx("span",{children:m})]});return n?i.jsxs(Kn,{children:[i.jsx(Wn,{asChild:!0,children:i.jsx("span",{className:"inline-flex",children:v})}),i.jsx(Yn,{side:"top",children:"Send a message first"})]}):i.jsxs(O5e,{children:[i.jsx(I5e,{asChild:!0,children:v}),i.jsxs(P5e,{side:"top",align:"start",className:"w-56",children:[i.jsx(L5e,{children:"Permission Mode"}),i.jsx(F5e,{value:e,onValueChange:k=>t(k),children:f.map(k=>{const w=l7[k.id]??u7,C=c7[k.id]??!1,E=JKe[k.id];return i.jsx(z5e,{value:k.id,icon:w,description:k.description,className:C?"text-red-500":"",children:i.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[k.label,E&&i.jsx("span",{className:"bg-muted text-muted-foreground rounded px-1 py-px text-[10px] font-medium tracking-wide uppercase",children:E})]})},k.id)})}),u&&i.jsxs(Kn,{children:[i.jsx(Wn,{asChild:!0,children:i.jsxs("p",{"data-testid":"auto-unsupported-hint",className:"text-muted-foreground flex items-center gap-1.5 px-2 py-1.5 text-[10px]",children:[i.jsx($y,{className:"size-(--size-icon-xs) shrink-0"}),"Auto unavailable on this model"]})}),i.jsx(Yn,{side:"top",children:eWe})]})]})]})}function sWe({open:e,onOpenChange:t,onConfirm:n}){return i.jsx(th,{open:e,onOpenChange:t,children:i.jsxs(Bu,{children:[i.jsxs(nh,{children:[i.jsxs($u,{className:"flex items-center gap-2",children:[i.jsx($y,{className:"size-4 text-red-500"}),"Turn on Auto mode",i.jsx(Ot,{variant:"secondary",className:"text-[10px] tracking-wide uppercase",children:"Preview"})]}),i.jsx(Hu,{children:"The agent runs on its own and only checks with you before risky actions — like deleting files or running unfamiliar commands. You can switch back anytime."})]}),i.jsxs(sh,{children:[i.jsx(Vu,{children:"Cancel"}),i.jsx(Uu,{onClick:n,children:"Turn on Auto mode"})]})]})})}const JR={none:{label:"None",description:"No reasoning"},minimal:{label:"Minimal",description:"Near-zero thinking"},low:{label:"Low",description:"Fastest responses"},medium:{label:"Medium",description:"Moderate thinking"},high:{label:"High",description:"Deep reasoning"},max:{label:"Max",description:"Maximum thinking"},xhigh:{label:"XHigh",description:"Beyond maximum"}},rWe={duration:.15,ease:"easeOut"};function aWe(e){return e>=1e6?`${Math.round(e/1e6)}M`:e>=1e3?`${Math.round(e/1e3)}K`:String(e)}function iWe(e,t){const n=t.find(r=>r.value===e);if(n)return n.displayName;const s=e.match(/claude-(\w+)-/);return s?s[1].charAt(0).toUpperCase()+s[1].slice(1):e}function oWe(){return i.jsx("div",{className:"space-y-2","data-testid":"model-cards-skeleton",children:Array.from({length:3}).map((e,t)=>i.jsxs("div",{className:"flex items-center gap-3 rounded-xl p-3",children:[i.jsx(on,{className:"size-4 rounded-full"}),i.jsxs("div",{className:"flex-1 space-y-1.5",children:[i.jsx(on,{className:"h-3.5 w-24"}),i.jsx(on,{className:"h-2.5 w-32"})]}),i.jsx(on,{className:"h-5 w-10 rounded-md"})]},t))})}function lWe({onRetry:e}){return i.jsxs("div",{className:"flex flex-col items-center gap-3 py-6 text-center","data-testid":"model-load-error",children:[i.jsx(Wk,{className:"text-muted-foreground size-5"}),i.jsx("p",{className:"text-muted-foreground text-xs",children:"Failed to load models"}),i.jsxs("button",{onClick:e,className:"text-foreground hover:bg-accent inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-xs transition-colors",children:[i.jsx(mu,{className:"size-3"}),"Retry"]})]})}function cWe({model:e,isSelected:t}){return i.jsxs("label",{className:X("flex w-full cursor-pointer items-center gap-3 rounded-xl border p-3 transition-colors duration-150",t?"bg-secondary border-foreground/15":"border-border hover:border-muted-foreground/30 hover:bg-muted/50 opacity-70"),children:[i.jsx(Xx,{value:e.value,className:"shrink-0"}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("div",{className:"text-foreground truncate text-sm font-medium",children:e.displayName}),i.jsx("div",{className:"text-muted-foreground truncate text-[11px] leading-tight",children:e.description})]}),e.contextWindow&&i.jsx(Ot,{variant:"secondary",className:"shrink-0 text-[10px]",children:aWe(e.contextWindow)})]})}function uWe({effortLevels:e,effort:t,onChangeEffort:n}){return i.jsxs("div",{children:[i.jsx("div",{className:"text-muted-foreground mb-2 text-[11px] font-medium tracking-wide uppercase",children:"Effort"}),i.jsxs("div",{className:"flex flex-wrap gap-1.5",role:"radiogroup","aria-label":"Effort level",children:[i.jsx(d7,{label:"Default",isSelected:t===null,onClick:()=>n(null)}),e.map(s=>i.jsx(d7,{label:JR[s].label,description:JR[s].description,isSelected:t===s,onClick:()=>n(s)},s))]})]})}function d7({label:e,description:t,isSelected:n,onClick:s}){const r=i.jsx("button",{role:"radio","aria-checked":n,onClick:s,className:X("rounded-md px-2.5 py-1 text-xs font-medium transition-colors duration-150",n?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:bg-muted/80 hover:text-foreground"),children:e});return t?i.jsxs(Kn,{children:[i.jsx(Wn,{asChild:!0,children:r}),i.jsx(Yn,{side:"top",className:"text-xs",children:t})]}):r}function dWe({supportsFastMode:e,fastMode:t,onChangeFastMode:n}){return e?i.jsxs("div",{children:[i.jsx("div",{className:"text-muted-foreground mb-2 text-[11px] font-medium tracking-wide uppercase",children:"Mode"}),i.jsx("div",{className:"flex gap-1.5",children:i.jsx(fWe,{label:"Fast",icon:i.jsx(Pu,{className:"size-3"}),isActive:t,onToggle:()=>n(!t)})})]}):null}function fWe({label:e,icon:t,isActive:n,onToggle:s}){return i.jsxs("button",{role:"switch","aria-checked":n,onClick:s,className:X("inline-flex items-center gap-1.5 rounded-md px-2.5 py-1 text-xs font-medium transition-colors duration-150",n?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:bg-muted/80 hover:text-foreground"),children:[t,e]})}function hWe({model:e,onChangeModel:t,effort:n,onChangeEffort:s,fastMode:r,onChangeFastMode:a,disabled:o,sessionId:l}){const{data:c,isLoading:u,isError:f,refetch:h}=aD(l),m=c??[],g=m.find(C=>C.value===e),b=(g==null?void 0:g.supportsEffort)&&g.supportedEffortLevels&&g.supportedEffortLevels.length>0,v=(g==null?void 0:g.supportsFastMode)??!1,k=n?JR[n].label:null,w=i.jsxs("button",{disabled:o,className:"hover:text-foreground inline-flex items-center gap-1 transition-colors duration-150 disabled:cursor-not-allowed disabled:opacity-40","data-testid":"model-config-trigger",children:[i.jsx(zy,{className:"size-(--size-icon-xs)"}),i.jsx("span",{children:iWe(e,m)}),k&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-muted-foreground text-[11px]",children:"·"}),i.jsx(Ot,{variant:"secondary",className:"px-1.5 py-0 text-[10px]",children:k})]}),r&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-muted-foreground text-[11px]",children:"·"}),i.jsxs(Ot,{variant:"secondary",className:"px-1.5 py-0 text-[10px]",children:[i.jsx(Pu,{className:"mr-0.5 inline size-2.5"}),"Fast"]})]})]});return o?i.jsxs(Kn,{children:[i.jsx(Wn,{asChild:!0,children:i.jsx("span",{className:"inline-flex",children:w})}),i.jsx(Yn,{side:"top",children:"Send a message first"})]}):i.jsxs(XD,{children:[i.jsx(QD,{asChild:!0,children:w}),i.jsxs(JD,{side:"top",align:"start",className:"w-80 p-3","data-testid":"model-config-popover",children:[i.jsx(e5,{children:"Model"}),u&&i.jsx(oWe,{}),f&&i.jsx(lWe,{onRetry:()=>h()}),!u&&!f&&i.jsx(YD,{value:e,onValueChange:t,className:"grid-cols-1 gap-1.5","aria-label":"Model selection","data-testid":"model-card-list",children:m.map(C=>i.jsx(cWe,{model:C,isSelected:C.value===e},C.value))}),i.jsx(He,{children:!u&&!f&&(b||v)&&i.jsxs(oe.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:4},transition:rWe,children:[i.jsx(VS,{className:"my-3"}),i.jsx("div",{className:"text-muted-foreground mb-3 text-[11px] font-medium tracking-wide uppercase",children:"Configuration"}),i.jsxs("div",{className:"space-y-3",children:[b&&i.jsx(uWe,{effortLevels:g.supportedEffortLevels,effort:n,onChangeEffort:s}),v&&i.jsx(dWe,{supportsFastMode:(g==null?void 0:g.supportsFastMode)??!1,fastMode:r,onChangeFastMode:a})]})]},"config")})]})]})}function pWe({costUsd:e}){return i.jsxs("span",{className:"inline-flex items-center gap-1",children:[i.jsx(EX,{className:"size-(--size-icon-xs)"}),i.jsxs("span",{children:["$",e.toFixed(2)]})]})}function jN(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function mWe({cacheReadTokens:e,cacheCreationTokens:t,contextTokens:n}){const s=n??e+t,r=Math.max(0,s-e-t),a=s>0?Math.round(e/s*100):0,o=a>=70?"text-emerald-500":a>=30?"":"text-amber-500";return i.jsxs(Kn,{children:[i.jsx(Wn,{asChild:!0,children:i.jsxs("span",{className:X("inline-flex cursor-default items-center gap-1",o),"aria-label":"Prompt cache hit rate",children:[i.jsx(Pu,{className:"size-(--size-icon-xs)"}),i.jsxs("span",{children:[a,"%"]})]})}),i.jsx(Yn,{side:"top",className:"max-w-56",children:i.jsxs("div",{className:"space-y-1",children:[i.jsx("div",{className:"text-xs font-medium",children:"Prompt Cache"}),i.jsxs("div",{className:"space-y-0.5 text-[10px]",children:[i.jsxs("div",{className:"flex justify-between gap-3",children:[i.jsx("span",{className:"text-muted-foreground",children:"Cache hits"}),i.jsx("span",{children:jN(e)})]}),i.jsxs("div",{className:"flex justify-between gap-3",children:[i.jsx("span",{className:"text-muted-foreground",children:"Cache writes"}),i.jsx("span",{children:jN(t)})]}),n!=null&&n>0&&i.jsxs("div",{className:"flex justify-between gap-3",children:[i.jsx("span",{className:"text-muted-foreground",children:"Uncached"}),i.jsx("span",{children:jN(r)})]})]})]})})]})}function AN(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function gWe({percent:e,contextUsage:t}){const n=t?Math.round(t.percentage):e,s=n>=95?"text-red-500":n>=80?"text-amber-500":"",r=i.jsxs("span",{className:X("inline-flex items-center gap-1",s),children:[i.jsx(GEe,{className:"size-(--size-icon-xs)"}),i.jsxs("span",{children:[n,"%"]})]});if(!t)return r;const a=t.categories.filter(o=>o.tokens>0).sort((o,l)=>l.tokens-o.tokens);return i.jsxs(Kn,{children:[i.jsx(Wn,{asChild:!0,children:i.jsx("span",{className:"inline-flex cursor-default","aria-label":"Context window usage",children:r})}),i.jsx(Yn,{side:"top",className:"max-w-64",children:i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs("div",{className:"text-xs font-medium",children:[AN(t.totalTokens)," / ",AN(t.maxTokens)," tokens"]}),a.length>0&&i.jsx("div",{className:"space-y-0.5",children:a.map(o=>i.jsxs("div",{className:"flex items-center justify-between gap-3 text-[10px]",children:[i.jsxs("span",{className:"flex items-center gap-1 truncate",children:[i.jsx("span",{className:"inline-block size-1.5 shrink-0 rounded-full",style:{backgroundColor:o.color}}),o.name]}),i.jsx("span",{className:"text-muted-foreground shrink-0",children:AN(o.tokens)})]},o.name))})]})})]})}function xWe(e){if(!e)return"Rate limit";switch(e){case"five_hour":return"5-hour window";case"seven_day":return"7-day window";case"seven_day_opus":return"7-day Opus";case"seven_day_sonnet":return"7-day Sonnet";case"overage":return"Overage";default:return e}}function yWe({usageInfo:e}){const t=e.utilization!=null?Math.round(e.utilization*100):null,n=e.status==="allowed_warning",s=e.status==="rejected",r=s?"text-red-500":n||t!=null&&t>=80?"text-amber-500":"",a=e.resetsAt?new Date(e.resetsAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):null;return i.jsxs(Kn,{children:[i.jsx(Wn,{asChild:!0,children:i.jsxs("span",{className:X("inline-flex cursor-default items-center gap-1",r),"aria-label":"Subscription usage",children:[i.jsx(NX,{className:"size-(--size-icon-xs)"}),t!=null&&i.jsxs("span",{children:[t,"%"]}),t==null&&s&&i.jsx("span",{children:"Limit"})]})}),i.jsx(Yn,{side:"top",className:"max-w-56",children:i.jsxs("div",{className:"space-y-1",children:[i.jsx("div",{className:"text-xs font-medium",children:"Subscription Usage"}),i.jsxs("div",{className:"space-y-0.5 text-[10px]",children:[t!=null&&i.jsxs("div",{className:"flex justify-between gap-3",children:[i.jsx("span",{className:"text-muted-foreground",children:"Utilization"}),i.jsxs("span",{children:[t,"%"]})]}),i.jsxs("div",{className:"flex justify-between gap-3",children:[i.jsx("span",{className:"text-muted-foreground",children:"Window"}),i.jsx("span",{children:xWe(e.rateLimitType)})]}),a&&i.jsxs("div",{className:"flex justify-between gap-3",children:[i.jsx("span",{className:"text-muted-foreground",children:"Resets at"}),i.jsx("span",{children:a})]}),e.isUsingOverage&&i.jsx("div",{className:"text-amber-500",children:"Using overage capacity"}),s&&i.jsx("div",{className:"text-red-500",children:"Rate limit reached"})]})]})})]})}function bWe({enabled:e,onToggle:t}){const n=e?qX:H_e;return i.jsx("button",{onClick:t,className:"hover:text-foreground inline-flex items-center gap-1 transition-colors duration-150","aria-label":e?"Mute notification sound":"Unmute notification sound",title:e?"Sound on — click to mute":"Sound off — click to unmute",children:i.jsx(n,{className:"size-(--size-icon-xs)"})})}function vWe({enabled:e,onToggle:t}){const n=e?D_e:R_e;return i.jsxs(GD,{openDelay:300,children:[i.jsx(KD,{asChild:!0,children:i.jsx("button",{onClick:t,className:"hover:text-foreground inline-flex items-center gap-1 transition-colors duration-150","aria-label":e?"Disable background refresh":"Enable background refresh",children:i.jsx(n,{className:"size-(--size-icon-xs)"})})}),i.jsxs(WD,{side:"top",align:"center",className:"w-64 p-3",children:[i.jsxs("p",{className:"text-sm font-medium",children:["Background refresh ",e?"on":"off"]}),i.jsx("p",{className:"text-muted-foreground mt-1.5 text-xs leading-relaxed",children:e?"Messages are checked for updates periodically, even when no one is typing. Useful if agents run in the background. Turn off to reduce network usage.":"Messages only update while someone is actively responding. Turn on if you have agents running unattended and want to see their progress."})]})]})}const SWe={connecting:{color:"bg-amber-500",label:"Connecting",icon:G1,tasks:!0},connected:{color:"bg-emerald-500",label:"Connected",icon:G1,tasks:!1},reconnecting:{color:"bg-amber-500",label:"Reconnecting",icon:G1,tasks:!0},disconnected:{color:"bg-red-500",label:"Connection lost",icon:Jk,tasks:!1}};function wWe({connectionState:e,failedAttempts:t}){const n=e!=="connected",s=SWe[e],r=s.icon,a=t&&e==="reconnecting"?`Reconnecting (${t}/${Id.DISCONNECTED_THRESHOLD})`:s.label;return i.jsx(La.Item,{itemKey:"connection",visible:n,children:i.jsxs(GD,{openDelay:200,children:[i.jsx(KD,{asChild:!0,children:i.jsxs("span",{className:"flex cursor-default items-center gap-1.5 text-xs",role:"status",children:[i.jsx("span",{className:X("size-1.5 rounded-full",s.color,s.tasks&&"animate-tasks")}),i.jsx("span",{className:"text-muted-foreground",children:a})]})}),i.jsx(WD,{side:"top",align:"center",className:"w-72 p-3",children:i.jsxs("div",{className:"flex items-start gap-2.5",children:[i.jsx(r,{className:X("mt-0.5 size-4 shrink-0",e==="disconnected"?"text-red-500":"text-amber-500")}),i.jsxs("div",{className:"min-w-0 space-y-1.5",children:[i.jsx("p",{className:"text-sm font-medium",children:a}),i.jsx(kWe,{connectionState:e})]})]})})]})})}function kWe({connectionState:e}){const t="text-muted-foreground text-xs leading-relaxed";return e==="connecting"?i.jsx("p",{className:t,children:"Opening the live connection to this session. New messages and updates appear once it's open."}):e==="reconnecting"?i.jsxs("div",{className:"space-y-1.5",children:[i.jsx("p",{className:t,children:"The live connection dropped and is reconnecting automatically. Incoming messages and updates are paused — nothing is lost; anything missed replays when it reconnects."}),i.jsx("p",{className:X(t,"text-muted-foreground/70"),children:"No action needed."})]}):i.jsxs("div",{className:"space-y-1.5",children:[i.jsx("p",{className:t,children:"Could not re-establish the live connection after several attempts. New messages and updates will not appear until it's restored."}),i.jsx("p",{className:X(t,"text-muted-foreground/70"),children:"Try refreshing the page. If the issue persists, check that the DorkOS server is running."})]})}function CWe({subagents:e}){return i.jsxs(Kn,{children:[i.jsx(Wn,{asChild:!0,children:i.jsxs("span",{className:"inline-flex items-center gap-1",children:[i.jsx(Hy,{className:"size-(--size-icon-xs)"}),i.jsxs("span",{children:[e.length," agent",e.length!==1?"s":""]})]})}),i.jsx(Yn,{side:"top",className:"max-w-64",children:i.jsx("ul",{className:"space-y-1",children:e.map(t=>i.jsxs("li",{children:[i.jsx("span",{className:"font-medium",children:t.name}),t.model&&i.jsxs("span",{className:"text-muted-foreground ml-1 text-[10px]",children:["(",t.model,")"]}),i.jsx("p",{className:"text-muted-foreground line-clamp-1 text-[10px] leading-tight",children:t.description})]},t.name))})})]})}const EWe={session:"Session Info",controls:"Controls"},mb=[{key:"cwd",label:"Directory",description:"Current working directory",group:"session",icon:Kf,defaultVisible:!0},{key:"git",label:"Git Status",description:"Branch name and change count",group:"session",icon:EA,defaultVisible:!0},{key:"model",label:"Model",description:"Selected AI model",group:"session",icon:zy,defaultVisible:!0},{key:"cost",label:"Cost",description:"Session cost in USD",group:"session",icon:EX,defaultVisible:!0},{key:"cache",label:"Cache",description:"Prompt cache hit rate",group:"session",icon:Pu,defaultVisible:!0},{key:"context",label:"Context Usage",description:"Context window utilization",group:"session",icon:FCe,defaultVisible:!0},{key:"usage",label:"Usage",description:"Subscription utilization",group:"session",icon:NX,defaultVisible:!0},{key:"permission",label:"Permission Mode",description:"Agent permission level selector",group:"controls",icon:Ho,defaultVisible:!0},{key:"sound",label:"Sound",description:"Notification sound toggle",group:"controls",icon:qX,defaultVisible:!0},{key:"polling",label:"Refresh",description:"Background polling for updates",group:"controls",icon:mu,defaultVisible:!0}];function hae(e){const t=e.charAt(0).toUpperCase()+e.slice(1),n=`showStatusBar${t}`,s=`setShowStatusBar${t}`,r=je(o=>o[n]),a=je(o=>o[s]);return[r,a]}function aE(){const e=je.getState();for(const t of mb){const s=`setShowStatusBar${t.key.charAt(0).toUpperCase()+t.key.slice(1)}`,r=e[s];r(t.defaultVisible)}}function TWe(){return["session","controls"].map(t=>({group:t,label:EWe[t],items:mb.filter(n=>n.group===t)})).filter(t=>t.items.length>0)}function _We({itemKey:e}){const t=mb.find(a=>a.key===e),[n,s]=hae(e);if(!t)return null;const r=t.icon;return i.jsx(os,{label:i.jsxs("span",{className:"flex items-center gap-1.5",children:[i.jsx(r,{className:"text-muted-foreground size-3.5 shrink-0","aria-hidden":!0}),t.label]}),description:t.description,children:i.jsx(Ks,{checked:n,onCheckedChange:s,"aria-label":`Toggle ${t.label}`})})}function pae(){const e=TWe();return i.jsxs("div",{className:"flex flex-col gap-4","aria-label":"Status bar configuration",children:[e.map(t=>i.jsxs("div",{className:"space-y-1.5",children:[i.jsx("p",{className:"text-muted-foreground px-1 text-xs font-medium tracking-wide uppercase",children:t.label}),i.jsx(Sa,{children:i.jsx(Wr,{children:t.items.map(n=>i.jsx(_We,{itemKey:n.key},n.key))})})]},t.group)),i.jsx(ve,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground h-auto justify-start px-1 py-1 text-xs",onClick:aE,children:"Reset to defaults"})]})}pae.displayName="StatusBarConfigureContent";function mae({children:e,open:t,onOpenChange:n}){return i.jsxs(XD,{open:t,onOpenChange:n,children:[i.jsx(QD,{asChild:!0,children:e}),i.jsxs(JD,{side:"top",align:"end",className:"w-72 p-3","aria-label":"Status bar configuration",children:[i.jsx(e5,{children:"Configure Status Bar"}),i.jsx(pae,{})]})]})}mae.displayName="StatusBarConfigurePopover";function gae(e,t){const[n,s,r]=e.split(".").map(Number),[a,o,l]=t.split(".").map(Number);return n!==a?n>a:s!==o?s>o:r>l}function NWe(e,t){const[n,s]=e.split(".").map(Number),[r,a]=t.split(".").map(Number);return n!==r||s!==a}function jWe({item:e}){const[t,n]=hae(e.key);return i.jsx(gi,{label:e.label,description:e.description,checked:t,onCheckedChange:n})}function AWe(){return i.jsxs("div",{className:"space-y-4",children:[i.jsx(Jm,{actions:i.jsx("button",{onClick:aE,className:"text-muted-foreground hover:text-foreground text-xs transition-colors duration-150",children:"Reset to defaults"}),children:"Status Bar"}),i.jsx(Sa,{children:i.jsx(Wr,{children:mb.map(e=>i.jsx(jWe,{item:e},e.key))})})]})}function RWe(){const e=Fe(),{data:t,isLoading:n}=mt({queryKey:["config"],queryFn:()=>e.getConfig(),staleTime:3e4});return i.jsx("div",{className:"space-y-3",children:n?i.jsx("div",{className:"space-y-2",children:Array.from({length:5}).map((s,r)=>i.jsxs("div",{className:"flex items-center justify-between py-1",children:[i.jsx("div",{className:"bg-muted animate-tasks h-4 w-24 rounded"}),i.jsx("div",{className:"bg-muted animate-tasks h-4 w-16 rounded"})]},r))}):t?i.jsxs("div",{className:"space-y-1",children:[t.isDevMode?i.jsxs("div",{className:"-mx-1 rounded border border-amber-200 bg-amber-50 px-2 py-1.5 dark:border-amber-800 dark:bg-amber-950/30",children:[i.jsx("span",{className:"text-sm font-medium text-amber-800 dark:text-amber-200",children:"Development Build"}),i.jsx("p",{className:"mt-0.5 text-xs text-amber-700 dark:text-amber-300",children:"Running from source — version checks disabled"})]}):i.jsxs(i.Fragment,{children:[i.jsx(hl,{label:"Version",value:t.version}),t.latestVersion&&gae(t.latestVersion,t.version)&&i.jsxs("div",{className:"-mx-1 rounded border border-amber-200 bg-amber-50 px-2 py-1.5 dark:border-amber-800 dark:bg-amber-950/30",children:[i.jsx("div",{className:"flex items-center justify-between",children:i.jsxs("span",{className:"text-sm font-medium text-amber-800 dark:text-amber-200",children:["Update available: v",t.latestVersion]})}),i.jsxs("p",{className:"mt-0.5 text-xs text-amber-700 dark:text-amber-300",children:["Run"," ",i.jsx("code",{className:"rounded bg-amber-100 px-1 py-0.5 font-mono text-[10px] dark:bg-amber-900/50",children:"npm update -g dorkos"})," ","to update"]})]})]}),i.jsx(hl,{label:"Port",value:String(t.port)}),i.jsx(hl,{label:"Uptime",value:MWe(t.uptime)}),i.jsx(hl,{label:"API URL",value:`http://localhost:${t.port}`,mono:!0}),i.jsx(hl,{label:"MCP Endpoint",value:`http://localhost:${t.port}/mcp`,mono:!0}),i.jsx(hl,{label:"Working Directory",value:t.workingDirectory,mono:!0,truncate:!0}),i.jsx(hl,{label:"Data Directory",value:t.dorkHome,mono:!0,truncate:!0}),i.jsx(hl,{label:"Boundary",value:t.boundary,mono:!0,truncate:!0}),i.jsx(hl,{label:"Node.js",value:t.nodeVersion})]}):null})}function hl({label:e,value:t,mono:n,truncate:s,muted:r}){const[a,o]=Bx();return i.jsxs("button",{type:"button",onClick:()=>o(t),className:"hover:bg-muted/50 active:bg-muted/70 -mx-1 flex w-full items-center justify-between gap-4 rounded px-1 py-1 transition-colors duration-100",children:[i.jsx("span",{className:"text-muted-foreground shrink-0 text-sm",children:e}),a?i.jsx("span",{className:"text-muted-foreground text-xs",children:"Copied"}):i.jsx("span",{className:X("text-right text-sm",n&&"font-mono",s&&"max-w-48 min-w-0 truncate",r&&"text-muted-foreground"),dir:s?"rtl":void 0,title:t,children:t})]})}function MWe(e){const t=Math.floor(e/3600),n=Math.floor(e%3600/60),s=Math.floor(e%60),r=[];return t>0&&r.push(`${t}h`),n>0&&r.push(`${n}m`),r.push(`${s}s`),r.join(" ")}const DWe={relayTools:!0,meshTools:!0,adapterTools:!0,tasksTools:!0};function OWe(){const e=Fe(),t=Ct(),{data:n}=mt({queryKey:["config"],queryFn:()=>e.getConfig(),staleTime:3e4}),s={...DWe,...n==null?void 0:n.agentContext},r=mn({mutationFn:o=>e.updateConfig({agentContext:{...s,...o}}),onSuccess:()=>{t.invalidateQueries({queryKey:["config"]})}}),a=x.useCallback(o=>{r.mutate(o)},[r]);return{config:s,updateConfig:a}}const tx={core:["ping","get_server_info","get_session_count","get_agent","control_ui","get_ui_state"],tasks:["tasks_list","tasks_create","tasks_update","tasks_delete","tasks_get_run_history"],relay:["relay_send","relay_inbox","relay_list_endpoints","relay_register_endpoint","relay_send_and_wait","relay_send_async","relay_unregister_endpoint","relay_get_trace","relay_get_metrics"],mesh:["mesh_discover","mesh_register","mesh_list","mesh_deny","mesh_unregister","mesh_status","mesh_inspect","mesh_query_topology"],adapter:["relay_list_adapters","relay_enable_adapter","relay_disable_adapter","relay_reload_adapters","binding_list","binding_create","binding_delete","binding_list_sessions","relay_notify_user"]},f7={tasks:"tasksTools",relay:"relayTools",mesh:"meshTools",adapter:"adapterTools"},IWe=[{key:"tasks",label:"Tasks (Scheduling)",description:"Create and manage scheduled agent runs",tools:tx.tasks},{key:"relay",label:"Relay (Messaging)",description:"Send messages, check inbox, register endpoints",tools:tx.relay,implicitNote:"Includes trace tools (relay_get_trace, relay_get_metrics)"},{key:"mesh",label:"Mesh (Discovery)",description:"Discover, register, and query agents",tools:tx.mesh},{key:"adapter",label:"Relay Adapters",description:"Manage Telegram, Slack, webhooks, and bindings",tools:tx.adapter,implicitNote:"Includes binding tools (binding_list, binding_create, binding_delete)"}];function xae({tools:e,implicitNote:t}){return i.jsxs(Kn,{children:[i.jsx(Wn,{asChild:!0,children:i.jsx(Ot,{variant:"outline",className:"text-muted-foreground shrink-0 cursor-default text-xs font-normal",children:e.length})}),i.jsxs(Yn,{side:"top",className:"max-w-xs",children:[i.jsx("p",{className:"font-mono text-xs",children:e.join(", ")}),t&&i.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:t})]})]})}function PWe({group:e,enabled:t,available:n,initError:s,overrideCount:r,onToggle:a,expandContent:o}){const[l,c]=x.useState(!1),u=!!o,f=i.jsxs("div",{className:"flex items-center gap-2",children:[s&&i.jsxs(Kn,{children:[i.jsx(Wn,{asChild:!0,children:i.jsx(Yr,{className:"size-3.5 shrink-0 text-amber-500"})}),i.jsx(Yn,{side:"top",className:"max-w-xs",children:i.jsx("p",{className:"text-xs",children:s})})]}),!n&&!s&&i.jsx(Ot,{variant:"secondary",className:"text-xs",children:"Disabled"}),r>0&&i.jsxs(Kn,{children:[i.jsx(Wn,{asChild:!0,children:i.jsxs("span",{className:"text-muted-foreground shrink-0 text-xs",children:[r," ",r===1?"override":"overrides"]})}),i.jsx(Yn,{side:"top",children:i.jsxs("p",{className:"text-xs",children:[r," ",r===1?"agent has":"agents have"," a per-agent override for this group"]})})]}),i.jsx(xae,{tools:e.tools,implicitNote:e.implicitNote}),i.jsx(Ks,{checked:t,onCheckedChange:m=>a(e.key,m),disabled:!n,"aria-label":`Toggle ${e.label}`}),u&&i.jsx($l,{asChild:!0,children:i.jsx("button",{className:"text-muted-foreground hover:text-foreground rounded-sm p-0.5 transition-colors duration-150","aria-label":`${l?"Collapse":"Expand"} ${e.label} settings`,children:i.jsx(Ps,{className:X("size-3.5 transition-transform duration-150",!l&&"-rotate-90")})})})]}),h=i.jsx(os,{label:e.label,description:e.description,children:f});return u?i.jsxs(Bl,{open:l,onOpenChange:c,children:[h,i.jsx(Hl,{children:i.jsx("div",{className:"border-border mt-2 space-y-2 border-t pt-2",children:o})})]}):h}function LWe({scheduler:e,onUpdate:t}){return i.jsxs(i.Fragment,{children:[i.jsx(os,{label:"Concurrent runs",description:"Maximum parallel task runs",children:i.jsx(_n,{type:"number",min:1,max:10,value:e.maxConcurrentRuns,onChange:n=>{const s=parseInt(n.target.value,10);s>=1&&s<=10&&t({maxConcurrentRuns:s})},className:"w-20"})}),i.jsx(os,{label:"Timezone",description:"IANA timezone for cron schedules",children:i.jsxs(Bn,{value:e.timezone??"system",onValueChange:n=>t({timezone:n==="system"?null:n}),children:[i.jsx(Dn,{className:"w-48",children:i.jsx($n,{})}),i.jsxs(On,{children:[i.jsx(yt,{value:"system",children:"System default"}),i.jsx(yt,{value:"UTC",children:"UTC"}),i.jsx(yt,{value:"America/New_York",children:"America/New_York"}),i.jsx(yt,{value:"America/Chicago",children:"America/Chicago"}),i.jsx(yt,{value:"America/Denver",children:"America/Denver"}),i.jsx(yt,{value:"America/Los_Angeles",children:"America/Los_Angeles"}),i.jsx(yt,{value:"Europe/London",children:"Europe/London"}),i.jsx(yt,{value:"Europe/Berlin",children:"Europe/Berlin"}),i.jsx(yt,{value:"Europe/Paris",children:"Europe/Paris"}),i.jsx(yt,{value:"Asia/Tokyo",children:"Asia/Tokyo"}),i.jsx(yt,{value:"Asia/Shanghai",children:"Asia/Shanghai"}),i.jsx(yt,{value:"Asia/Kolkata",children:"Asia/Kolkata"}),i.jsx(yt,{value:"Australia/Sydney",children:"Australia/Sydney"})]})]})}),i.jsx(os,{label:"Run history",description:"Completed runs to keep",children:i.jsx(_n,{type:"number",min:1,max:1e4,value:e.retentionCount,onChange:n=>{const s=parseInt(n.target.value,10);s>=1&&t({retentionCount:s})},className:"w-24"})})]})}function FWe({authConfigured:e,authSource:t,generatedKey:n,keyError:s,onGenerate:r,onRotate:a,onRemove:o}){const[l,c]=Bx();return t==="env"?i.jsx(os,{label:"API Key",description:"Set via MCP_API_KEY environment variable",children:i.jsx(Ot,{variant:"outline",children:"Environment variable"})}):!e&&!n?i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"min-w-0",children:[i.jsx("p",{className:"text-sm font-medium",children:"API Key"}),i.jsx("p",{className:"text-muted-foreground text-xs",children:"Protect the MCP endpoint with bearer token auth"})]}),i.jsxs(ve,{size:"sm",onClick:r,children:[i.jsx(HEe,{className:"mr-1.5 size-3.5"}),"Generate Key"]})]}),s&&i.jsx("p",{className:"text-xs text-red-500",role:"alert",children:s})]}):n?i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"min-w-0",children:[i.jsx("p",{className:"text-sm font-medium",children:"API Key"}),i.jsx("p",{className:"text-muted-foreground text-xs",children:"Copy this key now — it won't be shown again"})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("code",{className:"bg-muted min-w-0 flex-1 truncate rounded-md px-3 py-2 font-mono text-xs",children:n}),i.jsx("button",{className:"text-muted-foreground hover:text-foreground shrink-0 rounded-sm p-1.5 transition-colors",onClick:()=>c(n),"aria-label":"Copy API key",children:l?i.jsx(Zt,{className:"size-4 text-green-500"}):i.jsx(Gf,{className:"size-4"})})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(ve,{variant:"outline",size:"sm",onClick:a,children:"Rotate"}),i.jsx(ve,{variant:"ghost",size:"sm",onClick:o,children:"Remove"})]}),s&&i.jsx("p",{className:"text-xs text-red-500",role:"alert",children:s})]}):i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"min-w-0",children:[i.jsx("p",{className:"text-sm font-medium",children:"API Key"}),i.jsx("p",{className:"text-muted-foreground text-xs",children:"Bearer token for MCP authentication"})]}),i.jsx("div",{className:"flex items-center gap-2",children:i.jsx("code",{className:"bg-muted rounded-md px-3 py-2 font-mono text-xs",children:"dork_mcp_••••••••"})}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(ve,{variant:"outline",size:"sm",onClick:a,children:"Rotate"}),i.jsx(ve,{variant:"ghost",size:"sm",onClick:o,children:"Remove"})]}),s&&i.jsx("p",{className:"text-xs text-red-500",role:"alert",children:s})]})}function zWe(){return i.jsxs("div",{className:"flex gap-3 rounded-md border border-amber-500/20 bg-amber-500/10 p-3",children:[i.jsx(Yr,{className:"mt-0.5 size-4 shrink-0 text-amber-500"}),i.jsxs("div",{className:"space-y-1",children:[i.jsx("p",{className:"text-xs font-medium",children:"Do not configure this for agents running inside DorkOS."}),i.jsxs("p",{className:"text-muted-foreground text-xs",children:["DorkOS already provides tools to its managed agents internally. Adding DorkOS as an external MCP server to those same agents causes duplicate tool names — the Anthropic API will return HTTP 400 “Tool names must be unique” and all tool calls will fail. External MCP access is for agents running ",i.jsx("strong",{children:"outside"})," of DorkOS (standalone Claude Code, Cursor, Windsurf)."]})]})]})}function BWe({endpoint:e}){return i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"min-w-0",children:[i.jsx("p",{className:"text-sm font-medium",children:"Endpoint"}),i.jsx("p",{className:"text-muted-foreground text-xs",children:"MCP server URL for external agents"})]}),i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx("code",{className:"bg-muted min-w-0 flex-1 truncate rounded-md px-3 py-2 font-mono text-xs",children:e}),i.jsx(hw,{value:e})]})]})}function $We({rateLimit:e,onUpdate:t}){return i.jsxs("div",{className:"space-y-3",children:[i.jsx(gi,{label:"Rate limiting",description:"Limit external MCP requests per time window",checked:e.enabled,onCheckedChange:n=>t({enabled:n}),ariaLabel:"Toggle rate limiting"}),e.enabled&&i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"flex items-center gap-4",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("label",{htmlFor:"mcp-max-requests",className:"text-muted-foreground text-xs",children:"Max requests"}),i.jsx(_n,{id:"mcp-max-requests",type:"number",min:1,max:1e3,value:e.maxPerWindow,onChange:n=>{const s=parseInt(n.target.value,10);s>=1&&s<=1e3&&t({maxPerWindow:s})},className:"w-20"})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("label",{htmlFor:"mcp-window-secs",className:"text-muted-foreground text-xs",children:"Window (sec)"}),i.jsx(_n,{id:"mcp-window-secs",type:"number",min:1,max:3600,value:e.windowSecs,onChange:n=>{const s=parseInt(n.target.value,10);s>=1&&s<=3600&&t({windowSecs:s})},className:"w-20"})]})]}),i.jsx("p",{className:"text-muted-foreground text-xs",children:"Rate limit changes take effect after server restart."})]})]})}function HWe(e,t){const n=t?`Bearer ${t}`:"Bearer dork_mcp_YOUR_API_KEY";return{claudeCode:JSON.stringify({mcpServers:{"dorkos-external":{type:"http",url:e,headers:{Authorization:n}}}},null,2),claudeCodeCli:`claude mcp add-json dorkos-external '${JSON.stringify({type:"http",url:e,headers:{Authorization:n}})}'`,cursor:JSON.stringify({mcpServers:{"dorkos-external":{url:e,headers:{Authorization:n}}}},null,2),windsurf:JSON.stringify({mcpServers:{"dorkos-external":{serverUrl:e,headers:{Authorization:n}}}},null,2)}}function UWe({endpoint:e,apiKey:t}){const[n,s]=x.useState(!1),[r,a]=x.useState("claude-code"),o=HWe(e,t),l=r==="claude-code"?o.claudeCode:r==="cursor"?o.cursor:o.windsurf;return i.jsxs(Bl,{open:n,onOpenChange:s,children:[i.jsxs($l,{className:"flex w-full items-center justify-between text-sm font-medium",children:[i.jsx("span",{children:"Setup Instructions"}),i.jsx(Ps,{className:X("text-muted-foreground size-3.5 transition-transform duration-150",!n&&"-rotate-90")})]}),i.jsx(Hl,{children:i.jsxs("div",{className:"mt-3 space-y-3",children:[i.jsx("div",{className:"bg-muted flex gap-0.5 rounded-md p-0.5",children:["claude-code","cursor","windsurf"].map(c=>i.jsx("button",{onClick:()=>a(c),className:X("flex-1 rounded-sm px-3 py-1.5 text-xs font-medium transition-colors",r===c?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:c==="claude-code"?"Claude Code":c==="cursor"?"Cursor":"Windsurf"},c))}),i.jsxs("div",{className:"relative",children:[i.jsx("pre",{className:"bg-muted overflow-x-auto rounded-md p-3 text-xs leading-relaxed",children:l}),i.jsx("div",{className:"absolute top-2 right-2",children:i.jsx(hw,{value:l})})]}),r==="claude-code"&&i.jsxs("div",{className:"relative",children:[i.jsx("p",{className:"text-muted-foreground mb-1 text-xs",children:"Or add via CLI:"}),i.jsx("pre",{className:"bg-muted overflow-x-auto rounded-md p-3 text-xs leading-relaxed",children:o.claudeCodeCli}),i.jsx("div",{className:"absolute right-2 bottom-2",children:i.jsx(hw,{value:o.claudeCodeCli})})]})]})})]})}function VWe({mcp:e}){const t=Fe(),n=Ct(),[s,r]=x.useState(!1),[a,o]=x.useState(null),[l,c]=x.useState(null),u=x.useCallback(()=>n.invalidateQueries({queryKey:["config"]}),[n]),f=x.useCallback(async k=>{await t.updateConfig({mcp:{enabled:k,rateLimit:e.rateLimit}}),await u()},[t,e.rateLimit,u]),h=x.useCallback(async()=>{try{c(null);const{apiKey:k}=await t.generateMcpApiKey();o(k),await u()}catch{c("Failed to generate API key.")}},[t,u]),m=x.useCallback(async()=>{try{c(null),await t.deleteMcpApiKey();const{apiKey:k}=await t.generateMcpApiKey();o(k),await u()}catch{c("Failed to rotate API key. The previous key may have been removed."),await u()}},[t,u]),g=x.useCallback(async()=>{try{c(null),await t.deleteMcpApiKey(),o(null),await u()}catch{c("Failed to remove API key.")}},[t,u]),b=x.useCallback(async k=>{await t.updateConfig({mcp:{enabled:e.enabled,rateLimit:{...e.rateLimit,...k}}}),await u()},[t,e.enabled,e.rateLimit,u]),v=e.enabled?e.authConfigured?i.jsx(Ot,{variant:"outline",className:"border-green-500/50 text-xs text-green-600",children:"Enabled"}):i.jsx(Ot,{variant:"outline",className:"border-amber-500/50 text-xs text-amber-600",children:"No auth"}):i.jsx(Ot,{variant:"secondary",className:"text-xs",children:"Disabled"});return i.jsx(Sa,{children:i.jsxs(Bl,{open:s,onOpenChange:r,children:[i.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[i.jsxs("div",{className:"min-w-0",children:[i.jsx("p",{className:"text-sm font-medium",children:"External MCP Server"}),i.jsx("p",{className:"text-muted-foreground text-xs",children:"Add the DorkOS MCP to agents outside of DorkOS"})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[v,i.jsx(Ks,{checked:e.enabled,onCheckedChange:f,"aria-label":"Toggle external MCP access"}),i.jsx($l,{asChild:!0,children:i.jsx("button",{className:"text-muted-foreground hover:text-foreground rounded-sm p-0.5 transition-colors duration-150","aria-label":`${s?"Collapse":"Expand"} external MCP server settings`,children:i.jsx(Ps,{className:X("size-3.5 transition-transform duration-150",!s&&"-rotate-90")})})})]})]}),i.jsx(Hl,{children:i.jsxs(Wr,{className:"border-t",children:[i.jsx(zWe,{}),i.jsx(BWe,{endpoint:e.endpoint}),i.jsx(FWe,{authConfigured:e.authConfigured,authSource:e.authSource,generatedKey:a,keyError:l,onGenerate:h,onRotate:m,onRemove:g}),i.jsx($We,{rateLimit:e.rateLimit,onUpdate:b}),i.jsx(UWe,{endpoint:e.endpoint,apiKey:a})]})})]})})}function qWe({onClick:e}){return i.jsx("button",{onClick:e,className:"text-muted-foreground hover:text-foreground text-xs transition-colors duration-150",children:"Reset to defaults"})}function GWe(){var k,w,C,E;const e=ed(),t=td(),{config:n,updateConfig:s}=OWe(),r=Fe(),a=Ct(),{section:o}=qm();bNe(o);const{data:l}=mt({queryKey:["config"],queryFn:()=>r.getConfig(),staleTime:3e4}),{data:c}=ji(),u=l==null?void 0:l.scheduler,f=x.useMemo(()=>{const T=(c==null?void 0:c.agents)??[],_={tasks:0,relay:0,mesh:0,adapter:0};for(const j of T){const R=j.enabledToolGroups;R&&(R.tasks!==void 0&&_.tasks++,R.relay!==void 0&&_.relay++,R.mesh!==void 0&&_.mesh++,R.adapter!==void 0&&_.adapter++)}return _},[c]),h={tasks:t,relay:e,mesh:!0,adapter:e},m={tasks:(k=l==null?void 0:l.tasks)==null?void 0:k.initError,relay:(w=l==null?void 0:l.relay)==null?void 0:w.initError,mesh:(C=l==null?void 0:l.mesh)==null?void 0:C.initError,adapter:(E=l==null?void 0:l.relay)==null?void 0:E.initError},g=x.useCallback((T,_)=>{s({[f7[T]]:_})},[s]),b=x.useCallback(async T=>{const _=u??{maxConcurrentRuns:1,timezone:null,retentionCount:100};await r.updateConfig({scheduler:{..._,...T}}),await a.invalidateQueries({queryKey:["config"]})},[r,a,u]),v=x.useCallback(async()=>{await r.updateConfig({agentContext:{relayTools:!0,meshTools:!0,adapterTools:!0,tasksTools:!0}}),a.invalidateQueries({queryKey:["config"]})},[r,a]);return i.jsxs("div",{className:"space-y-4",children:[i.jsx(Jm,{actions:i.jsx(qWe,{onClick:v}),children:"Tools"}),i.jsx("p",{className:"text-muted-foreground text-sm",children:"Control which MCP tool groups are available to agents. These are global defaults — individual agents can override them in their Tools tab."}),i.jsx(Sa,{children:i.jsxs(Wr,{children:[i.jsx(os,{label:"Core Tools",description:"Server info, agent identity, UI control",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(xae,{tools:tx.core}),i.jsx("span",{className:"text-muted-foreground text-xs",children:"Always enabled"})]})}),IWe.map(T=>i.jsx(PWe,{group:T,enabled:n[f7[T.key]],available:h[T.key],initError:m[T.key],overrideCount:f[T.key],onToggle:g,expandContent:T.key==="tasks"&&u?i.jsx(LWe,{scheduler:u,onUpdate:b}):void 0},T.key))]})}),(l==null?void 0:l.mcp)&&i.jsx("div",{"data-section":"external-mcp",children:i.jsx(VWe,{mcp:l.mcp})})]})}function KWe(e){const t=MKe[e.status.state]??"bg-muted-foreground";return X("size-2 shrink-0 rounded-full",t)}function WWe({instance:e,manifest:t,bindingCount:n,onToggle:s,onConfigure:r}){const a=e.label||e.status.displayName||e.id,o=KWe(e),{inbound:l,outbound:c}=e.status.messageCount,u=l+c;return i.jsxs("div",{className:"flex items-center gap-3 py-2",children:[i.jsx("div",{className:o,"aria-hidden":!0}),i.jsx(hO,{iconId:t.iconId,adapterType:t.type,size:16,className:"text-muted-foreground shrink-0"}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("span",{className:"truncate text-sm font-medium",children:a}),i.jsxs("p",{className:"text-muted-foreground/60 text-xs",children:[n!==void 0&&n>0?`${n} agent${n!==1?"s":""}`:"No agents",u>0&&` · ${u} messages`]})]}),i.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[i.jsx(Ks,{checked:e.enabled,onCheckedChange:s,"aria-label":`${a} enabled`}),i.jsx(ve,{variant:"ghost",size:"sm",onClick:r,className:"size-7 p-0","aria-label":`Configure ${a}`,children:i.jsx(Qi,{className:"size-3.5"})})]})]})}function YWe(){const e=ed(),{data:t=[],isLoading:n}=VUe(e),{mutate:s}=W5(),{data:r=[]}=pb(),[a,o]=x.useState({open:!1}),l=x.useMemo(()=>{const g=new Map;for(const b of r)g.set(b.adapterId,(g.get(b.adapterId)??0)+1);return g},[r]);if(!e)return i.jsxs("div",{className:"flex flex-col items-center gap-3 rounded-xl border border-dashed py-8",children:[i.jsx(KS,{className:"text-muted-foreground/40 size-8"}),i.jsxs("div",{className:"text-center",children:[i.jsx("p",{className:"text-muted-foreground text-sm",children:"Relay is disabled"}),i.jsx("p",{className:"text-muted-foreground/60 text-xs",children:"Enable the Relay message bus to manage channels here"})]})]});if(n)return i.jsx("div",{className:"space-y-2",children:[1,2,3].map(g=>i.jsx(on,{className:"h-10 w-full rounded-md"},g))});const c=t.flatMap(g=>g.instances.map(b=>({instance:b,manifest:g.manifest}))),u=t.filter(g=>!g.manifest.deprecated&&(g.instances.length===0||g.manifest.multiInstance)),f=g=>{o({open:!0,manifest:g})},h=(g,b)=>{o({open:!0,manifest:g,instanceId:b})},m=a.instanceId?t.flatMap(g=>g.instances).find(g=>g.id===a.instanceId):void 0;return i.jsxs(i.Fragment,{children:[c.length>0?i.jsx(Sa,{children:i.jsx(Wr,{children:c.map(({instance:g,manifest:b})=>i.jsx(WWe,{instance:g,manifest:b,bindingCount:l.get(g.id)??0,onToggle:v=>s({id:g.id,enabled:v}),onConfigure:()=>h(b,g.id)},g.id))})}):i.jsxs("div",{className:"flex flex-col items-center gap-3 rounded-xl border border-dashed py-8",children:[i.jsx(KS,{className:"text-muted-foreground/40 size-8"}),i.jsxs("div",{className:"text-center",children:[i.jsx("p",{className:"text-muted-foreground text-sm",children:"No channels configured"}),i.jsx("p",{className:"text-muted-foreground/60 text-xs",children:"Add a channel below to connect agents to external platforms"})]})]}),u.length>0&&i.jsxs("section",{children:[i.jsx("h3",{className:"text-muted-foreground mb-2 text-xs font-semibold tracking-wide uppercase",children:"Available Channels"}),i.jsx("div",{className:"grid gap-2",style:{gridTemplateColumns:"repeat(auto-fill, minmax(240px, 1fr))"},children:u.map(g=>i.jsx(lae,{manifest:g.manifest,onAdd:()=>f(g.manifest)},g.manifest.type))})]}),a.manifest&&i.jsx(cae,{open:a.open,onOpenChange:g=>{g||o({open:!1})},manifest:a.manifest,existingInstance:m,existingAdapterIds:t.flatMap(g=>g.instances.map(b=>b.id))})]})}const ZWe=[0,0,.2,1],XWe={initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0}},QWe={duration:.2,ease:ZWe};function up({name:e,icon:t,description:n,status:s,enabled:r,onToggle:a,children:o}){const[l,c]=x.useState(!1),u=s==="coming-soon",f=!!o&&!u;return i.jsxs("div",{className:X("rounded-lg border transition-colors",u&&"border-dashed opacity-60"),children:[i.jsxs("button",{type:"button",className:"flex w-full items-center gap-3 px-4 py-3 text-left",onClick:()=>f&&c(h=>!h),disabled:!f,children:[i.jsx(t,{className:"text-muted-foreground size-5 shrink-0"}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-sm font-medium",children:e}),s==="active"&&i.jsx(Ot,{variant:"default",className:"text-xs",children:"Active"}),u&&i.jsx(Ot,{variant:"secondary",className:"text-xs",children:"Coming Soon"})]}),i.jsx("p",{className:"text-muted-foreground mt-0.5 text-xs",children:n})]}),!u&&a&&i.jsx("div",{onClick:h=>h.stopPropagation(),children:i.jsx(Ks,{checked:r,onCheckedChange:a})}),f&&i.jsx(Ps,{className:X("text-muted-foreground size-4 shrink-0 transition-transform duration-200",l&&"rotate-180")})]}),i.jsx(He,{initial:!1,children:l&&f&&i.jsx(oe.div,{variants:XWe,initial:"initial",animate:"animate",exit:"exit",transition:QWe,className:"overflow-hidden",children:i.jsx("div",{className:"space-y-3 border-t px-4 py-3",children:o})})})]})}function JWe(){var j;const e=Fe(),t=Ct(),n=ed(),{data:s=[]}=ug(n),{mutate:r}=W5(),{mutate:a}=ore(),[o,l]=x.useState(null),[c,u]=x.useState(null),{data:f}=mt({queryKey:["mesh","agents"],queryFn:()=>e.listMeshAgents(),staleTime:3e4}),{data:h}=mt({queryKey:["config"],queryFn:()=>e.getConfig(),staleTime:3e4}),m=x.useMemo(()=>s.find(R=>R.manifest.category==="internal"&&R.manifest.type==="claude-code"),[s]),g=m==null?void 0:m.instances[0],b=g==null?void 0:g.config,v=o??String((b==null?void 0:b.maxConcurrent)??3),k=c??String((b==null?void 0:b.defaultTimeoutMs)??3e5),w=(f==null?void 0:f.agents)??[],C=((j=h==null?void 0:h.agents)==null?void 0:j.defaultAgent)??"dorkbot";async function E(R){await e.setDefaultAgent(R),await t.invalidateQueries({queryKey:["config"]})}function T(R){g&&r({id:g.id,enabled:R})}function _(R,D){const I=Number(D);g&&!Number.isNaN(I)&&I>0&&a({id:g.id,config:{[R]:I}}),R==="maxConcurrent"&&l(null),R==="defaultTimeoutMs"&&u(null)}return i.jsxs(i.Fragment,{children:[w.length>0&&i.jsx(Sa,{children:i.jsx(Wr,{children:i.jsx(os,{label:"Default agent",description:"The primary agent used for new sessions and post-onboarding",children:i.jsxs(Bn,{value:C,onValueChange:E,children:[i.jsx(Dn,{className:"w-44","data-testid":"default-agent-select",children:i.jsx($n,{})}),i.jsx(On,{children:w.map(R=>i.jsx(yt,{value:R.name,children:tn(R)},R.id))})]})})})}),i.jsxs("div",{className:"space-y-2",children:[i.jsx("h3",{className:"text-sm font-semibold",children:"Runtimes"}),i.jsx("p",{className:"text-muted-foreground text-xs",children:"Configure which runtimes are available for agent sessions."}),i.jsxs(up,{name:"Claude Code",icon:oae,description:"Anthropic's agentic coding runtime — powers all DorkOS sessions",status:"active",enabled:(g==null?void 0:g.enabled)??!0,onToggle:g?T:void 0,children:[i.jsx(os,{label:"Claude CLI",description:(h==null?void 0:h.claudeCliPath)??"Not found — install Claude Code CLI to enable agent sessions",children:(h==null?void 0:h.claudeCliPath)&&i.jsx("span",{className:"text-muted-foreground max-w-48 min-w-0 truncate font-mono text-xs",dir:"rtl",title:h.claudeCliPath,children:h.claudeCliPath})}),g&&i.jsxs(i.Fragment,{children:[i.jsx(os,{label:"Max concurrent sessions",description:"Maximum relay-delivered sessions running simultaneously",children:i.jsx(_n,{type:"number",min:1,max:20,value:v,onChange:R=>l(R.target.value),onBlur:R=>_("maxConcurrent",R.target.value),className:"w-24"})}),i.jsx(os,{label:"Default timeout",description:"Timeout budget per relay session in milliseconds",children:i.jsx(_n,{type:"number",min:1e4,max:36e5,value:k,onChange:R=>u(R.target.value),onBlur:R=>_("defaultTimeoutMs",R.target.value),className:"w-32"})})]})]}),i.jsx(up,{name:"Codex",icon:ZR,description:"OpenAI's agentic coding runtime powered by o-series reasoning models",status:"coming-soon",enabled:!1}),i.jsx(up,{name:"Agent Protocol",icon:VTe,description:"Connect any ACP-compatible coding agent — OpenCode, Cline, Goose, Copilot CLI",status:"coming-soon",enabled:!1}),i.jsx(up,{name:"Pi Agent",icon:lEe,description:"Run coding agents locally with Ollama, LM Studio, or any model provider",status:"coming-soon",enabled:!1}),i.jsx(up,{name:"Gemini CLI",icon:XR,description:"Google's agentic coding runtime powered by Gemini 2.5 models",status:"coming-soon",enabled:!1}),i.jsx(up,{name:"Aider",icon:tD,description:"Multi-model coding agent supporting 20+ providers including local models",status:"coming-soon",enabled:!1})]})]})}function eYe({open:e,onOpenChange:t,onResetComplete:n}){const[s,r]=x.useState(""),[a,o]=x.useState(!1),l=Fe(),c=s==="reset";async function u(){o(!0);try{await l.resetAllData("reset"),localStorage.clear(),t(!1),n()}catch(h){rt.error(h instanceof Error?h.message:"Failed to reset data")}finally{o(!1)}}function f(h){h||(r(""),o(!1)),t(h)}return i.jsx(th,{open:e,onOpenChange:f,children:i.jsxs(Bu,{children:[i.jsxs(nh,{children:[i.jsx($u,{children:"Reset All Data"}),i.jsx(Hu,{asChild:!0,children:i.jsxs("div",{className:"space-y-3",children:[i.jsx("p",{children:"This will permanently delete all DorkOS data, including:"}),i.jsxs("ul",{className:"list-inside list-disc space-y-1 text-sm",children:[i.jsx("li",{children:"All Tasks schedules and run history"}),i.jsx("li",{children:"All Relay configuration and messages"}),i.jsx("li",{children:"All Mesh agent registry data"}),i.jsx("li",{children:"Your config file and preferences"}),i.jsx("li",{children:"All server logs"})]}),i.jsx("p",{children:"The server will restart automatically. Your UI preferences will also be cleared."}),i.jsx("p",{className:"font-semibold",children:"This action cannot be undone."})]})})]}),i.jsx("div",{className:"py-2",children:i.jsx(_n,{placeholder:'Type "reset" to confirm',value:s,onChange:h=>r(h.target.value),"data-testid":"reset-confirm-input"})}),i.jsxs(sh,{children:[i.jsx(Vu,{children:"Cancel"}),i.jsx(Uu,{disabled:!c||a,onClick:u,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:a?"Resetting...":"Reset All Data"})]})]})})}function tYe({open:e,onOpenChange:t,onRestartComplete:n}){const[s,r]=x.useState(!1),a=Fe();async function o(){r(!0);try{await a.restartServer(),t(!1),n()}catch(l){rt.error(l instanceof Error?l.message:"Failed to restart server")}finally{r(!1)}}return i.jsx(th,{open:e,onOpenChange:t,children:i.jsxs(Bu,{children:[i.jsxs(nh,{children:[i.jsx($u,{children:"Restart Server"}),i.jsx(Hu,{children:"This will restart the DorkOS server. All active sessions will be interrupted."})]}),i.jsxs(sh,{children:[i.jsx(Vu,{children:"Cancel"}),i.jsx(Uu,{disabled:s,onClick:o,children:s?"Restarting...":"Restart Server"})]})]})})}const nYe=["fatal","error","warn","info","debug","trace"];function sYe(){const[e,t]=x.useState(!1),[n,s]=x.useState(!1),r=je(m=>m.enableMessagePolling),a=je(m=>m.setEnableMessagePolling),o=je(m=>m.setRestartOverlayOpen),l=Fe(),c=Ct(),{data:u}=mt({queryKey:["config"],queryFn:()=>l.getConfig(),staleTime:3e4}),f=u==null?void 0:u.logging,h=x.useCallback(async m=>{const g=f??{level:"info",maxLogSizeKb:500,maxLogFiles:14};await l.updateConfig({logging:{...g,...m}}),await c.invalidateQueries({queryKey:["config"]})},[l,c,f]);return i.jsxs("div",{className:"space-y-6",children:[i.jsx("h3",{className:"text-sm font-semibold",children:"Background Updates"}),i.jsx("p",{className:"text-muted-foreground text-xs",children:"Messages stream in live and stay in sync across windows automatically. This optional setting adds an extra polling fallback for sessions running outside DorkOS."}),i.jsx(Sa,{children:i.jsx(Wr,{children:i.jsx(gi,{label:"Background refresh",description:"Poll for updates to sessions running outside DorkOS (e.g. the Claude Code CLI). Enable only if external activity isn't appearing promptly.",checked:r,onCheckedChange:a})})}),f&&i.jsxs(i.Fragment,{children:[i.jsx("h3",{className:"text-sm font-semibold",children:"Logging"}),i.jsx("p",{className:"text-muted-foreground text-xs",children:"Server log verbosity and rotation. Changes take effect immediately for log level; rotation settings apply on next file rotation."}),i.jsx(Sa,{children:i.jsxs(Wr,{children:[i.jsx(os,{label:"Log level",description:"Server log verbosity",children:i.jsxs(Bn,{value:f.level,onValueChange:m=>h({level:m}),children:[i.jsx(Dn,{className:"w-28",children:i.jsx($n,{})}),i.jsx(On,{children:nYe.map(m=>i.jsx(yt,{value:m,children:m},m))})]})}),i.jsx(os,{label:"Max log file size",description:"Size in KB before a log file is rotated",children:i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx(_n,{type:"number",min:100,max:10240,value:f.maxLogSizeKb,onChange:m=>{const g=parseInt(m.target.value,10);g>=100&&g<=10240&&h({maxLogSizeKb:g})},className:"w-24"}),i.jsx("span",{className:"text-muted-foreground text-xs",children:"KB"})]})}),i.jsx(os,{label:"Rotated files kept",description:"Number of old log files to retain (1-30)",children:i.jsx(_n,{type:"number",min:1,max:30,value:f.maxLogFiles,onChange:m=>{const g=parseInt(m.target.value,10);g>=1&&g<=30&&h({maxLogFiles:g})},className:"w-20"})}),(u==null?void 0:u.dorkHome)&&i.jsx(rYe,{dorkHome:u.dorkHome})]})})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Yr,{className:"text-destructive size-4"}),i.jsx("h3",{className:"text-destructive text-sm font-semibold",children:"Danger Zone"})]}),i.jsx(Sa,{className:"border-destructive/50",children:i.jsxs(Wr,{children:[i.jsxs("div",{className:"flex items-center justify-between gap-4",children:[i.jsxs("div",{className:"min-w-0",children:[i.jsx("p",{className:"text-sm font-medium",children:"Reset All Data"}),i.jsx("p",{className:"text-muted-foreground text-xs",children:"Permanently delete all DorkOS data and restart the server."})]}),i.jsx(ve,{variant:"destructive",size:"sm",onClick:()=>t(!0),children:"Reset"})]}),i.jsxs("div",{className:"flex items-center justify-between gap-4",children:[i.jsxs("div",{className:"min-w-0",children:[i.jsx("p",{className:"text-sm font-medium",children:"Restart Server"}),i.jsx("p",{className:"text-muted-foreground text-xs",children:"Restart the DorkOS server process. Active sessions will be interrupted."})]}),i.jsx(ve,{variant:"destructive",size:"sm",onClick:()=>s(!0),children:"Restart"})]})]})}),i.jsx(eYe,{open:e,onOpenChange:t,onResetComplete:()=>o(!0)}),i.jsx(tYe,{open:n,onOpenChange:s,onRestartComplete:()=>o(!0)})]})}function rYe({dorkHome:e}){const[t,n]=x.useState(!1),s=`${e}/logs`;function r(){navigator.clipboard.writeText(s).then(()=>{n(!0),setTimeout(()=>n(!1),Yi.COPY_FEEDBACK_MS)})}return i.jsx(os,{label:"Log location",description:"Directory where server log files are stored",children:i.jsx("button",{type:"button",onClick:r,className:"text-muted-foreground hover:text-foreground flex items-center gap-1.5 transition-colors",children:t?i.jsx("span",{className:"text-xs",children:"Copied"}):i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"max-w-40 truncate font-mono text-xs",dir:"rtl",title:s,children:s}),i.jsx(Gf,{className:"size-3 shrink-0"})]})})})}function aYe({onClick:e}){return Zs()?i.jsxs(oe.button,{onClick:e,whileTap:{scale:.98},transition:{type:"spring",stiffness:400,damping:30},className:X("flex w-full items-center gap-3 px-4 py-3 text-left text-sm transition-colors","hover:bg-muted/50 active:bg-muted min-h-[44px]"),children:[i.jsx(pu,{className:"text-muted-foreground size-(--size-icon-sm) shrink-0"}),i.jsx("span",{className:"flex-1",children:"Remote Access"}),i.jsx(Ws,{className:"text-muted-foreground/40 size-(--size-icon-sm) shrink-0"})]}):i.jsx("button",{onClick:e,className:"text-muted-foreground hover:text-foreground hover:bg-muted/50 relative mx-2 flex w-[calc(100%-1rem)] items-center gap-2 rounded-md px-2.5 py-1.5 text-left text-sm transition-colors duration-150",children:i.jsxs("span",{className:"relative z-10 flex items-center gap-2",children:[i.jsx(pu,{className:"size-(--size-icon-sm) shrink-0"}),"Remote Access"]})})}const iYe=15e3,oYe=3e4,lYe=3e4;function cYe(e,t,n){return!e&&!t?"landing":!e&&t||t?"setup":n==="error"?"error":n==="starting"?"connecting":n==="connected"||n==="stopping"?"connected":"ready"}function uYe({open:e}){const t=Fe(),{data:n}=mt({queryKey:["config"],queryFn:()=>t.getConfig(),staleTime:300*1e3}),s=n==null?void 0:n.tunnel,[r,a]=x.useState("off"),[o,l]=x.useState(null),[c,u]=x.useState(null),[f,h]=x.useState(!1),[m,g]=x.useState(""),[b,v]=x.useState(null),[k,w]=x.useState(!1),[C,E]=x.useState(""),[T,_]=x.useState(null),[j,R]=x.useState(!1),[D,I]=x.useState(""),O=x.useRef(void 0);x.useEffect(()=>{s!=null&&s.connected&&(s!=null&&s.url)?(a("connected"),l(s.url)):r!=="starting"&&r!=="stopping"&&(a("off"),l(null))},[s==null?void 0:s.connected,s==null?void 0:s.url,r]),x.useEffect(()=>{s!=null&&s.domain&&E(s.domain)},[s==null?void 0:s.domain]),x.useEffect(()=>{(s==null?void 0:s.passcodeEnabled)!==void 0&&R(s.passcodeEnabled)},[s==null?void 0:s.passcodeEnabled]),x.useEffect(()=>{s!=null&&s.tokenConfigured&&h(!1)},[s==null?void 0:s.tokenConfigured]),x.useEffect(()=>{const U=O.current,$=(s==null?void 0:s.connected)??!1;O.current=$,U!==void 0&&(U&&!$?rt.error("Remote access disconnected",{id:"tunnel-status",description:"Attempting to reconnect..."}):!U&&$&&(s!=null&&s.url)&&rt.success("Remote access reconnected",{id:"tunnel-status",description:s.url}))},[s==null?void 0:s.connected,s==null?void 0:s.url]),x.useEffect(()=>{if(r!=="starting"&&r!=="stopping")return;const U=setTimeout(()=>{r==="starting"?(a("error"),u("Connection timed out. Please try again.")):r==="stopping"&&(a("off"),l(null))},oYe);return()=>clearTimeout(U)},[r]),x.useEffect(()=>{if(r!=="connected"||!o||!e){_(null);return}const U=async()=>{try{const q=performance.now();await fetch(`${o}/api/health`,{mode:"cors",cache:"no-store"}),_(Math.round(performance.now()-q))}catch{_(null)}};U();const $=setInterval(U,lYe);return()=>clearInterval($)},[r,o,e]);const L=!!(s!=null&&s.tokenConfigured),B=cYe(L,f,r);return{state:r,setState:a,url:o,setUrl:l,error:c,setError:u,showSetup:f,setShowSetup:h,authToken:m,setAuthToken:g,tokenError:b,setTokenError:v,showTokenInput:k,setShowTokenInput:w,domain:C,setDomain:E,latencyMs:T,passcodeEnabled:j,setPasscodeEnabled:R,passcodeInput:D,setPasscodeInput:I,tunnel:s,tokenConfigured:L,viewState:B,isTransitioning:r==="starting"||r==="stopping",isChecked:r==="connected"||r==="starting"||r==="stopping"}}function dYe(){const e=Fe();return mt({queryKey:["tunnel-status"],queryFn:async()=>(await e.getConfig()).tunnel,refetchInterval:3e4,refetchIntervalInBackground:!1})}const fYe="dorkos-tunnel";function k1(){const e=uxe(fYe);e.postMessage({type:"tunnel_changed"}),e.close()}function hYe({machine:e,transport:t,queryClient:n}){const s=x.useCallback(async c=>{if(c){e.setState("starting"),e.setError(null);const u=setTimeout(()=>{e.setState("error"),e.setError("Connection timed out after 15 seconds")},iYe);try{const f=await t.startTunnel();clearTimeout(u),e.setState("connected"),e.setUrl(f.url),n.invalidateQueries({queryKey:["config"]}),k1()}catch(f){clearTimeout(u),e.setState("error"),e.setError(f instanceof Error?f.message:"Failed to start tunnel")}}else{e.setState("stopping"),e.setError(null);try{await t.stopTunnel(),e.setState("off"),e.setUrl(null),n.invalidateQueries({queryKey:["config"]}),k1()}catch(u){e.setState("connected"),e.setError(u instanceof Error?u.message:"Failed to stop tunnel")}}},[e,t,n]),r=x.useCallback(async()=>{e.setTokenError(null);try{await t.updateConfig({tunnel:{authtoken:e.authToken}}),e.setAuthToken(""),e.setShowTokenInput(!1),e.setShowSetup(!1),n.invalidateQueries({queryKey:["config"]})}catch{e.setTokenError("Could not save token. Try again.")}},[e,n,t]),a=x.useCallback(async()=>{try{await t.updateConfig({tunnel:{domain:e.domain.trim()||null}}),n.invalidateQueries({queryKey:["config"]})}catch{}},[e,n,t]),o=x.useCallback(async c=>{if(c)e.setPasscodeEnabled(!0);else try{await t.setTunnelPasscode({enabled:!1}),e.setPasscodeEnabled(!1),e.setPasscodeInput(""),n.invalidateQueries({queryKey:["config"]}),k1()}catch{rt.error("Failed to disable passcode")}},[e,t,n]),l=x.useCallback(async()=>{try{await t.setTunnelPasscode({passcode:e.passcodeInput,enabled:!0}),e.setPasscodeInput(""),n.invalidateQueries({queryKey:["config"]}),k1()}catch{rt.error("Failed to save passcode")}},[e,n,t]);return{handleToggle:s,handleSaveToken:r,handleSaveDomain:a,handlePasscodeToggle:o,handleSavePasscode:l}}function pYe(){return i.jsxs("svg",{viewBox:"0 0 240 120",className:"mx-auto h-24 w-48","aria-hidden":"true",children:[i.jsx("rect",{x:"80",y:"30",width:"80",height:"50",rx:"4",className:"fill-none stroke-current",strokeWidth:"2"}),i.jsx("rect",{x:"70",y:"80",width:"100",height:"6",rx:"2",className:"fill-current opacity-30"}),i.jsx("rect",{x:"90",y:"42",width:"20",height:"2",rx:"1",className:"fill-current opacity-40"}),i.jsx("rect",{x:"90",y:"48",width:"40",height:"2",rx:"1",className:"fill-current opacity-20"}),i.jsx("rect",{x:"90",y:"54",width:"30",height:"2",rx:"1",className:"fill-current opacity-20"}),i.jsx("rect",{x:"195",y:"35",width:"28",height:"45",rx:"4",className:"fill-none stroke-current",strokeWidth:"1.5"}),i.jsx("circle",{cx:"209",cy:"73",r:"2",className:"fill-current opacity-30"}),i.jsx("rect",{x:"10",y:"30",width:"40",height:"55",rx:"4",className:"fill-none stroke-current",strokeWidth:"1.5"}),i.jsx("circle",{cx:"30",cy:"78",r:"2",className:"fill-current opacity-30"}),i.jsx("line",{x1:"160",y1:"55",x2:"195",y2:"55",className:"stroke-current opacity-40",strokeWidth:"1.5",strokeDasharray:"4 3"}),i.jsx("line",{x1:"80",y1:"55",x2:"50",y2:"55",className:"stroke-current opacity-40",strokeWidth:"1.5",strokeDasharray:"4 3"})]})}function mYe(){return i.jsxs("div",{className:"space-y-3",children:[i.jsx(pYe,{}),i.jsx("p",{className:"text-foreground text-center text-sm font-medium",children:"Access DorkOS from any device"})]})}function gYe({onGetStarted:e}){return i.jsxs("div",{"data-testid":"tunnel-landing",className:"space-y-6 py-2",children:[i.jsx(mYe,{}),i.jsxs("div",{className:"text-center",children:[i.jsx("p",{className:"text-foreground text-sm font-medium",children:"Access DorkOS from any device"}),i.jsx("p",{className:"text-muted-foreground mx-auto mt-1 max-w-[280px] text-xs leading-relaxed",children:"Create a secure tunnel to access your sessions from your phone, tablet, or any browser."})]}),i.jsx(ve,{onClick:e,className:"w-full transition-transform duration-100 hover:scale-[1.01] active:scale-[0.98]",children:"Get started"}),i.jsx("p",{className:"text-muted-foreground/60 text-center text-xs",children:"Requires a free ngrok account"})]})}const xYe={initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0}},yYe={duration:.2,ease:[0,0,.2,1]};function bYe({authToken:e,tokenError:t,onAuthTokenChange:n,onSaveToken:s}){return i.jsxs("div",{"data-testid":"tunnel-setup",className:"space-y-4",children:[i.jsxs(Wa,{"data-invalid":t?!0:void 0,children:[i.jsx(Ya,{htmlFor:"tunnel-auth-token",className:"text-xs font-medium",children:"ngrok auth token"}),i.jsx(_n,{id:"tunnel-auth-token",type:"password",placeholder:"Paste your ngrok auth token",value:e,onChange:r=>n(r.target.value),onKeyDown:r=>{r.key==="Enter"&&e.trim()&&s()},className:"text-sm"}),i.jsx(He,{children:t&&i.jsx(oe.div,{variants:xYe,initial:"initial",animate:"animate",exit:"exit",transition:yYe,className:"overflow-hidden",children:i.jsx(Oo,{children:t})},"token-error")})]}),i.jsx(ve,{size:"sm",className:"w-full",disabled:!e.trim(),onClick:()=>void s(),children:"Save token"}),i.jsxs("p",{className:"text-muted-foreground text-xs",children:["Don't have a token?"," ",i.jsxs("a",{href:"https://dashboard.ngrok.com/signup",target:"_blank",rel:"noopener noreferrer",className:"text-foreground group inline-flex items-center gap-0.5 underline underline-offset-2",children:["Sign up for ngrok",i.jsx(V1,{className:"size-3 transition-transform duration-100 group-hover:-translate-x-0.5"})]})," ","— free tier is sufficient."]})]})}const vYe={initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0}},SYe={duration:.2,ease:[0,0,.2,1]},wYe={collapsed:{rotate:0},expanded:{rotate:90}},kYe={duration:.15,ease:"easeInOut"};function h7({active:e,label:t}){return i.jsxs("span",{className:X("flex items-center gap-1 text-xs",e?"text-muted-foreground":"text-muted-foreground/50"),children:[e?i.jsx(Zt,{className:"size-3 text-green-500"}):i.jsx("span",{className:"text-muted-foreground/40",children:"○"}),t]})}function CYe({authToken:e,tokenError:t,showTokenInput:n,onAuthTokenChange:s,onSaveToken:r,onShowTokenInput:a,domain:o,onDomainChange:l,onDomainSave:c}){const[u,f]=x.useState(!1),h=m=>{m.key==="Enter"&&c()};return i.jsxs("div",{"data-testid":"tunnel-settings",children:[i.jsxs("button",{type:"button",onClick:()=>f(m=>!m),className:"hover:text-foreground text-muted-foreground flex w-full items-center gap-1.5 py-1 text-xs transition-colors",children:[i.jsx(oe.span,{variants:wYe,animate:u?"expanded":"collapsed",transition:kYe,className:"inline-flex origin-center","aria-hidden":!0,children:i.jsx(Ws,{className:"size-3.5"})}),i.jsx("span",{className:"font-medium",children:"Settings"})]}),!u&&i.jsxs("div",{className:"mt-1.5 flex gap-3 pl-5",children:[i.jsx(h7,{active:!0,label:"Token"}),i.jsx(h7,{active:!!o.trim(),label:o.trim()||"No domain"})]}),i.jsx(He,{initial:!1,children:u&&i.jsx(oe.div,{variants:vYe,initial:"initial",animate:"animate",exit:"exit",transition:SYe,className:"overflow-hidden",children:i.jsxs("div",{className:"space-y-4 pt-3",children:[i.jsx("div",{className:"space-y-2",children:n?i.jsxs(Wa,{children:[i.jsx(Ya,{className:"text-sm",children:"Auth token"}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(_n,{type:"password",value:e,onChange:m=>s(m.target.value),placeholder:"Paste ngrok auth token",className:"flex-1","aria-label":"Auth token"}),i.jsx(ve,{type:"button",size:"sm",onClick:r,disabled:!e.trim(),children:"Save"})]}),t&&i.jsx(Oo,{children:t})]}):i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"space-y-0.5",children:[i.jsx("p",{className:"text-sm font-medium",children:"Auth token"}),i.jsx("p",{className:"text-muted-foreground text-xs",children:"Token saved"})]}),i.jsx(ve,{type:"button",variant:"outline",size:"sm",onClick:a,children:"Change"})]})}),i.jsxs(Wa,{children:[i.jsx(Ya,{className:"text-sm",children:"Custom domain"}),i.jsx(_n,{type:"text",value:o,onChange:m=>l(m.target.value),onBlur:c,onKeyDown:h,placeholder:"your-domain.ngrok.app","aria-label":"Custom domain"}),i.jsx(Ei,{className:"text-xs",children:"Leave blank to use a randomly assigned ngrok URL."})]})]})},"settings-panel")})]})}const dS=[0,500,1200],p7=[{label:"Initialising ngrok agent",thresholdMs:dS[0]},{label:"Opening secure tunnel",thresholdMs:dS[1]},{label:"Registering public URL",thresholdMs:dS[2]}],EYe={hidden:{},show:{transition:{staggerChildren:.15}}},TYe={hidden:{opacity:0,y:8},show:{opacity:1,y:0,transition:{type:"spring",stiffness:320,damping:28}}},_Ye={initial:{scale:.5,opacity:0},animate:{scale:1,opacity:1}},NYe={type:"spring",stiffness:400,damping:30};function jYe(){const[e,t]=x.useState(0);return x.useEffect(()=>{const n=Date.now(),s=dS.map(r=>setTimeout(()=>{t(Date.now()-n)},r));return()=>{s.forEach(clearTimeout)}},[]),i.jsx(oe.div,{className:"space-y-3 py-2","data-testid":"tunnel-connecting",variants:EYe,initial:"hidden",animate:"show",children:p7.map((n,s)=>{var c;const r=e>=n.thresholdMs,a=((c=p7[s+1])==null?void 0:c.thresholdMs)??1/0,o=e>=a,l=r&&!o;return i.jsxs(oe.div,{variants:TYe,className:X("flex items-center gap-3 text-sm transition-opacity duration-300",r?"opacity-100":"opacity-0"),children:[i.jsx("span",{className:"flex size-4 shrink-0 items-center justify-center",children:i.jsx(He,{mode:"wait",children:o?i.jsx(oe.span,{variants:_Ye,initial:"initial",animate:"animate",exit:{scale:.5,opacity:0},transition:NYe,className:"inline-flex",children:i.jsx(Zt,{className:"text-muted-foreground size-4"})},"check"):l?i.jsx(oe.span,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:"inline-flex",children:i.jsx(Xn,{className:"text-muted-foreground size-4 animate-spin"})},"spinner"):null})}),i.jsx("span",{className:X("transition-colors duration-200",o?"text-muted-foreground":"text-foreground"),children:n.label})]},n.label)})})}var dp={},RN={exports:{}},MN,m7;function AYe(){if(m7)return MN;m7=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return MN=e,MN}var DN,g7;function RYe(){if(g7)return DN;g7=1;var e=AYe();function t(){}function n(){}return n.resetWarningCache=t,DN=function(){function s(o,l,c,u,f,h){if(h!==e){var m=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw m.name="Invariant Violation",m}}s.isRequired=s;function r(){return s}var a={array:s,bigint:s,bool:s,func:s,number:s,object:s,string:s,symbol:s,any:s,arrayOf:r,element:s,elementType:s,instanceOf:r,node:s,objectOf:r,oneOf:r,oneOfType:r,shape:r,exact:r,checkPropTypes:n,resetWarningCache:t};return a.PropTypes=a,a},DN}var x7;function pO(){return x7||(x7=1,RN.exports=RYe()()),RN.exports}var ON,y7;function yae(){return y7||(y7=1,ON={L:1,M:0,Q:3,H:2}),ON}var IN,b7;function bae(){return b7||(b7=1,IN={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8}),IN}var PN,v7;function MYe(){if(v7)return PN;v7=1;var e=bae();function t(n){this.mode=e.MODE_8BIT_BYTE,this.data=n}return t.prototype={getLength:function(n){return this.data.length},write:function(n){for(var s=0;s<this.data.length;s++)n.put(this.data.charCodeAt(s),8)}},PN=t,PN}var LN,S7;function DYe(){if(S7)return LN;S7=1;var e=yae();function t(n,s){this.totalCount=n,this.dataCount=s}return t.RS_BLOCK_TABLE=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],t.getRSBlocks=function(n,s){var r=t.getRsBlockTable(n,s);if(r==null)throw new Error("bad rs block @ typeNumber:"+n+"/errorCorrectLevel:"+s);for(var a=r.length/3,o=new Array,l=0;l<a;l++)for(var c=r[l*3+0],u=r[l*3+1],f=r[l*3+2],h=0;h<c;h++)o.push(new t(u,f));return o},t.getRsBlockTable=function(n,s){switch(s){case e.L:return t.RS_BLOCK_TABLE[(n-1)*4+0];case e.M:return t.RS_BLOCK_TABLE[(n-1)*4+1];case e.Q:return t.RS_BLOCK_TABLE[(n-1)*4+2];case e.H:return t.RS_BLOCK_TABLE[(n-1)*4+3];default:return}},LN=t,LN}var FN,w7;function OYe(){if(w7)return FN;w7=1;function e(){this.buffer=new Array,this.length=0}return e.prototype={get:function(t){var n=Math.floor(t/8);return(this.buffer[n]>>>7-t%8&1)==1},put:function(t,n){for(var s=0;s<n;s++)this.putBit((t>>>n-s-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(t){var n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),t&&(this.buffer[n]|=128>>>this.length%8),this.length++}},FN=e,FN}var zN,k7;function vae(){if(k7)return zN;k7=1;for(var e={glog:function(n){if(n<1)throw new Error("glog("+n+")");return e.LOG_TABLE[n]},gexp:function(n){for(;n<0;)n+=255;for(;n>=256;)n-=255;return e.EXP_TABLE[n]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)},t=0;t<8;t++)e.EXP_TABLE[t]=1<<t;for(var t=8;t<256;t++)e.EXP_TABLE[t]=e.EXP_TABLE[t-4]^e.EXP_TABLE[t-5]^e.EXP_TABLE[t-6]^e.EXP_TABLE[t-8];for(var t=0;t<255;t++)e.LOG_TABLE[e.EXP_TABLE[t]]=t;return zN=e,zN}var BN,C7;function Sae(){if(C7)return BN;C7=1;var e=vae();function t(n,s){if(n.length==null)throw new Error(n.length+"/"+s);for(var r=0;r<n.length&&n[r]==0;)r++;this.num=new Array(n.length-r+s);for(var a=0;a<n.length-r;a++)this.num[a]=n[a+r]}return t.prototype={get:function(n){return this.num[n]},getLength:function(){return this.num.length},multiply:function(n){for(var s=new Array(this.getLength()+n.getLength()-1),r=0;r<this.getLength();r++)for(var a=0;a<n.getLength();a++)s[r+a]^=e.gexp(e.glog(this.get(r))+e.glog(n.get(a)));return new t(s,0)},mod:function(n){if(this.getLength()-n.getLength()<0)return this;for(var s=e.glog(this.get(0))-e.glog(n.get(0)),r=new Array(this.getLength()),a=0;a<this.getLength();a++)r[a]=this.get(a);for(var a=0;a<n.getLength();a++)r[a]^=e.gexp(e.glog(n.get(a))+s);return new t(r,0).mod(n)}},BN=t,BN}var $N,E7;function IYe(){if(E7)return $N;E7=1;var e=bae(),t=Sae(),n=vae(),s={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},r={PATTERN_POSITION_TABLE:[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],G15:1335,G18:7973,G15_MASK:21522,getBCHTypeInfo:function(a){for(var o=a<<10;r.getBCHDigit(o)-r.getBCHDigit(r.G15)>=0;)o^=r.G15<<r.getBCHDigit(o)-r.getBCHDigit(r.G15);return(a<<10|o)^r.G15_MASK},getBCHTypeNumber:function(a){for(var o=a<<12;r.getBCHDigit(o)-r.getBCHDigit(r.G18)>=0;)o^=r.G18<<r.getBCHDigit(o)-r.getBCHDigit(r.G18);return a<<12|o},getBCHDigit:function(a){for(var o=0;a!=0;)o++,a>>>=1;return o},getPatternPosition:function(a){return r.PATTERN_POSITION_TABLE[a-1]},getMask:function(a,o,l){switch(a){case s.PATTERN000:return(o+l)%2==0;case s.PATTERN001:return o%2==0;case s.PATTERN010:return l%3==0;case s.PATTERN011:return(o+l)%3==0;case s.PATTERN100:return(Math.floor(o/2)+Math.floor(l/3))%2==0;case s.PATTERN101:return o*l%2+o*l%3==0;case s.PATTERN110:return(o*l%2+o*l%3)%2==0;case s.PATTERN111:return(o*l%3+(o+l)%2)%2==0;default:throw new Error("bad maskPattern:"+a)}},getErrorCorrectPolynomial:function(a){for(var o=new t([1],0),l=0;l<a;l++)o=o.multiply(new t([1,n.gexp(l)],0));return o},getLengthInBits:function(a,o){if(1<=o&&o<10)switch(a){case e.MODE_NUMBER:return 10;case e.MODE_ALPHA_NUM:return 9;case e.MODE_8BIT_BYTE:return 8;case e.MODE_KANJI:return 8;default:throw new Error("mode:"+a)}else if(o<27)switch(a){case e.MODE_NUMBER:return 12;case e.MODE_ALPHA_NUM:return 11;case e.MODE_8BIT_BYTE:return 16;case e.MODE_KANJI:return 10;default:throw new Error("mode:"+a)}else if(o<41)switch(a){case e.MODE_NUMBER:return 14;case e.MODE_ALPHA_NUM:return 13;case e.MODE_8BIT_BYTE:return 16;case e.MODE_KANJI:return 12;default:throw new Error("mode:"+a)}else throw new Error("type:"+o)},getLostPoint:function(a){for(var o=a.getModuleCount(),l=0,c=0;c<o;c++)for(var u=0;u<o;u++){for(var f=0,h=a.isDark(c,u),m=-1;m<=1;m++)if(!(c+m<0||o<=c+m))for(var g=-1;g<=1;g++)u+g<0||o<=u+g||m==0&&g==0||h==a.isDark(c+m,u+g)&&f++;f>5&&(l+=3+f-5)}for(var c=0;c<o-1;c++)for(var u=0;u<o-1;u++){var b=0;a.isDark(c,u)&&b++,a.isDark(c+1,u)&&b++,a.isDark(c,u+1)&&b++,a.isDark(c+1,u+1)&&b++,(b==0||b==4)&&(l+=3)}for(var c=0;c<o;c++)for(var u=0;u<o-6;u++)a.isDark(c,u)&&!a.isDark(c,u+1)&&a.isDark(c,u+2)&&a.isDark(c,u+3)&&a.isDark(c,u+4)&&!a.isDark(c,u+5)&&a.isDark(c,u+6)&&(l+=40);for(var u=0;u<o;u++)for(var c=0;c<o-6;c++)a.isDark(c,u)&&!a.isDark(c+1,u)&&a.isDark(c+2,u)&&a.isDark(c+3,u)&&a.isDark(c+4,u)&&!a.isDark(c+5,u)&&a.isDark(c+6,u)&&(l+=40);for(var v=0,u=0;u<o;u++)for(var c=0;c<o;c++)a.isDark(c,u)&&v++;var k=Math.abs(100*v/o/o-50)/5;return l+=k*10,l}};return $N=r,$N}var HN,T7;function PYe(){if(T7)return HN;T7=1;var e=MYe(),t=DYe(),n=OYe(),s=IYe(),r=Sae();function a(l,c){this.typeNumber=l,this.errorCorrectLevel=c,this.modules=null,this.moduleCount=0,this.dataCache=null,this.dataList=[]}var o=a.prototype;return o.addData=function(l){var c=new e(l);this.dataList.push(c),this.dataCache=null},o.isDark=function(l,c){if(l<0||this.moduleCount<=l||c<0||this.moduleCount<=c)throw new Error(l+","+c);return this.modules[l][c]},o.getModuleCount=function(){return this.moduleCount},o.make=function(){if(this.typeNumber<1){var l=1;for(l=1;l<40;l++){for(var c=t.getRSBlocks(l,this.errorCorrectLevel),u=new n,f=0,h=0;h<c.length;h++)f+=c[h].dataCount;for(var h=0;h<this.dataList.length;h++){var m=this.dataList[h];u.put(m.mode,4),u.put(m.getLength(),s.getLengthInBits(m.mode,l)),m.write(u)}if(u.getLengthInBits()<=f*8)break}this.typeNumber=l}this.makeImpl(!1,this.getBestMaskPattern())},o.makeImpl=function(l,c){this.moduleCount=this.typeNumber*4+17,this.modules=new Array(this.moduleCount);for(var u=0;u<this.moduleCount;u++){this.modules[u]=new Array(this.moduleCount);for(var f=0;f<this.moduleCount;f++)this.modules[u][f]=null}this.setupPositionProbePattern(0,0),this.setupPositionProbePattern(this.moduleCount-7,0),this.setupPositionProbePattern(0,this.moduleCount-7),this.setupPositionAdjustPattern(),this.setupTimingPattern(),this.setupTypeInfo(l,c),this.typeNumber>=7&&this.setupTypeNumber(l),this.dataCache==null&&(this.dataCache=a.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,c)},o.setupPositionProbePattern=function(l,c){for(var u=-1;u<=7;u++)if(!(l+u<=-1||this.moduleCount<=l+u))for(var f=-1;f<=7;f++)c+f<=-1||this.moduleCount<=c+f||(0<=u&&u<=6&&(f==0||f==6)||0<=f&&f<=6&&(u==0||u==6)||2<=u&&u<=4&&2<=f&&f<=4?this.modules[l+u][c+f]=!0:this.modules[l+u][c+f]=!1)},o.getBestMaskPattern=function(){for(var l=0,c=0,u=0;u<8;u++){this.makeImpl(!0,u);var f=s.getLostPoint(this);(u==0||l>f)&&(l=f,c=u)}return c},o.createMovieClip=function(l,c,u){var f=l.createEmptyMovieClip(c,u),h=1;this.make();for(var m=0;m<this.modules.length;m++)for(var g=m*h,b=0;b<this.modules[m].length;b++){var v=b*h,k=this.modules[m][b];k&&(f.beginFill(0,100),f.moveTo(v,g),f.lineTo(v+h,g),f.lineTo(v+h,g+h),f.lineTo(v,g+h),f.endFill())}return f},o.setupTimingPattern=function(){for(var l=8;l<this.moduleCount-8;l++)this.modules[l][6]==null&&(this.modules[l][6]=l%2==0);for(var c=8;c<this.moduleCount-8;c++)this.modules[6][c]==null&&(this.modules[6][c]=c%2==0)},o.setupPositionAdjustPattern=function(){for(var l=s.getPatternPosition(this.typeNumber),c=0;c<l.length;c++)for(var u=0;u<l.length;u++){var f=l[c],h=l[u];if(this.modules[f][h]==null)for(var m=-2;m<=2;m++)for(var g=-2;g<=2;g++)m==-2||m==2||g==-2||g==2||m==0&&g==0?this.modules[f+m][h+g]=!0:this.modules[f+m][h+g]=!1}},o.setupTypeNumber=function(l){for(var c=s.getBCHTypeNumber(this.typeNumber),u=0;u<18;u++){var f=!l&&(c>>u&1)==1;this.modules[Math.floor(u/3)][u%3+this.moduleCount-8-3]=f}for(var u=0;u<18;u++){var f=!l&&(c>>u&1)==1;this.modules[u%3+this.moduleCount-8-3][Math.floor(u/3)]=f}},o.setupTypeInfo=function(l,c){for(var u=this.errorCorrectLevel<<3|c,f=s.getBCHTypeInfo(u),h=0;h<15;h++){var m=!l&&(f>>h&1)==1;h<6?this.modules[h][8]=m:h<8?this.modules[h+1][8]=m:this.modules[this.moduleCount-15+h][8]=m}for(var h=0;h<15;h++){var m=!l&&(f>>h&1)==1;h<8?this.modules[8][this.moduleCount-h-1]=m:h<9?this.modules[8][15-h-1+1]=m:this.modules[8][15-h-1]=m}this.modules[this.moduleCount-8][8]=!l},o.mapData=function(l,c){for(var u=-1,f=this.moduleCount-1,h=7,m=0,g=this.moduleCount-1;g>0;g-=2)for(g==6&&g--;;){for(var b=0;b<2;b++)if(this.modules[f][g-b]==null){var v=!1;m<l.length&&(v=(l[m]>>>h&1)==1);var k=s.getMask(c,f,g-b);k&&(v=!v),this.modules[f][g-b]=v,h--,h==-1&&(m++,h=7)}if(f+=u,f<0||this.moduleCount<=f){f-=u,u=-u;break}}},a.PAD0=236,a.PAD1=17,a.createData=function(l,c,u){for(var f=t.getRSBlocks(l,c),h=new n,m=0;m<u.length;m++){var g=u[m];h.put(g.mode,4),h.put(g.getLength(),s.getLengthInBits(g.mode,l)),g.write(h)}for(var b=0,m=0;m<f.length;m++)b+=f[m].dataCount;if(h.getLengthInBits()>b*8)throw new Error("code length overflow. ("+h.getLengthInBits()+">"+b*8+")");for(h.getLengthInBits()+4<=b*8&&h.put(0,4);h.getLengthInBits()%8!=0;)h.putBit(!1);for(;!(h.getLengthInBits()>=b*8||(h.put(a.PAD0,8),h.getLengthInBits()>=b*8));)h.put(a.PAD1,8);return a.createBytes(h,f)},a.createBytes=function(l,c){for(var u=0,f=0,h=0,m=new Array(c.length),g=new Array(c.length),b=0;b<c.length;b++){var v=c[b].dataCount,k=c[b].totalCount-v;f=Math.max(f,v),h=Math.max(h,k),m[b]=new Array(v);for(var w=0;w<m[b].length;w++)m[b][w]=255&l.buffer[w+u];u+=v;var C=s.getErrorCorrectPolynomial(k),E=new r(m[b],C.getLength()-1),T=E.mod(C);g[b]=new Array(C.getLength()-1);for(var w=0;w<g[b].length;w++){var _=w+T.getLength()-g[b].length;g[b][w]=_>=0?T.get(_):0}}for(var j=0,w=0;w<c.length;w++)j+=c[w].totalCount;for(var R=new Array(j),D=0,w=0;w<f;w++)for(var b=0;b<c.length;b++)w<m[b].length&&(R[D++]=m[b][w]);for(var w=0;w<h;w++)for(var b=0;b<c.length;b++)w<g[b].length&&(R[D++]=g[b][w]);return R},HN=a,HN}var C1={},_7;function LYe(){if(_7)return C1;_7=1,Object.defineProperty(C1,"__esModule",{value:!0});var e=Object.assign||function(u){for(var f=1;f<arguments.length;f++){var h=arguments[f];for(var m in h)Object.prototype.hasOwnProperty.call(h,m)&&(u[m]=h[m])}return u},t=pO(),n=a(t),s=_u(),r=a(s);function a(u){return u&&u.__esModule?u:{default:u}}function o(u,f){var h={};for(var m in u)f.indexOf(m)>=0||Object.prototype.hasOwnProperty.call(u,m)&&(h[m]=u[m]);return h}var l={bgColor:n.default.oneOfType([n.default.object,n.default.string]).isRequired,bgD:n.default.string.isRequired,fgColor:n.default.oneOfType([n.default.object,n.default.string]).isRequired,fgD:n.default.string.isRequired,size:n.default.number.isRequired,title:n.default.string,viewBoxSize:n.default.number.isRequired,xmlns:n.default.string},c=(0,s.forwardRef)(function(u,f){var h=u.bgColor,m=u.bgD,g=u.fgD,b=u.fgColor,v=u.size,k=u.title,w=u.viewBoxSize,C=u.xmlns,E=C===void 0?"http://www.w3.org/2000/svg":C,T=o(u,["bgColor","bgD","fgD","fgColor","size","title","viewBoxSize","xmlns"]);return r.default.createElement("svg",e({},T,{height:v,ref:f,viewBox:"0 0 "+w+" "+w,width:v,xmlns:E}),k?r.default.createElement("title",null,k):null,r.default.createElement("path",{d:m,fill:h}),r.default.createElement("path",{d:g,fill:b}))});return c.displayName="QRCodeSvg",c.propTypes=l,C1.default=c,C1}var N7;function FYe(){if(N7)return dp;N7=1,Object.defineProperty(dp,"__esModule",{value:!0}),dp.QRCode=void 0;var e=Object.assign||function(v){for(var k=1;k<arguments.length;k++){var w=arguments[k];for(var C in w)Object.prototype.hasOwnProperty.call(w,C)&&(v[C]=w[C])}return v},t=pO(),n=h(t),s=yae(),r=h(s),a=PYe(),o=h(a),l=_u(),c=h(l),u=LYe(),f=h(u);function h(v){return v&&v.__esModule?v:{default:v}}function m(v,k){var w={};for(var C in v)k.indexOf(C)>=0||Object.prototype.hasOwnProperty.call(v,C)&&(w[C]=v[C]);return w}var g={bgColor:n.default.oneOfType([n.default.object,n.default.string]),fgColor:n.default.oneOfType([n.default.object,n.default.string]),level:n.default.string,size:n.default.number,value:n.default.string.isRequired},b=(0,l.forwardRef)(function(v,k){var w=v.bgColor,C=w===void 0?"#FFFFFF":w,E=v.fgColor,T=E===void 0?"#000000":E,_=v.level,j=_===void 0?"L":_,R=v.size,D=R===void 0?256:R,I=v.value,O=m(v,["bgColor","fgColor","level","size","value"]),L=new o.default(-1,r.default[j]);L.addData(I),L.make();var B=L.modules;return c.default.createElement(f.default,e({},O,{bgColor:C,bgD:B.map(function(H,K){return H.map(function(U,$){return U?"":"M "+$+" "+K+" l 1 0 0 1 -1 0 Z"}).join(" ")}).join(" "),fgColor:T,fgD:B.map(function(H,K){return H.map(function(U,$){return U?"M "+$+" "+K+" l 1 0 0 1 -1 0 Z":""}).join(" ")}).join(" "),ref:k,size:D,viewBoxSize:B.length}))});return dp.QRCode=b,b.displayName="QRCode",b.propTypes=g,dp.default=b,dp}var zYe=FYe();const BYe=eo(zYe);function $Ye(e){return/auth|token|ERR_NGROK_105/i.test(e)?"Check your auth token at dashboard.ngrok.com":/timeout|ETIMEDOUT/i.test(e)?"Connection timed out. Check your network.":/limit|ERR_NGROK_108/i.test(e)?"Tunnel limit reached. Free ngrok accounts allow one active tunnel.":/DNS|NXDOMAIN|ERR_NGROK_332/i.test(e)?"DNS resolution failed. Check your domain configuration.":/gateway|502|ERR_NGROK_3200/i.test(e)?"Gateway error. The tunnel endpoint is unreachable.":/upgrade|ERR_NGROK_120/i.test(e)?"Feature requires a paid ngrok plan.":/ECONNREFUSED/i.test(e)?"Connection refused. Ensure the server is running.":e}function HYe(e){return e===null?"bg-gray-400":e<200?"bg-green-500":e<500?"bg-amber-400":"bg-red-500"}const UYe={initial:{scale:.98,opacity:0},animate:{scale:1,opacity:1}},VYe={type:"spring",stiffness:400,damping:28},qYe={initial:{opacity:0},animate:{opacity:1}},GYe={duration:.3,delay:.5},KYe={initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0}},WYe={duration:.2,ease:[0,0,.2,1]};function YYe({url:e,activeSessionId:t,latencyMs:n}){const[s,r]=Bx(),[a,o]=Bx(),[l,c]=x.useState(!1),u=t?`${e}?session=${t}`:null;return i.jsxs("div",{"data-testid":"tunnel-connected",className:"space-y-3",children:[i.jsxs(oe.div,{className:"bg-muted/30 rounded-lg border border-green-500/20 p-3",variants:UYe,initial:"initial",animate:"animate",transition:VYe,children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:X("inline-block size-1.5 shrink-0 rounded-full",HYe(n)),"aria-label":n!==null?`${n}ms latency`:"Latency unknown"}),i.jsx("span",{className:"text-foreground min-w-0 flex-1 truncate font-mono text-xs",children:e.replace(/^https?:\/\//,"")}),i.jsx(He,{children:n!==null&&i.jsxs(oe.span,{className:"text-muted-foreground shrink-0 text-xs",variants:qYe,initial:"initial",animate:"animate",transition:GYe,children:[n,"ms"]})})]}),i.jsxs("div",{className:"mt-3 flex gap-2",children:[i.jsxs(ve,{variant:"outline",size:"sm",className:"flex-1 gap-1.5",onClick:()=>r(e),children:[s?i.jsx(Zt,{className:"size-3"}):i.jsx(Gf,{className:"size-3"}),s?"Copied":"Copy URL"]}),u&&i.jsxs(ve,{variant:"outline",size:"sm",className:"flex-1 gap-1.5",onClick:()=>o(u),children:[a?i.jsx(Zt,{className:"size-3"}):i.jsx(eTe,{className:"size-3"}),a?"Copied":"Session link"]}),i.jsx(ve,{variant:"outline",size:"sm",onClick:()=>c(f=>!f),"aria-label":"Toggle QR code",className:X(l&&"bg-accent"),children:i.jsx(WTe,{className:"size-3.5"})})]})]}),i.jsx(He,{children:l&&i.jsxs(oe.div,{variants:KYe,initial:"initial",animate:"animate",exit:"exit",transition:WYe,className:"overflow-hidden",children:[i.jsx("div",{className:"flex justify-center rounded-lg bg-white p-4",children:i.jsx(BYe,{value:e,size:180,level:"M"})}),i.jsx("p",{className:"text-muted-foreground mt-2 text-center text-xs",children:"Scan from any device"})]},"qr-expand")})]})}const ZYe={initial:{x:0},animate:{x:[0,-2,2,-1,0]}},XYe={duration:.35,ease:"easeInOut"};function QYe({error:e,onRetry:t}){const n=$Ye(e);return i.jsx(oe.div,{"data-testid":"tunnel-error",className:"rounded-lg border border-red-200 bg-red-50 p-4 dark:border-red-800 dark:bg-red-950/30",variants:ZYe,initial:"initial",animate:"animate",transition:XYe,children:i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsx(Wk,{className:"mt-0.5 size-4 shrink-0 text-red-600 dark:text-red-400"}),i.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[i.jsx("p",{className:"text-sm font-medium text-red-800 dark:text-red-200",children:"Connection failed"}),i.jsx("p",{className:"text-xs text-red-700 dark:text-red-300",children:n}),i.jsxs(ve,{variant:"outline",size:"sm",onClick:t,className:"border-red-300 text-red-700 hover:bg-red-100 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-900/50",children:[i.jsx(mu,{className:"mr-1.5 size-3.5"}),"Try again"]})]})]})})}var JYe=Object.defineProperty,eZe=Object.defineProperties,tZe=Object.getOwnPropertyDescriptors,Aw=Object.getOwnPropertySymbols,wae=Object.prototype.hasOwnProperty,kae=Object.prototype.propertyIsEnumerable,j7=(e,t,n)=>t in e?JYe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,nZe=(e,t)=>{for(var n in t||(t={}))wae.call(t,n)&&j7(e,n,t[n]);if(Aw)for(var n of Aw(t))kae.call(t,n)&&j7(e,n,t[n]);return e},sZe=(e,t)=>eZe(e,tZe(t)),rZe=(e,t)=>{var n={};for(var s in e)wae.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&Aw)for(var s of Aw(e))t.indexOf(s)<0&&kae.call(e,s)&&(n[s]=e[s]);return n};function aZe(e){let t=setTimeout(e,0),n=setTimeout(e,10),s=setTimeout(e,50);return[t,n,s]}function iZe(e){let t=x.useRef();return x.useEffect(()=>{t.current=e}),t.current}var oZe=18,Cae=40,lZe=`${Cae}px`,cZe=["[data-lastpass-icon-root]","com-1password-button","[data-dashlanecreated]",'[style$="2147483647 !important;"]'].join(",");function uZe({containerRef:e,inputRef:t,pushPasswordManagerStrategy:n,isFocused:s}){let[r,a]=x.useState(!1),[o,l]=x.useState(!1),[c,u]=x.useState(!1),f=x.useMemo(()=>n==="none"?!1:(n==="increase-width"||n==="experimental-no-flickering")&&r&&o,[r,o,n]),h=x.useCallback(()=>{let m=e.current,g=t.current;if(!m||!g||c||n==="none")return;let b=m,v=b.getBoundingClientRect().left+b.offsetWidth,k=b.getBoundingClientRect().top+b.offsetHeight/2,w=v-oZe,C=k;document.querySelectorAll(cZe).length===0&&document.elementFromPoint(w,C)===m||(a(!0),u(!0))},[e,t,c,n]);return x.useEffect(()=>{let m=e.current;if(!m||n==="none")return;function g(){let v=window.innerWidth-m.getBoundingClientRect().right;l(v>=Cae)}g();let b=setInterval(g,1e3);return()=>{clearInterval(b)}},[e,n]),x.useEffect(()=>{let m=s||document.activeElement===t.current;if(n==="none"||!m)return;let g=setTimeout(h,0),b=setTimeout(h,2e3),v=setTimeout(h,5e3),k=setTimeout(()=>{u(!0)},6e3);return()=>{clearTimeout(g),clearTimeout(b),clearTimeout(v),clearTimeout(k)}},[t,s,n,h]),{hasPWMBadge:r,willPushPWMBadge:f,PWM_BADGE_SPACE_WIDTH:lZe}}var Eae=x.createContext({}),Tae=x.forwardRef((e,t)=>{var n=e,{value:s,onChange:r,maxLength:a,textAlign:o="left",pattern:l,placeholder:c,inputMode:u="numeric",onComplete:f,pushPasswordManagerStrategy:h="increase-width",pasteTransformer:m,containerClassName:g,noScriptCSSFallback:b=dZe,render:v,children:k}=n,w=rZe(n,["value","onChange","maxLength","textAlign","pattern","placeholder","inputMode","onComplete","pushPasswordManagerStrategy","pasteTransformer","containerClassName","noScriptCSSFallback","render","children"]),C,E,T,_,j;let[R,D]=x.useState(typeof w.defaultValue=="string"?w.defaultValue:""),I=s??R,O=iZe(I),L=x.useCallback(Se=>{r==null||r(Se),D(Se)},[r]),B=x.useMemo(()=>l?typeof l=="string"?new RegExp(l):l:null,[l]),H=x.useRef(null),K=x.useRef(null),U=x.useRef({value:I,onChange:L,isIOS:typeof window<"u"&&((E=(C=window==null?void 0:window.CSS)==null?void 0:C.supports)==null?void 0:E.call(C,"-webkit-touch-callout","none"))}),$=x.useRef({prev:[(T=H.current)==null?void 0:T.selectionStart,(_=H.current)==null?void 0:_.selectionEnd,(j=H.current)==null?void 0:j.selectionDirection]});x.useImperativeHandle(t,()=>H.current,[]),x.useEffect(()=>{let Se=H.current,Ze=K.current;if(!Se||!Ze)return;U.current.value!==Se.value&&U.current.onChange(Se.value),$.current.prev=[Se.selectionStart,Se.selectionEnd,Se.selectionDirection];function bt(){if(document.activeElement!==Se){G(null),Z(null);return}let Te=Se.selectionStart,Je=Se.selectionEnd,_t=Se.selectionDirection,St=Se.maxLength,Gt=Se.value,Kt=$.current.prev,Ae=-1,ce=-1,Ee;if(Gt.length!==0&&Te!==null&&Je!==null){let nn=Te===Je,Cn=Te===Gt.length&&Gt.length<St;if(nn&&!Cn){let yn=Te;if(yn===0)Ae=0,ce=1,Ee="forward";else if(yn===St)Ae=yn-1,ce=yn,Ee="backward";else if(St>1&&Gt.length>1){let En=0;if(Kt[0]!==null&&Kt[1]!==null){Ee=yn<Kt[1]?"backward":"forward";let Qn=Kt[0]===Kt[1]&&Kt[0]<St;Ee==="backward"&&!Qn&&(En=-1)}Ae=En+yn,ce=En+yn+1}}Ae!==-1&&ce!==-1&&Ae!==ce&&H.current.setSelectionRange(Ae,ce,Ee)}let Ye=Ae!==-1?Ae:Te,Ge=ce!==-1?ce:Je,et=Ee??_t;G(Ye),Z(Ge),$.current.prev=[Ye,Ge,et]}if(document.addEventListener("selectionchange",bt,{capture:!0}),bt(),document.activeElement===Se&&F(!0),!document.getElementById("input-otp-style")){let Te=document.createElement("style");if(Te.id="input-otp-style",document.head.appendChild(Te),Te.sheet){let Je="background: transparent !important; color: transparent !important; border-color: transparent !important; opacity: 0 !important; box-shadow: none !important; -webkit-box-shadow: none !important; -webkit-text-fill-color: transparent !important;";O0(Te.sheet,"[data-input-otp]::selection { background: transparent !important; color: transparent !important; }"),O0(Te.sheet,`[data-input-otp]:autofill { ${Je} }`),O0(Te.sheet,`[data-input-otp]:-webkit-autofill { ${Je} }`),O0(Te.sheet,"@supports (-webkit-touch-callout: none) { [data-input-otp] { letter-spacing: -.6em !important; font-weight: 100 !important; font-stretch: ultra-condensed; font-optical-sizing: none !important; left: -1px !important; right: 1px !important; } }"),O0(Te.sheet,"[data-input-otp] + * { pointer-events: all !important; }")}}let Me=()=>{Ze&&Ze.style.setProperty("--root-height",`${Se.clientHeight}px`)};Me();let Ie=new ResizeObserver(Me);return Ie.observe(Se),()=>{document.removeEventListener("selectionchange",bt,{capture:!0}),Ie.disconnect()}},[]);let[q,J]=x.useState(!1),[ne,F]=x.useState(!1),[V,G]=x.useState(null),[P,Z]=x.useState(null);x.useEffect(()=>{aZe(()=>{var Se,Ze,bt,Me;(Se=H.current)==null||Se.dispatchEvent(new Event("input"));let Ie=(Ze=H.current)==null?void 0:Ze.selectionStart,Te=(bt=H.current)==null?void 0:bt.selectionEnd,Je=(Me=H.current)==null?void 0:Me.selectionDirection;Ie!==null&&Te!==null&&(G(Ie),Z(Te),$.current.prev=[Ie,Te,Je])})},[I,ne]),x.useEffect(()=>{O!==void 0&&I!==O&&O.length<a&&I.length===a&&(f==null||f(I))},[a,f,O,I]);let Q=uZe({containerRef:K,inputRef:H,pushPasswordManagerStrategy:h,isFocused:ne}),re=x.useCallback(Se=>{let Ze=Se.currentTarget.value.slice(0,a);if(Ze.length>0&&B&&!B.test(Ze)){Se.preventDefault();return}typeof O=="string"&&Ze.length<O.length&&document.dispatchEvent(new Event("selectionchange")),L(Ze)},[a,L,O,B]),ae=x.useCallback(()=>{var Se;if(H.current){let Ze=Math.min(H.current.value.length,a-1),bt=H.current.value.length;(Se=H.current)==null||Se.setSelectionRange(Ze,bt),G(Ze),Z(bt)}F(!0)},[a]),de=x.useCallback(Se=>{var Ze,bt;let Me=H.current;if(!m&&(!U.current.isIOS||!Se.clipboardData||!Me))return;let Ie=Se.clipboardData.getData("text/plain"),Te=m?m(Ie):Ie;Se.preventDefault();let Je=(Ze=H.current)==null?void 0:Ze.selectionStart,_t=(bt=H.current)==null?void 0:bt.selectionEnd,St=(Je!==_t?I.slice(0,Je)+Te+I.slice(_t):I.slice(0,Je)+Te+I.slice(Je)).slice(0,a);if(St.length>0&&B&&!B.test(St))return;Me.value=St,L(St);let Gt=Math.min(St.length,a-1),Kt=St.length;Me.setSelectionRange(Gt,Kt),G(Gt),Z(Kt)},[a,L,B,I]),pe=x.useMemo(()=>({position:"relative",cursor:w.disabled?"default":"text",userSelect:"none",WebkitUserSelect:"none",pointerEvents:"none"}),[w.disabled]),Oe=x.useMemo(()=>({position:"absolute",inset:0,width:Q.willPushPWMBadge?`calc(100% + ${Q.PWM_BADGE_SPACE_WIDTH})`:"100%",clipPath:Q.willPushPWMBadge?`inset(0 ${Q.PWM_BADGE_SPACE_WIDTH} 0 0)`:void 0,height:"100%",display:"flex",textAlign:o,opacity:"1",color:"transparent",pointerEvents:"all",background:"transparent",caretColor:"transparent",border:"0 solid transparent",outline:"0 solid transparent",boxShadow:"none",lineHeight:"1",letterSpacing:"-.5em",fontSize:"var(--root-height)",fontFamily:"monospace",fontVariantNumeric:"tabular-nums"}),[Q.PWM_BADGE_SPACE_WIDTH,Q.willPushPWMBadge,o]),Ve=x.useMemo(()=>x.createElement("input",sZe(nZe({autoComplete:w.autoComplete||"one-time-code"},w),{"data-input-otp":!0,"data-input-otp-placeholder-shown":I.length===0||void 0,"data-input-otp-mss":V,"data-input-otp-mse":P,inputMode:u,pattern:B==null?void 0:B.source,"aria-placeholder":c,style:Oe,maxLength:a,value:I,ref:H,onPaste:Se=>{var Ze;de(Se),(Ze=w.onPaste)==null||Ze.call(w,Se)},onChange:re,onMouseOver:Se=>{var Ze;J(!0),(Ze=w.onMouseOver)==null||Ze.call(w,Se)},onMouseLeave:Se=>{var Ze;J(!1),(Ze=w.onMouseLeave)==null||Ze.call(w,Se)},onFocus:Se=>{var Ze;ae(),(Ze=w.onFocus)==null||Ze.call(w,Se)},onBlur:Se=>{var Ze;F(!1),(Ze=w.onBlur)==null||Ze.call(w,Se)}})),[re,ae,de,u,Oe,a,P,V,w,B==null?void 0:B.source,I]),$e=x.useMemo(()=>({slots:Array.from({length:a}).map((Se,Ze)=>{var bt;let Me=ne&&V!==null&&P!==null&&(V===P&&Ze===V||Ze>=V&&Ze<P),Ie=I[Ze]!==void 0?I[Ze]:null,Te=I[0]!==void 0?null:(bt=c==null?void 0:c[Ze])!=null?bt:null;return{char:Ie,placeholderChar:Te,isActive:Me,hasFakeCaret:Me&&Ie===null}}),isFocused:ne,isHovering:!w.disabled&&q}),[ne,q,a,P,V,w.disabled,I]),Qe=x.useMemo(()=>v?v($e):x.createElement(Eae.Provider,{value:$e},k),[k,$e,v]);return x.createElement(x.Fragment,null,b!==null&&x.createElement("noscript",null,x.createElement("style",null,b)),x.createElement("div",{ref:K,"data-input-otp-container":!0,style:pe,className:g},Qe,x.createElement("div",{style:{position:"absolute",inset:0,pointerEvents:"none"}},Ve)))});Tae.displayName="Input";function O0(e,t){try{e.insertRule(t)}catch{console.error("input-otp could not insert CSS rule:",t)}}var dZe=`
|
|
1043
|
+
`)[0]??"";return n.length>t?`${n.slice(0,t)}…`:n}function GR(e){return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",hour12:!0})}function VVe({status:e}){switch(e){case"running":return i.jsx("span",{title:"Running","aria-label":"Running",children:i.jsx(Xn,{className:"size-3.5 animate-spin text-blue-500"})});case"completed":return i.jsx("span",{title:"Completed","aria-label":"Completed",children:i.jsx(qf,{className:"size-3.5 text-green-500"})});case"failed":return i.jsx("span",{title:"Failed","aria-label":"Failed",children:i.jsx(Vm,{className:"text-destructive size-3.5"})});case"cancelled":return i.jsx("span",{title:"Cancelled","aria-label":"Cancelled",children:i.jsx(kX,{className:"text-muted-foreground size-3.5"})});default:return null}}function qVe({trigger:e}){return e==="scheduled"?i.jsx(Ja,{className:"text-muted-foreground/70 mr-1 inline size-3 shrink-0","aria-hidden":"true"}):e==="manual"?i.jsx(q1,{className:"text-muted-foreground/70 mr-1 inline size-3 shrink-0","aria-hidden":"true"}):null}function GVe({date:e}){const t=new Date,n=new Date(e),s=new Date(t);s.setDate(s.getDate()-7);const r=n>=s,a=r?uu(e):GR(e),o=r?GR(e):uu(e);return i.jsx("time",{dateTime:e,title:o,children:a})}function mN(){return i.jsxs("div",{className:"grid grid-cols-[20px_56px_1fr_64px_72px_20px] items-center gap-2 rounded-md px-2 py-2",children:[i.jsx(on,{className:"size-3.5 rounded-full"}),i.jsx(on,{className:"h-3 w-10"}),i.jsx(on,{className:"h-3 w-24"}),i.jsx(on,{className:"h-3 w-8"}),i.jsx("span",{}),i.jsx("span",{})]})}function KVe({run:e,onNavigate:t,onCancel:n,isCancelling:s}){const r=!!e.sessionId;function a(){e.sessionId&&t(e.sessionId)}function o(c){c.stopPropagation(),n(e.id)}const l=e.startedAt?GR(e.startedAt):"unknown time";return i.jsxs("div",{role:r?"button":void 0,tabIndex:r?0:void 0,"aria-label":r?`View ${e.status} run from ${l}`:void 0,onClick:r?a:void 0,onKeyDown:r?c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),a())}:void 0,className:X("grid grid-cols-[20px_56px_1fr_64px_72px_20px] items-center gap-2","rounded-md border border-transparent px-2 py-2 text-xs transition-colors",r&&["hover:bg-muted/50 hover:border-border cursor-pointer","focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:outline-none"],e.status==="failed"&&"bg-destructive/5"),children:[i.jsx(VVe,{status:e.status}),i.jsxs("span",{className:"text-muted-foreground truncate capitalize",children:[i.jsx(qVe,{trigger:e.trigger}),e.trigger]}),i.jsxs("span",{className:"flex min-w-0 flex-col gap-0.5",children:[i.jsx("span",{className:"text-foreground",children:e.startedAt?i.jsx(GVe,{date:e.startedAt}):"-"}),e.outputSummary&&i.jsx("span",{className:"text-muted-foreground truncate",title:e.outputSummary,children:AB(e.outputSummary)}),e.status==="failed"&&e.error&&i.jsx("span",{className:"text-destructive truncate",title:e.error,children:AB(e.error)})]}),i.jsx("span",{className:"text-muted-foreground",children:UVe(e.durationMs)}),i.jsx("span",{children:e.status==="running"&&i.jsx("button",{type:"button",disabled:s,onClick:o,className:X("inline-flex items-center rounded px-1.5 py-0.5 text-xs font-medium","text-muted-foreground transition-colors","hover:bg-accent hover:text-accent-foreground","focus-visible:ring-ring focus-visible:ring-2 focus-visible:outline-none","disabled:pointer-events-none disabled:opacity-50"),children:"Cancel"})}),i.jsx("span",{className:"flex items-center justify-end",children:r&&i.jsx(Ws,{className:"text-muted-foreground/50 size-3.5","aria-hidden":"true"})})]})}const gN=20;function WVe({scheduleId:e,scheduleCwd:t}){const[n,s]=x.useState("all"),[r,a]=x.useState(0),[o,l]=x.useState([]),c=n==="all"?void 0:n,{data:u=[],isLoading:f}=fg({scheduleId:e,status:c,limit:gN,offset:r}),h=dre(),[,m]=Jf(),[g,b]=eh(),v=x.useMemo(()=>r===0?u:[...o,...u],[r,u,o]),k=x.useCallback(()=>{l(v),a(E=>E+gN)},[v]),w=x.useCallback(E=>{s(E),a(0),l([])},[]),C=x.useCallback(E=>{t&&t!==g&&b(t,{preserveSession:!0}),m(E)},[t,g,b,m]);return f&&v.length===0?i.jsxs("div",{className:"space-y-0.5","aria-label":"Loading runs...",children:[i.jsx(mN,{}),i.jsx(mN,{}),i.jsx(mN,{})]}):v.length===0&&!f?i.jsxs("div",{className:"space-y-2",children:[i.jsx(RB,{value:n,onChange:w}),i.jsx("p",{className:"text-muted-foreground py-4 text-center text-xs",children:n==="all"?"No runs yet":`No ${n} runs`})]}):i.jsxs("div",{className:"space-y-0.5",children:[i.jsx(RB,{value:n,onChange:w}),i.jsxs("div",{className:"sm:text-muted-foreground hidden sm:grid sm:grid-cols-[20px_56px_1fr_64px_72px_20px] sm:gap-2 sm:px-2 sm:pb-1 sm:text-xs sm:font-medium",children:[i.jsx("span",{}),i.jsx("span",{children:"Trigger"}),i.jsx("span",{children:"Started"}),i.jsx("span",{children:"Duration"}),i.jsx("span",{}),i.jsx("span",{})]}),v.map(E=>i.jsx(KVe,{run:E,onNavigate:C,onCancel:T=>h.mutate(T,{onSuccess:()=>rt("Run cancelled"),onError:_=>rt.error(`Failed to cancel: ${_ instanceof Error?_.message:"Unknown error"}`)}),isCancelling:h.isPending},E.id)),u.length===gN&&i.jsx("button",{type:"button",onClick:k,disabled:f,className:"text-muted-foreground hover:bg-muted/50 hover:text-foreground mt-1 w-full rounded-md py-1.5 text-xs transition-colors disabled:opacity-50",children:f?"Loading...":"Load more"})]})}function RB({value:e,onChange:t}){return i.jsx("div",{className:"mb-1 flex items-center gap-2",children:i.jsxs(Bn,{value:e,onValueChange:t,children:[i.jsx(Dn,{responsive:!1,className:"h-7 w-[130px] text-xs",children:i.jsx($n,{placeholder:"Filter status"})}),i.jsxs(On,{children:[i.jsx(yt,{value:"all",children:"All"}),i.jsx(yt,{value:"running",children:"Running"}),i.jsx(yt,{value:"completed",children:"Completed"}),i.jsx(yt,{value:"failed",children:"Failed"}),i.jsx(yt,{value:"cancelled",children:"Cancelled"})]})]})})}function YVe(e){try{return wre.toString(e)}catch{return e}}function ZVe({task:e}){const t=e.status==="pending_approval"?"bg-yellow-500":e.enabled?"bg-green-500":"bg-neutral-400";return i.jsx("span",{className:X("inline-block size-2 rounded-full",t)})}function _re({task:e,agent:t,expanded:n,onToggleExpand:s,onEdit:r,size:a="default",showAgent:o=!0}){const l=J5(),c=ZUe(),u=ure(),[f,h]=x.useState(!1),m=t?Lu(t):null,g=a==="minimal",b=a==="compact",v=a==="default",k=o&&!g,w=!g,C=v,E=(t==null?void 0:t.isSystem)===!0,T=D=>{D.stopPropagation(),c.mutate(e.id,{onSuccess:()=>rt("Run triggered"),onError:I=>rt.error(`Failed to trigger run: ${I.message}`)})},_=D=>{D.stopPropagation(),l.mutate({id:e.id,status:"active",enabled:!0},{onSuccess:()=>rt("Schedule approved"),onError:I=>rt.error(`Failed to approve: ${I.message}`)})},j=D=>{D.stopPropagation(),u.mutate(e.id,{onError:I=>rt.error(`Failed to reject: ${I.message}`)})},R=()=>{u.mutate(e.id,{onSuccess:()=>h(!1),onError:D=>rt.error(`Failed to delete: ${D.message}`)})};return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"rounded-lg border",children:[i.jsxs("div",{role:"button",tabIndex:0,className:"flex cursor-pointer items-center gap-3 p-3",onClick:s,onKeyDown:D=>(D.key==="Enter"||D.key===" ")&&s(),children:[i.jsx(ZVe,{task:e}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsxs("div",{className:"flex items-center gap-1.5",children:[k&&t?i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"inline-block size-2 shrink-0 rounded-full",style:{backgroundColor:m.color}}),i.jsx("span",{className:"text-xs leading-none",children:m.emoji}),i.jsx("span",{className:"text-sm font-medium",children:tn(t)}),E&&i.jsxs(Ot,{variant:"outline",className:"px-1 py-0 text-[10px] leading-tight",children:[i.jsx(Ho,{className:"mr-0.5 size-2.5"}),"System"]}),i.jsx("span",{className:"text-muted-foreground text-xs",children:"·"})]}):k&&e.agentId?i.jsxs(i.Fragment,{children:[i.jsx(Wk,{className:"text-destructive size-3.5 shrink-0"}),i.jsx("span",{className:"text-destructive text-xs",children:"Agent not found"}),i.jsx("span",{className:"text-muted-foreground text-xs",children:"·"})]}):null,i.jsx("span",{className:k&&(t||e.agentId)?"text-muted-foreground text-xs":"text-sm font-medium",children:e.displayName??e.name})]}),w&&i.jsxs("div",{className:"text-muted-foreground text-xs",children:[e.cron?YVe(e.cron):"On-demand",e.nextRun&&i.jsxs(i.Fragment,{children:[" · Next: ",new Date(e.nextRun).toLocaleString()]})]})]}),!g&&e.status==="pending_approval"?i.jsxs("div",{className:"flex gap-1",children:[i.jsx("button",{className:"border-input hover:bg-accent hover:text-accent-foreground inline-flex items-center rounded-md border bg-transparent px-2.5 py-1 text-xs font-medium shadow-sm transition-colors",onClick:_,children:"Approve"}),i.jsx("button",{className:"hover:bg-accent hover:text-accent-foreground inline-flex items-center rounded-md px-2.5 py-1 text-xs font-medium transition-colors",onClick:j,children:"Reject"})]}):b?i.jsxs("button",{className:"border-input hover:bg-accent hover:text-accent-foreground inline-flex items-center gap-1 rounded-md border bg-transparent px-2 py-1 text-xs font-medium shadow-sm transition-colors",onClick:T,"aria-label":`Run ${e.name}`,children:[i.jsx(q1,{className:"size-3"}),"Run"]}):v?i.jsxs("div",{className:"flex items-center gap-2",children:[e.cron?i.jsx(Ks,{checked:e.enabled,onCheckedChange:D=>{l.mutate({id:e.id,enabled:D})},onClick:D=>D.stopPropagation(),"aria-label":`Toggle ${e.name}`}):i.jsxs("button",{className:"border-input hover:bg-accent hover:text-accent-foreground inline-flex items-center gap-1 rounded-md border bg-transparent px-2 py-1 text-xs font-medium shadow-sm transition-colors",onClick:T,"aria-label":`Run ${e.name}`,children:[i.jsx(q1,{className:"size-3"}),"Run"]}),i.jsxs(Xm,{children:[i.jsx(Qm,{asChild:!0,children:i.jsx("button",{className:"text-muted-foreground hover:text-foreground rounded-md p-1 transition-colors","aria-label":`Actions for ${e.name}`,onClick:D=>D.stopPropagation(),children:i.jsx(TX,{className:"size-4"})})}),i.jsxs(lh,{align:"end",children:[i.jsxs(Nr,{onClick:()=>r(),children:[i.jsx(J3,{className:"mr-2 size-3.5"}),"Edit"]}),i.jsxs(Nr,{onClick:T,disabled:!e.enabled,children:[i.jsx(q1,{className:"mr-2 size-3.5"}),"Run Now"]}),i.jsx(df,{}),i.jsxs(Nr,{onClick:D=>{D.stopPropagation(),h(!0)},className:"text-destructive focus:text-destructive",children:[i.jsx(Yf,{className:"mr-2 size-3.5"}),"Delete"]})]})]})]}):null]}),i.jsx(He,{initial:!1,children:n&&C&&i.jsx(oe.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.3,ease:[.4,0,.2,1]},className:"overflow-hidden",children:i.jsxs("div",{className:"border-t px-3 pt-2 pb-3",children:[e.filePath&&i.jsx("p",{className:"text-muted-foreground mb-2 truncate font-mono text-[11px]",children:Pl(e.filePath)}),i.jsx(WVe,{scheduleId:e.id,scheduleCwd:null})]})})})]}),v&&i.jsx(ah,{open:f,onOpenChange:h,children:i.jsxs(Gu,{children:[i.jsxs(Ku,{children:[i.jsx(Wu,{children:"Delete task"}),i.jsxs(Yu,{children:["Delete “",e.name,"”? This will also remove all run history. This action cannot be undone."]})]}),i.jsxs(Zm,{children:[i.jsx("button",{onClick:()=>h(!1),className:"border-input hover:bg-accent hover:text-accent-foreground inline-flex items-center rounded-md border bg-transparent px-3 py-1.5 text-sm font-medium shadow-sm transition-colors",children:"Cancel"}),i.jsx("button",{onClick:R,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90 inline-flex items-center rounded-md px-3 py-1.5 text-sm font-medium shadow-sm transition-colors",children:"Delete"})]})]})})]})}function XVe(){const e=td(),{data:t=[],isLoading:n}=XC(e),[s,r]=x.useState(!1),[a,o]=x.useState(),[l,c]=x.useState(null),[u,f]=x.useState(null),h=je(D=>D.tasksAgentFilter),m=je(D=>D.setTasksAgentFilter),g=je(D=>D.tasksEditScheduleId),b=je(D=>D.setTasksEditScheduleId),v=h?t.filter(D=>D.agentId===h):t,k=t.some(D=>D.agentId),{data:w}=ji(void 0,k),C=x.useMemo(()=>{const D=new Map;for(const I of(w==null?void 0:w.agents)??[])D.set(I.id,I);return D},[w]);x.useEffect(()=>{if(!g||n)return;const D=t.find(I=>I.id===g);D&&(o(D),r(!0)),b(null)},[g,t,n,b]);const E=x.useMemo(()=>{var D;return h?((D=C.get(h))==null?void 0:D.name)??h:null},[h,C]),{externalTrigger:T}=ub();x.useEffect(()=>{T&&(o(void 0),r(!0))},[T]);const _=D=>{f(D),o(void 0),r(!0)},j=()=>{f(null),o(void 0),r(!0)},R=D=>{r(D),D||f(null)};return e?n?i.jsx("div",{className:"space-y-2 p-4",children:[1,2,3].map(D=>i.jsx("div",{className:"rounded-lg border p-3",children:i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"bg-muted animate-tasks size-2 rounded-full"}),i.jsxs("div",{className:"flex-1 space-y-1.5",children:[i.jsx("div",{className:"bg-muted animate-tasks h-4 w-32 rounded"}),i.jsx("div",{className:"bg-muted animate-tasks h-3 w-48 rounded"})]})]})},D))}):v.length===0?i.jsxs(i.Fragment,{children:[h?i.jsxs("div",{className:"flex flex-col items-center gap-3 p-8",children:[i.jsx(MB,{name:E,onClear:()=>m(null)}),i.jsx("p",{className:"text-muted-foreground text-sm",children:"No schedules for this agent."}),i.jsx("button",{onClick:j,className:"border-input hover:bg-accent hover:text-accent-foreground inline-flex items-center rounded-md border bg-transparent px-3 py-1.5 text-sm font-medium shadow-sm transition-colors",children:"New Schedule"})]}):i.jsx(Tre,{onCreateWithPreset:_,onCreateBlank:j}),i.jsx(qR,{open:s,onOpenChange:R,editTask:a,initialPreset:u,initialAgentId:h??void 0})]}):i.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[i.jsx("div",{className:"space-y-2 p-4",children:i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("h3",{className:"text-muted-foreground text-sm font-medium",children:"Schedules"}),h&&i.jsx(MB,{name:E,onClear:()=>m(null)})]}),i.jsx("button",{onClick:()=>{o(void 0),r(!0)},className:"border-input hover:bg-accent hover:text-accent-foreground inline-flex items-center rounded-md border bg-transparent px-3 py-1.5 text-sm font-medium shadow-sm transition-colors",children:"New Schedule"})]})}),i.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-4 pb-4",children:i.jsx(He,{initial:!1,children:v.map(D=>i.jsx(oe.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,y:-8},transition:{duration:.2,ease:[0,0,.2,1]},className:"mb-2",children:i.jsx(_re,{task:D,agent:D.agentId?C.get(D.agentId)??null:null,expanded:l===D.id,onToggleExpand:()=>c(l===D.id?null:D.id),onEdit:()=>{o(D),r(!0)}})},D.id))})}),i.jsx(qR,{open:s,onOpenChange:r,editTask:a,initialPreset:u,initialAgentId:h??void 0})]}):i.jsx(a5,{icon:mre.tasks,name:"Tasks",description:"Tasks runs AI agent tasks on a schedule. Start DorkOS with the --tasks flag to enable it.",command:"dorkos --tasks"})}function MB({name:e,onClear:t}){return i.jsxs("span",{className:"text-muted-foreground inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-xs",children:[e??"Agent",i.jsx("button",{type:"button",onClick:t,className:"hover:text-foreground -mr-0.5 rounded-full p-0.5 transition-colors","aria-label":"Clear agent filter",children:i.jsx(ls,{className:"size-3"})})]})}const DB=WX({search:GX({fields:[e=>e.name,e=>e.description??"",e=>e.prompt]}),agent:Kp({field:e=>e.agentId,options:[],dynamic:!0,label:"Agent"}),status:Kp({field:e=>e.status==="pending_approval"?"pending_approval":e.enabled?"active":"paused",options:["active","paused","pending_approval"],multi:!0,label:"Status",labels:{active:"Active",paused:"Paused",pending_approval:"Pending Approval"},colors:{active:"text-emerald-400",paused:"text-muted-foreground",pending_approval:"text-amber-400"}}),type:Kp({field:e=>e.cron?"scheduled":"on-demand",options:["scheduled","on-demand"],label:"Type",labels:{scheduled:"Scheduled","on-demand":"On-demand"}})}),OB={name:{label:"Name",accessor:e=>e.name},lastRun:{label:"Last run",accessor:e=>e.updatedAt,direction:"desc"},nextRun:{label:"Next run",accessor:e=>e.nextRun??null},status:{label:"Status",accessor:e=>e.status==="pending_approval"?"pending_approval":e.enabled?"active":"paused"}},QVe=8,JVe={visible:{transition:{staggerChildren:.04}},hidden:{}},eqe={hidden:{opacity:0,y:8},visible:{opacity:1,y:0}};function tqe({tasks:e,isLoading:t,agentMap:n,onEditTask:s,agentId:r}){const a=eQ(DB,{debounce:{search:200}}),[o]=x.useState(0),[l,c]=x.useState(null),u=x.useMemo(()=>r?e.filter(m=>m.agentId===r):e,[e,r]),f=x.useMemo(()=>[...new Set(u.map(m=>m.agentId).filter(m=>!!m))],[u]),h=x.useMemo(()=>KX(u,DB,a.values,OB,{field:a.sortField,direction:a.sortDirection}),[u,a.values,a.sortField,a.sortDirection]);return t?i.jsx("div",{className:"space-y-3 p-4",children:Array.from({length:3}).map((m,g)=>i.jsx(on,{className:"h-14 w-full rounded-xl"},g))}):i.jsxs("div",{className:"flex h-full flex-col overflow-hidden",children:[i.jsxs(xa,{state:a,children:[i.jsx(xa.Search,{placeholder:"Filter tasks..."}),i.jsx(xa.Primary,{name:"status"}),i.jsx(xa.AddFilter,{dynamicOptions:{agent:f}}),i.jsx(xa.Sort,{options:OB}),i.jsx(xa.ResultCount,{count:h.length,total:u.length,noun:"task"}),i.jsx(xa.ActiveFilters,{})]}),i.jsx(so,{className:"min-h-0 flex-1",children:i.jsx("div",{className:"space-y-2 p-4 pt-0",children:h.length===0&&u.length>0?i.jsxs(oe.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.3,ease:"easeOut"},className:"flex flex-col items-center justify-center gap-3 py-12 text-center",children:[i.jsx(BX,{className:"text-muted-foreground/50 size-10"}),i.jsx("p",{className:"text-muted-foreground text-sm",children:a.describeActive()?`No tasks match ${a.describeActive()}`:"No tasks match your filters"}),i.jsx(ve,{variant:"outline",size:"sm",onClick:a.clearAll,children:"Clear filters"})]}):i.jsx(oe.div,{initial:"hidden",animate:"visible",variants:JVe,className:"space-y-2",children:h.map((m,g)=>i.jsx(oe.div,{variants:g<QVe?eqe:void 0,transition:{duration:.15},children:i.jsx(_re,{task:m,agent:(m.agentId?n.get(m.agentId):void 0)??null,expanded:l===m.id,onToggleExpand:()=>c(l===m.id?null:m.id),onEdit:()=>s(m)})},m.id))},o)})})]})}function nqe({totalSteps:e,currentStep:t,onBack:n,onSkip:s,onSkipAll:r}){const a=x.useId();return i.jsxs("div",{className:"grid grid-cols-3 items-center px-4 py-3 sm:px-6",children:[i.jsx(ve,{variant:"ghost",size:"sm",onClick:n,className:"justify-self-start",children:"Back"}),i.jsx("div",{className:"flex items-center justify-center gap-2",children:Array.from({length:e},(o,l)=>i.jsx("div",{className:"relative flex items-center justify-center",children:l===t?i.jsx(oe.div,{layoutId:`step-indicator-${a}`,className:"bg-primary flex h-2 w-6 items-center justify-center rounded-full",transition:{type:"spring",damping:25,stiffness:200}}):l<t?i.jsx("div",{className:"bg-primary/60 flex size-2 items-center justify-center rounded-full",children:i.jsx(Zt,{className:"text-primary-foreground size-1.5"})}):i.jsx("div",{className:X("ring-muted-foreground/30 size-2 rounded-full ring-1")})},l))}),i.jsxs("div",{className:"flex items-center justify-end gap-1",children:[i.jsx(ve,{variant:"ghost",size:"sm",onClick:s,children:"Skip"}),i.jsx(ve,{variant:"ghost",size:"sm",onClick:r,className:"text-muted-foreground",children:"Skip all"})]})]})}const sqe={default:"#1A1A1A",white:"#FFFFFF",orange:"#CE2021",current:"currentColor"};function _m({variant:e="default",size:t=40,className:n,style:s}){const r=sqe[e],a=t*(799/2325);return i.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:a,viewBox:"0 0 2325 799",fill:"none",className:n,style:s,"aria-hidden":"true",children:[i.jsx("rect",{x:"50",y:"50",width:"2225",height:"699",stroke:r,strokeWidth:"100"}),i.jsx("path",{d:"M492.333 199.627L599.833 295.627L600 295.776V491.707L492.207 599.5H199.5V199.5H492.19L492.333 199.627ZM334 347.5V448.5H435V347.5H334Z",fill:r}),i.jsx("path",{d:"M1108.5 497.715L1108.34 497.862L1001.34 599.362L1001.2 599.5H699V296.283L699.158 296.135L802.158 199.635L802.303 199.5H1108.5V497.715ZM855 347.5V448.5H956V347.5H855Z",fill:r}),i.jsx("path",{d:"M1616.94 200.24L1510.07 395.005L1616.94 598.768L1617.64 600.103L1616.28 599.451L1409 500.056L1208.22 599.448L1207.5 599.806V199.5H1617.34L1616.94 200.24ZM1332 337.5V439.207L1433.71 337.5H1332Z",fill:r}),i.jsx("path",{d:"M1716.5 599V200L1841 291.5L2125 200L2017.5 400L2125 599L1841 501L1716.5 599Z",fill:r,stroke:r})]})}const rqe=["Checking","system","requirements"],aqe=["Ready","to","go"],iqe=["Almost","there"],oqe=600,lqe=800;function cqe({onContinue:e,simulatedResult:t}){const n=Fe(),s=vr(),[r,a]=x.useState("checking"),[o,l]=x.useState(null),[c,u]=x.useState(null),[f,h]=x.useState(null),[m,g]=x.useState(0),[b,v]=x.useState(0),[k,w]=x.useState(new Set),C=x.useRef(!1),E=x.useCallback(()=>{a("checking"),l(null),u(null),v(0),w(new Set),C.current=!1,g(O=>O+1)},[]);x.useEffect(()=>{let O=!1;async function L(){const B=Date.now();let H=null,K=null;if(t)H=t;else try{H=await n.checkRequirements()}catch(q){K=q instanceof Error?q.message:"Failed to check requirements"}const U=Date.now()-B,$=3e3;U<$&&await new Promise(q=>setTimeout(q,$-U)),!O&&(K?(u(K),a("done")):(l(H),a("revealing")))}return L(),()=>{O=!0}},[n,t,m]);const T=o?Object.values(o.runtimes).flatMap(O=>O.dependencies):[],_=(o==null?void 0:o.allSatisfied)??!1,j=T.filter(O=>O.status!=="satisfied");x.useEffect(()=>{if(!(r!=="revealing"||T.length===0)&&b<T.length){const O=setTimeout(()=>v(L=>L+1),b===0?200:oqe);return()=>clearTimeout(O)}},[r,b,T.length]),x.useEffect(()=>{if(r==="revealing")for(let O=0;O<b;O++){if(k.has(O))continue;const L=setTimeout(()=>{w(B=>new Set(B).add(O))},lqe);return()=>clearTimeout(L)}},[r,b,k]),x.useEffect(()=>{if(r!=="revealing"||T.length===0||k.size<T.length)return;const O=setTimeout(()=>{a("done"),_&&!C.current&&(C.current=!0,u3())},400);return()=>clearTimeout(O)},[r,k.size,T.length,_]);const R=(O,L)=>{navigator.clipboard.writeText(L),h(O),setTimeout(()=>h(null),2e3)},D=r==="done"?_?aqe:iqe:rqe,I=r==="checking"||r==="revealing";return i.jsx(Zx,{children:i.jsxs(oe.div,{layout:!s,className:"mx-auto flex w-full max-w-md flex-col items-center px-4 text-center",transition:{layout:{duration:.4,ease:[.25,.1,.25,1]}},children:[i.jsx(oe.div,{layout:!s,className:"mb-8",initial:s?!1:{opacity:0,scale:.8},animate:{opacity:I?.6:.9,scale:1},transition:{duration:.5},children:i.jsxs(oe.div,{animate:I&&!s?{scale:[1,1.04,1],opacity:[.6,.8,.6]}:{scale:1,opacity:1},transition:I?{duration:2,repeat:1/0,ease:"easeInOut"}:{},children:[i.jsx(_m,{size:120,className:"dark:hidden"}),i.jsx(_m,{variant:"white",size:120,className:"hidden dark:block"})]})}),i.jsx(oe.div,{layout:!s,children:i.jsx(He,{mode:"wait",children:i.jsx(oe.h1,{className:"text-2xl font-semibold tracking-tight sm:text-3xl",children:s?D.join(" "):i.jsx(oe.span,{initial:"hidden",animate:"visible",exit:"exit",variants:{visible:{transition:{staggerChildren:.08}},exit:{transition:{staggerChildren:.02,staggerDirection:-1}}},children:D.map((O,L)=>i.jsxs(oe.span,{className:"inline-block",variants:{hidden:{opacity:0,filter:"blur(4px)"},visible:{opacity:1,filter:"blur(0px)"},exit:{opacity:0,filter:"blur(4px)"}},transition:{duration:.3},children:[O,L<D.length-1?" ":""]},L))})},D.join("-"))})}),i.jsx(He,{mode:"wait",children:i.jsx(oe.p,{className:"text-muted-foreground mt-3 text-sm",initial:s?!1:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.25},children:r==="checking"?"Making sure everything is in place.":r==="revealing"?"Verifying dependencies...":_?"Everything checked out perfectly.":"Some dependencies need to be installed."},r+String(_))}),i.jsxs(oe.div,{layout:!s,className:"mt-8 w-full",children:[i.jsx(He,{children:r==="checking"&&i.jsx(uqe,{},"scanning")}),i.jsx(He,{children:r==="done"&&c&&i.jsxs(oe.div,{className:"border-border bg-card rounded-xl border p-4 text-left",initial:s?!1:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.3},children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(ls,{className:"text-destructive size-4 shrink-0"}),i.jsx("span",{className:"text-sm font-medium",children:"Could not reach the server"})]}),i.jsx("p",{className:"text-muted-foreground mt-1.5 text-xs",children:c})]},"error")}),(r==="revealing"||r==="done")&&!c&&i.jsx("div",{className:"space-y-3",children:T.map((O,L)=>{if(L>=b)return null;const B=k.has(L);return i.jsx(dqe,{dep:O,isResolved:B,index:L},O.name)})}),i.jsx(He,{children:r==="done"&&j.length>0&&i.jsxs(oe.div,{className:"border-border bg-card mt-3 space-y-3 rounded-xl border p-4 text-left",initial:s?!1:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{delay:.15,duration:.3},children:[i.jsx("p",{className:"text-sm font-medium",children:j.length===1?"One dependency is missing":`${j.length} dependencies are missing`}),j.map(O=>i.jsxs("div",{className:"space-y-2",children:[O.installHint&&i.jsxs("div",{className:"bg-muted flex items-center justify-between gap-2 rounded-lg px-3 py-2.5",children:[i.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[i.jsx(tD,{className:"text-muted-foreground size-3.5 shrink-0"}),i.jsx("code",{className:"truncate text-xs",children:O.installHint})]}),i.jsx(ve,{variant:"ghost",size:"sm",className:"h-6 shrink-0 px-1.5",onClick:()=>R(O.name,O.installHint),children:f===O.name?i.jsx(Zt,{className:"size-3"}):i.jsx(Gf,{className:"size-3"})})]}),O.infoUrl&&i.jsxs("a",{href:O.infoUrl,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground inline-flex items-center gap-1 text-xs transition-colors",children:["Learn more ",i.jsx(bf,{className:"size-3"})]})]},O.name))]})})]}),i.jsxs(He,{mode:"wait",children:[r==="done"&&!c&&i.jsx(oe.div,{layout:!s,className:"mt-10 flex flex-col items-center gap-3",initial:s?!1:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{delay:.3,duration:.35},children:_?i.jsx(qD,{className:"px-6 py-2",duration:1.2,onClick:e,children:"Continue"}):i.jsxs(i.Fragment,{children:[i.jsxs(ve,{onClick:E,variant:"outline",className:"gap-2",children:[i.jsx(mu,{className:"size-3.5"}),"Check again"]}),i.jsx("p",{className:"text-muted-foreground text-xs",children:"Install the missing dependencies, then check again."})]})},_?"continue":"recheck"),r==="done"&&c&&i.jsx(oe.div,{layout:!s,className:"mt-10 flex flex-col items-center gap-3",initial:s?!1:{opacity:0},animate:{opacity:1},transition:{delay:.3,duration:.35},children:i.jsxs(ve,{onClick:E,variant:"outline",className:"gap-2",children:[i.jsx(mu,{className:"size-3.5"}),"Try again"]})},"error-recheck")]})]})})}function uqe(){const e=vr();return i.jsxs(oe.div,{className:"flex flex-col items-center gap-4 py-6",initial:e?!1:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.25},children:[i.jsx("div",{className:"flex items-center gap-1.5",children:[0,1,2].map(t=>i.jsx(oe.div,{className:"bg-muted-foreground/40 size-2 rounded-full",animate:e?{}:{scale:[1,1.5,1],opacity:[.3,1,.3]},transition:{duration:1.2,repeat:1/0,delay:t*.2,ease:"easeInOut"}},t))}),i.jsx("span",{className:"text-muted-foreground text-sm",children:"Scanning..."})]})}function dqe({dep:e,isResolved:t,index:n}){const s=e.status==="satisfied",r=vr();return i.jsxs(oe.div,{className:X("flex items-center gap-3 rounded-xl border px-4 py-3.5 transition-colors duration-500",t&&s&&"border-emerald-500/20 bg-emerald-500/5",t&&!s&&"border-destructive/20 bg-destructive/5",!t&&"border-border bg-card"),initial:r?!1:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{type:"spring",damping:24,stiffness:200,delay:n*.05},children:[i.jsx(He,{mode:"wait",children:t?s?i.jsx(oe.div,{className:"flex size-7 items-center justify-center rounded-full bg-emerald-500/15",initial:r?!1:{scale:0},animate:{scale:1},transition:{type:"spring",damping:10,stiffness:400},children:i.jsx(Zt,{className:"size-4 text-emerald-500"})},"pass"):i.jsx(oe.div,{className:"bg-destructive/10 flex size-7 items-center justify-center rounded-full",initial:r?!1:{scale:0},animate:{scale:1},transition:{type:"spring",damping:14,stiffness:300},children:i.jsx(ls,{className:"text-destructive size-4"})},"fail"):i.jsx(oe.div,{className:"bg-muted flex size-7 items-center justify-center rounded-full",exit:r?{}:{scale:0,opacity:0},transition:{duration:.15},children:i.jsx(oe.div,{className:"bg-muted-foreground/30 size-3 rounded-full",animate:r?{}:{opacity:[.3,.8,.3]},transition:{duration:1,repeat:1/0,ease:"easeInOut"}})},"scanning")}),i.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[i.jsx("p",{className:"text-sm font-medium",children:e.name}),i.jsx(He,{mode:"wait",children:t?i.jsx(oe.p,{className:"text-muted-foreground truncate text-xs",initial:r?!1:{opacity:0},animate:{opacity:1},transition:{duration:.3},children:s&&e.version?`v${e.version}`:e.description},"resolved"):i.jsx(oe.p,{className:"text-muted-foreground/50 text-xs",exit:{opacity:0},transition:{duration:.1},children:"Checking..."},"scanning")})]})]})}const xN=["Welcome","to","DorkOS"],fqe=[{icon:Es,label:"Create agents"},{icon:Ja,label:"Schedule tasks"},{icon:Xk,label:"Connect channels"}];function hqe({onGetStarted:e,onSkip:t}){const n=vr();return i.jsxs("div",{className:"mx-auto flex w-full max-w-md flex-col items-center px-4 text-center",children:[i.jsxs(oe.div,{className:"mb-6 opacity-80",initial:n?!1:{opacity:0,scale:.8},animate:{opacity:.8,scale:1},transition:{duration:.4},children:[i.jsx(_m,{size:150,className:"dark:hidden"}),i.jsx(_m,{variant:"white",size:150,className:"hidden dark:block"})]}),i.jsx("h1",{className:"text-3xl font-semibold tracking-tight sm:text-4xl",children:n?xN.join(" "):i.jsx(oe.span,{initial:"hidden",animate:"visible",variants:{visible:{transition:{staggerChildren:.08}}},children:xN.map((s,r)=>i.jsxs(oe.span,{className:"inline-block",variants:{hidden:{opacity:0,filter:"blur(4px)"},visible:{opacity:1,filter:"blur(0px)"}},transition:{duration:.4},children:[s,r<xN.length-1?" ":""]},r))})}),i.jsx(oe.p,{className:"text-muted-foreground mt-4",initial:n?!1:{opacity:0},animate:{opacity:1},transition:{delay:.4,duration:.5},children:"Your agents are three steps away."}),i.jsx(oe.div,{className:"mt-10 flex gap-8",initial:n?!1:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{delay:.6,duration:.4},children:fqe.map(({icon:s,label:r},a)=>i.jsxs("div",{className:"flex flex-col items-center gap-2",children:[i.jsx("div",{className:"bg-muted flex size-10 items-center justify-center rounded-lg",children:i.jsx(s,{className:"text-muted-foreground size-5"})}),i.jsx("span",{className:"text-muted-foreground text-xs",children:r})]},a))}),i.jsxs(oe.div,{className:"mt-12 flex flex-col items-center gap-3",initial:n?!1:{opacity:0},animate:{opacity:1},transition:{delay:.8,duration:.4},children:[i.jsx(qD,{className:"px-6 py-2",duration:1.2,onClick:e,children:"Get Started"}),i.jsx("button",{onClick:t,className:"text-muted-foreground hover:text-foreground text-sm transition-colors",children:"Skip setup"})]})]})}function pqe(e){const{verbosity:t}=e;return t>=4?"Hey! I'm DorkBot — your personal agent running on DorkOS. I can help with scheduling (Tasks), messaging (Relay), and discovering other agents (Mesh). What are we building today?":t<=2?"DorkBot online. I'm your default DorkOS agent. Tools available: Tasks (scheduling), Relay (messaging), Mesh (discovery). Ready for instructions.":"Hi, I'm DorkBot — your default agent in DorkOS. I have access to Tasks for scheduling, Relay for messaging, and Mesh for agent discovery. How can I help?"}const Eu=Fo()(Au(e=>({activeTab:"sessions",setActiveTab:t=>e({activeTab:t}),agentPath:null,setAgentPath:t=>e({agentPath:t}),openHub:(t,n)=>e({agentPath:t,activeTab:n??"sessions"})}),{name:"agent-hub"})),Nre=x.createContext(void 0);function ect({value:e,children:t}){return i.jsx(Nre.Provider,{value:e,children:t})}function tct(){const e=x.useContext(Nre);if(!e)throw new Error("useAgentHubContext must be used within an AgentHubProvider");return e}const jre={nebula:"#7c3aed",wisp:"#a78bfa",stroke:"#a78bfa",strokeEnd:"#c4b5fd",fill:"#7c3aed",fillEnd:"#a78bfa",glow:"#a78bfa",dot:"#c4b5fd"},Are=[{id:"balanced",name:"Balanced",emoji:"🤖",tagline:"The default. Steady, reliable, explains when it matters.",traits:{verbosity:3,autonomy:3,chaos:3,creativity:3,humor:3,spice:3},sampleResponse:"I'll handle this step by step. Let me explain my approach, then implement it. I'll check with you before making any irreversible changes.",colors:{nebula:"#7c3aed",wisp:"#a78bfa",stroke:"#a78bfa",strokeEnd:"#c4b5fd",fill:"#7c3aed",fillEnd:"#a78bfa",glow:"#a78bfa",dot:"#c4b5fd"}},{id:"hotshot",name:"The Hotshot",emoji:"🔥",tagline:"Ship fast, explain later. Turns caffeine into commits.",traits:{verbosity:2,autonomy:5,chaos:4,creativity:5,humor:3,spice:4},sampleResponse:"Done. Pushed the fix, tests pass, already moved on. Used a completely new approach btw — way cleaner.",colors:{nebula:"#ea580c",wisp:"#f97316",stroke:"#fb923c",strokeEnd:"#fbbf24",fill:"#ea580c",fillEnd:"#f59e0b",glow:"#fb923c",dot:"#fbbf24"}},{id:"sage",name:"The Sage",emoji:"🧐",tagline:"Teaches as it works. Every answer is a lesson.",traits:{verbosity:5,autonomy:2,chaos:1,creativity:3,humor:2,spice:1},sampleResponse:"This is a great learning opportunity. The issue stems from a race condition in the useEffect cleanup. Let me walk you through why this happens and three ways to fix it...",colors:{nebula:"#0ea5e9",wisp:"#06b6d4",stroke:"#22d3ee",strokeEnd:"#67e8f9",fill:"#0ea5e9",fillEnd:"#06b6d4",glow:"#22d3ee",dot:"#67e8f9"}},{id:"sentinel",name:"The Sentinel",emoji:"🛡",tagline:"Measure twice, cut once. Asks before every action.",traits:{verbosity:3,autonomy:1,chaos:1,creativity:2,humor:1,spice:2},sampleResponse:"Before I make any changes, I want to confirm: should I modify the auth middleware directly, or create a new wrapper? Both approaches have trade-offs I'd like to discuss.",colors:{nebula:"#16a34a",wisp:"#22c55e",stroke:"#4ade80",strokeEnd:"#86efac",fill:"#16a34a",fillEnd:"#10b981",glow:"#4ade80",dot:"#86efac"}},{id:"phantom",name:"The Phantom",emoji:"👻",tagline:"You'll barely know it's there. Pure silent execution.",traits:{verbosity:1,autonomy:5,chaos:3,creativity:3,humor:1,spice:3},sampleResponse:"Fixed.",colors:{nebula:"#6366f1",wisp:"#4338ca",stroke:"#818cf8",strokeEnd:"#a5b4fc",fill:"#4338ca",fillEnd:"#6366f1",glow:"#818cf8",dot:"#a5b4fc"}},{id:"mad-scientist",name:"Mad Scientist",emoji:"🎨",tagline:"Wild ideas, unexpected solutions. Thrives on chaos.",traits:{verbosity:4,autonomy:4,chaos:5,creativity:5,humor:4,spice:4},sampleResponse:"Okay hear me out — what if instead of fixing the N+1 query, we restructure the entire data layer? ngl it's kinda unhinged but it would solve three other problems too...",colors:{nebula:"#d946ef",wisp:"#a855f7",stroke:"#e879f9",strokeEnd:"#f0abfc",fill:"#d946ef",fillEnd:"#ec4899",glow:"#e879f9",dot:"#f0abfc"}},{id:"the-bro",name:"The Bro",emoji:"🤙",tagline:"Your unfiltered coding buddy. No filter, all vibes.",traits:{verbosity:4,autonomy:4,chaos:4,creativity:3,humor:4,spice:5},sampleResponse:"dude this codebase is absolutely unhinged lmao. ok I see the bug tho, gimme a sec... alright fixed that shit. whoever wrote this original code needs to be stopped fr fr",colors:{nebula:"#dc2626",wisp:"#ef4444",stroke:"#f87171",strokeEnd:"#fca5a5",fill:"#dc2626",fillEnd:"#ef4444",glow:"#f87171",dot:"#fca5a5"}},{id:"drill-sergeant",name:"Drill Sergeant",emoji:"🎖",tagline:"Terse. Efficient. Gets the job done with zero nonsense.",traits:{verbosity:2,autonomy:5,chaos:2,creativity:1,humor:1,spice:4},sampleResponse:"The bug is in line 47. Wrong comparison operator. Fixed it. Tests pass. Don't let it happen again.",colors:{nebula:"#475569",wisp:"#64748b",stroke:"#94a3b8",strokeEnd:"#cbd5e1",fill:"#334155",fillEnd:"#475569",glow:"#94a3b8",dot:"#cbd5e1"}}];function mqe(e){return Are.find(t=>t.traits.verbosity===e.verbosity&&t.traits.autonomy===e.autonomy&&t.traits.chaos===e.chaos&&t.traits.creativity===e.creativity&&t.traits.humor===e.humor&&t.traits.spice===e.spice)}const gqe=["Verbosity","Autonomy","Chaos","Creativity","Humor","Spice"],S1=["verbosity","autonomy","chaos","creativity","humor","spice"],Tw=6,aO=5,IB=3,xqe=800,yqe=600,PB={light:{nebulaCenter:.45,nebulaMid:.25,wispStart:.2,fillStart:.25,fillEnd:.15,haloBase:.25,haloAmplitude:.12,breatheMin:.25,breatheMax:.4,guideBase:.1,guideStep:.04,axis:.12,stardustPeak:1,glowBlur:12,vertexBlur:4},dark:{nebulaCenter:.35,nebulaMid:.15,wispStart:.12,fillStart:.35,fillEnd:.25,haloBase:.15,haloAmplitude:.1,breatheMin:.15,breatheMax:.25,guideBase:.06,guideStep:.02,axis:.08,stardustPeak:.8,glowBlur:10,vertexBlur:4}},bqe=[{r:1.2,dur:"9s",fade:"4.5s",begin:"0s",path:"M0,0 C30,-40 60,0 40,40 C20,60 -20,40 -30,10 C-40,-20 -10,-50 0,0"},{r:.9,dur:"7s",fade:"3.5s",begin:"0s",path:"M0,0 C-20,30 -40,20 -30,-10 C-20,-30 10,-40 20,-20 C30,0 20,30 0,0"},{r:1,dur:"11s",fade:"5s",begin:"0s",path:"M0,0 C40,10 30,50 0,40 C-30,30 -40,-10 -20,-30 C0,-50 30,-20 0,0"},{r:.7,dur:"8s",fade:"4s",begin:"2s",path:"M0,0 C15,-35 45,-15 35,20 C25,45 -15,40 -25,15 C-35,-10 -5,-40 0,0"},{r:1.1,dur:"12s",fade:"6s",begin:"1s",path:"M0,0 C-25,25 -45,5 -30,-20 C-15,-45 20,-35 30,-10 C40,15 15,35 0,0"}];function cS(e,t,n,s){const r=Math.PI*2*e/Tw-Math.PI/2,a=t/aO*s;return{x:n+a*Math.cos(r),y:n+a*Math.sin(r)}}function KR(e){return e.map(t=>`${t.x},${t.y}`).join(" ")}function vqe(e,t,n){return KR(Array.from({length:Tw},(s,r)=>cS(r,e*aO,t,n)))}function Sqe(e){return e<.5?4*e*e*e:1-(-2*e+2)**3/2}function wqe({traits:e,colors:t=jre,size:n=180,animated:s=!0,className:r}){const a=x.useId().replace(/:/g,""),o=nO(),l=o?PB.dark:PB.light,c=x.useRef(l);c.current=l;const u=o?{strokeStart:t.stroke,strokeEnd:t.strokeEnd,fillStart:t.fill,fillEnd:t.fillEnd,dot:t.dot,glow:t.glow}:{strokeStart:t.fill,strokeEnd:t.fillEnd,fillStart:t.stroke,fillEnd:t.strokeEnd,dot:t.fill,glow:t.stroke},f=n/2,h=n*.32,m=h+16,g=n/200,b=x.useRef(null),v=x.useRef(null),k=x.useRef([]),w=x.useRef([]),C=x.useRef({current:{...e},from:null,target:{...e},morphStart:0,breathe:0}),E=x.useRef(e);x.useEffect(()=>{const D=E.current;if(S1.some(O=>D[O]!==e[O])){const O=C.current;if(s){O.from={...O.current},O.target={...e},O.morphStart=performance.now();const L=v.current;if(L){const B=performance.now();(function H(){const K=Math.min((performance.now()-B)/yqe,1),U=1-(1-K)*(1-K);L.setAttribute("r",String(h*(.7+.6*U))),L.setAttribute("opacity",String(.4*(1-U))),K<1&&requestAnimationFrame(H)})()}}else Object.assign(O.current,e),Object.assign(O.target,e)}E.current=e},[e,s,h]),x.useEffect(()=>{if(!s)return;let D;const I=C.current;function O(){var K;I.breathe+=.015;const L=1+Math.sin(I.breathe)*.04;if(I.from){const U=Math.min((performance.now()-I.morphStart)/xqe,1),$=Sqe(U);for(const q of S1)I.current[q]=I.from[q]+(I.target[q]-I.from[q])*$;U>=1&&(I.from=null,Object.assign(I.current,I.target))}const H=S1.map(U=>I.current[U]).map((U,$)=>cS($,U*L,f,h));(K=b.current)==null||K.setAttribute("points",KR(H)),H.forEach((U,$)=>{const q=k.current[$],J=w.current[$];if(q){q.setAttribute("cx",String(U.x)),q.setAttribute("cy",String(U.y)),q.setAttribute("r",String(8+Math.sin(I.breathe+$*1.2)*3));const ne=c.current;q.setAttribute("opacity",String(ne.haloBase+Math.sin(I.breathe+$)*ne.haloAmplitude))}J&&(J.setAttribute("cx",String(U.x)),J.setAttribute("cy",String(U.y)),J.setAttribute("r",String(3.5+Math.sin(I.breathe+$*.8)*.8)))}),D=requestAnimationFrame(O)}return D=requestAnimationFrame(O),()=>cancelAnimationFrame(D)},[s,f,h]);const T=S1.map((D,I)=>cS(I,e[D],f,h)),_=KR(T),j={transition:"stop-color 0.6s ease"},R={transition:"fill 0.6s ease"};return i.jsxs("svg",{viewBox:`0 0 ${n} ${n}`,className:X("aspect-square",r),"aria-label":"Personality radar chart",role:"img",children:[i.jsxs("defs",{children:[o?i.jsxs("filter",{id:`ng-${a}`,x:"-80%",y:"-80%",width:"260%",height:"260%",children:[i.jsx("feGaussianBlur",{stdDeviation:l.glowBlur,result:"blur"}),i.jsxs("feMerge",{children:[i.jsx("feMergeNode",{in:"blur"}),i.jsx("feMergeNode",{in:"blur"}),i.jsx("feMergeNode",{in:"SourceGraphic"})]})]}):i.jsx("filter",{id:`ng-${a}`,x:"-50%",y:"-30%",width:"200%",height:"200%",children:i.jsx("feDropShadow",{dx:"0",dy:"2",stdDeviation:"6",floodColor:u.strokeStart,floodOpacity:"0.18"})}),i.jsxs("filter",{id:`vg-${a}`,x:"-100%",y:"-100%",width:"300%",height:"300%",children:[i.jsx("feGaussianBlur",{stdDeviation:l.vertexBlur,result:"blur"}),i.jsxs("feMerge",{children:[i.jsx("feMergeNode",{in:"blur"}),i.jsx("feMergeNode",{in:"SourceGraphic"})]})]}),i.jsxs("radialGradient",{id:`nc-${a}`,cx:"50%",cy:"50%",r:"50%",children:[i.jsx("stop",{offset:"0%",style:{stopColor:t.nebula,stopOpacity:l.nebulaCenter,...j}}),i.jsx("stop",{offset:"50%",style:{stopColor:t.nebula,stopOpacity:l.nebulaMid,...j}}),i.jsx("stop",{offset:"100%",style:{stopColor:"var(--nebula-edge)"},stopOpacity:0})]}),i.jsxs("radialGradient",{id:`nw-${a}`,cx:"35%",cy:"35%",r:"60%",children:[i.jsx("stop",{offset:"0%",style:{stopColor:t.wisp,stopOpacity:l.wispStart,...j}}),i.jsx("stop",{offset:"100%",style:{stopColor:"var(--nebula-edge)"},stopOpacity:0})]}),i.jsxs("linearGradient",{id:`sf-${a}`,x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[i.jsx("stop",{offset:"0%",style:{stopColor:u.fillStart,stopOpacity:l.fillStart,...j}}),i.jsx("stop",{offset:"100%",style:{stopColor:u.fillEnd,stopOpacity:l.fillEnd,...j}})]}),i.jsxs("linearGradient",{id:`ss-${a}`,x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[i.jsx("stop",{offset:"0%",style:{stopColor:u.strokeStart,...j}}),i.jsx("stop",{offset:"100%",style:{stopColor:u.strokeEnd,...j}})]})]}),i.jsx("circle",{cx:f,cy:f,r:n*.44,fill:`url(#nc-${a})`,children:s&&i.jsx("animateTransform",{attributeName:"transform",type:"rotate",values:`0 ${f} ${f};360 ${f} ${f}`,dur:"90s",repeatCount:"indefinite"})}),i.jsx("ellipse",{cx:f*.94,cy:f*.97,rx:n*.35,ry:n*.25,fill:`url(#nw-${a})`,children:s&&i.jsx("animateTransform",{attributeName:"transform",type:"rotate",values:`0 ${f} ${f};-360 ${f} ${f}`,dur:"60s",repeatCount:"indefinite"})}),s&&i.jsxs("circle",{cx:f,cy:f,r:h*.92,fill:"none",style:{stroke:u.strokeStart,transition:"stroke 0.6s ease"},strokeWidth:.3,opacity:l.breatheMin,children:[i.jsx("animate",{attributeName:"r",values:`${h*.85};${h*1.08};${h*.85}`,dur:"4s",repeatCount:"indefinite",calcMode:"spline",keySplines:"0.4 0 0.6 1;0.4 0 0.6 1"}),i.jsx("animate",{attributeName:"opacity",values:`${l.breatheMin};${l.breatheMax};${l.breatheMin}`,dur:"4s",repeatCount:"indefinite",calcMode:"spline",keySplines:"0.4 0 0.6 1;0.4 0 0.6 1"})]}),s&&i.jsx("g",{transform:`translate(${f},${f}) scale(${g})`,children:bqe.map((D,I)=>i.jsxs("circle",{r:D.r,style:{fill:u.dot,...R},children:[i.jsx("animateMotion",{dur:D.dur,repeatCount:"indefinite",begin:D.begin,path:D.path}),i.jsx("animate",{attributeName:"opacity",values:`0;${l.stardustPeak};0`,dur:D.fade,repeatCount:"indefinite",begin:D.begin})]},`star-${I}`))}),i.jsx("circle",{ref:v,cx:f,cy:f,r:0,fill:t.nebula,opacity:0}),Array.from({length:IB},(D,I)=>i.jsx("polygon",{points:vqe((I+1)/IB,f,h),fill:"none",stroke:o?"currentColor":u.strokeStart,strokeWidth:.5,opacity:l.guideBase+I*l.guideStep},`ring-${I}`)),Array.from({length:Tw},(D,I)=>{const O=cS(I,aO,f,h);return i.jsx("line",{x1:f,y1:f,x2:O.x,y2:O.y,stroke:o?"currentColor":u.strokeStart,strokeWidth:.5,opacity:l.axis},`axis-${I}`)}),i.jsx("polygon",{ref:b,points:_,fill:`url(#sf-${a})`,stroke:`url(#ss-${a})`,strokeWidth:2,strokeLinejoin:"round",filter:`url(#ng-${a})`}),T.map((D,I)=>i.jsx("circle",{ref:O=>{k.current[I]=O},cx:D.x,cy:D.y,r:8,style:{fill:u.glow,...R},opacity:l.haloBase},`halo-${I}`)),T.map((D,I)=>i.jsx("circle",{ref:O=>{w.current[I]=O},cx:D.x,cy:D.y,r:o?4:4.5,style:{fill:u.dot,...R},stroke:o?"none":"white",strokeWidth:o?0:1.5,filter:`url(#vg-${a})`},`dot-${I}`)),gqe.map((D,I)=>{const O=Math.PI*2*I/Tw-Math.PI/2;return i.jsx("text",{x:f+m*Math.cos(O),y:f+m*Math.sin(O),textAnchor:"middle",dominantBaseline:"middle",fill:"currentColor",opacity:.5,fontSize:8,className:"select-none",children:D},D)})]})}const LB={duration:.2,ease:"easeInOut"};function kqe({traits:e,onTraitsChange:t,compact:n=!1,sampleLabel:s="How this agent talks",className:r}){const[a,o]=x.useState("presets"),l=mqe(e),c=(l==null?void 0:l.colors)??jre,u=x.useCallback(m=>{t(m.traits),o("presets"),h0()},[t]),f=x.useCallback(()=>{o("custom"),h0()},[]),h=x.useCallback(()=>{o("presets"),h0()},[]);return i.jsxs("div",{className:X("@container/picker w-full",r),children:[i.jsxs("div",{className:X("flex flex-col items-center gap-3","@[480px]/picker:flex-row @[480px]/picker:items-center @[480px]/picker:gap-6"),children:[i.jsxs("div",{className:X("flex flex-col items-center gap-1","@[480px]/picker:w-[200px] @[480px]/picker:shrink-0"),children:[i.jsx("div",{"data-testid":"personality-radar",children:i.jsx(wqe,{traits:e,colors:c,size:n?180:200,className:n?"w-[90%] max-w-[240px]":"w-full max-w-[200px]"})}),i.jsxs("div",{className:"text-center",children:[i.jsx("h3",{className:"bg-clip-text text-sm font-bold text-transparent",style:{backgroundImage:`linear-gradient(135deg, ${c.stroke}, ${c.strokeEnd})`},children:(l==null?void 0:l.name)??"Custom"}),i.jsx("p",{className:"text-muted-foreground mt-0.5 text-[11px]",children:(l==null?void 0:l.tagline)??"A custom blend of personality traits."})]})]}),i.jsx("div",{className:"flex w-full min-w-0 flex-col items-center gap-3 @[480px]/picker:items-start",children:i.jsx(He,{mode:"wait",initial:!1,children:a==="presets"?i.jsxs(oe.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:-6},transition:LB,className:"flex max-w-sm flex-wrap justify-center gap-1.5 @[480px]/picker:justify-start","data-testid":"preset-pills",children:[Are.map(m=>i.jsx(oVe,{emoji:m.emoji,name:m.name,colors:m.colors,active:(l==null?void 0:l.id)===m.id,size:n?"sm":"default",glow:!0,onClick:()=>u(m)},m.id)),i.jsxs("button",{type:"button",onClick:f,className:X("inline-flex shrink-0 items-center gap-1.5 rounded-full border border-dashed font-medium transition-all","text-muted-foreground hover:text-foreground hover:border-foreground/20 border-border",n?"px-2.5 py-1 text-[11px]":"px-3 py-1 text-xs"),"data-testid":"custom-toggle",children:[i.jsx(Qi,{className:"size-3"}),i.jsx("span",{children:"Custom"})]})]},"presets"):i.jsxs(oe.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:-6},transition:LB,className:"flex w-full flex-col items-center gap-3 @[480px]/picker:items-start",children:[i.jsxs("div",{className:"flex gap-1.5","data-testid":"custom-mode-pills",children:[i.jsxs("button",{type:"button",onClick:h,className:X("inline-flex shrink-0 items-center gap-1.5 rounded-full border border-dashed font-medium transition-all","text-muted-foreground hover:text-foreground hover:border-foreground/20 border-border",n?"px-2.5 py-1 text-[11px]":"px-3 py-1 text-xs"),"data-testid":"presets-toggle",children:[i.jsx("span",{children:"←"}),i.jsx("span",{children:"Presets"})]}),i.jsxs("span",{className:X("bg-accent text-foreground inline-flex shrink-0 items-center gap-1.5 rounded-full border font-medium","border-foreground/15",n?"px-2.5 py-1 text-[11px]":"px-3 py-1 text-xs"),children:[i.jsx(Qi,{className:"size-3"}),i.jsx("span",{children:"Custom"})]})]}),i.jsx("div",{className:X("w-full",n?"max-w-sm":"max-w-md"),onPointerDown:()=>h0(),children:i.jsx(uVe,{traits:e,onChange:t,onSliderChange:()=>h0()})})]},"custom")})})]}),i.jsxs("div",{className:"hidden w-full max-w-sm",children:[i.jsx("span",{className:"text-muted-foreground text-[9px] font-medium tracking-wider uppercase",children:s}),i.jsx("div",{className:"bg-accent/50 mt-1 rounded-lg p-3",children:i.jsx("p",{className:"text-muted-foreground text-xs leading-relaxed italic",children:(l==null?void 0:l.sampleResponse)??"This agent uses a custom personality blend. Select a preset to see a sample response."})})]})]})}const JC=x.createContext(null);JC.displayName="PanelGroupContext";const ks={group:"data-panel-group",groupDirection:"data-panel-group-direction",groupId:"data-panel-group-id",panel:"data-panel",panelCollapsible:"data-panel-collapsible",panelId:"data-panel-id",panelSize:"data-panel-size",resizeHandle:"data-resize-handle",resizeHandleActive:"data-resize-handle-active",resizeHandleEnabled:"data-panel-resize-handle-enabled",resizeHandleId:"data-panel-resize-handle-id",resizeHandleState:"data-resize-handle-state"},iO=10,hf=x.useLayoutEffect,FB=gy.useId,Cqe=typeof FB=="function"?FB:()=>null;let Eqe=0;function oO(e=null){const t=Cqe(),n=x.useRef(e||t||null);return n.current===null&&(n.current=""+Eqe++),e??n.current}function Rre({children:e,className:t="",collapsedSize:n,collapsible:s,defaultSize:r,forwardedRef:a,id:o,maxSize:l,minSize:c,onCollapse:u,onExpand:f,onResize:h,order:m,style:g,tagName:b="div",...v}){const k=x.useContext(JC);if(k===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:w,expandPanel:C,getPanelSize:E,getPanelStyle:T,groupId:_,isPanelCollapsed:j,reevaluatePanelConstraints:R,registerPanel:D,resizePanel:I,unregisterPanel:O}=k,L=oO(o),B=x.useRef({callbacks:{onCollapse:u,onExpand:f,onResize:h},constraints:{collapsedSize:n,collapsible:s,defaultSize:r,maxSize:l,minSize:c},id:L,idIsFromProps:o!==void 0,order:m});x.useRef({didLogMissingDefaultSizeWarning:!1}),hf(()=>{const{callbacks:K,constraints:U}=B.current,$={...U};B.current.id=L,B.current.idIsFromProps=o!==void 0,B.current.order=m,K.onCollapse=u,K.onExpand=f,K.onResize=h,U.collapsedSize=n,U.collapsible=s,U.defaultSize=r,U.maxSize=l,U.minSize=c,($.collapsedSize!==U.collapsedSize||$.collapsible!==U.collapsible||$.maxSize!==U.maxSize||$.minSize!==U.minSize)&&R(B.current,$)}),hf(()=>{const K=B.current;return D(K),()=>{O(K)}},[m,L,D,O]),x.useImperativeHandle(a,()=>({collapse:()=>{w(B.current)},expand:K=>{C(B.current,K)},getId(){return L},getSize(){return E(B.current)},isCollapsed(){return j(B.current)},isExpanded(){return!j(B.current)},resize:K=>{I(B.current,K)}}),[w,C,E,j,L,I]);const H=T(B.current,r);return x.createElement(b,{...v,children:e,className:t,id:L,style:{...H,...g},[ks.groupId]:_,[ks.panel]:"",[ks.panelCollapsible]:s||void 0,[ks.panelId]:L,[ks.panelSize]:parseFloat(""+H.flexGrow).toFixed(1)})}const lO=x.forwardRef((e,t)=>x.createElement(Rre,{...e,forwardedRef:t}));Rre.displayName="Panel";lO.displayName="forwardRef(Panel)";let WR=null,uS=-1,Bc=null;function Tqe(e,t,n){const s=(t&Pre)!==0,r=(t&Lre)!==0,a=(t&Fre)!==0,o=(t&zre)!==0;if(t){if(s)return a?"se-resize":o?"ne-resize":"e-resize";if(r)return a?"sw-resize":o?"nw-resize":"w-resize";if(a)return"s-resize";if(o)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function _qe(){Bc!==null&&(document.head.removeChild(Bc),WR=null,Bc=null,uS=-1)}function yN(e,t,n){var s,r;const a=Tqe(e,t);if(WR!==a){if(WR=a,Bc===null&&(Bc=document.createElement("style"),document.head.appendChild(Bc)),uS>=0){var o;(o=Bc.sheet)===null||o===void 0||o.removeRule(uS)}uS=(s=(r=Bc.sheet)===null||r===void 0?void 0:r.insertRule(`*{cursor: ${a} !important;}`))!==null&&s!==void 0?s:-1}}function Mre(e){return e.type==="keydown"}function Dre(e){return e.type.startsWith("pointer")}function Ore(e){return e.type.startsWith("mouse")}function eE(e){if(Dre(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(Ore(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function Nqe(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function jqe(e,t,n){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function Aqe(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:$B(e),b:$B(t)};let s;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),s=e;Vt(s,"Stacking order can only be calculated for elements with a common ancestor");const r={a:BB(zB(n.a)),b:BB(zB(n.b))};if(r.a===r.b){const a=s.childNodes,o={a:n.a.at(-1),b:n.b.at(-1)};let l=a.length;for(;l--;){const c=a[l];if(c===o.a)return 1;if(c===o.b)return-1}}return Math.sign(r.a-r.b)}const Rqe=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Mqe(e){var t;const n=getComputedStyle((t=Ire(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function Dqe(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||Mqe(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||Rqe.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function zB(e){let t=e.length;for(;t--;){const n=e[t];if(Vt(n,"Missing node"),Dqe(n))return n}return null}function BB(e){return e&&Number(getComputedStyle(e).zIndex)||0}function $B(e){const t=[];for(;e;)t.push(e),e=Ire(e);return t}function Ire(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const Pre=1,Lre=2,Fre=4,zre=8,Oqe=Nqe()==="coarse";let Ki=[],Zp=!1,$c=new Map,tE=new Map;const ny=new Set;function Iqe(e,t,n,s,r){var a;const{ownerDocument:o}=t,l={direction:n,element:t,hitAreaMargins:s,setResizeHandlerState:r},c=(a=$c.get(o))!==null&&a!==void 0?a:0;return $c.set(o,c+1),ny.add(l),_w(),function(){var f;tE.delete(e),ny.delete(l);const h=(f=$c.get(o))!==null&&f!==void 0?f:1;if($c.set(o,h-1),_w(),h===1&&$c.delete(o),Ki.includes(l)){const m=Ki.indexOf(l);m>=0&&Ki.splice(m,1),nE(),r("up",!0,null)}}}function Pqe(e){const{target:t}=e,{x:n,y:s}=eE(e);Zp=!0,cO({target:t,x:n,y:s}),_w(),Ki.length>0&&(Nw("down",e),nE(),e.preventDefault(),Bre(t)||e.stopImmediatePropagation())}function bN(e){const{x:t,y:n}=eE(e);if(Zp&&e.type!=="pointerleave"&&e.buttons===0&&(Zp=!1,Nw("up",e)),!Zp){const{target:s}=e;cO({target:s,x:t,y:n})}Nw("move",e),nE(),Ki.length>0&&e.preventDefault()}function vN(e){const{target:t}=e,{x:n,y:s}=eE(e);tE.clear(),Zp=!1,Ki.length>0&&(e.preventDefault(),Bre(t)||e.stopImmediatePropagation()),Nw("up",e),cO({target:t,x:n,y:s}),nE(),_w()}function Bre(e){let t=e;for(;t;){if(t.hasAttribute(ks.resizeHandle))return!0;t=t.parentElement}return!1}function cO({target:e,x:t,y:n}){Ki.splice(0);let s=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(s=e),ny.forEach(r=>{const{element:a,hitAreaMargins:o}=r,l=a.getBoundingClientRect(),{bottom:c,left:u,right:f,top:h}=l,m=Oqe?o.coarse:o.fine;if(t>=u-m&&t<=f+m&&n>=h-m&&n<=c+m){if(s!==null&&document.contains(s)&&a!==s&&!a.contains(s)&&!s.contains(a)&&Aqe(s,a)>0){let b=s,v=!1;for(;b&&!b.contains(a);){if(jqe(b.getBoundingClientRect(),l)){v=!0;break}b=b.parentElement}if(v)return}Ki.push(r)}})}function SN(e,t){tE.set(e,t)}function nE(){let e=!1,t=!1;Ki.forEach(s=>{const{direction:r}=s;r==="horizontal"?e=!0:t=!0});let n=0;tE.forEach(s=>{n|=s}),e&&t?yN("intersection",n):e?yN("horizontal",n):t?yN("vertical",n):_qe()}let wN;function _w(){var e;(e=wN)===null||e===void 0||e.abort(),wN=new AbortController;const t={capture:!0,signal:wN.signal};ny.size&&(Zp?(Ki.length>0&&$c.forEach((n,s)=>{const{body:r}=s;n>0&&(r.addEventListener("contextmenu",vN,t),r.addEventListener("pointerleave",bN,t),r.addEventListener("pointermove",bN,t))}),$c.forEach((n,s)=>{const{body:r}=s;r.addEventListener("pointerup",vN,t),r.addEventListener("pointercancel",vN,t)})):$c.forEach((n,s)=>{const{body:r}=s;n>0&&(r.addEventListener("pointerdown",Pqe,t),r.addEventListener("pointermove",bN,t))}))}function Nw(e,t){ny.forEach(n=>{const{setResizeHandlerState:s}=n,r=Ki.includes(n);s(e,r,t)})}function Lqe(){const[e,t]=x.useState(0);return x.useCallback(()=>t(n=>n+1),[])}function Vt(e,t){if(!e)throw console.error(t),Error(t)}function Tf(e,t,n=iO){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function jl(e,t,n=iO){return Tf(e,t,n)===0}function Ba(e,t,n){return Tf(e,t,n)===0}function Fqe(e,t,n){if(e.length!==t.length)return!1;for(let s=0;s<e.length;s++){const r=e[s],a=t[s];if(!Ba(r,a,n))return!1}return!0}function Lp({panelConstraints:e,panelIndex:t,size:n}){const s=e[t];Vt(s!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:r=0,collapsible:a,maxSize:o=100,minSize:l=0}=s;if(Tf(n,l)<0)if(a){const c=(r+l)/2;Tf(n,c)<0?n=r:n=l}else n=l;return n=Math.min(o,n),n=parseFloat(n.toFixed(iO)),n}function Q0({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:s,prevLayout:r,trigger:a}){if(Ba(e,0))return t;const o=[...t],[l,c]=s;Vt(l!=null,"Invalid first pivot index"),Vt(c!=null,"Invalid second pivot index");let u=0;if(a==="keyboard"){{const h=e<0?c:l,m=n[h];Vt(m,`Panel constraints not found for index ${h}`);const{collapsedSize:g=0,collapsible:b,minSize:v=0}=m;if(b){const k=t[h];if(Vt(k!=null,`Previous layout not found for panel index ${h}`),Ba(k,g)){const w=v-k;Tf(w,Math.abs(e))>0&&(e=e<0?0-w:w)}}}{const h=e<0?l:c,m=n[h];Vt(m,`No panel constraints found for index ${h}`);const{collapsedSize:g=0,collapsible:b,minSize:v=0}=m;if(b){const k=t[h];if(Vt(k!=null,`Previous layout not found for panel index ${h}`),Ba(k,v)){const w=k-g;Tf(w,Math.abs(e))>0&&(e=e<0?0-w:w)}}}}{const h=e<0?1:-1;let m=e<0?c:l,g=0;for(;;){const v=t[m];Vt(v!=null,`Previous layout not found for panel index ${m}`);const w=Lp({panelConstraints:n,panelIndex:m,size:100})-v;if(g+=w,m+=h,m<0||m>=n.length)break}const b=Math.min(Math.abs(e),Math.abs(g));e=e<0?0-b:b}{let m=e<0?l:c;for(;m>=0&&m<n.length;){const g=Math.abs(e)-Math.abs(u),b=t[m];Vt(b!=null,`Previous layout not found for panel index ${m}`);const v=b-g,k=Lp({panelConstraints:n,panelIndex:m,size:v});if(!Ba(b,k)&&(u+=b-k,o[m]=k,u.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?m--:m++}}if(Fqe(r,o))return r;{const h=e<0?c:l,m=t[h];Vt(m!=null,`Previous layout not found for panel index ${h}`);const g=m+u,b=Lp({panelConstraints:n,panelIndex:h,size:g});if(o[h]=b,!Ba(b,g)){let v=g-b,w=e<0?c:l;for(;w>=0&&w<n.length;){const C=o[w];Vt(C!=null,`Previous layout not found for panel index ${w}`);const E=C+v,T=Lp({panelConstraints:n,panelIndex:w,size:E});if(Ba(C,T)||(v-=T-C,o[w]=T),Ba(v,0))break;e>0?w--:w++}}}const f=o.reduce((h,m)=>m+h,0);return Ba(f,100)?o:r}function zqe({layout:e,panelsArray:t,pivotIndices:n}){let s=0,r=100,a=0,o=0;const l=n[0];Vt(l!=null,"No pivot index found"),t.forEach((h,m)=>{const{constraints:g}=h,{maxSize:b=100,minSize:v=0}=g;m===l?(s=v,r=b):(a+=v,o+=b)});const c=Math.min(r,100-a),u=Math.max(s,100-o),f=e[l];return{valueMax:c,valueMin:u,valueNow:f}}function sy(e,t=document){return Array.from(t.querySelectorAll(`[${ks.resizeHandleId}][data-panel-group-id="${e}"]`))}function $re(e,t,n=document){const r=sy(e,n).findIndex(a=>a.getAttribute(ks.resizeHandleId)===t);return r??null}function Hre(e,t,n){const s=$re(e,t,n);return s!=null?[s,s+1]:[-1,-1]}function Bqe(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function Ure(e,t=document){if(Bqe(t)&&t.dataset.panelGroupId==e)return t;const n=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function sE(e,t=document){const n=t.querySelector(`[${ks.resizeHandleId}="${e}"]`);return n||null}function $qe(e,t,n,s=document){var r,a,o,l;const c=sE(t,s),u=sy(e,s),f=c?u.indexOf(c):-1,h=(r=(a=n[f])===null||a===void 0?void 0:a.id)!==null&&r!==void 0?r:null,m=(o=(l=n[f+1])===null||l===void 0?void 0:l.id)!==null&&o!==void 0?o:null;return[h,m]}function Hqe({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:s,panelDataArray:r,panelGroupElement:a,setLayout:o}){x.useRef({didWarnAboutMissingResizeHandle:!1}),hf(()=>{if(!a)return;const l=sy(n,a);for(let c=0;c<r.length-1;c++){const{valueMax:u,valueMin:f,valueNow:h}=zqe({layout:s,panelsArray:r,pivotIndices:[c,c+1]}),m=l[c];if(m!=null){const g=r[c];Vt(g,`No panel data found for index "${c}"`),m.setAttribute("aria-controls",g.id),m.setAttribute("aria-valuemax",""+Math.round(u)),m.setAttribute("aria-valuemin",""+Math.round(f)),m.setAttribute("aria-valuenow",h!=null?""+Math.round(h):"")}}return()=>{l.forEach((c,u)=>{c.removeAttribute("aria-controls"),c.removeAttribute("aria-valuemax"),c.removeAttribute("aria-valuemin"),c.removeAttribute("aria-valuenow")})}},[n,s,r,a]),x.useEffect(()=>{if(!a)return;const l=t.current;Vt(l,"Eager values not found");const{panelDataArray:c}=l,u=Ure(n,a);Vt(u!=null,`No group found for id "${n}"`);const f=sy(n,a);Vt(f,`No resize handles found for group id "${n}"`);const h=f.map(m=>{const g=m.getAttribute(ks.resizeHandleId);Vt(g,"Resize handle element has no handle id attribute");const[b,v]=$qe(n,g,c,a);if(b==null||v==null)return()=>{};const k=w=>{if(!w.defaultPrevented)switch(w.key){case"Enter":{w.preventDefault();const C=c.findIndex(E=>E.id===b);if(C>=0){const E=c[C];Vt(E,`No panel data found for index ${C}`);const T=s[C],{collapsedSize:_=0,collapsible:j,minSize:R=0}=E.constraints;if(T!=null&&j){const D=Q0({delta:Ba(T,_)?R-_:_-T,initialLayout:s,panelConstraints:c.map(I=>I.constraints),pivotIndices:Hre(n,g,a),prevLayout:s,trigger:"keyboard"});s!==D&&o(D)}}break}}};return m.addEventListener("keydown",k),()=>{m.removeEventListener("keydown",k)}});return()=>{h.forEach(m=>m())}},[a,e,t,n,s,r,o])}function HB(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Vre(e,t){const n=e==="horizontal",{x:s,y:r}=eE(t);return n?s:r}function Uqe(e,t,n,s,r){const a=n==="horizontal",o=sE(t,r);Vt(o,`No resize handle element found for id "${t}"`);const l=o.getAttribute(ks.groupId);Vt(l,"Resize handle element has no group id attribute");let{initialCursorPosition:c}=s;const u=Vre(n,e),f=Ure(l,r);Vt(f,`No group element found for id "${l}"`);const h=f.getBoundingClientRect(),m=a?h.width:h.height;return(u-c)/m*100}function Vqe(e,t,n,s,r,a){if(Mre(e)){const o=n==="horizontal";let l=0;e.shiftKey?l=100:r!=null?l=r:l=10;let c=0;switch(e.key){case"ArrowDown":c=o?0:l;break;case"ArrowLeft":c=o?-l:0;break;case"ArrowRight":c=o?l:0;break;case"ArrowUp":c=o?0:-l;break;case"End":c=100;break;case"Home":c=-100;break}return c}else return s==null?0:Uqe(e,t,n,s,a)}function qqe({panelDataArray:e}){const t=Array(e.length),n=e.map(a=>a.constraints);let s=0,r=100;for(let a=0;a<e.length;a++){const o=n[a];Vt(o,`Panel constraints not found for index ${a}`);const{defaultSize:l}=o;l!=null&&(s++,t[a]=l,r-=l)}for(let a=0;a<e.length;a++){const o=n[a];Vt(o,`Panel constraints not found for index ${a}`);const{defaultSize:l}=o;if(l!=null)continue;const c=e.length-s,u=r/c;s++,t[a]=u,r-=u}return t}function cp(e,t,n){t.forEach((s,r)=>{const a=e[r];Vt(a,`Panel data not found for index ${r}`);const{callbacks:o,constraints:l,id:c}=a,{collapsedSize:u=0,collapsible:f}=l,h=n[c];if(h==null||s!==h){n[c]=s;const{onCollapse:m,onExpand:g,onResize:b}=o;b&&b(s,h),f&&(m||g)&&(g&&(h==null||jl(h,u))&&!jl(s,u)&&g(),m&&(h==null||!jl(h,u))&&jl(s,u)&&m())}})}function w1(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function Gqe({defaultSize:e,dragState:t,layout:n,panelData:s,panelIndex:r,precision:a=3}){const o=n[r];let l;return o==null?l=e!=null?e.toFixed(a):"1":s.length===1?l="1":l=o.toFixed(a),{flexBasis:0,flexGrow:l,flexShrink:1,overflow:"hidden",pointerEvents:t!==null?"none":void 0}}function Kqe(e,t=10){let n=null;return(...r)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...r)},t)}}function UB(e){try{if(typeof localStorage<"u")e.getItem=t=>localStorage.getItem(t),e.setItem=(t,n)=>{localStorage.setItem(t,n)};else throw new Error("localStorage not supported in this environment")}catch(t){console.error(t),e.getItem=()=>null,e.setItem=()=>{}}}function qre(e){return`react-resizable-panels:${e}`}function Gre(e){return e.map(t=>{const{constraints:n,id:s,idIsFromProps:r,order:a}=t;return r?s:a?`${a}:${JSON.stringify(n)}`:JSON.stringify(n)}).sort((t,n)=>t.localeCompare(n)).join(",")}function Kre(e,t){try{const n=qre(e),s=t.getItem(n);if(s){const r=JSON.parse(s);if(typeof r=="object"&&r!=null)return r}}catch{}return null}function Wqe(e,t,n){var s,r;const a=(s=Kre(e,n))!==null&&s!==void 0?s:{},o=Gre(t);return(r=a[o])!==null&&r!==void 0?r:null}function Yqe(e,t,n,s,r){var a;const o=qre(e),l=Gre(t),c=(a=Kre(e,r))!==null&&a!==void 0?a:{};c[l]={expandToSizes:Object.fromEntries(n.entries()),layout:s};try{r.setItem(o,JSON.stringify(c))}catch(u){console.error(u)}}function VB({layout:e,panelConstraints:t}){const n=[...e],s=n.reduce((a,o)=>a+o,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map(a=>`${a}%`).join(", ")}`);if(!Ba(s,100)&&n.length>0)for(let a=0;a<t.length;a++){const o=n[a];Vt(o!=null,`No layout data found for index ${a}`);const l=100/s*o;n[a]=l}let r=0;for(let a=0;a<t.length;a++){const o=n[a];Vt(o!=null,`No layout data found for index ${a}`);const l=Lp({panelConstraints:t,panelIndex:a,size:o});o!=l&&(r+=o-l,n[a]=l)}if(!Ba(r,0))for(let a=0;a<t.length;a++){const o=n[a];Vt(o!=null,`No layout data found for index ${a}`);const l=o+r,c=Lp({panelConstraints:t,panelIndex:a,size:l});if(o!==c&&(r-=c-o,n[a]=c,Ba(r,0)))break}return n}const Zqe=100,J0={getItem:e=>(UB(J0),J0.getItem(e)),setItem:(e,t)=>{UB(J0),J0.setItem(e,t)}},qB={};function Wre({autoSaveId:e=null,children:t,className:n="",direction:s,forwardedRef:r,id:a=null,onLayout:o=null,keyboardResizeBy:l=null,storage:c=J0,style:u,tagName:f="div",...h}){const m=oO(a),g=x.useRef(null),[b,v]=x.useState(null),[k,w]=x.useState([]),C=Lqe(),E=x.useRef({}),T=x.useRef(new Map),_=x.useRef(0),j=x.useRef({autoSaveId:e,direction:s,dragState:b,id:m,keyboardResizeBy:l,onLayout:o,storage:c}),R=x.useRef({layout:k,panelDataArray:[],panelDataArrayChanged:!1});x.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),x.useImperativeHandle(r,()=>({getId:()=>j.current.id,getLayout:()=>{const{layout:P}=R.current;return P},setLayout:P=>{const{onLayout:Z}=j.current,{layout:Q,panelDataArray:re}=R.current,ae=VB({layout:P,panelConstraints:re.map(de=>de.constraints)});HB(Q,ae)||(w(ae),R.current.layout=ae,Z&&Z(ae),cp(re,ae,E.current))}}),[]),hf(()=>{j.current.autoSaveId=e,j.current.direction=s,j.current.dragState=b,j.current.id=m,j.current.onLayout=o,j.current.storage=c}),Hqe({committedValuesRef:j,eagerValuesRef:R,groupId:m,layout:k,panelDataArray:R.current.panelDataArray,setLayout:w,panelGroupElement:g.current}),x.useEffect(()=>{const{panelDataArray:P}=R.current;if(e){if(k.length===0||k.length!==P.length)return;let Z=qB[e];Z==null&&(Z=Kqe(Yqe,Zqe),qB[e]=Z);const Q=[...P],re=new Map(T.current);Z(e,Q,re,k,c)}},[e,k,c]),x.useEffect(()=>{});const D=x.useCallback(P=>{const{onLayout:Z}=j.current,{layout:Q,panelDataArray:re}=R.current;if(P.constraints.collapsible){const ae=re.map(Ve=>Ve.constraints),{collapsedSize:de=0,panelSize:pe,pivotIndices:Oe}=Od(re,P,Q);if(Vt(pe!=null,`Panel size not found for panel "${P.id}"`),!jl(pe,de)){T.current.set(P.id,pe);const $e=Ep(re,P)===re.length-1?pe-de:de-pe,Qe=Q0({delta:$e,initialLayout:Q,panelConstraints:ae,pivotIndices:Oe,prevLayout:Q,trigger:"imperative-api"});w1(Q,Qe)||(w(Qe),R.current.layout=Qe,Z&&Z(Qe),cp(re,Qe,E.current))}}},[]),I=x.useCallback((P,Z)=>{const{onLayout:Q}=j.current,{layout:re,panelDataArray:ae}=R.current;if(P.constraints.collapsible){const de=ae.map(Se=>Se.constraints),{collapsedSize:pe=0,panelSize:Oe=0,minSize:Ve=0,pivotIndices:$e}=Od(ae,P,re),Qe=Z??Ve;if(jl(Oe,pe)){const Se=T.current.get(P.id),Ze=Se!=null&&Se>=Qe?Se:Qe,Me=Ep(ae,P)===ae.length-1?Oe-Ze:Ze-Oe,Ie=Q0({delta:Me,initialLayout:re,panelConstraints:de,pivotIndices:$e,prevLayout:re,trigger:"imperative-api"});w1(re,Ie)||(w(Ie),R.current.layout=Ie,Q&&Q(Ie),cp(ae,Ie,E.current))}}},[]),O=x.useCallback(P=>{const{layout:Z,panelDataArray:Q}=R.current,{panelSize:re}=Od(Q,P,Z);return Vt(re!=null,`Panel size not found for panel "${P.id}"`),re},[]),L=x.useCallback((P,Z)=>{const{panelDataArray:Q}=R.current,re=Ep(Q,P);return Gqe({defaultSize:Z,dragState:b,layout:k,panelData:Q,panelIndex:re})},[b,k]),B=x.useCallback(P=>{const{layout:Z,panelDataArray:Q}=R.current,{collapsedSize:re=0,collapsible:ae,panelSize:de}=Od(Q,P,Z);return Vt(de!=null,`Panel size not found for panel "${P.id}"`),ae===!0&&jl(de,re)},[]),H=x.useCallback(P=>{const{layout:Z,panelDataArray:Q}=R.current,{collapsedSize:re=0,collapsible:ae,panelSize:de}=Od(Q,P,Z);return Vt(de!=null,`Panel size not found for panel "${P.id}"`),!ae||Tf(de,re)>0},[]),K=x.useCallback(P=>{const{panelDataArray:Z}=R.current;Z.push(P),Z.sort((Q,re)=>{const ae=Q.order,de=re.order;return ae==null&&de==null?0:ae==null?-1:de==null?1:ae-de}),R.current.panelDataArrayChanged=!0,C()},[C]);hf(()=>{if(R.current.panelDataArrayChanged){R.current.panelDataArrayChanged=!1;const{autoSaveId:P,onLayout:Z,storage:Q}=j.current,{layout:re,panelDataArray:ae}=R.current;let de=null;if(P){const Oe=Wqe(P,ae,Q);Oe&&(T.current=new Map(Object.entries(Oe.expandToSizes)),de=Oe.layout)}de==null&&(de=qqe({panelDataArray:ae}));const pe=VB({layout:de,panelConstraints:ae.map(Oe=>Oe.constraints)});HB(re,pe)||(w(pe),R.current.layout=pe,Z&&Z(pe),cp(ae,pe,E.current))}}),hf(()=>{const P=R.current;return()=>{P.layout=[]}},[]);const U=x.useCallback(P=>{let Z=!1;const Q=g.current;return Q&&window.getComputedStyle(Q,null).getPropertyValue("direction")==="rtl"&&(Z=!0),function(ae){ae.preventDefault();const de=g.current;if(!de)return()=>null;const{direction:pe,dragState:Oe,id:Ve,keyboardResizeBy:$e,onLayout:Qe}=j.current,{layout:Se,panelDataArray:Ze}=R.current,{initialLayout:bt}=Oe??{},Me=Hre(Ve,P,de);let Ie=Vqe(ae,P,pe,Oe,$e,de);const Te=pe==="horizontal";Te&&Z&&(Ie=-Ie);const Je=Ze.map(Gt=>Gt.constraints),_t=Q0({delta:Ie,initialLayout:bt??Se,panelConstraints:Je,pivotIndices:Me,prevLayout:Se,trigger:Mre(ae)?"keyboard":"mouse-or-touch"}),St=!w1(Se,_t);(Dre(ae)||Ore(ae))&&_.current!=Ie&&(_.current=Ie,!St&&Ie!==0?Te?SN(P,Ie<0?Pre:Lre):SN(P,Ie<0?Fre:zre):SN(P,0)),St&&(w(_t),R.current.layout=_t,Qe&&Qe(_t),cp(Ze,_t,E.current))}},[]),$=x.useCallback((P,Z)=>{const{onLayout:Q}=j.current,{layout:re,panelDataArray:ae}=R.current,de=ae.map(Se=>Se.constraints),{panelSize:pe,pivotIndices:Oe}=Od(ae,P,re);Vt(pe!=null,`Panel size not found for panel "${P.id}"`);const $e=Ep(ae,P)===ae.length-1?pe-Z:Z-pe,Qe=Q0({delta:$e,initialLayout:re,panelConstraints:de,pivotIndices:Oe,prevLayout:re,trigger:"imperative-api"});w1(re,Qe)||(w(Qe),R.current.layout=Qe,Q&&Q(Qe),cp(ae,Qe,E.current))},[]),q=x.useCallback((P,Z)=>{const{layout:Q,panelDataArray:re}=R.current,{collapsedSize:ae=0,collapsible:de}=Z,{collapsedSize:pe=0,collapsible:Oe,maxSize:Ve=100,minSize:$e=0}=P.constraints,{panelSize:Qe}=Od(re,P,Q);Qe!=null&&(de&&Oe&&jl(Qe,ae)?jl(ae,pe)||$(P,pe):Qe<$e?$(P,$e):Qe>Ve&&$(P,Ve))},[$]),J=x.useCallback((P,Z)=>{const{direction:Q}=j.current,{layout:re}=R.current;if(!g.current)return;const ae=sE(P,g.current);Vt(ae,`Drag handle element not found for id "${P}"`);const de=Vre(Q,Z);v({dragHandleId:P,dragHandleRect:ae.getBoundingClientRect(),initialCursorPosition:de,initialLayout:re})},[]),ne=x.useCallback(()=>{v(null)},[]),F=x.useCallback(P=>{const{panelDataArray:Z}=R.current,Q=Ep(Z,P);Q>=0&&(Z.splice(Q,1),delete E.current[P.id],R.current.panelDataArrayChanged=!0,C())},[C]),V=x.useMemo(()=>({collapsePanel:D,direction:s,dragState:b,expandPanel:I,getPanelSize:O,getPanelStyle:L,groupId:m,isPanelCollapsed:B,isPanelExpanded:H,reevaluatePanelConstraints:q,registerPanel:K,registerResizeHandle:U,resizePanel:$,startDragging:J,stopDragging:ne,unregisterPanel:F,panelGroupElement:g.current}),[D,b,s,I,O,L,m,B,H,q,K,U,$,J,ne,F]),G={display:"flex",flexDirection:s==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return x.createElement(JC.Provider,{value:V},x.createElement(f,{...h,children:t,className:n,id:a,ref:g,style:{...G,...u},[ks.group]:"",[ks.groupDirection]:s,[ks.groupId]:m}))}const Yre=x.forwardRef((e,t)=>x.createElement(Wre,{...e,forwardedRef:t}));Wre.displayName="PanelGroup";Yre.displayName="forwardRef(PanelGroup)";function Ep(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function Od(e,t,n){const s=Ep(e,t),a=s===e.length-1?[s-1,s]:[s,s+1],o=n[s];return{...t.constraints,panelSize:o,pivotIndices:a}}function Xqe({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:s}){x.useEffect(()=>{if(e||n==null||s==null)return;const r=sE(t,s);if(r==null)return;const a=o=>{if(!o.defaultPrevented)switch(o.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{o.preventDefault(),n(o);break}case"F6":{o.preventDefault();const l=r.getAttribute(ks.groupId);Vt(l,`No group element found for id "${l}"`);const c=sy(l,s),u=$re(l,t,s);Vt(u!==null,`No resize element found for id "${t}"`);const f=o.shiftKey?u>0?u-1:c.length-1:u+1<c.length?u+1:0;c[f].focus();break}}};return r.addEventListener("keydown",a),()=>{r.removeEventListener("keydown",a)}},[s,e,t,n])}function Zre({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:s,id:r,onBlur:a,onClick:o,onDragging:l,onFocus:c,onPointerDown:u,onPointerUp:f,style:h={},tabIndex:m=0,tagName:g="div",...b}){var v,k;const w=x.useRef(null),C=x.useRef({onClick:o,onDragging:l,onPointerDown:u,onPointerUp:f});x.useEffect(()=>{C.current.onClick=o,C.current.onDragging=l,C.current.onPointerDown=u,C.current.onPointerUp=f});const E=x.useContext(JC);if(E===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:T,groupId:_,registerResizeHandle:j,startDragging:R,stopDragging:D,panelGroupElement:I}=E,O=oO(r),[L,B]=x.useState("inactive"),[H,K]=x.useState(!1),[U,$]=x.useState(null),q=x.useRef({state:L});hf(()=>{q.current.state=L}),x.useEffect(()=>{if(n)$(null);else{const V=j(O);$(()=>V)}},[n,O,j]);const J=(v=s==null?void 0:s.coarse)!==null&&v!==void 0?v:15,ne=(k=s==null?void 0:s.fine)!==null&&k!==void 0?k:5;x.useEffect(()=>{if(n||U==null)return;const V=w.current;Vt(V,"Element ref not attached");let G=!1;return Iqe(O,V,T,{coarse:J,fine:ne},(Z,Q,re)=>{if(!Q){B("inactive");return}switch(Z){case"down":{B("drag"),G=!1,Vt(re,'Expected event to be defined for "down" action'),R(O,re);const{onDragging:ae,onPointerDown:de}=C.current;ae==null||ae(!0),de==null||de();break}case"move":{const{state:ae}=q.current;G=!0,ae!=="drag"&&B("hover"),Vt(re,'Expected event to be defined for "move" action'),U(re);break}case"up":{B("hover"),D();const{onClick:ae,onDragging:de,onPointerUp:pe}=C.current;de==null||de(!1),pe==null||pe(),G||ae==null||ae();break}}})},[J,T,n,ne,j,O,U,R,D]),Xqe({disabled:n,handleId:O,resizeHandler:U,panelGroupElement:I});const F={touchAction:"none",userSelect:"none"};return x.createElement(g,{...b,children:e,className:t,id:r,onBlur:()=>{K(!1),a==null||a()},onFocus:()=>{K(!0),c==null||c()},ref:w,role:"separator",style:{...F,...h},tabIndex:m,[ks.groupDirection]:T,[ks.groupId]:_,[ks.resizeHandle]:"",[ks.resizeHandleActive]:L==="drag"?"pointer":H?"keyboard":void 0,[ks.resizeHandleEnabled]:!n,[ks.resizeHandleId]:O,[ks.resizeHandleState]:L})}Zre.displayName="PanelResizeHandle";class GB extends x.Component{constructor(){super(...arguments);nt(this,"state",{hasError:!1})}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(n,s){console.error("[RightPanel] Tab component error:",n,s)}componentDidUpdate(n){n.tabId!==this.props.tabId&&this.state.hasError&&this.setState({hasError:!1})}render(){return this.state.hasError?i.jsx("div",{className:"flex h-full items-center justify-center p-4",children:i.jsx("p",{className:"text-muted-foreground text-sm",children:"Something went wrong in this panel."})}):this.props.children}}const Qqe="flex-grow 300ms ease-in-out",Jqe="opacity 300ms ease-in-out";function eGe(){var k;const e=je(w=>w.rightPanelOpen),t=je(w=>w.setRightPanelOpen),n=je(w=>w.activeRightPanelTab),s=je(w=>w.setActiveRightPanelTab),r=Zs(),a=x.useRef(null),[o,l]=x.useState(!1),[c,u]=x.useState(!1);x.useEffect(()=>{const w=requestAnimationFrame(()=>u(!0));return()=>cancelAnimationFrame(w)},[]);const f=xy({select:w=>w.location.pathname}),m=Fu("right-panel").filter(w=>!w.visibleWhen||w.visibleWhen({pathname:f}));x.useEffect(()=>{m.length>0&&(m.some(C=>C.id===n)||s(m[0].id))},[m,n,s]);const g=e&&m.length>0;if(x.useEffect(()=>{const w=a.current;w&&(g&&w.isCollapsed()?w.expand():!g&&w.isExpanded()&&w.collapse())},[g]),m.length===0)return null;const b=(k=m.find(w=>w.id===n))==null?void 0:k.component;if(r)return g?i.jsx(Xl,{open:!0,onOpenChange:w=>!w&&t(!1),children:i.jsxs(Ql,{side:"right",showCloseButton:!1,className:"bg-sidebar text-sidebar-foreground flex w-full flex-col gap-0 p-0 sm:max-w-full",children:[i.jsxs(Jl,{className:"sr-only",children:[i.jsx(ec,{children:"Panel"}),i.jsx(ph,{children:"Right panel content."})]}),i.jsx(GB,{tabId:n,children:i.jsx(x.Suspense,{fallback:null,children:b&&i.jsx(b,{})})})]})}):null;const v=c&&!o;return i.jsxs(i.Fragment,{children:[i.jsx(Zre,{className:"group relative",style:{width:0,overflow:"visible"},disabled:!g,onDragging:l,children:i.jsx("div",{className:"absolute inset-y-0 -left-1 z-10 flex w-2 items-center justify-center",style:{opacity:g?1:0,pointerEvents:g?"auto":"none",...v&&{transition:Jqe}},children:i.jsx("div",{className:"group-hover:bg-ring/50 h-full w-px transition-colors duration-500"})})}),i.jsx(lO,{ref:a,id:"right-panel",order:2,defaultSize:g?35:0,minSize:20,collapsible:!0,collapsedSize:0,onCollapse:()=>t(!1),onExpand:()=>{e||t(!0)},style:v?{transition:Qqe}:void 0,children:i.jsx("div",{className:"bg-sidebar text-sidebar-foreground flex h-full flex-col overflow-hidden border-l",children:i.jsx("div",{className:"flex-1 overflow-hidden",children:i.jsx(GB,{tabId:n,children:i.jsx(x.Suspense,{fallback:null,children:b&&i.jsx(b,{})})})})})})]})}function tGe(){const e=je(c=>c.rightPanelOpen),t=je(c=>c.toggleRightPanel),n=xy({select:c=>c.location.pathname});if(Fu("right-panel").filter(c=>!c.visibleWhen||c.visibleWhen({pathname:n})).length===0)return null;const a=e?MTe:IX,o=e?"Close right panel":"Open right panel",l=Dm?"⌘.":"Ctrl+.";return i.jsxs(Kn,{children:[i.jsx(Wn,{asChild:!0,children:i.jsx(oe.button,{"aria-label":o,className:"text-muted-foreground hover:text-foreground relative flex h-7 w-7 items-center justify-center rounded-md transition-colors",onClick:t,whileHover:{scale:1.1},whileTap:{scale:.93},transition:{type:"spring",stiffness:600,damping:35},children:i.jsx(a,{className:"size-4"})})}),i.jsxs(Yn,{children:[i.jsx("span",{className:"pr-2",children:"Toggle right panel"}),i.jsx(Br,{className:"relative z-10",children:l})]})]})}function nGe(){const e=je(t=>t.loadRightPanelState);x.useEffect(()=>{e()},[e])}function sGe(){const e=je(t=>t.toggleRightPanel);x.useEffect(()=>{const t=n=>{(n.metaKey||n.ctrlKey)&&n.key==="."&&(n.preventDefault(),e())};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e])}function rGe(){const e=je(n=>n.setRightPanelOpen),t=je(n=>n.setActiveRightPanelTab);x.useEffect(()=>{const n=s=>{if((s.metaKey||s.ctrlKey)&&s.shiftKey&&s.key==="A"){s.preventDefault();const{rightPanelOpen:r,activeRightPanelTab:a}=je.getState();r&&a==="agent-hub"?e(!1):(t("agent-hub"),e(!0))}};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)},[e,t])}const aGe=x.lazy(()=>Ar(()=>import("./SessionsTab-BeSViVbi.js"),[]).then(e=>({default:e.SessionsTab}))),iGe=x.lazy(()=>Ar(()=>import("./ConfigTab-lJafANrQ.js"),[]).then(e=>({default:e.ConfigTab}))),oGe=x.lazy(()=>Ar(()=>import("./ToolkitTab-p2cUpDvj.js"),[]).then(e=>({default:e.ToolkitTab})));function nct(){const e=Eu(n=>n.activeTab),t={sessions:aGe,config:iGe,toolkit:oGe}[e];return i.jsx("div",{"data-slot":"agent-hub-tab-content",className:"flex-1 overflow-auto",children:i.jsx(x.Suspense,{fallback:null,children:i.jsx(t,{})})})}function lGe({onStepComplete:e}){const[t,n]=x.useState({...lVe}),[s,r]=x.useState(null),a=PUe(),{config:o}=fb(),l=je(u=>u.setDorkbotFirstMessage),c=x.useCallback(()=>{var h;r(null);const f=`${((h=o==null?void 0:o.agents)==null?void 0:h.defaultDirectory)||"~/.dork/agents"}/dorkbot`;a.mutate({path:f,updates:{traits:t}},{onSuccess:()=>{l(pqe(t)),xG(),e()},onError:m=>{r(m instanceof Error?m.message:"Failed to update personality")}})},[t,o,a,e,l]);return i.jsxs("div",{className:"flex flex-1 flex-col items-center gap-4 overflow-y-auto py-4",children:[i.jsxs("div",{className:"space-y-2 text-center",children:[i.jsx("h2",{className:"text-2xl font-semibold tracking-tight",children:"Meet DorkBot"}),i.jsxs("p",{className:"text-muted-foreground max-w-sm text-sm",children:["Your first agent and DorkOS expert.",i.jsx("br",{}),"Choose DorkBot's personality."]})]}),i.jsx(kqe,{traits:t,onTraitsChange:n,sampleLabel:"How DorkBot will talk"}),s&&i.jsx("p",{className:"text-destructive text-sm",role:"alert","data-testid":"update-error",children:s}),i.jsxs("div",{className:"mt-2 flex flex-col items-center gap-2",children:[i.jsx(ve,{onClick:c,disabled:a.isPending,"data-testid":"continue-dorkbot",children:a.isPending?"Saving...":"Continue"}),i.jsx("p",{className:"text-muted-foreground text-xs",children:"Adjustable anytime in settings."})]})]})}const KB={candidates:[],existingAgents:[],progress:null,isScanning:!1,error:null,lastScanAt:null},uO=Fo()(Au(e=>({...KB,startScan:()=>e({candidates:[],existingAgents:[],progress:null,isScanning:!0,error:null},!1,"discovery/startScan"),addCandidate:t=>e(n=>({candidates:[...n.candidates,t]}),!1,"discovery/addCandidate"),addExistingAgent:t=>e(n=>({existingAgents:[...n.existingAgents,t]}),!1,"discovery/addExistingAgent"),setProgress:t=>e({progress:t},!1,"discovery/setProgress"),completeScan:t=>e({progress:t,isScanning:!1,lastScanAt:new Date().toISOString()},!1,"discovery/completeScan"),setError:t=>e({error:t,isScanning:!1},!1,"discovery/setError"),reset:()=>e(KB,!1,"discovery/reset")}),{name:"DiscoveryStore"}));function Xre(){const e=Fe(),t=x.useRef(null),{startScan:n,addCandidate:s,addExistingAgent:r,setProgress:a,completeScan:o,setError:l}=uO(),c=x.useCallback((f={roots:[]})=>{var m;(m=t.current)==null||m.abort();const h=new AbortController;t.current=h,n(),e.scan(f,g=>{switch(g.type){case"candidate":s(g.data);break;case"existing-agent":r(g.data);break;case"progress":a(g.data);break;case"complete":o(g.data);break;case"error":l(g.data.error);break}},h.signal).catch(g=>{g instanceof Error&&g.name!=="AbortError"&&l(g.message)})},[e,n,s,r,a,o,l]),u=x.useCallback(()=>{var f;(f=t.current)==null||f.abort(),t.current=null},[]);return{startScan:c,stopScan:u}}function Qre(){const[e,t]=x.useState(new Set),n=x.useCallback(r=>{t(a=>new Set(a).add(r))},[]),s=x.useCallback(()=>{t(new Set)},[]);return{actedPaths:e,markActed:n,resetActed:s}}function jw(e){return{name:e.hints.suggestedName,runtime:e.hints.detectedRuntime,...e.hints.inferredCapabilities?{capabilities:e.hints.inferredCapabilities}:{},...e.hints.description?{description:e.hints.description}:{}}}function Jre(e){return[...e].sort((t,n)=>{const s=t.strategy==="dork-manifest",r=n.strategy==="dork-manifest";return s!==r?s?-1:1:t.path.localeCompare(n.path)})}const cGe={"claude-code":"Detected a AGENTS.md file — this is a Claude Code project.",cursor:"Detected a .cursor/ directory — this is a Cursor project.",codex:"Detected a .codex/ directory — this is a Codex project.","dork-manifest":"Found an existing .dork/agent.json — already configured as a DorkOS agent."};function uGe(e){return cGe[e]??`Detected via "${e}" strategy.`}const dGe={"code-review":"Reviews code for bugs, style issues, and correctness.",summarize:"Summarizes documents, conversations, or code.","file-ops":"Reads and writes files on the filesystem.",test:"Generates and runs tests for a codebase.",search:"Searches code, files, or the web for relevant information.",refactor:"Refactors code while preserving existing behavior.",analyze:"Analyzes data, logs, or codebases for patterns and insights.",generate:"Generates code, content, or structured output.",debug:"Diagnoses and fixes bugs in code.",deploy:"Manages deployment pipelines and infrastructure changes."};function fGe(e){return dGe[e]??"Agent capability detected from project structure."}function eae({candidate:e,onApprove:t,onDeny:n,onSkip:s,className:r}){const{path:a,strategy:o,hints:l}=e;return i.jsxs(oe.div,{"data-slot":"candidate-card",layout:!0,initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:-6},transition:{duration:.15,ease:"easeOut"},className:X("flex items-start justify-between rounded-xl border p-4",r),children:[i.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[i.jsx("p",{className:"text-sm leading-tight font-semibold",children:l.suggestedName||a.split("/").pop()||a}),i.jsxs("div",{className:"text-muted-foreground flex items-center gap-1.5 text-xs",children:[i.jsx(Gp,{className:"size-3 shrink-0"}),i.jsx("span",{className:"truncate font-mono",children:a})]}),i.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[i.jsxs(GD,{openDelay:300,children:[i.jsx(KD,{asChild:!0,children:i.jsx(Ot,{variant:"secondary",className:"hover:bg-secondary/80 cursor-default text-xs",children:l.detectedRuntime})}),i.jsxs(WD,{className:"w-56 space-y-1.5 p-3",side:"top",align:"start",children:[i.jsx("p",{className:"text-xs font-medium",children:"Detected runtime"}),i.jsx("p",{className:"text-muted-foreground text-xs",children:uGe(o)})]})]}),l.inferredCapabilities&&l.inferredCapabilities.length>0&&l.inferredCapabilities.map(c=>i.jsxs(Kn,{children:[i.jsx(Wn,{asChild:!0,children:i.jsx(Ot,{variant:"outline",className:"cursor-default text-[10px]",children:c})}),i.jsx(Yn,{side:"top",className:"max-w-48 text-center",children:fGe(c)})]},c))]})]}),i.jsxs("div",{className:"ml-4 flex shrink-0 items-center gap-1.5",children:[i.jsx("button",{type:"button",onClick:()=>t(e),className:"focus-visible:ring-ring rounded-md bg-green-600/10 px-2.5 py-1 text-xs font-medium text-green-700 hover:bg-green-600/20 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none dark:text-green-400",children:"Add"}),s&&i.jsx("button",{type:"button",onClick:()=>s(e),className:"text-muted-foreground hover:bg-muted focus-visible:ring-ring rounded-md px-2.5 py-1 text-xs font-medium focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",children:"Skip"}),n&&i.jsx("button",{type:"button",onClick:()=>n(e),className:"focus-visible:ring-ring rounded-md bg-red-600/10 px-2.5 py-1 text-xs font-medium text-red-700 hover:bg-red-600/20 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none dark:text-red-400",children:"Deny"})]})]})}function hGe({agent:e}){return i.jsxs("div",{className:"bg-muted/50 flex items-center gap-3 rounded-lg border px-4 py-3",children:[i.jsx(qf,{className:"text-muted-foreground size-4 shrink-0"}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("p",{className:"truncate text-sm font-medium",children:tn(e)}),i.jsx("p",{className:"text-muted-foreground truncate text-xs",children:e.path})]}),i.jsx("span",{className:"text-muted-foreground shrink-0 text-xs",children:"Imported"})]})}const pGe=2;function tae({agents:e}){const[t,n]=x.useState(e.length<=pGe);return e.length===0?null:i.jsxs("div",{children:[i.jsxs("button",{type:"button",onClick:()=>n(s=>!s),className:"text-muted-foreground hover:text-foreground flex w-full items-center gap-1.5 py-1.5 text-xs transition-colors",children:[i.jsx(Ws,{className:X("size-3 transition-transform",t&&"rotate-90")}),e.length," project",e.length===1?"":"s"," already in DorkOS"]}),t&&i.jsx("div",{className:"mt-2 space-y-2",children:e.map(s=>i.jsx(hGe,{agent:s},s.path))})]})}function nae({count:e,onAddAll:t,disabled:n}){return e===0?null:i.jsxs("div",{className:"flex items-center justify-between py-1",children:[i.jsxs("span",{className:"text-muted-foreground text-sm font-medium",children:[e," new project",e===1?"":"s"]}),i.jsx(ve,{variant:"outline",size:"sm",onClick:t,disabled:n,children:"Add All"})]})}function sae({roots:e,onChange:t}){const[n,s]=x.useState(""),[r,a]=x.useState(!1),o=x.useCallback(f=>{const h=f.trim();h&&!e.includes(h)&&t([...e,h])},[e,t]),l=x.useCallback(f=>{t(e.filter(h=>h!==f))},[e,t]),c=x.useCallback(f=>{(f.key==="Enter"||f.key===",")&&(f.preventDefault(),n.trim()&&(o(n),s(""))),f.key==="Backspace"&&n===""&&e.length>0&&l(e[e.length-1])},[n,e,o,l]),u=x.useCallback(f=>{o(f)},[o]);return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"focus-within:ring-ring flex min-h-[40px] flex-wrap items-center gap-1.5 rounded-md border bg-transparent px-3 py-1.5 focus-within:ring-2",children:[e.map(f=>i.jsxs(Ot,{variant:"secondary",className:"gap-1 py-0.5 font-mono text-xs",children:[f,i.jsx("button",{type:"button",onClick:()=>l(f),className:"hover:bg-muted-foreground/20 ml-0.5 rounded-sm","aria-label":`Remove ${f}`,children:i.jsx(ls,{className:"size-3"})})]},f)),i.jsx("input",{type:"text",value:n,onChange:f=>s(f.target.value),onKeyDown:c,placeholder:e.length===0?"Add paths to scan (Enter to add)":"Add more...",className:"placeholder:text-muted-foreground min-w-[120px] flex-1 bg-transparent text-sm focus-visible:outline-none"}),i.jsx("button",{type:"button",onClick:()=>a(!0),className:"text-muted-foreground hover:bg-accent hover:text-foreground shrink-0 rounded p-1","aria-label":"Browse for directory",children:i.jsx(Kf,{className:"size-4"})})]}),i.jsx(jC,{open:r,onOpenChange:a,onSelect:u})]})}function mGe({onAgentCreated:e}){var g;const[t,n]=x.useState(""),[s,r]=x.useState(""),[a,o]=x.useState(""),[l,c]=x.useState(!1),[u,f]=x.useState(!1),h=IUe(),m=x.useCallback(()=>{!t||!s.trim()||h.mutate({path:t,name:s.trim(),description:a.trim()||void 0},{onSuccess:()=>{f(!0),setTimeout(e,1200)}})},[t,s,a,h,e]);return u?i.jsxs("div",{className:"flex flex-col items-center justify-center space-y-4 py-12 text-center",children:[i.jsx(qf,{className:"text-primary size-12"}),i.jsx("h3",{className:"text-lg font-semibold",children:"Agent created"}),i.jsxs("p",{className:"text-muted-foreground text-sm",children:[i.jsx("span",{className:"font-medium",children:s})," is ready at"," ",i.jsx("span",{className:"font-mono text-xs",children:Pl(t)})]})]}):i.jsx("div",{className:"flex flex-col items-center justify-center",children:i.jsxs("div",{className:"w-full max-w-sm space-y-4",children:[i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(jn,{htmlFor:"agent-directory",children:"Project directory"}),i.jsxs("button",{id:"agent-directory",type:"button",onClick:()=>c(!0),className:`border-input bg-background hover:bg-accent flex h-10 w-full items-center gap-2 rounded-md border px-3 text-sm transition-colors ${t?"text-foreground":"text-muted-foreground"}`,children:[i.jsx(Kf,{className:"size-4 flex-shrink-0"}),i.jsx("span",{className:"truncate",children:t?Pl(t):"Select a directory..."})]}),i.jsx(jC,{open:l,onOpenChange:c,onSelect:n})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(jn,{htmlFor:"agent-name",children:"Agent name"}),i.jsx(_n,{id:"agent-name",type:"text",placeholder:"e.g. my-project",value:s,onChange:b=>r(b.target.value)})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs(jn,{htmlFor:"agent-persona",children:["Persona ",i.jsx("span",{className:"text-muted-foreground font-normal",children:"(optional)"})]}),i.jsx(K3,{id:"agent-persona",placeholder:"Describe what this agent does...",value:a,onChange:b=>o(b.target.value),rows:3})]}),i.jsx(ve,{className:"w-full",onClick:m,disabled:!t||!s.trim()||h.isPending,children:h.isPending?i.jsxs(i.Fragment,{children:[i.jsx(Xn,{className:"size-4 animate-spin"}),"Creating..."]}):"Create agent"}),h.isError&&i.jsxs("p",{className:"text-destructive text-center text-sm",children:["Failed to initialize agent. ",((g=h.error)==null?void 0:g.message)??"Please try again."]})]})})}function gGe({onStepComplete:e}){const{startScan:t}=Xre(),{candidates:n,existingAgents:s,isScanning:r,progress:a,error:o}=uO(),l=gre(),{actedPaths:c,markActed:u,resetActed:f}=Qre(),[h,m]=x.useState(!1),[g,b]=x.useState(!1),[v,k]=x.useState(3),{roots:w,setScanRoots:C}=yre(),[E,T]=x.useState(null),_=E??w,j=vr(),R=x.useRef(!1);x.useEffect(()=>{R.current||(R.current=!0,m(!0),t())},[t]);const D=x.useMemo(()=>r?n:Jre(n),[n,r]),I=x.useCallback(G=>{u(G.path),l.mutate({path:G.path,overrides:jw(G)})},[l,u]),O=x.useCallback(G=>{u(G.path)},[u]),L=x.useCallback(()=>{for(const G of D)c.has(G.path)||(u(G.path),l.mutate({path:G.path,overrides:jw(G)}))},[D,c,l,u]),B=x.useCallback(G=>{T(G),C(G)},[C]),H=x.useCallback(()=>{f(),m(!0),t(_.length>0?{roots:_,maxDepth:v}:{roots:[]})},[t,f,_,v]),K=x.useCallback(()=>{H()},[H]),U=s.length>0,$=n.length>0,q=U||$,J=h&&!r,ne=J&&!q,F=!$||n.every(G=>c.has(G.path)),V=D.filter(G=>!c.has(G.path));return i.jsxs("div",{className:"flex min-h-0 w-full flex-1 flex-col items-center",children:[i.jsxs("div",{className:"w-full shrink-0 text-center",children:[i.jsx("h2",{className:"text-2xl font-semibold tracking-tight sm:text-3xl",children:r&&!q?"Searching your machine...":ne?"Create Your First Agent":"Projects Found"}),r&&!q&&i.jsxs("div",{className:"mt-2 space-y-1",children:[i.jsx("p",{className:"text-muted-foreground text-sm",children:"Looking for existing projects on your machine."}),i.jsx("p",{className:"text-muted-foreground text-sm",children:"Once imported, your agents can work across them — and you can connect to Slack, Telegram, and more."})]}),ne&&i.jsx("p",{className:"text-muted-foreground mt-2 text-sm",children:"No projects were found on your machine."})]}),r&&!q&&i.jsxs("div",{className:"mt-8 flex shrink-0 flex-col items-center gap-4",children:[i.jsx(oe.div,{animate:j?{}:{scale:[1,1.15,1]},transition:{duration:1.5,repeat:1/0,ease:"easeInOut"},children:i.jsx(Ti,{className:"text-muted-foreground size-8"})}),a&&i.jsxs("p",{className:"text-muted-foreground text-sm",children:["Scanned ",a.scannedDirs," directories"]})]}),r&&q&&a&&i.jsxs("div",{className:"text-muted-foreground mt-4 shrink-0 text-center text-sm",children:["Scanning... ",a.scannedDirs," directories · Found ",a.foundAgents," ","project",a.foundAgents===1?"":"s"]}),J&&q&&i.jsx("p",{className:"text-muted-foreground mt-3 shrink-0 text-center text-sm",children:"Add existing projects you want to manage in DorkOS. You can assign agents, schedule tasks, and connect to Slack, Telegram, and more."}),o&&i.jsx("div",{className:"border-destructive/30 bg-destructive/5 text-destructive mt-6 shrink-0 rounded-lg border px-4 py-3 text-sm",children:o}),q&&i.jsx("div",{className:"mt-4 min-h-0 w-full flex-1 overflow-y-auto pr-1",children:i.jsxs("div",{className:"space-y-3",children:[V.length>0&&i.jsx(nae,{count:V.length,onAddAll:L}),i.jsx(He,{mode:"popLayout",children:V.map(G=>i.jsx(eae,{candidate:G,onApprove:I,onSkip:O},G.path))}),U&&i.jsx(tae,{agents:s})]})}),ne&&i.jsxs("div",{className:"mt-6 w-full",children:[i.jsx(mGe,{onAgentCreated:K}),i.jsxs("div",{className:"mt-4",children:[i.jsxs("button",{type:"button",onClick:()=>b(!g),className:"text-muted-foreground hover:text-foreground mx-auto flex items-center gap-1 text-xs",children:[i.jsx(Ps,{className:`size-3 transition-transform ${g?"":"-rotate-90"}`}),"Scan options"]}),g&&i.jsxs("div",{className:"bg-muted/30 mt-2 space-y-3 rounded-lg border p-3",children:[i.jsx(sae,{roots:_,onChange:B}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("label",{htmlFor:"onboarding-scan-depth",className:"text-muted-foreground text-xs",children:"Scan depth"}),i.jsx("input",{id:"onboarding-scan-depth",type:"range",min:1,max:5,value:v,onChange:G=>k(Number(G.target.value)),className:"flex-1"}),i.jsx("span",{className:"min-w-[1.5rem] text-center text-xs font-medium",children:v})]})]})]}),i.jsxs("div",{className:"mt-6 flex flex-col items-center gap-3",children:[i.jsx(ve,{variant:"outline",size:"sm",onClick:H,children:"Scan Again"}),i.jsx("button",{onClick:e,className:"text-muted-foreground hover:text-foreground text-sm transition-colors",children:"Continue without adding"})]})]}),J&&q&&i.jsx("div",{className:"mt-4 flex shrink-0 flex-col items-center gap-2 border-t pt-4",children:i.jsx(ve,{size:"lg",onClick:e,variant:F?"default":"outline",children:"Continue"})})]})}function xGe({onStepComplete:e,agents:t}){const{data:n,isLoading:s,isError:r}=tO(),a=Q5(),[o,l]=x.useState(null),[c,u]=x.useState(!1),[f,h]=x.useState(null),m=t.length===1?t[0]:t.find(C=>C.id===f)??null,g=x.useMemo(()=>o??new Set((n==null?void 0:n.map(C=>C.id))??[]),[o,n]),b=x.useCallback(C=>{l(E=>{const T=E??new Set((n==null?void 0:n.map(j=>j.id))??[]),_=new Set(T);return _.has(C)?_.delete(C):_.add(C),_})},[n]),v=g.size,k=v>0&&m!==null,w=x.useCallback(async()=>{if(!n||v===0||!m){e();return}u(!0);const C=n.filter(_=>g.has(_.id)),T=(await Promise.allSettled(C.map(_=>a.mutateAsync({name:_.name,description:_.description,prompt:_.prompt,cron:_.cron,target:m.id})))).filter(_=>_.status==="rejected");T.length>0&&(console.error("[TaskTemplatesStep] Schedule creation failures:",T),rt.warning(`${T.length} of ${C.length} schedule(s) failed to create. You can retry from Tasks later.`)),u(!1),e()},[n,v,g,m,a,e]);return i.jsxs("div",{className:"mx-auto w-full max-w-2xl flex-1 space-y-4 overflow-y-auto px-4",children:[i.jsxs("div",{className:"space-y-2 text-center",children:[i.jsx("h2",{className:"text-2xl font-semibold tracking-tight",children:"Want your agents to work while you sleep?"}),i.jsx("p",{className:"text-muted-foreground text-sm",children:"Tasks runs automated tasks on a schedule — like a cron job for your agents."})]}),t.length===1&&i.jsxs("p",{className:"text-muted-foreground text-center text-sm",children:["Scheduling for ",t[0].icon?`${t[0].icon} `:"",t[0].name]}),t.length>=2&&i.jsx("div",{className:"mx-auto max-w-xs",children:i.jsxs(Bn,{value:f??"",onValueChange:h,children:[i.jsx(Dn,{children:i.jsx($n,{placeholder:"Select a project..."})}),i.jsx(On,{children:t.map(C=>i.jsxs(yt,{value:C.id,children:[C.icon?`${C.icon} `:"",tn(C)]},C.id))})]})}),s&&i.jsx("p",{className:"text-muted-foreground text-center text-sm",children:"Loading presets..."}),r&&i.jsx("p",{className:"text-destructive text-center text-sm",children:"Failed to load presets. You can skip this step and configure schedules later."}),n&&n.length>0&&i.jsx("div",{className:"grid gap-3",children:n.map(C=>i.jsx(vre,{preset:C,variant:"toggle",checked:g.has(C.id),onCheckedChange:()=>b(C.id)},C.id))}),i.jsxs("div",{className:"flex flex-col items-center gap-3 pt-2",children:[i.jsx(ve,{onClick:w,size:"lg",disabled:c||v>0&&!k,children:c?"Creating...":v>0?`Create ${v} Schedule${v===1?"":"s"}`:"Continue Without Schedules"}),t.length>=2&&i.jsx("p",{className:"text-muted-foreground text-xs",children:"You can put your other agents on autopilot anytime from Tasks."})]})]})}const kN=["You're","all","set!"];function yGe({onComplete:e}){const t=vr(),{state:n}=fb(),s=x.useRef(!1);x.useEffect(()=>{s.current||(s.current=!0,u3())},[]);const r=n.completedSteps.includes("meet-dorkbot"),a=n.completedSteps.includes("discovery"),o=n.completedSteps.includes("tasks"),l=[{icon:zy,label:r?"Met DorkBot":"DorkBot skipped",done:r},{icon:Hy,label:a?"Agents discovered":"Agents skipped",done:a},{icon:Ja,label:o?"Schedules created":"Schedules skipped",done:o}];return i.jsxs(oe.div,{initial:t?!1:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{duration:.3,ease:"easeOut"},className:"mx-auto flex w-full max-w-md flex-col items-center gap-8 px-4 text-center",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx("h2",{className:"text-3xl font-semibold tracking-tight",children:t?kN.join(" "):i.jsx(oe.span,{initial:"hidden",animate:"visible",variants:{visible:{transition:{staggerChildren:.08}}},children:kN.map((c,u)=>i.jsxs(oe.span,{className:"inline-block",variants:{hidden:{opacity:0,filter:"blur(4px)"},visible:{opacity:1,filter:"blur(0px)"}},transition:{duration:.4},children:[c,u<kN.length-1?" ":""]},u))})}),i.jsx("p",{className:"text-muted-foreground",children:"Your workspace is configured and ready."})]}),i.jsx(oe.div,{className:"w-full space-y-3",initial:"hidden",animate:"visible",variants:t?{}:{visible:{transition:{staggerChildren:.12,delayChildren:.3}}},children:l.map(({icon:c,label:u,done:f})=>i.jsxs(oe.div,{variants:t?{}:{hidden:{opacity:0,y:12},visible:{opacity:1,y:0}},transition:{duration:.3},className:"flex items-center gap-3 rounded-lg border p-4",children:[i.jsx(c,{className:`size-5 ${f?"text-primary":"text-muted-foreground/50"}`}),i.jsx("span",{className:f?"text-sm":"text-muted-foreground text-sm",children:u})]},u))}),i.jsx(oe.div,{initial:t?!1:{opacity:0},animate:{opacity:1},transition:{delay:.8,duration:.4},children:i.jsx(qD,{className:"px-6 py-2",duration:1.2,onClick:e,children:"Start your first session"})})]})}const ex=["meet-dorkbot","discovery","tasks"],bGe=ex.indexOf("tasks"),CN=-2,WB=-1;function rae({onComplete:e,initialStep:t=CN}){var L;const[n,s]=x.useState(t),[r,a]=x.useState(1),[o,l]=x.useState(!1),{completeStep:c,skipStep:u,dismiss:f,startOnboarding:h,config:m}=fb(),g=cs(),b=Zs(),v=vr(),k=hb();x.useEffect(()=>{h()},[]);const w=x.useCallback(()=>{n<ex.length-1?(a(1),s(B=>B+1)):(c("adapters"),l(!0))},[n,c]),C=x.useCallback(()=>{n>0?(a(-1),s(B=>B-1)):n===0&&(a(-1),s(CN))},[n]),E=x.useCallback(()=>{c(ex[n]),w()},[n,c,w]),T=x.useCallback(()=>{u(ex[n]),w()},[n,u,w]),_=x.useCallback(async()=>{await f(),e()},[f,e]),j=x.useCallback(()=>{a(1),s(WB)},[]),R=x.useCallback(()=>{a(1),s(0)},[]),D=x.useCallback(()=>{var U,$;const B=((U=m==null?void 0:m.agents)==null?void 0:U.defaultAgent)||"dorkbot",K=`${(($=m==null?void 0:m.agents)==null?void 0:$.defaultDirectory)||"~/.dork/agents"}/${B}`;g({to:"/session",search:{dir:K}}),e()},[m,g,e]);if(x.useEffect(()=>{var B;n===bGe&&!k.isLoading&&((B=k.data)==null?void 0:B.agents.length)===0&&(c("tasks"),w())},[n,k.isLoading,k.data,c,w]),o)return i.jsx("div",{className:"bg-background flex h-full w-full items-center justify-center",children:i.jsx(yGe,{onComplete:D})});if(n===CN)return i.jsx("div",{className:"bg-background flex h-full w-full items-center justify-center",children:i.jsx(hqe,{onGetStarted:j,onSkip:_})});if(n===WB)return i.jsx("div",{className:"bg-background flex h-full w-full items-center justify-center",children:i.jsx(cqe,{onContinue:R})});const I=b?150:300,O=v?{enter:{opacity:0},center:{opacity:1},exit:{opacity:0}}:{enter:B=>({x:B>0?I:-I,opacity:0,scale:.98,filter:"blur(2px)"}),center:{x:0,opacity:1,scale:1,filter:"blur(0px)"},exit:B=>({x:B>0?-I:I,opacity:0,scale:.98,filter:"blur(2px)"})};return i.jsxs("div",{className:"bg-background flex h-full w-full flex-col",children:[i.jsx(nqe,{totalSteps:ex.length,currentStep:n,onBack:C,onSkip:T,onSkipAll:_}),i.jsx("div",{className:"relative flex-1 overflow-hidden",children:i.jsx(He,{mode:"wait",custom:r,children:i.jsx(oe.div,{custom:r,variants:O,initial:"enter",animate:"center",exit:"exit",transition:{type:v?"tween":"spring",damping:25,stiffness:200,duration:v?.15:void 0},className:"absolute inset-0 flex flex-col",children:i.jsxs("div",{className:"mx-auto flex min-h-0 w-full max-w-2xl flex-1 flex-col px-4 py-4 sm:px-6",children:[n===0&&i.jsx(lGe,{onStepComplete:E}),n===1&&i.jsx(gGe,{onStepComplete:E}),n===2&&i.jsx(xGe,{onStepComplete:E,agents:((L=k.data)==null?void 0:L.agents)??[]})]})},n)})})]})}const rE=["relay","bindings"];function pb(){const e=Fe();return mt({queryKey:[...rE],queryFn:()=>e.getBindings()})}function dO(){const e=Fe(),t=Ct();return mn({mutationFn:n=>e.createBinding(n),onSuccess:()=>{t.invalidateQueries({queryKey:[...rE]})}})}function vGe(){const e=Fe(),t=Ct();return mn({mutationFn:n=>e.deleteBinding(n),onSuccess:()=>{t.invalidateQueries({queryKey:[...rE]})}})}function SGe(){const e=Fe(),t=Ct();return mn({mutationFn:({id:n,updates:s})=>e.updateBinding(n,s),onSuccess:()=>{t.invalidateQueries({queryKey:[...rE]})}})}const fO={healthy:{dot:"bg-green-500",text:"text-green-600 dark:text-green-400",border:"border-l-green-500"},delivered:{dot:"bg-green-500",text:"text-green-600 dark:text-green-400",border:"border-l-green-500"},connected:{dot:"bg-green-500",text:"text-green-600 dark:text-green-400",border:"border-l-green-500"},pending:{dot:"bg-blue-500",text:"text-blue-600 dark:text-blue-400",border:"border-l-blue-500"},starting:{dot:"bg-blue-500",text:"text-blue-600 dark:text-blue-400",border:"border-l-blue-500"},new:{dot:"bg-blue-500",text:"text-blue-600 dark:text-blue-400",border:"border-l-blue-500"},reconnecting:{dot:"bg-amber-500",text:"text-amber-600 dark:text-amber-400",border:"border-l-amber-500"},degraded:{dot:"bg-amber-500",text:"text-amber-600 dark:text-amber-400",border:"border-l-amber-500"},warning:{dot:"bg-amber-500",text:"text-amber-600 dark:text-amber-400",border:"border-l-amber-500"},rate_limited:{dot:"bg-amber-500",text:"text-amber-600 dark:text-amber-400",border:"border-l-amber-500"},failed:{dot:"bg-red-500",text:"text-red-600 dark:text-red-400",border:"border-l-red-500"},error:{dot:"bg-red-500",text:"text-red-600 dark:text-red-400",border:"border-l-red-500"},disconnected:{dot:"bg-red-500",text:"text-red-600 dark:text-red-400",border:"border-l-red-500"},inactive:{dot:"bg-gray-400",text:"text-muted-foreground",border:"border-l-gray-400"},stopped:{dot:"bg-gray-400",text:"text-muted-foreground",border:"border-l-gray-400"}};function wGe(e){var t;return((t=fO[e])==null?void 0:t.dot)??"bg-gray-400"}function kGe(e){var t;return((t=fO[e])==null?void 0:t.text)??"text-muted-foreground"}function CGe(e){var t;return((t=fO[e])==null?void 0:t.border)??"border-l-gray-400"}function YR(e){const t=Date.now()-new Date(e).getTime(),n=Math.floor(t/1e3);if(n<60)return"just now";const s=Math.floor(n/60);if(s<60)return`${s}m ago`;const r=Math.floor(s/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function EGe(e){switch(e){case"delivered":return"bg-green-500";case"failed":return"bg-red-500";case"sent":return"bg-yellow-500";case"timeout":return"bg-gray-500";default:return"bg-gray-400"}}function TGe(e){return new Date(e).toLocaleTimeString()}function YB(e,t){if(e==null||t==null)return null;const n=new Date(t).getTime()-new Date(e).getTime();return n<1e3?`${n}ms`:`${(n/1e3).toFixed(1)}s`}function _Ge({messageId:e,onClose:t}){const{data:n,isLoading:s,error:r}=qUe(e);if(s)return i.jsx("div",{className:"text-muted-foreground p-4 text-sm",children:"Loading trace..."});if(r||!n)return i.jsx("div",{className:"text-destructive p-4 text-sm",children:"Failed to load trace."});const{traceId:a,spans:o}=n;return i.jsxs("div",{className:"flex flex-col gap-2 p-4",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("span",{className:"text-muted-foreground font-mono text-xs",children:["Trace: ",a.slice(0,8),"..."]}),t&&i.jsx("button",{onClick:t,className:"text-muted-foreground hover:text-foreground text-xs",children:"Close"})]}),i.jsx("div",{className:"border-border relative ml-3 border-l pl-6",children:o.map(l=>{const c=YB(l.sentAt,l.deliveredAt),u=YB(l.deliveredAt,l.processedAt);return i.jsxs("div",{className:"relative pb-4 last:pb-0",children:[i.jsx("div",{className:`absolute top-1 -left-[calc(1.5rem+0.3125rem)] h-2.5 w-2.5 rounded-full ${EGe(l.status)}`}),i.jsxs("div",{className:"flex flex-col gap-0.5",children:[i.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[i.jsx("span",{className:"font-medium",children:l.subject}),i.jsx("span",{className:"bg-muted rounded px-1.5 py-0.5 text-xs",children:l.status})]}),i.jsxs("div",{className:"text-muted-foreground flex gap-3 text-xs",children:[i.jsxs("span",{children:["Sent: ",TGe(l.sentAt)]}),c&&i.jsxs("span",{children:["Delivery: ",c]}),u&&i.jsxs("span",{children:["Processing: ",u]})]}),l.errorMessage&&i.jsx("div",{className:"bg-destructive/10 text-destructive mt-1 rounded px-2 py-1 text-xs",children:l.errorMessage})]})]},l.id)})})]})}const ZB=[{value:"per-chat",label:"Per Chat",description:"One session per chat/conversation. Messages from the same chat resume the same session."},{value:"per-user",label:"Per User",description:"One session per user. All messages from a user share a session across chats."},{value:"stateless",label:"Stateless",description:"Every message starts a new session. No conversation history."}],XB=[{value:"default",label:"Default",description:"Agent asks for approval before using any tools"},{value:"plan",label:"Plan Only",description:"Agent can read files but asks before making changes"},{value:"acceptEdits",label:"Accept Edits",description:"Agent can read and write files; asks before running shell commands"},{value:"bypassPermissions",label:"Full Access",description:"Agent can use all tools without asking for approval"}];function NGe({strategy:e,onStrategyChange:t,permissionMode:n,onPermissionModeChange:s,bypassWarningOpen:r,onBypassWarningOpenChange:a,onBypassConfirm:o,canInitiate:l,onCanInitiateChange:c,canReply:u,onCanReplyChange:f,canReceive:h,onCanReceiveChange:m,open:g,onOpenChange:b,hasChanges:v}){const k=ZB.find(C=>C.value===e),w=XB.find(C=>C.value===n);return i.jsxs(i.Fragment,{children:[i.jsxs(VD,{open:g,onOpenChange:b,trigger:"Advanced",badge:v?i.jsx(Ot,{variant:"secondary",className:"text-xs",children:"Modified"}):void 0,children:[i.jsxs("div",{className:"space-y-1.5 px-4 py-3",children:[i.jsx(jn,{htmlFor:"binding-session-strategy",children:"Session Strategy"}),i.jsxs(Bn,{value:e,onValueChange:C=>t(C),children:[i.jsx(Dn,{id:"binding-session-strategy",className:"w-full",children:i.jsx($n,{})}),i.jsx(On,{children:ZB.map(C=>i.jsx(yt,{value:C.value,children:C.label},C.value))})]}),k&&i.jsx("p",{className:"text-muted-foreground text-xs",children:k.description})]}),i.jsxs("div",{className:"space-y-1.5 px-4 py-3",children:[i.jsx(jn,{htmlFor:"binding-permission-mode",children:"Permission Mode"}),i.jsxs(Bn,{value:n,onValueChange:s,children:[i.jsx(Dn,{id:"binding-permission-mode",className:"w-full",children:i.jsx($n,{})}),i.jsx(On,{children:XB.map(C=>i.jsx(yt,{value:C.value,children:C.label},C.value))})]}),w&&i.jsx("p",{className:"text-muted-foreground text-xs",children:w.description})]}),i.jsxs("div",{className:"space-y-2.5 px-4 py-3",children:[i.jsx("p",{className:"text-muted-foreground text-xs font-medium",children:"Message Direction"}),i.jsxs("div",{className:"flex cursor-pointer items-center justify-between gap-3",children:[i.jsxs(jn,{htmlFor:"perm-initiate",className:"flex cursor-pointer items-center gap-1.5 text-xs font-normal",children:[i.jsx(Ho,{className:"text-muted-foreground size-3"}),"Agent can initiate messages"]}),i.jsx(Ks,{id:"perm-initiate",checked:l,onCheckedChange:c,"aria-label":"Agent can initiate messages"})]}),i.jsxs("div",{className:"flex cursor-pointer items-center justify-between gap-3",children:[i.jsx(jn,{htmlFor:"perm-reply",className:"cursor-pointer text-xs font-normal",children:"Agent can reply to messages"}),i.jsx(Ks,{id:"perm-reply",checked:u,onCheckedChange:f,"aria-label":"Agent can reply to messages"})]}),i.jsxs("div",{className:"flex cursor-pointer items-center justify-between gap-3",children:[i.jsx(jn,{htmlFor:"perm-receive",className:"cursor-pointer text-xs font-normal",children:"Agent receives inbound messages"}),i.jsx(Ks,{id:"perm-receive",checked:h,onCheckedChange:m,"aria-label":"Agent receives inbound messages"})]})]})]}),i.jsx(th,{open:r,onOpenChange:a,children:i.jsxs(Bu,{children:[i.jsxs(nh,{children:[i.jsx($u,{children:"Enable Full Access?"}),i.jsx(Hu,{children:"Any user who can send messages through this adapter (e.g., members of your Slack workspace) will be able to trigger unrestricted agent actions, including file system access and command execution."})]}),i.jsxs(sh,{children:[i.jsx(Vu,{children:"Cancel"}),i.jsx(Uu,{onClick:o,className:"bg-red-600 hover:bg-red-700 focus:ring-red-600",children:"Enable Full Access"})]})]})})]})}const mi="__any__",jGe={"per-chat":"One thread for each conversation","per-user":"One thread for each person",stateless:"No memory between messages"};function AGe({sessionStrategy:e,chatDisplayName:t,channelType:n}){const s=jGe[e];return t?`${s} in ${t}`:n?`${s} · ${n}`:s}const RGe=[{value:"dm",label:"Direct Message"},{value:"group",label:"Group"},{value:"channel",label:"Channel"},{value:"thread",label:"Thread"}];function MGe(e){return!!(e!=null&&e.canInitiate||(e==null?void 0:e.canReply)===!1||(e==null?void 0:e.canReceive)===!1||(e==null?void 0:e.permissionMode)!==void 0&&e.permissionMode!=="acceptEdits"||e!=null&&e.sessionStrategy&&e.sessionStrategy!=="per-chat")}function DGe(e){return{adapterId:(e==null?void 0:e.adapterId)??"",agentId:(e==null?void 0:e.agentId)??"",strategy:(e==null?void 0:e.sessionStrategy)??"per-chat",label:(e==null?void 0:e.label)??"",chatId:(e==null?void 0:e.chatId)??mi,channelType:(e==null?void 0:e.channelType)??mi,permissionMode:(e==null?void 0:e.permissionMode)??"acceptEdits",canInitiate:(e==null?void 0:e.canInitiate)??!1,canReply:(e==null?void 0:e.canReply)??!0,canReceive:(e==null?void 0:e.canReceive)??!0}}function aae({open:e,onOpenChange:t,onConfirm:n,mode:s,initialValues:r,adapterName:a,agentName:o,onDelete:l,bindingId:c,isPending:u}){const f=s==="edit",[h,m]=x.useState(()=>!!(r!=null&&r.chatId||r!=null&&r.channelType)),[g,b]=x.useState(()=>MGe(r)),[v,k]=x.useState(!1),[w]=x.useState(()=>DGe(r)),C=eC({defaultValues:w,onSubmit:async({value:B})=>{await n({adapterId:B.adapterId,agentId:B.agentId,sessionStrategy:B.strategy,label:B.label,permissionMode:B.permissionMode,chatId:B.chatId===mi?void 0:B.chatId,channelType:B.channelType===mi?void 0:B.channelType,canInitiate:B.canInitiate,canReply:B.canReply,canReceive:B.canReceive}),f||C.reset()}}),{data:E=[]}=ug(),{data:T}=ji(),[_,j]=x.useState(()=>(r==null?void 0:r.adapterId)??""),{data:R=[]}=YUe(_||void 0),D=E.flatMap(B=>B.instances.filter(H=>H.enabled).map(H=>({id:H.id,label:H.label?`${H.label} (${B.manifest.displayName})`:`${H.id} (${B.manifest.displayName})`}))),I=(T==null?void 0:T.agents)??[];function O(B){B==="bypassPermissions"?k(!0):C.setFieldValue("permissionMode",B)}function L(){C.setFieldValue("chatId",mi),C.setFieldValue("channelType",mi)}return i.jsx(Ta,{open:e,onOpenChange:t,children:i.jsxs(_a,{className:"max-h-[85vh] max-w-md gap-0 p-0",children:[i.jsxs(Ni,{className:"border-b px-4 py-3",children:[i.jsx(ei,{children:f?"Edit Binding":"Create Binding"}),i.jsx(Ji,{className:"sr-only",children:f?"Modify the binding configuration":"Configure how the adapter connects to the agent"})]}),i.jsx(C.Subscribe,{selector:B=>({values:B.values,isSubmitting:B.isSubmitting}),children:({values:B,isSubmitting:H})=>{var G;const K=f||!!B.adapterId&&!!B.agentId,U=!f||B.adapterId!==w.adapterId||B.agentId!==w.agentId||B.strategy!==w.strategy||B.label!==w.label||B.chatId!==w.chatId||B.channelType!==w.channelType||B.permissionMode!==w.permissionMode||B.canInitiate!==w.canInitiate||B.canReply!==w.canReply||B.canReceive!==w.canReceive,$=f?o:(G=I.find(P=>P.id===B.agentId))==null?void 0:G.name,q=K&&$?`${AGe({sessionStrategy:B.strategy,chatDisplayName:B.chatId!==mi?`#${B.chatId}`:void 0,channelType:B.channelType!==mi?B.channelType:void 0})} — routed to ${$}.`:null,J=B.chatId!==mi||B.channelType!==mi,ne=B.strategy!=="per-chat"||B.permissionMode!=="acceptEdits"||B.canInitiate||!B.canReply||!B.canReceive,F=!K||!U||!!u||H,V=!!u||H;return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"space-y-5 overflow-y-auto px-4 py-5",children:[f?i.jsxs("p",{className:"text-muted-foreground text-sm",children:["Binding: ",i.jsx("span",{className:"text-foreground font-medium",children:a})," to"," ",i.jsx("span",{className:"text-foreground font-medium",children:o})]}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(jn,{htmlFor:"binding-adapter",children:"Adapter"}),D.length===0?i.jsx("p",{className:"text-muted-foreground border-input rounded-md border px-3 py-2 text-sm opacity-50",children:"No adapters configured"}):i.jsx(C.AppField,{name:"adapterId",children:P=>i.jsxs(Bn,{value:P.state.value,onValueChange:Z=>{P.handleChange(Z),j(Z)},children:[i.jsx(Dn,{id:"binding-adapter",className:"w-full",children:i.jsx($n,{placeholder:"Select an adapter"})}),i.jsx(On,{children:D.map(Z=>i.jsx(yt,{value:Z.id,children:Z.label},Z.id))})]})})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(jn,{htmlFor:"binding-agent",children:"Agent"}),I.length===0?i.jsx("p",{className:"text-muted-foreground border-input rounded-md border px-3 py-2 text-sm opacity-50",children:"No agents registered"}):i.jsx(C.AppField,{name:"agentId",children:P=>i.jsxs(Bn,{value:P.state.value,onValueChange:P.handleChange,children:[i.jsx(Dn,{id:"binding-agent",className:"w-full",children:i.jsx($n,{placeholder:"Select an agent"})}),i.jsx(On,{children:I.map(Z=>i.jsx(yt,{value:Z.id,children:tn(Z)},Z.id))})]})})]})]}),i.jsx(C.AppField,{name:"label",children:P=>i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(jn,{htmlFor:"binding-label",children:"Label (optional)"}),i.jsx(_n,{id:"binding-label",placeholder:"e.g., Customer support bot",value:P.state.value,onBlur:P.handleBlur,onChange:Z=>P.handleChange(Z.target.value)}),i.jsx(Ei,{children:"A display name for this binding"})]})}),i.jsxs(VD,{open:h,onOpenChange:m,trigger:"Chat Filter",badge:J?i.jsx(Ot,{variant:"secondary",className:"text-xs",children:"Active"}):void 0,children:[i.jsx(C.AppField,{name:"chatId",children:P=>i.jsxs("div",{className:"space-y-1.5 px-4 py-3",children:[i.jsx(jn,{htmlFor:"binding-chat-id",children:"Chat ID"}),i.jsxs(Bn,{value:P.state.value,onValueChange:P.handleChange,children:[i.jsx(Dn,{id:"binding-chat-id",className:"w-full",children:i.jsx($n,{placeholder:"Any chat (wildcard)"})}),i.jsxs(On,{children:[i.jsx(yt,{value:mi,children:"Any chat (wildcard)"}),R.map(Z=>i.jsxs(yt,{value:Z.chatId,children:[i.jsx("span",{children:Z.displayName??Z.chatId}),(Z.channelType||Z.messageCount>0)&&i.jsx("span",{className:"text-muted-foreground ml-2 text-xs",children:[Z.channelType,`${Z.messageCount} msgs`].filter(Boolean).join(" · ")})]},Z.chatId))]})]}),i.jsx(Ei,{children:"Route only messages from a specific chat or channel"})]})}),i.jsx(C.AppField,{name:"channelType",children:P=>i.jsxs("div",{className:"space-y-1.5 px-4 py-3",children:[i.jsx(jn,{htmlFor:"binding-channel-type",children:"Channel Type"}),i.jsxs(Bn,{value:P.state.value,onValueChange:P.handleChange,children:[i.jsx(Dn,{id:"binding-channel-type",className:"w-full",children:i.jsx($n,{placeholder:"Any type (wildcard)"})}),i.jsxs(On,{children:[i.jsx(yt,{value:mi,children:"Any type (wildcard)"}),RGe.map(Z=>i.jsx(yt,{value:Z.value,children:Z.label},Z.value))]})]})]})}),J&&i.jsx("div",{className:"px-4 py-3",children:i.jsx(ve,{variant:"ghost",size:"sm",onClick:L,children:"Clear filters"})})]}),i.jsx(NGe,{strategy:B.strategy,onStrategyChange:P=>C.setFieldValue("strategy",P),permissionMode:B.permissionMode,onPermissionModeChange:O,bypassWarningOpen:v,onBypassWarningOpenChange:k,onBypassConfirm:()=>C.setFieldValue("permissionMode","bypassPermissions"),canInitiate:B.canInitiate,onCanInitiateChange:P=>C.setFieldValue("canInitiate",P),canReply:B.canReply,onCanReplyChange:P=>C.setFieldValue("canReply",P),canReceive:B.canReceive,onCanReceiveChange:P=>C.setFieldValue("canReceive",P),open:g,onOpenChange:b,hasChanges:ne}),q&&i.jsx("p",{className:"text-muted-foreground bg-muted/50 rounded-md px-3 py-2 text-xs italic",children:q})]}),i.jsxs(Qy,{className:"border-t px-4 py-3",children:[f&&l&&c&&i.jsxs(th,{children:[i.jsx(iee,{asChild:!0,children:i.jsxs(ve,{variant:"ghost",size:"sm",className:"mr-auto text-red-600 hover:bg-red-50 hover:text-red-700 dark:hover:bg-red-950",children:[i.jsx(Yf,{className:"mr-1.5 size-3.5"}),"Delete"]})}),i.jsxs(Bu,{children:[i.jsxs(nh,{children:[i.jsx($u,{children:"Delete binding"}),i.jsx(Hu,{children:"Are you sure you want to delete this binding? The adapter will no longer route messages to the connected agent."})]}),i.jsxs(sh,{children:[i.jsx(Vu,{children:"Cancel"}),i.jsx(Uu,{onClick:()=>l(c),className:"bg-red-600 hover:bg-red-700 focus:ring-red-600",children:"Delete"})]})]})]}),i.jsx(ve,{variant:"ghost",size:"sm",onClick:()=>t(!1),children:"Cancel"}),i.jsxs(ve,{size:"sm",onClick:()=>C.handleSubmit(),disabled:F,children:[V&&i.jsx(Xn,{className:"mr-1.5 size-3.5 animate-spin"}),V?"Saving...":f?"Save Changes":"Create Binding"]})]})]})}})]})})}function EN(e){if(e.payload&&typeof e.payload=="object"){const n=e.payload;if(typeof n.adapterId=="string")return n.adapterId}const t=e.from.raw.match(/^relay\.human\.([^.]+)/);return t?t[1]:""}function QB(e){if(e.payload&&typeof e.payload=="object"){const t=e.payload;if(typeof t.chatId=="string")return t.chatId}}function JB(e){if(e.payload&&typeof e.payload=="object"){const n=e.payload.channelType;if(n==="dm"||n==="group"||n==="channel"||n==="thread")return n}}const OGe={delivered:"Delivered",failed:"Failed",pending:"Pending"};function e7(e){return new Date(e).toLocaleTimeString([],{hour:"numeric",minute:"2-digit",second:"2-digit"})}function IGe(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function PGe(e){return e.status==="delivered"?e.responseCount>0?`delivered · ${e.responseCount} chunks`:"delivered":e.failureReason??OGe[e.status].toLowerCase()}function LGe({conversation:e}){const[t,n]=x.useState(!1),[s,r]=x.useState(!1),[a,o]=x.useState(!1),[l,c]=x.useState(""),[u,f]=x.useState(!1),[h,m]=x.useState(!1),{data:g}=ji(),b=x.useMemo(()=>(g==null?void 0:g.agents)??[],[g]),{mutate:v}=dO(),{data:k=[]}=pb(),w=EN(e),C=x.useMemo(()=>k.filter(I=>I.adapterId===w),[k,w]),E=wGe(e.status),T=kGe(e.status),_=CGe(e.status),j=x.useCallback(()=>{b.find(O=>O.id===l)&&(v({adapterId:EN(e),agentId:l,sessionStrategy:"per-chat",label:"",chatId:QB(e),channelType:JB(e)}),c(""),f(!1))},[b,l,e,v]),R=x.useCallback(()=>{f(!1),m(!0)},[]),D=x.useCallback(I=>{v({adapterId:I.adapterId,agentId:I.agentId,sessionStrategy:I.sessionStrategy,label:I.label,chatId:I.chatId,channelType:I.channelType,canInitiate:I.canInitiate,canReply:I.canReply,canReceive:I.canReceive}),m(!1)},[v]);return i.jsxs("div",{className:X("hover:bg-muted/50 w-full rounded-lg border border-l-2 text-left transition-colors hover:shadow-sm",_,t&&"bg-muted/30"),children:[i.jsxs("div",{className:"flex items-start gap-2 p-3",children:[i.jsxs("button",{type:"button",onClick:()=>n(!t),className:"flex min-w-0 flex-1 items-start gap-2",children:[i.jsx("span",{className:X("mt-1 size-2 shrink-0 rounded-full",E)}),i.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[i.jsxs("div",{className:"text-muted-foreground text-xs",children:[i.jsx("span",{className:"inline-block w-8 font-medium",children:"From"}),i.jsx("span",{className:"text-foreground",children:e.from.label})]}),i.jsxs("div",{className:"text-muted-foreground text-xs",children:[i.jsx("span",{className:"inline-block w-8 font-medium",children:"To"}),i.jsx("span",{className:"text-foreground",children:e.to.label})]}),i.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.preview&&i.jsxs("span",{className:"text-muted-foreground min-w-0 flex-1 truncate text-xs",children:['"',e.preview,'"']}),i.jsx("span",{className:X("shrink-0 text-xs",T),children:PGe(e)})]})]})]}),i.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[i.jsx("span",{className:"text-muted-foreground text-xs",children:YR(e.sentAt)}),i.jsxs(eg,{open:u,onOpenChange:f,children:[i.jsx(tg,{asChild:!0,children:i.jsxs(ve,{variant:"ghost",size:"sm",className:"h-6 px-1.5 text-xs",onClick:I=>I.stopPropagation(),"aria-label":"Route to agent",children:[i.jsx(zX,{className:"mr-1 size-3"}),"Route"]})}),i.jsxs(ng,{className:"w-64 space-y-3 p-3",align:"end",children:[i.jsx("p",{className:"text-xs font-medium",children:"Route to Agent"}),C.length>0&&i.jsx("div",{className:"rounded border border-blue-200 bg-blue-50 px-2 py-1.5 text-xs dark:border-blue-900 dark:bg-blue-950",children:i.jsxs("p",{className:"font-medium text-blue-800 dark:text-blue-200",children:[C.length," binding",C.length!==1?"s":""," ","already exist",C.length===1?"s":""," for this adapter"]})}),i.jsxs(Bn,{value:l,onValueChange:c,children:[i.jsx(Dn,{className:"h-8 text-xs",children:i.jsx($n,{placeholder:"Select agent"})}),i.jsx(On,{children:b.map(I=>i.jsx(yt,{value:I.id,children:tn(I)},I.id))})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx(ve,{variant:"link",size:"sm",className:"h-6 px-0 text-xs",onClick:R,children:"More options..."}),i.jsx(ve,{size:"sm",className:"h-7 text-xs",disabled:!l,onClick:j,children:"Create Binding"})]})]})]})]})]}),h&&i.jsx(aae,{open:!0,onOpenChange:I=>{I||m(!1)},mode:"create",initialValues:{adapterId:EN(e),agentId:l||void 0,chatId:QB(e),channelType:JB(e)},onConfirm:D}),i.jsx(He,{initial:!1,children:t&&i.jsx(oe.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:"easeOut"},className:"overflow-hidden",children:i.jsxs("div",{className:"space-y-3 border-t px-3 pt-3 pb-3",children:[e.payload!=null&&i.jsxs("div",{children:[i.jsx("span",{className:"text-muted-foreground text-xs font-medium",children:"Payload"}),i.jsx("pre",{className:"bg-muted mt-1 max-h-40 overflow-auto rounded p-2 font-mono text-xs",children:JSON.stringify(e.payload,null,2)})]}),i.jsxs("div",{className:"text-muted-foreground text-xs",children:[i.jsxs("span",{children:["Sent ",e7(e.sentAt)]}),e.completedAt&&i.jsxs("span",{children:[" · Completed ",e7(e.completedAt)]}),e.durationMs!=null&&i.jsxs("span",{children:[" · Duration: ",IGe(e.durationMs)]}),e.responseCount>0&&i.jsxs("span",{children:[" · ",e.responseCount," response chunks"]})]}),e.failureReason&&i.jsx("div",{className:"bg-destructive/10 text-destructive rounded px-2 py-1 text-xs",children:e.failureReason}),i.jsxs("button",{type:"button",onClick:I=>{I.stopPropagation(),r(!s)},className:"text-muted-foreground hover:text-foreground flex items-center gap-1.5 text-xs",children:[s?i.jsx(Ps,{className:"size-3.5"}):i.jsx(Ws,{className:"size-3.5"}),"Technical Details"]}),i.jsx(He,{initial:!1,children:s&&i.jsx(oe.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15},className:"overflow-hidden",children:i.jsxs("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-xs",children:[i.jsx("dt",{className:"text-muted-foreground",children:"Subject"}),i.jsx("dd",{className:"truncate font-mono",children:e.subject}),e.sessionId&&i.jsxs(i.Fragment,{children:[i.jsx("dt",{className:"text-muted-foreground",children:"Session"}),i.jsx("dd",{className:"font-mono",children:e.sessionId.slice(0,8)})]}),e.traceId&&i.jsxs(i.Fragment,{children:[i.jsx("dt",{className:"text-muted-foreground",children:"Trace ID"}),i.jsxs("dd",{className:"font-mono",children:[e.traceId.slice(0,12),"…"]})]}),i.jsx("dt",{className:"text-muted-foreground",children:"Source"}),i.jsx("dd",{className:"truncate font-mono",children:e.from.raw}),i.jsx("dt",{className:"text-muted-foreground",children:"Destination"}),i.jsx("dd",{className:"truncate font-mono",children:e.to.raw})]})})}),e.traceId&&i.jsxs(i.Fragment,{children:[i.jsxs("button",{type:"button",onClick:I=>{I.stopPropagation(),o(!a)},className:"text-muted-foreground hover:text-foreground flex items-center gap-1.5 text-xs",children:[a?i.jsx(Ps,{className:"size-3.5"}):i.jsx(Ws,{className:"size-3.5"}),"Trace Timeline"]}),i.jsx(He,{initial:!1,children:a&&i.jsx(oe.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15},className:"overflow-hidden",children:i.jsx(_Ge,{messageId:e.traceId,onClose:()=>o(!1)})})})]})]})})})]})}const FGe={hop_limit:{label:"Hop Limit",className:"bg-orange-100 text-orange-700 dark:bg-orange-900/30 dark:text-orange-400"},ttl_expired:{label:"TTL Expired",className:"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400"},cycle_detected:{label:"Cycle Detected",className:"bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-400"},budget_exhausted:{label:"Budget Exhausted",className:"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400"}},zGe={label:"Unknown",className:"bg-muted text-muted-foreground"};function BGe(e,t){const n=YR(e),s=YR(t);return n===s?s:`${n} — ${s}`}function $Ge({group:e}){const[t,n]=x.useState(!1),s=cre(),r=FGe[e.reason]??zGe;return i.jsx("div",{className:"rounded-lg border border-red-200 bg-red-50/50 p-3 dark:border-red-900/40 dark:bg-red-950/20",children:i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsx(Yr,{className:"mt-0.5 size-4 shrink-0 text-red-500"}),i.jsxs("div",{className:"min-w-0 flex-1 space-y-1.5",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"truncate text-sm font-medium",children:e.source}),i.jsx(Ot,{className:X("shrink-0 border-0 text-xs font-normal",r.className),children:r.label}),i.jsx(Ot,{variant:"destructive",className:"shrink-0 tabular-nums",children:e.count.toLocaleString()})]}),i.jsx("p",{className:"text-muted-foreground text-xs",children:BGe(e.firstSeen,e.lastSeen)})]}),i.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[e.sample!=null&&i.jsxs(i.Fragment,{children:[i.jsxs(ve,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>n(!0),children:[i.jsx(Y3,{className:"mr-1 size-3"}),"View Sample"]}),i.jsx(ah,{open:t,onOpenChange:n,children:i.jsxs(Gu,{className:"max-w-lg",children:[i.jsxs(Ku,{children:[i.jsx(Wu,{children:"Sample Envelope"}),i.jsxs(Yu,{children:["Representative failure from ",e.source," (",r.label,")"]})]}),i.jsx("pre",{className:"bg-muted max-h-80 overflow-auto rounded-md p-3 font-mono text-xs",children:JSON.stringify(e.sample,null,2)})]})})]}),i.jsxs(th,{children:[i.jsx(iee,{asChild:!0,children:i.jsxs(ve,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground h-7 px-2 text-xs",disabled:s.isPending,children:[i.jsx(Yf,{className:"mr-1 size-3"}),"Mark Resolved"]})}),i.jsxs(Bu,{children:[i.jsxs(nh,{children:[i.jsx($u,{children:"Mark dead letters as resolved?"}),i.jsxs(Hu,{children:["This will dismiss ",e.count," dead letter",e.count!==1?"s":""," from"," ",i.jsx("span",{className:"font-medium",children:e.source})," (",r.label,"). This action cannot be undone."]})]}),i.jsxs(sh,{children:[i.jsx(Vu,{children:"Cancel"}),i.jsx(Uu,{onClick:()=>s.mutate({source:e.source,reason:e.reason}),children:"Mark Resolved"})]})]})]})]})]})})}function HGe({enabled:e=!0}){const{data:t=[],isLoading:n}=dg(e),{data:s}=X5(),r=s==null?void 0:s.budgetRejections,a=r&&Object.values(r).some(o=>o>0);return n||t.length===0?null:i.jsxs("div",{className:"space-y-2",children:[a&&i.jsx("div",{className:"rounded-md border border-amber-200 bg-amber-50 px-3 py-2 dark:border-amber-900 dark:bg-amber-950",children:i.jsxs("p",{className:"text-xs font-medium text-amber-800 dark:text-amber-200",children:["Budget rejections: ",r.hopLimit," hop limit,"," ",r.cycleDetected," cycles, ",r.budgetExhausted," budget,"," ",r.ttlExpired," TTL"]})}),t.map(o=>i.jsx($Ge,{group:o},`${o.source}:${o.reason}`))]})}function UGe(e){try{return JSON.parse(e)}catch{return{content:e}}}const VGe=me({subject:W().min(1,"Subject is required"),from:W().min(1,"From is required"),payload:W().min(1,"Payload is required")});function qGe({open:e,onOpenChange:t}={}){const[n,s]=x.useState(!1),r=e!==void 0,a=r?e:n,o=FUe(),l=eC({defaultValues:{subject:"",from:"relay.human.console",payload:""},validators:{onSubmit:VGe},onSubmit:({value:u})=>{o.mutate({subject:u.subject,from:u.from,payload:UGe(u.payload)},{onSuccess:()=>{rt.success("Message sent"),l.reset(),c(!1)}})}});function c(u){r?t==null||t(u):s(u),u||l.reset()}return i.jsxs(ah,{open:a,onOpenChange:c,children:[!r&&i.jsx(xee,{asChild:!0,children:i.jsxs(ve,{variant:"ghost",size:"sm",className:"gap-1.5","data-testid":"compose-trigger",children:[i.jsx(LTe,{className:"size-3.5"}),"Compose"]})}),i.jsxs(Gu,{children:[i.jsxs(Ku,{children:[i.jsx(Wu,{children:"Send Test Message"}),i.jsx(Yu,{children:"Compose a message to send through the Relay bus."})]}),i.jsx(l.AppForm,{children:i.jsxs("form",{onSubmit:u=>{u.preventDefault(),l.handleSubmit()},className:"space-y-4",children:[i.jsx(l.AppField,{name:"subject",children:u=>i.jsx(u.TextField,{label:"Subject",placeholder:"e.g. relay.test.ping"})}),i.jsx(l.AppField,{name:"from",children:u=>i.jsx(u.TextField,{label:"From"})}),i.jsx(l.AppField,{name:"payload",children:u=>i.jsx(u.TextareaField,{label:"Payload",placeholder:'Plain text or JSON (e.g. {"content": "hello"})',rows:4})}),i.jsx("div",{className:"flex justify-end",children:i.jsxs(ve,{type:"submit",disabled:o.isPending,children:[i.jsx(c_e,{className:"mr-2 size-4"}),"Send"]})})]})})]})]})}function GGe({enabled:e}){const{data:t}=X5();if(!e||!t)return null;const n=[{label:"Total",value:t.totalMessages,variant:"default"},{label:"Delivered",value:t.deliveredCount,variant:"success"},{label:"Failed",value:t.failedCount,variant:t.failedCount>0?"danger":"default"},{label:"Dead Letter",value:t.deadLetteredCount,variant:t.deadLetteredCount>0?"warning":"default"}];return i.jsxs("div",{className:"flex items-center gap-3 border-b px-4 py-2",children:[n.map(({label:s,value:r,variant:a})=>i.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[i.jsx("span",{className:"text-muted-foreground",children:s}),i.jsx("span",{className:X("font-medium tabular-nums",a==="success"&&r>0&&"text-green-600 dark:text-green-500",a==="danger"&&"text-red-600 dark:text-red-500",a==="warning"&&"text-amber-600 dark:text-amber-500"),children:r.toLocaleString()})]},s)),t.avgDeliveryLatencyMs!=null&&i.jsxs("div",{className:"ml-auto flex items-center gap-1.5 text-xs",children:[i.jsx("span",{className:"text-muted-foreground",children:"Avg"}),i.jsx("span",{className:"font-medium tabular-nums",children:t.avgDeliveryLatencyMs<1e3?`${Math.round(t.avgDeliveryLatencyMs)}ms`:`${(t.avgDeliveryLatencyMs/1e3).toFixed(1)}s`})]})]})}function KGe(e){return e.startsWith("relay.agent.")?"chat":e.startsWith("relay.system.tasks.")?"tasks":"system"}const WGe={initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,height:0},transition:{duration:.2,ease:"easeOut"}},YGe={initial:!1,animate:{opacity:1,y:0},exit:{opacity:0,height:0},transition:{duration:.2,ease:"easeOut"}};function ZGe(e,t,n,s){return e.filter(r=>{if(t!=="all"&&KGe(r.subject)!==t||n!=="all"&&r.status!==n)return!1;if(s){const a=s.toLowerCase();if(!(r.from.label.toLowerCase().includes(a)||r.to.label.toLowerCase().includes(a)||r.preview.toLowerCase().includes(a)||r.subject.toLowerCase().includes(a)))return!1}return!0})}function XGe({enabled:e,deadLetterRef:t,onSwitchToChannels:n,autoShowFailures:s}){const[r,a]=x.useState("all"),[o,l]=x.useState("all"),[c,u]=x.useState(""),[f,h]=x.useState(!1),[m,g]=x.useState(!1),{data:b,isLoading:v}=KUe(e),{data:k=[]}=dg(e),w=x.useMemo(()=>(b==null?void 0:b.conversations)??[],[b==null?void 0:b.conversations]);k.length>0;const C=x.useRef(null);x.useEffect(()=>{w.length>0&&C.current===null&&(C.current=new Set(w.map(j=>j.id)))},[w]),x.useEffect(()=>{!m&&k.length>0&&h(!0)},[k.length,m]),x.useEffect(()=>{s&&(h(!0),g(!1))},[s]);const E=r!=="all"||o!=="all"||c!=="",T=ZGe(w,r,o,c);function _(){a("all"),l("all"),u("")}return v?i.jsx("div",{className:"space-y-2 p-4",children:[1,2,3].map(j=>i.jsx("div",{className:"rounded-lg border p-3",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:"bg-muted animate-tasks size-4 rounded"}),i.jsx("div",{className:"bg-muted animate-tasks h-4 w-40 rounded"}),i.jsx("div",{className:"bg-muted animate-tasks ml-auto h-3 w-16 rounded"})]})},j))}):i.jsxs(i.Fragment,{children:[i.jsx(GGe,{enabled:e}),i.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[i.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[i.jsxs(Bn,{value:r,onValueChange:j=>a(j),children:[i.jsx(Dn,{className:"w-32",children:i.jsx($n,{})}),i.jsxs(On,{children:[i.jsx(yt,{value:"all",children:"All sources"}),i.jsx(yt,{value:"chat",children:"Chat messages"}),i.jsx(yt,{value:"tasks",children:"Tasks jobs"}),i.jsx(yt,{value:"system",children:"System"})]})]}),i.jsxs(Bn,{value:o,onValueChange:j=>l(j),children:[i.jsx(Dn,{className:"w-32",children:i.jsx($n,{})}),i.jsxs(On,{children:[i.jsx(yt,{value:"all",children:"All statuses"}),i.jsx(yt,{value:"delivered",children:"Delivered"}),i.jsx(yt,{value:"failed",children:"Failed"}),i.jsx(yt,{value:"pending",children:"Pending"})]})]}),i.jsxs(ve,{variant:f?"secondary":"ghost",size:"sm",className:"relative",onClick:()=>{h(!f),g(!0)},"aria-pressed":f,"aria-label":"Show dead letters",children:[i.jsx(Yr,{className:"mr-1 size-3.5"}),"Dead Letters",k.length>0&&!f&&m&&i.jsx("span",{className:"absolute -top-0.5 -right-0.5 size-2 rounded-full bg-red-500"})]}),i.jsx(_n,{className:"h-9 w-44",placeholder:"Filter by agent or message...",value:c,onChange:j=>u(j.target.value),"aria-label":"Search conversations"}),E&&i.jsx(ve,{variant:"ghost",size:"sm",onClick:_,children:"Clear filters"}),i.jsx("div",{className:"ml-auto",children:i.jsx(qGe,{})})]}),f&&i.jsx("div",{ref:t,children:i.jsx(HGe,{enabled:e})}),T.length===0&&!E?i.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-12 text-center",children:[i.jsx("div",{className:"pointer-events-none mb-2 w-full max-w-sm opacity-20 select-none",children:i.jsxs("div",{className:"space-y-2",children:[i.jsx("div",{className:"rounded-lg border p-3",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:"bg-muted size-4 rounded"}),i.jsx("div",{className:"bg-muted h-3 w-32 rounded"}),i.jsx("div",{className:"bg-muted ml-auto h-3 w-12 rounded"})]})}),i.jsx("div",{className:"rounded-lg border p-3",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:"bg-muted size-4 rounded"}),i.jsx("div",{className:"bg-muted h-3 w-44 rounded"}),i.jsx("div",{className:"bg-muted ml-auto h-3 w-12 rounded"})]})}),i.jsx("div",{className:"rounded-lg border p-3",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:"bg-muted size-4 rounded"}),i.jsx("div",{className:"bg-muted h-3 w-24 rounded"}),i.jsx("div",{className:"bg-muted ml-auto h-3 w-12 rounded"})]})})]})}),i.jsx(zEe,{className:"text-muted-foreground/50 size-10"}),i.jsxs("div",{className:"space-y-1",children:[i.jsx("p",{className:"text-sm font-medium",children:"No activity yet"}),i.jsx("p",{className:"text-muted-foreground text-sm",children:"Messages will appear here as your agents communicate"})]})]}):T.length===0?i.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-12 text-center",children:[i.jsx(Ti,{className:"text-muted-foreground/50 size-10"}),i.jsxs("div",{className:"space-y-1",children:[i.jsx("p",{className:"text-sm font-medium",children:"No messages match your filters"}),i.jsx("p",{className:"text-muted-foreground text-sm",children:"Try adjusting your filter criteria."})]}),i.jsx(ve,{variant:"ghost",size:"sm",onClick:_,children:"Clear filters"})]}):i.jsx("div",{className:"space-y-2",children:i.jsx(He,{mode:"popLayout",children:T.map(j=>{const D=C.current!==null&&!C.current.has(j.id)?WGe:YGe;return i.jsx(oe.div,{...D,children:i.jsx(LGe,{conversation:j})},j.id)})})})]})]})}const QGe={messaging:"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200",automation:"bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-200",internal:"bg-gray-100 text-gray-800 dark:bg-gray-900 dark:text-gray-200",custom:"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200"};function iae(e){return QGe[e]??""}function t7({size:e=16,className:t}){return i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 24 24",fill:"currentColor",className:t,"aria-hidden":"true",children:i.jsx("path",{d:"M11.944 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0a12 12 0 0 0-.056 0zm4.962 7.224c.1-.002.321.023.465.14a.506.506 0 0 1 .171.325c.016.093.036.306.02.472-.18 1.898-.962 6.502-1.36 8.627-.168.9-.499 1.201-.82 1.23-.696.065-1.225-.46-1.9-.902-1.056-.693-1.653-1.124-2.678-1.8-1.185-.78-.417-1.21.258-1.91.177-.184 3.247-2.977 3.307-3.23.007-.032.014-.15-.056-.212s-.174-.041-.249-.024c-.106.024-1.793 1.14-5.061 3.345-.48.33-.913.49-1.302.48-.428-.008-1.252-.241-1.865-.44-.752-.245-1.349-.374-1.297-.789.027-.216.325-.437.893-.663 3.498-1.524 5.83-2.529 6.998-3.014 3.332-1.386 4.025-1.627 4.476-1.635z"})})}function oae({size:e=16,className:t}){return i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 24 24",fill:"currentColor",className:t,"aria-hidden":"true",children:i.jsx("path",{d:"M17.304 3.541h-3.672l6.696 16.918h3.672zm-10.608 0L0 20.459h3.744l1.37-3.553h7.005l1.369 3.553h3.744L10.536 3.541zm-.372 10.339 2.18-5.632 2.171 5.632z"})})}function ZR({size:e=16,className:t}){return i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 24 24",fill:"currentColor",className:t,"aria-hidden":"true",children:i.jsx("path",{d:"M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z"})})}function XR({size:e=16,className:t}){return i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 24 24",fill:"currentColor",className:t,"aria-hidden":"true",children:i.jsx("path",{d:"M11.04 19.32Q12 21.51 12 24q0-2.49.93-4.68.96-2.19 2.58-3.81t3.81-2.55Q21.51 12 24 12q-2.49 0-4.68-.93a12.3 12.3 0 0 1-3.81-2.58 12.3 12.3 0 0 1-2.58-3.81Q12 2.49 12 0q0 2.49-.96 4.68-.93 2.19-2.55 3.81a12.3 12.3 0 0 1-3.81 2.58Q2.49 12 0 12q2.49 0 4.68.96 2.19.93 3.81 2.55t2.55 3.81"})})}function JGe({size:e=16,className:t}){return i.jsx(V_e,{className:t,style:{width:e,height:e}})}function eKe({size:e=16,className:t}){return i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 24 24",className:t,"aria-hidden":"true",children:i.jsx("text",{x:"12",y:"18",textAnchor:"middle",fontFamily:"system-ui, -apple-system, sans-serif",fontSize:"20",fontWeight:"900",fill:"currentColor",children:"#"})})}const n7={telegram:t7,"telegram-chatsdk":t7,"claude-code":oae,openai:ZR,codex:ZR,gemini:XR,"gemini-cli":XR,slack:eKe,webhook:JGe};function hO({iconId:e,adapterType:t,size:n=16,className:s}){const r=n7[e??""]??n7[t??""];return r?i.jsx(r,{size:n,className:s}):i.jsx(zy,{className:s,style:{width:n,height:n}})}function tKe({manifest:e,instance:t,primaryName:n,secondaryName:s,statusDotClass:r,onToggle:a,onShowEvents:o,onConfigure:l,onRemove:c,onAddBinding:u,isBuiltinClaude:f}){return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex items-start justify-between",children:[i.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[i.jsx("div",{className:r,"aria-hidden":!0}),i.jsx(hO,{iconId:e.iconId,adapterType:e.type,size:16,className:"text-muted-foreground shrink-0"}),i.jsx("span",{className:"text-sm font-medium",children:n})]}),i.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[i.jsx(Ks,{checked:t.enabled,onCheckedChange:a}),i.jsxs(Xm,{children:[i.jsx(Qm,{asChild:!0,children:i.jsx(ve,{variant:"ghost",size:"sm",className:"size-7 p-0","aria-label":"Adapter actions",children:i.jsx(dEe,{className:"size-4"})})}),i.jsxs(lh,{align:"end",children:[i.jsxs(Nr,{onClick:o,children:[i.jsx(Fy,{className:"mr-2 size-3.5"}),"Events"]}),i.jsxs(Nr,{onClick:u,children:[i.jsx(QEe,{className:"mr-2 size-3.5"}),"Add Binding"]}),i.jsxs(Nr,{onClick:l,children:[i.jsx(Qi,{className:"mr-2 size-3.5"}),"Configure"]}),i.jsxs(Nr,{onClick:c,disabled:f,className:"text-red-600 focus:text-red-600",children:[i.jsx(Yf,{className:"mr-2 size-3.5"}),"Remove"]})]})]})]})]}),i.jsxs("div",{className:"mt-1 flex items-center gap-2 pl-[18px]",children:[s&&i.jsx("span",{className:"text-muted-foreground text-xs",children:s}),s&&i.jsx("span",{className:"text-muted-foreground/50 text-xs",children:"·"}),i.jsx(Ot,{variant:"secondary",className:X("text-xs",iae(e.category)),children:e.category}),e.deprecated&&i.jsx(Ot,{variant:"outline",className:"text-xs text-amber-600 dark:text-amber-500",children:"Deprecated"})]})]})}const nKe={"per-chat":"Per Chat","per-user":"Per User",stateless:"Stateless"};function sKe({agentName:e,sessionStrategy:t,chatId:n,channelType:s,canInitiate:r=!1,canReply:a=!0,canReceive:o=!0}){return i.jsxs("div",{className:"text-muted-foreground flex items-center gap-2 text-sm",children:[i.jsx("span",{className:"truncate",children:e}),t!=="per-chat"&&i.jsx(Ot,{variant:"secondary",className:"shrink-0 text-xs",children:nKe[t]??t}),n&&i.jsx(Ot,{variant:"outline",className:"shrink-0 truncate text-xs",children:s?`#${n}`:n}),i.jsxs(eb,{children:[r&&i.jsxs(Kn,{children:[i.jsx(Wn,{asChild:!0,children:i.jsx(Pu,{className:"size-3 shrink-0 text-amber-500","aria-label":"Can initiate messages"})}),i.jsx(Yn,{children:"Can initiate messages"})]}),!a&&i.jsxs(Kn,{children:[i.jsx(Wn,{asChild:!0,children:i.jsx(cTe,{className:"text-muted-foreground/70 size-3 shrink-0","aria-label":"Reply disabled"})}),i.jsx(Yn,{children:"Reply disabled"})]}),!o&&i.jsxs(Kn,{children:[i.jsx(Wn,{asChild:!0,children:i.jsx(TCe,{className:"text-muted-foreground/70 size-3 shrink-0","aria-label":"Receive disabled"})}),i.jsx(Yn,{children:"Receive disabled"})]})]})]})}function s7({adapterId:e,onQuickBind:t,onAdvanced:n,isPending:s,children:r}){const[a,o]=x.useState(!1),{data:l}=ji(),{data:c=[]}=pb(),u=x.useMemo(()=>new Set(c.filter(g=>g.adapterId===e).map(g=>g.agentId)),[c,e]),f=x.useMemo(()=>((l==null?void 0:l.agents)??[]).filter(g=>!u.has(g.id)),[l,u]);async function h(g){await t(g),o(!1)}function m(){o(!1),n()}return i.jsxs(eg,{open:a,onOpenChange:o,children:[i.jsx(tg,{asChild:!0,children:r}),i.jsxs(ng,{className:"w-56 p-0",align:"start",children:[i.jsxs(yC,{children:[i.jsx(bC,{placeholder:"Search agents..."}),i.jsxs(vC,{children:[i.jsx(SC,{children:"No agents registered"}),f.map(g=>i.jsxs(Hr,{value:tn(g),onSelect:()=>h(g.id),disabled:s,children:[s?i.jsx(Xn,{className:"mr-2 size-3.5 animate-spin"}):null,tn(g)]},g.id))]})]}),i.jsx("div",{className:"border-t px-2 py-1.5",children:i.jsx(ve,{variant:"ghost",size:"sm",className:"text-muted-foreground w-full text-xs",onClick:m,children:"Advanced..."})})]})]})}const TN=3;function rKe({instance:e,isBuiltinClaude:t,boundAgentRows:n,adapterBindings:s,totalAgentCount:r,isConnected:a,hasBindings:o,onEditBinding:l,onQuickBind:c,onAdvancedBind:u,createBindingPending:f}){const[h,m]=x.useState(!1),g=h?n:n.slice(0,TN),b=n.length-TN;return i.jsx("div",{className:"mt-3 space-y-1.5 pl-[18px]",children:t?i.jsxs("p",{className:"text-muted-foreground text-sm",children:["Serving ",r," ",r===1?"agent":"agents"," · Chat + Tasks"]}):o?i.jsxs(i.Fragment,{children:[g.map((v,k)=>{const w=s[k];return i.jsxs("button",{type:"button",className:"group/row hover:bg-muted/50 flex w-full cursor-pointer items-center gap-1.5 rounded px-1 py-0.5 text-left transition-colors",onClick:()=>l(w),children:[i.jsx(sKe,{agentName:v.agentName,sessionStrategy:v.sessionStrategy,chatId:v.chatId,channelType:v.channelType,canInitiate:v.canInitiate,canReply:v.canReply,canReceive:v.canReceive}),i.jsx(Ws,{className:"text-muted-foreground ml-auto size-3 opacity-0 transition-opacity group-hover/row:opacity-100"})]},v.bindingId)}),b>0&&!h&&i.jsxs("button",{type:"button",className:"text-muted-foreground hover:text-foreground mt-1 text-xs hover:underline",onClick:()=>m(!0),children:["Show ",b," more"]}),h&&n.length>TN&&i.jsx("button",{type:"button",className:"text-muted-foreground hover:text-foreground mt-1 text-xs hover:underline",onClick:()=>m(!1),children:"Show less"}),i.jsx(s7,{adapterId:e.id,onQuickBind:c,onAdvanced:u,isPending:f,children:i.jsxs(ve,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground mt-1 h-6 gap-1 px-2 text-xs",children:[i.jsx(Es,{className:"size-3"}),"Add binding"]})})]}):a?i.jsx(s7,{adapterId:e.id,onQuickBind:c,onAdvanced:u,isPending:f,children:i.jsxs(ve,{variant:"ghost",size:"sm",className:"mt-1 h-6 gap-1 px-2 text-xs text-amber-600 hover:bg-amber-50 hover:text-amber-700 dark:text-amber-500 dark:hover:bg-amber-950",children:[i.jsx(Es,{className:"size-3"}),"Add binding"]})}):null})}function aKe({instance:e}){const{errorCount:t,lastError:n}=e.status;return!t&&!n?null:i.jsxs("div",{className:"mt-3 pl-[18px]",children:[t>0&&!n&&i.jsxs("div",{className:"flex items-center gap-1 text-xs text-red-500",children:[i.jsx(Yr,{className:"size-3"}),i.jsxs("span",{children:[t," ",t===1?"error":"errors"]})]}),n&&i.jsxs(Bl,{children:[i.jsx("div",{className:"flex items-center gap-1",children:i.jsx($l,{asChild:!0,children:i.jsxs("button",{className:"flex items-center gap-1 text-xs text-red-500 hover:text-red-600","aria-label":"Toggle full error message",children:[i.jsx(Ws,{className:"size-3 transition-transform data-[state=open]:rotate-90"}),t>0&&i.jsx(Yr,{className:"size-3"}),i.jsx("span",{className:"max-w-[200px] truncate",children:t>0?`${t} ${t===1?"error":"errors"}`:n})]})})}),i.jsx(Hl,{children:i.jsx("div",{className:"mt-1 rounded-md bg-red-50 p-2 font-mono text-xs text-red-700 dark:bg-red-950 dark:text-red-300",children:n})})]})]})}function iKe({instance:e,manifest:t,onToggle:n,onConfigure:s,onShowEvents:r,onEditBinding:a,onRemoveConfirm:o,onAddBinding:l}){const c=dO(),u=t.type==="claude-code"&&t.builtin,f=e.label||e.status.displayName||e.id,h=e.label?e.status.displayName||t.displayName:null,{data:m=[]}=pb(),{data:g}=ji(),b=x.useMemo(()=>(g==null?void 0:g.agents)??[],[g==null?void 0:g.agents]),v=b.length,k=x.useMemo(()=>m.filter(R=>R.adapterId===e.id),[m,e.id]),w=x.useMemo(()=>k.map(R=>{const D=b.find(I=>I.id===R.agentId);return{bindingId:R.id,agentName:(D==null?void 0:D.name)??R.agentId,sessionStrategy:R.sessionStrategy,chatId:R.chatId,channelType:R.channelType,canInitiate:R.canInitiate,canReply:R.canReply,canReceive:R.canReceive}}),[k,b]),C=k.length>0,E=e.status.state==="connected",T=u||C,_=X("size-2 shrink-0 rounded-full",e.status.state==="error"&&"bg-red-500",e.status.state==="connected"&&T&&"bg-green-500",e.status.state==="connected"&&!T&&"animate-tasks bg-amber-500",e.status.state==="disconnected"&&"bg-gray-400",e.status.state==="starting"&&"animate-tasks bg-blue-400",e.status.state==="stopping"&&"animate-tasks bg-gray-400",!["error","connected","disconnected","starting","stopping"].includes(e.status.state)&&"bg-gray-400");async function j(R){try{await c.mutateAsync({adapterId:e.id,agentId:R,sessionStrategy:"per-chat",label:""}),rt.success("Binding created")}catch(D){rt.error(D instanceof Error?D.message:"Failed to create binding")}}return i.jsxs("div",{className:X("shadow-soft hover:shadow-elevated rounded-xl border p-5 transition-shadow",u&&"border-dashed"),children:[i.jsx(tKe,{manifest:t,instance:e,primaryName:f,secondaryName:h,statusDotClass:_,onToggle:n,onShowEvents:()=>r(e.id),onConfigure:s,onRemove:()=>o(e.id,f),onAddBinding:()=>l(e.id,e.id),isBuiltinClaude:u}),i.jsx(rKe,{instance:e,isBuiltinClaude:u,boundAgentRows:w,adapterBindings:k,totalAgentCount:v,isConnected:E,hasBindings:C,onEditBinding:R=>a(R),onQuickBind:j,onAdvancedBind:()=>l(e.id,e.id),createBindingPending:c.isPending}),i.jsx(aKe,{instance:e})]})}const oKe={"adapter.connected":"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200","adapter.message_sent":"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200","adapter.disconnected":"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200","adapter.error":"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200","adapter.message_received":"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200","adapter.status_change":"bg-amber-100 text-amber-800 dark:bg-amber-900 dark:text-amber-200"},QR={"adapter.connected":"Connected","adapter.disconnected":"Disconnected","adapter.message_received":"Received","adapter.message_sent":"Sent","adapter.error":"Error","adapter.status_change":"Status"},lKe=Object.keys(QR);function cKe({adapterId:e}){const{data:t,isLoading:n}=WUe(e),[s,r]=x.useState("all"),a=x.useRef(null),[o,l]=x.useState(!0),c=x.useCallback(()=>{const m=a.current;if(!m)return;l(m.scrollHeight-m.scrollTop-m.clientHeight<20)},[]);x.useEffect(()=>{o&&a.current&&(a.current.scrollTop=a.current.scrollHeight)},[t,o]);const u=()=>{a.current&&(a.current.scrollTop=a.current.scrollHeight,l(!0))};if(n)return i.jsx("div",{className:"space-y-2 p-3",children:[1,2,3,4].map(m=>i.jsx(on,{className:"h-6 w-full"},m))});const f=(t==null?void 0:t.events)??[],h=s==="all"?f:f.filter(m=>m.subject===s);return f.length===0?i.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 p-6 text-center",children:[i.jsx(Fy,{className:"text-muted-foreground size-6"}),i.jsx("p",{className:"text-muted-foreground text-sm",children:"No events recorded"})]}):i.jsxs("div",{className:"flex h-full flex-col",children:[i.jsxs("div",{className:"flex items-center justify-between border-b px-3 py-2",children:[i.jsx("h4",{className:"text-muted-foreground text-xs font-semibold tracking-wide uppercase",children:"Events"}),i.jsxs(Bn,{value:s,onValueChange:r,children:[i.jsx(Dn,{className:"h-7 w-[130px] text-xs",children:i.jsx($n,{})}),i.jsxs(On,{children:[i.jsx(yt,{value:"all",children:"All types"}),lKe.map(m=>i.jsx(yt,{value:m,children:QR[m]},m))]})]})]}),i.jsx("div",{ref:a,onScroll:c,className:"flex-1 overflow-y-auto p-2",children:h.map(m=>{const g=m.metadata?JSON.parse(m.metadata):null,b=new Date(m.sentAt).toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"});return i.jsxs("div",{className:"flex items-start gap-2 py-1",children:[i.jsx("span",{className:"text-muted-foreground shrink-0 font-mono text-xs tabular-nums",children:b}),i.jsx(Ot,{variant:"secondary",className:X("shrink-0 text-[10px]",oKe[m.subject]??""),children:QR[m.subject]??m.subject}),i.jsx("span",{className:"text-xs break-words",children:(g==null?void 0:g.message)??m.subject})]},m.id)})}),!o&&i.jsx("div",{className:"flex justify-center border-t py-1",children:i.jsxs(ve,{variant:"ghost",size:"sm",onClick:u,className:"h-6 text-xs",children:[i.jsx(qk,{className:"mr-1 size-3"}),"Jump to bottom"]})})]})}function lae({manifest:e,onAdd:t}){return i.jsxs("div",{className:"hover:bg-muted/50 flex flex-col justify-between rounded-lg border p-4 transition-colors",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(hO,{iconId:e.iconId,adapterType:e.type,size:20,className:"text-muted-foreground shrink-0"}),i.jsx("span",{className:"text-sm font-medium",children:e.displayName}),i.jsx(Ot,{variant:"secondary",className:iae(e.category),children:e.category})]}),i.jsx("p",{className:"text-muted-foreground text-xs",children:e.description})]}),i.jsx("div",{className:"mt-3",children:i.jsxs(ve,{variant:"outline",size:"sm",className:"w-full",onClick:t,children:[i.jsx(Es,{className:"mr-1 size-3"}),"Add"]})})]})}const r7=["configure","test","confirm","bind"],uKe={configure:"Configure",test:"Test",confirm:"Confirm",bind:"Bind"};function dKe({current:e,showBindStep:t}){const n=t?r7:r7.filter(r=>r!=="bind"),s=n.indexOf(e);return i.jsx("div",{className:"flex items-start justify-between px-1",role:"navigation","aria-label":"Wizard steps",children:n.map((r,a)=>{const o=a<s,l=a===s,c=a>s;return i.jsxs(x.Fragment,{children:[a>0&&i.jsx("div",{className:X("mt-3 h-px flex-1",o||l?"bg-primary":"border-muted-foreground/40 border-t border-dashed")}),i.jsxs("div",{className:"flex flex-col items-center gap-1",children:[i.jsx("div",{className:X("flex size-6 items-center justify-center rounded-full text-xs font-medium",o&&"bg-primary text-primary-foreground",l&&"bg-primary text-primary-foreground ring-primary/30 ring-2",c&&"border-muted-foreground text-muted-foreground border"),"aria-current":l?"step":void 0,children:o?i.jsx(Zt,{className:"size-3"}):a+1}),i.jsx("span",{className:X("text-[10px]",l?"text-foreground font-medium":"text-muted-foreground"),children:uKe[r]})]})]},r)})})}function fKe({field:e,value:t,onChange:n,error:s,allValues:r}){const[a,o]=x.useState("");if(e.showWhen&&r[e.showWhen.field]!==e.showWhen.equals)return null;const l=`config-field-${e.key}`,c=t!=null?String(t):"",u=c==="***",f=()=>{if(u){o("");return}if(e.pattern&&c&&!new RegExp(e.pattern).test(c)){o(e.patternMessage??"Invalid format");return}o("")},h=s??a;if(e.type==="boolean")return i.jsxs("div",{children:[i.jsxs(Wa,{orientation:"horizontal",className:"items-center justify-between gap-4",children:[i.jsxs(vX,{className:"min-w-0",children:[i.jsx(Ya,{htmlFor:l,className:X("text-sm font-medium",e.required&&'after:text-destructive after:ml-0.5 after:content-["*"]'),children:e.label}),e.description&&i.jsx(Ei,{className:"text-xs",children:e.description})]}),i.jsx(Ks,{id:l,checked:!!t,onCheckedChange:g=>n(e.key,g)})]}),e.helpMarkdown&&i.jsxs(Bl,{children:[i.jsxs($l,{className:"text-muted-foreground hover:text-foreground mt-1 flex items-center gap-1 text-xs transition-colors",children:[i.jsx(jF,{className:"size-3"}),"Where do I find this?",i.jsx(Ps,{className:"size-3 transition-transform [[data-state=open]_&]:rotate-180"})]}),i.jsx(Hl,{children:i.jsx("div",{className:"bg-muted/50 mt-2 rounded-md border p-3",children:i.jsx(Ew,{content:e.helpMarkdown,className:"text-xs"})})})]}),i.jsx(He,{children:h&&i.jsx(oe.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.15},className:"overflow-hidden",children:i.jsx(Oo,{className:"mt-1.5",children:h})})})]});const m=()=>{var g,b;switch(e.type){case"text":case"url":return i.jsx(_n,{id:l,type:e.type==="url"?"url":"text",value:c,onChange:v=>n(e.key,v.target.value),placeholder:e.placeholder,"aria-invalid":!!h||void 0});case"password":return u?i.jsx(WS,{id:l,value:c,showPassword:!1,onChange:v=>{n(e.key,v.target.value.trim()),a&&o("")},onFocus:()=>n(e.key,""),onBlur:f,placeholder:"Saved — enter a new one to replace"}):i.jsx(WS,{id:l,value:c,visibleByDefault:e.visibleByDefault??!1,onChange:v=>{n(e.key,v.target.value.trim()),a&&o("")},onBlur:f,onPaste:()=>setTimeout(f,0),placeholder:e.placeholder,"aria-invalid":!!h||void 0});case"number":return i.jsx(_n,{id:l,type:"number",value:c,onChange:v=>n(e.key,v.target.value?Number(v.target.value):void 0),placeholder:e.placeholder,"aria-invalid":!!h||void 0});case"select":return e.displayAs==="radio-cards"?i.jsx("div",{className:"grid grid-cols-2 gap-3",role:"radiogroup",children:(g=e.options)==null?void 0:g.map(v=>i.jsxs("button",{type:"button",role:"radio","aria-checked":c===v.value,onClick:()=>n(e.key,v.value),className:X("hover:bg-accent/50 flex flex-col items-start rounded-md border p-3 text-left transition",c===v.value&&"border-primary ring-primary bg-accent/30 ring-1"),children:[i.jsx("span",{className:"text-sm font-medium",children:v.label}),v.description&&i.jsx("span",{className:"text-muted-foreground mt-1 text-xs",children:v.description})]},v.value))}):i.jsxs(Bn,{value:c,onValueChange:v=>n(e.key,v),children:[i.jsx(Dn,{id:l,"aria-invalid":!!h||void 0,children:i.jsx($n,{placeholder:e.placeholder??"Select..."})}),i.jsx(On,{children:(b=e.options)==null?void 0:b.map(v=>i.jsx(yt,{value:v.value,children:v.label},v.value))})]});case"textarea":return i.jsx(K3,{id:l,value:c,onChange:v=>n(e.key,v.target.value),placeholder:e.placeholder,rows:3,"aria-invalid":!!h||void 0});default:return null}};return i.jsxs(Wa,{children:[i.jsx(Ya,{htmlFor:l,className:X(e.required&&!u&&'after:text-destructive after:ml-0.5 after:content-["*"]'),children:e.label}),m(),e.description&&i.jsx(Ei,{className:"text-xs",children:e.description}),e.helpMarkdown&&i.jsxs(Bl,{children:[i.jsxs($l,{className:"text-muted-foreground hover:text-foreground mt-1 flex items-center gap-1 text-xs transition-colors",children:[i.jsx(jF,{className:"size-3"}),"Where do I find this?",i.jsx(Ps,{className:"size-3 transition-transform [[data-state=open]_&]:rotate-180"})]}),i.jsx(Hl,{children:i.jsx("div",{className:"bg-muted/50 mt-2 rounded-md border p-3",children:i.jsx(Ew,{content:e.helpMarkdown,className:"text-xs"})})})]}),i.jsx(He,{children:h&&i.jsx(oe.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.15},className:"overflow-hidden",children:i.jsx(Oo,{children:h})})})]})}function hKe(e,t){return e.showWhen?t[e.showWhen.field]===e.showWhen.equals:!0}function pKe({fields:e,allValues:t,renderField:n}){const s=new Map;for(const r of e){const a=r.section;s.has(a)||s.set(a,[]),s.get(a).push(r)}return i.jsx("div",{className:"space-y-6",children:Array.from(s.entries()).map(([r,a])=>{const o=a.filter(l=>hKe(l,t));return o.length===0?null:i.jsxs("div",{className:"space-y-3",children:[r&&i.jsx("h4",{className:"text-sm font-semibold",children:r}),i.jsx(Sa,{children:i.jsx(Wr,{children:o.map(l=>n(l))})})]},r??"__default")})})}function mKe({manifest:e,label:t,onLabelChange:n,fields:s,form:r,currentSetupStep:a,hasSetupGuide:o,onOpenGuide:l}){const{Subscribe:c,AppField:u}=r;return i.jsxs("div",{className:"space-y-4",children:[e.setupInstructions&&i.jsxs("div",{className:"flex gap-2 rounded-md border border-blue-200 bg-blue-50 p-3 text-sm text-blue-800 dark:border-blue-800 dark:bg-blue-950 dark:text-blue-200",children:[i.jsx(X3,{className:"mt-0.5 size-4 shrink-0"}),i.jsx(Ew,{content:e.setupInstructions,className:"text-sm text-blue-800 dark:text-blue-200"})]}),(e.actionButton||o)&&i.jsxs("div",{className:"flex items-center justify-end gap-2",children:[o&&i.jsxs(ve,{type:"button",variant:"outline",size:"sm",onClick:l,children:[i.jsx(W3,{className:"mr-1.5 size-3.5"}),"Setup Guide"]}),e.actionButton&&i.jsx("a",{href:e.actionButton.url,target:"_blank",rel:"noopener noreferrer",children:i.jsx(ve,{type:"button",variant:"outline",size:"sm",children:e.actionButton.label})})]}),a&&i.jsx("h4",{className:"text-sm font-medium",children:a.title}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(jn,{htmlFor:"adapter-label",children:"Name (optional)"}),i.jsx(_n,{id:"adapter-label",placeholder:e.displayName,value:t,onChange:f=>n(f.target.value)}),i.jsx("p",{className:"text-muted-foreground text-xs",children:"A friendly name to identify this adapter instance."})]}),i.jsx(c,{selector:f=>f.values,children:f=>i.jsx(pKe,{fields:s,allValues:f,renderField:h=>i.jsx(u,{name:h.key,children:m=>{var g;return i.jsx(fKe,{field:h,value:m.state.value,onChange:(b,v)=>m.handleChange(v),onBlur:m.handleBlur,error:m.state.meta.isTouched?(g=m.state.meta.errors[0])==null?void 0:g.toString():void 0,allValues:f})}},h.key)})})]})}function gKe({isPending:e,isSuccess:t,isError:n,errorMessage:s,botUsername:r,onRetry:a}){return i.jsxs("div",{className:"flex flex-col items-center gap-3 py-6",children:[e&&i.jsxs(i.Fragment,{children:[i.jsx(Xn,{className:"text-muted-foreground size-8 animate-spin"}),i.jsx("p",{className:"text-muted-foreground text-sm",children:"Testing connection..."})]}),t&&i.jsxs("div",{className:"flex flex-col items-center gap-2",children:[i.jsx(qf,{className:"size-8 text-green-500"}),i.jsx("p",{className:"text-sm text-green-700 dark:text-green-400",children:"Connection successful"}),r&&i.jsx("div",{className:"flex items-center gap-2 rounded-md border px-3 py-2 text-sm",children:i.jsxs("span",{className:"font-mono",children:["@",r]})})]}),n&&i.jsxs(i.Fragment,{children:[i.jsx(Vm,{className:"size-8 text-red-500"}),i.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:"Connection failed"}),s&&i.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-red-200 bg-red-50 p-3 text-xs text-red-700 dark:border-red-800 dark:bg-red-950 dark:text-red-300",children:[i.jsx(Yr,{className:"mt-0.5 size-3 shrink-0"}),i.jsx("span",{children:s})]}),i.jsx(ve,{variant:"outline",size:"sm",onClick:a,children:"Retry"})]})]})}function xKe(e){return e.length>8?"•••• "+e.slice(-4):"•••"}function yKe({manifest:e,adapterId:t,isEditMode:n,values:s}){return i.jsxs("div",{className:"space-y-3",children:[!n&&i.jsxs("div",{className:"flex justify-between text-sm",children:[i.jsx("span",{className:"text-muted-foreground",children:"Adapter ID"}),i.jsx("span",{className:"font-mono",children:t})]}),e.configFields.map(r=>{if(r.showWhen&&s[r.showWhen.field]!==r.showWhen.equals)return null;const a=String(s[r.key]??""),o=r.type==="password"?xKe(a):a;return i.jsxs("div",{className:"flex justify-between text-sm",children:[i.jsx("span",{className:"text-muted-foreground",children:r.label}),i.jsx("span",{className:"max-w-[200px] truncate font-mono",children:o})]},r.key)})]})}const bKe=[{value:"per-chat",label:"Per Chat"},{value:"per-user",label:"Per User"},{value:"stateless",label:"Stateless"}];function vKe({agentOptions:e,agentId:t,onAgentIdChange:n,strategy:s,onStrategyChange:r,botUsername:a,adapterType:o}){return x.useEffect(()=>{e.length===1&&!t&&n(e[0].id)},[e.length]),i.jsxs("div",{className:"space-y-4",children:[i.jsx("p",{className:"text-muted-foreground text-sm",children:"Bind this adapter to an agent so incoming messages are routed automatically. You can skip this and bind later from the Bindings tab."}),e.length===0?i.jsx("div",{className:"text-muted-foreground rounded-md border border-dashed px-4 py-6 text-center text-sm",children:"No agents registered yet. You can bind this adapter later from the Adapters tab."}):e.length===1?i.jsxs("div",{className:"bg-accent/30 rounded-md border px-4 py-3 text-sm",children:["Will bind to ",i.jsx("span",{className:"font-medium",children:tn(e[0])})]}):i.jsxs("div",{className:"space-y-2",children:[i.jsx(jn,{htmlFor:"bind-agent",children:"Agent"}),i.jsxs(Bn,{value:t,onValueChange:n,children:[i.jsx(Dn,{id:"bind-agent",className:"w-full",children:i.jsx($n,{placeholder:"Select an agent"})}),i.jsx(On,{children:e.map(l=>i.jsx(yt,{value:l.id,children:tn(l)},l.id))})]})]}),e.length>0&&i.jsxs("div",{className:"space-y-2",children:[i.jsx(jn,{htmlFor:"bind-strategy",children:"Session Strategy"}),i.jsxs(Bn,{value:s,onValueChange:l=>r(l),children:[i.jsx(Dn,{id:"bind-strategy",className:"w-full",children:i.jsx($n,{})}),i.jsx(On,{children:bKe.map(l=>i.jsx(yt,{value:l.value,children:l.label},l.value))})]})]}),a&&o==="telegram"&&i.jsxs("a",{href:`https://t.me/${a}`,target:"_blank",rel:"noopener noreferrer",className:"text-primary inline-flex items-center gap-1.5 text-sm underline-offset-4 hover:underline",children:["Message @",a," in Telegram"]})]})}function SKe({open:e,onOpenChange:t,title:n,content:s}){return i.jsx(Xl,{open:e,onOpenChange:t,children:i.jsxs(Ql,{side:"right",className:"w-[480px] overflow-y-auto sm:max-w-lg",children:[i.jsxs(Jl,{children:[i.jsxs(ec,{className:"flex items-center gap-2",children:[i.jsx(W3,{className:"size-4"}),n," Setup Guide"]}),i.jsx(ph,{children:"Step-by-step instructions for configuring this adapter."})]}),i.jsx("div",{className:"mt-4 px-4",children:i.jsx(Ew,{content:s})})]})})}function _N(e){const t={};for(const[n,s]of Object.entries(e)){const r=n.split(".");let a=t;for(let o=0;o<r.length-1;o++){const l=r[o];(!(l in a)||typeof a[l]!="object"||a[l]===null)&&(a[l]={}),a=a[l]}a[r[r.length-1]]=s}return t}function a7(e,t){const n=t.split(".");let s=e;for(const r of n){if(s==null||typeof s!="object")return;s=s[r]}return s}function wKe(e,t){const n={};for(const s of e.configFields){const r=t?a7(t,s.key):void 0;r!==void 0&&s.type!=="password"?n[s.key]=r:s.type==="password"&&t&&a7(t,s.key)!==void 0?n[s.key]="***":s.default!==void 0?n[s.key]=s.default:n[s.key]=s.type==="boolean"?!1:""}return n}function kKe(e,t=[]){const n=e.type;if(!t.includes(n))return n;let s=2;for(;t.includes(`${n}-${s}`);)s++;return`${n}-${s}`}function CKe({manifest:e,existingInstance:t,existingAdapterIds:n=[],onOpenChange:s}){const r=!!t,[a,o]=x.useState("configure"),[l,c]=x.useState(!1),[u]=x.useState(()=>(t==null?void 0:t.id)??kKe(e,n)),[f,h]=x.useState(()=>{var re;return((re=t==null?void 0:t.config)==null?void 0:re.label)??""}),[m,g]=x.useState(0),[b,v]=x.useState(""),[k,w]=x.useState(""),[C,E]=x.useState(""),[T,_]=x.useState("per-chat"),j=BUe(),R=ore(),D=HUe(),I=dO(),{data:O}=ji(),L=(O==null?void 0:O.agents)??[],B=e.setupSteps&&e.setupSteps.length>0,H=eC({defaultValues:wKe(e,t==null?void 0:t.config),validators:{onSubmit:({value:re})=>{const ae={};for(const de of e.configFields)if(!(de.showWhen&&re[de.showWhen.field]!==de.showWhen.equals)&&de.required){const pe=re[de.key];(pe==null||pe==="")&&(ae[de.key]=`${de.label} is required`)}return Object.keys(ae).length>0?{fields:ae}:void 0}},onSubmit:async()=>{}}),K=x.useMemo(()=>{if(!B||!e.setupSteps)return e.configFields;const re=e.setupSteps[m];return re?e.configFields.filter(ae=>re.fields.includes(ae.key)):e.configFields},[e.configFields,e.setupSteps,B,m]),U=x.useCallback(()=>{const re=H.state.values;let ae=!0;for(const de of K)if(!(de.showWhen&&re[de.showWhen.field]!==de.showWhen.equals)&&de.required){const pe=re[de.key];(pe==null||pe==="")&&(H.setFieldMeta(de.key,Oe=>({...Oe,isTouched:!0,errors:[`${de.label} is required`],errorMap:{onSubmit:`${de.label} is required`}})),ae=!1)}return ae},[H,K]),$=x.useCallback(()=>{if(a==="configure"){if(!U())return;if(B&&e.setupSteps&&m<e.setupSteps.length-1){g(de=>de+1);return}const ae=H.state.values;o("test"),D.mutate({type:e.type,config:_N(ae)},{onSuccess:de=>{de.botUsername&&(v(de.botUsername),f||h(`@${de.botUsername}`))}})}else a==="test"&&o("confirm")},[a,B,e,m,U,H,D,f]),q=x.useCallback(()=>{a==="test"?(o("configure"),D.reset()):a==="confirm"?o("test"):a==="bind"?s(!1):a==="configure"&&B&&m>0&&g(re=>re-1)},[a,B,m,D,s]),J=x.useCallback(()=>{const re=H.state.values,ae=_N(re),de=f?{...ae,label:f}:ae;r&&t?R.mutate({id:t.id,config:de},{onSuccess:()=>s(!1)}):j.mutate({type:e.type,id:u,config:de},{onSuccess:()=>{const pe=f||u;rt.success(`${e.displayName} adapter added`,{description:pe?`"${pe}" is ready to use.`:void 0}),w(u),o("bind")},onError:pe=>{var Oe,Ve,$e;(Oe=pe.message)!=null&&Oe.includes("timed out")?rt.error("Request timed out",{description:"Check your token and network connectivity, then try again."}):((Ve=pe.message)!=null&&Ve.includes("duplicate")||($e=pe.message)!=null&&$e.includes("exists"))&&(o("configure"),g(0))}})},[H,r,t,R,j,e,u,f,s]),ne=x.useCallback(()=>{C&&I.mutate({adapterId:k,agentId:C,sessionStrategy:T,label:""},{onSuccess:()=>s(!1)})},[C,k,T,I,s]),F=x.useCallback(()=>{s(!1)},[s]),V=x.useCallback(re=>{re||(o("configure"),g(0),h(""),v(""),w(""),E(""),_("per-chat"),c(!1),H.reset(),D.reset()),s(re)},[s,H,D]),G=x.useCallback(()=>{D.mutate({type:e.type,config:_N(H.state.values)})},[D,e.type,H]),P=j.isPending||R.isPending,Z=I.isPending,Q=B&&e.setupSteps?e.setupSteps[m]:void 0;return{step:a,isEditMode:r,adapterId:u,label:f,setLabel:h,botUsername:b,guideOpen:l,setGuideOpen:c,form:H,visibleFields:K,bindAgentId:C,setBindAgentId:E,bindStrategy:T,setBindStrategy:_,agentOptions:L,isSaving:P,isBinding:Z,hasSetupSteps:B,setupStepIndex:m,currentSetupStep:Q,testConnection:D,handleContinue:$,handleBack:q,handleSave:J,handleBind:ne,handleSkipBind:F,handleOpenChange:V,handleRetryTest:G}}function cae({open:e,onOpenChange:t,manifest:n,existingInstance:s,existingAdapterIds:r=[]}){var J;const a=CKe({manifest:n,existingInstance:s,existingAdapterIds:r,onOpenChange:t}),{step:o,isEditMode:l,adapterId:c,label:u,setLabel:f,botUsername:h,guideOpen:m,setGuideOpen:g,form:b,visibleFields:v,bindAgentId:k,setBindAgentId:w,bindStrategy:C,setBindStrategy:E,agentOptions:T,isSaving:_,isBinding:j,hasSetupSteps:R,setupStepIndex:D,currentSetupStep:I,testConnection:O,handleContinue:L,handleBack:B,handleSave:H,handleBind:K,handleSkipBind:U,handleOpenChange:$,handleRetryTest:q}=a;return i.jsxs(x.Fragment,{children:[i.jsx(ah,{open:e,onOpenChange:$,children:i.jsxs(Gu,{className:"flex max-h-[85vh] max-w-lg flex-col",children:[i.jsxs(Ku,{children:[i.jsx(Wu,{children:l?`Edit ${n.displayName}`:`Add ${n.displayName}`}),i.jsxs(Yu,{children:[o==="configure"&&((I==null?void 0:I.description)??"Configure the adapter settings."),o==="test"&&"Testing connection to the adapter.",o==="confirm"&&"Review your configuration before saving.",o==="bind"&&"Optionally bind this adapter to an agent."]})]}),i.jsxs("div",{className:"min-h-0 space-y-4 overflow-y-auto py-2",children:[i.jsx(dKe,{current:o,showBindStep:!l}),i.jsx(He,{mode:"wait",children:i.jsxs(oe.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},children:[o==="configure"&&i.jsx(mKe,{manifest:n,label:u,onLabelChange:f,fields:v,form:b,currentSetupStep:I,hasSetupGuide:!!n.setupGuide,onOpenGuide:()=>g(!0)}),o==="test"&&i.jsx(gKe,{isPending:O.isPending,isSuccess:O.isSuccess,isError:O.isError,errorMessage:(J=O.error)==null?void 0:J.message,botUsername:h,onRetry:q}),o==="confirm"&&i.jsx(b.Subscribe,{selector:ne=>ne.values,children:ne=>i.jsx(yKe,{manifest:n,adapterId:c,isEditMode:l,values:ne})}),o==="bind"&&i.jsx(vKe,{agentOptions:T,agentId:k,onAgentIdChange:w,strategy:C,onStrategyChange:E,botUsername:h,adapterType:n.type})]},o)})]}),i.jsxs(Zm,{className:"flex items-center justify-between sm:justify-between",children:[i.jsxs("div",{children:[(o==="test"||o==="confirm")&&i.jsxs(ve,{variant:"ghost",onClick:B,disabled:_,children:[i.jsx(qS,{className:"mr-1 size-4"}),"Back"]}),o==="configure"&&R&&D>0&&i.jsxs(ve,{variant:"ghost",onClick:B,children:[i.jsx(qS,{className:"mr-1 size-4"}),"Back"]})]}),i.jsxs("div",{className:"flex gap-2",children:[o!=="bind"&&i.jsx(ve,{variant:"outline",onClick:()=>$(!1),children:"Cancel"}),o==="test"&&i.jsx(ve,{variant:"ghost",onClick:L,children:"Skip"}),o==="configure"&&i.jsxs(ve,{onClick:L,children:["Continue",i.jsx(GS,{className:"ml-1 size-4"})]}),o==="test"&&!O.isPending&&i.jsxs(ve,{onClick:L,children:["Continue",i.jsx(GS,{className:"ml-1 size-4"})]}),o==="confirm"&&i.jsxs(ve,{onClick:H,disabled:_,children:[_&&i.jsx(Xn,{className:"mr-2 size-4 animate-spin"}),l?"Save Changes":"Add Adapter"]}),o==="bind"&&i.jsxs(i.Fragment,{children:[i.jsx(ve,{variant:"ghost",onClick:U,disabled:j,children:"Skip"}),i.jsxs(ve,{onClick:K,disabled:!k||j,children:[j&&i.jsx(Xn,{className:"mr-2 size-4 animate-spin"}),"Bind to Agent"]})]})]})]})]})}),n.setupGuide&&i.jsx(SKe,{open:m,onOpenChange:g,title:n.displayName,content:n.setupGuide})]})}function EKe(){const[e,t]=x.useState({removeTarget:null,eventsTarget:null,bindingTarget:null});return{...e,openRemove:(n,s)=>t(r=>({...r,removeTarget:{instanceId:n,name:s}})),closeRemove:()=>t(n=>({...n,removeTarget:null})),openEvents:n=>t(s=>({...s,eventsTarget:{instanceId:n}})),closeEvents:()=>t(n=>({...n,eventsTarget:null})),openBindingCreate:n=>t(s=>({...s,bindingTarget:{mode:"create",adapterId:n}})),openBindingEdit:(n,s)=>t(r=>({...r,bindingTarget:{mode:"edit",adapterId:n,binding:s}})),closeBinding:()=>t(n=>({...n,bindingTarget:null}))}}function i7({enabled:e}){var _;const{data:t=[],isLoading:n}=ug(e),{mutate:s}=W5(),{mutate:r}=$Ue(),a=SGe(),o=vGe(),[l,c]=x.useState({open:!1}),u=Ct(),f=EKe();function h(j){var R;return(R=t.flatMap(D=>D.instances.map(I=>({instance:I,manifest:D.manifest}))).find(D=>D.instance.id===j))==null?void 0:R.manifest}async function m(j){if(f.bindingTarget)try{if(f.bindingTarget.mode==="edit"&&f.bindingTarget.binding)await a.mutateAsync({id:f.bindingTarget.binding.id,updates:j}),rt.success("Binding updated");else{rt.error("Unexpected create from ConnectionsTab");return}f.closeBinding()}catch(R){rt.error(R instanceof Error?R.message:"Failed to save binding")}}async function g(j){try{await o.mutateAsync(j),rt.success("Binding deleted"),f.closeBinding()}catch(R){rt.error(R instanceof Error?R.message:"Failed to delete binding")}}if(n)return i.jsxs("div",{className:"space-y-6 p-4",children:[i.jsxs("div",{className:"space-y-3",children:[i.jsx(on,{className:"h-4 w-32"}),i.jsx("div",{className:"space-y-2",children:[1,2].map(j=>i.jsx(on,{className:"h-16 w-full rounded-lg"},j))})]}),i.jsxs("div",{className:"space-y-3",children:[i.jsx(on,{className:"h-4 w-32"}),i.jsx("div",{className:"grid gap-3",style:{gridTemplateColumns:"repeat(auto-fill, minmax(240px, 1fr))"},children:[1,2].map(j=>i.jsxs("div",{className:"rounded-lg border p-4",children:[i.jsx(on,{className:"mb-2 h-5 w-24"}),i.jsx(on,{className:"h-4 w-full"}),i.jsx(on,{className:"mt-3 h-8 w-full"})]},j))})]})]});const b=t.flatMap(j=>j.instances.map(R=>({instance:R,manifest:j.manifest}))),v=t.filter(j=>!j.manifest.deprecated&&(j.instances.length===0||j.manifest.multiInstance)),k=j=>{c({open:!0,manifest:j})},w=(j,R)=>{c({open:!0,manifest:j,instanceId:R})},C=l.instanceId?t.flatMap(j=>j.instances).find(j=>j.id===l.instanceId):void 0,E=()=>{u.invalidateQueries({queryKey:["relay","adapters","catalog"]})},T=j=>({adapterId:j.adapterId,agentId:j.agentId,sessionStrategy:j.sessionStrategy,label:j.label??"",permissionMode:j.permissionMode,chatId:j.chatId,channelType:j.channelType,canInitiate:j.canInitiate,canReply:j.canReply,canReceive:j.canReceive});return i.jsxs("div",{className:"space-y-6 p-4",children:[i.jsxs("section",{children:[i.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[i.jsx("h3",{className:"text-muted-foreground text-xs font-semibold tracking-wide uppercase",children:"Active Channels"}),i.jsx(ve,{variant:"ghost",size:"sm",onClick:E,className:"size-7 p-0","aria-label":"Refresh channel catalog",children:i.jsx(mu,{className:"size-3.5"})})]}),b.length===0?i.jsxs("div",{className:"flex flex-col items-center gap-3 rounded-xl border border-dashed py-8",children:[i.jsx(KS,{className:"text-muted-foreground/40 size-8"}),i.jsxs("div",{className:"text-center",children:[i.jsx("p",{className:"text-muted-foreground text-sm",children:"No channels active"}),i.jsx("p",{className:"text-muted-foreground/60 text-xs",children:"Add a channel below to connect agents to external services"})]})]}):i.jsx("div",{className:"space-y-3",children:b.map(({instance:j,manifest:R})=>i.jsx(iKe,{instance:j,manifest:R,onToggle:D=>s({id:j.id,enabled:D}),onConfigure:()=>w(R,j.id),onShowEvents:D=>f.openEvents(D),onEditBinding:D=>f.openBindingEdit(D.adapterId,D),onRemoveConfirm:(D,I)=>f.openRemove(D,I),onAddBinding:D=>f.openBindingCreate(D)},j.id))})]}),i.jsxs("section",{children:[i.jsx("h3",{className:"text-muted-foreground mb-2 text-xs font-semibold tracking-wide uppercase",children:"Add Channel"}),v.length===0?i.jsx("p",{className:"text-muted-foreground text-sm",children:"All channel types are active. Multi-instance channels like Webhook can be added again from the active list."}):i.jsx("div",{className:"grid gap-2",style:{gridTemplateColumns:"repeat(auto-fill, minmax(240px, 1fr))"},children:v.map(j=>i.jsx(lae,{manifest:j.manifest,onAdd:()=>k(j.manifest)},j.manifest.type))})]}),l.manifest&&i.jsx(cae,{open:l.open,onOpenChange:j=>{j||c({open:!1})},manifest:l.manifest,existingInstance:C,existingAdapterIds:t.flatMap(j=>j.instances.map(R=>R.id))}),f.removeTarget&&i.jsx(th,{open:!0,onOpenChange:j=>{j||f.closeRemove()},children:i.jsxs(Bu,{children:[i.jsxs(nh,{children:[i.jsx($u,{children:"Remove adapter"}),i.jsxs(Hu,{children:['Are you sure you want to remove "',f.removeTarget.name,'"? This will stop the adapter and remove its configuration. Messages to its subjects will no longer be delivered.']})]}),i.jsxs(sh,{children:[i.jsx(Vu,{children:"Cancel"}),i.jsx(Uu,{onClick:()=>{r(f.removeTarget.instanceId),f.closeRemove()},className:"bg-red-600 hover:bg-red-700 focus:ring-red-600",children:"Remove"})]})]})}),f.eventsTarget&&i.jsx(Xl,{open:!0,onOpenChange:j=>{j||f.closeEvents()},children:i.jsxs(Ql,{className:"flex flex-col sm:max-w-md",children:[i.jsx(Jl,{children:i.jsx(ec,{children:"Events"})}),i.jsx("div",{className:"flex-1 overflow-hidden",children:i.jsx(cKe,{adapterId:f.eventsTarget.instanceId})})]})}),f.bindingTarget&&f.bindingTarget.mode==="edit"&&f.bindingTarget.binding&&i.jsx(aae,{open:!0,onOpenChange:j=>{j||f.closeBinding()},mode:"edit",initialValues:T(f.bindingTarget.binding),adapterName:(_=h(f.bindingTarget.binding.adapterId))==null?void 0:_.displayName,onConfirm:m,onDelete:g,bindingId:f.bindingTarget.binding.id,isPending:a.isPending||o.isPending})]})}function TKe({onAddChannel:e}){return i.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center px-6 py-16",children:[i.jsx("div",{className:"pointer-events-none mb-8 w-full max-w-md opacity-30 select-none",children:i.jsxs("div",{className:"space-y-2",children:[i.jsx("div",{className:"rounded-lg border p-3",children:i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"flex size-6 items-center justify-center rounded-full bg-blue-500/20",children:i.jsx("div",{className:"size-3 rounded-full bg-blue-500"})}),i.jsxs("div",{className:"flex-1 space-y-1",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"text-sm font-medium",children:"relay.agent.frontend"}),i.jsx("span",{className:"text-muted-foreground text-xs",children:"2m ago"})]}),i.jsx("p",{className:"text-muted-foreground text-xs",children:"Build completed successfully"})]})]})}),i.jsx("div",{className:"rounded-lg border p-3",children:i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"flex size-6 items-center justify-center rounded-full bg-emerald-500/20",children:i.jsx("div",{className:"size-3 rounded-full bg-emerald-500"})}),i.jsxs("div",{className:"flex-1 space-y-1",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"text-sm font-medium",children:"relay.system.tasks.audit"}),i.jsx("span",{className:"text-muted-foreground text-xs",children:"15m ago"})]}),i.jsx("p",{className:"text-muted-foreground text-xs",children:"Scheduled audit run delivered"})]})]})}),i.jsx("div",{className:"rounded-lg border p-3",children:i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"flex size-6 items-center justify-center rounded-full bg-orange-500/20",children:i.jsx("div",{className:"size-3 rounded-full bg-orange-500"})}),i.jsxs("div",{className:"flex-1 space-y-1",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"text-sm font-medium",children:"relay.agent.backend"}),i.jsx("span",{className:"text-muted-foreground text-xs",children:"1h ago"})]}),i.jsx("p",{className:"text-muted-foreground text-xs",children:"API migration task completed"})]})]})})]})}),i.jsx("h3",{className:"mb-2 text-lg font-medium",children:"Connect your agents to the world"}),i.jsx("p",{className:"text-muted-foreground mb-1 max-w-sm text-center text-sm",children:"Relay routes messages between your agents and external platforms."}),i.jsx("p",{className:"text-muted-foreground mb-6 max-w-sm text-center text-sm",children:"Add your first channel to start sending and receiving messages."}),i.jsx(ve,{onClick:e,children:"Add Channel"})]})}const o7={healthy:"bg-emerald-500",degraded:"bg-amber-500",critical:"bg-red-500"};function _Ke(e){return e==null?"—":e<1?"<1ms":`${Math.round(e)}ms`}function NKe(e,t,n){const s=e.totalMessages>0?(e.failedCount+e.deadLetteredCount)/e.totalMessages:0;if(n===0)return{state:"healthy",message:"No connections configured"};if(s>.5||t===0)return{state:"critical",message:`${Math.round(s*100)}% failure rate — ${e.failedCount} messages failed today`};if(t<n||s>=.05){const r=n-t;return r>0?{state:"degraded",message:`${r} connection${r>1?"s":""} disconnected`}:{state:"degraded",message:`${e.failedCount} failure${e.failedCount!==1?"s":""} in last 24h`}}return{state:"healthy",message:`${t} connection${t>1?"s":""} active`}}function jKe(e){const{data:t=[],isLoading:n}=ug(e),s=t.flatMap(o=>o.instances),r=s.length,a=s.filter(o=>o.status.state==="connected").length;return{total:r,connected:a,isLoading:n}}function AKe({enabled:e=!0,onFailedClick:t}){const n=ed(),{data:s,isLoading:r}=X5(),{total:a,connected:o,isLoading:l}=jKe(e&&n);if(!n||!e||r||l||!s)return null;const{state:c,message:u}=NKe(s,o,a),f=(c==="degraded"||c==="critical")&&t!=null,h=_Ke(s.avgDeliveryLatencyMs),m=`${s.totalMessages} messages today · ${s.failedCount} failed · ${h} avg latency`;return i.jsx(eb,{children:i.jsx("div",{className:"text-muted-foreground flex items-center gap-2 border-b px-3 py-1.5 text-xs",children:c==="healthy"?i.jsxs(Kn,{children:[i.jsx(Wn,{asChild:!0,children:i.jsxs("span",{className:"flex min-w-0 flex-1 cursor-default items-center gap-1.5",children:[i.jsx("span",{className:`size-2 shrink-0 rounded-full ${o7[c]}`,"aria-hidden":"true"}),i.jsx("span",{className:"truncate",children:u}),s.avgDeliveryLatencyMs!=null&&i.jsxs(i.Fragment,{children:[i.jsx("span",{"aria-hidden":"true",children:"·"}),i.jsx("span",{children:h})]})]})}),i.jsx(Yn,{side:"bottom",children:m})]}):i.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[i.jsx("span",{className:`size-2 shrink-0 rounded-full ${o7[c]}`,"aria-hidden":"true"}),f?i.jsx("button",{type:"button",onClick:t,className:"truncate text-left hover:underline","aria-label":`${u} — click to view failures`,children:u}):i.jsx("span",{className:"truncate",children:u})]})})})}function RKe(){const e=ed(),[t,n]=x.useState("connections"),[s,r]=x.useState(!1),[a,o]=x.useState(!1),l=x.useRef(null),{connectionState:c}=zUe(e),{data:u=[]}=ug(e),f=u.some(m=>m.instances.length>0),h=x.useCallback(()=>{n("activity"),o(!0),setTimeout(()=>o(!1),100),setTimeout(()=>{var m;(m=l.current)==null||m.scrollIntoView({behavior:"smooth",block:"start"})},150)},[]);return e?i.jsx(He,{mode:"wait",children:f?i.jsx(oe.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"flex h-full flex-col",children:i.jsxs(ste,{value:t,onValueChange:n,className:"flex h-full flex-col",children:[i.jsx(AKe,{enabled:e,onFailedClick:h}),i.jsx($Oe,{connectionState:c,className:"mx-4 mt-2"}),i.jsxs(r5,{className:"mx-4 mt-3 shrink-0",children:[i.jsx(mw,{value:"connections",children:"Connections"}),i.jsx(mw,{value:"activity",children:"Activity"})]}),i.jsx(He,{mode:"wait",children:i.jsxs(oe.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:"min-h-0 flex-1 overflow-y-auto",children:[i.jsx(xR,{value:"connections",className:"h-full",children:i.jsx(i7,{enabled:e})}),i.jsx(xR,{value:"activity",className:"h-full",children:i.jsx(XGe,{enabled:e,deadLetterRef:l,onSwitchToChannels:()=>n("connections"),autoShowFailures:a})})]},t)})]})},"mode-b"):i.jsx(oe.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"flex h-full flex-col",children:s?i.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:i.jsx(i7,{enabled:e})}):i.jsx(TKe,{onAddChannel:()=>r(!0)})},"mode-a")}):i.jsx(a5,{icon:zX,name:"Relay",description:"Relay provides inter-agent messaging. Start DorkOS with relay enabled.",command:"DORKOS_RELAY_ENABLED=true dorkos"})}const MKe={connected:"bg-green-500",disconnected:"bg-muted-foreground",error:"bg-red-500",starting:"bg-amber-500 motion-safe:animate-pulse",stopping:"bg-amber-500 motion-safe:animate-pulse",reconnecting:"bg-amber-500 motion-safe:animate-pulse"},sct={connected:"Connected",disconnected:"Ready",error:"Error",starting:"Connecting…",stopping:"Stopping…",reconnecting:"Reconnecting…"},NN={"meet-dorkbot":"Meet DorkBot",discovery:"Create agents",tasks:"Set up Tasks schedules",adapters:"Connect adapters"},DKe=["discovery","tasks"];function OKe({onStepClick:e,onDismiss:t}){const{state:n}=fb(),s=vr();return i.jsxs(oe.div,{initial:s?!1:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.3},className:"border-border bg-card relative rounded-lg border p-3",children:[i.jsx("button",{onClick:t,className:"text-muted-foreground/50 hover:text-muted-foreground absolute top-1.5 right-1.5 rounded-md p-0.5 transition-colors duration-150","aria-label":"Dismiss getting started",children:i.jsx(ls,{className:"size-3.5"})}),i.jsx("h3",{className:"mb-2 text-xs font-medium",children:"Getting Started"}),i.jsx("ul",{className:"space-y-1",children:DKe.map((r,a)=>{const o=n.completedSteps.includes(r),l=n.skippedSteps.includes(r);return o?i.jsxs("li",{className:"flex items-center gap-2 py-0.5",children:[i.jsx(Zt,{className:"text-primary size-3.5 shrink-0"}),i.jsx("span",{className:"text-muted-foreground text-xs",children:NN[r]})]},r):l?i.jsxs("li",{className:"flex items-center gap-2 py-0.5",children:[i.jsx(mTe,{className:"text-muted-foreground/40 size-3.5 shrink-0"}),i.jsx("button",{onClick:()=>e(a),className:X("text-muted-foreground/40 text-left text-xs transition-colors duration-150","hover:text-muted-foreground"),children:NN[r]})]},r):i.jsxs("li",{className:"flex items-center gap-2 py-0.5",children:[i.jsx(Yk,{className:"text-muted-foreground size-3.5 shrink-0"}),i.jsx("button",{onClick:()=>e(a),className:"text-foreground text-left text-xs transition-colors duration-150 hover:underline",children:NN[r]})]},r)})})]})}function IKe(e){return`set${e.charAt(0).toUpperCase()}${e.slice(1)}`}function PKe(e){const t=qm(),n=Qf(),s=Gm();switch(e){case"settings":return{isOpen:t.isOpen,close:t.close};case"tasks":return{isOpen:n.isOpen,close:n.close};case"relay":return{isOpen:s.isOpen,close:s.close};default:return{isOpen:!1,close:()=>{}}}}function LKe({contribution:e}){const t=je(u=>u[e.openStateKey]),n=je(u=>u[IKe(e.openStateKey)]),s=PKe(e.urlParam),r=s.isOpen,a=s.close,o=t||r,l=x.useCallback(u=>{n(u),!u&&r&&a()},[n,r,a]),c=e.component;return i.jsx(c,{open:o,onOpenChange:l})}function FKe(){const e=Fu("dialog"),t=je(s=>s.onboardingStep),n=je(s=>s.setOnboardingStep);return i.jsxs(i.Fragment,{children:[e.map(s=>i.jsx(LKe,{contribution:s},s.id)),t!==null&&i.jsx("div",{className:"bg-background fixed inset-0 z-50",children:i.jsx(rae,{initialStep:t,onComplete:()=>n(null)})})]})}function zKe(){const{theme:e,setTheme:t}=nC(),{fontFamily:n,setFontFamily:s,fontSize:r,setFontSize:a,resetPreferences:o}=je();return i.jsxs("div",{className:"space-y-4",children:[i.jsx(Jm,{actions:i.jsx("button",{onClick:()=>{o(),t("system")},className:"text-muted-foreground hover:text-foreground text-xs transition-colors duration-150",children:"Reset to defaults"}),children:"Appearance"}),i.jsx(Sa,{children:i.jsxs(Wr,{children:[i.jsx(os,{label:"Theme",description:"Choose your preferred color scheme",children:i.jsxs(Bn,{value:e,onValueChange:t,children:[i.jsx(Dn,{className:"w-32",children:i.jsx($n,{})}),i.jsxs(On,{children:[i.jsx(yt,{value:"light",children:"Light"}),i.jsx(yt,{value:"dark",children:"Dark"}),i.jsx(yt,{value:"system",children:"System"})]})]})}),i.jsx(os,{label:"Font family",description:"Choose the typeface for the interface",children:i.jsxs(Bn,{value:n,onValueChange:l=>s(l),children:[i.jsx(Dn,{className:"w-40",children:i.jsx($n,{})}),i.jsx(On,{children:AS.map(l=>i.jsx(yt,{value:l.key,children:i.jsxs("div",{className:"flex flex-col",children:[i.jsx("span",{children:l.displayName}),i.jsx("span",{className:"text-muted-foreground text-xs",children:l.description})]})},l.key))})]})}),i.jsx(os,{label:"Font size",description:"Adjust the text size across the interface",children:i.jsxs(Bn,{value:r,onValueChange:l=>a(l),children:[i.jsx(Dn,{className:"w-32",children:i.jsx($n,{})}),i.jsxs(On,{children:[i.jsx(yt,{value:"small",children:"Small"}),i.jsx(yt,{value:"medium",children:"Medium"}),i.jsx(yt,{value:"large",children:"Large"})]})]})})]})})]})}function BKe(){const{showTimestamps:e,setShowTimestamps:t,expandToolCalls:n,setExpandToolCalls:s,autoHideToolCalls:r,setAutoHideToolCalls:a,devtoolsOpen:o,toggleDevtools:l,showShortcutChips:c,setShowShortcutChips:u,showTaskCelebrations:f,setShowTaskCelebrations:h,enableNotificationSound:m,setEnableNotificationSound:g,enableTasksNotifications:b,setEnableTasksNotifications:v,promoEnabled:k,setPromoEnabled:w}=je();return i.jsxs("div",{className:"space-y-4",children:[i.jsx(Jm,{children:"Preferences"}),i.jsx(Sa,{children:i.jsxs(Wr,{children:[i.jsx(gi,{label:"Show timestamps",description:"Display message timestamps in chat",checked:e,onCheckedChange:t}),i.jsx(gi,{label:"Expand tool calls",description:"Auto-expand tool call details in messages",checked:n,onCheckedChange:s}),i.jsx(gi,{label:"Auto-hide tool calls",description:"Fade out completed tool calls after a few seconds",checked:r,onCheckedChange:a}),i.jsx(gi,{label:"Show shortcut chips",description:"Display shortcut hints below the message input",checked:c,onCheckedChange:u}),i.jsx(gi,{label:"Task celebrations",description:"Show animations when tasks complete",checked:f,onCheckedChange:h}),i.jsx(gi,{label:"Notification sound",description:"Play a sound when AI finishes responding (3s+ responses)",checked:m,onCheckedChange:g}),i.jsx(gi,{label:"Tasks run notifications",description:"Show a toast when a scheduled Tasks run completes",checked:b,onCheckedChange:v}),i.jsx(gi,{label:"Feature suggestions",description:"Show feature discovery cards on the dashboard and sidebar",checked:k,onCheckedChange:w}),i.jsx(gi,{label:"Show dev tools",description:"Enable developer tools panel",checked:o,onCheckedChange:()=>l()})]})})]})}const uae=he.createContext(null);function $Ke(){const e=he.useContext(uae);if(!e)throw new Error("StatusLine.Item must be used within a StatusLine.");return e}const HKe={duration:.2,ease:[.4,0,.2,1]};function UKe({sessionId:e,isStreaming:t,children:n}){const[s,r]=x.useState([]),a=x.useCallback(f=>{r(h=>h.includes(f)?h:[...h,f])},[]),o=x.useCallback(f=>{r(h=>h.filter(m=>m!==f))},[]),l=s[0]??null,c=s.length>0,u=x.useMemo(()=>({itemTransition:HKe,firstVisibleKey:l,registerItem:a,unregisterItem:o}),[l,a,o]);return i.jsxs(uae.Provider,{value:u,children:[i.jsx(He,{initial:!1,children:c&&i.jsx(oe.div,{role:"toolbar","aria-label":"Session status","aria-live":"polite","data-testid":"status-line",initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:[.4,0,.2,1]},className:"overflow-hidden",children:i.jsx(GKe,{children:i.jsx(He,{initial:!1,mode:"popLayout",children:he.Children.map(n,f=>{if(!he.isValidElement(f))return f;const h=f.props.itemKey;return h?he.cloneElement(f,{key:h}):f})})})})}),!c&&n]})}function VKe({itemKey:e,visible:t,children:n}){const{itemTransition:s,firstVisibleKey:r,registerItem:a,unregisterItem:o}=$Ke();if(x.useEffect(()=>{if(t)return a(e),()=>o(e)},[t,e,a,o]),!t)return null;const l=e===r;return i.jsxs(oe.div,{layout:"position",initial:{opacity:0,scale:.8,filter:"blur(4px)"},animate:{opacity:1,scale:1,filter:"blur(0px)"},exit:{opacity:0,scale:.8,filter:"blur(4px)"},transition:s,className:"inline-flex items-center gap-2",children:[!l&&i.jsx(qKe,{}),n]},e)}function qKe(){return i.jsx("span",{className:"text-muted-foreground/30","aria-hidden":"true",children:"·"})}function GKe({children:e}){const t=x.useRef(null),[n,s]=x.useState(!1),r=x.useCallback(()=>{const a=t.current;a&&s(a.scrollWidth-a.scrollLeft-a.clientWidth>1)},[]);return x.useEffect(()=>{const a=t.current;if(!a)return;r(),a.addEventListener("scroll",r,{passive:!0});const o=new ResizeObserver(r);return o.observe(a),()=>{a.removeEventListener("scroll",r),o.disconnect()}},[r]),i.jsxs("div",{className:"relative",children:[i.jsx("div",{ref:t,className:"text-muted-foreground scrollbar-none flex items-center gap-2 overflow-x-auto px-1 text-xs whitespace-nowrap",children:e}),i.jsx("div",{className:X("from-background pointer-events-none absolute top-0 right-0 bottom-0 w-8 bg-gradient-to-l to-transparent transition-opacity duration-200",n?"opacity-100":"opacity-0"),"aria-hidden":!0})]})}const La=Object.assign(UKe,{Item:VKe});function KKe({cwd:e}){const t=e.split("/").filter(Boolean).pop()??e;return i.jsxs("span",{className:"inline-flex items-center gap-1",title:e,children:[i.jsx(Gp,{className:"size-(--size-icon-xs)"}),i.jsx("span",{children:t})]})}function WKe(e){const t=Fe();return mt({queryKey:["git-status",e],queryFn:()=>t.getGitStatus(e??void 0),enabled:!!e,refetchInterval:Va.GIT_STATUS_REFETCH_MS,refetchIntervalInBackground:!1,staleTime:Va.GIT_STATUS_STALE_TIME_MS})}function YKe(e){return!!e&&!("error"in e)}function ZKe({data:e}){if(!e)return null;if(!YKe(e))return i.jsxs("span",{className:"text-muted-foreground/50 inline-flex items-center gap-1",title:"Not a git repository",children:[i.jsx(EA,{className:"size-(--size-icon-xs)"}),i.jsx("span",{children:"No repo"})]});const t=e.modified+e.staged+e.untracked,n=t===1?"1 change":`${t} changes`,s=[];e.modified>0&&s.push(`${e.modified} modified`),e.staged>0&&s.push(`${e.staged} staged`),e.untracked>0&&s.push(`${e.untracked} untracked`),e.conflicted>0&&s.push(`${e.conflicted} conflicted`);const r=s.length>0?`${e.branch} · ${s.join(", ")}`:`${e.branch} · clean`;return i.jsxs("span",{className:"inline-flex items-center gap-1",title:r,children:[i.jsx(EA,{className:"size-(--size-icon-xs)"}),i.jsx("span",{className:"max-w-[25ch] truncate",children:e.branch}),e.ahead>0&&i.jsxs("span",{className:"text-muted-foreground inline-flex items-center gap-0.5",children:[i.jsx(Gk,{className:"size-(--size-icon-xs)"}),e.ahead]}),e.behind>0&&i.jsxs("span",{className:"text-muted-foreground inline-flex items-center gap-0.5",children:[i.jsx(qk,{className:"size-(--size-icon-xs)"}),e.behind]}),t>0&&i.jsxs("span",{className:"text-muted-foreground",children:["· ",n]})]})}const dae=["capabilities"];function XKe(){const e=Fe();return mt({queryKey:[...dae],queryFn:()=>e.getCapabilities(),staleTime:1/0})}function QKe(){const{data:e}=XKe();if(e)return e.capabilities[e.defaultRuntime]}function fae(e){const t=Fe(),{data:n}=mt({queryKey:[...dae,"active",e],queryFn:async()=>{if(!e)return null;const[s,r]=await Promise.all([t.getSessionRuntimeType(e),t.getCapabilities()]);return r.capabilities[s]??null},enabled:!!e,staleTime:1/0});return n??void 0}const l7={default:Ho,acceptEdits:Qk,plan:JCe,dontAsk:DX,bypassPermissions:eD,auto:$y,"always-allow":Zt,"always-deny":Vm,scripted:CX},c7={bypassPermissions:!0,auto:!0,"always-allow":!0},u7=Ho,JKe={auto:"Preview"},eWe="Auto mode requires Opus 4.6+ or Sonnet 4.6",tWe={default:"Default",acceptEdits:"Accept Edits",plan:"Plan Mode",dontAsk:"Don't Ask",bypassPermissions:"Bypass All",auto:"Auto"};function nWe({mode:e,onChangeMode:t,disabled:n,sessionId:s,modelSupportsAutoMode:r}){const a=fae(s),o=QKe(),l=s?a:o;if(l&&!l.permissionModes.supported)return null;const c=(l==null?void 0:l.permissionModes.values)??[],u=!r&&c.some(k=>k.id==="auto"),f=u?c.filter(k=>k.id!=="auto"):c,h=f.find(k=>k.id===e),m=(h==null?void 0:h.label)??tWe[e]??e,g=l7[e]??u7,b=c7[e]??!1,v=i.jsxs("button",{disabled:n,className:`hover:text-foreground inline-flex items-center gap-1 transition-colors duration-150 disabled:cursor-not-allowed disabled:opacity-40 ${b?"text-red-500":""}`,children:[i.jsx(g,{className:"size-(--size-icon-xs)"}),i.jsx("span",{children:m})]});return n?i.jsxs(Kn,{children:[i.jsx(Wn,{asChild:!0,children:i.jsx("span",{className:"inline-flex",children:v})}),i.jsx(Yn,{side:"top",children:"Send a message first"})]}):i.jsxs(O5e,{children:[i.jsx(I5e,{asChild:!0,children:v}),i.jsxs(P5e,{side:"top",align:"start",className:"w-56",children:[i.jsx(L5e,{children:"Permission Mode"}),i.jsx(F5e,{value:e,onValueChange:k=>t(k),children:f.map(k=>{const w=l7[k.id]??u7,C=c7[k.id]??!1,E=JKe[k.id];return i.jsx(z5e,{value:k.id,icon:w,description:k.description,className:C?"text-red-500":"",children:i.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[k.label,E&&i.jsx("span",{className:"bg-muted text-muted-foreground rounded px-1 py-px text-[10px] font-medium tracking-wide uppercase",children:E})]})},k.id)})}),u&&i.jsxs(Kn,{children:[i.jsx(Wn,{asChild:!0,children:i.jsxs("p",{"data-testid":"auto-unsupported-hint",className:"text-muted-foreground flex items-center gap-1.5 px-2 py-1.5 text-[10px]",children:[i.jsx($y,{className:"size-(--size-icon-xs) shrink-0"}),"Auto unavailable on this model"]})}),i.jsx(Yn,{side:"top",children:eWe})]})]})]})}function sWe({open:e,onOpenChange:t,onConfirm:n}){return i.jsx(th,{open:e,onOpenChange:t,children:i.jsxs(Bu,{children:[i.jsxs(nh,{children:[i.jsxs($u,{className:"flex items-center gap-2",children:[i.jsx($y,{className:"size-4 text-red-500"}),"Turn on Auto mode",i.jsx(Ot,{variant:"secondary",className:"text-[10px] tracking-wide uppercase",children:"Preview"})]}),i.jsx(Hu,{children:"The agent runs on its own and only checks with you before risky actions — like deleting files or running unfamiliar commands. You can switch back anytime."})]}),i.jsxs(sh,{children:[i.jsx(Vu,{children:"Cancel"}),i.jsx(Uu,{onClick:n,children:"Turn on Auto mode"})]})]})})}const JR={none:{label:"None",description:"No reasoning"},minimal:{label:"Minimal",description:"Near-zero thinking"},low:{label:"Low",description:"Fastest responses"},medium:{label:"Medium",description:"Moderate thinking"},high:{label:"High",description:"Deep reasoning"},max:{label:"Max",description:"Maximum thinking"},xhigh:{label:"XHigh",description:"Beyond maximum"}},rWe={duration:.15,ease:"easeOut"};function aWe(e){return e>=1e6?`${Math.round(e/1e6)}M`:e>=1e3?`${Math.round(e/1e3)}K`:String(e)}function iWe(e,t){const n=t.find(r=>r.value===e);if(n)return n.displayName;const s=e.match(/claude-(\w+)-/);return s?s[1].charAt(0).toUpperCase()+s[1].slice(1):e}function oWe(){return i.jsx("div",{className:"space-y-2","data-testid":"model-cards-skeleton",children:Array.from({length:3}).map((e,t)=>i.jsxs("div",{className:"flex items-center gap-3 rounded-xl p-3",children:[i.jsx(on,{className:"size-4 rounded-full"}),i.jsxs("div",{className:"flex-1 space-y-1.5",children:[i.jsx(on,{className:"h-3.5 w-24"}),i.jsx(on,{className:"h-2.5 w-32"})]}),i.jsx(on,{className:"h-5 w-10 rounded-md"})]},t))})}function lWe({onRetry:e}){return i.jsxs("div",{className:"flex flex-col items-center gap-3 py-6 text-center","data-testid":"model-load-error",children:[i.jsx(Wk,{className:"text-muted-foreground size-5"}),i.jsx("p",{className:"text-muted-foreground text-xs",children:"Failed to load models"}),i.jsxs("button",{onClick:e,className:"text-foreground hover:bg-accent inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-xs transition-colors",children:[i.jsx(mu,{className:"size-3"}),"Retry"]})]})}function cWe({model:e,isSelected:t}){return i.jsxs("label",{className:X("flex w-full cursor-pointer items-center gap-3 rounded-xl border p-3 transition-colors duration-150",t?"bg-secondary border-foreground/15":"border-border hover:border-muted-foreground/30 hover:bg-muted/50 opacity-70"),children:[i.jsx(Xx,{value:e.value,className:"shrink-0"}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("div",{className:"text-foreground truncate text-sm font-medium",children:e.displayName}),i.jsx("div",{className:"text-muted-foreground truncate text-[11px] leading-tight",children:e.description})]}),e.contextWindow&&i.jsx(Ot,{variant:"secondary",className:"shrink-0 text-[10px]",children:aWe(e.contextWindow)})]})}function uWe({effortLevels:e,effort:t,onChangeEffort:n}){return i.jsxs("div",{children:[i.jsx("div",{className:"text-muted-foreground mb-2 text-[11px] font-medium tracking-wide uppercase",children:"Effort"}),i.jsxs("div",{className:"flex flex-wrap gap-1.5",role:"radiogroup","aria-label":"Effort level",children:[i.jsx(d7,{label:"Default",isSelected:t===null,onClick:()=>n(null)}),e.map(s=>i.jsx(d7,{label:JR[s].label,description:JR[s].description,isSelected:t===s,onClick:()=>n(s)},s))]})]})}function d7({label:e,description:t,isSelected:n,onClick:s}){const r=i.jsx("button",{role:"radio","aria-checked":n,onClick:s,className:X("rounded-md px-2.5 py-1 text-xs font-medium transition-colors duration-150",n?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:bg-muted/80 hover:text-foreground"),children:e});return t?i.jsxs(Kn,{children:[i.jsx(Wn,{asChild:!0,children:r}),i.jsx(Yn,{side:"top",className:"text-xs",children:t})]}):r}function dWe({supportsFastMode:e,fastMode:t,onChangeFastMode:n}){return e?i.jsxs("div",{children:[i.jsx("div",{className:"text-muted-foreground mb-2 text-[11px] font-medium tracking-wide uppercase",children:"Mode"}),i.jsx("div",{className:"flex gap-1.5",children:i.jsx(fWe,{label:"Fast",icon:i.jsx(Pu,{className:"size-3"}),isActive:t,onToggle:()=>n(!t)})})]}):null}function fWe({label:e,icon:t,isActive:n,onToggle:s}){return i.jsxs("button",{role:"switch","aria-checked":n,onClick:s,className:X("inline-flex items-center gap-1.5 rounded-md px-2.5 py-1 text-xs font-medium transition-colors duration-150",n?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:bg-muted/80 hover:text-foreground"),children:[t,e]})}function hWe({model:e,onChangeModel:t,effort:n,onChangeEffort:s,fastMode:r,onChangeFastMode:a,disabled:o,sessionId:l}){const{data:c,isLoading:u,isError:f,refetch:h}=aD(l),m=c??[],g=m.find(C=>C.value===e),b=(g==null?void 0:g.supportsEffort)&&g.supportedEffortLevels&&g.supportedEffortLevels.length>0,v=(g==null?void 0:g.supportsFastMode)??!1,k=n?JR[n].label:null,w=i.jsxs("button",{disabled:o,className:"hover:text-foreground inline-flex items-center gap-1 transition-colors duration-150 disabled:cursor-not-allowed disabled:opacity-40","data-testid":"model-config-trigger",children:[i.jsx(zy,{className:"size-(--size-icon-xs)"}),i.jsx("span",{children:iWe(e,m)}),k&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-muted-foreground text-[11px]",children:"·"}),i.jsx(Ot,{variant:"secondary",className:"px-1.5 py-0 text-[10px]",children:k})]}),r&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-muted-foreground text-[11px]",children:"·"}),i.jsxs(Ot,{variant:"secondary",className:"px-1.5 py-0 text-[10px]",children:[i.jsx(Pu,{className:"mr-0.5 inline size-2.5"}),"Fast"]})]})]});return o?i.jsxs(Kn,{children:[i.jsx(Wn,{asChild:!0,children:i.jsx("span",{className:"inline-flex",children:w})}),i.jsx(Yn,{side:"top",children:"Send a message first"})]}):i.jsxs(XD,{children:[i.jsx(QD,{asChild:!0,children:w}),i.jsxs(JD,{side:"top",align:"start",className:"w-80 p-3","data-testid":"model-config-popover",children:[i.jsx(e5,{children:"Model"}),u&&i.jsx(oWe,{}),f&&i.jsx(lWe,{onRetry:()=>h()}),!u&&!f&&i.jsx(YD,{value:e,onValueChange:t,className:"grid-cols-1 gap-1.5","aria-label":"Model selection","data-testid":"model-card-list",children:m.map(C=>i.jsx(cWe,{model:C,isSelected:C.value===e},C.value))}),i.jsx(He,{children:!u&&!f&&(b||v)&&i.jsxs(oe.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:4},transition:rWe,children:[i.jsx(VS,{className:"my-3"}),i.jsx("div",{className:"text-muted-foreground mb-3 text-[11px] font-medium tracking-wide uppercase",children:"Configuration"}),i.jsxs("div",{className:"space-y-3",children:[b&&i.jsx(uWe,{effortLevels:g.supportedEffortLevels,effort:n,onChangeEffort:s}),v&&i.jsx(dWe,{supportsFastMode:(g==null?void 0:g.supportsFastMode)??!1,fastMode:r,onChangeFastMode:a})]})]},"config")})]})]})}function pWe({costUsd:e}){return i.jsxs("span",{className:"inline-flex items-center gap-1",children:[i.jsx(EX,{className:"size-(--size-icon-xs)"}),i.jsxs("span",{children:["$",e.toFixed(2)]})]})}function jN(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function mWe({cacheReadTokens:e,cacheCreationTokens:t,contextTokens:n}){const s=n??e+t,r=Math.max(0,s-e-t),a=s>0?Math.round(e/s*100):0,o=a>=70?"text-emerald-500":a>=30?"":"text-amber-500";return i.jsxs(Kn,{children:[i.jsx(Wn,{asChild:!0,children:i.jsxs("span",{className:X("inline-flex cursor-default items-center gap-1",o),"aria-label":"Prompt cache hit rate",children:[i.jsx(Pu,{className:"size-(--size-icon-xs)"}),i.jsxs("span",{children:[a,"%"]})]})}),i.jsx(Yn,{side:"top",className:"max-w-56",children:i.jsxs("div",{className:"space-y-1",children:[i.jsx("div",{className:"text-xs font-medium",children:"Prompt Cache"}),i.jsxs("div",{className:"space-y-0.5 text-[10px]",children:[i.jsxs("div",{className:"flex justify-between gap-3",children:[i.jsx("span",{className:"text-muted-foreground",children:"Cache hits"}),i.jsx("span",{children:jN(e)})]}),i.jsxs("div",{className:"flex justify-between gap-3",children:[i.jsx("span",{className:"text-muted-foreground",children:"Cache writes"}),i.jsx("span",{children:jN(t)})]}),n!=null&&n>0&&i.jsxs("div",{className:"flex justify-between gap-3",children:[i.jsx("span",{className:"text-muted-foreground",children:"Uncached"}),i.jsx("span",{children:jN(r)})]})]})]})})]})}function AN(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function gWe({percent:e,contextUsage:t}){const n=t?Math.round(t.percentage):e,s=n>=95?"text-red-500":n>=80?"text-amber-500":"",r=i.jsxs("span",{className:X("inline-flex items-center gap-1",s),children:[i.jsx(GEe,{className:"size-(--size-icon-xs)"}),i.jsxs("span",{children:[n,"%"]})]});if(!t)return r;const a=t.categories.filter(o=>o.tokens>0).sort((o,l)=>l.tokens-o.tokens);return i.jsxs(Kn,{children:[i.jsx(Wn,{asChild:!0,children:i.jsx("span",{className:"inline-flex cursor-default","aria-label":"Context window usage",children:r})}),i.jsx(Yn,{side:"top",className:"max-w-64",children:i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs("div",{className:"text-xs font-medium",children:[AN(t.totalTokens)," / ",AN(t.maxTokens)," tokens"]}),a.length>0&&i.jsx("div",{className:"space-y-0.5",children:a.map(o=>i.jsxs("div",{className:"flex items-center justify-between gap-3 text-[10px]",children:[i.jsxs("span",{className:"flex items-center gap-1 truncate",children:[i.jsx("span",{className:"inline-block size-1.5 shrink-0 rounded-full",style:{backgroundColor:o.color}}),o.name]}),i.jsx("span",{className:"text-muted-foreground shrink-0",children:AN(o.tokens)})]},o.name))})]})})]})}function xWe(e){if(!e)return"Rate limit";switch(e){case"five_hour":return"5-hour window";case"seven_day":return"7-day window";case"seven_day_opus":return"7-day Opus";case"seven_day_sonnet":return"7-day Sonnet";case"overage":return"Overage";default:return e}}function yWe({usageInfo:e}){const t=e.utilization!=null?Math.round(e.utilization*100):null,n=e.status==="allowed_warning",s=e.status==="rejected",r=s?"text-red-500":n||t!=null&&t>=80?"text-amber-500":"",a=e.resetsAt?new Date(e.resetsAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):null;return i.jsxs(Kn,{children:[i.jsx(Wn,{asChild:!0,children:i.jsxs("span",{className:X("inline-flex cursor-default items-center gap-1",r),"aria-label":"Subscription usage",children:[i.jsx(NX,{className:"size-(--size-icon-xs)"}),t!=null&&i.jsxs("span",{children:[t,"%"]}),t==null&&s&&i.jsx("span",{children:"Limit"})]})}),i.jsx(Yn,{side:"top",className:"max-w-56",children:i.jsxs("div",{className:"space-y-1",children:[i.jsx("div",{className:"text-xs font-medium",children:"Subscription Usage"}),i.jsxs("div",{className:"space-y-0.5 text-[10px]",children:[t!=null&&i.jsxs("div",{className:"flex justify-between gap-3",children:[i.jsx("span",{className:"text-muted-foreground",children:"Utilization"}),i.jsxs("span",{children:[t,"%"]})]}),i.jsxs("div",{className:"flex justify-between gap-3",children:[i.jsx("span",{className:"text-muted-foreground",children:"Window"}),i.jsx("span",{children:xWe(e.rateLimitType)})]}),a&&i.jsxs("div",{className:"flex justify-between gap-3",children:[i.jsx("span",{className:"text-muted-foreground",children:"Resets at"}),i.jsx("span",{children:a})]}),e.isUsingOverage&&i.jsx("div",{className:"text-amber-500",children:"Using overage capacity"}),s&&i.jsx("div",{className:"text-red-500",children:"Rate limit reached"})]})]})})]})}function bWe({enabled:e,onToggle:t}){const n=e?qX:H_e;return i.jsx("button",{onClick:t,className:"hover:text-foreground inline-flex items-center gap-1 transition-colors duration-150","aria-label":e?"Mute notification sound":"Unmute notification sound",title:e?"Sound on — click to mute":"Sound off — click to unmute",children:i.jsx(n,{className:"size-(--size-icon-xs)"})})}function vWe({enabled:e,onToggle:t}){const n=e?D_e:R_e;return i.jsxs(GD,{openDelay:300,children:[i.jsx(KD,{asChild:!0,children:i.jsx("button",{onClick:t,className:"hover:text-foreground inline-flex items-center gap-1 transition-colors duration-150","aria-label":e?"Disable background refresh":"Enable background refresh",children:i.jsx(n,{className:"size-(--size-icon-xs)"})})}),i.jsxs(WD,{side:"top",align:"center",className:"w-64 p-3",children:[i.jsxs("p",{className:"text-sm font-medium",children:["Background refresh ",e?"on":"off"]}),i.jsx("p",{className:"text-muted-foreground mt-1.5 text-xs leading-relaxed",children:e?"Messages are checked for updates periodically, even when no one is typing. Useful if agents run in the background. Turn off to reduce network usage.":"Messages only update while someone is actively responding. Turn on if you have agents running unattended and want to see their progress."})]})]})}const SWe={connecting:{color:"bg-amber-500",label:"Connecting",icon:G1,tasks:!0},connected:{color:"bg-emerald-500",label:"Connected",icon:G1,tasks:!1},reconnecting:{color:"bg-amber-500",label:"Reconnecting",icon:G1,tasks:!0},disconnected:{color:"bg-red-500",label:"Connection lost",icon:Jk,tasks:!1}};function wWe({connectionState:e,failedAttempts:t}){const n=e!=="connected",s=SWe[e],r=s.icon,a=t&&e==="reconnecting"?`Reconnecting (${t}/${Id.DISCONNECTED_THRESHOLD})`:s.label;return i.jsx(La.Item,{itemKey:"connection",visible:n,children:i.jsxs(GD,{openDelay:200,children:[i.jsx(KD,{asChild:!0,children:i.jsxs("span",{className:"flex cursor-default items-center gap-1.5 text-xs",role:"status",children:[i.jsx("span",{className:X("size-1.5 rounded-full",s.color,s.tasks&&"animate-tasks")}),i.jsx("span",{className:"text-muted-foreground",children:a})]})}),i.jsx(WD,{side:"top",align:"center",className:"w-72 p-3",children:i.jsxs("div",{className:"flex items-start gap-2.5",children:[i.jsx(r,{className:X("mt-0.5 size-4 shrink-0",e==="disconnected"?"text-red-500":"text-amber-500")}),i.jsxs("div",{className:"min-w-0 space-y-1.5",children:[i.jsx("p",{className:"text-sm font-medium",children:a}),i.jsx(kWe,{connectionState:e})]})]})})]})})}function kWe({connectionState:e}){const t="text-muted-foreground text-xs leading-relaxed";return e==="connecting"?i.jsx("p",{className:t,children:"Opening the live connection to this session. New messages and updates appear once it's open."}):e==="reconnecting"?i.jsxs("div",{className:"space-y-1.5",children:[i.jsx("p",{className:t,children:"The live connection dropped and is reconnecting automatically. Incoming messages and updates are paused — nothing is lost; anything missed replays when it reconnects."}),i.jsx("p",{className:X(t,"text-muted-foreground/70"),children:"No action needed."})]}):i.jsxs("div",{className:"space-y-1.5",children:[i.jsx("p",{className:t,children:"Could not re-establish the live connection after several attempts. New messages and updates will not appear until it's restored."}),i.jsx("p",{className:X(t,"text-muted-foreground/70"),children:"Try refreshing the page. If the issue persists, check that the DorkOS server is running."})]})}function CWe({subagents:e}){return i.jsxs(Kn,{children:[i.jsx(Wn,{asChild:!0,children:i.jsxs("span",{className:"inline-flex items-center gap-1",children:[i.jsx(Hy,{className:"size-(--size-icon-xs)"}),i.jsxs("span",{children:[e.length," agent",e.length!==1?"s":""]})]})}),i.jsx(Yn,{side:"top",className:"max-w-64",children:i.jsx("ul",{className:"space-y-1",children:e.map(t=>i.jsxs("li",{children:[i.jsx("span",{className:"font-medium",children:t.name}),t.model&&i.jsxs("span",{className:"text-muted-foreground ml-1 text-[10px]",children:["(",t.model,")"]}),i.jsx("p",{className:"text-muted-foreground line-clamp-1 text-[10px] leading-tight",children:t.description})]},t.name))})})]})}const EWe={session:"Session Info",controls:"Controls"},mb=[{key:"cwd",label:"Directory",description:"Current working directory",group:"session",icon:Kf,defaultVisible:!0},{key:"git",label:"Git Status",description:"Branch name and change count",group:"session",icon:EA,defaultVisible:!0},{key:"model",label:"Model",description:"Selected AI model",group:"session",icon:zy,defaultVisible:!0},{key:"cost",label:"Cost",description:"Session cost in USD",group:"session",icon:EX,defaultVisible:!0},{key:"cache",label:"Cache",description:"Prompt cache hit rate",group:"session",icon:Pu,defaultVisible:!0},{key:"context",label:"Context Usage",description:"Context window utilization",group:"session",icon:FCe,defaultVisible:!0},{key:"usage",label:"Usage",description:"Subscription utilization",group:"session",icon:NX,defaultVisible:!0},{key:"permission",label:"Permission Mode",description:"Agent permission level selector",group:"controls",icon:Ho,defaultVisible:!0},{key:"sound",label:"Sound",description:"Notification sound toggle",group:"controls",icon:qX,defaultVisible:!0},{key:"polling",label:"Refresh",description:"Background polling for updates",group:"controls",icon:mu,defaultVisible:!0}];function hae(e){const t=e.charAt(0).toUpperCase()+e.slice(1),n=`showStatusBar${t}`,s=`setShowStatusBar${t}`,r=je(o=>o[n]),a=je(o=>o[s]);return[r,a]}function aE(){const e=je.getState();for(const t of mb){const s=`setShowStatusBar${t.key.charAt(0).toUpperCase()+t.key.slice(1)}`,r=e[s];r(t.defaultVisible)}}function TWe(){return["session","controls"].map(t=>({group:t,label:EWe[t],items:mb.filter(n=>n.group===t)})).filter(t=>t.items.length>0)}function _We({itemKey:e}){const t=mb.find(a=>a.key===e),[n,s]=hae(e);if(!t)return null;const r=t.icon;return i.jsx(os,{label:i.jsxs("span",{className:"flex items-center gap-1.5",children:[i.jsx(r,{className:"text-muted-foreground size-3.5 shrink-0","aria-hidden":!0}),t.label]}),description:t.description,children:i.jsx(Ks,{checked:n,onCheckedChange:s,"aria-label":`Toggle ${t.label}`})})}function pae(){const e=TWe();return i.jsxs("div",{className:"flex flex-col gap-4","aria-label":"Status bar configuration",children:[e.map(t=>i.jsxs("div",{className:"space-y-1.5",children:[i.jsx("p",{className:"text-muted-foreground px-1 text-xs font-medium tracking-wide uppercase",children:t.label}),i.jsx(Sa,{children:i.jsx(Wr,{children:t.items.map(n=>i.jsx(_We,{itemKey:n.key},n.key))})})]},t.group)),i.jsx(ve,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground h-auto justify-start px-1 py-1 text-xs",onClick:aE,children:"Reset to defaults"})]})}pae.displayName="StatusBarConfigureContent";function mae({children:e,open:t,onOpenChange:n}){return i.jsxs(XD,{open:t,onOpenChange:n,children:[i.jsx(QD,{asChild:!0,children:e}),i.jsxs(JD,{side:"top",align:"end",className:"w-72 p-3","aria-label":"Status bar configuration",children:[i.jsx(e5,{children:"Configure Status Bar"}),i.jsx(pae,{})]})]})}mae.displayName="StatusBarConfigurePopover";function gae(e,t){const[n,s,r]=e.split(".").map(Number),[a,o,l]=t.split(".").map(Number);return n!==a?n>a:s!==o?s>o:r>l}function NWe(e,t){const[n,s]=e.split(".").map(Number),[r,a]=t.split(".").map(Number);return n!==r||s!==a}function jWe({item:e}){const[t,n]=hae(e.key);return i.jsx(gi,{label:e.label,description:e.description,checked:t,onCheckedChange:n})}function AWe(){return i.jsxs("div",{className:"space-y-4",children:[i.jsx(Jm,{actions:i.jsx("button",{onClick:aE,className:"text-muted-foreground hover:text-foreground text-xs transition-colors duration-150",children:"Reset to defaults"}),children:"Status Bar"}),i.jsx(Sa,{children:i.jsx(Wr,{children:mb.map(e=>i.jsx(jWe,{item:e},e.key))})})]})}function RWe(){const e=Fe(),{data:t,isLoading:n}=mt({queryKey:["config"],queryFn:()=>e.getConfig(),staleTime:3e4});return i.jsx("div",{className:"space-y-3",children:n?i.jsx("div",{className:"space-y-2",children:Array.from({length:5}).map((s,r)=>i.jsxs("div",{className:"flex items-center justify-between py-1",children:[i.jsx("div",{className:"bg-muted animate-tasks h-4 w-24 rounded"}),i.jsx("div",{className:"bg-muted animate-tasks h-4 w-16 rounded"})]},r))}):t?i.jsxs("div",{className:"space-y-1",children:[t.isDevMode?i.jsxs("div",{className:"-mx-1 rounded border border-amber-200 bg-amber-50 px-2 py-1.5 dark:border-amber-800 dark:bg-amber-950/30",children:[i.jsx("span",{className:"text-sm font-medium text-amber-800 dark:text-amber-200",children:"Development Build"}),i.jsx("p",{className:"mt-0.5 text-xs text-amber-700 dark:text-amber-300",children:"Running from source — version checks disabled"})]}):i.jsxs(i.Fragment,{children:[i.jsx(hl,{label:"Version",value:t.version}),t.latestVersion&&gae(t.latestVersion,t.version)&&i.jsxs("div",{className:"-mx-1 rounded border border-amber-200 bg-amber-50 px-2 py-1.5 dark:border-amber-800 dark:bg-amber-950/30",children:[i.jsx("div",{className:"flex items-center justify-between",children:i.jsxs("span",{className:"text-sm font-medium text-amber-800 dark:text-amber-200",children:["Update available: v",t.latestVersion]})}),i.jsxs("p",{className:"mt-0.5 text-xs text-amber-700 dark:text-amber-300",children:["Run"," ",i.jsx("code",{className:"rounded bg-amber-100 px-1 py-0.5 font-mono text-[10px] dark:bg-amber-900/50",children:"npm update -g dorkos"})," ","to update"]})]})]}),i.jsx(hl,{label:"Port",value:String(t.port)}),i.jsx(hl,{label:"Uptime",value:MWe(t.uptime)}),i.jsx(hl,{label:"API URL",value:`http://localhost:${t.port}`,mono:!0}),i.jsx(hl,{label:"MCP Endpoint",value:`http://localhost:${t.port}/mcp`,mono:!0}),i.jsx(hl,{label:"Working Directory",value:t.workingDirectory,mono:!0,truncate:!0}),i.jsx(hl,{label:"Data Directory",value:t.dorkHome,mono:!0,truncate:!0}),i.jsx(hl,{label:"Boundary",value:t.boundary,mono:!0,truncate:!0}),i.jsx(hl,{label:"Node.js",value:t.nodeVersion})]}):null})}function hl({label:e,value:t,mono:n,truncate:s,muted:r}){const[a,o]=Bx();return i.jsxs("button",{type:"button",onClick:()=>o(t),className:"hover:bg-muted/50 active:bg-muted/70 -mx-1 flex w-full items-center justify-between gap-4 rounded px-1 py-1 transition-colors duration-100",children:[i.jsx("span",{className:"text-muted-foreground shrink-0 text-sm",children:e}),a?i.jsx("span",{className:"text-muted-foreground text-xs",children:"Copied"}):i.jsx("span",{className:X("text-right text-sm",n&&"font-mono",s&&"max-w-48 min-w-0 truncate",r&&"text-muted-foreground"),dir:s?"rtl":void 0,title:t,children:t})]})}function MWe(e){const t=Math.floor(e/3600),n=Math.floor(e%3600/60),s=Math.floor(e%60),r=[];return t>0&&r.push(`${t}h`),n>0&&r.push(`${n}m`),r.push(`${s}s`),r.join(" ")}const DWe={relayTools:!0,meshTools:!0,adapterTools:!0,tasksTools:!0};function OWe(){const e=Fe(),t=Ct(),{data:n}=mt({queryKey:["config"],queryFn:()=>e.getConfig(),staleTime:3e4}),s={...DWe,...n==null?void 0:n.agentContext},r=mn({mutationFn:o=>e.updateConfig({agentContext:{...s,...o}}),onSuccess:()=>{t.invalidateQueries({queryKey:["config"]})}}),a=x.useCallback(o=>{r.mutate(o)},[r]);return{config:s,updateConfig:a}}const tx={core:["ping","get_server_info","get_session_count","get_agent","control_ui","get_ui_state"],tasks:["tasks_list","tasks_create","tasks_update","tasks_delete","tasks_get_run_history"],relay:["relay_send","relay_inbox","relay_list_endpoints","relay_register_endpoint","relay_send_and_wait","relay_send_async","relay_unregister_endpoint","relay_get_trace","relay_get_metrics"],mesh:["mesh_discover","mesh_register","mesh_list","mesh_deny","mesh_unregister","mesh_status","mesh_inspect","mesh_query_topology"],adapter:["relay_list_adapters","relay_enable_adapter","relay_disable_adapter","relay_reload_adapters","binding_list","binding_create","binding_delete","binding_list_sessions","relay_notify_user"]},f7={tasks:"tasksTools",relay:"relayTools",mesh:"meshTools",adapter:"adapterTools"},IWe=[{key:"tasks",label:"Tasks (Scheduling)",description:"Create and manage scheduled agent runs",tools:tx.tasks},{key:"relay",label:"Relay (Messaging)",description:"Send messages, check inbox, register endpoints",tools:tx.relay,implicitNote:"Includes trace tools (relay_get_trace, relay_get_metrics)"},{key:"mesh",label:"Mesh (Discovery)",description:"Discover, register, and query agents",tools:tx.mesh},{key:"adapter",label:"Relay Adapters",description:"Manage Telegram, Slack, webhooks, and bindings",tools:tx.adapter,implicitNote:"Includes binding tools (binding_list, binding_create, binding_delete)"}];function xae({tools:e,implicitNote:t}){return i.jsxs(Kn,{children:[i.jsx(Wn,{asChild:!0,children:i.jsx(Ot,{variant:"outline",className:"text-muted-foreground shrink-0 cursor-default text-xs font-normal",children:e.length})}),i.jsxs(Yn,{side:"top",className:"max-w-xs",children:[i.jsx("p",{className:"font-mono text-xs",children:e.join(", ")}),t&&i.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:t})]})]})}function PWe({group:e,enabled:t,available:n,initError:s,overrideCount:r,onToggle:a,expandContent:o}){const[l,c]=x.useState(!1),u=!!o,f=i.jsxs("div",{className:"flex items-center gap-2",children:[s&&i.jsxs(Kn,{children:[i.jsx(Wn,{asChild:!0,children:i.jsx(Yr,{className:"size-3.5 shrink-0 text-amber-500"})}),i.jsx(Yn,{side:"top",className:"max-w-xs",children:i.jsx("p",{className:"text-xs",children:s})})]}),!n&&!s&&i.jsx(Ot,{variant:"secondary",className:"text-xs",children:"Disabled"}),r>0&&i.jsxs(Kn,{children:[i.jsx(Wn,{asChild:!0,children:i.jsxs("span",{className:"text-muted-foreground shrink-0 text-xs",children:[r," ",r===1?"override":"overrides"]})}),i.jsx(Yn,{side:"top",children:i.jsxs("p",{className:"text-xs",children:[r," ",r===1?"agent has":"agents have"," a per-agent override for this group"]})})]}),i.jsx(xae,{tools:e.tools,implicitNote:e.implicitNote}),i.jsx(Ks,{checked:t,onCheckedChange:m=>a(e.key,m),disabled:!n,"aria-label":`Toggle ${e.label}`}),u&&i.jsx($l,{asChild:!0,children:i.jsx("button",{className:"text-muted-foreground hover:text-foreground rounded-sm p-0.5 transition-colors duration-150","aria-label":`${l?"Collapse":"Expand"} ${e.label} settings`,children:i.jsx(Ps,{className:X("size-3.5 transition-transform duration-150",!l&&"-rotate-90")})})})]}),h=i.jsx(os,{label:e.label,description:e.description,children:f});return u?i.jsxs(Bl,{open:l,onOpenChange:c,children:[h,i.jsx(Hl,{children:i.jsx("div",{className:"border-border mt-2 space-y-2 border-t pt-2",children:o})})]}):h}function LWe({scheduler:e,onUpdate:t}){return i.jsxs(i.Fragment,{children:[i.jsx(os,{label:"Concurrent runs",description:"Maximum parallel task runs",children:i.jsx(_n,{type:"number",min:1,max:10,value:e.maxConcurrentRuns,onChange:n=>{const s=parseInt(n.target.value,10);s>=1&&s<=10&&t({maxConcurrentRuns:s})},className:"w-20"})}),i.jsx(os,{label:"Timezone",description:"IANA timezone for cron schedules",children:i.jsxs(Bn,{value:e.timezone??"system",onValueChange:n=>t({timezone:n==="system"?null:n}),children:[i.jsx(Dn,{className:"w-48",children:i.jsx($n,{})}),i.jsxs(On,{children:[i.jsx(yt,{value:"system",children:"System default"}),i.jsx(yt,{value:"UTC",children:"UTC"}),i.jsx(yt,{value:"America/New_York",children:"America/New_York"}),i.jsx(yt,{value:"America/Chicago",children:"America/Chicago"}),i.jsx(yt,{value:"America/Denver",children:"America/Denver"}),i.jsx(yt,{value:"America/Los_Angeles",children:"America/Los_Angeles"}),i.jsx(yt,{value:"Europe/London",children:"Europe/London"}),i.jsx(yt,{value:"Europe/Berlin",children:"Europe/Berlin"}),i.jsx(yt,{value:"Europe/Paris",children:"Europe/Paris"}),i.jsx(yt,{value:"Asia/Tokyo",children:"Asia/Tokyo"}),i.jsx(yt,{value:"Asia/Shanghai",children:"Asia/Shanghai"}),i.jsx(yt,{value:"Asia/Kolkata",children:"Asia/Kolkata"}),i.jsx(yt,{value:"Australia/Sydney",children:"Australia/Sydney"})]})]})}),i.jsx(os,{label:"Run history",description:"Completed runs to keep",children:i.jsx(_n,{type:"number",min:1,max:1e4,value:e.retentionCount,onChange:n=>{const s=parseInt(n.target.value,10);s>=1&&t({retentionCount:s})},className:"w-24"})})]})}function FWe({authConfigured:e,authSource:t,generatedKey:n,keyError:s,onGenerate:r,onRotate:a,onRemove:o}){const[l,c]=Bx();return t==="env"?i.jsx(os,{label:"API Key",description:"Set via MCP_API_KEY environment variable",children:i.jsx(Ot,{variant:"outline",children:"Environment variable"})}):!e&&!n?i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"min-w-0",children:[i.jsx("p",{className:"text-sm font-medium",children:"API Key"}),i.jsx("p",{className:"text-muted-foreground text-xs",children:"Protect the MCP endpoint with bearer token auth"})]}),i.jsxs(ve,{size:"sm",onClick:r,children:[i.jsx(HEe,{className:"mr-1.5 size-3.5"}),"Generate Key"]})]}),s&&i.jsx("p",{className:"text-xs text-red-500",role:"alert",children:s})]}):n?i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"min-w-0",children:[i.jsx("p",{className:"text-sm font-medium",children:"API Key"}),i.jsx("p",{className:"text-muted-foreground text-xs",children:"Copy this key now — it won't be shown again"})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("code",{className:"bg-muted min-w-0 flex-1 truncate rounded-md px-3 py-2 font-mono text-xs",children:n}),i.jsx("button",{className:"text-muted-foreground hover:text-foreground shrink-0 rounded-sm p-1.5 transition-colors",onClick:()=>c(n),"aria-label":"Copy API key",children:l?i.jsx(Zt,{className:"size-4 text-green-500"}):i.jsx(Gf,{className:"size-4"})})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(ve,{variant:"outline",size:"sm",onClick:a,children:"Rotate"}),i.jsx(ve,{variant:"ghost",size:"sm",onClick:o,children:"Remove"})]}),s&&i.jsx("p",{className:"text-xs text-red-500",role:"alert",children:s})]}):i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"min-w-0",children:[i.jsx("p",{className:"text-sm font-medium",children:"API Key"}),i.jsx("p",{className:"text-muted-foreground text-xs",children:"Bearer token for MCP authentication"})]}),i.jsx("div",{className:"flex items-center gap-2",children:i.jsx("code",{className:"bg-muted rounded-md px-3 py-2 font-mono text-xs",children:"dork_mcp_••••••••"})}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(ve,{variant:"outline",size:"sm",onClick:a,children:"Rotate"}),i.jsx(ve,{variant:"ghost",size:"sm",onClick:o,children:"Remove"})]}),s&&i.jsx("p",{className:"text-xs text-red-500",role:"alert",children:s})]})}function zWe(){return i.jsxs("div",{className:"flex gap-3 rounded-md border border-amber-500/20 bg-amber-500/10 p-3",children:[i.jsx(Yr,{className:"mt-0.5 size-4 shrink-0 text-amber-500"}),i.jsxs("div",{className:"space-y-1",children:[i.jsx("p",{className:"text-xs font-medium",children:"Do not configure this for agents running inside DorkOS."}),i.jsxs("p",{className:"text-muted-foreground text-xs",children:["DorkOS already provides tools to its managed agents internally. Adding DorkOS as an external MCP server to those same agents causes duplicate tool names — the Anthropic API will return HTTP 400 “Tool names must be unique” and all tool calls will fail. External MCP access is for agents running ",i.jsx("strong",{children:"outside"})," of DorkOS (standalone Claude Code, Cursor, Windsurf)."]})]})]})}function BWe({endpoint:e}){return i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"min-w-0",children:[i.jsx("p",{className:"text-sm font-medium",children:"Endpoint"}),i.jsx("p",{className:"text-muted-foreground text-xs",children:"MCP server URL for external agents"})]}),i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx("code",{className:"bg-muted min-w-0 flex-1 truncate rounded-md px-3 py-2 font-mono text-xs",children:e}),i.jsx(hw,{value:e})]})]})}function $We({rateLimit:e,onUpdate:t}){return i.jsxs("div",{className:"space-y-3",children:[i.jsx(gi,{label:"Rate limiting",description:"Limit external MCP requests per time window",checked:e.enabled,onCheckedChange:n=>t({enabled:n}),ariaLabel:"Toggle rate limiting"}),e.enabled&&i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"flex items-center gap-4",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("label",{htmlFor:"mcp-max-requests",className:"text-muted-foreground text-xs",children:"Max requests"}),i.jsx(_n,{id:"mcp-max-requests",type:"number",min:1,max:1e3,value:e.maxPerWindow,onChange:n=>{const s=parseInt(n.target.value,10);s>=1&&s<=1e3&&t({maxPerWindow:s})},className:"w-20"})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("label",{htmlFor:"mcp-window-secs",className:"text-muted-foreground text-xs",children:"Window (sec)"}),i.jsx(_n,{id:"mcp-window-secs",type:"number",min:1,max:3600,value:e.windowSecs,onChange:n=>{const s=parseInt(n.target.value,10);s>=1&&s<=3600&&t({windowSecs:s})},className:"w-20"})]})]}),i.jsx("p",{className:"text-muted-foreground text-xs",children:"Rate limit changes take effect after server restart."})]})]})}function HWe(e,t){const n=t?`Bearer ${t}`:"Bearer dork_mcp_YOUR_API_KEY";return{claudeCode:JSON.stringify({mcpServers:{"dorkos-external":{type:"http",url:e,headers:{Authorization:n}}}},null,2),claudeCodeCli:`claude mcp add-json dorkos-external '${JSON.stringify({type:"http",url:e,headers:{Authorization:n}})}'`,cursor:JSON.stringify({mcpServers:{"dorkos-external":{url:e,headers:{Authorization:n}}}},null,2),windsurf:JSON.stringify({mcpServers:{"dorkos-external":{serverUrl:e,headers:{Authorization:n}}}},null,2)}}function UWe({endpoint:e,apiKey:t}){const[n,s]=x.useState(!1),[r,a]=x.useState("claude-code"),o=HWe(e,t),l=r==="claude-code"?o.claudeCode:r==="cursor"?o.cursor:o.windsurf;return i.jsxs(Bl,{open:n,onOpenChange:s,children:[i.jsxs($l,{className:"flex w-full items-center justify-between text-sm font-medium",children:[i.jsx("span",{children:"Setup Instructions"}),i.jsx(Ps,{className:X("text-muted-foreground size-3.5 transition-transform duration-150",!n&&"-rotate-90")})]}),i.jsx(Hl,{children:i.jsxs("div",{className:"mt-3 space-y-3",children:[i.jsx("div",{className:"bg-muted flex gap-0.5 rounded-md p-0.5",children:["claude-code","cursor","windsurf"].map(c=>i.jsx("button",{onClick:()=>a(c),className:X("flex-1 rounded-sm px-3 py-1.5 text-xs font-medium transition-colors",r===c?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:c==="claude-code"?"Claude Code":c==="cursor"?"Cursor":"Windsurf"},c))}),i.jsxs("div",{className:"relative",children:[i.jsx("pre",{className:"bg-muted overflow-x-auto rounded-md p-3 text-xs leading-relaxed",children:l}),i.jsx("div",{className:"absolute top-2 right-2",children:i.jsx(hw,{value:l})})]}),r==="claude-code"&&i.jsxs("div",{className:"relative",children:[i.jsx("p",{className:"text-muted-foreground mb-1 text-xs",children:"Or add via CLI:"}),i.jsx("pre",{className:"bg-muted overflow-x-auto rounded-md p-3 text-xs leading-relaxed",children:o.claudeCodeCli}),i.jsx("div",{className:"absolute right-2 bottom-2",children:i.jsx(hw,{value:o.claudeCodeCli})})]})]})})]})}function VWe({mcp:e}){const t=Fe(),n=Ct(),[s,r]=x.useState(!1),[a,o]=x.useState(null),[l,c]=x.useState(null),u=x.useCallback(()=>n.invalidateQueries({queryKey:["config"]}),[n]),f=x.useCallback(async k=>{await t.updateConfig({mcp:{enabled:k,rateLimit:e.rateLimit}}),await u()},[t,e.rateLimit,u]),h=x.useCallback(async()=>{try{c(null);const{apiKey:k}=await t.generateMcpApiKey();o(k),await u()}catch{c("Failed to generate API key.")}},[t,u]),m=x.useCallback(async()=>{try{c(null),await t.deleteMcpApiKey();const{apiKey:k}=await t.generateMcpApiKey();o(k),await u()}catch{c("Failed to rotate API key. The previous key may have been removed."),await u()}},[t,u]),g=x.useCallback(async()=>{try{c(null),await t.deleteMcpApiKey(),o(null),await u()}catch{c("Failed to remove API key.")}},[t,u]),b=x.useCallback(async k=>{await t.updateConfig({mcp:{enabled:e.enabled,rateLimit:{...e.rateLimit,...k}}}),await u()},[t,e.enabled,e.rateLimit,u]),v=e.enabled?e.authConfigured?i.jsx(Ot,{variant:"outline",className:"border-green-500/50 text-xs text-green-600",children:"Enabled"}):i.jsx(Ot,{variant:"outline",className:"border-amber-500/50 text-xs text-amber-600",children:"No auth"}):i.jsx(Ot,{variant:"secondary",className:"text-xs",children:"Disabled"});return i.jsx(Sa,{children:i.jsxs(Bl,{open:s,onOpenChange:r,children:[i.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[i.jsxs("div",{className:"min-w-0",children:[i.jsx("p",{className:"text-sm font-medium",children:"External MCP Server"}),i.jsx("p",{className:"text-muted-foreground text-xs",children:"Add the DorkOS MCP to agents outside of DorkOS"})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[v,i.jsx(Ks,{checked:e.enabled,onCheckedChange:f,"aria-label":"Toggle external MCP access"}),i.jsx($l,{asChild:!0,children:i.jsx("button",{className:"text-muted-foreground hover:text-foreground rounded-sm p-0.5 transition-colors duration-150","aria-label":`${s?"Collapse":"Expand"} external MCP server settings`,children:i.jsx(Ps,{className:X("size-3.5 transition-transform duration-150",!s&&"-rotate-90")})})})]})]}),i.jsx(Hl,{children:i.jsxs(Wr,{className:"border-t",children:[i.jsx(zWe,{}),i.jsx(BWe,{endpoint:e.endpoint}),i.jsx(FWe,{authConfigured:e.authConfigured,authSource:e.authSource,generatedKey:a,keyError:l,onGenerate:h,onRotate:m,onRemove:g}),i.jsx($We,{rateLimit:e.rateLimit,onUpdate:b}),i.jsx(UWe,{endpoint:e.endpoint,apiKey:a})]})})]})})}function qWe({onClick:e}){return i.jsx("button",{onClick:e,className:"text-muted-foreground hover:text-foreground text-xs transition-colors duration-150",children:"Reset to defaults"})}function GWe(){var k,w,C,E;const e=ed(),t=td(),{config:n,updateConfig:s}=OWe(),r=Fe(),a=Ct(),{section:o}=qm();bNe(o);const{data:l}=mt({queryKey:["config"],queryFn:()=>r.getConfig(),staleTime:3e4}),{data:c}=ji(),u=l==null?void 0:l.scheduler,f=x.useMemo(()=>{const T=(c==null?void 0:c.agents)??[],_={tasks:0,relay:0,mesh:0,adapter:0};for(const j of T){const R=j.enabledToolGroups;R&&(R.tasks!==void 0&&_.tasks++,R.relay!==void 0&&_.relay++,R.mesh!==void 0&&_.mesh++,R.adapter!==void 0&&_.adapter++)}return _},[c]),h={tasks:t,relay:e,mesh:!0,adapter:e},m={tasks:(k=l==null?void 0:l.tasks)==null?void 0:k.initError,relay:(w=l==null?void 0:l.relay)==null?void 0:w.initError,mesh:(C=l==null?void 0:l.mesh)==null?void 0:C.initError,adapter:(E=l==null?void 0:l.relay)==null?void 0:E.initError},g=x.useCallback((T,_)=>{s({[f7[T]]:_})},[s]),b=x.useCallback(async T=>{const _=u??{maxConcurrentRuns:1,timezone:null,retentionCount:100};await r.updateConfig({scheduler:{..._,...T}}),await a.invalidateQueries({queryKey:["config"]})},[r,a,u]),v=x.useCallback(async()=>{await r.updateConfig({agentContext:{relayTools:!0,meshTools:!0,adapterTools:!0,tasksTools:!0}}),a.invalidateQueries({queryKey:["config"]})},[r,a]);return i.jsxs("div",{className:"space-y-4",children:[i.jsx(Jm,{actions:i.jsx(qWe,{onClick:v}),children:"Tools"}),i.jsx("p",{className:"text-muted-foreground text-sm",children:"Control which MCP tool groups are available to agents. These are global defaults — individual agents can override them in their Tools tab."}),i.jsx(Sa,{children:i.jsxs(Wr,{children:[i.jsx(os,{label:"Core Tools",description:"Server info, agent identity, UI control",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(xae,{tools:tx.core}),i.jsx("span",{className:"text-muted-foreground text-xs",children:"Always enabled"})]})}),IWe.map(T=>i.jsx(PWe,{group:T,enabled:n[f7[T.key]],available:h[T.key],initError:m[T.key],overrideCount:f[T.key],onToggle:g,expandContent:T.key==="tasks"&&u?i.jsx(LWe,{scheduler:u,onUpdate:b}):void 0},T.key))]})}),(l==null?void 0:l.mcp)&&i.jsx("div",{"data-section":"external-mcp",children:i.jsx(VWe,{mcp:l.mcp})})]})}function KWe(e){const t=MKe[e.status.state]??"bg-muted-foreground";return X("size-2 shrink-0 rounded-full",t)}function WWe({instance:e,manifest:t,bindingCount:n,onToggle:s,onConfigure:r}){const a=e.label||e.status.displayName||e.id,o=KWe(e),{inbound:l,outbound:c}=e.status.messageCount,u=l+c;return i.jsxs("div",{className:"flex items-center gap-3 py-2",children:[i.jsx("div",{className:o,"aria-hidden":!0}),i.jsx(hO,{iconId:t.iconId,adapterType:t.type,size:16,className:"text-muted-foreground shrink-0"}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("span",{className:"truncate text-sm font-medium",children:a}),i.jsxs("p",{className:"text-muted-foreground/60 text-xs",children:[n!==void 0&&n>0?`${n} agent${n!==1?"s":""}`:"No agents",u>0&&` · ${u} messages`]})]}),i.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[i.jsx(Ks,{checked:e.enabled,onCheckedChange:s,"aria-label":`${a} enabled`}),i.jsx(ve,{variant:"ghost",size:"sm",onClick:r,className:"size-7 p-0","aria-label":`Configure ${a}`,children:i.jsx(Qi,{className:"size-3.5"})})]})]})}function YWe(){const e=ed(),{data:t=[],isLoading:n}=VUe(e),{mutate:s}=W5(),{data:r=[]}=pb(),[a,o]=x.useState({open:!1}),l=x.useMemo(()=>{const g=new Map;for(const b of r)g.set(b.adapterId,(g.get(b.adapterId)??0)+1);return g},[r]);if(!e)return i.jsxs("div",{className:"flex flex-col items-center gap-3 rounded-xl border border-dashed py-8",children:[i.jsx(KS,{className:"text-muted-foreground/40 size-8"}),i.jsxs("div",{className:"text-center",children:[i.jsx("p",{className:"text-muted-foreground text-sm",children:"Relay is disabled"}),i.jsx("p",{className:"text-muted-foreground/60 text-xs",children:"Enable the Relay message bus to manage channels here"})]})]});if(n)return i.jsx("div",{className:"space-y-2",children:[1,2,3].map(g=>i.jsx(on,{className:"h-10 w-full rounded-md"},g))});const c=t.flatMap(g=>g.instances.map(b=>({instance:b,manifest:g.manifest}))),u=t.filter(g=>!g.manifest.deprecated&&(g.instances.length===0||g.manifest.multiInstance)),f=g=>{o({open:!0,manifest:g})},h=(g,b)=>{o({open:!0,manifest:g,instanceId:b})},m=a.instanceId?t.flatMap(g=>g.instances).find(g=>g.id===a.instanceId):void 0;return i.jsxs(i.Fragment,{children:[c.length>0?i.jsx(Sa,{children:i.jsx(Wr,{children:c.map(({instance:g,manifest:b})=>i.jsx(WWe,{instance:g,manifest:b,bindingCount:l.get(g.id)??0,onToggle:v=>s({id:g.id,enabled:v}),onConfigure:()=>h(b,g.id)},g.id))})}):i.jsxs("div",{className:"flex flex-col items-center gap-3 rounded-xl border border-dashed py-8",children:[i.jsx(KS,{className:"text-muted-foreground/40 size-8"}),i.jsxs("div",{className:"text-center",children:[i.jsx("p",{className:"text-muted-foreground text-sm",children:"No channels configured"}),i.jsx("p",{className:"text-muted-foreground/60 text-xs",children:"Add a channel below to connect agents to external platforms"})]})]}),u.length>0&&i.jsxs("section",{children:[i.jsx("h3",{className:"text-muted-foreground mb-2 text-xs font-semibold tracking-wide uppercase",children:"Available Channels"}),i.jsx("div",{className:"grid gap-2",style:{gridTemplateColumns:"repeat(auto-fill, minmax(240px, 1fr))"},children:u.map(g=>i.jsx(lae,{manifest:g.manifest,onAdd:()=>f(g.manifest)},g.manifest.type))})]}),a.manifest&&i.jsx(cae,{open:a.open,onOpenChange:g=>{g||o({open:!1})},manifest:a.manifest,existingInstance:m,existingAdapterIds:t.flatMap(g=>g.instances.map(b=>b.id))})]})}const ZWe=[0,0,.2,1],XWe={initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0}},QWe={duration:.2,ease:ZWe};function up({name:e,icon:t,description:n,status:s,enabled:r,onToggle:a,children:o}){const[l,c]=x.useState(!1),u=s==="coming-soon",f=!!o&&!u;return i.jsxs("div",{className:X("rounded-lg border transition-colors",u&&"border-dashed opacity-60"),children:[i.jsxs("button",{type:"button",className:"flex w-full items-center gap-3 px-4 py-3 text-left",onClick:()=>f&&c(h=>!h),disabled:!f,children:[i.jsx(t,{className:"text-muted-foreground size-5 shrink-0"}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-sm font-medium",children:e}),s==="active"&&i.jsx(Ot,{variant:"default",className:"text-xs",children:"Active"}),u&&i.jsx(Ot,{variant:"secondary",className:"text-xs",children:"Coming Soon"})]}),i.jsx("p",{className:"text-muted-foreground mt-0.5 text-xs",children:n})]}),!u&&a&&i.jsx("div",{onClick:h=>h.stopPropagation(),children:i.jsx(Ks,{checked:r,onCheckedChange:a})}),f&&i.jsx(Ps,{className:X("text-muted-foreground size-4 shrink-0 transition-transform duration-200",l&&"rotate-180")})]}),i.jsx(He,{initial:!1,children:l&&f&&i.jsx(oe.div,{variants:XWe,initial:"initial",animate:"animate",exit:"exit",transition:QWe,className:"overflow-hidden",children:i.jsx("div",{className:"space-y-3 border-t px-4 py-3",children:o})})})]})}function JWe(){var j;const e=Fe(),t=Ct(),n=ed(),{data:s=[]}=ug(n),{mutate:r}=W5(),{mutate:a}=ore(),[o,l]=x.useState(null),[c,u]=x.useState(null),{data:f}=mt({queryKey:["mesh","agents"],queryFn:()=>e.listMeshAgents(),staleTime:3e4}),{data:h}=mt({queryKey:["config"],queryFn:()=>e.getConfig(),staleTime:3e4}),m=x.useMemo(()=>s.find(R=>R.manifest.category==="internal"&&R.manifest.type==="claude-code"),[s]),g=m==null?void 0:m.instances[0],b=g==null?void 0:g.config,v=o??String((b==null?void 0:b.maxConcurrent)??3),k=c??String((b==null?void 0:b.defaultTimeoutMs)??3e5),w=(f==null?void 0:f.agents)??[],C=((j=h==null?void 0:h.agents)==null?void 0:j.defaultAgent)??"dorkbot";async function E(R){await e.setDefaultAgent(R),await t.invalidateQueries({queryKey:["config"]})}function T(R){g&&r({id:g.id,enabled:R})}function _(R,D){const I=Number(D);g&&!Number.isNaN(I)&&I>0&&a({id:g.id,config:{[R]:I}}),R==="maxConcurrent"&&l(null),R==="defaultTimeoutMs"&&u(null)}return i.jsxs(i.Fragment,{children:[w.length>0&&i.jsx(Sa,{children:i.jsx(Wr,{children:i.jsx(os,{label:"Default agent",description:"The primary agent used for new sessions and post-onboarding",children:i.jsxs(Bn,{value:C,onValueChange:E,children:[i.jsx(Dn,{className:"w-44","data-testid":"default-agent-select",children:i.jsx($n,{})}),i.jsx(On,{children:w.map(R=>i.jsx(yt,{value:R.name,children:tn(R)},R.id))})]})})})}),i.jsxs("div",{className:"space-y-2",children:[i.jsx("h3",{className:"text-sm font-semibold",children:"Runtimes"}),i.jsx("p",{className:"text-muted-foreground text-xs",children:"Configure which runtimes are available for agent sessions."}),i.jsxs(up,{name:"Claude Code",icon:oae,description:"Anthropic's agentic coding runtime — powers all DorkOS sessions",status:"active",enabled:(g==null?void 0:g.enabled)??!0,onToggle:g?T:void 0,children:[i.jsx(os,{label:"Claude CLI",description:(h==null?void 0:h.claudeCliPath)??"Not found — install Claude Code CLI to enable agent sessions",children:(h==null?void 0:h.claudeCliPath)&&i.jsx("span",{className:"text-muted-foreground max-w-48 min-w-0 truncate font-mono text-xs",dir:"rtl",title:h.claudeCliPath,children:h.claudeCliPath})}),g&&i.jsxs(i.Fragment,{children:[i.jsx(os,{label:"Max concurrent sessions",description:"Maximum relay-delivered sessions running simultaneously",children:i.jsx(_n,{type:"number",min:1,max:20,value:v,onChange:R=>l(R.target.value),onBlur:R=>_("maxConcurrent",R.target.value),className:"w-24"})}),i.jsx(os,{label:"Default timeout",description:"Timeout budget per relay session in milliseconds",children:i.jsx(_n,{type:"number",min:1e4,max:36e5,value:k,onChange:R=>u(R.target.value),onBlur:R=>_("defaultTimeoutMs",R.target.value),className:"w-32"})})]})]}),i.jsx(up,{name:"Codex",icon:ZR,description:"OpenAI's agentic coding runtime powered by o-series reasoning models",status:"coming-soon",enabled:!1}),i.jsx(up,{name:"Agent Protocol",icon:VTe,description:"Connect any ACP-compatible coding agent — OpenCode, Cline, Goose, Copilot CLI",status:"coming-soon",enabled:!1}),i.jsx(up,{name:"Pi Agent",icon:lEe,description:"Run coding agents locally with Ollama, LM Studio, or any model provider",status:"coming-soon",enabled:!1}),i.jsx(up,{name:"Gemini CLI",icon:XR,description:"Google's agentic coding runtime powered by Gemini 2.5 models",status:"coming-soon",enabled:!1}),i.jsx(up,{name:"Aider",icon:tD,description:"Multi-model coding agent supporting 20+ providers including local models",status:"coming-soon",enabled:!1})]})]})}function eYe({open:e,onOpenChange:t,onResetComplete:n}){const[s,r]=x.useState(""),[a,o]=x.useState(!1),l=Fe(),c=s==="reset";async function u(){o(!0);try{await l.resetAllData("reset"),localStorage.clear(),t(!1),n()}catch(h){rt.error(h instanceof Error?h.message:"Failed to reset data")}finally{o(!1)}}function f(h){h||(r(""),o(!1)),t(h)}return i.jsx(th,{open:e,onOpenChange:f,children:i.jsxs(Bu,{children:[i.jsxs(nh,{children:[i.jsx($u,{children:"Reset All Data"}),i.jsx(Hu,{asChild:!0,children:i.jsxs("div",{className:"space-y-3",children:[i.jsx("p",{children:"This will permanently delete all DorkOS data, including:"}),i.jsxs("ul",{className:"list-inside list-disc space-y-1 text-sm",children:[i.jsx("li",{children:"All Tasks schedules and run history"}),i.jsx("li",{children:"All Relay configuration and messages"}),i.jsx("li",{children:"All Mesh agent registry data"}),i.jsx("li",{children:"Your config file and preferences"}),i.jsx("li",{children:"All server logs"})]}),i.jsx("p",{children:"The server will restart automatically. Your UI preferences will also be cleared."}),i.jsx("p",{className:"font-semibold",children:"This action cannot be undone."})]})})]}),i.jsx("div",{className:"py-2",children:i.jsx(_n,{placeholder:'Type "reset" to confirm',value:s,onChange:h=>r(h.target.value),"data-testid":"reset-confirm-input"})}),i.jsxs(sh,{children:[i.jsx(Vu,{children:"Cancel"}),i.jsx(Uu,{disabled:!c||a,onClick:u,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:a?"Resetting...":"Reset All Data"})]})]})})}function tYe({open:e,onOpenChange:t,onRestartComplete:n}){const[s,r]=x.useState(!1),a=Fe();async function o(){r(!0);try{await a.restartServer(),t(!1),n()}catch(l){rt.error(l instanceof Error?l.message:"Failed to restart server")}finally{r(!1)}}return i.jsx(th,{open:e,onOpenChange:t,children:i.jsxs(Bu,{children:[i.jsxs(nh,{children:[i.jsx($u,{children:"Restart Server"}),i.jsx(Hu,{children:"This will restart the DorkOS server. All active sessions will be interrupted."})]}),i.jsxs(sh,{children:[i.jsx(Vu,{children:"Cancel"}),i.jsx(Uu,{disabled:s,onClick:o,children:s?"Restarting...":"Restart Server"})]})]})})}const nYe=["fatal","error","warn","info","debug","trace"];function sYe(){const[e,t]=x.useState(!1),[n,s]=x.useState(!1),r=je(m=>m.enableMessagePolling),a=je(m=>m.setEnableMessagePolling),o=je(m=>m.setRestartOverlayOpen),l=Fe(),c=Ct(),{data:u}=mt({queryKey:["config"],queryFn:()=>l.getConfig(),staleTime:3e4}),f=u==null?void 0:u.logging,h=x.useCallback(async m=>{const g=f??{level:"info",maxLogSizeKb:500,maxLogFiles:14};await l.updateConfig({logging:{...g,...m}}),await c.invalidateQueries({queryKey:["config"]})},[l,c,f]);return i.jsxs("div",{className:"space-y-6",children:[i.jsx("h3",{className:"text-sm font-semibold",children:"Background Updates"}),i.jsx("p",{className:"text-muted-foreground text-xs",children:"Messages stream in live and stay in sync across windows automatically. This optional setting adds an extra polling fallback for sessions running outside DorkOS."}),i.jsx(Sa,{children:i.jsx(Wr,{children:i.jsx(gi,{label:"Background refresh",description:"Poll for updates to sessions running outside DorkOS (e.g. the Claude Code CLI). Enable only if external activity isn't appearing promptly.",checked:r,onCheckedChange:a})})}),f&&i.jsxs(i.Fragment,{children:[i.jsx("h3",{className:"text-sm font-semibold",children:"Logging"}),i.jsx("p",{className:"text-muted-foreground text-xs",children:"Server log verbosity and rotation. Changes take effect immediately for log level; rotation settings apply on next file rotation."}),i.jsx(Sa,{children:i.jsxs(Wr,{children:[i.jsx(os,{label:"Log level",description:"Server log verbosity",children:i.jsxs(Bn,{value:f.level,onValueChange:m=>h({level:m}),children:[i.jsx(Dn,{className:"w-28",children:i.jsx($n,{})}),i.jsx(On,{children:nYe.map(m=>i.jsx(yt,{value:m,children:m},m))})]})}),i.jsx(os,{label:"Max log file size",description:"Size in KB before a log file is rotated",children:i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx(_n,{type:"number",min:100,max:10240,value:f.maxLogSizeKb,onChange:m=>{const g=parseInt(m.target.value,10);g>=100&&g<=10240&&h({maxLogSizeKb:g})},className:"w-24"}),i.jsx("span",{className:"text-muted-foreground text-xs",children:"KB"})]})}),i.jsx(os,{label:"Rotated files kept",description:"Number of old log files to retain (1-30)",children:i.jsx(_n,{type:"number",min:1,max:30,value:f.maxLogFiles,onChange:m=>{const g=parseInt(m.target.value,10);g>=1&&g<=30&&h({maxLogFiles:g})},className:"w-20"})}),(u==null?void 0:u.dorkHome)&&i.jsx(rYe,{dorkHome:u.dorkHome})]})})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Yr,{className:"text-destructive size-4"}),i.jsx("h3",{className:"text-destructive text-sm font-semibold",children:"Danger Zone"})]}),i.jsx(Sa,{className:"border-destructive/50",children:i.jsxs(Wr,{children:[i.jsxs("div",{className:"flex items-center justify-between gap-4",children:[i.jsxs("div",{className:"min-w-0",children:[i.jsx("p",{className:"text-sm font-medium",children:"Reset All Data"}),i.jsx("p",{className:"text-muted-foreground text-xs",children:"Permanently delete all DorkOS data and restart the server."})]}),i.jsx(ve,{variant:"destructive",size:"sm",onClick:()=>t(!0),children:"Reset"})]}),i.jsxs("div",{className:"flex items-center justify-between gap-4",children:[i.jsxs("div",{className:"min-w-0",children:[i.jsx("p",{className:"text-sm font-medium",children:"Restart Server"}),i.jsx("p",{className:"text-muted-foreground text-xs",children:"Restart the DorkOS server process. Active sessions will be interrupted."})]}),i.jsx(ve,{variant:"destructive",size:"sm",onClick:()=>s(!0),children:"Restart"})]})]})}),i.jsx(eYe,{open:e,onOpenChange:t,onResetComplete:()=>o(!0)}),i.jsx(tYe,{open:n,onOpenChange:s,onRestartComplete:()=>o(!0)})]})}function rYe({dorkHome:e}){const[t,n]=x.useState(!1),s=`${e}/logs`;function r(){navigator.clipboard.writeText(s).then(()=>{n(!0),setTimeout(()=>n(!1),Yi.COPY_FEEDBACK_MS)})}return i.jsx(os,{label:"Log location",description:"Directory where server log files are stored",children:i.jsx("button",{type:"button",onClick:r,className:"text-muted-foreground hover:text-foreground flex items-center gap-1.5 transition-colors",children:t?i.jsx("span",{className:"text-xs",children:"Copied"}):i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"max-w-40 truncate font-mono text-xs",dir:"rtl",title:s,children:s}),i.jsx(Gf,{className:"size-3 shrink-0"})]})})})}function aYe({onClick:e}){return Zs()?i.jsxs(oe.button,{onClick:e,whileTap:{scale:.98},transition:{type:"spring",stiffness:400,damping:30},className:X("flex w-full items-center gap-3 px-4 py-3 text-left text-sm transition-colors","hover:bg-muted/50 active:bg-muted min-h-[44px]"),children:[i.jsx(pu,{className:"text-muted-foreground size-(--size-icon-sm) shrink-0"}),i.jsx("span",{className:"flex-1",children:"Remote Access"}),i.jsx(Ws,{className:"text-muted-foreground/40 size-(--size-icon-sm) shrink-0"})]}):i.jsx("button",{onClick:e,className:"text-muted-foreground hover:text-foreground hover:bg-muted/50 relative mx-2 flex w-[calc(100%-1rem)] items-center gap-2 rounded-md px-2.5 py-1.5 text-left text-sm transition-colors duration-150",children:i.jsxs("span",{className:"relative z-10 flex items-center gap-2",children:[i.jsx(pu,{className:"size-(--size-icon-sm) shrink-0"}),"Remote Access"]})})}const iYe=15e3,oYe=3e4,lYe=3e4;function cYe(e,t,n){return!e&&!t?"landing":!e&&t||t?"setup":n==="error"?"error":n==="starting"?"connecting":n==="connected"||n==="stopping"?"connected":"ready"}function uYe({open:e}){const t=Fe(),{data:n}=mt({queryKey:["config"],queryFn:()=>t.getConfig(),staleTime:300*1e3}),s=n==null?void 0:n.tunnel,[r,a]=x.useState("off"),[o,l]=x.useState(null),[c,u]=x.useState(null),[f,h]=x.useState(!1),[m,g]=x.useState(""),[b,v]=x.useState(null),[k,w]=x.useState(!1),[C,E]=x.useState(""),[T,_]=x.useState(null),[j,R]=x.useState(!1),[D,I]=x.useState(""),O=x.useRef(void 0);x.useEffect(()=>{s!=null&&s.connected&&(s!=null&&s.url)?(a("connected"),l(s.url)):r!=="starting"&&r!=="stopping"&&(a("off"),l(null))},[s==null?void 0:s.connected,s==null?void 0:s.url,r]),x.useEffect(()=>{s!=null&&s.domain&&E(s.domain)},[s==null?void 0:s.domain]),x.useEffect(()=>{(s==null?void 0:s.passcodeEnabled)!==void 0&&R(s.passcodeEnabled)},[s==null?void 0:s.passcodeEnabled]),x.useEffect(()=>{s!=null&&s.tokenConfigured&&h(!1)},[s==null?void 0:s.tokenConfigured]),x.useEffect(()=>{const U=O.current,$=(s==null?void 0:s.connected)??!1;O.current=$,U!==void 0&&(U&&!$?rt.error("Remote access disconnected",{id:"tunnel-status",description:"Attempting to reconnect..."}):!U&&$&&(s!=null&&s.url)&&rt.success("Remote access reconnected",{id:"tunnel-status",description:s.url}))},[s==null?void 0:s.connected,s==null?void 0:s.url]),x.useEffect(()=>{if(r!=="starting"&&r!=="stopping")return;const U=setTimeout(()=>{r==="starting"?(a("error"),u("Connection timed out. Please try again.")):r==="stopping"&&(a("off"),l(null))},oYe);return()=>clearTimeout(U)},[r]),x.useEffect(()=>{if(r!=="connected"||!o||!e){_(null);return}const U=async()=>{try{const q=performance.now();await fetch(`${o}/api/health`,{mode:"cors",cache:"no-store"}),_(Math.round(performance.now()-q))}catch{_(null)}};U();const $=setInterval(U,lYe);return()=>clearInterval($)},[r,o,e]);const L=!!(s!=null&&s.tokenConfigured),B=cYe(L,f,r);return{state:r,setState:a,url:o,setUrl:l,error:c,setError:u,showSetup:f,setShowSetup:h,authToken:m,setAuthToken:g,tokenError:b,setTokenError:v,showTokenInput:k,setShowTokenInput:w,domain:C,setDomain:E,latencyMs:T,passcodeEnabled:j,setPasscodeEnabled:R,passcodeInput:D,setPasscodeInput:I,tunnel:s,tokenConfigured:L,viewState:B,isTransitioning:r==="starting"||r==="stopping",isChecked:r==="connected"||r==="starting"||r==="stopping"}}function dYe(){const e=Fe();return mt({queryKey:["tunnel-status"],queryFn:async()=>(await e.getConfig()).tunnel,refetchInterval:3e4,refetchIntervalInBackground:!1})}const fYe="dorkos-tunnel";function k1(){const e=uxe(fYe);e.postMessage({type:"tunnel_changed"}),e.close()}function hYe({machine:e,transport:t,queryClient:n}){const s=x.useCallback(async c=>{if(c){e.setState("starting"),e.setError(null);const u=setTimeout(()=>{e.setState("error"),e.setError("Connection timed out after 15 seconds")},iYe);try{const f=await t.startTunnel();clearTimeout(u),e.setState("connected"),e.setUrl(f.url),n.invalidateQueries({queryKey:["config"]}),k1()}catch(f){clearTimeout(u),e.setState("error"),e.setError(f instanceof Error?f.message:"Failed to start tunnel")}}else{e.setState("stopping"),e.setError(null);try{await t.stopTunnel(),e.setState("off"),e.setUrl(null),n.invalidateQueries({queryKey:["config"]}),k1()}catch(u){e.setState("connected"),e.setError(u instanceof Error?u.message:"Failed to stop tunnel")}}},[e,t,n]),r=x.useCallback(async()=>{e.setTokenError(null);try{await t.updateConfig({tunnel:{authtoken:e.authToken}}),e.setAuthToken(""),e.setShowTokenInput(!1),e.setShowSetup(!1),n.invalidateQueries({queryKey:["config"]})}catch{e.setTokenError("Could not save token. Try again.")}},[e,n,t]),a=x.useCallback(async()=>{try{await t.updateConfig({tunnel:{domain:e.domain.trim()||null}}),n.invalidateQueries({queryKey:["config"]})}catch{}},[e,n,t]),o=x.useCallback(async c=>{if(c)e.setPasscodeEnabled(!0);else try{await t.setTunnelPasscode({enabled:!1}),e.setPasscodeEnabled(!1),e.setPasscodeInput(""),n.invalidateQueries({queryKey:["config"]}),k1()}catch{rt.error("Failed to disable passcode")}},[e,t,n]),l=x.useCallback(async()=>{try{await t.setTunnelPasscode({passcode:e.passcodeInput,enabled:!0}),e.setPasscodeInput(""),n.invalidateQueries({queryKey:["config"]}),k1()}catch{rt.error("Failed to save passcode")}},[e,n,t]);return{handleToggle:s,handleSaveToken:r,handleSaveDomain:a,handlePasscodeToggle:o,handleSavePasscode:l}}function pYe(){return i.jsxs("svg",{viewBox:"0 0 240 120",className:"mx-auto h-24 w-48","aria-hidden":"true",children:[i.jsx("rect",{x:"80",y:"30",width:"80",height:"50",rx:"4",className:"fill-none stroke-current",strokeWidth:"2"}),i.jsx("rect",{x:"70",y:"80",width:"100",height:"6",rx:"2",className:"fill-current opacity-30"}),i.jsx("rect",{x:"90",y:"42",width:"20",height:"2",rx:"1",className:"fill-current opacity-40"}),i.jsx("rect",{x:"90",y:"48",width:"40",height:"2",rx:"1",className:"fill-current opacity-20"}),i.jsx("rect",{x:"90",y:"54",width:"30",height:"2",rx:"1",className:"fill-current opacity-20"}),i.jsx("rect",{x:"195",y:"35",width:"28",height:"45",rx:"4",className:"fill-none stroke-current",strokeWidth:"1.5"}),i.jsx("circle",{cx:"209",cy:"73",r:"2",className:"fill-current opacity-30"}),i.jsx("rect",{x:"10",y:"30",width:"40",height:"55",rx:"4",className:"fill-none stroke-current",strokeWidth:"1.5"}),i.jsx("circle",{cx:"30",cy:"78",r:"2",className:"fill-current opacity-30"}),i.jsx("line",{x1:"160",y1:"55",x2:"195",y2:"55",className:"stroke-current opacity-40",strokeWidth:"1.5",strokeDasharray:"4 3"}),i.jsx("line",{x1:"80",y1:"55",x2:"50",y2:"55",className:"stroke-current opacity-40",strokeWidth:"1.5",strokeDasharray:"4 3"})]})}function mYe(){return i.jsxs("div",{className:"space-y-3",children:[i.jsx(pYe,{}),i.jsx("p",{className:"text-foreground text-center text-sm font-medium",children:"Access DorkOS from any device"})]})}function gYe({onGetStarted:e}){return i.jsxs("div",{"data-testid":"tunnel-landing",className:"space-y-6 py-2",children:[i.jsx(mYe,{}),i.jsxs("div",{className:"text-center",children:[i.jsx("p",{className:"text-foreground text-sm font-medium",children:"Access DorkOS from any device"}),i.jsx("p",{className:"text-muted-foreground mx-auto mt-1 max-w-[280px] text-xs leading-relaxed",children:"Create a secure tunnel to access your sessions from your phone, tablet, or any browser."})]}),i.jsx(ve,{onClick:e,className:"w-full transition-transform duration-100 hover:scale-[1.01] active:scale-[0.98]",children:"Get started"}),i.jsx("p",{className:"text-muted-foreground/60 text-center text-xs",children:"Requires a free ngrok account"})]})}const xYe={initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0}},yYe={duration:.2,ease:[0,0,.2,1]};function bYe({authToken:e,tokenError:t,onAuthTokenChange:n,onSaveToken:s}){return i.jsxs("div",{"data-testid":"tunnel-setup",className:"space-y-4",children:[i.jsxs(Wa,{"data-invalid":t?!0:void 0,children:[i.jsx(Ya,{htmlFor:"tunnel-auth-token",className:"text-xs font-medium",children:"ngrok auth token"}),i.jsx(_n,{id:"tunnel-auth-token",type:"password",placeholder:"Paste your ngrok auth token",value:e,onChange:r=>n(r.target.value),onKeyDown:r=>{r.key==="Enter"&&e.trim()&&s()},className:"text-sm"}),i.jsx(He,{children:t&&i.jsx(oe.div,{variants:xYe,initial:"initial",animate:"animate",exit:"exit",transition:yYe,className:"overflow-hidden",children:i.jsx(Oo,{children:t})},"token-error")})]}),i.jsx(ve,{size:"sm",className:"w-full",disabled:!e.trim(),onClick:()=>void s(),children:"Save token"}),i.jsxs("p",{className:"text-muted-foreground text-xs",children:["Don't have a token?"," ",i.jsxs("a",{href:"https://dashboard.ngrok.com/signup",target:"_blank",rel:"noopener noreferrer",className:"text-foreground group inline-flex items-center gap-0.5 underline underline-offset-2",children:["Sign up for ngrok",i.jsx(V1,{className:"size-3 transition-transform duration-100 group-hover:-translate-x-0.5"})]})," ","— free tier is sufficient."]})]})}const vYe={initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0}},SYe={duration:.2,ease:[0,0,.2,1]},wYe={collapsed:{rotate:0},expanded:{rotate:90}},kYe={duration:.15,ease:"easeInOut"};function h7({active:e,label:t}){return i.jsxs("span",{className:X("flex items-center gap-1 text-xs",e?"text-muted-foreground":"text-muted-foreground/50"),children:[e?i.jsx(Zt,{className:"size-3 text-green-500"}):i.jsx("span",{className:"text-muted-foreground/40",children:"○"}),t]})}function CYe({authToken:e,tokenError:t,showTokenInput:n,onAuthTokenChange:s,onSaveToken:r,onShowTokenInput:a,domain:o,onDomainChange:l,onDomainSave:c}){const[u,f]=x.useState(!1),h=m=>{m.key==="Enter"&&c()};return i.jsxs("div",{"data-testid":"tunnel-settings",children:[i.jsxs("button",{type:"button",onClick:()=>f(m=>!m),className:"hover:text-foreground text-muted-foreground flex w-full items-center gap-1.5 py-1 text-xs transition-colors",children:[i.jsx(oe.span,{variants:wYe,animate:u?"expanded":"collapsed",transition:kYe,className:"inline-flex origin-center","aria-hidden":!0,children:i.jsx(Ws,{className:"size-3.5"})}),i.jsx("span",{className:"font-medium",children:"Settings"})]}),!u&&i.jsxs("div",{className:"mt-1.5 flex gap-3 pl-5",children:[i.jsx(h7,{active:!0,label:"Token"}),i.jsx(h7,{active:!!o.trim(),label:o.trim()||"No domain"})]}),i.jsx(He,{initial:!1,children:u&&i.jsx(oe.div,{variants:vYe,initial:"initial",animate:"animate",exit:"exit",transition:SYe,className:"overflow-hidden",children:i.jsxs("div",{className:"space-y-4 pt-3",children:[i.jsx("div",{className:"space-y-2",children:n?i.jsxs(Wa,{children:[i.jsx(Ya,{className:"text-sm",children:"Auth token"}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(_n,{type:"password",value:e,onChange:m=>s(m.target.value),placeholder:"Paste ngrok auth token",className:"flex-1","aria-label":"Auth token"}),i.jsx(ve,{type:"button",size:"sm",onClick:r,disabled:!e.trim(),children:"Save"})]}),t&&i.jsx(Oo,{children:t})]}):i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"space-y-0.5",children:[i.jsx("p",{className:"text-sm font-medium",children:"Auth token"}),i.jsx("p",{className:"text-muted-foreground text-xs",children:"Token saved"})]}),i.jsx(ve,{type:"button",variant:"outline",size:"sm",onClick:a,children:"Change"})]})}),i.jsxs(Wa,{children:[i.jsx(Ya,{className:"text-sm",children:"Custom domain"}),i.jsx(_n,{type:"text",value:o,onChange:m=>l(m.target.value),onBlur:c,onKeyDown:h,placeholder:"your-domain.ngrok.app","aria-label":"Custom domain"}),i.jsx(Ei,{className:"text-xs",children:"Leave blank to use a randomly assigned ngrok URL."})]})]})},"settings-panel")})]})}const dS=[0,500,1200],p7=[{label:"Initialising ngrok agent",thresholdMs:dS[0]},{label:"Opening secure tunnel",thresholdMs:dS[1]},{label:"Registering public URL",thresholdMs:dS[2]}],EYe={hidden:{},show:{transition:{staggerChildren:.15}}},TYe={hidden:{opacity:0,y:8},show:{opacity:1,y:0,transition:{type:"spring",stiffness:320,damping:28}}},_Ye={initial:{scale:.5,opacity:0},animate:{scale:1,opacity:1}},NYe={type:"spring",stiffness:400,damping:30};function jYe(){const[e,t]=x.useState(0);return x.useEffect(()=>{const n=Date.now(),s=dS.map(r=>setTimeout(()=>{t(Date.now()-n)},r));return()=>{s.forEach(clearTimeout)}},[]),i.jsx(oe.div,{className:"space-y-3 py-2","data-testid":"tunnel-connecting",variants:EYe,initial:"hidden",animate:"show",children:p7.map((n,s)=>{var c;const r=e>=n.thresholdMs,a=((c=p7[s+1])==null?void 0:c.thresholdMs)??1/0,o=e>=a,l=r&&!o;return i.jsxs(oe.div,{variants:TYe,className:X("flex items-center gap-3 text-sm transition-opacity duration-300",r?"opacity-100":"opacity-0"),children:[i.jsx("span",{className:"flex size-4 shrink-0 items-center justify-center",children:i.jsx(He,{mode:"wait",children:o?i.jsx(oe.span,{variants:_Ye,initial:"initial",animate:"animate",exit:{scale:.5,opacity:0},transition:NYe,className:"inline-flex",children:i.jsx(Zt,{className:"text-muted-foreground size-4"})},"check"):l?i.jsx(oe.span,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:"inline-flex",children:i.jsx(Xn,{className:"text-muted-foreground size-4 animate-spin"})},"spinner"):null})}),i.jsx("span",{className:X("transition-colors duration-200",o?"text-muted-foreground":"text-foreground"),children:n.label})]},n.label)})})}var dp={},RN={exports:{}},MN,m7;function AYe(){if(m7)return MN;m7=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return MN=e,MN}var DN,g7;function RYe(){if(g7)return DN;g7=1;var e=AYe();function t(){}function n(){}return n.resetWarningCache=t,DN=function(){function s(o,l,c,u,f,h){if(h!==e){var m=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw m.name="Invariant Violation",m}}s.isRequired=s;function r(){return s}var a={array:s,bigint:s,bool:s,func:s,number:s,object:s,string:s,symbol:s,any:s,arrayOf:r,element:s,elementType:s,instanceOf:r,node:s,objectOf:r,oneOf:r,oneOfType:r,shape:r,exact:r,checkPropTypes:n,resetWarningCache:t};return a.PropTypes=a,a},DN}var x7;function pO(){return x7||(x7=1,RN.exports=RYe()()),RN.exports}var ON,y7;function yae(){return y7||(y7=1,ON={L:1,M:0,Q:3,H:2}),ON}var IN,b7;function bae(){return b7||(b7=1,IN={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8}),IN}var PN,v7;function MYe(){if(v7)return PN;v7=1;var e=bae();function t(n){this.mode=e.MODE_8BIT_BYTE,this.data=n}return t.prototype={getLength:function(n){return this.data.length},write:function(n){for(var s=0;s<this.data.length;s++)n.put(this.data.charCodeAt(s),8)}},PN=t,PN}var LN,S7;function DYe(){if(S7)return LN;S7=1;var e=yae();function t(n,s){this.totalCount=n,this.dataCount=s}return t.RS_BLOCK_TABLE=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],t.getRSBlocks=function(n,s){var r=t.getRsBlockTable(n,s);if(r==null)throw new Error("bad rs block @ typeNumber:"+n+"/errorCorrectLevel:"+s);for(var a=r.length/3,o=new Array,l=0;l<a;l++)for(var c=r[l*3+0],u=r[l*3+1],f=r[l*3+2],h=0;h<c;h++)o.push(new t(u,f));return o},t.getRsBlockTable=function(n,s){switch(s){case e.L:return t.RS_BLOCK_TABLE[(n-1)*4+0];case e.M:return t.RS_BLOCK_TABLE[(n-1)*4+1];case e.Q:return t.RS_BLOCK_TABLE[(n-1)*4+2];case e.H:return t.RS_BLOCK_TABLE[(n-1)*4+3];default:return}},LN=t,LN}var FN,w7;function OYe(){if(w7)return FN;w7=1;function e(){this.buffer=new Array,this.length=0}return e.prototype={get:function(t){var n=Math.floor(t/8);return(this.buffer[n]>>>7-t%8&1)==1},put:function(t,n){for(var s=0;s<n;s++)this.putBit((t>>>n-s-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(t){var n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),t&&(this.buffer[n]|=128>>>this.length%8),this.length++}},FN=e,FN}var zN,k7;function vae(){if(k7)return zN;k7=1;for(var e={glog:function(n){if(n<1)throw new Error("glog("+n+")");return e.LOG_TABLE[n]},gexp:function(n){for(;n<0;)n+=255;for(;n>=256;)n-=255;return e.EXP_TABLE[n]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)},t=0;t<8;t++)e.EXP_TABLE[t]=1<<t;for(var t=8;t<256;t++)e.EXP_TABLE[t]=e.EXP_TABLE[t-4]^e.EXP_TABLE[t-5]^e.EXP_TABLE[t-6]^e.EXP_TABLE[t-8];for(var t=0;t<255;t++)e.LOG_TABLE[e.EXP_TABLE[t]]=t;return zN=e,zN}var BN,C7;function Sae(){if(C7)return BN;C7=1;var e=vae();function t(n,s){if(n.length==null)throw new Error(n.length+"/"+s);for(var r=0;r<n.length&&n[r]==0;)r++;this.num=new Array(n.length-r+s);for(var a=0;a<n.length-r;a++)this.num[a]=n[a+r]}return t.prototype={get:function(n){return this.num[n]},getLength:function(){return this.num.length},multiply:function(n){for(var s=new Array(this.getLength()+n.getLength()-1),r=0;r<this.getLength();r++)for(var a=0;a<n.getLength();a++)s[r+a]^=e.gexp(e.glog(this.get(r))+e.glog(n.get(a)));return new t(s,0)},mod:function(n){if(this.getLength()-n.getLength()<0)return this;for(var s=e.glog(this.get(0))-e.glog(n.get(0)),r=new Array(this.getLength()),a=0;a<this.getLength();a++)r[a]=this.get(a);for(var a=0;a<n.getLength();a++)r[a]^=e.gexp(e.glog(n.get(a))+s);return new t(r,0).mod(n)}},BN=t,BN}var $N,E7;function IYe(){if(E7)return $N;E7=1;var e=bae(),t=Sae(),n=vae(),s={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},r={PATTERN_POSITION_TABLE:[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],G15:1335,G18:7973,G15_MASK:21522,getBCHTypeInfo:function(a){for(var o=a<<10;r.getBCHDigit(o)-r.getBCHDigit(r.G15)>=0;)o^=r.G15<<r.getBCHDigit(o)-r.getBCHDigit(r.G15);return(a<<10|o)^r.G15_MASK},getBCHTypeNumber:function(a){for(var o=a<<12;r.getBCHDigit(o)-r.getBCHDigit(r.G18)>=0;)o^=r.G18<<r.getBCHDigit(o)-r.getBCHDigit(r.G18);return a<<12|o},getBCHDigit:function(a){for(var o=0;a!=0;)o++,a>>>=1;return o},getPatternPosition:function(a){return r.PATTERN_POSITION_TABLE[a-1]},getMask:function(a,o,l){switch(a){case s.PATTERN000:return(o+l)%2==0;case s.PATTERN001:return o%2==0;case s.PATTERN010:return l%3==0;case s.PATTERN011:return(o+l)%3==0;case s.PATTERN100:return(Math.floor(o/2)+Math.floor(l/3))%2==0;case s.PATTERN101:return o*l%2+o*l%3==0;case s.PATTERN110:return(o*l%2+o*l%3)%2==0;case s.PATTERN111:return(o*l%3+(o+l)%2)%2==0;default:throw new Error("bad maskPattern:"+a)}},getErrorCorrectPolynomial:function(a){for(var o=new t([1],0),l=0;l<a;l++)o=o.multiply(new t([1,n.gexp(l)],0));return o},getLengthInBits:function(a,o){if(1<=o&&o<10)switch(a){case e.MODE_NUMBER:return 10;case e.MODE_ALPHA_NUM:return 9;case e.MODE_8BIT_BYTE:return 8;case e.MODE_KANJI:return 8;default:throw new Error("mode:"+a)}else if(o<27)switch(a){case e.MODE_NUMBER:return 12;case e.MODE_ALPHA_NUM:return 11;case e.MODE_8BIT_BYTE:return 16;case e.MODE_KANJI:return 10;default:throw new Error("mode:"+a)}else if(o<41)switch(a){case e.MODE_NUMBER:return 14;case e.MODE_ALPHA_NUM:return 13;case e.MODE_8BIT_BYTE:return 16;case e.MODE_KANJI:return 12;default:throw new Error("mode:"+a)}else throw new Error("type:"+o)},getLostPoint:function(a){for(var o=a.getModuleCount(),l=0,c=0;c<o;c++)for(var u=0;u<o;u++){for(var f=0,h=a.isDark(c,u),m=-1;m<=1;m++)if(!(c+m<0||o<=c+m))for(var g=-1;g<=1;g++)u+g<0||o<=u+g||m==0&&g==0||h==a.isDark(c+m,u+g)&&f++;f>5&&(l+=3+f-5)}for(var c=0;c<o-1;c++)for(var u=0;u<o-1;u++){var b=0;a.isDark(c,u)&&b++,a.isDark(c+1,u)&&b++,a.isDark(c,u+1)&&b++,a.isDark(c+1,u+1)&&b++,(b==0||b==4)&&(l+=3)}for(var c=0;c<o;c++)for(var u=0;u<o-6;u++)a.isDark(c,u)&&!a.isDark(c,u+1)&&a.isDark(c,u+2)&&a.isDark(c,u+3)&&a.isDark(c,u+4)&&!a.isDark(c,u+5)&&a.isDark(c,u+6)&&(l+=40);for(var u=0;u<o;u++)for(var c=0;c<o-6;c++)a.isDark(c,u)&&!a.isDark(c+1,u)&&a.isDark(c+2,u)&&a.isDark(c+3,u)&&a.isDark(c+4,u)&&!a.isDark(c+5,u)&&a.isDark(c+6,u)&&(l+=40);for(var v=0,u=0;u<o;u++)for(var c=0;c<o;c++)a.isDark(c,u)&&v++;var k=Math.abs(100*v/o/o-50)/5;return l+=k*10,l}};return $N=r,$N}var HN,T7;function PYe(){if(T7)return HN;T7=1;var e=MYe(),t=DYe(),n=OYe(),s=IYe(),r=Sae();function a(l,c){this.typeNumber=l,this.errorCorrectLevel=c,this.modules=null,this.moduleCount=0,this.dataCache=null,this.dataList=[]}var o=a.prototype;return o.addData=function(l){var c=new e(l);this.dataList.push(c),this.dataCache=null},o.isDark=function(l,c){if(l<0||this.moduleCount<=l||c<0||this.moduleCount<=c)throw new Error(l+","+c);return this.modules[l][c]},o.getModuleCount=function(){return this.moduleCount},o.make=function(){if(this.typeNumber<1){var l=1;for(l=1;l<40;l++){for(var c=t.getRSBlocks(l,this.errorCorrectLevel),u=new n,f=0,h=0;h<c.length;h++)f+=c[h].dataCount;for(var h=0;h<this.dataList.length;h++){var m=this.dataList[h];u.put(m.mode,4),u.put(m.getLength(),s.getLengthInBits(m.mode,l)),m.write(u)}if(u.getLengthInBits()<=f*8)break}this.typeNumber=l}this.makeImpl(!1,this.getBestMaskPattern())},o.makeImpl=function(l,c){this.moduleCount=this.typeNumber*4+17,this.modules=new Array(this.moduleCount);for(var u=0;u<this.moduleCount;u++){this.modules[u]=new Array(this.moduleCount);for(var f=0;f<this.moduleCount;f++)this.modules[u][f]=null}this.setupPositionProbePattern(0,0),this.setupPositionProbePattern(this.moduleCount-7,0),this.setupPositionProbePattern(0,this.moduleCount-7),this.setupPositionAdjustPattern(),this.setupTimingPattern(),this.setupTypeInfo(l,c),this.typeNumber>=7&&this.setupTypeNumber(l),this.dataCache==null&&(this.dataCache=a.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,c)},o.setupPositionProbePattern=function(l,c){for(var u=-1;u<=7;u++)if(!(l+u<=-1||this.moduleCount<=l+u))for(var f=-1;f<=7;f++)c+f<=-1||this.moduleCount<=c+f||(0<=u&&u<=6&&(f==0||f==6)||0<=f&&f<=6&&(u==0||u==6)||2<=u&&u<=4&&2<=f&&f<=4?this.modules[l+u][c+f]=!0:this.modules[l+u][c+f]=!1)},o.getBestMaskPattern=function(){for(var l=0,c=0,u=0;u<8;u++){this.makeImpl(!0,u);var f=s.getLostPoint(this);(u==0||l>f)&&(l=f,c=u)}return c},o.createMovieClip=function(l,c,u){var f=l.createEmptyMovieClip(c,u),h=1;this.make();for(var m=0;m<this.modules.length;m++)for(var g=m*h,b=0;b<this.modules[m].length;b++){var v=b*h,k=this.modules[m][b];k&&(f.beginFill(0,100),f.moveTo(v,g),f.lineTo(v+h,g),f.lineTo(v+h,g+h),f.lineTo(v,g+h),f.endFill())}return f},o.setupTimingPattern=function(){for(var l=8;l<this.moduleCount-8;l++)this.modules[l][6]==null&&(this.modules[l][6]=l%2==0);for(var c=8;c<this.moduleCount-8;c++)this.modules[6][c]==null&&(this.modules[6][c]=c%2==0)},o.setupPositionAdjustPattern=function(){for(var l=s.getPatternPosition(this.typeNumber),c=0;c<l.length;c++)for(var u=0;u<l.length;u++){var f=l[c],h=l[u];if(this.modules[f][h]==null)for(var m=-2;m<=2;m++)for(var g=-2;g<=2;g++)m==-2||m==2||g==-2||g==2||m==0&&g==0?this.modules[f+m][h+g]=!0:this.modules[f+m][h+g]=!1}},o.setupTypeNumber=function(l){for(var c=s.getBCHTypeNumber(this.typeNumber),u=0;u<18;u++){var f=!l&&(c>>u&1)==1;this.modules[Math.floor(u/3)][u%3+this.moduleCount-8-3]=f}for(var u=0;u<18;u++){var f=!l&&(c>>u&1)==1;this.modules[u%3+this.moduleCount-8-3][Math.floor(u/3)]=f}},o.setupTypeInfo=function(l,c){for(var u=this.errorCorrectLevel<<3|c,f=s.getBCHTypeInfo(u),h=0;h<15;h++){var m=!l&&(f>>h&1)==1;h<6?this.modules[h][8]=m:h<8?this.modules[h+1][8]=m:this.modules[this.moduleCount-15+h][8]=m}for(var h=0;h<15;h++){var m=!l&&(f>>h&1)==1;h<8?this.modules[8][this.moduleCount-h-1]=m:h<9?this.modules[8][15-h-1+1]=m:this.modules[8][15-h-1]=m}this.modules[this.moduleCount-8][8]=!l},o.mapData=function(l,c){for(var u=-1,f=this.moduleCount-1,h=7,m=0,g=this.moduleCount-1;g>0;g-=2)for(g==6&&g--;;){for(var b=0;b<2;b++)if(this.modules[f][g-b]==null){var v=!1;m<l.length&&(v=(l[m]>>>h&1)==1);var k=s.getMask(c,f,g-b);k&&(v=!v),this.modules[f][g-b]=v,h--,h==-1&&(m++,h=7)}if(f+=u,f<0||this.moduleCount<=f){f-=u,u=-u;break}}},a.PAD0=236,a.PAD1=17,a.createData=function(l,c,u){for(var f=t.getRSBlocks(l,c),h=new n,m=0;m<u.length;m++){var g=u[m];h.put(g.mode,4),h.put(g.getLength(),s.getLengthInBits(g.mode,l)),g.write(h)}for(var b=0,m=0;m<f.length;m++)b+=f[m].dataCount;if(h.getLengthInBits()>b*8)throw new Error("code length overflow. ("+h.getLengthInBits()+">"+b*8+")");for(h.getLengthInBits()+4<=b*8&&h.put(0,4);h.getLengthInBits()%8!=0;)h.putBit(!1);for(;!(h.getLengthInBits()>=b*8||(h.put(a.PAD0,8),h.getLengthInBits()>=b*8));)h.put(a.PAD1,8);return a.createBytes(h,f)},a.createBytes=function(l,c){for(var u=0,f=0,h=0,m=new Array(c.length),g=new Array(c.length),b=0;b<c.length;b++){var v=c[b].dataCount,k=c[b].totalCount-v;f=Math.max(f,v),h=Math.max(h,k),m[b]=new Array(v);for(var w=0;w<m[b].length;w++)m[b][w]=255&l.buffer[w+u];u+=v;var C=s.getErrorCorrectPolynomial(k),E=new r(m[b],C.getLength()-1),T=E.mod(C);g[b]=new Array(C.getLength()-1);for(var w=0;w<g[b].length;w++){var _=w+T.getLength()-g[b].length;g[b][w]=_>=0?T.get(_):0}}for(var j=0,w=0;w<c.length;w++)j+=c[w].totalCount;for(var R=new Array(j),D=0,w=0;w<f;w++)for(var b=0;b<c.length;b++)w<m[b].length&&(R[D++]=m[b][w]);for(var w=0;w<h;w++)for(var b=0;b<c.length;b++)w<g[b].length&&(R[D++]=g[b][w]);return R},HN=a,HN}var C1={},_7;function LYe(){if(_7)return C1;_7=1,Object.defineProperty(C1,"__esModule",{value:!0});var e=Object.assign||function(u){for(var f=1;f<arguments.length;f++){var h=arguments[f];for(var m in h)Object.prototype.hasOwnProperty.call(h,m)&&(u[m]=h[m])}return u},t=pO(),n=a(t),s=_u(),r=a(s);function a(u){return u&&u.__esModule?u:{default:u}}function o(u,f){var h={};for(var m in u)f.indexOf(m)>=0||Object.prototype.hasOwnProperty.call(u,m)&&(h[m]=u[m]);return h}var l={bgColor:n.default.oneOfType([n.default.object,n.default.string]).isRequired,bgD:n.default.string.isRequired,fgColor:n.default.oneOfType([n.default.object,n.default.string]).isRequired,fgD:n.default.string.isRequired,size:n.default.number.isRequired,title:n.default.string,viewBoxSize:n.default.number.isRequired,xmlns:n.default.string},c=(0,s.forwardRef)(function(u,f){var h=u.bgColor,m=u.bgD,g=u.fgD,b=u.fgColor,v=u.size,k=u.title,w=u.viewBoxSize,C=u.xmlns,E=C===void 0?"http://www.w3.org/2000/svg":C,T=o(u,["bgColor","bgD","fgD","fgColor","size","title","viewBoxSize","xmlns"]);return r.default.createElement("svg",e({},T,{height:v,ref:f,viewBox:"0 0 "+w+" "+w,width:v,xmlns:E}),k?r.default.createElement("title",null,k):null,r.default.createElement("path",{d:m,fill:h}),r.default.createElement("path",{d:g,fill:b}))});return c.displayName="QRCodeSvg",c.propTypes=l,C1.default=c,C1}var N7;function FYe(){if(N7)return dp;N7=1,Object.defineProperty(dp,"__esModule",{value:!0}),dp.QRCode=void 0;var e=Object.assign||function(v){for(var k=1;k<arguments.length;k++){var w=arguments[k];for(var C in w)Object.prototype.hasOwnProperty.call(w,C)&&(v[C]=w[C])}return v},t=pO(),n=h(t),s=yae(),r=h(s),a=PYe(),o=h(a),l=_u(),c=h(l),u=LYe(),f=h(u);function h(v){return v&&v.__esModule?v:{default:v}}function m(v,k){var w={};for(var C in v)k.indexOf(C)>=0||Object.prototype.hasOwnProperty.call(v,C)&&(w[C]=v[C]);return w}var g={bgColor:n.default.oneOfType([n.default.object,n.default.string]),fgColor:n.default.oneOfType([n.default.object,n.default.string]),level:n.default.string,size:n.default.number,value:n.default.string.isRequired},b=(0,l.forwardRef)(function(v,k){var w=v.bgColor,C=w===void 0?"#FFFFFF":w,E=v.fgColor,T=E===void 0?"#000000":E,_=v.level,j=_===void 0?"L":_,R=v.size,D=R===void 0?256:R,I=v.value,O=m(v,["bgColor","fgColor","level","size","value"]),L=new o.default(-1,r.default[j]);L.addData(I),L.make();var B=L.modules;return c.default.createElement(f.default,e({},O,{bgColor:C,bgD:B.map(function(H,K){return H.map(function(U,$){return U?"":"M "+$+" "+K+" l 1 0 0 1 -1 0 Z"}).join(" ")}).join(" "),fgColor:T,fgD:B.map(function(H,K){return H.map(function(U,$){return U?"M "+$+" "+K+" l 1 0 0 1 -1 0 Z":""}).join(" ")}).join(" "),ref:k,size:D,viewBoxSize:B.length}))});return dp.QRCode=b,b.displayName="QRCode",b.propTypes=g,dp.default=b,dp}var zYe=FYe();const BYe=eo(zYe);function $Ye(e){return/auth|token|ERR_NGROK_105/i.test(e)?"Check your auth token at dashboard.ngrok.com":/timeout|ETIMEDOUT/i.test(e)?"Connection timed out. Check your network.":/limit|ERR_NGROK_108/i.test(e)?"Tunnel limit reached. Free ngrok accounts allow one active tunnel.":/DNS|NXDOMAIN|ERR_NGROK_332/i.test(e)?"DNS resolution failed. Check your domain configuration.":/gateway|502|ERR_NGROK_3200/i.test(e)?"Gateway error. The tunnel endpoint is unreachable.":/upgrade|ERR_NGROK_120/i.test(e)?"Feature requires a paid ngrok plan.":/ECONNREFUSED/i.test(e)?"Connection refused. Ensure the server is running.":e}function HYe(e){return e===null?"bg-gray-400":e<200?"bg-green-500":e<500?"bg-amber-400":"bg-red-500"}const UYe={initial:{scale:.98,opacity:0},animate:{scale:1,opacity:1}},VYe={type:"spring",stiffness:400,damping:28},qYe={initial:{opacity:0},animate:{opacity:1}},GYe={duration:.3,delay:.5},KYe={initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0}},WYe={duration:.2,ease:[0,0,.2,1]};function YYe({url:e,activeSessionId:t,latencyMs:n}){const[s,r]=Bx(),[a,o]=Bx(),[l,c]=x.useState(!1),u=t?`${e}?session=${t}`:null;return i.jsxs("div",{"data-testid":"tunnel-connected",className:"space-y-3",children:[i.jsxs(oe.div,{className:"bg-muted/30 rounded-lg border border-green-500/20 p-3",variants:UYe,initial:"initial",animate:"animate",transition:VYe,children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:X("inline-block size-1.5 shrink-0 rounded-full",HYe(n)),"aria-label":n!==null?`${n}ms latency`:"Latency unknown"}),i.jsx("span",{className:"text-foreground min-w-0 flex-1 truncate font-mono text-xs",children:e.replace(/^https?:\/\//,"")}),i.jsx(He,{children:n!==null&&i.jsxs(oe.span,{className:"text-muted-foreground shrink-0 text-xs",variants:qYe,initial:"initial",animate:"animate",transition:GYe,children:[n,"ms"]})})]}),i.jsxs("div",{className:"mt-3 flex gap-2",children:[i.jsxs(ve,{variant:"outline",size:"sm",className:"flex-1 gap-1.5",onClick:()=>r(e),children:[s?i.jsx(Zt,{className:"size-3"}):i.jsx(Gf,{className:"size-3"}),s?"Copied":"Copy URL"]}),u&&i.jsxs(ve,{variant:"outline",size:"sm",className:"flex-1 gap-1.5",onClick:()=>o(u),children:[a?i.jsx(Zt,{className:"size-3"}):i.jsx(eTe,{className:"size-3"}),a?"Copied":"Session link"]}),i.jsx(ve,{variant:"outline",size:"sm",onClick:()=>c(f=>!f),"aria-label":"Toggle QR code",className:X(l&&"bg-accent"),children:i.jsx(WTe,{className:"size-3.5"})})]})]}),i.jsx(He,{children:l&&i.jsxs(oe.div,{variants:KYe,initial:"initial",animate:"animate",exit:"exit",transition:WYe,className:"overflow-hidden",children:[i.jsx("div",{className:"flex justify-center rounded-lg bg-white p-4",children:i.jsx(BYe,{value:e,size:180,level:"M"})}),i.jsx("p",{className:"text-muted-foreground mt-2 text-center text-xs",children:"Scan from any device"})]},"qr-expand")})]})}const ZYe={initial:{x:0},animate:{x:[0,-2,2,-1,0]}},XYe={duration:.35,ease:"easeInOut"};function QYe({error:e,onRetry:t}){const n=$Ye(e);return i.jsx(oe.div,{"data-testid":"tunnel-error",className:"rounded-lg border border-red-200 bg-red-50 p-4 dark:border-red-800 dark:bg-red-950/30",variants:ZYe,initial:"initial",animate:"animate",transition:XYe,children:i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsx(Wk,{className:"mt-0.5 size-4 shrink-0 text-red-600 dark:text-red-400"}),i.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[i.jsx("p",{className:"text-sm font-medium text-red-800 dark:text-red-200",children:"Connection failed"}),i.jsx("p",{className:"text-xs text-red-700 dark:text-red-300",children:n}),i.jsxs(ve,{variant:"outline",size:"sm",onClick:t,className:"border-red-300 text-red-700 hover:bg-red-100 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-900/50",children:[i.jsx(mu,{className:"mr-1.5 size-3.5"}),"Try again"]})]})]})})}var JYe=Object.defineProperty,eZe=Object.defineProperties,tZe=Object.getOwnPropertyDescriptors,Aw=Object.getOwnPropertySymbols,wae=Object.prototype.hasOwnProperty,kae=Object.prototype.propertyIsEnumerable,j7=(e,t,n)=>t in e?JYe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,nZe=(e,t)=>{for(var n in t||(t={}))wae.call(t,n)&&j7(e,n,t[n]);if(Aw)for(var n of Aw(t))kae.call(t,n)&&j7(e,n,t[n]);return e},sZe=(e,t)=>eZe(e,tZe(t)),rZe=(e,t)=>{var n={};for(var s in e)wae.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&Aw)for(var s of Aw(e))t.indexOf(s)<0&&kae.call(e,s)&&(n[s]=e[s]);return n};function aZe(e){let t=setTimeout(e,0),n=setTimeout(e,10),s=setTimeout(e,50);return[t,n,s]}function iZe(e){let t=x.useRef();return x.useEffect(()=>{t.current=e}),t.current}var oZe=18,Cae=40,lZe=`${Cae}px`,cZe=["[data-lastpass-icon-root]","com-1password-button","[data-dashlanecreated]",'[style$="2147483647 !important;"]'].join(",");function uZe({containerRef:e,inputRef:t,pushPasswordManagerStrategy:n,isFocused:s}){let[r,a]=x.useState(!1),[o,l]=x.useState(!1),[c,u]=x.useState(!1),f=x.useMemo(()=>n==="none"?!1:(n==="increase-width"||n==="experimental-no-flickering")&&r&&o,[r,o,n]),h=x.useCallback(()=>{let m=e.current,g=t.current;if(!m||!g||c||n==="none")return;let b=m,v=b.getBoundingClientRect().left+b.offsetWidth,k=b.getBoundingClientRect().top+b.offsetHeight/2,w=v-oZe,C=k;document.querySelectorAll(cZe).length===0&&document.elementFromPoint(w,C)===m||(a(!0),u(!0))},[e,t,c,n]);return x.useEffect(()=>{let m=e.current;if(!m||n==="none")return;function g(){let v=window.innerWidth-m.getBoundingClientRect().right;l(v>=Cae)}g();let b=setInterval(g,1e3);return()=>{clearInterval(b)}},[e,n]),x.useEffect(()=>{let m=s||document.activeElement===t.current;if(n==="none"||!m)return;let g=setTimeout(h,0),b=setTimeout(h,2e3),v=setTimeout(h,5e3),k=setTimeout(()=>{u(!0)},6e3);return()=>{clearTimeout(g),clearTimeout(b),clearTimeout(v),clearTimeout(k)}},[t,s,n,h]),{hasPWMBadge:r,willPushPWMBadge:f,PWM_BADGE_SPACE_WIDTH:lZe}}var Eae=x.createContext({}),Tae=x.forwardRef((e,t)=>{var n=e,{value:s,onChange:r,maxLength:a,textAlign:o="left",pattern:l,placeholder:c,inputMode:u="numeric",onComplete:f,pushPasswordManagerStrategy:h="increase-width",pasteTransformer:m,containerClassName:g,noScriptCSSFallback:b=dZe,render:v,children:k}=n,w=rZe(n,["value","onChange","maxLength","textAlign","pattern","placeholder","inputMode","onComplete","pushPasswordManagerStrategy","pasteTransformer","containerClassName","noScriptCSSFallback","render","children"]),C,E,T,_,j;let[R,D]=x.useState(typeof w.defaultValue=="string"?w.defaultValue:""),I=s??R,O=iZe(I),L=x.useCallback(Se=>{r==null||r(Se),D(Se)},[r]),B=x.useMemo(()=>l?typeof l=="string"?new RegExp(l):l:null,[l]),H=x.useRef(null),K=x.useRef(null),U=x.useRef({value:I,onChange:L,isIOS:typeof window<"u"&&((E=(C=window==null?void 0:window.CSS)==null?void 0:C.supports)==null?void 0:E.call(C,"-webkit-touch-callout","none"))}),$=x.useRef({prev:[(T=H.current)==null?void 0:T.selectionStart,(_=H.current)==null?void 0:_.selectionEnd,(j=H.current)==null?void 0:j.selectionDirection]});x.useImperativeHandle(t,()=>H.current,[]),x.useEffect(()=>{let Se=H.current,Ze=K.current;if(!Se||!Ze)return;U.current.value!==Se.value&&U.current.onChange(Se.value),$.current.prev=[Se.selectionStart,Se.selectionEnd,Se.selectionDirection];function bt(){if(document.activeElement!==Se){G(null),Z(null);return}let Te=Se.selectionStart,Je=Se.selectionEnd,_t=Se.selectionDirection,St=Se.maxLength,Gt=Se.value,Kt=$.current.prev,Ae=-1,ce=-1,Ee;if(Gt.length!==0&&Te!==null&&Je!==null){let nn=Te===Je,Cn=Te===Gt.length&&Gt.length<St;if(nn&&!Cn){let yn=Te;if(yn===0)Ae=0,ce=1,Ee="forward";else if(yn===St)Ae=yn-1,ce=yn,Ee="backward";else if(St>1&&Gt.length>1){let En=0;if(Kt[0]!==null&&Kt[1]!==null){Ee=yn<Kt[1]?"backward":"forward";let Qn=Kt[0]===Kt[1]&&Kt[0]<St;Ee==="backward"&&!Qn&&(En=-1)}Ae=En+yn,ce=En+yn+1}}Ae!==-1&&ce!==-1&&Ae!==ce&&H.current.setSelectionRange(Ae,ce,Ee)}let Ye=Ae!==-1?Ae:Te,Ge=ce!==-1?ce:Je,et=Ee??_t;G(Ye),Z(Ge),$.current.prev=[Ye,Ge,et]}if(document.addEventListener("selectionchange",bt,{capture:!0}),bt(),document.activeElement===Se&&F(!0),!document.getElementById("input-otp-style")){let Te=document.createElement("style");if(Te.id="input-otp-style",document.head.appendChild(Te),Te.sheet){let Je="background: transparent !important; color: transparent !important; border-color: transparent !important; opacity: 0 !important; box-shadow: none !important; -webkit-box-shadow: none !important; -webkit-text-fill-color: transparent !important;";O0(Te.sheet,"[data-input-otp]::selection { background: transparent !important; color: transparent !important; }"),O0(Te.sheet,`[data-input-otp]:autofill { ${Je} }`),O0(Te.sheet,`[data-input-otp]:-webkit-autofill { ${Je} }`),O0(Te.sheet,"@supports (-webkit-touch-callout: none) { [data-input-otp] { letter-spacing: -.6em !important; font-weight: 100 !important; font-stretch: ultra-condensed; font-optical-sizing: none !important; left: -1px !important; right: 1px !important; } }"),O0(Te.sheet,"[data-input-otp] + * { pointer-events: all !important; }")}}let Me=()=>{Ze&&Ze.style.setProperty("--root-height",`${Se.clientHeight}px`)};Me();let Ie=new ResizeObserver(Me);return Ie.observe(Se),()=>{document.removeEventListener("selectionchange",bt,{capture:!0}),Ie.disconnect()}},[]);let[q,J]=x.useState(!1),[ne,F]=x.useState(!1),[V,G]=x.useState(null),[P,Z]=x.useState(null);x.useEffect(()=>{aZe(()=>{var Se,Ze,bt,Me;(Se=H.current)==null||Se.dispatchEvent(new Event("input"));let Ie=(Ze=H.current)==null?void 0:Ze.selectionStart,Te=(bt=H.current)==null?void 0:bt.selectionEnd,Je=(Me=H.current)==null?void 0:Me.selectionDirection;Ie!==null&&Te!==null&&(G(Ie),Z(Te),$.current.prev=[Ie,Te,Je])})},[I,ne]),x.useEffect(()=>{O!==void 0&&I!==O&&O.length<a&&I.length===a&&(f==null||f(I))},[a,f,O,I]);let Q=uZe({containerRef:K,inputRef:H,pushPasswordManagerStrategy:h,isFocused:ne}),re=x.useCallback(Se=>{let Ze=Se.currentTarget.value.slice(0,a);if(Ze.length>0&&B&&!B.test(Ze)){Se.preventDefault();return}typeof O=="string"&&Ze.length<O.length&&document.dispatchEvent(new Event("selectionchange")),L(Ze)},[a,L,O,B]),ae=x.useCallback(()=>{var Se;if(H.current){let Ze=Math.min(H.current.value.length,a-1),bt=H.current.value.length;(Se=H.current)==null||Se.setSelectionRange(Ze,bt),G(Ze),Z(bt)}F(!0)},[a]),de=x.useCallback(Se=>{var Ze,bt;let Me=H.current;if(!m&&(!U.current.isIOS||!Se.clipboardData||!Me))return;let Ie=Se.clipboardData.getData("text/plain"),Te=m?m(Ie):Ie;Se.preventDefault();let Je=(Ze=H.current)==null?void 0:Ze.selectionStart,_t=(bt=H.current)==null?void 0:bt.selectionEnd,St=(Je!==_t?I.slice(0,Je)+Te+I.slice(_t):I.slice(0,Je)+Te+I.slice(Je)).slice(0,a);if(St.length>0&&B&&!B.test(St))return;Me.value=St,L(St);let Gt=Math.min(St.length,a-1),Kt=St.length;Me.setSelectionRange(Gt,Kt),G(Gt),Z(Kt)},[a,L,B,I]),pe=x.useMemo(()=>({position:"relative",cursor:w.disabled?"default":"text",userSelect:"none",WebkitUserSelect:"none",pointerEvents:"none"}),[w.disabled]),Oe=x.useMemo(()=>({position:"absolute",inset:0,width:Q.willPushPWMBadge?`calc(100% + ${Q.PWM_BADGE_SPACE_WIDTH})`:"100%",clipPath:Q.willPushPWMBadge?`inset(0 ${Q.PWM_BADGE_SPACE_WIDTH} 0 0)`:void 0,height:"100%",display:"flex",textAlign:o,opacity:"1",color:"transparent",pointerEvents:"all",background:"transparent",caretColor:"transparent",border:"0 solid transparent",outline:"0 solid transparent",boxShadow:"none",lineHeight:"1",letterSpacing:"-.5em",fontSize:"var(--root-height)",fontFamily:"monospace",fontVariantNumeric:"tabular-nums"}),[Q.PWM_BADGE_SPACE_WIDTH,Q.willPushPWMBadge,o]),Ve=x.useMemo(()=>x.createElement("input",sZe(nZe({autoComplete:w.autoComplete||"one-time-code"},w),{"data-input-otp":!0,"data-input-otp-placeholder-shown":I.length===0||void 0,"data-input-otp-mss":V,"data-input-otp-mse":P,inputMode:u,pattern:B==null?void 0:B.source,"aria-placeholder":c,style:Oe,maxLength:a,value:I,ref:H,onPaste:Se=>{var Ze;de(Se),(Ze=w.onPaste)==null||Ze.call(w,Se)},onChange:re,onMouseOver:Se=>{var Ze;J(!0),(Ze=w.onMouseOver)==null||Ze.call(w,Se)},onMouseLeave:Se=>{var Ze;J(!1),(Ze=w.onMouseLeave)==null||Ze.call(w,Se)},onFocus:Se=>{var Ze;ae(),(Ze=w.onFocus)==null||Ze.call(w,Se)},onBlur:Se=>{var Ze;F(!1),(Ze=w.onBlur)==null||Ze.call(w,Se)}})),[re,ae,de,u,Oe,a,P,V,w,B==null?void 0:B.source,I]),$e=x.useMemo(()=>({slots:Array.from({length:a}).map((Se,Ze)=>{var bt;let Me=ne&&V!==null&&P!==null&&(V===P&&Ze===V||Ze>=V&&Ze<P),Ie=I[Ze]!==void 0?I[Ze]:null,Te=I[0]!==void 0?null:(bt=c==null?void 0:c[Ze])!=null?bt:null;return{char:Ie,placeholderChar:Te,isActive:Me,hasFakeCaret:Me&&Ie===null}}),isFocused:ne,isHovering:!w.disabled&&q}),[ne,q,a,P,V,w.disabled,I]),Qe=x.useMemo(()=>v?v($e):x.createElement(Eae.Provider,{value:$e},k),[k,$e,v]);return x.createElement(x.Fragment,null,b!==null&&x.createElement("noscript",null,x.createElement("style",null,b)),x.createElement("div",{ref:K,"data-input-otp-container":!0,style:pe,className:g},Qe,x.createElement("div",{style:{position:"absolute",inset:0,pointerEvents:"none"}},Ve)))});Tae.displayName="Input";function O0(e,t){try{e.insertRule(t)}catch{console.error("input-otp could not insert CSS rule:",t)}}var dZe=`
|
|
1044
1044
|
[data-input-otp] {
|
|
1045
1045
|
--nojs-bg: white !important;
|
|
1046
1046
|
--nojs-fg: black !important;
|
|
@@ -1072,7 +1072,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1072
1072
|
`);/\r./.test(r);)r=r.replace(/^([^\r\n]*)\r+([^\r\n]+)/gm,function(a,o,l){return l+o.slice(l.length)});return r}function t(r){for(var a=0,o=0;o<r.length;o++)r[a].length<=r[o].length&&(a=o);return a}function n(r){if(!/\r/.test(r))return r;for(var a=r.split("\r"),o=[];a.length>0;){var l=t(a);o.push(a[l]),a=a.slice(l+1)}return o.join("\r")}function s(r){if(!r)return"";if(!/\r/.test(r))return r;if(!/\n/.test(r))return n(r);r=r.replace(/\r+\n/gm,`
|
|
1073
1073
|
`);var a=r.lastIndexOf(`
|
|
1074
1074
|
`);return e(r.slice(0,a))+`
|
|
1075
|
-
`+n(r.slice(a+1))}return F0.exports=e,F0.exports.escapeCarriageReturn=e,F0.exports.escapeCarriageReturnSafe=s,F0.exports}var rj,M$;function art(){return M$||(M$=1,rj=/[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/),rj}var aj,D$;function irt(){return D$||(D$=1,aj=/[\0-\x1F\x7F-\x9F]/),aj}var ij,O$;function ort(){return O$||(O$=1,ij=/[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/),ij}var oj,I$;function lrt(){return I$||(I$=1,oj=/[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4E\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDF55-\uDF59]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDF3C-\uDF3E]|\uD806[\uDC3B\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDE97-\uDE9A]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/),oj}var lj,P$;function crt(){return P$||(P$=1,lj=function(e){var t={};t.src_Any=art().source,t.src_Cc=irt().source,t.src_Z=ort().source,t.src_P=lrt().source,t.src_ZPCc=[t.src_Z,t.src_P,t.src_Cc].join("|"),t.src_ZCc=[t.src_Z,t.src_Cc].join("|");var n="[><|]";return t.src_pseudo_letter="(?:(?!"+n+"|"+t.src_ZPCc+")"+t.src_Any+")",t.src_ip4="(?:(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)",t.src_auth="(?:(?:(?!"+t.src_ZCc+"|[@/\\[\\]()]).)+@)?",t.src_port="(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?",t.src_host_terminator="(?=$|"+n+"|"+t.src_ZPCc+")(?!-|_|:\\d|\\.-|\\.(?!$|"+t.src_ZPCc+"))",t.src_path="(?:[/?#](?:(?!"+t.src_ZCc+"|"+n+`|[()[\\]{}.,"'?!\\-;]).|\\[(?:(?!`+t.src_ZCc+"|\\]).)*\\]|\\((?:(?!"+t.src_ZCc+"|[)]).)*\\)|\\{(?:(?!"+t.src_ZCc+'|[}]).)*\\}|\\"(?:(?!'+t.src_ZCc+`|["]).)+\\"|\\'(?:(?!`+t.src_ZCc+"|[']).)+\\'|\\'(?="+t.src_pseudo_letter+"|[-]).|\\.{2,}[a-zA-Z0-9%/&]|\\.(?!"+t.src_ZCc+"|[.]).|"+(e&&e["---"]?"\\-(?!--(?:[^-]|$))(?:-*)|":"\\-+|")+",(?!"+t.src_ZCc+").|;(?!"+t.src_ZCc+").|\\!+(?!"+t.src_ZCc+"|[!]).|\\?(?!"+t.src_ZCc+"|[?]).)+|\\/)?",t.src_email_name='[\\-;:&=\\+\\$,\\.a-zA-Z0-9_][\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]*',t.src_xn="xn--[a-z0-9\\-]{1,59}",t.src_domain_root="(?:"+t.src_xn+"|"+t.src_pseudo_letter+"{1,63})",t.src_domain="(?:"+t.src_xn+"|(?:"+t.src_pseudo_letter+")|(?:"+t.src_pseudo_letter+"(?:-|"+t.src_pseudo_letter+"){0,61}"+t.src_pseudo_letter+"))",t.src_host="(?:(?:(?:(?:"+t.src_domain+")\\.)*"+t.src_domain+"))",t.tpl_host_fuzzy="(?:"+t.src_ip4+"|(?:(?:(?:"+t.src_domain+")\\.)+(?:%TLDS%)))",t.tpl_host_no_ip_fuzzy="(?:(?:(?:"+t.src_domain+")\\.)+(?:%TLDS%))",t.src_host_strict=t.src_host+t.src_host_terminator,t.tpl_host_fuzzy_strict=t.tpl_host_fuzzy+t.src_host_terminator,t.src_host_port_strict=t.src_host+t.src_port+t.src_host_terminator,t.tpl_host_port_fuzzy_strict=t.tpl_host_fuzzy+t.src_port+t.src_host_terminator,t.tpl_host_port_no_ip_fuzzy_strict=t.tpl_host_no_ip_fuzzy+t.src_port+t.src_host_terminator,t.tpl_host_fuzzy_test="localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:"+t.src_ZPCc+"|>|$))",t.tpl_email_fuzzy="(^|"+n+'|"|\\(|'+t.src_ZCc+")("+t.src_email_name+"@"+t.tpl_host_fuzzy_strict+")",t.tpl_link_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+t.src_ZPCc+"))((?![$+<=>^`||])"+t.tpl_host_port_fuzzy_strict+t.src_path+")",t.tpl_link_no_ip_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+t.src_ZPCc+"))((?![$+<=>^`||])"+t.tpl_host_port_no_ip_fuzzy_strict+t.src_path+")",t}),lj}var cj,L$;function urt(){if(L$)return cj;L$=1;function e(E){var T=Array.prototype.slice.call(arguments,1);return T.forEach(function(_){_&&Object.keys(_).forEach(function(j){E[j]=_[j]})}),E}function t(E){return Object.prototype.toString.call(E)}function n(E){return t(E)==="[object String]"}function s(E){return t(E)==="[object Object]"}function r(E){return t(E)==="[object RegExp]"}function a(E){return t(E)==="[object Function]"}function o(E){return E.replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}var l={fuzzyLink:!0,fuzzyEmail:!0,fuzzyIP:!1};function c(E){return Object.keys(E||{}).reduce(function(T,_){return T||l.hasOwnProperty(_)},!1)}var u={"http:":{validate:function(E,T,_){var j=E.slice(T);return _.re.http||(_.re.http=new RegExp("^\\/\\/"+_.re.src_auth+_.re.src_host_port_strict+_.re.src_path,"i")),_.re.http.test(j)?j.match(_.re.http)[0].length:0}},"https:":"http:","ftp:":"http:","//":{validate:function(E,T,_){var j=E.slice(T);return _.re.no_http||(_.re.no_http=new RegExp("^"+_.re.src_auth+"(?:localhost|(?:(?:"+_.re.src_domain+")\\.)+"+_.re.src_domain_root+")"+_.re.src_port+_.re.src_host_terminator+_.re.src_path,"i")),_.re.no_http.test(j)?T>=3&&E[T-3]===":"||T>=3&&E[T-3]==="/"?0:j.match(_.re.no_http)[0].length:0}},"mailto:":{validate:function(E,T,_){var j=E.slice(T);return _.re.mailto||(_.re.mailto=new RegExp("^"+_.re.src_email_name+"@"+_.re.src_host_strict,"i")),_.re.mailto.test(j)?j.match(_.re.mailto)[0].length:0}}},f="a[cdefgilmnoqrstuwxz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvwxyz]|d[ejkmoz]|e[cegrstu]|f[ijkmor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdeghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eosuw]|s[abcdeghijklmnortuvxyz]|t[cdfghjklmnortvwz]|u[agksyz]|v[aceginu]|w[fs]|y[et]|z[amw]",h="biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф".split("|");function m(E){E.__index__=-1,E.__text_cache__=""}function g(E){return function(T,_){var j=T.slice(_);return E.test(j)?j.match(E)[0].length:0}}function b(){return function(E,T){T.normalize(E)}}function v(E){var T=E.re=crt()(E.__opts__),_=E.__tlds__.slice();E.onCompile(),E.__tlds_replaced__||_.push(f),_.push(T.src_xn),T.src_tlds=_.join("|");function j(O){return O.replace("%TLDS%",T.src_tlds)}T.email_fuzzy=RegExp(j(T.tpl_email_fuzzy),"i"),T.link_fuzzy=RegExp(j(T.tpl_link_fuzzy),"i"),T.link_no_ip_fuzzy=RegExp(j(T.tpl_link_no_ip_fuzzy),"i"),T.host_fuzzy_test=RegExp(j(T.tpl_host_fuzzy_test),"i");var R=[];E.__compiled__={};function D(O,L){throw new Error('(LinkifyIt) Invalid schema "'+O+'": '+L)}Object.keys(E.__schemas__).forEach(function(O){var L=E.__schemas__[O];if(L!==null){var B={validate:null,link:null};if(E.__compiled__[O]=B,s(L)){r(L.validate)?B.validate=g(L.validate):a(L.validate)?B.validate=L.validate:D(O,L),a(L.normalize)?B.normalize=L.normalize:L.normalize?D(O,L):B.normalize=b();return}if(n(L)){R.push(O);return}D(O,L)}}),R.forEach(function(O){E.__compiled__[E.__schemas__[O]]&&(E.__compiled__[O].validate=E.__compiled__[E.__schemas__[O]].validate,E.__compiled__[O].normalize=E.__compiled__[E.__schemas__[O]].normalize)}),E.__compiled__[""]={validate:null,normalize:b()};var I=Object.keys(E.__compiled__).filter(function(O){return O.length>0&&E.__compiled__[O]}).map(o).join("|");E.re.schema_test=RegExp("(^|(?!_)(?:[><|]|"+T.src_ZPCc+"))("+I+")","i"),E.re.schema_search=RegExp("(^|(?!_)(?:[><|]|"+T.src_ZPCc+"))("+I+")","ig"),E.re.pretest=RegExp("("+E.re.schema_test.source+")|("+E.re.host_fuzzy_test.source+")|@","i"),m(E)}function k(E,T){var _=E.__index__,j=E.__last_index__,R=E.__text_cache__.slice(_,j);this.schema=E.__schema__.toLowerCase(),this.index=_+T,this.lastIndex=j+T,this.raw=R,this.text=R,this.url=R}function w(E,T){var _=new k(E,T);return E.__compiled__[_.schema].normalize(_,E),_}function C(E,T){if(!(this instanceof C))return new C(E,T);T||c(E)&&(T=E,E={}),this.__opts__=e({},l,T),this.__index__=-1,this.__last_index__=-1,this.__schema__="",this.__text_cache__="",this.__schemas__=e({},u,E),this.__compiled__={},this.__tlds__=h,this.__tlds_replaced__=!1,this.re={},v(this)}return C.prototype.add=function(T,_){return this.__schemas__[T]=_,v(this),this},C.prototype.set=function(T){return this.__opts__=e(this.__opts__,T),this},C.prototype.test=function(T){if(this.__text_cache__=T,this.__index__=-1,!T.length)return!1;var _,j,R,D,I,O,L,B,H;if(this.re.schema_test.test(T)){for(L=this.re.schema_search,L.lastIndex=0;(_=L.exec(T))!==null;)if(D=this.testSchemaAt(T,_[2],L.lastIndex),D){this.__schema__=_[2],this.__index__=_.index+_[1].length,this.__last_index__=_.index+_[0].length+D;break}}return this.__opts__.fuzzyLink&&this.__compiled__["http:"]&&(B=T.search(this.re.host_fuzzy_test),B>=0&&(this.__index__<0||B<this.__index__)&&(j=T.match(this.__opts__.fuzzyIP?this.re.link_fuzzy:this.re.link_no_ip_fuzzy))!==null&&(I=j.index+j[1].length,(this.__index__<0||I<this.__index__)&&(this.__schema__="",this.__index__=I,this.__last_index__=j.index+j[0].length))),this.__opts__.fuzzyEmail&&this.__compiled__["mailto:"]&&(H=T.indexOf("@"),H>=0&&(R=T.match(this.re.email_fuzzy))!==null&&(I=R.index+R[1].length,O=R.index+R[0].length,(this.__index__<0||I<this.__index__||I===this.__index__&&O>this.__last_index__)&&(this.__schema__="mailto:",this.__index__=I,this.__last_index__=O))),this.__index__>=0},C.prototype.pretest=function(T){return this.re.pretest.test(T)},C.prototype.testSchemaAt=function(T,_,j){return this.__compiled__[_.toLowerCase()]?this.__compiled__[_.toLowerCase()].validate(T,j,this):0},C.prototype.match=function(T){var _=0,j=[];this.__index__>=0&&this.__text_cache__===T&&(j.push(w(this,_)),_=this.__last_index__);for(var R=_?T.slice(_):T;this.test(R);)j.push(w(this,_)),R=R.slice(this.__last_index__),_+=this.__last_index__;return j.length?j:null},C.prototype.tlds=function(T,_){return T=Array.isArray(T)?T:[T],_?(this.__tlds__=this.__tlds__.concat(T).sort().filter(function(j,R,D){return j!==D[R-1]}).reverse(),v(this),this):(this.__tlds__=T.slice(),this.__tlds_replaced__=!0,v(this),this)},C.prototype.normalize=function(T){T.schema||(T.url="http://"+T.url),T.schema==="mailto:"&&!/^mailto:/i.test(T.url)&&(T.url="mailto:"+T.url)},C.prototype.onCompile=function(){},cj=C,cj}var F$;function drt(){if(F$)return hi;F$=1;var e=hi&&hi.__createBinding||(Object.create?(function(k,w,C,E){E===void 0&&(E=C);var T=Object.getOwnPropertyDescriptor(w,C);(!T||("get"in T?!w.__esModule:T.writable||T.configurable))&&(T={enumerable:!0,get:function(){return w[C]}}),Object.defineProperty(k,E,T)}):(function(k,w,C,E){E===void 0&&(E=C),k[E]=w[C]})),t=hi&&hi.__setModuleDefault||(Object.create?(function(k,w){Object.defineProperty(k,"default",{enumerable:!0,value:w})}):function(k,w){k.default=w}),n=hi&&hi.__importStar||(function(){var k=function(w){return k=Object.getOwnPropertyNames||function(C){var E=[];for(var T in C)Object.prototype.hasOwnProperty.call(C,T)&&(E[E.length]=T);return E},k(w)};return function(w){if(w&&w.__esModule)return w;var C={};if(w!=null)for(var E=k(w),T=0;T<E.length;T++)E[T]!=="default"&&e(C,w,E[T]);return t(C,w),C}})(),s=hi&&hi.__importDefault||function(k){return k&&k.__esModule?k:{default:k}};Object.defineProperty(hi,"__esModule",{value:!0}),hi.default=b;const r=s(srt()),a=rrt(),o=s(urt()),l=n(_u());function c(k,w=!1){return k=(0,a.escapeCarriageReturn)(v(k)),r.default.ansiToJson(k,{json:!0,remove_empty:!0,use_classes:w})}function u(k){let w="";return k.bg&&(w+=`${k.bg}-bg `),k.fg&&(w+=`${k.fg}-fg `),k.decoration&&(w+=`ansi-${k.decoration} `),w===""?null:(w=w.substring(0,w.length-1),w)}function f(k){const w={};switch(k.bg&&(w.backgroundColor=`rgb(${k.bg})`),k.fg&&(w.color=`rgb(${k.fg})`),k.decoration){case"bold":w.fontWeight="bold";break;case"dim":w.opacity="0.5";break;case"italic":w.fontStyle="italic";break;case"hidden":w.visibility="hidden";break;case"strikethrough":w.textDecoration="line-through";break;case"underline":w.textDecoration="underline";break;case"blink":w.textDecoration="blink";break}return w}function h(k,w,C,E){const T=w?null:f(C),_=w?u(C):null;return k?k==="fuzzy"?g(C,E,T,_):m(C,E,T,_):l.createElement("span",{style:T,key:E,className:_},C.content)}function m(k,w,C,E){const T=[],_=/(\s|^)(https?:\/\/(?:www\.|(?!www))[^\s.]+\.[^\s]{2,}|www\.[^\s]+\.[^\s]{2,})/g;let j=0,R;for(;(R=_.exec(k.content))!==null;){const[,D,I]=R,O=R.index+D.length;O>j&&T.push(k.content.substring(j,O));const L=I.startsWith("www.")?`http://${I}`:I;T.push(l.createElement("a",{key:j,href:L,target:"_blank"},`${I}`)),j=_.lastIndex}return j<k.content.length&&T.push(k.content.substring(j)),l.createElement("span",{style:C,key:w,className:E},T)}function g(k,w,C,E){var T;const _=(0,o.default)({fuzzyEmail:!1}).tlds(["io"],!0);if(!_.pretest(k.content))return l.createElement("span",{style:C,key:w,className:E},k.content);const j=_.match(k.content);if(!j)return l.createElement("span",{style:C,key:w,className:E},k.content);const R=[k.content.substring(0,(T=j[0])===null||T===void 0?void 0:T.index)];return j.forEach((D,I)=>{var O;R.push(l.createElement("a",{href:D.url,target:"_blank",key:I},k.content.substring(D.index,D.lastIndex))),j[I+1]&&R.push(k.content.substring(j[I].lastIndex,(O=j[I+1])===null||O===void 0?void 0:O.index))}),j[j.length-1].lastIndex!==k.content.length&&R.push(k.content.substring(j[j.length-1].lastIndex,k.content.length)),l.createElement("span",{style:C,key:w,className:E},R)}function b(k){const{className:w,useClasses:C,children:E,linkify:T}=k;return l.createElement("code",{className:w},c(E??"",C??!1).map(h.bind(null,T??!1,C??!1)))}function v(k){let w=k;do k=w,w=k.replace(/[^\n]\x08/gm,"");while(w.length<k.length);return k}return hi}var frt=drt();const hrt=eo(frt),prt=x.lazy(()=>Ar(()=>import("./index-CRu7kmbh.js"),[])),mrt={...Jst,container:"bg-transparent text-xs font-mono leading-relaxed",label:"text-muted-foreground font-medium mr-1",clickableLabel:"text-muted-foreground font-medium mr-1 cursor-pointer",nullValue:"text-muted-foreground italic",undefinedValue:"text-muted-foreground italic",stringValue:"text-foreground",booleanValue:"text-amber-400",numberValue:"text-blue-400",otherValue:"text-muted-foreground",punctuation:"text-muted-foreground",collapseIcon:"text-muted-foreground",expandIcon:"text-muted-foreground",collapsedContent:"text-muted-foreground"},z$=5120;function grt(e){try{const t=JSON.parse(e);return typeof t=="object"&&t!==null&&("old_string"in t||"new_string"in t)?t:null}catch{return null}}function uj({children:e,rawContent:t,supportsRawToggle:n,isRaw:s,onToggleRaw:r}){const[a,o]=x.useState(!1),l=t.length>z$,c=l&&!a?t.slice(0,z$):t;return i.jsxs("div",{className:"space-y-1",children:[n&&i.jsx("div",{className:"flex justify-end",children:i.jsx("button",{onClick:r,className:"text-muted-foreground hover:text-foreground text-xs underline",children:s?"Formatted":"Raw"})}),s?i.jsxs(i.Fragment,{children:[i.jsx("pre",{className:"max-h-64 overflow-y-auto text-xs whitespace-pre-wrap",children:c}),l&&!a&&i.jsxs("button",{onClick:()=>o(!0),className:"text-muted-foreground hover:text-foreground text-xs underline",children:["Show full output (",(t.length/1024).toFixed(1),"KB)"]})]}):e]})}function xrt({oldValue:e,newValue:t,rawContent:n}){return i.jsx(x.Suspense,{fallback:i.jsx("pre",{className:"max-h-64 overflow-y-auto text-xs whitespace-pre-wrap",children:n}),children:i.jsx(prt,{oldValue:e,newValue:t,splitView:!1,useDarkTheme:!0,hideLineNumbers:!0,showDiffOnly:!0,extraLinesSurroundingDiff:2,styles:{variables:{dark:{diffViewerBackground:"transparent",addedBackground:"rgba(34, 197, 94, 0.1)",addedColor:"rgb(134, 239, 172)",addedGutterBackground:"rgba(34, 197, 94, 0.08)",wordAddedBackground:"rgba(34, 197, 94, 0.2)",removedBackground:"rgba(239, 68, 68, 0.1)",removedColor:"rgb(252, 165, 165)",removedGutterBackground:"rgba(239, 68, 68, 0.08)",wordRemovedBackground:"rgba(239, 68, 68, 0.2)",gutterBackground:"hsl(0 0% 9%)",gutterBackgroundDark:"hsl(0 0% 7%)",gutterColor:"hsl(0 0% 40%)"}}}})})}function yrt({content:e,toolName:t,input:n}){const[s,r]=x.useState(!1);if(t==="Edit"&&n){const o=grt(n);if(o)return i.jsx(xrt,{oldValue:o.old_string??"",newValue:o.new_string??"",rawContent:e})}const a=$2e(e);if(a==="json"){let o;try{o=JSON.parse(e)}catch{o={}}return i.jsx(uj,{rawContent:e,supportsRawToggle:!0,isRaw:s,onToggleRaw:()=>r(l=>!l),children:i.jsx(nrt,{data:o,style:mrt,shouldExpandNode:trt})})}return a==="ansi"?i.jsx(uj,{rawContent:e,supportsRawToggle:!0,isRaw:s,onToggleRaw:()=>r(o=>!o),children:i.jsx("pre",{className:"max-h-64 overflow-y-auto text-xs whitespace-pre-wrap",children:i.jsx(hrt,{children:e})})}):i.jsx(uj,{rawContent:e,supportsRawToggle:!1,isRaw:!0,onToggleRaw:()=>{},children:null})}const brt=5120;function vrt({content:e,threshold:t=brt,className:n}){const[s,r]=x.useState(!1),a=e.length>t,o=a&&!s?e.slice(0,t):e;return i.jsxs("div",{className:X("mt-2 border-t pt-2",n),children:[i.jsx("pre",{className:"max-h-48 overflow-y-auto text-xs whitespace-pre-wrap",children:o}),a&&!s&&i.jsxs("button",{onClick:()=>r(!0),className:"text-muted-foreground hover:text-foreground mt-1 text-xs underline",children:["Show full output (",(e.length/1024).toFixed(1),"KB)"]})]})}const Srt={running:i.jsx(Xn,{className:"text-muted-foreground size-(--size-icon-xs) animate-spin"}),success:i.jsx(Zt,{className:"text-muted-foreground size-(--size-icon-xs)"}),error:i.jsx(ls,{className:"text-destructive size-(--size-icon-xs)"}),cancelled:i.jsx(ls,{className:"text-muted-foreground size-(--size-icon-xs)"})};function wrt({hook:e}){const t=!!(e.stdout||e.stderr),[n,s]=x.useState(e.status==="error"),r=e.stderr||e.stdout;return i.jsxs("div",{children:[i.jsxs("button",{onClick:()=>t&&s(a=>!a),className:X("flex w-full items-center gap-1.5 py-0.5",!t&&"cursor-default"),"aria-expanded":t?n:void 0,disabled:!t,children:[Srt[e.status],i.jsx("span",{className:X("text-3xs font-mono",e.status==="error"?"text-destructive":"text-muted-foreground"),children:e.hookName}),e.status==="error"&&i.jsx("span",{className:"text-3xs text-destructive",children:"failed"}),e.exitCode!==void 0&&i.jsxs("span",{className:"text-3xs text-muted-foreground ml-auto",children:["exit ",e.exitCode]})]}),i.jsx(He,{initial:!1,children:n&&t&&r&&i.jsx(oe.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:[.4,0,.2,1]},className:"overflow-hidden",children:i.jsx("pre",{className:"text-muted-foreground max-h-32 overflow-y-auto py-1 text-xs whitespace-pre-wrap",children:r})})})]})}function krt({toolCall:e,defaultExpanded:t=!1}){const[n,s]=x.useState(t),r=!!e.progressOutput;x.useEffect(()=>{r&&!n&&s(!0)},[r]);const a=e.hooks&&e.hooks.length>0?i.jsx("div",{className:"border-border/50 space-y-0.5 border-t px-3 py-1",children:e.hooks.map(c=>i.jsx(wrt,{hook:c},c.hookId))}):void 0,o=e.startedAt&&e.completedAt?e.completedAt-e.startedAt:void 0,l=fG(e.toolName);return i.jsxs(gb,{expanded:n,onToggle:()=>s(!n),dimmed:e.status==="complete",extraContent:a,"data-testid":"tool-call-card","data-tool-name":e.toolName,"data-status":e.status,header:i.jsxs(i.Fragment,{children:[Tie(e.status),l&&i.jsx("span",{className:"bg-muted text-muted-foreground text-3xs rounded px-1 py-0.5 font-medium",children:l}),i.jsx("span",{className:"text-3xs flex-1 text-left font-mono",children:o3(e.toolName,e.input)}),o!==void 0&&i.jsx("span",{className:"text-muted-foreground text-3xs tabular-nums",children:c2e(o)})]}),children:[e.status==="running"&&!e.input?i.jsxs("div",{className:"text-muted-foreground flex items-center gap-1.5 py-1 text-xs",children:[i.jsx(Xn,{className:"size-3 animate-spin"}),i.jsx("span",{children:"Preparing..."})]}):e.input!==void 0&&e.input!==""?i.jsx(pG,{toolName:e.toolName,input:e.input,isStreaming:e.status==="running"}):null,e.progressOutput&&!e.result&&i.jsx(vrt,{content:e.progressOutput}),e.result&&i.jsx("div",{className:"mt-2 border-t pt-2",children:i.jsx(yrt,{content:e.result,toolName:e.toolName,input:e.input})})]})}const B$={duration:.15,ease:"easeOut"},$$=120,H$=60,U$=new Set(["Bash","Write","Edit","NotebookEdit"]),V$=new Set(["WebFetch","WebSearch"]);function Crt(e){const t=e.includes("__")?e.split("__").pop():e;return U$.has(t)||U$.has(e)?"high":V$.has(t)||V$.has(e)||e.startsWith("mcp__")?"medium":"low"}function Ert(e){const t=Math.floor(e/60),n=e%60;return t>0?`${t}:${String(n).padStart(2,"0")}`:`${n}s`}function Trt(e){if(e===null)return"";if(e<=0)return"Expired";const t=Math.floor(e/60),n=e%60;return t>0?`${t} minute${t!==1?"s":""} and ${n} second${n!==1?"s":""} remaining`:`${n} second${n!==1?"s":""} remaining`}function Die({sessionId:e,toolCallId:t,toolName:n,input:s,isActive:r=!1,onDecided:a,ref:o,timeoutMs:l,approvalStartedAt:c,approvalRemainingMs:u,approvalTitle:f,approvalDisplayName:h,approvalDescription:m,approvalBlockedPath:g,approvalDecisionReason:b,approvalHasSuggestions:v}){const k=Fe(),w=x.useMemo(()=>Crt(n),[n]),C=fG(n),E=o3(n,s),T=h||E,[_,j]=x.useState(!1),[R,D]=x.useState(null),[I,O]=x.useState(null),[L,B]=x.useState(null),H=x.useRef(!1),[K,U]=x.useState("");x.useEffect(()=>{if(R||!l)return;const F=u!==void 0?Date.now()+u:c?c+l:Date.now()+l;B(Math.max(0,Math.ceil((F-Date.now())/1e3)));const V=setInterval(()=>{const G=Math.max(0,Math.ceil((F-Date.now())/1e3));B(G),G<=0&&clearInterval(V)},1e3);return()=>clearInterval(V)},[l,c,u,R]),x.useEffect(()=>{L===0&&!R&&(H.current=!0,D("denied"),a==null||a())},[L,R,a]),x.useEffect(()=>{L===$$?U("Tool approval required. 2 minutes remaining."):L===H$?U("Urgent: 1 minute to approve or deny."):L===0&&U("Tool approval timed out. Execution denied.")},[L]);const $=x.useMemo(()=>L===null?"normal":L<=0?"expired":L<=H$?"urgent":L<=$$?"warning":"normal",[L]),q=x.useCallback(async()=>{if(!(_||R)){j(!0),O(null);try{await k.approveTool(e,t),D("approved"),a==null||a()}catch(F){F.code==="INTERACTION_ALREADY_RESOLVED"?(D("approved"),a==null||a()):(console.error("Approval failed:",F),O("Approval request failed — try again"))}finally{j(!1)}}},[_,R,k,e,t,a]),J=x.useCallback(async()=>{if(!(_||R)){j(!0),O(null);try{await k.approveTool(e,t,!0),D("approved"),a==null||a()}catch(F){F.code==="INTERACTION_ALREADY_RESOLVED"?(D("approved"),a==null||a()):(console.error("Always Allow failed:",F),O("Always Allow request failed — try again"))}finally{j(!1)}}},[_,R,k,e,t,a]),ne=x.useCallback(async()=>{if(!(_||R)){j(!0),O(null);try{await k.denyTool(e,t),D("denied"),a==null||a()}catch(F){F.code==="INTERACTION_ALREADY_RESOLVED"?(D("denied"),a==null||a()):(console.error("Deny failed:",F),O("Deny request failed — try again"))}finally{j(!1)}}},[_,R,k,e,t,a]);if(x.useImperativeHandle(o,()=>({approve(){q()},alwaysAllow(){J()},deny(){ne()}}),[q,J,ne]),R){const F=R==="approved";return i.jsx(oe.div,{initial:{opacity:0},animate:{opacity:1},transition:B$,children:i.jsx(pS,{"data-testid":"tool-approval-decided","data-decision":R,icon:F?i.jsx(Zt,{className:"text-status-success size-(--size-icon-sm) shrink-0"}):i.jsx(ls,{className:"text-status-error size-(--size-icon-sm) shrink-0"}),label:i.jsx("span",{className:"text-3xs font-mono",children:T}),trailing:i.jsx("span",{className:X("text-2xs rounded-full px-1.5 py-0.5 font-medium",F?"bg-status-success-bg text-status-success-fg":"bg-status-error-bg text-status-error-fg"),children:F?"Approved":"Denied"}),children:R==="denied"&&H.current&&i.jsxs("p",{className:"text-2xs text-muted-foreground mt-1",children:["Auto-denied — approval timed out after ",Math.ceil((l??0)/6e4)," minutes. The agent continued without this tool."]})})})}return i.jsxs(_ie,{isActive:r,isResolved:!!R,className:"my-1","data-testid":"tool-approval",children:[i.jsxs("div",{className:"mb-1 flex items-center gap-2",children:[i.jsx(Ho,{className:X("size-(--size-icon-md)",w==="high"&&"text-status-error",w==="medium"&&"text-status-warning",w==="low"&&"text-muted-foreground")}),i.jsx("span",{className:"font-semibold",children:f||"Tool approval required"})]}),(m||b||g)&&i.jsxs("div",{className:"text-muted-foreground text-2xs mb-2 space-y-0.5",children:[m&&i.jsx("p",{children:m}),b&&!m&&i.jsx("p",{children:b}),g&&i.jsxs("p",{className:"font-mono",children:["Path: ",g]})]}),l&&!R&&i.jsx("div",{role:"progressbar","aria-valuemin":0,"aria-valuemax":Math.ceil(l/1e3),"aria-valuenow":L??0,"aria-valuetext":Trt(L),className:"bg-muted mb-2 h-1 w-full overflow-hidden rounded-full",children:i.jsx("div",{className:X("h-full rounded-full transition-colors duration-500",$==="normal"&&"bg-muted-foreground/30",$==="warning"&&"bg-status-warning",$==="urgent"&&"bg-status-error","motion-safe:animate-drain"),style:{animationDuration:`${l}ms`,animationTimingFunction:"linear",animationFillMode:"forwards"}})}),i.jsx(He,{children:($==="warning"||$==="urgent")&&L!==null&&i.jsx(oe.div,{initial:{opacity:0,y:-4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:B$,className:"mb-2",children:i.jsxs("span",{className:X("text-2xs tabular-nums",$==="warning"&&"text-status-warning",$==="urgent"&&"text-status-error"),children:[Ert(L)," remaining"]})})}),i.jsxs("div",{className:"mb-2 flex items-center gap-1.5",children:[C&&i.jsx("span",{className:"bg-muted text-muted-foreground text-3xs rounded px-1 py-0.5 font-medium",children:C}),i.jsx("span",{className:"font-mono text-xs",children:T})]}),s&&i.jsx("div",{className:"bg-muted mb-3 rounded p-2",children:i.jsx(pG,{toolName:n,input:s})}),I&&i.jsx("p",{className:"text-status-error text-2xs mb-2",children:I}),i.jsxs("div",{className:"flex flex-wrap gap-2",children:[i.jsxs(ve,{size:"sm",onClick:q,disabled:_,className:"transition-opacity duration-150",children:[i.jsx(Zt,{className:"size-(--size-icon-xs)"})," Approve",r&&i.jsx(Br,{className:"ml-1.5",children:"Enter"})]}),v&&i.jsxs(ve,{size:"sm",variant:"outline",onClick:J,disabled:_,className:"transition-opacity duration-150",children:[i.jsx(Qk,{className:"size-(--size-icon-xs)"})," Always Allow",r&&i.jsx(Br,{className:"ml-1.5",children:"Shift+Enter"})]}),i.jsxs(ve,{size:"sm",variant:"outline",onClick:ne,disabled:_,className:"transition-opacity duration-150",children:[i.jsx(ls,{className:"size-(--size-icon-xs)"})," Deny",r&&i.jsx(Br,{className:"ml-1.5",children:"Esc"})]})]}),i.jsx("span",{role:"status","aria-live":"assertive","aria-atomic":"true",className:"sr-only",children:K})]})}function _rt(e,t,n,s,r){const a=n==null?void 0:n[String(t)];if(a){if(e.multiSelect&&a.startsWith("["))try{return JSON.parse(a).join(", ")}catch{return a}return a}const o=s[t];return o?e.multiSelect?o.map(l=>l==="__other__"?r[t]:l).join(", "):o==="__other__"?r[t]:o:null}function Nrt({questions:e,answers:t,selections:n,otherText:s}){const r=i.jsx(Zt,{className:"text-status-success size-(--size-icon-sm) shrink-0"}),a=e.map((o,l)=>({idx:l,header:o.header,value:_rt(o,l,t,n,s)})).filter(o=>o.value!==null);if(a.length===0){const o=e.length===1?"Question answered":`${e.length} questions answered`;return i.jsx(pS,{"data-testid":"question-prompt-submitted",icon:r,label:i.jsx("span",{className:"truncate",children:o})})}return a.length===1?i.jsx(pS,{"data-testid":"question-prompt-submitted",icon:r,label:i.jsx("span",{className:"truncate",children:`${a[0].header}: ${a[0].value}`})}):i.jsx(pS,{"data-testid":"question-prompt-submitted",icon:r,label:i.jsx("span",{className:"text-muted-foreground",children:"Questions answered"}),children:i.jsx("dl",{className:"mt-1 grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 pl-6 text-xs",children:a.map(({idx:o,header:l,value:c})=>i.jsxs(x.Fragment,{children:[i.jsx("dt",{className:"text-muted-foreground",children:l}),i.jsx("dd",{className:"text-foreground break-words",children:c})]},o))})})}const jrt={duration:.25,ease:[.4,0,.2,1]},dj={duration:.15,ease:"easeOut"},Art={enter:e=>({opacity:0,x:e*20}),center:{opacity:1,x:0},exit:e=>({opacity:0,x:e*-20})},Oie=x.forwardRef(function({sessionId:t,toolCallId:n,questions:s,answers:r,isActive:a=!1,focusedOptionIndex:o=-1,onDecided:l},c){const u=Fe(),f=x.useId(),[h,m]=x.useState({}),[g,b]=x.useState({}),[v,k]=x.useState(!!r),[w,C]=x.useState(!1),[E,T]=x.useState(null),[_,j]=x.useState("0"),R=x.useRef(1),D=s[Number(_)]||s[0],I=Number(_),O=D?D.options.length+1:0;function L(F,V){m(G=>({...G,[F]:V}))}function B(F,V,G){m(P=>{const Z=P[F]||[];return G?{...P,[F]:[...Z,V]}:{...P,[F]:Z.filter(Q=>Q!==V)}})}function H(F,V){b(G=>({...G,[F]:V}))}function K(F){var G,P;const V=h[F];if(!V)return!1;if(s[F].multiSelect){const Z=V;return Z.length>0&&(!Z.includes("__other__")||!!((G=g[F])!=null&&G.trim()))}return V!=="__other__"||!!((P=g[F])!=null&&P.trim())}function U(){return s.every((F,V)=>K(V))}const $=x.useCallback(async()=>{if(!U()||w)return;C(!0),T(null);const F={};s.forEach((V,G)=>{var Z;const P=h[G];if(V.multiSelect){const Q=P.map(re=>{var ae;return re==="__other__"?((ae=g[G])==null?void 0:ae.trim())||"":re}).filter(Boolean);F[String(G)]=Q.join(", ")}else F[String(G)]=P==="__other__"?((Z=g[G])==null?void 0:Z.trim())||"":P});try{await u.submitAnswers(t,n,F),k(!0),l==null||l(F)}catch(V){V.code==="INTERACTION_ALREADY_RESOLVED"?(k(!0),l==null||l(F)):T(V instanceof Error?V.message:"Failed to submit answers")}finally{C(!1)}},[h,g,w,u,t,n,s,l]);x.useImperativeHandle(c,()=>({toggleOption(F){if(!D||v||w)return;if(F===D.options.length){D.multiSelect?(h[I]||[]).includes("__other__")?B(I,"__other__",!1):B(I,"__other__",!0):L(I,"__other__");return}const V=D.options[F];V&&(D.multiSelect?(h[I]||[]).includes(V.label)?B(I,V.label,!1):B(I,V.label,!0):L(I,V.label))},navigateOption(F){},navigateQuestion(F){if(s.length<=1)return;const V=Number(_);F==="next"&&V<s.length-1?(R.current=1,j(String(V+1))):F==="prev"&&V>0&&(R.current=-1,j(String(V-1)))},submit(){const F=Number(_);if(F<s.length-1){R.current=1,j(String(F+1));return}$()},getOptionCount(){return O},getActiveTab(){return _}}),[D,I,_,h,v,w,O,$,s.length]);function q(F){const V=Number(_);F==="next"&&V<s.length-1?(R.current=1,j(String(V+1))):F==="prev"&&V>0&&(R.current=-1,j(String(V-1)))}function J(F,V){const G=F.multiSelect?(h[V]||[]).includes("__other__"):h[V]==="__other__",P=`${f}-q-${V}-other`,Z=F.options.length;return i.jsx(tj,{isSelected:G,isFocused:a&&o===Z,"data-selected":G,control:F.multiSelect?i.jsx(zx,{checked:G,id:P,disabled:w,onCheckedChange:Q=>B(V,"__other__",!!Q)}):i.jsx(Xx,{value:"__other__",id:P,disabled:w}),children:i.jsxs("div",{className:"flex-1",children:[i.jsxs("label",{htmlFor:P,className:"flex cursor-pointer items-center",children:[i.jsx("span",{className:"text-sm font-medium",children:"Other"}),Z<9&&i.jsx(Br,{className:"text-2xs text-muted-foreground ml-auto shrink-0",children:Z+1})]}),i.jsx(He,{initial:!1,children:G&&i.jsx(oe.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:jrt,className:"overflow-hidden",children:i.jsx("textarea",{placeholder:"Type your answer...",rows:2,value:g[V]||"",disabled:w,onChange:Q=>H(V,Q.target.value),className:"bg-background border-border focus:ring-ring mt-1 w-full resize-y rounded border px-2 py-1 text-sm focus:ring-1 focus:outline-none",autoFocus:!0})})})]})})}function ne(F,V){return i.jsxs("div",{children:[i.jsx("p",{className:"text-foreground mb-1.5",children:F.question}),F.multiSelect?i.jsxs("div",{role:"group","aria-label":F.question,className:"ml-1 space-y-1",children:[F.options.map((G,P)=>{const Z=(h[V]||[]).includes(G.label),Q=`${f}-q-${V}-opt-${P}`;return i.jsx(tj,{isSelected:Z,isFocused:a&&o===P,"data-selected":Z,control:i.jsx(zx,{checked:Z,id:Q,disabled:w,onCheckedChange:re=>B(V,G.label,!!re)}),children:i.jsxs("label",{htmlFor:Q,className:"flex flex-1 cursor-pointer items-center",children:[i.jsx("span",{className:"text-sm font-medium",children:G.label}),G.description&&i.jsxs("span",{className:"text-muted-foreground ml-1.5 text-xs",children:[" ","— ",G.description]}),P<9&&i.jsx(Br,{className:"text-2xs text-muted-foreground ml-auto shrink-0",children:P+1})]})},P)}),J(F,V)]}):i.jsxs(YD,{value:h[V]??"",onValueChange:G=>L(V,G),"aria-label":F.question,className:"ml-1 gap-1",children:[F.options.map((G,P)=>{const Z=h[V]===G.label,Q=`${f}-q-${V}-opt-${P}`;return i.jsx(tj,{isSelected:Z,isFocused:a&&o===P,"data-selected":Z,control:i.jsx(Xx,{value:G.label,id:Q,disabled:w}),children:i.jsxs("label",{htmlFor:Q,className:"flex flex-1 cursor-pointer items-center",children:[i.jsx("span",{className:"text-sm font-medium",children:G.label}),G.description&&i.jsxs("span",{className:"text-muted-foreground ml-1.5 text-xs",children:[" ","— ",G.description]}),P<9&&i.jsx(Br,{className:"text-2xs text-muted-foreground ml-auto shrink-0",children:P+1})]})},P)}),J(F,V)]})]})}return v?i.jsx(oe.div,{initial:r?!1:{opacity:0},animate:{opacity:1},transition:dj,children:i.jsx(Nrt,{questions:s,answers:r,selections:h,otherText:g})}):i.jsxs(_ie,{isActive:a,isResolved:v,children:[s.length===1?ne(s[0],0):i.jsxs("div",{children:[i.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[i.jsx("span",{className:"text-muted-foreground text-xs",children:s[Number(_)].header??`Question ${Number(_)+1} of ${s.length}`}),i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsxs(ve,{size:"sm",variant:"ghost",onClick:()=>q("prev"),disabled:Number(_)===0,className:"h-7 px-2 text-xs",children:["Back ",a&&i.jsx(Br,{className:"ml-1",children:"←"})]}),Number(_)<s.length-1?i.jsxs(ve,{size:"sm",onClick:()=>q("next"),className:"h-7 px-2 text-xs",children:["Next ",a&&i.jsx(Br,{className:"ml-1",children:"→"})]}):i.jsxs(ve,{size:"sm",onClick:$,disabled:!U()||w,className:"h-7 px-2 text-xs transition-opacity duration-150",children:[i.jsx(Zt,{className:"size-(--size-icon-xs)"}),w?"Submitting...":"Submit",a&&i.jsx(Br,{className:"ml-1",children:"Enter"})]})]})]}),i.jsx(He,{mode:"wait",custom:R.current,children:i.jsx(oe.div,{custom:R.current,variants:Art,initial:"enter",animate:"center",exit:"exit",transition:dj,children:ne(s[Number(_)],Number(_))},_)})]}),i.jsx(He,{children:E&&i.jsx(oe.p,{initial:{opacity:0,y:-4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:dj,className:"mt-2 text-xs text-red-500",children:E})}),s.length===1&&i.jsx(ve,{size:"sm",onClick:$,disabled:!U()||w,className:"mt-2 transition-opacity duration-150",children:w?"Submitting...":i.jsxs(i.Fragment,{children:[i.jsx(Zt,{className:"size-(--size-icon-xs)"})," Submit",a&&i.jsx(Br,{className:"ml-1.5",children:"Enter"})]})})]})});function Rrt(e){if(!e)return[];const t=e.properties??{};return Object.entries(t).map(([n,s])=>({key:n,label:s.description??n,type:s.type??"string",options:s.enum,defaultValue:s.default}))}function Mrt({sessionId:e,interactionId:t,serverName:n,message:s,mode:r="form",url:a,requestedSchema:o,status:l,action:c}){const u=Fe(),[f,h]=x.useState(!1),[m,g]=x.useState(null),[b,v]=x.useState({}),[k,w]=x.useState(!1),C=x.useMemo(()=>Rrt(o),[o]),E=l!=="pending",T=x.useCallback(async(O,L)=>{if(!(f||E)){h(!0),g(null);try{await u.submitElicitation(e,t,O,L)}catch(B){if(B.code!=="INTERACTION_ALREADY_RESOLVED"){g(B instanceof Error?B.message:"Failed to submit"),h(!1);return}}h(!1)}},[u,e,t,f,E]),_=x.useCallback(()=>{const O={};for(const L of C)O[L.key]=b[L.key]??L.defaultValue??"";T("accept",O)},[C,b,T]),j=x.useCallback(()=>{T("accept")},[T]),R=x.useCallback(()=>{T("decline")},[T]),D=x.useCallback((O,L)=>{v(B=>({...B,[O]:L}))},[]),I=x.useCallback(()=>{a&&(window.open(a,"_blank","noopener,noreferrer"),w(!0))},[a]);return E?i.jsxs("div",{className:"text-muted-foreground flex items-center gap-2 py-1 text-xs",children:[i.jsx("span",{className:"font-mono",children:n}),i.jsx("span",{children:"—"}),i.jsx("span",{children:c==="accept"?"Authorized":c==="decline"?"Declined":"Cancelled"})]}):i.jsxs(oe.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{duration:.15},className:X("border-border bg-card my-2 rounded-xl border p-4","shadow-soft"),children:[i.jsxs("div",{className:"text-muted-foreground mb-2 flex items-center gap-2 text-xs",children:[i.jsx("span",{className:"bg-muted inline-flex items-center rounded-md px-2 py-0.5 font-mono text-[10px]",children:n}),i.jsx("span",{children:"requests input"})]}),i.jsx("p",{className:"mb-3 text-sm",children:s}),m&&i.jsx("p",{className:"text-destructive mb-2 text-xs",children:m}),r==="url"&&a&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(ve,{size:"sm",variant:"outline",onClick:I,disabled:f,children:"Open authorization page"}),k&&i.jsx(ve,{size:"sm",onClick:j,disabled:f,children:f?"Submitting…":"Done — I authorized"}),i.jsx(ve,{size:"sm",variant:"ghost",onClick:R,disabled:f,children:"Decline"})]}),r==="form"&&i.jsxs(i.Fragment,{children:[C.length>0?i.jsx("div",{className:"mb-3 space-y-2",children:C.map(O=>i.jsxs("div",{children:[i.jsx("label",{htmlFor:`elicitation-${t}-${O.key}`,className:"text-muted-foreground mb-1 block text-xs font-medium",children:O.label}),O.options?i.jsxs("select",{id:`elicitation-${t}-${O.key}`,className:"border-input bg-background w-full rounded-md border px-3 py-1.5 text-sm",value:b[O.key]??String(O.defaultValue??""),onChange:L=>D(O.key,L.target.value),disabled:f,children:[i.jsx("option",{value:"",children:"Select…"}),O.options.map(L=>i.jsx("option",{value:L,children:L},L))]}):i.jsx("input",{id:`elicitation-${t}-${O.key}`,type:O.type==="number"?"number":"text",className:"border-input bg-background w-full rounded-md border px-3 py-1.5 text-sm",placeholder:String(O.defaultValue??""),value:b[O.key]??"",onChange:L=>D(O.key,L.target.value),disabled:f})]},O.key))}):i.jsx("p",{className:"text-muted-foreground mb-3 text-xs",children:"No additional input required."}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(ve,{size:"sm",onClick:_,disabled:f,children:f?"Submitting…":"Accept"}),i.jsx(ve,{size:"sm",variant:"ghost",onClick:R,disabled:f,children:"Decline"})]})]})]})}function Drt(e){if(e<1e3)return"<1s";const t=Math.floor(e/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60),s=t%60;return`${n}m ${s}s`}function Ort(e){const t=[];return e.toolUses&&t.push(`${e.toolUses} tool ${e.toolUses===1?"call":"calls"}`),e.durationMs&&t.push(Drt(e.durationMs)),t.length>0?t.join(" · "):null}function Irt({part:e}){const[t,n]=x.useState(!1),s=x.useRef(null),r=Ort(e),a=e.subagentText,o=!!(r||e.summary||e.lastToolName||a);return x.useEffect(()=>{const l=s.current;l&&(l.scrollTop=l.scrollHeight)},[a]),i.jsx(gb,{expanded:t,onToggle:()=>o&&n(!t),hideChevron:!o,ariaLabel:`Background task: ${e.description}`,"data-testid":"subagent-block","data-task-id":e.taskId,"data-status":e.status,header:i.jsxs(i.Fragment,{children:[Tie(e.status==="stopped"?"complete":e.status),i.jsx("span",{className:"text-3xs truncate font-mono",children:e.description}),r&&i.jsx("span",{className:"text-3xs text-muted-foreground ml-1 shrink-0",children:r})]}),children:i.jsxs("div",{className:"space-y-1.5",children:[a&&i.jsxs("div",{className:"space-y-1",children:[i.jsx("p",{className:"text-3xs text-muted-foreground/70 tracking-wide uppercase",children:"Subagent output"}),i.jsx("pre",{ref:s,className:"text-foreground/90 bg-muted/50 max-h-64 overflow-y-auto rounded-md p-2 text-xs break-words whitespace-pre-wrap","data-testid":"subagent-text",children:a})]}),e.lastToolName&&e.status==="running"&&i.jsxs("p",{className:"text-3xs text-muted-foreground",children:["Last tool: ",i.jsx("span",{className:"font-mono",children:e.lastToolName})]}),e.summary&&i.jsx("pre",{className:"overflow-x-auto text-xs whitespace-pre-wrap",children:e.summary})]})})}function Prt(e){if(e<1e3)return"<1s";const t=Math.floor(e/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60),s=t%60;return`${n}m ${s}s`}function Lrt({text:e,isStreaming:t,elapsedMs:n}){const[s,r]=x.useState(t),a=x.useRef(t),o=x.useRef(null);x.useEffect(()=>{a.current&&!t&&r(!1),a.current=t},[t]),x.useEffect(()=>{t&&s&&o.current&&(o.current.scrollTop=o.current.scrollHeight)},[e,t,s]);const l=n?`Thought for ${Prt(n)}`:"Thinking...";return i.jsx(gb,{expanded:s,onToggle:()=>r(!s),variant:"thinking",dimmed:!t,disabled:t,ariaLabel:l,"data-testid":"thinking-block","data-streaming":t?"true":void 0,header:i.jsxs(i.Fragment,{children:[i.jsx(MCe,{className:X("text-muted-foreground size-(--size-icon-xs)",t&&"animate-tasks")}),i.jsx("span",{className:X("text-3xs text-muted-foreground font-mono",t&&"animate-tasks"),children:l})]}),children:i.jsx("div",{ref:o,className:"max-h-32 overflow-y-auto",children:i.jsx("pre",{className:"text-muted-foreground text-xs break-words whitespace-pre-wrap",children:e})})})}const Frt={duration:.25,ease:[.4,0,.2,1]},zrt={max_turns:{heading:"Turn limit reached",subtext:"The agent ran for its maximum number of turns.",retryable:!1},execution_error:{heading:"Agent stopped unexpectedly",subtext:"An error occurred during execution.",retryable:!0},budget_exceeded:{heading:"Cost limit reached",subtext:"This session exceeded its budget.",retryable:!1},output_format_error:{heading:"Output format error",subtext:"The agent couldn't produce the required output format.",retryable:!1}};function Iie({message:e,category:t,details:n,onRetry:s,heading:r,subtext:a}){const[o,l]=x.useState(!1),c=t?zrt[t]:null,u=r??(c==null?void 0:c.heading)??"Error",f=a??(c==null?void 0:c.subtext)??e,h=(c==null?void 0:c.retryable)??!!s;return i.jsx("div",{className:X("my-2 rounded-lg border px-4 py-3","border-destructive/30 bg-destructive/5 text-foreground"),children:i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsx(Yr,{className:"text-destructive mt-0.5 size-4 shrink-0"}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("p",{className:"text-sm font-medium",children:u}),i.jsx("p",{className:"text-muted-foreground mt-0.5 text-sm",children:f}),n&&i.jsxs("button",{type:"button",onClick:()=>l(!o),className:"text-muted-foreground hover:text-foreground mt-2 flex items-center gap-1 text-xs","aria-expanded":o,children:[i.jsx(oe.div,{animate:{rotate:o?0:-90},transition:{type:"spring",stiffness:400,damping:30},children:i.jsx(Ps,{className:"size-3"})}),"Details"]}),i.jsx(He,{initial:!1,children:o&&n&&i.jsx(oe.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:Frt,className:"overflow-hidden",children:i.jsx("pre",{className:"bg-muted/50 mt-1 max-h-40 overflow-auto rounded p-2 text-xs whitespace-pre-wrap",children:n})})})]}),h&&s&&i.jsxs(ve,{variant:"outline",size:"sm",onClick:s,className:"shrink-0 gap-1.5",children:[i.jsx(e_e,{className:"size-3"}),"Retry"]})]})})}function Brt({mode:e,memories:t,isStreaming:n}){const[s,r]=x.useState(n),a=x.useRef(n);if(x.useEffect(()=>{a.current&&!n&&r(!1),a.current=n},[n]),t.length===0)return null;const o=t.length,l=n?o<=1?"Consulting memory…":`Consulting ${o} memories…`:o===1?"Recalled 1 memory":`Recalled ${o} memories`,c=e==="synthesize"?$y:W3,u=e==="synthesize"?"sparkles":"bookopen";return i.jsx(gb,{expanded:s,onToggle:()=>r(!s),variant:"memory",dimmed:!n,disabled:n,ariaLabel:l,"data-testid":"memory-recall-block","data-streaming":n?"true":void 0,header:i.jsxs(i.Fragment,{children:[i.jsx(c,{"aria-hidden":"true","data-testid":"memory-recall-header-icon","data-icon":u,className:X("text-muted-foreground size-(--size-icon-xs)",n&&"animate-tasks")}),i.jsx("span",{className:X("text-3xs text-muted-foreground font-mono",n&&"animate-tasks"),children:l})]}),children:i.jsx($rt,{memories:t})})}function $rt({memories:e}){return i.jsx("ul",{className:"flex flex-col gap-1 px-3 py-2",children:e.map(t=>i.jsx(Hrt,{memory:t},t.path))})}function Hrt({memory:e}){const t=e.path.startsWith("<synthesis:"),n=e.scope==="team"?Hy:Zf,s=e.scope==="team"?"team":"personal",r=async()=>{const a=t&&e.content?e.content:e.path;try{await navigator.clipboard.writeText(a),rt.success("Copied to clipboard")}catch{rt.error("Failed to copy")}};if(t&&e.content){const a=e.path.replace(/^<synthesis:/,"synthesis:").replace(/>$/,"");return i.jsx("li",{children:i.jsxs("button",{type:"button",onClick:r,"aria-label":`Copy synthesized ${s} memory content`,"data-scope":e.scope,className:"focus-ring hover:bg-muted/50 flex min-h-[44px] w-full flex-col items-start gap-1 rounded-md px-2 py-1 text-left",children:[i.jsx("span",{className:"text-sm",children:e.content}),i.jsxs("span",{className:"text-3xs text-muted-foreground flex items-center gap-1 font-mono",children:[i.jsx(n,{"aria-hidden":"true",className:"size-(--size-icon-xs)"}),a]})]})})}return i.jsx("li",{children:i.jsxs("button",{type:"button",onClick:r,"aria-label":`Copy ${s} memory path ${e.path}`,"data-scope":e.scope,className:"focus-ring hover:bg-muted/50 flex min-h-[44px] w-full items-center gap-2 rounded-md px-2 py-1 text-left",children:[i.jsx("span",{className:"flex-1 truncate font-mono text-sm",children:u2e(e.path,40)}),i.jsx(n,{"aria-hidden":"true",className:"text-muted-foreground size-(--size-icon-xs)"})]})})}function Urt({toolName:e,reasonType:t,reason:n,message:s}){const r=t==="classifier",a=n||s,o=r?`Blocked by auto-mode classifier: ${a}`:`Blocked: ${a}`;return i.jsxs("div",{"data-testid":"permission-denied-chip","data-reason-type":t,className:X("my-2 flex items-start gap-2 rounded-md border px-3 py-2","text-foreground border-amber-500/30 bg-amber-500/5"),children:[i.jsx(v_e,{"aria-hidden":"true",className:"mt-0.5 size-4 shrink-0 text-amber-600 dark:text-amber-500"}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("p",{className:"text-sm",children:o}),i.jsx("p",{className:"text-muted-foreground mt-0.5 font-mono text-xs",children:e})]})]})}function Pie(e,t,n){const s=x.useRef(e),[r,a]=x.useState(!(t&&s.current==="complete"));return x.useEffect(()=>{if(t&&e==="complete"&&s.current!=="complete"&&!n){const o=setTimeout(()=>a(!1),Yi.TOOL_CALL_AUTO_HIDE_MS);return()=>clearTimeout(o)}},[e,t,n]),!t||n?!0:r}function Vrt({part:e,autoHide:t,expandToolCalls:n}){var a;const s=((a=e.hooks)==null?void 0:a.some(o=>o.status==="error"))??!1,r=Pie(e.status,t,s);return i.jsx(He,{children:r&&i.jsx(oe.div,{exit:{height:0,opacity:0},transition:{duration:.3,ease:[.4,0,.2,1]},className:"overflow-hidden",children:i.jsx(krt,{toolCall:{toolCallId:e.toolCallId,toolName:e.toolName,input:e.input||"",result:e.result,progressOutput:e.progressOutput,status:e.status,hooks:e.hooks,startedAt:e.startedAt,completedAt:e.completedAt},defaultExpanded:n})},e.toolCallId)})}function qrt({part:e,autoHide:t,index:n}){const s=e.isStreaming?"running":"complete",r=Pie(s,t,!1);return i.jsx(He,{children:r&&i.jsx(oe.div,{exit:{height:0,opacity:0},transition:{duration:.3,ease:[.4,0,.2,1]},className:"overflow-hidden",children:i.jsx(Lrt,{text:e.text,isStreaming:e.isStreaming??!1,elapsedMs:e.elapsedMs})},`thinking-${n}`)})}const Grt=4,q$=2;function Krt({children:e}){const[t,n]=x.useState(!1);if(e.length<=Grt||t)return i.jsx(i.Fragment,{children:e});const s=e.length-q$;return i.jsxs(i.Fragment,{children:[e.slice(0,q$),i.jsx(gb,{expanded:!1,onToggle:()=>n(!0),hideChevron:!0,className:"border-l-muted-foreground/15",header:i.jsxs(i.Fragment,{children:[i.jsx(Ws,{className:"text-muted-foreground size-(--size-icon-xs)"}),i.jsxs("span",{className:"text-3xs text-muted-foreground font-mono",children:["and ",s," more steps…"]})]}),children:i.jsx(i.Fragment,{})})]})}function Wrt({message:e}){const{sessionId:t,isStreaming:n,activeToolCallId:s,onToolRef:r,focusedOptionIndex:a,onToolDecided:o,onRetry:l,inputZoneToolCallId:c,textEffect:u}=Mst(),{expandToolCalls:f,autoHideToolCalls:h}=je(),m=e.parts??[],g=x.useCallback(E=>{r==null||r(E)},[r]),b=x.useCallback(E=>{r==null||r(E)},[r]);let v=-1;for(let E=m.length-1;E>=0;E--)if(m[E].type==="text"){v=E;break}function k(E,T){if(E.type==="text")return i.jsx("div",{className:"msg-assistant",children:i.jsx(Hst,{content:E.text,isStreaming:n&&T===v,textEffect:u})},`text-${T}`);if(E.type==="background_task")return i.jsx(Irt,{part:E},E.taskId);if(E.type==="error")return i.jsx(Iie,{message:E.message,category:E.category,details:E.details,onRetry:l},`error-${T}`);if(E.type==="thinking")return i.jsx(qrt,{part:E,autoHide:h,index:T},`thinking-${T}`);if(E.type==="elicitation")return i.jsx(Mrt,{sessionId:t,interactionId:E.interactionId,serverName:E.serverName,message:E.message,mode:E.mode,url:E.url,requestedSchema:E.requestedSchema,status:E.status,action:E.action},`elicitation-${E.interactionId}`);if(E.type==="memory_recall")return i.jsx(Brt,{mode:E.mode,memories:E.memories,isStreaming:E.isStreaming??!1},`memory-recall-${T}`);if(E.type==="permission_denied")return i.jsx(Urt,{toolName:E.toolName,reasonType:E.reasonType,reason:E.reason,message:E.message},`permission-denied-${E.toolCallId}-${T}`);const _=E;if(_.interactiveType==="approval"&&_.status==="pending"){if(_.toolCallId===c)return i.jsx(j$,{type:"approval",toolName:_.toolName,toolInput:_.input},_.toolCallId);const j=_.toolCallId===s;return i.jsx(Die,{ref:j?g:void 0,sessionId:t,toolCallId:_.toolCallId,toolName:_.toolName,input:_.input||"",timeoutMs:_.timeoutMs,approvalStartedAt:_.approvalStartedAt,approvalRemainingMs:_.approvalRemainingMs,approvalTitle:_.approvalTitle,approvalDisplayName:_.approvalDisplayName,approvalDescription:_.approvalDescription,approvalBlockedPath:_.approvalBlockedPath,approvalDecisionReason:_.approvalDecisionReason,approvalHasSuggestions:_.approvalHasSuggestions,isActive:j,onDecided:o?()=>o(_.toolCallId):void 0},_.toolCallId)}if(_.interactiveType==="question"&&_.questions){if(_.toolCallId===c)return i.jsx(j$,{type:"question",toolName:_.toolName,toolInput:_.input},_.toolCallId);const j=_.toolCallId===s;return i.jsx(Oie,{ref:j?b:void 0,sessionId:t,toolCallId:_.toolCallId,questions:_.questions,answers:_.answers??(_.status!=="pending"?{}:void 0),isActive:j,focusedOptionIndex:j?a:-1,onDecided:o?R=>o(_.toolCallId,R):void 0},_.toolCallId)}return i.jsx(Vrt,{part:_,autoHide:h,expandToolCalls:f},_.toolCallId)}const w=[];let C=[];for(let E=0;E<m.length;E++){const T=m[E];T.type==="thinking"||T.type==="tool_call"&&!T.interactiveType?C.push(E):(C.length>0&&(w.push(C.length===1?{type:"single",index:C[0]}:{type:"run",indices:[...C]}),C=[]),w.push({type:"single",index:E}))}return C.length>0&&w.push(C.length===1?{type:"single",index:C[0]}:{type:"run",indices:[...C]}),i.jsx(i.Fragment,{children:w.map(E=>{if(E.type==="single"){const _=m[E.index];return _.type==="thinking"||_.type==="tool_call"&&!_.interactiveType?i.jsx("div",{className:"my-3",children:k(_,E.index)},`spacer-${E.index}`):k(_,E.index)}const T=E.indices.map(_=>k(m[_],_));return i.jsx("div",{className:"my-3",children:i.jsx(Krt,{children:T})},`run-${E.indices[0]}`)})})}function Yrt(e){try{return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}}function Zrt({message:e,grouping:t,sessionId:n,isNew:s=!1,isStreaming:r=!1,activeToolCallId:a=null,onToolRef:o,focusedOptionIndex:l=-1,onToolDecided:c,onRetry:u,inputZoneToolCallId:f=null,textEffect:h}){const m=e.role==="user",{showTimestamps:g}=je(),{position:b,groupIndex:v}=t,k=b==="only"||b==="first",w=Ast({role:m?"user":"assistant",position:b});return i.jsx(Rst,{value:{sessionId:n,isStreaming:r,activeToolCallId:a,onToolRef:o,focusedOptionIndex:l,onToolDecided:c,onRetry:u,inputZoneToolCallId:f,textEffect:h},children:i.jsxs(oe.div,{initial:s?{opacity:0,y:8,x:m?12:0,scale:m?.97:1}:!1,animate:{opacity:1,y:0,x:0,scale:1},transition:{type:"spring",stiffness:320,damping:28},"data-testid":"message-item","data-role":e.role,className:w.root(),children:[k&&v>0&&!m&&i.jsx("div",{className:w.divider()}),e.timestamp&&i.jsx("span",{className:X(w.timestamp(),g?"text-msg-timestamp":"group-hover:text-msg-timestamp text-transparent"),children:Yrt(e.timestamp)}),i.jsx("div",{className:w.content(),children:m?i.jsx(zst,{message:e}):i.jsx(Wrt,{message:e})})]})})}const G$=800,K$=24;function Xrt({scrollRef:e}){const t=x.useRef(null),n=x.useRef(null),s=x.useRef(null),[r,a]=x.useState(!1),o=x.useRef(!1),l=x.useRef(0),c=x.useRef(0),u=x.useCallback(()=>{a(!0),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{o.current||a(!1)},G$)},[]),f=x.useCallback(()=>{const g=e.current,b=t.current,v=n.current;if(!g||!b||!v)return;const{scrollTop:k,scrollHeight:w,clientHeight:C}=g;if(w<=C){b.style.display="none";return}b.style.display="";const E=v.clientHeight,T=C/w,_=Math.max(T*E,K$),j=E-_,D=k/(w-C)*j;b.style.height=`${_}px`,b.style.transform=`translateY(${D}px)`},[e]);x.useEffect(()=>{const g=e.current;if(!g)return;const b=()=>{u(),f()};return g.addEventListener("scroll",b,{passive:!0}),f(),()=>g.removeEventListener("scroll",b)},[e,u,f]);const h=x.useCallback(g=>{if(g.target===t.current)return;const b=e.current,v=n.current;if(!b||!v)return;const k=v.getBoundingClientRect(),w=(g.clientY-k.top)/k.height;b.scrollTop=w*(b.scrollHeight-b.clientHeight)},[e]),m=x.useCallback(g=>{var k;g.preventDefault(),g.stopPropagation(),o.current=!0,l.current=g.clientY,c.current=((k=e.current)==null?void 0:k.scrollTop)??0;const b=w=>{const C=e.current,E=n.current;if(!C||!E)return;const T=w.clientY-l.current,_=E.clientHeight,j=C.clientHeight/C.scrollHeight,R=Math.max(j*_,K$),D=_-R,I=C.scrollHeight-C.clientHeight,O=T/D*I;C.scrollTop=c.current+O},v=()=>{o.current=!1,document.removeEventListener("pointermove",b),document.removeEventListener("pointerup",v),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>a(!1),G$)};document.addEventListener("pointermove",b),document.addEventListener("pointerup",v)},[e]);return i.jsx("div",{ref:n,role:"presentation",onClick:h,className:"pointer-events-auto absolute top-12 right-0 bottom-0 z-10 w-2.5",children:i.jsx("div",{ref:t,onPointerDown:m,className:"bg-border absolute right-0.5 w-1.5 cursor-pointer rounded-full transition-opacity duration-200",style:{opacity:r?1:0}})})}function Qrt(e){let t=0;return e.map((n,s)=>{const r=s>0?e[s-1].role:null,a=s<e.length-1?e[s+1].role:null,o=r!==n.role,l=a!==n.role;o&&s>0&&t++;let c;return o&&l?c="only":o?c="first":l?c="last":c="middle",{position:c,groupIndex:t}})}const Jrt=x.forwardRef(function({messages:t,sessionId:n,isTextStreaming:s,onScrollStateChange:r,activeToolCallId:a,onToolRef:o,focusedOptionIndex:l,onToolDecided:c,onRetry:u,inputZoneToolCallId:f,textEffect:h},m){const[g,b]=x.useState(null),v=x.useMemo(()=>Qrt(t),[t]),{scrollRef:k,contentRef:w,isAtBottom:C,scrollToBottom:E}=bst({resize:"smooth",initial:"instant"});x.useEffect(()=>{g===null&&t.length>0&&b(t.length)},[t.length,g]);const T=pst({count:t.length,getScrollElement:()=>k.current,estimateSize:()=>80,overscan:5,measureElement:_=>(_==null?void 0:_.getBoundingClientRect().height)??80});return x.useEffect(()=>{r==null||r({isAtBottom:C,distanceFromBottom:C?0:200})},[C,r]),x.useEffect(()=>{const _=k.current;if(!_||t.length===0)return;let j=!1;const R=new IntersectionObserver(([D])=>{D.isIntersecting?j&&(j=!1,requestAnimationFrame(()=>{E()})):j=!0},{threshold:.1});return R.observe(_),()=>R.disconnect()},[k,t.length,E]),x.useImperativeHandle(m,()=>({scrollToBottom:E}),[E]),i.jsxs("div",{"data-testid":"message-list",className:"relative h-full",children:[i.jsx("div",{ref:k,className:"chat-scroll-area hide-scrollbar h-full overflow-y-auto px-3 pt-12",style:{overflowAnchor:"none"},children:i.jsx("div",{ref:w,style:{height:T.getTotalSize(),position:"relative",width:"100%"},children:T.getVirtualItems().map(_=>{const j=t[_.index],R=g!==null&&_.index>=g,I=_.index===t.length-1&&j.role==="assistant"&&!!s;return i.jsx("div",{"data-index":_.index,ref:T.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${_.start}px)`},children:i.jsx(Zrt,{message:j,grouping:v[_.index],sessionId:n,isNew:R,isStreaming:I,activeToolCallId:a,onToolRef:o,focusedOptionIndex:l,onToolDecided:c,onRetry:u,inputZoneToolCallId:f,textEffect:h})},_.key)})})}),i.jsx(Xrt,{scrollRef:k})]})});function eat({messages:e,sessionId:t,isLoadingHistory:n,isTextStreaming:s,isAtBottom:r,hasNewMessages:a,scrollToBottom:o,onScrollStateChange:l,activeToolCallId:c,onToolRef:u,focusedOptionIndex:f,onToolDecided:h,onRetry:m,inputZoneToolCallId:g,messageListRef:b}){const v=je(w=>w.dorkbotFirstMessage),k=je(w=>w.setDorkbotFirstMessage);return i.jsxs("div",{className:"relative min-h-0 flex-1",children:[n?i.jsx("div",{className:"flex h-full items-center justify-center",children:i.jsxs("div",{className:"text-muted-foreground flex items-center gap-2 text-sm",children:[i.jsxs("div",{className:"flex gap-1",children:[i.jsx("span",{className:"bg-muted-foreground h-2 w-2 rounded-full",style:{animation:"typing-dot 1.4s ease-in-out infinite",animationDelay:"0s"}}),i.jsx("span",{className:"bg-muted-foreground h-2 w-2 rounded-full",style:{animation:"typing-dot 1.4s ease-in-out infinite",animationDelay:"0.2s"}}),i.jsx("span",{className:"bg-muted-foreground h-2 w-2 rounded-full",style:{animation:"typing-dot 1.4s ease-in-out infinite",animationDelay:"0.4s"}})]}),"Loading conversation..."]})}):e.length===0?i.jsx("div",{className:"flex h-full items-center justify-center",children:v?i.jsxs("div",{className:"flex flex-col items-center gap-4 text-center",children:[i.jsx(oe.div,{layoutId:"dorkbot-first-message",className:"bg-muted/50 w-full max-w-md rounded-lg border p-4","data-testid":"dorkbot-welcome-message",onLayoutAnimationComplete:()=>{k(null)},children:i.jsx("p",{className:"text-muted-foreground text-sm",children:v})}),i.jsx("p",{className:"text-muted-foreground/60 text-sm",children:"Type a message below to begin"})]}):i.jsxs("div",{className:"text-center",children:[i.jsx("p",{className:"text-muted-foreground text-base",children:"Start a conversation"}),i.jsx("p",{className:"text-muted-foreground/60 mt-2 text-sm",children:"Type a message below to begin"})]})}):i.jsx(Jrt,{ref:b,messages:e,sessionId:t,isTextStreaming:s,onScrollStateChange:l,activeToolCallId:c,onToolRef:u,focusedOptionIndex:f,onToolDecided:h,onRetry:m,inputZoneToolCallId:g}),i.jsx(He,{children:a&&!r&&i.jsx(oe.button,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,y:4},transition:{duration:.2},onClick:o,className:"bg-foreground text-background hover:bg-foreground/90 absolute bottom-16 left-1/2 z-10 -translate-x-1/2 cursor-pointer rounded-full px-3 py-1.5 text-xs font-medium shadow-sm transition-colors",role:"status","aria-live":"polite",children:"New messages"})}),i.jsx(He,{children:!r&&e.length>0&&!n&&i.jsx(oe.button,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},transition:{duration:.15},onClick:o,className:"bg-background absolute right-4 bottom-4 rounded-full border p-2 shadow-sm transition-shadow hover:shadow-md","aria-label":"Scroll to bottom",children:i.jsx(qk,{className:"size-(--size-icon-md)"})})})]})}const tat=500;function nat({textareaRef:e,value:t,isStreaming:n,isMobile:s,sessionBusy:r,editingQueueItem:a,isPaletteOpen:o,queueHasItems:l,onSubmit:c,onStop:u,onEscape:f,onClear:h,onArrowUp:m,onArrowDown:g,onCommandSelect:b,onQueue:v,onSaveEdit:k,onCancelEdit:w,onQueueNavigateUp:C,onQueueNavigateDown:E}){const T=x.useRef(0);return x.useCallback(j=>{if(j.key==="Escape"&&n){u==null||u();return}if(j.key==="Escape"&&a){w==null||w();return}if(j.key==="Escape"){const R=Date.now();o?(f==null||f(),T.current=R):t.trim()&&R-T.current<tat?(h==null||h(),T.current=0):(f==null||f(),T.current=R);return}if(!o&&l){if(j.key==="ArrowUp"){const R=e.current,D=!R||R.selectionStart===0;if(!t.trim()||D){j.preventDefault(),C==null||C();return}}if(j.key==="ArrowDown"){const R=e.current,D=!R||R.selectionStart===R.value.length;if(a&&D){j.preventDefault(),E==null||E();return}}}if(o){if(j.key==="ArrowDown"){j.preventDefault(),g==null||g();return}if(j.key==="ArrowUp"){j.preventDefault(),m==null||m();return}if(j.key==="Enter"&&!j.shiftKey||j.key==="Tab"){j.preventDefault(),b==null||b();return}}j.key==="Enter"&&!j.shiftKey&&!s&&(j.preventDefault(),a&&t.trim()?k==null||k():n&&t.trim()?v==null||v():!n&&!r&&t.trim()&&c())},[n,s,t,c,u,f,h,o,m,g,b,a,v,k,w,l,C,E,r,e])}const sat=200,W$=24;function rat(e,t){const n=x.useCallback(()=>{const s=e.current;s&&(s.style.height="auto",s.style.height=`${Math.min(s.scrollHeight,sat)}px`)},[e]);return x.useEffect(()=>{const s=e.current;if(!s||t!=="")return;const r=s.scrollHeight;if(r<=W$)return;s.style.height=`${r}px`,s.style.transition="height 200ms ease",requestAnimationFrame(()=>{s.style.height=`${W$}px`});const a=()=>{s.style.transition="",s.style.height=""};return s.addEventListener("transitionend",a,{once:!0}),()=>s.removeEventListener("transitionend",a)},[e,t]),n}const fj={send:{icon:null,className:"bg-primary text-primary-foreground hover:bg-primary/90",label:"Send message"},stop:{icon:$X,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",label:"Stop generating"},queue:{icon:Ja,className:"bg-muted text-muted-foreground hover:bg-muted/80",label:"Queue message"},update:{icon:Zt,className:"bg-primary text-primary-foreground hover:bg-primary/90",label:"Save edit"}};function aat(e,t,n,s){return s&&e?"update":t&&e?"queue":t?"stop":e&&!n?"send":null}function iat({hasText:e,isStreaming:t,isUploading:n,sessionBusy:s,editingQueueItem:r,queueDepth:a,isMobile:o,onSubmit:l,onStop:c,onQueue:u,onSaveEdit:f}){const h=aat(e,t,n,r),m=o?Gk:iEe,g=h==="send"?l:h==="stop"?c:h==="queue"?u:h==="update"?f:void 0;return i.jsxs(i.Fragment,{children:[t&&e&&i.jsx(oe.button,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{duration:.15},whileHover:{scale:1.1},whileTap:{scale:.9},onClick:c,type:"button",className:"bg-destructive text-destructive-foreground hover:bg-destructive/90 shrink-0 rounded-lg p-1.5 transition-colors max-md:p-2","aria-label":"Stop generating",children:i.jsx($X,{className:"size-(--size-icon-sm)"})}),h&&i.jsxs("div",{className:"relative",children:[i.jsx(oe.button,{animate:{opacity:1,scale:1},transition:{duration:.15},whileHover:s?void 0:{scale:1.1},whileTap:s?void 0:{scale:.9},onClick:g,disabled:h==="send"&&s,className:X("shrink-0 rounded-lg p-1.5 transition-colors max-md:p-2",fj[h].className,h==="send"&&s&&"pointer-events-none opacity-50"),"aria-label":fj[h].label,children:h==="send"?i.jsx(m,{className:"size-(--size-icon-sm)"}):(()=>{const b=fj[h].icon;return i.jsx(b,{className:"size-(--size-icon-sm)"})})()}),a>0&&h==="queue"&&i.jsx("span",{className:"bg-foreground text-background absolute -top-1 -right-1 flex h-4 w-4 items-center justify-center rounded-full text-[10px] font-medium",children:a})]})]})}const oat=x.forwardRef(function({value:t,onChange:n,onSubmit:s,isStreaming:r,isUploading:a=!1,sessionBusy:o=!1,editingQueueItem:l=!1,queueDepth:c=0,onStop:u,onQueue:f,onSaveEdit:h,onCancelEdit:m,onEscape:g,onClear:b,isPaletteOpen:v,onArrowUp:k,onArrowDown:w,onCommandSelect:C,activeDescendantId:E,onCursorChange:T,onAttach:_,placeholder:j="Send a message...",placeholderOverlay:R,onQueueNavigateUp:D,onQueueNavigateDown:I,queueHasItems:O=!1},L){const B=x.useRef(null),H=x.useRef(null),[K,U]=x.useState(!1),$=Zs();x.useImperativeHandle(L,()=>({focus:()=>{var Q;return(Q=B.current)==null?void 0:Q.focus()},focusAt:Q=>{const re=B.current;re&&(re.focus(),re.setSelectionRange(Q,Q))}})),x.useEffect(()=>{var Q;(Q=B.current)==null||Q.focus()},[]);const q=nat({textareaRef:B,value:t,isStreaming:r,isMobile:$,sessionBusy:o,editingQueueItem:l,isPaletteOpen:v,queueHasItems:O,onSubmit:s,onStop:u,onEscape:g,onClear:b,onArrowUp:k,onArrowDown:w,onCommandSelect:C,onQueue:f,onSaveEdit:h,onCancelEdit:m,onQueueNavigateUp:D,onQueueNavigateDown:I}),J=rat(B,t),ne=x.useCallback(()=>U(!0),[]),F=x.useCallback(()=>{U(!1),v&&(g==null||g())},[v,g]),V=x.useCallback(Q=>{n(Q.target.value),T==null||T(Q.target.selectionStart),J()},[n,T,J]),G=x.useCallback(()=>{B.current&&(T==null||T(B.current.selectionStart))},[T]),P=t.trim().length>0,Z=P&&!o;return i.jsxs("div",{className:"flex flex-col gap-1.5",children:[o&&i.jsx("div",{className:"px-1 text-xs text-amber-600 dark:text-amber-500",children:"Session is busy. Please wait..."}),l&&i.jsxs("div",{className:"text-muted-foreground px-0.5 text-xs",children:["Editing message",c>0?" —":""]}),i.jsxs("div",{className:X("border-input bg-background flex items-end gap-1.5 rounded-md border p-1.5 shadow-xs transition-[color,box-shadow]",K&&"border-ring ring-ring/75 ring-[1px]",l&&"border-primary/40",!_&&"pl-3"),children:[_&&i.jsxs(i.Fragment,{children:[i.jsx("input",{ref:H,type:"file",className:"hidden",multiple:!0,onChange:Q=>{const re=Array.from(Q.target.files??[]);re.length>0&&_(re),Q.target.value=""}}),i.jsx("button",{type:"button",onClick:()=>{var Q;return(Q=H.current)==null?void 0:Q.click()},className:"text-muted-foreground hover:text-foreground flex shrink-0 items-center justify-center rounded-md px-1.5 py-1 transition-colors disabled:opacity-50","aria-label":"Attach file",children:i.jsx(ITe,{className:"size-4"})})]}),i.jsxs("div",{className:"relative min-h-[24px] flex-1",children:[!P&&R,i.jsx("textarea",{ref:B,value:t,onChange:V,onKeyDown:q,onFocus:ne,onBlur:F,onSelect:G,role:"combobox","aria-autocomplete":"list","aria-controls":v?E!=null&&E.startsWith("file-")?"file-palette-listbox":"command-palette-listbox":void 0,"aria-expanded":v??!1,"aria-activedescendant":v?E:void 0,"aria-label":j,placeholder:R?"":j,className:"block max-h-[200px] min-h-[24px] w-full resize-none bg-transparent py-0.5 text-sm focus:outline-none",rows:1,disabled:o})]}),i.jsx(oe.button,{animate:{opacity:Z?.5:0,scale:Z?1:.8},transition:{duration:.15},whileHover:Z?{opacity:1}:void 0,onClick:b,disabled:!Z,type:"button",className:X("text-muted-foreground hover:text-foreground shrink-0 rounded-lg p-1 transition-colors",!Z&&"pointer-events-none"),"aria-label":"Clear message",children:i.jsx(ls,{className:"size-(--size-icon-sm)"})}),i.jsx(iat,{hasText:P,isStreaming:r,isUploading:a,sessionBusy:o,editingQueueItem:l,queueDepth:c,isMobile:$,onSubmit:s,onStop:u,onQueue:f,onSaveEdit:h})]})]})});function lat({sessionId:e,pendingApprovals:t,onAllDecided:n}){const s=Fe(),[r,a]=x.useState(!1),o=x.useCallback(async()=>{if(!r){a(!0);try{const c=t.map(u=>u.toolCallId);await s.batchApprove(e,c),n==null||n()}catch(c){console.error("Batch approve failed:",c)}finally{a(!1)}}},[r,s,e,t,n]),l=x.useCallback(async()=>{if(!r){a(!0);try{const c=t.map(u=>u.toolCallId);await s.batchDeny(e,c),n==null||n()}catch(c){console.error("Batch deny failed:",c)}finally{a(!1)}}},[r,s,e,t,n]);return t.length<2?null:i.jsxs("div",{className:"border-border bg-muted/50 mb-1.5 flex items-center justify-between rounded-lg border px-3 py-1.5",children:[i.jsxs("span",{className:"text-muted-foreground text-xs",children:[t.length," tools awaiting approval"]}),i.jsxs("div",{className:"flex gap-1.5",children:[i.jsxs(ve,{size:"xs",variant:"outline",onClick:o,disabled:r,children:[i.jsx(BCe,{className:"size-3"})," Approve All"]}),i.jsxs(ve,{size:"xs",variant:"ghost",onClick:l,disabled:r,children:[i.jsx(Vm,{className:"size-3"})," Deny All"]})]})]})}function cat({sessionId:e,activeInteraction:t,pendingApprovals:n,focusedOptionIndex:s,onToolRef:r,onToolDecided:a}){const o=l=>a(t.toolCallId,l);return i.jsxs(i.Fragment,{children:[i.jsx(lat,{sessionId:e,pendingApprovals:n}),t.interactiveType==="approval"?i.jsx(Die,{ref:r,sessionId:e,toolCallId:t.toolCallId,toolName:t.toolName,input:t.input||"",isActive:!0,onDecided:o,timeoutMs:t.timeoutMs,approvalStartedAt:t.approvalStartedAt,approvalTitle:t.approvalTitle,approvalDisplayName:t.approvalDisplayName,approvalDescription:t.approvalDescription,approvalBlockedPath:t.approvalBlockedPath,approvalDecisionReason:t.approvalDecisionReason,approvalHasSuggestions:t.approvalHasSuggestions}):t.interactiveType==="question"&&t.questions?i.jsx(Oie,{ref:r,sessionId:e,toolCallId:t.toolCallId,questions:t.questions,answers:t.answers,isActive:!0,focusedOptionIndex:s,onDecided:o}):null]})}const Y$=e=>Symbol.iterator in e,Z$=e=>"entries"in e,X$=(e,t)=>{const n=e instanceof Map?e:new Map(e.entries()),s=t instanceof Map?t:new Map(t.entries());if(n.size!==s.size)return!1;for(const[r,a]of n)if(!s.has(r)||!Object.is(a,s.get(r)))return!1;return!0},uat=(e,t)=>{const n=e[Symbol.iterator](),s=t[Symbol.iterator]();let r=n.next(),a=s.next();for(;!r.done&&!a.done;){if(!Object.is(r.value,a.value))return!1;r=n.next(),a=s.next()}return!!r.done&&!!a.done};function dat(e,t){return Object.is(e,t)?!0:typeof e!="object"||e===null||typeof t!="object"||t===null||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:Y$(e)&&Y$(t)?Z$(e)&&Z$(t)?X$(e,t):uat(e,t):X$({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function fat(e){const t=he.useRef(void 0);return n=>{const s=e(n);return dat(t.current,s)?t.current:t.current=s}}function hat(e){const t=e.contextUsage;return!t||t.maxTokens<=0?null:Math.min(100,Math.round(t.totalTokens/t.maxTokens*100))}function pat(e){var n;const t=e.cacheStats;return!t||t.cacheReadTokens===0&&t.cacheCreationTokens===0?null:{cacheReadTokens:t.cacheReadTokens,cacheCreationTokens:t.cacheCreationTokens,contextTokens:(n=e.contextUsage)==null?void 0:n.totalTokens}}function mat(e){return e?{contextPercent:hat(e),costUsd:e.cost,model:e.model,cacheStatus:pat(e)}:{contextPercent:null,costUsd:null,model:null,cacheStatus:null}}function gat({children:e,onSwitchAgent:t,onOpenProfile:n,onNewSession:s}){return i.jsxs(qee,{children:[i.jsx(Gee,{children:e}),i.jsxs(Kee,{className:"w-48",children:[i.jsxs(ux,{onClick:t,children:[i.jsx(vCe,{className:"mr-2 size-4"}),"Switch agent"]}),i.jsx(dR,{}),i.jsxs(ux,{onClick:n,children:[i.jsx(Zf,{className:"mr-2 size-4"}),"Agent profile"]}),i.jsx(dR,{}),i.jsxs(ux,{onClick:s,children:[i.jsx(Es,{className:"mr-2 size-4"}),"New session"]})]})]})}const xat=[{trigger:"/",label:"Commands",icon:tD,ariaLabel:"Insert slash command trigger"},{trigger:"@",label:"Files",icon:Z3,ariaLabel:"Insert file mention trigger"}];function Q$({onChipClick:e,agentName:t,agentColor:n,agentEmoji:s,agentPath:r}){const a=cs(),o=x.useCallback(()=>{r&&(Eu.getState().openHub(r),je.getState().setRightPanelOpen(!0),je.getState().setActiveRightPanelTab("agent-hub"))},[r]),l=x.useCallback(()=>{je.getState().openGlobalPaletteWithSearch("@")},[]),c=x.useCallback(()=>{a({to:"/session",search:{dir:r??void 0,session:crypto.randomUUID()}})},[a,r]),u=t&&n&&s;return i.jsxs(oe.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"mt-1.5 flex items-center justify-center gap-2 sm:justify-start",children:[u&&(r?i.jsx(gat,{onSwitchAgent:l,onOpenProfile:o,onNewSession:c,children:i.jsx(VR,{size:"xs",name:t,color:n,emoji:s,onClick:o})}):i.jsx(VR,{size:"xs",name:t,color:n,emoji:s})),xat.map(f=>i.jsxs("button",{type:"button","aria-label":f.ariaLabel,onClick:()=>e(f.trigger),className:"bg-secondary text-muted-foreground hover:text-foreground hover:bg-muted inline-flex items-center gap-1.5 rounded-md px-2.5 py-1 text-xs transition-colors duration-150",children:[i.jsx(f.icon,{className:"size-3"}),i.jsx("kbd",{className:"font-mono text-[10px] opacity-60",children:f.trigger}),f.label]},f.trigger))]})}function yat({collapsed:e,onToggle:t}){return i.jsx("div",{role:"button",tabIndex:0,"aria-label":e?"Expand input extras":"Collapse input extras",onClick:t,onKeyDown:n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),t())},className:"flex h-6 w-full cursor-pointer items-center justify-center",children:i.jsx("div",{className:"bg-muted-foreground/30 hover:bg-muted-foreground/50 active:bg-muted-foreground/50 h-1 w-9 rounded-full transition-colors"})})}function fo({itemLabel:e,onHide:t,onConfigure:n,children:s}){return i.jsxs(wC,{children:[i.jsx(kC,{className:"inline-flex items-center",children:s}),i.jsxs(CC,{children:[e&&t&&i.jsxs(i.Fragment,{children:[i.jsxs(Ml,{onClick:t,children:["Hide “",e,"”"]}),i.jsx(pw,{})]}),i.jsx(Ml,{onClick:n,children:"Configure status bar..."}),i.jsx(Ml,{onClick:aE,children:"Reset to defaults"})]})]})}function ho(e){var t;return((t=mb.find(n=>n.key===e))==null?void 0:t.label)??null}const J$=80,eH=500;function bat({sessionId:e,sessionStatus:t,isStreaming:n,onChipClick:s,syncConnectionState:r,agentName:a,agentColor:o,agentEmoji:l,agentPath:c}){var Ye;const u=Zs(),f=aQ(e,t,n),{showShortcutChips:h,showStatusBarCwd:m,setShowStatusBarCwd:g,showStatusBarPermission:b,setShowStatusBarPermission:v,showStatusBarModel:k,setShowStatusBarModel:w,showStatusBarCost:C,setShowStatusBarCost:E,showStatusBarContext:T,setShowStatusBarContext:_,showStatusBarCache:j,setShowStatusBarCache:R,showStatusBarUsage:D,setShowStatusBarUsage:I,showStatusBarGit:O,setShowStatusBarGit:L,showStatusBarSound:B,setShowStatusBarSound:H,showStatusBarPolling:K,setShowStatusBarPolling:U,enableNotificationSound:$,setEnableNotificationSound:q,enableMessagePolling:J,setEnableMessagePolling:ne}=je(),F=XNe(e),V=mat(F),G=kn(x.useCallback(Ge=>{var et;return((et=Ge.sessions[e])==null?void 0:et.contextUsage)??null},[e])),P=kn(x.useCallback(Ge=>{var et;return((et=Ge.sessions[e])==null?void 0:et.usageInfo)??null},[e])),Z=kn(fat(Ge=>{var nn;const et=(nn=Ge.sessions[e])==null?void 0:nn.sessionStatus;return!(et!=null&&et.cacheReadTokens)&&!(et!=null&&et.cacheCreationTokens)?null:{cacheReadTokens:et.cacheReadTokens??0,cacheCreationTokens:et.cacheCreationTokens??0,contextTokens:et.contextTokens}})),Q=V.cacheStatus??Z,re=V.contextPercent??f.contextPercent,ae=V.costUsd??f.costUsd,{data:de}=WKe(f.cwd),{data:pe}=SNe(e),{data:Oe}=aD(e||void 0),Ve=((Ye=Oe==null?void 0:Oe.find(Ge=>Ge.value===f.model))==null?void 0:Ye.supportsAutoMode)??!1,$e=BNe(e),Qe=kn(Ge=>Ge.recordAutoConfirmed),[Se,Ze]=x.useState(!1),bt=x.useCallback(Ge=>{if(Ge==="auto"&&!$e){Ze(!0);return}f.updateSession({permissionMode:Ge})},[$e,f]),Me=x.useCallback(()=>{Qe(e),f.updateSession({permissionMode:"auto"}),Ze(!1)},[Qe,e,f]),[Ie,Te]=x.useState(!1),[Je,_t]=x.useState(!1),[St,Gt]=x.useState(()=>u?parseInt(localStorage.getItem(Gn.GESTURE_HINT_COUNT)||"0",10)<3:!1);x.useEffect(()=>{if(!St)return;const Ge=setTimeout(()=>{Gt(!1);const et=parseInt(localStorage.getItem(Gn.GESTURE_HINT_COUNT)||"0",10);localStorage.setItem(Gn.GESTURE_HINT_COUNT,String(et+1))},Yi.GESTURE_HINT_DISMISS_MS);return()=>clearTimeout(Ge)},[St]);const Kt=x.useCallback(()=>{Gt(!1);const Ge=parseInt(localStorage.getItem(Gn.GESTURE_HINT_COUNT)||"0",10);localStorage.setItem(Gn.GESTURE_HINT_COUNT,String(Ge+1))},[]),Ae=(Ge,et)=>{const{offset:nn,velocity:Cn}=et;nn.y>J$||Cn.y>eH?_t(!0):(nn.y<-J$||Cn.y<-eH)&&_t(!1)},ce=i.jsx(eb,{children:i.jsxs(Kn,{children:[i.jsx(mae,{open:Ie,onOpenChange:Te,children:i.jsx(Wn,{asChild:!0,children:i.jsx("button",{type:"button","aria-label":"Configure status bar",className:"text-muted-foreground/50 hover:text-muted-foreground inline-flex shrink-0 items-center transition-colors duration-150",children:i.jsx(k_e,{className:"size-3"})})})}),i.jsx(Yn,{side:"top",children:i.jsx("p",{children:"Configure status bar"})})]})}),Ee=i.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[i.jsxs(wC,{children:[i.jsx(kC,{className:"min-w-0 flex-1",children:i.jsxs(La,{sessionId:e,isStreaming:n,children:[i.jsx(La.Item,{itemKey:"cwd",visible:m&&!!f.cwd,children:i.jsx(fo,{itemLabel:ho("cwd"),onHide:()=>g(!1),onConfigure:()=>Te(!0),children:f.cwd&&i.jsx(KKe,{cwd:f.cwd})})}),i.jsx(La.Item,{itemKey:"git",visible:O,children:i.jsx(fo,{itemLabel:ho("git"),onHide:()=>L(!1),onConfigure:()=>Te(!0),children:i.jsx(ZKe,{data:de})})}),i.jsx(La.Item,{itemKey:"permission",visible:b,children:i.jsx(fo,{itemLabel:ho("permission"),onHide:()=>v(!1),onConfigure:()=>Te(!0),children:i.jsx(nWe,{mode:f.permissionMode,onChangeMode:bt,disabled:!e,sessionId:e||void 0,modelSupportsAutoMode:Ve})})}),i.jsx(La.Item,{itemKey:"model",visible:k,children:i.jsx(fo,{itemLabel:ho("model"),onHide:()=>w(!1),onConfigure:()=>Te(!0),children:i.jsx(hWe,{model:f.model,onChangeModel:Ge=>f.updateSession({model:Ge}),effort:f.effort,onChangeEffort:Ge=>f.updateSession({effort:Ge??void 0}),fastMode:f.fastMode,onChangeFastMode:Ge=>f.updateSession({fastMode:Ge}),disabled:!e,sessionId:e||void 0})})}),i.jsx(La.Item,{itemKey:"cost",visible:C&&ae!==null,children:i.jsx(fo,{itemLabel:ho("cost"),onHide:()=>E(!1),onConfigure:()=>Te(!0),children:ae!==null&&i.jsx(pWe,{costUsd:ae})})}),i.jsx(La.Item,{itemKey:"cache",visible:j&&Q!==null,children:i.jsx(fo,{itemLabel:ho("cache"),onHide:()=>R(!1),onConfigure:()=>Te(!0),children:Q&&i.jsx(mWe,{cacheReadTokens:Q.cacheReadTokens,cacheCreationTokens:Q.cacheCreationTokens,contextTokens:Q.contextTokens})})}),i.jsx(La.Item,{itemKey:"context",visible:T&&re!==null,children:i.jsx(fo,{itemLabel:ho("context"),onHide:()=>_(!1),onConfigure:()=>Te(!0),children:re!==null&&i.jsx(gWe,{percent:re,contextUsage:G})})}),i.jsx(La.Item,{itemKey:"usage",visible:D&&P!==null,children:i.jsx(fo,{itemLabel:ho("usage"),onHide:()=>I(!1),onConfigure:()=>Te(!0),children:P&&i.jsx(yWe,{usageInfo:P})})}),i.jsx(La.Item,{itemKey:"sound",visible:B,children:i.jsx(fo,{itemLabel:ho("sound"),onHide:()=>H(!1),onConfigure:()=>Te(!0),children:i.jsx(bWe,{enabled:$,onToggle:()=>q(!$)})})}),i.jsx(La.Item,{itemKey:"polling",visible:K,children:i.jsx(fo,{itemLabel:ho("polling"),onHide:()=>U(!1),onConfigure:()=>Te(!0),children:i.jsx(vWe,{enabled:J,onToggle:()=>ne(!J)})})}),i.jsx(wWe,{connectionState:r}),i.jsx(La.Item,{itemKey:"subagents",visible:!!pe&&pe.length>0,children:pe&&pe.length>0&&i.jsx(CWe,{subagents:pe})})]})}),i.jsxs(CC,{children:[i.jsx(Ml,{onClick:()=>Te(!0),children:"Configure status bar..."}),i.jsx(Ml,{onClick:aE,children:"Reset to defaults"})]})]}),ce,i.jsx(sWe,{open:Se,onOpenChange:Ze,onConfirm:Me})]});return u?i.jsxs(i.Fragment,{children:[i.jsx(oe.div,{animate:St?{y:[0,8,0]}:void 0,transition:St?{duration:1.2,repeat:2}:void 0,children:i.jsx(yat,{collapsed:Je,onToggle:()=>_t(Ge=>!Ge)})}),i.jsx(He,{children:St&&i.jsx(oe.p,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:Kt,className:"text-muted-foreground cursor-pointer text-center text-xs",children:"Swipe to collapse"})}),i.jsx(He,{initial:!1,children:!Je&&i.jsxs(oe.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{type:"spring",stiffness:300,damping:30},className:"overflow-hidden",drag:"y",dragConstraints:{top:0,bottom:0},dragElastic:.2,onDragEnd:Ae,style:{touchAction:"pan-y"},children:[h&&i.jsx(Q$,{onChipClick:s,agentName:a,agentColor:o,agentEmoji:l,agentPath:c}),Ee]})})]}):i.jsxs(i.Fragment,{children:[i.jsx(He,{children:h&&i.jsx(Q$,{onChipClick:s,agentName:a,agentColor:o,agentEmoji:l,agentPath:c})}),Ee]})}function vat({color:e}){const t=[{bx:"-8px",by:"-10px",delay:"0s"},{bx:"8px",by:"-8px",delay:"0.03s"},{bx:"-6px",by:"6px",delay:"0.06s"},{bx:"10px",by:"4px",delay:"0.09s"},{bx:"0px",by:"-12px",delay:"0.04s"},{bx:"-10px",by:"0px",delay:"0.07s"},{bx:"6px",by:"10px",delay:"0.05s"},{bx:"-4px",by:"-6px",delay:"0.08s"}];return i.jsx("div",{className:"pointer-events-none absolute inset-0",children:t.map((n,s)=>i.jsx("span",{className:"absolute top-1/2 left-1/2 size-[3px] rounded-full",style:{backgroundColor:e,"--bx":n.bx,"--by":n.by,animation:`burst-particle 0.5s ease-out ${n.delay} forwards`}},s))})}function Sat({agent:e,index:t}){const n=x.useMemo(()=>({animationDelay:`${t*.09}s`}),[t]),[s,r]=x.useState("running"),a=x.useRef(e.status);return x.useEffect(()=>{if(a.current==="running"&&(e.status==="complete"||e.status==="error")&&s==="running"){r("celebrating");const o=setTimeout(()=>r("done"),350);return()=>clearTimeout(o)}a.current=e.status},[e.status,s]),s==="done"?i.jsx("div",{className:"relative inline-flex",children:e.status==="error"?i.jsxs("svg",{className:"check-appear h-6 w-[22px]",viewBox:"0 0 22 24",children:[i.jsx("circle",{cx:"11",cy:"12",r:"7",fill:"none",stroke:e.color,strokeWidth:"1.5",opacity:"0.3"}),i.jsx("line",{x1:"8",y1:"9",x2:"14",y2:"15",stroke:e.color,strokeWidth:"2",strokeLinecap:"round"}),i.jsx("line",{x1:"14",y1:"9",x2:"8",y2:"15",stroke:e.color,strokeWidth:"2",strokeLinecap:"round"})]}):i.jsxs("svg",{className:"check-appear h-6 w-[22px]",viewBox:"0 0 22 24",children:[i.jsx("circle",{cx:"11",cy:"12",r:"7",fill:"none",stroke:e.color,strokeWidth:"1.5",opacity:"0.3"}),i.jsx("polyline",{points:"7,12 10,15 15,9",fill:"none",stroke:e.color,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}):i.jsxs("div",{className:"group relative inline-flex",children:[i.jsx("svg",{className:"h-6 w-[22px] shrink-0",style:{"--c":e.color},viewBox:"0 0 22 24","aria-label":e.description,children:i.jsxs("g",{className:"r-all",style:n,children:[i.jsx("circle",{cx:"11",cy:"4.5",r:"2.8",fill:"var(--c)"}),i.jsx("circle",{cx:"12.3",cy:"3.7",r:"0.6",fill:"hsl(0 0% 100% / 0.7)"}),i.jsx("ellipse",{cx:"11",cy:"10.5",rx:"2.5",ry:"3.5",fill:"var(--c)"}),i.jsxs("g",{className:"r-rua",style:n,children:[i.jsx("line",{x1:"12",y1:"9",x2:"14",y2:"11",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"}),i.jsx("g",{className:"r-rfa",style:n,children:i.jsx("line",{x1:"14",y1:"11",x2:"14.5",y2:"13",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"})})]}),i.jsxs("g",{className:"r-lua",style:n,children:[i.jsx("line",{x1:"10",y1:"9",x2:"8",y2:"11",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"}),i.jsx("g",{className:"r-lfa",style:n,children:i.jsx("line",{x1:"8",y1:"11",x2:"7.5",y2:"13",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"})})]}),i.jsxs("g",{className:"r-rt",style:n,children:[i.jsx("line",{x1:"11",y1:"14",x2:"13",y2:"17",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"}),i.jsx("g",{className:"r-rs",style:n,children:i.jsx("line",{x1:"13",y1:"17",x2:"13.5",y2:"21",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"})})]}),i.jsxs("g",{className:"r-lt",style:n,children:[i.jsx("line",{x1:"11",y1:"14",x2:"9",y2:"17",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"}),i.jsx("g",{className:"r-ls",style:n,children:i.jsx("line",{x1:"9",y1:"17",x2:"8.5",y2:"21",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"})})]})]})}),s==="celebrating"&&i.jsx(vat,{color:e.color}),s==="running"&&i.jsxs("div",{className:X("pointer-events-none absolute bottom-[calc(100%+8px)] left-1/2","-translate-x-1/2 translate-y-1 opacity-0 transition-all duration-150","group-hover:translate-y-0 group-hover:opacity-100","border-border bg-popover z-10 rounded-lg border px-3 py-2 whitespace-nowrap","text-foreground text-[0.6875rem] shadow-lg"),children:[i.jsxs("div",{className:"mb-0.5 flex items-center gap-1.5 font-semibold",children:[i.jsx("div",{className:"size-1.5 shrink-0 rounded-full",style:{backgroundColor:e.color}}),e.description]}),i.jsxs("div",{className:"text-muted-foreground font-mono text-[0.625rem]",children:[e.toolUses??0," tool calls · ",Math.round((e.durationMs??0)/1e3),"s"]}),e.lastToolName&&i.jsxs("div",{className:"text-muted-foreground/60 mt-0.5 font-mono text-[0.5625rem]",children:["Last: ",e.lastToolName]}),i.jsx("div",{className:"border-t-border absolute top-full left-1/2 -translate-x-1/2 border-5 border-transparent"})]})]})}function wat({bashTasks:e}){const t=vr(),n=e.filter(r=>r.taskType==="bash"),s=n.length;return s===0?null:i.jsxs("div",{role:"status","aria-live":"polite","aria-label":`${s} bash task${s!==1?"s":""} running`,className:"flex items-center gap-1.5",children:[i.jsx(He,{mode:"popLayout",children:n.map(r=>i.jsxs(oe.div,{initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:{duration:.25},className:"relative flex size-3 items-center justify-center",children:[r.status==="running"&&!t&&i.jsx("span",{className:"task-dot-tasks absolute inset-0 rounded-full opacity-40",style:{backgroundColor:r.color,animation:"task-dot-tasks 2s ease-in-out infinite"}}),i.jsx("span",{className:"relative size-1.5 rounded-full",style:{backgroundColor:r.color}})]},r.taskId))}),i.jsxs("span",{className:"text-muted-foreground text-xs whitespace-nowrap",children:[s," task",s!==1?"s":""]})]})}const kat=3e3;function Cat({taskType:e,onConfirm:t}){const[n,s]=x.useState(!1),r=x.useRef(null);x.useEffect(()=>()=>{r.current&&clearTimeout(r.current)},[]),x.useEffect(()=>{if(n)return r.current=setTimeout(()=>{s(!1)},kat),()=>{r.current&&clearTimeout(r.current)}},[n]);const a=x.useCallback(()=>{if(e==="bash"){t();return}n?(r.current&&clearTimeout(r.current),s(!1),t()):s(!0)},[e,n,t]),o=x.useCallback(l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),a())},[a]);return i.jsx("button",{onClick:a,onKeyDown:o,className:X("flex shrink-0 items-center justify-center rounded transition-all duration-150","focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-1",n?"bg-destructive/20 text-destructive hover:bg-destructive/30 px-1.5 py-0.5 text-[0.625rem] font-medium":"text-muted-foreground/40 hover:text-destructive size-4"),"aria-label":n?"Confirm stop task":"Stop task",tabIndex:0,children:n?"Stop?":i.jsx(ls,{className:"size-3"})})}function Eat({task:e,onStop:t}){const n=e.taskType==="agent"?e.description??"Background agent":e.command??"Background task",s=e.durationMs?Math.round(e.durationMs/1e3):0,r=e.status==="running";return i.jsxs("div",{className:X("flex items-center gap-2 rounded-md px-2 py-1 text-xs",r?"bg-muted":"bg-muted/50 opacity-60"),children:[i.jsx("span",{className:"size-2 shrink-0 rounded-full",style:{backgroundColor:e.color}}),i.jsx("span",{className:"text-muted-foreground/60 shrink-0 text-[0.625rem] tracking-wider uppercase",children:e.taskType}),i.jsx("span",{className:"text-foreground min-w-0 flex-1 truncate",children:n}),e.taskType==="agent"&&e.toolUses!==void 0&&e.toolUses>0&&i.jsxs("span",{className:"text-muted-foreground/60 shrink-0 font-mono text-[0.625rem]",children:[e.toolUses," tools"]}),s>0&&i.jsxs("span",{className:"text-muted-foreground/60 shrink-0 font-mono text-[0.625rem]",children:[s,"s"]}),r&&i.jsx(Cat,{taskType:e.taskType,onConfirm:t})]})}function Tat({tasks:e,onStopTask:t}){return i.jsx(oe.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.25,ease:[.16,1,.3,1]},className:"border-border overflow-hidden border-t px-2 py-1.5",children:i.jsx("div",{className:"flex flex-col gap-1",children:e.map(n=>i.jsx(Eat,{task:n,onStop:()=>t(n.taskId)},n.taskId))})})}const wM=4,Lie=[.16,1,.3,1],_at={width:{duration:.4,ease:Lie},opacity:{duration:.25}};function Nat({tasks:e,onStopTask:t}){const[n,s]=x.useState(!1),r=vr(),a=e.filter(g=>g.taskType==="agent"),o=e.filter(g=>g.taskType==="bash"),l=e.length,c=a.slice(0,wM),u=a.length-wM,f=a.reduce((g,b)=>g+(b.toolUses??0),0),h=Math.max(0,...e.map(g=>Math.round((g.durationMs??0)/1e3))),m=r?{duration:0}:{duration:.35,ease:Lie};return i.jsx(He,{children:l>0&&i.jsxs(oe.div,{role:"status","aria-live":"polite","aria-label":`${l} background task${l!==1?"s":""} running`,initial:{opacity:0,y:6,maxHeight:0},animate:{opacity:1,y:0,maxHeight:n?400:44},exit:{opacity:0,maxHeight:0},transition:m,className:"border-border bg-card overflow-hidden rounded-lg border",children:[i.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5",children:[a.length>0&&i.jsx(jat,{visibleAgents:c,overflowAgentCount:u,allAgentTasks:a}),a.length>0&&o.length>0&&i.jsx("div",{className:"bg-border h-4 w-px shrink-0"}),o.length>0&&i.jsx(wat,{bashTasks:o}),i.jsxs("span",{className:"text-muted-foreground text-xs whitespace-nowrap",children:[i.jsx("strong",{className:"text-foreground font-semibold",children:l})," task",l!==1?"s":""," running"]}),i.jsxs("span",{className:"text-muted-foreground/60 ml-auto font-mono text-[0.6875rem] whitespace-nowrap",children:[f>0&&i.jsxs(i.Fragment,{children:[f," tools · "]}),h,"s"]}),i.jsxs("button",{type:"button",onClick:()=>s(g=>!g),className:"text-muted-foreground hover:text-foreground ml-1 flex shrink-0 items-center gap-1 transition-colors duration-150","aria-label":n?"Collapse task details":"Expand task details","aria-expanded":n,children:[i.jsx("span",{className:"text-[0.625rem] tabular-nums",children:l}),i.jsx(Ps,{className:X("size-3.5 transition-transform duration-200",n&&"rotate-180")})]})]}),i.jsx(He,{children:n&&i.jsx(Tat,{tasks:e,onStopTask:t})})]},"background-task-bar")})}function jat({visibleAgents:e,overflowAgentCount:t,allAgentTasks:n}){return i.jsxs("div",{className:"flex items-center gap-0",children:[i.jsx(He,{mode:"popLayout",children:e.map((s,r)=>i.jsx(oe.div,{initial:{width:0,opacity:0},animate:{width:22,opacity:1},exit:{width:0,opacity:0},transition:_at,className:"shrink-0",children:i.jsx(Sat,{agent:{taskId:s.taskId,description:s.description??"",status:s.status==="running"?"running":s.status==="complete"?"complete":"error",color:s.color,toolUses:s.toolUses,lastToolName:s.lastToolName,durationMs:s.durationMs,summary:s.summary},index:r})},s.taskId))}),t>0&&i.jsx(Aat,{count:t,overflowTasks:n.slice(wM)})]})}function Aat({count:e,overflowTasks:t}){return i.jsxs("div",{className:"group relative",children:[i.jsxs("div",{className:"text-muted-foreground bg-muted flex size-6 shrink-0 items-center justify-center rounded-full text-[0.625rem] font-semibold","aria-label":`${e} more agents running`,children:["+",e]}),i.jsxs("div",{className:X("pointer-events-none absolute bottom-[calc(100%+8px)] left-1/2","-translate-x-1/2 translate-y-1 opacity-0 transition-all duration-150","group-hover:translate-y-0 group-hover:opacity-100","border-border bg-popover z-10 rounded-lg border px-3 py-2 whitespace-nowrap","text-foreground text-[0.6875rem] shadow-lg"),children:[t.map(n=>i.jsxs("div",{className:"flex items-center gap-1.5 py-0.5",children:[i.jsx("div",{className:"size-1.5 shrink-0 rounded-full",style:{backgroundColor:n.color}}),i.jsx("span",{className:"text-[0.625rem]",children:n.description})]},n.taskId)),i.jsx("div",{className:"border-t-border absolute top-full left-1/2 -translate-x-1/2 border-5 border-transparent"})]})]})}const tH=["hsl(210 80% 60%)","hsl(150 60% 50%)","hsl(270 60% 65%)","hsl(36 90% 55%)","hsl(340 75% 60%)"],nH=5e3,Rat=1e3,Mat=1500;function Dat(e){const t=x.useRef(new Map),n=x.useRef(0),s=x.useRef(new Map),r=x.useRef(new Set),[,a]=x.useState(0),o=x.useMemo(()=>{const c=new Map;for(const u of e)for(const f of u.parts)f.type==="background_task"&&c.set(f.taskId,f);return c},[e]);x.useEffect(()=>{if(!Array.from(o.values()).some(f=>f.taskType==="bash"&&f.status==="running"&&Date.now()-f.startedAt<nH))return;const u=setInterval(()=>{a(f=>f+1)},Rat);return()=>clearInterval(u)},[o]);const l=x.useRef(new Set);for(const[c,u]of o){const f=s.current.get(c),h=u.status==="complete"||u.status==="error"||u.status==="stopped";f==="running"&&h&&!r.current.has(c)&&r.current.add(c),s.current.set(c,u.status)}return x.useEffect(()=>{for(const c of r.current)l.current.has(c)||(l.current.add(c),setTimeout(()=>{r.current.delete(c),l.current.delete(c),a(u=>u+1)},Mat))},[o]),x.useMemo(()=>{const c=Date.now(),u=[];for(const[f,h]of o){const m=h.status==="running",g=r.current.has(f);!m&&!g||h.taskType==="bash"&&m&&c-h.startedAt<nH||(t.current.has(f)||(t.current.set(f,tH[n.current%tH.length]),n.current+=1),u.push({taskId:h.taskId,taskType:h.taskType,status:h.status,color:t.current.get(f),startedAt:h.startedAt,description:h.description,toolUses:h.toolUses,lastToolName:h.lastToolName,durationMs:h.durationMs,summary:h.summary,command:h.command}))}return u},[o])}function Oat({status:e,sessionBusy:t,sessionId:n,selectedCwd:s,onFlush:r}){const a=eje(n??""),[o,l]=x.useState(null),c=x.useRef(r);c.current=r;const u=x.useRef(a);u.current=a;const f=x.useRef(o);f.current=o;const h=x.useRef("idle"),m=x.useRef(null);x.useEffect(()=>{const T=n===null?null:`${n}\0${s??""}`;if(m.current!==T&&(m.current=T,h.current="idle",l(null)),h.current==="streaming"&&e==="idle"&&n){const _=u.current,j=f.current;if(_.length>0&&!t){const R=j===0?_.length>1?1:null:0;if(R!==null){const D=_[R],I=`[Note: This message was composed while the agent was responding to the previous message]
|
|
1075
|
+
`+n(r.slice(a+1))}return F0.exports=e,F0.exports.escapeCarriageReturn=e,F0.exports.escapeCarriageReturnSafe=s,F0.exports}var rj,M$;function art(){return M$||(M$=1,rj=/[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/),rj}var aj,D$;function irt(){return D$||(D$=1,aj=/[\0-\x1F\x7F-\x9F]/),aj}var ij,O$;function ort(){return O$||(O$=1,ij=/[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/),ij}var oj,I$;function lrt(){return I$||(I$=1,oj=/[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4E\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDF55-\uDF59]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDF3C-\uDF3E]|\uD806[\uDC3B\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDE97-\uDE9A]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/),oj}var lj,P$;function crt(){return P$||(P$=1,lj=function(e){var t={};t.src_Any=art().source,t.src_Cc=irt().source,t.src_Z=ort().source,t.src_P=lrt().source,t.src_ZPCc=[t.src_Z,t.src_P,t.src_Cc].join("|"),t.src_ZCc=[t.src_Z,t.src_Cc].join("|");var n="[><|]";return t.src_pseudo_letter="(?:(?!"+n+"|"+t.src_ZPCc+")"+t.src_Any+")",t.src_ip4="(?:(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)",t.src_auth="(?:(?:(?!"+t.src_ZCc+"|[@/\\[\\]()]).)+@)?",t.src_port="(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?",t.src_host_terminator="(?=$|"+n+"|"+t.src_ZPCc+")(?!-|_|:\\d|\\.-|\\.(?!$|"+t.src_ZPCc+"))",t.src_path="(?:[/?#](?:(?!"+t.src_ZCc+"|"+n+`|[()[\\]{}.,"'?!\\-;]).|\\[(?:(?!`+t.src_ZCc+"|\\]).)*\\]|\\((?:(?!"+t.src_ZCc+"|[)]).)*\\)|\\{(?:(?!"+t.src_ZCc+'|[}]).)*\\}|\\"(?:(?!'+t.src_ZCc+`|["]).)+\\"|\\'(?:(?!`+t.src_ZCc+"|[']).)+\\'|\\'(?="+t.src_pseudo_letter+"|[-]).|\\.{2,}[a-zA-Z0-9%/&]|\\.(?!"+t.src_ZCc+"|[.]).|"+(e&&e["---"]?"\\-(?!--(?:[^-]|$))(?:-*)|":"\\-+|")+",(?!"+t.src_ZCc+").|;(?!"+t.src_ZCc+").|\\!+(?!"+t.src_ZCc+"|[!]).|\\?(?!"+t.src_ZCc+"|[?]).)+|\\/)?",t.src_email_name='[\\-;:&=\\+\\$,\\.a-zA-Z0-9_][\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]*',t.src_xn="xn--[a-z0-9\\-]{1,59}",t.src_domain_root="(?:"+t.src_xn+"|"+t.src_pseudo_letter+"{1,63})",t.src_domain="(?:"+t.src_xn+"|(?:"+t.src_pseudo_letter+")|(?:"+t.src_pseudo_letter+"(?:-|"+t.src_pseudo_letter+"){0,61}"+t.src_pseudo_letter+"))",t.src_host="(?:(?:(?:(?:"+t.src_domain+")\\.)*"+t.src_domain+"))",t.tpl_host_fuzzy="(?:"+t.src_ip4+"|(?:(?:(?:"+t.src_domain+")\\.)+(?:%TLDS%)))",t.tpl_host_no_ip_fuzzy="(?:(?:(?:"+t.src_domain+")\\.)+(?:%TLDS%))",t.src_host_strict=t.src_host+t.src_host_terminator,t.tpl_host_fuzzy_strict=t.tpl_host_fuzzy+t.src_host_terminator,t.src_host_port_strict=t.src_host+t.src_port+t.src_host_terminator,t.tpl_host_port_fuzzy_strict=t.tpl_host_fuzzy+t.src_port+t.src_host_terminator,t.tpl_host_port_no_ip_fuzzy_strict=t.tpl_host_no_ip_fuzzy+t.src_port+t.src_host_terminator,t.tpl_host_fuzzy_test="localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:"+t.src_ZPCc+"|>|$))",t.tpl_email_fuzzy="(^|"+n+'|"|\\(|'+t.src_ZCc+")("+t.src_email_name+"@"+t.tpl_host_fuzzy_strict+")",t.tpl_link_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+t.src_ZPCc+"))((?![$+<=>^`||])"+t.tpl_host_port_fuzzy_strict+t.src_path+")",t.tpl_link_no_ip_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+t.src_ZPCc+"))((?![$+<=>^`||])"+t.tpl_host_port_no_ip_fuzzy_strict+t.src_path+")",t}),lj}var cj,L$;function urt(){if(L$)return cj;L$=1;function e(E){var T=Array.prototype.slice.call(arguments,1);return T.forEach(function(_){_&&Object.keys(_).forEach(function(j){E[j]=_[j]})}),E}function t(E){return Object.prototype.toString.call(E)}function n(E){return t(E)==="[object String]"}function s(E){return t(E)==="[object Object]"}function r(E){return t(E)==="[object RegExp]"}function a(E){return t(E)==="[object Function]"}function o(E){return E.replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}var l={fuzzyLink:!0,fuzzyEmail:!0,fuzzyIP:!1};function c(E){return Object.keys(E||{}).reduce(function(T,_){return T||l.hasOwnProperty(_)},!1)}var u={"http:":{validate:function(E,T,_){var j=E.slice(T);return _.re.http||(_.re.http=new RegExp("^\\/\\/"+_.re.src_auth+_.re.src_host_port_strict+_.re.src_path,"i")),_.re.http.test(j)?j.match(_.re.http)[0].length:0}},"https:":"http:","ftp:":"http:","//":{validate:function(E,T,_){var j=E.slice(T);return _.re.no_http||(_.re.no_http=new RegExp("^"+_.re.src_auth+"(?:localhost|(?:(?:"+_.re.src_domain+")\\.)+"+_.re.src_domain_root+")"+_.re.src_port+_.re.src_host_terminator+_.re.src_path,"i")),_.re.no_http.test(j)?T>=3&&E[T-3]===":"||T>=3&&E[T-3]==="/"?0:j.match(_.re.no_http)[0].length:0}},"mailto:":{validate:function(E,T,_){var j=E.slice(T);return _.re.mailto||(_.re.mailto=new RegExp("^"+_.re.src_email_name+"@"+_.re.src_host_strict,"i")),_.re.mailto.test(j)?j.match(_.re.mailto)[0].length:0}}},f="a[cdefgilmnoqrstuwxz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvwxyz]|d[ejkmoz]|e[cegrstu]|f[ijkmor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdeghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eosuw]|s[abcdeghijklmnortuvxyz]|t[cdfghjklmnortvwz]|u[agksyz]|v[aceginu]|w[fs]|y[et]|z[amw]",h="biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф".split("|");function m(E){E.__index__=-1,E.__text_cache__=""}function g(E){return function(T,_){var j=T.slice(_);return E.test(j)?j.match(E)[0].length:0}}function b(){return function(E,T){T.normalize(E)}}function v(E){var T=E.re=crt()(E.__opts__),_=E.__tlds__.slice();E.onCompile(),E.__tlds_replaced__||_.push(f),_.push(T.src_xn),T.src_tlds=_.join("|");function j(O){return O.replace("%TLDS%",T.src_tlds)}T.email_fuzzy=RegExp(j(T.tpl_email_fuzzy),"i"),T.link_fuzzy=RegExp(j(T.tpl_link_fuzzy),"i"),T.link_no_ip_fuzzy=RegExp(j(T.tpl_link_no_ip_fuzzy),"i"),T.host_fuzzy_test=RegExp(j(T.tpl_host_fuzzy_test),"i");var R=[];E.__compiled__={};function D(O,L){throw new Error('(LinkifyIt) Invalid schema "'+O+'": '+L)}Object.keys(E.__schemas__).forEach(function(O){var L=E.__schemas__[O];if(L!==null){var B={validate:null,link:null};if(E.__compiled__[O]=B,s(L)){r(L.validate)?B.validate=g(L.validate):a(L.validate)?B.validate=L.validate:D(O,L),a(L.normalize)?B.normalize=L.normalize:L.normalize?D(O,L):B.normalize=b();return}if(n(L)){R.push(O);return}D(O,L)}}),R.forEach(function(O){E.__compiled__[E.__schemas__[O]]&&(E.__compiled__[O].validate=E.__compiled__[E.__schemas__[O]].validate,E.__compiled__[O].normalize=E.__compiled__[E.__schemas__[O]].normalize)}),E.__compiled__[""]={validate:null,normalize:b()};var I=Object.keys(E.__compiled__).filter(function(O){return O.length>0&&E.__compiled__[O]}).map(o).join("|");E.re.schema_test=RegExp("(^|(?!_)(?:[><|]|"+T.src_ZPCc+"))("+I+")","i"),E.re.schema_search=RegExp("(^|(?!_)(?:[><|]|"+T.src_ZPCc+"))("+I+")","ig"),E.re.pretest=RegExp("("+E.re.schema_test.source+")|("+E.re.host_fuzzy_test.source+")|@","i"),m(E)}function k(E,T){var _=E.__index__,j=E.__last_index__,R=E.__text_cache__.slice(_,j);this.schema=E.__schema__.toLowerCase(),this.index=_+T,this.lastIndex=j+T,this.raw=R,this.text=R,this.url=R}function w(E,T){var _=new k(E,T);return E.__compiled__[_.schema].normalize(_,E),_}function C(E,T){if(!(this instanceof C))return new C(E,T);T||c(E)&&(T=E,E={}),this.__opts__=e({},l,T),this.__index__=-1,this.__last_index__=-1,this.__schema__="",this.__text_cache__="",this.__schemas__=e({},u,E),this.__compiled__={},this.__tlds__=h,this.__tlds_replaced__=!1,this.re={},v(this)}return C.prototype.add=function(T,_){return this.__schemas__[T]=_,v(this),this},C.prototype.set=function(T){return this.__opts__=e(this.__opts__,T),this},C.prototype.test=function(T){if(this.__text_cache__=T,this.__index__=-1,!T.length)return!1;var _,j,R,D,I,O,L,B,H;if(this.re.schema_test.test(T)){for(L=this.re.schema_search,L.lastIndex=0;(_=L.exec(T))!==null;)if(D=this.testSchemaAt(T,_[2],L.lastIndex),D){this.__schema__=_[2],this.__index__=_.index+_[1].length,this.__last_index__=_.index+_[0].length+D;break}}return this.__opts__.fuzzyLink&&this.__compiled__["http:"]&&(B=T.search(this.re.host_fuzzy_test),B>=0&&(this.__index__<0||B<this.__index__)&&(j=T.match(this.__opts__.fuzzyIP?this.re.link_fuzzy:this.re.link_no_ip_fuzzy))!==null&&(I=j.index+j[1].length,(this.__index__<0||I<this.__index__)&&(this.__schema__="",this.__index__=I,this.__last_index__=j.index+j[0].length))),this.__opts__.fuzzyEmail&&this.__compiled__["mailto:"]&&(H=T.indexOf("@"),H>=0&&(R=T.match(this.re.email_fuzzy))!==null&&(I=R.index+R[1].length,O=R.index+R[0].length,(this.__index__<0||I<this.__index__||I===this.__index__&&O>this.__last_index__)&&(this.__schema__="mailto:",this.__index__=I,this.__last_index__=O))),this.__index__>=0},C.prototype.pretest=function(T){return this.re.pretest.test(T)},C.prototype.testSchemaAt=function(T,_,j){return this.__compiled__[_.toLowerCase()]?this.__compiled__[_.toLowerCase()].validate(T,j,this):0},C.prototype.match=function(T){var _=0,j=[];this.__index__>=0&&this.__text_cache__===T&&(j.push(w(this,_)),_=this.__last_index__);for(var R=_?T.slice(_):T;this.test(R);)j.push(w(this,_)),R=R.slice(this.__last_index__),_+=this.__last_index__;return j.length?j:null},C.prototype.tlds=function(T,_){return T=Array.isArray(T)?T:[T],_?(this.__tlds__=this.__tlds__.concat(T).sort().filter(function(j,R,D){return j!==D[R-1]}).reverse(),v(this),this):(this.__tlds__=T.slice(),this.__tlds_replaced__=!0,v(this),this)},C.prototype.normalize=function(T){T.schema||(T.url="http://"+T.url),T.schema==="mailto:"&&!/^mailto:/i.test(T.url)&&(T.url="mailto:"+T.url)},C.prototype.onCompile=function(){},cj=C,cj}var F$;function drt(){if(F$)return hi;F$=1;var e=hi&&hi.__createBinding||(Object.create?(function(k,w,C,E){E===void 0&&(E=C);var T=Object.getOwnPropertyDescriptor(w,C);(!T||("get"in T?!w.__esModule:T.writable||T.configurable))&&(T={enumerable:!0,get:function(){return w[C]}}),Object.defineProperty(k,E,T)}):(function(k,w,C,E){E===void 0&&(E=C),k[E]=w[C]})),t=hi&&hi.__setModuleDefault||(Object.create?(function(k,w){Object.defineProperty(k,"default",{enumerable:!0,value:w})}):function(k,w){k.default=w}),n=hi&&hi.__importStar||(function(){var k=function(w){return k=Object.getOwnPropertyNames||function(C){var E=[];for(var T in C)Object.prototype.hasOwnProperty.call(C,T)&&(E[E.length]=T);return E},k(w)};return function(w){if(w&&w.__esModule)return w;var C={};if(w!=null)for(var E=k(w),T=0;T<E.length;T++)E[T]!=="default"&&e(C,w,E[T]);return t(C,w),C}})(),s=hi&&hi.__importDefault||function(k){return k&&k.__esModule?k:{default:k}};Object.defineProperty(hi,"__esModule",{value:!0}),hi.default=b;const r=s(srt()),a=rrt(),o=s(urt()),l=n(_u());function c(k,w=!1){return k=(0,a.escapeCarriageReturn)(v(k)),r.default.ansiToJson(k,{json:!0,remove_empty:!0,use_classes:w})}function u(k){let w="";return k.bg&&(w+=`${k.bg}-bg `),k.fg&&(w+=`${k.fg}-fg `),k.decoration&&(w+=`ansi-${k.decoration} `),w===""?null:(w=w.substring(0,w.length-1),w)}function f(k){const w={};switch(k.bg&&(w.backgroundColor=`rgb(${k.bg})`),k.fg&&(w.color=`rgb(${k.fg})`),k.decoration){case"bold":w.fontWeight="bold";break;case"dim":w.opacity="0.5";break;case"italic":w.fontStyle="italic";break;case"hidden":w.visibility="hidden";break;case"strikethrough":w.textDecoration="line-through";break;case"underline":w.textDecoration="underline";break;case"blink":w.textDecoration="blink";break}return w}function h(k,w,C,E){const T=w?null:f(C),_=w?u(C):null;return k?k==="fuzzy"?g(C,E,T,_):m(C,E,T,_):l.createElement("span",{style:T,key:E,className:_},C.content)}function m(k,w,C,E){const T=[],_=/(\s|^)(https?:\/\/(?:www\.|(?!www))[^\s.]+\.[^\s]{2,}|www\.[^\s]+\.[^\s]{2,})/g;let j=0,R;for(;(R=_.exec(k.content))!==null;){const[,D,I]=R,O=R.index+D.length;O>j&&T.push(k.content.substring(j,O));const L=I.startsWith("www.")?`http://${I}`:I;T.push(l.createElement("a",{key:j,href:L,target:"_blank"},`${I}`)),j=_.lastIndex}return j<k.content.length&&T.push(k.content.substring(j)),l.createElement("span",{style:C,key:w,className:E},T)}function g(k,w,C,E){var T;const _=(0,o.default)({fuzzyEmail:!1}).tlds(["io"],!0);if(!_.pretest(k.content))return l.createElement("span",{style:C,key:w,className:E},k.content);const j=_.match(k.content);if(!j)return l.createElement("span",{style:C,key:w,className:E},k.content);const R=[k.content.substring(0,(T=j[0])===null||T===void 0?void 0:T.index)];return j.forEach((D,I)=>{var O;R.push(l.createElement("a",{href:D.url,target:"_blank",key:I},k.content.substring(D.index,D.lastIndex))),j[I+1]&&R.push(k.content.substring(j[I].lastIndex,(O=j[I+1])===null||O===void 0?void 0:O.index))}),j[j.length-1].lastIndex!==k.content.length&&R.push(k.content.substring(j[j.length-1].lastIndex,k.content.length)),l.createElement("span",{style:C,key:w,className:E},R)}function b(k){const{className:w,useClasses:C,children:E,linkify:T}=k;return l.createElement("code",{className:w},c(E??"",C??!1).map(h.bind(null,T??!1,C??!1)))}function v(k){let w=k;do k=w,w=k.replace(/[^\n]\x08/gm,"");while(w.length<k.length);return k}return hi}var frt=drt();const hrt=eo(frt),prt=x.lazy(()=>Ar(()=>import("./index-DJ2ScbA0.js"),[])),mrt={...Jst,container:"bg-transparent text-xs font-mono leading-relaxed",label:"text-muted-foreground font-medium mr-1",clickableLabel:"text-muted-foreground font-medium mr-1 cursor-pointer",nullValue:"text-muted-foreground italic",undefinedValue:"text-muted-foreground italic",stringValue:"text-foreground",booleanValue:"text-amber-400",numberValue:"text-blue-400",otherValue:"text-muted-foreground",punctuation:"text-muted-foreground",collapseIcon:"text-muted-foreground",expandIcon:"text-muted-foreground",collapsedContent:"text-muted-foreground"},z$=5120;function grt(e){try{const t=JSON.parse(e);return typeof t=="object"&&t!==null&&("old_string"in t||"new_string"in t)?t:null}catch{return null}}function uj({children:e,rawContent:t,supportsRawToggle:n,isRaw:s,onToggleRaw:r}){const[a,o]=x.useState(!1),l=t.length>z$,c=l&&!a?t.slice(0,z$):t;return i.jsxs("div",{className:"space-y-1",children:[n&&i.jsx("div",{className:"flex justify-end",children:i.jsx("button",{onClick:r,className:"text-muted-foreground hover:text-foreground text-xs underline",children:s?"Formatted":"Raw"})}),s?i.jsxs(i.Fragment,{children:[i.jsx("pre",{className:"max-h-64 overflow-y-auto text-xs whitespace-pre-wrap",children:c}),l&&!a&&i.jsxs("button",{onClick:()=>o(!0),className:"text-muted-foreground hover:text-foreground text-xs underline",children:["Show full output (",(t.length/1024).toFixed(1),"KB)"]})]}):e]})}function xrt({oldValue:e,newValue:t,rawContent:n}){return i.jsx(x.Suspense,{fallback:i.jsx("pre",{className:"max-h-64 overflow-y-auto text-xs whitespace-pre-wrap",children:n}),children:i.jsx(prt,{oldValue:e,newValue:t,splitView:!1,useDarkTheme:!0,hideLineNumbers:!0,showDiffOnly:!0,extraLinesSurroundingDiff:2,styles:{variables:{dark:{diffViewerBackground:"transparent",addedBackground:"rgba(34, 197, 94, 0.1)",addedColor:"rgb(134, 239, 172)",addedGutterBackground:"rgba(34, 197, 94, 0.08)",wordAddedBackground:"rgba(34, 197, 94, 0.2)",removedBackground:"rgba(239, 68, 68, 0.1)",removedColor:"rgb(252, 165, 165)",removedGutterBackground:"rgba(239, 68, 68, 0.08)",wordRemovedBackground:"rgba(239, 68, 68, 0.2)",gutterBackground:"hsl(0 0% 9%)",gutterBackgroundDark:"hsl(0 0% 7%)",gutterColor:"hsl(0 0% 40%)"}}}})})}function yrt({content:e,toolName:t,input:n}){const[s,r]=x.useState(!1);if(t==="Edit"&&n){const o=grt(n);if(o)return i.jsx(xrt,{oldValue:o.old_string??"",newValue:o.new_string??"",rawContent:e})}const a=$2e(e);if(a==="json"){let o;try{o=JSON.parse(e)}catch{o={}}return i.jsx(uj,{rawContent:e,supportsRawToggle:!0,isRaw:s,onToggleRaw:()=>r(l=>!l),children:i.jsx(nrt,{data:o,style:mrt,shouldExpandNode:trt})})}return a==="ansi"?i.jsx(uj,{rawContent:e,supportsRawToggle:!0,isRaw:s,onToggleRaw:()=>r(o=>!o),children:i.jsx("pre",{className:"max-h-64 overflow-y-auto text-xs whitespace-pre-wrap",children:i.jsx(hrt,{children:e})})}):i.jsx(uj,{rawContent:e,supportsRawToggle:!1,isRaw:!0,onToggleRaw:()=>{},children:null})}const brt=5120;function vrt({content:e,threshold:t=brt,className:n}){const[s,r]=x.useState(!1),a=e.length>t,o=a&&!s?e.slice(0,t):e;return i.jsxs("div",{className:X("mt-2 border-t pt-2",n),children:[i.jsx("pre",{className:"max-h-48 overflow-y-auto text-xs whitespace-pre-wrap",children:o}),a&&!s&&i.jsxs("button",{onClick:()=>r(!0),className:"text-muted-foreground hover:text-foreground mt-1 text-xs underline",children:["Show full output (",(e.length/1024).toFixed(1),"KB)"]})]})}const Srt={running:i.jsx(Xn,{className:"text-muted-foreground size-(--size-icon-xs) animate-spin"}),success:i.jsx(Zt,{className:"text-muted-foreground size-(--size-icon-xs)"}),error:i.jsx(ls,{className:"text-destructive size-(--size-icon-xs)"}),cancelled:i.jsx(ls,{className:"text-muted-foreground size-(--size-icon-xs)"})};function wrt({hook:e}){const t=!!(e.stdout||e.stderr),[n,s]=x.useState(e.status==="error"),r=e.stderr||e.stdout;return i.jsxs("div",{children:[i.jsxs("button",{onClick:()=>t&&s(a=>!a),className:X("flex w-full items-center gap-1.5 py-0.5",!t&&"cursor-default"),"aria-expanded":t?n:void 0,disabled:!t,children:[Srt[e.status],i.jsx("span",{className:X("text-3xs font-mono",e.status==="error"?"text-destructive":"text-muted-foreground"),children:e.hookName}),e.status==="error"&&i.jsx("span",{className:"text-3xs text-destructive",children:"failed"}),e.exitCode!==void 0&&i.jsxs("span",{className:"text-3xs text-muted-foreground ml-auto",children:["exit ",e.exitCode]})]}),i.jsx(He,{initial:!1,children:n&&t&&r&&i.jsx(oe.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:[.4,0,.2,1]},className:"overflow-hidden",children:i.jsx("pre",{className:"text-muted-foreground max-h-32 overflow-y-auto py-1 text-xs whitespace-pre-wrap",children:r})})})]})}function krt({toolCall:e,defaultExpanded:t=!1}){const[n,s]=x.useState(t),r=!!e.progressOutput;x.useEffect(()=>{r&&!n&&s(!0)},[r]);const a=e.hooks&&e.hooks.length>0?i.jsx("div",{className:"border-border/50 space-y-0.5 border-t px-3 py-1",children:e.hooks.map(c=>i.jsx(wrt,{hook:c},c.hookId))}):void 0,o=e.startedAt&&e.completedAt?e.completedAt-e.startedAt:void 0,l=fG(e.toolName);return i.jsxs(gb,{expanded:n,onToggle:()=>s(!n),dimmed:e.status==="complete",extraContent:a,"data-testid":"tool-call-card","data-tool-name":e.toolName,"data-status":e.status,header:i.jsxs(i.Fragment,{children:[Tie(e.status),l&&i.jsx("span",{className:"bg-muted text-muted-foreground text-3xs rounded px-1 py-0.5 font-medium",children:l}),i.jsx("span",{className:"text-3xs flex-1 text-left font-mono",children:o3(e.toolName,e.input)}),o!==void 0&&i.jsx("span",{className:"text-muted-foreground text-3xs tabular-nums",children:c2e(o)})]}),children:[e.status==="running"&&!e.input?i.jsxs("div",{className:"text-muted-foreground flex items-center gap-1.5 py-1 text-xs",children:[i.jsx(Xn,{className:"size-3 animate-spin"}),i.jsx("span",{children:"Preparing..."})]}):e.input!==void 0&&e.input!==""?i.jsx(pG,{toolName:e.toolName,input:e.input,isStreaming:e.status==="running"}):null,e.progressOutput&&!e.result&&i.jsx(vrt,{content:e.progressOutput}),e.result&&i.jsx("div",{className:"mt-2 border-t pt-2",children:i.jsx(yrt,{content:e.result,toolName:e.toolName,input:e.input})})]})}const B$={duration:.15,ease:"easeOut"},$$=120,H$=60,U$=new Set(["Bash","Write","Edit","NotebookEdit"]),V$=new Set(["WebFetch","WebSearch"]);function Crt(e){const t=e.includes("__")?e.split("__").pop():e;return U$.has(t)||U$.has(e)?"high":V$.has(t)||V$.has(e)||e.startsWith("mcp__")?"medium":"low"}function Ert(e){const t=Math.floor(e/60),n=e%60;return t>0?`${t}:${String(n).padStart(2,"0")}`:`${n}s`}function Trt(e){if(e===null)return"";if(e<=0)return"Expired";const t=Math.floor(e/60),n=e%60;return t>0?`${t} minute${t!==1?"s":""} and ${n} second${n!==1?"s":""} remaining`:`${n} second${n!==1?"s":""} remaining`}function Die({sessionId:e,toolCallId:t,toolName:n,input:s,isActive:r=!1,onDecided:a,ref:o,timeoutMs:l,approvalStartedAt:c,approvalRemainingMs:u,approvalTitle:f,approvalDisplayName:h,approvalDescription:m,approvalBlockedPath:g,approvalDecisionReason:b,approvalHasSuggestions:v}){const k=Fe(),w=x.useMemo(()=>Crt(n),[n]),C=fG(n),E=o3(n,s),T=h||E,[_,j]=x.useState(!1),[R,D]=x.useState(null),[I,O]=x.useState(null),[L,B]=x.useState(null),H=x.useRef(!1),[K,U]=x.useState("");x.useEffect(()=>{if(R||!l)return;const F=u!==void 0?Date.now()+u:c?c+l:Date.now()+l;B(Math.max(0,Math.ceil((F-Date.now())/1e3)));const V=setInterval(()=>{const G=Math.max(0,Math.ceil((F-Date.now())/1e3));B(G),G<=0&&clearInterval(V)},1e3);return()=>clearInterval(V)},[l,c,u,R]),x.useEffect(()=>{L===0&&!R&&(H.current=!0,D("denied"),a==null||a())},[L,R,a]),x.useEffect(()=>{L===$$?U("Tool approval required. 2 minutes remaining."):L===H$?U("Urgent: 1 minute to approve or deny."):L===0&&U("Tool approval timed out. Execution denied.")},[L]);const $=x.useMemo(()=>L===null?"normal":L<=0?"expired":L<=H$?"urgent":L<=$$?"warning":"normal",[L]),q=x.useCallback(async()=>{if(!(_||R)){j(!0),O(null);try{await k.approveTool(e,t),D("approved"),a==null||a()}catch(F){F.code==="INTERACTION_ALREADY_RESOLVED"?(D("approved"),a==null||a()):(console.error("Approval failed:",F),O("Approval request failed — try again"))}finally{j(!1)}}},[_,R,k,e,t,a]),J=x.useCallback(async()=>{if(!(_||R)){j(!0),O(null);try{await k.approveTool(e,t,!0),D("approved"),a==null||a()}catch(F){F.code==="INTERACTION_ALREADY_RESOLVED"?(D("approved"),a==null||a()):(console.error("Always Allow failed:",F),O("Always Allow request failed — try again"))}finally{j(!1)}}},[_,R,k,e,t,a]),ne=x.useCallback(async()=>{if(!(_||R)){j(!0),O(null);try{await k.denyTool(e,t),D("denied"),a==null||a()}catch(F){F.code==="INTERACTION_ALREADY_RESOLVED"?(D("denied"),a==null||a()):(console.error("Deny failed:",F),O("Deny request failed — try again"))}finally{j(!1)}}},[_,R,k,e,t,a]);if(x.useImperativeHandle(o,()=>({approve(){q()},alwaysAllow(){J()},deny(){ne()}}),[q,J,ne]),R){const F=R==="approved";return i.jsx(oe.div,{initial:{opacity:0},animate:{opacity:1},transition:B$,children:i.jsx(pS,{"data-testid":"tool-approval-decided","data-decision":R,icon:F?i.jsx(Zt,{className:"text-status-success size-(--size-icon-sm) shrink-0"}):i.jsx(ls,{className:"text-status-error size-(--size-icon-sm) shrink-0"}),label:i.jsx("span",{className:"text-3xs font-mono",children:T}),trailing:i.jsx("span",{className:X("text-2xs rounded-full px-1.5 py-0.5 font-medium",F?"bg-status-success-bg text-status-success-fg":"bg-status-error-bg text-status-error-fg"),children:F?"Approved":"Denied"}),children:R==="denied"&&H.current&&i.jsxs("p",{className:"text-2xs text-muted-foreground mt-1",children:["Auto-denied — approval timed out after ",Math.ceil((l??0)/6e4)," minutes. The agent continued without this tool."]})})})}return i.jsxs(_ie,{isActive:r,isResolved:!!R,className:"my-1","data-testid":"tool-approval",children:[i.jsxs("div",{className:"mb-1 flex items-center gap-2",children:[i.jsx(Ho,{className:X("size-(--size-icon-md)",w==="high"&&"text-status-error",w==="medium"&&"text-status-warning",w==="low"&&"text-muted-foreground")}),i.jsx("span",{className:"font-semibold",children:f||"Tool approval required"})]}),(m||b||g)&&i.jsxs("div",{className:"text-muted-foreground text-2xs mb-2 space-y-0.5",children:[m&&i.jsx("p",{children:m}),b&&!m&&i.jsx("p",{children:b}),g&&i.jsxs("p",{className:"font-mono",children:["Path: ",g]})]}),l&&!R&&i.jsx("div",{role:"progressbar","aria-valuemin":0,"aria-valuemax":Math.ceil(l/1e3),"aria-valuenow":L??0,"aria-valuetext":Trt(L),className:"bg-muted mb-2 h-1 w-full overflow-hidden rounded-full",children:i.jsx("div",{className:X("h-full rounded-full transition-colors duration-500",$==="normal"&&"bg-muted-foreground/30",$==="warning"&&"bg-status-warning",$==="urgent"&&"bg-status-error","motion-safe:animate-drain"),style:{animationDuration:`${l}ms`,animationTimingFunction:"linear",animationFillMode:"forwards"}})}),i.jsx(He,{children:($==="warning"||$==="urgent")&&L!==null&&i.jsx(oe.div,{initial:{opacity:0,y:-4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:B$,className:"mb-2",children:i.jsxs("span",{className:X("text-2xs tabular-nums",$==="warning"&&"text-status-warning",$==="urgent"&&"text-status-error"),children:[Ert(L)," remaining"]})})}),i.jsxs("div",{className:"mb-2 flex items-center gap-1.5",children:[C&&i.jsx("span",{className:"bg-muted text-muted-foreground text-3xs rounded px-1 py-0.5 font-medium",children:C}),i.jsx("span",{className:"font-mono text-xs",children:T})]}),s&&i.jsx("div",{className:"bg-muted mb-3 rounded p-2",children:i.jsx(pG,{toolName:n,input:s})}),I&&i.jsx("p",{className:"text-status-error text-2xs mb-2",children:I}),i.jsxs("div",{className:"flex flex-wrap gap-2",children:[i.jsxs(ve,{size:"sm",onClick:q,disabled:_,className:"transition-opacity duration-150",children:[i.jsx(Zt,{className:"size-(--size-icon-xs)"})," Approve",r&&i.jsx(Br,{className:"ml-1.5",children:"Enter"})]}),v&&i.jsxs(ve,{size:"sm",variant:"outline",onClick:J,disabled:_,className:"transition-opacity duration-150",children:[i.jsx(Qk,{className:"size-(--size-icon-xs)"})," Always Allow",r&&i.jsx(Br,{className:"ml-1.5",children:"Shift+Enter"})]}),i.jsxs(ve,{size:"sm",variant:"outline",onClick:ne,disabled:_,className:"transition-opacity duration-150",children:[i.jsx(ls,{className:"size-(--size-icon-xs)"})," Deny",r&&i.jsx(Br,{className:"ml-1.5",children:"Esc"})]})]}),i.jsx("span",{role:"status","aria-live":"assertive","aria-atomic":"true",className:"sr-only",children:K})]})}function _rt(e,t,n,s,r){const a=n==null?void 0:n[String(t)];if(a){if(e.multiSelect&&a.startsWith("["))try{return JSON.parse(a).join(", ")}catch{return a}return a}const o=s[t];return o?e.multiSelect?o.map(l=>l==="__other__"?r[t]:l).join(", "):o==="__other__"?r[t]:o:null}function Nrt({questions:e,answers:t,selections:n,otherText:s}){const r=i.jsx(Zt,{className:"text-status-success size-(--size-icon-sm) shrink-0"}),a=e.map((o,l)=>({idx:l,header:o.header,value:_rt(o,l,t,n,s)})).filter(o=>o.value!==null);if(a.length===0){const o=e.length===1?"Question answered":`${e.length} questions answered`;return i.jsx(pS,{"data-testid":"question-prompt-submitted",icon:r,label:i.jsx("span",{className:"truncate",children:o})})}return a.length===1?i.jsx(pS,{"data-testid":"question-prompt-submitted",icon:r,label:i.jsx("span",{className:"truncate",children:`${a[0].header}: ${a[0].value}`})}):i.jsx(pS,{"data-testid":"question-prompt-submitted",icon:r,label:i.jsx("span",{className:"text-muted-foreground",children:"Questions answered"}),children:i.jsx("dl",{className:"mt-1 grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 pl-6 text-xs",children:a.map(({idx:o,header:l,value:c})=>i.jsxs(x.Fragment,{children:[i.jsx("dt",{className:"text-muted-foreground",children:l}),i.jsx("dd",{className:"text-foreground break-words",children:c})]},o))})})}const jrt={duration:.25,ease:[.4,0,.2,1]},dj={duration:.15,ease:"easeOut"},Art={enter:e=>({opacity:0,x:e*20}),center:{opacity:1,x:0},exit:e=>({opacity:0,x:e*-20})},Oie=x.forwardRef(function({sessionId:t,toolCallId:n,questions:s,answers:r,isActive:a=!1,focusedOptionIndex:o=-1,onDecided:l},c){const u=Fe(),f=x.useId(),[h,m]=x.useState({}),[g,b]=x.useState({}),[v,k]=x.useState(!!r),[w,C]=x.useState(!1),[E,T]=x.useState(null),[_,j]=x.useState("0"),R=x.useRef(1),D=s[Number(_)]||s[0],I=Number(_),O=D?D.options.length+1:0;function L(F,V){m(G=>({...G,[F]:V}))}function B(F,V,G){m(P=>{const Z=P[F]||[];return G?{...P,[F]:[...Z,V]}:{...P,[F]:Z.filter(Q=>Q!==V)}})}function H(F,V){b(G=>({...G,[F]:V}))}function K(F){var G,P;const V=h[F];if(!V)return!1;if(s[F].multiSelect){const Z=V;return Z.length>0&&(!Z.includes("__other__")||!!((G=g[F])!=null&&G.trim()))}return V!=="__other__"||!!((P=g[F])!=null&&P.trim())}function U(){return s.every((F,V)=>K(V))}const $=x.useCallback(async()=>{if(!U()||w)return;C(!0),T(null);const F={};s.forEach((V,G)=>{var Z;const P=h[G];if(V.multiSelect){const Q=P.map(re=>{var ae;return re==="__other__"?((ae=g[G])==null?void 0:ae.trim())||"":re}).filter(Boolean);F[String(G)]=Q.join(", ")}else F[String(G)]=P==="__other__"?((Z=g[G])==null?void 0:Z.trim())||"":P});try{await u.submitAnswers(t,n,F),k(!0),l==null||l(F)}catch(V){V.code==="INTERACTION_ALREADY_RESOLVED"?(k(!0),l==null||l(F)):T(V instanceof Error?V.message:"Failed to submit answers")}finally{C(!1)}},[h,g,w,u,t,n,s,l]);x.useImperativeHandle(c,()=>({toggleOption(F){if(!D||v||w)return;if(F===D.options.length){D.multiSelect?(h[I]||[]).includes("__other__")?B(I,"__other__",!1):B(I,"__other__",!0):L(I,"__other__");return}const V=D.options[F];V&&(D.multiSelect?(h[I]||[]).includes(V.label)?B(I,V.label,!1):B(I,V.label,!0):L(I,V.label))},navigateOption(F){},navigateQuestion(F){if(s.length<=1)return;const V=Number(_);F==="next"&&V<s.length-1?(R.current=1,j(String(V+1))):F==="prev"&&V>0&&(R.current=-1,j(String(V-1)))},submit(){const F=Number(_);if(F<s.length-1){R.current=1,j(String(F+1));return}$()},getOptionCount(){return O},getActiveTab(){return _}}),[D,I,_,h,v,w,O,$,s.length]);function q(F){const V=Number(_);F==="next"&&V<s.length-1?(R.current=1,j(String(V+1))):F==="prev"&&V>0&&(R.current=-1,j(String(V-1)))}function J(F,V){const G=F.multiSelect?(h[V]||[]).includes("__other__"):h[V]==="__other__",P=`${f}-q-${V}-other`,Z=F.options.length;return i.jsx(tj,{isSelected:G,isFocused:a&&o===Z,"data-selected":G,control:F.multiSelect?i.jsx(zx,{checked:G,id:P,disabled:w,onCheckedChange:Q=>B(V,"__other__",!!Q)}):i.jsx(Xx,{value:"__other__",id:P,disabled:w}),children:i.jsxs("div",{className:"flex-1",children:[i.jsxs("label",{htmlFor:P,className:"flex cursor-pointer items-center",children:[i.jsx("span",{className:"text-sm font-medium",children:"Other"}),Z<9&&i.jsx(Br,{className:"text-2xs text-muted-foreground ml-auto shrink-0",children:Z+1})]}),i.jsx(He,{initial:!1,children:G&&i.jsx(oe.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:jrt,className:"overflow-hidden",children:i.jsx("textarea",{placeholder:"Type your answer...",rows:2,value:g[V]||"",disabled:w,onChange:Q=>H(V,Q.target.value),className:"bg-background border-border focus:ring-ring mt-1 w-full resize-y rounded border px-2 py-1 text-sm focus:ring-1 focus:outline-none",autoFocus:!0})})})]})})}function ne(F,V){return i.jsxs("div",{children:[i.jsx("p",{className:"text-foreground mb-1.5",children:F.question}),F.multiSelect?i.jsxs("div",{role:"group","aria-label":F.question,className:"ml-1 space-y-1",children:[F.options.map((G,P)=>{const Z=(h[V]||[]).includes(G.label),Q=`${f}-q-${V}-opt-${P}`;return i.jsx(tj,{isSelected:Z,isFocused:a&&o===P,"data-selected":Z,control:i.jsx(zx,{checked:Z,id:Q,disabled:w,onCheckedChange:re=>B(V,G.label,!!re)}),children:i.jsxs("label",{htmlFor:Q,className:"flex flex-1 cursor-pointer items-center",children:[i.jsx("span",{className:"text-sm font-medium",children:G.label}),G.description&&i.jsxs("span",{className:"text-muted-foreground ml-1.5 text-xs",children:[" ","— ",G.description]}),P<9&&i.jsx(Br,{className:"text-2xs text-muted-foreground ml-auto shrink-0",children:P+1})]})},P)}),J(F,V)]}):i.jsxs(YD,{value:h[V]??"",onValueChange:G=>L(V,G),"aria-label":F.question,className:"ml-1 gap-1",children:[F.options.map((G,P)=>{const Z=h[V]===G.label,Q=`${f}-q-${V}-opt-${P}`;return i.jsx(tj,{isSelected:Z,isFocused:a&&o===P,"data-selected":Z,control:i.jsx(Xx,{value:G.label,id:Q,disabled:w}),children:i.jsxs("label",{htmlFor:Q,className:"flex flex-1 cursor-pointer items-center",children:[i.jsx("span",{className:"text-sm font-medium",children:G.label}),G.description&&i.jsxs("span",{className:"text-muted-foreground ml-1.5 text-xs",children:[" ","— ",G.description]}),P<9&&i.jsx(Br,{className:"text-2xs text-muted-foreground ml-auto shrink-0",children:P+1})]})},P)}),J(F,V)]})]})}return v?i.jsx(oe.div,{initial:r?!1:{opacity:0},animate:{opacity:1},transition:dj,children:i.jsx(Nrt,{questions:s,answers:r,selections:h,otherText:g})}):i.jsxs(_ie,{isActive:a,isResolved:v,children:[s.length===1?ne(s[0],0):i.jsxs("div",{children:[i.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[i.jsx("span",{className:"text-muted-foreground text-xs",children:s[Number(_)].header??`Question ${Number(_)+1} of ${s.length}`}),i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsxs(ve,{size:"sm",variant:"ghost",onClick:()=>q("prev"),disabled:Number(_)===0,className:"h-7 px-2 text-xs",children:["Back ",a&&i.jsx(Br,{className:"ml-1",children:"←"})]}),Number(_)<s.length-1?i.jsxs(ve,{size:"sm",onClick:()=>q("next"),className:"h-7 px-2 text-xs",children:["Next ",a&&i.jsx(Br,{className:"ml-1",children:"→"})]}):i.jsxs(ve,{size:"sm",onClick:$,disabled:!U()||w,className:"h-7 px-2 text-xs transition-opacity duration-150",children:[i.jsx(Zt,{className:"size-(--size-icon-xs)"}),w?"Submitting...":"Submit",a&&i.jsx(Br,{className:"ml-1",children:"Enter"})]})]})]}),i.jsx(He,{mode:"wait",custom:R.current,children:i.jsx(oe.div,{custom:R.current,variants:Art,initial:"enter",animate:"center",exit:"exit",transition:dj,children:ne(s[Number(_)],Number(_))},_)})]}),i.jsx(He,{children:E&&i.jsx(oe.p,{initial:{opacity:0,y:-4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:dj,className:"mt-2 text-xs text-red-500",children:E})}),s.length===1&&i.jsx(ve,{size:"sm",onClick:$,disabled:!U()||w,className:"mt-2 transition-opacity duration-150",children:w?"Submitting...":i.jsxs(i.Fragment,{children:[i.jsx(Zt,{className:"size-(--size-icon-xs)"})," Submit",a&&i.jsx(Br,{className:"ml-1.5",children:"Enter"})]})})]})});function Rrt(e){if(!e)return[];const t=e.properties??{};return Object.entries(t).map(([n,s])=>({key:n,label:s.description??n,type:s.type??"string",options:s.enum,defaultValue:s.default}))}function Mrt({sessionId:e,interactionId:t,serverName:n,message:s,mode:r="form",url:a,requestedSchema:o,status:l,action:c}){const u=Fe(),[f,h]=x.useState(!1),[m,g]=x.useState(null),[b,v]=x.useState({}),[k,w]=x.useState(!1),C=x.useMemo(()=>Rrt(o),[o]),E=l!=="pending",T=x.useCallback(async(O,L)=>{if(!(f||E)){h(!0),g(null);try{await u.submitElicitation(e,t,O,L)}catch(B){if(B.code!=="INTERACTION_ALREADY_RESOLVED"){g(B instanceof Error?B.message:"Failed to submit"),h(!1);return}}h(!1)}},[u,e,t,f,E]),_=x.useCallback(()=>{const O={};for(const L of C)O[L.key]=b[L.key]??L.defaultValue??"";T("accept",O)},[C,b,T]),j=x.useCallback(()=>{T("accept")},[T]),R=x.useCallback(()=>{T("decline")},[T]),D=x.useCallback((O,L)=>{v(B=>({...B,[O]:L}))},[]),I=x.useCallback(()=>{a&&(window.open(a,"_blank","noopener,noreferrer"),w(!0))},[a]);return E?i.jsxs("div",{className:"text-muted-foreground flex items-center gap-2 py-1 text-xs",children:[i.jsx("span",{className:"font-mono",children:n}),i.jsx("span",{children:"—"}),i.jsx("span",{children:c==="accept"?"Authorized":c==="decline"?"Declined":"Cancelled"})]}):i.jsxs(oe.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{duration:.15},className:X("border-border bg-card my-2 rounded-xl border p-4","shadow-soft"),children:[i.jsxs("div",{className:"text-muted-foreground mb-2 flex items-center gap-2 text-xs",children:[i.jsx("span",{className:"bg-muted inline-flex items-center rounded-md px-2 py-0.5 font-mono text-[10px]",children:n}),i.jsx("span",{children:"requests input"})]}),i.jsx("p",{className:"mb-3 text-sm",children:s}),m&&i.jsx("p",{className:"text-destructive mb-2 text-xs",children:m}),r==="url"&&a&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(ve,{size:"sm",variant:"outline",onClick:I,disabled:f,children:"Open authorization page"}),k&&i.jsx(ve,{size:"sm",onClick:j,disabled:f,children:f?"Submitting…":"Done — I authorized"}),i.jsx(ve,{size:"sm",variant:"ghost",onClick:R,disabled:f,children:"Decline"})]}),r==="form"&&i.jsxs(i.Fragment,{children:[C.length>0?i.jsx("div",{className:"mb-3 space-y-2",children:C.map(O=>i.jsxs("div",{children:[i.jsx("label",{htmlFor:`elicitation-${t}-${O.key}`,className:"text-muted-foreground mb-1 block text-xs font-medium",children:O.label}),O.options?i.jsxs("select",{id:`elicitation-${t}-${O.key}`,className:"border-input bg-background w-full rounded-md border px-3 py-1.5 text-sm",value:b[O.key]??String(O.defaultValue??""),onChange:L=>D(O.key,L.target.value),disabled:f,children:[i.jsx("option",{value:"",children:"Select…"}),O.options.map(L=>i.jsx("option",{value:L,children:L},L))]}):i.jsx("input",{id:`elicitation-${t}-${O.key}`,type:O.type==="number"?"number":"text",className:"border-input bg-background w-full rounded-md border px-3 py-1.5 text-sm",placeholder:String(O.defaultValue??""),value:b[O.key]??"",onChange:L=>D(O.key,L.target.value),disabled:f})]},O.key))}):i.jsx("p",{className:"text-muted-foreground mb-3 text-xs",children:"No additional input required."}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(ve,{size:"sm",onClick:_,disabled:f,children:f?"Submitting…":"Accept"}),i.jsx(ve,{size:"sm",variant:"ghost",onClick:R,disabled:f,children:"Decline"})]})]})]})}function Drt(e){if(e<1e3)return"<1s";const t=Math.floor(e/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60),s=t%60;return`${n}m ${s}s`}function Ort(e){const t=[];return e.toolUses&&t.push(`${e.toolUses} tool ${e.toolUses===1?"call":"calls"}`),e.durationMs&&t.push(Drt(e.durationMs)),t.length>0?t.join(" · "):null}function Irt({part:e}){const[t,n]=x.useState(!1),s=x.useRef(null),r=Ort(e),a=e.subagentText,o=!!(r||e.summary||e.lastToolName||a);return x.useEffect(()=>{const l=s.current;l&&(l.scrollTop=l.scrollHeight)},[a]),i.jsx(gb,{expanded:t,onToggle:()=>o&&n(!t),hideChevron:!o,ariaLabel:`Background task: ${e.description}`,"data-testid":"subagent-block","data-task-id":e.taskId,"data-status":e.status,header:i.jsxs(i.Fragment,{children:[Tie(e.status==="stopped"?"complete":e.status),i.jsx("span",{className:"text-3xs truncate font-mono",children:e.description}),r&&i.jsx("span",{className:"text-3xs text-muted-foreground ml-1 shrink-0",children:r})]}),children:i.jsxs("div",{className:"space-y-1.5",children:[a&&i.jsxs("div",{className:"space-y-1",children:[i.jsx("p",{className:"text-3xs text-muted-foreground/70 tracking-wide uppercase",children:"Subagent output"}),i.jsx("pre",{ref:s,className:"text-foreground/90 bg-muted/50 max-h-64 overflow-y-auto rounded-md p-2 text-xs break-words whitespace-pre-wrap","data-testid":"subagent-text",children:a})]}),e.lastToolName&&e.status==="running"&&i.jsxs("p",{className:"text-3xs text-muted-foreground",children:["Last tool: ",i.jsx("span",{className:"font-mono",children:e.lastToolName})]}),e.summary&&i.jsx("pre",{className:"overflow-x-auto text-xs whitespace-pre-wrap",children:e.summary})]})})}function Prt(e){if(e<1e3)return"<1s";const t=Math.floor(e/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60),s=t%60;return`${n}m ${s}s`}function Lrt({text:e,isStreaming:t,elapsedMs:n}){const[s,r]=x.useState(t),a=x.useRef(t),o=x.useRef(null);x.useEffect(()=>{a.current&&!t&&r(!1),a.current=t},[t]),x.useEffect(()=>{t&&s&&o.current&&(o.current.scrollTop=o.current.scrollHeight)},[e,t,s]);const l=n?`Thought for ${Prt(n)}`:"Thinking...";return i.jsx(gb,{expanded:s,onToggle:()=>r(!s),variant:"thinking",dimmed:!t,disabled:t,ariaLabel:l,"data-testid":"thinking-block","data-streaming":t?"true":void 0,header:i.jsxs(i.Fragment,{children:[i.jsx(MCe,{className:X("text-muted-foreground size-(--size-icon-xs)",t&&"animate-tasks")}),i.jsx("span",{className:X("text-3xs text-muted-foreground font-mono",t&&"animate-tasks"),children:l})]}),children:i.jsx("div",{ref:o,className:"max-h-32 overflow-y-auto",children:i.jsx("pre",{className:"text-muted-foreground text-xs break-words whitespace-pre-wrap",children:e})})})}const Frt={duration:.25,ease:[.4,0,.2,1]},zrt={max_turns:{heading:"Turn limit reached",subtext:"The agent ran for its maximum number of turns.",retryable:!1},execution_error:{heading:"Agent stopped unexpectedly",subtext:"An error occurred during execution.",retryable:!0},budget_exceeded:{heading:"Cost limit reached",subtext:"This session exceeded its budget.",retryable:!1},output_format_error:{heading:"Output format error",subtext:"The agent couldn't produce the required output format.",retryable:!1}};function Iie({message:e,category:t,details:n,onRetry:s,heading:r,subtext:a}){const[o,l]=x.useState(!1),c=t?zrt[t]:null,u=r??(c==null?void 0:c.heading)??"Error",f=a??(c==null?void 0:c.subtext)??e,h=(c==null?void 0:c.retryable)??!!s;return i.jsx("div",{className:X("my-2 rounded-lg border px-4 py-3","border-destructive/30 bg-destructive/5 text-foreground"),children:i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsx(Yr,{className:"text-destructive mt-0.5 size-4 shrink-0"}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("p",{className:"text-sm font-medium",children:u}),i.jsx("p",{className:"text-muted-foreground mt-0.5 text-sm",children:f}),n&&i.jsxs("button",{type:"button",onClick:()=>l(!o),className:"text-muted-foreground hover:text-foreground mt-2 flex items-center gap-1 text-xs","aria-expanded":o,children:[i.jsx(oe.div,{animate:{rotate:o?0:-90},transition:{type:"spring",stiffness:400,damping:30},children:i.jsx(Ps,{className:"size-3"})}),"Details"]}),i.jsx(He,{initial:!1,children:o&&n&&i.jsx(oe.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:Frt,className:"overflow-hidden",children:i.jsx("pre",{className:"bg-muted/50 mt-1 max-h-40 overflow-auto rounded p-2 text-xs whitespace-pre-wrap",children:n})})})]}),h&&s&&i.jsxs(ve,{variant:"outline",size:"sm",onClick:s,className:"shrink-0 gap-1.5",children:[i.jsx(e_e,{className:"size-3"}),"Retry"]})]})})}function Brt({mode:e,memories:t,isStreaming:n}){const[s,r]=x.useState(n),a=x.useRef(n);if(x.useEffect(()=>{a.current&&!n&&r(!1),a.current=n},[n]),t.length===0)return null;const o=t.length,l=n?o<=1?"Consulting memory…":`Consulting ${o} memories…`:o===1?"Recalled 1 memory":`Recalled ${o} memories`,c=e==="synthesize"?$y:W3,u=e==="synthesize"?"sparkles":"bookopen";return i.jsx(gb,{expanded:s,onToggle:()=>r(!s),variant:"memory",dimmed:!n,disabled:n,ariaLabel:l,"data-testid":"memory-recall-block","data-streaming":n?"true":void 0,header:i.jsxs(i.Fragment,{children:[i.jsx(c,{"aria-hidden":"true","data-testid":"memory-recall-header-icon","data-icon":u,className:X("text-muted-foreground size-(--size-icon-xs)",n&&"animate-tasks")}),i.jsx("span",{className:X("text-3xs text-muted-foreground font-mono",n&&"animate-tasks"),children:l})]}),children:i.jsx($rt,{memories:t})})}function $rt({memories:e}){return i.jsx("ul",{className:"flex flex-col gap-1 px-3 py-2",children:e.map(t=>i.jsx(Hrt,{memory:t},t.path))})}function Hrt({memory:e}){const t=e.path.startsWith("<synthesis:"),n=e.scope==="team"?Hy:Zf,s=e.scope==="team"?"team":"personal",r=async()=>{const a=t&&e.content?e.content:e.path;try{await navigator.clipboard.writeText(a),rt.success("Copied to clipboard")}catch{rt.error("Failed to copy")}};if(t&&e.content){const a=e.path.replace(/^<synthesis:/,"synthesis:").replace(/>$/,"");return i.jsx("li",{children:i.jsxs("button",{type:"button",onClick:r,"aria-label":`Copy synthesized ${s} memory content`,"data-scope":e.scope,className:"focus-ring hover:bg-muted/50 flex min-h-[44px] w-full flex-col items-start gap-1 rounded-md px-2 py-1 text-left",children:[i.jsx("span",{className:"text-sm",children:e.content}),i.jsxs("span",{className:"text-3xs text-muted-foreground flex items-center gap-1 font-mono",children:[i.jsx(n,{"aria-hidden":"true",className:"size-(--size-icon-xs)"}),a]})]})})}return i.jsx("li",{children:i.jsxs("button",{type:"button",onClick:r,"aria-label":`Copy ${s} memory path ${e.path}`,"data-scope":e.scope,className:"focus-ring hover:bg-muted/50 flex min-h-[44px] w-full items-center gap-2 rounded-md px-2 py-1 text-left",children:[i.jsx("span",{className:"flex-1 truncate font-mono text-sm",children:u2e(e.path,40)}),i.jsx(n,{"aria-hidden":"true",className:"text-muted-foreground size-(--size-icon-xs)"})]})})}function Urt({toolName:e,reasonType:t,reason:n,message:s}){const r=t==="classifier",a=n||s,o=r?`Blocked by auto-mode classifier: ${a}`:`Blocked: ${a}`;return i.jsxs("div",{"data-testid":"permission-denied-chip","data-reason-type":t,className:X("my-2 flex items-start gap-2 rounded-md border px-3 py-2","text-foreground border-amber-500/30 bg-amber-500/5"),children:[i.jsx(v_e,{"aria-hidden":"true",className:"mt-0.5 size-4 shrink-0 text-amber-600 dark:text-amber-500"}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("p",{className:"text-sm",children:o}),i.jsx("p",{className:"text-muted-foreground mt-0.5 font-mono text-xs",children:e})]})]})}function Pie(e,t,n){const s=x.useRef(e),[r,a]=x.useState(!(t&&s.current==="complete"));return x.useEffect(()=>{if(t&&e==="complete"&&s.current!=="complete"&&!n){const o=setTimeout(()=>a(!1),Yi.TOOL_CALL_AUTO_HIDE_MS);return()=>clearTimeout(o)}},[e,t,n]),!t||n?!0:r}function Vrt({part:e,autoHide:t,expandToolCalls:n}){var a;const s=((a=e.hooks)==null?void 0:a.some(o=>o.status==="error"))??!1,r=Pie(e.status,t,s);return i.jsx(He,{children:r&&i.jsx(oe.div,{exit:{height:0,opacity:0},transition:{duration:.3,ease:[.4,0,.2,1]},className:"overflow-hidden",children:i.jsx(krt,{toolCall:{toolCallId:e.toolCallId,toolName:e.toolName,input:e.input||"",result:e.result,progressOutput:e.progressOutput,status:e.status,hooks:e.hooks,startedAt:e.startedAt,completedAt:e.completedAt},defaultExpanded:n})},e.toolCallId)})}function qrt({part:e,autoHide:t,index:n}){const s=e.isStreaming?"running":"complete",r=Pie(s,t,!1);return i.jsx(He,{children:r&&i.jsx(oe.div,{exit:{height:0,opacity:0},transition:{duration:.3,ease:[.4,0,.2,1]},className:"overflow-hidden",children:i.jsx(Lrt,{text:e.text,isStreaming:e.isStreaming??!1,elapsedMs:e.elapsedMs})},`thinking-${n}`)})}const Grt=4,q$=2;function Krt({children:e}){const[t,n]=x.useState(!1);if(e.length<=Grt||t)return i.jsx(i.Fragment,{children:e});const s=e.length-q$;return i.jsxs(i.Fragment,{children:[e.slice(0,q$),i.jsx(gb,{expanded:!1,onToggle:()=>n(!0),hideChevron:!0,className:"border-l-muted-foreground/15",header:i.jsxs(i.Fragment,{children:[i.jsx(Ws,{className:"text-muted-foreground size-(--size-icon-xs)"}),i.jsxs("span",{className:"text-3xs text-muted-foreground font-mono",children:["and ",s," more steps…"]})]}),children:i.jsx(i.Fragment,{})})]})}function Wrt({message:e}){const{sessionId:t,isStreaming:n,activeToolCallId:s,onToolRef:r,focusedOptionIndex:a,onToolDecided:o,onRetry:l,inputZoneToolCallId:c,textEffect:u}=Mst(),{expandToolCalls:f,autoHideToolCalls:h}=je(),m=e.parts??[],g=x.useCallback(E=>{r==null||r(E)},[r]),b=x.useCallback(E=>{r==null||r(E)},[r]);let v=-1;for(let E=m.length-1;E>=0;E--)if(m[E].type==="text"){v=E;break}function k(E,T){if(E.type==="text")return i.jsx("div",{className:"msg-assistant",children:i.jsx(Hst,{content:E.text,isStreaming:n&&T===v,textEffect:u})},`text-${T}`);if(E.type==="background_task")return i.jsx(Irt,{part:E},E.taskId);if(E.type==="error")return i.jsx(Iie,{message:E.message,category:E.category,details:E.details,onRetry:l},`error-${T}`);if(E.type==="thinking")return i.jsx(qrt,{part:E,autoHide:h,index:T},`thinking-${T}`);if(E.type==="elicitation")return i.jsx(Mrt,{sessionId:t,interactionId:E.interactionId,serverName:E.serverName,message:E.message,mode:E.mode,url:E.url,requestedSchema:E.requestedSchema,status:E.status,action:E.action},`elicitation-${E.interactionId}`);if(E.type==="memory_recall")return i.jsx(Brt,{mode:E.mode,memories:E.memories,isStreaming:E.isStreaming??!1},`memory-recall-${T}`);if(E.type==="permission_denied")return i.jsx(Urt,{toolName:E.toolName,reasonType:E.reasonType,reason:E.reason,message:E.message},`permission-denied-${E.toolCallId}-${T}`);const _=E;if(_.interactiveType==="approval"&&_.status==="pending"){if(_.toolCallId===c)return i.jsx(j$,{type:"approval",toolName:_.toolName,toolInput:_.input},_.toolCallId);const j=_.toolCallId===s;return i.jsx(Die,{ref:j?g:void 0,sessionId:t,toolCallId:_.toolCallId,toolName:_.toolName,input:_.input||"",timeoutMs:_.timeoutMs,approvalStartedAt:_.approvalStartedAt,approvalRemainingMs:_.approvalRemainingMs,approvalTitle:_.approvalTitle,approvalDisplayName:_.approvalDisplayName,approvalDescription:_.approvalDescription,approvalBlockedPath:_.approvalBlockedPath,approvalDecisionReason:_.approvalDecisionReason,approvalHasSuggestions:_.approvalHasSuggestions,isActive:j,onDecided:o?()=>o(_.toolCallId):void 0},_.toolCallId)}if(_.interactiveType==="question"&&_.questions){if(_.toolCallId===c)return i.jsx(j$,{type:"question",toolName:_.toolName,toolInput:_.input},_.toolCallId);const j=_.toolCallId===s;return i.jsx(Oie,{ref:j?b:void 0,sessionId:t,toolCallId:_.toolCallId,questions:_.questions,answers:_.answers??(_.status!=="pending"?{}:void 0),isActive:j,focusedOptionIndex:j?a:-1,onDecided:o?R=>o(_.toolCallId,R):void 0},_.toolCallId)}return i.jsx(Vrt,{part:_,autoHide:h,expandToolCalls:f},_.toolCallId)}const w=[];let C=[];for(let E=0;E<m.length;E++){const T=m[E];T.type==="thinking"||T.type==="tool_call"&&!T.interactiveType?C.push(E):(C.length>0&&(w.push(C.length===1?{type:"single",index:C[0]}:{type:"run",indices:[...C]}),C=[]),w.push({type:"single",index:E}))}return C.length>0&&w.push(C.length===1?{type:"single",index:C[0]}:{type:"run",indices:[...C]}),i.jsx(i.Fragment,{children:w.map(E=>{if(E.type==="single"){const _=m[E.index];return _.type==="thinking"||_.type==="tool_call"&&!_.interactiveType?i.jsx("div",{className:"my-3",children:k(_,E.index)},`spacer-${E.index}`):k(_,E.index)}const T=E.indices.map(_=>k(m[_],_));return i.jsx("div",{className:"my-3",children:i.jsx(Krt,{children:T})},`run-${E.indices[0]}`)})})}function Yrt(e){try{return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}}function Zrt({message:e,grouping:t,sessionId:n,isNew:s=!1,isStreaming:r=!1,activeToolCallId:a=null,onToolRef:o,focusedOptionIndex:l=-1,onToolDecided:c,onRetry:u,inputZoneToolCallId:f=null,textEffect:h}){const m=e.role==="user",{showTimestamps:g}=je(),{position:b,groupIndex:v}=t,k=b==="only"||b==="first",w=Ast({role:m?"user":"assistant",position:b});return i.jsx(Rst,{value:{sessionId:n,isStreaming:r,activeToolCallId:a,onToolRef:o,focusedOptionIndex:l,onToolDecided:c,onRetry:u,inputZoneToolCallId:f,textEffect:h},children:i.jsxs(oe.div,{initial:s?{opacity:0,y:8,x:m?12:0,scale:m?.97:1}:!1,animate:{opacity:1,y:0,x:0,scale:1},transition:{type:"spring",stiffness:320,damping:28},"data-testid":"message-item","data-role":e.role,className:w.root(),children:[k&&v>0&&!m&&i.jsx("div",{className:w.divider()}),e.timestamp&&i.jsx("span",{className:X(w.timestamp(),g?"text-msg-timestamp":"group-hover:text-msg-timestamp text-transparent"),children:Yrt(e.timestamp)}),i.jsx("div",{className:w.content(),children:m?i.jsx(zst,{message:e}):i.jsx(Wrt,{message:e})})]})})}const G$=800,K$=24;function Xrt({scrollRef:e}){const t=x.useRef(null),n=x.useRef(null),s=x.useRef(null),[r,a]=x.useState(!1),o=x.useRef(!1),l=x.useRef(0),c=x.useRef(0),u=x.useCallback(()=>{a(!0),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{o.current||a(!1)},G$)},[]),f=x.useCallback(()=>{const g=e.current,b=t.current,v=n.current;if(!g||!b||!v)return;const{scrollTop:k,scrollHeight:w,clientHeight:C}=g;if(w<=C){b.style.display="none";return}b.style.display="";const E=v.clientHeight,T=C/w,_=Math.max(T*E,K$),j=E-_,D=k/(w-C)*j;b.style.height=`${_}px`,b.style.transform=`translateY(${D}px)`},[e]);x.useEffect(()=>{const g=e.current;if(!g)return;const b=()=>{u(),f()};return g.addEventListener("scroll",b,{passive:!0}),f(),()=>g.removeEventListener("scroll",b)},[e,u,f]);const h=x.useCallback(g=>{if(g.target===t.current)return;const b=e.current,v=n.current;if(!b||!v)return;const k=v.getBoundingClientRect(),w=(g.clientY-k.top)/k.height;b.scrollTop=w*(b.scrollHeight-b.clientHeight)},[e]),m=x.useCallback(g=>{var k;g.preventDefault(),g.stopPropagation(),o.current=!0,l.current=g.clientY,c.current=((k=e.current)==null?void 0:k.scrollTop)??0;const b=w=>{const C=e.current,E=n.current;if(!C||!E)return;const T=w.clientY-l.current,_=E.clientHeight,j=C.clientHeight/C.scrollHeight,R=Math.max(j*_,K$),D=_-R,I=C.scrollHeight-C.clientHeight,O=T/D*I;C.scrollTop=c.current+O},v=()=>{o.current=!1,document.removeEventListener("pointermove",b),document.removeEventListener("pointerup",v),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>a(!1),G$)};document.addEventListener("pointermove",b),document.addEventListener("pointerup",v)},[e]);return i.jsx("div",{ref:n,role:"presentation",onClick:h,className:"pointer-events-auto absolute top-12 right-0 bottom-0 z-10 w-2.5",children:i.jsx("div",{ref:t,onPointerDown:m,className:"bg-border absolute right-0.5 w-1.5 cursor-pointer rounded-full transition-opacity duration-200",style:{opacity:r?1:0}})})}function Qrt(e){let t=0;return e.map((n,s)=>{const r=s>0?e[s-1].role:null,a=s<e.length-1?e[s+1].role:null,o=r!==n.role,l=a!==n.role;o&&s>0&&t++;let c;return o&&l?c="only":o?c="first":l?c="last":c="middle",{position:c,groupIndex:t}})}const Jrt=x.forwardRef(function({messages:t,sessionId:n,isTextStreaming:s,onScrollStateChange:r,activeToolCallId:a,onToolRef:o,focusedOptionIndex:l,onToolDecided:c,onRetry:u,inputZoneToolCallId:f,textEffect:h},m){const[g,b]=x.useState(null),v=x.useMemo(()=>Qrt(t),[t]),{scrollRef:k,contentRef:w,isAtBottom:C,scrollToBottom:E}=bst({resize:"smooth",initial:"instant"});x.useEffect(()=>{g===null&&t.length>0&&b(t.length)},[t.length,g]);const T=pst({count:t.length,getScrollElement:()=>k.current,estimateSize:()=>80,overscan:5,measureElement:_=>(_==null?void 0:_.getBoundingClientRect().height)??80});return x.useEffect(()=>{r==null||r({isAtBottom:C,distanceFromBottom:C?0:200})},[C,r]),x.useEffect(()=>{const _=k.current;if(!_||t.length===0)return;let j=!1;const R=new IntersectionObserver(([D])=>{D.isIntersecting?j&&(j=!1,requestAnimationFrame(()=>{E()})):j=!0},{threshold:.1});return R.observe(_),()=>R.disconnect()},[k,t.length,E]),x.useImperativeHandle(m,()=>({scrollToBottom:E}),[E]),i.jsxs("div",{"data-testid":"message-list",className:"relative h-full",children:[i.jsx("div",{ref:k,className:"chat-scroll-area hide-scrollbar h-full overflow-y-auto px-3 pt-12",style:{overflowAnchor:"none"},children:i.jsx("div",{ref:w,style:{height:T.getTotalSize(),position:"relative",width:"100%"},children:T.getVirtualItems().map(_=>{const j=t[_.index],R=g!==null&&_.index>=g,I=_.index===t.length-1&&j.role==="assistant"&&!!s;return i.jsx("div",{"data-index":_.index,ref:T.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${_.start}px)`},children:i.jsx(Zrt,{message:j,grouping:v[_.index],sessionId:n,isNew:R,isStreaming:I,activeToolCallId:a,onToolRef:o,focusedOptionIndex:l,onToolDecided:c,onRetry:u,inputZoneToolCallId:f,textEffect:h})},_.key)})})}),i.jsx(Xrt,{scrollRef:k})]})});function eat({messages:e,sessionId:t,isLoadingHistory:n,isTextStreaming:s,isAtBottom:r,hasNewMessages:a,scrollToBottom:o,onScrollStateChange:l,activeToolCallId:c,onToolRef:u,focusedOptionIndex:f,onToolDecided:h,onRetry:m,inputZoneToolCallId:g,messageListRef:b}){const v=je(w=>w.dorkbotFirstMessage),k=je(w=>w.setDorkbotFirstMessage);return i.jsxs("div",{className:"relative min-h-0 flex-1",children:[n?i.jsx("div",{className:"flex h-full items-center justify-center",children:i.jsxs("div",{className:"text-muted-foreground flex items-center gap-2 text-sm",children:[i.jsxs("div",{className:"flex gap-1",children:[i.jsx("span",{className:"bg-muted-foreground h-2 w-2 rounded-full",style:{animation:"typing-dot 1.4s ease-in-out infinite",animationDelay:"0s"}}),i.jsx("span",{className:"bg-muted-foreground h-2 w-2 rounded-full",style:{animation:"typing-dot 1.4s ease-in-out infinite",animationDelay:"0.2s"}}),i.jsx("span",{className:"bg-muted-foreground h-2 w-2 rounded-full",style:{animation:"typing-dot 1.4s ease-in-out infinite",animationDelay:"0.4s"}})]}),"Loading conversation..."]})}):e.length===0?i.jsx("div",{className:"flex h-full items-center justify-center",children:v?i.jsxs("div",{className:"flex flex-col items-center gap-4 text-center",children:[i.jsx(oe.div,{layoutId:"dorkbot-first-message",className:"bg-muted/50 w-full max-w-md rounded-lg border p-4","data-testid":"dorkbot-welcome-message",onLayoutAnimationComplete:()=>{k(null)},children:i.jsx("p",{className:"text-muted-foreground text-sm",children:v})}),i.jsx("p",{className:"text-muted-foreground/60 text-sm",children:"Type a message below to begin"})]}):i.jsxs("div",{className:"text-center",children:[i.jsx("p",{className:"text-muted-foreground text-base",children:"Start a conversation"}),i.jsx("p",{className:"text-muted-foreground/60 mt-2 text-sm",children:"Type a message below to begin"})]})}):i.jsx(Jrt,{ref:b,messages:e,sessionId:t,isTextStreaming:s,onScrollStateChange:l,activeToolCallId:c,onToolRef:u,focusedOptionIndex:f,onToolDecided:h,onRetry:m,inputZoneToolCallId:g}),i.jsx(He,{children:a&&!r&&i.jsx(oe.button,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,y:4},transition:{duration:.2},onClick:o,className:"bg-foreground text-background hover:bg-foreground/90 absolute bottom-16 left-1/2 z-10 -translate-x-1/2 cursor-pointer rounded-full px-3 py-1.5 text-xs font-medium shadow-sm transition-colors",role:"status","aria-live":"polite",children:"New messages"})}),i.jsx(He,{children:!r&&e.length>0&&!n&&i.jsx(oe.button,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},transition:{duration:.15},onClick:o,className:"bg-background absolute right-4 bottom-4 rounded-full border p-2 shadow-sm transition-shadow hover:shadow-md","aria-label":"Scroll to bottom",children:i.jsx(qk,{className:"size-(--size-icon-md)"})})})]})}const tat=500;function nat({textareaRef:e,value:t,isStreaming:n,isMobile:s,sessionBusy:r,editingQueueItem:a,isPaletteOpen:o,queueHasItems:l,onSubmit:c,onStop:u,onEscape:f,onClear:h,onArrowUp:m,onArrowDown:g,onCommandSelect:b,onQueue:v,onSaveEdit:k,onCancelEdit:w,onQueueNavigateUp:C,onQueueNavigateDown:E}){const T=x.useRef(0);return x.useCallback(j=>{if(j.key==="Escape"&&n){u==null||u();return}if(j.key==="Escape"&&a){w==null||w();return}if(j.key==="Escape"){const R=Date.now();o?(f==null||f(),T.current=R):t.trim()&&R-T.current<tat?(h==null||h(),T.current=0):(f==null||f(),T.current=R);return}if(!o&&l){if(j.key==="ArrowUp"){const R=e.current,D=!R||R.selectionStart===0;if(!t.trim()||D){j.preventDefault(),C==null||C();return}}if(j.key==="ArrowDown"){const R=e.current,D=!R||R.selectionStart===R.value.length;if(a&&D){j.preventDefault(),E==null||E();return}}}if(o){if(j.key==="ArrowDown"){j.preventDefault(),g==null||g();return}if(j.key==="ArrowUp"){j.preventDefault(),m==null||m();return}if(j.key==="Enter"&&!j.shiftKey||j.key==="Tab"){j.preventDefault(),b==null||b();return}}j.key==="Enter"&&!j.shiftKey&&!s&&(j.preventDefault(),a&&t.trim()?k==null||k():n&&t.trim()?v==null||v():!n&&!r&&t.trim()&&c())},[n,s,t,c,u,f,h,o,m,g,b,a,v,k,w,l,C,E,r,e])}const sat=200,W$=24;function rat(e,t){const n=x.useCallback(()=>{const s=e.current;s&&(s.style.height="auto",s.style.height=`${Math.min(s.scrollHeight,sat)}px`)},[e]);return x.useEffect(()=>{const s=e.current;if(!s||t!=="")return;const r=s.scrollHeight;if(r<=W$)return;s.style.height=`${r}px`,s.style.transition="height 200ms ease",requestAnimationFrame(()=>{s.style.height=`${W$}px`});const a=()=>{s.style.transition="",s.style.height=""};return s.addEventListener("transitionend",a,{once:!0}),()=>s.removeEventListener("transitionend",a)},[e,t]),n}const fj={send:{icon:null,className:"bg-primary text-primary-foreground hover:bg-primary/90",label:"Send message"},stop:{icon:$X,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",label:"Stop generating"},queue:{icon:Ja,className:"bg-muted text-muted-foreground hover:bg-muted/80",label:"Queue message"},update:{icon:Zt,className:"bg-primary text-primary-foreground hover:bg-primary/90",label:"Save edit"}};function aat(e,t,n,s){return s&&e?"update":t&&e?"queue":t?"stop":e&&!n?"send":null}function iat({hasText:e,isStreaming:t,isUploading:n,sessionBusy:s,editingQueueItem:r,queueDepth:a,isMobile:o,onSubmit:l,onStop:c,onQueue:u,onSaveEdit:f}){const h=aat(e,t,n,r),m=o?Gk:iEe,g=h==="send"?l:h==="stop"?c:h==="queue"?u:h==="update"?f:void 0;return i.jsxs(i.Fragment,{children:[t&&e&&i.jsx(oe.button,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{duration:.15},whileHover:{scale:1.1},whileTap:{scale:.9},onClick:c,type:"button",className:"bg-destructive text-destructive-foreground hover:bg-destructive/90 shrink-0 rounded-lg p-1.5 transition-colors max-md:p-2","aria-label":"Stop generating",children:i.jsx($X,{className:"size-(--size-icon-sm)"})}),h&&i.jsxs("div",{className:"relative",children:[i.jsx(oe.button,{animate:{opacity:1,scale:1},transition:{duration:.15},whileHover:s?void 0:{scale:1.1},whileTap:s?void 0:{scale:.9},onClick:g,disabled:h==="send"&&s,className:X("shrink-0 rounded-lg p-1.5 transition-colors max-md:p-2",fj[h].className,h==="send"&&s&&"pointer-events-none opacity-50"),"aria-label":fj[h].label,children:h==="send"?i.jsx(m,{className:"size-(--size-icon-sm)"}):(()=>{const b=fj[h].icon;return i.jsx(b,{className:"size-(--size-icon-sm)"})})()}),a>0&&h==="queue"&&i.jsx("span",{className:"bg-foreground text-background absolute -top-1 -right-1 flex h-4 w-4 items-center justify-center rounded-full text-[10px] font-medium",children:a})]})]})}const oat=x.forwardRef(function({value:t,onChange:n,onSubmit:s,isStreaming:r,isUploading:a=!1,sessionBusy:o=!1,editingQueueItem:l=!1,queueDepth:c=0,onStop:u,onQueue:f,onSaveEdit:h,onCancelEdit:m,onEscape:g,onClear:b,isPaletteOpen:v,onArrowUp:k,onArrowDown:w,onCommandSelect:C,activeDescendantId:E,onCursorChange:T,onAttach:_,placeholder:j="Send a message...",placeholderOverlay:R,onQueueNavigateUp:D,onQueueNavigateDown:I,queueHasItems:O=!1},L){const B=x.useRef(null),H=x.useRef(null),[K,U]=x.useState(!1),$=Zs();x.useImperativeHandle(L,()=>({focus:()=>{var Q;return(Q=B.current)==null?void 0:Q.focus()},focusAt:Q=>{const re=B.current;re&&(re.focus(),re.setSelectionRange(Q,Q))}})),x.useEffect(()=>{var Q;(Q=B.current)==null||Q.focus()},[]);const q=nat({textareaRef:B,value:t,isStreaming:r,isMobile:$,sessionBusy:o,editingQueueItem:l,isPaletteOpen:v,queueHasItems:O,onSubmit:s,onStop:u,onEscape:g,onClear:b,onArrowUp:k,onArrowDown:w,onCommandSelect:C,onQueue:f,onSaveEdit:h,onCancelEdit:m,onQueueNavigateUp:D,onQueueNavigateDown:I}),J=rat(B,t),ne=x.useCallback(()=>U(!0),[]),F=x.useCallback(()=>{U(!1),v&&(g==null||g())},[v,g]),V=x.useCallback(Q=>{n(Q.target.value),T==null||T(Q.target.selectionStart),J()},[n,T,J]),G=x.useCallback(()=>{B.current&&(T==null||T(B.current.selectionStart))},[T]),P=t.trim().length>0,Z=P&&!o;return i.jsxs("div",{className:"flex flex-col gap-1.5",children:[o&&i.jsx("div",{className:"px-1 text-xs text-amber-600 dark:text-amber-500",children:"Session is busy. Please wait..."}),l&&i.jsxs("div",{className:"text-muted-foreground px-0.5 text-xs",children:["Editing message",c>0?" —":""]}),i.jsxs("div",{className:X("border-input bg-background flex items-end gap-1.5 rounded-md border p-1.5 shadow-xs transition-[color,box-shadow]",K&&"border-ring ring-ring/75 ring-[1px]",l&&"border-primary/40",!_&&"pl-3"),children:[_&&i.jsxs(i.Fragment,{children:[i.jsx("input",{ref:H,type:"file",className:"hidden",multiple:!0,onChange:Q=>{const re=Array.from(Q.target.files??[]);re.length>0&&_(re),Q.target.value=""}}),i.jsx("button",{type:"button",onClick:()=>{var Q;return(Q=H.current)==null?void 0:Q.click()},className:"text-muted-foreground hover:text-foreground flex shrink-0 items-center justify-center rounded-md px-1.5 py-1 transition-colors disabled:opacity-50","aria-label":"Attach file",children:i.jsx(ITe,{className:"size-4"})})]}),i.jsxs("div",{className:"relative min-h-[24px] flex-1",children:[!P&&R,i.jsx("textarea",{ref:B,value:t,onChange:V,onKeyDown:q,onFocus:ne,onBlur:F,onSelect:G,role:"combobox","aria-autocomplete":"list","aria-controls":v?E!=null&&E.startsWith("file-")?"file-palette-listbox":"command-palette-listbox":void 0,"aria-expanded":v??!1,"aria-activedescendant":v?E:void 0,"aria-label":j,placeholder:R?"":j,className:"block max-h-[200px] min-h-[24px] w-full resize-none bg-transparent py-0.5 text-sm focus:outline-none",rows:1,disabled:o})]}),i.jsx(oe.button,{animate:{opacity:Z?.5:0,scale:Z?1:.8},transition:{duration:.15},whileHover:Z?{opacity:1}:void 0,onClick:b,disabled:!Z,type:"button",className:X("text-muted-foreground hover:text-foreground shrink-0 rounded-lg p-1 transition-colors",!Z&&"pointer-events-none"),"aria-label":"Clear message",children:i.jsx(ls,{className:"size-(--size-icon-sm)"})}),i.jsx(iat,{hasText:P,isStreaming:r,isUploading:a,sessionBusy:o,editingQueueItem:l,queueDepth:c,isMobile:$,onSubmit:s,onStop:u,onQueue:f,onSaveEdit:h})]})]})});function lat({sessionId:e,pendingApprovals:t,onAllDecided:n}){const s=Fe(),[r,a]=x.useState(!1),o=x.useCallback(async()=>{if(!r){a(!0);try{const c=t.map(u=>u.toolCallId);await s.batchApprove(e,c),n==null||n()}catch(c){console.error("Batch approve failed:",c)}finally{a(!1)}}},[r,s,e,t,n]),l=x.useCallback(async()=>{if(!r){a(!0);try{const c=t.map(u=>u.toolCallId);await s.batchDeny(e,c),n==null||n()}catch(c){console.error("Batch deny failed:",c)}finally{a(!1)}}},[r,s,e,t,n]);return t.length<2?null:i.jsxs("div",{className:"border-border bg-muted/50 mb-1.5 flex items-center justify-between rounded-lg border px-3 py-1.5",children:[i.jsxs("span",{className:"text-muted-foreground text-xs",children:[t.length," tools awaiting approval"]}),i.jsxs("div",{className:"flex gap-1.5",children:[i.jsxs(ve,{size:"xs",variant:"outline",onClick:o,disabled:r,children:[i.jsx(BCe,{className:"size-3"})," Approve All"]}),i.jsxs(ve,{size:"xs",variant:"ghost",onClick:l,disabled:r,children:[i.jsx(Vm,{className:"size-3"})," Deny All"]})]})]})}function cat({sessionId:e,activeInteraction:t,pendingApprovals:n,focusedOptionIndex:s,onToolRef:r,onToolDecided:a}){const o=l=>a(t.toolCallId,l);return i.jsxs(i.Fragment,{children:[i.jsx(lat,{sessionId:e,pendingApprovals:n}),t.interactiveType==="approval"?i.jsx(Die,{ref:r,sessionId:e,toolCallId:t.toolCallId,toolName:t.toolName,input:t.input||"",isActive:!0,onDecided:o,timeoutMs:t.timeoutMs,approvalStartedAt:t.approvalStartedAt,approvalTitle:t.approvalTitle,approvalDisplayName:t.approvalDisplayName,approvalDescription:t.approvalDescription,approvalBlockedPath:t.approvalBlockedPath,approvalDecisionReason:t.approvalDecisionReason,approvalHasSuggestions:t.approvalHasSuggestions}):t.interactiveType==="question"&&t.questions?i.jsx(Oie,{ref:r,sessionId:e,toolCallId:t.toolCallId,questions:t.questions,answers:t.answers,isActive:!0,focusedOptionIndex:s,onDecided:o}):null]})}const Y$=e=>Symbol.iterator in e,Z$=e=>"entries"in e,X$=(e,t)=>{const n=e instanceof Map?e:new Map(e.entries()),s=t instanceof Map?t:new Map(t.entries());if(n.size!==s.size)return!1;for(const[r,a]of n)if(!s.has(r)||!Object.is(a,s.get(r)))return!1;return!0},uat=(e,t)=>{const n=e[Symbol.iterator](),s=t[Symbol.iterator]();let r=n.next(),a=s.next();for(;!r.done&&!a.done;){if(!Object.is(r.value,a.value))return!1;r=n.next(),a=s.next()}return!!r.done&&!!a.done};function dat(e,t){return Object.is(e,t)?!0:typeof e!="object"||e===null||typeof t!="object"||t===null||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:Y$(e)&&Y$(t)?Z$(e)&&Z$(t)?X$(e,t):uat(e,t):X$({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function fat(e){const t=he.useRef(void 0);return n=>{const s=e(n);return dat(t.current,s)?t.current:t.current=s}}function hat(e){const t=e.contextUsage;return!t||t.maxTokens<=0?null:Math.min(100,Math.round(t.totalTokens/t.maxTokens*100))}function pat(e){var n;const t=e.cacheStats;return!t||t.cacheReadTokens===0&&t.cacheCreationTokens===0?null:{cacheReadTokens:t.cacheReadTokens,cacheCreationTokens:t.cacheCreationTokens,contextTokens:(n=e.contextUsage)==null?void 0:n.totalTokens}}function mat(e){return e?{contextPercent:hat(e),costUsd:e.cost,model:e.model,cacheStatus:pat(e)}:{contextPercent:null,costUsd:null,model:null,cacheStatus:null}}function gat({children:e,onSwitchAgent:t,onOpenProfile:n,onNewSession:s}){return i.jsxs(qee,{children:[i.jsx(Gee,{children:e}),i.jsxs(Kee,{className:"w-48",children:[i.jsxs(ux,{onClick:t,children:[i.jsx(vCe,{className:"mr-2 size-4"}),"Switch agent"]}),i.jsx(dR,{}),i.jsxs(ux,{onClick:n,children:[i.jsx(Zf,{className:"mr-2 size-4"}),"Agent profile"]}),i.jsx(dR,{}),i.jsxs(ux,{onClick:s,children:[i.jsx(Es,{className:"mr-2 size-4"}),"New session"]})]})]})}const xat=[{trigger:"/",label:"Commands",icon:tD,ariaLabel:"Insert slash command trigger"},{trigger:"@",label:"Files",icon:Z3,ariaLabel:"Insert file mention trigger"}];function Q$({onChipClick:e,agentName:t,agentColor:n,agentEmoji:s,agentPath:r}){const a=cs(),o=x.useCallback(()=>{r&&(Eu.getState().openHub(r),je.getState().setRightPanelOpen(!0),je.getState().setActiveRightPanelTab("agent-hub"))},[r]),l=x.useCallback(()=>{je.getState().openGlobalPaletteWithSearch("@")},[]),c=x.useCallback(()=>{a({to:"/session",search:{dir:r??void 0,session:crypto.randomUUID()}})},[a,r]),u=t&&n&&s;return i.jsxs(oe.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"mt-1.5 flex items-center justify-center gap-2 sm:justify-start",children:[u&&(r?i.jsx(gat,{onSwitchAgent:l,onOpenProfile:o,onNewSession:c,children:i.jsx(VR,{size:"xs",name:t,color:n,emoji:s,onClick:o})}):i.jsx(VR,{size:"xs",name:t,color:n,emoji:s})),xat.map(f=>i.jsxs("button",{type:"button","aria-label":f.ariaLabel,onClick:()=>e(f.trigger),className:"bg-secondary text-muted-foreground hover:text-foreground hover:bg-muted inline-flex items-center gap-1.5 rounded-md px-2.5 py-1 text-xs transition-colors duration-150",children:[i.jsx(f.icon,{className:"size-3"}),i.jsx("kbd",{className:"font-mono text-[10px] opacity-60",children:f.trigger}),f.label]},f.trigger))]})}function yat({collapsed:e,onToggle:t}){return i.jsx("div",{role:"button",tabIndex:0,"aria-label":e?"Expand input extras":"Collapse input extras",onClick:t,onKeyDown:n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),t())},className:"flex h-6 w-full cursor-pointer items-center justify-center",children:i.jsx("div",{className:"bg-muted-foreground/30 hover:bg-muted-foreground/50 active:bg-muted-foreground/50 h-1 w-9 rounded-full transition-colors"})})}function fo({itemLabel:e,onHide:t,onConfigure:n,children:s}){return i.jsxs(wC,{children:[i.jsx(kC,{className:"inline-flex items-center",children:s}),i.jsxs(CC,{children:[e&&t&&i.jsxs(i.Fragment,{children:[i.jsxs(Ml,{onClick:t,children:["Hide “",e,"”"]}),i.jsx(pw,{})]}),i.jsx(Ml,{onClick:n,children:"Configure status bar..."}),i.jsx(Ml,{onClick:aE,children:"Reset to defaults"})]})]})}function ho(e){var t;return((t=mb.find(n=>n.key===e))==null?void 0:t.label)??null}const J$=80,eH=500;function bat({sessionId:e,sessionStatus:t,isStreaming:n,onChipClick:s,syncConnectionState:r,agentName:a,agentColor:o,agentEmoji:l,agentPath:c}){var Ye;const u=Zs(),f=aQ(e,t,n),{showShortcutChips:h,showStatusBarCwd:m,setShowStatusBarCwd:g,showStatusBarPermission:b,setShowStatusBarPermission:v,showStatusBarModel:k,setShowStatusBarModel:w,showStatusBarCost:C,setShowStatusBarCost:E,showStatusBarContext:T,setShowStatusBarContext:_,showStatusBarCache:j,setShowStatusBarCache:R,showStatusBarUsage:D,setShowStatusBarUsage:I,showStatusBarGit:O,setShowStatusBarGit:L,showStatusBarSound:B,setShowStatusBarSound:H,showStatusBarPolling:K,setShowStatusBarPolling:U,enableNotificationSound:$,setEnableNotificationSound:q,enableMessagePolling:J,setEnableMessagePolling:ne}=je(),F=XNe(e),V=mat(F),G=kn(x.useCallback(Ge=>{var et;return((et=Ge.sessions[e])==null?void 0:et.contextUsage)??null},[e])),P=kn(x.useCallback(Ge=>{var et;return((et=Ge.sessions[e])==null?void 0:et.usageInfo)??null},[e])),Z=kn(fat(Ge=>{var nn;const et=(nn=Ge.sessions[e])==null?void 0:nn.sessionStatus;return!(et!=null&&et.cacheReadTokens)&&!(et!=null&&et.cacheCreationTokens)?null:{cacheReadTokens:et.cacheReadTokens??0,cacheCreationTokens:et.cacheCreationTokens??0,contextTokens:et.contextTokens}})),Q=V.cacheStatus??Z,re=V.contextPercent??f.contextPercent,ae=V.costUsd??f.costUsd,{data:de}=WKe(f.cwd),{data:pe}=SNe(e),{data:Oe}=aD(e||void 0),Ve=((Ye=Oe==null?void 0:Oe.find(Ge=>Ge.value===f.model))==null?void 0:Ye.supportsAutoMode)??!1,$e=BNe(e),Qe=kn(Ge=>Ge.recordAutoConfirmed),[Se,Ze]=x.useState(!1),bt=x.useCallback(Ge=>{if(Ge==="auto"&&!$e){Ze(!0);return}f.updateSession({permissionMode:Ge})},[$e,f]),Me=x.useCallback(()=>{Qe(e),f.updateSession({permissionMode:"auto"}),Ze(!1)},[Qe,e,f]),[Ie,Te]=x.useState(!1),[Je,_t]=x.useState(!1),[St,Gt]=x.useState(()=>u?parseInt(localStorage.getItem(Gn.GESTURE_HINT_COUNT)||"0",10)<3:!1);x.useEffect(()=>{if(!St)return;const Ge=setTimeout(()=>{Gt(!1);const et=parseInt(localStorage.getItem(Gn.GESTURE_HINT_COUNT)||"0",10);localStorage.setItem(Gn.GESTURE_HINT_COUNT,String(et+1))},Yi.GESTURE_HINT_DISMISS_MS);return()=>clearTimeout(Ge)},[St]);const Kt=x.useCallback(()=>{Gt(!1);const Ge=parseInt(localStorage.getItem(Gn.GESTURE_HINT_COUNT)||"0",10);localStorage.setItem(Gn.GESTURE_HINT_COUNT,String(Ge+1))},[]),Ae=(Ge,et)=>{const{offset:nn,velocity:Cn}=et;nn.y>J$||Cn.y>eH?_t(!0):(nn.y<-J$||Cn.y<-eH)&&_t(!1)},ce=i.jsx(eb,{children:i.jsxs(Kn,{children:[i.jsx(mae,{open:Ie,onOpenChange:Te,children:i.jsx(Wn,{asChild:!0,children:i.jsx("button",{type:"button","aria-label":"Configure status bar",className:"text-muted-foreground/50 hover:text-muted-foreground inline-flex shrink-0 items-center transition-colors duration-150",children:i.jsx(k_e,{className:"size-3"})})})}),i.jsx(Yn,{side:"top",children:i.jsx("p",{children:"Configure status bar"})})]})}),Ee=i.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[i.jsxs(wC,{children:[i.jsx(kC,{className:"min-w-0 flex-1",children:i.jsxs(La,{sessionId:e,isStreaming:n,children:[i.jsx(La.Item,{itemKey:"cwd",visible:m&&!!f.cwd,children:i.jsx(fo,{itemLabel:ho("cwd"),onHide:()=>g(!1),onConfigure:()=>Te(!0),children:f.cwd&&i.jsx(KKe,{cwd:f.cwd})})}),i.jsx(La.Item,{itemKey:"git",visible:O,children:i.jsx(fo,{itemLabel:ho("git"),onHide:()=>L(!1),onConfigure:()=>Te(!0),children:i.jsx(ZKe,{data:de})})}),i.jsx(La.Item,{itemKey:"permission",visible:b,children:i.jsx(fo,{itemLabel:ho("permission"),onHide:()=>v(!1),onConfigure:()=>Te(!0),children:i.jsx(nWe,{mode:f.permissionMode,onChangeMode:bt,disabled:!e,sessionId:e||void 0,modelSupportsAutoMode:Ve})})}),i.jsx(La.Item,{itemKey:"model",visible:k,children:i.jsx(fo,{itemLabel:ho("model"),onHide:()=>w(!1),onConfigure:()=>Te(!0),children:i.jsx(hWe,{model:f.model,onChangeModel:Ge=>f.updateSession({model:Ge}),effort:f.effort,onChangeEffort:Ge=>f.updateSession({effort:Ge??void 0}),fastMode:f.fastMode,onChangeFastMode:Ge=>f.updateSession({fastMode:Ge}),disabled:!e,sessionId:e||void 0})})}),i.jsx(La.Item,{itemKey:"cost",visible:C&&ae!==null,children:i.jsx(fo,{itemLabel:ho("cost"),onHide:()=>E(!1),onConfigure:()=>Te(!0),children:ae!==null&&i.jsx(pWe,{costUsd:ae})})}),i.jsx(La.Item,{itemKey:"cache",visible:j&&Q!==null,children:i.jsx(fo,{itemLabel:ho("cache"),onHide:()=>R(!1),onConfigure:()=>Te(!0),children:Q&&i.jsx(mWe,{cacheReadTokens:Q.cacheReadTokens,cacheCreationTokens:Q.cacheCreationTokens,contextTokens:Q.contextTokens})})}),i.jsx(La.Item,{itemKey:"context",visible:T&&re!==null,children:i.jsx(fo,{itemLabel:ho("context"),onHide:()=>_(!1),onConfigure:()=>Te(!0),children:re!==null&&i.jsx(gWe,{percent:re,contextUsage:G})})}),i.jsx(La.Item,{itemKey:"usage",visible:D&&P!==null,children:i.jsx(fo,{itemLabel:ho("usage"),onHide:()=>I(!1),onConfigure:()=>Te(!0),children:P&&i.jsx(yWe,{usageInfo:P})})}),i.jsx(La.Item,{itemKey:"sound",visible:B,children:i.jsx(fo,{itemLabel:ho("sound"),onHide:()=>H(!1),onConfigure:()=>Te(!0),children:i.jsx(bWe,{enabled:$,onToggle:()=>q(!$)})})}),i.jsx(La.Item,{itemKey:"polling",visible:K,children:i.jsx(fo,{itemLabel:ho("polling"),onHide:()=>U(!1),onConfigure:()=>Te(!0),children:i.jsx(vWe,{enabled:J,onToggle:()=>ne(!J)})})}),i.jsx(wWe,{connectionState:r}),i.jsx(La.Item,{itemKey:"subagents",visible:!!pe&&pe.length>0,children:pe&&pe.length>0&&i.jsx(CWe,{subagents:pe})})]})}),i.jsxs(CC,{children:[i.jsx(Ml,{onClick:()=>Te(!0),children:"Configure status bar..."}),i.jsx(Ml,{onClick:aE,children:"Reset to defaults"})]})]}),ce,i.jsx(sWe,{open:Se,onOpenChange:Ze,onConfirm:Me})]});return u?i.jsxs(i.Fragment,{children:[i.jsx(oe.div,{animate:St?{y:[0,8,0]}:void 0,transition:St?{duration:1.2,repeat:2}:void 0,children:i.jsx(yat,{collapsed:Je,onToggle:()=>_t(Ge=>!Ge)})}),i.jsx(He,{children:St&&i.jsx(oe.p,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:Kt,className:"text-muted-foreground cursor-pointer text-center text-xs",children:"Swipe to collapse"})}),i.jsx(He,{initial:!1,children:!Je&&i.jsxs(oe.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{type:"spring",stiffness:300,damping:30},className:"overflow-hidden",drag:"y",dragConstraints:{top:0,bottom:0},dragElastic:.2,onDragEnd:Ae,style:{touchAction:"pan-y"},children:[h&&i.jsx(Q$,{onChipClick:s,agentName:a,agentColor:o,agentEmoji:l,agentPath:c}),Ee]})})]}):i.jsxs(i.Fragment,{children:[i.jsx(He,{children:h&&i.jsx(Q$,{onChipClick:s,agentName:a,agentColor:o,agentEmoji:l,agentPath:c})}),Ee]})}function vat({color:e}){const t=[{bx:"-8px",by:"-10px",delay:"0s"},{bx:"8px",by:"-8px",delay:"0.03s"},{bx:"-6px",by:"6px",delay:"0.06s"},{bx:"10px",by:"4px",delay:"0.09s"},{bx:"0px",by:"-12px",delay:"0.04s"},{bx:"-10px",by:"0px",delay:"0.07s"},{bx:"6px",by:"10px",delay:"0.05s"},{bx:"-4px",by:"-6px",delay:"0.08s"}];return i.jsx("div",{className:"pointer-events-none absolute inset-0",children:t.map((n,s)=>i.jsx("span",{className:"absolute top-1/2 left-1/2 size-[3px] rounded-full",style:{backgroundColor:e,"--bx":n.bx,"--by":n.by,animation:`burst-particle 0.5s ease-out ${n.delay} forwards`}},s))})}function Sat({agent:e,index:t}){const n=x.useMemo(()=>({animationDelay:`${t*.09}s`}),[t]),[s,r]=x.useState("running"),a=x.useRef(e.status);return x.useEffect(()=>{if(a.current==="running"&&(e.status==="complete"||e.status==="error")&&s==="running"){r("celebrating");const o=setTimeout(()=>r("done"),350);return()=>clearTimeout(o)}a.current=e.status},[e.status,s]),s==="done"?i.jsx("div",{className:"relative inline-flex",children:e.status==="error"?i.jsxs("svg",{className:"check-appear h-6 w-[22px]",viewBox:"0 0 22 24",children:[i.jsx("circle",{cx:"11",cy:"12",r:"7",fill:"none",stroke:e.color,strokeWidth:"1.5",opacity:"0.3"}),i.jsx("line",{x1:"8",y1:"9",x2:"14",y2:"15",stroke:e.color,strokeWidth:"2",strokeLinecap:"round"}),i.jsx("line",{x1:"14",y1:"9",x2:"8",y2:"15",stroke:e.color,strokeWidth:"2",strokeLinecap:"round"})]}):i.jsxs("svg",{className:"check-appear h-6 w-[22px]",viewBox:"0 0 22 24",children:[i.jsx("circle",{cx:"11",cy:"12",r:"7",fill:"none",stroke:e.color,strokeWidth:"1.5",opacity:"0.3"}),i.jsx("polyline",{points:"7,12 10,15 15,9",fill:"none",stroke:e.color,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}):i.jsxs("div",{className:"group relative inline-flex",children:[i.jsx("svg",{className:"h-6 w-[22px] shrink-0",style:{"--c":e.color},viewBox:"0 0 22 24","aria-label":e.description,children:i.jsxs("g",{className:"r-all",style:n,children:[i.jsx("circle",{cx:"11",cy:"4.5",r:"2.8",fill:"var(--c)"}),i.jsx("circle",{cx:"12.3",cy:"3.7",r:"0.6",fill:"hsl(0 0% 100% / 0.7)"}),i.jsx("ellipse",{cx:"11",cy:"10.5",rx:"2.5",ry:"3.5",fill:"var(--c)"}),i.jsxs("g",{className:"r-rua",style:n,children:[i.jsx("line",{x1:"12",y1:"9",x2:"14",y2:"11",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"}),i.jsx("g",{className:"r-rfa",style:n,children:i.jsx("line",{x1:"14",y1:"11",x2:"14.5",y2:"13",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"})})]}),i.jsxs("g",{className:"r-lua",style:n,children:[i.jsx("line",{x1:"10",y1:"9",x2:"8",y2:"11",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"}),i.jsx("g",{className:"r-lfa",style:n,children:i.jsx("line",{x1:"8",y1:"11",x2:"7.5",y2:"13",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"})})]}),i.jsxs("g",{className:"r-rt",style:n,children:[i.jsx("line",{x1:"11",y1:"14",x2:"13",y2:"17",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"}),i.jsx("g",{className:"r-rs",style:n,children:i.jsx("line",{x1:"13",y1:"17",x2:"13.5",y2:"21",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"})})]}),i.jsxs("g",{className:"r-lt",style:n,children:[i.jsx("line",{x1:"11",y1:"14",x2:"9",y2:"17",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"}),i.jsx("g",{className:"r-ls",style:n,children:i.jsx("line",{x1:"9",y1:"17",x2:"8.5",y2:"21",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"})})]})]})}),s==="celebrating"&&i.jsx(vat,{color:e.color}),s==="running"&&i.jsxs("div",{className:X("pointer-events-none absolute bottom-[calc(100%+8px)] left-1/2","-translate-x-1/2 translate-y-1 opacity-0 transition-all duration-150","group-hover:translate-y-0 group-hover:opacity-100","border-border bg-popover z-10 rounded-lg border px-3 py-2 whitespace-nowrap","text-foreground text-[0.6875rem] shadow-lg"),children:[i.jsxs("div",{className:"mb-0.5 flex items-center gap-1.5 font-semibold",children:[i.jsx("div",{className:"size-1.5 shrink-0 rounded-full",style:{backgroundColor:e.color}}),e.description]}),i.jsxs("div",{className:"text-muted-foreground font-mono text-[0.625rem]",children:[e.toolUses??0," tool calls · ",Math.round((e.durationMs??0)/1e3),"s"]}),e.lastToolName&&i.jsxs("div",{className:"text-muted-foreground/60 mt-0.5 font-mono text-[0.5625rem]",children:["Last: ",e.lastToolName]}),i.jsx("div",{className:"border-t-border absolute top-full left-1/2 -translate-x-1/2 border-5 border-transparent"})]})]})}function wat({bashTasks:e}){const t=vr(),n=e.filter(r=>r.taskType==="bash"),s=n.length;return s===0?null:i.jsxs("div",{role:"status","aria-live":"polite","aria-label":`${s} bash task${s!==1?"s":""} running`,className:"flex items-center gap-1.5",children:[i.jsx(He,{mode:"popLayout",children:n.map(r=>i.jsxs(oe.div,{initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:{duration:.25},className:"relative flex size-3 items-center justify-center",children:[r.status==="running"&&!t&&i.jsx("span",{className:"task-dot-tasks absolute inset-0 rounded-full opacity-40",style:{backgroundColor:r.color,animation:"task-dot-tasks 2s ease-in-out infinite"}}),i.jsx("span",{className:"relative size-1.5 rounded-full",style:{backgroundColor:r.color}})]},r.taskId))}),i.jsxs("span",{className:"text-muted-foreground text-xs whitespace-nowrap",children:[s," task",s!==1?"s":""]})]})}const kat=3e3;function Cat({taskType:e,onConfirm:t}){const[n,s]=x.useState(!1),r=x.useRef(null);x.useEffect(()=>()=>{r.current&&clearTimeout(r.current)},[]),x.useEffect(()=>{if(n)return r.current=setTimeout(()=>{s(!1)},kat),()=>{r.current&&clearTimeout(r.current)}},[n]);const a=x.useCallback(()=>{if(e==="bash"){t();return}n?(r.current&&clearTimeout(r.current),s(!1),t()):s(!0)},[e,n,t]),o=x.useCallback(l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),a())},[a]);return i.jsx("button",{onClick:a,onKeyDown:o,className:X("flex shrink-0 items-center justify-center rounded transition-all duration-150","focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-1",n?"bg-destructive/20 text-destructive hover:bg-destructive/30 px-1.5 py-0.5 text-[0.625rem] font-medium":"text-muted-foreground/40 hover:text-destructive size-4"),"aria-label":n?"Confirm stop task":"Stop task",tabIndex:0,children:n?"Stop?":i.jsx(ls,{className:"size-3"})})}function Eat({task:e,onStop:t}){const n=e.taskType==="agent"?e.description??"Background agent":e.command??"Background task",s=e.durationMs?Math.round(e.durationMs/1e3):0,r=e.status==="running";return i.jsxs("div",{className:X("flex items-center gap-2 rounded-md px-2 py-1 text-xs",r?"bg-muted":"bg-muted/50 opacity-60"),children:[i.jsx("span",{className:"size-2 shrink-0 rounded-full",style:{backgroundColor:e.color}}),i.jsx("span",{className:"text-muted-foreground/60 shrink-0 text-[0.625rem] tracking-wider uppercase",children:e.taskType}),i.jsx("span",{className:"text-foreground min-w-0 flex-1 truncate",children:n}),e.taskType==="agent"&&e.toolUses!==void 0&&e.toolUses>0&&i.jsxs("span",{className:"text-muted-foreground/60 shrink-0 font-mono text-[0.625rem]",children:[e.toolUses," tools"]}),s>0&&i.jsxs("span",{className:"text-muted-foreground/60 shrink-0 font-mono text-[0.625rem]",children:[s,"s"]}),r&&i.jsx(Cat,{taskType:e.taskType,onConfirm:t})]})}function Tat({tasks:e,onStopTask:t}){return i.jsx(oe.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.25,ease:[.16,1,.3,1]},className:"border-border overflow-hidden border-t px-2 py-1.5",children:i.jsx("div",{className:"flex flex-col gap-1",children:e.map(n=>i.jsx(Eat,{task:n,onStop:()=>t(n.taskId)},n.taskId))})})}const wM=4,Lie=[.16,1,.3,1],_at={width:{duration:.4,ease:Lie},opacity:{duration:.25}};function Nat({tasks:e,onStopTask:t}){const[n,s]=x.useState(!1),r=vr(),a=e.filter(g=>g.taskType==="agent"),o=e.filter(g=>g.taskType==="bash"),l=e.length,c=a.slice(0,wM),u=a.length-wM,f=a.reduce((g,b)=>g+(b.toolUses??0),0),h=Math.max(0,...e.map(g=>Math.round((g.durationMs??0)/1e3))),m=r?{duration:0}:{duration:.35,ease:Lie};return i.jsx(He,{children:l>0&&i.jsxs(oe.div,{role:"status","aria-live":"polite","aria-label":`${l} background task${l!==1?"s":""} running`,initial:{opacity:0,y:6,maxHeight:0},animate:{opacity:1,y:0,maxHeight:n?400:44},exit:{opacity:0,maxHeight:0},transition:m,className:"border-border bg-card overflow-hidden rounded-lg border",children:[i.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5",children:[a.length>0&&i.jsx(jat,{visibleAgents:c,overflowAgentCount:u,allAgentTasks:a}),a.length>0&&o.length>0&&i.jsx("div",{className:"bg-border h-4 w-px shrink-0"}),o.length>0&&i.jsx(wat,{bashTasks:o}),i.jsxs("span",{className:"text-muted-foreground text-xs whitespace-nowrap",children:[i.jsx("strong",{className:"text-foreground font-semibold",children:l})," task",l!==1?"s":""," running"]}),i.jsxs("span",{className:"text-muted-foreground/60 ml-auto font-mono text-[0.6875rem] whitespace-nowrap",children:[f>0&&i.jsxs(i.Fragment,{children:[f," tools · "]}),h,"s"]}),i.jsxs("button",{type:"button",onClick:()=>s(g=>!g),className:"text-muted-foreground hover:text-foreground ml-1 flex shrink-0 items-center gap-1 transition-colors duration-150","aria-label":n?"Collapse task details":"Expand task details","aria-expanded":n,children:[i.jsx("span",{className:"text-[0.625rem] tabular-nums",children:l}),i.jsx(Ps,{className:X("size-3.5 transition-transform duration-200",n&&"rotate-180")})]})]}),i.jsx(He,{children:n&&i.jsx(Tat,{tasks:e,onStopTask:t})})]},"background-task-bar")})}function jat({visibleAgents:e,overflowAgentCount:t,allAgentTasks:n}){return i.jsxs("div",{className:"flex items-center gap-0",children:[i.jsx(He,{mode:"popLayout",children:e.map((s,r)=>i.jsx(oe.div,{initial:{width:0,opacity:0},animate:{width:22,opacity:1},exit:{width:0,opacity:0},transition:_at,className:"shrink-0",children:i.jsx(Sat,{agent:{taskId:s.taskId,description:s.description??"",status:s.status==="running"?"running":s.status==="complete"?"complete":"error",color:s.color,toolUses:s.toolUses,lastToolName:s.lastToolName,durationMs:s.durationMs,summary:s.summary},index:r})},s.taskId))}),t>0&&i.jsx(Aat,{count:t,overflowTasks:n.slice(wM)})]})}function Aat({count:e,overflowTasks:t}){return i.jsxs("div",{className:"group relative",children:[i.jsxs("div",{className:"text-muted-foreground bg-muted flex size-6 shrink-0 items-center justify-center rounded-full text-[0.625rem] font-semibold","aria-label":`${e} more agents running`,children:["+",e]}),i.jsxs("div",{className:X("pointer-events-none absolute bottom-[calc(100%+8px)] left-1/2","-translate-x-1/2 translate-y-1 opacity-0 transition-all duration-150","group-hover:translate-y-0 group-hover:opacity-100","border-border bg-popover z-10 rounded-lg border px-3 py-2 whitespace-nowrap","text-foreground text-[0.6875rem] shadow-lg"),children:[t.map(n=>i.jsxs("div",{className:"flex items-center gap-1.5 py-0.5",children:[i.jsx("div",{className:"size-1.5 shrink-0 rounded-full",style:{backgroundColor:n.color}}),i.jsx("span",{className:"text-[0.625rem]",children:n.description})]},n.taskId)),i.jsx("div",{className:"border-t-border absolute top-full left-1/2 -translate-x-1/2 border-5 border-transparent"})]})]})}const tH=["hsl(210 80% 60%)","hsl(150 60% 50%)","hsl(270 60% 65%)","hsl(36 90% 55%)","hsl(340 75% 60%)"],nH=5e3,Rat=1e3,Mat=1500;function Dat(e){const t=x.useRef(new Map),n=x.useRef(0),s=x.useRef(new Map),r=x.useRef(new Set),[,a]=x.useState(0),o=x.useMemo(()=>{const c=new Map;for(const u of e)for(const f of u.parts)f.type==="background_task"&&c.set(f.taskId,f);return c},[e]);x.useEffect(()=>{if(!Array.from(o.values()).some(f=>f.taskType==="bash"&&f.status==="running"&&Date.now()-f.startedAt<nH))return;const u=setInterval(()=>{a(f=>f+1)},Rat);return()=>clearInterval(u)},[o]);const l=x.useRef(new Set);for(const[c,u]of o){const f=s.current.get(c),h=u.status==="complete"||u.status==="error"||u.status==="stopped";f==="running"&&h&&!r.current.has(c)&&r.current.add(c),s.current.set(c,u.status)}return x.useEffect(()=>{for(const c of r.current)l.current.has(c)||(l.current.add(c),setTimeout(()=>{r.current.delete(c),l.current.delete(c),a(u=>u+1)},Mat))},[o]),x.useMemo(()=>{const c=Date.now(),u=[];for(const[f,h]of o){const m=h.status==="running",g=r.current.has(f);!m&&!g||h.taskType==="bash"&&m&&c-h.startedAt<nH||(t.current.has(f)||(t.current.set(f,tH[n.current%tH.length]),n.current+=1),u.push({taskId:h.taskId,taskType:h.taskType,status:h.status,color:t.current.get(f),startedAt:h.startedAt,description:h.description,toolUses:h.toolUses,lastToolName:h.lastToolName,durationMs:h.durationMs,summary:h.summary,command:h.command}))}return u},[o])}function Oat({status:e,sessionBusy:t,sessionId:n,selectedCwd:s,onFlush:r}){const a=eje(n??""),[o,l]=x.useState(null),c=x.useRef(r);c.current=r;const u=x.useRef(a);u.current=a;const f=x.useRef(o);f.current=o;const h=x.useRef("idle"),m=x.useRef(null);x.useEffect(()=>{const T=n===null?null:`${n}\0${s??""}`;if(m.current!==T&&(m.current=T,h.current="idle",l(null)),h.current==="streaming"&&e==="idle"&&n){const _=u.current,j=f.current;if(_.length>0&&!t){const R=j===0?_.length>1?1:null:0;if(R!==null){const D=_[R],I=`[Note: This message was composed while the agent was responding to the previous message]
|
|
1076
1076
|
|
|
1077
1077
|
${D.content}`;as.getState().removeQueuedMessage(n,D.id),j!==null&&j>R&&l(O=>O!==null?O-1:null),c.current(I,n)}}}h.current=e},[e,t,n,s]);const g=x.useCallback(T=>{!T.trim()||!n||as.getState().enqueueMessage(n,T)},[n]),b=x.useCallback((T,_)=>{const j=a[T];!j||!n||as.getState().updateQueuedMessage(n,j.id,_)},[a,n]),v=x.useCallback(T=>{const _=a[T];_&&n&&as.getState().removeQueuedMessage(n,_.id),l(j=>j===T?null:j!==null&&j>T?j-1:j)},[a,n]),k=x.useCallback(T=>{var _;return l(T),((_=a[T])==null?void 0:_.content)??""},[a]),w=x.useCallback(()=>{l(null)},[]),C=x.useCallback(T=>{o!==null&&(b(o,T),l(null))},[o,b]),E=x.useCallback(()=>{n&&as.getState().clearQueue(n),l(null)},[n]);return{queue:a,editingIndex:o,addToQueue:g,updateQueueItem:b,removeFromQueue:v,startEditing:k,cancelEditing:w,saveEditing:C,clearQueue:E}}function Iat({input:e,setInput:t,status:n,sessionBusy:s,sessionId:r,selectedCwd:a,onFlush:o,chatInputRef:l}){const c=x.useRef("");x.useEffect(()=>{c.current=""},[r]);const u=Oat({status:n,sessionBusy:s,sessionId:r,selectedCwd:a,onFlush:o}),f=x.useCallback(()=>{e.trim()&&(u.addToQueue(e.trim()),t(""))},[e,u,t]),h=x.useCallback(w=>{var E;u.editingIndex===null&&(c.current=e);const C=u.startEditing(w);t(C),(E=l.current)==null||E.focus()},[e,u,t,l]),m=x.useCallback(()=>{u.editingIndex!==null&&e.trim()&&(u.saveEditing(e.trim()),t(c.current))},[e,u,t]),g=x.useCallback(()=>{u.cancelEditing(),t(c.current)},[u,t]),b=x.useCallback(w=>{u.editingIndex===w&&t(c.current),u.removeFromQueue(w)},[u,t]),v=x.useCallback(()=>{if(u.editingIndex===null){c.current=e;const w=u.startEditing(u.queue.length-1);t(w)}else if(u.editingIndex>0){const w=u.startEditing(u.editingIndex-1);t(w)}else u.cancelEditing(),t(c.current)},[e,u,t]),k=x.useCallback(()=>{if(u.editingIndex!==null)if(u.editingIndex<u.queue.length-1){const w=u.startEditing(u.editingIndex+1);t(w)}else u.cancelEditing(),t(c.current)},[u,t]);return{queue:u.queue,editingIndex:u.editingIndex,handleQueue:f,handleQueueEdit:h,handleQueueSaveEdit:m,handleQueueCancelEdit:g,handleQueueRemove:b,handleQueueNavigateUp:v,handleQueueNavigateDown:k}}function Pat(e){return e.type.startsWith("image/")}function Lat({files:e,onRemove:t}){const n=x.useMemo(()=>{const s=new Map;for(const r of e)Pat(r.file)&&s.set(r.id,URL.createObjectURL(r.file));return s},[e]);return x.useEffect(()=>()=>{for(const s of n.values())URL.revokeObjectURL(s)},[n]),i.jsx("div",{className:"flex flex-wrap gap-1.5 px-1 pb-1.5",children:i.jsx(He,{children:e.map(s=>{const r=n.get(s.id);return i.jsxs(oe.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{duration:.15},className:"bg-muted flex items-center gap-1 rounded-md px-2 py-1 text-xs",children:[s.status==="uploading"?i.jsx(Xn,{className:"text-muted-foreground size-3 animate-spin"}):s.status==="error"?i.jsx(Wk,{className:"text-destructive size-3"}):r?i.jsx("img",{src:r,alt:"",className:"size-5 shrink-0 rounded object-cover"}):i.jsx(By,{className:"text-muted-foreground size-3"}),i.jsx("span",{className:"max-w-32 truncate",children:s.file.name}),s.status==="uploading"&&i.jsxs("span",{className:"text-muted-foreground tabular-nums",children:[s.progress,"%"]}),i.jsx("button",{type:"button",onClick:()=>t(s.id),className:"text-muted-foreground hover:text-foreground -mr-0.5 ml-0.5 rounded-sm p-0.5","aria-label":`Remove ${s.file.name}`,children:i.jsx(ls,{className:"size-3"})})]},s.id)})})})}function Fat({queue:e,editingIndex:t,onEdit:n,onRemove:s}){return e.length===0?null:i.jsxs(oe.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.2},className:"mb-1.5 overflow-hidden",children:[i.jsxs("div",{className:"text-muted-foreground mb-1 text-xs font-medium",children:["Queued (",e.length,")"]}),i.jsx("div",{className:"space-y-0.5",children:i.jsx(He,{mode:"popLayout",children:e.map((r,a)=>i.jsx(oe.div,{initial:{opacity:0,y:-4},animate:{opacity:1,y:0,transition:{type:"spring",stiffness:320,damping:28}},exit:{opacity:0,scale:.95,transition:{duration:.15}},layout:!0,children:i.jsxs("button",{type:"button",onClick:()=>n(a),className:X("group flex w-full items-center gap-2 rounded-md px-3 py-1.5 text-left transition-colors",t===a?"border-primary bg-muted border-l-2":"hover:bg-muted/50"),children:[i.jsxs("span",{className:"text-muted-foreground shrink-0 text-xs font-medium",children:[a+1,"."]}),i.jsx("span",{className:"text-muted-foreground line-clamp-1 flex-1 text-sm",children:r.content}),i.jsx("span",{role:"button",tabIndex:0,onClick:o=>{o.stopPropagation(),s(a)},onKeyDown:o=>{(o.key==="Enter"||o.key===" ")&&(o.stopPropagation(),o.preventDefault(),s(a))},className:"text-muted-foreground hover:text-foreground shrink-0 rounded-sm p-0.5 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100","aria-label":`Remove queued message ${a+1}`,children:i.jsx(ls,{className:"size-3"})})]})},r.id))})})]})}function zat({filteredCommands:e,selectedIndex:t,onSelect:n}){const s=x.useMemo(()=>{const r=[],a=new Map;let o=0;for(const l of e){const c=l.namespace??"built-in";a.has(c)||a.set(c,[]),a.get(c).push({cmd:l,index:o++})}for(const[l,c]of a)r.push({namespace:l,items:c});return r},[e]);return x.useEffect(()=>{const r=document.getElementById(`command-item-${t}`);r&&r.scrollIntoView({block:"nearest"})},[t]),i.jsx(oe.div,{initial:{opacity:0,scale:.98,y:4},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.98,y:4},transition:{duration:.15,ease:[0,0,.2,1]},className:"bg-popover max-h-80 overflow-hidden rounded-lg border shadow-lg",onMouseDown:r=>r.preventDefault(),children:i.jsx("div",{id:"command-palette-listbox",role:"listbox",className:"max-h-72 overflow-y-auto p-1.5",children:e.length===0?i.jsx("div",{className:"text-muted-foreground px-2 py-4 text-center text-sm",children:"No commands found."}):s.map(({namespace:r,items:a},o)=>i.jsxs("div",{children:[o>0&&i.jsx("div",{className:"bg-border mx-2 my-1.5 h-px"}),i.jsx("div",{className:"text-muted-foreground/70 px-2 pt-1.5 pb-1 text-[11px] font-medium tracking-wide uppercase",children:r}),a.map(({cmd:l,index:c})=>{const u=c===t;return i.jsxs("div",{id:`command-item-${c}`,role:"option","aria-selected":u,"data-selected":u,tabIndex:u?0:-1,onClick:()=>n(l),onKeyDown:f=>{f.key==="Enter"&&n(l)},className:"data-[selected=true]:bg-accent hover:bg-muted cursor-pointer rounded-md px-2 py-1.5 transition-colors duration-100",children:[i.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[i.jsx("span",{className:"text-foreground shrink-0 font-mono text-[13px] font-medium",children:l.fullCommand}),l.argumentHint&&i.jsx("span",{className:"text-muted-foreground/50 shrink-0 font-mono text-xs",children:l.argumentHint})]}),l.description&&i.jsx("p",{className:"text-muted-foreground mt-0.5 truncate text-xs leading-normal",children:l.description})]},l.fullCommand)})]},r))})})}function Bat({text:e,indices:t,startOffset:n=0}){const s=new Set(t.map(r=>r-n));return i.jsx(i.Fragment,{children:e.split("").map((r,a)=>s.has(a)?i.jsx("span",{className:"text-foreground font-semibold",children:r},a):i.jsx("span",{children:r},a))})}function $at({filteredFiles:e,selectedIndex:t,onSelect:n}){return x.useEffect(()=>{const s=document.getElementById(`file-item-${t}`);s&&s.scrollIntoView({block:"nearest"})},[t]),i.jsx(oe.div,{initial:{opacity:0,scale:.98,y:4},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.98,y:4},transition:{duration:.15,ease:[0,0,.2,1]},className:"bg-popover max-h-80 overflow-hidden rounded-lg border shadow-lg",onMouseDown:s=>s.preventDefault(),children:i.jsx("div",{id:"file-palette-listbox",role:"listbox",className:"max-h-72 overflow-y-auto p-1.5",children:e.length===0?i.jsx("div",{className:"text-muted-foreground px-2 py-4 text-center text-sm",children:"No files found."}):e.map((s,r)=>{const a=r===t,o=s.isDirectory?Gp:By;return i.jsxs("div",{id:`file-item-${r}`,role:"option","aria-selected":a,"data-selected":a,tabIndex:a?0:-1,onClick:()=>n(s),onKeyDown:l=>{l.key==="Enter"&&n(s)},className:"data-[selected=true]:bg-accent hover:bg-muted flex cursor-pointer items-start gap-2 rounded-md px-2 py-1.5 transition-colors duration-100",children:[i.jsx(o,{className:"text-muted-foreground mt-0.5 size-4 shrink-0"}),i.jsxs("div",{className:"min-w-0",children:[i.jsx("span",{className:"text-foreground truncate text-sm font-medium",children:i.jsx(Bat,{text:s.filename,indices:s.indices,startOffset:s.directory.length})}),s.directory&&i.jsx("p",{className:"text-muted-foreground/70 truncate text-xs leading-normal",children:s.directory})]})]},s.path)})})})}function Hat(e){const t=Fe();return mt({queryKey:["files",{cwd:e??null}],queryFn:()=>t.listFiles(e),enabled:!!e,staleTime:Va.FILES_STALE_TIME_MS,gcTime:Va.FILES_GC_TIME_MS})}const Uat=5e3;function Vat(e){const t=[...e];for(let n=t.length-1;n>0;n--){const s=Math.floor(Math.random()*(n+1));[t[n],t[s]]=[t[s],t[n]]}return t}function qat({defaultText:e,hints:t,enabled:n,intervalMs:s=Uat}){const[r,a]=x.useState(0),[o]=x.useState(()=>t.length>0?Vat(t):[]);x.useEffect(()=>{if(!n||t.length===0){a(0);return}const f=setInterval(()=>a(h=>h+1),s);return()=>clearInterval(f)},[n,t.length,s]);const l=r>0&&r%2===1,c=Math.floor(r/2)%(o.length||1);return{text:l?o[c]??e:e,key:r,isHint:l}}const Gat={initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4}},Kat={duration:.3,ease:"easeInOut"};function Wat({text:e,animationKey:t}){return i.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-start overflow-hidden py-0.5",children:i.jsx(He,{mode:"wait",children:i.jsx(oe.span,{variants:Gat,initial:"initial",animate:"animate",exit:"exit",transition:Kat,className:"text-muted-foreground truncate text-sm",children:e},t)})})}const Yat=["Type @ to mention a file","Type / to browse commands","Shift+Enter for a new line","Drop or paste files to attach","Press Esc twice to clear"];var Zat=pO();const qn=eo(Zat),Xat=new Map([["1km","application/vnd.1000minds.decision-model+xml"],["3dml","text/vnd.in3d.3dml"],["3ds","image/x-3ds"],["3g2","video/3gpp2"],["3gp","video/3gp"],["3gpp","video/3gpp"],["3mf","model/3mf"],["7z","application/x-7z-compressed"],["7zip","application/x-7z-compressed"],["123","application/vnd.lotus-1-2-3"],["aab","application/x-authorware-bin"],["aac","audio/x-acc"],["aam","application/x-authorware-map"],["aas","application/x-authorware-seg"],["abw","application/x-abiword"],["ac","application/vnd.nokia.n-gage.ac+xml"],["ac3","audio/ac3"],["acc","application/vnd.americandynamics.acc"],["ace","application/x-ace-compressed"],["acu","application/vnd.acucobol"],["acutc","application/vnd.acucorp"],["adp","audio/adpcm"],["aep","application/vnd.audiograph"],["afm","application/x-font-type1"],["afp","application/vnd.ibm.modcap"],["ahead","application/vnd.ahead.space"],["ai","application/pdf"],["aif","audio/x-aiff"],["aifc","audio/x-aiff"],["aiff","audio/x-aiff"],["air","application/vnd.adobe.air-application-installer-package+zip"],["ait","application/vnd.dvb.ait"],["ami","application/vnd.amiga.ami"],["amr","audio/amr"],["apk","application/vnd.android.package-archive"],["apng","image/apng"],["appcache","text/cache-manifest"],["application","application/x-ms-application"],["apr","application/vnd.lotus-approach"],["arc","application/x-freearc"],["arj","application/x-arj"],["asc","application/pgp-signature"],["asf","video/x-ms-asf"],["asm","text/x-asm"],["aso","application/vnd.accpac.simply.aso"],["asx","video/x-ms-asf"],["atc","application/vnd.acucorp"],["atom","application/atom+xml"],["atomcat","application/atomcat+xml"],["atomdeleted","application/atomdeleted+xml"],["atomsvc","application/atomsvc+xml"],["atx","application/vnd.antix.game-component"],["au","audio/x-au"],["avi","video/x-msvideo"],["avif","image/avif"],["aw","application/applixware"],["azf","application/vnd.airzip.filesecure.azf"],["azs","application/vnd.airzip.filesecure.azs"],["azv","image/vnd.airzip.accelerator.azv"],["azw","application/vnd.amazon.ebook"],["b16","image/vnd.pco.b16"],["bat","application/x-msdownload"],["bcpio","application/x-bcpio"],["bdf","application/x-font-bdf"],["bdm","application/vnd.syncml.dm+wbxml"],["bdoc","application/x-bdoc"],["bed","application/vnd.realvnc.bed"],["bh2","application/vnd.fujitsu.oasysprs"],["bin","application/octet-stream"],["blb","application/x-blorb"],["blorb","application/x-blorb"],["bmi","application/vnd.bmi"],["bmml","application/vnd.balsamiq.bmml+xml"],["bmp","image/bmp"],["book","application/vnd.framemaker"],["box","application/vnd.previewsystems.box"],["boz","application/x-bzip2"],["bpk","application/octet-stream"],["bpmn","application/octet-stream"],["bsp","model/vnd.valve.source.compiled-map"],["btif","image/prs.btif"],["buffer","application/octet-stream"],["bz","application/x-bzip"],["bz2","application/x-bzip2"],["c","text/x-c"],["c4d","application/vnd.clonk.c4group"],["c4f","application/vnd.clonk.c4group"],["c4g","application/vnd.clonk.c4group"],["c4p","application/vnd.clonk.c4group"],["c4u","application/vnd.clonk.c4group"],["c11amc","application/vnd.cluetrust.cartomobile-config"],["c11amz","application/vnd.cluetrust.cartomobile-config-pkg"],["cab","application/vnd.ms-cab-compressed"],["caf","audio/x-caf"],["cap","application/vnd.tcpdump.pcap"],["car","application/vnd.curl.car"],["cat","application/vnd.ms-pki.seccat"],["cb7","application/x-cbr"],["cba","application/x-cbr"],["cbr","application/x-cbr"],["cbt","application/x-cbr"],["cbz","application/x-cbr"],["cc","text/x-c"],["cco","application/x-cocoa"],["cct","application/x-director"],["ccxml","application/ccxml+xml"],["cdbcmsg","application/vnd.contact.cmsg"],["cda","application/x-cdf"],["cdf","application/x-netcdf"],["cdfx","application/cdfx+xml"],["cdkey","application/vnd.mediastation.cdkey"],["cdmia","application/cdmi-capability"],["cdmic","application/cdmi-container"],["cdmid","application/cdmi-domain"],["cdmio","application/cdmi-object"],["cdmiq","application/cdmi-queue"],["cdr","application/cdr"],["cdx","chemical/x-cdx"],["cdxml","application/vnd.chemdraw+xml"],["cdy","application/vnd.cinderella"],["cer","application/pkix-cert"],["cfs","application/x-cfs-compressed"],["cgm","image/cgm"],["chat","application/x-chat"],["chm","application/vnd.ms-htmlhelp"],["chrt","application/vnd.kde.kchart"],["cif","chemical/x-cif"],["cii","application/vnd.anser-web-certificate-issue-initiation"],["cil","application/vnd.ms-artgalry"],["cjs","application/node"],["cla","application/vnd.claymore"],["class","application/octet-stream"],["clkk","application/vnd.crick.clicker.keyboard"],["clkp","application/vnd.crick.clicker.palette"],["clkt","application/vnd.crick.clicker.template"],["clkw","application/vnd.crick.clicker.wordbank"],["clkx","application/vnd.crick.clicker"],["clp","application/x-msclip"],["cmc","application/vnd.cosmocaller"],["cmdf","chemical/x-cmdf"],["cml","chemical/x-cml"],["cmp","application/vnd.yellowriver-custom-menu"],["cmx","image/x-cmx"],["cod","application/vnd.rim.cod"],["coffee","text/coffeescript"],["com","application/x-msdownload"],["conf","text/plain"],["cpio","application/x-cpio"],["cpp","text/x-c"],["cpt","application/mac-compactpro"],["crd","application/x-mscardfile"],["crl","application/pkix-crl"],["crt","application/x-x509-ca-cert"],["crx","application/x-chrome-extension"],["cryptonote","application/vnd.rig.cryptonote"],["csh","application/x-csh"],["csl","application/vnd.citationstyles.style+xml"],["csml","chemical/x-csml"],["csp","application/vnd.commonspace"],["csr","application/octet-stream"],["css","text/css"],["cst","application/x-director"],["csv","text/csv"],["cu","application/cu-seeme"],["curl","text/vnd.curl"],["cww","application/prs.cww"],["cxt","application/x-director"],["cxx","text/x-c"],["dae","model/vnd.collada+xml"],["daf","application/vnd.mobius.daf"],["dart","application/vnd.dart"],["dataless","application/vnd.fdsn.seed"],["davmount","application/davmount+xml"],["dbf","application/vnd.dbf"],["dbk","application/docbook+xml"],["dcr","application/x-director"],["dcurl","text/vnd.curl.dcurl"],["dd2","application/vnd.oma.dd2+xml"],["ddd","application/vnd.fujixerox.ddd"],["ddf","application/vnd.syncml.dmddf+xml"],["dds","image/vnd.ms-dds"],["deb","application/x-debian-package"],["def","text/plain"],["deploy","application/octet-stream"],["der","application/x-x509-ca-cert"],["dfac","application/vnd.dreamfactory"],["dgc","application/x-dgc-compressed"],["dic","text/x-c"],["dir","application/x-director"],["dis","application/vnd.mobius.dis"],["disposition-notification","message/disposition-notification"],["dist","application/octet-stream"],["distz","application/octet-stream"],["djv","image/vnd.djvu"],["djvu","image/vnd.djvu"],["dll","application/octet-stream"],["dmg","application/x-apple-diskimage"],["dmn","application/octet-stream"],["dmp","application/vnd.tcpdump.pcap"],["dms","application/octet-stream"],["dna","application/vnd.dna"],["doc","application/msword"],["docm","application/vnd.ms-word.template.macroEnabled.12"],["docx","application/vnd.openxmlformats-officedocument.wordprocessingml.document"],["dot","application/msword"],["dotm","application/vnd.ms-word.template.macroEnabled.12"],["dotx","application/vnd.openxmlformats-officedocument.wordprocessingml.template"],["dp","application/vnd.osgi.dp"],["dpg","application/vnd.dpgraph"],["dra","audio/vnd.dra"],["drle","image/dicom-rle"],["dsc","text/prs.lines.tag"],["dssc","application/dssc+der"],["dtb","application/x-dtbook+xml"],["dtd","application/xml-dtd"],["dts","audio/vnd.dts"],["dtshd","audio/vnd.dts.hd"],["dump","application/octet-stream"],["dvb","video/vnd.dvb.file"],["dvi","application/x-dvi"],["dwd","application/atsc-dwd+xml"],["dwf","model/vnd.dwf"],["dwg","image/vnd.dwg"],["dxf","image/vnd.dxf"],["dxp","application/vnd.spotfire.dxp"],["dxr","application/x-director"],["ear","application/java-archive"],["ecelp4800","audio/vnd.nuera.ecelp4800"],["ecelp7470","audio/vnd.nuera.ecelp7470"],["ecelp9600","audio/vnd.nuera.ecelp9600"],["ecma","application/ecmascript"],["edm","application/vnd.novadigm.edm"],["edx","application/vnd.novadigm.edx"],["efif","application/vnd.picsel"],["ei6","application/vnd.pg.osasli"],["elc","application/octet-stream"],["emf","image/emf"],["eml","message/rfc822"],["emma","application/emma+xml"],["emotionml","application/emotionml+xml"],["emz","application/x-msmetafile"],["eol","audio/vnd.digital-winds"],["eot","application/vnd.ms-fontobject"],["eps","application/postscript"],["epub","application/epub+zip"],["es","application/ecmascript"],["es3","application/vnd.eszigno3+xml"],["esa","application/vnd.osgi.subsystem"],["esf","application/vnd.epson.esf"],["et3","application/vnd.eszigno3+xml"],["etx","text/x-setext"],["eva","application/x-eva"],["evy","application/x-envoy"],["exe","application/octet-stream"],["exi","application/exi"],["exp","application/express"],["exr","image/aces"],["ext","application/vnd.novadigm.ext"],["ez","application/andrew-inset"],["ez2","application/vnd.ezpix-album"],["ez3","application/vnd.ezpix-package"],["f","text/x-fortran"],["f4v","video/mp4"],["f77","text/x-fortran"],["f90","text/x-fortran"],["fbs","image/vnd.fastbidsheet"],["fcdt","application/vnd.adobe.formscentral.fcdt"],["fcs","application/vnd.isac.fcs"],["fdf","application/vnd.fdf"],["fdt","application/fdt+xml"],["fe_launch","application/vnd.denovo.fcselayout-link"],["fg5","application/vnd.fujitsu.oasysgp"],["fgd","application/x-director"],["fh","image/x-freehand"],["fh4","image/x-freehand"],["fh5","image/x-freehand"],["fh7","image/x-freehand"],["fhc","image/x-freehand"],["fig","application/x-xfig"],["fits","image/fits"],["flac","audio/x-flac"],["fli","video/x-fli"],["flo","application/vnd.micrografx.flo"],["flv","video/x-flv"],["flw","application/vnd.kde.kivio"],["flx","text/vnd.fmi.flexstor"],["fly","text/vnd.fly"],["fm","application/vnd.framemaker"],["fnc","application/vnd.frogans.fnc"],["fo","application/vnd.software602.filler.form+xml"],["for","text/x-fortran"],["fpx","image/vnd.fpx"],["frame","application/vnd.framemaker"],["fsc","application/vnd.fsc.weblaunch"],["fst","image/vnd.fst"],["ftc","application/vnd.fluxtime.clip"],["fti","application/vnd.anser-web-funds-transfer-initiation"],["fvt","video/vnd.fvt"],["fxp","application/vnd.adobe.fxp"],["fxpl","application/vnd.adobe.fxp"],["fzs","application/vnd.fuzzysheet"],["g2w","application/vnd.geoplan"],["g3","image/g3fax"],["g3w","application/vnd.geospace"],["gac","application/vnd.groove-account"],["gam","application/x-tads"],["gbr","application/rpki-ghostbusters"],["gca","application/x-gca-compressed"],["gdl","model/vnd.gdl"],["gdoc","application/vnd.google-apps.document"],["geo","application/vnd.dynageo"],["geojson","application/geo+json"],["gex","application/vnd.geometry-explorer"],["ggb","application/vnd.geogebra.file"],["ggt","application/vnd.geogebra.tool"],["ghf","application/vnd.groove-help"],["gif","image/gif"],["gim","application/vnd.groove-identity-message"],["glb","model/gltf-binary"],["gltf","model/gltf+json"],["gml","application/gml+xml"],["gmx","application/vnd.gmx"],["gnumeric","application/x-gnumeric"],["gpg","application/gpg-keys"],["gph","application/vnd.flographit"],["gpx","application/gpx+xml"],["gqf","application/vnd.grafeq"],["gqs","application/vnd.grafeq"],["gram","application/srgs"],["gramps","application/x-gramps-xml"],["gre","application/vnd.geometry-explorer"],["grv","application/vnd.groove-injector"],["grxml","application/srgs+xml"],["gsf","application/x-font-ghostscript"],["gsheet","application/vnd.google-apps.spreadsheet"],["gslides","application/vnd.google-apps.presentation"],["gtar","application/x-gtar"],["gtm","application/vnd.groove-tool-message"],["gtw","model/vnd.gtw"],["gv","text/vnd.graphviz"],["gxf","application/gxf"],["gxt","application/vnd.geonext"],["gz","application/gzip"],["gzip","application/gzip"],["h","text/x-c"],["h261","video/h261"],["h263","video/h263"],["h264","video/h264"],["hal","application/vnd.hal+xml"],["hbci","application/vnd.hbci"],["hbs","text/x-handlebars-template"],["hdd","application/x-virtualbox-hdd"],["hdf","application/x-hdf"],["heic","image/heic"],["heics","image/heic-sequence"],["heif","image/heif"],["heifs","image/heif-sequence"],["hej2","image/hej2k"],["held","application/atsc-held+xml"],["hh","text/x-c"],["hjson","application/hjson"],["hlp","application/winhlp"],["hpgl","application/vnd.hp-hpgl"],["hpid","application/vnd.hp-hpid"],["hps","application/vnd.hp-hps"],["hqx","application/mac-binhex40"],["hsj2","image/hsj2"],["htc","text/x-component"],["htke","application/vnd.kenameaapp"],["htm","text/html"],["html","text/html"],["hvd","application/vnd.yamaha.hv-dic"],["hvp","application/vnd.yamaha.hv-voice"],["hvs","application/vnd.yamaha.hv-script"],["i2g","application/vnd.intergeo"],["icc","application/vnd.iccprofile"],["ice","x-conference/x-cooltalk"],["icm","application/vnd.iccprofile"],["ico","image/x-icon"],["ics","text/calendar"],["ief","image/ief"],["ifb","text/calendar"],["ifm","application/vnd.shana.informed.formdata"],["iges","model/iges"],["igl","application/vnd.igloader"],["igm","application/vnd.insors.igm"],["igs","model/iges"],["igx","application/vnd.micrografx.igx"],["iif","application/vnd.shana.informed.interchange"],["img","application/octet-stream"],["imp","application/vnd.accpac.simply.imp"],["ims","application/vnd.ms-ims"],["in","text/plain"],["ini","text/plain"],["ink","application/inkml+xml"],["inkml","application/inkml+xml"],["install","application/x-install-instructions"],["iota","application/vnd.astraea-software.iota"],["ipfix","application/ipfix"],["ipk","application/vnd.shana.informed.package"],["irm","application/vnd.ibm.rights-management"],["irp","application/vnd.irepository.package+xml"],["iso","application/x-iso9660-image"],["itp","application/vnd.shana.informed.formtemplate"],["its","application/its+xml"],["ivp","application/vnd.immervision-ivp"],["ivu","application/vnd.immervision-ivu"],["jad","text/vnd.sun.j2me.app-descriptor"],["jade","text/jade"],["jam","application/vnd.jam"],["jar","application/java-archive"],["jardiff","application/x-java-archive-diff"],["java","text/x-java-source"],["jhc","image/jphc"],["jisp","application/vnd.jisp"],["jls","image/jls"],["jlt","application/vnd.hp-jlyt"],["jng","image/x-jng"],["jnlp","application/x-java-jnlp-file"],["joda","application/vnd.joost.joda-archive"],["jp2","image/jp2"],["jpe","image/jpeg"],["jpeg","image/jpeg"],["jpf","image/jpx"],["jpg","image/jpeg"],["jpg2","image/jp2"],["jpgm","video/jpm"],["jpgv","video/jpeg"],["jph","image/jph"],["jpm","video/jpm"],["jpx","image/jpx"],["js","application/javascript"],["json","application/json"],["json5","application/json5"],["jsonld","application/ld+json"],["jsonl","application/jsonl"],["jsonml","application/jsonml+json"],["jsx","text/jsx"],["jxr","image/jxr"],["jxra","image/jxra"],["jxrs","image/jxrs"],["jxs","image/jxs"],["jxsc","image/jxsc"],["jxsi","image/jxsi"],["jxss","image/jxss"],["kar","audio/midi"],["karbon","application/vnd.kde.karbon"],["kdb","application/octet-stream"],["kdbx","application/x-keepass2"],["key","application/x-iwork-keynote-sffkey"],["kfo","application/vnd.kde.kformula"],["kia","application/vnd.kidspiration"],["kml","application/vnd.google-earth.kml+xml"],["kmz","application/vnd.google-earth.kmz"],["kne","application/vnd.kinar"],["knp","application/vnd.kinar"],["kon","application/vnd.kde.kontour"],["kpr","application/vnd.kde.kpresenter"],["kpt","application/vnd.kde.kpresenter"],["kpxx","application/vnd.ds-keypoint"],["ksp","application/vnd.kde.kspread"],["ktr","application/vnd.kahootz"],["ktx","image/ktx"],["ktx2","image/ktx2"],["ktz","application/vnd.kahootz"],["kwd","application/vnd.kde.kword"],["kwt","application/vnd.kde.kword"],["lasxml","application/vnd.las.las+xml"],["latex","application/x-latex"],["lbd","application/vnd.llamagraphics.life-balance.desktop"],["lbe","application/vnd.llamagraphics.life-balance.exchange+xml"],["les","application/vnd.hhe.lesson-player"],["less","text/less"],["lgr","application/lgr+xml"],["lha","application/octet-stream"],["link66","application/vnd.route66.link66+xml"],["list","text/plain"],["list3820","application/vnd.ibm.modcap"],["listafp","application/vnd.ibm.modcap"],["litcoffee","text/coffeescript"],["lnk","application/x-ms-shortcut"],["log","text/plain"],["lostxml","application/lost+xml"],["lrf","application/octet-stream"],["lrm","application/vnd.ms-lrm"],["ltf","application/vnd.frogans.ltf"],["lua","text/x-lua"],["luac","application/x-lua-bytecode"],["lvp","audio/vnd.lucent.voice"],["lwp","application/vnd.lotus-wordpro"],["lzh","application/octet-stream"],["m1v","video/mpeg"],["m2a","audio/mpeg"],["m2v","video/mpeg"],["m3a","audio/mpeg"],["m3u","text/plain"],["m3u8","application/vnd.apple.mpegurl"],["m4a","audio/x-m4a"],["m4p","application/mp4"],["m4s","video/iso.segment"],["m4u","application/vnd.mpegurl"],["m4v","video/x-m4v"],["m13","application/x-msmediaview"],["m14","application/x-msmediaview"],["m21","application/mp21"],["ma","application/mathematica"],["mads","application/mads+xml"],["maei","application/mmt-aei+xml"],["mag","application/vnd.ecowin.chart"],["maker","application/vnd.framemaker"],["man","text/troff"],["manifest","text/cache-manifest"],["map","application/json"],["mar","application/octet-stream"],["markdown","text/markdown"],["mathml","application/mathml+xml"],["mb","application/mathematica"],["mbk","application/vnd.mobius.mbk"],["mbox","application/mbox"],["mc1","application/vnd.medcalcdata"],["mcd","application/vnd.mcd"],["mcurl","text/vnd.curl.mcurl"],["md","text/markdown"],["mdb","application/x-msaccess"],["mdi","image/vnd.ms-modi"],["mdx","text/mdx"],["me","text/troff"],["mesh","model/mesh"],["meta4","application/metalink4+xml"],["metalink","application/metalink+xml"],["mets","application/mets+xml"],["mfm","application/vnd.mfmp"],["mft","application/rpki-manifest"],["mgp","application/vnd.osgeo.mapguide.package"],["mgz","application/vnd.proteus.magazine"],["mid","audio/midi"],["midi","audio/midi"],["mie","application/x-mie"],["mif","application/vnd.mif"],["mime","message/rfc822"],["mj2","video/mj2"],["mjp2","video/mj2"],["mjs","application/javascript"],["mk3d","video/x-matroska"],["mka","audio/x-matroska"],["mkd","text/x-markdown"],["mks","video/x-matroska"],["mkv","video/x-matroska"],["mlp","application/vnd.dolby.mlp"],["mmd","application/vnd.chipnuts.karaoke-mmd"],["mmf","application/vnd.smaf"],["mml","text/mathml"],["mmr","image/vnd.fujixerox.edmics-mmr"],["mng","video/x-mng"],["mny","application/x-msmoney"],["mobi","application/x-mobipocket-ebook"],["mods","application/mods+xml"],["mov","video/quicktime"],["movie","video/x-sgi-movie"],["mp2","audio/mpeg"],["mp2a","audio/mpeg"],["mp3","audio/mpeg"],["mp4","video/mp4"],["mp4a","audio/mp4"],["mp4s","application/mp4"],["mp4v","video/mp4"],["mp21","application/mp21"],["mpc","application/vnd.mophun.certificate"],["mpd","application/dash+xml"],["mpe","video/mpeg"],["mpeg","video/mpeg"],["mpg","video/mpeg"],["mpg4","video/mp4"],["mpga","audio/mpeg"],["mpkg","application/vnd.apple.installer+xml"],["mpm","application/vnd.blueice.multipass"],["mpn","application/vnd.mophun.application"],["mpp","application/vnd.ms-project"],["mpt","application/vnd.ms-project"],["mpy","application/vnd.ibm.minipay"],["mqy","application/vnd.mobius.mqy"],["mrc","application/marc"],["mrcx","application/marcxml+xml"],["ms","text/troff"],["mscml","application/mediaservercontrol+xml"],["mseed","application/vnd.fdsn.mseed"],["mseq","application/vnd.mseq"],["msf","application/vnd.epson.msf"],["msg","application/vnd.ms-outlook"],["msh","model/mesh"],["msi","application/x-msdownload"],["msl","application/vnd.mobius.msl"],["msm","application/octet-stream"],["msp","application/octet-stream"],["msty","application/vnd.muvee.style"],["mtl","model/mtl"],["mts","model/vnd.mts"],["mus","application/vnd.musician"],["musd","application/mmt-usd+xml"],["musicxml","application/vnd.recordare.musicxml+xml"],["mvb","application/x-msmediaview"],["mvt","application/vnd.mapbox-vector-tile"],["mwf","application/vnd.mfer"],["mxf","application/mxf"],["mxl","application/vnd.recordare.musicxml"],["mxmf","audio/mobile-xmf"],["mxml","application/xv+xml"],["mxs","application/vnd.triscape.mxs"],["mxu","video/vnd.mpegurl"],["n-gage","application/vnd.nokia.n-gage.symbian.install"],["n3","text/n3"],["nb","application/mathematica"],["nbp","application/vnd.wolfram.player"],["nc","application/x-netcdf"],["ncx","application/x-dtbncx+xml"],["nfo","text/x-nfo"],["ngdat","application/vnd.nokia.n-gage.data"],["nitf","application/vnd.nitf"],["nlu","application/vnd.neurolanguage.nlu"],["nml","application/vnd.enliven"],["nnd","application/vnd.noblenet-directory"],["nns","application/vnd.noblenet-sealer"],["nnw","application/vnd.noblenet-web"],["npx","image/vnd.net-fpx"],["nq","application/n-quads"],["nsc","application/x-conference"],["nsf","application/vnd.lotus-notes"],["nt","application/n-triples"],["ntf","application/vnd.nitf"],["numbers","application/x-iwork-numbers-sffnumbers"],["nzb","application/x-nzb"],["oa2","application/vnd.fujitsu.oasys2"],["oa3","application/vnd.fujitsu.oasys3"],["oas","application/vnd.fujitsu.oasys"],["obd","application/x-msbinder"],["obgx","application/vnd.openblox.game+xml"],["obj","model/obj"],["oda","application/oda"],["odb","application/vnd.oasis.opendocument.database"],["odc","application/vnd.oasis.opendocument.chart"],["odf","application/vnd.oasis.opendocument.formula"],["odft","application/vnd.oasis.opendocument.formula-template"],["odg","application/vnd.oasis.opendocument.graphics"],["odi","application/vnd.oasis.opendocument.image"],["odm","application/vnd.oasis.opendocument.text-master"],["odp","application/vnd.oasis.opendocument.presentation"],["ods","application/vnd.oasis.opendocument.spreadsheet"],["odt","application/vnd.oasis.opendocument.text"],["oga","audio/ogg"],["ogex","model/vnd.opengex"],["ogg","audio/ogg"],["ogv","video/ogg"],["ogx","application/ogg"],["omdoc","application/omdoc+xml"],["onepkg","application/onenote"],["onetmp","application/onenote"],["onetoc","application/onenote"],["onetoc2","application/onenote"],["opf","application/oebps-package+xml"],["opml","text/x-opml"],["oprc","application/vnd.palm"],["opus","audio/ogg"],["org","text/x-org"],["osf","application/vnd.yamaha.openscoreformat"],["osfpvg","application/vnd.yamaha.openscoreformat.osfpvg+xml"],["osm","application/vnd.openstreetmap.data+xml"],["otc","application/vnd.oasis.opendocument.chart-template"],["otf","font/otf"],["otg","application/vnd.oasis.opendocument.graphics-template"],["oth","application/vnd.oasis.opendocument.text-web"],["oti","application/vnd.oasis.opendocument.image-template"],["otp","application/vnd.oasis.opendocument.presentation-template"],["ots","application/vnd.oasis.opendocument.spreadsheet-template"],["ott","application/vnd.oasis.opendocument.text-template"],["ova","application/x-virtualbox-ova"],["ovf","application/x-virtualbox-ovf"],["owl","application/rdf+xml"],["oxps","application/oxps"],["oxt","application/vnd.openofficeorg.extension"],["p","text/x-pascal"],["p7a","application/x-pkcs7-signature"],["p7b","application/x-pkcs7-certificates"],["p7c","application/pkcs7-mime"],["p7m","application/pkcs7-mime"],["p7r","application/x-pkcs7-certreqresp"],["p7s","application/pkcs7-signature"],["p8","application/pkcs8"],["p10","application/x-pkcs10"],["p12","application/x-pkcs12"],["pac","application/x-ns-proxy-autoconfig"],["pages","application/x-iwork-pages-sffpages"],["pas","text/x-pascal"],["paw","application/vnd.pawaafile"],["pbd","application/vnd.powerbuilder6"],["pbm","image/x-portable-bitmap"],["pcap","application/vnd.tcpdump.pcap"],["pcf","application/x-font-pcf"],["pcl","application/vnd.hp-pcl"],["pclxl","application/vnd.hp-pclxl"],["pct","image/x-pict"],["pcurl","application/vnd.curl.pcurl"],["pcx","image/x-pcx"],["pdb","application/x-pilot"],["pde","text/x-processing"],["pdf","application/pdf"],["pem","application/x-x509-user-cert"],["pfa","application/x-font-type1"],["pfb","application/x-font-type1"],["pfm","application/x-font-type1"],["pfr","application/font-tdpfr"],["pfx","application/x-pkcs12"],["pgm","image/x-portable-graymap"],["pgn","application/x-chess-pgn"],["pgp","application/pgp"],["php","application/x-httpd-php"],["php3","application/x-httpd-php"],["php4","application/x-httpd-php"],["phps","application/x-httpd-php-source"],["phtml","application/x-httpd-php"],["pic","image/x-pict"],["pkg","application/octet-stream"],["pki","application/pkixcmp"],["pkipath","application/pkix-pkipath"],["pkpass","application/vnd.apple.pkpass"],["pl","application/x-perl"],["plb","application/vnd.3gpp.pic-bw-large"],["plc","application/vnd.mobius.plc"],["plf","application/vnd.pocketlearn"],["pls","application/pls+xml"],["pm","application/x-perl"],["pml","application/vnd.ctc-posml"],["png","image/png"],["pnm","image/x-portable-anymap"],["portpkg","application/vnd.macports.portpkg"],["pot","application/vnd.ms-powerpoint"],["potm","application/vnd.ms-powerpoint.presentation.macroEnabled.12"],["potx","application/vnd.openxmlformats-officedocument.presentationml.template"],["ppa","application/vnd.ms-powerpoint"],["ppam","application/vnd.ms-powerpoint.addin.macroEnabled.12"],["ppd","application/vnd.cups-ppd"],["ppm","image/x-portable-pixmap"],["pps","application/vnd.ms-powerpoint"],["ppsm","application/vnd.ms-powerpoint.slideshow.macroEnabled.12"],["ppsx","application/vnd.openxmlformats-officedocument.presentationml.slideshow"],["ppt","application/powerpoint"],["pptm","application/vnd.ms-powerpoint.presentation.macroEnabled.12"],["pptx","application/vnd.openxmlformats-officedocument.presentationml.presentation"],["pqa","application/vnd.palm"],["prc","application/x-pilot"],["pre","application/vnd.lotus-freelance"],["prf","application/pics-rules"],["provx","application/provenance+xml"],["ps","application/postscript"],["psb","application/vnd.3gpp.pic-bw-small"],["psd","application/x-photoshop"],["psf","application/x-font-linux-psf"],["pskcxml","application/pskc+xml"],["pti","image/prs.pti"],["ptid","application/vnd.pvi.ptid1"],["pub","application/x-mspublisher"],["pvb","application/vnd.3gpp.pic-bw-var"],["pwn","application/vnd.3m.post-it-notes"],["pya","audio/vnd.ms-playready.media.pya"],["pyv","video/vnd.ms-playready.media.pyv"],["qam","application/vnd.epson.quickanime"],["qbo","application/vnd.intu.qbo"],["qfx","application/vnd.intu.qfx"],["qps","application/vnd.publishare-delta-tree"],["qt","video/quicktime"],["qwd","application/vnd.quark.quarkxpress"],["qwt","application/vnd.quark.quarkxpress"],["qxb","application/vnd.quark.quarkxpress"],["qxd","application/vnd.quark.quarkxpress"],["qxl","application/vnd.quark.quarkxpress"],["qxt","application/vnd.quark.quarkxpress"],["ra","audio/x-realaudio"],["ram","audio/x-pn-realaudio"],["raml","application/raml+yaml"],["rapd","application/route-apd+xml"],["rar","application/x-rar"],["ras","image/x-cmu-raster"],["rcprofile","application/vnd.ipunplugged.rcprofile"],["rdf","application/rdf+xml"],["rdz","application/vnd.data-vision.rdz"],["relo","application/p2p-overlay+xml"],["rep","application/vnd.businessobjects"],["res","application/x-dtbresource+xml"],["rgb","image/x-rgb"],["rif","application/reginfo+xml"],["rip","audio/vnd.rip"],["ris","application/x-research-info-systems"],["rl","application/resource-lists+xml"],["rlc","image/vnd.fujixerox.edmics-rlc"],["rld","application/resource-lists-diff+xml"],["rm","audio/x-pn-realaudio"],["rmi","audio/midi"],["rmp","audio/x-pn-realaudio-plugin"],["rms","application/vnd.jcp.javame.midlet-rms"],["rmvb","application/vnd.rn-realmedia-vbr"],["rnc","application/relax-ng-compact-syntax"],["rng","application/xml"],["roa","application/rpki-roa"],["roff","text/troff"],["rp9","application/vnd.cloanto.rp9"],["rpm","audio/x-pn-realaudio-plugin"],["rpss","application/vnd.nokia.radio-presets"],["rpst","application/vnd.nokia.radio-preset"],["rq","application/sparql-query"],["rs","application/rls-services+xml"],["rsa","application/x-pkcs7"],["rsat","application/atsc-rsat+xml"],["rsd","application/rsd+xml"],["rsheet","application/urc-ressheet+xml"],["rss","application/rss+xml"],["rtf","text/rtf"],["rtx","text/richtext"],["run","application/x-makeself"],["rusd","application/route-usd+xml"],["rv","video/vnd.rn-realvideo"],["s","text/x-asm"],["s3m","audio/s3m"],["saf","application/vnd.yamaha.smaf-audio"],["sass","text/x-sass"],["sbml","application/sbml+xml"],["sc","application/vnd.ibm.secure-container"],["scd","application/x-msschedule"],["scm","application/vnd.lotus-screencam"],["scq","application/scvp-cv-request"],["scs","application/scvp-cv-response"],["scss","text/x-scss"],["scurl","text/vnd.curl.scurl"],["sda","application/vnd.stardivision.draw"],["sdc","application/vnd.stardivision.calc"],["sdd","application/vnd.stardivision.impress"],["sdkd","application/vnd.solent.sdkm+xml"],["sdkm","application/vnd.solent.sdkm+xml"],["sdp","application/sdp"],["sdw","application/vnd.stardivision.writer"],["sea","application/octet-stream"],["see","application/vnd.seemail"],["seed","application/vnd.fdsn.seed"],["sema","application/vnd.sema"],["semd","application/vnd.semd"],["semf","application/vnd.semf"],["senmlx","application/senml+xml"],["sensmlx","application/sensml+xml"],["ser","application/java-serialized-object"],["setpay","application/set-payment-initiation"],["setreg","application/set-registration-initiation"],["sfd-hdstx","application/vnd.hydrostatix.sof-data"],["sfs","application/vnd.spotfire.sfs"],["sfv","text/x-sfv"],["sgi","image/sgi"],["sgl","application/vnd.stardivision.writer-global"],["sgm","text/sgml"],["sgml","text/sgml"],["sh","application/x-sh"],["shar","application/x-shar"],["shex","text/shex"],["shf","application/shf+xml"],["shtml","text/html"],["sid","image/x-mrsid-image"],["sieve","application/sieve"],["sig","application/pgp-signature"],["sil","audio/silk"],["silo","model/mesh"],["sis","application/vnd.symbian.install"],["sisx","application/vnd.symbian.install"],["sit","application/x-stuffit"],["sitx","application/x-stuffitx"],["siv","application/sieve"],["skd","application/vnd.koan"],["skm","application/vnd.koan"],["skp","application/vnd.koan"],["skt","application/vnd.koan"],["sldm","application/vnd.ms-powerpoint.slide.macroenabled.12"],["sldx","application/vnd.openxmlformats-officedocument.presentationml.slide"],["slim","text/slim"],["slm","text/slim"],["sls","application/route-s-tsid+xml"],["slt","application/vnd.epson.salt"],["sm","application/vnd.stepmania.stepchart"],["smf","application/vnd.stardivision.math"],["smi","application/smil"],["smil","application/smil"],["smv","video/x-smv"],["smzip","application/vnd.stepmania.package"],["snd","audio/basic"],["snf","application/x-font-snf"],["so","application/octet-stream"],["spc","application/x-pkcs7-certificates"],["spdx","text/spdx"],["spf","application/vnd.yamaha.smaf-phrase"],["spl","application/x-futuresplash"],["spot","text/vnd.in3d.spot"],["spp","application/scvp-vp-response"],["spq","application/scvp-vp-request"],["spx","audio/ogg"],["sql","application/x-sql"],["src","application/x-wais-source"],["srt","application/x-subrip"],["sru","application/sru+xml"],["srx","application/sparql-results+xml"],["ssdl","application/ssdl+xml"],["sse","application/vnd.kodak-descriptor"],["ssf","application/vnd.epson.ssf"],["ssml","application/ssml+xml"],["sst","application/octet-stream"],["st","application/vnd.sailingtracker.track"],["stc","application/vnd.sun.xml.calc.template"],["std","application/vnd.sun.xml.draw.template"],["stf","application/vnd.wt.stf"],["sti","application/vnd.sun.xml.impress.template"],["stk","application/hyperstudio"],["stl","model/stl"],["stpx","model/step+xml"],["stpxz","model/step-xml+zip"],["stpz","model/step+zip"],["str","application/vnd.pg.format"],["stw","application/vnd.sun.xml.writer.template"],["styl","text/stylus"],["stylus","text/stylus"],["sub","text/vnd.dvb.subtitle"],["sus","application/vnd.sus-calendar"],["susp","application/vnd.sus-calendar"],["sv4cpio","application/x-sv4cpio"],["sv4crc","application/x-sv4crc"],["svc","application/vnd.dvb.service"],["svd","application/vnd.svd"],["svg","image/svg+xml"],["svgz","image/svg+xml"],["swa","application/x-director"],["swf","application/x-shockwave-flash"],["swi","application/vnd.aristanetworks.swi"],["swidtag","application/swid+xml"],["sxc","application/vnd.sun.xml.calc"],["sxd","application/vnd.sun.xml.draw"],["sxg","application/vnd.sun.xml.writer.global"],["sxi","application/vnd.sun.xml.impress"],["sxm","application/vnd.sun.xml.math"],["sxw","application/vnd.sun.xml.writer"],["t","text/troff"],["t3","application/x-t3vm-image"],["t38","image/t38"],["taglet","application/vnd.mynfc"],["tao","application/vnd.tao.intent-module-archive"],["tap","image/vnd.tencent.tap"],["tar","application/x-tar"],["tcap","application/vnd.3gpp2.tcap"],["tcl","application/x-tcl"],["td","application/urc-targetdesc+xml"],["teacher","application/vnd.smart.teacher"],["tei","application/tei+xml"],["teicorpus","application/tei+xml"],["tex","application/x-tex"],["texi","application/x-texinfo"],["texinfo","application/x-texinfo"],["text","text/plain"],["tfi","application/thraud+xml"],["tfm","application/x-tex-tfm"],["tfx","image/tiff-fx"],["tga","image/x-tga"],["tgz","application/x-tar"],["thmx","application/vnd.ms-officetheme"],["tif","image/tiff"],["tiff","image/tiff"],["tk","application/x-tcl"],["tmo","application/vnd.tmobile-livetv"],["toml","application/toml"],["torrent","application/x-bittorrent"],["tpl","application/vnd.groove-tool-template"],["tpt","application/vnd.trid.tpt"],["tr","text/troff"],["tra","application/vnd.trueapp"],["trig","application/trig"],["trm","application/x-msterminal"],["ts","video/mp2t"],["tsd","application/timestamped-data"],["tsv","text/tab-separated-values"],["ttc","font/collection"],["ttf","font/ttf"],["ttl","text/turtle"],["ttml","application/ttml+xml"],["twd","application/vnd.simtech-mindmapper"],["twds","application/vnd.simtech-mindmapper"],["txd","application/vnd.genomatix.tuxedo"],["txf","application/vnd.mobius.txf"],["txt","text/plain"],["u8dsn","message/global-delivery-status"],["u8hdr","message/global-headers"],["u8mdn","message/global-disposition-notification"],["u8msg","message/global"],["u32","application/x-authorware-bin"],["ubj","application/ubjson"],["udeb","application/x-debian-package"],["ufd","application/vnd.ufdl"],["ufdl","application/vnd.ufdl"],["ulx","application/x-glulx"],["umj","application/vnd.umajin"],["unityweb","application/vnd.unity"],["uoml","application/vnd.uoml+xml"],["uri","text/uri-list"],["uris","text/uri-list"],["urls","text/uri-list"],["usdz","model/vnd.usdz+zip"],["ustar","application/x-ustar"],["utz","application/vnd.uiq.theme"],["uu","text/x-uuencode"],["uva","audio/vnd.dece.audio"],["uvd","application/vnd.dece.data"],["uvf","application/vnd.dece.data"],["uvg","image/vnd.dece.graphic"],["uvh","video/vnd.dece.hd"],["uvi","image/vnd.dece.graphic"],["uvm","video/vnd.dece.mobile"],["uvp","video/vnd.dece.pd"],["uvs","video/vnd.dece.sd"],["uvt","application/vnd.dece.ttml+xml"],["uvu","video/vnd.uvvu.mp4"],["uvv","video/vnd.dece.video"],["uvva","audio/vnd.dece.audio"],["uvvd","application/vnd.dece.data"],["uvvf","application/vnd.dece.data"],["uvvg","image/vnd.dece.graphic"],["uvvh","video/vnd.dece.hd"],["uvvi","image/vnd.dece.graphic"],["uvvm","video/vnd.dece.mobile"],["uvvp","video/vnd.dece.pd"],["uvvs","video/vnd.dece.sd"],["uvvt","application/vnd.dece.ttml+xml"],["uvvu","video/vnd.uvvu.mp4"],["uvvv","video/vnd.dece.video"],["uvvx","application/vnd.dece.unspecified"],["uvvz","application/vnd.dece.zip"],["uvx","application/vnd.dece.unspecified"],["uvz","application/vnd.dece.zip"],["vbox","application/x-virtualbox-vbox"],["vbox-extpack","application/x-virtualbox-vbox-extpack"],["vcard","text/vcard"],["vcd","application/x-cdlink"],["vcf","text/x-vcard"],["vcg","application/vnd.groove-vcard"],["vcs","text/x-vcalendar"],["vcx","application/vnd.vcx"],["vdi","application/x-virtualbox-vdi"],["vds","model/vnd.sap.vds"],["vhd","application/x-virtualbox-vhd"],["vis","application/vnd.visionary"],["viv","video/vnd.vivo"],["vlc","application/videolan"],["vmdk","application/x-virtualbox-vmdk"],["vob","video/x-ms-vob"],["vor","application/vnd.stardivision.writer"],["vox","application/x-authorware-bin"],["vrml","model/vrml"],["vsd","application/vnd.visio"],["vsf","application/vnd.vsf"],["vss","application/vnd.visio"],["vst","application/vnd.visio"],["vsw","application/vnd.visio"],["vtf","image/vnd.valve.source.texture"],["vtt","text/vtt"],["vtu","model/vnd.vtu"],["vxml","application/voicexml+xml"],["w3d","application/x-director"],["wad","application/x-doom"],["wadl","application/vnd.sun.wadl+xml"],["war","application/java-archive"],["wasm","application/wasm"],["wav","audio/x-wav"],["wax","audio/x-ms-wax"],["wbmp","image/vnd.wap.wbmp"],["wbs","application/vnd.criticaltools.wbs+xml"],["wbxml","application/wbxml"],["wcm","application/vnd.ms-works"],["wdb","application/vnd.ms-works"],["wdp","image/vnd.ms-photo"],["weba","audio/webm"],["webapp","application/x-web-app-manifest+json"],["webm","video/webm"],["webmanifest","application/manifest+json"],["webp","image/webp"],["wg","application/vnd.pmi.widget"],["wgt","application/widget"],["wks","application/vnd.ms-works"],["wm","video/x-ms-wm"],["wma","audio/x-ms-wma"],["wmd","application/x-ms-wmd"],["wmf","image/wmf"],["wml","text/vnd.wap.wml"],["wmlc","application/wmlc"],["wmls","text/vnd.wap.wmlscript"],["wmlsc","application/vnd.wap.wmlscriptc"],["wmv","video/x-ms-wmv"],["wmx","video/x-ms-wmx"],["wmz","application/x-msmetafile"],["woff","font/woff"],["woff2","font/woff2"],["word","application/msword"],["wpd","application/vnd.wordperfect"],["wpl","application/vnd.ms-wpl"],["wps","application/vnd.ms-works"],["wqd","application/vnd.wqd"],["wri","application/x-mswrite"],["wrl","model/vrml"],["wsc","message/vnd.wfa.wsc"],["wsdl","application/wsdl+xml"],["wspolicy","application/wspolicy+xml"],["wtb","application/vnd.webturbo"],["wvx","video/x-ms-wvx"],["x3d","model/x3d+xml"],["x3db","model/x3d+fastinfoset"],["x3dbz","model/x3d+binary"],["x3dv","model/x3d-vrml"],["x3dvz","model/x3d+vrml"],["x3dz","model/x3d+xml"],["x32","application/x-authorware-bin"],["x_b","model/vnd.parasolid.transmit.binary"],["x_t","model/vnd.parasolid.transmit.text"],["xaml","application/xaml+xml"],["xap","application/x-silverlight-app"],["xar","application/vnd.xara"],["xav","application/xcap-att+xml"],["xbap","application/x-ms-xbap"],["xbd","application/vnd.fujixerox.docuworks.binder"],["xbm","image/x-xbitmap"],["xca","application/xcap-caps+xml"],["xcs","application/calendar+xml"],["xdf","application/xcap-diff+xml"],["xdm","application/vnd.syncml.dm+xml"],["xdp","application/vnd.adobe.xdp+xml"],["xdssc","application/dssc+xml"],["xdw","application/vnd.fujixerox.docuworks"],["xel","application/xcap-el+xml"],["xenc","application/xenc+xml"],["xer","application/patch-ops-error+xml"],["xfdf","application/vnd.adobe.xfdf"],["xfdl","application/vnd.xfdl"],["xht","application/xhtml+xml"],["xhtml","application/xhtml+xml"],["xhvml","application/xv+xml"],["xif","image/vnd.xiff"],["xl","application/excel"],["xla","application/vnd.ms-excel"],["xlam","application/vnd.ms-excel.addin.macroEnabled.12"],["xlc","application/vnd.ms-excel"],["xlf","application/xliff+xml"],["xlm","application/vnd.ms-excel"],["xls","application/vnd.ms-excel"],["xlsb","application/vnd.ms-excel.sheet.binary.macroEnabled.12"],["xlsm","application/vnd.ms-excel.sheet.macroEnabled.12"],["xlsx","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],["xlt","application/vnd.ms-excel"],["xltm","application/vnd.ms-excel.template.macroEnabled.12"],["xltx","application/vnd.openxmlformats-officedocument.spreadsheetml.template"],["xlw","application/vnd.ms-excel"],["xm","audio/xm"],["xml","application/xml"],["xns","application/xcap-ns+xml"],["xo","application/vnd.olpc-sugar"],["xop","application/xop+xml"],["xpi","application/x-xpinstall"],["xpl","application/xproc+xml"],["xpm","image/x-xpixmap"],["xpr","application/vnd.is-xpr"],["xps","application/vnd.ms-xpsdocument"],["xpw","application/vnd.intercon.formnet"],["xpx","application/vnd.intercon.formnet"],["xsd","application/xml"],["xsl","application/xml"],["xslt","application/xslt+xml"],["xsm","application/vnd.syncml+xml"],["xspf","application/xspf+xml"],["xul","application/vnd.mozilla.xul+xml"],["xvm","application/xv+xml"],["xvml","application/xv+xml"],["xwd","image/x-xwindowdump"],["xyz","chemical/x-xyz"],["xz","application/x-xz"],["yaml","text/yaml"],["yang","application/yang"],["yin","application/yin+xml"],["yml","text/yaml"],["ymp","text/x-suse-ymp"],["z","application/x-compress"],["z1","application/x-zmachine"],["z2","application/x-zmachine"],["z3","application/x-zmachine"],["z4","application/x-zmachine"],["z5","application/x-zmachine"],["z6","application/x-zmachine"],["z7","application/x-zmachine"],["z8","application/x-zmachine"],["zaz","application/vnd.zzazz.deck+xml"],["zip","application/zip"],["zir","application/vnd.zul"],["zirz","application/vnd.zul"],["zmm","application/vnd.handheld-entertainment+xml"],["zsh","text/x-scriptzsh"]]);function Rm(e,t,n){const s=Qat(e),{webkitRelativePath:r}=e,a=typeof t=="string"?t:typeof r=="string"&&r.length>0?r:`./${e.name}`;return typeof s.path!="string"&&sH(s,"path",a),sH(s,"relativePath",a),s}function Qat(e){const{name:t}=e;if(t&&t.lastIndexOf(".")!==-1&&!e.type){const s=t.split(".").pop().toLowerCase(),r=Xat.get(s);r&&Object.defineProperty(e,"type",{value:r,writable:!1,configurable:!1,enumerable:!0})}return e}function sH(e,t,n){Object.defineProperty(e,t,{value:n,writable:!1,configurable:!1,enumerable:!0})}const Jat=[".DS_Store","Thumbs.db"];function eit(e){return Hf(this,void 0,void 0,function*(){return Gw(e)&&tit(e.dataTransfer)?ait(e.dataTransfer,e.type):nit(e)?sit(e):Array.isArray(e)&&e.every(t=>"getFile"in t&&typeof t.getFile=="function")?rit(e):[]})}function tit(e){return Gw(e)}function nit(e){return Gw(e)&&Gw(e.target)}function Gw(e){return typeof e=="object"&&e!==null}function sit(e){return kM(e.target.files).map(t=>Rm(t))}function rit(e){return Hf(this,void 0,void 0,function*(){return(yield Promise.all(e.map(n=>n.getFile()))).map(n=>Rm(n))})}function ait(e,t){return Hf(this,void 0,void 0,function*(){if(e.items){const n=kM(e.items).filter(r=>r.kind==="file");if(t!=="drop")return n;const s=yield Promise.all(n.map(iit));return rH(Fie(s))}return rH(kM(e.files).map(n=>Rm(n)))})}function rH(e){return e.filter(t=>Jat.indexOf(t.name)===-1)}function kM(e){if(e===null)return[];const t=[];for(let n=0;n<e.length;n++){const s=e[n];t.push(s)}return t}function iit(e){if(typeof e.webkitGetAsEntry!="function")return aH(e);const t=e.webkitGetAsEntry();return t&&t.isDirectory?zie(t):aH(e,t)}function Fie(e){return e.reduce((t,n)=>[...t,...Array.isArray(n)?Fie(n):[n]],[])}function aH(e,t){return Hf(this,void 0,void 0,function*(){var n;if(globalThis.isSecureContext&&typeof e.getAsFileSystemHandle=="function"){const a=yield e.getAsFileSystemHandle();if(a===null)throw new Error(`${e} is not a File`);if(a!==void 0){const o=yield a.getFile();return o.handle=a,Rm(o)}}const s=e.getAsFile();if(!s)throw new Error(`${e} is not a File`);return Rm(s,(n=t==null?void 0:t.fullPath)!==null&&n!==void 0?n:void 0)})}function oit(e){return Hf(this,void 0,void 0,function*(){return e.isDirectory?zie(e):lit(e)})}function zie(e){const t=e.createReader();return new Promise((n,s)=>{const r=[];function a(){t.readEntries(o=>Hf(this,void 0,void 0,function*(){if(o.length){const l=Promise.all(o.map(oit));r.push(l),a()}else try{const l=yield Promise.all(r);n(l)}catch(l){s(l)}}),o=>{s(o)})}a()})}function lit(e){return Hf(this,void 0,void 0,function*(){return new Promise((t,n)=>{e.file(s=>{const r=Rm(s,e.fullPath);t(r)},s=>{n(s)})})})}var N1={},iH;function cit(){return iH||(iH=1,N1.__esModule=!0,N1.default=function(e,t){if(e&&t){var n=Array.isArray(t)?t:t.split(",");if(n.length===0)return!0;var s=e.name||"",r=(e.type||"").toLowerCase(),a=r.replace(/\/.*$/,"");return n.some(function(o){var l=o.trim().toLowerCase();return l.charAt(0)==="."?s.toLowerCase().endsWith(l):l.endsWith("/*")?a===l.replace(/\/.*$/,""):r===l})}return!0}),N1}var uit=cit();const hj=eo(uit);function oH(e){return hit(e)||fit(e)||$ie(e)||dit()}function dit(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
1078
1078
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function fit(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function hit(e){if(Array.isArray(e))return CM(e)}function lH(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),n.push.apply(n,s)}return n}function cH(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?lH(Object(n),!0).forEach(function(s){Bie(e,s,n[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):lH(Object(n)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(n,s))})}return e}function Bie(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function oy(e,t){return git(e)||mit(e,t)||$ie(e,t)||pit()}function pit(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
@@ -1082,4 +1082,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1082
1082
|
${St.map(Kt=>`- ${Kt}`).join(`
|
|
1083
1083
|
`)}
|
|
1084
1084
|
|
|
1085
|
-
${Je}`),f.clearFiles()}return t?t(Je):Je},[f,u,t]),m=x.useCallback(Te=>{o.handleTaskEvent(Te);const Je=o.tasks.map(_t=>_t.id===Te.task.id?{..._t,...Te.task}:_t);l.handleTaskEvent(Te,Je)},[o,l]);x.useCallback(Te=>{n(Te),s.invalidateQueries({queryKey:["session",Te]})},[n,s]);const g=x.useCallback(Te=>{n(Te,{replace:!0}),s.invalidateQueries({queryKey:["session",Te]})},[n,s]),{messages:b,input:v,setInput:k,handleSubmit:w,submitContent:C,status:E,error:T,sessionBusy:_,stop:j,isLoadingHistory:R,sessionStatus:D,streamStartTime:I,estimatedTokens:O,isTextStreaming:L,isWaitingForUser:B,waitingType:H,activeInteraction:K,pendingInteractions:U,markToolCallResponded:$,isRateLimited:q,rateLimitRetryAfter:J,systemStatus:ne,promptSuggestions:F,syncConnectionState:V,retryMessage:G}=Vnt(e,{transformContent:h,onTaskEvent:m,onSessionIdChangeReplace:g,onStreamingDone:x.useCallback(()=>{c&&nxe(),s.invalidateQueries({queryKey:["commands"]})},[c,s])}),{permissionMode:P}=aQ(e,D,E==="streaming"),{handleToolRef:Z,focusedOptionIndex:Q}=Ynt(K),{isAtBottom:re,hasNewMessages:ae,scrollToBottom:de,handleScrollStateChange:pe}=Znt(b,r);est(E,B,o.activeForm,L),x.useEffect(()=>{var Te;(Te=a.current)==null||Te.focus()},[e]);const{data:Oe}=Lae(u,e??void 0),Ve=x.useMemo(()=>(Oe==null?void 0:Oe.commands)??[],[Oe]),{data:$e}=Hat(u),Qe=x.useMemo(()=>$e!=null&&$e.files?nst($e.files):[],[$e]),Se=Jnt({input:v,setInput:k,commands:Ve,fileEntries:Qe,chatInputRef:a}),Ze=x.useCallback(()=>{const Te=[...b].reverse().find(Je=>Je.role==="user");Te!=null&&Te.content&&C(Te.content)},[b,C]),bt=x.useCallback(()=>{const Te=[...b].reverse().find(Je=>Je.role==="user");Te!=null&&Te.content&&G(Te.content)},[b,G]),Me=E==="idle"&&F.length>0&&v.length===0,Ie=x.useCallback(Te=>{var Je;k(Te),(Je=a.current)==null||Je.focus()},[k]);return i.jsxs("div",{"data-testid":"chat-panel",className:"mx-auto flex h-full w-full max-w-7xl flex-col",children:[i.jsx(eat,{messages:b,sessionId:e,isLoadingHistory:R,isTextStreaming:L,isAtBottom:re,hasNewMessages:ae,scrollToBottom:de,onScrollStateChange:pe,activeToolCallId:(K==null?void 0:K.toolCallId)??null,onToolRef:Z,focusedOptionIndex:Q,onToolDecided:$,onRetry:Ze,inputZoneToolCallId:(K==null?void 0:K.toolCallId)??null,messageListRef:r}),i.jsx(kot,{terminalReason:D==null?void 0:D.terminalReason}),i.jsx(yot,{status:E,streamStartTime:I,estimatedTokens:O,permissionMode:P,isWaitingForUser:B??!1,waitingType:H??"approval",isRateLimited:q??!1,rateLimitRetryAfter:J??null,systemStatus:ne}),i.jsx(He,{children:Me&&i.jsx(Eot,{suggestions:F,onChipClick:Ie})}),i.jsx(sot,{celebration:l.activeCelebration,onComplete:l.clearCelebration}),i.jsx(not,{tasks:o.tasks,taskMap:o.taskMap,activeForm:o.activeForm,isCollapsed:o.isCollapsed,onToggleCollapse:o.toggleCollapse,celebratingTaskId:l.celebratingTaskId,onCelebrationComplete:l.clearCelebration,statusTimestamps:o.statusTimestamps}),T&&i.jsx("div",{className:"mx-4 mb-2",children:i.jsx(Iie,{message:T.message,heading:T.heading,subtext:T.message,onRetry:T.retryable?bt:void 0})}),i.jsx(Wit,{chatInputRef:a,input:v,autocomplete:Se,handleSubmit:w,submitContent:C,status:E,sessionBusy:_,stop:j,setInput:k,sessionId:e??"",sessionStatus:D,fileUpload:{pendingFiles:f.pendingFiles,onFilesSelected:f.addFiles,onFileRemove:f.removeFile,isUploading:f.isUploading},interaction:{active:K,pendingApprovals:U.filter(Te=>Te.interactiveType==="approval"),focusedOptionIndex:Q,onToolRef:Z,onToolDecided:$},sync:{connectionState:V}})]})}function _ot(e){const t=je(n=>n.loadCanvasForSession);x.useEffect(()=>{e&&t(e)},[e,t])}function Not(){const[e]=Jf();return _ot(e),i.jsx(Tot,{sessionId:e})}function jot({onClearFilters:e,filterDescription:t}){return i.jsxs(oe.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.3,ease:"easeOut"},className:"flex flex-col items-center justify-center gap-3 py-12 text-center",children:[i.jsx(BX,{className:"text-muted-foreground/50 size-10"}),i.jsx("p",{className:"text-muted-foreground text-sm",children:t?`No agents match ${t}`:"No agents match your filters"}),i.jsx(ve,{variant:"outline",size:"sm",onClick:e,children:"Clear filters"})]})}const NM=WX({search:GX({fields:[e=>tn(e),e=>e.name,e=>e.description,e=>e.capabilities.join(" ")]}),status:Kp({field:e=>e.healthStatus,options:["active","inactive","stale","unreachable"],multi:!0,label:"Status",labels:{active:"Active",inactive:"Inactive",stale:"Stale",unreachable:"Unreachable"},colors:{active:"text-emerald-400",inactive:"text-amber-400",stale:"text-muted-foreground",unreachable:"text-red-400"}}),runtime:Kp({field:e=>e.runtime,options:["claude-code","cursor","codex","other"],label:"Runtime",labels:{"claude-code":"Claude Code",cursor:"Cursor",codex:"Codex",other:"Other"}}),lastSeen:V2e({field:e=>e.lastSeenAt,presets:["1h","24h","7d","30d"],label:"Last seen"}),namespace:Kp({field:e=>e.namespace,options:[],dynamic:!0,label:"Namespace"})}),vH={name:{label:"Name",accessor:e=>tn(e)},lastSeen:{label:"Last seen",accessor:e=>e.lastSeenAt??"",direction:"desc"},status:{label:"Status",accessor:e=>e.healthStatus},registered:{label:"Registered",accessor:e=>e.registeredAt,direction:"desc"}},Aot={active:{label:"Active",dotClass:"bg-emerald-500"},inactive:{label:"Inactive",dotClass:"bg-amber-500"},stale:{label:"Stale",dotClass:"bg-muted-foreground/50"},unreachable:{label:"Unreachable",dotClass:"bg-red-500"}};function Rot({status:e}){const t=Aot[e];return i.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[i.jsx("span",{className:X("size-2 rounded-full",t.dotClass)}),i.jsx("span",{className:"text-muted-foreground text-xs",children:t.label})]})}function Mot(e){return[{accessorKey:"name",header:"Agent",cell:({row:t})=>{const n=t.original,{color:s,emoji:r}=Lu(n);return i.jsxs("button",{type:"button",className:"flex min-w-0 items-center gap-2 text-left",onClick:()=>e.onNavigate(n.projectPath??""),children:[i.jsx(db,{color:s,emoji:r,size:"xs",healthStatus:n.healthStatus}),i.jsxs("span",{className:"min-w-0 flex-1",children:[i.jsx("span",{className:"block truncate text-sm font-medium hover:underline",children:tn(n)}),n.description&&i.jsx("span",{className:"text-muted-foreground block max-w-[300px] truncate text-xs max-sm:hidden",children:n.description})]}),n.isDefault&&i.jsxs(Ot,{variant:"outline",className:"shrink-0 text-[10px]",children:[i.jsx(HX,{className:"mr-0.5 size-2.5 fill-current"}),"Default"]})]})}},{accessorKey:"healthStatus",header:"Status",cell:({row:t})=>i.jsx(Rot,{status:t.original.healthStatus})},{accessorKey:"runtime",header:"Runtime",meta:{hideOnMobile:!0},cell:({row:t})=>i.jsx(Ot,{variant:"secondary",className:"text-xs",children:t.original.runtime})},{accessorKey:"projectPath",header:"Project",meta:{hideOnMobile:!0},cell:({row:t})=>{const n=t.original.projectPath;if(!n)return i.jsx("span",{className:"text-muted-foreground text-xs",children:"—"});const s=n.split("/").filter(Boolean),r=s.length<=2?n:s.slice(-2).join("/");return i.jsx("span",{className:"text-muted-foreground max-w-[200px] truncate font-mono text-xs",children:r})}},{accessorKey:"sessionCount",header:"Sessions",meta:{hideOnMobile:!0},cell:({row:t})=>{const n=t.original.sessionCount;return n===0?i.jsx("span",{className:"text-muted-foreground text-xs",children:"—"}):i.jsxs(Ot,{variant:"outline",className:"text-xs",children:[n," active"]})}},{accessorKey:"lastSeenAt",header:"Last Seen",cell:({row:t})=>i.jsx("span",{className:"text-muted-foreground text-xs tabular-nums",children:lM(t.original.lastSeenAt)})},{id:"actions",header:"",cell:({row:t})=>{const n=t.original;return i.jsxs("div",{className:"flex items-center justify-end gap-1",children:[i.jsx(ve,{variant:"ghost",size:"sm",className:"size-8 p-0",onClick:s=>{s.stopPropagation(),e.onStartSession(n.projectPath??"")},"aria-label":`Chat with ${tn(n)}`,children:i.jsx(Wf,{className:"size-4"})}),i.jsx(ve,{variant:"ghost",size:"sm",className:"size-8 p-0",onClick:s=>{s.stopPropagation(),e.onManage(n.projectPath??"")},"aria-label":`Manage ${tn(n)}`,children:i.jsx(Qi,{className:"size-4"})})]})}}]}function Dot({agents:e,isLoading:t}){var w;const n=cs(),s=Fe(),r=eQ(NM,{debounce:{search:200}}),{sessions:a}=Wl(),o=x.useMemo(()=>[...new Set(e.map(C=>C.namespace).filter(C=>!!C))],[e]),l=x.useMemo(()=>KX(e,NM,r.values,vH,{field:r.sortField,direction:r.sortDirection}),[e,r.values,r.sortField,r.sortDirection]),c=x.useMemo(()=>{const C={};for(const E of e){const T=E.projectPath;C[E.id]=T?a.filter(_=>_.cwd===T).length:0}return C},[e,a]),{data:u}=mt({queryKey:["config"],queryFn:()=>s.getConfig(),staleTime:3e4}),f=x.useMemo(()=>l.map(C=>{var E;return{...C,sessionCount:c[C.id]??0,isDefault:((E=u==null?void 0:u.agents)==null?void 0:E.defaultAgent)===C.name}}),[l,c,(w=u==null?void 0:u.agents)==null?void 0:w.defaultAgent]),h=je(C=>C.setRightPanelOpen),m=je(C=>C.setActiveRightPanelTab),g=x.useCallback(C=>{Eu.getState().openHub(C),m("agent-hub"),h(!0)},[m,h]),b=x.useCallback(C=>{n({to:"/session",search:{dir:C}})},[n]),v=x.useCallback(C=>{n({to:"/session",search:{dir:C}})},[n]),k=x.useMemo(()=>Mot({onNavigate:b,onManage:g,onStartSession:v}),[b,g,v]);return t?i.jsx("div",{className:"space-y-3 p-4",children:Array.from({length:3}).map((C,E)=>i.jsx(on,{className:"h-14 w-full rounded-xl"},E))}):i.jsxs("div",{className:"flex h-full flex-col overflow-hidden",children:[i.jsxs(xa,{state:r,children:[i.jsx(xa.Search,{placeholder:"Filter agents..."}),i.jsx(xa.Primary,{name:"status"}),i.jsx(xa.AddFilter,{dynamicOptions:{namespace:o}}),i.jsx(xa.Sort,{options:vH}),i.jsx(xa.ResultCount,{count:l.length,total:e.length,noun:"agent"}),i.jsx(xa.ActiveFilters,{})]}),i.jsx(so,{className:"min-h-0 flex-1",children:i.jsx("div",{className:"px-4 pb-4",children:l.length===0&&e.length>0?i.jsx(jot,{onClearFilters:r.clearAll,filterDescription:r.describeActive()}):i.jsx(LOe,{columns:k,data:f,emptyMessage:"No agents registered.",className:"border-0"})})})]})}const Oot={animate:{transition:{staggerChildren:.1}}},Iot={initial:{opacity:0},animate:{opacity:.2,transition:{duration:.3}}};function mj(){return i.jsxs(oe.div,{variants:Iot,className:"rounded-xl border border-dashed px-4 py-3",children:[i.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[i.jsx("div",{className:"bg-muted size-3 rounded-full"}),i.jsx("div",{className:"bg-muted h-3 w-32 rounded"}),i.jsx("div",{className:"bg-muted h-3 w-16 rounded"}),i.jsx("div",{className:"bg-muted ml-auto h-3 w-10 rounded"})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:"bg-muted h-2.5 w-48 rounded"}),i.jsx("div",{className:"bg-muted h-2.5 w-20 rounded"})]})]})}function Pot(){const[e,t]=x.useState(!1);return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"relative w-full max-w-2xl px-4",children:[i.jsxs(oe.div,{variants:Oot,initial:"initial",animate:"animate",className:"space-y-3",children:[i.jsx(mj,{}),i.jsx(mj,{}),i.jsx(mj,{})]}),i.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-4",children:[i.jsx("p",{className:"text-lg font-semibold",children:"Import Your Projects"}),i.jsxs(ve,{size:"sm",className:"gap-1.5",onClick:()=>t(!0),children:[i.jsx(a_e,{className:"size-3.5"}),"Search for Projects"]})]})]}),i.jsx(Ta,{open:e,onOpenChange:t,children:i.jsxs(_a,{className:"max-w-2xl",children:[i.jsx(Ni,{children:i.jsx(ei,{children:"Import Projects"})}),i.jsx(Yae,{})]})})]})}function Lot(){const{data:e,isLoading:t}=bVe(),n=(e==null?void 0:e.denied)??[];return t?i.jsx("div",{className:"flex items-center justify-center p-8",children:i.jsx(Xn,{className:"text-muted-foreground size-5 animate-spin"})}):n.length===0?i.jsx(Zae,{icon:Qk,headline:"No blocked paths",description:"When you deny agent paths during discovery, they appear here. This is a healthy state."}):i.jsx("div",{className:"space-y-2 p-4",children:n.map(s=>i.jsxs("div",{className:"flex items-center justify-between rounded-xl border px-4 py-3",children:[i.jsxs("div",{children:[i.jsx("p",{className:"font-mono text-sm",children:s.path}),s.reason&&i.jsx("p",{className:"text-muted-foreground text-xs",children:s.reason})]}),i.jsx(Ot,{variant:"outline",className:"text-xs",children:s.deniedBy})]},s.path))})}function Fot(){return i.jsx(CJe,{})}const zot=x.lazy(()=>Ar(()=>import("./TopologyGraph-BkPzBOVe.js"),__vite__mapDeps([0,1])).then(e=>({default:e.TopologyGraph})));function Bot(){const{view:e,agent:t}=Vl({from:"/_shell/agents"}),n=t,s=cs(),r=Zs(),a=je(v=>v.setRightPanelOpen),o=je(v=>v.setActiveRightPanelTab),[,l]=eh(),{data:c,isLoading:u,isError:f,refetch:h}=rO(),m=x.useMemo(()=>(c==null?void 0:c.namespaces.flatMap(v=>v.agents))??[],[c]),b=!(m.length>0)&&!u&&!f&&(e==="list"||e==="topology");return f?i.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-8 text-center",children:[i.jsx("div",{className:"bg-destructive/10 rounded-xl p-3",children:i.jsx(Yr,{className:"text-destructive size-6"})}),i.jsxs("div",{className:"space-y-1",children:[i.jsx("p",{className:"text-sm font-medium",children:"Could not load agents"}),i.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:"The mesh API is unreachable. Check that the server is running correctly."})]}),i.jsx(ve,{size:"sm",onClick:()=>void h(),className:"mt-1",children:"Retry"})]}):i.jsx(He,{mode:"wait",initial:!1,children:b?i.jsx(oe.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:"flex h-full flex-col items-center justify-center",children:i.jsx(Pot,{})},"mode-a"):i.jsx(oe.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:"flex h-full flex-col",children:i.jsxs(He,{mode:"wait",initial:!1,children:[e==="list"&&i.jsx(oe.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:"flex h-full flex-col",children:i.jsx(Dot,{agents:m,isLoading:u})},"view-list"),e==="topology"&&i.jsx(oe.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:"relative flex-1 overflow-hidden",children:i.jsxs("div",{className:"flex h-full",children:[i.jsx(oe.div,{layout:!0,className:"min-w-0 flex-1",transition:{type:"spring",stiffness:300,damping:30},children:i.jsx("div",{className:"absolute inset-0",children:i.jsx(x.Suspense,{fallback:i.jsxs("div",{className:"text-muted-foreground flex h-full items-center justify-center text-sm",children:[i.jsx(Xn,{className:"mr-2 size-4 animate-spin"}),"Loading topology..."]}),children:i.jsx(zot,{onSelectAgent:v=>s({to:"/agents",search:k=>({...k,agent:v})}),onOpenSettings:(v,k)=>{Eu.getState().openHub(k),o("agent-hub"),a(!0)},onOpenChat:v=>l(v)})})})}),r?i.jsx(ih,{open:!!n,onOpenChange:v=>!v&&s({to:"/agents",search:k=>({...k,agent:void 0})}),children:i.jsx(oh,{children:n&&i.jsx(n$,{agentId:n,onClose:()=>s({to:"/agents",search:v=>({...v,agent:void 0})})})})}):i.jsx(He,{children:n&&i.jsx(oe.div,{initial:{width:0,opacity:0},animate:{width:256,opacity:1},exit:{width:0,opacity:0},transition:{type:"spring",stiffness:300,damping:30},className:"bg-background overflow-y-auto border-l",children:i.jsx(n$,{agentId:n,onClose:()=>s({to:"/agents",search:v=>({...v,agent:void 0})})})})})]})},"view-topology"),e==="denied"&&i.jsx(oe.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},children:i.jsx(Lot,{})},"view-denied"),e==="access"&&i.jsx(oe.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},children:i.jsx(Fot,{})},"view-access")]})},"mode-b")})}const $ot={initial:{opacity:0,y:6},animate:{opacity:1,y:0,transition:{duration:.2,ease:"easeOut"}}};function Hot(){const e=x.useId(),t=x.useMemo(()=>`${e.split("").reduce((s,r)=>s+r.charCodeAt(0),0)%40+50}%`,[e]);return i.jsxs(dx,{children:[i.jsx(_o,{className:"w-28 py-1.5 pr-0 pl-2 max-sm:hidden",children:i.jsx(on,{className:"h-3 w-20"})}),i.jsx(_o,{className:"w-24 py-1.5 pr-0 max-sm:hidden",children:i.jsx(on,{className:"h-5 w-20 rounded-full"})}),i.jsx(_o,{className:"py-1.5 max-sm:pl-2",children:i.jsx(on,{className:"h-3 rounded",style:{width:t}})}),i.jsx(_o,{className:"w-16 py-1.5 max-sm:w-10"})]})}function Uot(){return i.jsxs("div",{"data-slot":"activity-timeline-skeleton",className:"space-y-1",children:[i.jsx("div",{className:"py-2",children:i.jsx(on,{className:"h-3 w-16 rounded"})}),i.jsx(TC,{children:i.jsx(_C,{children:Array.from({length:5}).map((e,t)=>i.jsx(Hot,{},t))})})]})}function Vot({items:e,isLoading:t,isFiltered:n,className:s}){const r=x.useMemo(()=>MXe(e,new Date),[e]),{containerRef:a,handleKeyDown:o}=AXe(e.length);return t&&e.length===0?i.jsx("div",{"data-slot":"activity-timeline",className:X("px-4",s),children:i.jsx(Uot,{})}):e.length===0?i.jsx("div",{"data-slot":"activity-timeline",className:X(s),children:i.jsx(HXe,{isFiltered:n})}):i.jsx("div",{ref:a,onKeyDown:o,"data-slot":"activity-timeline",className:X("px-4",s),children:r.map(l=>i.jsxs("section",{children:[i.jsx(LXe,{label:l.label}),i.jsx(oe.div,{variants:$ot,initial:"initial",animate:"animate",children:i.jsx(TC,{children:i.jsx(_C,{children:l.items.map(c=>i.jsx(Pae,{item:c},c.id))})})})]},l.label))})}function qot({onLoadMore:e,isFetching:t,hasNextPage:n,className:s}){return n?i.jsx(oe.div,{"data-slot":"activity-load-more",initial:{opacity:0},animate:{opacity:1},transition:{duration:.2,delay:.1},className:X("flex justify-center px-4 py-4",s),children:i.jsxs(ve,{variant:"outline",size:"sm",onClick:e,disabled:t,className:"gap-2",children:[t&&i.jsx(Xn,{className:"size-3.5 animate-spin","aria-hidden":!0}),"Load 50 more events"]})}):null}function Got(){const{queryFilters:e,isFiltered:t}=xO(),n=jXe(),{data:s,isLoading:r,isFetchingNextPage:a,hasNextPage:o,fetchNextPage:l}=NXe(e),c=x.useMemo(()=>(s==null?void 0:s.pages.flatMap(u=>u.items))??[],[s]);return i.jsx(so,{className:"h-full",children:i.jsxs("div",{className:"mx-auto max-w-4xl space-y-4 py-6 sm:py-8",children:[i.jsx(YXe,{lastVisitedAt:n,items:c,className:"mx-4"}),i.jsx(Vot,{items:c,isLoading:r,isFiltered:t}),i.jsx(qot,{onLoadMore:()=>void l(),isFetching:a,hasNextPage:!!o})]})})}function Kot(){const e=td(),{data:t=[],isLoading:n,isError:s,refetch:r}=XC(e),[a,o]=x.useState(!1),[l,c]=x.useState(),[u,f]=x.useState(null),h=t.some(R=>R.agentId),{data:m}=ji(void 0,h||!n),g=x.useMemo(()=>{const R=new Map;for(const D of(m==null?void 0:m.agents)??[])R.set(D.id,D);return R},[m]),{externalTrigger:b,clear:v}=ub(),[k,w]=x.useState(!1);b&&!k&&!a?(w(!0),c(void 0),o(!0),v()):!b&&k&&w(!1);const C=R=>{f(R),c(void 0),o(!0)},E=()=>{f(null),c(void 0),o(!0)},T=R=>{c(R),o(!0)},_=R=>{o(R),R||f(null)};if(!e)return i.jsx(a5,{icon:mre.tasks,name:"Tasks",description:"Tasks runs AI agent tasks on a schedule. Start DorkOS with the --tasks flag to enable it.",command:"dorkos --tasks"});if(s)return i.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-8 text-center",children:[i.jsx("div",{className:"bg-destructive/10 rounded-xl p-3",children:i.jsx(Yr,{className:"text-destructive size-6"})}),i.jsxs("div",{className:"space-y-1",children:[i.jsx("p",{className:"text-sm font-medium",children:"Could not load tasks"}),i.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:"The tasks API is unreachable. Check that the server is running correctly."})]}),i.jsx(ve,{size:"sm",onClick:()=>void r(),className:"mt-1",children:"Retry"})]});const j=t.length>0;return i.jsxs(i.Fragment,{children:[!j&&!n?i.jsx(oe.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.15},className:"flex h-full flex-col items-center justify-center",children:i.jsx(Tre,{onCreateWithPreset:C,onCreateBlank:E})}):i.jsx(oe.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.15},className:"flex h-full flex-col",children:i.jsx(tqe,{tasks:t,isLoading:n,agentMap:g,onEditTask:T})}),i.jsx(qR,{open:a,onOpenChange:_,editTask:l,initialPreset:u})]})}function Wot(){return i.jsx("div",{className:"flex h-full flex-col overflow-y-auto",children:i.jsx(gtt,{})})}function Yot(){return i.jsx("div",{className:"flex h-full flex-col",children:i.jsx(btt,{})})}const Yie=Pde()({component:()=>i.jsx(HM,{}),notFoundComponent:sre}),id=Nu({getParentRoute:()=>Yie,id:"_shell",component:Ttt}),Zot=sC(me({session:W().optional(),dir:W().optional()})),Xot=sC(me({detail:Dt(["dead-letter","failed-run","offline-agent"]).optional(),itemId:W().optional()})),Qot=sC(me({view:Dt(["list","topology","denied","access"]).optional().default("list"),sort:W().optional().default("lastSeen:desc"),agent:W().optional()}).merge(NM.searchValidator)),Jot=Nu({getParentRoute:()=>id,path:"/",validateSearch:ok(Xot),component:$tt,beforeLoad:({location:e})=>{const t=new URLSearchParams(e.searchStr),n=t.get("session");if(n)throw vS({to:"/session",search:{session:n,dir:t.get("dir")??void 0}})}});function elt({context:{queryClient:e},location:t}){const n=new URLSearchParams(t.searchStr);if(n.get("session"))return;const r=n.get("dir")??void 0,a=e.getQueryData(["sessions",r??null]);throw a&&a.length>0?vS({to:"/session",search:{session:a[0].id,dir:r},replace:!0}):vS({to:"/session",search:{session:crypto.randomUUID(),dir:r},replace:!0})}const tlt=Nu({getParentRoute:()=>id,path:"/session",validateSearch:ok(Zot),component:Not,loader:elt}),nlt=Nu({getParentRoute:()=>id,path:"/agents",validateSearch:ok(Qot),component:Bot}),slt=Nu({getParentRoute:()=>id,path:"/tasks",component:Kot}),rlt=Nu({getParentRoute:()=>id,path:"/marketplace",component:Wot}),alt=Nu({getParentRoute:()=>id,path:"/marketplace/sources",component:Yot}),ilt=sC(me({categories:W().optional(),actorType:W().optional(),actorId:W().optional(),since:W().optional()})),olt=Nu({getParentRoute:()=>id,path:"/activity",validateSearch:ok(ilt),component:Got}),llt=Yie.addChildren([id.addChildren([Jot,tlt,nlt,slt,olt,rlt,alt])]);function clt(e){return Yde({routeTree:llt,context:{queryClient:e},defaultPreload:"intent",defaultErrorComponent:jUe,defaultNotFoundComponent:sre})}function ult({onSuccess:e}){const t=Fe(),[n,s]=x.useState(null),[r,a]=x.useState(!1),[o,l]=x.useState(""),c=x.useCallback(async u=>{a(!0),s(null);try{const f=await t.verifyTunnelPasscode(u);if(f.ok)e();else{const h=f.retryAfter?`Too many attempts. Try again in ${Math.ceil(f.retryAfter/60)} minutes.`:f.error??"Incorrect passcode";s(h),l("")}}catch{s("Connection error. Try again."),l("")}finally{a(!1)}},[t,e]);return i.jsx("div",{className:"bg-background flex min-h-dvh items-center justify-center p-4",children:i.jsxs("div",{className:"flex w-full max-w-sm flex-col items-center gap-8",children:[i.jsx(_m,{variant:"white",size:120}),i.jsxs("div",{className:"flex flex-col items-center gap-2 text-center",children:[i.jsx("h1",{className:"text-foreground text-lg font-semibold",children:"Enter passcode"}),i.jsx("p",{className:"text-muted-foreground text-sm",children:"Enter your 6-digit passcode to access this instance."})]}),i.jsx(Nae,{maxLength:6,pattern:_ae,inputMode:"numeric",value:o,onChange:l,onComplete:c,disabled:r,autoFocus:!0,children:i.jsx(jae,{children:[0,1,2,3,4,5].map(u=>i.jsx(Aae,{index:u,className:n?"border-destructive":""},u))})}),n&&i.jsx("p",{className:"text-destructive text-sm",children:n}),r&&i.jsx("p",{className:"text-muted-foreground text-sm",children:"Verifying..."})]})})}function dlt({children:e}){const t=Fe(),n=window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1",[s,r]=x.useState(n?"unlocked":"checking");return x.useEffect(()=>{n||t.checkTunnelSession().then(a=>{!a.passcodeRequired||a.authenticated?r("unlocked"):r("locked")}).catch(()=>{r("unlocked")})},[t,n]),s==="checking"?null:s==="locked"?i.jsx(ult,{onSuccess:()=>r("unlocked")}):i.jsx(i.Fragment,{children:e})}const flt=50,Zie="puzzle";function SH(e,t){const n=[];return{api:{id:e,registerComponent(r,a,o,l){const c=hlt(r,`${e}:${a}`,o,l),u=t.registry.register(r,c);return n.push(u),u},registerCommand(r,a,o,l){const c=`ext:${e}:${r}`,u={id:`${e}:${r}`,label:a,icon:(l==null?void 0:l.icon)??Zie,action:c,shortcut:l==null?void 0:l.shortcut,category:"feature"},f=t.registry.register("command-palette.items",u);t.registerCommandHandler(c,o);const h=()=>{f(),t.unregisterCommandHandler(c)};return n.push(h),h},registerDialog(r,a){const o=`${e}:${r}`,l={id:o,component:a,openStateKey:`ext-dialog:${o}`},c=t.registry.register("dialog",l);n.push(c);let u=!1;return{open:()=>{u=!0},close:()=>{u=!1},get _openState(){return u}}},registerSettingsTab(r,a,o){const l={id:`${e}:${r}`,label:a,icon:void 0,component:o},c=t.registry.register("settings.tabs",l);return n.push(c),c},executeCommand(r){MF(t.dispatcherContext,r)},openCanvas(r){MF(t.dispatcherContext,{action:"open_canvas",content:r})},navigate(r){t.navigate({to:r})},getState(){const r=t.appStore.getState();return wH(r)},subscribe(r,a){const o=t.appStore.subscribe(l=>r(wH(l)),a);return n.push(o),o},async loadData(){const r=await fetch(`/api/extensions/${e}/data`);if(r.status===204)return null;if(!r.ok)throw new Error(`loadData failed: ${r.status}`);return r.json()},async saveData(r){const a=await fetch(`/api/extensions/${e}/data`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!a.ok)throw new Error(`saveData failed: ${a.status}`)},notify(r,a){const o=(a==null?void 0:a.type)??"info";rt[o](r)},isSlotAvailable(r){return t.availableSlots.has(r)}},cleanups:n}}function wH(e){return{currentCwd:e.selectedCwd??null,activeSessionId:e.sessionId??null,agentId:null}}function hlt(e,t,n,s){const r={id:t,priority:(s==null?void 0:s.priority)??flt};switch(e){case"dashboard.sections":return{...r,component:n};case"sidebar.tabs":return{...r,component:n,label:t,icon:void 0};case"sidebar.footer":return{...r,onClick:()=>{},label:t,icon:void 0};case"header.actions":return{...r,onClick:()=>{},label:t,icon:void 0};case"right-panel":return{...r,component:n,title:t,icon:void 0,visibleWhen:void 0};case"settings.tabs":return{...r,component:n,label:t,icon:void 0};case"dialog":return{...r,component:n,openStateKey:`ext:${t}`};case"command-palette.items":return{...r,label:t,icon:Zie,action:`ext:${t}`,category:"feature"};default:return console.warn("[ExtensionAPI] Unknown slot:",e),{...r,component:n}}}function plt({extensionId:e,status:t}){const[n,s]=x.useState(String(t.value??"")),[r,a]=x.useState(!1),o=async()=>{a(!0);try{const l=await fetch(`/api/extensions/${e}/settings/${t.key}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:n})});if(!l.ok)throw new Error(`${l.status}`);rt.success(`${t.label} saved`)}catch{rt.error(`Failed to save ${t.label}`)}finally{a(!1)}};return i.jsx(os,{label:t.label,description:t.description??"",orientation:"vertical",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(_n,{value:n,onChange:l=>s(l.target.value),placeholder:t.placeholder??t.key,className:"h-8 min-w-0 flex-1 text-sm",onKeyDown:l=>{l.key==="Enter"&&o()}}),i.jsx(ve,{size:"sm",onClick:o,disabled:r,className:"h-8",children:"Save"})]})})}function mlt({extensionId:e,status:t}){const[n,s]=x.useState(String(t.value??"")),[r,a]=x.useState(!1),o=async()=>{const l=Number(n);if(!Number.isNaN(l)){a(!0);try{const c=await fetch(`/api/extensions/${e}/settings/${t.key}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:l})});if(!c.ok)throw new Error(`${c.status}`);rt.success(`${t.label} saved`)}catch{rt.error(`Failed to save ${t.label}`)}finally{a(!1)}}};return i.jsx(os,{label:t.label,description:t.description??"",orientation:"vertical",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(_n,{type:"number",value:n,onChange:l=>s(l.target.value),placeholder:t.placeholder??t.key,min:t.min,max:t.max,className:"h-8 min-w-0 flex-1 text-sm",onKeyDown:l=>{l.key==="Enter"&&o()}}),i.jsx(ve,{size:"sm",onClick:o,disabled:r,className:"h-8",children:"Save"})]})})}function glt({extensionId:e,status:t,onChanged:n}){const[s,r]=x.useState(!1),a=!!t.value,o=async l=>{r(!0);try{const c=await fetch(`/api/extensions/${e}/settings/${t.key}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:l})});if(!c.ok)throw new Error(`${c.status}`);rt.success(`${t.label} ${l?"enabled":"disabled"}`),await n()}catch{rt.error(`Failed to update ${t.label}`)}finally{r(!1)}};return i.jsx(os,{label:t.label,description:t.description??"",children:i.jsx(Ks,{checked:a,onCheckedChange:o,disabled:s})})}function xlt({extensionId:e,status:t,onChanged:n}){const[s,r]=x.useState(!1),a=async o=>{var l;r(!0);try{const u=((l=t.options)==null?void 0:l.every(h=>typeof h.value=="number"))?Number(o):o,f=await fetch(`/api/extensions/${e}/settings/${t.key}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:u})});if(!f.ok)throw new Error(`${f.status}`);rt.success(`${t.label} updated`),await n()}catch{rt.error(`Failed to update ${t.label}`)}finally{r(!1)}};return i.jsx(os,{label:t.label,description:t.description??"",orientation:"vertical",children:i.jsxs(Bn,{value:String(t.value??""),onValueChange:a,disabled:s,children:[i.jsx(Dn,{className:"h-8 text-sm",children:i.jsx($n,{})}),i.jsx(On,{children:(t.options??[]).map(o=>i.jsx(yt,{value:String(o.value),children:o.label},String(o.value)))})]})})}function ylt(e,t,n,s){const r=new Map,a=(o,l)=>{r.has(o)||r.set(o,[]),r.get(o).push(l)};for(const o of e)a(o.group,{kind:"secret",declaration:o,isSet:t.get(o.key)??!1});for(const o of s){const l=n.find(c=>c.key===o.key);l&&a(l.group,{kind:"setting",declaration:l,status:o})}return r}function blt({extensionId:e,secrets:t,settings:n}){const[s,r]=x.useState(new Map),[a,o]=x.useState([]),[l,c]=x.useState(!0),u=x.useCallback(async()=>{try{const[b,v]=await Promise.all([t.length>0?fetch(`/api/extensions/${e}/secrets`):Promise.resolve(null),n.length>0?fetch(`/api/extensions/${e}/settings`):Promise.resolve(null)]);if(b!=null&&b.ok){const k=await b.json();r(new Map(k.map(w=>[w.key,w.isSet])))}if(v!=null&&v.ok){const k=await v.json();o(k)}}catch{}finally{c(!1)}},[e,t.length,n.length]);if(x.useEffect(()=>{u()},[u]),l)return i.jsx(Sa,{children:i.jsx(Wr,{children:i.jsx("div",{className:"text-muted-foreground py-4 text-center text-sm",children:"Loading…"})})});const f=ylt(t,s,n,a),h=f.get(void 0),m=[...f.entries()].filter(([b])=>b!==void 0);function g(b){if(b.kind==="secret")return i.jsx(Slt,{extensionId:e,secret:b.declaration,isSet:b.isSet,onChanged:u},b.declaration.key);switch(b.status.type){case"text":return i.jsx(plt,{extensionId:e,status:b.status},b.declaration.key);case"number":return i.jsx(mlt,{extensionId:e,status:b.status},b.declaration.key);case"boolean":return i.jsx(glt,{extensionId:e,status:b.status,onChanged:u},b.declaration.key);case"select":return i.jsx(xlt,{extensionId:e,status:b.status,onChanged:u},b.declaration.key)}}return i.jsxs(i.Fragment,{children:[h&&h.length>0&&i.jsx(Sa,{children:i.jsx(Wr,{children:h.map(g)})}),m.map(([b,v])=>i.jsx(vlt,{groupName:b,items:v,renderItem:g},b))]})}function vlt({groupName:e,items:t,renderItem:n}){const[s,r]=x.useState(!0);return i.jsx(VD,{open:s,onOpenChange:r,trigger:e,children:t.map(n)})}function Slt({extensionId:e,secret:t,isSet:n,onChanged:s}){const[r,a]=x.useState(""),[o,l]=x.useState(!1),c=async()=>{if(r.trim()){l(!0);try{const h=await fetch(`/api/extensions/${e}/secrets/${t.key}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:r})});if(!h.ok)throw new Error(`${h.status}`);a(""),rt.success(`${t.label} saved`),await s()}catch{rt.error(`Failed to save ${t.label}`)}finally{l(!1)}}},u=async()=>{l(!0);try{const h=await fetch(`/api/extensions/${e}/secrets/${t.key}`,{method:"DELETE"});if(!h.ok)throw new Error(`${h.status}`);rt.success(`${t.label} removed`),await s()}catch{rt.error(`Failed to remove ${t.label}`)}finally{l(!1)}},f=t.description??(t.required?"Required":"Optional");return n?i.jsx(os,{label:t.label,description:f,children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs(Ot,{variant:"outline",className:"text-muted-foreground gap-1",children:[i.jsx(Zt,{className:"size-3"}),"Configured"]}),i.jsxs(ve,{variant:"ghost",size:"sm",onClick:u,disabled:o,className:"text-muted-foreground hover:text-destructive h-7 px-2 text-xs",children:[i.jsx(ls,{className:"size-3"}),"Clear"]})]})}):i.jsx(os,{label:t.label,description:f,children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(WS,{value:r,onChange:h=>a(h.target.value),placeholder:t.placeholder??t.key,className:"h-8 w-48 text-sm",onKeyDown:h=>{h.key==="Enter"&&c()}}),i.jsx(ve,{size:"sm",onClick:c,disabled:o||!r.trim(),className:"h-8",children:"Save"})]})})}async function kH(){const e=await fetch("/api/extensions");return e.ok?e.json():(console.error("[extensions] Failed to fetch extension list:",e.status),[])}async function wlt(e){try{return await Ar(()=>import(`/api/extensions/${e}/bundle`),[])}catch(t){return console.error(`[extensions] Failed to import ${e}:`,t),null}}async function CH(e){if(!(!e.hasServerEntry&&!e.hasDataProxy))try{const t=await fetch(`/api/extensions/${e.id}/init-server`,{method:"POST"});if(!t.ok){const n=await t.json().catch(()=>({error:"Unknown error"}));console.warn(`[extensions] Server init failed for ${e.id}:`,n.error??t.statusText)}}catch(t){console.error(`[extensions] Server init error for ${e.id}:`,t)}}class klt{constructor(t){nt(this,"loaded",new Map);nt(this,"deps");nt(this,"disposed",!1);this.deps=t}async initialize(){const t=await kH(),n=t.filter(o=>o.status==="compiled"&&o.bundleReady);if(n.length===0)return console.log("[extensions] No extensions to load"),{extensions:t,loaded:this.loaded};const s=await Promise.all(n.map(async o=>({rec:o,module:await wlt(o.id)}))),r=[],a=[];for(const{rec:o,module:l}of s){if(this.disposed)break;if(l)try{const{api:c,cleanups:u}=SH(o.id,this.deps),f=l.activate(c);this.autoRegisterConfigTab(o,u);const h={id:o.id,manifest:o.manifest,module:l,api:c,cleanups:u,deactivate:typeof f=="function"?f:void 0};this.loaded.set(o.id,h),r.push(`${o.manifest.name} v${o.manifest.version}`),a.push(CH(o))}catch(c){console.error(`[extensions] Failed to activate ${o.id}:`,c)}}return await Promise.all(a),r.length>0&&console.log(`[extensions] Activated: ${r.join(", ")}`),{extensions:t,loaded:this.loaded}}deactivateAll(){var t;this.disposed=!0;for(const[n,s]of this.loaded){try{(t=s.deactivate)==null||t.call(s)}catch(r){console.error(`[extensions] Error calling deactivate for ${n}:`,r)}for(const r of s.cleanups)try{r()}catch(a){console.error(`[extensions] Error in cleanup for ${n}:`,a)}}this.loaded.clear()}async reloadExtensions(t){var s;for(const r of t){const a=this.loaded.get(r);if(a){try{(s=a.deactivate)==null||s.call(a)}catch(o){console.error(`[extensions] Error deactivating ${r}:`,o)}for(const o of a.cleanups)try{o()}catch(l){console.error(`[extensions] Error in cleanup for ${r}:`,l)}this.loaded.delete(r)}}const n=await kH();for(const r of t){const a=n.find(o=>o.id===r);if(!(!a||a.status!=="compiled"||!a.bundleReady))try{const o=await Ar(()=>import(`/api/extensions/${r}/bundle?t=${Date.now()}`),[]),{api:l,cleanups:c}=SH(r,this.deps),u=o.activate(l);this.autoRegisterConfigTab(a,c),this.loaded.set(r,{id:r,manifest:a.manifest,module:o,api:l,cleanups:c,deactivate:typeof u=="function"?u:void 0}),await CH(a),console.log(`[extensions] Hot-reloaded: ${a.manifest.name} v${a.manifest.version}`)}catch(o){console.error(`[extensions] Failed to hot-reload ${r}:`,o)}}return{extensions:n,loaded:this.loaded}}getLoaded(){return this.loaded}autoRegisterConfigTab(t,n){var f,h;const s=(f=t.manifest.serverCapabilities)==null?void 0:f.secrets,r=(h=t.manifest.serverCapabilities)==null?void 0:h.settings;if(!(s!=null&&s.length)&&!(r!=null&&r.length))return;const a=t.id,o=`${a}:settings`,l=s??[],c=r??[],u=this.deps.registry.register("settings.tabs",{id:o,label:t.manifest.name,icon:Qi,component:function(){return x.createElement(blt,{extensionId:a,secrets:l,settings:c})},priority:90});n.push(u)}}const EH=1500;async function Clt(e){try{const t=await fetch("/api/extensions/cwd-changed",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e})});return t.ok?await t.json():(console.error("[extensions] CWD change notification failed:",t.status),null)}catch(t){return console.error("[extensions] CWD change notification error:",t),null}}function Elt(){const e=je(n=>n.selectedCwd),t=x.useRef(void 0);x.useEffect(()=>{if(t.current===void 0){t.current=e;return}t.current!==e&&(t.current=e,Clt(e).then(n=>{!n||!n.changed||(rt.info("Project extensions changed. Reloading...",{duration:EH}),setTimeout(()=>{location.reload()},EH))}))},[e])}const Mf={all:["extensions"],lists:()=>[...Mf.all,"list"],detail:e=>[...Mf.all,"detail",e]};function rct(){return mt({queryKey:Mf.lists(),queryFn:async()=>{const e=await fetch("/api/extensions");if(!e.ok)throw new Error(`Failed to fetch extensions: ${e.status}`);return e.json()},staleTime:1e4,refetchInterval:3e4,refetchIntervalInBackground:!1})}function act(){const e=Ct();return mn({mutationFn:async t=>{const n=await fetch(`/api/extensions/${t}/enable`,{method:"POST"});if(!n.ok)throw new Error(`Failed to enable extension '${t}': ${n.status}`);return n.json()},onSuccess:()=>{e.invalidateQueries({queryKey:Mf.lists()})}})}function ict(){const e=Ct();return mn({mutationFn:async t=>{const n=await fetch(`/api/extensions/${t}/disable`,{method:"POST"});if(!n.ok)throw new Error(`Failed to disable extension '${t}': ${n.status}`);return n.json()},onSuccess:()=>{e.invalidateQueries({queryKey:Mf.lists()})}})}function oct(){const e=Ct();return mn({mutationFn:async()=>{const t=await fetch("/api/extensions/reload",{method:"POST"});if(!t.ok)throw new Error(`Failed to reload extensions: ${t.status}`);return t.json()},onSuccess:()=>{e.invalidateQueries({queryKey:Mf.lists()})}})}const Xie={extensions:[],loaded:new Map,ready:!1},Qie=x.createContext(Xie);function lct(){return x.useContext(Qie)}function Tlt({deps:e,children:t}){const[n,s]=x.useState(Xie),r=x.useRef(null),a=Ct();return Elt(),x.useEffect(()=>{const o=new klt(e);return r.current=o,o.initialize().then(({extensions:l,loaded:c})=>{s({extensions:l,loaded:c,ready:!0})}).catch(l=>{console.error("[extensions] Failed to initialize:",l),s(c=>({...c,ready:!0}))}),()=>{o.deactivateAll(),r.current=null}},[]),jA("extension_reloaded",o=>{const l=r.current;if(!l)return;const c=o;(async()=>{try{const{extensions:u,loaded:f}=await l.reloadExtensions(c.extensionIds);s({extensions:u,loaded:f,ready:!0}),a.invalidateQueries({queryKey:Mf.lists()})}catch(u){console.error("[extensions] Hot reload failed:",u)}})()}),i.jsx(Qie.Provider,{value:n,children:t})}function _lt(){const{register:e}=rD.getState();for(const t of xJe)e("command-palette.items",t);for(const t of yJe)e("command-palette.items",t);for(const t of dXe)e("sidebar.footer",t);for(const t of fXe)e("sidebar.tabs",t);for(const t of int)e("dashboard.sections",t);for(const t of _Ze)e("dialog",t);e("settings.tabs",{id:"extensions",label:"Extensions",icon:FX,component:x.lazy(()=>Ar(()=>import("./index-wLQz6ZAE.js"),[]).then(t=>({default:t.ExtensionsSettingsTab}))),priority:70}),e("right-panel",{id:"agent-hub",title:"Agent Profile",icon:Zf,component:x.lazy(()=>Ar(()=>import("./index-Ca1oUJjn.js"),__vite__mapDeps([2,3])).then(t=>({default:t.AgentHub}))),priority:10}),e("right-panel",{id:"canvas",title:"Canvas",icon:IX,component:x.lazy(()=>Ar(()=>import("./index-DK5Wb-8-.js"),__vite__mapDeps([4,3])).then(t=>({default:t.CanvasContent}))),visibleWhen:({pathname:t})=>t==="/session",priority:20})}const Nlt=x.createContext(null),gj={didCatch:!1,error:null};class jlt extends x.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=gj}static getDerivedStateFromError(t){return{didCatch:!0,error:t}}resetErrorBoundary(...t){var s,r;const{error:n}=this.state;n!==null&&((r=(s=this.props).onReset)==null||r.call(s,{args:t,reason:"imperative-api"}),this.setState(gj))}componentDidCatch(t,n){var s,r;(r=(s=this.props).onError)==null||r.call(s,t,n)}componentDidUpdate(t,n){var a,o;const{didCatch:s}=this.state,{resetKeys:r}=this.props;s&&n.error!==null&&Alt(t.resetKeys,r)&&((o=(a=this.props).onReset)==null||o.call(a,{next:r,prev:t.resetKeys,reason:"keys"}),this.setState(gj))}render(){const{children:t,fallbackRender:n,FallbackComponent:s,fallback:r}=this.props,{didCatch:a,error:o}=this.state;let l=t;if(a){const c={error:o,resetErrorBoundary:this.resetErrorBoundary};if(typeof n=="function")l=n(c);else if(s)l=x.createElement(s,c);else if(r!==void 0)l=r;else throw o}return x.createElement(Nlt.Provider,{value:{didCatch:a,error:o,resetErrorBoundary:this.resetErrorBoundary}},l)}}function Alt(e=[],t=[]){return e.length!==t.length||e.some((n,s)=>!Object.is(n,t[s]))}globalThis.React=he;const Rlt=null;he.lazy(()=>Ar(()=>import("./index-zioTSqyj.js"),[]).then(e=>({default:e.ReactQueryDevtoolsPanel})));he.lazy(()=>Ar(()=>import("./index-B2LppgvO.js").then(e=>e.w),[]).then(e=>({default:e.TanStackRouterDevtoolsPanel})));function Mlt(){return window.location.pathname.startsWith("/dev"),i.jsxs(Zce,{client:sD,children:[i.jsx(Sme,{transport:Ilt,children:i.jsx(mNe,{children:i.jsx(Tlt,{deps:Plt,children:i.jsx(dlt,{children:i.jsx(Qde,{router:Dlt})})})})}),!1]})}const Dlt=clt(sD);function Olt(){var e;return(e=window.electronAPI)!=null&&e.getServerPort?`http://localhost:${window.electronAPI.getServerPort()}/api`:"/api"}const Jie=Olt(),Ilt=new L0e(Jie);lr.useHttpSource(Jie);const TH=new Map,Plt={registry:rD.getState(),dispatcherContext:{store:je.getState(),setTheme:e=>{document.documentElement.classList.toggle("dark",e==="dark")}},navigate:e=>{console.warn("[extensions] navigate called before router ready:",e)},appStore:je,availableSlots:new Set(["sidebar.footer","sidebar.tabs","dashboard.sections","header.actions","command-palette.items","dialog","settings.tabs","right-panel"]),registerCommandHandler:(e,t)=>{TH.set(e,t)},unregisterCommandHandler:e=>{TH.delete(e)}};_lt();Ece.createRoot(document.getElementById("root"),{onCaughtError:(e,t)=>{console.error("[dorkos:caught]",e,t.componentStack)},onUncaughtError:(e,t)=>{console.error("[dorkos:uncaught]",e,t.componentStack)}}).render(i.jsx(he.StrictMode,{children:i.jsx(jlt,{FallbackComponent:AUe,children:i.jsx(Mlt,{})})}));const Llt=Object.freeze(Object.defineProperty({__proto__:null,Mermaid:Jse},Symbol.toStringTag,{value:"Module"}));export{Jae as $,$$e as A,ve as B,Vm as C,mu as D,klt as E,Tlt as F,SH as G,lct as H,of as I,cU as J,KL as K,Zlt as L,ed as M,td as N,OWe as O,FX as P,eVe as Q,Xa as R,Rae as S,Kn as T,Sa as U,Wr as V,VD as W,ls as X,os as Y,_n as Z,e_e as _,xy as a,sct as a$,TTe as a0,W_e as a1,Ws as a2,nr as a3,Ar as a4,Ca as a5,ke as a6,Z3 as a7,pu as a8,IX as a9,yt as aA,tn as aB,AGe as aC,uu as aD,hO as aE,MKe as aF,Xm as aG,Qm as aH,TX as aI,lh as aJ,Nr as aK,Xn as aL,df as aM,q1 as aN,th as aO,Bu as aP,nh as aQ,$u as aR,Hu as aS,sh as aT,Vu as aU,Uu as aV,YUe as aW,eg as aX,tg as aY,Es as aZ,ng as a_,q5 as aa,vr as ab,oe as ac,$y as ad,Zs as ae,Xl as af,Ql as ag,Jl as ah,ec as ai,ph as aj,Zre as ak,lO as al,_ot as am,mn as an,Wa as ao,Ya as ap,Qlt as aq,lVe as ar,pre as as,Jlt as at,uVe as au,h0 as av,Bn as aw,Dn as ax,$n as ay,On as az,Fu as b,J3 as b$,pb as b0,VUe as b1,dO as b2,vGe as b3,SGe as b4,aae as b5,cae as b6,KS as b7,Xk as b8,XKe as b9,dC as bA,Vl as bB,cs as bC,Eu as bD,gre as bE,xVe as bF,bVe as bG,Ta as bH,A5e as bI,dEe as bJ,_a as bK,Ni as bL,ei as bM,Ji as bN,EC as bO,Qk as bP,g_e as bQ,Yf as bR,Qy as bS,R5e as bT,qS as bU,Lu as bV,rVe as bW,mqe as bX,jre as bY,He as bZ,db as b_,Gp as ba,Pl as bb,Qi as bc,hje as bd,IRe as be,Js as bf,Yx as bg,dJ as bh,is as bi,nw as bj,br as bk,sAe as bl,Gje as bm,nAe as bn,XQ as bo,Ga as bp,qx as bq,RD as br,NRe as bs,XRe as bt,qRe as bu,RRe as bv,bMe as bw,iJ as bx,km as by,aw as bz,Wn as c,oVe as c0,l3 as c1,c3 as c2,U6 as c3,Zt as c4,kqe as c5,Zf as c6,Wk as c7,KC as c8,PUe as c9,ect as ca,nct as cb,on as cc,Are as cd,eo as ce,Hlt as cf,he as cg,to as ch,Gf as ci,Pu as cj,Ja as ck,lM as cl,zlt as cm,rO as cn,cb as co,X as d,Yn as e,tct as f,Wl as g,fre as h,Fe as i,i as j,Ct as k,aee as l,rxe as m,Mae as n,lk as o,Yr as p,Ps as q,x as r,Ot as s,rt as t,je as u,Ks as v,rct as w,act as x,ict as y,oct as z};
|
|
1085
|
+
${Je}`),f.clearFiles()}return t?t(Je):Je},[f,u,t]),m=x.useCallback(Te=>{o.handleTaskEvent(Te);const Je=o.tasks.map(_t=>_t.id===Te.task.id?{..._t,...Te.task}:_t);l.handleTaskEvent(Te,Je)},[o,l]);x.useCallback(Te=>{n(Te),s.invalidateQueries({queryKey:["session",Te]})},[n,s]);const g=x.useCallback(Te=>{n(Te,{replace:!0}),s.invalidateQueries({queryKey:["session",Te]})},[n,s]),{messages:b,input:v,setInput:k,handleSubmit:w,submitContent:C,status:E,error:T,sessionBusy:_,stop:j,isLoadingHistory:R,sessionStatus:D,streamStartTime:I,estimatedTokens:O,isTextStreaming:L,isWaitingForUser:B,waitingType:H,activeInteraction:K,pendingInteractions:U,markToolCallResponded:$,isRateLimited:q,rateLimitRetryAfter:J,systemStatus:ne,promptSuggestions:F,syncConnectionState:V,retryMessage:G}=Vnt(e,{transformContent:h,onTaskEvent:m,onSessionIdChangeReplace:g,onStreamingDone:x.useCallback(()=>{c&&nxe(),s.invalidateQueries({queryKey:["commands"]})},[c,s])}),{permissionMode:P}=aQ(e,D,E==="streaming"),{handleToolRef:Z,focusedOptionIndex:Q}=Ynt(K),{isAtBottom:re,hasNewMessages:ae,scrollToBottom:de,handleScrollStateChange:pe}=Znt(b,r);est(E,B,o.activeForm,L),x.useEffect(()=>{var Te;(Te=a.current)==null||Te.focus()},[e]);const{data:Oe}=Lae(u,e??void 0),Ve=x.useMemo(()=>(Oe==null?void 0:Oe.commands)??[],[Oe]),{data:$e}=Hat(u),Qe=x.useMemo(()=>$e!=null&&$e.files?nst($e.files):[],[$e]),Se=Jnt({input:v,setInput:k,commands:Ve,fileEntries:Qe,chatInputRef:a}),Ze=x.useCallback(()=>{const Te=[...b].reverse().find(Je=>Je.role==="user");Te!=null&&Te.content&&C(Te.content)},[b,C]),bt=x.useCallback(()=>{const Te=[...b].reverse().find(Je=>Je.role==="user");Te!=null&&Te.content&&G(Te.content)},[b,G]),Me=E==="idle"&&F.length>0&&v.length===0,Ie=x.useCallback(Te=>{var Je;k(Te),(Je=a.current)==null||Je.focus()},[k]);return i.jsxs("div",{"data-testid":"chat-panel",className:"mx-auto flex h-full w-full max-w-7xl flex-col",children:[i.jsx(eat,{messages:b,sessionId:e,isLoadingHistory:R,isTextStreaming:L,isAtBottom:re,hasNewMessages:ae,scrollToBottom:de,onScrollStateChange:pe,activeToolCallId:(K==null?void 0:K.toolCallId)??null,onToolRef:Z,focusedOptionIndex:Q,onToolDecided:$,onRetry:Ze,inputZoneToolCallId:(K==null?void 0:K.toolCallId)??null,messageListRef:r}),i.jsx(kot,{terminalReason:D==null?void 0:D.terminalReason}),i.jsx(yot,{status:E,streamStartTime:I,estimatedTokens:O,permissionMode:P,isWaitingForUser:B??!1,waitingType:H??"approval",isRateLimited:q??!1,rateLimitRetryAfter:J??null,systemStatus:ne}),i.jsx(He,{children:Me&&i.jsx(Eot,{suggestions:F,onChipClick:Ie})}),i.jsx(sot,{celebration:l.activeCelebration,onComplete:l.clearCelebration}),i.jsx(not,{tasks:o.tasks,taskMap:o.taskMap,activeForm:o.activeForm,isCollapsed:o.isCollapsed,onToggleCollapse:o.toggleCollapse,celebratingTaskId:l.celebratingTaskId,onCelebrationComplete:l.clearCelebration,statusTimestamps:o.statusTimestamps}),T&&i.jsx("div",{className:"mx-4 mb-2",children:i.jsx(Iie,{message:T.message,heading:T.heading,subtext:T.message,onRetry:T.retryable?bt:void 0})}),i.jsx(Wit,{chatInputRef:a,input:v,autocomplete:Se,handleSubmit:w,submitContent:C,status:E,sessionBusy:_,stop:j,setInput:k,sessionId:e??"",sessionStatus:D,fileUpload:{pendingFiles:f.pendingFiles,onFilesSelected:f.addFiles,onFileRemove:f.removeFile,isUploading:f.isUploading},interaction:{active:K,pendingApprovals:U.filter(Te=>Te.interactiveType==="approval"),focusedOptionIndex:Q,onToolRef:Z,onToolDecided:$},sync:{connectionState:V}})]})}function _ot(e){const t=je(n=>n.loadCanvasForSession);x.useEffect(()=>{e&&t(e)},[e,t])}function Not(){const[e]=Jf();return _ot(e),i.jsx(Tot,{sessionId:e})}function jot({onClearFilters:e,filterDescription:t}){return i.jsxs(oe.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.3,ease:"easeOut"},className:"flex flex-col items-center justify-center gap-3 py-12 text-center",children:[i.jsx(BX,{className:"text-muted-foreground/50 size-10"}),i.jsx("p",{className:"text-muted-foreground text-sm",children:t?`No agents match ${t}`:"No agents match your filters"}),i.jsx(ve,{variant:"outline",size:"sm",onClick:e,children:"Clear filters"})]})}const NM=WX({search:GX({fields:[e=>tn(e),e=>e.name,e=>e.description,e=>e.capabilities.join(" ")]}),status:Kp({field:e=>e.healthStatus,options:["active","inactive","stale","unreachable"],multi:!0,label:"Status",labels:{active:"Active",inactive:"Inactive",stale:"Stale",unreachable:"Unreachable"},colors:{active:"text-emerald-400",inactive:"text-amber-400",stale:"text-muted-foreground",unreachable:"text-red-400"}}),runtime:Kp({field:e=>e.runtime,options:["claude-code","cursor","codex","other"],label:"Runtime",labels:{"claude-code":"Claude Code",cursor:"Cursor",codex:"Codex",other:"Other"}}),lastSeen:V2e({field:e=>e.lastSeenAt,presets:["1h","24h","7d","30d"],label:"Last seen"}),namespace:Kp({field:e=>e.namespace,options:[],dynamic:!0,label:"Namespace"})}),vH={name:{label:"Name",accessor:e=>tn(e)},lastSeen:{label:"Last seen",accessor:e=>e.lastSeenAt??"",direction:"desc"},status:{label:"Status",accessor:e=>e.healthStatus},registered:{label:"Registered",accessor:e=>e.registeredAt,direction:"desc"}},Aot={active:{label:"Active",dotClass:"bg-emerald-500"},inactive:{label:"Inactive",dotClass:"bg-amber-500"},stale:{label:"Stale",dotClass:"bg-muted-foreground/50"},unreachable:{label:"Unreachable",dotClass:"bg-red-500"}};function Rot({status:e}){const t=Aot[e];return i.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[i.jsx("span",{className:X("size-2 rounded-full",t.dotClass)}),i.jsx("span",{className:"text-muted-foreground text-xs",children:t.label})]})}function Mot(e){return[{accessorKey:"name",header:"Agent",cell:({row:t})=>{const n=t.original,{color:s,emoji:r}=Lu(n);return i.jsxs("button",{type:"button",className:"flex min-w-0 items-center gap-2 text-left",onClick:()=>e.onNavigate(n.projectPath??""),children:[i.jsx(db,{color:s,emoji:r,size:"xs",healthStatus:n.healthStatus}),i.jsxs("span",{className:"min-w-0 flex-1",children:[i.jsx("span",{className:"block truncate text-sm font-medium hover:underline",children:tn(n)}),n.description&&i.jsx("span",{className:"text-muted-foreground block max-w-[300px] truncate text-xs max-sm:hidden",children:n.description})]}),n.isDefault&&i.jsxs(Ot,{variant:"outline",className:"shrink-0 text-[10px]",children:[i.jsx(HX,{className:"mr-0.5 size-2.5 fill-current"}),"Default"]})]})}},{accessorKey:"healthStatus",header:"Status",cell:({row:t})=>i.jsx(Rot,{status:t.original.healthStatus})},{accessorKey:"runtime",header:"Runtime",meta:{hideOnMobile:!0},cell:({row:t})=>i.jsx(Ot,{variant:"secondary",className:"text-xs",children:t.original.runtime})},{accessorKey:"projectPath",header:"Project",meta:{hideOnMobile:!0},cell:({row:t})=>{const n=t.original.projectPath;if(!n)return i.jsx("span",{className:"text-muted-foreground text-xs",children:"—"});const s=n.split("/").filter(Boolean),r=s.length<=2?n:s.slice(-2).join("/");return i.jsx("span",{className:"text-muted-foreground max-w-[200px] truncate font-mono text-xs",children:r})}},{accessorKey:"sessionCount",header:"Sessions",meta:{hideOnMobile:!0},cell:({row:t})=>{const n=t.original.sessionCount;return n===0?i.jsx("span",{className:"text-muted-foreground text-xs",children:"—"}):i.jsxs(Ot,{variant:"outline",className:"text-xs",children:[n," active"]})}},{accessorKey:"lastSeenAt",header:"Last Seen",cell:({row:t})=>i.jsx("span",{className:"text-muted-foreground text-xs tabular-nums",children:lM(t.original.lastSeenAt)})},{id:"actions",header:"",cell:({row:t})=>{const n=t.original;return i.jsxs("div",{className:"flex items-center justify-end gap-1",children:[i.jsx(ve,{variant:"ghost",size:"sm",className:"size-8 p-0",onClick:s=>{s.stopPropagation(),e.onStartSession(n.projectPath??"")},"aria-label":`Chat with ${tn(n)}`,children:i.jsx(Wf,{className:"size-4"})}),i.jsx(ve,{variant:"ghost",size:"sm",className:"size-8 p-0",onClick:s=>{s.stopPropagation(),e.onManage(n.projectPath??"")},"aria-label":`Manage ${tn(n)}`,children:i.jsx(Qi,{className:"size-4"})})]})}}]}function Dot({agents:e,isLoading:t}){var w;const n=cs(),s=Fe(),r=eQ(NM,{debounce:{search:200}}),{sessions:a}=Wl(),o=x.useMemo(()=>[...new Set(e.map(C=>C.namespace).filter(C=>!!C))],[e]),l=x.useMemo(()=>KX(e,NM,r.values,vH,{field:r.sortField,direction:r.sortDirection}),[e,r.values,r.sortField,r.sortDirection]),c=x.useMemo(()=>{const C={};for(const E of e){const T=E.projectPath;C[E.id]=T?a.filter(_=>_.cwd===T).length:0}return C},[e,a]),{data:u}=mt({queryKey:["config"],queryFn:()=>s.getConfig(),staleTime:3e4}),f=x.useMemo(()=>l.map(C=>{var E;return{...C,sessionCount:c[C.id]??0,isDefault:((E=u==null?void 0:u.agents)==null?void 0:E.defaultAgent)===C.name}}),[l,c,(w=u==null?void 0:u.agents)==null?void 0:w.defaultAgent]),h=je(C=>C.setRightPanelOpen),m=je(C=>C.setActiveRightPanelTab),g=x.useCallback(C=>{Eu.getState().openHub(C),m("agent-hub"),h(!0)},[m,h]),b=x.useCallback(C=>{n({to:"/session",search:{dir:C}})},[n]),v=x.useCallback(C=>{n({to:"/session",search:{dir:C}})},[n]),k=x.useMemo(()=>Mot({onNavigate:b,onManage:g,onStartSession:v}),[b,g,v]);return t?i.jsx("div",{className:"space-y-3 p-4",children:Array.from({length:3}).map((C,E)=>i.jsx(on,{className:"h-14 w-full rounded-xl"},E))}):i.jsxs("div",{className:"flex h-full flex-col overflow-hidden",children:[i.jsxs(xa,{state:r,children:[i.jsx(xa.Search,{placeholder:"Filter agents..."}),i.jsx(xa.Primary,{name:"status"}),i.jsx(xa.AddFilter,{dynamicOptions:{namespace:o}}),i.jsx(xa.Sort,{options:vH}),i.jsx(xa.ResultCount,{count:l.length,total:e.length,noun:"agent"}),i.jsx(xa.ActiveFilters,{})]}),i.jsx(so,{className:"min-h-0 flex-1",children:i.jsx("div",{className:"px-4 pb-4",children:l.length===0&&e.length>0?i.jsx(jot,{onClearFilters:r.clearAll,filterDescription:r.describeActive()}):i.jsx(LOe,{columns:k,data:f,emptyMessage:"No agents registered.",className:"border-0"})})})]})}const Oot={animate:{transition:{staggerChildren:.1}}},Iot={initial:{opacity:0},animate:{opacity:.2,transition:{duration:.3}}};function mj(){return i.jsxs(oe.div,{variants:Iot,className:"rounded-xl border border-dashed px-4 py-3",children:[i.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[i.jsx("div",{className:"bg-muted size-3 rounded-full"}),i.jsx("div",{className:"bg-muted h-3 w-32 rounded"}),i.jsx("div",{className:"bg-muted h-3 w-16 rounded"}),i.jsx("div",{className:"bg-muted ml-auto h-3 w-10 rounded"})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:"bg-muted h-2.5 w-48 rounded"}),i.jsx("div",{className:"bg-muted h-2.5 w-20 rounded"})]})]})}function Pot(){const[e,t]=x.useState(!1);return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"relative w-full max-w-2xl px-4",children:[i.jsxs(oe.div,{variants:Oot,initial:"initial",animate:"animate",className:"space-y-3",children:[i.jsx(mj,{}),i.jsx(mj,{}),i.jsx(mj,{})]}),i.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-4",children:[i.jsx("p",{className:"text-lg font-semibold",children:"Import Your Projects"}),i.jsxs(ve,{size:"sm",className:"gap-1.5",onClick:()=>t(!0),children:[i.jsx(a_e,{className:"size-3.5"}),"Search for Projects"]})]})]}),i.jsx(Ta,{open:e,onOpenChange:t,children:i.jsxs(_a,{className:"max-w-2xl",children:[i.jsx(Ni,{children:i.jsx(ei,{children:"Import Projects"})}),i.jsx(Yae,{})]})})]})}function Lot(){const{data:e,isLoading:t}=bVe(),n=(e==null?void 0:e.denied)??[];return t?i.jsx("div",{className:"flex items-center justify-center p-8",children:i.jsx(Xn,{className:"text-muted-foreground size-5 animate-spin"})}):n.length===0?i.jsx(Zae,{icon:Qk,headline:"No blocked paths",description:"When you deny agent paths during discovery, they appear here. This is a healthy state."}):i.jsx("div",{className:"space-y-2 p-4",children:n.map(s=>i.jsxs("div",{className:"flex items-center justify-between rounded-xl border px-4 py-3",children:[i.jsxs("div",{children:[i.jsx("p",{className:"font-mono text-sm",children:s.path}),s.reason&&i.jsx("p",{className:"text-muted-foreground text-xs",children:s.reason})]}),i.jsx(Ot,{variant:"outline",className:"text-xs",children:s.deniedBy})]},s.path))})}function Fot(){return i.jsx(CJe,{})}const zot=x.lazy(()=>Ar(()=>import("./TopologyGraph-DjrSwcZ7.js"),__vite__mapDeps([0,1])).then(e=>({default:e.TopologyGraph})));function Bot(){const{view:e,agent:t}=Vl({from:"/_shell/agents"}),n=t,s=cs(),r=Zs(),a=je(v=>v.setRightPanelOpen),o=je(v=>v.setActiveRightPanelTab),[,l]=eh(),{data:c,isLoading:u,isError:f,refetch:h}=rO(),m=x.useMemo(()=>(c==null?void 0:c.namespaces.flatMap(v=>v.agents))??[],[c]),b=!(m.length>0)&&!u&&!f&&(e==="list"||e==="topology");return f?i.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-8 text-center",children:[i.jsx("div",{className:"bg-destructive/10 rounded-xl p-3",children:i.jsx(Yr,{className:"text-destructive size-6"})}),i.jsxs("div",{className:"space-y-1",children:[i.jsx("p",{className:"text-sm font-medium",children:"Could not load agents"}),i.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:"The mesh API is unreachable. Check that the server is running correctly."})]}),i.jsx(ve,{size:"sm",onClick:()=>void h(),className:"mt-1",children:"Retry"})]}):i.jsx(He,{mode:"wait",initial:!1,children:b?i.jsx(oe.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:"flex h-full flex-col items-center justify-center",children:i.jsx(Pot,{})},"mode-a"):i.jsx(oe.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:"flex h-full flex-col",children:i.jsxs(He,{mode:"wait",initial:!1,children:[e==="list"&&i.jsx(oe.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:"flex h-full flex-col",children:i.jsx(Dot,{agents:m,isLoading:u})},"view-list"),e==="topology"&&i.jsx(oe.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:"relative flex-1 overflow-hidden",children:i.jsxs("div",{className:"flex h-full",children:[i.jsx(oe.div,{layout:!0,className:"min-w-0 flex-1",transition:{type:"spring",stiffness:300,damping:30},children:i.jsx("div",{className:"absolute inset-0",children:i.jsx(x.Suspense,{fallback:i.jsxs("div",{className:"text-muted-foreground flex h-full items-center justify-center text-sm",children:[i.jsx(Xn,{className:"mr-2 size-4 animate-spin"}),"Loading topology..."]}),children:i.jsx(zot,{onSelectAgent:v=>s({to:"/agents",search:k=>({...k,agent:v})}),onOpenSettings:(v,k)=>{Eu.getState().openHub(k),o("agent-hub"),a(!0)},onOpenChat:v=>l(v)})})})}),r?i.jsx(ih,{open:!!n,onOpenChange:v=>!v&&s({to:"/agents",search:k=>({...k,agent:void 0})}),children:i.jsx(oh,{children:n&&i.jsx(n$,{agentId:n,onClose:()=>s({to:"/agents",search:v=>({...v,agent:void 0})})})})}):i.jsx(He,{children:n&&i.jsx(oe.div,{initial:{width:0,opacity:0},animate:{width:256,opacity:1},exit:{width:0,opacity:0},transition:{type:"spring",stiffness:300,damping:30},className:"bg-background overflow-y-auto border-l",children:i.jsx(n$,{agentId:n,onClose:()=>s({to:"/agents",search:v=>({...v,agent:void 0})})})})})]})},"view-topology"),e==="denied"&&i.jsx(oe.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},children:i.jsx(Lot,{})},"view-denied"),e==="access"&&i.jsx(oe.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},children:i.jsx(Fot,{})},"view-access")]})},"mode-b")})}const $ot={initial:{opacity:0,y:6},animate:{opacity:1,y:0,transition:{duration:.2,ease:"easeOut"}}};function Hot(){const e=x.useId(),t=x.useMemo(()=>`${e.split("").reduce((s,r)=>s+r.charCodeAt(0),0)%40+50}%`,[e]);return i.jsxs(dx,{children:[i.jsx(_o,{className:"w-28 py-1.5 pr-0 pl-2 max-sm:hidden",children:i.jsx(on,{className:"h-3 w-20"})}),i.jsx(_o,{className:"w-24 py-1.5 pr-0 max-sm:hidden",children:i.jsx(on,{className:"h-5 w-20 rounded-full"})}),i.jsx(_o,{className:"py-1.5 max-sm:pl-2",children:i.jsx(on,{className:"h-3 rounded",style:{width:t}})}),i.jsx(_o,{className:"w-16 py-1.5 max-sm:w-10"})]})}function Uot(){return i.jsxs("div",{"data-slot":"activity-timeline-skeleton",className:"space-y-1",children:[i.jsx("div",{className:"py-2",children:i.jsx(on,{className:"h-3 w-16 rounded"})}),i.jsx(TC,{children:i.jsx(_C,{children:Array.from({length:5}).map((e,t)=>i.jsx(Hot,{},t))})})]})}function Vot({items:e,isLoading:t,isFiltered:n,className:s}){const r=x.useMemo(()=>MXe(e,new Date),[e]),{containerRef:a,handleKeyDown:o}=AXe(e.length);return t&&e.length===0?i.jsx("div",{"data-slot":"activity-timeline",className:X("px-4",s),children:i.jsx(Uot,{})}):e.length===0?i.jsx("div",{"data-slot":"activity-timeline",className:X(s),children:i.jsx(HXe,{isFiltered:n})}):i.jsx("div",{ref:a,onKeyDown:o,"data-slot":"activity-timeline",className:X("px-4",s),children:r.map(l=>i.jsxs("section",{children:[i.jsx(LXe,{label:l.label}),i.jsx(oe.div,{variants:$ot,initial:"initial",animate:"animate",children:i.jsx(TC,{children:i.jsx(_C,{children:l.items.map(c=>i.jsx(Pae,{item:c},c.id))})})})]},l.label))})}function qot({onLoadMore:e,isFetching:t,hasNextPage:n,className:s}){return n?i.jsx(oe.div,{"data-slot":"activity-load-more",initial:{opacity:0},animate:{opacity:1},transition:{duration:.2,delay:.1},className:X("flex justify-center px-4 py-4",s),children:i.jsxs(ve,{variant:"outline",size:"sm",onClick:e,disabled:t,className:"gap-2",children:[t&&i.jsx(Xn,{className:"size-3.5 animate-spin","aria-hidden":!0}),"Load 50 more events"]})}):null}function Got(){const{queryFilters:e,isFiltered:t}=xO(),n=jXe(),{data:s,isLoading:r,isFetchingNextPage:a,hasNextPage:o,fetchNextPage:l}=NXe(e),c=x.useMemo(()=>(s==null?void 0:s.pages.flatMap(u=>u.items))??[],[s]);return i.jsx(so,{className:"h-full",children:i.jsxs("div",{className:"mx-auto max-w-4xl space-y-4 py-6 sm:py-8",children:[i.jsx(YXe,{lastVisitedAt:n,items:c,className:"mx-4"}),i.jsx(Vot,{items:c,isLoading:r,isFiltered:t}),i.jsx(qot,{onLoadMore:()=>void l(),isFetching:a,hasNextPage:!!o})]})})}function Kot(){const e=td(),{data:t=[],isLoading:n,isError:s,refetch:r}=XC(e),[a,o]=x.useState(!1),[l,c]=x.useState(),[u,f]=x.useState(null),h=t.some(R=>R.agentId),{data:m}=ji(void 0,h||!n),g=x.useMemo(()=>{const R=new Map;for(const D of(m==null?void 0:m.agents)??[])R.set(D.id,D);return R},[m]),{externalTrigger:b,clear:v}=ub(),[k,w]=x.useState(!1);b&&!k&&!a?(w(!0),c(void 0),o(!0),v()):!b&&k&&w(!1);const C=R=>{f(R),c(void 0),o(!0)},E=()=>{f(null),c(void 0),o(!0)},T=R=>{c(R),o(!0)},_=R=>{o(R),R||f(null)};if(!e)return i.jsx(a5,{icon:mre.tasks,name:"Tasks",description:"Tasks runs AI agent tasks on a schedule. Start DorkOS with the --tasks flag to enable it.",command:"dorkos --tasks"});if(s)return i.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-8 text-center",children:[i.jsx("div",{className:"bg-destructive/10 rounded-xl p-3",children:i.jsx(Yr,{className:"text-destructive size-6"})}),i.jsxs("div",{className:"space-y-1",children:[i.jsx("p",{className:"text-sm font-medium",children:"Could not load tasks"}),i.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:"The tasks API is unreachable. Check that the server is running correctly."})]}),i.jsx(ve,{size:"sm",onClick:()=>void r(),className:"mt-1",children:"Retry"})]});const j=t.length>0;return i.jsxs(i.Fragment,{children:[!j&&!n?i.jsx(oe.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.15},className:"flex h-full flex-col items-center justify-center",children:i.jsx(Tre,{onCreateWithPreset:C,onCreateBlank:E})}):i.jsx(oe.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.15},className:"flex h-full flex-col",children:i.jsx(tqe,{tasks:t,isLoading:n,agentMap:g,onEditTask:T})}),i.jsx(qR,{open:a,onOpenChange:_,editTask:l,initialPreset:u})]})}function Wot(){return i.jsx("div",{className:"flex h-full flex-col overflow-y-auto",children:i.jsx(gtt,{})})}function Yot(){return i.jsx("div",{className:"flex h-full flex-col",children:i.jsx(btt,{})})}const Yie=Pde()({component:()=>i.jsx(HM,{}),notFoundComponent:sre}),id=Nu({getParentRoute:()=>Yie,id:"_shell",component:Ttt}),Zot=sC(me({session:W().optional(),dir:W().optional()})),Xot=sC(me({detail:Dt(["dead-letter","failed-run","offline-agent"]).optional(),itemId:W().optional()})),Qot=sC(me({view:Dt(["list","topology","denied","access"]).optional().default("list"),sort:W().optional().default("lastSeen:desc"),agent:W().optional()}).merge(NM.searchValidator)),Jot=Nu({getParentRoute:()=>id,path:"/",validateSearch:ok(Xot),component:$tt,beforeLoad:({location:e})=>{const t=new URLSearchParams(e.searchStr),n=t.get("session");if(n)throw vS({to:"/session",search:{session:n,dir:t.get("dir")??void 0}})}});function elt({context:{queryClient:e},location:t}){const n=new URLSearchParams(t.searchStr);if(n.get("session"))return;const r=n.get("dir")??void 0,a=e.getQueryData(["sessions",r??null]);throw a&&a.length>0?vS({to:"/session",search:{session:a[0].id,dir:r},replace:!0}):vS({to:"/session",search:{session:crypto.randomUUID(),dir:r},replace:!0})}const tlt=Nu({getParentRoute:()=>id,path:"/session",validateSearch:ok(Zot),component:Not,loader:elt}),nlt=Nu({getParentRoute:()=>id,path:"/agents",validateSearch:ok(Qot),component:Bot}),slt=Nu({getParentRoute:()=>id,path:"/tasks",component:Kot}),rlt=Nu({getParentRoute:()=>id,path:"/marketplace",component:Wot}),alt=Nu({getParentRoute:()=>id,path:"/marketplace/sources",component:Yot}),ilt=sC(me({categories:W().optional(),actorType:W().optional(),actorId:W().optional(),since:W().optional()})),olt=Nu({getParentRoute:()=>id,path:"/activity",validateSearch:ok(ilt),component:Got}),llt=Yie.addChildren([id.addChildren([Jot,tlt,nlt,slt,olt,rlt,alt])]);function clt(e){return Yde({routeTree:llt,context:{queryClient:e},defaultPreload:"intent",defaultErrorComponent:jUe,defaultNotFoundComponent:sre})}function ult({onSuccess:e}){const t=Fe(),[n,s]=x.useState(null),[r,a]=x.useState(!1),[o,l]=x.useState(""),c=x.useCallback(async u=>{a(!0),s(null);try{const f=await t.verifyTunnelPasscode(u);if(f.ok)e();else{const h=f.retryAfter?`Too many attempts. Try again in ${Math.ceil(f.retryAfter/60)} minutes.`:f.error??"Incorrect passcode";s(h),l("")}}catch{s("Connection error. Try again."),l("")}finally{a(!1)}},[t,e]);return i.jsx("div",{className:"bg-background flex min-h-dvh items-center justify-center p-4",children:i.jsxs("div",{className:"flex w-full max-w-sm flex-col items-center gap-8",children:[i.jsx(_m,{variant:"white",size:120}),i.jsxs("div",{className:"flex flex-col items-center gap-2 text-center",children:[i.jsx("h1",{className:"text-foreground text-lg font-semibold",children:"Enter passcode"}),i.jsx("p",{className:"text-muted-foreground text-sm",children:"Enter your 6-digit passcode to access this instance."})]}),i.jsx(Nae,{maxLength:6,pattern:_ae,inputMode:"numeric",value:o,onChange:l,onComplete:c,disabled:r,autoFocus:!0,children:i.jsx(jae,{children:[0,1,2,3,4,5].map(u=>i.jsx(Aae,{index:u,className:n?"border-destructive":""},u))})}),n&&i.jsx("p",{className:"text-destructive text-sm",children:n}),r&&i.jsx("p",{className:"text-muted-foreground text-sm",children:"Verifying..."})]})})}function dlt({children:e}){const t=Fe(),n=window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1",[s,r]=x.useState(n?"unlocked":"checking");return x.useEffect(()=>{n||t.checkTunnelSession().then(a=>{!a.passcodeRequired||a.authenticated?r("unlocked"):r("locked")}).catch(()=>{r("unlocked")})},[t,n]),s==="checking"?null:s==="locked"?i.jsx(ult,{onSuccess:()=>r("unlocked")}):i.jsx(i.Fragment,{children:e})}const flt=50,Zie="puzzle";function SH(e,t){const n=[];return{api:{id:e,registerComponent(r,a,o,l){const c=hlt(r,`${e}:${a}`,o,l),u=t.registry.register(r,c);return n.push(u),u},registerCommand(r,a,o,l){const c=`ext:${e}:${r}`,u={id:`${e}:${r}`,label:a,icon:(l==null?void 0:l.icon)??Zie,action:c,shortcut:l==null?void 0:l.shortcut,category:"feature"},f=t.registry.register("command-palette.items",u);t.registerCommandHandler(c,o);const h=()=>{f(),t.unregisterCommandHandler(c)};return n.push(h),h},registerDialog(r,a){const o=`${e}:${r}`,l={id:o,component:a,openStateKey:`ext-dialog:${o}`},c=t.registry.register("dialog",l);n.push(c);let u=!1;return{open:()=>{u=!0},close:()=>{u=!1},get _openState(){return u}}},registerSettingsTab(r,a,o){const l={id:`${e}:${r}`,label:a,icon:void 0,component:o},c=t.registry.register("settings.tabs",l);return n.push(c),c},executeCommand(r){MF(t.dispatcherContext,r)},openCanvas(r){MF(t.dispatcherContext,{action:"open_canvas",content:r})},navigate(r){t.navigate({to:r})},getState(){const r=t.appStore.getState();return wH(r)},subscribe(r,a){const o=t.appStore.subscribe(l=>r(wH(l)),a);return n.push(o),o},async loadData(){const r=await fetch(`/api/extensions/${e}/data`);if(r.status===204)return null;if(!r.ok)throw new Error(`loadData failed: ${r.status}`);return r.json()},async saveData(r){const a=await fetch(`/api/extensions/${e}/data`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!a.ok)throw new Error(`saveData failed: ${a.status}`)},notify(r,a){const o=(a==null?void 0:a.type)??"info";rt[o](r)},isSlotAvailable(r){return t.availableSlots.has(r)}},cleanups:n}}function wH(e){return{currentCwd:e.selectedCwd??null,activeSessionId:e.sessionId??null,agentId:null}}function hlt(e,t,n,s){const r={id:t,priority:(s==null?void 0:s.priority)??flt};switch(e){case"dashboard.sections":return{...r,component:n};case"sidebar.tabs":return{...r,component:n,label:t,icon:void 0};case"sidebar.footer":return{...r,onClick:()=>{},label:t,icon:void 0};case"header.actions":return{...r,onClick:()=>{},label:t,icon:void 0};case"right-panel":return{...r,component:n,title:t,icon:void 0,visibleWhen:void 0};case"settings.tabs":return{...r,component:n,label:t,icon:void 0};case"dialog":return{...r,component:n,openStateKey:`ext:${t}`};case"command-palette.items":return{...r,label:t,icon:Zie,action:`ext:${t}`,category:"feature"};default:return console.warn("[ExtensionAPI] Unknown slot:",e),{...r,component:n}}}function plt({extensionId:e,status:t}){const[n,s]=x.useState(String(t.value??"")),[r,a]=x.useState(!1),o=async()=>{a(!0);try{const l=await fetch(`/api/extensions/${e}/settings/${t.key}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:n})});if(!l.ok)throw new Error(`${l.status}`);rt.success(`${t.label} saved`)}catch{rt.error(`Failed to save ${t.label}`)}finally{a(!1)}};return i.jsx(os,{label:t.label,description:t.description??"",orientation:"vertical",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(_n,{value:n,onChange:l=>s(l.target.value),placeholder:t.placeholder??t.key,className:"h-8 min-w-0 flex-1 text-sm",onKeyDown:l=>{l.key==="Enter"&&o()}}),i.jsx(ve,{size:"sm",onClick:o,disabled:r,className:"h-8",children:"Save"})]})})}function mlt({extensionId:e,status:t}){const[n,s]=x.useState(String(t.value??"")),[r,a]=x.useState(!1),o=async()=>{const l=Number(n);if(!Number.isNaN(l)){a(!0);try{const c=await fetch(`/api/extensions/${e}/settings/${t.key}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:l})});if(!c.ok)throw new Error(`${c.status}`);rt.success(`${t.label} saved`)}catch{rt.error(`Failed to save ${t.label}`)}finally{a(!1)}}};return i.jsx(os,{label:t.label,description:t.description??"",orientation:"vertical",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(_n,{type:"number",value:n,onChange:l=>s(l.target.value),placeholder:t.placeholder??t.key,min:t.min,max:t.max,className:"h-8 min-w-0 flex-1 text-sm",onKeyDown:l=>{l.key==="Enter"&&o()}}),i.jsx(ve,{size:"sm",onClick:o,disabled:r,className:"h-8",children:"Save"})]})})}function glt({extensionId:e,status:t,onChanged:n}){const[s,r]=x.useState(!1),a=!!t.value,o=async l=>{r(!0);try{const c=await fetch(`/api/extensions/${e}/settings/${t.key}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:l})});if(!c.ok)throw new Error(`${c.status}`);rt.success(`${t.label} ${l?"enabled":"disabled"}`),await n()}catch{rt.error(`Failed to update ${t.label}`)}finally{r(!1)}};return i.jsx(os,{label:t.label,description:t.description??"",children:i.jsx(Ks,{checked:a,onCheckedChange:o,disabled:s})})}function xlt({extensionId:e,status:t,onChanged:n}){const[s,r]=x.useState(!1),a=async o=>{var l;r(!0);try{const u=((l=t.options)==null?void 0:l.every(h=>typeof h.value=="number"))?Number(o):o,f=await fetch(`/api/extensions/${e}/settings/${t.key}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:u})});if(!f.ok)throw new Error(`${f.status}`);rt.success(`${t.label} updated`),await n()}catch{rt.error(`Failed to update ${t.label}`)}finally{r(!1)}};return i.jsx(os,{label:t.label,description:t.description??"",orientation:"vertical",children:i.jsxs(Bn,{value:String(t.value??""),onValueChange:a,disabled:s,children:[i.jsx(Dn,{className:"h-8 text-sm",children:i.jsx($n,{})}),i.jsx(On,{children:(t.options??[]).map(o=>i.jsx(yt,{value:String(o.value),children:o.label},String(o.value)))})]})})}function ylt(e,t,n,s){const r=new Map,a=(o,l)=>{r.has(o)||r.set(o,[]),r.get(o).push(l)};for(const o of e)a(o.group,{kind:"secret",declaration:o,isSet:t.get(o.key)??!1});for(const o of s){const l=n.find(c=>c.key===o.key);l&&a(l.group,{kind:"setting",declaration:l,status:o})}return r}function blt({extensionId:e,secrets:t,settings:n}){const[s,r]=x.useState(new Map),[a,o]=x.useState([]),[l,c]=x.useState(!0),u=x.useCallback(async()=>{try{const[b,v]=await Promise.all([t.length>0?fetch(`/api/extensions/${e}/secrets`):Promise.resolve(null),n.length>0?fetch(`/api/extensions/${e}/settings`):Promise.resolve(null)]);if(b!=null&&b.ok){const k=await b.json();r(new Map(k.map(w=>[w.key,w.isSet])))}if(v!=null&&v.ok){const k=await v.json();o(k)}}catch{}finally{c(!1)}},[e,t.length,n.length]);if(x.useEffect(()=>{u()},[u]),l)return i.jsx(Sa,{children:i.jsx(Wr,{children:i.jsx("div",{className:"text-muted-foreground py-4 text-center text-sm",children:"Loading…"})})});const f=ylt(t,s,n,a),h=f.get(void 0),m=[...f.entries()].filter(([b])=>b!==void 0);function g(b){if(b.kind==="secret")return i.jsx(Slt,{extensionId:e,secret:b.declaration,isSet:b.isSet,onChanged:u},b.declaration.key);switch(b.status.type){case"text":return i.jsx(plt,{extensionId:e,status:b.status},b.declaration.key);case"number":return i.jsx(mlt,{extensionId:e,status:b.status},b.declaration.key);case"boolean":return i.jsx(glt,{extensionId:e,status:b.status,onChanged:u},b.declaration.key);case"select":return i.jsx(xlt,{extensionId:e,status:b.status,onChanged:u},b.declaration.key)}}return i.jsxs(i.Fragment,{children:[h&&h.length>0&&i.jsx(Sa,{children:i.jsx(Wr,{children:h.map(g)})}),m.map(([b,v])=>i.jsx(vlt,{groupName:b,items:v,renderItem:g},b))]})}function vlt({groupName:e,items:t,renderItem:n}){const[s,r]=x.useState(!0);return i.jsx(VD,{open:s,onOpenChange:r,trigger:e,children:t.map(n)})}function Slt({extensionId:e,secret:t,isSet:n,onChanged:s}){const[r,a]=x.useState(""),[o,l]=x.useState(!1),c=async()=>{if(r.trim()){l(!0);try{const h=await fetch(`/api/extensions/${e}/secrets/${t.key}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:r})});if(!h.ok)throw new Error(`${h.status}`);a(""),rt.success(`${t.label} saved`),await s()}catch{rt.error(`Failed to save ${t.label}`)}finally{l(!1)}}},u=async()=>{l(!0);try{const h=await fetch(`/api/extensions/${e}/secrets/${t.key}`,{method:"DELETE"});if(!h.ok)throw new Error(`${h.status}`);rt.success(`${t.label} removed`),await s()}catch{rt.error(`Failed to remove ${t.label}`)}finally{l(!1)}},f=t.description??(t.required?"Required":"Optional");return n?i.jsx(os,{label:t.label,description:f,children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs(Ot,{variant:"outline",className:"text-muted-foreground gap-1",children:[i.jsx(Zt,{className:"size-3"}),"Configured"]}),i.jsxs(ve,{variant:"ghost",size:"sm",onClick:u,disabled:o,className:"text-muted-foreground hover:text-destructive h-7 px-2 text-xs",children:[i.jsx(ls,{className:"size-3"}),"Clear"]})]})}):i.jsx(os,{label:t.label,description:f,children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(WS,{value:r,onChange:h=>a(h.target.value),placeholder:t.placeholder??t.key,className:"h-8 w-48 text-sm",onKeyDown:h=>{h.key==="Enter"&&c()}}),i.jsx(ve,{size:"sm",onClick:c,disabled:o||!r.trim(),className:"h-8",children:"Save"})]})})}async function kH(){const e=await fetch("/api/extensions");return e.ok?e.json():(console.error("[extensions] Failed to fetch extension list:",e.status),[])}async function wlt(e){try{return await Ar(()=>import(`/api/extensions/${e}/bundle`),[])}catch(t){return console.error(`[extensions] Failed to import ${e}:`,t),null}}async function CH(e){if(!(!e.hasServerEntry&&!e.hasDataProxy))try{const t=await fetch(`/api/extensions/${e.id}/init-server`,{method:"POST"});if(!t.ok){const n=await t.json().catch(()=>({error:"Unknown error"}));console.warn(`[extensions] Server init failed for ${e.id}:`,n.error??t.statusText)}}catch(t){console.error(`[extensions] Server init error for ${e.id}:`,t)}}class klt{constructor(t){nt(this,"loaded",new Map);nt(this,"deps");nt(this,"disposed",!1);this.deps=t}async initialize(){const t=await kH(),n=t.filter(o=>o.status==="compiled"&&o.bundleReady);if(n.length===0)return console.log("[extensions] No extensions to load"),{extensions:t,loaded:this.loaded};const s=await Promise.all(n.map(async o=>({rec:o,module:await wlt(o.id)}))),r=[],a=[];for(const{rec:o,module:l}of s){if(this.disposed)break;if(l)try{const{api:c,cleanups:u}=SH(o.id,this.deps),f=l.activate(c);this.autoRegisterConfigTab(o,u);const h={id:o.id,manifest:o.manifest,module:l,api:c,cleanups:u,deactivate:typeof f=="function"?f:void 0};this.loaded.set(o.id,h),r.push(`${o.manifest.name} v${o.manifest.version}`),a.push(CH(o))}catch(c){console.error(`[extensions] Failed to activate ${o.id}:`,c)}}return await Promise.all(a),r.length>0&&console.log(`[extensions] Activated: ${r.join(", ")}`),{extensions:t,loaded:this.loaded}}deactivateAll(){var t;this.disposed=!0;for(const[n,s]of this.loaded){try{(t=s.deactivate)==null||t.call(s)}catch(r){console.error(`[extensions] Error calling deactivate for ${n}:`,r)}for(const r of s.cleanups)try{r()}catch(a){console.error(`[extensions] Error in cleanup for ${n}:`,a)}}this.loaded.clear()}async reloadExtensions(t){var s;for(const r of t){const a=this.loaded.get(r);if(a){try{(s=a.deactivate)==null||s.call(a)}catch(o){console.error(`[extensions] Error deactivating ${r}:`,o)}for(const o of a.cleanups)try{o()}catch(l){console.error(`[extensions] Error in cleanup for ${r}:`,l)}this.loaded.delete(r)}}const n=await kH();for(const r of t){const a=n.find(o=>o.id===r);if(!(!a||a.status!=="compiled"||!a.bundleReady))try{const o=await Ar(()=>import(`/api/extensions/${r}/bundle?t=${Date.now()}`),[]),{api:l,cleanups:c}=SH(r,this.deps),u=o.activate(l);this.autoRegisterConfigTab(a,c),this.loaded.set(r,{id:r,manifest:a.manifest,module:o,api:l,cleanups:c,deactivate:typeof u=="function"?u:void 0}),await CH(a),console.log(`[extensions] Hot-reloaded: ${a.manifest.name} v${a.manifest.version}`)}catch(o){console.error(`[extensions] Failed to hot-reload ${r}:`,o)}}return{extensions:n,loaded:this.loaded}}getLoaded(){return this.loaded}autoRegisterConfigTab(t,n){var f,h;const s=(f=t.manifest.serverCapabilities)==null?void 0:f.secrets,r=(h=t.manifest.serverCapabilities)==null?void 0:h.settings;if(!(s!=null&&s.length)&&!(r!=null&&r.length))return;const a=t.id,o=`${a}:settings`,l=s??[],c=r??[],u=this.deps.registry.register("settings.tabs",{id:o,label:t.manifest.name,icon:Qi,component:function(){return x.createElement(blt,{extensionId:a,secrets:l,settings:c})},priority:90});n.push(u)}}const EH=1500;async function Clt(e){try{const t=await fetch("/api/extensions/cwd-changed",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e})});return t.ok?await t.json():(console.error("[extensions] CWD change notification failed:",t.status),null)}catch(t){return console.error("[extensions] CWD change notification error:",t),null}}function Elt(){const e=je(n=>n.selectedCwd),t=x.useRef(void 0);x.useEffect(()=>{if(t.current===void 0){t.current=e;return}t.current!==e&&(t.current=e,Clt(e).then(n=>{!n||!n.changed||(rt.info("Project extensions changed. Reloading...",{duration:EH}),setTimeout(()=>{location.reload()},EH))}))},[e])}const Mf={all:["extensions"],lists:()=>[...Mf.all,"list"],detail:e=>[...Mf.all,"detail",e]};function rct(){return mt({queryKey:Mf.lists(),queryFn:async()=>{const e=await fetch("/api/extensions");if(!e.ok)throw new Error(`Failed to fetch extensions: ${e.status}`);return e.json()},staleTime:1e4,refetchInterval:3e4,refetchIntervalInBackground:!1})}function act(){const e=Ct();return mn({mutationFn:async t=>{const n=await fetch(`/api/extensions/${t}/enable`,{method:"POST"});if(!n.ok)throw new Error(`Failed to enable extension '${t}': ${n.status}`);return n.json()},onSuccess:()=>{e.invalidateQueries({queryKey:Mf.lists()})}})}function ict(){const e=Ct();return mn({mutationFn:async t=>{const n=await fetch(`/api/extensions/${t}/disable`,{method:"POST"});if(!n.ok)throw new Error(`Failed to disable extension '${t}': ${n.status}`);return n.json()},onSuccess:()=>{e.invalidateQueries({queryKey:Mf.lists()})}})}function oct(){const e=Ct();return mn({mutationFn:async()=>{const t=await fetch("/api/extensions/reload",{method:"POST"});if(!t.ok)throw new Error(`Failed to reload extensions: ${t.status}`);return t.json()},onSuccess:()=>{e.invalidateQueries({queryKey:Mf.lists()})}})}const Xie={extensions:[],loaded:new Map,ready:!1},Qie=x.createContext(Xie);function lct(){return x.useContext(Qie)}function Tlt({deps:e,children:t}){const[n,s]=x.useState(Xie),r=x.useRef(null),a=Ct();return Elt(),x.useEffect(()=>{const o=new klt(e);return r.current=o,o.initialize().then(({extensions:l,loaded:c})=>{s({extensions:l,loaded:c,ready:!0})}).catch(l=>{console.error("[extensions] Failed to initialize:",l),s(c=>({...c,ready:!0}))}),()=>{o.deactivateAll(),r.current=null}},[]),jA("extension_reloaded",o=>{const l=r.current;if(!l)return;const c=o;(async()=>{try{const{extensions:u,loaded:f}=await l.reloadExtensions(c.extensionIds);s({extensions:u,loaded:f,ready:!0}),a.invalidateQueries({queryKey:Mf.lists()})}catch(u){console.error("[extensions] Hot reload failed:",u)}})()}),i.jsx(Qie.Provider,{value:n,children:t})}function _lt(){const{register:e}=rD.getState();for(const t of xJe)e("command-palette.items",t);for(const t of yJe)e("command-palette.items",t);for(const t of dXe)e("sidebar.footer",t);for(const t of fXe)e("sidebar.tabs",t);for(const t of int)e("dashboard.sections",t);for(const t of _Ze)e("dialog",t);e("settings.tabs",{id:"extensions",label:"Extensions",icon:FX,component:x.lazy(()=>Ar(()=>import("./index-DEQVQjg0.js"),[]).then(t=>({default:t.ExtensionsSettingsTab}))),priority:70}),e("right-panel",{id:"agent-hub",title:"Agent Profile",icon:Zf,component:x.lazy(()=>Ar(()=>import("./index-CCg4gR3O.js"),__vite__mapDeps([2,3])).then(t=>({default:t.AgentHub}))),priority:10}),e("right-panel",{id:"canvas",title:"Canvas",icon:IX,component:x.lazy(()=>Ar(()=>import("./index-Bu_BRhOD.js"),__vite__mapDeps([4,3])).then(t=>({default:t.CanvasContent}))),visibleWhen:({pathname:t})=>t==="/session",priority:20})}const Nlt=x.createContext(null),gj={didCatch:!1,error:null};class jlt extends x.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=gj}static getDerivedStateFromError(t){return{didCatch:!0,error:t}}resetErrorBoundary(...t){var s,r;const{error:n}=this.state;n!==null&&((r=(s=this.props).onReset)==null||r.call(s,{args:t,reason:"imperative-api"}),this.setState(gj))}componentDidCatch(t,n){var s,r;(r=(s=this.props).onError)==null||r.call(s,t,n)}componentDidUpdate(t,n){var a,o;const{didCatch:s}=this.state,{resetKeys:r}=this.props;s&&n.error!==null&&Alt(t.resetKeys,r)&&((o=(a=this.props).onReset)==null||o.call(a,{next:r,prev:t.resetKeys,reason:"keys"}),this.setState(gj))}render(){const{children:t,fallbackRender:n,FallbackComponent:s,fallback:r}=this.props,{didCatch:a,error:o}=this.state;let l=t;if(a){const c={error:o,resetErrorBoundary:this.resetErrorBoundary};if(typeof n=="function")l=n(c);else if(s)l=x.createElement(s,c);else if(r!==void 0)l=r;else throw o}return x.createElement(Nlt.Provider,{value:{didCatch:a,error:o,resetErrorBoundary:this.resetErrorBoundary}},l)}}function Alt(e=[],t=[]){return e.length!==t.length||e.some((n,s)=>!Object.is(n,t[s]))}globalThis.React=he;const Rlt=null;he.lazy(()=>Ar(()=>import("./index-zioTSqyj.js"),[]).then(e=>({default:e.ReactQueryDevtoolsPanel})));he.lazy(()=>Ar(()=>import("./index-DMT5csia.js").then(e=>e.w),[]).then(e=>({default:e.TanStackRouterDevtoolsPanel})));function Mlt(){return window.location.pathname.startsWith("/dev"),i.jsxs(Zce,{client:sD,children:[i.jsx(Sme,{transport:Ilt,children:i.jsx(mNe,{children:i.jsx(Tlt,{deps:Plt,children:i.jsx(dlt,{children:i.jsx(Qde,{router:Dlt})})})})}),!1]})}const Dlt=clt(sD);function Olt(){var e;return(e=window.electronAPI)!=null&&e.getServerPort?`http://localhost:${window.electronAPI.getServerPort()}/api`:"/api"}const Jie=Olt(),Ilt=new L0e(Jie);lr.useHttpSource(Jie);const TH=new Map,Plt={registry:rD.getState(),dispatcherContext:{store:je.getState(),setTheme:e=>{document.documentElement.classList.toggle("dark",e==="dark")}},navigate:e=>{console.warn("[extensions] navigate called before router ready:",e)},appStore:je,availableSlots:new Set(["sidebar.footer","sidebar.tabs","dashboard.sections","header.actions","command-palette.items","dialog","settings.tabs","right-panel"]),registerCommandHandler:(e,t)=>{TH.set(e,t)},unregisterCommandHandler:e=>{TH.delete(e)}};_lt();Ece.createRoot(document.getElementById("root"),{onCaughtError:(e,t)=>{console.error("[dorkos:caught]",e,t.componentStack)},onUncaughtError:(e,t)=>{console.error("[dorkos:uncaught]",e,t.componentStack)}}).render(i.jsx(he.StrictMode,{children:i.jsx(jlt,{FallbackComponent:AUe,children:i.jsx(Mlt,{})})}));const Llt=Object.freeze(Object.defineProperty({__proto__:null,Mermaid:Jse},Symbol.toStringTag,{value:"Module"}));export{Jae as $,$$e as A,ve as B,Vm as C,mu as D,klt as E,Tlt as F,SH as G,lct as H,of as I,cU as J,KL as K,Zlt as L,ed as M,td as N,OWe as O,FX as P,eVe as Q,Xa as R,Rae as S,Kn as T,Sa as U,Wr as V,VD as W,ls as X,os as Y,_n as Z,e_e as _,xy as a,sct as a$,TTe as a0,W_e as a1,Ws as a2,nr as a3,Ar as a4,Ca as a5,ke as a6,Z3 as a7,pu as a8,IX as a9,yt as aA,tn as aB,AGe as aC,uu as aD,hO as aE,MKe as aF,Xm as aG,Qm as aH,TX as aI,lh as aJ,Nr as aK,Xn as aL,df as aM,q1 as aN,th as aO,Bu as aP,nh as aQ,$u as aR,Hu as aS,sh as aT,Vu as aU,Uu as aV,YUe as aW,eg as aX,tg as aY,Es as aZ,ng as a_,q5 as aa,vr as ab,oe as ac,$y as ad,Zs as ae,Xl as af,Ql as ag,Jl as ah,ec as ai,ph as aj,Zre as ak,lO as al,_ot as am,mn as an,Wa as ao,Ya as ap,Qlt as aq,lVe as ar,pre as as,Jlt as at,uVe as au,h0 as av,Bn as aw,Dn as ax,$n as ay,On as az,Fu as b,J3 as b$,pb as b0,VUe as b1,dO as b2,vGe as b3,SGe as b4,aae as b5,cae as b6,KS as b7,Xk as b8,XKe as b9,dC as bA,Vl as bB,cs as bC,Eu as bD,gre as bE,xVe as bF,bVe as bG,Ta as bH,A5e as bI,dEe as bJ,_a as bK,Ni as bL,ei as bM,Ji as bN,EC as bO,Qk as bP,g_e as bQ,Yf as bR,Qy as bS,R5e as bT,qS as bU,Lu as bV,rVe as bW,mqe as bX,jre as bY,He as bZ,db as b_,Gp as ba,Pl as bb,Qi as bc,hje as bd,IRe as be,Js as bf,Yx as bg,dJ as bh,is as bi,nw as bj,br as bk,sAe as bl,Gje as bm,nAe as bn,XQ as bo,Ga as bp,qx as bq,RD as br,NRe as bs,XRe as bt,qRe as bu,RRe as bv,bMe as bw,iJ as bx,km as by,aw as bz,Wn as c,oVe as c0,l3 as c1,c3 as c2,U6 as c3,Zt as c4,kqe as c5,Zf as c6,Wk as c7,KC as c8,PUe as c9,ect as ca,nct as cb,on as cc,Are as cd,eo as ce,Hlt as cf,he as cg,to as ch,Gf as ci,Pu as cj,Ja as ck,lM as cl,zlt as cm,rO as cn,cb as co,X as d,Yn as e,tct as f,Wl as g,fre as h,Fe as i,i as j,Ct as k,aee as l,rxe as m,Mae as n,lk as o,Yr as p,Ps as q,x as r,Ot as s,rt as t,je as u,Ks as v,rct as w,act as x,ict as y,oct as z};
|