@mindflight/mindbrain-personal-studio 0.6.3 → 0.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/build/client/_app/immutable/chunks/BsHs7Gcd.js +1 -0
- package/build/client/_app/immutable/chunks/BsHs7Gcd.js.br +0 -0
- package/build/client/_app/immutable/chunks/BsHs7Gcd.js.gz +0 -0
- package/build/client/_app/immutable/entry/{app.mURYm8o_.js → app.CpAvcJQF.js} +2 -2
- package/build/client/_app/immutable/entry/app.CpAvcJQF.js.br +0 -0
- package/build/client/_app/immutable/entry/app.CpAvcJQF.js.gz +0 -0
- package/build/client/_app/immutable/entry/start.CI2IWrEW.js +1 -0
- package/build/client/_app/immutable/entry/start.CI2IWrEW.js.br +2 -0
- package/build/client/_app/immutable/entry/start.CI2IWrEW.js.gz +0 -0
- package/build/client/_app/immutable/nodes/{1.DHKtMeFI.js → 1.D6NCzfyp.js} +1 -1
- package/build/client/_app/immutable/nodes/1.D6NCzfyp.js.br +1 -0
- package/build/client/_app/immutable/nodes/1.D6NCzfyp.js.gz +0 -0
- package/build/client/_app/immutable/nodes/2.EDmnjbqo.js +9 -0
- package/build/client/_app/immutable/nodes/2.EDmnjbqo.js.br +0 -0
- package/build/client/_app/immutable/nodes/2.EDmnjbqo.js.gz +0 -0
- package/build/client/_app/version.json +1 -1
- package/build/client/_app/version.json.br +0 -0
- package/build/client/_app/version.json.gz +0 -0
- package/build/handler.js +4 -4
- package/build/index.js +4 -4
- package/build/server/chunks/chunks/{graphRepository.js-D2DARfVY.js → graphRepository.js-CmIA6rqA.js} +4 -1
- package/build/server/chunks/chunks/graphRepository.js-CmIA6rqA.js.map +1 -0
- package/build/server/chunks/chunks/{internal.js-C3tV0XXj.js → internal.js-Bx4qge33.js} +2 -2
- package/build/server/chunks/chunks/{internal.js-C3tV0XXj.js.map → internal.js-Bx4qge33.js.map} +1 -1
- package/build/server/chunks/entries/endpoints/api/graph/{_server.ts.js-Bxo7qHVz.js → _server.ts.js-BDrhYCoq.js} +2 -2
- package/build/server/chunks/entries/endpoints/api/graph/{_server.ts.js-Bxo7qHVz.js.map → _server.ts.js-BDrhYCoq.js.map} +1 -1
- package/build/server/chunks/entries/endpoints/api/graph/count/{_server.ts.js-BajaLnqp.js → _server.ts.js-BeCjTntz.js} +2 -2
- package/build/server/chunks/entries/endpoints/api/graph/count/{_server.ts.js-BajaLnqp.js.map → _server.ts.js-BeCjTntz.js.map} +1 -1
- package/build/server/chunks/entries/endpoints/api/graph/gap-rules/_server.ts.js-DduzA_uh.js +68 -0
- package/build/server/chunks/entries/endpoints/api/graph/gap-rules/_server.ts.js-DduzA_uh.js.map +1 -0
- package/build/server/chunks/entries/endpoints/api/graph/ontologies/{_server.ts.js-BFq2mbbX.js → _server.ts.js-K5EkSYpR.js} +2 -2
- package/build/server/chunks/entries/endpoints/api/graph/ontologies/{_server.ts.js-BFq2mbbX.js.map → _server.ts.js-K5EkSYpR.js.map} +1 -1
- package/build/server/chunks/entries/endpoints/api/graph/schema-registry/{_server.ts.js-CAsXxBRq.js → _server.ts.js-B5OTti3s.js} +2 -2
- package/build/server/chunks/entries/endpoints/api/graph/schema-registry/{_server.ts.js-CAsXxBRq.js.map → _server.ts.js-B5OTti3s.js.map} +1 -1
- package/build/server/chunks/{handler-DlaCCnxx.js → handler-Cc3Mp_Ob.js} +3 -3
- package/build/server/chunks/{handler-DlaCCnxx.js.map → handler-Cc3Mp_Ob.js.map} +1 -1
- package/build/server/chunks/{index.js-BGfKWHak.js → index.js-BRvQVgSe.js} +2 -2
- package/build/server/chunks/{index.js-BGfKWHak.js.map → index.js-BRvQVgSe.js.map} +1 -1
- package/build/server/chunks/{manifest.js-CnmaNf5D.js → manifest.js-Bv1A6wIB.js} +15 -8
- package/build/server/chunks/manifest.js-Bv1A6wIB.js.map +1 -0
- package/build/server/chunks/nodes/{1.js-BypjwBYB.js → 1.js-C8oWVl8C.js} +2 -2
- package/build/server/chunks/nodes/{1.js-BypjwBYB.js.map → 1.js-C8oWVl8C.js.map} +1 -1
- package/build/server/chunks/nodes/{2.js-D9-B_qyX.js → 2.js-D2JlHjgb.js} +2 -2
- package/build/server/chunks/nodes/{2.js-D9-B_qyX.js.map → 2.js-D2JlHjgb.js.map} +1 -1
- package/examples/immeuble/scripts/seed-immeuble-gap-rules.mjs +36 -2
- package/package.json +1 -1
- package/scripts/load-immeuble-demo.sh +83 -7
- package/build/client/_app/immutable/chunks/CIErFlYG.js +0 -1
- package/build/client/_app/immutable/chunks/CIErFlYG.js.br +0 -0
- package/build/client/_app/immutable/chunks/CIErFlYG.js.gz +0 -0
- package/build/client/_app/immutable/entry/app.mURYm8o_.js.br +0 -0
- package/build/client/_app/immutable/entry/app.mURYm8o_.js.gz +0 -0
- package/build/client/_app/immutable/entry/start.D4M9ZeGO.js +0 -1
- package/build/client/_app/immutable/entry/start.D4M9ZeGO.js.br +0 -2
- package/build/client/_app/immutable/entry/start.D4M9ZeGO.js.gz +0 -0
- package/build/client/_app/immutable/nodes/1.DHKtMeFI.js.br +0 -1
- package/build/client/_app/immutable/nodes/1.DHKtMeFI.js.gz +0 -0
- package/build/client/_app/immutable/nodes/2.D0pSa9ko.js +0 -9
- package/build/client/_app/immutable/nodes/2.D0pSa9ko.js.br +0 -0
- package/build/client/_app/immutable/nodes/2.D0pSa9ko.js.gz +0 -0
- package/build/server/chunks/chunks/graphRepository.js-D2DARfVY.js.map +0 -1
- package/build/server/chunks/manifest.js-CnmaNf5D.js.map +0 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["../chunks/-OSExkSk.js","../chunks/C5KYKPa8.js","../chunks/BJB7pSge.js","../chunks/i0D5dc1Y.js","../chunks/Gs0cNFYG.js","../chunks/DyXQogav.js","../chunks/Cp9dXlPT.js","../chunks/BP2JbIUZ.js","../chunks/BVrgUHq-.js","../chunks/CBDzfqXr.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{b as Va,a as x,f as D,c as Ft,t as zn}from"../chunks/NXeHtWpC.js";import{a as sa,o as Ka}from"../chunks/BNUkRZqg.js";import{h as dn,P as Pi,i as us,a1 as s,U as $a,ag as Za,V as Ds,w as Lr,v as Xr,e as wr,C as Ua,aE as Wa,ap as Ps,a as dr,c as bi,aM as sr,b as es,aN as Ga,s as Ya,a9 as Xa,aO as Ja,aP as Qa,aH as qa,ad as Is,aQ as eo,a5 as to,r as aa,p as oa,aR as zi,aS as no,aB as ro,m as io,d as so,aD as fs,aT as la,t as ao,x as ca,aU as da,q as oo,aV as lo,aW as co,E as ho,J as uo,aX as fo,K as go,av as ha,W as ua,g as gs,X as vs,aY as vo,aZ as po,a_ as yo,a$ as mo,b0 as ps,aJ as yn,A as Dn,a2 as Ut,u as De,a3 as u,aK as L,D as g,G as b,F as f,B as Pn,aL as me,z as te,aq as Yt,y as qe,b1 as Wr,b2 as di,b3 as hi,b4 as gr,b5 as _o}from"../chunks/BnkCgNCx.js";import{i as bo,s as B,d as Fn,a as Be,e as St}from"../chunks/D0daF8Eh.js";import{p as $,b as ei,i as q,_ as Gn}from"../chunks/nnWk1BBo.js";import{r as Tn,a as An,b as ko,s as On}from"../chunks/DpVrWha3.js";import{B as fa}from"../chunks/D4SoBmS0.js";const wo=Symbol("NaN");function xo(t,e,n){dn&&Pi();var r=new fa(t);us(()=>{var i=e();i!==i&&(i=wo),r.ensure(i,n)})}function Tt(t,e){return e}function Co(t,e,n){for(var r=[],i=e.length,a,o=e.length,l=0;l<i;l++){let p=e[l];oa(p,()=>{if(a){if(a.pending.delete(p),a.done.add(p),a.pending.size===0){var y=t.outrogroups;ts(t,fs(a.done)),y.delete(a),y.size===0&&(t.outrogroups=null)}}else o-=1},!1)}if(o===0){var c=r.length===0&&n!==null;if(c){var d=n,h=d.parentNode;ro(h),h.append(d),t.items.clear()}ts(t,e,!c)}else a={pending:new Set(e),done:new Set},(t.outrogroups??=new Set).add(a)}function ts(t,e,n=!0){var r;if(t.pending.size>0){r=new Set;for(const o of t.pending.values())for(const l of o)r.add(t.items.get(l).e)}for(var i=0;i<e.length;i++){var a=e[i];if(r?.has(a)){a.f|=sr;const o=document.createDocumentFragment();io(a,o)}else so(e[i],n)}}var Ts;function kt(t,e,n,r,i,a=null){var o=t,l=new Map,c=(e&da)!==0;if(c){var d=t;o=dn?Lr(ca(d)):d.appendChild(bi())}dn&&Pi();var h=null,p=Xa(()=>{var j=n();return la(j)?j:j==null?[]:fs(j)}),y,k=new Map,C=!0;function _(j){(O.effect.f&to)===0&&(O.pending.delete(j),O.fallback=h,So(O,y,o,e,r),h!==null&&(y.length===0?(h.f&sr)===0?aa(h):(h.f^=sr,Gr(h,null,o)):oa(h,()=>{h=null})))}function v(j){O.pending.delete(j)}var I=us(()=>{y=s(p);var j=y.length;let K=!1;if(dn){var U=$a(o)===Za;U!==(j===0)&&(o=Ds(),Lr(o),Xr(!1),K=!0)}for(var V=new Set,se=dr,oe=Ya(),ce=0;ce<j;ce+=1){dn&&wr.nodeType===Ua&&wr.data===Wa&&(o=wr,K=!0,Xr(!1));var G=y[ce],N=r(G,ce),W=C?null:l.get(N);W?(W.v&&Ps(W.v,G),W.i&&Ps(W.i,ce),oe&&se.unskip_effect(W.e)):(W=No(l,C?o:Ts??=bi(),G,N,ce,i,e,n),C||(W.e.f|=sr),l.set(N,W)),V.add(N)}if(j===0&&a&&!h&&(C?h=es(()=>a(o)):(h=es(()=>a(Ts??=bi())),h.f|=sr)),j>V.size&&Ga(),dn&&j>0&&Lr(Ds()),!C)if(k.set(se,V),oe){for(const[z,X]of l)V.has(z)||se.skip_effect(X.e);se.oncommit(_),se.ondiscard(v)}else _(se);K&&Xr(!0),s(p)}),O={effect:I,items:l,pending:k,outrogroups:null,fallback:h};C=!1,dn&&(o=wr)}function $r(t){for(;t!==null&&(t.f&no)===0;)t=t.next;return t}function So(t,e,n,r,i){var a=(r&lo)!==0,o=e.length,l=t.items,c=$r(t.effect.first),d,h=null,p,y=[],k=[],C,_,v,I;if(a)for(I=0;I<o;I+=1)C=e[I],_=i(C,I),v=l.get(_).e,(v.f&sr)===0&&(v.nodes?.a?.measure(),(p??=new Set).add(v));for(I=0;I<o;I+=1){if(C=e[I],_=i(C,I),v=l.get(_).e,t.outrogroups!==null)for(const G of t.outrogroups)G.pending.delete(v),G.done.delete(v);if((v.f&zi)!==0&&(aa(v),a&&(v.nodes?.a?.unfix(),(p??=new Set).delete(v))),(v.f&sr)!==0)if(v.f^=sr,v===c)Gr(v,null,n);else{var O=h?h.next:c;v===t.effect.last&&(t.effect.last=v.prev),v.prev&&(v.prev.next=v.next),v.next&&(v.next.prev=v.prev),fr(t,h,v),fr(t,v,O),Gr(v,O,n),h=v,y=[],k=[],c=$r(h.next);continue}if(v!==c){if(d!==void 0&&d.has(v)){if(y.length<k.length){var j=k[0],K;h=j.prev;var U=y[0],V=y[y.length-1];for(K=0;K<y.length;K+=1)Gr(y[K],j,n);for(K=0;K<k.length;K+=1)d.delete(k[K]);fr(t,U.prev,V.next),fr(t,h,U),fr(t,V,j),c=j,h=V,I-=1,y=[],k=[]}else d.delete(v),Gr(v,c,n),fr(t,v.prev,v.next),fr(t,v,h===null?t.effect.first:h.next),fr(t,h,v),h=v;continue}for(y=[],k=[];c!==null&&c!==v;)(d??=new Set).add(c),k.push(c),c=$r(c.next);if(c===null)continue}(v.f&sr)===0&&y.push(v),h=v,c=$r(v.next)}if(t.outrogroups!==null){for(const G of t.outrogroups)G.pending.size===0&&(ts(t,fs(G.done)),t.outrogroups?.delete(G));t.outrogroups.size===0&&(t.outrogroups=null)}if(c!==null||d!==void 0){var se=[];if(d!==void 0)for(v of d)(v.f&zi)===0&&se.push(v);for(;c!==null;)(c.f&zi)===0&&c!==t.fallback&&se.push(c),c=$r(c.next);var oe=se.length;if(oe>0){var ce=(r&da)!==0&&o===0?n:null;if(a){for(I=0;I<oe;I+=1)se[I].nodes?.a?.measure();for(I=0;I<oe;I+=1)se[I].nodes?.a?.fix()}Co(t,se,ce)}}a&&oo(()=>{if(p!==void 0)for(v of p)v.nodes?.a?.apply()})}function No(t,e,n,r,i,a,o,l){var c=(o&Ja)!==0?(o&Qa)===0?qa(n,!1,!1):Is(n):null,d=(o&eo)!==0?Is(i):null;return{v:c,i:d,e:es(()=>(a(e,c??n,d??i,l),()=>{t.delete(r)}))}}function Gr(t,e,n){if(t.nodes)for(var r=t.nodes.start,i=t.nodes.end,a=e&&(e.f&sr)===0?e.nodes.start:n;r!==null;){var o=ao(r);if(a.before(r),r===i)return;r=o}}function fr(t,e,n){e===null?t.effect.first=n:e.next=n,n===null?t.effect.last=e:n.prev=e}function Do(t,e,n,r,i,a){let o=dn;dn&&Pi();var l=null;dn&&wr.nodeType===co&&(l=wr,Pi());var c=dn?wr:t,d=new fa(c,!1);us(()=>{const h=e()||null;var p=h==="svg"?fo:void 0;if(h===null){d.ensure(null,null);return}return d.ensure(h,y=>{if(h){if(l=dn?l:uo(h,p),Va(l,l),r){dn&&bo(h)&&l.append(document.createComment(""));var k=dn?ca(l):l.appendChild(bi());dn&&(k===null?Xr(!1):Lr(k)),r(l,k)}go.nodes.end=l,y.before(l)}dn&&Lr(y)}),()=>{}},ho),ha(()=>{}),o&&(Xr(!0),Lr(c))}function Po(t,e,n){ua(()=>{var r=gs(()=>e(t,n?.())||{});if(n&&r?.update){var i=!1,a={};vs(()=>{var o=n();vo(o),i&&po(a,o)&&(a=o,r.update(o))}),i=!0}if(r?.destroy)return()=>r.destroy()})}function ga(t){var e,n,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var i=t.length;for(e=0;e<i;e++)t[e]&&(n=ga(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function Io(){for(var t,e,n=0,r="",i=arguments.length;n<i;n++)(t=arguments[n])&&(e=ga(t))&&(r&&(r+=" "),r+=e);return r}function To(t){return typeof t=="object"?Io(t):t??""}const Ms=[...`
|
|
3
|
+
\r\f \v\uFEFF`];function Mo(t,e,n){var r=t==null?"":""+t;if(e&&(r=r?r+" "+e:e),n){for(var i of Object.keys(n))if(n[i])r=r?r+" "+i:i;else if(r.length)for(var a=i.length,o=0;(o=r.indexOf(i,o))>=0;){var l=o+a;(o===0||Ms.includes(r[o-1]))&&(l===r.length||Ms.includes(r[l]))?r=(o===0?"":r.substring(0,o))+r.substring(l+1):o=l}}return r===""?null:r}function Es(t,e=!1){var n=e?" !important;":";",r="";for(var i of Object.keys(t)){var a=t[i];a!=null&&a!==""&&(r+=" "+i+": "+a+n)}return r}function Fi(t){return t[0]!=="-"||t[1]!=="-"?t.toLowerCase():t}function Eo(t,e){if(e){var n="",r,i;if(Array.isArray(e)?(r=e[0],i=e[1]):r=e,t){t=String(t).replaceAll(/\s*\/\*.*?\*\/\s*/g,"").trim();var a=!1,o=0,l=!1,c=[];r&&c.push(...Object.keys(r).map(Fi)),i&&c.push(...Object.keys(i).map(Fi));var d=0,h=-1;const _=t.length;for(var p=0;p<_;p++){var y=t[p];if(l?y==="/"&&t[p-1]==="*"&&(l=!1):a?a===y&&(a=!1):y==="/"&&t[p+1]==="*"?l=!0:y==='"'||y==="'"?a=y:y==="("?o++:y===")"&&o--,!l&&a===!1&&o===0){if(y===":"&&h===-1)h=p;else if(y===";"||p===_-1){if(h!==-1){var k=Fi(t.substring(d,h).trim());if(!c.includes(k)){y!==";"&&p++;var C=t.substring(d,p).trim();n+=" "+C+";"}}d=p+1,h=-1}}}}return r&&(n+=Es(r)),i&&(n+=Es(i,!0)),n=n.trim(),n===""?null:n}return t==null?null:String(t)}function at(t,e,n,r,i,a){var o=t.__className;if(dn||o!==n||o===void 0){var l=Mo(n,r,a);(!dn||l!==t.getAttribute("class"))&&(l==null?t.removeAttribute("class"):e?t.className=l:t.setAttribute("class",l)),t.__className=n}else if(a&&i!==a)for(var c in a){var d=!!a[c];(i==null||d!==!!i[c])&&t.classList.toggle(c,d)}return a}function Bi(t,e={},n,r){for(var i in n){var a=n[i];e[i]!==a&&(n[i]==null?t.style.removeProperty(i):t.style.setProperty(i,a,r))}}function ir(t,e,n,r){var i=t.__style;if(dn||i!==e){var a=Eo(e,r);(!dn||a!==t.getAttribute("style"))&&(a==null?t.removeAttribute("style"):t.style.cssText=a),t.__style=e}else r&&(Array.isArray(r)?(Bi(t,n?.[0],r[0]),Bi(t,n?.[1],r[1],"important")):Bi(t,n,r));return r}function ti(t,e,n=!1){if(t.multiple){if(e==null)return;if(!la(e))return yo();for(var r of t.options)r.selected=e.includes(Jr(r));return}for(r of t.options){var i=Jr(r);if(mo(i,e)){r.selected=!0;return}}(!n||e!==void 0)&&(t.selectedIndex=-1)}function Ii(t){var e=new MutationObserver(()=>{ti(t,t.__value)});e.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),ha(()=>{e.disconnect()})}function Hr(t,e,n=e){var r=new WeakSet,i=!0;ps(t,"change",a=>{var o=a?"[selected]":":checked",l;if(t.multiple)l=[].map.call(t.querySelectorAll(o),Jr);else{var c=t.querySelector(o)??t.querySelector("option:not([disabled])");l=c&&Jr(c)}n(l),t.__value=l,dr!==null&&r.add(dr)}),ua(()=>{var a=e();if(t===document.activeElement){var o=dr;if(r.has(o))return}if(ti(t,a,i),i&&a===void 0){var l=t.querySelector(":checked");l!==null&&(a=Jr(l),n(a))}t.__value=a,i=!1}),Ii(t)}function Jr(t){return"__value"in t?t.__value:t.value}function Br(t,e,n=e){var r=new WeakSet;ps(t,"input",async i=>{var a=i?t.defaultValue:t.value;if(a=ji(t)?Vi(a):a,n(a),dr!==null&&r.add(dr),await yn(),a!==(a=e())){var o=t.selectionStart,l=t.selectionEnd,c=t.value.length;if(t.value=a??"",l!==null){var d=t.value.length;o===l&&l===c&&d>c?(t.selectionStart=d,t.selectionEnd=d):(t.selectionStart=o,t.selectionEnd=Math.min(l,d))}}}),(dn&&t.defaultValue!==t.value||gs(e)==null&&t.value)&&(n(ji(t)?Vi(t.value):t.value),dr!==null&&r.add(dr)),vs(()=>{var i=e();if(t===document.activeElement){var a=dr;if(r.has(a))return}ji(t)&&i===Vi(t.value)||t.type==="date"&&!i&&!t.value||i!==t.value&&(t.value=i??"")})}function lr(t,e,n=e){ps(t,"change",r=>{var i=r?t.defaultChecked:t.checked;n(i)}),(dn&&t.defaultChecked!==t.checked||gs(e)==null)&&n(t.checked),vs(()=>{var r=e();t.checked=!!r})}function ji(t){var e=t.type;return e==="number"||e==="range"}function Vi(t){return t===""?null:+t}function Ao(t,e,n){const r=new Set([e]);let i=[e];for(let a=0;a<n;a++){const o=[];for(const l of i)t.forEachOutNeighbor(l,c=>{r.has(c)||(r.add(c),o.push(c))}),t.forEachInNeighbor(l,c=>{r.has(c)||(r.add(c),o.push(c))});i=o}return r}const Ro=[{id:"circular_force",label:"Circular + ForceAtlas2 (default)"},{id:"circular_only",label:"Circular ring only"},{id:"random_force",label:"Random seed + ForceAtlas2"},{id:"linlog_clusters",label:"ForceAtlas2 LinLog (clusters)"}];function va(t,e){const n=new Map;if(t.forEachNode(h=>{const p=e(h);p!=null&&(n.has(p)||n.set(p,[]),n.get(p).push(h))}),n.size===0)return;const r=[...n.keys()].sort(),i=r.length,a=Math.max(5,Math.sqrt(t.order)*1.5),o=Math.max(.5,a/(i*1.8)),l=new Map;r.forEach((h,p)=>{const y=2*Math.PI*p/i;l.set(h,{cx:Math.cos(y)*a,cy:Math.sin(y)*a})});let c=42;function d(){return c=c*1664525+1013904223&4294967295,(c>>>0)/4294967296}t.forEachNode(h=>{const p=e(h),y=p!=null?l.get(p):null;y?(t.setNodeAttribute(h,"x",y.cx+(d()-.5)*o*2),t.setNodeAttribute(h,"y",y.cy+(d()-.5)*o*2)):(t.setNodeAttribute(h,"x",(d()-.5)*o),t.setNodeAttribute(h,"y",(d()-.5)*o))})}function Oo(t,e,n,r){const{circular:i,random:a}=e;if(r)return va(t,r),!0;switch(n){case"circular_only":return i.assign(t,{scale:1}),!1;case"random_force":return a.assign(t,{scale:1}),!0;default:return i.assign(t,{scale:1}),!0}}function Ki(t,e,n,r,i,a,o){if(!Oo(t,e,i,a))return()=>{};const c=r.inferSettings(t),d=t.order;let h;a?h={...c,linLogMode:!0,gravity:.08}:i==="linlog_clusters"?h={...c,linLogMode:!0,gravity:.02}:h={...c,linLogMode:d>30},d>3e3&&(h={...h,slowDown:Math.max(h.slowDown??1,3)});const p=new n(t,{settings:h});p.start();const y=d<50?1500:d<500?3e3:d<3e3?5e3:8e3,k=setTimeout(()=>{p.isRunning()&&p.stop()},y);return()=>{clearTimeout(k),p.isRunning()&&p.stop(),p.kill()}}function Lo(t,e,n,r,i){const{circular:a,random:o}=e,l=n.inferSettings(t),c=t.order,d={iterations:Math.min(300,50+c*2),settings:{...l,linLogMode:c>30}};if(i){va(t,i),n.assign(t,{iterations:Math.min(400,80+c*2),settings:{...l,linLogMode:!0,gravity:.08}});return}switch(r){case"circular_only":a.assign(t,{scale:1});return;case"random_force":o.assign(t,{scale:1}),n.assign(t,d);return;case"linlog_clusters":a.assign(t,{scale:1}),n.assign(t,{iterations:Math.min(400,80+c*2),settings:{...l,linLogMode:!0,gravity:.02}});return;default:a.assign(t,{scale:1}),n.assign(t,d)}}const ni=3,zr=2,Ho=2,ri=[{name:"Chapters",fills:["#fbbf24","#f59e0b","#eab308","#ca8a04"],label:"#fffbeb"},{name:"Articles & annexes",fills:["#38bdf8","#22d3ee","#0ea5e9","#06b6d4"],label:"#ecfeff"},{name:"Concepts & obligations",fills:["#a78bfa","#818cf8","#c084fc","#34d399","#f472b6"],label:"#f5f3ff"},{name:"Other (AI Act tier)",fills:["#94a3b8","#78716c","#64748b","#737373"],label:"#f8fafc"}],As="#64748b",ui=56,fi=36,gi=40,zo=14,Rs=18,Fo=8e3;function ki(t){let e=2166136261;for(let n=0;n<t.length;n++)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return e>>>0}function Bo(t,e,n){const r=(t%360+360)%360,i=e/100,a=n/100,o=(1-Math.abs(2*a-1))*i,l=r/60,c=o*(1-Math.abs(l%2-1));let d=0,h=0,p=0;l>=0&&l<1?[d,h,p]=[o,c,0]:l<2?[d,h,p]=[c,o,0]:l<3?[d,h,p]=[0,o,c]:l<4?[d,h,p]=[0,c,o]:l<5?[d,h,p]=[c,0,o]:[d,h,p]=[o,0,c];const y=a-o/2,k=Math.round((d+y)*255),C=Math.round((h+y)*255),_=Math.round((p+y)*255);return`#${k.toString(16).padStart(2,"0")}${C.toString(16).padStart(2,"0")}${_.toString(16).padStart(2,"0")}`}function nr(t,e=0){const n=ki(`${e}\0${t}`)%360,r=58+ki(t)%12,i=52+ki(t+"L")%10;return Bo(n,r,i)}function jo(t,e){const r=ri[Math.min(t,ri.length-1)].fills;let i=0;for(let a=0;a<e.length;a++)i=i*31+e.charCodeAt(a)>>>0;return r[i%r.length]}function pa(t){const e=ur(t),n=e?Rn(e,"entity_type"):null,r=(t.node_type||n||"").toLowerCase(),i=(t.schema_id||"").toLowerCase();return r==="document"||r==="chapter"||r==="section"||i.includes("chapter")?0:r==="article"||r==="paragraph"||r==="recital"||r==="annex"||r==="annex-entry"||r==="definition"||i.includes(":article")||i.includes(":annex")?1:["concept","role","obligation","risk-level","deadline","domain","penalty","penalty-tier","risk-level","ai-system-category","stakeholder-role","obligation-type","sector","fundamental-right","exemption","usecase","classification","intent-pattern","user-profile","project-stage","facet-vector","answer-template","query-example","decision","task","constraint","source","note","integration","environment"].some(a=>r===a||r.includes(a))||/ai-act:(concept|obligation|role|risk|deadline|domain|penalty|recital|usecase)/.test(i)?2:3}function wi(t){if((t.schema_id||"").trim().toLowerCase().startsWith("ai-act:"))return!0;const n=ur(t);if(!n)return!1;const r=Rn(n,"workspace_id")??Rn(n,"workspace"),i=Rn(n,"record_id")??Rn(n,"source_ref"),a=Rn(n,"ontology_layer");if(r?.toLowerCase()==="ai-act"&&(a||i&&!i.toLowerCase().startsWith("workspace:ai-act:loadout"))||i?.toLowerCase().startsWith("ai-act:")||Rn(n,"celex")==="32024R1689"||Rn(n,"legal_version")?.toLowerCase().includes("ai act"))return!0;const c=Rn(n,"source_ref");return!!(a&&(c?.includes("L_202401689")||c?.toLowerCase().includes("ai_act")))}function $i(t){const e=(t.schema_id||"").trim();if(e!=="")return e;const n=(t.node_type||"").trim();return n!==""?`type:${n}`:"(no schema / type)"}function Zi(t){const e=(t.schema_id||"").trim();if(e===""){const r=(t.node_type||"").trim();return r!==""?`(type: ${r})`:"(no namespace)"}const n=e.indexOf(":");return n===-1?e:e.slice(0,n)}function Vo(t){const e=pa(t),n=[11,9,7,5.5],r=[12,9,6,3],i=ri[Math.min(e,ri.length-1)];return{color:jo(e,t.id),labelColor:i.label,size:n[e]??6,zIndex:r[e]??0}}function Un(t,e){return`${t} (${e})`}function Ko(t){const e=[0,0,0,0];for(const n of t){if(!wi(n))continue;const r=Math.min(Math.max(pa(n),0),3);e[r]++}return e}function $o(t,e){const n=new Map;for(const r of t){const i=e(r);n.set(i,(n.get(i)??0)+1)}return n}function Zo(t){const e=new Map;for(const n of t){const r=(n.label??"").trim();r!==""&&e.set(r,(e.get(r)??0)+1)}return e}function ur(t){const e=t.facets;return e==null||typeof e!="object"||Array.isArray(e)?null:e}function Rn(t,e){const n=t[e];if(n==null)return null;const r=String(n).trim();return r===""?null:r}const Os="abstraction_level:";function ya(t){const e=t.facet_tags;if(!Array.isArray(e))return[];const n=[];for(const r of e){if(typeof r!="string"||!r.startsWith(Os))continue;const i=r.slice(Os.length).trim();i!==""&&n.push(i)}return n}function Uo(t,e){const n=new Map;let r=0;for(const i of t){const a=ur(i);if(!a)continue;const o=Rn(a,e);o!=null&&(r++,n.set(o,(n.get(o)??0)+1))}return{counts:n,covered:r}}function Wo(t){const e=new Map;let n=0;for(const r of t){const i=ur(r);if(!i)continue;const a=ya(i);if(a.length!==0){n++;for(const o of a)e.set(o,(e.get(o)??0)+1)}}return{counts:e,covered:n}}function Go(t){const e=new Map;for(const n of t)e.has(n.source)||e.set(n.source,new Set),e.has(n.target)||e.set(n.target,new Set),e.get(n.source).add(n.target),e.get(n.target).add(n.source);return e}function Ui(t,e,n,r){if(t.size===0)return new Set;const i=Go(e),a=new Set(t);let o=[...t];for(let l=0;l<n;l++){const c=[];for(const d of o)for(const h of i.get(d)??[])r&&!r(h)||a.has(h)||(a.add(h),c.push(h));o=c}return a}function Ls(t){const e=ur(t);return e?Rn(e,"audit_phase")??Rn(e,"run_stage"):null}function Hs(t,e,n){if(n.kind==="scalar"){const r=new Set;for(const i of t){const a=ur(i);a&&Rn(a,n.key)===n.value&&r.add(i.id)}return r}if(n.kind==="abstraction"){const r=new Set;for(const i of t){const a=ur(i);a&&ya(a).includes(n.value)&&r.add(i.id)}return r}if(n.kind==="chantier_week_neighborhood"){const r=new Set;for(const i of t){const a=ur(i);if(!a)continue;Rn(a,"week_number")===n.week&&r.add(i.id)}return Ui(r,e,zr)}if(n.kind==="audit_phase_neighborhood"){const r=new Set,i=new Map(t.map(a=>[a.id,a]));for(const a of t)Ls(a)===n.phase&&r.add(a.id);return Ui(r,e,Ho,a=>{const o=i.get(a);if(!o)return!1;const l=Ls(o);return l==null||l===n.phase})}return Ui(new Set([n.platformId]),e,ni)}function zs(t,e,n,r,i,a){if(e.size===0||n===0)return null;const o=[...e.entries()].sort((d,h)=>h[1]-d[1]||d[0].localeCompare(h[0],void 0,{sensitivity:"base"})),c=o.slice(0,r).map(([d,h])=>{let p;return a.mode==="scalar"?p={kind:"scalar",key:a.key,value:d}:a.mode==="abstraction"?p={kind:"abstraction",value:d}:a.mode==="chantier_week"?p={kind:"chantier_week_neighborhood",week:d}:p={kind:"audit_phase_neighborhood",phase:d},{swatch:nr(`facet:${t}:${d}`,i),label:Un(d,h),facetFilter:p}});if(o.length>r){const h=o.slice(r).reduce((p,[,y])=>p+y,0);c.push({swatch:"#64748b",label:`… +${o.length-r} more values (${h} counts)`})}return{title:`${t} (${n})`,rows:c}}function Yo(t){if(t.length===0||t.length>Fo)return[];if(t.filter(a=>{const o=ur(a);return o!=null&&Object.keys(o).length>0}).length===0)return[];const n=[{kind:"scalar",label:"AI layer",key:"ontology_layer"},{kind:"scalar",label:"AI entity type",key:"entity_type"},{kind:"scalar",label:"risk level",key:"risk_level"},{kind:"scalar",label:"stakeholder role",key:"stakeholder_role"},{kind:"scalar",label:"obligation type",key:"obligation_type"},{kind:"scalar",label:"sector",key:"sector"},{kind:"scalar",label:"penalty tier",key:"penalty_tier"},{kind:"scalar",label:"deadline",key:"deadline"},{kind:"scalar",label:"fundamental right",key:"fundamental_right"},{kind:"scalar",label:"intent",key:"intent_primary"},{kind:"scalar",label:"answer granularity",key:"answer_granularity"},{kind:"scalar",label:"geo scope",key:"geo_scope"},{kind:"scalar",label:"validation",key:"validation_status"},{kind:"scalar",label:"audit phase",key:"audit_phase"},{kind:"scalar",label:"graph layer",key:"graph_layer"},{kind:"scalar",label:"semantic group",key:"semantic_group"},{kind:"scalar",label:"severity",key:"severity"},{kind:"scalar",label:"status",key:"status"},{kind:"scalar",label:"issue category",key:"issue_category"},{kind:"scalar",label:"page tier",key:"page_tier"},{kind:"scalar",label:"device",key:"device"},{kind:"scalar",label:"channel",key:"channel"},{kind:"scalar",label:"position bucket",key:"position_bucket"},{kind:"scalar",label:"domain",key:"domain"},{kind:"scalar",label:"week (chantier)",key:"week_number"},{kind:"scalar",label:"provider",key:"provider"},{kind:"scalar",label:"tier",key:"tier"},{kind:"scalar",label:"complexity",key:"complexity"},{kind:"abstraction"},{kind:"scalar",label:"action verb",key:"action_verb"},{kind:"scalar",label:"composability",key:"composability"},{kind:"scalar",label:"specificity",key:"specificity"},{kind:"scalar",label:"input type",key:"input_type"},{kind:"scalar",label:"output format",key:"output_format"},{kind:"scalar",label:"dependency type",key:"dependency_type"},{kind:"scalar",label:"interaction mode",key:"interaction_mode"}],r=[];let i=11;for(const a of n)if(a.kind==="scalar"){const{counts:o,covered:l}=Uo(t,a.key),c=a.key==="week_number"?{mode:"chantier_week"}:a.key==="audit_phase"?{mode:"audit_phase"}:{mode:"scalar",key:a.key},d=zs(a.label,o,l,Rs,i++,c);d&&r.push(d)}else{const o=Wo(t),l=zs("abstraction (from tags)",o.counts,o.covered,Rs,i++,{mode:"abstraction"});l&&r.push(l)}return r}function Xo(t){const e=t.filter(r=>(r.node_type||"").trim()==="Platform");if(e.length===0)return null;const n=e.map(r=>{const i=(r.label||r.id).trim();return{swatch:nr(`platform-hull:${r.id}`,42),label:`Ship · ${i}`,facetFilter:{kind:"platform_hull",platformId:r.id}}});return{title:`Ship hull (≤${ni} hops)`,rows:n}}function vi(t,e,n){const r=n==="all",i=t.filter(wi),a=t.filter(U=>!wi(U)),o=Ko(i),l=Zo(e),c=r?[...new Set(a.map(Zi))].sort((U,V)=>U.localeCompare(V,void 0,{sensitivity:"base"})):[...new Set(a.map($i))].sort((U,V)=>U.localeCompare(V,void 0,{sensitivity:"base"})),d=new Map,h=new Map;c.forEach((U,V)=>{d.set(U,nr(U)),h.set(U,V)});const p=[...new Set(e.map(U=>(U.label??"").trim()).filter(U=>U.length>0))].sort((U,V)=>U.localeCompare(V,void 0,{sensitivity:"base"})),y=new Map;for(const U of p)y.set(U,nr(U,7));const k=$o(a,r?Zi:$i);function C(U){return r?Zi(U):$i(U)}function _(U){if(wi(U))return Vo(U);const V=C(U),se=d.get(V)??nr(V),oe=h.get(V)??0;let ce=6.6+ki(V)%5*.55,G=4+oe%8;const N=(U.node_type||"").trim();return N==="Platform"?(ce=Math.max(ce,17),G=Math.max(G,24)):(N==="OTSystem"||N==="ITSystem"||N==="Emitter"||N==="Network")&&(ce=Math.max(ce,11),G=Math.max(G,14)),{color:se,labelColor:"#f8fafc",size:ce,zIndex:G}}function v(U){if(U==null)return As;const V=U.trim();return V===""?As:y.get(V)??nr(V,7)}const I=[],O=Yo(t),j=O.length>0&&i.length>0;if(i.length>0&&(n==="ai-act"||n==="all")&&I.push({title:Un("AI Act (node tiers)",i.length),rows:ri.map((U,V)=>({swatch:U.fills[0],label:Un(U.name,o[V]??0)}))}),j&&I.push(...O),r){if(c.length>0){const U=a.length,se=c.slice(0,gi).map(oe=>({swatch:d.get(oe)??nr(oe),label:Un(oe,k.get(oe)??0)}));if(c.length>gi){const ce=c.slice(gi).reduce((G,N)=>G+(k.get(N)??0),0);se.push({swatch:"#64748b",label:`… +${c.length-gi} more namespaces (${ce} nodes)`})}I.push({title:Un("Ontologies (node colour = prefix)",U),rows:se})}if(p.length>0){const U=e.length,V=p.slice(0,zo),se=V.map(ce=>({swatch:y.get(ce)??nr(ce,7),label:Un(ce,l.get(ce)??0)})),oe=p.length-V.length;oe>0&&se.push({swatch:"#64748b",label:`… +${oe} more relation types — pick one ontology to list only those`}),I.push({title:Un(`Relations (sample of ${p.length} types)`,U),rows:se})}I.push({title:"Tip",rows:[{swatch:"#334155",label:"Choose an ontology in the header for full types & relations"}]})}else{if(c.length>0){const U=a.length,se=c.slice(0,ui).map(ce=>({swatch:d.get(ce)??nr(ce),label:Un(ce,k.get(ce)??0)}));if(c.length>ui){const G=c.slice(ui).reduce((N,W)=>N+(k.get(W)??0),0);se.push({swatch:"#64748b",label:`… +${c.length-ui} more schema / type keys (${G} nodes)`})}const oe=n==="_none"?"Nodes (schema / type)":`Nodes — ${n} (schema_id / type)`;I.push({title:Un(oe,U),rows:se})}if(p.length>0){const U=e.length,se=p.slice(0,fi).map(oe=>({swatch:y.get(oe)??nr(oe,7),label:Un(oe,l.get(oe)??0)}));if(p.length>fi){const ce=p.slice(fi).reduce((G,N)=>G+(l.get(N)??0),0);se.push({swatch:"#64748b",label:`… +${p.length-fi} more edge labels (${ce} edges)`})}I.push({title:Un("Relations (edge labels)",U),rows:se})}}const K=Xo(t);if(K)if(r){const U=I.findIndex(V=>V.title==="Tip");U>=0?I.splice(U,0,K):I.push(K)}else I.push(K);if(O.length>0&&!j)if(r){const U=I.findIndex(V=>V.title==="Tip");U>=0?I.splice(U,0,...O):I.push(...O)}else I.push(...O);return{styleNode:_,edgeColor:v,legendSections:I}}const Jo=["BELONGS_TO_DOMAIN","PART_OF","BELONGS_TO","REQUIRES_TOOL","HAS_SKILL","IMPLEMENTS_PATTERN"],Qo=new Set(Jo);function qo(t){const e=(t??"").trim();return Qo.has(e)}async function*el(t){if(!t.body)throw new Error("Response body is null");const e=t.body.pipeThrough(new TextDecoderStream).getReader();let n="";try{for(;;){const{value:i,done:a}=await e.read();if(a)break;n+=i;let o;for(;(o=n.indexOf(`
|
|
4
|
+
`))!==-1;){const l=n.slice(0,o).trim();n=n.slice(o+1),l&&(yield JSON.parse(l))}}const r=n.trim();r&&(yield JSON.parse(r))}finally{e.releaseLock()}}function ns(t){if(!t)return{};if(typeof t=="object"&&!Array.isArray(t))return t;if(typeof t!="string")return{};try{const e=JSON.parse(t);return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function tl(t){return t.entity&&typeof t.entity=="object"?t.entity:t}function Fs(t){const e=tl(t),n=String(e.entity_id??e.id??e.node_id??""),r=ns(e.metadata??e.metadata_json),i=ns(e.facets??e.facets_json),a=String(e.entity_type??e.node_type??e.type??"");return{id:n,label:String(e.name??e.label??r.label??n),node_type:a||null,schema_id:a||null,facets:{...r,...i,workspace_id:e.workspace_id??r.workspace_id,entity_type:a}}}function nl(t){const e=Number(t);return!Number.isFinite(e)||e<=0?null:new Date(e*1e3).toISOString().slice(0,10)}function rl(t,e=[]){const r=[String(t.relation_type??t.label??"relation")];for(const o of e){const l=String(o.property_key??o.key??""),c=o.property_value??o.value;l&&c!=null&&c!==""&&r.push(`${l}=${c}`)}const i=ns(t.metadata_json);i.quotePart!=null&&r.push(`quote=${i.quotePart}`),i.status!=null&&r.push(String(i.status));const a=nl(t.valid_from_unix);return a&&r.push(`from ${a}`),r.join(" · ")}function il(t,e){const n=t.relation&&typeof t.relation=="object"?t.relation:t,r=String(n.relation_id??n.id??n.edge_id??""),i=String(n.source_id??n.source??n.source_entity_id??""),a=String(n.target_id??n.target??n.target_entity_id??""),o=Array.isArray(e?.properties)?e.properties:Array.isArray(n.properties)?n.properties:[],l={};for(const c of o){const d=String(c.property_key??c.key??"");d&&(l[d]=c.property_value??c.value)}return{id:r,source:i,target:a,label:rl(n,o),weight:n.confidence==null?null:Number(n.confidence),properties:Object.keys(l).length>0?l:void 0,relationMeta:n}}function sl(t){const e=t.kind;if(typeof e=="string"&&e.length>0&&!e.startsWith("."))return e;const n=t.payload??{};return n.relation?"edge":n.entity?n.depth==null?"seed_node":"node":n.kind==="subgraph"?"done":""}function al(t){const e=new Map,n=new Map;for(const o of t){const l=o.payload??{},c=sl(o);if(c!=="done"){if(c==="seed_node"||c==="node"){const d=Fs(l);d.id&&e.set(d.id,d);continue}if(c==="edge"){const d=il(l,l);d.id&&d.source&&d.target&&n.set(d.id,d);for(const h of["source","target"]){const p=l[h];if(p&&typeof p=="object"){const y=Fs(p);y.id&&e.set(y.id,y)}}}}}const r=[...e.values()],i=new Set(r.map(o=>o.id)),a=[...n.values()].filter(o=>i.has(o.source)&&i.has(o.target));return{nodes:r,edges:a,sourceUsed:"graph"}}var ol=D('<span class="stream-sep svelte-11bec40">·</span> <span class="stream-nums svelte-11bec40"> </span> <span class="stream-sep svelte-11bec40">·</span> <span class="stream-status svelte-11bec40">streaming…</span>',1),ll=D('<span class="stream-sep svelte-11bec40">·</span> <span class="stream-status svelte-11bec40">loading edges…</span>',1),cl=D('<span class="stream-sep svelte-11bec40">·</span> <span class="stream-status svelte-11bec40">streaming…</span>',1),dl=D('<span class="stream-nums svelte-11bec40"> </span> <!>',1),hl=D('<span class="stream-nums svelte-11bec40"> </span> <span class="stream-sep svelte-11bec40">·</span> <span class="stream-status stream-status--done svelte-11bec40">ready</span>',1),ul=D('<div role="status" aria-live="polite" aria-label="Graph loading progress"><div class="stream-track svelte-11bec40"><div class="stream-fill svelte-11bec40"></div></div> <span class="stream-label svelte-11bec40"><!></span></div>'),fl=D('<div class="focus-bar svelte-11bec40" role="status"><span class="svelte-11bec40">Focus</span> <span class="focus-text svelte-11bec40"> </span> <span class="focus-reset svelte-11bec40">Click background to reset</span></div>'),gl=D('<div class="source-hint svelte-11bec40" role="status"> </div>'),vl=D('<div class="overlay svelte-11bec40">Loading graph…</div>'),pl=D('<div class="overlay svelte-11bec40">No nodes to display (try another ontology, workspace, or source mode).</div>'),yl=D('<div class="overlay error svelte-11bec40"><strong>Graph load failed</strong> <p class="svelte-11bec40"> </p></div>'),ml=D('<div class="wrap svelte-11bec40"><div class="canvas svelte-11bec40" aria-label="Knowledge graph visualization"></div> <!> <!> <!> <!> <!> <!></div>');function _l(t,e){Dn(e,!0);const n=Number.POSITIVE_INFINITY,r=.5,i=3e3;let a=null;function o(){return a||(a=Promise.all([Gn(()=>import("../chunks/-OSExkSk.js"),__vite__mapDeps([0,1,2,3]),import.meta.url),Gn(()=>import("../chunks/Gs0cNFYG.js"),__vite__mapDeps([4,2]),import.meta.url),Gn(()=>import("../chunks/DyXQogav.js").then(T=>T.i),__vite__mapDeps([5,3]),import.meta.url),Gn(()=>import("../chunks/Cp9dXlPT.js").then(T=>T.i),__vite__mapDeps([6,3,7]),import.meta.url),Gn(()=>import("../chunks/BVrgUHq-.js").then(T=>T.w),__vite__mapDeps([8,3,7]),import.meta.url),Gn(()=>import("../chunks/CBDzfqXr.js"),__vite__mapDeps([9,1]),import.meta.url)]).then(([T,ee,Te,Ae,Ie,we])=>({Sigma:T.default,DirectedGraph:ee.DirectedGraph,layoutMod:Te,forceAtlas2:Ae.default,FA2LayoutCtor:Ie.default,drawDarkDiscNodeHover:we.drawDarkDiscNodeHover}))),a}function l(T,ee,Te){if(ee<=i)return()=>{};const Ae=T.getCamera();let Ie=!1;const we=()=>{const Ve=Ae.ratio>r;Ve!==Ie&&(Ie=Ve,!s(de)&&!V()&&T.setSettings({edgeReducer:Ve?(ot,it)=>({...it,hidden:!0}):null,labelRenderedSizeThreshold:Ve?8:Te?3:4}))};return Ae.on("updated",we),()=>Ae.removeListener("updated",we)}let c=$(e,"ontologyKey",3,"all"),d=$(e,"providerKey",3,null),h=$(e,"layoutTemplate",3,"circular_force"),p=$(e,"dbKey",3,"default"),y=$(e,"edgeLinkMode",3,"all"),k=$(e,"expandHops",3,0),C=$(e,"focusCompositionOnly",3,!1),_=$(e,"graphSource",3,"auto"),v=$(e,"workspaceId",3,null),I=$(e,"scenarioId",3,null),O=$(e,"topK",3,30),j=$(e,"groupByDimension",3,null),K=$(e,"dataSource",3,"sqlite-demo"),U=$(e,"brainSeedIds",19,()=>[]),V=$(e,"facetFilter",15,null),se=$(e,"legendBlocks",31,()=>Ut([]));const oe=2,ce={renderEdgeLabels:!0,edgeLabelSize:10,edgeLabelWeight:"400",edgeLabelColor:{color:"#cbd5e1"}},G=120;function N(T){return{labelDensity:T?.14:.09,labelRenderedSizeThreshold:T?3:4}}function W(){return{labelDensity:1,labelRenderedSizeThreshold:0}}function z(T,ee,Te){return{label:T??"",size:Math.max(1.2,Math.min(2.8,(ee??1)*.35)),color:Te,forceLabel:!0,labelColor:"#cbd5e1"}}let X=L(null);De(()=>{se(s(X)?.plan?.legendSections??[])});let le=me(()=>s(X)?.nodes??[]),ue=me(()=>s(X)?.edges??[]),Se=me(()=>new Map(s(le).map(T=>[T.id,T]))),ie=me(()=>new Map(s(ue).map(T=>[T.id,T]))),de=L(null),Ce=L(null);De(()=>{const T=V();if(T){if(T.kind==="platform_hull"){u(de,null);return}s(de)&&s(le).length>0&&(Hs(s(le),s(ue),T).has(s(de))||u(de,null))}});let xe=L(null),tt=L(null),_e=L(void 0),Z=L("loading"),pe=L(null),ve=null,Ke=L(null),Oe=L(!1),je=L(null),Ge=L(Ut({nodes:0,edges:0})),et=L(!1),$e=!1,mt=me(()=>s(je)&&s(je).nodeCount>0?Math.min(100,Math.round(s(Ge).nodes/s(je).nodeCount*100)):0),vt=me(()=>s(je)?s(je).edgeCount>0?Math.round((s(Ge).nodes*.3+s(Ge).edges*.7)/(s(je).nodeCount*.3+s(je).edgeCount*.7)*100):s(mt):0);function Qe(T,ee){return T===ee?!0:!T||!ee||T.kind!==ee.kind?!1:T.kind==="scalar"&&ee.kind==="scalar"?T.key===ee.key&&T.value===ee.value:T.kind==="platform_hull"&&ee.kind==="platform_hull"?T.platformId===ee.platformId:T.kind==="abstraction"&&ee.kind==="abstraction"?T.value===ee.value:T.kind==="chantier_week_neighborhood"&&ee.kind==="chantier_week_neighborhood"?T.week===ee.week:T.kind==="audit_phase_neighborhood"&&ee.kind==="audit_phase_neighborhood"?T.phase===ee.phase:!1}function Fe(T){const ee=s(Se).get(T);if(!ee||ee.node_type!=="AuditRun")return null;const Te=ee.facets;if(Te==null||typeof Te!="object"||Array.isArray(Te))return null;const Ae=String(Te.audit_phase??"").trim();return!Ae||Ae.includes("_to_")?null:{kind:"audit_phase_neighborhood",phase:Ae}}function nt(T){if(s(de)===T){u(de,null);const Ie=Fe(T);Ie&&Qe(V(),Ie)&&V(null);return}u(de,T,!0);const ee=s(Se).get(T),Te=Number.parseInt(T,10);Number.isFinite(Te)&&e.onSelect?.({kind:"entity",entityId:Te,entityType:ee?.node_type??"",label:ee?.label??T});const Ae=Fe(T);Ae&&V(Ae)}function lt(T){const ee=s(ie).get(T),Te=Number.parseInt(T,10);Number.isFinite(Te)&&e.onSelect?.({kind:"relation",relationId:Te,relationType:ee?.label??""})}function H(T){return T==="all"?null:T.toLowerCase().startsWith("type:")?T.slice(5):T}async function ne(T,ee,Te,Ae){let Ie=ee.filter(P=>Number.isFinite(P)&&P>0);if(Ie.length===0){const P=new URLSearchParams({workspace_id:T,limit:String(Te??30)});Ae&&P.set("entity_type",Ae);const w=await fetch(`/api/brain/ghostcrab/graph-search?${P}`);if(!w.ok)throw new Error(await w.text());Ie=((await w.json()).rows??[]).map(he=>Number(he.entity_id)).filter(he=>Number.isFinite(he))}if(Ie.length===0)return F(T,Te,Ae);const we=new URLSearchParams({workspace_id:T,seed_ids:Ie.slice(0,30).join(","),hops:"2",format:"json"});Ae&&we.set("entity_type",Ae);const Ve=await fetch(`/api/brain/graph/subgraph?${we}`);if(!Ve.ok)throw new Error(await Ve.text());const ot=await Ve.json(),it=al(ot);return it.nodes.length>0?it:F(T,Te,Ae)}async function F(T,ee,Te){const Ae=new URLSearchParams({workspace:T});Te&&Ae.set("ontology",`type:${Te}`),ee==null||ee<=0?Ae.set("topK","none"):Ae.set("topK",String(ee));const Ie=await fetch(`/api/graph?${Ae}`);if(!Ie.ok)throw new Error(await Ie.text());return await Ie.json()}function M(){u(de,null),V(null)}De(()=>{const T=c(),ee=d(),Te=p(),Ae=y(),Ie=k(),we=I()?.trim()||null,Ve=O(),ot=K(),it=U().filter(be=>Number.isFinite(be)).sort((be,ze)=>be-ze),P=it.join(","),w=we?"graph":_(),E=v()?.trim()||null,he=E??"default";let Ee=!1;return u(X,null),u(de,null),V(null),u(Ke,null),u(Z,"loading"),u(pe,null),u(tt,null),u(Oe,!1),u(je,null),u(Ge,{nodes:0,edges:0},!0),u(et,!1),o().catch(()=>{}),(async()=>{try{const be=new URLSearchParams;if(T!=="all"&&be.set("ontology",T),Te!=="default"&&be.set("db",Te),ee&&be.set("provider",ee),Ae!=="all"&&be.set("linkMode",Ae),Ie>0&&be.set("expandHops",String(Ie)),w!=="auto"&&be.set("source",w),E&&be.set("workspace",E),we&&be.set("scenarioId",we),Ve==null||Ve<=0?be.set("topK","none"):be.set("topK",String(Ve)),s(xe)?.ontology===T&&s(xe)?.db===Te&&s(xe)?.provider===ee&&s(xe)?.linkMode===Ae&&s(xe)?.expandHops===Ie&&s(xe)?.graphSource===w&&s(xe)?.workspaceId===E&&s(xe)?.scenarioId===we&&s(xe)?.topK===Ve&&s(xe)?.dataSource===ot&&s(xe)?.brainSeedKey===P){const Ue=s(xe).payload;if(Ee)return;R(Ue,T,()=>Ee);return}if(ot==="brain"){const Ue=await ne(he,it,Ve,H(T));if(Ee)return;u(xe,{db:Te,ontology:T,provider:ee,linkMode:Ae,expandHops:Ie,graphSource:w,workspaceId:E,scenarioId:we,topK:Ve,dataSource:ot,brainSeedKey:P,payload:Ue},!0),R(Ue,T,()=>Ee);return}const ze=new URLSearchParams(be);let Le=!1;try{const Ue=await fetch(`/api/graph/count?${ze}`);Ue.ok&&!Ee&&(Le=(await Ue.json()).nodeCount>n)}catch{}if(Ee)return;if(!Le){const Ue=new URLSearchParams(be),Je=await fetch(`/api/graph?${Ue}`);if(Ee)return;if(!Je.ok){const Et=await Je.text();throw new Error(Et||`HTTP ${Je.status}`)}const Nt=await Je.json();if(u(xe,{db:Te,ontology:T,provider:ee,linkMode:Ae,expandHops:Ie,graphSource:w,workspaceId:E,scenarioId:we,topK:Ve,dataSource:ot,brainSeedKey:P,payload:Nt},!0),Ee)return;R(Nt,T,()=>Ee);return}u(Oe,!0),u(et,!1),u(Ge,{nodes:0,edges:0},!0);const rt=new URLSearchParams(be);rt.set("topK","30");const m=await fetch(`/api/graph/stream?${rt}`);if(Ee)return;if(!m.ok){const Ue=await m.text();throw new Error(Ue||`HTTP ${m.status}`)}const Ze=[],Ye=[];let Mt=null,Ot=Date.now(),J=null,fe=null,dt=!1;for await(const Ue of el(m)){if(Ee)break;if(Ue.type==="meta")Mt=Ue,u(je,{nodeCount:Mt.nodeCount,edgeCount:Mt.edgeCount,sourceUsed:Mt.sourceUsed},!0);else if(Ue.type==="node"){const Je=Ue;Ze.push({id:Je.id,label:Je.label,node_type:Je.node_type,schema_id:Je.schema_id,facets:Je.facets});const Nt=Date.now();if(Nt-Ot>120&&(u(Ge,{nodes:Ze.length,edges:0},!0),Ot=Nt),!dt&&Mt&&Ze.length>=Mt.nodeCount&&!Ee){if(dt=!0,u(Ge,{nodes:Ze.length,edges:0},!0),Ze.length===0)continue;fe=vi(Ze,[],T);const Et=await o();if(Ee)break;const st=s(_e);if(!st)break;ve?.kill(),ve=null,u(Ce,null),J=new Et.DirectedGraph;const At=new Map(Ze.map(Pt=>[Pt.id,Pt]));for(const Pt of Ze){const hn=(Pt.label?.trim()||Pt.id).slice(0,80),Lt=fe.styleNode(Pt);J.addNode(Pt.id,{label:hn,size:Lt.size,x:0,y:0,color:Lt.color,labelColor:Lt.labelColor,zIndex:Lt.zIndex})}const an=j()?.trim()||null,gn=an?Pt=>{const Lt=At.get(Pt)?.facets;if(Lt==null||typeof Lt!="object"||Array.isArray(Lt))return null;const bt=Lt[an];return bt==null?null:String(bt).trim()||null}:void 0;let Xt=Ki(J,Et.layoutMod,Et.FA2LayoutCtor,Et.forceAtlas2,h(),gn);if(Ee){Xt();break}const Bt=(Mt.sourceUsed??"mfo")==="graph";ve=new Et.Sigma(J,st,{renderLabels:!0,defaultNodeColor:"#94a3b8",defaultEdgeColor:"#64748b",labelDensity:Bt?.14:.09,zIndex:!0,labelSize:Bt?14:13,labelWeight:"500",labelColor:{attribute:"labelColor",color:"#f1f5f9"},labelRenderedSizeThreshold:Bt?3:4,defaultDrawNodeHover:Et.drawDarkDiscNodeHover,...ce}),ve.on("clickNode",({node:Pt})=>{nt(Pt)}),ve.on("clickEdge",({edge:Pt})=>{lt(Pt)}),ve.on("clickStage",()=>{M()}),l(ve,Ze.length,Bt),u(tt,Bt?"GhostCrab PERSO SQLite":"Legacy graph source",!0),u(Ce,{graph:J,sigma:ve},!0),u(Z,"ready"),$e=!0}}else if(Ue.type==="edge"){const Je=Ue;if(Ye.push({id:Je.id,source:Je.source,target:Je.target,label:Je.label,weight:Je.weight}),J&&fe)try{J.hasNode(Je.source)&&J.hasNode(Je.target)&&!J.hasEdge(Je.id)&&J.addEdgeWithKey(Je.id,Je.source,Je.target,{...z(Je.label,Je.weight,fe.edgeColor(Je.label))})}catch{}const Nt=Date.now();Nt-Ot>200&&(u(Ge,{nodes:Ze.length,edges:Ye.length},!0),Ot=Nt)}}if(Ee){u(Oe,!1);return}if(u(Ge,{nodes:Ze.length,edges:Ye.length},!0),Ze.length===0){u(Z,"empty"),u(Oe,!1);return}if(!dt){const Ue=Mt?.sourceUsed??"mfo";u(tt,Ue==="mfo"?"Legacy graph source":"GhostCrab PERSO SQLite",!0);const Je=vi(Ze,Ye,T);if(Ee){u(Oe,!1);return}const{Sigma:Nt,DirectedGraph:Et,layoutMod:st,forceAtlas2:At,FA2LayoutCtor:an,drawDarkDiscNodeHover:gn}=await o();if(Ee){u(Oe,!1);return}const Xt=s(_e);if(!Xt){u(Oe,!1);return}ve?.kill(),ve=null,u(Ce,null),J=new Et;const on=new Map(Ze.map(bt=>[bt.id,bt]));for(const bt of Ze){const wn=(bt.label?.trim()||bt.id).slice(0,80),Vt=Je.styleNode(bt);J.addNode(bt.id,{label:wn,size:Vt.size,x:0,y:0,color:Vt.color,labelColor:Vt.labelColor,zIndex:Vt.zIndex})}for(const bt of Ye)if(!(!J.hasNode(bt.source)||!J.hasNode(bt.target)))try{J.addEdgeWithKey(bt.id,bt.source,bt.target,z(bt.label,bt.weight,Je.edgeColor(bt.label)))}catch{}const Bt=j()?.trim()||null,Pt=Bt?bt=>{const Vt=on.get(bt)?.facets;if(Vt==null||typeof Vt!="object"||Array.isArray(Vt))return null;const _n=Vt[Bt];return _n==null?null:String(_n).trim()||null}:void 0;let hn=Ki(J,st,an,At,h(),Pt);if(Ee){hn(),u(Oe,!1);return}const Lt=Ue==="graph";ve=new Nt(J,Xt,{renderLabels:!0,defaultNodeColor:"#94a3b8",defaultEdgeColor:"#64748b",labelDensity:Lt?.14:.09,zIndex:!0,labelSize:Lt?14:13,labelWeight:"500",labelColor:{attribute:"labelColor",color:"#f1f5f9"},labelRenderedSizeThreshold:Lt?3:4,defaultDrawNodeHover:gn,...ce}),ve.on("clickNode",({node:bt})=>{nt(bt)}),ve.on("clickEdge",({edge:bt})=>{lt(bt)}),ve.on("clickStage",()=>{M()}),l(ve,Ze.length,Lt),u(Ce,{graph:J,sigma:ve},!0),u(Z,"ready"),$e=!0,fe=Je}if(Ee)return;if(J&&fe){const Ue=vi(Ze,Ye,T);for(const Nt of Ze)if(J.hasNode(Nt.id)){const Et=Ue.styleNode(Nt);J.setNodeAttribute(Nt.id,"size",Et.size),J.setNodeAttribute(Nt.id,"color",Et.color)}u(Ce,J&&ve?{graph:J,sigma:ve}:s(Ce),!0);const Je=Mt?.sourceUsed??"mfo";u(Ge,{nodes:Ze.length,edges:Ye.length},!0),u(et,!0),u(xe,{db:Te,ontology:T,provider:ee,linkMode:Ae,expandHops:Ie,graphSource:w,workspaceId:E,scenarioId:we,topK:Ve,dataSource:ot,brainSeedKey:P,payload:{nodes:Ze,edges:Ye,sourceUsed:Je}},!0),$e=!0,u(X,{nodes:Ze,edges:Ye,plan:Ue,sourceUsed:Je,ontology:T},!0)}setTimeout(()=>{Ee||u(Oe,!1)},1800)}catch(be){if(Ee)return;u(Z,"error"),u(Oe,!1),u(pe,be instanceof Error?be.message:String(be),!0)}})(),()=>{Ee=!0,s(Oe)&&ve&&!s(X)&&(ve.kill(),ve=null,u(Ce,null)),u(Oe,!1)}});function R(T,ee,Te){T.sourceUsed==="mfo"?u(tt,"Legacy graph source"):T.sourceUsed==="graph"?u(tt,K()==="brain"?"MindBrain live graph":"GhostCrab PERSO SQLite",!0):u(tt,null);const Ae=T.nodes??[],Ie=T.edges??[];if(Ae.length===0){u(tt,null),u(Z,"empty");return}const we=vi(Ae,Ie,ee);Te()||u(X,{nodes:Ae,edges:Ie,plan:we,sourceUsed:T.sourceUsed,ontology:ee},!0)}De(()=>{const T=s(_e),ee=s(X),Te=h(),Ae=j()?.trim()||null;if($e){$e=!1;return}if(ve?.kill(),ve=null,u(Ce,null),!T||!ee)return;const{nodes:Ie,edges:we,plan:Ve}=ee;let ot=!1,it=null,P=()=>{};return(async()=>{try{const{Sigma:w,DirectedGraph:E,layoutMod:he,forceAtlas2:Ee,FA2LayoutCtor:be,drawDarkDiscNodeHover:ze}=await o();if(ot)return;const Le=new E,rt=new Map(Ie.map(Ye=>[Ye.id,Ye]));for(const Ye of Ie){const Mt=(Ye.label?.trim()||Ye.id).slice(0,80),Ot=Ve.styleNode(Ye);Le.addNode(Ye.id,{label:Mt,size:Ot.size,x:0,y:0,color:Ot.color,labelColor:Ot.labelColor,zIndex:Ot.zIndex})}for(const Ye of we)if(!(!Le.hasNode(Ye.source)||!Le.hasNode(Ye.target)))try{Le.addEdgeWithKey(Ye.id,Ye.source,Ye.target,z(Ye.label,Ye.weight,Ve.edgeColor(Ye.label)))}catch{}if(it=Ki(Le,he,be,Ee,Te,Ae?Ye=>{const Ot=rt.get(Ye)?.facets;if(Ot==null||typeof Ot!="object"||Array.isArray(Ot))return null;const J=Ot[Ae];return J==null?null:String(J).trim()||null}:void 0),ot){it?.();return}const Ze=ee.sourceUsed==="graph";ve=new w(Le,T,{renderLabels:!0,defaultNodeColor:"#94a3b8",defaultEdgeColor:"#64748b",labelDensity:Ze?.14:.09,zIndex:!0,labelSize:Ze?14:13,labelWeight:"500",labelColor:{attribute:"labelColor",color:"#f1f5f9"},labelRenderedSizeThreshold:Ze?3:4,defaultDrawNodeHover:ze,...ce}),ve.on("clickNode",({node:Ye})=>{nt(Ye)}),ve.on("clickEdge",({edge:Ye})=>{lt(Ye)}),ve.on("clickStage",()=>{M()}),P=l(ve,Le.order,Ze),u(Ce,{graph:Le,sigma:ve},!0),u(Z,"ready")}catch(w){if(ot)return;u(Z,"error"),u(pe,w instanceof Error?w.message:String(w),!0)}})(),()=>{ot=!0,P(),it?.(),it=null,u(Ce,null),ve?.kill(),ve=null}}),De(()=>{const T=s(Ce);if(!T?.sigma)return;const{graph:ee,sigma:Te}=T,Ae=s(de),Ie=C(),we=V(),Ve=s(le),ot=s(ue),it=we?.kind==="platform_hull",P=we&&Ve.length>0?Hs(Ve,ot,we):null,w=Ae!=null&&ee.hasNode(Ae),E=!it&&w&&Ae!=null?Ao(ee,Ae,oe):null;if(!P&&!w){u(Ke,null);const Le=s(X)?.sourceUsed==="graph";Te.setSettings({nodeReducer:null,edgeReducer:null,...N(Le)});return}const he=P&&E?[...E].filter(Le=>P.has(Le)).length:P?P.size:E?E.size:ee.order,Ee=he>0&&he<=G,be=s(X)?.sourceUsed==="graph",ze=Ee?W():N(be);if(w&&Ae!=null&&E){const Le=ee.getNodeAttribute(Ae,"label"),rt=typeof Le=="string"&&Le.trim()?Le.trim():Ae,m=Ie?" · composition edges":"";let Ze=`${rt} · ${E.size} nodes (≤${oe} hops)${m}`;if(P&&we){const Ye=[...E].filter(Ot=>P.has(Ot)).length,Mt=we.kind==="scalar"?`${we.key}=${we.value}`:we.kind==="abstraction"?`abstraction=${we.value}`:we.kind==="chantier_week_neighborhood"?`demo_week=${we.week} (≤${zr} hops)`:we.kind==="audit_phase_neighborhood"?`audit_phase=${we.phase}`:`hull=${we.platformId}`;Ze+=` · facet ${Mt} · ${Ye} nodes in both`}u(Ke,Ze,!0)}else if(P&&we)if(we.kind==="platform_hull"){const rt=(s(Se).get(we.platformId)?.label||we.platformId).trim();u(Ke,`Ship hull · ${rt} · ≤${ni} hops · ${P.size} nodes — click row again to clear`)}else{const Le=we.kind==="scalar"?`${we.key}=${we.value}`:we.kind==="chantier_week_neighborhood"?`demo_week=${we.week} (≤${zr} hops)`:we.kind==="audit_phase_neighborhood"?`audit_phase=${we.phase}`:`abstraction=${we.value}`;u(Ke,`Facet · ${Le} · ${P.size} nodes — click row again to clear`)}else u(Ke,null);Te.setSettings({...ze,nodeReducer:(Le,rt)=>{let m=!1;return P&&!P.has(Le)&&(m=!0),!m&&E&&!E.has(Le)&&(m=!0),m?{...rt,hidden:!0}:Ee?{...rt,hidden:!1,forceLabel:!0}:{...rt,hidden:!1}},edgeReducer:(Le,rt)=>{const[m,Ze]=ee.extremities(Le);let Ye=!1;return P&&(!P.has(m)||!P.has(Ze))&&(Ye=!0),!Ye&&E&&(!E.has(m)||!E.has(Ze))&&(Ye=!0),!Ye&&Ie&&w&&!qo(String(rt.label??""))&&(Ye=!0),Ye?{...rt,hidden:!0}:{...rt,hidden:!1}}})});var Y=ml(),Q=g(Y);ei(Q,T=>u(_e,T),()=>s(_e));var Pe=b(Q,2);{var Ne=T=>{var ee=ul();let Te;var Ae=g(ee),Ie=g(Ae);let we;f(Ae);var Ve=b(Ae,2),ot=g(Ve);{var it=w=>{var E=dl(),he=qe(E),Ee=g(he);f(he);var be=b(he,2);{var ze=m=>{var Ze=ol(),Ye=b(qe(Ze),2),Mt=g(Ye);f(Ye),Yt(4),te(Ot=>B(Mt,`${Ot??""} edges`),[()=>s(Ge).edges.toLocaleString()]),x(m,Ze)},Le=m=>{var Ze=ll();Yt(2),x(m,Ze)},rt=m=>{var Ze=cl();Yt(2),x(m,Ze)};q(be,m=>{s(Ge).edges>0?m(ze):s(Ge).nodes>=s(je).nodeCount?m(Le,1):m(rt,-1)})}te((m,Ze)=>B(Ee,`${m??""}/${Ze??""} nodes`),[()=>s(Ge).nodes.toLocaleString(),()=>s(je).nodeCount.toLocaleString()]),x(w,E)},P=w=>{var E=hl(),he=qe(E),Ee=g(he);f(he),Yt(4),te((be,ze)=>B(Ee,`${be??""} nodes · ${ze??""} edges`),[()=>s(je).nodeCount.toLocaleString(),()=>s(Ge).edges.toLocaleString()]),x(w,E)};q(ot,w=>{s(et)?w(P,-1):w(it)})}f(Ve),f(ee),te(()=>{Te=at(ee,1,"stream-bar svelte-11bec40",null,Te,{"stream-bar--complete":s(et)}),we=ir(Ie,"",we,{width:`${s(vt)??""}%`})}),x(T,ee)};q(Pe,T=>{s(Oe)&&s(je)&&T(Ne)})}var ge=b(Pe,2);{var ye=T=>{var ee=fl(),Te=b(g(ee),2),Ae=g(Te,!0);f(Te),Yt(2),f(ee),te(()=>B(Ae,s(Ke))),x(T,ee)};q(ge,T=>{s(Ke)&&T(ye)})}var A=b(ge,2);{var re=T=>{var ee=gl(),Te=g(ee);f(ee),te(()=>B(Te,`Source: ${s(tt)??""}`)),x(T,ee)};q(A,T=>{s(Z)==="ready"&&s(tt)&&T(re)})}var ae=b(A,2);{var Me=T=>{var ee=vl();x(T,ee)};q(ae,T=>{s(Z)==="loading"&&!s(Oe)&&T(Me)})}var ke=b(ae,2);{var He=T=>{var ee=pl();x(T,ee)};q(ke,T=>{s(Z)==="empty"&&T(He)})}var Xe=b(ke,2);{var ut=T=>{var ee=yl(),Te=b(g(ee),2),Ae=g(Te,!0);f(Te),f(ee),te(()=>B(Ae,s(pe))),x(T,ee)};q(Xe,T=>{s(Z)==="error"&&T(ut)})}f(Y),x(t,Y),Pn()}const Kn={concreteClass:"#38bdf8",abstractClass:"#64748b",concreteLabel:"#f0f9ff",abstractLabel:"#cbd5e1",relationEdge:"#a78bfa",relationLabel:"#ede9fe",isAEdge:"#475569",isALabel:"#94a3b8"},bl=[{swatch:Kn.concreteClass,label:"Concrete class"},{swatch:Kn.abstractClass,label:"Abstract mixin"},{swatch:Kn.relationEdge,label:"Relation type"},{swatch:Kn.isAEdge,label:"Inheritance (is_a)",dashed:!0}];function kl(t){const e=t.abstract||t.synthetic;return{color:e?Kn.abstractClass:Kn.concreteClass,labelColor:e?Kn.abstractLabel:Kn.concreteLabel,size:e?10:14,label:t.label||t.typeName,forceLabel:!1,zIndex:e?2:4}}function wl(t){return t.kind==="is_a"?{color:Kn.isAEdge,labelColor:Kn.isALabel,size:1,label:"is_a",forceLabel:!1,type:"line",zIndex:1,dashed:!0}:{color:Kn.relationEdge,labelColor:Kn.relationLabel,size:2,label:t.edgeType??t.label,forceLabel:!1,type:"arrow",zIndex:3}}var xl=D('<p class="muted svelte-es94y4">No schema types to display.</p>'),Cl=D('<p class="error svelte-es94y4"> </p>'),Sl=D('<div class="legend-row svelte-es94y4"><span></span> <span class="legend-label svelte-es94y4"> </span></div>'),Nl=D('<div class="schema-graph svelte-es94y4"><div class="sigma-root svelte-es94y4"><!></div> <aside class="legend svelte-es94y4" aria-label="Schema graph legend"></aside></div>');function Bs(t,e){Dn(e,!0);let n=$(e,"showEdgeLabels",3,!1),r=L(void 0),i=L("loading"),a=L(null),o=null,l=0;De(()=>{const _=s(r),v=e.nodes,I=e.edges,O=n();if(!_)return;const j=++l;return c(_,v,I,O,j),()=>{l++,o?.kill(),o=null}});async function c(_,v,I,O,j){if(o?.kill(),o=null,u(a,null),v.length===0){u(i,"empty");return}u(i,"loading");try{const[{default:K},{MultiDirectedGraph:U},V,se]=await Promise.all([Gn(()=>import("../chunks/-OSExkSk.js"),__vite__mapDeps([0,1,2,3]),import.meta.url),Gn(()=>import("../chunks/Gs0cNFYG.js"),__vite__mapDeps([4,2]),import.meta.url),Gn(()=>import("../chunks/DyXQogav.js").then(N=>N.i),__vite__mapDeps([5,3]),import.meta.url),Gn(()=>import("../chunks/Cp9dXlPT.js").then(N=>N.i),__vite__mapDeps([6,3,7]),import.meta.url)]);if(j!==l||s(r)!==_)return;const oe=new U,ce=new Map(v.map(N=>[N.id,N])),G=new Map;for(const N of v){const W=kl(N);oe.addNode(N.id,{label:W.label,size:W.size,x:0,y:0,color:W.color,labelColor:W.labelColor,forceLabel:W.forceLabel,zIndex:W.zIndex,schemaAbstract:N.abstract||N.synthetic,schemaDomain:typeof N.metadata?.ontology_key=="string"?N.metadata.ontology_key:null})}for(const N of I){if(!oe.hasNode(N.source)||!oe.hasNode(N.target)||oe.hasEdge(N.id))continue;const W=wl(N);G.set(N.id,N);try{oe.addEdgeWithKey(N.id,N.source,N.target,{label:O&&N.importantLabel?W.label:"",size:W.size,color:W.color,labelColor:W.labelColor,forceLabel:O&&N.kind==="relation"&&N.importantLabel,type:"arrow",zIndex:W.zIndex,schemaKind:N.kind})}catch{G.delete(N.id)}}if(Lo(oe,V,se.default,"circular_force",N=>{const W=oe.getNodeAttribute(N,"schemaDomain");return typeof W=="string"&&W?W:null}),j!==l||s(r)!==_)return;o=new K(oe,_,{renderLabels:!0,renderEdgeLabels:O,labelDensity:.08,labelSize:12,labelWeight:"600",labelColor:{attribute:"labelColor",color:"#f0f9ff"},edgeLabelSize:10,edgeLabelWeight:"500",edgeLabelColor:{attribute:"labelColor",color:"#ede9fe"},labelRenderedSizeThreshold:9,zIndex:!0,defaultEdgeType:"arrow",enableEdgeEvents:!0,allowInvalidContainer:!0,edgeReducer(N,W){return oe.getEdgeAttribute(N,"schemaKind")==="is_a"?{...W,size:1,color:"#475569"}:W}}),o.on("clickNode",({node:N})=>{const W=ce.get(N);W&&e.onNodeClick?.(W)}),o.on("clickEdge",({edge:N})=>{const W=G.get(N);W&&e.onEdgeClick?.(W)}),o.refresh(),o.getCamera().animatedReset({duration:0}),u(i,"ready")}catch(K){if(j!==l)return;u(a,K instanceof Error?K.message:String(K),!0),u(i,"error")}}var d=Nl(),h=g(d),p=g(h);{var y=_=>{var v=xl();x(_,v)},k=_=>{var v=Cl(),I=g(v,!0);f(v),te(()=>B(I,s(a))),x(_,v)};q(p,_=>{s(i)==="empty"?_(y):s(i)==="error"&&s(a)&&_(k,1)})}f(h),ei(h,_=>u(r,_),()=>s(r));var C=b(h,2);kt(C,21,()=>bl,Tt,(_,v)=>{var I=Sl(),O=g(I);let j,K;var U=b(O,2),V=g(U,!0);f(U),f(I),te(()=>{j=at(O,1,"swatch svelte-es94y4",null,j,{dashed:s(v).dashed}),K=ir(O,"",K,{background:s(v).dashed?"transparent":s(v).swatch,"border-color":s(v).swatch}),B(V,s(v).label)}),x(_,I)}),f(C),f(d),x(t,d),Pn()}function Ir(t){return`entity_type:${t}`}function Ri(t){return t.metadata.synthetic===!0||t.metadata.abstract===!0}function Dl(t,e){return[...t.classes.values()].filter(n=>!(n.metadata.synthetic&&e||e&&Ri(n)))}function Pl(t){const e=t.metadata??{},n=typeof e.ghostcrab=="object"&&e.ghostcrab?e.ghostcrab:null,i=(typeof n?.["ghostcrab.native_edge_type"]=="string"?n["ghostcrab.native_edge_type"]:null)??(typeof e.linkml_slot=="string"?e.linkml_slot:null)??t.edgeType;return i.includes("contains")?"contains":i}const Il=new Set(["ADDRESSED_TO","APPOINTS","ASSOCIATED_WITH","BELONGS_TO","CLOSES","CONTAINS","DOCUMENTS","HAS_ACCOUNT","HAS_BUDGET","HAS_MEMBER","HAS_OCCUPANT","HAS_OWNER","LINKED_TO","LOCATED_IN","OPENS","OWNED_BY","PART_OF","RECORDED_IN","REFERENCES","REPRESENTS","RESULTS_FROM","TRIGGERS","USES_KEY","VERIFIES","VOTED_ON","contains","belongs_to","bills_to","created_by","has_member","leases","occupies","owns","primary_residence_of","triggers_spend","uses_common","uses_exclusive"]),Tl=["adm_","com_","dec_","exp_","tec_"];function Ml(t){return!t||t==="is_a"||Tl.some(e=>t.startsWith(e))?!1:Il.has(t)?!0:/^[A-Z][A-Z0-9_]+$/.test(t)}function El(t,e){const n=e.classes.get(t);return n?Ri(n):!1}function Al(t,e){return[...t.classes.values()].filter(n=>{if(n.metadata.synthetic||e&&Ri(n)||n.typeName==="Asset")return!1;let r=n.parentTypeName;for(;r;){if(r==="Asset")return!0;r=t.classes.get(r)?.parentTypeName??null}return!1}).map(n=>n.typeName).sort((n,r)=>n.localeCompare(r))}function Rl(t){return t.includes("contains")||t==="uses_common"||t==="uses_exclusive"||t==="part_of"}function Ol(t,e,n){return t.targetType!=="Asset"||!El("Asset",e)||!Rl(t.edgeType)?[t.targetType]:Al(e,n)}function Ll(t,e){const n=Dl(t,e.hideAbstract),r=new Set(n.map(l=>Ir(l.typeName))),i=n.map(l=>({id:Ir(l.typeName),typeName:l.typeName,label:l.label||l.typeName,abstract:Ri(l),synthetic:l.metadata.synthetic===!0,metadata:l.metadata})).sort((l,c)=>l.typeName.localeCompare(c.typeName)),a=[],o=new Set;if(e.showRelations)for(const l of t.allRelations){if(l.edgeType==="contains"&&l.targetType==="Asset")continue;const c=Ir(l.sourceType);if(!r.has(c))continue;const d=Pl(l);for(const h of Ol(l,t,e.hideAbstract)){const p=Ir(h);if(!r.has(p))continue;const y=`${l.sourceType}|${d}|${h}`;o.has(y)||(o.add(y),a.push({id:`rel:${y}`,kind:"relation",source:c,target:p,label:d,edgeType:l.edgeType,importantLabel:Ml(d),metadata:l.metadata}))}}if(e.showIsA)for(const l of n){if(!l.parentTypeName)continue;const c=Ir(l.typeName),d=Ir(l.parentTypeName);!r.has(c)||!r.has(d)||a.push({id:`isa:${l.typeName}->${l.parentTypeName}`,kind:"is_a",source:c,target:d,label:"is_a",importantLabel:!1})}return{nodes:i,edges:a,stats:{classCount:i.length,relationCount:a.filter(l=>l.kind==="relation").length,isACount:a.filter(l=>l.kind==="is_a").length}}}const mn="__all__";function Qr(t,e){const n=`${e}::`;if(t.startsWith(n))return t.slice(n.length);const r=t.indexOf("::");return r>=0?t.slice(r+2):t}async function Hl(t,e){return zl(t,e)}async function zl(t,e){const n=new URLSearchParams({ontology_id:t});e.trim()&&n.set("workspace_id",e.trim());const r=await fetch(`/api/brain/ontology/graph?${n}`);if(!r.ok)throw new Error(await r.text());const i=await r.json(),a=i.nodes??[],o=[];for(const l of a){const c=Or(l.metadata??l.metadata_json),d=rs(c);if(d["ghostcrab.native_edge_type"]!=="true")continue;const h=Wi(d["ghostcrab.native_edge_label"]),p=Wi(d["ghostcrab.source_entity_type"]),y=Wi(d["ghostcrab.target_entity_type"]);!h||!p||!y||o.push({edge_type:h,source_entity_type:p,target_entity_type:y,directed:!0,metadata:{...c,native_relation_class:String(l.type??l.id??h)}})}return{ontology_id:t,workspace_id:e,name:t,namespaces:[],dimensions:[],values:[],entity_types:a.filter(l=>{const c=String(l.kind??l.node_kind??"");return c==="entity_type"||c==="class"}).map(l=>{const c=String(l.id??"");return{entity_type:String(l.type??c.replace(/^entity_type:/,"").replace(/^class:/,"")),label:l.label==null?null:String(l.label),metadata:Or(l.metadata??l.metadata_json)}}).filter(l=>{const c=rs(Or(l.metadata));return Bl(l.entity_type)&&c["ghostcrab.native_edge_type"]!=="true"}),edge_types:[...(i.edges??[]).map(l=>{const c=l.source_entity_type??l.source_type,d=l.target_entity_type??l.target_type;return{edge_type:String(l.edge_type??l.type??l.label??l.id??"relation"),source_entity_type:c==null?null:String(c),target_entity_type:d==null?null:String(d),directed:l.directed!==!1,metadata:Or(l.metadata??l.metadata_json)}}),...o],integrity:{ok:!0}}}async function Fl(t){const e=new URLSearchParams({workspace:t}),n=await fetch(`/api/graph/schema-registry?${e}`);if(!n.ok)throw new Error(await n.text());return await n.json()}function Or(t){if(!t)return{};if(typeof t=="object"&&!Array.isArray(t))return t;if(typeof t!="string")return{};try{const e=JSON.parse(t);return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function Wi(t){return typeof t=="string"&&t.trim()?t.trim():null}function Zr(t,e){return`${t}:${e}`}function Bl(t){return!new Set(["owl_blank_node","owl_class","owl_object_property","owl_resource"]).has(t)}function rs(t){return t.ghostcrab&&typeof t.ghostcrab=="object"&&!Array.isArray(t.ghostcrab)?t.ghostcrab:{}}function jl(t,e,n){const r=rs(n)["ghostcrab.schema_family"];if(typeof r!="string")return e;const i=`${t}:`;if(!r.startsWith(i))return e;const a=r.slice(i.length).split(":")[0]?.trim();return a?`${t}::${a}`:e}function Vl(t,e){return t.entity_type}function Kl(t,e,n=mn,r=[]){const i=new Map,a=[],o=new Map,l=new Map,c=new Map,d=e.filter(_=>n===mn?!0:Qr(_.ontology_id,t)===n);for(const _ of d)for(const v of _.entity_types??[]){const I=Or(v.metadata),O=jl(t,_.ontology_id,I),j=Qr(O,t),K=typeof I.is_a=="string"&&I.is_a.trim()?I.is_a.trim():null,U=Zr(O,v.entity_type);o.has(v.entity_type)||o.set(v.entity_type,new Set),o.get(v.entity_type)?.add(O);const V=typeof I.linkml_class=="string"?I.linkml_class:"";V&&(l.has(V)||l.set(V,new Set),l.get(V)?.add(O)),K&&c.set(U,K),i.set(U,{typeName:U,label:Vl(v),parentTypeName:null,metadata:{...I,source_ontology_id:_.ontology_id,ontology_id:O,ontology_key:j,native_type:v.entity_type},properties:[],outgoingRelations:[],incomingRelations:[]})}function h(_,v){const I=Zr(v,_);if(i.has(I))return I;const O=Zr(`${t}::core`,_);if(i.has(O))return O;const j=o.get(_);return!j||j.size===0?null:j.size===1?Zr([...j][0],_):null}function p(_,v){const I=l.get(_);if(!I||I.size===0)return null;const O=I.has(v)?v:null,j=I.has(`${t}::core`)?`${t}::core`:null,K=O??j??(I.size===1?[...I][0]:null);if(!K)return null;for(const U of i.values())if(U.metadata.linkml_class===_&&U.metadata.ontology_id===K)return U.typeName;return null}function y(_){const v=Zr(`${t}::core`,_);return i.has(v)||i.set(v,{typeName:v,label:_,parentTypeName:null,metadata:{abstract:!0,synthetic:!0,ontology_id:`${t}::core`,ontology_key:"core",native_type:_},properties:[],outgoingRelations:[],incomingRelations:[]}),v}for(const[_,v]of c){const I=i.get(_);if(!I)continue;const O=typeof I.metadata.ontology_id=="string"?I.metadata.ontology_id:"";I.parentTypeName=h(v,O)??y(v)}for(const _ of d)for(const v of _.edge_types??[]){if(!v.source_entity_type||!v.target_entity_type)continue;const I=Or(v.metadata),O=h(v.source_entity_type,_.ontology_id),j=h(v.target_entity_type,_.ontology_id);if(!O||!j)continue;const K=i.get(O)?.metadata??{},U=typeof K.ontology_id=="string"?K.ontology_id:_.ontology_id,V={edgeType:v.edge_type,sourceType:O,targetType:j,label:v.edge_type,directed:v.directed!==!1,metadata:{...I,source_ontology_id:_.ontology_id,ontology_id:U,ontology_key:Qr(U,t),native_edge_type:v.edge_type,native_source_type:v.source_entity_type,native_target_type:v.target_entity_type}};a.push(V),i.get(V.sourceType)?.outgoingRelations.push(V),i.get(V.targetType)?.incomingRelations.push(V)}const k=new Set(["boolean","date","datetime","decimal","double","euro","float","integer","list<string>","string","time","uri"]),C=new Set(a.map(_=>`${_.sourceType}|${_.edgeType}|${_.targetType}`));for(const _ of r){if(n!==mn&&_.ontology_key!==n)continue;const v=`${t}::${_.ontology_key}`,I=h(_.entity_type,v);if(I)for(const O of _.fields??[]){const j=O.range?.trim();if(!j||k.has(j)||j.endsWith("Enum"))continue;const K=p(j,v)??h(j,v);if(!K)continue;const U=`${I}|${O.name}|${K}`;if(C.has(U))continue;C.add(U);const V={edgeType:O.name,sourceType:I,targetType:K,label:O.name,directed:!0,metadata:{ontology_id:v,ontology_key:_.ontology_key,schema_id:_.schema_id,native_edge_type:O.name,native_source_type:_.entity_type,native_target_range:j,field:O}};a.push(V),i.get(I)?.outgoingRelations.push(V),i.get(K)?.incomingRelations.push(V)}}for(const _ of i.values())_.outgoingRelations.sort((v,I)=>v.edgeType.localeCompare(I.edgeType)),_.incomingRelations.sort((v,I)=>v.edgeType.localeCompare(I.edgeType));return{ontologyId:n,classes:i,roots:[...i.values()].filter(_=>!_.parentTypeName||!i.has(_.parentTypeName)).map(_=>_.typeName).sort((_,v)=>_.localeCompare(v)),allRelations:a}}var $l=D("<option> </option>"),Zl=D('<p class="muted svelte-1hnvxh9">Loading workspace model...</p>'),Ul=D('<p class="error svelte-1hnvxh9"> </p>'),Wl=D('<div class="summary-bar svelte-1hnvxh9"><span> </span> <span> </span> <span> </span> <span> </span></div> <div class="model-graph-panel svelte-1hnvxh9"><div class="graph-toolbar svelte-1hnvxh9"><label class="svelte-1hnvxh9"><input type="checkbox" class="svelte-1hnvxh9"/> Relations métier</label> <label class="svelte-1hnvxh9"><input type="checkbox" class="svelte-1hnvxh9"/> Labels importants</label> <label class="svelte-1hnvxh9"><input type="checkbox" class="svelte-1hnvxh9"/> Abstractions</label> <label><input type="checkbox" class="svelte-1hnvxh9"/> Héritage</label> <span> </span></div> <!></div>',1),Gl=D("<span>registry unavailable</span>"),Yl=D('<p class="warn svelte-1hnvxh9"> </p>'),Xl=D('<button type="button" class="svelte-1hnvxh9"><strong class="svelte-1hnvxh9"> </strong> <span class="svelte-1hnvxh9"> </span> <small class="svelte-1hnvxh9"> </small></button>'),Jl=D('<p class="muted svelte-1hnvxh9">No schema registry rows for this view.</p>'),Ql=D('<div class="summary-bar svelte-1hnvxh9"><span> </span> <span> </span> <span> </span> <span> </span> <!></div> <div class="schema-layout svelte-1hnvxh9"><aside class="schema-list svelte-1hnvxh9" aria-label="Schema registry"><!> <!> <!></aside> <div class="schema-graph-panel svelte-1hnvxh9"><div class="graph-toolbar svelte-1hnvxh9"><label class="svelte-1hnvxh9"><input type="checkbox" class="svelte-1hnvxh9"/> Relations métier</label> <label class="svelte-1hnvxh9"><input type="checkbox" class="svelte-1hnvxh9"/> Labels importants</label> <label class="svelte-1hnvxh9"><input type="checkbox" class="svelte-1hnvxh9"/> Abstractions</label> <label><input type="checkbox" class="svelte-1hnvxh9"/> Héritage</label> <span> </span></div> <!></div></div>',1),ql=D('<div class="workspace-model svelte-1hnvxh9"><div class="model-toolbar svelte-1hnvxh9"><div class="segmented svelte-1hnvxh9" role="tablist" aria-label="Model surface"><button type="button">Ontologies</button> <button type="button">Schema</button></div> <label class="select-wrap svelte-1hnvxh9"><span>View</span> <select class="svelte-1hnvxh9"><option>Tous</option><!></select></label></div> <!></div>');function ec(t,e){Dn(e,!0);let n=$(e,"selectedOntologyId",3,mn),r=L("ontologies"),i=L(Ut(mn)),a=L(!0),o=L(null),l=L(Ut([])),c=L(null),d=L(!0),h=L(!0),p=L(!1),y=L(!1),k=L(Ut([])),C=L(Ut([])),_=L(Ut({classCount:0,relationCount:0,isACount:0}));De(()=>{e.workspaceId&&e.ontologies.length>0&&v()}),De(()=>{u(i,n()===mn?mn:Qr(n(),e.workspaceId),!0)}),De(()=>{const _e=Kl(e.workspaceId,s(l),s(i),s(c)?.rows??[]),Z=Ll(_e,{hideAbstract:!s(y),showRelations:s(d),showIsA:s(y)&&s(p)});u(k,Z.nodes,!0),u(C,Z.edges,!0),u(_,Z.stats,!0)});async function v(){u(a,!0),u(o,null);try{const _e=await Promise.all(e.ontologies.map(Z=>Hl(Z.ontology_id,e.workspaceId)));u(l,_e,!0);try{u(c,await Fl(e.workspaceId),!0)}catch(Z){u(c,{workspace_id:e.workspaceId,total:0,facet_definition_total:0,rows:[],source:"unavailable",error:Z instanceof Error?Z.message:String(Z)},!0)}}catch(_e){u(o,_e instanceof Error?_e.message:String(_e),!0),u(l,[],!0),u(c,null)}finally{u(a,!1)}}function I(_e){return Qr(_e.ontology_id,e.workspaceId)}function O(){return s(i)===mn?s(l):s(l).filter(_e=>I(_e)===s(i))}function j(){const _e=s(c)?.rows??[];return s(i)===mn?_e:_e.filter(Z=>Z.ontology_key===s(i))}function K(_e){const Z=_e.metadata??{};e.onSelect?.({nodeKind:"entity",typeName:String(Z.native_type??_e.typeName),payload:{...Z,typeName:String(Z.native_type??_e.typeName),qualifiedTypeName:_e.typeName,ontology_id:Z.ontology_id}})}function U(_e){const Z=_e.metadata??{};e.onSelect?.({nodeKind:"edge",typeName:String(Z.native_edge_type??_e.edgeType??_e.label),payload:{id:_e.id,source:_e.source,target:_e.target,label:_e.label,edgeType:String(Z.native_edge_type??_e.edgeType??_e.label),ontology_id:Z.ontology_id,native_source_type:Z.native_source_type,native_target_type:Z.native_target_type}})}var V=ql(),se=g(V),oe=g(se),ce=g(oe);let G;var N=b(ce,2);let W;f(oe);var z=b(oe,2),X=b(g(z),2),le=g(X),ue={},Se=b(le);kt(Se,17,()=>e.ontologies,Tt,(_e,Z)=>{var pe=$l(),ve=g(pe,!0);f(pe);var Ke={};te((Oe,je)=>{B(ve,Oe),Ke!==(Ke=je)&&(pe.value=(pe.__value=je)??"")},[()=>I(s(Z)),()=>I(s(Z))]),x(_e,pe)}),f(X),f(z),f(se);var ie=b(se,2);{var de=_e=>{var Z=Zl();x(_e,Z)},Ce=_e=>{var Z=Ul(),pe=g(Z,!0);f(Z),te(()=>B(pe,s(o))),x(_e,Z)},xe=_e=>{var Z=Wl(),pe=qe(Z),ve=g(pe),Ke=g(ve);f(ve);var Oe=b(ve,2),je=g(Oe);f(Oe);var Ge=b(Oe,2),et=g(Ge);f(Ge);var $e=b(Ge,2),mt=g($e);f($e),f(pe);var vt=b(pe,2),Qe=g(vt),Fe=g(Qe),nt=g(Fe);Tn(nt),Yt(),f(Fe);var lt=b(Fe,2),H=g(lt);Tn(H),Yt(),f(lt);var ne=b(lt,2),F=g(ne);Tn(F),Yt(),f(ne);var M=b(ne,2);let R;var Y=g(M);Tn(Y),Yt(),f(M);var Q=b(M,2),Pe=g(Q);f(Q),f(Qe);var Ne=b(Qe,2);Bs(Ne,{get nodes(){return s(k)},get edges(){return s(C)},get showEdgeLabels(){return s(h)},onNodeClick:K,onEdgeClick:U}),f(vt),te((ge,ye)=>{B(Ke,`${ge??""} ontologies`),B(je,`${s(_).classCount??""} classes`),B(et,`${s(_).relationCount??""} relations`),B(mt,`${ye??""} dimensions`),R=at(M,1,"svelte-1hnvxh9",null,R,{disabled:!s(y)}),Y.disabled=!s(y),B(Pe,`${s(_).classCount??""} classes · ${s(_).relationCount??""} relations · ${s(_).isACount??""} is_a`)},[()=>O().length,()=>O().reduce((ge,ye)=>ge+(ye.dimensions?.length??0),0)]),lr(nt,()=>s(d),ge=>u(d,ge)),lr(H,()=>s(h),ge=>u(h,ge)),lr(F,()=>s(y),ge=>u(y,ge)),lr(Y,()=>s(p),ge=>u(p,ge)),x(_e,Z)},tt=_e=>{var Z=Ql(),pe=qe(Z),ve=g(pe),Ke=g(ve);f(ve);var Oe=b(ve,2),je=g(Oe);f(Oe);var Ge=b(Oe,2),et=g(Ge);f(Ge);var $e=b(Ge,2),mt=g($e);f($e);var vt=b($e,2);{var Qe=T=>{var ee=Gl();x(T,ee)};q(vt,T=>{s(c)?.source==="unavailable"&&T(Qe)})}f(pe);var Fe=b(pe,2),nt=g(Fe),lt=g(nt);{var H=T=>{var ee=Yl(),Te=g(ee,!0);f(ee),te(()=>B(Te,s(c).error)),x(T,ee)};q(lt,T=>{s(c)?.error&&T(H)})}var ne=b(lt,2);kt(ne,17,j,Tt,(T,ee)=>{var Te=Xl(),Ae=g(Te),Ie=g(Ae,!0);f(Ae);var we=b(Ae,2),Ve=g(we,!0);f(we);var ot=b(we,2),it=g(ot);f(ot),f(Te),te(()=>{B(Ie,s(ee).entity_type),B(Ve,s(ee).schema_id),B(it,`${s(ee).facet_definition_count??""} facets`)}),Be("click",Te,()=>e.onSelect?.({nodeKind:"schema",typeName:s(ee).entity_type,payload:s(ee)})),x(T,Te)});var F=b(ne,2);{var M=T=>{var ee=Jl();x(T,ee)},R=me(()=>j().length===0);q(F,T=>{s(R)&&T(M)})}f(nt);var Y=b(nt,2),Q=g(Y),Pe=g(Q),Ne=g(Pe);Tn(Ne),Yt(),f(Pe);var ge=b(Pe,2),ye=g(ge);Tn(ye),Yt(),f(ge);var A=b(ge,2),re=g(A);Tn(re),Yt(),f(A);var ae=b(A,2);let Me;var ke=g(ae);Tn(ke),Yt(),f(ae);var He=b(ae,2),Xe=g(He);f(He),f(Q);var ut=b(Q,2);Bs(ut,{get nodes(){return s(k)},get edges(){return s(C)},get showEdgeLabels(){return s(h)},onNodeClick:K,onEdgeClick:U}),f(Y),f(Fe),te((T,ee)=>{B(Ke,`${T??""} schemas`),B(je,`${ee??""} facet definitions`),B(et,`${s(_).classCount??""} graph classes`),B(mt,`${s(_).relationCount??""} graph relations`),Me=at(ae,1,"svelte-1hnvxh9",null,Me,{disabled:!s(y)}),ke.disabled=!s(y),B(Xe,`${s(_).classCount??""} classes · ${s(_).relationCount??""} relations · ${s(_).isACount??""} is_a`)},[()=>j().length,()=>j().reduce((T,ee)=>T+ee.facet_definition_count,0)]),lr(Ne,()=>s(d),T=>u(d,T)),lr(ye,()=>s(h),T=>u(h,T)),lr(re,()=>s(y),T=>u(y,T)),lr(ke,()=>s(p),T=>u(p,T)),x(_e,Z)};q(ie,_e=>{s(a)?_e(de):s(o)?_e(Ce,1):s(r)==="ontologies"?_e(xe,2):_e(tt,-1)})}f(V),te(()=>{G=at(ce,1,"svelte-1hnvxh9",null,G,{active:s(r)==="ontologies"}),W=at(N,1,"svelte-1hnvxh9",null,W,{active:s(r)==="schema"}),ue!==(ue=mn)&&(le.value=(le.__value=mn)??"")}),Be("click",ce,()=>u(r,"ontologies")),Be("click",N,()=>u(r,"schema")),Hr(X,()=>s(i),_e=>u(i,_e)),x(t,V),Pn()}Fn(["click"]);var tc=D('<p class="muted svelte-1d1a86y">Select an ontology to explore the model.</p>'),nc=D('<div class="modele-panel svelte-1d1a86y"><div class="body svelte-1d1a86y"><!></div></div>');function rc(t,e){Dn(e,!0);let n=$(e,"workspaceId",3,""),r=$(e,"ontologies",19,()=>[]);var i=nc(),a=g(i),o=g(a);{var l=d=>{var h=tc();x(d,h)},c=d=>{{let h=me(()=>e.ontologyId||mn);ec(d,{get workspaceId(){return n()},get ontologies(){return r()},get selectedOntologyId(){return s(h)},get onSelect(){return e.onSelect}})}};q(o,d=>{!e.ontologyId||r().length===0?d(l):d(c,-1)})}f(a),f(i),x(t,i),Pn()}var ic=D('<p class="search-error svelte-yyldap"> </p>'),sc=D('<span class="result-sub svelte-yyldap"> </span>'),ac=D('<button type="button" class="clear-result svelte-yyldap" title="Clear search focus">×</button>'),oc=D('<div><button type="button" class="result svelte-yyldap"><span class="result-label svelte-yyldap"> </span> <!></button> <!></div>'),lc=D('<div class="results svelte-yyldap"></div>'),cc=D('<section class="search svelte-yyldap" aria-label="Graph search"><form class="search-form svelte-yyldap"><select aria-label="Search mode" class="svelte-yyldap"><option>Graph</option><option>BM25</option></select> <input placeholder="Search graph" aria-label="Search query" class="svelte-yyldap"/> <button type="submit" class="svelte-yyldap"> </button></form></section> <!> <!>',1);function dc(t,e){Dn(e,!0);let n=$(e,"workspaceId",3,"default"),r=$(e,"entityType",3,null),i=L("graph"),a=L(""),o=L(!1),l=L(null),c=L(Ut([])),d=L("");function h(z){const X=Number(z.entity_id??z.id);return Number.isFinite(X)&&X>0?X:null}function p(z){return z.map(X=>{const le=h(X);return{key:String(le??X.name??crypto.randomUUID()),label:String(X.name??X.entity_type??le??"result"),subtitle:X.score==null?String(X.entity_type??""):`score ${Number(X.score).toFixed(2)}`,entityId:le??void 0,raw:X}})}function y(z){return z.map(X=>{const le=h(X),ue=X.score??X.rank,Se=String(X.excerpt??X.content??X.snippet??"").slice(0,120);return{key:String(X.doc_id??le??crypto.randomUUID()),label:String(X.title??X.doc_id??X.name??"document"),subtitle:[ue==null?null:`score ${Number(ue).toFixed(2)}`,Se||null].filter(Boolean).join(" · "),entityId:le??void 0,raw:X}})}async function k(){u(o,!0),u(l,null),u(c,[],!0),u(d,"");try{const z=n().trim()||"default";if(s(i)==="graph"){const X=new URLSearchParams({workspace_id:z,query:s(a),limit:"20"});r()&&X.set("entity_type",r());const le=await fetch(`/api/brain/ghostcrab/graph-search?${X}`);if(!le.ok)throw new Error(await le.text());const ue=await le.json();u(c,p(ue.rows??[]),!0),e.onSeeds?.(s(c).map(Se=>Se.entityId).filter(Se=>Se!=null))}else{const X=await fetch("/api/brain/ghostcrab/search",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({workspace_id:z,query:s(a),embedding:[],vector_weight:0,limit:20})});if(!X.ok)throw new Error(await X.text());const le=await X.json();u(c,y(le.matches??[]),!0),e.onSeeds?.(s(c).map(ue=>ue.entityId).filter(ue=>ue!=null))}}catch(z){u(l,z instanceof Error?z.message:String(z),!0)}finally{u(o,!1)}}function C(z){z.entityId!=null&&(u(d,z.key,!0),e.onSeeds?.([z.entityId]))}function _(){u(d,""),e.onSeeds?.([])}var v=cc(),I=qe(v),O=g(I),j=g(O),K=g(j);K.value=K.__value="graph";var U=b(K);U.value=U.__value="bm25",f(j);var V=b(j,2);Tn(V);var se=b(V,2),oe=g(se,!0);f(se),f(O),f(I);var ce=b(I,2);{var G=z=>{var X=ic(),le=g(X,!0);f(X),te(()=>B(le,s(l))),x(z,X)};q(ce,z=>{s(l)&&z(G)})}var N=b(ce,2);{var W=z=>{var X=lc();kt(X,21,()=>s(c).slice(0,8),Tt,(le,ue)=>{var Se=oc();let ie;var de=g(Se),Ce=g(de),xe=g(Ce,!0);f(Ce);var tt=b(Ce,2);{var _e=ve=>{var Ke=sc(),Oe=g(Ke,!0);f(Ke),te(()=>B(Oe,s(ue).subtitle)),x(ve,Ke)};q(tt,ve=>{s(ue).subtitle&&ve(_e)})}f(de);var Z=b(de,2);{var pe=ve=>{var Ke=ac();te(()=>An(Ke,"aria-label",`Clear search focus for ${s(ue).label}`)),Be("click",Ke,_),x(ve,Ke)};q(Z,ve=>{s(d)===s(ue).key&&ve(pe)})}f(Se),te(()=>{ie=at(Se,1,"result-wrap svelte-yyldap",null,ie,{focused:s(d)===s(ue).key}),de.disabled=s(ue).entityId==null,B(xe,s(ue).label)}),Be("click",de,()=>C(s(ue))),x(le,Se)}),f(X),x(z,X)};q(N,z=>{s(c).length>0&&z(W)})}te(()=>{se.disabled=s(o),B(oe,s(o)?"Searching":"Search")}),St("submit",O,z=>{z.preventDefault(),k()}),Hr(j,()=>s(i),z=>u(i,z)),Br(V,()=>s(a),z=>u(a,z)),x(t,v),Pn()}Fn(["click"]);var hc=D('<p class="legend-hint-line svelte-lmk6mp"><strong>Facet row</strong>: filter graph — chantier weeks use <code class="svelte-lmk6mp">week_number</code> </p>'),uc=D("<strong>Ship</strong> ",1),fc=D('<div class="legend-hint svelte-lmk6mp"><p class="legend-hint-line svelte-lmk6mp"><strong>Node</strong> <strong>Background</strong>: reset selection</p> <!> <p class="legend-hint-line svelte-lmk6mp"><!> <strong>Links</strong>: edge mode + composition when a node is focused</p></div>'),gc=D('<div class="legend-hint svelte-lmk6mp"><p class="legend-hint-line svelte-lmk6mp"><strong>Facet row</strong>: filter graph — chantier weeks use <code class="svelte-lmk6mp">week_number</code> </p> <p class="legend-hint-line svelte-lmk6mp"><strong>Ship</strong> </p></div>'),vc=D('<div class="legend-active svelte-lmk6mp" role="status" aria-label="Active facet filter"><span class="svelte-lmk6mp">Active filter</span> <strong class="svelte-lmk6mp"> </strong> <button type="button" class="svelte-lmk6mp">clear</button></div>'),pc=D("<!> <!>",1),yc=D('<p class="legend-empty svelte-lmk6mp"><!></p>'),mc=D('<button type="button"><span class="swatch svelte-lmk6mp"></span> <span class="legend-label svelte-lmk6mp"> </span></button>'),_c=D('<div class="legend-row svelte-lmk6mp"><span class="swatch svelte-lmk6mp"></span> <span class="legend-label svelte-lmk6mp"> </span></div>'),bc=D('<div class="legend-block-rows svelte-lmk6mp"></div>'),kc=D('<div class="legend-block svelte-lmk6mp"><button type="button"><span aria-hidden="true">›</span> <span class="legend-block-title svelte-lmk6mp"> </span></button> <!></div>'),wc=D('<div class="legend svelte-lmk6mp"><!> <!> <!></div>');function js(t,e){Dn(e,!0);let n=$(e,"legendBlocks",19,()=>[]),r=$(e,"facetFilter",15,null),i=$(e,"focusDepth",3,2),a=$(e,"variant",3,"all");function o(G){return G.rows.some(N=>N.facetFilter)}const l=me(()=>a()==="all"?n():a()==="facets"?n().filter(o):n().filter(G=>!o(G)));function c(G,N){return G===N?!0:!G||!N||G.kind!==N.kind?!1:G.kind==="scalar"&&N.kind==="scalar"?G.key===N.key&&G.value===N.value:G.kind==="platform_hull"&&N.kind==="platform_hull"?G.platformId===N.platformId:G.kind==="abstraction"&&N.kind==="abstraction"?G.value===N.value:G.kind==="chantier_week_neighborhood"&&N.kind==="chantier_week_neighborhood"?G.week===N.week:G.kind==="audit_phase_neighborhood"&&N.kind==="audit_phase_neighborhood"?G.phase===N.phase:!1}function d(G){return G.kind==="scalar"?`${G.key} = ${G.value}`:G.kind==="abstraction"?`abstraction = ${G.value}`:G.kind==="chantier_week_neighborhood"?`week_number = ${G.week} (≤${zr} hops)`:G.kind==="audit_phase_neighborhood"?`audit_phase = ${G.phase}`:`hull = ${G.platformId}`}function h(G){return!!(G.facetFilter&&c(r(),G.facetFilter))}function p(G){if(!G.facetFilter)return;const N=G.facetFilter;if(c(r(),N)){r(null);return}r(N)}let y=L(Ut(new Set)),k=L(null);function C(G){return G.title}function _(G){return s(y).has(G)}function v(G){const N=C(G),W=new Set(s(y));W.has(N)?W.delete(N):W.add(N),u(y,W,!0)}function I(G){return G.rows.some(N=>h(N))}De(()=>{if(a()!=="facets")return;const G=r();if(!G){u(k,null);return}if(c(G,s(k)))return;u(k,G,!0);const N=s(l).filter(I).map(C);N.length!==0&&u(y,new Set([...s(y),...N]),!0)});var O=wc(),j=g(O);{var K=G=>{var N=fc(),W=g(N),z=b(g(W));Yt(2),f(W);var X=b(W,2);{var le=de=>{var Ce=hc(),xe=b(g(Ce),3);f(Ce),te(()=>B(xe,` + neighbors
|
|
5
|
+
≤${zr} hops; click the same row again to clear`)),x(de,Ce)};q(X,de=>{a()==="all"&&de(le)})}var ue=b(X,2),Se=g(ue);{var ie=de=>{var Ce=uc(),xe=b(qe(Ce));te(()=>B(xe,`: hull ≤${ni} hops ·`)),x(de,Ce)};q(Se,de=>{a()==="all"&&de(ie)})}Yt(3),f(ue),f(N),te(()=>B(z,`: neighborhood ≤${i()??""} hops · `)),x(G,N)};q(j,G=>{(a()==="all"||a()==="legend")&&G(K)})}var U=b(j,2);{var V=G=>{var N=pc(),W=qe(N);{var z=ue=>{var Se=gc(),ie=g(Se),de=b(g(ie),3);f(ie);var Ce=b(ie,2),xe=b(g(Ce));f(Ce),f(Se),te(()=>{B(de,` + neighbors
|
|
6
|
+
≤${zr} hops; click the same row again to clear`),B(xe,`: hull ≤${ni} hops`)}),x(ue,Se)};q(W,ue=>{a()==="facets"&&ue(z)})}var X=b(W,2);{var le=ue=>{var Se=vc(),ie=b(g(Se),2),de=g(ie,!0);f(ie);var Ce=b(ie,2);f(Se),te(xe=>B(de,xe),[()=>d(r())]),Be("click",Ce,()=>{r(null)}),x(ue,Se)};q(X,ue=>{r()&&ue(le)})}x(G,N)};q(U,G=>{(a()==="all"||a()==="facets")&&G(V)})}var se=b(U,2);{var oe=G=>{var N=yc(),W=g(N);{var z=ue=>{var Se=zn("No facet dimensions in this graph.");x(ue,Se)},X=ue=>{var Se=zn("Load a graph to see ontology and relation colours.");x(ue,Se)},le=ue=>{var Se=zn("Load a graph to see ontology and relation facets.");x(ue,Se)};q(W,ue=>{a()==="facets"?ue(z):a()==="legend"?ue(X,1):ue(le,-1)})}f(N),x(G,N)},ce=G=>{var N=Ft(),W=qe(N);kt(W,17,()=>s(l),z=>C(z),(z,X)=>{var le=kc(),ue=g(le);let Se;var ie=g(ue);let de;var Ce=b(ie,2),xe=g(Ce,!0);f(Ce),f(ue);var tt=b(ue,2);{var _e=pe=>{var ve=bc();kt(ve,21,()=>s(X).rows,Tt,(Ke,Oe)=>{var je=Ft(),Ge=qe(je);{var et=mt=>{var vt=mc();let Qe;var Fe=g(vt);let nt;var lt=b(Fe,2),H=g(lt,!0);f(lt),f(vt),te(ne=>{Qe=at(vt,1,"legend-row legend-row--clickable svelte-lmk6mp",null,Qe,ne),nt=ir(Fe,"",nt,{background:s(Oe).swatch}),B(H,s(Oe).label)},[()=>({"legend-row--active":h(s(Oe))})]),Be("click",vt,()=>p(s(Oe))),x(mt,vt)},$e=mt=>{var vt=_c(),Qe=g(vt);let Fe;var nt=b(Qe,2),lt=g(nt,!0);f(nt),f(vt),te(()=>{Fe=ir(Qe,"",Fe,{background:s(Oe).swatch}),B(lt,s(Oe).label)}),x(mt,vt)};q(Ge,mt=>{s(Oe).facetFilter?mt(et):mt($e,-1)})}x(Ke,je)}),f(ve),x(pe,ve)},Z=me(()=>_(C(s(X))));q(tt,pe=>{s(Z)&&pe(_e)})}f(le),te((pe,ve,Ke)=>{Se=at(ue,1,"legend-block-toggle svelte-lmk6mp",null,Se,pe),An(ue,"aria-expanded",ve),de=at(ie,1,"block-chevron svelte-lmk6mp",null,de,Ke),B(xe,s(X).title)},[()=>({"legend-block-toggle--active":I(s(X))}),()=>_(C(s(X))),()=>({expanded:_(C(s(X)))})]),Be("click",ue,()=>v(s(X))),x(z,le)}),x(G,N)};q(se,G=>{s(l).length===0?G(oe):G(ce,-1)})}f(O),te(()=>An(O,"aria-label",a()==="facets"?"Graph facets":"Graph legend")),x(t,O),Pn()}Fn(["click"]);function Gi(t){if(!t)return{};if(typeof t=="object"&&!Array.isArray(t))return t;if(typeof t!="string")return{};try{const e=JSON.parse(t);return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function pi(t){const e=Number(t);return!Number.isFinite(e)||e<=0?null:new Date(e*1e3).toISOString().slice(0,10)}function _r(t,e=new Set){const n=[];for(const[r,i]of Object.entries(t))e.has(r)||i==null||i===""||typeof i!="object"&&n.push([r,String(i)]);return n}function xc(t){const e=t.triples;if(!Array.isArray(e))return[];const n=[];for(const r of e){if(!r||typeof r!="object")continue;const i=r,a=String(i.predicate??"");a&&n.push({subject:String(i.subject??""),predicate:a,object_value:String(i.object_value??i.object??""),object_kind:i.object_kind==null?void 0:String(i.object_kind)})}return n}function Cc(t){for(const e of t){const n=e.predicate.toLowerCase();if(n.includes("definition")||n.endsWith("comment")||n.endsWith("label"))return e.object_value}return null}const Sc="http://www.w3.org/2000/01/rdf-schema#domain",Nc="http://www.w3.org/2000/01/rdf-schema#range",Dc="http://www.w3.org/2002/07/owl#DatatypeProperty",Pc="http://www.w3.org/1999/02/22-rdf-syntax-ns#type";function is(t){const e=t.lastIndexOf("#");if(e>=0)return t.slice(e+1);const n=t.lastIndexOf("/");return n>=0?t.slice(n+1):t.startsWith("studio:")?t.slice(7):t}function Ic(t){return t.includes("XMLSchema#string")?"string":t.includes("XMLSchema#date")?"date":t.includes("XMLSchema#integer")?"integer":t.includes("XMLSchema#decimal")||t.includes("XMLSchema#double")?"number":t.includes("XMLSchema#boolean")?"boolean":is(t)}function Tc(t,e,n){const r=new Set([e]);n&&r.add(n),r.add(`studio:class:${e}`);const i=new Map;for(const o of t){const l=i.get(o.subject)??[];l.push(o),i.set(o.subject,l)}const a=[];for(const[o,l]of i){if(!l.some(y=>y.predicate===Pc&&(y.object_value===Dc||y.object_value.endsWith("DatatypeProperty"))))continue;const d=l.find(y=>y.predicate===Sc)?.object_value;if(!d||!r.has(d)&&!r.has(is(d)))continue;const h=l.find(y=>y.predicate===Nc),p=o.startsWith("studio:property:")?o.slice(16):is(o);a.push({name:p,range:h?Ic(h.object_value):"string",propertyUri:o})}return a.sort((o,l)=>o.name.localeCompare(l.name))}var Mc=D('<label class="svelte-pwv6at"><span class="svelte-pwv6at">Range</span> <select class="svelte-pwv6at"><option>string</option><option>date</option><option>integer</option><option>number</option><option>boolean</option></select></label>'),Ec=D('<label class="svelte-pwv6at"><span class="svelte-pwv6at">Target class</span> <input placeholder="unit" class="svelte-pwv6at"/></label>'),Ac=D('<p class="error svelte-pwv6at"> </p>'),Rc=D('<form class="property-editor svelte-pwv6at"><h4 class="svelte-pwv6at"> </h4> <label class="svelte-pwv6at"><span class="svelte-pwv6at">Name</span> <input class="svelte-pwv6at"/></label> <!> <label class="checkbox svelte-pwv6at"><input type="checkbox" class="svelte-pwv6at"/> <span class="svelte-pwv6at">Required</span></label> <!> <div class="actions svelte-pwv6at"><button type="button" class="secondary svelte-pwv6at">Cancel</button> <button type="submit" class="svelte-pwv6at"> </button></div></form>');function Oc(t,e){Dn(e,!0);let n=$(e,"kind",3,"datatype"),r=$(e,"initialName",3,""),i=$(e,"initialRange",3,"string"),a=$(e,"initialTarget",3,""),o=L(""),l=L("string"),c=L(""),d=L(!1),h=L(!1),p=L(null);De(()=>{u(o,r()),u(l,i()),u(c,a())});async function y(){if(!s(o).trim()){u(p,"Name is required.");return}u(h,!0),u(p,null);try{const z=n()==="object"?{ontology_id:e.ontologyId,edge_type:s(o).trim(),source_entity_type:e.domainClass,target_entity_type:s(c).trim()||"unit",directed:!0,metadata_json:JSON.stringify({required:s(d)})}:{ontology_id:e.ontologyId,name:s(o).trim(),kind:"datatype",domain:e.domainClass,range:s(l).trim()||"string",required:s(d),metadata_json:JSON.stringify({})},X=n()==="object"?"/api/brain/ontology/edge-type":"/api/brain/ontology/property",le=await fetch(X,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(z)});if(!le.ok)throw new Error(await le.text());e.onSaved?.()}catch(z){u(p,z instanceof Error?z.message:String(z),!0)}finally{u(h,!1)}}var k=Rc(),C=g(k),_=g(C);f(C);var v=b(C,2),I=b(g(v),2);Tn(I),f(v);var O=b(v,2);{var j=z=>{var X=Mc(),le=b(g(X),2),ue=g(le);ue.value=ue.__value="string";var Se=b(ue);Se.value=Se.__value="date";var ie=b(Se);ie.value=ie.__value="integer";var de=b(ie);de.value=de.__value="number";var Ce=b(de);Ce.value=Ce.__value="boolean",f(le),f(X),Hr(le,()=>s(l),xe=>u(l,xe)),x(z,X)},K=z=>{var X=Ec(),le=b(g(X),2);Tn(le),f(X),Br(le,()=>s(c),ue=>u(c,ue)),x(z,X)};q(O,z=>{n()==="datatype"?z(j):z(K,-1)})}var U=b(O,2),V=g(U);Tn(V),Yt(2),f(U);var se=b(U,2);{var oe=z=>{var X=Ac(),le=g(X,!0);f(X),te(()=>B(le,s(p))),x(z,X)};q(se,z=>{s(p)&&z(oe)})}var ce=b(se,2),G=g(ce),N=b(G,2),W=g(N,!0);f(N),f(ce),f(k),te(()=>{B(_,`${n()==="object"?"Add relation":"Add property"} · ${e.domainClass??""}`),An(I,"placeholder",n()==="object"?"owns":"quotePart"),N.disabled=s(h),B(W,s(h)?"Saving…":"Save")}),St("submit",k,z=>(z.preventDefault(),y())),Br(I,()=>s(o),z=>u(o,z)),lr(V,()=>s(d),z=>u(d,z)),Be("click",G,()=>e.onCancel?.()),x(t,k),Pn()}Fn(["click"]);var Lc=D('<div class="help-popover svelte-r3rl1u" role="dialog"> </div>'),Hc=D('<span class="help-wrap svelte-r3rl1u"><button type="button" class="help-hint svelte-r3rl1u">?</button> <!></span>');function zc(t,e){Dn(e,!0);let n=$(e,"label",3,"Help"),r=L(!1),i=L(void 0);function a(){u(r,!s(r))}function o(){u(r,!1)}De(()=>{if(!s(r))return;function p(k){k.key==="Escape"&&o()}function y(k){const C=k.target;s(i)&&C&&!s(i).contains(C)&&o()}return document.addEventListener("keydown",p),document.addEventListener("pointerdown",y,!0),()=>{document.removeEventListener("keydown",p),document.removeEventListener("pointerdown",y,!0)}});var l=Hc(),c=g(l),d=b(c,2);{var h=p=>{var y=Lc(),k=g(y,!0);f(y),te(()=>{An(y,"aria-label",n()),B(k,e.text)}),x(p,y)};q(d,p=>{s(r)&&p(h)})}f(l),ei(l,p=>u(i,p),()=>s(i)),te(()=>{An(c,"aria-label",n()),An(c,"aria-expanded",s(r))}),Be("click",c,a),x(t,l),Pn()}Fn(["click"]);const Fc={inspectorDefinition:"Edit label, description, properties, and relations for the selected type. Use the Taxonomies tab only for enum value lists."};var Bc=D('<h2 class="svelte-k2kih7">Inspector</h2>'),jc=D('<p class="muted svelte-k2kih7">Select a node or edge to inspect instance facts and ontology definition.</p>'),Vc=D('<p class="muted svelte-k2kih7">Loading…</p>'),Kc=D('<p class="warn svelte-k2kih7"> </p>'),$c=D('<button type="button" class="link svelte-k2kih7">View type in Modèle</button>'),Zc=D('<p class="subtitle svelte-k2kih7"> <!></p>'),Uc=D('<div class="svelte-k2kih7"><dt class="svelte-k2kih7"> </dt><dd class="svelte-k2kih7"> </dd></div>'),Wc=D('<dl class="kv svelte-k2kih7"></dl>'),Gc=D('<div class="svelte-k2kih7"><dt class="svelte-k2kih7"> </dt><dd class="svelte-k2kih7"> </dd></div>'),Yc=D('<h4 class="svelte-k2kih7">Relation properties</h4> <dl class="kv svelte-k2kih7"></dl>',1),Xc=D('<div class="svelte-k2kih7"><dt class="svelte-k2kih7"> </dt><dd class="svelte-k2kih7"> </dd></div>'),Jc=D('<h4 class="svelte-k2kih7">Facets</h4> <dl class="kv svelte-k2kih7"></dl>',1),Qc=D('<li class="svelte-k2kih7"> <span class="muted-inline svelte-k2kih7"> </span></li>'),qc=D('<h4 class="svelte-k2kih7"> </h4> <ul class="list svelte-k2kih7"></ul>',1),ed=D('<div class="svelte-k2kih7"><dt class="svelte-k2kih7"> </dt><dd class="svelte-k2kih7"> </dd></div>'),td=D('<h4 class="svelte-k2kih7">Provenance</h4> <dl class="kv svelte-k2kih7"></dl>',1),nd=D('<section class="svelte-k2kih7"><h3 class="svelte-k2kih7">Instance</h3> <p class="title svelte-k2kih7"> </p> <!> <!> <!> <!> <!> <!></section>'),rd=D('<p class="muted svelte-k2kih7"> </p>'),id=D('<p class="muted svelte-k2kih7"> </p>'),sd=D('<p class="definition svelte-k2kih7"> </p>'),ad=D('<p class="muted svelte-k2kih7"><!> <!></p>'),od=D('<div class="def-actions svelte-k2kih7"><button type="button" class="svelte-k2kih7">Add property</button> <button type="button" class="svelte-k2kih7">Add relation</button></div> <!>',1),ld=D('<li class="svelte-k2kih7"><code class="svelte-k2kih7"> </code> <span class="muted-inline svelte-k2kih7"> </span></li>'),cd=D('<h4 class="svelte-k2kih7"> </h4> <ul class="list relations svelte-k2kih7"></ul>',1),dd=D('<div class="svelte-k2kih7"><dt class="svelte-k2kih7"> </dt><dd class="svelte-k2kih7"> </dd></div>'),hd=D('<h4 class="svelte-k2kih7"> </h4> <dl class="kv svelte-k2kih7"></dl>',1),ud=D('<li class="svelte-k2kih7"><code class="svelte-k2kih7"> </code> </li>'),fd=D('<h4 class="svelte-k2kih7"> </h4> <ul class="list triples svelte-k2kih7"></ul>',1),gd=D('<p class="title svelte-k2kih7"> </p> <p class="type-id svelte-k2kih7"> </p> <!> <!> <!> <!> <!> <!> <!>',1),vd=D('<section class="svelte-k2kih7"><div class="section-head svelte-k2kih7"><h3 class="svelte-k2kih7">Definition</h3> <!></div> <!></section>'),pd=D('<p class="muted svelte-k2kih7"> </p>'),yd=D('<p class="muted svelte-k2kih7"> </p>'),md=D('<span class="chip svelte-k2kih7"> </span>'),_d=D('<div class="chips svelte-k2kih7"></div>'),bd=D('<li class="svelte-k2kih7"><strong> </strong> <span class="muted-inline svelte-k2kih7"> </span> <!></li>'),kd=D('<ul class="list taxonomy svelte-k2kih7"></ul>'),wd=D('<section class="svelte-k2kih7"><h3 class="svelte-k2kih7">Taxonomy</h3> <!></section>'),xd=D('<pre class="svelte-k2kih7"> </pre>'),Cd=D('<!> <!> <!> <!> <button type="button" class="toggle-raw svelte-k2kih7"> </button> <!>',1),Sd=D("<!> <!>",1);function Nd(t,e){Dn(e,!0);let n=$(e,"selection",11,null),r=$(e,"ontologyId",3,""),i=$(e,"workspaceId",3,""),a=$(e,"embedded",3,!1),o=L(!1),l=L(null),c=L(null),d=L(null),h=L(null),p=L(!1),y=L(!1),k=L("datatype");De(()=>{C(n(),r(),i())});async function C(N,W,z){if(!N){u(c,null),u(d,null),u(h,null),u(l,null);return}u(o,!0),u(l,null);try{if(N.kind==="entity"){const X=await v(N,z);u(c,K(X,N),!0);const le=String(X.entity?.entity_type??N.entityType);u(d,await j(W,"entity",le,z),!0),u(h,null)}else if(N.kind==="relation"){const X=await I(N,z);u(c,U(X,N),!0);const le=String(X.relation?.relation_type??N.relationType);u(d,await j(W,"edge",le),!0),u(h,null)}else u(c,V(N),!0),u(d,se(N),!0),u(h,null)}catch(X){u(l,X instanceof Error?X.message:String(X),!0),u(c,oe(N),!0),u(d,null),u(h,null)}finally{u(o,!1)}}async function _(N){const W=await fetch(N);if(!W.ok)throw new Error(await W.text());return await W.json()}async function v(N,W){const z=new URLSearchParams({entity_id:String(N.entityId)});W.trim()&&z.set("workspace_id",W.trim());try{return await _(`/api/brain/graph/entity?${z}`)}catch{return{entity:{entity_id:N.entityId,entity_type:N.entityType,name:N.label,metadata_json:JSON.stringify(N.payload??{})},incident_relations:[],facets:[]}}}async function I(N,W){const z=new URLSearchParams({relation_id:String(N.relationId)});W.trim()&&z.set("workspace_id",W.trim());try{return await _(`/api/brain/graph/relation?${z}`)}catch{return{relation:{relation_id:N.relationId,relation_type:N.relationType,...N.payload??{}},properties:[]}}}async function O(N,W,z){try{const X=new URLSearchParams({ontology_id:N});z.trim()&&X.set("workspace_id",z.trim());const le=await _(`/api/brain/ontology/graph?${X}`),ue=Array.isArray(le.edges)?le.edges:[],Se=new Set,ie=[];for(const de of ue){if(String(de.source_type??"")!==W)continue;const xe=String(de.type??de.label??""),tt=String(de.target_type??"?"),_e=`${xe}:${tt}`;!xe||Se.has(_e)||(Se.add(_e),ie.push({edgeType:xe,targetType:tt}))}return ie.sort((de,Ce)=>de.edgeType.localeCompare(Ce.edgeType))}catch{return[]}}async function j(N,W,z,X=""){if(!N||!z)return{typeName:z,triples:[],scalars:[],properties:[],outgoingRelations:[],unavailable:"No ontology linked."};try{const le=await _(`/api/brain/ontology/type?ontology_id=${encodeURIComponent(N)}&kind=${W}&type=${encodeURIComponent(z)}`),ue=xc(le),Se=Gi(le.metadata_json),ie=typeof Se.class_uri=="string"?Se.class_uri:null,de=typeof Se.is_a=="string"&&Se.is_a.trim()?Se.is_a.trim():null;return{typeName:String(le.type_name??z),label:le.label==null?null:String(le.label),definition:Cc(ue)??(Se.definition==null?null:String(Se.definition)),parentType:de,sourceType:le.source_entity_type==null?null:String(le.source_entity_type),targetType:le.target_entity_type==null?null:String(le.target_entity_type),triples:ue,scalars:_r(Se),properties:Tc(ue,z,ie),outgoingRelations:W==="entity"?await O(N,z,X):[],kind:W}}catch(le){return{typeName:z,triples:[],scalars:[],properties:[],outgoingRelations:[],unavailable:le instanceof Error?le.message:"Ontology type unavailable."}}}function K(N,W){const z=N.entity??{},X=Gi(z.metadata_json??z.metadata),le=N.facets,ue=[];if(Array.isArray(le))for(const ie of le){if(!ie||typeof ie!="object")continue;const de=ie,Ce=String(de.id??de.facet_id??"facet"),xe=String(de.content??de.value??JSON.stringify(de.facets_json??de.facets??""));ue.push([Ce,xe.slice(0,240)])}const Se=Array.isArray(N.incident_relations)?N.incident_relations:[];return{title:String(z.name??W.label),subtitle:String(z.entity_type??W.entityType),scalars:[["entity_id",String(z.entity_id??W.entityId)],["confidence",z.confidence==null?"":String(z.confidence)],..._r(X,new Set(["label","workspace_id"]))].filter(ie=>ie[1]!==""),facets:ue,incidentRelations:Se,properties:[],provenance:_r({deprecated_at:pi(z.deprecated_at)??"",created_at:pi(z.created_at_unix??z.created_at)??"",run_id:z.run_id,patch_id:z.patch_id}),raw:N}}function U(N,W){const z=N.relation??{},X=Gi(z.metadata_json??z.metadata),le=N.properties??z.properties,ue=[];if(Array.isArray(le))for(const Se of le){if(!Se||typeof Se!="object")continue;const ie=Se,de=String(ie.property_key??ie.key??"property");ue.push([de,String(ie.property_value??ie.value??"")])}return{title:String(z.relation_type??W.relationType),subtitle:`${z.source_id??"?"} → ${z.target_id??"?"}`,scalars:[["relation_id",String(z.relation_id??W.relationId)],["confidence",z.confidence==null?"":String(z.confidence)],["valid_from",pi(z.valid_from_unix)??""],["valid_to",pi(z.valid_to_unix)??""],..._r(X)].filter(Se=>Se[1]!==""),facets:[],incidentRelations:[],properties:ue,provenance:_r({run_id:z.run_id,patch_id:z.patch_id,source:X.source,domain:X.domain}),raw:N}}function V(N){const W=N.payload??{};return{title:N.typeName,subtitle:N.nodeKind,scalars:_r(W),facets:[],incidentRelations:[],properties:[],provenance:[],raw:W}}function se(N){const W=N.payload??{},z=W.field&&typeof W.field=="object"&&!Array.isArray(W.field)?W.field:null,X=W.native_source_type==null?null:String(W.native_source_type),le=W.native_target_type==null?W.native_target_range==null?null:String(W.native_target_range):String(W.native_target_type),ue=typeof W.is_a=="string"&&W.is_a.trim()?W.is_a.trim():null,Se=z?.description==null?W.definition==null?null:String(W.definition):String(z.description);return{typeName:N.typeName,label:W.label==null?z?.name==null?null:String(z.name):String(W.label),definition:Se,parentType:ue,sourceType:X,targetType:le,triples:[],scalars:_r(W,new Set(["field"])),properties:z&&z.range!=null?[{name:String(z.name??N.typeName),range:String(z.range)}]:[],outgoingRelations:[],kind:N.nodeKind==="edge"?"edge":"entity"}}function oe(N){return N?N.kind==="entity"?{title:N.label,subtitle:N.entityType,scalars:[["entity_id",String(N.entityId)]],facets:[],incidentRelations:[],properties:[],provenance:[]}:N.kind==="relation"?{title:N.relationType,subtitle:`relation ${N.relationId}`,scalars:[["relation_id",String(N.relationId)]],facets:[],incidentRelations:[],properties:[],provenance:[]}:V(N):null}var ce=Ft(),G=qe(ce);Do(G,()=>a()?"div":"aside",!1,(N,W)=>{let z;te(()=>z=at(N,0,"inspector svelte-k2kih7",null,z,{embedded:a()}));var X=Sd(),le=qe(X);{var ue=xe=>{var tt=Bc();x(xe,tt)};q(le,xe=>{a()||xe(ue)})}var Se=b(le,2);{var ie=xe=>{var tt=jc();x(xe,tt)},de=xe=>{var tt=Vc();x(xe,tt)},Ce=xe=>{var tt=Cd(),_e=qe(tt);{var Z=Qe=>{var Fe=Kc(),nt=g(Fe,!0);f(Fe),te(()=>B(nt,s(l))),x(Qe,Fe)};q(_e,Qe=>{s(l)&&Qe(Z)})}var pe=b(_e,2);{var ve=Qe=>{var Fe=nd(),nt=b(g(Fe),2),lt=g(nt,!0);f(nt);var H=b(nt,2);{var ne=re=>{var ae=Zc(),Me=g(ae),ke=b(Me);{var He=Xe=>{var ut=$c();Be("click",ut,()=>e.onOpenType?.(n().kind==="entity"?n().entityType:n().relationType,n().kind==="relation"?"edge":"entity")),x(Xe,ut)};q(ke,Xe=>{(n().kind==="entity"||n().kind==="relation")&&Xe(He)})}f(ae),te(()=>B(Me,`${s(c).subtitle??""} `)),x(re,ae)};q(H,re=>{s(c).subtitle&&re(ne)})}var F=b(H,2);{var M=re=>{var ae=Wc();kt(ae,21,()=>s(c).scalars,Tt,(Me,ke)=>{var He=me(()=>Wr(s(ke),2));let Xe=()=>s(He)[0],ut=()=>s(He)[1];var T=Uc(),ee=g(T),Te=g(ee,!0);f(ee);var Ae=b(ee),Ie=g(Ae,!0);f(Ae),f(T),te(()=>{B(Te,Xe()),B(Ie,ut())}),x(Me,T)}),f(ae),x(re,ae)};q(F,re=>{s(c).scalars.length>0&&re(M)})}var R=b(F,2);{var Y=re=>{var ae=Yc(),Me=b(qe(ae),2);kt(Me,21,()=>s(c).properties,Tt,(ke,He)=>{var Xe=me(()=>Wr(s(He),2));let ut=()=>s(Xe)[0],T=()=>s(Xe)[1];var ee=Gc(),Te=g(ee),Ae=g(Te,!0);f(Te);var Ie=b(Te),we=g(Ie,!0);f(Ie),f(ee),te(()=>{B(Ae,ut()),B(we,T())}),x(ke,ee)}),f(Me),x(re,ae)};q(R,re=>{s(c).properties.length>0&&re(Y)})}var Q=b(R,2);{var Pe=re=>{var ae=Jc(),Me=b(qe(ae),2);kt(Me,21,()=>s(c).facets,Tt,(ke,He)=>{var Xe=me(()=>Wr(s(He),2));let ut=()=>s(Xe)[0],T=()=>s(Xe)[1];var ee=Xc(),Te=g(ee),Ae=g(Te,!0);f(Te);var Ie=b(Te),we=g(Ie,!0);f(Ie),f(ee),te(()=>{B(Ae,ut()),B(we,T())}),x(ke,ee)}),f(Me),x(re,ae)};q(Q,re=>{s(c).facets.length>0&&re(Pe)})}var Ne=b(Q,2);{var ge=re=>{var ae=qc(),Me=qe(ae),ke=g(Me);f(Me);var He=b(Me,2);kt(He,21,()=>s(c).incidentRelations.slice(0,8),Tt,(Xe,ut)=>{var T=Qc(),ee=g(T),Te=b(ee),Ae=g(Te);f(Te),f(T),te(Ie=>{B(ee,`${Ie??""} `),B(Ae,`${s(ut).source_id??""??""} → ${s(ut).target_id??""??""}`)},[()=>String(s(ut).relation_type??s(ut).label??"relation")]),x(Xe,T)}),f(He),te(()=>B(ke,`Incident relations (${s(c).incidentRelations.length??""})`)),x(re,ae)};q(Ne,re=>{s(c).incidentRelations.length>0&&re(ge)})}var ye=b(Ne,2);{var A=re=>{var ae=td(),Me=b(qe(ae),2);kt(Me,21,()=>s(c).provenance,Tt,(ke,He)=>{var Xe=me(()=>Wr(s(He),2));let ut=()=>s(Xe)[0],T=()=>s(Xe)[1];var ee=ed(),Te=g(ee),Ae=g(Te,!0);f(Te);var Ie=b(Te),we=g(Ie,!0);f(Ie),f(ee),te(()=>{B(Ae,ut()),B(we,T())}),x(ke,ee)}),f(Me),x(re,ae)};q(ye,re=>{s(c).provenance.length>0&&re(A)})}f(Fe),te(()=>B(lt,s(c).title)),x(Qe,Fe)};q(pe,Qe=>{s(c)&&Qe(ve)})}var Ke=b(pe,2);{var Oe=Qe=>{var Fe=vd(),nt=g(Fe),lt=b(g(nt),2);zc(lt,{get text(){return Fc.inspectorDefinition},label:"Definition help"}),f(nt);var H=b(nt,2);{var ne=M=>{var R=rd(),Y=g(R,!0);f(R),te(()=>B(Y,s(d).unavailable)),x(M,R)},F=M=>{var R=gd(),Y=qe(R),Q=g(Y,!0);f(Y);var Pe=b(Y,2),Ne=g(Pe,!0);f(Pe);var ge=b(Pe,2);{var ye=Ie=>{var we=id(),Ve=g(we);f(we),te(()=>B(Ve,`subclass of ${s(d).parentType??""}`)),x(Ie,we)};q(ge,Ie=>{s(d).parentType&&Ie(ye)})}var A=b(ge,2);{var re=Ie=>{var we=sd(),Ve=g(we,!0);f(we),te(()=>B(Ve,s(d).definition)),x(Ie,we)};q(A,Ie=>{s(d).definition&&Ie(re)})}var ae=b(A,2);{var Me=Ie=>{var we=ad(),Ve=g(we);{var ot=w=>{var E=zn();te(()=>B(E,`domain: ${s(d).sourceType??""}`)),x(w,E)};q(Ve,w=>{s(d).sourceType&&w(ot)})}var it=b(Ve,2);{var P=w=>{var E=zn();te(()=>B(E,`· range: ${s(d).targetType??""}`)),x(w,E)};q(it,w=>{s(d).targetType&&w(P)})}f(we),x(Ie,we)};q(ae,Ie=>{(s(d).sourceType||s(d).targetType)&&Ie(Me)})}var ke=b(ae,2);{var He=Ie=>{var we=od(),Ve=qe(we),ot=g(Ve),it=b(ot,2);f(Ve);var P=b(Ve,2);{var w=E=>{Oc(E,{get ontologyId(){return r()},get domainClass(){return s(d).typeName},get kind(){return s(k)},onSaved:()=>{u(y,!1),C(n(),r(),i())},onCancel:()=>u(y,!1)})};q(P,E=>{s(y)&&E(w)})}Be("click",ot,()=>(u(y,!0),u(k,"datatype"))),Be("click",it,()=>(u(y,!0),u(k,"object"))),x(Ie,we)};q(ke,Ie=>{s(d).kind==="entity"&&r()&&Ie(He)})}var Xe=b(ke,2);{var ut=Ie=>{var we=cd(),Ve=qe(we),ot=g(Ve);f(Ve);var it=b(Ve,2);kt(it,21,()=>s(d).outgoingRelations,Tt,(P,w)=>{var E=ld(),he=g(E),Ee=g(he,!0);f(he);var be=b(he,2),ze=g(be);f(be),f(E),te(()=>{B(Ee,s(w).edgeType),B(ze,`→ ${s(w).targetType??""}`)}),x(P,E)}),f(it),te(()=>B(ot,`Relations (${s(d).outgoingRelations.length??""})`)),x(Ie,we)};q(Xe,Ie=>{s(d).outgoingRelations.length>0&&Ie(ut)})}var T=b(Xe,2);{var ee=Ie=>{var we=hd(),Ve=qe(we),ot=g(Ve);f(Ve);var it=b(Ve,2);kt(it,21,()=>s(d).properties,Tt,(P,w)=>{var E=dd(),he=g(E),Ee=g(he,!0);f(he);var be=b(he),ze=g(be,!0);f(be),f(E),te(()=>{B(Ee,s(w).name),B(ze,s(w).range)}),x(P,E)}),f(it),te(()=>B(ot,`Properties (${s(d).properties.length??""})`)),x(Ie,we)};q(T,Ie=>{s(d).properties.length>0&&Ie(ee)})}var Te=b(T,2);{var Ae=Ie=>{var we=fd(),Ve=qe(we),ot=g(Ve);f(Ve);var it=b(Ve,2);kt(it,21,()=>s(d).triples.slice(0,12),Tt,(P,w)=>{var E=ud(),he=g(E),Ee=g(he,!0);f(he);var be=b(he);f(E),te(()=>{B(Ee,s(w).subject),B(be,` · ${s(w).predicate??""} · ${s(w).object_value??""}`)}),x(P,E)}),f(it),te(()=>B(ot,`Raw triples (${s(d).triples.length??""})`)),x(Ie,we)};q(Te,Ie=>{s(d).triples.length>0&&Ie(Ae)})}te(()=>{B(Q,s(d).label??s(d).typeName),B(Ne,s(d).typeName)}),x(M,R)};q(H,M=>{s(d).unavailable?M(ne):M(F,-1)})}f(Fe),x(Qe,Fe)};q(Ke,Qe=>{s(d)&&Qe(Oe)})}var je=b(Ke,2);{var Ge=Qe=>{var Fe=wd(),nt=b(g(Fe),2);{var lt=F=>{var M=pd(),R=g(M,!0);f(M),te(()=>B(R,s(h).unavailable)),x(F,M)},H=F=>{var M=yd(),R=g(M);f(M),te(()=>B(R,`No taxonomy dimensions for ${s(h).ontologyId??""}.`)),x(F,M)},ne=F=>{var M=kd();kt(M,21,()=>s(h).dimensions.slice(0,10),Tt,(R,Y)=>{var Q=bd(),Pe=g(Q),Ne=g(Pe,!0);f(Pe);var ge=b(Pe,2),ye=g(ge);f(ge);var A=b(ge,2);{var re=ae=>{var Me=_d();kt(Me,21,()=>s(Y).values.slice(0,12),Tt,(ke,He)=>{var Xe=md(),ut=g(Xe,!0);f(Xe),te(()=>B(ut,s(He).label??s(He).value)),x(ke,Xe)}),f(Me),x(ae,Me)};q(A,ae=>{s(Y).values.length>0&&ae(re)})}f(Q),te(()=>{B(Ne,s(Y).label),B(ye,`${s(Y).valueType??""} · ${s(Y).hierarchyKind??""}`)}),x(R,Q)}),f(M),x(F,M)};q(nt,F=>{s(h).unavailable?F(lt):s(h).dimensions.length===0?F(H,1):F(ne,-1)})}f(Fe),x(Qe,Fe)};q(je,Qe=>{s(h)&&Qe(Ge)})}var et=b(je,2),$e=g(et,!0);f(et);var mt=b(et,2);{var vt=Qe=>{var Fe=xd(),nt=g(Fe,!0);f(Fe),te(lt=>B(nt,lt),[()=>JSON.stringify(s(c).raw,null,2)]),x(Qe,Fe)};q(mt,Qe=>{s(p)&&s(c)?.raw&&Qe(vt)})}te(()=>B($e,s(p)?"Hide raw JSON":"Show raw JSON")),Be("click",et,()=>u(p,!s(p))),x(xe,tt)};q(Se,xe=>{n()?s(o)?xe(de,1):xe(Ce,-1):xe(ie)})}x(W,X)}),x(t,ce),Pn()}Fn(["click"]);var Dd=D('<div class="section-body svelte-9xspyz"><!></div>'),Pd=D("<option> </option>"),Id=D("<option> </option>"),Td=D('<div class="section-body display-fields svelte-9xspyz"><label class="field svelte-9xspyz"><span class="field-label svelte-9xspyz">Filter type</span> <select class="select svelte-9xspyz" aria-label="Filter type"><option> </option><!></select></label> <label class="field svelte-9xspyz"><span class="field-label svelte-9xspyz">Layout</span> <select class="select svelte-9xspyz" aria-label="Graph layout template"></select></label> <label class="field svelte-9xspyz"><span class="field-label svelte-9xspyz">Links</span> <select class="select svelte-9xspyz" aria-label="Edge link semantics"><option>All edge types</option><option>Composition</option><option>Discovery</option></select></label> <label class="field svelte-9xspyz"><span class="field-label svelte-9xspyz">TopK</span> <select class="select svelte-9xspyz" aria-label="Maximum links per source node"><option>10 per source</option><option>30 per source</option><option>100 per source</option><option>All links</option></select></label></div>'),Md=D('<div class="section-body svelte-9xspyz"><!></div>'),Ed=D('<section class="collapsible svelte-9xspyz"><button type="button" class="section-toggle svelte-9xspyz"><span aria-hidden="true">›</span> Search</button> <!></section> <section class="collapsible svelte-9xspyz"><button type="button" class="section-toggle svelte-9xspyz"><span aria-hidden="true">›</span> Display</button> <!></section> <section class="collapsible svelte-9xspyz"><button type="button" class="section-toggle svelte-9xspyz"><span aria-hidden="true">›</span> Legend</button> <!></section>',1),Ad=D('<div class="section-body selection-body svelte-9xspyz"><!></div>'),Rd=D('<div class="section-body grow-body svelte-9xspyz"><!></div>'),Od=D('<section><button type="button" class="section-toggle svelte-9xspyz"><span aria-hidden="true">›</span> Facets</button> <!></section>'),Ld=D('<div id="inspector-panel" class="panel svelte-9xspyz"><div class="sections svelte-9xspyz"><div class="sections-upper svelte-9xspyz"><!> <section class="collapsible svelte-9xspyz"><button type="button" class="section-toggle svelte-9xspyz"><span aria-hidden="true">›</span> Selection</button> <!></section></div> <!></div></div>'),Hd=D('<aside aria-label="Inspector sidebar"><button type="button" aria-controls="inspector-panel"><span class="rail-label svelte-9xspyz">Inspector</span> <span class="rail-chevron svelte-9xspyz" aria-hidden="true"> </span></button> <!></aside>');function zd(t,e){Dn(e,!0);let n=$(e,"open",15,!1),r=$(e,"sections",31,()=>Ut({search:!0,display:!1,facets:!1,legend:!1,selection:!0})),i=$(e,"showGraphTools",3,!1),a=$(e,"brainOnline",3,!1),o=$(e,"selection",15,null),l=$(e,"ontologyId",3,""),c=$(e,"workspaceId",3,""),d=$(e,"ontologyKey",11,"all"),h=$(e,"layoutTemplate",15,"circular_force"),p=$(e,"edgeLinkMode",15,"all"),y=$(e,"topK",15,"30"),k=$(e,"ontologies",19,()=>[]),C=$(e,"legendBlocks",19,()=>[]),_=$(e,"facetFilter",15,null);function v(ce){r({...r(),[ce]:!r()[ce]})}var I=Hd();let O;var j=g(I);let K;var U=b(g(j),2),V=g(U,!0);f(U),f(j);var se=b(j,2);{var oe=ce=>{var G=Ld(),N=g(G),W=g(N),z=g(W);{var X=_e=>{var Z=Ed(),pe=qe(Z),ve=g(pe),Ke=g(ve);let Oe;Yt(),f(ve);var je=b(ve,2);{var Ge=R=>{var Y=Dd(),Q=g(Y);{let Pe=me(()=>c().trim()||"default"),Ne=me(()=>e.filterEntityType?.()??null);dc(Q,{get workspaceId(){return s(Pe)},get entityType(){return s(Ne)},get onSeeds(){return e.onSeeds}})}f(Y),x(R,Y)};q(je,R=>{r().search&&R(Ge)})}f(pe);var et=b(pe,2),$e=g(et),mt=g($e);let vt;Yt(),f($e);var Qe=b($e,2);{var Fe=R=>{var Y=Td(),Q=g(Y),Pe=b(g(Q),2),Ne=g(Pe),ge=g(Ne,!0);f(Ne),Ne.value=Ne.__value="all";var ye=b(Ne);kt(ye,17,k,Tt,(Ve,ot)=>{var it=Pd(),P=g(it);f(it);var w={};te(E=>{B(P,`${E??""} (${s(ot).nodeCount??""})`),w!==(w=s(ot).id)&&(it.value=(it.__value=s(ot).id)??"")},[()=>e.ontologyLabel?.(s(ot).id)??s(ot).id]),x(Ve,it)}),f(Pe);var A;Ii(Pe),f(Q);var re=b(Q,2),ae=b(g(re),2);kt(ae,21,()=>Ro,Tt,(Ve,ot)=>{var it=Id(),P=g(it,!0);f(it);var w={};te(()=>{B(P,s(ot).label),w!==(w=s(ot).id)&&(it.value=(it.__value=s(ot).id)??"")}),x(Ve,it)}),f(ae),f(re);var Me=b(re,2),ke=b(g(Me),2),He=g(ke);He.value=He.__value="all";var Xe=b(He);Xe.value=Xe.__value="composition";var ut=b(Xe);ut.value=ut.__value="discovery",f(ke),f(Me);var T=b(Me,2),ee=b(g(T),2),Te=g(ee);Te.value=Te.__value="10";var Ae=b(Te);Ae.value=Ae.__value="30";var Ie=b(Ae);Ie.value=Ie.__value="100";var we=b(Ie);we.value=we.__value="none",f(ee),f(T),f(Y),te(Ve=>{B(ge,Ve),A!==(A=d())&&(Pe.value=(Pe.__value=d())??"",ti(Pe,d()))},[()=>e.ontologyLabel?.("all")??"All entity types"]),Be("change",Pe,function(...Ve){e.onOntologyChange?.apply(this,Ve)}),Hr(ae,h),Hr(ke,p),Hr(ee,y),x(R,Y)};q(Qe,R=>{r().display&&R(Fe)})}f(et);var nt=b(et,2),lt=g(nt),H=g(lt);let ne;Yt(),f(lt);var F=b(lt,2);{var M=R=>{var Y=Md(),Q=g(Y);js(Q,{get legendBlocks(){return C()},variant:"legend",get facetFilter(){return _()},set facetFilter(Pe){_(Pe)}}),f(Y),x(R,Y)};q(F,R=>{r().legend&&R(M)})}f(nt),te(()=>{Oe=at(Ke,1,"chevron svelte-9xspyz",null,Oe,{expanded:r().search}),vt=at(mt,1,"chevron svelte-9xspyz",null,vt,{expanded:r().display}),ne=at(H,1,"chevron svelte-9xspyz",null,ne,{expanded:r().legend})}),Be("click",ve,()=>v("search")),Be("click",$e,()=>v("display")),Be("click",lt,()=>v("legend")),x(_e,Z)};q(z,_e=>{i()&&a()&&_e(X)})}var le=b(z,2),ue=g(le),Se=g(ue);let ie;Yt(),f(ue);var de=b(ue,2);{var Ce=_e=>{var Z=Ad(),pe=g(Z);Nd(pe,{embedded:!0,get ontologyId(){return l()},get workspaceId(){return c()},get onOpenType(){return e.onOpenType},get selection(){return o()},set selection(ve){o(ve)}}),f(Z),x(_e,Z)};q(de,_e=>{r().selection&&_e(Ce)})}f(le),f(W);var xe=b(W,2);{var tt=_e=>{var Z=Od();let pe;var ve=g(Z),Ke=g(ve);let Oe;Yt(),f(ve);var je=b(ve,2);{var Ge=et=>{var $e=Rd(),mt=g($e);js(mt,{get legendBlocks(){return C()},variant:"facets",get facetFilter(){return _()},set facetFilter(vt){_(vt)}}),f($e),x(et,$e)};q(je,et=>{r().facets&&et(Ge)})}f(Z),te(()=>{pe=at(Z,1,"collapsible collapsible-grow svelte-9xspyz",null,pe,{expanded:r().facets}),Oe=at(Ke,1,"chevron svelte-9xspyz",null,Oe,{expanded:r().facets})}),Be("click",ve,()=>v("facets")),x(_e,Z)};q(xe,_e=>{i()&&a()&&_e(tt)})}f(N),f(G),te(()=>ie=at(Se,1,"chevron svelte-9xspyz",null,ie,{expanded:r().selection})),Be("click",ue,()=>v("selection")),x(ce,G)};q(se,ce=>{n()&&ce(oe)})}f(I),te(()=>{O=at(I,1,"shell svelte-9xspyz",null,O,{open:n()}),K=at(j,1,"rail svelte-9xspyz",null,K,{active:n()}),An(j,"aria-expanded",n()),B(V,n()?"▸":"◂")}),Be("click",j,()=>n(!n())),x(t,I),Pn()}Fn(["click","change"]);function Vs(t){const e=t?.trim();if(!e?.startsWith("projection:"))return;const n=e.slice(11).trim();return n.length>0?n:void 0}function hr(t){if(!t||typeof t!="object")return[];const e=t,n=[];for(const r of["entity_id","evidence_entity_id","source_id","target_id","entity_ids","seed_ids"]){const i=e[r];if(Array.isArray(i))for(const a of i){const o=Number(a);Number.isFinite(o)&&o>0&&n.push(o)}else{const a=Number(i);Number.isFinite(a)&&a>0&&n.push(a)}}for(const r of Object.values(e))if(Array.isArray(r))for(const i of r)n.push(...hr(i));else r&&typeof r=="object"&&n.push(...hr(r));return[...new Set(n)]}function ma(t){const e=t.rows??t.projection_results??t.results;return Array.isArray(e)?e.map(n=>{const r=n,i=r.source_ref==null?null:String(r.source_ref),a=r.artifact_kind==null?r.type==null?r.proj_type==null?void 0:Fd(String(r.proj_type)):String(r.type):String(r.artifact_kind),o=r.projection_id==null?Vs(i):String(r.projection_id);return{id:r.id==null?void 0:String(r.id),artifact_id:r.artifact_id==null?void 0:String(r.artifact_id),artifact_kind:a,legacy_kind:r.legacy_kind==null?void 0:String(r.legacy_kind),public_label:r.public_label==null?void 0:String(r.public_label),scope:r.scope==null?null:String(r.scope),lifecycle:r.lifecycle==null?void 0:String(r.lifecycle),state:r.state==null?void 0:String(r.state),current_version:r.current_version==null||!Number.isFinite(Number(r.current_version))?void 0:Number(r.current_version),projection_id:o,linked_projection_id:Vs(i),type:a,status:r.status==null?void 0:String(r.status),weight:r.weight==null?void 0:Number(r.weight),proj_type:r.proj_type==null?void 0:String(r.proj_type),content:r.content==null?void 0:String(r.content).slice(0,200),preview:r.preview==null?void 0:String(r.preview).slice(0,260),source_ref:i,entity_id:hr(r)[0],graph_focusable:r.graph_focusable==null?void 0:!!r.graph_focusable,suggested_tools:Array.isArray(r.suggested_tools)?r.suggested_tools.map(l=>String(l)):void 0,linked_snapshot_id:r.linked_snapshot_id==null?void 0:String(r.linked_snapshot_id),source:r.source==null?void 0:String(r.source),raw:r}}):[]}function Fd(t){const e=t.trim().toUpperCase();return e==="FACT"||e==="STEP"||e==="GOAL"||e==="CONSTRAINT"?"analysis_plan":t}function Ln(t){return t.public_label??t.artifact_id??t.projection_id??t.id??t.content??t.artifact_kind??"Artifact"}function xi(t){switch(t){case"analysis_plan":return"Analysis plan";case"answer_snapshot":return"Snapshot";case"live_answer_view":return"Live answer";case"evidence_pack":return"Evidence pack";default:return t??"Artifact"}}function _a(t,e){if(!e.label&&!e.entityType)return!1;const n=`${t.public_label??""} ${t.preview??""} ${t.content??""}`.toLowerCase(),r=(e.label??"").toLowerCase(),i=(e.entityType??"").toLowerCase();return!!(r&&n.includes(r)||i&&n.includes(i))}var ba=function(){},Yn="undefined",Bd=typeof window!==Yn&&typeof window.navigator!==Yn&&/Trident\/|MSIE /.test(window.navigator.userAgent),ss=["trace","debug","info","warn","error"],ii={},qt=null;function Ks(t,e){var n=t[e];if(typeof n.bind=="function")return n.bind(t);try{return Function.prototype.bind.call(n,t)}catch{return function(){return Function.prototype.apply.apply(n,[t,arguments])}}}function jd(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function Vd(t){return t==="debug"&&(t="log"),typeof console===Yn?!1:t==="trace"&&Bd?jd:console[t]!==void 0?Ks(console,t):console.log!==void 0?Ks(console,"log"):ba}function Yr(){for(var t=this.getLevel(),e=0;e<ss.length;e++){var n=ss[e];this[n]=e<t?ba:this.methodFactory(n,t,this.name)}if(this.log=this.debug,typeof console===Yn&&t<this.levels.SILENT)return"No console available for logging"}function Kd(t){return function(){typeof console!==Yn&&(Yr.call(this),this[t].apply(this,arguments))}}function $d(t,e,n){return Vd(t)||Kd.apply(this,arguments)}function ka(t,e){var n=this,r,i,a,o="loglevel";typeof t=="string"?o+=":"+t:typeof t=="symbol"&&(o=void 0);function l(y){var k=(ss[y]||"silent").toUpperCase();if(!(typeof window===Yn||!o)){try{window.localStorage[o]=k;return}catch{}try{window.document.cookie=encodeURIComponent(o)+"="+k+";"}catch{}}}function c(){var y;if(!(typeof window===Yn||!o)){try{y=window.localStorage[o]}catch{}if(typeof y===Yn)try{var k=window.document.cookie,C=encodeURIComponent(o),_=k.indexOf(C+"=");_!==-1&&(y=/^([^;]+)/.exec(k.slice(_+C.length+1))[1])}catch{}return n.levels[y]===void 0&&(y=void 0),y}}function d(){if(!(typeof window===Yn||!o)){try{window.localStorage.removeItem(o)}catch{}try{window.document.cookie=encodeURIComponent(o)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function h(y){var k=y;if(typeof k=="string"&&n.levels[k.toUpperCase()]!==void 0&&(k=n.levels[k.toUpperCase()]),typeof k=="number"&&k>=0&&k<=n.levels.SILENT)return k;throw new TypeError("log.setLevel() called with invalid level: "+y)}n.name=t,n.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},n.methodFactory=e||$d,n.getLevel=function(){return a??i??r},n.setLevel=function(y,k){return a=h(y),k!==!1&&l(a),Yr.call(n)},n.setDefaultLevel=function(y){i=h(y),c()||n.setLevel(y,!1)},n.resetLevel=function(){a=null,d(),Yr.call(n)},n.enableAll=function(y){n.setLevel(n.levels.TRACE,y)},n.disableAll=function(y){n.setLevel(n.levels.SILENT,y)},n.rebuild=function(){if(qt!==n&&(r=h(qt.getLevel())),Yr.call(n),qt===n)for(var y in ii)ii[y].rebuild()},r=h(qt?qt.getLevel():"WARN");var p=c();p!=null&&(a=h(p)),Yr.call(n)}qt=new ka;qt.getLogger=function(e){if(typeof e!="symbol"&&typeof e!="string"||e==="")throw new TypeError("You must supply a name when creating a logger.");var n=ii[e];return n||(n=ii[e]=new ka(e,qt.methodFactory)),n};var Zd=typeof window!==Yn?window.log:void 0;qt.noConflict=function(){return typeof window!==Yn&&window.log===qt&&(window.log=Zd),qt};qt.getLoggers=function(){return ii};qt.default=qt;var Ud=function(t){for(var e=1,n=arguments.length,r;e<n;e++)for(r in arguments[e])Object.prototype.hasOwnProperty.call(arguments[e],r)&&(t[r]=arguments[e][r]);return t},Wd={template:"[%t] %l:",levelFormatter:function(t){return t.toUpperCase()},nameFormatter:function(t){return t||"root"},timestampFormatter:function(t){return t.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1")},format:void 0},wa,br={},Gd=function(t){if(!t||!t.getLogger)throw new TypeError("Argument is not a root logger");wa=t},Yd=function(t,e){if(!t||!t.setLevel)throw new TypeError("Argument is not a logger");var n=t.methodFactory,r=t.name||"",i=br[r]||br[""]||Wd;function a(o,l,c){var d=n(o,l,c),h=br[c]||br[""],p=h.template.indexOf("%t")!==-1,y=h.template.indexOf("%l")!==-1,k=h.template.indexOf("%n")!==-1;return function(){for(var C="",_=arguments.length,v=Array(_),I=0;I<_;I++)v[I]=arguments[I];if(r||!br[c]){var O=h.timestampFormatter(new Date),j=h.levelFormatter(o),K=h.nameFormatter(c);h.format?C+=h.format(j,K,O):(C+=h.template,p&&(C=C.replace(/%t/,O)),y&&(C=C.replace(/%l/,j)),k&&(C=C.replace(/%n/,K))),v.length&&typeof v[0]=="string"?v[0]=C+" "+v[0]:v.unshift(C)}d.apply(void 0,v)}}return br[r]||(t.methodFactory=a),e=e||{},e.template&&(e.format=void 0),br[r]=Ud({},i,e),t.setLevel(t.getLevel()),wa||t.warn("It is necessary to call the function reg() of loglevel-plugin-prefix before calling apply. From the next release, it will throw an error. See more: https://github.com/kutuluk/loglevel-plugin-prefix/blob/master/README.md"),t},Oi={reg:Gd,apply:Yd};const Xd={trace:"#9ca3af",debug:"#0ea5e9",info:"#10b981",warn:"#f59e0b",error:"#ef4444"};Oi.reg(qt);qt.setLevel("silent");const Jd={format(t,e,n){return`%c[${n}]%c %c[${t.toUpperCase()}]%c %c[${e}]%c`},timestampFormatter(t){return t.toTimeString().split(" ")[0]+"."+t.getMilliseconds().toString().padStart(3,"0")}};function Qd(t){return function(e,n,r){const i=t(e,n,r);return function(...a){if(a.length>0&&typeof a[0]=="string"&&a[0].includes("%c")){const o=Xd[e]||"#666",l=(a[0].match(/%c/g)||[]).length,c=[];for(let d=0;d<l;d++)c.push(d%2===0?`color: ${o}; font-weight: bold;`:"color: inherit;");i(a[0],...c,...a.slice(1))}else i(...a)}}}const qd=qt.getLogger("LTREE:INIT"),eh=qt.getLogger("LTREE:DATA"),Ci=qt.getLogger("LTREE:RENDER"),Wn=qt.getLogger("LTREE:INDEX"),Wt=qt.getLogger("LTREE:DRAG"),Nn=qt.getLogger("LTREE:UI"),th=[qd,eh,Ci,Wn,Wt,Nn];th.forEach(t=>{const e=t.methodFactory;t.methodFactory=Qd(e),Oi.apply(t,Jd),t.setLevel("silent")});var nh=D("<span></span>"),rh=D("<span></span>"),ih=D('<label class="ltree-checkbox"><input type="checkbox"/> <span class="ltree-checkbox__box"></span></label>'),sh=D('<div class="ltree-loading-more"> </div>'),ah=D('<div class="ltree-children"><!> <!></div>'),oh=D('<div class="ltree-node"><div class="ltree-node-row"><!> <!> <div><!></div></div> <!></div>');function Si(t,e){Dn(e,!0);let n=$(e,"node",7),r=$(e,"children",3,void 0),i=$(e,"progressiveRender",3,!1),a=$(e,"renderBatchSize",3,50),o=$(e,"isDraggedNode",3,!1),l=$(e,"isDragInProgress",3,!1),c=$(e,"hoveredNodeForDropPath",3,null),d=$(e,"activeDropPosition",3,null),h=$(e,"dropOperation",3,"move"),p=$(e,"flatMode",3,!1),y=$(e,"flatGap",3,!1);const k=di("NodeCallbacks"),C=di("NodeConfig"),{expandIconClass:_,collapseIconClass:v,leafIconClass:I,highlightedNodeClass:O,focusedNodeClass:j,dragOverNodeClass:K,allowCopy:U}=C,V=me(()=>C.clickBehavior),se=me(()=>C.showCheckboxes),oe=me(()=>C.checkboxMode),ce=me(()=>s(oe)==="cascade"&&n().visualState==="indeterminate"),G=me(()=>C.dropZoneMode),N=me(()=>C.dropZoneStart),W=me(()=>C.accordionExpand),z=me(()=>C.toggleIconMode),X=me(()=>c()===n().path),le=di("Ltree"),ue=di("RenderCoordinator");let Se=L(!1),ie=L(null);const de=me(()=>le.getNodeAllowedDropPositions(n()));function Ce(A){return!s(de)||s(de).length===0?!0:s(de).includes(A)}function xe(A,re){const ae=re.getBoundingClientRect(),Me=A.clientX-ae.left,ke=A.clientY-ae.top,He=ae.width,Xe=ae.height,ut=typeof s(N)=="number"?s(N)/100*He:typeof s(N)=="string"&&s(N).endsWith("px")?parseFloat(s(N)):typeof s(N)=="string"?parseFloat(s(N))/100*He:He/2,T=isNaN(ut)?He/2:ut;let ee;return Me>T?ee="child":ke<Xe/2?ee="before":ee="after",!s(de)||s(de).length===0||s(de).includes(ee)?ee:s(de).length===1?s(de)[0]:s(de).includes("before")&&s(de).includes("after")?ke<Xe/2?"before":"after":s(de)[0]}const tt=me(()=>le.getNodeIsCollapsible(n())),_e=me(()=>p()?[]:Object.values(n()?.children||[])),Z=me(()=>n()?.hasChildren||!1),pe=me(()=>p()?`margin-left: calc(${n()?.level||1} * var(--tree-node-indent-per-level, 0.5rem))${y()?"; margin-top: 2px":""}`:"margin-left: var(--tree-node-indent-per-level, 0.5rem)");let ve=L(0),Ke=null,Oe=!1,je=0;const Ge=me(()=>!p()&&i()&&ue?s(_e).slice(0,s(ve)):s(_e)),et=me(()=>!p()&&i()&&ue&&s(ve)<s(_e).length);De(()=>{if(p())return;const A=n()?.isExpanded??!1,re=s(_e).length,ae=i()&&ue&&re>0;if(A!==Oe||re!==je)if(Oe=A,je=re,A&&ae){if(Ke&&(Ke(),Ke=null),ue.isCompleted(n().path)){u(ve,re,!0);return}u(ve,Math.min(a(),re),!0),s(ve)<re&&(Ke=ue.register(n().path,()=>s(ve)<re?(u(ve,Math.min(s(ve)+a(),re),!0),s(ve)<re):!1))}else A||(Ke&&(Ke(),Ke=null),u(ve,0))}),sa(()=>{Ke&&(Ke(),Ke=null)});function $e(){if(n().hasChildren&&s(tt)){const A=!n().isExpanded;if(A&&s(W)){const re=le.getSiblings(n().path);console.log(`[accordion] expanding ${n().path}, checking ${re.length} siblings, accordionExpand=${s(W)}`);for(const ae of re)ae.path!==n().path&&ae.isExpanded&&le.getNodeIsCollapsible(ae)&&(console.log(`[accordion] collapsing sibling: ${ae.path}`),ae.isExpanded=!1,ae._rev=(ae._rev||0)+1)}Nn.debug(`${A?"Expanding":"Collapsing"} node: ${n().path}`),n().isExpanded=A,n()._rev=(n()._rev||0)+1,le.refresh()}}function mt(A,re){return A.indeterminate=re,{update(ae){A.indeterminate=ae}}}function vt(A){Nn.debug(`Node clicked: ${n().path}`,{id:n().id,hasChildren:n().hasChildren});const re=A?{ctrl:A.ctrlKey||A.metaKey,shift:A.shiftKey}:void 0;s(V)==="expand"?$e():s(V)==="expand-and-focus"?(k.onNodeClicked(n(),re),$e()):k.onNodeClicked(n(),re)}function Qe(A){s(V)==="select"&&$e()}var Fe=oh(),nt=g(Fe),lt=g(nt);{var H=A=>{var re=nh();let ae;te(()=>ae=at(re,1,`ltree-toggle-icon ltree-clickable ${(s(z)==="swap"&&n().isExpanded?v:_)??""}`,null,ae,{expanded:s(z)==="rotate"&&n().isExpanded})),Be("click",re,$e),x(A,re)},ne=A=>{var re=rh();te(()=>at(re,1,`ltree-toggle-icon ${I??""}`)),x(A,re)};q(lt,A=>{s(Z)&&s(tt)?A(H):A(ne,-1)})}var F=b(lt,2);{var M=A=>{var re=ih(),ae=g(re);Tn(ae),An(ae,"tabindex",-1),Po(ae,(Me,ke)=>mt?.(Me,ke),()=>s(ce)),Yt(2),f(re),te(()=>ko(ae,n().isSelected&&!s(ce))),Be("click",re,Me=>{Me.preventDefault(),Me.stopPropagation(),k.onCheckboxToggle(n())}),x(A,re)};q(F,A=>{s(se)&&n().isSelectable&&A(M)})}var R=b(F,2);let Y;var Q=g(R);{var Pe=A=>{var re=Ft(),ae=qe(re);On(ae,r,n),x(A,re)},Ne=A=>{var re=zn();te(ae=>B(re,ae),[()=>le.getNodeDisplayValue(n())]),x(A,re)};q(Q,A=>{r()?A(Pe):A(Ne,-1)})}f(R),f(nt);var ge=b(nt,2);{var ye=A=>{var re=ah(),ae=g(re);kt(ae,17,()=>s(Ge),He=>He.id,(He,Xe)=>{Si(He,{get node(){return s(Xe)},get children(){return r()},get progressiveRender(){return i()},get renderBatchSize(){return a()},get isDraggedNode(){return o()},get isDragInProgress(){return l()},get hoveredNodeForDropPath(){return c()},get activeDropPosition(){return d()},get dropOperation(){return h()}})});var Me=b(ae,2);{var ke=He=>{var Xe=sh(),ut=g(Xe);f(Xe),te(()=>B(ut,`Loading... (${s(ve)??""}/${s(_e).length??""})`)),x(He,Xe)};q(Me,He=>{s(et)&&He(ke)})}f(re),x(A,re)};q(ge,A=>{!p()&&n()?.isExpanded&&n()?.hasChildren&&A(ye)})}f(Fe),te(A=>{An(Fe,"id",`${n().treeId??""}-${n().id??""}`),An(Fe,"data-tree-path",n().path),ir(Fe,s(pe)),Y=at(R,1,`ltree-node-content ${(n().isHighlighted?O:"")??""} ${(n().isFocused&&j?j:"")??""} ${(s(Se)&&K?K:"")??""}`,null,Y,A),An(R,"draggable",n()?.isDraggable)},[()=>({"ltree-clickable":n().isSelectable,"ltree-dragged":o(),"ltree-draggable":n()?.isDraggable,"ltree-glow-before":s(G)==="glow"&&l()&&s(X)&&s(ie)==="before"&&Ce("before"),"ltree-glow-after":s(G)==="glow"&&l()&&s(X)&&s(ie)==="after"&&Ce("after"),"ltree-glow-child":s(G)==="glow"&&l()&&s(X)&&s(ie)==="child"&&Ce("child"),"ltree-drop-copy":l()&&s(X)&&h()==="copy"})]),Be("click",R,A=>{A.stopPropagation(),vt(A)}),Be("dblclick",R,A=>{A.stopPropagation(),Qe()}),Be("contextmenu",R,A=>{A.stopPropagation(),k.onNodeRightClicked(n(),A)}),St("dragstart",R,A=>{n()?.isDraggable&&A.dataTransfer&&(A.dataTransfer.effectAllowed=U?"copyMove":"move",A.dataTransfer.setData("application/svelte-treeview",JSON.stringify(n())),k.onNodeDragStart(n(),A))}),St("dragover",R,A=>{A.dataTransfer?.types.includes("application/svelte-treeview")&&(A.preventDefault(),A.dataTransfer&&(A.dataTransfer.dropEffect=U&&A.ctrlKey?"copy":"move"),u(Se,!0),s(G)==="glow"&&u(ie,xe(A,A.currentTarget),!0)),k.onNodeDragOver(n(),A)}),St("dragleave",R,A=>{const re=A.currentTarget.getBoundingClientRect(),ae=A.clientX,Me=A.clientY;(ae<re.left||ae>=re.right||Me<re.top||Me>=re.bottom)&&(u(Se,!1),u(ie,null),k.onNodeDragLeave(n(),A))}),St("drop",R,A=>{A.stopPropagation(),A.dataTransfer&&(A.dataTransfer.dropEffect=U&&A.ctrlKey?"copy":"move"),u(Se,!1),s(G)==="glow"&&s(ie)?k.onZoneDrop(n(),s(ie),A):k.onNodeDrop(n(),A),u(ie,null)}),Be("touchstart",R,A=>k.onTouchDragStart(n(),A)),Be("touchmove",R,A=>k.onTouchDragMove(n(),A)),Be("touchend",R,A=>k.onTouchDragEnd(n(),A)),x(t,Fe),Pn()}Fn(["click","dblclick","contextmenu","touchstart","touchmove","touchend"]);var rr;(function(t){t.indeterminate="indeterminate",t.selected="true",t.notSelected="false"})(rr||(rr={}));function Tr(t){return{treeId:"",path:"",pathSegment:"",parentPath:void 0,level:void 0,id:-1,children:{},hasChildren:!1,data:void 0,isDraggable:!0,isCollapsible:!0,isDropAllowed:!0,allowedDropPositions:void 0,visualState:rr.notSelected,isExpanded:!1,isFocused:!1,isHighlighted:!1,isSelected:!1,isSelectable:!0,_rev:0,...t}}var We;function Sn(t,e,n){const r=typeof n,i=typeof t;if(r!=="undefined"){if(i!=="undefined"){if(n){if(i==="function"&&r===i)return function(l){return t(n(l))};if(e=t.constructor,e===n.constructor){if(e===Array)return n.concat(t);if(e===Map){var a=new Map(n);for(var o of t)a.set(o[0],o[1]);return a}if(e===Set){o=new Set(n);for(a of t.values())o.add(a);return o}}}return t}return n}return i==="undefined"?e:t}function Mr(t,e){return typeof t>"u"?e:t}function fn(){return Object.create(null)}function Xn(t){return typeof t=="string"}function si(t){return typeof t=="object"}function ai(t,e){if(Xn(e))t=t[e];else for(let n=0;t&&n<e.length;n++)t=t[e[n]];return t}const lh=/[^\p{L}\p{N}]+/u,ch=/(\d{3})/g,dh=/(\D)(\d{3})/g,hh=/(\d{3})(\D)/g,$s=/[\u0300-\u036f]/g;function oi(t={}){if(!this||this.constructor!==oi)return new oi(...arguments);if(arguments.length)for(t=0;t<arguments.length;t++)this.assign(arguments[t]);else this.assign(t)}We=oi.prototype;We.assign=function(t){this.normalize=Sn(t.normalize,!0,this.normalize);let e=t.include,n=e||t.exclude||t.split,r;if(n||n===""){if(typeof n=="object"&&n.constructor!==RegExp){let i="";r=!e,e||(i+="\\p{Z}"),n.letter&&(i+="\\p{L}"),n.number&&(i+="\\p{N}",r=!!e),n.symbol&&(i+="\\p{S}"),n.punctuation&&(i+="\\p{P}"),n.control&&(i+="\\p{C}"),(n=n.char)&&(i+=typeof n=="object"?n.join(""):n);try{this.split=new RegExp("["+(e?"^":"")+i+"]+","u")}catch{this.split=/\s+/}}else this.split=n,r=n===!1||"a1a".split(n).length<2;this.numeric=Sn(t.numeric,r)}else{try{this.split=Sn(this.split,lh)}catch{this.split=/\s+/}this.numeric=Sn(t.numeric,Sn(this.numeric,!0))}if(this.prepare=Sn(t.prepare,null,this.prepare),this.finalize=Sn(t.finalize,null,this.finalize),n=t.filter,this.filter=typeof n=="function"?n:Sn(n&&new Set(n),null,this.filter),this.dedupe=Sn(t.dedupe,!0,this.dedupe),this.matcher=Sn((n=t.matcher)&&new Map(n),null,this.matcher),this.mapper=Sn((n=t.mapper)&&new Map(n),null,this.mapper),this.stemmer=Sn((n=t.stemmer)&&new Map(n),null,this.stemmer),this.replacer=Sn(t.replacer,null,this.replacer),this.minlength=Sn(t.minlength,1,this.minlength),this.maxlength=Sn(t.maxlength,1024,this.maxlength),this.rtl=Sn(t.rtl,!1,this.rtl),(this.cache=n=Sn(t.cache,!0,this.cache))&&(this.F=null,this.L=typeof n=="number"?n:2e5,this.B=new Map,this.D=new Map,this.I=this.H=128),this.h="",this.J=null,this.A="",this.K=null,this.matcher)for(const i of this.matcher.keys())this.h+=(this.h?"|":"")+i;if(this.stemmer)for(const i of this.stemmer.keys())this.A+=(this.A?"|":"")+i;return this};We.addStemmer=function(t,e){return this.stemmer||(this.stemmer=new Map),this.stemmer.set(t,e),this.A+=(this.A?"|":"")+t,this.K=null,this.cache&&xr(this),this};We.addFilter=function(t){return typeof t=="function"?this.filter=t:(this.filter||(this.filter=new Set),this.filter.add(t)),this.cache&&xr(this),this};We.addMapper=function(t,e){return typeof t=="object"?this.addReplacer(t,e):t.length>1?this.addMatcher(t,e):(this.mapper||(this.mapper=new Map),this.mapper.set(t,e),this.cache&&xr(this),this)};We.addMatcher=function(t,e){return typeof t=="object"?this.addReplacer(t,e):t.length<2&&(this.dedupe||this.mapper)?this.addMapper(t,e):(this.matcher||(this.matcher=new Map),this.matcher.set(t,e),this.h+=(this.h?"|":"")+t,this.J=null,this.cache&&xr(this),this)};We.addReplacer=function(t,e){return typeof t=="string"?this.addMatcher(t,e):(this.replacer||(this.replacer=[]),this.replacer.push(t,e),this.cache&&xr(this),this)};We.encode=function(t,e){if(this.cache&&t.length<=this.H)if(this.F){if(this.B.has(t))return this.B.get(t)}else this.F=setTimeout(xr,50,this);this.normalize&&(typeof this.normalize=="function"?t=this.normalize(t):t=$s?t.normalize("NFKD").replace($s,"").toLowerCase():t.toLowerCase()),this.prepare&&(t=this.prepare(t)),this.numeric&&t.length>3&&(t=t.replace(dh,"$1 $2").replace(hh,"$1 $2").replace(ch,"$1 "));const n=!(this.dedupe||this.mapper||this.filter||this.matcher||this.stemmer||this.replacer);let r=[],i=fn(),a,o,l=this.split||this.split===""?t.split(this.split):[t];for(let d=0,h,p;d<l.length;d++)if((h=p=l[d])&&!(h.length<this.minlength||h.length>this.maxlength)){if(e){if(i[h])continue;i[h]=1}else{if(a===h)continue;a=h}if(n)r.push(h);else if(!this.filter||(typeof this.filter=="function"?this.filter(h):!this.filter.has(h))){if(this.cache&&h.length<=this.I)if(this.F){var c=this.D.get(h);if(c||c===""){c&&r.push(c);continue}}else this.F=setTimeout(xr,50,this);if(this.stemmer){this.K||(this.K=new RegExp("(?!^)("+this.A+")$"));let y;for(;y!==h&&h.length>2;)y=h,h=h.replace(this.K,k=>this.stemmer.get(k))}if(h&&(this.mapper||this.dedupe&&h.length>1)){c="";for(let y=0,k="",C,_;y<h.length;y++)C=h.charAt(y),C===k&&this.dedupe||((_=this.mapper&&this.mapper.get(C))||_===""?_===k&&this.dedupe||!(k=_)||(c+=_):c+=k=C);h=c}if(this.matcher&&h.length>1&&(this.J||(this.J=new RegExp("("+this.h+")","g")),h=h.replace(this.J,y=>this.matcher.get(y))),h&&this.replacer)for(c=0;h&&c<this.replacer.length;c+=2)h=h.replace(this.replacer[c],this.replacer[c+1]);if(this.cache&&p.length<=this.I&&(this.D.set(p,h),this.D.size>this.L&&(this.D.clear(),this.I=this.I/1.1|0)),h){if(h!==p)if(e){if(i[h])continue;i[h]=1}else{if(o===h)continue;o=h}r.push(h)}}}return this.finalize&&(r=this.finalize(r)||r),this.cache&&t.length<=this.H&&(this.B.set(t,r),this.B.size>this.L&&(this.B.clear(),this.H=this.H/1.1|0)),r};function xr(t){t.F=null,t.B.clear(),t.D.clear()}function ys(t,e,n){n||(e||typeof t!="object"?typeof e=="object"&&(n=e,e=0):n=t),n&&(t=n.query||t,e=n.limit||e);let r=""+(e||0);n&&(r+=(n.offset||0)+!!n.context+!!n.suggest+(n.resolve!==!1)+(n.resolution||this.resolution)+(n.boost||0)),t=(""+t).toLowerCase(),this.cache||(this.cache=new Sr);let i=this.cache.get(t+r);if(!i){const a=n&&n.cache;a&&(n.cache=!1),i=this.search(t,e,n),a&&(n.cache=a),this.cache.set(t+r,i)}return i}function Sr(t){this.limit=t&&t!==!0?t:1e3,this.cache=new Map,this.h=""}Sr.prototype.set=function(t,e){this.cache.set(this.h=t,e),this.cache.size>this.limit&&this.cache.delete(this.cache.keys().next().value)};Sr.prototype.get=function(t){const e=this.cache.get(t);return e&&this.h!==t&&(this.cache.delete(t),this.cache.set(this.h=t,e)),e};Sr.prototype.remove=function(t){for(const e of this.cache){const n=e[0];e[1].includes(t)&&this.cache.delete(n)}};Sr.prototype.clear=function(){this.cache.clear(),this.h=""};const Zs={normalize:!1,numeric:!1,dedupe:!1},yi={},Yi=new Map([["b","p"],["v","f"],["w","f"],["z","s"],["x","s"],["d","t"],["n","m"],["c","k"],["g","k"],["j","k"],["q","k"],["i","e"],["y","e"],["u","o"]]),Us=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]),Ws=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\1+/g,"$1"],Gs={a:"",e:"",i:"",o:"",u:"",y:"",b:1,f:1,p:1,v:1,c:2,g:2,j:2,k:2,q:2,s:2,x:2,z:2,ß:2,d:3,t:3,l:4,m:5,n:5,r:6};var ms={Exact:Zs,Default:yi,Normalize:yi,LatinBalance:{mapper:Yi},LatinAdvanced:{mapper:Yi,matcher:Us,replacer:Ws},LatinExtra:{mapper:Yi,replacer:Ws.concat([/(?!^)[aeo]/g,""]),matcher:Us},LatinSoundex:{dedupe:!1,include:{letter:!0},finalize:function(t){for(let n=0;n<t.length;n++){var e=t[n];let r=e.charAt(0),i=Gs[r];for(let a=1,o;a<e.length&&(o=e.charAt(a),o==="h"||o==="w"||!(o=Gs[o])||o===i||(r+=o,i=o,r.length!==4));a++);t[n]=r}}},CJK:{split:""},LatinExact:Zs,LatinDefault:yi,LatinSimple:yi};function Ys(t,e,n,r){let i=[];for(let a=0,o;a<t.index.length;a++)if(o=t.index[a],e>=o.length)e-=o.length;else{e=o[r?"splice":"slice"](e,n);const l=e.length;if(l&&(i=i.length?i.concat(e):e,n-=l,r&&(t.length-=l),!n))break;e=0}return i}function jr(t){if(!this||this.constructor!==jr)return new jr(t);this.index=t?[t]:[],this.length=t?t.length:0;const e=this;return new Proxy([],{get(n,r){if(r==="length")return e.length;if(r==="push")return function(i){e.index[e.index.length-1].push(i),e.length++};if(r==="pop")return function(){if(e.length)return e.length--,e.index[e.index.length-1].pop()};if(r==="indexOf")return function(i){let a=0;for(let o=0,l,c;o<e.index.length;o++){if(l=e.index[o],c=l.indexOf(i),c>=0)return a+c;a+=l.length}return-1};if(r==="includes")return function(i){for(let a=0;a<e.index.length;a++)if(e.index[a].includes(i))return!0;return!1};if(r==="slice")return function(i,a){return Ys(e,i||0,a||e.length,!1)};if(r==="splice")return function(i,a){return Ys(e,i||0,a||e.length,!0)};if(r==="constructor")return Array;if(typeof r!="symbol")return(n=e.index[r/2**31|0])&&n[r]},set(n,r,i){return n=r/2**31|0,(e.index[n]||(e.index[n]=[]))[r]=i,e.length++,!0}})}jr.prototype.clear=function(){this.index.length=0};jr.prototype.push=function(){};function Jn(t=8){if(!this||this.constructor!==Jn)return new Jn(t);this.index=fn(),this.h=[],this.size=0,t>32?(this.B=Ca,this.A=BigInt(t)):(this.B=xa,this.A=t)}Jn.prototype.get=function(t){const e=this.index[this.B(t)];return e&&e.get(t)};Jn.prototype.set=function(t,e){var n=this.B(t);let r=this.index[n];r?(n=r.size,r.set(t,e),(n-=r.size)&&this.size++):(this.index[n]=r=new Map([[t,e]]),this.h.push(r),this.size++)};function Qn(t=8){if(!this||this.constructor!==Qn)return new Qn(t);this.index=fn(),this.h=[],this.size=0,t>32?(this.B=Ca,this.A=BigInt(t)):(this.B=xa,this.A=t)}Qn.prototype.add=function(t){var e=this.B(t);let n=this.index[e];n?(e=n.size,n.add(t),(e-=n.size)&&this.size++):(this.index[e]=n=new Set([t]),this.h.push(n),this.size++)};We=Jn.prototype;We.has=Qn.prototype.has=function(t){const e=this.index[this.B(t)];return e&&e.has(t)};We.delete=Qn.prototype.delete=function(t){const e=this.index[this.B(t)];e&&e.delete(t)&&this.size--};We.clear=Qn.prototype.clear=function(){this.index=fn(),this.h=[],this.size=0};We.values=Qn.prototype.values=function*(){for(let t=0;t<this.h.length;t++)for(let e of this.h[t].values())yield e};We.keys=Qn.prototype.keys=function*(){for(let t=0;t<this.h.length;t++)for(let e of this.h[t].keys())yield e};We.entries=Qn.prototype.entries=function*(){for(let t=0;t<this.h.length;t++)for(let e of this.h[t].entries())yield e};function xa(t){let e=2**this.A-1;if(typeof t=="number")return t&e;let n=0,r=this.A+1;for(let i=0;i<t.length;i++)n=(n*r^t.charCodeAt(i))&e;return this.A===32?n+2**31:n}function Ca(t){let e=BigInt(2)**this.A-BigInt(1);var n=typeof t;if(n==="bigint")return t&e;if(n==="number")return BigInt(t)&e;n=BigInt(0);let r=this.A+BigInt(1);for(let i=0;i<t.length;i++)n=(n*r^BigInt(t.charCodeAt(i)))&e;return n}let Er,Ur;async function uh(t){t=t.data;var e=t.task;const n=t.id;let r=t.args;if(e==="init")Ur=t.options||{},(e=t.factory)?(Function("return "+e)()(self),Er=new self.FlexSearch.Index(Ur),delete self.FlexSearch):Er=new qn(Ur),postMessage({id:n});else{let i;e==="export"&&(r[1]?(r[0]=Ur.export,r[2]=0,r[3]=1):r=null),e==="import"?r[0]&&(t=await Ur.import.call(Er,r[0]),Er.import(r[0],t)):((i=r&&Er[e].apply(Er,r))&&i.then&&(i=await i),i&&i.await&&(i=await i.await),e==="search"&&i.result&&(i=i.result)),postMessage(e==="search"?{id:n,msg:i}:{id:n})}}function _s(t){Ar.call(t,"add"),Ar.call(t,"append"),Ar.call(t,"search"),Ar.call(t,"update"),Ar.call(t,"remove"),Ar.call(t,"searchCache")}let as,Xs,Ni;function fh(){as=Ni=0}function Ar(t){this[t+"Async"]=function(){const e=arguments;var n=e[e.length-1];let r;if(typeof n=="function"&&(r=n,delete e[e.length-1]),as?Ni||(Ni=Date.now()-Xs>=this.priority*this.priority*3):(as=setTimeout(fh,0),Xs=Date.now()),Ni){const a=this;return new Promise(o=>{setTimeout(function(){o(a[t+"Async"].apply(a,e))},0)})}const i=this[t].apply(this,e);return n=i.then?i:new Promise(a=>a(i)),r&&n.then(r),n}}let vr=0;function Vr(t={},e){function n(l){function c(d){d=d.data||d;const h=d.id,p=h&&a.h[h];p&&(p(d.msg),delete a.h[h])}if(this.worker=l,this.h=fn(),this.worker)return i?this.worker.on("message",c):this.worker.onmessage=c,t.config?new Promise(function(d){vr>1e9&&(vr=0),a.h[++vr]=function(){d(a)},a.worker.postMessage({id:vr,task:"init",factory:r,options:t})}):(this.priority=t.priority||4,this.encoder=e||null,this.worker.postMessage({task:"init",factory:r,options:t}),this)}if(!this||this.constructor!==Vr)return new Vr(t);let r=typeof self<"u"?self._factory:typeof window<"u"?window._factory:null;r&&(r=r.toString());const i=typeof window>"u",a=this,o=gh(r,i,t.worker);return o.then?o.then(function(l){return n.call(a,l)}):n.call(this,o)}pr("add");pr("append");pr("search");pr("update");pr("remove");pr("clear");pr("export");pr("import");Vr.prototype.searchCache=ys;_s(Vr.prototype);function pr(t){Vr.prototype[t]=function(){const e=this,n=[].slice.call(arguments);var r=n[n.length-1];let i;return typeof r=="function"&&(i=r,n.pop()),r=new Promise(function(a){t==="export"&&typeof n[0]=="function"&&(n[0]=null),vr>1e9&&(vr=0),e.h[++vr]=a,e.worker.postMessage({task:t,id:vr,args:n})}),i?(r.then(i),this):r}}function gh(t,e,n){return e?typeof module<"u"?new(require("worker_threads")).Worker(__dirname+"/worker/node.js"):Gn(()=>import("../chunks/BIHI7g3E.js"),[],import.meta.url).then(function(r){return new r.Worker(import.meta.dirname+"/node/node.mjs")}):t?new window.Worker(URL.createObjectURL(new Blob(["onmessage="+uh.toString()],{type:"text/javascript"}))):new window.Worker(typeof n=="string"?n:import.meta.url.replace("/worker.js","/worker/worker.js").replace("flexsearch.bundle.module.min.js","module/worker/worker.js").replace("flexsearch.bundle.module.min.mjs","module/worker/worker.js"),{type:"module"})}Kr.prototype.add=function(t,e,n){if(si(t)&&(e=t,t=ai(e,this.key)),e&&(t||t===0)){if(!n&&this.reg.has(t))return this.update(t,e);for(let l=0,c;l<this.field.length;l++){c=this.B[l];var r=this.index.get(this.field[l]);if(typeof c=="function"){var i=c(e);i&&r.add(t,i,n,!0)}else i=c.G,(!i||i(e))&&(c.constructor===String?c=[""+c]:Xn(c)&&(c=[c]),ls(e,c,this.D,0,r,t,c[0],n))}if(this.tag)for(r=0;r<this.A.length;r++){var a=this.A[r];i=this.tag.get(this.F[r]);let l=fn();if(typeof a=="function"){if(a=a(e),!a)continue}else{var o=a.G;if(o&&!o(e))continue;a.constructor===String&&(a=""+a),a=ai(e,a)}if(i&&a){Xn(a)&&(a=[a]);for(let c=0,d,h;c<a.length;c++)if(d=a[c],!l[d]&&(l[d]=1,(o=i.get(d))?h=o:i.set(d,h=[]),!n||!h.includes(t))){if(h.length===2**31-1){if(o=new jr(h),this.fastupdate)for(let p of this.reg.values())p.includes(h)&&(p[p.indexOf(h)]=o);i.set(d,h=o)}h.push(t),this.fastupdate&&((o=this.reg.get(t))?o.push(h):this.reg.set(t,[h]))}}}if(this.store&&(!n||!this.store.has(t))){let l;if(this.h){l=fn();for(let c=0,d;c<this.h.length;c++){if(d=this.h[c],(n=d.G)&&!n(e))continue;let h;if(typeof d=="function"){if(h=d(e),!h)continue;d=[d.O]}else if(Xn(d)||d.constructor===String){l[d]=e[d];continue}os(e,l,d,0,d[0],h)}}this.store.set(t,l||e)}this.worker&&(this.fastupdate||this.reg.add(t))}return this};function os(t,e,n,r,i,a){if(t=t[i],r===n.length-1)e[i]=a||t;else if(t)if(t.constructor===Array)for(e=e[i]=Array(t.length),i=0;i<t.length;i++)os(t,e,n,r,i);else e=e[i]||(e[i]=fn()),i=n[++r],os(t,e,n,r,i)}function ls(t,e,n,r,i,a,o,l){if(t=t[o])if(r===e.length-1){if(t.constructor===Array){if(n[r]){for(e=0;e<t.length;e++)i.add(a,t[e],!0,!0);return}t=t.join(" ")}i.add(a,t,l,!0)}else if(t.constructor===Array)for(o=0;o<t.length;o++)ls(t,e,n,r,i,a,o,l);else o=e[++r],ls(t,e,n,r,i,a,o,l)}function bs(t,e,n,r){if(!t.length)return t;if(t.length===1)return t=t[0],t=n||t.length>e?t.slice(n,n+e):t,r?Fr.call(this,t):t;let i=[];for(let a=0,o,l;a<t.length;a++)if((o=t[a])&&(l=o.length)){if(n){if(n>=l){n-=l;continue}o=o.slice(n,n+e),l=o.length,n=0}if(l>e&&(o=o.slice(0,e),l=e),!i.length&&l>=e)return r?Fr.call(this,o):o;if(i.push(o),e-=l,!e)break}return i=i.length>1?[].concat.apply([],i):i[0],r?Fr.call(this,i):i}function Li(t,e,n,r){var i=r[0];if(i[0]&&i[0].query)return t[e].apply(t,i);if(!(e!=="and"&&e!=="not"||t.result.length||t.await||i.suggest))return r.length>1&&(i=r[r.length-1]),(r=i.resolve)?t.await||t.result:t;let a=[],o=0,l=0,c,d,h,p,y;for(e=0;e<r.length;e++)if(i=r[e]){var k=void 0;if(i.constructor===Gt)k=i.await||i.result;else if(i.then||i.constructor===Array)k=i;else{o=i.limit||0,l=i.offset||0,h=i.suggest,d=i.resolve,c=((p=i.highlight||t.highlight)||i.enrich)&&d,k=i.queue;let C=i.async||k,_=i.index,v=i.query;if(_?t.index||(t.index=_):_=t.index,v||i.tag){const I=i.field||i.pluck;if(I&&(!v||t.query&&!p||(t.query=v,t.field=I,t.highlight=p),_=_.index.get(I)),k&&(y||t.await)){y=1;let O;const j=t.C.length,K=new Promise(function(U){O=U});(function(U,V){K.h=function(){V.index=null,V.resolve=!1;let se=C?U.searchAsync(V):U.search(V);return se.then?se.then(function(oe){return t.C[j]=oe=oe.result||oe,O(oe),oe}):(se=se.result||se,O(se),se)}})(_,Object.assign({},i)),t.C.push(K),a[e]=K;continue}else i.resolve=!1,i.index=null,k=C?_.searchAsync(i):_.search(i),i.resolve=d,i.index=_}else if(i.and)k=mi(i,"and",_);else if(i.or)k=mi(i,"or",_);else if(i.not)k=mi(i,"not",_);else if(i.xor)k=mi(i,"xor",_);else continue}k.await?(y=1,k=k.await):k.then?(y=1,k=k.then(function(C){return C.result||C})):k=k.result||k,a[e]=k}if(y&&!t.await&&(t.await=new Promise(function(C){t.return=C})),y){const C=Promise.all(a).then(function(_){for(let v=0;v<t.C.length;v++)if(t.C[v]===C){t.C[v]=function(){return n.call(t,_,o,l,c,d,h,p)};break}ks(t)});t.C.push(C)}else if(t.await)t.C.push(function(){return n.call(t,a,o,l,c,d,h,p)});else return n.call(t,a,o,l,c,d,h,p);return d?t.await||t.result:t}function mi(t,e,n){t=t[e];const r=t[0]||t;return r.index||(r.index=n),n=new Gt(r),t.length>1&&(n=n[e].apply(n,t.slice(1))),n}Gt.prototype.or=function(){return Li(this,"or",vh,arguments)};function vh(t,e,n,r,i,a,o){return t.length&&(this.result.length&&t.push(this.result),t.length<2?this.result=t[0]:(this.result=Sa(t,e,n,!1,this.h),n=0)),i&&(this.await=null),i?this.resolve(e,n,r,o):this}Gt.prototype.and=function(){return Li(this,"and",ph,arguments)};function ph(t,e,n,r,i,a,o){if(!a&&!this.result.length)return i?this.result:this;let l;if(t.length)if(this.result.length&&t.unshift(this.result),t.length<2)this.result=t[0];else{let c=0;for(let d=0,h,p;d<t.length;d++)if((h=t[d])&&(p=h.length))c<p&&(c=p);else if(!a){c=0;break}c?(this.result=Ti(t,c,e,n,a,this.h,i),l=!0):this.result=[]}else a||(this.result=t);return i&&(this.await=null),i?this.resolve(e,n,r,o,l):this}Gt.prototype.xor=function(){return Li(this,"xor",yh,arguments)};function yh(t,e,n,r,i,a,o){if(t.length)if(this.result.length&&t.unshift(this.result),t.length<2)this.result=t[0];else{e:{a=n;var l=this.h;const c=[],d=fn();let h=0;for(let p=0,y;p<t.length;p++)if(y=t[p]){h<y.length&&(h=y.length);for(let k=0,C;k<y.length;k++)if(C=y[k])for(let _=0,v;_<C.length;_++)v=C[_],d[v]=d[v]?2:1}for(let p=0,y,k=0;p<h;p++)for(let C=0,_;C<t.length;C++)if((_=t[C])&&(y=_[p])){for(let v=0,I;v<y.length;v++)if(I=y[v],d[I]===1)if(a)a--;else if(i){if(c.push(I),c.length===e){t=c;break e}}else{const O=p+(C?l:0);if(c[O]||(c[O]=[]),c[O].push(I),++k===e){t=c;break e}}}t=c}this.result=t,l=!0}else a||(this.result=t);return i&&(this.await=null),i?this.resolve(e,n,r,o,l):this}Gt.prototype.not=function(){return Li(this,"not",mh,arguments)};function mh(t,e,n,r,i,a,o){if(!a&&!this.result.length)return i?this.result:this;if(t.length&&this.result.length){e:{a=n;var l=[];t=new Set(t.flat().flat());for(let c=0,d,h=0;c<this.result.length;c++)if(d=this.result[c]){for(let p=0,y;p<d.length;p++)if(y=d[p],!t.has(y)){if(a)a--;else if(i){if(l.push(y),l.length===e){t=l;break e}}else if(l[c]||(l[c]=[]),l[c].push(y),++h===e){t=l;break e}}}t=l}this.result=t,l=!0}return i&&(this.await=null),i?this.resolve(e,n,r,o,l):this}function Di(t,e,n,r,i){let a,o,l;typeof i=="string"?(a=i,i=""):a=i.template,o=a.indexOf("$1"),l=a.substring(o+2),o=a.substring(0,o);let c=i&&i.boundary,d=!i||i.clip!==!1,h=i&&i.merge&&l&&o&&new RegExp(l+" "+o,"g");i=i&&i.ellipsis;var p=0;if(typeof i=="object"){var y=i.template;p=y.length-2,i=i.pattern}typeof i!="string"&&(i=i===!1?"":"..."),p&&(i=y.replace("$1",i)),y=i.length-p;let k,C;typeof c=="object"&&(k=c.before,k===0&&(k=-1),C=c.after,C===0&&(C=-1),c=c.total||9e5),p=new Map;for(let Se=0,ie,de,Ce;Se<e.length;Se++){let xe;if(r)xe=e,Ce=r;else{var _=e[Se];if(Ce=_.field,!Ce)continue;xe=_.result}de=n.get(Ce),ie=de.encoder,_=p.get(ie),typeof _!="string"&&(_=ie.encode(t),p.set(ie,_));for(let tt=0;tt<xe.length;tt++){var v=xe[tt].doc;if(!v||(v=ai(v,Ce),!v))continue;var I=v.trim().split(/\s+/);if(!I.length)continue;v="";var O=[];let _e=[];for(var j=-1,K=-1,U=0,V=0;V<I.length;V++){var se=I[V],oe=ie.encode(se);oe=oe.length>1?oe.join(" "):oe[0];let Z;if(oe&&se){for(var ce=se.length,G=(ie.split?se.replace(ie.split,""):se).length-oe.length,N="",W=0,z=0;z<_.length;z++){var X=_[z];if(X){var le=X.length;le+=G<0?0:G,W&&le<=W||(X=oe.indexOf(X),X>-1&&(N=(X?se.substring(0,X):"")+o+se.substring(X,X+le)+l+(X+le<ce?se.substring(X+le):""),W=le,Z=!0))}}N&&(c&&(j<0&&(j=v.length+(v?1:0)),K=v.length+(v?1:0)+N.length,U+=ce,_e.push(O.length),O.push({match:N})),v+=(v?" ":"")+N)}if(!Z)se=I[V],v+=(v?" ":"")+se,c&&O.push({text:se});else if(c&&U>=c)break}if(U=_e.length*(a.length-2),k||C||c&&v.length-U>c)if(U=c+U-y*2,V=K-j,k>0&&(V+=k),C>0&&(V+=C),V<=U)I=k?j-(k>0?k:0):j-((U-V)/2|0),O=C?K+(C>0?C:0):I+U,d||(I>0&&v.charAt(I)!==" "&&v.charAt(I-1)!==" "&&(I=v.indexOf(" ",I),I<0&&(I=0)),O<v.length&&v.charAt(O-1)!==" "&&v.charAt(O)!==" "&&(O=v.lastIndexOf(" ",O),O<K?O=K:++O)),v=(I?i:"")+v.substring(I,O)+(O<v.length?i:"");else{for(K=[],j={},U={},V={},se={},oe={},N=G=ce=0,z=W=1;;){var ue=void 0;for(let Z=0,pe;Z<_e.length;Z++){if(pe=_e[Z],N)if(G!==N){if(V[Z+1])continue;if(pe+=N,j[pe]){ce-=y,U[Z+1]=1,V[Z+1]=1;continue}if(pe>=O.length-1){if(pe>=O.length){V[Z+1]=1,pe>=I.length&&(U[Z+1]=1);continue}ce-=y}if(v=O[pe].text,le=C&&oe[Z])if(le>0){if(v.length>le)if(V[Z+1]=1,d)v=v.substring(0,le);else continue;(le-=v.length)||(le=-1),oe[Z]=le}else{V[Z+1]=1;continue}if(ce+v.length+1<=c)v=" "+v,K[Z]+=v;else if(d)ue=c-ce-1,ue>0&&(v=" "+v.substring(0,ue),K[Z]+=v),V[Z+1]=1;else{V[Z+1]=1;continue}}else{if(V[Z])continue;if(pe-=G,j[pe]){ce-=y,V[Z]=1,U[Z]=1;continue}if(pe<=0){if(pe<0){V[Z]=1,U[Z]=1;continue}ce-=y}if(v=O[pe].text,le=k&&se[Z])if(le>0){if(v.length>le)if(V[Z]=1,d)v=v.substring(v.length-le);else continue;(le-=v.length)||(le=-1),se[Z]=le}else{V[Z]=1;continue}if(ce+v.length+1<=c)v+=" ",K[Z]=v+K[Z];else if(d)ue=v.length+1-(c-ce),ue>=0&&ue<v.length&&(v=v.substring(ue)+" ",K[Z]=v+K[Z]),V[Z]=1;else{V[Z]=1;continue}}else{v=O[pe].match,k&&(se[Z]=k),C&&(oe[Z]=C),Z&&ce++;let ve;if(pe?!Z&&y&&(ce+=y):(U[Z]=1,V[Z]=1),pe>=I.length-1||pe<O.length-1&&O[pe+1].match?ve=1:y&&(ce+=y),ce-=a.length-2,!Z||ce+v.length<=c)K[Z]=v;else{ue=W=z=U[Z]=0;break}ve&&(U[Z+1]=1,V[Z+1]=1)}ce+=v.length,ue=j[pe]=1}if(ue)G===N?N++:G++;else{if(G===N?W=0:z=0,!W&&!z)break;W?(G++,N=G):N++}}v="";for(let Z=0,pe;Z<K.length;Z++)pe=(U[Z]?Z?" ":"":(Z&&!i?" ":"")+i)+K[Z],v+=pe;i&&!U[K.length]&&(v+=i)}h&&(v=v.replace(h," ")),xe[tt].highlight=v}if(r)break}return e}function Gt(t,e){if(!this||this.constructor!==Gt)return new Gt(t,e);let n=0,r,i,a,o,l,c;if(t&&t.index){const d=t;if(e=d.index,n=d.boost||0,i=d.query){a=d.field||d.pluck,o=d.highlight;const h=d.resolve;t=d.async||d.queue,d.resolve=!1,d.index=null,t=t?e.searchAsync(d):e.search(d),d.resolve=h,d.index=e,t=t.result||t}else t=[]}if(t&&t.then){const d=this;t=t.then(function(h){d.C[0]=d.result=h.result||h,ks(d)}),r=[t],t=[],l=new Promise(function(h){c=h})}this.index=e||null,this.result=t||[],this.h=n,this.C=r||[],this.await=l||null,this.return=c||null,this.highlight=o||null,this.query=i||"",this.field=a||""}We=Gt.prototype;We.limit=function(t){if(this.await){const e=this;this.C.push(function(){return e.limit(t).result})}else if(this.result.length){const e=[];for(let n=0,r;n<this.result.length;n++)if(r=this.result[n])if(r.length<=t){if(e[n]=r,t-=r.length,!t)break}else{e[n]=r.slice(0,t);break}this.result=e}return this};We.offset=function(t){if(this.await){const e=this;this.C.push(function(){return e.offset(t).result})}else if(this.result.length){const e=[];for(let n=0,r;n<this.result.length;n++)(r=this.result[n])&&(r.length<=t?t-=r.length:(e[n]=r.slice(t),t=0));this.result=e}return this};We.boost=function(t){if(this.await){const e=this;this.C.push(function(){return e.boost(t).result})}else this.h+=t;return this};function ks(t,e){let n=t.result;var r=t.await;t.await=null;for(let i=0,a;i<t.C.length;i++)if(a=t.C[i]){if(typeof a=="function")n=a(),t.C[i]=n=n.result||n,i--;else if(a.h)n=a.h(),t.C[i]=n=n.result||n,i--;else if(a.then)return t.await=r}return r=t.return,t.C=[],t.return=null,e||r(n),n}We.resolve=function(t,e,n,r,i){let a=this.await?ks(this,!0):this.result;if(a.then){const o=this;return a.then(function(){return o.resolve(t,e,n,r,i)})}return a.length&&(typeof t=="object"?(r=t.highlight||this.highlight,n=!!r||t.enrich,e=t.offset,t=t.limit):(r=r||this.highlight,n=!!r||n),a=i?n?Fr.call(this.index,a):a:bs.call(this.index,a,t||100,e,n)),this.finalize(a,r)};We.finalize=function(t,e){if(t.then){const r=this;return t.then(function(i){return r.finalize(i,e)})}e&&t.length&&this.query&&(t=Di(this.query,t,this.index.index,this.field,e));const n=this.return;return this.highlight=this.index=this.result=this.C=this.await=this.return=null,this.query=this.field="",n&&n(t),t};function Ti(t,e,n,r,i,a,o){const l=t.length;let c=[],d,h;d=fn();for(let p=0,y,k,C,_;p<e;p++)for(let v=0;v<l;v++)if(C=t[v],p<C.length&&(y=C[p]))for(let I=0;I<y.length;I++){if(k=y[I],(h=d[k])?d[k]++:(h=0,d[k]=1),_=c[h]||(c[h]=[]),!o){let O=p+(v||!i?0:a||0);_=_[O]||(_[O]=[])}if(_.push(k),o&&n&&h===l-1&&_.length-r===n)return r?_.slice(r):_}if(t=c.length)if(i)c=c.length>1?Sa(c,n,r,o,a):(c=c[0])&&n&&c.length>n||r?c.slice(r,n+r):c;else{if(t<l)return[];if(c=c[t-1],n||r)if(o)(c.length>n||r)&&(c=c.slice(r,n+r));else{i=[];for(let p=0,y;p<c.length;p++)if(y=c[p]){if(r&&y.length>r)r-=y.length;else if((n&&y.length>n||r)&&(y=y.slice(r,n+r),n-=y.length,r&&(r-=y.length)),i.push(y),!n)break}c=i}}return c}function Sa(t,e,n,r,i){const a=[],o=fn();let l;var c=t.length;let d;if(r){for(i=c-1;i>=0;i--)if(d=(r=t[i])&&r.length){for(c=0;c<d;c++)if(l=r[c],!o[l]){if(o[l]=1,n)n--;else if(a.push(l),a.length===e)return a}}}else for(let h=c-1,p,y=0;h>=0;h--){p=t[h];for(let k=0;k<p.length;k++)if(d=(r=p[k])&&r.length){for(let C=0;C<d;C++)if(l=r[C],!o[l])if(o[l]=1,n)n--;else{let _=(k+(h<c-1&&i||0))/(h+1)|0;if((a[_]||(a[_]=[])).push(l),++y===e)return a}}}return a}function _h(t,e,n,r,i){const a=fn(),o=[];for(let l=0,c;l<e.length;l++){c=e[l];for(let d=0;d<c.length;d++)a[c[d]]=1}if(i){for(let l=0,c;l<t.length;l++)if(c=t[l],a[c]){if(r)r--;else if(o.push(c),a[c]=0,n&&--n===0)break}}else for(let l=0,c,d;l<t.result.length;l++)for(c=t.result[l],e=0;e<c.length;e++)d=c[e],a[d]&&((o[l]||(o[l]=[])).push(d),a[d]=0);return o}Kr.prototype.search=function(t,e,n,r){n||(!e&&si(t)?(n=t,t=""):si(e)&&(n=e,e=0));let i=[];var a=[];let o,l,c,d,h,p,y=0,k=!0,C;if(n){n.constructor===Array&&(n={index:n}),t=n.query||t,o=n.pluck,l=n.merge,d=n.boost,p=o||n.field||(p=n.index)&&(p.index?null:p);var _=this.tag&&n.tag;c=n.suggest,k=n.resolve!==!1,h=n.cache,C=k&&this.store&&n.highlight;var v=!!C||k&&this.store&&n.enrich;e=n.limit||e;var I=n.offset||0;if(e||(e=k?100:0),_&&(!this.db||!r)){_.constructor!==Array&&(_=[_]);var O=[];for(let se=0,oe;se<_.length;se++)if(oe=_[se],oe.field&&oe.tag){var j=oe.tag;if(j.constructor===Array)for(var K=0;K<j.length;K++)O.push(oe.field,j[K]);else O.push(oe.field,j)}else{j=Object.keys(oe);for(let ce=0,G,N;ce<j.length;ce++)if(G=j[ce],N=oe[G],N.constructor===Array)for(K=0;K<N.length;K++)O.push(G,N[K]);else O.push(G,N)}if(_=O,!t){if(a=[],O.length)for(_=0;_<O.length;_+=2){if(this.db){if(r=this.index.get(O[_]),!r)continue;a.push(r=r.db.tag(O[_+1],e,I,v))}else r=bh.call(this,O[_],O[_+1],e,I,v);i.push(k?{field:O[_],tag:O[_+1],result:r}:[r])}if(a.length){const se=this;return Promise.all(a).then(function(oe){for(let ce=0;ce<oe.length;ce++)k?i[ce].result=oe[ce]:i[ce]=oe[ce];return k?i:new Gt(i.length>1?Ti(i,1,0,0,c,d):i[0],se)})}return k?i:new Gt(i.length>1?Ti(i,1,0,0,c,d):i[0],this)}}k||o||!(p=p||this.field)||(Xn(p)?o=p:(p.constructor===Array&&p.length===1&&(p=p[0]),o=p.field||p.index)),p&&p.constructor!==Array&&(p=[p])}p||(p=this.field);let U;O=(this.worker||this.db)&&!r&&[];for(let se=0,oe,ce,G;se<p.length;se++){if(ce=p[se],this.db&&this.tag&&!this.B[se])continue;let N;if(Xn(ce)||(N=ce,ce=N.field,t=N.query||t,e=Mr(N.limit,e),I=Mr(N.offset,I),c=Mr(N.suggest,c),C=k&&this.store&&Mr(N.highlight,C),v=!!C||k&&this.store&&Mr(N.enrich,v),h=Mr(N.cache,h)),r)oe=r[se];else{j=N||n||{},K=j.enrich;var V=this.index.get(ce);if(_&&(this.db&&(j.tag=_,j.field=p,U=V.db.support_tag_search),!U&&K&&(j.enrich=!1),U||(j.limit=0,j.offset=0)),oe=h?V.searchCache(t,_&&!U?0:e,j):V.search(t,_&&!U?0:e,j),_&&!U&&(j.limit=e,j.offset=I),K&&(j.enrich=K),O){O[se]=oe;continue}}if(G=(oe=oe.result||oe)&&oe.length,_&&G){if(j=[],K=0,this.db&&r){if(!U)for(V=p.length;V<r.length;V++){let W=r[V];if(W&&W.length)K++,j.push(W);else if(!c)return k?i:new Gt(i,this)}}else for(let W=0,z,X;W<_.length;W+=2){if(z=this.tag.get(_[W]),!z){if(c)continue;return k?i:new Gt(i,this)}if(X=(z=z&&z.get(_[W+1]))&&z.length)K++,j.push(z);else if(!c)return k?i:new Gt(i,this)}if(K){if(oe=_h(oe,j,e,I,k),G=oe.length,!G&&!c)return k?oe:new Gt(oe,this);K--}}if(G)a[y]=ce,i.push(oe),y++;else if(p.length===1)return k?i:new Gt(i,this)}if(O){if(this.db&&_&&_.length&&!U)for(v=0;v<_.length;v+=2){if(a=this.index.get(_[v]),!a){if(c)continue;return k?i:new Gt(i,this)}O.push(a.db.tag(_[v+1],e,I,!1))}const se=this;return Promise.all(O).then(function(oe){return n&&(n.resolve=k),oe.length&&(oe=se.search(t,e,n,oe)),oe})}if(!y)return k?i:new Gt(i,this);if(o&&(!v||!this.store))return i=i[0],k?i:new Gt(i,this);for(O=[],I=0;I<a.length;I++){if(_=i[I],v&&_.length&&typeof _[0].doc>"u"&&(this.db?O.push(_=this.index.get(this.field[0]).db.enrich(_)):_=Fr.call(this,_)),o)return k?C?Di(t,_,this.index,o,C):_:new Gt(_,this);i[I]={field:a[I],result:_}}if(v&&this.db&&O.length){const se=this;return Promise.all(O).then(function(oe){for(let ce=0;ce<oe.length;ce++)i[ce].result=oe[ce];return C&&(i=Di(t,i,se.index,o,C)),l?Js(i):i})}return C&&(i=Di(t,i,this.index,o,C)),l?Js(i):i};function Js(t){const e=[],n=fn(),r=fn();for(let i=0,a,o,l,c,d,h,p;i<t.length;i++){a=t[i],o=a.field,l=a.result;for(let y=0;y<l.length;y++)d=l[y],typeof d!="object"?d={id:c=d}:c=d.id,(h=n[c])?h.push(o):(d.field=n[c]=[o],e.push(d)),(p=d.highlight)&&(h=r[c],h||(r[c]=h={},d.highlight=h),h[o]=p)}return e}function bh(t,e,n,r,i){return t=this.tag.get(t),t?(t=t.get(e),t?(e=t.length-r,e>0&&((n&&e>n||r)&&(t=t.slice(r,r+n)),i&&(t=Fr.call(this,t))),t):[]):[]}function Fr(t){if(!this||!this.store)return t;if(this.db)return this.index.get(this.field[0]).db.enrich(t);const e=Array(t.length);for(let n=0,r;n<t.length;n++)r=t[n],e[n]={id:r,doc:this.store.get(r)};return e}function Kr(t){if(!this||this.constructor!==Kr)return new Kr(t);const e=t.document||t.doc||t;let n,r;if(this.B=[],this.field=[],this.D=[],this.key=(n=e.key||e.id)&&Mi(n,this.D)||"id",(r=t.keystore||0)&&(this.keystore=r),this.fastupdate=!!t.fastupdate,this.reg=!this.fastupdate||t.worker||t.db?r?new Qn(r):new Set:r?new Jn(r):new Map,this.h=(n=e.store||null)&&n&&n!==!0&&[],this.store=n?r?new Jn(r):new Map:null,this.cache=(n=t.cache||null)&&new Sr(n),t.cache=!1,this.worker=t.worker||!1,this.priority=t.priority||4,this.index=kh.call(this,t,e),this.tag=null,(n=e.tag)&&(typeof n=="string"&&(n=[n]),n.length)){this.tag=new Map,this.A=[],this.F=[];for(let i=0,a,o;i<n.length;i++){if(a=n[i],o=a.field||a,!o)throw Error("The tag field from the document descriptor is undefined.");a.custom?this.A[i]=a.custom:(this.A[i]=Mi(o,this.D),a.filter&&(typeof this.A[i]=="string"&&(this.A[i]=new String(this.A[i])),this.A[i].G=a.filter)),this.F[i]=o,this.tag.set(o,new Map)}}if(this.worker){this.fastupdate=!1,t=[];for(const i of this.index.values())i.then&&t.push(i);if(t.length){const i=this;return Promise.all(t).then(function(a){let o=0;for(const l of i.index.entries()){const c=l[0];let d=l[1];d.then&&(d=a[o],i.index.set(c,d),o++)}return i})}}else t.db&&(this.fastupdate=!1,this.mount(t.db))}We=Kr.prototype;We.mount=function(t){let e=this.field;if(this.tag)for(let a=0,o;a<this.F.length;a++){o=this.F[a];var n=void 0;this.index.set(o,n=new qn({},this.reg)),e===this.field&&(e=e.slice(0)),e.push(o),n.tag=this.tag.get(o)}n=[];const r={db:t.db,type:t.type,fastupdate:t.fastupdate};for(let a=0,o,l;a<e.length;a++){r.field=l=e[a],o=this.index.get(l);const c=new t.constructor(t.id,r);c.id=t.id,n[a]=c.mount(o),o.document=!0,a?o.bypass=!0:o.store=this.store}const i=this;return this.db=Promise.all(n).then(function(){i.db=!0})};We.commit=async function(){const t=[];for(const e of this.index.values())t.push(e.commit());await Promise.all(t),this.reg.clear()};We.destroy=function(){const t=[];for(const e of this.index.values())t.push(e.destroy());return Promise.all(t)};function kh(t,e){const n=new Map;let r=e.index||e.field||e;Xn(r)&&(r=[r]);for(let a=0,o,l;a<r.length;a++){if(o=r[a],Xn(o)||(l=o,o=o.field),l=si(l)?Object.assign({},t,l):t,this.worker){var i=void 0;i=(i=l.encoder)&&i.encode?i:new oi(typeof i=="string"?ms[i]:i||{}),i=new Vr(l,i),n.set(o,i)}this.worker||n.set(o,new qn(l,this.reg)),l.custom?this.B[a]=l.custom:(this.B[a]=Mi(o,this.D),l.filter&&(typeof this.B[a]=="string"&&(this.B[a]=new String(this.B[a])),this.B[a].G=l.filter)),this.field[a]=o}if(this.h){t=e.store,Xn(t)&&(t=[t]);for(let a=0,o,l;a<t.length;a++)o=t[a],l=o.field||o,o.custom?(this.h[a]=o.custom,o.custom.O=l):(this.h[a]=Mi(l,this.D),o.filter&&(typeof this.h[a]=="string"&&(this.h[a]=new String(this.h[a])),this.h[a].G=o.filter))}return n}function Mi(t,e){const n=t.split(":");let r=0;for(let i=0;i<n.length;i++)t=n[i],t[t.length-1]==="]"&&(t=t.substring(0,t.length-2))&&(e[r]=!0),t&&(n[r++]=t);return r<n.length&&(n.length=r),r>1?n:n[0]}We.append=function(t,e){return this.add(t,e,!0)};We.update=function(t,e){return this.remove(t).add(t,e)};We.remove=function(t){si(t)&&(t=ai(t,this.key));for(var e of this.index.values())e.remove(t,!0);if(this.reg.has(t)){if(this.tag&&!this.fastupdate)for(let n of this.tag.values())for(let r of n){e=r[0];const i=r[1],a=i.indexOf(t);a>-1&&(i.length>1?i.splice(a,1):n.delete(e))}this.store&&this.store.delete(t),this.reg.delete(t)}return this.cache&&this.cache.remove(t),this};We.clear=function(){const t=[];for(const e of this.index.values()){const n=e.clear();n.then&&t.push(n)}if(this.tag)for(const e of this.tag.values())e.clear();return this.store&&this.store.clear(),this.cache&&this.cache.clear(),t.length?Promise.all(t):this};We.contain=function(t){return this.db?this.index.get(this.field[0]).db.has(t):this.reg.has(t)};We.cleanup=function(){for(const t of this.index.values())t.cleanup();return this};We.get=function(t){return this.db?this.index.get(this.field[0]).db.enrich(t).then(function(e){return e[0]&&e[0].doc||null}):this.store.get(t)||null};We.set=function(t,e){return typeof t=="object"&&(e=t,t=ai(e,this.key)),this.store.set(t,e),this};We.searchCache=ys;We.export=wh;We.import=xh;_s(Kr.prototype);function ws(t,e=0){let n=[],r=[];e&&(e=25e4/e*5e3|0);for(const i of t.entries())r.push(i),r.length===e&&(n.push(r),r=[]);return r.length&&n.push(r),n}function xs(t,e){e||(e=new Map);for(let n=0,r;n<t.length;n++)r=t[n],e.set(r[0],r[1]);return e}function Na(t,e=0){let n=[],r=[];e&&(e=25e4/e*1e3|0);for(const i of t.entries())r.push([i[0],ws(i[1])[0]||[]]),r.length===e&&(n.push(r),r=[]);return r.length&&n.push(r),n}function Da(t,e){e||(e=new Map);for(let n=0,r,i;n<t.length;n++)r=t[n],i=e.get(r[0]),e.set(r[0],xs(r[1],i));return e}function Pa(t){let e=[],n=[];for(const r of t.keys())n.push(r),n.length===25e4&&(e.push(n),n=[]);return n.length&&e.push(n),e}function Ia(t,e){e||(e=new Set);for(let n=0;n<t.length;n++)e.add(t[n]);return e}function Ei(t,e,n,r,i,a,o=0){const l=r&&r.constructor===Array;var c=l?r.shift():r;if(!c)return this.export(t,e,i,a+1);if((c=t((e?e+".":"")+(o+1)+"."+n,JSON.stringify(c)))&&c.then){const d=this;return c.then(function(){return Ei.call(d,t,e,n,l?r:null,i,a,o+1)})}return Ei.call(this,t,e,n,l?r:null,i,a,o+1)}function wh(t,e,n=0,r=0){if(n<this.field.length){const o=this.field[n];if((e=this.index.get(o).export(t,o,n,r=1))&&e.then){const l=this;return e.then(function(){return l.export(t,o,n+1)})}return this.export(t,o,n+1)}let i,a;switch(r){case 0:i="reg",a=Pa(this.reg),e=null;break;case 1:i="tag",a=this.tag&&Na(this.tag,this.reg.size),e=null;break;case 2:i="doc",a=this.store&&ws(this.store),e=null;break;default:return}return Ei.call(this,t,e,i,a||null,n,r)}function xh(t,e){var n=t.split(".");n[n.length-1]==="json"&&n.pop();const r=n.length>2?n[0]:"";if(n=n.length>2?n[2]:n[1],this.worker&&r)return this.index.get(r).import(t);if(e){if(typeof e=="string"&&(e=JSON.parse(e)),r)return this.index.get(r).import(n,e);switch(n){case"reg":this.fastupdate=!1,this.reg=Ia(e,this.reg);for(let i=0,a;i<this.field.length;i++)a=this.index.get(this.field[i]),a.fastupdate=!1,a.reg=this.reg;if(this.worker){e=[];for(const i of this.index.values())e.push(i.import(t));return Promise.all(e)}break;case"tag":this.tag=Da(e,this.tag);break;case"doc":this.store=xs(e,this.store)}}}function Qs(t,e){let n="";for(const r of t.entries()){t=r[0];const i=r[1];let a="";for(let o=0,l;o<i.length;o++){l=i[o]||[""];let c="";for(let d=0;d<l.length;d++)c+=(c?",":"")+(e==="string"?'"'+l[d]+'"':l[d]);c="["+c+"]",a+=(a?",":"")+c}a='["'+t+'",['+a+"]]",n+=(n?",":"")+a}return n}qn.prototype.remove=function(t,e){const n=this.reg.size&&(this.fastupdate?this.reg.get(t):this.reg.has(t));if(n){if(this.fastupdate){for(let r=0,i,a;r<n.length;r++)if((i=n[r])&&(a=i.length))if(i[a-1]===t)i.pop();else{const o=i.indexOf(t);o>=0&&i.splice(o,1)}}else li(this.map,t),this.depth&&li(this.ctx,t);e||this.reg.delete(t)}return this.db&&(this.commit_task.push({del:t}),this.M&&Ta(this)),this.cache&&this.cache.remove(t),this};function li(t,e){let n=0;var r=typeof e>"u";if(t.constructor===Array){for(let i=0,a,o,l;i<t.length;i++)if((a=t[i])&&a.length){if(r)return 1;if(o=a.indexOf(e),o>=0){if(a.length>1)return a.splice(o,1),1;if(delete t[i],n)return 1;l=1}else{if(l)return 1;n++}}}else for(let i of t.entries())r=i[0],li(i[1],e)?n++:t.delete(r);return n}const Ch={memory:{resolution:1},performance:{resolution:3,fastupdate:!0,context:{depth:1,resolution:1}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:3}}};qn.prototype.add=function(t,e,n,r){if(e&&(t||t===0)){if(!r&&!n&&this.reg.has(t))return this.update(t,e);r=this.depth,e=this.encoder.encode(e,!r);const d=e.length;if(d){const h=fn(),p=fn(),y=this.resolution;for(let k=0;k<d;k++){let C=e[this.rtl?d-1-k:k];var i=C.length;if(i&&(r||!p[C])){var a=this.score?this.score(e,C,k,null,0):_i(y,d,k),o="";switch(this.tokenize){case"tolerant":if(or(this,p,C,a,t,n),i>2){for(let _=1,v,I,O,j;_<i-1;_++)v=C.charAt(_),I=C.charAt(_+1),O=C.substring(0,_)+I,j=C.substring(_+2),o=O+v+j,or(this,p,o,a,t,n),o=O+j,or(this,p,o,a,t,n);or(this,p,C.substring(0,C.length-1),a,t,n)}break;case"full":if(i>2){for(let _=0,v;_<i;_++)for(a=i;a>_;a--){o=C.substring(_,a),v=this.rtl?i-1-_:_;var l=this.score?this.score(e,C,k,o,v):_i(y,d,k,i,v);or(this,p,o,l,t,n)}break}case"bidirectional":case"reverse":if(i>1){for(l=i-1;l>0;l--){o=C[this.rtl?i-1-l:l]+o;var c=this.score?this.score(e,C,k,o,l):_i(y,d,k,i,l);or(this,p,o,c,t,n)}o=""}case"forward":if(i>1){for(l=0;l<i;l++)o+=C[this.rtl?i-1-l:l],or(this,p,o,a,t,n);break}default:if(or(this,p,C,a,t,n),r&&d>1&&k<d-1)for(i=this.N,o=C,a=Math.min(r+1,this.rtl?k+1:d-k),l=1;l<a;l++){C=e[this.rtl?d-1-k-l:k+l],c=this.bidirectional&&C>o;const _=this.score?this.score(e,o,k,C,l-1):_i(i+(d/2>i?0:1),d,k,a-1,l-1);or(this,h,c?o:C,_,t,n,c?C:o)}}}}this.fastupdate||this.reg.add(t)}}return this.db&&(this.commit_task.push(n?{ins:t}:{del:t}),this.M&&Ta(this)),this};function or(t,e,n,r,i,a,o){let l,c;if(!(l=e[n])||o&&!l[o]){if(o?(e=l||(e[n]=fn()),e[o]=1,c=t.ctx,(l=c.get(o))?c=l:c.set(o,c=t.keystore?new Jn(t.keystore):new Map)):(c=t.map,e[n]=1),(l=c.get(n))?c=l:c.set(n,c=l=[]),a){for(let d=0,h;d<l.length;d++)if((h=l[d])&&h.includes(i)){if(d<=r)return;h.splice(h.indexOf(i),1),t.fastupdate&&(e=t.reg.get(i))&&e.splice(e.indexOf(h),1);break}}if(c=c[r]||(c[r]=[]),c.push(i),c.length===2**31-1){if(e=new jr(c),t.fastupdate)for(let d of t.reg.values())d.includes(c)&&(d[d.indexOf(c)]=e);l[r]=c=e}t.fastupdate&&((r=t.reg.get(i))?r.push(c):t.reg.set(i,[c]))}}function _i(t,e,n,r,i){return n&&t>1?e+(r||0)<=t?n+(i||0):(t-1)/(e+(r||0))*(n+(i||0))+1|0:0}qn.prototype.search=function(t,e,n){if(n||(e||typeof t!="object"?typeof e=="object"&&(n=e,e=0):(n=t,t="")),n&&n.cache)return n.cache=!1,t=this.searchCache(t,e,n),n.cache=!0,t;let r=[],i,a,o,l=0,c,d,h,p,y;n&&(t=n.query||t,e=n.limit||e,l=n.offset||0,a=n.context,o=n.suggest,y=(c=n.resolve)&&n.enrich,h=n.boost,p=n.resolution,d=this.db&&n.tag),typeof c>"u"&&(c=this.resolve),a=this.depth&&a!==!1;let k=this.encoder.encode(t,!a);if(i=k.length,e=e||(c?100:0),i===1)return ea.call(this,k[0],"",e,l,c,y,d);if(i===2&&a&&!o)return ea.call(this,k[1],k[0],e,l,c,y,d);let C=fn(),_=0,v;if(a&&(v=k[0],_=1),p||p===0||(p=v?this.N:this.resolution),this.db){if(this.db.search&&(n=this.db.search(this,k,e,l,o,c,y,d),n!==!1))return n;const I=this;return(async function(){for(let O,j;_<i;_++){if((j=k[_])&&!C[j]){if(C[j]=1,O=await cs(I,j,v,0,0,!1,!1),O=ta(O,r,o,p)){r=O;break}v&&(o&&O&&r.length||(v=j))}o&&v&&_===i-1&&!r.length&&(p=I.resolution,v="",_=-1,C=fn())}return qs(r,p,e,l,o,h,c)})()}for(let I,O;_<i;_++){if((O=k[_])&&!C[O]){if(C[O]=1,I=cs(this,O,v,0,0,!1,!1),I=ta(I,r,o,p)){r=I;break}v&&(o&&I&&r.length||(v=O))}o&&v&&_===i-1&&!r.length&&(p=this.resolution,v="",_=-1,C=fn())}return qs(r,p,e,l,o,h,c)};function qs(t,e,n,r,i,a,o){let l=t.length,c=t;if(l>1)c=Ti(t,e,n,r,i,a,o);else if(l===1)return o?bs.call(null,t[0],n,r):new Gt(t[0],this);return o?c:new Gt(c,this)}function ea(t,e,n,r,i,a,o){return t=cs(this,t,e,n,r,i,a,o),this.db?t.then(function(l){return i?l||[]:new Gt(l,this)}):t&&t.length?i?bs.call(this,t,n,r):new Gt(t,this):i?[]:new Gt([],this)}function ta(t,e,n,r){let i=[];if(t&&t.length){if(t.length<=r){e.push(t);return}for(let a=0,o;a<r;a++)(o=t[a])&&(i[a]=o);if(i.length){e.push(i);return}}if(!n)return i}function cs(t,e,n,r,i,a,o,l){let c;return n&&(c=t.bidirectional&&e>n)&&(c=n,n=e,e=c),t.db?t.db.get(e,n,r,i,a,o,l):(t=n?(t=t.ctx.get(n))&&t.get(e):t.map.get(e),t)}function qn(t,e){if(!this||this.constructor!==qn)return new qn(t);if(t){var n=Xn(t)?t:t.preset;n&&(t=Object.assign({},Ch[n],t))}else t={};n=t.context;const r=n===!0?{depth:1}:n||{},i=Xn(t.encoder)?ms[t.encoder]:t.encode||t.encoder||{};this.encoder=i.encode?i:typeof i=="object"?new oi(i):{encode:i},this.resolution=t.resolution||9,this.tokenize=n=(n=t.tokenize)&&n!=="default"&&n!=="exact"&&n||"strict",this.depth=n==="strict"&&r.depth||0,this.bidirectional=r.bidirectional!==!1,this.fastupdate=!!t.fastupdate,this.score=t.score||null,(n=t.keystore||0)&&(this.keystore=n),this.map=n?new Jn(n):new Map,this.ctx=n?new Jn(n):new Map,this.reg=e||(this.fastupdate?n?new Jn(n):new Map:n?new Qn(n):new Set),this.N=r.resolution||3,this.rtl=i.rtl||t.rtl||!1,this.cache=(n=t.cache||null)&&new Sr(n),this.resolve=t.resolve!==!1,(n=t.db)&&(this.db=this.mount(n)),this.M=t.commit!==!1,this.commit_task=[],this.commit_timer=null,this.priority=t.priority||4}We=qn.prototype;We.mount=function(t){return this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null),t.mount(this)};We.commit=function(){return this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null),this.db.commit(this)};We.destroy=function(){return this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null),this.db.destroy()};function Ta(t){t.commit_timer||(t.commit_timer=setTimeout(function(){t.commit_timer=null,t.db.commit(t)},1))}We.clear=function(){return this.map.clear(),this.ctx.clear(),this.reg.clear(),this.cache&&this.cache.clear(),this.db?(this.commit_timer&&clearTimeout(this.commit_timer),this.commit_timer=null,this.commit_task=[],this.db.clear()):this};We.append=function(t,e){return this.add(t,e,!0)};We.contain=function(t){return this.db?this.db.has(t):this.reg.has(t)};We.update=function(t,e){const n=this,r=this.remove(t);return r&&r.then?r.then(()=>n.add(t,e)):this.add(t,e)};We.cleanup=function(){return this.fastupdate?(li(this.map),this.depth&&li(this.ctx),this):this};We.searchCache=ys;We.export=function(t,e,n=0,r=0){let i,a;switch(r){case 0:i="reg",a=Pa(this.reg);break;case 1:i="cfg",a=null;break;case 2:i="map",a=ws(this.map,this.reg.size);break;case 3:i="ctx",a=Na(this.ctx,this.reg.size);break;default:return}return Ei.call(this,t,e,i,a,n,r)};We.import=function(t,e){if(e)switch(typeof e=="string"&&(e=JSON.parse(e)),t=t.split("."),t[t.length-1]==="json"&&t.pop(),t.length===3&&t.shift(),t=t.length>1?t[1]:t[0],t){case"reg":this.fastupdate=!1,this.reg=Ia(e,this.reg);break;case"map":this.map=xs(e,this.map);break;case"ctx":this.ctx=Da(e,this.ctx)}};We.serialize=function(t=!0){let e="",n="",r="";if(this.reg.size){let a;for(var i of this.reg.keys())a||(a=typeof i),e+=(e?",":"")+(a==="string"?'"'+i+'"':i);e="index.reg=new Set(["+e+"]);",n=Qs(this.map,a),n="index.map=new Map(["+n+"]);";for(const o of this.ctx.entries()){i=o[0];let l=Qs(o[1],a);l="new Map(["+l+"])",l='["'+i+'",'+l+"]",r+=(r?",":"")+l}r="index.ctx=new Map(["+r+"]);"}return t?"function inject(index){"+e+n+r+"}":e+n+r};_s(qn.prototype);const Ma=typeof window<"u"&&(window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB),Ai=["map","ctx","tag","reg","cfg"],kr=fn();function ds(t,e={}){if(!this||this.constructor!==ds)return new ds(t,e);typeof t=="object"&&(e=t,t=t.name),t||console.info("Default storage space was used, because a name was not passed."),this.id="flexsearch"+(t?":"+t.toLowerCase().replace(/[^a-z0-9_\-]/g,""):""),this.field=e.field?e.field.toLowerCase().replace(/[^a-z0-9_\-]/g,""):"",this.type=e.type,this.fastupdate=this.support_tag_search=!1,this.db=null,this.h={}}We=ds.prototype;We.mount=function(t){return t.index?t.mount(this):(t.db=this,this.open())};We.open=function(){if(this.db)return this.db;let t=this;navigator.storage&&navigator.storage.persist&&navigator.storage.persist(),kr[t.id]||(kr[t.id]=[]),kr[t.id].push(t.field);const e=Ma.open(t.id,1);return e.onupgradeneeded=function(){const n=t.db=this.result;for(let r=0,i;r<Ai.length;r++){i=Ai[r];for(let a=0,o;a<kr[t.id].length;a++)o=kr[t.id][a],n.objectStoreNames.contains(i+(i!=="reg"&&o?":"+o:""))||n.createObjectStore(i+(i!=="reg"&&o?":"+o:""))}},t.db=yr(e,function(n){t.db=n,t.db.onversionchange=function(){t.close()}})};We.close=function(){this.db&&this.db.close(),this.db=null};We.destroy=function(){const t=Ma.deleteDatabase(this.id);return yr(t)};We.clear=function(){const t=[];for(let n=0,r;n<Ai.length;n++){r=Ai[n];for(let i=0,a;i<kr[this.id].length;i++)a=kr[this.id][i],t.push(r+(r!=="reg"&&a?":"+a:""))}const e=this.db.transaction(t,"readwrite");for(let n=0;n<t.length;n++)e.objectStore(t[n]).clear();return yr(e)};We.get=function(t,e,n=0,r=0,i=!0,a=!1){t=this.db.transaction((e?"ctx":"map")+(this.field?":"+this.field:""),"readonly").objectStore((e?"ctx":"map")+(this.field?":"+this.field:"")).get(e?e+":"+t:t);const o=this;return yr(t).then(function(l){let c=[];if(!l||!l.length)return c;if(i){if(!n&&!r&&l.length===1)return l[0];for(let d=0,h;d<l.length;d++)if((h=l[d])&&h.length){if(r>=h.length){r-=h.length;continue}const p=n?r+Math.min(h.length-r,n):h.length;for(let y=r;y<p;y++)c.push(h[y]);if(r=0,c.length===n)break}return a?o.enrich(c):c}return l})};We.tag=function(t,e=0,n=0,r=!1){t=this.db.transaction("tag"+(this.field?":"+this.field:""),"readonly").objectStore("tag"+(this.field?":"+this.field:"")).get(t);const i=this;return yr(t).then(function(a){return!a||!a.length||n>=a.length?[]:!e&&!n?a:(a=a.slice(n,n+e),r?i.enrich(a):a)})};We.enrich=function(t){typeof t!="object"&&(t=[t]);const e=this.db.transaction("reg","readonly").objectStore("reg"),n=[];for(let r=0;r<t.length;r++)n[r]=yr(e.get(t[r]));return Promise.all(n).then(function(r){for(let i=0;i<r.length;i++)r[i]={id:t[i],doc:r[i]?JSON.parse(r[i]):null};return r})};We.has=function(t){return t=this.db.transaction("reg","readonly").objectStore("reg").getKey(t),yr(t).then(function(e){return!!e})};We.search=null;We.info=function(){};We.transaction=function(t,e,n){t+=t!=="reg"&&this.field?":"+this.field:"";let r=this.h[t+":"+e];if(r)return n.call(this,r);let i=this.db.transaction(t,e);this.h[t+":"+e]=r=i.objectStore(t);const a=n.call(this,r);return this.h[t+":"+e]=null,yr(i).finally(function(){return a})};We.commit=async function(t){let e=t.commit_task,n=[];t.commit_task=[];for(let r=0,i;r<e.length;r++)i=e[r],i.del&&n.push(i.del);n.length&&await this.remove(n),t.reg.size&&(await this.transaction("map","readwrite",function(r){for(const i of t.map){const a=i[0],o=i[1];o.length&&(r.get(a).onsuccess=function(){let l=this.result;var c;if(l&&l.length){const d=Math.max(l.length,o.length);for(let h=0,p,y;h<d;h++)if((y=o[h])&&y.length){if((p=l[h])&&p.length)for(c=0;c<y.length;c++)p.push(y[c]);else l[h]=y;c=1}}else l=o,c=1;c&&r.put(l,a)})}}),await this.transaction("ctx","readwrite",function(r){for(const i of t.ctx){const a=i[0],o=i[1];for(const l of o){const c=l[0],d=l[1];d.length&&(r.get(a+":"+c).onsuccess=function(){let h=this.result;var p;if(h&&h.length){const y=Math.max(h.length,d.length);for(let k=0,C,_;k<y;k++)if((_=d[k])&&_.length){if((C=h[k])&&C.length)for(p=0;p<_.length;p++)C.push(_[p]);else h[k]=_;p=1}}else h=d,p=1;p&&r.put(h,a+":"+c)})}}}),t.store?await this.transaction("reg","readwrite",function(r){for(const i of t.store){const a=i[0],o=i[1];r.put(typeof o=="object"?JSON.stringify(o):1,a)}}):t.bypass||await this.transaction("reg","readwrite",function(r){for(const i of t.reg.keys())r.put(1,i)}),t.tag&&await this.transaction("tag","readwrite",function(r){for(const i of t.tag){const a=i[0],o=i[1];o.length&&(r.get(a).onsuccess=function(){let l=this.result;l=l&&l.length?l.concat(o):o,r.put(l,a)})}}),t.map.clear(),t.ctx.clear(),t.tag&&t.tag.clear(),t.store&&t.store.clear(),t.document||t.reg.clear())};function Xi(t,e,n){const r=t.value;let i,a=0;for(let o=0,l;o<r.length;o++){if(l=n?r:r[o]){for(let c=0,d,h;c<e.length;c++)if(h=e[c],d=l.indexOf(h),d>=0)if(i=1,l.length>1)l.splice(d,1);else{r[o]=[];break}a+=l.length}if(n)break}a?i&&t.update(r):t.delete(),t.continue()}We.remove=function(t){return typeof t!="object"&&(t=[t]),Promise.all([this.transaction("map","readwrite",function(e){e.openCursor().onsuccess=function(){const n=this.result;n&&Xi(n,t)}}),this.transaction("ctx","readwrite",function(e){e.openCursor().onsuccess=function(){const n=this.result;n&&Xi(n,t)}}),this.transaction("tag","readwrite",function(e){e.openCursor().onsuccess=function(){const n=this.result;n&&Xi(n,t,!0)}}),this.transaction("reg","readwrite",function(e){for(let n=0;n<t.length;n++)e.delete(t[n])})])};function yr(t,e){return new Promise((n,r)=>{t.onsuccess=t.oncomplete=function(){e&&e(this.result),e=null,n(this.result)},t.onerror=t.onblocked=r,t=null})}const Sh={Index:qn},Nh=ms,kn=t=>!t||typeof t=="string"&&t.trim()==="",Dh=t=>t&&t.trim()!=="";function na(t,e="."){if(!t||typeof t!="string")return null;const n=t.lastIndexOf(e);return n===-1?"":t.substring(0,n)}function Ji(t,e,n="."){return kn(e)?t:t.startsWith(e+n)?t.substring(e.length+n.length):t}function Qi(t,e=0,n=1,r="."){return t.split(r).slice(e,e+n).join(r)}function Rr(t,e){return t.split(e).length}function Ph(){return new Sh.Index({tokenize:"full",resolution:9,encoder:Nh.Normalize})}class Ih{timeout;treeId;processingQueue=[];batchSize;searchIndex;isProcessing=!1;shouldCalculateSearchValue;searchValueMember;getSearchValueCallback;onProgressCallback;onCompleteCallback;totalItemsAdded=0;totalItemsProcessed=0;constructor(e,n,r,i,a,o=25,l=50,c=!1){this.timeout=l,this.treeId=e,this.searchIndex=n,this.batchSize=o,this.shouldCalculateSearchValue=r,this.searchValueMember=i,this.getSearchValueCallback=a,Wn.debug(`[${this.treeId}] Initialized with batch size: ${o}`)}addToQueue(e){this.processingQueue=this.processingQueue.concat(e),this.totalItemsAdded+=e.length,Wn.debug(`[${this.treeId}] Added ${e.length} items to queue. Queue size: ${this.processingQueue.length}`),this.isProcessing||this.startProcessing()}addItem(e){this.processingQueue.push(e),this.totalItemsAdded++,this.isProcessing||this.startProcessing()}setCallbacks(e,n){this.onProgressCallback=e,this.onCompleteCallback=n}setBatchSize(e){this.batchSize=e,Wn.debug(`[${this.treeId}] Batch size updated to: ${this.batchSize}`)}startProcessing(){this.isProcessing||this.processingQueue.length===0||(this.isProcessing=!0,Wn.debug(`[${this.treeId}] Starting indexing. Queue size: ${this.processingQueue.length}`),this.processNextBatch())}processNextBatch(){requestIdleCallback(e=>this.processBatch(e),{timeout:this.timeout})}processBatch(e){const n=performance.now();let r=0;const i=e.didTimeout,a=16;Wn.trace(`[${this.treeId}] Batch start: timeout=${i}, timeRemaining=${e.timeRemaining().toFixed(1)}ms, queueSize=${this.processingQueue.length}`);let o;for(i?o=Math.min(5,Math.ceil(this.batchSize/5)):o=this.batchSize;this.processingQueue.length>0&&r<o&&(!i&&e.timeRemaining()>1||i);){const c=performance.now()-n;if(c>a){Wn.trace(`[${this.treeId}] Time limit hit after ${c.toFixed(2)}ms, processed ${r} items`);break}const d=this.processingQueue.shift();if(this.indexItem(d),r++,this.totalItemsProcessed++,i&&r>=o)break}const l=performance.now()-n;Wn.trace(`[${this.treeId}] Batch end: ${r} items in ${l.toFixed(2)}ms`),this.onProgressCallback&&this.onProgressCallback(this.totalItemsProcessed,this.totalItemsAdded),this.processingQueue.length>0?this.processNextBatch():this.finishProcessing()}indexItem(e){const n=this.shouldCalculateSearchValue?this.getSearchValueCallback&&this.getSearchValueCallback(e.node):this.searchValueMember&&e.node.data?.[this.searchValueMember]?.toString();if(Dh(n)){const r=performance.now();this.searchIndex.add(e.index,n);const i=performance.now()-r;i>5&&Wn.warn(`[${this.treeId}] Slow FlexSearch.add(): ${i.toFixed(2)}ms for index ${e.index}`)}}finishProcessing(){this.isProcessing=!1,Wn.info(`[${this.treeId}] Indexing complete. Processed ${this.totalItemsProcessed} items.`),this.onCompleteCallback&&this.onCompleteCallback()}getStatus(){return{queueSize:this.processingQueue.length,isProcessing:this.isProcessing,processed:this.totalItemsProcessed,total:this.totalItemsAdded,batchSize:this.batchSize}}clearQueue(){this.processingQueue=[],this.isProcessing=!1,this.totalItemsAdded=0,this.totalItemsProcessed=0,Wn.debug(`[${this.treeId}] Queue cleared`)}isBusy(){return this.isProcessing||this.processingQueue.length>0}async waitForCompletion(){return new Promise(e=>{if(!this.isBusy()){e();return}const n=this.onCompleteCallback;this.onCompleteCallback=()=>{n&&n(),e()}})}}const Cr=qt.getLogger("LTREE:PERF");let Ea=0;const Th="#a855f7",Mh={format(t,e,n){return`%c[${n}]%c %c[PERF]%c`},timestampFormatter(t){return t.toTimeString().split(" ")[0]+"."+t.getMilliseconds().toString().padStart(3,"0")}};function Eh(t){return function(e,n,r){const i=t(e,n,r);return function(...a){if(a.length>0&&typeof a[0]=="string"&&a[0].includes("%c")){const o=(a[0].match(/%c/g)||[]).length,l=[];for(let c=0;c<o;c++)l.push(c%2===0?`color: ${Th}; font-weight: bold;`:"color: inherit;");i(a[0],...l,...a.slice(1))}else i(...a)}}}const Ah=Cr.methodFactory;Cr.methodFactory=Eh(Ah);Oi.reg(qt);Oi.apply(Cr,Mh);Cr.setLevel("silent");const hs=new Map;function cr(t,e){hs.set(t,{start:performance.now(),metadata:e})}function Hn(t,e){const n=hs.get(t);if(!n)return Cr.warn(`Timer "${t}" not found`),0;const r=performance.now()-n.start;if(hs.delete(t),r<Ea)return r;let i=`${t}: ${qr(r)}`;if(e!==void 0&&e>0){const a=r/e,o=1e3/a;i+=` | ${e.toLocaleString()} items | ${qr(a)}/item | ${Oh(o)} items/sec`}return n.metadata&&(i+=` | ${JSON.stringify(n.metadata)}`),Cr.info(i),r}function Rh(t,e,n){const r=Object.values(e).reduce((a,o)=>a+o,0);if(r<Ea)return;let i=`[${t}] Performance Summary:
|
|
7
|
+
`;for(const[a,o]of Object.entries(e)){const l=(o/r*100).toFixed(1);i+=` ${a}: ${qr(o)} (${l}%)
|
|
8
|
+
`}i+=` TOTAL: ${qr(r)}`,n!==void 0&&(i+=` | ${n.toLocaleString()} items | ${qr(r/n)}/item`),Cr.info(i)}function qr(t){return t<1?`${(t*1e3).toFixed(2)}µs`:t<1e3?`${t.toFixed(2)}ms`:`${(t/1e3).toFixed(2)}s`}function Oh(t){return t.toLocaleString(void 0,{maximumFractionDigits:0})}function wt(t,e){return t[e]}function Lh(t,e,n,r,i,a,o,l,c,d,h,p,y,k,C,_,v,I,O,j,K,U,V,se,oe,ce,G,N){let W=kn(n),z=kn(r),X=kn(i),le=kn(a),ue=kn(o),Se=kn(l),ie=kn(c),de=kn(h),Ce=kn(p),xe=kn(I),tt=kn(y),_e=kn(C);const Z="x";let pe=Tr(),ve=Tr(),Ke=null;se&&(Ke=oe?oe():Ph());let Oe=L(Ut(Symbol())),je=0,Ge=0,et=[],$e=null,mt=!1,vt=[],Qe=null,Fe=null,nt=null,lt;return se&&Ke&&(Fe=new Ih(K||"unknown",Ke,_e,C,_,ce||25,G||50,N?.shouldDisplayDebugInformation??!1)),{treePathSeparator:U||".",root:pe,filteredRoot:ve,get changeTracker(){return s(Oe)},idMember:t,pathMember:e,parentPathMember:n,levelMember:r,isExpandedMember:a,isSelectableMember:o,isSelectedMember:l,isDraggableMember:c,getIsDraggableCallback:d,isDropAllowedMember:h,allowedDropPositionsMember:p,hasChildrenMember:i,displayValueMember:y,getDisplayValueCallback:k,searchValueMember:C,getSearchValueCallback:_,getAllowedDropPositionsCallback:v,isCollapsibleMember:I,getIsCollapsibleCallback:O,orderMember:j,isSorted:!1,shouldDisplayDebugInformation:N?.shouldDisplayDebugInformation??!1,filteredTree:$e,isFiltered:mt,get tree(){return this.isFiltered?Object.values(ve?.children)||[]:!pe?.children||!s(Oe)?[]:Object.values(pe.children)},get visibleFlatNodes(){const H=s(Oe);if(H===Qe&&vt.length>0)return vt;performance.now();const ne=this.isFiltered?ve:pe;if(!ne?.children||!H)return vt=[],Qe=H,vt;const F=[];function M(R){const Y=Object.values(R.children);for(const Q of Y)F.push(Q),Q.isExpanded&&Q.hasChildren&&M(Q)}return M(ne),vt=F,Qe=H,F},get statistics(){const ne=Fe?.getStatus()||{isProcessing:!1,queueSize:0};return s(Oe)&&{nodeCount:je,maxLevel:Ge,filteredNodeCount:0,isIndexing:ne.isProcessing,pendingIndexCount:ne.queueSize}},insertArray(H,ne=!1){H=H||[],Fe?.clearQueue(),et=[],pe.children={},je=0,Ge=0,cr(`[${K}] insertArray:conversion`);const F=[];let M=H.map((ae,Me)=>{const ke=Tr();ke.treeId=K||"",ke.id=t?wt(ae,t):void 0;const He=e?wt(ae,e):void 0;if(He==null||He===""||typeof He!="string"){ke.path="",ke.data=ae;const Xe=He===""?"empty string":He==null?"undefined/null":`non-string (${typeof He})`;return F.push({node:ke,originalData:ae,error:`Item at index ${Me} has invalid path (${Xe}). Check that pathMember="${e}" matches your data. First item keys: ${Me===0?JSON.stringify(Object.keys(ae)):"(see index 0)"}`}),null}return ke.path=He,W?ke.parentPath=na(ke.path,this.treePathSeparator):ke.parentPath=wt(ae,n),ke.pathSegment=Qi(Ji(ke.path,ke.parentPath??"",this.treePathSeparator),0,1,this.treePathSeparator),z?ke.level=Rr(ke.path,this.treePathSeparator):ke.level=wt(ae,r),le?V&&(ke.isExpanded=(ke.level??0)<=V):ke.isExpanded=wt(ae,a),ue||(ke.isSelectable=wt(ae,o)),Se||(ke.isSelected=wt(ae,l)),ie||(ke.isDraggable=wt(ae,c)),xe||(ke.isCollapsible=wt(ae,I)),de||(ke.isDropAllowed=wt(ae,h)),Ce||(ke.allowedDropPositions=wt(ae,p)),X||(ke.hasChildren=wt(ae,i)),ke.data=ae,ke}).filter(ae=>ae!==null);const R=Hn(`[${K}] insertArray:conversion`,H.length);cr(`[${K}] insertArray:sort`),this.isSorted||(this.sortCallback?M=this.sortCallback(M):M=this._defaultSort(this,M));const Y=Hn(`[${K}] insertArray:sort`,H.length);cr(`[${K}] insertArray:insert`);const Q=[...F];F.length>0&&console.warn(`[Tree ${K}] ${F.length} of ${H.length} items have invalid paths (pathMember="${e}"). These items will be skipped.
|
|
9
|
+
First failure: ${F[0].error}`);const Pe=[];let Ne=0,ge=0,ye=!1,A=-1;if(V&&!ne){for(let ae=M.length-1;ae>=0;ae--)if((M[ae].level||Rr(M[ae].path,this.treePathSeparator))<=V){A=ae;break}}if(M.forEach((ae,Me)=>{const ke=this.insertTreeNode(ae.parentPath??"",ae,!0);ke?Q.push({node:ae,originalData:H[Me],error:ke}):(ge++,se&&Fe&&(et.push(ae),Pe.push({node:ae,index:Ne}),Ne++),!ne&&!ye&&V&&Me===A&&(ye=!0,this._emitTreeChanged()))}),Q.length>0){const ae=Q.map(Me=>Me.error);console.warn(`[Tree ${K}] ${Q.length} nodes failed to insert:`,ae)}Pe.length>0&&Fe&&(Fe.setCallbacks(void 0,()=>{kn(nt)||this.filterNodes(nt,lt),ne||this._emitTreeChanged()}),Fe.addToQueue(Pe)),ne||this._emitTreeChanged();const re=Hn(`[${K}] insertArray:insert`,H.length);return Rh(K||"unknown",{Conversion:R,Sort:Y,Insert:re},H.length),{successful:ge,failed:Q,total:H.length}},insertTreeNode(H,ne,F){const M=this.getNodeByPath(H);if(!M)return`Node: ${ne.path} - Could not find parent node: ${H}`;z&&(ne.level=(M.level||0)+1);const R=Z+Qi(Ji(ne?.path,H,this.treePathSeparator),0,1,this.treePathSeparator);return M.children.hasOwnProperty(R)||(M.children[R]=ne,X&&!M.hasChildren&&(M.hasChildren=!0),je++,Ge=Math.max(Ge,ne.level||0)),F||this._emitTreeChanged(),null},filterNodes(H,ne){if(nt=H,lt=ne,kn(H)){ve.children={},this.isFiltered=!1,this._emitTreeChanged();return}if(!se)return;cr(`[${K}] filterNodes:search`);const F=Ke.search(H,ne),M=F.map(R=>et[R].path);Hn(`[${K}] filterNodes:search`,F.length),this.createFilteredTree(M)},searchNodes(H,ne){return kn(H)?[]:se?Ke.search(H,ne).map(R=>et[R]):[]},createFilteredTree(H){cr(`[${K}] createFilteredTree`),ve.children={},$e=null;const ne=new Set;H.forEach(R=>{const Y=R.split(this.treePathSeparator);for(let Q=1;Q<=Y.length;Q++)ne.add(Y.slice(0,Q).join(this.treePathSeparator))});const F=new Map;ne.forEach(R=>{const Y=this.getNodeByPath(R,pe);if(Y){const Q={...Y,children:{},hasChildren:!1,isExpanded:!0};F.set(R,Q)}}),ne.forEach(R=>{const Y=F.get(R);if(!Y)return;const Q=R.split(this.treePathSeparator);if(Q.length>1){const Pe=Q.slice(0,-1).join(this.treePathSeparator),Ne=F.get(Pe),ge=Z+Q[Q.length-1];Ne&&(Ne.children[ge]=Y,Ne.hasChildren=!0)}});const M=[];ne.forEach(R=>{if(!R.includes(this.treePathSeparator)){const Y=F.get(R);Y&&M.push(Y)}}),M.forEach(R=>{ve.children[Z+R.path]=R}),$e=M,this.isFiltered=!0,this._emitTreeChanged(),Hn(`[${K}] createFilteredTree`,M.length)},clearFilter(){ve.children={},$e=null,this.isFiltered=!1,this._emitTreeChanged()},expandAll(H){cr(`[${K}] expandAll`);function ne(F,M){F.isExpanded=M;for(const R in F.children)ne(F.children[R],M)}if(kn(H))ne(pe,!0);else{const F=this.getNodeByPath(H);F&&ne(F,!0)}this._emitTreeChanged(),Hn(`[${K}] expandAll`)},collapseAll(H){cr(`[${K}] collapseAll`);const ne=this;function F(M){M.isExpanded&&ne.getNodeIsCollapsible(M)&&(M.isExpanded=!1);for(const R in M.children)F(M.children[R])}if(kn(H))F(pe);else{const M=this.getNodeByPath(H);M&&F(M)}this._emitTreeChanged(),Hn(`[${K}] collapseAll`)},insert(H,ne,F=!1){let M=this.root;const R=H.split(this.treePathSeparator);for(let Y=0;Y<R.length;Y++){const Q=Z+R[Y];M.children.hasOwnProperty(Q)||(M.children[Q]=Tr()),M=M.children[Q]}M.hasChildren=!0,M.data=ne,F||this._emitTreeChanged()},expandNodes(H,ne=!1){cr(`[${K}] expandNodes`);let F=this.isFiltered?ve:pe,M=!1;const R=H.split(this.treePathSeparator);for(let Y=0;Y<R.length;Y++){const Q=Z+R[Y];F.children.hasOwnProperty(Q)&&(F=F.children[Q],F.isExpanded||(F.isExpanded=!0,M=!0))}return!ne&&M&&this._emitTreeChanged(),Hn(`[${K}] expandNodes`),this},collapseNodes(H,ne=!1){let F=this.isFiltered?ve:this.root,M=!1;const R=H.split(this.treePathSeparator);for(let Y=0;Y<R.length;Y++){const Q=Z+R[Y];F.children.hasOwnProperty(Q)&&(F=F.children[Q])}return F.isExpanded&&(F.isExpanded=!1,M=!0),!ne&&M&&this._emitTreeChanged(),this},getNodeByPath(H,ne){let F=ne||(this.isFiltered?ve:pe);if(H){const M=H.split(this.treePathSeparator);for(let R=0;R<M.length;R++){const Y=Z+M[R];if(!F.children.hasOwnProperty(Y))return null;F=F.children[Y]}}return F},getNodeDisplayValue(H){return!tt&&H.data?wt(H.data,y):this.getDisplayValueCallback?this.getDisplayValueCallback(H):"[N/A]"},getNodeSearchValue(H){return!_e&&H.data?wt(H.data,C):this.getSearchValueCallback?this.getSearchValueCallback(H):"[N/A]"},getNodeAllowedDropPositions(H){return this.getAllowedDropPositionsCallback?this.getAllowedDropPositionsCallback(H):!Ce&&H.data?wt(H.data,p):H.allowedDropPositions},getNodeIsDraggable(H){return this.getIsDraggableCallback?this.getIsDraggableCallback(H):!ie&&H.data?wt(H.data,c):H.isDraggable},getNodeIsCollapsible(H){return this.getIsCollapsibleCallback?this.getIsCollapsibleCallback(H):!xe&&H.data?wt(H.data,I):H.isCollapsible},refresh(){this._emitTreeChanged()},getChildren(H){const ne=s(Oe),F=this.getNodeByPath(H);return!F||!ne?[]:Object.values(F.children)},getSiblings(H){const ne=s(Oe),F=this.getNodeByPath(H);if(!F||!ne)return[];const M=F.parentPath||"";return this.getChildren(M)},refreshSiblings(H){const ne=H?this.getNodeByPath(H):pe;if(!ne)return;const F=Object.values(ne.children);if(F.length===0)return;let M;this.sortCallback?M=this.sortCallback(F):M=[...F].sort((Y,Q)=>{if(this.orderMember&&Y.data&&Q.data){const Pe=wt(Y.data,this.orderMember)??0,Ne=wt(Q.data,this.orderMember)??0;if(Pe!==Ne)return Pe-Ne}return this.getNodeDisplayValue(Y).localeCompare(this.getNodeDisplayValue(Q))});const R={};M.forEach(Y=>{const Q=Z+Y.pathSegment;R[Q]=Y}),ne.children=R,this._emitTreeChanged()},refreshNode(H){this._emitTreeChanged()},moveNode(H,ne,F){const M=this.getNodeByPath(H);if(!M)return{success:!1,error:`Source node not found: ${H}`};const R=this.getNodeByPath(ne);if(!R)return{success:!1,error:`Target node not found: ${ne}`};if(ne.startsWith(H+this.treePathSeparator)||ne===H)return{success:!1,error:"Cannot move a node into itself or its descendants"};const Y=M.parentPath||"",Q=Y?this.getNodeByPath(Y):pe;if(!Q)return{success:!1,error:`Source parent not found: ${Y}`};const Pe=Z+M.pathSegment;delete Q.children[Pe],Object.keys(Q.children).length===0&&(Q.hasChildren=!1,i&&Q.data&&(Q.data[i]=!1));let Ne,ge;F==="child"?(Ne=ne,ge=R):(Ne=R.parentPath||"",ge=Ne?this.getNodeByPath(Ne):pe);let ye=M.pathSegment;const A=ge.children[Z+ye];if(A&&A!==M){const Me=M.id?.toString();Me&&!ge.children[Z+Me]?ye=Me:ye=`${ye}_${Date.now()}`}const re=Ne?`${Ne}${this.treePathSeparator}${ye}`:ye,ae=M.path;if(M.path=re,M.pathSegment=ye,M.parentPath=Ne,M.level=Rr(re,this.treePathSeparator),M.data&&(e&&(M.data[e]=re),n&&(M.data[n]=Ne),r&&(M.data[r]=M.level)),this._updateDescendantPaths(M,ae,re),ge.children[Z+ye]=M,ge.hasChildren=!0,i&&ge.data&&(ge.data[i]=!0),this.orderMember&&F!=="child"&&M.data){const Me=this.orderMember,ke=Object.values(ge.children),He=(R.data?wt(R.data,Me):0)??0;if(F==="before"){const ut=ke.filter(T=>T!==M&&T.data&&wt(T.data,Me)!==void 0).map(T=>wt(T.data,Me)).filter(T=>T<He).sort((T,ee)=>ee-T)[0]??He-20;M.data[Me]=Math.floor((ut+He)/2)}else{const ut=ke.filter(T=>T!==M&&T.data&&wt(T.data,Me)!==void 0).map(T=>wt(T.data,Me)).filter(T=>T>He).sort((T,ee)=>T-ee)[0]??He+20;M.data[Me]=Math.floor((He+ut)/2)}}return this.refreshSiblings(Ne),{success:!0}},_updateDescendantPaths(H,ne,F){for(const M of Object.values(H.children)){const R=M.path,Y=R.substring(ne.length),Q=F+Y;M.path=Q,M.parentPath=H.path,M.level=Rr(Q,this.treePathSeparator),M.data&&(e&&(M.data[e]=Q),n&&(M.data[n]=H.path),r&&(M.data[r]=M.level)),this._updateDescendantPaths(M,R,Q)}},removeNode(H,ne=!0){const F=this.getNodeByPath(H);if(!F)return{success:!1,error:`Node not found: ${H}`};const M=F.parentPath||"",R=M?this.getNodeByPath(M):pe;if(!R)return{success:!1,error:`Parent not found: ${M}`};const Y=Z+F.pathSegment;if(delete R.children[Y],Object.keys(R.children).length===0&&(R.hasChildren=!1,i&&R.data&&(R.data[i]=!1)),ne){const Q=Pe=>{let Ne=1;for(const ge of Object.values(Pe.children))Ne+=Q(ge);return Ne};je-=Q(F)}else je--;return this._emitTreeChanged(),{success:!0,node:F}},addNode(H,ne,F){const M=H?this.getNodeByPath(H):pe;if(!M&&H)return{success:!1,error:`Parent not found: ${H}`};F||(F=(t&&ne?ne[t]:void 0)?.toString()||`new_${Date.now()}_${Math.random().toString(36).substr(2,9)}`);const R=F,Y=H?`${H}${this.treePathSeparator}${R}`:R;if(this.getNodeByPath(Y))return{success:!1,error:`Node already exists at path: ${Y}`};const Q=Tr();Q.treeId=K||"",Q.id=t&&ne?ne[t]:void 0,Q.path=Y,Q.pathSegment=R,Q.parentPath=H,Q.level=Rr(Y,this.treePathSeparator),Q.data=ne,Q.isExpanded=V?Q.level<=V:!1,Q.hasChildren=!1,ne&&(e&&(ne[e]=Y),n&&(ne[n]=H),r&&(ne[r]=Q.level),i&&(ne[i]=!1));const Pe=M||pe;return Pe.children[Z+F]=Q,Pe.hasChildren=!0,i&&Pe.data&&(Pe.data[i]=!0),je++,Ge=Math.max(Ge,Q.level||0),et.push(Q),this.refreshSiblings(H),this._emitTreeChanged(),{success:!0,node:Q}},updateNode(H,ne){const F=this.getNodeByPath(H);if(!F)return{success:!1,error:`Node not found: ${H}`};if(!F.data)return{success:!1,error:`Node has no data: ${H}`};const M=this.orderMember&&this.orderMember in ne;if(F.data={...F.data,...ne},F._rev=(F._rev||0)+1,Fe&&se){const R=et.indexOf(F);R!==-1&&Fe.addItem({node:F,index:R})}return M&&this.refreshSiblings(F.parentPath||""),this._emitTreeChanged(),{success:!0,node:F}},applyChanges(H){const ne=[];let F=0;for(let M=0;M<H.length;M++){const R=H[M];let Y;switch(R.operation){case"create":Y=this.addNode(R.parentPath,R.data,R.pathSegment),Y.success?F++:ne.push({index:M,operation:R.operation,path:R.parentPath,error:Y.error||"Unknown error"});break;case"update":Y=this.updateNode(R.path,R.data),Y.success?F++:ne.push({index:M,operation:R.operation,path:R.path,error:Y.error||"Unknown error"});break;case"delete":Y=this.removeNode(R.path),Y.success?F++:ne.push({index:M,operation:R.operation,path:R.path,error:Y.error||"Unknown error"});break}}return F>0&&this._emitTreeChanged(),{successful:F,failed:ne}},copyNodeWithDescendants(H,ne,F,M,R){if(!H.data)return{success:!1,count:0,error:"Source node has no data"};let Y=0;const Q=(Ne,ge)=>{if(!Ne.data)return null;const ye=F(Ne.data),A=this.addNode(ge,ye);if(!A.success||!A.node)return this.shouldDisplayDebugInformation&&console.warn(`[Tree ${K}] copyNodeWithDescendants: Failed to add node`,A.error),null;Y++;const re=A.node;if(Ne.children&&Object.keys(Ne.children).length>0)for(const ae of Object.values(Ne.children))Q(ae,re.path);return re},Pe=Q(H,ne);if(!Pe)return{success:!1,count:0,error:"Failed to copy root node"};if(M&&R&&Pe.data){const Ne=this.getNodeByPath(M);if(Ne&&this.orderMember){const ge=ne?this.getNodeByPath(ne):pe;if(ge){const ye=Object.values(ge.children),A=this.orderMember,re=Ne.data?.[A]??0;if(R==="before"){const Me=ye.filter(ke=>ke!==Pe&&ke.data?.[A]!==void 0).map(ke=>ke.data[A]).filter(ke=>ke<re).sort((ke,He)=>He-ke)[0]??re-20;Pe.data[A]=Math.floor((Me+re)/2)}else{const Me=ye.filter(ke=>ke!==Pe&&ke.data?.[A]!==void 0).map(ke=>ke.data[A]).filter(ke=>ke>re).sort((ke,He)=>ke-He)[0]??re+20;Pe.data[A]=Math.floor((re+Me)/2)}this.refreshSiblings(ne)}}}return{success:!0,rootNode:Pe,count:Y}},getExpandedPaths(){const H=[],ne=F=>{F.isExpanded&&F.path&&H.push(F.path);for(const M of Object.values(F.children))ne(M)};return ne(pe),H},setExpandedPaths(H){const ne=new Set(H),F=M=>{M.path&&(M.isExpanded=ne.has(M.path));for(const R of Object.values(M.children))F(R)};F(pe),this._emitTreeChanged()},getAllData(){const H=[],ne=F=>{F.data&&H.push(F.data);for(const M of Object.values(F.children))ne(M)};return ne(pe),H},insertBranch(H,ne){const F=H?this.getNodeByPath(H):pe;if(!F&&H)return{success:!1,count:0,failed:[],parentNode:null};const M=F||pe;if(ne.length===0)return{success:!0,count:0,failed:[],parentNode:M};const R=[];let Y=ne.map((ge,ye)=>{const A=Tr();A.treeId=K||"",A.id=t?wt(ge,t):void 0;const re=e?wt(ge,e):void 0;if(re==null||re===""||typeof re!="string"){const ae=re===""?"empty string":re==null?"undefined/null":`non-string (${typeof re})`;return R.push({data:ge,error:`Item at index ${ye} has invalid path (${ae})`}),null}return A.path=re,W?A.parentPath=na(A.path,this.treePathSeparator):A.parentPath=wt(ge,n),A.pathSegment=Qi(Ji(A.path,A.parentPath??"",this.treePathSeparator),0,1,this.treePathSeparator),z?A.level=Rr(A.path,this.treePathSeparator):A.level=wt(ge,r),le?V&&(A.isExpanded=(A.level??0)<=V):A.isExpanded=wt(ge,a),ue||(A.isSelectable=wt(ge,o)),Se||(A.isSelected=wt(ge,l)),ie||(A.isDraggable=wt(ge,c)),xe||(A.isCollapsible=wt(ge,I)),de||(A.isDropAllowed=wt(ge,h)),Ce||(A.allowedDropPositions=wt(ge,p)),X||(A.hasChildren=wt(ge,i)),A.data=ge,A}).filter(ge=>ge!==null);this.isSorted||(this.sortCallback?Y=this.sortCallback(Y):Y=this._defaultSort(this,Y));const Q=new Set;let Pe=0;for(const ge of Y){const ye=this.insertTreeNode(ge.parentPath??"",ge,!0);ye?R.push({data:ge.data,error:ye}):(Pe++,Q.add(ge.parentPath??""),se&&et.push(ge))}for(const ge of Q){const ye=ge?this.getNodeByPath(ge):pe;if(!ye)continue;const A=Object.values(ye.children);if(A.length===0)continue;let re;this.sortCallback?re=this.sortCallback(A):re=[...A].sort((Me,ke)=>{if(this.orderMember&&Me.data&&ke.data){const He=wt(Me.data,this.orderMember)??0,Xe=wt(ke.data,this.orderMember)??0;if(He!==Xe)return He-Xe}return this.getNodeDisplayValue(Me).localeCompare(this.getNodeDisplayValue(ke))});const ae={};re.forEach(Me=>{ae[Z+Me.pathSegment]=Me}),ye.children=ae}for(const ge of Q){const ye=ge?this.getNodeByPath(ge):pe;ye&&(ye.hasChildren=Object.keys(ye.children).length>0,i&&ye.data&&(ye.data[i]=ye.hasChildren))}const Ne=new Set;for(const ge of Q){let ye=ge;for(;ye&&!Ne.has(ye);){Ne.add(ye);const A=this.getNodeByPath(ye);A&&(A._rev=(A._rev||0)+1);const re=ye.lastIndexOf(this.treePathSeparator);ye=re>0?ye.substring(0,re):""}}if(se&&Fe){const ge=et.length-Pe,ye=[];for(let A=ge;A<et.length;A++)ye.push({node:et[A],index:A});ye.length>0&&Fe.addToQueue(ye)}return this._emitTreeChanged(),{success:!0,count:Pe,failed:R,parentNode:M}},replaceBranch(H,ne){const F=H?this.getNodeByPath(H):pe;if(!F&&H)return{success:!1,count:0,failed:[],parentNode:null};const M=F||pe,R=Q=>{let Pe=0;for(const Ne of Object.values(Q.children))Pe+=1+R(Ne);return Pe},Y=R(M);if(Y>0){const Q=(Ne,ge)=>{for(const ye of Object.values(Ne.children))ge.add(ye.path),Q(ye,ge)},Pe=new Set;Q(M,Pe),et=et.filter(Ne=>!Pe.has(Ne.path))}return M.children={},M.hasChildren=!1,i&&M.data&&(M.data[i]=!1),je-=Y,this.insertBranch(H,ne)},deleteBranch(H,ne=!1){const F=R=>{let Y=0;for(const Q of Object.values(R.children))Y+=1+F(Q);return Y},M=(R,Y)=>{for(const Q of Object.values(R.children))Y.add(Q.path),M(Q,Y)};if(ne){const R=H?this.getNodeByPath(H):pe;if(!R&&H)return{success:!1,removedCount:0,error:`Node not found: ${H}`};const Y=R||pe,Q=F(Y);if(Q===0)return{success:!0,removedCount:0};const Pe=new Set;M(Y,Pe),et=et.filter(ge=>!Pe.has(ge.path)),Y.children={},Y.hasChildren=!1,i&&Y.data&&(Y.data[i]=!1),je-=Q,Y._rev=(Y._rev||0)+1;let Ne=H;for(;Ne;){const ge=Ne.lastIndexOf(this.treePathSeparator);if(Ne=ge>0?Ne.substring(0,ge):"",Ne){const ye=this.getNodeByPath(Ne);ye&&(ye._rev=(ye._rev||0)+1)}}return this._emitTreeChanged(),{success:!0,removedCount:Q}}else{if(H==="")return{success:!1,removedCount:0,error:"Cannot delete root node"};const R=this.getNodeByPath(H);if(!R)return{success:!1,removedCount:0,error:`Node not found: ${H}`};const Y=R.parentPath||"",Q=Y?this.getNodeByPath(Y):pe;if(!Q)return{success:!1,removedCount:0,error:`Parent not found: ${Y}`};const Pe=1+F(R),Ne=new Set;Ne.add(R.path),M(R,Ne),et=et.filter(A=>!Ne.has(A.path));const ge=Z+R.pathSegment;delete Q.children[ge],Object.keys(Q.children).length===0&&(Q.hasChildren=!1,i&&Q.data&&(Q.data[i]=!1)),je-=Pe;let ye=Y;for(;ye;){const A=this.getNodeByPath(ye);A&&(A._rev=(A._rev||0)+1);const re=ye.lastIndexOf(this.treePathSeparator);ye=re>0?ye.substring(0,re):""}return this._emitTreeChanged(),{success:!0,removedCount:Pe}}},_defaultSort(H,ne){return ne.sort((F,M)=>{const R=F.level||0,Y=M.level||0;if(R!==Y)return R-Y;if(F.parentPath!==M.parentPath)return F.parentPath?M.parentPath?F.parentPath.localeCompare(M.parentPath):1:-1;if(H.orderMember&&F.data&&M.data){const Q=F.data[H.orderMember]??0,Pe=M.data[H.orderMember]??0;if(Q!==Pe)return Q-Pe}return H.getNodeDisplayValue(F).localeCompare(H.getNodeDisplayValue(M))})},_emitTreeChanged(){u(Oe,Symbol(),!0)},...N}}function Hh(t=100,e){const n=new Map,r=new Set;let i=null,a=!1,o=0,l=!1;function c(){i!==null||n.size===0||(i=requestAnimationFrame(()=>{i=null,d()}))}function d(){const h=performance.now();if(n.size===0){l&&(a=!1,l=!1,e?.onComplete?.({pending:0,processed:o}));return}l||(l=!0,o=0,e?.onStart?.()),a=!0;let p=t;const y=[];Ci.trace(`Frame start: pending=${n.size}, budget=${p}`);for(const[C,_]of n){if(p<=0)break;const v=performance.now(),I=_(),O=performance.now()-v;O>10&&Ci.warn(`Slow callback: ${C} took ${O.toFixed(2)}ms`),p--,o++,I||y.push(C)}for(const C of y)n.delete(C),r.add(C);const k=performance.now()-h;Ci.trace(`Frame end: processed ${t-p} nodes in ${k.toFixed(2)}ms`),e?.onProgress?.({pending:n.size,processed:o}),n.size>0?c():(a=!1,l=!1,e?.onComplete?.({pending:0,processed:o}))}return{register(h,p){return r.has(h)?()=>{}:(n.set(h,p),c(),()=>{n.delete(h)})},isActive(){return a||n.size>0},getStats(){return{pending:n.size,processed:o}},isCompleted(h){return r.has(h)},reset(){r.clear(),n.clear(),i!==null&&(cancelAnimationFrame(i),i=null),a=!1,l=!1,o=0}}}let ci=null;function ra(t){ci=t}function zh(){return ci}function qi(){ci=null}function Fh(){return ci!==null}function ia(){return ci?.operation??null}class Bh{tree;renderCoordinator;nodeCallbacks;#e=L(Ut({clickBehavior:"expand-and-focus",showCheckboxes:!1,checkboxMode:"independent",expandIconClass:"ltree-icon-expand",collapseIconClass:"ltree-icon-collapse",leafIconClass:"ltree-icon-leaf",highlightedNodeClass:void 0,focusedNodeClass:void 0,dragOverNodeClass:void 0,dropZoneMode:"glow",dropZoneLayout:"around",dropZoneStart:33,toggleIconMode:"rotate",dropZoneMaxWidth:120,allowCopy:!1,accordionExpand:!1}));get nodeConfig(){return s(this.#e)}set nodeConfig(e){u(this.#e,e,!0)}#t=L("");get treeId(){return s(this.#t)}set treeId(e){u(this.#t,e,!0)}#n=L(".");get treePathSeparator(){return s(this.#n)}set treePathSeparator(e){u(this.#n,e,!0)}#r=L([]);get data(){return s(this.#r)}set data(e){u(this.#r,e)}#i=L(null);get focusedNode(){return s(this.#i)}set focusedNode(e){u(this.#i,e)}#s=L(new Set);get highlightedPaths(){return s(this.#s)}set highlightedPaths(e){u(this.#s,e)}lastHighlightedPath=null;#a=L(new Set);get selectedPaths(){return s(this.#a)}set selectedPaths(e){u(this.#a,e)}#o=L(null);get insertResult(){return s(this.#o)}set insertResult(e){u(this.#o,e)}#l=L(void 0);get searchText(){return s(this.#l)}set searchText(e){u(this.#l,e,!0)}#c=L(!1);get isRendering(){return s(this.#c)}set isRendering(e){u(this.#c,e,!0)}#d=L(!1);get shouldDisplayDebugInformation(){return s(this.#d)}set shouldDisplayDebugInformation(e){u(this.#d,e,!0)}#h=L(!1);get shouldDisplayContextMenuInDebugMode(){return s(this.#h)}set shouldDisplayContextMenuInDebugMode(e){u(this.#h,e,!0)}#u=L("visual");get rangeSelectionMode(){return s(this.#u)}set rangeSelectionMode(e){u(this.#u,e,!0)}#f=L(!1);get isLoading(){return s(this.#f)}set isLoading(e){u(this.#f,e,!0)}#g=L(!0);get useFlatRendering(){return s(this.#g)}set useFlatRendering(e){u(this.#g,e,!0)}#v=L(!0);get progressiveRender(){return s(this.#v)}set progressiveRender(e){u(this.#v,e,!0)}#p=L(20);get initialBatchSize(){return s(this.#p)}set initialBatchSize(e){u(this.#p,e,!0)}#y=L(500);get maxBatchSize(){return s(this.#y)}set maxBatchSize(e){u(this.#y,e,!0)}#m=L(void 0);get bodyClass(){return s(this.#m)}set bodyClass(e){u(this.#m,e,!0)}#_=L("none");get dragDropMode(){return s(this.#_)}set dragDropMode(e){u(this.#_,e,!0)}#b=L(!1);get allowCopy(){return s(this.#b)}set allowCopy(e){u(this.#b,e,!0)}#k=L(!1);get accordionExpand(){return s(this.#k)}set accordionExpand(e){u(this.#k,e,!0)}#w=L(!0);get autoHandleCopy(){return s(this.#w)}set autoHandleCopy(e){u(this.#w,e,!0)}#x=L(!0);get autoHandleMove(){return s(this.#x)}set autoHandleMove(e){u(this.#x,e,!0)}#C=L(!0);get autoHandlePaste(){return s(this.#C)}set autoHandlePaste(e){u(this.#C,e,!0)}onNodeClickHandler;onHighlightChangeHandler;onSelectionChangeHandler;onNodeDragStartHandler;onNodeDragOverHandler;onNodeDropHandler;onPasteHandler;onRenderStartHandler;onRenderProgressHandler;onRenderCompleteHandler;beforeDropHandler;beforeCopyHandler;beforeCutHandler;beforePasteHandler;beforeCheckboxToggleHandler;getContextMenuItemsHandler;#S=L("expand-and-focus");get clickBehavior(){return s(this.#S)}set clickBehavior(e){u(this.#S,e,!0)}#N=L(!1);get showCheckboxes(){return s(this.#N)}set showCheckboxes(e){u(this.#N,e,!0)}#D=L("independent");get checkboxMode(){return s(this.#D)}set checkboxMode(e){u(this.#D,e,!0)}#P=L("ltree-icon-expand");get expandIconClass(){return s(this.#P)}set expandIconClass(e){u(this.#P,e,!0)}#I=L("ltree-icon-collapse");get collapseIconClass(){return s(this.#I)}set collapseIconClass(e){u(this.#I,e,!0)}#T=L("ltree-icon-leaf");get leafIconClass(){return s(this.#T)}set leafIconClass(e){u(this.#T,e,!0)}#M=L("rotate");get toggleIconMode(){return s(this.#M)}set toggleIconMode(e){u(this.#M,e,!0)}#E=L(void 0);get highlightedNodeClass(){return s(this.#E)}set highlightedNodeClass(e){u(this.#E,e,!0)}#A=L(void 0);get focusedNodeClass(){return s(this.#A)}set focusedNodeClass(e){u(this.#A,e,!0)}#R=L(void 0);get dragOverNodeClass(){return s(this.#R)}set dragOverNodeClass(e){u(this.#R,e,!0)}#O=L("glow");get dropZoneMode(){return s(this.#O)}set dropZoneMode(e){u(this.#O,e,!0)}#L=L("around");get dropZoneLayout(){return s(this.#L)}set dropZoneLayout(e){u(this.#L,e,!0)}#H=L(33);get dropZoneStart(){return s(this.#H)}set dropZoneStart(e){u(this.#H,e,!0)}#z=L(120);get dropZoneMaxWidth(){return s(this.#z)}set dropZoneMaxWidth(e){u(this.#z,e,!0)}#F=L(4e3);get scrollHighlightTimeout(){return s(this.#F)}set scrollHighlightTimeout(e){u(this.#F,e,!0)}#B=L("ltree-scroll-highlight");get scrollHighlightClass(){return s(this.#B)}set scrollHighlightClass(e){u(this.#B,e,!0)}#j=L(8);get contextMenuXOffset(){return s(this.#j)}set contextMenuXOffset(e){u(this.#j,e,!0)}#V=L(0);get contextMenuYOffset(){return s(this.#V)}set contextMenuYOffset(e){u(this.#V,e,!0)}#K=L(!1);get hasContextMenuSnippet(){return s(this.#K)}set hasContextMenuSnippet(e){u(this.#K,e,!0)}#$=L(!1);get virtualScroll(){return s(this.#$)}set virtualScroll(e){u(this.#$,e,!0)}#Z=L(void 0);get virtualRowHeight(){return s(this.#Z)}set virtualRowHeight(e){u(this.#Z,e,!0)}#U=L(5);get virtualOverscan(){return s(this.#U)}set virtualOverscan(e){u(this.#U,e,!0)}#W=L(void 0);get virtualContainerHeight(){return s(this.#W)}set virtualContainerHeight(e){u(this.#W,e,!0)}navigation;#G=L(!1);get contextMenuVisible(){return s(this.#G)}set contextMenuVisible(e){u(this.#G,e,!0)}#Y=L(0);get contextMenuX(){return s(this.#Y)}set contextMenuX(e){u(this.#Y,e,!0)}#X=L(0);get contextMenuY(){return s(this.#X)}set contextMenuY(e){u(this.#X,e,!0)}#J=L(null);get contextMenuNode(){return s(this.#J)}set contextMenuNode(e){u(this.#J,e)}#Q=L(!1);get isDebugMenuActive(){return s(this.#Q)}set isDebugMenuActive(e){u(this.#Q,e,!0)}currentHighlight=null;#q=L(null);get draggedNode(){return s(this.#q)}set draggedNode(e){u(this.#q,e)}#ee=L(!1);get isDragInProgress(){return s(this.#ee)}set isDragInProgress(e){u(this.#ee,e,!0)}#te=L(null);get hoveredNodeForDrop(){return s(this.#te)}set hoveredNodeForDrop(e){u(this.#te,e)}#ne=L(null);get activeDropPosition(){return s(this.#ne)}set activeDropPosition(e){u(this.#ne,e,!0)}#re=L("move");get currentDropOperation(){return s(this.#re)}set currentDropOperation(e){u(this.#re,e,!0)}#ie=L(null);get floatingZoneRect(){return s(this.#ie)}set floatingZoneRect(e){u(this.#ie,e,!0)}#se=L(null);get floatingHoveredZone(){return s(this.#se)}set floatingHoveredZone(e){u(this.#se,e,!0)}#ae=L({node:null,startX:0,startY:0,isDragging:!1,ghostElement:null,currentDropTarget:null});get touchDragState(){return s(this.#ae)}set touchDragState(e){u(this.#ae,e)}touchTimer=null;#oe=L(new Set);get flatRenderedIds(){return s(this.#oe)}set flatRenderedIds(e){u(this.#oe,e)}#le=L([]);get flatRenderQueue(){return s(this.#le)}set flatRenderQueue(e){u(this.#le,e)}flatRenderAnimationFrame=null;currentBatchSize=0;#ce=L(0);get vsScrollTop(){return s(this.#ce)}set vsScrollTop(e){u(this.#ce,e,!0)}#de=L(null);get vsMeasuredRowHeight(){return s(this.#de)}set vsMeasuredRowHeight(e){u(this.#de,e,!0)}#he=L();get vsContainerRef(){return s(this.#he)}set vsContainerRef(e){u(this.#he,e,!0)}#ue=L(null);get vsDetectedHeight(){return s(this.#ue)}set vsDetectedHeight(e){u(this.#ue,e,!0)}vsRafPending=!1;#fe=L(!1);get isDropPlaceholderActive(){return s(this.#fe)}set isDropPlaceholderActive(e){u(this.#fe,e,!0)}#ge=L(new Set);get cutPaths(){return s(this.#ge)}set cutPaths(e){u(this.#ge,e)}_skipInsertArray=!1;lastFlatNodesTracker=null;containerElement=null;#ve=me(()=>this.virtualRowHeight??this.vsMeasuredRowHeight??32);get vsRowHeight(){return s(this.#ve)}set vsRowHeight(e){u(this.#ve,e)}#pe=me(()=>this.virtualScroll&&this.useFlatRendering);get vsActive(){return s(this.#pe)}set vsActive(e){u(this.#pe,e)}#ye=me(()=>this.virtualContainerHeight??this.vsDetectedHeight??"400px");get vsContainerStyle(){return s(this.#ye)}set vsContainerStyle(e){u(this.#ye,e)}#me=me(()=>this.tree?.visibleFlatNodes??[]);get allFlatNodes(){return s(this.#me)}set allFlatNodes(e){u(this.#me,e)}#_e=me(()=>this.allFlatNodes.length);get vsTotalCount(){return s(this.#_e)}set vsTotalCount(e){u(this.#_e,e)}#be=me(()=>this.vsTotalCount*this.vsRowHeight);get vsTotalHeight(){return s(this.#be)}set vsTotalHeight(e){u(this.#be,e)}#ke=me(()=>this.vsActive?Math.max(0,Math.floor(this.vsScrollTop/this.vsRowHeight)-this.virtualOverscan):0);get vsStartIndex(){return s(this.#ke)}set vsStartIndex(e){u(this.#ke,e)}#we=me(()=>this.vsActive?Math.min(this.vsTotalCount,Math.ceil((this.vsScrollTop+(this.vsContainerRef?.clientHeight??0))/this.vsRowHeight)+this.virtualOverscan):this.vsTotalCount);get vsEndIndex(){return s(this.#we)}set vsEndIndex(e){u(this.#we,e)}#xe=me(()=>this.vsStartIndex*this.vsRowHeight);get vsOffsetY(){return s(this.#xe)}set vsOffsetY(e){u(this.#xe,e)}#Ce=me(()=>this.vsActive?this.allFlatNodes.slice(this.vsStartIndex,this.vsEndIndex):this.useFlatRendering&&this.progressiveRender?this.tree?.visibleFlatNodes?.filter(e=>this.flatRenderedIds.has(String(e.id)))??[]:this.tree?.visibleFlatNodes??[]);get flatNodesToRender(){return s(this.#Ce)}set flatNodesToRender(e){u(this.#Ce,e)}get statistics(){return this.tree?.statistics}constructor(e){this.treeId=e.treeId||this.generateTreeId(),this.treePathSeparator=e.treePathSeparator??".",this.data=e.data,this.focusedNode=e.focusedNode??null,this.highlightedPaths=e.highlightedPaths??new Set,this.selectedPaths=e.selectedPaths??new Set,this.searchText=e.searchText,this.shouldDisplayDebugInformation=e.shouldDisplayDebugInformation??!1,this.shouldDisplayContextMenuInDebugMode=e.shouldDisplayContextMenuInDebugMode??!1,this.rangeSelectionMode=e.rangeSelectionMode??"visual",this.isLoading=e.isLoading??!1,this.useFlatRendering=e.useFlatRendering??!0,this.progressiveRender=e.progressiveRender??!0,this.initialBatchSize=e.initialBatchSize??20,this.maxBatchSize=e.maxBatchSize??500,this.bodyClass=e.bodyClass,this.dragDropMode=e.dragDropMode??"none",this.allowCopy=e.allowCopy??!1,this.autoHandleCopy=e.autoHandleCopy??!0,this.autoHandleMove=e.autoHandleMove??!0,this.autoHandlePaste=e.autoHandlePaste??!0,this.accordionExpand=e.accordionExpand??!1,this.clickBehavior=e.clickBehavior??"expand-and-focus",this.showCheckboxes=e.showCheckboxes??!1,this.checkboxMode=e.checkboxMode??"independent",this.beforeCheckboxToggleHandler=e.beforeCheckboxToggleCallback,this.expandIconClass=e.expandIconClass??"ltree-icon-expand",this.collapseIconClass=e.collapseIconClass??"ltree-icon-collapse",this.leafIconClass=e.leafIconClass??"ltree-icon-leaf",this.toggleIconMode=e.toggleIconMode??"rotate",this.highlightedNodeClass=e.highlightedNodeClass,this.focusedNodeClass=e.focusedNodeClass,this.dragOverNodeClass=e.dragOverNodeClass,this.dropZoneMode=e.dropZoneMode??"glow",this.dropZoneLayout=e.dropZoneLayout??"around",this.dropZoneStart=e.dropZoneStart??33,this.dropZoneMaxWidth=e.dropZoneMaxWidth??120,this.scrollHighlightTimeout=e.scrollHighlightTimeout??4e3,this.scrollHighlightClass=e.scrollHighlightClass??"ltree-scroll-highlight",this.contextMenuXOffset=e.contextMenuXOffset??8,this.contextMenuYOffset=e.contextMenuYOffset??0,this.hasContextMenuSnippet=e.hasContextMenuSnippet??!1,this.virtualScroll=e.virtualScroll??!1,this.virtualRowHeight=e.virtualRowHeight,this.virtualOverscan=e.virtualOverscan??5,this.virtualContainerHeight=e.virtualContainerHeight,this.onNodeClickHandler=e.onNodeClick,this.onHighlightChangeHandler=e.onHighlightChange,this.onSelectionChangeHandler=e.onSelectionChange,this.onNodeDragStartHandler=e.onNodeDragStart,this.onNodeDragOverHandler=e.onNodeDragOver,this.onNodeDropHandler=e.onNodeDrop,this.onPasteHandler=e.onPaste,this.beforeDropHandler=e.beforeDropCallback,this.beforeCopyHandler=e.beforeCopyCallback,this.beforeCutHandler=e.beforeCutCallback,this.beforePasteHandler=e.beforePasteCallback,this.getContextMenuItemsHandler=e.getContextMenuItemsCallback,this.onRenderStartHandler=e.onRenderStart,this.onRenderProgressHandler=e.onRenderProgress,this.onRenderCompleteHandler=e.onRenderComplete,this.tree=Lh(e.idMember,e.pathMember,e.parentPathMember,e.levelMember,e.hasChildrenMember,e.isExpandedMember,e.isSelectableMember,e.isSelectedMember,e.isDraggableMember,e.getIsDraggableCallback,e.isDropAllowedMember,e.allowedDropPositionsMember,e.displayValueMember,e.getDisplayValueCallback,e.searchValueMember,e.getSearchValueCallback,e.getAllowedDropPositionsCallback,e.isCollapsibleMember,e.getIsCollapsibleCallback,e.orderMember,this.treeId,this.treePathSeparator,e.expandLevel,e.shouldUseInternalSearchIndex,e.initializeIndexCallback,e.indexerBatchSize,e.indexerTimeout,{shouldDisplayDebugInformation:e.shouldDisplayDebugInformation,isSorted:e.isSorted,sortCallback:e.sortCallback}),this.renderCoordinator=this.progressiveRender?Hh(2,{onStart:()=>{this.isRendering=!0,this.onRenderStartHandler?.()},onProgress:n=>{this.onRenderProgressHandler?.(n)},onComplete:n=>{this.isRendering=!1,this.onRenderCompleteHandler?.(n)}}):null,this.nodeCallbacks={onNodeClicked:(n,r)=>this._onNodeClicked(n,r),onCheckboxToggle:n=>this._onCheckboxToggle(n),onNodeRightClicked:this._onNodeRightClicked.bind(this),onNodeDragStart:this._onNodeDragStart.bind(this),onNodeDragOver:this._onNodeDragOver.bind(this),onNodeDragLeave:this._onNodeDragLeave.bind(this),onNodeDrop:this._onNodeDrop.bind(this),onZoneDrop:this._onZoneDrop.bind(this),onTouchDragStart:this._onTouchStart.bind(this),onTouchDragMove:this._onTouchMove.bind(this),onTouchDragEnd:this._onTouchEnd.bind(this)},this.nodeConfig={clickBehavior:this.clickBehavior,showCheckboxes:this.showCheckboxes,checkboxMode:this.checkboxMode,expandIconClass:this.expandIconClass,collapseIconClass:this.collapseIconClass,leafIconClass:this.leafIconClass,toggleIconMode:this.toggleIconMode,highlightedNodeClass:this.highlightedNodeClass,focusedNodeClass:this.focusedNodeClass,dragOverNodeClass:this.dragOverNodeClass,dropZoneMode:this.dropZoneMode,dropZoneLayout:this.dropZoneLayout,dropZoneStart:this.dropZoneStart,dropZoneMaxWidth:this.dropZoneMaxWidth,allowCopy:this.allowCopy,accordionExpand:this.accordionExpand},this.navigation=this.createDefaultNavigation(),De(()=>{this.tree.treePathSeparator=this.treePathSeparator}),De(()=>{Object.assign(this.nodeConfig,{clickBehavior:this.clickBehavior,showCheckboxes:this.showCheckboxes,expandIconClass:this.expandIconClass,collapseIconClass:this.collapseIconClass,leafIconClass:this.leafIconClass,toggleIconMode:this.toggleIconMode,highlightedNodeClass:this.highlightedNodeClass,focusedNodeClass:this.focusedNodeClass,dragOverNodeClass:this.dragOverNodeClass,dropZoneMode:this.dropZoneMode,dropZoneLayout:this.dropZoneLayout,dropZoneStart:this.dropZoneStart,dropZoneMaxWidth:this.dropZoneMaxWidth,allowCopy:this.allowCopy,accordionExpand:this.accordionExpand})}),De(()=>{this.tree.filterNodes(this.searchText)}),De(()=>{if(this.tree&&this.data){if(this._skipInsertArray){this._skipInsertArray=!1;return}if(this.renderCoordinator?.reset(),this.flatRenderedIds=new Set,this.flatRenderQueue=[],this.currentBatchSize=0,this.vsMeasuredRowHeight=null,this.vsDetectedHeight=null,this.insertResult=this.tree.insertArray(this.data),this.tree.isSelectedMember){const n=new Set,r=i=>{i.isSelected&&n.add(i.path);for(const a in i.children)r(i.children[a])};for(const i in this.tree.root.children)r(this.tree.root.children[i]);this.selectedPaths=n}}}),De(()=>{if(!this.useFlatRendering||!this.progressiveRender||!this.tree?.visibleFlatNodes)return;const n=this.tree.changeTracker;if(n===this.lastFlatNodesTracker)return;this.lastFlatNodesTracker=n;const r=this.tree.visibleFlatNodes,i=new Set(r.map(d=>String(d.id))),a=new Set(this.flatRenderedIds),o=new Set(this.flatRenderQueue),l=[];for(const d of r){const h=String(d.id);!a.has(h)&&!o.has(h)&&l.push(h)}const c=[];for(const d of a)i.has(d)||c.push(d);if(c.length>0){const d=new Set(a);for(const h of c)d.delete(h);this.flatRenderedIds=d}if(l.length>0){const d=a.size>1e3,h=l.length<200;if(d&&h)this.flatRenderedIds=new Set([...this.flatRenderedIds,...l]);else{this.currentBatchSize=this.initialBatchSize;const p=l.slice(0,this.currentBatchSize),y=l.slice(this.currentBatchSize);p.length>0&&(this.flatRenderedIds=new Set([...this.flatRenderedIds,...p])),this.currentBatchSize=Math.min(this.currentBatchSize*2,this.maxBatchSize),y.length>0&&(this.flatRenderQueue=[...y],this.scheduleFlatRenderBatch())}}}),De(()=>{!this.vsActive||this.virtualRowHeight||this.vsMeasuredRowHeight||this.allFlatNodes.length!==0&&yn().then(()=>{if(this.vsContainerRef){const n=this.vsContainerRef.querySelector(".ltree-node");if(n){const r=n.getBoundingClientRect().height;r>0&&(this.vsMeasuredRowHeight=r)}}})}),De(()=>{!this.vsActive||this.virtualContainerHeight||this.vsDetectedHeight||yn().then(()=>{if(this.vsContainerRef?.parentElement){const n=this.vsContainerRef.parentElement.clientHeight;n>100&&(this.vsDetectedHeight=n+"px")}})}),De(()=>{if(this.contextMenuVisible){const n=i=>{i.target.closest(".ltree-context-menu")||this.closeContextMenu()},r=()=>{this.closeContextMenu()};return document.addEventListener("click",n),document.addEventListener("contextmenu",n),window.addEventListener("scroll",r,!0),document.addEventListener("scroll",r,!0),window.addEventListener("wheel",r,{passive:!0}),()=>{document.removeEventListener("click",n),document.removeEventListener("contextmenu",n),window.removeEventListener("scroll",r,!0),document.removeEventListener("scroll",r,!0),window.removeEventListener("wheel",r)}}}),De(()=>{if(this.shouldDisplayContextMenuInDebugMode&&(this.hasContextMenuSnippet||this.getContextMenuItemsHandler)&&this.tree?.tree&&this.tree.tree.length>0){const n=this.tree.tree.length>1?this.tree.tree[1]:this.tree.tree[0];if(n&&this.containerElement){const r=this.containerElement.getBoundingClientRect();this.contextMenuNode=n,this.contextMenuX=r.left+200,this.contextMenuY=r.top+100,this.contextMenuVisible=!0,this.isDebugMenuActive=!0}}else!this.shouldDisplayContextMenuInDebugMode&&this.isDebugMenuActive&&(this.contextMenuVisible=!1,this.contextMenuNode=null,this.isDebugMenuActive=!1)})}handleVirtualScroll=e=>{this.vsRafPending||(this.vsRafPending=!0,requestAnimationFrame(()=>{this.vsScrollTop=e.target.scrollTop,this.vsRafPending=!1}))};async expandNodes(e){this.tree.expandNodes(e)}async collapseNodes(e){this.tree.collapseNodes(e)}expandAll(e){this.tree?.expandAll(e)}collapseAll(e){this.tree?.collapseAll(e)}filterNodes(e,n){this.tree?.filterNodes(e,n)}searchNodes(e,n){return this.tree?.searchNodes(e,n)||[]}getChildren(e){return this.tree?.getChildren(e)||[]}getSiblings(e){return this.tree?.getSiblings(e)||[]}refreshSiblings(e){this.tree?.refreshSiblings(e)}refreshNode(e){this.tree?.refreshNode(e)}getNodeByPath(e){return this.tree?.getNodeByPath(e)||null}moveNode(e,n,r){this._skipInsertArray=!0;const i=this.tree?.moveNode(e,n,r)||{success:!1,error:"Tree not initialized"};return yn().then(()=>{this._skipInsertArray=!1}),i}removeNode(e,n=!0){this._skipInsertArray=!0;const r=this.tree?.removeNode(e,n)||{success:!1,error:"Tree not initialized"};return yn().then(()=>{this._skipInsertArray=!1}),r}addNode(e,n,r){this._skipInsertArray=!0;const i=this.tree?.addNode(e,n,r)||{success:!1,error:"Tree not initialized"};return yn().then(()=>{this._skipInsertArray=!1}),i}updateNode(e,n){this._skipInsertArray=!0;const r=this.tree?.updateNode(e,n)||{success:!1,error:"Tree not initialized"};return yn().then(()=>{this._skipInsertArray=!1}),r}applyChanges(e){this._skipInsertArray=!0;const n=this.tree?.applyChanges(e)||{successful:0,failed:[]};return yn().then(()=>{this._skipInsertArray=!1}),n}copyNodeWithDescendants(e,n,r,i,a){this._skipInsertArray=!0;const o=this.tree?.copyNodeWithDescendants(e,n,r,i,a)||{success:!1,count:0,error:"Tree not initialized"};return yn().then(()=>{this._skipInsertArray=!1}),o}insertBranch(e,n){this._skipInsertArray=!0;const r=this.tree?.insertBranch(e,n)||{success:!1,count:0,failed:[],parentNode:null};return yn().then(()=>{this._skipInsertArray=!1}),r}replaceBranch(e,n){this._skipInsertArray=!0;const r=this.tree?.replaceBranch(e,n)||{success:!1,count:0,failed:[],parentNode:null};return yn().then(()=>{this._skipInsertArray=!1}),r}deleteBranch(e,n){this._skipInsertArray=!0;const r=this.tree?.deleteBranch(e,n)||{success:!1,removedCount:0,error:"Tree not initialized"};return yn().then(()=>{this._skipInsertArray=!1}),r}_collectClipboardEntry(e){const n=[];this.treePathSeparator;const r=i=>{for(const a of Object.values(i.children)){const o=a.path.substring(e.path.length);n.push({relativePath:o,data:structuredClone(a.data)}),r(a)}};return r(e),{sourceTreeId:this.treeId,sourcePath:e.path,data:structuredClone(e.data),descendants:n}}copyNodes(e){let n=e??[...this.highlightedPaths];if(n.length===0)return;if(this.beforeCopyHandler){const i=this.beforeCopyHandler(n);if(i===!1)return;Array.isArray(i)&&(n=i)}const r=[];for(const i of n){const a=this.tree.getNodeByPath(i);a&&r.push(this._collectClipboardEntry(a))}r.length!==0&&(this.cutPaths=new Set,ra({operation:"copy",entries:r,sourceTreeId:this.treeId}),Nn.debug(`[clipboard] Copied ${r.length} node(s)`))}cutNodes(e){let n=e??[...this.highlightedPaths];if(n.length===0)return;if(this.beforeCutHandler){const a=this.beforeCutHandler(n);if(a===!1)return;Array.isArray(a)&&(n=a)}const r=[],i=new Set;for(const a of n){const o=this.tree.getNodeByPath(a);if(o){r.push(this._collectClipboardEntry(o)),i.add(a);const l=c=>{for(const d of Object.values(c.children))i.add(d.path),l(d)};l(o)}}r.length!==0&&(ra({operation:"cut",entries:r,sourceTreeId:this.treeId}),this.cutPaths=i,Nn.debug(`[clipboard] Cut ${r.length} node(s), dimming ${i.size} paths`))}pasteNodes(e,n,r="child"){const i=zh();if(!i||i.entries.length===0)return{success:!1,count:0,error:"Clipboard is empty"};if(this.beforePasteHandler){const h=this.beforePasteHandler(e,i.operation,i.entries);if(h===!1)return{success:!1,count:0,error:"Paste blocked by beforePasteCallback"};h&&typeof h=="object"&&(h.targetPath!==void 0&&(e=h.targetPath),h.position!==void 0&&(r=h.position))}const a=e==="",o=a?null:this.tree.getNodeByPath(e);if(!a&&!o)return{success:!1,count:0,error:`Target node not found: ${e}`};if(!a&&i.sourceTreeId===this.treeId){const h=this.treePathSeparator;for(const p of i.entries)if(e===p.sourcePath||e.startsWith(p.sourcePath+h))return{success:!1,count:0,error:"Cannot paste a node into itself or its own descendant"}}if(!this.autoHandlePaste){const h={success:!0,count:i.entries.length,entries:i.entries,operation:i.operation,targetPath:e,position:r};return this.cutPaths=new Set,qi(),Nn.debug(`[clipboard] autoHandlePaste=false — forwarding ${i.entries.length} entries to consumer`),this.onPasteHandler?.(h),h}this._skipInsertArray=!0;let l=0,c;for(const h of i.entries){const p=n(h.data,l,i.operation);let y;if(a||r==="child"?y=this.tree.addNode(e,p):y=this.tree.addNode(o.parentPath??"",p),y.success&&y.node){l++;for(const k of h.descendants){const C=n(k.data,l,i.operation),_=k.relativePath.substring(0,k.relativePath.lastIndexOf(this.treePathSeparator)),v=_?y.node.path+_:y.node.path;this.tree.addNode(v,C).success&&l++}}else c=y.error}if(i.operation==="cut"&&i.sourceTreeId===this.treeId)for(const h of i.entries)this.tree.removeNode(h.sourcePath,!0);yn().then(()=>{this._skipInsertArray=!1}),this.cutPaths=new Set,qi();const d={success:l>0,count:l,error:l===0?c??"No nodes pasted":void 0};return Nn.debug(`[clipboard] Pasted ${l} node(s)`),this.onPasteHandler?.(d),d}cancelCut(){ia()==="cut"&&qi(),this.cutPaths=new Set,Nn.debug("[clipboard] Cut cancelled")}hasClipboardContent(){return Fh()}getClipboardOperation(){return ia()}getExpandedPaths(){return this.tree?.getExpandedPaths()||[]}setExpandedPaths(e){this.tree?.setExpandedPaths(e)}getAllData(){return this.tree?.getAllData()||[]}openContextMenu(e,n,r){this.contextMenuNode=e,this.contextMenuX=n+this.contextMenuXOffset,this.contextMenuY=r+this.contextMenuYOffset,this.contextMenuVisible=!0,this.isDebugMenuActive=!1}closeContextMenu(){this.contextMenuVisible=!1,this.contextMenuNode=null,this.isDebugMenuActive=!1}startDrag(e,n){if(Wt.debug("startDrag",{path:e.path,isDraggable:this.getNodeIsDraggable(e),hasDataTransfer:!!n.dataTransfer}),!this.getNodeIsDraggable(e)||!n.dataTransfer)return;n.dataTransfer.effectAllowed=this.allowCopy?"copyMove":"move",n.dataTransfer.setData("application/svelte-treeview",JSON.stringify(e));const r=this.tree.getNodeDisplayValue(e);r&&n.dataTransfer.setData("text/plain",r),this._onNodeDragStart(e,n)}dragOver(e,n,r){if(!n.dataTransfer?.types.includes("application/svelte-treeview")){Wt.debug("dragOver SKIP - no svelte-treeview type",{path:e.path,types:Array.from(n.dataTransfer?.types??[])});return}let i=this.draggedNode,a=!1;if(!i){a=!0;try{const c=n.dataTransfer.getData("application/svelte-treeview");c&&(i=JSON.parse(c))}catch{}this.isDragInProgress=!0}if(!(a?this.dragDropMode==="both"||this.dragDropMode==="cross":this.isDropAllowedByMode(i?.treeId))){Wt.debug("dragOver REJECTED - mode not allowed",{path:e.path,dragDropMode:this.dragDropMode,isCrossTreeDrag:a,draggedTreeId:i?.treeId,thisTreeId:this.treeId}),this.hoveredNodeForDrop=null;return}if(!(i?a||i.path!==e.path:this.isDragInProgress)){Wt.debug("dragOver REJECTED - invalid drop (same node?)",{path:e.path,draggedPath:i?.path});return}if(n.preventDefault(),this.hoveredNodeForDrop=e,this.currentDropOperation=this.allowCopy&&n.ctrlKey?"copy":"move",n.dataTransfer&&(n.dataTransfer.dropEffect=this.currentDropOperation),r){const c=this.getNodeAllowedDropPositions(e);this.activeDropPosition=this.calculateDropPositionFromEvent(n,r,c)}else{const c=n.currentTarget||n.target;c&&(this.activeDropPosition=this.calculateDropPosition(n,c))}Wt.debug("dragOver OK",{target:e.path,position:this.activeDropPosition,operation:this.currentDropOperation,hasElement:!!r}),this.onNodeDragOverHandler?.(e,n)}dragLeave(e,n){const r=n.currentTarget;if(!r)return;const i=r.getBoundingClientRect(),a=n.clientX,o=n.clientY;(a<i.left||a>=i.right||o<i.top||o>=i.bottom)&&(Wt.debug("dragLeave",{path:e.path}),this.hoveredNodeForDrop=null,this.activeDropPosition=null)}drop(e,n){Wt.debug("drop called",{target:e.path,draggedNode:this.draggedNode?.path,activeDropPosition:this.activeDropPosition}),n.preventDefault(),n.stopPropagation(),n.dataTransfer&&(n.dataTransfer.dropEffect=this.allowCopy&&n.ctrlKey?"copy":"move");let r=!1;if(!this.draggedNode){const i=n.dataTransfer?.getData("application/svelte-treeview");Wt.debug("drop - no draggedNode, read from dataTransfer:",{hasData:!!i}),i&&(this.draggedNode=JSON.parse(i),r=this.draggedNode?.treeId!==this.treeId)}if(this.draggedNode){const i=r?this.dragDropMode==="both"||this.dragDropMode==="cross":this.isDropAllowedByMode(this.draggedNode.treeId),a=!r&&this.draggedNode.path===e.path;if(Wt.debug("drop check",{dropAllowed:i,isCrossTreeDrag:r,sameNode:a,draggedPath:this.draggedNode.path,targetPath:e.path,dragDropMode:this.dragDropMode}),i&&(r||this.draggedNode.path!==e.path)){const o=this.activeDropPosition||"child";Wt.debug("drop EXECUTING",{from:this.draggedNode.path,to:e.path,position:o}),this._handleDrop(e,this.draggedNode,o,n)}else Wt.debug("drop REJECTED",{dropAllowed:i,sameNode:a})}else Wt.debug("drop - no draggedNode available, skipping");this._resetDragState()}dropAt(e,n,r){if(Wt.debug("dropAt",{target:e.path,position:n,draggedNode:this.draggedNode?.path}),r instanceof DragEvent&&(r.preventDefault(),!this.draggedNode)){const i=r.dataTransfer?.getData("application/svelte-treeview");i&&(this.draggedNode=JSON.parse(i))}this.draggedNode?(Wt.debug("dropAt EXECUTING",{from:this.draggedNode.path,to:e.path,position:n}),this._handleDrop(e,this.draggedNode,n,r)):Wt.debug("dropAt - no draggedNode, skipping"),this._resetDragState()}cancelDrag(){Wt.debug("Drag cancelled via public API"),this._resetDragState()}touchStart(e,n){this._onTouchStart(e,n)}touchMove(e,n){this._onTouchMove(e,n)}touchEnd(e,n){this._onTouchEnd(e,n)}getNodeAllowedDropPositions(e){return this.tree?.getNodeAllowedDropPositions(e)??null}getNodeIsDraggable(e){return this.tree?.getNodeIsDraggable(e)??!0}getNodeIsCollapsible(e){return this.tree?.getNodeIsCollapsible(e)??!0}calculateDropPositionFromEvent(e,n,r){const i=n.getBoundingClientRect(),a=e.clientX-i.left,o=e.clientY-i.top,l=i.width,c=i.height;let d;return a>l/2?d="child":o<c/2?d="before":d="after",!r||r.length===0||r.includes(d)?d:r.length===1?r[0]:r.includes("before")&&r.includes("after")?o<c/2?"before":"after":r[0]}async scrollToPath(e,n){cr(`[${this.treeId}] scrollToPath`);const{expand:r=!0,expandTarget:i=!1,highlight:a=!0,scrollOptions:o={behavior:"smooth",block:"center"},containerScroll:l=!1,containerElement:c}=n||{},d=this.tree.getNodeByPath(e);if(!d||!d.id)return console.warn(`[Tree ${this.treeId}] Node not found for path: ${e}`),Hn(`[${this.treeId}] scrollToPath`),!1;if(r&&d.parentPath&&this.tree.expandNodes(d.parentPath),i&&this.tree.expandNodes(e),(r||i)&&await yn(),this.vsActive&&this.vsContainerRef){const C=this.allFlatNodes.findIndex(v=>v.path===e);if(C===-1)return console.warn(`[Tree ${this.treeId}] Node not found in flat nodes for path: ${e}`),Hn(`[${this.treeId}] scrollToPath`),!1;const _=C*this.vsRowHeight-this.vsContainerRef.clientHeight/2+this.vsRowHeight/2;if(this.vsContainerRef.scrollTo({top:Math.max(0,_),behavior:o?.behavior||"smooth"}),await yn(),await new Promise(v=>requestAnimationFrame(v)),await yn(),await new Promise(v=>requestAnimationFrame(v)),a&&this.scrollHighlightClass){const v=`${this.treeId}-${d.id}`;this.applyHighlight(v)||(await yn(),await new Promise(I=>requestAnimationFrame(I)),this.applyHighlight(v))}return Hn(`[${this.treeId}] scrollToPath`),!0}const h=`${this.treeId}-${d.id}`,p=c||this.containerElement,k=(p?p.querySelector(`#${CSS.escape(h)}`):document.getElementById(h))?.querySelector(".ltree-node-content");if(!k)return console.warn(`[Tree ${this.treeId}] DOM element not found for node ID: ${h}`),Hn(`[${this.treeId}] scrollToPath`),!1;if(l){const C=this.findScrollableAncestor(k);if(C){const _=C.getBoundingClientRect(),v=k.getBoundingClientRect(),I=C.scrollTop+(v.top-_.top)-_.height/2+v.height/2;C.scrollTo({top:I,behavior:o?.behavior||"smooth"})}}else k.scrollIntoView(o);return a&&this.scrollHighlightClass&&this.applyHighlight(h),Hn(`[${this.treeId}] scrollToPath`),!0}applyHighlight(e){const n=this.containerElement,i=(n?n.querySelector(`#${CSS.escape(e)}`):document.getElementById(e))?.querySelector(".ltree-node-content");if(!i||!this.scrollHighlightClass)return!1;this.currentHighlight&&(this.currentHighlight.element.classList.remove(this.scrollHighlightClass),clearTimeout(this.currentHighlight.timeoutId),this.currentHighlight=null),i.classList.add(this.scrollHighlightClass);const a=this.scrollHighlightClass,o=setTimeout(()=>{i.classList.remove(a),this.currentHighlight=null},this.scrollHighlightTimeout);return this.currentHighlight={element:i,timeoutId:o},!0}updateProps(e){e.treeId!==void 0&&(this.treeId=e.treeId||this.treeId),e.treePathSeparator!==void 0&&(this.treePathSeparator=e.treePathSeparator??"."),e.data!==void 0&&(this.data=e.data),e.focusedNode!==void 0&&this._setFocusedNode(e.focusedNode??null),e.highlightedPaths!==void 0&&(this.highlightedPaths=e.highlightedPaths??new Set),e.selectedPaths!==void 0&&(this.selectedPaths=e.selectedPaths??new Set),e.searchText!==void 0&&(this.searchText=e.searchText),e.shouldDisplayDebugInformation!==void 0&&(this.shouldDisplayDebugInformation=e.shouldDisplayDebugInformation),e.rangeSelectionMode!==void 0&&(this.rangeSelectionMode=e.rangeSelectionMode??"visual"),e.shouldDisplayContextMenuInDebugMode!==void 0&&(this.shouldDisplayContextMenuInDebugMode=e.shouldDisplayContextMenuInDebugMode??!1),e.isLoading!==void 0&&(this.isLoading=e.isLoading??!1),e.bodyClass!==void 0&&(this.bodyClass=e.bodyClass),e.virtualScroll!==void 0&&(this.virtualScroll=e.virtualScroll??!1),e.virtualRowHeight!==void 0&&(this.virtualRowHeight=e.virtualRowHeight),e.virtualOverscan!==void 0&&(this.virtualOverscan=e.virtualOverscan??5),e.virtualContainerHeight!==void 0&&(this.virtualContainerHeight=e.virtualContainerHeight),e.clickBehavior!==void 0&&(this.clickBehavior=e.clickBehavior??"expand-and-focus"),e.showCheckboxes!==void 0&&(this.showCheckboxes=e.showCheckboxes??!1),e.checkboxMode!==void 0&&(this.checkboxMode=e.checkboxMode??"independent"),e.beforeCheckboxToggleCallback!==void 0&&(this.beforeCheckboxToggleHandler=e.beforeCheckboxToggleCallback),e.expandIconClass!==void 0&&(this.expandIconClass=e.expandIconClass??"ltree-icon-expand"),e.collapseIconClass!==void 0&&(this.collapseIconClass=e.collapseIconClass??"ltree-icon-collapse"),e.leafIconClass!==void 0&&(this.leafIconClass=e.leafIconClass??"ltree-icon-leaf"),e.highlightedNodeClass!==void 0&&(this.highlightedNodeClass=e.highlightedNodeClass),e.focusedNodeClass!==void 0&&(this.focusedNodeClass=e.focusedNodeClass),e.dragOverNodeClass!==void 0&&(this.dragOverNodeClass=e.dragOverNodeClass),e.dropZoneMode!==void 0&&(this.dropZoneMode=e.dropZoneMode??"glow"),e.dropZoneLayout!==void 0&&(this.dropZoneLayout=e.dropZoneLayout??"around"),e.dropZoneStart!==void 0&&(this.dropZoneStart=e.dropZoneStart??33),e.dropZoneMaxWidth!==void 0&&(this.dropZoneMaxWidth=e.dropZoneMaxWidth??120),e.allowCopy!==void 0&&(this.allowCopy=e.allowCopy??!1),e.autoHandleCopy!==void 0&&(this.autoHandleCopy=e.autoHandleCopy??!0),e.autoHandleMove!==void 0&&(this.autoHandleMove=e.autoHandleMove??!0),e.autoHandlePaste!==void 0&&(this.autoHandlePaste=e.autoHandlePaste??!0),e.dragDropMode!==void 0&&(this.dragDropMode=e.dragDropMode??"none"),e.scrollHighlightTimeout!==void 0&&(this.scrollHighlightTimeout=e.scrollHighlightTimeout??4e3),e.scrollHighlightClass!==void 0&&(this.scrollHighlightClass=e.scrollHighlightClass??"ltree-scroll-highlight"),e.contextMenuXOffset!==void 0&&(this.contextMenuXOffset=e.contextMenuXOffset??8),e.contextMenuYOffset!==void 0&&(this.contextMenuYOffset=e.contextMenuYOffset??0),e.onNodeClick!==void 0&&(this.onNodeClickHandler=e.onNodeClick),e.onNodeDragStart!==void 0&&(this.onNodeDragStartHandler=e.onNodeDragStart),e.onNodeDragOver!==void 0&&(this.onNodeDragOverHandler=e.onNodeDragOver),e.beforeDropCallback!==void 0&&(this.beforeDropHandler=e.beforeDropCallback),e.beforeCopyCallback!==void 0&&(this.beforeCopyHandler=e.beforeCopyCallback),e.beforeCutCallback!==void 0&&(this.beforeCutHandler=e.beforeCutCallback),e.beforePasteCallback!==void 0&&(this.beforePasteHandler=e.beforePasteCallback),e.onNodeDrop!==void 0&&(this.onNodeDropHandler=e.onNodeDrop),e.onPaste!==void 0&&(this.onPasteHandler=e.onPaste),e.getContextMenuItemsCallback!==void 0&&(this.getContextMenuItemsHandler=e.getContextMenuItemsCallback),e.onHighlightChange!==void 0&&(this.onHighlightChangeHandler=e.onHighlightChange),e.onSelectionChange!==void 0&&(this.onSelectionChangeHandler=e.onSelectionChange)}async _onNodeClicked(e,n){this.contextMenuVisible&&this.closeContextMenu();const r=n?.ctrl??!1,i=n?.shift??!1;if(Nn.debug(`[highlight] Click on ${e.path}`,{ctrl:r,shift:i,lastAnchor:this.lastHighlightedPath,prevCount:this.highlightedPaths.size}),r){const a=new Set([...this.highlightedPaths]);a.has(e.path)?(a.delete(e.path),e.isHighlighted=!1):(a.add(e.path),e.isHighlighted=!0),e._rev=(e._rev||0)+1,this.highlightedPaths=a,this.lastHighlightedPath=e.path}else if(i&&this.lastHighlightedPath){const a=this._getNodesBetween(this.lastHighlightedPath,e.path);this._clearAllHighlightFlags();const o=new Set;for(const l of a){o.add(l);const c=this.tree.getNodeByPath(l);c&&(c.isHighlighted=!0,c._rev=(c._rev||0)+1)}this.highlightedPaths=o}else{this._clearAllHighlightFlags(),e.isHighlighted=!0,e._rev=(e._rev||0)+1;const a=new Set;a.add(e.path),this.highlightedPaths=a,this.lastHighlightedPath=e.path}this._setFocusedNode(e),this.onNodeClickHandler?.(e),this._notifyHighlightChanged(),this.tree.refresh(),this.containerElement?.focus()}_getDescendantPaths(e){const n=[],r=i=>{for(const a of Object.values(i.children))n.push(a.path),r(a)};return r(e),n}_onCheckboxToggle(e){const n=this.checkboxMode==="cascade"&&e.visualState===rr.indeterminate?!0:!e.isSelected,r=this.highlightedPaths.size>1&&this.highlightedPaths.has(e.path);let i=[];if(r?i=[...this.highlightedPaths]:i=[e.path],this.checkboxMode==="cascade"){const l=new Set(i);for(const c of i){const d=this.tree.getNodeByPath(c);if(d)for(const h of this._getDescendantPaths(d))l.add(h)}i=[...l]}if(this.beforeCheckboxToggleHandler){const l=this.beforeCheckboxToggleHandler(e,n,i);if(l===!1)return;Array.isArray(l)&&(i=l)}const a=new Set([...this.selectedPaths]);for(const l of i){const c=this.tree.getNodeByPath(l);c&&(n?(a.add(l),c.isSelected=!0):(a.delete(l),c.isSelected=!1),c._rev=(c._rev||0)+1)}this.selectedPaths=a,this._setFocusedNode(e);const o=r?[...this.highlightedPaths]:[e.path];for(const l of o){const c=this.tree.getNodeByPath(l);if(c){if(this.checkboxMode==="cascade"){const d=this._computeVisualState(c);c.visualState!==d&&(c.visualState=d,c._rev=(c._rev||0)+1)}this._updateAncestorVisualStates(l)}}this.onNodeClickHandler?.(e),this._notifySelectionChanged(),this.tree.refresh(),this.containerElement?.focus()}_updateAncestorVisualStates(e){const n=new Set([...this.selectedPaths]);let r=this.tree.getNodeByPath(e)?.parentPath;for(;r;){const i=this.tree.getNodeByPath(r);if(!i)break;const a=this._computeVisualState(i),o=a===rr.selected;i.isSelected!==o&&(i.isSelected=o,o?n.add(r):n.delete(r)),i.visualState!==a&&(i.visualState=a),i._rev=(i._rev||0)+1,r=i.parentPath}this.selectedPaths=n}_computeVisualState(e){const n=Object.values(e.children);if(n.length===0)return e.isSelected?rr.selected:rr.notSelected;let r=!0,i=!0;const a=o=>{if(!(!r&&!i)){o.isSelected?i=!1:r=!1;for(const l of Object.values(o.children)){if(!r&&!i)return;a(l)}}};for(const o of n)if(a(o),!r&&!i)break;return r?rr.selected:i?rr.notSelected:rr.indeterminate}_setFocusedNode(e){this.focusedNode&&this.focusedNode.path!==e?.path&&(this.focusedNode.isFocused=!1,this.focusedNode._rev=(this.focusedNode._rev||0)+1),e&&(e.isFocused=!0,e._rev=(e._rev||0)+1),this.focusedNode=e}_clearAllHighlightFlags(){for(const e of this.highlightedPaths){const n=this.tree.getNodeByPath(e);n&&(n.isHighlighted=!1,n._rev=(n._rev||0)+1)}}_clearAllSelectionFlags(){for(const e of this.selectedPaths){const n=this.tree.getNodeByPath(e);n&&(n.isSelected=!1,n._rev=(n._rev||0)+1)}}_notifyHighlightChanged(){if(this.onHighlightChangeHandler){const e=this.getHighlightedNodes();this.onHighlightChangeHandler(this.highlightedPaths,e)}}_notifySelectionChanged(){if(this.onSelectionChangeHandler){const e=this.getSelectedNodes();this.onSelectionChangeHandler(this.selectedPaths,e)}}_getNodesBetween(e,n){return Nn.debug(`[multi-select] _getNodesBetween: ${e} → ${n}, mode=${this.rangeSelectionMode}`),this.rangeSelectionMode==="logical"?this._getAllNodesBetween(e,n):this._getVisibleNodesBetween(e,n)}_getVisibleNodesBetween(e,n){const r=this.tree.visibleFlatNodes;let i=-1,a=-1;for(let d=0;d<r.length&&(r[d].path===e&&(i=d),r[d].path===n&&(a=d),!(i!==-1&&a!==-1));d++);if(Nn.debug(`[multi-select] _getVisibleNodesBetween: indexA=${i}, indexB=${a}, totalVisible=${r.length}`),i===-1||a===-1)return Nn.debug(`[multi-select] _getVisibleNodesBetween: path not found in visible nodes, falling back to [${n}]`),[n];const o=Math.min(i,a),l=Math.max(i,a),c=r.slice(o,l+1).map(d=>d.path);return Nn.debug(`[multi-select] _getVisibleNodesBetween: selected ${c.length} visible nodes [${o}..${l}]`),c}_getAllNodesBetween(e,n){const r=[],i=h=>{h.path&&r.push(h.path);for(const p of Object.values(h.children))i(p)};for(const h of this.tree.tree)i(h);let a=-1,o=-1;for(let h=0;h<r.length&&(r[h]===e&&(a=h),r[h]===n&&(o=h),!(a!==-1&&o!==-1));h++);if(Nn.debug(`[multi-select] _getAllNodesBetween: indexA=${a}, indexB=${o}, totalNodes=${r.length}`),a===-1||o===-1)return Nn.debug(`[multi-select] _getAllNodesBetween: path not found in tree, falling back to [${n}]`),[n];const l=Math.min(a,o),c=Math.max(a,o),d=r.slice(l,c+1);return Nn.debug(`[multi-select] _getAllNodesBetween: selected ${d.length} nodes [${l}..${c}]`),d}highlightNode(e,n="replace"){const r=this.tree.getNodeByPath(e);r&&(n==="toggle"?this._onNodeClicked(r,{ctrl:!0,shift:!1}):n==="range"?this._onNodeClicked(r,{ctrl:!1,shift:!0}):this._onNodeClicked(r))}highlightNodes(e){this._clearAllHighlightFlags();const n=new Set;let r=null;for(const i of e){const a=this.tree.getNodeByPath(i);a&&(a.isHighlighted=!0,a._rev=(a._rev||0)+1,n.add(i),r=a)}this.highlightedPaths=n,r&&(this._setFocusedNode(r),this.lastHighlightedPath=r.path),this._notifyHighlightChanged(),this.tree.refresh()}clearHighlight(){this._clearAllHighlightFlags(),this.highlightedPaths=new Set,this.lastHighlightedPath=null,this._notifyHighlightChanged(),this.tree.refresh()}getHighlightedNodes(){const e=[];for(const n of this.highlightedPaths){const r=this.tree.getNodeByPath(n);r&&e.push(r)}return e}isNodeHighlighted(e){return this.highlightedPaths.has(e)}getSelectedNodes(){const e=[];for(const n of this.selectedPaths){const r=this.tree.getNodeByPath(n);r&&e.push(r)}return e}isNodeSelected(e){return this.selectedPaths.has(e)}deselectAll(){this._clearAllSelectionFlags(),this.selectedPaths=new Set,this._notifySelectionChanged(),this.tree.refresh()}selectNode(e,n="replace"){this.highlightNode(e,n)}selectNodes(e){this.highlightNodes(e)}_onNodeRightClicked(e,n){!this.hasContextMenuSnippet&&!this.getContextMenuItemsHandler||(this.highlightedPaths.has(e.path)||(this._clearAllHighlightFlags(),e.isHighlighted=!0,e._rev=(e._rev||0)+1,this.highlightedPaths=new Set([e.path]),this._setFocusedNode(e),this.lastHighlightedPath=e.path,this._notifyHighlightChanged(),this.tree.refresh()),Nn.debug(`Context menu opened: ${e.path}`),n.preventDefault(),this.openContextMenu(e,n.clientX,n.clientY))}isDropAllowedByMode(e){if(this.dragDropMode==="none")return!1;const n=e===this.treeId;return!(this.dragDropMode==="self"&&!n||this.dragDropMode==="cross"&&n)}calculateDropPosition(e,n){const r=n.getBoundingClientRect(),i=e.clientY-r.top,a=r.height;return i<a*.25?"before":i>a*.75?"after":"child"}_onNodeDragStart(e,n){Wt.debug(`Drag started: ${e.path}`,{ctrlKey:n.ctrlKey,allowCopy:this.allowCopy,treeId:this.treeId}),this.draggedNode=e,this.isDragInProgress=!0,this.onNodeDragStartHandler?.(e,n)}_onNodeDragEnd=e=>{Wt.debug("Drag ended",{dropEffect:e.dataTransfer?.dropEffect,operation:this.currentDropOperation}),this._resetDragState()};_resetDragState(){Wt.debug("_resetDragState"),this.isDragInProgress=!1,this.draggedNode=null,this.hoveredNodeForDrop=null,this.activeDropPosition=null,this.isDropPlaceholderActive=!1,this.currentDropOperation="move",this.floatingZoneRect=null,this.floatingHoveredZone=null}async _handleDrop(e,n,r,i){let a="move";const o=i instanceof DragEvent,l=o?i.ctrlKey:!1;if(this.allowCopy&&o&&l&&(a="copy"),Wt.info(`Drop: ${n.path} -> ${e?.path??"empty tree"}`,{position:r,operation:a,isCrossTree:n.treeId!==this.treeId}),this.beforeDropHandler){const d=await this.beforeDropHandler(e,n,r,i,a);if(d===!1)return!1;d&&typeof d=="object"&&("position"in d&&d.position&&(r=d.position),"operation"in d&&d.operation&&(a=d.operation))}const c=n.treeId===this.treeId;if(c&&a==="move"&&e){if(this.autoHandleMove){const d=this.moveNode(n.path,e.path,r);return this.onNodeDropHandler?.(e,n,r,i,a),d.success}return this.onNodeDropHandler?.(e,n,r,i,a),!0}if(c&&a==="copy"&&e&&this.autoHandleCopy){const d=r==="child"?e.path:e.parentPath||"",h=r!=="child"?e.path:void 0,p=r!=="child"?r:void 0,y=this.tree.copyNodeWithDescendants(n,d,k=>({...k,[this.tree.idMember||"id"]:`${k[this.tree.idMember||"id"]}_copy_${Date.now()}`}),h,p);return this.onNodeDropHandler?.(e,n,r,i,a),y.success}return this.onNodeDropHandler?.(e,n,r,i,a),!0}_onNodeDragOver(e,n){let r=this.draggedNode,i=!1;if(!r&&n.dataTransfer?.types.includes("application/svelte-treeview")){i=!0;try{const l=n.dataTransfer.getData("application/svelte-treeview");l&&(r=JSON.parse(l))}catch{}this.isDragInProgress=!0}if(!(i?this.dragDropMode==="both"||this.dragDropMode==="cross":this.isDropAllowedByMode(r?.treeId))){this.hoveredNodeForDrop=null;return}if(r?i||r.path!==e.path:this.isDragInProgress){n.preventDefault(),this.hoveredNodeForDrop=e;const l=n.target.closest(".ltree-node-content");if(l&&(this.activeDropPosition=this.calculateDropPosition(n,l)),this.currentDropOperation=this.allowCopy&&n.ctrlKey?"copy":"move",this.onNodeDragOverHandler?.(e,n),n.dataTransfer&&(n.dataTransfer.dropEffect=this.currentDropOperation),this.dropZoneMode==="floating"){const c=n.target.closest(".ltree-node-row");if(c){const d=c.getBoundingClientRect();this.floatingZoneRect={top:d.top,left:d.left,width:d.width,height:d.height}}}}}_onNodeDragLeave(e,n){}_onNodeDrop(e,n){n.preventDefault();let r=!1;if(!this.draggedNode){const a=n.dataTransfer?.getData("application/svelte-treeview");a&&(this.draggedNode=JSON.parse(a),r=this.draggedNode?.treeId!==this.treeId)}if(!(r?this.dragDropMode==="both"||this.dragDropMode==="cross":this.isDropAllowedByMode(this.draggedNode?.treeId))){this._onNodeDragEnd(n);return}if(this.draggedNode&&(r||this.draggedNode!==e)){const a=this.activeDropPosition||"child";this._handleDrop(e,this.draggedNode,a,n)}this._onNodeDragEnd(n)}_onZoneDrop(e,n,r){r.preventDefault();let i=!1;if(!this.draggedNode){const o=r.dataTransfer?.getData("application/svelte-treeview");o&&(this.draggedNode=JSON.parse(o),i=this.draggedNode?.treeId!==this.treeId)}if(!this.draggedNode){this._onNodeDragEnd(r);return}if(!(i?this.dragDropMode==="both"||this.dragDropMode==="cross":this.isDropAllowedByMode(this.draggedNode?.treeId))){this._onNodeDragEnd(r);return}(i||this.draggedNode!==e)&&this._handleDrop(e,this.draggedNode,n,r),this._onNodeDragEnd(r)}isFloatingPositionAllowed(e){if(!this.hoveredNodeForDrop)return!1;const n=this.tree.getNodeAllowedDropPositions(this.hoveredNodeForDrop);return!n||n.length===0?!0:n.includes(e)}handleFloatingZoneDragOver(e,n){n.preventDefault(),n.dataTransfer&&(n.dataTransfer.dropEffect=this.allowCopy&&n.ctrlKey?"copy":"move"),this.floatingHoveredZone=e,this.hoveredNodeForDrop&&this._onNodeDragOver(this.hoveredNodeForDrop,n)}handleFloatingZoneDragLeave(){this.floatingHoveredZone=null}handleFloatingZoneDrop(e,n){this.floatingHoveredZone=null,this.hoveredNodeForDrop&&this._onZoneDrop(this.hoveredNodeForDrop,e,n)}_onTouchStart(e,n){if(!this.getNodeIsDraggable(e))return;const r=n.touches[0];this.touchDragState={node:e,startX:r.clientX,startY:r.clientY,isDragging:!1,ghostElement:null,currentDropTarget:null},this._addDocumentTouchListeners(),this.touchTimer=setTimeout(()=>{this.touchDragState.isDragging=!0,this.draggedNode=e,this.isDragInProgress=!0,Wt.debug(`Touch drag started: ${e.path}`),this.createGhostElement(e,r.clientX,r.clientY);try{navigator.vibrate?.(50)}catch{}},300)}_onTouchMove(e,n){}_onTouchEnd(e,n){}_boundDocTouchMove=null;_boundDocTouchEnd=null;_addDocumentTouchListeners(){this._removeDocumentTouchListeners(),this._boundDocTouchMove=e=>this._docTouchMove(e),this._boundDocTouchEnd=e=>this._docTouchEnd(e),document.addEventListener("touchmove",this._boundDocTouchMove,{passive:!1}),document.addEventListener("touchend",this._boundDocTouchEnd),document.addEventListener("touchcancel",this._boundDocTouchEnd)}_removeDocumentTouchListeners(){this._boundDocTouchMove&&(document.removeEventListener("touchmove",this._boundDocTouchMove),this._boundDocTouchMove=null),this._boundDocTouchEnd&&(document.removeEventListener("touchend",this._boundDocTouchEnd),document.removeEventListener("touchcancel",this._boundDocTouchEnd),this._boundDocTouchEnd=null)}_docTouchMove(e){if(!this.touchDragState.node)return;const n=e.touches[0];if(!this.touchDragState.isDragging){const i=Math.abs(n.clientX-this.touchDragState.startX),a=Math.abs(n.clientY-this.touchDragState.startY);(i>10||a>10)&&(this.touchTimer&&clearTimeout(this.touchTimer),this._resetTouchState());return}e.preventDefault(),this.touchDragState.ghostElement&&(this.touchDragState.ghostElement.style.left=`${n.clientX}px`,this.touchDragState.ghostElement.style.top=`${n.clientY}px`),this.touchDragState.ghostElement&&(this.touchDragState.ghostElement.style.pointerEvents="none");const r=document.elementFromPoint(n.clientX,n.clientY);this.touchDragState.ghostElement&&(this.touchDragState.ghostElement.style.pointerEvents=""),this.updateDropTarget(r)}_docTouchEnd(e){if(this.touchTimer&&clearTimeout(this.touchTimer),this.touchDragState.isDragging&&this.draggedNode){const n=e.changedTouches[0];this.touchDragState.ghostElement&&(this.touchDragState.ghostElement.style.display="none");const r=document.elementFromPoint(n.clientX,n.clientY),i=this.findNodeFromElement(r),a=r?.closest(".ltree-empty-state"),o=r?.closest(".ltree-root-drop-zone");(a||o)&&!i?(Wt.debug(`Touch drag ended: ${this.draggedNode.path} -> empty tree`),this._handleDrop(null,this.draggedNode,"child",e)):i&&i!==this.draggedNode&&i.isDropAllowed?(Wt.debug(`Touch drag ended: ${this.draggedNode.path} -> ${i.path}`),this._handleDrop(i,this.draggedNode,"child",e)):Wt.debug(`Touch drag cancelled: ${this.draggedNode.path}`),this.removeGhostElement(),this.clearDropTargetHighlight()}this._resetTouchState()}_resetTouchState(){this._removeDocumentTouchListeners(),this.touchDragState={node:null,startX:0,startY:0,isDragging:!1,ghostElement:null,currentDropTarget:null},this.draggedNode=null,this.isDragInProgress=!1,this.isDropPlaceholderActive=!1}createGhostElement(e,n,r){this.removeGhostElement(),document.querySelectorAll(".ltree-touch-ghost").forEach(a=>a.remove());const i=document.createElement("div");i.className="ltree-touch-ghost",i.textContent=this.tree.getNodeDisplayValue(e),i.style.left=`${n}px`,i.style.top=`${r}px`,document.body.appendChild(i),this.touchDragState.ghostElement=i}removeGhostElement(){this.touchDragState.ghostElement&&(this.touchDragState.ghostElement.remove(),this.touchDragState.ghostElement=null)}destroy(){typeof document>"u"||(this._removeDocumentTouchListeners(),this.removeGhostElement(),document.querySelectorAll(".ltree-touch-ghost").forEach(e=>e.remove()))}findNodeFromElement(e){if(!e)return null;const n=e.closest(".ltree-node");if(!n)return null;const r=n.getAttribute("data-tree-path");return r?this.tree.getNodeByPath(r):null}updateDropTarget(e){const n=this.findNodeFromElement(e);if(this.touchDragState.currentDropTarget&&this.touchDragState.currentDropTarget!==n&&document.querySelector(`[data-tree-path="${this.touchDragState.currentDropTarget.path}"] .ltree-node-content`)?.classList.remove(this.dragOverNodeClass||"ltree-dragover-highlight"),e?.closest(".ltree-empty-state")&&!n){this.isDropPlaceholderActive=!0,this.touchDragState.currentDropTarget=null;return}else this.isDropPlaceholderActive=!1;n&&n!==this.draggedNode&&n.isDropAllowed?(document.querySelector(`[data-tree-path="${n.path}"] .ltree-node-content`)?.classList.add(this.dragOverNodeClass||"ltree-dragover-highlight"),this.touchDragState.currentDropTarget=n):this.touchDragState.currentDropTarget=null}clearDropTargetHighlight(){this.touchDragState.currentDropTarget&&document.querySelector(`[data-tree-path="${this.touchDragState.currentDropTarget.path}"] .ltree-node-content`)?.classList.remove(this.dragOverNodeClass||"ltree-dragover-highlight")}handleEmptyTreeDragOver=e=>{this.dragDropMode!=="none"&&e.dataTransfer?.types.includes("application/svelte-treeview")&&(e.preventDefault(),this.isDropPlaceholderActive=!0,e.dataTransfer&&(e.dataTransfer.dropEffect="move"))};handleEmptyTreeDragLeave=e=>{const n=e.currentTarget.getBoundingClientRect(),r=e.clientX,i=e.clientY;(r<n.left||r>=n.right||i<n.top||i>=n.bottom)&&(this.isDropPlaceholderActive=!1)};handleEmptyTreeDrop=e=>{if(e.preventDefault(),this.isDropPlaceholderActive=!1,this.dragDropMode==="none")return;const n=e.dataTransfer?.getData("application/svelte-treeview");if(n){const r=JSON.parse(n);this._handleDrop(null,r,"child",e)}this._onNodeDragEnd(e)};handleEmptyTreeTouchEnd=e=>{this.dragDropMode!=="none"&&this.draggedNode&&this.isDropPlaceholderActive&&(this._handleDrop(null,this.draggedNode,"child",e),this.isDropPlaceholderActive=!1)};handleTreeDragEnter=e=>{e.dataTransfer?.types.includes("application/svelte-treeview")&&(this.isDragInProgress=!0)};handleTreeDragLeave=e=>{const n=e.currentTarget.getBoundingClientRect(),r=e.clientX,i=e.clientY;(r<n.left||r>=n.right||i<n.top||i>=n.bottom)&&this.draggedNode?.treeId!==this.treeId&&(this.isDragInProgress=!1,this.hoveredNodeForDrop=null,this.activeDropPosition=null)};scheduleFlatRenderBatch(){this.flatRenderAnimationFrame||(this.flatRenderAnimationFrame=requestAnimationFrame(()=>{if(this.flatRenderAnimationFrame=null,this.flatRenderQueue.length===0)return;const e=this.currentBatchSize||this.initialBatchSize,n=this.flatRenderQueue.slice(0,e),r=this.flatRenderQueue.slice(e);this.flatRenderedIds=new Set([...this.flatRenderedIds,...n]),this.flatRenderQueue=r,this.currentBatchSize=Math.min(e*2,this.maxBatchSize),r.length>0&&this.scheduleFlatRenderBatch()}))}generateTreeId(){return`${Date.now()}${Math.floor(Math.random()*1e4)}`}navTo(e){this.navigation.navTo(e)}navNextSibling(){this.navigation.navNextSibling()}navPrevSibling(){this.navigation.navPrevSibling()}navInto(){this.navigation.navInto()}navOut(){this.navigation.navOut()}navBackOut(){this.navigation.navBackOut()}navToggle(){this.navigation.navToggle()}navFirst(){this.navigation.navFirst()}navLast(){this.navigation.navLast()}navPageDown(){this.navigation.navPageDown()}navPageUp(){this.navigation.navPageUp()}navHighlightNext(){this.navigation.navHighlightNext()}navHighlightPrev(){this.navigation.navHighlightPrev()}navHighlightFirst(){this.navigation.navHighlightFirst()}navHighlightLast(){this.navigation.navHighlightLast()}navHighlightPageDown(){this.navigation.navHighlightPageDown()}navHighlightPageUp(){this.navigation.navHighlightPageUp()}createDefaultNavigation(){return{navTo:e=>{this.getNodeByPath(e)&&(this.selectNode(e,"replace"),this.scrollToPath(e,{expand:!1,highlight:!1,containerScroll:!0}))},navNextSibling:()=>{const e=this.allFlatNodes;if(e.length===0)return;const n=this.focusedNode?.path,r=n?e.findIndex(a=>a.path===n):-1;if(r===-1){this.navigation.navTo(e[0].path);return}const i=e[r].level;for(let a=r+1;a<e.length;a++)if(e[a].level===i){this.navigation.navTo(e[a].path);return}},navPrevSibling:()=>{const e=this.allFlatNodes;if(e.length===0)return;const n=this.focusedNode?.path,r=n?e.findIndex(a=>a.path===n):-1;if(r===-1){this.navigation.navTo(e[e.length-1].path);return}const i=e[r].level;for(let a=r-1;a>=0;a--)if(e[a].level===i){this.navigation.navTo(e[a].path);return}},navInto:()=>{const e=this.focusedNode?.path;if(!e)return;const n=this.getNodeByPath(e);if(!n)return;const r=this.allFlatNodes,i=r.findIndex(a=>a.path===e);if(n.hasChildren&&!n.isExpanded&&n.isCollapsible!==!1)this.expandNodes(e),yn().then(()=>{const a=this.allFlatNodes,o=a.findIndex(l=>l.path===e);o>=0&&o+1<a.length&&this.navigation.navTo(a[o+1].path)});else if(n.hasChildren&&n.isExpanded){const a=i+1;a<r.length&&this.navigation.navTo(r[a].path)}},navOut:()=>{const e=this.focusedNode?.path;if(!e)return;const n=this.getNodeByPath(e);n?.parentPath&&this.navigation.navTo(n.parentPath)},navBackOut:()=>{const e=this.focusedNode?.path;if(!e)return;const n=this.getNodeByPath(e);if(!n?.parentPath)return;const r=this.getNodeByPath(n.parentPath);r&&(r.hasChildren&&r.isExpanded&&r.isCollapsible!==!1&&(this.collapseNodes(r.path),r._rev=(r._rev||0)+1),yn().then(()=>{this.navigation.navTo(r.path)}))},navToggle:()=>{const e=this.focusedNode?.path;if(!e)return;const n=this.getNodeByPath(e);!n?.hasChildren||n.isCollapsible===!1||(n.isExpanded?this.collapseNodes(e):this.expandNodes(e))},navFirst:()=>{const e=this.allFlatNodes;e.length>0&&this.navigation.navTo(e[0].path)},navLast:()=>{const e=this.allFlatNodes;e.length>0&&this.navigation.navTo(e[e.length-1].path)},navPageDown:()=>{const e=this.allFlatNodes;if(e.length===0)return;const n=this.focusedNode?.path,r=n?e.findIndex(a=>a.path===n):-1,i=Math.min((r===-1?0:r)+10,e.length-1);this.navigation.navTo(e[i].path)},navPageUp:()=>{const e=this.allFlatNodes;if(e.length===0)return;const n=this.focusedNode?.path,r=n?e.findIndex(a=>a.path===n):e.length,i=Math.max((r===-1?e.length:r)-10,0);this.navigation.navTo(e[i].path)},navHighlightNext:()=>{const e=this.allFlatNodes;if(e.length===0)return;const n=this.focusedNode?.path,r=n?e.findIndex(a=>a.path===n):-1;if(r===-1)return;const i=e[r].level;for(let a=r+1;a<e.length;a++)if(e[a].level===i){this._navHighlightTo(e[a].path);return}},navHighlightPrev:()=>{const e=this.allFlatNodes;if(e.length===0)return;const n=this.focusedNode?.path,r=n?e.findIndex(a=>a.path===n):-1;if(r===-1)return;const i=e[r].level;for(let a=r-1;a>=0;a--)if(e[a].level===i){this._navHighlightTo(e[a].path);return}},navHighlightFirst:()=>{const e=this.allFlatNodes;e.length>0&&this._navHighlightTo(e[0].path)},navHighlightLast:()=>{const e=this.allFlatNodes;e.length>0&&this._navHighlightTo(e[e.length-1].path)},navHighlightPageDown:()=>{const e=this.allFlatNodes;if(e.length===0)return;const n=this.focusedNode?.path,r=n?e.findIndex(a=>a.path===n):-1;if(r===-1)return;const i=Math.min(r+10,e.length-1);this._navHighlightTo(e[i].path)},navHighlightPageUp:()=>{const e=this.allFlatNodes;if(e.length===0)return;const n=this.focusedNode?.path,r=n?e.findIndex(a=>a.path===n):-1;if(r===-1)return;const i=Math.max(r-10,0);this._navHighlightTo(e[i].path)}}}_navHighlightTo(e){if(!this.lastHighlightedPath&&this.focusedNode){this.lastHighlightedPath=this.focusedNode.path;const r=this.focusedNode;r.isHighlighted||(r.isHighlighted=!0,r._rev=(r._rev||0)+1,this.highlightedPaths=new Set([r.path]))}this.highlightNode(e,"range");const n=this.tree.getNodeByPath(e);n&&this._setFocusedNode(n),this.scrollToPath(e,{expand:!1,highlight:!1,containerScroll:!0}),this.tree.refresh()}findScrollableAncestor(e){let n=e.parentElement;for(;n;){const i=getComputedStyle(n).overflowY;if((i==="auto"||i==="scroll")&&n.scrollHeight>n.clientHeight)return n;n=n.parentElement}return null}}function jh(t){return new Bh(t)}var Vh=D("<span> </span>"),Kh=D("<span> </span>"),$h=D('<div class="ltree-debug-info"><details><summary>Debug Info</summary> <div class="ltree-debug-stats"><span> </span> <span> </span> <span> </span> <span> </span> <span> </span> <!> <!> <span> </span></div></details></div>'),Zh=D('<div class="ltree-loading-spinner"></div>'),Uh=D('<div class="ltree-loading-overlay"><!></div>'),Wh=D('<div class="ltree-drop-placeholder-content">Drop here to add</div>'),Gh=D("<div><!></div>"),Yh=D('<div class="ltree-tree ltree-flat-mode ltree-virtual-scroll"><div><div></div></div></div>'),Xh=D('<div class="ltree-drop-placeholder-content">Drop here to add</div>'),Jh=D("<div><!></div>"),Qh=D('<div class="ltree-tree ltree-flat-mode"></div>'),qh=D('<div class="ltree-drop-placeholder-content">Drop here to add</div>'),eu=D("<div><!></div>"),tu=D('<div class="ltree-tree"></div>'),nu=D('<div class="ltree-drop-placeholder-content">Drop here to add</div>'),ru=D("<div><!></div>"),iu=D("<div>↑ Before</div>"),su=D("<div>↓ After</div>"),au=D("<div>→ Child</div>"),ou=D("<div><!> <!> <!></div>"),lu=D('<span class="ltree-context-menu-divider-label"> </span>'),cu=D('<div class="ltree-context-menu-divider" role="separator"><!></div>'),du=D('<span class="ltree-context-menu-icon"> </span>'),hu=D('<span class="ltree-context-menu-shortcut"> </span>'),uu=D('<span class="ltree-context-menu-arrow">▸</span> <div class="ltree-context-submenu" role="menu"><!></div>',1),fu=D('<div role="menuitem"><!> <span class="ltree-context-menu-label"> </span> <!> <!></div>'),gu=D('<div class="ltree-context-menu" role="menu"><!></div>'),vu=D('<div class="ltree-container" tabindex="0"><!> <!> <!> <div><!></div> <!> <!> <!></div>');function pu(t,e){Dn(e,!0);let n=$(e,"treeId",7),r=$(e,"treePathSeparator",7,"."),i=$(e,"idMember",7),a=$(e,"pathMember",7),o=$(e,"parentPathMember",7),l=$(e,"levelMember",7),c=$(e,"hasChildrenMember",7),d=$(e,"isExpandedMember",7),h=$(e,"isSelectableMember",7),p=$(e,"isSelectedMember",7),y=$(e,"isDraggableMember",7),k=$(e,"getIsDraggableCallback",7),C=$(e,"isDropAllowedMember",7),_=$(e,"isCollapsibleMember",7),v=$(e,"getIsCollapsibleCallback",7),I=$(e,"displayValueMember",7),O=$(e,"getDisplayValueCallback",7),j=$(e,"searchValueMember",7),K=$(e,"getSearchValueCallback",7),U=$(e,"orderMember",7),V=$(e,"isSorted",7),se=$(e,"sortCallback",7),oe=$(e,"data",15),ce=$(e,"focusedNode",15),G=$(e,"highlightedPaths",31,()=>Ut(new Set)),N=$(e,"selectedPaths",31,()=>Ut(new Set)),W=$(e,"insertResult",15),z=$(e,"nodeTemplate",3,void 0),X=$(e,"treeHeader",3,void 0),le=$(e,"treeFooter",3,void 0),ue=$(e,"noDataFound",3,void 0),Se=$(e,"contextMenu",3,void 0),ie=$(e,"dropPlaceholder",3,void 0),de=$(e,"loadingPlaceholder",3,void 0),Ce=$(e,"expandLevel",7,2),xe=$(e,"clickBehavior",7,"expand-and-focus"),tt=$(e,"showCheckboxes",7,!1),_e=$(e,"checkboxMode",7,"independent"),Z=$(e,"beforeCheckboxToggleCallback",7),pe=$(e,"rangeSelectionMode",7,"visual"),ve=$(e,"shouldUseInternalSearchIndex",7,!0),Ke=$(e,"initializeIndexCallback",7),Oe=$(e,"searchText",15),je=$(e,"indexerBatchSize",7,25),Ge=$(e,"indexerTimeout",7,50),et=$(e,"shouldDisplayDebugInformation",7,!1),$e=$(e,"shouldDisplayContextMenuInDebugMode",7,!1),mt=$(e,"isLoading",3,!1),vt=$(e,"progressiveRender",3,!0),Qe=$(e,"initialBatchSize",3,20),Fe=$(e,"maxBatchSize",3,500),nt=$(e,"isRendering",15,!1),lt=$(e,"useFlatRendering",3,!0),H=$(e,"virtualScroll",7,!1),ne=$(e,"virtualRowHeight",7,void 0),F=$(e,"virtualOverscan",7,5),M=$(e,"virtualContainerHeight",7,void 0),R=$(e,"dragDropMode",7,"none"),Y=$(e,"dropZoneMode",7,"glow"),Q=$(e,"dropZoneLayout",3,"around"),Pe=$(e,"dropZoneStart",3,33),Ne=$(e,"dropZoneMaxWidth",3,120),ge=$(e,"allowCopy",3,!1),ye=$(e,"autoHandleCopy",3,!0),A=$(e,"autoHandleMove",3,!0),re=$(e,"autoHandlePaste",3,!0),ae=$(e,"accordionExpand",7,!1),Me=$(e,"onNodeClick",7),ke=$(e,"onHighlightChange",7),He=$(e,"onSelectionChange",7),Xe=$(e,"onNodeDragStart",7),ut=$(e,"onNodeDragOver",7),T=$(e,"onNodeDrop",7),ee=$(e,"beforeDropCallback",7),Te=$(e,"beforeCopyCallback",7),Ae=$(e,"beforeCutCallback",7),Ie=$(e,"beforePasteCallback",7),we=$(e,"getContextMenuItemsCallback",7),Ve=$(e,"bodyClass",7),ot=$(e,"expandIconClass",7,"ltree-icon-expand"),it=$(e,"collapseIconClass",7,"ltree-icon-collapse"),P=$(e,"leafIconClass",7,"ltree-icon-leaf"),w=$(e,"toggleIconMode",7,"rotate"),E=$(e,"highlightedNodeClass",7),he=$(e,"focusedNodeClass",7),Ee=$(e,"dragOverNodeClass",7),be=$(e,"scrollHighlightTimeout",7,4e3),ze=$(e,"scrollHighlightClass",7,"ltree-scroll-highlight"),Le=$(e,"contextMenuXOffset",7,8),rt=$(e,"contextMenuYOffset",7,0);const m=jh({idMember:i(),pathMember:a(),parentPathMember:o(),levelMember:l(),hasChildrenMember:c(),isExpandedMember:d(),isSelectableMember:h(),isSelectedMember:p(),isDraggableMember:y(),getIsDraggableCallback:k(),isDropAllowedMember:C(),allowedDropPositionsMember:e.allowedDropPositionsMember,getAllowedDropPositionsCallback:e.getAllowedDropPositionsCallback,isCollapsibleMember:_(),getIsCollapsibleCallback:v(),displayValueMember:I(),getDisplayValueCallback:O(),searchValueMember:j(),getSearchValueCallback:K(),orderMember:U(),isSorted:V(),sortCallback:se(),treeId:n(),treePathSeparator:r(),data:oe(),focusedNode:ce(),highlightedPaths:G(),selectedPaths:N(),expandLevel:Ce(),clickBehavior:xe(),showCheckboxes:tt(),checkboxMode:_e(),beforeCheckboxToggleCallback:Z(),rangeSelectionMode:pe(),shouldUseInternalSearchIndex:ve(),initializeIndexCallback:Ke(),searchText:Oe(),indexerBatchSize:je(),indexerTimeout:Ge(),shouldDisplayDebugInformation:et(),shouldDisplayContextMenuInDebugMode:$e(),isLoading:mt(),progressiveRender:vt(),initialBatchSize:Qe(),maxBatchSize:Fe(),onRenderStart:e.onRenderStart,onRenderProgress:e.onRenderProgress,onRenderComplete:e.onRenderComplete,useFlatRendering:lt(),virtualScroll:H(),virtualRowHeight:ne(),virtualOverscan:F(),virtualContainerHeight:M(),dragDropMode:R(),dropZoneMode:Y(),dropZoneLayout:Q(),dropZoneStart:Pe(),dropZoneMaxWidth:Ne(),allowCopy:ge(),autoHandleCopy:ye(),autoHandleMove:A(),autoHandlePaste:re(),accordionExpand:ae(),onNodeClick:Me(),onHighlightChange:ke(),onSelectionChange:He(),onNodeDragStart:Xe(),onNodeDragOver:ut(),onNodeDrop:T(),beforeDropCallback:ee(),beforeCopyCallback:Te(),beforeCutCallback:Ae(),beforePasteCallback:Ie(),getContextMenuItemsCallback:we(),hasContextMenuSnippet:!!Se(),bodyClass:Ve(),highlightedNodeClass:E(),focusedNodeClass:he(),dragOverNodeClass:Ee(),expandIconClass:ot(),collapseIconClass:it(),leafIconClass:P(),toggleIconMode:w(),scrollHighlightTimeout:be(),scrollHighlightClass:ze(),contextMenuXOffset:Le(),contextMenuYOffset:rt()});e.navigationOverrides&&(m.navigation={...m.createDefaultNavigation(),...e.navigationOverrides}),hi("Ltree",m.tree),hi("NodeCallbacks",m.nodeCallbacks),hi("NodeConfig",m.nodeConfig),m.renderCoordinator&&hi("RenderCoordinator",m.renderCoordinator),sa(()=>m.destroy());let Ze;De(()=>{Ze&&(m.containerElement=Ze)}),De(()=>{m.data=oe()}),De(()=>{m.searchText=Oe()}),De(()=>{n()&&(m.treeId=n())}),De(()=>{m.treePathSeparator=r()??"."}),De(()=>{m.shouldDisplayDebugInformation=et()??!1}),De(()=>{m.shouldDisplayContextMenuInDebugMode=$e()??!1}),De(()=>{m.isLoading=mt()??!1}),De(()=>{m.bodyClass=Ve()}),De(()=>{m.useFlatRendering=lt()??!0}),De(()=>{m.virtualScroll=H()??!1}),De(()=>{m.virtualRowHeight=ne()}),De(()=>{m.virtualOverscan=F()??5}),De(()=>{m.virtualContainerHeight=M()}),De(()=>{m.progressiveRender=vt()??!0}),De(()=>{m.initialBatchSize=Qe()??20}),De(()=>{m.maxBatchSize=Fe()??500}),De(()=>{m.dragDropMode=R()??"none"}),De(()=>{m.allowCopy=ge()??!1}),De(()=>{m.autoHandleCopy=ye()??!0}),De(()=>{m.autoHandleMove=A()??!0}),De(()=>{m.autoHandlePaste=re()??!0}),De(()=>{m.accordionExpand=ae()??!1}),De(()=>{m.hasContextMenuSnippet=!!Se()}),De(()=>{m.clickBehavior=xe()??"expand-and-focus"}),De(()=>{m.showCheckboxes=tt()??!1}),De(()=>{m.checkboxMode=_e()??"independent"}),De(()=>{m.beforeCheckboxToggleHandler=Z()}),De(()=>{m.rangeSelectionMode=pe()??"visual"}),De(()=>{m.expandIconClass=ot()??"ltree-icon-expand"}),De(()=>{m.collapseIconClass=it()??"ltree-icon-collapse"}),De(()=>{m.leafIconClass=P()??"ltree-icon-leaf"}),De(()=>{m.toggleIconMode=w()??"rotate"}),De(()=>{m.highlightedNodeClass=E()}),De(()=>{m.focusedNodeClass=he()}),De(()=>{m.dragOverNodeClass=Ee()}),De(()=>{m.dropZoneMode=Y()??"glow"}),De(()=>{m.dropZoneLayout=Q()??"around"}),De(()=>{m.dropZoneStart=Pe()??33}),De(()=>{m.dropZoneMaxWidth=Ne()??120}),De(()=>{m.scrollHighlightTimeout=be()??4e3}),De(()=>{m.scrollHighlightClass=ze()??"ltree-scroll-highlight"}),De(()=>{m.contextMenuXOffset=Le()??8}),De(()=>{m.contextMenuYOffset=rt()??0}),De(()=>{m.onNodeClickHandler=Me()}),De(()=>{m.onHighlightChangeHandler=ke()}),De(()=>{m.onSelectionChangeHandler=He()}),De(()=>{m.onNodeDragStartHandler=Xe()}),De(()=>{m.onNodeDragOverHandler=ut()}),De(()=>{m.onNodeDropHandler=T()}),De(()=>{m.beforeDropHandler=ee()}),De(()=>{m.beforeCopyHandler=Te()}),De(()=>{m.beforeCutHandler=Ae()}),De(()=>{m.beforePasteHandler=Ie()}),De(()=>{m.getContextMenuItemsHandler=we()}),De(()=>{m.onRenderStartHandler=e.onRenderStart}),De(()=>{m.onRenderProgressHandler=e.onRenderProgress}),De(()=>{m.onRenderCompleteHandler=e.onRenderComplete}),De(()=>{ce(m.focusedNode)}),De(()=>{G(m.highlightedPaths)}),De(()=>{N(m.selectedPaths)}),De(()=>{W(m.insertResult)}),De(()=>{nt(m.isRendering)}),De(()=>{m.focusedNode=ce()}),De(()=>{const S=G(),Re=m.highlightedPaths;(S.size!==Re.size||[...S].some(xt=>!Re.has(xt)))&&(m.highlightedPaths=new Set(S))}),De(()=>{const S=N(),Re=m.selectedPaths;(S.size!==Re.size||[...S].some(xt=>!Re.has(xt)))&&(m.selectedPaths=new Set(S))});const Ye=me(()=>typeof m.dropZoneStart=="number"?`${m.dropZoneStart}%`:m.dropZoneStart);async function Mt(S){m.expandNodes(S)}async function Ot(S){m.collapseNodes(S)}function J(S){m.expandAll(S)}function fe(S){m.collapseAll(S)}function dt(S,Re){m.filterNodes(S,Re)}function Ue(S,Re){return m.searchNodes(S,Re)}function Je(S){return m.getChildren(S)}function Nt(S){return m.getSiblings(S)}function Et(S){m.refreshSiblings(S)}function st(S){m.refreshNode(S)}function At(S){return m.getNodeByPath(S)}function an(S,Re,xt){return m.moveNode(S,Re,xt)}function gn(S,Re=!0){return m.removeNode(S,Re)}function Xt(S,Re,xt){return m.addNode(S,Re,xt)}function on(S,Re){return m.updateNode(S,Re)}function Bt(S){return m.applyChanges(S)}function Pt(S,Re){return m.insertBranch(S,Re)}function hn(S,Re){return m.replaceBranch(S,Re)}function Lt(S,Re){return m.deleteBranch(S,Re)}function bt(S,Re,xt,It,In){return m.copyNodeWithDescendants(S,Re,xt,It,In)}function wn(){return m.getExpandedPaths()}function Vt(S){m.setExpandedPaths(S)}function _n(){return m.getAllData()}function Kt(){m.closeContextMenu()}function en(S,Re="replace"){m.selectNode(S,Re)}function tn(S){m.selectNodes(S)}function bn(){m.deselectAll()}function xn(){return m.getSelectedNodes()}function Jt(S){return m.isNodeSelected(S)}async function Qt(S,Re){return m.scrollToPath(S,Re)}function vn(S){S.treeId!==void 0&&n(S.treeId),S.treePathSeparator!==void 0&&r(S.treePathSeparator),S.idMember!==void 0&&i(S.idMember),S.pathMember!==void 0&&a(S.pathMember),S.parentPathMember!==void 0&&o(S.parentPathMember),S.levelMember!==void 0&&l(S.levelMember),S.hasChildrenMember!==void 0&&c(S.hasChildrenMember),S.isExpandedMember!==void 0&&d(S.isExpandedMember),S.isSelectableMember!==void 0&&h(S.isSelectableMember),S.isSelectedMember!==void 0&&p(S.isSelectedMember),S.isDraggableMember!==void 0&&y(S.isDraggableMember),S.getIsDraggableCallback!==void 0&&k(S.getIsDraggableCallback),S.isDropAllowedMember!==void 0&&C(S.isDropAllowedMember),S.displayValueMember!==void 0&&I(S.displayValueMember),S.getDisplayValueCallback!==void 0&&O(S.getDisplayValueCallback),S.searchValueMember!==void 0&&j(S.searchValueMember),S.getSearchValueCallback!==void 0&&K(S.getSearchValueCallback),S.isCollapsibleMember!==void 0&&_(S.isCollapsibleMember),S.getIsCollapsibleCallback!==void 0&&v(S.getIsCollapsibleCallback),S.orderMember!==void 0&&U(S.orderMember),S.isSorted!==void 0&&V(S.isSorted),S.sortCallback!==void 0&&se(S.sortCallback),S.data!==void 0&&oe(S.data),S.focusedNode!==void 0&&ce(S.focusedNode),S.highlightedPaths!==void 0&&G(S.highlightedPaths),S.selectedPaths!==void 0&&N(S.selectedPaths),S.expandLevel!==void 0&&Ce(S.expandLevel),S.clickBehavior!==void 0&&xe(S.clickBehavior),S.showCheckboxes!==void 0&&tt(S.showCheckboxes),S.checkboxMode!==void 0&&_e(S.checkboxMode),S.beforeCheckboxToggleCallback!==void 0&&Z(S.beforeCheckboxToggleCallback),S.rangeSelectionMode!==void 0&&pe(S.rangeSelectionMode),S.shouldUseInternalSearchIndex!==void 0&&ve(S.shouldUseInternalSearchIndex),S.initializeIndexCallback!==void 0&&Ke(S.initializeIndexCallback),S.searchText!==void 0&&Oe(S.searchText),S.indexerBatchSize!==void 0&&je(S.indexerBatchSize),S.indexerTimeout!==void 0&&Ge(S.indexerTimeout),S.shouldDisplayDebugInformation!==void 0&&et(S.shouldDisplayDebugInformation),S.shouldDisplayContextMenuInDebugMode!==void 0&&$e(S.shouldDisplayContextMenuInDebugMode),S.onNodeClick!==void 0&&Me(S.onNodeClick),S.onHighlightChange!==void 0&&ke(S.onHighlightChange),S.onSelectionChange!==void 0&&He(S.onSelectionChange),S.onNodeDragStart!==void 0&&Xe(S.onNodeDragStart),S.onNodeDragOver!==void 0&&ut(S.onNodeDragOver),S.onNodeDrop!==void 0&&T(S.onNodeDrop),S.beforeDropCallback!==void 0&&ee(S.beforeDropCallback),S.beforeCopyCallback!==void 0&&Te(S.beforeCopyCallback),S.beforeCutCallback!==void 0&&Ae(S.beforeCutCallback),S.beforePasteCallback!==void 0&&Ie(S.beforePasteCallback),S.getContextMenuItemsCallback!==void 0&&we(S.getContextMenuItemsCallback),S.virtualScroll!==void 0&&H(S.virtualScroll),S.virtualRowHeight!==void 0&&ne(S.virtualRowHeight),S.virtualOverscan!==void 0&&F(S.virtualOverscan),S.virtualContainerHeight!==void 0&&M(S.virtualContainerHeight),S.dragDropMode!==void 0&&R(S.dragDropMode),S.dropZoneMode!==void 0&&Y(S.dropZoneMode),S.bodyClass!==void 0&&Ve(S.bodyClass),S.expandIconClass!==void 0&&ot(S.expandIconClass),S.collapseIconClass!==void 0&&it(S.collapseIconClass),S.leafIconClass!==void 0&&P(S.leafIconClass),S.toggleIconMode!==void 0&&w(S.toggleIconMode),S.highlightedNodeClass!==void 0&&E(S.highlightedNodeClass),S.focusedNodeClass!==void 0&&he(S.focusedNodeClass),S.dragOverNodeClass!==void 0&&Ee(S.dragOverNodeClass),S.scrollHighlightTimeout!==void 0&&be(S.scrollHighlightTimeout),S.scrollHighlightClass!==void 0&&ze(S.scrollHighlightClass),S.contextMenuXOffset!==void 0&&Le(S.contextMenuXOffset),S.contextMenuYOffset!==void 0&&rt(S.contextMenuYOffset),S.accordionExpand!==void 0&&ae(S.accordionExpand)}function pn(S){if(["Control","Shift","Alt","Meta"].includes(S.key)||m.contextMenuVisible)return;if(e.onTreeKeydown?.(S,m)===!0){S.preventDefault();return}if(m.allFlatNodes.length===0)return;let Re=!0;switch(S.key){case"ArrowDown":S.shiftKey?m.navHighlightNext():m.navNextSibling();break;case"ArrowUp":S.shiftKey?m.navHighlightPrev():m.navPrevSibling();break;case"ArrowRight":m.navInto();break;case"ArrowLeft":m.navOut();break;case"Backspace":m.navBackOut();break;case"Home":S.shiftKey?m.navHighlightFirst():m.navFirst();break;case"End":S.shiftKey?m.navHighlightLast():m.navLast();break;case"PageDown":S.shiftKey?m.navHighlightPageDown():m.navPageDown();break;case"PageUp":S.shiftKey?m.navHighlightPageUp():m.navPageUp();break;case"Enter":case" ":m.navToggle();break;default:Re=!1}Re&&S.preventDefault()}function $n(S){const Re=S.split("+").map(It=>It.trim());return{key:Re.pop().toLowerCase(),ctrl:Re.some(It=>It.toLowerCase()==="ctrl"),shift:Re.some(It=>It.toLowerCase()==="shift"),alt:Re.some(It=>It.toLowerCase()==="alt")}}function Bn(S,Re){for(const xt of S)if(!("divider"in xt)&&!(xt.isVisible===!1||xt.isDisabled)){if(xt.shortcut){const It=$n(xt.shortcut);if((Re.key.length===1?Re.key.toLowerCase():Re.key)===It.key&&Re.ctrlKey===It.ctrl&&Re.shiftKey===It.shift&&Re.altKey===It.alt)return xt}if(xt.children){const It=Bn(xt.children,Re);if(It)return It}}return null}async function er(S){if(!m.contextMenuVisible||!m.contextMenuNode||!we())return;if(S.key==="Escape"){m.closeContextMenu();return}const Re=we()(m.contextMenuNode,m.closeContextMenu.bind(m),m.getSelectedNodes()),xt=Bn(Re,S);if(xt){S.preventDefault();try{await xt.onclick?.()}catch(It){console.error("Context menu shortcut error:",It)}}}var ar={expandNodes:Mt,collapseNodes:Ot,expandAll:J,collapseAll:fe,filterNodes:dt,searchNodes:Ue,getChildren:Je,getSiblings:Nt,refreshSiblings:Et,refreshNode:st,getNodeByPath:At,moveNode:an,removeNode:gn,addNode:Xt,updateNode:on,applyChanges:Bt,insertBranch:Pt,replaceBranch:hn,deleteBranch:Lt,copyNodeWithDescendants:bt,getExpandedPaths:wn,setExpandedPaths:Vt,getAllData:_n,closeContextMenu:Kt,selectNode:en,selectNodes:tn,deselectAll:bn,getSelectedNodes:xn,isNodeSelected:Jt,scrollToPath:Qt,update:vn},_t=vu();St("keydown",_o,er);var ht=g(_t);{var Ct=S=>{var Re=$h(),xt=g(Re),It=b(g(xt),2),In=g(It),ln=g(In);f(In);var yt=b(In,2),Ht=g(yt);f(yt);var jt=b(yt,2),$t=g(jt);f(jt);var Dt=b(jt,2),ft=g(Dt);f(Dt);var ct=b(Dt,2),gt=g(ct);f(ct);var pt=b(ct,2);{var En=Zt=>{var sn=Vh(),cn=g(sn);f(sn),te(()=>B(cn,`Filtered: ${m.tree.statistics.filteredNodeCount??""}`)),x(Zt,sn)};q(pt,Zt=>{m.tree?.statistics.filteredNodeCount>0&&Zt(En)})}var zt=b(pt,2);{var Rt=Zt=>{var sn=Kh(),cn=g(sn);f(sn),te(()=>B(cn,`Indexing: ${m.tree.statistics.pendingIndexCount??""} pending`)),x(Zt,sn)};q(zt,Zt=>{m.tree?.statistics.isIndexing&&Zt(Rt)})}var un=b(zt,2),rn=g(un);f(un),f(It),f(xt),f(Re),te(()=>{B(ln,`Tree: ${m.treeId??""}`),B(Ht,`Data: ${(m.data?.length||0)??""}`),B($t,`Expand level: ${(Ce()||0)??""}`),B(ft,`Nodes: ${(m.tree?.statistics.nodeCount||0)??""}`),B(gt,`Levels: ${(m.tree?.statistics.maxLevel||0)??""}`),B(rn,`Dragging: ${(m.draggedNode?.path||"none")??""}`)}),x(S,Re)};q(ht,S=>{m.shouldDisplayDebugInformation&&S(Ct)})}var nn=b(ht,2);On(nn,()=>X()??gr);var Mn=b(nn,2);{var tr=S=>{var Re=Uh(),xt=g(Re);{var It=ln=>{var yt=Ft(),Ht=qe(yt);On(Ht,de),x(ln,yt)},In=ln=>{var yt=Zh();x(ln,yt)};q(xt,ln=>{de()?ln(It):ln(In,-1)})}f(Re),x(S,Re)};q(Mn,S=>{m.isLoading&&S(tr)})}var Zn=b(Mn,2),Nr=g(Zn);{var Dr=S=>{var Re=Ft(),xt=qe(Re);{var It=yt=>{var Ht=Yh(),jt=g(Ht),$t=g(jt);kt($t,23,()=>m.flatNodesToRender,Dt=>Dt.id+"|"+Dt.path+"|"+Dt.hasChildren+"|"+Dt._rev,(Dt,ft,ct)=>{const gt=me(()=>m.vsStartIndex+s(ct)),pt=me(()=>s(gt)>0?m.allFlatNodes[s(gt)-1]:null);{let En=me(()=>m.draggedNode?.path===s(ft).path),zt=me(()=>m.hoveredNodeForDrop?.path),Rt=me(()=>s(pt)!=null&&(s(ft).level??0)>(s(pt).level??0));Si(Dt,{get node(){return s(ft)},get children(){return z()},progressiveRender:!1,get isDraggedNode(){return s(En)},get isDragInProgress(){return m.isDragInProgress},get hoveredNodeForDropPath(){return s(zt)},get activeDropPosition(){return m.activeDropPosition},get dropOperation(){return m.currentDropOperation},flatMode:!0,get flatGap(){return s(Rt)}})}},Dt=>{var ft=Gh();let ct;var gt=g(ft);{var pt=zt=>{var Rt=Ft(),un=qe(Rt);{var rn=sn=>{var cn=Ft(),jn=qe(cn);On(jn,ie),x(sn,cn)},Zt=sn=>{var cn=Wh();x(sn,cn)};q(un,sn=>{ie()?sn(rn):sn(Zt,-1)})}x(zt,Rt)},En=zt=>{var Rt=Ft(),un=qe(Rt);On(un,()=>ue()??gr),x(zt,Rt)};q(gt,zt=>{m.isDropPlaceholderActive?zt(pt):zt(En,-1)})}f(ft),te(()=>ct=at(ft,1,"ltree-empty-state",null,ct,{"ltree-drop-placeholder":m.isDropPlaceholderActive})),St("dragenter",ft,function(...zt){m.handleEmptyTreeDragOver?.apply(this,zt)}),St("dragover",ft,function(...zt){m.handleEmptyTreeDragOver?.apply(this,zt)}),St("dragleave",ft,function(...zt){m.handleEmptyTreeDragLeave?.apply(this,zt)}),St("drop",ft,function(...zt){m.handleEmptyTreeDrop?.apply(this,zt)}),Be("touchend",ft,function(...zt){m.handleEmptyTreeTouchEnd?.apply(this,zt)}),x(Dt,ft)}),f($t),f(jt),f(Ht),ei(Ht,Dt=>m.vsContainerRef=Dt,()=>m?.vsContainerRef),te(()=>{ir(Ht,`height: ${m.vsContainerStyle??""}; overflow-y: auto;`),ir(jt,`height: ${m.vsTotalHeight??""}px; position: relative;`),ir($t,`transform: translateY(${m.vsOffsetY??""}px);`)}),St("scroll",Ht,function(...Dt){m.handleVirtualScroll?.apply(this,Dt)}),x(yt,Ht)},In=yt=>{var Ht=Qh();kt(Ht,23,()=>m.flatNodesToRender,jt=>jt.id+"|"+jt.path+"|"+jt.hasChildren+"|"+jt._rev,(jt,$t,Dt)=>{const ft=me(()=>s(Dt)>0?m.flatNodesToRender[s(Dt)-1]:null);{let ct=me(()=>m.draggedNode?.path===s($t).path),gt=me(()=>m.hoveredNodeForDrop?.path),pt=me(()=>s(ft)!=null&&(s($t).level??0)>(s(ft).level??0));Si(jt,{get node(){return s($t)},get children(){return z()},progressiveRender:!1,get isDraggedNode(){return s(ct)},get isDragInProgress(){return m.isDragInProgress},get hoveredNodeForDropPath(){return s(gt)},get activeDropPosition(){return m.activeDropPosition},get dropOperation(){return m.currentDropOperation},flatMode:!0,get flatGap(){return s(pt)}})}},jt=>{var $t=Jh();let Dt;var ft=g($t);{var ct=pt=>{var En=Ft(),zt=qe(En);{var Rt=rn=>{var Zt=Ft(),sn=qe(Zt);On(sn,ie),x(rn,Zt)},un=rn=>{var Zt=Xh();x(rn,Zt)};q(zt,rn=>{ie()?rn(Rt):rn(un,-1)})}x(pt,En)},gt=pt=>{var En=Ft(),zt=qe(En);On(zt,()=>ue()??gr),x(pt,En)};q(ft,pt=>{m.isDropPlaceholderActive?pt(ct):pt(gt,-1)})}f($t),te(()=>Dt=at($t,1,"ltree-empty-state",null,Dt,{"ltree-drop-placeholder":m.isDropPlaceholderActive})),St("dragenter",$t,function(...pt){m.handleEmptyTreeDragOver?.apply(this,pt)}),St("dragover",$t,function(...pt){m.handleEmptyTreeDragOver?.apply(this,pt)}),St("dragleave",$t,function(...pt){m.handleEmptyTreeDragLeave?.apply(this,pt)}),St("drop",$t,function(...pt){m.handleEmptyTreeDrop?.apply(this,pt)}),Be("touchend",$t,function(...pt){m.handleEmptyTreeTouchEnd?.apply(this,pt)}),x(jt,$t)}),f(Ht),x(yt,Ht)},ln=yt=>{var Ht=Ft(),jt=qe(Ht);xo(jt,()=>m.tree.changeTracker,$t=>{var Dt=tu();kt(Dt,21,()=>m.tree.tree,ft=>ft.id,(ft,ct)=>{{let gt=me(()=>m.draggedNode?.path===s(ct).path),pt=me(()=>m.hoveredNodeForDrop?.path);Si(ft,{get node(){return s(ct)},get children(){return z()},get progressiveRender(){return m.progressiveRender},get renderBatchSize(){return m.initialBatchSize},get isDraggedNode(){return s(gt)},get isDragInProgress(){return m.isDragInProgress},get hoveredNodeForDropPath(){return s(pt)},get activeDropPosition(){return m.activeDropPosition},get dropOperation(){return m.currentDropOperation}})}},ft=>{var ct=eu();let gt;var pt=g(ct);{var En=Rt=>{var un=Ft(),rn=qe(un);{var Zt=cn=>{var jn=Ft(),mr=qe(jn);On(mr,ie),x(cn,jn)},sn=cn=>{var jn=qh();x(cn,jn)};q(rn,cn=>{ie()?cn(Zt):cn(sn,-1)})}x(Rt,un)},zt=Rt=>{var un=Ft(),rn=qe(un);On(rn,()=>ue()??gr),x(Rt,un)};q(pt,Rt=>{m.isDropPlaceholderActive?Rt(En):Rt(zt,-1)})}f(ct),te(()=>gt=at(ct,1,"ltree-empty-state",null,gt,{"ltree-drop-placeholder":m.isDropPlaceholderActive})),St("dragenter",ct,function(...Rt){m.handleEmptyTreeDragOver?.apply(this,Rt)}),St("dragover",ct,function(...Rt){m.handleEmptyTreeDragOver?.apply(this,Rt)}),St("dragleave",ct,function(...Rt){m.handleEmptyTreeDragLeave?.apply(this,Rt)}),St("drop",ct,function(...Rt){m.handleEmptyTreeDrop?.apply(this,Rt)}),Be("touchend",ct,function(...Rt){m.handleEmptyTreeTouchEnd?.apply(this,Rt)}),x(ft,ct)}),f(Dt),x($t,Dt)}),x(yt,Ht)};q(xt,yt=>{m.vsActive?yt(It):m.useFlatRendering?yt(In,1):yt(ln,-1)})}x(S,Re)},Hi=S=>{var Re=ru();let xt;var It=g(Re);{var In=yt=>{var Ht=Ft(),jt=qe(Ht);{var $t=ft=>{var ct=Ft(),gt=qe(ct);On(gt,ie),x(ft,ct)},Dt=ft=>{var ct=nu();x(ft,ct)};q(jt,ft=>{ie()?ft($t):ft(Dt,-1)})}x(yt,Ht)},ln=yt=>{var Ht=Ft(),jt=qe(Ht);On(jt,()=>ue()??gr),x(yt,Ht)};q(It,yt=>{m.isDropPlaceholderActive?yt(In):yt(ln,-1)})}f(Re),te(()=>xt=at(Re,1,"ltree-empty-state",null,xt,{"ltree-drop-placeholder":m.isDropPlaceholderActive})),St("dragenter",Re,function(...yt){m.handleEmptyTreeDragOver?.apply(this,yt)}),St("dragover",Re,function(...yt){m.handleEmptyTreeDragOver?.apply(this,yt)}),St("dragleave",Re,function(...yt){m.handleEmptyTreeDragLeave?.apply(this,yt)}),St("drop",Re,function(...yt){m.handleEmptyTreeDrop?.apply(this,yt)}),Be("touchend",Re,function(...yt){m.handleEmptyTreeTouchEnd?.apply(this,yt)}),x(S,Re)};q(Nr,S=>{m.tree?.root?S(Dr):S(Hi,-1)})}f(Zn);var Cs=b(Zn,2);On(Cs,()=>le()??gr);var Ss=b(Cs,2);{var Ra=S=>{var Re=ou(),xt=g(Re);{var It=ft=>{var ct=iu();let gt;te(()=>gt=at(ct,1,"ltree-drop-zone ltree-drop-before",null,gt,{"ltree-drop-zone-active":m.floatingHoveredZone==="before"})),St("dragover",ct,pt=>m.handleFloatingZoneDragOver("before",pt)),St("dragleave",ct,()=>m.handleFloatingZoneDragLeave()),St("drop",ct,pt=>m.handleFloatingZoneDrop("before",pt)),x(ft,ct)},In=me(()=>m.isFloatingPositionAllowed("before"));q(xt,ft=>{s(In)&&ft(It)})}var ln=b(xt,2);{var yt=ft=>{var ct=su();let gt;te(()=>gt=at(ct,1,"ltree-drop-zone ltree-drop-after",null,gt,{"ltree-drop-zone-active":m.floatingHoveredZone==="after"})),St("dragover",ct,pt=>m.handleFloatingZoneDragOver("after",pt)),St("dragleave",ct,()=>m.handleFloatingZoneDragLeave()),St("drop",ct,pt=>m.handleFloatingZoneDrop("after",pt)),x(ft,ct)},Ht=me(()=>m.isFloatingPositionAllowed("after"));q(ln,ft=>{s(Ht)&&ft(yt)})}var jt=b(ln,2);{var $t=ft=>{var ct=au();let gt;te(()=>gt=at(ct,1,"ltree-drop-zone ltree-drop-child",null,gt,{"ltree-drop-zone-active":m.floatingHoveredZone==="child"})),St("dragover",ct,pt=>m.handleFloatingZoneDragOver("child",pt)),St("dragleave",ct,()=>m.handleFloatingZoneDragLeave()),St("drop",ct,pt=>m.handleFloatingZoneDrop("child",pt)),x(ft,ct)},Dt=me(()=>m.isFloatingPositionAllowed("child"));q(jt,ft=>{s(Dt)&&ft($t)})}f(Re),te(()=>{at(Re,1,`ltree-drop-zones ltree-drop-zones-${m.dropZoneLayout??""}`),ir(Re,`position: fixed; top: ${m.floatingZoneRect.top??""}px; left: ${m.floatingZoneRect.left??""}px; width: ${m.floatingZoneRect.width??""}px; height: ${m.floatingZoneRect.height??""}px; z-index: 10000; --drop-zone-start: ${s(Ye)??""}; --drop-zone-max-width: ${m.dropZoneMaxWidth??""}px;`)}),x(S,Re)};q(Ss,S=>{m.dropZoneMode==="floating"&&m.isDragInProgress&&m.hoveredNodeForDrop&&m.floatingZoneRect&&S(Ra)})}var Oa=b(Ss,2);{var La=S=>{var Re=gu(),xt=g(Re);{var It=ln=>{const yt=(jt,$t=gr)=>{var Dt=Ft(),ft=qe(Dt);kt(ft,17,$t,Tt,(ct,gt)=>{var pt=Ft(),En=qe(pt);{var zt=un=>{var rn=cu(),Zt=g(rn);{var sn=cn=>{var jn=lu(),mr=g(jn,!0);f(jn),te(()=>B(mr,s(gt).label)),x(cn,jn)};q(Zt,cn=>{s(gt).label&&cn(sn)})}f(rn),x(un,rn)},Rt=un=>{const rn=me(()=>s(gt).children&&s(gt).children.length>0);var Zt=fu();let sn;var cn=g(Zt);{var jn=Cn=>{var Vn=du(),Pr=g(Vn,!0);f(Vn),te(()=>B(Pr,s(gt).icon)),x(Cn,Vn)};q(cn,Cn=>{s(gt).icon&&Cn(jn)})}var mr=b(cn,2),Ha=g(mr,!0);f(mr);var Ns=b(mr,2);{var za=Cn=>{var Vn=hu(),Pr=g(Vn,!0);f(Vn),te(()=>B(Pr,s(gt).shortcut)),x(Cn,Vn)};q(Ns,Cn=>{s(gt).shortcut&&Cn(za)})}var Fa=b(Ns,2);{var Ba=Cn=>{var Vn=uu(),Pr=b(qe(Vn),2),ja=g(Pr);yt(ja,()=>s(gt).children),f(Pr),x(Cn,Vn)};q(Fa,Cn=>{s(rn)&&Cn(Ba)})}f(Zt),te(()=>{sn=at(Zt,1,`ltree-context-menu-item ${(s(gt).className||"")??""}`,null,sn,{"ltree-context-menu-item-disabled":s(gt).isDisabled,"ltree-context-menu-has-children":s(rn)}),An(Zt,"tabindex",s(gt).isDisabled?-1:0),B(Ha,s(gt).label)}),Be("click",Zt,async()=>{if(!s(gt).isDisabled&&!s(rn))try{await s(gt).onclick?.()}catch(Cn){console.error("Context menu callback error:",Cn)}}),Be("keydown",Zt,async Cn=>{if((Cn.key==="Enter"||Cn.key===" ")&&!s(gt).isDisabled&&!s(rn)){Cn.preventDefault();try{await s(gt).onclick?.()}catch(Vn){console.error("Context menu callback error:",Vn)}}}),x(un,Zt)};q(En,un=>{"divider"in s(gt)?un(zt):s(gt).isVisible!==!1&&un(Rt,1)})}x(ct,pt)}),x(jt,Dt)},Ht=me(()=>we()(m.contextMenuNode,m.closeContextMenu.bind(m),m.getSelectedNodes()));yt(ln,()=>s(Ht))},In=ln=>{var yt=Ft(),Ht=qe(yt);{let jt=me(()=>m.closeContextMenu.bind(m));On(Ht,Se,()=>m.contextMenuNode,()=>s(jt))}x(ln,yt)};q(xt,ln=>{we()?ln(It):Se()&&ln(In,1)})}f(Re),te(()=>ir(Re,`left: ${m.contextMenuX??""}px; top: ${m.contextMenuY??""}px;`)),x(S,Re)};q(Oa,S=>{m.contextMenuVisible&&m.contextMenuNode&&S(La)})}return f(_t),ei(_t,S=>Ze=S,()=>Ze),te(()=>at(Zn,1,To(m.bodyClass))),Be("keydown",_t,pn),St("dragenter",_t,function(...S){m.handleTreeDragEnter?.apply(this,S)}),St("dragleave",_t,function(...S){m.handleTreeDragLeave?.apply(this,S)}),St("dragend",_t,function(...S){m._onNodeDragEnd?.apply(this,S)}),x(t,_t),Pn(ar)}Fn(["keydown","touchend","click"]);var yu=D('<div><span class="json-key svelte-19sik8e"> </span> <span class="json-separator svelte-19sik8e">:</span> <span> </span></div>'),mu=D('<div class="json-tree svelte-19sik8e"><!></div>');function Aa(t,e){Dn(e,!0);let n=$(e,"expandLevel",3,2);function r(y){return y===null?"null":Array.isArray(y)?"array":typeof y=="object"?"object":typeof y=="string"?"string":typeof y=="number"?"number":typeof y=="boolean"?"boolean":"string"}function i(y){return y.replaceAll(".","\\.")}function a(y){return typeof y=="string"?JSON.stringify(y):y===void 0?"undefined":String(y)}function o(y){if(Array.isArray(y))return{value:y.length===0?"[]":`Array(${y.length})`,count:y.length};if(y&&typeof y=="object"){const k=Object.keys(y).length;return{value:k===0?"{}":`Object(${k})`,count:k}}return{value:a(y),count:0}}function l(y,k,C,_){const v=r(C),I=o(C);if(y.push({id:_,path:_,key:k,value:v==="object"||v==="array"?I.value:a(C),type:v,count:I.count}),Array.isArray(C)){C.forEach((O,j)=>l(y,`[${j}]`,O,`${_}.${j}`));return}if(C&&typeof C=="object")for(const[O,j]of Object.entries(C))l(y,O,j,`${_}.${i(O)}`)}function c(y){const k=[];return l(k,"root",y,"root"),k}let d=me(()=>c(e.value));var h=mu(),p=g(h);pu(p,{get data(){return s(d)},idMember:"id",pathMember:"path",displayValueMember:"key",get expandLevel(){return n()},clickBehavior:"expand-and-focus",dragDropMode:"none",nodeTemplate:(k,C=gr)=>{const _=me(()=>C().data);var v=Ft(),I=qe(v);{var O=j=>{var K=yu();let U;var V=g(K),se=g(V,!0);f(V);var oe=b(V,4);let ce;var G=g(oe,!0);f(oe),f(K),te(()=>{U=at(K,1,"json-row svelte-19sik8e",null,U,{branch:s(_).type==="object"||s(_).type==="array"}),B(se,s(_).key),ce=at(oe,1,"json-value svelte-19sik8e",null,ce,{"type-string":s(_).type==="string","type-number":s(_).type==="number","type-boolean":s(_).type==="boolean","type-null":s(_).type==="null"}),B(G,s(_).value)}),x(j,K)};q(I,j=>{s(_)&&j(O)})}x(k,v)},$$slots:{nodeTemplate:!0}}),f(h),x(t,h),Pn()}var _u=D('<button type="button"> <span class="svelte-6ezzcw"> </span></button>'),bu=D('<button type="button"> <span class="svelte-6ezzcw"> </span></button>'),ku=D('<nav class="proj-type-tabs svelte-6ezzcw" aria-label="Analysis plan subtype"><button type="button">All plan types <span class="svelte-6ezzcw"> </span></button> <!></nav>'),wu=D('<p class="error svelte-6ezzcw"> </p>'),xu=D('<p class="muted svelte-6ezzcw">Loading workspace artifacts...</p>'),Cu=D('<p class="muted svelte-6ezzcw"> </p>'),Su=D('<p class="muted svelte-6ezzcw">No artifacts match this filter.</p>'),Nu=D('<span class="title-prefix svelte-6ezzcw">Analysis plan:</span>'),Du=D('<span class="content svelte-6ezzcw"> </span>'),Pu=D('<span class="tag svelte-6ezzcw"> </span>'),Iu=D('<span class="scope svelte-6ezzcw"> </span>'),Tu=D('<button type="button" class="svelte-6ezzcw">Pack context</button>'),Mu=D('<button type="button" class="svelte-6ezzcw">Focus graph</button>'),Eu=D('<button type="button" class="svelte-6ezzcw">Refresh live</button>'),Au=D('<li><button type="button" class="row-button svelte-6ezzcw"><span class="row-title svelte-6ezzcw"><!> </span> <!></button> <div class="row-meta svelte-6ezzcw"><!> <!></div> <div class="row-actions svelte-6ezzcw"><button type="button" class="svelte-6ezzcw"> </button> <!> <!> <!></div></li>'),Ru=D('<ul class="rows svelte-6ezzcw"></ul>'),Ou=D('<section class="type-group svelte-6ezzcw"><header class="svelte-6ezzcw"><button type="button" class="group-toggle svelte-6ezzcw"><span class="svelte-6ezzcw"> </span> <small class="svelte-6ezzcw"> </small></button></header> <!></section>'),Lu=D('<button type="button" class="svelte-6ezzcw">Refresh live</button>'),Hu=D('<button type="button" class="svelte-6ezzcw">Focus graph</button>'),zu=D('<p class="detail-line svelte-6ezzcw"> </p>'),Fu=D('<li class="svelte-6ezzcw"> </li>'),Bu=D('<h4 class="svelte-6ezzcw"> </h4> <ul class="detail-list svelte-6ezzcw"></ul>',1),ju=D('<p class="detail-line svelte-6ezzcw">No packed context rows returned for this scope.</p>'),Vu=D('<p class="detail-line svelte-6ezzcw"> </p>'),Ku=D('<li class="svelte-6ezzcw"><strong> </strong> <p class="svelte-6ezzcw"> </p></li>'),$u=D('<h4 class="svelte-6ezzcw"> </h4> <ul class="detail-list svelte-6ezzcw"></ul>',1),Zu=D('<li class="svelte-6ezzcw"> </li>'),Uu=D('<h4 class="svelte-6ezzcw"> </h4> <ul class="detail-list svelte-6ezzcw"></ul>',1),Wu=D('<li class="svelte-6ezzcw"><strong> </strong> <p class="svelte-6ezzcw"> </p></li>'),Gu=D('<h4 class="svelte-6ezzcw"> </h4> <ul class="detail-list svelte-6ezzcw"></ul>',1),Yu=D("<!> <!> <!> <!>",1),Xu=D('<header class="result-head svelte-6ezzcw"><div><h3 class="svelte-6ezzcw"> </h3> <p class="svelte-6ezzcw"> </p></div> <div class="result-actions svelte-6ezzcw"><!> <!></div></header> <!> <details class="svelte-6ezzcw"><summary class="svelte-6ezzcw">Technical details</summary> <!></details>',1),Ju=D('<p class="muted svelte-6ezzcw">Select an artifact.</p>'),Qu=D('<div class="projections svelte-6ezzcw"><header class="toolbar svelte-6ezzcw"><div><h2 class="svelte-6ezzcw">Projections</h2> <p class="svelte-6ezzcw"> </p></div> <div class="actions svelte-6ezzcw"><label class="search svelte-6ezzcw"><span class="svelte-6ezzcw">Filter</span> <input class="svelte-6ezzcw"/></label> <button type="button" class="svelte-6ezzcw">Refresh</button></div></header> <nav class="kind-tabs svelte-6ezzcw" aria-label="Projection artifact type"><button type="button">All <span class="svelte-6ezzcw"> </span></button> <!></nav> <!> <!> <div class="layout svelte-6ezzcw"><section class="catalog svelte-6ezzcw"><!></section> <section class="result svelte-6ezzcw"><!></section></div></div>');function qu(t,e){Dn(e,!0);const n=["analysis_plan","answer_snapshot","live_answer_view","evidence_pack"],r=["FACT","GOAL","STEP","CONSTRAINT"];let i=$(e,"workspaceId",3,""),a=$(e,"graphContext",19,()=>({})),o=$(e,"active",3,!1),l=$(e,"initialProjectionId",3,""),c=L(""),d=L("all"),h=L("all"),p=L(!1),y=L(!1),k=L(null),C=L(Ut([])),_=L(""),v=L(null),I=L(""),O=L(""),j=L(""),K=L(Ut({analysis_plan:!1,answer_snapshot:!0,live_answer_view:!0,evidence_pack:!0}));De(()=>{const P=U();o()&&P&&(s(I)!==P||s(O)!==s(c).trim())&&ue()}),De(()=>{l()&&l()!==s(j)&&(u(j,l()),Ce(l(),null))});function U(){return i().trim()||"default"}function V(P){return P.artifact_id??P.projection_id??P.id??(P.entity_id==null?void 0:String(P.entity_id))??Ln(P)}function se(P){return P.artifact_kind??P.type??"artifact"}function oe(){return s(C).filter(P=>s(h)!=="all"?se(P)==="analysis_plan"&&P.proj_type===s(h):!(s(d)!=="all"&&se(P)!==s(d)))}function ce(){const P=new Map;for(const w of n)P.set(w,[]);for(const w of oe()){const E=se(w);P.set(E,[...P.get(E)??[],w])}return[...P.entries()].filter(([,w])=>w.length>0)}function G(P){return s(C).filter(w=>se(w)===P).length}function N(P){return s(C).filter(w=>se(w)==="analysis_plan"&&w.proj_type===P).length}function W(P){return s(K)[P]??!0}function z(P){u(K,{...s(K),[P]:!W(P)},!0)}function X(P){u(d,P,!0),u(h,"all"),P!=="all"&&u(K,{...s(K),[P]:!0},!0)}function le(P){u(d,"analysis_plan"),u(h,P,!0),u(K,{...s(K),analysis_plan:!0},!0)}async function ue(){const P=U();u(p,!0),u(k,null);try{const w=new URLSearchParams({workspace_id:P,limit:"1000"});s(c).trim()&&w.set("search",s(c).trim());const E=await fetch(`/api/projections/catalog?${w}`);if(!E.ok)throw new Error(await E.text());const he=await E.json();u(C,ma(he),!0),u(I,P,!0),u(O,s(c).trim(),!0);const Ee=s(_)?s(C).find(ze=>V(ze)===s(_)):null,be=s(j)?s(C).find(ze=>ze.projection_id===s(j)):null;if(be&&!Ee)u(_,V(be),!0);else if(!Ee){const ze=s(C)[0];u(_,ze?V(ze):"",!0),u(v,null),ze&&Se(ze)}}catch(w){u(k,w instanceof Error?w.message:String(w),!0),u(C,[],!0),u(v,null)}finally{u(p,!1)}}async function Se(P){if(u(_,V(P),!0),se(P)==="answer_snapshot"&&P.projection_id){await Ce(P.projection_id,P);return}if(P.artifact_id){await de(P);return}u(v,{kind:"artifact",row:P,title:Ln(P),raw:P.raw},!0)}async function ie(P){const w=P.scope?.trim();if(w){u(_,V(P),!0),u(p,!0),u(k,null);try{const E=new URLSearchParams({agent_id:"agent:self",workspace_id:U(),scope:w,query:Ln(P),limit:"12"}),he=await fetch(`/api/brain/ghostcrab/pack-projections?${E}`);if(!he.ok)throw new Error(await he.text());u(v,{kind:"pack",row:P,title:`${Ln(P)} context`,raw:await he.json()},!0)}catch(E){u(k,E instanceof Error?E.message:String(E),!0)}finally{u(p,!1)}}}async function de(P){if(P.artifact_id){u(p,!0),u(k,null);try{const w=new URLSearchParams({workspace_id:U()}),E=await fetch(`/api/brain/ghostcrab/artifact/${encodeURIComponent(P.artifact_id)}?${w}`);if(!E.ok){u(v,{kind:"artifact",row:P,title:Ln(P),raw:P.raw},!0);return}u(v,{kind:"artifact",row:P,title:Ln(P),raw:await E.json()},!0)}catch{u(v,{kind:"artifact",row:P,title:Ln(P),raw:P.raw},!0)}finally{u(p,!1)}}}async function Ce(P,w){const E=P.trim();if(E){u(p,!0),u(k,null);try{const he=new URLSearchParams({workspace_id:U(),projection_id:E,include_evidence:"true",include_deltas:"true"}),Ee=await fetch(`/api/brain/ghostcrab/projection-get?${he}`);if(!Ee.ok)throw new Error(await Ee.text());u(v,{kind:"snapshot",row:w,title:w?Ln(w):E,raw:await Ee.json()},!0)}catch(he){u(k,he instanceof Error?he.message:String(he),!0),u(v,w?{kind:"artifact",row:w,title:Ln(w),raw:w.raw}:null,!0)}finally{u(p,!1)}}}async function xe(P){if(!(!P.artifact_id||se(P)!=="live_answer_view")){u(y,!0),u(k,null);try{const w=new URLSearchParams({workspace_id:U()}),E=await fetch(`/api/brain/ghostcrab/artifact/${encodeURIComponent(P.artifact_id)}/refresh?${w}`,{method:"POST"});if(!E.ok)throw new Error(await E.text());await ue();const he=s(C).find(Ee=>Ee.artifact_id===P.artifact_id)??P;await Se(he)}catch(w){u(k,w instanceof Error?w.message:String(w),!0)}finally{u(y,!1)}}}function tt(){const P=s(v)?.row;P&&xe(P)}function _e(P){const w=P.raw,he=(w.metadata&&typeof w.metadata=="object"?w.metadata:null)?.source_plan_id;return typeof he=="string"&&he.trim()?he.trim():void 0}function Z(P){const w=P.entity_id!=null?[P.entity_id]:hr(P.raw);if(w.length>0)return w;if(!P.artifact_id)return[];const E=s(C).find(he=>se(he)==="answer_snapshot"&&_e(he)===P.artifact_id);return E?E.entity_id!=null?[E.entity_id]:hr(E.raw):[]}function pe(P){const w=Z(P);w.length>0&&e.onViewInGraph?.(w)}function ve(){if(!s(v))return;const P=s(v).kind==="snapshot"?hr(s(v).raw):Z(s(v).row);P.length>0&&e.onViewInGraph?.(P)}function Ke(){return s(v)?s(v).kind==="snapshot"?hr(s(v).raw):Z(s(v).row):[]}function Oe(){return s(v)?.kind==="snapshot"?s(v).raw:{}}function je(){const P=s(v)?.kind==="pack"?s(v).raw.rows:null;return Array.isArray(P)?P:[]}function Ge(){const P=Oe();return P.report?.has_projection??P.has_projection}function et(P){return[P.proj_type,P.lifecycle,P.state??P.status,P.current_version==null?void 0:`v${P.current_version}`,P.source==="legacy_projection"?"legacy":void 0].filter(w=>!!w)}function $e(P){return P.preview??P.content??P.public_label??""}function mt(P,w=320){const E=typeof P=="object"?JSON.stringify(P)??String(P):String(P);return E.length>w?`${E.slice(0,w)}...`:E}function vt(P){switch(se(P)){case"answer_snapshot":return"Open snapshot";case"live_answer_view":return"Open live answer";case"analysis_plan":return"Open plan";case"evidence_pack":return"Open evidence";default:return"Open"}}var Qe=Qu(),Fe=g(Qe),nt=g(Fe),lt=b(g(nt),2),H=g(lt);f(lt),f(nt);var ne=b(nt,2),F=g(ne),M=b(g(F),2);Tn(M),f(F);var R=b(F,2);f(ne),f(Fe);var Y=b(Fe,2),Q=g(Y);let Pe;var Ne=b(g(Q)),ge=g(Ne,!0);f(Ne),f(Q);var ye=b(Q,2);kt(ye,17,()=>n,Tt,(P,w)=>{var E=_u();let he;var Ee=g(E),be=b(Ee),ze=g(be,!0);f(be),f(E),te((Le,rt,m)=>{E.disabled=Le,he=at(E,1,"svelte-6ezzcw",null,he,{active:s(d)===s(w)&&s(h)==="all"}),B(Ee,`${rt??""} `),B(ze,m)},[()=>G(s(w))===0,()=>xi(s(w)),()=>G(s(w))]),Be("click",E,()=>X(s(w))),x(P,E)}),f(Y);var A=b(Y,2);{var re=P=>{var w=ku(),E=g(w);let he;var Ee=b(g(E)),be=g(Ee,!0);f(Ee),f(E);var ze=b(E,2);kt(ze,17,()=>r,Tt,(Le,rt)=>{var m=bu();let Ze;var Ye=g(m),Mt=b(Ye),Ot=g(Mt,!0);f(Mt),f(m),te((J,fe)=>{m.disabled=J,Ze=at(m,1,"svelte-6ezzcw",null,Ze,{active:s(h)===s(rt)}),B(Ye,`${s(rt)??""} `),B(Ot,fe)},[()=>N(s(rt))===0,()=>N(s(rt))]),Be("click",m,()=>le(s(rt))),x(Le,m)}),f(w),te(Le=>{he=at(E,1,"svelte-6ezzcw",null,he,{active:s(h)==="all"}),B(be,Le)},[()=>G("analysis_plan")]),Be("click",E,()=>X("analysis_plan")),x(P,w)},ae=me(()=>G("analysis_plan")>0);q(A,P=>{s(ae)&&P(re)})}var Me=b(A,2);{var ke=P=>{var w=wu(),E=g(w,!0);f(w),te(()=>B(E,s(k))),x(P,w)};q(Me,P=>{s(k)&&P(ke)})}var He=b(Me,2),Xe=g(He),ut=g(Xe);{var T=P=>{var w=xu();x(P,w)},ee=P=>{var w=Cu(),E=g(w);f(w),te(he=>B(E,`No projection artifacts found for workspace ${he??""} in this SQLite runtime.`),[()=>U()]),x(P,w)},Te=P=>{var w=Su();x(P,w)},Ae=me(()=>oe().length===0),Ie=P=>{var w=Ft(),E=qe(w);kt(E,17,ce,Tt,(he,Ee)=>{var be=me(()=>Wr(s(Ee),2));let ze=()=>s(be)[0],Le=()=>s(be)[1];var rt=Ou(),m=g(rt),Ze=g(m),Ye=g(Ze),Mt=g(Ye);f(Ye);var Ot=b(Ye,2),J=g(Ot,!0);f(Ot),f(Ze),f(m);var fe=b(m,2);{var dt=Je=>{var Nt=Ru();kt(Nt,21,Le,Et=>V(Et),(Et,st)=>{var At=Au();let an;var gn=g(At),Xt=g(gn),on=g(Xt);{var Bt=ht=>{var Ct=Nu();x(ht,Ct)},Pt=me(()=>se(s(st))==="analysis_plan");q(on,ht=>{s(Pt)&&ht(Bt)})}var hn=b(on);f(Xt);var Lt=b(Xt,2);{var bt=ht=>{var Ct=Du(),nn=g(Ct,!0);f(Ct),te(Mn=>B(nn,Mn),[()=>$e(s(st))]),x(ht,Ct)},wn=me(()=>$e(s(st)));q(Lt,ht=>{s(wn)&&ht(bt)})}f(gn);var Vt=b(gn,2),_n=g(Vt);kt(_n,17,()=>et(s(st)),Tt,(ht,Ct)=>{var nn=Pu(),Mn=g(nn,!0);f(nn),te(()=>B(Mn,s(Ct))),x(ht,nn)});var Kt=b(_n,2);{var en=ht=>{var Ct=Iu(),nn=g(Ct,!0);f(Ct),te(()=>B(nn,s(st).scope)),x(ht,Ct)};q(Kt,ht=>{s(st).scope&&ht(en)})}f(Vt);var tn=b(Vt,2),bn=g(tn),xn=g(bn,!0);f(bn);var Jt=b(bn,2);{var Qt=ht=>{var Ct=Tu();Be("click",Ct,()=>ie(s(st))),x(ht,Ct)},vn=me(()=>se(s(st))==="analysis_plan"&&s(st).scope);q(Jt,ht=>{s(vn)&&ht(Qt)})}var pn=b(Jt,2);{var $n=ht=>{var Ct=Mu();Be("click",Ct,()=>pe(s(st))),x(ht,Ct)},Bn=me(()=>Z(s(st)).length>0);q(pn,ht=>{s(Bn)&&ht($n)})}var er=b(pn,2);{var ar=ht=>{var Ct=Eu();te(()=>Ct.disabled=s(y)),Be("click",Ct,()=>xe(s(st))),x(ht,Ct)},_t=me(()=>se(s(st))==="live_answer_view");q(er,ht=>{s(_t)&&ht(ar)})}f(tn),f(At),te((ht,Ct,nn)=>{an=at(At,1,"svelte-6ezzcw",null,an,ht),B(hn,` ${Ct??""}`),B(xn,nn)},[()=>({highlight:_a(s(st),a()),selected:s(_)===V(s(st))}),()=>Ln(s(st)),()=>vt(s(st))]),Be("click",gn,()=>Se(s(st))),Be("click",bn,()=>Se(s(st))),x(Et,At)}),f(Nt),x(Je,Nt)},Ue=me(()=>W(ze()));q(fe,Je=>{s(Ue)&&Je(dt)})}f(rt),te((Je,Nt)=>{B(Mt,`${Je??""} ${Nt??""}`),B(J,Le().length)},[()=>W(ze())?"▼":"▶",()=>xi(ze())]),Be("click",Ze,()=>z(ze())),x(he,rt)}),x(P,w)};q(ut,P=>{s(p)&&s(C).length===0?P(T):s(C).length===0?P(ee,1):s(Ae)?P(Te,2):P(Ie,-1)})}f(Xe);var we=b(Xe,2),Ve=g(we);{var ot=P=>{var w=Xu(),E=qe(w),he=g(E),Ee=g(he),be=g(Ee,!0);f(Ee);var ze=b(Ee,2),Le=g(ze);f(ze),f(he);var rt=b(he,2),m=g(rt);{var Ze=st=>{var At=Lu();te(()=>At.disabled=s(y)),Be("click",At,tt),x(st,At)},Ye=me(()=>s(v).row&&se(s(v).row)==="live_answer_view");q(m,st=>{s(Ye)&&st(Ze)})}var Mt=b(m,2);{var Ot=st=>{var At=Hu();Be("click",At,ve),x(st,At)},J=me(()=>Ke().length>0);q(Mt,st=>{s(J)&&st(Ot)})}f(rt),f(E);var fe=b(E,2);{var dt=st=>{var At=Ft(),an=qe(At);{var gn=Xt=>{var on=zu(),Bt=g(on,!0);f(on),te(()=>B(Bt,s(v).row.preview??s(v).row.content)),x(Xt,on)};q(an,Xt=>{(s(v).row?.preview||s(v).row?.content)&&Xt(gn)})}x(st,At)},Ue=st=>{var At=Ft(),an=qe(At);{var gn=Bt=>{var Pt=Bu(),hn=qe(Pt),Lt=g(hn);f(hn);var bt=b(hn,2);kt(bt,21,()=>je().slice(0,12),Tt,(wn,Vt)=>{var _n=Fu(),Kt=g(_n,!0);f(_n),te(en=>B(Kt,en),[()=>mt(s(Vt))]),x(wn,_n)}),f(bt),te(wn=>B(Lt,`Context rows (${wn??""})`),[()=>je().length]),x(Bt,Pt)},Xt=me(()=>je().length>0),on=Bt=>{var Pt=ju();x(Bt,Pt)};q(an,Bt=>{s(Xt)?Bt(gn):Bt(on,-1)})}x(st,At)},Je=st=>{var At=Yu(),an=qe(At);{var gn=Kt=>{var en=Vu(),tn=g(en);f(en),te(bn=>B(tn,`has_projection: ${bn??""}`),[()=>String(Ge())]),x(Kt,en)},Xt=me(()=>Ge()!=null);q(an,Kt=>{s(Xt)&&Kt(gn)})}var on=b(an,2);{var Bt=Kt=>{var en=$u(),tn=qe(en),bn=g(tn);f(tn);var xn=b(tn,2);kt(xn,21,()=>Oe().projection_results?.slice(0,8)??[],Tt,(Jt,Qt)=>{var vn=Ku(),pn=g(vn),$n=g(pn,!0);f(pn);var Bn=b(pn,2),er=g(Bn,!0);f(Bn),f(vn),te((ar,_t)=>{B($n,ar),B(er,_t)},[()=>String(s(Qt).name??s(Qt).entity_type??"ProjectionResult"),()=>mt(s(Qt).metadata??s(Qt).metadata_json??s(Qt))]),x(Jt,vn)}),f(xn),te(Jt=>B(bn,`Snapshot results (${Jt??""})`),[()=>Oe().projection_results?.length]),x(Kt,en)},Pt=me(()=>Oe().projection_results?.length);q(on,Kt=>{s(Pt)&&Kt(Bt)})}var hn=b(on,2);{var Lt=Kt=>{var en=Uu(),tn=qe(en),bn=g(tn);f(tn);var xn=b(tn,2);kt(xn,21,()=>Oe().linked_evidence?.slice(0,8)??[],Tt,(Jt,Qt)=>{var vn=Zu(),pn=g(vn,!0);f(vn),te($n=>B(pn,$n),[()=>mt(s(Qt))]),x(Jt,vn)}),f(xn),te(Jt=>B(bn,`Evidence (${Jt??""})`),[()=>Oe().linked_evidence?.length]),x(Kt,en)},bt=me(()=>Oe().linked_evidence?.length);q(hn,Kt=>{s(bt)&&Kt(Lt)})}var wn=b(hn,2);{var Vt=Kt=>{var en=Gu(),tn=qe(en),bn=g(tn);f(tn);var xn=b(tn,2);kt(xn,21,()=>Oe().deltas?.slice(0,8)??[],Tt,(Jt,Qt)=>{var vn=Wu(),pn=g(vn),$n=g(pn,!0);f(pn);var Bn=b(pn,2),er=g(Bn,!0);f(Bn),f(vn),te((ar,_t)=>{B($n,ar),B(er,_t)},[()=>String(s(Qt).name??s(Qt).entity_type??"DeltaFinding"),()=>mt(s(Qt).metadata??s(Qt).metadata_json??s(Qt))]),x(Jt,vn)}),f(xn),te(Jt=>B(bn,`Deltas (${Jt??""})`),[()=>Oe().deltas?.length]),x(Kt,en)},_n=me(()=>Oe().deltas?.length);q(wn,Kt=>{s(_n)&&Kt(Vt)})}x(st,At)};q(fe,st=>{s(v).kind==="artifact"?st(dt):s(v).kind==="pack"?st(Ue,1):st(Je,-1)})}var Nt=b(fe,2),Et=b(g(Nt),2);Aa(Et,{get value(){return s(v).raw}}),f(Nt),te(st=>{B(be,s(v).title),B(Le,`${st??""} · ${s(v).kind??""}`)},[()=>s(v).row?xi(se(s(v).row)):"Snapshot"]),x(P,w)},it=P=>{var w=Ju();x(P,w)};q(Ve,P=>{s(v)?P(ot):P(it,-1)})}f(we),f(He),f(Qe),te(P=>{B(H,`${s(C).length??""} artifacts · ${P??""}`),R.disabled=s(p),Pe=at(Q,1,"svelte-6ezzcw",null,Pe,{active:s(d)==="all"&&s(h)==="all"}),B(ge,s(C).length),An(Xe,"aria-busy",s(p))},[()=>U()]),Be("keydown",M,P=>{P.key==="Enter"&&ue()}),Br(M,()=>s(c),P=>u(c,P)),Be("click",R,ue),Be("click",Q,()=>X("all")),x(t,Qe),Pn()}Fn(["keydown","click"]);var ef=D('<button type="button" class="reset svelte-1mzsyd7">Reset graph</button>'),tf=D('<p class="error svelte-1mzsyd7"> </p>'),nf=D('<p class="muted svelte-1mzsyd7">No graph-focusable projections for this workspace.</p>'),rf=D('<span class="tag svelte-1mzsyd7"> </span>'),sf=D('<span class="content svelte-1mzsyd7"> </span>'),af=D('<button type="button" class="svelte-1mzsyd7">Open snapshot</button>'),of=D('<li><button type="button" class="row-select svelte-1mzsyd7"><span class="row-head svelte-1mzsyd7"><strong class="svelte-1mzsyd7"> </strong> <span class="tag svelte-1mzsyd7"> </span> <!></span> <!></button> <div class="actions svelte-1mzsyd7"><!></div></li>'),lf=D('<ul class="svelte-1mzsyd7"></ul>'),cf=D('<div class="filter-row svelte-1mzsyd7"><input placeholder="Filter projections" aria-label="Filter projections" class="svelte-1mzsyd7"/> <span class="svelte-1mzsyd7"> </span></div> <!>',1),df=D('<aside><header class="svelte-1mzsyd7"><button type="button" class="toggle svelte-1mzsyd7"> </button> <span class="hint svelte-1mzsyd7"><!></span> <!></header> <!></aside>');function hf(t,e){Dn(e,!0);let n=$(e,"workspaceId",3,""),r=$(e,"graphContext",19,()=>({})),i=$(e,"graphFocused",3,!1),a=L(!1),o=L(null),l=L(Ut([])),c=L(!0),d=L(""),h=L(""),p=L("");De(()=>{const ie=n().trim(),de=`${ie}:${r().label??""}:${r().entityType??""}`;ie&&de!==s(d)&&y(ie,de)});async function y(ie,de){u(a,!0),u(o,null);try{const Ce=new URLSearchParams({workspace_id:ie,limit:"8"}),xe=await fetch(`/api/projections/catalog?${Ce}`);if(!xe.ok)throw new Error(await xe.text());u(l,ma(await xe.json()),!0),u(d,de,!0)}catch(Ce){u(o,Ce instanceof Error?Ce.message:String(Ce),!0),u(l,[],!0)}finally{u(a,!1)}}function k(ie){const de=I(ie);de.length>0&&(u(h,C(ie),!0),e.onViewInGraph?.(de))}function C(ie){return ie.artifact_id??ie.projection_id??ie.id??(ie.entity_id==null?void 0:String(ie.entity_id))??Ln(ie)}function _(ie){u(h,C(ie),!0)}function v(ie){const de=ie.raw,xe=(de.metadata&&typeof de.metadata=="object"?de.metadata:null)?.source_plan_id;return typeof xe=="string"&&xe.trim()?xe.trim():void 0}function I(ie){const de=ie.entity_id!=null?[ie.entity_id]:hr(ie.raw);if(de.length>0)return de;if(!ie.artifact_id)return[];const Ce=s(l).find(xe=>(xe.artifact_kind??xe.type)==="answer_snapshot"&&v(xe)===ie.artifact_id);return Ce?Ce.entity_id!=null?[Ce.entity_id]:hr(Ce.raw):[]}function O(){const ie=s(l).filter(Ce=>I(Ce).length>0),de=s(p).trim().toLowerCase();return de?ie.filter(Ce=>[Ln(Ce),Ce.preview,Ce.content,Ce.artifact_kind,Ce.state,Ce.status].filter(Boolean).join(" ").toLowerCase().includes(de)):ie}function j(ie){return ie.state??ie.status??ie.lifecycle}var K=df();let U;var V=g(K),se=g(V),oe=g(se);f(se);var ce=b(se,2),G=g(ce);{var N=ie=>{var de=zn("Loading…");x(ie,de)},W=ie=>{var de=zn();te(()=>B(de,`Context: ${r().label??""}`)),x(ie,de)},z=ie=>{var de=zn();te(()=>B(de,n()||"workspace")),x(ie,de)};q(G,ie=>{s(a)?ie(N):r().label?ie(W,1):ie(z,-1)})}f(ce);var X=b(ce,2);{var le=ie=>{var de=ef();Be("click",de,()=>e.onResetGraph?.()),x(ie,de)};q(X,ie=>{i()&&ie(le)})}f(V);var ue=b(V,2);{var Se=ie=>{var de=cf(),Ce=qe(de),xe=g(Ce);Tn(xe);var tt=b(xe,2),_e=g(tt,!0);f(tt),f(Ce);var Z=b(Ce,2);{var pe=je=>{var Ge=tf(),et=g(Ge,!0);f(Ge),te(()=>B(et,s(o))),x(je,Ge)},ve=je=>{var Ge=nf();x(je,Ge)},Ke=me(()=>O().length===0),Oe=je=>{var Ge=lf();kt(Ge,21,O,Tt,(et,$e)=>{var mt=of();let vt;var Qe=g(mt),Fe=g(Qe),nt=g(Fe),lt=g(nt,!0);f(nt);var H=b(nt,2),ne=g(H,!0);f(H);var F=b(H,2);{var M=ye=>{var A=rf(),re=g(A,!0);f(A),te(ae=>B(re,ae),[()=>j(s($e))]),x(ye,A)},R=me(()=>j(s($e)));q(F,ye=>{s(R)&&ye(M)})}f(Fe);var Y=b(Fe,2);{var Q=ye=>{var A=sf(),re=g(A,!0);f(A),te(()=>B(re,s($e).preview??s($e).content)),x(ye,A)};q(Y,ye=>{(s($e).preview||s($e).content)&&ye(Q)})}f(Qe);var Pe=b(Qe,2),Ne=g(Pe);{var ge=ye=>{var A=af();Be("click",A,()=>{_(s($e)),e.onOpenDetail?.(s($e).projection_id)}),x(ye,A)};q(Ne,ye=>{s($e).artifact_kind==="answer_snapshot"&&s($e).projection_id&&ye(ge)})}f(Pe),f(mt),te((ye,A,re)=>{vt=at(mt,1,"svelte-1mzsyd7",null,vt,ye),B(lt,A),B(ne,re)},[()=>({highlight:_a(s($e),r()),selected:s(h)===C(s($e))}),()=>Ln(s($e)),()=>xi(s($e).artifact_kind??s($e).type)]),Be("click",Qe,()=>k(s($e))),x(et,mt)}),f(Ge),x(je,Ge)};q(Z,je=>{s(o)?je(pe):s(Ke)?je(ve,1):je(Oe,-1)})}te(je=>B(_e,je),[()=>O().length]),Br(xe,()=>s(p),je=>u(p,je)),x(ie,de)};q(ue,ie=>{s(c)||ie(Se)})}f(K),te(()=>{U=at(K,1,"drawer svelte-1mzsyd7",null,U,{collapsed:s(c)}),B(oe,`${s(c)?"▲":"▼"} Projections`)}),Be("click",se,()=>u(c,!s(c))),x(t,K),Pn()}Fn(["click"]);var uf=D('<button type="button"> </button>'),ff=D('<button type="button" class="svelte-1u70db1"> </button>'),gf=D('<p class="error svelte-1u70db1"> </p>'),vf=D('<p class="muted svelte-1u70db1">Loading rules...</p>'),pf=D('<p class="muted svelte-1u70db1">No graph gap rules found for this workspace.</p>'),yf=D('<p class="muted svelte-1u70db1">No rules match this filter.</p>'),mf=D('<button type="button" class="svelte-1u70db1">Focus graph</button>'),_f=D('<li><button type="button" class="row-button svelte-1u70db1"><span class="row-title svelte-1u70db1"> </span> <span class="content svelte-1u70db1"> </span></button> <div class="row-meta svelte-1u70db1"><span class="tag severity svelte-1u70db1"> </span> <span class="tag svelte-1u70db1"> </span> <span class="scope svelte-1u70db1"> </span></div> <div class="row-actions svelte-1u70db1"><span class="count invalid svelte-1u70db1"> </span> <span class="count svelte-1u70db1"> </span> <!></div></li>'),bf=D('<ul class="rows svelte-1u70db1"></ul>'),kf=D('<button type="button" class="svelte-1u70db1">Focus invalid</button>'),wf=D('<p class="detail-line svelte-1u70db1"> </p>'),xf=D('<p class="muted svelte-1u70db1">No invalid subjects for this rule.</p>'),Cf=D('<li class="svelte-1u70db1"><button type="button" class="link-button svelte-1u70db1"> </button> <span> </span></li>'),Sf=D('<ul class="detail-list svelte-1u70db1"></ul>'),Nf=D('<li class="svelte-1u70db1"><button type="button" class="link-button svelte-1u70db1"> </button> <span> </span></li>'),Df=D('<h4 class="svelte-1u70db1">Recent events</h4> <ul class="detail-list svelte-1u70db1"></ul>',1),Pf=D('<header class="result-head svelte-1u70db1"><div><h3 class="svelte-1u70db1"> </h3> <p class="svelte-1u70db1"> </p></div> <div class="result-actions svelte-1u70db1"><!></div></header> <!> <div class="cards svelte-1u70db1"><div class="svelte-1u70db1"><strong class="svelte-1u70db1"> </strong> <span class="svelte-1u70db1">invalid</span></div> <div class="svelte-1u70db1"><strong class="svelte-1u70db1"> </strong> <span class="svelte-1u70db1">valid</span></div> <div class="svelte-1u70db1"><strong class="svelte-1u70db1"> </strong> <span class="svelte-1u70db1">diagnostic issues</span></div></div> <h4 class="svelte-1u70db1">Invalid subjects</h4> <!> <!> <details class="svelte-1u70db1"><summary class="svelte-1u70db1">Technical details</summary> <!></details>',1),If=D('<p class="muted svelte-1u70db1">Select a rule.</p>'),Tf=D('<div class="rules svelte-1u70db1"><header class="toolbar svelte-1u70db1"><div><h2 class="svelte-1u70db1">Rules</h2> <p class="svelte-1u70db1"> <!></p></div> <div class="actions svelte-1u70db1"><label class="search svelte-1u70db1"><span class="svelte-1u70db1">Filter</span> <input class="svelte-1u70db1"/></label> <button type="button" class="svelte-1u70db1">Refresh</button> <button type="button" class="svelte-1u70db1"> </button></div></header> <nav class="filters svelte-1u70db1" aria-label="Rule filters"><button type="button">All <span class="svelte-1u70db1"> </span></button> <button type="button">Invalid <span class="svelte-1u70db1"> </span></button> <button type="button">Valid <span class="svelte-1u70db1"> </span></button> <button type="button">All severities</button> <!></nav> <section class="summary svelte-1u70db1" aria-label="Rule diagnostics summary"><span class="svelte-1u70db1"> </span> <span class="svelte-1u70db1"> </span> <span class="svelte-1u70db1"> </span> <span class="svelte-1u70db1"> </span> <!></section> <!> <div class="layout svelte-1u70db1"><section class="catalog svelte-1u70db1"><!></section> <section class="result svelte-1u70db1"><!></section></div></div>');function Mf(t,e){Dn(e,!0);let n=$(e,"workspaceId",3,"default"),r=$(e,"ontologyId",3,""),i=$(e,"active",3,!1),a=L(!1),o=L(!1),l=L(null),c=L(""),d=L("all"),h=L("all"),p=L(""),y=L(""),k=L(""),C=L(Ut([])),_=L(Ut([])),v=L(Ut([])),I=L(null),O=L(null);De(()=>{const J=j(),fe=K();i()&&J&&(s(y)!==J||s(k)!==fe)&&ce()});function j(){return n().trim()||"default"}function K(){const J=r().trim();if(J&&J!==mn)return J;const fe=j();return fe!=="default"?fe:""}function U(J=new URLSearchParams){J.set("workspace_id",j());const fe=K();return fe&&J.set("ontology_id",fe),J}async function V(J,fe){const dt=await fetch(J,fe);if(!dt.ok)throw new Error(await dt.text());return await dt.json()}async function se(J,fe){try{return await V(J)}catch{return fe}}async function oe(){const J=U();try{return await V(`/api/brain/graph/gap-rules?${J}`)}catch{return V(`/api/graph/gap-rules?${J}`)}}async function ce(){u(a,!0),u(l,null);try{const[J,fe,dt]=await Promise.all([oe(),se(`/api/brain/graph/rule-evaluations?${U(new URLSearchParams({limit:"500"}))}`,{evaluations:[]}),se(`/api/brain/graph/rule-events?${U(new URLSearchParams({limit:"100"}))}`,{events:[]})]);u(C,Array.isArray(J.rules)?J.rules:[],!0),u(_,Array.isArray(fe.evaluations)?fe.evaluations:[],!0),u(v,Array.isArray(dt.events)?dt.events:[],!0),u(I,{issues:[],summary:{}},!0),u(y,j(),!0),u(k,K(),!0),s(p)&&!s(C).some(Ue=>Ue.rule_id===s(p))&&u(p,""),!s(p)&&s(C).length>0&&u(p,s(C)[0].rule_id,!0)}catch(J){u(l,J instanceof Error?J.message:String(J),!0),u(C,[],!0),u(_,[],!0),u(v,[],!0),u(I,null)}finally{u(a,!1)}}async function G(){u(o,!0),u(l,null);try{const J={workspace_id:j(),limit:100,create_remediation_actions:!1},fe=K();fe&&(J.ontology_id=fe),u(O,await V("/api/brain/graph/rule-evaluations/run",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(J)}),!0),await ce()}catch(J){u(l,J instanceof Error?J.message:String(J),!0)}finally{u(o,!1)}}function N(J){return s(_).filter(fe=>fe.rule_id===J)}function W(J){const fe=s(I)?.issues;return Array.isArray(fe)?fe.filter(dt=>dt.rule_id===J):[]}function z(J){return N(J).filter(fe=>fe.state==="invalid").length}function X(J){return N(J).filter(fe=>fe.state==="valid").length}function le(J,fe=!0){const dt=new Set;for(const Ue of N(J))(!fe||Ue.state==="invalid")&&dt.add(Number(Ue.subject_entity_id));for(const Ue of W(J)){const Je=Number(Ue.entity_id);Number.isFinite(Je)&&Je>0&&dt.add(Je)}return[...dt].filter(Ue=>Number.isFinite(Ue)&&Ue>0)}function ue(){const J=s(c).trim().toLowerCase();return s(C).filter(fe=>s(h)!=="all"&&fe.severity!==s(h)||s(d)==="invalid"&&z(fe.rule_id)===0||s(d)==="valid"&&X(fe.rule_id)===0?!1:J?[fe.rule_id,fe.label,fe.entity_type,fe.relation_type,fe.target_entity_type,fe.severity].filter(Boolean).join(" ").toLowerCase().includes(J):!0)}function Se(){return s(C).find(J=>J.rule_id===s(p))??ue()[0]??null}function ie(){return[...new Set(s(C).map(J=>J.severity).filter(J=>!!J))].sort()}function de(){const J=s(I)?.summary;return J&&typeof J=="object"?J:{}}function Ce(){const J=new Set;for(const fe of ue())for(const dt of le(fe.rule_id,s(d)!=="valid"))J.add(dt);return[...J]}function xe(J){const fe=[...new Set(J)].filter(dt=>Number.isFinite(dt)&&dt>0).slice(0,30);fe.length>0&&e.onViewInGraph?.(fe)}function tt(J){return J==null?"0":String(J)}function _e(J){const fe=J.target_entity_type?` -> ${J.target_entity_type}`:"";return`${J.entity_type??"?"} · ${J.direction??"?"} ${J.relation_type??"?"}${fe}`}var Z=Tf(),pe=g(Z),ve=g(pe),Ke=b(g(ve),2),Oe=g(Ke),je=b(Oe);{var Ge=J=>{var fe=zn();te(dt=>B(fe,`· ${dt??""}`),[()=>K()]),x(J,fe)},et=me(()=>K());q(je,J=>{s(et)&&J(Ge)})}f(Ke),f(ve);var $e=b(ve,2),mt=g($e),vt=b(g(mt),2);Tn(vt),f(mt);var Qe=b(mt,2),Fe=b(Qe,2),nt=g(Fe,!0);f(Fe),f($e),f(pe);var lt=b(pe,2),H=g(lt);let ne;var F=b(g(H)),M=g(F,!0);f(F),f(H);var R=b(H,2);let Y;var Q=b(g(R)),Pe=g(Q,!0);f(Q),f(R);var Ne=b(R,2);let ge;var ye=b(g(Ne)),A=g(ye,!0);f(ye),f(Ne);var re=b(Ne,2);let ae;var Me=b(re,2);kt(Me,17,ie,Tt,(J,fe)=>{var dt=uf();let Ue;var Je=g(dt,!0);f(dt),te(()=>{Ue=at(dt,1,"svelte-1u70db1",null,Ue,{active:s(h)===s(fe)}),B(Je,s(fe))}),Be("click",dt,()=>u(h,s(fe),!0)),x(J,dt)}),f(lt);var ke=b(lt,2),He=g(ke),Xe=g(He);f(He);var ut=b(He,2),T=g(ut);f(ut);var ee=b(ut,2),Te=g(ee);f(ee);var Ae=b(ee,2),Ie=g(Ae);f(Ae);var we=b(Ae,2);{var Ve=J=>{var fe=ff(),dt=g(fe);f(fe),te(Ue=>B(dt,`Focus impacted (${Ue??""})`),[()=>Math.min(Ce().length,30)]),Be("click",fe,()=>xe(Ce())),x(J,fe)},ot=me(()=>Ce().length>0);q(we,J=>{s(ot)&&J(Ve)})}f(ke);var it=b(ke,2);{var P=J=>{var fe=gf(),dt=g(fe,!0);f(fe),te(()=>B(dt,s(l))),x(J,fe)};q(it,J=>{s(l)&&J(P)})}var w=b(it,2),E=g(w),he=g(E);{var Ee=J=>{var fe=vf();x(J,fe)},be=J=>{var fe=pf();x(J,fe)},ze=J=>{var fe=yf();x(J,fe)},Le=me(()=>ue().length===0),rt=J=>{var fe=bf();kt(fe,21,ue,dt=>dt.rule_id,(dt,Ue)=>{var Je=_f();let Nt;var Et=g(Je),st=g(Et),At=g(st,!0);f(st);var an=b(st,2),gn=g(an,!0);f(an),f(Et);var Xt=b(Et,2),on=g(Xt),Bt=g(on,!0);f(on);var Pt=b(on,2),hn=g(Pt,!0);f(Pt);var Lt=b(Pt,2),bt=g(Lt,!0);f(Lt),f(Xt);var wn=b(Xt,2),Vt=g(wn),_n=g(Vt);f(Vt);var Kt=b(Vt,2),en=g(Kt);f(Kt);var tn=b(Kt,2);{var bn=Jt=>{var Qt=mf();Be("click",Qt,()=>xe(le(s(Ue).rule_id))),x(Jt,Qt)},xn=me(()=>le(s(Ue).rule_id).length>0);q(tn,Jt=>{s(xn)&&Jt(bn)})}f(wn),f(Je),te((Jt,Qt,vn,pn)=>{Nt=at(Je,1,"svelte-1u70db1",null,Nt,{selected:s(p)===s(Ue).rule_id}),B(At,s(Ue).rule_id),B(gn,Jt),B(Bt,s(Ue).severity??"info"),B(hn,s(Ue).enabled===!1?"disabled":"enabled"),B(bt,Qt),B(_n,`invalid ${vn??""}`),B(en,`valid ${pn??""}`)},[()=>s(Ue).label??_e(s(Ue)),()=>_e(s(Ue)),()=>z(s(Ue).rule_id),()=>X(s(Ue).rule_id)]),Be("click",Et,()=>u(p,s(Ue).rule_id,!0)),x(dt,Je)}),f(fe),x(J,fe)};q(he,J=>{s(a)&&s(C).length===0?J(Ee):s(C).length===0?J(be,1):s(Le)?J(ze,2):J(rt,-1)})}f(E);var m=b(E,2),Ze=g(m);{var Ye=J=>{const fe=me(Se);var dt=Pf(),Ue=qe(dt),Je=g(Ue),Nt=g(Je),Et=g(Nt,!0);f(Nt);var st=b(Nt,2),At=g(st,!0);f(st),f(Je);var an=b(Je,2),gn=g(an);{var Xt=_t=>{var ht=kf();Be("click",ht,()=>xe(le(s(fe).rule_id))),x(_t,ht)},on=me(()=>s(fe)&&le(s(fe).rule_id).length>0);q(gn,_t=>{s(on)&&_t(Xt)})}f(an),f(Ue);var Bt=b(Ue,2);{var Pt=_t=>{var ht=wf(),Ct=g(ht,!0);f(ht),te(()=>B(Ct,s(fe).label)),x(_t,ht)};q(Bt,_t=>{s(fe)?.label&&_t(Pt)})}var hn=b(Bt,2),Lt=g(hn),bt=g(Lt),wn=g(bt,!0);f(bt),Yt(2),f(Lt);var Vt=b(Lt,2),_n=g(Vt),Kt=g(_n,!0);f(_n),Yt(2),f(Vt);var en=b(Vt,2),tn=g(en),bn=g(tn,!0);f(tn),Yt(2),f(en),f(hn);var xn=b(hn,4);{var Jt=_t=>{var ht=xf();x(_t,ht)},Qt=me(()=>N(s(fe)?.rule_id??"").filter(_t=>_t.state==="invalid").length===0),vn=_t=>{var ht=Sf();kt(ht,21,()=>N(s(fe)?.rule_id??"").filter(Ct=>Ct.state==="invalid").slice(0,40),Tt,(Ct,nn)=>{var Mn=Cf(),tr=g(Mn),Zn=g(tr);f(tr);var Nr=b(tr,2),Dr=g(Nr);f(Nr),f(Mn),te(()=>{B(Zn,`#${s(nn).subject_entity_id??""}`),B(Dr,`observed ${s(nn).observed_count??0??""}, expected min ${s(nn).expected_min??0??""}`)}),Be("click",tr,()=>xe([s(nn).subject_entity_id])),x(Ct,Mn)}),f(ht),x(_t,ht)};q(xn,_t=>{s(Qt)?_t(Jt):_t(vn,-1)})}var pn=b(xn,2);{var $n=_t=>{var ht=Df(),Ct=b(qe(ht),2);kt(Ct,21,()=>s(v).filter(nn=>nn.rule_id===s(fe)?.rule_id).slice(0,8),Tt,(nn,Mn)=>{var tr=Nf(),Zn=g(tr),Nr=g(Zn);f(Zn);var Dr=b(Zn,2),Hi=g(Dr);f(Dr),f(tr),te(()=>{B(Nr,`#${s(Mn).subject_entity_id??""}`),B(Hi,`${s(Mn).from_state??"?"??""} -> ${s(Mn).to_state??"?"??""}`)}),Be("click",Zn,()=>xe([s(Mn).subject_entity_id])),x(nn,tr)}),f(Ct),x(_t,ht)},Bn=me(()=>s(v).filter(_t=>_t.rule_id===s(fe)?.rule_id).length>0);q(pn,_t=>{s(Bn)&&_t($n)})}var er=b(pn,2),ar=b(g(er),2);{let _t=me(()=>({rule:s(fe),evaluations:N(s(fe)?.rule_id??""),issues:W(s(fe)?.rule_id??"")}));Aa(ar,{get value(){return s(_t)}})}f(er),te((_t,ht,Ct,nn)=>{B(Et,s(fe)?.rule_id),B(At,_t),B(wn,ht),B(Kt,Ct),B(bn,nn)},[()=>s(fe)?_e(s(fe)):"",()=>z(s(fe)?.rule_id??""),()=>X(s(fe)?.rule_id??""),()=>W(s(fe)?.rule_id??"").length]),x(J,dt)},Mt=me(()=>Se()),Ot=J=>{var fe=If();x(J,fe)};q(Ze,J=>{s(Mt)?J(Ye):J(Ot,-1)})}f(m),f(w),f(Z),te((J,fe,dt,Ue,Je,Nt,Et)=>{B(Oe,`${s(C).length??""} rules · ${J??""} `),Qe.disabled=s(a)||s(o),Fe.disabled=s(a)||s(o),B(nt,s(o)?"Running...":"Run evaluations"),ne=at(H,1,"svelte-1u70db1",null,ne,{active:s(d)==="all"}),B(M,s(C).length),Y=at(R,1,"svelte-1u70db1",null,Y,{active:s(d)==="invalid"}),B(Pe,fe),ge=at(Ne,1,"svelte-1u70db1",null,ge,{active:s(d)==="valid"}),B(A,dt),ae=at(re,1,"svelte-1u70db1",null,ae,{active:s(h)==="all"}),B(Xe,`evaluated ${Ue??""}`),B(T,`invalid ${Je??""}`),B(Te,`events ${Nt??""}`),B(Ie,`diagnostic issues ${Et??""}`),An(E,"aria-busy",s(a))},[()=>j(),()=>s(_).filter(J=>J.state==="invalid").length,()=>s(_).filter(J=>J.state==="valid").length,()=>tt(s(O)?.evaluated??de().rules_evaluated),()=>tt(s(O)?.invalid_count??de().missing_required_relations),()=>tt(s(O)?.events_created??s(v).length),()=>tt(de().issues_total)]),Be("keydown",vt,J=>{J.key==="Enter"&&ce()}),Br(vt,()=>s(c),J=>u(c,J)),Be("click",Qe,ce),Be("click",Fe,G),Be("click",H,()=>u(d,"all")),Be("click",R,()=>u(d,"invalid")),Be("click",Ne,()=>u(d,"valid")),Be("click",re,()=>u(h,"all")),x(t,Z),Pn()}Fn(["keydown","click"]);function Ef(t,e,n){if(e.length===0)return n?.trim()??"";const r=t.trim(),i=new Map(e.map(d=>[d.ontology_id,d])),a=`${r}::core`;if(i.has(a))return a;const o=e.filter(d=>d.source_kind==="linkml");if(o.length===1)return o[0].ontology_id;if(o.length>1)return o.find(h=>h.ontology_id.startsWith(`${r}::`))?.ontology_id??o[0].ontology_id;const l=e.filter(d=>!d.ontology_id.endsWith("::default"));if(l.length>0)return l[0].ontology_id;const c=n?.trim();return c&&i.has(c)?c:e[0]?.ontology_id??""}var Af=D("<option>All workspaces</option>"),Rf=D("<option> </option>"),Of=D("<option> </option>"),Lf=D("<option> </option>"),Hf=D('<label class="field svelte-1uha8ag"><span class="field-label svelte-1uha8ag">Ontology</span> <select class="select svelte-1uha8ag" aria-label="Ontology model"><!><!></select></label>'),zf=D('<p class="ontologies-warn svelte-1uha8ag" role="status"> </p>'),Ff=D('<p class="panel-message svelte-1uha8ag">Modèle view requires MindBrain online.</p>'),Bf=D('<div class="donnees-stage svelte-1uha8ag"><!> <!></div>'),jf=D('<p class="panel-message svelte-1uha8ag">Projections require MindBrain online (brain mode).</p>'),Vf=D('<p class="panel-message svelte-1uha8ag">Rules require MindBrain online (brain mode).</p>'),Kf=D('<main class="page svelte-1uha8ag"><header class="bar svelte-1uha8ag"><div class="bar-top svelte-1uha8ag"><div class="title-block svelte-1uha8ag"><h1 class="svelte-1uha8ag">GhostCrab Graph Explorer</h1> <span class="hint svelte-1uha8ag"><span></span> <!></span></div> <div class="tabs svelte-1uha8ag"><button>Modèle</button> <button>Données</button> <button>Projections</button> <button>Rules</button></div> <div class="controls svelte-1uha8ag"><label class="field field-workspace svelte-1uha8ag"><span class="field-label svelte-1uha8ag">Workspace</span> <select class="select svelte-1uha8ag" aria-label="Workspace"><!><!></select></label> <!></div></div> <!></header> <div><div class="stage svelte-1uha8ag"><!></div> <!></div></main>');function Jf(t,e){Dn(e,!0);let n=L("donnees"),r=L("all"),i=L("circular_force"),a=L("all"),o=L(""),l=L(""),c=L("30"),d=L(Ut([])),h=L(Ut([])),p=L(Ut([])),y=L(null),k=L(null),C=L("brain"),_=L(null),v=L(Ut([])),I=L(""),O=L(!1),j=L(Ut({search:!0,display:!1,facets:!1,legend:!1,selection:!0})),K=L(null),U=L(Ut([])),V=me(()=>s(c)==="none"?null:Number(s(c))),se=me(()=>s(o).trim()==="immeuble-demo"?"sqlite-demo":s(C)),oe=me(()=>{const w=s(_);return w?.kind==="ontology"&&w.payload?.ontology_id?String(w.payload.ontology_id):s(l)===mn?"":s(l)}),ce=me(()=>{const w=s(_);return w?w.kind==="entity"?{entityId:w.entityId,entityType:w.entityType,label:w.label}:w.kind==="relation"?{relationType:w.relationType}:{}:{}});async function G(){try{const w=await fetch("/api/brain/health");if(!w.ok)throw new Error(w.statusText);const E=await w.json();u(k,E.online,!0),u(C,E.mode,!0),s(C)==="brain"&&E.online?await le():await N()}catch{u(k,!1),await N()}}async function N(){u(y,null);try{const w=new URLSearchParams;s(o)&&w.set("workspace",s(o));const E=await fetch(`/api/graph/ontologies?${w}`);if(!E.ok)throw new Error(E.statusText);const he=await E.json();u(h,he.ontologies??[],!0),u(d,he.graphWorkspaces??[],!0),s(o)&&!s(d).some(Ee=>Ee.id===s(o))&&u(o,""),s(r)!=="all"&&!s(h).some(Ee=>Ee.id===s(r))&&u(r,"all")}catch(w){u(y,w instanceof Error?w.message:String(w),!0)}}function W(w,E){if(E&&w.some(be=>be.id===E))return E;const he=w.filter(be=>be.defaultOntologyId),Ee=[...w].sort((be,ze)=>ze.entityCount-be.entityCount);return w.find(be=>be.id==="immeuble-demo")?.id??he.find(be=>be.entityCount>0)?.id??Ee.find(be=>be.entityCount>0)?.id??he[0]?.id??w.find(be=>be.id!=="default")?.id??w[0]?.id??""}async function z(w){const E=await fetch(`/api/graph/ontologies?workspace=${encodeURIComponent(w)}`);if(!E.ok)throw new Error(await E.text());const he=await E.json();u(h,he.ontologies??[],!0),he.graphWorkspaces?.length&&u(d,he.graphWorkspaces,!0)}async function X(){if(s(k)!==!0){u(p,[],!0),u(l,"");return}try{const w=s(o).trim();if(!w){u(p,[],!0),u(l,"");return}const E=await fetch(`/api/brain/ontology/list?workspace_id=${encodeURIComponent(w)}`);if(!E.ok)throw new Error(await E.text());const he=await E.json(),Ee=`${w}::`;u(p,(he.ontologies??[]).filter(Le=>Le.ontology_id===w||Le.ontology_id.startsWith(Ee)),!0);const be=(he.default_ontology_id===w||he.default_ontology_id?.startsWith(Ee)?he.default_ontology_id:null)??s(d).find(Le=>Le.id===w)?.defaultOntologyId??null,ze=Ef(w,s(p),be);u(l,s(l)===mn||s(p).some(Le=>Le.ontology_id===s(l))?s(l)||mn:s(p).length>1?mn:ze,!0)}catch{u(p,[],!0),u(l,"")}}async function le(){u(y,null);try{const w=await fetch("/api/graph/ontologies");if(!w.ok)throw new Error(await w.text());const E=await w.json();u(d,E.graphWorkspaces??[],!0);const he=W(s(d),s(o).trim());he&&s(o)!==he&&u(o,he,!0),he?await z(he):u(h,E.ontologies??[],!0),await X()}catch(w){u(y,w instanceof Error?w.message:String(w),!0),u(d,[],!0),u(h,[],!0),u(p,[],!0),u(l,"")}}function ue(w){const E=w.currentTarget;u(o,E.value,!0),u(r,"all"),u(v,[],!0),u(_,null),s(C)==="brain"&&s(k)===!0?(async()=>(await z(s(o)),await X()))():N()}function Se(w){const E=w.currentTarget;u(r,E.value,!0)}function ie(w){const E=w.currentTarget;u(l,E.value,!0)}function de(w){if(w==="all")return"All entity types";const E=s(h).find(he=>he.id===w);return E?.label?E.label:w.toLowerCase().startsWith("type:")?w.slice(5):w}function Ce(){return s(r)==="all"?null:de(s(r))}function xe(w){u(_,w,!0),u(O,!0),w&&u(j,{...s(j),selection:!0},!0)}function tt(w,E){u(n,"modele"),xe({kind:"ontology",nodeKind:E,typeName:w})}function _e(w){u(n,"donnees"),u(v,w,!0)}function Z(w){u(n,"donnees"),u(v,w,!0)}function pe(){u(v,[],!0),u(_,null)}function ve(w){u(I,w,!0),u(n,"projections")}Ka(()=>{G()});var Ke=Kf(),Oe=g(Ke),je=g(Oe),Ge=g(je),et=b(g(Ge),2),$e=g(et);let mt;var vt=b($e,2);{var Qe=w=>{var E=zn("Demo SQLite · read-only");x(w,E)},Fe=w=>{var E=zn("MindBrain live · dual view");x(w,E)},nt=w=>{var E=zn("Brain offline · demo fallback recommended");x(w,E)};q(vt,w=>{s(C)==="sqlite-demo"?w(Qe):s(k)===!0?w(Fe,1):w(nt,-1)})}f(et),f(Ge);var lt=b(Ge,2),H=g(lt);let ne;var F=b(H,2);let M;var R=b(F,2);let Y;var Q=b(R,2);let Pe;f(lt);var Ne=b(lt,2),ge=g(Ne),ye=b(g(ge),2),A=g(ye);{var re=w=>{var E=Af();E.value=E.__value="",x(w,E)};q(A,w=>{(s(C)!=="brain"||s(k)!==!0)&&w(re)})}var ae=b(A);kt(ae,17,()=>s(d),Tt,(w,E)=>{var he=Rf(),Ee=g(he);f(he);var be={};te(()=>{B(Ee,`${(s(E).label?`${s(E).label} · ${s(E).id}`:s(E).id)??""} (${s(E).entityCount??""})`),be!==(be=s(E).id)&&(he.value=(he.__value=s(E).id)??"")}),x(w,he)}),f(ye);var Me;Ii(ye),f(ge);var ke=b(ge,2);{var He=w=>{var E=Hf(),he=b(g(E),2),Ee=g(he);{var be=rt=>{var m=Of(),Ze=g(m);f(m);var Ye={};te(()=>{B(Ze,`Tous · ${s(p).length??""} ontologies`),Ye!==(Ye=mn)&&(m.value=(m.__value=mn)??"")}),x(rt,m)};q(Ee,rt=>{s(p).length>1&&rt(be)})}var ze=b(Ee);kt(ze,17,()=>s(p),Tt,(rt,m)=>{var Ze=Lf(),Ye=g(Ze);f(Ze);var Mt={};te(()=>{B(Ye,`${s(m).name??""} · ${s(m).ontology_id??""}`),Mt!==(Mt=s(m).ontology_id)&&(Ze.value=(Ze.__value=s(m).ontology_id)??"")}),x(rt,Ze)}),f(he);var Le;Ii(he),f(E),te(()=>{Le!==(Le=s(l))&&(he.value=(he.__value=s(l))??"",ti(he,s(l)))}),Be("change",he,ie),x(w,E)};q(ke,w=>{s(n)==="modele"&&w(He)})}f(Ne),f(je);var Xe=b(je,2);{var ut=w=>{var E=zf(),he=g(E);f(E),te(()=>B(he,`Ontology list unavailable: ${s(y)??""}`)),x(w,E)};q(Xe,w=>{s(y)&&w(ut)})}f(Oe);var T=b(Oe,2);let ee;var Te=g(T),Ae=g(Te);{var Ie=w=>{var E=Ft(),he=qe(E);{var Ee=ze=>{{let Le=me(()=>s(o).trim()||"default");rc(ze,{get ontologyId(){return s(l)},get workspaceId(){return s(Le)},get ontologies(){return s(p)},onSelect:rt=>{xe({kind:"ontology",nodeKind:rt.nodeKind,typeName:rt.typeName,payload:rt.payload})}})}},be=ze=>{var Le=Ff();x(ze,Le)};q(he,ze=>{s(k)?ze(Ee):ze(be,-1)})}x(w,E)},we=w=>{var E=Bf(),he=g(E);{let ze=me(()=>s(o).trim()||(s(C)==="brain"?"default":null));_l(he,{get ontologyKey(){return s(r)},get layoutTemplate(){return s(i)},get edgeLinkMode(){return s(a)},get workspaceId(){return s(ze)},get topK(){return s(V)},get dataSource(){return s(se)},get brainSeedIds(){return s(v)},onSelect:Le=>{xe(Le)},get facetFilter(){return s(K)},set facetFilter(Le){u(K,Le,!0)},get legendBlocks(){return s(U)},set legendBlocks(Le){u(U,Le,!0)}})}var Ee=b(he,2);{var be=ze=>{{let Le=me(()=>s(o).trim()||"default"),rt=me(()=>s(v).length>0);hf(ze,{get workspaceId(){return s(Le)},get graphContext(){return s(ce)},get graphFocused(){return s(rt)},onViewInGraph:_e,onResetGraph:pe,onOpenDetail:ve})}};q(Ee,ze=>{s(C)==="brain"&&s(k)&&ze(be)})}f(E),x(w,E)},Ve=w=>{var E=Ft(),he=qe(E);{var Ee=ze=>{var Le=jf();x(ze,Le)},be=ze=>{{let Le=me(()=>s(o).trim()||"default"),rt=me(()=>s(n)==="projections");qu(ze,{get workspaceId(){return s(Le)},get graphContext(){return s(ce)},get active(){return s(rt)},get initialProjectionId(){return s(I)},onViewInGraph:_e})}};q(he,ze=>{s(C)==="sqlite-demo"||s(k)!==!0?ze(Ee):ze(be,-1)})}x(w,E)},ot=w=>{var E=Ft(),he=qe(E);{var Ee=ze=>{var Le=Vf();x(ze,Le)},be=ze=>{{let Le=me(()=>s(o).trim()||"default"),rt=me(()=>s(n)==="rules");Mf(ze,{get workspaceId(){return s(Le)},get ontologyId(){return s(l)},get active(){return s(rt)},onViewInGraph:Z})}};q(he,ze=>{s(C)==="sqlite-demo"||s(k)!==!0?ze(Ee):ze(be,-1)})}x(w,E)};q(Ae,w=>{s(n)==="modele"?w(Ie):s(n)==="donnees"?w(we,1):s(n)==="projections"?w(Ve,2):w(ot,-1)})}f(Te);var it=b(Te,2);{var P=w=>{{let E=me(()=>s(n)==="donnees"&&s(C)==="brain"&&s(k)===!0),he=me(()=>s(k)===!0),Ee=me(()=>s(o).trim());zd(w,{get showGraphTools(){return s(E)},get brainOnline(){return s(he)},get ontologyId(){return s(oe)},get workspaceId(){return s(Ee)},onOpenType:tt,get ontologies(){return s(h)},ontologyLabel:de,onOntologyChange:Se,filterEntityType:Ce,onSeeds:be=>{u(v,be,!0)},get legendBlocks(){return s(U)},get open(){return s(O)},set open(be){u(O,be,!0)},get sections(){return s(j)},set sections(be){u(j,be,!0)},get selection(){return s(_)},set selection(be){u(_,be,!0)},get ontologyKey(){return s(r)},set ontologyKey(be){u(r,be,!0)},get layoutTemplate(){return s(i)},set layoutTemplate(be){u(i,be,!0)},get edgeLinkMode(){return s(a)},set edgeLinkMode(be){u(a,be,!0)},get topK(){return s(c)},set topK(be){u(c,be,!0)},get facetFilter(){return s(K)},set facetFilter(be){u(K,be,!0)}})}};q(it,w=>{s(n)!=="projections"&&s(n)!=="rules"&&w(P)})}f(T),f(Ke),te(()=>{mt=at($e,1,"health-badge svelte-1uha8ag",null,mt,{online:s(k)===!0,offline:s(k)===!1,demo:s(C)==="sqlite-demo"}),ne=at(H,1,"svelte-1uha8ag",null,ne,{active:s(n)==="modele"}),M=at(F,1,"svelte-1uha8ag",null,M,{active:s(n)==="donnees"}),Y=at(R,1,"svelte-1uha8ag",null,Y,{active:s(n)==="projections"}),Pe=at(Q,1,"svelte-1uha8ag",null,Pe,{active:s(n)==="rules"}),Me!==(Me=s(o))&&(ye.value=(ye.__value=s(o))??"",ti(ye,s(o))),ee=at(T,1,"workspace svelte-1uha8ag",null,ee,{"with-inspector":s(n)!=="projections"&&s(n)!=="rules"})}),Be("click",H,()=>u(n,"modele")),Be("click",F,()=>u(n,"donnees")),Be("click",R,()=>u(n,"projections")),Be("click",Q,()=>u(n,"rules")),Be("change",ye,ue),x(t,Ke),Pn()}Fn(["click","change"]);export{Jf as component};
|