eminiar 0.10.1 → 0.12.0

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.
@@ -1,88 +1,95 @@
1
- "use strict";(()=>{var fa=Object.create;var Cn=Object.defineProperty;var ba=Object.getOwnPropertyDescriptor;var ya=Object.getOwnPropertyNames;var va=Object.getPrototypeOf,ka=Object.prototype.hasOwnProperty;var Ts=t=>{throw TypeError(t)};var xa=(t,n,s)=>n in t?Cn(t,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[n]=s;var wa=(t,n)=>()=>(n||t((n={exports:{}}).exports,n),n.exports);var _a=(t,n,s,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of ya(n))!ka.call(t,r)&&r!==s&&Cn(t,r,{get:()=>n[r],enumerable:!(i=ba(n,r))||i.enumerable});return t};var Sa=(t,n,s)=>(s=t!=null?fa(va(t)):{},_a(n||!t||!t.__esModule?Cn(s,"default",{value:t,enumerable:!0}):s,t));var ee=(t,n,s)=>xa(t,typeof n!="symbol"?n+"":n,s),Ta=(t,n,s)=>n.has(t)||Ts("Cannot "+s);var Es=(t,n,s)=>n.has(t)?Ts("Cannot add the same private member more than once"):n instanceof WeakSet?n.add(t):n.set(t,s);var Cs=(t,n,s)=>(Ta(t,n,"access private method"),s);var ii=wa((ap,cn)=>{"use strict";var So=typeof window<"u"?window:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?self:{};var U=(function(t){var n=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,s=0,i={},r={manual:t.Prism&&t.Prism.manual,disableWorkerMessageHandler:t.Prism&&t.Prism.disableWorkerMessageHandler,util:{encode:function h(u){return u instanceof a?new a(u.type,h(u.content),u.alias):Array.isArray(u)?u.map(h):u.replace(/&/g,"&amp;").replace(/</g,"&lt;").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(u,y){y=y||{};var b,v;switch(r.util.type(u)){case"Object":if(v=r.util.objId(u),y[v])return y[v];b={},y[v]=b;for(var k in u)u.hasOwnProperty(k)&&(b[k]=h(u[k],y));return b;case"Array":return v=r.util.objId(u),y[v]?y[v]:(b=[],y[v]=b,u.forEach(function(S,E){b[E]=h(S,y)}),b);default:return u}},getLanguage:function(h){for(;h;){var u=n.exec(h.className);if(u)return u[1].toLowerCase();h=h.parentElement}return"none"},setLanguage:function(h,u){h.className=h.className.replace(RegExp(n,"gi"),""),h.classList.add("language-"+u)},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 h=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(b.stack)||[])[1];if(h){var u=document.getElementsByTagName("script");for(var y in u)if(u[y].src==h)return u[y]}return null}},isActive:function(h,u,y){for(var b="no-"+u;h;){var v=h.classList;if(v.contains(u))return!0;if(v.contains(b))return!1;h=h.parentElement}return!!y}},languages:{plain:i,plaintext:i,text:i,txt:i,extend:function(h,u){var y=r.util.clone(r.languages[h]);for(var b in u)y[b]=u[b];return y},insertBefore:function(h,u,y,b){b=b||r.languages;var v=b[h],k={};for(var S in v)if(v.hasOwnProperty(S)){if(S==u)for(var E in y)y.hasOwnProperty(E)&&(k[E]=y[E]);y.hasOwnProperty(S)||(k[S]=v[S])}var w=b[h];return b[h]=k,r.languages.DFS(r.languages,function(C,R){R===w&&C!=h&&(this[C]=k)}),k},DFS:function h(u,y,b,v){v=v||{};var k=r.util.objId;for(var S in u)if(u.hasOwnProperty(S)){y.call(u,S,u[S],b||S);var E=u[S],w=r.util.type(E);w==="Object"&&!v[k(E)]?(v[k(E)]=!0,h(E,y,null,v)):w==="Array"&&!v[k(E)]&&(v[k(E)]=!0,h(E,y,S,v))}}},plugins:{},highlightAll:function(h,u){r.highlightAllUnder(document,h,u)},highlightAllUnder:function(h,u,y){var b={callback:y,container:h,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 v=0,k;k=b.elements[v++];)r.highlightElement(k,u===!0,b.callback)},highlightElement:function(h,u,y){var b=r.util.getLanguage(h),v=r.languages[b];r.util.setLanguage(h,b);var k=h.parentElement;k&&k.nodeName.toLowerCase()==="pre"&&r.util.setLanguage(k,b);var S=h.textContent,E={element:h,language:b,grammar:v,code:S};function w(R){E.highlightedCode=R,r.hooks.run("before-insert",E),E.element.innerHTML=E.highlightedCode,r.hooks.run("after-highlight",E),r.hooks.run("complete",E),y&&y.call(E.element)}if(r.hooks.run("before-sanity-check",E),k=E.element.parentElement,k&&k.nodeName.toLowerCase()==="pre"&&!k.hasAttribute("tabindex")&&k.setAttribute("tabindex","0"),!E.code){r.hooks.run("complete",E),y&&y.call(E.element);return}if(r.hooks.run("before-highlight",E),!E.grammar){w(r.util.encode(E.code));return}if(u&&t.Worker){var C=new Worker(r.filename);C.onmessage=function(R){w(R.data)},C.postMessage(JSON.stringify({language:E.language,code:E.code,immediateClose:!0}))}else w(r.highlight(E.code,E.grammar,E.language))},highlight:function(h,u,y){var b={code:h,grammar:u,language:y};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),a.stringify(r.util.encode(b.tokens),b.language)},tokenize:function(h,u){var y=u.rest;if(y){for(var b in y)u[b]=y[b];delete u.rest}var v=new c;return d(v,v.head,h),l(h,v,u,v.head,0),m(v)},hooks:{all:{},add:function(h,u){var y=r.hooks.all;y[h]=y[h]||[],y[h].push(u)},run:function(h,u){var y=r.hooks.all[h];if(!(!y||!y.length))for(var b=0,v;v=y[b++];)v(u)}},Token:a};t.Prism=r;function a(h,u,y,b){this.type=h,this.content=u,this.alias=y,this.length=(b||"").length|0}a.stringify=function h(u,y){if(typeof u=="string")return u;if(Array.isArray(u)){var b="";return u.forEach(function(w){b+=h(w,y)}),b}var v={type:u.type,content:h(u.content,y),tag:"span",classes:["token",u.type],attributes:{},language:y},k=u.alias;k&&(Array.isArray(k)?Array.prototype.push.apply(v.classes,k):v.classes.push(k)),r.hooks.run("wrap",v);var S="";for(var E in v.attributes)S+=" "+E+'="'+(v.attributes[E]||"").replace(/"/g,"&quot;")+'"';return"<"+v.tag+' class="'+v.classes.join(" ")+'"'+S+">"+v.content+"</"+v.tag+">"};function o(h,u,y,b){h.lastIndex=u;var v=h.exec(y);if(v&&b&&v[1]){var k=v[1].length;v.index+=k,v[0]=v[0].slice(k)}return v}function l(h,u,y,b,v,k){for(var S in y)if(!(!y.hasOwnProperty(S)||!y[S])){var E=y[S];E=Array.isArray(E)?E:[E];for(var w=0;w<E.length;++w){if(k&&k.cause==S+","+w)return;var C=E[w],R=C.inside,M=!!C.lookbehind,$=!!C.greedy,F=C.alias;if($&&!C.pattern.global){var T=C.pattern.toString().match(/[imsuy]*$/)[0];C.pattern=RegExp(C.pattern.source,T+"g")}for(var D=C.pattern||C,W=b.next,q=v;W!==u.tail&&!(k&&q>=k.reach);q+=W.value.length,W=W.next){var A=W.value;if(u.length>h.length)return;if(!(A instanceof a)){var z=1,re;if($){if(re=o(D,q,h,M),!re||re.index>=h.length)break;var ye=re.index,je=re.index+re[0].length,P=q;for(P+=W.value.length;ye>=P;)W=W.next,P+=W.value.length;if(P-=W.value.length,q=P,W.value instanceof a)continue;for(var ie=W;ie!==u.tail&&(P<je||typeof ie.value=="string");ie=ie.next)z++,P+=ie.value.length;z--,A=h.slice(q,P),re.index-=q}else if(re=o(D,0,A,M),!re)continue;var ye=re.index,tt=re[0],xe=A.slice(0,ye),Re=A.slice(ye+tt.length),Ft=q+A.length;k&&Ft>k.reach&&(k.reach=Ft);var nt=W.prev;xe&&(nt=d(u,nt,xe),q+=xe.length),p(u,nt,z);var Q=new a(S,R?r.tokenize(tt,R):tt,F,tt);if(W=d(u,nt,Q),Re&&d(u,W,Re),z>1){var ge={cause:S+","+w,reach:Ft};l(h,u,y,W.prev,q,ge),k&&ge.reach>k.reach&&(k.reach=ge.reach)}}}}}}function c(){var h={value:null,prev:null,next:null},u={value:null,prev:h,next:null};h.next=u,this.head=h,this.tail=u,this.length=0}function d(h,u,y){var b=u.next,v={value:y,prev:u,next:b};return u.next=v,b.prev=v,h.length++,v}function p(h,u,y){for(var b=u.next,v=0;v<y&&b!==h.tail;v++)b=b.next;u.next=b,b.prev=u,h.length-=v}function m(h){for(var u=[],y=h.head.next;y!==h.tail;)u.push(y.value),y=y.next;return u}if(!t.document)return t.addEventListener&&(r.disableWorkerMessageHandler||t.addEventListener("message",function(h){var u=JSON.parse(h.data),y=u.language,b=u.code,v=u.immediateClose;t.postMessage(r.highlight(b,r.languages[y],y)),v&&t.close()},!1)),r;var g=r.util.currentScript();g&&(r.filename=g.src,g.hasAttribute("data-manual")&&(r.manual=!0));function f(){r.manual||r.highlightAll()}if(!r.manual){var x=document.readyState;x==="loading"||x==="interactive"&&g&&g.defer?document.addEventListener("DOMContentLoaded",f):window.requestAnimationFrame?window.requestAnimationFrame(f):window.setTimeout(f,16)}return r})(So);typeof cn<"u"&&cn.exports&&(cn.exports=U);typeof global<"u"&&(global.Prism=U);U.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]};U.languages.markup.tag.inside["attr-value"].inside.entity=U.languages.markup.entity;U.languages.markup.doctype.inside["internal-subset"].inside=U.languages.markup;U.hooks.add("wrap",function(t){t.type==="entity"&&(t.attributes.title=t.content.replace(/&amp;/,"&"))});Object.defineProperty(U.languages.markup.tag,"addInlined",{value:function(n,s){var i={};i["language-"+s]={pattern:/(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,lookbehind:!0,inside:U.languages[s]},i.cdata=/^<!\[CDATA\[|\]\]>$/i;var r={"included-cdata":{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,inside:i}};r["language-"+s]={pattern:/[\s\S]+/,inside:U.languages[s]};var a={};a[n]={pattern:RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g,function(){return n}),"i"),lookbehind:!0,greedy:!0,inside:r},U.languages.insertBefore("markup","cdata",a)}});Object.defineProperty(U.languages.markup.tag,"addAttribute",{value:function(t,n){U.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:U.languages[n]},punctuation:[{pattern:/^=/,alias:"attr-equals"},/"|'/]}}}})}});U.languages.html=U.languages.markup;U.languages.mathml=U.languages.markup;U.languages.svg=U.languages.markup;U.languages.xml=U.languages.extend("markup",{});U.languages.ssml=U.languages.xml;U.languages.atom=U.languages.xml;U.languages.rss=U.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"))})(U);U.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:/[{}[\];(),.:]/};U.languages.javascript=U.languages.extend("clike",{"class-name":[U.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}|\?\?=?|\?\.?|[~:]/});U.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/;U.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:U.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:U.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:U.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:U.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:U.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/});U.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:U.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"}});U.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}});U.languages.markup&&(U.languages.markup.tag.addInlined("script","javascript"),U.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"));U.languages.js=U.languages.javascript;(function(){if(typeof U>"u"||typeof document>"u")return;Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector);var t="Loading\u2026",n=function(g,f){return"\u2716 Error "+g+" while fetching file: "+f},s="\u2716 Error: File does not exist or is empty",i={js:"javascript",py:"python",rb:"ruby",ps1:"powershell",psm1:"powershell",sh:"bash",bat:"batch",h:"c",tex:"latex"},r="data-src-status",a="loading",o="loaded",l="failed",c="pre[data-src]:not(["+r+'="'+o+'"]):not(['+r+'="'+a+'"])';function d(g,f,x){var h=new XMLHttpRequest;h.open("GET",g,!0),h.onreadystatechange=function(){h.readyState==4&&(h.status<400&&h.responseText?f(h.responseText):h.status>=400?x(n(h.status,h.statusText)):x(s))},h.send(null)}function p(g){var f=/^\s*(\d+)\s*(?:(,)\s*(?:(\d+)\s*)?)?$/.exec(g||"");if(f){var x=Number(f[1]),h=f[2],u=f[3];return h?u?[x,Number(u)]:[x,void 0]:[x,x]}}U.hooks.add("before-highlightall",function(g){g.selector+=", "+c}),U.hooks.add("before-sanity-check",function(g){var f=g.element;if(f.matches(c)){g.code="",f.setAttribute(r,a);var x=f.appendChild(document.createElement("CODE"));x.textContent=t;var h=f.getAttribute("data-src"),u=g.language;if(u==="none"){var y=(/\.(\w+)$/.exec(h)||[,"none"])[1];u=i[y]||y}U.util.setLanguage(x,u),U.util.setLanguage(f,u);var b=U.plugins.autoloader;b&&b.loadLanguages(u),d(h,function(v){f.setAttribute(r,o);var k=p(f.getAttribute("data-range"));if(k){var S=v.split(/\r\n?|\n/g),E=k[0],w=k[1]==null?S.length:k[1];E<0&&(E+=S.length),E=Math.max(0,Math.min(E-1,S.length)),w<0&&(w+=S.length),w=Math.max(0,Math.min(w,S.length)),v=S.slice(E,w).join(`
2
- `),f.hasAttribute("data-start")||f.setAttribute("data-start",String(E+1))}x.textContent=v,U.highlightElement(x)},function(v){f.setAttribute(r,l),x.textContent=v})}}),U.plugins.fileHighlight={highlight:function(f){for(var x=(f||document).querySelectorAll(c),h=0,u;u=x[h++];)U.highlightElement(u)}};var m=!1;U.fileHighlight=function(){m||(console.warn("Prism.fileHighlight is deprecated. Use `Prism.plugins.fileHighlight.highlight` instead."),m=!0),U.plugins.fileHighlight.highlight.apply(this,arguments)}})()});var jt,te,Fs,Ea,Pe,$s,Ls,Is,$n,Pt,bt,Ds,Mn,An,Rn,Ca,Bt={},Ut=[],$a=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Gt=Array.isArray;function Ie(t,n){for(var s in n)t[s]=n[s];return t}function Fn(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function Xt(t,n,s){var i,r,a,o={};for(a in n)a=="key"?i=n[a]:a=="ref"?r=n[a]:o[a]=n[a];if(arguments.length>2&&(o.children=arguments.length>3?jt.call(arguments,2):s),typeof t=="function"&&t.defaultProps!=null)for(a in t.defaultProps)o[a]===void 0&&(o[a]=t.defaultProps[a]);return Ot(t,o,i,r,null)}function Ot(t,n,s,i,r){var a={type:t,props:n,key:s,ref:i,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:r??++Fs,__i:-1,__u:0};return r==null&&te.vnode!=null&&te.vnode(a),a}function N(t){return t.children}function Ht(t,n){this.props=t,this.context=n}function Ge(t,n){if(n==null)return t.__?Ge(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"?Ge(t):null}function Aa(t){if(t.__P&&t.__d){var n=t.__v,s=n.__e,i=[],r=[],a=Ie({},n);a.__v=n.__v+1,te.vnode&&te.vnode(a),Ln(t.__P,a,n,t.__n,t.__P.namespaceURI,32&n.__u?[s]:null,i,s??Ge(n),!!(32&n.__u),r),a.__v=n.__v,a.__.__k[a.__i]=a,Bs(i,a,r),n.__e=n.__=null,a.__e!=s&&Ns(a)}}function Ns(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}),Ns(t)}function As(t){(!t.__d&&(t.__d=!0)&&Pe.push(t)&&!zt.__r++||$s!=te.debounceRendering)&&(($s=te.debounceRendering)||Ls)(zt)}function zt(){try{for(var t,n=1;Pe.length;)Pe.length>n&&Pe.sort(Is),t=Pe.shift(),n=Pe.length,Aa(t)}finally{Pe.length=zt.__r=0}}function Ps(t,n,s,i,r,a,o,l,c,d,p){var m,g,f,x,h,u,y=i&&i.__k||Ut,b=n.length;for(c=Ra(s,n,y,c,b),m=0;m<b;m++)(f=s.__k[m])!=null&&(g=f.__i!=-1&&y[f.__i]||Bt,f.__i=m,u=Ln(t,f,g,r,a,o,l,c,d,p),x=f.__e,f.ref&&g.ref!=f.ref&&(g.ref&&In(g.ref,null,f),p.push(f.ref,f.__c||x,f)),h==null&&x!=null&&(h=x),4&f.__u?(c=Os(f,c,t),g.__e&&(g.__e=null)):typeof f.type=="function"&&u!==void 0?c=u:x&&(c=x.nextSibling),f.__u&=-7);return s.__e=h,c}function Ra(t,n,s,i,r){var a,o,l,c,d,p=s.length,m=p,g=0;for(t.__k=new Array(r),a=0;a<r;a++)(o=n[a])!=null&&typeof o!="boolean"&&typeof o!="function"?(typeof o=="string"||typeof o=="number"||typeof o=="bigint"||o.constructor==String?o=t.__k[a]=Ot(null,o,null,null,null):Gt(o)?o=t.__k[a]=Ot(N,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=t.__k[a]=Ot(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):t.__k[a]=o,c=a+g,o.__=t,o.__b=t.__b+1,l=null,(d=o.__i=Ma(o,s,c,m))!=-1&&(m--,(l=s[d])&&(l.__u|=2)),l==null||l.__v==null?(d==-1&&(r>p?g--:r<p&&g++),typeof o.type!="function"&&(o.__u|=4)):d!=c&&(d==c-1?g--:d==c+1?g++:(d>c?g--:g++,o.__u|=4))):t.__k[a]=null;if(m)for(a=0;a<p;a++)(l=s[a])!=null&&(2&l.__u)==0&&(l.__e==i&&(i=Ge(l)),zs(l,l));return i}function Os(t,n,s){var i,r;if(typeof t.type=="function"){for(i=t.__k,r=0;i&&r<i.length;r++)i[r]&&(i[r].__=t,n=Os(i[r],n,s));return n}t.__e!=n&&(n&&t.type&&!n.parentNode&&(n=Ge(t)),n=s.insertBefore(t.__e,n||null));do n=n&&n.nextSibling;while(n!=null&&n.nodeType==8);return n}function Ma(t,n,s,i){var r,a,o,l=t.key,c=t.type,d=n[s],p=d!=null&&(2&d.__u)==0;if(d===null&&l==null||p&&l==d.key&&c==d.type)return s;if(i>(p?1:0)){for(r=s-1,a=s+1;r>=0||a<n.length;)if((d=n[o=r>=0?r--:a++])!=null&&(2&d.__u)==0&&l==d.key&&c==d.type)return o}return-1}function Rs(t,n,s){n[0]=="-"?t.setProperty(n,s??""):t[n]=s==null?"":typeof s!="number"||$a.test(n)?s:s+"px"}function Nt(t,n,s,i,r){var a,o;e:if(n=="style")if(typeof s=="string")t.style.cssText=s;else{if(typeof i=="string"&&(t.style.cssText=i=""),i)for(n in i)s&&n in s||Rs(t.style,n,"");if(s)for(n in s)i&&s[n]==i[n]||Rs(t.style,n,s[n])}else if(n[0]=="o"&&n[1]=="n")a=n!=(n=n.replace(Ds,"$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+a]=s,s?i?s[bt]=i[bt]:(s[bt]=Mn,t.addEventListener(n,a?Rn:An,a)):t.removeEventListener(n,a?Rn:An,a);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 Ms(t){return function(n){if(this.l){var s=this.l[n.type+t];if(n[Pt]==null)n[Pt]=Mn++;else if(n[Pt]<s[bt])return;return s(te.event?te.event(n):n)}}}function Ln(t,n,s,i,r,a,o,l,c,d){var p,m,g,f,x,h,u,y,b,v,k,S,E,w,C,R,M=n.type;if(n.constructor!==void 0)return null;128&s.__u&&(c=!!(32&s.__u),a=[l=n.__e=s.__e]),(p=te.__b)&&p(n);e:if(typeof M=="function"){m=o.length;try{if(b=n.props,v=M.prototype&&M.prototype.render,k=(p=M.contextType)&&i[p.__c],S=p?k?k.props.value:p.__:i,s.__c?y=(g=n.__c=s.__c).__=g.__E:(v?n.__c=g=new M(b,S):(n.__c=g=new Ht(b,S),g.constructor=M,g.render=La),k&&k.sub(g),g.state||(g.state={}),g.__n=i,f=g.__d=!0,g.__h=[],g._sb=[]),v&&g.__s==null&&(g.__s=g.state),v&&M.getDerivedStateFromProps!=null&&(g.__s==g.state&&(g.__s=Ie({},g.__s)),Ie(g.__s,M.getDerivedStateFromProps(b,g.__s))),x=g.props,h=g.state,g.__v=n,f)v&&M.getDerivedStateFromProps==null&&g.componentWillMount!=null&&g.componentWillMount(),v&&g.componentDidMount!=null&&g.__h.push(g.componentDidMount);else{if(v&&M.getDerivedStateFromProps==null&&b!==x&&g.componentWillReceiveProps!=null&&g.componentWillReceiveProps(b,S),n.__v==s.__v||!g.__e&&g.shouldComponentUpdate!=null&&g.shouldComponentUpdate(b,g.__s,S)===!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($){$&&($.__=n)}),Ut.push.apply(g.__h,g._sb),g._sb=[],g.__h.length&&o.push(g),l=Ge(s);break e}g.componentWillUpdate!=null&&g.componentWillUpdate(b,g.__s,S),v&&g.componentDidUpdate!=null&&g.__h.push(function(){g.componentDidUpdate(x,h,u)})}if(g.context=S,g.props=b,g.__P=t,g.__e=!1,E=te.__r,w=0,v)g.state=g.__s,g.__d=!1,E&&E(n),p=g.render(g.props,g.state,g.context),Ut.push.apply(g.__h,g._sb),g._sb=[];else do g.__d=!1,E&&E(n),p=g.render(g.props,g.state,g.context),g.state=g.__s;while(g.__d&&++w<25);g.state=g.__s,g.getChildContext!=null&&(i=Ie(Ie({},i),g.getChildContext())),v&&!f&&g.getSnapshotBeforeUpdate!=null&&(u=g.getSnapshotBeforeUpdate(x,h)),C=p!=null&&p.type===N&&p.key==null?Us(p.props.children):p,l=Ps(t,Gt(C)?C:[C],n,s,i,r,a,o,l,c,d),g.base=n.__e,n.__u&=-161,g.__h.length&&o.push(g),y&&(g.__E=g.__=null)}catch($){if(o.length=m,n.__v=null,c||a!=null){if($.then){for(n.__u|=c?160:128;l&&l.nodeType==8&&l.nextSibling;)l=l.nextSibling;a!=null&&(a[a.indexOf(l)]=null),n.__e=l}else if(a!=null)for(R=a.length;R--;)Fn(a[R])}else n.__e=s.__e;n.__k==null&&(n.__k=s.__k||[]),$.then||Hs(n),te.__e($,n,s)}}else a==null&&n.__v==s.__v?(n.__k=s.__k,n.__e=s.__e):l=n.__e=Fa(s.__e,n,s,i,r,a,o,c,d);return(p=te.diffed)&&p(n),128&n.__u?void 0:l}function Hs(t){t&&(t.__c&&(t.__c.__e=!0),t.__k&&t.__k.some(Hs))}function Bs(t,n,s){for(var i=0;i<s.length;i++)In(s[i],s[++i],s[++i]);te.__c&&te.__c(n,t),t.some(function(r){try{t=r.__h,r.__h=[],t.some(function(a){a.call(r)})}catch(a){te.__e(a,r.__v)}})}function Us(t){return typeof t!="object"||t==null||t.__b>0?t:Gt(t)?t.map(Us):t.constructor!==void 0?null:Ie({},t)}function Fa(t,n,s,i,r,a,o,l,c){var d,p,m,g,f,x,h,u=s.props||Bt,y=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"),a!=null){for(d=0;d<a.length;d++)if((f=a[d])&&"setAttribute"in f==!!b&&(b?f.localName==b:f.nodeType==3)){t=f,a[d]=null;break}}if(t==null){if(b==null)return document.createTextNode(y);t=document.createElementNS(r,b,y.is&&y),l&&(te.__m&&te.__m(n,a),l=!1),a=null}if(b==null)u===y||l&&t.data==y||(t.data=y);else{if(a=b=="textarea"&&y.defaultValue!=null?null:a&&jt.call(t.childNodes),!l&&a!=null)for(u={},d=0;d<t.attributes.length;d++)u[(f=t.attributes[d]).name]=f.value;for(d in u)f=u[d],d=="dangerouslySetInnerHTML"?m=f:d=="children"||d in y||d=="value"&&"defaultValue"in y||d=="checked"&&"defaultChecked"in y||Nt(t,d,null,f,r);for(d in y)f=y[d],d=="children"?g=f:d=="dangerouslySetInnerHTML"?p=f:d=="value"?x=f:d=="checked"?h=f:l&&typeof f!="function"||u[d]===f||Nt(t,d,f,u[d],r);if(p)l||m&&(p.__html==m.__html||p.__html==t.innerHTML)||(t.innerHTML=p.__html),n.__k=[];else if(m&&(t.innerHTML=""),Ps(n.type=="template"?t.content:t,Gt(g)?g:[g],n,s,i,b=="foreignObject"?"http://www.w3.org/1999/xhtml":r,a,o,a?a[0]:s.__k&&Ge(s,0),l,c),a!=null)for(d=a.length;d--;)Fn(a[d]);l&&b!="textarea"||(d="value",b=="progress"&&x==null?t.removeAttribute("value"):x!=null&&(x!==t[d]||b=="progress"&&!x||b=="option"&&x!=u[d])&&Nt(t,d,x,u[d],r),d="checked",h!=null&&h!=t[d]&&Nt(t,d,h,u[d],r))}return t}function In(t,n,s){try{if(typeof t=="function"){var i=typeof t.__u=="function";i&&t.__u(),i&&n==null||(t.__u=t(n))}else t.current=n}catch(r){te.__e(r,s)}}function zs(t,n,s){var i,r;if(te.unmount&&te.unmount(t),(i=t.ref)&&(i.current&&i.current!=t.__e||In(i,null,n)),(i=t.__c)!=null){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(a){te.__e(a,n)}i.base=i.__P=i.__n=null}if(i=t.__k)for(r=0;r<i.length;r++)i[r]&&zs(i[r],n,s||typeof t.type!="function");s||Fn(t.__e),t.__c=t.__=t.__e=void 0}function La(t,n,s){return this.constructor(t,s)}function js(t,n,s){var i,r,a,o;n==document&&(n=document.documentElement),te.__&&te.__(t,n),r=(i=typeof s=="function")?null:s&&s.__k||n.__k,a=[],o=[],Ln(n,t=(!i&&s||n).__k=Xt(N,null,[t]),r||Bt,Bt,n.namespaceURI,!i&&s?[s]:r?null:n.firstChild?jt.call(n.childNodes):null,a,!i&&s?s:r?r.__e:n.firstChild,i,o),Bs(a,t,o),t.props.children=null}jt=Ut.slice,te={__e:function(t,n,s,i){for(var r,a,o;n=n.__;)if((r=n.__c)&&!r.__)try{if((a=r.constructor)&&a.getDerivedStateFromError!=null&&(r.setState(a.getDerivedStateFromError(t)),o=r.__d),r.componentDidCatch!=null&&(r.componentDidCatch(t,i||{}),o=r.__d),o)return r.__E=r}catch(l){t=l}throw t}},Fs=0,Ea=function(t){return t!=null&&t.constructor===void 0},Ht.prototype.setState=function(t,n){var s;s=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Ie({},this.state),typeof t=="function"&&(t=t(Ie({},s),this.props)),t&&Ie(s,t),t!=null&&this.__v&&(n&&this._sb.push(n),As(this))},Ht.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),As(this))},Ht.prototype.render=N,Pe=[],Ls=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Is=function(t,n){return t.__v.__b-n.__v.__b},zt.__r=0,$n=Math.random().toString(8),Pt="__d"+$n,bt="__a"+$n,Ds=/(PointerCapture)$|Capture$/i,Mn=0,An=Ms(!1),Rn=Ms(!0),Ca=0;var st,ae,Dn,Gs,rt=0,Ys=[],le=te,Xs=le.__b,Ws=le.__r,qs=le.diffed,Js=le.__c,Ks=le.unmount,Vs=le.__;function qt(t,n){le.__h&&le.__h(ae,t,rt||n),rt=0;var s=ae.__H||(ae.__H={__:[],__h:[]});return t>=s.__.length&&s.__.push({}),s.__[t]}function _(t){return rt=1,Ia(tr,t)}function Ia(t,n,s){var i=qt(st++,2);if(i.t=t,!i.__c&&(i.__=[s?s(n):tr(void 0,n),function(l){var c=i.__N?i.__N[0]:i.__[0],d=i.t(c,l);c!==d&&(i.__N=[d,i.__[1]],i.__c.setState({}))}],i.__c=ae,!ae.__f)){var r=function(l,c,d){if(!i.__c.__H)return!0;var p=!1,m=i.__c.props!==l;if(i.__c.__H.__.some(function(f){if(f.__N){p=!0;var x=f.__[0];f.__=f.__N,f.__N=void 0,x!==f.__[0]&&(m=!0)}}),a){var g=a.call(this,l,c,d);return p?g||m:g}return!p||m};ae.__f=!0;var a=ae.shouldComponentUpdate,o=ae.componentWillUpdate;ae.componentWillUpdate=function(l,c,d){if(this.__e){var p=a;a=void 0,r(l,c,d),a=p}o&&o.call(this,l,c,d)},ae.shouldComponentUpdate=r}return i.__N||i.__}function j(t,n){var s=qt(st++,3);!le.__s&&Pn(s.__H,n)&&(s.__=t,s.u=n,ae.__H.__h.push(s))}function Da(t,n){var s=qt(st++,4);!le.__s&&Pn(s.__H,n)&&(s.__=t,s.u=n,ae.__h.push(s))}function oe(t){return rt=5,K(function(){return{current:t}},[])}function Qs(t,n,s){rt=6,Da(function(){if(typeof t=="function"){var i=t(n());return function(){t(null),i&&typeof i=="function"&&i()}}if(t)return t.current=n(),function(){return t.current=null}},s==null?s:s.concat(t))}function K(t,n){var s=qt(st++,7);return Pn(s.__H,n)&&(s.__=t(),s.__H=n,s.__h=t),s.__}function er(t,n){return rt=8,K(function(){return t},n)}function Na(){for(var t;t=Ys.shift();){var n=t.__H;if(t.__P&&n)try{n.__h.some(Wt),n.__h.some(Nn),n.__h=[]}catch(s){n.__h=[],le.__e(s,t.__v)}}}le.__b=function(t){ae=null,Xs&&Xs(t)},le.__=function(t,n){t&&n.__k&&n.__k.__m&&(t.__m=n.__k.__m),Vs&&Vs(t,n)},le.__r=function(t){Ws&&Ws(t),st=0;var n=(ae=t.__c).__H;n&&(Dn===ae?(n.__h=[],ae.__h=[],n.__.some(function(s){s.__N&&(s.__=s.__N),s.u=s.__N=void 0})):(n.__h.some(Wt),n.__h.some(Nn),n.__h=[],st=0)),Dn=ae},le.diffed=function(t){qs&&qs(t);var n=t.__c;n&&n.__H&&(n.__H.__h.length&&(Ys.push(n)!==1&&Gs===le.requestAnimationFrame||((Gs=le.requestAnimationFrame)||Pa)(Na)),n.__H.__.some(function(s){s.u&&(s.__H=s.u,s.u=void 0)})),Dn=ae=null},le.__c=function(t,n){n.some(function(s){try{s.__h.some(Wt),s.__h=s.__h.filter(function(i){return!i.__||Nn(i)})}catch(i){n.some(function(r){r.__h&&(r.__h=[])}),n=[],le.__e(i,s.__v)}}),Js&&Js(t,n)},le.unmount=function(t){Ks&&Ks(t);var n,s=t.__c;s&&s.__H&&(s.__H.__.some(function(i){try{Wt(i)}catch(r){n=r}}),s.__H=void 0,n&&le.__e(n,s.__v))};var Zs=typeof requestAnimationFrame=="function";function Pa(t){var n,s=function(){clearTimeout(i),Zs&&cancelAnimationFrame(n),setTimeout(t)},i=setTimeout(s,35);Zs&&(n=requestAnimationFrame(s))}function Wt(t){var n=ae,s=t.__c;typeof s=="function"&&(t.__c=void 0,s()),ae=n}function Nn(t){var n=ae;t.__c=t.__(),ae=n}function Pn(t,n){return!t||t.length!==n.length||n.some(function(s,i){return s!==t[i]})}function tr(t,n){return typeof n=="function"?n(t):n}var Jt=new URLSearchParams(location.search).get("root")??"",On=()=>Jt;function nr(t){Jt=t;let n=new URL(location.href);n.searchParams.set("root",t),history.replaceState(null,"",n.toString())}function Oa(t,n){let s=new URL(t,location.origin);Jt&&s.searchParams.set("root",Jt);for(let[i,r]of Object.entries(n??{}))r==null||r===""||s.searchParams.set(i,String(r));return s.toString()}var yt=class extends Error{constructor(s,i){super(s);ee(this,"status",i)}};async function H(t,n,s){let i=await fetch(Oa(t,n),s),r=await i.json().catch(()=>({error:"bad response"}));if(i.status===404&&r.error==="not found"&&t.startsWith("/api/"))throw new yt(`${t} is not available on the running server; restart \`eminiar ui\` to pick up the rebuilt bundle`,i.status);if(!i.ok)throw new yt(r.error??`HTTP ${i.status}`,i.status);if(r&&typeof r=="object"&&"error"in r&&r.error)throw new yt(String(r.error),i.status);return r}function ve(t,n,s="POST",i){return H(t,i,{method:s,headers:{"content-type":"application/json"},body:JSON.stringify(n)})}function Kt(t,n){return H(t,n,{method:"DELETE",headers:{"content-type":"application/json"}})}var J=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(Math.round(t));function ne(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 fe=t=>t?new Date(t).toISOString().slice(0,10):"",sr=t=>t?new Date(t).toLocaleTimeString():"",Vt=t=>t.split("/").pop()??t;var Ha={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"},Se=t=>Ha[t]??"#94a3b8",Ba={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"},it=t=>Ba[t]??"#94a3b8",Zt=new Set(["imports","reexports","calls","references","extends","implements","handles","mentions","supersedes","links","documents","about"]),rr=["imports","calls","references","extends","implements","handles","reexports","co_changes","mentions","defines"],L=(...t)=>t.filter(Boolean).join(" ");function ir(t,n){let s;return(...i)=>{clearTimeout(s),s=setTimeout(()=>t(...i),n)}}var Te=t=>`${Math.round((t??0)*100)}%`;function ar(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 Ua=0;function e(t,n,s,i,r,a){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:--Ua,__i:-1,__u:0,__source:r,__self:a};if(typeof t=="function"&&(o=t.defaultProps))for(l in o)c[l]===void 0&&(c[l]=o[l]);return te.vnode&&te.vnode(d),d}var Hn=new Set;function Y(t,n=!1){for(let s of Hn)s(t,n)}function or(){let[t,n]=_(null);return j(()=>{let s,i=(r,a)=>{n({msg:r,bad:a}),clearTimeout(s),s=setTimeout(()=>n(null),a?6e3:2500)};return Hn.add(i),()=>{Hn.delete(i),clearTimeout(s)}},[]),t?e("div",{class:L("toast",t.bad&&"bad"),children:t.msg}):null}function G(t,n){let[s,i]=_({data:void 0,error:void 0,loading:!0}),[r,a]=_(0),o=oe(0);j(()=>{let c=++o.current;i(d=>({...d,loading:!0,error:void 0})),t().then(d=>c===o.current&&i({data:d,error:void 0,loading:!1}),d=>c===o.current&&i(p=>({...p,error:d.message,loading:!1})))},[...n,r]);let l=er(()=>a(c=>c+1),[]);return{...s,reload:l}}var B=()=>e("span",{class:"spin"}),X=({children:t})=>e("div",{class:"empty",children:t}),Z=({error:t})=>e("div",{class:"empty bad",children:t});function pe({kind:t}){return e("span",{class:"tag kind",style:{color:Se(t)},children:t})}function I({children:t,class:n}){return e("span",{class:L("tag",n),children:t})}function De({value:t,max:n,width:s=80}){let i=n>0?Math.max(2,t/n*s):2;return e("span",{class:"bar",style:{width:`${i}px`},title:String(t)})}function Oe({rows:t}){return e("dl",{class:"kv",children:t.map(([n,s])=>e(N,{children:[e("dt",{children:n}),e("dd",{children:s})]}))})}function we({tabs:t,value:n,onChange:s}){return e("div",{class:"subtabs",children:t.map(([i,r])=>e("button",{type:"button",class:L(n===i&&"active"),onClick:()=>s(i),children:r}))})}function lr({left:t,center:n,right:s,leftWidth:i=280,rightWidth:r=340}){let[a,o]=_(i),[l,c]=_(r),d=oe(null),[p,m]=_(null);j(()=>{let f=h=>{let u=d.current;if(!u)return;let y=h.clientX-u.x;u.side==="l"?o(Math.max(160,Math.min(700,u.start+y))):c(Math.max(200,Math.min(800,u.start-y)))},x=()=>{d.current=null,m(null)};return window.addEventListener("mousemove",f),window.addEventListener("mouseup",x),()=>{window.removeEventListener("mousemove",f),window.removeEventListener("mouseup",x)}},[]);let g=[t?`${a}px 5px`:"","minmax(0, 1fr)",s?`5px ${l}px`:""].filter(Boolean).join(" ");return e("div",{class:"split",style:{gridTemplateColumns:g},children:[t&&e(N,{children:[e("div",{class:"pane",children:t}),e("div",{class:L("gutter",p==="l"&&"on"),onMouseDown:f=>{d.current={side:"l",x:f.clientX,start:a},m("l"),f.preventDefault()}})]}),e("div",{class:"pane",children:n}),s&&e(N,{children:[e("div",{class:L("gutter",p==="r"&&"on"),onMouseDown:f=>{d.current={side:"r",x:f.clientX,start:l},m("r"),f.preventDefault()}}),e("div",{class:"pane",children:s})]})]})}function He(t,n,s=!0){let[i,r]=_(n),[a,o]=_(s?-1:1);return{sorted:(t??[]).slice().sort((d,p)=>{let m=d[i],g=p[i];return typeof m=="number"&&typeof g=="number"?(m-g)*a:String(m??"").localeCompare(String(g??""))*a}),th:(d,p,m=!1)=>e("th",{class:L("sortable",m&&"num",i===d&&"sorted"),onClick:()=>{i===d?o(g=>g===1?-1:1):(r(d),o(m?-1:1))},children:[p,i===d?a===1?" \u25B2":" \u25BC":""]})}}var za=["overview","usage","explore","galaxy","architecture","history","memory","docs","coverage","sessions","system"];function cr(){let t=location.hash.replace(/^#\/?/,""),[n="",s=""]=t.split("?"),i=za.includes(n)?n:"overview",r={};for(let[a,o]of new URLSearchParams(s))r[a]=o;return{view:i,params:r}}function O(t,n={}){let s=new URLSearchParams;for(let[r,a]of Object.entries(n))a&&s.set(r,a);let i=s.toString();location.hash=`/${t}${i?`?${i}`:""}`}function dr(){let[t,n]=_(cr);return j(()=>{let s=()=>n(cr());return window.addEventListener("hashchange",s),()=>window.removeEventListener("hashchange",s)},[]),t}function Bn(t,n){var s,i=1;t==null&&(t=0),n==null&&(n=0);function r(){var a,o=s.length,l,c=0,d=0;for(a=0;a<o;++a)l=s[a],c+=l.x,d+=l.y;for(c=(c/o-t)*i,d=(d/o-n)*i,a=0;a<o;++a)l=s[a],l.x-=c,l.y-=d}return r.initialize=function(a){s=a},r.x=function(a){return arguments.length?(t=+a,r):t},r.y=function(a){return arguments.length?(n=+a,r):n},r.strength=function(a){return arguments.length?(i=+a,r):i},r}function ur(t){let n=+this._x.call(null,t),s=+this._y.call(null,t);return pr(this.cover(n,s),n,s,t)}function pr(t,n,s,i){if(isNaN(n)||isNaN(s))return t;var r,a=t._root,o={data:i},l=t._x0,c=t._y0,d=t._x1,p=t._y1,m,g,f,x,h,u,y,b;if(!a)return t._root=o,t;for(;a.length;)if((h=n>=(m=(l+d)/2))?l=m:d=m,(u=s>=(g=(c+p)/2))?c=g:p=g,r=a,!(a=a[y=u<<1|h]))return r[y]=o,t;if(f=+t._x.call(null,a.data),x=+t._y.call(null,a.data),n===f&&s===x)return o.next=a,r?r[y]=o:t._root=o,t;do r=r?r[y]=new Array(4):t._root=new Array(4),(h=n>=(m=(l+d)/2))?l=m:d=m,(u=s>=(g=(c+p)/2))?c=g:p=g;while((y=u<<1|h)===(b=(x>=g)<<1|f>=m));return r[b]=a,r[y]=o,t}function mr(t){var n,s,i=t.length,r,a,o=new Array(i),l=new Array(i),c=1/0,d=1/0,p=-1/0,m=-1/0;for(s=0;s<i;++s)isNaN(r=+this._x.call(null,n=t[s]))||isNaN(a=+this._y.call(null,n))||(o[s]=r,l[s]=a,r<c&&(c=r),r>p&&(p=r),a<d&&(d=a),a>m&&(m=a));if(c>p||d>m)return this;for(this.cover(c,d).cover(p,m),s=0;s<i;++s)pr(this,o[s],l[s],t[s]);return this}function hr(t,n){if(isNaN(t=+t)||isNaN(n=+n))return this;var s=this._x0,i=this._y0,r=this._x1,a=this._y1;if(isNaN(s))r=(s=Math.floor(t))+1,a=(i=Math.floor(n))+1;else{for(var o=r-s||1,l=this._root,c,d;s>t||t>=r||i>n||n>=a;)switch(d=(n<i)<<1|t<s,c=new Array(4),c[d]=l,l=c,o*=2,d){case 0:r=s+o,a=i+o;break;case 1:s=r-o,a=i+o;break;case 2:r=s+o,i=a-o;break;case 3:s=r-o,i=a-o;break}this._root&&this._root.length&&(this._root=l)}return this._x0=s,this._y0=i,this._x1=r,this._y1=a,this}function gr(){var t=[];return this.visit(function(n){if(!n.length)do t.push(n.data);while(n=n.next)}),t}function fr(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 me(t,n,s,i,r){this.node=t,this.x0=n,this.y0=s,this.x1=i,this.y1=r}function br(t,n,s){var i,r=this._x0,a=this._y0,o,l,c,d,p=this._x1,m=this._y1,g=[],f=this._root,x,h;for(f&&g.push(new me(f,r,a,p,m)),s==null?s=1/0:(r=t-s,a=n-s,p=t+s,m=n+s,s*=s);x=g.pop();)if(!(!(f=x.node)||(o=x.x0)>p||(l=x.y0)>m||(c=x.x1)<r||(d=x.y1)<a))if(f.length){var u=(o+c)/2,y=(l+d)/2;g.push(new me(f[3],u,y,c,d),new me(f[2],o,y,u,d),new me(f[1],u,l,c,y),new me(f[0],o,l,u,y)),(h=(n>=y)<<1|t>=u)&&(x=g[g.length-1],g[g.length-1]=g[g.length-1-h],g[g.length-1-h]=x)}else{var b=t-+this._x.call(null,f.data),v=n-+this._y.call(null,f.data),k=b*b+v*v;if(k<s){var S=Math.sqrt(s=k);r=t-S,a=n-S,p=t+S,m=n+S,i=f.data}}return i}function yr(t){if(isNaN(p=+this._x.call(null,t))||isNaN(m=+this._y.call(null,t)))return this;var n,s=this._root,i,r,a,o=this._x0,l=this._y0,c=this._x1,d=this._y1,p,m,g,f,x,h,u,y;if(!s)return this;if(s.length)for(;;){if((x=p>=(g=(o+c)/2))?o=g:c=g,(h=m>=(f=(l+d)/2))?l=f:d=f,n=s,!(s=s[u=h<<1|x]))return this;if(!s.length)break;(n[u+1&3]||n[u+2&3]||n[u+3&3])&&(i=n,y=u)}for(;s.data!==t;)if(r=s,!(s=s.next))return this;return(a=s.next)&&delete s.next,r?(a?r.next=a:delete r.next,this):n?(a?n[u]=a:delete n[u],(s=n[0]||n[1]||n[2]||n[3])&&s===(n[3]||n[2]||n[1]||n[0])&&!s.length&&(i?i[y]=s:this._root=s),this):(this._root=a,this)}function vr(t){for(var n=0,s=t.length;n<s;++n)this.remove(t[n]);return this}function kr(){return this._root}function xr(){var t=0;return this.visit(function(n){if(!n.length)do++t;while(n=n.next)}),t}function wr(t){var n=[],s,i=this._root,r,a,o,l,c;for(i&&n.push(new me(i,this._x0,this._y0,this._x1,this._y1));s=n.pop();)if(!t(i=s.node,a=s.x0,o=s.y0,l=s.x1,c=s.y1)&&i.length){var d=(a+l)/2,p=(o+c)/2;(r=i[3])&&n.push(new me(r,d,p,l,c)),(r=i[2])&&n.push(new me(r,a,p,d,c)),(r=i[1])&&n.push(new me(r,d,o,l,p)),(r=i[0])&&n.push(new me(r,a,o,d,p))}return this}function _r(t){var n=[],s=[],i;for(this._root&&n.push(new me(this._root,this._x0,this._y0,this._x1,this._y1));i=n.pop();){var r=i.node;if(r.length){var a,o=i.x0,l=i.y0,c=i.x1,d=i.y1,p=(o+c)/2,m=(l+d)/2;(a=r[0])&&n.push(new me(a,o,l,p,m)),(a=r[1])&&n.push(new me(a,p,l,c,m)),(a=r[2])&&n.push(new me(a,o,m,p,d)),(a=r[3])&&n.push(new me(a,p,m,c,d))}s.push(i)}for(;i=s.pop();)t(i.node,i.x0,i.y0,i.x1,i.y1);return this}function Sr(t){return t[0]}function Tr(t){return arguments.length?(this._x=t,this):this._x}function Er(t){return t[1]}function Cr(t){return arguments.length?(this._y=t,this):this._y}function Xe(t,n,s){var i=new Un(n??Sr,s??Er,NaN,NaN,NaN,NaN);return t==null?i:i.addAll(t)}function Un(t,n,s,i,r,a){this._x=t,this._y=n,this._x0=s,this._y0=i,this._x1=r,this._y1=a,this._root=void 0}function $r(t){for(var n={data:t.data},s=n;t=t.next;)s=s.next={data:t.data};return n}var be=Xe.prototype=Un.prototype;be.copy=function(){var t=new Un(this._x,this._y,this._x0,this._y0,this._x1,this._y1),n=this._root,s,i;if(!n)return t;if(!n.length)return t._root=$r(n),t;for(s=[{source:n,target:t._root=new Array(4)}];n=s.pop();)for(var r=0;r<4;++r)(i=n.source[r])&&(i.length?s.push({source:i,target:n.target[r]=new Array(4)}):n.target[r]=$r(i));return t};be.add=ur;be.addAll=mr;be.cover=hr;be.data=gr;be.extent=fr;be.find=br;be.remove=yr;be.removeAll=vr;be.root=kr;be.size=xr;be.visit=wr;be.visitAfter=_r;be.x=Tr;be.y=Cr;function de(t){return function(){return t}}function Ee(t){return(t()-.5)*1e-6}function ja(t){return t.x+t.vx}function Ga(t){return t.y+t.vy}function zn(t){var n,s,i,r=1,a=1;typeof t!="function"&&(t=de(t==null?1:+t));function o(){for(var d,p=n.length,m,g,f,x,h,u,y=0;y<a;++y)for(m=Xe(n,ja,Ga).visitAfter(l),d=0;d<p;++d)g=n[d],h=s[g.index],u=h*h,f=g.x+g.vx,x=g.y+g.vy,m.visit(b);function b(v,k,S,E,w){var C=v.data,R=v.r,M=h+R;if(C){if(C.index>g.index){var $=f-C.x-C.vx,F=x-C.y-C.vy,T=$*$+F*F;T<M*M&&($===0&&($=Ee(i),T+=$*$),F===0&&(F=Ee(i),T+=F*F),T=(M-(T=Math.sqrt(T)))/T*r,g.vx+=($*=T)*(M=(R*=R)/(u+R)),g.vy+=(F*=T)*M,C.vx-=$*(M=1-M),C.vy-=F*M)}return}return k>f+M||E<f-M||S>x+M||w<x-M}}function l(d){if(d.data)return d.r=s[d.data.index];for(var p=d.r=0;p<4;++p)d[p]&&d[p].r>d.r&&(d.r=d[p].r)}function c(){if(n){var d,p=n.length,m;for(s=new Array(p),d=0;d<p;++d)m=n[d],s[m.index]=+t(m,d,n)}}return o.initialize=function(d,p){n=d,i=p,c()},o.iterations=function(d){return arguments.length?(a=+d,o):a},o.strength=function(d){return arguments.length?(r=+d,o):r},o.radius=function(d){return arguments.length?(t=typeof d=="function"?d:de(+d),c(),o):t},o}function Xa(t){return t.index}function Ar(t,n){var s=t.get(n);if(!s)throw new Error("node not found: "+n);return s}function jn(t){var n=Xa,s=m,i,r=de(30),a,o,l,c,d,p=1;t==null&&(t=[]);function m(u){return 1/Math.min(l[u.source.index],l[u.target.index])}function g(u){for(var y=0,b=t.length;y<p;++y)for(var v=0,k,S,E,w,C,R,M;v<b;++v)k=t[v],S=k.source,E=k.target,w=E.x+E.vx-S.x-S.vx||Ee(d),C=E.y+E.vy-S.y-S.vy||Ee(d),R=Math.sqrt(w*w+C*C),R=(R-a[v])/R*u*i[v],w*=R,C*=R,E.vx-=w*(M=c[v]),E.vy-=C*M,S.vx+=w*(M=1-M),S.vy+=C*M}function f(){if(o){var u,y=o.length,b=t.length,v=new Map(o.map((S,E)=>[n(S,E,o),S])),k;for(u=0,l=new Array(y);u<b;++u)k=t[u],k.index=u,typeof k.source!="object"&&(k.source=Ar(v,k.source)),typeof k.target!="object"&&(k.target=Ar(v,k.target)),l[k.source.index]=(l[k.source.index]||0)+1,l[k.target.index]=(l[k.target.index]||0)+1;for(u=0,c=new Array(b);u<b;++u)k=t[u],c[u]=l[k.source.index]/(l[k.source.index]+l[k.target.index]);i=new Array(b),x(),a=new Array(b),h()}}function x(){if(o)for(var u=0,y=t.length;u<y;++u)i[u]=+s(t[u],u,t)}function h(){if(o)for(var u=0,y=t.length;u<y;++u)a[u]=+r(t[u],u,t)}return g.initialize=function(u,y){o=u,d=y,f()},g.links=function(u){return arguments.length?(t=u,f(),g):t},g.id=function(u){return arguments.length?(n=u,g):n},g.iterations=function(u){return arguments.length?(p=+u,g):p},g.strength=function(u){return arguments.length?(s=typeof u=="function"?u:de(+u),x(),g):s},g.distance=function(u){return arguments.length?(r=typeof u=="function"?u:de(+u),h(),g):r},g}var Wa={value:()=>{}};function Mr(){for(var t=0,n=arguments.length,s={},i;t<n;++t){if(!(i=arguments[t]+"")||i in s||/[\s.]/.test(i))throw new Error("illegal type: "+i);s[i]=[]}return new Yt(s)}function Yt(t){this._=t}function qa(t,n){return t.trim().split(/^|\s+/).map(function(s){var i="",r=s.indexOf(".");if(r>=0&&(i=s.slice(r+1),s=s.slice(0,r)),s&&!n.hasOwnProperty(s))throw new Error("unknown type: "+s);return{type:s,name:i}})}Yt.prototype=Mr.prototype={constructor:Yt,on:function(t,n){var s=this._,i=qa(t+"",s),r,a=-1,o=i.length;if(arguments.length<2){for(;++a<o;)if((r=(t=i[a]).type)&&(r=Ja(s[r],t.name)))return r;return}if(n!=null&&typeof n!="function")throw new Error("invalid callback: "+n);for(;++a<o;)if(r=(t=i[a]).type)s[r]=Rr(s[r],t.name,n);else if(n==null)for(r in s)s[r]=Rr(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 Yt(t)},call:function(t,n){if((r=arguments.length-2)>0)for(var s=new Array(r),i=0,r,a;i<r;++i)s[i]=arguments[i+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(a=this._[t],i=0,r=a.length;i<r;++i)a[i].value.apply(n,s)},apply:function(t,n,s){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var i=this._[t],r=0,a=i.length;r<a;++r)i[r].value.apply(n,s)}};function Ja(t,n){for(var s=0,i=t.length,r;s<i;++s)if((r=t[s]).name===n)return r.value}function Rr(t,n,s){for(var i=0,r=t.length;i<r;++i)if(t[i].name===n){t[i]=Wa,t=t.slice(0,i).concat(t.slice(i+1));break}return s!=null&&t.push({name:n,value:s}),t}var Gn=Mr;var at=0,kt=0,vt=0,Lr=1e3,Qt,xt,en=0,We=0,tn=0,wt=typeof performance=="object"&&performance.now?performance:Date,Ir=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function qn(){return We||(Ir(Ka),We=wt.now()+tn)}function Ka(){We=0}function Xn(){this._call=this._time=this._next=null}Xn.prototype=nn.prototype={constructor:Xn,restart:function(t,n,s){if(typeof t!="function")throw new TypeError("callback is not a function");s=(s==null?qn():+s)+(n==null?0:+n),!this._next&&xt!==this&&(xt?xt._next=this:Qt=this,xt=this),this._call=t,this._time=s,Wn()},stop:function(){this._call&&(this._call=null,this._time=1/0,Wn())}};function nn(t,n,s){var i=new Xn;return i.restart(t,n,s),i}function Dr(){qn(),++at;for(var t=Qt,n;t;)(n=We-t._time)>=0&&t._call.call(void 0,n),t=t._next;--at}function Fr(){We=(en=wt.now())+tn,at=kt=0;try{Dr()}finally{at=0,Za(),We=0}}function Va(){var t=wt.now(),n=t-en;n>Lr&&(tn-=n,en=t)}function Za(){for(var t,n=Qt,s,i=1/0;n;)n._call?(i>n._time&&(i=n._time),t=n,n=n._next):(s=n._next,n._next=null,n=t?t._next=s:Qt=s);xt=t,Wn(i)}function Wn(t){if(!at){kt&&(kt=clearTimeout(kt));var n=t-We;n>24?(t<1/0&&(kt=setTimeout(Fr,t-wt.now()-tn)),vt&&(vt=clearInterval(vt))):(vt||(en=wt.now(),vt=setInterval(Va,Lr)),at=1,Ir(Fr))}}function Nr(){let t=1;return()=>(t=(1664525*t+1013904223)%4294967296)/4294967296}function Pr(t){return t.x}function Or(t){return t.y}var Ya=10,Qa=Math.PI*(3-Math.sqrt(5));function Jn(t){var n,s=1,i=.001,r=1-Math.pow(i,1/300),a=0,o=.6,l=new Map,c=nn(m),d=Gn("tick","end"),p=Nr();t==null&&(t=[]);function m(){g(),d.call("tick",n),s<i&&(c.stop(),d.call("end",n))}function g(h){var u,y=t.length,b;h===void 0&&(h=1);for(var v=0;v<h;++v)for(s+=(a-s)*r,l.forEach(function(k){k(s)}),u=0;u<y;++u)b=t[u],b.fx==null?b.x+=b.vx*=o:(b.x=b.fx,b.vx=0),b.fy==null?b.y+=b.vy*=o:(b.y=b.fy,b.vy=0);return n}function f(){for(var h=0,u=t.length,y;h<u;++h){if(y=t[h],y.index=h,y.fx!=null&&(y.x=y.fx),y.fy!=null&&(y.y=y.fy),isNaN(y.x)||isNaN(y.y)){var b=Ya*Math.sqrt(.5+h),v=h*Qa;y.x=b*Math.cos(v),y.y=b*Math.sin(v)}(isNaN(y.vx)||isNaN(y.vy))&&(y.vx=y.vy=0)}}function x(h){return h.initialize&&h.initialize(t,p),h}return f(),n={tick:g,restart:function(){return c.restart(m),n},stop:function(){return c.stop(),n},nodes:function(h){return arguments.length?(t=h,f(),l.forEach(x),n):t},alpha:function(h){return arguments.length?(s=+h,n):s},alphaMin:function(h){return arguments.length?(i=+h,n):i},alphaDecay:function(h){return arguments.length?(r=+h,n):+r},alphaTarget:function(h){return arguments.length?(a=+h,n):a},velocityDecay:function(h){return arguments.length?(o=1-h,n):1-o},randomSource:function(h){return arguments.length?(p=h,l.forEach(x),n):p},force:function(h,u){return arguments.length>1?(u==null?l.delete(h):l.set(h,x(u)),n):l.get(h)},find:function(h,u,y){var b=0,v=t.length,k,S,E,w,C;for(y==null?y=1/0:y*=y,b=0;b<v;++b)w=t[b],k=h-w.x,S=u-w.y,E=k*k+S*S,E<y&&(C=w,y=E);return C},on:function(h,u){return arguments.length>1?(d.on(h,u),n):d.on(h)}}}function Kn(){var t,n,s,i,r=de(-30),a,o=1,l=1/0,c=.81;function d(f){var x,h=t.length,u=Xe(t,Pr,Or).visitAfter(m);for(i=f,x=0;x<h;++x)n=t[x],u.visit(g)}function p(){if(t){var f,x=t.length,h;for(a=new Array(x),f=0;f<x;++f)h=t[f],a[h.index]=+r(h,f,t)}}function m(f){var x=0,h,u,y=0,b,v,k;if(f.length){for(b=v=k=0;k<4;++k)(h=f[k])&&(u=Math.abs(h.value))&&(x+=h.value,y+=u,b+=u*h.x,v+=u*h.y);f.x=b/y,f.y=v/y}else{h=f,h.x=h.data.x,h.y=h.data.y;do x+=a[h.data.index];while(h=h.next)}f.value=x}function g(f,x,h,u){if(!f.value)return!0;var y=f.x-n.x,b=f.y-n.y,v=u-x,k=y*y+b*b;if(v*v/c<k)return k<l&&(y===0&&(y=Ee(s),k+=y*y),b===0&&(b=Ee(s),k+=b*b),k<o&&(k=Math.sqrt(o*k)),n.vx+=y*f.value*i/k,n.vy+=b*f.value*i/k),!0;if(f.length||k>=l)return;(f.data!==n||f.next)&&(y===0&&(y=Ee(s),k+=y*y),b===0&&(b=Ee(s),k+=b*b),k<o&&(k=Math.sqrt(o*k)));do f.data!==n&&(v=a[f.data.index]*i/k,n.vx+=y*v,n.vy+=b*v);while(f=f.next)}return d.initialize=function(f,x){t=f,s=x,p()},d.strength=function(f){return arguments.length?(r=typeof f=="function"?f:de(+f),p(),d):r},d.distanceMin=function(f){return arguments.length?(o=f*f,d):Math.sqrt(o)},d.distanceMax=function(f){return arguments.length?(l=f*f,d):Math.sqrt(l)},d.theta=function(f){return arguments.length?(c=f*f,d):Math.sqrt(c)},d}function Vn(t){var n=de(.1),s,i,r;typeof t!="function"&&(t=de(t==null?0:+t));function a(l){for(var c=0,d=s.length,p;c<d;++c)p=s[c],p.vx+=(r[c]-p.x)*i[c]*l}function o(){if(s){var l,c=s.length;for(i=new Array(c),r=new Array(c),l=0;l<c;++l)i[l]=isNaN(r[l]=+t(s[l],l,s))?0:+n(s[l],l,s)}}return a.initialize=function(l){s=l,o()},a.strength=function(l){return arguments.length?(n=typeof l=="function"?l:de(+l),o(),a):n},a.x=function(l){return arguments.length?(t=typeof l=="function"?l:de(+l),o(),a):t},a}function Zn(t){var n=de(.1),s,i,r;typeof t!="function"&&(t=de(t==null?0:+t));function a(l){for(var c=0,d=s.length,p;c<d;++c)p=s[c],p.vy+=(r[c]-p.y)*i[c]*l}function o(){if(s){var l,c=s.length;for(i=new Array(c),r=new Array(c),l=0;l<c;++l)i[l]=isNaN(r[l]=+t(s[l],l,s))?0:+n(s[l],l,s)}}return a.initialize=function(l){s=l,o()},a.strength=function(l){return arguments.length?(n=typeof l=="function"?l:de(+l),o(),a):n},a.y=function(l){return arguments.length?(t=typeof l=="function"?l:de(+l),o(),a):t},a}function Yn(t,n,s){let i=new Map,r=t.map(c=>{let d=s?.get(c.id),p={...c,deg:0,r:4};return d&&(p.x=d.x,p.y=d.y),i.set(c.id,p),p}),a=[];for(let c of n){let d=i.get(c.src),p=i.get(c.dst);!d||!p||d===p||(d.deg++,p.deg++,a.push({source:d,target:p,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 o=r.length,l=Jn(r).force("link",jn(a).distance(c=>c.kind==="co_changes"?90:c.kind==="defines"?36:60).strength(c=>c.kind==="co_changes"?.15:.5)).force("charge",Kn().strength(o>400?-60:-140).distanceMax(600)).force("collide",zn().radius(c=>c.r+4).iterations(2)).force("center",Bn(0,0).strength(.05)).force("x",Vn(0).strength(.02)).force("y",Zn(0).strength(.02)).alphaDecay(o>400?.05:.03).velocityDecay(.4);return{nodes:r,links:a,sim:l,byId:i}}function Hr(t,n){let s=Yn(t,n);s.sim.stop();let i=s.nodes.filter(x=>x.kind==="file"),r=s.nodes.filter(x=>x.kind!=="file"),a=new Map;for(let x of i){let h=(x.path??x.label).split("/").slice(0,-1).join("/")||".";(a.get(h)??a.set(h,[]).get(h)).push(x)}let o=[...a.keys()].sort((x,h)=>x.split("/").length-h.split("/").length||x.localeCompare(h)),l=220,c=34,d=-(o.length-1)*l/2,p=new Map;for(let x of o){let h=a.get(x).sort((y,b)=>y.label.localeCompare(b.label)),u=-(h.length-1)*c/2;for(let y of h)y.x=d,y.y=u,y.fx=d,y.fy=u,p.set(y.path??y.label,y),u+=c;d+=l}let m=new Map,g=[];for(let x of r){let h=x.path?p.get(x.path):void 0;if(!h){g.push(x);continue}let u=m.get(h.id)??0;m.set(h.id,u+1),x.x=(h.x??0)+70+u%3*46,x.y=(h.y??0)+Math.floor(u/3)*14-8,x.fx=x.x,x.fy=x.y}let f=(o.length?a.get(o[0]).length:0)*c/2+60;for(let x of g)x.x=-(g.length-1)*60/2+g.indexOf(x)*60,x.y=f,x.fx=x.x,x.fy=x.y;return f+=40,s}var Qn=t=>Se(t.kind),es=t=>"circle";function Br(t,n=1){return{color:it(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:Zt.has(t)}}function Ur(t,n,s,i,r){switch(t.beginPath(),n){case"square":{let a=r*.88;t.rect(s-a,i-a,a*2,a*2);break}case"diamond":{let a=r*1.25;t.moveTo(s,i-a),t.lineTo(s+a,i),t.lineTo(s,i+a),t.lineTo(s-a,i),t.closePath();break}case"triangle":{let a=r*1.3;t.moveTo(s,i-a),t.lineTo(s+a*.87,i+a*.5),t.lineTo(s-a*.87,i+a*.5),t.closePath();break}case"hexagon":{let a=r*1.12;for(let o=0;o<6;o++){let l=Math.PI/3*o,c=s+a*Math.cos(l),d=i+a*Math.sin(l);o===0?t.moveTo(c,d):t.lineTo(c,d)}t.closePath();break}default:t.arc(s,i,r,0,Math.PI*2)}}function zr(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 Be({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:zr(t),fill:s?"none":n,stroke:n,"stroke-width":s?1.6:0})})}function ot({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 eo=t=>t.kind==="file"||t.kind==="package"?Vt(t.label):t.label.split(".").pop()??t.label,to=()=>document.documentElement.getAttribute("data-theme")==="dark"||document.documentElement.getAttribute("data-theme")!=="light"&&window.matchMedia("(prefers-color-scheme: dark)").matches;function Fe(t){let n=oe(null),s=oe(null),i=oe(null),r=oe({k:1,x:0,y:0}),a=oe(!1),o=oe(null),l=oe(null),[c,d]=_(null),[p,m]=_(!1),g=oe(t);g.current=t;let f=()=>{let $=n.current,F=i.current;if(!$||!F)return;let T=$.getContext("2d");if(!T)return;let D=window.devicePixelRatio||1,W=$.width/D,q=$.height/D,A=r.current,z=to(),{selected:re,highlight:je}=g.current,P=g.current.colorOf??Qn,ie=g.current.shapeOf??es,ye=g.current.edgeStyleOf??Br,tt=g.current.labelOf??eo,xe=re?F.byId.get(re):void 0,Re=new Set;if(xe){Re.add(xe.id);for(let Q of F.links){let ge=Q.source,ue=Q.target;ge.id===xe.id&&Re.add(ue.id),ue.id===xe.id&&Re.add(ge.id)}}T.setTransform(D,0,0,D,0,0),T.clearRect(0,0,W,q),T.translate(W/2+A.x,q/2+A.y),T.scale(A.k,A.k);for(let Q of F.links){let ge=Q.source,ue=Q.target;if(ge.x===void 0||ue.x===void 0)continue;let Lt=`${ge.id}|${ue.id}|${Q.kind}`,Sn=je?.has(Lt),It=xe&&!(Re.has(ge.id)&&Re.has(ue.id))&&ge.id!==xe.id&&ue.id!==xe.id,Me=ye(Q.kind,Q.weight);if(T.globalAlpha=Sn?1:It?.06:Me.alpha??.45,T.strokeStyle=Me.color,T.lineWidth=(Sn?2.5:Me.width??1)/A.k,T.setLineDash(Me.dash?Me.dash.map(Dt=>Dt/A.k):[]),T.beginPath(),T.moveTo(ge.x,ge.y??0),T.lineTo(ue.x,ue.y??0),T.stroke(),T.setLineDash([]),Me.directed&&A.k>.5){let Dt=ue.x-ge.x,_s=(ue.y??0)-(ge.y??0),Ss=Math.hypot(Dt,_s)||1,gt=Dt/Ss,ft=_s/Ss,Tn=ue.x-gt*(ue.r+2),En=(ue.y??0)-ft*(ue.r+2),Ne=5/A.k;T.fillStyle=Me.color,T.beginPath(),T.moveTo(Tn,En),T.lineTo(Tn-gt*Ne*2-ft*Ne,En-ft*Ne*2+gt*Ne),T.lineTo(Tn-gt*Ne*2+ft*Ne,En-ft*Ne*2-gt*Ne),T.closePath(),T.fill()}}let nt=F.nodes.length<=120||A.k>1.6;T.font=`${11/A.k}px system-ui, sans-serif`,T.textBaseline="middle";for(let Q of F.nodes){if(Q.x===void 0||Q.y===void 0)continue;let ge=xe&&!Re.has(Q.id);T.globalAlpha=ge?.2:1;let ue=ie(Q),Lt=P(Q);if(Ur(T,ue,Q.x,Q.y,Q.r/Math.max(1,A.k**.5)),ue==="ring"?(T.fillStyle=z?"#171a21":"#ffffff",T.fill(),T.lineWidth=1.6/A.k,T.strokeStyle=Lt,T.stroke()):(T.fillStyle=Lt,T.fill()),(Q.root||Q.id===re||Q===o.current)&&(T.lineWidth=2.5/A.k,T.strokeStyle=z?"#e5e7eb":"#1b1f24",T.stroke()),nt||Q.root||Q.deg>3||Re.has(Q.id)||Q===o.current||Q.id===re){let It=tt(Q),Me=Q.x+Q.r/Math.max(1,A.k**.5)+3/A.k;T.lineWidth=3/A.k,T.strokeStyle=z?"#171a21":"#ffffff",T.strokeText(It,Me,Q.y),T.fillStyle=z?"#e5e7eb":"#1b1f24",T.fillText(It,Me,Q.y)}}T.globalAlpha=1},x=()=>{let $=n.current,F=i.current;if(!$||!F?.nodes.length)return;let T=window.devicePixelRatio||1,D=$.width/T,W=$.height/T,q=Number.POSITIVE_INFINITY,A=Number.POSITIVE_INFINITY,z=Number.NEGATIVE_INFINITY,re=Number.NEGATIVE_INFINITY;for(let ye of F.nodes)ye.x===void 0||ye.y===void 0||(q=Math.min(q,ye.x),A=Math.min(A,ye.y),z=Math.max(z,ye.x),re=Math.max(re,ye.y));let je=Math.max(100,z-q+120),P=Math.max(100,re-A+120),ie=Math.min(2.5,Math.min(D/je,W/P));r.current={k:ie,x:-((q+z)/2)*ie,y:-((A+re)/2)*ie},f()};Qs(t.handle??null,()=>({fit:x}),[]);let h=t.nodes.map($=>$.id).join("|"),u=t.edges.map($=>`${$.src}|${$.dst}|${$.kind}`).join(`
3
- `),y=t.mode??"galaxy";j(()=>{let $=t.keepPositions?i.current?.byId:void 0;i.current?.sim.stop();let F=y==="hierarchy"?Hr(t.nodes,t.edges):Yn(t.nodes,t.edges,$);i.current=F,a.current=!1;let T=!1,D=!1,W=0;if(y==="hierarchy"){x();return}return F.sim.on("tick",()=>{W++,(W%2===0||F.sim.alpha()<.05)&&f(),!T&&(W===30||F.sim.alpha()<.3)&&(T=!0,a.current||x())}),F.sim.on("end",()=>{D||(D=!0,T=!0,a.current||x())}),()=>F.sim.stop()},[h,u,y]),j(()=>{f()},[t.selected,t.highlight,c,t.colorOf,t.shapeOf,t.edgeStyleOf]),j(()=>{let $=s.current,F=n.current;if(!$||!F)return;let T=()=>{let A=window.devicePixelRatio||1;F.width=Math.max(1,$.clientWidth*A),F.height=Math.max(1,$.clientHeight*A),f()};T();let D=new ResizeObserver(T);D.observe($);let W=window.matchMedia("(prefers-color-scheme: dark)");W.addEventListener("change",f);let q=new MutationObserver(f);return q.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>{D.disconnect(),W.removeEventListener("change",f),q.disconnect()}},[]);let b=$=>{let T=n.current.getBoundingClientRect(),D=r.current;return{x:($.clientX-T.left-T.width/2-D.x)/D.k,y:($.clientY-T.top-T.height/2-D.y)/D.k}},v=$=>{let F=i.current;if(!F)return null;let T=b($),D=r.current,W=null,q=Number.POSITIVE_INFINITY;for(let A of F.nodes){if(A.x===void 0||A.y===void 0)continue;let z=Math.hypot(A.x-T.x,A.y-T.y),re=A.r/Math.max(1,D.k**.5)+6/D.k;z<re&&z<q&&(q=z,W=A)}return W},k=$=>{let F=v($),T=r.current;l.current={node:F??void 0,px:$.clientX,py:$.clientY,vx:T.x,vy:T.y,moved:!1},F&&(F.fx=F.x,F.fy=F.y,i.current?.sim.alphaTarget(.2).restart()),m(!0),$.preventDefault()},S=$=>{let F=l.current;if(F){let D=$.clientX-F.px,W=$.clientY-F.py;if(Math.abs(D)+Math.abs(W)>3&&(F.moved=!0),F.node){let q=b($);F.node.fx=q.x,F.node.fy=q.y,y==="hierarchy"&&(F.node.x=q.x,F.node.y=q.y,f())}else F.moved&&(a.current=!0),r.current={...r.current,x:F.vx+D,y:F.vy+W},f();return}let T=v($);T!==o.current&&(o.current=T,d(T))},E=$=>{let F=l.current;l.current=null,m(!1),F&&(F.node?(y!=="hierarchy"&&(F.node.fx=null,F.node.fy=null,i.current?.sim.alphaTarget(0)),F.moved||g.current.onSelect?.(F.node.id===g.current.selected?null:F.node.id)):F.moved||g.current.onSelect?.(null))},w=$=>{$.preventDefault();let T=n.current.getBoundingClientRect(),D=r.current;a.current=!0;let W=$.deltaY>0?.9:1.1,q=Math.max(.05,Math.min(8,D.k*W)),A=$.clientX-T.left-T.width/2,z=$.clientY-T.top-T.height/2;r.current={k:q,x:A-(A-D.x)*q/D.k,y:z-(z-D.y)*q/D.k},f()},C=$=>{let F=v($);F&&g.current.onActivate?.(F.id)},R=[...new Set(t.nodes.map($=>$.kind))],M=[...new Set(t.edges.map($=>$.kind))];return e("div",{class:"gwrap",ref:s,children:[e("canvas",{ref:n,class:L(p&&"drag",c&&!p&&"hover"),onMouseDown:k,onMouseMove:S,onMouseUp:E,onMouseLeave:()=>{o.current=null,d(null),l.current&&!l.current.node&&(l.current=null)},onWheel:w,onDblClick:C}),c&&!p&&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:[R.map($=>{let F=t.nodes.find(T=>T.kind===$);return e("span",{children:[t.shapeOf||t.colorOf?e(Be,{shape:(t.shapeOf??es)(F),color:(t.colorOf??Qn)(F)}):e("i",{style:{background:Se($)}}),$]})}),M.map($=>{let F=t.edgeStyleOf?.($,1);return e("span",{children:[F?e(ot,{color:F.color,dash:F.dash}):e("s",{style:{borderColor:it($)}}),$]})})]}),e("button",{type:"button",class:"overlay fit",onClick:x,children:"fit view"})]})}function jr(t,n,s,i,r){let a=t.reduce((x,h)=>x+(h.value??h.size),0);if(!a||!t.length)return[];let o=i*r/a,l=[],c=0,d=n,p=s,m=i,g=r,f=[...t].sort((x,h)=>(h.value??h.size)-(x.value??x.size));for(;c<f.length;){let x=m>=g,h=x?g:m,u=[],y=0,b=Number.POSITIVE_INFINITY;for(;c<f.length;){let S=f[c],E=(S.value??S.size)*o,w=[...u,S],C=y+E,R=Math.max(...w.map(F=>(F.value??F.size)*o)),M=Math.min(...w.map(F=>(F.value??F.size)*o)),$=Math.max(h*h*R/(C*C),C*C/(h*h*M));if($>b&&u.length)break;b=$,u=w,y=C,c++}let v=h?y/h:0,k=0;for(let S of u){let E=v?(S.value??S.size)*o/v:0;l.push(x?{node:S,x:d,y:p+k,w:v,h:E,depth:0}:{node:S,x:d+k,y:p,w:E,h:v,depth:0}),k+=E}x?(d+=v,m-=v):(p+=v,g-=v)}return l}function Gr(t,n,s,i=18){let r=[];for(let a of jr(t.children??[],0,0,n,s))if(r.push({...a,depth:0}),a.node.children?.length&&a.w>40&&a.h>30)for(let o of jr(a.node.children,a.x+2,a.y+i,Math.max(0,a.w-4),Math.max(0,a.h-i-2)))r.push({...o,depth:1});return r}function Xr(t,n,s){let i={name:n||"(project)",path:n,size:0,children:[]},r=new Map([["",i]]),a=l=>{let c=r.get(l);if(c)return c;let d=a(l.includes("/")?l.slice(0,l.lastIndexOf("/")):""),p={name:l.split("/").pop()??l,path:l,size:0,children:[]};return d.children.push(p),r.set(l,p),p};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("/")):"",p=Math.max(1,s(l));a(d).children.push({name:c.split("/").pop()??c,path:l.path,size:p,data:l})}let o=l=>(l.children?.length&&(l.size=l.children.reduce((c,d)=>c+o(d),0)),l.size);return o(i),i}var Wr={typescript:"#2563eb",tsx:"#3b82f6",javascript:"#d97706",python:"#16a34a",go:"#0d9488",php:"#6366f1",other:"#6b7280"};function no(t){let n=Math.max(0,Math.min(1,t)),s=Math.round(37+180*n),i=Math.round(99+20*n),r=Math.round(235+-229*n);return`rgb(${s},${i},${r})`}function so({files:t,arch:n}){let[s,i]=_(""),[r,a]=_("language"),[o,l]=_("loc"),[c,d]=_(null),p=oe(null),[m,g]=_({w:900,h:520});j(()=>{let b=p.current;if(!b)return;let v=new ResizeObserver(()=>g({w:b.clientWidth,h:b.clientHeight}));return v.observe(b),g({w:b.clientWidth,h:b.clientHeight}),()=>v.disconnect()},[]);let f=K(()=>{let b=Xr(t,s,v=>o==="uniform"?1:v.loc||Math.max(1,v.size/40));return Gr(b,m.w,m.h)},[t,s,o,m]),h=c?(b=>t.filter(v=>v.path===b||v.path.startsWith(`${b}/`)))(c):[],u=h.length===1&&h[0]?.path===c?h[0]:void 0,y=n?.entryPoints.filter(b=>b.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:()=>i(""),children:n?.project.name??"project"}),s.split("/").filter(Boolean).map((b,v,k)=>e(N,{children:[e("span",{class:"muted",children:"\u203A"}),e("a",{onClick:()=>i(k.slice(0,v+1).join("/")),children:b})]}))]}),e("span",{class:"spacer"}),e("span",{class:"row tight",children:[e("button",{type:"button",class:L("chip",o==="loc"&&"on"),onClick:()=>l("loc"),children:"size: loc"}),e("button",{type:"button",class:L("chip",o==="uniform"&&"on"),onClick:()=>l("uniform"),children:"uniform"}),e("button",{type:"button",class:L("chip",r==="language"&&"on"),onClick:()=>a("language"),children:"color: language"}),e("button",{type:"button",class:L("chip",r==="heat"&&"on"),onClick:()=>a("heat"),children:"heat"})]})]}),e("div",{class:"treemap",ref:p,children:f.map(b=>{let v=b.node.data,k=!!b.node.children?.length,S=v?r==="heat"?no(v.score):Wr[v.language??"other"]??Wr.other:void 0;return e("div",{class:L("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:S},title:v?`${v.path} \xB7 ${v.loc} loc \xB7 ${v.symbols} symbols \xB7 heat ${v.score.toFixed(2)}`:`${b.node.path} \xB7 ${b.node.size} loc`,onClick:E=>{E.stopPropagation(),d(b.node.path)},onDblClick:E=>{E.stopPropagation(),k?i(b.node.path):v&&O("explore",{file:v.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("div",{class:"card",children:[e("h3",{children:c??"selection"}),u?e(N,{children:[e("div",{class:"row small",children:[e(I,{children:u.language??"?"}),e(I,{children:[u.loc," loc"]}),e(I,{children:[u.symbols," symbols"]}),e(I,{children:["fan-in ",u.fanIn]}),e(I,{children:["heat ",u.score.toFixed(2)]}),e(I,{children:u.status})]}),e("div",{class:"row",style:{marginTop:8},children:[e("button",{type:"button",class:"sm",onClick:()=>O("explore",{file:u.path}),children:"Open source"}),e("button",{type:"button",class:"sm",onClick:()=>O("galaxy",{node:`file:${u.path}`}),children:"Galaxy"})]})]}):h.length?e("div",{class:"row small",children:[e(I,{children:[h.length," files"]}),e(I,{children:[J(h.reduce((b,v)=>b+v.loc,0))," loc"]}),e(I,{children:[h.reduce((b,v)=>b+v.symbols,0)," symbols"]}),e(I,{children:["mean heat ",(h.reduce((b,v)=>b+v.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"}),y.length?e("table",{children:e("tbody",{children:y.map(b=>e("tr",{class:"click",onClick:()=>O("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",children:"none found"})]}),n&&e("div",{class:"card",children:[e("h3",{children:"overview"}),e("div",{class:"row small",children:[e(I,{children:[n.overview.files," files"]}),e(I,{children:[n.overview.symbols," symbols"]}),e(I,{children:[n.overview.edges," edges"]}),Object.entries(n.overview.languages).map(([b,v])=>e(I,{children:[b," ",v]}))]}),n.project.description?e("div",{class:"muted small",style:{marginTop:6},children:n.project.description}):null]})]})]})}function ro(){let t=G(()=>H("/api/routes"),[]);return t.error?e(Z,{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(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?O("explore",{file:s.path,symbol:s.id}):O("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:()=>O("explore",{file:n.file,line:n.line?String(n.line):void 0}),children:[n.file,n.line?`:${n.line}`:""]})})]}))})]})}):e(X,{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(B,{})}function io(){let[t,n]=_("file"),[s,i]=_(""),r=G(()=>H("/api/hotspots",{kind:t,path:s.trim()||void 0,limit:80}),[t,s]),{sorted:a,th:o}=He(r.data,"score"),l={fan_in:Math.max(1,...a.map(c=>c.fan_in)),commits_90d:Math.max(1,...a.map(c=>c.commits_90d)),complexity:Math.max(1,...a.map(c=>c.complexity))};return e(N,{children:[e("div",{class:"row",style:{marginBottom:10},children:[e("button",{type:"button",class:L("chip",t==="file"&&"on"),onClick:()=>n("file"),children:"files"}),e("button",{type:"button",class:L("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=>i(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?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:a.map(c=>e("tr",{class:"click",onClick:()=>c.kind==="file"?O("explore",{file:c.path}):O("explore",{file:c.path.split(" > ")[0],symbol:c.id}),children:[e("td",{class:"break",children:[c.kind!=="file"?e(pe,{kind:c.kind}):null,c.path]}),e("td",{class:"num",children:[e(De,{value:c.fan_in,max:l.fan_in,width:60})," ",c.fan_in]}),e("td",{class:"num",children:[e(De,{value:c.commits_90d,max:l.commits_90d,width:60})," ",c.commits_90d]}),e("td",{class:"num",children:[e(De,{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(B,{})]})}function ao(){let t=G(()=>H("/api/clusters"),[]),[n,s]=_(null),[i,r]=_(null),[a,o]=_(new Set),l=K(()=>{let p=t.data;if(!p)return{nodes:[],edges:[]};let m=[],g=[];if(i!==null){let f=p.cycles[i]??[];for(let x of f)m.push({id:`file:${x}`,label:x,kind:"file",path:x,line:null});for(let x=0;x<f.length;x++)g.push({src:`file:${f[x]}`,dst:`file:${f[(x+1)%f.length]}`,kind:"imports",weight:1});return{nodes:m,edges:g}}for(let f of p.clusters){if(a.has(f.id))for(let x of p.members[String(f.id)]??[])m.push({id:`file:${x.path}`,label:x.path,kind:"file",path:x.path,line:null,score:x.score});if(m.push({id:`cluster:${f.id}`,label:`#${f.id} ${f.label} (${f.size})`,kind:"cluster",path:null,line:null}),a.has(f.id))for(let x of p.members[String(f.id)]??[])g.push({src:`file:${x.path}`,dst:`cluster:${f.id}`,kind:"link",weight:.5});for(let[x,h]of Object.entries(f.links))g.push({src:`cluster:${f.id}`,dst:`cluster:${x}`,kind:"imports",weight:Math.min(1,h/10),count:h})}return{nodes:m,edges:g}},[t.data,i,a]);if(t.error)return e(Z,{error:t.error});let c=t.data;if(!c)return e(B,{});let d=n?.startsWith("cluster:")?c.clusters.find(p=>String(p.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(Fe,{nodes:l.nodes,edges:l.edges,selected:n,onSelect:s,onActivate:p=>{if(p.startsWith("cluster:")){let m=Number(p.slice(8));o(g=>{let f=new Set(g);return f.has(m)?f.delete(m):f.add(m),f})}else p.startsWith("file:")&&O("explore",{file:p.slice(5)})}}):e(X,{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(p=>e("div",{class:L("item",n===`cluster:${p.id}`&&"sel"),onClick:()=>{r(null),s(`cluster:${p.id}`)},children:[e("div",{class:"n",children:["#",p.id," ",p.label," ",e("span",{class:"muted",children:["\xB7 ",p.size," files"]})]}),e("div",{class:"p",children:p.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(p=>e("div",{class:"item",onClick:()=>O("explore",{file:p.path}),children:e("div",{class:"p",children:[p.path," ",e("span",{class:"muted",children:["\xB7 heat ",p.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((p,m)=>e("div",{class:L("item",i===m&&"sel"),onClick:()=>{r(i===m?null:m),s(null)},children:e("div",{class:"p",children:[p.length," files: ",p.slice(0,4).join(" \u2192 "),p.length>4?" \u2026":""]})}))}):e("div",{class:"muted small",children:"none"}),i!==null?e("button",{type:"button",class:"sm",style:{marginTop:6},onClick:()=>r(null),children:"show clusters"}):null]})]})]})}function qr({id:t,depth:n,onSelect:s,selected:i}){let r=G(()=>H("/api/behavior",{id:t}),[t]),[a,o]=_(new Set);if(r.error)return e("div",{class:"muted small",children:r.error});if(!r.data)return e(B,{});let l=r.data;return e(N,{children:[n===0&&e("div",{class:L("bnode",i===l.root.id&&"sel"),onClick:()=>s(l),children:[e(I,{children:"start"}),e(pe,{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=a.has(c.node.id);return e(N,{children:[e("div",{class:L("bnode",i===c.node.id&&"sel"),onClick:()=>s({root:c.node,callees:[]}),children:[e("span",{class:"arrow",onClick:p=>{p.stopPropagation(),o(m=>{let g=new Set(m);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":d?"\u25BE":"\u25B8"}),e(I,{children:c.kind==="handles"?"handles":"possible call"}),e(pe,{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(qr,{id:c.node.id,depth:n+1,onSelect:s,selected:i}):null]})}):e("div",{class:"muted small",style:{padding:"2px 6px"},children:"no resolved calls"})})]})}function oo({params:t}){let[n,s]=_(t.node??null),[i,r]=_(""),[a,o]=_([]),[l,c]=_(null);return j(()=>{if(i.trim().length<2)return o([]);let d=setTimeout(()=>{H("/api/nodes/search",{q:i.trim(),limit:10}).then(p=>o(p.filter(m=>m.kind!=="file"&&m.kind!=="package"))).catch(()=>o([]))},180);return()=>clearTimeout(d)},[i]),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:i,onInput:d=>r(d.target.value),style:{width:320}}),a.length>0&&e("div",{class:"suggest",style:{top:36,left:40},children:a.map(d=>e("div",{onMouseDown:()=>{s(d.id),r(""),o([]),c(null)},children:[e(pe,{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(qr,{id:n,depth:0,onSelect:c,selected:l?.root.id??null}):e(X,{children:"Choose a starting operation."})})]}),e("div",{class:"card",children:[e("h3",{children:l?"selected operation":"starting operation"}),l?e(N,{children:[e("div",{class:"row tight",children:[e(pe,{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:()=>O("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:()=>O("galaxy",{node:l.root.id}),children:"Galaxy"})]})]}):e("div",{class:"muted small",children:"Click an operation in the tree."})]})]})}function Jr({params:t}){let[n,s]=_(t.tab||"overview");j(()=>{t.tab&&s(t.tab)},[t.tab]);let i=G(()=>H("/api/tree"),[]),r=G(()=>H("/api/architecture",{aspects:"overview,entry_points"}),[]);return e("div",{class:"page",children:[e(we,{tabs:[["overview","Overview"],["routes","Routes"],["hotspots","Hotspots"],["structure","System structure"],["behavior","Behavior"]],value:n,onChange:s}),n==="overview"&&(i.data?e(so,{files:i.data.files,arch:r.data}):i.error?e(Z,{error:i.error}):e(B,{})),n==="routes"&&e(ro,{}),n==="hotspots"&&e(io,{}),n==="structure"&&e(ao,{}),n==="behavior"&&e(oo,{params:t})]})}function Kr(){let t=G(()=>H("/api/coverage"),[]),[n,s]=_(""),[i,r]=_(""),[a,o]=_(null),l=K(()=>{let u=i.trim().toLowerCase();return(t.data?.files??[]).filter(y=>(!n||y.status===n)&&(!u||y.path.toLowerCase().includes(u)||(y.reason??"").toLowerCase().includes(u)))},[t.data,n,i]),{sorted:c,th:d}=He(l,"path",!1),p=async(u,y)=>{o(u);try{let b=await ve("/api/actions",y);Y(b.output.split(`
4
- `)[0]??"done",!b.ok),t.reload()}catch(b){Y(b.message,!0)}finally{o(null)}};if(t.error)return e("div",{class:"page",children:e(Z,{error:t.error})});let m=t.data;if(!m)return e("div",{class:"page",children:e(B,{})});let g=m.summary.byStatus,f=Object.values(g).reduce((u,y)=>u+y,0),x=m.freshness.headMatches&&!m.freshness.dirty.length&&!m.freshness.queued,h=[["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"]];return e("div",{class:"page",children:[e("div",{class:"grid",children:[h.map(([u,y,b])=>e("div",{class:L("card"),style:{cursor:"pointer"},onClick:()=>s(n===u?"":u),children:[e("h3",{children:[u,n===u?e("span",{class:"right",children:"filtering"}):null]}),e("div",{class:L("big",u==="skipped"&&y>0&&"bad",u==="partial"&&y>0&&"warn"),children:y}),e("div",{class:"sub",children:b})]})),e("div",{class:"card",children:[e("h3",{children:"freshness"}),e("div",{class:L("big",x?"ok":"warn"),children:x?"fresh":m.freshness.dirty.length||m.freshness.queued?"stale":"git behind"}),e("div",{class:"sub",children:[m.freshness.dirty.length," changed \xB7 ",m.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 ",f]})]}),e("div",{class:"row",style:{marginBottom:8},children:[e("input",{type:"search",class:"grow",placeholder:"filter by path or reason\u2026",value:i,onInput:u=>r(u.target.value)}),e("select",{value:n,onChange:u=>s(u.target.value),children:[e("option",{value:"",children:"any status"}),["indexed","partial","skipped","unsupported"].map(u=>e("option",{value:u,children:u}))]}),e("button",{type:"button",disabled:!!a,onClick:()=>p("code",{action:"reindex",scope:"code"}),children:a==="code"?e(B,{}):"Reindex code"}),e("button",{type:"button",disabled:!!a,onClick:()=>p("full",{action:"reindex",scope:"code",full:!0}),children:a==="full"?e(B,{}):"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(u=>e("tr",{children:[e("td",{class:"break",children:e("a",{onClick:()=>O("explore",{file:u.path}),children:u.path})}),e("td",{children:e(I,{class:u.status==="indexed"?"s-accepted":u.status==="partial"?"s-proposed":"risk-high",children:u.status})}),e("td",{class:"muted small",children:[u.reason??"",u.errors?e("div",{class:"bad small",children:u.errors.slice(0,160)}):null]}),e("td",{class:"num",children:u.symbols??""}),e("td",{class:"num",children:J(u.size??0)}),e("td",{class:"num muted small",children:ne(u.indexed_at)}),e("td",{children:e("button",{type:"button",class:"sm",disabled:!!a,onClick:()=>p(u.path,{action:"reindex",scope:"code",paths:[u.path]}),children:a===u.path?e(B,{}):"reindex"})})]})):e("tr",{children:e("td",{colSpan:7,children:e(X,{children:"no files match"})})})})]})})]}),e("div",{class:"stack",children:[e("div",{class:"card",children:[e("h3",{children:"index state"}),e(Oe,{rows:[["HEAD",m.freshness.head?.slice(0,10)??"no git"],["git signals at",m.freshness.indexedHead?`${m.freshness.indexedHead.slice(0,10)}${m.freshness.headMatches?" (current)":" (behind)"}`:"never"],["last run",m.freshness.lastRun?ne(m.freshness.lastRun):"never"],["queued",String(m.freshness.queued)],["last scan",m.scan?.at?`${ne(m.scan.at)} \xB7 ${m.scan.scanned} files \xB7 ${m.scan.durationMs} ms`:"n/a"]]})]}),m.freshness.dirty.length?e("div",{class:"card",children:[e("h3",{children:["changed since indexed \xB7 ",m.freshness.dirty.length]}),e("div",{class:"list",style:{maxHeight:200},children:m.freshness.dirty.map(u=>e("div",{class:"item",onClick:()=>O("explore",{file:u}),children:e("div",{class:"p",children:u})}))}),e("button",{type:"button",class:"sm",style:{marginTop:6},disabled:!!a,onClick:()=>p("dirty",{action:"reindex",scope:"code",paths:m.freshness.dirty}),children:a==="dirty"?e(B,{}):"Reindex changed files"})]}):null,m.summary.reasons.length?e("div",{class:"card",children:[e("h3",{children:"why files are not fully indexed"}),e("table",{children:e("tbody",{children:m.summary.reasons.map(u=>e("tr",{class:"click",onClick:()=>r(u.reason),children:[e("td",{children:u.reason}),e("td",{class:"num",children:u.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:(m.scan?.include??[]).join(" ")||"(defaults)"}),e("div",{class:"muted",style:{marginTop:4},children:"exclude"}),e("div",{class:"mono break",children:(m.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 _t=[{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"}],Vr=new Map(_t.map(t=>[t.id,t]));function sn(t){return Vr.get(t)??Vr.get("local")}var Zr={project:"Project documentation",external:"External documentation"};function ts(t){let n=_t.findIndex(s=>s.id===t);return n===-1?_t.length:n}function lt({title:t,rows:n,label:s,onPick:i,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(a=>e("tr",{class:"click",onClick:()=>i(a.id),children:[e("td",{children:e(I,{children:a.kind})}),e("td",{class:"break",children:s(a.id)})]}))})}),n.length>r?e("div",{class:"muted small",children:["\u2026 ",n.length-r," more"]}):null]})}function lo(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 rn(t,n){let s=new Set(t.nodes.filter(o=>lo(o,n)).map(o=>o.id)),i=t.edges.filter(o=>!n.hiddenEdges.has(o.kind)&&s.has(o.src)&&s.has(o.dst)),r=new Set(i.flatMap(o=>[o.src,o.dst]));return{nodes:t.nodes.filter(o=>s.has(o.id)&&(o.seed||o.root||r.has(o.id))),edges:i}}function qe(t,n){let s=new Map;for(let i of t)s.set(n(i),(s.get(n(i))??0)+1);return s}var co={memory:"diamond",doc:"square",tag:"triangle",topic:"hexagon"};function an(t){return t.missing?"ring":co[t.kind]??"circle"}function on(t){let n=t;return n.group==="memory"&&(n.status==="superseded"||n.status==="deprecated")?"#93c5fd":Se(t.kind)}function St(t){let n={links:[4,3],supersedes:[6,3],about:[2,3],tagged:[1,3],in_topic:[1,3]};return{color:it(t),dash:n[t],width:t==="documents"||t==="mentions"?1.4:1,alpha:t==="tagged"||t==="in_topic"?.35:.55,directed:Zt.has(t)}}function Yr(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 uo=["proposed","accepted","superseded","deprecated"],po=["memory","doc","topic","tag","file","package"],mo=["mentions","links","supersedes","documents","about","tagged","in_topic"],ho={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"},Qr=(t,n)=>[...t].sort((s,i)=>{let r=n.indexOf(s),a=n.indexOf(i);return(r===-1?99:r)-(a===-1?99:a)||s.localeCompare(i)});function ei(t,n){let s=new Set(t);return s.has(n)?s.delete(n):s.add(n),s}function ln({scope:t,focus:n}){let s=t==="docs"?"docs":"memory",[i,r]=_(null),[a,o]=_(!1),[l,c]=_(0),[d,p]=_(new Set),[m,g]=_(new Set),[f,x]=_(""),[h,u]=_(""),[y,b]=_(t==="memory"),[v,k]=_(!1),[S,E]=_(n??null);j(()=>{let P=!0;return o(!0),H("/api/knowledge",{scope:t,focus:n,limit:300}).then(ie=>{P&&(r(ie),E(n??null))}).catch(ie=>P&&Y(ie.message,!0)).finally(()=>P&&o(!1)),()=>{P=!1}},[t,n,l]);let w=K(()=>i?rn(i,{hiddenKinds:d,hiddenEdges:m,status:f,category:h,hideSuperseded:y}):null,[i,d,m,f,h,y]),C=K(()=>qe(i?.nodes??[],P=>P.kind),[i]),R=K(()=>qe(i?.edges??[],P=>P.kind),[i]),M=P=>i?.nodes.find(ie=>ie.kind===P&&!ie.missing),$=K(()=>[...new Set((i?.nodes??[]).filter(P=>P.group==="doc"&&P.sub).map(P=>P.sub))],[i]),F=(i?.nodes??[]).some(P=>P.group==="memory"),T=K(()=>new Map((i?.nodes??[]).map(P=>[P.id,P])),[i]),D=S?T.get(S):void 0,W=w?.edges??[],q=D?W.filter(P=>P.dst===D.id):[],A=D?W.filter(P=>P.src===D.id):[],z=P=>T.get(P)?.label??P,re=P=>O(s,{tab:"graph",focus:P}),je=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:je?.label??n}),e("button",{type:"button",class:"sm",onClick:()=>O(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"}),F?e(N,{children:[e("select",{value:f,title:"memory status",onChange:P=>x(P.target.value),children:[e("option",{value:"",children:"any status"}),uo.map(P=>e("option",{value:P,children:P}))]}),e("button",{type:"button",class:L("chip",y&&"on"),onClick:()=>b(!y),children:"hide superseded"})]}):null,$.length?e("select",{value:h,title:"doc category",onChange:P=>u(P.target.value),children:[e("option",{value:"",children:"any category"}),$.map(P=>e("option",{value:P,children:sn(P).label}))]}):null,e("button",{type:"button",class:L("chip",v&&"on"),onClick:()=>k(!v),children:"legend"}),e("button",{type:"button",class:"sm",title:"reload",onClick:()=>c(P=>P+1),children:"\u21BB"}),e("span",{class:"count",children:a?e(B,{}):w&&i?`${w.nodes.length} of ${i.nodes.length} nodes \xB7 ${w.edges.length} edges${i.truncated?` \xB7 first ${i.nodes.length} of ${i.total}`:""}`:""})]}),e("div",{class:"gtoolbar",style:{paddingTop:4,paddingBottom:6},children:[e("span",{class:"muted small",children:"nodes:"}),Qr([...C.keys()],po).map(P=>{let ie=M(P);return e("button",{type:"button",class:L("chip",!d.has(P)&&"on"),onClick:()=>p(ei(d,P)),children:[ie?e(Be,{shape:an(ie),color:on(ie)}):null,P," ",C.get(P)]})}),e("span",{class:"muted small",style:{marginLeft:8},children:"edges:"}),Qr([...R.keys()],mo).map(P=>{let ie=St(P);return e("button",{type:"button",title:ho[P],class:L("chip",!m.has(P)&&"on"),onClick:()=>g(ei(m,P)),children:[e(ot,{color:ie.color,dash:ie.dash}),P," ",R.get(P)]})})]}),e("div",{class:"kbody",style:{gridTemplateColumns:D?"minmax(0,1fr) 320px":"minmax(0,1fr)"},children:[e("div",{style:{minWidth:0,minHeight:0},children:w?w.nodes.length?e(Fe,{nodes:w.nodes,edges:w.edges,selected:S,onSelect:E,onActivate:re,legend:v,colorOf:on,shapeOf:an,edgeStyleOf:St,labelOf:Yr}):i?.nodes.length?e(X,{children:"Nothing left after these filters."}):t==="docs"?e(X,{children:"No documentation sources yet. Add some from Discover."}):e(X,{children:"No memories yet."}):e(X,{children:e(B,{})})}),D&&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(go,{node:D,focus:n,onFocus:re}),e(lt,{title:"incoming",rows:q.map(P=>({kind:P.kind,id:P.src})),label:z,onPick:E}),e(lt,{title:"outgoing",rows:A.map(P=>({kind:P.kind,id:P.dst})),label:z,onPick:E})]})]})]})]})}function go({node:t,focus:n,onFocus:s}){let i=t.group==="hub";return e("div",{class:"section",children:[e("div",{class:"row tight",children:[e(Be,{shape:an(t),color:on(t)}),e(pe,{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("span",{class:`tag s-${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:()=>O("memory",{name:t.label}),children:"Open memory"}):null,t.group==="doc"&&!t.missing?e("button",{type:"button",class:"sm",onClick:()=>O("docs",{tab:"sources",name:t.label}),children:"Open doc source"}):null,!i&&!t.missing?e("button",{type:"button",class:"sm",onClick:()=>O("galaxy",{node:t.id}),children:"Open in code galaxy"}):null,t.kind==="file"&&t.path&&!t.missing?e("button",{type:"button",class:"sm",onClick:()=>O("explore",{file:t.path}),children:"Open source"}):null]})]})}var fo={url:"#2563eb",path:"#16a34a"},bo={catalog:"#16a34a",probe:"#2563eb",registry:"#d97706",unknown:"#6b7280"};function ni({kind:t}){return e("span",{class:"tag kind",style:{color:fo[t]??"#6b7280"},children:t})}function si({urls:t}){return e("span",{class:"break",children:t.map((n,s)=>e(N,{children:[s?", ":"",e("a",{href:n,target:"_blank",rel:"noreferrer",children:n})]}))})}function yo({s:t,busy:n,onSync:s,onRemove:i}){let r=G(()=>H("/api/docs/pages",{name:t.name}),[t.name,t.sync?.at]),a=[["kind",e(ni,{kind:t.kind})],...t.provider?[["provider",t.provider]]:[],...t.title?[["title",t.title]]:[],t.kind==="url"?["seeds",e(si,{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?`${ne(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(B,{}):"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:()=>O("docs",{tab:"graph",focus:`doc:${t.name}`}),children:"graph"}),e("button",{type:"button",class:"sm danger",disabled:!!n,onClick:i,children:"remove"})]}),e(Oe,{rows:a}),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(o=>e("tr",{children:[e("td",{class:"break",children:o.uri?.startsWith("http")?e("a",{href:o.uri,target:"_blank",rel:"noreferrer",children:o.title}):o.title}),e("td",{class:"num",children:o.chunks}),e("td",{class:"muted nowrap",children:fe(o.created_at)})]}))})]}):e(X,{children:"nothing indexed yet \u2014 run sync"}):e(B,{})]})}function vo({onDone:t}){let[n,s]=_(""),[i,r]=_(""),[a,o]=_(""),[l,c]=_(""),[d,p]=_(""),[m,g]=_(""),[f,x]=_(""),[h,u]=_(""),[y,b]=_(!1);return e("div",{class:"card",children:[e("h3",{children:"add a source"}),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:i,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:d,onInput:k=>p(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:a,onInput:k=>o(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:m,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:f,onInput:k=>x(k.target.value)})]}),e("div",{class:"field",children:[e("label",{children:"tags"}),e("input",{type:"text",value:h,onInput:k=>u(k.target.value)})]})]}),e("div",{class:"row",children:e("button",{type:"button",class:"primary",disabled:y,onClick:async()=>{let k=i.split(/\s+/).map(S=>S.trim()).filter(Boolean);if(!k.length&&!a.trim()&&!d.trim())return Y("give a url, a path or a provider",!0);b(!0);try{let S=await ve("/api/docs",{sources:[{name:n.trim()||void 0,urls:k.length?k:void 0,path:a.trim()||void 0,glob:l.trim()?l.split(",").map(E=>E.trim()).filter(Boolean):void 0,provider:d.trim()||void 0,crawl:m||f?{depth:m?Number(m):void 0,maxPages:f?Number(f):void 0}:void 0,tags:h.trim()?h.split(",").map(E=>E.trim()).filter(Boolean):void 0}],sync:!0});Y(S.failed.length?S.failed[0].reason:`added ${[...S.added,...S.updated].join(", ")}`,!!S.failed.length),t(S),S.failed.length||(s(""),r(""),o(""),c(""),p(""))}catch(S){Y(S.message,!0)}finally{b(!1)}},children:y?e(B,{}):"Add & index"})})]})}function ns(t){let n=t.tags?.[0];return t.kind==="path"&&n&&(t.name===n||t.name.startsWith(`${n}-`))?n:t.name}function ti(t){if(t.kind==="path"){let s=t.path&&t.path!=="."?t.path:"",i=t.glob?.length?t.glob.length<=2?t.glob.join(", "):`${t.glob.length} globs`:"";return[s,i].filter(Boolean).join(" \xB7 ")||t.title||"project root"}return[...new Set((t.urls??[]).map(s=>s.replace(/^https?:\/\//,"").split("/")[0]))].join(", ")||t.provider||""}function ko({s:t,sel:n,onSelect:s}){let i=ns(t);return e("div",{class:L("item",n&&"sel"),onClick:s,children:[e("div",{class:"n",children:[i,i!==t.name?e("span",{class:"muted small",children:[" ",t.name]}):null]}),e("div",{class:"p",title:t.kind==="url"?(t.urls??[]).join(`
6
- `):ti(t),children:[e(ni,{kind:t.kind}),t.provider?e("span",{class:"muted",children:[t.provider," \xB7 "]}):null,e("span",{class:"muted",children:ti(t)})]}),e("div",{class:"p",children:e("span",{class:"muted",children:[t.documents," docs \xB7 ",t.chunks," chunks \xB7"," ",t.sync?`synced ${ne(t.sync.at)}`:"never synced",t.sync?.errors.length?e("span",{class:"bad",children:[" \xB7 ",t.sync.errors.length," errors"]}):null]})})]})}function xo({params:t,onLog:n}){let s=G(()=>H("/api/docs"),[]),[i,r]=_(t.name??null),[a,o]=_(""),[l,c]=_(!1),[d,p]=_(null);j(()=>{t.name&&r(t.name)},[t.name]);let[m,g]=_("all"),[f,x]=_(new Set),h=s.data,u=K(()=>{let w=a.trim().toLowerCase();return(h?.sources??[]).filter(C=>(m==="all"||C.category===m)&&(!w||C.name.includes(w)||(C.title??"").toLowerCase().includes(w)||(C.provider??"").includes(w)||(C.tags??[]).some(R=>R.includes(w))||(C.urls??[]).some(R=>R.includes(w))||(C.path??"").includes(w)))},[h,a,m]),y=K(()=>{let w=new Map;for(let C of h?.sources??[])w.set(C.category,(w.get(C.category)??0)+1);return w},[h]),b=K(()=>{let w=new Map;for(let M of u){let $=w.get(M.category)??[];$.push(M),w.set(M.category,$)}let C=[...w.entries()].sort((M,$)=>ts(M[0])-ts($[0])).map(([M,$])=>({info:sn(M),items:$.sort((F,T)=>ns(F).localeCompare(ns(T)))})),R=[];for(let M of C){let $=R[R.length-1];$?.group===M.info.group?$.cats.push(M):R.push({group:M.info.group,label:Zr[M.info.group],cats:[M]})}return R},[u]),v=w=>x(C=>{let R=new Set(C);return R.has(w)?R.delete(w):R.add(w),R}),k=u.find(w=>w.name===i)??h?.sources.find(w=>w.name===i),S=async(w,C)=>{let R=w?.length===1?`sync ${w[0]}`:"sync all";p(R);try{let M=await ve("/api/docs/sync",{names:w,force:C});n(M.text),Y(`${R} done`),s.reload()}catch(M){Y(M.message,!0)}finally{p(null)}},E=async w=>{if(confirm(`Remove documentation source "${w}" and its indexed pages?`))try{let C=await Kt("/api/docs",{name:w});Y(`removed ${w} (${C.documents} document(s))`),r(null),s.reload()}catch(C){Y(C.message,!0)}};return s.error?e(Z,{error:s.error}):e(N,{children:[e("div",{class:"row",style:{marginBottom:12},children:[e("button",{type:"button",class:"primary",onClick:()=>c(w=>!w),children:l?"close":"+ Add source"}),e("button",{type:"button",disabled:!!d||!h?.sources.length,onClick:()=>S(void 0,!1),children:d==="sync all"?e(B,{}):"\u21BB Sync all"}),e("input",{type:"search",class:"grow",placeholder:"filter by name, provider, tag or url\u2026",value:a,onInput:w=>o(w.target.value)}),e("span",{class:"muted small nowrap",children:h?`${h.sources.length} sources \xB7 ${J(h.totals.documents)} docs \xB7 ${J(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:L("chip",m==="all"&&"on"),onClick:()=>g("all"),children:["All \xB7 ",h.sources.length]}),_t.filter(w=>y.get(w.id)).map(w=>e("button",{type:"button",class:L("chip",m===w.id&&"on"),title:w.blurb,onClick:()=>g(m===w.id?"all":w.id),children:[w.label," \xB7 ",y.get(w.id)]}))]}):null,l&&e(vo,{onDone:w=>{n(w.text),s.reload();let C=[...w.added,...w.updated][0];C&&r(C)}}),h?.orphans.length?e("div",{class:"empty",style:{marginBottom:12},children:["indexed under docs: but missing from the manifest:"," ",h.orphans.map(w=>`${w.source} (${w.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?u.length?b.map(w=>e(N,{children:[b.length>1?e("div",{class:"group-h",children:w.label}):null,w.cats.map(({info:C,items:R})=>{let M=!f.has(C.id);return e(N,{children:[e("div",{class:L("cat-h",!M&&"closed"),title:C.blurb,onClick:()=>v(C.id),children:[e("span",{class:"caret",children:M?"\u25BE":"\u25B8"}),C.label,e("span",{class:"muted",children:[" \xB7 ",R.length]}),e("span",{class:"muted small right",children:[J(R.reduce(($,F)=>$+F.documents,0))," docs"]})]}),M?R.map($=>e(ko,{s:$,sel:i===$.name,onSelect:()=>r($.name)})):null]})})]})):e(X,{children:h.sources.length?"no sources match":"No documentation sources yet. Use Discover, or add a url, path or provider."}):e(X,{children:e(B,{})})})}),e("div",{class:"card",children:k?e(yo,{s:k,busy:d,onSync:w=>S([k.name],w),onRemove:()=>E(k.name)}):e(X,{children:"Select a source to see its pages and sync state."})})]})]})}function wo({onLog:t,onAdded:n}){let[s,i]=_(!1),[r,a]=_(!1),o=G(()=>r?H("/api/docs/discover",{dev:s?1:void 0}):Promise.resolve(void 0),[r,s]),[l,c]=_(new Set),[d,p]=_({}),[m,g]=_(!1),f=o.data;j(()=>{if(!f)return;let v=new Set;for(let k of f.local)k.registered||v.add(`local:${k.name}`);for(let k of f.providers)!k.registered&&(k.confidence==="probe"||k.confidence==="catalog"&&k.tier!=="library"&&k.tier!=="infra")&&v.add(`prov:${k.name}`);c(v)},[f]);let x=v=>c(k=>{let S=new Set(k);return S.has(v)?S.delete(v):S.add(v),S}),h=async()=>{if(!f)return;let v=[];for(let k of f.local)l.has(`local:${k.name}`)&&v.push({name:k.name,path:k.path,glob:k.glob,title:k.why,tags:k.project?[k.project]:void 0});for(let k of f.providers){if(!l.has(`prov:${k.name}`))continue;let S=d[k.name]?.trim(),E=S?S.split(/\s+/).filter(Boolean):k.urls.length?k.urls:void 0;!E&&k.confidence==="unknown"||v.push({name:k.name,provider:k.provider,urls:E,title:k.title,crawl:k.crawl})}if(!v.length)return Y("nothing selected",!0);g(!0),t(`adding ${v.length} source(s)\u2026`);try{let k=await ve("/api/docs",{sources:v,sync:!0});t(k.text),Y(`${k.added.length+k.updated.length} added${k.failed.length?`, ${k.failed.length} failed`:""}`,!!k.failed.length&&!k.added.length),n(),a(!1),setTimeout(()=>a(!0),0)}catch(k){Y(k.message,!0)}finally{g(!1)}},u=v=>(f?.providers??[]).filter(k=>k.confidence===v),y=({keyId:v,title:k,meta:S,right:E,registered:w})=>e("tr",{class:L(w&&"muted"),children:[e("td",{style:{width:24},children:e("input",{type:"checkbox",disabled:w,checked:l.has(v),onChange:()=>x(v)})}),e("td",{class:"break",children:[k,w?e("span",{class:"tag",children:" registered"}):null]}),e("td",{class:"break muted small",children:S}),e("td",{children:E??null})]}),b=({conf:v,note:k})=>{let S=u(v);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:bo[v]},children:v})," ",v==="catalog"?"libraries, services and infrastructure":v==="probe"?"third-party APIs called from code":v==="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:S.map(E=>e(y,{keyId:`prov:${E.name}`,registered:E.registered,title:e(N,{children:[e("b",{children:E.name})," ",e("span",{class:"muted small",children:["\u2190 ",E.provider]})]}),meta:e(N,{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(N,{children:[" \xB7 ",e(si,{urls:E.urls.slice(0,2)})]}):v==="probe"||v==="unknown"?` \xB7 ${E.evidence[0]}`:""]}),right:v==="unknown"||v==="probe"?e("input",{type:"text",placeholder:v==="probe"?"docs url (optional; probed if empty)":"docs url",style:{minWidth:220},value:d[E.name]??"",onInput:w=>p({...d,[E.name]:w.target.value})}):void 0}))})})]}):null};return e(N,{children:[e("div",{class:"row",style:{marginBottom:12},children:[e("button",{type:"button",class:"primary",disabled:o.loading&&r,onClick:()=>r?o.reload():a(!0),children:o.loading&&r?e(B,{}):r?"\u21BB Scan again":"Scan project"}),e("label",{class:"small",children:[e("input",{type:"checkbox",checked:s,onChange:v=>i(v.target.checked)})," ","include devDependencies"]}),e("span",{class:"spacer"}),f?e(N,{children:[e("span",{class:"muted small",children:[f.projects.length>1?`${f.projects.length} projects \xB7 `:"",f.local.length," local \xB7 ",f.providers.length," providers \xB7 ",l.size," selected"]}),e("button",{type:"button",class:"primary",disabled:m||!l.size,onClick:h,children:m?e(B,{}):"Add selected & index"})]}):null]}),o.error?e(Z,{error:o.error}):null,r?f?e(N,{children:[f.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:f.local.map(v=>e(y,{keyId:`local:${v.name}`,registered:v.registered,title:e(N,{children:[e("b",{children:v.name})," ",e("span",{class:"muted small",children:v.path})]}),meta:`${v.files} file(s) \xB7 ${J(v.bytes)} B \xB7 ${v.why}${v.glob&&v.glob.length<=4?` \xB7 ${v.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(B,{}):e(X,{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 _o({sources:t}){let[n,s]=_(""),[i,r]=_(""),[a,o]=_(""),l=G(()=>a?H("/api/search",{q:a,source:i?`docs:${i}`:"docs:*",limit:15}):Promise.resolve(void 0),[a,i]);return e(N,{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:i,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:()=>o(n.trim()),children:"Search"})]}),l.error?e(Z,{error:l.error}):null,a?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,{children:"no matches"}):e(B,{}):e(X,{children:"Searches only the documentation sources (source docs:*). Claude uses the same index through em_docs lookup."})]})}function ri({params:t}){let[n,s]=_(t.tab??"sources"),[i,r]=_([]),[a,o]=_(0),l=G(()=>H("/api/docs"),[a]),c=d=>r(p=>[...p,`[${new Date().toLocaleTimeString()}]
7
- ${d}`]);return j(()=>{t.tab&&s(t.tab)},[t.tab]),e("div",{class:"page",children:[e(we,{tabs:[["sources","Sources"],["discover","Discover"],["search","Search"],["graph","Graph"]],value:n,onChange:d=>{s(d),O("docs",{tab:d})}}),n==="sources"&&e(xo,{params:t,onLog:c},a),n==="discover"&&e(wo,{onLog:c,onAdded:()=>o(d=>d+1)}),n==="search"&&e(_o,{sources:(l.data?.sources??[]).map(d=>d.name)}),n==="graph"&&e(ln,{scope:"docs",focus:t.focus}),i.length?e("div",{class:"card",style:{marginTop:12},children:[e("h3",{children:["sync log"," ",e("button",{type:"button",class:"sm right",onClick:()=>r([]),children:"clear"})]}),e("pre",{class:"log",children:i.join(`
1
+ "use strict";(()=>{var so=Object.create;var jn=Object.defineProperty;var ro=Object.getOwnPropertyDescriptor;var ao=Object.getOwnPropertyNames;var io=Object.getPrototypeOf,oo=Object.prototype.hasOwnProperty;var Js=t=>{throw TypeError(t)};var lo=(t,n,s)=>n in t?jn(t,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[n]=s;var co=(t,n)=>()=>(n||t((n={exports:{}}).exports,n),n.exports);var uo=(t,n,s,a)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of ao(n))!oo.call(t,r)&&r!==s&&jn(t,r,{get:()=>n[r],enumerable:!(a=ro(n,r))||a.enumerable});return t};var po=(t,n,s)=>(s=t!=null?so(io(t)):{},uo(n||!t||!t.__esModule?jn(s,"default",{value:t,enumerable:!0}):s,t));var ae=(t,n,s)=>lo(t,typeof n!="symbol"?n+"":n,s),mo=(t,n,s)=>n.has(t)||Js("Cannot "+s);var qs=(t,n,s)=>n.has(t)?Js("Cannot add the same private member more than once"):n instanceof WeakSet?n.add(t):n.set(t,s);var Ks=(t,n,s)=>(mo(t,n,"access private method"),s);var $a=co((Dm,xn)=>{"use strict";var ul=typeof window<"u"?window:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?self:{};var X=(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 h(p){return p instanceof i?new i(p.type,h(p.content),p.alias):Array.isArray(p)?p.map(h):p.replace(/&/g,"&amp;").replace(/</g,"&lt;").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(p,b){b=b||{};var y,v;switch(r.util.type(p)){case"Object":if(v=r.util.objId(p),b[v])return b[v];y={},b[v]=y;for(var w in p)p.hasOwnProperty(w)&&(y[w]=h(p[w],b));return y;case"Array":return v=r.util.objId(p),b[v]?b[v]:(y=[],b[v]=y,p.forEach(function(S,T){y[T]=h(S,b)}),y);default:return p}},getLanguage:function(h){for(;h;){var p=n.exec(h.className);if(p)return p[1].toLowerCase();h=h.parentElement}return"none"},setLanguage:function(h,p){h.className=h.className.replace(RegExp(n,"gi"),""),h.classList.add("language-"+p)},currentScript:function(){if(typeof document>"u")return null;if(document.currentScript&&document.currentScript.tagName==="SCRIPT")return document.currentScript;try{throw new Error}catch(y){var h=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(y.stack)||[])[1];if(h){var p=document.getElementsByTagName("script");for(var b in p)if(p[b].src==h)return p[b]}return null}},isActive:function(h,p,b){for(var y="no-"+p;h;){var v=h.classList;if(v.contains(p))return!0;if(v.contains(y))return!1;h=h.parentElement}return!!b}},languages:{plain:a,plaintext:a,text:a,txt:a,extend:function(h,p){var b=r.util.clone(r.languages[h]);for(var y in p)b[y]=p[y];return b},insertBefore:function(h,p,b,y){y=y||r.languages;var v=y[h],w={};for(var S in v)if(v.hasOwnProperty(S)){if(S==p)for(var T in b)b.hasOwnProperty(T)&&(w[T]=b[T]);b.hasOwnProperty(S)||(w[S]=v[S])}var x=y[h];return y[h]=w,r.languages.DFS(r.languages,function($,A){A===x&&$!=h&&(this[$]=w)}),w},DFS:function h(p,b,y,v){v=v||{};var w=r.util.objId;for(var S in p)if(p.hasOwnProperty(S)){b.call(p,S,p[S],y||S);var T=p[S],x=r.util.type(T);x==="Object"&&!v[w(T)]?(v[w(T)]=!0,h(T,b,null,v)):x==="Array"&&!v[w(T)]&&(v[w(T)]=!0,h(T,b,S,v))}}},plugins:{},highlightAll:function(h,p){r.highlightAllUnder(document,h,p)},highlightAllUnder:function(h,p,b){var y={callback:b,container:h,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};r.hooks.run("before-highlightall",y),y.elements=Array.prototype.slice.apply(y.container.querySelectorAll(y.selector)),r.hooks.run("before-all-elements-highlight",y);for(var v=0,w;w=y.elements[v++];)r.highlightElement(w,p===!0,y.callback)},highlightElement:function(h,p,b){var y=r.util.getLanguage(h),v=r.languages[y];r.util.setLanguage(h,y);var w=h.parentElement;w&&w.nodeName.toLowerCase()==="pre"&&r.util.setLanguage(w,y);var S=h.textContent,T={element:h,language:y,grammar:v,code:S};function x(A){T.highlightedCode=A,r.hooks.run("before-insert",T),T.element.innerHTML=T.highlightedCode,r.hooks.run("after-highlight",T),r.hooks.run("complete",T),b&&b.call(T.element)}if(r.hooks.run("before-sanity-check",T),w=T.element.parentElement,w&&w.nodeName.toLowerCase()==="pre"&&!w.hasAttribute("tabindex")&&w.setAttribute("tabindex","0"),!T.code){r.hooks.run("complete",T),b&&b.call(T.element);return}if(r.hooks.run("before-highlight",T),!T.grammar){x(r.util.encode(T.code));return}if(p&&t.Worker){var $=new Worker(r.filename);$.onmessage=function(A){x(A.data)},$.postMessage(JSON.stringify({language:T.language,code:T.code,immediateClose:!0}))}else x(r.highlight(T.code,T.grammar,T.language))},highlight:function(h,p,b){var y={code:h,grammar:p,language:b};if(r.hooks.run("before-tokenize",y),!y.grammar)throw new Error('The language "'+y.language+'" has no grammar.');return y.tokens=r.tokenize(y.code,y.grammar),r.hooks.run("after-tokenize",y),i.stringify(r.util.encode(y.tokens),y.language)},tokenize:function(h,p){var b=p.rest;if(b){for(var y in b)p[y]=b[y];delete p.rest}var v=new c;return d(v,v.head,h),l(h,v,p,v.head,0),m(v)},hooks:{all:{},add:function(h,p){var b=r.hooks.all;b[h]=b[h]||[],b[h].push(p)},run:function(h,p){var b=r.hooks.all[h];if(!(!b||!b.length))for(var y=0,v;v=b[y++];)v(p)}},Token:i};t.Prism=r;function i(h,p,b,y){this.type=h,this.content=p,this.alias=b,this.length=(y||"").length|0}i.stringify=function h(p,b){if(typeof p=="string")return p;if(Array.isArray(p)){var y="";return p.forEach(function(x){y+=h(x,b)}),y}var v={type:p.type,content:h(p.content,b),tag:"span",classes:["token",p.type],attributes:{},language:b},w=p.alias;w&&(Array.isArray(w)?Array.prototype.push.apply(v.classes,w):v.classes.push(w)),r.hooks.run("wrap",v);var S="";for(var T in v.attributes)S+=" "+T+'="'+(v.attributes[T]||"").replace(/"/g,"&quot;")+'"';return"<"+v.tag+' class="'+v.classes.join(" ")+'"'+S+">"+v.content+"</"+v.tag+">"};function o(h,p,b,y){h.lastIndex=p;var v=h.exec(b);if(v&&y&&v[1]){var w=v[1].length;v.index+=w,v[0]=v[0].slice(w)}return v}function l(h,p,b,y,v,w){for(var S in b)if(!(!b.hasOwnProperty(S)||!b[S])){var T=b[S];T=Array.isArray(T)?T:[T];for(var x=0;x<T.length;++x){if(w&&w.cause==S+","+x)return;var $=T[x],A=$.inside,F=!!$.lookbehind,C=!!$.greedy,L=$.alias;if(C&&!$.pattern.global){var E=$.pattern.toString().match(/[imsuy]*$/)[0];$.pattern=RegExp($.pattern.source,E+"g")}for(var I=$.pattern||$,B=y.next,W=v;B!==p.tail&&!(w&&W>=w.reach);W+=B.value.length,B=B.next){var R=B.value;if(p.length>h.length)return;if(!(R instanceof i)){var z=1,te;if(C){if(te=o(I,W,h,F),!te||te.index>=h.length)break;var he=te.index,xe=te.index+te[0].length,D=W;for(D+=B.value.length;he>=D;)B=B.next,D+=B.value.length;if(D-=B.value.length,W=D,B.value instanceof i)continue;for(var K=B;K!==p.tail&&(D<xe||typeof K.value=="string");K=K.next)z++,D+=K.value.length;z--,R=h.slice(W,D),te.index-=W}else if(te=o(I,0,R,F),!te)continue;var he=te.index,Me=te[0],pe=R.slice(0,he),se=R.slice(he+Me.length),_e=W+R.length;w&&_e>w.reach&&(w.reach=_e);var Ee=B.prev;pe&&(Ee=d(p,Ee,pe),W+=pe.length),u(p,Ee,z);var ee=new i(S,A?r.tokenize(Me,A):Me,L,Me);if(B=d(p,Ee,ee),se&&d(p,B,se),z>1){var we={cause:S+","+x,reach:_e};l(h,p,b,B.prev,W,we),w&&we.reach>w.reach&&(w.reach=we.reach)}}}}}}function c(){var h={value:null,prev:null,next:null},p={value:null,prev:h,next:null};h.next=p,this.head=h,this.tail=p,this.length=0}function d(h,p,b){var y=p.next,v={value:b,prev:p,next:y};return p.next=v,y.prev=v,h.length++,v}function u(h,p,b){for(var y=p.next,v=0;v<b&&y!==h.tail;v++)y=y.next;p.next=y,y.prev=p,h.length-=v}function m(h){for(var p=[],b=h.head.next;b!==h.tail;)p.push(b.value),b=b.next;return p}if(!t.document)return t.addEventListener&&(r.disableWorkerMessageHandler||t.addEventListener("message",function(h){var p=JSON.parse(h.data),b=p.language,y=p.code,v=p.immediateClose;t.postMessage(r.highlight(y,r.languages[b],b)),v&&t.close()},!1)),r;var g=r.util.currentScript();g&&(r.filename=g.src,g.hasAttribute("data-manual")&&(r.manual=!0));function f(){r.manual||r.highlightAll()}if(!r.manual){var k=document.readyState;k==="loading"||k==="interactive"&&g&&g.defer?document.addEventListener("DOMContentLoaded",f):window.requestAnimationFrame?window.requestAnimationFrame(f):window.setTimeout(f,16)}return r})(ul);typeof xn<"u"&&xn.exports&&(xn.exports=X);typeof global<"u"&&(global.Prism=X);X.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]};X.languages.markup.tag.inside["attr-value"].inside.entity=X.languages.markup.entity;X.languages.markup.doctype.inside["internal-subset"].inside=X.languages.markup;X.hooks.add("wrap",function(t){t.type==="entity"&&(t.attributes.title=t.content.replace(/&amp;/,"&"))});Object.defineProperty(X.languages.markup.tag,"addInlined",{value:function(n,s){var a={};a["language-"+s]={pattern:/(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,lookbehind:!0,inside:X.languages[s]},a.cdata=/^<!\[CDATA\[|\]\]>$/i;var r={"included-cdata":{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,inside:a}};r["language-"+s]={pattern:/[\s\S]+/,inside:X.languages[s]};var i={};i[n]={pattern:RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g,function(){return n}),"i"),lookbehind:!0,greedy:!0,inside:r},X.languages.insertBefore("markup","cdata",i)}});Object.defineProperty(X.languages.markup.tag,"addAttribute",{value:function(t,n){X.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:X.languages[n]},punctuation:[{pattern:/^=/,alias:"attr-equals"},/"|'/]}}}})}});X.languages.html=X.languages.markup;X.languages.mathml=X.languages.markup;X.languages.svg=X.languages.markup;X.languages.xml=X.languages.extend("markup",{});X.languages.ssml=X.languages.xml;X.languages.atom=X.languages.xml;X.languages.rss=X.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"))})(X);X.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:/[{}[\];(),.:]/};X.languages.javascript=X.languages.extend("clike",{"class-name":[X.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}|\?\?=?|\?\.?|[~:]/});X.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/;X.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:X.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:X.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:X.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:X.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:X.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/});X.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:X.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"}});X.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}});X.languages.markup&&(X.languages.markup.tag.addInlined("script","javascript"),X.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"));X.languages.js=X.languages.javascript;(function(){if(typeof X>"u"||typeof document>"u")return;Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector);var t="Loading\u2026",n=function(g,f){return"\u2716 Error "+g+" while fetching file: "+f},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",i="loading",o="loaded",l="failed",c="pre[data-src]:not(["+r+'="'+o+'"]):not(['+r+'="'+i+'"])';function d(g,f,k){var h=new XMLHttpRequest;h.open("GET",g,!0),h.onreadystatechange=function(){h.readyState==4&&(h.status<400&&h.responseText?f(h.responseText):h.status>=400?k(n(h.status,h.statusText)):k(s))},h.send(null)}function u(g){var f=/^\s*(\d+)\s*(?:(,)\s*(?:(\d+)\s*)?)?$/.exec(g||"");if(f){var k=Number(f[1]),h=f[2],p=f[3];return h?p?[k,Number(p)]:[k,void 0]:[k,k]}}X.hooks.add("before-highlightall",function(g){g.selector+=", "+c}),X.hooks.add("before-sanity-check",function(g){var f=g.element;if(f.matches(c)){g.code="",f.setAttribute(r,i);var k=f.appendChild(document.createElement("CODE"));k.textContent=t;var h=f.getAttribute("data-src"),p=g.language;if(p==="none"){var b=(/\.(\w+)$/.exec(h)||[,"none"])[1];p=a[b]||b}X.util.setLanguage(k,p),X.util.setLanguage(f,p);var y=X.plugins.autoloader;y&&y.loadLanguages(p),d(h,function(v){f.setAttribute(r,o);var w=u(f.getAttribute("data-range"));if(w){var S=v.split(/\r\n?|\n/g),T=w[0],x=w[1]==null?S.length:w[1];T<0&&(T+=S.length),T=Math.max(0,Math.min(T-1,S.length)),x<0&&(x+=S.length),x=Math.max(0,Math.min(x,S.length)),v=S.slice(T,x).join(`
2
+ `),f.hasAttribute("data-start")||f.setAttribute("data-start",String(T+1))}k.textContent=v,X.highlightElement(k)},function(v){f.setAttribute(r,l),k.textContent=v})}}),X.plugins.fileHighlight={highlight:function(f){for(var k=(f||document).querySelectorAll(c),h=0,p;p=k[h++];)X.highlightElement(p)}};var m=!1;X.fileHighlight=function(){m||(console.warn("Prism.fileHighlight is deprecated. Use `Prism.plugins.fileHighlight.highlight` instead."),m=!0),X.plugins.fileHighlight.highlight.apply(this,arguments)}})()});var sn,ie,er,ho,qe,Vs,tr,nr,zn,Yt,Rt,sr,Wn,Xn,Gn,go,en={},tn=[],fo=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,rn=Array.isArray;function Ge(t,n){for(var s in n)t[s]=n[s];return t}function Jn(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function pt(t,n,s){var a,r,i,o={};for(i in n)i=="key"?a=n[i]:i=="ref"?r=n[i]:o[i]=n[i];if(arguments.length>2&&(o.children=arguments.length>3?sn.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 Qt(t,o,a,r,null)}function Qt(t,n,s,a,r){var i={type:t,props:n,key:s,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:r??++er,__i:-1,__u:0};return r==null&&ie.vnode!=null&&ie.vnode(i),i}function N(t){return t.children}function ut(t,n){this.props=t,this.context=n}function et(t,n){if(n==null)return t.__?et(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"?et(t):null}function bo(t){if(t.__P&&t.__d){var n=t.__v,s=n.__e,a=[],r=[],i=Ge({},n);i.__v=n.__v+1,ie.vnode&&ie.vnode(i),qn(t.__P,i,n,t.__n,t.__P.namespaceURI,32&n.__u?[s]:null,a,s??et(n),!!(32&n.__u),r),i.__v=n.__v,i.__.__k[i.__i]=i,lr(a,i,r),n.__e=n.__=null,i.__e!=s&&rr(i)}}function rr(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}),rr(t)}function Zs(t){(!t.__d&&(t.__d=!0)&&qe.push(t)&&!nn.__r++||Vs!=ie.debounceRendering)&&((Vs=ie.debounceRendering)||tr)(nn)}function nn(){try{for(var t,n=1;qe.length;)qe.length>n&&qe.sort(nr),t=qe.shift(),n=qe.length,bo(t)}finally{qe.length=nn.__r=0}}function ar(t,n,s,a,r,i,o,l,c,d,u){var m,g,f,k,h,p,b=a&&a.__k||tn,y=n.length;for(c=yo(s,n,b,c,y),m=0;m<y;m++)(f=s.__k[m])!=null&&(g=f.__i!=-1&&b[f.__i]||en,f.__i=m,p=qn(t,f,g,r,i,o,l,c,d,u),k=f.__e,f.ref&&g.ref!=f.ref&&(g.ref&&Kn(g.ref,null,f),u.push(f.ref,f.__c||k,f)),h==null&&k!=null&&(h=k),4&f.__u?(c=ir(f,c,t),g.__e&&(g.__e=null)):typeof f.type=="function"&&p!==void 0?c=p:k&&(c=k.nextSibling),f.__u&=-7);return s.__e=h,c}function yo(t,n,s,a,r){var i,o,l,c,d,u=s.length,m=u,g=0;for(t.__k=new Array(r),i=0;i<r;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]=Qt(null,o,null,null,null):rn(o)?o=t.__k[i]=Qt(N,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=t.__k[i]=Qt(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):t.__k[i]=o,c=i+g,o.__=t,o.__b=t.__b+1,l=null,(d=o.__i=vo(o,s,c,m))!=-1&&(m--,(l=s[d])&&(l.__u|=2)),l==null||l.__v==null?(d==-1&&(r>u?g--:r<u&&g++),typeof o.type!="function"&&(o.__u|=4)):d!=c&&(d==c-1?g--:d==c+1?g++:(d>c?g--:g++,o.__u|=4))):t.__k[i]=null;if(m)for(i=0;i<u;i++)(l=s[i])!=null&&(2&l.__u)==0&&(l.__e==a&&(a=et(l)),dr(l,l));return a}function ir(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=ir(a[r],n,s));return n}t.__e!=n&&(n&&t.type&&!n.parentNode&&(n=et(t)),n=s.insertBefore(t.__e,n||null));do n=n&&n.nextSibling;while(n!=null&&n.nodeType==8);return n}function vo(t,n,s,a){var r,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(a>(u?1:0)){for(r=s-1,i=s+1;r>=0||i<n.length;)if((d=n[o=r>=0?r--:i++])!=null&&(2&d.__u)==0&&l==d.key&&c==d.type)return o}return-1}function Ys(t,n,s){n[0]=="-"?t.setProperty(n,s??""):t[n]=s==null?"":typeof s!="number"||fo.test(n)?s:s+"px"}function Zt(t,n,s,a,r){var i,o;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||Ys(t.style,n,"");if(s)for(n in s)a&&s[n]==a[n]||Ys(t.style,n,s[n])}else if(n[0]=="o"&&n[1]=="n")i=n!=(n=n.replace(sr,"$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?a?s[Rt]=a[Rt]:(s[Rt]=Wn,t.addEventListener(n,i?Gn:Xn,i)):t.removeEventListener(n,i?Gn:Xn,i);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 Qs(t){return function(n){if(this.l){var s=this.l[n.type+t];if(n[Yt]==null)n[Yt]=Wn++;else if(n[Yt]<s[Rt])return;return s(ie.event?ie.event(n):n)}}}function qn(t,n,s,a,r,i,o,l,c,d){var u,m,g,f,k,h,p,b,y,v,w,S,T,x,$,A,F=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 F=="function"){m=o.length;try{if(y=n.props,v=F.prototype&&F.prototype.render,w=(u=F.contextType)&&a[u.__c],S=u?w?w.props.value:u.__:a,s.__c?b=(g=n.__c=s.__c).__=g.__E:(v?n.__c=g=new F(y,S):(n.__c=g=new ut(y,S),g.constructor=F,g.render=wo),w&&w.sub(g),g.state||(g.state={}),g.__n=a,f=g.__d=!0,g.__h=[],g._sb=[]),v&&g.__s==null&&(g.__s=g.state),v&&F.getDerivedStateFromProps!=null&&(g.__s==g.state&&(g.__s=Ge({},g.__s)),Ge(g.__s,F.getDerivedStateFromProps(y,g.__s))),k=g.props,h=g.state,g.__v=n,f)v&&F.getDerivedStateFromProps==null&&g.componentWillMount!=null&&g.componentWillMount(),v&&g.componentDidMount!=null&&g.__h.push(g.componentDidMount);else{if(v&&F.getDerivedStateFromProps==null&&y!==k&&g.componentWillReceiveProps!=null&&g.componentWillReceiveProps(y,S),n.__v==s.__v||!g.__e&&g.shouldComponentUpdate!=null&&g.shouldComponentUpdate(y,g.__s,S)===!1){n.__v!=s.__v&&(g.props=y,g.state=g.__s,g.__d=!1),n.__e=s.__e,n.__k=s.__k,n.__k.some(function(C){C&&(C.__=n)}),tn.push.apply(g.__h,g._sb),g._sb=[],g.__h.length&&o.push(g),l=et(s);break e}g.componentWillUpdate!=null&&g.componentWillUpdate(y,g.__s,S),v&&g.componentDidUpdate!=null&&g.__h.push(function(){g.componentDidUpdate(k,h,p)})}if(g.context=S,g.props=y,g.__P=t,g.__e=!1,T=ie.__r,x=0,v)g.state=g.__s,g.__d=!1,T&&T(n),u=g.render(g.props,g.state,g.context),tn.push.apply(g.__h,g._sb),g._sb=[];else do g.__d=!1,T&&T(n),u=g.render(g.props,g.state,g.context),g.state=g.__s;while(g.__d&&++x<25);g.state=g.__s,g.getChildContext!=null&&(a=Ge(Ge({},a),g.getChildContext())),v&&!f&&g.getSnapshotBeforeUpdate!=null&&(p=g.getSnapshotBeforeUpdate(k,h)),$=u!=null&&u.type===N&&u.key==null?cr(u.props.children):u,l=ar(t,rn($)?$:[$],n,s,a,r,i,o,l,c,d),g.base=n.__e,n.__u&=-161,g.__h.length&&o.push(g),b&&(g.__E=g.__=null)}catch(C){if(o.length=m,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(A=i.length;A--;)Jn(i[A])}else n.__e=s.__e;n.__k==null&&(n.__k=s.__k||[]),C.then||or(n),ie.__e(C,n,s)}}else i==null&&n.__v==s.__v?(n.__k=s.__k,n.__e=s.__e):l=n.__e=ko(s.__e,n,s,a,r,i,o,c,d);return(u=ie.diffed)&&u(n),128&n.__u?void 0:l}function or(t){t&&(t.__c&&(t.__c.__e=!0),t.__k&&t.__k.some(or))}function lr(t,n,s){for(var a=0;a<s.length;a++)Kn(s[a],s[++a],s[++a]);ie.__c&&ie.__c(n,t),t.some(function(r){try{t=r.__h,r.__h=[],t.some(function(i){i.call(r)})}catch(i){ie.__e(i,r.__v)}})}function cr(t){return typeof t!="object"||t==null||t.__b>0?t:rn(t)?t.map(cr):t.constructor!==void 0?null:Ge({},t)}function ko(t,n,s,a,r,i,o,l,c){var d,u,m,g,f,k,h,p=s.props||en,b=n.props,y=n.type;if(y=="svg"?r="http://www.w3.org/2000/svg":y=="math"?r="http://www.w3.org/1998/Math/MathML":r||(r="http://www.w3.org/1999/xhtml"),i!=null){for(d=0;d<i.length;d++)if((f=i[d])&&"setAttribute"in f==!!y&&(y?f.localName==y:f.nodeType==3)){t=f,i[d]=null;break}}if(t==null){if(y==null)return document.createTextNode(b);t=document.createElementNS(r,y,b.is&&b),l&&(ie.__m&&ie.__m(n,i),l=!1),i=null}if(y==null)p===b||l&&t.data==b||(t.data=b);else{if(i=y=="textarea"&&b.defaultValue!=null?null:i&&sn.call(t.childNodes),!l&&i!=null)for(p={},d=0;d<t.attributes.length;d++)p[(f=t.attributes[d]).name]=f.value;for(d in p)f=p[d],d=="dangerouslySetInnerHTML"?m=f:d=="children"||d in b||d=="value"&&"defaultValue"in b||d=="checked"&&"defaultChecked"in b||Zt(t,d,null,f,r);for(d in b)f=b[d],d=="children"?g=f:d=="dangerouslySetInnerHTML"?u=f:d=="value"?k=f:d=="checked"?h=f:l&&typeof f!="function"||p[d]===f||Zt(t,d,f,p[d],r);if(u)l||m&&(u.__html==m.__html||u.__html==t.innerHTML)||(t.innerHTML=u.__html),n.__k=[];else if(m&&(t.innerHTML=""),ar(n.type=="template"?t.content:t,rn(g)?g:[g],n,s,a,y=="foreignObject"?"http://www.w3.org/1999/xhtml":r,i,o,i?i[0]:s.__k&&et(s,0),l,c),i!=null)for(d=i.length;d--;)Jn(i[d]);l&&y!="textarea"||(d="value",y=="progress"&&k==null?t.removeAttribute("value"):k!=null&&(k!==t[d]||y=="progress"&&!k||y=="option"&&k!=p[d])&&Zt(t,d,k,p[d],r),d="checked",h!=null&&h!=t[d]&&Zt(t,d,h,p[d],r))}return t}function Kn(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){ie.__e(r,s)}}function dr(t,n,s){var a,r;if(ie.unmount&&ie.unmount(t),(a=t.ref)&&(a.current&&a.current!=t.__e||Kn(a,null,n)),(a=t.__c)!=null){if(a.componentWillUnmount)try{a.componentWillUnmount()}catch(i){ie.__e(i,n)}a.base=a.__P=a.__n=null}if(a=t.__k)for(r=0;r<a.length;r++)a[r]&&dr(a[r],n,s||typeof t.type!="function");s||Jn(t.__e),t.__c=t.__=t.__e=void 0}function wo(t,n,s){return this.constructor(t,s)}function ur(t,n,s){var a,r,i,o;n==document&&(n=document.documentElement),ie.__&&ie.__(t,n),r=(a=typeof s=="function")?null:s&&s.__k||n.__k,i=[],o=[],qn(n,t=(!a&&s||n).__k=pt(N,null,[t]),r||en,en,n.namespaceURI,!a&&s?[s]:r?null:n.firstChild?sn.call(n.childNodes):null,i,!a&&s?s:r?r.__e:n.firstChild,a,o),lr(i,t,o),t.props.children=null}sn=tn.slice,ie={__e:function(t,n,s,a){for(var r,i,o;n=n.__;)if((r=n.__c)&&!r.__)try{if((i=r.constructor)&&i.getDerivedStateFromError!=null&&(r.setState(i.getDerivedStateFromError(t)),o=r.__d),r.componentDidCatch!=null&&(r.componentDidCatch(t,a||{}),o=r.__d),o)return r.__E=r}catch(l){t=l}throw t}},er=0,ho=function(t){return t!=null&&t.constructor===void 0},ut.prototype.setState=function(t,n){var s;s=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Ge({},this.state),typeof t=="function"&&(t=t(Ge({},s),this.props)),t&&Ge(s,t),t!=null&&this.__v&&(n&&this._sb.push(n),Zs(this))},ut.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),Zs(this))},ut.prototype.render=N,qe=[],tr=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,nr=function(t,n){return t.__v.__b-n.__v.__b},nn.__r=0,zn=Math.random().toString(8),Yt="__d"+zn,Rt="__a"+zn,sr=/(PointerCapture)$|Capture$/i,Wn=0,Xn=Qs(!1),Gn=Qs(!0),go=0;var mt,ce,Vn,pr,ht=0,kr=[],de=ie,mr=de.__b,hr=de.__r,gr=de.diffed,fr=de.__c,br=de.unmount,yr=de.__;function on(t,n){de.__h&&de.__h(ce,t,ht||n),ht=0;var s=ce.__H||(ce.__H={__:[],__h:[]});return t>=s.__.length&&s.__.push({}),s.__[t]}function _(t){return ht=1,xo(xr,t)}function xo(t,n,s){var a=on(mt++,2);if(a.t=t,!a.__c&&(a.__=[s?s(n):xr(void 0,n),function(l){var c=a.__N?a.__N[0]:a.__[0],d=a.t(c,l);c!==d&&(a.__N=[d,a.__[1]],a.__c.setState({}))}],a.__c=ce,!ce.__f)){var r=function(l,c,d){if(!a.__c.__H)return!0;var u=!1,m=a.__c.props!==l;if(a.__c.__H.__.some(function(f){if(f.__N){u=!0;var k=f.__[0];f.__=f.__N,f.__N=void 0,k!==f.__[0]&&(m=!0)}}),i){var g=i.call(this,l,c,d);return u?g||m:g}return!u||m};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,r(l,c,d),i=u}o&&o.call(this,l,c,d)},ce.shouldComponentUpdate=r}return a.__N||a.__}function j(t,n){var s=on(mt++,3);!de.__s&&Yn(s.__H,n)&&(s.__=t,s.u=n,ce.__H.__h.push(s))}function _o(t,n){var s=on(mt++,4);!de.__s&&Yn(s.__H,n)&&(s.__=t,s.u=n,ce.__h.push(s))}function ne(t){return ht=5,V(function(){return{current:t}},[])}function wr(t,n,s){ht=6,_o(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 V(t,n){var s=on(mt++,7);return Yn(s.__H,n)&&(s.__=t(),s.__H=n,s.__h=t),s.__}function At(t,n){return ht=8,V(function(){return t},n)}function So(){for(var t;t=kr.shift();){var n=t.__H;if(t.__P&&n)try{n.__h.some(an),n.__h.some(Zn),n.__h=[]}catch(s){n.__h=[],de.__e(s,t.__v)}}}de.__b=function(t){ce=null,mr&&mr(t)},de.__=function(t,n){t&&n.__k&&n.__k.__m&&(t.__m=n.__k.__m),yr&&yr(t,n)},de.__r=function(t){hr&&hr(t),mt=0;var n=(ce=t.__c).__H;n&&(Vn===ce?(n.__h=[],ce.__h=[],n.__.some(function(s){s.__N&&(s.__=s.__N),s.u=s.__N=void 0})):(n.__h.some(an),n.__h.some(Zn),n.__h=[],mt=0)),Vn=ce},de.diffed=function(t){gr&&gr(t);var n=t.__c;n&&n.__H&&(n.__H.__h.length&&(kr.push(n)!==1&&pr===de.requestAnimationFrame||((pr=de.requestAnimationFrame)||To)(So)),n.__H.__.some(function(s){s.u&&(s.__H=s.u,s.u=void 0)})),Vn=ce=null},de.__c=function(t,n){n.some(function(s){try{s.__h.some(an),s.__h=s.__h.filter(function(a){return!a.__||Zn(a)})}catch(a){n.some(function(r){r.__h&&(r.__h=[])}),n=[],de.__e(a,s.__v)}}),fr&&fr(t,n)},de.unmount=function(t){br&&br(t);var n,s=t.__c;s&&s.__H&&(s.__H.__.some(function(a){try{an(a)}catch(r){n=r}}),s.__H=void 0,n&&de.__e(n,s.__v))};var vr=typeof requestAnimationFrame=="function";function To(t){var n,s=function(){clearTimeout(a),vr&&cancelAnimationFrame(n),setTimeout(t)},a=setTimeout(s,35);vr&&(n=requestAnimationFrame(s))}function an(t){var n=ce,s=t.__c;typeof s=="function"&&(t.__c=void 0,s()),ce=n}function Zn(t){var n=ce;t.__c=t.__(),ce=n}function Yn(t,n){return!t||t.length!==n.length||n.some(function(s,a){return s!==t[a]})}function xr(t,n){return typeof n=="function"?n(t):n}var ln=new URLSearchParams(location.search).get("root")??"",Qn=()=>ln;function _r(t){ln=t;let n=new URL(location.href);n.searchParams.set("root",t),history.replaceState(null,"",n.toString())}function $o(t,n){let s=new URL(t,location.origin);ln&&s.searchParams.set("root",ln);for(let[a,r]of Object.entries(n??{}))r==null||r===""||s.searchParams.set(a,String(r));return s.toString()}var Mt=class extends Error{constructor(s,a){super(s);ae(this,"status",a)}};async function O(t,n,s){let a=await fetch($o(t,n),s),r=await a.json().catch(()=>({error:"bad response"}));if(a.status===404&&r.error==="not found"&&t.startsWith("/api/"))throw new Mt(`${t} is not available on the running server; restart \`eminiar ui\` to pick up the rebuilt bundle`,a.status);if(!a.ok)throw new Mt(r.error??`HTTP ${a.status}`,a.status);if(r&&typeof r=="object"&&"error"in r&&r.error)throw new Mt(String(r.error),a.status);return r}function fe(t,n,s="POST",a){return O(t,a,{method:s,headers:{"content-type":"application/json"},body:JSON.stringify(n)})}function cn(t,n){return O(t,n,{method:"DELETE",headers:{"content-type":"application/json"}})}var q=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(Math.round(t));function re(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 Se=t=>t?new Date(t).toISOString().slice(0,10):"",Sr=t=>t?new Date(t).toLocaleTimeString():"",dn=t=>t.split("/").pop()??t;var Eo={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"},Le=t=>Eo[t]??"#94a3b8",Co={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"},gt=t=>Co[t]??"#94a3b8",un=new Set(["imports","reexports","calls","references","extends","implements","handles","mentions","supersedes","links","documents","about"]),Tr=["imports","calls","references","extends","implements","handles","reexports","co_changes","mentions","defines"],M=(...t)=>t.filter(Boolean).join(" ");function $r(t,n){let s;return(...a)=>{clearTimeout(s),s=setTimeout(()=>t(...a),n)}}var Fe=t=>`${Math.round((t??0)*100)}%`;function Er(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 Ro=0;function e(t,n,s,a,r,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:--Ro,__i:-1,__u:0,__source:r,__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 Q(t,n=!1){for(let s of es)s(t,n)}function Cr(){let[t,n]=_(null);return j(()=>{let s,a=(r,i)=>{n({msg:r,bad:i}),clearTimeout(s),s=setTimeout(()=>n(null),i?6e3:2500)};return es.add(a),()=>{es.delete(a),clearTimeout(s)}},[]),t?e("div",{class:M("toast",t.bad&&"bad"),children:t.msg}):null}function G(t,n){let[s,a]=_({data:void 0,error:void 0,loading:!0}),[r,i]=_(0),o=ne(0);j(()=>{let c=++o.current;a(d=>({...d,loading:!0,error:void 0})),t().then(d=>c===o.current&&a({data:d,error:void 0,loading:!1}),d=>c===o.current&&a(u=>({...u,error:d.message,loading:!1})))},[...n,r]);let l=At(()=>i(c=>c+1),[]);return{...s,reload:l}}var U=()=>e("span",{class:"spin"}),J=({children:t})=>e("div",{class:"empty",children:t}),Z=({error:t})=>e("div",{class:"empty bad",children:t});function be({kind:t}){return e("span",{class:"tag kind",style:{color:Le(t)},children:t})}function P({children:t,class:n}){return e("span",{class:M("tag",n),children:t})}function We({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 Ke({rows:t}){return e("dl",{class:"kv",children:t.map(([n,s])=>e(N,{children:[e("dt",{children:n}),e("dd",{children:s})]}))})}function Ce({tabs:t,value:n,onChange:s}){return e("div",{class:"subtabs",children:t.map(([a,r])=>e("button",{type:"button",class:M(n===a&&"active"),onClick:()=>s(a),children:r}))})}function Rr({left:t,center:n,right:s,leftWidth:a=280,rightWidth:r=340}){let[i,o]=_(a),[l,c]=_(r),d=ne(null),[u,m]=_(null);j(()=>{let f=h=>{let p=d.current;if(!p)return;let b=h.clientX-p.x;p.side==="l"?o(Math.max(160,Math.min(700,p.start+b))):c(Math.max(200,Math.min(800,p.start-b)))},k=()=>{d.current=null,m(null)};return window.addEventListener("mousemove",f),window.addEventListener("mouseup",k),()=>{window.removeEventListener("mousemove",f),window.removeEventListener("mouseup",k)}},[]);let g=[t?`${i}px 5px`:"","minmax(0, 1fr)",s?`5px ${l}px`:""].filter(Boolean).join(" ");return e("div",{class:"split",style:{gridTemplateColumns:g},children:[t&&e(N,{children:[e("div",{class:"pane",children:t}),e("div",{class:M("gutter",u==="l"&&"on"),onMouseDown:f=>{d.current={side:"l",x:f.clientX,start:i},m("l"),f.preventDefault()}})]}),e("div",{class:"pane",children:n}),s&&e(N,{children:[e("div",{class:M("gutter",u==="r"&&"on"),onMouseDown:f=>{d.current={side:"r",x:f.clientX,start:l},m("r"),f.preventDefault()}}),e("div",{class:"pane",children:s})]})]})}function Ve(t,n,s=!0){let[a,r]=_(n),[i,o]=_(s?-1:1);return{sorted:(t??[]).slice().sort((d,u)=>{let m=d[a],g=u[a];return typeof m=="number"&&typeof g=="number"?(m-g)*i:String(m??"").localeCompare(String(g??""))*i}),th:(d,u,m=!1)=>e("th",{class:M("sortable",m&&"num",a===d&&"sorted"),onClick:()=>{a===d?o(g=>g===1?-1:1):(r(d),o(m?-1:1))},children:[u,a===d?i===1?" \u25B2":" \u25BC":""]})}}var Ao=["overview","usage","explore","galaxy","architecture","history","memory","docs","coverage","sessions","swarm","system"];function Ar(){let t=location.hash.replace(/^#\/?/,""),[n="",s=""]=t.split("?"),a=Ao.includes(n)?n:"overview",r={};for(let[i,o]of new URLSearchParams(s))r[i]=o;return{view:a,params:r}}function H(t,n={}){let s=new URLSearchParams;for(let[r,i]of Object.entries(n))i&&s.set(r,i);let a=s.toString();location.hash=`/${t}${a?`?${a}`:""}`}function Mr(){let[t,n]=_(Ar);return j(()=>{let s=()=>n(Ar());return window.addEventListener("hashchange",s),()=>window.removeEventListener("hashchange",s)},[]),t}function ts(t,n){var s,a=1;t==null&&(t=0),n==null&&(n=0);function r(){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)*a,d=(d/o-n)*a,i=0;i<o;++i)l=s[i],l.x-=c,l.y-=d}return r.initialize=function(i){s=i},r.x=function(i){return arguments.length?(t=+i,r):t},r.y=function(i){return arguments.length?(n=+i,r):n},r.strength=function(i){return arguments.length?(a=+i,r):a},r}function Lr(t){let n=+this._x.call(null,t),s=+this._y.call(null,t);return Fr(this.cover(n,s),n,s,t)}function Fr(t,n,s,a){if(isNaN(n)||isNaN(s))return t;var r,i=t._root,o={data:a},l=t._x0,c=t._y0,d=t._x1,u=t._y1,m,g,f,k,h,p,b,y;if(!i)return t._root=o,t;for(;i.length;)if((h=n>=(m=(l+d)/2))?l=m:d=m,(p=s>=(g=(c+u)/2))?c=g:u=g,r=i,!(i=i[b=p<<1|h]))return r[b]=o,t;if(f=+t._x.call(null,i.data),k=+t._y.call(null,i.data),n===f&&s===k)return o.next=i,r?r[b]=o:t._root=o,t;do r=r?r[b]=new Array(4):t._root=new Array(4),(h=n>=(m=(l+d)/2))?l=m:d=m,(p=s>=(g=(c+u)/2))?c=g:u=g;while((b=p<<1|h)===(y=(k>=g)<<1|f>=m));return r[y]=i,r[b]=o,t}function Ir(t){var n,s,a=t.length,r,i,o=new Array(a),l=new Array(a),c=1/0,d=1/0,u=-1/0,m=-1/0;for(s=0;s<a;++s)isNaN(r=+this._x.call(null,n=t[s]))||isNaN(i=+this._y.call(null,n))||(o[s]=r,l[s]=i,r<c&&(c=r),r>u&&(u=r),i<d&&(d=i),i>m&&(m=i));if(c>u||d>m)return this;for(this.cover(c,d).cover(u,m),s=0;s<a;++s)Fr(this,o[s],l[s],t[s]);return this}function Dr(t,n){if(isNaN(t=+t)||isNaN(n=+n))return this;var s=this._x0,a=this._y0,r=this._x1,i=this._y1;if(isNaN(s))r=(s=Math.floor(t))+1,i=(a=Math.floor(n))+1;else{for(var o=r-s||1,l=this._root,c,d;s>t||t>=r||a>n||n>=i;)switch(d=(n<a)<<1|t<s,c=new Array(4),c[d]=l,l=c,o*=2,d){case 0:r=s+o,i=a+o;break;case 1:s=r-o,i=a+o;break;case 2:r=s+o,a=i-o;break;case 3:s=r-o,a=i-o;break}this._root&&this._root.length&&(this._root=l)}return this._x0=s,this._y0=a,this._x1=r,this._y1=i,this}function Pr(){var t=[];return this.visit(function(n){if(!n.length)do t.push(n.data);while(n=n.next)}),t}function Nr(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 ye(t,n,s,a,r){this.node=t,this.x0=n,this.y0=s,this.x1=a,this.y1=r}function Or(t,n,s){var a,r=this._x0,i=this._y0,o,l,c,d,u=this._x1,m=this._y1,g=[],f=this._root,k,h;for(f&&g.push(new ye(f,r,i,u,m)),s==null?s=1/0:(r=t-s,i=n-s,u=t+s,m=n+s,s*=s);k=g.pop();)if(!(!(f=k.node)||(o=k.x0)>u||(l=k.y0)>m||(c=k.x1)<r||(d=k.y1)<i))if(f.length){var p=(o+c)/2,b=(l+d)/2;g.push(new ye(f[3],p,b,c,d),new ye(f[2],o,b,p,d),new ye(f[1],p,l,c,b),new ye(f[0],o,l,p,b)),(h=(n>=b)<<1|t>=p)&&(k=g[g.length-1],g[g.length-1]=g[g.length-1-h],g[g.length-1-h]=k)}else{var y=t-+this._x.call(null,f.data),v=n-+this._y.call(null,f.data),w=y*y+v*v;if(w<s){var S=Math.sqrt(s=w);r=t-S,i=n-S,u=t+S,m=n+S,a=f.data}}return a}function Hr(t){if(isNaN(u=+this._x.call(null,t))||isNaN(m=+this._y.call(null,t)))return this;var n,s=this._root,a,r,i,o=this._x0,l=this._y0,c=this._x1,d=this._y1,u,m,g,f,k,h,p,b;if(!s)return this;if(s.length)for(;;){if((k=u>=(g=(o+c)/2))?o=g:c=g,(h=m>=(f=(l+d)/2))?l=f:d=f,n=s,!(s=s[p=h<<1|k]))return this;if(!s.length)break;(n[p+1&3]||n[p+2&3]||n[p+3&3])&&(a=n,b=p)}for(;s.data!==t;)if(r=s,!(s=s.next))return this;return(i=s.next)&&delete s.next,r?(i?r.next=i:delete r.next,this):n?(i?n[p]=i:delete n[p],(s=n[0]||n[1]||n[2]||n[3])&&s===(n[3]||n[2]||n[1]||n[0])&&!s.length&&(a?a[b]=s:this._root=s),this):(this._root=i,this)}function Br(t){for(var n=0,s=t.length;n<s;++n)this.remove(t[n]);return this}function Ur(){return this._root}function jr(){var t=0;return this.visit(function(n){if(!n.length)do++t;while(n=n.next)}),t}function zr(t){var n=[],s,a=this._root,r,i,o,l,c;for(a&&n.push(new ye(a,this._x0,this._y0,this._x1,this._y1));s=n.pop();)if(!t(a=s.node,i=s.x0,o=s.y0,l=s.x1,c=s.y1)&&a.length){var d=(i+l)/2,u=(o+c)/2;(r=a[3])&&n.push(new ye(r,d,u,l,c)),(r=a[2])&&n.push(new ye(r,i,u,d,c)),(r=a[1])&&n.push(new ye(r,d,o,l,u)),(r=a[0])&&n.push(new ye(r,i,o,d,u))}return this}function Xr(t){var n=[],s=[],a;for(this._root&&n.push(new ye(this._root,this._x0,this._y0,this._x1,this._y1));a=n.pop();){var r=a.node;if(r.length){var i,o=a.x0,l=a.y0,c=a.x1,d=a.y1,u=(o+c)/2,m=(l+d)/2;(i=r[0])&&n.push(new ye(i,o,l,u,m)),(i=r[1])&&n.push(new ye(i,u,l,c,m)),(i=r[2])&&n.push(new ye(i,o,m,u,d)),(i=r[3])&&n.push(new ye(i,u,m,c,d))}s.push(a)}for(;a=s.pop();)t(a.node,a.x0,a.y0,a.x1,a.y1);return this}function Gr(t){return t[0]}function Wr(t){return arguments.length?(this._x=t,this):this._x}function Jr(t){return t[1]}function qr(t){return arguments.length?(this._y=t,this):this._y}function tt(t,n,s){var a=new ns(n??Gr,s??Jr,NaN,NaN,NaN,NaN);return t==null?a:a.addAll(t)}function ns(t,n,s,a,r,i){this._x=t,this._y=n,this._x0=s,this._y0=a,this._x1=r,this._y1=i,this._root=void 0}function Kr(t){for(var n={data:t.data},s=n;t=t.next;)s=s.next={data:t.data};return n}var Te=tt.prototype=ns.prototype;Te.copy=function(){var t=new ns(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=Kr(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]=Kr(a));return t};Te.add=Lr;Te.addAll=Ir;Te.cover=Dr;Te.data=Pr;Te.extent=Nr;Te.find=Or;Te.remove=Hr;Te.removeAll=Br;Te.root=Ur;Te.size=jr;Te.visit=zr;Te.visitAfter=Xr;Te.x=Wr;Te.y=qr;function me(t){return function(){return t}}function Ie(t){return(t()-.5)*1e-6}function Mo(t){return t.x+t.vx}function Lo(t){return t.y+t.vy}function ss(t){var n,s,a,r=1,i=1;typeof t!="function"&&(t=me(t==null?1:+t));function o(){for(var d,u=n.length,m,g,f,k,h,p,b=0;b<i;++b)for(m=tt(n,Mo,Lo).visitAfter(l),d=0;d<u;++d)g=n[d],h=s[g.index],p=h*h,f=g.x+g.vx,k=g.y+g.vy,m.visit(y);function y(v,w,S,T,x){var $=v.data,A=v.r,F=h+A;if($){if($.index>g.index){var C=f-$.x-$.vx,L=k-$.y-$.vy,E=C*C+L*L;E<F*F&&(C===0&&(C=Ie(a),E+=C*C),L===0&&(L=Ie(a),E+=L*L),E=(F-(E=Math.sqrt(E)))/E*r,g.vx+=(C*=E)*(F=(A*=A)/(p+A)),g.vy+=(L*=E)*F,$.vx-=C*(F=1-F),$.vy-=L*F)}return}return w>f+F||T<f-F||S>k+F||x<k-F}}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,m;for(s=new Array(u),d=0;d<u;++d)m=n[d],s[m.index]=+t(m,d,n)}}return o.initialize=function(d,u){n=d,a=u,c()},o.iterations=function(d){return arguments.length?(i=+d,o):i},o.strength=function(d){return arguments.length?(r=+d,o):r},o.radius=function(d){return arguments.length?(t=typeof d=="function"?d:me(+d),c(),o):t},o}function Fo(t){return t.index}function Vr(t,n){var s=t.get(n);if(!s)throw new Error("node not found: "+n);return s}function rs(t){var n=Fo,s=m,a,r=me(30),i,o,l,c,d,u=1;t==null&&(t=[]);function m(p){return 1/Math.min(l[p.source.index],l[p.target.index])}function g(p){for(var b=0,y=t.length;b<u;++b)for(var v=0,w,S,T,x,$,A,F;v<y;++v)w=t[v],S=w.source,T=w.target,x=T.x+T.vx-S.x-S.vx||Ie(d),$=T.y+T.vy-S.y-S.vy||Ie(d),A=Math.sqrt(x*x+$*$),A=(A-i[v])/A*p*a[v],x*=A,$*=A,T.vx-=x*(F=c[v]),T.vy-=$*F,S.vx+=x*(F=1-F),S.vy+=$*F}function f(){if(o){var p,b=o.length,y=t.length,v=new Map(o.map((S,T)=>[n(S,T,o),S])),w;for(p=0,l=new Array(b);p<y;++p)w=t[p],w.index=p,typeof w.source!="object"&&(w.source=Vr(v,w.source)),typeof w.target!="object"&&(w.target=Vr(v,w.target)),l[w.source.index]=(l[w.source.index]||0)+1,l[w.target.index]=(l[w.target.index]||0)+1;for(p=0,c=new Array(y);p<y;++p)w=t[p],c[p]=l[w.source.index]/(l[w.source.index]+l[w.target.index]);a=new Array(y),k(),i=new Array(y),h()}}function k(){if(o)for(var p=0,b=t.length;p<b;++p)a[p]=+s(t[p],p,t)}function h(){if(o)for(var p=0,b=t.length;p<b;++p)i[p]=+r(t[p],p,t)}return g.initialize=function(p,b){o=p,d=b,f()},g.links=function(p){return arguments.length?(t=p,f(),g):t},g.id=function(p){return arguments.length?(n=p,g):n},g.iterations=function(p){return arguments.length?(u=+p,g):u},g.strength=function(p){return arguments.length?(s=typeof p=="function"?p:me(+p),k(),g):s},g.distance=function(p){return arguments.length?(r=typeof p=="function"?p:me(+p),h(),g):r},g}var Io={value:()=>{}};function Yr(){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 pn(s)}function pn(t){this._=t}function Do(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}})}pn.prototype=Yr.prototype={constructor:pn,on:function(t,n){var s=this._,a=Do(t+"",s),r,i=-1,o=a.length;if(arguments.length<2){for(;++i<o;)if((r=(t=a[i]).type)&&(r=Po(s[r],t.name)))return r;return}if(n!=null&&typeof n!="function")throw new Error("invalid callback: "+n);for(;++i<o;)if(r=(t=a[i]).type)s[r]=Zr(s[r],t.name,n);else if(n==null)for(r in s)s[r]=Zr(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 pn(t)},call:function(t,n){if((r=arguments.length-2)>0)for(var s=new Array(r),a=0,r,i;a<r;++a)s[a]=arguments[a+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(i=this._[t],a=0,r=i.length;a<r;++a)i[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,i=a.length;r<i;++r)a[r].value.apply(n,s)}};function Po(t,n){for(var s=0,a=t.length,r;s<a;++s)if((r=t[s]).name===n)return r.value}function Zr(t,n,s){for(var a=0,r=t.length;a<r;++a)if(t[a].name===n){t[a]=Io,t=t.slice(0,a).concat(t.slice(a+1));break}return s!=null&&t.push({name:n,value:s}),t}var as=Yr;var ft=0,Ft=0,Lt=0,ea=1e3,mn,It,hn=0,nt=0,gn=0,Dt=typeof performance=="object"&&performance.now?performance:Date,ta=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function ls(){return nt||(ta(No),nt=Dt.now()+gn)}function No(){nt=0}function is(){this._call=this._time=this._next=null}is.prototype=fn.prototype={constructor:is,restart:function(t,n,s){if(typeof t!="function")throw new TypeError("callback is not a function");s=(s==null?ls():+s)+(n==null?0:+n),!this._next&&It!==this&&(It?It._next=this:mn=this,It=this),this._call=t,this._time=s,os()},stop:function(){this._call&&(this._call=null,this._time=1/0,os())}};function fn(t,n,s){var a=new is;return a.restart(t,n,s),a}function na(){ls(),++ft;for(var t=mn,n;t;)(n=nt-t._time)>=0&&t._call.call(void 0,n),t=t._next;--ft}function Qr(){nt=(hn=Dt.now())+gn,ft=Ft=0;try{na()}finally{ft=0,Ho(),nt=0}}function Oo(){var t=Dt.now(),n=t-hn;n>ea&&(gn-=n,hn=t)}function Ho(){for(var t,n=mn,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:mn=s);It=t,os(a)}function os(t){if(!ft){Ft&&(Ft=clearTimeout(Ft));var n=t-nt;n>24?(t<1/0&&(Ft=setTimeout(Qr,t-Dt.now()-gn)),Lt&&(Lt=clearInterval(Lt))):(Lt||(hn=Dt.now(),Lt=setInterval(Oo,ea)),ft=1,ta(Qr))}}function sa(){let t=1;return()=>(t=(1664525*t+1013904223)%4294967296)/4294967296}function ra(t){return t.x}function aa(t){return t.y}var Bo=10,Uo=Math.PI*(3-Math.sqrt(5));function cs(t){var n,s=1,a=.001,r=1-Math.pow(a,1/300),i=0,o=.6,l=new Map,c=fn(m),d=as("tick","end"),u=sa();t==null&&(t=[]);function m(){g(),d.call("tick",n),s<a&&(c.stop(),d.call("end",n))}function g(h){var p,b=t.length,y;h===void 0&&(h=1);for(var v=0;v<h;++v)for(s+=(i-s)*r,l.forEach(function(w){w(s)}),p=0;p<b;++p)y=t[p],y.fx==null?y.x+=y.vx*=o:(y.x=y.fx,y.vx=0),y.fy==null?y.y+=y.vy*=o:(y.y=y.fy,y.vy=0);return n}function f(){for(var h=0,p=t.length,b;h<p;++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 y=Bo*Math.sqrt(.5+h),v=h*Uo;b.x=y*Math.cos(v),b.y=y*Math.sin(v)}(isNaN(b.vx)||isNaN(b.vy))&&(b.vx=b.vy=0)}}function k(h){return h.initialize&&h.initialize(t,u),h}return f(),n={tick:g,restart:function(){return c.restart(m),n},stop:function(){return c.stop(),n},nodes:function(h){return arguments.length?(t=h,f(),l.forEach(k),n):t},alpha:function(h){return arguments.length?(s=+h,n):s},alphaMin:function(h){return arguments.length?(a=+h,n):a},alphaDecay:function(h){return arguments.length?(r=+h,n):+r},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(k),n):u},force:function(h,p){return arguments.length>1?(p==null?l.delete(h):l.set(h,k(p)),n):l.get(h)},find:function(h,p,b){var y=0,v=t.length,w,S,T,x,$;for(b==null?b=1/0:b*=b,y=0;y<v;++y)x=t[y],w=h-x.x,S=p-x.y,T=w*w+S*S,T<b&&($=x,b=T);return $},on:function(h,p){return arguments.length>1?(d.on(h,p),n):d.on(h)}}}function ds(){var t,n,s,a,r=me(-30),i,o=1,l=1/0,c=.81;function d(f){var k,h=t.length,p=tt(t,ra,aa).visitAfter(m);for(a=f,k=0;k<h;++k)n=t[k],p.visit(g)}function u(){if(t){var f,k=t.length,h;for(i=new Array(k),f=0;f<k;++f)h=t[f],i[h.index]=+r(h,f,t)}}function m(f){var k=0,h,p,b=0,y,v,w;if(f.length){for(y=v=w=0;w<4;++w)(h=f[w])&&(p=Math.abs(h.value))&&(k+=h.value,b+=p,y+=p*h.x,v+=p*h.y);f.x=y/b,f.y=v/b}else{h=f,h.x=h.data.x,h.y=h.data.y;do k+=i[h.data.index];while(h=h.next)}f.value=k}function g(f,k,h,p){if(!f.value)return!0;var b=f.x-n.x,y=f.y-n.y,v=p-k,w=b*b+y*y;if(v*v/c<w)return w<l&&(b===0&&(b=Ie(s),w+=b*b),y===0&&(y=Ie(s),w+=y*y),w<o&&(w=Math.sqrt(o*w)),n.vx+=b*f.value*a/w,n.vy+=y*f.value*a/w),!0;if(f.length||w>=l)return;(f.data!==n||f.next)&&(b===0&&(b=Ie(s),w+=b*b),y===0&&(y=Ie(s),w+=y*y),w<o&&(w=Math.sqrt(o*w)));do f.data!==n&&(v=i[f.data.index]*a/w,n.vx+=b*v,n.vy+=y*v);while(f=f.next)}return d.initialize=function(f,k){t=f,s=k,u()},d.strength=function(f){return arguments.length?(r=typeof f=="function"?f:me(+f),u(),d):r},d.distanceMin=function(f){return arguments.length?(o=f*f,d):Math.sqrt(o)},d.distanceMax=function(f){return arguments.length?(l=f*f,d):Math.sqrt(l)},d.theta=function(f){return arguments.length?(c=f*f,d):Math.sqrt(c)},d}function us(t){var n=me(.1),s,a,r;typeof t!="function"&&(t=me(t==null?0:+t));function i(l){for(var c=0,d=s.length,u;c<d;++c)u=s[c],u.vx+=(r[c]-u.x)*a[c]*l}function o(){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 i.initialize=function(l){s=l,o()},i.strength=function(l){return arguments.length?(n=typeof l=="function"?l:me(+l),o(),i):n},i.x=function(l){return arguments.length?(t=typeof l=="function"?l:me(+l),o(),i):t},i}function ps(t){var n=me(.1),s,a,r;typeof t!="function"&&(t=me(t==null?0:+t));function i(l){for(var c=0,d=s.length,u;c<d;++c)u=s[c],u.vy+=(r[c]-u.y)*a[c]*l}function o(){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 i.initialize=function(l){s=l,o()},i.strength=function(l){return arguments.length?(n=typeof l=="function"?l:me(+l),o(),i):n},i.y=function(l){return arguments.length?(t=typeof l=="function"?l:me(+l),o(),i):t},i}function ms(t,n,s){let a=new Map,r=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),a.set(c.id,u),u}),i=[];for(let c of n){let d=a.get(c.src),u=a.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 r)c.r=4+Math.min(12,Math.sqrt(c.deg)*1.8)+(c.root?3:0);let o=r.length,l=cs(r).force("link",rs(i).distance(c=>c.kind==="co_changes"?90:c.kind==="defines"?36:60).strength(c=>c.kind==="co_changes"?.15:.5)).force("charge",ds().strength(o>400?-60:-140).distanceMax(600)).force("collide",ss().radius(c=>c.r+4).iterations(2)).force("center",ts(0,0).strength(.05)).force("x",us(0).strength(.02)).force("y",ps(0).strength(.02)).alphaDecay(o>400?.05:.03).velocityDecay(.4);return{nodes:r,links:i,sim:l,byId:a}}function ia(t,n){let s=ms(t,n);s.sim.stop();let a=s.nodes.filter(k=>k.kind==="file"),r=s.nodes.filter(k=>k.kind!=="file"),i=new Map;for(let k of a){let h=(k.path??k.label).split("/").slice(0,-1).join("/")||".";(i.get(h)??i.set(h,[]).get(h)).push(k)}let o=[...i.keys()].sort((k,h)=>k.split("/").length-h.split("/").length||k.localeCompare(h)),l=220,c=34,d=-(o.length-1)*l/2,u=new Map;for(let k of o){let h=i.get(k).sort((b,y)=>b.label.localeCompare(y.label)),p=-(h.length-1)*c/2;for(let b of h)b.x=d,b.y=p,b.fx=d,b.fy=p,u.set(b.path??b.label,b),p+=c;d+=l}let m=new Map,g=[];for(let k of r){let h=k.path?u.get(k.path):void 0;if(!h){g.push(k);continue}let p=m.get(h.id)??0;m.set(h.id,p+1),k.x=(h.x??0)+70+p%3*46,k.y=(h.y??0)+Math.floor(p/3)*14-8,k.fx=k.x,k.fy=k.y}let f=(o.length?i.get(o[0]).length:0)*c/2+60;for(let k of g)k.x=-(g.length-1)*60/2+g.indexOf(k)*60,k.y=f,k.fx=k.x,k.fy=k.y;return f+=40,s}var hs=t=>Le(t.kind),gs=t=>"circle";function oa(t,n=1){return{color:gt(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:un.has(t)}}function la(t,n,s,a,r){switch(t.beginPath(),n){case"square":{let i=r*.88;t.rect(s-i,a-i,i*2,i*2);break}case"diamond":{let i=r*1.25;t.moveTo(s,a-i),t.lineTo(s+i,a),t.lineTo(s,a+i),t.lineTo(s-i,a),t.closePath();break}case"triangle":{let i=r*1.3;t.moveTo(s,a-i),t.lineTo(s+i*.87,a+i*.5),t.lineTo(s-i*.87,a+i*.5),t.closePath();break}case"hexagon":{let i=r*1.12;for(let o=0;o<6;o++){let l=Math.PI/3*o,c=s+i*Math.cos(l),d=a+i*Math.sin(l);o===0?t.moveTo(c,d):t.lineTo(c,d)}t.closePath();break}default:t.arc(s,a,r,0,Math.PI*2)}}function ca(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 Ze({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:ca(t),fill:s?"none":n,stroke:n,"stroke-width":s?1.6:0})})}function bt({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 jo=t=>t.kind==="file"||t.kind==="package"?dn(t.label):t.label.split(".").pop()??t.label,zo=()=>document.documentElement.getAttribute("data-theme")==="dark"||document.documentElement.getAttribute("data-theme")!=="light"&&window.matchMedia("(prefers-color-scheme: dark)").matches;function Be(t){let n=ne(null),s=ne(null),a=ne(null),r=ne({k:1,x:0,y:0}),i=ne(!1),o=ne(null),l=ne(null),[c,d]=_(null),[u,m]=_(!1),g=ne(t);g.current=t;let f=()=>{let C=n.current,L=a.current;if(!C||!L)return;let E=C.getContext("2d");if(!E)return;let I=window.devicePixelRatio||1,B=C.width/I,W=C.height/I,R=r.current,z=zo(),{selected:te,highlight:xe}=g.current,D=g.current.colorOf??hs,K=g.current.shapeOf??gs,he=g.current.edgeStyleOf??oa,Me=g.current.labelOf??jo,pe=te?L.byId.get(te):void 0,se=new Set;if(pe){se.add(pe.id);for(let ee of L.links){let we=ee.source,ge=ee.target;we.id===pe.id&&se.add(ge.id),ge.id===pe.id&&se.add(we.id)}}E.setTransform(I,0,0,I,0,0),E.clearRect(0,0,B,W),E.translate(B/2+R.x,W/2+R.y),E.scale(R.k,R.k);for(let ee of L.links){let we=ee.source,ge=ee.target;if(we.x===void 0||ge.x===void 0)continue;let qt=`${we.id}|${ge.id}|${ee.kind}`,Hn=xe?.has(qt),Kt=pe&&!(se.has(we.id)&&se.has(ge.id))&&we.id!==pe.id&&ge.id!==pe.id,He=he(ee.kind,ee.weight);if(E.globalAlpha=Hn?1:Kt?.06:He.alpha??.45,E.strokeStyle=He.color,E.lineWidth=(Hn?2.5:He.width??1)/R.k,E.setLineDash(He.dash?He.dash.map(Vt=>Vt/R.k):[]),E.beginPath(),E.moveTo(we.x,we.y??0),E.lineTo(ge.x,ge.y??0),E.stroke(),E.setLineDash([]),He.directed&&R.k>.5){let Vt=ge.x-we.x,Gs=(ge.y??0)-(we.y??0),Ws=Math.hypot(Vt,Gs)||1,Et=Vt/Ws,Ct=Gs/Ws,Bn=ge.x-Et*(ge.r+2),Un=(ge.y??0)-Ct*(ge.r+2),Je=5/R.k;E.fillStyle=He.color,E.beginPath(),E.moveTo(Bn,Un),E.lineTo(Bn-Et*Je*2-Ct*Je,Un-Ct*Je*2+Et*Je),E.lineTo(Bn-Et*Je*2+Ct*Je,Un-Ct*Je*2-Et*Je),E.closePath(),E.fill()}}let Ee=L.nodes.length<=120||R.k>1.6;E.font=`${11/R.k}px system-ui, sans-serif`,E.textBaseline="middle";for(let ee of L.nodes){if(ee.x===void 0||ee.y===void 0)continue;let we=pe&&!se.has(ee.id);E.globalAlpha=we?.2:1;let ge=K(ee),qt=D(ee);if(la(E,ge,ee.x,ee.y,ee.r/Math.max(1,R.k**.5)),ge==="ring"?(E.fillStyle=z?"#171a21":"#ffffff",E.fill(),E.lineWidth=1.6/R.k,E.strokeStyle=qt,E.stroke()):(E.fillStyle=qt,E.fill()),(ee.root||ee.id===te||ee===o.current)&&(E.lineWidth=2.5/R.k,E.strokeStyle=z?"#e5e7eb":"#1b1f24",E.stroke()),Ee||ee.root||ee.deg>3||se.has(ee.id)||ee===o.current||ee.id===te){let Kt=Me(ee),He=ee.x+ee.r/Math.max(1,R.k**.5)+3/R.k;E.lineWidth=3/R.k,E.strokeStyle=z?"#171a21":"#ffffff",E.strokeText(Kt,He,ee.y),E.fillStyle=z?"#e5e7eb":"#1b1f24",E.fillText(Kt,He,ee.y)}}E.globalAlpha=1},k=()=>{let C=n.current,L=a.current;if(!C||!L?.nodes.length)return;let E=window.devicePixelRatio||1,I=C.width/E,B=C.height/E,W=Number.POSITIVE_INFINITY,R=Number.POSITIVE_INFINITY,z=Number.NEGATIVE_INFINITY,te=Number.NEGATIVE_INFINITY;for(let he of L.nodes)he.x===void 0||he.y===void 0||(W=Math.min(W,he.x),R=Math.min(R,he.y),z=Math.max(z,he.x),te=Math.max(te,he.y));let xe=Math.max(100,z-W+120),D=Math.max(100,te-R+120),K=Math.min(2.5,Math.min(I/xe,B/D));r.current={k:K,x:-((W+z)/2)*K,y:-((R+te)/2)*K},f()};wr(t.handle??null,()=>({fit:k}),[]);let h=t.nodes.map(C=>C.id).join("|"),p=t.edges.map(C=>`${C.src}|${C.dst}|${C.kind}`).join(`
3
+ `),b=t.mode??"galaxy";j(()=>{let C=t.keepPositions?a.current?.byId:void 0;a.current?.sim.stop();let L=b==="hierarchy"?ia(t.nodes,t.edges):ms(t.nodes,t.edges,C);a.current=L,i.current=!1;let E=!1,I=!1,B=0;if(b==="hierarchy"){k();return}return L.sim.on("tick",()=>{B++,(B%2===0||L.sim.alpha()<.05)&&f(),!E&&(B===30||L.sim.alpha()<.3)&&(E=!0,i.current||k())}),L.sim.on("end",()=>{I||(I=!0,E=!0,i.current||k())}),()=>L.sim.stop()},[h,p,b]),j(()=>{f()},[t.selected,t.highlight,c,t.colorOf,t.shapeOf,t.edgeStyleOf]),j(()=>{let C=s.current,L=n.current;if(!C||!L)return;let E=()=>{let R=window.devicePixelRatio||1;L.width=Math.max(1,C.clientWidth*R),L.height=Math.max(1,C.clientHeight*R),f()};E();let I=new ResizeObserver(E);I.observe(C);let B=window.matchMedia("(prefers-color-scheme: dark)");B.addEventListener("change",f);let W=new MutationObserver(f);return W.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>{I.disconnect(),B.removeEventListener("change",f),W.disconnect()}},[]);let y=C=>{let E=n.current.getBoundingClientRect(),I=r.current;return{x:(C.clientX-E.left-E.width/2-I.x)/I.k,y:(C.clientY-E.top-E.height/2-I.y)/I.k}},v=C=>{let L=a.current;if(!L)return null;let E=y(C),I=r.current,B=null,W=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-E.x,R.y-E.y),te=R.r/Math.max(1,I.k**.5)+6/I.k;z<te&&z<W&&(W=z,B=R)}return B},w=C=>{let L=v(C),E=r.current;l.current={node:L??void 0,px:C.clientX,py:C.clientY,vx:E.x,vy:E.y,moved:!1},L&&(L.fx=L.x,L.fy=L.y,a.current?.sim.alphaTarget(.2).restart()),m(!0),C.preventDefault()},S=C=>{let L=l.current;if(L){let I=C.clientX-L.px,B=C.clientY-L.py;if(Math.abs(I)+Math.abs(B)>3&&(L.moved=!0),L.node){let W=y(C);L.node.fx=W.x,L.node.fy=W.y,b==="hierarchy"&&(L.node.x=W.x,L.node.y=W.y,f())}else L.moved&&(i.current=!0),r.current={...r.current,x:L.vx+I,y:L.vy+B},f();return}let E=v(C);E!==o.current&&(o.current=E,d(E))},T=C=>{let L=l.current;l.current=null,m(!1),L&&(L.node?(b!=="hierarchy"&&(L.node.fx=null,L.node.fy=null,a.current?.sim.alphaTarget(0)),L.moved||g.current.onSelect?.(L.node.id===g.current.selected?null:L.node.id)):L.moved||g.current.onSelect?.(null))},x=C=>{C.preventDefault();let E=n.current.getBoundingClientRect(),I=r.current;i.current=!0;let B=C.deltaY>0?.9:1.1,W=Math.max(.05,Math.min(8,I.k*B)),R=C.clientX-E.left-E.width/2,z=C.clientY-E.top-E.height/2;r.current={k:W,x:R-(R-I.x)*W/I.k,y:z-(z-I.y)*W/I.k},f()},$=C=>{let L=v(C);L&&g.current.onActivate?.(L.id)},A=[...new Set(t.nodes.map(C=>C.kind))],F=[...new Set(t.edges.map(C=>C.kind))];return e("div",{class:"gwrap",ref:s,children:[e("canvas",{ref:n,class:M(u&&"drag",c&&!u&&"hover"),onMouseDown:w,onMouseMove:S,onMouseUp:T,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:[A.map(C=>{let L=t.nodes.find(E=>E.kind===C);return e("span",{children:[t.shapeOf||t.colorOf?e(Ze,{shape:(t.shapeOf??gs)(L),color:(t.colorOf??hs)(L)}):e("i",{style:{background:Le(C)}}),C]})}),F.map(C=>{let L=t.edgeStyleOf?.(C,1);return e("span",{children:[L?e(bt,{color:L.color,dash:L.dash}):e("s",{style:{borderColor:gt(C)}}),C]})})]}),e("button",{type:"button",class:"overlay fit",onClick:k,children:"fit view"})]})}function da(t,n,s,a,r){let i=t.reduce((k,h)=>k+(h.value??h.size),0);if(!i||!t.length)return[];let o=a*r/i,l=[],c=0,d=n,u=s,m=a,g=r,f=[...t].sort((k,h)=>(h.value??h.size)-(k.value??k.size));for(;c<f.length;){let k=m>=g,h=k?g:m,p=[],b=0,y=Number.POSITIVE_INFINITY;for(;c<f.length;){let S=f[c],T=(S.value??S.size)*o,x=[...p,S],$=b+T,A=Math.max(...x.map(L=>(L.value??L.size)*o)),F=Math.min(...x.map(L=>(L.value??L.size)*o)),C=Math.max(h*h*A/($*$),$*$/(h*h*F));if(C>y&&p.length)break;y=C,p=x,b=$,c++}let v=h?b/h:0,w=0;for(let S of p){let T=v?(S.value??S.size)*o/v:0;l.push(k?{node:S,x:d,y:u+w,w:v,h:T,depth:0}:{node:S,x:d+w,y:u,w:T,h:v,depth:0}),w+=T}k?(d+=v,m-=v):(u+=v,g-=v)}return l}function ua(t,n,s,a=18){let r=[];for(let i of da(t.children??[],0,0,n,s))if(r.push({...i,depth:0}),i.node.children?.length&&i.w>40&&i.h>30)for(let o of da(i.node.children,i.x+2,i.y+a,Math.max(0,i.w-4),Math.max(0,i.h-a-2)))r.push({...o,depth:1});return r}function pa(t,n,s){let a={name:n||"(project)",path:n,size:0,children:[]},r=new Map([["",a]]),i=l=>{let c=r.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),r.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(a),a}var ma={typescript:"#2563eb",tsx:"#3b82f6",javascript:"#d97706",python:"#16a34a",go:"#0d9488",php:"#6366f1",other:"#6b7280"};function Xo(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 Go({files:t,arch:n}){let[s,a]=_(""),[r,i]=_("language"),[o,l]=_("loc"),[c,d]=_(null),u=ne(null),[m,g]=_({w:900,h:520});j(()=>{let y=u.current;if(!y)return;let v=new ResizeObserver(()=>g({w:y.clientWidth,h:y.clientHeight}));return v.observe(y),g({w:y.clientWidth,h:y.clientHeight}),()=>v.disconnect()},[]);let f=V(()=>{let y=pa(t,s,v=>o==="uniform"?1:v.loc||Math.max(1,v.size/40));return ua(y,m.w,m.h)},[t,s,o,m]),h=c?(y=>t.filter(v=>v.path===y||v.path.startsWith(`${y}/`)))(c):[],p=h.length===1&&h[0]?.path===c?h[0]:void 0,b=n?.entryPoints.filter(y=>y.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:()=>a(""),children:n?.project.name??"project"}),s.split("/").filter(Boolean).map((y,v,w)=>e(N,{children:[e("span",{class:"muted",children:"\u203A"}),e("a",{onClick:()=>a(w.slice(0,v+1).join("/")),children:y})]}))]}),e("span",{class:"spacer"}),e("span",{class:"row tight",children:[e("button",{type:"button",class:M("chip",o==="loc"&&"on"),onClick:()=>l("loc"),children:"size: loc"}),e("button",{type:"button",class:M("chip",o==="uniform"&&"on"),onClick:()=>l("uniform"),children:"uniform"}),e("button",{type:"button",class:M("chip",r==="language"&&"on"),onClick:()=>i("language"),children:"color: language"}),e("button",{type:"button",class:M("chip",r==="heat"&&"on"),onClick:()=>i("heat"),children:"heat"})]})]}),e("div",{class:"treemap",ref:u,children:f.map(y=>{let v=y.node.data,w=!!y.node.children?.length,S=v?r==="heat"?Xo(v.score):ma[v.language??"other"]??ma.other:void 0;return e("div",{class:M("cell",w&&"dir",c===y.node.path&&"sel"),style:{left:y.x,top:y.y,width:Math.max(0,y.w),height:Math.max(0,y.h),background:S},title:v?`${v.path} \xB7 ${v.loc} loc \xB7 ${v.symbols} symbols \xB7 heat ${v.score.toFixed(2)}`:`${y.node.path} \xB7 ${y.node.size} loc`,onClick:T=>{T.stopPropagation(),d(y.node.path)},onDblClick:T=>{T.stopPropagation(),w?a(y.node.path):v&&H("explore",{file:v.path})},children:w?e("span",{class:"lbl",children:[y.node.name,"/"]}):y.w>50&&y.h>14?y.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"}),p?e(N,{children:[e("div",{class:"row small",children:[e(P,{children:p.language??"?"}),e(P,{children:[p.loc," loc"]}),e(P,{children:[p.symbols," symbols"]}),e(P,{children:["fan-in ",p.fanIn]}),e(P,{children:["heat ",p.score.toFixed(2)]}),e(P,{children:p.status})]}),e("div",{class:"row",style:{marginTop:8},children:[e("button",{type:"button",class:"sm",onClick:()=>H("explore",{file:p.path}),children:"Open source"}),e("button",{type:"button",class:"sm",onClick:()=>H("galaxy",{node:`file:${p.path}`}),children:"Galaxy"})]})]}):h.length?e("div",{class:"row small",children:[e(P,{children:[h.length," files"]}),e(P,{children:[q(h.reduce((y,v)=>y+v.loc,0))," loc"]}),e(P,{children:[h.reduce((y,v)=>y+v.symbols,0)," symbols"]}),e(P,{children:["mean heat ",(h.reduce((y,v)=>y+v.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(y=>e("tr",{class:"click",onClick:()=>H("explore",{file:y.path}),children:[e("td",{children:e(P,{children:y.kind})}),e("td",{class:"break",children:y.name}),e("td",{class:"muted small break",children:y.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(([y,v])=>e(P,{children:[y," ",v]}))]}),n.project.description?e("div",{class:"muted small",style:{marginTop:6},children:n.project.description}):null]})]})]})}function Wo(){let t=G(()=>O("/api/routes"),[]);return t.error?e(Z,{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?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(J,{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(U,{})}function Jo(){let[t,n]=_("file"),[s,a]=_(""),r=G(()=>O("/api/hotspots",{kind:t,path:s.trim()||void 0,limit:80}),[t,s]),{sorted:i,th:o}=Ve(r.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(N,{children:[e("div",{class:"row",style:{marginBottom:10},children:[e("button",{type:"button",class:M("chip",t==="file"&&"on"),onClick:()=>n("file"),children:"files"}),e("button",{type:"button",class:M("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?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"?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(be,{kind:c.kind}):null,c.path]}),e("td",{class:"num",children:[e(We,{value:c.fan_in,max:l.fan_in,width:60})," ",c.fan_in]}),e("td",{class:"num",children:[e(We,{value:c.commits_90d,max:l.commits_90d,width:60})," ",c.commits_90d]}),e("td",{class:"num",children:[e(We,{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(U,{})]})}function qo(){let t=G(()=>O("/api/clusters"),[]),[n,s]=_(null),[a,r]=_(null),[i,o]=_(new Set),l=V(()=>{let u=t.data;if(!u)return{nodes:[],edges:[]};let m=[],g=[];if(a!==null){let f=u.cycles[a]??[];for(let k of f)m.push({id:`file:${k}`,label:k,kind:"file",path:k,line:null});for(let k=0;k<f.length;k++)g.push({src:`file:${f[k]}`,dst:`file:${f[(k+1)%f.length]}`,kind:"imports",weight:1});return{nodes:m,edges:g}}for(let f of u.clusters){if(i.has(f.id))for(let k of u.members[String(f.id)]??[])m.push({id:`file:${k.path}`,label:k.path,kind:"file",path:k.path,line:null,score:k.score});if(m.push({id:`cluster:${f.id}`,label:`#${f.id} ${f.label} (${f.size})`,kind:"cluster",path:null,line:null}),i.has(f.id))for(let k of u.members[String(f.id)]??[])g.push({src:`file:${k.path}`,dst:`cluster:${f.id}`,kind:"link",weight:.5});for(let[k,h]of Object.entries(f.links))g.push({src:`cluster:${f.id}`,dst:`cluster:${k}`,kind:"imports",weight:Math.min(1,h/10),count:h})}return{nodes:m,edges:g}},[t.data,a,i]);if(t.error)return e(Z,{error:t.error});let c=t.data;if(!c)return e(U,{});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(Be,{nodes:l.nodes,edges:l.edges,selected:n,onSelect:s,onActivate:u=>{if(u.startsWith("cluster:")){let m=Number(u.slice(8));o(g=>{let f=new Set(g);return f.has(m)?f.delete(m):f.add(m),f})}else u.startsWith("file:")&&H("explore",{file:u.slice(5)})}}):e(J,{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:M("item",n===`cluster:${u.id}`&&"sel"),onClick:()=>{r(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:()=>H("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,m)=>e("div",{class:M("item",a===m&&"sel"),onClick:()=>{r(a===m?null:m),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"}),a!==null?e("button",{type:"button",class:"sm",style:{marginTop:6},onClick:()=>r(null),children:"show clusters"}):null]})]})]})}function ha({id:t,depth:n,onSelect:s,selected:a}){let r=G(()=>O("/api/behavior",{id:t}),[t]),[i,o]=_(new Set);if(r.error)return e("div",{class:"muted small",children:r.error});if(!r.data)return e(U,{});let l=r.data;return e(N,{children:[n===0&&e("div",{class:M("bnode",a===l.root.id&&"sel"),onClick:()=>s(l),children:[e(P,{children:"start"}),e(be,{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(N,{children:[e("div",{class:M("bnode",a===c.node.id&&"sel"),onClick:()=>s({root:c.node,callees:[]}),children:[e("span",{class:"arrow",onClick:u=>{u.stopPropagation(),o(m=>{let g=new Set(m);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":d?"\u25BE":"\u25B8"}),e(P,{children:c.kind==="handles"?"handles":"possible call"}),e(be,{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(ha,{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 Ko({params:t}){let[n,s]=_(t.node??null),[a,r]=_(""),[i,o]=_([]),[l,c]=_(null);return j(()=>{if(a.trim().length<2)return o([]);let d=setTimeout(()=>{O("/api/nodes/search",{q:a.trim(),limit:10}).then(u=>o(u.filter(m=>m.kind!=="file"&&m.kind!=="package"))).catch(()=>o([]))},180);return()=>clearTimeout(d)},[a]),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:a,onInput:d=>r(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),r(""),o([]),c(null)},children:[e(be,{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(ha,{id:n,depth:0,onSelect:c,selected:l?.root.id??null}):e(J,{children:"Choose a starting operation."})})]}),e("div",{class:"card",children:[e("h3",{children:l?"selected operation":"starting operation"}),l?e(N,{children:[e("div",{class:"row tight",children:[e(be,{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:()=>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 ga({params:t}){let[n,s]=_(t.tab||"overview");j(()=>{t.tab&&s(t.tab)},[t.tab]);let a=G(()=>O("/api/tree"),[]),r=G(()=>O("/api/architecture",{aspects:"overview,entry_points"}),[]);return e("div",{class:"page",children:[e(Ce,{tabs:[["overview","Overview"],["routes","Routes"],["hotspots","Hotspots"],["structure","System structure"],["behavior","Behavior"]],value:n,onChange:s}),n==="overview"&&(a.data?e(Go,{files:a.data.files,arch:r.data}):a.error?e(Z,{error:a.error}):e(U,{})),n==="routes"&&e(Wo,{}),n==="hotspots"&&e(Jo,{}),n==="structure"&&e(qo,{}),n==="behavior"&&e(Ko,{params:t})]})}function fa(){let t=G(()=>O("/api/coverage"),[]),[n,s]=_(""),[a,r]=_(""),[i,o]=_(null),l=V(()=>{let p=a.trim().toLowerCase();return(t.data?.files??[]).filter(b=>(!n||b.status===n)&&(!p||b.path.toLowerCase().includes(p)||(b.reason??"").toLowerCase().includes(p)))},[t.data,n,a]),{sorted:c,th:d}=Ve(l,"path",!1),u=async(p,b)=>{o(p);try{let y=await fe("/api/actions",b);Q(y.output.split(`
4
+ `)[0]??"done",!y.ok),t.reload()}catch(y){Q(y.message,!0)}finally{o(null)}};if(t.error)return e("div",{class:"page",children:e(Z,{error:t.error})});let m=t.data;if(!m)return e("div",{class:"page",children:e(U,{})});let g=m.summary.byStatus,f=Object.values(g).reduce((p,b)=>p+b,0),k=m.freshness.headMatches&&!m.freshness.dirty.length&&!m.freshness.queued,h=[["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"]];return e("div",{class:"page",children:[e("div",{class:"grid",children:[h.map(([p,b,y])=>e("div",{class:M("card"),style:{cursor:"pointer"},onClick:()=>s(n===p?"":p),children:[e("h3",{children:[p,n===p?e("span",{class:"right",children:"filtering"}):null]}),e("div",{class:M("big",p==="skipped"&&b>0&&"bad",p==="partial"&&b>0&&"warn"),children:b}),e("div",{class:"sub",children:y})]})),e("div",{class:"card",children:[e("h3",{children:"freshness"}),e("div",{class:M("big",k?"ok":"warn"),children:k?"fresh":m.freshness.dirty.length||m.freshness.queued?"stale":"git behind"}),e("div",{class:"sub",children:[m.freshness.dirty.length," changed \xB7 ",m.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 ",f]})]}),e("div",{class:"row",style:{marginBottom:8},children:[e("input",{type:"search",class:"grow",placeholder:"filter by path or reason\u2026",value:a,onInput:p=>r(p.target.value)}),e("select",{value:n,onChange:p=>s(p.target.value),children:[e("option",{value:"",children:"any status"}),["indexed","partial","skipped","unsupported"].map(p=>e("option",{value:p,children:p}))]}),e("button",{type:"button",disabled:!!i,onClick:()=>u("code",{action:"reindex",scope:"code"}),children:i==="code"?e(U,{}):"Reindex code"}),e("button",{type:"button",disabled:!!i,onClick:()=>u("full",{action:"reindex",scope:"code",full:!0}),children:i==="full"?e(U,{}):"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(p=>e("tr",{children:[e("td",{class:"break",children:e("a",{onClick:()=>H("explore",{file:p.path}),children:p.path})}),e("td",{children:e(P,{class:p.status==="indexed"?"s-accepted":p.status==="partial"?"s-proposed":"risk-high",children:p.status})}),e("td",{class:"muted small",children:[p.reason??"",p.errors?e("div",{class:"bad small",children:p.errors.slice(0,160)}):null]}),e("td",{class:"num",children:p.symbols??""}),e("td",{class:"num",children:q(p.size??0)}),e("td",{class:"num muted small",children:re(p.indexed_at)}),e("td",{children:e("button",{type:"button",class:"sm",disabled:!!i,onClick:()=>u(p.path,{action:"reindex",scope:"code",paths:[p.path]}),children:i===p.path?e(U,{}):"reindex"})})]})):e("tr",{children:e("td",{colSpan:7,children:e(J,{children:"no files match"})})})})]})})]}),e("div",{class:"stack",children:[e("div",{class:"card",children:[e("h3",{children:"index state"}),e(Ke,{rows:[["HEAD",m.freshness.head?.slice(0,10)??"no git"],["git signals at",m.freshness.indexedHead?`${m.freshness.indexedHead.slice(0,10)}${m.freshness.headMatches?" (current)":" (behind)"}`:"never"],["last run",m.freshness.lastRun?re(m.freshness.lastRun):"never"],["queued",String(m.freshness.queued)],["last scan",m.scan?.at?`${re(m.scan.at)} \xB7 ${m.scan.scanned} files \xB7 ${m.scan.durationMs} ms`:"n/a"]]})]}),m.freshness.dirty.length?e("div",{class:"card",children:[e("h3",{children:["changed since indexed \xB7 ",m.freshness.dirty.length]}),e("div",{class:"list",style:{maxHeight:200},children:m.freshness.dirty.map(p=>e("div",{class:"item",onClick:()=>H("explore",{file:p}),children:e("div",{class:"p",children:p})}))}),e("button",{type:"button",class:"sm",style:{marginTop:6},disabled:!!i,onClick:()=>u("dirty",{action:"reindex",scope:"code",paths:m.freshness.dirty}),children:i==="dirty"?e(U,{}):"Reindex changed files"})]}):null,m.summary.reasons.length?e("div",{class:"card",children:[e("h3",{children:"why files are not fully indexed"}),e("table",{children:e("tbody",{children:m.summary.reasons.map(p=>e("tr",{class:"click",onClick:()=>r(p.reason),children:[e("td",{children:p.reason}),e("td",{class:"num",children:p.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:(m.scan?.include??[]).join(" ")||"(defaults)"}),e("div",{class:"muted",style:{marginTop:4},children:"exclude"}),e("div",{class:"mono break",children:(m.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 Pt=[{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"}],ba=new Map(Pt.map(t=>[t.id,t]));function bn(t){return ba.get(t)??ba.get("local")}var ya={project:"Project documentation",external:"External documentation"};function fs(t){let n=Pt.findIndex(s=>s.id===t);return n===-1?Pt.length:n}function yt({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(i=>e("tr",{class:"click",onClick:()=>a(i.id),children:[e("td",{children:e(P,{children:i.kind})}),e("td",{class:"break",children:s(i.id)})]}))})}),n.length>r?e("div",{class:"muted small",children:["\u2026 ",n.length-r," more"]}):null]})}function Vo(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 yn(t,n){let s=new Set(t.nodes.filter(o=>Vo(o,n)).map(o=>o.id)),a=t.edges.filter(o=>!n.hiddenEdges.has(o.kind)&&s.has(o.src)&&s.has(o.dst)),r=new Set(a.flatMap(o=>[o.src,o.dst]));return{nodes:t.nodes.filter(o=>s.has(o.id)&&(o.seed||o.root||r.has(o.id))),edges:a}}function st(t,n){let s=new Map;for(let a of t)s.set(n(a),(s.get(n(a))??0)+1);return s}var Zo={memory:"diamond",doc:"square",tag:"triangle",topic:"hexagon"};function vn(t){return t.missing?"ring":Zo[t.kind]??"circle"}function kn(t){let n=t;return n.group==="memory"&&(n.status==="superseded"||n.status==="deprecated")?"#93c5fd":Le(t.kind)}function Nt(t){let n={links:[4,3],supersedes:[6,3],about:[2,3],tagged:[1,3],in_topic:[1,3]};return{color:gt(t),dash:n[t],width:t==="documents"||t==="mentions"?1.4:1,alpha:t==="tagged"||t==="in_topic"?.35:.55,directed:un.has(t)}}function va(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 Yo=["proposed","accepted","superseded","deprecated"],Qo=["memory","doc","topic","tag","file","package"],el=["mentions","links","supersedes","documents","about","tagged","in_topic"],tl={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"},ka=(t,n)=>[...t].sort((s,a)=>{let r=n.indexOf(s),i=n.indexOf(a);return(r===-1?99:r)-(i===-1?99:i)||s.localeCompare(a)});function wa(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",[a,r]=_(null),[i,o]=_(!1),[l,c]=_(0),[d,u]=_(new Set),[m,g]=_(new Set),[f,k]=_(""),[h,p]=_(""),[b,y]=_(t==="memory"),[v,w]=_(!1),[S,T]=_(n??null);j(()=>{let D=!0;return o(!0),O("/api/knowledge",{scope:t,focus:n,limit:300}).then(K=>{D&&(r(K),T(n??null))}).catch(K=>D&&Q(K.message,!0)).finally(()=>D&&o(!1)),()=>{D=!1}},[t,n,l]);let x=V(()=>a?yn(a,{hiddenKinds:d,hiddenEdges:m,status:f,category:h,hideSuperseded:b}):null,[a,d,m,f,h,b]),$=V(()=>st(a?.nodes??[],D=>D.kind),[a]),A=V(()=>st(a?.edges??[],D=>D.kind),[a]),F=D=>a?.nodes.find(K=>K.kind===D&&!K.missing),C=V(()=>[...new Set((a?.nodes??[]).filter(D=>D.group==="doc"&&D.sub).map(D=>D.sub))],[a]),L=(a?.nodes??[]).some(D=>D.group==="memory"),E=V(()=>new Map((a?.nodes??[]).map(D=>[D.id,D])),[a]),I=S?E.get(S):void 0,B=x?.edges??[],W=I?B.filter(D=>D.dst===I.id):[],R=I?B.filter(D=>D.src===I.id):[],z=D=>E.get(D)?.label??D,te=D=>H(s,{tab:"graph",focus:D}),xe=n?E.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:xe?.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"}),L?e(N,{children:[e("select",{value:f,title:"memory status",onChange:D=>k(D.target.value),children:[e("option",{value:"",children:"any status"}),Yo.map(D=>e("option",{value:D,children:D}))]}),e("button",{type:"button",class:M("chip",b&&"on"),onClick:()=>y(!b),children:"hide superseded"})]}):null,C.length?e("select",{value:h,title:"doc category",onChange:D=>p(D.target.value),children:[e("option",{value:"",children:"any category"}),C.map(D=>e("option",{value:D,children:bn(D).label}))]}):null,e("button",{type:"button",class:M("chip",v&&"on"),onClick:()=>w(!v),children:"legend"}),e("button",{type:"button",class:"sm",title:"reload",onClick:()=>c(D=>D+1),children:"\u21BB"}),e("span",{class:"count",children:i?e(U,{}):x&&a?`${x.nodes.length} of ${a.nodes.length} nodes \xB7 ${x.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:"}),ka([...$.keys()],Qo).map(D=>{let K=F(D);return e("button",{type:"button",class:M("chip",!d.has(D)&&"on"),onClick:()=>u(wa(d,D)),children:[K?e(Ze,{shape:vn(K),color:kn(K)}):null,D," ",$.get(D)]})}),e("span",{class:"muted small",style:{marginLeft:8},children:"edges:"}),ka([...A.keys()],el).map(D=>{let K=Nt(D);return e("button",{type:"button",title:tl[D],class:M("chip",!m.has(D)&&"on"),onClick:()=>g(wa(m,D)),children:[e(bt,{color:K.color,dash:K.dash}),D," ",A.get(D)]})})]}),e("div",{class:"kbody",style:{gridTemplateColumns:I?"minmax(0,1fr) 320px":"minmax(0,1fr)"},children:[e("div",{style:{minWidth:0,minHeight:0},children:x?x.nodes.length?e(Be,{nodes:x.nodes,edges:x.edges,selected:S,onSelect:T,onActivate:te,legend:v,colorOf:kn,shapeOf:vn,edgeStyleOf:Nt,labelOf:va}):a?.nodes.length?e(J,{children:"Nothing left after these filters."}):t==="docs"?e(J,{children:"No documentation sources yet. Add some from Discover."}):e(J,{children:"No memories yet."}):e(J,{children:e(U,{})})}),I&&e("div",{class:"panel right",children:[e("div",{class:"head",children:["selection ",e("span",{class:"spacer"}),e("a",{onClick:()=>T(null),children:"close"})]}),e("div",{class:"body",children:[e(nl,{node:I,focus:n,onFocus:te}),e(yt,{title:"incoming",rows:W.map(D=>({kind:D.kind,id:D.src})),label:z,onPick:T}),e(yt,{title:"outgoing",rows:R.map(D=>({kind:D.kind,id:D.dst})),label:z,onPick:T})]})]})]})]})}function nl({node:t,focus:n,onFocus:s}){let a=t.group==="hub";return e("div",{class:"section",children:[e("div",{class:"row tight",children:[e(Ze,{shape:vn(t),color:kn(t)}),e(be,{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(r=>e(P,{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 sl={url:"#2563eb",path:"#16a34a"},rl={catalog:"#16a34a",probe:"#2563eb",registry:"#d97706",unknown:"#6b7280"};function _a({kind:t}){return e("span",{class:"tag kind",style:{color:sl[t]??"#6b7280"},children:t})}function Sa({urls:t}){return e("span",{class:"break",children:t.map((n,s)=>e(N,{children:[s?", ":"",e("a",{href:n,target:"_blank",rel:"noreferrer",children:n})]}))})}function al({s:t,busy:n,onSync:s,onRemove:a}){let r=G(()=>O("/api/docs/pages",{name:t.name}),[t.name,t.sync?.at]),i=[["kind",e(_a,{kind:t.kind})],...t.provider?[["provider",t.provider]]:[],...t.title?[["title",t.title]]:[],t.kind==="url"?["seeds",e(Sa,{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?`${re(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(U,{}):"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(Ke,{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,")"]})]}),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(o=>e("tr",{children:[e("td",{class:"break",children:o.uri?.startsWith("http")?e("a",{href:o.uri,target:"_blank",rel:"noreferrer",children:o.title}):o.title}),e("td",{class:"num",children:o.chunks}),e("td",{class:"muted nowrap",children:Se(o.created_at)})]}))})]}):e(J,{children:"nothing indexed yet \u2014 run sync"}):e(U,{})]})}function il({onDone:t}){let[n,s]=_(""),[a,r]=_(""),[i,o]=_(""),[l,c]=_(""),[d,u]=_(""),[m,g]=_(""),[f,k]=_(""),[h,p]=_(""),[b,y]=_(!1);return e("div",{class:"card",children:[e("h3",{children:"add a source"}),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:w=>s(w.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:w=>r(w.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:d,onInput:w=>u(w.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:i,onInput:w=>o(w.target.value)})]}),e("div",{class:"field",children:[e("label",{children:"globs (comma separated)"}),e("input",{type:"text",placeholder:"**/*.md",value:l,onInput:w=>c(w.target.value)})]}),e("div",{class:"field",children:[e("label",{children:"crawl depth"}),e("input",{type:"number",min:0,max:3,value:m,onInput:w=>g(w.target.value)})]}),e("div",{class:"field",children:[e("label",{children:"max pages"}),e("input",{type:"number",min:1,max:200,value:f,onInput:w=>k(w.target.value)})]}),e("div",{class:"field",children:[e("label",{children:"tags"}),e("input",{type:"text",value:h,onInput:w=>p(w.target.value)})]})]}),e("div",{class:"row",children:e("button",{type:"button",class:"primary",disabled:b,onClick:async()=>{let w=a.split(/\s+/).map(S=>S.trim()).filter(Boolean);if(!w.length&&!i.trim()&&!d.trim())return Q("give a url, a path or a provider",!0);y(!0);try{let S=await fe("/api/docs",{sources:[{name:n.trim()||void 0,urls:w.length?w:void 0,path:i.trim()||void 0,glob:l.trim()?l.split(",").map(T=>T.trim()).filter(Boolean):void 0,provider:d.trim()||void 0,crawl:m||f?{depth:m?Number(m):void 0,maxPages:f?Number(f):void 0}:void 0,tags:h.trim()?h.split(",").map(T=>T.trim()).filter(Boolean):void 0}],sync:!0});Q(S.failed.length?S.failed[0].reason:`added ${[...S.added,...S.updated].join(", ")}`,!!S.failed.length),t(S),S.failed.length||(s(""),r(""),o(""),c(""),u(""))}catch(S){Q(S.message,!0)}finally{y(!1)}},children:b?e(U,{}):"Add & index"})})]})}function bs(t){let n=t.tags?.[0];return t.kind==="path"&&n&&(t.name===n||t.name.startsWith(`${n}-`))?n:t.name}function xa(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 ol({s:t,sel:n,onSelect:s}){let a=bs(t);return e("div",{class:M("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
+ `):xa(t),children:[e(_a,{kind:t.kind}),t.provider?e("span",{class:"muted",children:[t.provider," \xB7 "]}):null,e("span",{class:"muted",children:xa(t)})]}),e("div",{class:"p",children:e("span",{class:"muted",children:[t.documents," docs \xB7 ",t.chunks," chunks \xB7"," ",t.sync?`synced ${re(t.sync.at)}`:"never synced",t.sync?.errors.length?e("span",{class:"bad",children:[" \xB7 ",t.sync.errors.length," errors"]}):null]})})]})}function ll({params:t,onLog:n}){let s=G(()=>O("/api/docs"),[]),[a,r]=_(t.name??null),[i,o]=_(""),[l,c]=_(!1),[d,u]=_(null);j(()=>{t.name&&r(t.name)},[t.name]);let[m,g]=_("all"),[f,k]=_(new Set),h=s.data,p=V(()=>{let x=i.trim().toLowerCase();return(h?.sources??[]).filter($=>(m==="all"||$.category===m)&&(!x||$.name.includes(x)||($.title??"").toLowerCase().includes(x)||($.provider??"").includes(x)||($.tags??[]).some(A=>A.includes(x))||($.urls??[]).some(A=>A.includes(x))||($.path??"").includes(x)))},[h,i,m]),b=V(()=>{let x=new Map;for(let $ of h?.sources??[])x.set($.category,(x.get($.category)??0)+1);return x},[h]),y=V(()=>{let x=new Map;for(let F of p){let C=x.get(F.category)??[];C.push(F),x.set(F.category,C)}let $=[...x.entries()].sort((F,C)=>fs(F[0])-fs(C[0])).map(([F,C])=>({info:bn(F),items:C.sort((L,E)=>bs(L).localeCompare(bs(E)))})),A=[];for(let F of $){let C=A[A.length-1];C?.group===F.info.group?C.cats.push(F):A.push({group:F.info.group,label:ya[F.info.group],cats:[F]})}return A},[p]),v=x=>k($=>{let A=new Set($);return A.has(x)?A.delete(x):A.add(x),A}),w=p.find(x=>x.name===a)??h?.sources.find(x=>x.name===a),S=async(x,$)=>{let A=x?.length===1?`sync ${x[0]}`:"sync all";u(A);try{let F=await fe("/api/docs/sync",{names:x,force:$});n(F.text),Q(`${A} done`),s.reload()}catch(F){Q(F.message,!0)}finally{u(null)}},T=async x=>{if(confirm(`Remove documentation source "${x}" and its indexed pages?`))try{let $=await cn("/api/docs",{name:x});Q(`removed ${x} (${$.documents} document(s))`),r(null),s.reload()}catch($){Q($.message,!0)}};return s.error?e(Z,{error:s.error}):e(N,{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(U,{}):"\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:M("chip",m==="all"&&"on"),onClick:()=>g("all"),children:["All \xB7 ",h.sources.length]}),Pt.filter(x=>b.get(x.id)).map(x=>e("button",{type:"button",class:M("chip",m===x.id&&"on"),title:x.blurb,onClick:()=>g(m===x.id?"all":x.id),children:[x.label," \xB7 ",b.get(x.id)]}))]}):null,l&&e(il,{onDone:x=>{n(x.text),s.reload();let $=[...x.added,...x.updated][0];$&&r($)}}),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?p.length?y.map(x=>e(N,{children:[y.length>1?e("div",{class:"group-h",children:x.label}):null,x.cats.map(({info:$,items:A})=>{let F=!f.has($.id);return e(N,{children:[e("div",{class:M("cat-h",!F&&"closed"),title:$.blurb,onClick:()=>v($.id),children:[e("span",{class:"caret",children:F?"\u25BE":"\u25B8"}),$.label,e("span",{class:"muted",children:[" \xB7 ",A.length]}),e("span",{class:"muted small right",children:[q(A.reduce((C,L)=>C+L.documents,0))," docs"]})]}),F?A.map(C=>e(ol,{s:C,sel:a===C.name,onSelect:()=>r(C.name)})):null]})})]})):e(J,{children:h.sources.length?"no sources match":"No documentation sources yet. Use Discover, or add a url, path or provider."}):e(J,{children:e(U,{})})})}),e("div",{class:"card",children:w?e(al,{s:w,busy:d,onSync:x=>S([w.name],x),onRemove:()=>T(w.name)}):e(J,{children:"Select a source to see its pages and sync state."})})]})]})}function cl({onLog:t,onAdded:n}){let[s,a]=_(!1),[r,i]=_(!1),o=G(()=>r?O("/api/docs/discover",{dev:s?1:void 0}):Promise.resolve(void 0),[r,s]),[l,c]=_(new Set),[d,u]=_({}),[m,g]=_(!1),f=o.data;j(()=>{if(!f)return;let v=new Set;for(let w of f.local)w.registered||v.add(`local:${w.name}`);for(let w of f.providers)!w.registered&&(w.confidence==="probe"||w.confidence==="catalog"&&w.tier!=="library"&&w.tier!=="infra")&&v.add(`prov:${w.name}`);c(v)},[f]);let k=v=>c(w=>{let S=new Set(w);return S.has(v)?S.delete(v):S.add(v),S}),h=async()=>{if(!f)return;let v=[];for(let w of f.local)l.has(`local:${w.name}`)&&v.push({name:w.name,path:w.path,glob:w.glob,title:w.why,tags:w.project?[w.project]:void 0});for(let w of f.providers){if(!l.has(`prov:${w.name}`))continue;let S=d[w.name]?.trim(),T=S?S.split(/\s+/).filter(Boolean):w.urls.length?w.urls:void 0;!T&&w.confidence==="unknown"||v.push({name:w.name,provider:w.provider,urls:T,title:w.title,crawl:w.crawl})}if(!v.length)return Q("nothing selected",!0);g(!0),t(`adding ${v.length} source(s)\u2026`);try{let w=await fe("/api/docs",{sources:v,sync:!0});t(w.text),Q(`${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){Q(w.message,!0)}finally{g(!1)}},p=v=>(f?.providers??[]).filter(w=>w.confidence===v),b=({keyId:v,title:w,meta:S,right:T,registered:x})=>e("tr",{class:M(x&&"muted"),children:[e("td",{style:{width:24},children:e("input",{type:"checkbox",disabled:x,checked:l.has(v),onChange:()=>k(v)})}),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:T??null})]}),y=({conf:v,note:w})=>{let S=p(v);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:rl[v]},children:v})," ",v==="catalog"?"libraries, services and infrastructure":v==="probe"?"third-party APIs called from code":v==="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(T=>e(b,{keyId:`prov:${T.name}`,registered:T.registered,title:e(N,{children:[e("b",{children:T.name})," ",e("span",{class:"muted small",children:["\u2190 ",T.provider]})]}),meta:e(N,{children:[T.title,T.usedBy.length>1?` \xB7 used by ${T.usedBy.length} projects`:T.usedBy[0]&&T.usedBy[0]!=="."?` \xB7 ${T.usedBy[0]}`:"",T.urls.length?e(N,{children:[" \xB7 ",e(Sa,{urls:T.urls.slice(0,2)})]}):v==="probe"||v==="unknown"?` \xB7 ${T.evidence[0]}`:""]}),right:v==="unknown"||v==="probe"?e("input",{type:"text",placeholder:v==="probe"?"docs url (optional; probed if empty)":"docs url",style:{minWidth:220},value:d[T.name]??"",onInput:x=>u({...d,[T.name]:x.target.value})}):void 0}))})})]}):null};return e(N,{children:[e("div",{class:"row",style:{marginBottom:12},children:[e("button",{type:"button",class:"primary",disabled:o.loading&&r,onClick:()=>r?o.reload():i(!0),children:o.loading&&r?e(U,{}):r?"\u21BB Scan again":"Scan project"}),e("label",{class:"small",children:[e("input",{type:"checkbox",checked:s,onChange:v=>a(v.target.checked)})," ","include devDependencies"]}),e("span",{class:"spacer"}),f?e(N,{children:[e("span",{class:"muted small",children:[f.projects.length>1?`${f.projects.length} projects \xB7 `:"",f.local.length," local \xB7 ",f.providers.length," providers \xB7 ",l.size," selected"]}),e("button",{type:"button",class:"primary",disabled:m||!l.size,onClick:h,children:m?e(U,{}):"Add selected & index"})]}):null]}),o.error?e(Z,{error:o.error}):null,r?f?e(N,{children:[f.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:f.local.map(v=>e(b,{keyId:`local:${v.name}`,registered:v.registered,title:e(N,{children:[e("b",{children:v.name})," ",e("span",{class:"muted small",children:v.path})]}),meta:`${v.files} file(s) \xB7 ${q(v.bytes)} B \xB7 ${v.why}${v.glob&&v.glob.length<=4?` \xB7 ${v.glob.join(", ")}`:""}`}))})})]}):null,e(y,{conf:"catalog",note:"documentation URLs known offline"}),e(y,{conf:"probe",note:"docs., developer. and /docs locations are probed when added; give a url to skip the guess"}),e(y,{conf:"registry",note:"homepage and README come from the package registry when added"}),e(y,{conf:"unknown",note:"needs a documentation url"})]}):e(U,{}):e(J,{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 dl({sources:t}){let[n,s]=_(""),[a,r]=_(""),[i,o]=_(""),l=G(()=>i?O("/api/search",{q:i,source:a?`docs:${a}`:"docs:*",limit:15}):Promise.resolve(void 0),[i,a]);return e(N,{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: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:()=>o(n.trim()),children:"Search"})]}),l.error?e(Z,{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(J,{children:"no matches"}):e(U,{}):e(J,{children:"Searches only the documentation sources (source docs:*). Claude uses the same index through em_docs lookup."})]})}function Ta({params:t}){let[n,s]=_(t.tab??"sources"),[a,r]=_([]),[i,o]=_(0),l=G(()=>O("/api/docs"),[i]),c=d=>r(u=>[...u,`[${new Date().toLocaleTimeString()}]
7
+ ${d}`]);return j(()=>{t.tab&&s(t.tab)},[t.tab]),e("div",{class:"page",children:[e(Ce,{tabs:[["sources","Sources"],["discover","Discover"],["search","Search"],["graph","Graph"]],value:n,onChange:d=>{s(d),H("docs",{tab:d})}}),n==="sources"&&e(ll,{params:t,onLog:c},i),n==="discover"&&e(cl,{onLog:c,onAdded:()=>o(d=>d+1)}),n==="search"&&e(dl,{sources:(l.data?.sources??[]).map(d=>d.name)}),n==="graph"&&e(wn,{scope:"docs",focus:t.focus}),a.length?e("div",{class:"card",style:{marginTop:12},children:[e("h3",{children:["sync log"," ",e("button",{type:"button",class:"sm right",onClick:()=>r([]),children:"clear"})]}),e("pre",{class:"log",children:a.join(`
8
8
 
9
- `)})]}):null]})}var ss=Sa(ii(),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,i=/(?:\{(?:\{(?:\{[^{}]*\}|[^{}])*\}|[^{}])*\})/.source,r=/(?:\{<S>*\.{3}(?:[^{}]|<BRACES>)*\})/.source;function a(c,d){return c=c.replace(/<S>/g,function(){return s}).replace(/<BRACES>/g,function(){return i}).replace(/<SPREAD>/g,function(){return r}),RegExp(c,d)}r=a(r).source,t.languages.jsx=t.languages.extend("markup",n),t.languages.jsx.tag.pattern=a(/<\/?(?:[\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:a(/<SPREAD>/.source),inside:t.languages.jsx}},t.languages.jsx.tag),t.languages.insertBefore("inside","special-attr",{script:{pattern:a(/=<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=[],p=0;p<c.length;p++){var m=c[p],g=!1;if(typeof m!="string"&&(m.type==="tag"&&m.content[0]&&m.content[0].type==="tag"?m.content[0].content[0].content==="</"?d.length>0&&d[d.length-1].tagName===o(m.content[0].content[1])&&d.pop():m.content[m.content.length-1].content==="/>"||d.push({tagName:o(m.content[0].content[1]),openedBraces:0}):d.length>0&&m.type==="punctuation"&&m.content==="{"?d[d.length-1].openedBraces++:d.length>0&&d[d.length-1].openedBraces>0&&m.type==="punctuation"&&m.content==="}"?d[d.length-1].openedBraces--:g=!0),(g||typeof m=="string")&&d.length>0&&d[d.length-1].openedBraces===0){var f=o(m);p<c.length-1&&(typeof c[p+1]=="string"||c[p+1].type==="plain-text")&&(f+=o(c[p+1]),c.splice(p+1,1)),p>0&&(typeof c[p-1]=="string"||c[p-1].type==="plain-text")&&(f=o(c[p-1])+f,c.splice(p-1,1),p--),c[p]=new t.Token("plain-text",f,null,f)}m.content&&typeof m.content!="string"&&l(m.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:/![sra](?=[:}]$)/,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,i){return"___"+s.toUpperCase()+i+"___"}Object.defineProperties(t.languages["markup-templating"]={},{buildPlaceholders:{value:function(s,i,r,a){if(s.language===i){var o=s.tokenStack=[];s.code=s.code.replace(r,function(l){if(typeof a=="function"&&!a(l))return l;for(var c=o.length,d;s.code.indexOf(d=n(i,c))!==-1;)++c;return o[c]=l,d}),s.grammar=t.languages.markup}}},tokenizePlaceholders:{value:function(s,i){if(s.language!==i||!s.tokenStack)return;s.grammar=t.languages[i];var r=0,a=Object.keys(s.tokenStack);function o(l){for(var c=0;c<l.length&&!(r>=a.length);c++){var d=l[c];if(typeof d=="string"||d.content&&typeof d.content=="string"){var p=a[r],m=s.tokenStack[p],g=typeof d=="string"?d:d.content,f=n(i,p),x=g.indexOf(f);if(x>-1){++r;var h=g.substring(0,x),u=new t.Token(i,t.tokenize(m,s.grammar),"language-"+i,m),y=g.substring(x+f.length),b=[];h&&b.push.apply(b,o([h])),b.push(u),y&&b.push.apply(b,o([y])),typeof d=="string"?l.splice.apply(l,[c,1].concat(b)):d.content=b}}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*\()/],i=/\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}|\??->|[!=]=?=?|::|\*\*=?|--|\+\+|&&|\|\||<<|>>|[?~]|[/^|%*&<>.+-]=?/,a=/[{}\[\](),:;]/;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:i,operator:r,punctuation:a};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:i,operator:r,punctuation:a}},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(p){return p=p.replace(/<inner>/g,function(){return n}),RegExp(/((?:^|[^\\])(?:\\{2})*)/.source+"(?:"+p+")")}var i=/(?:\\.|``(?:[^`\r\n]|`(?!`))+``|`[^`\r\n]+`|[^\\|\r\n`])+/.source,r=/\|?__(?:\|__)+\|?(?:(?:\n|\r\n?)|(?![\s\S]))/.source.replace(/__/g,function(){return i}),a=/\|?[ \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+a+"(?:"+r+")*","m"),inside:{"table-data-rows":{pattern:RegExp("^("+r+a+")(?:"+r+")*$"),lookbehind:!0,inside:{"table-data":{pattern:RegExp(i),inside:t.languages.markdown},punctuation:/\|/}},"table-line":{pattern:RegExp("^("+r+")"+a+"$"),lookbehind:!0,inside:{punctuation:/\||:?-{3,}:?/}},"table-header-row":{pattern:RegExp("^"+r+"$"),inside:{"table-header":{pattern:RegExp(i),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(p){["url","bold","italic","strike","code-snippet"].forEach(function(m){p!==m&&(t.languages.markdown[p].inside.content.inside[m]=t.languages.markdown[m])})}),t.hooks.add("after-tokenize",function(p){if(p.language!=="markdown"&&p.language!=="md")return;function m(g){if(!(!g||typeof g=="string"))for(var f=0,x=g.length;f<x;f++){var h=g[f];if(h.type!=="code"){m(h.content);continue}var u=h.content[1],y=h.content[3];if(u&&y&&u.type==="code-language"&&y.type==="code-block"&&typeof u.content=="string"){var b=u.content.replace(/\b#/g,"sharp").replace(/\b\+\+/g,"pp");b=(/[a-z][\w-]*/i.exec(b)||[""])[0].toLowerCase();var v="language-"+b;y.alias?typeof y.alias=="string"?y.alias=[y.alias,v]:y.alias.push(v):y.alias=[v]}}}m(p.tokens)}),t.hooks.add("wrap",function(p){if(p.type==="code-block"){for(var m="",g=0,f=p.classes.length;g<f;g++){var x=p.classes[g],h=/language-(.+)/.exec(x);if(h){m=h[1];break}}var u=t.languages[m];if(u)p.content=t.highlight(d(p.content),u,m);else if(m&&m!=="none"&&t.plugins.autoloader){var y="md-"+new Date().valueOf()+"-"+Math.floor(Math.random()*1e16);p.attributes.id=y,t.plugins.autoloader.loadLanguages(m,function(){var b=document.getElementById(y);b&&(b.innerHTML=t.highlight(b.textContent,t.languages[m],m))})}}});var o=RegExp(t.languages.markup.tag.pattern.source,"gi"),l={amp:"&",lt:"<",gt:">",quot:'"'},c=String.fromCodePoint||String.fromCharCode;function d(p){var m=p.replace(o,"");return m=m.replace(/&(\w{1,8}|#x?[\da-f]{1,8});/gi,function(g,f){if(f=f.toLowerCase(),f[0]==="#"){var x;return f[1]==="x"?x=parseInt(f.slice(2),16):x=Number(f.slice(1)),c(x)}else{var h=l[f];return h||g}}),m}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},i={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:i},{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:i},{pattern:/(^|[^$\\])'[^']*'/,lookbehind:!0,greedy:!0},{pattern:/\$'(?:[^'\\]|\\[\s\S])*'/,greedy:!0,inside:{entity:i.entity}}],environment:{pattern:RegExp("\\$?"+n),alias:"constant"},variable:i.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"],a=i.variable[1].inside,o=0;o<r.length;o++)a[r[o]]=t.languages.bash[r[o]];t.languages.sh=t.languages.bash,t.languages.shell=t.languages.bash})(Prism);var To=t=>t.replace(/[&<>]/g,n=>({"&":"&amp;","<":"&lt;",">":"&gt;"})[n]??n);function dn(t,n){let s=ss.default.languages[n];if(!s)return t.split(`
10
- `).map(To);let i=ss.default.highlight(t,s,n),r=[],a=[],o="",l=i.split(/(<span[^>]*>|<\/span>|\n)/);for(let c of l)c===`
11
- `?(r.push(o+"</span>".repeat(a.length)),o=a.join("")):c.startsWith("<span")?(a.push(c),o+=c):(c==="</span>"&&a.pop(),o+=c);return r.push(o+"</span>".repeat(a.length)),r}function ai({code:t,lang:n,symbols:s,highlight:i,scrollTo:r,onLine:a}){let o=K(()=>dn(t,n),[t,n]),l=K(()=>{let p=new Map;for(let m of s??[])m.start_line&&!p.has(m.start_line)&&p.set(m.start_line,m);return p},[s]),c=p=>{let m;for(let g of s??[])g.start_line&&g.end_line&&g.start_line<=p&&g.end_line>=p&&(!m||g.end_line-g.start_line<m.end_line-m.start_line)&&(m=g);return m},d=oe(null);return j(()=>{if(!r||!d.current)return;let p=d.current.querySelector(`tr[data-l="${r}"]`);p&&p.scrollIntoView({block:"center"})},[r]),e("div",{class:"code",ref:d,children:e("table",{children:e("tbody",{children:o.map((p,m)=>{let g=m+1,f=l.get(g),x=i&&g>=i[0]&&g<=i[1];return e("tr",{"data-l":g,class:L(x&&"hl",f&&"sym"),children:[e("td",{class:"ln",onClick:()=>a?.(g,c(g)),title:f?`${f.kind} ${f.name}`:void 0,children:g}),e("td",{dangerouslySetInnerHTML:{__html:p||" "}})]})})})})})}function Eo(t){let n={name:"",path:"",dirs:new Map,files:[]};for(let s of t){let i=s.path.split("/"),r=n;for(let a of i.slice(0,-1)){let o=r.dirs.get(a);o||(o={name:a,path:r.path?`${r.path}/${a}`:a,dirs:new Map,files:[]},r.dirs.set(a,o)),r=o}r.files.push(s)}return n}function li({dir:t,depth:n,open:s,toggle:i,selected:r,onSelect:a,filter:o}){let l=[...t.dirs.values()].sort((p,m)=>p.name.localeCompare(m.name)),c=[...t.files].sort((p,m)=>p.path.localeCompare(m.path)),d={paddingLeft:`${8+n*14}px`};return e(N,{children:[l.map(p=>{let m=s.has(p.path)||!!o;return e(N,{children:[e("div",{class:"node",style:d,onClick:()=>i(p.path),children:[e("span",{class:"arrow",children:m?"\u25BE":"\u25B8"}),e("span",{class:"name",children:p.name})]}),m&&e(li,{dir:p,depth:n+1,open:s,toggle:i,selected:r,onSelect:a,filter:o})]})}),c.map(p=>e("div",{class:L("node",r===p.path&&"sel"),style:d,title:`${p.status}${p.reason?` (${p.reason})`:""} \xB7 ${p.symbols} symbols \xB7 ${p.loc} loc`,onClick:()=>a(p.path),children:[e("span",{class:"arrow"}),e("i",{class:L("st",p.status)}),e("span",{class:"name",children:Vt(p.path)}),e("span",{class:L("heat",p.score>.6&&"hot"),children:p.score?p.score.toFixed(2):""})]}))]})}function Co({files:t,selected:n,onSelect:s}){let[i,r]=_(""),[a,o]=_(()=>{let d=new Set;if(n){let p=n.split("/");for(let m=1;m<p.length;m++)d.add(p.slice(0,m).join("/"))}else{let p=new Map;for(let m of t){let g=m.path.split("/")[0];m.path.includes("/")&&p.set(g,(p.get(g)??0)+1)}for(let[m]of[...p].sort((g,f)=>f[1]-g[1]).slice(0,2))d.add(m)}return d});j(()=>{n&&o(d=>{let p=new Set(d),m=n.split("/");for(let g=1;g<m.length;g++)p.add(m.slice(0,g).join("/"));return p})},[n]);let l=K(()=>{let d=i.trim().toLowerCase();return d?t.filter(p=>p.path.toLowerCase().includes(d)):t},[t,i]),c=K(()=>Eo(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:i,onInput:d=>r(d.target.value)})}),e("div",{class:"body tree",children:e(li,{dir:c,depth:0,open:a,toggle:d=>o(p=>{let m=new Set(p);return m.has(d)?m.delete(d):m.add(d),m}),selected:n,onSelect:s,filter:i})})]})}function oi({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(i=>e("tr",{class:"click",onClick:()=>s(i.node.id,i.node.path,i.node.line),children:[e("td",{children:e(I,{children:i.kind})}),e("td",{class:"break",children:[e(pe,{kind:i.node.kind})," ",i.node.label,i.node.path&&i.node.kind!=="file"?e("div",{class:"muted small",children:[i.node.path,i.lines?.length?` \xB7 L${i.lines.join(", L")}`:""]}):null]}),e("td",{class:"num muted",children:i.count??""})]}))})}),n.length>40?e("div",{class:"muted small",children:["\u2026 ",n.length-40," more"]}):null]}):null}function $o({file:t,impact:n,symbol:s,onPick:i}){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:()=>O("history",{file:t}),children:"history"}),e("a",{onClick:()=>O("galaxy",{node:s?s.node.id:`file:${t}`}),children:"open in Galaxy \u2192"})]}),e("div",{class:"body",children:s?e(N,{children:[e("div",{class:"section",children:[e("div",{class:"row tight",children:[e(pe,{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(oi,{title:"callers and references",rows:s.callers,onPick:i}),e(oi,{title:"calls and uses",rows:s.callees,onPick:i}),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:()=>i(r.id,r.path,r.line),children:[e(pe,{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:()=>O("memory",{name:r.name}),children:r.name})," ",e(I,{children:r.kind})]}))]}):null]}):n?e(N,{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(Fe,{nodes:n.graph.nodes,edges:n.graph.edges,legend:!1,onActivate:r=>r.startsWith("file:")&&i(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:()=>i(r.id,r.path,null),children:[e("td",{class:"break",children:[e(pe,{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:()=>O("memory",{name:r}),children:r})}))]}):null]}):e("div",{class:"section",children:e(B,{})})})]}):e("div",{class:"panel right",children:e(X,{children:"Select a file to see what depends on it."})})}function ci({params:t}){let n=t.file,s=t.line?Number(t.line):void 0,i=G(()=>H("/api/tree"),[]),r=G(()=>n?H("/api/file",{path:n}):Promise.resolve(void 0),[n]),a=G(()=>n?H("/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=G(()=>o?H("/api/symbol",{id:o}):Promise.resolve(void 0),[o]),d=(x,h,u)=>O("explore",{file:x,line:h?String(h):void 0,symbol:u}),p=(x,h,u)=>{x.startsWith("file:")?d(x.slice(5)):h?d(h,u,x):O("galaxy",{node:x})},m=c.data&&o?c.data:void 0,g=r.data?.symbols.find(x=>x.id===o),f=r.data;return e(lr,{left:i.data?e(Co,{files:i.data.files,selected:n,onSelect:x=>d(x)}):e("div",{class:"panel",children:e(X,{children:i.error??e(B,{})})}),center:e("div",{style:{height:"100%",display:"flex",flexDirection:"column"},children:[e("div",{class:"crumbs",children:[n?n.split("/").map((x,h,u)=>e(N,{children:[h>0&&e("span",{class:"sep",children:"\u203A"}),e("span",{class:h===u.length-1?"":"muted",children:x})]})):e("span",{class:"muted",children:"no file selected"}),e("span",{class:"spacer"}),f?.status&&f.status!=="indexed"?e("span",{class:"warn small",children:[f.status,f.reason?` \xB7 ${f.reason}`:""]}):null,f?e("span",{class:"muted small",children:[f.symbols.length," symbols \xB7 ",J(f.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?r.error?e(Z,{error:r.error}):f?f.tooLarge?e(X,{children:[f.path," is over the 1.5 MB limit and is not shown."]}):e(ai,{code:f.content??"",lang:ar(f.path),symbols:f.symbols,highlight:g?.start_line&&g.end_line?[g.start_line,g.end_line]:null,scrollTo:s??g?.start_line??null,onLine:(x,h)=>l(h?.id??null)}):e(X,{children:e(B,{})}):e(X,{children:"Pick a file in the explorer. Click a line number to inspect the symbol around it."})})]}),right:e($o,{file:n,impact:a.data,symbol:m,onPick:p})})}var Ao=["imports","calls","references","extends","implements","handles","reexports"];function Ro({value:t,onPick:n}){let[s,i]=_(t),[r,a]=_([]),[o,l]=_(!1),[c,d]=_(0);j(()=>i(t),[t]);let p=oe(ir(async m=>{if(m.trim().length<2)return a([]);try{a(await H("/api/nodes/search",{q:m.trim(),limit:12})),l(!0),d(0)}catch{a([])}},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:m=>{let g=m.target.value;i(g),p(g)},onFocus:()=>r.length&&l(!0),onBlur:()=>setTimeout(()=>l(!1),150),onKeyDown:m=>{if(m.key==="ArrowDown")d(g=>Math.min(r.length-1,g+1));else if(m.key==="ArrowUp")d(g=>Math.max(0,g-1));else if(m.key==="Enter"){let g=r[c];g&&(n(g),l(!1))}else m.key==="Escape"&&l(!1)}}),o&&r.length>0&&e("div",{class:"suggest",children:r.map((m,g)=>e("div",{class:L(g===c&&"on"),onMouseDown:()=>n(m),children:[e(pe,{kind:m.kind}),e("span",{class:"ellipsis",children:m.label}),m.path&&m.kind!=="file"?e("span",{class:"path",children:m.path}):null]}))})]})}function di({params:t}){let[n,s]=_({node:t.node??null,depth:1,direction:"both",kinds:Ao,mode:"galaxy"}),[i,r]=_({back:[],fwd:[]}),[a,o]=_(null),[l,c]=_(!1),[d,p]=_(null),[m,g]=_(""),[f,x]=_(),[h,u]=_(!0),[y,b]=_(!1),v=oe(null);j(()=>{t.node&&t.node!==n.node&&k({...n,node:t.node})},[t.node]);let k=(T,D=!0)=>{D&&r(W=>({back:[...W.back,n].slice(-30),fwd:[]})),s(T)};j(()=>{let T=!0;c(!0),x(void 0);let D=n.kinds.join(",")||"none";return(n.node?H("/api/graph",{mode:"expand",node:n.node,direction:n.direction,kinds:D,depth:n.depth,limit:400}):H("/api/graph",{mode:"map",kinds:D,limit:200})).then(q=>{T&&(o(q),p(q.root??null))}).catch(q=>T&&Y(q.message,!0)).finally(()=>T&&c(!1)),()=>{T=!1}},[n]);let S=T=>{b(!0),k({...n,node:T})},E=async()=>{if(!(!n.node||!m.trim()))try{let T=await H("/api/graph",{mode:"path",node:n.node,to:m.trim()});o(D=>{if(!D)return D;let W=new Set(D.nodes.map(A=>A.id)),q=new Set(D.edges.map(A=>`${A.src}|${A.dst}|${A.kind}`));return{...D,nodes:[...D.nodes,...T.nodes.filter(A=>!W.has(A.id))],edges:[...D.edges,...T.edges.filter(A=>!q.has(`${A.src}|${A.dst}|${A.kind}`))]}}),b(!0),x(new Set(T.edges.map(D=>`${D.src}|${D.dst}|${D.kind}`)))}catch(T){Y(T.message,!0)}},w=a?.nodes.find(T=>T.id===d),C=w?a.edges.filter(T=>T.dst===w.id):[],R=w?a.edges.filter(T=>T.src===w.id):[],M=T=>a?.nodes.find(D=>D.id===T)?.label??T,$=a?.nodes.filter(T=>T.kind==="file").length??0,F=T=>k({...n,kinds:n.kinds.includes(T)?n.kinds.filter(D=>D!==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:!i.back.length,title:"back",onClick:()=>{let T=i.back[i.back.length-1];T&&(r(D=>({back:D.back.slice(0,-1),fwd:[n,...D.fwd]})),s(T))},children:"\u2190"}),e("button",{type:"button",class:"sm",disabled:!i.fwd.length,title:"forward",onClick:()=>{let T=i.fwd[0];T&&(r(D=>({back:[...D.back,n],fwd:D.fwd.slice(1)})),s(T))},children:"\u2192"}),e(Ro,{value:n.node??"",onPick:T=>k({...n,node:T.id})}),e("button",{type:"button",class:"sm",onClick:()=>k({...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=>k({...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:()=>k({...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:()=>k({...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:m,onInput:T=>g(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:L("chip",n.mode==="galaxy"&&"on"),onClick:()=>s({...n,mode:"galaxy"}),children:"galaxy"}),e("button",{type:"button",class:L("chip",n.mode==="hierarchy"&&"on"),onClick:()=>s({...n,mode:"hierarchy"}),children:"hierarchy"}),e("button",{type:"button",class:L("chip",h&&"on"),onClick:()=>u(!h),children:"legend"})]}),e("span",{class:"count",children:l?e(B,{}):a?`${a.nodes.length} nodes \xB7 ${a.edges.length} edges${a.truncated?" \xB7 truncated":""}${a.total&&a.total>$?` \xB7 top ${$} of ${a.total} files`:""}`:""})]}),e("div",{class:"gtoolbar",style:{paddingTop:4,paddingBottom:6},children:[e("span",{class:"muted small",children:"edges:"}),rr.map(T=>e("button",{type:"button",class:L("chip",n.kinds.includes(T)&&"on"),onClick:()=>F(T),children:T}))]}),e("div",{style:{flex:1,minHeight:0,display:"grid",gridTemplateColumns:w?"minmax(0,1fr) 340px":"1fr"},children:[e("div",{style:{minWidth:0},children:a?a.nodes.length?e(Fe,{nodes:a.nodes,edges:a.edges,mode:n.mode,selected:d,highlight:f,onSelect:p,onActivate:S,legend:h,handle:v,keepPositions:y}):e(X,{children:"The graph is empty. Run a reindex from System."}):e(X,{children:e(B,{})})}),w&&e("div",{class:"panel right",children:[e("div",{class:"head",children:["selection ",e("span",{class:"spacer"}),e("a",{onClick:()=>p(null),children:"close"})]}),e("div",{class:"body",children:[e("div",{class:"section",children:[e("div",{class:"row tight",children:[e(pe,{kind:w.kind}),e("b",{class:"break",children:w.label})]}),w.path&&w.kind!=="file"?e("div",{class:"muted small",children:[w.path,w.line?`:${w.line}`:""]}):null,e("div",{class:"row",style:{marginTop:8},children:[e("button",{type:"button",class:"sm primary",onClick:()=>S(w.id),children:"Expand from here"}),w.path?e("button",{type:"button",class:"sm",onClick:()=>O("explore",{file:w.path,line:w.line?String(w.line):void 0,symbol:w.kind==="file"?void 0:w.id}),children:"Open source"}):null,w.kind==="memory"?e("button",{type:"button",class:"sm",onClick:()=>O("memory",{name:w.label}),children:"Open memory"}):null]})]}),e("div",{class:"section",children:[e("h4",{children:["incoming \xB7 ",C.length]}),e("table",{children:e("tbody",{children:C.slice(0,60).map(T=>e("tr",{class:"click",onClick:()=>p(T.src),children:[e("td",{children:e(I,{children:T.kind})}),e("td",{class:"break",children:M(T.src)})]}))})})]}),e("div",{class:"section",children:[e("h4",{children:["outgoing \xB7 ",R.length]}),e("table",{children:e("tbody",{children:R.slice(0,60).map(T=>e("tr",{class:"click",onClick:()=>p(T.dst),children:[e("td",{children:e(I,{children:T.kind})}),e("td",{class:"break",children:M(T.dst)})]}))})})]})]})]})]})]})}var Je=["feat","test","perf","refactor","fix","docs","other"],ct={feat:"#2563eb",test:"#16a34a",perf:"#d97706",refactor:"#7c3aed",fix:"#e11d48",docs:"#0284c7",other:"#9ca3af"},Ke=t=>ct[t]??ct.other;function rs(t){let n=[],s=[],i=0,r=a=>{let o=n.indexOf(null);return o===-1?(o=n.length,n.push(a)):n[o]=a,o};for(let a of t){let o=n.indexOf(a.sha);o===-1&&(o=r(a.sha));let l=[];for(let p=0;p<n.length;p++)p!==o&&n[p]===a.sha&&(l.push(p),n[p]=null);let c=[],d=a.parents;if(!d.length)n[o]=null;else{n[o]=d[0];for(let p of d.slice(1)){let m=n.indexOf(p);m===-1&&(m=r(p)),c.push(m)}}for(;n.length&&n[n.length-1]===null;)n.pop();i=Math.max(i,n.length,o+1),s.push({c:a,lane:o,after:[...n],joins:l,forks:c})}return{rows:s,lanes:i}}function ui(t){let n=[];for(let s=0;s<t.length-1;s++){let i=t[s],r=t[s+1];for(let a=0;a<i.after.length;a++){let o=i.after[a];o&&(o===r.c.sha&&a!==r.lane?n.push({kind:"curve",fromLane:a,toLane:r.lane,from:s,to:s+1,lane:a}):i.forks.includes(a)&&a!==i.lane?n.push({kind:"curve",fromLane:i.lane,toLane:a,from:s,to:s+1,lane:a}):n.push({kind:"line",lane:a,from:s,to:s+1}))}}return n}function is(t){let n=Math.max(0,Math.min(1,t)),s=[191,219,254],i=[30,58,138],r=s.map((a,o)=>Math.round(a+((i[o]??0)-a)*n));return`rgb(${r[0]},${r[1]},${r[2]})`}function Tt(t=800){let n=oe(null),[s,i]=_(t);return j(()=>{let r=n.current;if(!r)return;let a=new ResizeObserver(()=>i(r.clientWidth||t));return a.observe(r),i(r.clientWidth||t),()=>a.disconnect()},[]),[n,s]}function mi({weeks:t,range:n,onRange:s,hidden:i}){let[r,a]=Tt(),o=150,l={l:34,r:8,t:8,b:22},c=Math.max(10,a-l.l-l.r),d=o-l.t-l.b,p=t.length,m=p?c/p:c,g=m>=5?1:0,f=Math.max(1,...t.map(C=>Je.reduce((R,M)=>R+(i.has(M)?0:C.byBucket[M]),0))),x=C=>l.t+d-C/f*d,[h,u]=_(null),y=oe(null),[b,v]=_(null),k=(C,R)=>{let M=R.getBoundingClientRect(),$=C-M.left-l.l;return Math.max(0,Math.min(p-1,Math.floor($/m)))},S=K(()=>{let C=[],R="";for(let $=0;$<p;$++){let F=t[$].week.slice(0,7);if(F!==R){R=F;let T=new Date(t[$].at),D=T.getUTCMonth()===0||!C.length?`${T.getUTCFullYear()}`:T.toLocaleString("en",{month:"short",timeZone:"UTC"});C.push({i:$,label:D})}}let M=Math.max(1,Math.ceil(C.length/Math.max(4,c/60)));return C.filter(($,F)=>F%M===0)},[t,c]),E=b??(n?[t.findIndex(C=>C.at+7*864e5>n[0]),t.findIndex(C=>C.at>n[1])-1]:null),w=h!==null?t[h]:void 0;return e("div",{class:"hist-chart",ref:r,children:[e("svg",{width:a,height:o,onMouseMove:C=>{let R=C.currentTarget,M=k(C.clientX,R);u(M),y.current&&v([Math.min(y.current.i0,M),Math.max(y.current.i0,M)])},onMouseLeave:()=>u(null),onMouseDown:C=>{let R=C.currentTarget,M=k(C.clientX,R);y.current={x0:C.clientX,i0:M},v([M,M]),C.preventDefault()},onMouseUp:C=>{let R=y.current;if(y.current=null,!R)return;if(Math.abs(C.clientX-R.x0)<3){v(null),s(null);return}let M=b;v(null),M&&s([t[M[0]].at,t[M[1]].at+7*864e5-1])},children:[e("title",{children:"commits per week by kind"}),[0,.5,1].map(C=>e("g",{children:[e("line",{x1:l.l,x2:a-l.r,y1:x(f*C),y2:x(f*C),class:"grid"}),e("text",{x:l.l-6,y:x(f*C)+3,class:"axis","text-anchor":"end",children:Math.round(f*C)})]})),S.map(C=>e("text",{x:l.l+C.i*m,y:o-6,class:"axis",children:C.label})),E&&E[0]>=0&&E[1]>=E[0]?e("rect",{x:l.l+E[0]*m,y:l.t,width:(E[1]-E[0]+1)*m,height:d,class:"brush"}):null,t.map((C,R)=>{let M=0;return e("g",{opacity:E&&(R<E[0]||R>E[1])?.35:1,children:Je.map($=>{if(i.has($))return null;let F=C.byBucket[$];if(!F)return null;let T=x(M+F),D=x(M);return M+=F,e("rect",{x:l.l+R*m+g/2,y:T,width:Math.max(.5,m-g),height:Math.max(0,D-T-(g&&D-T>2?1:0)),fill:ct[$],rx:m>=6?1.5:0})})})}),h!==null?e("line",{x1:l.l+h*m+m/2,x2:l.l+h*m+m/2,y1:l.t,y2:l.t+d,class:"cross"}):null]}),w?e("div",{class:"tip",style:{left:Math.min(a-190,l.l+h*m+10),top:4},children:[e("b",{children:["week of ",w.week]})," \xB7 ",w.total," commit",w.total===1?"":"s"," \xB7 +",w.added,"/-",w.deleted,e("div",{class:"row tight",style:{marginTop:4,flexWrap:"wrap"},children:Je.filter(C=>w.byBucket[C]).map(C=>e("span",{class:"kdot-lbl",children:[e("i",{class:"kdot",style:{background:ct[C]}}),C," ",w.byBucket[C]]}))})]}):null]})}function hi({counts:t,hidden:n,onToggle:s}){return e("div",{class:"row tight",style:{flexWrap:"wrap"},children:Je.map(i=>e("button",{type:"button",class:L("chip",!n.has(i)&&"on"),onClick:()=>s(i),title:n.has(i)?`show ${i}`:`hide ${i}`,children:[e("i",{class:"kdot",style:{background:ct[i],opacity:n.has(i)?.3:1}}),i," ",t[i]??0]}))})}function as({values:t,width:n=72,height:s=16}){let i=Math.max(1,...t),r=t.length,a=t.map((o,l)=>`${l/Math.max(1,r-1)*(n-2)+1},${s-1-o/i*(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:a.join(" ")}),t.map((o,l)=>o?e("circle",{cx:l/Math.max(1,r-1)*(n-2)+1,cy:s-1-o/i*(s-3),r:1.4}):null)]})}function gi({files:t,selected:n,onSelect:s}){let[i,r]=Tt(),a=300,o={l:42,r:16,t:12,b:30},l=Math.max(10,r-o.l-o.r),c=a-o.t-o.b,d=t.filter(v=>v.commits>=2),p=Math.max(2,...d.map(v=>v.commits)),m=Math.max(1,...d.map(v=>v.added+v.deleted)),g=v=>o.l+Math.log(v)/Math.log(p)*l,f=v=>o.t+c-v*c,x=v=>3+Math.sqrt((v.added+v.deleted)/m)*13,[h,u]=_(null),y=[...d].sort((v,k)=>k.risk-v.risk).slice(0,5),b=[1,2,5,10,20,50,100,200,500,1e3].filter(v=>v<=p);return e("div",{class:"hist-chart",ref:i,children:[e("svg",{width:r,height:a,children:[e("title",{children:"files by commits and fix share, sized by lines changed"}),[0,.25,.5,.75,1].map(v=>e("g",{children:[e("line",{x1:o.l,x2:r-o.r,y1:f(v),y2:f(v),class:"grid"}),e("text",{x:o.l-6,y:f(v)+3,class:"axis","text-anchor":"end",children:[Math.round(v*100),"%"]})]})),b.filter(v=>g(v)<r-o.r-70).map(v=>e("text",{x:g(v),y:a-8,class:"axis","text-anchor":"middle",children:v})),e("text",{x:r-o.r,y:a-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(v=>e("circle",{cx:g(v.commits),cy:f(v.commits?v.fixes/v.commits:0),r:x(v),fill:is(v.risk),class:L("dot",n===v.path&&"sel"),onMouseEnter:()=>u(v),onMouseLeave:()=>u(null),onClick:()=>s(v.path)})),y.map(v=>{let k=g(v.commits)>r-160;return e("text",{x:k?g(v.commits)-x(v)-3:g(v.commits)+x(v)+3,y:f(v.fixes/v.commits)+3,class:"lbl","text-anchor":k?"end":"start",children:v.path.split("/").slice(-2).join("/")})})]}),h?e("div",{class:"tip",style:{left:Math.min(r-260,g(h.commits)+12),top:Math.max(0,f(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 pi=["#2563eb","#d97706","#16a34a","#7c3aed","#e11d48","#0284c7","#db2777","#0d9488"],un=t=>pi[t%pi.length];function fi({rows:t,lanes:n,rowH:s,selected:i}){let a=n*14+10,o=d=>7+d*14,l=d=>d*s+s/2,c=ui(t);return e("svg",{class:"lanes",width:a,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:un(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:un(d.lane)})),t.map((d,p)=>e("circle",{cx:o(d.lane),cy:l(p),r:d.c.merge?3.5:4,fill:d.c.merge?"var(--card)":un(d.lane),stroke:un(d.lane),"stroke-width":i===d.c.sha?3:d.c.merge?2:1,class:L(i===d.c.sha&&"sel",!d.c.onHead&&"off")}))]})}var Mo={branch:"hexagon",commit:"triangle",memory:"diamond",doc:"square"};function pn(t){return t.missing?"ring":Mo[t.kind]??"circle"}function mn(t){let n=t;return n.kind==="commit"?Ke(n.bucket??"other"):n.kind==="branch"?n.live||n.isDefault?"#64748b":"#9ca3af":n.kind==="memory"&&(n.status==="superseded"||n.status==="deprecated")?"#93c5fd":Se(t.kind)}var Fo={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 os(t){return Fo[t]??St(t)}var Lo=(t,n)=>t.length>n?`${t.slice(0,n-1)}\u2026`:t;function bi(t){return t.kind==="commit"?Lo(t.label,32):t.kind==="file"?t.label.split("/").pop()??t.label:t.label}var Io=["branch","commit","file","memory","doc"],Do=["contains","merged_into","touches","fixes","records","mentions","documents"],No={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"},Po=[5,8,15,30],yi=(t,n)=>[...t].sort((s,i)=>{let r=n.indexOf(s),a=n.indexOf(i);return(r===-1?99:r)-(a===-1?99:a)||s.localeCompare(i)});function vi(t,n){let s=new Set(t);return s.has(n)?s.delete(n):s.add(n),s}function ki({focus:t}){let[n,s]=_(null),[i,r]=_(!1),[a,o]=_(0),[l,c]=_(8),[d,p]=_(new Set),[m,g]=_(new Set),[f,x]=_(""),[h,u]=_(!1),[y,b]=_(t??null);j(()=>{let A=!0;return r(!0),H("/api/history/knowledge",{focus:t,branches:l,limit:400}).then(z=>{A&&(s(z),b(z.focus??null))}).catch(z=>A&&Y(z.message,!0)).finally(()=>A&&r(!1)),()=>{A=!1}},[t,l,a]);let v=K(()=>{if(!n?.git)return null;let A=f?n.nodes.filter(z=>z.kind!=="commit"||z.root||z.bucket===f):n.nodes;return rn({nodes:A,edges:n.edges},{hiddenKinds:d,hiddenEdges:m,status:"",category:"",hideSuperseded:!1})},[n,d,m,f]),k=n?.git?n.nodes:[],S=K(()=>qe(k,A=>A.kind),[n]),E=K(()=>qe(n?.edges??[],A=>A.kind),[n]),w=K(()=>qe(k.filter(A=>A.kind==="commit"),A=>A.bucket??"other"),[n]),C=A=>k.find(z=>z.kind===A&&!z.missing),R=K(()=>new Map(k.map(A=>[A.id,A])),[n]),M=y?R.get(y):void 0,$=v?.edges??[],F=M?$.filter(A=>A.dst===M.id):[],T=M?$.filter(A=>A.src===M.id):[],D=A=>{let z=R.get(A);return z?z.kind==="commit"?`${z.short} ${z.label}`:z.label:A},W=A=>O("history",{tab:"graph",focus:A}),q=n?.focus?R.get(n.focus):void 0;return n&&!n.git?e(X,{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:q?D(q.id):t}),e("button",{type:"button",class:"sm",onClick:()=>O("history",{tab:"graph"}),children:"Show all"})]}):e(N,{children:[e("span",{class:"muted small",children:"newest"}),e("select",{value:String(l),title:"feature branches drawn",onChange:A=>c(Number(A.target.value)),children:Po.map(A=>e("option",{value:String(A),children:A}))}),e("span",{class:"muted small",children:"branches, their commits and what they touched"})]}),e("select",{value:"",title:"focus a branch",onChange:A=>{let z=A.target.value;z&&W(`branch:${z}`)},children:[e("option",{value:"",children:"focus a branch\u2026"}),(n?.branches??[]).map(A=>e("option",{value:A.name,children:[A.name," (",A.commits,")",A.isDefault?" \xB7 default":A.merged?" \xB7 merged":"",A.live?"":" \xB7 deleted"]}))]}),w.size>1?e("select",{value:f,title:"commit kind",onChange:A=>x(A.target.value),children:[e("option",{value:"",children:"any commit kind"}),Je.filter(A=>w.has(A)).map(A=>e("option",{value:A,children:[A," (",w.get(A),")"]}))]}):null,e("button",{type:"button",class:L("chip",h&&"on"),onClick:()=>u(!h),children:"legend"}),e("button",{type:"button",class:"sm",title:"reload",onClick:()=>o(A=>A+1),children:"\u21BB"}),e("span",{class:"count",children:i?e(B,{}):v&&n?`${v.nodes.length} of ${k.length} nodes \xB7 ${v.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:"}),yi([...S.keys()],Io).map(A=>{let z=C(A);return e("button",{type:"button",class:L("chip",!d.has(A)&&"on"),onClick:()=>p(vi(d,A)),children:[z?e(Be,{shape:pn(z),color:mn(z)}):null,A," ",S.get(A)]})}),e("span",{class:"muted small",style:{marginLeft:8},children:"edges:"}),yi([...E.keys()],Do).map(A=>{let z=os(A);return e("button",{type:"button",title:No[A],class:L("chip",!m.has(A)&&"on"),onClick:()=>g(vi(m,A)),children:[e(ot,{color:z.color,dash:z.dash}),A," ",E.get(A)]})})]}),e("div",{class:"kbody",style:{gridTemplateColumns:M?"minmax(0,1fr) 320px":"minmax(0,1fr)"},children:[e("div",{style:{minWidth:0,minHeight:0},children:v?v.nodes.length?e(Fe,{nodes:v.nodes,edges:v.edges,selected:y,onSelect:b,onActivate:W,legend:h,colorOf:mn,shapeOf:pn,edgeStyleOf:os,labelOf:bi}):k.length?e(X,{children:"Nothing left after these filters."}):e(X,{children:"No commits to draw."}):e(X,{children:e(B,{})})}),M&&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(Oo,{node:M,focus:n?.focus??void 0,onFocus:W}),e(lt,{title:"incoming",rows:F.map(A=>({kind:A.kind,id:A.src})),label:D,onPick:b}),e(lt,{title:"outgoing",rows:T.map(A=>({kind:A.kind,id:A.dst})),label:D,onPick:b})]})]})]})]})}function Oo({node:t,focus:n,onFocus:s}){return e("div",{class:"section",children:[e("div",{class:"row tight",children:[e(Be,{shape:pn(t),color:mn(t)}),e(pe,{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:Ke(t.bucket??"other")},children:t.sub}):null,t.group==="memory"&&t.sub?e(I,{children:t.sub}):null,t.status?e("span",{class:`tag s-${t.status}`,children:t.status}):null,t.group==="doc"&&t.detail?e(I,{children:t.detail}):null,t.kind==="branch"?e(N,{children:[e(I,{children:[t.commits," own commits"]}),t.isDefault?e(I,{children:"default"}):t.merged?e(I,{children:"merged"}):e(I,{children:"open"}),t.live?null:e(I,{children:"ref deleted"}),(t.prs??[]).map(i=>e(I,{children:["#",i]}))]}):null,t.kind==="file"&&t.fixes?e(I,{children:[t.fixes," fixes"]}):null,t.risk?e(I,{children:["risk ",Math.round(t.risk*100),"%"]}):null]}),t.at?e("div",{class:"muted small",style:{marginTop:4},children:[t.author?`${t.author} \xB7 `:"",ne(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:()=>O("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:()=>O("history",{tab:"branches",branch:t.label}),children:"Branch detail"}):null,t.kind==="file"&&t.path?e("button",{type:"button",class:"sm",onClick:()=>O("history",{tab:"files",file:t.path}),children:"File history"}):null,t.kind==="file"&&t.path&&!t.missing?e("button",{type:"button",class:"sm",onClick:()=>O("explore",{file:t.path}),children:"Open source"}):null,t.group==="memory"&&!t.missing?e("button",{type:"button",class:"sm",onClick:()=>O("memory",{name:t.label}),children:"Open memory"}):null,t.group==="doc"&&!t.missing?e("button",{type:"button",class:"sm",onClick:()=>O("docs",{tab:"sources",name:t.label}),children:"Open doc source"}):null]})]})}function hn({kind:t,bucket:n}){return e("span",{class:"tag kind",style:{color:Ke(n)},children:t})}function xi({added:t,deleted:n}){let s=t+n,i=5,r=s?Math.round(t/s*i):0,a=s?Math.min(i-r,Math.round(n/s*i)):0;return e("span",{class:"pm",title:`+${t} / -${n}`,children:[e("span",{class:"add",children:["+",J(t)]}),e("span",{class:"del",children:["-",J(n)]}),e("span",{class:"bars",children:Array.from({length:i},(o,l)=>e("i",{class:l<r?"a":l<r+a?"d":""}))})]})}function wi({refs:t,tags:n,max:s=3}){let i=t.filter(r=>!r.startsWith("tag: "));return!i.length&&!n.length?null:e(N,{children:[n.slice(0,2).map(r=>e("span",{class:"ref tag",children:r})),i.slice(0,s).map(r=>e("span",{class:L("ref",r.includes("/")&&"remote"),children:r})),i.length>s?e("span",{class:"ref remote",children:["+",i.length-s]}):null]})}function Ho({c:t}){return e(N,{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 dt({value:t}){return e("span",{class:"riskbar",title:t.toFixed(2),children:e("i",{style:{width:`${Math.round(t*100)}%`,background:is(.3+t*.7)}})})}function Ue({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 ut({commits:t,selected:n,onSelect:s,lanes:i,empty:r}){return t.length?e("div",{class:"commits",children:[i?e(fi,{rows:i.rows,lanes:i.lanes,rowH:28,selected:n}):null,e("div",{class:"rows",children:t.map(o=>e("div",{class:L("crow",n===o.sha&&"sel",!o.onHead&&"off"),onClick:()=>s(o.sha),title:`${o.sha}
9
+ `)})]}):null]})}var ys=po($a(),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 i(c,d){return c=c.replace(/<S>/g,function(){return s}).replace(/<BRACES>/g,function(){return a}).replace(/<SPREAD>/g,function(){return r}),RegExp(c,d)}r=i(r).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 m=c[u],g=!1;if(typeof m!="string"&&(m.type==="tag"&&m.content[0]&&m.content[0].type==="tag"?m.content[0].content[0].content==="</"?d.length>0&&d[d.length-1].tagName===o(m.content[0].content[1])&&d.pop():m.content[m.content.length-1].content==="/>"||d.push({tagName:o(m.content[0].content[1]),openedBraces:0}):d.length>0&&m.type==="punctuation"&&m.content==="{"?d[d.length-1].openedBraces++:d.length>0&&d[d.length-1].openedBraces>0&&m.type==="punctuation"&&m.content==="}"?d[d.length-1].openedBraces--:g=!0),(g||typeof m=="string")&&d.length>0&&d[d.length-1].openedBraces===0){var f=o(m);u<c.length-1&&(typeof c[u+1]=="string"||c[u+1].type==="plain-text")&&(f+=o(c[u+1]),c.splice(u+1,1)),u>0&&(typeof c[u-1]=="string"||c[u-1].type==="plain-text")&&(f=o(c[u-1])+f,c.splice(u-1,1),u--),c[u]=new t.Token("plain-text",f,null,f)}m.content&&typeof m.content!="string"&&l(m.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:/![sra](?=[:}]$)/,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,i){if(s.language===a){var o=s.tokenStack=[];s.code=s.code.replace(r,function(l){if(typeof i=="function"&&!i(l))return l;for(var c=o.length,d;s.code.indexOf(d=n(a,c))!==-1;)++c;return o[c]=l,d}),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,i=Object.keys(s.tokenStack);function o(l){for(var c=0;c<l.length&&!(r>=i.length);c++){var d=l[c];if(typeof d=="string"||d.content&&typeof d.content=="string"){var u=i[r],m=s.tokenStack[u],g=typeof d=="string"?d:d.content,f=n(a,u),k=g.indexOf(f);if(k>-1){++r;var h=g.substring(0,k),p=new t.Token(a,t.tokenize(m,s.grammar),"language-"+a,m),b=g.substring(k+f.length),y=[];h&&y.push.apply(y,o([h])),y.push(p),b&&y.push.apply(y,o([b])),typeof d=="string"?l.splice.apply(l,[c,1].concat(y)):d.content=y}}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*\()/],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}|\??->|[!=]=?=?|::|\*\*=?|--|\+\+|&&|\|\||<<|>>|[?~]|[/^|%*&<>.+-]=?/,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:a,operator:r,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:a,operator:r,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 a=/(?:\\.|``(?:[^`\r\n]|`(?!`))+``|`[^`\r\n]+`|[^\\|\r\n`])+/.source,r=/\|?__(?:\|__)+\|?(?:(?:\n|\r\n?)|(?![\s\S]))/.source.replace(/__/g,function(){return a}),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("^"+r+i+"(?:"+r+")*","m"),inside:{"table-data-rows":{pattern:RegExp("^("+r+i+")(?:"+r+")*$"),lookbehind:!0,inside:{"table-data":{pattern:RegExp(a),inside:t.languages.markdown},punctuation:/\|/}},"table-line":{pattern:RegExp("^("+r+")"+i+"$"),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(u){["url","bold","italic","strike","code-snippet"].forEach(function(m){u!==m&&(t.languages.markdown[u].inside.content.inside[m]=t.languages.markdown[m])})}),t.hooks.add("after-tokenize",function(u){if(u.language!=="markdown"&&u.language!=="md")return;function m(g){if(!(!g||typeof g=="string"))for(var f=0,k=g.length;f<k;f++){var h=g[f];if(h.type!=="code"){m(h.content);continue}var p=h.content[1],b=h.content[3];if(p&&b&&p.type==="code-language"&&b.type==="code-block"&&typeof p.content=="string"){var y=p.content.replace(/\b#/g,"sharp").replace(/\b\+\+/g,"pp");y=(/[a-z][\w-]*/i.exec(y)||[""])[0].toLowerCase();var v="language-"+y;b.alias?typeof b.alias=="string"?b.alias=[b.alias,v]:b.alias.push(v):b.alias=[v]}}}m(u.tokens)}),t.hooks.add("wrap",function(u){if(u.type==="code-block"){for(var m="",g=0,f=u.classes.length;g<f;g++){var k=u.classes[g],h=/language-(.+)/.exec(k);if(h){m=h[1];break}}var p=t.languages[m];if(p)u.content=t.highlight(d(u.content),p,m);else if(m&&m!=="none"&&t.plugins.autoloader){var b="md-"+new Date().valueOf()+"-"+Math.floor(Math.random()*1e16);u.attributes.id=b,t.plugins.autoloader.loadLanguages(m,function(){var y=document.getElementById(b);y&&(y.innerHTML=t.highlight(y.textContent,t.languages[m],m))})}}});var o=RegExp(t.languages.markup.tag.pattern.source,"gi"),l={amp:"&",lt:"<",gt:">",quot:'"'},c=String.fromCodePoint||String.fromCharCode;function d(u){var m=u.replace(o,"");return m=m.replace(/&(\w{1,8}|#x?[\da-f]{1,8});/gi,function(g,f){if(f=f.toLowerCase(),f[0]==="#"){var k;return f[1]==="x"?k=parseInt(f.slice(2),16):k=Number(f.slice(1)),c(k)}else{var h=l[f];return h||g}}),m}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"],i=a.variable[1].inside,o=0;o<r.length;o++)i[r[o]]=t.languages.bash[r[o]];t.languages.sh=t.languages.bash,t.languages.shell=t.languages.bash})(Prism);var pl=t=>t.replace(/[&<>]/g,n=>({"&":"&amp;","<":"&lt;",">":"&gt;"})[n]??n);function _n(t,n){let s=ys.default.languages[n];if(!s)return t.split(`
10
+ `).map(pl);let a=ys.default.highlight(t,s,n),r=[],i=[],o="",l=a.split(/(<span[^>]*>|<\/span>|\n)/);for(let c of l)c===`
11
+ `?(r.push(o+"</span>".repeat(i.length)),o=i.join("")):c.startsWith("<span")?(i.push(c),o+=c):(c==="</span>"&&i.pop(),o+=c);return r.push(o+"</span>".repeat(i.length)),r}function Ea({code:t,lang:n,symbols:s,highlight:a,scrollTo:r,onLine:i}){let o=V(()=>_n(t,n),[t,n]),l=V(()=>{let u=new Map;for(let m of s??[])m.start_line&&!u.has(m.start_line)&&u.set(m.start_line,m);return u},[s]),c=u=>{let m;for(let g of s??[])g.start_line&&g.end_line&&g.start_line<=u&&g.end_line>=u&&(!m||g.end_line-g.start_line<m.end_line-m.start_line)&&(m=g);return m},d=ne(null);return j(()=>{if(!r||!d.current)return;let u=d.current.querySelector(`tr[data-l="${r}"]`);u&&u.scrollIntoView({block:"center"})},[r]),e("div",{class:"code",ref:d,children:e("table",{children:e("tbody",{children:o.map((u,m)=>{let g=m+1,f=l.get(g),k=a&&g>=a[0]&&g<=a[1];return e("tr",{"data-l":g,class:M(k&&"hl",f&&"sym"),children:[e("td",{class:"ln",onClick:()=>i?.(g,c(g)),title:f?`${f.kind} ${f.name}`:void 0,children:g}),e("td",{dangerouslySetInnerHTML:{__html:u||" "}})]})})})})})}function ml(t){let n={name:"",path:"",dirs:new Map,files:[]};for(let s of t){let a=s.path.split("/"),r=n;for(let i of a.slice(0,-1)){let o=r.dirs.get(i);o||(o={name:i,path:r.path?`${r.path}/${i}`:i,dirs:new Map,files:[]},r.dirs.set(i,o)),r=o}r.files.push(s)}return n}function Ra({dir:t,depth:n,open:s,toggle:a,selected:r,onSelect:i,filter:o}){let l=[...t.dirs.values()].sort((u,m)=>u.name.localeCompare(m.name)),c=[...t.files].sort((u,m)=>u.path.localeCompare(m.path)),d={paddingLeft:`${8+n*14}px`};return e(N,{children:[l.map(u=>{let m=s.has(u.path)||!!o;return e(N,{children:[e("div",{class:"node",style:d,onClick:()=>a(u.path),children:[e("span",{class:"arrow",children:m?"\u25BE":"\u25B8"}),e("span",{class:"name",children:u.name})]}),m&&e(Ra,{dir:u,depth:n+1,open:s,toggle:a,selected:r,onSelect:i,filter:o})]})}),c.map(u=>e("div",{class:M("node",r===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:M("st",u.status)}),e("span",{class:"name",children:dn(u.path)}),e("span",{class:M("heat",u.score>.6&&"hot"),children:u.score?u.score.toFixed(2):""})]}))]})}function hl({files:t,selected:n,onSelect:s}){let[a,r]=_(""),[i,o]=_(()=>{let d=new Set;if(n){let u=n.split("/");for(let m=1;m<u.length;m++)d.add(u.slice(0,m).join("/"))}else{let u=new Map;for(let m of t){let g=m.path.split("/")[0];m.path.includes("/")&&u.set(g,(u.get(g)??0)+1)}for(let[m]of[...u].sort((g,f)=>f[1]-g[1]).slice(0,2))d.add(m)}return d});j(()=>{n&&o(d=>{let u=new Set(d),m=n.split("/");for(let g=1;g<m.length;g++)u.add(m.slice(0,g).join("/"));return u})},[n]);let l=V(()=>{let d=a.trim().toLowerCase();return d?t.filter(u=>u.path.toLowerCase().includes(d)):t},[t,a]),c=V(()=>ml(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:d=>r(d.target.value)})}),e("div",{class:"body tree",children:e(Ra,{dir:c,depth:0,open:i,toggle:d=>o(u=>{let m=new Set(u);return m.has(d)?m.delete(d):m.add(d),m}),selected:n,onSelect:s,filter:a})})]})}function Ca({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(P,{children:a.kind})}),e("td",{class:"break",children:[e(be,{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 gl({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(N,{children:[e("div",{class:"section",children:[e("div",{class:"row tight",children:[e(be,{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(r=>e("code",{children:r.label}))]}):null]}),e(Ca,{title:"callers and references",rows:s.callers,onPick:a}),e(Ca,{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(be,{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(P,{children:r.kind})]}))]}):null]}):n?e(N,{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(Be,{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(be,{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",children:e(U,{})})})]}):e("div",{class:"panel right",children:e(J,{children:"Select a file to see what depends on it."})})}function Aa({params:t}){let n=t.file,s=t.line?Number(t.line):void 0,a=G(()=>O("/api/tree"),[]),r=G(()=>n?O("/api/file",{path:n}):Promise.resolve(void 0),[n]),i=G(()=>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=G(()=>o?O("/api/symbol",{id:o}):Promise.resolve(void 0),[o]),d=(k,h,p)=>H("explore",{file:k,line:h?String(h):void 0,symbol:p}),u=(k,h,p)=>{k.startsWith("file:")?d(k.slice(5)):h?d(h,p,k):H("galaxy",{node:k})},m=c.data&&o?c.data:void 0,g=r.data?.symbols.find(k=>k.id===o),f=r.data;return e(Rr,{left:a.data?e(hl,{files:a.data.files,selected:n,onSelect:k=>d(k)}):e("div",{class:"panel",children:e(J,{children:a.error??e(U,{})})}),center:e("div",{style:{height:"100%",display:"flex",flexDirection:"column"},children:[e("div",{class:"crumbs",children:[n?n.split("/").map((k,h,p)=>e(N,{children:[h>0&&e("span",{class:"sep",children:"\u203A"}),e("span",{class:h===p.length-1?"":"muted",children:k})]})):e("span",{class:"muted",children:"no file selected"}),e("span",{class:"spacer"}),f?.status&&f.status!=="indexed"?e("span",{class:"warn small",children:[f.status,f.reason?` \xB7 ${f.reason}`:""]}):null,f?e("span",{class:"muted small",children:[f.symbols.length," symbols \xB7 ",q(f.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?r.error?e(Z,{error:r.error}):f?f.tooLarge?e(J,{children:[f.path," is over the 1.5 MB limit and is not shown."]}):e(Ea,{code:f.content??"",lang:Er(f.path),symbols:f.symbols,highlight:g?.start_line&&g.end_line?[g.start_line,g.end_line]:null,scrollTo:s??g?.start_line??null,onLine:(k,h)=>l(h?.id??null)}):e(J,{children:e(U,{})}):e(J,{children:"Pick a file in the explorer. Click a line number to inspect the symbol around it."})})]}),right:e(gl,{file:n,impact:i.data,symbol:m,onPick:u})})}var fl=["imports","calls","references","extends","implements","handles","reexports"];function bl({value:t,onPick:n}){let[s,a]=_(t),[r,i]=_([]),[o,l]=_(!1),[c,d]=_(0);j(()=>a(t),[t]);let u=ne($r(async m=>{if(m.trim().length<2)return i([]);try{i(await O("/api/nodes/search",{q:m.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:m=>{let g=m.target.value;a(g),u(g)},onFocus:()=>r.length&&l(!0),onBlur:()=>setTimeout(()=>l(!1),150),onKeyDown:m=>{if(m.key==="ArrowDown")d(g=>Math.min(r.length-1,g+1));else if(m.key==="ArrowUp")d(g=>Math.max(0,g-1));else if(m.key==="Enter"){let g=r[c];g&&(n(g),l(!1))}else m.key==="Escape"&&l(!1)}}),o&&r.length>0&&e("div",{class:"suggest",children:r.map((m,g)=>e("div",{class:M(g===c&&"on"),onMouseDown:()=>n(m),children:[e(be,{kind:m.kind}),e("span",{class:"ellipsis",children:m.label}),m.path&&m.kind!=="file"?e("span",{class:"path",children:m.path}):null]}))})]})}function Ma({params:t}){let[n,s]=_({node:t.node??null,depth:1,direction:"both",kinds:fl,mode:"galaxy"}),[a,r]=_({back:[],fwd:[]}),[i,o]=_(null),[l,c]=_(!1),[d,u]=_(null),[m,g]=_(""),[f,k]=_(),[h,p]=_(!0),[b,y]=_(!1),v=ne(null);j(()=>{t.node&&t.node!==n.node&&w({...n,node:t.node})},[t.node]);let w=(E,I=!0)=>{I&&r(B=>({back:[...B.back,n].slice(-30),fwd:[]})),s(E)};j(()=>{let E=!0;c(!0),k(void 0);let I=n.kinds.join(",")||"none";return(n.node?O("/api/graph",{mode:"expand",node:n.node,direction:n.direction,kinds:I,depth:n.depth,limit:400}):O("/api/graph",{mode:"map",kinds:I,limit:200})).then(W=>{E&&(o(W),u(W.root??null))}).catch(W=>E&&Q(W.message,!0)).finally(()=>E&&c(!1)),()=>{E=!1}},[n]);let S=E=>{y(!0),w({...n,node:E})},T=async()=>{if(!(!n.node||!m.trim()))try{let E=await O("/api/graph",{mode:"path",node:n.node,to:m.trim()});o(I=>{if(!I)return I;let B=new Set(I.nodes.map(R=>R.id)),W=new Set(I.edges.map(R=>`${R.src}|${R.dst}|${R.kind}`));return{...I,nodes:[...I.nodes,...E.nodes.filter(R=>!B.has(R.id))],edges:[...I.edges,...E.edges.filter(R=>!W.has(`${R.src}|${R.dst}|${R.kind}`))]}}),y(!0),k(new Set(E.edges.map(I=>`${I.src}|${I.dst}|${I.kind}`)))}catch(E){Q(E.message,!0)}},x=i?.nodes.find(E=>E.id===d),$=x?i.edges.filter(E=>E.dst===x.id):[],A=x?i.edges.filter(E=>E.src===x.id):[],F=E=>i?.nodes.find(I=>I.id===E)?.label??E,C=i?.nodes.filter(E=>E.kind==="file").length??0,L=E=>w({...n,kinds:n.kinds.includes(E)?n.kinds.filter(I=>I!==E):[...n.kinds,E]});return e("div",{style:{height:"100%",display:"flex",flexDirection:"column"},children:[e("div",{class:"gtoolbar",children:[e("button",{type:"button",class:"sm",disabled:!a.back.length,title:"back",onClick:()=>{let E=a.back[a.back.length-1];E&&(r(I=>({back:I.back.slice(0,-1),fwd:[n,...I.fwd]})),s(E))},children:"\u2190"}),e("button",{type:"button",class:"sm",disabled:!a.fwd.length,title:"forward",onClick:()=>{let E=a.fwd[0];E&&(r(I=>({back:[...I.back,n],fwd:I.fwd.slice(1)})),s(E))},children:"\u2192"}),e(bl,{value:n.node??"",onPick:E=>w({...n,node:E.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:E=>w({...n,direction:E.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:m,onInput:E=>g(E.target.value),onKeyDown:E=>E.key==="Enter"&&T()}),e("button",{type:"button",class:"sm",onClick:T,disabled:!n.node,children:"Path"})]}),e("span",{class:"row tight",children:[e("button",{type:"button",class:M("chip",n.mode==="galaxy"&&"on"),onClick:()=>s({...n,mode:"galaxy"}),children:"galaxy"}),e("button",{type:"button",class:M("chip",n.mode==="hierarchy"&&"on"),onClick:()=>s({...n,mode:"hierarchy"}),children:"hierarchy"}),e("button",{type:"button",class:M("chip",h&&"on"),onClick:()=>p(!h),children:"legend"})]}),e("span",{class:"count",children:l?e(U,{}):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:"}),Tr.map(E=>e("button",{type:"button",class:M("chip",n.kinds.includes(E)&&"on"),onClick:()=>L(E),children:E}))]}),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(Be,{nodes:i.nodes,edges:i.edges,mode:n.mode,selected:d,highlight:f,onSelect:u,onActivate:S,legend:h,handle:v,keepPositions:b}):e(J,{children:"The graph is empty. Run a reindex from System."}):e(J,{children:e(U,{})})}),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(be,{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:()=>H("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:()=>H("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(E=>e("tr",{class:"click",onClick:()=>u(E.src),children:[e("td",{children:e(P,{children:E.kind})}),e("td",{class:"break",children:F(E.src)})]}))})})]}),e("div",{class:"section",children:[e("h4",{children:["outgoing \xB7 ",A.length]}),e("table",{children:e("tbody",{children:A.slice(0,60).map(E=>e("tr",{class:"click",onClick:()=>u(E.dst),children:[e("td",{children:e(P,{children:E.kind})}),e("td",{class:"break",children:F(E.dst)})]}))})})]})]})]})]})]})}var rt=["feat","test","perf","refactor","fix","docs","other"],vt={feat:"#2563eb",test:"#16a34a",perf:"#d97706",refactor:"#7c3aed",fix:"#e11d48",docs:"#0284c7",other:"#9ca3af"},at=t=>vt[t]??vt.other;function vs(t){let n=[],s=[],a=0,r=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=r(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 m=n.indexOf(u);m===-1&&(m=r(u)),c.push(m)}}for(;n.length&&n[n.length-1]===null;)n.pop();a=Math.max(a,n.length,o+1),s.push({c:i,lane:o,after:[...n],joins:l,forks:c})}return{rows:s,lanes:a}}function La(t){let n=[];for(let s=0;s<t.length-1;s++){let a=t[s],r=t[s+1];for(let i=0;i<a.after.length;i++){let o=a.after[i];o&&(o===r.c.sha&&i!==r.lane?n.push({kind:"curve",fromLane:i,toLane:r.lane,from:s,to:s+1,lane:i}):a.forks.includes(i)&&i!==a.lane?n.push({kind:"curve",fromLane:a.lane,toLane:i,from:s,to:s+1,lane:i}):n.push({kind:"line",lane:i,from:s,to:s+1}))}}return n}function ks(t){let n=Math.max(0,Math.min(1,t)),s=[191,219,254],a=[30,58,138],r=s.map((i,o)=>Math.round(i+((a[o]??0)-i)*n));return`rgb(${r[0]},${r[1]},${r[2]})`}function Ot(t=800){let n=ne(null),[s,a]=_(t);return j(()=>{let r=n.current;if(!r)return;let i=new ResizeObserver(()=>a(r.clientWidth||t));return i.observe(r),a(r.clientWidth||t),()=>i.disconnect()},[]),[n,s]}function Ia({weeks:t,range:n,onRange:s,hidden:a}){let[r,i]=Ot(),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,m=u?c/u:c,g=m>=5?1:0,f=Math.max(1,...t.map($=>rt.reduce((A,F)=>A+(a.has(F)?0:$.byBucket[F]),0))),k=$=>l.t+d-$/f*d,[h,p]=_(null),b=ne(null),[y,v]=_(null),w=($,A)=>{let F=A.getBoundingClientRect(),C=$-F.left-l.l;return Math.max(0,Math.min(u-1,Math.floor(C/m)))},S=V(()=>{let $=[],A="";for(let C=0;C<u;C++){let L=t[C].week.slice(0,7);if(L!==A){A=L;let E=new Date(t[C].at),I=E.getUTCMonth()===0||!$.length?`${E.getUTCFullYear()}`:E.toLocaleString("en",{month:"short",timeZone:"UTC"});$.push({i:C,label:I})}}let F=Math.max(1,Math.ceil($.length/Math.max(4,c/60)));return $.filter((C,L)=>L%F===0)},[t,c]),T=y??(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:r,children:[e("svg",{width:i,height:o,onMouseMove:$=>{let A=$.currentTarget,F=w($.clientX,A);p(F),b.current&&v([Math.min(b.current.i0,F),Math.max(b.current.i0,F)])},onMouseLeave:()=>p(null),onMouseDown:$=>{let A=$.currentTarget,F=w($.clientX,A);b.current={x0:$.clientX,i0:F},v([F,F]),$.preventDefault()},onMouseUp:$=>{let A=b.current;if(b.current=null,!A)return;if(Math.abs($.clientX-A.x0)<3){v(null),s(null);return}let F=y;v(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($=>e("g",{children:[e("line",{x1:l.l,x2:i-l.r,y1:k(f*$),y2:k(f*$),class:"grid"}),e("text",{x:l.l-6,y:k(f*$)+3,class:"axis","text-anchor":"end",children:Math.round(f*$)})]})),S.map($=>e("text",{x:l.l+$.i*m,y:o-6,class:"axis",children:$.label})),T&&T[0]>=0&&T[1]>=T[0]?e("rect",{x:l.l+T[0]*m,y:l.t,width:(T[1]-T[0]+1)*m,height:d,class:"brush"}):null,t.map(($,A)=>{let F=0;return e("g",{opacity:T&&(A<T[0]||A>T[1])?.35:1,children:rt.map(C=>{if(a.has(C))return null;let L=$.byBucket[C];if(!L)return null;let E=k(F+L),I=k(F);return F+=L,e("rect",{x:l.l+A*m+g/2,y:E,width:Math.max(.5,m-g),height:Math.max(0,I-E-(g&&I-E>2?1:0)),fill:vt[C],rx:m>=6?1.5:0})})})}),h!==null?e("line",{x1:l.l+h*m+m/2,x2:l.l+h*m+m/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*m+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:rt.filter($=>x.byBucket[$]).map($=>e("span",{class:"kdot-lbl",children:[e("i",{class:"kdot",style:{background:vt[$]}}),$," ",x.byBucket[$]]}))})]}):null]})}function Da({counts:t,hidden:n,onToggle:s}){return e("div",{class:"row tight",style:{flexWrap:"wrap"},children:rt.map(a=>e("button",{type:"button",class:M("chip",!n.has(a)&&"on"),onClick:()=>s(a),title:n.has(a)?`show ${a}`:`hide ${a}`,children:[e("i",{class:"kdot",style:{background:vt[a],opacity:n.has(a)?.3:1}}),a," ",t[a]??0]}))})}function ws({values:t,width:n=72,height:s=16}){let a=Math.max(1,...t),r=t.length,i=t.map((o,l)=>`${l/Math.max(1,r-1)*(n-2)+1},${s-1-o/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:i.join(" ")}),t.map((o,l)=>o?e("circle",{cx:l/Math.max(1,r-1)*(n-2)+1,cy:s-1-o/a*(s-3),r:1.4}):null)]})}function Pa({files:t,selected:n,onSelect:s}){let[a,r]=Ot(),i=300,o={l:42,r:16,t:12,b:30},l=Math.max(10,r-o.l-o.r),c=i-o.t-o.b,d=t.filter(v=>v.commits>=2),u=Math.max(2,...d.map(v=>v.commits)),m=Math.max(1,...d.map(v=>v.added+v.deleted)),g=v=>o.l+Math.log(v)/Math.log(u)*l,f=v=>o.t+c-v*c,k=v=>3+Math.sqrt((v.added+v.deleted)/m)*13,[h,p]=_(null),b=[...d].sort((v,w)=>w.risk-v.risk).slice(0,5),y=[1,2,5,10,20,50,100,200,500,1e3].filter(v=>v<=u);return e("div",{class:"hist-chart",ref:a,children:[e("svg",{width:r,height:i,children:[e("title",{children:"files by commits and fix share, sized by lines changed"}),[0,.25,.5,.75,1].map(v=>e("g",{children:[e("line",{x1:o.l,x2:r-o.r,y1:f(v),y2:f(v),class:"grid"}),e("text",{x:o.l-6,y:f(v)+3,class:"axis","text-anchor":"end",children:[Math.round(v*100),"%"]})]})),y.filter(v=>g(v)<r-o.r-70).map(v=>e("text",{x:g(v),y:i-8,class:"axis","text-anchor":"middle",children:v})),e("text",{x:r-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(v=>e("circle",{cx:g(v.commits),cy:f(v.commits?v.fixes/v.commits:0),r:k(v),fill:ks(v.risk),class:M("dot",n===v.path&&"sel"),onMouseEnter:()=>p(v),onMouseLeave:()=>p(null),onClick:()=>s(v.path)})),b.map(v=>{let w=g(v.commits)>r-160;return e("text",{x:w?g(v.commits)-k(v)-3:g(v.commits)+k(v)+3,y:f(v.fixes/v.commits)+3,class:"lbl","text-anchor":w?"end":"start",children:v.path.split("/").slice(-2).join("/")})})]}),h?e("div",{class:"tip",style:{left:Math.min(r-260,g(h.commits)+12),top:Math.max(0,f(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 Fa=["#2563eb","#d97706","#16a34a","#7c3aed","#e11d48","#0284c7","#db2777","#0d9488"],Sn=t=>Fa[t%Fa.length];function Na({rows:t,lanes:n,rowH:s,selected:a}){let i=n*14+10,o=d=>7+d*14,l=d=>d*s+s/2,c=La(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:Sn(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:Sn(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)":Sn(d.lane),stroke:Sn(d.lane),"stroke-width":a===d.c.sha?3:d.c.merge?2:1,class:M(a===d.c.sha&&"sel",!d.c.onHead&&"off")}))]})}var yl={branch:"hexagon",commit:"triangle",memory:"diamond",doc:"square"};function Tn(t){return t.missing?"ring":yl[t.kind]??"circle"}function $n(t){let n=t;return n.kind==="commit"?at(n.bucket??"other"):n.kind==="branch"?n.live||n.isDefault?"#64748b":"#9ca3af":n.kind==="memory"&&(n.status==="superseded"||n.status==="deprecated")?"#93c5fd":Le(t.kind)}var vl={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 xs(t){return vl[t]??Nt(t)}var kl=(t,n)=>t.length>n?`${t.slice(0,n-1)}\u2026`:t;function Oa(t){return t.kind==="commit"?kl(t.label,32):t.kind==="file"?t.label.split("/").pop()??t.label:t.label}var wl=["branch","commit","file","memory","doc"],xl=["contains","merged_into","touches","fixes","records","mentions","documents"],_l={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"},Sl=[5,8,15,30],Ha=(t,n)=>[...t].sort((s,a)=>{let r=n.indexOf(s),i=n.indexOf(a);return(r===-1?99:r)-(i===-1?99:i)||s.localeCompare(a)});function Ba(t,n){let s=new Set(t);return s.has(n)?s.delete(n):s.add(n),s}function Ua({focus:t}){let[n,s]=_(null),[a,r]=_(!1),[i,o]=_(0),[l,c]=_(8),[d,u]=_(new Set),[m,g]=_(new Set),[f,k]=_(""),[h,p]=_(!1),[b,y]=_(t??null);j(()=>{let R=!0;return r(!0),O("/api/history/knowledge",{focus:t,branches:l,limit:400}).then(z=>{R&&(s(z),y(z.focus??null))}).catch(z=>R&&Q(z.message,!0)).finally(()=>R&&r(!1)),()=>{R=!1}},[t,l,i]);let v=V(()=>{if(!n?.git)return null;let R=f?n.nodes.filter(z=>z.kind!=="commit"||z.root||z.bucket===f):n.nodes;return yn({nodes:R,edges:n.edges},{hiddenKinds:d,hiddenEdges:m,status:"",category:"",hideSuperseded:!1})},[n,d,m,f]),w=n?.git?n.nodes:[],S=V(()=>st(w,R=>R.kind),[n]),T=V(()=>st(n?.edges??[],R=>R.kind),[n]),x=V(()=>st(w.filter(R=>R.kind==="commit"),R=>R.bucket??"other"),[n]),$=R=>w.find(z=>z.kind===R&&!z.missing),A=V(()=>new Map(w.map(R=>[R.id,R])),[n]),F=b?A.get(b):void 0,C=v?.edges??[],L=F?C.filter(R=>R.dst===F.id):[],E=F?C.filter(R=>R.src===F.id):[],I=R=>{let z=A.get(R);return z?z.kind==="commit"?`${z.short} ${z.label}`:z.label:R},B=R=>H("history",{tab:"graph",focus:R}),W=n?.focus?A.get(n.focus):void 0;return n&&!n.git?e(J,{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:W?I(W.id):t}),e("button",{type:"button",class:"sm",onClick:()=>H("history",{tab:"graph"}),children:"Show all"})]}):e(N,{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:Sl.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&&B(`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:f,title:"commit kind",onChange:R=>k(R.target.value),children:[e("option",{value:"",children:"any commit kind"}),rt.filter(R=>x.has(R)).map(R=>e("option",{value:R,children:[R," (",x.get(R),")"]}))]}):null,e("button",{type:"button",class:M("chip",h&&"on"),onClick:()=>p(!h),children:"legend"}),e("button",{type:"button",class:"sm",title:"reload",onClick:()=>o(R=>R+1),children:"\u21BB"}),e("span",{class:"count",children:a?e(U,{}):v&&n?`${v.nodes.length} of ${w.length} nodes \xB7 ${v.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:"}),Ha([...S.keys()],wl).map(R=>{let z=$(R);return e("button",{type:"button",class:M("chip",!d.has(R)&&"on"),onClick:()=>u(Ba(d,R)),children:[z?e(Ze,{shape:Tn(z),color:$n(z)}):null,R," ",S.get(R)]})}),e("span",{class:"muted small",style:{marginLeft:8},children:"edges:"}),Ha([...T.keys()],xl).map(R=>{let z=xs(R);return e("button",{type:"button",title:_l[R],class:M("chip",!m.has(R)&&"on"),onClick:()=>g(Ba(m,R)),children:[e(bt,{color:z.color,dash:z.dash}),R," ",T.get(R)]})})]}),e("div",{class:"kbody",style:{gridTemplateColumns:F?"minmax(0,1fr) 320px":"minmax(0,1fr)"},children:[e("div",{style:{minWidth:0,minHeight:0},children:v?v.nodes.length?e(Be,{nodes:v.nodes,edges:v.edges,selected:b,onSelect:y,onActivate:B,legend:h,colorOf:$n,shapeOf:Tn,edgeStyleOf:xs,labelOf:Oa}):w.length?e(J,{children:"Nothing left after these filters."}):e(J,{children:"No commits to draw."}):e(J,{children:e(U,{})})}),F&&e("div",{class:"panel right",children:[e("div",{class:"head",children:["selection ",e("span",{class:"spacer"}),e("a",{onClick:()=>y(null),children:"close"})]}),e("div",{class:"body",children:[e(Tl,{node:F,focus:n?.focus??void 0,onFocus:B}),e(yt,{title:"incoming",rows:L.map(R=>({kind:R.kind,id:R.src})),label:I,onPick:y}),e(yt,{title:"outgoing",rows:E.map(R=>({kind:R.kind,id:R.dst})),label:I,onPick:y})]})]})]})]})}function Tl({node:t,focus:n,onFocus:s}){return e("div",{class:"section",children:[e("div",{class:"row tight",children:[e(Ze,{shape:Tn(t),color:$n(t)}),e(be,{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:at(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(N,{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(a=>e(P,{children:["#",a]}))]}):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 `:"",re(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 En({kind:t,bucket:n}){return e("span",{class:"tag kind",style:{color:at(n)},children:t})}function ja({added:t,deleted:n}){let s=t+n,a=5,r=s?Math.round(t/s*a):0,i=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:["+",q(t)]}),e("span",{class:"del",children:["-",q(n)]}),e("span",{class:"bars",children:Array.from({length:a},(o,l)=>e("i",{class:l<r?"a":l<r+i?"d":""}))})]})}function za({refs:t,tags:n,max:s=3}){let a=t.filter(r=>!r.startsWith("tag: "));return!a.length&&!n.length?null:e(N,{children:[n.slice(0,2).map(r=>e("span",{class:"ref tag",children:r})),a.slice(0,s).map(r=>e("span",{class:M("ref",r.includes("/")&&"remote"),children:r})),a.length>s?e("span",{class:"ref remote",children:["+",a.length-s]}):null]})}function $l({c:t}){return e(N,{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 kt({value:t}){return e("span",{class:"riskbar",title:t.toFixed(2),children:e("i",{style:{width:`${Math.round(t*100)}%`,background:ks(.3+t*.7)}})})}function Ye({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 wt({commits:t,selected:n,onSelect:s,lanes:a,empty:r}){return t.length?e("div",{class:"commits",children:[a?e(Na,{rows:a.rows,lanes:a.lanes,rowH:28,selected:n}):null,e("div",{class:"rows",children:t.map(o=>e("div",{class:M("crow",n===o.sha&&"sel",!o.onHead&&"off"),onClick:()=>s(o.sha),title:`${o.sha}
12
12
  ${o.subject}
13
13
  ${o.author} \xB7 ${new Date(o.at).toLocaleString()}${o.riskReasons.length?`
14
- ${o.riskReasons.join("; ")}`:""}`,children:[e("span",{class:"when",children:fe(o.at)}),e("span",{class:"subj",children:[e("span",{class:"sha",children:o.short}),e(hn,{kind:o.kind,bucket:o.bucket}),o.subject,e(wi,{refs:o.refs,tags:o.tags})]}),e("span",{class:"meta",children:[e(Ho,{c:o}),o.merge?e("span",{children:"merge"}):e(xi,{added:o.added,deleted:o.deleted}),e("span",{children:o.author.split(" ")[0]})]})]}))})]}):e(X,{children:r??"No commits match."})}function ls({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(hn,{kind:t.kind,bucket:t.bucket}):null,e("a",{children:t.subject}),t.at?e("span",{class:"muted small",children:[" \xB7 ",fe(t.at)]}):null,t.paths.length?e("div",{class:"muted small",children:t.paths.join(", ")}):null]})}function Bo({sha:t,path:n}){let s=G(()=>H("/api/history/diff",{sha:t,path:n}),[t,n]);if(s.error)return e(Z,{error:s.error});if(!s.data)return e(B,{});let i=s.data.text.split(`
15
- `);return e(N,{children:[e("div",{class:"diff",children:i.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 Uo({sha:t,onSelect:n}){let s=G(()=>H("/api/history/commit",{sha:t}),[t]),[i,r]=_(!1);if(j(()=>r(!1),[t]),s.error)return e(Z,{error:s.error});if(!s.data)return e(B,{});if(s.data.error)return e(Z,{error:s.data.error});let a=s.data,o=a.commit,l=Math.max(1,...a.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(hn,{kind:o.kind,bucket:o.bucket}),o.scope?e(I,{children:o.scope}):null,o.breaking?e(I,{class:"risk-high",children:"breaking"}):null,o.pr?e(I,{children:["PR #",o.pr]}):null,o.issues.map(c=>e(I,{children:c})),e(wi,{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()," (",ne(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(I,{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:()=>r(i===!1?null:!1),children:i===!1?"Show diff":"Hide diff"}),e("button",{type:"button",class:"sm",onClick:()=>O("history",{tab:"graph",focus:`commit:${o.sha}`}),children:"Graph"}),a.branches.length?e("span",{class:"muted small",children:["on ",a.branches.slice(0,5).join(", "),a.branches.length>5?` +${a.branches.length-5}`:""]}):null]})]}),a.blamedBy.length||a.origins.length||a.revertedBy?e("div",{class:"card",children:[e("h3",{children:"what history says"}),a.origins.length?e(N,{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:a.origins.map(c=>e("div",{class:L("step","origin"),children:e(ls,{l:c,onSelect:n})}))})]}):null,a.blamedBy.length?e(N,{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:a.blamedBy.map(c=>e("div",{class:L("step","fix"),children:[e(ls,{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,a.revertedBy?e(N,{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(ls,{l:a.revertedBy,onSelect:n})})})]}):null]}):null,i!==!1?e("div",{class:"card",children:[e("div",{class:"row",style:{marginBottom:6},children:[e("h3",{style:{margin:0},children:["diff",i?` \xB7 ${i}`:""]}),i?e("button",{type:"button",class:"sm ghost",onClick:()=>r(null),children:"whole commit"}):null]}),e(Bo,{sha:o.sha,path:i??void 0})]}):null,a.files.length?e("div",{class:"card",children:[e("h3",{children:["files \xB7 ",a.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:a.files.map(c=>e("div",{class:"cfile",children:[e("div",{class:"row tight",children:[e("a",{class:"ellipsis grow",title:c.path,onClick:()=>O("explore",{file:c.path}),children:c.path}),e(De,{value:c.added+c.deleted,max:l,width:44}),e(xi,{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:()=>O("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(dt,{value:c.fileRisk})," ",c.fileFixes," past fix",c.fileFixes===1?"":"es"]}):null,c.symbols.map(d=>e("a",{onClick:()=>O("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 zo({ov:t,params:n,selected:s,onSelect:i}){let[r,a]=_(new Set),[o,l]=_(null),[c,d]=_(n.q??""),[p,m]=_(""),[g,f]=_(n.path??""),[x,h]=_(!1),[u,y]=_(!1),[b,v]=_(150),k=t.buckets.filter(R=>!r.has(R)),S=G(()=>H("/api/history/commits",{buckets:r.size?k.join(","):void 0,q:c.trim()||void 0,author:p||void 0,path:g.trim()||void 0,since:o?new Date(o[0]).toISOString():void 0,until:o?new Date(o[1]).toISOString():void 0,risky:x?1:void 0,head:u?1:void 0,limit:b}),[r,c,p,g,o,x,u,b]),E=G(()=>H("/api/history/graph",{limit:400}),[t.head]),w=K(()=>{if(!E.data||!S.data)return;let R=new Set(S.data.commits.map($=>$.sha)),M=E.data.commits.slice(0,S.data.commits.length);if(!(M.length!==R.size||!M.every($=>R.has($.sha))))return rs(M)},[E.data,S.data]),C=K(()=>{let R={};for(let M of t.weeks)for(let $ of t.buckets)R[$]=(R[$]??0)+M.byBucket[$];return R},[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(hi,{counts:C,hidden:r,onToggle:R=>a(M=>{let $=new Set(M);return $.has(R)?$.delete(R):$.add(R),$})}),e("span",{class:"spacer"}),e("span",{class:"muted small",children:o?e(N,{children:[fe(o[0])," \u2192 ",fe(o[1])," ",e("a",{onClick:()=>l(null),children:"clear"})]}):"drag across the chart to focus a period"})]}),e(mi,{weeks:t.weeks,range:o,onRange:l,hidden:r})]}),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:R=>d(R.target.value),style:{width:240}}),e("select",{value:p,onChange:R=>m(R.target.value),children:[e("option",{value:"",children:"everyone"}),t.authors.map(R=>e("option",{value:R.name,children:[R.name," (",R.commits,")"]}))]}),e("input",{type:"text",placeholder:"path prefix",value:g,onInput:R=>f(R.target.value),style:{width:180}}),e("button",{type:"button",class:L("chip",x&&"on"),onClick:()=>h(!x),title:"only commits later fixed, reverted, large or touching hotspots",children:"\u26A0 hindsight flags"}),e("button",{type:"button",class:L("chip",u&&"on"),onClick:()=>y(!u),children:"HEAD only"}),e("span",{class:"spacer"}),e("span",{class:"muted small",children:S.data?`${S.data.total} commits`:""})]}),S.error?e(Z,{error:S.error}):S.data?e(N,{children:[e(ut,{commits:S.data.commits,selected:s,onSelect:i,lanes:w}),S.data.total>S.data.commits.length?e("div",{class:"row",style:{marginTop:8},children:e("button",{type:"button",class:"sm",onClick:()=>v(R=>R+200),children:["show more (",S.data.total-S.data.commits.length," left)"]})}):null]}):e(B,{})]})]}),e("div",{class:"stack",children:s?e(Uo,{sha:s,onSelect:i}):e(N,{children:[e("div",{class:"card",children:[e("h3",{children:"worth knowing"}),t.notable.length?e(ut,{commits:t.notable,selected:null,onSelect:i}):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(R=>e("tr",{class:"click",onClick:()=>m(R.name),children:[e("td",{children:R.name}),e("td",{class:"num",children:[e(De,{value:R.commits,max:t.authors[0]?.commits??1,width:70})," ",R.commits]}),e("td",{class:"muted small",children:[R.fixes," fixes \xB7 ",R.files," files"]}),e("td",{class:"muted small",children:ne(R.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(R=>e("a",{onClick:()=>i(R.sha),title:fe(R.at),children:e("span",{class:"ref tag",children:R.name})}))})]}):null]})})]})}function jo({ov:t,params:n,onSelectCommit:s}){let[i,r]=_(n.branch??null),[a,o]=_(!1),[l,c]=_(!0),d=G(()=>H("/api/history/graph",{limit:120}),[t.head]),p=G(()=>i?H("/api/history/branch",{name:i}):Promise.resolve(null),[i]),m=K(()=>d.data?rs(d.data.commits):void 0,[d.data]),g=t.branches.filter(u=>(a||!u.remote)&&(l||!u.merged||u.isDefault)),f=Math.max(1,...g.map(u=>Math.max(u.ahead,u.behind))),[x,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(Z,{error:d.error}):d.data?e(ut,{commits:d.data.commits,selected:x,onSelect:u=>{h(u),s(u)},lanes:m}):e(B,{})]}),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 ",g.length]}),e("span",{class:"spacer"}),e("button",{type:"button",class:L("chip",a&&"on"),onClick:()=>o(!a),children:"remotes"}),e("button",{type:"button",class:L("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(u=>e("tr",{class:L("click",i===u.name&&"sel"),onClick:()=>r(u.name),children:[e("td",{class:"break",children:[e("span",{class:L("ref",u.remote&&"remote"),children:u.name}),u.current?e(I,{children:"current"}):null,u.isDefault?e(I,{children:"base"}):null,!u.merged&&!u.isDefault?e(I,{class:"risk-medium",children:"unmerged"}):null,u.lastSubject?e("div",{class:"muted small ellipsis",style:{maxWidth:260},children:u.lastSubject}):null]}),e("td",{children:u.isDefault?e("span",{class:"muted small",children:"\u2014"}):e("span",{class:"ab",title:`${u.ahead} ahead, ${u.behind} behind`,children:[e("span",{class:"ok",children:["+",u.ahead]}),e(De,{value:u.ahead,max:f,width:40}),e(De,{value:u.behind,max:f,width:40}),e("span",{class:"bad",children:["-",u.behind]})]})}),e("td",{class:"muted small nowrap",children:[ne(u.at),u.lastAuthor?` \xB7 ${u.lastAuthor.split(" ")[0]}`:""]})]}))})]})]}),i?e("div",{class:"card",children:[e("h3",{children:i}),p.error?e(Z,{error:p.error}):p.data?p.data.error?e(Z,{error:p.data.error}):e(Go,{d:p.data,onSelect:u=>{h(u),s(u)}}):e(B,{})]}):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 Go({d:t,onSelect:n}){let s=t.branch,i=t.files.filter(r=>r.risk>=.3);return e(N,{children:[e("div",{class:"row small",style:{flexWrap:"wrap"},children:[e(I,{children:["tip ",s.sha.slice(0,7)]}),e(I,{children:ne(s.at)}),s.upstream?e(I,{children:["tracks ",s.upstream]}):null,s.isDefault?null:e(I,{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:()=>O("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(N,{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(ut,{commits:t.commits,selected:null,onSelect:n,empty:"Nothing unique: the branch is fully merged or behind."}),t.files.length?e(N,{children:[e("div",{class:"muted small",style:{margin:"8px 0 4px"},children:["files touched ",i.length?`\xB7 ${i.length} with a fix-heavy history`:""]}),e("div",{class:"list",style:{maxHeight:220},children:t.files.map(r=>e("div",{class:"item",onClick:()=>O("history",{tab:"files",file:r.path}),children:e("div",{class:"p",children:[r.risk>=.3?e(dt,{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 Xo({params:t,onSelectCommit:n}){let[s,i]=_(""),[r,a]=_(t.file??null);j(()=>{t.file&&a(t.file)},[t.file]);let o=G(()=>H("/api/history/files",{path:s.trim()||void 0,limit:400}),[s]),{sorted:l,th:c}=He(o.data?.files,"risk"),[d,p]=_(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:m=>i(m.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(gi,{files:o.data.files,selected:r,onSelect:a}):o.error?e(Z,{error:o.error}):e(B,{})]}),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(m=>e("tr",{class:L("click",r===m.path&&"sel"),onClick:()=>a(m.path),children:[e("td",{class:"break",children:m.path}),e("td",{class:"num",children:m.commits}),e("td",{class:"num",children:m.fixes}),e("td",{class:"num",children:m.bugOrigins}),e("td",{class:"num",children:m.commits90d}),e("td",{children:e(as,{values:m.months})}),e("td",{class:"num",children:[e(dt,{value:m.risk})," ",m.risk.toFixed(2)]})]}))})]})})]}),e("div",{class:"stack",children:r?e(Wo,{path:r,selected:d,onSelect:m=>{p(m),n(m)}}):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 Wo({path:t,selected:n,onSelect:s}){let i=G(()=>H("/api/history/file",{path:t}),[t]);if(i.error)return e(Z,{error:i.error});if(!i.data)return e(B,{});let r=i.data,a=r.file;return e(N,{children:[e("div",{class:"card",children:[e("h3",{class:"break",children:t}),a?e(N,{children:[e("div",{class:"row small",style:{flexWrap:"wrap"},children:[e(I,{children:[a.commits," commits"]}),e(I,{children:[a.fixes," fixes"]}),e(I,{children:["+",J(a.added),"/-",J(a.deleted)]}),e(I,{children:[fe(a.firstAt)," \u2192 ",fe(a.lastAt)]}),a.renamedFrom?e(I,{children:["from ",a.renamedFrom]}):null]}),e("div",{class:"row small",style:{marginTop:6,alignItems:"center"},children:[e(dt,{value:a.risk}),e("span",{class:"muted",children:["history risk ",a.risk.toFixed(2),a.reasons.length?`: ${a.reasons.join("; ")}`:""]})]}),e("div",{class:"row small",style:{marginTop:6,flexWrap:"wrap"},children:[e("span",{class:"muted",children:"authors:"}),a.authors.map(([o,l])=>e(I,{children:[o," ",l]})),e("span",{class:"spacer"}),e(as,{values:a.months,width:120,height:22})]}),e("div",{class:"row",style:{marginTop:8},children:[e("button",{type:"button",class:"sm",onClick:()=>O("explore",{file:t}),children:"Open source"}),e("button",{type:"button",class:"sm",onClick:()=>O("galaxy",{node:`file:${t}`}),children:"Galaxy"}),e("button",{type:"button",class:"sm",onClick:()=>O("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("div",{class:"card",children:[e("h3",{children:"changes that later needed fixing"}),e("div",{class:"chain",children:r.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(hn,{kind:o.kind,bucket:o.bucket})," ",o.subject]}),e("span",{class:"muted small",children:[" \xB7 ",fe(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 ",r.commits.length]}),e(ut,{commits:r.commits,selected:n,onSelect:s})]})]})}function qo({ov:t,onSelectCommit:n}){let s=G(()=>H("/api/history/risk"),[t.head,t.stats.workingTree]),[i,r]=_(""),a=G(()=>i.trim()?H("/api/history/risk",{paths:i.trim()}):Promise.resolve(null),[i]),o=i.trim()?a.data:s.data,l=G(()=>H("/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:i.trim()?"history risk for these paths":"working tree exposure"}),e("input",{type:"text",placeholder:"or paths, comma separated",value:i,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."}),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:()=>O("history",{tab:"files",file:c.path}),children:c.path})}),e("td",{class:"nowrap",children:c.file?e(N,{children:[e(dt,{value:c.file.risk})," ",c.file.risk.toFixed(2)]}):e("span",{class:"muted small",children:"new"})}),e("td",{class:"small",children:c.file?e(N,{children:[e("div",{class:"muted",children:[c.file.commits," commits \xB7 ",c.file.fixes," fixes \xB7 last"," ",ne(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(X,{children:"Working tree is clean."}):s.error?e(Z,{error:s.error}):e(B,{})]}),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:()=>O("history",{tab:"files",file:c.path}),children:[e("td",{class:"break",children:c.path}),e("td",{class:"nowrap",children:[e(dt,{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(Jo,{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(ut,{commits:l.data,selected:null,onSelect:n,empty:"No traced fix origins yet."}):e(B,{})]})]})]})}function Jo({text:t}){return e("div",{class:"lesson",children:[e("span",{class:"i",children:"\u25C6"}),e("span",{children:t})]})}function _i({params:t}){let[n,s]=_(t.tab||(t.file?"files":t.branch?"branches":"timeline")),[i,r]=_(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&&r(t.sha)},[t.sha]);let a=G(()=>H("/api/history"),[]),o=p=>{r(p),s("timeline")};if(a.error)return e("div",{class:"page",children:e(Z,{error:a.error})});if(!a.data)return e("div",{class:"page",children:e(B,{})});let l=a.data;if(!l.git)return e("div",{class:"page",children:e(X,{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(Ue,{v:c.commits,k:"commits",sub:`${c.onHead} on HEAD`}),e(Ue,{v:c.last30,k:"last 30 days",sub:d===null?`${c.prior30} in the 30 before`:`${d>=0?"+":""}${d}% vs prior 30`}),e(Ue,{v:c.fixes,k:"fixes",sub:`${Math.round(c.fixes/Math.max(1,c.commits-c.merges)*100)}%`}),e(Ue,{v:c.linksTraced,k:"traced fix origins",sub:c.tracePending?`${c.tracePending} pending`:`${c.fixesTraced} fixes`}),e(Ue,{v:c.branches,k:"branches",sub:c.unmerged?`${c.unmerged} unmerged`:"all merged"}),e(Ue,{v:c.authors,k:"authors",sub:`${c.files} files`}),e(Ue,{v:c.tags,k:"tags",sub:l.tags[0]?.name??""}),e(Ue,{v:c.workingTree,k:"working tree",sub:l.branch??"detached"})]}),e("div",{class:"row",style:{marginBottom:8},children:[e(we,{tabs:[["timeline","Timeline"],["branches","Branches"],["files","Files"],["graph","Graph"],["risk","Risk & lessons"]],value:n,onChange:p=>{s(p),O("history",{tab:p,sha:i??void 0})}}),e("span",{class:"spacer"}),e("span",{class:"muted small",children:[l.branch??"detached"," @ ",l.head.slice(0,7)," \xB7 built ",ne(l.builtAt)," ",e("a",{onClick:()=>H("/api/history",{refresh:1}).then(()=>a.reload()),children:"rebuild"})]})]}),n==="timeline"&&e(zo,{ov:l,params:t,selected:i,onSelect:r}),n==="branches"&&e(jo,{ov:l,params:t,onSelectCommit:o}),n==="files"&&e(Xo,{params:t,onSelectCommit:o}),n==="graph"&&e(ki,{focus:t.focus}),n==="risk"&&e(qo,{ov:l,onSelectCommit:o})]})}var Ko=/^([a-z][a-z0-9+.-]*):(.*)$/i;function Et(t){let n=t.trim();if(!n)return{kind:"text"};if(n.startsWith("#"))return{kind:"anchor",href:n};let s=Ko.exec(n);if(!s){let a=n.replace(/^\.\//,"").split("#")[0]??"";return a?{kind:"file",file:a}:{kind:"text"}}let i=s[1].toLowerCase(),r=s[2];switch(i){case"mem":case"memory":return r?{kind:"memory",name:r}:{kind:"text"};case"file":case"sym":{let a=r.replace(/^\/+/,"").split("#")[0]??"";return a?{kind:"file",file:a}:{kind:"text"}}case"http":case"https":case"mailto":return{kind:"external",href:n};default:return{kind:"text"}}}function gn(t){if(t.kind==="memory")return`#/memory?name=${encodeURIComponent(t.name)}`;if(t.kind==="file")return`#/explore?file=${encodeURIComponent(t.file)}`}function ps(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var et=ps();function Ii(t){et=t}var Ze={exec:()=>null};function pt(t){let n=[];return s=>{let i=Math.max(0,Math.min(3,s-1)),r=n[i];return r||(r=t(i),n[i]=r),r}}function V(t,n=""){let s=typeof t=="string"?t:t.source,i={replace:(r,a)=>{let o=typeof a=="string"?a:a.source;return o=o.replace(he.caret,"$1"),s=s.replace(r,o),i},getRegex:()=>new RegExp(s,n)};return i}var Vo=((t="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+t)}catch{return!1}})(),he={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:pt(t=>new RegExp(`^ {0,${t}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:pt(t=>new RegExp(`^ {0,${t}}((?:-[ ]*){3,}|(?:_[ ]*){3,}|(?:\\*[ ]*){3,})(?:\\n+|$)`)),fencesBeginRegex:pt(t=>new RegExp(`^ {0,${t}}(?:\`\`\`|~~~)`)),headingBeginRegex:pt(t=>new RegExp(`^ {0,${t}}#`)),htmlBeginRegex:pt(t=>new RegExp(`^ {0,${t}}(?:</?(?:${Rt})(?: +|$|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`,"i")),blockquoteBeginRegex:pt(t=>new RegExp(`^ {0,${t}}>`))},Zo=/^(?:[ \t]*(?:\n|$))+/,Yo=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Qo=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,At=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,el=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ms=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Di=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |fences|blockquote|heading|hr|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Ni=V(Di).replace(/bull/g,ms).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(),tl=V(Di).replace(/bull/g,ms).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(),hs=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,nl=/^[^\n]+/,gs=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,sl=V(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",gs).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),rl=V(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,ms).getRegex(),Rt="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",fs=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,il=V("^ {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",fs).replace("tag",Rt).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Pi=t=>V(hs).replace("hr",At).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",Rt).getRegex(),al=Pi(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),ol=Pi(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),ll=V(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",ol).getRegex(),bs={blockquote:ll,code:Yo,def:sl,fences:Qo,heading:el,hr:At,html:il,lheading:Ni,list:rl,newline:Zo,paragraph:al,table:Ze,text:nl},Si=V("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",At).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",Rt).getRegex(),cl={...bs,lheading:tl,table:Si,paragraph:V(hs).replace("hr",At).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Si).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",Rt).getRegex()},dl={...bs,html:V(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",fs).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:Ze,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:V(hs).replace("hr",At).replace("heading",` *#{1,6} *[^
16
- ]`).replace("lheading",Ni).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},ul=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,pl=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Oi=/^( {2,}|\\)\n(?!\s*$)[ \t]*/,ml=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Le=/[\p{P}\p{S}]/u,mt=/[\s\p{P}\p{S}]/u,Mt=/[^\s\p{P}\p{S}]/u,hl=V(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,mt).getRegex(),gl=/[\p{Pi}\p{Ps}"']/u,Hi=/(?!~)[\p{P}\p{S}]/u,fl=/(?!~)[\s\p{P}\p{S}]/u,bl=/(?:[^\s\p{P}\p{S}]|~)/u,yl=V(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Vo?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Bi=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,vl=V(Bi,"u").replace(/punct/g,Le).getRegex(),kl=V(Bi,"u").replace(/punct/g,Hi).getRegex(),xl=/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,wl=V(xl,"u").replace(/openQuote/g,gl).replace(/punct/g,Le).getRegex(),Ui="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",_l=V(Ui,"gu").replace(/notPunctSpace/g,Mt).replace(/punctSpace/g,mt).replace(/punct/g,Le).getRegex(),Sl=V(Ui,"gu").replace(/notPunctSpace/g,bl).replace(/punctSpace/g,fl).replace(/punct/g,Hi).getRegex(),Tl="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)",El=V(Tl,"gu").replace(/notPunctSpace/g,Mt).replace(/punctSpace/g,mt).replace(/punct/g,Le).getRegex(),Cl=V("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Mt).replace(/punctSpace/g,mt).replace(/punct/g,Le).getRegex(),$l="^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",Al=V($l,"gu").replace(/notPunctSpace/g,Mt).replace(/punctSpace/g,mt).replace(/punct/g,Le).getRegex(),Rl=V(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Le).getRegex(),Ml="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",Fl=V(Ml,"gu").replace(/notPunctSpace/g,Mt).replace(/punctSpace/g,mt).replace(/punct/g,Le).getRegex(),Ll=V(/\\(punct)/,"gu").replace(/punct/g,Le).getRegex(),Il=V(/(`+)(?:[^`]|[^`][\s\S]*?[^`])\1(?!`)|`+|\\(punct)/,"gu").replace(/punct/g,Le).getRegex(),Dl=V(/^<(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(),Nl=V(fs).replace("(?:-->|$)","-->").getRegex(),Pl=V("^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",Nl).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),zi=/\[(?:\\[\s\S]|[^\[\]\\])*\]/,yn=V(/(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/).replace("brackets",zi).getRegex(),Ol=V(/^!?\[(label)\]\([ \t\n]*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?[ \t\n]*\)/).replace("label",yn).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Hl=V(/^!?\[(label)\]\[(ref)\]/).replace("label",yn).replace("ref",gs).getRegex(),Bl=V(/^!?\[(ref)\](?:\[\])?/).replace("ref",gs).getRegex(),Ti=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\]){1,999}/,Ul=V(/(?:[^\[\]\\`]*(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\]))){0,999}?[^\[\]\\`]*?/).replace("brackets",zi).getRegex(),zl=V("reflink|nolink(?!\\()","g").replace("reflink",V(/^!?\[(label)\]\[(ref)\]/).replace("label",Ul).replace("ref",Ti).getRegex()).replace("nolink",V(/^!?\[(ref)\](?:\[\])?/).replace("ref",Ti).getRegex()).getRegex(),Ei=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,jl=/[A-Za-z0-9._+-]+@[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/,Gl=V(/(?:mailto:email|xmpp:email(?:\/[A-Za-z0-9@.]+)?)/).replace(/email/g,jl).getRegex(),ys={_backpedal:Ze,anyPunctuation:Ll,anyPunctuationOutsideCode:Il,autolink:Dl,blockSkip:yl,br:Oi,code:pl,del:Ze,delLDelim:Ze,delRDelim:Ze,emStrongLDelim:vl,emStrongRDelimAst:_l,emStrongRDelimUnd:Cl,escape:ul,link:Ol,nolink:Bl,punctuation:hl,reflink:Hl,reflinkSearch:zl,tag:Pl,text:ml,url:Ze},Xl={...ys,emStrongLDelim:wl,emStrongRDelimAst:El,emStrongRDelimUnd:Al,link:V(/^!?\[(label)\]\((.*?)\)/).replace("label",yn).getRegex(),reflink:V(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",yn).getRegex()},ds={...ys,emStrongRDelimAst:Sl,emStrongLDelim:kl,delLDelim:Rl,delRDelim:Fl,url:V(/^emailProtocol|^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("emailProtocol",Gl).replace("protocol",Ei).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:V(/^(?:[^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",Ei).replace(/emailProtocol/g,/(?:mailto|xmpp):/).getRegex()},Wl={...ds,br:V(Oi).replace("{2,}","*").getRegex(),text:V(ds.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},fn={normal:bs,gfm:cl,pedantic:dl},Ct={normal:ys,gfm:ds,breaks:Wl,pedantic:Xl},ql={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Ci=t=>ql[t];function ke(t,n){if(n){if(he.escapeTest.test(t))return t.replace(he.escapeReplace,Ci)}else if(he.escapeTestNoEncode.test(t))return t.replace(he.escapeReplaceNoEncode,Ci);return t}function Jl(t){return he.numericCharacterReference.test(t)?t.replace(he.numericCharacterReferenceOrAmpersand,(n,s,i)=>{if(s===void 0&&i===void 0)return"&amp;";let r=s===void 0?Number.parseInt(i,16):Number.parseInt(s,10);return r===0||r>1114111||r>=55296&&r<=57343?"\uFFFD":r===38?"&amp;":String.fromCodePoint(r)}):t}function $i(t){try{t=encodeURI(t).replace(he.percentDecode,"%")}catch{return null}return t}function Ai(t,n){let s=t.replace(he.findPipe,(a,o,l)=>{let c=!1,d=o;for(;--d>=0&&l[d]==="\\";)c=!c;return c?"|":" |"}),i=s.split(he.splitPipe),r=0;if(i[0].trim()||i.shift(),i.length>0&&!i.at(-1)?.trim()&&i.pop(),n)if(i.length>n)i.splice(n);else for(;i.length<n;)i.push("");for(;r<i.length;r++)i[r]=i[r].trim().replace(he.slashPipe,"|");return i}function ze(t,n,s){let i=t.length;if(i===0)return"";let r=0;for(;r<i;){let a=t.charAt(i-r-1);if(a===n&&!s)r++;else if(a!==n&&s)r++;else break}return t.slice(0,i-r)}function Ri(t){let n=t.split(`
17
- `),s=n.length-1;for(;s>=0&&he.blankLine.test(n[s]);)s--;return n.length-s<=2?t:n.slice(0,s+1).join(`
18
- `)}function vn(t){return t.trim().toLowerCase().toUpperCase().toLowerCase()}function Mi(t,n){if(t.indexOf(n[0])===-1&&t.indexOf(n[1])===-1)return-1;let s=0;for(let i=0;i<t.length;i++)if(t[i]==="\\")i++;else if(t[i]===n[0])s++;else if(t[i]===n[1]&&(s--,s<0))return i;return s>0?-2:-1}function cs(t,n=0){let s=n,i="";for(let r of t)if(r===" "){let a=4-s%4;i+=" ".repeat(a),s+=a}else i+=r,s++;return i}function Fi(t,n,s,i,r){let a=n.href,o=n.title||null,l=t[1].replace(r.other.outputLinkReplace,"$1"),c=t[0].charAt(0)==="!",d=i.state.inLink,p=i.state.linkEmitted,m=i.state.inRawBlock;i.state.inLink=!0,i.state.linkEmitted=!1;let g=i.inlineTokens(l),f=i.state.linkEmitted;if(i.state.linkEmitted=p,i.state.inLink=d,!c){if(f){i.state.inRawBlock=m;return}i.state.linkEmitted=!0}return{type:c?"image":"link",raw:s,href:a,title:o,text:l,tokens:g}}function Kl(t,n,s){let i=t.match(s.other.indentCodeCompensation);if(i===null)return n;let r=i[1];return n.split(`
19
- `).map(a=>{let o=a.match(s.other.beginningSpace);if(o===null)return a;let[l]=o;return a.slice(Math.min(l.length,r.length))}).join(`
20
- `)}function Li(t,n,s,i){if(!n.includes("<"))return!1;for(let r=0;r<n.length;r++){if(n[r]==="\\"){r++;continue}if(n[r]==="`"){let l=i.inline.code.exec(n.slice(r));if(l){r+=l[0].length-1;continue}}if(n[r]!=="<")continue;let a=t.slice(s+r),o=i.inline.tag.exec(a)||i.inline.autolink.exec(a);if(o){if(o[0].length>n.length-r)return!0;r+=o[0].length-1}}return!1}var kn=class{constructor(t){ee(this,"options");ee(this,"rules");ee(this,"lexer");this.options=t||et}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]:Ri(n[0]),i=s.replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:s,codeBlockStyle:"indented",text:i}}}fences(t){let n=this.rules.block.fences.exec(t);if(n){let s=n[0],i=Kl(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:i}}}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 i=ze(s,"#");(this.options.pedantic||!i||this.rules.other.endingSpaceTabChar.test(i))&&(s=i.trim())}return{type:"heading",raw:ze(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:ze(n[0],`
22
- `)}}blockquote(t){let n=this.rules.block.blockquote.exec(t);if(n){let s=ze(n[0],`
14
+ ${o.riskReasons.join("; ")}`:""}`,children:[e("span",{class:"when",children:Se(o.at)}),e("span",{class:"subj",children:[e("span",{class:"sha",children:o.short}),e(En,{kind:o.kind,bucket:o.bucket}),o.subject,e(za,{refs:o.refs,tags:o.tags})]}),e("span",{class:"meta",children:[e($l,{c:o}),o.merge?e("span",{children:"merge"}):e(ja,{added:o.added,deleted:o.deleted}),e("span",{children:o.author.split(" ")[0]})]})]}))})]}):e(J,{children:r??"No commits match."})}function _s({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(En,{kind:t.kind,bucket:t.bucket}):null,e("a",{children:t.subject}),t.at?e("span",{class:"muted small",children:[" \xB7 ",Se(t.at)]}):null,t.paths.length?e("div",{class:"muted small",children:t.paths.join(", ")}):null]})}function El({sha:t,path:n}){let s=G(()=>O("/api/history/diff",{sha:t,path:n}),[t,n]);if(s.error)return e(Z,{error:s.error});if(!s.data)return e(U,{});let a=s.data.text.split(`
15
+ `);return e(N,{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 Cl({sha:t,onSelect:n}){let s=G(()=>O("/api/history/commit",{sha:t}),[t]),[a,r]=_(!1);if(j(()=>r(!1),[t]),s.error)return e(Z,{error:s.error});if(!s.data)return e(U,{});if(s.data.error)return e(Z,{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(En,{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(za,{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()," (",re(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:()=>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:${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(N,{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:M("step","origin"),children:e(_s,{l:c,onSelect:n})}))})]}):null,i.blamedBy.length?e(N,{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:M("step","fix"),children:[e(_s,{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(N,{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(_s,{l:i.revertedBy,onSelect:n})})})]}):null]}):null,a!==!1?e("div",{class:"card",children:[e("div",{class:"row",style:{marginBottom:6},children:[e("h3",{style:{margin:0},children:["diff",a?` \xB7 ${a}`:""]}),a?e("button",{type:"button",class:"sm ghost",onClick:()=>r(null),children:"whole commit"}):null]}),e(El,{sha:o.sha,path:a??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:()=>H("explore",{file:c.path}),children:c.path}),e(We,{value:c.added+c.deleted,max:l,width:44}),e(ja,{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(kt,{value:c.fileRisk})," ",c.fileFixes," past fix",c.fileFixes===1?"":"es"]}):null,c.symbols.map(d=>e("a",{onClick:()=>H("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 Rl({ov:t,params:n,selected:s,onSelect:a}){let[r,i]=_(new Set),[o,l]=_(null),[c,d]=_(n.q??""),[u,m]=_(""),[g,f]=_(n.path??""),[k,h]=_(!1),[p,b]=_(!1),[y,v]=_(150),w=t.buckets.filter(A=>!r.has(A)),S=G(()=>O("/api/history/commits",{buckets:r.size?w.join(","):void 0,q:c.trim()||void 0,author:u||void 0,path:g.trim()||void 0,since:o?new Date(o[0]).toISOString():void 0,until:o?new Date(o[1]).toISOString():void 0,risky:k?1:void 0,head:p?1:void 0,limit:y}),[r,c,u,g,o,k,p,y]),T=G(()=>O("/api/history/graph",{limit:400}),[t.head]),x=V(()=>{if(!T.data||!S.data)return;let A=new Set(S.data.commits.map(C=>C.sha)),F=T.data.commits.slice(0,S.data.commits.length);if(!(F.length!==A.size||!F.every(C=>A.has(C.sha))))return vs(F)},[T.data,S.data]),$=V(()=>{let A={};for(let F of t.weeks)for(let C of t.buckets)A[C]=(A[C]??0)+F.byBucket[C];return A},[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(Da,{counts:$,hidden:r,onToggle:A=>i(F=>{let C=new Set(F);return C.has(A)?C.delete(A):C.add(A),C})}),e("span",{class:"spacer"}),e("span",{class:"muted small",children:o?e(N,{children:[Se(o[0])," \u2192 ",Se(o[1])," ",e("a",{onClick:()=>l(null),children:"clear"})]}):"drag across the chart to focus a period"})]}),e(Ia,{weeks:t.weeks,range:o,onRange:l,hidden:r})]}),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:A=>d(A.target.value),style:{width:240}}),e("select",{value:u,onChange:A=>m(A.target.value),children:[e("option",{value:"",children:"everyone"}),t.authors.map(A=>e("option",{value:A.name,children:[A.name," (",A.commits,")"]}))]}),e("input",{type:"text",placeholder:"path prefix",value:g,onInput:A=>f(A.target.value),style:{width:180}}),e("button",{type:"button",class:M("chip",k&&"on"),onClick:()=>h(!k),title:"only commits later fixed, reverted, large or touching hotspots",children:"\u26A0 hindsight flags"}),e("button",{type:"button",class:M("chip",p&&"on"),onClick:()=>b(!p),children:"HEAD only"}),e("span",{class:"spacer"}),e("span",{class:"muted small",children:S.data?`${S.data.total} commits`:""})]}),S.error?e(Z,{error:S.error}):S.data?e(N,{children:[e(wt,{commits:S.data.commits,selected:s,onSelect:a,lanes:x}),S.data.total>S.data.commits.length?e("div",{class:"row",style:{marginTop:8},children:e("button",{type:"button",class:"sm",onClick:()=>v(A=>A+200),children:["show more (",S.data.total-S.data.commits.length," left)"]})}):null]}):e(U,{})]})]}),e("div",{class:"stack",children:s?e(Cl,{sha:s,onSelect:a}):e(N,{children:[e("div",{class:"card",children:[e("h3",{children:"worth knowing"}),t.notable.length?e(wt,{commits:t.notable,selected:null,onSelect:a}):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(A=>e("tr",{class:"click",onClick:()=>m(A.name),children:[e("td",{children:A.name}),e("td",{class:"num",children:[e(We,{value:A.commits,max:t.authors[0]?.commits??1,width:70})," ",A.commits]}),e("td",{class:"muted small",children:[A.fixes," fixes \xB7 ",A.files," files"]}),e("td",{class:"muted small",children:re(A.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(A=>e("a",{onClick:()=>a(A.sha),title:Se(A.at),children:e("span",{class:"ref tag",children:A.name})}))})]}):null]})})]})}function Al({ov:t,params:n,onSelectCommit:s}){let[a,r]=_(n.branch??null),[i,o]=_(!1),[l,c]=_(!0),d=G(()=>O("/api/history/graph",{limit:120}),[t.head]),u=G(()=>a?O("/api/history/branch",{name:a}):Promise.resolve(null),[a]),m=V(()=>d.data?vs(d.data.commits):void 0,[d.data]),g=t.branches.filter(p=>(i||!p.remote)&&(l||!p.merged||p.isDefault)),f=Math.max(1,...g.map(p=>Math.max(p.ahead,p.behind))),[k,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(Z,{error:d.error}):d.data?e(wt,{commits:d.data.commits,selected:k,onSelect:p=>{h(p),s(p)},lanes:m}):e(U,{})]}),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 ",g.length]}),e("span",{class:"spacer"}),e("button",{type:"button",class:M("chip",i&&"on"),onClick:()=>o(!i),children:"remotes"}),e("button",{type:"button",class:M("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(p=>e("tr",{class:M("click",a===p.name&&"sel"),onClick:()=>r(p.name),children:[e("td",{class:"break",children:[e("span",{class:M("ref",p.remote&&"remote"),children:p.name}),p.current?e(P,{children:"current"}):null,p.isDefault?e(P,{children:"base"}):null,!p.merged&&!p.isDefault?e(P,{class:"risk-medium",children:"unmerged"}):null,p.lastSubject?e("div",{class:"muted small ellipsis",style:{maxWidth:260},children:p.lastSubject}):null]}),e("td",{children:p.isDefault?e("span",{class:"muted small",children:"\u2014"}):e("span",{class:"ab",title:`${p.ahead} ahead, ${p.behind} behind`,children:[e("span",{class:"ok",children:["+",p.ahead]}),e(We,{value:p.ahead,max:f,width:40}),e(We,{value:p.behind,max:f,width:40}),e("span",{class:"bad",children:["-",p.behind]})]})}),e("td",{class:"muted small nowrap",children:[re(p.at),p.lastAuthor?` \xB7 ${p.lastAuthor.split(" ")[0]}`:""]})]}))})]})]}),a?e("div",{class:"card",children:[e("h3",{children:a}),u.error?e(Z,{error:u.error}):u.data?u.data.error?e(Z,{error:u.data.error}):e(Ml,{d:u.data,onSelect:p=>{h(p),s(p)}}):e(U,{})]}):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 Ml({d:t,onSelect:n}){let s=t.branch,a=t.files.filter(r=>r.risk>=.3);return e(N,{children:[e("div",{class:"row small",style:{flexWrap:"wrap"},children:[e(P,{children:["tip ",s.sha.slice(0,7)]}),e(P,{children:re(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:()=>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(N,{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(wt,{commits:t.commits,selected:null,onSelect:n,empty:"Nothing unique: the branch is fully merged or behind."}),t.files.length?e(N,{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(kt,{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 Ll({params:t,onSelectCommit:n}){let[s,a]=_(""),[r,i]=_(t.file??null);j(()=>{t.file&&i(t.file)},[t.file]);let o=G(()=>O("/api/history/files",{path:s.trim()||void 0,limit:400}),[s]),{sorted:l,th:c}=Ve(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:m=>a(m.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(Pa,{files:o.data.files,selected:r,onSelect:i}):o.error?e(Z,{error:o.error}):e(U,{})]}),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(m=>e("tr",{class:M("click",r===m.path&&"sel"),onClick:()=>i(m.path),children:[e("td",{class:"break",children:m.path}),e("td",{class:"num",children:m.commits}),e("td",{class:"num",children:m.fixes}),e("td",{class:"num",children:m.bugOrigins}),e("td",{class:"num",children:m.commits90d}),e("td",{children:e(ws,{values:m.months})}),e("td",{class:"num",children:[e(kt,{value:m.risk})," ",m.risk.toFixed(2)]})]}))})]})})]}),e("div",{class:"stack",children:r?e(Fl,{path:r,selected:d,onSelect:m=>{u(m),n(m)}}):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 Fl({path:t,selected:n,onSelect:s}){let a=G(()=>O("/api/history/file",{path:t}),[t]);if(a.error)return e(Z,{error:a.error});if(!a.data)return e(U,{});let r=a.data,i=r.file;return e(N,{children:[e("div",{class:"card",children:[e("h3",{class:"break",children:t}),i?e(N,{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:[Se(i.firstAt)," \u2192 ",Se(i.lastAt)]}),i.renamedFrom?e(P,{children:["from ",i.renamedFrom]}):null]}),e("div",{class:"row small",style:{marginTop:6,alignItems:"center"},children:[e(kt,{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(ws,{values:i.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("div",{class:"card",children:[e("h3",{children:"changes that later needed fixing"}),e("div",{class:"chain",children:r.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(En,{kind:o.kind,bucket:o.bucket})," ",o.subject]}),e("span",{class:"muted small",children:[" \xB7 ",Se(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 ",r.commits.length]}),e(wt,{commits:r.commits,selected:n,onSelect:s})]})]})}function Il({ov:t,onSelectCommit:n}){let s=G(()=>O("/api/history/risk"),[t.head,t.stats.workingTree]),[a,r]=_(""),i=G(()=>a.trim()?O("/api/history/risk",{paths:a.trim()}):Promise.resolve(null),[a]),o=a.trim()?i.data:s.data,l=G(()=>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: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."}),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:()=>H("history",{tab:"files",file:c.path}),children:c.path})}),e("td",{class:"nowrap",children:c.file?e(N,{children:[e(kt,{value:c.file.risk})," ",c.file.risk.toFixed(2)]}):e("span",{class:"muted small",children:"new"})}),e("td",{class:"small",children:c.file?e(N,{children:[e("div",{class:"muted",children:[c.file.commits," commits \xB7 ",c.file.fixes," fixes \xB7 last"," ",re(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(J,{children:"Working tree is clean."}):s.error?e(Z,{error:s.error}):e(U,{})]}),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:()=>H("history",{tab:"files",file:c.path}),children:[e("td",{class:"break",children:c.path}),e("td",{class:"nowrap",children:[e(kt,{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(Dl,{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(wt,{commits:l.data,selected:null,onSelect:n,empty:"No traced fix origins yet."}):e(U,{})]})]})]})}function Dl({text:t}){return e("div",{class:"lesson",children:[e("span",{class:"i",children:"\u25C6"}),e("span",{children:t})]})}function Xa({params:t}){let[n,s]=_(t.tab||(t.file?"files":t.branch?"branches":"timeline")),[a,r]=_(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&&r(t.sha)},[t.sha]);let i=G(()=>O("/api/history"),[]),o=u=>{r(u),s("timeline")};if(i.error)return e("div",{class:"page",children:e(Z,{error:i.error})});if(!i.data)return e("div",{class:"page",children:e(U,{})});let l=i.data;if(!l.git)return e("div",{class:"page",children:e(J,{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(Ye,{v:c.commits,k:"commits",sub:`${c.onHead} on HEAD`}),e(Ye,{v:c.last30,k:"last 30 days",sub:d===null?`${c.prior30} in the 30 before`:`${d>=0?"+":""}${d}% vs prior 30`}),e(Ye,{v:c.fixes,k:"fixes",sub:`${Math.round(c.fixes/Math.max(1,c.commits-c.merges)*100)}%`}),e(Ye,{v:c.linksTraced,k:"traced fix origins",sub:c.tracePending?`${c.tracePending} pending`:`${c.fixesTraced} fixes`}),e(Ye,{v:c.branches,k:"branches",sub:c.unmerged?`${c.unmerged} unmerged`:"all merged"}),e(Ye,{v:c.authors,k:"authors",sub:`${c.files} files`}),e(Ye,{v:c.tags,k:"tags",sub:l.tags[0]?.name??""}),e(Ye,{v:c.workingTree,k:"working tree",sub:l.branch??"detached"})]}),e("div",{class:"row",style:{marginBottom:8},children:[e(Ce,{tabs:[["timeline","Timeline"],["branches","Branches"],["files","Files"],["graph","Graph"],["risk","Risk & lessons"]],value:n,onChange:u=>{s(u),H("history",{tab:u,sha:a??void 0})}}),e("span",{class:"spacer"}),e("span",{class:"muted small",children:[l.branch??"detached"," @ ",l.head.slice(0,7)," \xB7 built ",re(l.builtAt)," ",e("a",{onClick:()=>O("/api/history",{refresh:1}).then(()=>i.reload()),children:"rebuild"})]})]}),n==="timeline"&&e(Rl,{ov:l,params:t,selected:a,onSelect:r}),n==="branches"&&e(Al,{ov:l,params:t,onSelectCommit:o}),n==="files"&&e(Ll,{params:t,onSelectCommit:o}),n==="graph"&&e(Ua,{focus:t.focus}),n==="risk"&&e(Il,{ov:l,onSelectCommit:o})]})}var Pl=/^([a-z][a-z0-9+.-]*):(.*)$/i;function Ht(t){let n=t.trim();if(!n)return{kind:"text"};if(n.startsWith("#"))return{kind:"anchor",href:n};let s=Pl.exec(n);if(!s){let i=n.replace(/^\.\//,"").split("#")[0]??"";return i?{kind:"file",file:i}:{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 i=r.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 Cn(t){if(t.kind==="memory")return`#/memory?name=${encodeURIComponent(t.name)}`;if(t.kind==="file")return`#/explore?file=${encodeURIComponent(t.file)}`}function Es(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var dt=Es();function ti(t){dt=t}var ot={exec:()=>null};function xt(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 Y(t,n=""){let s=typeof t=="string"?t:t.source,a={replace:(r,i)=>{let o=typeof i=="string"?i:i.source;return o=o.replace(ve.caret,"$1"),s=s.replace(r,o),a},getRegex:()=>new RegExp(s,n)};return a}var Nl=((t="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+t)}catch{return!1}})(),ve={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:xt(t=>new RegExp(`^ {0,${t}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:xt(t=>new RegExp(`^ {0,${t}}((?:-[ ]*){3,}|(?:_[ ]*){3,}|(?:\\*[ ]*){3,})(?:\\n+|$)`)),fencesBeginRegex:xt(t=>new RegExp(`^ {0,${t}}(?:\`\`\`|~~~)`)),headingBeginRegex:xt(t=>new RegExp(`^ {0,${t}}#`)),htmlBeginRegex:xt(t=>new RegExp(`^ {0,${t}}(?:</?(?:${zt})(?: +|$|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`,"i")),blockquoteBeginRegex:xt(t=>new RegExp(`^ {0,${t}}>`))},Ol=/^(?:[ \t]*(?:\n|$))+/,Hl=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Bl=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,jt=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Ul=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Cs=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,ni=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |fences|blockquote|heading|hr|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,si=Y(ni).replace(/bull/g,Cs).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(),jl=Y(ni).replace(/bull/g,Cs).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(),Rs=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,zl=/^[^\n]+/,As=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Xl=Y(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",As).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Gl=Y(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,Cs).getRegex(),zt="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",Ms=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Wl=Y("^ {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",Ms).replace("tag",zt).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ri=t=>Y(Rs).replace("hr",jt).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",zt).getRegex(),Jl=ri(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),ql=ri(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),Kl=Y(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",ql).getRegex(),Ls={blockquote:Kl,code:Hl,def:Xl,fences:Bl,heading:Ul,hr:jt,html:Wl,lheading:si,list:Gl,newline:Ol,paragraph:Jl,table:ot,text:zl},Ga=Y("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",jt).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",zt).getRegex(),Vl={...Ls,lheading:jl,table:Ga,paragraph:Y(Rs).replace("hr",jt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Ga).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",zt).getRegex()},Zl={...Ls,html:Y(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Ms).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:ot,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Y(Rs).replace("hr",jt).replace("heading",` *#{1,6} *[^
16
+ ]`).replace("lheading",si).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Yl=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Ql=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,ai=/^( {2,}|\\)\n(?!\s*$)[ \t]*/,ec=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Ue=/[\p{P}\p{S}]/u,_t=/[\s\p{P}\p{S}]/u,Xt=/[^\s\p{P}\p{S}]/u,tc=Y(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,_t).getRegex(),nc=/[\p{Pi}\p{Ps}"']/u,ii=/(?!~)[\p{P}\p{S}]/u,sc=/(?!~)[\s\p{P}\p{S}]/u,rc=/(?:[^\s\p{P}\p{S}]|~)/u,ac=Y(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Nl?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),oi=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,ic=Y(oi,"u").replace(/punct/g,Ue).getRegex(),oc=Y(oi,"u").replace(/punct/g,ii).getRegex(),lc=/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,cc=Y(lc,"u").replace(/openQuote/g,nc).replace(/punct/g,Ue).getRegex(),li="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",dc=Y(li,"gu").replace(/notPunctSpace/g,Xt).replace(/punctSpace/g,_t).replace(/punct/g,Ue).getRegex(),uc=Y(li,"gu").replace(/notPunctSpace/g,rc).replace(/punctSpace/g,sc).replace(/punct/g,ii).getRegex(),pc="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)",mc=Y(pc,"gu").replace(/notPunctSpace/g,Xt).replace(/punctSpace/g,_t).replace(/punct/g,Ue).getRegex(),hc=Y("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Xt).replace(/punctSpace/g,_t).replace(/punct/g,Ue).getRegex(),gc="^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",fc=Y(gc,"gu").replace(/notPunctSpace/g,Xt).replace(/punctSpace/g,_t).replace(/punct/g,Ue).getRegex(),bc=Y(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Ue).getRegex(),yc="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",vc=Y(yc,"gu").replace(/notPunctSpace/g,Xt).replace(/punctSpace/g,_t).replace(/punct/g,Ue).getRegex(),kc=Y(/\\(punct)/,"gu").replace(/punct/g,Ue).getRegex(),wc=Y(/(`+)(?:[^`]|[^`][\s\S]*?[^`])\1(?!`)|`+|\\(punct)/,"gu").replace(/punct/g,Ue).getRegex(),xc=Y(/^<(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(),_c=Y(Ms).replace("(?:-->|$)","-->").getRegex(),Sc=Y("^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",_c).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),ci=/\[(?:\\[\s\S]|[^\[\]\\])*\]/,Mn=Y(/(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/).replace("brackets",ci).getRegex(),Tc=Y(/^!?\[(label)\]\([ \t\n]*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?[ \t\n]*\)/).replace("label",Mn).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),$c=Y(/^!?\[(label)\]\[(ref)\]/).replace("label",Mn).replace("ref",As).getRegex(),Ec=Y(/^!?\[(ref)\](?:\[\])?/).replace("ref",As).getRegex(),Wa=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\]){1,999}/,Cc=Y(/(?:[^\[\]\\`]*(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\]))){0,999}?[^\[\]\\`]*?/).replace("brackets",ci).getRegex(),Rc=Y("reflink|nolink(?!\\()","g").replace("reflink",Y(/^!?\[(label)\]\[(ref)\]/).replace("label",Cc).replace("ref",Wa).getRegex()).replace("nolink",Y(/^!?\[(ref)\](?:\[\])?/).replace("ref",Wa).getRegex()).getRegex(),Ja=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Ac=/[A-Za-z0-9._+-]+@[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/,Mc=Y(/(?:mailto:email|xmpp:email(?:\/[A-Za-z0-9@.]+)?)/).replace(/email/g,Ac).getRegex(),Fs={_backpedal:ot,anyPunctuation:kc,anyPunctuationOutsideCode:wc,autolink:xc,blockSkip:ac,br:ai,code:Ql,del:ot,delLDelim:ot,delRDelim:ot,emStrongLDelim:ic,emStrongRDelimAst:dc,emStrongRDelimUnd:hc,escape:Yl,link:Tc,nolink:Ec,punctuation:tc,reflink:$c,reflinkSearch:Rc,tag:Sc,text:ec,url:ot},Lc={...Fs,emStrongLDelim:cc,emStrongRDelimAst:mc,emStrongRDelimUnd:fc,link:Y(/^!?\[(label)\]\((.*?)\)/).replace("label",Mn).getRegex(),reflink:Y(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Mn).getRegex()},Ts={...Fs,emStrongRDelimAst:uc,emStrongLDelim:oc,delLDelim:bc,delRDelim:vc,url:Y(/^emailProtocol|^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("emailProtocol",Mc).replace("protocol",Ja).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:Y(/^(?:[^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",Ja).replace(/emailProtocol/g,/(?:mailto|xmpp):/).getRegex()},Fc={...Ts,br:Y(ai).replace("{2,}","*").getRegex(),text:Y(Ts.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Rn={normal:Ls,gfm:Vl,pedantic:Zl},Bt={normal:Fs,gfm:Ts,breaks:Fc,pedantic:Lc},Ic={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},qa=t=>Ic[t];function $e(t,n){if(n){if(ve.escapeTest.test(t))return t.replace(ve.escapeReplace,qa)}else if(ve.escapeTestNoEncode.test(t))return t.replace(ve.escapeReplaceNoEncode,qa);return t}function Dc(t){return ve.numericCharacterReference.test(t)?t.replace(ve.numericCharacterReferenceOrAmpersand,(n,s,a)=>{if(s===void 0&&a===void 0)return"&amp;";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?"&amp;":String.fromCodePoint(r)}):t}function Ka(t){try{t=encodeURI(t).replace(ve.percentDecode,"%")}catch{return null}return t}function Va(t,n){let s=t.replace(ve.findPipe,(i,o,l)=>{let c=!1,d=o;for(;--d>=0&&l[d]==="\\";)c=!c;return c?"|":" |"}),a=s.split(ve.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(ve.slashPipe,"|");return a}function Qe(t,n,s){let a=t.length;if(a===0)return"";let r=0;for(;r<a;){let i=t.charAt(a-r-1);if(i===n&&!s)r++;else if(i!==n&&s)r++;else break}return t.slice(0,a-r)}function Za(t){let n=t.split(`
17
+ `),s=n.length-1;for(;s>=0&&ve.blankLine.test(n[s]);)s--;return n.length-s<=2?t:n.slice(0,s+1).join(`
18
+ `)}function Ln(t){return t.trim().toLowerCase().toUpperCase().toLowerCase()}function Ya(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 Ss(t,n=0){let s=n,a="";for(let r of t)if(r===" "){let i=4-s%4;a+=" ".repeat(i),s+=i}else a+=r,s++;return a}function Qa(t,n,s,a,r){let i=n.href,o=n.title||null,l=t[1].replace(r.other.outputLinkReplace,"$1"),c=t[0].charAt(0)==="!",d=a.state.inLink,u=a.state.linkEmitted,m=a.state.inRawBlock;a.state.inLink=!0,a.state.linkEmitted=!1;let g=a.inlineTokens(l),f=a.state.linkEmitted;if(a.state.linkEmitted=u,a.state.inLink=d,!c){if(f){a.state.inRawBlock=m;return}a.state.linkEmitted=!0}return{type:c?"image":"link",raw:s,href:i,title:o,text:l,tokens:g}}function Pc(t,n,s){let a=t.match(s.other.indentCodeCompensation);if(a===null)return n;let r=a[1];return n.split(`
19
+ `).map(i=>{let o=i.match(s.other.beginningSpace);if(o===null)return i;let[l]=o;return i.slice(Math.min(l.length,r.length))}).join(`
20
+ `)}function ei(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 i=t.slice(s+r),o=a.inline.tag.exec(i)||a.inline.autolink.exec(i);if(o){if(o[0].length>n.length-r)return!0;r+=o[0].length-1}}return!1}var Fn=class{constructor(t){ae(this,"options");ae(this,"rules");ae(this,"lexer");this.options=t||dt}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]:Za(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=Pc(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=Qe(s,"#");(this.options.pedantic||!a||this.rules.other.endingSpaceTabChar.test(a))&&(s=a.trim())}return{type:"heading",raw:Qe(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:Qe(n[0],`
22
+ `)}}blockquote(t){let n=this.rules.block.blockquote.exec(t);if(n){let s=Qe(n[0],`
23
23
  `).split(`
24
- `),i="",r="",a=[];for(;s.length>0;){let o=!1,l=[],c;for(c=0;c<s.length;c++)if(this.rules.other.blockquoteStart.test(s[c]))l.push(s[c]),o=!0;else if(!o)l.push(s[c]);else break;s=s.slice(c);let d=l.join(`
25
- `),p=d.replace(this.rules.other.blockquoteSetextReplace,`
26
- $1`).replace(this.rules.other.blockquoteSetextReplace2,"");i=i?`${i}
24
+ `),a="",r="",i=[];for(;s.length>0;){let o=!1,l=[],c;for(c=0;c<s.length;c++)if(this.rules.other.blockquoteStart.test(s[c]))l.push(s[c]),o=!0;else if(!o)l.push(s[c]);else break;s=s.slice(c);let d=l.join(`
25
+ `),u=d.replace(this.rules.other.blockquoteSetextReplace,`
26
+ $1`).replace(this.rules.other.blockquoteSetextReplace2,"");a=a?`${a}
27
27
  ${d}`:d,r=r?`${r}
28
- ${p}`:p;let m=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(p,a,!0),this.lexer.state.top=m,s.length===0)break;let g=a.at(-1);if(g?.type==="code"||g?.type==="heading"||g?.type==="hr"||g?.type==="html")break;if(g?.type==="blockquote"){let f=g,x=s.join(`
28
+ ${u}`:u;let m=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(u,i,!0),this.lexer.state.top=m,s.length===0)break;let g=i.at(-1);if(g?.type==="code"||g?.type==="heading"||g?.type==="hr"||g?.type==="html")break;if(g?.type==="blockquote"){let f=g,k=s.join(`
29
29
  `),h=f.raw+`
30
- `+x.replace(this.rules.other.blockquoteSetextReplace2,""),u=this.blockquote(h);a[a.length-1]=u;let y=h.substring(u.raw.length).replace(/^\n/,""),b=y?y.split(`
31
- `).length:0,v=b?s.slice(0,-b):s;v.length>0&&(i=`${i}
30
+ `+k.replace(this.rules.other.blockquoteSetextReplace2,""),p=this.blockquote(h);i[i.length-1]=p;let b=h.substring(p.raw.length).replace(/^\n/,""),y=b?b.split(`
31
+ `).length:0,v=y?s.slice(0,-y):s;v.length>0&&(a=`${a}
32
32
  ${v.join(`
33
- `)}`),r=r.substring(0,r.length-f.text.length)+u.text;break}else if(g?.type==="list"){let f=g,x=f.raw+`
33
+ `)}`),r=r.substring(0,r.length-f.text.length)+p.text;break}else if(g?.type==="list"){let f=g,k=f.raw+`
34
34
  `+s.join(`
35
- `),h=this.list(x);a[a.length-1]=h,i=i.substring(0,i.length-g.raw.length)+h.raw,r=r.substring(0,r.length-f.raw.length)+h.raw,s=x.substring(a.at(-1).raw.length).split(`
36
- `);continue}}return{type:"blockquote",raw:i,tokens:a,text:r}}}list(t){let n=this.rules.block.list.exec(t);if(n){let s=t,i=()=>s.length-t.length,r=n[1].trim(),a=r.length>1,o={type:"list",raw:"",ordered:a,start:a?+r.slice(0,-1):"",loose:!1,items:[]};r=a?`\\d{1,9}\\${r.slice(-1)}`:`\\${r}`,this.options.pedantic&&(r=a?r:"[*+-]");let l=this.rules.other.listItemRegex(r),c=!1;for(;t;){let p=!1,m="";if(!(n=l.exec(t))||this.rules.block.hr.test(t))break;let g=i();t=t.substring(n[0].length);let f=n[2].split(`
37
- `,1)[0],x=n[1].length,h=this.options.pedantic?cs(f,x):f.replace(this.rules.other.leadingSpaceTab,k=>cs(k,x)),u=t.split(`
38
- `,1)[0],y=!h.trim(),b=0;if(this.options.pedantic?(b=2,m=h.trimStart()):y?b=x+1:(b=h.search(this.rules.other.nonSpaceChar),b=b>4?1:b,m=h.slice(b),b+=x),y&&this.rules.other.blankLine.test(u)&&(t=t.substring(u.length+1),p=!0),!p){let k=this.rules.other.nextBulletRegex(b),S=this.rules.other.hrRegex(b),E=this.rules.other.fencesBeginRegex(b),w=this.rules.other.headingBeginRegex(b),C=this.rules.other.htmlBeginRegex(b),R=this.rules.other.blockquoteBeginRegex(b);for(;t;){let M=t.split(`
39
- `,1)[0],$;if(u=M,this.options.pedantic?(u=u.replace(this.rules.other.listReplaceNesting," "),$=u):$=u.replace(this.rules.other.leadingSpaceTab,F=>cs(F)),E.test(u)||w.test(u)||C.test(u)||R.test(u)||k.test(u)||S.test(u))break;if($.search(this.rules.other.nonSpaceChar)>=b||!u.trim())m+=`
40
- `+$.slice(b);else{if(y||h.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||E.test(h)||w.test(h)||S.test(h))break;m+=`
41
- `+u}y=!u.trim(),t=t.substring(M.length+1),h=$.slice(b)}}let v=s.slice(g,i());o.loose||(c?o.loose=!0:this.rules.other.doubleBlankLine.test(v)&&(c=!0)),o.items.push({type:"list_item",raw:v,task:!!this.options.gfm&&this.rules.other.listIsTask.test(m),loose:!1,text:m,tokens:[]})}let d=o.items.at(-1);if(d)d.raw=d.raw.trimEnd(),d.text=d.text.trimEnd();else return;o.raw=s.slice(0,i()).trimEnd();for(let p of o.items)if(this.lexer.state.top=!1,p.tokens=this.lexer.blockTokens(p.text,[]),!o.loose){let m=p.tokens.filter(f=>f.type==="space"),g=m.length>0&&m.some(f=>this.rules.other.anyLine.test(f.raw));o.loose=g}for(let p of o.items){let m=p.tokens[0];if(p.task&&(m?.type==="text"||m?.type==="paragraph")){p.text=p.text.replace(this.rules.other.listReplaceTask,""),m.raw=m.raw.replace(this.rules.other.listReplaceTask,""),m.text=m.text.replace(this.rules.other.listReplaceTask,"");for(let f=this.lexer.inlineQueue.length-1;f>=0;f--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[f].src)){this.lexer.inlineQueue[f].src=this.lexer.inlineQueue[f].src.replace(this.rules.other.listReplaceTask,"");break}let g=this.rules.other.listTaskCheckbox.exec(p.raw);if(g){let f={type:"checkbox",raw:g[0]+" ",checked:g[0]!=="[ ]"};p.checked=f.checked,o.loose?p.tokens[0]&&["paragraph","text"].includes(p.tokens[0].type)&&"tokens"in p.tokens[0]&&p.tokens[0].tokens?(p.tokens[0].raw=f.raw+p.tokens[0].raw,p.tokens[0].text=f.raw+p.tokens[0].text,p.tokens[0].tokens.unshift(f)):p.tokens.unshift({type:"paragraph",raw:f.raw,text:f.raw,tokens:[f]}):p.tokens.unshift(f)}}else p.task&&(p.task=!1)}if(o.loose)for(let p of o.items){p.loose=!0;for(let m of p.tokens)m.type==="text"&&(m.type="paragraph")}return o}}html(t){let n=this.rules.block.html.exec(t);if(n){let s=Ri(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])&&Mi(n[2],"()")!==-1)return;let s=vn(n[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=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:ze(n[0],`
42
- `),href:i,title:r}}}table(t){let n=this.rules.block.table.exec(t);if(!n||!this.rules.other.tableDelimiter.test(n[2]))return;let s=Ai(n[1]),i=n[2].replace(this.rules.other.tableAlignChars,"").split("|"),r=n[3]?.trim()?n[3].replace(this.rules.other.tableRowBlankLine,"").split(`
43
- `):[],a={type:"table",raw:ze(n[0],`
44
- `),header:[],align:[],rows:[]};if(s.length===i.length){for(let o of i)this.rules.other.tableAlignRight.test(o)?a.align.push("right"):this.rules.other.tableAlignCenter.test(o)?a.align.push("center"):this.rules.other.tableAlignLeft.test(o)?a.align.push("left"):a.align.push(null);for(let o=0;o<s.length;o++)a.header.push({text:s[o],tokens:this.lexer.inline(s[o]),header:!0,align:a.align[o]});for(let o of r)a.rows.push(Ai(o,a.header.length).map((l,c)=>({text:l,tokens:this.lexer.inline(l),header:!1,align:a.align[c]})));return a}}lheading(t){let n=this.rules.block.lheading.exec(t);if(n){let s=n[1].trim();return{type:"heading",raw:ze(n[0],`
35
+ `),h=this.list(k);i[i.length-1]=h,a=a.substring(0,a.length-g.raw.length)+h.raw,r=r.substring(0,r.length-f.raw.length)+h.raw,s=k.substring(i.at(-1).raw.length).split(`
36
+ `);continue}}return{type:"blockquote",raw:a,tokens:i,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(),i=r.length>1,o={type:"list",raw:"",ordered:i,start:i?+r.slice(0,-1):"",loose:!1,items:[]};r=i?`\\d{1,9}\\${r.slice(-1)}`:`\\${r}`,this.options.pedantic&&(r=i?r:"[*+-]");let l=this.rules.other.listItemRegex(r),c=!1;for(;t;){let u=!1,m="";if(!(n=l.exec(t))||this.rules.block.hr.test(t))break;let g=a();t=t.substring(n[0].length);let f=n[2].split(`
37
+ `,1)[0],k=n[1].length,h=this.options.pedantic?Ss(f,k):f.replace(this.rules.other.leadingSpaceTab,w=>Ss(w,k)),p=t.split(`
38
+ `,1)[0],b=!h.trim(),y=0;if(this.options.pedantic?(y=2,m=h.trimStart()):b?y=k+1:(y=h.search(this.rules.other.nonSpaceChar),y=y>4?1:y,m=h.slice(y),y+=k),b&&this.rules.other.blankLine.test(p)&&(t=t.substring(p.length+1),u=!0),!u){let w=this.rules.other.nextBulletRegex(y),S=this.rules.other.hrRegex(y),T=this.rules.other.fencesBeginRegex(y),x=this.rules.other.headingBeginRegex(y),$=this.rules.other.htmlBeginRegex(y),A=this.rules.other.blockquoteBeginRegex(y);for(;t;){let F=t.split(`
39
+ `,1)[0],C;if(p=F,this.options.pedantic?(p=p.replace(this.rules.other.listReplaceNesting," "),C=p):C=p.replace(this.rules.other.leadingSpaceTab,L=>Ss(L)),T.test(p)||x.test(p)||$.test(p)||A.test(p)||w.test(p)||S.test(p))break;if(C.search(this.rules.other.nonSpaceChar)>=y||!p.trim())m+=`
40
+ `+C.slice(y);else{if(b||h.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||T.test(h)||x.test(h)||S.test(h))break;m+=`
41
+ `+p}b=!p.trim(),t=t.substring(F.length+1),h=C.slice(y)}}let v=s.slice(g,a());o.loose||(c?o.loose=!0:this.rules.other.doubleBlankLine.test(v)&&(c=!0)),o.items.push({type:"list_item",raw:v,task:!!this.options.gfm&&this.rules.other.listIsTask.test(m),loose:!1,text:m,tokens:[]})}let d=o.items.at(-1);if(d)d.raw=d.raw.trimEnd(),d.text=d.text.trimEnd();else return;o.raw=s.slice(0,a()).trimEnd();for(let u of o.items)if(this.lexer.state.top=!1,u.tokens=this.lexer.blockTokens(u.text,[]),!o.loose){let m=u.tokens.filter(f=>f.type==="space"),g=m.length>0&&m.some(f=>this.rules.other.anyLine.test(f.raw));o.loose=g}for(let u of o.items){let m=u.tokens[0];if(u.task&&(m?.type==="text"||m?.type==="paragraph")){u.text=u.text.replace(this.rules.other.listReplaceTask,""),m.raw=m.raw.replace(this.rules.other.listReplaceTask,""),m.text=m.text.replace(this.rules.other.listReplaceTask,"");for(let f=this.lexer.inlineQueue.length-1;f>=0;f--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[f].src)){this.lexer.inlineQueue[f].src=this.lexer.inlineQueue[f].src.replace(this.rules.other.listReplaceTask,"");break}let g=this.rules.other.listTaskCheckbox.exec(u.raw);if(g){let f={type:"checkbox",raw:g[0]+" ",checked:g[0]!=="[ ]"};u.checked=f.checked,o.loose?u.tokens[0]&&["paragraph","text"].includes(u.tokens[0].type)&&"tokens"in u.tokens[0]&&u.tokens[0].tokens?(u.tokens[0].raw=f.raw+u.tokens[0].raw,u.tokens[0].text=f.raw+u.tokens[0].text,u.tokens[0].tokens.unshift(f)):u.tokens.unshift({type:"paragraph",raw:f.raw,text:f.raw,tokens:[f]}):u.tokens.unshift(f)}}else u.task&&(u.task=!1)}if(o.loose)for(let u of o.items){u.loose=!0;for(let m of u.tokens)m.type==="text"&&(m.type="paragraph")}return o}}html(t){let n=this.rules.block.html.exec(t);if(n){let s=Za(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])&&Ya(n[2],"()")!==-1)return;let s=Ln(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:Qe(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=Va(n[1]),a=n[2].replace(this.rules.other.tableAlignChars,"").split("|"),r=n[3]?.trim()?n[3].replace(this.rules.other.tableRowBlankLine,"").split(`
43
+ `):[],i={type:"table",raw:Qe(n[0],`
44
+ `),header:[],align:[],rows:[]};if(s.length===a.length){for(let o of a)this.rules.other.tableAlignRight.test(o)?i.align.push("right"):this.rules.other.tableAlignCenter.test(o)?i.align.push("center"):this.rules.other.tableAlignLeft.test(o)?i.align.push("left"):i.align.push(null);for(let o=0;o<s.length;o++)i.header.push({text:s[o],tokens:this.lexer.inline(s[o]),header:!0,align:i.align[o]});for(let o of r)i.rows.push(Va(o,i.header.length).map((l,c)=>({text:l,tokens:this.lexer.inline(l),header:!1,align:i.align[c]})));return i}}lheading(t){let n=this.rules.block.lheading.exec(t);if(n){let s=n[1].trim();return{type:"heading",raw:Qe(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&&Li(t,n[1],s,this.rules))return;let i=n[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(i)){if(!this.rules.other.endAngleBracket.test(i))return;let o=ze(i.slice(0,-1),"\\");if((i.length-o.length)%2===0)return}else{let o=Mi(n[2],"()");if(o===-2)return;if(o>-1){let l=(n[0].indexOf("!")===0?5:4)+n[1].length+o;n[2]=n[2].substring(0,o),n[0]=n[0].substring(0,l).trim(),n[3]=""}}let r=n[2],a="";if(this.options.pedantic){let o=this.rules.other.pedanticHrefTitle.exec(r);o&&(r=o[1],a=o[3])}else a=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(i)?r=r.slice(1):r=r.slice(1,-1)),Fi(n,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:a&&a.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 i=s[0].charAt(0)==="!"?2:1;if(!this.options.pedantic&&Li(t,s[1],i,this.rules))return;let r=(s[2]||s[1]).replace(this.rules.other.multipleSpaceGlobal," "),a=n[vn(r)];if(!a){let o=s[0].charAt(0);return{type:"text",raw:o,text:o}}return Fi(s,a,s[0],this.lexer,this.rules)}}emStrong(t,n,s=""){let i=this.rules.inline.emStrongLDelim.exec(t);if(!(!i||!i[1]&&!i[2]&&!i[3]&&!i[4]||i[4]&&s.match(this.rules.other.unicodeAlphaNumeric))&&(!(i[1]||i[3])||!s||this.rules.inline.punctuation.exec(s))){let r=[...i[0]].length-1,a,o,l=r,c=0,d=i[0][0],p=s===d,m=d==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(m.lastIndex=0,n=n.slice(-1*t.length+r);(i=m.exec(n))!==null;){if(a=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!a)continue;if(o=[...a].length,i[3]||i[4]){l+=o;continue}else if(i[5]||i[6]){if(r%3&&!((r+o)%3)){c+=o;continue}if(p)break}if(l-=o,l>0)continue;o=Math.min(o,o+l+c);let g=[...i[0]][0].length,f=t.slice(0,r+i.index+g+o);if(Math.min(r,o)%2){let h=f.slice(1,-1);return{type:"em",raw:f,text:h,tokens:this.lexer.inlineTokens(h)}}let x=f.slice(2,-2);return{type:"strong",raw:f,text:x,tokens:this.lexer.inlineTokens(x)}}}}codespan(t){let n=this.rules.inline.code.exec(t);if(n){let s=n[2].replace(this.rules.other.newLineCharGlobal," "),i=this.rules.other.nonSpaceChar.test(s),r=this.rules.other.startingSpaceChar.test(s)&&this.rules.other.endingSpaceChar.test(s);return i&&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 i=this.rules.inline.delLDelim.exec(t);if(i&&(!i[1]||!s||this.rules.inline.punctuation.exec(s))){let r=[...i[0]].length-1,a,o,l=r,c=this.rules.inline.delRDelim;for(c.lastIndex=0,n=n.slice(-1*t.length+r);(i=c.exec(n))!==null;){if(a=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!a||(o=[...a].length,o!==r))continue;if(i[3]||i[4]){l+=o;continue}if(l-=o,l>0)continue;o=Math.min(o,o+l);let d=[...i[0]][0].length,p=t.slice(0,r+i.index+d+o),m=p.slice(r,-r);return{type:"del",raw:p,text:m,tokens:this.lexer.inlineTokens(m)}}}}autolink(t){let n=this.rules.inline.autolink.exec(t);if(n){let s,i;return n[2]==="@"?(s=n[1],i="mailto:"+s):(s=n[1],i=s),{type:"link",raw:n[0],text:s,href:i,autolink:!0,tokens:[{type:"text",raw:s,text:s}]}}}url(t){let n;if(n=this.rules.inline.url.exec(t)){let s,i;if(n[2]==="@")s=n[0],i="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."?i="http://"+n[0]:i=n[0]}return{type:"link",raw:n[0],text:s,href:i,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]:Jl(n[0]),escaped:s}}}},wn,ji,Ye,Ce=(Ye=class{constructor(n){Es(this,wn);ee(this,"tokens");ee(this,"options");ee(this,"state");ee(this,"inlineQueue");ee(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=n||et,this.options.tokenizer=this.options.tokenizer||new kn,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:he,block:fn.normal,inline:Ct.normal};this.options.pedantic?(s.block=fn.pedantic,s.inline=Ct.pedantic):this.options.gfm&&(s.block=fn.gfm,this.options.breaks?s.inline=Ct.breaks:s.inline=Ct.gfm),this.tokenizer.rules=s}static get rules(){return{block:fn,inline:Ct}}static lex(n,s){return new Ye(s).lex(n)}static lexInline(n,s){return new Ye(s).inlineTokens(n)}lex(n){n=n.replace(he.carriageReturn,`
47
- `),this.blockTokens(n,this.tokens);for(let s=0;s<this.inlineQueue.length;s++){let i=this.inlineQueue[s];this.inlineTokens(i.src,i.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(n,s=[],i=!1){this.tokenizer.lexer=this,this.options.pedantic&&(n=n.replace(he.tabCharGlobal," ").replace(he.spaceLine,""));let r=1/0;for(;n;){if(n.length<r)r=n.length;else{this.infiniteLoopError(n.charCodeAt(0));break}let a;if(this.options.extensions?.block?.some(l=>(a=l.call({lexer:this},n,s))?(n=n.substring(a.raw.length),s.push(a),!0):!1))continue;if(a=this.tokenizer.space(n)){n=n.substring(a.raw.length);let l=s.at(-1);a.raw.length===1&&l!==void 0?l.raw+=`
48
- `:s.push(a);continue}if(a=this.tokenizer.code(n)){n=n.substring(a.raw.length);let l=s.at(-1);l?.type==="paragraph"||l?.type==="text"?(l.raw+=(l.raw.endsWith(`
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&&ei(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 o=Qe(a.slice(0,-1),"\\");if((a.length-o.length)%2===0)return}else{let o=Ya(n[2],"()");if(o===-2)return;if(o>-1){let l=(n[0].indexOf("!")===0?5:4)+n[1].length+o;n[2]=n[2].substring(0,o),n[0]=n[0].substring(0,l).trim(),n[3]=""}}let r=n[2],i="";if(this.options.pedantic){let o=this.rules.other.pedanticHrefTitle.exec(r);o&&(r=o[1],i=o[3])}else i=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)),Qa(n,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.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&&ei(t,s[1],a,this.rules))return;let r=(s[2]||s[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=n[Ln(r)];if(!i){let o=s[0].charAt(0);return{type:"text",raw:o,text:o}}return Qa(s,i,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,i,o,l=r,c=0,d=a[0][0],u=s===d,m=d==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(m.lastIndex=0,n=n.slice(-1*t.length+r);(a=m.exec(n))!==null;){if(i=a[1]||a[2]||a[3]||a[4]||a[5]||a[6],!i)continue;if(o=[...i].length,a[3]||a[4]){l+=o;continue}else if(a[5]||a[6]){if(r%3&&!((r+o)%3)){c+=o;continue}if(u)break}if(l-=o,l>0)continue;o=Math.min(o,o+l+c);let g=[...a[0]][0].length,f=t.slice(0,r+a.index+g+o);if(Math.min(r,o)%2){let h=f.slice(1,-1);return{type:"em",raw:f,text:h,tokens:this.lexer.inlineTokens(h)}}let k=f.slice(2,-2);return{type:"strong",raw:f,text:k,tokens:this.lexer.inlineTokens(k)}}}}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,i,o,l=r,c=this.rules.inline.delRDelim;for(c.lastIndex=0,n=n.slice(-1*t.length+r);(a=c.exec(n))!==null;){if(i=a[1]||a[2]||a[3]||a[4]||a[5]||a[6],!i||(o=[...i].length,o!==r))continue;if(a[3]||a[4]){l+=o;continue}if(l-=o,l>0)continue;o=Math.min(o,o+l);let d=[...a[0]][0].length,u=t.slice(0,r+a.index+d+o),m=u.slice(r,-r);return{type:"del",raw:u,text:m,tokens:this.lexer.inlineTokens(m)}}}}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]:Dc(n[0]),escaped:s}}}},Dn,di,lt,De=(lt=class{constructor(n){qs(this,Dn);ae(this,"tokens");ae(this,"options");ae(this,"state");ae(this,"inlineQueue");ae(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=n||dt,this.options.tokenizer=this.options.tokenizer||new Fn,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:ve,block:Rn.normal,inline:Bt.normal};this.options.pedantic?(s.block=Rn.pedantic,s.inline=Bt.pedantic):this.options.gfm&&(s.block=Rn.gfm,this.options.breaks?s.inline=Bt.breaks:s.inline=Bt.gfm),this.tokenizer.rules=s}static get rules(){return{block:Rn,inline:Bt}}static lex(n,s){return new lt(s).lex(n)}static lexInline(n,s){return new lt(s).inlineTokens(n)}lex(n){n=n.replace(ve.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(ve.tabCharGlobal," ").replace(ve.spaceLine,""));let r=1/0;for(;n;){if(n.length<r)r=n.length;else{this.infiniteLoopError(n.charCodeAt(0));break}let i;if(this.options.extensions?.block?.some(l=>(i=l.call({lexer:this},n,s))?(n=n.substring(i.raw.length),s.push(i),!0):!1))continue;if(i=this.tokenizer.space(n)){n=n.substring(i.raw.length);let l=s.at(-1);i.raw.length===1&&l!==void 0?l.raw+=`
48
+ `:s.push(i);continue}if(i=this.tokenizer.code(n)){n=n.substring(i.raw.length);let l=s.at(-1);l?.type==="paragraph"||l?.type==="text"?(l.raw+=(l.raw.endsWith(`
49
49
  `)?"":`
50
- `)+a.raw,l.text+=`
51
- `+a.text,this.inlineQueue.at(-1).src=l.text):s.push(a);continue}if(a=this.tokenizer.fences(n)){n=n.substring(a.raw.length),s.push(a);continue}if(a=this.tokenizer.heading(n)){n=n.substring(a.raw.length),s.push(a);continue}if(a=this.tokenizer.hr(n)){n=n.substring(a.raw.length),s.push(a);continue}if(a=this.tokenizer.blockquote(n)){n=n.substring(a.raw.length),s.push(a);continue}if(a=this.tokenizer.list(n)){n=n.substring(a.raw.length),s.push(a);continue}if(a=this.tokenizer.html(n)){n=n.substring(a.raw.length),s.push(a);continue}if(a=this.tokenizer.def(n)){n=n.substring(a.raw.length);let l=s.at(-1);l?.type==="paragraph"||l?.type==="text"?(l.raw+=(l.raw.endsWith(`
50
+ `)+i.raw,l.text+=`
51
+ `+i.text,this.inlineQueue.at(-1).src=l.text):s.push(i);continue}if(i=this.tokenizer.fences(n)){n=n.substring(i.raw.length),s.push(i);continue}if(i=this.tokenizer.heading(n)){n=n.substring(i.raw.length),s.push(i);continue}if(i=this.tokenizer.hr(n)){n=n.substring(i.raw.length),s.push(i);continue}if(i=this.tokenizer.blockquote(n)){n=n.substring(i.raw.length),s.push(i);continue}if(i=this.tokenizer.list(n)){n=n.substring(i.raw.length),s.push(i);continue}if(i=this.tokenizer.html(n)){n=n.substring(i.raw.length),s.push(i);continue}if(i=this.tokenizer.def(n)){n=n.substring(i.raw.length);let l=s.at(-1);l?.type==="paragraph"||l?.type==="text"?(l.raw+=(l.raw.endsWith(`
52
52
  `)?"":`
53
- `)+a.raw,l.text+=`
54
- `+a.raw,this.inlineQueue.at(-1).src=l.text):this.tokens.links[a.tag]||(this.tokens.links[a.tag]={href:a.href,title:a.title},s.push(a));continue}if(a=this.tokenizer.table(n)){n=n.substring(a.raw.length),s.push(a);continue}if(a=this.tokenizer.lheading(n)){n=n.substring(a.raw.length),s.push(a);continue}let o=n;if(this.options.extensions?.startBlock){let l=1/0,c=n.slice(1),d;this.options.extensions.startBlock.forEach(p=>{d=p.call({lexer:this},c),typeof d=="number"&&d>=0&&(l=Math.min(l,d))}),l<1/0&&l>=0&&(o=n.substring(0,l+1))}if(this.state.top&&(a=this.tokenizer.paragraph(o))){let l=s.at(-1);i&&l?.type==="paragraph"?(l.raw+=(l.raw.endsWith(`
53
+ `)+i.raw,l.text+=`
54
+ `+i.raw,this.inlineQueue.at(-1).src=l.text):this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title},s.push(i));continue}if(i=this.tokenizer.table(n)){n=n.substring(i.raw.length),s.push(i);continue}if(i=this.tokenizer.lheading(n)){n=n.substring(i.raw.length),s.push(i);continue}let o=n;if(this.options.extensions?.startBlock){let l=1/0,c=n.slice(1),d;this.options.extensions.startBlock.forEach(u=>{d=u.call({lexer:this},c),typeof d=="number"&&d>=0&&(l=Math.min(l,d))}),l<1/0&&l>=0&&(o=n.substring(0,l+1))}if(this.state.top&&(i=this.tokenizer.paragraph(o))){let l=s.at(-1);a&&l?.type==="paragraph"?(l.raw+=(l.raw.endsWith(`
55
55
  `)?"":`
56
- `)+a.raw,l.text+=`
57
- `+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=l.text):s.push(a),i=o.length!==n.length,n=n.substring(a.raw.length);continue}if(a=this.tokenizer.text(n)){n=n.substring(a.raw.length);let l=s.at(-1);l?.type==="text"?(l.raw+=(l.raw.endsWith(`
56
+ `)+i.raw,l.text+=`
57
+ `+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=l.text):s.push(i),a=o.length!==n.length,n=n.substring(i.raw.length);continue}if(i=this.tokenizer.text(n)){n=n.substring(i.raw.length);let l=s.at(-1);l?.type==="text"?(l.raw+=(l.raw.endsWith(`
58
58
  `)?"":`
59
- `)+a.raw,l.text+=`
60
- `+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=l.text):s.push(a);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 i of n.matchAll(this.tokenizer.rules.inline.blockSkip))if(s.test(i[0])&&n.charAt(i.index-1)!=="!")return!0;for(let i of n.matchAll(this.tokenizer.rules.inline.reflinkSearch)){let r=i[0],a=r.lastIndexOf("[");if(!(r.charAt(0)==="!"||!Object.hasOwn(this.tokens.links,vn(r.slice(a+1,-1))))&&!(a>1&&this.linkInText(r.slice(1,a-1))))return!0}return!1}inlineTokens(n,s=[]){this.tokenizer.lexer=this;let i=this.state.linkParenPossible;this.state.linkParenPossible=i&&n.includes(")");try{return Cs(this,wn,ji).call(this,n,s)}finally{this.state.linkParenPossible=i}}infiniteLoopError(n){let s="Infinite loop on byte: "+n;if(this.options.silent)console.error(s);else throw new Error(s)}},wn=new WeakSet,ji=function(n,s){let i=n;if(this.tokens.links&&n.includes("[")){let l=this.tokenizer.rules.inline.reflinkSearch,c=d=>{let p=d.lastIndexOf("[");if(!Object.hasOwn(this.tokens.links,vn(d.slice(p+1,-1))))return d;if(p>1&&d.charAt(0)!=="!"){let m=d.slice(1,p-1);if(this.linkInText(m))return"["+m.replace(l,c)+"]["+"a".repeat(d.length-p-2)+"]"}return"["+"a".repeat(d.length-2)+"]"};i=i.replace(l,c)}i=i.replace(this.tokenizer.rules.inline.anyPunctuationOutsideCode,(l,c,d)=>d?"+".repeat(l.length):c?c+l.slice(c.length,-c.length).replace(/`/g,"+")+c:l),i=i.replace(this.tokenizer.rules.inline.blockSkip,(l,c,d)=>{let p=d?d.length:0;return l.slice(0,p)+"["+"a".repeat(l.length-p-2)+"]"}),i=this.options.hooks?.emStrongMask?.call({lexer:this},i)??i;let r=!1,a="",o=1/0;for(;n;){if(n.length<o)o=n.length;else{this.infiniteLoopError(n.charCodeAt(0));break}r||(a=""),r=!1;let l;if(this.options.extensions?.inline?.some(d=>(l=d.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 d=s.at(-1);l.type==="text"&&d?.type==="text"?(d.raw+=l.raw,d.text+=l.text):s.push(l);continue}if(l=this.tokenizer.emStrong(n,i,a)){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,i,a)){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 d=1/0,p=n.slice(1),m;this.options.extensions.startInline.forEach(g=>{m=g.call({lexer:this},p),typeof m=="number"&&m>=0&&(d=Math.min(d,m))}),d<1/0&&d>=0&&(c=n.substring(0,d+1))}if(l=this.tokenizer.inlineText(c)){n=n.substring(l.raw.length),l.raw.slice(-1)!=="_"&&(a=l.raw.slice(-1)),r=!0;let d=s.at(-1);d?.type==="text"?(d.raw+=l.raw,d.text+=l.text):s.push(l);continue}if(n){this.infiniteLoopError(n.charCodeAt(0));break}}return s},Ye),xn=class{constructor(t){ee(this,"options");ee(this,"parser");this.options=t||et}space(t){return""}code({text:t,lang:n,escaped:s}){let i=(n||"").match(he.notSpaceStart)?.[0],r=t?t.replace(he.endingNewline,"")+`
61
- `:"";return i?'<pre><code class="language-'+ke(i)+'">'+(s?r:ke(r,!0))+`</code></pre>
62
- `:"<pre><code>"+(s?r:ke(r,!0))+`</code></pre>
59
+ `)+i.raw,l.text+=`
60
+ `+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=l.text):s.push(i);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],i=r.lastIndexOf("[");if(!(r.charAt(0)==="!"||!Object.hasOwn(this.tokens.links,Ln(r.slice(i+1,-1))))&&!(i>1&&this.linkInText(r.slice(1,i-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 Ks(this,Dn,di).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)}},Dn=new WeakSet,di=function(n,s){let a=n;if(this.tokens.links&&n.includes("[")){let l=this.tokenizer.rules.inline.reflinkSearch,c=d=>{let u=d.lastIndexOf("[");if(!Object.hasOwn(this.tokens.links,Ln(d.slice(u+1,-1))))return d;if(u>1&&d.charAt(0)!=="!"){let m=d.slice(1,u-1);if(this.linkInText(m))return"["+m.replace(l,c)+"]["+"a".repeat(d.length-u-2)+"]"}return"["+"a".repeat(d.length-2)+"]"};a=a.replace(l,c)}a=a.replace(this.tokenizer.rules.inline.anyPunctuationOutsideCode,(l,c,d)=>d?"+".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,d)=>{let u=d?d.length:0;return l.slice(0,u)+"["+"a".repeat(l.length-u-2)+"]"}),a=this.options.hooks?.emStrongMask?.call({lexer:this},a)??a;let r=!1,i="",o=1/0;for(;n;){if(n.length<o)o=n.length;else{this.infiniteLoopError(n.charCodeAt(0));break}r||(i=""),r=!1;let l;if(this.options.extensions?.inline?.some(d=>(l=d.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 d=s.at(-1);l.type==="text"&&d?.type==="text"?(d.raw+=l.raw,d.text+=l.text):s.push(l);continue}if(l=this.tokenizer.emStrong(n,a,i)){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,i)){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 d=1/0,u=n.slice(1),m;this.options.extensions.startInline.forEach(g=>{m=g.call({lexer:this},u),typeof m=="number"&&m>=0&&(d=Math.min(d,m))}),d<1/0&&d>=0&&(c=n.substring(0,d+1))}if(l=this.tokenizer.inlineText(c)){n=n.substring(l.raw.length),l.raw.slice(-1)!=="_"&&(i=l.raw.slice(-1)),r=!0;let d=s.at(-1);d?.type==="text"?(d.raw+=l.raw,d.text+=l.text):s.push(l);continue}if(n){this.infiniteLoopError(n.charCodeAt(0));break}}return s},lt),In=class{constructor(t){ae(this,"options");ae(this,"parser");this.options=t||dt}space(t){return""}code({text:t,lang:n,escaped:s}){let a=(n||"").match(ve.notSpaceStart)?.[0],r=t?t.replace(ve.endingNewline,"")+`
61
+ `:"";return a?'<pre><code class="language-'+$e(a)+'">'+(s?r:$e(r,!0))+`</code></pre>
62
+ `:"<pre><code>"+(s?r:$e(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,i="";for(let o=0;o<t.items.length;o++){let l=t.items[o];i+=this.listitem(l)}let r=n?"ol":"ul",a=n&&s!==1?' start="'+s+'"':"";return"<"+r+a+`>
68
- `+i+"</"+r+`>
67
+ `}list(t){let n=t.ordered,s=t.start,a="";for(let o=0;o<t.items.length;o++){let l=t.items[o];a+=this.listitem(l)}let r=n?"ol":"ul",i=n&&s!==1?' start="'+s+'"':"";return"<"+r+i+`>
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 r=0;r<t.header.length;r++)s+=this.tablecell(t.header[r]);n+=this.tablerow({text:s});let i="";for(let r=0;r<t.rows.length;r++){let a=t.rows[r];s="";for(let o=0;o<a.length;o++)s+=this.tablecell(a[o]);i+=this.tablerow({text:s})}return i&&(i=`<tbody>${i}</tbody>`),`<table>
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 i=t.rows[r];s="";for(let o=0;o<i.length;o++)s+=this.tablecell(i[o]);a+=this.tablerow({text:s})}return a&&(a=`<tbody>${a}</tbody>`),`<table>
72
72
  <thead>
73
73
  `+n+`</thead>
74
- `+i+`</table>
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>${ke(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:i,autolink:r}){let a=r?ke(s,!0):this.parser.parseInline(i),o=$i(t);if(o===null)return a;t=ke(o,r);let l='<a href="'+t+'"';return n&&(l+=' title="'+ke(n)+'"'),l+=">"+a+"</a>",l}image({href:t,title:n,text:s,tokens:i}){i&&(s=this.parser.parseInline(i,this.parser.textRenderer));let r=$i(t);if(r===null)return ke(s);t=r;let a=`<img src="${ke(t)}" alt="${ke(s)}"`;return n&&(a+=` title="${ke(n)}"`),a+=">",a}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:ke(t.text)}},vs=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}},$e=class us{constructor(n){ee(this,"options");ee(this,"renderer");ee(this,"textRenderer");this.options=n||et,this.options.renderer=this.options.renderer||new xn,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new vs}static parse(n,s){return new us(s).parse(n)}static parseInline(n,s){return new us(s).parseInline(n)}parse(n){this.renderer.parser=this;let s="";for(let i=0;i<n.length;i++){let r=n[i];if(this.options.extensions?.renderers?.[r.type]){let o=r,l=this.options.extensions.renderers[o.type].call({parser:this},o);if(l!==!1||!["space","hr","heading","code","table","blockquote","list","checkbox","html","def","paragraph","text"].includes(o.type)){s+=l||"";continue}}let a=r;switch(a.type){case"space":{s+=this.renderer.space(a);break}case"hr":{s+=this.renderer.hr(a);break}case"heading":{s+=this.renderer.heading(a);break}case"code":{s+=this.renderer.code(a);break}case"table":{s+=this.renderer.table(a);break}case"blockquote":{s+=this.renderer.blockquote(a);break}case"list":{s+=this.renderer.list(a);break}case"checkbox":{s+=this.renderer.checkbox(a);break}case"html":{s+=this.renderer.html(a);break}case"def":{s+=this.renderer.def(a);break}case"paragraph":{s+=this.renderer.paragraph(a);break}case"text":{s+=this.renderer.text(a);break}default:{let o='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return s}parseInline(n,s=this.renderer){this.renderer.parser=this;let i="";for(let r=0;r<n.length;r++){let a=n[r];if(this.options.extensions?.renderers?.[a.type]){let l=this.options.extensions.renderers[a.type].call({parser:this},a);if(l!==!1||!["escape","html","link","image","checkbox","strong","em","codespan","br","del","text"].includes(a.type)){i+=l||"";continue}}let o=a;switch(o.type){case"escape":{i+=s.text(o);break}case"html":{i+=s.html(o);break}case"link":{i+=s.link(o);break}case"image":{i+=s.image(o);break}case"checkbox":{i+=s.checkbox(o);break}case"strong":{i+=s.strong(o);break}case"em":{i+=s.em(o);break}case"codespan":{i+=s.codespan(o);break}case"br":{i+=s.br(o);break}case"del":{i+=s.del(o);break}case"text":{i+=s.text(o);break}default:{let l='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return i}},bn,$t=(bn=class{constructor(t){ee(this,"options");ee(this,"block");this.options=t||et}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(t=this.block){return t?Ce.lex:Ce.lexInline}provideParser(t=this.block){return t?$e.parse:$e.parseInline}},ee(bn,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),ee(bn,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),bn);function Ve(t,n){if(Array.isArray(n))for(let s=0;s<n.length;s++)t.push(n[s]);else t.push(n)}var Vl=class{constructor(...t){ee(this,"defaults",ps());ee(this,"options",this.setOptions);ee(this,"parse",this.parseMarkdown(!0));ee(this,"parseInline",this.parseMarkdown(!1));ee(this,"Parser",$e);ee(this,"Renderer",xn);ee(this,"TextRenderer",vs);ee(this,"Lexer",Ce);ee(this,"Tokenizer",kn);ee(this,"Hooks",$t);this.use(...t)}walkTokens(t,n){let s=[];for(let i of t)switch(Ve(s,n.call(this,i)),i.type){case"table":{let r=i;for(let a of r.header)Ve(s,this.walkTokens(a.tokens,n));for(let a of r.rows)for(let o of a)Ve(s,this.walkTokens(o.tokens,n));break}case"list":{let r=i;Ve(s,this.walkTokens(r.items,n));break}default:{let r=i;this.defaults.extensions?.childTokens?.[r.type]?this.defaults.extensions.childTokens[r.type].forEach(a=>{let o=r[a].flat(1/0);Ve(s,this.walkTokens(o,n))}):r.tokens&&Ve(s,this.walkTokens(r.tokens,n))}}return s}use(...t){let n=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(s=>{let i={...s};if(i.async=this.defaults.async||i.async||!1,s.extensions&&(s.extensions.forEach(r=>{if(!r.name)throw new Error("extension name required");if("renderer"in r){let a=n.renderers[r.name];a?n.renderers[r.name]=function(...o){let l=r.renderer.apply(this,o);return l===!1&&(l=a.apply(this,o)),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 a=n[r.level];a?a.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)}),i.extensions=n),s.renderer){let r=this.defaults.renderer||new xn(this.defaults);for(let a in s.renderer){if(!(a in r))throw new Error(`renderer '${a}' does not exist`);if(["options","parser"].includes(a))continue;let o=a,l=s.renderer[o],c=r[o];r[o]=(...d)=>{let p=l.apply(r,d);return p===!1&&(p=c.apply(r,d)),p||""}}i.renderer=r}if(s.tokenizer){let r=this.defaults.tokenizer||new kn(this.defaults);for(let a in s.tokenizer){if(!(a in r))throw new Error(`tokenizer '${a}' does not exist`);if(["options","rules","lexer"].includes(a))continue;let o=a,l=s.tokenizer[o],c=r[o];r[o]=(...d)=>{let p=l.apply(r,d);return p===!1&&(p=c.apply(r,d)),p}}i.tokenizer=r}if(s.hooks){let r=this.defaults.hooks||new $t;for(let a in s.hooks){if(!(a in r))throw new Error(`hook '${a}' does not exist`);if(["options","block"].includes(a))continue;let o=a,l=s.hooks[o],c=r[o];$t.passThroughHooks.has(a)?r[o]=d=>{if(this.defaults.async&&$t.passThroughHooksRespectAsync.has(a))return(async()=>{let m=await l.call(r,d);return c.call(r,m)})();let p=l.call(r,d);return c.call(r,p)}:r[o]=(...d)=>{if(this.defaults.async)return(async()=>{let m=await l.apply(r,d);return m===!1&&(m=await c.apply(r,d)),m})();let p=l.apply(r,d);return p===!1&&(p=c.apply(r,d)),p}}i.hooks=r}if(s.walkTokens){let r=this.defaults.walkTokens,a=s.walkTokens;i.walkTokens=function(o){let l=[];return l.push(a.call(this,o)),r&&Ve(l,r.call(this,o)),l}}this.defaults={...this.defaults,...i}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,n){return Ce.lex(t,n??this.defaults)}parser(t,n){return $e.parse(t,n??this.defaults)}parseMarkdown(t){return(n,s)=>{let i={...s},r={...this.defaults,...i},a=this.onError(!!r.silent,!!r.async);if(this.defaults.async===!0&&i.async===!1)return a(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 a(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return a(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 o=r.hooks?await r.hooks.preprocess(n):n,l=await(r.hooks?await r.hooks.provideLexer(t):t?Ce.lex:Ce.lexInline)(o,r),c=r.hooks?await r.hooks.processAllTokens(l):l;r.walkTokens&&await Promise.all(this.walkTokens(c,r.walkTokens));let d=await(r.hooks?await r.hooks.provideParser(t):t?$e.parse:$e.parseInline)(c,r);return r.hooks?await r.hooks.postprocess(d):d})().catch(a);try{r.hooks&&(n=r.hooks.preprocess(n));let o=(r.hooks?r.hooks.provideLexer(t):t?Ce.lex:Ce.lexInline)(n,r);r.hooks&&(o=r.hooks.processAllTokens(o)),r.walkTokens&&this.walkTokens(o,r.walkTokens);let l=(r.hooks?r.hooks.provideParser(t):t?$e.parse:$e.parseInline)(o,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(o){return a(o)}}}onError(t,n){return s=>{if(s.message+=`
79
- Please report this to https://github.com/markedjs/marked.`,t){let i="<p>An error occurred:</p><pre>"+ke(s.message+"",!0)+"</pre>";return n?Promise.resolve(i):i}if(n)return Promise.reject(s);throw s}}},Qe=new Vl;function se(t,n){return Qe.parse(t,n)}se.options=se.setOptions=function(t){return Qe.setOptions(t),se.defaults=Qe.defaults,Ii(se.defaults),se};se.getDefaults=ps;se.defaults=et;function Zl(...t){return Qe.use(...t),se.defaults=Qe.defaults,Ii(se.defaults),se}se.use=Zl;se.walkTokens=function(t,n){return Qe.walkTokens(t,n)};se.parseInline=Qe.parseInline;se.Parser=$e;se.parser=$e.parse;se.Renderer=xn;se.TextRenderer=vs;se.Lexer=Ce;se.lexer=Ce.lex;se.Tokenizer=kn;se.Hooks=$t;se.parse=se;var _m=se.options,Sm=se.setOptions,Tm=se.walkTokens,Em=se.parseInline;var Cm=$e.parse,Gi=Ce.lex;var Yl={ts:"typescript",js:"javascript",mjs:"javascript",cjs:"javascript",py:"python",sh:"bash",shell:"bash",zsh:"bash",console:"bash",jsonc:"json",md:"markdown"},Xi={amp:"&",lt:"<",gt:">",quot:'"',apos:"'","#39":"'"};function Ql(t){return t.replace(/&(#x[0-9a-f]+|#\d+|[a-z]+);/gi,(n,s)=>s in Xi?Xi[s]:s.startsWith("#x")?String.fromCodePoint(Number.parseInt(s.slice(2),16)):s.startsWith("#")?String.fromCodePoint(Number.parseInt(s.slice(1),10)):n)}function Ae({tokens:t}){return e(N,{children:(t??[]).map((n,s)=>Wi(n,s))})}function ec({t}){let n=Et(t.href),s=e(Ae,{tokens:t.tokens}),i=t.title??void 0,r=gn(n);return r?e("a",{class:"ref",href:r,title:i??t.href,children:s}):n.kind==="external"?e("a",{href:n.href,title:i,target:"_blank",rel:"noopener noreferrer",children:s}):n.kind==="anchor"?e("a",{href:n.href,title:i,children:s}):e("span",{title:t.href,children:s})}function Wi(t,n){switch(t.type){case"text":{let s=t;return s.tokens?e(Ae,{tokens:s.tokens},n):s.escaped?Ql(s.text):s.text}case"escape":return t.text;case"strong":return e("strong",{children:e(Ae,{tokens:t.tokens})},n);case"em":return e("em",{children:e(Ae,{tokens:t.tokens})},n);case"del":return e("del",{children:e(Ae,{tokens:t.tokens})},n);case"codespan":return e("code",{children:t.text},n);case"br":return e("br",{},n);case"link":return e(ec,{t},n);case"image":{let s=t,i=Et(s.href);return i.kind==="external"?e("img",{src:i.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(Ae,{tokens:s.tokens},n):s.raw}}}function tc({t}){let n=(t.lang??"").trim().split(/\s+/)[0]?.toLowerCase()??"",s=Yl[n]??n,i=K(()=>dn(t.text,s).join(`
80
- `),[t.text,s]);return e("pre",{class:"code","data-lang":n||void 0,children:e("code",{dangerouslySetInnerHTML:{__html:i}})})}function ks({tokens:t}){return e(N,{children:(t??[]).map((n,s)=>nc(n,s))})}function nc(t,n){switch(t.type){case"space":case"def":return null;case"heading":{let s=t;return Xt(`h${Math.min(Math.max(s.depth,1),6)}`,{key:n},e(Ae,{tokens:s.tokens}))}case"paragraph":return e("p",{children:e(Ae,{tokens:t.tokens})},n);case"text":{let s=t;return s.tokens?e(Ae,{tokens:s.tokens},n):s.text}case"checkbox":return Wi(t,n);case"code":return e(tc,{t},n);case"blockquote":return e("blockquote",{children:e(ks,{tokens:t.tokens})},n);case"list":{let s=t,i=s.items.map((r,a)=>e("li",{class:r.task?"task":void 0,children:e(ks,{tokens:r.tokens})},a));return s.ordered?e("ol",{start:s.start===""?void 0:s.start,children:i},n):e("ul",{children:i},n)}case"table":{let s=t,i=(r,a)=>Xt(r.header?"th":"td",{key:a,style:r.align?{textAlign:r.align}:void 0},e(Ae,{tokens:r.tokens}));return e("table",{children:[e("thead",{children:e("tr",{children:s.header.map(i)})}),e("tbody",{children:s.rows.map((r,a)=>e("tr",{children:r.map(i)},a))})]},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(Ae,{tokens:s.tokens}):s.raw},n)}}}function _n({source:t,class:n}){let s=K(()=>Gi(t,{gfm:!0}),[t]);return e("div",{class:n?`md ${n}`:"md",children:e(ks,{tokens:s})})}var sc={decision:"#7c3aed",constraint:"#dc2626",fact:"#2563eb",preference:"#0d9488",todo:"#d97706",note:"#6b7280",onboarding:"#16a34a"};function xs({m:t}){return e(N,{children:[e("span",{class:"tag kind",style:{color:sc[t.kind]??"#6b7280"},children:t.kind}),t.status&&t.status!=="accepted"?e("span",{class:`tag s-${t.status}`,children:t.status}):null]})}function qi({value:t}){let n=gn(Et(t));return n?e("a",{class:"ref",href:n,title:t,children:t}):e("span",{class:"tag",title:t,children:t})}function rc(t){return t.split(`
81
- `).find(n=>n.trim())?.replace(/^#+\s*/,"").slice(0,120)??""}var Ji={kind:"fact",tags:"",related:"",body:"",name:"",status:"",supersedes:""};function Ki(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 ic({name:t,kinds:n,statuses:s,onSaved:i,onDeleted:r}){let a=G(()=>t?H("/api/memories",{name:t}):Promise.resolve(void 0),[t]),[o,l]=_(!t),[c,d]=_(!1),[p,m]=_(Ji),[g,f]=_(!1);j(()=>{l(!t),d(!1)},[t]),j(()=>{let w=a.data;t&&w&&m(Ki(w)),t||m(Ji)},[t,a.data]);let x=w=>C=>m({...p,[w]:C.target.value}),h=()=>{l(!1),d(!1)},u=async()=>{if(!p.body.trim())return Y("body required",!0);f(!0);try{let w={kind:p.kind,content:p.body,tags:p.tags,related:p.related,status:p.status||void 0,supersedes:p.supersedes||void 0},C=t?await ve("/api/memories",w,"PUT",{name:t}):await ve("/api/memories",{...w,name:p.name.trim()||void 0});Y(`${t?"saved":"created"} ${C.name}${C.superseded?` \xB7 ${C.superseded} marked superseded`:""}`),t===C.name&&a.reload(),i(C.name),h()}catch(w){Y(w.message,!0)}finally{f(!1)}},y=()=>{a.data&&m(Ki(a.data)),h()},b=async()=>{if(!(!t||!confirm(`Delete memory "${t}" and its file?`)))try{await Kt("/api/memories",{name:t}),Y(`deleted ${t}`),r()}catch(w){Y(w.message,!0)}},v=async()=>{if(!t)return;let w=prompt("New name (topic/slug):",t);if(!(!w||w===t))try{let C=await ve("/api/memories",{to:w},"PATCH",{name:t});Y(`renamed \u2192 ${C.name}${C.refsUpdated?` (${C.refsUpdated} references updated)`:""}`),i(C.name)}catch(C){Y(C.message,!0)}},k=w=>{(w.metaKey||w.ctrlKey)&&w.key.toLowerCase()==="s"?(w.preventDefault(),u()):w.key==="Escape"&&t&&(w.preventDefault(),y())};if(t&&a.error)return e(Z,{error:a.error});if(t&&!a.data)return e(B,{});let S=a.data,E=p.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:v,children:"rename"}),e("button",{type:"button",class:"sm",title:"this memory in the knowledge graph",onClick:()=>O("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:[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(xs,{m:S}),S.tags.map(w=>e("span",{class:"tag",children:["#",w]})),S.related.map(w=>e(qi,{value:w})),S.supersedes?e("span",{class:"muted small",children:["supersedes ",e(qi,{value:`mem:${S.supersedes}`})]}):null]}),e(_n,{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(N,{children:[e("span",{class:"muted small",children:"editing"}),e("button",{type:"button",class:"sm",onClick:v,children:"rename"}),e("button",{type:"button",class:"sm danger",onClick:b,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:p.name,onInput:x("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:p.kind,onChange:x("kind"),children:n.map(w=>e("option",{value:w,children:w}))})]}),E&&e("div",{class:"field",children:[e("label",{children:"status"}),e("select",{value:p.status,onChange:x("status"),children:[e("option",{value:"",children:"accepted (default)"}),s.map(w=>e("option",{value:w,children:w}))]})]}),e("div",{class:"field",children:[e("label",{children:"tags (comma separated)"}),e("input",{type:"text",value:p.tags,onInput:x("tags")})]}),e("div",{class:"field",children:[e("label",{children:"related (file:path, sym:path#Name, mem:name)"}),e("input",{type:"text",value:p.related,onInput:x("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:p.supersedes,onInput:x("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(_n,{class:"preview",source:p.body.trim()?p.body:"_Nothing to preview yet._"}):e("textarea",{value:p.body,onInput:x("body"),onKeyDown:k,spellcheck:!1})]}),e("div",{class:"row",children:[e("button",{type:"button",class:"primary",disabled:g,onClick:u,children:g?e(B,{}):t?"Save":"Create"}),t?e("button",{type:"button",disabled:g,onClick:y,children:"Cancel"}):null,e("span",{class:"muted small",children:["\u2318S / Ctrl+S saves",t?", Esc cancels":""]})]})]})}function ac({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,i])=>e("div",{class:"card",children:[e("h3",{children:s}),i.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(xs,{m:r}),e("span",{class:"muted small",children:fe(r.updated_at)}),e("span",{class:"spacer"}),e("a",{class:"small",onClick:()=>O("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(_n,{source:r.content})})]}))]}))}):e(X,{children:'No accepted decisions yet. Record one with kind "decision", or ask Claude to em_remember it.'})}function Vi({params:t}){let[n,s]=_(t.name?.startsWith("decision/")?"decision":t.tab??"all"),[i,r]=_(t.name??null),[a,o]=_(!1),[l,c]=_(""),[d,p]=_(""),m=G(()=>H("/api/memories"),[]);j(()=>{t.name&&(r(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(()=>{m.data?.gitignored&&Y(`.gitignore keeps ${m.data.dir} out of git; memories stay local`,!0),m.data?.skipped.length&&Y(`skipped invalid memory files: ${m.data.skipped.join(", ")}`,!0)},[m.data]);let g=K(()=>{let h=m.data?.memories??[],u=l.trim().toLowerCase();return h.filter(y=>(n==="all"||n==="record"||y.kind===n)&&(!d||(y.status??"accepted")===d)&&(!u||y.name.includes(u)||y.tags.some(b=>b.includes(u))||y.content.toLowerCase().includes(u)))},[m.data,n,l,d]);if(m.error)return e("div",{class:"page",children:e(Z,{error:m.error})});let f=m.data,x=[["all","All"],...(f?.kinds??[]).map(h=>[h,h]),["record","Decision record"],["graph","Graph"]];return e("div",{class:"page",children:[e(we,{tabs:x,value:n,onChange:h=>{s(h),h!=="decision"&&p(""),(h==="graph"||t.tab)&&O("memory",{tab:h})}}),n==="graph"?e(ln,{scope:"memory",focus:t.focus}):n==="record"?e(ac,{rows:(f?.memories??[]).filter(h=>h.kind==="decision"&&(h.status??"accepted")==="accepted")}):e(N,{children:[e("div",{class:"row",style:{marginBottom:12},children:[e("button",{type:"button",class:"primary",onClick:()=>{o(!0),r(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=>p(h.target.value),children:[e("option",{value:"",children:"any status"}),(f?.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 ve("/api/actions",{action:"reconcile"});Y(h.output,!h.ok),m.reload()},children:"\u21BB Reconcile"}),e("span",{class:"muted small",children:[g.length," of ",f?.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:f?g.length?g.map(h=>e("div",{class:L("item",i===h.name&&"sel"),onClick:()=>{r(h.name),o(!1)},children:[e("div",{class:"n",children:h.name}),e("div",{class:"p",children:[e(xs,{m:h}),e("span",{class:"muted",children:[fe(h.updated_at)," \xB7 ",J(h.size??0),"B"]})]}),e("div",{class:"p",children:rc(h.content)})]})):e(X,{children:"no memories match"}):e(X,{children:e(B,{})})})}),e("div",{class:"card",children:a||i?e(ic,{name:a?null:i,kinds:f?.kinds??[],statuses:f?.statuses??[],onSaved:h=>{o(!1),r(h),m.reload()},onDeleted:()=>{r(null),m.reload()}}):e(X,{children:"Select a memory, or create a new one."})})]})]}),e("div",{style:{display:"none"},children:e(I,{children:"x"})})]})}function Zi({rows:t}){let n=[...t].sort((s,i)=>i.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 i=Math.ceil(s.raw_chars/4),r=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:J(i)}),e("td",{class:"num",children:J(r)}),e("td",{class:"num",children:J(Math.max(0,i-r))})]})}):e("tr",{children:e("td",{class:"muted",colSpan:5,children:"no calls yet"})})})]})}function Yi(){let t=G(()=>H("/api/stats"),[]);if(t.error)return e("div",{class:"page",children:e(Z,{error:t.error})});let n=t.data;if(!n)return e("div",{class:"page",children:e(B,{})});let s=[["session saved",J(n.session.savedTokens),`${Te(n.session.efficiency)} efficient \xB7 ${n.session.calls} calls`],["project saved",J(n.projectTotals.savedTokens),`${Te(n.projectTotals.efficiency)} efficient \xB7 ${n.projectTotals.calls} calls`],["lifetime saved",J(n.lifetime.savedTokens),`${Te(n.lifetime.efficiency)} efficient \xB7 ${n.lifetime.calls} calls`],["documents",String(n.index.documents),e(N,{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`]],i=Math.max(1,...n.daily.map(a=>a.saved_chars)),r=["overview","structure","commands","conventions"].filter(a=>!n.onboarding.includes(a));return e("div",{class:"page",children:[e("div",{class:"grid",children:s.map(([a,o,l])=>e("div",{class:"card",children:[e("h3",{children:a}),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(a=>e("div",{title:`${a.day}: ${J(Math.ceil(a.saved_chars/4))} tokens, ${a.calls} calls`,style:{height:`${Math.max(2,100*a.saved_chars/i)}%`}})):e("div",{class:"muted",children:"no data yet"})})]}),e("div",{class:"card",children:[e("h3",{children:"system"}),e(Oe,{rows:[["project",n.project],["database",n.dbPath],["routing",n.routing],["embeddings",n.index.embeddings],["memories dir",n.memoriesDir],["onboarding",r.length?e("span",{class:"warn",children:["missing: ",r.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(Zi,{rows:n.session.tools})]}),e("div",{class:"card",children:[e("h3",{children:"lifetime \xB7 by tool"}),e(Zi,{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(([,a])=>a).map(([a,o])=>e("tr",{children:[e("td",{children:a}),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((a,o)=>o[1]-a[1]).map(([a,o])=>e("tr",{children:[e("td",{children:a}),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:()=>O("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(a=>e("tr",{children:[e("td",{class:"muted",children:[ne(a.started_at)," ",a.current?e(I,{children:"current"}):null]}),e("td",{children:e("code",{children:a.id.slice(0,8)})}),e("td",{class:"muted",children:(a.last_prompt??"").slice(0,90)}),e("td",{class:"num",children:a.calls}),e("td",{class:"num",children:J(a.savedTokens)})]}))})]})]})]})]})}function Qi(){let t=G(()=>H("/api/sessions",{limit:60}),[]),[n,s]=_(null),[i,r]=_(""),[a,o]=_(100);j(()=>{!n&&t.data?.[0]&&s(t.data[0].id)},[t.data]);let l=G(()=>n?H("/api/events",{session:n,category:i||void 0,limit:a}):Promise.resolve([]),[n,i,a]),c=[...new Set((l.data??[]).map(d=>d.category))].sort();return t.error?e("div",{class:"page",children:e(Z,{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:L("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(I,{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:ne(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 ",J(d.savedTokens)," saved \xB7 ",Te(d.efficiency),d.source?` \xB7 ${d.source}`:""]})]})):e(X,{children:"no sessions yet"}):e(X,{children:e(B,{})})})}),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:i,onChange:d=>r(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(a),onChange:d=>o(Number(d.target.value)),children:[100,300,1e3].map(d=>e("option",{value:String(d),children:d}))})]})]}),l.error?e(Z,{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:sr(d.ts)}),e("td",{class:"nowrap",children:[e(I,{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"})})})]})]})]})})}function oc(){let[t,n]=_(!1),s=G(()=>H("/api/doctor",{fix:t?1:void 0}),[t]),i=(s.data??[]).filter(r=>!r.ok).length;return e(N,{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(B,{}):s.data?i?e("span",{class:"bad",children:[i," problem",i>1?"s":""]}):e("span",{class:"ok",children:"all checks pass"}):""})]}),s.error?e(Z,{error:s.error}):e("div",{class:"card flush",children:e("table",{children:e("tbody",{children:(s.data??[]).map(r=>e("tr",{children:[e("td",{class:L(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})]}))})})})]})}function lc({onChanged:t}){let[n,s]=_([]),[i,r]=_(null),[a,o]=_("all"),[l,c]=_(!1),[d,p]=_(""),[m,g]=_(""),[f,x]=_("index"),[h,u]=_(""),y=G(()=>H("/api/stats"),[]),b=async(k,S)=>{r(k);let E=new Date().toLocaleTimeString();s(w=>[...w,`[${E}] ${k} \u2026`]);try{let w=await ve("/api/actions",S);s(C=>[...C,`${w.ok?"\u2713":"\u2717"} ${k} (${w.ms} ms)
82
- ${w.output}`]),w.ok?Y(`${k} done`):Y(w.output.split(`
83
- `)[0]??"failed",!0),t()}catch(w){s(C=>[...C,`\u2717 ${k} failed: ${w.message}`]),Y(w.message,!0)}finally{r(null)}},v=({label:k,body:S,cls:E})=>e("button",{type:"button",class:E??"primary",disabled:!!i,onClick:()=>b(k,S),children:i===k?e(B,{}):k});return e(N,{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:a,onChange:k=>o(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(v,{label:`reindex ${a}`,body:{action:"reindex",scope:a,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:k=>p(k.target.value)}),e("input",{type:"text",placeholder:"globs, comma separated",style:{maxWidth:200},value:m,onInput:k=>g(k.target.value)}),e("button",{type:"button",class:"primary",disabled:!!i||!d.trim(),onClick:()=>b("index",{action:"index",path:d,glob:m}),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."," ",y.data?e("span",{class:"muted",children:["(",y.data.index.embeddings,")"]}):null]}),e("div",{class:"row",children:e(v,{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:y.data?.memoriesDir??".eminiar/memories"}),"."]}),e("div",{class:"row",children:e(v,{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:f,onChange:k=>x(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:h,onInput:k=>u(k.target.value)}),e("button",{type:"button",class:"danger",disabled:!!i||h.trim()!=="purge",onClick:()=>{u(""),b(`purge ${f}`,{action:"purge",scope:f,confirm:!0})},children:"Purge"}),e(v,{label:"empty fetch cache",body:{action:"purge-fetch-cache"},cls:""})]})]}),e("div",{class:"card",children:[e("h3",{children:"server"}),y.data?e(Oe,{rows:[["project",y.data.project],["database",y.data.dbPath],["routing",y.data.routing]]}):e(B,{})]})]}),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>${$e(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 i=r?$e(s,!0):this.parser.parseInline(a),o=Ka(t);if(o===null)return i;t=$e(o,r);let l='<a href="'+t+'"';return n&&(l+=' title="'+$e(n)+'"'),l+=">"+i+"</a>",l}image({href:t,title:n,text:s,tokens:a}){a&&(s=this.parser.parseInline(a,this.parser.textRenderer));let r=Ka(t);if(r===null)return $e(s);t=r;let i=`<img src="${$e(t)}" alt="${$e(s)}"`;return n&&(i+=` title="${$e(n)}"`),i+=">",i}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:$e(t.text)}},Is=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}},Pe=class $s{constructor(n){ae(this,"options");ae(this,"renderer");ae(this,"textRenderer");this.options=n||dt,this.options.renderer=this.options.renderer||new In,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Is}static parse(n,s){return new $s(s).parse(n)}static parseInline(n,s){return new $s(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 o=r,l=this.options.extensions.renderers[o.type].call({parser:this},o);if(l!==!1||!["space","hr","heading","code","table","blockquote","list","checkbox","html","def","paragraph","text"].includes(o.type)){s+=l||"";continue}}let i=r;switch(i.type){case"space":{s+=this.renderer.space(i);break}case"hr":{s+=this.renderer.hr(i);break}case"heading":{s+=this.renderer.heading(i);break}case"code":{s+=this.renderer.code(i);break}case"table":{s+=this.renderer.table(i);break}case"blockquote":{s+=this.renderer.blockquote(i);break}case"list":{s+=this.renderer.list(i);break}case"checkbox":{s+=this.renderer.checkbox(i);break}case"html":{s+=this.renderer.html(i);break}case"def":{s+=this.renderer.def(i);break}case"paragraph":{s+=this.renderer.paragraph(i);break}case"text":{s+=this.renderer.text(i);break}default:{let o='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return s}parseInline(n,s=this.renderer){this.renderer.parser=this;let a="";for(let r=0;r<n.length;r++){let i=n[r];if(this.options.extensions?.renderers?.[i.type]){let l=this.options.extensions.renderers[i.type].call({parser:this},i);if(l!==!1||!["escape","html","link","image","checkbox","strong","em","codespan","br","del","text"].includes(i.type)){a+=l||"";continue}}let o=i;switch(o.type){case"escape":{a+=s.text(o);break}case"html":{a+=s.html(o);break}case"link":{a+=s.link(o);break}case"image":{a+=s.image(o);break}case"checkbox":{a+=s.checkbox(o);break}case"strong":{a+=s.strong(o);break}case"em":{a+=s.em(o);break}case"codespan":{a+=s.codespan(o);break}case"br":{a+=s.br(o);break}case"del":{a+=s.del(o);break}case"text":{a+=s.text(o);break}default:{let l='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return a}},An,Ut=(An=class{constructor(t){ae(this,"options");ae(this,"block");this.options=t||dt}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(t=this.block){return t?De.lex:De.lexInline}provideParser(t=this.block){return t?Pe.parse:Pe.parseInline}},ae(An,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),ae(An,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),An);function it(t,n){if(Array.isArray(n))for(let s=0;s<n.length;s++)t.push(n[s]);else t.push(n)}var Nc=class{constructor(...t){ae(this,"defaults",Es());ae(this,"options",this.setOptions);ae(this,"parse",this.parseMarkdown(!0));ae(this,"parseInline",this.parseMarkdown(!1));ae(this,"Parser",Pe);ae(this,"Renderer",In);ae(this,"TextRenderer",Is);ae(this,"Lexer",De);ae(this,"Tokenizer",Fn);ae(this,"Hooks",Ut);this.use(...t)}walkTokens(t,n){let s=[];for(let a of t)switch(it(s,n.call(this,a)),a.type){case"table":{let r=a;for(let i of r.header)it(s,this.walkTokens(i.tokens,n));for(let i of r.rows)for(let o of i)it(s,this.walkTokens(o.tokens,n));break}case"list":{let r=a;it(s,this.walkTokens(r.items,n));break}default:{let r=a;this.defaults.extensions?.childTokens?.[r.type]?this.defaults.extensions.childTokens[r.type].forEach(i=>{let o=r[i].flat(1/0);it(s,this.walkTokens(o,n))}):r.tokens&&it(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 i=n.renderers[r.name];i?n.renderers[r.name]=function(...o){let l=r.renderer.apply(this,o);return l===!1&&(l=i.apply(this,o)),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 i=n[r.level];i?i.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 In(this.defaults);for(let i in s.renderer){if(!(i in r))throw new Error(`renderer '${i}' does not exist`);if(["options","parser"].includes(i))continue;let o=i,l=s.renderer[o],c=r[o];r[o]=(...d)=>{let u=l.apply(r,d);return u===!1&&(u=c.apply(r,d)),u||""}}a.renderer=r}if(s.tokenizer){let r=this.defaults.tokenizer||new Fn(this.defaults);for(let i in s.tokenizer){if(!(i in r))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;let o=i,l=s.tokenizer[o],c=r[o];r[o]=(...d)=>{let u=l.apply(r,d);return u===!1&&(u=c.apply(r,d)),u}}a.tokenizer=r}if(s.hooks){let r=this.defaults.hooks||new Ut;for(let i in s.hooks){if(!(i in r))throw new Error(`hook '${i}' does not exist`);if(["options","block"].includes(i))continue;let o=i,l=s.hooks[o],c=r[o];Ut.passThroughHooks.has(i)?r[o]=d=>{if(this.defaults.async&&Ut.passThroughHooksRespectAsync.has(i))return(async()=>{let m=await l.call(r,d);return c.call(r,m)})();let u=l.call(r,d);return c.call(r,u)}:r[o]=(...d)=>{if(this.defaults.async)return(async()=>{let m=await l.apply(r,d);return m===!1&&(m=await c.apply(r,d)),m})();let u=l.apply(r,d);return u===!1&&(u=c.apply(r,d)),u}}a.hooks=r}if(s.walkTokens){let r=this.defaults.walkTokens,i=s.walkTokens;a.walkTokens=function(o){let l=[];return l.push(i.call(this,o)),r&&it(l,r.call(this,o)),l}}this.defaults={...this.defaults,...a}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,n){return De.lex(t,n??this.defaults)}parser(t,n){return Pe.parse(t,n??this.defaults)}parseMarkdown(t){return(n,s)=>{let a={...s},r={...this.defaults,...a},i=this.onError(!!r.silent,!!r.async);if(this.defaults.async===!0&&a.async===!1)return i(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 i(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return i(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 o=r.hooks?await r.hooks.preprocess(n):n,l=await(r.hooks?await r.hooks.provideLexer(t):t?De.lex:De.lexInline)(o,r),c=r.hooks?await r.hooks.processAllTokens(l):l;r.walkTokens&&await Promise.all(this.walkTokens(c,r.walkTokens));let d=await(r.hooks?await r.hooks.provideParser(t):t?Pe.parse:Pe.parseInline)(c,r);return r.hooks?await r.hooks.postprocess(d):d})().catch(i);try{r.hooks&&(n=r.hooks.preprocess(n));let o=(r.hooks?r.hooks.provideLexer(t):t?De.lex:De.lexInline)(n,r);r.hooks&&(o=r.hooks.processAllTokens(o)),r.walkTokens&&this.walkTokens(o,r.walkTokens);let l=(r.hooks?r.hooks.provideParser(t):t?Pe.parse:Pe.parseInline)(o,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(o){return i(o)}}}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>"+$e(s.message+"",!0)+"</pre>";return n?Promise.resolve(a):a}if(n)return Promise.reject(s);throw s}}},ct=new Nc;function oe(t,n){return ct.parse(t,n)}oe.options=oe.setOptions=function(t){return ct.setOptions(t),oe.defaults=ct.defaults,ti(oe.defaults),oe};oe.getDefaults=Es;oe.defaults=dt;function Oc(...t){return ct.use(...t),oe.defaults=ct.defaults,ti(oe.defaults),oe}oe.use=Oc;oe.walkTokens=function(t,n){return ct.walkTokens(t,n)};oe.parseInline=ct.parseInline;oe.Parser=Pe;oe.parser=Pe.parse;oe.Renderer=In;oe.TextRenderer=Is;oe.Lexer=De;oe.lexer=De.lex;oe.Tokenizer=Fn;oe.Hooks=Ut;oe.parse=oe;var Yh=oe.options,Qh=oe.setOptions,eg=oe.walkTokens,tg=oe.parseInline;var ng=Pe.parse,ui=De.lex;var Hc={ts:"typescript",js:"javascript",mjs:"javascript",cjs:"javascript",py:"python",sh:"bash",shell:"bash",zsh:"bash",console:"bash",jsonc:"json",md:"markdown"},pi={amp:"&",lt:"<",gt:">",quot:'"',apos:"'","#39":"'"};function Bc(t){return t.replace(/&(#x[0-9a-f]+|#\d+|[a-z]+);/gi,(n,s)=>s in pi?pi[s]:s.startsWith("#x")?String.fromCodePoint(Number.parseInt(s.slice(2),16)):s.startsWith("#")?String.fromCodePoint(Number.parseInt(s.slice(1),10)):n)}function Ne({tokens:t}){return e(N,{children:(t??[]).map((n,s)=>mi(n,s))})}function Uc({t}){let n=Ht(t.href),s=e(Ne,{tokens:t.tokens}),a=t.title??void 0,r=Cn(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 mi(t,n){switch(t.type){case"text":{let s=t;return s.tokens?e(Ne,{tokens:s.tokens},n):s.escaped?Bc(s.text):s.text}case"escape":return t.text;case"strong":return e("strong",{children:e(Ne,{tokens:t.tokens})},n);case"em":return e("em",{children:e(Ne,{tokens:t.tokens})},n);case"del":return e("del",{children:e(Ne,{tokens:t.tokens})},n);case"codespan":return e("code",{children:t.text},n);case"br":return e("br",{},n);case"link":return e(Uc,{t},n);case"image":{let s=t,a=Ht(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(Ne,{tokens:s.tokens},n):s.raw}}}function jc({t}){let n=(t.lang??"").trim().split(/\s+/)[0]?.toLowerCase()??"",s=Hc[n]??n,a=V(()=>_n(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 Ds({tokens:t}){return e(N,{children:(t??[]).map((n,s)=>zc(n,s))})}function zc(t,n){switch(t.type){case"space":case"def":return null;case"heading":{let s=t;return pt(`h${Math.min(Math.max(s.depth,1),6)}`,{key:n},e(Ne,{tokens:s.tokens}))}case"paragraph":return e("p",{children:e(Ne,{tokens:t.tokens})},n);case"text":{let s=t;return s.tokens?e(Ne,{tokens:s.tokens},n):s.text}case"checkbox":return mi(t,n);case"code":return e(jc,{t},n);case"blockquote":return e("blockquote",{children:e(Ds,{tokens:t.tokens})},n);case"list":{let s=t,a=s.items.map((r,i)=>e("li",{class:r.task?"task":void 0,children:e(Ds,{tokens:r.tokens})},i));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,i)=>pt(r.header?"th":"td",{key:i,style:r.align?{textAlign:r.align}:void 0},e(Ne,{tokens:r.tokens}));return e("table",{children:[e("thead",{children:e("tr",{children:s.header.map(a)})}),e("tbody",{children:s.rows.map((r,i)=>e("tr",{children:r.map(a)},i))})]},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(Ne,{tokens:s.tokens}):s.raw},n)}}}function Pn({source:t,class:n}){let s=V(()=>ui(t,{gfm:!0}),[t]);return e("div",{class:n?`md ${n}`:"md",children:e(Ds,{tokens:s})})}var Xc={decision:"#7c3aed",constraint:"#dc2626",fact:"#2563eb",preference:"#0d9488",todo:"#d97706",note:"#6b7280",onboarding:"#16a34a"};function Ps({m:t}){return e(N,{children:[e("span",{class:"tag kind",style:{color:Xc[t.kind]??"#6b7280"},children:t.kind}),t.status&&t.status!=="accepted"?e("span",{class:`tag s-${t.status}`,children:t.status}):null]})}function hi({value:t}){let n=Cn(Ht(t));return n?e("a",{class:"ref",href:n,title:t,children:t}):e("span",{class:"tag",title:t,children:t})}function Gc(t){return t.split(`
81
+ `).find(n=>n.trim())?.replace(/^#+\s*/,"").slice(0,120)??""}var gi={kind:"fact",tags:"",related:"",body:"",name:"",status:"",supersedes:""};function fi(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 Wc({name:t,kinds:n,statuses:s,onSaved:a,onDeleted:r}){let i=G(()=>t?O("/api/memories",{name:t}):Promise.resolve(void 0),[t]),[o,l]=_(!t),[c,d]=_(!1),[u,m]=_(gi),[g,f]=_(!1);j(()=>{l(!t),d(!1)},[t]),j(()=>{let x=i.data;t&&x&&m(fi(x)),t||m(gi)},[t,i.data]);let k=x=>$=>m({...u,[x]:$.target.value}),h=()=>{l(!1),d(!1)},p=async()=>{if(!u.body.trim())return Q("body required",!0);f(!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 fe("/api/memories",x,"PUT",{name:t}):await fe("/api/memories",{...x,name:u.name.trim()||void 0});Q(`${t?"saved":"created"} ${$.name}${$.superseded?` \xB7 ${$.superseded} marked superseded`:""}`),t===$.name&&i.reload(),a($.name),h()}catch(x){Q(x.message,!0)}finally{f(!1)}},b=()=>{i.data&&m(fi(i.data)),h()},y=async()=>{if(!(!t||!confirm(`Delete memory "${t}" and its file?`)))try{await cn("/api/memories",{name:t}),Q(`deleted ${t}`),r()}catch(x){Q(x.message,!0)}},v=async()=>{if(!t)return;let x=prompt("New name (topic/slug):",t);if(!(!x||x===t))try{let $=await fe("/api/memories",{to:x},"PATCH",{name:t});Q(`renamed \u2192 ${$.name}${$.refsUpdated?` (${$.refsUpdated} references updated)`:""}`),a($.name)}catch($){Q($.message,!0)}},w=x=>{(x.metaKey||x.ctrlKey)&&x.key.toLowerCase()==="s"?(x.preventDefault(),p()):x.key==="Escape"&&t&&(x.preventDefault(),b())};if(t&&i.error)return e(Z,{error:i.error});if(t&&!i.data)return e(U,{});let S=i.data,T=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:v,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:y,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(Ps,{m:S}),S.tags.map(x=>e("span",{class:"tag",children:["#",x]})),S.related.map(x=>e(hi,{value:x})),S.supersedes?e("span",{class:"muted small",children:["supersedes ",e(hi,{value:`mem:${S.supersedes}`})]}):null]}),e(Pn,{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(N,{children:[e("span",{class:"muted small",children:"editing"}),e("button",{type:"button",class:"sm",onClick:v,children:"rename"}),e("button",{type:"button",class:"sm danger",onClick:y,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:k("name")})]}),e("div",{class:"grid",style:{gridTemplateColumns:T?"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:k("kind"),children:n.map(x=>e("option",{value:x,children:x}))})]}),T&&e("div",{class:"field",children:[e("label",{children:"status"}),e("select",{value:u.status,onChange:k("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:k("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:k("related")})]})]}),T&&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:k("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(Pn,{class:"preview",source:u.body.trim()?u.body:"_Nothing to preview yet._"}):e("textarea",{value:u.body,onInput:k("body"),onKeyDown:w,spellcheck:!1})]}),e("div",{class:"row",children:[e("button",{type:"button",class:"primary",disabled:g,onClick:p,children:g?e(U,{}):t?"Save":"Create"}),t?e("button",{type:"button",disabled:g,onClick:b,children:"Cancel"}):null,e("span",{class:"muted small",children:["\u2318S / Ctrl+S saves",t?", Esc cancels":""]})]})]})}function Jc({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("div",{class:"card",children:[e("h3",{children:s}),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(Ps,{m:r}),e("span",{class:"muted small",children:Se(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(Pn,{source:r.content})})]}))]}))}):e(J,{children:'No accepted decisions yet. Record one with kind "decision", or ask Claude to em_remember it.'})}function bi({params:t}){let[n,s]=_(t.name?.startsWith("decision/")?"decision":t.tab??"all"),[a,r]=_(t.name??null),[i,o]=_(!1),[l,c]=_(""),[d,u]=_(""),m=G(()=>O("/api/memories"),[]);j(()=>{t.name&&(r(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(()=>{m.data?.gitignored&&Q(`.gitignore keeps ${m.data.dir} out of git; memories stay local`,!0),m.data?.skipped.length&&Q(`skipped invalid memory files: ${m.data.skipped.join(", ")}`,!0)},[m.data]);let g=V(()=>{let h=m.data?.memories??[],p=l.trim().toLowerCase();return h.filter(b=>(n==="all"||n==="record"||b.kind===n)&&(!d||(b.status??"accepted")===d)&&(!p||b.name.includes(p)||b.tags.some(y=>y.includes(p))||b.content.toLowerCase().includes(p)))},[m.data,n,l,d]);if(m.error)return e("div",{class:"page",children:e(Z,{error:m.error})});let f=m.data,k=[["all","All"],...(f?.kinds??[]).map(h=>[h,h]),["record","Decision record"],["graph","Graph"]];return e("div",{class:"page",children:[e(Ce,{tabs:k,value:n,onChange:h=>{s(h),h!=="decision"&&u(""),(h==="graph"||t.tab)&&H("memory",{tab:h})}}),n==="graph"?e(wn,{scope:"memory",focus:t.focus}):n==="record"?e(Jc,{rows:(f?.memories??[]).filter(h=>h.kind==="decision"&&(h.status??"accepted")==="accepted")}):e(N,{children:[e("div",{class:"row",style:{marginBottom:12},children:[e("button",{type:"button",class:"primary",onClick:()=>{o(!0),r(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"}),(f?.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 fe("/api/actions",{action:"reconcile"});Q(h.output,!h.ok),m.reload()},children:"\u21BB Reconcile"}),e("span",{class:"muted small",children:[g.length," of ",f?.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:f?g.length?g.map(h=>e("div",{class:M("item",a===h.name&&"sel"),onClick:()=>{r(h.name),o(!1)},children:[e("div",{class:"n",children:h.name}),e("div",{class:"p",children:[e(Ps,{m:h}),e("span",{class:"muted",children:[Se(h.updated_at)," \xB7 ",q(h.size??0),"B"]})]}),e("div",{class:"p",children:Gc(h.content)})]})):e(J,{children:"no memories match"}):e(J,{children:e(U,{})})})}),e("div",{class:"card",children:i||a?e(Wc,{name:i?null:a,kinds:f?.kinds??[],statuses:f?.statuses??[],onSaved:h=>{o(!1),r(h),m.reload()},onDeleted:()=>{r(null),m.reload()}}):e(J,{children:"Select a memory, or create a new one."})})]})]}),e("div",{style:{display:"none"},children:e(P,{children:"x"})})]})}function yi({rows:t}){let n=[...t].sort((s,a)=>a.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 a=Math.ceil(s.raw_chars/4),r=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(a)}),e("td",{class:"num",children:q(r)}),e("td",{class:"num",children:q(Math.max(0,a-r))})]})}):e("tr",{children:e("td",{class:"muted",colSpan:5,children:"no calls yet"})})})]})}function vi(){let t=G(()=>O("/api/stats"),[]);if(t.error)return e("div",{class:"page",children:e(Z,{error:t.error})});let n=t.data;if(!n)return e("div",{class:"page",children:e(U,{})});let s=[["session saved",q(n.session.savedTokens),`${Fe(n.session.efficiency)} efficient \xB7 ${n.session.calls} calls`],["project saved",q(n.projectTotals.savedTokens),`${Fe(n.projectTotals.efficiency)} efficient \xB7 ${n.projectTotals.calls} calls`],["lifetime saved",q(n.lifetime.savedTokens),`${Fe(n.lifetime.efficiency)} efficient \xB7 ${n.lifetime.calls} calls`],["documents",String(n.index.documents),e(N,{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`]],a=Math.max(1,...n.daily.map(i=>i.saved_chars)),r=["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/a)}%`}})):e("div",{class:"muted",children:"no data yet"})})]}),e("div",{class:"card",children:[e("h3",{children:"system"}),e(Ke,{rows:[["project",n.project],["database",n.dbPath],["routing",n.routing],["embeddings",n.index.embeddings],["memories dir",n.memoriesDir],["onboarding",r.length?e("span",{class:"warn",children:["missing: ",r.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(yi,{rows:n.session.tools})]}),e("div",{class:"card",children:[e("h3",{children:"lifetime \xB7 by tool"}),e(yi,{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:()=>H("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:[re(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 ki(){let t=G(()=>O("/api/sessions",{limit:60}),[]),[n,s]=_(null),[a,r]=_(""),[i,o]=_(100);j(()=>{!n&&t.data?.[0]&&s(t.data[0].id)},[t.data]);let l=G(()=>n?O("/api/events",{session:n,category:a||void 0,limit:i}):Promise.resolve([]),[n,a,i]),c=[...new Set((l.data??[]).map(d=>d.category))].sort();return t.error?e("div",{class:"page",children:e(Z,{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:M("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:re(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 ",Fe(d.efficiency),d.source?` \xB7 ${d.source}`:""]})]})):e(J,{children:"no sessions yet"}):e(J,{children:e(U,{})})})}),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:a,onChange:d=>r(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(Z,{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:Sr(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"},xi=t=>`sw-s-${t}`,Gt={hierarchical:"\u22D4",mesh:"\u2B21",pipeline:"\u21C9"},_i={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"},Ns=[["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"]]],Os={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"}},wi=["var(--accent)","var(--tok-ty)","var(--tok-str)","var(--tok-kw)","var(--tok-num)","var(--muted)"];function Wt(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 wi[s%wi.length]}function Nn(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 je=t=>t?t.replace(/^agent-/,"").slice(0,8):"";function St(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 Tt(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 Re(t,n,s){let[,a]=_(0);return j(()=>{if(!n)return;let r=setInterval(()=>{document.visibilityState==="visible"&&a(i=>i+1)},t);return()=>clearInterval(r)},[t,n]),Date.now()+s}function ze(t){class n extends ut{shouldComponentUpdate(a){let r=this.props,i=a;for(let o in i)if(r[o]!==i[o])return!0;for(let o in r)if(!(o in i))return!0;return!1}render(a){return pt(t,a)}}return n}var Si=t=>n=>{n.target===n.currentTarget&&(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),t())};function Xe({s:t,word:n,title:s}){return e("span",{class:M("sw-state",xi(t)),title:s,children:[e("span",{class:"g","aria-hidden":"true",children:le[t]}),n??t]})}function Oe({role:t,roles:n,title:s,label:a,children:r}){return e("span",{class:"sw-chip",style:`--rc:${Wt(t,n)}`,title:s,children:[a??t??"any role",r]})}function ke({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 qc({notes:t,roles:n,live:s,skew:a}){let r=Re(15e3,s,a),[i,o]=_(null);return e("div",{class:"card",children:[e(ke,{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:M("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(Oe,{role:d.split("@")[0],roles:n,label:d}),e("span",{class:"age",title:new Date(l.ts).toLocaleString(),children:Tt(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 Ti=ze(qc);var Hs=300;function Kc({events:t,roles:n,live:s,skew:a,behind:r,agent:i,onAgent:o}){let l=Re(5e3,s,a),[c,d]=_(""),[u,m]=_(""),g=Ns.find(([h])=>h===u)?.[2],f=[...new Set([...n,...t.map(h=>h.role??"").filter(Boolean)])],k=t.filter(h=>(!c||h.role===c)&&(!g||g.includes(h.kind))&&(!i||h.agent_id===i)).reverse();return e("div",{class:"card sw-feed-card",children:[e(ke,{title:"Activity",meta:`${k.length}${k.length!==t.length?` of ${t.length}`:""} events`}),e("div",{class:"row sw-filters",children:[e("select",{value:c,onChange:h=>d(h.target.value),children:[e("option",{value:"",children:"all roles"}),f.map(h=>e("option",{value:h,children:h}))]}),e("select",{value:u,onChange:h=>m(h.target.value),children:[e("option",{value:"",children:"all kinds"}),Ns.map(([h,p])=>e("option",{value:h,children:p}))]}),i?e("button",{type:"button",class:"chip on",onClick:()=>o(null),title:"clear",children:["worker ",je(i)," \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,k.length?k.slice(0,Hs).map(h=>{let p=Nn(h);return e("div",{class:M("sw-ev",`k-${h.kind}`,`io-${p}`),title:`${new Date(h.ts).toLocaleString()} \xB7 ${h.kind}${h.agent_id?` \xB7 ${h.agent_id}`:""}`,children:[e("span",{class:"t",children:Tt(h.ts,l)}),e(Oe,{role:h.role??"coordinator",roles:n}),e("span",{class:"g",title:h.kind,children:_i[h.kind]??"\xB7"}),e("span",{class:"x",children:[h.task_id?e("b",{children:["#",h.task_id," "]}):null,h.text??h.kind]})]},h.id)}):e("div",{class:"empty small",children:["no events",t.length?" match the filter":" yet"]}),k.length>Hs?e("div",{class:"muted small sw-more",children:[k.length-Hs," older events not shown; narrow the filter"]}):null]})]})}var $i=ze(Kc);var Vc=[["pending",["pending"],!1],["active",["active"],!1],["done",["done"],!0],["failed / blocked",["failed","blocked"],!0]],Bs=30,Zc=15e3;function Yc(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${je(s.agent_id)}`:t.agent_id.startsWith("agent-")?je(t.agent_id):t.agent_id}function Qc(t,n){let[s,a]=_(),[r,i]=_();return j(()=>{if(!n||!t.clipped)return;let o=!0;return i(void 0),O("/api/swarm/task",{id:t.id,run:t.run_id}).then(l=>o&&a(l.task),l=>o&&i(l.message)),()=>{o=!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 ed({t,roles:n,workers:s,byId:a,now:r}){let[i,o]=_(!1),l=Qc(t,i),c=l.task,d=t.deps.filter(f=>a.get(f)?.status!=="done"),u=t.result?.trim().split(`
83
+ `)[0],m=t.status==="active"&&t.agent_id?s.get(t.agent_id):void 0,g=m&&m.status!=="running"?m.status:null;return e("div",{class:M("sw-task",`st-${t.status}`,i&&"open"),children:[e("button",{type:"button",class:"sw-btn sw-task-sum","aria-expanded":i,title:u?`result: ${u.slice(0,300)}`:void 0,onClick:()=>o(f=>!f),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(Xe,{s:t.status}),e(Oe,{role:t.role,roles:n}),e("span",{class:"who",title:t.agent_id??void 0,children:Yc(t,s)}),t.files.length?e("span",{class:"files",title:t.files.join(`
84
+ `),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:[le.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:M("deps",d.length>0&&"waiting"),children:["after ",t.deps.map(f=>`#${f}`).join(", ")]}):null,e("span",{class:"age",children:Tt(t.updated_at,r)})]})]}),i?e("div",{class:"x",children:[c.detail?e("pre",{class:"sw-pre",children:c.detail}):null,c.result?e(N,{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(f=>e("a",{href:`#/explore?file=${encodeURIComponent(f)}`,children:e("code",{children:f})}))}):null,e("div",{class:"lbl",children:["created by ",t.created_by??"n/a"," \xB7 ",new Date(t.created_at).toLocaleString()]})]}):null]})}function td({label:t,tasks:n,roles:s,workers:a,byId:r,now:i}){let[o,l]=_(Bs),c=n.length-o;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,o).map(d=>e(ed,{t:d,roles:s,workers:a,byId:r,now:i},d.id)),c>0?e("button",{type:"button",class:"ghost sm sw-col-more",onClick:()=>l(d=>d+Bs),title:`${c} more ${t} task${c===1?"":"s"} not shown`,children:["show ",Math.min(Bs,c)," more \xB7 ",c," hidden"]}):null]})}function nd({tasks:t,workers:n,roles:s,live:a,skew:r}){let i=Re(Zc,a,r),o=new Map(t.map(d=>[d.id,d])),l=new Map(n.map(d=>[d.agent_id,d])),c=t.filter(d=>d.status==="done").length;return e("div",{class:"card sw-board-card",children:[e(ke,{title:"Tasks",meta:t.length?`${c}/${t.length} done`:"none planned"}),t.length?e("div",{class:"sw-board",children:Vc.map(([d,u,m])=>{let g=t.filter(f=>u.includes(f.status));return m&&g.sort((f,k)=>k.updated_at-f.updated_at||k.id-f.id),e(td,{label:d,tasks:g,roles:s,workers:l,byId:o,now:i},d)})}):e("div",{class:"empty small",children:["No tasks yet. The coordinator plans them with ",e("code",{children:["em_swarm ",'{action:"plan"}']}),"."]})]})}var Ei=ze(nd);var sd=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()} (${St(t.end-t.start)})`,`${t.n} events${n?` \xB7 ${n}`:""}${t.errors?` \xB7 ${t.errors} errors`:""}`].join(`
85
+ `)},rd=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 ad({agent:t,onRelease:n}){let[s,a]=_(!1),[r,i]=_(!1);return j(()=>{if(!s)return;let o=setTimeout(()=>a(!1),4e3);return()=>clearTimeout(o)},[s]),e("button",{type:"button",class:M("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);i(!0);try{await n(t)}finally{i(!1),a(!1)}},children:r?"releasing\u2026":s?"confirm release":"release"})}function id({timeline:t,live:n,roles:s,skew:a,onRelease:r}){let i=Re(5e3,n,a),o=t.start,l=Math.max(n?i:t.end,o+1e3),c=l-o,d=k=>`${Math.max(0,Math.min(100,(k-o)/c*100))}%`,u=(k,h)=>`${Math.max(0,Math.min(100,(Math.min(h,l)-Math.max(k,o))/c*100))}%`,m=[0,.25,.5,.75,1],g=t.cut&&t.from?t.from:null,f=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(ke,{title:"Timeline",meta:e("span",{title:f,children:[St(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(k=>e("div",{class:"sw-tl-row",children:[e("div",{class:"who",title:k.agent_id,children:[e("span",{class:M("g",`sw-s-${k.status}`),children:le[k.status]}),e(Oe,{role:k.role,roles:s}),e("span",{class:"id",children:je(k.agent_id)}),n&&r&&k.status==="stale"?e(ad,{agent:k.agent_id,onRelease:r}):null]}),e("div",{class:"track",style:"--rc:var(--line)",children:[g&&g>o?e("span",{class:"cut",style:{left:0,width:u(o,g)},title:f}):null,e("span",{class:"life",style:{left:d(k.spawned_at),width:u(k.spawned_at,k.ended_at??(n?i:l))}}),k.segments.map(h=>e("span",{class:M("seg",`io-${rd(h)}`,h.errors>0&&"err",h.open&&"open"),style:{left:d(h.start),width:u(h.start,h.end)},title:sd(h)}))]})]},k.agent_id)),e("div",{class:"sw-tl-row axis",children:[e("div",{class:"who"}),e("div",{class:"track",children:m.map(k=>e("span",{class:"tick",style:{left:`${k*100}%`},children:k===0?new Date(o).toLocaleTimeString():`+${St(c*k)}`}))})]})]}):e("div",{class:"empty small",children:"No workers have started in this run."})]})}var Ci=ze(id);var od=new Set(["claim","post","update","plan","spawn","start","stop","auto_close"]),ld=1e4,Ri=2500,cd=12,dd=6,Ai=8,Mi=110,ud=.95;function pd(t,n){let s=n.length>cd;return t.map(a=>{let r=n.filter(o=>o.role===a),i=[];for(let o of r)(!s||o.status==="running"&&i.length<dd)&&i.push({type:"worker",id:o.agent_id,role:a,w:o});if(s&&r.length>i.length){let o=r.filter(c=>!i.some(d=>d.id===c.agent_id)),l=c=>o.filter(d=>d.status===c).length;i.push({type:"group",id:`fold:${a}`,role:a,n:o.length,running:l("running"),stale:l("stale"),done:l("done")})}return i.length||i.push({type:"idle",id:`idle:${a}`,role:a}),i})}var md=t=>[t.running?`${le.running}${t.running}`:"",t.stale?`${le.stale}${t.stale}`:"",t.done?`${le.done}${t.done}`:""].filter(Boolean).join(" "),Us=116,Li=56;function hd(t,n,s,a){let r=n.flat();if(t==="pipeline"){let d=[...s,...a.filter(v=>!s.includes(v))],u=d.map(v=>n[a.indexOf(v)]??[]),m=84,g=Math.max(1,...u.map(v=>v.length)),f=Math.max(240,96+g*m),k=150,h=150,p=h+u.length*k+10,b=[],y=[];return u.forEach((v,w)=>{let S=h+w*k+k/2,T=60+(f-60-v.length*m)/2;v.forEach(($,A)=>{b.push({item:$,x:S,y:T+A*m+22})});let x=d[w];y.push({x:h+w*k+6,w:k-12,label:On(s.includes(x)?`${s.indexOf(x)+1} \xB7 ${x}`:x,20),n:v.length})}),{w:p,h:f,hub:{x:60,y:f/2},nodes:b,peers:[],lanes:y}}if(t==="mesh"){let d=r.length,u=Math.max(100,d*120/(2*Math.PI)),m=Math.max(640,2*u+2*Li+120),g=2*u+130,f=m/2,k=u+46,h=r.map((b,y)=>{let v=-Math.PI/2+2*Math.PI*y/Math.max(1,d);return{item:b,x:f+u*Math.cos(v),y:k+u*Math.sin(v)}}),p=[];for(let b=0;b<h.length;b++)for(let y=b+1;y<h.length;y++)(d<=8||y===b+1||b===0&&y===d-1)&&p.push([h[b],h[y]]);return{w:m,h:g,hub:{x:f,y:k},nodes:h,peers:p,lanes:[]}}let i=[[]];for(let d of n){let u=i[i.length-1];u.length&&u.length+d.length>Ai&&i.push([]);for(let m of d)i[i.length-1].length>=Ai&&i.push([]),i[i.length-1].push(m)}let o=Math.max(1,...i.map(d=>d.length)),l=Math.max(640,o*Us+2*Li),c=i.flatMap((d,u)=>{let m=(l-d.length*Us)/2;return d.map((g,f)=>({item:g,x:m+Us*(f+.5),y:200+u*Mi}))});return{w:l,h:286+(i.length-1)*Mi,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 gd(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 fd({detail:t,events:n,skew:s,roles:a,picked:r,onPick:i}){let o=t.run.topology,l=t.run.status==="active",c=Re(1e3,l,s),d=pd(a,t.workers),u=hd(o,d,t.stages,a),m=d.flat().some(b=>b.type==="group"),g=new Map,f=new Set,k=new Set;for(let b of n){let y=c-b.ts;b.agent_id&&y<Ri&&y>-Ri&&g.set(b.agent_id,b),y<ld&&od.has(b.kind)&&(b.agent_id?f.add(b.agent_id):b.role&&k.add(b.role))}let h=new Map(t.tasks.map(b=>[b.id,b.title])),p=b=>l&&(b.type==="worker"?f.has(b.id):b.type==="idle"&&k.has(b.role));return e("div",{class:"sw-topo-wrap",children:[e("svg",{class:M("sw-topo",`topo-${o}`),viewBox:`0 0 ${u.w} ${u.h}`,style:{maxWidth:`${u.w}px`,minWidth:`${Math.round(u.w*ud)}px`},role:"group","aria-label":`${o} topology: coordinator and ${t.workers.length} workers${m?", quiet workers folded per role":""}`,children:[u.lanes.map((b,y)=>e("g",{class:"sw-lane",children:[e("rect",{x:b.x,y:8,width:b.w,height:u.h-16,rx:8}),e("text",{x:b.x+b.w/2,y:26,children:b.label}),y<u.lanes.length-1?e("text",{class:"arrow",x:b.x+b.w+6,y:26,children:"\u2192"}):null]})),u.peers.map(([b,y])=>e("line",{class:M("sw-edge peer",(p(b.item)||p(y.item))&&"hot"),x1:b.x,y1:b.y,x2:y.x,y2:y.y})),u.nodes.map(b=>e("path",{class:M("sw-edge spoke",p(b.item)&&"hot",b.item.type!=="worker"&&"ghost"),d:gd(o,u.hub,b),style:{stroke:p(b.item)?Wt(b.item.role,a):void 0}},b.item.id)),e("g",{class:M("sw-node hub",l&&"live"),transform:`translate(${u.hub.x},${u.hub.y})`,children:[l?e("circle",{class:"sw-halo",r:30}):null,e("circle",{class:"sw-core",r:22}),e("text",{class:"sw-glyph",dy:6,children:le.coordinator}),e("text",{class:"sw-l1",y:o==="hierarchical"?-32:40,children:"coordinator"}),e("title",{children:"coordinator: the main Claude Code session leads the run"})]}),u.nodes.map(({item:b,x:y,y:v})=>{let w=Wt(b.role,a);if(b.type==="group")return e("g",{class:"sw-node group",transform:`translate(${y},${v})`,children:[e("circle",{class:"sw-core",r:17,style:{stroke:w}}),e("text",{class:"sw-glyph sw-plus",dy:4,style:{fill:w},children:["+",b.n]}),e("text",{class:"sw-l1",y:33,style:{fill:w},children:On(b.role,16)}),e("text",{class:"sw-l2",y:47,children:md(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(${y},${v})`,children:[e("circle",{class:"sw-core",r:16,style:{stroke:w}}),e("text",{class:"sw-glyph",dy:5,style:{fill:w},children:le.idle}),e("text",{class:"sw-l1",y:32,style:{fill:w},children:On(b.role,16)}),e("text",{class:"sw-l2",y:46,children:`${le.idle} idle`}),e("title",{children:`${b.role}: no worker spawned in this run yet`})]},b.id);let S=b.w,T=g.get(S.agent_id),x=S.task_id?`#${S.task_id}`:"",$=r===S.agent_id,A=()=>i($?null:S.agent_id);return e("g",{class:M("sw-node worker",`st-${S.status}`,$&&"picked"),transform:`translate(${y},${v})`,tabindex:0,role:"button","aria-pressed":$,"aria-label":`${S.role} worker ${je(S.agent_id)}, ${S.status}${x?`, task ${x}`:""}: ${$?"show every worker's":"show only its"} activity`,onClick:A,onKeyDown:Si(A),children:[e("circle",{class:"sw-focus",r:27}),S.status==="running"&&l?e("circle",{class:"sw-halo",r:24,style:{stroke:w}}):null,T?e("circle",{class:M("sw-flash",`io-${Nn(T)}`),r:20},T.id):null,e("circle",{class:"sw-core",r:17,style:{stroke:w}}),e("text",{class:"sw-glyph",dy:5,style:{fill:w},children:le[S.status]}),e("text",{class:"sw-l1",y:33,children:[e("tspan",{style:{fill:w},children:On(S.role,8)}),e("tspan",{class:"id",children:["\xB7",je(S.agent_id)]})]}),e("text",{class:M("sw-l2",`sw-s-${S.status}`),y:47,children:[le[S.status]," ",S.status,x?` ${x}`:""]}),e("title",{children:[`${S.role} worker ${S.agent_id}`,`${S.status}${S.task_id?` \xB7 task #${S.task_id} ${h.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(`
86
+ `)})]},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:[le.running," running \xB7 ",le.stale," stale \xB7 ",le.done," done \xB7 ",le.idle," idle",m?" \xB7 +N folded":""]})]})]})}var Fi=ze(fd);function bd(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 Ii(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(N,{children:[s,e("span",{class:r,children:n}),a]})}function Di({text:t,marks:n}){let s=t.replace(/\n$/,"").split(`
87
+ `),a=-1;return e("pre",{class:"sw-yaml",children:s.map((r,i)=>{let o=r.length-r.trimStart().length,l=i+1,c;if(a>=0&&(r.trim()===""||o>a))c=e("span",{class:"tok-str",children:r});else{a=-1;let[d,u]=bd(r),m=/^(\s*)(- )?([A-Za-z0-9_.-]+)(:)(.*)$/.exec(d);if(m){let g=m[5]??"";/^\s*[|>]-?\s*$/.test(g)&&(a=o+(m[2]?2:0)),c=e(N,{children:[m[1],m[2]?e("span",{class:"tok-pn",children:m[2]}):null,e("span",{class:"tok-ty",children:m[3]}),e("span",{class:"tok-pn",children:m[4]}),Ii(g),u?e("span",{class:"tok-cm",children:u}):null]})}else{let g=/^(\s*)(- )(.*)$/.exec(d);c=e(N,{children:[g?e(N,{children:[g[1],e("span",{class:"tok-pn",children:g[2]}),Ii(g[3]??"")]}):d,u?e("span",{class:"tok-cm",children:u}):null]})}}return e("span",{class:M("l",n?.has(l)&&"mark"),children:[e("span",{class:"ln",children:l}),c]})})})}var yd=15e3,vd=2e3,kd=5e3,Pi=800,wd=5,js=30,xd=1e3,_d=3e4,zs=()=>document.visibilityState==="visible";function Sd(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,i)=>r.id-i.id);return a.length>Pi?a.slice(-Pi):a}function Ni({onCreated:t}){let[n,s]=_(!1),[a,r]=_();return e("span",{class:"row tight",children:[e("button",{type:"button",class:"primary",disabled:n,onClick:async()=>{s(!0),r(void 0);try{let i=await fe("/api/swarm/init",{});Q(`created ${i.created} \xB7 ${i.sync.changed} agent file(s) written`),t()}catch(i){r(i.message)}finally{s(!1)}},children:n?"Creating\u2026":"Create .eminiar/swarm.yaml"}),a?e("span",{class:"bad small",children:a}):null]})}function Td({needed:t,onDone:n}){let[s,a]=_(!1),[r,i]=_();return e("div",{class:"row tight sw-sync",children:[e("button",{type:"button",class:M("sm",t&&"primary"),disabled:s,title:"write .claude/agents/swarm-<swarm>-<role>.md from the swarm file",onClick:async()=>{a(!0),i(void 0);try{let o=await fe("/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{a(!1)}},children:s?"Syncing\u2026":"Sync agent files"}),r?e("span",{class:M("small",r.bad?"bad":"muted"),children:r.text}):t?e("span",{class:"small warn",children:[le.blocked," out of date"]}):e("span",{class:"small muted",children:[le.done," in sync"]})]})}function $d({f:t}){return t.memoryError?e("div",{class:"sw-note-box warn small",role:"alert",children:[e(Xe,{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(Xe,{s:"done",word:"memory written"})," ",e("code",{children:t.memory})]}):null}function Ed({id:t,onDone:n}){let[s,a]=_(!1),[r,i]=_("done"),[o,l]=_(""),[c,d]=_(!1),[u,m]=_(!1),[g,f]=_();return s?e("form",{class:"sw-finish",onSubmit:async k=>{k.preventDefault(),m(!0),f(void 0);try{let h=await fe("/api/swarm/finish",{id:t,status:r,summary:o.trim()||void 0,remember:c}),p=h.memoryError??null;Q(p?`run finished as ${r} \xB7 its memory was NOT written`:`run finished as ${r}${h.memory?` \xB7 memory ${h.memory}`:""}`,!!p),a(!1),n({status:r,memory:h.memory,memoryError:p,remember:c})}catch(h){f(h.message)}finally{m(!1)}},children:[e("div",{class:"row",children:[e("span",{class:"small muted",children:"close the run as"}),["done","failed","cancelled"].map(k=>e("label",{class:M("sw-radio",r===k&&"on"),children:[e("input",{type:"radio",name:`finish-${t}`,checked:r===k,onChange:()=>i(k)}),e(Xe,{s:k})]}))]}),e("textarea",{class:"sw-summary",placeholder:"Summary (optional): the outcome in a sentence or two",value:o,maxLength:4e3,onInput:k=>l(k.target.value)}),e("label",{class:"small row tight",children:[e("input",{type:"checkbox",checked:c,onChange:k=>d(k.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 ${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",onClick:()=>a(!0),children:"Finish run\u2026"})}function Oi({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 Cd({s:t}){let[n,s]=_(!1),a=t.roles.map(i=>i.role),r=new Map;for(let i of t.roles)r.set(i.file.action,(r.get(i.file.action)??0)+1);return e("div",{class:M("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:Gt[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=Os[i.file.action];return e(Oe,{role:i.role,roles:a,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:M("fs",o.cls),children:o.glyph})]})})}),e("div",{class:"files small",children:[e("span",{class:"muted",children:"agent files"}),[...r.entries()].map(([i,o])=>{let l=Os[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(Oe,{role:i.role,roles:a}),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"}),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 Rd({o:t,onChanged:n}){return t.state==="absent"?e("div",{class:"card",children:[e(ke,{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(Ni,{onCreated:n})]}):t.state==="invalid"?e("div",{class:"card",children:[e(ke,{title:"Swarms",meta:e(Xe,{s:"failed",word:"invalid"})}),e("div",{class:"small mono",children:t.file}),e(Oi,{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(ke,{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(Xe,{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(Cd,{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(Td,{needed:t.syncNeeded,onDone:n}):null]})}function Ad({runs:t,selected:n,more:s,loading:a,onMore:r}){let i=t.filter(o=>o.status==="active").length;return e("div",{class:"card flush",children:[e("div",{class:"sw-pad",children:e(ke,{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:M("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(Xe,{s:o.status}),e("span",{class:"spacer"}),e("span",{class:"muted small",title:new Date(o.created_at).toLocaleString(),children:re(o.created_at)})]}),e("div",{class:"n sw-goal",title:o.goal,children:o.goal}),e("div",{class:"p",children:[Gt[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:a,onClick:r,children:a?"Loading\u2026":`Show ${js} older runs`})}):null]}):e("div",{class:"empty small",children:"No runs yet."})]})}function Hi({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 Md({o:t,onCreated:n}){return e("div",{class:"card sw-optin",children:[e(ke,{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(Ni,{onCreated:n})}),e(Hi,{swarms:[]}),e(ke,{title:"Starter",meta:`${t.file} \xB7 read-only preview`}),t.starter?e(Di,{text:t.starter}):null]})}function Ld({o:t}){return t.state==="invalid"?e("div",{class:"card sw-optin",children:[e(ke,{title:"Swarm file is invalid",meta:t.file}),e("p",{children:"Fix these and the swarms appear here:"}),e(Oi,{issues:t.issues})]}):e("div",{class:"card sw-optin",children:[e(ke,{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(Hi,{swarms:t.swarms.map(n=>n.name)})]})}function Jt({label:t,value:n,sub:s,tone:a,children:r}){return e("div",{class:"card sw-stat",children:[e("h3",{children:t}),e("div",{class:M("big",a||void 0),children:n}),e("div",{class:"sub",children:s}),r]})}function Fd({run:t,skew:n}){let s=t.status==="active",a=Re(1e3,s,n),r=s?a-t.created_at:t.ended_at?t.ended_at-t.created_at:null;return e(Jt,{label:"elapsed",value:St(r),sub:s?`since ${new Date(t.created_at).toLocaleTimeString()}`:t.ended_at?`ended ${re(t.ended_at)}`:"end time not recorded"})}var Id=(t,n)=>!!t&&t.length===n.length&&t.every((s,a)=>s===n[a]);function Dd({id:t,onChanged:n}){let[s,a]=_(),[r,i]=_(),[o,l]=_(null),[c,d]=_([]),[u,m]=_(!1),[g,f]=_(null),[k,h]=_(0),[p,b]=_(),y=ne(0),v=ne(!1),w=ne(new Map),S=ne([]),T=ne(0),x=ne(),$=ne(""),A=ne(!1),F=ne(!1),C=ne(!0),L=At(async(xe=!1)=>{let D=v.current&&!xe&&T.current>0,K;try{K=await O("/api/swarm/run",{id:t,tasksSince:D?T.current:void 0,events:v.current?0:void 0})}catch(se){return C.current&&i(se.message),!1}if(!C.current)return!0;let he=!K.tasksPartial;if(K.tasksPartial){for(let se of K.tasks){let _e=w.current.get(se.id);(!_e||_e.updated_at!==se.updated_at||_e.status!==se.status)&&(he=!0),w.current.set(se.id,se)}if(K.taskCount!==void 0&&w.current.size!==K.taskCount)return L(!0)}else w.current=new Map(K.tasks.map(se=>[se.id,se]));he&&(S.current=[...w.current.values()].sort((se,_e)=>se.id-_e.id),T.current=S.current.reduce((se,_e)=>Math.max(se,_e.updated_at),0)),Id(x.current,K.roles)||(x.current=K.roles);let Me=K.now-Date.now();h(se=>Math.abs(se-Me)>1e3?Me:se);let pe=$.current;return $.current=K.run.status,v.current||(v.current=!0,y.current=K.events.length?K.events[K.events.length-1].id:0,d(K.events)),a({...K,tasks:S.current,roles:x.current??K.roles}),i(void 0),l(null),pe==="active"&&K.run.status!=="active"&&(A.current=!0,n()),!0},[t]),E=At(async xe=>{try{let D=await fe("/api/swarm/release",{id:t,agent:xe});Q(`released ${D.released.join(", ")}; its task is pending again`),L(!0)}catch(D){Q(`release failed: ${D.message}`,!0)}},[t,L]);if(j(()=>{C.current=!0;let xe,D=xd,K=async()=>{await L()||!C.current||v.current||(l(D),xe=setTimeout(K,D),D=Math.min(D*2,_d))};K();let he=setInterval(async()=>{if(!(!v.current||F.current||!zs())&&!($.current!=="active"&&!A.current)){F.current=!0;try{let pe=!0,se=!1;for(let _e=0;_e<wd&&pe;_e++){let Ee=await O("/api/swarm/events",{id:t,after:y.current});if(!C.current)return;Ee.events.length&&(y.current=Ee.last,d(ee=>Sd(ee,Ee.events))),pe=Ee.more,se=Ee.run.status!=="active"}A.current=pe,m(pe),se&&!pe&&$.current==="active"&&L()}catch{}finally{F.current=!1}}},vd),Me=setInterval(()=>{v.current&&$.current==="active"&&zs()&&L()},kd);return()=>{C.current=!1,clearTimeout(xe),clearInterval(he),clearInterval(Me)}},[t]),!s)return r?e("div",{class:"card",children:[e(Z,{error:r}),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(U,{})});let{run:I,counts:B}=s,W=I.status==="active",R=s.roles,z=s.workers.length,te=s.tasks.length;return e("div",{class:"sw-run",children:[r?e("div",{class:"sw-note-box bad small",children:["refresh failed: ",r]}):null,e("div",{class:"card sw-runhead",children:[e("div",{class:"row",children:[e(Xe,{s:I.status}),e("h2",{class:"goal",children:I.goal}),e("span",{class:"spacer"}),W?e(Ed,{id:I.id,onDone:xe=>{b(xe),L(!0),n()}}):null]}),e("div",{class:"meta small muted",children:[e("code",{children:I.id}),e("span",{children:["swarm ",e("b",{children:I.swarm})]}),e("span",{children:[Gt[I.topology]," ",I.topology]}),e("span",{title:new Date(I.created_at).toLocaleString(),children:["started ",re(I.created_at)]}),e("span",{children:["session ",I.session_id?e("code",{children:I.session_id.slice(0,8)}):"n/a"]}),s.configured?null:e("span",{class:"warn",children:['swarm "',I.swarm,'" is no longer in the swarm file']})]}),I.summary?e("div",{class:"sw-summary-text",children:I.summary}):null,p?e($d,{f:p}):null]}),e("div",{class:"sw-stats",children:[e(Jt,{label:"workers running",value:`${B.workers.running}${s.maxAgents?` / ${s.maxAgents}`:""}`,sub:z?`${z} spawned \xB7 ${B.workers.stale} stale \xB7 ${B.workers.done} done`:"none spawned yet"}),e(Jt,{label:"tasks done",value:`${B.tasks.done} / ${te}`,sub:te?`${B.tasks.active} active \xB7 ${B.tasks.pending} pending \xB7 ${B.tasks.failed+B.tasks.blocked} failed/blocked${B.staleHeld?` \xB7 ${B.staleHeld} held by a quiet worker`:""}`:"none planned",children:te?e("div",{class:"sw-progress",children:[e("span",{class:"done",style:{width:`${100*B.tasks.done/te}%`}}),e("span",{class:"active",style:{width:`${100*B.tasks.active/te}%`}}),e("span",{class:"bad",style:{width:`${100*(B.tasks.failed+B.tasks.blocked)/te}%`}})]}):null}),e(Jt,{label:"tool calls",value:q(B.toolCalls),sub:z?`by ${z} worker${z===1?"":"s"}${B.autoClosed?` \xB7 ${B.autoClosed} auto-closed`:""}`:"no workers yet"}),e(Jt,{label:"errors",value:q(B.errors),sub:"failed tool calls",tone:B.errors>0&&"bad"}),e(Fd,{run:I,skew:k})]}),e("div",{class:"card",children:[e(ke,{title:"Topology",meta:`${Gt[I.topology]} ${I.topology} \xB7 ${z} worker${z===1?"":"s"}${W?" \xB7 live":""}`}),e(Fi,{detail:s,events:c,skew:k,roles:R,picked:g,onPick:f})]}),e(Ei,{tasks:s.tasks,workers:s.workers,roles:R,live:W,skew:k}),e(Ci,{timeline:s.timeline,live:W,roles:R,skew:k,onRelease:E}),e("div",{class:"sw-two",children:[e($i,{events:c,roles:R,live:W,skew:k,behind:u,agent:g,onAgent:f}),e(Ti,{notes:s.notes,roles:R,live:W,skew:k})]})]})}function Bi({params:t}){let[n,s]=_(js),a=G(()=>O("/api/swarm",{limit:n}),[n]);j(()=>{let l=setInterval(()=>{zs()&&a.reload()},yd);return()=>clearInterval(l)},[]);let r=a.data;if(!r)return e("div",{class:"page",children:a.error?e(Z,{error:a.error}):e(U,{})});let i=r.runs,o=t.run||(i.find(l=>l.status==="active")??i[0])?.id;return e("div",{class:"page sw-page",children:[a.error?e(Z,{error:a.error}):null,e("div",{class:"sw-layout",children:[e("aside",{class:"sw-rail",children:[e(Rd,{o:r,onChanged:a.reload}),e(Ad,{runs:i,selected:o,more:!!r.runsMore,loading:a.loading,onMore:()=>s(l=>l+js)})]}),e("section",{class:"sw-main",children:o?e(Dd,{id:o,onChanged:a.reload},o):r.state==="absent"?e(Md,{o:r,onCreated:a.reload}):e(Ld,{o:r})})]})]})}function Pd(){let[t,n]=_(!1),s=G(()=>O("/api/doctor",{fix:t?1:void 0}),[t]),a=(s.data??[]).filter(r=>!r.ok).length;return e(N,{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(U,{}):s.data?a?e("span",{class:"bad",children:[a," problem",a>1?"s":""]}):e("span",{class:"ok",children:"all checks pass"}):""})]}),s.error?e(Z,{error:s.error}):e("div",{class:"card flush",children:e("table",{children:e("tbody",{children:(s.data??[]).map(r=>e("tr",{children:[e("td",{class:M(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})]}))})})})]})}function Nd({onChanged:t}){let[n,s]=_([]),[a,r]=_(null),[i,o]=_("all"),[l,c]=_(!1),[d,u]=_(""),[m,g]=_(""),[f,k]=_("index"),[h,p]=_(""),b=G(()=>O("/api/stats"),[]),y=async(w,S)=>{r(w);let T=new Date().toLocaleTimeString();s(x=>[...x,`[${T}] ${w} \u2026`]);try{let x=await fe("/api/actions",S);s($=>[...$,`${x.ok?"\u2713":"\u2717"} ${w} (${x.ms} ms)
89
+ ${x.output}`]),x.ok?Q(`${w} done`):Q(x.output.split(`
90
+ `)[0]??"failed",!0),t()}catch(x){s($=>[...$,`\u2717 ${w} failed: ${x.message}`]),Q(x.message,!0)}finally{r(null)}},v=({label:w,body:S,cls:T})=>e("button",{type:"button",class:T??"primary",disabled:!!a,onClick:()=>y(w,S),children:a===w?e(U,{}):w});return e(N,{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(v,{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:m,onInput:w=>g(w.target.value)}),e("button",{type:"button",class:"primary",disabled:!!a||!d.trim(),onClick:()=>y("index",{action:"index",path:d,glob:m}),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(v,{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(v,{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:f,onChange:w=>k(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=>p(w.target.value)}),e("button",{type:"button",class:"danger",disabled:!!a||h.trim()!=="purge",onClick:()=>{p(""),y(`purge ${f}`,{action:"purge",scope:f,confirm:!0})},children:"Purge"}),e(v,{label:"empty fetch cache",body:{action:"purge-fetch-cache"},cls:""})]})]}),e("div",{class:"card",children:[e("h3",{children:"server"}),b.data?e(Ke,{rows:[["project",b.data.project],["database",b.data.dbPath],["routing",b.data.routing]]}):e(U,{})]})]}),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(`
84
91
 
85
- `):"ready."})]})]})}function cc(){let t=G(()=>H("/api/runs"),[]);return t.error?e(Z,{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:ne(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:L("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(B,{})}function ea({onChanged:t}){let[n,s]=_("actions");return e("div",{class:"page",children:[e(we,{tabs:[["actions","Actions"],["doctor","Doctor"],["runs","Index runs"]],value:n,onChange:s}),n==="actions"&&e(lc,{onChanged:t}),n==="doctor"&&e(oc,{}),n==="runs"&&e(cc,{})]})}function _e(t,n,s,i={}){return{input:t,output:n,cacheWrite5m:t*1.25,cacheWrite1h:t*2,cacheRead:s,webSearch:10,...i}}var fh=_e(10,50,.25),bh=_e(10,50,1),yh=_e(4,20,.2),vh=_e(5,25,.5),kh=_e(5,25,.5),xh=_e(15,75,1.5),wh=_e(2,10,.1),_h=_e(2,10,.2),Sh=_e(3,15,.3),Th=_e(.1,.5,.01,{longContext:{threshold:1e5,input:.5,output:2.5}}),Eh=_e(1,5,.1),Ch=_e(.8,4,.08);function ta(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 i=s.toFixed(2);return Number(i)>=1e3?`${n}$${Math.round(s).toLocaleString("en-US")}`:`${n}$${i}`}var dc={calls:0,input:0,output:0,cacheCreate5m:0,cacheCreate1h:0,cacheRead:0,thinking:0,costUsd:0,unpricedCalls:0,cacheHitRate:0,models:{}},sa={opus:[263,84,58],sonnet:[221,83,53],haiku:[142,76,36],fable:[347,77,50],other:[220,9,46]},ra=[220,9,46],uc=["opus","sonnet","haiku","fable","mythos"];function ia(t){let n=t.toLowerCase();for(let s of uc)if(n.includes(s))return s==="mythos"?"fable":s;return"other"}var aa=([t,n,s])=>`hsl(${t} ${n}% ${s}%)`;function oa(t){return aa(sa[ia(t)]??ra)}function la(t){let n=new Map;for(let i of new Set(t)){let r=ia(i),a=n.get(r);a?a.push(i):n.set(r,[i])}let s=new Map;for(let[i,r]of n){let[a,o,l]=sa[i]??ra;r.sort();let c=r.length,d=c>1?Math.min(14,40/(c-1)):0;r.forEach((p,m)=>{let g=Math.max(28,Math.min(72,l+(m-(c-1)/2)*d));s.set(p,aa([a,o,Math.round(g)]))})}return s}var ht=t=>t.replace(/^claude-/,"").replace(/-\d{8}(\[1m\])?$/,"$1"),na=t=>String(t).padStart(2,"0"),pc=t=>`${t.getFullYear()}-${na(t.getMonth()+1)}-${na(t.getDate())}`;function ca(t,n,s=Date.now()){let i=new Map(t.map(c=>[c.key,c])),r=new Date(s),a=new Date(r.getFullYear(),r.getMonth(),r.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<a&&(a=c)}let l=[];for(let c=a,d=0;c<=r&&d<400;c=new Date(c.getFullYear(),c.getMonth(),c.getDate()+1),d+=1){let p=pc(c);l.push(i.get(p)??{key:p,totals:dc,models:[]}),i.delete(p)}for(let c of t)i.has(c.key)&&l.push(c);return l}var ce=t=>ta(t??0),ws=t=>new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),da=t=>new Date(t).toISOString().slice(11,16),ua=[["7d","7 days"],["30d","30 days"],["90d","90 days"]],mc={"7d":7,"30d":30,"90d":90};function hc({s:t}){return e("span",{class:L("tag",`sev-${t}`),children:t})}function gc({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:L(n>=70?"ok":n>=40?"warn":"bad"),children:n})]}),e("span",{class:"scorebar",children:e("i",{class:L(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 pa({items:t,empty:n}){return t.length?e("div",{class:"insights",children:t.map(s=>e("div",{class:L("insight",s.severity),children:[e("div",{class:"row tight",children:[e(hc,{s:s.severity}),e("b",{children:s.title}),e("span",{class:"spacer"}),s.estimatedSavingsUsd?e("span",{class:"muted small",children:["\u2248 ",ce(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,{children:n})}function fc({rows:t,models:n,color:s}){let[i,r]=Tt(),a=170,o={l:48,r:8,t:8,b:22},l=Math.max(10,r-o.l-o.r),c=a-o.t-o.b,d=t.length,p=d?l/d:l,m=p>=6?2:p>=3?1:0,g=Math.max(.01,...t.map(b=>b.totals.costUsd)),f=b=>o.t+c-b/g*c,[x,h]=_(null),u=Math.max(1,Math.ceil(d/Math.max(2,l/70))),y=x!==null?t[x]:void 0;return e("div",{class:"hist-chart usage-chart",ref:i,children:[e("svg",{width:r,height:a,onMouseMove:b=>{let v=b.currentTarget.getBoundingClientRect(),k=Math.floor((b.clientX-v.left-o.l)/p);h(k>=0&&k<d?k:null)},onMouseLeave:()=>h(null),children:[e("title",{children:"cost per day by model"}),[0,.5,1].map(b=>e("g",{children:[e("line",{x1:o.l,x2:r-o.r,y1:f(g*b),y2:f(g*b),class:"grid"}),e("text",{x:o.l-6,y:f(g*b)+3,class:"axis","text-anchor":"end",children:ce(g*b)})]})),t.map((b,v)=>v%u===0?e("text",{x:o.l+v*p,y:a-6,class:"axis",children:b.key.slice(5)}):null),t.map((b,v)=>{let k=0;return e("g",{opacity:x!==null&&x!==v?.55:1,children:[n.map(S=>{let E=b.models.find(R=>R.model===S)?.costUsd??0;if(!E)return null;let w=f(k+E),C=f(k);return k+=E,e("rect",{x:o.l+v*p+m/2,y:w,width:Math.max(.5,p-m),height:Math.max(0,C-w),fill:s(S),rx:p>=6?1.5:0})}),b.totals.unpricedCalls&&!b.totals.costUsd?e("rect",{x:o.l+v*p+m/2,y:o.t+c-3,width:Math.max(.5,p-m),height:3,fill:"#6b7280"}):null]})})]}),y?e("div",{class:"tip",style:{left:Math.min(r-220,o.l+x*p+10),top:4},children:[e("b",{children:y.key})," \xB7 ",y.totals.calls," calls \xB7 ",ce(y.totals.costUsd),y.totals.unpricedCalls?` \xB7 ${y.totals.unpricedCalls} unpriced`:"",e("div",{class:"row tight",style:{marginTop:4,flexWrap:"wrap"},children:y.models.map(b=>e("span",{class:"kdot-lbl",children:[e("i",{class:"kdot",style:{background:s(b.model)}}),ht(b.model)," ",ce(b.costUsd)]}))})]}):null]})}function bc({points:t,color:n}){let[s,i]=Tt(),r=170,a={l:48,r:8,t:8,b:22},o=Math.max(10,i-a.l-a.r),l=r-a.t-a.b,c=t.length,d=Math.max(1e3,...t.map(u=>u.contextTokens)),p=u=>a.l+(c>1?u/(c-1)*o:o/2),m=u=>a.t+l-u/d*l,[g,f]=_(null),x=g!==null?t[g]:void 0,h=t.map((u,y)=>`${y?"L":"M"}${p(y)},${m(u.contextTokens)}`).join(" ");return e("div",{class:"hist-chart usage-chart",ref:s,children:[e("svg",{width:i,height:r,onMouseMove:u=>{let y=u.currentTarget.getBoundingClientRect(),b=u.clientX-y.left-a.l,v=c>1?Math.round(b/o*(c-1)):0;f(v>=0&&v<c?v:null)},onMouseLeave:()=>f(null),children:[e("title",{children:"context tokens per API call, with compactions"}),[0,.5,1].map(u=>e("g",{children:[e("line",{x1:a.l,x2:i-a.r,y1:m(d*u),y2:m(d*u),class:"grid"}),e("text",{x:a.l-6,y:m(d*u)+3,class:"axis","text-anchor":"end",children:J(d*u)})]})),t.map((u,y)=>u.compactBefore?e("g",{children:[e("line",{x1:p(y),x2:p(y),y1:a.t,y2:a.t+l,class:"compact"}),e("text",{x:p(y)+3,y:a.t+10,class:"axis",children:"compact"})]}):null),e("path",{d:h,class:"line"}),t.map((u,y)=>e("circle",{cx:p(y),cy:m(u.contextTokens),r:g===y?4:2.2,fill:n(u.model),class:"dot"})),c?e("text",{x:a.l,y:r-6,class:"axis",children:ws(t[0].ts)}):null,c>1?e("text",{x:i-a.r,y:r-6,class:"axis","text-anchor":"end",children:ws(t[c-1].ts)}):null]}),x?e("div",{class:"tip",style:{left:Math.min(i-240,p(g)+10),top:4},children:[e("b",{children:ws(x.ts)})," \xB7 ",ht(x.model),e("div",{class:"muted",children:["context ",J(x.contextTokens)," \xB7 output ",J(x.output)," \xB7 ",ce(x.costUsd),x.compactBefore?" \xB7 compacted before this call":""]})]}):null]})}function yc({rows:t,color:n}){let{sorted:s,th:i}=He(t,"costUsd");return e("table",{children:[e("thead",{children:e("tr",{children:[i("model","model"),i("calls","calls",!0),i("costUsd","cost",!0),i("share","share",!0),i("input","in",!0),i("output","out",!0),i("cacheRead","cache rd",!0),i("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)}})," ",ht(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:ce(r.costUsd)}),e("td",{class:"num",children:Te(r.share)}),e("td",{class:"num",children:J(r.input)}),e("td",{class:"num",children:J(r.output)}),e("td",{class:"num",children:J(r.cacheRead)}),e("td",{class:"num",children:J(r.cacheWrite)})]})):e("tr",{children:e("td",{class:"muted",colSpan:8,children:"no API calls in this range"})})})]})}function vc({rows:t}){let n=Math.max(1,...t.map(s=>s.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:"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:J(s.estTokens)}),e("td",{class:"num",children:J(s.avgChars)}),e("td",{class:L("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 kc({rows:t,color:n}){return 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,{children:"active"}):null]}),e("td",{class:"nowrap muted",children:[da(s.firstCall),"\u2013",da(s.lastCall)]}),e("td",{class:"num",children:s.calls}),e("td",{class:"num",children:ce(s.costUsd)}),e("td",{class:"num",children:J(s.tokens.input+s.tokens.output+s.tokens.cacheCreate+s.tokens.cacheRead)}),e("td",{children:s.models.map(i=>e("span",{class:"kdot-lbl",children:[e("i",{class:"kdot",style:{background:n(i)}}),ht(i)]}))})]})):e("tr",{children:e("td",{class:"muted",colSpan:6,children:"no blocks in this range"})})})]})}function ma({params:t}){let n=ua.find(([u])=>u===t.range)?.[0]??"30d",[s,i]=_(t.session??null);j(()=>{i(t.session??null)},[t.session]);let r=G(async()=>{let u=C=>H("/api/usage",{view:C,since:n,limit:30}),[y,b,v,k,S,E,w]=await Promise.all([u("summary"),u("daily"),u("models"),u("blocks"),u("tools"),u("sessions"),u("insights")]);return{summary:y,daily:b,models:v,blocks:k,tools:S,sessions:E,insights:w}},[n]);j(()=>{let u=r.data;if(s||!u)return;let b=u.sessions.rows.find(v=>v.session===u.summary.sessionId)??u.sessions.rows[0];b&&i(b.session)},[r.data,s]);let a=G(()=>s?H("/api/usage/session",{id:s}):Promise.resolve(void 0),[s]),o=K(()=>{let u=new Map;for(let y of r.data?.daily.rows??[])for(let b of y.models)u.set(b.model,(u.get(b.model)??0)+b.costUsd);return[...u.entries()].sort((y,b)=>b[1]-y[1]).map(([y])=>y)},[r.data]),l=K(()=>ca(r.data?.daily.rows??[],mc[n]??30),[r.data,n]),c=K(()=>{let u=r.data,y=[...o,...u?.models.rows.map(b=>b.model)??[],...u?.blocks.rows.flatMap(b=>b.models)??[],...a.data?.timeline.map(b=>b.model)??[]];return la(y)},[r.data,o,a.data]),d=u=>c.get(u)??oa(u);if(r.error)return e("div",{class:"page",children:e(Z,{error:r.error})});let p=r.data;if(!p)return e("div",{class:"page",children:e(B,{})});let m=p.summary,g=m.snapshot,f=a.data?.totals,x=[["today",ce(m.today.costUsd),`${m.today.calls} calls \xB7 ${Te(m.today.cacheHitRate)} cache hits`],["last 7 days",ce(m.last7d.costUsd),`${m.last7d.calls} calls \xB7 30d ${ce(m.last30d.costUsd)}`],["session",ce(f?.costUsd??0),s?`${s.slice(0,8)} \xB7 ${f?.calls??0} calls`:"no session selected"],["cache hit rate",Te(m.cache.hitRate),`${J(m.cache.cacheReads)} read \xB7 ${J(m.cache.cacheWrites)} written \xB7 ${m.cache.coldCalls} cold`],["burn rate",m.block?m.burn.reliable?`${ce(m.burn.usdPerHour)}/h`:"n/a":"idle",m.block?m.burn.reliable?`block ${ce(m.block.costUsd)} \u2192 ${ce(m.burn.projectedBlockUsd)} projected`:`block ${ce(m.block.costUsd)} \xB7 too few calls or minutes to project`:"no calls in the current 5-hour block"],["plan use",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",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 ${ne(g.ts)}`:"statusline snapshots carry plan limits for subscribers"]],h=(u,y=n)=>O("usage",{session:u??void 0,range:y});return e("div",{class:"page",children:[m.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(we,{tabs:ua,value:n,onChange:u=>h(s,u)}),e("span",{class:"spacer"}),e("span",{class:"muted small",children:[m.totals.calls," calls \xB7 ",ce(m.totals.costUsd)," in range",m.totals.unpricedCalls?e("span",{class:"warn",children:[" ","\xB7 ",m.totals.unpricedCalls," unpriced (see config.usage.pricing)"]}):null," \xB7 estimates at list price"]})]}),e("div",{class:"grid",children:x.map(([u,y,b])=>e("div",{class:"card",children:[e("h3",{children:u}),e("div",{class:"big",children:y}),e("div",{class:"sub",children:b})]}))}),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(u=>e("span",{class:"kdot-lbl",children:[e("i",{class:"kdot",style:{background:d(u)}}),ht(u)]}))})]}),p.daily.rows.length?e(fc,{rows:l,models:o,color:d}):e(X,{children:"no API calls in this range"})]}),e("div",{class:"card",children:[e("h3",{children:"scores"}),m.scores.length?m.scores.map(u=>e(gc,{s:u})):e(X,{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:u=>h(u.target.value||null),children:[s?null:e("option",{value:"",children:"pick a session"}),p.sessions.rows.map(u=>e("option",{value:u.session,children:[u.session.slice(0,8)," \xB7 ",ne(u.lastCall)," \xB7 ",ce(u.totals.costUsd),u.session===m.sessionId?" \xB7 current":""]})),s&&!p.sessions.rows.some(u=>u.session===s)?e("option",{value:s,children:s.slice(0,8)}):null]})})]}),a.error?e(Z,{error:a.error}):a.data?.timeline.length?e(N,{children:[e(bc,{points:a.data.timeline,color:d}),e("div",{class:"muted small",children:[a.data.timeline.length," calls \xB7 ",a.data.contextEvents.length," compaction",a.data.contextEvents.length===1?"":"s"," \xB7"," ",ce(a.data.totals.costUsd)," \xB7 ",Te(a.data.totals.cacheHitRate)," cache hits \xB7 times local"]})]}):s?e(X,{children:a.loading?e(B,{}):"no API calls recorded for this session"}):e(X,{children:"no sessions with API calls yet"})]}),e("div",{class:"card",children:[e("h3",{children:"session insights"}),e(pa,{items:a.data?.insights.filter(u=>u.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(yc,{rows:p.models.rows,color:d})]}),e("div",{class:"card",children:[e("h3",{children:["tool results in context",e("span",{class:"right",children:[J(Math.ceil(p.tools.totalChars/4))," est. tokens"]})]}),e(vc,{rows:p.tools.rows})]})]}),e("div",{class:"grid two",children:[e("div",{class:"card",children:[e("h3",{children:["insights ",e("span",{class:"right",children:p.insights.insights.length})]}),e(pa,{items:p.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:ce(m.savings.directUsd)}),e("div",{class:"sub",children:["direct \xB7 ",J(m.savings.savedTokens)," tokens never written to cache"]})]}),e("div",{children:[e("div",{class:"big",children:ce(m.savings.compoundingUsd)}),e("div",{class:"sub",children:["compounding \xB7 re-read on ",m.savings.laterCallsPerSession.toFixed(1)," later calls per session"]})]})]}),e("ul",{class:"reasons",children:m.savings.assumptions.map(u=>e("li",{children:u}))})]})]}),e("div",{class:"grid",children:e("div",{class:"card",style:{gridColumn:"1 / -1"},children:[e("h3",{children:["5-hour billing blocks",p.blocks.rows.some(u=>u.active)?e("span",{class:"right",children:p.blocks.burn.reliable?`${ce(p.blocks.burn.usdPerHour)}/h \xB7 ${J(Math.round(p.blocks.burn.tokensPerMin))} tok/min`:"burn rate n/a"}):null]}),e(kc,{rows:p.blocks.rows,color:d})]})})]})}var xc=[["overview","Overview"],["usage","Usage"],["explore","Explore"],["galaxy","Galaxy"],["architecture","Architecture"],["history","History"],["memory","Memory"],["docs","Docs"],["coverage","Coverage"],["sessions","Sessions"],["system","System"]],wc=new Set(["explore","galaxy"]);function _c(){try{let t=localStorage.getItem("eminiar.theme");return t==="light"||t==="dark"?t:"auto"}catch{return"auto"}}function Sc(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 ha(){let t=dr(),[n,s]=_(_c),[i,r]=_(0),[a,o]=_(On),l=f=>{nr(f),o(f)},c=G(()=>H("/api/projects"),[i]),d=G(()=>H("/api/status"),[t.view,i,a]);j(()=>{c.data&&!On()&&l(c.data.current)},[c.data]),j(()=>{let f=setInterval(()=>r(x=>x+1),45e3);return()=>clearInterval(f)},[]);let p=[...new Set([c.data?.current,...c.data?.projects.map(f=>f.root)??[]].filter(Boolean))],m=d.data,g=t.view;return e(N,{children:[e("header",{class:"top",children:[e("div",{class:"brand",children:[e("span",{children:"em"}),"iniar",e("small",{children:m?.version?`v${m.version}`:""})]}),e("nav",{class:"tabs",children:xc.map(([f,x])=>e("button",{type:"button",class:L(g===f&&"active"),onClick:()=>O(f),children:x}))}),e("span",{class:"spacer"}),e("span",{class:"small nowrap",title:m?`${m.graph.nodes} nodes \xB7 ${m.freshness.dirty.length} changed \xB7 ${m.freshness.queued} queued`:"",children:[e("i",{class:L("dot",m?.state)}),m?m.state==="empty"?"no graph":m.state==="stale"?"index stale":"index fresh":"\u2026"]}),e("button",{type:"button",class:"ghost sm",title:"theme",onClick:()=>{let f=n==="auto"?"dark":n==="dark"?"light":"auto";s(f),Sc(f)},children:n==="auto"?"\u25D0 auto":n==="dark"?"\u25CF dark":"\u25CB light"}),e("select",{class:"project",title:a,value:a,onChange:f=>{l(f.target.value),r(x=>x+1)},children:p.map(f=>e("option",{value:f,children:f.split("/").slice(-2).join("/")}))})]}),e("main",{class:L("work",wc.has(g)&&"fill"),children:[g==="overview"&&e(Yi,{}),g==="usage"&&e(ma,{params:t.params}),g==="explore"&&e(ci,{params:t.params}),g==="galaxy"&&e(di,{params:t.params}),g==="architecture"&&e(Jr,{params:t.params}),g==="history"&&e(_i,{params:t.params}),g==="memory"&&e(Vi,{params:t.params}),g==="docs"&&e(ri,{params:t.params}),g==="coverage"&&e(Kr,{}),g==="sessions"&&e(Qi,{}),g==="system"&&e(ea,{onChanged:()=>r(f=>f+1)})]},a),e("footer",{class:"status",children:[e("span",{children:["server ",e("b",{class:"ok",children:"ready"})]}),m&&e(N,{children:[e("span",{children:[e("b",{children:m.graph.nodes})," nodes \xB7 ",e("b",{children:m.graph.edges})," edges"]}),e("span",{children:["files: ",e("b",{children:m.files.byStatus.indexed??0})," indexed",m.files.byStatus.partial?` \xB7 ${m.files.byStatus.partial} partial`:"",m.files.byStatus.skipped?` \xB7 ${m.files.byStatus.skipped} skipped`:""]}),e("span",{children:["git ",m.freshness.head?.slice(0,7)??"n/a",m.freshness.indexedHead&&m.freshness.indexedHead!==m.freshness.head?` (signals at ${m.freshness.indexedHead.slice(0,7)})`:""]}),e("span",{children:["last index ",m.freshness.lastRun?ne(m.freshness.lastRun):"never"]})]}),e("span",{class:"spacer"}),e("span",{class:"ellipsis",children:a})]}),e(or,{})]})}var ga=document.getElementById("app");ga&&js(e(ha,{}),ga);})();
92
+ `):"ready."})]})]})}function Od(){let t=G(()=>O("/api/runs"),[]);return t.error?e(Z,{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:re(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:M("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(U,{})}function Ui({onChanged:t}){let[n,s]=_("actions");return e("div",{class:"page",children:[e(Ce,{tabs:[["actions","Actions"],["doctor","Doctor"],["runs","Index runs"]],value:n,onChange:s}),n==="actions"&&e(Nd,{onChanged:t}),n==="doctor"&&e(Pd,{}),n==="runs"&&e(Od,{})]})}function Ae(t,n,s,a={}){return{input:t,output:n,cacheWrite5m:t*1.25,cacheWrite1h:t*2,cacheRead:s,webSearch:10,...a}}var Wf=Ae(10,50,.25),Jf=Ae(10,50,1),qf=Ae(4,20,.2),Kf=Ae(5,25,.5),Vf=Ae(5,25,.5),Zf=Ae(15,75,1.5),Yf=Ae(2,10,.1),Qf=Ae(2,10,.2),eb=Ae(3,15,.3),tb=Ae(.1,.5,.01,{longContext:{threshold:1e5,input:.5,output:2.5}}),nb=Ae(1,5,.1),sb=Ae(.8,4,.08);function ji(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 Hd={calls:0,input:0,output:0,cacheCreate5m:0,cacheCreate1h:0,cacheRead:0,thinking:0,costUsd:0,unpricedCalls:0,cacheHitRate:0,models:{}},Xi={opus:[263,84,58],sonnet:[221,83,53],haiku:[142,76,36],fable:[347,77,50],other:[220,9,46]},Gi=[220,9,46],Bd=["opus","sonnet","haiku","fable","mythos"];function Wi(t){let n=t.toLowerCase();for(let s of Bd)if(n.includes(s))return s==="mythos"?"fable":s;return"other"}var Ji=([t,n,s])=>`hsl(${t} ${n}% ${s}%)`;function qi(t){return Ji(Xi[Wi(t)]??Gi)}function Ki(t){let n=new Map;for(let a of new Set(t)){let r=Wi(a),i=n.get(r);i?i.push(a):n.set(r,[a])}let s=new Map;for(let[a,r]of n){let[i,o,l]=Xi[a]??Gi;r.sort();let c=r.length,d=c>1?Math.min(14,40/(c-1)):0;r.forEach((u,m)=>{let g=Math.max(28,Math.min(72,l+(m-(c-1)/2)*d));s.set(u,Ji([i,o,Math.round(g)]))})}return s}var $t=t=>t.replace(/^claude-/,"").replace(/-\d{8}(\[1m\])?$/,"$1"),zi=t=>String(t).padStart(2,"0"),Ud=t=>`${t.getFullYear()}-${zi(t.getMonth()+1)}-${zi(t.getDate())}`;function Vi(t,n,s=Date.now()){let a=new Map(t.map(c=>[c.key,c])),r=new Date(s),i=new Date(r.getFullYear(),r.getMonth(),r.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<=r&&d<400;c=new Date(c.getFullYear(),c.getMonth(),c.getDate()+1),d+=1){let u=Ud(c);l.push(a.get(u)??{key:u,totals:Hd,models:[]}),a.delete(u)}for(let c of t)a.has(c.key)&&l.push(c);return l}var ue=t=>ji(t??0),Xs=t=>new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),Zi=t=>new Date(t).toISOString().slice(11,16),Yi=[["7d","7 days"],["30d","30 days"],["90d","90 days"]],jd={"7d":7,"30d":30,"90d":90};function zd({s:t}){return e("span",{class:M("tag",`sev-${t}`),children:t})}function Xd({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:M(n>=70?"ok":n>=40?"warn":"bad"),children:n})]}),e("span",{class:"scorebar",children:e("i",{class:M(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 Qi({items:t,empty:n}){return t.length?e("div",{class:"insights",children:t.map(s=>e("div",{class:M("insight",s.severity),children:[e("div",{class:"row tight",children:[e(zd,{s:s.severity}),e("b",{children:s.title}),e("span",{class:"spacer"}),s.estimatedSavingsUsd?e("span",{class:"muted small",children:["\u2248 ",ue(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(J,{children:n})}function Gd({rows:t,models:n,color:s}){let[a,r]=Ot(),i=170,o={l:48,r:8,t:8,b:22},l=Math.max(10,r-o.l-o.r),c=i-o.t-o.b,d=t.length,u=d?l/d:l,m=u>=6?2:u>=3?1:0,g=Math.max(.01,...t.map(y=>y.totals.costUsd)),f=y=>o.t+c-y/g*c,[k,h]=_(null),p=Math.max(1,Math.ceil(d/Math.max(2,l/70))),b=k!==null?t[k]:void 0;return e("div",{class:"hist-chart usage-chart",ref:a,children:[e("svg",{width:r,height:i,onMouseMove:y=>{let v=y.currentTarget.getBoundingClientRect(),w=Math.floor((y.clientX-v.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(y=>e("g",{children:[e("line",{x1:o.l,x2:r-o.r,y1:f(g*y),y2:f(g*y),class:"grid"}),e("text",{x:o.l-6,y:f(g*y)+3,class:"axis","text-anchor":"end",children:ue(g*y)})]})),t.map((y,v)=>v%p===0?e("text",{x:o.l+v*u,y:i-6,class:"axis",children:y.key.slice(5)}):null),t.map((y,v)=>{let w=0;return e("g",{opacity:k!==null&&k!==v?.55:1,children:[n.map(S=>{let T=y.models.find(A=>A.model===S)?.costUsd??0;if(!T)return null;let x=f(w+T),$=f(w);return w+=T,e("rect",{x:o.l+v*u+m/2,y:x,width:Math.max(.5,u-m),height:Math.max(0,$-x),fill:s(S),rx:u>=6?1.5:0})}),y.totals.unpricedCalls&&!y.totals.costUsd?e("rect",{x:o.l+v*u+m/2,y:o.t+c-3,width:Math.max(.5,u-m),height:3,fill:"#6b7280"}):null]})})]}),b?e("div",{class:"tip",style:{left:Math.min(r-220,o.l+k*u+10),top:4},children:[e("b",{children:b.key})," \xB7 ",b.totals.calls," calls \xB7 ",ue(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(y=>e("span",{class:"kdot-lbl",children:[e("i",{class:"kdot",style:{background:s(y.model)}}),$t(y.model)," ",ue(y.costUsd)]}))})]}):null]})}function Wd({points:t,color:n}){let[s,a]=Ot(),r=170,i={l:48,r:8,t:8,b:22},o=Math.max(10,a-i.l-i.r),l=r-i.t-i.b,c=t.length,d=Math.max(1e3,...t.map(p=>p.contextTokens)),u=p=>i.l+(c>1?p/(c-1)*o:o/2),m=p=>i.t+l-p/d*l,[g,f]=_(null),k=g!==null?t[g]:void 0,h=t.map((p,b)=>`${b?"L":"M"}${u(b)},${m(p.contextTokens)}`).join(" ");return e("div",{class:"hist-chart usage-chart",ref:s,children:[e("svg",{width:a,height:r,onMouseMove:p=>{let b=p.currentTarget.getBoundingClientRect(),y=p.clientX-b.left-i.l,v=c>1?Math.round(y/o*(c-1)):0;f(v>=0&&v<c?v:null)},onMouseLeave:()=>f(null),children:[e("title",{children:"context tokens per API call, with compactions"}),[0,.5,1].map(p=>e("g",{children:[e("line",{x1:i.l,x2:a-i.r,y1:m(d*p),y2:m(d*p),class:"grid"}),e("text",{x:i.l-6,y:m(d*p)+3,class:"axis","text-anchor":"end",children:q(d*p)})]})),t.map((p,b)=>p.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((p,b)=>e("circle",{cx:u(b),cy:m(p.contextTokens),r:g===b?4:2.2,fill:n(p.model),class:"dot"})),c?e("text",{x:i.l,y:r-6,class:"axis",children:Xs(t[0].ts)}):null,c>1?e("text",{x:a-i.r,y:r-6,class:"axis","text-anchor":"end",children:Xs(t[c-1].ts)}):null]}),k?e("div",{class:"tip",style:{left:Math.min(a-240,u(g)+10),top:4},children:[e("b",{children:Xs(k.ts)})," \xB7 ",$t(k.model),e("div",{class:"muted",children:["context ",q(k.contextTokens)," \xB7 output ",q(k.output)," \xB7 ",ue(k.costUsd),k.compactBefore?" \xB7 compacted before this call":""]})]}):null]})}function Jd({rows:t,color:n}){let{sorted:s,th:a}=Ve(t,"costUsd");return 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)}})," ",$t(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:ue(r.costUsd)}),e("td",{class:"num",children:Fe(r.share)}),e("td",{class:"num",children:q(r.input)}),e("td",{class:"num",children:q(r.output)}),e("td",{class:"num",children:q(r.cacheRead)}),e("td",{class:"num",children:q(r.cacheWrite)})]})):e("tr",{children:e("td",{class:"muted",colSpan:8,children:"no API calls in this range"})})})]})}function qd({rows:t}){let n=Math.max(1,...t.map(s=>s.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:"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:M("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 Kd({rows:t,color:n}){return 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:[Zi(s.firstCall),"\u2013",Zi(s.lastCall)]}),e("td",{class:"num",children:s.calls}),e("td",{class:"num",children:ue(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(a=>e("span",{class:"kdot-lbl",children:[e("i",{class:"kdot",style:{background:n(a)}}),$t(a)]}))})]})):e("tr",{children:e("td",{class:"muted",colSpan:6,children:"no blocks in this range"})})})]})}function eo({params:t}){let n=Yi.find(([p])=>p===t.range)?.[0]??"30d",[s,a]=_(t.session??null);j(()=>{a(t.session??null)},[t.session]);let r=G(async()=>{let p=$=>O("/api/usage",{view:$,since:n,limit:30}),[b,y,v,w,S,T,x]=await Promise.all([p("summary"),p("daily"),p("models"),p("blocks"),p("tools"),p("sessions"),p("insights")]);return{summary:b,daily:y,models:v,blocks:w,tools:S,sessions:T,insights:x}},[n]);j(()=>{let p=r.data;if(s||!p)return;let y=p.sessions.rows.find(v=>v.session===p.summary.sessionId)??p.sessions.rows[0];y&&a(y.session)},[r.data,s]);let i=G(()=>s?O("/api/usage/session",{id:s}):Promise.resolve(void 0),[s]),o=V(()=>{let p=new Map;for(let b of r.data?.daily.rows??[])for(let y of b.models)p.set(y.model,(p.get(y.model)??0)+y.costUsd);return[...p.entries()].sort((b,y)=>y[1]-b[1]).map(([b])=>b)},[r.data]),l=V(()=>Vi(r.data?.daily.rows??[],jd[n]??30),[r.data,n]),c=V(()=>{let p=r.data,b=[...o,...p?.models.rows.map(y=>y.model)??[],...p?.blocks.rows.flatMap(y=>y.models)??[],...i.data?.timeline.map(y=>y.model)??[]];return Ki(b)},[r.data,o,i.data]),d=p=>c.get(p)??qi(p);if(r.error)return e("div",{class:"page",children:e(Z,{error:r.error})});let u=r.data;if(!u)return e("div",{class:"page",children:e(U,{})});let m=u.summary,g=m.snapshot,f=i.data?.totals,k=[["today",ue(m.today.costUsd),`${m.today.calls} calls \xB7 ${Fe(m.today.cacheHitRate)} cache hits`],["last 7 days",ue(m.last7d.costUsd),`${m.last7d.calls} calls \xB7 30d ${ue(m.last30d.costUsd)}`],["session",ue(f?.costUsd??0),s?`${s.slice(0,8)} \xB7 ${f?.calls??0} calls`:"no session selected"],["cache hit rate",Fe(m.cache.hitRate),`${q(m.cache.cacheReads)} read \xB7 ${q(m.cache.cacheWrites)} written \xB7 ${m.cache.coldCalls} cold`],["burn rate",m.block?m.burn.reliable?`${ue(m.burn.usdPerHour)}/h`:"n/a":"idle",m.block?m.burn.reliable?`block ${ue(m.block.costUsd)} \u2192 ${ue(m.burn.projectedBlockUsd)} projected`:`block ${ue(m.block.costUsd)} \xB7 too few calls or minutes to project`:"no calls in the current 5-hour block"],["plan use",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",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 ${re(g.ts)}`:"statusline snapshots carry plan limits for subscribers"]],h=(p,b=n)=>H("usage",{session:p??void 0,range:b});return e("div",{class:"page",children:[m.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(Ce,{tabs:Yi,value:n,onChange:p=>h(s,p)}),e("span",{class:"spacer"}),e("span",{class:"muted small",children:[m.totals.calls," calls \xB7 ",ue(m.totals.costUsd)," in range",m.totals.unpricedCalls?e("span",{class:"warn",children:[" ","\xB7 ",m.totals.unpricedCalls," unpriced (see config.usage.pricing)"]}):null," \xB7 estimates at list price"]})]}),e("div",{class:"grid",children:k.map(([p,b,y])=>e("div",{class:"card",children:[e("h3",{children:p}),e("div",{class:"big",children:b}),e("div",{class:"sub",children:y})]}))}),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(p=>e("span",{class:"kdot-lbl",children:[e("i",{class:"kdot",style:{background:d(p)}}),$t(p)]}))})]}),u.daily.rows.length?e(Gd,{rows:l,models:o,color:d}):e(J,{children:"no API calls in this range"})]}),e("div",{class:"card",children:[e("h3",{children:"scores"}),m.scores.length?m.scores.map(p=>e(Xd,{s:p})):e(J,{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:p=>h(p.target.value||null),children:[s?null:e("option",{value:"",children:"pick a session"}),u.sessions.rows.map(p=>e("option",{value:p.session,children:[p.session.slice(0,8)," \xB7 ",re(p.lastCall)," \xB7 ",ue(p.totals.costUsd),p.session===m.sessionId?" \xB7 current":""]})),s&&!u.sessions.rows.some(p=>p.session===s)?e("option",{value:s,children:s.slice(0,8)}):null]})})]}),i.error?e(Z,{error:i.error}):i.data?.timeline.length?e(N,{children:[e(Wd,{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"," ",ue(i.data.totals.costUsd)," \xB7 ",Fe(i.data.totals.cacheHitRate)," cache hits \xB7 times local"]})]}):s?e(J,{children:i.loading?e(U,{}):"no API calls recorded for this session"}):e(J,{children:"no sessions with API calls yet"})]}),e("div",{class:"card",children:[e("h3",{children:"session insights"}),e(Qi,{items:i.data?.insights.filter(p=>p.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(Jd,{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(qd,{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(Qi,{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:ue(m.savings.directUsd)}),e("div",{class:"sub",children:["direct \xB7 ",q(m.savings.savedTokens)," tokens never written to cache"]})]}),e("div",{children:[e("div",{class:"big",children:ue(m.savings.compoundingUsd)}),e("div",{class:"sub",children:["compounding \xB7 re-read on ",m.savings.laterCallsPerSession.toFixed(1)," later calls per session"]})]})]}),e("ul",{class:"reasons",children:m.savings.assumptions.map(p=>e("li",{children:p}))})]})]}),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(p=>p.active)?e("span",{class:"right",children:u.blocks.burn.reliable?`${ue(u.blocks.burn.usdPerHour)}/h \xB7 ${q(Math.round(u.blocks.burn.tokensPerMin))} tok/min`:"burn rate n/a"}):null]}),e(Kd,{rows:u.blocks.rows,color:d})]})})]})}var Vd=[["overview","Overview"],["usage","Usage"],["explore","Explore"],["galaxy","Galaxy"],["architecture","Architecture"],["history","History"],["memory","Memory"],["docs","Docs"],["coverage","Coverage"],["sessions","Sessions"],["swarm","Swarms"],["system","System"]],Zd=new Set(["explore","galaxy"]);function Yd(){try{let t=localStorage.getItem("eminiar.theme");return t==="light"||t==="dark"?t:"auto"}catch{return"auto"}}function Qd(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 to(){let t=Mr(),[n,s]=_(Yd),[a,r]=_(0),[i,o]=_(Qn),l=f=>{_r(f),o(f)},c=G(()=>O("/api/projects"),[a]),d=G(()=>O("/api/status"),[t.view,a,i]);j(()=>{c.data&&!Qn()&&l(c.data.current)},[c.data]),j(()=>{let f=setInterval(()=>r(k=>k+1),45e3);return()=>clearInterval(f)},[]);let u=[...new Set([c.data?.current,...c.data?.projects.map(f=>f.root)??[]].filter(Boolean))],m=d.data,g=t.view;return e(N,{children:[e("header",{class:"top",children:[e("div",{class:"brand",children:[e("span",{children:"em"}),"iniar",e("small",{children:m?.version?`v${m.version}`:""})]}),e("nav",{class:"tabs",children:Vd.map(([f,k])=>e("button",{type:"button",class:M(g===f&&"active"),onClick:()=>H(f),children:k}))}),e("span",{class:"spacer"}),e("span",{class:"small nowrap",title:m?`${m.graph.nodes} nodes \xB7 ${m.freshness.dirty.length} changed \xB7 ${m.freshness.queued} queued`:"",children:[e("i",{class:M("dot",m?.state)}),m?m.state==="empty"?"no graph":m.state==="stale"?"index stale":"index fresh":"\u2026"]}),e("button",{type:"button",class:"ghost sm",title:"theme",onClick:()=>{let f=n==="auto"?"dark":n==="dark"?"light":"auto";s(f),Qd(f)},children:n==="auto"?"\u25D0 auto":n==="dark"?"\u25CF dark":"\u25CB light"}),e("select",{class:"project",title:i,value:i,onChange:f=>{l(f.target.value),r(k=>k+1)},children:u.map(f=>e("option",{value:f,children:f.split("/").slice(-2).join("/")}))})]}),e("main",{class:M("work",Zd.has(g)&&"fill"),children:[g==="overview"&&e(vi,{}),g==="usage"&&e(eo,{params:t.params}),g==="explore"&&e(Aa,{params:t.params}),g==="galaxy"&&e(Ma,{params:t.params}),g==="architecture"&&e(ga,{params:t.params}),g==="history"&&e(Xa,{params:t.params}),g==="memory"&&e(bi,{params:t.params}),g==="docs"&&e(Ta,{params:t.params}),g==="coverage"&&e(fa,{}),g==="sessions"&&e(ki,{}),g==="swarm"&&e(Bi,{params:t.params}),g==="system"&&e(Ui,{onChanged:()=>r(f=>f+1)})]},i),e("footer",{class:"status",children:[e("span",{children:["server ",e("b",{class:"ok",children:"ready"})]}),m&&e(N,{children:[e("span",{children:[e("b",{children:m.graph.nodes})," nodes \xB7 ",e("b",{children:m.graph.edges})," edges"]}),e("span",{children:["files: ",e("b",{children:m.files.byStatus.indexed??0})," indexed",m.files.byStatus.partial?` \xB7 ${m.files.byStatus.partial} partial`:"",m.files.byStatus.skipped?` \xB7 ${m.files.byStatus.skipped} skipped`:""]}),e("span",{children:["git ",m.freshness.head?.slice(0,7)??"n/a",m.freshness.indexedHead&&m.freshness.indexedHead!==m.freshness.head?` (signals at ${m.freshness.indexedHead.slice(0,7)})`:""]}),e("span",{children:["last index ",m.freshness.lastRun?re(m.freshness.lastRun):"never"]})]}),e("span",{class:"spacer"}),e("span",{class:"ellipsis",children:i})]}),e(Cr,{})]})}var no=document.getElementById("app");no&&ur(e(to,{}),no);})();
86
93
  /*! Bundled license information:
87
94
 
88
95
  prismjs/prism.js: