eminiar 0.13.0 → 0.13.2
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/.claude-plugin/plugin.json +1 -1
- package/.cursor-plugin/plugin.json +1 -1
- package/README.md +43 -15
- package/bin/_resolve.sh +7 -4
- package/bin/em-hook +2 -1
- package/bin/em-server +2 -1
- package/bin/eminiar +2 -1
- package/dist/cli.js +10113 -8385
- package/dist/{hook-async-4MIP3VHX.js → hook-async-3TLK23ZY.js} +3 -3
- package/dist/{hook-chunk-IYHVLMJ4.js → hook-chunk-ETYHCPPH.js} +52 -25
- package/dist/{hook-chunk-77I6QQ43.js → hook-chunk-MVSMFCKL.js} +2 -2
- package/dist/{hook-chunk-MVOBVFQL.js → hook-chunk-ZLRLOPLR.js} +98 -33
- package/dist/{hook-hooks-U6GDOQSY.js → hook-hooks-5U2AI6W7.js} +8 -6
- package/dist/hook.js +318 -74
- package/dist/server.js +4417 -4078
- package/dist/ui/app.global.js +78 -72
- package/dist/ui/styles.css +4724 -1508
- package/eminiar.config.schema.json +2 -1
- package/package.json +1 -1
package/dist/ui/app.global.js
CHANGED
|
@@ -1,95 +1,101 @@
|
|
|
1
|
-
"use strict";(()=>{var Zl=Object.create;var ms=Object.defineProperty;var Yl=Object.getOwnPropertyDescriptor;var Ql=Object.getOwnPropertyNames;var ec=Object.getPrototypeOf,tc=Object.prototype.hasOwnProperty;var Mr=t=>{throw TypeError(t)};var nc=(t,n,s)=>n in t?ms(t,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[n]=s;var sc=(t,n)=>()=>(n||t((n={exports:{}}).exports,n),n.exports);var rc=(t,n,s,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let a of Ql(n))!tc.call(t,a)&&a!==s&&ms(t,a,{get:()=>n[a],enumerable:!(r=Yl(n,a))||r.enumerable});return t};var ac=(t,n,s)=>(s=t!=null?Zl(ec(t)):{},rc(n||!t||!t.__esModule?ms(s,"default",{value:t,enumerable:!0}):s,t));var ae=(t,n,s)=>nc(t,typeof n!="symbol"?n+"":n,s),ic=(t,n,s)=>n.has(t)||Mr("Cannot "+s);var jr=(t,n,s)=>n.has(t)?Mr("Cannot add the same private member more than once"):n instanceof WeakSet?n.add(t):n.set(t,s);var Lr=(t,n,s)=>(ic(t,n,"access private method"),s);var Fo=sc((pb,qn)=>{"use strict";var Hd=typeof window<"u"?window:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?self:{};var G=(function(t){var n=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,s=0,r={},a={manual:t.Prism&&t.Prism.manual,disableWorkerMessageHandler:t.Prism&&t.Prism.disableWorkerMessageHandler,util:{encode:function h(m){return m instanceof i?new i(m.type,h(m.content),m.alias):Array.isArray(m)?m.map(h):m.replace(/&/g,"&").replace(/</g,"<").replace(/\u00a0/g," ")},type:function(h){return Object.prototype.toString.call(h).slice(8,-1)},objId:function(h){return h.__id||Object.defineProperty(h,"__id",{value:++s}),h.__id},clone:function h(m,b){b=b||{};var v,k;switch(a.util.type(m)){case"Object":if(k=a.util.objId(m),b[k])return b[k];v={},b[k]=v;for(var w in m)m.hasOwnProperty(w)&&(v[w]=h(m[w],b));return v;case"Array":return k=a.util.objId(m),b[k]?b[k]:(v=[],b[k]=v,m.forEach(function(S,E){v[E]=h(S,b)}),v);default:return m}},getLanguage:function(h){for(;h;){var m=n.exec(h.className);if(m)return m[1].toLowerCase();h=h.parentElement}return"none"},setLanguage:function(h,m){h.className=h.className.replace(RegExp(n,"gi"),""),h.classList.add("language-"+m)},currentScript:function(){if(typeof document>"u")return null;if(document.currentScript&&document.currentScript.tagName==="SCRIPT")return document.currentScript;try{throw new Error}catch(v){var h=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(v.stack)||[])[1];if(h){var m=document.getElementsByTagName("script");for(var b in m)if(m[b].src==h)return m[b]}return null}},isActive:function(h,m,b){for(var v="no-"+m;h;){var k=h.classList;if(k.contains(m))return!0;if(k.contains(v))return!1;h=h.parentElement}return!!b}},languages:{plain:r,plaintext:r,text:r,txt:r,extend:function(h,m){var b=a.util.clone(a.languages[h]);for(var v in m)b[v]=m[v];return b},insertBefore:function(h,m,b,v){v=v||a.languages;var k=v[h],w={};for(var S in k)if(k.hasOwnProperty(S)){if(S==m)for(var E in b)b.hasOwnProperty(E)&&(w[E]=b[E]);b.hasOwnProperty(S)||(w[S]=k[S])}var x=v[h];return v[h]=w,a.languages.DFS(a.languages,function($,M){M===x&&$!=h&&(this[$]=w)}),w},DFS:function h(m,b,v,k){k=k||{};var w=a.util.objId;for(var S in m)if(m.hasOwnProperty(S)){b.call(m,S,m[S],v||S);var E=m[S],x=a.util.type(E);x==="Object"&&!k[w(E)]?(k[w(E)]=!0,h(E,b,null,k)):x==="Array"&&!k[w(E)]&&(k[w(E)]=!0,h(E,b,S,k))}}},plugins:{},highlightAll:function(h,m){a.highlightAllUnder(document,h,m)},highlightAllUnder:function(h,m,b){var v={callback:b,container:h,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};a.hooks.run("before-highlightall",v),v.elements=Array.prototype.slice.apply(v.container.querySelectorAll(v.selector)),a.hooks.run("before-all-elements-highlight",v);for(var k=0,w;w=v.elements[k++];)a.highlightElement(w,m===!0,v.callback)},highlightElement:function(h,m,b){var v=a.util.getLanguage(h),k=a.languages[v];a.util.setLanguage(h,v);var w=h.parentElement;w&&w.nodeName.toLowerCase()==="pre"&&a.util.setLanguage(w,v);var S=h.textContent,E={element:h,language:v,grammar:k,code:S};function x(M){E.highlightedCode=M,a.hooks.run("before-insert",E),E.element.innerHTML=E.highlightedCode,a.hooks.run("after-highlight",E),a.hooks.run("complete",E),b&&b.call(E.element)}if(a.hooks.run("before-sanity-check",E),w=E.element.parentElement,w&&w.nodeName.toLowerCase()==="pre"&&!w.hasAttribute("tabindex")&&w.setAttribute("tabindex","0"),!E.code){a.hooks.run("complete",E),b&&b.call(E.element);return}if(a.hooks.run("before-highlight",E),!E.grammar){x(a.util.encode(E.code));return}if(m&&t.Worker){var $=new Worker(a.filename);$.onmessage=function(M){x(M.data)},$.postMessage(JSON.stringify({language:E.language,code:E.code,immediateClose:!0}))}else x(a.highlight(E.code,E.grammar,E.language))},highlight:function(h,m,b){var v={code:h,grammar:m,language:b};if(a.hooks.run("before-tokenize",v),!v.grammar)throw new Error('The language "'+v.language+'" has no grammar.');return v.tokens=a.tokenize(v.code,v.grammar),a.hooks.run("after-tokenize",v),i.stringify(a.util.encode(v.tokens),v.language)},tokenize:function(h,m){var b=m.rest;if(b){for(var v in b)m[v]=b[v];delete m.rest}var k=new c;return d(k,k.head,h),l(h,k,m,k.head,0),p(k)},hooks:{all:{},add:function(h,m){var b=a.hooks.all;b[h]=b[h]||[],b[h].push(m)},run:function(h,m){var b=a.hooks.all[h];if(!(!b||!b.length))for(var v=0,k;k=b[v++];)k(m)}},Token:i};t.Prism=a;function i(h,m,b,v){this.type=h,this.content=m,this.alias=b,this.length=(v||"").length|0}i.stringify=function h(m,b){if(typeof m=="string")return m;if(Array.isArray(m)){var v="";return m.forEach(function(x){v+=h(x,b)}),v}var k={type:m.type,content:h(m.content,b),tag:"span",classes:["token",m.type],attributes:{},language:b},w=m.alias;w&&(Array.isArray(w)?Array.prototype.push.apply(k.classes,w):k.classes.push(w)),a.hooks.run("wrap",k);var S="";for(var E in k.attributes)S+=" "+E+'="'+(k.attributes[E]||"").replace(/"/g,""")+'"';return"<"+k.tag+' class="'+k.classes.join(" ")+'"'+S+">"+k.content+"</"+k.tag+">"};function o(h,m,b,v){h.lastIndex=m;var k=h.exec(b);if(k&&v&&k[1]){var w=k[1].length;k.index+=w,k[0]=k[0].slice(w)}return k}function l(h,m,b,v,k,w){for(var S in b)if(!(!b.hasOwnProperty(S)||!b[S])){var E=b[S];E=Array.isArray(E)?E:[E];for(var x=0;x<E.length;++x){if(w&&w.cause==S+","+x)return;var $=E[x],M=$.inside,I=!!$.lookbehind,C=!!$.greedy,L=$.alias;if(C&&!$.pattern.global){var T=$.pattern.toString().match(/[imsuy]*$/)[0];$.pattern=RegExp($.pattern.source,T+"g")}for(var F=$.pattern||$,H=v.next,K=k;H!==m.tail&&!(w&&K>=w.reach);K+=H.value.length,H=H.next){var R=H.value;if(m.length>h.length)return;if(!(R instanceof i)){var z=1,se;if(C){if(se=o(F,K,h,I),!se||se.index>=h.length)break;var be=se.index,Ee=se.index+se[0].length,D=K;for(D+=H.value.length;be>=D;)H=H.next,D+=H.value.length;if(D-=H.value.length,K=D,H.value instanceof i)continue;for(var V=H;V!==m.tail&&(D<Ee||typeof V.value=="string");V=V.next)z++,D+=V.value.length;z--,R=h.slice(K,D),se.index-=K}else if(se=o(F,0,R,I),!se)continue;var be=se.index,Pe=se[0],me=R.slice(0,be),re=R.slice(be+Pe.length),$e=K+R.length;w&&$e>w.reach&&(w.reach=$e);var Le=H.prev;me&&(Le=d(m,Le,me),K+=me.length),u(m,Le,z);var ne=new i(S,M?a.tokenize(Pe,M):Pe,L,Pe);if(H=d(m,Le,ne),re&&d(m,H,re),z>1){var _e={cause:S+","+x,reach:$e};l(h,m,b,H.prev,K,_e),w&&_e.reach>w.reach&&(w.reach=_e.reach)}}}}}}function c(){var h={value:null,prev:null,next:null},m={value:null,prev:h,next:null};h.next=m,this.head=h,this.tail=m,this.length=0}function d(h,m,b){var v=m.next,k={value:b,prev:m,next:v};return m.next=k,v.prev=k,h.length++,k}function u(h,m,b){for(var v=m.next,k=0;k<b&&v!==h.tail;k++)v=v.next;m.next=v,v.prev=m,h.length-=k}function p(h){for(var m=[],b=h.head.next;b!==h.tail;)m.push(b.value),b=b.next;return m}if(!t.document)return t.addEventListener&&(a.disableWorkerMessageHandler||t.addEventListener("message",function(h){var m=JSON.parse(h.data),b=m.language,v=m.code,k=m.immediateClose;t.postMessage(a.highlight(v,a.languages[b],b)),k&&t.close()},!1)),a;var f=a.util.currentScript();f&&(a.filename=f.src,f.hasAttribute("data-manual")&&(a.manual=!0));function g(){a.manual||a.highlightAll()}if(!a.manual){var y=document.readyState;y==="loading"||y==="interactive"&&f&&f.defer?document.addEventListener("DOMContentLoaded",g):window.requestAnimationFrame?window.requestAnimationFrame(g):window.setTimeout(g,16)}return a})(Hd);typeof qn<"u"&&qn.exports&&(qn.exports=G);typeof global<"u"&&(global.Prism=G);G.languages.markup={comment:{pattern:/<!--(?:(?!<!--)[\s\S])*?-->/,greedy:!0},prolog:{pattern:/<\?[\s\S]+?\?>/,greedy:!0},doctype:{pattern:/<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,greedy:!0,inside:{"internal-subset":{pattern:/(^[^\[]*\[)[\s\S]+(?=\]>$)/,lookbehind:!0,greedy:!0,inside:null},string:{pattern:/"[^"]*"|'[^']*'/,greedy:!0},punctuation:/^<!|>$|[[\]]/,"doctype-tag":/^DOCTYPE/i,name:/[^\s<>'"]+/}},cdata:{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,greedy:!0},tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>\/]+/,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"special-attr":[],"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,inside:{punctuation:[{pattern:/^=/,alias:"attr-equals"},{pattern:/^(\s*)["']|["']$/,lookbehind:!0}]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:[{pattern:/&[\da-z]{1,8};/i,alias:"named-entity"},/&#x?[\da-f]{1,8};/i]};G.languages.markup.tag.inside["attr-value"].inside.entity=G.languages.markup.entity;G.languages.markup.doctype.inside["internal-subset"].inside=G.languages.markup;G.hooks.add("wrap",function(t){t.type==="entity"&&(t.attributes.title=t.content.replace(/&/,"&"))});Object.defineProperty(G.languages.markup.tag,"addInlined",{value:function(n,s){var r={};r["language-"+s]={pattern:/(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,lookbehind:!0,inside:G.languages[s]},r.cdata=/^<!\[CDATA\[|\]\]>$/i;var a={"included-cdata":{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,inside:r}};a["language-"+s]={pattern:/[\s\S]+/,inside:G.languages[s]};var i={};i[n]={pattern:RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g,function(){return n}),"i"),lookbehind:!0,greedy:!0,inside:a},G.languages.insertBefore("markup","cdata",i)}});Object.defineProperty(G.languages.markup.tag,"addAttribute",{value:function(t,n){G.languages.markup.tag.inside["special-attr"].push({pattern:RegExp(/(^|["'\s])/.source+"(?:"+t+")"+/\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,"i"),lookbehind:!0,inside:{"attr-name":/^[^\s=]+/,"attr-value":{pattern:/=[\s\S]+/,inside:{value:{pattern:/(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,lookbehind:!0,alias:[n,"language-"+n],inside:G.languages[n]},punctuation:[{pattern:/^=/,alias:"attr-equals"},/"|'/]}}}})}});G.languages.html=G.languages.markup;G.languages.mathml=G.languages.markup;G.languages.svg=G.languages.markup;G.languages.xml=G.languages.extend("markup",{});G.languages.ssml=G.languages.xml;G.languages.atom=G.languages.xml;G.languages.rss=G.languages.xml;(function(t){var n=/(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;t.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:RegExp("@[\\w-](?:"+/[^;{\s"']|\s+(?!\s)/.source+"|"+n.source+")*?"+/(?:;|(?=\s*\{))/.source),inside:{rule:/^@[\w-]+/,"selector-function-argument":{pattern:/(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,lookbehind:!0,alias:"selector"},keyword:{pattern:/(^|[^\w-])(?:and|not|only|or)(?![\w-])/,lookbehind:!0}}},url:{pattern:RegExp("\\burl\\((?:"+n.source+"|"+/(?:[^\\\r\n()"']|\\[\s\S])*/.source+")\\)","i"),greedy:!0,inside:{function:/^url/i,punctuation:/^\(|\)$/,string:{pattern:RegExp("^"+n.source+"$"),alias:"url"}}},selector:{pattern:RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|`+n.source+")*(?=\\s*\\{)"),lookbehind:!0},string:{pattern:n,greedy:!0},property:{pattern:/(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,lookbehind:!0},important:/!important\b/i,function:{pattern:/(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,lookbehind:!0},punctuation:/[(){};:,]/},t.languages.css.atrule.inside.rest=t.languages.css;var s=t.languages.markup;s&&(s.tag.addInlined("style","css"),s.tag.addAttribute("style","css"))})(G);G.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,lookbehind:!0,greedy:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,lookbehind:!0,inside:{punctuation:/[.\\]/}},keyword:/\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,boolean:/\b(?:false|true)\b/,function:/\b\w+(?=\()/,number:/\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,operator:/[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/};G.languages.javascript=G.languages.extend("clike",{"class-name":[G.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+(/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source)+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/});G.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/;G.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:G.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:G.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:G.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:G.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:G.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/});G.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:G.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}});G.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}});G.languages.markup&&(G.languages.markup.tag.addInlined("script","javascript"),G.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript"));G.languages.js=G.languages.javascript;(function(){if(typeof G>"u"||typeof document>"u")return;Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector);var t="Loading\u2026",n=function(f,g){return"\u2716 Error "+f+" while fetching file: "+g},s="\u2716 Error: File does not exist or is empty",r={js:"javascript",py:"python",rb:"ruby",ps1:"powershell",psm1:"powershell",sh:"bash",bat:"batch",h:"c",tex:"latex"},a="data-src-status",i="loading",o="loaded",l="failed",c="pre[data-src]:not(["+a+'="'+o+'"]):not(['+a+'="'+i+'"])';function d(f,g,y){var h=new XMLHttpRequest;h.open("GET",f,!0),h.onreadystatechange=function(){h.readyState==4&&(h.status<400&&h.responseText?g(h.responseText):h.status>=400?y(n(h.status,h.statusText)):y(s))},h.send(null)}function u(f){var g=/^\s*(\d+)\s*(?:(,)\s*(?:(\d+)\s*)?)?$/.exec(f||"");if(g){var y=Number(g[1]),h=g[2],m=g[3];return h?m?[y,Number(m)]:[y,void 0]:[y,y]}}G.hooks.add("before-highlightall",function(f){f.selector+=", "+c}),G.hooks.add("before-sanity-check",function(f){var g=f.element;if(g.matches(c)){f.code="",g.setAttribute(a,i);var y=g.appendChild(document.createElement("CODE"));y.textContent=t;var h=g.getAttribute("data-src"),m=f.language;if(m==="none"){var b=(/\.(\w+)$/.exec(h)||[,"none"])[1];m=r[b]||b}G.util.setLanguage(y,m),G.util.setLanguage(g,m);var v=G.plugins.autoloader;v&&v.loadLanguages(m),d(h,function(k){g.setAttribute(a,o);var w=u(g.getAttribute("data-range"));if(w){var S=k.split(/\r\n?|\n/g),E=w[0],x=w[1]==null?S.length:w[1];E<0&&(E+=S.length),E=Math.max(0,Math.min(E-1,S.length)),x<0&&(x+=S.length),x=Math.max(0,Math.min(x,S.length)),k=S.slice(E,x).join(`
|
|
2
|
-
`),g.hasAttribute("data-start")||g.setAttribute("data-start",String(E+1))}y.textContent=k,G.highlightElement(y)},function(k){g.setAttribute(a,l),y.textContent=k})}}),G.plugins.fileHighlight={highlight:function(g){for(var y=(g||document).querySelectorAll(c),h=0,m;m=y[h++];)G.highlightElement(m)}};var p=!1;G.fileHighlight=function(){p||(console.warn("Prism.fileHighlight is deprecated. Use `Prism.plugins.fileHighlight.highlight` instead."),p=!0),G.plugins.fileHighlight.highlight.apply(this,arguments)}})()});var bn,ie,Or,oc,tt,Ir,Nr,Ur,hs,pn,Ht,Hr,bs,gs,fs,lc,hn={},gn=[],cc=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,vn=Array.isArray;function Ye(t,n){for(var s in n)t[s]=n[s];return t}function vs(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function xt(t,n,s){var r,a,i,o={};for(i in n)i=="key"?r=n[i]:i=="ref"?a=n[i]:o[i]=n[i];if(arguments.length>2&&(o.children=arguments.length>3?bn.call(arguments,2):s),typeof t=="function"&&t.defaultProps!=null)for(i in t.defaultProps)o[i]===void 0&&(o[i]=t.defaultProps[i]);return mn(t,o,r,a,null)}function mn(t,n,s,r,a){var i={type:t,props:n,key:s,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:a??++Or,__i:-1,__u:0};return a==null&&ie.vnode!=null&&ie.vnode(i),i}function j(t){return t.children}function wt(t,n){this.props=t,this.context=n}function ot(t,n){if(n==null)return t.__?ot(t.__,t.__i+1):null;for(var s;n<t.__k.length;n++)if((s=t.__k[n])!=null&&s.__e!=null)return s.__e;return typeof t.type=="function"?ot(t):null}function dc(t){if(t.__P&&t.__d){var n=t.__v,s=n.__e,r=[],a=[],i=Ye({},n);i.__v=n.__v+1,ie.vnode&&ie.vnode(i),ys(t.__P,i,n,t.__n,t.__P.namespaceURI,32&n.__u?[s]:null,r,s??ot(n),!!(32&n.__u),a),i.__v=n.__v,i.__.__k[i.__i]=i,Gr(r,i,a),n.__e=n.__=null,i.__e!=s&&Br(i)}}function Br(t){if((t=t.__)!=null&&t.__c!=null)return t.__e=t.__c.base=null,t.__k.some(function(n){if(n!=null&&n.__e!=null)return t.__e=t.__c.base=n.__e}),Br(t)}function Fr(t){(!t.__d&&(t.__d=!0)&&tt.push(t)&&!fn.__r++||Ir!=ie.debounceRendering)&&((Ir=ie.debounceRendering)||Nr)(fn)}function fn(){try{for(var t,n=1;tt.length;)tt.length>n&&tt.sort(Ur),t=tt.shift(),n=tt.length,dc(t)}finally{tt.length=fn.__r=0}}function Jr(t,n,s,r,a,i,o,l,c,d,u){var p,f,g,y,h,m,b=r&&r.__k||gn,v=n.length;for(c=uc(s,n,b,c,v),p=0;p<v;p++)(g=s.__k[p])!=null&&(f=g.__i!=-1&&b[g.__i]||hn,g.__i=p,m=ys(t,g,f,a,i,o,l,c,d,u),y=g.__e,g.ref&&f.ref!=g.ref&&(f.ref&&ks(f.ref,null,g),u.push(g.ref,g.__c||y,g)),h==null&&y!=null&&(h=y),4&g.__u?(c=Xr(g,c,t),f.__e&&(f.__e=null)):typeof g.type=="function"&&m!==void 0?c=m:y&&(c=y.nextSibling),g.__u&=-7);return s.__e=h,c}function uc(t,n,s,r,a){var i,o,l,c,d,u=s.length,p=u,f=0;for(t.__k=new Array(a),i=0;i<a;i++)(o=n[i])!=null&&typeof o!="boolean"&&typeof o!="function"?(typeof o=="string"||typeof o=="number"||typeof o=="bigint"||o.constructor==String?o=t.__k[i]=mn(null,o,null,null,null):vn(o)?o=t.__k[i]=mn(j,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=t.__k[i]=mn(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):t.__k[i]=o,c=i+f,o.__=t,o.__b=t.__b+1,l=null,(d=o.__i=pc(o,s,c,p))!=-1&&(p--,(l=s[d])&&(l.__u|=2)),l==null||l.__v==null?(d==-1&&(a>u?f--:a<u&&f++),typeof o.type!="function"&&(o.__u|=4)):d!=c&&(d==c-1?f--:d==c+1?f++:(d>c?f--:f++,o.__u|=4))):t.__k[i]=null;if(p)for(i=0;i<u;i++)(l=s[i])!=null&&(2&l.__u)==0&&(l.__e==r&&(r=ot(l)),qr(l,l));return r}function Xr(t,n,s){var r,a;if(typeof t.type=="function"){for(r=t.__k,a=0;r&&a<r.length;a++)r[a]&&(r[a].__=t,n=Xr(r[a],n,s));return n}t.__e!=n&&(n&&t.type&&!n.parentNode&&(n=ot(t)),n=s.insertBefore(t.__e,n||null));do n=n&&n.nextSibling;while(n!=null&&n.nodeType==8);return n}function pc(t,n,s,r){var a,i,o,l=t.key,c=t.type,d=n[s],u=d!=null&&(2&d.__u)==0;if(d===null&&l==null||u&&l==d.key&&c==d.type)return s;if(r>(u?1:0)){for(a=s-1,i=s+1;a>=0||i<n.length;)if((d=n[o=a>=0?a--:i++])!=null&&(2&d.__u)==0&&l==d.key&&c==d.type)return o}return-1}function Pr(t,n,s){n[0]=="-"?t.setProperty(n,s??""):t[n]=s==null?"":typeof s!="number"||cc.test(n)?s:s+"px"}function un(t,n,s,r,a){var i,o;e:if(n=="style")if(typeof s=="string")t.style.cssText=s;else{if(typeof r=="string"&&(t.style.cssText=r=""),r)for(n in r)s&&n in s||Pr(t.style,n,"");if(s)for(n in s)r&&s[n]==r[n]||Pr(t.style,n,s[n])}else if(n[0]=="o"&&n[1]=="n")i=n!=(n=n.replace(Hr,"$1")),o=n.toLowerCase(),n=o in t||n=="onFocusOut"||n=="onFocusIn"?o.slice(2):n.slice(2),t.l||(t.l={}),t.l[n+i]=s,s?r?s[Ht]=r[Ht]:(s[Ht]=bs,t.addEventListener(n,i?fs:gs,i)):t.removeEventListener(n,i?fs:gs,i);else{if(a=="http://www.w3.org/2000/svg")n=n.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(n!="width"&&n!="height"&&n!="href"&&n!="list"&&n!="form"&&n!="tabIndex"&&n!="download"&&n!="rowSpan"&&n!="colSpan"&&n!="role"&&n!="popover"&&n in t)try{t[n]=s??"";break e}catch{}typeof s=="function"||(s==null||s===!1&&n[4]!="-"?t.removeAttribute(n):t.setAttribute(n,n=="popover"&&s==1?"":s))}}function Dr(t){return function(n){if(this.l){var s=this.l[n.type+t];if(n[pn]==null)n[pn]=bs++;else if(n[pn]<s[Ht])return;return s(ie.event?ie.event(n):n)}}}function ys(t,n,s,r,a,i,o,l,c,d){var u,p,f,g,y,h,m,b,v,k,w,S,E,x,$,M,I=n.type;if(n.constructor!==void 0)return null;128&s.__u&&(c=!!(32&s.__u),i=[l=n.__e=s.__e]),(u=ie.__b)&&u(n);e:if(typeof I=="function"){p=o.length;try{if(v=n.props,k=I.prototype&&I.prototype.render,w=(u=I.contextType)&&r[u.__c],S=u?w?w.props.value:u.__:r,s.__c?b=(f=n.__c=s.__c).__=f.__E:(k?n.__c=f=new I(v,S):(n.__c=f=new wt(v,S),f.constructor=I,f.render=hc),w&&w.sub(f),f.state||(f.state={}),f.__n=r,g=f.__d=!0,f.__h=[],f._sb=[]),k&&f.__s==null&&(f.__s=f.state),k&&I.getDerivedStateFromProps!=null&&(f.__s==f.state&&(f.__s=Ye({},f.__s)),Ye(f.__s,I.getDerivedStateFromProps(v,f.__s))),y=f.props,h=f.state,f.__v=n,g)k&&I.getDerivedStateFromProps==null&&f.componentWillMount!=null&&f.componentWillMount(),k&&f.componentDidMount!=null&&f.__h.push(f.componentDidMount);else{if(k&&I.getDerivedStateFromProps==null&&v!==y&&f.componentWillReceiveProps!=null&&f.componentWillReceiveProps(v,S),n.__v==s.__v||!f.__e&&f.shouldComponentUpdate!=null&&f.shouldComponentUpdate(v,f.__s,S)===!1){n.__v!=s.__v&&(f.props=v,f.state=f.__s,f.__d=!1),n.__e=s.__e,n.__k=s.__k,n.__k.some(function(C){C&&(C.__=n)}),gn.push.apply(f.__h,f._sb),f._sb=[],f.__h.length&&o.push(f),l=ot(s);break e}f.componentWillUpdate!=null&&f.componentWillUpdate(v,f.__s,S),k&&f.componentDidUpdate!=null&&f.__h.push(function(){f.componentDidUpdate(y,h,m)})}if(f.context=S,f.props=v,f.__P=t,f.__e=!1,E=ie.__r,x=0,k)f.state=f.__s,f.__d=!1,E&&E(n),u=f.render(f.props,f.state,f.context),gn.push.apply(f.__h,f._sb),f._sb=[];else do f.__d=!1,E&&E(n),u=f.render(f.props,f.state,f.context),f.state=f.__s;while(f.__d&&++x<25);f.state=f.__s,f.getChildContext!=null&&(r=Ye(Ye({},r),f.getChildContext())),k&&!g&&f.getSnapshotBeforeUpdate!=null&&(m=f.getSnapshotBeforeUpdate(y,h)),$=u!=null&&u.type===j&&u.key==null?Wr(u.props.children):u,l=Jr(t,vn($)?$:[$],n,s,r,a,i,o,l,c,d),f.base=n.__e,n.__u&=-161,f.__h.length&&o.push(f),b&&(f.__E=f.__=null)}catch(C){if(o.length=p,n.__v=null,c||i!=null){if(C.then){for(n.__u|=c?160:128;l&&l.nodeType==8&&l.nextSibling;)l=l.nextSibling;i!=null&&(i[i.indexOf(l)]=null),n.__e=l}else if(i!=null)for(M=i.length;M--;)vs(i[M])}else n.__e=s.__e;n.__k==null&&(n.__k=s.__k||[]),C.then||zr(n),ie.__e(C,n,s)}}else i==null&&n.__v==s.__v?(n.__k=s.__k,n.__e=s.__e):l=n.__e=mc(s.__e,n,s,r,a,i,o,c,d);return(u=ie.diffed)&&u(n),128&n.__u?void 0:l}function zr(t){t&&(t.__c&&(t.__c.__e=!0),t.__k&&t.__k.some(zr))}function Gr(t,n,s){for(var r=0;r<s.length;r++)ks(s[r],s[++r],s[++r]);ie.__c&&ie.__c(n,t),t.some(function(a){try{t=a.__h,a.__h=[],t.some(function(i){i.call(a)})}catch(i){ie.__e(i,a.__v)}})}function Wr(t){return typeof t!="object"||t==null||t.__b>0?t:vn(t)?t.map(Wr):t.constructor!==void 0?null:Ye({},t)}function mc(t,n,s,r,a,i,o,l,c){var d,u,p,f,g,y,h,m=s.props||hn,b=n.props,v=n.type;if(v=="svg"?a="http://www.w3.org/2000/svg":v=="math"?a="http://www.w3.org/1998/Math/MathML":a||(a="http://www.w3.org/1999/xhtml"),i!=null){for(d=0;d<i.length;d++)if((g=i[d])&&"setAttribute"in g==!!v&&(v?g.localName==v:g.nodeType==3)){t=g,i[d]=null;break}}if(t==null){if(v==null)return document.createTextNode(b);t=document.createElementNS(a,v,b.is&&b),l&&(ie.__m&&ie.__m(n,i),l=!1),i=null}if(v==null)m===b||l&&t.data==b||(t.data=b);else{if(i=v=="textarea"&&b.defaultValue!=null?null:i&&bn.call(t.childNodes),!l&&i!=null)for(m={},d=0;d<t.attributes.length;d++)m[(g=t.attributes[d]).name]=g.value;for(d in m)g=m[d],d=="dangerouslySetInnerHTML"?p=g:d=="children"||d in b||d=="value"&&"defaultValue"in b||d=="checked"&&"defaultChecked"in b||un(t,d,null,g,a);for(d in b)g=b[d],d=="children"?f=g:d=="dangerouslySetInnerHTML"?u=g:d=="value"?y=g:d=="checked"?h=g:l&&typeof g!="function"||m[d]===g||un(t,d,g,m[d],a);if(u)l||p&&(u.__html==p.__html||u.__html==t.innerHTML)||(t.innerHTML=u.__html),n.__k=[];else if(p&&(t.innerHTML=""),Jr(n.type=="template"?t.content:t,vn(f)?f:[f],n,s,r,v=="foreignObject"?"http://www.w3.org/1999/xhtml":a,i,o,i?i[0]:s.__k&&ot(s,0),l,c),i!=null)for(d=i.length;d--;)vs(i[d]);l&&v!="textarea"||(d="value",v=="progress"&&y==null?t.removeAttribute("value"):y!=null&&(y!==t[d]||v=="progress"&&!y||v=="option"&&y!=m[d])&&un(t,d,y,m[d],a),d="checked",h!=null&&h!=t[d]&&un(t,d,h,m[d],a))}return t}function ks(t,n,s){try{if(typeof t=="function"){var r=typeof t.__u=="function";r&&t.__u(),r&&n==null||(t.__u=t(n))}else t.current=n}catch(a){ie.__e(a,s)}}function qr(t,n,s){var r,a;if(ie.unmount&&ie.unmount(t),(r=t.ref)&&(r.current&&r.current!=t.__e||ks(r,null,n)),(r=t.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(i){ie.__e(i,n)}r.base=r.__P=r.__n=null}if(r=t.__k)for(a=0;a<r.length;a++)r[a]&&qr(r[a],n,s||typeof t.type!="function");s||vs(t.__e),t.__c=t.__=t.__e=void 0}function hc(t,n,s){return this.constructor(t,s)}function Kr(t,n,s){var r,a,i,o;n==document&&(n=document.documentElement),ie.__&&ie.__(t,n),a=(r=typeof s=="function")?null:s&&s.__k||n.__k,i=[],o=[],ys(n,t=(!r&&s||n).__k=xt(j,null,[t]),a||hn,hn,n.namespaceURI,!r&&s?[s]:a?null:n.firstChild?bn.call(n.childNodes):null,i,!r&&s?s:a?a.__e:n.firstChild,r,o),Gr(i,t,o),t.props.children=null}bn=gn.slice,ie={__e:function(t,n,s,r){for(var a,i,o;n=n.__;)if((a=n.__c)&&!a.__)try{if((i=a.constructor)&&i.getDerivedStateFromError!=null&&(a.setState(i.getDerivedStateFromError(t)),o=a.__d),a.componentDidCatch!=null&&(a.componentDidCatch(t,r||{}),o=a.__d),o)return a.__E=a}catch(l){t=l}throw t}},Or=0,oc=function(t){return t!=null&&t.constructor===void 0},wt.prototype.setState=function(t,n){var s;s=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Ye({},this.state),typeof t=="function"&&(t=t(Ye({},s),this.props)),t&&Ye(s,t),t!=null&&this.__v&&(n&&this._sb.push(n),Fr(this))},wt.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),Fr(this))},wt.prototype.render=j,tt=[],Nr=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Ur=function(t,n){return t.__v.__b-n.__v.__b},fn.__r=0,hs=Math.random().toString(8),pn="__d"+hs,Ht="__a"+hs,Hr=/(PointerCapture)$|Capture$/i,bs=0,gs=Dr(!1),fs=Dr(!0),lc=0;var _t,ce,ws,Vr,St=0,ra=[],de=ie,Zr=de.__b,Yr=de.__r,Qr=de.diffed,ea=de.__c,ta=de.unmount,na=de.__;function kn(t,n){de.__h&&de.__h(ce,t,St||n),St=0;var s=ce.__H||(ce.__H={__:[],__h:[]});return t>=s.__.length&&s.__.push({}),s.__[t]}function _(t){return St=1,gc(ia,t)}function gc(t,n,s){var r=kn(_t++,2);if(r.t=t,!r.__c&&(r.__=[s?s(n):ia(void 0,n),function(l){var c=r.__N?r.__N[0]:r.__[0],d=r.t(c,l);c!==d&&(r.__N=[d,r.__[1]],r.__c.setState({}))}],r.__c=ce,!ce.__f)){var a=function(l,c,d){if(!r.__c.__H)return!0;var u=!1,p=r.__c.props!==l;if(r.__c.__H.__.some(function(g){if(g.__N){u=!0;var y=g.__[0];g.__=g.__N,g.__N=void 0,y!==g.__[0]&&(p=!0)}}),i){var f=i.call(this,l,c,d);return u?f||p:f}return!u||p};ce.__f=!0;var i=ce.shouldComponentUpdate,o=ce.componentWillUpdate;ce.componentWillUpdate=function(l,c,d){if(this.__e){var u=i;i=void 0,a(l,c,d),i=u}o&&o.call(this,l,c,d)},ce.shouldComponentUpdate=a}return r.__N||r.__}function J(t,n){var s=kn(_t++,3);!de.__s&&_s(s.__H,n)&&(s.__=t,s.u=n,ce.__H.__h.push(s))}function fc(t,n){var s=kn(_t++,4);!de.__s&&_s(s.__H,n)&&(s.__=t,s.u=n,ce.__h.push(s))}function ee(t){return St=5,Z(function(){return{current:t}},[])}function aa(t,n,s){St=6,fc(function(){if(typeof t=="function"){var r=t(n());return function(){t(null),r&&typeof r=="function"&&r()}}if(t)return t.current=n(),function(){return t.current=null}},s==null?s:s.concat(t))}function Z(t,n){var s=kn(_t++,7);return _s(s.__H,n)&&(s.__=t(),s.__H=n,s.__h=t),s.__}function Bt(t,n){return St=8,Z(function(){return t},n)}function bc(){for(var t;t=ra.shift();){var n=t.__H;if(t.__P&&n)try{n.__h.some(yn),n.__h.some(xs),n.__h=[]}catch(s){n.__h=[],de.__e(s,t.__v)}}}de.__b=function(t){ce=null,Zr&&Zr(t)},de.__=function(t,n){t&&n.__k&&n.__k.__m&&(t.__m=n.__k.__m),na&&na(t,n)},de.__r=function(t){Yr&&Yr(t),_t=0;var n=(ce=t.__c).__H;n&&(ws===ce?(n.__h=[],ce.__h=[],n.__.some(function(s){s.__N&&(s.__=s.__N),s.u=s.__N=void 0})):(n.__h.some(yn),n.__h.some(xs),n.__h=[],_t=0)),ws=ce},de.diffed=function(t){Qr&&Qr(t);var n=t.__c;n&&n.__H&&(n.__H.__h.length&&(ra.push(n)!==1&&Vr===de.requestAnimationFrame||((Vr=de.requestAnimationFrame)||vc)(bc)),n.__H.__.some(function(s){s.u&&(s.__H=s.u,s.u=void 0)})),ws=ce=null},de.__c=function(t,n){n.some(function(s){try{s.__h.some(yn),s.__h=s.__h.filter(function(r){return!r.__||xs(r)})}catch(r){n.some(function(a){a.__h&&(a.__h=[])}),n=[],de.__e(r,s.__v)}}),ea&&ea(t,n)},de.unmount=function(t){ta&&ta(t);var n,s=t.__c;s&&s.__H&&(s.__H.__.some(function(r){try{yn(r)}catch(a){n=a}}),s.__H=void 0,n&&de.__e(n,s.__v))};var sa=typeof requestAnimationFrame=="function";function vc(t){var n,s=function(){clearTimeout(r),sa&&cancelAnimationFrame(n),setTimeout(t)},r=setTimeout(s,35);sa&&(n=requestAnimationFrame(s))}function yn(t){var n=ce,s=t.__c;typeof s=="function"&&(t.__c=void 0,s()),ce=n}function xs(t){var n=ce;t.__c=t.__(),ce=n}function _s(t,n){return!t||t.length!==n.length||n.some(function(s,r){return s!==t[r]})}function ia(t,n){return typeof n=="function"?n(t):n}var wn=new URLSearchParams(location.search).get("root")??"",Ss=()=>wn;function oa(t){wn=t;let n=new URL(location.href);n.searchParams.set("root",t),history.replaceState(null,"",n.toString())}function yc(t,n){let s=new URL(t,location.origin);wn&&s.searchParams.set("root",wn);for(let[r,a]of Object.entries(n??{}))a==null||a===""||s.searchParams.set(r,String(a));return s.toString()}var Jt=class extends Error{constructor(s,r){super(s);ae(this,"status",r)}};async function O(t,n,s){let r=await fetch(yc(t,n),s),a=await r.json().catch(()=>({error:"bad response"}));if(r.status===404&&a.error==="not found"&&t.startsWith("/api/"))throw new Jt(`${t} is not available on the running server; restart \`eminiar ui\` to pick up the rebuilt bundle`,r.status);if(!r.ok)throw new Jt(a.error??`HTTP ${r.status}`,r.status);if(a&&typeof a=="object"&&"error"in a&&a.error)throw new Jt(String(a.error),r.status);return a}function he(t,n,s="POST",r){return O(t,r,{method:s,headers:{"content-type":"application/json"},body:JSON.stringify(n)})}function xn(t,n){return O(t,n,{method:"DELETE",headers:{"content-type":"application/json"}})}var la=t=>O("/api/adjudicator/jev",{since:t}),ca=(t,n)=>O("/api/adjudicator/jev/exchanges",{limit:t,row:n}),da=t=>O("/api/adjudicator/jev/exchange",{id:t});var q=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(Math.round(t));function te(t){if(!t)return"";let n=Date.now()-t;return n<6e4?"just now":n<36e5?`${Math.round(n/6e4)}m ago`:n<864e5?`${Math.round(n/36e5)}h ago`:`${Math.round(n/864e5)}d ago`}var Te=t=>t?new Date(t).toISOString().slice(0,10):"",ua=t=>t?new Date(t).toLocaleTimeString():"",_n=t=>t.split("/").pop()??t;var kc={file:"#2563eb",function:"#16a34a",method:"#0d9488",class:"#d97706",interface:"#7c3aed",type:"#8b5cf6",enum:"#a855f7",field:"#64748b",variable:"#64748b",route:"#e11d48",package:"#6b7280",memory:"#2563eb",doc:"#1e40af",tag:"#9ca3af",topic:"#6b7280",branch:"#64748b",commit:"#94a3b8",person:"#f59e0b",concept:"#0ea5e9",cluster:"#2563eb"},De=t=>kc[t]??"#94a3b8",wc={imports:"#2563eb",reexports:"#3b82f6",calls:"#16a34a",references:"#0ea5e9",extends:"#7c3aed",implements:"#8b5cf6",handles:"#e11d48",defines:"#9ca3af",exports:"#9ca3af",co_changes:"#f59e0b",mentions:"#2563eb",supersedes:"#6b7280",links:"#3b82f6",documents:"#1e40af",about:"#93c5fd",tagged:"#9ca3af",in_topic:"#cdd2da",authored:"#d97706",link:"#2563eb"},Et=t=>wc[t]??"#94a3b8",Sn=new Set(["imports","reexports","calls","references","extends","implements","handles","mentions","supersedes","links","documents","about"]),pa=["imports","calls","references","extends","implements","handles","reexports","co_changes","mentions","defines"],A=(...t)=>t.filter(Boolean).join(" ");function ma(t,n){let s;return(...r)=>{clearTimeout(s),s=setTimeout(()=>t(...r),n)}}var Oe=t=>`${Math.round((t??0)*100)}%`;function ha(t){let n=t.slice(t.lastIndexOf(".")+1).toLowerCase();return{ts:"typescript",mts:"typescript",cts:"typescript",tsx:"tsx",js:"javascript",mjs:"javascript",cjs:"javascript",jsx:"jsx",py:"python",go:"go",php:"php",json:"json",md:"markdown",sh:"bash"}[n]??"plain"}var xc=0;function e(t,n,s,r,a,i){n||(n={});var o,l,c=n;if("ref"in c)for(l in c={},n)l=="ref"?o=n[l]:c[l]=n[l];var d={type:t,props:c,key:s,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--xc,__i:-1,__u:0,__source:a,__self:i};if(typeof t=="function"&&(o=t.defaultProps))for(l in o)c[l]===void 0&&(c[l]=o[l]);return ie.vnode&&ie.vnode(d),d}var Es=new Set;function Y(t,n=!1){for(let s of Es)s(t,n)}function ga(){let[t,n]=_(null);return J(()=>{let s,r=(a,i)=>{n({msg:a,bad:i}),clearTimeout(s),s=setTimeout(()=>n(null),i?6e3:2500)};return Es.add(r),()=>{Es.delete(r),clearTimeout(s)}},[]),t?e("div",{class:A("toast",t.bad&&"bad"),children:t.msg}):null}function X(t,n){let[s,r]=_({data:void 0,error:void 0,loading:!0}),[a,i]=_(0),o=ee(0);J(()=>{let c=++o.current;r(d=>({...d,loading:!0,error:void 0})),t().then(d=>c===o.current&&r({data:d,error:void 0,loading:!1}),d=>c===o.current&&r(u=>({...u,error:d.message,loading:!1})))},[...n,a]);let l=Bt(()=>i(c=>c+1),[]);return{...s,reload:l}}var N=()=>e("span",{class:"spin"}),B=({children:t})=>e("div",{class:"empty",children:t}),W=({error:t})=>e("div",{class:"empty bad",children:t});function ye({kind:t}){return e("span",{class:"tag kind",style:{color:De(t)},children:t})}function P({children:t,class:n}){return e("span",{class:A("tag",n),children:t})}function Qe({value:t,max:n,width:s=80}){let r=n>0?Math.max(2,t/n*s):2;return e("span",{class:"bar",style:{width:`${r}px`},title:String(t)})}function Ae({rows:t}){return e("dl",{class:"kv",children:t.map(([n,s])=>e(j,{children:[e("dt",{children:n}),e("dd",{children:s})]}))})}function Re({tabs:t,value:n,onChange:s}){return e("div",{class:"subtabs",children:t.map(([r,a])=>e("button",{type:"button",class:A(n===r&&"active"),onClick:()=>s(r),children:a}))})}function fa({left:t,center:n,right:s,leftWidth:r=280,rightWidth:a=340}){let[i,o]=_(r),[l,c]=_(a),d=ee(null),[u,p]=_(null);J(()=>{let g=h=>{let m=d.current;if(!m)return;let b=h.clientX-m.x;m.side==="l"?o(Math.max(160,Math.min(700,m.start+b))):c(Math.max(200,Math.min(800,m.start-b)))},y=()=>{d.current=null,p(null)};return window.addEventListener("mousemove",g),window.addEventListener("mouseup",y),()=>{window.removeEventListener("mousemove",g),window.removeEventListener("mouseup",y)}},[]);let f=[t?`${i}px 5px`:"","minmax(0, 1fr)",s?`5px ${l}px`:""].filter(Boolean).join(" ");return e("div",{class:"split",style:{gridTemplateColumns:f},children:[t&&e(j,{children:[e("div",{class:"pane",children:t}),e("div",{class:A("gutter",u==="l"&&"on"),onMouseDown:g=>{d.current={side:"l",x:g.clientX,start:i},p("l"),g.preventDefault()}})]}),e("div",{class:"pane",children:n}),s&&e(j,{children:[e("div",{class:A("gutter",u==="r"&&"on"),onMouseDown:g=>{d.current={side:"r",x:g.clientX,start:l},p("r"),g.preventDefault()}}),e("div",{class:"pane",children:s})]})]})}function nt(t,n,s=!0){let[r,a]=_(n),[i,o]=_(s?-1:1);return{sorted:(t??[]).slice().sort((d,u)=>{let p=d[r],f=u[r];return typeof p=="number"&&typeof f=="number"?(p-f)*i:String(p??"").localeCompare(String(f??""))*i}),th:(d,u,p=!1)=>e("th",{class:A("sortable",p&&"num",r===d&&"sorted"),onClick:()=>{r===d?o(f=>f===1?-1:1):(a(d),o(p?-1:1))},children:[u,r===d?i===1?" \u25B2":" \u25BC":""]})}}var _c=["overview","usage","explore","galaxy","architecture","history","memory","docs","coverage","sessions","swarm","adjudicator","system"];function ba(){let t=location.hash.replace(/^#\/?/,""),[n="",s=""]=t.split("?"),r=_c.includes(n)?n:"overview",a={};for(let[i,o]of new URLSearchParams(s))a[i]=o;return{view:r,params:a}}function U(t,n={}){let s=new URLSearchParams;for(let[a,i]of Object.entries(n))i&&s.set(a,i);let r=s.toString();location.hash=`/${t}${r?`?${r}`:""}`}function va(){let[t,n]=_(ba);return J(()=>{let s=()=>n(ba());return window.addEventListener("hashchange",s),()=>window.removeEventListener("hashchange",s)},[]),t}function Ie(t,n,s,r={}){return{input:t,output:n,cacheWrite5m:t*1.25,cacheWrite1h:t*2,cacheRead:s,webSearch:10,...r}}var Jm=Ie(10,50,.25),Xm=Ie(10,50,1),zm=Ie(4,20,.2),Gm=Ie(5,25,.5),Wm=Ie(5,25,.5),qm=Ie(15,75,1.5),Km=Ie(2,10,.1),Vm=Ie(2,10,.2),Zm=Ie(3,15,.3),Ym=Ie(.1,.5,.01,{longContext:{threshold:1e5,input:.5,output:2.5}}),Qm=Ie(1,5,.1),eh=Ie(.8,4,.08);function lt(t){if(!Number.isFinite(t)||t===0)return"$0.00";let n=t<0?"-":"",s=Math.abs(t);if(s<1e-4)return n?"-$0.0001":"<$0.0001";if(s<1){let a=s.toFixed(4);return a.startsWith("1")?`${n}$1.00`:`${n}$${a.replace(/0+$/,"").replace(/\.(\d)$/,".$10")}`}let r=s.toFixed(2);return Number(r)>=1e3?`${n}$${Math.round(s).toLocaleString("en-US")}`:`${n}$${r}`}var ct=["feat","test","perf","refactor","fix","docs","other"],$t={feat:"#2563eb",test:"#16a34a",perf:"#d97706",refactor:"#7c3aed",fix:"#e11d48",docs:"#0284c7",other:"#9ca3af"},dt=t=>$t[t]??$t.other;function $s(t){let n=[],s=[],r=0,a=i=>{let o=n.indexOf(null);return o===-1?(o=n.length,n.push(i)):n[o]=i,o};for(let i of t){let o=n.indexOf(i.sha);o===-1&&(o=a(i.sha));let l=[];for(let u=0;u<n.length;u++)u!==o&&n[u]===i.sha&&(l.push(u),n[u]=null);let c=[],d=i.parents;if(!d.length)n[o]=null;else{n[o]=d[0];for(let u of d.slice(1)){let p=n.indexOf(u);p===-1&&(p=a(u)),c.push(p)}}for(;n.length&&n[n.length-1]===null;)n.pop();r=Math.max(r,n.length,o+1),s.push({c:i,lane:o,after:[...n],joins:l,forks:c})}return{rows:s,lanes:r}}function ya(t){let n=[];for(let s=0;s<t.length-1;s++){let r=t[s],a=t[s+1];for(let i=0;i<r.after.length;i++){let o=r.after[i];o&&(o===a.c.sha&&i!==a.lane?n.push({kind:"curve",fromLane:i,toLane:a.lane,from:s,to:s+1,lane:i}):r.forks.includes(i)&&i!==r.lane?n.push({kind:"curve",fromLane:r.lane,toLane:i,from:s,to:s+1,lane:i}):n.push({kind:"line",lane:i,from:s,to:s+1}))}}return n}function Ts(t){let n=Math.max(0,Math.min(1,t)),s=[191,219,254],r=[30,58,138],a=s.map((i,o)=>Math.round(i+((r[o]??0)-i)*n));return`rgb(${a[0]},${a[1]},${a[2]})`}function ut(t=800){let n=ee(null),[s,r]=_(t);return J(()=>{let a=n.current;if(!a)return;let i=new ResizeObserver(()=>r(a.clientWidth||t));return i.observe(a),r(a.clientWidth||t),()=>i.disconnect()},[]),[n,s]}function wa({weeks:t,range:n,onRange:s,hidden:r}){let[a,i]=ut(),o=150,l={l:34,r:8,t:8,b:22},c=Math.max(10,i-l.l-l.r),d=o-l.t-l.b,u=t.length,p=u?c/u:c,f=p>=5?1:0,g=Math.max(1,...t.map($=>ct.reduce((M,I)=>M+(r.has(I)?0:$.byBucket[I]),0))),y=$=>l.t+d-$/g*d,[h,m]=_(null),b=ee(null),[v,k]=_(null),w=($,M)=>{let I=M.getBoundingClientRect(),C=$-I.left-l.l;return Math.max(0,Math.min(u-1,Math.floor(C/p)))},S=Z(()=>{let $=[],M="";for(let C=0;C<u;C++){let L=t[C].week.slice(0,7);if(L!==M){M=L;let T=new Date(t[C].at),F=T.getUTCMonth()===0||!$.length?`${T.getUTCFullYear()}`:T.toLocaleString("en",{month:"short",timeZone:"UTC"});$.push({i:C,label:F})}}let I=Math.max(1,Math.ceil($.length/Math.max(4,c/60)));return $.filter((C,L)=>L%I===0)},[t,c]),E=v??(n?[t.findIndex($=>$.at+7*864e5>n[0]),t.findIndex($=>$.at>n[1])-1]:null),x=h!==null?t[h]:void 0;return e("div",{class:"hist-chart",ref:a,children:[e("svg",{width:i,height:o,onMouseMove:$=>{let M=$.currentTarget,I=w($.clientX,M);m(I),b.current&&k([Math.min(b.current.i0,I),Math.max(b.current.i0,I)])},onMouseLeave:()=>m(null),onMouseDown:$=>{let M=$.currentTarget,I=w($.clientX,M);b.current={x0:$.clientX,i0:I},k([I,I]),$.preventDefault()},onMouseUp:$=>{let M=b.current;if(b.current=null,!M)return;if(Math.abs($.clientX-M.x0)<3){k(null),s(null);return}let I=v;k(null),I&&s([t[I[0]].at,t[I[1]].at+7*864e5-1])},children:[e("title",{children:"commits per week by kind"}),[0,.5,1].map($=>e("g",{children:[e("line",{x1:l.l,x2:i-l.r,y1:y(g*$),y2:y(g*$),class:"grid"}),e("text",{x:l.l-6,y:y(g*$)+3,class:"axis","text-anchor":"end",children:Math.round(g*$)})]})),S.map($=>e("text",{x:l.l+$.i*p,y:o-6,class:"axis",children:$.label})),E&&E[0]>=0&&E[1]>=E[0]?e("rect",{x:l.l+E[0]*p,y:l.t,width:(E[1]-E[0]+1)*p,height:d,class:"brush"}):null,t.map(($,M)=>{let I=0;return e("g",{opacity:E&&(M<E[0]||M>E[1])?.35:1,children:ct.map(C=>{if(r.has(C))return null;let L=$.byBucket[C];if(!L)return null;let T=y(I+L),F=y(I);return I+=L,e("rect",{x:l.l+M*p+f/2,y:T,width:Math.max(.5,p-f),height:Math.max(0,F-T-(f&&F-T>2?1:0)),fill:$t[C],rx:p>=6?1.5:0})})})}),h!==null?e("line",{x1:l.l+h*p+p/2,x2:l.l+h*p+p/2,y1:l.t,y2:l.t+d,class:"cross"}):null]}),x?e("div",{class:"tip",style:{left:Math.min(i-190,l.l+h*p+10),top:4},children:[e("b",{children:["week of ",x.week]})," \xB7 ",x.total," commit",x.total===1?"":"s"," \xB7 +",x.added,"/-",x.deleted,e("div",{class:"row tight",style:{marginTop:4,flexWrap:"wrap"},children:ct.filter($=>x.byBucket[$]).map($=>e("span",{class:"kdot-lbl",children:[e("i",{class:"kdot",style:{background:$t[$]}}),$," ",x.byBucket[$]]}))})]}):null]})}function xa({counts:t,hidden:n,onToggle:s}){return e("div",{class:"row tight",style:{flexWrap:"wrap"},children:ct.map(r=>e("button",{type:"button",class:A("chip",!n.has(r)&&"on"),onClick:()=>s(r),title:n.has(r)?`show ${r}`:`hide ${r}`,children:[e("i",{class:"kdot",style:{background:$t[r],opacity:n.has(r)?.3:1}}),r," ",t[r]??0]}))})}function Cs({values:t,width:n=72,height:s=16}){let r=Math.max(1,...t),a=t.length,i=t.map((o,l)=>`${l/Math.max(1,a-1)*(n-2)+1},${s-1-o/r*(s-3)}`);return e("svg",{width:n,height:s,class:"spark",title:t.join(" "),children:[e("title",{children:["commits per month: ",t.join(" ")]}),e("polyline",{points:i.join(" ")}),t.map((o,l)=>o?e("circle",{cx:l/Math.max(1,a-1)*(n-2)+1,cy:s-1-o/r*(s-3),r:1.4}):null)]})}function _a({files:t,selected:n,onSelect:s}){let[r,a]=ut(),i=300,o={l:42,r:16,t:12,b:30},l=Math.max(10,a-o.l-o.r),c=i-o.t-o.b,d=t.filter(k=>k.commits>=2),u=Math.max(2,...d.map(k=>k.commits)),p=Math.max(1,...d.map(k=>k.added+k.deleted)),f=k=>o.l+Math.log(k)/Math.log(u)*l,g=k=>o.t+c-k*c,y=k=>3+Math.sqrt((k.added+k.deleted)/p)*13,[h,m]=_(null),b=[...d].sort((k,w)=>w.risk-k.risk).slice(0,5),v=[1,2,5,10,20,50,100,200,500,1e3].filter(k=>k<=u);return e("div",{class:"hist-chart",ref:r,children:[e("svg",{width:a,height:i,children:[e("title",{children:"files by commits and fix share, sized by lines changed"}),[0,.25,.5,.75,1].map(k=>e("g",{children:[e("line",{x1:o.l,x2:a-o.r,y1:g(k),y2:g(k),class:"grid"}),e("text",{x:o.l-6,y:g(k)+3,class:"axis","text-anchor":"end",children:[Math.round(k*100),"%"]})]})),v.filter(k=>f(k)<a-o.r-70).map(k=>e("text",{x:f(k),y:i-8,class:"axis","text-anchor":"middle",children:k})),e("text",{x:a-o.r,y:i-8,class:"axis","text-anchor":"end",children:"commits (log) \u2192"}),e("text",{x:o.l+4,y:o.t+10,class:"axis",children:"share of commits that were fixes \u2191"}),d.map(k=>e("circle",{cx:f(k.commits),cy:g(k.commits?k.fixes/k.commits:0),r:y(k),fill:Ts(k.risk),class:A("dot",n===k.path&&"sel"),onMouseEnter:()=>m(k),onMouseLeave:()=>m(null),onClick:()=>s(k.path)})),b.map(k=>{let w=f(k.commits)>a-160;return e("text",{x:w?f(k.commits)-y(k)-3:f(k.commits)+y(k)+3,y:g(k.fixes/k.commits)+3,class:"lbl","text-anchor":w?"end":"start",children:k.path.split("/").slice(-2).join("/")})})]}),h?e("div",{class:"tip",style:{left:Math.min(a-260,f(h.commits)+12),top:Math.max(0,g(h.fixes/h.commits)-60)},children:[e("b",{children:h.path}),e("div",{class:"muted",children:[h.commits," commits \xB7 ",h.fixes," fixes \xB7 +",h.added,"/-",h.deleted," \xB7 risk"," ",h.risk.toFixed(2)]}),h.reasons.length?e("div",{class:"muted",children:h.reasons.join("; ")}):null]}):null]})}var ka=["#2563eb","#d97706","#16a34a","#7c3aed","#e11d48","#0284c7","#db2777","#0d9488"],En=t=>ka[t%ka.length];function Sa({rows:t,lanes:n,rowH:s,selected:r}){let i=n*14+10,o=d=>7+d*14,l=d=>d*s+s/2,c=ya(t);return e("svg",{class:"lanes",width:i,height:t.length*s,children:[e("title",{children:"commit graph"}),c.map(d=>d.kind==="line"?e("line",{x1:o(d.lane),x2:o(d.lane),y1:l(d.from),y2:l(d.to),stroke:En(d.lane)}):e("path",{d:`M${o(d.fromLane)},${l(d.from)} C${o(d.fromLane)},${l(d.from)+s/2} ${o(d.toLane)},${l(d.to)-s/2} ${o(d.toLane)},${l(d.to)}`,stroke:En(d.lane)})),t.map((d,u)=>e("circle",{cx:o(d.lane),cy:l(u),r:d.c.merge?3.5:4,fill:d.c.merge?"var(--card)":En(d.lane),stroke:En(d.lane),"stroke-width":r===d.c.sha?3:d.c.merge?2:1,class:A(r===d.c.sha&&"sel",!d.c.onHead&&"off")}))]})}var Tn=["heuristic","blend","cache","fallback"],Tt={heuristic:"#2563eb",blend:"#7c3aed",cache:"#0d9488",fallback:"#d97706"},Xt={heuristic:"local heuristic only",blend:"heuristic blended with the provider",cache:"reused an earlier verdict for the same text",fallback:"provider failed or was skipped; heuristic used"},Rs=["heuristic","provider","learned"],Cn={heuristic:"#2563eb",provider:"#7c3aed",learned:"#d97706"},Ca={heuristic:"local features (words, intents, paths, risk \u2026) scored on this machine",provider:"the provider's probability \xD7 \u03B1 (its weight in the blend)",learned:"learned bias from past outcomes, plus provider risk / plan boosts"},An=["trivial","simple","moderate","complex","very complex"];function Rn(t){return typeof t!="number"||!Number.isFinite(t)?"n/a":An[Math.max(0,Math.min(4,Math.round(t)))]}function ze(t){return typeof t=="number"&&Number.isFinite(t)?`${Math.round(t*100)}%`:"\u2014"}function ue(t){return typeof t!="number"||!Number.isFinite(t)?"\u2014":t<1e3?`${Math.round(t)} ms`:`${(t/1e3).toFixed(t<1e4?1:0)} s`}var Sc=t=>Math.round(t*100)/100;function Mn(t){let n=Sc(t);return n>0?`+${n.toFixed(2)}`:n<0?`\u2212${Math.abs(n).toFixed(2)}`:"0.00"}var Ea=new Set(["bias","risky","needsPlan"]),$n=(t,n)=>t.reduce((s,r)=>n(r.feature)?s+(Number(r.weight)||0):s,0);function Aa(t,n=0){let s=t.entries??[],r=s.reduce((u,p)=>u+$n(p.reasons??[],f=>Ea.has(f)),0),a=Math.max(1e-9,1+r),i=[...s].sort((u,p)=>p.score-u.score),o=t.choice??i[0]?.option??"",l=i.find(u=>u.option!==o)??null,c=i.map(u=>{let p=u.reasons??[],f=Math.max(0,u.score)*a,g=Math.max(0,Math.min(f,$n(p,b=>b==="provider"))),y=Math.max(0,Math.min(f-g,$n(p,b=>Ea.has(b)))),h=Math.max(0,f-g-y),m=f>0?u.score/f:0;return{...u,reasons:p,parts:{heuristic:h*m,provider:g*m,learned:y*m},chosen:u.option===o,runnerUp:l!==null&&u.option===l.option}}),d=c.find(u=>u.chosen);return{dimension:t.dimension,entries:c,choice:o,runnerUp:l?.option??null,margin:d&&l?d.score-l.score:null,confidence:t.confidence??0,roundedUp:!!i[0]&&i[0].option!==o,alpha:n,providerShare:d&&d.score>0?d.parts.provider/d.score:0}}function Ms(t,n=1/0){return[...t??[]].sort((s,r)=>Math.abs(r.weight)-Math.abs(s.weight)).slice(0,n)}function Ra(t,n){let s=n??[],r=s.filter(i=>i.feature==="provider"),a=$n(r,()=>!0);return{value:t,heuristic:t-a,provider:a,terms:Ms(s.filter(i=>i.feature!=="provider")),providerNote:r[0]?.note??null}}function Ma(t){return t.startsWith("intent.")?`intent: ${t.slice(7)}`:t}var Ec={advised:{label:"advised",tone:"accent",help:"advice was given; whether it was taken is not known yet"},followed:{label:"followed",tone:"ok",help:"the advice was taken (advise mode)"},applied:{label:"applied",tone:"ok",help:"the adjudicator set the model itself (apply mode)"},respected:{label:"respected",tone:"muted",help:"apply mode left an explicitly pinned model alone"},ignored:{label:"ignored",tone:"warn",help:"a different choice was made than advised"},none:{label:"none",tone:"muted",help:"nothing to advise on (e.g. too short or chat)"}},js=t=>Ec[t??"none"]??{label:t??"\u2014",tone:"muted",help:""},Ls={pending:{tone:"muted",help:"the work has not finished yet"},success:{tone:"ok",help:"the work finished and was not redone"},failure:{tone:"bad",help:"the work failed or had to be redone"},abandoned:{tone:"warn",help:"the session ended before the work finished"},"n/a":{tone:"muted",help:"no outcome is tracked for this surface"}},ja=t=>Ls[t??""]?.tone??"muted";function Is(t){return!t||t==="n/a"||t==="skipped"?"muted":t==="ok"?"ok":t==="slow_guard"||t==="over_budget"||t==="breaker_open"||t==="rate_limited"?"warn":"bad"}function jn(t){switch(t){case null:case void 0:return{label:"not called yet",tone:"muted",help:"no call has been made to this provider"};case"closed":return{label:"healthy",tone:"ok",help:"breaker closed: calls go through"};case"half_open":return{label:"probing",tone:"warn",help:"breaker half-open: the next call is a probe"};case"open":return{label:"paused",tone:"bad",help:"breaker open: calls skip the provider until the retry time"};case"slow":return{label:"slow",tone:"warn",help:"recent calls ran past the latency budget"};case"auth_failed":return{label:"auth failed",tone:"bad",help:"the provider rejected the key"};default:return{label:t.replace(/_/g," "),tone:"warn",help:`breaker state ${t}`}}}var $c={used:"heuristic blended with the provider",disabled:"the adjudicator is off: heuristic only",not_requested:"heuristic only (provider not requested)",heuristic_configured:"heuristic only: no provider is configured",no_key:"heuristic only: the provider has no key",no_consent:"heuristic only: remote consent has not been given",hook_context:"heuristic only in this context",misconfigured:"heuristic only: the provider is misconfigured"},La=t=>$c[t]??t.replace(/_/g," "),Ln={no_key:"no key found: run `eminiar adjudicator key set` or set keyEnv",no_consent:"remote consent not given: run `eminiar adjudicator consent`",misconfigured:"the provider settings are incomplete",hook_context:"remote providers are not called from hooks"};function Ia(t){return Math.max(1,...t.map(n=>n.total))}function Fa(t){let n=Math.max(1,Math.ceil(t));if(n<=2)return[0,n];let s=Math.ceil(n/2);return[0,s,s*2]}var $a=["haiku","sonnet","opus","fable"];function Ta(t,n){let s=$a.indexOf(t),r=$a.indexOf(n);return s>=0&&r>=0?s-r:s>=0?-1:r>=0?1:t.localeCompare(n)}function In(t){let n=new Map,s=new Set,r=new Set,a=0,i=0,o=0;for(let l of t){let c=`${l.suggested}\0${l.actual}`,d=(n.get(c)??0)+l.n;n.set(c,d),s.add(l.suggested),r.add(l.actual),a=Math.max(a,d),i+=l.n,l.suggested===l.actual&&(o+=l.n)}return{rows:[...s].sort(Ta),cols:[...r].sort(Ta),cell:(l,c)=>n.get(`${l}\0${c}`)??0,max:a,total:i,agree:o}}function Fs(t){if(!t)return"";let n=[];return t.pin&&n.push(`${t.pin} kept their pin`),t.force&&n.push(`${t.force} under CLAUDE_CODE_SUBAGENT_MODEL_FORCE`),t.fork&&n.push(`${t.fork} fork${t.fork===1?"":"s"}`),n.join(" \xB7 ")}function Fn(t,n){return!(t>0)||!(n>0)?0:.08+.82*(t/n)}function Pa(t,n,s){let r={limit:n,offset:s};return t.since&&t.since!=="all"&&(r.since=t.since),t.surface&&(r.surface=t.surface),t.provider&&(r.provider=t.provider),t.outcome&&(r.outcome=t.outcome),r}function Da(t,n,s){return!s||!n?`0 of ${s}`:`${t+1}\u2013${t+n} of ${s}`}function Oa(t){return t.surface==="prompt"?"main-session advice: potential savings only, never added to net":t.surface==="test"?"try-it runs are not counted":t.action!=="followed"&&t.action!=="applied"?"no credit: the advice was not followed or applied":t.savingsUsd===null||t.savingsUsd===void 0?t.final?"no usage data to price this dispatch (usage ingest off?)":"not reconciled yet: waits for the dispatch to finish":t.outcome==="failure"&&t.savingsUsd<0?"redo penalty: the attempt failed and its full cost is charged":"baseline model cost \u2212 actual cost at list prices, same tokens"}function Na(t){if(t.usageAvailable)return null;let n=t.creditedRows>0||t.realisedUsd!==0;return{label:n?"no API calls recorded: new dispatches and potential savings are not priced":"no API calls recorded: savings cannot be priced",help:"Savings are priced from Claude Code's API calls, which usage ingestion records (config.usage.enabled). Without them reconcile cannot price new dispatches and potential savings stay $0"+(n?"; realised and net still include the dispatches priced earlier.":"; spend still counts the adjudicator's own provider calls.")}}function Ua(t,n=5,s=.05){return Object.entries(t?.intents??{}).filter(a=>typeof a[1]=="number"&&a[1]>=s).sort((a,i)=>i[1]-a[1]).slice(0,n)}function Ha(t){if(!t)return[];let n=[],s=(r,a)=>{typeof a=="number"&&a>0&&n.push([r,String(Math.round(a*100)/100)])};return s("words",t.words),s("lines",t.lines),s("paths",t.paths),s("symbols",t.symbols),typeof t.scope=="number"&&n.push(["scope",t.scope.toFixed(2)]),typeof t.risk=="number"&&n.push(["risk",t.risk.toFixed(2)]),t.codeBlock&&n.push(["code block","yes"]),t.stackTrace&&n.push(["stack trace","yes"]),t.chat&&n.push(["chat","yes"]),t.slash&&n.push(["slash command","yes"]),t.classify&&n.push(["classified",t.classify]),t.task&&(t.task.role&&n.push(["task role",t.task.role]),n.push(["task files",String(t.task.files)]),n.push(["task deps",String(t.task.deps)])),n}var As=t=>t==null?"\u2014":typeof t=="number"?Number.isInteger(t)?String(t):Math.abs(t)<=1?t.toFixed(3):t.toFixed(1):typeof t=="boolean"?t?"yes":"no":typeof t=="string"?t:JSON.stringify(t);function Tc(t){let n={};for(let[s,r]of Object.entries(t))if(r&&typeof r=="object"&&!Array.isArray(r))for(let[a,i]of Object.entries(r))i&&typeof i=="object"||(n[`${s}.${a}`]=As(i));else Array.isArray(r)||(n[s]=As(r));return n}function Ba(t){if(!t)return null;let s=["rows","results","providers","candidates"].map(i=>t[i]).find(i=>Array.isArray(i)&&i.length)??Object.values(t).find(i=>Array.isArray(i)&&i.length&&i.every(o=>o&&typeof o=="object"));if(!Array.isArray(s))return null;let r=s.filter(i=>i&&typeof i=="object").map(i=>Tc(i)),a=[];for(let i of r)for(let o of Object.keys(i))a.includes(o)||a.push(o);return{columns:a,rows:r}}function Ja(t){return t?Object.entries(t).filter(([,n])=>n===null||typeof n!="object").map(([n,s])=>[n,As(s)]):[]}var Cc="eminiar adjudicator exchanges on",Ac="eminiar adjudicator exchanges purge --yes",Ps=100,Xa="api.typesafe.ai",ge=t=>ue(t);function Ds(t){if(typeof t!="number"||!Number.isFinite(t)||t<0)return"\u2014";let n=Math.round(t);return`${n.toLocaleString("en-US")} ${n===1?"character":"characters"}`}function Os(t,n){let s=r=>typeof r!="number"||!Number.isFinite(r)?"\u2014":r>=1e3?`${(r/1e3).toFixed(1)}k`:String(Math.round(r));return`${s(t)} / ${s(n)}`}function Ns(t){let n=typeof t.status=="number"&&t.status>0?t.status:null;switch(t.outcome){case"ok":return n!==null?String(n):"ok";case"timeout":return"timeout";case"rate_limited":return n!==null?`${n} rate limited`:"rate limited";case"http_error":return n!==null?`http ${n}`:"http error";case"invalid":return"invalid";case"no_key":return"no key";default:return String(t.outcome).replace(/_/g," ")||"unknown"}}function za(t){switch(t){case"ok":return"ok";case"timeout":case"http_error":return"bad";case"rate_limited":case"invalid":return"warn";default:return"muted"}}function Ga(t){let n=t.durationMs,s=t.deadlineMs;if(typeof n!="number"||!Number.isFinite(n)||typeof s!="number"||s<=0)return{frac:0,over:t.timedOut};let r=n/s;return{frac:Math.min(1,Math.max(0,r)),over:t.timedOut||r>=1}}function Wa(t){let n=ge(t.waitMs);return typeof t.jobWaitMs=="number"&&t.jobWaitMs>0?`${n} \xB7 job +${ge(t.jobWaitMs)}`:n}function qa(t){return t.retryWaitMs>0?`${t.attempts} \xB7 \u21BB ${ge(t.retryWaitMs)}`:String(t.attempts)}function Ka(t,n=Date.now()){if(!Number.isFinite(t)||t<=0)return"\u2014";let s=Math.max(0,n-t);return s<6e4?"just now":s<36e5?`${Math.round(s/6e4)}m ago`:s<864e5?`${Math.round(s/36e5)}h ago`:`${Math.round(s/864e5)}d ago`}var Ct=t=>typeof t=="number"&&Number.isFinite(t)&&t>0?t:0;function Va(t){let n=Ct(t.jobWaitMs),s=Ct(t.waitMs),r=Ct(t.durationMs),a=Math.min(Ct(t.retryWaitMs),r),i=Math.min(Ct(t.ttfbMs),Math.max(0,r-a)),o=Math.max(0,r-a-i),l=[{key:"job",label:"job wait",help:"queued in the background scoring job before it started",ms:n},{key:"wait",label:"wait before send",help:"from the start of the call to the moment the request was sent",ms:s},{key:"retry",label:"retry wait",help:"pause before the second attempt, after a 429 or 529",ms:a},{key:"ttfb",label:"to first byte",help:"from sending the final attempt to the first byte of the answer",ms:i},{key:"rest",label:t.attempts>1?"first attempt + body":"body read",help:t.attempts>1?"the superseded first attempt and reading the final answer":"reading the answer after its first byte",ms:o}],c=l.reduce((y,h)=>y+h.ms,0),d=Ct(t.deadlineMs),u=d>0?n+s+d:0,p=Math.max(c,u),f=0;return{segments:l.filter(y=>y.ms>0).map(y=>{let h=p>0?f/p:0,m=p>0?y.ms/p:0;return f+=y.ms,{...y,start:h,width:m}}),totalMs:p,deadlineAt:u>0&&p>0?u/p:null}}function Za(t){if(!t)return{text:"",formatted:!1,note:null};let n=t.truncated?`truncated: the stored text is cut, the body was ${Ds(t.bytes)}`:null;if(t.json&&!t.truncated)try{return{text:JSON.stringify(JSON.parse(t.text),null,2),formatted:!0,note:n}}catch{}return{text:t.text,formatted:!1,note:n}}function Rc(t){let n=(t??"").trim();return n&&n.split(/[/?#]/)[0]||Xa}function Ya(t,n=Ps){return`Contains your redacted prompt text: each row is the exact request sent to ${Rc(t)} (redacted, up to privacy.maxChars characters per item) and Jev's answer, stored in this project's local database. Only the newest ${n} are kept. Delete them: ${Ac}`}function Qa(){return{before:"Request capture is off. To see each request eminiar sends to Jev, what it contained, what came back and how long it took, run",command:Cc,after:"It is a personal setting: a project's eminiar.config.json cannot turn it on. Captured requests contain your redacted prompt text."}}var ei="Capture is on. No request has gone to Jev since. Prompt scoring runs in the background, so a request appears when that job finishes.";function ti(t){return t?t.active?t.capture?t.rows.length?"rows":"empty":"off":"hidden":"loading"}function ni(t,n){return`Request #${t.id} \xB7 ${n} \xB7 ${Ns(t)}`}var ri=t=>new Date(t).toLocaleString(),Mc=t=>new Date(t).toISOString();function ai({x:t}){let n=za(t.outcome);return e("span",{class:A("tag",`adj-t-${n}`),children:Ns(t)})}function jc({x:t}){let{frac:n,over:s}=Ga(t);return e("span",{class:"xchg-meter",title:`${ge(t.durationMs)} of a ${ge(t.deadlineMs)} deadline`,role:"img","aria-label":`${ge(t.durationMs)} of a ${ge(t.deadlineMs)} deadline`,children:e("span",{class:A("xchg-meter-fill",s&&"over"),style:{width:`${Math.max(n>0?3:0,Math.round(n*100))}%`}})})}function Lc({rows:t,now:n,onRow:s,onOpen:r}){return e("div",{class:"adj-scroll",children:e("table",{class:"adj-tiers xchg-table",children:[e("thead",{children:e("tr",{children:[e("th",{children:"time"}),e("th",{children:"surface"}),e("th",{children:"result"}),e("th",{children:"duration"}),e("th",{class:"num",children:"wait"}),e("th",{class:"num",children:"tries"}),e("th",{class:"num",children:"items"}),e("th",{class:"num",title:"tokens in / out",children:"tokens"}),e("th",{children:"decisions"})]})}),e("tbody",{children:t.map(a=>e("tr",{class:"xchg-row",onClick:()=>s(a.id),children:[e("td",{title:Mc(a.ts),children:e("button",{type:"button",class:"adj-link",onClick:i=>{i.stopPropagation(),s(a.id)},"aria-label":`open request ${a.id}`,children:Ka(a.ts,n)})}),e("td",{children:a.surface??"\u2014"}),e("td",{children:e(ai,{x:a})}),e("td",{children:e("span",{class:"xchg-dur",children:[ge(a.durationMs),e(jc,{x:a})]})}),e("td",{class:"num",children:Wa(a)}),e("td",{class:"num",children:qa(a)}),e("td",{class:"num",children:a.items}),e("td",{class:"num",children:Os(a.tokensIn,a.tokensOut)}),e("td",{children:a.rowIds.length?e("span",{class:"xchg-ids",children:a.rowIds.map(i=>e("button",{type:"button",class:"adj-link",onClick:o=>{o.stopPropagation(),r(i)},children:["#",i]},i))}):e("span",{class:"muted",children:"\u2014"})})]},a.id))})]})})}function Ic({x:t}){let n=Va(t);return n.segments.length?e(j,{children:[e("div",{class:"xchg-bar",role:"img","aria-label":"request timing",children:[n.segments.map(s=>e("span",{class:`xchg-seg xchg-seg-${s.key}`,style:{left:`${s.start*100}%`,width:`${s.width*100}%`},title:`${s.label}: ${ge(s.ms)} (${s.help})`},s.key)),n.deadlineAt!==null?e("span",{class:"xchg-deadline",style:{left:`${n.deadlineAt*100}%`},title:`deadline ${ge(t.deadlineMs)} after sending`}):null]}),e("ul",{class:"xchg-legend small",children:[n.segments.map(s=>e("li",{title:s.help,children:[e("span",{class:`xchg-dot xchg-seg-${s.key}`})," ",s.label," ",ge(s.ms)]},s.key)),n.deadlineAt!==null?e("li",{children:[e("span",{class:"xchg-dot xchg-dot-deadline"})," deadline ",ge(t.deadlineMs)]}):null]})]}):e(B,{children:"no timing was recorded"})}function si({title:t,body:n,kind:s}){if(!n)return e("div",{class:"muted small",children:["no ",s," was stored"]});let r=Za(n),a=async()=>{try{await navigator.clipboard.writeText(r.text),Y(`${t} copied`)}catch{Y("could not copy",!0)}};return e(j,{children:[e("div",{class:"xchg-body-head small",children:[e("span",{class:"muted",children:[Ds(n.bytes),r.formatted?" \xB7 formatted JSON":n.json?" \xB7 JSON":" \xB7 text"]}),e("button",{type:"button",class:"ghost sm",onClick:a,children:"Copy"})]}),r.note?e("div",{class:"warn small xchg-trunc",children:r.note}):null,e("pre",{class:"xchg-json",children:r.text})]})}function Fc({x:t}){let n=[["sent at",ri(t.ts)],["wait before send",ge(t.waitMs)],["job wait",t.jobWaitMs===null?"\u2014 (not a background job)":ge(t.jobWaitMs)],["to first byte",ge(t.ttfbMs)],["duration",ge(t.durationMs)],["retry wait",t.retryWaitMs>0?ge(t.retryWaitMs):"\u2014"],["attempts",String(t.attempts)],["deadline",ge(t.deadlineMs)],["engine budget",ge(t.budgetMs)],["timed out",t.timedOut?"yes":"no"],["HTTP status",t.status===null?"\u2014":String(t.status)]];return e("dl",{class:"kv xchg-facts",children:n.map(([s,r])=>e(j,{children:[e("dt",{children:s}),e("dd",{children:r})]}))})}function Pc({x:t,onOpen:n}){return e(j,{children:[e("section",{children:[e("div",{class:"adj-h",children:"Timing"}),e(Ic,{x:t}),e(Fc,{x:t})]}),t.rowIds.length?e("section",{children:[e("div",{class:"adj-h",children:"Decisions this request served"}),e("span",{class:"xchg-ids",children:t.rowIds.map(s=>e("button",{type:"button",class:"adj-link",onClick:()=>n(s),children:["#",s]},s))})]}):null,e("section",{children:[e("div",{class:"adj-h",children:["Request",e("span",{class:"right muted small",children:[t.target," \xB7 ",t.model??"model unknown"," \xB7 ",t.items," item",t.items===1?"":"s"]})]}),e(si,{title:"request",body:t.request,kind:"request"})]}),e("section",{children:[e("div",{class:"adj-h",children:["Response",e("span",{class:"right muted small",children:[Os(t.tokensIn,t.tokensOut)," tokens",t.costUsd!==null?` \xB7 $${t.costUsd.toFixed(4)}`:""]})]}),t.error?e("div",{class:"warn small xchg-trunc",children:["error: ",t.error]}):null,e(si,{title:"response",body:t.response,kind:"response"})]})]})}function Dc({id:t,onClose:n,onOpen:s}){let r=X(()=>da(t),[t]),a=ee(null);J(()=>{let o=document.activeElement;a.current?.focus();let l=c=>{c.key==="Escape"&&n()};return window.addEventListener("keydown",l),()=>{window.removeEventListener("keydown",l),o?.focus?.()}},[t]);let i=r.data?.active&&r.data.capture?r.data.exchange:null;return e(j,{children:[e("div",{class:"adj-backdrop",onClick:n}),e("aside",{class:"adj-drawer",ref:a,tabIndex:-1,role:"dialog","aria-modal":"true","aria-label":`Jev request ${t}`,children:[e("div",{class:"adj-drawer-head",children:[e("b",{children:i?ni(i,ri(i.ts)):`Request #${t}`}),i?e(ai,{x:i}):null,e("span",{class:"spacer"}),e("button",{type:"button",class:"ghost sm",onClick:n,"aria-label":"close",children:"\u2715 close"})]}),e("div",{class:"adj-drawer-body",children:r.error?e(W,{error:r.error}):r.data?i?e(Pc,{x:i,onOpen:o=>{n(),s(o)}}):e(B,{children:"Request capture is off or Jev is not the provider, so nothing is shown."}):e(N,{})})]})]})}function ii({tick:t,onOpen:n}){let s=X(()=>ca(),[t]),[r,a]=_(null),i=ti(s.data);if(i==="hidden")return null;let o=s.data?.active&&s.data.capture?s.data:null,l=s.data?.active?s.data.keep:Ps,c=e("h3",{children:["Jev requests",e("span",{class:"right muted small",children:["newest ",l," kept \xB7 capture ",i==="off"?"off":i==="loading"?"\u2026":"on"]})]}),d;if(s.error)d=e(W,{error:s.error});else if(i==="loading")d=e(N,{});else if(i==="off"){let u=Qa();d=e(B,{children:[u.before," ",e("code",{class:"adj-cmd",children:u.command}),". ",u.after]})}else i==="empty"?d=e(B,{children:ei}):d=e(j,{children:[e("div",{class:"jev-banner warn small",role:"note",children:Ya(o?.rows[0]?.target,l)}),e(Lc,{rows:o?.rows??[],now:o?.now??Date.now(),onRow:a,onOpen:n}),o&&o.total>o.rows.length?e("div",{class:"muted small jev-notes",children:["showing the newest ",o.rows.length," of ",o.total]}):null]});return e("section",{class:"card jev-xchg",children:[c,d,r!==null?e(Dc,{id:r,onClose:()=>a(null),onOpen:n}):null]})}function Pn(t){return!!t&&t.enabled===!0&&t.provider?.configured==="typesafe"}var zt=t=>t==null||!Number.isFinite(t)?"\u2014":lt(t);function li(t){return t==="helping"?"ok":t==="hindering"?"bad":"muted"}function ci(t){return t==="help"?"ok":t==="hurt"?"bad":"muted"}var Oc={too_small_after_up:"marked too small after Jev moved it up",too_big_after_up:"marked too big after Jev moved it up",good_after_up:"marked good after Jev moved it up",too_small_after_down:"marked too small after Jev moved it down",too_big_after_down:"marked too big after Jev moved it down",good_after_down:"marked good after Jev moved it down",success_after_down:"the cheaper model finished the work",failure_after_down:"the cheaper model failed or was redone",success_after_up:"finished on the bigger model (not counted)",failure_after_up:"failed even on the bigger model (not counted)"};function di(t){return Oc[t]??t.replace(/_/g," ")}function ui(t){let n=[...t.reasons??[]];return t.n&&n.push(`n = ${t.n}`),n.join(" \xB7 ")}function pi(t){return In((t??[]).map(n=>({suggested:n.from,actual:n.to,n:n.n})))}function Nc(t,n){return!t.n||!n.n||t.p50===null||n.p50===null?null:Math.max(0,t.p50-n.p50)}var oi=(t,n)=>n>0?ze(t/n):"\u2014";function mi(t,n){let s=t.influence.tier,r=t.influence.effective,a=t.cost,i=s.up+s.down,o=Math.max(0,s.compared-s.uncertain),l=t.coverage,c=Math.max(0,l.attempts-l.errors),d=Nc(a.inline,a.heuristicInline),u=t.savings,p=jn(n),f=u.usageAvailable&&u.repriced>0;return[{title:"changed the tier",value:oi(i,o),sub:`\u2191${s.up} \u2193${s.down} of ${o} compared \xB7 ${s.uncertain} uncertain left out \xB7 ${t.sample.deferred} deferred`,help:"decisions where Jev moved the tier away from what the heuristic alone would have chosen; uncertain near-ties and deferred async prompt rows are not counted"},{title:"effective model changed",value:oi(r.changed,r.dispatches),sub:`${r.changed} of ${r.dispatches} dispatches \xB7 unknown ${r.unknown}`,help:"dispatches whose model, after the apply bounds, differs from what the heuristic alone would have led to; unknown: a ranged role or apply bounds that are not stored could have changed the answer"},{title:"Jev calls",value:String(l.attempts),sub:`${c} answered \xB7 failure ${ze(l.failureRate)} \xB7 p50 ${ue(a.providerLatency.p50)} \xB7 breaker ${p.label}`,help:"provider calls attempted for decisions in range, answered or not (timeouts and errors included), and the share that failed"},{title:"Jev spend",value:zt(a.spendUsd),sub:`${a.usdPerCall===null?"\u2014":lt(a.usdPerCall)} per call \xB7 adds ${d===null?"\u2014":`~${ue(d)}`} inline`,help:"the provider's own cost; the added wait is the p50 inline latency of Jev decisions minus heuristic-only ones"},{title:"net from Jev's changes",value:f?zt(u.netUsd):"\u2014",sub:u.usageAvailable?u.repriced===0?"no repriced dispatches yet":`saved ${zt(u.downSavedUsd)} \xB7 extra ${zt(u.upCostUsd)} \xB7 spend ${zt(a.spendUsd)}`:"no usage data",help:"cost the changed dispatches would have had on the heuristic's model, minus what they cost, minus Jev's spend (list prices)"}]}function hi(t){return Object.entries(t.bySurface??{}).map(([n,s])=>({label:n,...s})).filter(n=>n.compared>0).sort((n,s)=>s.compared-n.compared||n.label.localeCompare(s.label))}function Us(t){return t.compared?`agree ${t.agree} of ${t.compared} \xB7 ${t.changed} changed \xB7 ${t.uncertain} uncertain`:"no compared decisions"}function gi(t){if(!t.n||t.meanDelta===null)return t.excludedBeforeFix?`no scored rows yet (${t.excludedBeforeFix} before the score-scale fix left out)`:"no scored rows yet";let n=t.meanDelta;return`mean \u0394 ${n>0?"+":n<0?"\u2212":""}${Math.abs(n).toFixed(2)} \xB7 mean |\u0394| ${(t.meanAbsDelta??0).toFixed(2)} over ${t.n}`+(t.excludedBeforeFix?` \xB7 ${t.excludedBeforeFix} before the score-scale fix left out`:"")}function Uc(t){let n=t.success+t.failure;return n?`${ze(t.successRate)} of ${n}`:"\u2014"}function fi(t,n){let s=(r,a)=>({label:r,changed:a(t),unchanged:a(n)});return[s("dispatches",r=>String(r.dispatches)),s("advice followed",r=>ze(r.followRate)),s("success",Uc),s("feedback: good",r=>String(r.feedback.good)),s("feedback: too small",r=>String(r.feedback.too_small)),s("feedback: too big",r=>String(r.feedback.too_big))]}function bi(t){return[`kept model ${t.kept}`,`deferred ${t.deferred}`,`fell back ${t.notJev}`,`uncertain ${t.uncertain+t.unreconstructable}`,`unknown model ${t.unknown}`,`apply bounds not stored ${t.bounds??0}`,`advised tier not run ${t.notRun??0} (outcome and feedback not counted)`,`outcome not final yet ${t.notFinal??0}`].join(" \xB7 ")}function vi(t){let n=t.cost,s=[];n.providerLatency.n&&s.push(`provider p50 ${ue(n.providerLatency.p50)} \xB7 p95 ${ue(n.providerLatency.p95)} over ${n.providerLatency.n}`),n.inline.n&&s.push(`inline p50 ${ue(n.inline.p50)} over ${n.inline.n}`),s.push(`deferred ${n.deferred}`),s.push(`timeouts ${n.timeouts}`);let r=Object.entries(t.sample.models??{}).sort((i,o)=>o[1]-i[1]).map(([i,o])=>`${i}: ${o}`);r.length&&s.push(`models ${r.join(", ")}`);let a=t.sample.eras;return(a.units||a.wholeText)&&s.push(`briefs per statement ${a.units} \xB7 as one text ${a.wholeText}`),s}var ki=({tone:t,children:n,title:s})=>e("span",{class:A("tag",`adj-t-${t}`),title:s,children:n});function Hc({t}){let n=pi(t.transitions);return n.total?e(j,{children:[e("div",{class:"adj-scroll",children:e("table",{class:"adj-matrix",children:[e("thead",{children:e("tr",{children:[e("th",{class:"corner",children:"heuristic \u2193 \xB7 with Jev \u2192"}),n.cols.map(s=>e("th",{class:"num",children:s}))]})}),e("tbody",{children:n.rows.map(s=>e("tr",{children:[e("th",{children:s}),n.cols.map(r=>{let a=n.cell(s,r),i=Fn(a,n.max);return e("td",{class:A("num","cell",s===r&&"diag",i>.55&&"strong"),style:i?{background:`color-mix(in srgb, var(--accent) ${Math.round(i*100)}%, transparent)`}:void 0,title:`${a} decisions: heuristic ${s}, with Jev ${r}`,children:a||""})})]}))})]})}),e("div",{class:"sub",children:[n.agree," of ",n.total," kept the heuristic's tier \xB7 outlined cells are agreement"]}),e("div",{class:"muted small jev-notes",children:["Jev overruled by the heuristic ",t.jevOverruled," \xB7 rounded up for low confidence"," ",t.roundUps.final," (only because of blending: ",t.roundUps.blendInduced,")",t.wouldHaveChanged.compared?` \xB7 deferred (async) ${t.wouldHaveChanged.changed} of ${t.wouldHaveChanged.compared} would have changed`:""]})]}):e(B,{children:"no compared decisions yet"})}function Bc({r:t}){let n=t.influence.tier,s=hi(n),r=t.influence.effort;return e(j,{children:[s.length?e("div",{class:"adj-scroll",children:e("table",{class:"adj-tiers",children:[e("thead",{children:e("tr",{children:[e("th",{children:"surface"}),e("th",{class:"num",children:"compared"}),e("th",{class:"num",children:"agree"}),e("th",{class:"num",title:"Jev raised the tier",children:"\u2191"}),e("th",{class:"num",title:"Jev lowered the tier",children:"\u2193"})]})}),e("tbody",{children:s.map(a=>e("tr",{children:[e("td",{children:a.label}),e("td",{class:"num",children:a.compared}),e("td",{class:"num",children:a.agree}),e("td",{class:"num",children:a.up}),e("td",{class:"num",children:a.down})]}))})]})}):e(B,{children:"no compared decisions yet"}),e("ul",{class:"jev-lines",children:[e("li",{children:[e("b",{children:"role"})," ",Us(t.influence.role)]}),e("li",{children:[e("b",{children:"tool"})," ",Us(t.influence.tool)," ",e("span",{class:"muted",children:"(tools change only through Jev's needs-plan boost)"})]}),e("li",{children:[e("b",{children:"effort"})," \u2191",r.up," \u2193",r.down," of ",r.compared]}),e("li",{children:[e("b",{children:"complexity"})," ",gi(t.influence.complexity)]})]})]})}function Jc({r:t}){let n=fi(t.outcomes.changed,t.outcomes.unchanged),s=t.outcomes.excluded;return e(j,{children:[e("div",{class:"adj-scroll",children:e("table",{class:"adj-tiers",children:[e("thead",{children:e("tr",{children:[e("th",{}),e("th",{class:"num",children:"Jev changed it"}),e("th",{class:"num",children:"same as heuristic"})]})}),e("tbody",{children:n.map(r=>e("tr",{children:[e("td",{children:r.label}),e("td",{class:"num",children:r.changed}),e("td",{class:"num",children:r.unchanged})]}))})]})}),e("div",{class:"muted small jev-notes",children:["left out: ",bi(s)]})]})}function Xc({r:t,onOpen:n}){let s=t.outcomes.evidence;return s.rows.length?e(j,{children:[e("div",{class:"sub",children:["help ",s.help," \xB7 hurt ",s.hurt," \xB7 neutral ",s.neutral," (newest ",s.rows.length," listed)"]}),e("ul",{class:"jev-evidence",children:s.rows.map(r=>e("li",{children:[e(ki,{tone:ci(r.kind),children:r.kind}),e("button",{type:"button",class:"adj-link",onClick:()=>n(r.id),children:["#",r.id]}),e("span",{class:"muted small",children:r.surface}),e("span",{class:"jev-move",children:[r.from," \u2192 ",r.to]}),e("span",{class:"muted small jev-why",children:di(r.code)})]}))})]}):e(B,{children:"no labelled outcomes on decisions Jev changed yet: feedback through em_adjudicate and finished swarm tasks add them"})}function zc({range:t,tick:n,onOpen:s}){let[r,a]=_(!1),i=X(()=>la(t),[t,n]);if(i.data&&!i.data.active)return null;let o=i.data?.active?i.data:void 0,l=e("h3",{children:["Jev impact",e("span",{class:"right muted small",children:["TypeSafe Jev blended onto the heuristic \xB7 ",t]})]});if(i.error)return e("section",{class:"card jev-impact",children:[l,e(W,{error:i.error})]});if(!o)return e("section",{class:"card jev-impact",children:[l,e(N,{})]});if(!o.sample.rows)return e("section",{class:"card jev-impact",children:[l,o.provider.degraded?e(yi,{why:o.provider.degraded}):null,e(B,{children:"no Jev decisions in this range yet"})]});let c=o.verdict,d=li(c.label),u=o.provider.degraded?c.warnings.filter(p=>!p.startsWith("Jev is configured but degraded")):c.warnings;return e("section",{class:"card jev-impact",children:[l,o.provider.degraded?e(yi,{why:o.provider.degraded}):null,e("div",{class:"jev-verdict",children:[e(ki,{tone:d,children:c.label}),e("span",{class:"jev-why-line",children:ui(c)}),e("button",{type:"button",class:"adj-link","aria-expanded":r,onClick:()=>a(!r),children:"how is this decided?"})]}),r?e("div",{class:"jev-rule",children:[e("p",{class:"small",children:c.rule}),e("ul",{class:"reasons",children:o.savings.assumptions.map(p=>e("li",{children:p}))})]}):null,u.length?e("ul",{class:"warn small jev-warn",children:u.map(p=>e("li",{children:p}))}):null,e("div",{class:"grid adj-kpis",children:mi(o,o.provider.health?.state).map(p=>e("div",{class:"card",title:p.help,children:[e("h3",{children:p.title}),e("div",{class:"big",children:p.value}),e("div",{class:"sub",children:p.sub})]}))}),e("div",{class:"grid two",children:[e("div",{class:"card",children:[e("h3",{children:"heuristic \u2192 final tier"}),e(Hc,{t:o.influence.tier})]}),e("div",{class:"card",children:[e("h3",{children:"agreement"}),e(Bc,{r:o})]})]}),e("div",{class:"grid two",children:[e("div",{class:"card",children:[e("h3",{children:"outcomes: changed vs unchanged"}),e(Jc,{r:o})]}),e("div",{class:"card",children:[e("h3",{children:"evidence"}),e(Xc,{r:o,onOpen:s})]})]}),e("div",{class:"muted small jev-foot",children:vi(o).join(" \xB7 ")})]})}function yi({why:t}){return e("div",{class:"jev-banner warn small",role:"status",children:["Jev is configured but not being called (",t.replace(/_/g," "),"): every decision falls back to the heuristic. ",Ln[t]??""]})}function wi({range:t,tick:n,ov:s,onOpen:r}){return Pn(s)?e(j,{children:[e(zc,{range:t,tick:n,onOpen:r}),e(ii,{tick:n,onOpen:r})]}):null}var Gc={calls:0,input:0,output:0,cacheCreate5m:0,cacheCreate1h:0,cacheRead:0,thinking:0,costUsd:0,unpricedCalls:0,cacheHitRate:0,models:{}},_i={opus:[263,84,58],sonnet:[221,83,53],haiku:[142,76,36],fable:[347,77,50],other:[220,9,46]},Si=[220,9,46],Wc=["opus","sonnet","haiku","fable","mythos"];function Ei(t){let n=t.toLowerCase();for(let s of Wc)if(n.includes(s))return s==="mythos"?"fable":s;return"other"}var $i=([t,n,s])=>`hsl(${t} ${n}% ${s}%)`;function Ti(t){return $i(_i[Ei(t)]??Si)}function Ci(t){let n=new Map;for(let r of new Set(t)){let a=Ei(r),i=n.get(a);i?i.push(r):n.set(a,[r])}let s=new Map;for(let[r,a]of n){let[i,o,l]=_i[r]??Si;a.sort();let c=a.length,d=c>1?Math.min(14,40/(c-1)):0;a.forEach((u,p)=>{let f=Math.max(28,Math.min(72,l+(p-(c-1)/2)*d));s.set(u,$i([i,o,Math.round(f)]))})}return s}var Me=t=>t.replace(/^claude-/,"").replace(/-\d{8}(\[1m\])?$/,"$1"),xi=t=>String(t).padStart(2,"0"),qc=t=>`${t.getFullYear()}-${xi(t.getMonth()+1)}-${xi(t.getDate())}`;function Ai(t,n,s=Date.now()){let r=new Map(t.map(c=>[c.key,c])),a=new Date(s),i=new Date(a.getFullYear(),a.getMonth(),a.getDate()-(n-1)),o=t[0]?.key.match(/^(\d{4})-(\d{2})-(\d{2})$/);if(o){let c=new Date(Number(o[1]),Number(o[2])-1,Number(o[3]));c<i&&(i=c)}let l=[];for(let c=i,d=0;c<=a&&d<400;c=new Date(c.getFullYear(),c.getMonth(),c.getDate()+1),d+=1){let u=qc(c);l.push(r.get(u)??{key:u,totals:Gc,models:[]}),r.delete(u)}for(let c of t)r.has(c.key)&&l.push(c);return l}var Se=t=>t==null?"\u2014":lt(t),Ri=[["7d","7 days"],["30d","30 days"],["90d","90 days"],["all","all"]],pt=50,Mi=.01,Fi=t=>new Date(t).toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});function st({tone:t,children:n,title:s}){return e("span",{class:A("tag",`adj-t-${t}`),title:s,children:n})}function Dn({color:t,label:n,title:s}){return e("span",{class:"kdot-lbl",title:s,children:[e("i",{class:"kdot",style:{background:t}}),n]})}function Hs({children:t}){return e("code",{class:"adj-cmd",children:t})}function Ge({children:t,right:n}){return e("h4",{class:"adj-h",children:[t,n?e("span",{class:"right",children:n}):null]})}function Kc({rows:t}){let[n,s]=ut(),r=170,a={l:34,r:8,t:8,b:22},i=Math.max(10,s-a.l-a.r),o=r-a.t-a.b,l=t.length,c=l?i/l:i,d=c>=6?2:c>=3?1:0,u=Fa(Ia(t)),p=u[u.length-1],f=b=>a.t+o-b/p*o,[g,y]=_(null),h=Math.max(1,Math.ceil(l/Math.max(2,i/70))),m=g!==null?t[g]:void 0;return e("div",{class:"hist-chart",ref:n,children:[e("svg",{width:s,height:r,role:"img","aria-label":"decisions per day, stacked by verdict source",onMouseMove:b=>{let v=b.currentTarget.getBoundingClientRect(),k=Math.floor((b.clientX-v.left-a.l)/c);y(k>=0&&k<l?k:null)},onMouseLeave:()=>y(null),children:[u.map(b=>e("g",{children:[e("line",{x1:a.l,x2:s-a.r,y1:f(b),y2:f(b),class:"grid"}),e("text",{x:a.l-6,y:f(b)+3,class:"axis","text-anchor":"end",children:b})]})),t.map((b,v)=>v%h===0?e("text",{x:a.l+v*c,y:r-6,class:"axis",children:b.day.slice(5)}):null),t.map((b,v)=>{let k=0;return e("g",{opacity:g!==null&&g!==v?.55:1,children:Tn.map(w=>{let S=b[w];if(!S)return null;let E=f(k+S),x=f(k);return k+=S,e("rect",{x:a.l+v*c+d/2,y:E,width:Math.max(.5,c-d),height:Math.max(0,x-E-(c>=6?1:0)),fill:Tt[w],rx:c>=6?1.5:0})})})})]}),m?e("div",{class:"tip",style:{left:Math.max(0,Math.min(s-200,a.l+g*c+10)),top:4},children:[e("b",{children:m.day})," \xB7 ",m.total," decision",m.total===1?"":"s",e("div",{class:"stack",style:{gap:1,marginTop:4},children:Tn.filter(b=>m[b]).map(b=>e(Dn,{color:Tt[b],label:`${b} ${m[b]}`}))})]}):null]})}function Vc({counts:t}){let n=Math.max(1,...t),s=t.reduce((r,a)=>r+a,0);return e("div",{class:"adj-hist",role:"img","aria-label":"decisions by complexity bucket",children:t.map((r,a)=>e("div",{class:"adj-hist-col",title:`${r} decision${r===1?"":"s"} at complexity ${a}`,children:[e("span",{class:"n",children:r}),e("div",{class:"adj-hist-track",children:e("div",{class:"adj-hist-bar",style:{height:`${r/n*100}%`}})}),e("span",{class:"k",children:a}),e("span",{class:"lbl",children:An[a]}),e("span",{class:"lbl muted",children:s?`${Math.round(r/s*100)}%`:""})]}))})}function Zc({matrix:t,kept:n}){let s=In(t),r=Fs(n);return s.total?e(j,{children:[e("div",{class:"adj-scroll",children:e("table",{class:"adj-matrix",children:[e("thead",{children:e("tr",{children:[e("th",{class:"corner",children:"suggested \u2193 \xB7 ran \u2192"}),s.cols.map(a=>e("th",{class:"num",children:Me(a)}))]})}),e("tbody",{children:s.rows.map(a=>e("tr",{children:[e("th",{children:a}),s.cols.map(i=>{let o=s.cell(a,i),l=Fn(o,s.max);return e("td",{class:A("num","cell",a===i&&"diag",l>.55&&"strong"),style:l?{background:`color-mix(in srgb, var(--accent) ${Math.round(l*100)}%, transparent)`}:void 0,title:`${o} suggested ${a}, ran on ${i}`,children:o||""})})]}))})]})}),e("div",{class:"sub",children:[s.agree," of ",s.total," ran on the suggested tier (",Math.round(s.agree/s.total*100),"%) \xB7 outlined cells are agreement",r?` \xB7 not counted: ${r} (the advice named no model)`:""]})]}):e(B,{children:r?`no dispatch ran on a model the advice chose (${r})`:"no agent or plan dispatches with a known model yet"})}function Pi({reasons:t,limit:n=1/0}){let s=Ms(t,n);if(!s.length)return e("div",{class:"muted small",children:"no recorded reasons"});let r=Math.max(.01,...s.map(a=>Math.abs(a.weight)));return e("ul",{class:"adj-reasons",children:s.map(a=>{let i=Math.abs(a.weight)/r*50;return e("li",{children:[e("span",{class:"f",title:a.feature,children:Ma(a.feature)}),e("span",{class:"adj-div","aria-hidden":"true",children:e("i",{class:A(a.weight<0?"neg":"pos",a.feature==="provider"&&"prov",a.feature==="bias"&&"learn"),style:a.weight<0?{right:"50%",width:`${i}%`}:{left:"50%",width:`${i}%`}})}),e("span",{class:"w mono",children:Mn(a.weight)}),a.note?e("span",{class:"note",children:a.note}):null]})})})}function At({title:t,table:n,alpha:s,ladder:r}){let[a,i]=_(null),[o,l]=_(!1);if(!n?.entries?.length)return e("div",{class:"adj-table",children:[e(Ge,{children:t}),e("div",{class:"muted small",children:"not scored"})]});let c=Aa(n,s),d=a??new Set([c.choice,...c.runnerUp?[c.runnerUp]:[]]),u=g=>d.has(g),p=c.entries.filter(g=>!g.chosen&&!g.runnerUp&&g.score<Mi).length,f=g=>{let y=new Set(d);y.has(g)?y.delete(g):y.add(g),i(y)};return e("div",{class:"adj-table",children:[e(Ge,{right:e("span",{class:"muted small",children:["confidence ",Math.round(c.confidence*100),"%",c.margin!==null?` \xB7 margin ${Math.round(c.margin*100)} pts`:""]}),children:t}),e("div",{class:"adj-verdict-line",children:[e("b",{class:"adj-choice",children:c.choice}),r?.(c.choice)?e("span",{class:"muted small",children:[" \u2192 ",r(c.choice)]}):null,c.runnerUp?e("span",{class:"muted small",children:[" \xB7 runner-up ",c.runnerUp]}):null,c.roundedUp?e(st,{tone:"warn",title:"confidence was below weights.lowConfidence, so the tier was rounded up one step",children:"rounded up"}):null,s>0?e("span",{class:"muted small",children:[" ","\xB7 provider weight \u03B1 ",s.toFixed(2)," \xB7 ",Math.round(c.providerShare*100),"% of the winning score"]}):e("span",{class:"muted small",children:" \xB7 heuristic only"})]}),e("div",{class:"adj-entries",children:[(o?c.entries:c.entries.filter(g=>g.chosen||g.runnerUp||g.score>=Mi)).map(g=>e("div",{class:A("adj-entry",g.chosen&&"chosen",g.runnerUp&&"runner"),children:[e("button",{type:"button",class:"adj-entry-row","aria-expanded":u(g.option),onClick:()=>f(g.option),title:"show the reasons for this option",children:[e("span",{class:"opt",children:[g.chosen?e("span",{class:"mark",title:"chosen",children:"\u2713"}):g.runnerUp?e("span",{class:"mark ru",children:"2"}):e("span",{class:"mark none"}),g.option]}),e("span",{class:"adj-sbar","aria-hidden":"true",children:Rs.map(y=>g.parts[y]>5e-4?e("i",{style:{width:`${g.parts[y]*100}%`,background:Cn[y]},title:`${y} ${Math.round(g.parts[y]*100)}%`}):null)}),e("span",{class:"pc mono",children:[Math.round(g.score*100),"%"]})]}),u(g.option)?e(Pi,{reasons:g.reasons,limit:8}):null]})),p?e("button",{type:"button",class:"adj-link small adj-more-opts",onClick:()=>l(!o),children:o?"hide options under 1%":`+ ${p} more option${p===1?"":"s"} under 1%`}):null]})]})}function Di(){return e("div",{class:"row tight adj-legend",children:[Rs.map(t=>e(Dn,{color:Cn[t],label:t,title:Ca[t]})),e("span",{class:"muted small",children:"\xB7 \u2713 chosen \xB7 2 runner-up \xB7 click an option for its reasons"})]})}function Oi({value:t,reasons:n,alpha:s}){let r=Ra(t,n),a=i=>`${Math.max(0,Math.min(4,i))/4*100}%`;return e("div",{children:[e("div",{class:"adj-verdict-line",children:[e("b",{class:"adj-choice",children:t.toFixed(2)}),e("span",{class:"muted small",children:[" ","/ 4 \xB7 ",Rn(t),r.provider?` \xB7 heuristic ${r.heuristic.toFixed(2)}, provider ${Mn(r.provider)}${s?` (\u03B1 ${s.toFixed(2)})`:""}`:" \xB7 heuristic only"]})]}),e("div",{class:"adj-scale",role:"img","aria-label":`complexity ${t.toFixed(2)} of 4`,children:[An.map((i,o)=>e("span",{class:A(Math.round(t)===o&&"on"),children:[o," ",i]})),r.provider?e("i",{class:"mk heur",style:{left:a(r.heuristic)},title:`heuristic ${r.heuristic.toFixed(2)}`}):null,e("i",{class:"mk",style:{left:a(t)},title:`final ${t.toFixed(2)}`})]}),r.providerNote?e("div",{class:"muted small",children:["provider: ",r.providerNote]}):null,e(Pi,{reasons:r.terms,limit:12})]})}function Yc({id:t,onClose:n}){let s=X(()=>O("/api/adjudicator/decision",{id:t}),[t]),r=ee(null);return J(()=>{let a=document.activeElement;r.current?.focus();let i=o=>{o.key==="Escape"&&n()};return window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i),a?.focus?.()}},[t]),e(j,{children:[e("div",{class:"adj-backdrop",onClick:n}),e("aside",{class:"adj-drawer",ref:r,tabIndex:-1,role:"dialog","aria-modal":"true","aria-label":`decision ${t}`,children:[e("div",{class:"adj-drawer-head",children:[e("b",{children:["decision #",t]}),s.data?e(j,{children:[e(P,{children:s.data.row.surface}),e("span",{class:"muted small",title:new Date(s.data.row.ts).toISOString(),children:[Fi(s.data.row.ts)," \xB7 ",te(s.data.row.ts)]})]}):null,e("span",{class:"spacer"}),e("button",{type:"button",class:"ghost sm",onClick:n,"aria-label":"close",children:"\u2715 close"})]}),e("div",{class:"adj-drawer-body",children:s.error?e(W,{error:s.error}):s.data?e(Qc,{row:s.data.row,scores:s.data.scores}):e(N,{})})]})]})}function Qc({row:t,scores:n}){let s=js(t.action),r=Ls[t.outcome]??{tone:"muted",help:""},a=n?.alpha??{},i=Object.entries(n?.bias??{}).filter(([,d])=>d),o=Ua(n?.features),l=Ha(n?.features),c=d=>t.modelFinal&&t.tier===d?Me(t.modelFinal):null;return e(j,{children:[e("section",{children:[e(Ge,{right:t.inputChars?e("span",{class:"muted small",children:[q(t.inputChars)," chars in"]}):null,children:"input"}),t.inputHead?e("blockquote",{class:"adj-head",children:[t.inputHead,t.inputChars&&t.inputChars>t.inputHead.length?"\u2026":""]}):e("div",{class:"muted small",children:"not stored (privacy.storeHead is off): only a hash is kept"}),e("div",{class:"muted small",children:["redacted, at most 80 characters are ever stored \xB7 hash ",t.inputHash.slice(0,12)]})]}),e("section",{class:"adj-summary",children:[e("div",{children:[e("span",{class:"k",children:"complexity"}),e("b",{children:typeof t.complexity=="number"?t.complexity.toFixed(1):"\u2014"}),e("span",{class:"s",children:Rn(t.complexity)})]}),e("div",{children:[e("span",{class:"k",children:"model tier"}),e("b",{children:t.tier??"\u2014"}),e("span",{class:"s",children:["effort ",t.effort??"\u2014"]})]}),e("div",{children:[e("span",{class:"k",children:"tool"}),e("b",{children:t.tool??"\u2014"})]}),e("div",{children:[e("span",{class:"k",children:"role"}),e("b",{children:t.role??"\u2014"})]}),e("div",{children:[e("span",{class:"k",children:"confidence"}),e("b",{children:typeof t.confidence=="number"?`${Math.round(t.confidence*100)}%`:"\u2014"}),e("span",{class:"s",children:"tier"})]})]}),e("section",{children:[e(Ge,{children:"how it decided"}),e("div",{class:"row tight",style:{marginBottom:6},children:[e(Dn,{color:Tt[t.source??"heuristic"]??"#94a3b8",label:t.source??"heuristic",title:Xt[t.source??"heuristic"]}),e("span",{class:"muted small",children:Xt[t.source??"heuristic"]??""})]}),e(Ae,{rows:[["provider",e(j,{children:[t.provider??"heuristic",t.providerModel?e("span",{class:"muted",children:[" \xB7 ",t.providerModel]}):null]})],["provider status",e(st,{tone:Is(t.providerStatus),children:t.providerStatus??"n/a"})],["provider weight \u03B1",Object.keys(a).length?e("span",{class:"row tight",children:["complexity","tier","tool","role"].map(d=>e("span",{class:"adj-alpha",title:`${d}: ${(a[d]??0).toFixed(2)}`,children:[d,e("span",{class:"scorebar",children:e("i",{style:{width:`${(a[d]??0)*100}%`,background:Cn.provider}})}),e("span",{class:"mono small",children:(a[d]??0).toFixed(2)})]}))}):e("span",{class:"muted",children:"0 everywhere: the heuristic decided alone"})],["learned bias",i.length?e("span",{class:"row tight",children:i.map(([d,u])=>e("span",{class:"tag mono",children:[d," ",Mn(u)]}))}):e("span",{class:"muted",children:"none applied"})]]})]}),n?e(j,{children:[e("section",{children:[e(Ge,{children:"complexity"}),e(Oi,{value:n.complexity,reasons:n.complexityReasons??[],alpha:a.complexity})]}),e("section",{children:[e(Di,{}),e(At,{title:"model tier",table:n.tier,alpha:a.tier??0,ladder:c}),e(At,{title:"tool",table:n.tool,alpha:a.tool??0}),e(At,{title:"agent role",table:n.role,alpha:a.role??0})]})]}):e("section",{children:e("div",{class:"muted small",children:"this row has no score tables (older scorer or a cache hit stored without them)"})}),e("section",{children:[e(Ge,{children:"cost and speed"}),e("div",{class:"adj-summary small4",children:[e("div",{children:[e("span",{class:"k",children:"latency"}),e("b",{children:ue(t.latencyMs)}),e("span",{class:"s",children:"end to end"})]}),e("div",{children:[e("span",{class:"k",children:"provider"}),e("b",{children:ue(t.providerLatencyMs)}),e("span",{class:"s",children:"round trip"})]}),e("div",{children:[e("span",{class:"k",children:"tokens"}),e("b",{children:t.tokensIn!=null?`${q(t.tokensIn)} / ${q(t.tokensOut??0)}`:"\u2014"}),e("span",{class:"s",children:"in / out"})]}),e("div",{children:[e("span",{class:"k",children:"cost"}),e("b",{children:t.costUsd===null||t.costUsd===void 0?t.tokensIn!=null?"unpriced":"$0":Se(t.costUsd)}),e("span",{class:"s",children:"adjudicator spend"})]})]})]}),e("section",{children:[e(Ge,{children:"what happened"}),e(Ae,{rows:[["advice",e(j,{children:[e(st,{tone:s.tone,children:s.label})," ",e("span",{class:"muted small",children:s.help})]})],["model",e("span",{children:[t.modelRequested?e(j,{children:["requested ",e("b",{children:Me(t.modelRequested)})," \xB7"," "]}):null,t.modelFinal?e(j,{children:["set ",e("b",{children:Me(t.modelFinal)})," \xB7"," "]}):null,"ran on ",e("b",{children:t.actualModel?Me(t.actualModel):"\u2014"})]})],["baseline",t.baselineModel?Me(t.baselineModel):e("span",{class:"muted",children:"\u2014"})],["actual usage",t.actualTokens!=null?`${q(t.actualTokens)} tokens \xB7 ${Se(t.actualCostUsd)}`:e("span",{class:"muted",children:"\u2014"})],["outcome",e(j,{children:[e(st,{tone:r.tone,children:t.outcome})," ",e("span",{class:"muted small",children:[r.help,t.outcomeSource?` \xB7 via ${t.outcomeSource}`:"",t.outcomeTs?` \xB7 ${te(t.outcomeTs)}`:"",t.final?" \xB7 final":" \xB7 still open"]})]})]]})]}),e("section",{children:[e(Ge,{children:"savings for this decision"}),e("div",{class:"adj-savings-row",children:[e("div",{children:[e("span",{class:"k",children:"baseline cost"}),e("b",{children:Se(t.baselineCostUsd)})]}),e("span",{class:"op",children:"\u2212"}),e("div",{children:[e("span",{class:"k",children:"actual cost"}),e("b",{children:Se(t.actualCostUsd)})]}),e("span",{class:"op",children:"="}),e("div",{children:[e("span",{class:"k",children:"saved"}),e("b",{class:A(t.savingsUsd!=null&&(t.savingsUsd>0?"ok":t.savingsUsd<0?"bad":"")),children:Se(t.savingsUsd)})]})]}),e("div",{class:"muted small",children:Oa(t)})]}),n?.features?e("section",{children:[e(Ge,{children:"features the heuristic saw"}),o.length?e("div",{class:"adj-intents",children:o.map(([d,u])=>e("span",{class:"adj-alpha",title:`intent ${d}: ${u.toFixed(2)}`,children:[d,e("span",{class:"scorebar",children:e("i",{style:{width:`${Math.min(1,u)*100}%`}})}),e("span",{class:"mono small",children:u.toFixed(2)})]}))}):e("div",{class:"muted small",children:"no intent detected"}),e("div",{class:"row tight",style:{marginTop:6},children:l.map(([d,u])=>e("span",{class:"tag",children:[d," ",e("b",{children:u})]}))})]}):null,e("section",{children:[e(Ge,{children:"ids"}),e(Ae,{rows:[["session",t.sessionId?e("span",{class:"mono",children:t.sessionId.slice(0,8)}):"\u2014"],["agent",t.agentId??"\u2014"],["swarm",t.runId?e("a",{href:"#",onClick:d=>{d.preventDefault(),U("swarm",{run:t.runId??void 0})},children:[t.runId,t.taskId?` \xB7 task #${t.taskId}`:""]}):"\u2014"],["parent",t.parentId?`#${t.parentId}`:"\u2014"],["scorer",t.version??"\u2014"]]})]})]})}function ed({ov:t,since:n,tick:s,selected:r,onOpen:a}){let[i,o]=_({}),[l,c]=_(0);J(()=>c(0),[n,i.surface,i.provider,i.outcome]);let d=X(()=>O("/api/adjudicator/decisions",Pa({...i,since:n},pt,l)),[n,i.surface,i.provider,i.outcome,l,s]),u=(f,g,y)=>e("label",{class:"adj-filter",children:[e("span",{class:"muted small",children:g}),e("select",{value:i[f]??"",onChange:h=>o({...i,[f]:h.target.value||void 0}),children:[e("option",{value:"",children:"all"}),y.map(h=>e("option",{value:h,children:h}))]})]}),p=d.data;return e("div",{class:"card adj-log",children:[e("h3",{children:["call log",e("span",{class:"right muted small",children:p?Da(p.offset,p.rows.length,p.total):""})]}),e("div",{class:"row adj-filters",children:[u("surface","surface",t.filters.surfaces.filter(f=>f!=="test")),u("provider","provider",t.filters.providers),u("outcome","outcome",t.filters.outcomes),i.surface||i.provider||i.outcome?e("button",{type:"button",class:"ghost sm",onClick:()=>o({}),children:"clear"}):null,e("span",{class:"spacer"}),d.loading?e(N,{}):null]}),d.error?e(W,{error:d.error}):p?p.rows.length?e("div",{class:"adj-scroll",children:e("table",{class:"adj-calls",children:[e("thead",{children:e("tr",{children:[e("th",{children:"when"}),e("th",{children:"surface"}),e("th",{children:"input"}),e("th",{class:"num",children:"cx"}),e("th",{children:"tier"}),e("th",{children:"tool"}),e("th",{children:"role"}),e("th",{children:"source"}),e("th",{class:"num",children:"latency"}),e("th",{class:"num",children:"cost"}),e("th",{children:"advice"}),e("th",{children:"outcome"}),e("th",{class:"num",children:"saved"})]})}),e("tbody",{children:p.rows.map(f=>e(td,{r:f,selected:r===f.id,onOpen:a}))})]})}):e(B,{children:p.total||i.surface||i.provider||i.outcome?"no decisions match these filters":"no decisions in this range"}):e(N,{}),p&&p.total>pt?e("div",{class:"row adj-pager",children:[e("button",{type:"button",class:"sm",disabled:l===0,onClick:()=>c(Math.max(0,l-pt)),children:"\u2190 newer"}),e("span",{class:"muted small",children:["page ",Math.floor(l/pt)+1," of ",Math.ceil(p.total/pt)]}),e("button",{type:"button",class:"sm",disabled:l+pt>=p.total,onClick:()=>c(l+pt),children:"older \u2192"})]}):null]})}function td({r:t,selected:n,onOpen:s}){let r=js(t.action),a=t.source??"heuristic",i=typeof t.complexity=="number"?t.complexity:null;return e("tr",{class:A("click",n&&"sel"),tabIndex:0,onClick:()=>s(t.id),onKeyDown:o=>{(o.key==="Enter"||o.key===" ")&&(o.preventDefault(),s(t.id))},"aria-label":`decision ${t.id}`,children:[e("td",{class:"nowrap muted",title:new Date(t.ts).toISOString(),children:Fi(t.ts)}),e("td",{children:t.surface}),e("td",{class:"adj-headcell",title:t.inputHead??"",children:t.inputHead??e("span",{class:"muted",children:"\u2014"})}),e("td",{class:"num nowrap",title:Rn(i),children:i!==null?e(j,{children:[e("span",{class:"adj-cx",children:e("i",{style:{width:`${i/4*100}%`}})}),i.toFixed(1)]}):"\u2014"}),e("td",{children:e("b",{children:t.tier??"\u2014"})}),e("td",{class:"mono small",children:t.tool??"\u2014"}),e("td",{children:t.role??"\u2014"}),e("td",{class:"nowrap",title:`${Xt[a]??""}${t.provider?` \xB7 ${t.provider}`:""} \xB7 ${t.providerStatus??"n/a"}`,children:[e("i",{class:"kdot",style:{background:Tt[a]??"#94a3b8"}}),a,t.providerStatus&&t.providerStatus!=="ok"&&t.providerStatus!=="n/a"?e("span",{class:A("small",`adj-t-${Is(t.providerStatus)}`),children:[" ",t.providerStatus]}):null]}),e("td",{class:"num nowrap",children:ue(t.latencyMs)}),e("td",{class:"num nowrap",children:t.costUsd!=null?Se(t.costUsd):e("span",{class:"muted",children:"\u2014"})}),e("td",{children:e("span",{class:A("small",`adj-t-${r.tone}`),title:r.help,children:r.label})}),e("td",{children:e("span",{class:A("small",`adj-t-${ja(t.outcome)}`),children:t.outcome})}),e("td",{class:A("num nowrap",t.savingsUsd!=null&&t.savingsUsd>0&&"ok",t.savingsUsd!=null&&t.savingsUsd<0&&"bad"),children:t.savingsUsd!=null?Se(t.savingsUsd):e("span",{class:"muted",children:"\u2014"})})]})}function nd(t){return t?[...(t.split(":")[0]??"").matchAll(/adjudicator\.([A-Za-z0-9_]+)/g)].map(s=>s[1]):[]}function sd({ov:t}){let n=t.provider,s=t.health.find(i=>i.configured),r=t.health.filter(i=>!i.configured),a=nd(t.projectIgnored);return e("div",{class:"card",children:[e("h3",{children:["provider",e("span",{class:"right",children:[t.projectIgnored?e(st,{tone:"warn",title:t.projectIgnored,children:["project config ignored: ",a.length?a.join(", "):"some keys"]}):null," ",e(st,{tone:t.mode==="apply"?"accent":"muted",title:t.mode==="apply"?"sets the Agent model within the configured floor and ceiling":"suggests only; Claude decides",children:[t.mode," mode"]})]})]}),e(Ae,{rows:[["configured",e(j,{children:[e("b",{children:n.configured}),n.preset?e("span",{class:"muted",children:[" \xB7 ",n.preset]}):null,n.model?e("span",{class:"muted",children:[" \xB7 ",n.model]}):null]})],["in use",n.effective===n.configured?e("span",{class:"ok",children:n.effective}):e("span",{children:[e("b",{class:"warn",children:n.effective}),e("span",{class:"muted small",children:[" ","\xB7 ",n.degraded?Ln[n.degraded]??n.degraded:""]})]})],...n.detail&&n.effective!==n.configured?[["why",e("span",{class:"small",children:n.detail})]]:[],["where",n.configuredRemote?e("span",{children:["remote",n.baseUrl?e("span",{class:"muted",children:[" \xB7 ",n.baseUrl]}):null]}):"on this machine"],["key",n.configuredRemote?e("span",{children:[t.keySource==="none"?e("span",{class:"warn",children:"none"}):`from ${t.keySource}`,t.keyFileRefused?e("span",{class:"bad small",children:" \xB7 key file refused (permissions)"}):null,e("span",{class:"muted small",children:[" ","\xB7 consent ",t.consent?"given":"not given",t.origin?` for ${t.origin}`:""]})]}):e("span",{class:"muted",children:"not needed"})],["apply effective",t.apply.checked?e("span",{children:[t.apply.effective," of ",t.apply.checked,t.apply.ineffective?e("span",{class:"warn small",children:[" \xB7 ",t.apply.ineffective," ran on another model"]}):null]}):e("span",{class:"muted",children:"no applied dispatches checked yet"})]]}),s?e(ji,{h:s,now:t.now}):n.configured==="heuristic"?e("div",{class:"muted small adj-health",children:"the heuristic runs locally: no breaker, no spend"}):null,r.length?e("details",{class:"adj-more",children:[e("summary",{class:"muted small",children:[r.length," other provider",r.length===1?"":"s"," with history"]}),r.map(i=>e(ji,{h:i,now:t.now}))]}):null]})}function ji({h:t,now:n}){let s=jn(t.state),r=t.dailyCapUsd,a=r?Math.min(1,t.spendTodayUsd/r):0;return e("div",{class:"adj-health",children:[e("div",{class:"row tight",children:[e("b",{children:t.provider}),e(st,{tone:s.tone,title:s.help,children:s.label}),t.failures?e("span",{class:"muted small",children:[t.failures," recent failure",t.failures===1?"":"s"]}):null,e("span",{class:"spacer"}),t.retryAt&&t.retryAt>n?e("span",{class:"warn small",children:["retry in ",ue(t.retryAt-n)]}):null]}),e("div",{class:"adj-health-grid",children:[e("span",{class:"muted",children:"latency"}),e("span",{children:[t.latency.n?`p50 ${ue(t.latency.p50)} \xB7 p95 ${ue(t.latency.p95)}`:"no calls",t.latency.n?e("span",{class:"muted small",children:[" \xB7 last ",t.latency.n]}):null]}),e("span",{class:"muted",children:"last ok"}),e("span",{children:t.lastOkAt?te(t.lastOkAt):"\u2014"}),e("span",{class:"muted",children:"last error"}),e("span",{children:[t.lastErrorClass?e("span",{class:"bad",children:t.lastErrorClass}):"\u2014",t.lastErrorAt?e("span",{class:"muted small",children:[" \xB7 ",te(t.lastErrorAt)]}):null]}),e("span",{class:"muted",children:"spend today"}),e("span",{children:r===null?e("span",{class:"muted",children:"local \xB7 no cap"}):e(j,{children:[Se(t.spendTodayUsd)," of ",Se(r),e("span",{class:"scorebar",style:{maxWidth:160},children:e("i",{class:A(a>=.9?"bad":a>=.6?"warn":"ok"),style:{width:`${a*100}%`}})})]})})]})]})}function rd({s:t}){let n=Object.entries(t.tokensPerSuccessByTier).filter(([,i])=>i?.tasks),s=Math.max(1,...n.map(([,i])=>i?.tokensPerTask??0)),r=Na(t),a=[["realised",t.realisedUsd,`${t.creditedRows} followed/applied dispatches${t.redoPenaltyUsd?` \xB7 ${Se(t.redoPenaltyUsd)} redo penalty`:""}`,"ok"],["potential",t.potentialUsd,`${t.potentialRows} main-session prompts \xB7 not in net`,"muted"],["spend",-t.spendUsd,"the adjudicator's own provider calls","bad"],["net",t.netUsd,"realised \u2212 spend",t.netUsd>=0?"ok":"bad"]];return e("div",{class:"card",children:[e("h3",{children:["savings",r?e("span",{class:"right warn small",title:r.help,children:r.label}):null]}),e("div",{class:"adj-figs",children:a.map(([i,o,l,c])=>e("div",{children:[e("div",{class:"sub",children:i}),e("div",{class:A("big",c!=="muted"&&o!==0&&c),children:Se(i==="spend"?t.spendUsd:o)}),e("div",{class:"sub",children:l})]}))}),e("h4",{class:"adj-h",children:"tokens per successful task, by tier"}),n.length?e("table",{class:"adj-tiers",children:e("tbody",{children:n.map(([i,o])=>e("tr",{children:[e("td",{children:i}),e("td",{class:"num",children:[o.tasks," task",o.tasks===1?"":"s"]}),e("td",{style:{width:"40%"},children:e("span",{class:"bar",style:{width:`${Math.max(2,(o.tokensPerTask??0)/s*100)}%`}})}),e("td",{class:"num",children:o.tokensPerTask!=null?q(o.tokensPerTask):"\u2014"}),e("td",{class:"num muted",children:Se(o.costUsd)})]}))})}):e("div",{class:"muted small",children:"no successful agent tasks with usage yet"}),e("div",{class:"muted small",style:{marginTop:6},children:"smaller tiers can need more turns: if haiku needs far more tokens per task than sonnet, the savings above overstate."})]})}function ad({list:t}){return e("div",{class:"card adj-assume",id:"adj-assumptions",children:[e("h3",{children:"how savings are computed"}),e("ul",{class:"reasons",children:t.map(n=>e("li",{children:n}))})]})}function Li({ov:t}){let[n,s]=_(""),[r,a]=_(!1),[i,o]=_(!1),[l,c]=_(),[d,u]=_(),p=!!t?.enabled&&t.provider.configured!=="heuristic",f=async()=>{if(n.trim()){o(!0),c(void 0);try{u(await he("/api/adjudicator/test",{text:n,useProvider:p&&r}))}catch(y){c(y.message)}finally{o(!1)}}},g=d?.verdict;return e("div",{class:"card adj-try",children:[e("h3",{children:["try it",e("span",{class:"right muted small",children:"nothing is stored \xB7 the text is not sent back"})]}),e("textarea",{rows:4,maxLength:2e4,placeholder:"Paste a prompt or task, e.g. \u201Crefactor the session store to batch writes and add tests\u201D",value:n,onInput:y=>s(y.target.value),onKeyDown:y=>{y.key==="Enter"&&(y.metaKey||y.ctrlKey)&&f()}}),e("div",{class:"row",style:{marginTop:6},children:[e("label",{class:A("row tight small",!p&&"muted"),title:p?"":"needs the adjudicator enabled with a provider configured",children:[e("input",{type:"checkbox",checked:p&&r,disabled:!p,onChange:y=>a(y.target.checked)}),"use the provider",t&&p?` (${t.provider.configured})`:""]}),p&&r&&t?.provider.configuredRemote?e("span",{class:"warn small",children:["sends redacted text to ",t.provider.baseUrl??"the provider"," and counts toward today's cap"]}):null,e("span",{class:"spacer"}),e("button",{type:"button",class:"primary",disabled:i||!n.trim(),onClick:()=>{f()},children:i?"scoring\u2026":"score"})]}),l?e(W,{error:l}):null,d&&g?e("div",{class:"adj-try-out",children:[e("div",{class:"row tight",children:[e(st,{tone:d.usedProvider?"accent":"muted",children:g.source}),e("span",{class:"muted small",children:[La(d.reason)," \xB7 ",ue(g.latencyMs),g.providerStatus&&g.providerStatus!=="n/a"?` \xB7 provider ${g.providerStatus}`:"",d.providerModel?` \xB7 ${d.providerModel}`:"",g.usage?.costUsd?` \xB7 ${Se(g.usage.costUsd)}`:""]})]}),d.advice?e("blockquote",{class:"adj-head",children:d.advice}):null,e(Oi,{value:g.complexity,reasons:g.complexityReasons??[],alpha:g.alpha?.complexity}),e(Di,{}),e(At,{title:"model tier",table:g.tier,alpha:g.alpha?.tier??0}),e(At,{title:"tool",table:g.tool,alpha:g.alpha?.tool??0}),e(At,{title:"agent role",table:g.role,alpha:g.alpha?.role??0})]}):null]})}function Ii(){let t=X(()=>O("/api/adjudicator/eval"),[]),n=t.data?.report??null,s=Ba(n),r=Ja(n),a=r.find(([i])=>i==="verdict");return e("div",{class:"card",children:[e("h3",{children:"last eval"}),t.error?e(W,{error:t.error}):t.data?n?e(j,{children:[a?e("div",{class:"adj-verdict-line",children:e("b",{children:a[1]})}):null,e(Ae,{rows:r.filter(([i])=>i!=="verdict").map(([i,o])=>[i,o])}),s?e("div",{class:"adj-scroll",style:{marginTop:8},children:e("table",{class:"adj-eval",children:[e("thead",{children:e("tr",{children:s.columns.map(i=>e("th",{class:A(i!==s.columns[0]&&"num"),children:i}))})}),e("tbody",{children:s.rows.map(i=>e("tr",{children:s.columns.map((o,l)=>e("td",{class:A(l>0&&"num","nowrap"),children:i[o]??"\u2014"}))}))})]})}):null]}):e(B,{children:["no eval yet: run ",e(Hs,{children:"eminiar adjudicator eval"})," to compare the heuristic and your provider on the labelled set",t.data.error?e("div",{class:"bad small",children:t.data.error}):null]}):e(N,{})]})}function id(){return e("div",{class:"card adj-intro",children:[e("h3",{children:"adjudicator is off"}),e("p",{children:"The adjudicator scores each request's complexity and suggests the eminiar tool, the Claude model size (haiku, sonnet, opus) and the swarm role that fit it, so small work goes to small models and large work gets the right help. It is optional and off by default."}),e("ul",{class:"reasons",children:[e("li",{children:[e("b",{children:"local by default"}),": the heuristic runs on this machine; nothing leaves it."]}),e("li",{children:[e("b",{children:"remote providers only with consent and a key"}),": text is redacted and capped (privacy.maxChars) before it is sent; keys live in ",e(Hs,{children:"~/.eminiar"}),", never in config."]}),e("li",{children:[e("b",{children:"what is stored"}),": a hash and at most 80 redacted characters per decision (privacy.storeHead)."]}),e("li",{children:[e("b",{children:"advise vs apply"}),": advise only suggests; apply sets the Agent model within a floor and ceiling."]})]}),e("div",{class:"row",style:{marginTop:8},children:[e("span",{children:"Turn it on with"}),e(Hs,{children:"eminiar adjudicator enable"}),e("span",{class:"muted small",children:"then /mcp reconnect. This page updates without restarting the server."})]})]})}function Ni({params:t}){let n=Ri.find(([h])=>h===t.range)?.[0]??"30d",s=t.id&&/^\d+$/.test(t.id)?Number(t.id):null,[r,a]=_(0),[i,o]=_(!1),l=X(()=>O("/api/adjudicator",{since:n}),[n,r]),c=X(()=>O("/api/adjudicator/savings",{since:n}),[n,r]),d=h=>U("adjudicator",{range:(h.range??n)==="30d"?void 0:h.range??n,id:h.id===void 0?s?String(s):void 0:h.id?String(h.id):void 0});if(l.error)return e("div",{class:"page",children:e(W,{error:l.error})});let u=l.data;if(!u)return e("div",{class:"page",children:e(N,{})});let p=u.summary,f=p.total>0,g=Object.entries(p.byProviderStatus).filter(([h,m])=>m&&h!=="ok"&&h!=="n/a"),y=[["decisions",q(p.total),Object.entries(p.bySurface).filter(([,h])=>h).sort((h,m)=>m[1]-h[1]).map(([h,m])=>`${h} ${m}`).join(" \xB7 ")||"none in range"],["advice followed",ze(p.rates.follow),[`apply ${ze(p.rates.apply)} \xB7 respected ${ze(p.rates.respect)}`,Fs(p.keptModel)].filter(Boolean).join(" \xB7 "),"followed \xF7 (advised + followed + ignored), leaving out advised dispatches whose advice named no model (a kept pin, CLAUDE_CODE_SUBAGENT_MODEL_FORCE, a fork); apply = applied \xF7 (applied + respected)"],["fallback rate",ze(u.fallbackRate),g.length?g.map(([h,m])=>`${h} ${m}`).join(" \xB7 "):"no provider errors","decisions where the provider failed or was skipped and the heuristic answered"],["provider latency",p.providerLatency.n?`${ue(p.providerLatency.p50)}`:"\u2014",p.providerLatency.n?`p95 ${ue(p.providerLatency.p95)} \xB7 end to end p50 ${ue(p.latency.p50)}`:`end to end p50 ${ue(p.latency.p50)} \xB7 p95 ${ue(p.latency.p95)}`,"p50 of the provider round trip; end to end includes the heuristic and blending"],["adjudicator spend",Se(p.costUsd),`${u.provider.configuredRemote?"remote provider":"local: free"} \xB7 in range`],["net savings",Se(c.data?c.data.netUsd:p.netUsd),e(j,{children:["saved ",Se(c.data?c.data.realisedUsd:p.savingsUsd)," \u2212 spend ",Se(p.costUsd)," \xB7"," ",e("button",{type:"button",class:"adj-link","aria-expanded":i,onClick:()=>o(!i),children:"how is this computed?"})]})]];return e("div",{class:"page adj-page",children:[e("div",{class:"row",style:{marginBottom:10},children:[e(Re,{tabs:Ri,value:n,onChange:h=>d({range:h})}),e("span",{class:"spacer"}),e("span",{class:"muted small",children:[u.enabled?e(j,{children:[e("i",{class:"dot fresh"}),"on \xB7 ",u.mode," \xB7 ",u.provider.effective]}):e(j,{children:[e("i",{class:"dot"}),"off"]}),"reconcile"in u&&u.reconcile&&"error"in u.reconcile?e("span",{class:"warn",children:[" \xB7 reconcile failed: ",u.reconcile.error]}):null,u.chartsCut?e("span",{class:"warn",children:" \xB7 charts drawn from the newest 20k rows"}):null]}),e("button",{type:"button",class:"ghost sm",onClick:()=>a(h=>h+1),disabled:l.loading,children:l.loading?"\u2026":"\u21BB refresh"})]}),u.enabled?null:e(id,{}),!u.enabled&&f?e("div",{class:"muted small",style:{margin:"-4px 0 10px"},children:"showing decisions recorded while it was on"}):null,u.enabled||f?e(j,{children:[e("div",{class:"grid adj-kpis",children:y.map(([h,m,b,v])=>e("div",{class:"card",title:v,children:[e("h3",{children:h}),e("div",{class:"big",children:m}),e("div",{class:"sub",children:b})]}))}),i?e(ad,{list:c.data?.assumptions??[]}):null,Pn(u)?e(wi,{range:n,tick:r,ov:u,onOpen:h=>d({id:h})}):null,e("div",{class:"grid wide",children:[e("div",{class:"card",children:[e("h3",{children:["decisions per day",e("span",{class:"right usage-legend",children:Tn.map(h=>e(Dn,{color:Tt[h],label:h,title:Xt[h]}))})]}),u.charts.perDay.length?e(Kc,{rows:u.charts.perDay}):e(B,{children:u.enabled?"no decisions yet: they appear as you prompt and dispatch agents":"no decisions in this range"}),e("div",{class:"muted small",children:"UTC days"})]}),e(sd,{ov:u})]}),e("div",{class:"grid two",children:[e("div",{class:"card",children:[e("h3",{children:["complexity",e("span",{class:"right muted small",children:"0 trivial \u2192 4 very complex"})]}),f?e(Vc,{counts:u.charts.complexity}):e(B,{children:"no decisions yet"})]}),e("div",{class:"card",children:[e("h3",{children:"suggested tier \xD7 model that ran"}),c.error?e(W,{error:c.error}):c.data?e(Zc,{matrix:c.data.matrix,kept:c.data.keptModel}):e(N,{})]})]}),e(ed,{ov:u,since:n,tick:r,selected:s,onOpen:h=>d({id:h})}),e("div",{class:"grid two",children:[c.error?e("div",{class:"card",children:e(W,{error:c.error})}):c.data?e(rd,{s:c.data}):e("div",{class:"card",children:e(N,{})}),e(Li,{ov:u})]}),e("div",{class:"grid",children:e(Ii,{})})]}):e("div",{class:"grid two",children:[e(Li,{ov:u}),e(Ii,{})]}),s!==null?e(Yc,{id:s,onClose:()=>d({id:null})}):null]})}function Bs(t,n){var s,r=1;t==null&&(t=0),n==null&&(n=0);function a(){var i,o=s.length,l,c=0,d=0;for(i=0;i<o;++i)l=s[i],c+=l.x,d+=l.y;for(c=(c/o-t)*r,d=(d/o-n)*r,i=0;i<o;++i)l=s[i],l.x-=c,l.y-=d}return a.initialize=function(i){s=i},a.x=function(i){return arguments.length?(t=+i,a):t},a.y=function(i){return arguments.length?(n=+i,a):n},a.strength=function(i){return arguments.length?(r=+i,a):r},a}function Ui(t){let n=+this._x.call(null,t),s=+this._y.call(null,t);return Hi(this.cover(n,s),n,s,t)}function Hi(t,n,s,r){if(isNaN(n)||isNaN(s))return t;var a,i=t._root,o={data:r},l=t._x0,c=t._y0,d=t._x1,u=t._y1,p,f,g,y,h,m,b,v;if(!i)return t._root=o,t;for(;i.length;)if((h=n>=(p=(l+d)/2))?l=p:d=p,(m=s>=(f=(c+u)/2))?c=f:u=f,a=i,!(i=i[b=m<<1|h]))return a[b]=o,t;if(g=+t._x.call(null,i.data),y=+t._y.call(null,i.data),n===g&&s===y)return o.next=i,a?a[b]=o:t._root=o,t;do a=a?a[b]=new Array(4):t._root=new Array(4),(h=n>=(p=(l+d)/2))?l=p:d=p,(m=s>=(f=(c+u)/2))?c=f:u=f;while((b=m<<1|h)===(v=(y>=f)<<1|g>=p));return a[v]=i,a[b]=o,t}function Bi(t){var n,s,r=t.length,a,i,o=new Array(r),l=new Array(r),c=1/0,d=1/0,u=-1/0,p=-1/0;for(s=0;s<r;++s)isNaN(a=+this._x.call(null,n=t[s]))||isNaN(i=+this._y.call(null,n))||(o[s]=a,l[s]=i,a<c&&(c=a),a>u&&(u=a),i<d&&(d=i),i>p&&(p=i));if(c>u||d>p)return this;for(this.cover(c,d).cover(u,p),s=0;s<r;++s)Hi(this,o[s],l[s],t[s]);return this}function Ji(t,n){if(isNaN(t=+t)||isNaN(n=+n))return this;var s=this._x0,r=this._y0,a=this._x1,i=this._y1;if(isNaN(s))a=(s=Math.floor(t))+1,i=(r=Math.floor(n))+1;else{for(var o=a-s||1,l=this._root,c,d;s>t||t>=a||r>n||n>=i;)switch(d=(n<r)<<1|t<s,c=new Array(4),c[d]=l,l=c,o*=2,d){case 0:a=s+o,i=r+o;break;case 1:s=a-o,i=r+o;break;case 2:a=s+o,r=i-o;break;case 3:s=a-o,r=i-o;break}this._root&&this._root.length&&(this._root=l)}return this._x0=s,this._y0=r,this._x1=a,this._y1=i,this}function Xi(){var t=[];return this.visit(function(n){if(!n.length)do t.push(n.data);while(n=n.next)}),t}function zi(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function ke(t,n,s,r,a){this.node=t,this.x0=n,this.y0=s,this.x1=r,this.y1=a}function Gi(t,n,s){var r,a=this._x0,i=this._y0,o,l,c,d,u=this._x1,p=this._y1,f=[],g=this._root,y,h;for(g&&f.push(new ke(g,a,i,u,p)),s==null?s=1/0:(a=t-s,i=n-s,u=t+s,p=n+s,s*=s);y=f.pop();)if(!(!(g=y.node)||(o=y.x0)>u||(l=y.y0)>p||(c=y.x1)<a||(d=y.y1)<i))if(g.length){var m=(o+c)/2,b=(l+d)/2;f.push(new ke(g[3],m,b,c,d),new ke(g[2],o,b,m,d),new ke(g[1],m,l,c,b),new ke(g[0],o,l,m,b)),(h=(n>=b)<<1|t>=m)&&(y=f[f.length-1],f[f.length-1]=f[f.length-1-h],f[f.length-1-h]=y)}else{var v=t-+this._x.call(null,g.data),k=n-+this._y.call(null,g.data),w=v*v+k*k;if(w<s){var S=Math.sqrt(s=w);a=t-S,i=n-S,u=t+S,p=n+S,r=g.data}}return r}function Wi(t){if(isNaN(u=+this._x.call(null,t))||isNaN(p=+this._y.call(null,t)))return this;var n,s=this._root,r,a,i,o=this._x0,l=this._y0,c=this._x1,d=this._y1,u,p,f,g,y,h,m,b;if(!s)return this;if(s.length)for(;;){if((y=u>=(f=(o+c)/2))?o=f:c=f,(h=p>=(g=(l+d)/2))?l=g:d=g,n=s,!(s=s[m=h<<1|y]))return this;if(!s.length)break;(n[m+1&3]||n[m+2&3]||n[m+3&3])&&(r=n,b=m)}for(;s.data!==t;)if(a=s,!(s=s.next))return this;return(i=s.next)&&delete s.next,a?(i?a.next=i:delete a.next,this):n?(i?n[m]=i:delete n[m],(s=n[0]||n[1]||n[2]||n[3])&&s===(n[3]||n[2]||n[1]||n[0])&&!s.length&&(r?r[b]=s:this._root=s),this):(this._root=i,this)}function qi(t){for(var n=0,s=t.length;n<s;++n)this.remove(t[n]);return this}function Ki(){return this._root}function Vi(){var t=0;return this.visit(function(n){if(!n.length)do++t;while(n=n.next)}),t}function Zi(t){var n=[],s,r=this._root,a,i,o,l,c;for(r&&n.push(new ke(r,this._x0,this._y0,this._x1,this._y1));s=n.pop();)if(!t(r=s.node,i=s.x0,o=s.y0,l=s.x1,c=s.y1)&&r.length){var d=(i+l)/2,u=(o+c)/2;(a=r[3])&&n.push(new ke(a,d,u,l,c)),(a=r[2])&&n.push(new ke(a,i,u,d,c)),(a=r[1])&&n.push(new ke(a,d,o,l,u)),(a=r[0])&&n.push(new ke(a,i,o,d,u))}return this}function Yi(t){var n=[],s=[],r;for(this._root&&n.push(new ke(this._root,this._x0,this._y0,this._x1,this._y1));r=n.pop();){var a=r.node;if(a.length){var i,o=r.x0,l=r.y0,c=r.x1,d=r.y1,u=(o+c)/2,p=(l+d)/2;(i=a[0])&&n.push(new ke(i,o,l,u,p)),(i=a[1])&&n.push(new ke(i,u,l,c,p)),(i=a[2])&&n.push(new ke(i,o,p,u,d)),(i=a[3])&&n.push(new ke(i,u,p,c,d))}s.push(r)}for(;r=s.pop();)t(r.node,r.x0,r.y0,r.x1,r.y1);return this}function Qi(t){return t[0]}function eo(t){return arguments.length?(this._x=t,this):this._x}function to(t){return t[1]}function no(t){return arguments.length?(this._y=t,this):this._y}function mt(t,n,s){var r=new Js(n??Qi,s??to,NaN,NaN,NaN,NaN);return t==null?r:r.addAll(t)}function Js(t,n,s,r,a,i){this._x=t,this._y=n,this._x0=s,this._y0=r,this._x1=a,this._y1=i,this._root=void 0}function so(t){for(var n={data:t.data},s=n;t=t.next;)s=s.next={data:t.data};return n}var Ce=mt.prototype=Js.prototype;Ce.copy=function(){var t=new Js(this._x,this._y,this._x0,this._y0,this._x1,this._y1),n=this._root,s,r;if(!n)return t;if(!n.length)return t._root=so(n),t;for(s=[{source:n,target:t._root=new Array(4)}];n=s.pop();)for(var a=0;a<4;++a)(r=n.source[a])&&(r.length?s.push({source:r,target:n.target[a]=new Array(4)}):n.target[a]=so(r));return t};Ce.add=Ui;Ce.addAll=Bi;Ce.cover=Ji;Ce.data=Xi;Ce.extent=zi;Ce.find=Gi;Ce.remove=Wi;Ce.removeAll=qi;Ce.root=Ki;Ce.size=Vi;Ce.visit=Zi;Ce.visitAfter=Yi;Ce.x=eo;Ce.y=no;function fe(t){return function(){return t}}function Ne(t){return(t()-.5)*1e-6}function od(t){return t.x+t.vx}function ld(t){return t.y+t.vy}function Xs(t){var n,s,r,a=1,i=1;typeof t!="function"&&(t=fe(t==null?1:+t));function o(){for(var d,u=n.length,p,f,g,y,h,m,b=0;b<i;++b)for(p=mt(n,od,ld).visitAfter(l),d=0;d<u;++d)f=n[d],h=s[f.index],m=h*h,g=f.x+f.vx,y=f.y+f.vy,p.visit(v);function v(k,w,S,E,x){var $=k.data,M=k.r,I=h+M;if($){if($.index>f.index){var C=g-$.x-$.vx,L=y-$.y-$.vy,T=C*C+L*L;T<I*I&&(C===0&&(C=Ne(r),T+=C*C),L===0&&(L=Ne(r),T+=L*L),T=(I-(T=Math.sqrt(T)))/T*a,f.vx+=(C*=T)*(I=(M*=M)/(m+M)),f.vy+=(L*=T)*I,$.vx-=C*(I=1-I),$.vy-=L*I)}return}return w>g+I||E<g-I||S>y+I||x<y-I}}function l(d){if(d.data)return d.r=s[d.data.index];for(var u=d.r=0;u<4;++u)d[u]&&d[u].r>d.r&&(d.r=d[u].r)}function c(){if(n){var d,u=n.length,p;for(s=new Array(u),d=0;d<u;++d)p=n[d],s[p.index]=+t(p,d,n)}}return o.initialize=function(d,u){n=d,r=u,c()},o.iterations=function(d){return arguments.length?(i=+d,o):i},o.strength=function(d){return arguments.length?(a=+d,o):a},o.radius=function(d){return arguments.length?(t=typeof d=="function"?d:fe(+d),c(),o):t},o}function cd(t){return t.index}function ro(t,n){var s=t.get(n);if(!s)throw new Error("node not found: "+n);return s}function zs(t){var n=cd,s=p,r,a=fe(30),i,o,l,c,d,u=1;t==null&&(t=[]);function p(m){return 1/Math.min(l[m.source.index],l[m.target.index])}function f(m){for(var b=0,v=t.length;b<u;++b)for(var k=0,w,S,E,x,$,M,I;k<v;++k)w=t[k],S=w.source,E=w.target,x=E.x+E.vx-S.x-S.vx||Ne(d),$=E.y+E.vy-S.y-S.vy||Ne(d),M=Math.sqrt(x*x+$*$),M=(M-i[k])/M*m*r[k],x*=M,$*=M,E.vx-=x*(I=c[k]),E.vy-=$*I,S.vx+=x*(I=1-I),S.vy+=$*I}function g(){if(o){var m,b=o.length,v=t.length,k=new Map(o.map((S,E)=>[n(S,E,o),S])),w;for(m=0,l=new Array(b);m<v;++m)w=t[m],w.index=m,typeof w.source!="object"&&(w.source=ro(k,w.source)),typeof w.target!="object"&&(w.target=ro(k,w.target)),l[w.source.index]=(l[w.source.index]||0)+1,l[w.target.index]=(l[w.target.index]||0)+1;for(m=0,c=new Array(v);m<v;++m)w=t[m],c[m]=l[w.source.index]/(l[w.source.index]+l[w.target.index]);r=new Array(v),y(),i=new Array(v),h()}}function y(){if(o)for(var m=0,b=t.length;m<b;++m)r[m]=+s(t[m],m,t)}function h(){if(o)for(var m=0,b=t.length;m<b;++m)i[m]=+a(t[m],m,t)}return f.initialize=function(m,b){o=m,d=b,g()},f.links=function(m){return arguments.length?(t=m,g(),f):t},f.id=function(m){return arguments.length?(n=m,f):n},f.iterations=function(m){return arguments.length?(u=+m,f):u},f.strength=function(m){return arguments.length?(s=typeof m=="function"?m:fe(+m),y(),f):s},f.distance=function(m){return arguments.length?(a=typeof m=="function"?m:fe(+m),h(),f):a},f}var dd={value:()=>{}};function io(){for(var t=0,n=arguments.length,s={},r;t<n;++t){if(!(r=arguments[t]+"")||r in s||/[\s.]/.test(r))throw new Error("illegal type: "+r);s[r]=[]}return new On(s)}function On(t){this._=t}function ud(t,n){return t.trim().split(/^|\s+/).map(function(s){var r="",a=s.indexOf(".");if(a>=0&&(r=s.slice(a+1),s=s.slice(0,a)),s&&!n.hasOwnProperty(s))throw new Error("unknown type: "+s);return{type:s,name:r}})}On.prototype=io.prototype={constructor:On,on:function(t,n){var s=this._,r=ud(t+"",s),a,i=-1,o=r.length;if(arguments.length<2){for(;++i<o;)if((a=(t=r[i]).type)&&(a=pd(s[a],t.name)))return a;return}if(n!=null&&typeof n!="function")throw new Error("invalid callback: "+n);for(;++i<o;)if(a=(t=r[i]).type)s[a]=ao(s[a],t.name,n);else if(n==null)for(a in s)s[a]=ao(s[a],t.name,null);return this},copy:function(){var t={},n=this._;for(var s in n)t[s]=n[s].slice();return new On(t)},call:function(t,n){if((a=arguments.length-2)>0)for(var s=new Array(a),r=0,a,i;r<a;++r)s[r]=arguments[r+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(i=this._[t],r=0,a=i.length;r<a;++r)i[r].value.apply(n,s)},apply:function(t,n,s){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],a=0,i=r.length;a<i;++a)r[a].value.apply(n,s)}};function pd(t,n){for(var s=0,r=t.length,a;s<r;++s)if((a=t[s]).name===n)return a.value}function ao(t,n,s){for(var r=0,a=t.length;r<a;++r)if(t[r].name===n){t[r]=dd,t=t.slice(0,r).concat(t.slice(r+1));break}return s!=null&&t.push({name:n,value:s}),t}var Gs=io;var Rt=0,Wt=0,Gt=0,lo=1e3,Nn,qt,Un=0,ht=0,Hn=0,Kt=typeof performance=="object"&&performance.now?performance:Date,co=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function Ks(){return ht||(co(md),ht=Kt.now()+Hn)}function md(){ht=0}function Ws(){this._call=this._time=this._next=null}Ws.prototype=Bn.prototype={constructor:Ws,restart:function(t,n,s){if(typeof t!="function")throw new TypeError("callback is not a function");s=(s==null?Ks():+s)+(n==null?0:+n),!this._next&&qt!==this&&(qt?qt._next=this:Nn=this,qt=this),this._call=t,this._time=s,qs()},stop:function(){this._call&&(this._call=null,this._time=1/0,qs())}};function Bn(t,n,s){var r=new Ws;return r.restart(t,n,s),r}function uo(){Ks(),++Rt;for(var t=Nn,n;t;)(n=ht-t._time)>=0&&t._call.call(void 0,n),t=t._next;--Rt}function oo(){ht=(Un=Kt.now())+Hn,Rt=Wt=0;try{uo()}finally{Rt=0,gd(),ht=0}}function hd(){var t=Kt.now(),n=t-Un;n>lo&&(Hn-=n,Un=t)}function gd(){for(var t,n=Nn,s,r=1/0;n;)n._call?(r>n._time&&(r=n._time),t=n,n=n._next):(s=n._next,n._next=null,n=t?t._next=s:Nn=s);qt=t,qs(r)}function qs(t){if(!Rt){Wt&&(Wt=clearTimeout(Wt));var n=t-ht;n>24?(t<1/0&&(Wt=setTimeout(oo,t-Kt.now()-Hn)),Gt&&(Gt=clearInterval(Gt))):(Gt||(Un=Kt.now(),Gt=setInterval(hd,lo)),Rt=1,co(oo))}}function po(){let t=1;return()=>(t=(1664525*t+1013904223)%4294967296)/4294967296}function mo(t){return t.x}function ho(t){return t.y}var fd=10,bd=Math.PI*(3-Math.sqrt(5));function Vs(t){var n,s=1,r=.001,a=1-Math.pow(r,1/300),i=0,o=.6,l=new Map,c=Bn(p),d=Gs("tick","end"),u=po();t==null&&(t=[]);function p(){f(),d.call("tick",n),s<r&&(c.stop(),d.call("end",n))}function f(h){var m,b=t.length,v;h===void 0&&(h=1);for(var k=0;k<h;++k)for(s+=(i-s)*a,l.forEach(function(w){w(s)}),m=0;m<b;++m)v=t[m],v.fx==null?v.x+=v.vx*=o:(v.x=v.fx,v.vx=0),v.fy==null?v.y+=v.vy*=o:(v.y=v.fy,v.vy=0);return n}function g(){for(var h=0,m=t.length,b;h<m;++h){if(b=t[h],b.index=h,b.fx!=null&&(b.x=b.fx),b.fy!=null&&(b.y=b.fy),isNaN(b.x)||isNaN(b.y)){var v=fd*Math.sqrt(.5+h),k=h*bd;b.x=v*Math.cos(k),b.y=v*Math.sin(k)}(isNaN(b.vx)||isNaN(b.vy))&&(b.vx=b.vy=0)}}function y(h){return h.initialize&&h.initialize(t,u),h}return g(),n={tick:f,restart:function(){return c.restart(p),n},stop:function(){return c.stop(),n},nodes:function(h){return arguments.length?(t=h,g(),l.forEach(y),n):t},alpha:function(h){return arguments.length?(s=+h,n):s},alphaMin:function(h){return arguments.length?(r=+h,n):r},alphaDecay:function(h){return arguments.length?(a=+h,n):+a},alphaTarget:function(h){return arguments.length?(i=+h,n):i},velocityDecay:function(h){return arguments.length?(o=1-h,n):1-o},randomSource:function(h){return arguments.length?(u=h,l.forEach(y),n):u},force:function(h,m){return arguments.length>1?(m==null?l.delete(h):l.set(h,y(m)),n):l.get(h)},find:function(h,m,b){var v=0,k=t.length,w,S,E,x,$;for(b==null?b=1/0:b*=b,v=0;v<k;++v)x=t[v],w=h-x.x,S=m-x.y,E=w*w+S*S,E<b&&($=x,b=E);return $},on:function(h,m){return arguments.length>1?(d.on(h,m),n):d.on(h)}}}function Zs(){var t,n,s,r,a=fe(-30),i,o=1,l=1/0,c=.81;function d(g){var y,h=t.length,m=mt(t,mo,ho).visitAfter(p);for(r=g,y=0;y<h;++y)n=t[y],m.visit(f)}function u(){if(t){var g,y=t.length,h;for(i=new Array(y),g=0;g<y;++g)h=t[g],i[h.index]=+a(h,g,t)}}function p(g){var y=0,h,m,b=0,v,k,w;if(g.length){for(v=k=w=0;w<4;++w)(h=g[w])&&(m=Math.abs(h.value))&&(y+=h.value,b+=m,v+=m*h.x,k+=m*h.y);g.x=v/b,g.y=k/b}else{h=g,h.x=h.data.x,h.y=h.data.y;do y+=i[h.data.index];while(h=h.next)}g.value=y}function f(g,y,h,m){if(!g.value)return!0;var b=g.x-n.x,v=g.y-n.y,k=m-y,w=b*b+v*v;if(k*k/c<w)return w<l&&(b===0&&(b=Ne(s),w+=b*b),v===0&&(v=Ne(s),w+=v*v),w<o&&(w=Math.sqrt(o*w)),n.vx+=b*g.value*r/w,n.vy+=v*g.value*r/w),!0;if(g.length||w>=l)return;(g.data!==n||g.next)&&(b===0&&(b=Ne(s),w+=b*b),v===0&&(v=Ne(s),w+=v*v),w<o&&(w=Math.sqrt(o*w)));do g.data!==n&&(k=i[g.data.index]*r/w,n.vx+=b*k,n.vy+=v*k);while(g=g.next)}return d.initialize=function(g,y){t=g,s=y,u()},d.strength=function(g){return arguments.length?(a=typeof g=="function"?g:fe(+g),u(),d):a},d.distanceMin=function(g){return arguments.length?(o=g*g,d):Math.sqrt(o)},d.distanceMax=function(g){return arguments.length?(l=g*g,d):Math.sqrt(l)},d.theta=function(g){return arguments.length?(c=g*g,d):Math.sqrt(c)},d}function Ys(t){var n=fe(.1),s,r,a;typeof t!="function"&&(t=fe(t==null?0:+t));function i(l){for(var c=0,d=s.length,u;c<d;++c)u=s[c],u.vx+=(a[c]-u.x)*r[c]*l}function o(){if(s){var l,c=s.length;for(r=new Array(c),a=new Array(c),l=0;l<c;++l)r[l]=isNaN(a[l]=+t(s[l],l,s))?0:+n(s[l],l,s)}}return i.initialize=function(l){s=l,o()},i.strength=function(l){return arguments.length?(n=typeof l=="function"?l:fe(+l),o(),i):n},i.x=function(l){return arguments.length?(t=typeof l=="function"?l:fe(+l),o(),i):t},i}function Qs(t){var n=fe(.1),s,r,a;typeof t!="function"&&(t=fe(t==null?0:+t));function i(l){for(var c=0,d=s.length,u;c<d;++c)u=s[c],u.vy+=(a[c]-u.y)*r[c]*l}function o(){if(s){var l,c=s.length;for(r=new Array(c),a=new Array(c),l=0;l<c;++l)r[l]=isNaN(a[l]=+t(s[l],l,s))?0:+n(s[l],l,s)}}return i.initialize=function(l){s=l,o()},i.strength=function(l){return arguments.length?(n=typeof l=="function"?l:fe(+l),o(),i):n},i.y=function(l){return arguments.length?(t=typeof l=="function"?l:fe(+l),o(),i):t},i}function er(t,n,s){let r=new Map,a=t.map(c=>{let d=s?.get(c.id),u={...c,deg:0,r:4};return d&&(u.x=d.x,u.y=d.y),r.set(c.id,u),u}),i=[];for(let c of n){let d=r.get(c.src),u=r.get(c.dst);!d||!u||d===u||(d.deg++,u.deg++,i.push({source:d,target:u,kind:c.kind,weight:c.weight,count:c.count,lines:c.lines}))}for(let c of a)c.r=4+Math.min(12,Math.sqrt(c.deg)*1.8)+(c.root?3:0);let o=a.length,l=Vs(a).force("link",zs(i).distance(c=>c.kind==="co_changes"?90:c.kind==="defines"?36:60).strength(c=>c.kind==="co_changes"?.15:.5)).force("charge",Zs().strength(o>400?-60:-140).distanceMax(600)).force("collide",Xs().radius(c=>c.r+4).iterations(2)).force("center",Bs(0,0).strength(.05)).force("x",Ys(0).strength(.02)).force("y",Qs(0).strength(.02)).alphaDecay(o>400?.05:.03).velocityDecay(.4);return{nodes:a,links:i,sim:l,byId:r}}function go(t,n){let s=er(t,n);s.sim.stop();let r=s.nodes.filter(y=>y.kind==="file"),a=s.nodes.filter(y=>y.kind!=="file"),i=new Map;for(let y of r){let h=(y.path??y.label).split("/").slice(0,-1).join("/")||".";(i.get(h)??i.set(h,[]).get(h)).push(y)}let o=[...i.keys()].sort((y,h)=>y.split("/").length-h.split("/").length||y.localeCompare(h)),l=220,c=34,d=-(o.length-1)*l/2,u=new Map;for(let y of o){let h=i.get(y).sort((b,v)=>b.label.localeCompare(v.label)),m=-(h.length-1)*c/2;for(let b of h)b.x=d,b.y=m,b.fx=d,b.fy=m,u.set(b.path??b.label,b),m+=c;d+=l}let p=new Map,f=[];for(let y of a){let h=y.path?u.get(y.path):void 0;if(!h){f.push(y);continue}let m=p.get(h.id)??0;p.set(h.id,m+1),y.x=(h.x??0)+70+m%3*46,y.y=(h.y??0)+Math.floor(m/3)*14-8,y.fx=y.x,y.fy=y.y}let g=(o.length?i.get(o[0]).length:0)*c/2+60;for(let y of f)y.x=-(f.length-1)*60/2+f.indexOf(y)*60,y.y=g,y.fx=y.x,y.fy=y.y;return g+=40,s}var tr=t=>De(t.kind),nr=t=>"circle";function fo(t,n=1){return{color:Et(t),dash:t==="calls"?[4,3]:t==="co_changes"?[1,3]:t==="references"?[2,2]:void 0,width:t==="co_changes"?1+n*2:1,alpha:t==="co_changes"?.35:.45,directed:Sn.has(t)}}function bo(t,n,s,r,a){switch(t.beginPath(),n){case"square":{let i=a*.88;t.rect(s-i,r-i,i*2,i*2);break}case"diamond":{let i=a*1.25;t.moveTo(s,r-i),t.lineTo(s+i,r),t.lineTo(s,r+i),t.lineTo(s-i,r),t.closePath();break}case"triangle":{let i=a*1.3;t.moveTo(s,r-i),t.lineTo(s+i*.87,r+i*.5),t.lineTo(s-i*.87,r+i*.5),t.closePath();break}case"hexagon":{let i=a*1.12;for(let o=0;o<6;o++){let l=Math.PI/3*o,c=s+i*Math.cos(l),d=r+i*Math.sin(l);o===0?t.moveTo(c,d):t.lineTo(c,d)}t.closePath();break}default:t.arc(s,r,a,0,Math.PI*2)}}function vo(t){switch(t){case"square":return"M1.5 1.5H10.5V10.5H1.5Z";case"diamond":return"M6 0.5L11.5 6L6 11.5L0.5 6Z";case"triangle":return"M6 0.8L11.4 10.6H0.6Z";case"hexagon":return"M11.5 6L8.75 10.76H3.25L0.5 6L3.25 1.24H8.75Z";default:return"M6 1A5 5 0 1 1 5.99 1Z"}}function rt({shape:t,color:n}){let s=t==="ring";return e("svg",{class:"glyph",width:"11",height:"11",viewBox:"0 0 12 12","aria-hidden":"true",children:e("path",{d:vo(t),fill:s?"none":n,stroke:n,"stroke-width":s?1.6:0})})}function Mt({color:t,dash:n}){return e("svg",{class:"glyph",width:"18",height:"8",viewBox:"0 0 18 8","aria-hidden":"true",children:e("line",{x1:"0",y1:"4",x2:"18",y2:"4",stroke:t,"stroke-width":"2","stroke-dasharray":n?.length?n.join(" "):void 0})})}var vd=t=>t.kind==="file"||t.kind==="package"?_n(t.label):t.label.split(".").pop()??t.label,yd=()=>document.documentElement.getAttribute("data-theme")==="dark"||document.documentElement.getAttribute("data-theme")!=="light"&&window.matchMedia("(prefers-color-scheme: dark)").matches;function We(t){let n=ee(null),s=ee(null),r=ee(null),a=ee({k:1,x:0,y:0}),i=ee(!1),o=ee(null),l=ee(null),[c,d]=_(null),[u,p]=_(!1),f=ee(t);f.current=t;let g=()=>{let C=n.current,L=r.current;if(!C||!L)return;let T=C.getContext("2d");if(!T)return;let F=window.devicePixelRatio||1,H=C.width/F,K=C.height/F,R=a.current,z=yd(),{selected:se,highlight:Ee}=f.current,D=f.current.colorOf??tr,V=f.current.shapeOf??nr,be=f.current.edgeStyleOf??fo,Pe=f.current.labelOf??vd,me=se?L.byId.get(se):void 0,re=new Set;if(me){re.add(me.id);for(let ne of L.links){let _e=ne.source,ve=ne.target;_e.id===me.id&&re.add(ve.id),ve.id===me.id&&re.add(_e.id)}}T.setTransform(F,0,0,F,0,0),T.clearRect(0,0,H,K),T.translate(H/2+R.x,K/2+R.y),T.scale(R.k,R.k);for(let ne of L.links){let _e=ne.source,ve=ne.target;if(_e.x===void 0||ve.x===void 0)continue;let ln=`${_e.id}|${ve.id}|${ne.kind}`,ds=Ee?.has(ln),cn=me&&!(re.has(_e.id)&&re.has(ve.id))&&_e.id!==me.id&&ve.id!==me.id,Xe=be(ne.kind,ne.weight);if(T.globalAlpha=ds?1:cn?.06:Xe.alpha??.45,T.strokeStyle=Xe.color,T.lineWidth=(ds?2.5:Xe.width??1)/R.k,T.setLineDash(Xe.dash?Xe.dash.map(dn=>dn/R.k):[]),T.beginPath(),T.moveTo(_e.x,_e.y??0),T.lineTo(ve.x,ve.y??0),T.stroke(),T.setLineDash([]),Xe.directed&&R.k>.5){let dn=ve.x-_e.x,Ar=(ve.y??0)-(_e.y??0),Rr=Math.hypot(dn,Ar)||1,Nt=dn/Rr,Ut=Ar/Rr,us=ve.x-Nt*(ve.r+2),ps=(ve.y??0)-Ut*(ve.r+2),et=5/R.k;T.fillStyle=Xe.color,T.beginPath(),T.moveTo(us,ps),T.lineTo(us-Nt*et*2-Ut*et,ps-Ut*et*2+Nt*et),T.lineTo(us-Nt*et*2+Ut*et,ps-Ut*et*2-Nt*et),T.closePath(),T.fill()}}let Le=L.nodes.length<=120||R.k>1.6;T.font=`${11/R.k}px system-ui, sans-serif`,T.textBaseline="middle";for(let ne of L.nodes){if(ne.x===void 0||ne.y===void 0)continue;let _e=me&&!re.has(ne.id);T.globalAlpha=_e?.2:1;let ve=V(ne),ln=D(ne);if(bo(T,ve,ne.x,ne.y,ne.r/Math.max(1,R.k**.5)),ve==="ring"?(T.fillStyle=z?"#171a21":"#ffffff",T.fill(),T.lineWidth=1.6/R.k,T.strokeStyle=ln,T.stroke()):(T.fillStyle=ln,T.fill()),(ne.root||ne.id===se||ne===o.current)&&(T.lineWidth=2.5/R.k,T.strokeStyle=z?"#e5e7eb":"#1b1f24",T.stroke()),Le||ne.root||ne.deg>3||re.has(ne.id)||ne===o.current||ne.id===se){let cn=Pe(ne),Xe=ne.x+ne.r/Math.max(1,R.k**.5)+3/R.k;T.lineWidth=3/R.k,T.strokeStyle=z?"#171a21":"#ffffff",T.strokeText(cn,Xe,ne.y),T.fillStyle=z?"#e5e7eb":"#1b1f24",T.fillText(cn,Xe,ne.y)}}T.globalAlpha=1},y=()=>{let C=n.current,L=r.current;if(!C||!L?.nodes.length)return;let T=window.devicePixelRatio||1,F=C.width/T,H=C.height/T,K=Number.POSITIVE_INFINITY,R=Number.POSITIVE_INFINITY,z=Number.NEGATIVE_INFINITY,se=Number.NEGATIVE_INFINITY;for(let be of L.nodes)be.x===void 0||be.y===void 0||(K=Math.min(K,be.x),R=Math.min(R,be.y),z=Math.max(z,be.x),se=Math.max(se,be.y));let Ee=Math.max(100,z-K+120),D=Math.max(100,se-R+120),V=Math.min(2.5,Math.min(F/Ee,H/D));a.current={k:V,x:-((K+z)/2)*V,y:-((R+se)/2)*V},g()};aa(t.handle??null,()=>({fit:y}),[]);let h=t.nodes.map(C=>C.id).join("|"),m=t.edges.map(C=>`${C.src}|${C.dst}|${C.kind}`).join(`
|
|
3
|
-
`),b=t.mode??"galaxy";J(()=>{let C=t.keepPositions?r.current?.byId:void 0;r.current?.sim.stop();let L=b==="hierarchy"?go(t.nodes,t.edges):er(t.nodes,t.edges,C);r.current=L,i.current=!1;let T=!1,F=!1,H=0;if(b==="hierarchy"){y();return}return L.sim.on("tick",()=>{H++,(H%2===0||L.sim.alpha()<.05)&&g(),!T&&(H===30||L.sim.alpha()<.3)&&(T=!0,i.current||y())}),L.sim.on("end",()=>{F||(F=!0,T=!0,i.current||y())}),()=>L.sim.stop()},[h,m,b]),J(()=>{g()},[t.selected,t.highlight,c,t.colorOf,t.shapeOf,t.edgeStyleOf]),J(()=>{let C=s.current,L=n.current;if(!C||!L)return;let T=()=>{let R=window.devicePixelRatio||1;L.width=Math.max(1,C.clientWidth*R),L.height=Math.max(1,C.clientHeight*R),g()};T();let F=new ResizeObserver(T);F.observe(C);let H=window.matchMedia("(prefers-color-scheme: dark)");H.addEventListener("change",g);let K=new MutationObserver(g);return K.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>{F.disconnect(),H.removeEventListener("change",g),K.disconnect()}},[]);let v=C=>{let T=n.current.getBoundingClientRect(),F=a.current;return{x:(C.clientX-T.left-T.width/2-F.x)/F.k,y:(C.clientY-T.top-T.height/2-F.y)/F.k}},k=C=>{let L=r.current;if(!L)return null;let T=v(C),F=a.current,H=null,K=Number.POSITIVE_INFINITY;for(let R of L.nodes){if(R.x===void 0||R.y===void 0)continue;let z=Math.hypot(R.x-T.x,R.y-T.y),se=R.r/Math.max(1,F.k**.5)+6/F.k;z<se&&z<K&&(K=z,H=R)}return H},w=C=>{let L=k(C),T=a.current;l.current={node:L??void 0,px:C.clientX,py:C.clientY,vx:T.x,vy:T.y,moved:!1},L&&(L.fx=L.x,L.fy=L.y,r.current?.sim.alphaTarget(.2).restart()),p(!0),C.preventDefault()},S=C=>{let L=l.current;if(L){let F=C.clientX-L.px,H=C.clientY-L.py;if(Math.abs(F)+Math.abs(H)>3&&(L.moved=!0),L.node){let K=v(C);L.node.fx=K.x,L.node.fy=K.y,b==="hierarchy"&&(L.node.x=K.x,L.node.y=K.y,g())}else L.moved&&(i.current=!0),a.current={...a.current,x:L.vx+F,y:L.vy+H},g();return}let T=k(C);T!==o.current&&(o.current=T,d(T))},E=C=>{let L=l.current;l.current=null,p(!1),L&&(L.node?(b!=="hierarchy"&&(L.node.fx=null,L.node.fy=null,r.current?.sim.alphaTarget(0)),L.moved||f.current.onSelect?.(L.node.id===f.current.selected?null:L.node.id)):L.moved||f.current.onSelect?.(null))},x=C=>{C.preventDefault();let T=n.current.getBoundingClientRect(),F=a.current;i.current=!0;let H=C.deltaY>0?.9:1.1,K=Math.max(.05,Math.min(8,F.k*H)),R=C.clientX-T.left-T.width/2,z=C.clientY-T.top-T.height/2;a.current={k:K,x:R-(R-F.x)*K/F.k,y:z-(z-F.y)*K/F.k},g()},$=C=>{let L=k(C);L&&f.current.onActivate?.(L.id)},M=[...new Set(t.nodes.map(C=>C.kind))],I=[...new Set(t.edges.map(C=>C.kind))];return e("div",{class:"gwrap",ref:s,children:[e("canvas",{ref:n,class:A(u&&"drag",c&&!u&&"hover"),onMouseDown:w,onMouseMove:S,onMouseUp:E,onMouseLeave:()=>{o.current=null,d(null),l.current&&!l.current.node&&(l.current=null)},onWheel:x,onDblClick:$}),c&&!u&&e("div",{class:"overlay tip",style:{left:12,top:12},children:[e("b",{children:c.kind})," ",c.label,c.path&&c.kind!=="file"?e("span",{class:"muted",children:[" ","\xB7 ",c.path,c.line?`:${c.line}`:""]}):null,e("span",{class:"muted",children:[" ","\xB7 ",c.deg," edge",c.deg===1?"":"s"]})]}),t.legend!==!1&&e("div",{class:"overlay legend",children:[M.map(C=>{let L=t.nodes.find(T=>T.kind===C);return e("span",{children:[t.shapeOf||t.colorOf?e(rt,{shape:(t.shapeOf??nr)(L),color:(t.colorOf??tr)(L)}):e("i",{style:{background:De(C)}}),C]})}),I.map(C=>{let L=t.edgeStyleOf?.(C,1);return e("span",{children:[L?e(Mt,{color:L.color,dash:L.dash}):e("s",{style:{borderColor:Et(C)}}),C]})})]}),e("button",{type:"button",class:"overlay fit",onClick:y,children:"fit view"})]})}function yo(t,n,s,r,a){let i=t.reduce((y,h)=>y+(h.value??h.size),0);if(!i||!t.length)return[];let o=r*a/i,l=[],c=0,d=n,u=s,p=r,f=a,g=[...t].sort((y,h)=>(h.value??h.size)-(y.value??y.size));for(;c<g.length;){let y=p>=f,h=y?f:p,m=[],b=0,v=Number.POSITIVE_INFINITY;for(;c<g.length;){let S=g[c],E=(S.value??S.size)*o,x=[...m,S],$=b+E,M=Math.max(...x.map(L=>(L.value??L.size)*o)),I=Math.min(...x.map(L=>(L.value??L.size)*o)),C=Math.max(h*h*M/($*$),$*$/(h*h*I));if(C>v&&m.length)break;v=C,m=x,b=$,c++}let k=h?b/h:0,w=0;for(let S of m){let E=k?(S.value??S.size)*o/k:0;l.push(y?{node:S,x:d,y:u+w,w:k,h:E,depth:0}:{node:S,x:d+w,y:u,w:E,h:k,depth:0}),w+=E}y?(d+=k,p-=k):(u+=k,f-=k)}return l}function ko(t,n,s,r=18){let a=[];for(let i of yo(t.children??[],0,0,n,s))if(a.push({...i,depth:0}),i.node.children?.length&&i.w>40&&i.h>30)for(let o of yo(i.node.children,i.x+2,i.y+r,Math.max(0,i.w-4),Math.max(0,i.h-r-2)))a.push({...o,depth:1});return a}function wo(t,n,s){let r={name:n||"(project)",path:n,size:0,children:[]},a=new Map([["",r]]),i=l=>{let c=a.get(l);if(c)return c;let d=i(l.includes("/")?l.slice(0,l.lastIndexOf("/")):""),u={name:l.split("/").pop()??l,path:l,size:0,children:[]};return d.children.push(u),a.set(l,u),u};for(let l of t){if(n&&!l.path.startsWith(n))continue;let c=n?l.path.slice(n.length).replace(/^\//,""):l.path,d=c.includes("/")?c.slice(0,c.lastIndexOf("/")):"",u=Math.max(1,s(l));i(d).children.push({name:c.split("/").pop()??c,path:l.path,size:u,data:l})}let o=l=>(l.children?.length&&(l.size=l.children.reduce((c,d)=>c+o(d),0)),l.size);return o(r),r}var xo={typescript:"#2563eb",tsx:"#3b82f6",javascript:"#d97706",python:"#16a34a",go:"#0d9488",php:"#6366f1",other:"#6b7280"};function kd(t){let n=Math.max(0,Math.min(1,t)),s=Math.round(37+180*n),r=Math.round(99+20*n),a=Math.round(235+-229*n);return`rgb(${s},${r},${a})`}function wd({files:t,arch:n}){let[s,r]=_(""),[a,i]=_("language"),[o,l]=_("loc"),[c,d]=_(null),u=ee(null),[p,f]=_({w:900,h:520});J(()=>{let v=u.current;if(!v)return;let k=new ResizeObserver(()=>f({w:v.clientWidth,h:v.clientHeight}));return k.observe(v),f({w:v.clientWidth,h:v.clientHeight}),()=>k.disconnect()},[]);let g=Z(()=>{let v=wo(t,s,k=>o==="uniform"?1:k.loc||Math.max(1,k.size/40));return ko(v,p.w,p.h)},[t,s,o,p]),h=c?(v=>t.filter(k=>k.path===v||k.path.startsWith(`${v}/`)))(c):[],m=h.length===1&&h[0]?.path===c?h[0]:void 0,b=n?.entryPoints.filter(v=>v.kind!=="script")??[];return e("div",{class:"grid wide",style:{alignItems:"start"},children:[e("div",{children:[e("div",{class:"row",style:{marginBottom:8},children:[e("span",{class:"row tight",children:[e("a",{onClick:()=>r(""),children:n?.project.name??"project"}),s.split("/").filter(Boolean).map((v,k,w)=>e(j,{children:[e("span",{class:"muted",children:"\u203A"}),e("a",{onClick:()=>r(w.slice(0,k+1).join("/")),children:v})]}))]}),e("span",{class:"spacer"}),e("span",{class:"row tight",children:[e("button",{type:"button",class:A("chip",o==="loc"&&"on"),onClick:()=>l("loc"),children:"size: loc"}),e("button",{type:"button",class:A("chip",o==="uniform"&&"on"),onClick:()=>l("uniform"),children:"uniform"}),e("button",{type:"button",class:A("chip",a==="language"&&"on"),onClick:()=>i("language"),children:"color: language"}),e("button",{type:"button",class:A("chip",a==="heat"&&"on"),onClick:()=>i("heat"),children:"heat"})]})]}),e("div",{class:"treemap",ref:u,children:g.map(v=>{let k=v.node.data,w=!!v.node.children?.length,S=k?a==="heat"?kd(k.score):xo[k.language??"other"]??xo.other:void 0;return e("div",{class:A("cell",w&&"dir",c===v.node.path&&"sel"),style:{left:v.x,top:v.y,width:Math.max(0,v.w),height:Math.max(0,v.h),background:S},title:k?`${k.path} \xB7 ${k.loc} loc \xB7 ${k.symbols} symbols \xB7 heat ${k.score.toFixed(2)}`:`${v.node.path} \xB7 ${v.node.size} loc`,onClick:E=>{E.stopPropagation(),d(v.node.path)},onDblClick:E=>{E.stopPropagation(),w?r(v.node.path):k&&U("explore",{file:k.path})},children:w?e("span",{class:"lbl",children:[v.node.name,"/"]}):v.w>50&&v.h>14?v.node.name:""})})}),e("div",{class:"muted small",style:{marginTop:6},children:"Area is lines of code (or uniform). Double-click a folder to open it, a file to read it. Heat mixes fan-in, recent commits and complexity; it is a signal, not a grade."})]}),e("div",{class:"stack",children:[e("div",{class:"card",children:[e("h3",{children:c??"selection"}),m?e(j,{children:[e("div",{class:"row small",children:[e(P,{children:m.language??"?"}),e(P,{children:[m.loc," loc"]}),e(P,{children:[m.symbols," symbols"]}),e(P,{children:["fan-in ",m.fanIn]}),e(P,{children:["heat ",m.score.toFixed(2)]}),e(P,{children:m.status})]}),e("div",{class:"row",style:{marginTop:8},children:[e("button",{type:"button",class:"sm",onClick:()=>U("explore",{file:m.path}),children:"Open source"}),e("button",{type:"button",class:"sm",onClick:()=>U("galaxy",{node:`file:${m.path}`}),children:"Galaxy"})]})]}):h.length?e("div",{class:"row small",children:[e(P,{children:[h.length," files"]}),e(P,{children:[q(h.reduce((v,k)=>v+k.loc,0))," loc"]}),e(P,{children:[h.reduce((v,k)=>v+k.symbols,0)," symbols"]}),e(P,{children:["mean heat ",(h.reduce((v,k)=>v+k.score,0)/h.length).toFixed(2)]})]}):e("div",{class:"muted small",children:"Click a cell."})]}),e("div",{class:"card",children:[e("h3",{children:"entry points"}),b.length?e("table",{children:e("tbody",{children:b.map(v=>e("tr",{class:"click",onClick:()=>U("explore",{file:v.path}),children:[e("td",{children:e(P,{children:v.kind})}),e("td",{class:"break",children:v.name}),e("td",{class:"muted small break",children:v.path})]}))})}):e("div",{class:"muted small",children:"none found"})]}),n&&e("div",{class:"card",children:[e("h3",{children:"overview"}),e("div",{class:"row small",children:[e(P,{children:[n.overview.files," files"]}),e(P,{children:[n.overview.symbols," symbols"]}),e(P,{children:[n.overview.edges," edges"]}),Object.entries(n.overview.languages).map(([v,k])=>e(P,{children:[v," ",k]}))]}),n.project.description?e("div",{class:"muted small",style:{marginTop:6},children:n.project.description}):null]})]})]})}function xd(){let t=X(()=>O("/api/routes"),[]);return t.error?e(W,{error:t.error}):t.data?t.data.length?e("div",{class:"card flush",children:e("table",{children:[e("thead",{children:e("tr",{children:[e("th",{children:"method"}),e("th",{children:"path"}),e("th",{children:"framework"}),e("th",{children:"handler"}),e("th",{children:"registered in"})]})}),e("tbody",{children:t.data.map(n=>e("tr",{children:[e("td",{children:e(P,{children:n.method})}),e("td",{class:"mono",children:n.path}),e("td",{class:"muted",children:n.framework}),e("td",{children:n.handlers.map(s=>e("div",{children:[e("a",{onClick:()=>s.path?U("explore",{file:s.path,symbol:s.id}):U("galaxy",{node:s.id}),children:s.name}),s.path?e("span",{class:"muted small",children:[" ",s.path]}):null]}))}),e("td",{class:"muted small",children:e("a",{onClick:()=>U("explore",{file:n.file,line:n.line?String(n.line):void 0}),children:[n.file,n.line?`:${n.line}`:""]})})]}))})]})}):e(B,{children:"No routes detected. express/fastify/hono/koa/hapi/restify registrations, moleculer service schemas and gateway aliases, and Next.js route files are recognised."}):e(N,{})}function _d(){let[t,n]=_("file"),[s,r]=_(""),a=X(()=>O("/api/hotspots",{kind:t,path:s.trim()||void 0,limit:80}),[t,s]),{sorted:i,th:o}=nt(a.data,"score"),l={fan_in:Math.max(1,...i.map(c=>c.fan_in)),commits_90d:Math.max(1,...i.map(c=>c.commits_90d)),complexity:Math.max(1,...i.map(c=>c.complexity))};return e(j,{children:[e("div",{class:"row",style:{marginBottom:10},children:[e("button",{type:"button",class:A("chip",t==="file"&&"on"),onClick:()=>n("file"),children:"files"}),e("button",{type:"button",class:A("chip",t==="symbol"&&"on"),onClick:()=>n("symbol"),children:"functions and classes"}),e("input",{type:"text",placeholder:"folder prefix, e.g. src/graph/",value:s,onInput:c=>r(c.target.value),style:{width:260}}),e("span",{class:"muted small",children:"Score = 0.4\xB7fan-in + 0.4\xB7commits/90d + 0.2\xB7complexity, log-scaled. A signal of where attention goes, not a quality grade."})]}),a.error?e(W,{error:a.error}):a.data?e("div",{class:"card flush",children:e("table",{children:[e("thead",{children:e("tr",{children:[o("path",t==="file"?"file":"symbol"),o("fan_in","fan-in",!0),o("commits_90d","commits/90d",!0),o("complexity","complexity",!0),o("loc","loc",!0),o("score","score",!0),e("th",{children:"last"})]})}),e("tbody",{children:i.map(c=>e("tr",{class:"click",onClick:()=>c.kind==="file"?U("explore",{file:c.path}):U("explore",{file:c.path.split(" > ")[0],symbol:c.id}),children:[e("td",{class:"break",children:[c.kind!=="file"?e(ye,{kind:c.kind}):null,c.path]}),e("td",{class:"num",children:[e(Qe,{value:c.fan_in,max:l.fan_in,width:60})," ",c.fan_in]}),e("td",{class:"num",children:[e(Qe,{value:c.commits_90d,max:l.commits_90d,width:60})," ",c.commits_90d]}),e("td",{class:"num",children:[e(Qe,{value:c.complexity,max:l.complexity,width:60})," ",c.complexity]}),e("td",{class:"num",children:c.loc}),e("td",{class:"num",children:e("b",{children:c.score.toFixed(2)})}),e("td",{class:"muted small",children:c.last_touched})]}))})]})}):e(N,{})]})}function Sd(){let t=X(()=>O("/api/clusters"),[]),[n,s]=_(null),[r,a]=_(null),[i,o]=_(new Set),l=Z(()=>{let u=t.data;if(!u)return{nodes:[],edges:[]};let p=[],f=[];if(r!==null){let g=u.cycles[r]??[];for(let y of g)p.push({id:`file:${y}`,label:y,kind:"file",path:y,line:null});for(let y=0;y<g.length;y++)f.push({src:`file:${g[y]}`,dst:`file:${g[(y+1)%g.length]}`,kind:"imports",weight:1});return{nodes:p,edges:f}}for(let g of u.clusters){if(i.has(g.id))for(let y of u.members[String(g.id)]??[])p.push({id:`file:${y.path}`,label:y.path,kind:"file",path:y.path,line:null,score:y.score});if(p.push({id:`cluster:${g.id}`,label:`#${g.id} ${g.label} (${g.size})`,kind:"cluster",path:null,line:null}),i.has(g.id))for(let y of u.members[String(g.id)]??[])f.push({src:`file:${y.path}`,dst:`cluster:${g.id}`,kind:"link",weight:.5});for(let[y,h]of Object.entries(g.links))f.push({src:`cluster:${g.id}`,dst:`cluster:${y}`,kind:"imports",weight:Math.min(1,h/10),count:h})}return{nodes:p,edges:f}},[t.data,r,i]);if(t.error)return e(W,{error:t.error});let c=t.data;if(!c)return e(N,{});let d=n?.startsWith("cluster:")?c.clusters.find(u=>String(u.id)===n.slice(8)):void 0;return e("div",{class:"grid wide",style:{alignItems:"start"},children:[e("div",{class:"card flush",style:{height:560},children:l.nodes.length?e(We,{nodes:l.nodes,edges:l.edges,selected:n,onSelect:s,onActivate:u=>{if(u.startsWith("cluster:")){let p=Number(u.slice(8));o(f=>{let g=new Set(f);return g.has(p)?g.delete(p):g.add(p),g})}else u.startsWith("file:")&&U("explore",{file:u.slice(5)})}}):e(B,{children:"No clusters yet. Run a reindex."})}),e("div",{class:"stack",children:[e("div",{class:"card",children:[e("h3",{children:["clusters \xB7 ",c.clusters.length]}),e("div",{class:"muted small",style:{marginBottom:6},children:"Connectivity groups from imports and co-change (label propagation). Double-click a cluster to expand its files; they are not proof of architectural boundaries."}),e("div",{class:"list",style:{maxHeight:260},children:c.clusters.map(u=>e("div",{class:A("item",n===`cluster:${u.id}`&&"sel"),onClick:()=>{a(null),s(`cluster:${u.id}`)},children:[e("div",{class:"n",children:["#",u.id," ",u.label," ",e("span",{class:"muted",children:["\xB7 ",u.size," files"]})]}),e("div",{class:"p",children:u.files.slice(0,3).join(", ")})]}))})]}),d&&e("div",{class:"card",children:[e("h3",{children:["cluster #",d.id," members"]}),e("div",{class:"list",style:{maxHeight:220},children:(c.members[String(d.id)]??[]).map(u=>e("div",{class:"item",onClick:()=>U("explore",{file:u.path}),children:e("div",{class:"p",children:[u.path," ",e("span",{class:"muted",children:["\xB7 heat ",u.score.toFixed(2)]})]})}))})]}),e("div",{class:"card",children:[e("h3",{children:["import cycles \xB7 ",c.cycles.length]}),c.cycles.length?e("div",{class:"list",style:{maxHeight:220},children:c.cycles.map((u,p)=>e("div",{class:A("item",r===p&&"sel"),onClick:()=>{a(r===p?null:p),s(null)},children:e("div",{class:"p",children:[u.length," files: ",u.slice(0,4).join(" \u2192 "),u.length>4?" \u2026":""]})}))}):e("div",{class:"muted small",children:"none"}),r!==null?e("button",{type:"button",class:"sm",style:{marginTop:6},onClick:()=>a(null),children:"show clusters"}):null]})]})]})}function _o({id:t,depth:n,onSelect:s,selected:r}){let a=X(()=>O("/api/behavior",{id:t}),[t]),[i,o]=_(new Set);if(a.error)return e("div",{class:"muted small",children:a.error});if(!a.data)return e(N,{});let l=a.data;return e(j,{children:[n===0&&e("div",{class:A("bnode",r===l.root.id&&"sel"),onClick:()=>s(l),children:[e(P,{children:"start"}),e(ye,{kind:l.root.kind}),e("b",{children:l.root.label}),e("span",{class:"muted small",children:l.root.path})]}),e("div",{class:"kids",children:l.callees.length?l.callees.map(c=>{let d=i.has(c.node.id);return e(j,{children:[e("div",{class:A("bnode",r===c.node.id&&"sel"),onClick:()=>s({root:c.node,callees:[]}),children:[e("span",{class:"arrow",onClick:u=>{u.stopPropagation(),o(p=>{let f=new Set(p);return f.has(c.node.id)?f.delete(c.node.id):f.add(c.node.id),f})},children:c.node.kind==="package"||c.node.kind==="route"?"\xB7":d?"\u25BE":"\u25B8"}),e(P,{children:c.kind==="handles"?"handles":"possible call"}),e(ye,{kind:c.node.kind}),e("span",{children:c.node.label}),e("span",{class:"muted small",children:[c.lines?.length?`L${c.lines.join(", L")}`:"",c.count&&c.count>1?` \xD7${c.count}`:""]})]}),d&&n<6?e(_o,{id:c.node.id,depth:n+1,onSelect:s,selected:r}):null]})}):e("div",{class:"muted small",style:{padding:"2px 6px"},children:"no resolved calls"})})]})}function Ed({params:t}){let[n,s]=_(t.node??null),[r,a]=_(""),[i,o]=_([]),[l,c]=_(null);return J(()=>{if(r.trim().length<2)return o([]);let d=setTimeout(()=>{O("/api/nodes/search",{q:r.trim(),limit:10}).then(u=>o(u.filter(p=>p.kind!=="file"&&p.kind!=="package"))).catch(()=>o([]))},180);return()=>clearTimeout(d)},[r]),e("div",{class:"grid wide",style:{alignItems:"start"},children:[e("div",{class:"card",children:[e("div",{class:"row",style:{marginBottom:10,position:"relative"},children:[e("span",{class:"muted small",children:"Start"}),e("input",{type:"text",placeholder:"function or method\u2026",value:r,onInput:d=>a(d.target.value),style:{width:320}}),i.length>0&&e("div",{class:"suggest",style:{top:36,left:40},children:i.map(d=>e("div",{onMouseDown:()=>{s(d.id),a(""),o([]),c(null)},children:[e(ye,{kind:d.kind}),e("span",{class:"ellipsis",children:d.label}),e("span",{class:"path",children:d.path})]}))}),e("span",{class:"muted small",children:"Branches are possible static calls from the index, not an execution order."})]}),e("div",{class:"btree",children:n?e(_o,{id:n,depth:0,onSelect:c,selected:l?.root.id??null}):e(B,{children:"Choose a starting operation."})})]}),e("div",{class:"card",children:[e("h3",{children:l?"selected operation":"starting operation"}),l?e(j,{children:[e("div",{class:"row tight",children:[e(ye,{kind:l.root.kind}),e("b",{class:"break",children:l.root.label})]}),e("div",{class:"muted small",children:[l.root.path,l.root.line?`:${l.root.line}`:"",l.root.endLine?`\u2013${l.root.endLine}`:""]}),l.root.complexity?e("div",{class:"row small",style:{marginTop:6},children:[e(P,{children:["complexity ",l.root.complexity]}),e(P,{children:[l.root.loc," loc"]})]}):null,e("div",{class:"row",style:{marginTop:8},children:[l.root.path?e("button",{type:"button",class:"sm",onClick:()=>U("explore",{file:l.root.path,line:l.root.line?String(l.root.line):void 0,symbol:l.root.id}),children:"Open definition"}):null,e("button",{type:"button",class:"sm",onClick:()=>{s(l.root.id),c(null)},children:"Start here"}),e("button",{type:"button",class:"sm",onClick:()=>U("galaxy",{node:l.root.id}),children:"Galaxy"})]})]}):e("div",{class:"muted small",children:"Click an operation in the tree."})]})]})}function So({params:t}){let[n,s]=_(t.tab||"overview");J(()=>{t.tab&&s(t.tab)},[t.tab]);let r=X(()=>O("/api/tree"),[]),a=X(()=>O("/api/architecture",{aspects:"overview,entry_points"}),[]);return e("div",{class:"page",children:[e(Re,{tabs:[["overview","Overview"],["routes","Routes"],["hotspots","Hotspots"],["structure","System structure"],["behavior","Behavior"]],value:n,onChange:s}),n==="overview"&&(r.data?e(wd,{files:r.data.files,arch:a.data}):r.error?e(W,{error:r.error}):e(N,{})),n==="routes"&&e(xd,{}),n==="hotspots"&&e(_d,{}),n==="structure"&&e(Sd,{}),n==="behavior"&&e(Ed,{params:t})]})}function Eo(){let t=X(()=>O("/api/coverage"),[]),[n,s]=_(""),[r,a]=_(""),[i,o]=_(null),l=Z(()=>{let m=r.trim().toLowerCase();return(t.data?.files??[]).filter(b=>(!n||b.status===n)&&(!m||b.path.toLowerCase().includes(m)||(b.reason??"").toLowerCase().includes(m)))},[t.data,n,r]),{sorted:c,th:d}=nt(l,"path",!1),u=async(m,b)=>{o(m);try{let v=await he("/api/actions",b);Y(v.output.split(`
|
|
4
|
-
`)[0]??"done",!v.ok),t.reload()}catch(v){Y(v.message,!0)}finally{o(null)}};if(t.error)return e("div",{class:"page",children:e(W,{error:t.error})});let p=t.data;if(!p)return e("div",{class:"page",children:e(N,{})});let f=p.summary.byStatus,g=Object.values(f).reduce((m,b)=>m+b,0),y=p.freshness.headMatches&&!p.freshness.dirty.length&&!p.freshness.queued,h=[["indexed",f.indexed??0,"parsed into the graph and search"],["partial",f.partial??0,"indexed, syntax errors recovered"],["skipped",f.skipped??0,"too large or parser error"],["unsupported",f.unsupported??0,"matched by globs, no parser"]];return e("div",{class:"page",children:[e("div",{class:"grid",children:[h.map(([m,b,v])=>e("div",{class:A("card"),style:{cursor:"pointer"},onClick:()=>s(n===m?"":m),children:[e("h3",{children:[m,n===m?e("span",{class:"right",children:"filtering"}):null]}),e("div",{class:A("big",m==="skipped"&&b>0&&"bad",m==="partial"&&b>0&&"warn"),children:b}),e("div",{class:"sub",children:v})]})),e("div",{class:"card",children:[e("h3",{children:"freshness"}),e("div",{class:A("big",y?"ok":"warn"),children:y?"fresh":p.freshness.dirty.length||p.freshness.queued?"stale":"git behind"}),e("div",{class:"sub",children:[p.freshness.dirty.length," changed \xB7 ",p.freshness.queued," queued"]})]})]}),e("div",{class:"grid wide",children:[e("div",{class:"card",children:[e("h3",{children:["files"," ",e("span",{class:"right",children:[c.length," of ",g]})]}),e("div",{class:"row",style:{marginBottom:8},children:[e("input",{type:"search",class:"grow",placeholder:"filter by path or reason\u2026",value:r,onInput:m=>a(m.target.value)}),e("select",{value:n,onChange:m=>s(m.target.value),children:[e("option",{value:"",children:"any status"}),["indexed","partial","skipped","unsupported"].map(m=>e("option",{value:m,children:m}))]}),e("button",{type:"button",disabled:!!i,onClick:()=>u("code",{action:"reindex",scope:"code"}),children:i==="code"?e(N,{}):"Reindex code"}),e("button",{type:"button",disabled:!!i,onClick:()=>u("full",{action:"reindex",scope:"code",full:!0}),children:i==="full"?e(N,{}):"Full reindex"})]}),e("div",{class:"list",style:{maxHeight:560},children:e("table",{children:[e("thead",{children:e("tr",{children:[d("path","path"),d("status","status"),d("reason","reason"),d("symbols","symbols",!0),d("size","size",!0),d("indexed_at","indexed",!0),e("th",{})]})}),e("tbody",{children:c.length?c.slice(0,500).map(m=>e("tr",{children:[e("td",{class:"break",children:e("a",{onClick:()=>U("explore",{file:m.path}),children:m.path})}),e("td",{children:e(P,{class:m.status==="indexed"?"s-accepted":m.status==="partial"?"s-proposed":"risk-high",children:m.status})}),e("td",{class:"muted small",children:[m.reason??"",m.errors?e("div",{class:"bad small",children:m.errors.slice(0,160)}):null]}),e("td",{class:"num",children:m.symbols??""}),e("td",{class:"num",children:q(m.size??0)}),e("td",{class:"num muted small",children:te(m.indexed_at)}),e("td",{children:e("button",{type:"button",class:"sm",disabled:!!i,onClick:()=>u(m.path,{action:"reindex",scope:"code",paths:[m.path]}),children:i===m.path?e(N,{}):"reindex"})})]})):e("tr",{children:e("td",{colSpan:7,children:e(B,{children:"no files match"})})})})]})})]}),e("div",{class:"stack",children:[e("div",{class:"card",children:[e("h3",{children:"index state"}),e(Ae,{rows:[["HEAD",p.freshness.head?.slice(0,10)??"no git"],["git signals at",p.freshness.indexedHead?`${p.freshness.indexedHead.slice(0,10)}${p.freshness.headMatches?" (current)":" (behind)"}`:"never"],["last run",p.freshness.lastRun?te(p.freshness.lastRun):"never"],["queued",String(p.freshness.queued)],["last scan",p.scan?.at?`${te(p.scan.at)} \xB7 ${p.scan.scanned} files \xB7 ${p.scan.durationMs} ms`:"n/a"]]})]}),p.freshness.dirty.length?e("div",{class:"card",children:[e("h3",{children:["changed since indexed \xB7 ",p.freshness.dirty.length]}),e("div",{class:"list",style:{maxHeight:200},children:p.freshness.dirty.map(m=>e("div",{class:"item",onClick:()=>U("explore",{file:m}),children:e("div",{class:"p",children:m})}))}),e("button",{type:"button",class:"sm",style:{marginTop:6},disabled:!!i,onClick:()=>u("dirty",{action:"reindex",scope:"code",paths:p.freshness.dirty}),children:i==="dirty"?e(N,{}):"Reindex changed files"})]}):null,p.summary.reasons.length?e("div",{class:"card",children:[e("h3",{children:"why files are not fully indexed"}),e("table",{children:e("tbody",{children:p.summary.reasons.map(m=>e("tr",{class:"click",onClick:()=>a(m.reason),children:[e("td",{children:m.reason}),e("td",{class:"num",children:m.n})]}))})})]}):null,e("div",{class:"card",children:[e("h3",{children:"scope"}),e("div",{class:"small",children:[e("div",{class:"muted",children:"include"}),e("div",{class:"mono break",children:(p.scan?.include??[]).join(" ")||"(defaults)"}),e("div",{class:"muted",style:{marginTop:4},children:"exclude"}),e("div",{class:"mono break",children:(p.scan?.exclude??[]).join(" ")||"(defaults)"}),e("div",{class:"muted",style:{marginTop:6},children:"Change them in eminiar.config.json under graph.include / graph.exclude. A clean coverage result means no recorded gap, not proof of completeness."})]})]})]})]})]})}var Vt=[{id:"readme",group:"project",label:"Readme & guides",blurb:"README, CONTRIBUTING, CHANGELOG and other top-level guides"},{id:"guides",group:"project",label:"Docs folders",blurb:"docs/ directories: handbooks, how-tos, references"},{id:"adr",group:"project",label:"Decision records",blurb:"architecture decision records"},{id:"agent-instructions",group:"project",label:"Agent instructions",blurb:"Copilot, Claude and Cursor instructions, agents and skills"},{id:"api-specs",group:"project",label:"API specs",blurb:"OpenAPI, Postman, GraphQL and protobuf definitions"},{id:"env-reference",group:"project",label:"Environment reference",blurb:".env examples: every variable the project reads"},{id:"deploy-config",group:"project",label:"Deploy config",blurb:"Terraform, Kubernetes, Helm, Compose and CI workflows"},{id:"local",group:"project",label:"Other local files",blurb:"hand-registered paths"},{id:"service",group:"external",label:"Services",blurb:"third-party products and APIs the project integrates"},{id:"api",group:"external",label:"External APIs",blurb:"hosts the code calls, found by probing their docs"},{id:"infra",group:"external",label:"Infrastructure",blurb:"platforms the project runs on"},{id:"library",group:"external",label:"Libraries",blurb:"frameworks and packages"},{id:"web",group:"external",label:"Web pages",blurb:"hand-registered URLs"}],$o=new Map(Vt.map(t=>[t.id,t]));function Jn(t){return $o.get(t)??$o.get("local")}var To={project:"Project documentation",external:"External documentation"};function sr(t){let n=Vt.findIndex(s=>s.id===t);return n===-1?Vt.length:n}function jt({title:t,rows:n,label:s,onPick:r,max:a=60}){return e("div",{class:"section",children:[e("h4",{children:[t," \xB7 ",n.length]}),e("table",{children:e("tbody",{children:n.slice(0,a).map(i=>e("tr",{class:"click",onClick:()=>r(i.id),children:[e("td",{children:e(P,{children:i.kind})}),e("td",{class:"break",children:s(i.id)})]}))})}),n.length>a?e("div",{class:"muted small",children:["\u2026 ",n.length-a," more"]}):null]})}function $d(t,n){if(n.hiddenKinds.has(t.kind))return!1;if(t.group==="memory"&&!t.missing){let s=t.status??"accepted";if(n.hideSuperseded&&s==="superseded"||n.status&&s!==n.status)return!1}return!(t.group==="doc"&&!t.missing&&n.category&&t.sub!==n.category)}function Xn(t,n){let s=new Set(t.nodes.filter(o=>$d(o,n)).map(o=>o.id)),r=t.edges.filter(o=>!n.hiddenEdges.has(o.kind)&&s.has(o.src)&&s.has(o.dst)),a=new Set(r.flatMap(o=>[o.src,o.dst]));return{nodes:t.nodes.filter(o=>s.has(o.id)&&(o.seed||o.root||a.has(o.id))),edges:r}}function gt(t,n){let s=new Map;for(let r of t)s.set(n(r),(s.get(n(r))??0)+1);return s}var Td={memory:"diamond",doc:"square",tag:"triangle",topic:"hexagon"};function zn(t){return t.missing?"ring":Td[t.kind]??"circle"}function Gn(t){let n=t;return n.group==="memory"&&(n.status==="superseded"||n.status==="deprecated")?"#93c5fd":De(t.kind)}function Zt(t){let n={links:[4,3],supersedes:[6,3],about:[2,3],tagged:[1,3],in_topic:[1,3]};return{color:Et(t),dash:n[t],width:t==="documents"||t==="mentions"?1.4:1,alpha:t==="tagged"||t==="in_topic"?.35:.55,directed:Sn.has(t)}}function Co(t){let n=t;return n.group==="memory"||n.group==="doc"||n.group==="hub"||t.kind==="package"?t.label:t.kind==="file"?t.label.split("/").pop()??t.label:t.label.split(".").pop()??t.label}var Cd=["proposed","accepted","superseded","deprecated"],Ad=["memory","doc","topic","tag","file","package"],Rd=["mentions","links","supersedes","documents","about","tagged","in_topic"],Md={mentions:"a memory's related: header names it",links:"a mem: link in a memory's body",supersedes:"a decision that replaces another",documents:"a doc source covers this package or names this file",about:"a memory relates to a page of this local doc source",tagged:"carries this tag",in_topic:"memory topic or doc category"},Ao=(t,n)=>[...t].sort((s,r)=>{let a=n.indexOf(s),i=n.indexOf(r);return(a===-1?99:a)-(i===-1?99:i)||s.localeCompare(r)});function Ro(t,n){let s=new Set(t);return s.has(n)?s.delete(n):s.add(n),s}function Wn({scope:t,focus:n}){let s=t==="docs"?"docs":"memory",[r,a]=_(null),[i,o]=_(!1),[l,c]=_(0),[d,u]=_(new Set),[p,f]=_(new Set),[g,y]=_(""),[h,m]=_(""),[b,v]=_(t==="memory"),[k,w]=_(!1),[S,E]=_(n??null);J(()=>{let D=!0;return o(!0),O("/api/knowledge",{scope:t,focus:n,limit:300}).then(V=>{D&&(a(V),E(n??null))}).catch(V=>D&&Y(V.message,!0)).finally(()=>D&&o(!1)),()=>{D=!1}},[t,n,l]);let x=Z(()=>r?Xn(r,{hiddenKinds:d,hiddenEdges:p,status:g,category:h,hideSuperseded:b}):null,[r,d,p,g,h,b]),$=Z(()=>gt(r?.nodes??[],D=>D.kind),[r]),M=Z(()=>gt(r?.edges??[],D=>D.kind),[r]),I=D=>r?.nodes.find(V=>V.kind===D&&!V.missing),C=Z(()=>[...new Set((r?.nodes??[]).filter(D=>D.group==="doc"&&D.sub).map(D=>D.sub))],[r]),L=(r?.nodes??[]).some(D=>D.group==="memory"),T=Z(()=>new Map((r?.nodes??[]).map(D=>[D.id,D])),[r]),F=S?T.get(S):void 0,H=x?.edges??[],K=F?H.filter(D=>D.dst===F.id):[],R=F?H.filter(D=>D.src===F.id):[],z=D=>T.get(D)?.label??D,se=D=>U(s,{tab:"graph",focus:D}),Ee=n?T.get(n):void 0;return e("div",{class:"kgalaxy",children:[e("div",{class:"gtoolbar",children:[n?e("span",{class:"row tight",children:[e("span",{class:"muted small",children:"focused on"}),e("b",{class:"break",children:Ee?.label??n}),e("button",{type:"button",class:"sm",onClick:()=>U(s,{tab:"graph"}),children:"Show all"})]}):e("span",{class:"muted small",children:t==="docs"?"documentation sources and what they cover":"memories and what they are about"}),L?e(j,{children:[e("select",{value:g,title:"memory status",onChange:D=>y(D.target.value),children:[e("option",{value:"",children:"any status"}),Cd.map(D=>e("option",{value:D,children:D}))]}),e("button",{type:"button",class:A("chip",b&&"on"),onClick:()=>v(!b),children:"hide superseded"})]}):null,C.length?e("select",{value:h,title:"doc category",onChange:D=>m(D.target.value),children:[e("option",{value:"",children:"any category"}),C.map(D=>e("option",{value:D,children:Jn(D).label}))]}):null,e("button",{type:"button",class:A("chip",k&&"on"),onClick:()=>w(!k),children:"legend"}),e("button",{type:"button",class:"sm",title:"reload",onClick:()=>c(D=>D+1),children:"\u21BB"}),e("span",{class:"count",children:i?e(N,{}):x&&r?`${x.nodes.length} of ${r.nodes.length} nodes \xB7 ${x.edges.length} edges${r.truncated?` \xB7 first ${r.nodes.length} of ${r.total}`:""}`:""})]}),e("div",{class:"gtoolbar",style:{paddingTop:4,paddingBottom:6},children:[e("span",{class:"muted small",children:"nodes:"}),Ao([...$.keys()],Ad).map(D=>{let V=I(D);return e("button",{type:"button",class:A("chip",!d.has(D)&&"on"),onClick:()=>u(Ro(d,D)),children:[V?e(rt,{shape:zn(V),color:Gn(V)}):null,D," ",$.get(D)]})}),e("span",{class:"muted small",style:{marginLeft:8},children:"edges:"}),Ao([...M.keys()],Rd).map(D=>{let V=Zt(D);return e("button",{type:"button",title:Md[D],class:A("chip",!p.has(D)&&"on"),onClick:()=>f(Ro(p,D)),children:[e(Mt,{color:V.color,dash:V.dash}),D," ",M.get(D)]})})]}),e("div",{class:"kbody",style:{gridTemplateColumns:F?"minmax(0,1fr) 320px":"minmax(0,1fr)"},children:[e("div",{style:{minWidth:0,minHeight:0},children:x?x.nodes.length?e(We,{nodes:x.nodes,edges:x.edges,selected:S,onSelect:E,onActivate:se,legend:k,colorOf:Gn,shapeOf:zn,edgeStyleOf:Zt,labelOf:Co}):r?.nodes.length?e(B,{children:"Nothing left after these filters."}):t==="docs"?e(B,{children:"No documentation sources yet. Add some from Discover."}):e(B,{children:"No memories yet."}):e(B,{children:e(N,{})})}),F&&e("div",{class:"panel right",children:[e("div",{class:"head",children:["selection ",e("span",{class:"spacer"}),e("a",{onClick:()=>E(null),children:"close"})]}),e("div",{class:"body",children:[e(jd,{node:F,focus:n,onFocus:se}),e(jt,{title:"incoming",rows:K.map(D=>({kind:D.kind,id:D.src})),label:z,onPick:E}),e(jt,{title:"outgoing",rows:R.map(D=>({kind:D.kind,id:D.dst})),label:z,onPick:E})]})]})]})]})}function jd({node:t,focus:n,onFocus:s}){let r=t.group==="hub";return e("div",{class:"section",children:[e("div",{class:"row tight",children:[e(rt,{shape:zn(t),color:Gn(t)}),e(ye,{kind:t.kind}),e("b",{class:"break",children:t.label})]}),e("div",{class:"row tight wrap",style:{marginTop:4},children:[t.sub&&t.group==="memory"?e(P,{children:t.sub}):null,t.status?e("span",{class:`tag s-${t.status}`,children:t.status}):null,t.group==="doc"&&t.detail?e(P,{children:t.detail}):null,t.provider?e(P,{children:t.provider}):null,(t.tags??[]).map(a=>e(P,{children:["#",a]}))]}),t.path&&t.group==="code"&&t.kind!=="file"?e("div",{class:"muted small",children:[t.path,t.line?`:${t.line}`:""]}):null,t.missing?e("div",{class:"muted small",style:{marginTop:4},children:"Referenced, but nothing defines it: a deleted or renamed memory, a file outside the index, or a package the code does not import."}):null,e("div",{class:"row wrap",style:{marginTop:8},children:[t.id!==n?e("button",{type:"button",class:"sm primary",onClick:()=>s(t.id),children:"Focus here"}):null,t.group==="memory"&&!t.missing?e("button",{type:"button",class:"sm",onClick:()=>U("memory",{name:t.label}),children:"Open memory"}):null,t.group==="doc"&&!t.missing?e("button",{type:"button",class:"sm",onClick:()=>U("docs",{tab:"sources",name:t.label}),children:"Open doc source"}):null,!r&&!t.missing?e("button",{type:"button",class:"sm",onClick:()=>U("galaxy",{node:t.id}),children:"Open in code galaxy"}):null,t.kind==="file"&&t.path&&!t.missing?e("button",{type:"button",class:"sm",onClick:()=>U("explore",{file:t.path}),children:"Open source"}):null]})]})}var Ld={url:"#2563eb",path:"#16a34a"},Id={catalog:"#16a34a",probe:"#2563eb",registry:"#d97706",unknown:"#6b7280"};function jo({kind:t}){return e("span",{class:"tag kind",style:{color:Ld[t]??"#6b7280"},children:t})}function Lo({urls:t}){return e("span",{class:"break",children:t.map((n,s)=>e(j,{children:[s?", ":"",e("a",{href:n,target:"_blank",rel:"noreferrer",children:n})]}))})}function Fd({s:t,busy:n,onSync:s,onRemove:r}){let a=X(()=>O("/api/docs/pages",{name:t.name}),[t.name,t.sync?.at]),i=[["kind",e(jo,{kind:t.kind})],...t.provider?[["provider",t.provider]]:[],...t.title?[["title",t.title]]:[],t.kind==="url"?["seeds",e(Lo,{urls:t.urls??[]})]:["path",`${t.path}${t.glob?.length?` [${t.glob.join(", ")}]`:""}`],...t.kind==="url"?[["crawl",`depth ${t.crawl?.depth??"default"}, max ${t.crawl?.maxPages??"default"} pages, ttl ${t.ttlHours??"default"} h`]]:[],...t.tags?.length?[["tags",t.tags.join(", ")]]:[],["added",t.addedAt.slice(0,10)],["last sync",t.sync?`${te(t.sync.at)} \xB7 ${t.sync.pages} ${t.kind==="url"?"pages":"files"} \xB7 ${t.sync.documents} docs \xB7 ${t.sync.chunks} chunks \xB7 ${t.sync.ms} ms${t.sync.errors.length?` \xB7 ${t.sync.errors.length} error(s)`:""}`:"never"]];return e("div",{children:[e("div",{class:"row",style:{marginBottom:6},children:[e("b",{class:"grow break",children:t.name}),e("button",{type:"button",class:"sm",disabled:!!n,onClick:()=>s(!1),children:n===`sync ${t.name}`?e(N,{}):"sync"}),e("button",{type:"button",class:"sm",disabled:!!n,title:"refetch ignoring the cache and drop stale pages",onClick:()=>s(!0),children:"force"}),e("button",{type:"button",class:"sm",title:"this source in the knowledge graph",onClick:()=>U("docs",{tab:"graph",focus:`doc:${t.name}`}),children:"graph"}),e("button",{type:"button",class:"sm danger",disabled:!!n,onClick:r,children:"remove"})]}),e(Ae,{rows:i}),t.sync?.errors.length?e("pre",{class:"log",style:{marginTop:8},children:t.sync.errors.join(`
|
|
5
|
-
`)}):null,e("h3",{style:{marginTop:12},children:["indexed pages ",e("span",{class:"muted small",children:["(",t.documents,")"]})]}),
|
|
6
|
-
`):Mo(t),children:[e(jo,{kind:t.kind}),t.provider?e("span",{class:"muted",children:[t.provider," \xB7 "]}):null,e("span",{class:"muted",children:Mo(t)})]}),e("div",{class:"p",children:e("span",{class:"muted",children:[t.documents," docs \xB7 ",t.chunks," chunks \xB7"," ",t.sync?`synced ${te(t.sync.at)}`:"never synced",t.sync?.errors.length?e("span",{class:"bad",children:[" \xB7 ",t.sync.errors.length," errors"]}):null]})})]})}function Od({params:t,onLog:n}){let s=X(()=>O("/api/docs"),[]),[r,a]=_(t.name??null),[i,o]=_(""),[l,c]=_(!1),[d,u]=_(null);J(()=>{t.name&&a(t.name)},[t.name]);let[p,f]=_("all"),[g,y]=_(new Set),h=s.data,m=Z(()=>{let x=i.trim().toLowerCase();return(h?.sources??[]).filter($=>(p==="all"||$.category===p)&&(!x||$.name.includes(x)||($.title??"").toLowerCase().includes(x)||($.provider??"").includes(x)||($.tags??[]).some(M=>M.includes(x))||($.urls??[]).some(M=>M.includes(x))||($.path??"").includes(x)))},[h,i,p]),b=Z(()=>{let x=new Map;for(let $ of h?.sources??[])x.set($.category,(x.get($.category)??0)+1);return x},[h]),v=Z(()=>{let x=new Map;for(let I of m){let C=x.get(I.category)??[];C.push(I),x.set(I.category,C)}let $=[...x.entries()].sort((I,C)=>sr(I[0])-sr(C[0])).map(([I,C])=>({info:Jn(I),items:C.sort((L,T)=>rr(L).localeCompare(rr(T)))})),M=[];for(let I of $){let C=M[M.length-1];C?.group===I.info.group?C.cats.push(I):M.push({group:I.info.group,label:To[I.info.group],cats:[I]})}return M},[m]),k=x=>y($=>{let M=new Set($);return M.has(x)?M.delete(x):M.add(x),M}),w=m.find(x=>x.name===r)??h?.sources.find(x=>x.name===r),S=async(x,$)=>{let M=x?.length===1?`sync ${x[0]}`:"sync all";u(M);try{let I=await he("/api/docs/sync",{names:x,force:$});n(I.text),Y(`${M} done`),s.reload()}catch(I){Y(I.message,!0)}finally{u(null)}},E=async x=>{if(confirm(`Remove documentation source "${x}" and its indexed pages?`))try{let $=await xn("/api/docs",{name:x});Y(`removed ${x} (${$.documents} document(s))`),a(null),s.reload()}catch($){Y($.message,!0)}};return s.error?e(W,{error:s.error}):e(j,{children:[e("div",{class:"row",style:{marginBottom:12},children:[e("button",{type:"button",class:"primary",onClick:()=>c(x=>!x),children:l?"close":"+ Add source"}),e("button",{type:"button",disabled:!!d||!h?.sources.length,onClick:()=>S(void 0,!1),children:d==="sync all"?e(N,{}):"\u21BB Sync all"}),e("input",{type:"search",class:"grow",placeholder:"filter by name, provider, tag or url\u2026",value:i,onInput:x=>o(x.target.value)}),e("span",{class:"muted small nowrap",children:h?`${h.sources.length} sources \xB7 ${q(h.totals.documents)} docs \xB7 ${q(h.totals.chunks)} chunks \xB7 ${h.manifest}`:""})]}),h?.sources.length?e("div",{class:"row wrap",style:{marginBottom:10,gap:4},children:[e("button",{type:"button",class:A("chip",p==="all"&&"on"),onClick:()=>f("all"),children:["All \xB7 ",h.sources.length]}),Vt.filter(x=>b.get(x.id)).map(x=>e("button",{type:"button",class:A("chip",p===x.id&&"on"),title:x.blurb,onClick:()=>f(p===x.id?"all":x.id),children:[x.label," \xB7 ",b.get(x.id)]}))]}):null,l&&e(Pd,{onDone:x=>{n(x.text),s.reload();let $=[...x.added,...x.updated][0];$&&a($)}}),h?.orphans.length?e("div",{class:"empty",style:{marginBottom:12},children:["indexed under docs: but missing from the manifest:"," ",h.orphans.map(x=>`${x.source} (${x.documents})`).join(", ")," \u2014 re-add them or purge the index."]}):null,e("div",{class:"grid wide",style:{gridTemplateColumns:"minmax(280px,1fr) minmax(0,2fr)",alignItems:"start"},children:[e("div",{class:"card flush",children:e("div",{class:"list",children:h?m.length?v.map(x=>e(j,{children:[v.length>1?e("div",{class:"group-h",children:x.label}):null,x.cats.map(({info:$,items:M})=>{let I=!g.has($.id);return e(j,{children:[e("div",{class:A("cat-h",!I&&"closed"),title:$.blurb,onClick:()=>k($.id),children:[e("span",{class:"caret",children:I?"\u25BE":"\u25B8"}),$.label,e("span",{class:"muted",children:[" \xB7 ",M.length]}),e("span",{class:"muted small right",children:[q(M.reduce((C,L)=>C+L.documents,0))," docs"]})]}),I?M.map(C=>e(Dd,{s:C,sel:r===C.name,onSelect:()=>a(C.name)})):null]})})]})):e(B,{children:h.sources.length?"no sources match":"No documentation sources yet. Use Discover, or add a url, path or provider."}):e(B,{children:e(N,{})})})}),e("div",{class:"card",children:w?e(Fd,{s:w,busy:d,onSync:x=>S([w.name],x),onRemove:()=>E(w.name)}):e(B,{children:"Select a source to see its pages and sync state."})})]})]})}function Nd({onLog:t,onAdded:n}){let[s,r]=_(!1),[a,i]=_(!1),o=X(()=>a?O("/api/docs/discover",{dev:s?1:void 0}):Promise.resolve(void 0),[a,s]),[l,c]=_(new Set),[d,u]=_({}),[p,f]=_(!1),g=o.data;J(()=>{if(!g)return;let k=new Set;for(let w of g.local)w.registered||k.add(`local:${w.name}`);for(let w of g.providers)!w.registered&&(w.confidence==="probe"||w.confidence==="catalog"&&w.tier!=="library"&&w.tier!=="infra")&&k.add(`prov:${w.name}`);c(k)},[g]);let y=k=>c(w=>{let S=new Set(w);return S.has(k)?S.delete(k):S.add(k),S}),h=async()=>{if(!g)return;let k=[];for(let w of g.local)l.has(`local:${w.name}`)&&k.push({name:w.name,path:w.path,glob:w.glob,title:w.why,tags:w.project?[w.project]:void 0});for(let w of g.providers){if(!l.has(`prov:${w.name}`))continue;let S=d[w.name]?.trim(),E=S?S.split(/\s+/).filter(Boolean):w.urls.length?w.urls:void 0;!E&&w.confidence==="unknown"||k.push({name:w.name,provider:w.provider,urls:E,title:w.title,crawl:w.crawl})}if(!k.length)return Y("nothing selected",!0);f(!0),t(`adding ${k.length} source(s)\u2026`);try{let w=await he("/api/docs",{sources:k,sync:!0});t(w.text),Y(`${w.added.length+w.updated.length} added${w.failed.length?`, ${w.failed.length} failed`:""}`,!!w.failed.length&&!w.added.length),n(),i(!1),setTimeout(()=>i(!0),0)}catch(w){Y(w.message,!0)}finally{f(!1)}},m=k=>(g?.providers??[]).filter(w=>w.confidence===k),b=({keyId:k,title:w,meta:S,right:E,registered:x})=>e("tr",{class:A(x&&"muted"),children:[e("td",{style:{width:24},children:e("input",{type:"checkbox",disabled:x,checked:l.has(k),onChange:()=>y(k)})}),e("td",{class:"break",children:[w,x?e("span",{class:"tag",children:" registered"}):null]}),e("td",{class:"break muted small",children:S}),e("td",{children:E??null})]}),v=({conf:k,note:w})=>{let S=m(k);return S.length?e("div",{class:"card flush",style:{marginBottom:12},children:[e("h3",{style:{padding:"10px 12px 0"},children:[e("span",{class:"tag kind",style:{color:Id[k]},children:k})," ",k==="catalog"?"libraries, services and infrastructure":k==="probe"?"third-party APIs called from code":k==="registry"?"packages resolved through npm / PyPI / Go":"unknown env prefixes and images"," ",e("span",{class:"muted small",children:["\u2014 ",w]})]}),e("table",{children:e("tbody",{children:S.map(E=>e(b,{keyId:`prov:${E.name}`,registered:E.registered,title:e(j,{children:[e("b",{children:E.name})," ",e("span",{class:"muted small",children:["\u2190 ",E.provider]})]}),meta:e(j,{children:[E.title,E.usedBy.length>1?` \xB7 used by ${E.usedBy.length} projects`:E.usedBy[0]&&E.usedBy[0]!=="."?` \xB7 ${E.usedBy[0]}`:"",E.urls.length?e(j,{children:[" \xB7 ",e(Lo,{urls:E.urls.slice(0,2)})]}):k==="probe"||k==="unknown"?` \xB7 ${E.evidence[0]}`:""]}),right:k==="unknown"||k==="probe"?e("input",{type:"text",placeholder:k==="probe"?"docs url (optional; probed if empty)":"docs url",style:{minWidth:220},value:d[E.name]??"",onInput:x=>u({...d,[E.name]:x.target.value})}):void 0}))})})]}):null};return e(j,{children:[e("div",{class:"row",style:{marginBottom:12},children:[e("button",{type:"button",class:"primary",disabled:o.loading&&a,onClick:()=>a?o.reload():i(!0),children:o.loading&&a?e(N,{}):a?"\u21BB Scan again":"Scan project"}),e("label",{class:"small",children:[e("input",{type:"checkbox",checked:s,onChange:k=>r(k.target.checked)})," ","include devDependencies"]}),e("span",{class:"spacer"}),g?e(j,{children:[e("span",{class:"muted small",children:[g.projects.length>1?`${g.projects.length} projects \xB7 `:"",g.local.length," local \xB7 ",g.providers.length," providers \xB7 ",l.size," selected"]}),e("button",{type:"button",class:"primary",disabled:p||!l.size,onClick:h,children:p?e(N,{}):"Add selected & index"})]}):null]}),o.error?e(W,{error:o.error}):null,a?g?e(j,{children:[g.local.length?e("div",{class:"card flush",style:{marginBottom:12},children:[e("h3",{style:{padding:"10px 12px 0"},children:["local documentation ",e("span",{class:"muted small",children:"\u2014 indexed from the working tree"})]}),e("table",{children:e("tbody",{children:g.local.map(k=>e(b,{keyId:`local:${k.name}`,registered:k.registered,title:e(j,{children:[e("b",{children:k.name})," ",e("span",{class:"muted small",children:k.path})]}),meta:`${k.files} file(s) \xB7 ${q(k.bytes)} B \xB7 ${k.why}${k.glob&&k.glob.length<=4?` \xB7 ${k.glob.join(", ")}`:""}`}))})})]}):null,e(v,{conf:"catalog",note:"documentation URLs known offline"}),e(v,{conf:"probe",note:"docs., developer. and /docs locations are probed when added; give a url to skip the guess"}),e(v,{conf:"registry",note:"homepage and README come from the package registry when added"}),e(v,{conf:"unknown",note:"needs a documentation url"})]}):e(N,{}):e(B,{children:"Scans the project (and one level of sub-projects) for READMEs, docs folders, ADRs, API specs, agent instructions and env references, plus the npm / PyPI / Go packages, env var prefixes, container images, infrastructure files and outbound API calls \u2014 and maps each to its documentation. Nothing is fetched until you add."})]})}function Ud({sources:t}){let[n,s]=_(""),[r,a]=_(""),[i,o]=_(""),l=X(()=>i?O("/api/search",{q:i,source:r?`docs:${r}`:"docs:*",limit:15}):Promise.resolve(void 0),[i,r]);return e(j,{children:[e("div",{class:"row",style:{marginBottom:12},children:[e("input",{type:"search",class:"grow",placeholder:"ask the documentation\u2026 (hybrid keyword + semantic)",value:n,onInput:c=>s(c.target.value),onKeyDown:c=>{c.key==="Enter"&&o(n.trim())}}),e("select",{value:r,onChange:c=>a(c.target.value),children:[e("option",{value:"",children:"all documentation"}),t.map(c=>e("option",{value:c,children:c}))]}),e("button",{type:"button",class:"primary",onClick:()=>o(n.trim()),children:"Search"})]}),l.error?e(W,{error:l.error}):null,i?l.data?l.data.hits.length?e("div",{class:"stack",children:[l.data.corrections.length?e("div",{class:"muted small",children:["corrected: ",l.data.corrections.map(c=>`${c.from}\u2192${c.to}`).join(", ")]}):null,l.data.hits.map(c=>e("div",{class:"card hit",children:[e("div",{class:"row tight",children:[e("b",{class:"break",children:c.uri?.startsWith("http")?e("a",{href:c.uri,target:"_blank",rel:"noreferrer",children:c.title}):c.title}),e("span",{class:"tag",children:c.source.replace(/^docs:/,"")}),e("span",{class:"muted small",children:["doc ",c.doc," \xB7 ",c.score.toFixed(3)]})]}),e("pre",{class:"json",style:{whiteSpace:"pre-wrap",fontFamily:"inherit",fontSize:13,marginTop:4},children:c.snippet})]}))]}):e(B,{children:"no matches"}):e(N,{}):e(B,{children:"Searches only the documentation sources (source docs:*). Claude uses the same index through em_docs lookup."})]})}function Io({params:t}){let[n,s]=_(t.tab??"sources"),[r,a]=_([]),[i,o]=_(0),l=X(()=>O("/api/docs"),[i]),c=d=>a(u=>[...u,`[${new Date().toLocaleTimeString()}]
|
|
7
|
-
${
|
|
1
|
+
"use strict";(()=>{var Gu=Object.create;var jr=Object.defineProperty;var Wu=Object.getOwnPropertyDescriptor;var zu=Object.getOwnPropertyNames;var qu=Object.getPrototypeOf,Ku=Object.prototype.hasOwnProperty;var Mo=t=>{throw TypeError(t)};var Vu=(t,n,s)=>n in t?jr(t,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[n]=s;var Yu=(t,n)=>()=>(n||t((n={exports:{}}).exports,n),n.exports);var Zu=(t,n,s,a)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of zu(n))!Ku.call(t,r)&&r!==s&&jr(t,r,{get:()=>n[r],enumerable:!(a=Wu(n,r))||a.enumerable});return t};var Qu=(t,n,s)=>(s=t!=null?Gu(qu(t)):{},Zu(n||!t||!t.__esModule?jr(s,"default",{value:t,enumerable:!0}):s,t));var be=(t,n,s)=>Vu(t,typeof n!="symbol"?n+"":n,s),ep=(t,n,s)=>n.has(t)||Mo("Cannot "+s);var Do=(t,n,s)=>n.has(t)?Mo("Cannot add the same private member more than once"):n instanceof WeakSet?n.add(t):n.set(t,s);var Lo=(t,n,s)=>(ep(t,n,"access private method"),s);var Lc=Yu((ik,sr)=>{"use strict";var Jm=typeof window<"u"?window:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?self:{};var Q=(function(t){var n=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,s=0,a={},r={manual:t.Prism&&t.Prism.manual,disableWorkerMessageHandler:t.Prism&&t.Prism.disableWorkerMessageHandler,util:{encode:function m(f){return f instanceof o?new o(f.type,m(f.content),f.alias):Array.isArray(f)?f.map(m):f.replace(/&/g,"&").replace(/</g,"<").replace(/\u00a0/g," ")},type:function(m){return Object.prototype.toString.call(m).slice(8,-1)},objId:function(m){return m.__id||Object.defineProperty(m,"__id",{value:++s}),m.__id},clone:function m(f,v){v=v||{};var b,w;switch(r.util.type(f)){case"Object":if(w=r.util.objId(f),v[w])return v[w];b={},v[w]=b;for(var k in f)f.hasOwnProperty(k)&&(b[k]=m(f[k],v));return b;case"Array":return w=r.util.objId(f),v[w]?v[w]:(b=[],v[w]=b,f.forEach(function(C,S){b[S]=m(C,v)}),b);default:return f}},getLanguage:function(m){for(;m;){var f=n.exec(m.className);if(f)return f[1].toLowerCase();m=m.parentElement}return"none"},setLanguage:function(m,f){m.className=m.className.replace(RegExp(n,"gi"),""),m.classList.add("language-"+f)},currentScript:function(){if(typeof document>"u")return null;if(document.currentScript&&document.currentScript.tagName==="SCRIPT")return document.currentScript;try{throw new Error}catch(b){var m=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(b.stack)||[])[1];if(m){var f=document.getElementsByTagName("script");for(var v in f)if(f[v].src==m)return f[v]}return null}},isActive:function(m,f,v){for(var b="no-"+f;m;){var w=m.classList;if(w.contains(f))return!0;if(w.contains(b))return!1;m=m.parentElement}return!!v}},languages:{plain:a,plaintext:a,text:a,txt:a,extend:function(m,f){var v=r.util.clone(r.languages[m]);for(var b in f)v[b]=f[b];return v},insertBefore:function(m,f,v,b){b=b||r.languages;var w=b[m],k={};for(var C in w)if(w.hasOwnProperty(C)){if(C==f)for(var S in v)v.hasOwnProperty(S)&&(k[S]=v[S]);v.hasOwnProperty(C)||(k[C]=w[C])}var _=b[m];return b[m]=k,r.languages.DFS(r.languages,function(T,M){M===_&&T!=m&&(this[T]=k)}),k},DFS:function m(f,v,b,w){w=w||{};var k=r.util.objId;for(var C in f)if(f.hasOwnProperty(C)){v.call(f,C,f[C],b||C);var S=f[C],_=r.util.type(S);_==="Object"&&!w[k(S)]?(w[k(S)]=!0,m(S,v,null,w)):_==="Array"&&!w[k(S)]&&(w[k(S)]=!0,m(S,v,C,w))}}},plugins:{},highlightAll:function(m,f){r.highlightAllUnder(document,m,f)},highlightAllUnder:function(m,f,v){var b={callback:v,container:m,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};r.hooks.run("before-highlightall",b),b.elements=Array.prototype.slice.apply(b.container.querySelectorAll(b.selector)),r.hooks.run("before-all-elements-highlight",b);for(var w=0,k;k=b.elements[w++];)r.highlightElement(k,f===!0,b.callback)},highlightElement:function(m,f,v){var b=r.util.getLanguage(m),w=r.languages[b];r.util.setLanguage(m,b);var k=m.parentElement;k&&k.nodeName.toLowerCase()==="pre"&&r.util.setLanguage(k,b);var C=m.textContent,S={element:m,language:b,grammar:w,code:C};function _(M){S.highlightedCode=M,r.hooks.run("before-insert",S),S.element.innerHTML=S.highlightedCode,r.hooks.run("after-highlight",S),r.hooks.run("complete",S),v&&v.call(S.element)}if(r.hooks.run("before-sanity-check",S),k=S.element.parentElement,k&&k.nodeName.toLowerCase()==="pre"&&!k.hasAttribute("tabindex")&&k.setAttribute("tabindex","0"),!S.code){r.hooks.run("complete",S),v&&v.call(S.element);return}if(r.hooks.run("before-highlight",S),!S.grammar){_(r.util.encode(S.code));return}if(f&&t.Worker){var T=new Worker(r.filename);T.onmessage=function(M){_(M.data)},T.postMessage(JSON.stringify({language:S.language,code:S.code,immediateClose:!0}))}else _(r.highlight(S.code,S.grammar,S.language))},highlight:function(m,f,v){var b={code:m,grammar:f,language:v};if(r.hooks.run("before-tokenize",b),!b.grammar)throw new Error('The language "'+b.language+'" has no grammar.');return b.tokens=r.tokenize(b.code,b.grammar),r.hooks.run("after-tokenize",b),o.stringify(r.util.encode(b.tokens),b.language)},tokenize:function(m,f){var v=f.rest;if(v){for(var b in v)f[b]=v[b];delete f.rest}var w=new c;return u(w,w.head,m),l(m,w,f,w.head,0),p(w)},hooks:{all:{},add:function(m,f){var v=r.hooks.all;v[m]=v[m]||[],v[m].push(f)},run:function(m,f){var v=r.hooks.all[m];if(!(!v||!v.length))for(var b=0,w;w=v[b++];)w(f)}},Token:o};t.Prism=r;function o(m,f,v,b){this.type=m,this.content=f,this.alias=v,this.length=(b||"").length|0}o.stringify=function m(f,v){if(typeof f=="string")return f;if(Array.isArray(f)){var b="";return f.forEach(function(_){b+=m(_,v)}),b}var w={type:f.type,content:m(f.content,v),tag:"span",classes:["token",f.type],attributes:{},language:v},k=f.alias;k&&(Array.isArray(k)?Array.prototype.push.apply(w.classes,k):w.classes.push(k)),r.hooks.run("wrap",w);var C="";for(var S in w.attributes)C+=" "+S+'="'+(w.attributes[S]||"").replace(/"/g,""")+'"';return"<"+w.tag+' class="'+w.classes.join(" ")+'"'+C+">"+w.content+"</"+w.tag+">"};function i(m,f,v,b){m.lastIndex=f;var w=m.exec(v);if(w&&b&&w[1]){var k=w[1].length;w.index+=k,w[0]=w[0].slice(k)}return w}function l(m,f,v,b,w,k){for(var C in v)if(!(!v.hasOwnProperty(C)||!v[C])){var S=v[C];S=Array.isArray(S)?S:[S];for(var _=0;_<S.length;++_){if(k&&k.cause==C+","+_)return;var T=S[_],M=T.inside,F=!!T.lookbehind,D=!!T.greedy,$=T.alias;if(D&&!T.pattern.global){var L=T.pattern.toString().match(/[imsuy]*$/)[0];T.pattern=RegExp(T.pattern.source,L+"g")}for(var K=T.pattern||T,Y=b.next,ne=w;Y!==f.tail&&!(k&&ne>=k.reach);ne+=Y.value.length,Y=Y.next){var O=Y.value;if(f.length>m.length)return;if(!(O instanceof o)){var A=1,W;if(D){if(W=i(K,ne,m,F),!W||W.index>=m.length)break;var fe=W.index,ye=W.index+W[0].length,B=ne;for(B+=Y.value.length;fe>=B;)Y=Y.next,B+=Y.value.length;if(B-=Y.value.length,ne=B,Y.value instanceof o)continue;for(var re=Y;re!==f.tail&&(B<ye||typeof re.value=="string");re=re.next)A++,B+=re.value.length;A--,O=m.slice(ne,B),W.index-=ne}else if(W=i(K,0,O,F),!W)continue;var fe=W.index,dt=W[0],ue=O.slice(0,fe),ge=O.slice(fe+dt.length),de=ne+O.length;k&&de>k.reach&&(k.reach=de);var Ce=Y.prev;ue&&(Ce=u(f,Ce,ue),ne+=ue.length),d(f,Ce,A);var oe=new o(C,M?r.tokenize(dt,M):dt,$,dt);if(Y=u(f,Ce,oe),ge&&u(f,Y,ge),A>1){var we={cause:C+","+_,reach:de};l(m,f,v,Y.prev,ne,we),k&&we.reach>k.reach&&(k.reach=we.reach)}}}}}}function c(){var m={value:null,prev:null,next:null},f={value:null,prev:m,next:null};m.next=f,this.head=m,this.tail=f,this.length=0}function u(m,f,v){var b=f.next,w={value:v,prev:f,next:b};return f.next=w,b.prev=w,m.length++,w}function d(m,f,v){for(var b=f.next,w=0;w<v&&b!==m.tail;w++)b=b.next;f.next=b,b.prev=f,m.length-=w}function p(m){for(var f=[],v=m.head.next;v!==m.tail;)f.push(v.value),v=v.next;return f}if(!t.document)return t.addEventListener&&(r.disableWorkerMessageHandler||t.addEventListener("message",function(m){var f=JSON.parse(m.data),v=f.language,b=f.code,w=f.immediateClose;t.postMessage(r.highlight(b,r.languages[v],v)),w&&t.close()},!1)),r;var g=r.util.currentScript();g&&(r.filename=g.src,g.hasAttribute("data-manual")&&(r.manual=!0));function h(){r.manual||r.highlightAll()}if(!r.manual){var y=document.readyState;y==="loading"||y==="interactive"&&g&&g.defer?document.addEventListener("DOMContentLoaded",h):window.requestAnimationFrame?window.requestAnimationFrame(h):window.setTimeout(h,16)}return r})(Jm);typeof sr<"u"&&sr.exports&&(sr.exports=Q);typeof global<"u"&&(global.Prism=Q);Q.languages.markup={comment:{pattern:/<!--(?:(?!<!--)[\s\S])*?-->/,greedy:!0},prolog:{pattern:/<\?[\s\S]+?\?>/,greedy:!0},doctype:{pattern:/<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,greedy:!0,inside:{"internal-subset":{pattern:/(^[^\[]*\[)[\s\S]+(?=\]>$)/,lookbehind:!0,greedy:!0,inside:null},string:{pattern:/"[^"]*"|'[^']*'/,greedy:!0},punctuation:/^<!|>$|[[\]]/,"doctype-tag":/^DOCTYPE/i,name:/[^\s<>'"]+/}},cdata:{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,greedy:!0},tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>\/]+/,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"special-attr":[],"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,inside:{punctuation:[{pattern:/^=/,alias:"attr-equals"},{pattern:/^(\s*)["']|["']$/,lookbehind:!0}]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:[{pattern:/&[\da-z]{1,8};/i,alias:"named-entity"},/&#x?[\da-f]{1,8};/i]};Q.languages.markup.tag.inside["attr-value"].inside.entity=Q.languages.markup.entity;Q.languages.markup.doctype.inside["internal-subset"].inside=Q.languages.markup;Q.hooks.add("wrap",function(t){t.type==="entity"&&(t.attributes.title=t.content.replace(/&/,"&"))});Object.defineProperty(Q.languages.markup.tag,"addInlined",{value:function(n,s){var a={};a["language-"+s]={pattern:/(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,lookbehind:!0,inside:Q.languages[s]},a.cdata=/^<!\[CDATA\[|\]\]>$/i;var r={"included-cdata":{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,inside:a}};r["language-"+s]={pattern:/[\s\S]+/,inside:Q.languages[s]};var o={};o[n]={pattern:RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g,function(){return n}),"i"),lookbehind:!0,greedy:!0,inside:r},Q.languages.insertBefore("markup","cdata",o)}});Object.defineProperty(Q.languages.markup.tag,"addAttribute",{value:function(t,n){Q.languages.markup.tag.inside["special-attr"].push({pattern:RegExp(/(^|["'\s])/.source+"(?:"+t+")"+/\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,"i"),lookbehind:!0,inside:{"attr-name":/^[^\s=]+/,"attr-value":{pattern:/=[\s\S]+/,inside:{value:{pattern:/(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,lookbehind:!0,alias:[n,"language-"+n],inside:Q.languages[n]},punctuation:[{pattern:/^=/,alias:"attr-equals"},/"|'/]}}}})}});Q.languages.html=Q.languages.markup;Q.languages.mathml=Q.languages.markup;Q.languages.svg=Q.languages.markup;Q.languages.xml=Q.languages.extend("markup",{});Q.languages.ssml=Q.languages.xml;Q.languages.atom=Q.languages.xml;Q.languages.rss=Q.languages.xml;(function(t){var n=/(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;t.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:RegExp("@[\\w-](?:"+/[^;{\s"']|\s+(?!\s)/.source+"|"+n.source+")*?"+/(?:;|(?=\s*\{))/.source),inside:{rule:/^@[\w-]+/,"selector-function-argument":{pattern:/(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,lookbehind:!0,alias:"selector"},keyword:{pattern:/(^|[^\w-])(?:and|not|only|or)(?![\w-])/,lookbehind:!0}}},url:{pattern:RegExp("\\burl\\((?:"+n.source+"|"+/(?:[^\\\r\n()"']|\\[\s\S])*/.source+")\\)","i"),greedy:!0,inside:{function:/^url/i,punctuation:/^\(|\)$/,string:{pattern:RegExp("^"+n.source+"$"),alias:"url"}}},selector:{pattern:RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|`+n.source+")*(?=\\s*\\{)"),lookbehind:!0},string:{pattern:n,greedy:!0},property:{pattern:/(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,lookbehind:!0},important:/!important\b/i,function:{pattern:/(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,lookbehind:!0},punctuation:/[(){};:,]/},t.languages.css.atrule.inside.rest=t.languages.css;var s=t.languages.markup;s&&(s.tag.addInlined("style","css"),s.tag.addAttribute("style","css"))})(Q);Q.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,lookbehind:!0,greedy:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,lookbehind:!0,inside:{punctuation:/[.\\]/}},keyword:/\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,boolean:/\b(?:false|true)\b/,function:/\b\w+(?=\()/,number:/\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,operator:/[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/};Q.languages.javascript=Q.languages.extend("clike",{"class-name":[Q.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+(/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source)+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/});Q.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/;Q.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:Q.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:Q.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:Q.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:Q.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:Q.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/});Q.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Q.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}});Q.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}});Q.languages.markup&&(Q.languages.markup.tag.addInlined("script","javascript"),Q.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript"));Q.languages.js=Q.languages.javascript;(function(){if(typeof Q>"u"||typeof document>"u")return;Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector);var t="Loading\u2026",n=function(g,h){return"\u2716 Error "+g+" while fetching file: "+h},s="\u2716 Error: File does not exist or is empty",a={js:"javascript",py:"python",rb:"ruby",ps1:"powershell",psm1:"powershell",sh:"bash",bat:"batch",h:"c",tex:"latex"},r="data-src-status",o="loading",i="loaded",l="failed",c="pre[data-src]:not(["+r+'="'+i+'"]):not(['+r+'="'+o+'"])';function u(g,h,y){var m=new XMLHttpRequest;m.open("GET",g,!0),m.onreadystatechange=function(){m.readyState==4&&(m.status<400&&m.responseText?h(m.responseText):m.status>=400?y(n(m.status,m.statusText)):y(s))},m.send(null)}function d(g){var h=/^\s*(\d+)\s*(?:(,)\s*(?:(\d+)\s*)?)?$/.exec(g||"");if(h){var y=Number(h[1]),m=h[2],f=h[3];return m?f?[y,Number(f)]:[y,void 0]:[y,y]}}Q.hooks.add("before-highlightall",function(g){g.selector+=", "+c}),Q.hooks.add("before-sanity-check",function(g){var h=g.element;if(h.matches(c)){g.code="",h.setAttribute(r,o);var y=h.appendChild(document.createElement("CODE"));y.textContent=t;var m=h.getAttribute("data-src"),f=g.language;if(f==="none"){var v=(/\.(\w+)$/.exec(m)||[,"none"])[1];f=a[v]||v}Q.util.setLanguage(y,f),Q.util.setLanguage(h,f);var b=Q.plugins.autoloader;b&&b.loadLanguages(f),u(m,function(w){h.setAttribute(r,i);var k=d(h.getAttribute("data-range"));if(k){var C=w.split(/\r\n?|\n/g),S=k[0],_=k[1]==null?C.length:k[1];S<0&&(S+=C.length),S=Math.max(0,Math.min(S-1,C.length)),_<0&&(_+=C.length),_=Math.max(0,Math.min(_,C.length)),w=C.slice(S,_).join(`
|
|
2
|
+
`),h.hasAttribute("data-start")||h.setAttribute("data-start",String(S+1))}y.textContent=w,Q.highlightElement(y)},function(w){h.setAttribute(r,l),y.textContent=w})}}),Q.plugins.fileHighlight={highlight:function(h){for(var y=(h||document).querySelectorAll(c),m=0,f;f=y[m++];)Q.highlightElement(f)}};var p=!1;Q.fileHighlight=function(){p||(console.warn("Prism.fileHighlight is deprecated. Use `Prism.plugins.fileHighlight.highlight` instead."),p=!0),Q.plugins.fileHighlight.highlight.apply(this,arguments)}})()});var xs,ke,Oo,tp,Pt,jo,No,Bo,Pr,bs,Gn,Ho,Or,Ir,Fr,np,vs={},ws=[],sp=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Ss=Array.isArray;function Mt(t,n){for(var s in n)t[s]=n[s];return t}function Nr(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function bn(t,n,s){var a,r,o,i={};for(o in n)o=="key"?a=n[o]:o=="ref"?r=n[o]:i[o]=n[o];if(arguments.length>2&&(i.children=arguments.length>3?xs.call(arguments,2):s),typeof t=="function"&&t.defaultProps!=null)for(o in t.defaultProps)i[o]===void 0&&(i[o]=t.defaultProps[o]);return ys(t,i,a,r,null)}function ys(t,n,s,a,r){var o={type:t,props:n,key:s,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:r??++Oo,__i:-1,__u:0};return r==null&&ke.vnode!=null&&ke.vnode(o),o}function R(t){return t.children}function fn(t,n){this.props=t,this.context=n}function Wt(t,n){if(n==null)return t.__?Wt(t.__,t.__i+1):null;for(var s;n<t.__k.length;n++)if((s=t.__k[n])!=null&&s.__e!=null)return s.__e;return typeof t.type=="function"?Wt(t):null}function rp(t){if(t.__P&&t.__d){var n=t.__v,s=n.__e,a=[],r=[],o=Mt({},n);o.__v=n.__v+1,ke.vnode&&ke.vnode(o),Br(t.__P,o,n,t.__n,t.__P.namespaceURI,32&n.__u?[s]:null,a,s??Wt(n),!!(32&n.__u),r),o.__v=n.__v,o.__.__k[o.__i]=o,Wo(a,o,r),n.__e=n.__=null,o.__e!=s&&Uo(o)}}function Uo(t){if((t=t.__)!=null&&t.__c!=null)return t.__e=t.__c.base=null,t.__k.some(function(n){if(n!=null&&n.__e!=null)return t.__e=t.__c.base=n.__e}),Uo(t)}function Po(t){(!t.__d&&(t.__d=!0)&&Pt.push(t)&&!ks.__r++||jo!=ke.debounceRendering)&&((jo=ke.debounceRendering)||No)(ks)}function ks(){try{for(var t,n=1;Pt.length;)Pt.length>n&&Pt.sort(Bo),t=Pt.shift(),n=Pt.length,rp(t)}finally{Pt.length=ks.__r=0}}function Jo(t,n,s,a,r,o,i,l,c,u,d){var p,g,h,y,m,f,v=a&&a.__k||ws,b=n.length;for(c=ap(s,n,v,c,b),p=0;p<b;p++)(h=s.__k[p])!=null&&(g=h.__i!=-1&&v[h.__i]||vs,h.__i=p,f=Br(t,h,g,r,o,i,l,c,u,d),y=h.__e,h.ref&&g.ref!=h.ref&&(g.ref&&Hr(g.ref,null,h),d.push(h.ref,h.__c||y,h)),m==null&&y!=null&&(m=y),4&h.__u?(c=Xo(h,c,t),g.__e&&(g.__e=null)):typeof h.type=="function"&&f!==void 0?c=f:y&&(c=y.nextSibling),h.__u&=-7);return s.__e=m,c}function ap(t,n,s,a,r){var o,i,l,c,u,d=s.length,p=d,g=0;for(t.__k=new Array(r),o=0;o<r;o++)(i=n[o])!=null&&typeof i!="boolean"&&typeof i!="function"?(typeof i=="string"||typeof i=="number"||typeof i=="bigint"||i.constructor==String?i=t.__k[o]=ys(null,i,null,null,null):Ss(i)?i=t.__k[o]=ys(R,{children:i},null,null,null):i.constructor===void 0&&i.__b>0?i=t.__k[o]=ys(i.type,i.props,i.key,i.ref?i.ref:null,i.__v):t.__k[o]=i,c=o+g,i.__=t,i.__b=t.__b+1,l=null,(u=i.__i=op(i,s,c,p))!=-1&&(p--,(l=s[u])&&(l.__u|=2)),l==null||l.__v==null?(u==-1&&(r>d?g--:r<d&&g++),typeof i.type!="function"&&(i.__u|=4)):u!=c&&(u==c-1?g--:u==c+1?g++:(u>c?g--:g++,i.__u|=4))):t.__k[o]=null;if(p)for(o=0;o<d;o++)(l=s[o])!=null&&(2&l.__u)==0&&(l.__e==a&&(a=Wt(l)),qo(l,l));return a}function Xo(t,n,s){var a,r;if(typeof t.type=="function"){for(a=t.__k,r=0;a&&r<a.length;r++)a[r]&&(a[r].__=t,n=Xo(a[r],n,s));return n}t.__e!=n&&(n&&t.type&&!n.parentNode&&(n=Wt(t)),n=s.insertBefore(t.__e,n||null));do n=n&&n.nextSibling;while(n!=null&&n.nodeType==8);return n}function op(t,n,s,a){var r,o,i,l=t.key,c=t.type,u=n[s],d=u!=null&&(2&u.__u)==0;if(u===null&&l==null||d&&l==u.key&&c==u.type)return s;if(a>(d?1:0)){for(r=s-1,o=s+1;r>=0||o<n.length;)if((u=n[i=r>=0?r--:o++])!=null&&(2&u.__u)==0&&l==u.key&&c==u.type)return i}return-1}function Io(t,n,s){n[0]=="-"?t.setProperty(n,s??""):t[n]=s==null?"":typeof s!="number"||sp.test(n)?s:s+"px"}function fs(t,n,s,a,r){var o,i;e:if(n=="style")if(typeof s=="string")t.style.cssText=s;else{if(typeof a=="string"&&(t.style.cssText=a=""),a)for(n in a)s&&n in s||Io(t.style,n,"");if(s)for(n in s)a&&s[n]==a[n]||Io(t.style,n,s[n])}else if(n[0]=="o"&&n[1]=="n")o=n!=(n=n.replace(Ho,"$1")),i=n.toLowerCase(),n=i in t||n=="onFocusOut"||n=="onFocusIn"?i.slice(2):n.slice(2),t.l||(t.l={}),t.l[n+o]=s,s?a?s[Gn]=a[Gn]:(s[Gn]=Or,t.addEventListener(n,o?Fr:Ir,o)):t.removeEventListener(n,o?Fr:Ir,o);else{if(r=="http://www.w3.org/2000/svg")n=n.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(n!="width"&&n!="height"&&n!="href"&&n!="list"&&n!="form"&&n!="tabIndex"&&n!="download"&&n!="rowSpan"&&n!="colSpan"&&n!="role"&&n!="popover"&&n in t)try{t[n]=s??"";break e}catch{}typeof s=="function"||(s==null||s===!1&&n[4]!="-"?t.removeAttribute(n):t.setAttribute(n,n=="popover"&&s==1?"":s))}}function Fo(t){return function(n){if(this.l){var s=this.l[n.type+t];if(n[bs]==null)n[bs]=Or++;else if(n[bs]<s[Gn])return;return s(ke.event?ke.event(n):n)}}}function Br(t,n,s,a,r,o,i,l,c,u){var d,p,g,h,y,m,f,v,b,w,k,C,S,_,T,M,F=n.type;if(n.constructor!==void 0)return null;128&s.__u&&(c=!!(32&s.__u),o=[l=n.__e=s.__e]),(d=ke.__b)&&d(n);e:if(typeof F=="function"){p=i.length;try{if(b=n.props,w=F.prototype&&F.prototype.render,k=(d=F.contextType)&&a[d.__c],C=d?k?k.props.value:d.__:a,s.__c?v=(g=n.__c=s.__c).__=g.__E:(w?n.__c=g=new F(b,C):(n.__c=g=new fn(b,C),g.constructor=F,g.render=lp),k&&k.sub(g),g.state||(g.state={}),g.__n=a,h=g.__d=!0,g.__h=[],g._sb=[]),w&&g.__s==null&&(g.__s=g.state),w&&F.getDerivedStateFromProps!=null&&(g.__s==g.state&&(g.__s=Mt({},g.__s)),Mt(g.__s,F.getDerivedStateFromProps(b,g.__s))),y=g.props,m=g.state,g.__v=n,h)w&&F.getDerivedStateFromProps==null&&g.componentWillMount!=null&&g.componentWillMount(),w&&g.componentDidMount!=null&&g.__h.push(g.componentDidMount);else{if(w&&F.getDerivedStateFromProps==null&&b!==y&&g.componentWillReceiveProps!=null&&g.componentWillReceiveProps(b,C),n.__v==s.__v||!g.__e&&g.shouldComponentUpdate!=null&&g.shouldComponentUpdate(b,g.__s,C)===!1){n.__v!=s.__v&&(g.props=b,g.state=g.__s,g.__d=!1),n.__e=s.__e,n.__k=s.__k,n.__k.some(function(D){D&&(D.__=n)}),ws.push.apply(g.__h,g._sb),g._sb=[],g.__h.length&&i.push(g),l=Wt(s);break e}g.componentWillUpdate!=null&&g.componentWillUpdate(b,g.__s,C),w&&g.componentDidUpdate!=null&&g.__h.push(function(){g.componentDidUpdate(y,m,f)})}if(g.context=C,g.props=b,g.__P=t,g.__e=!1,S=ke.__r,_=0,w)g.state=g.__s,g.__d=!1,S&&S(n),d=g.render(g.props,g.state,g.context),ws.push.apply(g.__h,g._sb),g._sb=[];else do g.__d=!1,S&&S(n),d=g.render(g.props,g.state,g.context),g.state=g.__s;while(g.__d&&++_<25);g.state=g.__s,g.getChildContext!=null&&(a=Mt(Mt({},a),g.getChildContext())),w&&!h&&g.getSnapshotBeforeUpdate!=null&&(f=g.getSnapshotBeforeUpdate(y,m)),T=d!=null&&d.type===R&&d.key==null?zo(d.props.children):d,l=Jo(t,Ss(T)?T:[T],n,s,a,r,o,i,l,c,u),g.base=n.__e,n.__u&=-161,g.__h.length&&i.push(g),v&&(g.__E=g.__=null)}catch(D){if(i.length=p,n.__v=null,c||o!=null){if(D.then){for(n.__u|=c?160:128;l&&l.nodeType==8&&l.nextSibling;)l=l.nextSibling;o!=null&&(o[o.indexOf(l)]=null),n.__e=l}else if(o!=null)for(M=o.length;M--;)Nr(o[M])}else n.__e=s.__e;n.__k==null&&(n.__k=s.__k||[]),D.then||Go(n),ke.__e(D,n,s)}}else o==null&&n.__v==s.__v?(n.__k=s.__k,n.__e=s.__e):l=n.__e=ip(s.__e,n,s,a,r,o,i,c,u);return(d=ke.diffed)&&d(n),128&n.__u?void 0:l}function Go(t){t&&(t.__c&&(t.__c.__e=!0),t.__k&&t.__k.some(Go))}function Wo(t,n,s){for(var a=0;a<s.length;a++)Hr(s[a],s[++a],s[++a]);ke.__c&&ke.__c(n,t),t.some(function(r){try{t=r.__h,r.__h=[],t.some(function(o){o.call(r)})}catch(o){ke.__e(o,r.__v)}})}function zo(t){return typeof t!="object"||t==null||t.__b>0?t:Ss(t)?t.map(zo):t.constructor!==void 0?null:Mt({},t)}function ip(t,n,s,a,r,o,i,l,c){var u,d,p,g,h,y,m,f=s.props||vs,v=n.props,b=n.type;if(b=="svg"?r="http://www.w3.org/2000/svg":b=="math"?r="http://www.w3.org/1998/Math/MathML":r||(r="http://www.w3.org/1999/xhtml"),o!=null){for(u=0;u<o.length;u++)if((h=o[u])&&"setAttribute"in h==!!b&&(b?h.localName==b:h.nodeType==3)){t=h,o[u]=null;break}}if(t==null){if(b==null)return document.createTextNode(v);t=document.createElementNS(r,b,v.is&&v),l&&(ke.__m&&ke.__m(n,o),l=!1),o=null}if(b==null)f===v||l&&t.data==v||(t.data=v);else{if(o=b=="textarea"&&v.defaultValue!=null?null:o&&xs.call(t.childNodes),!l&&o!=null)for(f={},u=0;u<t.attributes.length;u++)f[(h=t.attributes[u]).name]=h.value;for(u in f)h=f[u],u=="dangerouslySetInnerHTML"?p=h:u=="children"||u in v||u=="value"&&"defaultValue"in v||u=="checked"&&"defaultChecked"in v||fs(t,u,null,h,r);for(u in v)h=v[u],u=="children"?g=h:u=="dangerouslySetInnerHTML"?d=h:u=="value"?y=h:u=="checked"?m=h:l&&typeof h!="function"||f[u]===h||fs(t,u,h,f[u],r);if(d)l||p&&(d.__html==p.__html||d.__html==t.innerHTML)||(t.innerHTML=d.__html),n.__k=[];else if(p&&(t.innerHTML=""),Jo(n.type=="template"?t.content:t,Ss(g)?g:[g],n,s,a,b=="foreignObject"?"http://www.w3.org/1999/xhtml":r,o,i,o?o[0]:s.__k&&Wt(s,0),l,c),o!=null)for(u=o.length;u--;)Nr(o[u]);l&&b!="textarea"||(u="value",b=="progress"&&y==null?t.removeAttribute("value"):y!=null&&(y!==t[u]||b=="progress"&&!y||b=="option"&&y!=f[u])&&fs(t,u,y,f[u],r),u="checked",m!=null&&m!=t[u]&&fs(t,u,m,f[u],r))}return t}function Hr(t,n,s){try{if(typeof t=="function"){var a=typeof t.__u=="function";a&&t.__u(),a&&n==null||(t.__u=t(n))}else t.current=n}catch(r){ke.__e(r,s)}}function qo(t,n,s){var a,r;if(ke.unmount&&ke.unmount(t),(a=t.ref)&&(a.current&&a.current!=t.__e||Hr(a,null,n)),(a=t.__c)!=null){if(a.componentWillUnmount)try{a.componentWillUnmount()}catch(o){ke.__e(o,n)}a.base=a.__P=a.__n=null}if(a=t.__k)for(r=0;r<a.length;r++)a[r]&&qo(a[r],n,s||typeof t.type!="function");s||Nr(t.__e),t.__c=t.__=t.__e=void 0}function lp(t,n,s){return this.constructor(t,s)}function Ko(t,n,s){var a,r,o,i;n==document&&(n=document.documentElement),ke.__&&ke.__(t,n),r=(a=typeof s=="function")?null:s&&s.__k||n.__k,o=[],i=[],Br(n,t=(!a&&s||n).__k=bn(R,null,[t]),r||vs,vs,n.namespaceURI,!a&&s?[s]:r?null:n.firstChild?xs.call(n.childNodes):null,o,!a&&s?s:r?r.__e:n.firstChild,a,i),Wo(o,t,i),t.props.children=null}xs=ws.slice,ke={__e:function(t,n,s,a){for(var r,o,i;n=n.__;)if((r=n.__c)&&!r.__)try{if((o=r.constructor)&&o.getDerivedStateFromError!=null&&(r.setState(o.getDerivedStateFromError(t)),i=r.__d),r.componentDidCatch!=null&&(r.componentDidCatch(t,a||{}),i=r.__d),i)return r.__E=r}catch(l){t=l}throw t}},Oo=0,tp=function(t){return t!=null&&t.constructor===void 0},fn.prototype.setState=function(t,n){var s;s=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Mt({},this.state),typeof t=="function"&&(t=t(Mt({},s),this.props)),t&&Mt(s,t),t!=null&&this.__v&&(n&&this._sb.push(n),Po(this))},fn.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),Po(this))},fn.prototype.render=R,Pt=[],No=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Bo=function(t,n){return t.__v.__b-n.__v.__b},ks.__r=0,Pr=Math.random().toString(8),bs="__d"+Pr,Gn="__a"+Pr,Ho=/(PointerCapture)$|Capture$/i,Or=0,Ir=Fo(!1),Fr=Fo(!0),np=0;var yn,Ee,Ur,Vo,vn=0,ri=[],Ae=ke,Yo=Ae.__b,Zo=Ae.__r,Qo=Ae.diffed,ei=Ae.__c,ti=Ae.unmount,ni=Ae.__;function Cs(t,n){Ae.__h&&Ae.__h(Ee,t,vn||n),vn=0;var s=Ee.__H||(Ee.__H={__:[],__h:[]});return t>=s.__.length&&s.__.push({}),s.__[t]}function x(t){return vn=1,cp(oi,t)}function cp(t,n,s){var a=Cs(yn++,2);if(a.t=t,!a.__c&&(a.__=[s?s(n):oi(void 0,n),function(l){var c=a.__N?a.__N[0]:a.__[0],u=a.t(c,l);c!==u&&(a.__N=[u,a.__[1]],a.__c.setState({}))}],a.__c=Ee,!Ee.__f)){var r=function(l,c,u){if(!a.__c.__H)return!0;var d=!1,p=a.__c.props!==l;if(a.__c.__H.__.some(function(h){if(h.__N){d=!0;var y=h.__[0];h.__=h.__N,h.__N=void 0,y!==h.__[0]&&(p=!0)}}),o){var g=o.call(this,l,c,u);return d?g||p:g}return!d||p};Ee.__f=!0;var o=Ee.shouldComponentUpdate,i=Ee.componentWillUpdate;Ee.componentWillUpdate=function(l,c,u){if(this.__e){var d=o;o=void 0,r(l,c,u),o=d}i&&i.call(this,l,c,u)},Ee.shouldComponentUpdate=r}return a.__N||a.__}function U(t,n){var s=Cs(yn++,3);!Ae.__s&&Xr(s.__H,n)&&(s.__=t,s.u=n,Ee.__H.__h.push(s))}function dp(t,n){var s=Cs(yn++,4);!Ae.__s&&Xr(s.__H,n)&&(s.__=t,s.u=n,Ee.__h.push(s))}function te(t){return vn=5,ae(function(){return{current:t}},[])}function ai(t,n,s){vn=6,dp(function(){if(typeof t=="function"){var a=t(n());return function(){t(null),a&&typeof a=="function"&&a()}}if(t)return t.current=n(),function(){return t.current=null}},s==null?s:s.concat(t))}function ae(t,n){var s=Cs(yn++,7);return Xr(s.__H,n)&&(s.__=t(),s.__H=n,s.__h=t),s.__}function ut(t,n){return vn=8,ae(function(){return t},n)}function up(){for(var t;t=ri.shift();){var n=t.__H;if(t.__P&&n)try{n.__h.some(_s),n.__h.some(Jr),n.__h=[]}catch(s){n.__h=[],Ae.__e(s,t.__v)}}}Ae.__b=function(t){Ee=null,Yo&&Yo(t)},Ae.__=function(t,n){t&&n.__k&&n.__k.__m&&(t.__m=n.__k.__m),ni&&ni(t,n)},Ae.__r=function(t){Zo&&Zo(t),yn=0;var n=(Ee=t.__c).__H;n&&(Ur===Ee?(n.__h=[],Ee.__h=[],n.__.some(function(s){s.__N&&(s.__=s.__N),s.u=s.__N=void 0})):(n.__h.some(_s),n.__h.some(Jr),n.__h=[],yn=0)),Ur=Ee},Ae.diffed=function(t){Qo&&Qo(t);var n=t.__c;n&&n.__H&&(n.__H.__h.length&&(ri.push(n)!==1&&Vo===Ae.requestAnimationFrame||((Vo=Ae.requestAnimationFrame)||pp)(up)),n.__H.__.some(function(s){s.u&&(s.__H=s.u,s.u=void 0)})),Ur=Ee=null},Ae.__c=function(t,n){n.some(function(s){try{s.__h.some(_s),s.__h=s.__h.filter(function(a){return!a.__||Jr(a)})}catch(a){n.some(function(r){r.__h&&(r.__h=[])}),n=[],Ae.__e(a,s.__v)}}),ei&&ei(t,n)},Ae.unmount=function(t){ti&&ti(t);var n,s=t.__c;s&&s.__H&&(s.__H.__.some(function(a){try{_s(a)}catch(r){n=r}}),s.__H=void 0,n&&Ae.__e(n,s.__v))};var si=typeof requestAnimationFrame=="function";function pp(t){var n,s=function(){clearTimeout(a),si&&cancelAnimationFrame(n),setTimeout(t)},a=setTimeout(s,35);si&&(n=requestAnimationFrame(s))}function _s(t){var n=Ee,s=t.__c;typeof s=="function"&&(t.__c=void 0,s()),Ee=n}function Jr(t){var n=Ee;t.__c=t.__(),Ee=n}function Xr(t,n){return!t||t.length!==n.length||n.some(function(s,a){return s!==t[a]})}function oi(t,n){return typeof n=="function"?n(t):n}var $s=new URLSearchParams(location.search).get("root")??"",Gr=()=>$s;function Wr(t){$s=t;let n=new URL(location.href);n.searchParams.set("root",t),history.replaceState(history.state,"",n.toString())}function mp(t,n){let s=new URL(t,location.origin);$s&&s.searchParams.set("root",$s);for(let[a,r]of Object.entries(n??{}))r==null||r===""||s.searchParams.set(a,String(r));return s.toString()}var zt=class extends Error{constructor(s,a,r){super(s);be(this,"status",a);be(this,"body",r)}};async function J(t,n,s){let a=await fetch(mp(t,n),s),r=await a.json().catch(()=>({error:"bad response"}));if(a.status===404&&r.error==="not found"&&t.startsWith("/api/"))throw new zt(`${t} is not available on the running server; restart \`eminiar ui\` to pick up the rebuilt bundle`,a.status);if(!a.ok)throw new zt(r.error??`HTTP ${a.status}`,a.status,r);if(r&&typeof r=="object"&&"error"in r&&r.error)throw new zt(String(r.error),a.status);return r}function $e(t,n,s="POST",a){return J(t,a,{method:s,headers:{"content-type":"application/json"},body:JSON.stringify(n)})}function Es(t,n){return J(t,n,{method:"DELETE",headers:{"content-type":"application/json"}})}var ii=t=>J("/api/adjudicator/jev",{since:t}),li=(t,n)=>J("/api/adjudicator/jev/exchanges",{limit:t,row:n}),ci=t=>J("/api/adjudicator/jev/exchange",{id:t}),Wn=()=>J("/api/swarm/config"),di=()=>J("/api/swarm/templates"),zr=t=>$e("/api/swarm/config/validate",t),ui=t=>$e("/api/swarm/config/save",t);var z=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(Math.round(t));function me(t){if(!t)return"";let n=Date.now()-t;return n<6e4?"just now":n<36e5?`${Math.round(n/6e4)}m ago`:n<864e5?`${Math.round(n/36e5)}h ago`:`${Math.round(n/864e5)}d ago`}var Ve=t=>t?new Date(t).toISOString().slice(0,10):"",pi=t=>t?new Date(t).toLocaleTimeString():"",wn=t=>t.split("/").pop()??t;var gp={file:"#2563eb",function:"#16a34a",method:"#0d9488",class:"#d97706",interface:"#7c3aed",type:"#8b5cf6",enum:"#a855f7",field:"#64748b",variable:"#64748b",route:"#e11d48",package:"#6b7280",memory:"#2563eb",doc:"#1e40af",tag:"#9ca3af",topic:"#6b7280",branch:"#64748b",commit:"#94a3b8",person:"#f59e0b",concept:"#0ea5e9",cluster:"#2563eb"},xt=t=>gp[t]??"#94a3b8",hp={imports:"#2563eb",reexports:"#3b82f6",calls:"#16a34a",references:"#0ea5e9",extends:"#7c3aed",implements:"#8b5cf6",handles:"#e11d48",defines:"#9ca3af",exports:"#9ca3af",co_changes:"#f59e0b",mentions:"#2563eb",supersedes:"#6b7280",links:"#3b82f6",documents:"#1e40af",about:"#93c5fd",tagged:"#9ca3af",in_topic:"#cdd2da",authored:"#d97706",link:"#2563eb"},kn=t=>hp[t]??"#94a3b8",Ts=new Set(["imports","reexports","calls","references","extends","implements","handles","mentions","supersedes","links","documents","about"]),mi=["imports","calls","references","extends","implements","handles","reexports","co_changes","mentions","defines"],E=(...t)=>t.filter(Boolean).join(" ");function gi(t,n){let s;return(...a)=>{clearTimeout(s),s=setTimeout(()=>t(...a),n)}}var tt=t=>`${Math.round((t??0)*100)}%`;function hi(t){let n=t.slice(t.lastIndexOf(".")+1).toLowerCase();return{ts:"typescript",mts:"typescript",cts:"typescript",tsx:"tsx",js:"javascript",mjs:"javascript",cjs:"javascript",jsx:"jsx",py:"python",go:"go",php:"php",json:"json",md:"markdown",sh:"bash"}[n]??"plain"}var fp=0;function e(t,n,s,a,r,o){n||(n={});var i,l,c=n;if("ref"in c)for(l in c={},n)l=="ref"?i=n[l]:c[l]=n[l];var u={type:t,props:c,key:s,ref:i,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--fp,__i:-1,__u:0,__source:r,__self:o};if(typeof t=="function"&&(i=t.defaultProps))for(l in i)c[l]===void 0&&(c[l]=i[l]);return ke.vnode&&ke.vnode(u),u}var qt=t=>!!t&&`ds-t-${t}`;if(typeof document<"u"){let t=()=>{document.hidden?document.documentElement.setAttribute("data-tab-hidden",""):document.documentElement.removeAttribute("data-tab-hidden")};document.addEventListener("visibilitychange",t),t()}var xn=({children:t})=>e("span",{class:"ds-gradient-text",children:t});function Te({eyebrow:t,title:n,sub:s,meta:a,aside:r}){return e("section",{class:"ds-hero",children:[e("div",{class:"ds-hero-main",children:[t?e("div",{class:"ds-eyebrow",children:t}):null,e("h1",{class:"ds-hero-title",children:n}),s?e("div",{class:"ds-hero-sub",children:s}):null,a?e("div",{class:"ds-hero-meta",children:a}):null]}),r?e("div",{class:"ds-hero-aside",children:r}):null]})}var Re=({children:t})=>e("div",{class:"ds-stats",children:t});function le({label:t,value:n,sub:s,tone:a,onClick:r,title:o,children:i}){let l=e(R,{children:[e("span",{class:"ds-stat-label",children:t}),e("span",{class:"ds-stat-value",children:n}),s?e("span",{class:"ds-stat-sub",children:s}):null,i?e("div",{class:"ds-stat-extra",children:i}):null]}),c=E("ds-stat",qt(a),r&&"is-link");return r?e("button",{type:"button",class:c,title:o,onClick:r,children:l}):e("div",{class:c,title:o,children:l})}function I({tone:t,dot:n,title:s,children:a}){return e("span",{class:E("ds-badge",qt(t)),title:s,children:[n?e("i",{class:"ds-dot"}):null,a]})}function It({tone:t,pulse:n,title:s,children:a}){return e("span",{class:E("ds-badge ds-pill",qt(t),n&&"pulse"),title:s,children:[e("i",{class:"ds-dot"}),a]})}function j({title:t,sub:n,right:s,raised:a,selected:r,flush:o,onClick:i,class:l,children:c}){let u=!!i;return e("div",{class:E("ds-card",a&&"raised",r&&"selected",o&&"flush",u&&"interactive",l),tabIndex:u?0:void 0,onClick:i,onKeyDown:i?d=>{d.target===d.currentTarget&&(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),i())}:void 0,children:[t||s?e("div",{class:"ds-card-head",children:[t?e("h3",{children:t}):null,n?e("span",{class:"ds-card-sub",children:n}):null,s?e("span",{class:"right",children:s}):null]}):null,c]})}function Kt({value:t,size:n=72,thickness:s,tone:a="accent",label:r,caption:o,title:i,class:l}){let c=Number.isFinite(t)?Math.max(0,Math.min(1,t)):0,u={"--size":`${n}px`,"--th":`${s??Math.max(5,Math.round(n/9))}px`,"--p":String(Math.round(c*1e3)/10)};return e("div",{class:E("ds-gauge",qt(a),l),style:u,title:i,role:"img","aria-label":i??`${Math.round(c*100)}%`,children:[e("div",{class:"ds-gauge-ring"}),e("div",{class:"ds-gauge-label",children:[r??`${Math.round(c*100)}%`,o?e("small",{children:o}):null]})]})}function Rs({values:t,height:n=32,tone:s="accent",title:a}){let i=t.length,l=Math.max(1,...t),c=t.map((p,g)=>[i>1?g/(i-1)*100:100/2,94-Math.max(0,p)/l*88]),u=c.map(([p,g],h)=>`${h?"L":"M"}${p.toFixed(2)} ${g.toFixed(2)}`).join(" "),d=c[c.length-1];return e("svg",{class:E("ds-spark",qt(s)),style:{"--h":`${n}px`},viewBox:"0 0 100 100",preserveAspectRatio:"none",role:"img","aria-label":a??"trend",children:[a?e("title",{children:a}):null,i>1?e(R,{children:[e("path",{class:"ds-spark-fill",d:`${u} L100 100 L0 100 Z`}),e("path",{class:"ds-spark-line",d:u})]}):null,d&&i===1?e("circle",{class:"ds-spark-end",cx:d[0],cy:d[1],r:"3"}):null]})}function St({segments:t,total:n,title:s}){let a=n??t.reduce((r,o)=>r+o.value,0);return e("div",{class:"ds-segbar",title:s,role:"img","aria-label":s??"progress",children:a>0?t.filter(r=>r.value>0).map(r=>e("i",{class:qt(r.tone)||void 0,title:r.label,style:{flex:`0 0 ${100*r.value/a}%`}})):null})}function qr({rows:t,tone:n="accent",empty:s="no data yet"}){if(!t.length)return e("div",{class:"muted small",children:s});let a=Math.max(1,...t.map(r=>r.value));return e("div",{class:E("ds-meters",qt(n)),children:t.map(r=>e("div",{class:"ds-meter",children:[e("span",{class:"ds-meter-label",title:r.label,children:r.label}),e("span",{class:"ds-meter-track",children:e("i",{style:{width:`${Math.max(2,100*r.value/a)}%`}})}),e("span",{class:"ds-meter-value",children:r.text??r.value})]}))})}function fi({data:t,startLabel:n,endLabel:s}){let a=Math.max(1,...t.map(r=>r.value));return e("div",{class:"ds-chart",children:[e("div",{class:"ds-chart-plot",children:t.map((r,o)=>e("div",{class:E("ds-chart-col",o===t.length-1&&"is-last"),children:[e("i",{style:{height:`${Math.max(2,100*r.value/a)}%`,animationDelay:`${Math.min(o*12,360)}ms`}}),e("span",{class:"ds-chart-tip",children:r.tip})]}))}),n||s?e("div",{class:"ds-chart-axis",children:[e("span",{children:n}),e("span",{children:s})]}):null]})}function N({w:t,h:n,class:s}){let a=o=>typeof o=="number"?`${o}px`:o,r={};return t!==void 0&&(r["--w"]=a(t)),n!==void 0&&(r["--h"]=a(n)),e("span",{class:E("ds-skeleton",s),style:r,"aria-hidden":"true"})}function Se({options:t,value:n,onChange:s,label:a}){return e("div",{class:"ds-segmented",role:"tablist","aria-label":a,children:t.map(r=>e("button",{type:"button",role:"tab","aria-selected":r.id===n,title:r.title,class:E(r.id===n&&"active"),onClick:()=>s(r.id),children:r.label}))})}var bp=0,yp='a[href],button:not(:disabled),input:not(:disabled),select:not(:disabled),textarea:not(:disabled),[tabindex]:not([tabindex="-1"])';function Sn({open:t=!0,onClose:n,title:s,actions:a,footer:r,children:o}){let i=te(null),l=te(!1),c=te(!1),u=te(`ds-drawer-t${++bp}`).current;return U(()=>{if(!t)return;let d=document.activeElement;i.current?.focus();let p=g=>{if(g.key==="Escape"){g.stopPropagation(),n();return}if(g.key!=="Tab"||!i.current)return;let h=[...i.current.querySelectorAll(yp)],y=h[0],m=h[h.length-1];if(!y||!m){g.preventDefault();return}let f=document.activeElement;g.shiftKey&&(f===y||f===i.current)?(g.preventDefault(),m.focus()):!g.shiftKey&&f===m&&(g.preventDefault(),y.focus())};return document.addEventListener("keydown",p),()=>{document.removeEventListener("keydown",p),d?.focus?.()}},[t]),t?e("div",{class:"ds-drawer-scrim",onMouseDown:d=>{l.current=d.target===d.currentTarget},onMouseUp:d=>{c.current=d.target===d.currentTarget},onClick:d=>{let p=l.current&&c.current&&d.target===d.currentTarget;l.current=!1,c.current=!1,p&&(d.stopPropagation(),n())},children:e("aside",{class:"ds-drawer",role:"dialog","aria-modal":"true","aria-labelledby":u,tabIndex:-1,ref:i,children:[e("header",{class:"ds-drawer-head",children:[e("h2",{id:u,children:s}),a,e("button",{type:"button",class:"ghost sm ds-drawer-close","aria-label":"close",onClick:n,children:"\u2715"})]}),e("div",{class:"ds-drawer-body",children:o}),r?e("footer",{class:"ds-drawer-foot",children:r}):null]})}):null}function xe({label:t,hint:n,error:s,htmlFor:a,class:r,children:o}){return e("div",{class:E("ds-field",!!s&&"has-error",r),children:[e("label",{for:a,children:t}),o,s?e("div",{class:"ds-field-error",children:s}):null,n&&!s?e("div",{class:"ds-field-hint",children:n}):null]})}function Ft({value:t,min:n=0,max:s=99,onChange:a,label:r}){return e("span",{class:"ds-stepper",role:"group","aria-label":r,children:[e("button",{type:"button","aria-label":"decrease",disabled:t<=n,onClick:()=>a(Math.max(n,t-1)),children:"\u2212"}),e("output",{children:t}),e("button",{type:"button","aria-label":"increase",disabled:t>=s,onClick:()=>a(Math.min(s,t+1)),children:"+"})]})}function zn({value:t,onChange:n,placeholder:s,disabled:a,label:r}){let[o,i]=x(""),l=c=>{let u=c.split(/[,\n]/).map(d=>d.trim()).filter(d=>d&&!t.includes(d));u.length&&n([...t,...new Set(u)]),i("")};return e("div",{class:"ds-chips",children:[t.map(c=>e("span",{class:"ds-chip",children:[c,a?null:e("button",{type:"button","aria-label":`remove ${c}`,onClick:()=>n(t.filter(u=>u!==c)),children:"\xD7"})]})),e("input",{type:"text","aria-label":r,value:o,disabled:a,placeholder:t.length?"":s,onInput:c=>i(c.target.value),onKeyDown:c=>{c.key==="Enter"||c.key===","?(c.preventDefault(),l(o)):c.key==="Backspace"&&!o&&t.length&&n(t.slice(0,-1))},onBlur:()=>o.trim()&&l(o),onPaste:c=>{let u=c.clipboardData?.getData("text")??"";/[,\n]/.test(u)&&(c.preventDefault(),l(o+u))}})]})}function qn({checked:t,onChange:n,label:s,disabled:a}){let r=e("button",{type:"button",role:"switch",class:"ds-switch","aria-checked":t,"aria-label":typeof s=="string"?s:void 0,disabled:a,onClick:()=>n(!t)});return s?e("span",{class:"ds-switch-row",children:[r,e("span",{children:s})]}):r}function X({icon:t="\u25CB",title:n,tone:s,compact:a,children:r,action:o}){return e("div",{class:E("ds-empty",a&&"compact",s),children:[e("div",{class:"ds-empty-icon","aria-hidden":"true",children:t}),e("div",{class:"ds-empty-title",children:n}),r?e("div",{class:"ds-empty-text",children:r}):null,o]})}var Kr=new Set;function ee(t,n=!1){for(let s of Kr)s(t,n)}function bi(){let[t,n]=x(null);return U(()=>{let s,a=(r,o)=>{n({msg:r,bad:o}),clearTimeout(s),s=setTimeout(()=>n(null),o?6e3:2500)};return Kr.add(a),()=>{Kr.delete(a),clearTimeout(s)}},[]),t?e("div",{class:E("toast",t.bad&&"bad"),children:t.msg}):null}function V(t,n){let[s,a]=x({data:void 0,error:void 0,loading:!0}),[r,o]=x(0),i=te(0);U(()=>{let c=++i.current;a(u=>({...u,loading:!0,error:void 0})),t().then(u=>c===i.current&&a({data:u,error:void 0,loading:!1}),u=>c===i.current&&a(d=>({...d,error:u.message,loading:!1})))},[...n,r]);let l=ut(()=>o(c=>c+1),[]);return{...s,reload:l}}var se=()=>e("span",{class:"spin"});var Z=({error:t,onRetry:n})=>e(X,{compact:!0,tone:"bad",icon:"!",title:"Could not load this view",action:n?e("button",{type:"button",class:"ds-empty-action",onClick:n,children:"Retry"}):void 0,children:t});function Ie({kind:t}){return e("span",{class:"tag kind",style:{color:xt(t)},children:t})}function Je({children:t,class:n}){return e("span",{class:E("tag",n),children:t})}function Dt({value:t,max:n,width:s=80}){let a=n>0?Math.max(2,t/n*s):2;return e("span",{class:"bar",style:{width:`${a}px`},title:String(t)})}function nt({rows:t}){return e("dl",{class:"kv",children:t.map(([n,s])=>e(R,{children:[e("dt",{children:n}),e("dd",{children:s})]}))})}function yi({left:t,center:n,right:s,leftWidth:a=280,rightWidth:r=340}){let[o,i]=x(a),[l,c]=x(r),u=te(null),[d,p]=x(null);U(()=>{let h=m=>{let f=u.current;if(!f)return;let v=m.clientX-f.x;f.side==="l"?i(Math.max(160,Math.min(700,f.start+v))):c(Math.max(200,Math.min(800,f.start-v)))},y=()=>{u.current=null,p(null)};return window.addEventListener("mousemove",h),window.addEventListener("mouseup",y),()=>{window.removeEventListener("mousemove",h),window.removeEventListener("mouseup",y)}},[]);let g=[t?`${o}px 5px`:"","minmax(0, 1fr)",s?`5px ${l}px`:""].filter(Boolean).join(" ");return e("div",{class:"split",style:{gridTemplateColumns:g},children:[t&&e(R,{children:[e("div",{class:"pane",children:t}),e("div",{class:E("gutter",d==="l"&&"on"),onMouseDown:h=>{u.current={side:"l",x:h.clientX,start:o},p("l"),h.preventDefault()}})]}),e("div",{class:"pane",children:n}),s&&e(R,{children:[e("div",{class:E("gutter",d==="r"&&"on"),onMouseDown:h=>{u.current={side:"r",x:h.clientX,start:l},p("r"),h.preventDefault()}}),e("div",{class:"pane",children:s})]})]})}function Ot(t,n,s=!0){let[a,r]=x(n),[o,i]=x(s?-1:1);return{sorted:(t??[]).slice().sort((u,d)=>{let p=u[a],g=d[a];return typeof p=="number"&&typeof g=="number"?(p-g)*o:String(p??"").localeCompare(String(g??""))*o}),th:(u,d,p=!1)=>e("th",{class:E("sortable",p&&"num",a===u&&"sorted"),onClick:()=>{a===u?i(g=>g===1?-1:1):(r(u),i(p?-1:1))},children:[d,a===u?o===1?" \u25B2":" \u25BC":""]})}}var vi=["overview","usage","explore","galaxy","history","memory","docs","coverage","sessions","swarm","adjudicator","system"],wi={swarm:["config"]},vp=["galaxy","hierarchy","map","routes","hotspots","structure","behavior"],Ms=t=>vp.includes(t??"");function wp(t){return t==="overview"||!t?"map":Ms(t)?t:"map"}function Ds(t){let n=t.replace(/^#\/?/,""),s=n.indexOf("?"),a=s<0?n:n.slice(0,s),r=s<0?"":n.slice(s+1),[o="",i=""]=a.split("/");if(o==="architecture"){let d={};for(let[p,g]of new URLSearchParams(r))d[p]=g;return d.tab=wp(d.tab),{view:"galaxy",sub:null,params:d}}let l=vi.includes(o)?o:"overview",c=i&&l===o&&wi[l]?.includes(i)?i:null,u={};for(let[d,p]of new URLSearchParams(r))u[d]=p;return{view:l,sub:c,params:u}}function Yr(t,n={}){let s=new URLSearchParams;for(let[r,o]of Object.entries(n))o&&s.set(r,o);let a=s.toString();return`/${t}${a?`?${a}`:""}`}function Vr(t,n){return n??t+1}function kp(t,n){return t-Vr(t,n)}function As(t){let n=t?.pos;return typeof n=="number"?n:void 0}function xp(t,n){return{...t&&typeof t=="object"?t:{},pos:n}}var Sp=3,_p=250;function Cp(t,n,s,a,r){return s?a===s.target?"home":"walking":a===t&&r===n?"same":"moved"}function $p(t,n){let s=kp(t,n);return s===0?{kind:"restore"}:{kind:"go",delta:s}}function Ep(t,n,s=Sp){return n===t.target?{kind:"home"}:n===void 0?{kind:"moved"}:t.tries>=s?{kind:"restore",pos:n}:{kind:"go",delta:t.target-n}}function ki(t,n,s){return!t||t===n?{kind:"keep"}:s()?{kind:"switch",root:t}:{kind:"restore",root:n}}function xi(t){let n=0,s="",a=null,r,o=(d,p)=>{let g=xp(t.history.state,d);p===void 0?t.history.replaceState(g,""):t.history.replaceState(g,"",p)},i=()=>{t.clearTimer(r),r=t.setTimer(u,_p)},l=()=>{a=null,t.clearTimer(r),r=void 0},c=()=>{let d=As(t.history.state),p=Ds(t.hash());if(!t.allow(p)){let g=$p(n,d);if(g.kind==="restore"){o(n,t.urlWithHash(s));return}d===void 0&&o(Vr(n,d)),a={target:n,tries:0},t.history.go(g.delta),i();return}n=Vr(n,d),s=t.hash(),o(n),t.show(p)};function u(){if(r=void 0,!a)return;let d=Ep(a,As(t.history.state));d.kind==="home"?l():d.kind==="go"?(a.tries++,t.history.go(d.delta),i()):d.kind==="restore"?(l(),n=d.pos,o(n,t.urlWithHash(s))):(l(),c())}return{start(){l(),n=As(t.history.state)??0,s=t.hash(),o(n)},onLocation(){let d=Cp(n,s,a,As(t.history.state),t.hash());d==="home"?l():d==="walking"?i():d==="moved"&&c()},stop:l,pos:()=>n,walking:()=>a!==null}}function H(t,n={}){location.hash=Yr(t,n)}var Vt=null;function Si(t){return Vt=t,()=>{Vt===t&&(Vt=null)}}function Zr(){return!Vt||Vt({view:"overview",sub:null,params:{}})}function _i(){let[t,n]=x(()=>Ds(location.hash));return U(()=>{let s=xi({history,hash:()=>location.hash,urlWithHash:r=>{let o=new URL(location.href);return o.hash=r,o.toString()},allow:r=>!Vt||Vt(r),show:n,setTimer:(r,o)=>setTimeout(r,o),clearTimer:r=>clearTimeout(r)});s.start();let a=()=>s.onLocation();return window.addEventListener("popstate",a),window.addEventListener("hashchange",a),()=>{window.removeEventListener("popstate",a),window.removeEventListener("hashchange",a),s.stop()}},[]),t}function pt(t,n,s,a={}){return{input:t,output:n,cacheWrite5m:t*1.25,cacheWrite1h:t*2,cacheRead:s,webSearch:10,...a}}var Hb=pt(10,50,.25),Ub=pt(10,50,1),Jb=pt(4,20,.2),Xb=pt(5,25,.5),Gb=pt(5,25,.5),Wb=pt(15,75,1.5),zb=pt(2,10,.1),qb=pt(2,10,.2),Kb=pt(3,15,.3),Vb=pt(.1,.5,.01,{longContext:{threshold:1e5,input:.5,output:2.5}}),Yb=pt(1,5,.1),Zb=pt(.8,4,.08);function Yt(t){if(!Number.isFinite(t)||t===0)return"$0.00";let n=t<0?"-":"",s=Math.abs(t);if(s<1e-4)return n?"-$0.0001":"<$0.0001";if(s<1){let r=s.toFixed(4);return r.startsWith("1")?`${n}$1.00`:`${n}$${r.replace(/0+$/,"").replace(/\.(\d)$/,".$10")}`}let a=s.toFixed(2);return Number(a)>=1e3?`${n}$${Math.round(s).toLocaleString("en-US")}`:`${n}$${a}`}var Zt=["feat","test","perf","refactor","fix","docs","other"],_n={feat:"#2563eb",test:"#16a34a",perf:"#d97706",refactor:"#7c3aed",fix:"#e11d48",docs:"#0284c7",other:"#9ca3af"},Qt=t=>_n[t]??_n.other;function Qr(t){let n=[],s=[],a=0,r=o=>{let i=n.indexOf(null);return i===-1?(i=n.length,n.push(o)):n[i]=o,i};for(let o of t){let i=n.indexOf(o.sha);i===-1&&(i=r(o.sha));let l=[];for(let d=0;d<n.length;d++)d!==i&&n[d]===o.sha&&(l.push(d),n[d]=null);let c=[],u=o.parents;if(!u.length)n[i]=null;else{n[i]=u[0];for(let d of u.slice(1)){let p=n.indexOf(d);p===-1&&(p=r(d)),c.push(p)}}for(;n.length&&n[n.length-1]===null;)n.pop();a=Math.max(a,n.length,i+1),s.push({c:o,lane:i,after:[...n],joins:l,forks:c})}return{rows:s,lanes:a}}function Ci(t){let n=[];for(let s=0;s<t.length-1;s++){let a=t[s],r=t[s+1];for(let o=0;o<a.after.length;o++){let i=a.after[o];i&&(i===r.c.sha&&o!==r.lane?n.push({kind:"curve",fromLane:o,toLane:r.lane,from:s,to:s+1,lane:o}):a.forks.includes(o)&&o!==a.lane?n.push({kind:"curve",fromLane:a.lane,toLane:o,from:s,to:s+1,lane:o}):n.push({kind:"line",lane:o,from:s,to:s+1}))}}return n}function ea(t){let n=Math.max(0,Math.min(1,t)),s=[191,219,254],a=[30,58,138],r=s.map((o,i)=>Math.round(o+((a[i]??0)-o)*n));return`rgb(${r[0]},${r[1]},${r[2]})`}function en(t=800){let n=te(null),[s,a]=x(t);return U(()=>{let r=n.current;if(!r)return;let o=new ResizeObserver(()=>a(r.clientWidth||t));return o.observe(r),a(r.clientWidth||t),()=>o.disconnect()},[]),[n,s]}function Ei({weeks:t,range:n,onRange:s,hidden:a}){let[r,o]=en(),i=150,l={l:34,r:8,t:8,b:22},c=Math.max(10,o-l.l-l.r),u=i-l.t-l.b,d=t.length,p=d?c/d:c,g=p>=5?1:0,h=Math.max(1,...t.map(T=>Zt.reduce((M,F)=>M+(a.has(F)?0:T.byBucket[F]),0))),y=T=>l.t+u-T/h*u,[m,f]=x(null),v=te(null),[b,w]=x(null),k=(T,M)=>{let F=M.getBoundingClientRect(),D=T-F.left-l.l;return Math.max(0,Math.min(d-1,Math.floor(D/p)))},C=ae(()=>{let T=[],M="";for(let D=0;D<d;D++){let $=t[D].week.slice(0,7);if($!==M){M=$;let L=new Date(t[D].at),K=L.getUTCMonth()===0||!T.length?`${L.getUTCFullYear()}`:L.toLocaleString("en",{month:"short",timeZone:"UTC"});T.push({i:D,label:K})}}let F=Math.max(1,Math.ceil(T.length/Math.max(4,c/60)));return T.filter((D,$)=>$%F===0)},[t,c]),S=b??(n?[t.findIndex(T=>T.at+7*864e5>n[0]),t.findIndex(T=>T.at>n[1])-1]:null),_=m!==null?t[m]:void 0;return e("div",{class:"hist-chart",ref:r,children:[e("svg",{width:o,height:i,onMouseMove:T=>{let M=T.currentTarget,F=k(T.clientX,M);f(F),v.current&&w([Math.min(v.current.i0,F),Math.max(v.current.i0,F)])},onMouseLeave:()=>f(null),onMouseDown:T=>{let M=T.currentTarget,F=k(T.clientX,M);v.current={x0:T.clientX,i0:F},w([F,F]),T.preventDefault()},onMouseUp:T=>{let M=v.current;if(v.current=null,!M)return;if(Math.abs(T.clientX-M.x0)<3){w(null),s(null);return}let F=b;w(null),F&&s([t[F[0]].at,t[F[1]].at+7*864e5-1])},children:[e("title",{children:"commits per week by kind"}),[0,.5,1].map(T=>e("g",{children:[e("line",{x1:l.l,x2:o-l.r,y1:y(h*T),y2:y(h*T),class:"grid"}),e("text",{x:l.l-6,y:y(h*T)+3,class:"axis","text-anchor":"end",children:Math.round(h*T)})]})),C.map(T=>e("text",{x:l.l+T.i*p,y:i-6,class:"axis",children:T.label})),S&&S[0]>=0&&S[1]>=S[0]?e("rect",{x:l.l+S[0]*p,y:l.t,width:(S[1]-S[0]+1)*p,height:u,class:"brush"}):null,t.map((T,M)=>{let F=0;return e("g",{opacity:S&&(M<S[0]||M>S[1])?.35:1,children:Zt.map(D=>{if(a.has(D))return null;let $=T.byBucket[D];if(!$)return null;let L=y(F+$),K=y(F);return F+=$,e("rect",{x:l.l+M*p+g/2,y:L,width:Math.max(.5,p-g),height:Math.max(0,K-L-(g&&K-L>2?1:0)),fill:_n[D],rx:p>=6?1.5:0})})})}),m!==null?e("line",{x1:l.l+m*p+p/2,x2:l.l+m*p+p/2,y1:l.t,y2:l.t+u,class:"cross"}):null]}),_?e("div",{class:"tip",style:{left:Math.min(o-190,l.l+m*p+10),top:4},children:[e("b",{children:["week of ",_.week]})," \xB7 ",_.total," commit",_.total===1?"":"s"," \xB7 +",_.added,"/-",_.deleted,e("div",{class:"row tight",style:{marginTop:4,flexWrap:"wrap"},children:Zt.filter(T=>_.byBucket[T]).map(T=>e("span",{class:"kdot-lbl",children:[e("i",{class:"kdot",style:{background:_n[T]}}),T," ",_.byBucket[T]]}))})]}):null]})}function Ti({counts:t,hidden:n,onToggle:s}){return e("div",{class:"row tight",style:{flexWrap:"wrap"},children:Zt.map(a=>e("button",{type:"button",class:E("chip",!n.has(a)&&"on"),onClick:()=>s(a),title:n.has(a)?`show ${a}`:`hide ${a}`,children:[e("i",{class:"kdot",style:{background:_n[a],opacity:n.has(a)?.3:1}}),a," ",t[a]??0]}))})}function ta({values:t,width:n=72,height:s=16}){let a=Math.max(1,...t),r=t.length,o=t.map((i,l)=>`${l/Math.max(1,r-1)*(n-2)+1},${s-1-i/a*(s-3)}`);return e("svg",{width:n,height:s,class:"spark",title:t.join(" "),children:[e("title",{children:["commits per month: ",t.join(" ")]}),e("polyline",{points:o.join(" ")}),t.map((i,l)=>i?e("circle",{cx:l/Math.max(1,r-1)*(n-2)+1,cy:s-1-i/a*(s-3),r:1.4}):null)]})}function Ri({files:t,selected:n,onSelect:s}){let[a,r]=en(),o=300,i={l:42,r:16,t:12,b:30},l=Math.max(10,r-i.l-i.r),c=o-i.t-i.b,u=t.filter(w=>w.commits>=2),d=Math.max(2,...u.map(w=>w.commits)),p=Math.max(1,...u.map(w=>w.added+w.deleted)),g=w=>i.l+Math.log(w)/Math.log(d)*l,h=w=>i.t+c-w*c,y=w=>3+Math.sqrt((w.added+w.deleted)/p)*13,[m,f]=x(null),v=[...u].sort((w,k)=>k.risk-w.risk).slice(0,5),b=[1,2,5,10,20,50,100,200,500,1e3].filter(w=>w<=d);return e("div",{class:"hist-chart",ref:a,children:[e("svg",{width:r,height:o,children:[e("title",{children:"files by commits and fix share, sized by lines changed"}),[0,.25,.5,.75,1].map(w=>e("g",{children:[e("line",{x1:i.l,x2:r-i.r,y1:h(w),y2:h(w),class:"grid"}),e("text",{x:i.l-6,y:h(w)+3,class:"axis","text-anchor":"end",children:[Math.round(w*100),"%"]})]})),b.filter(w=>g(w)<r-i.r-70).map(w=>e("text",{x:g(w),y:o-8,class:"axis","text-anchor":"middle",children:w})),e("text",{x:r-i.r,y:o-8,class:"axis","text-anchor":"end",children:"commits (log) \u2192"}),e("text",{x:i.l+4,y:i.t+10,class:"axis",children:"share of commits that were fixes \u2191"}),u.map(w=>e("circle",{cx:g(w.commits),cy:h(w.commits?w.fixes/w.commits:0),r:y(w),fill:ea(w.risk),class:E("dot",n===w.path&&"sel"),onMouseEnter:()=>f(w),onMouseLeave:()=>f(null),onClick:()=>s(w.path)})),v.map(w=>{let k=g(w.commits)>r-160;return e("text",{x:k?g(w.commits)-y(w)-3:g(w.commits)+y(w)+3,y:h(w.fixes/w.commits)+3,class:"lbl","text-anchor":k?"end":"start",children:w.path.split("/").slice(-2).join("/")})})]}),m?e("div",{class:"tip",style:{left:Math.min(r-260,g(m.commits)+12),top:Math.max(0,h(m.fixes/m.commits)-60)},children:[e("b",{children:m.path}),e("div",{class:"muted",children:[m.commits," commits \xB7 ",m.fixes," fixes \xB7 +",m.added,"/-",m.deleted," \xB7 risk"," ",m.risk.toFixed(2)]}),m.reasons.length?e("div",{class:"muted",children:m.reasons.join("; ")}):null]}):null]})}var $i=["#2563eb","#d97706","#16a34a","#7c3aed","#e11d48","#0284c7","#db2777","#0d9488"],Ls=t=>$i[t%$i.length];function Ai({rows:t,lanes:n,rowH:s,selected:a}){let o=n*14+10,i=u=>7+u*14,l=u=>u*s+s/2,c=Ci(t);return e("svg",{class:"lanes",width:o,height:t.length*s,children:[e("title",{children:"commit graph"}),c.map(u=>u.kind==="line"?e("line",{x1:i(u.lane),x2:i(u.lane),y1:l(u.from),y2:l(u.to),stroke:Ls(u.lane)}):e("path",{d:`M${i(u.fromLane)},${l(u.from)} C${i(u.fromLane)},${l(u.from)+s/2} ${i(u.toLane)},${l(u.to)-s/2} ${i(u.toLane)},${l(u.to)}`,stroke:Ls(u.lane)})),t.map((u,d)=>e("circle",{cx:i(u.lane),cy:l(d),r:u.c.merge?3.5:4,fill:u.c.merge?"var(--card)":Ls(u.lane),stroke:Ls(u.lane),"stroke-width":a===u.c.sha?3:u.c.merge?2:1,class:E(a===u.c.sha&&"sel",!u.c.onHead&&"off")}))]})}var Ps=["heuristic","blend","cache","fallback"],Cn={heuristic:"#2563eb",blend:"#7c3aed",cache:"#0d9488",fallback:"#d97706"},Kn={heuristic:"local heuristic only",blend:"heuristic blended with the provider",cache:"reused an earlier verdict for the same text",fallback:"provider failed or was skipped; heuristic used"},sa=["heuristic","provider","learned"],Is={heuristic:"#2563eb",provider:"#7c3aed",learned:"#d97706"},ji={heuristic:"local features (words, intents, paths, risk \u2026) scored on this machine",provider:"the provider's probability \xD7 \u03B1 (its weight in the blend)",learned:"learned bias from past outcomes, plus provider risk / plan boosts"},Fs=["trivial","simple","moderate","complex","very complex"];function Os(t){return typeof t!="number"||!Number.isFinite(t)?"n/a":Fs[Math.max(0,Math.min(4,Math.round(t)))]}function _t(t){return typeof t=="number"&&Number.isFinite(t)?`${Math.round(t*100)}%`:"\u2014"}function Me(t){return typeof t!="number"||!Number.isFinite(t)?"\u2014":t<1e3?`${Math.round(t)} ms`:`${(t/1e3).toFixed(t<1e4?1:0)} s`}var Tp=t=>Math.round(t*100)/100;function Ns(t){let n=Tp(t);return n>0?`+${n.toFixed(2)}`:n<0?`\u2212${Math.abs(n).toFixed(2)}`:"0.00"}var Mi=new Set(["bias","risky","needsPlan"]),js=(t,n)=>t.reduce((s,a)=>n(a.feature)?s+(Number(a.weight)||0):s,0);function Pi(t,n=0){let s=t.entries??[],a=s.reduce((d,p)=>d+js(p.reasons??[],g=>Mi.has(g)),0),r=Math.max(1e-9,1+a),o=[...s].sort((d,p)=>p.score-d.score),i=t.choice??o[0]?.option??"",l=o.find(d=>d.option!==i)??null,c=o.map(d=>{let p=d.reasons??[],g=Math.max(0,d.score)*r,h=Math.max(0,Math.min(g,js(p,v=>v==="provider"))),y=Math.max(0,Math.min(g-h,js(p,v=>Mi.has(v)))),m=Math.max(0,g-h-y),f=g>0?d.score/g:0;return{...d,reasons:p,parts:{heuristic:m*f,provider:h*f,learned:y*f},chosen:d.option===i,runnerUp:l!==null&&d.option===l.option}}),u=c.find(d=>d.chosen);return{dimension:t.dimension,entries:c,choice:i,runnerUp:l?.option??null,margin:u&&l?u.score-l.score:null,confidence:t.confidence??0,roundedUp:!!o[0]&&o[0].option!==i,alpha:n,providerShare:u&&u.score>0?u.parts.provider/u.score:0}}function ra(t,n=1/0){return[...t??[]].sort((s,a)=>Math.abs(a.weight)-Math.abs(s.weight)).slice(0,n)}function Ii(t,n){let s=n??[],a=s.filter(o=>o.feature==="provider"),r=js(a,()=>!0);return{value:t,heuristic:t-r,provider:r,terms:ra(s.filter(o=>o.feature!=="provider")),providerNote:a[0]?.note??null}}function Fi(t){return t.startsWith("intent.")?`intent: ${t.slice(7)}`:t}var Rp={advised:{label:"advised",tone:"accent",help:"advice was given; whether it was taken is not known yet"},followed:{label:"followed",tone:"ok",help:"the advice was taken (advise mode)"},applied:{label:"applied",tone:"ok",help:"the adjudicator set the model itself (apply mode)"},respected:{label:"respected",tone:"muted",help:"apply mode left an explicitly pinned model alone"},ignored:{label:"ignored",tone:"warn",help:"a different choice was made than advised"},none:{label:"none",tone:"muted",help:"nothing to advise on (e.g. too short or chat)"}},aa=t=>Rp[t??"none"]??{label:t??"\u2014",tone:"muted",help:""},oa={pending:{tone:"muted",help:"the work has not finished yet"},success:{tone:"ok",help:"the work finished and was not redone"},failure:{tone:"bad",help:"the work failed or had to be redone"},abandoned:{tone:"warn",help:"the session ended before the work finished"},"n/a":{tone:"muted",help:"no outcome is tracked for this surface"}},Oi=t=>oa[t??""]?.tone??"muted";function ia(t){return!t||t==="n/a"||t==="skipped"?"muted":t==="ok"?"ok":t==="slow_guard"||t==="over_budget"||t==="breaker_open"||t==="rate_limited"?"warn":"bad"}function Bs(t){switch(t){case null:case void 0:return{label:"not called yet",tone:"muted",help:"no call has been made to this provider"};case"closed":return{label:"healthy",tone:"ok",help:"breaker closed: calls go through"};case"half_open":return{label:"probing",tone:"warn",help:"breaker half-open: the next call is a probe"};case"open":return{label:"paused",tone:"bad",help:"breaker open: calls skip the provider until the retry time"};case"slow":return{label:"slow",tone:"warn",help:"recent calls ran past the latency budget"};case"auth_failed":return{label:"auth failed",tone:"bad",help:"the provider rejected the key"};default:return{label:t.replace(/_/g," "),tone:"warn",help:`breaker state ${t}`}}}var Ap={used:"heuristic blended with the provider",disabled:"the adjudicator is off: heuristic only",not_requested:"heuristic only (provider not requested)",heuristic_configured:"heuristic only: no provider is configured",no_key:"heuristic only: the provider has no key",no_consent:"heuristic only: remote consent has not been given",hook_context:"heuristic only in this context",misconfigured:"heuristic only: the provider is misconfigured"},Ni=t=>Ap[t]??t.replace(/_/g," "),Hs={no_key:"no key found: run `eminiar adjudicator key set` or set keyEnv",no_consent:"remote consent not given: run `eminiar adjudicator consent`",misconfigured:"the provider settings are incomplete",hook_context:"remote providers are not called from hooks"};function Bi(t){return Math.max(1,...t.map(n=>n.total))}function Hi(t){let n=Math.max(1,Math.ceil(t));if(n<=2)return[0,n];let s=Math.ceil(n/2);return[0,s,s*2]}var Di=["haiku","sonnet","opus","fable"];function Li(t,n){let s=Di.indexOf(t),a=Di.indexOf(n);return s>=0&&a>=0?s-a:s>=0?-1:a>=0?1:t.localeCompare(n)}function Us(t){let n=new Map,s=new Set,a=new Set,r=0,o=0,i=0;for(let l of t){let c=`${l.suggested}\0${l.actual}`,u=(n.get(c)??0)+l.n;n.set(c,u),s.add(l.suggested),a.add(l.actual),r=Math.max(r,u),o+=l.n,l.suggested===l.actual&&(i+=l.n)}return{rows:[...s].sort(Li),cols:[...a].sort(Li),cell:(l,c)=>n.get(`${l}\0${c}`)??0,max:r,total:o,agree:i}}function la(t){if(!t)return"";let n=[];return t.pin&&n.push(`${t.pin} kept their pin`),t.force&&n.push(`${t.force} under CLAUDE_CODE_SUBAGENT_MODEL_FORCE`),t.fork&&n.push(`${t.fork} fork${t.fork===1?"":"s"}`),n.join(" \xB7 ")}function Js(t,n){return!(t>0)||!(n>0)?0:.08+.82*(t/n)}function Ui(t,n,s){let a={limit:n,offset:s};return t.since&&t.since!=="all"&&(a.since=t.since),t.surface&&(a.surface=t.surface),t.provider&&(a.provider=t.provider),t.outcome&&(a.outcome=t.outcome),a}function Ji(t,n,s){return!s||!n?`0 of ${s}`:`${t+1}\u2013${t+n} of ${s}`}function Xi(t){return t.surface==="prompt"?"main-session advice: potential savings only, never added to net":t.surface==="test"?"try-it runs are not counted":t.action!=="followed"&&t.action!=="applied"?"no credit: the advice was not followed or applied":t.savingsUsd===null||t.savingsUsd===void 0?t.final?"no usage data to price this dispatch (usage ingest off?)":"not reconciled yet: waits for the dispatch to finish":t.outcome==="failure"&&t.savingsUsd<0?"redo penalty: the attempt failed and its full cost is charged":"baseline model cost \u2212 actual cost at list prices, same tokens"}function Gi(t){if(t.usageAvailable)return null;let n=t.creditedRows>0||t.realisedUsd!==0;return{label:n?"no API calls recorded: new dispatches and potential savings are not priced":"no API calls recorded: savings cannot be priced",help:"Savings are priced from Claude Code's API calls, which usage ingestion records (config.usage.enabled). Without them reconcile cannot price new dispatches and potential savings stay $0"+(n?"; realised and net still include the dispatches priced earlier.":"; spend still counts the adjudicator's own provider calls.")}}function Wi(t,n=5,s=.05){return Object.entries(t?.intents??{}).filter(r=>typeof r[1]=="number"&&r[1]>=s).sort((r,o)=>o[1]-r[1]).slice(0,n)}function zi(t){if(!t)return[];let n=[],s=(a,r)=>{typeof r=="number"&&r>0&&n.push([a,String(Math.round(r*100)/100)])};return s("words",t.words),s("lines",t.lines),s("paths",t.paths),s("symbols",t.symbols),typeof t.scope=="number"&&n.push(["scope",t.scope.toFixed(2)]),typeof t.risk=="number"&&n.push(["risk",t.risk.toFixed(2)]),t.codeBlock&&n.push(["code block","yes"]),t.stackTrace&&n.push(["stack trace","yes"]),t.chat&&n.push(["chat","yes"]),t.slash&&n.push(["slash command","yes"]),t.classify&&n.push(["classified",t.classify]),t.task&&(t.task.role&&n.push(["task role",t.task.role]),n.push(["task files",String(t.task.files)]),n.push(["task deps",String(t.task.deps)])),n}var na=t=>t==null?"\u2014":typeof t=="number"?Number.isInteger(t)?String(t):Math.abs(t)<=1?t.toFixed(3):t.toFixed(1):typeof t=="boolean"?t?"yes":"no":typeof t=="string"?t:JSON.stringify(t);function Mp(t){let n={};for(let[s,a]of Object.entries(t))if(a&&typeof a=="object"&&!Array.isArray(a))for(let[r,o]of Object.entries(a))o&&typeof o=="object"||(n[`${s}.${r}`]=na(o));else Array.isArray(a)||(n[s]=na(a));return n}function qi(t){if(!t)return null;let s=["rows","results","providers","candidates"].map(o=>t[o]).find(o=>Array.isArray(o)&&o.length)??Object.values(t).find(o=>Array.isArray(o)&&o.length&&o.every(i=>i&&typeof i=="object"));if(!Array.isArray(s))return null;let a=s.filter(o=>o&&typeof o=="object").map(o=>Mp(o)),r=[];for(let o of a)for(let i of Object.keys(o))r.includes(i)||r.push(i);return{columns:r,rows:a}}function Ki(t){return t?Object.entries(t).filter(([,n])=>n===null||typeof n!="object").map(([n,s])=>[n,na(s)]):[]}var Dp="eminiar adjudicator exchanges on",Lp="eminiar adjudicator exchanges purge --yes",ca=100,Vi="api.typesafe.ai",je=t=>Me(t);function da(t){if(typeof t!="number"||!Number.isFinite(t)||t<0)return"\u2014";let n=Math.round(t);return`${n.toLocaleString("en-US")} ${n===1?"character":"characters"}`}function ua(t,n){let s=a=>typeof a!="number"||!Number.isFinite(a)?"\u2014":a>=1e3?`${(a/1e3).toFixed(1)}k`:String(Math.round(a));return`${s(t)} / ${s(n)}`}function pa(t){let n=typeof t.status=="number"&&t.status>0?t.status:null;switch(t.outcome){case"ok":return n!==null?String(n):"ok";case"timeout":return"timeout";case"rate_limited":return n!==null?`${n} rate limited`:"rate limited";case"http_error":return n!==null?`http ${n}`:"http error";case"invalid":return"invalid";case"no_key":return"no key";default:return String(t.outcome).replace(/_/g," ")||"unknown"}}function Yi(t){switch(t){case"ok":return"ok";case"timeout":case"http_error":return"bad";case"rate_limited":case"invalid":return"warn";default:return"muted"}}function Zi(t){let n=t.durationMs,s=t.deadlineMs;if(typeof n!="number"||!Number.isFinite(n)||typeof s!="number"||s<=0)return{frac:0,over:t.timedOut};let a=n/s;return{frac:Math.min(1,Math.max(0,a)),over:t.timedOut||a>=1}}function Qi(t){let n=je(t.waitMs);return typeof t.jobWaitMs=="number"&&t.jobWaitMs>0?`${n} \xB7 job +${je(t.jobWaitMs)}`:n}function el(t){return t.retryWaitMs>0?`${t.attempts} \xB7 \u21BB ${je(t.retryWaitMs)}`:String(t.attempts)}function tl(t,n=Date.now()){if(!Number.isFinite(t)||t<=0)return"\u2014";let s=Math.max(0,n-t);return s<6e4?"just now":s<36e5?`${Math.round(s/6e4)}m ago`:s<864e5?`${Math.round(s/36e5)}h ago`:`${Math.round(s/864e5)}d ago`}var $n=t=>typeof t=="number"&&Number.isFinite(t)&&t>0?t:0;function nl(t){let n=$n(t.jobWaitMs),s=$n(t.waitMs),a=$n(t.durationMs),r=Math.min($n(t.retryWaitMs),a),o=Math.min($n(t.ttfbMs),Math.max(0,a-r)),i=Math.max(0,a-r-o),l=[{key:"job",label:"job wait",help:"queued in the background scoring job before it started",ms:n},{key:"wait",label:"wait before send",help:"from the start of the call to the moment the request was sent",ms:s},{key:"retry",label:"retry wait",help:"pause before the second attempt, after a 429 or 529",ms:r},{key:"ttfb",label:"to first byte",help:"from sending the final attempt to the first byte of the answer",ms:o},{key:"rest",label:t.attempts>1?"first attempt + body":"body read",help:t.attempts>1?"the superseded first attempt and reading the final answer":"reading the answer after its first byte",ms:i}],c=l.reduce((y,m)=>y+m.ms,0),u=$n(t.deadlineMs),d=u>0?n+s+u:0,p=Math.max(c,d),g=0;return{segments:l.filter(y=>y.ms>0).map(y=>{let m=p>0?g/p:0,f=p>0?y.ms/p:0;return g+=y.ms,{...y,start:m,width:f}}),totalMs:p,deadlineAt:d>0&&p>0?d/p:null}}function sl(t){if(!t)return{text:"",formatted:!1,note:null};let n=t.truncated?`truncated: the stored text is cut, the body was ${da(t.bytes)}`:null;if(t.json&&!t.truncated)try{return{text:JSON.stringify(JSON.parse(t.text),null,2),formatted:!0,note:n}}catch{}return{text:t.text,formatted:!1,note:n}}function jp(t){let n=(t??"").trim();return n&&n.split(/[/?#]/)[0]||Vi}function rl(t,n=ca){return`Contains your redacted prompt text: each row is the exact request sent to ${jp(t)} (redacted, up to privacy.maxChars characters per item) and Jev's answer, stored in this project's local database. Only the newest ${n} are kept. Delete them: ${Lp}`}function al(){return{before:"Request capture is off. To see each request eminiar sends to Jev, what it contained, what came back and how long it took, run",command:Dp,after:"It is a personal setting: a project's eminiar.config.json cannot turn it on. Captured requests contain your redacted prompt text."}}var ol="Capture is on. No request has gone to Jev since. Prompt scoring runs in the background, so a request appears when that job finishes.";function il(t){return t?t.active?t.capture?t.rows.length?"rows":"empty":"off":"hidden":"loading"}function ll(t,n){return`Request #${t.id} \xB7 ${n} \xB7 ${pa(t)}`}var dl=t=>new Date(t).toLocaleString(),Pp=t=>new Date(t).toISOString();function ul({x:t}){let n=Yi(t.outcome);return e(I,{tone:n,children:pa(t)})}function Ip({x:t}){let{frac:n,over:s}=Zi(t);return e("span",{class:"xchg-meter",title:`${je(t.durationMs)} of a ${je(t.deadlineMs)} deadline`,role:"img","aria-label":`${je(t.durationMs)} of a ${je(t.deadlineMs)} deadline`,children:e("span",{class:E("xchg-meter-fill",s&&"over"),style:{width:`${Math.max(n>0?3:0,Math.round(n*100))}%`}})})}function Fp({rows:t,now:n,onRow:s,onOpen:a}){return e("div",{class:"adj-scroll",children:e("table",{class:"adj-tiers xchg-table",children:[e("thead",{children:e("tr",{children:[e("th",{children:"time"}),e("th",{children:"surface"}),e("th",{children:"result"}),e("th",{children:"duration"}),e("th",{class:"num",children:"wait"}),e("th",{class:"num",children:"tries"}),e("th",{class:"num",children:"items"}),e("th",{class:"num",title:"tokens in / out",children:"tokens"}),e("th",{children:"decisions"})]})}),e("tbody",{children:t.map(r=>e("tr",{class:"xchg-row",onClick:()=>s(r.id),children:[e("td",{title:Pp(r.ts),children:e("button",{type:"button",class:"adj-link",onClick:o=>{o.stopPropagation(),s(r.id)},"aria-label":`open request ${r.id}`,children:tl(r.ts,n)})}),e("td",{children:r.surface??"\u2014"}),e("td",{children:e(ul,{x:r})}),e("td",{children:e("span",{class:"xchg-dur",children:[je(r.durationMs),e(Ip,{x:r})]})}),e("td",{class:"num",children:Qi(r)}),e("td",{class:"num",children:el(r)}),e("td",{class:"num",children:r.items}),e("td",{class:"num",children:ua(r.tokensIn,r.tokensOut)}),e("td",{children:r.rowIds.length?e("span",{class:"xchg-ids",children:r.rowIds.map(o=>e("button",{type:"button",class:"adj-link",onClick:i=>{i.stopPropagation(),a(o)},children:["#",o]},o))}):e("span",{class:"muted",children:"\u2014"})})]},r.id))})]})})}function Op({x:t}){let n=nl(t);return n.segments.length?e(R,{children:[e("div",{class:"xchg-bar",role:"img","aria-label":"request timing",children:[n.segments.map(s=>e("span",{class:`xchg-seg xchg-seg-${s.key}`,style:{left:`${s.start*100}%`,width:`${s.width*100}%`},title:`${s.label}: ${je(s.ms)} (${s.help})`},s.key)),n.deadlineAt!==null?e("span",{class:"xchg-deadline",style:{left:`${n.deadlineAt*100}%`},title:`deadline ${je(t.deadlineMs)} after sending`}):null]}),e("ul",{class:"xchg-legend small",children:[n.segments.map(s=>e("li",{title:s.help,children:[e("span",{class:`xchg-dot xchg-seg-${s.key}`})," ",s.label," ",je(s.ms)]},s.key)),n.deadlineAt!==null?e("li",{children:[e("span",{class:"xchg-dot xchg-dot-deadline"})," deadline ",je(t.deadlineMs)]}):null]})]}):e(X,{compact:!0,icon:"\u2581",title:"No timing recorded"})}function cl({title:t,body:n,kind:s}){if(!n)return e("div",{class:"muted small",children:["no ",s," was stored"]});let a=sl(n),r=async()=>{try{await navigator.clipboard.writeText(a.text),ee(`${t} copied`)}catch{ee("could not copy",!0)}};return e(R,{children:[e("div",{class:"xchg-body-head small",children:[e("span",{class:"muted",children:[da(n.bytes),a.formatted?" \xB7 formatted JSON":n.json?" \xB7 JSON":" \xB7 text"]}),e("button",{type:"button",class:"ghost sm",onClick:r,children:"Copy"})]}),a.note?e("div",{class:"warn small xchg-trunc",children:a.note}):null,e("pre",{class:"xchg-json",children:a.text})]})}function Np({x:t}){let n=[["sent at",dl(t.ts)],["wait before send",je(t.waitMs)],["job wait",t.jobWaitMs===null?"\u2014 (not a background job)":je(t.jobWaitMs)],["to first byte",je(t.ttfbMs)],["duration",je(t.durationMs)],["retry wait",t.retryWaitMs>0?je(t.retryWaitMs):"\u2014"],["attempts",String(t.attempts)],["deadline",je(t.deadlineMs)],["engine budget",je(t.budgetMs)],["timed out",t.timedOut?"yes":"no"],["HTTP status",t.status===null?"\u2014":String(t.status)]];return e("dl",{class:"kv xchg-facts",children:n.map(([s,a])=>e(R,{children:[e("dt",{children:s}),e("dd",{children:a})]}))})}function Bp({x:t,onOpen:n}){return e(R,{children:[e("section",{children:[e("div",{class:"adj-h",children:"Timing"}),e(Op,{x:t}),e(Np,{x:t})]}),t.rowIds.length?e("section",{children:[e("div",{class:"adj-h",children:"Decisions this request served"}),e("span",{class:"xchg-ids",children:t.rowIds.map(s=>e("button",{type:"button",class:"adj-link",onClick:()=>n(s),children:["#",s]},s))})]}):null,e("section",{children:[e("div",{class:"adj-h",children:["Request",e("span",{class:"right muted small",children:[t.target," \xB7 ",t.model??"model unknown"," \xB7 ",t.items," item",t.items===1?"":"s"]})]}),e(cl,{title:"request",body:t.request,kind:"request"})]}),e("section",{children:[e("div",{class:"adj-h",children:["Response",e("span",{class:"right muted small",children:[ua(t.tokensIn,t.tokensOut)," tokens",t.costUsd!==null?` \xB7 $${t.costUsd.toFixed(4)}`:""]})]}),t.error?e("div",{class:"warn small xchg-trunc",children:["error: ",t.error]}):null,e(cl,{title:"response",body:t.response,kind:"response"})]})]})}function Hp({id:t,onClose:n,onOpen:s}){let a=V(()=>ci(t),[t]),r=te(null);U(()=>{let i=document.activeElement;r.current?.focus();let l=c=>{c.key==="Escape"&&n()};return window.addEventListener("keydown",l),()=>{window.removeEventListener("keydown",l),i?.focus?.()}},[t]);let o=a.data?.active&&a.data.capture?a.data.exchange:null;return e(R,{children:[e("div",{class:"adj-backdrop",onClick:n}),e("aside",{class:"adj-drawer",ref:r,tabIndex:-1,role:"dialog","aria-modal":"true","aria-label":`Jev request ${t}`,children:[e("div",{class:"adj-drawer-head",children:[e("b",{children:o?ll(o,dl(o.ts)):`Request #${t}`}),o?e(ul,{x:o}):null,e("span",{class:"spacer"}),e("button",{type:"button",class:"ghost sm",onClick:n,"aria-label":"close",children:"\u2715 close"})]}),e("div",{class:"adj-drawer-body",children:a.error?e(Z,{error:a.error}):a.data?o?e(Bp,{x:o,onOpen:i=>{n(),s(i)}}):e(X,{compact:!0,icon:"\u25CB",title:"Nothing to show",children:"Request capture is off or Jev is not the provider."}):e(se,{})})]})]})}function pl({tick:t,onOpen:n}){let s=V(()=>li(),[t]),[a,r]=x(null),o=il(s.data);if(o==="hidden")return null;let i=s.data?.active&&s.data.capture?s.data:null,l=s.data?.active?s.data.keep:ca,c=`newest ${l} kept \xB7 capture ${o==="off"?"off":o==="loading"?"\u2026":"on"}`,u;if(s.error)u=e(Z,{error:s.error});else if(o==="loading")u=e(N,{h:120});else if(o==="off"){let d=al();u=e(X,{compact:!0,icon:"\u25CB",title:"Request capture is off",children:[d.before," ",e("code",{class:"adj-cmd",children:d.command}),". ",d.after]})}else o==="empty"?u=e(X,{compact:!0,icon:"\u25B8",title:"No requests captured yet",children:ol}):u=e(R,{children:[e("div",{class:"jev-banner warn small",role:"note",children:rl(i?.rows[0]?.target,l)}),e(Fp,{rows:i?.rows??[],now:i?.now??Date.now(),onRow:r,onOpen:n}),i&&i.total>i.rows.length?e("div",{class:"muted small jev-notes",children:["showing the newest ",i.rows.length," of ",i.total]}):null]});return e(j,{class:"jev-xchg ds-block",title:"Jev requests",right:c,children:[u,a!==null?e(Hp,{id:a,onClose:()=>r(null),onOpen:n}):null]})}function Xs(t){return!!t&&t.enabled===!0&&t.provider?.configured==="typesafe"}var Vn=t=>t==null||!Number.isFinite(t)?"\u2014":Yt(t);function gl(t){return t==="helping"?"ok":t==="hindering"?"bad":"muted"}function hl(t){return t==="help"?"ok":t==="hurt"?"bad":"muted"}var Up={too_small_after_up:"marked too small after Jev moved it up",too_big_after_up:"marked too big after Jev moved it up",good_after_up:"marked good after Jev moved it up",too_small_after_down:"marked too small after Jev moved it down",too_big_after_down:"marked too big after Jev moved it down",good_after_down:"marked good after Jev moved it down",success_after_down:"the cheaper model finished the work",failure_after_down:"the cheaper model failed or was redone",success_after_up:"finished on the bigger model (not counted)",failure_after_up:"failed even on the bigger model (not counted)"};function fl(t){return Up[t]??t.replace(/_/g," ")}function bl(t){let n=[...t.reasons??[]];return t.n&&n.push(`n = ${t.n}`),n.join(" \xB7 ")}function yl(t){return Us((t??[]).map(n=>({suggested:n.from,actual:n.to,n:n.n})))}function Jp(t,n){return!t.n||!n.n||t.p50===null||n.p50===null?null:Math.max(0,t.p50-n.p50)}var ml=(t,n)=>n>0?_t(t/n):"\u2014";function vl(t,n){let s=t.influence.tier,a=t.influence.effective,r=t.cost,o=s.up+s.down,i=Math.max(0,s.compared-s.uncertain),l=t.coverage,c=Math.max(0,l.attempts-l.errors),u=Jp(r.inline,r.heuristicInline),d=t.savings,p=Bs(n),g=d.usageAvailable&&d.repriced>0;return[{title:"changed the tier",value:ml(o,i),sub:`\u2191${s.up} \u2193${s.down} of ${i} compared \xB7 ${s.uncertain} uncertain left out \xB7 ${t.sample.deferred} deferred`,help:"decisions where Jev moved the tier away from what the heuristic alone would have chosen; uncertain near-ties and deferred async prompt rows are not counted"},{title:"effective model changed",value:ml(a.changed,a.dispatches),sub:`${a.changed} of ${a.dispatches} dispatches \xB7 unknown ${a.unknown}`,help:"dispatches whose model, after the apply bounds, differs from what the heuristic alone would have led to; unknown: a ranged role or apply bounds that are not stored could have changed the answer"},{title:"Jev calls",value:String(l.attempts),sub:`${c} answered \xB7 failure ${_t(l.failureRate)} \xB7 p50 ${Me(r.providerLatency.p50)} \xB7 breaker ${p.label}`,help:"provider calls attempted for decisions in range, answered or not (timeouts and errors included), and the share that failed"},{title:"Jev spend",value:Vn(r.spendUsd),sub:`${r.usdPerCall===null?"\u2014":Yt(r.usdPerCall)} per call \xB7 adds ${u===null?"\u2014":`~${Me(u)}`} inline`,help:"the provider's own cost; the added wait is the p50 inline latency of Jev decisions minus heuristic-only ones"},{title:"net from Jev's changes",value:g?Vn(d.netUsd):"\u2014",sub:d.usageAvailable?d.repriced===0?"no repriced dispatches yet":`saved ${Vn(d.downSavedUsd)} \xB7 extra ${Vn(d.upCostUsd)} \xB7 spend ${Vn(r.spendUsd)}`:"no usage data",help:"cost the changed dispatches would have had on the heuristic's model, minus what they cost, minus Jev's spend (list prices)"}]}function wl(t){return Object.entries(t.bySurface??{}).map(([n,s])=>({label:n,...s})).filter(n=>n.compared>0).sort((n,s)=>s.compared-n.compared||n.label.localeCompare(s.label))}function ma(t){return t.compared?`agree ${t.agree} of ${t.compared} \xB7 ${t.changed} changed \xB7 ${t.uncertain} uncertain`:"no compared decisions"}function kl(t){if(!t.n||t.meanDelta===null)return t.excludedBeforeFix?`no scored rows yet (${t.excludedBeforeFix} before the score-scale fix left out)`:"no scored rows yet";let n=t.meanDelta;return`mean \u0394 ${n>0?"+":n<0?"\u2212":""}${Math.abs(n).toFixed(2)} \xB7 mean |\u0394| ${(t.meanAbsDelta??0).toFixed(2)} over ${t.n}`+(t.excludedBeforeFix?` \xB7 ${t.excludedBeforeFix} before the score-scale fix left out`:"")}function Xp(t){let n=t.success+t.failure;return n?`${_t(t.successRate)} of ${n}`:"\u2014"}function xl(t,n){let s=(a,r)=>({label:a,changed:r(t),unchanged:r(n)});return[s("dispatches",a=>String(a.dispatches)),s("advice followed",a=>_t(a.followRate)),s("success",Xp),s("feedback: good",a=>String(a.feedback.good)),s("feedback: too small",a=>String(a.feedback.too_small)),s("feedback: too big",a=>String(a.feedback.too_big))]}function Sl(t){return[`kept model ${t.kept}`,`deferred ${t.deferred}`,`fell back ${t.notJev}`,`uncertain ${t.uncertain+t.unreconstructable}`,`unknown model ${t.unknown}`,`apply bounds not stored ${t.bounds??0}`,`advised tier not run ${t.notRun??0} (outcome and feedback not counted)`,`outcome not final yet ${t.notFinal??0}`].join(" \xB7 ")}function _l(t){let n=t.cost,s=[];n.providerLatency.n&&s.push(`provider p50 ${Me(n.providerLatency.p50)} \xB7 p95 ${Me(n.providerLatency.p95)} over ${n.providerLatency.n}`),n.inline.n&&s.push(`inline p50 ${Me(n.inline.p50)} over ${n.inline.n}`),s.push(`deferred ${n.deferred}`),s.push(`timeouts ${n.timeouts}`);let a=Object.entries(t.sample.models??{}).sort((o,i)=>i[1]-o[1]).map(([o,i])=>`${o}: ${i}`);a.length&&s.push(`models ${a.join(", ")}`);let r=t.sample.eras;return(r.units||r.wholeText)&&s.push(`briefs per statement ${r.units} \xB7 as one text ${r.wholeText}`),s}function Gp({t}){let n=yl(t.transitions);return n.total?e(R,{children:[e("div",{class:"adj-scroll",children:e("table",{class:"adj-matrix",children:[e("thead",{children:e("tr",{children:[e("th",{class:"corner",children:"heuristic \u2193 \xB7 with Jev \u2192"}),n.cols.map(s=>e("th",{class:"num",children:s}))]})}),e("tbody",{children:n.rows.map(s=>e("tr",{children:[e("th",{children:s}),n.cols.map(a=>{let r=n.cell(s,a),o=Js(r,n.max);return e("td",{class:E("num","cell",s===a&&"diag",o>.55&&"strong"),style:o?{background:`color-mix(in srgb, var(--accent) ${Math.round(o*100)}%, transparent)`}:void 0,title:`${r} decisions: heuristic ${s}, with Jev ${a}`,children:r||""})})]}))})]})}),e("div",{class:"sub",children:[n.agree," of ",n.total," kept the heuristic's tier \xB7 outlined cells are agreement"]}),e("div",{class:"muted small jev-notes",children:["Jev overruled by the heuristic ",t.jevOverruled," \xB7 rounded up for low confidence"," ",t.roundUps.final," (only because of blending: ",t.roundUps.blendInduced,")",t.wouldHaveChanged.compared?` \xB7 deferred (async) ${t.wouldHaveChanged.changed} of ${t.wouldHaveChanged.compared} would have changed`:""]})]}):e(X,{compact:!0,icon:"\u25A6",title:"No compared decisions yet"})}function Wp({r:t}){let n=t.influence.tier,s=wl(n),a=t.influence.effort;return e(R,{children:[s.length?e("div",{class:"adj-scroll",children:e("table",{class:"adj-tiers",children:[e("thead",{children:e("tr",{children:[e("th",{children:"surface"}),e("th",{class:"num",children:"compared"}),e("th",{class:"num",children:"agree"}),e("th",{class:"num",title:"Jev raised the tier",children:"\u2191"}),e("th",{class:"num",title:"Jev lowered the tier",children:"\u2193"})]})}),e("tbody",{children:s.map(r=>e("tr",{children:[e("td",{children:r.label}),e("td",{class:"num",children:r.compared}),e("td",{class:"num",children:r.agree}),e("td",{class:"num",children:r.up}),e("td",{class:"num",children:r.down})]}))})]})}):e(X,{compact:!0,icon:"\u25A6",title:"No compared decisions yet"}),e("ul",{class:"jev-lines",children:[e("li",{children:[e("b",{children:"role"})," ",ma(t.influence.role)]}),e("li",{children:[e("b",{children:"tool"})," ",ma(t.influence.tool)," ",e("span",{class:"muted",children:"(tools change only through Jev's needs-plan boost)"})]}),e("li",{children:[e("b",{children:"effort"})," \u2191",a.up," \u2193",a.down," of ",a.compared]}),e("li",{children:[e("b",{children:"complexity"})," ",kl(t.influence.complexity)]})]})]})}function zp({r:t}){let n=xl(t.outcomes.changed,t.outcomes.unchanged),s=t.outcomes.excluded;return e(R,{children:[e("div",{class:"adj-scroll",children:e("table",{class:"adj-tiers",children:[e("thead",{children:e("tr",{children:[e("th",{}),e("th",{class:"num",children:"Jev changed it"}),e("th",{class:"num",children:"same as heuristic"})]})}),e("tbody",{children:n.map(a=>e("tr",{children:[e("td",{children:a.label}),e("td",{class:"num",children:a.changed}),e("td",{class:"num",children:a.unchanged})]}))})]})}),e("div",{class:"muted small jev-notes",children:["left out: ",Sl(s)]})]})}function qp({r:t,onOpen:n}){let s=t.outcomes.evidence;return s.rows.length?e(R,{children:[e("div",{class:"sub",children:["help ",s.help," \xB7 hurt ",s.hurt," \xB7 neutral ",s.neutral," (newest ",s.rows.length," listed)"]}),e("ul",{class:"jev-evidence",children:s.rows.map(a=>e("li",{children:[e(I,{tone:hl(a.kind),children:a.kind}),e("button",{type:"button",class:"adj-link",onClick:()=>n(a.id),children:["#",a.id]}),e("span",{class:"muted small",children:a.surface}),e("span",{class:"jev-move",children:[a.from," \u2192 ",a.to]}),e("span",{class:"muted small jev-why",children:fl(a.code)})]}))})]}):e(X,{compact:!0,icon:"\u25CB",title:"No labelled outcomes yet",children:"Feedback through em_adjudicate and finished swarm tasks add them to decisions Jev changed."})}function Kp({range:t,tick:n,onOpen:s}){let[a,r]=x(!1),o=V(()=>ii(t),[t,n]);if(o.data&&!o.data.active)return null;let i=o.data?.active?o.data:void 0,l={class:"jev-impact ds-block",title:"Jev impact",right:`TypeSafe Jev blended onto the heuristic \xB7 ${t}`};if(o.error)return e(j,{...l,children:e(Z,{error:o.error})});if(!i)return e(j,{...l,children:e(N,{h:160})});if(!i.sample.rows)return e(j,{...l,children:[i.provider.degraded?e(Cl,{why:i.provider.degraded}):null,e(X,{compact:!0,icon:"\u25B8",title:"No Jev decisions in this range yet",children:"Decisions blended with Jev appear here as the adjudicator runs."})]});let c=i.verdict,u=gl(c.label),d=i.provider.degraded?c.warnings.filter(p=>!p.startsWith("Jev is configured but degraded")):c.warnings;return e(j,{...l,children:[i.provider.degraded?e(Cl,{why:i.provider.degraded}):null,e("div",{class:"jev-verdict",children:[e(I,{tone:u,children:c.label}),e("span",{class:"jev-why-line",children:bl(c)}),e("button",{type:"button",class:"adj-link","aria-expanded":a,onClick:()=>r(!a),children:"how is this decided?"})]}),a?e("div",{class:"jev-rule",children:[e("p",{class:"small",children:c.rule}),e("ul",{class:"reasons",children:i.savings.assumptions.map(p=>e("li",{children:p}))})]}):null,d.length?e("ul",{class:"warn small jev-warn",children:d.map(p=>e("li",{children:p}))}):null,e(Re,{children:vl(i,i.provider.health?.state).map(p=>e(le,{label:p.title,value:p.value,sub:p.sub,title:p.help}))}),e("div",{class:"ds-grid cols-2",children:[e(j,{title:"Heuristic \u2192 final tier",children:e(Gp,{t:i.influence.tier})}),e(j,{title:"Agreement",children:e(Wp,{r:i})})]}),e("div",{class:"ds-grid cols-2",children:[e(j,{title:"Outcomes: changed vs unchanged",children:e(zp,{r:i})}),e(j,{title:"Evidence",children:e(qp,{r:i,onOpen:s})})]}),e("div",{class:"muted small jev-foot",children:_l(i).join(" \xB7 ")})]})}function Cl({why:t}){return e("div",{class:"jev-banner warn small",role:"status",children:["Jev is configured but not being called (",t.replace(/_/g," "),"): every decision falls back to the heuristic. ",Hs[t]??""]})}function $l({range:t,tick:n,ov:s,onOpen:a}){return Xs(s)?e(R,{children:[e(Kp,{range:t,tick:n,onOpen:a}),e(pl,{tick:n,onOpen:a})]}):null}var Vp={calls:0,input:0,output:0,cacheCreate5m:0,cacheCreate1h:0,cacheRead:0,thinking:0,costUsd:0,unpricedCalls:0,cacheHitRate:0,models:{}},Tl={opus:[263,84,58],sonnet:[221,83,53],haiku:[142,76,36],fable:[347,77,50],other:[220,9,46]},Rl=[220,9,46],Yp=["opus","sonnet","haiku","fable","mythos"];function Al(t){let n=t.toLowerCase();for(let s of Yp)if(n.includes(s))return s==="mythos"?"fable":s;return"other"}var Ml=([t,n,s])=>`hsl(${t} ${n}% ${s}%)`;function Dl(t){return Ml(Tl[Al(t)]??Rl)}function Ll(t){let n=new Map;for(let a of new Set(t)){let r=Al(a),o=n.get(r);o?o.push(a):n.set(r,[a])}let s=new Map;for(let[a,r]of n){let[o,i,l]=Tl[a]??Rl;r.sort();let c=r.length,u=c>1?Math.min(14,40/(c-1)):0;r.forEach((d,p)=>{let g=Math.max(28,Math.min(72,l+(p-(c-1)/2)*u));s.set(d,Ml([o,i,Math.round(g)]))})}return s}var lt=t=>t.replace(/^claude-/,"").replace(/-\d{8}(\[1m\])?$/,"$1"),El=t=>String(t).padStart(2,"0"),Zp=t=>`${t.getFullYear()}-${El(t.getMonth()+1)}-${El(t.getDate())}`;function jl(t,n,s=Date.now()){let a=new Map(t.map(c=>[c.key,c])),r=new Date(s),o=new Date(r.getFullYear(),r.getMonth(),r.getDate()-(n-1)),i=t[0]?.key.match(/^(\d{4})-(\d{2})-(\d{2})$/);if(i){let c=new Date(Number(i[1]),Number(i[2])-1,Number(i[3]));c<o&&(o=c)}let l=[];for(let c=o,u=0;c<=r&&u<400;c=new Date(c.getFullYear(),c.getMonth(),c.getDate()+1),u+=1){let d=Zp(c);l.push(a.get(d)??{key:d,totals:Vp,models:[]}),a.delete(d)}for(let c of t)a.has(c.key)&&l.push(c);return l}var Xe=t=>t==null?"\u2014":Yt(t),Pl=[["7d","7 days"],["30d","30 days"],["90d","90 days"],["all","all"]],tn=50,Il=.01,Bl=t=>new Date(t).toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});function En({tone:t,children:n,title:s}){return e("span",{class:E("tag",`adj-t-${t}`),title:s,children:n})}function Gs({color:t,label:n,title:s}){return e("span",{class:"kdot-lbl",title:s,children:[e("i",{class:"kdot",style:{background:t}}),n]})}function ga({children:t}){return e("code",{class:"adj-cmd",children:t})}function Ct({children:t,right:n}){return e("h4",{class:"adj-h",children:[t,n?e("span",{class:"right",children:n}):null]})}function Qp({rows:t}){let[n,s]=en(),a=170,r={l:34,r:8,t:8,b:22},o=Math.max(10,s-r.l-r.r),i=a-r.t-r.b,l=t.length,c=l?o/l:o,u=c>=6?2:c>=3?1:0,d=Hi(Bi(t)),p=d[d.length-1],g=v=>r.t+i-v/p*i,[h,y]=x(null),m=Math.max(1,Math.ceil(l/Math.max(2,o/70))),f=h!==null?t[h]:void 0;return e("div",{class:"hist-chart",ref:n,children:[e("svg",{width:s,height:a,role:"img","aria-label":"decisions per day, stacked by verdict source",onMouseMove:v=>{let b=v.currentTarget.getBoundingClientRect(),w=Math.floor((v.clientX-b.left-r.l)/c);y(w>=0&&w<l?w:null)},onMouseLeave:()=>y(null),children:[d.map(v=>e("g",{children:[e("line",{x1:r.l,x2:s-r.r,y1:g(v),y2:g(v),class:"grid"}),e("text",{x:r.l-6,y:g(v)+3,class:"axis","text-anchor":"end",children:v})]})),t.map((v,b)=>b%m===0?e("text",{x:r.l+b*c,y:a-6,class:"axis",children:v.day.slice(5)}):null),t.map((v,b)=>{let w=0;return e("g",{opacity:h!==null&&h!==b?.55:1,children:Ps.map(k=>{let C=v[k];if(!C)return null;let S=g(w+C),_=g(w);return w+=C,e("rect",{x:r.l+b*c+u/2,y:S,width:Math.max(.5,c-u),height:Math.max(0,_-S-(c>=6?1:0)),fill:Cn[k],rx:c>=6?1.5:0})})})})]}),f?e("div",{class:"tip",style:{left:Math.max(0,Math.min(s-200,r.l+h*c+10)),top:4},children:[e("b",{children:f.day})," \xB7 ",f.total," decision",f.total===1?"":"s",e("div",{class:"stack",style:{gap:1,marginTop:4},children:Ps.filter(v=>f[v]).map(v=>e(Gs,{color:Cn[v],label:`${v} ${f[v]}`}))})]}):null]})}function em({counts:t}){let n=Math.max(1,...t),s=t.reduce((a,r)=>a+r,0);return e("div",{class:"adj-hist",role:"img","aria-label":"decisions by complexity bucket",children:t.map((a,r)=>e("div",{class:"adj-hist-col",title:`${a} decision${a===1?"":"s"} at complexity ${r}`,children:[e("span",{class:"n",children:a}),e("div",{class:"adj-hist-track",children:e("div",{class:"adj-hist-bar",style:{height:`${a/n*100}%`}})}),e("span",{class:"k",children:r}),e("span",{class:"lbl",children:Fs[r]}),e("span",{class:"lbl muted",children:s?`${Math.round(a/s*100)}%`:""})]}))})}function tm({matrix:t,kept:n}){let s=Us(t),a=la(n);return s.total?e(R,{children:[e("div",{class:"adj-scroll",children:e("table",{class:"adj-matrix",children:[e("thead",{children:e("tr",{children:[e("th",{class:"corner",children:"suggested \u2193 \xB7 ran \u2192"}),s.cols.map(r=>e("th",{class:"num",children:lt(r)}))]})}),e("tbody",{children:s.rows.map(r=>e("tr",{children:[e("th",{children:r}),s.cols.map(o=>{let i=s.cell(r,o),l=Js(i,s.max);return e("td",{class:E("num","cell",r===o&&"diag",l>.55&&"strong"),style:l?{background:`color-mix(in srgb, var(--accent) ${Math.round(l*100)}%, transparent)`}:void 0,title:`${i} suggested ${r}, ran on ${o}`,children:i||""})})]}))})]})}),e("div",{class:"sub",children:[s.agree," of ",s.total," ran on the suggested tier (",Math.round(s.agree/s.total*100),"%) \xB7 outlined cells are agreement",a?` \xB7 not counted: ${a} (the advice named no model)`:""]})]}):e(X,{compact:!0,icon:"\u25A6",title:"No dispatches to compare",children:a?`No dispatch ran on a model the advice chose (${a}).`:"No agent or plan dispatches with a known model yet."})}function Hl({reasons:t,limit:n=1/0}){let s=ra(t,n);if(!s.length)return e("div",{class:"muted small",children:"no recorded reasons"});let a=Math.max(.01,...s.map(r=>Math.abs(r.weight)));return e("ul",{class:"adj-reasons",children:s.map(r=>{let o=Math.abs(r.weight)/a*50;return e("li",{children:[e("span",{class:"f",title:r.feature,children:Fi(r.feature)}),e("span",{class:"adj-div","aria-hidden":"true",children:e("i",{class:E(r.weight<0?"neg":"pos",r.feature==="provider"&&"prov",r.feature==="bias"&&"learn"),style:r.weight<0?{right:"50%",width:`${o}%`}:{left:"50%",width:`${o}%`}})}),e("span",{class:"w mono",children:Ns(r.weight)}),r.note?e("span",{class:"note",children:r.note}):null]})})})}function Tn({title:t,table:n,alpha:s,ladder:a}){let[r,o]=x(null),[i,l]=x(!1);if(!n?.entries?.length)return e("div",{class:"adj-table",children:[e(Ct,{children:t}),e("div",{class:"muted small",children:"not scored"})]});let c=Pi(n,s),u=r??new Set([c.choice,...c.runnerUp?[c.runnerUp]:[]]),d=h=>u.has(h),p=c.entries.filter(h=>!h.chosen&&!h.runnerUp&&h.score<Il).length,g=h=>{let y=new Set(u);y.has(h)?y.delete(h):y.add(h),o(y)};return e("div",{class:"adj-table",children:[e(Ct,{right:e("span",{class:"muted small",children:["confidence ",Math.round(c.confidence*100),"%",c.margin!==null?` \xB7 margin ${Math.round(c.margin*100)} pts`:""]}),children:t}),e("div",{class:"adj-verdict-line",children:[e("b",{class:"adj-choice",children:c.choice}),a?.(c.choice)?e("span",{class:"muted small",children:[" \u2192 ",a(c.choice)]}):null,c.runnerUp?e("span",{class:"muted small",children:[" \xB7 runner-up ",c.runnerUp]}):null,c.roundedUp?e(En,{tone:"warn",title:"confidence was below weights.lowConfidence, so the tier was rounded up one step",children:"rounded up"}):null,s>0?e("span",{class:"muted small",children:[" ","\xB7 provider weight \u03B1 ",s.toFixed(2)," \xB7 ",Math.round(c.providerShare*100),"% of the winning score"]}):e("span",{class:"muted small",children:" \xB7 heuristic only"})]}),e("div",{class:"adj-entries",children:[(i?c.entries:c.entries.filter(h=>h.chosen||h.runnerUp||h.score>=Il)).map(h=>e("div",{class:E("adj-entry",h.chosen&&"chosen",h.runnerUp&&"runner"),children:[e("button",{type:"button",class:"adj-entry-row","aria-expanded":d(h.option),onClick:()=>g(h.option),title:"show the reasons for this option",children:[e("span",{class:"opt",children:[h.chosen?e("span",{class:"mark",title:"chosen",children:"\u2713"}):h.runnerUp?e("span",{class:"mark ru",children:"2"}):e("span",{class:"mark none"}),h.option]}),e("span",{class:"adj-sbar","aria-hidden":"true",children:sa.map(y=>h.parts[y]>5e-4?e("i",{style:{width:`${h.parts[y]*100}%`,background:Is[y]},title:`${y} ${Math.round(h.parts[y]*100)}%`}):null)}),e("span",{class:"pc mono",children:[Math.round(h.score*100),"%"]})]}),d(h.option)?e(Hl,{reasons:h.reasons,limit:8}):null]})),p?e("button",{type:"button",class:"adj-link small adj-more-opts",onClick:()=>l(!i),children:i?"hide options under 1%":`+ ${p} more option${p===1?"":"s"} under 1%`}):null]})]})}function Ul(){return e("div",{class:"row tight adj-legend",children:[sa.map(t=>e(Gs,{color:Is[t],label:t,title:ji[t]})),e("span",{class:"muted small",children:"\xB7 \u2713 chosen \xB7 2 runner-up \xB7 click an option for its reasons"})]})}function Jl({value:t,reasons:n,alpha:s}){let a=Ii(t,n),r=o=>`${Math.max(0,Math.min(4,o))/4*100}%`;return e("div",{children:[e("div",{class:"adj-verdict-line",children:[e("b",{class:"adj-choice",children:t.toFixed(2)}),e("span",{class:"muted small",children:[" ","/ 4 \xB7 ",Os(t),a.provider?` \xB7 heuristic ${a.heuristic.toFixed(2)}, provider ${Ns(a.provider)}${s?` (\u03B1 ${s.toFixed(2)})`:""}`:" \xB7 heuristic only"]})]}),e("div",{class:"adj-scale",role:"img","aria-label":`complexity ${t.toFixed(2)} of 4`,children:[Fs.map((o,i)=>e("span",{class:E(Math.round(t)===i&&"on"),children:[i," ",o]})),a.provider?e("i",{class:"mk heur",style:{left:r(a.heuristic)},title:`heuristic ${a.heuristic.toFixed(2)}`}):null,e("i",{class:"mk",style:{left:r(t)},title:`final ${t.toFixed(2)}`})]}),a.providerNote?e("div",{class:"muted small",children:["provider: ",a.providerNote]}):null,e(Hl,{reasons:a.terms,limit:12})]})}function nm({id:t,onClose:n}){let s=V(()=>J("/api/adjudicator/decision",{id:t}),[t]),a=te(null);return U(()=>{let r=document.activeElement;a.current?.focus();let o=i=>{i.key==="Escape"&&n()};return window.addEventListener("keydown",o),()=>{window.removeEventListener("keydown",o),r?.focus?.()}},[t]),e(R,{children:[e("div",{class:"adj-backdrop",onClick:n}),e("aside",{class:"adj-drawer",ref:a,tabIndex:-1,role:"dialog","aria-modal":"true","aria-label":`decision ${t}`,children:[e("div",{class:"adj-drawer-head",children:[e("b",{children:["decision #",t]}),s.data?e(R,{children:[e(Je,{children:s.data.row.surface}),e("span",{class:"muted small",title:new Date(s.data.row.ts).toISOString(),children:[Bl(s.data.row.ts)," \xB7 ",me(s.data.row.ts)]})]}):null,e("span",{class:"spacer"}),e("button",{type:"button",class:"ghost sm",onClick:n,"aria-label":"close",children:"\u2715 close"})]}),e("div",{class:"adj-drawer-body",children:s.error?e(Z,{error:s.error}):s.data?e(sm,{row:s.data.row,scores:s.data.scores}):e(se,{})})]})]})}function sm({row:t,scores:n}){let s=aa(t.action),a=oa[t.outcome]??{tone:"muted",help:""},r=n?.alpha??{},o=Object.entries(n?.bias??{}).filter(([,u])=>u),i=Wi(n?.features),l=zi(n?.features),c=u=>t.modelFinal&&t.tier===u?lt(t.modelFinal):null;return e(R,{children:[e("section",{children:[e(Ct,{right:t.inputChars?e("span",{class:"muted small",children:[z(t.inputChars)," chars in"]}):null,children:"input"}),t.inputHead?e("blockquote",{class:"adj-head",children:[t.inputHead,t.inputChars&&t.inputChars>t.inputHead.length?"\u2026":""]}):e("div",{class:"muted small",children:"not stored (privacy.storeHead is off): only a hash is kept"}),e("div",{class:"muted small",children:["redacted, at most 80 characters are ever stored \xB7 hash ",t.inputHash.slice(0,12)]})]}),e("section",{class:"adj-summary",children:[e("div",{children:[e("span",{class:"k",children:"complexity"}),e("b",{children:typeof t.complexity=="number"?t.complexity.toFixed(1):"\u2014"}),e("span",{class:"s",children:Os(t.complexity)})]}),e("div",{children:[e("span",{class:"k",children:"model tier"}),e("b",{children:t.tier??"\u2014"}),e("span",{class:"s",children:["effort ",t.effort??"\u2014"]})]}),e("div",{children:[e("span",{class:"k",children:"tool"}),e("b",{children:t.tool??"\u2014"})]}),e("div",{children:[e("span",{class:"k",children:"role"}),e("b",{children:t.role??"\u2014"})]}),e("div",{children:[e("span",{class:"k",children:"confidence"}),e("b",{children:typeof t.confidence=="number"?`${Math.round(t.confidence*100)}%`:"\u2014"}),e("span",{class:"s",children:"tier"})]})]}),e("section",{children:[e(Ct,{children:"how it decided"}),e("div",{class:"row tight",style:{marginBottom:6},children:[e(Gs,{color:Cn[t.source??"heuristic"]??"#94a3b8",label:t.source??"heuristic",title:Kn[t.source??"heuristic"]}),e("span",{class:"muted small",children:Kn[t.source??"heuristic"]??""})]}),e(nt,{rows:[["provider",e(R,{children:[t.provider??"heuristic",t.providerModel?e("span",{class:"muted",children:[" \xB7 ",t.providerModel]}):null]})],["provider status",e(En,{tone:ia(t.providerStatus),children:t.providerStatus??"n/a"})],["provider weight \u03B1",Object.keys(r).length?e("span",{class:"row tight",children:["complexity","tier","tool","role"].map(u=>e("span",{class:"adj-alpha",title:`${u}: ${(r[u]??0).toFixed(2)}`,children:[u,e("span",{class:"scorebar",children:e("i",{style:{width:`${(r[u]??0)*100}%`,background:Is.provider}})}),e("span",{class:"mono small",children:(r[u]??0).toFixed(2)})]}))}):e("span",{class:"muted",children:"0 everywhere: the heuristic decided alone"})],["learned bias",o.length?e("span",{class:"row tight",children:o.map(([u,d])=>e("span",{class:"tag mono",children:[u," ",Ns(d)]}))}):e("span",{class:"muted",children:"none applied"})]]})]}),n?e(R,{children:[e("section",{children:[e(Ct,{children:"complexity"}),e(Jl,{value:n.complexity,reasons:n.complexityReasons??[],alpha:r.complexity})]}),e("section",{children:[e(Ul,{}),e(Tn,{title:"model tier",table:n.tier,alpha:r.tier??0,ladder:c}),e(Tn,{title:"tool",table:n.tool,alpha:r.tool??0}),e(Tn,{title:"agent role",table:n.role,alpha:r.role??0})]})]}):e("section",{children:e("div",{class:"muted small",children:"this row has no score tables (older scorer or a cache hit stored without them)"})}),e("section",{children:[e(Ct,{children:"cost and speed"}),e("div",{class:"adj-summary small4",children:[e("div",{children:[e("span",{class:"k",children:"latency"}),e("b",{children:Me(t.latencyMs)}),e("span",{class:"s",children:"end to end"})]}),e("div",{children:[e("span",{class:"k",children:"provider"}),e("b",{children:Me(t.providerLatencyMs)}),e("span",{class:"s",children:"round trip"})]}),e("div",{children:[e("span",{class:"k",children:"tokens"}),e("b",{children:t.tokensIn!=null?`${z(t.tokensIn)} / ${z(t.tokensOut??0)}`:"\u2014"}),e("span",{class:"s",children:"in / out"})]}),e("div",{children:[e("span",{class:"k",children:"cost"}),e("b",{children:t.costUsd===null||t.costUsd===void 0?t.tokensIn!=null?"unpriced":"$0":Xe(t.costUsd)}),e("span",{class:"s",children:"adjudicator spend"})]})]})]}),e("section",{children:[e(Ct,{children:"what happened"}),e(nt,{rows:[["advice",e(R,{children:[e(En,{tone:s.tone,children:s.label})," ",e("span",{class:"muted small",children:s.help})]})],["model",e("span",{children:[t.modelRequested?e(R,{children:["requested ",e("b",{children:lt(t.modelRequested)})," \xB7"," "]}):null,t.modelFinal?e(R,{children:["set ",e("b",{children:lt(t.modelFinal)})," \xB7"," "]}):null,"ran on ",e("b",{children:t.actualModel?lt(t.actualModel):"\u2014"})]})],["baseline",t.baselineModel?lt(t.baselineModel):e("span",{class:"muted",children:"\u2014"})],["actual usage",t.actualTokens!=null?`${z(t.actualTokens)} tokens \xB7 ${Xe(t.actualCostUsd)}`:e("span",{class:"muted",children:"\u2014"})],["outcome",e(R,{children:[e(En,{tone:a.tone,children:t.outcome})," ",e("span",{class:"muted small",children:[a.help,t.outcomeSource?` \xB7 via ${t.outcomeSource}`:"",t.outcomeTs?` \xB7 ${me(t.outcomeTs)}`:"",t.final?" \xB7 final":" \xB7 still open"]})]})]]})]}),e("section",{children:[e(Ct,{children:"savings for this decision"}),e("div",{class:"adj-savings-row",children:[e("div",{children:[e("span",{class:"k",children:"baseline cost"}),e("b",{children:Xe(t.baselineCostUsd)})]}),e("span",{class:"op",children:"\u2212"}),e("div",{children:[e("span",{class:"k",children:"actual cost"}),e("b",{children:Xe(t.actualCostUsd)})]}),e("span",{class:"op",children:"="}),e("div",{children:[e("span",{class:"k",children:"saved"}),e("b",{class:E(t.savingsUsd!=null&&(t.savingsUsd>0?"ok":t.savingsUsd<0?"bad":"")),children:Xe(t.savingsUsd)})]})]}),e("div",{class:"muted small",children:Xi(t)})]}),n?.features?e("section",{children:[e(Ct,{children:"features the heuristic saw"}),i.length?e("div",{class:"adj-intents",children:i.map(([u,d])=>e("span",{class:"adj-alpha",title:`intent ${u}: ${d.toFixed(2)}`,children:[u,e("span",{class:"scorebar",children:e("i",{style:{width:`${Math.min(1,d)*100}%`}})}),e("span",{class:"mono small",children:d.toFixed(2)})]}))}):e("div",{class:"muted small",children:"no intent detected"}),e("div",{class:"row tight",style:{marginTop:6},children:l.map(([u,d])=>e("span",{class:"tag",children:[u," ",e("b",{children:d})]}))})]}):null,e("section",{children:[e(Ct,{children:"ids"}),e(nt,{rows:[["session",t.sessionId?e("span",{class:"mono",children:t.sessionId.slice(0,8)}):"\u2014"],["agent",t.agentId??"\u2014"],["swarm",t.runId?e("a",{href:"#",onClick:u=>{u.preventDefault(),H("swarm",{run:t.runId??void 0})},children:[t.runId,t.taskId?` \xB7 task #${t.taskId}`:""]}):"\u2014"],["parent",t.parentId?`#${t.parentId}`:"\u2014"],["scorer",t.version??"\u2014"]]})]})]})}function rm({ov:t,since:n,tick:s,selected:a,onOpen:r}){let[o,i]=x({}),[l,c]=x(0);U(()=>c(0),[n,o.surface,o.provider,o.outcome]);let u=V(()=>J("/api/adjudicator/decisions",Ui({...o,since:n},tn,l)),[n,o.surface,o.provider,o.outcome,l,s]),d=(g,h,y)=>e("label",{class:"adj-filter",children:[e("span",{class:"muted small",children:h}),e("select",{value:o[g]??"",onChange:m=>i({...o,[g]:m.target.value||void 0}),children:[e("option",{value:"",children:"all"}),y.map(m=>e("option",{value:m,children:m}))]})]}),p=u.data;return e(j,{class:"adj-log",title:"Call log",right:p?Ji(p.offset,p.rows.length,p.total):"",children:[e("div",{class:"row adj-filters",children:[d("surface","surface",t.filters.surfaces.filter(g=>g!=="test")),d("provider","provider",t.filters.providers),d("outcome","outcome",t.filters.outcomes),o.surface||o.provider||o.outcome?e("button",{type:"button",class:"ghost sm",onClick:()=>i({}),children:"clear"}):null,e("span",{class:"spacer"}),u.loading?e(se,{}):null]}),u.error?e(Z,{error:u.error}):p?p.rows.length?e("div",{class:"adj-scroll",children:e("table",{class:"adj-calls",children:[e("thead",{children:e("tr",{children:[e("th",{children:"when"}),e("th",{children:"surface"}),e("th",{children:"input"}),e("th",{class:"num",children:"cx"}),e("th",{children:"tier"}),e("th",{children:"tool"}),e("th",{children:"role"}),e("th",{children:"source"}),e("th",{class:"num",children:"latency"}),e("th",{class:"num",children:"cost"}),e("th",{children:"advice"}),e("th",{children:"outcome"}),e("th",{class:"num",children:"saved"})]})}),e("tbody",{children:p.rows.map(g=>e(am,{r:g,selected:a===g.id,onOpen:r}))})]})}):e(X,{compact:!0,icon:"\u2581",title:"No decisions",children:p.total||o.surface||o.provider||o.outcome?"None match these filters.":"Nothing was recorded in this range."}):e(se,{}),p&&p.total>tn?e("div",{class:"row adj-pager",children:[e("button",{type:"button",class:"sm",disabled:l===0,onClick:()=>c(Math.max(0,l-tn)),children:"\u2190 newer"}),e("span",{class:"muted small",children:["page ",Math.floor(l/tn)+1," of ",Math.ceil(p.total/tn)]}),e("button",{type:"button",class:"sm",disabled:l+tn>=p.total,onClick:()=>c(l+tn),children:"older \u2192"})]}):null]})}function am({r:t,selected:n,onOpen:s}){let a=aa(t.action),r=t.source??"heuristic",o=typeof t.complexity=="number"?t.complexity:null;return e("tr",{class:E("click",n&&"sel"),tabIndex:0,onClick:()=>s(t.id),onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),s(t.id))},"aria-label":`decision ${t.id}`,children:[e("td",{class:"nowrap muted",title:new Date(t.ts).toISOString(),children:Bl(t.ts)}),e("td",{children:t.surface}),e("td",{class:"adj-headcell",title:t.inputHead??"",children:t.inputHead??e("span",{class:"muted",children:"\u2014"})}),e("td",{class:"num nowrap",title:Os(o),children:o!==null?e(R,{children:[e("span",{class:"adj-cx",children:e("i",{style:{width:`${o/4*100}%`}})}),o.toFixed(1)]}):"\u2014"}),e("td",{children:e("b",{children:t.tier??"\u2014"})}),e("td",{class:"mono small",children:t.tool??"\u2014"}),e("td",{children:t.role??"\u2014"}),e("td",{class:"nowrap",title:`${Kn[r]??""}${t.provider?` \xB7 ${t.provider}`:""} \xB7 ${t.providerStatus??"n/a"}`,children:[e("i",{class:"kdot",style:{background:Cn[r]??"#94a3b8"}}),r,t.providerStatus&&t.providerStatus!=="ok"&&t.providerStatus!=="n/a"?e("span",{class:E("small",`adj-t-${ia(t.providerStatus)}`),children:[" ",t.providerStatus]}):null]}),e("td",{class:"num nowrap",children:Me(t.latencyMs)}),e("td",{class:"num nowrap",children:t.costUsd!=null?Xe(t.costUsd):e("span",{class:"muted",children:"\u2014"})}),e("td",{children:e("span",{class:E("small",`adj-t-${a.tone}`),title:a.help,children:a.label})}),e("td",{children:e("span",{class:E("small",`adj-t-${Oi(t.outcome)}`),children:t.outcome})}),e("td",{class:E("num nowrap",t.savingsUsd!=null&&t.savingsUsd>0&&"ok",t.savingsUsd!=null&&t.savingsUsd<0&&"bad"),children:t.savingsUsd!=null?Xe(t.savingsUsd):e("span",{class:"muted",children:"\u2014"})})]})}function om(t){return t?[...(t.split(":")[0]??"").matchAll(/adjudicator\.([A-Za-z0-9_]+)/g)].map(s=>s[1]):[]}function im({ov:t}){let n=t.provider,s=t.health.find(o=>o.configured),a=t.health.filter(o=>!o.configured),r=om(t.projectIgnored);return e(j,{title:"Provider",right:e(R,{children:[t.projectIgnored?e(I,{tone:"warn",title:t.projectIgnored,children:["project config ignored: ",r.length?r.join(", "):"some keys"]}):null,e(I,{tone:t.mode==="apply"?"accent":"muted",title:t.mode==="apply"?"sets the Agent model within the configured floor and ceiling":"suggests only; Claude decides",children:[t.mode," mode"]})]}),children:[e(nt,{rows:[["configured",e(R,{children:[e("b",{children:n.configured}),n.preset?e("span",{class:"muted",children:[" \xB7 ",n.preset]}):null,n.model?e("span",{class:"muted",children:[" \xB7 ",n.model]}):null]})],["in use",n.effective===n.configured?e("span",{class:"ok",children:n.effective}):e("span",{children:[e("b",{class:"warn",children:n.effective}),e("span",{class:"muted small",children:[" ","\xB7 ",n.degraded?Hs[n.degraded]??n.degraded:""]})]})],...n.detail&&n.effective!==n.configured?[["why",e("span",{class:"small",children:n.detail})]]:[],["where",n.configuredRemote?e("span",{children:["remote",n.baseUrl?e("span",{class:"muted",children:[" \xB7 ",n.baseUrl]}):null]}):"on this machine"],["key",n.configuredRemote?e("span",{children:[t.keySource==="none"?e("span",{class:"warn",children:"none"}):`from ${t.keySource}`,t.keyFileRefused?e("span",{class:"bad small",children:" \xB7 key file refused (permissions)"}):null,e("span",{class:"muted small",children:[" ","\xB7 consent ",t.consent?"given":"not given",t.origin?` for ${t.origin}`:""]})]}):e("span",{class:"muted",children:"not needed"})],["apply effective",t.apply.checked?e("span",{children:[t.apply.effective," of ",t.apply.checked,t.apply.ineffective?e("span",{class:"warn small",children:[" \xB7 ",t.apply.ineffective," ran on another model"]}):null]}):e("span",{class:"muted",children:"no applied dispatches checked yet"})]]}),s?e(Fl,{h:s,now:t.now}):n.configured==="heuristic"?e("div",{class:"muted small adj-health",children:"the heuristic runs locally: no breaker, no spend"}):null,a.length?e("details",{class:"adj-more",children:[e("summary",{class:"muted small",children:[a.length," other provider",a.length===1?"":"s"," with history"]}),a.map(o=>e(Fl,{h:o,now:t.now}))]}):null]})}function Fl({h:t,now:n}){let s=Bs(t.state),a=t.dailyCapUsd,r=a?Math.min(1,t.spendTodayUsd/a):0;return e("div",{class:"adj-health",children:[e("div",{class:"row tight",children:[e("b",{children:t.provider}),e(En,{tone:s.tone,title:s.help,children:s.label}),t.failures?e("span",{class:"muted small",children:[t.failures," recent failure",t.failures===1?"":"s"]}):null,e("span",{class:"spacer"}),t.retryAt&&t.retryAt>n?e("span",{class:"warn small",children:["retry in ",Me(t.retryAt-n)]}):null]}),e("div",{class:"adj-health-grid",children:[e("span",{class:"muted",children:"latency"}),e("span",{children:[t.latency.n?`p50 ${Me(t.latency.p50)} \xB7 p95 ${Me(t.latency.p95)}`:"no calls",t.latency.n?e("span",{class:"muted small",children:[" \xB7 last ",t.latency.n]}):null]}),e("span",{class:"muted",children:"last ok"}),e("span",{children:t.lastOkAt?me(t.lastOkAt):"\u2014"}),e("span",{class:"muted",children:"last error"}),e("span",{children:[t.lastErrorClass?e("span",{class:"bad",children:t.lastErrorClass}):"\u2014",t.lastErrorAt?e("span",{class:"muted small",children:[" \xB7 ",me(t.lastErrorAt)]}):null]}),e("span",{class:"muted",children:"spend today"}),e("span",{children:a===null?e("span",{class:"muted",children:"local \xB7 no cap"}):e(R,{children:[Xe(t.spendTodayUsd)," of ",Xe(a),e("span",{class:"scorebar",style:{maxWidth:160},children:e("i",{class:E(r>=.9?"bad":r>=.6?"warn":"ok"),style:{width:`${r*100}%`}})})]})})]})]})}function lm({s:t}){let n=Object.entries(t.tokensPerSuccessByTier).filter(([,o])=>o?.tasks),s=Math.max(1,...n.map(([,o])=>o?.tokensPerTask??0)),a=Gi(t),r=[["realised",t.realisedUsd,`${t.creditedRows} followed/applied dispatches${t.redoPenaltyUsd?` \xB7 ${Xe(t.redoPenaltyUsd)} redo penalty`:""}`,"ok"],["potential",t.potentialUsd,`${t.potentialRows} main-session prompts \xB7 not in net`,"muted"],["spend",-t.spendUsd,"the adjudicator's own provider calls","bad"],["net",t.netUsd,"realised \u2212 spend",t.netUsd>=0?"ok":"bad"]];return e(j,{title:"Savings",right:a?e(I,{tone:"warn",title:a.help,children:a.label}):void 0,children:[e("div",{class:"adj-figs",children:r.map(([o,i,l,c])=>e("div",{children:[e("div",{class:"sub",children:o}),e("div",{class:E("big",c!=="muted"&&i!==0&&c),children:Xe(o==="spend"?t.spendUsd:i)}),e("div",{class:"sub",children:l})]}))}),e("h4",{class:"adj-h",children:"tokens per successful task, by tier"}),n.length?e("table",{class:"adj-tiers",children:e("tbody",{children:n.map(([o,i])=>e("tr",{children:[e("td",{children:o}),e("td",{class:"num",children:[i.tasks," task",i.tasks===1?"":"s"]}),e("td",{style:{width:"40%"},children:e("span",{class:"bar",style:{width:`${Math.max(2,(i.tokensPerTask??0)/s*100)}%`}})}),e("td",{class:"num",children:i.tokensPerTask!=null?z(i.tokensPerTask):"\u2014"}),e("td",{class:"num muted",children:Xe(i.costUsd)})]}))})}):e("div",{class:"muted small",children:"no successful agent tasks with usage yet"}),e("div",{class:"muted small",style:{marginTop:6},children:"smaller tiers can need more turns: if haiku needs far more tokens per task than sonnet, the savings above overstate."})]})}function cm({list:t}){return e(j,{class:"adj-assume ds-block",title:"How savings are computed",children:e("ul",{class:"reasons",id:"adj-assumptions",children:t.map(n=>e("li",{children:n}))})})}function Ol({ov:t}){let[n,s]=x(""),[a,r]=x(!1),[o,i]=x(!1),[l,c]=x(),[u,d]=x(),p=!!t?.enabled&&t.provider.configured!=="heuristic",g=async()=>{if(n.trim()){i(!0),c(void 0);try{d(await $e("/api/adjudicator/test",{text:n,useProvider:p&&a}))}catch(y){c(y.message)}finally{i(!1)}}},h=u?.verdict;return e(j,{class:"adj-try",title:"Try it",right:"nothing is stored \xB7 the text is not sent back",children:[e("textarea",{rows:4,maxLength:2e4,placeholder:"Paste a prompt or task, e.g. \u201Crefactor the session store to batch writes and add tests\u201D",value:n,onInput:y=>s(y.target.value),onKeyDown:y=>{y.key==="Enter"&&(y.metaKey||y.ctrlKey)&&g()}}),e("div",{class:"row",style:{marginTop:6},children:[e("label",{class:E("row tight small",!p&&"muted"),title:p?"":"needs the adjudicator enabled with a provider configured",children:[e("input",{type:"checkbox",checked:p&&a,disabled:!p,onChange:y=>r(y.target.checked)}),"use the provider",t&&p?` (${t.provider.configured})`:""]}),p&&a&&t?.provider.configuredRemote?e("span",{class:"warn small",children:["sends redacted text to ",t.provider.baseUrl??"the provider"," and counts toward today's cap"]}):null,e("span",{class:"spacer"}),e("button",{type:"button",class:"primary",disabled:o||!n.trim(),onClick:()=>{g()},children:o?"scoring\u2026":"score"})]}),l?e(Z,{error:l}):null,u&&h?e("div",{class:"adj-try-out",children:[e("div",{class:"row tight",children:[e(En,{tone:u.usedProvider?"accent":"muted",children:h.source}),e("span",{class:"muted small",children:[Ni(u.reason)," \xB7 ",Me(h.latencyMs),h.providerStatus&&h.providerStatus!=="n/a"?` \xB7 provider ${h.providerStatus}`:"",u.providerModel?` \xB7 ${u.providerModel}`:"",h.usage?.costUsd?` \xB7 ${Xe(h.usage.costUsd)}`:""]})]}),u.advice?e("blockquote",{class:"adj-head",children:u.advice}):null,e(Jl,{value:h.complexity,reasons:h.complexityReasons??[],alpha:h.alpha?.complexity}),e(Ul,{}),e(Tn,{title:"model tier",table:h.tier,alpha:h.alpha?.tier??0}),e(Tn,{title:"tool",table:h.tool,alpha:h.alpha?.tool??0}),e(Tn,{title:"agent role",table:h.role,alpha:h.alpha?.role??0})]}):null]})}function Nl(){let t=V(()=>J("/api/adjudicator/eval"),[]),n=t.data?.report??null,s=qi(n),a=Ki(n),r=a.find(([o])=>o==="verdict");return e(j,{title:"Last eval",children:t.error?e(Z,{error:t.error}):t.data?n?e(R,{children:[r?e("div",{class:"adj-verdict-line",children:e("b",{children:r[1]})}):null,e(nt,{rows:a.filter(([o])=>o!=="verdict").map(([o,i])=>[o,i])}),s?e("div",{class:"adj-scroll",style:{marginTop:8},children:e("table",{class:"adj-eval",children:[e("thead",{children:e("tr",{children:s.columns.map(o=>e("th",{class:E(o!==s.columns[0]&&"num"),children:o}))})}),e("tbody",{children:s.rows.map(o=>e("tr",{children:s.columns.map((i,l)=>e("td",{class:E(l>0&&"num","nowrap"),children:o[i]??"\u2014"}))}))})]})}):null]}):e(X,{compact:!0,icon:"\u25CB",title:"No eval yet",children:["Run ",e(ga,{children:"eminiar adjudicator eval"})," to compare the heuristic and your provider on the labelled set.",t.data.error?e("div",{class:"bad small",children:t.data.error}):null]}):e(se,{})})}function dm(){return e("div",{class:"page ds-page adj-page","aria-busy":"true",children:[e("section",{class:"ds-hero",children:e("div",{class:"ds-hero-main ds-skel-stack",children:[e(N,{w:140,h:12}),e(N,{w:"60%",h:30}),e(N,{w:"40%",h:14})]})}),e("div",{class:"ds-stats",children:[0,1,2,3,4,5].map(()=>e("div",{class:"ds-stat",children:[e(N,{w:70,h:10}),e(N,{w:90,h:26}),e(N,{w:"80%",h:10})]}))}),e("div",{class:"ds-grid main-side",children:[e(N,{h:260,class:"adj-skel-card"}),e(N,{h:260,class:"adj-skel-card"})]})]})}function um(){return e(j,{class:"adj-intro ds-block",title:"Adjudicator is off",children:[e("p",{children:"The adjudicator scores each request's complexity and suggests the eminiar tool, the Claude model size (haiku, sonnet, opus) and the swarm role that fit it, so small work goes to small models and large work gets the right help. It is optional and off by default."}),e("ul",{class:"reasons",children:[e("li",{children:[e("b",{children:"local by default"}),": the heuristic runs on this machine; nothing leaves it."]}),e("li",{children:[e("b",{children:"remote providers only with consent and a key"}),": text is redacted and capped (privacy.maxChars) before it is sent; keys live in ",e(ga,{children:"~/.eminiar"}),", never in config."]}),e("li",{children:[e("b",{children:"what is stored"}),": a hash and at most 80 redacted characters per decision (privacy.storeHead)."]}),e("li",{children:[e("b",{children:"advise vs apply"}),": advise only suggests; apply sets the Agent model within a floor and ceiling."]})]}),e("div",{class:"row",style:{marginTop:8},children:[e("span",{children:"Turn it on with"}),e(ga,{children:"eminiar adjudicator enable"}),e("span",{class:"muted small",children:"then /mcp reconnect. This page updates without restarting the server."})]})]})}function Xl({params:t}){let n=Pl.find(([m])=>m===t.range)?.[0]??"30d",s=t.id&&/^\d+$/.test(t.id)?Number(t.id):null,[a,r]=x(0),[o,i]=x(!1),l=V(()=>J("/api/adjudicator",{since:n}),[n,a]),c=V(()=>J("/api/adjudicator/savings",{since:n}),[n,a]),u=m=>H("adjudicator",{range:(m.range??n)==="30d"?void 0:m.range??n,id:m.id===void 0?s?String(s):void 0:m.id?String(m.id):void 0});if(l.error)return e("div",{class:"page ds-page adj-page",children:e(Z,{error:l.error})});let d=l.data;if(!d)return e(dm,{});let p=d.summary,g=p.total>0,h=Object.entries(p.byProviderStatus).filter(([m,f])=>f&&m!=="ok"&&m!=="n/a"),y=[["decisions",z(p.total),Object.entries(p.bySurface).filter(([,m])=>m).sort((m,f)=>f[1]-m[1]).map(([m,f])=>`${m} ${f}`).join(" \xB7 ")||"none in range"],["advice followed",_t(p.rates.follow),[`apply ${_t(p.rates.apply)} \xB7 respected ${_t(p.rates.respect)}`,la(p.keptModel)].filter(Boolean).join(" \xB7 "),"followed \xF7 (advised + followed + ignored), leaving out advised dispatches whose advice named no model (a kept pin, CLAUDE_CODE_SUBAGENT_MODEL_FORCE, a fork); apply = applied \xF7 (applied + respected)"],["fallback rate",_t(d.fallbackRate),h.length?h.map(([m,f])=>`${m} ${f}`).join(" \xB7 "):"no provider errors","decisions where the provider failed or was skipped and the heuristic answered"],["provider latency",p.providerLatency.n?`${Me(p.providerLatency.p50)}`:"\u2014",p.providerLatency.n?`p95 ${Me(p.providerLatency.p95)} \xB7 end to end p50 ${Me(p.latency.p50)}`:`end to end p50 ${Me(p.latency.p50)} \xB7 p95 ${Me(p.latency.p95)}`,"p50 of the provider round trip; end to end includes the heuristic and blending"],["adjudicator spend",Xe(p.costUsd),`${d.provider.configuredRemote?"remote provider":"local: free"} \xB7 in range`],["net savings",Xe(c.data?c.data.netUsd:p.netUsd),e(R,{children:["saved ",Xe(c.data?c.data.realisedUsd:p.savingsUsd)," \u2212 spend ",Xe(p.costUsd)," \xB7"," ",e("button",{type:"button",class:"adj-link","aria-expanded":o,onClick:()=>i(!o),children:"how is this computed?"})]})]];return e("div",{class:"page ds-page adj-page",children:[e(Te,{eyebrow:e(R,{children:[e("span",{children:"Adjudicator"}),d.enabled?e(It,{tone:"ok",title:"the adjudicator is enabled",children:"on"}):e(It,{tone:"muted",title:"the adjudicator is disabled",children:"off"})]}),title:g?e(R,{children:[e(xn,{children:[z(p.total)," decisions"]})," in ",n]}):"No decisions in this range",sub:d.enabled?"Complexity, tool, model tier and role advice for each request, with the cost and savings it brings.":g?"Showing decisions recorded while it was on.":"Turn it on to see routing advice for each request.",meta:e(R,{children:[d.enabled?e(R,{children:[e(I,{tone:d.mode==="apply"?"accent":"muted",title:"advise or apply",children:[d.mode," mode"]}),e(I,{tone:"purple",title:"the provider in use",children:d.provider.effective})]}):null,"reconcile"in d&&d.reconcile&&"error"in d.reconcile?e(I,{tone:"warn",children:["reconcile failed: ",d.reconcile.error]}):null,d.chartsCut?e(I,{tone:"warn",children:"charts drawn from the newest 20k rows"}):null]}),aside:e("div",{class:"adj-hero-actions",children:[e(Se,{label:"time range",options:Pl.map(([m,f])=>({id:m,label:f})),value:n,onChange:m=>u({range:m})}),e("button",{type:"button",class:"ghost sm",onClick:()=>r(m=>m+1),disabled:l.loading,children:l.loading?"\u2026":"\u21BB refresh"})]})}),d.enabled?null:e(um,{}),d.enabled||g?e(R,{children:[e(Re,{children:y.map(([m,f,v,b])=>e(le,{label:m,value:f,sub:v,title:b}))}),o?e(cm,{list:c.data?.assumptions??[]}):null,Xs(d)?e($l,{range:n,tick:a,ov:d,onOpen:m=>u({id:m})}):null,e("div",{class:"ds-grid main-side",children:[e(j,{title:"Decisions per day",right:e("span",{class:"usage-legend",children:Ps.map(m=>e(Gs,{color:Cn[m],label:m,title:Kn[m]}))}),children:[d.charts.perDay.length?e(Qp,{rows:d.charts.perDay}):e(X,{compact:!0,icon:"\u2581",title:"No decisions yet",children:d.enabled?"They appear as you prompt and dispatch agents.":"Nothing was recorded in this range."}),e("div",{class:"muted small",children:"UTC days"})]}),e(im,{ov:d})]}),e("div",{class:"ds-grid cols-2",children:[e(j,{title:"Complexity",right:"0 trivial \u2192 4 very complex",children:g?e(em,{counts:d.charts.complexity}):e(X,{compact:!0,icon:"\u2581",title:"No decisions yet"})}),e(j,{title:"Suggested tier \xD7 model that ran",children:c.error?e(Z,{error:c.error}):c.data?e(tm,{matrix:c.data.matrix,kept:c.data.keptModel}):e(se,{})})]}),e(rm,{ov:d,since:n,tick:a,selected:s,onOpen:m=>u({id:m})}),e("div",{class:"ds-grid cols-2",children:[c.error?e(j,{title:"Savings",children:e(Z,{error:c.error})}):c.data?e(lm,{s:c.data}):e(j,{title:"Savings",children:e(N,{h:120})}),e(Ol,{ov:d})]}),e("div",{class:"ds-grid",children:e(Nl,{})})]}):e("div",{class:"ds-grid cols-2",children:[e(Ol,{ov:d}),e(Nl,{})]}),s!==null?e(nm,{id:s,onClose:()=>u({id:null})}):null]})}var pm={indexed:"ok",partial:"warn",skipped:"bad",unsupported:"muted"};function Gl(){let t=V(()=>J("/api/coverage"),[]),[n,s]=x(""),[a,r]=x(""),[o,i]=x(null),l=ae(()=>{let b=a.trim().toLowerCase();return(t.data?.files??[]).filter(w=>(!n||w.status===n)&&(!b||w.path.toLowerCase().includes(b)||(w.reason??"").toLowerCase().includes(b)))},[t.data,n,a]),{sorted:c,th:u}=Ot(l,"path",!1),d=async(b,w)=>{i(b);try{let k=await $e("/api/actions",w);ee(k.output.split(`
|
|
3
|
+
`)[0]??"done",!k.ok),t.reload()}catch(k){ee(k.message,!0)}finally{i(null)}};if(t.error)return e("div",{class:"page ds-page",children:e(Z,{error:t.error,onRetry:t.reload})});let p=t.data;if(!p)return e("div",{class:"page ds-page",role:"status","aria-busy":"true",children:[e(Te,{title:e(N,{w:"min(320px, 70%)",h:34}),sub:e(N,{w:220,h:14})}),e(Re,{children:[0,1,2,3].map(b=>e("div",{class:"ds-stat",children:[e(N,{w:80,h:11}),e(N,{w:100,h:28}),e(N,{w:130,h:11})]},b))}),e(N,{h:120})]});let g=p.summary.byStatus,h=Object.values(g).reduce((b,w)=>b+w,0),y=p.freshness.headMatches&&!p.freshness.dirty.length&&!p.freshness.queued,m=y?"fresh":p.freshness.dirty.length||p.freshness.queued?"stale":"git behind",f=[["indexed",g.indexed??0,"parsed into the graph and search"],["partial",g.partial??0,"indexed, syntax errors recovered"],["skipped",g.skipped??0,"too large or parser error"],["unsupported",g.unsupported??0,"matched by globs, no parser"]],v=(g.partial??0)+(g.skipped??0)+(g.unsupported??0);return e("div",{class:"page ds-page cv-page",children:[e(Te,{eyebrow:"Index coverage",title:h?e(R,{children:[e(xn,{children:z(g.indexed??0)})," of ",z(h)," files indexed"]}):"No files scanned yet",sub:h?v?`${z(v)} file${v===1?"":"s"} partly or not indexed. Pick a status below to filter the list.`:"Every matched file is in the graph and search index.":"Run a code reindex and the coverage report shows up here.",meta:e(I,{tone:y?"ok":"warn",dot:!0,children:m}),aside:e(R,{children:[e("button",{type:"button",disabled:!!o,onClick:()=>d("code",{action:"reindex",scope:"code"}),children:o==="code"?e(se,{}):"Reindex code"}),e("button",{type:"button",disabled:!!o,onClick:()=>d("full",{action:"reindex",scope:"code",full:!0}),children:o==="full"?e(se,{}):"Full reindex"})]})}),e(Re,{children:[f.map(([b,w,k])=>e(le,{label:b,value:w,tone:b==="skipped"&&w>0?"bad":b==="partial"&&w>0?"warn":void 0,sub:n===b?`${k} \xB7 filtering`:k,title:n===b?"show all files":`show only ${b} files`,onClick:()=>s(n===b?"":b)})),e(le,{label:"freshness",value:m,tone:y?"ok":"warn",sub:`${p.freshness.dirty.length} changed \xB7 ${p.freshness.queued} queued`})]}),e("div",{class:"ds-grid main-side",children:[e(j,{flush:!0,title:"Files",right:`${c.length} of ${h}`,children:[e("div",{class:"row cv-filter",children:[e("input",{type:"search",class:"grow",placeholder:"filter by path or reason\u2026",value:a,onInput:b=>r(b.target.value)}),e("select",{value:n,onChange:b=>s(b.target.value),children:[e("option",{value:"",children:"any status"}),["indexed","partial","skipped","unsupported"].map(b=>e("option",{value:b,children:b}))]})]}),e("div",{class:"ds-table-wrap cv-files",children:e("table",{children:[e("thead",{children:e("tr",{children:[u("path","path"),u("status","status"),u("reason","reason"),u("symbols","symbols",!0),u("size","size",!0),u("indexed_at","indexed",!0),e("th",{})]})}),e("tbody",{children:c.length?c.slice(0,500).map(b=>e("tr",{children:[e("td",{class:"break",children:e("a",{onClick:()=>H("explore",{file:b.path}),children:b.path})}),e("td",{children:e(I,{tone:pm[b.status]??"muted",children:b.status})}),e("td",{class:"muted small",children:[b.reason??"",b.errors?e("div",{class:"bad small",children:b.errors.slice(0,160)}):null]}),e("td",{class:"num",children:b.symbols??""}),e("td",{class:"num",children:z(b.size??0)}),e("td",{class:"num muted small",children:me(b.indexed_at)}),e("td",{children:e("button",{type:"button",class:"sm",disabled:!!o,onClick:()=>d(b.path,{action:"reindex",scope:"code",paths:[b.path]}),children:o===b.path?e(se,{}):"reindex"})})]})):e("tr",{children:e("td",{colSpan:7,children:e(X,{compact:!0,icon:"\u2205",title:h?"No files match":"No files yet",children:h?"Change the filter or status to see more files.":"Nothing has been scanned. Run a code reindex."})})})})]})})]}),e("div",{class:"cv-side",children:[e(j,{title:"Index state",children:e(nt,{rows:[["HEAD",p.freshness.head?.slice(0,10)??"no git"],["git signals at",p.freshness.indexedHead?`${p.freshness.indexedHead.slice(0,10)}${p.freshness.headMatches?" (current)":" (behind)"}`:"never"],["last run",p.freshness.lastRun?me(p.freshness.lastRun):"never"],["queued",String(p.freshness.queued)],["last scan",p.scan?.at?`${me(p.scan.at)} \xB7 ${p.scan.scanned} files \xB7 ${p.scan.durationMs} ms`:"n/a"]]})}),p.freshness.dirty.length?e(j,{title:"Changed since indexed",right:p.freshness.dirty.length,children:[e("div",{class:"list cv-dirty",children:p.freshness.dirty.map(b=>e("div",{class:"item",onClick:()=>H("explore",{file:b}),children:e("div",{class:"p",children:b})}))}),e("button",{type:"button",class:"sm",style:{marginTop:6},disabled:!!o,onClick:()=>d("dirty",{action:"reindex",scope:"code",paths:p.freshness.dirty}),children:o==="dirty"?e(se,{}):"Reindex changed files"})]}):null,p.summary.reasons.length?e(j,{flush:!0,title:"Why files are not fully indexed",children:e("div",{class:"ds-table-wrap",children:e("table",{children:e("tbody",{children:p.summary.reasons.map(b=>e("tr",{class:"click",onClick:()=>r(b.reason),children:[e("td",{children:b.reason}),e("td",{class:"num",children:b.n})]}))})})})}):null,e(j,{title:"Scope",children:e("div",{class:"small",children:[e("div",{class:"muted",children:"include"}),e("div",{class:"mono break",children:(p.scan?.include??[]).join(" ")||"(defaults)"}),e("div",{class:"muted",style:{marginTop:4},children:"exclude"}),e("div",{class:"mono break",children:(p.scan?.exclude??[]).join(" ")||"(defaults)"}),e("div",{class:"muted",style:{marginTop:6},children:"Change them in eminiar.config.json under graph.include / graph.exclude. A clean coverage result means no recorded gap, not proof of completeness."})]})})]})]})]})}var Yn=[{id:"readme",group:"project",label:"Readme & guides",blurb:"README, CONTRIBUTING, CHANGELOG and other top-level guides"},{id:"guides",group:"project",label:"Docs folders",blurb:"docs/ directories: handbooks, how-tos, references"},{id:"adr",group:"project",label:"Decision records",blurb:"architecture decision records"},{id:"agent-instructions",group:"project",label:"Agent instructions",blurb:"Copilot, Claude and Cursor instructions, agents and skills"},{id:"api-specs",group:"project",label:"API specs",blurb:"OpenAPI, Postman, GraphQL and protobuf definitions"},{id:"env-reference",group:"project",label:"Environment reference",blurb:".env examples: every variable the project reads"},{id:"deploy-config",group:"project",label:"Deploy config",blurb:"Terraform, Kubernetes, Helm, Compose and CI workflows"},{id:"local",group:"project",label:"Other local files",blurb:"hand-registered paths"},{id:"service",group:"external",label:"Services",blurb:"third-party products and APIs the project integrates"},{id:"api",group:"external",label:"External APIs",blurb:"hosts the code calls, found by probing their docs"},{id:"infra",group:"external",label:"Infrastructure",blurb:"platforms the project runs on"},{id:"library",group:"external",label:"Libraries",blurb:"frameworks and packages"},{id:"web",group:"external",label:"Web pages",blurb:"hand-registered URLs"}],Wl=new Map(Yn.map(t=>[t.id,t]));function Ws(t){return Wl.get(t)??Wl.get("local")}var zl={project:"Project documentation",external:"External documentation"};function ha(t){let n=Yn.findIndex(s=>s.id===t);return n===-1?Yn.length:n}var mm=/^([a-z][a-z0-9+.-]*):(.*)$/i;function nn(t){let n=t.trim();if(!n)return{kind:"text"};if(n.startsWith("#"))return{kind:"anchor",href:n};let s=mm.exec(n);if(!s){let o=n.replace(/^\.\//,"").split("#")[0]??"";return o?{kind:"file",file:o}:{kind:"text"}}let a=s[1].toLowerCase(),r=s[2];switch(a){case"mem":case"memory":return r?{kind:"memory",name:r}:{kind:"text"};case"file":case"sym":{let o=r.replace(/^\/+/,"").split("#")[0]??"";return o?{kind:"file",file:o}:{kind:"text"}}case"http":case"https":case"mailto":return{kind:"external",href:n};default:return{kind:"text"}}}function zs(t){if(t.kind==="memory")return`#/memory?name=${encodeURIComponent(t.name)}`;if(t.kind==="file")return`#/explore?file=${encodeURIComponent(t.file)}`}function Rn({title:t,rows:n,label:s,onPick:a,max:r=60}){return e("div",{class:"section",children:[e("h4",{children:[t," \xB7 ",n.length]}),e("table",{children:e("tbody",{children:n.slice(0,r).map(o=>e("tr",{class:"click",onClick:()=>a(o.id),children:[e("td",{children:e(Je,{children:o.kind})}),e("td",{class:"break",children:s(o.id)})]}))})}),n.length>r?e("div",{class:"muted small",children:["\u2026 ",n.length-r," more"]}):null]})}var fa=t=>xt(t.kind),ba=t=>"circle";function ql(t,n=1){return{color:kn(t),dash:t==="calls"?[4,3]:t==="co_changes"?[1,3]:t==="references"?[2,2]:void 0,width:t==="co_changes"?1+n*2:1,alpha:t==="co_changes"?.35:.45,directed:Ts.has(t)}}function Kl(t,n,s,a,r){switch(t.beginPath(),n){case"square":{let o=r*.88;t.rect(s-o,a-o,o*2,o*2);break}case"diamond":{let o=r*1.25;t.moveTo(s,a-o),t.lineTo(s+o,a),t.lineTo(s,a+o),t.lineTo(s-o,a),t.closePath();break}case"triangle":{let o=r*1.3;t.moveTo(s,a-o),t.lineTo(s+o*.87,a+o*.5),t.lineTo(s-o*.87,a+o*.5),t.closePath();break}case"hexagon":{let o=r*1.12;for(let i=0;i<6;i++){let l=Math.PI/3*i,c=s+o*Math.cos(l),u=a+o*Math.sin(l);i===0?t.moveTo(c,u):t.lineTo(c,u)}t.closePath();break}default:t.arc(s,a,r,0,Math.PI*2)}}function Vl(t){switch(t){case"square":return"M1.5 1.5H10.5V10.5H1.5Z";case"diamond":return"M6 0.5L11.5 6L6 11.5L0.5 6Z";case"triangle":return"M6 0.8L11.4 10.6H0.6Z";case"hexagon":return"M11.5 6L8.75 10.76H3.25L0.5 6L3.25 1.24H8.75Z";default:return"M6 1A5 5 0 1 1 5.99 1Z"}}function Nt({shape:t,color:n}){let s=t==="ring";return e("svg",{class:"glyph",width:"11",height:"11",viewBox:"0 0 12 12","aria-hidden":"true",children:e("path",{d:Vl(t),fill:s?"none":n,stroke:n,"stroke-width":s?1.6:0})})}function An({color:t,dash:n}){return e("svg",{class:"glyph",width:"18",height:"8",viewBox:"0 0 18 8","aria-hidden":"true",children:e("line",{x1:"0",y1:"4",x2:"18",y2:"4",stroke:t,"stroke-width":"2","stroke-dasharray":n?.length?n.join(" "):void 0})})}function ya(t,n){var s,a=1;t==null&&(t=0),n==null&&(n=0);function r(){var o,i=s.length,l,c=0,u=0;for(o=0;o<i;++o)l=s[o],c+=l.x,u+=l.y;for(c=(c/i-t)*a,u=(u/i-n)*a,o=0;o<i;++o)l=s[o],l.x-=c,l.y-=u}return r.initialize=function(o){s=o},r.x=function(o){return arguments.length?(t=+o,r):t},r.y=function(o){return arguments.length?(n=+o,r):n},r.strength=function(o){return arguments.length?(a=+o,r):a},r}function Yl(t){let n=+this._x.call(null,t),s=+this._y.call(null,t);return Zl(this.cover(n,s),n,s,t)}function Zl(t,n,s,a){if(isNaN(n)||isNaN(s))return t;var r,o=t._root,i={data:a},l=t._x0,c=t._y0,u=t._x1,d=t._y1,p,g,h,y,m,f,v,b;if(!o)return t._root=i,t;for(;o.length;)if((m=n>=(p=(l+u)/2))?l=p:u=p,(f=s>=(g=(c+d)/2))?c=g:d=g,r=o,!(o=o[v=f<<1|m]))return r[v]=i,t;if(h=+t._x.call(null,o.data),y=+t._y.call(null,o.data),n===h&&s===y)return i.next=o,r?r[v]=i:t._root=i,t;do r=r?r[v]=new Array(4):t._root=new Array(4),(m=n>=(p=(l+u)/2))?l=p:u=p,(f=s>=(g=(c+d)/2))?c=g:d=g;while((v=f<<1|m)===(b=(y>=g)<<1|h>=p));return r[b]=o,r[v]=i,t}function Ql(t){var n,s,a=t.length,r,o,i=new Array(a),l=new Array(a),c=1/0,u=1/0,d=-1/0,p=-1/0;for(s=0;s<a;++s)isNaN(r=+this._x.call(null,n=t[s]))||isNaN(o=+this._y.call(null,n))||(i[s]=r,l[s]=o,r<c&&(c=r),r>d&&(d=r),o<u&&(u=o),o>p&&(p=o));if(c>d||u>p)return this;for(this.cover(c,u).cover(d,p),s=0;s<a;++s)Zl(this,i[s],l[s],t[s]);return this}function ec(t,n){if(isNaN(t=+t)||isNaN(n=+n))return this;var s=this._x0,a=this._y0,r=this._x1,o=this._y1;if(isNaN(s))r=(s=Math.floor(t))+1,o=(a=Math.floor(n))+1;else{for(var i=r-s||1,l=this._root,c,u;s>t||t>=r||a>n||n>=o;)switch(u=(n<a)<<1|t<s,c=new Array(4),c[u]=l,l=c,i*=2,u){case 0:r=s+i,o=a+i;break;case 1:s=r-i,o=a+i;break;case 2:r=s+i,a=o-i;break;case 3:s=r-i,a=o-i;break}this._root&&this._root.length&&(this._root=l)}return this._x0=s,this._y0=a,this._x1=r,this._y1=o,this}function tc(){var t=[];return this.visit(function(n){if(!n.length)do t.push(n.data);while(n=n.next)}),t}function nc(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function Fe(t,n,s,a,r){this.node=t,this.x0=n,this.y0=s,this.x1=a,this.y1=r}function sc(t,n,s){var a,r=this._x0,o=this._y0,i,l,c,u,d=this._x1,p=this._y1,g=[],h=this._root,y,m;for(h&&g.push(new Fe(h,r,o,d,p)),s==null?s=1/0:(r=t-s,o=n-s,d=t+s,p=n+s,s*=s);y=g.pop();)if(!(!(h=y.node)||(i=y.x0)>d||(l=y.y0)>p||(c=y.x1)<r||(u=y.y1)<o))if(h.length){var f=(i+c)/2,v=(l+u)/2;g.push(new Fe(h[3],f,v,c,u),new Fe(h[2],i,v,f,u),new Fe(h[1],f,l,c,v),new Fe(h[0],i,l,f,v)),(m=(n>=v)<<1|t>=f)&&(y=g[g.length-1],g[g.length-1]=g[g.length-1-m],g[g.length-1-m]=y)}else{var b=t-+this._x.call(null,h.data),w=n-+this._y.call(null,h.data),k=b*b+w*w;if(k<s){var C=Math.sqrt(s=k);r=t-C,o=n-C,d=t+C,p=n+C,a=h.data}}return a}function rc(t){if(isNaN(d=+this._x.call(null,t))||isNaN(p=+this._y.call(null,t)))return this;var n,s=this._root,a,r,o,i=this._x0,l=this._y0,c=this._x1,u=this._y1,d,p,g,h,y,m,f,v;if(!s)return this;if(s.length)for(;;){if((y=d>=(g=(i+c)/2))?i=g:c=g,(m=p>=(h=(l+u)/2))?l=h:u=h,n=s,!(s=s[f=m<<1|y]))return this;if(!s.length)break;(n[f+1&3]||n[f+2&3]||n[f+3&3])&&(a=n,v=f)}for(;s.data!==t;)if(r=s,!(s=s.next))return this;return(o=s.next)&&delete s.next,r?(o?r.next=o:delete r.next,this):n?(o?n[f]=o:delete n[f],(s=n[0]||n[1]||n[2]||n[3])&&s===(n[3]||n[2]||n[1]||n[0])&&!s.length&&(a?a[v]=s:this._root=s),this):(this._root=o,this)}function ac(t){for(var n=0,s=t.length;n<s;++n)this.remove(t[n]);return this}function oc(){return this._root}function ic(){var t=0;return this.visit(function(n){if(!n.length)do++t;while(n=n.next)}),t}function lc(t){var n=[],s,a=this._root,r,o,i,l,c;for(a&&n.push(new Fe(a,this._x0,this._y0,this._x1,this._y1));s=n.pop();)if(!t(a=s.node,o=s.x0,i=s.y0,l=s.x1,c=s.y1)&&a.length){var u=(o+l)/2,d=(i+c)/2;(r=a[3])&&n.push(new Fe(r,u,d,l,c)),(r=a[2])&&n.push(new Fe(r,o,d,u,c)),(r=a[1])&&n.push(new Fe(r,u,i,l,d)),(r=a[0])&&n.push(new Fe(r,o,i,u,d))}return this}function cc(t){var n=[],s=[],a;for(this._root&&n.push(new Fe(this._root,this._x0,this._y0,this._x1,this._y1));a=n.pop();){var r=a.node;if(r.length){var o,i=a.x0,l=a.y0,c=a.x1,u=a.y1,d=(i+c)/2,p=(l+u)/2;(o=r[0])&&n.push(new Fe(o,i,l,d,p)),(o=r[1])&&n.push(new Fe(o,d,l,c,p)),(o=r[2])&&n.push(new Fe(o,i,p,d,u)),(o=r[3])&&n.push(new Fe(o,d,p,c,u))}s.push(a)}for(;a=s.pop();)t(a.node,a.x0,a.y0,a.x1,a.y1);return this}function dc(t){return t[0]}function uc(t){return arguments.length?(this._x=t,this):this._x}function pc(t){return t[1]}function mc(t){return arguments.length?(this._y=t,this):this._y}function sn(t,n,s){var a=new va(n??dc,s??pc,NaN,NaN,NaN,NaN);return t==null?a:a.addAll(t)}function va(t,n,s,a,r,o){this._x=t,this._y=n,this._x0=s,this._y0=a,this._x1=r,this._y1=o,this._root=void 0}function gc(t){for(var n={data:t.data},s=n;t=t.next;)s=s.next={data:t.data};return n}var Ye=sn.prototype=va.prototype;Ye.copy=function(){var t=new va(this._x,this._y,this._x0,this._y0,this._x1,this._y1),n=this._root,s,a;if(!n)return t;if(!n.length)return t._root=gc(n),t;for(s=[{source:n,target:t._root=new Array(4)}];n=s.pop();)for(var r=0;r<4;++r)(a=n.source[r])&&(a.length?s.push({source:a,target:n.target[r]=new Array(4)}):n.target[r]=gc(a));return t};Ye.add=Yl;Ye.addAll=Ql;Ye.cover=ec;Ye.data=tc;Ye.extent=nc;Ye.find=sc;Ye.remove=rc;Ye.removeAll=ac;Ye.root=oc;Ye.size=ic;Ye.visit=lc;Ye.visitAfter=cc;Ye.x=uc;Ye.y=mc;function Pe(t){return function(){return t}}function ft(t){return(t()-.5)*1e-6}function gm(t){return t.x+t.vx}function hm(t){return t.y+t.vy}function wa(t){var n,s,a,r=1,o=1;typeof t!="function"&&(t=Pe(t==null?1:+t));function i(){for(var u,d=n.length,p,g,h,y,m,f,v=0;v<o;++v)for(p=sn(n,gm,hm).visitAfter(l),u=0;u<d;++u)g=n[u],m=s[g.index],f=m*m,h=g.x+g.vx,y=g.y+g.vy,p.visit(b);function b(w,k,C,S,_){var T=w.data,M=w.r,F=m+M;if(T){if(T.index>g.index){var D=h-T.x-T.vx,$=y-T.y-T.vy,L=D*D+$*$;L<F*F&&(D===0&&(D=ft(a),L+=D*D),$===0&&($=ft(a),L+=$*$),L=(F-(L=Math.sqrt(L)))/L*r,g.vx+=(D*=L)*(F=(M*=M)/(f+M)),g.vy+=($*=L)*F,T.vx-=D*(F=1-F),T.vy-=$*F)}return}return k>h+F||S<h-F||C>y+F||_<y-F}}function l(u){if(u.data)return u.r=s[u.data.index];for(var d=u.r=0;d<4;++d)u[d]&&u[d].r>u.r&&(u.r=u[d].r)}function c(){if(n){var u,d=n.length,p;for(s=new Array(d),u=0;u<d;++u)p=n[u],s[p.index]=+t(p,u,n)}}return i.initialize=function(u,d){n=u,a=d,c()},i.iterations=function(u){return arguments.length?(o=+u,i):o},i.strength=function(u){return arguments.length?(r=+u,i):r},i.radius=function(u){return arguments.length?(t=typeof u=="function"?u:Pe(+u),c(),i):t},i}function fm(t){return t.index}function hc(t,n){var s=t.get(n);if(!s)throw new Error("node not found: "+n);return s}function ka(t){var n=fm,s=p,a,r=Pe(30),o,i,l,c,u,d=1;t==null&&(t=[]);function p(f){return 1/Math.min(l[f.source.index],l[f.target.index])}function g(f){for(var v=0,b=t.length;v<d;++v)for(var w=0,k,C,S,_,T,M,F;w<b;++w)k=t[w],C=k.source,S=k.target,_=S.x+S.vx-C.x-C.vx||ft(u),T=S.y+S.vy-C.y-C.vy||ft(u),M=Math.sqrt(_*_+T*T),M=(M-o[w])/M*f*a[w],_*=M,T*=M,S.vx-=_*(F=c[w]),S.vy-=T*F,C.vx+=_*(F=1-F),C.vy+=T*F}function h(){if(i){var f,v=i.length,b=t.length,w=new Map(i.map((C,S)=>[n(C,S,i),C])),k;for(f=0,l=new Array(v);f<b;++f)k=t[f],k.index=f,typeof k.source!="object"&&(k.source=hc(w,k.source)),typeof k.target!="object"&&(k.target=hc(w,k.target)),l[k.source.index]=(l[k.source.index]||0)+1,l[k.target.index]=(l[k.target.index]||0)+1;for(f=0,c=new Array(b);f<b;++f)k=t[f],c[f]=l[k.source.index]/(l[k.source.index]+l[k.target.index]);a=new Array(b),y(),o=new Array(b),m()}}function y(){if(i)for(var f=0,v=t.length;f<v;++f)a[f]=+s(t[f],f,t)}function m(){if(i)for(var f=0,v=t.length;f<v;++f)o[f]=+r(t[f],f,t)}return g.initialize=function(f,v){i=f,u=v,h()},g.links=function(f){return arguments.length?(t=f,h(),g):t},g.id=function(f){return arguments.length?(n=f,g):n},g.iterations=function(f){return arguments.length?(d=+f,g):d},g.strength=function(f){return arguments.length?(s=typeof f=="function"?f:Pe(+f),y(),g):s},g.distance=function(f){return arguments.length?(r=typeof f=="function"?f:Pe(+f),m(),g):r},g}var bm={value:()=>{}};function bc(){for(var t=0,n=arguments.length,s={},a;t<n;++t){if(!(a=arguments[t]+"")||a in s||/[\s.]/.test(a))throw new Error("illegal type: "+a);s[a]=[]}return new qs(s)}function qs(t){this._=t}function ym(t,n){return t.trim().split(/^|\s+/).map(function(s){var a="",r=s.indexOf(".");if(r>=0&&(a=s.slice(r+1),s=s.slice(0,r)),s&&!n.hasOwnProperty(s))throw new Error("unknown type: "+s);return{type:s,name:a}})}qs.prototype=bc.prototype={constructor:qs,on:function(t,n){var s=this._,a=ym(t+"",s),r,o=-1,i=a.length;if(arguments.length<2){for(;++o<i;)if((r=(t=a[o]).type)&&(r=vm(s[r],t.name)))return r;return}if(n!=null&&typeof n!="function")throw new Error("invalid callback: "+n);for(;++o<i;)if(r=(t=a[o]).type)s[r]=fc(s[r],t.name,n);else if(n==null)for(r in s)s[r]=fc(s[r],t.name,null);return this},copy:function(){var t={},n=this._;for(var s in n)t[s]=n[s].slice();return new qs(t)},call:function(t,n){if((r=arguments.length-2)>0)for(var s=new Array(r),a=0,r,o;a<r;++a)s[a]=arguments[a+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(o=this._[t],a=0,r=o.length;a<r;++a)o[a].value.apply(n,s)},apply:function(t,n,s){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var a=this._[t],r=0,o=a.length;r<o;++r)a[r].value.apply(n,s)}};function vm(t,n){for(var s=0,a=t.length,r;s<a;++s)if((r=t[s]).name===n)return r.value}function fc(t,n,s){for(var a=0,r=t.length;a<r;++a)if(t[a].name===n){t[a]=bm,t=t.slice(0,a).concat(t.slice(a+1));break}return s!=null&&t.push({name:n,value:s}),t}var xa=bc;var Mn=0,Qn=0,Zn=0,vc=1e3,Ks,es,Vs=0,rn=0,Ys=0,ts=typeof performance=="object"&&performance.now?performance:Date,wc=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function Ca(){return rn||(wc(wm),rn=ts.now()+Ys)}function wm(){rn=0}function Sa(){this._call=this._time=this._next=null}Sa.prototype=Zs.prototype={constructor:Sa,restart:function(t,n,s){if(typeof t!="function")throw new TypeError("callback is not a function");s=(s==null?Ca():+s)+(n==null?0:+n),!this._next&&es!==this&&(es?es._next=this:Ks=this,es=this),this._call=t,this._time=s,_a()},stop:function(){this._call&&(this._call=null,this._time=1/0,_a())}};function Zs(t,n,s){var a=new Sa;return a.restart(t,n,s),a}function kc(){Ca(),++Mn;for(var t=Ks,n;t;)(n=rn-t._time)>=0&&t._call.call(void 0,n),t=t._next;--Mn}function yc(){rn=(Vs=ts.now())+Ys,Mn=Qn=0;try{kc()}finally{Mn=0,xm(),rn=0}}function km(){var t=ts.now(),n=t-Vs;n>vc&&(Ys-=n,Vs=t)}function xm(){for(var t,n=Ks,s,a=1/0;n;)n._call?(a>n._time&&(a=n._time),t=n,n=n._next):(s=n._next,n._next=null,n=t?t._next=s:Ks=s);es=t,_a(a)}function _a(t){if(!Mn){Qn&&(Qn=clearTimeout(Qn));var n=t-rn;n>24?(t<1/0&&(Qn=setTimeout(yc,t-ts.now()-Ys)),Zn&&(Zn=clearInterval(Zn))):(Zn||(Vs=ts.now(),Zn=setInterval(km,vc)),Mn=1,wc(yc))}}function xc(){let t=1;return()=>(t=(1664525*t+1013904223)%4294967296)/4294967296}function Sc(t){return t.x}function _c(t){return t.y}var Sm=10,_m=Math.PI*(3-Math.sqrt(5));function $a(t){var n,s=1,a=.001,r=1-Math.pow(a,1/300),o=0,i=.6,l=new Map,c=Zs(p),u=xa("tick","end"),d=xc();t==null&&(t=[]);function p(){g(),u.call("tick",n),s<a&&(c.stop(),u.call("end",n))}function g(m){var f,v=t.length,b;m===void 0&&(m=1);for(var w=0;w<m;++w)for(s+=(o-s)*r,l.forEach(function(k){k(s)}),f=0;f<v;++f)b=t[f],b.fx==null?b.x+=b.vx*=i:(b.x=b.fx,b.vx=0),b.fy==null?b.y+=b.vy*=i:(b.y=b.fy,b.vy=0);return n}function h(){for(var m=0,f=t.length,v;m<f;++m){if(v=t[m],v.index=m,v.fx!=null&&(v.x=v.fx),v.fy!=null&&(v.y=v.fy),isNaN(v.x)||isNaN(v.y)){var b=Sm*Math.sqrt(.5+m),w=m*_m;v.x=b*Math.cos(w),v.y=b*Math.sin(w)}(isNaN(v.vx)||isNaN(v.vy))&&(v.vx=v.vy=0)}}function y(m){return m.initialize&&m.initialize(t,d),m}return h(),n={tick:g,restart:function(){return c.restart(p),n},stop:function(){return c.stop(),n},nodes:function(m){return arguments.length?(t=m,h(),l.forEach(y),n):t},alpha:function(m){return arguments.length?(s=+m,n):s},alphaMin:function(m){return arguments.length?(a=+m,n):a},alphaDecay:function(m){return arguments.length?(r=+m,n):+r},alphaTarget:function(m){return arguments.length?(o=+m,n):o},velocityDecay:function(m){return arguments.length?(i=1-m,n):1-i},randomSource:function(m){return arguments.length?(d=m,l.forEach(y),n):d},force:function(m,f){return arguments.length>1?(f==null?l.delete(m):l.set(m,y(f)),n):l.get(m)},find:function(m,f,v){var b=0,w=t.length,k,C,S,_,T;for(v==null?v=1/0:v*=v,b=0;b<w;++b)_=t[b],k=m-_.x,C=f-_.y,S=k*k+C*C,S<v&&(T=_,v=S);return T},on:function(m,f){return arguments.length>1?(u.on(m,f),n):u.on(m)}}}function Ea(){var t,n,s,a,r=Pe(-30),o,i=1,l=1/0,c=.81;function u(h){var y,m=t.length,f=sn(t,Sc,_c).visitAfter(p);for(a=h,y=0;y<m;++y)n=t[y],f.visit(g)}function d(){if(t){var h,y=t.length,m;for(o=new Array(y),h=0;h<y;++h)m=t[h],o[m.index]=+r(m,h,t)}}function p(h){var y=0,m,f,v=0,b,w,k;if(h.length){for(b=w=k=0;k<4;++k)(m=h[k])&&(f=Math.abs(m.value))&&(y+=m.value,v+=f,b+=f*m.x,w+=f*m.y);h.x=b/v,h.y=w/v}else{m=h,m.x=m.data.x,m.y=m.data.y;do y+=o[m.data.index];while(m=m.next)}h.value=y}function g(h,y,m,f){if(!h.value)return!0;var v=h.x-n.x,b=h.y-n.y,w=f-y,k=v*v+b*b;if(w*w/c<k)return k<l&&(v===0&&(v=ft(s),k+=v*v),b===0&&(b=ft(s),k+=b*b),k<i&&(k=Math.sqrt(i*k)),n.vx+=v*h.value*a/k,n.vy+=b*h.value*a/k),!0;if(h.length||k>=l)return;(h.data!==n||h.next)&&(v===0&&(v=ft(s),k+=v*v),b===0&&(b=ft(s),k+=b*b),k<i&&(k=Math.sqrt(i*k)));do h.data!==n&&(w=o[h.data.index]*a/k,n.vx+=v*w,n.vy+=b*w);while(h=h.next)}return u.initialize=function(h,y){t=h,s=y,d()},u.strength=function(h){return arguments.length?(r=typeof h=="function"?h:Pe(+h),d(),u):r},u.distanceMin=function(h){return arguments.length?(i=h*h,u):Math.sqrt(i)},u.distanceMax=function(h){return arguments.length?(l=h*h,u):Math.sqrt(l)},u.theta=function(h){return arguments.length?(c=h*h,u):Math.sqrt(c)},u}function Ta(t){var n=Pe(.1),s,a,r;typeof t!="function"&&(t=Pe(t==null?0:+t));function o(l){for(var c=0,u=s.length,d;c<u;++c)d=s[c],d.vx+=(r[c]-d.x)*a[c]*l}function i(){if(s){var l,c=s.length;for(a=new Array(c),r=new Array(c),l=0;l<c;++l)a[l]=isNaN(r[l]=+t(s[l],l,s))?0:+n(s[l],l,s)}}return o.initialize=function(l){s=l,i()},o.strength=function(l){return arguments.length?(n=typeof l=="function"?l:Pe(+l),i(),o):n},o.x=function(l){return arguments.length?(t=typeof l=="function"?l:Pe(+l),i(),o):t},o}function Ra(t){var n=Pe(.1),s,a,r;typeof t!="function"&&(t=Pe(t==null?0:+t));function o(l){for(var c=0,u=s.length,d;c<u;++c)d=s[c],d.vy+=(r[c]-d.y)*a[c]*l}function i(){if(s){var l,c=s.length;for(a=new Array(c),r=new Array(c),l=0;l<c;++l)a[l]=isNaN(r[l]=+t(s[l],l,s))?0:+n(s[l],l,s)}}return o.initialize=function(l){s=l,i()},o.strength=function(l){return arguments.length?(n=typeof l=="function"?l:Pe(+l),i(),o):n},o.y=function(l){return arguments.length?(t=typeof l=="function"?l:Pe(+l),i(),o):t},o}function Aa(t,n,s){let a=new Map,r=t.map(c=>{let u=s?.get(c.id),d={...c,deg:0,r:4};return u&&(d.x=u.x,d.y=u.y),a.set(c.id,d),d}),o=[];for(let c of n){let u=a.get(c.src),d=a.get(c.dst);!u||!d||u===d||(u.deg++,d.deg++,o.push({source:u,target:d,kind:c.kind,weight:c.weight,count:c.count,lines:c.lines}))}for(let c of r)c.r=4+Math.min(12,Math.sqrt(c.deg)*1.8)+(c.root?3:0);let i=r.length,l=$a(r).force("link",ka(o).distance(c=>c.kind==="co_changes"?90:c.kind==="defines"?36:60).strength(c=>c.kind==="co_changes"?.15:.5)).force("charge",Ea().strength(i>400?-60:-140).distanceMax(600)).force("collide",wa().radius(c=>c.r+4).iterations(2)).force("center",ya(0,0).strength(.05)).force("x",Ta(0).strength(.02)).force("y",Ra(0).strength(.02)).alphaDecay(i>400?.05:.03).velocityDecay(.4);return{nodes:r,links:o,sim:l,byId:a}}function Cc(t,n){let s=Aa(t,n);s.sim.stop();let a=s.nodes.filter(y=>y.kind==="file"),r=s.nodes.filter(y=>y.kind!=="file"),o=new Map;for(let y of a){let m=(y.path??y.label).split("/").slice(0,-1).join("/")||".";(o.get(m)??o.set(m,[]).get(m)).push(y)}let i=[...o.keys()].sort((y,m)=>y.split("/").length-m.split("/").length||y.localeCompare(m)),l=220,c=34,u=-(i.length-1)*l/2,d=new Map;for(let y of i){let m=o.get(y).sort((v,b)=>v.label.localeCompare(b.label)),f=-(m.length-1)*c/2;for(let v of m)v.x=u,v.y=f,v.fx=u,v.fy=f,d.set(v.path??v.label,v),f+=c;u+=l}let p=new Map,g=[];for(let y of r){let m=y.path?d.get(y.path):void 0;if(!m){g.push(y);continue}let f=p.get(m.id)??0;p.set(m.id,f+1),y.x=(m.x??0)+70+f%3*46,y.y=(m.y??0)+Math.floor(f/3)*14-8,y.fx=y.x,y.fy=y.y}let h=(i.length?o.get(i[0]).length:0)*c/2+60;for(let y of g)y.x=-(g.length-1)*60/2+g.indexOf(y)*60,y.y=h,y.fx=y.x,y.fy=y.y;return h+=40,s}var Cm=t=>t.kind==="file"||t.kind==="package"?wn(t.label):t.label.split(".").pop()??t.label,$m=()=>document.documentElement.getAttribute("data-theme")==="dark"||document.documentElement.getAttribute("data-theme")!=="light"&&window.matchMedia("(prefers-color-scheme: dark)").matches;function $t(t){let n=te(null),s=te(null),a=te(null),r=te({k:1,x:0,y:0}),o=te(!1),i=te(null),l=te(null),[c,u]=x(null),[d,p]=x(!1),g=te(t);g.current=t;let h=()=>{let D=n.current,$=a.current;if(!D||!$)return;let L=D.getContext("2d");if(!L)return;let K=window.devicePixelRatio||1,Y=D.width/K,ne=D.height/K,O=r.current,A=$m(),{selected:W,highlight:ye}=g.current,B=g.current.colorOf??fa,re=g.current.shapeOf??ba,fe=g.current.edgeStyleOf??ql,dt=g.current.labelOf??Cm,ue=W?$.byId.get(W):void 0,ge=new Set;if(ue){ge.add(ue.id);for(let oe of $.links){let we=oe.source,ie=oe.target;we.id===ue.id&&ge.add(ie.id),ie.id===ue.id&&ge.add(we.id)}}L.setTransform(K,0,0,K,0,0),L.clearRect(0,0,Y,ne),L.translate(Y/2+O.x,ne/2+O.y),L.scale(O.k,O.k);for(let oe of $.links){let we=oe.source,ie=oe.target;if(we.x===void 0||ie.x===void 0)continue;let He=`${we.id}|${ie.id}|${oe.kind}`,Ge=ye?.has(He),ot=ue&&!(ge.has(we.id)&&ge.has(ie.id))&&we.id!==ue.id&&ie.id!==ue.id,it=fe(oe.kind,oe.weight);if(L.globalAlpha=Ge?1:ot?.06:it.alpha??.45,L.strokeStyle=it.color,L.lineWidth=(Ge?2.5:it.width??1)/O.k,L.setLineDash(it.dash?it.dash.map(kt=>kt/O.k):[]),L.beginPath(),L.moveTo(we.x,we.y??0),L.lineTo(ie.x,ie.y??0),L.stroke(),L.setLineDash([]),it.directed&&O.k>.5){let kt=ie.x-we.x,Jn=(ie.y??0)-(we.y??0),Tt=Math.hypot(kt,Jn)||1,Xt=kt/Tt,Gt=Jn/Tt,Le=ie.x-Xt*(ie.r+2),gt=(ie.y??0)-Gt*(ie.r+2),Qe=5/O.k;L.fillStyle=it.color,L.beginPath(),L.moveTo(Le,gt),L.lineTo(Le-Xt*Qe*2-Gt*Qe,gt-Gt*Qe*2+Xt*Qe),L.lineTo(Le-Xt*Qe*2+Gt*Qe,gt-Gt*Qe*2-Xt*Qe),L.closePath(),L.fill()}}let Ce=$.nodes.length<=120||O.k>1.6;L.font=`${11/O.k}px system-ui, sans-serif`,L.textBaseline="middle";for(let oe of $.nodes){if(oe.x===void 0||oe.y===void 0)continue;let we=ue&&!ge.has(oe.id);L.globalAlpha=we?.2:1;let ie=re(oe),He=B(oe);if(Kl(L,ie,oe.x,oe.y,oe.r/Math.max(1,O.k**.5)),ie==="ring"?(L.fillStyle=A?"#171a21":"#ffffff",L.fill(),L.lineWidth=1.6/O.k,L.strokeStyle=He,L.stroke()):(L.fillStyle=He,L.fill()),(oe.root||oe.id===W||oe===i.current)&&(L.lineWidth=2.5/O.k,L.strokeStyle=A?"#e5e7eb":"#1b1f24",L.stroke()),Ce||oe.root||oe.deg>3||ge.has(oe.id)||oe===i.current||oe.id===W){let ot=dt(oe),it=oe.x+oe.r/Math.max(1,O.k**.5)+3/O.k;L.lineWidth=3/O.k,L.strokeStyle=A?"#171a21":"#ffffff",L.strokeText(ot,it,oe.y),L.fillStyle=A?"#e5e7eb":"#1b1f24",L.fillText(ot,it,oe.y)}}L.globalAlpha=1},y=()=>{let D=n.current,$=a.current;if(!D||!$?.nodes.length)return;let L=window.devicePixelRatio||1,K=D.width/L,Y=D.height/L,ne=Number.POSITIVE_INFINITY,O=Number.POSITIVE_INFINITY,A=Number.NEGATIVE_INFINITY,W=Number.NEGATIVE_INFINITY;for(let fe of $.nodes)fe.x===void 0||fe.y===void 0||(ne=Math.min(ne,fe.x),O=Math.min(O,fe.y),A=Math.max(A,fe.x),W=Math.max(W,fe.y));let ye=Math.max(100,A-ne+120),B=Math.max(100,W-O+120),re=Math.min(2.5,Math.min(K/ye,Y/B));r.current={k:re,x:-((ne+A)/2)*re,y:-((O+W)/2)*re},h()};ai(t.handle??null,()=>({fit:y}),[]);let m=t.nodes.map(D=>D.id).join("|"),f=t.edges.map(D=>`${D.src}|${D.dst}|${D.kind}`).join(`
|
|
4
|
+
`),v=t.mode??"galaxy";U(()=>{let D=t.keepPositions?a.current?.byId:void 0;a.current?.sim.stop();let $=v==="hierarchy"?Cc(t.nodes,t.edges):Aa(t.nodes,t.edges,D);a.current=$,o.current=!1;let L=!1,K=!1,Y=0;if(v==="hierarchy"){y();return}return $.sim.on("tick",()=>{Y++,(Y%2===0||$.sim.alpha()<.05)&&h(),!L&&(Y===30||$.sim.alpha()<.3)&&(L=!0,o.current||y())}),$.sim.on("end",()=>{K||(K=!0,L=!0,o.current||y())}),()=>$.sim.stop()},[m,f,v]),U(()=>{h()},[t.selected,t.highlight,c,t.colorOf,t.shapeOf,t.edgeStyleOf]),U(()=>{let D=s.current,$=n.current;if(!D||!$)return;let L=()=>{let O=window.devicePixelRatio||1;$.width=Math.max(1,D.clientWidth*O),$.height=Math.max(1,D.clientHeight*O),h()};L();let K=new ResizeObserver(L);K.observe(D);let Y=window.matchMedia("(prefers-color-scheme: dark)");Y.addEventListener("change",h);let ne=new MutationObserver(h);return ne.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>{K.disconnect(),Y.removeEventListener("change",h),ne.disconnect()}},[]);let b=D=>{let L=n.current.getBoundingClientRect(),K=r.current;return{x:(D.clientX-L.left-L.width/2-K.x)/K.k,y:(D.clientY-L.top-L.height/2-K.y)/K.k}},w=D=>{let $=a.current;if(!$)return null;let L=b(D),K=r.current,Y=null,ne=Number.POSITIVE_INFINITY;for(let O of $.nodes){if(O.x===void 0||O.y===void 0)continue;let A=Math.hypot(O.x-L.x,O.y-L.y),W=O.r/Math.max(1,K.k**.5)+6/K.k;A<W&&A<ne&&(ne=A,Y=O)}return Y},k=D=>{let $=w(D),L=r.current;l.current={node:$??void 0,px:D.clientX,py:D.clientY,vx:L.x,vy:L.y,moved:!1},$&&($.fx=$.x,$.fy=$.y,a.current?.sim.alphaTarget(.2).restart()),p(!0),D.preventDefault()},C=D=>{let $=l.current;if($){let K=D.clientX-$.px,Y=D.clientY-$.py;if(Math.abs(K)+Math.abs(Y)>3&&($.moved=!0),$.node){let ne=b(D);$.node.fx=ne.x,$.node.fy=ne.y,v==="hierarchy"&&($.node.x=ne.x,$.node.y=ne.y,h())}else $.moved&&(o.current=!0),r.current={...r.current,x:$.vx+K,y:$.vy+Y},h();return}let L=w(D);L!==i.current&&(i.current=L,u(L))},S=D=>{let $=l.current;l.current=null,p(!1),$&&($.node?(v!=="hierarchy"&&($.node.fx=null,$.node.fy=null,a.current?.sim.alphaTarget(0)),$.moved||g.current.onSelect?.($.node.id===g.current.selected?null:$.node.id)):$.moved||g.current.onSelect?.(null))},_=D=>{D.preventDefault();let L=n.current.getBoundingClientRect(),K=r.current;o.current=!0;let Y=D.deltaY>0?.9:1.1,ne=Math.max(.05,Math.min(8,K.k*Y)),O=D.clientX-L.left-L.width/2,A=D.clientY-L.top-L.height/2;r.current={k:ne,x:O-(O-K.x)*ne/K.k,y:A-(A-K.y)*ne/K.k},h()},T=D=>{let $=w(D);$&&g.current.onActivate?.($.id)},M=[...new Set(t.nodes.map(D=>D.kind))],F=[...new Set(t.edges.map(D=>D.kind))];return e("div",{class:"gwrap",ref:s,children:[e("canvas",{ref:n,class:E(d&&"drag",c&&!d&&"hover"),onMouseDown:k,onMouseMove:C,onMouseUp:S,onMouseLeave:()=>{i.current=null,u(null),l.current&&!l.current.node&&(l.current=null)},onWheel:_,onDblClick:T}),c&&!d&&e("div",{class:"overlay tip",style:{left:12,top:12},children:[e("b",{children:c.kind})," ",c.label,c.path&&c.kind!=="file"?e("span",{class:"muted",children:[" ","\xB7 ",c.path,c.line?`:${c.line}`:""]}):null,e("span",{class:"muted",children:[" ","\xB7 ",c.deg," edge",c.deg===1?"":"s"]})]}),t.legend!==!1&&e("div",{class:"overlay legend",children:[M.map(D=>{let $=t.nodes.find(L=>L.kind===D);return e("span",{children:[t.shapeOf||t.colorOf?e(Nt,{shape:(t.shapeOf??ba)($),color:(t.colorOf??fa)($)}):e("i",{style:{background:xt(D)}}),D]})}),F.map(D=>{let $=t.edgeStyleOf?.(D,1);return e("span",{children:[$?e(An,{color:$.color,dash:$.dash}):e("s",{style:{borderColor:kn(D)}}),D]})})]}),e("button",{type:"button",class:"overlay fit",onClick:y,children:"fit view"})]})}function Em(t,n){if(n.hiddenKinds.has(t.kind))return!1;if(t.group==="memory"&&!t.missing){let s=t.status??"accepted";if(n.hideSuperseded&&s==="superseded"||n.status&&s!==n.status)return!1}return!(t.group==="doc"&&!t.missing&&n.category&&t.sub!==n.category)}function Qs(t,n){let s=new Set(t.nodes.filter(i=>Em(i,n)).map(i=>i.id)),a=t.edges.filter(i=>!n.hiddenEdges.has(i.kind)&&s.has(i.src)&&s.has(i.dst)),r=new Set(a.flatMap(i=>[i.src,i.dst]));return{nodes:t.nodes.filter(i=>s.has(i.id)&&(i.seed||i.root||r.has(i.id))),edges:a}}function an(t,n){let s=new Map;for(let a of t)s.set(n(a),(s.get(n(a))??0)+1);return s}var Tm={memory:"diamond",doc:"square",tag:"triangle",topic:"hexagon"};function er(t){return t.missing?"ring":Tm[t.kind]??"circle"}function tr(t){let n=t;return n.group==="memory"&&(n.status==="superseded"||n.status==="deprecated")?"#93c5fd":xt(t.kind)}function ns(t){let n={links:[4,3],supersedes:[6,3],about:[2,3],tagged:[1,3],in_topic:[1,3]};return{color:kn(t),dash:n[t],width:t==="documents"||t==="mentions"?1.4:1,alpha:t==="tagged"||t==="in_topic"?.35:.55,directed:Ts.has(t)}}function $c(t){let n=t;return n.group==="memory"||n.group==="doc"||n.group==="hub"||t.kind==="package"?t.label:t.kind==="file"?t.label.split("/").pop()??t.label:t.label.split(".").pop()??t.label}var Rm=["proposed","accepted","superseded","deprecated"],Am={proposed:"warn",accepted:"ok",superseded:"muted",deprecated:"muted"},Mm=["memory","doc","topic","tag","file","package"],Dm=["mentions","links","supersedes","documents","about","tagged","in_topic"],Lm={mentions:"a memory's related: header names it",links:"a mem: link in a memory's body",supersedes:"a decision that replaces another",documents:"a doc source covers this package or names this file",about:"a memory relates to a page of this local doc source",tagged:"carries this tag",in_topic:"memory topic or doc category"},Ec=(t,n)=>[...t].sort((s,a)=>{let r=n.indexOf(s),o=n.indexOf(a);return(r===-1?99:r)-(o===-1?99:o)||s.localeCompare(a)});function Tc(t,n){let s=new Set(t);return s.has(n)?s.delete(n):s.add(n),s}function nr({scope:t,focus:n}){let s=t==="docs"?"docs":"memory",[a,r]=x(null),[o,i]=x(!1),[l,c]=x(0),[u,d]=x(new Set),[p,g]=x(new Set),[h,y]=x(""),[m,f]=x(""),[v,b]=x(t==="memory"),[w,k]=x(!1),[C,S]=x(n??null);U(()=>{let B=!0;return i(!0),J("/api/knowledge",{scope:t,focus:n,limit:300}).then(re=>{B&&(r(re),S(n??null))}).catch(re=>B&&ee(re.message,!0)).finally(()=>B&&i(!1)),()=>{B=!1}},[t,n,l]);let _=ae(()=>a?Qs(a,{hiddenKinds:u,hiddenEdges:p,status:h,category:m,hideSuperseded:v}):null,[a,u,p,h,m,v]),T=ae(()=>an(a?.nodes??[],B=>B.kind),[a]),M=ae(()=>an(a?.edges??[],B=>B.kind),[a]),F=B=>a?.nodes.find(re=>re.kind===B&&!re.missing),D=ae(()=>[...new Set((a?.nodes??[]).filter(B=>B.group==="doc"&&B.sub).map(B=>B.sub))],[a]),$=(a?.nodes??[]).some(B=>B.group==="memory"),L=ae(()=>new Map((a?.nodes??[]).map(B=>[B.id,B])),[a]),K=C?L.get(C):void 0,Y=_?.edges??[],ne=K?Y.filter(B=>B.dst===K.id):[],O=K?Y.filter(B=>B.src===K.id):[],A=B=>L.get(B)?.label??B,W=B=>H(s,{tab:"graph",focus:B}),ye=n?L.get(n):void 0;return e("div",{class:"kgalaxy ws",children:[e("div",{class:"gtoolbar",children:[n?e("span",{class:"row tight",children:[e("span",{class:"muted small",children:"focused on"}),e("b",{class:"break",children:ye?.label??n}),e("button",{type:"button",class:"sm",onClick:()=>H(s,{tab:"graph"}),children:"Show all"})]}):e("span",{class:"muted small",children:t==="docs"?"documentation sources and what they cover":"memories and what they are about"}),$?e(R,{children:[e("select",{value:h,title:"memory status",onChange:B=>y(B.target.value),children:[e("option",{value:"",children:"any status"}),Rm.map(B=>e("option",{value:B,children:B}))]}),e("button",{type:"button",class:E("chip",v&&"on"),onClick:()=>b(!v),children:"hide superseded"})]}):null,D.length?e("select",{value:m,title:"doc category",onChange:B=>f(B.target.value),children:[e("option",{value:"",children:"any category"}),D.map(B=>e("option",{value:B,children:Ws(B).label}))]}):null,e("button",{type:"button",class:E("chip",w&&"on"),onClick:()=>k(!w),children:"legend"}),e("button",{type:"button",class:"sm",title:"reload",onClick:()=>c(B=>B+1),children:"\u21BB"}),e("span",{class:"count",children:o?e(se,{}):_&&a?`${_.nodes.length} of ${a.nodes.length} nodes \xB7 ${_.edges.length} edges${a.truncated?` \xB7 first ${a.nodes.length} of ${a.total}`:""}`:""})]}),e("div",{class:"gtoolbar",style:{paddingTop:4,paddingBottom:6},children:[e("span",{class:"muted small",children:"nodes:"}),Ec([...T.keys()],Mm).map(B=>{let re=F(B);return e("button",{type:"button",class:E("chip",!u.has(B)&&"on"),onClick:()=>d(Tc(u,B)),children:[re?e(Nt,{shape:er(re),color:tr(re)}):null,B," ",T.get(B)]})}),e("span",{class:"muted small",style:{marginLeft:8},children:"edges:"}),Ec([...M.keys()],Dm).map(B=>{let re=ns(B);return e("button",{type:"button",title:Lm[B],class:E("chip",!p.has(B)&&"on"),onClick:()=>g(Tc(p,B)),children:[e(An,{color:re.color,dash:re.dash}),B," ",M.get(B)]})})]}),e("div",{class:"kbody",style:{gridTemplateColumns:K?"minmax(0,1fr) 320px":"minmax(0,1fr)"},children:[e("div",{style:{minWidth:0,minHeight:0},children:_?_.nodes.length?e($t,{nodes:_.nodes,edges:_.edges,selected:C,onSelect:S,onActivate:W,legend:w,colorOf:tr,shapeOf:er,edgeStyleOf:ns,labelOf:$c}):a?.nodes.length?e(X,{compact:!0,icon:"\u2205",title:"Nothing left after these filters",children:"Turn some node or edge kinds back on above."}):t==="docs"?e(X,{icon:"\u274F",title:"No documentation sources yet",children:"Add some from Discover and they appear here with what they cover."}):e(X,{icon:"\u274F",title:"No memories yet",children:"Memories saved with em_remember show up here with what they are about."}):e("div",{class:"ws-skel","aria-busy":"true",children:e(N,{h:180})})}),K&&e("div",{class:"panel right",children:[e("div",{class:"head",children:["selection ",e("span",{class:"spacer"}),e("a",{onClick:()=>S(null),children:"close"})]}),e("div",{class:"body",children:[e(jm,{node:K,focus:n,onFocus:W}),e(Rn,{title:"incoming",rows:ne.map(B=>({kind:B.kind,id:B.src})),label:A,onPick:S}),e(Rn,{title:"outgoing",rows:O.map(B=>({kind:B.kind,id:B.dst})),label:A,onPick:S})]})]})]})]})}function jm({node:t,focus:n,onFocus:s}){let a=t.group==="hub";return e("div",{class:"section",children:[e("div",{class:"row tight",children:[e(Nt,{shape:er(t),color:tr(t)}),e(Ie,{kind:t.kind}),e("b",{class:"break",children:t.label})]}),e("div",{class:"row tight wrap",style:{marginTop:4},children:[t.sub&&t.group==="memory"?e(I,{children:t.sub}):null,t.status?e(I,{tone:Am[t.status],children:t.status}):null,t.group==="doc"&&t.detail?e(I,{children:t.detail}):null,t.provider?e(I,{children:t.provider}):null,(t.tags??[]).map(r=>e(I,{children:["#",r]}))]}),t.path&&t.group==="code"&&t.kind!=="file"?e("div",{class:"muted small",children:[t.path,t.line?`:${t.line}`:""]}):null,t.missing?e("div",{class:"muted small",style:{marginTop:4},children:"Referenced, but nothing defines it: a deleted or renamed memory, a file outside the index, or a package the code does not import."}):null,e("div",{class:"row wrap",style:{marginTop:8},children:[t.id!==n?e("button",{type:"button",class:"sm primary",onClick:()=>s(t.id),children:"Focus here"}):null,t.group==="memory"&&!t.missing?e("button",{type:"button",class:"sm",onClick:()=>H("memory",{name:t.label}),children:"Open memory"}):null,t.group==="doc"&&!t.missing?e("button",{type:"button",class:"sm",onClick:()=>H("docs",{tab:"sources",name:t.label}),children:"Open doc source"}):null,!a&&!t.missing?e("button",{type:"button",class:"sm",onClick:()=>H("galaxy",{node:t.id}),children:"Open in code galaxy"}):null,t.kind==="file"&&t.path&&!t.missing?e("button",{type:"button",class:"sm",onClick:()=>H("explore",{file:t.path}),children:"Open source"}):null]})]})}var Pm={url:"accent",path:"ok"},Im={catalog:"ok",probe:"accent",registry:"warn",unknown:"muted"};function Ac({kind:t}){return e(I,{tone:Pm[t]??"muted",children:t})}function Mc({urls:t}){return e("span",{class:"break",children:t.map((n,s)=>{let a=nn(n);return e(R,{children:[s?", ":"",a.kind==="external"?e("a",{href:a.href,target:"_blank",rel:"noreferrer",children:n}):n]})})})}function Fm({s:t,busy:n,onSync:s,onRemove:a}){let r=V(()=>J("/api/docs/pages",{name:t.name}),[t.name,t.sync?.at]),o=[["kind",e(Ac,{kind:t.kind})],...t.provider?[["provider",t.provider]]:[],...t.title?[["title",t.title]]:[],t.kind==="url"?["seeds",e(Mc,{urls:t.urls??[]})]:["path",`${t.path}${t.glob?.length?` [${t.glob.join(", ")}]`:""}`],...t.kind==="url"?[["crawl",`depth ${t.crawl?.depth??"default"}, max ${t.crawl?.maxPages??"default"} pages, ttl ${t.ttlHours??"default"} h`]]:[],...t.tags?.length?[["tags",t.tags.join(", ")]]:[],["added",t.addedAt.slice(0,10)],["last sync",t.sync?`${me(t.sync.at)} \xB7 ${t.sync.pages} ${t.kind==="url"?"pages":"files"} \xB7 ${t.sync.documents} docs \xB7 ${t.sync.chunks} chunks \xB7 ${t.sync.ms} ms${t.sync.errors.length?` \xB7 ${t.sync.errors.length} error(s)`:""}`:"never"]];return e("div",{children:[e("div",{class:"row",style:{marginBottom:6},children:[e("b",{class:"grow break",children:t.name}),e("button",{type:"button",class:"sm",disabled:!!n,onClick:()=>s(!1),children:n===`sync ${t.name}`?e(se,{}):"sync"}),e("button",{type:"button",class:"sm",disabled:!!n,title:"refetch ignoring the cache and drop stale pages",onClick:()=>s(!0),children:"force"}),e("button",{type:"button",class:"sm",title:"this source in the knowledge graph",onClick:()=>H("docs",{tab:"graph",focus:`doc:${t.name}`}),children:"graph"}),e("button",{type:"button",class:"sm danger",disabled:!!n,onClick:a,children:"remove"})]}),e(nt,{rows:o}),t.sync?.errors.length?e("pre",{class:"log",style:{marginTop:8},children:t.sync.errors.join(`
|
|
5
|
+
`)}):null,e("h3",{style:{marginTop:12},children:["indexed pages ",e("span",{class:"muted small",children:["(",t.documents,")"]})]}),r.error?e(Z,{error:r.error}):r.data?r.data.length?e("table",{children:[e("thead",{children:e("tr",{children:[e("th",{children:"title"}),e("th",{class:"num",children:"chunks"}),e("th",{children:"indexed"})]})}),e("tbody",{children:r.data.map(i=>e("tr",{children:[e("td",{class:"break",children:i.uri?.startsWith("http")?e("a",{href:i.uri,target:"_blank",rel:"noreferrer",children:i.title}):i.title}),e("td",{class:"num",children:i.chunks}),e("td",{class:"muted nowrap",children:Ve(i.created_at)})]}))})]}):e(X,{compact:!0,icon:"\u25CB",title:"Nothing indexed yet",children:"Run sync to index this source."}):e(se,{})]})}function Om({onDone:t}){let[n,s]=x(""),[a,r]=x(""),[o,i]=x(""),[l,c]=x(""),[u,d]=x(""),[p,g]=x(""),[h,y]=x(""),[m,f]=x(""),[v,b]=x(!1);return e(j,{title:"Add a source",children:[e("div",{class:"grid",style:{gridTemplateColumns:"1fr 2fr 1fr",gap:8},children:[e("div",{class:"field",children:[e("label",{children:"name (optional)"}),e("input",{type:"text",placeholder:"moleculer",value:n,onInput:k=>s(k.target.value)})]}),e("div",{class:"field",children:[e("label",{children:"url(s) \u2014 one per line; same-origin pages under each are crawled"}),e("textarea",{rows:2,placeholder:"https://moleculer.services/docs/0.14/",value:a,onInput:k=>r(k.target.value)})]}),e("div",{class:"field",children:[e("label",{children:"or provider (npm:zod, pypi:fastapi, api:api.example.com)"}),e("input",{type:"text",value:u,onInput:k=>d(k.target.value)})]})]}),e("div",{class:"grid",style:{gridTemplateColumns:"2fr 2fr 1fr 1fr 2fr",gap:8},children:[e("div",{class:"field",children:[e("label",{children:"or local path"}),e("input",{type:"text",placeholder:"docs/",value:o,onInput:k=>i(k.target.value)})]}),e("div",{class:"field",children:[e("label",{children:"globs (comma separated)"}),e("input",{type:"text",placeholder:"**/*.md",value:l,onInput:k=>c(k.target.value)})]}),e("div",{class:"field",children:[e("label",{children:"crawl depth"}),e("input",{type:"number",min:0,max:3,value:p,onInput:k=>g(k.target.value)})]}),e("div",{class:"field",children:[e("label",{children:"max pages"}),e("input",{type:"number",min:1,max:200,value:h,onInput:k=>y(k.target.value)})]}),e("div",{class:"field",children:[e("label",{children:"tags"}),e("input",{type:"text",value:m,onInput:k=>f(k.target.value)})]})]}),e("div",{class:"row",children:e("button",{type:"button",class:"primary",disabled:v,onClick:async()=>{let k=a.split(/\s+/).map(C=>C.trim()).filter(Boolean);if(!k.length&&!o.trim()&&!u.trim())return ee("give a url, a path or a provider",!0);b(!0);try{let C=await $e("/api/docs",{sources:[{name:n.trim()||void 0,urls:k.length?k:void 0,path:o.trim()||void 0,glob:l.trim()?l.split(",").map(S=>S.trim()).filter(Boolean):void 0,provider:u.trim()||void 0,crawl:p||h?{depth:p?Number(p):void 0,maxPages:h?Number(h):void 0}:void 0,tags:m.trim()?m.split(",").map(S=>S.trim()).filter(Boolean):void 0}],sync:!0});ee(C.failed.length?C.failed[0].reason:`added ${[...C.added,...C.updated].join(", ")}`,!!C.failed.length),t(C),C.failed.length||(s(""),r(""),i(""),c(""),d(""))}catch(C){ee(C.message,!0)}finally{b(!1)}},children:v?e(se,{}):"Add & index"})})]})}function Ma(t){let n=t.tags?.[0];return t.kind==="path"&&n&&(t.name===n||t.name.startsWith(`${n}-`))?n:t.name}function Rc(t){if(t.kind==="path"){let s=t.path&&t.path!=="."?t.path:"",a=t.glob?.length?t.glob.length<=2?t.glob.join(", "):`${t.glob.length} globs`:"";return[s,a].filter(Boolean).join(" \xB7 ")||t.title||"project root"}return[...new Set((t.urls??[]).map(s=>s.replace(/^https?:\/\//,"").split("/")[0]))].join(", ")||t.provider||""}function Nm({s:t,sel:n,onSelect:s}){let a=Ma(t);return e("div",{class:E("item",n&&"sel"),onClick:s,children:[e("div",{class:"n",children:[a,a!==t.name?e("span",{class:"muted small",children:[" ",t.name]}):null]}),e("div",{class:"p",title:t.kind==="url"?(t.urls??[]).join(`
|
|
6
|
+
`):Rc(t),children:[e(Ac,{kind:t.kind}),t.provider?e("span",{class:"muted",children:[t.provider," \xB7 "]}):null,e("span",{class:"muted",children:Rc(t)})]}),e("div",{class:"p",children:e("span",{class:"muted",children:[t.documents," docs \xB7 ",t.chunks," chunks \xB7"," ",t.sync?`synced ${me(t.sync.at)}`:"never synced",t.sync?.errors.length?e("span",{class:"bad",children:[" \xB7 ",t.sync.errors.length," errors"]}):null]})})]})}function Bm({params:t,onLog:n}){let s=V(()=>J("/api/docs"),[]),[a,r]=x(t.name??null),[o,i]=x(""),[l,c]=x(!1),[u,d]=x(null);U(()=>{t.name&&r(t.name)},[t.name]);let[p,g]=x("all"),[h,y]=x(new Set),m=s.data,f=ae(()=>{let _=o.trim().toLowerCase();return(m?.sources??[]).filter(T=>(p==="all"||T.category===p)&&(!_||T.name.includes(_)||(T.title??"").toLowerCase().includes(_)||(T.provider??"").includes(_)||(T.tags??[]).some(M=>M.includes(_))||(T.urls??[]).some(M=>M.includes(_))||(T.path??"").includes(_)))},[m,o,p]),v=ae(()=>{let _=new Map;for(let T of m?.sources??[])_.set(T.category,(_.get(T.category)??0)+1);return _},[m]),b=ae(()=>{let _=new Map;for(let F of f){let D=_.get(F.category)??[];D.push(F),_.set(F.category,D)}let T=[..._.entries()].sort((F,D)=>ha(F[0])-ha(D[0])).map(([F,D])=>({info:Ws(F),items:D.sort(($,L)=>Ma($).localeCompare(Ma(L)))})),M=[];for(let F of T){let D=M[M.length-1];D?.group===F.info.group?D.cats.push(F):M.push({group:F.info.group,label:zl[F.info.group],cats:[F]})}return M},[f]),w=_=>y(T=>{let M=new Set(T);return M.has(_)?M.delete(_):M.add(_),M}),k=f.find(_=>_.name===a)??m?.sources.find(_=>_.name===a),C=async(_,T)=>{let M=_?.length===1?`sync ${_[0]}`:"sync all";d(M);try{let F=await $e("/api/docs/sync",{names:_,force:T});n(F.text),ee(`${M} done`),s.reload()}catch(F){ee(F.message,!0)}finally{d(null)}},S=async _=>{if(confirm(`Remove documentation source "${_}" and its indexed pages?`))try{let T=await Es("/api/docs",{name:_});ee(`removed ${_} (${T.documents} document(s))`),r(null),s.reload()}catch(T){ee(T.message,!0)}};return s.error?e(Z,{error:s.error}):e(R,{children:[e("div",{class:"row",style:{marginBottom:12},children:[e("button",{type:"button",class:"primary",onClick:()=>c(_=>!_),children:l?"close":"+ Add source"}),e("button",{type:"button",disabled:!!u||!m?.sources.length,onClick:()=>C(void 0,!1),children:u==="sync all"?e(se,{}):"\u21BB Sync all"}),e("input",{type:"search",class:"grow",placeholder:"filter by name, provider, tag or url\u2026",value:o,onInput:_=>i(_.target.value)}),e("span",{class:"muted small nowrap",children:m?`${m.sources.length} sources \xB7 ${z(m.totals.documents)} docs \xB7 ${z(m.totals.chunks)} chunks \xB7 ${m.manifest}`:""})]}),m?.sources.length?e("div",{class:"row wrap",style:{marginBottom:10,gap:4},children:[e("button",{type:"button",class:E("chip",p==="all"&&"on"),onClick:()=>g("all"),children:["All \xB7 ",m.sources.length]}),Yn.filter(_=>v.get(_.id)).map(_=>e("button",{type:"button",class:E("chip",p===_.id&&"on"),title:_.blurb,onClick:()=>g(p===_.id?"all":_.id),children:[_.label," \xB7 ",v.get(_.id)]}))]}):null,l&&e(Om,{onDone:_=>{n(_.text),s.reload();let T=[..._.added,..._.updated][0];T&&r(T)}}),m?.orphans.length?e("div",{class:"empty",style:{marginBottom:12},children:["indexed under docs: but missing from the manifest:"," ",m.orphans.map(_=>`${_.source} (${_.documents})`).join(", ")," \u2014 re-add them or purge the index."]}):null,e("div",{class:"grid wide",style:{gridTemplateColumns:"minmax(280px,1fr) minmax(0,2fr)",alignItems:"start"},children:[e(j,{flush:!0,children:e("div",{class:"list",children:m?f.length?b.map(_=>e(R,{children:[b.length>1?e("div",{class:"group-h",children:_.label}):null,_.cats.map(({info:T,items:M})=>{let F=!h.has(T.id);return e(R,{children:[e("div",{class:E("cat-h",!F&&"closed"),title:T.blurb,onClick:()=>w(T.id),children:[e("span",{class:"caret",children:F?"\u25BE":"\u25B8"}),T.label,e("span",{class:"muted",children:[" \xB7 ",M.length]}),e("span",{class:"muted small right",children:[z(M.reduce((D,$)=>D+$.documents,0))," docs"]})]}),F?M.map(D=>e(Nm,{s:D,sel:a===D.name,onSelect:()=>r(D.name)})):null]})})]})):e(X,{compact:!0,icon:"\u25CB",title:m.sources.length?"No sources match":"No documentation sources yet",children:m.sources.length?null:"Use Discover, or add a url, path or provider."}):e(X,{compact:!0,icon:"\u2026",title:"Loading sources",children:e(se,{})})})}),e(j,{children:k?e(Fm,{s:k,busy:u,onSync:_=>C([k.name],_),onRemove:()=>S(k.name)}):e(X,{compact:!0,icon:"\u25C7",title:"Select a source",children:"to see its pages and sync state."})})]})]})}function Hm({onLog:t,onAdded:n}){let[s,a]=x(!1),[r,o]=x(!1),i=V(()=>r?J("/api/docs/discover",{dev:s?1:void 0}):Promise.resolve(void 0),[r,s]),[l,c]=x(new Set),[u,d]=x({}),[p,g]=x(!1),h=i.data;U(()=>{if(!h)return;let w=new Set;for(let k of h.local)k.registered||w.add(`local:${k.name}`);for(let k of h.providers)!k.registered&&(k.confidence==="probe"||k.confidence==="catalog"&&k.tier!=="library"&&k.tier!=="infra")&&w.add(`prov:${k.name}`);c(w)},[h]);let y=w=>c(k=>{let C=new Set(k);return C.has(w)?C.delete(w):C.add(w),C}),m=async()=>{if(!h)return;let w=[];for(let k of h.local)l.has(`local:${k.name}`)&&w.push({name:k.name,path:k.path,glob:k.glob,title:k.why,tags:k.project?[k.project]:void 0});for(let k of h.providers){if(!l.has(`prov:${k.name}`))continue;let C=u[k.name]?.trim(),S=C?C.split(/\s+/).filter(Boolean):k.urls.length?k.urls:void 0;!S&&k.confidence==="unknown"||w.push({name:k.name,provider:k.provider,urls:S,title:k.title,crawl:k.crawl})}if(!w.length)return ee("nothing selected",!0);g(!0),t(`adding ${w.length} source(s)\u2026`);try{let k=await $e("/api/docs",{sources:w,sync:!0});t(k.text),ee(`${k.added.length+k.updated.length} added${k.failed.length?`, ${k.failed.length} failed`:""}`,!!k.failed.length&&!k.added.length),n(),o(!1),setTimeout(()=>o(!0),0)}catch(k){ee(k.message,!0)}finally{g(!1)}},f=w=>(h?.providers??[]).filter(k=>k.confidence===w),v=({keyId:w,title:k,meta:C,right:S,registered:_})=>e("tr",{class:E(_&&"muted"),children:[e("td",{style:{width:24},children:e("input",{type:"checkbox",disabled:_,checked:l.has(w),onChange:()=>y(w)})}),e("td",{class:"break",children:[k,_?e("span",{class:"tag",children:" registered"}):null]}),e("td",{class:"break muted small",children:C}),e("td",{children:S??null})]}),b=({conf:w,note:k})=>{let C=f(w);return C.length?e("div",{class:"card flush",style:{marginBottom:12},children:[e("h3",{style:{padding:"10px 12px 0"},children:[e(I,{tone:Im[w]??"muted",children:w})," ",w==="catalog"?"libraries, services and infrastructure":w==="probe"?"third-party APIs called from code":w==="registry"?"packages resolved through npm / PyPI / Go":"unknown env prefixes and images"," ",e("span",{class:"muted small",children:["\u2014 ",k]})]}),e("table",{children:e("tbody",{children:C.map(S=>e(v,{keyId:`prov:${S.name}`,registered:S.registered,title:e(R,{children:[e("b",{children:S.name})," ",e("span",{class:"muted small",children:["\u2190 ",S.provider]})]}),meta:e(R,{children:[S.title,S.usedBy.length>1?` \xB7 used by ${S.usedBy.length} projects`:S.usedBy[0]&&S.usedBy[0]!=="."?` \xB7 ${S.usedBy[0]}`:"",S.urls.length?e(R,{children:[" \xB7 ",e(Mc,{urls:S.urls.slice(0,2)})]}):w==="probe"||w==="unknown"?` \xB7 ${S.evidence[0]}`:""]}),right:w==="unknown"||w==="probe"?e("input",{type:"text",placeholder:w==="probe"?"docs url (optional; probed if empty)":"docs url",style:{minWidth:220},value:u[S.name]??"",onInput:_=>d({...u,[S.name]:_.target.value})}):void 0}))})})]}):null};return e(R,{children:[e("div",{class:"row",style:{marginBottom:12},children:[e("button",{type:"button",class:"primary",disabled:i.loading&&r,onClick:()=>r?i.reload():o(!0),children:i.loading&&r?e(se,{}):r?"\u21BB Scan again":"Scan project"}),e("label",{class:"small",children:[e("input",{type:"checkbox",checked:s,onChange:w=>a(w.target.checked)})," ","include devDependencies"]}),e("span",{class:"spacer"}),h?e(R,{children:[e("span",{class:"muted small",children:[h.projects.length>1?`${h.projects.length} projects \xB7 `:"",h.local.length," local \xB7 ",h.providers.length," providers \xB7 ",l.size," selected"]}),e("button",{type:"button",class:"primary",disabled:p||!l.size,onClick:m,children:p?e(se,{}):"Add selected & index"})]}):null]}),i.error?e(Z,{error:i.error}):null,r?h?e(R,{children:[h.local.length?e("div",{class:"card flush",style:{marginBottom:12},children:[e("h3",{style:{padding:"10px 12px 0"},children:["local documentation ",e("span",{class:"muted small",children:"\u2014 indexed from the working tree"})]}),e("table",{children:e("tbody",{children:h.local.map(w=>e(v,{keyId:`local:${w.name}`,registered:w.registered,title:e(R,{children:[e("b",{children:w.name})," ",e("span",{class:"muted small",children:w.path})]}),meta:`${w.files} file(s) \xB7 ${z(w.bytes)} B \xB7 ${w.why}${w.glob&&w.glob.length<=4?` \xB7 ${w.glob.join(", ")}`:""}`}))})})]}):null,e(b,{conf:"catalog",note:"documentation URLs known offline"}),e(b,{conf:"probe",note:"docs., developer. and /docs locations are probed when added; give a url to skip the guess"}),e(b,{conf:"registry",note:"homepage and README come from the package registry when added"}),e(b,{conf:"unknown",note:"needs a documentation url"})]}):e(se,{}):e(X,{compact:!0,icon:"\u2315",title:"Discover documentation",children:"Scans the project (and one level of sub-projects) for READMEs, docs folders, ADRs, API specs, agent instructions and env references, plus the npm / PyPI / Go packages, env var prefixes, container images, infrastructure files and outbound API calls \u2014 and maps each to its documentation. Nothing is fetched until you add."})]})}function Um({sources:t}){let[n,s]=x(""),[a,r]=x(""),[o,i]=x(""),l=V(()=>o?J("/api/search",{q:o,source:a?`docs:${a}`:"docs:*",limit:15}):Promise.resolve(void 0),[o,a]);return e(R,{children:[e("div",{class:"row",style:{marginBottom:12},children:[e("input",{type:"search",class:"grow",placeholder:"ask the documentation\u2026 (hybrid keyword + semantic)",value:n,onInput:c=>s(c.target.value),onKeyDown:c=>{c.key==="Enter"&&i(n.trim())}}),e("select",{value:a,onChange:c=>r(c.target.value),children:[e("option",{value:"",children:"all documentation"}),t.map(c=>e("option",{value:c,children:c}))]}),e("button",{type:"button",class:"primary",onClick:()=>i(n.trim()),children:"Search"})]}),l.error?e(Z,{error:l.error}):null,o?l.data?l.data.hits.length?e("div",{class:"stack",children:[l.data.corrections.length?e("div",{class:"muted small",children:["corrected: ",l.data.corrections.map(c=>`${c.from}\u2192${c.to}`).join(", ")]}):null,l.data.hits.map(c=>e("div",{class:"card hit",children:[e("div",{class:"row tight",children:[e("b",{class:"break",children:c.uri?.startsWith("http")?e("a",{href:c.uri,target:"_blank",rel:"noreferrer",children:c.title}):c.title}),e("span",{class:"tag",children:c.source.replace(/^docs:/,"")}),e("span",{class:"muted small",children:["doc ",c.doc," \xB7 ",c.score.toFixed(3)]})]}),e("pre",{class:"json",style:{whiteSpace:"pre-wrap",fontFamily:"inherit",fontSize:13,marginTop:4},children:c.snippet})]}))]}):e(X,{compact:!0,icon:"\u25CB",title:"No matches"}):e(se,{}):e(X,{compact:!0,icon:"\u2315",title:"Search the documentation",children:"Searches only the documentation sources (source docs:*). Claude uses the same index through em_docs lookup."})]})}function Dc({params:t}){let[n,s]=x(t.tab??"sources"),[a,r]=x([]),[o,i]=x(0),l=V(()=>J("/api/docs"),[o]),c=u=>r(d=>[...d,`[${new Date().toLocaleTimeString()}]
|
|
7
|
+
${u}`]);return U(()=>{t.tab&&s(t.tab)},[t.tab]),e("div",{class:"page ds-page docs-page",children:[e(Te,{eyebrow:"Documentation",title:"Documentation knowledge base",sub:"Local docs and the libraries, services and APIs the project depends on, indexed for em_docs lookup.",meta:l.data?e(I,{tone:"accent",children:[l.data.sources.length," sources"]}):null}),e(Se,{label:"Documentation views",options:[{id:"sources",label:"Sources"},{id:"discover",label:"Discover"},{id:"search",label:"Search"},{id:"graph",label:"Graph"}],value:n,onChange:u=>{s(u),H("docs",{tab:u})}}),n==="sources"&&e(Bm,{params:t,onLog:c},o),n==="discover"&&e(Hm,{onLog:c,onAdded:()=>i(u=>u+1)}),n==="search"&&e(Um,{sources:(l.data?.sources??[]).map(u=>u.name)}),n==="graph"&&e(nr,{scope:"docs",focus:t.focus}),a.length?e(j,{class:"docs-log",title:"Sync log",right:e("button",{type:"button",class:"sm",onClick:()=>r([]),children:"clear"}),children:e("pre",{class:"log",children:a.join(`
|
|
8
8
|
|
|
9
|
-
`)})]}):null]})}var ar=ac(Fo(),1);Prism.languages.javascript=Prism.languages.extend("clike",{"class-name":[Prism.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+(/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source)+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/});Prism.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/;Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:Prism.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:Prism.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/});Prism.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}});Prism.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}});Prism.languages.markup&&(Prism.languages.markup.tag.addInlined("script","javascript"),Prism.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript"));Prism.languages.js=Prism.languages.javascript;(function(t){t.languages.typescript=t.languages.extend("javascript",{"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|type)\s+)(?!keyof\b)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?:\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>)?/,lookbehind:!0,greedy:!0,inside:null},builtin:/\b(?:Array|Function|Promise|any|boolean|console|never|number|string|symbol|unknown)\b/}),t.languages.typescript.keyword.push(/\b(?:abstract|declare|is|keyof|readonly|require)\b/,/\b(?:asserts|infer|interface|module|namespace|type)\b(?=\s*(?:[{_$a-zA-Z\xA0-\uFFFF]|$))/,/\btype\b(?=\s*(?:[\{*]|$))/),delete t.languages.typescript.parameter,delete t.languages.typescript["literal-property"];var n=t.languages.extend("typescript",{});delete n["class-name"],t.languages.typescript["class-name"].inside=n,t.languages.insertBefore("typescript","function",{decorator:{pattern:/@[$\w\xA0-\uFFFF]+/,inside:{at:{pattern:/^@/,alias:"operator"},function:/^[\s\S]+/}},"generic-function":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>(?=\s*\()/,greedy:!0,inside:{function:/^#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*/,generic:{pattern:/<[\s\S]+/,alias:"class-name",inside:n}}}}),t.languages.ts=t.languages.typescript})(Prism);(function(t){var n=t.util.clone(t.languages.javascript),s=/(?:\s|\/\/.*(?!.)|\/\*(?:[^*]|\*(?!\/))\*\/)/.source,r=/(?:\{(?:\{(?:\{[^{}]*\}|[^{}])*\}|[^{}])*\})/.source,a=/(?:\{<S>*\.{3}(?:[^{}]|<BRACES>)*\})/.source;function i(c,d){return c=c.replace(/<S>/g,function(){return s}).replace(/<BRACES>/g,function(){return r}).replace(/<SPREAD>/g,function(){return a}),RegExp(c,d)}a=i(a).source,t.languages.jsx=t.languages.extend("markup",n),t.languages.jsx.tag.pattern=i(/<\/?(?:[\w.:-]+(?:<S>+(?:[\w.:$-]+(?:=(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|[^\s{'"/>=]+|<BRACES>))?|<SPREAD>))*<S>*\/?)?>/.source),t.languages.jsx.tag.inside.tag.pattern=/^<\/?[^\s>\/]*/,t.languages.jsx.tag.inside["attr-value"].pattern=/=(?!\{)(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|[^\s'">]+)/,t.languages.jsx.tag.inside.tag.inside["class-name"]=/^[A-Z]\w*(?:\.[A-Z]\w*)*$/,t.languages.jsx.tag.inside.comment=n.comment,t.languages.insertBefore("inside","attr-name",{spread:{pattern:i(/<SPREAD>/.source),inside:t.languages.jsx}},t.languages.jsx.tag),t.languages.insertBefore("inside","special-attr",{script:{pattern:i(/=<BRACES>/.source),alias:"language-javascript",inside:{"script-punctuation":{pattern:/^=(?=\{)/,alias:"punctuation"},rest:t.languages.jsx}}},t.languages.jsx.tag);var o=function(c){return c?typeof c=="string"?c:typeof c.content=="string"?c.content:c.content.map(o).join(""):""},l=function(c){for(var d=[],u=0;u<c.length;u++){var p=c[u],f=!1;if(typeof p!="string"&&(p.type==="tag"&&p.content[0]&&p.content[0].type==="tag"?p.content[0].content[0].content==="</"?d.length>0&&d[d.length-1].tagName===o(p.content[0].content[1])&&d.pop():p.content[p.content.length-1].content==="/>"||d.push({tagName:o(p.content[0].content[1]),openedBraces:0}):d.length>0&&p.type==="punctuation"&&p.content==="{"?d[d.length-1].openedBraces++:d.length>0&&d[d.length-1].openedBraces>0&&p.type==="punctuation"&&p.content==="}"?d[d.length-1].openedBraces--:f=!0),(f||typeof p=="string")&&d.length>0&&d[d.length-1].openedBraces===0){var g=o(p);u<c.length-1&&(typeof c[u+1]=="string"||c[u+1].type==="plain-text")&&(g+=o(c[u+1]),c.splice(u+1,1)),u>0&&(typeof c[u-1]=="string"||c[u-1].type==="plain-text")&&(g=o(c[u-1])+g,c.splice(u-1,1),u--),c[u]=new t.Token("plain-text",g,null,g)}p.content&&typeof p.content!="string"&&l(p.content)}};t.hooks.add("after-tokenize",function(c){c.language!=="jsx"&&c.language!=="tsx"||l(c.tokens)})})(Prism);(function(t){var n=t.util.clone(t.languages.typescript);t.languages.tsx=t.languages.extend("jsx",n),delete t.languages.tsx.parameter,delete t.languages.tsx["literal-property"];var s=t.languages.tsx.tag;s.pattern=RegExp(/(^|[^\w$]|(?=<\/))/.source+"(?:"+s.pattern.source+")",s.pattern.flags),s.lookbehind=!0})(Prism);Prism.languages.python={comment:{pattern:/(^|[^\\])#.*/,lookbehind:!0,greedy:!0},"string-interpolation":{pattern:/(?:f|fr|rf)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,greedy:!0,inside:{interpolation:{pattern:/((?:^|[^{])(?:\{\{)*)\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}])+\})+\})+\}/,lookbehind:!0,inside:{"format-spec":{pattern:/(:)[^:(){}]+(?=\}$)/,lookbehind:!0},"conversion-option":{pattern://,alias:"punctuation"},rest:null}},string:/[\s\S]+/}},"triple-quoted-string":{pattern:/(?:[rub]|br|rb)?("""|''')[\s\S]*?\1/i,greedy:!0,alias:"string"},string:{pattern:/(?:[rub]|br|rb)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i,greedy:!0},function:{pattern:/((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,lookbehind:!0},"class-name":{pattern:/(\bclass\s+)\w+/i,lookbehind:!0},decorator:{pattern:/(^[\t ]*)@\w+(?:\.\w+)*/m,lookbehind:!0,alias:["annotation","punctuation"],inside:{punctuation:/\./}},keyword:/\b(?:_(?=\s*:)|and|as|assert|async|await|break|case|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|match|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b/,builtin:/\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/,boolean:/\b(?:False|None|True)\b/,number:/\b0(?:b(?:_?[01])+|o(?:_?[0-7])+|x(?:_?[a-f0-9])+)\b|(?:\b\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\B\.\d+(?:_\d+)*)(?:e[+-]?\d+(?:_\d+)*)?j?(?!\w)/i,operator:/[-+%=]=?|!=|:=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,punctuation:/[{}[\];(),.:]/};Prism.languages.python["string-interpolation"].inside.interpolation.inside.rest=Prism.languages.python;Prism.languages.py=Prism.languages.python;Prism.languages.go=Prism.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,lookbehind:!0,greedy:!0},keyword:/\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,boolean:/\b(?:_|false|iota|nil|true)\b/,number:[/\b0(?:b[01_]+|o[0-7_]+)i?\b/i,/\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,/(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i],operator:/[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,builtin:/\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/});Prism.languages.insertBefore("go","string",{char:{pattern:/'(?:\\.|[^'\\\r\n]){0,10}'/,greedy:!0}});delete Prism.languages.go["class-name"];(function(t){function n(s,r){return"___"+s.toUpperCase()+r+"___"}Object.defineProperties(t.languages["markup-templating"]={},{buildPlaceholders:{value:function(s,r,a,i){if(s.language===r){var o=s.tokenStack=[];s.code=s.code.replace(a,function(l){if(typeof i=="function"&&!i(l))return l;for(var c=o.length,d;s.code.indexOf(d=n(r,c))!==-1;)++c;return o[c]=l,d}),s.grammar=t.languages.markup}}},tokenizePlaceholders:{value:function(s,r){if(s.language!==r||!s.tokenStack)return;s.grammar=t.languages[r];var a=0,i=Object.keys(s.tokenStack);function o(l){for(var c=0;c<l.length&&!(a>=i.length);c++){var d=l[c];if(typeof d=="string"||d.content&&typeof d.content=="string"){var u=i[a],p=s.tokenStack[u],f=typeof d=="string"?d:d.content,g=n(r,u),y=f.indexOf(g);if(y>-1){++a;var h=f.substring(0,y),m=new t.Token(r,t.tokenize(p,s.grammar),"language-"+r,p),b=f.substring(y+g.length),v=[];h&&v.push.apply(v,o([h])),v.push(m),b&&v.push.apply(v,o([b])),typeof d=="string"?l.splice.apply(l,[c,1].concat(v)):d.content=v}}else d.content&&o(d.content)}return l}o(s.tokens)}}})})(Prism);(function(t){var n=/\/\*[\s\S]*?\*\/|\/\/.*|#(?!\[).*/,s=[{pattern:/\b(?:false|true)\b/i,alias:"boolean"},{pattern:/(::\s*)\b[a-z_]\w*\b(?!\s*\()/i,greedy:!0,lookbehind:!0},{pattern:/(\b(?:case|const)\s+)\b[a-z_]\w*(?=\s*[;=])/i,greedy:!0,lookbehind:!0},/\b(?:null)\b/i,/\b[A-Z_][A-Z0-9_]*\b(?!\s*\()/],r=/\b0b[01]+(?:_[01]+)*\b|\b0o[0-7]+(?:_[0-7]+)*\b|\b0x[\da-f]+(?:_[\da-f]+)*\b|(?:\b\d+(?:_\d+)*\.?(?:\d+(?:_\d+)*)?|\B\.\d+)(?:e[+-]?\d+)?/i,a=/<?=>|\?\?=?|\.{3}|\??->|[!=]=?=?|::|\*\*=?|--|\+\+|&&|\|\||<<|>>|[?~]|[/^|%*&<>.+-]=?/,i=/[{}\[\](),:;]/;t.languages.php={delimiter:{pattern:/\?>$|^<\?(?:php(?=\s)|=)?/i,alias:"important"},comment:n,variable:/\$+(?:\w+\b|(?=\{))/,package:{pattern:/(namespace\s+|use\s+(?:function\s+)?)(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,lookbehind:!0,inside:{punctuation:/\\/}},"class-name-definition":{pattern:/(\b(?:class|enum|interface|trait)\s+)\b[a-z_]\w*(?!\\)\b/i,lookbehind:!0,alias:"class-name"},"function-definition":{pattern:/(\bfunction\s+)[a-z_]\w*(?=\s*\()/i,lookbehind:!0,alias:"function"},keyword:[{pattern:/(\(\s*)\b(?:array|bool|boolean|float|int|integer|object|string)\b(?=\s*\))/i,alias:"type-casting",greedy:!0,lookbehind:!0},{pattern:/([(,?]\s*)\b(?:array(?!\s*\()|bool|callable|(?:false|null)(?=\s*\|)|float|int|iterable|mixed|object|self|static|string)\b(?=\s*\$)/i,alias:"type-hint",greedy:!0,lookbehind:!0},{pattern:/(\)\s*:\s*(?:\?\s*)?)\b(?:array(?!\s*\()|bool|callable|(?:false|null)(?=\s*\|)|float|int|iterable|mixed|never|object|self|static|string|void)\b/i,alias:"return-type",greedy:!0,lookbehind:!0},{pattern:/\b(?:array(?!\s*\()|bool|float|int|iterable|mixed|object|string|void)\b/i,alias:"type-declaration",greedy:!0},{pattern:/(\|\s*)(?:false|null)\b|\b(?:false|null)(?=\s*\|)/i,alias:"type-declaration",greedy:!0,lookbehind:!0},{pattern:/\b(?:parent|self|static)(?=\s*::)/i,alias:"static-context",greedy:!0},{pattern:/(\byield\s+)from\b/i,lookbehind:!0},/\bclass\b/i,{pattern:/((?:^|[^\s>:]|(?:^|[^-])>|(?:^|[^:]):)\s*)\b(?:abstract|and|array|as|break|callable|case|catch|clone|const|continue|declare|default|die|do|echo|else|elseif|empty|enddeclare|endfor|endforeach|endif|endswitch|endwhile|enum|eval|exit|extends|final|finally|fn|for|foreach|function|global|goto|if|implements|include|include_once|instanceof|insteadof|interface|isset|list|match|namespace|never|new|or|parent|print|private|protected|public|readonly|require|require_once|return|self|static|switch|throw|trait|try|unset|use|var|while|xor|yield|__halt_compiler)\b/i,lookbehind:!0}],"argument-name":{pattern:/([(,]\s*)\b[a-z_]\w*(?=\s*:(?!:))/i,lookbehind:!0},"class-name":[{pattern:/(\b(?:extends|implements|instanceof|new(?!\s+self|\s+static))\s+|\bcatch\s*\()\b[a-z_]\w*(?!\\)\b/i,greedy:!0,lookbehind:!0},{pattern:/(\|\s*)\b[a-z_]\w*(?!\\)\b/i,greedy:!0,lookbehind:!0},{pattern:/\b[a-z_]\w*(?!\\)\b(?=\s*\|)/i,greedy:!0},{pattern:/(\|\s*)(?:\\?\b[a-z_]\w*)+\b/i,alias:"class-name-fully-qualified",greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}},{pattern:/(?:\\?\b[a-z_]\w*)+\b(?=\s*\|)/i,alias:"class-name-fully-qualified",greedy:!0,inside:{punctuation:/\\/}},{pattern:/(\b(?:extends|implements|instanceof|new(?!\s+self\b|\s+static\b))\s+|\bcatch\s*\()(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,alias:"class-name-fully-qualified",greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}},{pattern:/\b[a-z_]\w*(?=\s*\$)/i,alias:"type-declaration",greedy:!0},{pattern:/(?:\\?\b[a-z_]\w*)+(?=\s*\$)/i,alias:["class-name-fully-qualified","type-declaration"],greedy:!0,inside:{punctuation:/\\/}},{pattern:/\b[a-z_]\w*(?=\s*::)/i,alias:"static-context",greedy:!0},{pattern:/(?:\\?\b[a-z_]\w*)+(?=\s*::)/i,alias:["class-name-fully-qualified","static-context"],greedy:!0,inside:{punctuation:/\\/}},{pattern:/([(,?]\s*)[a-z_]\w*(?=\s*\$)/i,alias:"type-hint",greedy:!0,lookbehind:!0},{pattern:/([(,?]\s*)(?:\\?\b[a-z_]\w*)+(?=\s*\$)/i,alias:["class-name-fully-qualified","type-hint"],greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}},{pattern:/(\)\s*:\s*(?:\?\s*)?)\b[a-z_]\w*(?!\\)\b/i,alias:"return-type",greedy:!0,lookbehind:!0},{pattern:/(\)\s*:\s*(?:\?\s*)?)(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,alias:["class-name-fully-qualified","return-type"],greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}}],constant:s,function:{pattern:/(^|[^\\\w])\\?[a-z_](?:[\w\\]*\w)?(?=\s*\()/i,lookbehind:!0,inside:{punctuation:/\\/}},property:{pattern:/(->\s*)\w+/,lookbehind:!0},number:r,operator:a,punctuation:i};var o={pattern:/\{\$(?:\{(?:\{[^{}]+\}|[^{}]+)\}|[^{}])+\}|(^|[^\\{])\$+(?:\w+(?:\[[^\r\n\[\]]+\]|->\w+)?)/,lookbehind:!0,inside:t.languages.php},l=[{pattern:/<<<'([^']+)'[\r\n](?:.*[\r\n])*?\1;/,alias:"nowdoc-string",greedy:!0,inside:{delimiter:{pattern:/^<<<'[^']+'|[a-z_]\w*;$/i,alias:"symbol",inside:{punctuation:/^<<<'?|[';]$/}}}},{pattern:/<<<(?:"([^"]+)"[\r\n](?:.*[\r\n])*?\1;|([a-z_]\w*)[\r\n](?:.*[\r\n])*?\2;)/i,alias:"heredoc-string",greedy:!0,inside:{delimiter:{pattern:/^<<<(?:"[^"]+"|[a-z_]\w*)|[a-z_]\w*;$/i,alias:"symbol",inside:{punctuation:/^<<<"?|[";]$/}},interpolation:o}},{pattern:/`(?:\\[\s\S]|[^\\`])*`/,alias:"backtick-quoted-string",greedy:!0},{pattern:/'(?:\\[\s\S]|[^\\'])*'/,alias:"single-quoted-string",greedy:!0},{pattern:/"(?:\\[\s\S]|[^\\"])*"/,alias:"double-quoted-string",greedy:!0,inside:{interpolation:o}}];t.languages.insertBefore("php","variable",{string:l,attribute:{pattern:/#\[(?:[^"'\/#]|\/(?![*/])|\/\/.*$|#(?!\[).*$|\/\*(?:[^*]|\*(?!\/))*\*\/|"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*')+\](?=\s*[a-z$#])/im,greedy:!0,inside:{"attribute-content":{pattern:/^(#\[)[\s\S]+(?=\]$)/,lookbehind:!0,inside:{comment:n,string:l,"attribute-class-name":[{pattern:/([^:]|^)\b[a-z_]\w*(?!\\)\b/i,alias:"class-name",greedy:!0,lookbehind:!0},{pattern:/([^:]|^)(?:\\?\b[a-z_]\w*)+/i,alias:["class-name","class-name-fully-qualified"],greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}}],constant:s,number:r,operator:a,punctuation:i}},delimiter:{pattern:/^#\[|\]$/,alias:"punctuation"}}}}),t.hooks.add("before-tokenize",function(c){if(/<\?/.test(c.code)){var d=/<\?(?:[^"'/#]|\/(?![*/])|("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|(?:\/\/|#(?!\[))(?:[^?\n\r]|\?(?!>))*(?=$|\?>|[\r\n])|#\[|\/\*(?:[^*]|\*(?!\/))*(?:\*\/|$))*?(?:\?>|$)/g;t.languages["markup-templating"].buildPlaceholders(c,"php",d)}}),t.hooks.add("after-tokenize",function(c){t.languages["markup-templating"].tokenizePlaceholders(c,"php")})})(Prism);Prism.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:"keyword"}};Prism.languages.webmanifest=Prism.languages.json;(function(t){var n=/(?:\\.|[^\\\n\r]|(?:\n|\r\n?)(?![\r\n]))/.source;function s(u){return u=u.replace(/<inner>/g,function(){return n}),RegExp(/((?:^|[^\\])(?:\\{2})*)/.source+"(?:"+u+")")}var r=/(?:\\.|``(?:[^`\r\n]|`(?!`))+``|`[^`\r\n]+`|[^\\|\r\n`])+/.source,a=/\|?__(?:\|__)+\|?(?:(?:\n|\r\n?)|(?![\s\S]))/.source.replace(/__/g,function(){return r}),i=/\|?[ \t]*:?-{3,}:?[ \t]*(?:\|[ \t]*:?-{3,}:?[ \t]*)+\|?(?:\n|\r\n?)/.source;t.languages.markdown=t.languages.extend("markup",{}),t.languages.insertBefore("markdown","prolog",{"front-matter-block":{pattern:/(^(?:\s*[\r\n])?)---(?!.)[\s\S]*?[\r\n]---(?!.)/,lookbehind:!0,greedy:!0,inside:{punctuation:/^---|---$/,"front-matter":{pattern:/\S+(?:\s+\S+)*/,alias:["yaml","language-yaml"],inside:t.languages.yaml}}},blockquote:{pattern:/^>(?:[\t ]*>)*/m,alias:"punctuation"},table:{pattern:RegExp("^"+a+i+"(?:"+a+")*","m"),inside:{"table-data-rows":{pattern:RegExp("^("+a+i+")(?:"+a+")*$"),lookbehind:!0,inside:{"table-data":{pattern:RegExp(r),inside:t.languages.markdown},punctuation:/\|/}},"table-line":{pattern:RegExp("^("+a+")"+i+"$"),lookbehind:!0,inside:{punctuation:/\||:?-{3,}:?/}},"table-header-row":{pattern:RegExp("^"+a+"$"),inside:{"table-header":{pattern:RegExp(r),alias:"important",inside:t.languages.markdown},punctuation:/\|/}}}},code:[{pattern:/((?:^|\n)[ \t]*\n|(?:^|\r\n?)[ \t]*\r\n?)(?: {4}|\t).+(?:(?:\n|\r\n?)(?: {4}|\t).+)*/,lookbehind:!0,alias:"keyword"},{pattern:/^```[\s\S]*?^```$/m,greedy:!0,inside:{"code-block":{pattern:/^(```.*(?:\n|\r\n?))[\s\S]+?(?=(?:\n|\r\n?)^```$)/m,lookbehind:!0},"code-language":{pattern:/^(```).+/,lookbehind:!0},punctuation:/```/}}],title:[{pattern:/\S.*(?:\n|\r\n?)(?:==+|--+)(?=[ \t]*$)/m,alias:"important",inside:{punctuation:/==+$|--+$/}},{pattern:/(^\s*)#.+/m,lookbehind:!0,alias:"important",inside:{punctuation:/^#+|#+$/}}],hr:{pattern:/(^\s*)([*-])(?:[\t ]*\2){2,}(?=\s*$)/m,lookbehind:!0,alias:"punctuation"},list:{pattern:/(^\s*)(?:[*+-]|\d+\.)(?=[\t ].)/m,lookbehind:!0,alias:"punctuation"},"url-reference":{pattern:/!?\[[^\]]+\]:[\t ]+(?:\S+|<(?:\\.|[^>\\])+>)(?:[\t ]+(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\)))?/,inside:{variable:{pattern:/^(!?\[)[^\]]+/,lookbehind:!0},string:/(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\))$/,punctuation:/^[\[\]!:]|[<>]/},alias:"url"},bold:{pattern:s(/\b__(?:(?!_)<inner>|_(?:(?!_)<inner>)+_)+__\b|\*\*(?:(?!\*)<inner>|\*(?:(?!\*)<inner>)+\*)+\*\*/.source),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^..)[\s\S]+(?=..$)/,lookbehind:!0,inside:{}},punctuation:/\*\*|__/}},italic:{pattern:s(/\b_(?:(?!_)<inner>|__(?:(?!_)<inner>)+__)+_\b|\*(?:(?!\*)<inner>|\*\*(?:(?!\*)<inner>)+\*\*)+\*/.source),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^.)[\s\S]+(?=.$)/,lookbehind:!0,inside:{}},punctuation:/[*_]/}},strike:{pattern:s(/(~~?)(?:(?!~)<inner>)+\2/.source),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^~~?)[\s\S]+(?=\1$)/,lookbehind:!0,inside:{}},punctuation:/~~?/}},"code-snippet":{pattern:/(^|[^\\`])(?:``[^`\r\n]+(?:`[^`\r\n]+)*``(?!`)|`[^`\r\n]+`(?!`))/,lookbehind:!0,greedy:!0,alias:["code","keyword"]},url:{pattern:s(/!?\[(?:(?!\])<inner>)+\](?:\([^\s)]+(?:[\t ]+"(?:\\.|[^"\\])*")?\)|[ \t]?\[(?:(?!\])<inner>)+\])/.source),lookbehind:!0,greedy:!0,inside:{operator:/^!/,content:{pattern:/(^\[)[^\]]+(?=\])/,lookbehind:!0,inside:{}},variable:{pattern:/(^\][ \t]?\[)[^\]]+(?=\]$)/,lookbehind:!0},url:{pattern:/(^\]\()[^\s)]+/,lookbehind:!0},string:{pattern:/(^[ \t]+)"(?:\\.|[^"\\])*"(?=\)$)/,lookbehind:!0}}}}),["url","bold","italic","strike"].forEach(function(u){["url","bold","italic","strike","code-snippet"].forEach(function(p){u!==p&&(t.languages.markdown[u].inside.content.inside[p]=t.languages.markdown[p])})}),t.hooks.add("after-tokenize",function(u){if(u.language!=="markdown"&&u.language!=="md")return;function p(f){if(!(!f||typeof f=="string"))for(var g=0,y=f.length;g<y;g++){var h=f[g];if(h.type!=="code"){p(h.content);continue}var m=h.content[1],b=h.content[3];if(m&&b&&m.type==="code-language"&&b.type==="code-block"&&typeof m.content=="string"){var v=m.content.replace(/\b#/g,"sharp").replace(/\b\+\+/g,"pp");v=(/[a-z][\w-]*/i.exec(v)||[""])[0].toLowerCase();var k="language-"+v;b.alias?typeof b.alias=="string"?b.alias=[b.alias,k]:b.alias.push(k):b.alias=[k]}}}p(u.tokens)}),t.hooks.add("wrap",function(u){if(u.type==="code-block"){for(var p="",f=0,g=u.classes.length;f<g;f++){var y=u.classes[f],h=/language-(.+)/.exec(y);if(h){p=h[1];break}}var m=t.languages[p];if(m)u.content=t.highlight(d(u.content),m,p);else if(p&&p!=="none"&&t.plugins.autoloader){var b="md-"+new Date().valueOf()+"-"+Math.floor(Math.random()*1e16);u.attributes.id=b,t.plugins.autoloader.loadLanguages(p,function(){var v=document.getElementById(b);v&&(v.innerHTML=t.highlight(v.textContent,t.languages[p],p))})}}});var o=RegExp(t.languages.markup.tag.pattern.source,"gi"),l={amp:"&",lt:"<",gt:">",quot:'"'},c=String.fromCodePoint||String.fromCharCode;function d(u){var p=u.replace(o,"");return p=p.replace(/&(\w{1,8}|#x?[\da-f]{1,8});/gi,function(f,g){if(g=g.toLowerCase(),g[0]==="#"){var y;return g[1]==="x"?y=parseInt(g.slice(2),16):y=Number(g.slice(1)),c(y)}else{var h=l[g];return h||f}}),p}t.languages.md=t.languages.markdown})(Prism);(function(t){var n="\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b",s={pattern:/(^(["']?)\w+\2)[ \t]+\S.*/,lookbehind:!0,alias:"punctuation",inside:null},r={bash:s,environment:{pattern:RegExp("\\$"+n),alias:"constant"},variable:[{pattern:/\$?\(\([\s\S]+?\)\)/,greedy:!0,inside:{variable:[{pattern:/(^\$\(\([\s\S]+)\)\)/,lookbehind:!0},/^\$\(\(/],number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,operator:/--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,punctuation:/\(\(?|\)\)?|,|;/}},{pattern:/\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,greedy:!0,inside:{variable:/^\$\(|^`|\)$|`$/}},{pattern:/\$\{[^}]+\}/,greedy:!0,inside:{operator:/:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,punctuation:/[\[\]]/,environment:{pattern:RegExp("(\\{)"+n),lookbehind:!0,alias:"constant"}}},/\$(?:\w+|[#?*!@$])/],entity:/\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/};t.languages.bash={shebang:{pattern:/^#!\s*\/.*/,alias:"important"},comment:{pattern:/(^|[^"{\\$])#.*/,lookbehind:!0},"function-name":[{pattern:/(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,lookbehind:!0,alias:"function"},{pattern:/\b[\w-]+(?=\s*\(\s*\)\s*\{)/,alias:"function"}],"for-or-select":{pattern:/(\b(?:for|select)\s+)\w+(?=\s+in\s)/,alias:"variable",lookbehind:!0},"assign-left":{pattern:/(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,inside:{environment:{pattern:RegExp("(^|[\\s;|&]|[<>]\\()"+n),lookbehind:!0,alias:"constant"}},alias:"variable",lookbehind:!0},parameter:{pattern:/(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,alias:"variable",lookbehind:!0},string:[{pattern:/((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,lookbehind:!0,greedy:!0,inside:r},{pattern:/((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,lookbehind:!0,greedy:!0,inside:{bash:s}},{pattern:/(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,lookbehind:!0,greedy:!0,inside:r},{pattern:/(^|[^$\\])'[^']*'/,lookbehind:!0,greedy:!0},{pattern:/\$'(?:[^'\\]|\\[\s\S])*'/,greedy:!0,inside:{entity:r.entity}}],environment:{pattern:RegExp("\\$?"+n),alias:"constant"},variable:r.variable,function:{pattern:/(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,lookbehind:!0},keyword:{pattern:/(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,lookbehind:!0},builtin:{pattern:/(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,lookbehind:!0,alias:"class-name"},boolean:{pattern:/(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,lookbehind:!0},"file-descriptor":{pattern:/\B&\d\b/,alias:"important"},operator:{pattern:/\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,inside:{"file-descriptor":{pattern:/^\d/,alias:"important"}}},punctuation:/\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,number:{pattern:/(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,lookbehind:!0}},s.inside=t.languages.bash;for(var a=["comment","function-name","for-or-select","assign-left","parameter","string","environment","function","keyword","builtin","boolean","file-descriptor","operator","punctuation","number"],i=r.variable[1].inside,o=0;o<a.length;o++)i[a[o]]=t.languages.bash[a[o]];t.languages.sh=t.languages.bash,t.languages.shell=t.languages.bash})(Prism);var Bd=t=>t.replace(/[&<>]/g,n=>({"&":"&","<":"<",">":">"})[n]??n);function Kn(t,n){let s=ar.default.languages[n];if(!s)return t.split(`
|
|
10
|
-
`).map(
|
|
11
|
-
`?(a.push(o+"</span>".repeat(i.length)),o=i.join("")):c.startsWith("<span")?(i.push(c),o+=c):(c==="</span>"&&i.pop(),o+=c);return a.push(o+"</span>".repeat(i.length)),a}function Po({code:t,lang:n,symbols:s,highlight:r,scrollTo:a,onLine:i}){let o=Z(()=>Kn(t,n),[t,n]),l=Z(()=>{let u=new Map;for(let p of s??[])p.start_line&&!u.has(p.start_line)&&u.set(p.start_line,p);return u},[s]),c=u=>{let p;for(let f of s??[])f.start_line&&f.end_line&&f.start_line<=u&&f.end_line>=u&&(!p||f.end_line-f.start_line<p.end_line-p.start_line)&&(p=f);return p},d=ee(null);return J(()=>{if(!a||!d.current)return;let u=d.current.querySelector(`tr[data-l="${a}"]`);u&&u.scrollIntoView({block:"center"})},[a]),e("div",{class:"code",ref:d,children:e("table",{children:e("tbody",{children:o.map((u,p)=>{let f=p+1,g=l.get(f),y=r&&f>=r[0]&&f<=r[1];return e("tr",{"data-l":f,class:A(y&&"hl",g&&"sym"),children:[e("td",{class:"ln",onClick:()=>i?.(f,c(f)),title:g?`${g.kind} ${g.name}`:void 0,children:f}),e("td",{dangerouslySetInnerHTML:{__html:u||" "}})]})})})})})}function Jd(t){let n={name:"",path:"",dirs:new Map,files:[]};for(let s of t){let r=s.path.split("/"),a=n;for(let i of r.slice(0,-1)){let o=a.dirs.get(i);o||(o={name:i,path:a.path?`${a.path}/${i}`:i,dirs:new Map,files:[]},a.dirs.set(i,o)),a=o}a.files.push(s)}return n}function Oo({dir:t,depth:n,open:s,toggle:r,selected:a,onSelect:i,filter:o}){let l=[...t.dirs.values()].sort((u,p)=>u.name.localeCompare(p.name)),c=[...t.files].sort((u,p)=>u.path.localeCompare(p.path)),d={paddingLeft:`${8+n*14}px`};return e(j,{children:[l.map(u=>{let p=s.has(u.path)||!!o;return e(j,{children:[e("div",{class:"node",style:d,onClick:()=>r(u.path),children:[e("span",{class:"arrow",children:p?"\u25BE":"\u25B8"}),e("span",{class:"name",children:u.name})]}),p&&e(Oo,{dir:u,depth:n+1,open:s,toggle:r,selected:a,onSelect:i,filter:o})]})}),c.map(u=>e("div",{class:A("node",a===u.path&&"sel"),style:d,title:`${u.status}${u.reason?` (${u.reason})`:""} \xB7 ${u.symbols} symbols \xB7 ${u.loc} loc`,onClick:()=>i(u.path),children:[e("span",{class:"arrow"}),e("i",{class:A("st",u.status)}),e("span",{class:"name",children:_n(u.path)}),e("span",{class:A("heat",u.score>.6&&"hot"),children:u.score?u.score.toFixed(2):""})]}))]})}function Xd({files:t,selected:n,onSelect:s}){let[r,a]=_(""),[i,o]=_(()=>{let d=new Set;if(n){let u=n.split("/");for(let p=1;p<u.length;p++)d.add(u.slice(0,p).join("/"))}else{let u=new Map;for(let p of t){let f=p.path.split("/")[0];p.path.includes("/")&&u.set(f,(u.get(f)??0)+1)}for(let[p]of[...u].sort((f,g)=>g[1]-f[1]).slice(0,2))d.add(p)}return d});J(()=>{n&&o(d=>{let u=new Set(d),p=n.split("/");for(let f=1;f<p.length;f++)u.add(p.slice(0,f).join("/"));return u})},[n]);let l=Z(()=>{let d=r.trim().toLowerCase();return d?t.filter(u=>u.path.toLowerCase().includes(d)):t},[t,r]),c=Z(()=>Jd(l),[l]);return e("div",{class:"panel",children:[e("div",{class:"head",children:["explorer ",e("span",{class:"spacer"}),e("span",{children:[t.length," files"]})]}),e("div",{style:{padding:"6px 8px",borderBottom:"1px solid var(--line)"},children:e("input",{type:"search",placeholder:"filter files\u2026",style:{width:"100%"},value:r,onInput:d=>a(d.target.value)})}),e("div",{class:"body tree",children:e(Oo,{dir:c,depth:0,open:i,toggle:d=>o(u=>{let p=new Set(u);return p.has(d)?p.delete(d):p.add(d),p}),selected:n,onSelect:s,filter:r})})]})}function Do({title:t,rows:n,onPick:s}){return n.length?e("div",{class:"section",children:[e("h4",{children:[t," \xB7 ",n.length]}),e("table",{children:e("tbody",{children:n.slice(0,40).map(r=>e("tr",{class:"click",onClick:()=>s(r.node.id,r.node.path,r.node.line),children:[e("td",{children:e(P,{children:r.kind})}),e("td",{class:"break",children:[e(ye,{kind:r.node.kind})," ",r.node.label,r.node.path&&r.node.kind!=="file"?e("div",{class:"muted small",children:[r.node.path,r.lines?.length?` \xB7 L${r.lines.join(", L")}`:""]}):null]}),e("td",{class:"num muted",children:r.count??""})]}))})}),n.length>40?e("div",{class:"muted small",children:["\u2026 ",n.length-40," more"]}):null]}):null}function zd({file:t,impact:n,symbol:s,onPick:r}){return t?e("div",{class:"panel right",children:[e("div",{class:"head",children:[s?"code details":"file impact"," ",e("span",{class:"spacer"}),e("a",{onClick:()=>U("history",{file:t}),children:"history"}),e("a",{onClick:()=>U("galaxy",{node:s?s.node.id:`file:${t}`}),children:"open in Galaxy \u2192"})]}),e("div",{class:"body",children:s?e(j,{children:[e("div",{class:"section",children:[e("div",{class:"row tight",children:[e(ye,{kind:s.node.kind}),e("b",{class:"break",children:s.node.label})]}),e("div",{class:"muted small",children:[s.node.path,s.node.line?`:${s.node.line}`:"",s.node.exported?" \xB7 exported":""]}),s.metrics&&e("div",{class:"row small",style:{marginTop:6},children:[e(P,{children:["fan-in ",s.metrics.fan_in]}),e(P,{children:["fan-out ",s.metrics.fan_out]}),e(P,{children:["complexity ",s.metrics.complexity]}),e(P,{children:[s.metrics.loc," loc"]}),e(P,{children:["heat ",s.metrics.score.toFixed(2)]})]}),s.routes.length?e("div",{class:"small",style:{marginTop:6},children:["handles"," ",s.routes.map(a=>e("code",{children:a.label}))]}):null]}),e(Do,{title:"callers and references",rows:s.callers,onPick:r}),e(Do,{title:"calls and uses",rows:s.callees,onPick:r}),s.members.length?e("div",{class:"section",children:[e("h4",{children:["members \xB7 ",s.members.length]}),s.members.map(a=>e("div",{class:"small",children:e("a",{onClick:()=>r(a.id,a.path,a.line),children:[e(ye,{kind:a.kind}),a.label]})}))]}):null,s.memories.length?e("div",{class:"section",children:[e("h4",{children:"memories mentioning it"}),s.memories.map(a=>e("div",{class:"small",children:[e("a",{onClick:()=>U("memory",{name:a.name}),children:a.name})," ",e(P,{children:a.kind})]}))]}):null]}):n?e(j,{children:[e("div",{class:"section",children:[e("div",{class:"row small",children:[e(P,{children:[n.directDependents," direct dependents"]}),e(P,{children:[n.affected," affected files"]}),e(P,{children:[n.tests," test file",n.tests===1?"":"s"]}),e(P,{children:[n.coChanged.length," co-changed"]})]}),e("div",{class:"muted small",style:{marginTop:4},children:"Structural edges from the index plus git co-change history. Files outside the index are invisible here."})]}),n.graph.nodes.length>1&&e("div",{class:"section",style:{padding:0,height:240},children:e(We,{nodes:n.graph.nodes,edges:n.graph.edges,legend:!1,onActivate:a=>a.startsWith("file:")&&r(a,a.slice(5),null)})}),e("div",{class:"section",children:[e("h4",{children:["affected \xB7 ",n.hits.length]}),e("table",{children:e("tbody",{children:n.hits.map(a=>e("tr",{class:"click",onClick:()=>r(a.id,a.path,null),children:[e("td",{class:"break",children:[e(ye,{kind:a.kind}),a.label.replace(/^[a-z]+ /,""),e("div",{class:"muted small",children:a.reasons.join("; ")})]}),e("td",{class:"num muted",children:a.score.toFixed(2)})]}))})})]}),n.memories.length?e("div",{class:"section",children:[e("h4",{children:"memories"}),n.memories.map(a=>e("div",{class:"small",children:e("a",{onClick:()=>U("memory",{name:a}),children:a})}))]}):null]}):e("div",{class:"section",children:e(N,{})})})]}):e("div",{class:"panel right",children:e(B,{children:"Select a file to see what depends on it."})})}function No({params:t}){let n=t.file,s=t.line?Number(t.line):void 0,r=X(()=>O("/api/tree"),[]),a=X(()=>n?O("/api/file",{path:n}):Promise.resolve(void 0),[n]),i=X(()=>n?O("/api/file-impact",{path:n}):Promise.resolve(void 0),[n]),[o,l]=_(t.symbol??null);J(()=>l(t.symbol??null),[t.symbol,n]);let c=X(()=>o?O("/api/symbol",{id:o}):Promise.resolve(void 0),[o]),d=(y,h,m)=>U("explore",{file:y,line:h?String(h):void 0,symbol:m}),u=(y,h,m)=>{y.startsWith("file:")?d(y.slice(5)):h?d(h,m,y):U("galaxy",{node:y})},p=c.data&&o?c.data:void 0,f=a.data?.symbols.find(y=>y.id===o),g=a.data;return e(fa,{left:r.data?e(Xd,{files:r.data.files,selected:n,onSelect:y=>d(y)}):e("div",{class:"panel",children:e(B,{children:r.error??e(N,{})})}),center:e("div",{style:{height:"100%",display:"flex",flexDirection:"column"},children:[e("div",{class:"crumbs",children:[n?n.split("/").map((y,h,m)=>e(j,{children:[h>0&&e("span",{class:"sep",children:"\u203A"}),e("span",{class:h===m.length-1?"":"muted",children:y})]})):e("span",{class:"muted",children:"no file selected"}),e("span",{class:"spacer"}),g?.status&&g.status!=="indexed"?e("span",{class:"warn small",children:[g.status,g.reason?` \xB7 ${g.reason}`:""]}):null,g?e("span",{class:"muted small",children:[g.symbols.length," symbols \xB7 ",q(g.size??0)," B"]}):null,o?e("button",{type:"button",class:"sm",onClick:()=>l(null),children:"\u2190 file impact"}):null]}),e("div",{style:{flex:1,minHeight:0},children:n?a.error?e(W,{error:a.error}):g?g.tooLarge?e(B,{children:[g.path," is over the 1.5 MB limit and is not shown."]}):e(Po,{code:g.content??"",lang:ha(g.path),symbols:g.symbols,highlight:f?.start_line&&f.end_line?[f.start_line,f.end_line]:null,scrollTo:s??f?.start_line??null,onLine:(y,h)=>l(h?.id??null)}):e(B,{children:e(N,{})}):e(B,{children:"Pick a file in the explorer. Click a line number to inspect the symbol around it."})})]}),right:e(zd,{file:n,impact:i.data,symbol:p,onPick:u})})}var Gd=["imports","calls","references","extends","implements","handles","reexports"];function Wd({value:t,onPick:n}){let[s,r]=_(t),[a,i]=_([]),[o,l]=_(!1),[c,d]=_(0);J(()=>r(t),[t]);let u=ee(ma(async p=>{if(p.trim().length<2)return i([]);try{i(await O("/api/nodes/search",{q:p.trim(),limit:12})),l(!0),d(0)}catch{i([])}},180)).current;return e("div",{style:{position:"relative"},children:[e("input",{type:"text",placeholder:"search a file, symbol, route or memory\u2026",value:s,onInput:p=>{let f=p.target.value;r(f),u(f)},onFocus:()=>a.length&&l(!0),onBlur:()=>setTimeout(()=>l(!1),150),onKeyDown:p=>{if(p.key==="ArrowDown")d(f=>Math.min(a.length-1,f+1));else if(p.key==="ArrowUp")d(f=>Math.max(0,f-1));else if(p.key==="Enter"){let f=a[c];f&&(n(f),l(!1))}else p.key==="Escape"&&l(!1)}}),o&&a.length>0&&e("div",{class:"suggest",children:a.map((p,f)=>e("div",{class:A(f===c&&"on"),onMouseDown:()=>n(p),children:[e(ye,{kind:p.kind}),e("span",{class:"ellipsis",children:p.label}),p.path&&p.kind!=="file"?e("span",{class:"path",children:p.path}):null]}))})]})}function Uo({params:t}){let[n,s]=_({node:t.node??null,depth:1,direction:"both",kinds:Gd,mode:"galaxy"}),[r,a]=_({back:[],fwd:[]}),[i,o]=_(null),[l,c]=_(!1),[d,u]=_(null),[p,f]=_(""),[g,y]=_(),[h,m]=_(!0),[b,v]=_(!1),k=ee(null);J(()=>{t.node&&t.node!==n.node&&w({...n,node:t.node})},[t.node]);let w=(T,F=!0)=>{F&&a(H=>({back:[...H.back,n].slice(-30),fwd:[]})),s(T)};J(()=>{let T=!0;c(!0),y(void 0);let F=n.kinds.join(",")||"none";return(n.node?O("/api/graph",{mode:"expand",node:n.node,direction:n.direction,kinds:F,depth:n.depth,limit:400}):O("/api/graph",{mode:"map",kinds:F,limit:200})).then(K=>{T&&(o(K),u(K.root??null))}).catch(K=>T&&Y(K.message,!0)).finally(()=>T&&c(!1)),()=>{T=!1}},[n]);let S=T=>{v(!0),w({...n,node:T})},E=async()=>{if(!(!n.node||!p.trim()))try{let T=await O("/api/graph",{mode:"path",node:n.node,to:p.trim()});o(F=>{if(!F)return F;let H=new Set(F.nodes.map(R=>R.id)),K=new Set(F.edges.map(R=>`${R.src}|${R.dst}|${R.kind}`));return{...F,nodes:[...F.nodes,...T.nodes.filter(R=>!H.has(R.id))],edges:[...F.edges,...T.edges.filter(R=>!K.has(`${R.src}|${R.dst}|${R.kind}`))]}}),v(!0),y(new Set(T.edges.map(F=>`${F.src}|${F.dst}|${F.kind}`)))}catch(T){Y(T.message,!0)}},x=i?.nodes.find(T=>T.id===d),$=x?i.edges.filter(T=>T.dst===x.id):[],M=x?i.edges.filter(T=>T.src===x.id):[],I=T=>i?.nodes.find(F=>F.id===T)?.label??T,C=i?.nodes.filter(T=>T.kind==="file").length??0,L=T=>w({...n,kinds:n.kinds.includes(T)?n.kinds.filter(F=>F!==T):[...n.kinds,T]});return e("div",{style:{height:"100%",display:"flex",flexDirection:"column"},children:[e("div",{class:"gtoolbar",children:[e("button",{type:"button",class:"sm",disabled:!r.back.length,title:"back",onClick:()=>{let T=r.back[r.back.length-1];T&&(a(F=>({back:F.back.slice(0,-1),fwd:[n,...F.fwd]})),s(T))},children:"\u2190"}),e("button",{type:"button",class:"sm",disabled:!r.fwd.length,title:"forward",onClick:()=>{let T=r.fwd[0];T&&(a(F=>({back:[...F.back,n],fwd:F.fwd.slice(1)})),s(T))},children:"\u2192"}),e(Wd,{value:n.node??"",onPick:T=>w({...n,node:T.id})}),e("button",{type:"button",class:"sm",onClick:()=>w({...n,node:null}),title:"whole project (file map)",children:"All"}),e("select",{value:n.direction,disabled:!n.node,title:n.node?void 0:"pick a node to follow edges in one direction",onChange:T=>w({...n,direction:T.target.value}),children:[e("option",{value:"both",children:"Both directions"}),e("option",{value:"in",children:"Incoming (who uses it)"}),e("option",{value:"out",children:"Outgoing (what it uses)"})]}),e("span",{class:"row tight",children:[e("button",{type:"button",class:"sm",disabled:!n.node||n.depth<=1,onClick:()=>w({...n,depth:n.depth-1}),children:"\u2212"}),e("span",{class:"small nowrap",children:[n.depth," layer",n.depth===1?"":"s"]}),e("button",{type:"button",class:"sm",disabled:!n.node||n.depth>=4,onClick:()=>w({...n,depth:n.depth+1}),children:"+1"})]}),e("span",{class:"row tight",children:[e("input",{type:"text",placeholder:"path to\u2026",style:{width:160},value:p,onInput:T=>f(T.target.value),onKeyDown:T=>T.key==="Enter"&&E()}),e("button",{type:"button",class:"sm",onClick:E,disabled:!n.node,children:"Path"})]}),e("span",{class:"row tight",children:[e("button",{type:"button",class:A("chip",n.mode==="galaxy"&&"on"),onClick:()=>s({...n,mode:"galaxy"}),children:"galaxy"}),e("button",{type:"button",class:A("chip",n.mode==="hierarchy"&&"on"),onClick:()=>s({...n,mode:"hierarchy"}),children:"hierarchy"}),e("button",{type:"button",class:A("chip",h&&"on"),onClick:()=>m(!h),children:"legend"})]}),e("span",{class:"count",children:l?e(N,{}):i?`${i.nodes.length} nodes \xB7 ${i.edges.length} edges${i.truncated?" \xB7 truncated":""}${i.total&&i.total>C?` \xB7 top ${C} of ${i.total} files`:""}`:""})]}),e("div",{class:"gtoolbar",style:{paddingTop:4,paddingBottom:6},children:[e("span",{class:"muted small",children:"edges:"}),pa.map(T=>e("button",{type:"button",class:A("chip",n.kinds.includes(T)&&"on"),onClick:()=>L(T),children:T}))]}),e("div",{style:{flex:1,minHeight:0,display:"grid",gridTemplateColumns:x?"minmax(0,1fr) 340px":"1fr"},children:[e("div",{style:{minWidth:0},children:i?i.nodes.length?e(We,{nodes:i.nodes,edges:i.edges,mode:n.mode,selected:d,highlight:g,onSelect:u,onActivate:S,legend:h,handle:k,keepPositions:b}):e(B,{children:"The graph is empty. Run a reindex from System."}):e(B,{children:e(N,{})})}),x&&e("div",{class:"panel right",children:[e("div",{class:"head",children:["selection ",e("span",{class:"spacer"}),e("a",{onClick:()=>u(null),children:"close"})]}),e("div",{class:"body",children:[e("div",{class:"section",children:[e("div",{class:"row tight",children:[e(ye,{kind:x.kind}),e("b",{class:"break",children:x.label})]}),x.path&&x.kind!=="file"?e("div",{class:"muted small",children:[x.path,x.line?`:${x.line}`:""]}):null,e("div",{class:"row",style:{marginTop:8},children:[e("button",{type:"button",class:"sm primary",onClick:()=>S(x.id),children:"Expand from here"}),x.path?e("button",{type:"button",class:"sm",onClick:()=>U("explore",{file:x.path,line:x.line?String(x.line):void 0,symbol:x.kind==="file"?void 0:x.id}),children:"Open source"}):null,x.kind==="memory"?e("button",{type:"button",class:"sm",onClick:()=>U("memory",{name:x.label}),children:"Open memory"}):null]})]}),e("div",{class:"section",children:[e("h4",{children:["incoming \xB7 ",$.length]}),e("table",{children:e("tbody",{children:$.slice(0,60).map(T=>e("tr",{class:"click",onClick:()=>u(T.src),children:[e("td",{children:e(P,{children:T.kind})}),e("td",{class:"break",children:I(T.src)})]}))})})]}),e("div",{class:"section",children:[e("h4",{children:["outgoing \xB7 ",M.length]}),e("table",{children:e("tbody",{children:M.slice(0,60).map(T=>e("tr",{class:"click",onClick:()=>u(T.dst),children:[e("td",{children:e(P,{children:T.kind})}),e("td",{class:"break",children:I(T.dst)})]}))})})]})]})]})]})]})}var qd={branch:"hexagon",commit:"triangle",memory:"diamond",doc:"square"};function Vn(t){return t.missing?"ring":qd[t.kind]??"circle"}function Zn(t){let n=t;return n.kind==="commit"?dt(n.bucket??"other"):n.kind==="branch"?n.live||n.isDefault?"#64748b":"#9ca3af":n.kind==="memory"&&(n.status==="superseded"||n.status==="deprecated")?"#93c5fd":De(t.kind)}var Kd={contains:{color:"#64748b",width:1.2,alpha:.55,directed:!0},merged_into:{color:"#64748b",dash:[6,3],width:1.6,alpha:.6,directed:!0},touches:{color:"#94a3b8",width:.9,alpha:.4,directed:!0},records:{color:"#2563eb",dash:[2,3],width:1.2,alpha:.6,directed:!0},fixes:{color:"#e11d48",dash:[4,3],width:1.6,alpha:.75,directed:!0}};function ir(t){return Kd[t]??Zt(t)}var Vd=(t,n)=>t.length>n?`${t.slice(0,n-1)}\u2026`:t;function Ho(t){return t.kind==="commit"?Vd(t.label,32):t.kind==="file"?t.label.split("/").pop()??t.label:t.label}var Zd=["branch","commit","file","memory","doc"],Yd=["contains","merged_into","touches","fixes","records","mentions","documents"],Qd={contains:"a commit made on this branch",merged_into:"the branch was merged into the default branch",touches:"the commit changed this file",fixes:"a fix whose removed lines trace back to this commit",records:"the commit wrote or edited this memory",mentions:"a memory's related: header names this file",documents:"a doc source covers this file"},eu=[5,8,15,30],Bo=(t,n)=>[...t].sort((s,r)=>{let a=n.indexOf(s),i=n.indexOf(r);return(a===-1?99:a)-(i===-1?99:i)||s.localeCompare(r)});function Jo(t,n){let s=new Set(t);return s.has(n)?s.delete(n):s.add(n),s}function Xo({focus:t}){let[n,s]=_(null),[r,a]=_(!1),[i,o]=_(0),[l,c]=_(8),[d,u]=_(new Set),[p,f]=_(new Set),[g,y]=_(""),[h,m]=_(!1),[b,v]=_(t??null);J(()=>{let R=!0;return a(!0),O("/api/history/knowledge",{focus:t,branches:l,limit:400}).then(z=>{R&&(s(z),v(z.focus??null))}).catch(z=>R&&Y(z.message,!0)).finally(()=>R&&a(!1)),()=>{R=!1}},[t,l,i]);let k=Z(()=>{if(!n?.git)return null;let R=g?n.nodes.filter(z=>z.kind!=="commit"||z.root||z.bucket===g):n.nodes;return Xn({nodes:R,edges:n.edges},{hiddenKinds:d,hiddenEdges:p,status:"",category:"",hideSuperseded:!1})},[n,d,p,g]),w=n?.git?n.nodes:[],S=Z(()=>gt(w,R=>R.kind),[n]),E=Z(()=>gt(n?.edges??[],R=>R.kind),[n]),x=Z(()=>gt(w.filter(R=>R.kind==="commit"),R=>R.bucket??"other"),[n]),$=R=>w.find(z=>z.kind===R&&!z.missing),M=Z(()=>new Map(w.map(R=>[R.id,R])),[n]),I=b?M.get(b):void 0,C=k?.edges??[],L=I?C.filter(R=>R.dst===I.id):[],T=I?C.filter(R=>R.src===I.id):[],F=R=>{let z=M.get(R);return z?z.kind==="commit"?`${z.short} ${z.label}`:z.label:R},H=R=>U("history",{tab:"graph",focus:R}),K=n?.focus?M.get(n.focus):void 0;return n&&!n.git?e(B,{children:n.error??"Not a git repository."}):e("div",{class:"kgalaxy hgraph",children:[e("div",{class:"gtoolbar",children:[t?e("span",{class:"row tight",children:[e("span",{class:"muted small",children:"focused on"}),e("b",{class:"break",children:K?F(K.id):t}),e("button",{type:"button",class:"sm",onClick:()=>U("history",{tab:"graph"}),children:"Show all"})]}):e(j,{children:[e("span",{class:"muted small",children:"newest"}),e("select",{value:String(l),title:"feature branches drawn",onChange:R=>c(Number(R.target.value)),children:eu.map(R=>e("option",{value:String(R),children:R}))}),e("span",{class:"muted small",children:"branches, their commits and what they touched"})]}),e("select",{value:"",title:"focus a branch",onChange:R=>{let z=R.target.value;z&&H(`branch:${z}`)},children:[e("option",{value:"",children:"focus a branch\u2026"}),(n?.branches??[]).map(R=>e("option",{value:R.name,children:[R.name," (",R.commits,")",R.isDefault?" \xB7 default":R.merged?" \xB7 merged":"",R.live?"":" \xB7 deleted"]}))]}),x.size>1?e("select",{value:g,title:"commit kind",onChange:R=>y(R.target.value),children:[e("option",{value:"",children:"any commit kind"}),ct.filter(R=>x.has(R)).map(R=>e("option",{value:R,children:[R," (",x.get(R),")"]}))]}):null,e("button",{type:"button",class:A("chip",h&&"on"),onClick:()=>m(!h),children:"legend"}),e("button",{type:"button",class:"sm",title:"reload",onClick:()=>o(R=>R+1),children:"\u21BB"}),e("span",{class:"count",children:r?e(N,{}):k&&n?`${k.nodes.length} of ${w.length} nodes \xB7 ${k.edges.length} edges${n.truncated?` \xB7 first ${w.length} of ${n.total}`:""}`:""})]}),e("div",{class:"gtoolbar",style:{paddingTop:4,paddingBottom:6},children:[e("span",{class:"muted small",children:"nodes:"}),Bo([...S.keys()],Zd).map(R=>{let z=$(R);return e("button",{type:"button",class:A("chip",!d.has(R)&&"on"),onClick:()=>u(Jo(d,R)),children:[z?e(rt,{shape:Vn(z),color:Zn(z)}):null,R," ",S.get(R)]})}),e("span",{class:"muted small",style:{marginLeft:8},children:"edges:"}),Bo([...E.keys()],Yd).map(R=>{let z=ir(R);return e("button",{type:"button",title:Qd[R],class:A("chip",!p.has(R)&&"on"),onClick:()=>f(Jo(p,R)),children:[e(Mt,{color:z.color,dash:z.dash}),R," ",E.get(R)]})})]}),e("div",{class:"kbody",style:{gridTemplateColumns:I?"minmax(0,1fr) 320px":"minmax(0,1fr)"},children:[e("div",{style:{minWidth:0,minHeight:0},children:k?k.nodes.length?e(We,{nodes:k.nodes,edges:k.edges,selected:b,onSelect:v,onActivate:H,legend:h,colorOf:Zn,shapeOf:Vn,edgeStyleOf:ir,labelOf:Ho}):w.length?e(B,{children:"Nothing left after these filters."}):e(B,{children:"No commits to draw."}):e(B,{children:e(N,{})})}),I&&e("div",{class:"panel right",children:[e("div",{class:"head",children:["selection ",e("span",{class:"spacer"}),e("a",{onClick:()=>v(null),children:"close"})]}),e("div",{class:"body",children:[e(tu,{node:I,focus:n?.focus??void 0,onFocus:H}),e(jt,{title:"incoming",rows:L.map(R=>({kind:R.kind,id:R.src})),label:F,onPick:v}),e(jt,{title:"outgoing",rows:T.map(R=>({kind:R.kind,id:R.dst})),label:F,onPick:v})]})]})]})]})}function tu({node:t,focus:n,onFocus:s}){return e("div",{class:"section",children:[e("div",{class:"row tight",children:[e(rt,{shape:Vn(t),color:Zn(t)}),e(ye,{kind:t.kind}),e("b",{class:"break",children:t.kind==="commit"?t.short:t.label})]}),t.kind==="commit"?e("div",{style:{marginTop:4},children:t.label}):null,e("div",{class:"row tight wrap",style:{marginTop:4},children:[t.kind==="commit"&&t.sub?e("span",{class:"tag",style:{borderColor:dt(t.bucket??"other")},children:t.sub}):null,t.group==="memory"&&t.sub?e(P,{children:t.sub}):null,t.status?e("span",{class:`tag s-${t.status}`,children:t.status}):null,t.group==="doc"&&t.detail?e(P,{children:t.detail}):null,t.kind==="branch"?e(j,{children:[e(P,{children:[t.commits," own commits"]}),t.isDefault?e(P,{children:"default"}):t.merged?e(P,{children:"merged"}):e(P,{children:"open"}),t.live?null:e(P,{children:"ref deleted"}),(t.prs??[]).map(r=>e(P,{children:["#",r]}))]}):null,t.kind==="file"&&t.fixes?e(P,{children:[t.fixes," fixes"]}):null,t.risk?e(P,{children:["risk ",Math.round(t.risk*100),"%"]}):null]}),t.at?e("div",{class:"muted small",style:{marginTop:4},children:[t.author?`${t.author} \xB7 `:"",te(t.at)]}):null,t.missing?e("div",{class:"muted small",style:{marginTop:4},children:t.kind==="file"?"No longer in the working tree (deleted or renamed since).":"Nothing defines it any more (deleted or renamed)."}):null,e("div",{class:"row wrap",style:{marginTop:8},children:[t.id!==n?e("button",{type:"button",class:"sm primary",onClick:()=>s(t.id),children:"Focus here"}):null,t.kind==="commit"&&t.short?e("button",{type:"button",class:"sm",onClick:()=>U("history",{tab:"timeline",sha:t.id.slice(7)}),children:"Open commit"}):null,t.kind==="branch"&&t.live&&!t.isDefault?e("button",{type:"button",class:"sm",onClick:()=>U("history",{tab:"branches",branch:t.label}),children:"Branch detail"}):null,t.kind==="file"&&t.path?e("button",{type:"button",class:"sm",onClick:()=>U("history",{tab:"files",file:t.path}),children:"File history"}):null,t.kind==="file"&&t.path&&!t.missing?e("button",{type:"button",class:"sm",onClick:()=>U("explore",{file:t.path}),children:"Open source"}):null,t.group==="memory"&&!t.missing?e("button",{type:"button",class:"sm",onClick:()=>U("memory",{name:t.label}),children:"Open memory"}):null,t.group==="doc"&&!t.missing?e("button",{type:"button",class:"sm",onClick:()=>U("docs",{tab:"sources",name:t.label}),children:"Open doc source"}):null]})]})}function Yn({kind:t,bucket:n}){return e("span",{class:"tag kind",style:{color:dt(n)},children:t})}function zo({added:t,deleted:n}){let s=t+n,r=5,a=s?Math.round(t/s*r):0,i=s?Math.min(r-a,Math.round(n/s*r)):0;return e("span",{class:"pm",title:`+${t} / -${n}`,children:[e("span",{class:"add",children:["+",q(t)]}),e("span",{class:"del",children:["-",q(n)]}),e("span",{class:"bars",children:Array.from({length:r},(o,l)=>e("i",{class:l<a?"a":l<a+i?"d":""}))})]})}function Go({refs:t,tags:n,max:s=3}){let r=t.filter(a=>!a.startsWith("tag: "));return!r.length&&!n.length?null:e(j,{children:[n.slice(0,2).map(a=>e("span",{class:"ref tag",children:a})),r.slice(0,s).map(a=>e("span",{class:A("ref",a.includes("/")&&"remote"),children:a})),r.length>s?e("span",{class:"ref remote",children:["+",r.length-s]}):null]})}function nu({c:t}){return e(j,{children:[t.blamedBy?e("span",{class:"flag warn",title:`${t.blamedBy} later fix(es) removed lines from this commit`,children:["\u26A0 ",t.blamedBy]}):null,t.reverted?e("span",{class:"flag bad",title:"reverted",children:"\u21A9"}):null,t.origins&&(t.kind==="fix"||t.kind==="revert")?e("span",{class:"flag ok",title:`traced to ${t.origins} earlier commit(s)`,children:["\u21E0 ",t.origins]}):null,t.breaking?e("span",{class:"flag bad",children:"BREAKING"}):null]})}function Lt({value:t}){return e("span",{class:"riskbar",title:t.toFixed(2),children:e("i",{style:{width:`${Math.round(t*100)}%`,background:Ts(.3+t*.7)}})})}function at({v:t,k:n,sub:s}){return e("div",{class:"stat",children:[e("div",{class:"v",children:[t,s?e("small",{children:s}):null]}),e("div",{class:"k",children:n})]})}function It({commits:t,selected:n,onSelect:s,lanes:r,empty:a}){return t.length?e("div",{class:"commits",children:[r?e(Sa,{rows:r.rows,lanes:r.lanes,rowH:28,selected:n}):null,e("div",{class:"rows",children:t.map(o=>e("div",{class:A("crow",n===o.sha&&"sel",!o.onHead&&"off"),onClick:()=>s(o.sha),title:`${o.sha}
|
|
12
|
-
${
|
|
13
|
-
${
|
|
14
|
-
${
|
|
15
|
-
`);return e(j,{children:[e("div",{class:"diff",children:r.map(a=>e("div",{class:a.startsWith("+++")||a.startsWith("---")?"muted":a.startsWith("diff --git")?"file":a.startsWith("@@")?"hunk":a.startsWith("+")?"add":a.startsWith("-")?"del":"",children:a.startsWith("diff --git")?a.replace(/^diff --git a\/(.*) b\/.*$/,"$1"):a||" "}))}),s.data.truncated?e("div",{class:"muted small",children:"diff truncated"}):null]})}function ru({sha:t,onSelect:n}){let s=X(()=>O("/api/history/commit",{sha:t}),[t]),[r,a]=_(!1);if(J(()=>a(!1),[t]),s.error)return e(W,{error:s.error});if(!s.data)return e(N,{});if(s.data.error)return e(W,{error:s.data.error});let i=s.data,o=i.commit,l=Math.max(1,...i.files.map(c=>c.added+c.deleted));return e("div",{class:"stack",children:[e("div",{class:"card",children:[e("div",{class:"row tight",style:{flexWrap:"wrap"},children:[e(Yn,{kind:o.kind,bucket:o.bucket}),o.scope?e(P,{children:o.scope}):null,o.breaking?e(P,{class:"risk-high",children:"breaking"}):null,o.pr?e(P,{children:["PR #",o.pr]}):null,o.issues.map(c=>e(P,{children:c})),e(Go,{refs:o.refs,tags:o.tags,max:6}),e("span",{class:"spacer"}),e("span",{class:"mono small muted",title:o.sha,children:o.sha.slice(0,12)})]}),e("h3",{style:{marginTop:6},children:o.subject}),e("div",{class:"muted small",children:[o.author," <",o.email,"> \xB7 ",new Date(o.at).toLocaleString()," (",te(o.at),")",o.merge?" \xB7 merge":` \xB7 +${o.added}/-${o.deleted} in ${o.files} file${o.files===1?"":"s"} (${o.size})`,o.onHead?"":" \xB7 not reachable from HEAD"]}),o.body?e("div",{class:"msg",style:{marginTop:8},children:o.body}):null,o.riskReasons.length?e("div",{class:"row small",style:{marginTop:8,alignItems:"baseline"},children:[e(P,{class:o.risk>=.5?"risk-high":o.risk>=.3?"risk-medium":"risk-low",children:["hindsight ",o.risk.toFixed(2)]}),e("span",{class:"muted",children:o.riskReasons.join("; ")})]}):null,e("div",{class:"row",style:{marginTop:8},children:[e("button",{type:"button",class:"sm",onClick:()=>a(r===!1?null:!1),children:r===!1?"Show diff":"Hide diff"}),e("button",{type:"button",class:"sm",onClick:()=>U("history",{tab:"graph",focus:`commit:${o.sha}`}),children:"Graph"}),i.branches.length?e("span",{class:"muted small",children:["on ",i.branches.slice(0,5).join(", "),i.branches.length>5?` +${i.branches.length-5}`:""]}):null]})]}),i.blamedBy.length||i.origins.length||i.revertedBy?e("div",{class:"card",children:[e("h3",{children:"what history says"}),i.origins.length?e(j,{children:[e("div",{class:"muted small",style:{marginBottom:4},children:o.kind==="revert"?"reverts":"removed lines last written by (likely cause of the bug)"}),e("div",{class:"chain",children:i.origins.map(c=>e("div",{class:A("step","origin"),children:e(or,{l:c,onSelect:n})}))})]}):null,i.blamedBy.length?e(j,{children:[e("div",{class:"muted small",style:{margin:"6px 0 4px"},children:"later fixes that removed lines from this commit"}),e("div",{class:"chain",children:i.blamedBy.map(c=>e("div",{class:A("step","fix"),children:[e(or,{l:c,onSelect:n}),c.at?e("span",{class:"muted small",children:[Math.max(0,Math.round((c.at-o.at)/864e5)),"d later"]}):null]}))})]}):null,i.revertedBy?e(j,{children:[e("div",{class:"muted small",style:{margin:"6px 0 4px"},children:"reverted by"}),e("div",{class:"chain",children:e("div",{class:"step fix",children:e(or,{l:i.revertedBy,onSelect:n})})})]}):null]}):null,r!==!1?e("div",{class:"card",children:[e("div",{class:"row",style:{marginBottom:6},children:[e("h3",{style:{margin:0},children:["diff",r?` \xB7 ${r}`:""]}),r?e("button",{type:"button",class:"sm ghost",onClick:()=>a(null),children:"whole commit"}):null]}),e(su,{sha:o.sha,path:r??void 0})]}):null,i.files.length?e("div",{class:"card",children:[e("h3",{children:["files \xB7 ",i.files.length,e("span",{class:"muted small",style:{fontWeight:400,marginLeft:8},children:"symbols are listed when the file has not changed since this commit"})]}),e("div",{class:"cfiles",children:i.files.map(c=>e("div",{class:"cfile",children:[e("div",{class:"row tight",children:[e("a",{class:"ellipsis grow",title:c.path,onClick:()=>U("explore",{file:c.path}),children:c.path}),e(Qe,{value:c.added+c.deleted,max:l,width:44}),e(zo,{added:c.added,deleted:c.deleted})]}),e("div",{class:"row tight small",style:{flexWrap:"wrap"},children:[e("a",{class:"muted",onClick:()=>a(c.path),children:"diff"}),e("a",{class:"muted",onClick:()=>U("history",{tab:"files",file:c.path}),children:"history"}),c.renamedFrom?e("span",{class:"muted",children:["\u2190 ",c.renamedFrom]}):null,c.fileFixes?e("span",{class:"muted",title:`history risk ${c.fileRisk.toFixed(2)}`,children:[e(Lt,{value:c.fileRisk})," ",c.fileFixes," past fix",c.fileFixes===1?"":"es"]}):null,c.symbols.map(d=>e("a",{onClick:()=>U("explore",{file:c.path,symbol:d.id,line:d.line?String(d.line):void 0}),children:[e("span",{class:"muted",children:d.kind})," ",d.name]}))]})]}))})]}):null]})}function au({ov:t,params:n,selected:s,onSelect:r}){let[a,i]=_(new Set),[o,l]=_(null),[c,d]=_(n.q??""),[u,p]=_(""),[f,g]=_(n.path??""),[y,h]=_(!1),[m,b]=_(!1),[v,k]=_(150),w=t.buckets.filter(M=>!a.has(M)),S=X(()=>O("/api/history/commits",{buckets:a.size?w.join(","):void 0,q:c.trim()||void 0,author:u||void 0,path:f.trim()||void 0,since:o?new Date(o[0]).toISOString():void 0,until:o?new Date(o[1]).toISOString():void 0,risky:y?1:void 0,head:m?1:void 0,limit:v}),[a,c,u,f,o,y,m,v]),E=X(()=>O("/api/history/graph",{limit:400}),[t.head]),x=Z(()=>{if(!E.data||!S.data)return;let M=new Set(S.data.commits.map(C=>C.sha)),I=E.data.commits.slice(0,S.data.commits.length);if(!(I.length!==M.size||!I.every(C=>M.has(C.sha))))return $s(I)},[E.data,S.data]),$=Z(()=>{let M={};for(let I of t.weeks)for(let C of t.buckets)M[C]=(M[C]??0)+I.byBucket[C];return M},[t]);return e("div",{class:"grid wide",style:{alignItems:"start",gridTemplateColumns:"minmax(0, 1.4fr) minmax(320px, 1fr)"},children:[e("div",{class:"stack",children:[e("div",{class:"card",children:[e("div",{class:"row",style:{marginBottom:6,flexWrap:"wrap"},children:[e(xa,{counts:$,hidden:a,onToggle:M=>i(I=>{let C=new Set(I);return C.has(M)?C.delete(M):C.add(M),C})}),e("span",{class:"spacer"}),e("span",{class:"muted small",children:o?e(j,{children:[Te(o[0])," \u2192 ",Te(o[1])," ",e("a",{onClick:()=>l(null),children:"clear"})]}):"drag across the chart to focus a period"})]}),e(wa,{weeks:t.weeks,range:o,onRange:l,hidden:a})]}),e("div",{class:"card",children:[e("div",{class:"row",style:{flexWrap:"wrap",marginBottom:8},children:[e("input",{type:"search",placeholder:"search message, sha, issue\u2026",value:c,onInput:M=>d(M.target.value),style:{width:240}}),e("select",{value:u,onChange:M=>p(M.target.value),children:[e("option",{value:"",children:"everyone"}),t.authors.map(M=>e("option",{value:M.name,children:[M.name," (",M.commits,")"]}))]}),e("input",{type:"text",placeholder:"path prefix",value:f,onInput:M=>g(M.target.value),style:{width:180}}),e("button",{type:"button",class:A("chip",y&&"on"),onClick:()=>h(!y),title:"only commits later fixed, reverted, large or touching hotspots",children:"\u26A0 hindsight flags"}),e("button",{type:"button",class:A("chip",m&&"on"),onClick:()=>b(!m),children:"HEAD only"}),e("span",{class:"spacer"}),e("span",{class:"muted small",children:S.data?`${S.data.total} commits`:""})]}),S.error?e(W,{error:S.error}):S.data?e(j,{children:[e(It,{commits:S.data.commits,selected:s,onSelect:r,lanes:x}),S.data.total>S.data.commits.length?e("div",{class:"row",style:{marginTop:8},children:e("button",{type:"button",class:"sm",onClick:()=>k(M=>M+200),children:["show more (",S.data.total-S.data.commits.length," left)"]})}):null]}):e(N,{})]})]}),e("div",{class:"stack",children:s?e(ru,{sha:s,onSelect:r}):e(j,{children:[e("div",{class:"card",children:[e("h3",{children:"worth knowing"}),t.notable.length?e(It,{commits:t.notable,selected:null,onSelect:r}):e("div",{class:"muted small",children:"No commit stands out in hindsight."})]}),e("div",{class:"card",children:[e("h3",{children:"people"}),e("table",{children:e("tbody",{children:t.authors.slice(0,8).map(M=>e("tr",{class:"click",onClick:()=>p(M.name),children:[e("td",{children:M.name}),e("td",{class:"num",children:[e(Qe,{value:M.commits,max:t.authors[0]?.commits??1,width:70})," ",M.commits]}),e("td",{class:"muted small",children:[M.fixes," fixes \xB7 ",M.files," files"]}),e("td",{class:"muted small",children:te(M.lastAt)})]}))})})]}),t.tags.length?e("div",{class:"card",children:[e("h3",{children:"releases"}),e("div",{class:"row tight",style:{flexWrap:"wrap"},children:t.tags.slice(0,20).map(M=>e("a",{onClick:()=>r(M.sha),title:Te(M.at),children:e("span",{class:"ref tag",children:M.name})}))})]}):null]})})]})}function iu({ov:t,params:n,onSelectCommit:s}){let[r,a]=_(n.branch??null),[i,o]=_(!1),[l,c]=_(!0),d=X(()=>O("/api/history/graph",{limit:120}),[t.head]),u=X(()=>r?O("/api/history/branch",{name:r}):Promise.resolve(null),[r]),p=Z(()=>d.data?$s(d.data.commits):void 0,[d.data]),f=t.branches.filter(m=>(i||!m.remote)&&(l||!m.merged||m.isDefault)),g=Math.max(1,...f.map(m=>Math.max(m.ahead,m.behind))),[y,h]=_(null);return e("div",{class:"grid wide",style:{alignItems:"start",gridTemplateColumns:"minmax(0, 1fr) minmax(360px, 1fr)"},children:[e("div",{class:"card",children:[e("h3",{children:["commit graph"," ",e("span",{class:"muted small",children:["\xB7 latest ",d.data?.commits.length??""," across all branches"]})]}),d.error?e(W,{error:d.error}):d.data?e(It,{commits:d.data.commits,selected:y,onSelect:m=>{h(m),s(m)},lanes:p}):e(N,{})]}),e("div",{class:"stack",children:[e("div",{class:"card",children:[e("div",{class:"row",style:{marginBottom:6},children:[e("h3",{style:{margin:0},children:["branches \xB7 ",f.length]}),e("span",{class:"spacer"}),e("button",{type:"button",class:A("chip",i&&"on"),onClick:()=>o(!i),children:"remotes"}),e("button",{type:"button",class:A("chip",l&&"on"),onClick:()=>c(!l),children:"merged"})]}),e("table",{children:[e("thead",{children:e("tr",{children:[e("th",{children:"branch"}),e("th",{children:["vs ",t.base??"base"]}),e("th",{children:"last"})]})}),e("tbody",{children:f.map(m=>e("tr",{class:A("click",r===m.name&&"sel"),onClick:()=>a(m.name),children:[e("td",{class:"break",children:[e("span",{class:A("ref",m.remote&&"remote"),children:m.name}),m.current?e(P,{children:"current"}):null,m.isDefault?e(P,{children:"base"}):null,!m.merged&&!m.isDefault?e(P,{class:"risk-medium",children:"unmerged"}):null,m.lastSubject?e("div",{class:"muted small ellipsis",style:{maxWidth:260},children:m.lastSubject}):null]}),e("td",{children:m.isDefault?e("span",{class:"muted small",children:"\u2014"}):e("span",{class:"ab",title:`${m.ahead} ahead, ${m.behind} behind`,children:[e("span",{class:"ok",children:["+",m.ahead]}),e(Qe,{value:m.ahead,max:g,width:40}),e(Qe,{value:m.behind,max:g,width:40}),e("span",{class:"bad",children:["-",m.behind]})]})}),e("td",{class:"muted small nowrap",children:[te(m.at),m.lastAuthor?` \xB7 ${m.lastAuthor.split(" ")[0]}`:""]})]}))})]})]}),r?e("div",{class:"card",children:[e("h3",{children:r}),u.error?e(W,{error:u.error}):u.data?u.data.error?e(W,{error:u.data.error}):e(ou,{d:u.data,onSelect:m=>{h(m),s(m)}}):e(N,{})]}):e("div",{class:"card muted small",children:"Select a branch to see the commits only it has, the files they touch, and how bug-prone those files have been."})]})]})}function ou({d:t,onSelect:n}){let s=t.branch,r=t.files.filter(a=>a.risk>=.3);return e(j,{children:[e("div",{class:"row small",style:{flexWrap:"wrap"},children:[e(P,{children:["tip ",s.sha.slice(0,7)]}),e(P,{children:te(s.at)}),s.upstream?e(P,{children:["tracks ",s.upstream]}):null,s.isDefault?null:e(P,{class:s.merged?"s-accepted":"risk-medium",children:s.merged?"merged":`+${s.ahead} / -${s.behind}`}),e("span",{class:"spacer"}),e("button",{type:"button",class:"sm",onClick:()=>U("history",{tab:"graph",focus:`branch:${s.remote?s.name.replace(/^[^/]+\//,""):s.name}`}),children:"Graph"})]}),s.isDefault?e("div",{class:"muted small",style:{marginTop:6},children:"This is the base branch; other branches are compared against it."}):e(j,{children:[e("div",{class:"muted small",style:{margin:"8px 0 4px"},children:[t.commits.length," commit",t.commits.length===1?"":"s"," only on this branch"]}),e(It,{commits:t.commits,selected:null,onSelect:n,empty:"Nothing unique: the branch is fully merged or behind."}),t.files.length?e(j,{children:[e("div",{class:"muted small",style:{margin:"8px 0 4px"},children:["files touched ",r.length?`\xB7 ${r.length} with a fix-heavy history`:""]}),e("div",{class:"list",style:{maxHeight:220},children:t.files.map(a=>e("div",{class:"item",onClick:()=>U("history",{tab:"files",file:a.path}),children:e("div",{class:"p",children:[a.risk>=.3?e(Lt,{value:a.risk}):null," ",a.path,e("span",{class:"muted",children:[" ","\xB7 ",a.commits," commit",a.commits===1?"":"s",a.fixes?`, ${a.fixes} past fixes`:""]})]})}))})]}):null]})]})}function lu({params:t,onSelectCommit:n}){let[s,r]=_(""),[a,i]=_(t.file??null);J(()=>{t.file&&i(t.file)},[t.file]);let o=X(()=>O("/api/history/files",{path:s.trim()||void 0,limit:400}),[s]),{sorted:l,th:c}=nt(o.data?.files,"risk"),[d,u]=_(null);return e("div",{class:"grid wide",style:{alignItems:"start",gridTemplateColumns:"minmax(0, 1fr) minmax(360px, 1fr)"},children:[e("div",{class:"stack",children:[e("div",{class:"card",children:[e("div",{class:"row",style:{marginBottom:6},children:[e("h3",{style:{margin:0},children:"churn vs fix share"}),e("input",{type:"text",placeholder:"folder prefix, e.g. src/graph/",value:s,onInput:p=>r(p.target.value),style:{width:220}}),e("span",{class:"spacer"}),e("span",{class:"muted small",children:"size = lines changed \xB7 colour = history risk"})]}),o.data?e(_a,{files:o.data.files,selected:a,onSelect:i}):o.error?e(W,{error:o.error}):e(N,{})]}),e("div",{class:"card flush",children:e("table",{children:[e("thead",{children:e("tr",{children:[c("path","file"),c("commits","commits",!0),c("fixes","fixes",!0),c("bugOrigins","caused fixes",!0),c("commits90d","90d",!0),e("th",{children:"12 months"}),c("risk","risk",!0)]})}),e("tbody",{children:l.slice(0,150).map(p=>e("tr",{class:A("click",a===p.path&&"sel"),onClick:()=>i(p.path),children:[e("td",{class:"break",children:p.path}),e("td",{class:"num",children:p.commits}),e("td",{class:"num",children:p.fixes}),e("td",{class:"num",children:p.bugOrigins}),e("td",{class:"num",children:p.commits90d}),e("td",{children:e(Cs,{values:p.months})}),e("td",{class:"num",children:[e(Lt,{value:p.risk})," ",p.risk.toFixed(2)]})]}))})]})})]}),e("div",{class:"stack",children:a?e(cu,{path:a,selected:d,onSelect:p=>{u(p),n(p)}}):e("div",{class:"card muted small",children:"Pick a file to read its story: who changed it, what broke afterwards, and which fixes restored behaviour worth a test."})})]})}function cu({path:t,selected:n,onSelect:s}){let r=X(()=>O("/api/history/file",{path:t}),[t]);if(r.error)return e(W,{error:r.error});if(!r.data)return e(N,{});let a=r.data,i=a.file;return e(j,{children:[e("div",{class:"card",children:[e("h3",{class:"break",children:t}),i?e(j,{children:[e("div",{class:"row small",style:{flexWrap:"wrap"},children:[e(P,{children:[i.commits," commits"]}),e(P,{children:[i.fixes," fixes"]}),e(P,{children:["+",q(i.added),"/-",q(i.deleted)]}),e(P,{children:[Te(i.firstAt)," \u2192 ",Te(i.lastAt)]}),i.renamedFrom?e(P,{children:["from ",i.renamedFrom]}):null]}),e("div",{class:"row small",style:{marginTop:6,alignItems:"center"},children:[e(Lt,{value:i.risk}),e("span",{class:"muted",children:["history risk ",i.risk.toFixed(2),i.reasons.length?`: ${i.reasons.join("; ")}`:""]})]}),e("div",{class:"row small",style:{marginTop:6,flexWrap:"wrap"},children:[e("span",{class:"muted",children:"authors:"}),i.authors.map(([o,l])=>e(P,{children:[o," ",l]})),e("span",{class:"spacer"}),e(Cs,{values:i.months,width:120,height:22})]}),e("div",{class:"row",style:{marginTop:8},children:[e("button",{type:"button",class:"sm",onClick:()=>U("explore",{file:t}),children:"Open source"}),e("button",{type:"button",class:"sm",onClick:()=>U("galaxy",{node:`file:${t}`}),children:"Galaxy"}),e("button",{type:"button",class:"sm",onClick:()=>U("history",{tab:"graph",focus:`file:${t}`}),children:"History graph"})]})]}):e("div",{class:"muted small",children:"No commits in the loaded window touch this file."})]}),a.origins.length?e("div",{class:"card",children:[e("h3",{children:"changes that later needed fixing"}),e("div",{class:"chain",children:a.origins.map(o=>e("div",{class:"step origin",children:[e("a",{onClick:()=>s(o.sha),children:[e("span",{class:"mono muted small",children:o.short})," ",e(Yn,{kind:o.kind,bucket:o.bucket})," ",o.subject]}),e("span",{class:"muted small",children:[" \xB7 ",Te(o.at)]}),e("div",{class:"chain",style:{marginTop:2},children:o.fixes.map(l=>e("div",{class:"step fix",children:[e("a",{onClick:()=>s(l.sha),children:[e("span",{class:"mono muted small",children:l.short})," ",l.subject]}),e("span",{class:"muted small",children:[" \xB7 ",l.daysLater,"d later"]})]}))})]}))})]}):null,e("div",{class:"card",children:[e("h3",{children:["timeline \xB7 ",a.commits.length]}),e(It,{commits:a.commits,selected:n,onSelect:s})]})]})}function du({ov:t,onSelectCommit:n}){let s=X(()=>O("/api/history/risk"),[t.head,t.stats.workingTree]),[r,a]=_(""),i=X(()=>r.trim()?O("/api/history/risk",{paths:r.trim()}):Promise.resolve(null),[r]),o=r.trim()?i.data:s.data,l=X(()=>O("/api/history/commits",{risky:1,limit:40}).then(c=>c.commits.filter(d=>d.blamedBy||d.reverted)),[t.head]);return e("div",{class:"grid wide",style:{alignItems:"start"},children:[e("div",{class:"stack",children:[e("div",{class:"card",children:[e("div",{class:"row",style:{marginBottom:6},children:[e("h3",{style:{margin:0},children:r.trim()?"history risk for these paths":"working tree exposure"}),e("input",{type:"text",placeholder:"or paths, comma separated",value:r,onInput:c=>a(c.target.value),style:{width:300}})]}),e("div",{class:"muted small",style:{marginBottom:8},children:"What the past says about the files you are changing now: fix density, changes here that were later fixed, and the last fix to re-read before editing."}),o?o.files.length?e("table",{children:[e("thead",{children:e("tr",{children:[e("th",{children:"file"}),e("th",{children:"risk"}),e("th",{children:"history"})]})}),e("tbody",{children:[...o.files].sort((c,d)=>(d.file?.risk??-1)-(c.file?.risk??-1)).map(c=>e("tr",{children:[e("td",{class:"break",children:e("a",{onClick:()=>U("history",{tab:"files",file:c.path}),children:c.path})}),e("td",{class:"nowrap",children:c.file?e(j,{children:[e(Lt,{value:c.file.risk})," ",c.file.risk.toFixed(2)]}):e("span",{class:"muted small",children:"new"})}),e("td",{class:"small",children:c.file?e(j,{children:[e("div",{class:"muted",children:[c.file.commits," commits \xB7 ",c.file.fixes," fixes \xB7 last"," ",te(c.file.lastAt),c.file.reasons.length?` \xB7 ${c.file.reasons.join("; ")}`:""]}),c.lastFix?e("div",{children:["last fix: ",c.lastFix]}):null,c.origins.length?e("div",{children:["needed fixing before:"," ",c.origins.map(d=>e("a",{onClick:()=>n(d.sha),style:{marginRight:6},children:[d.short," ",d.subject.slice(0,40)]}))]}):null]}):e("span",{class:"muted",children:"no history yet"})})]}))})]}):e(B,{children:"Working tree is clean."}):s.error?e(W,{error:s.error}):e(N,{})]}),e("div",{class:"card",children:[e("h3",{children:"bug-prone files"}),t.risky.length?e("table",{children:e("tbody",{children:t.risky.map(c=>e("tr",{class:"click",onClick:()=>U("history",{tab:"files",file:c.path}),children:[e("td",{class:"break",children:c.path}),e("td",{class:"nowrap",children:[e(Lt,{value:c.risk})," ",c.risk.toFixed(2)]}),e("td",{class:"muted small",children:c.reasons.join("; ")||`${c.commits} commits`})]}))})}):e("div",{class:"muted small",children:"No file shows a fix pattern yet."})]})]}),e("div",{class:"stack",children:[e("div",{class:"card",children:[e("h3",{children:"lessons from this history"}),t.lessons.length?t.lessons.map(c=>e(uu,{text:c})):e("div",{class:"muted small",children:"Not enough history yet."}),t.stats.tracePending?e("div",{class:"muted small",style:{marginTop:6},children:[t.stats.tracePending," fixes still to trace; reload to continue."]}):null]}),e("div",{class:"card",children:[e("h3",{children:"changes that later needed fixing"}),e("div",{class:"muted small",style:{marginBottom:6},children:"A fix removed lines these commits wrote. The pattern, not the blame, is the lesson: what kind of change tends to break here?"}),l.data?e(It,{commits:l.data,selected:null,onSelect:n,empty:"No traced fix origins yet."}):e(N,{})]})]})]})}function uu({text:t}){return e("div",{class:"lesson",children:[e("span",{class:"i",children:"\u25C6"}),e("span",{children:t})]})}function Wo({params:t}){let[n,s]=_(t.tab||(t.file?"files":t.branch?"branches":"timeline")),[r,a]=_(t.sha??null);J(()=>{t.tab?s(t.tab):t.file?s("files"):t.branch&&s("branches")},[t.tab,t.file,t.branch]),J(()=>{t.sha&&a(t.sha)},[t.sha]);let i=X(()=>O("/api/history"),[]),o=u=>{a(u),s("timeline")};if(i.error)return e("div",{class:"page",children:e(W,{error:i.error})});if(!i.data)return e("div",{class:"page",children:e(N,{})});let l=i.data;if(!l.git)return e("div",{class:"page",children:e(B,{children:[l.error??"Not a git repository."," The history explorer reads `git log`; initialise a repository and commit to use it."]})});let c=l.stats,d=c.prior30?Math.round((c.last30-c.prior30)/c.prior30*100):null;return e("div",{class:"page",children:[e("div",{class:"hist-stats",children:[e(at,{v:c.commits,k:"commits",sub:`${c.onHead} on HEAD`}),e(at,{v:c.last30,k:"last 30 days",sub:d===null?`${c.prior30} in the 30 before`:`${d>=0?"+":""}${d}% vs prior 30`}),e(at,{v:c.fixes,k:"fixes",sub:`${Math.round(c.fixes/Math.max(1,c.commits-c.merges)*100)}%`}),e(at,{v:c.linksTraced,k:"traced fix origins",sub:c.tracePending?`${c.tracePending} pending`:`${c.fixesTraced} fixes`}),e(at,{v:c.branches,k:"branches",sub:c.unmerged?`${c.unmerged} unmerged`:"all merged"}),e(at,{v:c.authors,k:"authors",sub:`${c.files} files`}),e(at,{v:c.tags,k:"tags",sub:l.tags[0]?.name??""}),e(at,{v:c.workingTree,k:"working tree",sub:l.branch??"detached"})]}),e("div",{class:"row",style:{marginBottom:8},children:[e(Re,{tabs:[["timeline","Timeline"],["branches","Branches"],["files","Files"],["graph","Graph"],["risk","Risk & lessons"]],value:n,onChange:u=>{s(u),U("history",{tab:u,sha:r??void 0})}}),e("span",{class:"spacer"}),e("span",{class:"muted small",children:[l.branch??"detached"," @ ",l.head.slice(0,7)," \xB7 built ",te(l.builtAt)," ",e("a",{onClick:()=>O("/api/history",{refresh:1}).then(()=>i.reload()),children:"rebuild"})]})]}),n==="timeline"&&e(au,{ov:l,params:t,selected:r,onSelect:a}),n==="branches"&&e(iu,{ov:l,params:t,onSelectCommit:o}),n==="files"&&e(lu,{params:t,onSelectCommit:o}),n==="graph"&&e(Xo,{focus:t.focus}),n==="risk"&&e(du,{ov:l,onSelectCommit:o})]})}var pu=/^([a-z][a-z0-9+.-]*):(.*)$/i;function Yt(t){let n=t.trim();if(!n)return{kind:"text"};if(n.startsWith("#"))return{kind:"anchor",href:n};let s=pu.exec(n);if(!s){let i=n.replace(/^\.\//,"").split("#")[0]??"";return i?{kind:"file",file:i}:{kind:"text"}}let r=s[1].toLowerCase(),a=s[2];switch(r){case"mem":case"memory":return a?{kind:"memory",name:a}:{kind:"text"};case"file":case"sym":{let i=a.replace(/^\/+/,"").split("#")[0]??"";return i?{kind:"file",file:i}:{kind:"text"}}case"http":case"https":case"mailto":return{kind:"external",href:n};default:return{kind:"text"}}}function Qn(t){if(t.kind==="memory")return`#/memory?name=${encodeURIComponent(t.name)}`;if(t.kind==="file")return`#/explore?file=${encodeURIComponent(t.file)}`}function ur(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var kt=ur();function rl(t){kt=t}var bt={exec:()=>null};function Ft(t){let n=[];return s=>{let r=Math.max(0,Math.min(3,s-1)),a=n[r];return a||(a=t(r),n[r]=a),a}}function Q(t,n=""){let s=typeof t=="string"?t:t.source,r={replace:(a,i)=>{let o=typeof i=="string"?i:i.source;return o=o.replace(we.caret,"$1"),s=s.replace(a,o),r},getRegex:()=>new RegExp(s,n)};return r}var mu=((t="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+t)}catch{return!1}})(),we={codeRemoveIndent:/^(?: {0,3}\t| {1,4})/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,endingSpaceTabChar:/[ \t]$/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,leadingSpaceTab:/^[ \t]+/,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,numericCharacterReference:/&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));/,numericCharacterReferenceOrAmpersand:/&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:Ft(t=>new RegExp(`^ {0,${t}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:Ft(t=>new RegExp(`^ {0,${t}}((?:-[ ]*){3,}|(?:_[ ]*){3,}|(?:\\*[ ]*){3,})(?:\\n+|$)`)),fencesBeginRegex:Ft(t=>new RegExp(`^ {0,${t}}(?:\`\`\`|~~~)`)),headingBeginRegex:Ft(t=>new RegExp(`^ {0,${t}}#`)),htmlBeginRegex:Ft(t=>new RegExp(`^ {0,${t}}(?:</?(?:${nn})(?: +|$|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`,"i")),blockquoteBeginRegex:Ft(t=>new RegExp(`^ {0,${t}}>`))},hu=/^(?:[ \t]*(?:\n|$))+/,gu=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,fu=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,tn=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,bu=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,pr=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,al=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |fences|blockquote|heading|hr|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,il=Q(al).replace(/bull/g,pr).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/hr/g,/ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),vu=Q(al).replace(/bull/g,pr).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/hr/g,/ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),mr=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,yu=/^[^\n]+/,hr=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,ku=Q(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",hr).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),wu=Q(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,pr).getRegex(),nn="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",gr=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,xu=Q("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!(?:script|pre|style|textarea)(?![a-z0-9-]))([a-z][a-z0-9-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</[a-z][a-z0-9-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",gr).replace("tag",nn).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ol=t=>Q(mr).replace("hr",tn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list",t).replace("html"," {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)").replace("tag",nn).getRegex(),_u=ol(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),Su=ol(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),Eu=Q(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Su).getRegex(),fr={blockquote:Eu,code:gu,def:ku,fences:fu,heading:bu,hr:tn,html:xu,lheading:il,list:wu,newline:hu,paragraph:_u,table:bt,text:yu},qo=Q("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",tn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html"," {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)").replace("tag",nn).getRegex(),$u={...fr,lheading:vu,table:qo,paragraph:Q(mr).replace("hr",tn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",qo).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html"," {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)").replace("tag",nn).getRegex()},Tu={...fr,html:Q(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",gr).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:bt,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Q(mr).replace("hr",tn).replace("heading",` *#{1,6} *[^
|
|
16
|
-
]`).replace("lheading",
|
|
17
|
-
`),s=n.length-1;for(;s>=0&&
|
|
18
|
-
`)}function
|
|
19
|
-
`).map(
|
|
20
|
-
`)}function
|
|
21
|
-
`),depth:n[1].length,text:s,tokens:this.lexer.inline(s)}}}hr(t){let n=this.rules.block.hr.exec(t);if(n)return{type:"hr",raw:
|
|
22
|
-
`)}}blockquote(t){let n=this.rules.block.blockquote.exec(t);if(n){let s=
|
|
9
|
+
`)})}):null]})}var Da=Qu(Lc(),1);Prism.languages.javascript=Prism.languages.extend("clike",{"class-name":[Prism.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+(/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source)+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/});Prism.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/;Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:Prism.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:Prism.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/});Prism.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}});Prism.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}});Prism.languages.markup&&(Prism.languages.markup.tag.addInlined("script","javascript"),Prism.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript"));Prism.languages.js=Prism.languages.javascript;(function(t){t.languages.typescript=t.languages.extend("javascript",{"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|type)\s+)(?!keyof\b)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?:\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>)?/,lookbehind:!0,greedy:!0,inside:null},builtin:/\b(?:Array|Function|Promise|any|boolean|console|never|number|string|symbol|unknown)\b/}),t.languages.typescript.keyword.push(/\b(?:abstract|declare|is|keyof|readonly|require)\b/,/\b(?:asserts|infer|interface|module|namespace|type)\b(?=\s*(?:[{_$a-zA-Z\xA0-\uFFFF]|$))/,/\btype\b(?=\s*(?:[\{*]|$))/),delete t.languages.typescript.parameter,delete t.languages.typescript["literal-property"];var n=t.languages.extend("typescript",{});delete n["class-name"],t.languages.typescript["class-name"].inside=n,t.languages.insertBefore("typescript","function",{decorator:{pattern:/@[$\w\xA0-\uFFFF]+/,inside:{at:{pattern:/^@/,alias:"operator"},function:/^[\s\S]+/}},"generic-function":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>(?=\s*\()/,greedy:!0,inside:{function:/^#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*/,generic:{pattern:/<[\s\S]+/,alias:"class-name",inside:n}}}}),t.languages.ts=t.languages.typescript})(Prism);(function(t){var n=t.util.clone(t.languages.javascript),s=/(?:\s|\/\/.*(?!.)|\/\*(?:[^*]|\*(?!\/))\*\/)/.source,a=/(?:\{(?:\{(?:\{[^{}]*\}|[^{}])*\}|[^{}])*\})/.source,r=/(?:\{<S>*\.{3}(?:[^{}]|<BRACES>)*\})/.source;function o(c,u){return c=c.replace(/<S>/g,function(){return s}).replace(/<BRACES>/g,function(){return a}).replace(/<SPREAD>/g,function(){return r}),RegExp(c,u)}r=o(r).source,t.languages.jsx=t.languages.extend("markup",n),t.languages.jsx.tag.pattern=o(/<\/?(?:[\w.:-]+(?:<S>+(?:[\w.:$-]+(?:=(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|[^\s{'"/>=]+|<BRACES>))?|<SPREAD>))*<S>*\/?)?>/.source),t.languages.jsx.tag.inside.tag.pattern=/^<\/?[^\s>\/]*/,t.languages.jsx.tag.inside["attr-value"].pattern=/=(?!\{)(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|[^\s'">]+)/,t.languages.jsx.tag.inside.tag.inside["class-name"]=/^[A-Z]\w*(?:\.[A-Z]\w*)*$/,t.languages.jsx.tag.inside.comment=n.comment,t.languages.insertBefore("inside","attr-name",{spread:{pattern:o(/<SPREAD>/.source),inside:t.languages.jsx}},t.languages.jsx.tag),t.languages.insertBefore("inside","special-attr",{script:{pattern:o(/=<BRACES>/.source),alias:"language-javascript",inside:{"script-punctuation":{pattern:/^=(?=\{)/,alias:"punctuation"},rest:t.languages.jsx}}},t.languages.jsx.tag);var i=function(c){return c?typeof c=="string"?c:typeof c.content=="string"?c.content:c.content.map(i).join(""):""},l=function(c){for(var u=[],d=0;d<c.length;d++){var p=c[d],g=!1;if(typeof p!="string"&&(p.type==="tag"&&p.content[0]&&p.content[0].type==="tag"?p.content[0].content[0].content==="</"?u.length>0&&u[u.length-1].tagName===i(p.content[0].content[1])&&u.pop():p.content[p.content.length-1].content==="/>"||u.push({tagName:i(p.content[0].content[1]),openedBraces:0}):u.length>0&&p.type==="punctuation"&&p.content==="{"?u[u.length-1].openedBraces++:u.length>0&&u[u.length-1].openedBraces>0&&p.type==="punctuation"&&p.content==="}"?u[u.length-1].openedBraces--:g=!0),(g||typeof p=="string")&&u.length>0&&u[u.length-1].openedBraces===0){var h=i(p);d<c.length-1&&(typeof c[d+1]=="string"||c[d+1].type==="plain-text")&&(h+=i(c[d+1]),c.splice(d+1,1)),d>0&&(typeof c[d-1]=="string"||c[d-1].type==="plain-text")&&(h=i(c[d-1])+h,c.splice(d-1,1),d--),c[d]=new t.Token("plain-text",h,null,h)}p.content&&typeof p.content!="string"&&l(p.content)}};t.hooks.add("after-tokenize",function(c){c.language!=="jsx"&&c.language!=="tsx"||l(c.tokens)})})(Prism);(function(t){var n=t.util.clone(t.languages.typescript);t.languages.tsx=t.languages.extend("jsx",n),delete t.languages.tsx.parameter,delete t.languages.tsx["literal-property"];var s=t.languages.tsx.tag;s.pattern=RegExp(/(^|[^\w$]|(?=<\/))/.source+"(?:"+s.pattern.source+")",s.pattern.flags),s.lookbehind=!0})(Prism);Prism.languages.python={comment:{pattern:/(^|[^\\])#.*/,lookbehind:!0,greedy:!0},"string-interpolation":{pattern:/(?:f|fr|rf)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,greedy:!0,inside:{interpolation:{pattern:/((?:^|[^{])(?:\{\{)*)\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}])+\})+\})+\}/,lookbehind:!0,inside:{"format-spec":{pattern:/(:)[^:(){}]+(?=\}$)/,lookbehind:!0},"conversion-option":{pattern://,alias:"punctuation"},rest:null}},string:/[\s\S]+/}},"triple-quoted-string":{pattern:/(?:[rub]|br|rb)?("""|''')[\s\S]*?\1/i,greedy:!0,alias:"string"},string:{pattern:/(?:[rub]|br|rb)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i,greedy:!0},function:{pattern:/((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,lookbehind:!0},"class-name":{pattern:/(\bclass\s+)\w+/i,lookbehind:!0},decorator:{pattern:/(^[\t ]*)@\w+(?:\.\w+)*/m,lookbehind:!0,alias:["annotation","punctuation"],inside:{punctuation:/\./}},keyword:/\b(?:_(?=\s*:)|and|as|assert|async|await|break|case|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|match|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b/,builtin:/\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/,boolean:/\b(?:False|None|True)\b/,number:/\b0(?:b(?:_?[01])+|o(?:_?[0-7])+|x(?:_?[a-f0-9])+)\b|(?:\b\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\B\.\d+(?:_\d+)*)(?:e[+-]?\d+(?:_\d+)*)?j?(?!\w)/i,operator:/[-+%=]=?|!=|:=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,punctuation:/[{}[\];(),.:]/};Prism.languages.python["string-interpolation"].inside.interpolation.inside.rest=Prism.languages.python;Prism.languages.py=Prism.languages.python;Prism.languages.go=Prism.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,lookbehind:!0,greedy:!0},keyword:/\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,boolean:/\b(?:_|false|iota|nil|true)\b/,number:[/\b0(?:b[01_]+|o[0-7_]+)i?\b/i,/\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,/(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i],operator:/[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,builtin:/\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/});Prism.languages.insertBefore("go","string",{char:{pattern:/'(?:\\.|[^'\\\r\n]){0,10}'/,greedy:!0}});delete Prism.languages.go["class-name"];(function(t){function n(s,a){return"___"+s.toUpperCase()+a+"___"}Object.defineProperties(t.languages["markup-templating"]={},{buildPlaceholders:{value:function(s,a,r,o){if(s.language===a){var i=s.tokenStack=[];s.code=s.code.replace(r,function(l){if(typeof o=="function"&&!o(l))return l;for(var c=i.length,u;s.code.indexOf(u=n(a,c))!==-1;)++c;return i[c]=l,u}),s.grammar=t.languages.markup}}},tokenizePlaceholders:{value:function(s,a){if(s.language!==a||!s.tokenStack)return;s.grammar=t.languages[a];var r=0,o=Object.keys(s.tokenStack);function i(l){for(var c=0;c<l.length&&!(r>=o.length);c++){var u=l[c];if(typeof u=="string"||u.content&&typeof u.content=="string"){var d=o[r],p=s.tokenStack[d],g=typeof u=="string"?u:u.content,h=n(a,d),y=g.indexOf(h);if(y>-1){++r;var m=g.substring(0,y),f=new t.Token(a,t.tokenize(p,s.grammar),"language-"+a,p),v=g.substring(y+h.length),b=[];m&&b.push.apply(b,i([m])),b.push(f),v&&b.push.apply(b,i([v])),typeof u=="string"?l.splice.apply(l,[c,1].concat(b)):u.content=b}}else u.content&&i(u.content)}return l}i(s.tokens)}}})})(Prism);(function(t){var n=/\/\*[\s\S]*?\*\/|\/\/.*|#(?!\[).*/,s=[{pattern:/\b(?:false|true)\b/i,alias:"boolean"},{pattern:/(::\s*)\b[a-z_]\w*\b(?!\s*\()/i,greedy:!0,lookbehind:!0},{pattern:/(\b(?:case|const)\s+)\b[a-z_]\w*(?=\s*[;=])/i,greedy:!0,lookbehind:!0},/\b(?:null)\b/i,/\b[A-Z_][A-Z0-9_]*\b(?!\s*\()/],a=/\b0b[01]+(?:_[01]+)*\b|\b0o[0-7]+(?:_[0-7]+)*\b|\b0x[\da-f]+(?:_[\da-f]+)*\b|(?:\b\d+(?:_\d+)*\.?(?:\d+(?:_\d+)*)?|\B\.\d+)(?:e[+-]?\d+)?/i,r=/<?=>|\?\?=?|\.{3}|\??->|[!=]=?=?|::|\*\*=?|--|\+\+|&&|\|\||<<|>>|[?~]|[/^|%*&<>.+-]=?/,o=/[{}\[\](),:;]/;t.languages.php={delimiter:{pattern:/\?>$|^<\?(?:php(?=\s)|=)?/i,alias:"important"},comment:n,variable:/\$+(?:\w+\b|(?=\{))/,package:{pattern:/(namespace\s+|use\s+(?:function\s+)?)(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,lookbehind:!0,inside:{punctuation:/\\/}},"class-name-definition":{pattern:/(\b(?:class|enum|interface|trait)\s+)\b[a-z_]\w*(?!\\)\b/i,lookbehind:!0,alias:"class-name"},"function-definition":{pattern:/(\bfunction\s+)[a-z_]\w*(?=\s*\()/i,lookbehind:!0,alias:"function"},keyword:[{pattern:/(\(\s*)\b(?:array|bool|boolean|float|int|integer|object|string)\b(?=\s*\))/i,alias:"type-casting",greedy:!0,lookbehind:!0},{pattern:/([(,?]\s*)\b(?:array(?!\s*\()|bool|callable|(?:false|null)(?=\s*\|)|float|int|iterable|mixed|object|self|static|string)\b(?=\s*\$)/i,alias:"type-hint",greedy:!0,lookbehind:!0},{pattern:/(\)\s*:\s*(?:\?\s*)?)\b(?:array(?!\s*\()|bool|callable|(?:false|null)(?=\s*\|)|float|int|iterable|mixed|never|object|self|static|string|void)\b/i,alias:"return-type",greedy:!0,lookbehind:!0},{pattern:/\b(?:array(?!\s*\()|bool|float|int|iterable|mixed|object|string|void)\b/i,alias:"type-declaration",greedy:!0},{pattern:/(\|\s*)(?:false|null)\b|\b(?:false|null)(?=\s*\|)/i,alias:"type-declaration",greedy:!0,lookbehind:!0},{pattern:/\b(?:parent|self|static)(?=\s*::)/i,alias:"static-context",greedy:!0},{pattern:/(\byield\s+)from\b/i,lookbehind:!0},/\bclass\b/i,{pattern:/((?:^|[^\s>:]|(?:^|[^-])>|(?:^|[^:]):)\s*)\b(?:abstract|and|array|as|break|callable|case|catch|clone|const|continue|declare|default|die|do|echo|else|elseif|empty|enddeclare|endfor|endforeach|endif|endswitch|endwhile|enum|eval|exit|extends|final|finally|fn|for|foreach|function|global|goto|if|implements|include|include_once|instanceof|insteadof|interface|isset|list|match|namespace|never|new|or|parent|print|private|protected|public|readonly|require|require_once|return|self|static|switch|throw|trait|try|unset|use|var|while|xor|yield|__halt_compiler)\b/i,lookbehind:!0}],"argument-name":{pattern:/([(,]\s*)\b[a-z_]\w*(?=\s*:(?!:))/i,lookbehind:!0},"class-name":[{pattern:/(\b(?:extends|implements|instanceof|new(?!\s+self|\s+static))\s+|\bcatch\s*\()\b[a-z_]\w*(?!\\)\b/i,greedy:!0,lookbehind:!0},{pattern:/(\|\s*)\b[a-z_]\w*(?!\\)\b/i,greedy:!0,lookbehind:!0},{pattern:/\b[a-z_]\w*(?!\\)\b(?=\s*\|)/i,greedy:!0},{pattern:/(\|\s*)(?:\\?\b[a-z_]\w*)+\b/i,alias:"class-name-fully-qualified",greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}},{pattern:/(?:\\?\b[a-z_]\w*)+\b(?=\s*\|)/i,alias:"class-name-fully-qualified",greedy:!0,inside:{punctuation:/\\/}},{pattern:/(\b(?:extends|implements|instanceof|new(?!\s+self\b|\s+static\b))\s+|\bcatch\s*\()(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,alias:"class-name-fully-qualified",greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}},{pattern:/\b[a-z_]\w*(?=\s*\$)/i,alias:"type-declaration",greedy:!0},{pattern:/(?:\\?\b[a-z_]\w*)+(?=\s*\$)/i,alias:["class-name-fully-qualified","type-declaration"],greedy:!0,inside:{punctuation:/\\/}},{pattern:/\b[a-z_]\w*(?=\s*::)/i,alias:"static-context",greedy:!0},{pattern:/(?:\\?\b[a-z_]\w*)+(?=\s*::)/i,alias:["class-name-fully-qualified","static-context"],greedy:!0,inside:{punctuation:/\\/}},{pattern:/([(,?]\s*)[a-z_]\w*(?=\s*\$)/i,alias:"type-hint",greedy:!0,lookbehind:!0},{pattern:/([(,?]\s*)(?:\\?\b[a-z_]\w*)+(?=\s*\$)/i,alias:["class-name-fully-qualified","type-hint"],greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}},{pattern:/(\)\s*:\s*(?:\?\s*)?)\b[a-z_]\w*(?!\\)\b/i,alias:"return-type",greedy:!0,lookbehind:!0},{pattern:/(\)\s*:\s*(?:\?\s*)?)(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,alias:["class-name-fully-qualified","return-type"],greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}}],constant:s,function:{pattern:/(^|[^\\\w])\\?[a-z_](?:[\w\\]*\w)?(?=\s*\()/i,lookbehind:!0,inside:{punctuation:/\\/}},property:{pattern:/(->\s*)\w+/,lookbehind:!0},number:a,operator:r,punctuation:o};var i={pattern:/\{\$(?:\{(?:\{[^{}]+\}|[^{}]+)\}|[^{}])+\}|(^|[^\\{])\$+(?:\w+(?:\[[^\r\n\[\]]+\]|->\w+)?)/,lookbehind:!0,inside:t.languages.php},l=[{pattern:/<<<'([^']+)'[\r\n](?:.*[\r\n])*?\1;/,alias:"nowdoc-string",greedy:!0,inside:{delimiter:{pattern:/^<<<'[^']+'|[a-z_]\w*;$/i,alias:"symbol",inside:{punctuation:/^<<<'?|[';]$/}}}},{pattern:/<<<(?:"([^"]+)"[\r\n](?:.*[\r\n])*?\1;|([a-z_]\w*)[\r\n](?:.*[\r\n])*?\2;)/i,alias:"heredoc-string",greedy:!0,inside:{delimiter:{pattern:/^<<<(?:"[^"]+"|[a-z_]\w*)|[a-z_]\w*;$/i,alias:"symbol",inside:{punctuation:/^<<<"?|[";]$/}},interpolation:i}},{pattern:/`(?:\\[\s\S]|[^\\`])*`/,alias:"backtick-quoted-string",greedy:!0},{pattern:/'(?:\\[\s\S]|[^\\'])*'/,alias:"single-quoted-string",greedy:!0},{pattern:/"(?:\\[\s\S]|[^\\"])*"/,alias:"double-quoted-string",greedy:!0,inside:{interpolation:i}}];t.languages.insertBefore("php","variable",{string:l,attribute:{pattern:/#\[(?:[^"'\/#]|\/(?![*/])|\/\/.*$|#(?!\[).*$|\/\*(?:[^*]|\*(?!\/))*\*\/|"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*')+\](?=\s*[a-z$#])/im,greedy:!0,inside:{"attribute-content":{pattern:/^(#\[)[\s\S]+(?=\]$)/,lookbehind:!0,inside:{comment:n,string:l,"attribute-class-name":[{pattern:/([^:]|^)\b[a-z_]\w*(?!\\)\b/i,alias:"class-name",greedy:!0,lookbehind:!0},{pattern:/([^:]|^)(?:\\?\b[a-z_]\w*)+/i,alias:["class-name","class-name-fully-qualified"],greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}}],constant:s,number:a,operator:r,punctuation:o}},delimiter:{pattern:/^#\[|\]$/,alias:"punctuation"}}}}),t.hooks.add("before-tokenize",function(c){if(/<\?/.test(c.code)){var u=/<\?(?:[^"'/#]|\/(?![*/])|("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|(?:\/\/|#(?!\[))(?:[^?\n\r]|\?(?!>))*(?=$|\?>|[\r\n])|#\[|\/\*(?:[^*]|\*(?!\/))*(?:\*\/|$))*?(?:\?>|$)/g;t.languages["markup-templating"].buildPlaceholders(c,"php",u)}}),t.hooks.add("after-tokenize",function(c){t.languages["markup-templating"].tokenizePlaceholders(c,"php")})})(Prism);Prism.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:"keyword"}};Prism.languages.webmanifest=Prism.languages.json;(function(t){var n=/(?:\\.|[^\\\n\r]|(?:\n|\r\n?)(?![\r\n]))/.source;function s(d){return d=d.replace(/<inner>/g,function(){return n}),RegExp(/((?:^|[^\\])(?:\\{2})*)/.source+"(?:"+d+")")}var a=/(?:\\.|``(?:[^`\r\n]|`(?!`))+``|`[^`\r\n]+`|[^\\|\r\n`])+/.source,r=/\|?__(?:\|__)+\|?(?:(?:\n|\r\n?)|(?![\s\S]))/.source.replace(/__/g,function(){return a}),o=/\|?[ \t]*:?-{3,}:?[ \t]*(?:\|[ \t]*:?-{3,}:?[ \t]*)+\|?(?:\n|\r\n?)/.source;t.languages.markdown=t.languages.extend("markup",{}),t.languages.insertBefore("markdown","prolog",{"front-matter-block":{pattern:/(^(?:\s*[\r\n])?)---(?!.)[\s\S]*?[\r\n]---(?!.)/,lookbehind:!0,greedy:!0,inside:{punctuation:/^---|---$/,"front-matter":{pattern:/\S+(?:\s+\S+)*/,alias:["yaml","language-yaml"],inside:t.languages.yaml}}},blockquote:{pattern:/^>(?:[\t ]*>)*/m,alias:"punctuation"},table:{pattern:RegExp("^"+r+o+"(?:"+r+")*","m"),inside:{"table-data-rows":{pattern:RegExp("^("+r+o+")(?:"+r+")*$"),lookbehind:!0,inside:{"table-data":{pattern:RegExp(a),inside:t.languages.markdown},punctuation:/\|/}},"table-line":{pattern:RegExp("^("+r+")"+o+"$"),lookbehind:!0,inside:{punctuation:/\||:?-{3,}:?/}},"table-header-row":{pattern:RegExp("^"+r+"$"),inside:{"table-header":{pattern:RegExp(a),alias:"important",inside:t.languages.markdown},punctuation:/\|/}}}},code:[{pattern:/((?:^|\n)[ \t]*\n|(?:^|\r\n?)[ \t]*\r\n?)(?: {4}|\t).+(?:(?:\n|\r\n?)(?: {4}|\t).+)*/,lookbehind:!0,alias:"keyword"},{pattern:/^```[\s\S]*?^```$/m,greedy:!0,inside:{"code-block":{pattern:/^(```.*(?:\n|\r\n?))[\s\S]+?(?=(?:\n|\r\n?)^```$)/m,lookbehind:!0},"code-language":{pattern:/^(```).+/,lookbehind:!0},punctuation:/```/}}],title:[{pattern:/\S.*(?:\n|\r\n?)(?:==+|--+)(?=[ \t]*$)/m,alias:"important",inside:{punctuation:/==+$|--+$/}},{pattern:/(^\s*)#.+/m,lookbehind:!0,alias:"important",inside:{punctuation:/^#+|#+$/}}],hr:{pattern:/(^\s*)([*-])(?:[\t ]*\2){2,}(?=\s*$)/m,lookbehind:!0,alias:"punctuation"},list:{pattern:/(^\s*)(?:[*+-]|\d+\.)(?=[\t ].)/m,lookbehind:!0,alias:"punctuation"},"url-reference":{pattern:/!?\[[^\]]+\]:[\t ]+(?:\S+|<(?:\\.|[^>\\])+>)(?:[\t ]+(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\)))?/,inside:{variable:{pattern:/^(!?\[)[^\]]+/,lookbehind:!0},string:/(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\))$/,punctuation:/^[\[\]!:]|[<>]/},alias:"url"},bold:{pattern:s(/\b__(?:(?!_)<inner>|_(?:(?!_)<inner>)+_)+__\b|\*\*(?:(?!\*)<inner>|\*(?:(?!\*)<inner>)+\*)+\*\*/.source),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^..)[\s\S]+(?=..$)/,lookbehind:!0,inside:{}},punctuation:/\*\*|__/}},italic:{pattern:s(/\b_(?:(?!_)<inner>|__(?:(?!_)<inner>)+__)+_\b|\*(?:(?!\*)<inner>|\*\*(?:(?!\*)<inner>)+\*\*)+\*/.source),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^.)[\s\S]+(?=.$)/,lookbehind:!0,inside:{}},punctuation:/[*_]/}},strike:{pattern:s(/(~~?)(?:(?!~)<inner>)+\2/.source),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^~~?)[\s\S]+(?=\1$)/,lookbehind:!0,inside:{}},punctuation:/~~?/}},"code-snippet":{pattern:/(^|[^\\`])(?:``[^`\r\n]+(?:`[^`\r\n]+)*``(?!`)|`[^`\r\n]+`(?!`))/,lookbehind:!0,greedy:!0,alias:["code","keyword"]},url:{pattern:s(/!?\[(?:(?!\])<inner>)+\](?:\([^\s)]+(?:[\t ]+"(?:\\.|[^"\\])*")?\)|[ \t]?\[(?:(?!\])<inner>)+\])/.source),lookbehind:!0,greedy:!0,inside:{operator:/^!/,content:{pattern:/(^\[)[^\]]+(?=\])/,lookbehind:!0,inside:{}},variable:{pattern:/(^\][ \t]?\[)[^\]]+(?=\]$)/,lookbehind:!0},url:{pattern:/(^\]\()[^\s)]+/,lookbehind:!0},string:{pattern:/(^[ \t]+)"(?:\\.|[^"\\])*"(?=\)$)/,lookbehind:!0}}}}),["url","bold","italic","strike"].forEach(function(d){["url","bold","italic","strike","code-snippet"].forEach(function(p){d!==p&&(t.languages.markdown[d].inside.content.inside[p]=t.languages.markdown[p])})}),t.hooks.add("after-tokenize",function(d){if(d.language!=="markdown"&&d.language!=="md")return;function p(g){if(!(!g||typeof g=="string"))for(var h=0,y=g.length;h<y;h++){var m=g[h];if(m.type!=="code"){p(m.content);continue}var f=m.content[1],v=m.content[3];if(f&&v&&f.type==="code-language"&&v.type==="code-block"&&typeof f.content=="string"){var b=f.content.replace(/\b#/g,"sharp").replace(/\b\+\+/g,"pp");b=(/[a-z][\w-]*/i.exec(b)||[""])[0].toLowerCase();var w="language-"+b;v.alias?typeof v.alias=="string"?v.alias=[v.alias,w]:v.alias.push(w):v.alias=[w]}}}p(d.tokens)}),t.hooks.add("wrap",function(d){if(d.type==="code-block"){for(var p="",g=0,h=d.classes.length;g<h;g++){var y=d.classes[g],m=/language-(.+)/.exec(y);if(m){p=m[1];break}}var f=t.languages[p];if(f)d.content=t.highlight(u(d.content),f,p);else if(p&&p!=="none"&&t.plugins.autoloader){var v="md-"+new Date().valueOf()+"-"+Math.floor(Math.random()*1e16);d.attributes.id=v,t.plugins.autoloader.loadLanguages(p,function(){var b=document.getElementById(v);b&&(b.innerHTML=t.highlight(b.textContent,t.languages[p],p))})}}});var i=RegExp(t.languages.markup.tag.pattern.source,"gi"),l={amp:"&",lt:"<",gt:">",quot:'"'},c=String.fromCodePoint||String.fromCharCode;function u(d){var p=d.replace(i,"");return p=p.replace(/&(\w{1,8}|#x?[\da-f]{1,8});/gi,function(g,h){if(h=h.toLowerCase(),h[0]==="#"){var y;return h[1]==="x"?y=parseInt(h.slice(2),16):y=Number(h.slice(1)),c(y)}else{var m=l[h];return m||g}}),p}t.languages.md=t.languages.markdown})(Prism);(function(t){var n="\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b",s={pattern:/(^(["']?)\w+\2)[ \t]+\S.*/,lookbehind:!0,alias:"punctuation",inside:null},a={bash:s,environment:{pattern:RegExp("\\$"+n),alias:"constant"},variable:[{pattern:/\$?\(\([\s\S]+?\)\)/,greedy:!0,inside:{variable:[{pattern:/(^\$\(\([\s\S]+)\)\)/,lookbehind:!0},/^\$\(\(/],number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,operator:/--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,punctuation:/\(\(?|\)\)?|,|;/}},{pattern:/\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,greedy:!0,inside:{variable:/^\$\(|^`|\)$|`$/}},{pattern:/\$\{[^}]+\}/,greedy:!0,inside:{operator:/:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,punctuation:/[\[\]]/,environment:{pattern:RegExp("(\\{)"+n),lookbehind:!0,alias:"constant"}}},/\$(?:\w+|[#?*!@$])/],entity:/\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/};t.languages.bash={shebang:{pattern:/^#!\s*\/.*/,alias:"important"},comment:{pattern:/(^|[^"{\\$])#.*/,lookbehind:!0},"function-name":[{pattern:/(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,lookbehind:!0,alias:"function"},{pattern:/\b[\w-]+(?=\s*\(\s*\)\s*\{)/,alias:"function"}],"for-or-select":{pattern:/(\b(?:for|select)\s+)\w+(?=\s+in\s)/,alias:"variable",lookbehind:!0},"assign-left":{pattern:/(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,inside:{environment:{pattern:RegExp("(^|[\\s;|&]|[<>]\\()"+n),lookbehind:!0,alias:"constant"}},alias:"variable",lookbehind:!0},parameter:{pattern:/(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,alias:"variable",lookbehind:!0},string:[{pattern:/((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,lookbehind:!0,greedy:!0,inside:a},{pattern:/((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,lookbehind:!0,greedy:!0,inside:{bash:s}},{pattern:/(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,lookbehind:!0,greedy:!0,inside:a},{pattern:/(^|[^$\\])'[^']*'/,lookbehind:!0,greedy:!0},{pattern:/\$'(?:[^'\\]|\\[\s\S])*'/,greedy:!0,inside:{entity:a.entity}}],environment:{pattern:RegExp("\\$?"+n),alias:"constant"},variable:a.variable,function:{pattern:/(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,lookbehind:!0},keyword:{pattern:/(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,lookbehind:!0},builtin:{pattern:/(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,lookbehind:!0,alias:"class-name"},boolean:{pattern:/(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,lookbehind:!0},"file-descriptor":{pattern:/\B&\d\b/,alias:"important"},operator:{pattern:/\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,inside:{"file-descriptor":{pattern:/^\d/,alias:"important"}}},punctuation:/\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,number:{pattern:/(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,lookbehind:!0}},s.inside=t.languages.bash;for(var r=["comment","function-name","for-or-select","assign-left","parameter","string","environment","function","keyword","builtin","boolean","file-descriptor","operator","punctuation","number"],o=a.variable[1].inside,i=0;i<r.length;i++)o[r[i]]=t.languages.bash[r[i]];t.languages.sh=t.languages.bash,t.languages.shell=t.languages.bash})(Prism);var Xm=t=>t.replace(/[&<>]/g,n=>({"&":"&","<":"<",">":">"})[n]??n);function rr(t,n){let s=Da.default.languages[n];if(!s)return t.split(`
|
|
10
|
+
`).map(Xm);let a=Da.default.highlight(t,s,n),r=[],o=[],i="",l=a.split(/(<span[^>]*>|<\/span>|\n)/);for(let c of l)c===`
|
|
11
|
+
`?(r.push(i+"</span>".repeat(o.length)),i=o.join("")):c.startsWith("<span")?(o.push(c),i+=c):(c==="</span>"&&o.pop(),i+=c);return r.push(i+"</span>".repeat(o.length)),r}function jc({code:t,lang:n,symbols:s,highlight:a,scrollTo:r,onLine:o}){let i=ae(()=>rr(t,n),[t,n]),l=ae(()=>{let d=new Map;for(let p of s??[])p.start_line&&!d.has(p.start_line)&&d.set(p.start_line,p);return d},[s]),c=d=>{let p;for(let g of s??[])g.start_line&&g.end_line&&g.start_line<=d&&g.end_line>=d&&(!p||g.end_line-g.start_line<p.end_line-p.start_line)&&(p=g);return p},u=te(null);return U(()=>{if(!r||!u.current)return;let d=u.current.querySelector(`tr[data-l="${r}"]`);d&&d.scrollIntoView({block:"center"})},[r]),e("div",{class:"code",ref:u,children:e("table",{children:e("tbody",{children:i.map((d,p)=>{let g=p+1,h=l.get(g),y=a&&g>=a[0]&&g<=a[1];return e("tr",{"data-l":g,class:E(y&&"hl",h&&"sym"),children:[e("td",{class:"ln",onClick:()=>o?.(g,c(g)),title:h?`${h.kind} ${h.name}`:void 0,children:g}),e("td",{dangerouslySetInnerHTML:{__html:d||" "}})]})})})})})}function Gm(t){let n={name:"",path:"",dirs:new Map,files:[]};for(let s of t){let a=s.path.split("/"),r=n;for(let o of a.slice(0,-1)){let i=r.dirs.get(o);i||(i={name:o,path:r.path?`${r.path}/${o}`:o,dirs:new Map,files:[]},r.dirs.set(o,i)),r=i}r.files.push(s)}return n}function Ic({dir:t,depth:n,open:s,toggle:a,selected:r,onSelect:o,filter:i}){let l=[...t.dirs.values()].sort((d,p)=>d.name.localeCompare(p.name)),c=[...t.files].sort((d,p)=>d.path.localeCompare(p.path)),u={paddingLeft:`${8+n*14}px`};return e(R,{children:[l.map(d=>{let p=s.has(d.path)||!!i;return e(R,{children:[e("div",{class:"node",style:u,onClick:()=>a(d.path),children:[e("span",{class:"arrow",children:p?"\u25BE":"\u25B8"}),e("span",{class:"name",children:d.name})]}),p&&e(Ic,{dir:d,depth:n+1,open:s,toggle:a,selected:r,onSelect:o,filter:i})]})}),c.map(d=>e("div",{class:E("node",r===d.path&&"sel"),style:u,title:`${d.status}${d.reason?` (${d.reason})`:""} \xB7 ${d.symbols} symbols \xB7 ${d.loc} loc`,onClick:()=>o(d.path),children:[e("span",{class:"arrow"}),e("i",{class:E("st",d.status)}),e("span",{class:"name",children:wn(d.path)}),e("span",{class:E("heat",d.score>.6&&"hot"),children:d.score?d.score.toFixed(2):""})]}))]})}function Wm({files:t,selected:n,onSelect:s}){let[a,r]=x(""),[o,i]=x(()=>{let u=new Set;if(n){let d=n.split("/");for(let p=1;p<d.length;p++)u.add(d.slice(0,p).join("/"))}else{let d=new Map;for(let p of t){let g=p.path.split("/")[0];p.path.includes("/")&&d.set(g,(d.get(g)??0)+1)}for(let[p]of[...d].sort((g,h)=>h[1]-g[1]).slice(0,2))u.add(p)}return u});U(()=>{n&&i(u=>{let d=new Set(u),p=n.split("/");for(let g=1;g<p.length;g++)d.add(p.slice(0,g).join("/"));return d})},[n]);let l=ae(()=>{let u=a.trim().toLowerCase();return u?t.filter(d=>d.path.toLowerCase().includes(u)):t},[t,a]),c=ae(()=>Gm(l),[l]);return e("div",{class:"panel",children:[e("div",{class:"head",children:["explorer ",e("span",{class:"spacer"}),e("span",{children:[t.length," files"]})]}),e("div",{style:{padding:"6px 8px",borderBottom:"1px solid var(--line)"},children:e("input",{type:"search",placeholder:"filter files\u2026",style:{width:"100%"},value:a,onInput:u=>r(u.target.value)})}),e("div",{class:"body tree",children:e(Ic,{dir:c,depth:0,open:o,toggle:u=>i(d=>{let p=new Set(d);return p.has(u)?p.delete(u):p.add(u),p}),selected:n,onSelect:s,filter:a})})]})}function Pc({title:t,rows:n,onPick:s}){return n.length?e("div",{class:"section",children:[e("h4",{children:[t," \xB7 ",n.length]}),e("table",{children:e("tbody",{children:n.slice(0,40).map(a=>e("tr",{class:"click",onClick:()=>s(a.node.id,a.node.path,a.node.line),children:[e("td",{children:e(I,{children:a.kind})}),e("td",{class:"break",children:[e(Ie,{kind:a.node.kind})," ",a.node.label,a.node.path&&a.node.kind!=="file"?e("div",{class:"muted small",children:[a.node.path,a.lines?.length?` \xB7 L${a.lines.join(", L")}`:""]}):null]}),e("td",{class:"num muted",children:a.count??""})]}))})}),n.length>40?e("div",{class:"muted small",children:["\u2026 ",n.length-40," more"]}):null]}):null}function zm({file:t,impact:n,symbol:s,onPick:a}){return t?e("div",{class:"panel right",children:[e("div",{class:"head",children:[s?"code details":"file impact"," ",e("span",{class:"spacer"}),e("a",{onClick:()=>H("history",{file:t}),children:"history"}),e("a",{onClick:()=>H("galaxy",{node:s?s.node.id:`file:${t}`}),children:"open in Galaxy \u2192"})]}),e("div",{class:"body",children:s?e(R,{children:[e("div",{class:"section",children:[e("div",{class:"row tight",children:[e(Ie,{kind:s.node.kind}),e("b",{class:"break",children:s.node.label})]}),e("div",{class:"muted small",children:[s.node.path,s.node.line?`:${s.node.line}`:"",s.node.exported?" \xB7 exported":""]}),s.metrics&&e("div",{class:"row small",style:{marginTop:6},children:[e(I,{children:["fan-in ",s.metrics.fan_in]}),e(I,{children:["fan-out ",s.metrics.fan_out]}),e(I,{children:["complexity ",s.metrics.complexity]}),e(I,{children:[s.metrics.loc," loc"]}),e(I,{children:["heat ",s.metrics.score.toFixed(2)]})]}),s.routes.length?e("div",{class:"small",style:{marginTop:6},children:["handles"," ",s.routes.map(r=>e("code",{children:r.label}))]}):null]}),e(Pc,{title:"callers and references",rows:s.callers,onPick:a}),e(Pc,{title:"calls and uses",rows:s.callees,onPick:a}),s.members.length?e("div",{class:"section",children:[e("h4",{children:["members \xB7 ",s.members.length]}),s.members.map(r=>e("div",{class:"small",children:e("a",{onClick:()=>a(r.id,r.path,r.line),children:[e(Ie,{kind:r.kind}),r.label]})}))]}):null,s.memories.length?e("div",{class:"section",children:[e("h4",{children:"memories mentioning it"}),s.memories.map(r=>e("div",{class:"small",children:[e("a",{onClick:()=>H("memory",{name:r.name}),children:r.name})," ",e(I,{children:r.kind})]}))]}):null]}):n?e(R,{children:[e("div",{class:"section",children:[e("div",{class:"row small",children:[e(I,{children:[n.directDependents," direct dependents"]}),e(I,{children:[n.affected," affected files"]}),e(I,{children:[n.tests," test file",n.tests===1?"":"s"]}),e(I,{children:[n.coChanged.length," co-changed"]})]}),e("div",{class:"muted small",style:{marginTop:4},children:"Structural edges from the index plus git co-change history. Files outside the index are invisible here."})]}),n.graph.nodes.length>1&&e("div",{class:"section",style:{padding:0,height:240},children:e($t,{nodes:n.graph.nodes,edges:n.graph.edges,legend:!1,onActivate:r=>r.startsWith("file:")&&a(r,r.slice(5),null)})}),e("div",{class:"section",children:[e("h4",{children:["affected \xB7 ",n.hits.length]}),e("table",{children:e("tbody",{children:n.hits.map(r=>e("tr",{class:"click",onClick:()=>a(r.id,r.path,null),children:[e("td",{class:"break",children:[e(Ie,{kind:r.kind}),r.label.replace(/^[a-z]+ /,""),e("div",{class:"muted small",children:r.reasons.join("; ")})]}),e("td",{class:"num muted",children:r.score.toFixed(2)})]}))})})]}),n.memories.length?e("div",{class:"section",children:[e("h4",{children:"memories"}),n.memories.map(r=>e("div",{class:"small",children:e("a",{onClick:()=>H("memory",{name:r}),children:r})}))]}):null]}):e("div",{class:"section ws-skel","aria-busy":"true",children:[e(N,{h:14,w:"60%"}),e(N,{h:14}),e(N,{h:14,w:"80%"})]})})]}):e("div",{class:"panel right",children:e(X,{compact:!0,icon:"\u25C7",title:"No file selected",children:"Select a file to see what depends on it."})})}function Fc({params:t}){let n=t.file,s=t.line?Number(t.line):void 0,a=V(()=>J("/api/tree"),[]),r=V(()=>n?J("/api/file",{path:n}):Promise.resolve(void 0),[n]),o=V(()=>n?J("/api/file-impact",{path:n}):Promise.resolve(void 0),[n]),[i,l]=x(t.symbol??null);U(()=>l(t.symbol??null),[t.symbol,n]);let c=V(()=>i?J("/api/symbol",{id:i}):Promise.resolve(void 0),[i]),u=(y,m,f)=>H("explore",{file:y,line:m?String(m):void 0,symbol:f}),d=(y,m,f)=>{y.startsWith("file:")?u(y.slice(5)):m?u(m,f,y):H("galaxy",{node:y})},p=c.data&&i?c.data:void 0,g=r.data?.symbols.find(y=>y.id===i),h=r.data;return e("div",{class:"ws ws-explore",children:e(yi,{left:a.data?e(Wm,{files:a.data.files,selected:n,onSelect:y=>u(y)}):e("div",{class:"panel",children:a.error?e(X,{compact:!0,tone:"bad",icon:"!",title:"Could not load the file tree",children:a.error}):e("div",{class:"ws-skel","aria-busy":"true",children:[e(N,{h:14,w:"70%"}),e(N,{h:14}),e(N,{h:14,w:"85%"})]})}),center:e("div",{style:{height:"100%",display:"flex",flexDirection:"column"},children:[e("div",{class:"crumbs",children:[n?n.split("/").map((y,m,f)=>e(R,{children:[m>0&&e("span",{class:"sep",children:"\u203A"}),e("span",{class:m===f.length-1?"":"muted",children:y})]})):e("span",{class:"muted",children:"no file selected"}),e("span",{class:"spacer"}),h?.status&&h.status!=="indexed"?e(I,{tone:"warn",children:[h.status,h.reason?` \xB7 ${h.reason}`:""]}):null,h?e("span",{class:"muted small",children:[h.symbols.length," symbols \xB7 ",z(h.size??0)," B"]}):null,i?e("button",{type:"button",class:"sm",onClick:()=>l(null),children:"\u2190 file impact"}):null]}),e("div",{style:{flex:1,minHeight:0},children:n?r.error?e(Z,{error:r.error}):h?h.tooLarge?e(X,{icon:"\u2913",title:"File too large",children:[h.path," is over the 1.5 MB limit and is not shown."]}):e(jc,{code:h.content??"",lang:hi(h.path),symbols:h.symbols,highlight:g?.start_line&&g.end_line?[g.start_line,g.end_line]:null,scrollTo:s??g?.start_line??null,onLine:(y,m)=>l(m?.id??null)}):e("div",{class:"ws-skel","aria-busy":"true",children:[e(N,{h:14,w:"40%"}),e(N,{h:14}),e(N,{h:14,w:"90%"}),e(N,{h:14,w:"70%"})]}):e(X,{icon:"\u276F",title:"Pick a file",children:"Choose a file in the explorer. Click a line number to inspect the symbol around it."})})]}),right:e(zm,{file:n,impact:o.data,symbol:p,onPick:d})})})}function Oc({id:t,depth:n,onSelect:s,selected:a}){let r=V(()=>J("/api/behavior",{id:t}),[t]),[o,i]=x(new Set);if(r.error)return e("div",{class:"muted small",children:r.error});if(!r.data)return e(N,{h:24});let l=r.data;return e(R,{children:[n===0&&e("div",{class:E("bnode",a===l.root.id&&"sel"),onClick:()=>s(l),children:[e(I,{children:"start"}),e(Ie,{kind:l.root.kind}),e("b",{children:l.root.label}),e("span",{class:"muted small",children:l.root.path})]}),e("div",{class:"kids",children:l.callees.length?l.callees.map(c=>{let u=o.has(c.node.id);return e(R,{children:[e("div",{class:E("bnode",a===c.node.id&&"sel"),onClick:()=>s({root:c.node,callees:[]}),children:[e("span",{class:"arrow",onClick:d=>{d.stopPropagation(),i(p=>{let g=new Set(p);return g.has(c.node.id)?g.delete(c.node.id):g.add(c.node.id),g})},children:c.node.kind==="package"||c.node.kind==="route"?"\xB7":u?"\u25BE":"\u25B8"}),e(I,{children:c.kind==="handles"?"handles":"possible call"}),e(Ie,{kind:c.node.kind}),e("span",{children:c.node.label}),e("span",{class:"muted small",children:[c.lines?.length?`L${c.lines.join(", L")}`:"",c.count&&c.count>1?` \xD7${c.count}`:""]})]}),u&&n<6?e(Oc,{id:c.node.id,depth:n+1,onSelect:s,selected:a}):null]})}):e("div",{class:"muted small",style:{padding:"2px 6px"},children:"no resolved calls"})})]})}function Nc({params:t}){let[n,s]=x(t.node??null),[a,r]=x(""),[o,i]=x([]),[l,c]=x(null);return U(()=>{if(a.trim().length<2)return i([]);let u=setTimeout(()=>{J("/api/nodes/search",{q:a.trim(),limit:10}).then(d=>i(d.filter(p=>p.kind!=="file"&&p.kind!=="package"))).catch(()=>i([]))},180);return()=>clearTimeout(u)},[a]),e("div",{class:"ds-grid main-side",style:{alignItems:"start"},children:[e(j,{title:"Behavior",sub:"possible calls from one operation",children:[e("div",{class:"row",style:{marginBottom:10,position:"relative"},children:[e("span",{class:"muted small",children:"Start"}),e("input",{type:"text",placeholder:"function or method\u2026",value:a,onInput:u=>r(u.target.value),style:{width:320}}),o.length>0&&e("div",{class:"suggest",style:{top:36,left:40},children:o.map(u=>e("div",{onMouseDown:()=>{s(u.id),r(""),i([]),c(null)},children:[e(Ie,{kind:u.kind}),e("span",{class:"ellipsis",children:u.label}),e("span",{class:"path",children:u.path})]}))}),e("span",{class:"muted small",children:"Branches are possible static calls from the index, not an execution order."})]}),e("div",{class:"btree",children:n?e(Oc,{id:n,depth:0,onSelect:c,selected:l?.root.id??null}):e(X,{compact:!0,icon:"\u21B3",title:"Choose a starting operation",children:"Search a function or method above to follow its calls."})})]}),e(j,{title:l?"Selected operation":"Starting operation",children:l?e(R,{children:[e("div",{class:"row tight",children:[e(Ie,{kind:l.root.kind}),e("b",{class:"break",children:l.root.label})]}),e("div",{class:"muted small",children:[l.root.path,l.root.line?`:${l.root.line}`:"",l.root.endLine?`\u2013${l.root.endLine}`:""]}),l.root.complexity?e("div",{class:"row small",style:{marginTop:6},children:[e(I,{children:["complexity ",l.root.complexity]}),e(I,{children:[l.root.loc," loc"]})]}):null,e("div",{class:"row",style:{marginTop:8},children:[l.root.path?e("button",{type:"button",class:"sm",onClick:()=>H("explore",{file:l.root.path,line:l.root.line?String(l.root.line):void 0,symbol:l.root.id}),children:"Open definition"}):null,e("button",{type:"button",class:"sm",onClick:()=>{s(l.root.id),c(null)},children:"Start here"}),e("button",{type:"button",class:"sm",onClick:()=>H("galaxy",{node:l.root.id}),children:"Galaxy"})]})]}):e("div",{class:"muted small",children:"Click an operation in the tree."})})]})}function Bc(t,n,s,a,r){let o=t.reduce((y,m)=>y+(m.value??m.size),0);if(!o||!t.length)return[];let i=a*r/o,l=[],c=0,u=n,d=s,p=a,g=r,h=[...t].sort((y,m)=>(m.value??m.size)-(y.value??y.size));for(;c<h.length;){let y=p>=g,m=y?g:p,f=[],v=0,b=Number.POSITIVE_INFINITY;for(;c<h.length;){let C=h[c],S=(C.value??C.size)*i,_=[...f,C],T=v+S,M=Math.max(..._.map($=>($.value??$.size)*i)),F=Math.min(..._.map($=>($.value??$.size)*i)),D=Math.max(m*m*M/(T*T),T*T/(m*m*F));if(D>b&&f.length)break;b=D,f=_,v=T,c++}let w=m?v/m:0,k=0;for(let C of f){let S=w?(C.value??C.size)*i/w:0;l.push(y?{node:C,x:u,y:d+k,w,h:S,depth:0}:{node:C,x:u+k,y:d,w:S,h:w,depth:0}),k+=S}y?(u+=w,p-=w):(d+=w,g-=w)}return l}function Hc(t,n,s,a=18){let r=[];for(let o of Bc(t.children??[],0,0,n,s))if(r.push({...o,depth:0}),o.node.children?.length&&o.w>40&&o.h>30)for(let i of Bc(o.node.children,o.x+2,o.y+a,Math.max(0,o.w-4),Math.max(0,o.h-a-2)))r.push({...i,depth:1});return r}function Uc(t,n,s){let a={name:n||"(project)",path:n,size:0,children:[]},r=new Map([["",a]]),o=l=>{let c=r.get(l);if(c)return c;let u=o(l.includes("/")?l.slice(0,l.lastIndexOf("/")):""),d={name:l.split("/").pop()??l,path:l,size:0,children:[]};return u.children.push(d),r.set(l,d),d};for(let l of t){if(n&&!l.path.startsWith(n))continue;let c=n?l.path.slice(n.length).replace(/^\//,""):l.path,u=c.includes("/")?c.slice(0,c.lastIndexOf("/")):"",d=Math.max(1,s(l));o(u).children.push({name:c.split("/").pop()??c,path:l.path,size:d,data:l})}let i=l=>(l.children?.length&&(l.size=l.children.reduce((c,u)=>c+i(u),0)),l.size);return i(a),a}var Jc={typescript:"#2563eb",tsx:"#3b82f6",javascript:"#d97706",python:"#16a34a",go:"#0d9488",php:"#6366f1",other:"#6b7280"};function qm(t){let n=Math.max(0,Math.min(1,t)),s=Math.round(37+180*n),a=Math.round(99+20*n),r=Math.round(235+-229*n);return`rgb(${s},${a},${r})`}function Km({files:t,arch:n}){let[s,a]=x(""),[r,o]=x("language"),[i,l]=x("loc"),[c,u]=x(null),d=te(null),[p,g]=x({w:900,h:520});U(()=>{let b=d.current;if(!b)return;let w=new ResizeObserver(()=>g({w:b.clientWidth,h:b.clientHeight}));return w.observe(b),g({w:b.clientWidth,h:b.clientHeight}),()=>w.disconnect()},[]);let h=ae(()=>{let b=Uc(t,s,w=>i==="uniform"?1:w.loc||Math.max(1,w.size/40));return Hc(b,p.w,p.h)},[t,s,i,p]),m=c?(b=>t.filter(w=>w.path===b||w.path.startsWith(`${b}/`)))(c):[],f=m.length===1&&m[0]?.path===c?m[0]:void 0,v=n?.entryPoints.filter(b=>b.kind!=="script")??[];return e(R,{children:[n&&e(Re,{children:[e(le,{label:"files",value:z(n.overview.files)}),e(le,{label:"symbols",value:z(n.overview.symbols)}),e(le,{label:"edges",value:z(n.overview.edges)}),e(le,{label:"languages",value:Object.keys(n.overview.languages).length,sub:Object.entries(n.overview.languages).map(([b,w])=>`${b} ${w}`).join(" \xB7 ")})]}),e("div",{class:"ds-grid main-side",style:{alignItems:"start"},children:[e("div",{children:[e("div",{class:"row",style:{marginBottom:8},children:[e("span",{class:"row tight",children:[e("a",{onClick:()=>a(""),children:n?.project.name??"project"}),s.split("/").filter(Boolean).map((b,w,k)=>e(R,{children:[e("span",{class:"muted",children:"\u203A"}),e("a",{onClick:()=>a(k.slice(0,w+1).join("/")),children:b})]}))]}),e("span",{class:"spacer"}),e("span",{class:"row tight",children:[e("button",{type:"button",class:E("chip",i==="loc"&&"on"),onClick:()=>l("loc"),children:"size: loc"}),e("button",{type:"button",class:E("chip",i==="uniform"&&"on"),onClick:()=>l("uniform"),children:"uniform"}),e("button",{type:"button",class:E("chip",r==="language"&&"on"),onClick:()=>o("language"),children:"color: language"}),e("button",{type:"button",class:E("chip",r==="heat"&&"on"),onClick:()=>o("heat"),children:"heat"})]})]}),e("div",{class:"treemap",ref:d,children:h.map(b=>{let w=b.node.data,k=!!b.node.children?.length,C=w?r==="heat"?qm(w.score):Jc[w.language??"other"]??Jc.other:void 0;return e("div",{class:E("cell",k&&"dir",c===b.node.path&&"sel"),style:{left:b.x,top:b.y,width:Math.max(0,b.w),height:Math.max(0,b.h),background:C},title:w?`${w.path} \xB7 ${w.loc} loc \xB7 ${w.symbols} symbols \xB7 heat ${w.score.toFixed(2)}`:`${b.node.path} \xB7 ${b.node.size} loc`,onClick:S=>{S.stopPropagation(),u(b.node.path)},onDblClick:S=>{S.stopPropagation(),k?a(b.node.path):w&&H("explore",{file:w.path})},children:k?e("span",{class:"lbl",children:[b.node.name,"/"]}):b.w>50&&b.h>14?b.node.name:""})})}),e("div",{class:"muted small",style:{marginTop:6},children:"Area is lines of code (or uniform). Double-click a folder to open it, a file to read it. Heat mixes fan-in, recent commits and complexity; it is a signal, not a grade."})]}),e("div",{class:"stack",children:[e(j,{title:c??"Selection",children:f?e(R,{children:[e("div",{class:"row small",children:[e(I,{children:f.language??"?"}),e(I,{children:[f.loc," loc"]}),e(I,{children:[f.symbols," symbols"]}),e(I,{children:["fan-in ",f.fanIn]}),e(I,{children:["heat ",f.score.toFixed(2)]}),e(I,{children:f.status})]}),e("div",{class:"row",style:{marginTop:8},children:[e("button",{type:"button",class:"sm",onClick:()=>H("explore",{file:f.path}),children:"Open source"}),e("button",{type:"button",class:"sm",onClick:()=>H("galaxy",{node:`file:${f.path}`}),children:"Galaxy"})]})]}):m.length?e("div",{class:"row small",children:[e(I,{children:[m.length," files"]}),e(I,{children:[z(m.reduce((b,w)=>b+w.loc,0))," loc"]}),e(I,{children:[m.reduce((b,w)=>b+w.symbols,0)," symbols"]}),e(I,{children:["mean heat"," ",(m.reduce((b,w)=>b+w.score,0)/m.length).toFixed(2)]})]}):e("div",{class:"muted small",children:"Click a cell."})}),e(j,{title:"Entry points",flush:!0,children:v.length?e("table",{children:e("tbody",{children:v.map(b=>e("tr",{class:"click",onClick:()=>H("explore",{file:b.path}),children:[e("td",{children:e(I,{children:b.kind})}),e("td",{class:"break",children:b.name}),e("td",{class:"muted small break",children:b.path})]}))})}):e("div",{class:"muted small",style:{padding:"0 var(--space-3) var(--space-3)"},children:"none found"})}),n?.project.description?e(j,{title:"Project",children:e("div",{class:"muted small",children:n.project.description})}):null]})]})]})}function Xc(){let t=V(()=>J("/api/tree"),[]),n=V(()=>J("/api/architecture",{aspects:"overview,entry_points"}),[]);return t.error?e(Z,{error:t.error}):t.data?e(Km,{files:t.data.files,arch:n.data}):e(N,{h:320})}function Gc(){let[t,n]=x("file"),[s,a]=x(""),r=V(()=>J("/api/hotspots",{kind:t,path:s.trim()||void 0,limit:80}),[t,s]),{sorted:o,th:i}=Ot(r.data,"score"),l={fan_in:Math.max(1,...o.map(c=>c.fan_in)),commits_90d:Math.max(1,...o.map(c=>c.commits_90d)),complexity:Math.max(1,...o.map(c=>c.complexity))};return e(R,{children:[e("div",{class:"row",style:{marginBottom:10},children:[e("button",{type:"button",class:E("chip",t==="file"&&"on"),onClick:()=>n("file"),children:"files"}),e("button",{type:"button",class:E("chip",t==="symbol"&&"on"),onClick:()=>n("symbol"),children:"functions and classes"}),e("input",{type:"text",placeholder:"folder prefix, e.g. src/graph/",value:s,onInput:c=>a(c.target.value),style:{width:260}}),e("span",{class:"muted small",children:"Score = 0.4\xB7fan-in + 0.4\xB7commits/90d + 0.2\xB7complexity, log-scaled. A signal of where attention goes, not a quality grade."})]}),r.error?e(Z,{error:r.error}):r.data?o.length?e(j,{flush:!0,title:t==="file"?"Hot files":"Hot functions and classes",right:`${o.length}`,children:e("table",{children:[e("thead",{children:e("tr",{children:[i("path",t==="file"?"file":"symbol"),i("fan_in","fan-in",!0),i("commits_90d","commits/90d",!0),i("complexity","complexity",!0),i("loc","loc",!0),i("score","score",!0),e("th",{children:"last"})]})}),e("tbody",{children:o.map(c=>e("tr",{class:"click",onClick:()=>c.kind==="file"?H("explore",{file:c.path}):H("explore",{file:c.path.split(" > ")[0],symbol:c.id}),children:[e("td",{class:"break",children:[c.kind!=="file"?e(Ie,{kind:c.kind}):null,c.path]}),e("td",{class:"num",children:[e(Dt,{value:c.fan_in,max:l.fan_in,width:60})," ",c.fan_in]}),e("td",{class:"num",children:[e(Dt,{value:c.commits_90d,max:l.commits_90d,width:60})," ",c.commits_90d]}),e("td",{class:"num",children:[e(Dt,{value:c.complexity,max:l.complexity,width:60})," ",c.complexity]}),e("td",{class:"num",children:c.loc}),e("td",{class:"num",children:e("b",{children:c.score.toFixed(2)})}),e("td",{class:"muted small",children:c.last_touched})]}))})]})}):e(X,{icon:"\u2668",title:"No hotspots yet",children:"Run a reindex from System (or widen the folder prefix) and the most changed, most used code shows up here."}):e(N,{h:160})]})}function Wc(){let t=V(()=>J("/api/routes"),[]);return t.error?e(Z,{error:t.error}):t.data?t.data.length?e(j,{flush:!0,title:"Routes",right:`${t.data.length}`,children:e("table",{children:[e("thead",{children:e("tr",{children:[e("th",{children:"method"}),e("th",{children:"path"}),e("th",{children:"framework"}),e("th",{children:"handler"}),e("th",{children:"registered in"})]})}),e("tbody",{children:t.data.map(n=>e("tr",{children:[e("td",{children:e(I,{children:n.method})}),e("td",{class:"mono",children:n.path}),e("td",{class:"muted",children:n.framework}),e("td",{children:n.handlers.map(s=>e("div",{children:[e("a",{onClick:()=>s.path?H("explore",{file:s.path,symbol:s.id}):H("galaxy",{node:s.id}),children:s.name}),s.path?e("span",{class:"muted small",children:[" ",s.path]}):null]}))}),e("td",{class:"muted small",children:e("a",{onClick:()=>H("explore",{file:n.file,line:n.line?String(n.line):void 0}),children:[n.file,n.line?`:${n.line}`:""]})})]}))})]})}):e(X,{icon:"\u21B9",title:"No routes detected",children:"express/fastify/hono/koa/hapi/restify registrations, moleculer service schemas and gateway aliases, and Next.js route files are recognised."}):e(N,{h:160})}function zc(){let t=V(()=>J("/api/clusters"),[]),[n,s]=x(null),[a,r]=x(null),[o,i]=x(new Set),l=ae(()=>{let d=t.data;if(!d)return{nodes:[],edges:[]};let p=[],g=[];if(a!==null){let h=d.cycles[a]??[];for(let y of h)p.push({id:`file:${y}`,label:y,kind:"file",path:y,line:null});for(let y=0;y<h.length;y++)g.push({src:`file:${h[y]}`,dst:`file:${h[(y+1)%h.length]}`,kind:"imports",weight:1});return{nodes:p,edges:g}}for(let h of d.clusters){if(o.has(h.id))for(let y of d.members[String(h.id)]??[])p.push({id:`file:${y.path}`,label:y.path,kind:"file",path:y.path,line:null,score:y.score});if(p.push({id:`cluster:${h.id}`,label:`#${h.id} ${h.label} (${h.size})`,kind:"cluster",path:null,line:null}),o.has(h.id))for(let y of d.members[String(h.id)]??[])g.push({src:`file:${y.path}`,dst:`cluster:${h.id}`,kind:"link",weight:.5});for(let[y,m]of Object.entries(h.links))g.push({src:`cluster:${h.id}`,dst:`cluster:${y}`,kind:"imports",weight:Math.min(1,m/10),count:m})}return{nodes:p,edges:g}},[t.data,a,o]);if(t.error)return e(Z,{error:t.error});let c=t.data;if(!c)return e(N,{h:320});let u=n?.startsWith("cluster:")?c.clusters.find(d=>String(d.id)===n.slice(8)):void 0;return e("div",{class:"ds-grid main-side",style:{alignItems:"start"},children:[e(j,{flush:!0,class:"gt-canvas",children:l.nodes.length?e($t,{nodes:l.nodes,edges:l.edges,selected:n,onSelect:s,onActivate:d=>{if(d.startsWith("cluster:")){let p=Number(d.slice(8));i(g=>{let h=new Set(g);return h.has(p)?h.delete(p):h.add(p),h})}else d.startsWith("file:")&&H("explore",{file:d.slice(5)})}}):e(X,{icon:"\u2726",title:"No clusters yet",children:"Run a reindex from System and the connectivity groups show up here."})}),e("div",{class:"stack",children:[e(j,{title:"Clusters",right:String(c.clusters.length),children:[e("div",{class:"muted small",style:{marginBottom:6},children:"Connectivity groups from imports and co-change (label propagation). Double-click a cluster to expand its files; they are not proof of architectural boundaries."}),e("div",{class:"list",style:{maxHeight:260},children:c.clusters.map(d=>e("div",{class:E("item",n===`cluster:${d.id}`&&"sel"),onClick:()=>{r(null),s(`cluster:${d.id}`)},children:[e("div",{class:"n",children:["#",d.id," ",d.label," ",e("span",{class:"muted",children:["\xB7 ",d.size," files"]})]}),e("div",{class:"p",children:d.files.slice(0,3).join(", ")})]}))})]}),u&&e(j,{title:`Cluster #${u.id} members`,children:e("div",{class:"list",style:{maxHeight:220},children:(c.members[String(u.id)]??[]).map(d=>e("div",{class:"item",onClick:()=>H("explore",{file:d.path}),children:e("div",{class:"p",children:[d.path," ",e("span",{class:"muted",children:["\xB7 heat ",d.score.toFixed(2)]})]})}))})}),e(j,{title:"Import cycles",right:String(c.cycles.length),children:[c.cycles.length?e("div",{class:"list",style:{maxHeight:220},children:c.cycles.map((d,p)=>e("div",{class:E("item",a===p&&"sel"),onClick:()=>{r(a===p?null:p),s(null)},children:e("div",{class:"p",children:[d.length," files: ",d.slice(0,4).join(" \u2192 "),d.length>4?" \u2026":""]})}))}):e("div",{class:"muted small",children:"none"}),a!==null?e("button",{type:"button",class:"sm",style:{marginTop:6},onClick:()=>r(null),children:"show clusters"}):null]})]})]})}var Vm=["imports","calls","references","extends","implements","handles","reexports"];function Ym({value:t,onPick:n}){let[s,a]=x(t),[r,o]=x([]),[i,l]=x(!1),[c,u]=x(0);U(()=>a(t),[t]);let d=te(gi(async p=>{if(p.trim().length<2)return o([]);try{o(await J("/api/nodes/search",{q:p.trim(),limit:12})),l(!0),u(0)}catch{o([])}},180)).current;return e("div",{style:{position:"relative"},children:[e("input",{type:"text",placeholder:"search a file, symbol, route or memory\u2026",value:s,onInput:p=>{let g=p.target.value;a(g),d(g)},onFocus:()=>r.length&&l(!0),onBlur:()=>setTimeout(()=>l(!1),150),onKeyDown:p=>{if(p.key==="ArrowDown")u(g=>Math.min(r.length-1,g+1));else if(p.key==="ArrowUp")u(g=>Math.max(0,g-1));else if(p.key==="Enter"){let g=r[c];g&&(n(g),l(!1))}else p.key==="Escape"&&l(!1)}}),i&&r.length>0&&e("div",{class:"suggest",children:r.map((p,g)=>e("div",{class:E(g===c&&"on"),onMouseDown:()=>n(p),children:[e(Ie,{kind:p.kind}),e("span",{class:"ellipsis",children:p.label}),p.path&&p.kind!=="file"?e("span",{class:"path",children:p.path}):null]}))})]})}function Zm({params:t,mode:n}){let[s,a]=x({node:t.node??null,depth:1,direction:"both",kinds:Vm}),[r,o]=x({back:[],fwd:[]}),[i,l]=x(null),[c,u]=x(!1),[d,p]=x(null),[g,h]=x(0),[y,m]=x(null),[f,v]=x(""),[b,w]=x(),[k,C]=x(!0),[S,_]=x(!1),T=te(null);U(()=>{t.node&&t.node!==s.node&&M({...s,node:t.node})},[t.node]);let M=(A,W=!0)=>{W&&o(ye=>({back:[...ye.back,s].slice(-30),fwd:[]})),a(A)};U(()=>{let A=!0;u(!0),p(null),w(void 0);let W=s.kinds.join(",")||"none";return(s.node?J("/api/graph",{mode:"expand",node:s.node,direction:s.direction,kinds:W,depth:s.depth,limit:400}):J("/api/graph",{mode:"map",kinds:W,limit:200})).then(B=>{A&&(l(B),m(B.root??null))}).catch(B=>A&&p(B.message)).finally(()=>A&&u(!1)),()=>{A=!1}},[s,g]);let F=A=>{_(!0),M({...s,node:A})},D=async()=>{if(!(!s.node||!f.trim()))try{let A=await J("/api/graph",{mode:"path",node:s.node,to:f.trim()});l(W=>{if(!W)return W;let ye=new Set(W.nodes.map(re=>re.id)),B=new Set(W.edges.map(re=>`${re.src}|${re.dst}|${re.kind}`));return{...W,nodes:[...W.nodes,...A.nodes.filter(re=>!ye.has(re.id))],edges:[...W.edges,...A.edges.filter(re=>!B.has(`${re.src}|${re.dst}|${re.kind}`))]}}),_(!0),w(new Set(A.edges.map(W=>`${W.src}|${W.dst}|${W.kind}`)))}catch(A){ee(A.message,!0)}},$=i?.nodes.find(A=>A.id===y),L=$?i.edges.filter(A=>A.dst===$.id):[],K=$?i.edges.filter(A=>A.src===$.id):[],Y=A=>i?.nodes.find(W=>W.id===A)?.label??A,ne=i?.nodes.filter(A=>A.kind==="file").length??0,O=A=>M({...s,kinds:s.kinds.includes(A)?s.kinds.filter(W=>W!==A):[...s.kinds,A]});return e("div",{class:"ws-graph-pane",children:[e("div",{class:"gtoolbar",children:[e("button",{type:"button",class:"sm",disabled:!r.back.length,title:"back",onClick:()=>{let A=r.back[r.back.length-1];A&&(o(W=>({back:W.back.slice(0,-1),fwd:[s,...W.fwd]})),a(A))},children:"\u2190"}),e("button",{type:"button",class:"sm",disabled:!r.fwd.length,title:"forward",onClick:()=>{let A=r.fwd[0];A&&(o(W=>({back:[...W.back,s],fwd:W.fwd.slice(1)})),a(A))},children:"\u2192"}),e(Ym,{value:s.node??"",onPick:A=>M({...s,node:A.id})}),e("button",{type:"button",class:"sm",onClick:()=>M({...s,node:null}),title:"whole project (file map)",children:"All"}),e("select",{value:s.direction,disabled:!s.node,title:s.node?void 0:"pick a node to follow edges in one direction",onChange:A=>M({...s,direction:A.target.value}),children:[e("option",{value:"both",children:"Both directions"}),e("option",{value:"in",children:"Incoming (who uses it)"}),e("option",{value:"out",children:"Outgoing (what it uses)"})]}),e("span",{class:"row tight",children:[e("button",{type:"button",class:"sm",disabled:!s.node||s.depth<=1,onClick:()=>M({...s,depth:s.depth-1}),children:"\u2212"}),e("span",{class:"small nowrap",children:[s.depth," layer",s.depth===1?"":"s"]}),e("button",{type:"button",class:"sm",disabled:!s.node||s.depth>=4,onClick:()=>M({...s,depth:s.depth+1}),children:"+1"})]}),e("span",{class:"row tight",children:[e("input",{type:"text",placeholder:"path to\u2026",style:{width:160},value:f,onInput:A=>v(A.target.value),onKeyDown:A=>A.key==="Enter"&&D()}),e("button",{type:"button",class:"sm",onClick:D,disabled:!s.node,children:"Path"})]}),e("span",{class:"row tight",children:e("button",{type:"button",class:E("chip",k&&"on"),onClick:()=>C(!k),children:"legend"})}),e("span",{class:"count",children:c?e(se,{}):i?`${i.nodes.length} nodes \xB7 ${i.edges.length} edges${i.truncated?" \xB7 truncated":""}${i.total&&i.total>ne?` \xB7 top ${ne} of ${i.total} files`:""}`:""})]}),e("div",{class:"gtoolbar",style:{paddingTop:4,paddingBottom:6},children:[e("span",{class:"muted small",children:"edges:"}),mi.map(A=>e("button",{type:"button",class:E("chip",s.kinds.includes(A)&&"on"),onClick:()=>O(A),children:A}))]}),e("div",{class:"ws-body",style:{gridTemplateColumns:$?"minmax(0,1fr) 340px":"1fr"},children:[e("div",{style:{minWidth:0},children:d?e(Z,{error:d,onRetry:()=>h(A=>A+1)}):i?i.nodes.length?e($t,{nodes:i.nodes,edges:i.edges,mode:n,selected:y,highlight:b,onSelect:m,onActivate:F,legend:k,handle:T,keepPositions:S}):e(X,{icon:"\u2726",title:"The graph is empty",children:"Run a reindex from System and the code graph shows up here."}):e("div",{class:"ws-skel","aria-busy":"true",children:e(N,{h:180})})}),$&&e("div",{class:"panel right",children:[e("div",{class:"head",children:["selection ",e("span",{class:"spacer"}),e("a",{onClick:()=>m(null),children:"close"})]}),e("div",{class:"body",children:[e("div",{class:"section",children:[e("div",{class:"row tight",children:[e(Ie,{kind:$.kind}),e("b",{class:"break",children:$.label})]}),$.path&&$.kind!=="file"?e("div",{class:"muted small",children:[$.path,$.line?`:${$.line}`:""]}):null,e("div",{class:"row",style:{marginTop:8},children:[e("button",{type:"button",class:"sm primary",onClick:()=>F($.id),children:"Expand from here"}),$.path?e("button",{type:"button",class:"sm",onClick:()=>H("explore",{file:$.path,line:$.line?String($.line):void 0,symbol:$.kind==="file"?void 0:$.id}),children:"Open source"}):null,$.kind==="memory"?e("button",{type:"button",class:"sm",onClick:()=>H("memory",{name:$.label}),children:"Open memory"}):null]})]}),e("div",{class:"section",children:[e("h4",{children:["incoming \xB7 ",L.length]}),e("table",{children:e("tbody",{children:L.slice(0,60).map(A=>e("tr",{class:"click",onClick:()=>m(A.src),children:[e("td",{children:e(I,{children:A.kind})}),e("td",{class:"break",children:Y(A.src)})]}))})})]}),e("div",{class:"section",children:[e("h4",{children:["outgoing \xB7 ",K.length]}),e("table",{children:e("tbody",{children:K.slice(0,60).map(A=>e("tr",{class:"click",onClick:()=>m(A.dst),children:[e("td",{children:e(I,{children:A.kind})}),e("td",{class:"break",children:Y(A.dst)})]}))})})]})]})]})]})]})}var qc="eminiar.galaxy.tab",Qm=[{id:"galaxy",label:"Galaxy",title:"force-directed code graph"},{id:"hierarchy",label:"Hierarchy",title:"layered code graph"},{id:"map",label:"Folder map",title:"treemap of the project by size or heat"},{id:"routes",label:"Routes",title:"detected HTTP routes and their handlers"},{id:"hotspots",label:"Hotspots",title:"files and functions that attract change"},{id:"structure",label:"Structure",title:"clusters and import cycles"},{id:"behavior",label:"Behavior",title:"possible call tree from one operation"}];function eg(t){if(Ms(t.tab))return t.tab;if(t.node)return"galaxy";try{let n=localStorage.getItem(qc)??void 0;if(Ms(n))return n}catch{}return"galaxy"}function Kc({params:t}){let n=eg(t);return U(()=>{try{localStorage.setItem(qc,n)}catch{}},[n]),e("div",{class:"ws ws-galaxy",children:[e("div",{class:"gtabs",children:e(Se,{label:"Galaxy views",value:n,onChange:a=>H("galaxy",{tab:a}),options:Qm})}),n==="galaxy"||n==="hierarchy"?e(Zm,{params:t,mode:n}):e("div",{class:"gt-page",children:e("div",{class:"page ds-page",children:[n==="map"&&e(Xc,{}),n==="routes"&&e(Wc,{}),n==="hotspots"&&e(Gc,{}),n==="structure"&&e(zc,{}),n==="behavior"&&e(Nc,{params:t})]})})]})}var tg={branch:"hexagon",commit:"triangle",memory:"diamond",doc:"square"};function ar(t){return t.missing?"ring":tg[t.kind]??"circle"}function or(t){let n=t;return n.kind==="commit"?Qt(n.bucket??"other"):n.kind==="branch"?n.live||n.isDefault?"#64748b":"#9ca3af":n.kind==="memory"&&(n.status==="superseded"||n.status==="deprecated")?"#93c5fd":xt(t.kind)}var ng={contains:{color:"#64748b",width:1.2,alpha:.55,directed:!0},merged_into:{color:"#64748b",dash:[6,3],width:1.6,alpha:.6,directed:!0},touches:{color:"#94a3b8",width:.9,alpha:.4,directed:!0},records:{color:"#2563eb",dash:[2,3],width:1.2,alpha:.6,directed:!0},fixes:{color:"#e11d48",dash:[4,3],width:1.6,alpha:.75,directed:!0}};function La(t){return ng[t]??ns(t)}var sg=(t,n)=>t.length>n?`${t.slice(0,n-1)}\u2026`:t;function Vc(t){return t.kind==="commit"?sg(t.label,32):t.kind==="file"?t.label.split("/").pop()??t.label:t.label}var rg=["branch","commit","file","memory","doc"],ag=["contains","merged_into","touches","fixes","records","mentions","documents"],og={contains:"a commit made on this branch",merged_into:"the branch was merged into the default branch",touches:"the commit changed this file",fixes:"a fix whose removed lines trace back to this commit",records:"the commit wrote or edited this memory",mentions:"a memory's related: header names this file",documents:"a doc source covers this file"},ig=[5,8,15,30],Yc=(t,n)=>[...t].sort((s,a)=>{let r=n.indexOf(s),o=n.indexOf(a);return(r===-1?99:r)-(o===-1?99:o)||s.localeCompare(a)});function Zc(t,n){let s=new Set(t);return s.has(n)?s.delete(n):s.add(n),s}function Qc({focus:t}){let[n,s]=x(null),[a,r]=x(!1),[o,i]=x(0),[l,c]=x(8),[u,d]=x(new Set),[p,g]=x(new Set),[h,y]=x(""),[m,f]=x(!1),[v,b]=x(t??null);U(()=>{let O=!0;return r(!0),J("/api/history/knowledge",{focus:t,branches:l,limit:400}).then(A=>{O&&(s(A),b(A.focus??null))}).catch(A=>O&&ee(A.message,!0)).finally(()=>O&&r(!1)),()=>{O=!1}},[t,l,o]);let w=ae(()=>{if(!n?.git)return null;let O=h?n.nodes.filter(A=>A.kind!=="commit"||A.root||A.bucket===h):n.nodes;return Qs({nodes:O,edges:n.edges},{hiddenKinds:u,hiddenEdges:p,status:"",category:"",hideSuperseded:!1})},[n,u,p,h]),k=n?.git?n.nodes:[],C=ae(()=>an(k,O=>O.kind),[n]),S=ae(()=>an(n?.edges??[],O=>O.kind),[n]),_=ae(()=>an(k.filter(O=>O.kind==="commit"),O=>O.bucket??"other"),[n]),T=O=>k.find(A=>A.kind===O&&!A.missing),M=ae(()=>new Map(k.map(O=>[O.id,O])),[n]),F=v?M.get(v):void 0,D=w?.edges??[],$=F?D.filter(O=>O.dst===F.id):[],L=F?D.filter(O=>O.src===F.id):[],K=O=>{let A=M.get(O);return A?A.kind==="commit"?`${A.short} ${A.label}`:A.label:O},Y=O=>H("history",{tab:"graph",focus:O}),ne=n?.focus?M.get(n.focus):void 0;return n&&!n.git?e(X,{icon:"\u2387",title:"No git history",children:n.error??"Not a git repository."}):e("div",{class:"kgalaxy hgraph ds-card flush",children:[e("div",{class:"gtoolbar",children:[t?e("span",{class:"row tight",children:[e("span",{class:"muted small",children:"focused on"}),e("b",{class:"break",children:ne?K(ne.id):t}),e("button",{type:"button",class:"sm",onClick:()=>H("history",{tab:"graph"}),children:"Show all"})]}):e(R,{children:[e("span",{class:"muted small",children:"newest"}),e("select",{value:String(l),title:"feature branches drawn",onChange:O=>c(Number(O.target.value)),children:ig.map(O=>e("option",{value:String(O),children:O}))}),e("span",{class:"muted small",children:"branches, their commits and what they touched"})]}),e("select",{value:"",title:"focus a branch",onChange:O=>{let A=O.target.value;A&&Y(`branch:${A}`)},children:[e("option",{value:"",children:"focus a branch\u2026"}),(n?.branches??[]).map(O=>e("option",{value:O.name,children:[O.name," (",O.commits,")",O.isDefault?" \xB7 default":O.merged?" \xB7 merged":"",O.live?"":" \xB7 deleted"]}))]}),_.size>1?e("select",{value:h,title:"commit kind",onChange:O=>y(O.target.value),children:[e("option",{value:"",children:"any commit kind"}),Zt.filter(O=>_.has(O)).map(O=>e("option",{value:O,children:[O," (",_.get(O),")"]}))]}):null,e("button",{type:"button",class:E("chip",m&&"on"),onClick:()=>f(!m),children:"legend"}),e("button",{type:"button",class:"sm",title:"reload",onClick:()=>i(O=>O+1),children:"\u21BB"}),e("span",{class:"count",children:a?e(se,{}):w&&n?`${w.nodes.length} of ${k.length} nodes \xB7 ${w.edges.length} edges${n.truncated?` \xB7 first ${k.length} of ${n.total}`:""}`:""})]}),e("div",{class:"gtoolbar",style:{paddingTop:4,paddingBottom:6},children:[e("span",{class:"muted small",children:"nodes:"}),Yc([...C.keys()],rg).map(O=>{let A=T(O);return e("button",{type:"button",class:E("chip",!u.has(O)&&"on"),onClick:()=>d(Zc(u,O)),children:[A?e(Nt,{shape:ar(A),color:or(A)}):null,O," ",C.get(O)]})}),e("span",{class:"muted small",style:{marginLeft:8},children:"edges:"}),Yc([...S.keys()],ag).map(O=>{let A=La(O);return e("button",{type:"button",title:og[O],class:E("chip",!p.has(O)&&"on"),onClick:()=>g(Zc(p,O)),children:[e(An,{color:A.color,dash:A.dash}),O," ",S.get(O)]})})]}),e("div",{class:"kbody",style:{gridTemplateColumns:F?"minmax(0,1fr) 320px":"minmax(0,1fr)"},children:[e("div",{style:{minWidth:0,minHeight:0},children:w?w.nodes.length?e($t,{nodes:w.nodes,edges:w.edges,selected:v,onSelect:b,onActivate:Y,legend:m,colorOf:or,shapeOf:ar,edgeStyleOf:La,labelOf:Vc}):k.length?e(X,{compact:!0,title:"Nothing left after these filters."}):e(X,{compact:!0,title:"No commits to draw."}):e("div",{class:"hist-graph-loading",role:"status","aria-busy":"true",children:[e(N,{h:14}),e(N,{w:"70%",h:14}),e(N,{h:120})]})}),F&&e("div",{class:"panel right",children:[e("div",{class:"head",children:["selection ",e("span",{class:"spacer"}),e("a",{onClick:()=>b(null),children:"close"})]}),e("div",{class:"body",children:[e(lg,{node:F,focus:n?.focus??void 0,onFocus:Y}),e(Rn,{title:"incoming",rows:$.map(O=>({kind:O.kind,id:O.src})),label:K,onPick:b}),e(Rn,{title:"outgoing",rows:L.map(O=>({kind:O.kind,id:O.dst})),label:K,onPick:b})]})]})]})]})}function lg({node:t,focus:n,onFocus:s}){return e("div",{class:"section",children:[e("div",{class:"row tight",children:[e(Nt,{shape:ar(t),color:or(t)}),e(Ie,{kind:t.kind}),e("b",{class:"break",children:t.kind==="commit"?t.short:t.label})]}),t.kind==="commit"?e("div",{style:{marginTop:4},children:t.label}):null,e("div",{class:"row tight wrap",style:{marginTop:4},children:[t.kind==="commit"&&t.sub?e("span",{class:"tag",style:{borderColor:Qt(t.bucket??"other")},children:t.sub}):null,t.group==="memory"&&t.sub?e(Je,{children:t.sub}):null,t.status?e("span",{class:`tag s-${t.status}`,children:t.status}):null,t.group==="doc"&&t.detail?e(Je,{children:t.detail}):null,t.kind==="branch"?e(R,{children:[e(Je,{children:[t.commits," own commits"]}),t.isDefault?e(Je,{children:"default"}):t.merged?e(Je,{children:"merged"}):e(Je,{children:"open"}),t.live?null:e(Je,{children:"ref deleted"}),(t.prs??[]).map(a=>e(Je,{children:["#",a]}))]}):null,t.kind==="file"&&t.fixes?e(Je,{children:[t.fixes," fixes"]}):null,t.risk?e(Je,{children:["risk ",Math.round(t.risk*100),"%"]}):null]}),t.at?e("div",{class:"muted small",style:{marginTop:4},children:[t.author?`${t.author} \xB7 `:"",me(t.at)]}):null,t.missing?e("div",{class:"muted small",style:{marginTop:4},children:t.kind==="file"?"No longer in the working tree (deleted or renamed since).":"Nothing defines it any more (deleted or renamed)."}):null,e("div",{class:"row wrap",style:{marginTop:8},children:[t.id!==n?e("button",{type:"button",class:"sm primary",onClick:()=>s(t.id),children:"Focus here"}):null,t.kind==="commit"&&t.short?e("button",{type:"button",class:"sm",onClick:()=>H("history",{tab:"timeline",sha:t.id.slice(7)}),children:"Open commit"}):null,t.kind==="branch"&&t.live&&!t.isDefault?e("button",{type:"button",class:"sm",onClick:()=>H("history",{tab:"branches",branch:t.label}),children:"Branch detail"}):null,t.kind==="file"&&t.path?e("button",{type:"button",class:"sm",onClick:()=>H("history",{tab:"files",file:t.path}),children:"File history"}):null,t.kind==="file"&&t.path&&!t.missing?e("button",{type:"button",class:"sm",onClick:()=>H("explore",{file:t.path}),children:"Open source"}):null,t.group==="memory"&&!t.missing?e("button",{type:"button",class:"sm",onClick:()=>H("memory",{name:t.label}),children:"Open memory"}):null,t.group==="doc"&&!t.missing?e("button",{type:"button",class:"sm",onClick:()=>H("docs",{tab:"sources",name:t.label}),children:"Open doc source"}):null]})]})}function ir({kind:t,bucket:n}){return e("span",{class:E("ds-badge hist-kind",n==="other"&&"neutral"),style:n==="other"?void 0:{color:Qt(n)},children:t})}function ed({added:t,deleted:n}){let s=t+n,a=5,r=s?Math.round(t/s*a):0,o=s?Math.min(a-r,Math.round(n/s*a)):0;return e("span",{class:"pm",title:`+${t} / -${n}`,children:[e("span",{class:"add",children:["+",z(t)]}),e("span",{class:"del",children:["-",z(n)]}),e("span",{class:"bars",children:Array.from({length:a},(i,l)=>e("i",{class:l<r?"a":l<r+o?"d":""}))})]})}function td({refs:t,tags:n,max:s=3}){let a=t.filter(r=>!r.startsWith("tag: "));return!a.length&&!n.length?null:e(R,{children:[n.slice(0,2).map(r=>e("span",{class:"ref tag",children:r})),a.slice(0,s).map(r=>e("span",{class:E("ref",r.includes("/")&&"remote"),children:r})),a.length>s?e("span",{class:"ref remote",children:["+",a.length-s]}):null]})}function cg({c:t}){return e(R,{children:[t.blamedBy?e("span",{class:"flag warn",title:`${t.blamedBy} later fix(es) removed lines from this commit`,children:["\u26A0 ",t.blamedBy]}):null,t.reverted?e("span",{class:"flag bad",title:"reverted",children:"\u21A9"}):null,t.origins&&(t.kind==="fix"||t.kind==="revert")?e("span",{class:"flag ok",title:`traced to ${t.origins} earlier commit(s)`,children:["\u21E0 ",t.origins]}):null,t.breaking?e("span",{class:"flag bad",children:"BREAKING"}):null]})}function Dn({value:t}){return e("span",{class:"riskbar",title:t.toFixed(2),children:e("i",{style:{width:`${Math.round(t*100)}%`,background:ea(.3+t*.7)}})})}var dg={"risk-high":"bad","risk-medium":"warn","risk-low":"ok","s-accepted":"ok"};function Oe({children:t,class:n}){return e(I,{tone:n?dg[n]:void 0,children:t})}function nd({children:t}){return e(X,{compact:!0,title:t})}function Ln({commits:t,selected:n,onSelect:s,lanes:a,empty:r}){return t.length?e("div",{class:"commits",children:[a?e(Ai,{rows:a.rows,lanes:a.lanes,rowH:28,selected:n}):null,e("div",{class:"rows",children:t.map(i=>e("div",{class:E("crow",n===i.sha&&"sel",!i.onHead&&"off"),onClick:()=>s(i.sha),title:`${i.sha}
|
|
12
|
+
${i.subject}
|
|
13
|
+
${i.author} \xB7 ${new Date(i.at).toLocaleString()}${i.riskReasons.length?`
|
|
14
|
+
${i.riskReasons.join("; ")}`:""}`,children:[e("span",{class:"when",children:Ve(i.at)}),e("span",{class:"subj",children:[e("span",{class:"sha",children:i.short}),e(ir,{kind:i.kind,bucket:i.bucket}),i.subject,e(td,{refs:i.refs,tags:i.tags})]}),e("span",{class:"meta",children:[e(cg,{c:i}),i.merge?e("span",{children:"merge"}):e(ed,{added:i.added,deleted:i.deleted}),e("span",{children:i.author.split(" ")[0]})]})]}))})]}):e(nd,{children:r??"No commits match."})}function ja({l:t,onSelect:n}){return e("div",{class:"step",onClick:()=>n(t.sha),style:{cursor:"pointer"},children:[e("span",{class:"sha mono muted",children:t.short})," ",t.kind&&t.bucket?e(ir,{kind:t.kind,bucket:t.bucket}):null,e("a",{children:t.subject}),t.at?e("span",{class:"muted small",children:[" \xB7 ",Ve(t.at)]}):null,t.paths.length?e("div",{class:"muted small",children:t.paths.join(", ")}):null]})}function ug({sha:t,path:n}){let s=V(()=>J("/api/history/diff",{sha:t,path:n}),[t,n]);if(s.error)return e(Z,{error:s.error});if(!s.data)return e(se,{});let a=s.data.text.split(`
|
|
15
|
+
`);return e(R,{children:[e("div",{class:"diff",children:a.map(r=>e("div",{class:r.startsWith("+++")||r.startsWith("---")?"muted":r.startsWith("diff --git")?"file":r.startsWith("@@")?"hunk":r.startsWith("+")?"add":r.startsWith("-")?"del":"",children:r.startsWith("diff --git")?r.replace(/^diff --git a\/(.*) b\/.*$/,"$1"):r||" "}))}),s.data.truncated?e("div",{class:"muted small",children:"diff truncated"}):null]})}function pg({sha:t,onSelect:n}){let s=V(()=>J("/api/history/commit",{sha:t}),[t]),[a,r]=x(!1);if(U(()=>r(!1),[t]),s.error)return e(Z,{error:s.error});if(!s.data)return e(se,{});if(s.data.error)return e(Z,{error:s.data.error});let o=s.data,i=o.commit,l=Math.max(1,...o.files.map(c=>c.added+c.deleted));return e("div",{class:"stack",children:[e(j,{children:[e("div",{class:"row tight",style:{flexWrap:"wrap"},children:[e(ir,{kind:i.kind,bucket:i.bucket}),i.scope?e(Oe,{children:i.scope}):null,i.breaking?e(Oe,{class:"risk-high",children:"breaking"}):null,i.pr?e(Oe,{children:["PR #",i.pr]}):null,i.issues.map(c=>e(Oe,{children:c})),e(td,{refs:i.refs,tags:i.tags,max:6}),e("span",{class:"spacer"}),e("span",{class:"mono small muted",title:i.sha,children:i.sha.slice(0,12)})]}),e("h3",{class:"hist-subject",children:i.subject}),e("div",{class:"muted small",children:[i.author," <",i.email,"> \xB7 ",new Date(i.at).toLocaleString()," (",me(i.at),")",i.merge?" \xB7 merge":` \xB7 +${i.added}/-${i.deleted} in ${i.files} file${i.files===1?"":"s"} (${i.size})`,i.onHead?"":" \xB7 not reachable from HEAD"]}),i.body?e("div",{class:"msg",style:{marginTop:8},children:i.body}):null,i.riskReasons.length?e("div",{class:"row small",style:{marginTop:8,alignItems:"baseline"},children:[e(Oe,{class:i.risk>=.5?"risk-high":i.risk>=.3?"risk-medium":"risk-low",children:["hindsight ",i.risk.toFixed(2)]}),e("span",{class:"muted",children:i.riskReasons.join("; ")})]}):null,e("div",{class:"row",style:{marginTop:8},children:[e("button",{type:"button",class:"sm",onClick:()=>r(a===!1?null:!1),children:a===!1?"Show diff":"Hide diff"}),e("button",{type:"button",class:"sm",onClick:()=>H("history",{tab:"graph",focus:`commit:${i.sha}`}),children:"Graph"}),o.branches.length?e("span",{class:"muted small",children:["on ",o.branches.slice(0,5).join(", "),o.branches.length>5?` +${o.branches.length-5}`:""]}):null]})]}),o.blamedBy.length||o.origins.length||o.revertedBy?e(j,{title:"what history says",children:[o.origins.length?e(R,{children:[e("div",{class:"muted small",style:{marginBottom:4},children:i.kind==="revert"?"reverts":"removed lines last written by (likely cause of the bug)"}),e("div",{class:"chain",children:o.origins.map(c=>e("div",{class:E("step","origin"),children:e(ja,{l:c,onSelect:n})}))})]}):null,o.blamedBy.length?e(R,{children:[e("div",{class:"muted small",style:{margin:"6px 0 4px"},children:"later fixes that removed lines from this commit"}),e("div",{class:"chain",children:o.blamedBy.map(c=>e("div",{class:E("step","fix"),children:[e(ja,{l:c,onSelect:n}),c.at?e("span",{class:"muted small",children:[Math.max(0,Math.round((c.at-i.at)/864e5)),"d later"]}):null]}))})]}):null,o.revertedBy?e(R,{children:[e("div",{class:"muted small",style:{margin:"6px 0 4px"},children:"reverted by"}),e("div",{class:"chain",children:e("div",{class:"step fix",children:e(ja,{l:o.revertedBy,onSelect:n})})})]}):null]}):null,a!==!1?e(j,{children:[e("div",{class:"row",style:{marginBottom:6},children:[e("h3",{class:"hist-h3",children:["diff",a?` \xB7 ${a}`:""]}),a?e("button",{type:"button",class:"sm ghost",onClick:()=>r(null),children:"whole commit"}):null]}),e(ug,{sha:i.sha,path:a??void 0})]}):null,o.files.length?e(j,{title:`files \xB7 ${o.files.length}`,sub:"symbols are listed when the file has not changed since this commit",children:e("div",{class:"cfiles",children:o.files.map(c=>e("div",{class:"cfile",children:[e("div",{class:"row tight",children:[e("a",{class:"ellipsis grow",title:c.path,onClick:()=>H("explore",{file:c.path}),children:c.path}),e(Dt,{value:c.added+c.deleted,max:l,width:44}),e(ed,{added:c.added,deleted:c.deleted})]}),e("div",{class:"row tight small",style:{flexWrap:"wrap"},children:[e("a",{class:"muted",onClick:()=>r(c.path),children:"diff"}),e("a",{class:"muted",onClick:()=>H("history",{tab:"files",file:c.path}),children:"history"}),c.renamedFrom?e("span",{class:"muted",children:["\u2190 ",c.renamedFrom]}):null,c.fileFixes?e("span",{class:"muted",title:`history risk ${c.fileRisk.toFixed(2)}`,children:[e(Dn,{value:c.fileRisk})," ",c.fileFixes," past fix",c.fileFixes===1?"":"es"]}):null,c.symbols.map(u=>e("a",{onClick:()=>H("explore",{file:c.path,symbol:u.id,line:u.line?String(u.line):void 0}),children:[e("span",{class:"muted",children:u.kind})," ",u.name]}))]})]}))})}):null]})}function mg({ov:t,params:n,selected:s,onSelect:a}){let[r,o]=x(new Set),[i,l]=x(null),[c,u]=x(n.q??""),[d,p]=x(""),[g,h]=x(n.path??""),[y,m]=x(!1),[f,v]=x(!1),[b,w]=x(150),k=t.buckets.filter(M=>!r.has(M)),C=V(()=>J("/api/history/commits",{buckets:r.size?k.join(","):void 0,q:c.trim()||void 0,author:d||void 0,path:g.trim()||void 0,since:i?new Date(i[0]).toISOString():void 0,until:i?new Date(i[1]).toISOString():void 0,risky:y?1:void 0,head:f?1:void 0,limit:b}),[r,c,d,g,i,y,f,b]),S=V(()=>J("/api/history/graph",{limit:400}),[t.head]),_=ae(()=>{if(!S.data||!C.data)return;let M=new Set(C.data.commits.map(D=>D.sha)),F=S.data.commits.slice(0,C.data.commits.length);if(!(F.length!==M.size||!F.every(D=>M.has(D.sha))))return Qr(F)},[S.data,C.data]),T=ae(()=>{let M={};for(let F of t.weeks)for(let D of t.buckets)M[D]=(M[D]??0)+F.byBucket[D];return M},[t]);return e("div",{class:"grid wide",style:{alignItems:"start",gridTemplateColumns:"minmax(0, 1.4fr) minmax(320px, 1fr)"},children:[e("div",{class:"stack",children:[e(j,{children:[e("div",{class:"row",style:{marginBottom:6,flexWrap:"wrap"},children:[e(Ti,{counts:T,hidden:r,onToggle:M=>o(F=>{let D=new Set(F);return D.has(M)?D.delete(M):D.add(M),D})}),e("span",{class:"spacer"}),e("span",{class:"muted small",children:i?e(R,{children:[Ve(i[0])," \u2192 ",Ve(i[1])," ",e("a",{onClick:()=>l(null),children:"clear"})]}):"drag across the chart to focus a period"})]}),e(Ei,{weeks:t.weeks,range:i,onRange:l,hidden:r})]}),e(j,{children:[e("div",{class:"row",style:{flexWrap:"wrap",marginBottom:8},children:[e("input",{type:"search",placeholder:"search message, sha, issue\u2026",value:c,onInput:M=>u(M.target.value),style:{width:240}}),e("select",{value:d,onChange:M=>p(M.target.value),children:[e("option",{value:"",children:"everyone"}),t.authors.map(M=>e("option",{value:M.name,children:[M.name," (",M.commits,")"]}))]}),e("input",{type:"text",placeholder:"path prefix",value:g,onInput:M=>h(M.target.value),style:{width:180}}),e("button",{type:"button",class:E("chip",y&&"on"),onClick:()=>m(!y),title:"only commits later fixed, reverted, large or touching hotspots",children:"\u26A0 hindsight flags"}),e("button",{type:"button",class:E("chip",f&&"on"),onClick:()=>v(!f),children:"HEAD only"}),e("span",{class:"spacer"}),e("span",{class:"muted small",children:C.data?`${C.data.total} commits`:""})]}),C.error?e(Z,{error:C.error}):C.data?e(R,{children:[e(Ln,{commits:C.data.commits,selected:s,onSelect:a,lanes:_}),C.data.total>C.data.commits.length?e("div",{class:"row",style:{marginTop:8},children:e("button",{type:"button",class:"sm",onClick:()=>w(M=>M+200),children:["show more (",C.data.total-C.data.commits.length," left)"]})}):null]}):e(se,{})]})]}),e("div",{class:"stack",children:s?e(pg,{sha:s,onSelect:a}):e(R,{children:[e(j,{title:"worth knowing",children:t.notable.length?e(Ln,{commits:t.notable,selected:null,onSelect:a}):e("div",{class:"muted small",children:"No commit stands out in hindsight."})}),e(j,{title:"people",children:e("table",{children:e("tbody",{children:t.authors.slice(0,8).map(M=>e("tr",{class:"click",onClick:()=>p(M.name),children:[e("td",{children:M.name}),e("td",{class:"num",children:[e(Dt,{value:M.commits,max:t.authors[0]?.commits??1,width:70})," ",M.commits]}),e("td",{class:"muted small",children:[M.fixes," fixes \xB7 ",M.files," files"]}),e("td",{class:"muted small",children:me(M.lastAt)})]}))})})}),t.tags.length?e(j,{title:"releases",children:e("div",{class:"row tight",style:{flexWrap:"wrap"},children:t.tags.slice(0,20).map(M=>e("a",{onClick:()=>a(M.sha),title:Ve(M.at),children:e("span",{class:"ref tag",children:M.name})}))})}):null]})})]})}function gg({ov:t,params:n,onSelectCommit:s}){let[a,r]=x(n.branch??null),[o,i]=x(!1),[l,c]=x(!0),u=V(()=>J("/api/history/graph",{limit:120}),[t.head]),d=V(()=>a?J("/api/history/branch",{name:a}):Promise.resolve(null),[a]),p=ae(()=>u.data?Qr(u.data.commits):void 0,[u.data]),g=t.branches.filter(f=>(o||!f.remote)&&(l||!f.merged||f.isDefault)),h=Math.max(1,...g.map(f=>Math.max(f.ahead,f.behind))),[y,m]=x(null);return e("div",{class:"grid wide",style:{alignItems:"start",gridTemplateColumns:"minmax(0, 1fr) minmax(360px, 1fr)"},children:[e(j,{title:"commit graph",sub:`latest ${u.data?.commits.length??""} across all branches`,children:u.error?e(Z,{error:u.error}):u.data?e(Ln,{commits:u.data.commits,selected:y,onSelect:f=>{m(f),s(f)},lanes:p}):e(se,{})}),e("div",{class:"stack",children:[e(j,{children:[e("div",{class:"row",style:{marginBottom:6},children:[e("h3",{class:"hist-h3",children:["branches \xB7 ",g.length]}),e("span",{class:"spacer"}),e("button",{type:"button",class:E("chip",o&&"on"),onClick:()=>i(!o),children:"remotes"}),e("button",{type:"button",class:E("chip",l&&"on"),onClick:()=>c(!l),children:"merged"})]}),e("table",{children:[e("thead",{children:e("tr",{children:[e("th",{children:"branch"}),e("th",{children:["vs ",t.base??"base"]}),e("th",{children:"last"})]})}),e("tbody",{children:g.map(f=>e("tr",{class:E("click",a===f.name&&"sel"),onClick:()=>r(f.name),children:[e("td",{class:"break",children:[e("span",{class:E("ref",f.remote&&"remote"),children:f.name}),f.current?e(Oe,{children:"current"}):null,f.isDefault?e(Oe,{children:"base"}):null,!f.merged&&!f.isDefault?e(Oe,{class:"risk-medium",children:"unmerged"}):null,f.lastSubject?e("div",{class:"muted small ellipsis",style:{maxWidth:260},children:f.lastSubject}):null]}),e("td",{children:f.isDefault?e("span",{class:"muted small",children:"\u2014"}):e("span",{class:"ab",title:`${f.ahead} ahead, ${f.behind} behind`,children:[e("span",{class:"ok",children:["+",f.ahead]}),e(Dt,{value:f.ahead,max:h,width:40}),e(Dt,{value:f.behind,max:h,width:40}),e("span",{class:"bad",children:["-",f.behind]})]})}),e("td",{class:"muted small nowrap",children:[me(f.at),f.lastAuthor?` \xB7 ${f.lastAuthor.split(" ")[0]}`:""]})]}))})]})]}),a?e(j,{title:e("span",{class:"break",children:a}),children:d.error?e(Z,{error:d.error}):d.data?d.data.error?e(Z,{error:d.data.error}):e(hg,{d:d.data,onSelect:f=>{m(f),s(f)}}):e(se,{})}):e(j,{class:"muted small",children:"Select a branch to see the commits only it has, the files they touch, and how bug-prone those files have been."})]})]})}function hg({d:t,onSelect:n}){let s=t.branch,a=t.files.filter(r=>r.risk>=.3);return e(R,{children:[e("div",{class:"row small",style:{flexWrap:"wrap"},children:[e(Oe,{children:["tip ",s.sha.slice(0,7)]}),e(Oe,{children:me(s.at)}),s.upstream?e(Oe,{children:["tracks ",s.upstream]}):null,s.isDefault?null:e(Oe,{class:s.merged?"s-accepted":"risk-medium",children:s.merged?"merged":`+${s.ahead} / -${s.behind}`}),e("span",{class:"spacer"}),e("button",{type:"button",class:"sm",onClick:()=>H("history",{tab:"graph",focus:`branch:${s.remote?s.name.replace(/^[^/]+\//,""):s.name}`}),children:"Graph"})]}),s.isDefault?e("div",{class:"muted small",style:{marginTop:6},children:"This is the base branch; other branches are compared against it."}):e(R,{children:[e("div",{class:"muted small",style:{margin:"8px 0 4px"},children:[t.commits.length," commit",t.commits.length===1?"":"s"," only on this branch"]}),e(Ln,{commits:t.commits,selected:null,onSelect:n,empty:"Nothing unique: the branch is fully merged or behind."}),t.files.length?e(R,{children:[e("div",{class:"muted small",style:{margin:"8px 0 4px"},children:["files touched ",a.length?`\xB7 ${a.length} with a fix-heavy history`:""]}),e("div",{class:"list",style:{maxHeight:220},children:t.files.map(r=>e("div",{class:"item",onClick:()=>H("history",{tab:"files",file:r.path}),children:e("div",{class:"p",children:[r.risk>=.3?e(Dn,{value:r.risk}):null," ",r.path,e("span",{class:"muted",children:[" ","\xB7 ",r.commits," commit",r.commits===1?"":"s",r.fixes?`, ${r.fixes} past fixes`:""]})]})}))})]}):null]})]})}function fg({params:t,onSelectCommit:n}){let[s,a]=x(""),[r,o]=x(t.file??null);U(()=>{t.file&&o(t.file)},[t.file]);let i=V(()=>J("/api/history/files",{path:s.trim()||void 0,limit:400}),[s]),{sorted:l,th:c}=Ot(i.data?.files,"risk"),[u,d]=x(null);return e("div",{class:"grid wide",style:{alignItems:"start",gridTemplateColumns:"minmax(0, 1fr) minmax(360px, 1fr)"},children:[e("div",{class:"stack",children:[e(j,{children:[e("div",{class:"row",style:{marginBottom:6},children:[e("h3",{class:"hist-h3",children:"churn vs fix share"}),e("input",{type:"text",placeholder:"folder prefix, e.g. src/graph/",value:s,onInput:p=>a(p.target.value),style:{width:220}}),e("span",{class:"spacer"}),e("span",{class:"muted small",children:"size = lines changed \xB7 colour = history risk"})]}),i.data?e(Ri,{files:i.data.files,selected:r,onSelect:o}):i.error?e(Z,{error:i.error}):e(se,{})]}),e(j,{flush:!0,children:e("table",{children:[e("thead",{children:e("tr",{children:[c("path","file"),c("commits","commits",!0),c("fixes","fixes",!0),c("bugOrigins","caused fixes",!0),c("commits90d","90d",!0),e("th",{children:"12 months"}),c("risk","risk",!0)]})}),e("tbody",{children:l.slice(0,150).map(p=>e("tr",{class:E("click",r===p.path&&"sel"),onClick:()=>o(p.path),children:[e("td",{class:"break",children:p.path}),e("td",{class:"num",children:p.commits}),e("td",{class:"num",children:p.fixes}),e("td",{class:"num",children:p.bugOrigins}),e("td",{class:"num",children:p.commits90d}),e("td",{children:e(ta,{values:p.months})}),e("td",{class:"num",children:[e(Dn,{value:p.risk})," ",p.risk.toFixed(2)]})]}))})]})})]}),e("div",{class:"stack",children:r?e(bg,{path:r,selected:u,onSelect:p=>{d(p),n(p)}}):e(j,{class:"muted small",children:"Pick a file to read its story: who changed it, what broke afterwards, and which fixes restored behaviour worth a test."})})]})}function bg({path:t,selected:n,onSelect:s}){let a=V(()=>J("/api/history/file",{path:t}),[t]);if(a.error)return e(Z,{error:a.error});if(!a.data)return e(se,{});let r=a.data,o=r.file;return e(R,{children:[e(j,{title:e("span",{class:"break",children:t}),children:o?e(R,{children:[e("div",{class:"row small",style:{flexWrap:"wrap"},children:[e(Oe,{children:[o.commits," commits"]}),e(Oe,{children:[o.fixes," fixes"]}),e(Oe,{children:["+",z(o.added),"/-",z(o.deleted)]}),e(Oe,{children:[Ve(o.firstAt)," \u2192 ",Ve(o.lastAt)]}),o.renamedFrom?e(Oe,{children:["from ",o.renamedFrom]}):null]}),e("div",{class:"row small",style:{marginTop:6,alignItems:"center"},children:[e(Dn,{value:o.risk}),e("span",{class:"muted",children:["history risk ",o.risk.toFixed(2),o.reasons.length?`: ${o.reasons.join("; ")}`:""]})]}),e("div",{class:"row small",style:{marginTop:6,flexWrap:"wrap"},children:[e("span",{class:"muted",children:"authors:"}),o.authors.map(([i,l])=>e(Oe,{children:[i," ",l]})),e("span",{class:"spacer"}),e(ta,{values:o.months,width:120,height:22})]}),e("div",{class:"row",style:{marginTop:8},children:[e("button",{type:"button",class:"sm",onClick:()=>H("explore",{file:t}),children:"Open source"}),e("button",{type:"button",class:"sm",onClick:()=>H("galaxy",{node:`file:${t}`}),children:"Galaxy"}),e("button",{type:"button",class:"sm",onClick:()=>H("history",{tab:"graph",focus:`file:${t}`}),children:"History graph"})]})]}):e("div",{class:"muted small",children:"No commits in the loaded window touch this file."})}),r.origins.length?e(j,{title:"changes that later needed fixing",children:e("div",{class:"chain",children:r.origins.map(i=>e("div",{class:"step origin",children:[e("a",{onClick:()=>s(i.sha),children:[e("span",{class:"mono muted small",children:i.short})," ",e(ir,{kind:i.kind,bucket:i.bucket})," ",i.subject]}),e("span",{class:"muted small",children:[" \xB7 ",Ve(i.at)]}),e("div",{class:"chain",style:{marginTop:2},children:i.fixes.map(l=>e("div",{class:"step fix",children:[e("a",{onClick:()=>s(l.sha),children:[e("span",{class:"mono muted small",children:l.short})," ",l.subject]}),e("span",{class:"muted small",children:[" \xB7 ",l.daysLater,"d later"]})]}))})]}))})}):null,e(j,{title:`timeline \xB7 ${r.commits.length}`,children:e(Ln,{commits:r.commits,selected:n,onSelect:s})})]})}function yg({ov:t,onSelectCommit:n}){let s=V(()=>J("/api/history/risk"),[t.head,t.stats.workingTree]),[a,r]=x(""),o=V(()=>a.trim()?J("/api/history/risk",{paths:a.trim()}):Promise.resolve(null),[a]),i=a.trim()?o.data:s.data,l=V(()=>J("/api/history/commits",{risky:1,limit:40}).then(c=>c.commits.filter(u=>u.blamedBy||u.reverted)),[t.head]);return e("div",{class:"grid wide",style:{alignItems:"start"},children:[e("div",{class:"stack",children:[e(j,{children:[e("div",{class:"row",style:{marginBottom:6},children:[e("h3",{class:"hist-h3",children:a.trim()?"history risk for these paths":"working tree exposure"}),e("input",{type:"text",placeholder:"or paths, comma separated",value:a,onInput:c=>r(c.target.value),style:{width:300}})]}),e("div",{class:"muted small",style:{marginBottom:8},children:"What the past says about the files you are changing now: fix density, changes here that were later fixed, and the last fix to re-read before editing."}),i?i.files.length?e("table",{children:[e("thead",{children:e("tr",{children:[e("th",{children:"file"}),e("th",{children:"risk"}),e("th",{children:"history"})]})}),e("tbody",{children:[...i.files].sort((c,u)=>(u.file?.risk??-1)-(c.file?.risk??-1)).map(c=>e("tr",{children:[e("td",{class:"break",children:e("a",{onClick:()=>H("history",{tab:"files",file:c.path}),children:c.path})}),e("td",{class:"nowrap",children:c.file?e(R,{children:[e(Dn,{value:c.file.risk})," ",c.file.risk.toFixed(2)]}):e("span",{class:"muted small",children:"new"})}),e("td",{class:"small",children:c.file?e(R,{children:[e("div",{class:"muted",children:[c.file.commits," commits \xB7 ",c.file.fixes," fixes \xB7 last"," ",me(c.file.lastAt),c.file.reasons.length?` \xB7 ${c.file.reasons.join("; ")}`:""]}),c.lastFix?e("div",{children:["last fix: ",c.lastFix]}):null,c.origins.length?e("div",{children:["needed fixing before:"," ",c.origins.map(u=>e("a",{onClick:()=>n(u.sha),style:{marginRight:6},children:[u.short," ",u.subject.slice(0,40)]}))]}):null]}):e("span",{class:"muted",children:"no history yet"})})]}))})]}):e(nd,{children:"Working tree is clean."}):s.error?e(Z,{error:s.error}):e(se,{})]}),e(j,{title:"bug-prone files",children:t.risky.length?e("table",{children:e("tbody",{children:t.risky.map(c=>e("tr",{class:"click",onClick:()=>H("history",{tab:"files",file:c.path}),children:[e("td",{class:"break",children:c.path}),e("td",{class:"nowrap",children:[e(Dn,{value:c.risk})," ",c.risk.toFixed(2)]}),e("td",{class:"muted small",children:c.reasons.join("; ")||`${c.commits} commits`})]}))})}):e("div",{class:"muted small",children:"No file shows a fix pattern yet."})})]}),e("div",{class:"stack",children:[e(j,{title:"lessons from this history",children:[t.lessons.length?t.lessons.map(c=>e(vg,{text:c})):e("div",{class:"muted small",children:"Not enough history yet."}),t.stats.tracePending?e("div",{class:"muted small",style:{marginTop:6},children:[t.stats.tracePending," fixes still to trace; reload to continue."]}):null]}),e(j,{title:"changes that later needed fixing",children:[e("div",{class:"muted small",style:{marginBottom:6},children:"A fix removed lines these commits wrote. The pattern, not the blame, is the lesson: what kind of change tends to break here?"}),l.data?e(Ln,{commits:l.data,selected:null,onSelect:n,empty:"No traced fix origins yet."}):e(se,{})]})]})]})}function vg({text:t}){return e("div",{class:"lesson",children:[e("span",{class:"i",children:"\u25C6"}),e("span",{children:t})]})}function sd({params:t}){let[n,s]=x(t.tab||(t.file?"files":t.branch?"branches":"timeline")),[a,r]=x(t.sha??null);U(()=>{t.tab?s(t.tab):t.file?s("files"):t.branch&&s("branches")},[t.tab,t.file,t.branch]),U(()=>{t.sha&&r(t.sha)},[t.sha]);let o=V(()=>J("/api/history"),[]),i=d=>{r(d),s("timeline")};if(o.error)return e("div",{class:"page ds-page hist-page",children:e(Z,{error:o.error})});if(!o.data)return e("div",{class:"page ds-page hist-page",role:"status","aria-busy":"true",children:[e("section",{class:"ds-hero",children:e("div",{class:"ds-hero-main",children:[e(N,{w:120,h:12}),e(N,{w:"min(360px, 70%)",h:34})]})}),e(Re,{children:[0,1,2,3].map(()=>e("div",{class:"ds-stat",children:[e(N,{w:90,h:11}),e(N,{w:80,h:28})]}))})]});let l=o.data;if(!l.git)return e("div",{class:"page ds-page hist-page",children:e(X,{icon:"\u2387",title:"No git history",children:[l.error??"Not a git repository."," The history explorer reads `git log`; initialise a repository and commit to use it."]})});let c=l.stats,u=c.prior30?Math.round((c.last30-c.prior30)/c.prior30*100):null;return e("div",{class:"page ds-page hist-page",children:[e(Te,{eyebrow:"History",title:"Project history",sub:e(R,{children:[l.branch??"detached"," @ ",l.head.slice(0,7)," \xB7 built ",me(l.builtAt)]}),meta:e(R,{children:[e(I,{tone:"accent",children:[z(c.commits)," commits"]}),e(I,{tone:c.unmerged?"warn":"ok",children:c.unmerged?`${c.unmerged} unmerged`:"all merged"}),e("a",{class:"ds-link",onClick:()=>J("/api/history",{refresh:1}).then(()=>o.reload()),children:"rebuild"})]})}),e(Re,{children:[e(le,{label:"commits",value:c.commits,sub:`${c.onHead} on HEAD`}),e(le,{label:"last 30 days",value:c.last30,sub:u===null?`${c.prior30} in the 30 before`:`${u>=0?"+":""}${u}% vs prior 30`,tone:u===null?void 0:u>=0?"ok":"warn"}),e(le,{label:"fixes",value:c.fixes,sub:`${Math.round(c.fixes/Math.max(1,c.commits-c.merges)*100)}% \xB7 ${c.linksTraced} origins traced${c.tracePending?`, ${c.tracePending} pending`:""}`}),e(le,{label:"branches",value:c.branches,sub:`${c.unmerged?`${c.unmerged} unmerged`:"all merged"} \xB7 ${c.tags} tags`}),e(le,{label:"authors",value:c.authors,sub:`${c.files} files`}),e(le,{label:"working tree",value:c.workingTree,sub:l.branch??"detached"})]}),e("div",{class:"hist-nav",children:e(Se,{label:"History view",options:[{id:"timeline",label:"Timeline"},{id:"branches",label:"Branches"},{id:"files",label:"Files"},{id:"graph",label:"Graph"},{id:"risk",label:"Risk & lessons"}],value:n,onChange:d=>{s(d),H("history",{tab:d,sha:a??void 0})}})}),n==="timeline"&&e(mg,{ov:l,params:t,selected:a,onSelect:r}),n==="branches"&&e(gg,{ov:l,params:t,onSelectCommit:i}),n==="files"&&e(fg,{params:t,onSelectCommit:i}),n==="graph"&&e(Qc,{focus:t.focus}),n==="risk"&&e(yg,{ov:l,onSelectCommit:i})]})}function Oa(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var un=Oa();function gd(t){un=t}var ln={exec:()=>null};function jn(t){let n=[];return s=>{let a=Math.max(0,Math.min(3,s-1)),r=n[a];return r||(r=t(a),n[a]=r),r}}function ce(t,n=""){let s=typeof t=="string"?t:t.source,a={replace:(r,o)=>{let i=typeof o=="string"?o:o.source;return i=i.replace(Ne.caret,"$1"),s=s.replace(r,i),a},getRegex:()=>new RegExp(s,n)};return a}var wg=((t="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+t)}catch{return!1}})(),Ne={codeRemoveIndent:/^(?: {0,3}\t| {1,4})/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,endingSpaceTabChar:/[ \t]$/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,leadingSpaceTab:/^[ \t]+/,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,numericCharacterReference:/&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));/,numericCharacterReferenceOrAmpersand:/&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:jn(t=>new RegExp(`^ {0,${t}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:jn(t=>new RegExp(`^ {0,${t}}((?:-[ ]*){3,}|(?:_[ ]*){3,}|(?:\\*[ ]*){3,})(?:\\n+|$)`)),fencesBeginRegex:jn(t=>new RegExp(`^ {0,${t}}(?:\`\`\`|~~~)`)),headingBeginRegex:jn(t=>new RegExp(`^ {0,${t}}#`)),htmlBeginRegex:jn(t=>new RegExp(`^ {0,${t}}(?:</?(?:${os})(?: +|$|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`,"i")),blockquoteBeginRegex:jn(t=>new RegExp(`^ {0,${t}}>`))},kg=/^(?:[ \t]*(?:\n|$))+/,xg=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Sg=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,as=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,_g=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Na=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,hd=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |fences|blockquote|heading|hr|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,fd=ce(hd).replace(/bull/g,Na).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/hr/g,/ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Cg=ce(hd).replace(/bull/g,Na).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/hr/g,/ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Ba=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,$g=/^[^\n]+/,Ha=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Eg=ce(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Ha).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Tg=ce(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,Na).getRegex(),os="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Ua=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Rg=ce("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!(?:script|pre|style|textarea)(?![a-z0-9-]))([a-z][a-z0-9-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</[a-z][a-z0-9-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Ua).replace("tag",os).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),bd=t=>ce(Ba).replace("hr",as).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list",t).replace("html"," {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)").replace("tag",os).getRegex(),Ag=bd(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),Mg=bd(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),Dg=ce(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Mg).getRegex(),Ja={blockquote:Dg,code:xg,def:Eg,fences:Sg,heading:_g,hr:as,html:Rg,lheading:fd,list:Tg,newline:kg,paragraph:Ag,table:ln,text:$g},rd=ce("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",as).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html"," {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)").replace("tag",os).getRegex(),Lg={...Ja,lheading:Cg,table:rd,paragraph:ce(Ba).replace("hr",as).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",rd).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html"," {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)").replace("tag",os).getRegex()},jg={...Ja,html:ce(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Ua).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:ln,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:ce(Ba).replace("hr",as).replace("heading",` *#{1,6} *[^
|
|
16
|
+
]`).replace("lheading",fd).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Pg=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Ig=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,yd=/^( {2,}|\\)\n(?!\s*$)[ \t]*/,Fg=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Et=/[\p{P}\p{S}]/u,Pn=/[\s\p{P}\p{S}]/u,is=/[^\s\p{P}\p{S}]/u,Og=ce(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Pn).getRegex(),Ng=/[\p{Pi}\p{Ps}"']/u,vd=/(?!~)[\p{P}\p{S}]/u,Bg=/(?!~)[\s\p{P}\p{S}]/u,Hg=/(?:[^\s\p{P}\p{S}]|~)/u,Ug=ce(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",wg?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),wd=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,Jg=ce(wd,"u").replace(/punct/g,Et).getRegex(),Xg=ce(wd,"u").replace(/punct/g,vd).getRegex(),Gg=/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,Wg=ce(Gg,"u").replace(/openQuote/g,Ng).replace(/punct/g,Et).getRegex(),kd="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",zg=ce(kd,"gu").replace(/notPunctSpace/g,is).replace(/punctSpace/g,Pn).replace(/punct/g,Et).getRegex(),qg=ce(kd,"gu").replace(/notPunctSpace/g,Hg).replace(/punctSpace/g,Bg).replace(/punct/g,vd).getRegex(),Kg="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)",Vg=ce(Kg,"gu").replace(/notPunctSpace/g,is).replace(/punctSpace/g,Pn).replace(/punct/g,Et).getRegex(),Yg=ce("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,is).replace(/punctSpace/g,Pn).replace(/punct/g,Et).getRegex(),Zg="^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",Qg=ce(Zg,"gu").replace(/notPunctSpace/g,is).replace(/punctSpace/g,Pn).replace(/punct/g,Et).getRegex(),eh=ce(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Et).getRegex(),th="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",nh=ce(th,"gu").replace(/notPunctSpace/g,is).replace(/punctSpace/g,Pn).replace(/punct/g,Et).getRegex(),sh=ce(/\\(punct)/,"gu").replace(/punct/g,Et).getRegex(),rh=ce(/(`+)(?:[^`]|[^`][\s\S]*?[^`])\1(?!`)|`+|\\(punct)/,"gu").replace(/punct/g,Et).getRegex(),ah=ce(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),oh=ce(Ua).replace("(?:-->|$)","-->").getRegex(),ih=ce("^comment|^</[a-zA-Z][a-zA-Z0-9-]*\\s*>|^<[a-zA-Z][a-zA-Z0-9-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",oh).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),xd=/\[(?:\\[\s\S]|[^\[\]\\])*\]/,dr=ce(/(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/).replace("brackets",xd).getRegex(),lh=ce(/^!?\[(label)\]\([ \t\n]*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?[ \t\n]*\)/).replace("label",dr).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),ch=ce(/^!?\[(label)\]\[(ref)\]/).replace("label",dr).replace("ref",Ha).getRegex(),dh=ce(/^!?\[(ref)\](?:\[\])?/).replace("ref",Ha).getRegex(),ad=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\]){1,999}/,uh=ce(/(?:[^\[\]\\`]*(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\]))){0,999}?[^\[\]\\`]*?/).replace("brackets",xd).getRegex(),ph=ce("reflink|nolink(?!\\()","g").replace("reflink",ce(/^!?\[(label)\]\[(ref)\]/).replace("label",uh).replace("ref",ad).getRegex()).replace("nolink",ce(/^!?\[(ref)\](?:\[\])?/).replace("ref",ad).getRegex()).getRegex(),od=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,mh=/[A-Za-z0-9._+-]+@[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/,gh=ce(/(?:mailto:email|xmpp:email(?:\/[A-Za-z0-9@.]+)?)/).replace(/email/g,mh).getRegex(),Xa={_backpedal:ln,anyPunctuation:sh,anyPunctuationOutsideCode:rh,autolink:ah,blockSkip:Ug,br:yd,code:Ig,del:ln,delLDelim:ln,delRDelim:ln,emStrongLDelim:Jg,emStrongRDelimAst:zg,emStrongRDelimUnd:Yg,escape:Pg,link:lh,nolink:dh,punctuation:Og,reflink:ch,reflinkSearch:ph,tag:ih,text:Fg,url:ln},hh={...Xa,emStrongLDelim:Wg,emStrongRDelimAst:Vg,emStrongRDelimUnd:Qg,link:ce(/^!?\[(label)\]\((.*?)\)/).replace("label",dr).getRegex(),reflink:ce(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",dr).getRegex()},Ia={...Xa,emStrongRDelimAst:qg,emStrongLDelim:Xg,delLDelim:eh,delRDelim:nh,url:ce(/^emailProtocol|^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("emailProtocol",gh).replace("protocol",od).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:ce(/^(?:[^a-zA-Z0-9](?=emailProtocol)|(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9](?=emailProtocol)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))))/).replace("protocol",od).replace(/emailProtocol/g,/(?:mailto|xmpp):/).getRegex()},fh={...Ia,br:ce(yd).replace("{2,}","*").getRegex(),text:ce(Ia.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},lr={normal:Ja,gfm:Lg,pedantic:jg},ss={normal:Xa,gfm:Ia,breaks:fh,pedantic:hh},bh={"&":"&","<":"<",">":">",'"':""","'":"'"},id=t=>bh[t];function ct(t,n){if(n){if(Ne.escapeTest.test(t))return t.replace(Ne.escapeReplace,id)}else if(Ne.escapeTestNoEncode.test(t))return t.replace(Ne.escapeReplaceNoEncode,id);return t}function yh(t){return Ne.numericCharacterReference.test(t)?t.replace(Ne.numericCharacterReferenceOrAmpersand,(n,s,a)=>{if(s===void 0&&a===void 0)return"&";let r=s===void 0?Number.parseInt(a,16):Number.parseInt(s,10);return r===0||r>1114111||r>=55296&&r<=57343?"\uFFFD":r===38?"&":String.fromCodePoint(r)}):t}function ld(t){try{t=encodeURI(t).replace(Ne.percentDecode,"%")}catch{return null}return t}function cd(t,n){let s=t.replace(Ne.findPipe,(o,i,l)=>{let c=!1,u=i;for(;--u>=0&&l[u]==="\\";)c=!c;return c?"|":" |"}),a=s.split(Ne.splitPipe),r=0;if(a[0].trim()||a.shift(),a.length>0&&!a.at(-1)?.trim()&&a.pop(),n)if(a.length>n)a.splice(n);else for(;a.length<n;)a.push("");for(;r<a.length;r++)a[r]=a[r].trim().replace(Ne.slashPipe,"|");return a}function Bt(t,n,s){let a=t.length;if(a===0)return"";let r=0;for(;r<a;){let o=t.charAt(a-r-1);if(o===n&&!s)r++;else if(o!==n&&s)r++;else break}return t.slice(0,a-r)}function dd(t){let n=t.split(`
|
|
17
|
+
`),s=n.length-1;for(;s>=0&&Ne.blankLine.test(n[s]);)s--;return n.length-s<=2?t:n.slice(0,s+1).join(`
|
|
18
|
+
`)}function ur(t){return t.trim().toLowerCase().toUpperCase().toLowerCase()}function ud(t,n){if(t.indexOf(n[0])===-1&&t.indexOf(n[1])===-1)return-1;let s=0;for(let a=0;a<t.length;a++)if(t[a]==="\\")a++;else if(t[a]===n[0])s++;else if(t[a]===n[1]&&(s--,s<0))return a;return s>0?-2:-1}function Pa(t,n=0){let s=n,a="";for(let r of t)if(r===" "){let o=4-s%4;a+=" ".repeat(o),s+=o}else a+=r,s++;return a}function pd(t,n,s,a,r){let o=n.href,i=n.title||null,l=t[1].replace(r.other.outputLinkReplace,"$1"),c=t[0].charAt(0)==="!",u=a.state.inLink,d=a.state.linkEmitted,p=a.state.inRawBlock;a.state.inLink=!0,a.state.linkEmitted=!1;let g=a.inlineTokens(l),h=a.state.linkEmitted;if(a.state.linkEmitted=d,a.state.inLink=u,!c){if(h){a.state.inRawBlock=p;return}a.state.linkEmitted=!0}return{type:c?"image":"link",raw:s,href:o,title:i,text:l,tokens:g}}function vh(t,n,s){let a=t.match(s.other.indentCodeCompensation);if(a===null)return n;let r=a[1];return n.split(`
|
|
19
|
+
`).map(o=>{let i=o.match(s.other.beginningSpace);if(i===null)return o;let[l]=i;return o.slice(Math.min(l.length,r.length))}).join(`
|
|
20
|
+
`)}function md(t,n,s,a){if(!n.includes("<"))return!1;for(let r=0;r<n.length;r++){if(n[r]==="\\"){r++;continue}if(n[r]==="`"){let l=a.inline.code.exec(n.slice(r));if(l){r+=l[0].length-1;continue}}if(n[r]!=="<")continue;let o=t.slice(s+r),i=a.inline.tag.exec(o)||a.inline.autolink.exec(o);if(i){if(i[0].length>n.length-r)return!0;r+=i[0].length-1}}return!1}var pr=class{constructor(t){be(this,"options");be(this,"rules");be(this,"lexer");this.options=t||un}space(t){let n=this.rules.block.newline.exec(t);if(n&&n[0].length>0)return{type:"space",raw:n[0]}}code(t){let n=this.rules.block.code.exec(t);if(n){let s=this.options.pedantic?n[0]:dd(n[0]),a=s.replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:s,codeBlockStyle:"indented",text:a}}}fences(t){let n=this.rules.block.fences.exec(t);if(n){let s=n[0],a=vh(s,n[3]||"",this.rules);return{type:"code",raw:s,lang:n[2]?n[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):n[2],text:a}}}heading(t){let n=this.rules.block.heading.exec(t);if(n){let s=n[2].trim();if(this.rules.other.endingHash.test(s)){let a=Bt(s,"#");(this.options.pedantic||!a||this.rules.other.endingSpaceTabChar.test(a))&&(s=a.trim())}return{type:"heading",raw:Bt(n[0],`
|
|
21
|
+
`),depth:n[1].length,text:s,tokens:this.lexer.inline(s)}}}hr(t){let n=this.rules.block.hr.exec(t);if(n)return{type:"hr",raw:Bt(n[0],`
|
|
22
|
+
`)}}blockquote(t){let n=this.rules.block.blockquote.exec(t);if(n){let s=Bt(n[0],`
|
|
23
23
|
`).split(`
|
|
24
|
-
`),
|
|
25
|
-
`),u
|
|
26
|
-
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");
|
|
27
|
-
${
|
|
28
|
-
${
|
|
29
|
-
`),h
|
|
30
|
-
`+y.replace(this.rules.other.blockquoteSetextReplace2,""),
|
|
31
|
-
`).length:0,
|
|
32
|
-
${
|
|
33
|
-
`)}`),
|
|
24
|
+
`),a="",r="",o=[];for(;s.length>0;){let i=!1,l=[],c;for(c=0;c<s.length;c++)if(this.rules.other.blockquoteStart.test(s[c]))l.push(s[c]),i=!0;else if(!i)l.push(s[c]);else break;s=s.slice(c);let u=l.join(`
|
|
25
|
+
`),d=u.replace(this.rules.other.blockquoteSetextReplace,`
|
|
26
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");a=a?`${a}
|
|
27
|
+
${u}`:u,r=r?`${r}
|
|
28
|
+
${d}`:d;let p=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(d,o,!0),this.lexer.state.top=p,s.length===0)break;let g=o.at(-1);if(g?.type==="code"||g?.type==="heading"||g?.type==="hr"||g?.type==="html")break;if(g?.type==="blockquote"){let h=g,y=s.join(`
|
|
29
|
+
`),m=h.raw+`
|
|
30
|
+
`+y.replace(this.rules.other.blockquoteSetextReplace2,""),f=this.blockquote(m);o[o.length-1]=f;let v=m.substring(f.raw.length).replace(/^\n/,""),b=v?v.split(`
|
|
31
|
+
`).length:0,w=b?s.slice(0,-b):s;w.length>0&&(a=`${a}
|
|
32
|
+
${w.join(`
|
|
33
|
+
`)}`),r=r.substring(0,r.length-h.text.length)+f.text;break}else if(g?.type==="list"){let h=g,y=h.raw+`
|
|
34
34
|
`+s.join(`
|
|
35
|
-
`),
|
|
36
|
-
`);continue}}return{type:"blockquote",raw:
|
|
37
|
-
`,1)[0],y=n[1].length,
|
|
38
|
-
`,1)[0],
|
|
39
|
-
`,1)[0],
|
|
40
|
-
`+
|
|
41
|
-
`+
|
|
42
|
-
`),href:
|
|
43
|
-
`):[],
|
|
44
|
-
`),header:[],align:[],rows:[]};if(s.length===
|
|
35
|
+
`),m=this.list(y);o[o.length-1]=m,a=a.substring(0,a.length-g.raw.length)+m.raw,r=r.substring(0,r.length-h.raw.length)+m.raw,s=y.substring(o.at(-1).raw.length).split(`
|
|
36
|
+
`);continue}}return{type:"blockquote",raw:a,tokens:o,text:r}}}list(t){let n=this.rules.block.list.exec(t);if(n){let s=t,a=()=>s.length-t.length,r=n[1].trim(),o=r.length>1,i={type:"list",raw:"",ordered:o,start:o?+r.slice(0,-1):"",loose:!1,items:[]};r=o?`\\d{1,9}\\${r.slice(-1)}`:`\\${r}`,this.options.pedantic&&(r=o?r:"[*+-]");let l=this.rules.other.listItemRegex(r),c=!1;for(;t;){let d=!1,p="";if(!(n=l.exec(t))||this.rules.block.hr.test(t))break;let g=a();t=t.substring(n[0].length);let h=n[2].split(`
|
|
37
|
+
`,1)[0],y=n[1].length,m=this.options.pedantic?Pa(h,y):h.replace(this.rules.other.leadingSpaceTab,k=>Pa(k,y)),f=t.split(`
|
|
38
|
+
`,1)[0],v=!m.trim(),b=0;if(this.options.pedantic?(b=2,p=m.trimStart()):v?b=y+1:(b=m.search(this.rules.other.nonSpaceChar),b=b>4?1:b,p=m.slice(b),b+=y),v&&this.rules.other.blankLine.test(f)&&(t=t.substring(f.length+1),d=!0),!d){let k=this.rules.other.nextBulletRegex(b),C=this.rules.other.hrRegex(b),S=this.rules.other.fencesBeginRegex(b),_=this.rules.other.headingBeginRegex(b),T=this.rules.other.htmlBeginRegex(b),M=this.rules.other.blockquoteBeginRegex(b);for(;t;){let F=t.split(`
|
|
39
|
+
`,1)[0],D;if(f=F,this.options.pedantic?(f=f.replace(this.rules.other.listReplaceNesting," "),D=f):D=f.replace(this.rules.other.leadingSpaceTab,$=>Pa($)),S.test(f)||_.test(f)||T.test(f)||M.test(f)||k.test(f)||C.test(f))break;if(D.search(this.rules.other.nonSpaceChar)>=b||!f.trim())p+=`
|
|
40
|
+
`+D.slice(b);else{if(v||m.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||S.test(m)||_.test(m)||C.test(m))break;p+=`
|
|
41
|
+
`+f}v=!f.trim(),t=t.substring(F.length+1),m=D.slice(b)}}let w=s.slice(g,a());i.loose||(c?i.loose=!0:this.rules.other.doubleBlankLine.test(w)&&(c=!0)),i.items.push({type:"list_item",raw:w,task:!!this.options.gfm&&this.rules.other.listIsTask.test(p),loose:!1,text:p,tokens:[]})}let u=i.items.at(-1);if(u)u.raw=u.raw.trimEnd(),u.text=u.text.trimEnd();else return;i.raw=s.slice(0,a()).trimEnd();for(let d of i.items)if(this.lexer.state.top=!1,d.tokens=this.lexer.blockTokens(d.text,[]),!i.loose){let p=d.tokens.filter(h=>h.type==="space"),g=p.length>0&&p.some(h=>this.rules.other.anyLine.test(h.raw));i.loose=g}for(let d of i.items){let p=d.tokens[0];if(d.task&&(p?.type==="text"||p?.type==="paragraph")){d.text=d.text.replace(this.rules.other.listReplaceTask,""),p.raw=p.raw.replace(this.rules.other.listReplaceTask,""),p.text=p.text.replace(this.rules.other.listReplaceTask,"");for(let h=this.lexer.inlineQueue.length-1;h>=0;h--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[h].src)){this.lexer.inlineQueue[h].src=this.lexer.inlineQueue[h].src.replace(this.rules.other.listReplaceTask,"");break}let g=this.rules.other.listTaskCheckbox.exec(d.raw);if(g){let h={type:"checkbox",raw:g[0]+" ",checked:g[0]!=="[ ]"};d.checked=h.checked,i.loose?d.tokens[0]&&["paragraph","text"].includes(d.tokens[0].type)&&"tokens"in d.tokens[0]&&d.tokens[0].tokens?(d.tokens[0].raw=h.raw+d.tokens[0].raw,d.tokens[0].text=h.raw+d.tokens[0].text,d.tokens[0].tokens.unshift(h)):d.tokens.unshift({type:"paragraph",raw:h.raw,text:h.raw,tokens:[h]}):d.tokens.unshift(h)}}else d.task&&(d.task=!1)}if(i.loose)for(let d of i.items){d.loose=!0;for(let p of d.tokens)p.type==="text"&&(p.type="paragraph")}return i}}html(t){let n=this.rules.block.html.exec(t);if(n){let s=dd(n[0]);return{type:"html",block:!0,raw:s,pre:n[1]==="pre"||n[1]==="script"||n[1]==="style",text:s}}}def(t){let n=this.rules.block.def.exec(t);if(n){if(!this.rules.other.startAngleBracket.test(n[2])&&ud(n[2],"()")!==-1)return;let s=ur(n[1]).replace(this.rules.other.multipleSpaceGlobal," "),a=n[2]?n[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=n[3]?n[3].substring(1,n[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):n[3];return{type:"def",tag:s,raw:Bt(n[0],`
|
|
42
|
+
`),href:a,title:r}}}table(t){let n=this.rules.block.table.exec(t);if(!n||!this.rules.other.tableDelimiter.test(n[2]))return;let s=cd(n[1]),a=n[2].replace(this.rules.other.tableAlignChars,"").split("|"),r=n[3]?.trim()?n[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
43
|
+
`):[],o={type:"table",raw:Bt(n[0],`
|
|
44
|
+
`),header:[],align:[],rows:[]};if(s.length===a.length){for(let i of a)this.rules.other.tableAlignRight.test(i)?o.align.push("right"):this.rules.other.tableAlignCenter.test(i)?o.align.push("center"):this.rules.other.tableAlignLeft.test(i)?o.align.push("left"):o.align.push(null);for(let i=0;i<s.length;i++)o.header.push({text:s[i],tokens:this.lexer.inline(s[i]),header:!0,align:o.align[i]});for(let i of r)o.rows.push(cd(i,o.header.length).map((l,c)=>({text:l,tokens:this.lexer.inline(l),header:!1,align:o.align[c]})));return o}}lheading(t){let n=this.rules.block.lheading.exec(t);if(n){let s=n[1].trim();return{type:"heading",raw:Bt(n[0],`
|
|
45
45
|
`),depth:n[2].charAt(0)==="="?1:2,text:s,tokens:this.lexer.inline(s)}}}paragraph(t){let n=this.rules.block.paragraph.exec(t);if(n){let s=n[1].charAt(n[1].length-1)===`
|
|
46
|
-
`?n[1].slice(0,-1):n[1];return{type:"paragraph",raw:n[0],text:s,tokens:this.lexer.inline(s)}}}text(t){let n=this.rules.block.text.exec(t);if(n)return{type:"text",raw:n[0],text:n[0],tokens:this.lexer.inline(n[0])}}escape(t){let n=this.rules.inline.escape.exec(t);if(n)return{type:"escape",raw:n[0],text:n[1]}}tag(t){let n=this.rules.inline.tag.exec(t);if(n)return!this.lexer.state.inLink&&this.rules.other.startATag.test(n[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(n[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(n[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(n[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:n[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:n[0]}}link(t){if(this.lexer.state.linkParenPossible===!1)return;let n=this.rules.inline.link.exec(t);if(n){let s=n[0].charAt(0)==="!"?2:1;if(!this.options.pedantic&&
|
|
47
|
-
`),this.blockTokens(n,this.tokens);for(let s=0;s<this.inlineQueue.length;s++){let
|
|
48
|
-
`:s.push(
|
|
46
|
+
`?n[1].slice(0,-1):n[1];return{type:"paragraph",raw:n[0],text:s,tokens:this.lexer.inline(s)}}}text(t){let n=this.rules.block.text.exec(t);if(n)return{type:"text",raw:n[0],text:n[0],tokens:this.lexer.inline(n[0])}}escape(t){let n=this.rules.inline.escape.exec(t);if(n)return{type:"escape",raw:n[0],text:n[1]}}tag(t){let n=this.rules.inline.tag.exec(t);if(n)return!this.lexer.state.inLink&&this.rules.other.startATag.test(n[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(n[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(n[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(n[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:n[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:n[0]}}link(t){if(this.lexer.state.linkParenPossible===!1)return;let n=this.rules.inline.link.exec(t);if(n){let s=n[0].charAt(0)==="!"?2:1;if(!this.options.pedantic&&md(t,n[1],s,this.rules))return;let a=n[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(a)){if(!this.rules.other.endAngleBracket.test(a))return;let i=Bt(a.slice(0,-1),"\\");if((a.length-i.length)%2===0)return}else{let i=ud(n[2],"()");if(i===-2)return;if(i>-1){let l=(n[0].indexOf("!")===0?5:4)+n[1].length+i;n[2]=n[2].substring(0,i),n[0]=n[0].substring(0,l).trim(),n[3]=""}}let r=n[2],o="";if(this.options.pedantic){let i=this.rules.other.pedanticHrefTitle.exec(r);i&&(r=i[1],o=i[3])}else o=n[3]?n[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(a)?r=r.slice(1):r=r.slice(1,-1)),pd(n,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:o&&o.replace(this.rules.inline.anyPunctuation,"$1")},n[0],this.lexer,this.rules)}}reflink(t,n){let s;if((s=this.rules.inline.reflink.exec(t))||(s=this.rules.inline.nolink.exec(t))){let a=s[0].charAt(0)==="!"?2:1;if(!this.options.pedantic&&md(t,s[1],a,this.rules))return;let r=(s[2]||s[1]).replace(this.rules.other.multipleSpaceGlobal," "),o=n[ur(r)];if(!o){let i=s[0].charAt(0);return{type:"text",raw:i,text:i}}return pd(s,o,s[0],this.lexer,this.rules)}}emStrong(t,n,s=""){let a=this.rules.inline.emStrongLDelim.exec(t);if(!(!a||!a[1]&&!a[2]&&!a[3]&&!a[4]||a[4]&&s.match(this.rules.other.unicodeAlphaNumeric))&&(!(a[1]||a[3])||!s||this.rules.inline.punctuation.exec(s))){let r=[...a[0]].length-1,o,i,l=r,c=0,u=a[0][0],d=s===u,p=u==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(p.lastIndex=0,n=n.slice(-1*t.length+r);(a=p.exec(n))!==null;){if(o=a[1]||a[2]||a[3]||a[4]||a[5]||a[6],!o)continue;if(i=[...o].length,a[3]||a[4]){l+=i;continue}else if(a[5]||a[6]){if(r%3&&!((r+i)%3)){c+=i;continue}if(d)break}if(l-=i,l>0)continue;i=Math.min(i,i+l+c);let g=[...a[0]][0].length,h=t.slice(0,r+a.index+g+i);if(Math.min(r,i)%2){let m=h.slice(1,-1);return{type:"em",raw:h,text:m,tokens:this.lexer.inlineTokens(m)}}let y=h.slice(2,-2);return{type:"strong",raw:h,text:y,tokens:this.lexer.inlineTokens(y)}}}}codespan(t){let n=this.rules.inline.code.exec(t);if(n){let s=n[2].replace(this.rules.other.newLineCharGlobal," "),a=this.rules.other.nonSpaceChar.test(s),r=this.rules.other.startingSpaceChar.test(s)&&this.rules.other.endingSpaceChar.test(s);return a&&r&&(s=s.substring(1,s.length-1)),{type:"codespan",raw:n[0],text:s}}}br(t){let n=this.rules.inline.br.exec(t);if(n)return{type:"br",raw:n[0]}}del(t,n,s=""){let a=this.rules.inline.delLDelim.exec(t);if(a&&(!a[1]||!s||this.rules.inline.punctuation.exec(s))){let r=[...a[0]].length-1,o,i,l=r,c=this.rules.inline.delRDelim;for(c.lastIndex=0,n=n.slice(-1*t.length+r);(a=c.exec(n))!==null;){if(o=a[1]||a[2]||a[3]||a[4]||a[5]||a[6],!o||(i=[...o].length,i!==r))continue;if(a[3]||a[4]){l+=i;continue}if(l-=i,l>0)continue;i=Math.min(i,i+l);let u=[...a[0]][0].length,d=t.slice(0,r+a.index+u+i),p=d.slice(r,-r);return{type:"del",raw:d,text:p,tokens:this.lexer.inlineTokens(p)}}}}autolink(t){let n=this.rules.inline.autolink.exec(t);if(n){let s,a;return n[2]==="@"?(s=n[1],a="mailto:"+s):(s=n[1],a=s),{type:"link",raw:n[0],text:s,href:a,autolink:!0,tokens:[{type:"text",raw:s,text:s}]}}}url(t){let n;if(n=this.rules.inline.url.exec(t)){let s,a;if(n[2]==="@")s=n[0],a="mailto:"+s;else{let r;do r=n[0],n[0]=this.rules.inline._backpedal.exec(n[0])?.[0]??"";while(r!==n[0]);s=n[0],n[1]==="www."?a="http://"+n[0]:a=n[0]}return{type:"link",raw:n[0],text:s,href:a,autolink:!0,tokens:[{type:"text",raw:s,text:s}]}}}inlineText(t){let n=this.rules.inline.text.exec(t);if(n){let s=this.lexer.state.inRawBlock;return{type:"text",raw:n[0],text:s?n[0]:yh(n[0]),escaped:s}}}},gr,Sd,cn,bt=(cn=class{constructor(n){Do(this,gr);be(this,"tokens");be(this,"options");be(this,"state");be(this,"inlineQueue");be(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=n||un,this.options.tokenizer=this.options.tokenizer||new pr,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,linkEmitted:!1,linkParenPossible:!0,top:!0};let s={other:Ne,block:lr.normal,inline:ss.normal};this.options.pedantic?(s.block=lr.pedantic,s.inline=ss.pedantic):this.options.gfm&&(s.block=lr.gfm,this.options.breaks?s.inline=ss.breaks:s.inline=ss.gfm),this.tokenizer.rules=s}static get rules(){return{block:lr,inline:ss}}static lex(n,s){return new cn(s).lex(n)}static lexInline(n,s){return new cn(s).inlineTokens(n)}lex(n){n=n.replace(Ne.carriageReturn,`
|
|
47
|
+
`),this.blockTokens(n,this.tokens);for(let s=0;s<this.inlineQueue.length;s++){let a=this.inlineQueue[s];this.inlineTokens(a.src,a.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(n,s=[],a=!1){this.tokenizer.lexer=this,this.options.pedantic&&(n=n.replace(Ne.tabCharGlobal," ").replace(Ne.spaceLine,""));let r=1/0;for(;n;){if(n.length<r)r=n.length;else{this.infiniteLoopError(n.charCodeAt(0));break}let o;if(this.options.extensions?.block?.some(l=>(o=l.call({lexer:this},n,s))?(n=n.substring(o.raw.length),s.push(o),!0):!1))continue;if(o=this.tokenizer.space(n)){n=n.substring(o.raw.length);let l=s.at(-1);o.raw.length===1&&l!==void 0?l.raw+=`
|
|
48
|
+
`:s.push(o);continue}if(o=this.tokenizer.code(n)){n=n.substring(o.raw.length);let l=s.at(-1);l?.type==="paragraph"||l?.type==="text"?(l.raw+=(l.raw.endsWith(`
|
|
49
49
|
`)?"":`
|
|
50
|
-
`)+
|
|
51
|
-
`+
|
|
50
|
+
`)+o.raw,l.text+=`
|
|
51
|
+
`+o.text,this.inlineQueue.at(-1).src=l.text):s.push(o);continue}if(o=this.tokenizer.fences(n)){n=n.substring(o.raw.length),s.push(o);continue}if(o=this.tokenizer.heading(n)){n=n.substring(o.raw.length),s.push(o);continue}if(o=this.tokenizer.hr(n)){n=n.substring(o.raw.length),s.push(o);continue}if(o=this.tokenizer.blockquote(n)){n=n.substring(o.raw.length),s.push(o);continue}if(o=this.tokenizer.list(n)){n=n.substring(o.raw.length),s.push(o);continue}if(o=this.tokenizer.html(n)){n=n.substring(o.raw.length),s.push(o);continue}if(o=this.tokenizer.def(n)){n=n.substring(o.raw.length);let l=s.at(-1);l?.type==="paragraph"||l?.type==="text"?(l.raw+=(l.raw.endsWith(`
|
|
52
52
|
`)?"":`
|
|
53
|
-
`)+
|
|
54
|
-
`+
|
|
53
|
+
`)+o.raw,l.text+=`
|
|
54
|
+
`+o.raw,this.inlineQueue.at(-1).src=l.text):this.tokens.links[o.tag]||(this.tokens.links[o.tag]={href:o.href,title:o.title},s.push(o));continue}if(o=this.tokenizer.table(n)){n=n.substring(o.raw.length),s.push(o);continue}if(o=this.tokenizer.lheading(n)){n=n.substring(o.raw.length),s.push(o);continue}let i=n;if(this.options.extensions?.startBlock){let l=1/0,c=n.slice(1),u;this.options.extensions.startBlock.forEach(d=>{u=d.call({lexer:this},c),typeof u=="number"&&u>=0&&(l=Math.min(l,u))}),l<1/0&&l>=0&&(i=n.substring(0,l+1))}if(this.state.top&&(o=this.tokenizer.paragraph(i))){let l=s.at(-1);a&&l?.type==="paragraph"?(l.raw+=(l.raw.endsWith(`
|
|
55
55
|
`)?"":`
|
|
56
|
-
`)+
|
|
57
|
-
`+
|
|
56
|
+
`)+o.raw,l.text+=`
|
|
57
|
+
`+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=l.text):s.push(o),a=i.length!==n.length,n=n.substring(o.raw.length);continue}if(o=this.tokenizer.text(n)){n=n.substring(o.raw.length);let l=s.at(-1);l?.type==="text"?(l.raw+=(l.raw.endsWith(`
|
|
58
58
|
`)?"":`
|
|
59
|
-
`)+
|
|
60
|
-
`+
|
|
61
|
-
`:"";return
|
|
62
|
-
`:"<pre><code>"+(s?
|
|
59
|
+
`)+o.raw,l.text+=`
|
|
60
|
+
`+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=l.text):s.push(o);continue}if(n){this.infiniteLoopError(n.charCodeAt(0));break}}return this.state.top=!0,s}inline(n,s=[]){return this.inlineQueue.push({src:n,tokens:s}),s}linkInText(n){if(!n.includes("["))return!1;let s=this.tokenizer.rules.inline.link;for(let a of n.matchAll(this.tokenizer.rules.inline.blockSkip))if(s.test(a[0])&&n.charAt(a.index-1)!=="!")return!0;for(let a of n.matchAll(this.tokenizer.rules.inline.reflinkSearch)){let r=a[0],o=r.lastIndexOf("[");if(!(r.charAt(0)==="!"||!Object.hasOwn(this.tokens.links,ur(r.slice(o+1,-1))))&&!(o>1&&this.linkInText(r.slice(1,o-1))))return!0}return!1}inlineTokens(n,s=[]){this.tokenizer.lexer=this;let a=this.state.linkParenPossible;this.state.linkParenPossible=a&&n.includes(")");try{return Lo(this,gr,Sd).call(this,n,s)}finally{this.state.linkParenPossible=a}}infiniteLoopError(n){let s="Infinite loop on byte: "+n;if(this.options.silent)console.error(s);else throw new Error(s)}},gr=new WeakSet,Sd=function(n,s){let a=n;if(this.tokens.links&&n.includes("[")){let l=this.tokenizer.rules.inline.reflinkSearch,c=u=>{let d=u.lastIndexOf("[");if(!Object.hasOwn(this.tokens.links,ur(u.slice(d+1,-1))))return u;if(d>1&&u.charAt(0)!=="!"){let p=u.slice(1,d-1);if(this.linkInText(p))return"["+p.replace(l,c)+"]["+"a".repeat(u.length-d-2)+"]"}return"["+"a".repeat(u.length-2)+"]"};a=a.replace(l,c)}a=a.replace(this.tokenizer.rules.inline.anyPunctuationOutsideCode,(l,c,u)=>u?"+".repeat(l.length):c?c+l.slice(c.length,-c.length).replace(/`/g,"+")+c:l),a=a.replace(this.tokenizer.rules.inline.blockSkip,(l,c,u)=>{let d=u?u.length:0;return l.slice(0,d)+"["+"a".repeat(l.length-d-2)+"]"}),a=this.options.hooks?.emStrongMask?.call({lexer:this},a)??a;let r=!1,o="",i=1/0;for(;n;){if(n.length<i)i=n.length;else{this.infiniteLoopError(n.charCodeAt(0));break}r||(o=""),r=!1;let l;if(this.options.extensions?.inline?.some(u=>(l=u.call({lexer:this},n,s))?(n=n.substring(l.raw.length),s.push(l),!0):!1))continue;if(l=this.tokenizer.escape(n)){n=n.substring(l.raw.length),s.push(l);continue}if(l=this.tokenizer.tag(n)){n=n.substring(l.raw.length),s.push(l);continue}if(l=this.tokenizer.link(n)){n=n.substring(l.raw.length),s.push(l);continue}if(l=this.tokenizer.reflink(n,this.tokens.links)){n=n.substring(l.raw.length);let u=s.at(-1);l.type==="text"&&u?.type==="text"?(u.raw+=l.raw,u.text+=l.text):s.push(l);continue}if(l=this.tokenizer.emStrong(n,a,o)){n=n.substring(l.raw.length),s.push(l);continue}if(l=this.tokenizer.codespan(n)){n=n.substring(l.raw.length),s.push(l);continue}if(l=this.tokenizer.br(n)){n=n.substring(l.raw.length),s.push(l);continue}if(l=this.tokenizer.del(n,a,o)){n=n.substring(l.raw.length),s.push(l);continue}if(l=this.tokenizer.autolink(n)){n=n.substring(l.raw.length),s.push(l);continue}if(!this.state.inLink&&(l=this.tokenizer.url(n))){n=n.substring(l.raw.length),s.push(l);continue}let c=n;if(this.options.extensions?.startInline){let u=1/0,d=n.slice(1),p;this.options.extensions.startInline.forEach(g=>{p=g.call({lexer:this},d),typeof p=="number"&&p>=0&&(u=Math.min(u,p))}),u<1/0&&u>=0&&(c=n.substring(0,u+1))}if(l=this.tokenizer.inlineText(c)){n=n.substring(l.raw.length),l.raw.slice(-1)!=="_"&&(o=l.raw.slice(-1)),r=!0;let u=s.at(-1);u?.type==="text"?(u.raw+=l.raw,u.text+=l.text):s.push(l);continue}if(n){this.infiniteLoopError(n.charCodeAt(0));break}}return s},cn),mr=class{constructor(t){be(this,"options");be(this,"parser");this.options=t||un}space(t){return""}code({text:t,lang:n,escaped:s}){let a=(n||"").match(Ne.notSpaceStart)?.[0],r=t?t.replace(Ne.endingNewline,"")+`
|
|
61
|
+
`:"";return a?'<pre><code class="language-'+ct(a)+'">'+(s?r:ct(r,!0))+`</code></pre>
|
|
62
|
+
`:"<pre><code>"+(s?r:ct(r,!0))+`</code></pre>
|
|
63
63
|
`}blockquote({tokens:t}){return`<blockquote>
|
|
64
64
|
${this.parser.parse(t)}</blockquote>
|
|
65
65
|
`}html({text:t}){return t}def(t){return""}heading({tokens:t,depth:n}){return`<h${n}>${this.parser.parseInline(t)}</h${n}>
|
|
66
66
|
`}hr(t){return`<hr>
|
|
67
|
-
`}list(t){let n=t.ordered,s=t.start,
|
|
68
|
-
`+
|
|
67
|
+
`}list(t){let n=t.ordered,s=t.start,a="";for(let i=0;i<t.items.length;i++){let l=t.items[i];a+=this.listitem(l)}let r=n?"ol":"ul",o=n&&s!==1?' start="'+s+'"':"";return"<"+r+o+`>
|
|
68
|
+
`+a+"</"+r+`>
|
|
69
69
|
`}listitem(t){return`<li>${this.parser.parse(t.tokens)}</li>
|
|
70
70
|
`}checkbox({checked:t}){return"<input "+(t?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:t}){return`<p>${this.parser.parseInline(t)}</p>
|
|
71
|
-
`}table(t){let n="",s="";for(let
|
|
71
|
+
`}table(t){let n="",s="";for(let r=0;r<t.header.length;r++)s+=this.tablecell(t.header[r]);n+=this.tablerow({text:s});let a="";for(let r=0;r<t.rows.length;r++){let o=t.rows[r];s="";for(let i=0;i<o.length;i++)s+=this.tablecell(o[i]);a+=this.tablerow({text:s})}return a&&(a=`<tbody>${a}</tbody>`),`<table>
|
|
72
72
|
<thead>
|
|
73
73
|
`+n+`</thead>
|
|
74
|
-
`+
|
|
74
|
+
`+a+`</table>
|
|
75
75
|
`}tablerow({text:t}){return`<tr>
|
|
76
76
|
${t}</tr>
|
|
77
77
|
`}tablecell(t){let n=this.parser.parseInline(t.tokens),s=t.header?"th":"td";return(t.align?`<${s} align="${t.align}">`:`<${s}>`)+n+`</${s}>
|
|
78
|
-
`}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>${
|
|
79
|
-
Please report this to https://github.com/markedjs/marked.`,t){let
|
|
80
|
-
`),[t.text,s]);return e("pre",{class:"code","data-lang":n||void 0,children:e("code",{dangerouslySetInnerHTML:{__html:
|
|
81
|
-
`).find(n=>n.trim())?.replace(/^#+\s*/,"").slice(0,120)??""}var vl={kind:"fact",tags:"",related:"",body:"",name:"",status:"",supersedes:""};function yl(t){return{kind:t.kind,tags:t.tags.join(", "),related:t.related.join(", "),body:t.body,name:t.name,status:t.status??"",supersedes:t.supersedes??""}}function xp({name:t,kinds:n,statuses:s,onSaved:r,onDeleted:a}){let i=X(()=>t?O("/api/memories",{name:t}):Promise.resolve(void 0),[t]),[o,l]=_(!t),[c,d]=_(!1),[u,p]=_(vl),[f,g]=_(!1);J(()=>{l(!t),d(!1)},[t]),J(()=>{let x=i.data;t&&x&&p(yl(x)),t||p(vl)},[t,i.data]);let y=x=>$=>p({...u,[x]:$.target.value}),h=()=>{l(!1),d(!1)},m=async()=>{if(!u.body.trim())return Y("body required",!0);g(!0);try{let x={kind:u.kind,content:u.body,tags:u.tags,related:u.related,status:u.status||void 0,supersedes:u.supersedes||void 0},$=t?await he("/api/memories",x,"PUT",{name:t}):await he("/api/memories",{...x,name:u.name.trim()||void 0});Y(`${t?"saved":"created"} ${$.name}${$.superseded?` \xB7 ${$.superseded} marked superseded`:""}`),t===$.name&&i.reload(),r($.name),h()}catch(x){Y(x.message,!0)}finally{g(!1)}},b=()=>{i.data&&p(yl(i.data)),h()},v=async()=>{if(!(!t||!confirm(`Delete memory "${t}" and its file?`)))try{await xn("/api/memories",{name:t}),Y(`deleted ${t}`),a()}catch(x){Y(x.message,!0)}},k=async()=>{if(!t)return;let x=prompt("New name (topic/slug):",t);if(!(!x||x===t))try{let $=await he("/api/memories",{to:x},"PATCH",{name:t});Y(`renamed \u2192 ${$.name}${$.refsUpdated?` (${$.refsUpdated} references updated)`:""}`),r($.name)}catch($){Y($.message,!0)}},w=x=>{(x.metaKey||x.ctrlKey)&&x.key.toLowerCase()==="s"?(x.preventDefault(),m()):x.key==="Escape"&&t&&(x.preventDefault(),b())};if(t&&i.error)return e(W,{error:i.error});if(t&&!i.data)return e(N,{});let S=i.data,E=u.kind==="decision";return t&&S&&!o?e("div",{children:[e("div",{class:"row",style:{marginBottom:6},children:[e("b",{class:"grow break",children:t}),e("button",{type:"button",class:"sm primary",onClick:()=>l(!0),children:"edit"}),e("button",{type:"button",class:"sm",onClick:k,children:"rename"}),e("button",{type:"button",class:"sm",title:"this memory in the knowledge graph",onClick:()=>U("memory",{tab:"graph",focus:`memory:${t}`}),children:"graph"}),e("button",{type:"button",class:"sm danger",onClick:v,children:"delete"})]}),e("div",{class:"muted small",style:{marginBottom:8},children:[S.path," \xB7 created ",S.created.slice(0,10)," \xB7 updated ",S.updated.slice(0,10)]}),e("div",{class:"row tight mem-refs",style:{marginBottom:12},children:[e(kr,{m:S}),S.tags.map(x=>e("span",{class:"tag",children:["#",x]})),S.related.map(x=>e(bl,{value:x})),S.supersedes?e("span",{class:"muted small",children:["supersedes ",e(bl,{value:`mem:${S.supersedes}`})]}):null]}),e(os,{source:S.body})]}):e("div",{children:[e("div",{class:"row",style:{marginBottom:6},children:[e("b",{class:"grow break",children:t??"New memory"}),t?e(j,{children:[e("span",{class:"muted small",children:"editing"}),e("button",{type:"button",class:"sm",onClick:k,children:"rename"}),e("button",{type:"button",class:"sm danger",onClick:v,children:"delete"})]}):null]}),t&&S?e("div",{class:"muted small",style:{marginBottom:8},children:[S.path," \xB7 created ",S.created.slice(0,10)," \xB7 updated ",S.updated.slice(0,10)]}):e("div",{class:"field",children:[e("label",{children:"name (topic/slug, optional \u2014 derived from kind + content)"}),e("input",{type:"text",placeholder:"auth/session-tokens",value:u.name,onInput:y("name")})]}),e("div",{class:"grid",style:{gridTemplateColumns:E?"1fr 1fr 2fr 2fr":"1fr 2fr 2fr",gap:8,marginBottom:0},children:[e("div",{class:"field",children:[e("label",{children:"kind"}),e("select",{value:u.kind,onChange:y("kind"),children:n.map(x=>e("option",{value:x,children:x}))})]}),E&&e("div",{class:"field",children:[e("label",{children:"status"}),e("select",{value:u.status,onChange:y("status"),children:[e("option",{value:"",children:"accepted (default)"}),s.map(x=>e("option",{value:x,children:x}))]})]}),e("div",{class:"field",children:[e("label",{children:"tags (comma separated)"}),e("input",{type:"text",value:u.tags,onInput:y("tags")})]}),e("div",{class:"field",children:[e("label",{children:"related (file:path, sym:path#Name, mem:name)"}),e("input",{type:"text",value:u.related,onInput:y("related")})]})]}),E&&e("div",{class:"field",children:[e("label",{children:"supersedes (name of the decision this replaces; it is marked superseded on save)"}),e("input",{type:"text",placeholder:"decision/old-approach",value:u.supersedes,onInput:y("supersedes")})]}),e("div",{class:"field",children:[e("div",{class:"row tight",children:[e("label",{class:"grow",children:"body (raw markdown)"}),e("a",{class:"small",onClick:()=>d(!c),children:c?"back to markdown":"preview"})]}),c?e(os,{class:"preview",source:u.body.trim()?u.body:"_Nothing to preview yet._"}):e("textarea",{value:u.body,onInput:y("body"),onKeyDown:w,spellcheck:!1})]}),e("div",{class:"row",children:[e("button",{type:"button",class:"primary",disabled:f,onClick:m,children:f?e(N,{}):t?"Save":"Create"}),t?e("button",{type:"button",disabled:f,onClick:b,children:"Cancel"}):null,e("span",{class:"muted small",children:["\u2318S / Ctrl+S saves",t?", Esc cancels":""]})]})]})}function _p({rows:t}){let n=new Map;for(let s of t)(n.get(s.topic||"(no topic)")??n.set(s.topic||"(no topic)",[]).get(s.topic||"(no topic)")).push(s);return t.length?e("div",{class:"stack",children:[...n.entries()].sort().map(([s,r])=>e("div",{class:"card",children:[e("h3",{children:s}),r.map(a=>e("div",{style:{padding:"8px 0",borderBottom:"1px solid var(--line)"},children:[e("div",{class:"row tight",children:[e("b",{children:a.name}),e(kr,{m:a}),e("span",{class:"muted small",children:Te(a.updated_at)}),e("span",{class:"spacer"}),e("a",{class:"small",onClick:()=>U("memory",{name:a.name}),children:"open"})]}),a.supersedes?e("div",{class:"muted small",children:["supersedes ",a.supersedes]}):null,e("div",{style:{marginTop:6,fontSize:13},children:e(os,{source:a.content})})]}))]}))}):e(B,{children:'No accepted decisions yet. Record one with kind "decision", or ask Claude to em_remember it.'})}function kl({params:t}){let[n,s]=_(t.name?.startsWith("decision/")?"decision":t.tab??"all"),[r,a]=_(t.name??null),[i,o]=_(!1),[l,c]=_(""),[d,u]=_(""),p=X(()=>O("/api/memories"),[]);J(()=>{t.name&&(a(t.name),o(!1),s(h=>h==="graph"||h==="record"?t.name.startsWith("decision/")?"decision":"all":h))},[t.name]),J(()=>{t.tab&&s(t.tab)},[t.tab]),J(()=>{p.data?.gitignored&&Y(`.gitignore keeps ${p.data.dir} out of git; memories stay local`,!0),p.data?.skipped.length&&Y(`skipped invalid memory files: ${p.data.skipped.join(", ")}`,!0)},[p.data]);let f=Z(()=>{let h=p.data?.memories??[],m=l.trim().toLowerCase();return h.filter(b=>(n==="all"||n==="record"||b.kind===n)&&(!d||(b.status??"accepted")===d)&&(!m||b.name.includes(m)||b.tags.some(v=>v.includes(m))||b.content.toLowerCase().includes(m)))},[p.data,n,l,d]);if(p.error)return e("div",{class:"page",children:e(W,{error:p.error})});let g=p.data,y=[["all","All"],...(g?.kinds??[]).map(h=>[h,h]),["record","Decision record"],["graph","Graph"]];return e("div",{class:"page",children:[e(Re,{tabs:y,value:n,onChange:h=>{s(h),h!=="decision"&&u(""),(h==="graph"||t.tab)&&U("memory",{tab:h})}}),n==="graph"?e(Wn,{scope:"memory",focus:t.focus}):n==="record"?e(_p,{rows:(g?.memories??[]).filter(h=>h.kind==="decision"&&(h.status??"accepted")==="accepted")}):e(j,{children:[e("div",{class:"row",style:{marginBottom:12},children:[e("button",{type:"button",class:"primary",onClick:()=>{o(!0),a(null)},children:"+ New memory"}),e("input",{type:"search",class:"grow",placeholder:"filter by name, tag or text\u2026",value:l,onInput:h=>c(h.target.value)}),n==="decision"&&e("select",{value:d,onChange:h=>u(h.target.value),children:[e("option",{value:"",children:"any status"}),(g?.statuses??[]).map(h=>e("option",{value:h,children:h}))]}),e("button",{type:"button",title:"re-import files edited by hand",onClick:async()=>{let h=await he("/api/actions",{action:"reconcile"});Y(h.output,!h.ok),p.reload()},children:"\u21BB Reconcile"}),e("span",{class:"muted small",children:[f.length," of ",g?.memories.length??0]})]}),e("div",{class:"grid wide",style:{gridTemplateColumns:"minmax(280px,1fr) minmax(0,2fr)",alignItems:"start"},children:[e("div",{class:"card flush",children:e("div",{class:"list",children:g?f.length?f.map(h=>e("div",{class:A("item",r===h.name&&"sel"),onClick:()=>{a(h.name),o(!1)},children:[e("div",{class:"n",children:h.name}),e("div",{class:"p",children:[e(kr,{m:h}),e("span",{class:"muted",children:[Te(h.updated_at)," \xB7 ",q(h.size??0),"B"]})]}),e("div",{class:"p",children:wp(h.content)})]})):e(B,{children:"no memories match"}):e(B,{children:e(N,{})})})}),e("div",{class:"card",children:i||r?e(xp,{name:i?null:r,kinds:g?.kinds??[],statuses:g?.statuses??[],onSaved:h=>{o(!1),a(h),p.reload()},onDeleted:()=>{a(null),p.reload()}}):e(B,{children:"Select a memory, or create a new one."})})]})]}),e("div",{style:{display:"none"},children:e(P,{children:"x"})})]})}function wl({rows:t}){let n=[...t].sort((s,r)=>r.raw_chars-s.raw_chars);return e("table",{children:[e("thead",{children:e("tr",{children:[e("th",{children:"tool"}),e("th",{class:"num",children:"calls"}),e("th",{class:"num",children:"seen"}),e("th",{class:"num",children:"returned"}),e("th",{class:"num",children:"saved"})]})}),e("tbody",{children:n.length?n.map(s=>{let r=Math.ceil(s.raw_chars/4),a=Math.ceil(s.returned_chars/4);return e("tr",{children:[e("td",{children:s.tool}),e("td",{class:"num",children:s.calls}),e("td",{class:"num",children:q(r)}),e("td",{class:"num",children:q(a)}),e("td",{class:"num",children:q(Math.max(0,r-a))})]})}):e("tr",{children:e("td",{class:"muted",colSpan:5,children:"no calls yet"})})})]})}function xl(){let t=X(()=>O("/api/stats"),[]);if(t.error)return e("div",{class:"page",children:e(W,{error:t.error})});let n=t.data;if(!n)return e("div",{class:"page",children:e(N,{})});let s=[["session saved",q(n.session.savedTokens),`${Oe(n.session.efficiency)} efficient \xB7 ${n.session.calls} calls`],["project saved",q(n.projectTotals.savedTokens),`${Oe(n.projectTotals.efficiency)} efficient \xB7 ${n.projectTotals.calls} calls`],["lifetime saved",q(n.lifetime.savedTokens),`${Oe(n.lifetime.efficiency)} efficient \xB7 ${n.lifetime.calls} calls`],["documents",String(n.index.documents),e(j,{children:[n.index.vectors," vectors",n.index.pendingEmbeddings?e("span",{class:"warn",children:" \xB7 backlog"}):null]})],["memories",String(n.index.memories),`${n.onboarding.length}/4 onboarding`],["graph",`${n.index.graph.nodes} nodes`,`${n.index.graph.edges} edges`]],r=Math.max(1,...n.daily.map(i=>i.saved_chars)),a=["overview","structure","commands","conventions"].filter(i=>!n.onboarding.includes(i));return e("div",{class:"page",children:[e("div",{class:"grid",children:s.map(([i,o,l])=>e("div",{class:"card",children:[e("h3",{children:i}),e("div",{class:"big",children:o}),e("div",{class:"sub",children:l})]}))}),e("div",{class:"grid wide",children:[e("div",{class:"card",children:[e("h3",{children:["tokens saved per day",e("span",{class:"right",children:n.daily.length?`${n.daily[0]?.day} \u2192 ${n.daily[n.daily.length-1]?.day}`:""})]}),e("div",{class:"bars",children:n.daily.length?n.daily.map(i=>e("div",{title:`${i.day}: ${q(Math.ceil(i.saved_chars/4))} tokens, ${i.calls} calls`,style:{height:`${Math.max(2,100*i.saved_chars/r)}%`}})):e("div",{class:"muted",children:"no data yet"})})]}),e("div",{class:"card",children:[e("h3",{children:"system"}),e(Ae,{rows:[["project",n.project],["database",n.dbPath],["routing",n.routing],["embeddings",n.index.embeddings],["memories dir",n.memoriesDir],["onboarding",a.length?e("span",{class:"warn",children:["missing: ",a.join(", ")," \u2014 run /eminiar:em-onboard"]}):e("span",{class:"ok",children:"complete"})],["session",n.session.id]]})]})]}),e("div",{class:"grid two",children:[e("div",{class:"card",children:[e("h3",{children:"this session \xB7 by tool"}),e(wl,{rows:n.session.tools})]}),e("div",{class:"card",children:[e("h3",{children:"lifetime \xB7 by tool"}),e(wl,{rows:n.lifetime.tools})]})]}),e("div",{class:"grid",children:[e("div",{class:"card",children:[e("h3",{children:"index by source"}),e("table",{children:e("tbody",{children:Object.entries(n.index.bySource).filter(([,i])=>i).map(([i,o])=>e("tr",{children:[e("td",{children:i}),e("td",{class:"num",children:o})]}))})})]}),e("div",{class:"card",children:[e("h3",{children:"graph by edge kind"}),e("table",{children:e("tbody",{children:Object.entries(n.index.graph.byKind??{}).sort((i,o)=>o[1]-i[1]).map(([i,o])=>e("tr",{children:[e("td",{children:i}),e("td",{class:"num",children:o})]}))})})]}),e("div",{class:"card",style:{gridColumn:"span 2"},children:[e("h3",{children:["recent sessions"," ",e("a",{class:"right",onClick:()=>U("sessions"),children:"all \u2192"})]}),e("table",{children:[e("thead",{children:e("tr",{children:[e("th",{children:"started"}),e("th",{children:"session"}),e("th",{children:"last prompt"}),e("th",{class:"num",children:"calls"}),e("th",{class:"num",children:"saved"})]})}),e("tbody",{children:n.sessions.map(i=>e("tr",{children:[e("td",{class:"muted",children:[te(i.started_at)," ",i.current?e(P,{children:"current"}):null]}),e("td",{children:e("code",{children:i.id.slice(0,8)})}),e("td",{class:"muted",children:(i.last_prompt??"").slice(0,90)}),e("td",{class:"num",children:i.calls}),e("td",{class:"num",children:q(i.savedTokens)})]}))})]})]})]})]})}function _l(){let t=X(()=>O("/api/sessions",{limit:60}),[]),[n,s]=_(null),[r,a]=_(""),[i,o]=_(100);J(()=>{!n&&t.data?.[0]&&s(t.data[0].id)},[t.data]);let l=X(()=>n?O("/api/events",{session:n,category:r||void 0,limit:i}):Promise.resolve([]),[n,r,i]),c=[...new Set((l.data??[]).map(d=>d.category))].sort();return t.error?e("div",{class:"page",children:e(W,{error:t.error})}):e("div",{class:"page",children:e("div",{class:"grid wide",style:{gridTemplateColumns:"minmax(280px,1fr) minmax(0,2fr)",alignItems:"start"},children:[e("div",{class:"card flush",children:e("div",{class:"list",children:t.data?t.data.length?t.data.map(d=>e("div",{class:A("item",n===d.id&&"sel"),onClick:()=>s(d.id),children:[e("div",{class:"n",children:[e("code",{children:d.id.slice(0,8)})," ",d.current?e(P,{children:"current"}):null," ",e("a",{class:"small",href:`#/usage?session=${d.id}`,children:"usage \u2192"}),e("span",{class:"muted",style:{float:"right",fontWeight:400},children:te(d.started_at)})]}),e("div",{class:"p",children:(d.last_prompt??"(no prompt yet)").slice(0,100)}),e("div",{class:"p",children:[d.calls," calls \xB7 ",q(d.savedTokens)," saved \xB7 ",Oe(d.efficiency),d.source?` \xB7 ${d.source}`:""]})]})):e(B,{children:"no sessions yet"}):e(B,{children:e(N,{})})})}),e("div",{class:"card",children:[e("h3",{children:["events \xB7 ",n?n.slice(0,8):"all"," \xB7 ",l.data?.length??0]}),e("div",{class:"row",style:{marginBottom:8},children:[e("select",{value:r,onChange:d=>a(d.target.value),children:[e("option",{value:"",children:"all categories"}),c.map(d=>e("option",{value:d,children:d}))]}),e("label",{class:"muted small",children:["limit"," ",e("select",{value:String(i),onChange:d=>o(Number(d.target.value)),children:[100,300,1e3].map(d=>e("option",{value:String(d),children:d}))})]})]}),l.error?e(W,{error:l.error}):e("table",{children:[e("thead",{children:e("tr",{children:[e("th",{children:"time"}),e("th",{children:"category"}),e("th",{children:"tool"}),e("th",{children:"payload"})]})}),e("tbody",{children:(l.data??[]).length?(l.data??[]).map(d=>e("tr",{children:[e("td",{class:"muted nowrap",title:new Date(d.ts).toLocaleString(),children:ua(d.ts)}),e("td",{class:"nowrap",children:[e(P,{children:["P",d.priority]}),d.category]}),e("td",{children:d.tool??""}),e("td",{children:e("pre",{class:"json",children:JSON.stringify(d.payload).slice(0,400)})})]})):e("tr",{children:e("td",{colSpan:4,class:"muted",children:"no events"})})})]})]})]})})}var le={pending:"\u25CB",idle:"\u25CB",running:"\u25CF",active:"\u25CF",blocked:"\u25C6",done:"\u2713",failed:"\u2717",cancelled:"\u2717",stale:"\u25CC",coordinator:"\u2605"},El=t=>`sw-s-${t}`,rn={hierarchical:"\u22D4",mesh:"\u2B21",pipeline:"\u21C9"},$l={run_start:"\u25B8",run_finish:"\u25A0",plan:"+",claim:"\u2192",update:"\u270E",post:"\u2261",spawn:"\u2295",deny:"\u2298",start:"\u25CF",tool:"\u203A",tool_error:"\u2717",stop:"\u25A1",auto_close:"\u21BA"},wr=[["tools","tool calls",["tool","tool_error"]],["tasks","tasks",["plan","claim","update","auto_close"]],["notes","blackboard",["post"]],["workers","workers",["spawn","deny","start","stop"]],["run","run",["run_start","run_finish"]],["errors","errors",["tool_error","deny"]]],xr={unchanged:{glyph:"\u2713",word:"agent file in sync",short:"in sync",cls:"sw-s-done"},create:{glyph:"\u25CB",word:"agent file missing",short:"missing",cls:"sw-s-pending"},update:{glyph:"\u25C6",word:"agent file stale",short:"stale",cls:"sw-s-blocked"},conflict:{glyph:"\u2717",word:"conflict: a hand-written file has this name",short:"conflict (hand-written file)",cls:"sw-s-failed"},delete:{glyph:"\u25CC",word:"generated file a sync will remove",short:"to be removed",cls:"sw-s-stale"},disabled:{glyph:"\u25CC",word:"no agent file (swarms disabled)",short:"none (disabled)",cls:"sw-s-stale"}},Sl=["var(--accent)","var(--tok-ty)","var(--tok-str)","var(--tok-kw)","var(--tok-num)","var(--muted)"];function an(t,n){if(!t||t==="coordinator")return"var(--fg)";let s=n.indexOf(t);if(s<0){s=0;for(let r of t)s=s*31+r.charCodeAt(0)>>>0}return Sl[s%Sl.length]}function ls(t){let n=t.payload?.io;return n==="read"||n==="write"||n==="exec"||n==="swarm"||n==="other"?n:t.kind==="tool"||t.kind==="tool_error"?"other":"swarm"}var Ke=t=>t?t.replace(/^agent-/,"").slice(0,8):"";function Dt(t){if(t==null||!Number.isFinite(t)||t<0)return"n/a";let n=Math.round(t/1e3);if(n<60)return`${n}s`;let s=Math.floor(n/60);if(s<60)return`${s}m ${String(n%60).padStart(2,"0")}s`;let r=Math.floor(s/60);return r<24?`${r}h ${String(s%60).padStart(2,"0")}m`:`${Math.floor(r/24)}d ${r%24}h`}function Ot(t,n){let s=Math.max(0,n-t);return s<6e4?`${Math.floor(s/1e3)}s`:s<36e5?`${Math.floor(s/6e4)}m`:s<864e5?`${Math.floor(s/36e5)}h`:`${Math.floor(s/864e5)}d`}function Fe(t,n,s){let[,r]=_(0);return J(()=>{if(!n)return;let a=setInterval(()=>{document.visibilityState==="visible"&&r(i=>i+1)},t);return()=>clearInterval(a)},[t,n]),Date.now()+s}function Ve(t){class n extends wt{shouldComponentUpdate(r){let a=this.props,i=r;for(let o in i)if(a[o]!==i[o])return!0;for(let o in a)if(!(o in i))return!0;return!1}render(r){return xt(t,r)}}return n}var Tl=t=>n=>{n.target===n.currentTarget&&(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),t())};function Ze({s:t,word:n,title:s}){return e("span",{class:A("sw-state",El(t)),title:s,children:[e("span",{class:"g","aria-hidden":"true",children:le[t]}),n??t]})}function Je({role:t,roles:n,title:s,label:r,children:a}){return e("span",{class:"sw-chip",style:`--rc:${an(t,n)}`,title:s,children:[r??t??"any role",a]})}function xe({title:t,meta:n,children:s}){return e("div",{class:"sw-head",children:[e("span",{class:"t",children:t}),e("span",{class:"rule","aria-hidden":"true"}),n!=null&&n!==""?e("span",{class:"m",children:n}):null,s]})}function Sp({notes:t,roles:n,live:s,skew:r}){let a=Fe(15e3,s,r),[i,o]=_(null);return e("div",{class:"card",children:[e(xe,{title:"Blackboard",meta:`${t.length} key${t.length===1?"":"s"}`}),t.length?e("div",{class:"sw-notes",children:t.map(l=>{let c=i===l.key,d=l.author??"n/a";return e("div",{class:A("sw-note-row",c&&"open"),children:[e("button",{type:"button",class:"sw-btn sw-note-sum","aria-expanded":c,title:c?"hide the value":"show the value",onClick:()=>o(c?null:l.key),children:[e("div",{class:"h",children:[e("code",{class:"k",children:l.key}),e("span",{class:"v",children:["v",l.version]}),e(Je,{role:d.split("@")[0],roles:n,label:d}),e("span",{class:"age",title:new Date(l.ts).toLocaleString(),children:Ot(l.ts,a)})]}),c?null:e("div",{class:"p",children:l.value.trim().split(`
|
|
82
|
-
`)[0]?.slice(0,160)})]}),c?e("pre",{class:"sw-pre",children:l.value}):null]},l.key)})}):e("div",{class:"empty small",children:["Nothing shared yet. Workers post with"," ",e("code",{children:["em_swarm ",'{action:"post", key, value}']}),"."]})]})}var
|
|
83
|
-
`)[
|
|
84
|
-
|
|
85
|
-
`)
|
|
86
|
-
`)
|
|
87
|
-
`),r=-1;return e("pre",{class:"sw-yaml",children:s.map((a,i)=>{let o=a.length-a.trimStart().length,l=i+1,c;if(r>=0&&(a.trim()===""||o>r))c=e("span",{class:"tok-str",children:a});else{r=-1;let[d,u]=Wp(a),p=/^(\s*)(- )?([A-Za-z0-9_.-]+)(:)(.*)$/.exec(d);if(p){let f=p[5]??"";/^\s*[|>]-?\s*$/.test(f)&&(r=o+(p[2]?2:0)),c=e(j,{children:[p[1],p[2]?e("span",{class:"tok-pn",children:p[2]}):null,e("span",{class:"tok-ty",children:p[3]}),e("span",{class:"tok-pn",children:p[4]}),Dl(f),u?e("span",{class:"tok-cm",children:u}):null]})}else{let f=/^(\s*)(- )(.*)$/.exec(d);c=e(j,{children:[f?e(j,{children:[f[1],e("span",{class:"tok-pn",children:f[2]}),Dl(f[3]??"")]}):d,u?e("span",{class:"tok-cm",children:u}):null]})}}return e("span",{class:A("l",n?.has(l)&&"mark"),children:[e("span",{class:"ln",children:l}),c]})})})}var qp=15e3,Kp=2e3,Vp=5e3,Nl=800,Zp=5,$r=30,Yp=1e3,Qp=3e4,Tr=()=>document.visibilityState==="visible";function em(t,n){if(!n.length)return t;let s=new Map(t.map(a=>[a.id,a]));for(let a of n)s.set(a.id,a);let r=[...s.values()].sort((a,i)=>a.id-i.id);return r.length>Nl?r.slice(-Nl):r}function Ul({onCreated:t}){let[n,s]=_(!1),[r,a]=_();return e("span",{class:"row tight",children:[e("button",{type:"button",class:"primary",disabled:n,onClick:async()=>{s(!0),a(void 0);try{let i=await he("/api/swarm/init",{});Y(`created ${i.created} \xB7 ${i.sync.changed} agent file(s) written`),t()}catch(i){a(i.message)}finally{s(!1)}},children:n?"Creating\u2026":"Create .eminiar/swarm.yaml"}),r?e("span",{class:"bad small",children:r}):null]})}function tm({needed:t,onDone:n}){let[s,r]=_(!1),[a,i]=_();return e("div",{class:"row tight sw-sync",children:[e("button",{type:"button",class:A("sm",t&&"primary"),disabled:s,title:"write .claude/agents/swarm-<swarm>-<role>.md from the swarm file",onClick:async()=>{r(!0),i(void 0);try{let o=await he("/api/swarm/sync",{}),l=`${o.changed} file(s) changed${o.conflicts?` \xB7 ${o.conflicts} conflict(s) left alone`:""}`;i({text:l,bad:o.conflicts>0}),n()}catch(o){i({text:o.message,bad:!0})}finally{r(!1)}},children:s?"Syncing\u2026":"Sync agent files"}),a?e("span",{class:A("small",a.bad?"bad":"muted"),children:a.text}):t?e("span",{class:"small warn",children:[le.blocked," out of date"]}):e("span",{class:"small muted",children:[le.done," in sync"]})]})}function nm({f:t}){return t.memoryError?e("div",{class:"sw-note-box warn small",role:"alert",children:[e(Ze,{s:"blocked",word:"memory not written"})," The run closed as ",e("b",{children:t.status}),", but its outcome was not saved as a memory: ",t.memoryError,". Record it with ",e("code",{children:"em_remember"}),"."]}):t.remember&&t.memory?e("div",{class:"sw-note-box small",children:[e(Ze,{s:"done",word:"memory written"})," ",e("code",{children:t.memory})]}):null}function sm({id:t,onDone:n}){let[s,r]=_(!1),[a,i]=_("done"),[o,l]=_(""),[c,d]=_(!1),[u,p]=_(!1),[f,g]=_();return s?e("form",{class:"sw-finish",onSubmit:async y=>{y.preventDefault(),p(!0),g(void 0);try{let h=await he("/api/swarm/finish",{id:t,status:a,summary:o.trim()||void 0,remember:c}),m=h.memoryError??null;Y(m?`run finished as ${a} \xB7 its memory was NOT written`:`run finished as ${a}${h.memory?` \xB7 memory ${h.memory}`:""}`,!!m),r(!1),n({status:a,memory:h.memory,memoryError:m,remember:c})}catch(h){g(h.message)}finally{p(!1)}},children:[e("div",{class:"row",children:[e("span",{class:"small muted",children:"close the run as"}),["done","failed","cancelled"].map(y=>e("label",{class:A("sw-radio",a===y&&"on"),children:[e("input",{type:"radio",name:`finish-${t}`,checked:a===y,onChange:()=>i(y)}),e(Ze,{s:y})]}))]}),e("textarea",{class:"sw-summary",placeholder:"Summary (optional): the outcome in a sentence or two",value:o,maxLength:4e3,onInput:y=>l(y.target.value)}),e("label",{class:"small row tight",children:[e("input",{type:"checkbox",checked:c,onChange:y=>d(y.target.checked)}),"also write the outcome as a project memory (",e("code",{children:"swarm/run-\u2026"}),")"]}),e("div",{class:"row",children:[e("button",{type:"submit",class:"primary sm",disabled:u,children:u?"Finishing\u2026":`Finish as ${a}`}),e("button",{type:"button",class:"ghost sm",onClick:()=>r(!1),children:"Keep running"}),f?e("span",{class:"bad small",children:f}):null]})]}):e("button",{type:"button",class:"sm",onClick:()=>r(!0),children:"Finish run\u2026"})}function Hl({issues:t}){return e("ul",{class:"sw-issues",children:t.map(n=>e("li",{children:[e("span",{class:"g sw-s-failed",children:le.failed}),e("span",{class:"ln mono",children:n.line?`line ${n.line}`:"file"}),n.path?e("code",{children:n.path}):null," ",e("span",{children:n.message})]}))})}function rm({s:t}){let[n,s]=_(!1),r=t.roles.map(i=>i.role),a=new Map;for(let i of t.roles)a.set(i.file.action,(a.get(i.file.action)??0)+1);return e("div",{class:A("sw-swarm",n&&"open"),children:[e("button",{type:"button",class:"sw-btn h","aria-expanded":n,title:n?"hide the roles":"show the roles, models and tools",onClick:()=>s(i=>!i),children:[e("span",{class:"topo",title:t.topology,children:rn[t.topology]}),e("b",{children:t.name}),e("span",{class:"muted small",children:[t.topology," \xB7 max ",t.maxAgents]}),e("span",{class:"caret","aria-hidden":"true",children:n?"\u25BE":"\u25B8"})]}),e("div",{class:"d small muted",children:t.description}),e("div",{class:"chips",children:t.roles.map(i=>{let o=xr[i.file.action];return e(Je,{role:i.role,roles:r,title:`${i.description}
|
|
88
|
-
${i.agentType} \xB7 ${o.word}${i.file.reason?` (${i.file.reason})`:""}`,children:[i.count>1?e("span",{class:"n",children:["\xD7",i.count]}):null,e("span",{class:A("fs",o.cls),children:o.glyph})]})})}),e("div",{class:"files small",children:[e("span",{class:"muted",children:"agent files"}),[...a.entries()].map(([i,o])=>{let l=xr[i];return e("span",{class:l.cls,children:[l.glyph," ",o," ",l.short]})})]}),t.topology==="pipeline"&&t.stages.length?e("div",{class:"small muted mono",children:["stages ",t.stages.join(" \u2192 ")]}):null,n?e("div",{class:"more",children:[e("table",{class:"sw-roles",children:[e("thead",{children:e("tr",{children:[e("th",{children:"role"}),e("th",{children:"model"}),e("th",{class:"num",children:"count"}),e("th",{children:"tools"})]})}),e("tbody",{children:t.roles.map(i=>e("tr",{title:i.description,children:[e("td",{children:[e(Je,{role:i.role,roles:r}),i.hasHooks?e("span",{class:"sw-badge",children:"hooks"}):null,i.isolation?e("span",{class:"sw-badge",children:i.isolation}):null]}),e("td",{class:"mono",children:[i.model??"inherit",i.range?e("span",{class:"muted",children:[" ","(",i.range.floor,"..",i.range.ceiling,")"]}):null]}),e("td",{class:"num",children:i.count}),e("td",{class:"small",children:[i.tools?i.tools.join(", "):"all",i.disallowedTools?.length?e("span",{class:"muted",children:[" \xB7 not ",i.disallowedTools.join(", ")]}):null,i.skills.length?e("div",{class:"muted",children:["skills ",i.skills.join(", ")]}):null,i.scope.length?e("div",{class:"muted",children:["scope ",i.scope.join(", ")]}):null]})]}))})]}),t.instructions?e("pre",{class:"sw-pre",children:t.instructions}):null,e("div",{class:"small muted",children:["spawn with ",e("code",{children:["subagent_type: swarm-",t.name,"-<role>"]})]})]}):null]})}function am({o:t,onChanged:n}){return t.state==="absent"?e("div",{class:"card",children:[e(xe,{title:"Swarms",meta:"not opted in"}),e("p",{class:"small muted sw-p",children:["Agent swarms are off for this project: no ",e("code",{children:t.file}),"."]}),e(Ul,{onCreated:n})]}):t.state==="invalid"?e("div",{class:"card",children:[e(xe,{title:"Swarms",meta:e(Ze,{s:"failed",word:"invalid"})}),e("div",{class:"small mono",children:t.file}),e(Hl,{issues:t.issues}),e("p",{class:"small muted sw-p",children:"While the file is invalid, hooks ignore it and no agent files are written. This tab re-reads it every 15 s."})]}):e("div",{class:"card",children:[e(xe,{title:"Swarms",meta:`${t.swarms.length} defined`}),e("div",{class:"small muted mono sw-file",children:[t.file," \xB7 sync ",t.sync??"n/a"]}),t.enabled?null:e("div",{class:"sw-note-box",children:[e(Ze,{s:"stale",word:"disabled"})," ",e("code",{children:"enabled: false"}),": hooks ignore the swarms and a sync removes the generated agent files. Shown read-only."]}),t.swarms.map(s=>e(rm,{s})),t.orphans.length?e("div",{class:"small sw-orphans",children:t.orphans.map(s=>e("div",{children:[e("span",{class:"sw-s-stale",children:le.stale})," ",e("code",{children:s.path})," ",e("span",{class:"muted",children:s.reason??"will be removed"})]}))}):null,t.enabled?e(tm,{needed:t.syncNeeded,onDone:n}):null]})}function im({runs:t,selected:n,more:s,loading:r,onMore:a}){let i=t.filter(o=>o.status==="active").length;return e("div",{class:"card flush",children:[e("div",{class:"sw-pad",children:e(xe,{title:"Runs",meta:t.length?`${i} active \xB7 ${t.length}${s?"+":""}`:"none"})}),t.length?e("div",{class:"list sw-runs",children:[t.map(o=>{let l=o.counts.tasks;return e("a",{class:A("item",o.id===n&&"sel"),href:`#/swarm?run=${encodeURIComponent(o.id)}`,"aria-current":o.id===n?"page":void 0,children:[e("div",{class:"row tight",children:[e(Ze,{s:o.status}),e("span",{class:"spacer"}),e("span",{class:"muted small",title:new Date(o.created_at).toLocaleString(),children:te(o.created_at)})]}),e("div",{class:"n sw-goal",title:o.goal,children:o.goal}),e("div",{class:"p",children:[rn[o.topology]," ",o.swarm," \xB7"," ",l.total?`${l.done}/${l.total} tasks`:"no tasks",o.counts.workers.running?` \xB7 ${o.counts.workers.running} running`:"",l.failed+l.blocked?` \xB7 ${l.failed+l.blocked} failed/blocked`:""]}),l.total?e("div",{class:"sw-progress",title:`${l.done} of ${l.total} done`,children:[e("span",{class:"done",style:{width:`${100*l.done/l.total}%`}}),e("span",{class:"active",style:{width:`${100*l.active/l.total}%`}}),e("span",{class:"bad",style:{width:`${100*(l.failed+l.blocked)/l.total}%`}})]}):null]},o.id)}),s?e("div",{class:"sw-more",children:e("button",{type:"button",class:"ghost sm",disabled:r,onClick:a,children:r?"Loading\u2026":`Show ${$r} older runs`})}):null]}):e("div",{class:"empty small",children:"No runs yet."})]})}function Bl({swarms:t}){let n=t[0]??"feature";return e("div",{class:"sw-cmds",children:[e("div",{children:[e("span",{class:"muted small",children:"in a terminal"}),e("code",{children:"eminiar swarm init"})]}),e("div",{children:[e("span",{class:"muted small",children:"in Claude Code"}),e("code",{children:["/eminiar:em-swarm ",n," <goal>"]})]})]})}function om({o:t,onCreated:n}){return e("div",{class:"card sw-optin",children:[e(xe,{title:"Agent swarms",meta:"opt-in \xB7 off for this project"}),e("p",{children:["A swarm is a team of Claude Code subagents defined in ",e("code",{children:t.file}),": named roles with their prompts, models, tools, skills and hooks, and how they coordinate (hierarchical, mesh or pipeline). Your main session leads the run; each worker starts with what eminiar knows about the project (memories, history, structure), and this tab shows the run live."]}),e("p",{class:"muted small",children:["Nothing changes until the file exists: no agent files, no swarm work in any hook. Creating it writes the starter below and generates one agent file per role under"," ",e("code",{children:".claude/agents/"}),"."]}),e("div",{class:"row",children:e(Ul,{onCreated:n})}),e(Bl,{swarms:[]}),e(xe,{title:"Starter",meta:`${t.file} \xB7 read-only preview`}),t.starter?e(Ol,{text:t.starter}):null]})}function lm({o:t}){return t.state==="invalid"?e("div",{class:"card sw-optin",children:[e(xe,{title:"Swarm file is invalid",meta:t.file}),e("p",{children:"Fix these and the swarms appear here:"}),e(Hl,{issues:t.issues})]}):e("div",{class:"card sw-optin",children:[e(xe,{title:"No runs yet",meta:t.enabled?"ready":"disabled"}),e("p",{children:"Start a run from Claude Code. The coordinator (your session) plans tasks and spawns the workers; they appear here as they start."}),e(Bl,{swarms:t.swarms.map(n=>n.name)})]})}function on({label:t,value:n,sub:s,tone:r,children:a}){return e("div",{class:"card sw-stat",children:[e("h3",{children:t}),e("div",{class:A("big",r||void 0),children:n}),e("div",{class:"sub",children:s}),a]})}function cm({run:t,skew:n}){let s=t.status==="active",r=Fe(1e3,s,n),a=s?r-t.created_at:t.ended_at?t.ended_at-t.created_at:null;return e(on,{label:"elapsed",value:Dt(a),sub:s?`since ${new Date(t.created_at).toLocaleTimeString()}`:t.ended_at?`ended ${te(t.ended_at)}`:"end time not recorded"})}var dm=(t,n)=>!!t&&t.length===n.length&&t.every((s,r)=>s===n[r]);function um({id:t,onChanged:n}){let[s,r]=_(),[a,i]=_(),[o,l]=_(null),[c,d]=_([]),[u,p]=_(!1),[f,g]=_(null),[y,h]=_(0),[m,b]=_(),v=ee(0),k=ee(!1),w=ee(new Map),S=ee([]),E=ee(0),x=ee(),$=ee(""),M=ee(!1),I=ee(!1),C=ee(!0),L=Bt(async(Ee=!1)=>{let D=k.current&&!Ee&&E.current>0,V;try{V=await O("/api/swarm/run",{id:t,tasksSince:D?E.current:void 0,events:k.current?0:void 0})}catch(re){return C.current&&i(re.message),!1}if(!C.current)return!0;let be=!V.tasksPartial;if(V.tasksPartial){for(let re of V.tasks){let $e=w.current.get(re.id);(!$e||$e.updated_at!==re.updated_at||$e.status!==re.status)&&(be=!0),w.current.set(re.id,re)}if(V.taskCount!==void 0&&w.current.size!==V.taskCount)return L(!0)}else w.current=new Map(V.tasks.map(re=>[re.id,re]));be&&(S.current=[...w.current.values()].sort((re,$e)=>re.id-$e.id),E.current=S.current.reduce((re,$e)=>Math.max(re,$e.updated_at),0)),dm(x.current,V.roles)||(x.current=V.roles);let Pe=V.now-Date.now();h(re=>Math.abs(re-Pe)>1e3?Pe:re);let me=$.current;return $.current=V.run.status,k.current||(k.current=!0,v.current=V.events.length?V.events[V.events.length-1].id:0,d(V.events)),r({...V,tasks:S.current,roles:x.current??V.roles}),i(void 0),l(null),me==="active"&&V.run.status!=="active"&&(M.current=!0,n()),!0},[t]),T=Bt(async Ee=>{try{let D=await he("/api/swarm/release",{id:t,agent:Ee});Y(`released ${D.released.join(", ")}; its task is pending again`),L(!0)}catch(D){Y(`release failed: ${D.message}`,!0)}},[t,L]);if(J(()=>{C.current=!0;let Ee,D=Yp,V=async()=>{await L()||!C.current||k.current||(l(D),Ee=setTimeout(V,D),D=Math.min(D*2,Qp))};V();let be=setInterval(async()=>{if(!(!k.current||I.current||!Tr())&&!($.current!=="active"&&!M.current)){I.current=!0;try{let me=!0,re=!1;for(let $e=0;$e<Zp&&me;$e++){let Le=await O("/api/swarm/events",{id:t,after:v.current});if(!C.current)return;Le.events.length&&(v.current=Le.last,d(ne=>em(ne,Le.events))),me=Le.more,re=Le.run.status!=="active"}M.current=me,p(me),re&&!me&&$.current==="active"&&L()}catch{}finally{I.current=!1}}},Kp),Pe=setInterval(()=>{k.current&&$.current==="active"&&Tr()&&L()},Vp);return()=>{C.current=!1,clearTimeout(Ee),clearInterval(be),clearInterval(Pe)}},[t]),!s)return a?e("div",{class:"card",children:[e(W,{error:a}),e("div",{class:"small muted sw-retry",children:o?`retrying in ${Math.round(o/1e3)} s\u2026`:"retrying\u2026"})]}):e("div",{class:"empty",children:e(N,{})});let{run:F,counts:H}=s,K=F.status==="active",R=s.roles,z=s.workers.length,se=s.tasks.length;return e("div",{class:"sw-run",children:[a?e("div",{class:"sw-note-box bad small",children:["refresh failed: ",a]}):null,e("div",{class:"card sw-runhead",children:[e("div",{class:"row",children:[e(Ze,{s:F.status}),e("h2",{class:"goal",children:F.goal}),e("span",{class:"spacer"}),K?e(sm,{id:F.id,onDone:Ee=>{b(Ee),L(!0),n()}}):null]}),e("div",{class:"meta small muted",children:[e("code",{children:F.id}),e("span",{children:["swarm ",e("b",{children:F.swarm})]}),e("span",{children:[rn[F.topology]," ",F.topology]}),e("span",{title:new Date(F.created_at).toLocaleString(),children:["started ",te(F.created_at)]}),e("span",{children:["session ",F.session_id?e("code",{children:F.session_id.slice(0,8)}):"n/a"]}),s.configured?null:e("span",{class:"warn",children:['swarm "',F.swarm,'" is no longer in the swarm file']})]}),F.summary?e("div",{class:"sw-summary-text",children:F.summary}):null,m?e(nm,{f:m}):null]}),e("div",{class:"sw-stats",children:[e(on,{label:"workers running",value:`${H.workers.running}${s.maxAgents?` / ${s.maxAgents}`:""}`,sub:z?`${z} spawned \xB7 ${H.workers.stale} stale \xB7 ${H.workers.done} done`:"none spawned yet"}),e(on,{label:"tasks done",value:`${H.tasks.done} / ${se}`,sub:se?`${H.tasks.active} active \xB7 ${H.tasks.pending} pending \xB7 ${H.tasks.failed+H.tasks.blocked} failed/blocked${H.staleHeld?` \xB7 ${H.staleHeld} held by a quiet worker`:""}`:"none planned",children:se?e("div",{class:"sw-progress",children:[e("span",{class:"done",style:{width:`${100*H.tasks.done/se}%`}}),e("span",{class:"active",style:{width:`${100*H.tasks.active/se}%`}}),e("span",{class:"bad",style:{width:`${100*(H.tasks.failed+H.tasks.blocked)/se}%`}})]}):null}),e(on,{label:"tool calls",value:q(H.toolCalls),sub:z?`by ${z} worker${z===1?"":"s"}${H.autoClosed?` \xB7 ${H.autoClosed} auto-closed`:""}`:"no workers yet"}),e(on,{label:"errors",value:q(H.errors),sub:"failed tool calls",tone:H.errors>0&&"bad"}),e(cm,{run:F,skew:y})]}),e("div",{class:"card",children:[e(xe,{title:"Topology",meta:`${rn[F.topology]} ${F.topology} \xB7 ${z} worker${z===1?"":"s"}${K?" \xB7 live":""}`}),e(Pl,{detail:s,events:c,skew:y,roles:R,picked:f,onPick:g})]}),e(Rl,{tasks:s.tasks,workers:s.workers,roles:R,live:K,skew:y}),e(Ml,{timeline:s.timeline,live:K,roles:R,skew:y,onRelease:T}),e("div",{class:"sw-two",children:[e(Al,{events:c,roles:R,live:K,skew:y,behind:u,agent:f,onAgent:g}),e(Cl,{notes:s.notes,roles:R,live:K,skew:y})]})]})}function Jl({params:t}){let[n,s]=_($r),r=X(()=>O("/api/swarm",{limit:n}),[n]);J(()=>{let l=setInterval(()=>{Tr()&&r.reload()},qp);return()=>clearInterval(l)},[]);let a=r.data;if(!a)return e("div",{class:"page",children:r.error?e(W,{error:r.error}):e(N,{})});let i=a.runs,o=t.run||(i.find(l=>l.status==="active")??i[0])?.id;return e("div",{class:"page sw-page",children:[r.error?e(W,{error:r.error}):null,e("div",{class:"sw-layout",children:[e("aside",{class:"sw-rail",children:[e(am,{o:a,onChanged:r.reload}),e(im,{runs:i,selected:o,more:!!a.runsMore,loading:r.loading,onMore:()=>s(l=>l+$r)})]}),e("section",{class:"sw-main",children:o?e(um,{id:o,onChanged:r.reload},o):a.state==="absent"?e(om,{o:a,onCreated:r.reload}):e(lm,{o:a})})]})]})}function pm(){let[t,n]=_(!1),s=X(()=>O("/api/doctor",{fix:t?1:void 0}),[t]),r=(s.data??[]).filter(a=>!a.ok).length;return e(j,{children:[e("div",{class:"row",style:{marginBottom:10},children:[e("button",{type:"button",class:"primary",onClick:()=>s.reload(),children:"Re-run"}),e("button",{type:"button",onClick:()=>{n(!0),s.reload()},children:"Run with --fix"}),e("span",{class:"muted small",children:s.loading?e(N,{}):s.data?r?e("span",{class:"bad",children:[r," problem",r>1?"s":""]}):e("span",{class:"ok",children:"all checks pass"}):""})]}),s.error?e(W,{error:s.error}):e("div",{class:"card flush",children:e("table",{children:e("tbody",{children:(s.data??[]).map(a=>e("tr",{children:[e("td",{class:A(a.ok?"ok":"bad"),style:{width:24},children:a.ok?"\u2713":"\u2717"}),e("td",{class:"nowrap",children:a.name}),e("td",{class:"break",children:a.detail})]}))})})})]})}function mm({onChanged:t}){let[n,s]=_([]),[r,a]=_(null),[i,o]=_("all"),[l,c]=_(!1),[d,u]=_(""),[p,f]=_(""),[g,y]=_("index"),[h,m]=_(""),b=X(()=>O("/api/stats"),[]),v=async(w,S)=>{a(w);let E=new Date().toLocaleTimeString();s(x=>[...x,`[${E}] ${w} \u2026`]);try{let x=await he("/api/actions",S);s($=>[...$,`${x.ok?"\u2713":"\u2717"} ${w} (${x.ms} ms)
|
|
89
|
-
|
|
90
|
-
`)[0]??"failed",!0),t()}catch(x){s($=>[...$,`\u2717 ${w} failed: ${x.message}`]),Y(x.message,!0)}finally{a(null)}},k=({label:w,body:S,cls:E})=>e("button",{type:"button",class:E??"primary",disabled:!!r,onClick:()=>v(w,S),children:r===w?e(N,{}):w});return e(j,{children:[e("div",{class:"actions",children:[e("div",{class:"card",children:[e("h3",{children:"reindex"}),e("p",{children:"Rebuild the code graph, git signals, metrics, docs, memories or embeddings. Incremental unless full."}),e("div",{class:"row",children:[e("select",{value:i,onChange:w=>o(w.target.value),children:["all","code","git","metrics","docs","memories","embeddings"].map(w=>e("option",{value:w,children:w}))}),e("label",{class:"small",children:[e("input",{type:"checkbox",checked:l,onChange:w=>c(w.target.checked)})," ","full"]}),e(k,{label:`reindex ${i}`,body:{action:"reindex",scope:i,full:l}})]})]}),e("div",{class:"card",children:[e("h3",{children:"index a path"}),e("p",{children:"Index files or a directory into search (markdown by default; pass globs for other files)."}),e("div",{class:"row",children:[e("input",{type:"text",class:"grow",placeholder:"docs/ or README.md",value:d,onInput:w=>u(w.target.value)}),e("input",{type:"text",placeholder:"globs, comma separated",style:{maxWidth:200},value:p,onInput:w=>f(w.target.value)}),e("button",{type:"button",class:"primary",disabled:!!r||!d.trim(),onClick:()=>v("index",{action:"index",path:d,glob:p}),children:"Index"})]})]}),e("div",{class:"card",children:[e("h3",{children:"embeddings"}),e("p",{children:["Embed every chunk that still has no vector. Loads the model on first use."," ",b.data?e("span",{class:"muted",children:["(",b.data.index.embeddings,")"]}):null]}),e("div",{class:"row",children:e(k,{label:"embed pending",body:{action:"embed"}})})]}),e("div",{class:"card",children:[e("h3",{children:"memories"}),e("p",{children:["Re-import memory files edited, added or removed by hand under"," ",e("code",{children:b.data?.memoriesDir??".eminiar/memories"}),"."]}),e("div",{class:"row",children:e(k,{label:"reconcile",body:{action:"reconcile"}})})]}),e("div",{class:"card",children:[e("h3",{children:"purge"}),e("p",{children:"Permanently delete project data. Memory files stay on disk and are re-imported."}),e("div",{class:"row",children:[e("select",{value:g,onChange:w=>y(w.target.value),children:["index","sessions","graph","memories","all"].map(w=>e("option",{value:w,children:w}))}),e("input",{type:"text",placeholder:'type "purge" to confirm',style:{maxWidth:180},value:h,onInput:w=>m(w.target.value)}),e("button",{type:"button",class:"danger",disabled:!!r||h.trim()!=="purge",onClick:()=>{m(""),v(`purge ${g}`,{action:"purge",scope:g,confirm:!0})},children:"Purge"}),e(k,{label:"empty fetch cache",body:{action:"purge-fetch-cache"},cls:""})]})]}),e("div",{class:"card",children:[e("h3",{children:"server"}),b.data?e(Ae,{rows:[["project",b.data.project],["database",b.data.dbPath],["routing",b.data.routing]]}):e(N,{})]})]}),e("div",{class:"card",children:[e("h3",{children:["action log"," ",e("button",{type:"button",class:"sm right",onClick:()=>s([]),children:"clear"})]}),e("pre",{class:"log",children:n.length?n.join(`
|
|
78
|
+
`}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>${ct(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:n,text:s,tokens:a,autolink:r}){let o=r?ct(s,!0):this.parser.parseInline(a),i=ld(t);if(i===null)return o;t=ct(i,r);let l='<a href="'+t+'"';return n&&(l+=' title="'+ct(n)+'"'),l+=">"+o+"</a>",l}image({href:t,title:n,text:s,tokens:a}){a&&(s=this.parser.parseInline(a,this.parser.textRenderer));let r=ld(t);if(r===null)return ct(s);t=r;let o=`<img src="${ct(t)}" alt="${ct(s)}"`;return n&&(o+=` title="${ct(n)}"`),o+=">",o}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:ct(t.text)}},Ga=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}},yt=class Fa{constructor(n){be(this,"options");be(this,"renderer");be(this,"textRenderer");this.options=n||un,this.options.renderer=this.options.renderer||new mr,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Ga}static parse(n,s){return new Fa(s).parse(n)}static parseInline(n,s){return new Fa(s).parseInline(n)}parse(n){this.renderer.parser=this;let s="";for(let a=0;a<n.length;a++){let r=n[a];if(this.options.extensions?.renderers?.[r.type]){let i=r,l=this.options.extensions.renderers[i.type].call({parser:this},i);if(l!==!1||!["space","hr","heading","code","table","blockquote","list","checkbox","html","def","paragraph","text"].includes(i.type)){s+=l||"";continue}}let o=r;switch(o.type){case"space":{s+=this.renderer.space(o);break}case"hr":{s+=this.renderer.hr(o);break}case"heading":{s+=this.renderer.heading(o);break}case"code":{s+=this.renderer.code(o);break}case"table":{s+=this.renderer.table(o);break}case"blockquote":{s+=this.renderer.blockquote(o);break}case"list":{s+=this.renderer.list(o);break}case"checkbox":{s+=this.renderer.checkbox(o);break}case"html":{s+=this.renderer.html(o);break}case"def":{s+=this.renderer.def(o);break}case"paragraph":{s+=this.renderer.paragraph(o);break}case"text":{s+=this.renderer.text(o);break}default:{let i='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(i),"";throw new Error(i)}}}return s}parseInline(n,s=this.renderer){this.renderer.parser=this;let a="";for(let r=0;r<n.length;r++){let o=n[r];if(this.options.extensions?.renderers?.[o.type]){let l=this.options.extensions.renderers[o.type].call({parser:this},o);if(l!==!1||!["escape","html","link","image","checkbox","strong","em","codespan","br","del","text"].includes(o.type)){a+=l||"";continue}}let i=o;switch(i.type){case"escape":{a+=s.text(i);break}case"html":{a+=s.html(i);break}case"link":{a+=s.link(i);break}case"image":{a+=s.image(i);break}case"checkbox":{a+=s.checkbox(i);break}case"strong":{a+=s.strong(i);break}case"em":{a+=s.em(i);break}case"codespan":{a+=s.codespan(i);break}case"br":{a+=s.br(i);break}case"del":{a+=s.del(i);break}case"text":{a+=s.text(i);break}default:{let l='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return a}},cr,rs=(cr=class{constructor(t){be(this,"options");be(this,"block");this.options=t||un}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(t=this.block){return t?bt.lex:bt.lexInline}provideParser(t=this.block){return t?yt.parse:yt.parseInline}},be(cr,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),be(cr,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),cr);function on(t,n){if(Array.isArray(n))for(let s=0;s<n.length;s++)t.push(n[s]);else t.push(n)}var wh=class{constructor(...t){be(this,"defaults",Oa());be(this,"options",this.setOptions);be(this,"parse",this.parseMarkdown(!0));be(this,"parseInline",this.parseMarkdown(!1));be(this,"Parser",yt);be(this,"Renderer",mr);be(this,"TextRenderer",Ga);be(this,"Lexer",bt);be(this,"Tokenizer",pr);be(this,"Hooks",rs);this.use(...t)}walkTokens(t,n){let s=[];for(let a of t)switch(on(s,n.call(this,a)),a.type){case"table":{let r=a;for(let o of r.header)on(s,this.walkTokens(o.tokens,n));for(let o of r.rows)for(let i of o)on(s,this.walkTokens(i.tokens,n));break}case"list":{let r=a;on(s,this.walkTokens(r.items,n));break}default:{let r=a;this.defaults.extensions?.childTokens?.[r.type]?this.defaults.extensions.childTokens[r.type].forEach(o=>{let i=r[o].flat(1/0);on(s,this.walkTokens(i,n))}):r.tokens&&on(s,this.walkTokens(r.tokens,n))}}return s}use(...t){let n=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(s=>{let a={...s};if(a.async=this.defaults.async||a.async||!1,s.extensions&&(s.extensions.forEach(r=>{if(!r.name)throw new Error("extension name required");if("renderer"in r){let o=n.renderers[r.name];o?n.renderers[r.name]=function(...i){let l=r.renderer.apply(this,i);return l===!1&&(l=o.apply(this,i)),l}:n.renderers[r.name]=r.renderer}if("tokenizer"in r){if(!r.level||r.level!=="block"&&r.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let o=n[r.level];o?o.unshift(r.tokenizer):n[r.level]=[r.tokenizer],r.start&&(r.level==="block"?n.startBlock?n.startBlock.push(r.start):n.startBlock=[r.start]:r.level==="inline"&&(n.startInline?n.startInline.push(r.start):n.startInline=[r.start]))}"childTokens"in r&&r.childTokens&&(n.childTokens[r.name]=r.childTokens)}),a.extensions=n),s.renderer){let r=this.defaults.renderer||new mr(this.defaults);for(let o in s.renderer){if(!(o in r))throw new Error(`renderer '${o}' does not exist`);if(["options","parser"].includes(o))continue;let i=o,l=s.renderer[i],c=r[i];r[i]=(...u)=>{let d=l.apply(r,u);return d===!1&&(d=c.apply(r,u)),d||""}}a.renderer=r}if(s.tokenizer){let r=this.defaults.tokenizer||new pr(this.defaults);for(let o in s.tokenizer){if(!(o in r))throw new Error(`tokenizer '${o}' does not exist`);if(["options","rules","lexer"].includes(o))continue;let i=o,l=s.tokenizer[i],c=r[i];r[i]=(...u)=>{let d=l.apply(r,u);return d===!1&&(d=c.apply(r,u)),d}}a.tokenizer=r}if(s.hooks){let r=this.defaults.hooks||new rs;for(let o in s.hooks){if(!(o in r))throw new Error(`hook '${o}' does not exist`);if(["options","block"].includes(o))continue;let i=o,l=s.hooks[i],c=r[i];rs.passThroughHooks.has(o)?r[i]=u=>{if(this.defaults.async&&rs.passThroughHooksRespectAsync.has(o))return(async()=>{let p=await l.call(r,u);return c.call(r,p)})();let d=l.call(r,u);return c.call(r,d)}:r[i]=(...u)=>{if(this.defaults.async)return(async()=>{let p=await l.apply(r,u);return p===!1&&(p=await c.apply(r,u)),p})();let d=l.apply(r,u);return d===!1&&(d=c.apply(r,u)),d}}a.hooks=r}if(s.walkTokens){let r=this.defaults.walkTokens,o=s.walkTokens;a.walkTokens=function(i){let l=[];return l.push(o.call(this,i)),r&&on(l,r.call(this,i)),l}}this.defaults={...this.defaults,...a}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,n){return bt.lex(t,n??this.defaults)}parser(t,n){return yt.parse(t,n??this.defaults)}parseMarkdown(t){return(n,s)=>{let a={...s},r={...this.defaults,...a},o=this.onError(!!r.silent,!!r.async);if(this.defaults.async===!0&&a.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(r.hooks&&(r.hooks.options=r,r.hooks.block=t),r.async)return(async()=>{let i=r.hooks?await r.hooks.preprocess(n):n,l=await(r.hooks?await r.hooks.provideLexer(t):t?bt.lex:bt.lexInline)(i,r),c=r.hooks?await r.hooks.processAllTokens(l):l;r.walkTokens&&await Promise.all(this.walkTokens(c,r.walkTokens));let u=await(r.hooks?await r.hooks.provideParser(t):t?yt.parse:yt.parseInline)(c,r);return r.hooks?await r.hooks.postprocess(u):u})().catch(o);try{r.hooks&&(n=r.hooks.preprocess(n));let i=(r.hooks?r.hooks.provideLexer(t):t?bt.lex:bt.lexInline)(n,r);r.hooks&&(i=r.hooks.processAllTokens(i)),r.walkTokens&&this.walkTokens(i,r.walkTokens);let l=(r.hooks?r.hooks.provideParser(t):t?yt.parse:yt.parseInline)(i,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(i){return o(i)}}}onError(t,n){return s=>{if(s.message+=`
|
|
79
|
+
Please report this to https://github.com/markedjs/marked.`,t){let a="<p>An error occurred:</p><pre>"+ct(s.message+"",!0)+"</pre>";return n?Promise.resolve(a):a}if(n)return Promise.reject(s);throw s}}},dn=new wh;function _e(t,n){return dn.parse(t,n)}_e.options=_e.setOptions=function(t){return dn.setOptions(t),_e.defaults=dn.defaults,gd(_e.defaults),_e};_e.getDefaults=Oa;_e.defaults=un;function kh(...t){return dn.use(...t),_e.defaults=dn.defaults,gd(_e.defaults),_e}_e.use=kh;_e.walkTokens=function(t,n){return dn.walkTokens(t,n)};_e.parseInline=dn.parseInline;_e.Parser=yt;_e.parser=yt.parse;_e.Renderer=mr;_e.TextRenderer=Ga;_e.Lexer=bt;_e.lexer=bt.lex;_e.Tokenizer=pr;_e.Hooks=rs;_e.parse=_e;var pS=_e.options,mS=_e.setOptions,gS=_e.walkTokens,hS=_e.parseInline;var fS=yt.parse,_d=bt.lex;var xh={ts:"typescript",js:"javascript",mjs:"javascript",cjs:"javascript",py:"python",sh:"bash",shell:"bash",zsh:"bash",console:"bash",jsonc:"json",md:"markdown"},Cd={amp:"&",lt:"<",gt:">",quot:'"',apos:"'","#39":"'"};function Sh(t){return t.replace(/&(#x[0-9a-f]+|#\d+|[a-z]+);/gi,(n,s)=>s in Cd?Cd[s]:s.startsWith("#x")?String.fromCodePoint(Number.parseInt(s.slice(2),16)):s.startsWith("#")?String.fromCodePoint(Number.parseInt(s.slice(1),10)):n)}function vt({tokens:t}){return e(R,{children:(t??[]).map((n,s)=>$d(n,s))})}function _h({t}){let n=nn(t.href),s=e(vt,{tokens:t.tokens}),a=t.title??void 0,r=zs(n);return r?e("a",{class:"ref",href:r,title:a??t.href,children:s}):n.kind==="external"?e("a",{href:n.href,title:a,target:"_blank",rel:"noopener noreferrer",children:s}):n.kind==="anchor"?e("a",{href:n.href,title:a,children:s}):e("span",{title:t.href,children:s})}function $d(t,n){switch(t.type){case"text":{let s=t;return s.tokens?e(vt,{tokens:s.tokens},n):s.escaped?Sh(s.text):s.text}case"escape":return t.text;case"strong":return e("strong",{children:e(vt,{tokens:t.tokens})},n);case"em":return e("em",{children:e(vt,{tokens:t.tokens})},n);case"del":return e("del",{children:e(vt,{tokens:t.tokens})},n);case"codespan":return e("code",{children:t.text},n);case"br":return e("br",{},n);case"link":return e(_h,{t},n);case"image":{let s=t,a=nn(s.href);return a.kind==="external"?e("img",{src:a.href,alt:s.text,title:s.title??void 0,loading:"lazy"},n):e("span",{class:"md-html",title:s.href,children:s.text},n)}case"checkbox":return e("input",{type:"checkbox",checked:t.checked,disabled:!0},n);case"html":return e("span",{class:"md-html",children:t.text},n);default:{let s=t;return s.tokens?e(vt,{tokens:s.tokens},n):s.raw}}}function Ch({t}){let n=(t.lang??"").trim().split(/\s+/)[0]?.toLowerCase()??"",s=xh[n]??n,a=ae(()=>rr(t.text,s).join(`
|
|
80
|
+
`),[t.text,s]);return e("pre",{class:"code","data-lang":n||void 0,children:e("code",{dangerouslySetInnerHTML:{__html:a}})})}function Wa({tokens:t}){return e(R,{children:(t??[]).map((n,s)=>$h(n,s))})}function $h(t,n){switch(t.type){case"space":case"def":return null;case"heading":{let s=t;return bn(`h${Math.min(Math.max(s.depth,1),6)}`,{key:n},e(vt,{tokens:s.tokens}))}case"paragraph":return e("p",{children:e(vt,{tokens:t.tokens})},n);case"text":{let s=t;return s.tokens?e(vt,{tokens:s.tokens},n):s.text}case"checkbox":return $d(t,n);case"code":return e(Ch,{t},n);case"blockquote":return e("blockquote",{children:e(Wa,{tokens:t.tokens})},n);case"list":{let s=t,a=s.items.map((r,o)=>e("li",{class:r.task?"task":void 0,children:e(Wa,{tokens:r.tokens})},o));return s.ordered?e("ol",{start:s.start===""?void 0:s.start,children:a},n):e("ul",{children:a},n)}case"table":{let s=t,a=(r,o)=>bn(r.header?"th":"td",{key:o,style:r.align?{textAlign:r.align}:void 0},e(vt,{tokens:r.tokens}));return e("table",{children:[e("thead",{children:e("tr",{children:s.header.map(a)})}),e("tbody",{children:s.rows.map((r,o)=>e("tr",{children:r.map(a)},o))})]},n)}case"hr":return e("hr",{},n);case"html":return e("pre",{class:"md-html",children:t.text},n);default:{let s=t;return e("p",{children:s.tokens?e(vt,{tokens:s.tokens}):s.raw},n)}}}function hr({source:t,class:n}){let s=ae(()=>_d(t,{gfm:!0}),[t]);return e("div",{class:n?`md ${n}`:"md",children:e(Wa,{tokens:s})})}var Eh={decision:"purple",constraint:"bad",fact:"accent",preference:"ok",todo:"warn",note:"muted",onboarding:"ok"},Th={proposed:"warn",rejected:"bad"};function za({m:t}){return e(R,{children:[e(I,{tone:Eh[t.kind]??"muted",children:t.kind}),t.status&&t.status!=="accepted"?e(I,{tone:Th[t.status]??"muted",children:t.status}):null]})}function Ed({value:t}){let n=zs(nn(t));return n?e("a",{class:"ref",href:n,title:t,children:t}):e("span",{class:"tag",title:t,children:t})}function Rh(t){return t.split(`
|
|
81
|
+
`).find(n=>n.trim())?.replace(/^#+\s*/,"").slice(0,120)??""}var Td={kind:"fact",tags:"",related:"",body:"",name:"",status:"",supersedes:""};function Rd(t){return{kind:t.kind,tags:t.tags.join(", "),related:t.related.join(", "),body:t.body,name:t.name,status:t.status??"",supersedes:t.supersedes??""}}function Ah({name:t,kinds:n,statuses:s,onSaved:a,onDeleted:r}){let o=V(()=>t?J("/api/memories",{name:t}):Promise.resolve(void 0),[t]),[i,l]=x(!t),[c,u]=x(!1),[d,p]=x(Td),[g,h]=x(!1);U(()=>{l(!t),u(!1)},[t]),U(()=>{let _=o.data;t&&_&&p(Rd(_)),t||p(Td)},[t,o.data]);let y=_=>T=>p({...d,[_]:T.target.value}),m=()=>{l(!1),u(!1)},f=async()=>{if(!d.body.trim())return ee("body required",!0);h(!0);try{let _={kind:d.kind,content:d.body,tags:d.tags,related:d.related,status:d.status||void 0,supersedes:d.supersedes||void 0},T=t?await $e("/api/memories",_,"PUT",{name:t}):await $e("/api/memories",{..._,name:d.name.trim()||void 0});ee(`${t?"saved":"created"} ${T.name}${T.superseded?` \xB7 ${T.superseded} marked superseded`:""}`),t===T.name&&o.reload(),a(T.name),m()}catch(_){ee(_.message,!0)}finally{h(!1)}},v=()=>{o.data&&p(Rd(o.data)),m()},b=async()=>{if(!(!t||!confirm(`Delete memory "${t}" and its file?`)))try{await Es("/api/memories",{name:t}),ee(`deleted ${t}`),r()}catch(_){ee(_.message,!0)}},w=async()=>{if(!t)return;let _=prompt("New name (topic/slug):",t);if(!(!_||_===t))try{let T=await $e("/api/memories",{to:_},"PATCH",{name:t});ee(`renamed \u2192 ${T.name}${T.refsUpdated?` (${T.refsUpdated} references updated)`:""}`),a(T.name)}catch(T){ee(T.message,!0)}},k=_=>{(_.metaKey||_.ctrlKey)&&_.key.toLowerCase()==="s"?(_.preventDefault(),f()):_.key==="Escape"&&t&&(_.preventDefault(),v())};if(t&&o.error)return e(Z,{error:o.error});if(t&&!o.data)return e(se,{});let C=o.data,S=d.kind==="decision";return t&&C&&!i?e("div",{children:[e("div",{class:"row",style:{marginBottom:6},children:[e("b",{class:"grow break",children:t}),e("button",{type:"button",class:"sm primary",onClick:()=>l(!0),children:"edit"}),e("button",{type:"button",class:"sm",onClick:w,children:"rename"}),e("button",{type:"button",class:"sm",title:"this memory in the knowledge graph",onClick:()=>H("memory",{tab:"graph",focus:`memory:${t}`}),children:"graph"}),e("button",{type:"button",class:"sm danger",onClick:b,children:"delete"})]}),e("div",{class:"muted small",style:{marginBottom:8},children:[C.path," \xB7 created ",C.created.slice(0,10)," \xB7 updated ",C.updated.slice(0,10)]}),e("div",{class:"row tight mem-refs",style:{marginBottom:12},children:[e(za,{m:C}),C.tags.map(_=>e("span",{class:"tag",children:["#",_]})),C.related.map(_=>e(Ed,{value:_})),C.supersedes?e("span",{class:"muted small",children:["supersedes ",e(Ed,{value:`mem:${C.supersedes}`})]}):null]}),e(hr,{source:C.body})]}):e("div",{children:[e("div",{class:"row",style:{marginBottom:6},children:[e("b",{class:"grow break",children:t??"New memory"}),t?e(R,{children:[e("span",{class:"muted small",children:"editing"}),e("button",{type:"button",class:"sm",onClick:w,children:"rename"}),e("button",{type:"button",class:"sm danger",onClick:b,children:"delete"})]}):null]}),t&&C?e("div",{class:"muted small",style:{marginBottom:8},children:[C.path," \xB7 created ",C.created.slice(0,10)," \xB7 updated ",C.updated.slice(0,10)]}):e("div",{class:"field",children:[e("label",{children:"name (topic/slug, optional \u2014 derived from kind + content)"}),e("input",{type:"text",placeholder:"auth/session-tokens",value:d.name,onInput:y("name")})]}),e("div",{class:"grid",style:{gridTemplateColumns:S?"1fr 1fr 2fr 2fr":"1fr 2fr 2fr",gap:8,marginBottom:0},children:[e("div",{class:"field",children:[e("label",{children:"kind"}),e("select",{value:d.kind,onChange:y("kind"),children:n.map(_=>e("option",{value:_,children:_}))})]}),S&&e("div",{class:"field",children:[e("label",{children:"status"}),e("select",{value:d.status,onChange:y("status"),children:[e("option",{value:"",children:"accepted (default)"}),s.map(_=>e("option",{value:_,children:_}))]})]}),e("div",{class:"field",children:[e("label",{children:"tags (comma separated)"}),e("input",{type:"text",value:d.tags,onInput:y("tags")})]}),e("div",{class:"field",children:[e("label",{children:"related (file:path, sym:path#Name, mem:name)"}),e("input",{type:"text",value:d.related,onInput:y("related")})]})]}),S&&e("div",{class:"field",children:[e("label",{children:"supersedes (name of the decision this replaces; it is marked superseded on save)"}),e("input",{type:"text",placeholder:"decision/old-approach",value:d.supersedes,onInput:y("supersedes")})]}),e("div",{class:"field",children:[e("div",{class:"row tight",children:[e("label",{class:"grow",children:"body (raw markdown)"}),e("a",{class:"small",onClick:()=>u(!c),children:c?"back to markdown":"preview"})]}),c?e(hr,{class:"preview",source:d.body.trim()?d.body:"_Nothing to preview yet._"}):e("textarea",{value:d.body,onInput:y("body"),onKeyDown:k,spellcheck:!1})]}),e("div",{class:"row",children:[e("button",{type:"button",class:"primary",disabled:g,onClick:f,children:g?e(se,{}):t?"Save":"Create"}),t?e("button",{type:"button",disabled:g,onClick:v,children:"Cancel"}):null,e("span",{class:"muted small",children:["\u2318S / Ctrl+S saves",t?", Esc cancels":""]})]})]})}function Mh({rows:t}){let n=new Map;for(let s of t)(n.get(s.topic||"(no topic)")??n.set(s.topic||"(no topic)",[]).get(s.topic||"(no topic)")).push(s);return t.length?e("div",{class:"stack",children:[...n.entries()].sort().map(([s,a])=>e(j,{title:s,children:a.map(r=>e("div",{style:{padding:"8px 0",borderBottom:"1px solid var(--line)"},children:[e("div",{class:"row tight",children:[e("b",{children:r.name}),e(za,{m:r}),e("span",{class:"muted small",children:Ve(r.updated_at)}),e("span",{class:"spacer"}),e("a",{class:"small",onClick:()=>H("memory",{name:r.name}),children:"open"})]}),r.supersedes?e("div",{class:"muted small",children:["supersedes ",r.supersedes]}):null,e("div",{style:{marginTop:6,fontSize:13},children:e(hr,{source:r.content})})]}))}))}):e(X,{compact:!0,icon:"\u25C7",title:"No accepted decisions yet",children:'Record one with kind "decision", or ask Claude to em_remember it.'})}function Ad({params:t}){let[n,s]=x(t.name?.startsWith("decision/")?"decision":t.tab??"all"),[a,r]=x(t.name??null),[o,i]=x(!1),[l,c]=x(""),[u,d]=x(""),p=V(()=>J("/api/memories"),[]);U(()=>{t.name&&(r(t.name),i(!1),s(m=>m==="graph"||m==="record"?t.name.startsWith("decision/")?"decision":"all":m))},[t.name]),U(()=>{t.tab&&s(t.tab)},[t.tab]),U(()=>{p.data?.gitignored&&ee(`.gitignore keeps ${p.data.dir} out of git; memories stay local`,!0),p.data?.skipped.length&&ee(`skipped invalid memory files: ${p.data.skipped.join(", ")}`,!0)},[p.data]);let g=ae(()=>{let m=p.data?.memories??[],f=l.trim().toLowerCase();return m.filter(v=>(n==="all"||n==="record"||v.kind===n)&&(!u||(v.status??"accepted")===u)&&(!f||v.name.includes(f)||v.tags.some(b=>b.includes(f))||v.content.toLowerCase().includes(f)))},[p.data,n,l,u]);if(p.error)return e("div",{class:"page",children:e(Z,{error:p.error})});let h=p.data,y=[["all","All"],...(h?.kinds??[]).map(m=>[m,m]),["record","Decision record"],["graph","Graph"]];return e("div",{class:"page ds-page mem-page",children:[e(Te,{eyebrow:"Memory",title:"Project memory",sub:"Decisions, constraints and facts Claude recalls across sessions.",meta:h?e(R,{children:[e(I,{tone:"accent",children:[h.memories.length," memories"]}),e(I,{tone:"purple",children:[h.memories.filter(m=>m.kind==="decision").length," decisions"]})]}):null}),e(Se,{label:"Memory views",options:y.map(([m,f])=>({id:m,label:f})),value:n,onChange:m=>{s(m),m!=="decision"&&d(""),(m==="graph"||t.tab)&&H("memory",{tab:m})}}),n==="graph"?e(nr,{scope:"memory",focus:t.focus}):n==="record"?e(Mh,{rows:(h?.memories??[]).filter(m=>m.kind==="decision"&&(m.status??"accepted")==="accepted")}):e(R,{children:[e("div",{class:"row mem-toolbar",style:{marginBottom:12},children:[e("button",{type:"button",class:"primary",onClick:()=>{i(!0),r(null)},children:"+ New memory"}),e("input",{type:"search",class:"grow mem-filter",placeholder:"filter by name, tag or text\u2026",value:l,onInput:m=>c(m.target.value)}),n==="decision"&&e("select",{value:u,onChange:m=>d(m.target.value),children:[e("option",{value:"",children:"any status"}),(h?.statuses??[]).map(m=>e("option",{value:m,children:m}))]}),e("button",{type:"button",title:"re-import files edited by hand",onClick:async()=>{let m=await $e("/api/actions",{action:"reconcile"});ee(m.output,!m.ok),p.reload()},children:"\u21BB Reconcile"}),e("span",{class:"muted small",children:[g.length," of ",h?.memories.length??0]})]}),e("div",{class:"grid wide",style:{gridTemplateColumns:"minmax(280px,1fr) minmax(0,2fr)",alignItems:"start"},children:[e(j,{flush:!0,children:e("div",{class:"list",children:h?g.length?g.map(m=>e("div",{class:E("item",a===m.name&&"sel"),onClick:()=>{r(m.name),i(!1)},children:[e("div",{class:"n",children:m.name}),e("div",{class:"p",children:[e(za,{m}),e("span",{class:"muted",children:[Ve(m.updated_at)," \xB7 ",z(m.size??0),"B"]})]}),e("div",{class:"p",children:Rh(m.content)})]})):e(X,{compact:!0,icon:"\u25CB",title:"No memories match"}):e(X,{compact:!0,icon:"\u2026",title:"Loading memories",children:e(se,{})})})}),e(j,{children:o||a?e(Ah,{name:o?null:a,kinds:h?.kinds??[],statuses:h?.statuses??[],onSaved:m=>{i(!1),r(m),p.reload()},onDeleted:()=>{r(null),p.reload()}}):e(X,{compact:!0,icon:"\u25C7",title:"Select a memory",children:"or create a new one."})})]})]})]})}var Md=["overview","structure","commands","conventions"],In=t=>Math.ceil(t/4);function Dh(){return e("div",{class:"page ds-page",role:"status","aria-busy":"true",children:[e("section",{class:"ds-hero",children:[e("div",{class:"ds-hero-main",children:[e(N,{w:160,h:12}),e(N,{w:"min(420px, 80%)",h:34}),e(N,{w:"min(320px, 60%)",h:14})]}),e("div",{class:"ds-hero-aside",children:e(N,{w:92,h:92,class:"sk-round"})})]}),e(Re,{children:[0,1,2,3,4].map(()=>e("div",{class:"ds-stat",children:[e(N,{w:90,h:11}),e(N,{w:110,h:28}),e(N,{w:140,h:11})]}))}),e("div",{class:"ds-grid main-side",children:[e(j,{children:e("div",{class:"ds-skel-stack",children:[e(N,{w:180,h:14}),e(N,{h:132})]})}),e(j,{children:e("div",{class:"ds-skel-stack",children:[e(N,{w:120,h:14}),e(N,{h:14}),e(N,{w:"70%",h:14})]})})]})]})}function Dd({rows:t}){let n=[...t].sort((r,o)=>o.raw_chars-r.raw_chars),s=r=>Math.max(0,In(r.raw_chars)-In(r.returned_chars)),a=Math.max(1,...n.map(s));return e("div",{class:"ds-table-wrap",children:e("table",{children:[e("thead",{children:e("tr",{children:[e("th",{children:"tool"}),e("th",{class:"num",children:"calls"}),e("th",{class:"num",children:"seen"}),e("th",{class:"num",children:"returned"}),e("th",{class:"num",children:"saved"})]})}),e("tbody",{children:n.length?n.map(r=>{let o=s(r);return e("tr",{children:[e("td",{children:r.tool}),e("td",{class:"num",children:r.calls}),e("td",{class:"num",children:z(In(r.raw_chars))}),e("td",{class:"num",children:z(In(r.returned_chars))}),e("td",{class:"num",children:e("span",{class:"ov-saved-cell",children:[e("span",{class:"ds-meter-track ds-t-ok",children:e("i",{style:{width:`${o?Math.max(3,100*o/a):0}%`}})}),e("b",{children:z(o)})]})})]})}):e("tr",{children:e("td",{class:"muted",colSpan:5,children:"no calls yet"})})})]})})}function Lh(){let t=V(()=>J("/api/swarm",{limit:5}),[]),n=t.reload,s=t.data?.runs.some(l=>l.status==="active")??!1;U(()=>{if(!s)return;let l=setInterval(()=>{document.hidden||n()},15e3);return()=>clearInterval(l)},[s,n]);let a=e("a",{class:"ds-link",onClick:()=>H("swarm"),children:"open \u2192"}),r=t.data,o,i=a;if(t.error)o=e(X,{compact:!0,icon:"!",tone:"bad",title:"Swarm status unavailable",children:t.error});else if(!r)o=e("div",{class:"ds-skel-stack",children:[e(N,{h:14}),e(N,{w:"75%",h:14}),e(N,{h:8})]}),i=null;else if(r.state==="absent")o=e(X,{compact:!0,icon:"\u22D4",title:"Swarms are not set up",children:["No ",e("code",{children:r.file})," yet. Pick a template on the Swarms tab to define roles and a topology."]});else if(r.state==="invalid")o=e(X,{compact:!0,icon:"!",tone:"bad",title:"Swarm file has problems",children:[r.issues.length," issue",r.issues.length===1?"":"s"," in ",e("code",{children:r.file}),r.issues[0]?`: ${r.issues[0].message}`:""]});else if(!r.enabled)o=e(X,{compact:!0,icon:"\u23F8",title:"Swarms are disabled",children:[e("code",{children:r.file})," sets ",e("code",{children:"enabled: false"}),", so no agent files are generated."]});else{let l=r.runs.find(c=>c.status==="active");if(l){let c=l.counts.tasks,u=l.counts.workers;o=e("div",{class:"ov-swarm-run",role:"link",tabIndex:0,onClick:()=>H("swarm",{run:l.id}),onKeyDown:d=>d.key==="Enter"&&H("swarm",{run:l.id}),children:[e("div",{class:"ov-row",children:[e(It,{tone:"accent",pulse:!0,children:"running"}),e(I,{children:l.swarm}),e("span",{class:"ds-card-sub",children:["started ",me(l.created_at)]})]}),e("div",{class:"ov-swarm-goal",children:l.goal}),e(St,{total:c.total,title:`${c.done} of ${c.total} tasks done`,segments:[{value:c.done,tone:"ok",label:`${c.done} done`},{value:c.active,tone:"accent",label:`${c.active} active`},{value:c.blocked,tone:"warn",label:`${c.blocked} blocked`},{value:c.failed,tone:"bad",label:`${c.failed} failed`}]}),e("div",{class:"ds-card-sub",children:[c.total?`${c.done}/${c.total} tasks done`:"no tasks planned yet"," \xB7 ",u.running," ","worker",u.running===1?"":"s"," running",u.stale?` \xB7 ${u.stale} stale`:""]})]})}else{let c=r.runs[0];o=e("div",{class:"ds-skel-stack",children:[e("div",{class:"ov-row",children:[e(I,{tone:"ok",dot:!0,children:"ready"}),e("span",{class:"ds-card-sub",children:[r.swarms.length," swarm",r.swarms.length===1?"":"s"," defined:"," ",r.swarms.map(u=>u.name).join(", ")]})]}),c?e("div",{class:"ds-card-sub",children:["Last run ",e("b",{children:c.swarm})," ",c.status," ",me(c.updated_at),":"," ",c.goal.slice(0,80)]}):e("div",{class:"ds-card-sub",children:["No runs yet. Start one from Claude Code with ",e("code",{children:"/eminiar:em-swarm"}),"."]}),r.syncNeeded?e(I,{tone:"warn",children:"agent files need a sync"}):null]})}}return e(j,{title:"Swarms",right:i,children:o})}function jh(t){if(!t)return e(I,{tone:"muted",children:"checking index\u2026"});let n=t.state==="fresh"?"ok":t.state==="stale"?"warn":"bad",s=t.state==="fresh"?"index fresh":t.state==="stale"?"index stale":"no graph",a=`${t.graph.nodes} nodes \xB7 ${t.freshness.dirty.length} changed \xB7 ${t.freshness.queued} queued`;return e(It,{tone:n,title:a,children:s})}function Ld(){let t=V(()=>J("/api/stats"),[]),n=V(()=>J("/api/status"),[]);if(t.error)return e("div",{class:"page ds-page",children:e(Z,{error:t.error})});let s=t.data;if(!s)return e(Dh,{});let a=Md.filter(d=>!s.onboarding.includes(d)),r=s.daily.map(d=>In(d.saved_chars)),o=s.lifetime.savedTokens,i=s.daily[0],l=s.daily[s.daily.length-1],c=Object.entries(s.index.bySource).filter(([,d])=>d).sort((d,p)=>p[1]-d[1]).map(([d,p])=>({label:d,value:p})),u=Object.entries(s.index.graph.byKind??{}).sort((d,p)=>p[1]-d[1]).map(([d,p])=>({label:d,value:p,text:z(p)}));return e("div",{class:"page ds-page",children:[e(Te,{eyebrow:e(R,{children:[e("span",{children:wn(s.project)}),jh(n.data)]}),title:o>0?e(R,{children:[e(xn,{children:[z(o)," tokens"]})," kept out of context"]}):"Nothing kept out of context yet",sub:o>0?`${s.lifetime.calls} tool calls compacted to ${tt(1-s.lifetime.efficiency)} of their raw size. ${s.session.savedTokens>0?`${z(s.session.savedTokens)} saved this session.`:""}`:"Run tools through the eminiar sandbox and the savings will show up here.",meta:e(R,{children:[e(I,{tone:"accent",title:"routing mode",children:["routing ",s.routing]}),e(I,{tone:"purple",title:"embedding backend",children:s.index.embeddings}),a.length?e(I,{tone:"warn",title:`missing: ${a.join(", ")}`,children:["onboarding ",s.onboarding.length,"/4"]}):e(I,{tone:"ok",dot:!0,children:"onboarded"})]}),aside:e(R,{children:[e(Kt,{class:"ov-hero-gauge",size:92,thickness:10,tone:o>0?"accent":"muted",value:s.lifetime.efficiency,label:tt(s.lifetime.efficiency),caption:"efficient",title:`lifetime efficiency ${tt(s.lifetime.efficiency)}`}),e("div",{class:"ov-hero-kpi",children:[e("b",{children:z(s.session.savedTokens)}),e("span",{children:"saved this session"}),e("span",{children:[s.session.calls," calls"]})]})]})}),e(Re,{children:[e(le,{label:"session saved",value:z(s.session.savedTokens),sub:`${tt(s.session.efficiency)} efficient \xB7 ${s.session.calls} calls`,children:e(St,{total:1,segments:[{value:s.session.efficiency,tone:"accent"}]})}),e(le,{label:"project saved",value:z(s.projectTotals.savedTokens),sub:`${tt(s.projectTotals.efficiency)} efficient \xB7 ${s.projectTotals.calls} calls`,children:e(St,{total:1,segments:[{value:s.projectTotals.efficiency,tone:"purple"}]})}),e(le,{label:"lifetime saved",value:z(o),sub:`${tt(s.lifetime.efficiency)} efficient \xB7 ${s.lifetime.calls} calls`,onClick:()=>H("usage"),title:"open Usage",children:r.length>1?e(Rs,{values:r,title:"tokens saved per day"}):e(St,{total:1,segments:[{value:s.lifetime.efficiency,tone:"ok"}]})}),e(le,{label:"documents",value:z(s.index.documents),tone:s.index.pendingEmbeddings?"warn":void 0,sub:e(R,{children:[z(s.index.vectors)," vectors",s.index.pendingEmbeddings?" \xB7 embedding backlog":""]})}),e(le,{label:"memories",value:z(s.index.memories),sub:`${s.onboarding.length}/4 onboarding`,onClick:()=>H("memory"),title:"open Memory",children:e(St,{total:Md.length,segments:[{value:s.onboarding.length,tone:a.length?"warn":"ok"}]})}),e(le,{label:"graph",value:`${z(s.index.graph.nodes)} nodes`,sub:`${z(s.index.graph.edges)} edges`,onClick:()=>H("galaxy",{tab:"map"}),title:"open the Galaxy folder map"})]}),e("div",{class:"ds-grid main-side",children:[e(j,{title:"Tokens saved per day",right:i&&l?`${i.day} \u2192 ${l.day}`:void 0,children:s.daily.length?e(fi,{data:s.daily.map(d=>({value:d.saved_chars,tip:`${d.day}: ${z(In(d.saved_chars))} tokens \xB7 ${d.calls} calls`})),startLabel:i?.day,endLabel:l?.day}):e(X,{compact:!0,icon:"\u2581",title:"No daily data yet",children:"Savings are recorded per day once tools run through eminiar."})}),e(Lh,{})]}),e("div",{class:"ds-grid cols-2",children:[e(j,{flush:!0,title:"This session \xB7 by tool",right:`${s.session.tools.length} tools`,children:e(Dd,{rows:s.session.tools})}),e(j,{flush:!0,title:"Lifetime \xB7 by tool",right:`${s.lifetime.tools.length} tools`,children:e(Dd,{rows:s.lifetime.tools})})]}),e("div",{class:"ds-grid cols-3",children:[e(j,{title:"Index by source",right:`${z(s.index.documents)} docs`,children:e(qr,{rows:c,tone:"accent",empty:"nothing indexed yet"})}),e(j,{title:"Graph by edge kind",right:`${z(s.index.graph.edges)} edges`,children:e(qr,{rows:u,tone:"purple",empty:"no graph edges yet"})}),e(j,{title:"System",children:e(nt,{rows:[["project",s.project],["database",s.dbPath],["routing",s.routing],["embeddings",s.index.embeddings],["memories dir",s.memoriesDir],["onboarding",a.length?e("span",{class:"warn",children:["missing: ",a.join(", ")," \u2014 run /eminiar:em-onboard"]}):e("span",{class:"ok",children:"complete"})],["session",s.session.id]]})})]}),e(j,{flush:!0,title:"Recent sessions",right:e("a",{class:"ds-link",onClick:()=>H("sessions"),children:"all \u2192"}),children:e("div",{class:"ds-table-wrap",children:e("table",{children:[e("thead",{children:e("tr",{children:[e("th",{children:"started"}),e("th",{children:"session"}),e("th",{children:"last prompt"}),e("th",{class:"num",children:"calls"}),e("th",{class:"num",children:"saved"})]})}),e("tbody",{children:s.sessions.length?s.sessions.map(d=>e("tr",{children:[e("td",{class:"muted",children:[me(d.started_at)," ",d.current?e(Je,{children:"current"}):null]}),e("td",{children:e("code",{children:d.id.slice(0,8)})}),e("td",{class:"muted",children:e("div",{class:"ov-prompt",children:(d.last_prompt??"").slice(0,90)})}),e("td",{class:"num",children:d.calls}),e("td",{class:"num",children:z(d.savedTokens)})]})):e("tr",{children:e("td",{class:"muted",colSpan:5,children:"no sessions recorded yet"})})})]})})})]})}function jd(){let t=V(()=>J("/api/sessions",{limit:60}),[]),[n,s]=x(null),[a,r]=x(""),[o,i]=x(100);U(()=>{!n&&t.data?.[0]&&s(t.data[0].id)},[t.data]);let l=V(()=>n?J("/api/events",{session:n,category:a||void 0,limit:o}):Promise.resolve([]),[n,a,o]),c=[...new Set((l.data??[]).map(p=>p.category))].sort();if(t.error)return e("div",{class:"page ds-page",children:e(Z,{error:t.error})});let u=t.data,d=u?.find(p=>p.current);return e("div",{class:"page ds-page",children:[e(Te,{eyebrow:"Sessions",title:u?`${u.length} recent session${u.length===1?"":"s"}`:"Sessions",sub:"Pick a session to read the events eminiar recorded for it.",meta:d?e(I,{tone:"ok",dot:!0,children:["current ",d.id.slice(0,8)]}):null}),e("div",{class:"ds-grid ss-split",children:[e(j,{flush:!0,title:"Sessions",right:u?.length??0,children:e("div",{class:"ss-list",children:u?u.length?u.map(p=>e("div",{class:E("ss-item",n===p.id&&"sel"),role:"button",tabIndex:0,"aria-pressed":n===p.id,onClick:()=>s(p.id),onKeyDown:g=>{g.target===g.currentTarget&&(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),s(p.id))},children:[e("div",{class:"ss-item-head",children:[e("code",{children:p.id.slice(0,8)}),p.current?e(I,{tone:"ok",dot:!0,children:"current"}):null,e("a",{class:"small",href:`#/usage?session=${p.id}`,children:"usage \u2192"}),e("span",{class:"muted small ss-ago",children:me(p.started_at)})]}),e("div",{class:"ss-prompt",children:(p.last_prompt??"(no prompt yet)").slice(0,100)}),e("div",{class:"muted small",children:[p.calls," calls \xB7 ",z(p.savedTokens)," saved \xB7 ",tt(p.efficiency),p.source?` \xB7 ${p.source}`:""]})]})):e(X,{compact:!0,icon:"\u25CB",title:"No sessions yet"}):e("div",{class:"ss-skel",children:[e(N,{h:14}),e(N,{w:"70%",h:12}),e(N,{h:14})]})})}),e(j,{flush:!0,title:`Events \xB7 ${n?n.slice(0,8):"all"}`,right:e("span",{class:"ss-filters",children:[e("select",{"aria-label":"category",value:a,onChange:p=>r(p.target.value),children:[e("option",{value:"",children:"all categories"}),c.map(p=>e("option",{value:p,children:p}))]}),e("label",{class:"muted small",children:["limit"," ",e("select",{value:String(o),onChange:p=>i(Number(p.target.value)),children:[100,300,1e3].map(p=>e("option",{value:String(p),children:p}))})]}),e("span",{class:"muted small",children:[l.data?.length??0," shown"]})]}),children:l.error?e("div",{class:"ss-pad",children:e(Z,{error:l.error})}):(l.data??[]).length?e("div",{class:"ds-table-wrap",children:e("table",{children:[e("thead",{children:e("tr",{children:[e("th",{children:"time"}),e("th",{children:"category"}),e("th",{children:"tool"}),e("th",{children:"payload"})]})}),e("tbody",{children:(l.data??[]).map(p=>e("tr",{children:[e("td",{class:"muted nowrap",title:new Date(p.ts).toLocaleString(),children:pi(p.ts)}),e("td",{class:"nowrap",children:[e(I,{children:["P",p.priority]})," ",p.category]}),e("td",{children:p.tool??""}),e("td",{children:e("pre",{class:"json",children:JSON.stringify(p.payload).slice(0,400)})})]}))})]})}):l.loading?e("div",{class:"ss-skel",children:[e(N,{h:14}),e(N,{w:"80%",h:14})]}):e(X,{compact:!0,icon:"\u25CB",title:"No events"})})]})]})}var q={pending:"\u25CB",idle:"\u25CB",running:"\u25CF",active:"\u25CF",blocked:"\u25C6",done:"\u2713",failed:"\u2717",cancelled:"\u2717",stale:"\u25CC",coordinator:"\u2605"},Id=t=>`sw-s-${t}`,fr={pending:"muted",idle:"muted",running:"accent",active:"accent",blocked:"warn",done:"ok",failed:"bad",cancelled:"muted",stale:"warn",coordinator:"purple"},Be={hierarchical:"\u22D4",mesh:"\u2B21",pipeline:"\u21C9"},br={run_start:"\u25B8",run_finish:"\u25A0",plan:"+",claim:"\u2192",update:"\u270E",post:"\u2261",spawn:"\u2295",deny:"\u2298",start:"\u25CF",tool:"\u203A",tool_error:"\u2717",stop:"\u25A1",auto_close:"\u21BA"},qa=[["tools","tool calls",["tool","tool_error"]],["tasks","tasks",["plan","claim","update","auto_close"]],["notes","blackboard",["post"]],["workers","workers",["spawn","deny","start","stop"]],["run","run",["run_start","run_finish"]],["errors","errors",["tool_error","deny"]]],Ka={unchanged:{glyph:"\u2713",word:"agent file in sync",short:"in sync",cls:"sw-s-done"},create:{glyph:"\u25CB",word:"agent file missing",short:"missing",cls:"sw-s-pending"},update:{glyph:"\u25C6",word:"agent file stale",short:"stale",cls:"sw-s-blocked"},conflict:{glyph:"\u2717",word:"conflict: a hand-written file has this name",short:"conflict (hand-written file)",cls:"sw-s-failed"},delete:{glyph:"\u25CC",word:"generated file a sync will remove",short:"to be removed",cls:"sw-s-stale"},disabled:{glyph:"\u25CC",word:"no agent file (swarms disabled)",short:"none (disabled)",cls:"sw-s-stale"}},Pd=["var(--accent)","var(--tok-ty)","var(--tok-str)","var(--tok-kw)","var(--tok-num)","var(--muted)"];function mt(t,n){if(!t||t==="coordinator")return"var(--fg)";let s=n.indexOf(t);if(s<0){s=0;for(let a of t)s=s*31+a.charCodeAt(0)>>>0}return Pd[s%Pd.length]}function Fn(t){let n=t.payload?.io;return n==="read"||n==="write"||n==="exec"||n==="swarm"||n==="other"?n:t.kind==="tool"||t.kind==="tool_error"?"other":"swarm"}var We=t=>t?t.replace(/^agent-/,"").slice(0,8):"";function Ze(t){if(t==null||!Number.isFinite(t)||t<0)return"n/a";let n=Math.round(t/1e3);if(n<60)return`${n}s`;let s=Math.floor(n/60);if(s<60)return`${s}m ${String(n%60).padStart(2,"0")}s`;let a=Math.floor(s/60);return a<24?`${a}h ${String(s%60).padStart(2,"0")}m`:`${Math.floor(a/24)}d ${a%24}h`}function Ht(t,n){let s=Math.max(0,n-t);return s<6e4?`${Math.floor(s/1e3)}s`:s<36e5?`${Math.floor(s/6e4)}m`:s<864e5?`${Math.floor(s/36e5)}h`:`${Math.floor(s/864e5)}d`}function ze(t,n,s){let[,a]=x(0);return U(()=>{if(!n)return;let r=setInterval(()=>{document.visibilityState==="visible"&&a(o=>o+1)},t);return()=>clearInterval(r)},[t,n]),Date.now()+s}function st(t){class n extends fn{shouldComponentUpdate(a){let r=this.props,o=a;for(let i in o)if(r[i]!==o[i])return!0;for(let i in r)if(!(i in o))return!0;return!1}render(a){return bn(t,a)}}return n}var Fd=t=>n=>{n.target===n.currentTarget&&(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),t())};function qe({s:t,word:n,title:s}){return e("span",{class:E("sw-state",Id(t)),title:s,children:[e("span",{class:"g","aria-hidden":"true",children:q[t]}),n??t]})}function Ke({role:t,roles:n,title:s,label:a,children:r}){return e("span",{class:"sw-chip",style:`--rc:${mt(t,n)}`,title:s,children:[a??t??"any role",r]})}function Ut({title:t,meta:n,children:s}){return e("div",{class:"sw-head",children:[e("span",{class:"t",children:t}),e("span",{class:"rule","aria-hidden":"true"}),n!=null&&n!==""?e("span",{class:"m",children:n}):null,s]})}function Ph({notes:t,roles:n,live:s,skew:a}){let r=ze(15e3,s,a),[o,i]=x(null);return e("div",{class:"card",children:[e(Ut,{title:"Blackboard",meta:`${t.length} key${t.length===1?"":"s"}`}),t.length?e("div",{class:"sw-notes",children:t.map(l=>{let c=o===l.key,u=l.author??"n/a";return e("div",{class:E("sw-note-row",c&&"open"),children:[e("button",{type:"button",class:"sw-btn sw-note-sum","aria-expanded":c,title:c?"hide the value":"show the value",onClick:()=>i(c?null:l.key),children:[e("div",{class:"h",children:[e("code",{class:"k",children:l.key}),e("span",{class:"v",children:["v",l.version]}),e(Ke,{role:u.split("@")[0],roles:n,label:u}),e("span",{class:"age",title:new Date(l.ts).toLocaleString(),children:Ht(l.ts,r)})]}),c?null:e("div",{class:"p",children:l.value.trim().split(`
|
|
82
|
+
`)[0]?.slice(0,160)})]}),c?e("pre",{class:"sw-pre",children:l.value}):null]},l.key)})}):e("div",{class:"empty small",children:["Nothing shared yet. Workers post with"," ",e("code",{children:["em_swarm ",'{action:"post", key, value}']}),"."]})]})}var Od=st(Ph);var Ih=new Set(["claim","post","update","plan","spawn","start","stop","auto_close"]),Fh=1e4,Nd=2500,Ya=12,Oh=6,Bd=8,Hd=110,Nh=.95;function Bh(t,n){let s=n.length>Ya;return t.map(a=>{let r=n.filter(i=>i.role===a),o=[];for(let i of r)(!s||i.status==="running"&&o.length<Oh)&&o.push({type:"worker",id:i.agent_id,role:a,w:i});if(s&&r.length>o.length){let i=r.filter(c=>!o.some(u=>u.id===c.agent_id)),l=c=>i.filter(u=>u.status===c).length;o.push({type:"group",id:`fold:${a}`,role:a,n:i.length,running:l("running"),stale:l("stale"),done:l("done")})}return o.length||o.push({type:"idle",id:`idle:${a}`,role:a}),o})}var Hh=t=>[t.running?`${q.running}${t.running}`:"",t.stale?`${q.stale}${t.stale}`:"",t.done?`${q.done}${t.done}`:""].filter(Boolean).join(" "),Va=116,Ud=56;function Za(t,n,s,a){let r=n.flat();if(t==="pipeline"){let u=[...s,...a.filter(w=>!s.includes(w))],d=u.map(w=>n[a.indexOf(w)]??[]),p=84,g=Math.max(1,...d.map(w=>w.length)),h=Math.max(240,96+g*p),y=150,m=150,f=m+d.length*y+10,v=[],b=[];return d.forEach((w,k)=>{let C=m+k*y+y/2,S=60+(h-60-w.length*p)/2;w.forEach((T,M)=>{v.push({item:T,x:C,y:S+M*p+22})});let _=u[k];b.push({x:m+k*y+6,w:y-12,label:On(s.includes(_)?`${s.indexOf(_)+1} \xB7 ${_}`:_,20),n:w.length})}),{w:f,h,hub:{x:60,y:h/2},nodes:v,peers:[],lanes:b}}if(t==="mesh"){let u=r.length,d=Math.max(100,u*120/(2*Math.PI)),p=Math.max(640,2*d+2*Ud+120),g=2*d+130,h=p/2,y=d+46,m=r.map((v,b)=>{let w=-Math.PI/2+2*Math.PI*b/Math.max(1,u);return{item:v,x:h+d*Math.cos(w),y:y+d*Math.sin(w)}}),f=[];for(let v=0;v<m.length;v++)for(let b=v+1;b<m.length;b++)(u<=8||b===v+1||v===0&&b===u-1)&&f.push([m[v],m[b]]);return{w:p,h:g,hub:{x:h,y},nodes:m,peers:f,lanes:[]}}let o=[[]];for(let u of n){let d=o[o.length-1];d.length&&d.length+u.length>Bd&&o.push([]);for(let p of u)o[o.length-1].length>=Bd&&o.push([]),o[o.length-1].push(p)}let i=Math.max(1,...o.map(u=>u.length)),l=Math.max(640,i*Va+2*Ud),c=o.flatMap((u,d)=>{let p=(l-u.length*Va)/2;return u.map((g,h)=>({item:g,x:p+Va*(h+.5),y:200+d*Hd}))});return{w:l,h:286+(o.length-1)*Hd,hub:{x:l/2,y:58},nodes:c,peers:[],lanes:[]}}var On=(t,n)=>t.length>n?`${t.slice(0,n-1)}\u2026`:t;function Qa(t,n,s){if(t==="hierarchical"){let a=(n.y+s.y)/2;return`M${n.x},${n.y} C${n.x},${a} ${s.x},${a} ${s.x},${s.y}`}if(t==="pipeline"){let a=(n.x+s.x)/2;return`M${n.x},${n.y} C${a},${n.y} ${a},${s.y} ${s.x},${s.y}`}return`M${n.x},${n.y} L${s.x},${s.y}`}function Uh({detail:t,events:n,skew:s,roles:a,picked:r,onPick:o}){let i=t.run.topology,l=t.run.status==="active",c=ze(1e3,l,s),u=Bh(a,t.workers),d=Za(i,u,t.stages,a),p=u.flat().some(b=>b.type==="group"),g=new Map,h=new Set,y=new Set;for(let b of n){let w=c-b.ts;b.agent_id&&w<Nd&&w>-Nd&&g.set(b.agent_id,b),w<Fh&&Ih.has(b.kind)&&(b.agent_id?h.add(b.agent_id):b.role&&y.add(b.role))}let m=new Map(t.tasks.map(b=>[b.id,b.title])),f=b=>l&&(b.type==="worker"?h.has(b.id):b.type==="idle"&&y.has(b.role)),v=te(null);return U(()=>{let b=v.current;b&&b.scrollWidth>b.clientWidth&&(b.scrollLeft=d.hub.x/d.w*b.scrollWidth-b.clientWidth/2)},[i]),e("div",{class:"sw-topo-wrap",ref:v,children:[e("svg",{class:E("sw-topo",`topo-${i}`),viewBox:`0 0 ${d.w} ${d.h}`,style:{maxWidth:`${d.w}px`,minWidth:`${Math.round(d.w*Nh)}px`},role:"group","aria-label":`${i} topology: coordinator and ${t.workers.length} workers${p?", quiet workers folded per role":""}`,children:[d.lanes.map((b,w)=>e("g",{class:"sw-lane",children:[e("rect",{x:b.x,y:8,width:b.w,height:d.h-16,rx:8}),e("text",{x:b.x+b.w/2,y:26,children:b.label}),w<d.lanes.length-1?e("text",{class:"arrow",x:b.x+b.w+6,y:26,children:"\u2192"}):null]})),d.peers.map(([b,w])=>e("line",{class:E("sw-edge peer",(f(b.item)||f(w.item))&&"hot"),x1:b.x,y1:b.y,x2:w.x,y2:w.y})),d.nodes.map(b=>{let w=Qa(i,d.hub,b),k=f(b.item),C=mt(b.item.role,a),S=l&&b.item.type==="worker"&&b.item.w.status==="running";return e("g",{children:[e("path",{class:E("sw-edge spoke",k&&"hot",S&&"live",b.item.type!=="worker"&&"ghost",b.item.type==="worker"&&r===b.item.id&&"picked"),d:w,style:{stroke:k||S?C:void 0}}),k?e("path",{class:"sw-comet",d:w,pathLength:100,style:{stroke:C}}):null]},b.item.id)}),e("g",{class:E("sw-node hub",l&&"live"),transform:`translate(${d.hub.x},${d.hub.y})`,children:[l?e("circle",{class:"sw-halo",r:30}):null,l?e("circle",{class:"sw-halo late",r:30}):null,e("circle",{class:"sw-core",r:22}),e("text",{class:"sw-glyph",dy:6,children:q.coordinator}),e("text",{class:"sw-l1",y:i==="hierarchical"?-32:40,children:"coordinator"}),e("title",{children:"coordinator: the main Claude Code session leads the run"})]}),d.nodes.map(({item:b,x:w,y:k})=>{let C=mt(b.role,a);if(b.type==="group")return e("g",{class:"sw-node group",transform:`translate(${w},${k})`,children:[e("circle",{class:"sw-core",r:17,style:{stroke:C}}),e("text",{class:"sw-glyph sw-plus",dy:4,style:{fill:C},children:["+",b.n]}),e("text",{class:"sw-l1",y:33,style:{fill:C},children:On(b.role,16)}),e("text",{class:"sw-l2",y:47,children:Hh(b)}),e("title",{children:`${b.n} more ${b.role} worker(s), folded: ${b.running} running \xB7 ${b.stale} stale \xB7 ${b.done} done. Every worker is listed in the timeline.`})]},b.id);if(b.type==="idle")return e("g",{class:"sw-node idle",transform:`translate(${w},${k})`,children:[e("circle",{class:"sw-core",r:16,style:{stroke:C}}),e("text",{class:"sw-glyph",dy:5,style:{fill:C},children:q.idle}),e("text",{class:"sw-l1",y:32,style:{fill:C},children:On(b.role,16)}),e("text",{class:"sw-l2",y:46,children:`${q.idle} idle`}),e("title",{children:`${b.role}: no worker spawned in this run yet`})]},b.id);let S=b.w,_=g.get(S.agent_id),T=S.task_id?`#${S.task_id}`:"",M=r===S.agent_id,F=()=>o(M?null:S.agent_id);return e("g",{class:E("sw-node worker",`st-${S.status}`,l&&S.status==="running"&&"glow",M&&"picked"),transform:`translate(${w},${k})`,style:{"--rc":C},tabindex:0,role:"button","aria-pressed":M,"aria-label":`${S.role} worker ${We(S.agent_id)}, ${S.status}${T?`, task ${T}`:""}: ${M?"show every worker's":"show only its"} activity`,onClick:F,onKeyDown:Fd(F),children:[e("circle",{class:"sw-focus",r:27}),M?e("circle",{class:"sw-ring",r:24}):null,S.status==="running"&&l?e("circle",{class:"sw-halo",r:24,style:{stroke:C}}):null,_?e("circle",{class:E("sw-flash",`io-${Fn(_)}`),r:20},_.id):null,e("circle",{class:"sw-core",r:17,style:{stroke:C}}),e("text",{class:"sw-glyph",dy:5,style:{fill:C},children:q[S.status]}),e("text",{class:"sw-l1",y:33,children:[e("tspan",{style:{fill:C},children:On(S.role,8)}),e("tspan",{class:"id",children:["\xB7",We(S.agent_id)]})]}),e("text",{class:E("sw-l2",`sw-s-${S.status}`),y:47,children:[q[S.status]," ",S.status,T?` ${T}`:""]}),e("title",{children:[`${S.role} worker ${S.agent_id}`,`${S.status}${S.task_id?` \xB7 task #${S.task_id} ${m.get(S.task_id)??""}`:""}`,`${S.tool_calls} tool calls \xB7 ${S.errors} errors${S.last_tool?` \xB7 last ${S.last_tool}`:""}`,"click (or Enter) to filter the activity feed"].join(`
|
|
83
|
+
`)})]},b.id)})]}),e("div",{class:"sw-legend small muted",children:[e("span",{children:[e("i",{class:"sw-sw io-read"})," read"]}),e("span",{children:[e("i",{class:"sw-sw io-write"})," write"]}),e("span",{children:[e("i",{class:"sw-sw io-exec"})," exec"]}),e("span",{children:[e("i",{class:"sw-sw io-swarm"})," swarm"]}),e("span",{class:"sep",children:"\xB7"}),e("span",{children:[q.running," running \xB7 ",q.stale," stale \xB7 ",q.done," done \xB7 ",q.idle," idle",p?" \xB7 +N folded":""]})]})]})}var Jd=st(Uh);var Jh=3;function Xh(t){let s=t.reduce((a,r)=>a+Math.max(1,r.count),0)>Ya;return t.map(a=>{let r=Math.max(1,a.count),o=s?Math.min(r,Jh):r,i=[];for(let l=0;l<o;l++)i.push({type:"idle",id:`cfg:${a.name}:${l}`,role:a.name});return r>o&&i.push({type:"group",id:`cfg:${a.name}:+`,role:a.name,n:r-o,running:0,stale:0,done:0}),i})}function Gh({topology:t,roles:n,stages:s=[],maxAgents:a,label:r,class:o}){let i=n.map(d=>d.name),l=Xh(n),c=Za(t,l,s,i),u=n.reduce((d,p)=>d+Math.max(1,p.count),0);return e("svg",{class:E("sw-topo sw-topo-preview",`topo-${t}`,o),viewBox:`0 0 ${c.w} ${c.h}`,role:"img","aria-label":r??`${t} swarm preview: coordinator and ${u} worker slot${u===1?"":"s"} over ${n.length} role${n.length===1?"":"s"}${a?`, at most ${a} at once`:""}`,children:[c.lanes.map((d,p)=>e("g",{class:"sw-lane",children:[e("rect",{x:d.x,y:8,width:d.w,height:c.h-16,rx:8}),e("text",{x:d.x+d.w/2,y:26,children:d.label}),p<c.lanes.length-1?e("text",{class:"arrow",x:d.x+d.w+6,y:26,children:"\u2192"}):null]})),c.peers.map(([d,p])=>e("line",{class:"sw-edge peer",x1:d.x,y1:d.y,x2:p.x,y2:p.y})),c.nodes.map(d=>e("path",{class:"sw-edge spoke cfg",d:Qa(t,c.hub,d),style:{stroke:mt(d.item.role,i)}},d.item.id)),e("g",{class:"sw-node hub",transform:`translate(${c.hub.x},${c.hub.y})`,children:[e("circle",{class:"sw-core",r:22}),e("text",{class:"sw-glyph",dy:6,children:q.coordinator}),e("text",{class:"sw-l1",y:t==="hierarchical"?-32:40,children:"coordinator"})]}),c.nodes.map(({item:d,x:p,y:g})=>{let h=mt(d.role,i),y=d.type==="group";return e("g",{class:E("sw-node cfg",y&&"group"),transform:`translate(${p},${g})`,style:{"--rc":h},children:[e("circle",{class:"sw-core",r:y?15:16,style:{stroke:h}}),e("text",{class:E("sw-glyph",y&&"sw-plus"),dy:y?4:5,style:{fill:h},children:y?`+${d.n}`:(d.role[0]??"?").toUpperCase()}),e("text",{class:"sw-l1",y:32,style:{fill:h},children:On(d.role,16)}),e("title",{children:y?`${d.n} more ${d.role} slot(s)`:`${d.role} worker slot`})]},d.id)})]})}var Nn=st(Gh);var eo=300;function Wh({events:t,roles:n,live:s,skew:a,behind:r,agent:o,onAgent:i}){let l=ze(5e3,s,a),[c,u]=x(""),[d,p]=x(""),g=qa.find(([m])=>m===d)?.[2],h=[...new Set([...n,...t.map(m=>m.role??"").filter(Boolean)])],y=t.filter(m=>(!c||m.role===c)&&(!g||g.includes(m.kind))&&(!o||m.agent_id===o)).reverse();return e("div",{class:"card sw-feed-card",children:[e(Ut,{title:"Activity",meta:`${y.length}${y.length!==t.length?` of ${t.length}`:""} events`}),e("div",{class:"row sw-filters",children:[e("select",{value:c,onChange:m=>u(m.target.value),children:[e("option",{value:"",children:"all roles"}),h.map(m=>e("option",{value:m,children:m}))]}),e("select",{value:d,onChange:m=>p(m.target.value),children:[e("option",{value:"",children:"all kinds"}),qa.map(([m,f])=>e("option",{value:m,children:f}))]}),o?e("button",{type:"button",class:"chip on",onClick:()=>i(null),title:"clear",children:["worker ",We(o)," \u2715"]}):null]}),e("div",{class:"sw-feed",role:"log","aria-live":"polite",children:[r?e("div",{class:"sw-ev sw-gap",role:"status",children:[e("span",{class:"t",children:"\u25B2"}),e("span",{class:"x",children:"catching up: newer events are still loading; the rows below are not the latest yet"})]}):null,y.length?y.slice(0,eo).map(m=>{let f=Fn(m);return e("div",{class:E("sw-ev",`k-${m.kind}`,`io-${f}`),title:`${new Date(m.ts).toLocaleString()} \xB7 ${m.kind}${m.agent_id?` \xB7 ${m.agent_id}`:""}`,children:[e("span",{class:"t",children:Ht(m.ts,l)}),e(Ke,{role:m.role??"coordinator",roles:n}),e("span",{class:"g",title:m.kind,children:br[m.kind]??"\xB7"}),e("span",{class:"x",children:[m.task_id?e("b",{children:["#",m.task_id," "]}):null,m.text??m.kind]})]},m.id)}):e("div",{class:"empty small",children:["no events",t.length?" match the filter":" yet"]}),y.length>eo?e("div",{class:"muted small sw-more",children:[y.length-eo," older events not shown; narrow the filter"]}):null]})]})}var Xd=st(Wh);function Wd(t,n=30){let s=t.cut&&t.from?t.from:t.start,a=Math.max(0,t.end-s),r=Math.max(6e4,Math.ceil(a/Math.max(1,n)/6e4)*6e4),o=Math.max(1,Math.ceil(a/r)),i=new Array(o).fill(0),l=0;for(let d of t.workers)for(let p of d.segments){if(p.n<=0||p.end<s)continue;l+=p.n;let g=Math.max(s,p.start),h=Math.max(g,Math.min(t.end,p.end)),y=Math.min(o-1,Math.max(0,Math.floor((g-s)/r))),m=Math.min(o-1,Math.max(0,Math.floor((h-s)/r)));if(y===m||h===g){i[y]+=p.n;continue}for(let f=y;f<=m;f++){let v=Math.max(g,s+f*r),b=Math.min(h,s+(f+1)*r);i[f]+=p.n*Math.max(0,b-v)/(h-g)}}let c=r/6e4,u=i.map(d=>Math.round(d/c*10)/10);return{values:u,bucketMs:r,peak:Math.max(0,...u),total:l}}function yr(t,n,s){let a=Math.max(0,n-t.last_ts);return{age:a,quiet:t.status==="stale"||t.status==="running"&&a>s}}var Gd={running:0,stale:1,done:2};function zd(t){return[...t].sort((n,s)=>Gd[n.status]-Gd[s.status]||n.spawned_at-s.spawned_at)}function qd(t,n){return t.filter(s=>s.agent_id===n).sort((s,a)=>a.updated_at-s.updated_at)}var to=["all","active","done","failed"],Kd=(t,n)=>n==="all"||(n==="failed"?t==="failed"||t==="cancelled":t===n),Vd=(t,n)=>t.filter(s=>Kd(s.status,n));function Yd(t){let n={all:0,active:0,done:0,failed:0};for(let s of t)for(let a of to)Kd(s.status,a)&&n[a]++;return n}function vr(t){return t.total>0?Math.min(1,t.done/t.total):0}function ls(t,n){let s=t.reduce((a,r)=>a+Math.max(0,r.count),0);return{total:s,max:n,over:n>0&&s>n}}var cs=(t,n="<goal>")=>`/eminiar:em-swarm ${t} ${n}`;function Zd(t,n){if(t.length<=n)return{text:t,clipped:!1};let s=t.lastIndexOf(`
|
|
84
|
+
`,n);return{text:`${t.slice(0,s>n*.6?s:n).trimEnd()}\u2026`,clipped:!0}}function zh({f:t}){return t.memoryError?e("div",{class:"sw-note-box warn small",role:"alert",children:[e(qe,{s:"blocked",word:"memory not written"})," The run closed as ",e("b",{children:t.status}),", but its outcome was not saved as a memory: ",t.memoryError,". Record it with ",e("code",{children:"em_remember"}),"."]}):t.remember&&t.memory?e("div",{class:"sw-note-box small",children:[e(qe,{s:"done",word:"memory written"})," ",e("code",{children:t.memory})]}):null}function qh({id:t,onDone:n}){let[s,a]=x(!1),[r,o]=x("done"),[i,l]=x(""),[c,u]=x(!1),[d,p]=x(!1),[g,h]=x();return s?e("form",{class:"sw-finish",onSubmit:async y=>{y.preventDefault(),p(!0),h(void 0);try{let m=await $e("/api/swarm/finish",{id:t,status:r,summary:i.trim()||void 0,remember:c}),f=m.memoryError??null;ee(f?`run finished as ${r} \xB7 its memory was NOT written`:`run finished as ${r}${m.memory?` \xB7 memory ${m.memory}`:""}`,!!f),a(!1),n({status:r,memory:m.memory,memoryError:f,remember:c})}catch(m){h(m.message)}finally{p(!1)}},children:[e("div",{class:"row",children:[e("span",{class:"small muted",children:"close the run as"}),["done","failed","cancelled"].map(y=>e("label",{class:E("sw-radio",r===y&&"on"),children:[e("input",{type:"radio",name:`finish-${t}`,checked:r===y,onChange:()=>o(y)}),e(qe,{s:y})]}))]}),e("textarea",{class:"sw-summary",placeholder:"Summary (optional): the outcome in a sentence or two",value:i,maxLength:4e3,onInput:y=>l(y.target.value)}),e("label",{class:"small row tight",children:[e("input",{type:"checkbox",checked:c,onChange:y=>u(y.target.checked)}),"also write the outcome as a project memory (",e("code",{children:"swarm/run-\u2026"}),")"]}),e("div",{class:"row",children:[e("button",{type:"submit",class:"primary sm",disabled:d,children:d?"Finishing\u2026":`Finish as ${r}`}),e("button",{type:"button",class:"ghost sm",onClick:()=>a(!1),children:"Keep running"}),g?e("span",{class:"bad small",children:g}):null]})]}):e("button",{type:"button",class:"sm sw-finish-btn",onClick:()=>a(!0),children:"\u25A0 Finish run\u2026"})}var Kh=(t,n)=>t.status==="active"?n-t.created_at:t.ended_at?t.ended_at-t.created_at:null;function Vh({run:t,skew:n}){let s=t.status==="active",a=ze(1e3,s,n);return e(le,{label:"elapsed",value:e("span",{class:"ds-mono",children:Ze(Kh(t,a))}),tone:s?"accent":"muted",sub:s?`since ${new Date(t.created_at).toLocaleTimeString()}`:t.ended_at?`ended ${me(t.ended_at)}`:"end time not recorded"})}function Qd({detail:t,skew:n,finished:s,onFinished:a}){let{run:r,counts:o}=t,i=r.status==="active",l=t.tasks.length,c=o.tasks.failed+o.tasks.blocked,u=t.workers.length,d=o.workers.running,p=t.maxAgents??0,g=Wd(t.timeline),h=vr({done:o.tasks.done,total:l}),y=o.toolCalls>0?o.errors/o.toolCalls:0;return e("div",{class:E("sw-hero",i&&"is-live"),children:[e(Te,{eyebrow:e(R,{children:[e("span",{class:"sw-hero-topo",title:r.topology,children:Be[r.topology]}),e("span",{children:[r.topology," swarm ",e("b",{class:"sw-hero-swarm",children:r.swarm})]}),e("code",{class:"sw-hero-id",title:"run id",children:r.id})]}),title:e("span",{class:"sw-hero-goal",children:r.goal}),sub:r.summary?e("span",{class:"sw-hero-summary",children:r.summary}):e("span",{title:new Date(r.created_at).toLocaleString(),children:["started ",me(r.created_at),r.session_id?e(R,{children:[" ","by session ",e("code",{children:r.session_id.slice(0,8)})]}):null]}),meta:e(R,{children:[e(It,{tone:fr[r.status],pulse:i,title:`run ${r.status}`,children:[i?"":`${q[r.status]} `,r.status]}),t.configured?null:e(I,{tone:"warn",title:"the run's swarm was removed from the swarm file",children:[q.blocked," swarm no longer configured"]}),o.staleHeld?e(I,{tone:"warn",title:"active tasks held by a worker that went quiet or stopped",children:[q.stale," ",o.staleHeld," held by a quiet worker"]}):null,o.autoClosed?e(I,{tone:"warn",title:"tasks closed by SubagentStop: the worker stopped without reporting",children:["\u21BA ",o.autoClosed," auto-closed"]}):null,i?e(qh,{id:r.id,onDone:a}):null]}),aside:e(R,{children:[e(Kt,{class:"sw-hero-gauge",value:h,size:104,tone:c&&!o.tasks.done?"bad":"ok",label:l?`${Math.round(h*100)}%`:"\u2013",caption:l?"done":"no tasks",title:`${o.tasks.done} of ${l} tasks done`}),e(Kt,{value:p?d/p:d?1:0,size:80,tone:i?"accent":"muted",label:p?`${d}/${p}`:String(d),caption:"running",title:p?`${d} of at most ${p} workers running at once (max_agents)`:`${d} workers running`})]})}),s?e(zh,{f:s}):null,e(Re,{children:[e(le,{label:"workers",value:e(R,{children:[d,e("span",{class:"sw-stat-of",children:["/",p||u]})]}),tone:d?"accent":"muted",sub:u?`${u} spawned \xB7 ${o.workers.stale} stale \xB7 ${o.workers.done} done`:"none spawned yet"}),e(le,{label:"tasks",value:e(R,{children:[o.tasks.done,e("span",{class:"sw-stat-of",children:["/",l]})]}),tone:c?"warn":"ok",sub:l?`${o.tasks.active} active \xB7 ${o.tasks.pending} pending \xB7 ${c} failed/blocked`:"none planned",children:l?e(St,{total:l,title:`${o.tasks.done} done \xB7 ${o.tasks.active} active \xB7 ${c} failed/blocked of ${l}`,segments:[{value:o.tasks.done,tone:"ok",label:`${o.tasks.done} done`},{value:o.tasks.active,tone:"accent",label:`${o.tasks.active} active`},{value:c,tone:"bad",label:`${c} failed/blocked`}]}):null}),e(le,{label:"tool calls",value:z(o.toolCalls),tone:"purple",sub:g.total?`peak ${z(Math.round(g.peak))}/min`:u?"no activity drawn yet":"no workers yet",children:g.values.length>1?e(Rs,{values:g.values,tone:"purple",height:30,title:`events per minute, ${g.values.length} buckets of ${Math.round(g.bucketMs/6e4)} min`}):null}),e(le,{label:"errors",value:z(o.errors),tone:o.errors>0?"bad":"ok",sub:o.toolCalls?`${(y*100).toFixed(y<.1?1:0)}% of tool calls failed`:"failed tool calls"}),e(Vh,{run:r,skew:n})]})]})}function eu({page:t,o:n}){let s=n?n.runs.filter(o=>o.status==="active").length:0,a=n?.state==="invalid"?n.issues.length:0,r=n?n.state==="absent"?{tone:"muted",text:"not opted in"}:n.state==="invalid"?{tone:"bad",text:`${q.failed} file invalid`}:n.enabled?n.syncNeeded?{tone:"warn",text:`${q.blocked} agent files out of date`}:{tone:"ok",text:`${q.done} enabled \xB7 in sync`}:{tone:"warn",text:`${q.stale} disabled`}:null;return e("nav",{class:"sw-nav","aria-label":"Swarms pages",children:[e(Se,{label:"Swarms pages",value:t,onChange:o=>H(o==="config"?"swarm/config":"swarm"),options:[{id:"runs",title:"the run dashboard: live topology, workers, tasks and events",label:e(R,{children:["Runs",s?e("span",{class:"sw-nav-count live",title:`${s} active run(s)`,children:[q.active," ",s," active"]}):null]})},{id:"config",title:"the configuration studio: edit .eminiar/swarm.yaml",label:e(R,{children:["Configure",a?e("span",{class:"sw-nav-count bad",title:`${a} issue(s) in the swarm file`,children:["\u26A0 ",a," issue",a===1?"":"s"]}):null]})}]}),e("span",{class:"sw-nav-meta",children:[n?e("code",{class:"sw-nav-file",children:n.file}):null,r?e(I,{tone:r.tone,title:"swarm file state, re-read every 15 s",children:r.text}):null]})]})}var Yh=[["pending",["pending"],!1],["active",["active"],!1],["done",["done"],!0],["failed / blocked",["failed","blocked"],!0]],no=30,Zh=15e3;function Qh(t,n){if(!t.agent_id)return t.status==="pending"?"unassigned":"n/a";let s=n.get(t.agent_id);return s?`${s.role}\xB7${We(s.agent_id)}`:t.agent_id.startsWith("agent-")?We(t.agent_id):t.agent_id}function ef(t,n){let[s,a]=x(),[r,o]=x();return U(()=>{if(!n||!t.clipped)return;let i=!0;return o(void 0),J("/api/swarm/task",{id:t.id,run:t.run_id}).then(l=>i&&a(l.task),l=>i&&o(l.message)),()=>{i=!1}},[n,t.clipped,t.id,t.updated_at]),t.clipped?s&&s.updated_at>=t.updated_at?{task:s,loading:!1}:r?{task:t,loading:!1,error:r}:{task:t,loading:!0}:{task:t,loading:!1}}function tf({t,roles:n,workers:s,byId:a,now:r}){let[o,i]=x(!1),l=ef(t,o),c=l.task,u=t.deps.filter(h=>a.get(h)?.status!=="done"),d=t.result?.trim().split(`
|
|
85
|
+
`)[0],p=t.status==="active"&&t.agent_id?s.get(t.agent_id):void 0,g=p&&p.status!=="running"?p.status:null;return e("div",{class:E("sw-task",`st-${t.status}`,o&&"open"),children:[e("button",{type:"button",class:"sw-btn sw-task-sum","aria-expanded":o,title:d?`result: ${d.slice(0,300)}`:void 0,onClick:()=>i(h=>!h),children:[e("div",{class:"h",children:[e("span",{class:"id",children:["#",t.id]}),e("span",{class:"title",children:t.title})]}),e("div",{class:"m",children:[e(qe,{s:t.status}),e(Ke,{role:t.role,roles:n}),e("span",{class:"who",title:t.agent_id??void 0,children:Qh(t,s)}),t.files.length?e("span",{class:"files",title:t.files.join(`
|
|
86
|
+
`),children:[t.files.length," file",t.files.length===1?"":"s"]}):null,g?e("span",{class:"sw-badge warn",title:"the worker holding this task went quiet or stopped; the coordinator can reopen it (status pending)",children:[q.stale," holder ",g]}):null,t.auto_closed?e("span",{class:"sw-badge warn",title:"closed from the worker's final message because it never reported; check the result and reopen if wrong",children:"auto-closed"}):null,t.deps.length?e("span",{class:E("deps",u.length>0&&"waiting"),children:["after ",t.deps.map(h=>`#${h}`).join(", ")]}):null,e("span",{class:"age",children:Ht(t.updated_at,r)})]})]}),o?e("div",{class:"x",children:[c.detail?e("pre",{class:"sw-pre",children:c.detail}):null,c.result?e(R,{children:[e("div",{class:"lbl",children:["result",t.auto_closed?" (auto-closed)":""]}),e("pre",{class:"sw-pre",children:c.result})]}):e("div",{class:"lbl",children:"no result yet"}),l.loading?e("div",{class:"lbl",children:"\u2026 loading the full text"}):null,l.error?e("div",{class:"lbl bad",children:["text cut at 300 characters; loading the rest failed: ",l.error]}):null,t.files.length?e("div",{class:"flist",children:t.files.map(h=>e("a",{href:`#/explore?file=${encodeURIComponent(h)}`,children:e("code",{children:h})}))}):null,e("div",{class:"lbl",children:["created by ",t.created_by??"n/a"," \xB7 ",new Date(t.created_at).toLocaleString()]})]}):null]})}function nf({label:t,tasks:n,roles:s,workers:a,byId:r,now:o}){let[i,l]=x(no),c=n.length-i;return e("div",{class:"sw-col",children:[e("div",{class:"ch",children:[e("span",{children:t}),e("span",{class:"n",children:n.length})]}),n.slice(0,i).map(u=>e(tf,{t:u,roles:s,workers:a,byId:r,now:o},u.id)),c>0?e("button",{type:"button",class:"ghost sm sw-col-more",onClick:()=>l(u=>u+no),title:`${c} more ${t} task${c===1?"":"s"} not shown`,children:["show ",Math.min(no,c)," more \xB7 ",c," hidden"]}):null]})}function sf({tasks:t,workers:n,roles:s,live:a,skew:r}){let o=ze(Zh,a,r),i=new Map(t.map(u=>[u.id,u])),l=new Map(n.map(u=>[u.agent_id,u])),c=t.filter(u=>u.status==="done").length;return e("div",{class:"card sw-board-card",children:[e(Ut,{title:"Tasks",meta:t.length?`${c}/${t.length} done`:"none planned"}),t.length?e("div",{class:"sw-board",children:Yh.map(([u,d,p])=>{let g=t.filter(h=>d.includes(h.status));return p&&g.sort((h,y)=>y.updated_at-h.updated_at||y.id-h.id),e(nf,{label:u,tasks:g,roles:s,workers:l,byId:i,now:o},u)})}):e("div",{class:"empty small",children:["No tasks yet. The coordinator plans them with ",e("code",{children:["em_swarm ",'{action:"plan"}']}),"."]})]})}var tu=st(sf);var rf=t=>{let n=Object.entries(t.io).filter(([,s])=>s>0).map(([s,a])=>`${a} ${s}`).join(" \xB7 ");return[`${new Date(t.start).toLocaleTimeString()} \u2192 ${t.open?"now":new Date(t.end).toLocaleTimeString()} (${Ze(t.end-t.start)})`,`${t.n} events${n?` \xB7 ${n}`:""}${t.errors?` \xB7 ${t.errors} errors`:""}`].join(`
|
|
87
|
+
`)},af=t=>{let n="swarm",s=-1;for(let[a,r]of Object.entries(t.io))r>s&&(n=a,s=r);return s>0?n:"swarm"};function so({agent:t,onRelease:n}){let[s,a]=x(!1),[r,o]=x(!1);return U(()=>{if(!s)return;let i=setTimeout(()=>a(!1),4e3);return()=>clearTimeout(i)},[s]),e("button",{type:"button",class:E("sm sw-release",s?"danger":"ghost"),disabled:r,title:"this worker went quiet with no SubagentStop: stop it and put its task back to pending (em_swarm release)",onClick:async()=>{if(!s)return a(!0);o(!0);try{await n(t)}finally{o(!1),a(!1)}},children:r?"releasing\u2026":s?"confirm release":"release"})}function of({timeline:t,live:n,roles:s,skew:a,onRelease:r}){let o=ze(5e3,n,a),i=t.start,l=Math.max(n?o:t.end,i+1e3),c=l-i,u=y=>`${Math.max(0,Math.min(100,(y-i)/c*100))}%`,d=(y,m)=>`${Math.max(0,Math.min(100,(Math.min(m,l)-Math.max(y,i))/c*100))}%`,p=[0,.25,.5,.75,1],g=t.cut&&t.from?t.from:null,h=g?`The timeline is drawn from the newest events only; activity before ${new Date(g).toLocaleString()} is not drawn.`:void 0;return e("div",{class:"card",children:[e(Ut,{title:"Timeline",meta:e("span",{title:h,children:[Ze(c),n?" \xB7 live":"",t.cut?` \xB7 oldest events cut${g?`, drawn from ${new Date(g).toLocaleTimeString()}`:""}`:""]})}),t.workers.length?e("div",{class:"sw-tl",children:[t.workers.map(y=>e("div",{class:"sw-tl-row",children:[e("div",{class:"who",title:y.agent_id,children:[e("span",{class:E("g",`sw-s-${y.status}`),children:q[y.status]}),e(Ke,{role:y.role,roles:s}),e("span",{class:"id",children:We(y.agent_id)}),n&&r&&y.status==="stale"?e(so,{agent:y.agent_id,onRelease:r}):null]}),e("div",{class:"track",style:"--rc:var(--line)",children:[g&&g>i?e("span",{class:"cut",style:{left:0,width:d(i,g)},title:h}):null,e("span",{class:"life",style:{left:u(y.spawned_at),width:d(y.spawned_at,y.ended_at??(n?o:l))}}),y.segments.map(m=>e("span",{class:E("seg",`io-${af(m)}`,m.errors>0&&"err",m.open&&"open"),style:{left:u(m.start),width:d(m.start,m.end)},title:rf(m)}))]})]},y.agent_id)),e("div",{class:"sw-tl-row axis",children:[e("div",{class:"who"}),e("div",{class:"track",children:p.map(y=>e("span",{class:"tick",style:{left:`${y*100}%`},children:y===0?new Date(i).toLocaleTimeString():`+${Ze(c*y)}`}))})]})]}):e("div",{class:"empty small",children:"No workers have started in this run."})]})}var nu=st(of);var lf=50,cf=900,wr=["haiku","sonnet","opus","fable"];function df({role:t}){let n=t.model??"inherit";if(!t.range)return e("div",{class:"sw-wd-model",children:[e(I,{tone:"purple",children:n}),e("span",{class:"muted small",children:t.model?"fixed pin":"inherits the session's model"})]});let s=wr.indexOf(t.range.floor),a=wr.indexOf(t.range.ceiling),r=t.model?wr.indexOf(t.model):-1;return e("div",{class:"sw-wd-model",children:[e(I,{tone:"purple",title:"fallback model inside the range",children:n}),e("span",{class:"muted small",children:["range ",t.range.floor,"..",t.range.ceiling]}),s>=0&&a>=0?e("div",{class:"sw-ladder",role:"img","aria-label":`model range ${t.range.floor} to ${t.range.ceiling}${t.model?`, fallback ${t.model}`:""}`,children:wr.map((o,i)=>e("span",{class:E("step",i>=s&&i<=a&&"in",i===r&&"at"),children:o}))}):null]})}function su({worker:t,role:n,roles:s,tasks:a,events:r,live:o,skew:i,staleMs:l,onClose:c}){let u=ze(5e3,o,i),[d,p]=x(!1),g=yr(t,u,l),h=qd(a,t.agent_id),y=[];for(let v=r.length-1;v>=0&&y.length<lf;v--)r[v].agent_id===t.agent_id&&y.push(r[v]);let m=t.prompt?Zd(t.prompt,cf):null,f=(t.ended_at??(o?u:t.last_ts))-t.spawned_at;return e(Sn,{onClose:c,title:e("span",{class:"sw-wd-title",children:[e(Ke,{role:t.role,roles:s})," ",e("code",{children:We(t.agent_id)})]}),actions:e(qe,{s:t.status}),footer:e(R,{children:[e("span",{class:"muted small sw-wd-foot",children:"the activity feed is filtered to this worker"}),e("button",{type:"button",class:"sm",onClick:c,children:"Close"})]}),children:[e(Re,{children:[e(le,{label:"tool calls",value:z(t.tool_calls),tone:"purple",sub:t.last_tool?`last ${t.last_tool}`:"none yet"}),e(le,{label:"errors",value:z(t.errors),tone:t.errors?"bad":"ok",sub:t.tool_calls?`${Math.round(100*t.errors/t.tool_calls)}% failed`:"failed tool calls"}),e(le,{label:t.status==="done"?"ran":"heartbeat",value:e("span",{class:"ds-mono",children:t.status==="done"?Ze(f):Ze(g.age)}),tone:g.quiet?"warn":"muted",sub:t.status==="done"?"spawn to stop":g.quiet?"quiet: no recent event":"since the last event"})]}),e("section",{class:"sw-wd-sec",children:[e("h4",{children:"Role"}),n?e(R,{children:[n.description?e("p",{class:"small sw-wd-p",children:n.description}):null,e(df,{role:n}),e("div",{class:"sw-wd-kv small",children:[e("span",{class:"k",children:"tools"}),e("span",{children:[n.tools?n.tools.join(", "):"all",n.disallowedTools?.length?e("span",{class:"muted",children:[" \xB7 not ",n.disallowedTools.join(", ")]}):null]}),n.scope.length?e(R,{children:[e("span",{class:"k",children:"scope"}),e("span",{class:"mono",children:n.scope.join(", ")})]}):null,n.skills.length?e(R,{children:[e("span",{class:"k",children:"skills"}),e("span",{children:n.skills.join(", ")})]}):null,e("span",{class:"k",children:"agent"}),e("span",{class:"mono",children:t.agent_type}),n.isolation?e(R,{children:[e("span",{class:"k",children:"isolation"}),e("span",{children:n.isolation})]}):null]})]}):e("p",{class:"small muted sw-wd-p",children:["Role ",e("b",{children:t.role})," is not in the swarm file any more; agent"," ",e("code",{children:t.agent_type}),"."]})]}),t.summary?e("section",{class:"sw-wd-sec",children:[e("h4",{children:"Summary"}),e("div",{class:"sw-summary-text",children:t.summary})]}):null,e("section",{class:"sw-wd-sec",children:[e("h4",{children:["Tasks ",h.length?e("span",{class:"muted",children:["(",h.length,")"]}):null]}),h.length?e("ul",{class:"sw-wd-tasks",children:h.map(v=>e("li",{class:E(`st-${v.status}`),children:[e(qe,{s:v.status}),e("span",{class:"id",children:["#",v.id]}),e("span",{class:"t",title:v.title,children:v.title})]}))}):e("div",{class:"muted small",children:"No task claimed by this worker."})]}),e("section",{class:"sw-wd-sec",children:[e("h4",{children:"Prompt"}),m?e(R,{children:[e("pre",{class:"sw-pre",children:d?t.prompt:m.text}),m.clipped?e("button",{type:"button",class:"ghost sm",onClick:()=>p(v=>!v),children:d?"Show less":`Show all ${z(t.prompt?.length??0)} characters`}):null]}):e("div",{class:"muted small",children:"The spawn prompt was not recorded."})]}),e("section",{class:"sw-wd-sec",children:[e("h4",{children:["Latest events ",e("span",{class:"muted",children:["(",y.length,")"]})]}),y.length?e("div",{class:"sw-feed sw-wd-feed",children:y.map(v=>e("div",{class:E("sw-ev sw-ev-mini",`k-${v.kind}`,`io-${Fn(v)}`),title:`${new Date(v.ts).toLocaleString()} \xB7 ${v.kind}`,children:[e("span",{class:"t",children:Ht(v.ts,u)}),e("span",{class:"g",children:br[v.kind]??"\xB7"}),e("span",{class:"x",children:[v.task_id?e("b",{children:["#",v.task_id," "]}):null,v.text??v.kind]})]},v.id))}):e(X,{compact:!0,icon:q.idle,title:"No events read yet",children:"The feed keeps the newest events of the run; this worker has none among them."})]})]})}var ro=4;function uf({w:t,roles:n,task:s,now:a,staleMs:r,live:o,maxCalls:i,picked:l,onPick:c,onRelease:u}){let d=yr(t,a,r),p=mt(t.role,n),g=t.ended_at??null;return e(j,{class:E("sw-wk",`st-${t.status}`,o&&t.status==="running"&&"is-live"),selected:l,onClick:()=>c(t.agent_id),children:[e("div",{class:"sw-wk-stripe",style:{background:p},"aria-hidden":"true"}),e("div",{class:"sw-wk-head",children:[e(Ke,{role:t.role,roles:n}),e("code",{class:"sw-wk-id",title:t.agent_id,children:We(t.agent_id)}),e("span",{class:"spacer"}),e(qe,{s:t.status})]}),e("div",{class:E("sw-wk-task",!s&&"none"),title:s?.title,children:s?e(R,{children:[e("span",{class:"id",children:["#",s.id]})," ",s.title]}):t.task_id?e("span",{class:"id",children:["#",t.task_id]}):t.status==="running"?"no task claimed yet":"no task held"}),e("div",{class:"sw-wk-bar",title:`${t.tool_calls} tool calls`,"aria-hidden":"true",children:e("i",{style:{width:`${i?Math.max(2,100*t.tool_calls/i):0}%`,background:p}})}),e("div",{class:"sw-wk-meta",children:[e("span",{title:"tool calls",children:["\u203A ",z(t.tool_calls)," calls"]}),t.errors?e("span",{class:"bad",title:"failed tool calls",children:[q.failed," ",z(t.errors)]}):null,t.last_tool?e("span",{class:"sw-wk-tool",title:"last tool",children:t.last_tool}):null,e("span",{class:"spacer"}),e("span",{class:E("sw-wk-beat",d.quiet&&"warn"),title:`last event ${new Date(t.last_ts).toLocaleTimeString()}`,children:t.status==="done"&&g?`ran ${Ze(g-t.spawned_at)}`:`\u2665 ${Ze(d.age)} ago`})]}),o&&d.quiet?e("div",{class:"sw-wk-quiet",onClick:h=>h.stopPropagation(),children:[e(I,{tone:"warn",title:`no event for ${Ze(d.age)} (stale after ${Ze(r)})`,children:[q.stale," quiet ",Ze(d.age)]}),t.status==="stale"?e(so,{agent:t.agent_id,onRelease:u}):null]}):null]})}function pf({workers:t,tasks:n,roles:s,live:a,skew:r,staleMs:o,picked:i,onPick:l,onRelease:c}){let u=ze(5e3,a,r),[d,p]=x(!1),g=zd(t),h=new Map(n.map(w=>[w.id,w])),y=g.filter(w=>w.status==="done"),m=d?0:Math.max(0,y.length-ro),f=m?[...g.filter(w=>w.status!=="done"),...y.slice(-ro)]:g,v=Math.max(0,...t.map(w=>w.tool_calls)),b=w=>t.filter(k=>k.status===w).length;return e(j,{class:"sw-workers",title:"Workers",sub:t.length?`${t.length} spawned`:void 0,right:t.length?e("span",{class:"sw-wk-counts",children:[e(qe,{s:"running",word:`${b("running")} running`}),b("stale")?e(qe,{s:"stale",word:`${b("stale")} stale`}):null,e(qe,{s:"done",word:`${b("done")} done`})]}):null,children:t.length?e(R,{children:[e("div",{class:"sw-wk-grid",children:f.map(w=>e(uf,{w,roles:s,task:w.task_id?h.get(w.task_id):void 0,now:u,staleMs:o,live:a,maxCalls:v,picked:i===w.agent_id,onPick:l,onRelease:c},w.agent_id))}),m||d&&y.length>ro?e("div",{class:"sw-more",children:e("button",{type:"button",class:"ghost sm",onClick:()=>p(w=>!w),children:d?"Show fewer finished workers":`Show ${m} more finished worker${m===1?"":"s"}`})}):null]}):e(X,{compact:!0,icon:q.idle,title:a?"No workers yet":"No workers ran",children:a?"The coordinator spawns workers with the Agent tool (subagent_type swarm-<swarm>-<role>); each appears here as it starts.":"This run closed before any worker was spawned."})})}var ru=st(pf);function mf(t){let n=null;for(let s=0;s<t.length;s++){let a=t[s];if(n)a===n&&(n=null);else if(a==='"'||a==="'")n=a;else if(a==="#"&&(s===0||t[s-1]===" "))return[t.slice(0,s),t.slice(s)]}return[t,""]}function au(t){let n=t.trim();if(!n)return t;let s=t.slice(0,t.length-t.trimStart().length),a=t.slice(t.trimEnd().length),r="";return/^(true|false|null|~|\||>|\|-|>-)$/.test(n)?r="tok-kw":/^-?\d+(\.\d+)?$/.test(n)?r="tok-num":/^\[.*\]$/.test(n)||/^\{.*\}$/.test(n)?r="tok-pn":r="tok-str",e(R,{children:[s,e("span",{class:r,children:n}),a]})}function kr({text:t,marks:n}){let s=t.replace(/\n$/,"").split(`
|
|
88
|
+
`),a=-1;return e("pre",{class:"sw-yaml",children:s.map((r,o)=>{let i=r.length-r.trimStart().length,l=o+1,c;if(a>=0&&(r.trim()===""||i>a))c=e("span",{class:"tok-str",children:r});else{a=-1;let[u,d]=mf(r),p=/^(\s*)(- )?([A-Za-z0-9_.-]+)(:)(.*)$/.exec(u);if(p){let g=p[5]??"";/^\s*[|>]-?\s*$/.test(g)&&(a=i+(p[2]?2:0)),c=e(R,{children:[p[1],p[2]?e("span",{class:"tok-pn",children:p[2]}):null,e("span",{class:"tok-ty",children:p[3]}),e("span",{class:"tok-pn",children:p[4]}),au(g),d?e("span",{class:"tok-cm",children:d}):null]})}else{let g=/^(\s*)(- )(.*)$/.exec(u);c=e(R,{children:[g?e(R,{children:[g[1],e("span",{class:"tok-pn",children:g[2]}),au(g[3]??"")]}):u,d?e("span",{class:"tok-cm",children:d}):null]})}}return e("span",{class:E("l",n?.has(l)&&"mark"),children:[e("span",{class:"ln",children:l}),c]})})})}var rt=["haiku","sonnet","opus","fable"],ao=4,oo=["Edit","Write","NotebookEdit"],gf=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,xr=32,ds=t=>!!t&&typeof t=="object"&&!Array.isArray(t);function at(t,n,s){if(!n.length)return s;let[a,...r]=n,o=ds(t)?{...t}:{},i=at(o[a],r,s);return i===void 0?delete o[a]:o[a]=i,o}function Sr(t,n){if(t===n)return!0;if(Array.isArray(t)||Array.isArray(n))return!Array.isArray(t)||!Array.isArray(n)||t.length!==n.length?!1:t.every((s,a)=>Sr(s,n[a]));if(ds(t)&&ds(n)){let s=Object.keys(t).filter(r=>t[r]!==void 0),a=Object.keys(n).filter(r=>n[r]!==void 0);return s.length!==a.length?!1:s.every(r=>Object.hasOwn(n,r)&&Sr(t[r],n[r]))}return!1}function ou(t,n,s){let a={};for(let[r,o]of Object.entries(t))a[r===n?s:r]=o;return a}function Cr(t,n=[]){if(!t)return"a name is required";if(t.length>xr)return`at most ${xr} characters`;if(!gf.test(t))return"lowercase letters and digits in words joined by single hyphens, starting with a letter (e.g. code-review)";if(n.includes(t))return`"${t}" is already used`}function pn(t,n){let s=t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^[^a-z]+/,"").replace(/-+$/,"").slice(0,xr).replace(/-+$/,"")||"swarm";if(!n.includes(s))return s;for(let a=2;a<1e3;a++){let r=`-${a}`;if(s=s.slice(0,xr-r.length).replace(/-+$/,""),!n.includes(s+r))return s+r}return`${s}-${Date.now()%1e3}`}function iu(t,n){let s=new Map;for(let[a,r]of Object.entries(t?.swarms??{}))s.set(a,new Set(Object.keys(ds(r)&&ds(r.agents)?r.agents:{})));for(let a of n){let r=s.get(a.swarm);if(r)if(a.role===void 0){let o=new Map;for(let[i,l]of s)o.set(i===a.swarm?a.to:i,l);s.clear();for(let[i,l]of o)s.set(i,l)}else r.has(a.role)&&(r.delete(a.role),r.add(a.to))}return s}function lu(t,n,s,a){if(s===a||!t.doc.swarms[s])return t;let r={...t.doc,swarms:ou(t.doc.swarms,s,a)},o=iu(n,t.renames),i=o.has(s)&&!o.has(a);return{doc:r,renames:i?[...t.renames,{swarm:s,to:a}]:t.renames}}function cu(t,n,s,a,r){let o=t.doc.swarms[s];if(!o||a===r||!o.agents[a])return t;let i={...o,agents:ou(o.agents,a,r),...o.stages?{stages:o.stages.map(d=>d===a?r:d)}:{}},l={...t.doc,swarms:{...t.doc.swarms,[s]:i}},c=iu(n,t.renames).get(s),u=!!c&&c.has(a)&&!c.has(r);return{doc:l,renames:u?[...t.renames,{swarm:s,role:a,to:r}]:t.renames}}function io(t,n,s){return{...t,swarms:{...t.swarms,[n]:structuredClone(s)}}}function du(t,n,s){let a=t.swarms[n];return a?io(t,s,a):t}function uu(t,n){let s={...t.swarms};return delete s[n],{...t,swarms:s}}function hf(){return{description:"Describe what this worker does.",prompt:""}}function lo(t,n,s,a=hf()){let r=t.swarms[n];if(!r)return t;let o=r.topology==="pipeline"&&r.stages?[...r.stages,s]:r.stages;return at(t,["swarms",n],{...r,...o?{stages:o}:{},agents:{...r.agents,[s]:structuredClone(a)}})}function co(t,n,s,a){let r=t.swarms[n]?.agents[s];return r?lo(t,n,a,r):t}function pu(t,n,s){let a=t.swarms[n];if(!a)return t;let r={...a.agents};delete r[s];let o={...a,agents:r};return a.stages&&(o.stages=a.stages.filter(i=>i!==s)),at(t,["swarms",n],o)}function uo(t,n,s){let a=n+s,r=[...t];return n<0||a<0||n>=r.length||a>=r.length||([r[n],r[a]]=[r[a],r[n]]),r}var mu=t=>Object.keys(t.agents).filter(n=>!(t.stages??[]).includes(n));function gu(t,n){return{version:1,enabled:!0,sync:"auto",swarms:{[t]:structuredClone(n)}}}function $r(t){return ls(Object.values(t.agents).map(n=>({count:n?.count??1})),t.max_agents??ao)}var po=(t,n)=>!n||t===n||t.startsWith(`${n}.`),Lt=(t,n)=>t.filter(s=>po(s.path,n)),Jt=(t,n)=>t.some(s=>po(n,s));function Er(t,n){if(Jt(t,n))return"it is an alias, anchor or merge key; delete it in raw mode";let s=t.filter(r=>r!==n&&po(r,n));if(!s.length)return;let a=r=>/^swarms\.[^.]+\.agents\.[^.]+\.hooks$/.test(r);return s.every(a)?/^swarms\.[^.]+\.agents\.[^.]+$/.test(n)?"this role has hooks, which are edited in raw YAML":"a role in it has hooks, which are edited in raw YAML":"an anchor or alias inside it is shared with another part of the file; delete it in raw mode"}function hu(t){if(!t)return;let n=/(haiku|sonnet|opus|fable)/.exec(t);if(!(!n||t.startsWith("opusplan")))return n[1]}var wt=t=>rt.indexOf(t),_r=t=>!!t&&(!!t.floor||!!t.ceiling);function us(t,n){let s=t.defaults,a=n.model??s?.model,r=n.model!==void 0?"role":s?.model!==void 0?"defaults":"none",o=hu(a),i=n.model_range??s?.model_range,l=_r(i)?n.model_range?"range":"default":"pin";if(l==="pin")return{mode:l,model:a,modelFrom:r,tier:o,floor:void 0,ceiling:void 0};let c=i?.floor??o,u=i?.ceiling??o;return{mode:l,model:a,modelFrom:r,tier:o,floor:c,ceiling:u}}function fu(t,n,s){let a=_r(t.defaults?.model_range),r={...n};if(s==="default")delete r.model_range;else if(s==="pin")a?r.model_range={}:delete r.model_range;else{let i=us(t,n).tier??"sonnet",l=wt(i);r.model_range=_r(n.model_range)?n.model_range:a?{...t.defaults?.model_range}:{floor:rt[Math.max(0,l-1)],ceiling:rt[Math.min(rt.length-1,l+1)]}}return r}function bu(t,n){if(!_r(n))return;if(n.floor&&n.ceiling&&wt(n.floor)>wt(n.ceiling))return`the floor must not be above the ceiling (${rt.join(" < ")})`;if(!t)return"a range needs a fallback model inside it: set the model";if(t==="inherit")return"inherit cannot be the fallback of a range: the main session's model is not known in advance";let s=hu(t);if(!s)return`${t} has no single tier, so it cannot be the fallback of a range`;let a=n.floor??s,r=n.ceiling??s;if(wt(s)<wt(a))return`${t} is below the floor ${a}: the fallback must lie inside the range`;if(wt(s)>wt(r))return`${t} is above the ceiling ${r}: the fallback must lie inside the range`}function yu(t,n){return!t||!n?[]:rt.filter(s=>wt(s)>=wt(t)&&wt(s)<=wt(n))}function vu(t){let n=t.disallowed_tools??[];return n.includes("Edit")&&n.includes("Write")?"read-only":t.tools?.length?`${t.tools.length} tool${t.tools.length===1?"":"s"}`:n.length?`all but ${n.slice(0,2).join(", ")}${n.length>2?"\u2026":""}`:"all tools"}function wu(t){return t.visual||t.raw!==null&&t.raw!==(t.baseText??"")}function ku(t){return t.dirty?t.conflict?{kind:"stale",reason:"conflict"}:t.current?t.failure?{kind:"stale",reason:t.failure}:{kind:"render"}:{kind:"wait"}:{kind:"base"}}var ff={haiku:"fast, cheap",sonnet:"balanced",opus:"deep work",fable:"largest"};function mo({floor:t,ceiling:n,tier:s,compact:a,onPick:r}){let o=t&&n?yu(t,n):s?[s]:[],i=o.length?o.length===1?`pinned to ${o[0]}`:`${t} to ${n}${s?`, falls back to ${s}`:""}`:"no known tier";return e("div",{class:E("swc-range",a&&"compact"),role:"img","aria-label":i,title:i,children:rt.map((l,c)=>{let u=o.includes(l),d=u&&o[0]===l,p=u&&o[o.length-1]===l,g=e(R,{children:[e("span",{class:"swc-range-name",children:[l===s?e("b",{"aria-hidden":"true",children:"\u2605 "}):null,l]}),a?null:e("span",{class:"swc-range-hint",children:ff[l]})]}),h=E("swc-range-cell",u&&"on",d&&"first",p&&"last",l===s&&"fb");return r?e("button",{type:"button",class:h,style:{"--i":String(c)},onClick:()=>r(l),children:g}):e("span",{class:h,children:g})})})}function bf({value:t,models:n,inherited:s,disabled:a,id:r,onChange:o}){let i=t!==void 0&&!n.includes(t),[l,c]=x(i),u=t===void 0?"":i||l?"__custom":t;return e("div",{class:"swc-model",children:[e("select",{id:r,value:u,disabled:a,onChange:d=>{let p=d.target.value;p==="__custom"?(c(!0),o(t??"claude-")):(c(!1),o(p||void 0))},children:[e("option",{value:"",children:s!==void 0?`default (${s})`:"not set (the main session's)"}),n.map(d=>e("option",{value:d,children:d})),e("option",{value:"__custom",children:"a model id\u2026"})]}),u==="__custom"?e("input",{type:"text",class:"mono","aria-label":"Claude model id",placeholder:"claude-sonnet-4-5",value:t??"",disabled:a,spellcheck:!1,onInput:d=>o(d.target.value.trim()||void 0)}):null]})}var yf={pin:"Pin the model",range:"Adjudicator picks",default:"Use the default"};function Tr({doc:t,value:n,models:s,isDefaults:a,modelDisabled:r,rangeDisabled:o,error:i,onChange:l}){let c=a?{swarms:{}}:t,u={description:"",...n},d=us(c,u),g=!a&&!!(t.defaults?.model_range?.floor||t.defaults?.model_range?.ceiling)?["default","pin","range"]:["pin","range"],h=bu(d.model,d.mode==="pin"?void 0:n.model_range??t.defaults?.model_range),y=f=>l({...n,model_range:f}),m=n.model_range??{};return e("div",{class:"swc-policy",children:[e(Se,{label:"model policy",value:d.mode,onChange:f=>{let v=fu(c,u,f);l({model:v.model,model_range:v.model_range})},options:g.map(f=>({id:f,label:yf[f],title:f==="pin"?"always run this model":f==="range"?"the adjudicator picks haiku, sonnet, opus or fable per task, within the range":"follow defaults.model_range"}))}),e("div",{class:"swc-policy-row",children:[e("label",{class:"swc-mini-label",for:"swc-model",children:d.mode==="pin"?"Model":"Fallback model"}),e(bf,{id:"swc-model",value:n.model,models:s,inherited:a?void 0:t.defaults?.model,disabled:r,onChange:f=>l({...n,model:f})})]}),d.mode==="range"?e("div",{class:"swc-policy-row",children:[e("span",{class:"swc-mini-label",children:"Range"}),e("div",{class:"swc-bounds",children:[e("select",{"aria-label":"floor",value:m.floor??"",disabled:o,onChange:f=>{let v=f.target.value;y({...m,floor:v||void 0})},children:[e("option",{value:"",children:"floor: the fallback's tier"}),rt.map(f=>e("option",{value:f,children:["floor: ",f]}))]}),e("select",{"aria-label":"ceiling",value:m.ceiling??"",disabled:o,onChange:f=>{let v=f.target.value;y({...m,ceiling:v||void 0})},children:[e("option",{value:"",children:"ceiling: the fallback's tier"}),rt.map(f=>e("option",{value:f,children:["ceiling: ",f]}))]})]})]}):null,e(mo,{floor:d.floor,ceiling:d.ceiling,tier:d.tier,onPick:d.mode==="range"&&!o?f=>{let v=d.floor?rt.indexOf(d.floor):0,b=rt.indexOf(f),w=d.ceiling?rt.indexOf(d.ceiling):rt.length-1;b<=v||b<w&&b-v<=w-b?y({...m,floor:f}):y({...m,ceiling:f})}:void 0}),e("div",{class:E("small",h||i?"bad":"muted"),children:h??i??(d.mode==="pin"?d.model?`Every task runs on ${d.model}${d.modelFrom==="defaults"?" (the default)":""}.`:"No model set: the worker runs on the main session's model.":`The adjudicator picks ${d.floor} to ${d.ceiling} per task; ${d.model??"the fallback"} is pinned in the agent file and used when it does not choose.${d.mode==="default"?" Follows defaults.model_range.":""}`)})]})}var vf=[{key:"memories",label:"Memories",hint:"project memories matching the role and task (0-10)",kind:"n"},{key:"docs",label:"Docs",hint:"documentation pages matching the task (0-10)",kind:"n"},{key:"history",label:"History",hint:"bug-prone files, recent fixes and history lessons",kind:"b"},{key:"insights",label:"Insights",hint:"hot files (fan-in \xD7 churn) in the work area",kind:"b"},{key:"structure",label:"Structure",hint:"the project brief: overview, decisions, constraints",kind:"b"},{key:"max_chars",label:"Max chars",hint:"size of the brief (500-9000)",kind:"n"}],wf={memories:[0,10,1],docs:[0,10,1],max_chars:[500,9e3,500]};function Bn({value:t,inherited:n,inheritedFrom:s,disabled:a,onChange:r}){let o=t??{},i=(l,c)=>{let u={...o,[l]:c};c===void 0&&delete u[l],r(Object.keys(u).length?u:void 0)};return e("div",{class:"swc-ctx",children:vf.map(l=>{let c=o[l.key],u=n[l.key],d=wf[l.key];return e("div",{class:E("swc-ctx-row",c!==void 0&&"set"),children:[e("span",{class:"swc-ctx-label",title:l.hint,children:[l.label,e("span",{class:"swc-ctx-hint",children:l.hint})]}),l.kind==="b"?e(Se,{label:l.label,value:c===void 0?"inherit":c?"on":"off",onChange:p=>!a&&i(l.key,p==="inherit"?void 0:p==="on"),options:[{id:"inherit",label:`inherit (${u===void 0?"\u2013":u?"on":"off"})`,title:`use the value from ${s}`},{id:"on",label:"on"},{id:"off",label:"off"}]}):e("span",{class:"swc-ctx-num",children:c===void 0?e("button",{type:"button",class:"ghost sm",disabled:a,title:`override the value from ${s}`,onClick:()=>i(l.key,typeof u=="number"?u:d?.[0]??0),children:["inherit (",String(u??"\u2013"),") \xB7 override"]}):e(R,{children:[e(Ft,{label:l.label,value:c,min:d?.[0],max:d?.[1],onChange:p=>{if(a)return;let g=d?.[2]??1,h=c,y=p>h?1:-1,m=g===1?p:Math.round((h+y*g)/g)*g;i(l.key,Math.max(d?.[0]??0,Math.min(d?.[1]??99,m)))}}),e("button",{type:"button",class:"ghost sm",disabled:a,title:"inherit again",onClick:()=>i(l.key,void 0),children:"\u2715"})]})})]})})})}function Hn(t,...n){let s={memories:t.memories,docs:t.docs,history:t.history,structure:t.structure,insights:t.insights,max_chars:t.maxChars??t.max_chars};for(let a of n)if(a)for(let[r,o]of Object.entries(a))o!==void 0&&(s[r]=o);return s}var Rr={red:"var(--bad)",blue:"var(--accent)",green:"var(--ok)",yellow:"var(--warn)",purple:"var(--accent-2)",orange:"#ea7a2b",pink:"#e0559a",cyan:"#14a8c4"},kf=(t,n,s)=>n.color&&Rr[n.color]||mt(t,s);function xu({name:t,role:n,doc:s,names:a,issues:r,selected:o,countLocked:i,maxCount:l,onOpen:c,onCount:u}){let d=us(s,n),p=kf(t,n,a),g=vu(n),h=n.count??1,y=!n.prompt?.trim();return e(j,{class:E("swc-role",r>0&&"has-issues"),selected:o,onClick:c,children:[e("div",{class:"swc-role-top",style:{"--rc":p},children:[e("span",{class:"swc-role-dot","aria-hidden":"true",children:(t[0]??"?").toUpperCase()}),e("span",{class:"swc-role-name",children:[e("b",{children:t}),e("span",{class:"muted small swc-role-desc",title:n.description,children:n.description})]}),e("span",{class:"swc-role-count",onClick:m=>m.stopPropagation(),onKeyDown:m=>m.stopPropagation(),title:i?"set in the YAML (anchor or merge)":"workers of this role at once",children:i?e("span",{class:"ds-num",children:["\xD7",h]}):e(Ft,{label:`${t} count`,value:h,min:1,max:l,onChange:u})})]}),e("div",{class:"swc-role-model",children:[e(I,{tone:d.mode==="pin"?"muted":"purple",title:d.mode==="pin"?`pinned to ${d.model??"the main session's model"}`:`the adjudicator picks ${d.floor}\u2013${d.ceiling}; falls back to ${d.model}`,children:[d.mode==="pin"?"pinned":"adaptive"," \xB7 ",d.model??"inherit",d.modelFrom==="defaults"?e("span",{class:"muted",children:" (default)"}):null]}),n.effort?e(I,{tone:"muted",children:["effort ",n.effort]}):null,e(mo,{compact:!0,floor:d.floor,ceiling:d.ceiling,tier:d.tier})]}),e("div",{class:"swc-role-foot",children:[e(I,{tone:g==="read-only"?"accent":"muted",title:"tools and disallowed_tools",children:[g==="read-only"?"\u25C7 ":"",g]}),n.isolation==="worktree"?e(I,{tone:"muted",children:"worktree"}):null,n.skills?.length?e(I,{tone:"muted",title:n.skills.join(`
|
|
89
|
+
`),children:[n.skills.length," skill",n.skills.length===1?"":"s"]}):null,n.hooks?e(I,{tone:"muted",title:"hooks are edited in the YAML",children:"hooks"}):null,(n.scope??[]).slice(0,3).map(m=>e("code",{class:"swc-glob",title:"scope",children:m})),(n.scope?.length??0)>3?e("span",{class:"muted small",children:["+",(n.scope?.length??0)-3]}):null,e("span",{class:"spacer"}),r?e(I,{tone:"bad",children:[q.failed," ",r]}):y?e(I,{tone:"warn",title:"no prompt: the worker gets only the description",children:[q.blocked," no prompt"]}):null]})]})}var Ar=(t,n,s)=>{let a=t.limits[n];return typeof a=="number"?a:s};function ho({value:t,taken:n,disabled:s,id:a,onCommit:r}){let[o,i]=x(t);U(()=>i(t),[t]);let l=o===t?void 0:Cr(o,n),c=()=>{o!==t&&!l&&r(o)};return e("div",{class:"swc-name",children:[e("input",{id:a,type:"text",class:E("mono",l&&"bad-input"),value:o,disabled:s,spellcheck:!1,autocomplete:"off",onInput:u=>i(u.target.value.trim()),onBlur:c,onKeyDown:u=>{u.key==="Enter"?(u.preventDefault(),c()):u.key==="Escape"&&o!==t&&(u.stopPropagation(),i(t))}}),l?e("div",{class:"ds-field-error",children:l}):o!==t?e("div",{class:"ds-field-hint",children:"Enter to rename"}):null]})}function ps({value:t,max:n,rows:s=4,id:a,placeholder:r,disabled:o,mono:i,onChange:l}){let c=t.length;return e("div",{class:"swc-counted",children:[e("textarea",{id:a,rows:s,class:E(!i&&"swc-prose"),value:t,placeholder:r,disabled:o,spellcheck:!i,onInput:u=>l(u.target.value)}),e("span",{class:E("swc-count",c>n?"bad":c>n*.8?"warn":"muted"),children:[c.toLocaleString("en-US")," / ",n.toLocaleString("en-US")]})]})}var go="default",xf=["description","model","model_range","effort","color","count","max_turns","isolation","tools","disallowed_tools","skills","scope","memory_tags","context","prompt"];function Su({swarm:t,name:n,role:s,doc:a,meta:r,issues:o,locked:i,taken:l,onChange:c,onRename:u,onDuplicate:d,onDelete:p,onRaw:g,onClose:h}){let[y,m]=x(!1);U(()=>m(!1),[n]);let f=`swarms.${t}.agents.${n}`,v=$=>{let L=Lt(o,`${f}.${$}`);return L.length?L.map(K=>K.message).join("; "):void 0},b=$=>Jt(i,`${f}.${$}`),w=Jt(i,f),k=Er(i,f),C=xf.filter($=>!w&&b($)),S=($,L)=>{let K={...s,[$]:L};L===void 0&&delete K[$],c(K)},_=$=>e(zn,{label:$,value:s[$]??[],disabled:b($),placeholder:$==="scope"?"src/ui/**":$==="skills"?"eminiar:em-history":$==="memory_tags"?"decision":"Read, Bash, mcp__server__tool",onChange:L=>S($,L.length?L:void 0)}),T=a.swarms[t],M=Hn(r.defaultContext,a.defaults?.context,T?.context),F=oo.every($=>s.disallowed_tools?.includes($))&&!s.tools?.length,D=!s.tools?.length&&!s.disallowed_tools?.length;return e(Sn,{title:e(R,{children:[e("span",{class:"swc-role-dot sm","aria-hidden":"true",style:{"--rc":s.color&&Rr[s.color]||"var(--accent)"},children:(n[0]??"?").toUpperCase()})," ",n," ",e("span",{class:"muted small",children:["in ",t]})]}),onClose:h,footer:y?e(R,{children:[e("span",{class:"small bad swc-grow",children:["Delete the role ",n,"? Its agent file goes on the next sync."]}),e("button",{type:"button",class:"sm",onClick:()=>m(!1),children:"Cancel"}),e("button",{type:"button",class:"sm danger",onClick:p,children:"Delete role"})]}):e(R,{children:[e("button",{type:"button",class:"sm ghost",disabled:!!k,title:k&&`Cannot delete: ${k}`,onClick:()=>m(!0),children:"Delete\u2026"}),e("button",{type:"button",class:"sm",onClick:d,children:"Duplicate"}),e("span",{class:"swc-grow"}),e("button",{type:"button",class:"sm primary",onClick:h,children:"Done"})]}),children:[w?e("div",{class:"swc-note warn small",children:["This role comes from a YAML anchor or merge key, so it is read-only here."," ",e("button",{type:"button",class:"ghost sm",onClick:g,children:"Edit in YAML"})]}):C.length?e("div",{class:"swc-note warn small",children:["Read-only here (set through a YAML anchor or merge key): ",C.join(", "),"."," ",e("button",{type:"button",class:"ghost sm",onClick:g,children:"Edit in YAML"})]}):null,e("div",{class:"swc-form-2",children:[e(xe,{label:"Name",htmlFor:"swc-r-name",hint:`agent swarm-${t}-${n}`,error:v("__name"),children:e(ho,{id:"swc-r-name",value:n,taken:l,disabled:w,onCommit:u})}),e(xe,{label:"Workers at once",hint:"count: parallel workers of this role (1-8)",error:v("count"),children:b("count")?e("span",{class:"ds-num",children:s.count??1}):e(Ft,{label:"count",value:s.count??1,min:1,max:Ar(r,"count",8),onChange:$=>S("count",$)})})]}),e(xe,{label:"Description",htmlFor:"swc-r-desc",hint:"Claude Code shows it when choosing the agent; also the worker's one-line brief",error:v("description"),children:e(ps,{id:"swc-r-desc",rows:2,value:s.description,max:Ar(r,"description",500),disabled:b("description"),onChange:$=>S("description",$)})}),e(xe,{label:"Model",hint:"pin one model, or let the adjudicator pick a tier per task inside a range",error:v("model")??v("model_range"),children:e(Tr,{doc:a,value:{model:s.model,model_range:s.model_range},models:r.models,modelDisabled:b("model"),rangeDisabled:b("model_range"),onChange:$=>{let L={...s,model:$.model,model_range:$.model_range};$.model===void 0&&delete L.model,$.model_range===void 0&&delete L.model_range,c(L)}})}),e(xe,{label:"Effort",hint:"thinking effort of the worker's model",error:v("effort"),children:e(Se,{label:"effort",value:s.effort??go,onChange:$=>!b("effort")&&S("effort",$===go?void 0:$),options:[go,...r.efforts].map($=>({id:$,label:$}))})}),e(xe,{label:"Colour",hint:"the agent's colour in Claude Code",error:v("color"),children:e("div",{class:"swc-swatches",role:"radiogroup","aria-label":"colour",children:[e("button",{type:"button",role:"radio","aria-checked":!s.color,class:E("swc-swatch none",!s.color&&"on"),title:"no colour",disabled:b("color"),onClick:()=>S("color",void 0),children:"\u2205"}),r.colors.map($=>e("button",{type:"button",role:"radio","aria-checked":s.color===$,"aria-label":$,title:$,class:E("swc-swatch",s.color===$&&"on"),style:{"--sw":Rr[$]??$},disabled:b("color"),onClick:()=>S("color",$)}))]})}),e("div",{class:"swc-form-2",children:[e(xe,{label:"Max turns",htmlFor:"swc-r-turns",hint:"stop the worker after this many turns (empty: no limit)",error:v("max_turns"),children:e("input",{id:"swc-r-turns",type:"number",min:1,max:Ar(r,"maxTurns",500),value:s.max_turns??"",disabled:b("max_turns"),placeholder:"no limit",onInput:$=>{let L=$.target.value;S("max_turns",L===""?void 0:Math.round(Number(L)))}})}),e(xe,{label:"Isolation",hint:"run each worker in its own git worktree",error:v("isolation"),children:e(qn,{checked:s.isolation==="worktree",disabled:b("isolation"),label:"worktree",onChange:$=>S("isolation",$?"worktree":void 0)})})]}),e(xe,{label:e("span",{class:"swc-label-row",children:["Tools",e("span",{class:"swc-presets",children:[e("button",{type:"button",class:E("chip",D&&"on"),disabled:b("tools")||b("disallowed_tools"),onClick:()=>c({...s,tools:void 0,disallowed_tools:void 0}),children:"all tools"}),e("button",{type:"button",class:E("chip",F&&"on"),disabled:b("tools")||b("disallowed_tools"),title:"disallow Edit, Write and NotebookEdit",onClick:()=>c({...s,tools:void 0,disallowed_tools:[...new Set([...s.disallowed_tools??[],...oo])]}),children:"read-only"})]})]}),hint:"allowed tools (empty: every tool the session has)",error:v("tools"),children:_("tools")}),e(xe,{label:"Disallowed tools",hint:"removed from the worker's tools",error:v("disallowed_tools"),children:_("disallowed_tools")}),e(xe,{label:"Skills",hint:"skills preloaded into the worker",error:v("skills"),children:_("skills")}),e(xe,{label:"Scope",hint:"project-relative globs the worker may edit (empty: anywhere)",error:v("scope"),children:_("scope")}),e(xe,{label:"Memory tags",hint:"recall memories of these kinds or tags first",error:v("memory_tags"),children:_("memory_tags")}),e(xe,{label:"Prompt",htmlFor:"swc-r-prompt",hint:"the worker's system prompt, after eminiar's swarm protocol",error:v("prompt"),children:e(ps,{id:"swc-r-prompt",mono:!0,rows:9,value:s.prompt??"",max:Ar(r,"prompt",2e4),placeholder:"How this worker should work: what to read first, what to verify, what to report.",disabled:b("prompt"),onChange:$=>S("prompt",$||void 0)})}),e("details",{class:"swc-details",open:!!s.context,children:[e("summary",{children:["Context overrides"," ",s.context?e(I,{tone:"accent",children:[Object.keys(s.context).length," set"]}):null]}),e(Bn,{value:s.context,inherited:M,inheritedFrom:"the swarm and the defaults",disabled:b("context"),onChange:$=>S("context",$)}),v("context")?e("div",{class:"ds-field-error",children:v("context")}):null]}),e(xe,{label:"Hooks",hint:"Claude Code hooks of the agent file",children:s.hooks?e("div",{class:"swc-hooks",children:[e("pre",{class:"mono small",children:Sf(s.hooks)}),e("button",{type:"button",class:"sm",onClick:g,children:"Edit in YAML"})]}):e("span",{class:"small muted",children:["none \xB7"," ",e("button",{type:"button",class:"ghost sm",onClick:g,children:"add in YAML"})]})})]})}function Sf(t){if(!t||typeof t!="object")return String(t);let n=[];for(let[s,a]of Object.entries(t))if(Array.isArray(a))for(let r of a)for(let o of r.hooks??[])n.push(`${s}${r.matcher?` ${r.matcher}`:""} \u2192 ${o.command??"?"}${o.timeout?` (${o.timeout} s)`:""}`);return n.join(`
|
|
90
|
+
`)||JSON.stringify(t)}function _u({doc:t,meta:n,issues:s,locked:a,onChange:r}){let[o,i]=x(null),l=y=>{let m=Lt(s,y);return m.length?m.map(f=>f.message).join("; "):void 0},c=y=>Jt(a,y),u=(y,m)=>r(at(t,y,m)),d=t.enabled!==!1,p=t.enforce===!0,g=t.defaults??{},h=y=>u(["defaults"],Object.values(y).some(m=>m!==void 0)?y:void 0);return e("div",{class:"swc-settings",children:[e(j,{title:"Swarms in this project",sub:"enabled \xB7 sync \xB7 enforce",raised:!0,children:[e("div",{class:"swc-set-row",children:[e("div",{class:"swc-set-text",children:[e("b",{children:"Enabled"}),e("span",{class:"small muted",children:"Off: the hooks ignore every swarm, and a sync removes the generated agent files."})]}),e(qn,{checked:d,disabled:c("enabled"),label:d?"on":"off",onChange:y=>y?u(["enabled"],!0):i("disable")})]}),o==="disable"?e("div",{class:"swc-confirm",role:"alertdialog","aria-label":"turn swarms off",children:[e("span",{children:[q.blocked," Turn swarms off? The hooks stop coordinating runs, and the next sync deletes ",e("code",{children:".claude/agents/swarm-*.md"}),"."]}),e("span",{class:"row tight",children:[e("button",{type:"button",class:"sm",onClick:()=>i(null),children:"Cancel"}),e("button",{type:"button",class:"sm danger",onClick:()=>{u(["enabled"],!1),i(null)},children:"Turn off"})]})]}):null,e("div",{class:"swc-set-row",children:[e("div",{class:"swc-set-text",children:[e("b",{children:"Sync"}),e("span",{class:"small muted",children:"auto: regenerate the agent files at session start when this file changes \xB7 manual: only on Sync."})]}),e(Se,{label:"sync",value:t.sync??"auto",onChange:y=>!c("sync")&&u(["sync"],y==="auto"&&t.sync===void 0?void 0:y),options:[{id:"auto",label:"auto"},{id:"manual",label:"manual"}]})]}),e("div",{class:"swc-set-row",children:[e("div",{class:"swc-set-text",children:[e("b",{children:"Enforce"}),e("span",{class:"small muted",children:"Only this file's swarm workers may run as subagents, and only during a run of their swarm."})]}),e(qn,{checked:p,disabled:c("enforce"),label:p?"on":"off",onChange:y=>y?i("enforce"):u(["enforce"],!1)})]}),l("enforce")?e("div",{class:"ds-field-error",children:l("enforce")}):null,o==="enforce"?e("div",{class:"swc-confirm",role:"alertdialog","aria-label":"turn enforcement on",children:[e("span",{children:[q.blocked," With enforce on, any other subagent (Explore, general-purpose, your own agents) is denied unless it is listed in allowed agents."]}),e("span",{class:"row tight",children:[e("button",{type:"button",class:"sm",onClick:()=>i(null),children:"Cancel"}),e("button",{type:"button",class:"sm primary",onClick:()=>{u(["enforce"],!0),i(null)},children:"Turn on"})]})]}):null,p?e(xe,{label:"Allowed agents",hint:"subagent types that may still run outside a run (e.g. Explore)",error:l("allowed_agents"),children:e(zn,{label:"allowed agents",value:t.allowed_agents??[],disabled:c("allowed_agents"),placeholder:"Explore, general-purpose",onChange:y=>u(["allowed_agents"],y.length?y:void 0)})}):null]}),e(j,{title:"Defaults",sub:"every role inherits these unless it sets its own",raised:!0,children:[e(xe,{label:"Model",hint:"the default model, and the default range the adjudicator may move every role within",error:l("defaults.model")??l("defaults.model_range"),children:e(Tr,{isDefaults:!0,doc:t,value:{model:g.model,model_range:g.model_range},models:n.models,modelDisabled:c("defaults.model"),rangeDisabled:c("defaults.model_range"),onChange:y=>h({...g,model:y.model,model_range:y.model_range})})}),e(xe,{label:"Skills",hint:"preloaded into every worker",error:l("defaults.skills"),children:e(zn,{label:"default skills",value:g.skills??[],disabled:c("defaults.skills"),placeholder:"eminiar:em-history",onChange:y=>h({...g,skills:y.length?y:void 0})})}),e(xe,{label:"Context",hint:"what eminiar tells each worker when it starts",error:l("defaults.context"),children:e(Bn,{value:g.context,inherited:Hn(n.defaultContext),inheritedFrom:"eminiar's built-in defaults",disabled:c("defaults.context"),onChange:y=>h({...g,context:y})})})]})]})}var _f=["hierarchical","mesh","pipeline"],Cu={hierarchical:{what:"The coordinator plans, assigns and reviews; workers report back to it.",when:"Use when one lead should split a feature into disjoint tasks."},mesh:{what:"Peers share one task board and blackboard and take whatever is open.",when:"Use when several angles look at the same thing at once (reviews, research)."},pipeline:{what:"Work moves stage by stage, in the order of the stages list.",when:"Use when each step needs the previous one's output (write \u2192 edit \u2192 check)."}};function Cf({topology:t,size:n=96}){let s=n,a=Math.round(n*.62),r=Math.max(4,n/16),o={x:s/2,y:a*.24},i=[],l=[];if(t==="hierarchical")i=[.16,.39,.61,.84].map(c=>({x:s*c,y:a*.78})),l=i.map(c=>[o,c]);else if(t==="mesh"){let c=s/2,u=a*.56,d=a*.32;i=[0,1,2,3,4].map(p=>{let g=-Math.PI/2+p*2*Math.PI/5;return{x:c+d*1.35*Math.cos(g),y:u+d*Math.sin(g)}});for(let p=0;p<i.length;p++)for(let g=p+1;g<i.length;g++)l.push([i[p],i[g]])}else{i=[.12,.37,.63,.88].map(c=>({x:s*c,y:a*.56}));for(let c=0;c<i.length-1;c++)l.push([i[c],i[c+1]])}return e("svg",{class:E("swc-mini-topo",`topo-${t}`),viewBox:`0 0 ${s} ${a}`,width:s,height:a,"aria-hidden":"true",children:[l.map(([c,u])=>e("line",{x1:c.x,y1:c.y,x2:u.x,y2:u.y})),t==="pipeline"?i.slice(0,-1).map((c,u)=>{let d=i[u+1],p=(c.x+d.x)/2;return e("path",{class:"arrow",d:`M${p-3},${c.y-3} L${p+2},${c.y} L${p-3},${c.y+3}`})}):null,t==="hierarchical"?e("circle",{class:"hub",cx:o.x,cy:o.y,r:r*1.35}):null,i.map((c,u)=>e("circle",{class:"node",cx:c.x,cy:c.y,r,style:{"--i":String(u)}}))]})}function $u({value:t,disabled:n,onChange:s}){return e("div",{class:"swc-topos",role:"radiogroup","aria-label":"topology",children:_f.map(a=>e("button",{type:"button",role:"radio","aria-checked":a===t,disabled:n,class:E("swc-topo",a===t&&"on"),onClick:()=>s(a),children:[e(Cf,{topology:a}),e("span",{class:"swc-topo-name",children:[e("span",{"aria-hidden":"true",children:Be[a]})," ",a,a===t?e("span",{class:"swc-check",children:"\u2713"}):null]}),e("span",{class:"swc-topo-what",children:Cu[a].what}),e("span",{class:"swc-topo-when",children:Cu[a].when})]}))})}var Mr=(t,n,s)=>{let a=t.limits[n];return typeof a=="number"?a:s};function $f({text:t}){return e("span",{class:"sw-copy-row swc-cmd",children:[e("code",{children:t}),e("button",{type:"button",class:"ghost sm",title:"copy to the clipboard",onClick:async()=>{try{await navigator.clipboard.writeText(t),ee("copied")}catch{ee("could not copy: select the line and copy it by hand",!0)}},children:"Copy"})]})}function Eu({name:t,swarm:n,doc:s,meta:a,issues:r,warnings:o,locked:i,swarmNames:l,activeRun:c,selectedRole:u,onChange:d,onRename:p,onDuplicate:g,onDelete:h,onOpenRole:y,onAddRole:m}){let[f,v]=x(!1),[b,w]=x("");U(()=>{v(!1),w("")},[t]);let k=`swarms.${t}`,C=Er(i,k),S=A=>{let W=Lt(r,`${k}.${A}`);return W.length?W.map(ye=>ye.message).join("; "):void 0},_=A=>o.filter(W=>W.path===`${k}.${A}`).map(W=>W.message).join("; ")||void 0,T=r.filter(A=>A.path===k).map(A=>A.message).join("; ")||void 0,M=A=>Jt(i,`${k}.${A}`),F=(A,W)=>d(at(n,[A],W)),D=n.topology??"hierarchical",$=Object.keys(n.agents),L=$r(n),K=n.max_agents??ao,Y=n.stages??[],ne=D==="pipeline"?mu(n):[],O=Hn(a.defaultContext,s.defaults?.context);return e("div",{class:"swc-editor",children:[e("section",{class:"ds-hero swc-hero",children:[e("div",{class:"ds-hero-main",children:[e("div",{class:"ds-eyebrow",children:[e("span",{"aria-hidden":"true",children:Be[D]})," ",D," swarm",c?e(I,{tone:"accent",dot:!0,title:`run ${c} is active`,children:"run active"}):null]}),e("div",{class:"swc-hero-name",children:[e(ho,{value:t,taken:l.filter(A=>A!==t),onCommit:p}),T?e("div",{class:"ds-field-error",children:T}):null]}),e(xe,{label:"Description",htmlFor:"swc-s-desc",error:S("description"),children:e(ps,{id:"swc-s-desc",rows:3,value:n.description,max:Mr(a,"description",500),disabled:M("description"),placeholder:"What this swarm is for: the coordinator reads it when it plans a run.",onChange:A=>F("description",A)})}),e("div",{class:"ds-hero-meta",children:[e($f,{text:cs(t)}),e("span",{class:"spacer"}),f?e("span",{class:"swc-confirm inline",role:"alertdialog","aria-label":`delete ${t}`,children:[e("span",{class:"small",children:["Delete ",t," and its ",$.length," role",$.length===1?"":"s","?"]}),e("button",{type:"button",class:"sm",onClick:()=>v(!1),children:"Cancel"}),e("button",{type:"button",class:"sm danger",onClick:h,children:"Delete swarm"})]}):e(R,{children:[e("button",{type:"button",class:"sm",onClick:g,children:"Duplicate"}),e("button",{type:"button",class:"sm ghost",disabled:!!C,title:C&&`Cannot delete: ${C}`,onClick:()=>v(!0),children:"Delete\u2026"})]})]})]}),e("div",{class:"ds-hero-aside swc-hero-aside",children:[e(Nn,{class:"swc-live-topo",topology:D,roles:$.map(A=>({name:A,count:n.agents[A]?.count??1})),stages:Y,maxAgents:K}),e("span",{class:"swc-live-cap small muted",children:["live preview \xB7 ",L.total," slot",L.total===1?"":"s"]})]})]}),e(j,{title:"Shape",sub:"how the coordinator and the workers work together",raised:!0,children:[e($u,{value:D,disabled:M("topology"),onChange:A=>{let W=at(n,["topology"],A);A==="pipeline"&&!n.stages?.length&&(W=at(W,["stages"],$)),d(W)}}),S("topology")?e("div",{class:"ds-field-error",children:S("topology")}):null,e("div",{class:"swc-cap",children:[e(Kt,{value:L.max?L.total/L.max:0,size:76,tone:L.over?"warn":"accent",label:e("span",{class:"ds-num",children:[L.total,"/",L.max]}),caption:"slots",title:`${L.total} worker slots (\u03A3 count) against max_agents ${L.max}`}),e("div",{class:"swc-cap-text",children:[e(xe,{label:"Max agents",hint:"workers running at once in one run (1-16)",error:S("max_agents"),children:M("max_agents")?e("span",{class:"ds-num",children:K}):e(Ft,{label:"max agents",value:K,min:1,max:Mr(a,"maxAgents",16),onChange:A=>F("max_agents",A)})}),e("span",{class:E("small",L.over?"warn":"muted"),children:L.over?`${q.blocked} ${_("max_agents")??`${L.total} slots but max_agents ${L.max}: only ${L.max} run at once`}`:`${L.total} slot${L.total===1?"":"s"} configured (\u03A3 count); ${L.max-L.total} spare.`})]})]}),D==="pipeline"?e(xe,{label:"Stages",hint:"the order work moves through; every role should appear once",error:S("stages")??_("stages"),children:[e("ol",{class:"swc-stages",children:Y.map((A,W)=>e("li",{children:[e("span",{class:"swc-stage-n",children:W+1}),e("code",{children:A}),$.includes(A)?null:e(I,{tone:"bad",children:"no such role"}),e("span",{class:"spacer"}),e("button",{type:"button",class:"ghost sm","aria-label":`move ${A} up`,disabled:W===0||M("stages"),onClick:()=>F("stages",uo(Y,W,-1)),children:"\u2191"}),e("button",{type:"button",class:"ghost sm","aria-label":`move ${A} down`,disabled:W===Y.length-1||M("stages"),onClick:()=>F("stages",uo(Y,W,1)),children:"\u2193"}),e("button",{type:"button",class:"ghost sm","aria-label":`remove ${A} from the stages`,disabled:M("stages"),onClick:()=>F("stages",Y.filter((ye,B)=>B!==W)),children:"\u2715"})]}))}),ne.length?e("div",{class:"row tight",children:[e("span",{class:"small muted",children:"Not in the stages:"}),ne.map(A=>e("button",{type:"button",class:"chip",disabled:M("stages"),onClick:()=>F("stages",[...Y,A]),children:["+ ",A]}))]}):null]}):null]}),e(j,{title:"Roles",sub:`${$.length} role${$.length===1?"":"s"} \xB7 click one to edit`,raised:!0,right:S("agents")?e(I,{tone:"bad",children:[q.failed," ",S("agents")]}):null,children:e("div",{class:"swc-roles",children:[$.map(A=>e(xu,{name:A,role:n.agents[A],doc:s,names:$,issues:Lt(r,`${k}.agents.${A}`).length,selected:A===u,countLocked:M(`agents.${A}.count`),maxCount:Mr(a,"count",8),onOpen:()=>y(A),onCount:W=>F("agents",at(n.agents,[A,"count"],W))})),e("div",{class:"swc-add-role",children:[e("span",{class:"swc-add-plus","aria-hidden":"true",children:"\uFF0B"}),e("b",{children:"Add a role"}),e("span",{class:"small muted",children:"A worker type with its own prompt, model and tools."}),e("div",{class:"row tight",children:[e("button",{type:"button",class:"sm primary",disabled:M("agents"),onClick:()=>m(pn(b||"worker",$),b||void 0),children:b?`Copy ${b}`:"Blank role"}),$.length?e("select",{"aria-label":"copy from a role",value:b,onChange:A=>w(A.target.value),children:[e("option",{value:"",children:"blank"}),$.map(A=>e("option",{value:A,children:["copy of ",A]}))]}):null]})]})]})}),e(j,{title:"Instructions",sub:"what the coordinator follows when it plans and runs this swarm",raised:!0,children:e(xe,{label:"",htmlFor:"swc-s-instr",error:S("instructions"),children:e(ps,{id:"swc-s-instr",mono:!0,rows:7,value:n.instructions??"",max:Mr(a,"prompt",2e4),disabled:M("instructions"),placeholder:"Order of work, how tasks are split, when the run is done\u2026",onChange:A=>F("instructions",A||void 0)})})}),e("details",{class:"swc-details card-like",open:!!n.context,children:[e("summary",{children:["Context overrides for every role of ",t," ",n.context?e(I,{tone:"accent",children:[Object.keys(n.context).length," set"]}):null]}),e(Bn,{value:n.context,inherited:O,inheritedFrom:"the defaults",disabled:M("context"),onChange:A=>F("context",A)}),S("context")?e("div",{class:"ds-field-error",children:S("context")}):null]})]})}function fo({templates:t,error:n,taken:s,action:a="Add swarm",onCreate:r}){let[o,i]=x(),[l,c]=x(""),u=t?.find(p=>p.id===o)??t?.[0];if(U(()=>{u&&c(pn(u.id==="blank"?"swarm":u.id,s))},[u?.id]),n)return e("div",{class:"swc-note bad small",children:["Templates could not be loaded: ",n]});if(!t)return e("div",{class:"swc-tpls","aria-busy":"true",children:[0,1,2,3].map(()=>e(N,{h:150,class:"swc-skel-card"}))});let d=Cr(l,s);return e("div",{class:"swc-gallery",children:[e("div",{class:"swc-tpls",role:"radiogroup","aria-label":"swarm templates",children:t.map(p=>{let g=p.roles.map(y=>y.role),h=u?.id===p.id;return e(j,{raised:!0,selected:h,class:E("swc-tpl",h&&"on"),onClick:()=>i(p.id),children:[e("div",{class:"swc-tpl-head",children:[e("span",{class:"swc-tpl-glyph","aria-hidden":"true",children:Be[p.topology]}),e("span",{class:"swc-tpl-title",children:[e("b",{children:p.name}),e("span",{class:"muted small",children:[p.topology," \xB7 ",p.roles.length," role",p.roles.length===1?"":"s"]})]}),h?e(I,{tone:"accent",children:"\u2713 selected"}):null]}),p.roles.length?e(Nn,{class:"swc-tpl-topo",topology:p.topology,roles:p.roles.map(y=>({name:y.role,count:y.count})),stages:p.swarm.stages}):e("div",{class:"swc-tpl-blank","aria-hidden":"true",children:"\uFF0B"}),e("p",{class:"small swc-tpl-desc",children:p.description}),e("p",{class:"small muted swc-tpl-when",children:p.useWhen}),e("div",{class:"swc-tpl-roles",children:p.roles.map(y=>e(Ke,{role:y.role,roles:g,title:`${y.role} \xB7 ${y.model}`,children:y.count>1?e("span",{class:"n",children:["\xD7",y.count]}):null}))})]})})}),u?e("div",{class:"swc-tpl-go",children:[e(xe,{label:"Swarm name",htmlFor:"swc-tpl-name",hint:"you start a run with /eminiar:em-swarm <name> <goal>",children:[e("input",{id:"swc-tpl-name",type:"text",class:"mono",value:l,spellcheck:!1,autocomplete:"off",onInput:p=>c(p.target.value.trim()),onKeyDown:p=>{p.key==="Enter"&&!d&&u&&r(l,u)}}),d?e("div",{class:"ds-field-error",children:d}):null]}),e("button",{type:"button",class:"primary",disabled:!!d,title:d,onClick:()=>r(l,u),children:[a,": ",u.name]})]}):null]})}function bo({issues:t,warnings:n,onLine:s,onPath:a}){return!t.length&&!n.length?null:e("ul",{class:"swc-issues",children:[t.map(r=>e("li",{class:"bad-row",children:[e("span",{class:"g","aria-hidden":"true",children:q.failed}),e("span",{class:"swc-issue-body",children:[r.path?a?e("button",{type:"button",class:"swc-path",title:"show the field",onClick:()=>a(r.path),children:r.path}):e("code",{children:r.path}):null," ",r.message]}),r.line&&s?e("button",{type:"button",class:"ghost sm swc-ln",onClick:()=>s(r.line),children:["line ",r.line]}):null]})),n.map(r=>e("li",{class:"warn-row",children:[e("span",{class:"g","aria-hidden":"true",children:q.blocked}),e("span",{class:"swc-issue-body",children:[r.path?a?e("button",{type:"button",class:"swc-path",onClick:()=>a(r.path),children:r.path}):e("code",{children:r.path}):null," ",r.message]})]}))]})}function Tu({mode:t,rawOnly:n,file:s,text:a,changed:r,removed:o,pending:i,stale:l,rawText:c,rawDisabled:u,issues:d,warnings:p,onMode:g,onRaw:h,onClose:y,onPath:m}){let f=te(null),v=te(null),b=new Set(r),w=C=>{if(t==="raw"&&v.current){let _=c.split(`
|
|
91
|
+
`),T=_.slice(0,C-1).reduce((F,D)=>F+D.length+1,0);v.current.focus(),v.current.setSelectionRange(T,T+(_[C-1]?.length??0));let M=Number.parseFloat(getComputedStyle(v.current).lineHeight)||18;v.current.scrollTop=Math.max(0,(C-4)*M);return}let S=f.current?.querySelectorAll(".sw-yaml .l")[C-1];S&&(S.scrollIntoView({block:"center",behavior:"smooth"}),S.classList.remove("flash"),S.offsetWidth,S.classList.add("flash"))},k=r[0];return e(j,{class:"swc-yaml",flush:!0,title:e("span",{class:"swc-yaml-title",children:["YAML ",e("code",{class:"small",children:s})]}),right:e("span",{class:"row tight",children:[n?e(I,{tone:"warn",children:"raw only"}):e(Se,{label:"YAML mode",value:t,onChange:g,options:[{id:"preview",label:"Preview",title:"the text the visual draft writes"},{id:"raw",label:"Raw",title:"edit the YAML text directly"}]}),y?e("button",{type:"button",class:"ghost sm","aria-label":"hide the YAML",onClick:y,children:"\u2715"}):null]}),children:[e("div",{class:"swc-yaml-sum small",children:[i?e("span",{class:"muted",children:"checking\u2026"}):null,l&&t!=="raw"?e("span",{class:"warn",role:"status",children:[q.blocked," ",l]}):r.length||o?e("button",{type:"button",class:"ghost sm",disabled:!k||t==="raw",title:"jump to the first change",onClick:()=>k&&w(k),children:[e("span",{class:"swc-diff-add",children:["+",r.length]})," line",r.length===1?"":"s"," changed \xB7 ",e("span",{class:"swc-diff-del",children:["\u2212",o]})," ","removed"]}):a!==void 0?e("span",{class:"muted",children:"no changes against the file on disk"}):null,t==="raw"?e("span",{class:"muted",children:"validated as you type; saved as written"}):e("span",{class:"muted",children:"comments and layout of untouched lines are kept"})]}),e("div",{class:"swc-yaml-body",ref:f,children:t==="raw"||n?e("textarea",{ref:v,class:"swc-raw",value:c,disabled:u,spellcheck:!1,"aria-label":`${s} as YAML`,onInput:C=>h(C.target.value),onKeyDown:C=>{if(C.key!=="Tab"||C.shiftKey)return;C.preventDefault();let S=C.target,{selectionStart:_,selectionEnd:T,value:M}=S;h(`${M.slice(0,_)} ${M.slice(T)}`),requestAnimationFrame(()=>S.setSelectionRange(_+2,_+2))}}):a===void 0?e("div",{class:"swc-pad ds-skel-stack",children:[80,60,72,40,66,54].map(C=>e(N,{w:`${C}%`,h:12}))}):e("div",{class:E(l&&"is-stale"),style:l?{opacity:.5}:void 0,children:e(kr,{text:a,marks:b})})}),e("div",{class:E("swc-yaml-issues",!d.length&&!p.length&&"empty"),children:e(bo,{issues:d,warnings:p,onLine:w,onPath:m})})]})}var Ef=350,Ru="eminiar.swarmcfg.yaml",Tf="Leave the Configuration Studio? Your unsaved changes to the swarm file will be lost.",Rf="Reload the swarm file from disk? Your unsaved changes in the studio will be lost.";function Au(t){return`${t==="conflict"?"The swarm file changed on disk, so your latest form edits cannot be rendered as YAML.":t==="render"?"Your latest form edits cannot be written as YAML.":"Your latest form edits could not be checked."} Raw YAML opens the last version that rendered, without those edits: they will not carry over to the text (the form keeps them until you save or revert). Open the raw YAML anyway?`}function Af(t,n){try{let s=localStorage.getItem(t);return s===null?n:s==="1"}catch{return n}}function Mf(t,n){try{localStorage.setItem(t,n?"1":"0")}catch{}}function yo(t){let n=t.message??String(t);if(t instanceof zt){let s=t.body??{};if(t.status===409)return{kind:"conflict",message:n,current:s.current??null};if(t.status===422)return{kind:"render",message:n,locked:s.locked??[]};if(t.status===400)return{kind:"invalid",message:n,issues:s.issues??[]}}return{kind:"error",message:n}}function Mu(t){let n=t.split(".");return n[0]==="swarms"&&n[1]?n[2]==="agents"&&n[3]?{swarm:n[1],role:n[3]}:{swarm:n[1]}:{settings:!0}}function Df(){return e("div",{class:"swc",role:"status","aria-busy":"true","aria-label":"loading the swarm file",children:[e(N,{h:52,class:"swc-skel-card"}),e("div",{class:"swc-layout",children:[e("aside",{class:"swc-rail",children:[e(N,{h:64,class:"swc-skel-card"}),e(N,{h:88,class:"swc-skel-card"}),e(N,{h:88,class:"swc-skel-card"})]}),e("section",{class:"swc-main",children:[e(N,{h:190,class:"swc-skel-card"}),e(N,{h:240,class:"swc-skel-card"}),e(N,{h:320,class:"swc-skel-card"})]})]})]})}function Du({o:t,params:n,onChanged:s}){let[a,r]=x(),[o,i]=x(),[l,c]=x({text:null,hash:null,doc:null}),[u,d]=x(null),[p,g]=x(null),h=te(null),[y,m]=x({pending:!1}),[f,v]=x(!1),b=te(null),[w,k]=x(!1),[C,S]=x(),[_,T]=x(),[M,F]=x(0),[D,$]=x(),[L,K]=x(),[Y,ne]=x(!1),[O,A]=x(()=>Af(Ru,!0)),W=te(0),ye=ut((P,G)=>{r(P),i(void 0),c({text:P.text,hash:P.hash,doc:P.doc}),d(P.doc?{doc:P.doc,renames:[]}:null);let he=P.state!=="absent"&&!P.doc||G&&P.text!==null;g(he?P.text??"":null),h.current=he?P.text:null,S(void 0),T(void 0),m({pending:!1})},[]),B=ut(async()=>{try{let P=await Wn();return ye(P,!1),P}catch(P){i(P.message);return}},[ye]);U(()=>{B(),di().then(P=>$(P.templates),P=>K(P.message))},[]);let re=!!a&&a.state!=="absent"&&!l.doc,fe=p!==null,dt=!!u&&(l.hash===null||u.renames.length>0||!Sr(u.doc,l.doc)),ue=wu({raw:p,baseText:l.text,visual:dt}),ge=ae(()=>p!==null?{text:p}:u?{doc:u.doc,renames:u.renames}:null,[p,u]);U(()=>{if(!ge||C)return;let P=++W.current;m(pe=>({...pe,pending:!0}));let G=setTimeout(async()=>{try{let pe=await zr({...ge,baseHash:l.hash});P===W.current&&m({pending:!1,result:pe,of:ge,...p===null&&u?{good:u}:{}})}catch(pe){if(P!==W.current)return;let he=yo(pe);he.kind==="conflict"&&S(he),m(et=>({...et,pending:!1,failure:he,of:ge}))}},Ef);return()=>clearTimeout(G)},[ge,l.hash,C,p,u,M]);let de=y.result,Ce=y.failure?.kind==="invalid"?y.failure.issues:de?.issues??a?.issues??[],oe=de?.warnings??a?.warnings??[],we=de?.locked??a?.locked??[],ie=!!y.failure&&y.failure.kind!=="conflict",He=!!de&&de.ok&&!y.pending&&!ie,Ge=!!ge&&ue&&He&&!f&&!C,ot=!ue&&!!t?.syncNeeded&&!f&&!C&&!!ge,it=l.doc?l.doc.enabled===!1:!!t&&!t.enabled,kt=ut(async P=>{if(!ge||!Ge&&!(P&&ot))return;let G=document.activeElement;b.current=G instanceof HTMLElement&&G!==document.body?G:null,v(!0),T(void 0);try{if(!ue){let et=await Wn().catch(()=>{});if(et&&et.hash!==l.hash){ye(et,p!==null),s(),ee("the swarm file changed on disk; the studio now shows it. Check it and press again");return}}let pe=await ui({...ge,baseHash:l.hash,sync:P}),he=pe.sync;ee([pe.saved?pe.created?"created the swarm file":`saved ${pe.changed.length} changed line(s)`:"no changes to save",he?`${he.changed} agent file(s) synced${he.conflicts?`, ${he.conflicts} conflict(s) left alone`:""}`:null].filter(Boolean).join(" \xB7 "),!!he?.conflicts),await B(),s()}catch(pe){let he=yo(pe);he.kind==="conflict"?S(he):he.kind==="error"?T({message:he.message,sync:P}):m(et=>({...et,failure:he,of:ge})),ee(`save failed: ${he.message}`,!0)}finally{v(!1)}},[ge,l.hash,Ge,ot,ue,p,ye,B,s]);U(()=>{if(f)return;let P=b.current;if(b.current=null,!P)return;let G=document.activeElement;if(G&&G!==document.body&&G!==P)return;let pe=P.isConnected?P:P.id?document.getElementById(P.id):null;!pe||pe.closest("[inert]")||pe.disabled||pe.focus({preventScroll:!0})},[f]);let Jn=te(kt);Jn.current=kt,U(()=>{let P=G=>{(G.metaKey||G.ctrlKey)&&!G.shiftKey&&!G.altKey&&G.key.toLowerCase()==="s"&&(G.preventDefault(),Jn.current(!1))};return document.addEventListener("keydown",P),()=>document.removeEventListener("keydown",P)},[]);let Tt=te(ue);Tt.current=ue,U(()=>{let P=pe=>{Tt.current&&(pe.preventDefault(),pe.returnValue="")},G=Si(pe=>!Tt.current||pe.view==="swarm"&&pe.sub==="config"||window.confirm(Tf));return window.addEventListener("beforeunload",P),()=>{G(),window.removeEventListener("beforeunload",P)}},[]);let Xt=ut(async()=>{try{let P=await Wn();r(P),c({text:P.text,hash:P.hash,doc:P.doc}),d(G=>G&&{doc:G.doc,renames:[]}),S(void 0),T(void 0),m({pending:!1}),ee(P.hash===null?"the file is gone on disk; saving now creates it again from your draft":"rebased your draft on the file on disk; saving now overwrites the other change")}catch(P){ee(`could not read the file: ${P.message}`,!0)}},[]),Gt=()=>{Tt.current&&!window.confirm(Rf)||B()},Le=u?.doc,gt=Le?Object.keys(Le.swarms):[],Qe=n.tab==="settings"?"settings":"swarm",ve=Qe==="swarm"?n.swarm&&Le?.swarms[n.swarm]?n.swarm:gt[0]:void 0,jt=ve&&Le?Le.swarms[ve]:void 0,ht=jt&&n.role&&jt.agents[n.role]?n.role:void 0,Ue=P=>H("swarm/config",P),ms=P=>d(G=>G&&P(G)),Rt=P=>ms(G=>({...G,doc:P(G.doc)})),mn=te({body:ge,draft:u,base:l,visualDirty:dt,check:y,conflict:C,rawMode:fe,saving:f});mn.current={body:ge,draft:u,base:l,visualDirty:dt,check:y,conflict:C,rawMode:fe,saving:f};let xo=te(0);U(()=>{let P=mn.current;if(!t||!a||Tt.current||P.saving||P.conflict||w)return;let G=++xo.current;Wn().then(pe=>{let he=mn.current;G!==xo.current||Tt.current||he.saving||he.conflict||he.body!==P.body||he.base!==P.base||pe.hash===he.base.hash||ye(pe,he.rawMode)},()=>{})},[t]);let Xn=P=>{h.current=P,g(P)},gs=async()=>{if(!w){for(let P=0;P<3;P++){let G=mn.current;if(G.rawMode||G.saving||!G.body)return;let pe=G.check.of===G.body,he=ku({dirty:G.visualDirty,current:pe,failure:pe?G.check.failure?.kind:void 0,conflict:!!G.conflict}),et=G.check.result?.text??G.base.text??"";if(he.kind==="base")return Xn(G.base.text??"");if(he.kind==="render")return Xn(G.check.result?.text??et);if(he.kind==="stale"){window.confirm(Au(he.reason))&&Xn(et);return}k(!0);try{let gn=await zr({...G.body,baseHash:G.base.hash});if(mn.current.body!==G.body)continue;return m({pending:!1,result:gn,of:G.body,...G.draft?{good:G.draft}:{}}),Xn(gn.text)}catch(gn){if(mn.current.body!==G.body)continue;let hn=yo(gn);hn.kind==="conflict"&&S(hn),m(Xu=>({...Xu,pending:!1,failure:hn,of:G.body})),window.confirm(Au(hn.kind))&&Xn(et);return}finally{k(!1)}}ee("the draft kept changing; open Raw YAML again",!0)}},So=()=>{p!==null&&p!==h.current&&!window.confirm("Discard your raw YAML edits and go back to the visual editor?")||(g(null),h.current=null)},_o=P=>{A(P),Mf(Ru,P)},Co=P=>{let G=Mu(P);G.settings?Ue({tab:"settings"}):Ue({swarm:G.swarm,role:G.role})};if(!a)return o?e(j,{children:[e(Z,{error:o}),e("button",{type:"button",class:"sm",onClick:()=>{B()},children:"Retry"})]}):e(Df,{});if(a.state==="absent"&&!u)return e("div",{class:"swc",children:[e("section",{class:"ds-hero swc-onboard",children:[e("div",{class:"ds-hero-main",children:[e("div",{class:"ds-eyebrow",children:"Configuration Studio \xB7 not opted in"}),e("h1",{class:"ds-hero-title",children:"Design your first agent swarm"}),e("div",{class:"ds-hero-sub",children:["Swarms are off for this project: there is no ",e("code",{children:a.file})," yet, so no agent files are written and no hook does swarm work. Pick a template (or the annotated starter), shape the roles, models and topology, and save to opt in."]}),e("div",{class:"ds-hero-meta",children:[a.starter?e("button",{type:"button",class:"primary",onClick:()=>{d({doc:a.starter,renames:[]}),Ue({})},children:"Start from the annotated starter"}):null,e("span",{class:"small muted",children:"or choose a template below"})]})]}),e("div",{class:"ds-hero-aside swc-onboard-glyphs","aria-hidden":"true",children:["hierarchical","mesh","pipeline"].map(P=>e("span",{children:Be[P]}))})]}),e(j,{title:"Templates",sub:"a ready-made team you can reshape",raised:!0,children:e(fo,{templates:D,error:L,taken:[],action:"Create",onCreate:(P,G)=>{d({doc:gu(P,G.swarm),renames:[]}),Ue({swarm:P})}})})]});let Dr=a.meta,$o=a.activeRuns,hs=Ce.length,Lr=oe.length,At=y.failure,Eo=C?`not checked: the file was ${C.current?"changed":"removed"} on disk`:ie?At?.kind==="render"?"out of date: the latest edit cannot be written; this is the last version that rendered":"out of date: the last check failed":void 0,To=C?{tone:"bad",text:`${q.failed} ${C.current?"changed":"removed"} on disk`}:y.pending?{tone:"muted",text:"checking\u2026"}:ie?{tone:"bad",text:`${q.failed} ${At?.kind==="error"?"not checked":"cannot render"}`}:hs?{tone:"bad",text:`${q.failed} ${hs} issue${hs===1?"":"s"}`}:Lr?{tone:"warn",text:`\u26A0 ${Lr} warning${Lr===1?"":"s"}`}:de?{tone:"ok",text:`${q.done} valid`}:{tone:"muted",text:"not checked yet"},Ro=e(Tu,{mode:fe?"raw":"preview",rawOnly:re,file:a.file,text:de?.text??(fe?void 0:l.text??void 0),changed:de?.changed??[],removed:de?.removed??0,pending:y.pending,stale:Eo,rawText:p??"",issues:Ce,warnings:oe,onMode:P=>P==="raw"?void gs():So(),onRaw:g,onClose:fe?void 0:()=>_o(!1),onPath:fe?void 0:Co}),Ao=At?.kind==="render"&&!fe?y.good:void 0;return e("div",{class:E("swc",fe&&"is-raw"),children:[e("div",{class:"swc-bar",role:"toolbar","aria-label":"swarm file actions",children:[e("div",{class:"swc-bar-file",children:[e("code",{title:a.file,children:a.file}),l.hash===null?e(I,{tone:"accent",children:"new file"}):null,e(I,{tone:To.tone,title:hs?Ce.map(P=>P.message).join(`
|
|
92
|
+
`):void 0,children:To.text}),ue?e("span",{class:"swc-dirty",title:"the draft differs from the file on disk",children:[e("i",{"aria-hidden":"true"})," unsaved"]}):e("span",{class:"small muted",children:"saved"}),de&&!Eo&&(de.changed.length||de.removed)?e("span",{class:"small muted ds-num",children:["+",de.changed.length," \u2212",de.removed," lines"]}):null]}),e("div",{class:"swc-bar-actions",children:[re?null:fe?e("button",{type:"button",class:"sm",disabled:f,onClick:So,title:"back to the form",children:"\u2190 Visual editor"}):e("button",{type:"button",class:"sm ghost",disabled:f||w,"aria-busy":w||void 0,onClick:()=>{gs()},title:w?"rendering the draft\u2026":"edit the YAML text directly",children:w?"Rendering\u2026":"Raw YAML"}),fe?null:e("button",{type:"button",class:E("sm ghost",O&&"on"),"aria-pressed":O,onClick:()=>_o(!O),children:O?"Hide YAML":"Show YAML"}),e("button",{type:"button",class:"sm",disabled:!ue||f,onClick:()=>{g(re?l.text??"":null),h.current=re?l.text:null,d(l.doc?{doc:l.doc,renames:[]}:null),T(void 0)},children:"Revert"}),e("button",{type:"button",class:"sm",disabled:!Ge,title:Ge?"save (\u2318S / Ctrl-S)":ue?"fix the issues first":"no changes",onClick:()=>{kt(!1)},children:f?"Saving\u2026":l.hash===null?"Create":"Save"}),e("button",{type:"button",class:"sm primary",disabled:!Ge&&!ot,title:ot&&it?"swarms are disabled: delete the generated .claude/agents/swarm-*.md files":"save, then write .claude/agents/swarm-*.md",onClick:()=>{kt(!0)},children:ot?it?"Remove agent files":"Sync agent files":l.hash===null?"Create & sync":"Save & sync"})]})]}),C?e("div",{class:"swc-banner bad",role:"alert",children:[e("span",{children:C.current?e(R,{children:[e("b",{children:[q.failed," The swarm file changed on disk"]})," since the studio loaded it (",C.message,"). Nothing was overwritten."]}):e(R,{children:[e("b",{children:[q.failed," The swarm file was removed on disk"]})," since the studio loaded it (a branch switch?). Keep your draft to create it again on save, or reload."]})}),e("span",{class:"row tight",children:[e("button",{type:"button",class:"sm",disabled:f,onClick:Gt,children:"Reload from disk"}),e("button",{type:"button",class:"sm primary",disabled:f,title:C.current?"rebase your draft on the file on disk; saving overwrites the other change":"keep your draft; saving creates the file again",onClick:()=>{Xt()},children:"Keep mine"})]})]}):null,At&&At.kind==="render"?e("div",{class:"swc-banner warn",role:"alert",children:[e("span",{children:[e("b",{children:[q.blocked," This edit cannot be written from the form."]})," ",At.message]}),re||fe?null:e("span",{class:"row tight",children:[Ao?e("button",{type:"button",class:"sm primary",disabled:f,title:"drop the edit that cannot be written (and any form edit after it); earlier edits stay",onClick:()=>d(Ao),children:"Undo the last change"}):null,e("button",{type:"button",class:"sm",disabled:f||w,onClick:()=>{gs()},children:"Edit in raw YAML"})]})]}):null,_&&!C?e("div",{class:"swc-banner bad",role:"alert",children:[e("span",{children:[e("b",{children:[q.failed," The save did not go through"]})," (",_.message,"). Your draft is kept; try again."]}),e("span",{class:"row tight",children:[e("button",{type:"button",class:"sm primary",disabled:f||!(Ge||_.sync&&ot),onClick:()=>{kt(_.sync)},children:"Retry"}),e("button",{type:"button",class:"sm ghost","aria-label":"dismiss the save error",onClick:()=>T(void 0),children:"Dismiss"})]})]}):null,At&&At.kind==="error"?e("div",{class:"swc-banner bad",role:"alert",children:[e("span",{children:[e("b",{children:[q.failed," The draft could not be checked"]})," (",At.message,")."]}),e("button",{type:"button",class:"sm",disabled:f||y.pending,onClick:()=>F(P=>P+1),children:"Check again"})]}):null,re?e("div",{class:"swc-banner warn",children:e("span",{children:[e("b",{children:[q.blocked," The file is not valid YAML"]}),", so only the raw editor works. Fix it and save; the visual editor comes back once it parses."]})}):null,Le&&Le.enabled===!1&&!fe?e("div",{class:"swc-banner warn",children:[e("span",{children:[e("b",{children:"Swarms are disabled"})," (",e("code",{children:"enabled: false"}),"): the hooks ignore every swarm below and a sync removes the generated agent files."]}),e("button",{type:"button",class:"sm",disabled:f,onClick:()=>Rt(P=>at(P,["enabled"],!0)),children:"Turn swarms on"})]}):null,oe.filter(P=>P.kind==="active-run").length&&!fe?e("div",{class:"swc-banner info",children:e("span",{children:[e("b",{children:[q.active," A run is active."]})," ",oe.filter(P=>P.kind==="active-run").map(P=>P.message).join(" \xB7 "),". Saving is allowed; the run keeps the workers it has."]})}):null,fe?e("div",{class:"swc-raw-wrap",inert:f,"aria-busy":f||void 0,children:Ro}):Le?e("div",{class:E("swc-layout",O&&"with-yaml"),inert:f,"aria-busy":f||void 0,children:[e("aside",{class:"swc-rail","aria-label":"swarms in the file",children:[e("button",{type:"button",class:E("swc-nav-item settings",Qe==="settings"&&"on"),"aria-current":Qe==="settings"?"page":void 0,onClick:()=>Ue({tab:"settings"}),children:[e("span",{class:"swc-nav-glyph","aria-hidden":"true",children:"\u2699"}),e("span",{class:"swc-nav-main",children:[e("b",{children:"File settings"}),e("span",{class:"small muted",children:[Le.enabled===!1?"disabled":"enabled"," \xB7 sync ",Le.sync??"auto",Le.enforce?" \xB7 enforced":""]})]}),(()=>{let P=Ce.filter(G=>Mu(G.path).settings).length;return P?e(I,{tone:"bad",children:P}):null})()]}),e("div",{class:"swc-rail-head small muted",children:["Swarms ",e("span",{class:"ds-num",children:gt.length})]}),gt.map(P=>{let G=Le.swarms[P],pe=$r(G),he=Lt(Ce,`swarms.${P}`).length,et=Object.keys(G.agents),gn=$o.some(hn=>hn.swarm===P);return e("button",{type:"button",class:E("swc-nav-item",P===ve&&"on"),"aria-current":P===ve?"page":void 0,onClick:()=>Ue({swarm:P}),children:[e("span",{class:"swc-nav-glyph","aria-hidden":"true",children:Be[G.topology??"hierarchical"]}),e("span",{class:"swc-nav-main",children:[e("b",{children:[P,gn?e("i",{class:"swc-live-dot",title:"a run of this swarm is active"}):null]}),e("span",{class:"small muted",children:[G.topology??"hierarchical"," \xB7 ",et.length," role",et.length===1?"":"s"," \xB7"," ",e("span",{class:E("ds-num",pe.over&&"warn"),children:[pe.total,"/",pe.max]})]})]}),he?e(I,{tone:"bad",children:[q.failed," ",he]}):null]})}),e("button",{type:"button",class:"swc-new",onClick:()=>ne(!0),children:"\uFF0B New swarm"}),Ce.length&&Qe==="swarm"?e("div",{class:"swc-rail-issues",children:[e(bo,{issues:Ce.slice(0,6),warnings:[],onPath:Co}),Ce.length>6?e("div",{class:"small muted",children:["+",Ce.length-6," more in the YAML pane"]}):null]}):null]}),e("section",{class:"swc-main",children:Qe==="settings"?e(_u,{doc:Le,meta:Dr,issues:Ce,locked:we,onChange:P=>ms(G=>({...G,doc:P}))}):jt&&ve?e(Eu,{name:ve,swarm:jt,doc:Le,meta:Dr,issues:Ce,warnings:oe,locked:we,swarmNames:gt,activeRun:$o.find(P=>P.swarm===ve)?.id,selectedRole:ht,onChange:P=>Rt(G=>at(G,["swarms",ve],P)),onRename:P=>{ms(G=>lu(G,l.doc,ve,P)),Ue({swarm:P})},onDuplicate:()=>{let P=pn(`${ve}-copy`,gt);Rt(G=>du(G,ve,P)),Ue({swarm:P})},onDelete:()=>{Rt(P=>uu(P,ve)),Ue({swarm:gt.find(P=>P!==ve)})},onOpenRole:P=>Ue({swarm:ve,role:P}),onAddRole:(P,G)=>{Rt(pe=>G?co(pe,ve,G,P):lo(pe,ve,P)),Ue({swarm:ve,role:P})}},ve):e(j,{raised:!0,children:e(X,{icon:"\uFF0B",title:"No swarms in the file yet",action:e("button",{type:"button",class:"primary",onClick:()=>ne(!0),children:"Add a swarm from a template"}),children:"A swarm is a team of Claude Code subagents: named roles with their prompts, models and tools, and how they coordinate."})})}),O?e("aside",{class:"swc-side",children:Ro}):null]}):e(j,{children:e(X,{icon:"\u270E",title:"Nothing to edit",children:"The swarm file has no structured content."})}),e("div",{style:{display:"contents"},inert:f,children:[jt&&ve&&ht&&!fe?e(Su,{swarm:ve,name:ht,role:jt.agents[ht],doc:Le,meta:Dr,issues:Ce,locked:we,taken:Object.keys(jt.agents).filter(P=>P!==ht),onChange:P=>Rt(G=>at(G,["swarms",ve,"agents",ht],P)),onRename:P=>{ms(G=>cu(G,l.doc,ve,ht,P)),Ue({swarm:ve,role:P})},onDuplicate:()=>{let P=pn(`${ht}-copy`,Object.keys(jt.agents));Rt(G=>co(G,ve,ht,P)),Ue({swarm:ve,role:P})},onDelete:()=>{Rt(P=>pu(P,ve,ht)),Ue({swarm:ve})},onRaw:()=>{Ue({swarm:ve}),gs()},onClose:()=>Ue({swarm:ve})},`${ve}/${ht}`):null,Y&&Le?e(Sn,{title:"New swarm from a template",onClose:()=>ne(!1),children:e(fo,{templates:D,error:L,taken:gt,onCreate:(P,G)=>{Rt(pe=>io(pe,P,G.swarm)),ne(!1),Ue({swarm:P})}})}):null]})]})}var Lf=15e3,jf=2e3,Pf=5e3,Lu=800,If=5,vo=30,Ff=1e3,Of=3e4,wo=()=>document.visibilityState==="visible";function Nf(t,n){if(!n.length)return t;let s=new Map(t.map(r=>[r.id,r]));for(let r of n)s.set(r.id,r);let a=[...s.values()].sort((r,o)=>r.id-o.id);return a.length>Lu?a.slice(-Lu):a}function Bf({onCreated:t}){let[n,s]=x(!1),[a,r]=x();return e("span",{class:"row tight",children:[e("button",{type:"button",class:"primary",disabled:n,onClick:async()=>{s(!0),r(void 0);try{let o=await $e("/api/swarm/init",{});ee(`created ${o.created} \xB7 ${o.sync.changed} agent file(s) written`),t()}catch(o){r(o.message)}finally{s(!1)}},children:n?"Creating\u2026":"Create from the starter"}),a?e("span",{class:"bad small",children:a}):null]})}function Hf({needed:t,disabled:n,onDone:s}){let[a,r]=x(!1),[o,i]=x();return e("div",{class:"row tight sw-sync",children:[e("button",{type:"button",class:E("sm",t&&"primary"),disabled:a,title:n?"swarms are disabled: delete the generated .claude/agents/swarm-*.md files":"write .claude/agents/swarm-<swarm>-<role>.md from the swarm file",onClick:async()=>{r(!0),i(void 0);try{let l=await $e("/api/swarm/sync",{}),c=`${l.changed} file(s) changed${l.conflicts?` \xB7 ${l.conflicts} conflict(s) left alone`:""}`;i({text:c,bad:l.conflicts>0}),s()}catch(l){i({text:l.message,bad:!0})}finally{r(!1)}},children:a?"Syncing\u2026":n?"Remove agent files":"Sync agent files"}),o?e("span",{class:E("small",o.bad?"bad":"muted"),children:o.text}):t?e("span",{class:"small warn",children:[q.blocked," ",n?"agent files left to remove":"out of date"]}):e("span",{class:"small muted",children:[q.done," in sync"]})]})}function ju({text:t,label:n}){return e("div",{class:"sw-copy",children:[n?e("span",{class:"muted small",children:n}):null,e("span",{class:"sw-copy-row",children:[e("code",{children:t}),e("button",{type:"button",class:"ghost sm",title:"copy to the clipboard",onClick:async()=>{try{await navigator.clipboard.writeText(t),ee("copied")}catch{ee("could not copy: select the line and copy it by hand",!0)}},children:"Copy"})]})]})}function Uf({issues:t}){return e("ul",{class:"sw-issues",children:t.map(n=>e("li",{children:[e("span",{class:"g sw-s-failed",children:q.failed}),e("span",{class:"ln mono",children:n.line?`line ${n.line}`:"file"}),n.path?e("code",{children:n.path}):null," ",e("span",{children:n.message})]}))})}var Un=t=>e("a",{class:"ds-link",href:`#/swarm/config${t?`?swarm=${encodeURIComponent(t)}`:""}`,onClick:n=>{n.preventDefault(),H("swarm/config",{swarm:t})},children:"Configure \u2192"});function Jf({s:t}){let n=t.roles.map(r=>r.role),s=ls(t.roles,t.maxAgents),a=t.roles.filter(r=>r.file.action!=="unchanged"&&r.file.action!=="disabled");return e("a",{class:"sw-swarm-row",href:`#/swarm/config?swarm=${encodeURIComponent(t.name)}`,title:t.description||`edit ${t.name} in the configuration studio`,children:[e("span",{class:"sw-swarm-glyph","aria-hidden":"true",children:Be[t.topology]}),e("span",{class:"sw-swarm-main",children:[e("span",{class:"sw-swarm-name",children:[e("b",{children:t.name}),e("span",{class:"muted small",children:[t.topology," \xB7 ",t.roles.length," role",t.roles.length===1?"":"s"," \xB7 ",s.total,"/",t.maxAgents," slots"]})]}),e("span",{class:"sw-swarm-chips",children:t.roles.map(r=>e(Ke,{role:r.role,roles:n,title:`${r.description}
|
|
93
|
+
${r.agentType} \xB7 ${Ka[r.file.action].word}`,children:r.count>1?e("span",{class:"n",children:["\xD7",r.count]}):null}))}),a.length||s.over?e("span",{class:"sw-swarm-badges",children:[a.length?e(I,{tone:"warn",title:a.map(r=>`${r.role}: ${Ka[r.file.action].word}`).join(`
|
|
94
|
+
`),children:[q.blocked," ",a.length," agent file",a.length===1?"":"s"," to sync"]}):null,s.over?e(I,{tone:"muted",title:"more worker slots than max_agents: only max_agents run at once",children:[s.total," > max ",s.max]}):null]}):null]})]})}function Xf({o:t,onChanged:n}){return t.state==="absent"?e(j,{title:"Swarms",right:e(I,{tone:"muted",children:"not opted in"}),children:[e("p",{class:"small muted sw-p",children:["No ",e("code",{children:t.file})," yet, so swarms are off for this project."]}),Un()]}):t.state==="invalid"?e(j,{title:"Swarms",right:e(I,{tone:"bad",children:[q.failed," ",t.issues.length," issue",t.issues.length===1?"":"s"]}),children:[e("p",{class:"small muted sw-p",children:[e("code",{children:t.file})," is invalid: hooks ignore it and no agent files are written until it parses."]}),Un()]}):e(j,{title:"Swarms",sub:`${t.swarms.length} defined`,right:Un(),children:[t.enabled?null:e("div",{class:"sw-note-box",children:[e(qe,{s:"stale",word:"disabled"})," ",e("code",{children:"enabled: false"}),": hooks ignore the swarms and a sync removes the generated agent files."]}),e("div",{class:"sw-swarm-list",children:t.swarms.map(s=>e(Jf,{s}))}),t.orphans.length?e("div",{class:"small sw-orphans",children:t.orphans.map(s=>e("div",{children:[e("span",{class:"sw-s-stale",children:q.stale})," ",e("code",{children:s.path})," ",e("span",{class:"muted",children:s.reason??"will be removed"})]}))}):null,t.enabled||t.syncNeeded?e(Hf,{needed:t.syncNeeded,disabled:!t.enabled,onDone:n}):null]})}function Gf({r:t,selected:n}){let s=t.counts.tasks,a=s.failed+s.blocked,r=vr(s);return e("a",{class:E("sw-run-item",n&&"sel",t.status==="active"&&"is-live"),href:`#/swarm?run=${encodeURIComponent(t.id)}`,"aria-current":n?"page":void 0,children:[e("div",{class:"sw-run-top",children:[e(I,{tone:fr[t.status],children:[q[t.status]," ",t.status]}),e("span",{class:"muted small",children:[Be[t.topology]," ",t.swarm]}),e("span",{class:"spacer"}),e("span",{class:"muted small",title:new Date(t.created_at).toLocaleString(),children:me(t.created_at)})]}),e("div",{class:"sw-goal",title:t.goal,children:t.goal}),e("div",{class:"sw-run-foot small muted",children:[e("span",{children:s.total?`${s.done}/${s.total} tasks`:"no tasks"}),t.counts.workers.running?e("span",{class:"sw-s-running",children:[q.running," ",t.counts.workers.running," running"]}):null,a?e("span",{class:"sw-s-failed",children:[q.failed," ",a]}):null,s.total?e("span",{class:"spacer"}):null,s.total?e("span",{class:"ds-num",children:[Math.round(r*100),"%"]}):null]}),s.total?e(St,{total:s.total,title:`${s.done} done \xB7 ${s.active} active \xB7 ${a} failed/blocked of ${s.total}`,segments:[{value:s.done,tone:"ok"},{value:s.active,tone:"accent"},{value:a,tone:"bad"}]}):null]},t.id)}function Wf({runs:t,selected:n,more:s,loading:a,onMore:r}){let[o,i]=x("all"),l=Yd(t),c=Vd(t,o);return e(j,{flush:!0,class:"sw-runs-card",title:"Runs",sub:t.length?`${l.active} active \xB7 ${t.length}${s?"+":""}`:"none",children:t.length?e(R,{children:[e("div",{class:"sw-run-filter",children:e(Se,{label:"filter runs by status",value:o,onChange:i,options:to.map(u=>({id:u,title:u==="failed"?"failed or cancelled":`${u} runs`,label:e(R,{children:[u,e("span",{class:"sw-count",children:l[u]})]})}))})}),e("div",{class:"sw-runs",children:[c.length?c.map(u=>e(Gf,{r:u,selected:u.id===n})):e("div",{class:"empty small",children:["No ",o," runs among the ",t.length," listed."]}),s?e("div",{class:"sw-more",children:e("button",{type:"button",class:"ghost sm",disabled:a,onClick:r,children:a?"Loading\u2026":`Show ${vo} older runs`})}):null]})]}):e("div",{class:"sw-pad",children:e(X,{compact:!0,icon:"\u25B8",title:"No runs yet",children:"Runs appear here as soon as the coordinator starts one."})})})}function zf({o:t,onCreated:n}){return e("div",{class:"sw-run",children:[e(j,{class:"sw-optin",raised:!0,children:e(X,{icon:Be.hierarchical,title:"Agent swarms are off for this project",action:e("div",{class:"row sw-optin-actions",children:[e("button",{type:"button",class:"primary",onClick:()=>H("swarm/config"),children:"Open the Configuration Studio"}),e(Bf,{onCreated:n})]}),children:["A swarm is a team of Claude Code subagents defined in ",e("code",{children:t.file}),": named roles with their prompts, models, tools and skills, and how they coordinate (hierarchical, mesh or pipeline). Your main session leads the run and this page shows it live. Nothing changes until the file exists: no agent files, no swarm work in any hook."]})}),t.starter?e(j,{title:"Starter",sub:`${t.file} \xB7 read-only preview`,children:e(kr,{text:t.starter})}):null]})}function qf({o:t}){return t.state==="invalid"?e(j,{class:"sw-optin",title:"The swarm file is invalid",sub:t.file,right:Un(),children:[e("p",{class:"small",children:"Fix these and the swarms appear here:"}),e(Uf,{issues:t.issues})]}):e("div",{class:"sw-run",children:[e(X,{icon:"\u25B8",title:t.enabled?"No runs yet":"Swarms are disabled",action:t.swarms[0]?e(ju,{text:cs(t.swarms[0].name)}):null,children:t.enabled?e(R,{children:"Start a run from Claude Code. The coordinator (your session) plans the tasks and spawns the workers; the topology, task board and activity feed fill in here live."}):e(R,{children:[e("code",{children:"enabled: false"})," in ",e("code",{children:t.file}),": the hooks ignore the swarms below until it is switched back on in ",Un()]})}),t.swarms.length?e("div",{class:"sw-previews",children:t.swarms.map(n=>{let s=ls(n.roles,n.maxAgents);return e(j,{raised:!0,class:"sw-preview",title:e(R,{children:[e("span",{class:"sw-swarm-glyph",children:Be[n.topology]})," ",n.name]}),sub:`${n.topology} \xB7 ${n.roles.length} roles \xB7 ${s.total} slots \xB7 max ${n.maxAgents}`,right:Un(n.name),children:[n.description?e("p",{class:"small muted sw-p",children:n.description}):null,e(Nn,{topology:n.topology,roles:n.roles.map(a=>({name:a.role,count:a.count})),stages:n.stages,maxAgents:n.maxAgents}),e(ju,{label:"in Claude Code",text:cs(n.name)})]})})}):null]})}function Pu(){return e("div",{class:"sw-run",role:"status","aria-busy":"true","aria-label":"loading the run",children:[e("div",{class:"sw-skel-hero",children:[e("div",{class:"ds-skel-stack",children:[e(N,{w:180,h:12}),e(N,{w:"70%",h:30}),e(N,{w:"40%",h:14})]}),e(N,{class:"sk-round",w:104,h:104})]}),e("div",{class:"ds-stats",children:[0,1,2,3,4].map(()=>e("div",{class:"ds-stat",children:[e(N,{w:70,h:10}),e(N,{w:90,h:26}),e(N,{w:"80%",h:10})]}))}),e("div",{class:"sw-grid",children:[e(N,{h:320,class:"sw-skel-card"}),e(N,{h:320,class:"sw-skel-card"})]})]})}function Kf(){return e("div",{class:"sw-layout",children:[e("aside",{class:"sw-rail",children:[e(N,{h:180,class:"sw-skel-card"}),e(N,{h:320,class:"sw-skel-card"})]}),e("section",{class:"sw-main",children:e(Pu,{})})]})}var Vf=(t,n)=>!!t&&t.length===n.length&&t.every((s,a)=>s===n[a]);function Yf({id:t,swarms:n,onChanged:s}){let[a,r]=x(),[o,i]=x(),[l,c]=x(null),[u,d]=x([]),[p,g]=x(!1),[h,y]=x(null),[m,f]=x(null),[v,b]=x(0),[w,k]=x(),C=te(0),S=te(!1),_=te(new Map),T=te([]),M=te(0),F=te(),D=te(""),$=te(!1),L=te(!1),K=te(!0),Y=ut(async(ue=!1)=>{let ge=S.current&&!ue&&M.current>0,de;try{de=await J("/api/swarm/run",{id:t,tasksSince:ge?M.current:void 0,events:S.current?0:void 0})}catch(ie){return K.current&&i(ie.message),!1}if(!K.current)return!0;let Ce=!de.tasksPartial;if(de.tasksPartial){for(let ie of de.tasks){let He=_.current.get(ie.id);(!He||He.updated_at!==ie.updated_at||He.status!==ie.status)&&(Ce=!0),_.current.set(ie.id,ie)}if(de.taskCount!==void 0&&_.current.size!==de.taskCount)return Y(!0)}else _.current=new Map(de.tasks.map(ie=>[ie.id,ie]));Ce&&(T.current=[..._.current.values()].sort((ie,He)=>ie.id-He.id),M.current=T.current.reduce((ie,He)=>Math.max(ie,He.updated_at),0)),Vf(F.current,de.roles)||(F.current=de.roles);let oe=de.now-Date.now();b(ie=>Math.abs(ie-oe)>1e3?oe:ie);let we=D.current;return D.current=de.run.status,S.current||(S.current=!0,C.current=de.events.length?de.events[de.events.length-1].id:0,d(de.events)),r({...de,tasks:T.current,roles:F.current??de.roles}),i(void 0),c(null),we==="active"&&de.run.status!=="active"&&($.current=!0,s()),!0},[t]),ne=ut(async ue=>{try{let ge=await $e("/api/swarm/release",{id:t,agent:ue});ee(`released ${ge.released.join(", ")}; its task is pending again`),Y(!0)}catch(ge){ee(`release failed: ${ge.message}`,!0)}},[t,Y]),O=ut(ue=>{y(ue),f(ue)},[]),A=ut(()=>f(null),[]);if(U(()=>{K.current=!0;let ue,ge=Ff,de=async()=>{await Y()||!K.current||S.current||(c(ge),ue=setTimeout(de,ge),ge=Math.min(ge*2,Of))};de();let Ce=setInterval(async()=>{if(!(!S.current||L.current||!wo())&&!(D.current!=="active"&&!$.current)){L.current=!0;try{let we=!0,ie=!1;for(let He=0;He<If&&we;He++){let Ge=await J("/api/swarm/events",{id:t,after:C.current});if(!K.current)return;Ge.events.length&&(C.current=Ge.last,d(ot=>Nf(ot,Ge.events))),we=Ge.more,ie=Ge.run.status!=="active"}$.current=we,g(we),ie&&!we&&D.current==="active"&&Y()}catch{}finally{L.current=!1}}},jf),oe=setInterval(()=>{S.current&&D.current==="active"&&wo()&&Y()},Pf);return()=>{K.current=!1,clearTimeout(ue),clearInterval(Ce),clearInterval(oe)}},[t]),!a)return o?e(j,{children:[e(Z,{error:o}),e("div",{class:"small muted sw-retry",children:l?`retrying in ${Math.round(l/1e3)} s\u2026`:"retrying\u2026"})]}):e(Pu,{});let{run:W}=a,ye=W.status==="active",B=a.roles,re=a.workers.length,fe=m?a.workers.find(ue=>ue.agent_id===m):void 0,dt=n.find(ue=>ue.name===W.swarm);return e("div",{class:E("sw-run",ye&&"is-live"),children:[o?e("div",{class:"sw-note-box bad small",children:["refresh failed: ",o]}):null,e(Qd,{detail:a,skew:v,finished:w,onFinished:ue=>{k(ue),Y(!0),s()}}),e("div",{class:"sw-grid-box",children:e("div",{class:"sw-grid",children:[e(j,{class:"sw-topo-card",title:"Topology",sub:`${Be[W.topology]} ${W.topology} \xB7 ${re} worker${re===1?"":"s"}`,right:h?e("button",{type:"button",class:"chip on",title:"show every worker again",onClick:()=>y(null),children:["focus ",We(h)," \u2715"]}):ye?e(I,{tone:"accent",dot:!0,children:"live"}):null,children:e(Jd,{detail:a,events:u,skew:v,roles:B,picked:h,onPick:y})}),e(ru,{workers:a.workers,tasks:a.tasks,roles:B,live:ye,skew:v,staleMs:a.staleMs,picked:h,onPick:O,onRelease:ne})]})}),e(tu,{tasks:a.tasks,workers:a.workers,roles:B,live:ye,skew:v}),e(nu,{timeline:a.timeline,live:ye,roles:B,skew:v,onRelease:ne}),e("div",{class:"sw-two",children:[e(Xd,{events:u,roles:B,live:ye,skew:v,behind:p,agent:h,onAgent:y}),e(Od,{notes:a.notes,roles:B,live:ye,skew:v})]}),fe?e(su,{worker:fe,role:dt?.roles.find(ue=>ue.role===fe.role),roles:B,tasks:a.tasks,events:u,live:ye,skew:v,staleMs:a.staleMs,onClose:A}):null]})}function Zf({o:t,params:n,loading:s,onChanged:a,onMore:r}){let o=t.runs,i=n.run||(o.find(l=>l.status==="active")??o[0])?.id;return e("div",{class:"sw-layout",children:[e("aside",{class:"sw-rail",children:[e(Xf,{o:t,onChanged:a}),e(Wf,{runs:o,selected:i,more:!!t.runsMore,loading:s,onMore:r})]}),e("section",{class:"sw-main",children:i?e(Yf,{id:i,swarms:t.swarms,onChanged:a},i):t.state==="absent"?e(zf,{o:t,onCreated:a}):e(qf,{o:t})})]})}function Iu({params:t,sub:n}){let[s,a]=x(vo),r=V(()=>J("/api/swarm",{limit:s}),[s]);U(()=>{let l=setInterval(()=>{wo()&&r.reload()},Lf);return()=>clearInterval(l)},[]);let o=r.data,i=n==="config"?"config":"runs";return e("div",{class:"page ds-page sw-page",children:[e(eu,{page:i,o}),r.error?e(Z,{error:r.error}):null,i==="config"?e(Du,{o,params:t,onChanged:r.reload}):o?e(Zf,{o,params:t,loading:r.loading,onChanged:r.reload,onMore:()=>a(l=>l+vo)}):r.error?null:e(Kf,{})]})}function Qf(){let[t,n]=x(!1),s=V(()=>t?$e("/api/doctor",{fix:!0}):J("/api/doctor"),[t]),a=(s.data??[]).filter(r=>!r.ok).length;return e(R,{children:[e("div",{class:"sy-bar",children:[e("button",{type:"button",class:"primary",onClick:()=>s.reload(),children:"Re-run"}),e("button",{type:"button",onClick:()=>{n(!0),s.reload()},children:"Run with --fix"}),s.loading?e(se,{}):s.data?a?e(I,{tone:"bad",dot:!0,children:[a," problem",a>1?"s":""]}):e(I,{tone:"ok",dot:!0,children:"all checks pass"}):null]}),s.error?e(Z,{error:s.error}):s.data?e(j,{flush:!0,title:"Checks",right:`${s.data.length-a}/${s.data.length} pass`,children:e("div",{class:"ds-table-wrap",children:e("table",{children:e("tbody",{children:s.data.map(r=>e("tr",{children:[e("td",{class:E(r.ok?"ok":"bad"),style:{width:24},children:r.ok?"\u2713":"\u2717"}),e("td",{class:"nowrap",children:r.name}),e("td",{class:"break",children:r.detail})]}))})})})}):e(j,{children:e(N,{h:14})})]})}function eb({onChanged:t}){let[n,s]=x([]),[a,r]=x(null),[o,i]=x("all"),[l,c]=x(!1),[u,d]=x(""),[p,g]=x(""),[h,y]=x("index"),[m,f]=x(""),v=V(()=>J("/api/stats"),[]),b=async(k,C)=>{r(k);let S=new Date().toLocaleTimeString();s(_=>[..._,`[${S}] ${k} \u2026`]);try{let _=await $e("/api/actions",C);s(T=>[...T,`${_.ok?"\u2713":"\u2717"} ${k} (${_.ms} ms)
|
|
95
|
+
${_.output}`]),_.ok?ee(`${k} done`):ee(_.output.split(`
|
|
96
|
+
`)[0]??"failed",!0),t()}catch(_){s(T=>[...T,`\u2717 ${k} failed: ${_.message}`]),ee(_.message,!0)}finally{r(null)}},w=({label:k,body:C,cls:S})=>e("button",{type:"button",class:S??"primary",disabled:!!a,onClick:()=>b(k,C),children:a===k?e(se,{}):k});return e(R,{children:[e("div",{class:"sy-actions",children:[e(j,{title:"Reindex",children:[e("p",{class:"sy-desc",children:"Rebuild the code graph, git signals, metrics, docs, memories or embeddings. Incremental unless full."}),e("div",{class:"row",children:[e("select",{value:o,onChange:k=>i(k.target.value),children:["all","code","git","metrics","docs","memories","embeddings"].map(k=>e("option",{value:k,children:k}))}),e("label",{class:"small",children:[e("input",{type:"checkbox",checked:l,onChange:k=>c(k.target.checked)})," ","full"]}),e(w,{label:`reindex ${o}`,body:{action:"reindex",scope:o,full:l}})]})]}),e(j,{title:"Index a path",children:[e("p",{class:"sy-desc",children:"Index files or a directory into search (markdown by default; pass globs for other files)."}),e("div",{class:"row sy-index",children:[e("input",{type:"text",class:"sy-index-path",placeholder:"docs/ or README.md",value:u,onInput:k=>d(k.target.value)}),e("input",{type:"text",class:"sy-index-globs",placeholder:"globs, comma separated",value:p,onInput:k=>g(k.target.value)}),e("button",{type:"button",class:"primary",disabled:!!a||!u.trim(),onClick:()=>b("index",{action:"index",path:u,glob:p}),children:"Index"})]})]}),e(j,{title:"Embeddings",children:[e("p",{class:"sy-desc",children:["Embed every chunk that still has no vector. Loads the model on first use."," ",v.data?e("span",{class:"muted",children:["(",v.data.index.embeddings,")"]}):null]}),e("div",{class:"row",children:e(w,{label:"embed pending",body:{action:"embed"}})})]}),e(j,{title:"Memories",children:[e("p",{class:"sy-desc",children:["Re-import memory files edited, added or removed by hand under"," ",e("code",{children:v.data?.memoriesDir??".eminiar/memories"}),"."]}),e("div",{class:"row",children:e(w,{label:"reconcile",body:{action:"reconcile"}})})]}),e(j,{title:"Purge",children:[e("p",{class:"sy-desc",children:"Permanently delete project data. Memory files stay on disk and are re-imported."}),e("div",{class:"row",children:[e("select",{value:h,onChange:k=>y(k.target.value),children:["index","sessions","graph","memories","all"].map(k=>e("option",{value:k,children:k}))}),e("input",{type:"text",placeholder:'type "purge" to confirm',style:{maxWidth:180},value:m,onInput:k=>f(k.target.value)}),e("button",{type:"button",class:"danger",disabled:!!a||m.trim()!=="purge",onClick:()=>{f(""),b(`purge ${h}`,{action:"purge",scope:h,confirm:!0})},children:"Purge"}),e(w,{label:"empty fetch cache",body:{action:"purge-fetch-cache"},cls:""})]})]}),e(j,{title:"Server",children:v.data?e(nt,{rows:[["project",v.data.project],["database",v.data.dbPath],["routing",v.data.routing]]}):e(se,{})})]}),e(j,{title:"Action log",right:e("button",{type:"button",class:"sm",onClick:()=>s([]),children:"clear"}),children:e("pre",{class:"log",children:n.length?n.join(`
|
|
91
97
|
|
|
92
|
-
`):"ready."})]})]})}function hm(){let t=X(()=>O("/api/runs"),[]);return t.error?e(W,{error:t.error}):t.data?e("div",{class:"card flush",children:e("table",{children:[e("thead",{children:e("tr",{children:[e("th",{children:"started"}),e("th",{children:"scope"}),e("th",{class:"num",children:"scanned"}),e("th",{class:"num",children:"indexed"}),e("th",{class:"num",children:"unchanged"}),e("th",{class:"num",children:"skipped"}),e("th",{class:"num",children:"removed"}),e("th",{class:"num",children:"errors"}),e("th",{class:"num",children:"ms"}),e("th",{children:"git"}),e("th",{children:"detail"})]})}),e("tbody",{children:t.data.length?t.data.map(n=>e("tr",{children:[e("td",{class:"muted nowrap",title:new Date(n.started_at).toLocaleString(),children:te(n.started_at)}),e("td",{children:n.scope}),e("td",{class:"num",children:n.scanned}),e("td",{class:"num",children:n.indexed}),e("td",{class:"num",children:n.unchanged}),e("td",{class:"num",children:n.skipped}),e("td",{class:"num",children:n.removed}),e("td",{class:A("num",n.errors>0&&"bad"),children:n.errors}),e("td",{class:"num",children:n.finished_at?n.finished_at-n.started_at:"\u2026"}),e("td",{class:"muted small",children:n.head_sha?.slice(0,7)??""}),e("td",{class:"muted small break",children:n.detail??""})]})):e("tr",{children:e("td",{colSpan:11,class:"muted",children:"no runs logged yet"})})})]})}):e(N,{})}function Xl({onChanged:t}){let[n,s]=_("actions");return e("div",{class:"page",children:[e(Re,{tabs:[["actions","Actions"],["doctor","Doctor"],["runs","Index runs"]],value:n,onChange:s}),n==="actions"&&e(mm,{onChanged:t}),n==="doctor"&&e(pm,{}),n==="runs"&&e(hm,{})]})}var pe=t=>lt(t??0),Cr=t=>new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),zl=t=>new Date(t).toISOString().slice(11,16),Gl=[["7d","7 days"],["30d","30 days"],["90d","90 days"]],gm={"7d":7,"30d":30,"90d":90};function fm({s:t}){return e("span",{class:A("tag",`sev-${t}`),children:t})}function bm({s:t}){let n=Math.max(0,Math.min(100,Math.round(t.value)));return e("div",{class:"score",children:[e("div",{class:"row tight",children:[e("b",{children:t.id}),e("span",{class:"spacer"}),e("span",{class:A(n>=70?"ok":n>=40?"warn":"bad"),children:n})]}),e("span",{class:"scorebar",children:e("i",{class:A(n>=70?"ok":n>=40?"warn":"bad"),style:{width:`${n}%`}})}),t.reasons.length?e("ul",{class:"reasons",children:t.reasons.map(s=>e("li",{children:s}))}):null]})}function Wl({items:t,empty:n}){return t.length?e("div",{class:"insights",children:t.map(s=>e("div",{class:A("insight",s.severity),children:[e("div",{class:"row tight",children:[e(fm,{s:s.severity}),e("b",{children:s.title}),e("span",{class:"spacer"}),s.estimatedSavingsUsd?e("span",{class:"muted small",children:["\u2248 ",pe(s.estimatedSavingsUsd)]}):null,e("span",{class:"muted small",children:s.scope})]}),e("div",{class:"p",children:s.reason}),s.recommendation?e("div",{class:"p muted",children:["\u2192 ",s.recommendation]}):null]}))}):e(B,{children:n})}function vm({rows:t,models:n,color:s}){let[r,a]=ut(),i=170,o={l:48,r:8,t:8,b:22},l=Math.max(10,a-o.l-o.r),c=i-o.t-o.b,d=t.length,u=d?l/d:l,p=u>=6?2:u>=3?1:0,f=Math.max(.01,...t.map(v=>v.totals.costUsd)),g=v=>o.t+c-v/f*c,[y,h]=_(null),m=Math.max(1,Math.ceil(d/Math.max(2,l/70))),b=y!==null?t[y]:void 0;return e("div",{class:"hist-chart usage-chart",ref:r,children:[e("svg",{width:a,height:i,onMouseMove:v=>{let k=v.currentTarget.getBoundingClientRect(),w=Math.floor((v.clientX-k.left-o.l)/u);h(w>=0&&w<d?w:null)},onMouseLeave:()=>h(null),children:[e("title",{children:"cost per day by model"}),[0,.5,1].map(v=>e("g",{children:[e("line",{x1:o.l,x2:a-o.r,y1:g(f*v),y2:g(f*v),class:"grid"}),e("text",{x:o.l-6,y:g(f*v)+3,class:"axis","text-anchor":"end",children:pe(f*v)})]})),t.map((v,k)=>k%m===0?e("text",{x:o.l+k*u,y:i-6,class:"axis",children:v.key.slice(5)}):null),t.map((v,k)=>{let w=0;return e("g",{opacity:y!==null&&y!==k?.55:1,children:[n.map(S=>{let E=v.models.find(M=>M.model===S)?.costUsd??0;if(!E)return null;let x=g(w+E),$=g(w);return w+=E,e("rect",{x:o.l+k*u+p/2,y:x,width:Math.max(.5,u-p),height:Math.max(0,$-x),fill:s(S),rx:u>=6?1.5:0})}),v.totals.unpricedCalls&&!v.totals.costUsd?e("rect",{x:o.l+k*u+p/2,y:o.t+c-3,width:Math.max(.5,u-p),height:3,fill:"#6b7280"}):null]})})]}),b?e("div",{class:"tip",style:{left:Math.min(a-220,o.l+y*u+10),top:4},children:[e("b",{children:b.key})," \xB7 ",b.totals.calls," calls \xB7 ",pe(b.totals.costUsd),b.totals.unpricedCalls?` \xB7 ${b.totals.unpricedCalls} unpriced`:"",e("div",{class:"row tight",style:{marginTop:4,flexWrap:"wrap"},children:b.models.map(v=>e("span",{class:"kdot-lbl",children:[e("i",{class:"kdot",style:{background:s(v.model)}}),Me(v.model)," ",pe(v.costUsd)]}))})]}):null]})}function ym({points:t,color:n}){let[s,r]=ut(),a=170,i={l:48,r:8,t:8,b:22},o=Math.max(10,r-i.l-i.r),l=a-i.t-i.b,c=t.length,d=Math.max(1e3,...t.map(m=>m.contextTokens)),u=m=>i.l+(c>1?m/(c-1)*o:o/2),p=m=>i.t+l-m/d*l,[f,g]=_(null),y=f!==null?t[f]:void 0,h=t.map((m,b)=>`${b?"L":"M"}${u(b)},${p(m.contextTokens)}`).join(" ");return e("div",{class:"hist-chart usage-chart",ref:s,children:[e("svg",{width:r,height:a,onMouseMove:m=>{let b=m.currentTarget.getBoundingClientRect(),v=m.clientX-b.left-i.l,k=c>1?Math.round(v/o*(c-1)):0;g(k>=0&&k<c?k:null)},onMouseLeave:()=>g(null),children:[e("title",{children:"context tokens per API call, with compactions"}),[0,.5,1].map(m=>e("g",{children:[e("line",{x1:i.l,x2:r-i.r,y1:p(d*m),y2:p(d*m),class:"grid"}),e("text",{x:i.l-6,y:p(d*m)+3,class:"axis","text-anchor":"end",children:q(d*m)})]})),t.map((m,b)=>m.compactBefore?e("g",{children:[e("line",{x1:u(b),x2:u(b),y1:i.t,y2:i.t+l,class:"compact"}),e("text",{x:u(b)+3,y:i.t+10,class:"axis",children:"compact"})]}):null),e("path",{d:h,class:"line"}),t.map((m,b)=>e("circle",{cx:u(b),cy:p(m.contextTokens),r:f===b?4:2.2,fill:n(m.model),class:"dot"})),c?e("text",{x:i.l,y:a-6,class:"axis",children:Cr(t[0].ts)}):null,c>1?e("text",{x:r-i.r,y:a-6,class:"axis","text-anchor":"end",children:Cr(t[c-1].ts)}):null]}),y?e("div",{class:"tip",style:{left:Math.min(r-240,u(f)+10),top:4},children:[e("b",{children:Cr(y.ts)})," \xB7 ",Me(y.model),e("div",{class:"muted",children:["context ",q(y.contextTokens)," \xB7 output ",q(y.output)," \xB7 ",pe(y.costUsd),y.compactBefore?" \xB7 compacted before this call":""]})]}):null]})}function km({rows:t,color:n}){let{sorted:s,th:r}=nt(t,"costUsd");return e("div",{class:"scroll-x",children:e("table",{children:[e("thead",{children:e("tr",{children:[r("model","model"),r("calls","calls",!0),r("costUsd","cost",!0),r("share","share",!0),r("input","in",!0),r("output","out",!0),r("cacheRead","cache rd",!0),r("cacheWrite","cache wr",!0)]})}),e("tbody",{children:s.length?s.map(a=>e("tr",{children:[e("td",{class:"nowrap",children:[e("i",{class:"kdot",style:{background:n(a.model)}})," ",Me(a.model),a.unpricedCalls?e("span",{class:"warn small",title:"no bundled price; add config.usage.pricing",children:[" ","unpriced"]}):null]}),e("td",{class:"num",children:a.calls}),e("td",{class:"num",children:pe(a.costUsd)}),e("td",{class:"num",children:Oe(a.share)}),e("td",{class:"num",children:q(a.input)}),e("td",{class:"num",children:q(a.output)}),e("td",{class:"num",children:q(a.cacheRead)}),e("td",{class:"num",children:q(a.cacheWrite)})]})):e("tr",{children:e("td",{class:"muted",colSpan:8,children:"no API calls in this range"})})})]})})}function wm({rows:t}){let n=Math.max(1,...t.map(s=>s.chars));return e("div",{class:"scroll-x",children:e("table",{children:[e("thead",{children:e("tr",{children:[e("th",{children:"tool"}),e("th",{class:"num",children:"calls"}),e("th",{class:"num",children:"est. tokens"}),e("th",{class:"num",children:"avg chars"}),e("th",{class:"num",children:"errors"}),e("th",{})]})}),e("tbody",{children:t.length?t.map(s=>e("tr",{children:[e("td",{children:s.tool}),e("td",{class:"num",children:s.calls}),e("td",{class:"num",children:q(s.estTokens)}),e("td",{class:"num",children:q(s.avgChars)}),e("td",{class:A("num",s.errors>0&&"warn"),children:s.errors}),e("td",{children:e("span",{class:"bar",style:{width:`${Math.max(2,s.chars/n*80)}px`}})})]})):e("tr",{children:e("td",{class:"muted",colSpan:6,children:"no tool results recorded"})})})]})})}function xm({rows:t,color:n}){return e("div",{class:"scroll-x",children:e("table",{children:[e("thead",{children:e("tr",{children:[e("th",{children:"block (UTC)"}),e("th",{children:"calls at (UTC)"}),e("th",{class:"num",children:"calls"}),e("th",{class:"num",children:"cost"}),e("th",{class:"num",children:"tokens"}),e("th",{children:"models"})]})}),e("tbody",{children:t.length?t.map(s=>e("tr",{children:[e("td",{class:"nowrap",children:[s.id.slice(0,16).replace("T"," ")," ",s.active?e(P,{children:"active"}):null]}),e("td",{class:"nowrap muted",children:[zl(s.firstCall),"\u2013",zl(s.lastCall)]}),e("td",{class:"num",children:s.calls}),e("td",{class:"num",children:pe(s.costUsd)}),e("td",{class:"num",children:q(s.tokens.input+s.tokens.output+s.tokens.cacheCreate+s.tokens.cacheRead)}),e("td",{children:s.models.map(r=>e("span",{class:"kdot-lbl",children:[e("i",{class:"kdot",style:{background:n(r)}}),Me(r)]}))})]})):e("tr",{children:e("td",{class:"muted",colSpan:6,children:"no blocks in this range"})})})]})})}function ql({params:t}){let n=Gl.find(([m])=>m===t.range)?.[0]??"30d",[s,r]=_(t.session??null);J(()=>{r(t.session??null)},[t.session]);let a=X(async()=>{let m=$=>O("/api/usage",{view:$,since:n,limit:30}),[b,v,k,w,S,E,x]=await Promise.all([m("summary"),m("daily"),m("models"),m("blocks"),m("tools"),m("sessions"),m("insights")]);return{summary:b,daily:v,models:k,blocks:w,tools:S,sessions:E,insights:x}},[n]);J(()=>{let m=a.data;if(s||!m)return;let v=m.sessions.rows.find(k=>k.session===m.summary.sessionId)??m.sessions.rows[0];v&&r(v.session)},[a.data,s]);let i=X(()=>s?O("/api/usage/session",{id:s}):Promise.resolve(void 0),[s]),o=Z(()=>{let m=new Map;for(let b of a.data?.daily.rows??[])for(let v of b.models)m.set(v.model,(m.get(v.model)??0)+v.costUsd);return[...m.entries()].sort((b,v)=>v[1]-b[1]).map(([b])=>b)},[a.data]),l=Z(()=>Ai(a.data?.daily.rows??[],gm[n]??30),[a.data,n]),c=Z(()=>{let m=a.data,b=[...o,...m?.models.rows.map(v=>v.model)??[],...m?.blocks.rows.flatMap(v=>v.models)??[],...i.data?.timeline.map(v=>v.model)??[]];return Ci(b)},[a.data,o,i.data]),d=m=>c.get(m)??Ti(m);if(a.error)return e("div",{class:"page",children:e(W,{error:a.error})});let u=a.data;if(!u)return e("div",{class:"page",children:e(N,{})});let p=u.summary,f=p.snapshot,g=i.data?.totals,y=[["today",pe(p.today.costUsd),`${p.today.calls} calls \xB7 ${Oe(p.today.cacheHitRate)} cache hits`],["last 7 days",pe(p.last7d.costUsd),`${p.last7d.calls} calls \xB7 30d ${pe(p.last30d.costUsd)}`],["session",pe(g?.costUsd??0),s?`${s.slice(0,8)} \xB7 ${g?.calls??0} calls`:"no session selected"],["cache hit rate",Oe(p.cache.hitRate),`${q(p.cache.cacheReads)} read \xB7 ${q(p.cache.cacheWrites)} written \xB7 ${p.cache.coldCalls} cold`],["burn rate",p.block?p.burn.reliable?`${pe(p.burn.usdPerHour)}/h`:"n/a":"idle",p.block?p.burn.reliable?`block ${pe(p.block.costUsd)} \u2192 ${pe(p.burn.projectedBlockUsd)} projected`:`block ${pe(p.block.costUsd)} \xB7 too few calls or minutes to project`:"no calls in the current 5-hour block"],["plan use",f&&f.five_hour_pct!=null?f.seven_day_pct!=null?`${f.five_hour_pct}% \xB7 ${f.seven_day_pct}%`:`${f.five_hour_pct}%`:"n/a",f&&f.five_hour_pct!=null?`${f.seven_day_pct!=null?"5h \xB7 7d windows":"5h window"}${f.ctx_used_pct!=null?` \xB7 ctx ${f.ctx_used_pct}%`:""} \xB7 ${te(f.ts)}`:"statusline snapshots carry plan limits for subscribers"]],h=(m,b=n)=>U("usage",{session:m??void 0,range:b});return e("div",{class:"page",children:[p.enabled?null:e("div",{class:"empty warn",children:"usage ingest is off (config.usage.enabled = false)"}),e("div",{class:"row",style:{marginBottom:10},children:[e(Re,{tabs:Gl,value:n,onChange:m=>h(s,m)}),e("span",{class:"spacer"}),e("span",{class:"muted small",children:[p.totals.calls," calls \xB7 ",pe(p.totals.costUsd)," in range",p.totals.unpricedCalls?e("span",{class:"warn",children:[" ","\xB7 ",p.totals.unpricedCalls," unpriced (see config.usage.pricing)"]}):null," \xB7 estimates at list price"]})]}),e("div",{class:"grid",children:y.map(([m,b,v])=>e("div",{class:"card",children:[e("h3",{children:m}),e("div",{class:"big",children:b}),e("div",{class:"sub",children:v})]}))}),e("div",{class:"grid wide",children:[e("div",{class:"card",children:[e("h3",{children:["cost per day by model",e("span",{class:"right usage-legend",children:o.map(m=>e("span",{class:"kdot-lbl",children:[e("i",{class:"kdot",style:{background:d(m)}}),Me(m)]}))})]}),u.daily.rows.length?e(vm,{rows:l,models:o,color:d}):e(B,{children:"no API calls in this range"})]}),e("div",{class:"card",children:[e("h3",{children:"scores"}),p.scores.length?p.scores.map(m=>e(bm,{s:m})):e(B,{children:"no scores yet"})]})]}),e("div",{class:"grid wide",children:[e("div",{class:"card",children:[e("h3",{children:["context timeline",e("span",{class:"right",children:e("select",{value:s??"",onChange:m=>h(m.target.value||null),children:[s?null:e("option",{value:"",children:"pick a session"}),u.sessions.rows.map(m=>e("option",{value:m.session,children:[m.session.slice(0,8)," \xB7 ",te(m.lastCall)," \xB7 ",pe(m.totals.costUsd),m.session===p.sessionId?" \xB7 current":""]})),s&&!u.sessions.rows.some(m=>m.session===s)?e("option",{value:s,children:s.slice(0,8)}):null]})})]}),i.error?e(W,{error:i.error}):i.data?.timeline.length?e(j,{children:[e(ym,{points:i.data.timeline,color:d}),e("div",{class:"muted small",children:[i.data.timeline.length," calls \xB7 ",i.data.contextEvents.length," compaction",i.data.contextEvents.length===1?"":"s"," \xB7"," ",pe(i.data.totals.costUsd)," \xB7 ",Oe(i.data.totals.cacheHitRate)," cache hits \xB7 times local"]})]}):s?e(B,{children:i.loading?e(N,{}):"no API calls recorded for this session"}):e(B,{children:"no sessions with API calls yet"})]}),e("div",{class:"card",children:[e("h3",{children:"session insights"}),e(Wl,{items:i.data?.insights.filter(m=>m.scope==="session")??[],empty:s?"nothing to flag in this session":"pick a session"})]})]}),e("div",{class:"grid two",children:[e("div",{class:"card",children:[e("h3",{children:"models"}),e(km,{rows:u.models.rows,color:d})]}),e("div",{class:"card",children:[e("h3",{children:["tool results in context",e("span",{class:"right",children:[q(Math.ceil(u.tools.totalChars/4))," est. tokens"]})]}),e(wm,{rows:u.tools.rows})]})]}),e("div",{class:"grid two",children:[e("div",{class:"card",children:[e("h3",{children:["insights ",e("span",{class:"right",children:u.insights.insights.length})]}),e(Wl,{items:u.insights.insights,empty:"nothing to flag in this range"})]}),e("div",{class:"card",children:[e("h3",{children:"eminiar savings"}),e("div",{class:"row",style:{gap:24,marginBottom:8},children:[e("div",{children:[e("div",{class:"big",children:pe(p.savings.directUsd)}),e("div",{class:"sub",children:["direct \xB7 ",q(p.savings.savedTokens)," tokens never written to cache"]})]}),e("div",{children:[e("div",{class:"big",children:pe(p.savings.compoundingUsd)}),e("div",{class:"sub",children:["compounding \xB7 re-read on ",p.savings.laterCallsPerSession.toFixed(1)," later calls per session"]})]})]}),e("ul",{class:"reasons",children:p.savings.assumptions.map(m=>e("li",{children:m}))})]})]}),e("div",{class:"grid",children:e("div",{class:"card",style:{gridColumn:"1 / -1"},children:[e("h3",{children:["5-hour billing blocks",u.blocks.rows.some(m=>m.active)?e("span",{class:"right",children:u.blocks.burn.reliable?`${pe(u.blocks.burn.usdPerHour)}/h \xB7 ${q(Math.round(u.blocks.burn.tokensPerMin))} tok/min`:"burn rate n/a"}):null]}),e(xm,{rows:u.blocks.rows,color:d})]})})]})}var _m=[["overview","Overview"],["usage","Usage"],["explore","Explore"],["galaxy","Galaxy"],["architecture","Architecture"],["history","History"],["memory","Memory"],["docs","Docs"],["coverage","Coverage"],["sessions","Sessions"],["swarm","Swarms"],["adjudicator","Adjudicator"],["system","System"]],Sm=new Set(["explore","galaxy"]);function Em(){try{let t=localStorage.getItem("eminiar.theme");return t==="light"||t==="dark"?t:"auto"}catch{return"auto"}}function $m(t){t==="auto"?document.documentElement.removeAttribute("data-theme"):document.documentElement.setAttribute("data-theme",t);try{t==="auto"?localStorage.removeItem("eminiar.theme"):localStorage.setItem("eminiar.theme",t)}catch{}}function Kl(){let t=va(),[n,s]=_(Em),[r,a]=_(0),[i,o]=_(Ss),l=g=>{oa(g),o(g)},c=X(()=>O("/api/projects"),[r]),d=X(()=>O("/api/status"),[t.view,r,i]);J(()=>{c.data&&!Ss()&&l(c.data.current)},[c.data]),J(()=>{let g=setInterval(()=>a(y=>y+1),45e3);return()=>clearInterval(g)},[]);let u=[...new Set([c.data?.current,...c.data?.projects.map(g=>g.root)??[]].filter(Boolean))],p=d.data,f=t.view;return e(j,{children:[e("header",{class:"top",children:[e("div",{class:"brand",children:[e("span",{children:"em"}),"iniar",e("small",{children:p?.version?`v${p.version}`:""})]}),e("nav",{class:"tabs",children:_m.map(([g,y])=>e("button",{type:"button",class:A(f===g&&"active"),onClick:()=>U(g),children:y}))}),e("span",{class:"spacer"}),e("span",{class:"small nowrap",title:p?`${p.graph.nodes} nodes \xB7 ${p.freshness.dirty.length} changed \xB7 ${p.freshness.queued} queued`:"",children:[e("i",{class:A("dot",p?.state)}),p?p.state==="empty"?"no graph":p.state==="stale"?"index stale":"index fresh":"\u2026"]}),e("button",{type:"button",class:"ghost sm",title:"theme",onClick:()=>{let g=n==="auto"?"dark":n==="dark"?"light":"auto";s(g),$m(g)},children:n==="auto"?"\u25D0 auto":n==="dark"?"\u25CF dark":"\u25CB light"}),e("select",{class:"project",title:i,value:i,onChange:g=>{l(g.target.value),a(y=>y+1)},children:u.map(g=>e("option",{value:g,children:g.split("/").slice(-2).join("/")}))})]}),e("main",{class:A("work",Sm.has(f)&&"fill"),children:[f==="overview"&&e(xl,{}),f==="usage"&&e(ql,{params:t.params}),f==="explore"&&e(No,{params:t.params}),f==="galaxy"&&e(Uo,{params:t.params}),f==="architecture"&&e(So,{params:t.params}),f==="history"&&e(Wo,{params:t.params}),f==="memory"&&e(kl,{params:t.params}),f==="docs"&&e(Io,{params:t.params}),f==="coverage"&&e(Eo,{}),f==="sessions"&&e(_l,{}),f==="swarm"&&e(Jl,{params:t.params}),f==="adjudicator"&&e(Ni,{params:t.params}),f==="system"&&e(Xl,{onChanged:()=>a(g=>g+1)})]},i),e("footer",{class:"status",children:[e("span",{children:["server ",e("b",{class:"ok",children:"ready"})]}),p&&e(j,{children:[e("span",{children:[e("b",{children:p.graph.nodes})," nodes \xB7 ",e("b",{children:p.graph.edges})," edges"]}),e("span",{children:["files: ",e("b",{children:p.files.byStatus.indexed??0})," indexed",p.files.byStatus.partial?` \xB7 ${p.files.byStatus.partial} partial`:"",p.files.byStatus.skipped?` \xB7 ${p.files.byStatus.skipped} skipped`:""]}),e("span",{children:["git ",p.freshness.head?.slice(0,7)??"n/a",p.freshness.indexedHead&&p.freshness.indexedHead!==p.freshness.head?` (signals at ${p.freshness.indexedHead.slice(0,7)})`:""]}),e("span",{children:["last index ",p.freshness.lastRun?te(p.freshness.lastRun):"never"]})]}),e("span",{class:"spacer"}),e("span",{class:"ellipsis",children:i})]}),e(ga,{})]})}var Vl=document.getElementById("app");Vl&&Kr(e(Kl,{}),Vl);})();
|
|
98
|
+
`):"ready."})})]})}function tb(){let t=V(()=>J("/api/runs"),[]);return t.error?e(Z,{error:t.error}):t.data?e(j,{flush:!0,title:"Index runs",right:t.data.length,children:e("div",{class:"ds-table-wrap",children:e("table",{children:[e("thead",{children:e("tr",{children:[e("th",{children:"started"}),e("th",{children:"scope"}),e("th",{class:"num",children:"scanned"}),e("th",{class:"num",children:"indexed"}),e("th",{class:"num",children:"unchanged"}),e("th",{class:"num",children:"skipped"}),e("th",{class:"num",children:"removed"}),e("th",{class:"num",children:"errors"}),e("th",{class:"num",children:"ms"}),e("th",{children:"git"}),e("th",{children:"detail"})]})}),e("tbody",{children:t.data.length?t.data.map(n=>e("tr",{children:[e("td",{class:"muted nowrap",title:new Date(n.started_at).toLocaleString(),children:me(n.started_at)}),e("td",{children:n.scope}),e("td",{class:"num",children:n.scanned}),e("td",{class:"num",children:n.indexed}),e("td",{class:"num",children:n.unchanged}),e("td",{class:"num",children:n.skipped}),e("td",{class:"num",children:n.removed}),e("td",{class:E("num",n.errors>0&&"bad"),children:n.errors}),e("td",{class:"num",children:n.finished_at?n.finished_at-n.started_at:"\u2026"}),e("td",{class:"muted small",children:n.head_sha?.slice(0,7)??""}),e("td",{class:"muted small break",children:n.detail??""})]})):e("tr",{children:e("td",{colSpan:11,children:e(X,{compact:!0,icon:"\u25CB",title:"No runs logged yet"})})})})]})})}):e(se,{})}var nb={actions:"Rebuild indexes, embed, reconcile memories and purge project data.",doctor:"Check that eminiar's runtime dependencies and storage are healthy.",runs:"Every indexing pass, newest first."};function Fu({onChanged:t}){let[n,s]=x("actions");return e("div",{class:"page ds-page",children:[e(Te,{eyebrow:"System",title:"Maintenance",sub:nb[n],aside:e(Se,{label:"system section",options:[{id:"actions",label:"Actions"},{id:"doctor",label:"Doctor"},{id:"runs",label:"Index runs"}],value:n,onChange:s})}),n==="actions"&&e(eb,{onChanged:t}),n==="doctor"&&e(Qf,{}),n==="runs"&&e(tb,{})]})}var De=t=>Yt(t??0),ko=t=>new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),Ou=t=>new Date(t).toISOString().slice(11,16),Nu=[["7d","7 days"],["30d","30 days"],["90d","90 days"]],sb={"7d":"7 days","30d":"30 days","90d":"90 days"},rb={"7d":7,"30d":30,"90d":90},ab={info:"accent",warn:"warn",high:"bad"};function ob({s:t}){return e(I,{tone:ab[t],children:t})}function ib({s:t}){let n=Math.max(0,Math.min(100,Math.round(t.value)));return e("div",{class:"score",children:[e("div",{class:"row tight",children:[e("b",{children:t.id}),e("span",{class:"spacer"}),e("span",{class:E(n>=70?"ok":n>=40?"warn":"bad"),children:n})]}),e("span",{class:"scorebar",children:e("i",{class:E(n>=70?"ok":n>=40?"warn":"bad"),style:{width:`${n}%`}})}),t.reasons.length?e("ul",{class:"reasons",children:t.reasons.map(s=>e("li",{children:s}))}):null]})}function Bu({items:t,empty:n}){return t.length?e("div",{class:"insights",children:t.map(s=>e("div",{class:E("insight",s.severity),children:[e("div",{class:"row tight",children:[e(ob,{s:s.severity}),e("b",{children:s.title}),e("span",{class:"spacer"}),s.estimatedSavingsUsd?e("span",{class:"muted small",children:["\u2248 ",De(s.estimatedSavingsUsd)]}):null,e("span",{class:"muted small",children:s.scope})]}),e("div",{class:"p",children:s.reason}),s.recommendation?e("div",{class:"p muted",children:["\u2192 ",s.recommendation]}):null]}))}):e(X,{compact:!0,title:n})}function lb({rows:t,models:n,color:s}){let[a,r]=en(),o=170,i={l:48,r:8,t:8,b:22},l=Math.max(10,r-i.l-i.r),c=o-i.t-i.b,u=t.length,d=u?l/u:l,p=d>=6?2:d>=3?1:0,g=Math.max(.01,...t.map(b=>b.totals.costUsd)),h=b=>i.t+c-b/g*c,[y,m]=x(null),f=Math.max(1,Math.ceil(u/Math.max(2,l/70))),v=y!==null?t[y]:void 0;return e("div",{class:"hist-chart usage-chart",ref:a,children:[e("svg",{width:r,height:o,onMouseMove:b=>{let w=b.currentTarget.getBoundingClientRect(),k=Math.floor((b.clientX-w.left-i.l)/d);m(k>=0&&k<u?k:null)},onMouseLeave:()=>m(null),children:[e("title",{children:"cost per day by model"}),[0,.5,1].map(b=>e("g",{children:[e("line",{x1:i.l,x2:r-i.r,y1:h(g*b),y2:h(g*b),class:"grid"}),e("text",{x:i.l-6,y:h(g*b)+3,class:"axis","text-anchor":"end",children:De(g*b)})]})),t.map((b,w)=>w%f===0?e("text",{x:i.l+w*d,y:o-6,class:"axis",children:b.key.slice(5)}):null),t.map((b,w)=>{let k=0;return e("g",{opacity:y!==null&&y!==w?.55:1,children:[n.map(C=>{let S=b.models.find(M=>M.model===C)?.costUsd??0;if(!S)return null;let _=h(k+S),T=h(k);return k+=S,e("rect",{x:i.l+w*d+p/2,y:_,width:Math.max(.5,d-p),height:Math.max(0,T-_),fill:s(C),rx:d>=6?1.5:0})}),b.totals.unpricedCalls&&!b.totals.costUsd?e("rect",{x:i.l+w*d+p/2,y:i.t+c-3,width:Math.max(.5,d-p),height:3,fill:"#6b7280"}):null]})})]}),v?e("div",{class:"tip",style:{left:Math.min(r-220,i.l+y*d+10),top:4},children:[e("b",{children:v.key})," \xB7 ",v.totals.calls," calls \xB7 ",De(v.totals.costUsd),v.totals.unpricedCalls?` \xB7 ${v.totals.unpricedCalls} unpriced`:"",e("div",{class:"row tight",style:{marginTop:4,flexWrap:"wrap"},children:v.models.map(b=>e("span",{class:"kdot-lbl",children:[e("i",{class:"kdot",style:{background:s(b.model)}}),lt(b.model)," ",De(b.costUsd)]}))})]}):null]})}function cb({points:t,color:n}){let[s,a]=en(),r=170,o={l:48,r:8,t:8,b:22},i=Math.max(10,a-o.l-o.r),l=r-o.t-o.b,c=t.length,u=Math.max(1e3,...t.map(f=>f.contextTokens)),d=f=>o.l+(c>1?f/(c-1)*i:i/2),p=f=>o.t+l-f/u*l,[g,h]=x(null),y=g!==null?t[g]:void 0,m=t.map((f,v)=>`${v?"L":"M"}${d(v)},${p(f.contextTokens)}`).join(" ");return e("div",{class:"hist-chart usage-chart",ref:s,children:[e("svg",{width:a,height:r,onMouseMove:f=>{let v=f.currentTarget.getBoundingClientRect(),b=f.clientX-v.left-o.l,w=c>1?Math.round(b/i*(c-1)):0;h(w>=0&&w<c?w:null)},onMouseLeave:()=>h(null),children:[e("title",{children:"context tokens per API call, with compactions"}),[0,.5,1].map(f=>e("g",{children:[e("line",{x1:o.l,x2:a-o.r,y1:p(u*f),y2:p(u*f),class:"grid"}),e("text",{x:o.l-6,y:p(u*f)+3,class:"axis","text-anchor":"end",children:z(u*f)})]})),t.map((f,v)=>f.compactBefore?e("g",{children:[e("line",{x1:d(v),x2:d(v),y1:o.t,y2:o.t+l,class:"compact"}),e("text",{x:d(v)+3,y:o.t+10,class:"axis",children:"compact"})]}):null),e("path",{d:m,class:"line"}),t.map((f,v)=>e("circle",{cx:d(v),cy:p(f.contextTokens),r:g===v?4:2.2,fill:n(f.model),class:"dot"})),c?e("text",{x:o.l,y:r-6,class:"axis",children:ko(t[0].ts)}):null,c>1?e("text",{x:a-o.r,y:r-6,class:"axis","text-anchor":"end",children:ko(t[c-1].ts)}):null]}),y?e("div",{class:"tip",style:{left:Math.min(a-240,d(g)+10),top:4},children:[e("b",{children:ko(y.ts)})," \xB7 ",lt(y.model),e("div",{class:"muted",children:["context ",z(y.contextTokens)," \xB7 output ",z(y.output)," \xB7 ",De(y.costUsd),y.compactBefore?" \xB7 compacted before this call":""]})]}):null]})}function db({rows:t,color:n}){let{sorted:s,th:a}=Ot(t,"costUsd");return e("div",{class:"ds-table-wrap",children:e("table",{children:[e("thead",{children:e("tr",{children:[a("model","model"),a("calls","calls",!0),a("costUsd","cost",!0),a("share","share",!0),a("input","in",!0),a("output","out",!0),a("cacheRead","cache rd",!0),a("cacheWrite","cache wr",!0)]})}),e("tbody",{children:s.length?s.map(r=>e("tr",{children:[e("td",{class:"nowrap",children:[e("i",{class:"kdot",style:{background:n(r.model)}})," ",lt(r.model),r.unpricedCalls?e("span",{class:"warn small",title:"no bundled price; add config.usage.pricing",children:[" ","unpriced"]}):null]}),e("td",{class:"num",children:r.calls}),e("td",{class:"num",children:De(r.costUsd)}),e("td",{class:"num",children:tt(r.share)}),e("td",{class:"num",children:z(r.input)}),e("td",{class:"num",children:z(r.output)}),e("td",{class:"num",children:z(r.cacheRead)}),e("td",{class:"num",children:z(r.cacheWrite)})]})):e("tr",{children:e("td",{class:"muted",colSpan:8,children:"no API calls in this range"})})})]})})}function ub({rows:t}){let n=Math.max(1,...t.map(s=>s.chars));return e("div",{class:"ds-table-wrap",children:e("table",{children:[e("thead",{children:e("tr",{children:[e("th",{children:"tool"}),e("th",{class:"num",children:"calls"}),e("th",{class:"num",children:"est. tokens"}),e("th",{class:"num",children:"avg chars"}),e("th",{class:"num",children:"errors"}),e("th",{})]})}),e("tbody",{children:t.length?t.map(s=>e("tr",{children:[e("td",{children:s.tool}),e("td",{class:"num",children:s.calls}),e("td",{class:"num",children:z(s.estTokens)}),e("td",{class:"num",children:z(s.avgChars)}),e("td",{class:E("num",s.errors>0&&"warn"),children:s.errors}),e("td",{children:e("span",{class:"bar",style:{width:`${Math.max(2,s.chars/n*80)}px`}})})]})):e("tr",{children:e("td",{class:"muted",colSpan:6,children:"no tool results recorded"})})})]})})}function pb({rows:t,color:n}){return e("div",{class:"ds-table-wrap",children:e("table",{children:[e("thead",{children:e("tr",{children:[e("th",{children:"block (UTC)"}),e("th",{children:"calls at (UTC)"}),e("th",{class:"num",children:"calls"}),e("th",{class:"num",children:"cost"}),e("th",{class:"num",children:"tokens"}),e("th",{children:"models"})]})}),e("tbody",{children:t.length?t.map(s=>e("tr",{children:[e("td",{class:"nowrap",children:[s.id.slice(0,16).replace("T"," ")," ",s.active?e(I,{tone:"accent",children:"active"}):null]}),e("td",{class:"nowrap muted",children:[Ou(s.firstCall),"\u2013",Ou(s.lastCall)]}),e("td",{class:"num",children:s.calls}),e("td",{class:"num",children:De(s.costUsd)}),e("td",{class:"num",children:z(s.tokens.input+s.tokens.output+s.tokens.cacheCreate+s.tokens.cacheRead)}),e("td",{children:s.models.map(a=>e("span",{class:"kdot-lbl",children:[e("i",{class:"kdot",style:{background:n(a)}}),lt(a)]}))})]})):e("tr",{children:e("td",{class:"muted",colSpan:6,children:"no blocks in this range"})})})]})})}function Hu({params:t}){let n=Nu.find(([f])=>f===t.range)?.[0]??"30d",[s,a]=x(t.session??null);U(()=>{a(t.session??null)},[t.session]);let r=V(async()=>{let f=T=>J("/api/usage",{view:T,since:n,limit:30}),[v,b,w,k,C,S,_]=await Promise.all([f("summary"),f("daily"),f("models"),f("blocks"),f("tools"),f("sessions"),f("insights")]);return{summary:v,daily:b,models:w,blocks:k,tools:C,sessions:S,insights:_}},[n]);U(()=>{let f=r.data;if(s||!f)return;let b=f.sessions.rows.find(w=>w.session===f.summary.sessionId)??f.sessions.rows[0];b&&a(b.session)},[r.data,s]);let o=V(()=>s?J("/api/usage/session",{id:s}):Promise.resolve(void 0),[s]),i=ae(()=>{let f=new Map;for(let v of r.data?.daily.rows??[])for(let b of v.models)f.set(b.model,(f.get(b.model)??0)+b.costUsd);return[...f.entries()].sort((v,b)=>b[1]-v[1]).map(([v])=>v)},[r.data]),l=ae(()=>jl(r.data?.daily.rows??[],rb[n]??30),[r.data,n]),c=ae(()=>{let f=r.data,v=[...i,...f?.models.rows.map(b=>b.model)??[],...f?.blocks.rows.flatMap(b=>b.models)??[],...o.data?.timeline.map(b=>b.model)??[]];return Ll(v)},[r.data,i,o.data]),u=f=>c.get(f)??Dl(f);if(r.error)return e("div",{class:"page ds-page",children:e(Z,{error:r.error})});let d=r.data;if(!d)return e("div",{class:"page ds-page",role:"status","aria-busy":"true",children:[e(Te,{title:e(N,{w:"min(320px, 70%)",h:34}),sub:e(N,{w:220,h:14})}),e(Re,{children:[0,1,2,3,4,5].map(f=>e("div",{class:"ds-stat",children:[e(N,{w:80,h:11}),e(N,{w:100,h:28}),e(N,{w:130,h:11})]},f))})]});let p=d.summary,g=p.snapshot,h=o.data?.totals,y=g&&g.five_hour_pct!=null?g.seven_day_pct!=null?`${g.five_hour_pct}% \xB7 ${g.seven_day_pct}%`:`${g.five_hour_pct}%`:"n/a",m=(f,v=n)=>H("usage",{session:f??void 0,range:v});return e("div",{class:"page ds-page us-page",children:[e(Te,{eyebrow:"Usage",title:e(R,{children:[De(p.totals.costUsd)," ",e("span",{class:"us-hero-unit",children:["in ",sb[n]]})]}),sub:`${p.totals.calls} API calls \xB7 estimates at list price`,meta:e(R,{children:[p.enabled?null:e(I,{tone:"warn",children:"usage ingest is off (config.usage.enabled = false)"}),p.totals.unpricedCalls?e(I,{tone:"warn",title:"see config.usage.pricing",children:[p.totals.unpricedCalls," unpriced"]}):null]}),aside:e(Se,{label:"range",options:Nu.map(([f,v])=>({id:f,label:v})),value:n,onChange:f=>m(s,f)})}),e(Re,{children:[e(le,{label:"today",value:De(p.today.costUsd),sub:`${p.today.calls} calls \xB7 ${tt(p.today.cacheHitRate)} cache hits`}),e(le,{label:"last 7 days",value:De(p.last7d.costUsd),sub:`${p.last7d.calls} calls \xB7 30d ${De(p.last30d.costUsd)}`}),e(le,{label:"session",value:De(h?.costUsd??0),sub:s?`${s.slice(0,8)} \xB7 ${h?.calls??0} calls`:"no session selected"}),e(le,{label:"cache hit rate",value:tt(p.cache.hitRate),sub:`${z(p.cache.cacheReads)} read \xB7 ${z(p.cache.cacheWrites)} written \xB7 ${p.cache.coldCalls} cold`}),e(le,{label:"burn rate",value:p.block?p.burn.reliable?`${De(p.burn.usdPerHour)}/h`:"n/a":"idle",sub:p.block?p.burn.reliable?`block ${De(p.block.costUsd)} \u2192 ${De(p.burn.projectedBlockUsd)} projected`:`block ${De(p.block.costUsd)} \xB7 too few calls or minutes to project`:"no calls in the current 5-hour block"}),e(le,{label:"plan use",value:y,sub:g&&g.five_hour_pct!=null?`${g.seven_day_pct!=null?"5h \xB7 7d windows":"5h window"}${g.ctx_used_pct!=null?` \xB7 ctx ${g.ctx_used_pct}%`:""} \xB7 ${me(g.ts)}`:"statusline snapshots carry plan limits for subscribers"})]}),e("div",{class:"ds-grid main-side",children:[e(j,{title:"Cost per day by model",right:e("span",{class:"usage-legend",children:i.map(f=>e("span",{class:"kdot-lbl",children:[e("i",{class:"kdot",style:{background:u(f)}}),lt(f)]}))}),children:d.daily.rows.length?e(lb,{rows:l,models:i,color:u}):e(X,{compact:!0,icon:"\u2581",title:"No API calls in this range"})}),e(j,{title:"Scores",children:p.scores.length?p.scores.map(f=>e(ib,{s:f})):e(X,{compact:!0,title:"No scores yet"})})]}),e("div",{class:"ds-grid main-side",children:[e(j,{title:"Context timeline",right:e("select",{"aria-label":"session",value:s??"",onChange:f=>m(f.target.value||null),children:[s?null:e("option",{value:"",children:"pick a session"}),d.sessions.rows.map(f=>e("option",{value:f.session,children:[f.session.slice(0,8)," \xB7 ",me(f.lastCall)," \xB7 ",De(f.totals.costUsd),f.session===p.sessionId?" \xB7 current":""]})),s&&!d.sessions.rows.some(f=>f.session===s)?e("option",{value:s,children:s.slice(0,8)}):null]}),children:o.error?e(Z,{error:o.error}):o.data?.timeline.length?e(R,{children:[e(cb,{points:o.data.timeline,color:u}),e("div",{class:"muted small",children:[o.data.timeline.length," calls \xB7 ",o.data.contextEvents.length," compaction",o.data.contextEvents.length===1?"":"s"," \xB7"," ",De(o.data.totals.costUsd)," \xB7 ",tt(o.data.totals.cacheHitRate)," cache hits \xB7 times local"]})]}):s?o.loading?e(N,{h:170}):e(X,{compact:!0,title:"No API calls recorded for this session"}):e(X,{compact:!0,title:"No sessions with API calls yet"})}),e(j,{title:"Session insights",children:e(Bu,{items:o.data?.insights.filter(f=>f.scope==="session")??[],empty:s?"Nothing to flag in this session":"Pick a session"})})]}),e("div",{class:"ds-grid cols-2",children:[e(j,{flush:!0,title:"Models",children:e(db,{rows:d.models.rows,color:u})}),e(j,{flush:!0,title:"Tool results in context",right:`${z(Math.ceil(d.tools.totalChars/4))} est. tokens`,children:e(ub,{rows:d.tools.rows})})]}),e("div",{class:"ds-grid cols-2",children:[e(j,{title:"Insights",right:d.insights.insights.length,children:e(Bu,{items:d.insights.insights,empty:"Nothing to flag in this range"})}),e(j,{title:"eminiar savings",children:[e("div",{class:"us-savings",children:[e("div",{children:[e("div",{class:"us-big",children:De(p.savings.directUsd)}),e("div",{class:"muted small",children:["direct \xB7 ",z(p.savings.savedTokens)," tokens never written to cache"]})]}),e("div",{children:[e("div",{class:"us-big",children:De(p.savings.compoundingUsd)}),e("div",{class:"muted small",children:["compounding \xB7 re-read on ",p.savings.laterCallsPerSession.toFixed(1)," later calls per session"]})]})]}),e("ul",{class:"reasons",children:p.savings.assumptions.map(f=>e("li",{children:f}))})]})]}),e(j,{flush:!0,title:"5-hour billing blocks",right:d.blocks.rows.some(f=>f.active)?d.blocks.burn.reliable?`${De(d.blocks.burn.usdPerHour)}/h \xB7 ${z(Math.round(d.blocks.burn.tokensPerMin))} tok/min`:"burn rate n/a":void 0,children:e(pb,{rows:d.blocks.rows,color:u})})]})}var mb=[["overview","Overview"],["usage","Usage"],["explore","Explore"],["galaxy","Galaxy"],["history","History"],["memory","Memory"],["docs","Docs"],["coverage","Coverage"],["sessions","Sessions"],["swarm","Swarms"],["adjudicator","Adjudicator"],["system","System"]],gb=new Set(["explore","galaxy"]);function hb(){try{let t=localStorage.getItem("eminiar.theme");return t==="light"||t==="dark"?t:"auto"}catch{return"auto"}}function fb(t){t==="auto"?document.documentElement.removeAttribute("data-theme"):document.documentElement.setAttribute("data-theme",t);try{t==="auto"?localStorage.removeItem("eminiar.theme"):localStorage.setItem("eminiar.theme",t)}catch{}}function Uu(){let t=_i(),[n,s]=x(hb),[a,r]=x(0),[o,i]=x(Gr),l=h=>{Wr(h),i(h)};U(()=>{let h=ki(new URLSearchParams(location.search).get("root"),o,Zr);h.kind==="switch"?(l(h.root),r(y=>y+1)):h.kind==="restore"&&Wr(h.root)},[t]);let c=V(()=>J("/api/projects"),[a]),u=V(()=>J("/api/status"),[t.view,a,o]);U(()=>{c.data&&!Gr()&&l(c.data.current)},[c.data]),U(()=>{let h=setInterval(()=>r(y=>y+1),45e3);return()=>clearInterval(h)},[]);let d=[...new Set([c.data?.current,...c.data?.projects.map(h=>h.root)??[]].filter(Boolean))],p=u.data,g=t.view;return e(R,{children:[e("header",{class:"top",children:[e("div",{class:"brand",children:[e("span",{children:"em"}),"iniar",e("small",{children:p?.version?`v${p.version}`:""})]}),e("nav",{class:"tabs",children:mb.map(([h,y])=>e("button",{type:"button",class:E(g===h&&"active"),onClick:()=>H(h),children:y}))}),e("span",{class:"spacer"}),e("span",{class:"small nowrap",title:p?`${p.graph.nodes} nodes \xB7 ${p.freshness.dirty.length} changed \xB7 ${p.freshness.queued} queued`:"",children:[e("i",{class:E("dot",p?.state)}),p?p.state==="empty"?"no graph":p.state==="stale"?"index stale":"index fresh":"\u2026"]}),e("button",{type:"button",class:"ghost sm",title:"theme",onClick:()=>{let h=n==="auto"?"dark":n==="dark"?"light":"auto";s(h),fb(h)},children:n==="auto"?"\u25D0 auto":n==="dark"?"\u25CF dark":"\u25CB light"}),e("select",{class:"project",title:o,value:o,onChange:h=>{let y=h.target;if(!Zr()){y.value=o;return}l(y.value),r(m=>m+1)},children:d.map(h=>e("option",{value:h,children:h.split("/").slice(-2).join("/")}))})]}),e("main",{class:E("work",gb.has(g)&&"fill"),children:[g==="overview"&&e(Ld,{}),g==="usage"&&e(Hu,{params:t.params}),g==="explore"&&e(Fc,{params:t.params}),g==="galaxy"&&e(Kc,{params:t.params}),g==="history"&&e(sd,{params:t.params}),g==="memory"&&e(Ad,{params:t.params}),g==="docs"&&e(Dc,{params:t.params}),g==="coverage"&&e(Gl,{}),g==="sessions"&&e(jd,{}),g==="swarm"&&e(Iu,{params:t.params,sub:t.sub}),g==="adjudicator"&&e(Xl,{params:t.params}),g==="system"&&e(Fu,{onChanged:()=>r(h=>h+1)})]},o),e("footer",{class:"status",children:[e("span",{children:["server ",e("b",{class:"ok",children:"ready"})]}),p&&e(R,{children:[e("span",{children:[e("b",{children:p.graph.nodes})," nodes \xB7 ",e("b",{children:p.graph.edges})," edges"]}),e("span",{children:["files: ",e("b",{children:p.files.byStatus.indexed??0})," indexed",p.files.byStatus.partial?` \xB7 ${p.files.byStatus.partial} partial`:"",p.files.byStatus.skipped?` \xB7 ${p.files.byStatus.skipped} skipped`:""]}),e("span",{children:["git ",p.freshness.head?.slice(0,7)??"n/a",p.freshness.indexedHead&&p.freshness.indexedHead!==p.freshness.head?` (signals at ${p.freshness.indexedHead.slice(0,7)})`:""]}),e("span",{children:["last index ",p.freshness.lastRun?me(p.freshness.lastRun):"never"]})]}),e("span",{class:"spacer"}),e("span",{class:"ellipsis",children:o})]}),e(bi,{})]})}var Ju=document.getElementById("app");Ju&&Ko(e(Uu,{}),Ju);})();
|
|
93
99
|
/*! Bundled license information:
|
|
94
100
|
|
|
95
101
|
prismjs/prism.js:
|