@reddb-io/ui 0.4.5 → 0.4.6
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/build/404.html +10 -10
- package/build/_app/immutable/chunks/BT_NlJ9b.js +9 -0
- package/build/_app/immutable/chunks/{C7CNScGY.js → BdKYr7lO.js} +1 -1
- package/build/_app/immutable/chunks/Br0XzNbS.js +1 -0
- package/build/_app/immutable/chunks/{B3FG5fhF.js → BspwW-rP.js} +1 -1
- package/build/_app/immutable/chunks/{wBgvmJJD.js → DD7_KB97.js} +1 -1
- package/build/_app/immutable/chunks/{BlQXYusA.js → xVmvYz1F.js} +3 -3
- package/build/_app/immutable/entry/{app.D8Jp8K7E.js → app.BwQs72pA.js} +2 -2
- package/build/_app/immutable/entry/start.Dokw79m9.js +1 -0
- package/build/_app/immutable/nodes/{0.BUmcOGPK.js → 0.Bn0HCj5G.js} +1 -1
- package/build/_app/immutable/nodes/{1.BY28ghvY.js → 1.C2fTzfSV.js} +1 -1
- package/build/_app/immutable/nodes/{10.B0M25chV.js → 10.C6p9_zpN.js} +1 -1
- package/build/_app/immutable/nodes/{15.CcKAFOhX.js → 15.CZkgDcbY.js} +1 -1
- package/build/_app/version.json +1 -1
- package/build/analytics.html +10 -10
- package/build/appearance.html +10 -10
- package/build/ask.html +10 -10
- package/build/cluster.html +10 -10
- package/build/collections.html +10 -10
- package/build/graph.html +11 -11
- package/build/index.html +10 -10
- package/build/query.html +10 -10
- package/build/redwire-ws-spike.html +10 -10
- package/build/security.html +10 -10
- package/build/settings.html +10 -10
- package/build/shadow-dom-spike.html +11 -11
- package/dist/embed/{AnalyticsView-DxVm8C96.js → AnalyticsView-Bq4u563e.js} +4 -4
- package/dist/embed/{AnalyticsView-DxVm8C96.js.map → AnalyticsView-Bq4u563e.js.map} +1 -1
- package/dist/embed/{RedUiEmbedRoot-kDChueQB.js → RedUiEmbedRoot-C29ndra1.js} +8061 -8051
- package/dist/embed/RedUiEmbedRoot-C29ndra1.js.map +1 -0
- package/dist/embed/{index-DoXUF64H.js → index-BAYmeM5z.js} +125 -125
- package/dist/embed/{index-DoXUF64H.js.map → index-BAYmeM5z.js.map} +1 -1
- package/dist/embed/{index-client-BSNcPP6j.js → index-client-Duv8Z53P.js} +2 -2
- package/dist/embed/{index-client-BSNcPP6j.js.map → index-client-Duv8Z53P.js.map} +1 -1
- package/dist/embed/index.js +1 -1
- package/dist/embed/{sigma.esm-DVyBdcK2.js → sigma.esm-Daj5mOac.js} +2 -2
- package/dist/embed/{sigma.esm-DVyBdcK2.js.map → sigma.esm-Daj5mOac.js.map} +1 -1
- package/package.json +3 -3
- package/src/lib/ConnectDropdown.svelte +3 -1
- package/src/lib/reddb/client.ts +4 -1
- package/build/_app/immutable/chunks/CA0FBK2E.js +0 -1
- package/build/_app/immutable/chunks/DUYiW17f.js +0 -9
- package/build/_app/immutable/entry/start.D-Hfyjh7.js +0 -1
- package/dist/embed/RedUiEmbedRoot-kDChueQB.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./B5euRbKa.js","./DhEqZVGG.js","./C-kqMbRi.js","./
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./B5euRbKa.js","./DhEqZVGG.js","./C-kqMbRi.js","./DD7_KB97.js","./DqvWKbSc.js","./CXNPJgv1.js","./CDKIdLnm.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
var du=Object.defineProperty;var ls=r=>{throw TypeError(r)};var fu=(r,e,t)=>e in r?du(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var Te=(r,e,t)=>fu(r,typeof e!="symbol"?e+"":e,t),us=(r,e,t)=>e.has(r)||ls("Cannot "+t);var xe=(r,e,t)=>(us(r,e,"read from private field"),t?t.call(r):e.get(r)),nt=(r,e,t)=>e.has(r)?ls("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t);var ds=(r,e,t)=>(us(r,e,"access private method"),t);import{aF as _t,aD as qn,aU as hu,a2 as ni,at as u,bb as pu,s as gu,bx as fs,br as Mr,bs as sn,aE as wr,f as mu,p as vu,aK as hs,ac as yu,ab as Fn,l as Vt,a3 as oo,ak as bu,bv as wu,ai as _u,aO as xu,a0 as yo,k as ku,j as Eu,b0 as Su,by as ps,E as Cu,D as Au,bh as Ca,b5 as Aa,I as Ai,d as $u,a7 as Du,a$ as Iu,aj as Lu,ay as $a,ba as Tu,az as Gu,i as Da,h as Ru,n as Ia,o as Ou,aa as zu,x as Mu,Y as Nu,bF as Pu,bz as Ee,bm as N,b8 as Kt,bK as Qt,av as Uu,b9 as ii,b6 as oi,a6 as R,aq as lt,bw as P,b3 as Wu,bg as T,bN as Q,ap as ju,bI as an,bO as Zt,bG as pe,b2 as Bt,be as Bu}from"./CGFL56WJ.js";import{B as bo,i as ke}from"./DCJ0QyYH.js";import{_ as hr,p as Gt,r as Ze,s as it,c as Fu,b as Vu}from"./CN4cKZHK.js";import"./Bzak7iHL.js";import{o as Ku,a as Hu}from"./Btd6PFkC.js";import{b as qu,o as Yu,u as Tn,a as V,l as At,e as er,v as fe,k as he,h as Xu,i as Ne,j as $i,x as Di}from"./nuKvOE41.js";import{a as Yn,e as Dt,j as St,g as H,r as Ii,i as Ju,s as Zu,d as Gn,k as Qu}from"./BRBZjpE2.js";const ed=Symbol("NaN");function ry(r,e,t){_t&&qn();var n=new bo(r),i=!hu();ni(()=>{var o=e();o!==o&&(o=ed),i&&o!==null&&typeof o=="object"&&(o={}),n.ensure(o,t)})}function Vn(r,e){return e}function td(r,e,t){for(var n=[],i=e.length,o,s=e.length,a=0;a<i;a++){let f=e[a];Aa(f,()=>{if(o){if(o.pending.delete(f),o.done.add(f),o.pending.size===0){var h=r.outrogroups;so(r,yo(o.done)),h.delete(o),h.size===0&&(r.outrogroups=null)}}else s-=1},!1)}if(s===0){var c=n.length===0&&t!==null;if(c){var l=t,d=l.parentNode;Du(d),d.append(l),r.items.clear()}so(r,e,!c)}else o={pending:new Set(e),done:new Set},(r.outrogroups??(r.outrogroups=new Set)).add(o)}function so(r,e,t=!0){var n;if(r.pending.size>0){n=new Set;for(const s of r.pending.values())for(const a of s)n.add(r.items.get(a).e)}for(var i=0;i<e.length;i++){var o=e[i];if(n!=null&&n.has(o)){o.f|=Vt;const s=document.createDocumentFragment();Iu(o,s)}else Lu(e[i],t)}}var gs;function bt(r,e,t,n,i,o=null){var s=r,a=new Map,c=(e&Da)!==0;if(c){var l=r;s=_t?Mr($a(l)):l.appendChild(Fn())}_t&&qn();var d=null,f=_u(()=>{var v=t();return xu(v)?v:v==null?[]:yo(v)}),h,g=new Map,y=!0;function C(v){(A.effect.f&Au)===0&&(A.pending.delete(v),A.fallback=d,rd(A,h,s,e,n),d!==null&&(h.length===0?(d.f&Vt)===0?Ca(d):(d.f^=Vt,rn(d,null,s)):Aa(d,()=>{d=null})))}function b(v){A.pending.delete(v)}var m=ni(()=>{h=u(f);var v=h.length;let p=!1;if(_t){var E=pu(s)===gu;E!==(v===0)&&(s=fs(),Mr(s),sn(!1),p=!0)}for(var S=new Set,$=yu,x=wu(),D=0;D<v;D+=1){_t&&wr.nodeType===mu&&wr.data===vu&&(s=wr,p=!0,sn(!1));var I=h[D],j=n(I,D),O=y?null:a.get(j);O?(O.v&&hs(O.v,I),O.i&&hs(O.i,D),x&&$.unskip_effect(O.e)):(O=nd(a,y?s:gs??(gs=Fn()),I,j,D,i,e,t),y||(O.e.f|=Vt),a.set(j,O)),S.add(j)}if(v===0&&o&&!d&&(y?d=oo(()=>o(s)):(d=oo(()=>o(gs??(gs=Fn()))),d.f|=Vt)),v>S.size&&bu(),_t&&v>0&&Mr(fs()),!y)if(g.set($,S),x){for(const[w,ge]of a)S.has(w)||$.skip_effect(ge.e);$.oncommit(C),$.ondiscard(b)}else C($);p&&sn(!0),u(f)}),A={effect:m,items:a,pending:g,outrogroups:null,fallback:d};y=!1,_t&&(s=wr)}function Yr(r){for(;r!==null&&(r.f&$u)===0;)r=r.next;return r}function rd(r,e,t,n,i){var I,j,O,w,ge,ce,L,_,K;var o=(n&Ru)!==0,s=e.length,a=r.items,c=Yr(r.effect.first),l,d=null,f,h=[],g=[],y,C,b,m;if(o)for(m=0;m<s;m+=1)y=e[m],C=i(y,m),b=a.get(C).e,(b.f&Vt)===0&&((j=(I=b.nodes)==null?void 0:I.a)==null||j.measure(),(f??(f=new Set)).add(b));for(m=0;m<s;m+=1){if(y=e[m],C=i(y,m),b=a.get(C).e,r.outrogroups!==null)for(const ee of r.outrogroups)ee.pending.delete(b),ee.done.delete(b);if((b.f&Ai)!==0&&(Ca(b),o&&((w=(O=b.nodes)==null?void 0:O.a)==null||w.unfix(),(f??(f=new Set)).delete(b))),(b.f&Vt)!==0)if(b.f^=Vt,b===c)rn(b,null,t);else{var A=d?d.next:c;b===r.effect.last&&(r.effect.last=b.prev),b.prev&&(b.prev.next=b.next),b.next&&(b.next.prev=b.prev),ar(r,d,b),ar(r,b,A),rn(b,A,t),d=b,h=[],g=[],c=Yr(d.next);continue}if(b!==c){if(l!==void 0&&l.has(b)){if(h.length<g.length){var v=g[0],p;d=v.prev;var E=h[0],S=h[h.length-1];for(p=0;p<h.length;p+=1)rn(h[p],v,t);for(p=0;p<g.length;p+=1)l.delete(g[p]);ar(r,E.prev,S.next),ar(r,d,E),ar(r,S,v),c=v,d=S,m-=1,h=[],g=[]}else l.delete(b),rn(b,c,t),ar(r,b.prev,b.next),ar(r,b,d===null?r.effect.first:d.next),ar(r,d,b),d=b;continue}for(h=[],g=[];c!==null&&c!==b;)(l??(l=new Set)).add(c),g.push(c),c=Yr(c.next);if(c===null)continue}(b.f&Vt)===0&&h.push(b),d=b,c=Yr(b.next)}if(r.outrogroups!==null){for(const ee of r.outrogroups)ee.pending.size===0&&(so(r,yo(ee.done)),(ge=r.outrogroups)==null||ge.delete(ee));r.outrogroups.size===0&&(r.outrogroups=null)}if(c!==null||l!==void 0){var $=[];if(l!==void 0)for(b of l)(b.f&Ai)===0&&$.push(b);for(;c!==null;)(c.f&Ai)===0&&c!==r.fallback&&$.push(c),c=Yr(c.next);var x=$.length;if(x>0){var D=(n&Da)!==0&&s===0?t:null;if(o){for(m=0;m<x;m+=1)(L=(ce=$[m].nodes)==null?void 0:ce.a)==null||L.measure();for(m=0;m<x;m+=1)(K=(_=$[m].nodes)==null?void 0:_.a)==null||K.fix()}td(r,$,D)}}o&&Tu(()=>{var ee,M;if(f!==void 0)for(b of f)(M=(ee=b.nodes)==null?void 0:ee.a)==null||M.apply()})}function nd(r,e,t,n,i,o,s,a){var c=(s&ku)!==0?(s&Eu)===0?Su(t,!1,!1):ps(t):null,l=(s&Cu)!==0?ps(i):null;return{v:c,i:l,e:oo(()=>(o(e,c??t,l??i,a),()=>{r.delete(n)}))}}function rn(r,e,t){if(r.nodes)for(var n=r.nodes.start,i=r.nodes.end,o=e&&(e.f&Vt)===0?e.nodes.start:t;n!==null;){var s=Gu(n);if(o.before(n),n===i)return;n=s}}function ar(r,e,t){e===null?r.effect.first=t:e.next=t,t===null?r.effect.last=e:t.prev=e}function ao(r,e,...t){var n=new bo(r);ni(()=>{const i=e()??null;n.ensure(i,i&&(o=>i(o,...t)))},Ia)}function id(r,e,t,n,i,o){let s=_t;_t&&qn();var a=null;_t&&wr.nodeType===Ou&&(a=wr,qn());var c=_t?wr:r,l=new bo(c,!1);ni(()=>{const d=e()||null;var f=t||d==="svg"?Mu:void 0;if(d===null){l.ensure(null,null),Tn(!0);return}return l.ensure(d,h=>{if(d){if(a=_t?a:zu(d,f),qu(a,a),n){_t&&Yu(d)&&a.append(document.createComment(""));var g=_t?$a(a):a.appendChild(Fn());_t&&(g===null?sn(!1):Mr(g)),n(a,g)}Nu.nodes.end=a,h.before(a)}_t&&Mr(h)}),Tn(!0),()=>{d&&Tn(!1)}},Ia),Pu(()=>{Tn(!0)}),s&&(sn(!0),Mr(c))}function ny(r){return`${(Math.max(0,r)/1e3).toFixed(1)}s`}var un,dn,fn,ri,La;class od{constructor(){nt(this,ri);nt(this,un,Ee(null));nt(this,dn,Ee(null));nt(this,fn,Ee(Kt([])));Te(this,"nextId",1)}get startedAt(){return u(xe(this,un))}set startedAt(e){N(xe(this,un),e,!0)}get label(){return u(xe(this,dn))}set label(e){N(xe(this,dn),e,!0)}get steps(){return u(xe(this,fn))}set steps(e){N(xe(this,fn),e,!0)}get active(){return this.startedAt!==null}get current(){return this.steps.length?this.steps[this.steps.length-1]:null}elapsedMs(e=Date.now()){return this.startedAt===null?0:Math.max(0,e-this.startedAt)}begin(e,t=Date.now()){Qt(()=>{this.startedAt=t,this.label=e,this.steps=[],this.nextId=1})}step(e,t,n=Date.now()){Qt(()=>{if(this.startedAt===null)return;const i=this.steps.map(o=>o.status==="active"?{...o,status:"done",durationMs:n-o.startedAt}:o);this.steps=[...i,{id:this.nextId++,label:e,...t?{detail:t}:{},startedAt:n,durationMs:null,status:"active"}]})}succeed(e=Date.now()){Qt(()=>{ds(this,ri,La).call(this,e),this.startedAt=null})}fail(e,t=Date.now()){Qt(()=>{this.steps=this.steps.map(n=>n.status==="active"?{...n,status:"error",durationMs:t-n.startedAt,...e?{error:e}:{}}:n),this.startedAt=null})}}un=new WeakMap,dn=new WeakMap,fn=new WeakMap,ri=new WeakSet,La=function(e){this.steps=this.steps.map(t=>t.status==="active"?{...t,status:"done",durationMs:e-t.startedAt}:t)};const Xr=new od,fr=Object.freeze({vcs:!1,clusterStatus:!1,collectionMetadata:!1,cdcStream:!1}),ms={vcs:"vcs",versioning:"vcs",version_control:"vcs",cluster:"clusterStatus",cluster_status:"clusterStatus",collection_metadata:"collectionMetadata",collections_metadata:"collectionMetadata",cdc:"cdcStream",changes_stream:"cdcStream",cdc_stream:"cdcStream"};function sd(r){var t;const e={...fr};for(const n of r.features??[]){const i=ms[((t=n==null?void 0:n.toLowerCase)==null?void 0:t.call(n))??""];i&&(e[i]=!0)}for(const[n,i]of Object.entries(r.capabilities??{})){const o=ms[n.toLowerCase()];o&&(e[o]=i===!0)}return e}const ad=/pass(word)?|secret|token|api[-_]?key|authorization|auth|credential|cookie|session|bearer|private[-_]?key|mfa/i,cd="«redacted»";function co(r,e=0){if(e>6)return"«…»";if(Array.isArray(r))return r.slice(0,100).map(t=>co(t,e+1));if(r&&typeof r=="object"){const t={};for(const[n,i]of Object.entries(r))t[n]=ad.test(n)?cd:co(i,e+1);return t}return r}function vs(r){if(r==null)return;let e=r;if(typeof r=="string"){if(r.length===0)return;try{e=JSON.parse(r)}catch{return r.length>2e3?`${r.slice(0,2e3)}…`:r}}try{const t=JSON.stringify(co(e),null,2);return t.length>4e3?`${t.slice(0,4e3)}…`:t}catch{return}}class ld{constructor(e=500){Te(this,"entries",[]);Te(this,"listeners",new Set);Te(this,"sinks",new Set);Te(this,"nextId",1);this.capacity=e}record(e){const t={...e,id:this.nextId++};this.entries.push(t),this.entries.length>this.capacity&&this.entries.splice(0,this.entries.length-this.capacity),this.emit();for(const n of this.sinks)try{n(t)}catch{}return t}addSink(e){return this.sinks.add(e),()=>{this.sinks.delete(e)}}snapshot(){return this.entries.slice()}get size(){return this.entries.length}clear(){this.entries.length!==0&&(this.entries=[],this.emit())}subscribe(e){return this.listeners.add(e),e(this.snapshot()),()=>{this.listeners.delete(e)}}emit(){const e=this.snapshot();for(const t of this.listeners)t(e)}}const Tr=new ld,ys=new Set,Li=new Map;function ud(r){return(r instanceof Error?r.message:String(r)).includes("route not found: GET /collections/")}function dd(r){const e=r instanceof Error?r.message:String(r);return/ → (404|405|501)\b/.test(e)}function bs(r){return new Error(`GET /collections/:name unsupported by this reddb server (${r})`)}function fd(r){if(!r||typeof r!="object")return!1;const e=r;return typeof e.kind=="string"&&e.kind.length>0&&typeof e.name=="string"&&e.name.length>0&&(e.tenant===void 0||typeof e.tenant=="string")}async function*hd(r){const e=r.getReader(),t=new TextDecoder;let n="";try{for(;;){const{done:o,value:s}=await e.read();if(o)break;n+=t.decode(s,{stream:!0});let a;for(;(a=n.indexOf(`
|
|
3
|
-
`))!==-1;){const c=n.slice(0,a).trim();n=n.slice(a+1),c&&(yield JSON.parse(c))}}const i=n.trim();i&&(yield JSON.parse(i))}finally{e.releaseLock()}}const pd=/^\s*select\b/i;function gd(r){var e;if(Array.isArray(r))return r.length;if(r&&typeof r=="object"){const t=r;if(typeof t.record_count=="number")return t.record_count;if(Array.isArray((e=t.result)==null?void 0:e.records))return t.result.records.length}}function Ti(r){if(r instanceof Error)return r.message||String(r);if(typeof r=="string")return r;if(r&&typeof r=="object"){const e=r.message;if(typeof e=="string"&&e)return e;try{const t=JSON.stringify(r);if(t&&t!=="{}")return t}catch{}}return String(r)}async function iy(r,e,t={}){var i;const n=t.signal?{signal:t.signal}:void 0;if(!pd.test(e))return n?r.query(e,n):r.query(e);try{const o=await r.queryStreamCollect(e,t);return{ok:!0,query:e,record_count:o.rowCount,result:{columns:o.columns,records:o.rows.map(s=>s.values&&typeof s.values=="object"&&("nodes"in s||"edges"in s||"paths"in s||"vector_results"in s)?s:{values:s})},streamed:!0,truncated:o.truncated}}catch(o){if((i=t.signal)!=null&&i.aborted||o instanceof Error&&o.name==="AbortError")throw o;return n?r.query(e,n):r.query(e)}}class wo{constructor(e,t={}){Te(this,"baseUrl");Te(this,"headers");Te(this,"fetcher");this.baseUrl=e.replace(/\/$/,""),this.headers=t.headers,this.fetcher=t.fetch??globalThis.fetch.bind(globalThis)}async json(e,t){const n=`${this.baseUrl}${e}`,i={"Content-Type":"application/json"};Object.assign(i,this.headers),Object.assign(i,t==null?void 0:t.headers);const o=(t==null?void 0:t.method)??"GET",s=Date.now(),a=performance.now(),c=vs(t==null?void 0:t.body),l=()=>Math.round(performance.now()-a);let d;try{d=await this.fetcher(n,{...t,headers:i})}catch(g){throw Tr.record({kind:"http",verb:o,target:e,startedAt:s,durationMs:l(),ok:!1,payload:c,error:Ti(g)}),g}if(!d.ok){const g=await d.text().catch(()=>""),y=`${o} ${e} → ${d.status} ${g.slice(0,200)}`;throw Tr.record({kind:"http",verb:o,target:e,startedAt:s,durationMs:l(),ok:!1,status:d.status,payload:c,error:y}),new Error(y)}const f=await d.json(),h=gd(f);return Tr.record({kind:h===void 0?"http":"query",verb:o,target:e,startedAt:s,durationMs:l(),ok:!0,status:d.status,...h===void 0?{}:{rowCount:h},payload:c}),f}async login(e,t){const n=new URL(this.baseUrl);if(n.username||n.password||n.search||n.hash||n.protocol!=="https:"&&!(n.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(n.hostname)))throw new Error("Use HTTPS to sign in to a remote database.");const i=await this.fetcher(`${this.baseUrl}/auth/login`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"omit",redirect:"error",body:JSON.stringify({username:e,password:t})});if(!i.ok)throw new Error("Database sign-in failed. Check your credentials and try again.");const o=await i.json();if(o.ok!==!0||typeof o.token!="string"||!o.token)throw new Error("The database did not return a session token.");return o.token}async stats(){return this.json("/stats")}async clusterStatus(){return this.json("/cluster/status")}async metricsCatalog(){return(await this.query("SELECT path, kind, role, unit, supports_prometheus_query, created_at_ms FROM red.metrics")).result.records.map(t=>{const n=t.values;return{path:String(n.path??""),kind:n.kind,role:String(n.role??"metric"),unit:n.unit??null,supports_prometheus_query:n.supports_prometheus_query!==!1,created_at_ms:typeof n.created_at_ms=="number"?n.created_at_ms:void 0}})}async promQuery(e,t){const n=new URLSearchParams({query:e});return t!==void 0&&n.set("time",String(t)),this.json(`/api/v1/query?${n}`)}async promQueryRange(e,t,n,i){const o=new URLSearchParams({query:e,start:String(t),end:String(n),step:String(i)});return this.json(`/api/v1/query_range?${o}`)}async ping(){const e=performance.now();try{return await this.json("/stats"),{ok:!0,rtt_ms:Math.round(performance.now()-e)}}catch(t){return{ok:!1,error:Ti(t)}}}async capabilities(){try{const n=await this.json("/capabilities");if(!n||typeof n!="object"||Array.isArray(n)||n.ok===!1)return{...fr};if("features"in n||"capabilities"in n)return sd(n)}catch(n){if(!dd(n))return{...fr}}const[e,t]=await Promise.all([this.probeGet("/repo/commits?limit=1"),this.probeGet("/cluster/status")]);return{...fr,vcs:e,clusterStatus:t}}async probeGet(e){try{return await this.json(e),!0}catch{return!1}}async collections(){return(await this.json("/collections")).collections}async collection(e){if(ys.has(this.baseUrl))throw bs(this.baseUrl);const t=`/collections/${encodeURIComponent(e)}`,n=Li.get(this.baseUrl);if(n){if(!await n)throw bs(this.baseUrl);return this.json(t)}let i;const o=new Promise(s=>{i=s});Li.set(this.baseUrl,o);try{const s=await this.json(t);return i(!0),s}catch(s){throw ud(s)?(ys.add(this.baseUrl),i(!1)):i(!0),s}finally{Li.delete(this.baseUrl)}}async createCollection(e){await this.json("/collections",{method:"POST",body:JSON.stringify({name:e})})}async insertDocument(e,t){return this.json(`/collections/${encodeURIComponent(e)}/documents`,{method:"POST",body:JSON.stringify(t)})}async query(e,t={}){return this.json("/query",{method:"POST",body:JSON.stringify({query:e}),signal:t.signal})}async queryStreamCollect(e,t={}){const n=t.maxRows??1e4,i={"Content-Type":"application/json",Accept:"application/x-ndjson"};Object.assign(i,this.headers);const o=Date.now(),s=performance.now(),a=JSON.stringify({query:e}),c=vs(a),l=()=>Math.round(performance.now()-s);let d;try{d=await this.fetcher(`${this.baseUrl}/query/stream`,{method:"POST",headers:i,body:a,signal:t.signal})}catch(h){throw Tr.record({kind:"query",verb:"POST",target:"/query/stream",startedAt:o,durationMs:l(),ok:!1,payload:c,error:Ti(h)}),h}if(!d.ok||!d.body){const h=d.body?await d.text().catch(()=>""):"",g=`POST /query/stream → ${d.status} ${h.slice(0,200)}`;throw Tr.record({kind:"query",verb:"POST",target:"/query/stream",startedAt:o,durationMs:l(),ok:!1,status:d.status,payload:c,error:g}),new Error(g)}const f={columns:[],rows:[],rowCount:0,truncated:!1};for await(const h of hd(d.body))if("descriptor"in h)f.columns=(h.descriptor.columns??[]).map(g=>typeof g=="string"?g:g.name),f.schemaFingerprint=h.descriptor.schema_fingerprint;else if("cursor"in h)f.cursor=h.cursor.token;else if("row"in h){if(f.rows.length>=n){f.truncated=!0;break}f.rows.push(h.row),f.rowCount=f.rows.length}else if("end"in h||"cancelled"in h)break;return Tr.record({kind:"query",verb:"POST",target:"/query/stream",startedAt:o,durationMs:l(),ok:!0,status:d.status,rowCount:f.rowCount,payload:c}),f.truncated&&f.cursor&&await this.cancelQueryStream(f.cursor).catch(()=>{}),f}async cancelQueryStream(e){await this.json("/query/stream/cancel",{method:"POST",body:JSON.stringify({cursor:e})}).catch(()=>{})}async collectionVcs(e){return(await this.json(`/collections/${encodeURIComponent(e)}/vcs`)).result}async setCollectionVcs(e,t){return(await this.json(`/collections/${encodeURIComponent(e)}/vcs`,{method:"PUT",body:JSON.stringify({versioned:t})})).result}async commits(e={}){const t=new URLSearchParams;e.from&&t.set("from",e.from),e.to&&t.set("to",e.to),e.branch&&t.set("branch",e.branch),e.limit!==void 0&&t.set("limit",String(e.limit)),e.skip!==void 0&&t.set("skip",String(e.skip)),e.noMerges!==void 0&&t.set("no_merges",String(e.noMerges));const n=t.toString()?`?${t}`:"";return(await this.json(`/repo/commits${n}`)).result}async commitDiff(e,t,n={}){const i=new URLSearchParams;n.collection&&i.set("collection",n.collection),n.summary!==void 0&&i.set("summary",String(n.summary));const o=i.toString()?`?${i}`:"";return(await this.json(`/repo/commits/${encodeURIComponent(e)}/diff/${encodeURIComponent(t)}${o}`)).result}async replication(){return this.json("/replication/status").catch(()=>({ok:!1,role:"standalone"}))}async whoami(){return this.json("/auth/whoami")}async ask(e,t={}){return this.json("/ai/ask",{method:"POST",body:JSON.stringify({question:e,...t})})}async users(){return(await this.json("/auth/users")).users}async tenants(){return(await this.json("/auth/tenants")).tenants??[]}async policies(){return(await this.json("/auth/policies")).policies??[]}async authCan(e){const t=await this.json("/auth/can",{method:"POST",body:JSON.stringify({checks:e})});if(!Array.isArray(t.results))throw new Error(t.error??"POST /auth/can returned no results");return e.map((n,i)=>{var a;const o=((a=t.results)==null?void 0:a[i])??{},s=fd(o.resource)?o.resource:n.resource;return{action:typeof o.action=="string"?o.action:n.action,resource:s,current_tenant:typeof o.current_tenant=="string"?o.current_tenant:n.current_tenant,allowed:o.allowed===!0,reason:typeof o.reason=="string"?o.reason:void 0}})}async changes(e,t={}){const n=new URLSearchParams;e!==void 0&&n.set("since_lsn",String(e)),t.limit!==void 0&&n.set("limit",String(t.limit));const i=n.toString()?`?${n}`:"",s=(await this.json("/changes"+i)).events??[];return t.collection?s.filter(a=>a.collection===t.collection):s}async rows(e){return(await this.query(e)).result.records.map(n=>n.values)}}class md extends Error{constructor(e){super(`Unknown connection: ${e}`),this.id=e,this.name="UnknownConnectionError"}}class vd extends Error{constructor(){super("No active connection — call connect() first"),this.name="NotConnectedError"}}class ws extends Error{constructor(e,t){super(`Connection ${e} unreachable: ${t}`),this.id=e,this.reason=t,this.name="UnreachableConnectionError"}}const yd={http:"http",https:"https",red:"http","red+tcp":"http","red+wire":"http",reds:"https","red+tls":"https","red+http":"http","red+https":"https","red+unix":"unix",file:"unix",unix:"unix"};function Ta(r){const e=r.trim();if(!e)return null;const t=e.match(/^([a-z+]+):\/\//i);return t?yd[t[1].toLowerCase()]??null:"http"}const _o=["http","https"],bd=["http","https","unix"];function wd(r,e){const t=Ta(r);return t!==null&&e.includes(t)}class ur extends Error{constructor(e="Enter a valid connection URL or its Base64 encoding."){super(e),this.name="ConnectionStringError"}}const _d=16384,xd=/token|secret|password|passwd|auth|credential|api[-_]?key|bearer/i;function Ga(r){const e=r.trim();if(!e||e.length>_d)throw new ur;if(/^[a-z][a-z0-9+.-]*:\/\//i.test(e))return e;const t=/^base64(?:url)?:/i.test(e),n=t?e.replace(/^base64(?:url)?:/i,""):e;if(!t&&!/^[\w+/=-]+$/.test(n))return e;let i=!1;try{if(!/^[A-Za-z0-9+/_-]+={0,2}$/.test(n))throw new Error;const o=n.replace(/-/g,"+").replace(/_/g,"/"),s=o.replace(/=+$/,"");if(s.length%4===1||o.includes("=")&&o.length%4!==0)throw new Error;const a=atob(s+"=".repeat((4-s.length%4)%4));if(btoa(a).replace(/=+$/,"")!==s)throw new Error;const c=new TextDecoder("utf-8",{fatal:!0}).decode(Uint8Array.from(a,l=>l.charCodeAt(0)));if(i=!0,!/^[a-z][a-z0-9+.-]*:\/\//i.test(c))throw new Error;return c}catch{if(!t&&!i&&/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/i.test(e))return e;throw new ur}}function kd(r){const e="[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?";return new RegExp(`^${e}\\.${e}\\.dbs\\.reddb\\.(?:dev|io)$`,"i").test(r)}function pr(r){let e=Ga(r);if(/^(file|unix|red\+unix):\/\//i.test(e))return{url:e};e.includes("://")||(e="http://"+e);const t=/^([a-z][a-z0-9+.-]*):\/\/(.+)$/i.exec(e);if(!t)throw new ur;const n=t[1].toLowerCase(),i=["red","red+tcp","red+wire","reds","red+tls"].includes(n),o=["https","reds","red+tls","red+https"].includes(n);if(!i&&!["http","https","red+http","red+https"].includes(n))throw new ur("This connection requires an HTTP or HTTPS endpoint.");try{const s=new URL(`${o?"https":"http"}://${t[2]}`);if(!s.hostname||/\s/.test(s.hostname)||s.hash)throw new Error;for(const l of s.searchParams.keys())if(xd.test(l))throw new ur("Use URI credentials or the sign-in fields, not secrets in query parameters.");let a;if(s.username||s.password){if(!s.username||!s.password)throw new ur("A connection string needs both a username and a password.");a={username:decodeURIComponent(s.username),password:decodeURIComponent(s.password)},s.username="",s.password=""}return i&&(kd(s.hostname)?(s.protocol="https:",s.port=""):s.port="5055"),{url:s.href.replace(/\/$/,""),...a?{credentials:a}:{}}}catch(s){throw s instanceof ur?s:new ur}}const Ed=["endpoint","connection","red_url","red"],Sd="view",Xn="cs",Ra="to",Cd="token",Ad=/(token|secret|password|passwd|auth|credential|api[-_]?key|bearer)/i;class Nr extends Error{constructor(e,t){super(t),this.code=e,this.name="OpenContractError"}}function $d(r,e=""){if(r instanceof URL)return{search:r.search,hash:r.hash};const t=r??"";if(/^[a-z][a-z0-9+.-]*:\/\//i.test(t)){const s=new URL(t);return{search:s.search,hash:s.hash}}const n=t.indexOf("#"),i=n>=0?t.slice(0,n):t,o=n>=0?t.slice(n):e;return{search:i,hash:o}}function _s(r){return/^file:/i.test(r)||/^~(?:\/|\\|$)/.test(r)||/^(?:\.{1,2})(?:\/|\\|$)/.test(r)||/^(?:\/|\\)/.test(r)||/^[a-z]:[\\/]/i.test(r)||r.includes("\\")}function Oa(r){const e=r.trim();if(!e)throw new Nr("EMPTY_CS","Open Contract cs is empty");if(_s(e))throw new Nr("FILESYSTEM_PATH","Open Contract cs must be a browser-reachable URL, not a filesystem path");try{const t=Ga(e);if(!/^[a-z][a-z0-9+.-]*:\/\//i.test(t))throw new Error;if(_s(t))throw new Error;const n=pr(t);if(!/^https?:\/\//.test(n.url))throw new Error}catch{throw new Nr("MALFORMED_URL","Enter a valid HTTP connection string or its Base64 encoding.")}return e}function za(r){const e=r.trim();if(!e)throw new Nr("MALFORMED_ROUTE","Open Contract to is empty");if(/^[a-z][a-z0-9+.-]*:/i.test(e)||e.startsWith("//")||e.includes("\\"))throw new Nr("MALFORMED_ROUTE","Open Contract to must be an app route");const t=e.startsWith("/")?e:`/${e}`;if(t==="/query"||t==="/collections"||t==="/cluster"||t==="/security"||t.startsWith("/c/"))return t;throw new Nr("MALFORMED_ROUTE","Open Contract to must target a known red-ui route")}function xo(r,e=""){const{search:t,hash:n}=$d(r,e),i=new URLSearchParams(t),o=new URLSearchParams(n.startsWith("#")?n.slice(1):n),s={},a=o.get(Xn)??i.get(Xn);a!==null&&(s.cs=Oa(a));const c=i.get(Ra);c!==null&&(s.to=za(c));const l=o.get(Cd);return l&&(s.token=l),s}function Dd(r,e=""){const t=new URLSearchParams(r??""),n={},i=new URLSearchParams(e.replace(/^#/,"")).get(Xn)??t.get(Xn);if(i!==null)try{n.endpoint=pr(Oa(i)).url}catch{}const o=t.get(Ra);if(o!==null)try{n.to=za(o)}catch{}for(const a of Ed){if(n.endpoint)break;const c=t.get(a);if(c&&!Ad.test(a)){try{const l=pr(c);n.endpoint=l.credentials?l.url:c}catch{}break}}const s=t.get(Sd);s&&(n.view=s);try{xo(r,e).token}catch{}return n}function Id(r){return typeof r.endpoint=="string"&&r.endpoint.trim().length>0}function Ld(r){return typeof r.to=="string"&&r.to.trim().length>0}const Td=8;function Gd(){let r=[];return{load:()=>r.slice(),save:e=>{r=e.slice()}}}class Rd{constructor(e={}){Te(this,"presets");Te(this,"history");Te(this,"clientFactory");Te(this,"historyMax");Te(this,"supportedTransports");Te(this,"boot");Te(this,"embeddedResolver");Te(this,"handoffTokens",new Map);Te(this,"active",null);var t,n;this.presets=((t=e.presets)==null?void 0:t.slice())??[],this.history=e.history??Gd(),this.historyMax=e.historyMax??Td,this.clientFactory=e.clientFactory??((i,o)=>new wo(i,o)),this.supportedTransports=((n=e.transports)==null?void 0:n.slice())??[..._o],this.boot=e.bootParams&&(Id(e.bootParams)||Ld(e.bootParams))?{...e.bootParams}:null,this.embeddedResolver=e.embeddedResolver}transports(){return this.supportedTransports.slice()}bootParams(){return this.boot?{...this.boot}:null}useHandoffToken(e,t){const n=t.trim();n&&this.handoffTokens.set(this.handoffKey(e),n)}async list(){const e=new Set,t=[];for(const n of this.presets)e.has(n.url)||(e.add(n.url),t.push(n));for(const n of this.history.load())e.has(n.url)||(e.add(n.url),t.push({id:n.url,label:n.label,url:n.url,role:"primary"}));return t}async connect(e){const t=this.resolve(e);if(!t)throw new md(e);let n=t.url;if(this.embeddedResolver&&/^file:\/\//i.test(t.url))try{n=await this.embeddedResolver(t.url)}catch(c){const l=c instanceof Error?c.message:String(c);throw new ws(t.id,l)}const i=this.consumeHandoffToken(t.url),o=this.clientFactory(n,i?{headers:{Authorization:`Bearer ${i}`}}:void 0),s=await o.ping();if(!s.ok)throw new ws(t.id,s.error);const a={connection:t,client:o,rtt_ms:s.rtt_ms};return this.active=a,this.record(t,s.rtt_ms),a}async whoami(){if(!this.active)throw new vd;const e=await this.active.client.whoami();return{authenticated:e.authenticated,username:e.username,role:e.role}}forget(e){const t=this.history.load().filter(n=>n.url!==e);this.history.save(t)}resolve(e){const t=this.presets.find(i=>i.id===e);if(t)return t;const n=this.history.load().find(i=>i.url===e);if(n)return{id:n.url,label:n.label,url:n.url,role:"primary"};if(/^[a-z+]+:\/\//i.test(e)){let i=e;try{i=new URL(e).host||e}catch{}return{id:e,label:i,url:e,role:"primary",description:"Ad-hoc URL."}}return null}handoffKey(e){return e.replace(/\/$/,"")}consumeHandoffToken(e){const t=this.handoffKey(e),n=this.handoffTokens.get(t)??null;return this.handoffTokens.delete(t),n}record(e,t){const n=this.history.load().filter(o=>o.url!==e.url),i=[{url:e.url,label:e.label,last_used:Date.now(),rtt_ms:t},...n].slice(0,this.historyMax);this.history.save(i)}}const Ma="red-ui:connection",Od=["__RED_BOOTSTRAP__","__RED_UI_CONNECTION_BOOTSTRAP__","__RED_UI_BOOTSTRAP__"];function nn(r){return typeof r=="string"&&r.trim()?r.trim():void 0}function zd(r){if(!r||typeof r!="object")return null;const e=nn(r.target),t=nn(r.token),n=nn(r.route),i=nn(r.error);return!e&&!t&&!n&&!i?null:{target:e??null,...i?{error:i}:{},...t?{token:t}:{},...n?{route:n}:{}}}async function Md(r){for(const e of r){let t;try{t=zd(await e())}catch{t=null}if(t)return t}return null}async function Nd(){if(typeof window>"u"||!("__TAURI_INTERNALS__"in window||"__TAURI__"in window))return null;try{return(await hr(()=>import("./DhEqZVGG.js"),[],import.meta.url)).invoke}catch{return null}}async function Pd(r){const e=r??await Nd();if(!e)return null;try{return await e("connection_bootstrap")}catch{return null}}async function Ud(r=globalThis){if(!r||typeof r!="object")return null;const e=r;for(const t of Od){const n=e[t];if(n)try{return typeof n=="function"?await n():n}finally{try{delete e[t]}catch{e[t]=void 0}}}return null}function Wd(){return{consume:!0,location:typeof location>"u"?void 0:{pathname:location.pathname,search:location.search,hash:location.hash},history:typeof history>"u"?void 0:{state:history.state,replaceState:(r,e,t)=>history.replaceState(r,e,t)}}}function jd(r){if(!r.consume||!r.location||!r.history)return;const{pathname:e,search:t,hash:n}=r.location,i=new URLSearchParams(t),o=new URLSearchParams(n.replace(/^#/,""));let s=!1,a=!1;for(const[d,f]of[[i,!1],[o,!0]]){for(const h of[...d.keys()])/token|secret|password|passwd|auth|credential|api[-_]?key|bearer/i.test(h)&&(d.delete(h),f?a=!0:s=!0);for(const h of["cs","endpoint","connection","red_url","red"]){const g=d.get(h);if(g===null)continue;let y;try{h==="cs"&&xo(`?cs=${encodeURIComponent(g)}`),y=pr(g).url}catch{}(f||y!==g)&&(d.delete(h),!f&&y&&d.set(h,y),f?a=!0:s=!0)}}if(!s&&!a)return;const c=s?i.size?`?${i}`:"":t,l=a?o.size?`#${o}`:"":n;try{r.history.replaceState(r.history.state,"",`${e}${c}${l}`)}catch{}}function xs(r=typeof location>"u"?"":location.search,e=typeof location>"u"?"":location.hash,t=Wd()){try{const n=xo(r,e);return!n.cs&&!n.to&&!n.token?null:{target:n.cs,token:n.token,route:n.to}}catch{return{error:"Enter a valid HTTP connection string or its Base64 encoding."}}finally{jd(t)}}function Bd(){try{return typeof localStorage>"u"?void 0:localStorage}catch{return}}function Fd(r=Bd(),e=Ma){if(!r)return null;try{const t=r.getItem(e);if(!t)return null;const n=JSON.parse(t),i=nn(n==null?void 0:n.url);return i?{target:i}:null}catch{return null}}async function Vd(r={}){const e=r.readUrl??(()=>xs()),t=await Md([r.readTauri??Pd,r.readInjectedGlobal??Ud,e,r.readPersisted??(()=>Fd())]);if(t&&!r.readUrl)try{xs()}catch{}return t??{target:null}}class wt extends Error{constructor(t,n){super(n);Te(this,"code");this.name="SecureStoreError",this.code=t}}const Kd=2e5,Hd=16,qd=12;function Rn(r){let e="";for(const t of r)e+=String.fromCharCode(t);return btoa(e)}function Gi(r){const e=atob(r),t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}function Gr(r){const e=new ArrayBuffer(r.byteLength);return new Uint8Array(e).set(r),e}class Yd{constructor(e,t={}){Te(this,"storage");Te(this,"namespace");Te(this,"iterations");Te(this,"subtle");Te(this,"password");Te(this,"keyCache",new Map);var o;if(typeof e!="string"||e.length===0)throw new wt("LOCKED","master password required");const n=t.storage??(typeof globalThis<"u"?globalThis.localStorage:void 0);if(!n)throw new wt("BACKEND_FAILURE","no Storage backend available");const i=t.subtle??(typeof globalThis<"u"?(o=globalThis.crypto)==null?void 0:o.subtle:void 0);if(!i)throw new wt("BACKEND_FAILURE","Web Crypto SubtleCrypto unavailable");this.password=e,this.storage=n,this.namespace=t.namespace??"red-ui:secure",this.iterations=t.iterations??Kd,this.subtle=i}storageKey(e){return`${this.namespace}:${e}`}async deriveKey(e){const t=Rn(e),n=this.keyCache.get(t);if(n)return n;const i=new TextEncoder().encode(this.password),o=await this.subtle.importKey("raw",Gr(i),"PBKDF2",!1,["deriveKey"]),s=await this.subtle.deriveKey({name:"PBKDF2",salt:Gr(e),iterations:this.iterations,hash:"SHA-256"},o,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"]);return this.keyCache.set(t,s),s}randomBytes(e){const t=new Uint8Array(e),n=globalThis.crypto;if(!n)throw new wt("BACKEND_FAILURE","crypto.getRandomValues unavailable");return n.getRandomValues(t),t}async put(e,t){const n=this.randomBytes(Hd),i=this.randomBytes(qd),o=await this.deriveKey(n),s=new TextEncoder().encode(t);let a;try{a=await this.subtle.encrypt({name:"AES-GCM",iv:Gr(i)},o,Gr(s))}catch(l){throw new wt("BACKEND_FAILURE",`encrypt failed: ${l.message}`)}const c={v:1,salt:Rn(n),nonce:Rn(i),ciphertext:Rn(new Uint8Array(a))};try{this.storage.setItem(this.storageKey(e),JSON.stringify(c))}catch(l){throw new wt("BACKEND_FAILURE",`storage write failed: ${l.message}`)}}async get(e){const t=this.storage.getItem(this.storageKey(e));if(!t)return null;let n;try{n=JSON.parse(t)}catch{throw new wt("CORRUPT_ENVELOPE",`key ${e}: not valid JSON`)}if(!n||n.v!==1||typeof n.salt!="string"||typeof n.nonce!="string"||typeof n.ciphertext!="string")throw new wt("CORRUPT_ENVELOPE",`key ${e}: missing envelope fields`);let i,o,s;try{i=Gi(n.salt),o=Gi(n.nonce),s=Gi(n.ciphertext)}catch{throw new wt("CORRUPT_ENVELOPE",`key ${e}: base64 decode failed`)}const a=await this.deriveKey(i);let c;try{c=await this.subtle.decrypt({name:"AES-GCM",iv:Gr(o)},a,Gr(s))}catch{throw new wt("DECRYPT_FAILED",`key ${e}: decryption failed (wrong password or tampered payload)`)}return new TextDecoder().decode(c)}async delete(e){try{this.storage.removeItem(this.storageKey(e))}catch(t){throw new wt("BACKEND_FAILURE",`storage delete failed: ${t.message}`)}}}const Ri="UNKNOWN";function Xd(r){return typeof r=="object"&&r!==null&&typeof r.code=="string"&&typeof r.message=="string"}function Na(r){if(Xd(r)){const e=r.detail;return{code:r.code,message:r.message,...typeof e=="string"&&e.length>0?{detail:e}:{}}}return typeof r=="string"?{code:Ri,message:r}:r instanceof Error?{code:Ri,message:r.message||String(r)}:{code:Ri,message:String(r)}}function Oi(r){const e=Na(r);return e.detail?`${e.message}: ${e.detail}`:e.message}class Jn extends Error{constructor(t){super(t.detail?`${t.message}: ${t.detail}`:t.message);Te(this,"code");Te(this,"detail");this.name="DesktopError",this.code=t.code,this.detail=t.detail}static from(t){return t instanceof Jn?t:new Jn(Na(t))}}class Jd{constructor(e){Te(this,"invoke");Te(this,"service");if(!e.invoke)throw new wt("BACKEND_FAILURE","tauri invoke fn not provided");this.invoke=e.invoke,this.service=e.service??"io.reddb.red-ui"}async put(e,t){try{await this.invoke("keychain_set",{service:this.service,key:e,value:t})}catch(n){throw new wt("BACKEND_FAILURE",`keychain_set failed: ${Oi(n)}`)}}async get(e){try{return await this.invoke("keychain_get",{service:this.service,key:e})??null}catch(t){throw new wt("BACKEND_FAILURE",`keychain_get failed: ${Oi(t)}`)}}async delete(e){try{await this.invoke("keychain_delete",{service:this.service,key:e})}catch(t){throw new wt("BACKEND_FAILURE",`keychain_delete failed: ${Oi(t)}`)}}}/**
|
|
3
|
+
`))!==-1;){const c=n.slice(0,a).trim();n=n.slice(a+1),c&&(yield JSON.parse(c))}}const i=n.trim();i&&(yield JSON.parse(i))}finally{e.releaseLock()}}const pd=/^\s*select\b/i;function gd(r){var e;if(Array.isArray(r))return r.length;if(r&&typeof r=="object"){const t=r;if(typeof t.record_count=="number")return t.record_count;if(Array.isArray((e=t.result)==null?void 0:e.records))return t.result.records.length}}function Ti(r){if(r instanceof Error)return r.message||String(r);if(typeof r=="string")return r;if(r&&typeof r=="object"){const e=r.message;if(typeof e=="string"&&e)return e;try{const t=JSON.stringify(r);if(t&&t!=="{}")return t}catch{}}return String(r)}async function iy(r,e,t={}){var i;const n=t.signal?{signal:t.signal}:void 0;if(!pd.test(e))return n?r.query(e,n):r.query(e);try{const o=await r.queryStreamCollect(e,t);return{ok:!0,query:e,record_count:o.rowCount,result:{columns:o.columns,records:o.rows.map(s=>s.values&&typeof s.values=="object"&&("nodes"in s||"edges"in s||"paths"in s||"vector_results"in s)?s:{values:s})},streamed:!0,truncated:o.truncated}}catch(o){if((i=t.signal)!=null&&i.aborted||o instanceof Error&&o.name==="AbortError")throw o;return n?r.query(e,n):r.query(e)}}class wo{constructor(e,t={}){Te(this,"baseUrl");Te(this,"headers");Te(this,"fetcher");this.baseUrl=e.replace(/\/$/,""),this.headers=t.headers,this.fetcher=t.fetch??globalThis.fetch.bind(globalThis)}async json(e,t){const n=`${this.baseUrl}${e}`,i={"Content-Type":"application/json"};Object.assign(i,this.headers),Object.assign(i,t==null?void 0:t.headers);const o=(t==null?void 0:t.method)??"GET",s=Date.now(),a=performance.now(),c=vs(t==null?void 0:t.body),l=()=>Math.round(performance.now()-a);let d;try{d=await this.fetcher(n,{...t,headers:i})}catch(g){throw Tr.record({kind:"http",verb:o,target:e,startedAt:s,durationMs:l(),ok:!1,payload:c,error:Ti(g)}),g}if(!d.ok){const g=await d.text().catch(()=>""),y=d.status===401?"Database credentials required (HTTP 401). Sign in with a database username and password.":`${o} ${e} → ${d.status} ${g.slice(0,200)}`;throw Tr.record({kind:"http",verb:o,target:e,startedAt:s,durationMs:l(),ok:!1,status:d.status,payload:c,error:y}),new Error(y)}const f=await d.json(),h=gd(f);return Tr.record({kind:h===void 0?"http":"query",verb:o,target:e,startedAt:s,durationMs:l(),ok:!0,status:d.status,...h===void 0?{}:{rowCount:h},payload:c}),f}async login(e,t){const n=new URL(this.baseUrl);if(n.username||n.password||n.search||n.hash||n.protocol!=="https:"&&!(n.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(n.hostname)))throw new Error("Use HTTPS to sign in to a remote database.");const i=await this.fetcher(`${this.baseUrl}/auth/login`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"omit",redirect:"error",body:JSON.stringify({username:e,password:t})});if(!i.ok)throw new Error("Database sign-in failed. Check your credentials and try again.");const o=await i.json();if(o.ok!==!0||typeof o.token!="string"||!o.token)throw new Error("The database did not return a session token.");return o.token}async stats(){return this.json("/stats")}async clusterStatus(){return this.json("/cluster/status")}async metricsCatalog(){return(await this.query("SELECT path, kind, role, unit, supports_prometheus_query, created_at_ms FROM red.metrics")).result.records.map(t=>{const n=t.values;return{path:String(n.path??""),kind:n.kind,role:String(n.role??"metric"),unit:n.unit??null,supports_prometheus_query:n.supports_prometheus_query!==!1,created_at_ms:typeof n.created_at_ms=="number"?n.created_at_ms:void 0}})}async promQuery(e,t){const n=new URLSearchParams({query:e});return t!==void 0&&n.set("time",String(t)),this.json(`/api/v1/query?${n}`)}async promQueryRange(e,t,n,i){const o=new URLSearchParams({query:e,start:String(t),end:String(n),step:String(i)});return this.json(`/api/v1/query_range?${o}`)}async ping(){const e=performance.now();try{return await this.json("/stats"),{ok:!0,rtt_ms:Math.round(performance.now()-e)}}catch(t){return{ok:!1,error:Ti(t)}}}async capabilities(){try{const n=await this.json("/capabilities");if(!n||typeof n!="object"||Array.isArray(n)||n.ok===!1)return{...fr};if("features"in n||"capabilities"in n)return sd(n)}catch(n){if(!dd(n))return{...fr}}const[e,t]=await Promise.all([this.probeGet("/repo/commits?limit=1"),this.probeGet("/cluster/status")]);return{...fr,vcs:e,clusterStatus:t}}async probeGet(e){try{return await this.json(e),!0}catch{return!1}}async collections(){return(await this.json("/collections")).collections}async collection(e){if(ys.has(this.baseUrl))throw bs(this.baseUrl);const t=`/collections/${encodeURIComponent(e)}`,n=Li.get(this.baseUrl);if(n){if(!await n)throw bs(this.baseUrl);return this.json(t)}let i;const o=new Promise(s=>{i=s});Li.set(this.baseUrl,o);try{const s=await this.json(t);return i(!0),s}catch(s){throw ud(s)?(ys.add(this.baseUrl),i(!1)):i(!0),s}finally{Li.delete(this.baseUrl)}}async createCollection(e){await this.json("/collections",{method:"POST",body:JSON.stringify({name:e})})}async insertDocument(e,t){return this.json(`/collections/${encodeURIComponent(e)}/documents`,{method:"POST",body:JSON.stringify(t)})}async query(e,t={}){return this.json("/query",{method:"POST",body:JSON.stringify({query:e}),signal:t.signal})}async queryStreamCollect(e,t={}){const n=t.maxRows??1e4,i={"Content-Type":"application/json",Accept:"application/x-ndjson"};Object.assign(i,this.headers);const o=Date.now(),s=performance.now(),a=JSON.stringify({query:e}),c=vs(a),l=()=>Math.round(performance.now()-s);let d;try{d=await this.fetcher(`${this.baseUrl}/query/stream`,{method:"POST",headers:i,body:a,signal:t.signal})}catch(h){throw Tr.record({kind:"query",verb:"POST",target:"/query/stream",startedAt:o,durationMs:l(),ok:!1,payload:c,error:Ti(h)}),h}if(!d.ok||!d.body){const h=d.body?await d.text().catch(()=>""):"",g=`POST /query/stream → ${d.status} ${h.slice(0,200)}`;throw Tr.record({kind:"query",verb:"POST",target:"/query/stream",startedAt:o,durationMs:l(),ok:!1,status:d.status,payload:c,error:g}),new Error(g)}const f={columns:[],rows:[],rowCount:0,truncated:!1};for await(const h of hd(d.body))if("descriptor"in h)f.columns=(h.descriptor.columns??[]).map(g=>typeof g=="string"?g:g.name),f.schemaFingerprint=h.descriptor.schema_fingerprint;else if("cursor"in h)f.cursor=h.cursor.token;else if("row"in h){if(f.rows.length>=n){f.truncated=!0;break}f.rows.push(h.row),f.rowCount=f.rows.length}else if("end"in h||"cancelled"in h)break;return Tr.record({kind:"query",verb:"POST",target:"/query/stream",startedAt:o,durationMs:l(),ok:!0,status:d.status,rowCount:f.rowCount,payload:c}),f.truncated&&f.cursor&&await this.cancelQueryStream(f.cursor).catch(()=>{}),f}async cancelQueryStream(e){await this.json("/query/stream/cancel",{method:"POST",body:JSON.stringify({cursor:e})}).catch(()=>{})}async collectionVcs(e){return(await this.json(`/collections/${encodeURIComponent(e)}/vcs`)).result}async setCollectionVcs(e,t){return(await this.json(`/collections/${encodeURIComponent(e)}/vcs`,{method:"PUT",body:JSON.stringify({versioned:t})})).result}async commits(e={}){const t=new URLSearchParams;e.from&&t.set("from",e.from),e.to&&t.set("to",e.to),e.branch&&t.set("branch",e.branch),e.limit!==void 0&&t.set("limit",String(e.limit)),e.skip!==void 0&&t.set("skip",String(e.skip)),e.noMerges!==void 0&&t.set("no_merges",String(e.noMerges));const n=t.toString()?`?${t}`:"";return(await this.json(`/repo/commits${n}`)).result}async commitDiff(e,t,n={}){const i=new URLSearchParams;n.collection&&i.set("collection",n.collection),n.summary!==void 0&&i.set("summary",String(n.summary));const o=i.toString()?`?${i}`:"";return(await this.json(`/repo/commits/${encodeURIComponent(e)}/diff/${encodeURIComponent(t)}${o}`)).result}async replication(){return this.json("/replication/status").catch(()=>({ok:!1,role:"standalone"}))}async whoami(){return this.json("/auth/whoami")}async ask(e,t={}){return this.json("/ai/ask",{method:"POST",body:JSON.stringify({question:e,...t})})}async users(){return(await this.json("/auth/users")).users}async tenants(){return(await this.json("/auth/tenants")).tenants??[]}async policies(){return(await this.json("/auth/policies")).policies??[]}async authCan(e){const t=await this.json("/auth/can",{method:"POST",body:JSON.stringify({checks:e})});if(!Array.isArray(t.results))throw new Error(t.error??"POST /auth/can returned no results");return e.map((n,i)=>{var a;const o=((a=t.results)==null?void 0:a[i])??{},s=fd(o.resource)?o.resource:n.resource;return{action:typeof o.action=="string"?o.action:n.action,resource:s,current_tenant:typeof o.current_tenant=="string"?o.current_tenant:n.current_tenant,allowed:o.allowed===!0,reason:typeof o.reason=="string"?o.reason:void 0}})}async changes(e,t={}){const n=new URLSearchParams;e!==void 0&&n.set("since_lsn",String(e)),t.limit!==void 0&&n.set("limit",String(t.limit));const i=n.toString()?`?${n}`:"",s=(await this.json("/changes"+i)).events??[];return t.collection?s.filter(a=>a.collection===t.collection):s}async rows(e){return(await this.query(e)).result.records.map(n=>n.values)}}class md extends Error{constructor(e){super(`Unknown connection: ${e}`),this.id=e,this.name="UnknownConnectionError"}}class vd extends Error{constructor(){super("No active connection — call connect() first"),this.name="NotConnectedError"}}class ws extends Error{constructor(e,t){super(`Connection ${e} unreachable: ${t}`),this.id=e,this.reason=t,this.name="UnreachableConnectionError"}}const yd={http:"http",https:"https",red:"http","red+tcp":"http","red+wire":"http",reds:"https","red+tls":"https","red+http":"http","red+https":"https","red+unix":"unix",file:"unix",unix:"unix"};function Ta(r){const e=r.trim();if(!e)return null;const t=e.match(/^([a-z+]+):\/\//i);return t?yd[t[1].toLowerCase()]??null:"http"}const _o=["http","https"],bd=["http","https","unix"];function wd(r,e){const t=Ta(r);return t!==null&&e.includes(t)}class ur extends Error{constructor(e="Enter a valid connection URL or its Base64 encoding."){super(e),this.name="ConnectionStringError"}}const _d=16384,xd=/token|secret|password|passwd|auth|credential|api[-_]?key|bearer/i;function Ga(r){const e=r.trim();if(!e||e.length>_d)throw new ur;if(/^[a-z][a-z0-9+.-]*:\/\//i.test(e))return e;const t=/^base64(?:url)?:/i.test(e),n=t?e.replace(/^base64(?:url)?:/i,""):e;if(!t&&!/^[\w+/=-]+$/.test(n))return e;let i=!1;try{if(!/^[A-Za-z0-9+/_-]+={0,2}$/.test(n))throw new Error;const o=n.replace(/-/g,"+").replace(/_/g,"/"),s=o.replace(/=+$/,"");if(s.length%4===1||o.includes("=")&&o.length%4!==0)throw new Error;const a=atob(s+"=".repeat((4-s.length%4)%4));if(btoa(a).replace(/=+$/,"")!==s)throw new Error;const c=new TextDecoder("utf-8",{fatal:!0}).decode(Uint8Array.from(a,l=>l.charCodeAt(0)));if(i=!0,!/^[a-z][a-z0-9+.-]*:\/\//i.test(c))throw new Error;return c}catch{if(!t&&!i&&/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/i.test(e))return e;throw new ur}}function kd(r){const e="[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?";return new RegExp(`^${e}\\.${e}\\.dbs\\.reddb\\.(?:dev|io)$`,"i").test(r)}function pr(r){let e=Ga(r);if(/^(file|unix|red\+unix):\/\//i.test(e))return{url:e};e.includes("://")||(e="http://"+e);const t=/^([a-z][a-z0-9+.-]*):\/\/(.+)$/i.exec(e);if(!t)throw new ur;const n=t[1].toLowerCase(),i=["red","red+tcp","red+wire","reds","red+tls"].includes(n),o=["https","reds","red+tls","red+https"].includes(n);if(!i&&!["http","https","red+http","red+https"].includes(n))throw new ur("This connection requires an HTTP or HTTPS endpoint.");try{const s=new URL(`${o?"https":"http"}://${t[2]}`);if(!s.hostname||/\s/.test(s.hostname)||s.hash)throw new Error;for(const l of s.searchParams.keys())if(xd.test(l))throw new ur("Use URI credentials or the sign-in fields, not secrets in query parameters.");let a;if(s.username||s.password){if(!s.username||!s.password)throw new ur("A connection string needs both a username and a password.");a={username:decodeURIComponent(s.username),password:decodeURIComponent(s.password)},s.username="",s.password=""}return i&&(kd(s.hostname)?(s.protocol="https:",s.port=""):s.port="5055"),{url:s.href.replace(/\/$/,""),...a?{credentials:a}:{}}}catch(s){throw s instanceof ur?s:new ur}}const Ed=["endpoint","connection","red_url","red"],Sd="view",Xn="cs",Ra="to",Cd="token",Ad=/(token|secret|password|passwd|auth|credential|api[-_]?key|bearer)/i;class Nr extends Error{constructor(e,t){super(t),this.code=e,this.name="OpenContractError"}}function $d(r,e=""){if(r instanceof URL)return{search:r.search,hash:r.hash};const t=r??"";if(/^[a-z][a-z0-9+.-]*:\/\//i.test(t)){const s=new URL(t);return{search:s.search,hash:s.hash}}const n=t.indexOf("#"),i=n>=0?t.slice(0,n):t,o=n>=0?t.slice(n):e;return{search:i,hash:o}}function _s(r){return/^file:/i.test(r)||/^~(?:\/|\\|$)/.test(r)||/^(?:\.{1,2})(?:\/|\\|$)/.test(r)||/^(?:\/|\\)/.test(r)||/^[a-z]:[\\/]/i.test(r)||r.includes("\\")}function Oa(r){const e=r.trim();if(!e)throw new Nr("EMPTY_CS","Open Contract cs is empty");if(_s(e))throw new Nr("FILESYSTEM_PATH","Open Contract cs must be a browser-reachable URL, not a filesystem path");try{const t=Ga(e);if(!/^[a-z][a-z0-9+.-]*:\/\//i.test(t))throw new Error;if(_s(t))throw new Error;const n=pr(t);if(!/^https?:\/\//.test(n.url))throw new Error}catch{throw new Nr("MALFORMED_URL","Enter a valid HTTP connection string or its Base64 encoding.")}return e}function za(r){const e=r.trim();if(!e)throw new Nr("MALFORMED_ROUTE","Open Contract to is empty");if(/^[a-z][a-z0-9+.-]*:/i.test(e)||e.startsWith("//")||e.includes("\\"))throw new Nr("MALFORMED_ROUTE","Open Contract to must be an app route");const t=e.startsWith("/")?e:`/${e}`;if(t==="/query"||t==="/collections"||t==="/cluster"||t==="/security"||t.startsWith("/c/"))return t;throw new Nr("MALFORMED_ROUTE","Open Contract to must target a known red-ui route")}function xo(r,e=""){const{search:t,hash:n}=$d(r,e),i=new URLSearchParams(t),o=new URLSearchParams(n.startsWith("#")?n.slice(1):n),s={},a=o.get(Xn)??i.get(Xn);a!==null&&(s.cs=Oa(a));const c=i.get(Ra);c!==null&&(s.to=za(c));const l=o.get(Cd);return l&&(s.token=l),s}function Dd(r,e=""){const t=new URLSearchParams(r??""),n={},i=new URLSearchParams(e.replace(/^#/,"")).get(Xn)??t.get(Xn);if(i!==null)try{n.endpoint=pr(Oa(i)).url}catch{}const o=t.get(Ra);if(o!==null)try{n.to=za(o)}catch{}for(const a of Ed){if(n.endpoint)break;const c=t.get(a);if(c&&!Ad.test(a)){try{const l=pr(c);n.endpoint=l.credentials?l.url:c}catch{}break}}const s=t.get(Sd);s&&(n.view=s);try{xo(r,e).token}catch{}return n}function Id(r){return typeof r.endpoint=="string"&&r.endpoint.trim().length>0}function Ld(r){return typeof r.to=="string"&&r.to.trim().length>0}const Td=8;function Gd(){let r=[];return{load:()=>r.slice(),save:e=>{r=e.slice()}}}class Rd{constructor(e={}){Te(this,"presets");Te(this,"history");Te(this,"clientFactory");Te(this,"historyMax");Te(this,"supportedTransports");Te(this,"boot");Te(this,"embeddedResolver");Te(this,"handoffTokens",new Map);Te(this,"active",null);var t,n;this.presets=((t=e.presets)==null?void 0:t.slice())??[],this.history=e.history??Gd(),this.historyMax=e.historyMax??Td,this.clientFactory=e.clientFactory??((i,o)=>new wo(i,o)),this.supportedTransports=((n=e.transports)==null?void 0:n.slice())??[..._o],this.boot=e.bootParams&&(Id(e.bootParams)||Ld(e.bootParams))?{...e.bootParams}:null,this.embeddedResolver=e.embeddedResolver}transports(){return this.supportedTransports.slice()}bootParams(){return this.boot?{...this.boot}:null}useHandoffToken(e,t){const n=t.trim();n&&this.handoffTokens.set(this.handoffKey(e),n)}async list(){const e=new Set,t=[];for(const n of this.presets)e.has(n.url)||(e.add(n.url),t.push(n));for(const n of this.history.load())e.has(n.url)||(e.add(n.url),t.push({id:n.url,label:n.label,url:n.url,role:"primary"}));return t}async connect(e){const t=this.resolve(e);if(!t)throw new md(e);let n=t.url;if(this.embeddedResolver&&/^file:\/\//i.test(t.url))try{n=await this.embeddedResolver(t.url)}catch(c){const l=c instanceof Error?c.message:String(c);throw new ws(t.id,l)}const i=this.consumeHandoffToken(t.url),o=this.clientFactory(n,i?{headers:{Authorization:`Bearer ${i}`}}:void 0),s=await o.ping();if(!s.ok)throw new ws(t.id,s.error);const a={connection:t,client:o,rtt_ms:s.rtt_ms};return this.active=a,this.record(t,s.rtt_ms),a}async whoami(){if(!this.active)throw new vd;const e=await this.active.client.whoami();return{authenticated:e.authenticated,username:e.username,role:e.role}}forget(e){const t=this.history.load().filter(n=>n.url!==e);this.history.save(t)}resolve(e){const t=this.presets.find(i=>i.id===e);if(t)return t;const n=this.history.load().find(i=>i.url===e);if(n)return{id:n.url,label:n.label,url:n.url,role:"primary"};if(/^[a-z+]+:\/\//i.test(e)){let i=e;try{i=new URL(e).host||e}catch{}return{id:e,label:i,url:e,role:"primary",description:"Ad-hoc URL."}}return null}handoffKey(e){return e.replace(/\/$/,"")}consumeHandoffToken(e){const t=this.handoffKey(e),n=this.handoffTokens.get(t)??null;return this.handoffTokens.delete(t),n}record(e,t){const n=this.history.load().filter(o=>o.url!==e.url),i=[{url:e.url,label:e.label,last_used:Date.now(),rtt_ms:t},...n].slice(0,this.historyMax);this.history.save(i)}}const Ma="red-ui:connection",Od=["__RED_BOOTSTRAP__","__RED_UI_CONNECTION_BOOTSTRAP__","__RED_UI_BOOTSTRAP__"];function nn(r){return typeof r=="string"&&r.trim()?r.trim():void 0}function zd(r){if(!r||typeof r!="object")return null;const e=nn(r.target),t=nn(r.token),n=nn(r.route),i=nn(r.error);return!e&&!t&&!n&&!i?null:{target:e??null,...i?{error:i}:{},...t?{token:t}:{},...n?{route:n}:{}}}async function Md(r){for(const e of r){let t;try{t=zd(await e())}catch{t=null}if(t)return t}return null}async function Nd(){if(typeof window>"u"||!("__TAURI_INTERNALS__"in window||"__TAURI__"in window))return null;try{return(await hr(()=>import("./DhEqZVGG.js"),[],import.meta.url)).invoke}catch{return null}}async function Pd(r){const e=r??await Nd();if(!e)return null;try{return await e("connection_bootstrap")}catch{return null}}async function Ud(r=globalThis){if(!r||typeof r!="object")return null;const e=r;for(const t of Od){const n=e[t];if(n)try{return typeof n=="function"?await n():n}finally{try{delete e[t]}catch{e[t]=void 0}}}return null}function Wd(){return{consume:!0,location:typeof location>"u"?void 0:{pathname:location.pathname,search:location.search,hash:location.hash},history:typeof history>"u"?void 0:{state:history.state,replaceState:(r,e,t)=>history.replaceState(r,e,t)}}}function jd(r){if(!r.consume||!r.location||!r.history)return;const{pathname:e,search:t,hash:n}=r.location,i=new URLSearchParams(t),o=new URLSearchParams(n.replace(/^#/,""));let s=!1,a=!1;for(const[d,f]of[[i,!1],[o,!0]]){for(const h of[...d.keys()])/token|secret|password|passwd|auth|credential|api[-_]?key|bearer/i.test(h)&&(d.delete(h),f?a=!0:s=!0);for(const h of["cs","endpoint","connection","red_url","red"]){const g=d.get(h);if(g===null)continue;let y;try{h==="cs"&&xo(`?cs=${encodeURIComponent(g)}`),y=pr(g).url}catch{}(f||y!==g)&&(d.delete(h),!f&&y&&d.set(h,y),f?a=!0:s=!0)}}if(!s&&!a)return;const c=s?i.size?`?${i}`:"":t,l=a?o.size?`#${o}`:"":n;try{r.history.replaceState(r.history.state,"",`${e}${c}${l}`)}catch{}}function xs(r=typeof location>"u"?"":location.search,e=typeof location>"u"?"":location.hash,t=Wd()){try{const n=xo(r,e);return!n.cs&&!n.to&&!n.token?null:{target:n.cs,token:n.token,route:n.to}}catch{return{error:"Enter a valid HTTP connection string or its Base64 encoding."}}finally{jd(t)}}function Bd(){try{return typeof localStorage>"u"?void 0:localStorage}catch{return}}function Fd(r=Bd(),e=Ma){if(!r)return null;try{const t=r.getItem(e);if(!t)return null;const n=JSON.parse(t),i=nn(n==null?void 0:n.url);return i?{target:i}:null}catch{return null}}async function Vd(r={}){const e=r.readUrl??(()=>xs()),t=await Md([r.readTauri??Pd,r.readInjectedGlobal??Ud,e,r.readPersisted??(()=>Fd())]);if(t&&!r.readUrl)try{xs()}catch{}return t??{target:null}}class wt extends Error{constructor(t,n){super(n);Te(this,"code");this.name="SecureStoreError",this.code=t}}const Kd=2e5,Hd=16,qd=12;function Rn(r){let e="";for(const t of r)e+=String.fromCharCode(t);return btoa(e)}function Gi(r){const e=atob(r),t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}function Gr(r){const e=new ArrayBuffer(r.byteLength);return new Uint8Array(e).set(r),e}class Yd{constructor(e,t={}){Te(this,"storage");Te(this,"namespace");Te(this,"iterations");Te(this,"subtle");Te(this,"password");Te(this,"keyCache",new Map);var o;if(typeof e!="string"||e.length===0)throw new wt("LOCKED","master password required");const n=t.storage??(typeof globalThis<"u"?globalThis.localStorage:void 0);if(!n)throw new wt("BACKEND_FAILURE","no Storage backend available");const i=t.subtle??(typeof globalThis<"u"?(o=globalThis.crypto)==null?void 0:o.subtle:void 0);if(!i)throw new wt("BACKEND_FAILURE","Web Crypto SubtleCrypto unavailable");this.password=e,this.storage=n,this.namespace=t.namespace??"red-ui:secure",this.iterations=t.iterations??Kd,this.subtle=i}storageKey(e){return`${this.namespace}:${e}`}async deriveKey(e){const t=Rn(e),n=this.keyCache.get(t);if(n)return n;const i=new TextEncoder().encode(this.password),o=await this.subtle.importKey("raw",Gr(i),"PBKDF2",!1,["deriveKey"]),s=await this.subtle.deriveKey({name:"PBKDF2",salt:Gr(e),iterations:this.iterations,hash:"SHA-256"},o,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"]);return this.keyCache.set(t,s),s}randomBytes(e){const t=new Uint8Array(e),n=globalThis.crypto;if(!n)throw new wt("BACKEND_FAILURE","crypto.getRandomValues unavailable");return n.getRandomValues(t),t}async put(e,t){const n=this.randomBytes(Hd),i=this.randomBytes(qd),o=await this.deriveKey(n),s=new TextEncoder().encode(t);let a;try{a=await this.subtle.encrypt({name:"AES-GCM",iv:Gr(i)},o,Gr(s))}catch(l){throw new wt("BACKEND_FAILURE",`encrypt failed: ${l.message}`)}const c={v:1,salt:Rn(n),nonce:Rn(i),ciphertext:Rn(new Uint8Array(a))};try{this.storage.setItem(this.storageKey(e),JSON.stringify(c))}catch(l){throw new wt("BACKEND_FAILURE",`storage write failed: ${l.message}`)}}async get(e){const t=this.storage.getItem(this.storageKey(e));if(!t)return null;let n;try{n=JSON.parse(t)}catch{throw new wt("CORRUPT_ENVELOPE",`key ${e}: not valid JSON`)}if(!n||n.v!==1||typeof n.salt!="string"||typeof n.nonce!="string"||typeof n.ciphertext!="string")throw new wt("CORRUPT_ENVELOPE",`key ${e}: missing envelope fields`);let i,o,s;try{i=Gi(n.salt),o=Gi(n.nonce),s=Gi(n.ciphertext)}catch{throw new wt("CORRUPT_ENVELOPE",`key ${e}: base64 decode failed`)}const a=await this.deriveKey(i);let c;try{c=await this.subtle.decrypt({name:"AES-GCM",iv:Gr(o)},a,Gr(s))}catch{throw new wt("DECRYPT_FAILED",`key ${e}: decryption failed (wrong password or tampered payload)`)}return new TextDecoder().decode(c)}async delete(e){try{this.storage.removeItem(this.storageKey(e))}catch(t){throw new wt("BACKEND_FAILURE",`storage delete failed: ${t.message}`)}}}const Ri="UNKNOWN";function Xd(r){return typeof r=="object"&&r!==null&&typeof r.code=="string"&&typeof r.message=="string"}function Na(r){if(Xd(r)){const e=r.detail;return{code:r.code,message:r.message,...typeof e=="string"&&e.length>0?{detail:e}:{}}}return typeof r=="string"?{code:Ri,message:r}:r instanceof Error?{code:Ri,message:r.message||String(r)}:{code:Ri,message:String(r)}}function Oi(r){const e=Na(r);return e.detail?`${e.message}: ${e.detail}`:e.message}class Jn extends Error{constructor(t){super(t.detail?`${t.message}: ${t.detail}`:t.message);Te(this,"code");Te(this,"detail");this.name="DesktopError",this.code=t.code,this.detail=t.detail}static from(t){return t instanceof Jn?t:new Jn(Na(t))}}class Jd{constructor(e){Te(this,"invoke");Te(this,"service");if(!e.invoke)throw new wt("BACKEND_FAILURE","tauri invoke fn not provided");this.invoke=e.invoke,this.service=e.service??"io.reddb.red-ui"}async put(e,t){try{await this.invoke("keychain_set",{service:this.service,key:e,value:t})}catch(n){throw new wt("BACKEND_FAILURE",`keychain_set failed: ${Oi(n)}`)}}async get(e){try{return await this.invoke("keychain_get",{service:this.service,key:e})??null}catch(t){throw new wt("BACKEND_FAILURE",`keychain_get failed: ${Oi(t)}`)}}async delete(e){try{await this.invoke("keychain_delete",{service:this.service,key:e})}catch(t){throw new wt("BACKEND_FAILURE",`keychain_delete failed: ${Oi(t)}`)}}}/**
|
|
4
4
|
* @file
|
|
5
5
|
* @license @lucide/svelte v1.61.0 - ISC
|
|
6
6
|
*
|
|
@@ -30,6 +30,6 @@ var du=Object.defineProperty;var ls=r=>{throw TypeError(r)};var fu=(r,e,t)=>e in
|
|
|
30
30
|
*
|
|
31
31
|
* This source code is licensed under the ISC license.
|
|
32
32
|
* See the LICENSE file in the root directory of this source tree.
|
|
33
|
-
*/const ef=Symbol("lucide-context"),tf=()=>Uu(ef);var rf=At("<svg><!><!></svg>");function at(r,e){ii(e,!0);const t=tf()??{},n=Gt(e,"color",19,()=>t.color??"currentColor"),i=Gt(e,"size",19,()=>t.size??24),o=Gt(e,"width",19,i),s=Gt(e,"height",19,i),a=Gt(e,"strokeWidth",19,()=>t.strokeWidth??2),c=Gt(e,"absoluteStrokeWidth",19,()=>t.absoluteStrokeWidth??!1),l=Gt(e,"nonScalingStroke",19,()=>t.nonScalingStroke??!1),d=Gt(e,"iconNode",19,()=>[]),f=Gt(e,"icon",19,()=>({node:d(),aliases:[],size:24})),h=Ze(e,["$$slots","$$events","$$legacy","color","size","width","height","strokeWidth","absoluteStrokeWidth","nonScalingStroke","iconNode","icon","class","children"]),g=Q(()=>!!e.children||Qd(h)),y=Q(()=>Zd(f(),{color:n(),width:o(),height:s(),strokeWidth:a(),absoluteStrokeWidth:c(),nonScalingStroke:l(),className:lo("lucide-icon",t.class),hasA11yProp:u(g),attributes:h})),C=Q(()=>an(u(y),3)),b=Q(()=>u(C)[1]),m=Q(()=>ju(u(C)[2],()=>[],!0)),A=Q(()=>({...u(b),class:[...u(b).class.split(" "),e.class]}));var v=rf();Yn(v,()=>({...u(A)}));var p=R(v);bt(p,17,()=>u(m),Vn,(S,$)=>{var x=Q(()=>an(u($),2));let D=()=>u(x)[0],I=()=>u(x)[1];var j=er(),O=lt(j);id(O,D,!0,(w,ge)=>{Yn(w,()=>({...I()}))}),V(S,j)});var E=P(p);ao(E,()=>e.children??Wu),T(v),V(r,v),oi()}const Pa={name:"x",size:24,node:[["path",{d:"M18 6 6 18"}],["path",{d:"m6 6 12 12"}]]};Pa.node;function ks(r,e){let t=Ze(e,["$$slots","$$events","$$legacy"]);at(r,it(()=>t,{get icon(){return Pa}}))}const nf=20;var hn,pn,gn;class of{constructor(){nt(this,hn,Ee(0));nt(this,pn,Q(()=>this.inflight>0));nt(this,gn,Ee(Kt([])));Te(this,"nextId",1)}get inflight(){return u(xe(this,hn))}set inflight(e){N(xe(this,hn),e,!0)}get active(){return u(xe(this,pn))}set active(e){N(xe(this,pn),e)}get log(){return u(xe(this,gn))}set log(e){N(xe(this,gn),e,!0)}async track(e,t){const n=this.nextId++,i={id:n,label:e,startedAt:Date.now(),durationMs:null,status:"pending"};Qt(()=>{this.log=[i,...this.log].slice(0,nf),this.inflight+=1});try{const o=await t();return Qt(()=>this.update(n,{durationMs:Date.now()-i.startedAt,status:"ok"})),o}catch(o){throw Qt(()=>this.update(n,{durationMs:Date.now()-i.startedAt,status:"error",error:o.message})),o}finally{Qt(()=>{this.inflight=Math.max(0,this.inflight-1)})}}update(e,t){this.log=this.log.map(n=>n.id===e?{...n,...t}:n)}reset(){Qt(()=>{this.log=this.log.map(e=>e.status==="pending"?{...e,status:"error",error:"reset by user",durationMs:Date.now()-e.startedAt}:e),this.inflight=0})}}hn=new WeakMap,pn=new WeakMap,gn=new WeakMap;const lr=new of;var sf=Array.isArray,si=r=>{if(!r&&r!==0&&r!==0n)return"";if(typeof r=="string")return r;if(typeof r=="number")return r!==r?"":""+r;if(typeof r=="bigint")return""+r;let e="";if(sf(r)){const t=r.length;for(let n=0;n<t;n++){const i=r[n];if(!i&&i!==0&&i!==0n)continue;const o=typeof i=="string"?i:si(i);o&&(e&&(e+=" "),e+=o)}return e}if(typeof r=="object")for(const t in r)r[t]&&(e&&(e+=" "),e+=t);return e},af=/\s+/g,uo=Array.isArray,cf=r=>typeof r!="string"||!r?r:r.replace(af," ").trim(),lf=r=>{const e=r.length;if(e===0)return!1;const t=r.charCodeAt(0),n=r.charCodeAt(e-1);if(t===32||n===32||t>=9&&t<=13||t===160||n>=9&&n<=13||n===160)return!0;for(let i=0;i<e;i++){const o=r.charCodeAt(i);if(o>=9&&o<=13||o===160||o===32&&i+1<e&&r.charCodeAt(i+1)===32)return!0}return!1},Kn=(...r)=>{const e=si(r);if(e)return lf(e)?cf(e):e},fo=r=>r===!1?"false":r===!0?"true":r===0?"0":r,Mt=r=>{if(!r||typeof r!="object")return!0;for(const e in r)return!1;return!0},Ua=(r,e)=>{if(r===e)return!0;if(!r||!e)return!1;const t=r,n=e,i=Object.keys(t),o=Object.keys(n);if(i.length!==o.length)return!1;for(let s=0;s<i.length;s++){const a=i[s];if(!o.includes(a)||t[a]!==n[a])return!1}return!0},uf=(r,e)=>{const t=r;for(const n in e)if(Object.hasOwn(e,n)){const i=e[n];n in t?t[n]=Kn(t[n],i):t[n]=i}return r},Wa=(r,e)=>{for(let t=0;t<r.length;t++){const n=r[t];uo(n)?Wa(n,e):n&&e.push(n)}},ho=(...r)=>{const e=[];Wa(r,e);const t=[];for(let n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t},ko=(r,e)=>{const t=r,n=e,i={};for(const o in t){const s=t[o];if(o in n){const a=n[o];uo(s)||uo(a)?i[o]=ho(a,s):typeof s=="object"&&typeof a=="object"&&s&&a?i[o]=ko(s,a):i[o]=a+" "+s}else i[o]=s}for(const o in n)o in t||(i[o]=n[o]);return i},df={twMerge:!0,twMergeConfig:{}},ja=256,ff=128,xr=Symbol("tv-cache-miss"),hf=r=>(r==null?void 0:r.class)!=null&&r.class!==""||(r==null?void 0:r.className)!=null&&r.className!=="",Es=r=>{if(r===void 0)return"";if(r===null)return"null";if(typeof r=="string")return r;if(typeof r=="boolean")return r?"true":"false";if(typeof r=="number")return r===0?"0":String(r);if(typeof r=="bigint")return String(r);const e=fo(r),t=typeof e;if(t==="string"||t==="number"||t==="boolean"||t==="bigint")return String(e);if(t==="object")try{return JSON.stringify(e)}catch{return null}return null},Rr=(r,e)=>{if(e===void 0)return r;if(e===null)return r+"null";const t=typeof e;if(t==="string"||t==="number"||t==="boolean"||t==="bigint")return r+String(e);if(Array.isArray(e))return r+e.join("\0");try{return r+JSON.stringify(e)}catch{return r+"?"}},Ba=(r,e,t,n)=>{let i="";const o=Object.create(null);for(let a=0;a<r.length;a++){const c=r[a];o[c]=1;let l=e[c];t&&t[c]!==void 0&&(l=t[c]);const d=Es(l);if(d===null)return null;i+=c+":"+d+";"}const s=[];for(const a in e)a==="class"||a==="className"||o[a]||(o[a]=1,s.push(a));if(t)for(const a in t)a==="class"||a==="className"||o[a]||t[a]===void 0||(o[a]=1,s.push(a));s.length>1&&s.sort();for(let a=0;a<s.length;a++){const c=s[a];let l=e[c];t&&t[c]!==void 0&&(l=t[c]);const d=Es(l);if(d===null)return null;i+=c+":"+d+";"}return i},Fa=(r,e)=>{let t="";for(let n=0;n<r.length;n++){const{conditionKeys:i,source:o}=r[n];for(let s=0;s<i.length;s++){const a=i[s];t+=a+"=",t=Rr(t,o[a]),t+=","}t+="c=",t=Rr(t,o.class),t+="|cn=",t=Rr(t,o.className),t+=";"}for(let n=0;n<e.length;n++){const{conditionKeys:i,source:o}=e[n];for(let s=0;s<i.length;s++){const a=i[s];t+=a+"=",t=Rr(t,o[a]),t+=","}Array.isArray(o.slots)&&(t+="slots="+o.slots.join(",")+","),t+="c=",t=Rr(t,o.class),t+="|cn=",t=Rr(t,o.className),t+=";"}return t},Va=(r=ja)=>{let e=new Map,t=null;return{get(n){if(e.has(n))return e.get(n);if(t!=null&&t.has(n)){const i=t.get(n);return e.set(n,i),i}return xr},set(n,i){e.size>=r&&(t=e,e=new Map),e.set(n,i)}}},pf=(r=ja)=>{const e=Va(r);return{get(t){return e.get(t)},set(t,n){e.set(t,n)}}},gf=(r=ff)=>{let e=new Map,t=null,n=0;return{get(i,o){const s=e.get(i);if(s){const a=s.get(o);if(a!==void 0||s.has(o))return a}if(t){const a=t.get(i);if(a){const c=a.get(o);if(c!==void 0||a.has(o)){let l=e.get(i);return l||(l=new Map,e.set(i,l)),l.has(o)||n++,l.set(o,c),c}}}return xr},set(i,o,s){n>=r&&(t=e,e=new Map,n=0);let a=e.get(i);a||(a=new Map,e.set(i,a)),a.has(o)||n++,a.set(o,s)}}},Eo=(r,e)=>{let t=null;return(n,i)=>{if(!hf(i))return n;const o=i.class,s=i.className;if(o!=null&&o!==""&&typeof o!="string"||s!=null&&s!==""&&typeof s!="string")return r(e,n,o,s);t??(t=gf());const a=n??"",c=(typeof o=="string"?o:"")+"\0"+(typeof s=="string"?s:""),l=t.get(a,c);if(l!==xr)return l;const d=r(e,n,o,s);return t.set(a,c,d),d}};function mf(){let r=null,e={},t=!1;return{get cachedTwMerge(){return r},set cachedTwMerge(n){r=n},get cachedTwMergeConfig(){return e},set cachedTwMergeConfig(n){e=n},get didTwMergeConfigChange(){return t},set didTwMergeConfigChange(n){t=n},reset(){r=null,e={},t=!1}}}var Ct=mf(),vf=r=>{!Mt(r.twMergeConfig)&&!Ua(r.twMergeConfig,Ct.cachedTwMergeConfig)&&(Ct.didTwMergeConfigChange=!0,Ct.cachedTwMergeConfig=r.twMergeConfig)},yf=(r,e)=>{const t=[];for(let n=0;n<e.length;n++){const i=e[n],o=r[i];t.push({key:i,values:o,isEmpty:Mt(o)})}return t},bf=r=>{if(!Array.isArray(r)||r.length===0)return[];const e=[];for(let t=0;t<r.length;t++){const n=r[t],i=[];for(const o in n)o!=="class"&&o!=="className"&&i.push(o);e.push({conditionKeys:i,source:n})}return e},wf=r=>{if(!Array.isArray(r)||r.length===0)return[];const e=[];for(let t=0;t<r.length;t++){const n=r[t],i=[];for(const o in n)o!=="slots"&&o!=="class"&&o!=="className"&&i.push(o);e.push({conditionKeys:i,source:n})}return e},_f=r=>{const e={};for(let t=0;t<r.length;t++){const n=r[t],i=n.source.slots;if(Array.isArray(i))for(let o=0;o<i.length;o++){const s=i[o];e[s]||(e[s]=[]),e[s].push(n)}}return e},xf=(r,e)=>{const{extend:t=null,slots:n={},variants:i={},compoundVariants:o=[],compoundSlots:s=[],defaultVariants:a={}}=r,c={...df,...e},l=r.slots!==void 0,d=t!=null&&t.base?Kn(t.base,r==null?void 0:r.base):r==null?void 0:r.base,f=t!=null&&t.variants&&!Mt(t.variants)?ko(i,t.variants):i,h=t!=null&&t.defaultVariants&&!Mt(t.defaultVariants)?{...t.defaultVariants,...a}:a;vf(c);const g=!(t!=null&&t.slots)||Mt(t.slots),y=l?g&&(t!=null&&t.base)?Kn(r==null?void 0:r.base,t.base):typeof(r==null?void 0:r.base)=="string"||(r==null?void 0:r.base)==null?r.base:Kn(r.base):void 0,C=l?{base:y,...n}:{},b=g?C:uf({...t==null?void 0:t.slots},Mt(C)?{base:r==null?void 0:r.base}:C),m=!(t!=null&&t.compoundVariants)||Mt(t.compoundVariants)?o:ho(t==null?void 0:t.compoundVariants,o),A=!(t!=null&&t.compoundSlots)||Mt(t.compoundSlots)?s:ho(t==null?void 0:t.compoundSlots,s),v=Object.keys(f),p=m&&!Array.isArray(m)?new TypeError(`The "compoundVariants" prop must be an array. Received: ${typeof m}`):A&&!Array.isArray(A)?new TypeError(`The "compoundSlots" prop must be an array. Received: ${typeof A}`):null,E=l||!g?"slots":v.length===0?"plain":"variants";return{config:c,extend:t,base:d,variants:f,defaultVariants:h,slots:b,compoundVariants:m,compoundSlots:A,compiledVariants:null,compiledCompoundVariants:null,compiledCompoundSlots:null,compiledCompoundSlotsBySlot:null,deferredError:p,mode:E,slotKeys:null,variantKeys:v}},Ka=r=>(r.compiledVariants!==null||(r.compiledVariants=yf(r.variants,r.variantKeys),r.compiledCompoundVariants=bf(r.compoundVariants),r.compiledCompoundSlots=wf(r.compoundSlots),r.compiledCompoundSlotsBySlot=_f(r.compiledCompoundSlots),r.slotKeys=r.slots&&typeof r.slots=="object"?Object.keys(r.slots):[]),r),po=[],Ha=[],kf=[],Ef=[],Sf=[],qa=(r,e,t)=>{const n={};for(const i in r)n[i]=r[i];if(e)for(const i in e)e[i]!==void 0&&(n[i]=e[i]);if(t)for(const i in t)t[i]!==void 0&&(n[i]=t[i]);return n},On=r=>r==null||r===!1,Cf=(r,e)=>{if(!Array.isArray(r))return r===e||On(r)&&On(e);for(let t=0;t<r.length;t++){const n=r[t];if(n===e||On(n)&&On(e))return!0}return!1},Ya=(r,e,t,n)=>{if(r.isEmpty)return null;const i=(n==null?void 0:n[r.key])??(t==null?void 0:t[r.key]);if(i===null)return null;const o=fo(i);if(typeof o=="object")return null;const s=e==null?void 0:e[r.key],a=o??fo(s);return r.values[a||"false"]},So=(r,e)=>{const{conditionKeys:t,source:n}=r;for(let i=0;i<t.length;i++){const o=t[i];if(!Cf(n[o],e[o]))return!1}return!0},Ss=(r,e,t)=>{typeof t=="string"?e==="base"&&r.push(t):t&&typeof t=="object"&&t[e]&&r.push(t[e])},Af=(r,e,t)=>{const n=Ha;n.length=0;for(let i=0;i<r.length;i++){const o=Ya(r[i],e,t);o&&n.push(o)}return n},$f=(r,e,t,n,i)=>{const o=Ha;o.length=0;for(let s=0;s<e.length;s++){const a=Ya(e[s],t,n,i),c=r==="base"&&typeof a=="string"?a:a&&a[r];c&&o.push(c)}return o},Df=(r,e)=>{const t=kf;t.length=0;for(let n=0;n<r.length;n++){const i=r[n];So(i,e)&&(i.source.class&&t.push(i.source.class),i.source.className&&t.push(i.source.className))}return t},If=(r,e,t)=>{const n=Ef;n.length=0;for(let i=0;i<e.length;i++){const o=e[i];So(o,t)&&(Ss(n,r,o.source.class),Ss(n,r,o.source.className))}return n},Lf=(r,e)=>{const t=Sf;t.length=0;for(let n=0;n<r.length;n++){const i=r[n];So(i,e)&&(i.source.class&&t.push(i.source.class),i.source.className&&t.push(i.source.className))}return t},Tf=(r,e)=>{const{base:t,config:n}=r;let i=xr;const o=Eo(e,n);return(s=>(i===xr&&(i=e(n,t)),o(i,s)))},Gf=(r,e)=>{const{base:t,config:n,defaultVariants:i,deferredError:o,variantKeys:s}=r;let a=r.compiledCompoundVariants,c=r.compiledVariants,l=po,d=null;const f=Eo(e,n);let h=1;const g=y=>{const C=a.length>0?Df(a,qa(i,y)):void 0;return e(n,t,Af(c,i,y),C)};return(y=>{if(o)throw o;(c===null||a===null)&&(Ka(r),c=r.compiledVariants,a=r.compiledCompoundVariants,l=r.compiledCompoundSlots??po);let C;if(h>0)h--,C=g(y);else{d??(d=pf());const b=Ba(s,i,y);if(b!==null){const m=a.length>0||l.length>0?Fa(a,l):"",A=b+"#"+m,v=d.get(A);v!==xr?C=v:(C=g(y),d.set(A,C))}else C=g(y)}return f(C,y)})},Rf=(r,e)=>{const{config:t,defaultVariants:n,deferredError:i,slots:o,variantKeys:s}=r;let a=null,c=null,l=null,d=null,f=!1,h=null,g=null,y=1;const C=()=>{if(l!==null)return;(r.compiledVariants===null||r.compiledCompoundVariants===null||r.compiledCompoundSlots===null||r.compiledCompoundSlotsBySlot===null||r.slotKeys===null)&&Ka(r);const m=r.compiledVariants;a=r.compiledCompoundVariants,c=r.compiledCompoundSlots;const A=r.compiledCompoundSlotsBySlot;l=r.slotKeys,f=a.length>0||c.length>0,h=Eo(e,t);const v=new Array(l.length);for(let p=0;p<l.length;p++){const E=l[p],S=A[E]??po;v[p]=($,x)=>{const D=f?qa(n,$,x):void 0,I=D?If(E,a,D):void 0,j=D?Lf(S,D):void 0;return e(t,o[E],$f(E,m,n,$,x),I,j)}}d=v},b=m=>{const A=l,v=d,p=h,E={};for(let S=0;S<A.length;S++){const $=v[S],x=$(m);E[A[S]]=D=>{if(D==null)return x;let I=!1;for(const j in D)if(!(j==="class"||j==="className")&&D[j]!==void 0){I=!0;break}return p(I?$(m,D):x,D)}}return E};return(m=>{if(i)throw i;if(C(),y>0)return y--,b(m);const A=Ba(s,n,m);if(A===null)return b(m);const v=f?Fa(a,c):"",p=A+"#"+v;g??(g=Va());const E=g.get(p);if(E!==xr)return E;const S=b(m);return g.set(p,S),S})},Of=(r,e)=>{if(r.mode==="plain")return Tf(r,e);let t;return(n=>(t??(t=r.mode==="slots"?Rf(r,e):Gf(r,e)),t(n)))},zf=(r,e)=>{r.variantKeys=e.variantKeys,r.extend=e.extend,r.base=e.base,r.slots=e.slots,r.variants=e.variants,r.defaultVariants=e.defaultVariants,r.compoundSlots=e.compoundSlots,r.compoundVariants=e.compoundVariants},Mf=r=>{const e=(n,i)=>{const o=xf(n,i),s=Of(o,r);return zf(s,o),s};return{tv:e,createTV:n=>(i,o)=>e(i,o?ko(n,o):n)}},Nf=(r,e)=>{const t=r.length,n=e.length,i=new Array(t+n);for(let o=0;o<t;o++)i[o]=r[o];for(let o=0;o<n;o++)i[t+o]=e[o];return i},Pf=(r,e)=>({classGroupId:r,validator:e}),Xa=(r=new Map,e=null,t)=>({nextPart:r,validators:e,classGroupId:t}),Zn="-",Cs=[],Uf="arbitrary..",Wf=r=>{const e=Bf(r),{conflictingClassGroups:t,conflictingClassGroupModifiers:n}=r;return{getClassGroupId:s=>{if(s[0]==="["&&s[s.length-1]==="]")return jf(s);const a=s.split(Zn),c=a[0]===""&&a.length>1?1:0;return Ja(a,c,e)},getConflictingClassGroupIds:(s,a)=>{if(a){const c=n[s],l=t[s];return c?l?Nf(l,c):c:l||Cs}return t[s]||Cs}}},Ja=(r,e,t)=>{if(r.length-e===0)return t.classGroupId;const i=r[e],o=t.nextPart.get(i);if(o){const l=Ja(r,e+1,o);if(l)return l}const s=t.validators;if(s===null)return;const a=e===0?r.join(Zn):r.slice(e).join(Zn),c=s.length;for(let l=0;l<c;l++){const d=s[l];if(d.validator(a))return d.classGroupId}},jf=r=>{const e=r.slice(1,-1),t=e.indexOf(":");if(t===-1)return;const n=e.slice(0,t);return n?Uf+n:void 0},Bf=r=>{const{theme:e,classGroups:t}=r;return Ff(t,e)},Ff=(r,e)=>{const t=Xa();for(const n in r){const i=r[n];Co(i,t,n,e)}return t},Co=(r,e,t,n)=>{const i=r.length;for(let o=0;o<i;o++){const s=r[o];Vf(s,e,t,n)}},Vf=(r,e,t,n)=>{if(typeof r=="string"){Kf(r,e,t);return}if(typeof r=="function"){Hf(r,e,t,n);return}qf(r,e,t,n)},Kf=(r,e,t)=>{const n=r===""?e:Za(e,r);n.classGroupId=t},Hf=(r,e,t,n)=>{if(Yf(r)){Co(r(n),e,t,n);return}e.validators===null&&(e.validators=[]),e.validators.push(Pf(t,r))},qf=(r,e,t,n)=>{const i=Object.entries(r),o=i.length;for(let s=0;s<o;s++){const[a,c]=i[s];Co(c,Za(e,a),t,n)}},Za=(r,e)=>{let t=r;const n=e.split(Zn),i=n.length;for(let o=0;o<i;o++){const s=n[o];let a=t.nextPart.get(s);a||(a=Xa(),t.nextPart.set(s,a)),t=a}return t},Yf=r=>"isThemeGetter"in r&&r.isThemeGetter===!0,Xf="!",Jf=58,Zf=47,Qf=91,eh=93,th=40,rh=41,As=33,nh=(r,e,t,n)=>({modifiers:r,hasImportantModifier:e,baseClassName:t,maybePostfixModifierPosition:n,isExternal:void 0}),$s=r=>{const e=[];let t=0,n=0,i=0,o;const s=r.length;for(let h=0;h<s;h++){const g=r.charCodeAt(h);if(t===0&&n===0){if(g===Jf){e.push(r.slice(i,h)),i=h+1;continue}if(g===Zf){o=h;continue}}g===Qf?t++:g===eh?t--:g===th?n++:g===rh&&n--}const a=e.length===0?r:r.slice(i);let c=a,l=!1;const d=a.length-1;a.charCodeAt(d)===As?(c=a.slice(0,-1),l=!0):a.charCodeAt(0)===As&&(c=a.slice(1),l=!0);const f=o&&o>i?o-i:void 0;return nh(e,l,c,f)},ih=r=>{const e=new Set(r.orderSensitiveModifiers);return t=>{const n=[];let i=[];for(let o=0;o<t.length;o++){const s=t[o],a=s[0]==="[",c=e.has(s);if(a||c){if(i.length>0){i.sort();for(let l=0;l<i.length;l++)n.push(i[l]);i=[]}n.push(s)}else i.push(s)}if(i.length>0){i.sort();for(let o=0;o<i.length;o++)n.push(i[o])}return n}},Mi={isExternal:!0,classId:-1,conflictIds:[]},oh=4096,sh=16384,ah=r=>{const e=ih(r),t=ch(r),{getClassGroupId:n,getConflictingClassGroupIds:i}=Wf(r);let o=Object.create(null),s=Object.create(null),a=0,c=new Int32Array(256),l=0,d=new Uint8Array(64),f=!1;const h=v=>{const p=[],E=v.length;let S=-1;f=!1;for(let $=0;$<E;$++){const x=v.charCodeAt($);x===32?S!==-1&&(p.push(v.slice(S,$)),S=-1):x>=9&&x<=13?(f=!0,S!==-1&&(p.push(v.slice(S,$)),S=-1)):S===-1&&(S=$)}return S!==-1&&p.push(v.slice(S)),p},g=new Map;let y=0;const C=v=>{let p=g.get(v);if(p===void 0&&(p=y++,g.set(v,p),p>=c.length)){const E=new Int32Array(c.length*2);E.set(c),c=E}return p},b=v=>{const{isExternal:p,modifiers:E,hasImportantModifier:S,baseClassName:$,maybePostfixModifierPosition:x}=$s(v);if(p)return Mi;let D=!!x,I;if(D){const ce=$.substring(0,x);I=n(ce);const L=I&&t[I]?n($):void 0;L&&L!==I&&(I=L,D=!1)}else I=n($);if(!I){if(!D||(I=n($),!I))return Mi;D=!1}const j=E.length===0?"":E.length===1?E[0]:e(E).join(":"),O=S?j+Xf:j,w=i(I,D),ge=[];for(let ce=0;ce<w.length;ce++)ge.push(C(O+w[ce]));return{isExternal:!1,classId:C(O+I),conflictIds:ge}},m=v=>{let p=o[v];return p!==void 0||(p=s[v],p===void 0&&(p=b(v)),o[v]=p,++a>oh&&(a=0,s=o,o=Object.create(null))),p};return{parseClassName:$s,sortModifiers:e,postfixLookupClassGroupIds:t,getClassGroupId:n,getConflictingClassGroupIds:i,getClassDescriptor:m,mergeClassList:v=>{const p=h(v),E=p.length;if(E===1)return p[0];y>sh&&(g.clear(),y=0,o=Object.create(null),s=Object.create(null),a=0),l=l+1|0,l===0&&(l=1);const S=l;if(E>d.length){let I=d.length;for(;I<E;)I*=2;d=new Uint8Array(I)}let $=!1,x=0;for(let I=E-1;I>=0;I-=1){const j=p[I];x+=j.length;const O=m(j);if(O.isExternal){d[I]=1;continue}const w=O.classId;if(c[w]===S){d[I]=0,$=!0;continue}c[w]=S;const ge=O.conflictIds;for(let ce=0;ce<ge.length;ce++)c[ge[ce]]=S;d[I]=1}if(!$&&!f&&v.length===x+E-1)return v;let D="";for(let I=0;I<E;I++)d[I]===1&&(D&&(D+=" "),D+=p[I]);return D}}},ch=r=>{const e=Object.create(null),t=r.postfixLookupClassGroups;if(t)for(let n=0;n<t.length;n++)e[t[n]]=!0;return e},lh=500,Ds=r=>{let e,t,n=Object.create(null),i=Object.create(null),o=0;const s=l=>(e=ah(r()),t=e.mergeClassList,c.mergeString=a,a(l)),a=l=>{let d=n[l];return d!==void 0||(d=i[l],d===void 0&&(d=t(l)),n[l]=d,++o>lh&&(o=0,i=n,n=Object.create(null))),d},c=(...l)=>c.mergeString(si(l));return c.mergeString=s,c},uh=[],ct=r=>{const e=t=>t[r]||uh;return e.isThemeGetter=!0,e},Qa=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,ec=/^\((?:(\w[\w-]*):)?(.+)\)$/i,dh=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,fh=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,hh=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,ph=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,gh=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,mh=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,tc=Number,vh=Number.isNaN,yh=Number.isInteger,cr=r=>dh.test(r),Ge=r=>!!r&&!vh(tc(r)),Ft=r=>!!r&&yh(tc(r)),Ni=r=>r.endsWith("%")&&Ge(r.slice(0,-1)),Xt=r=>fh.test(r),rc=()=>!0,bh=r=>hh.test(r)&&!ph.test(r),Ao=()=>!1,wh=r=>gh.test(r),_h=r=>mh.test(r),xh=r=>!Y(r)&&!Z(r),kh=r=>r.startsWith("@container")&&(r[10]==="/"&&r[11]!==void 0||r[11]==="s"&&r[16]!==void 0&&r.startsWith("-size/",10)||r[11]==="n"&&r[18]!==void 0&&r.startsWith("-normal/",10)),Eh=r=>gr(r,oc,Ao),Y=r=>Qa.test(r),yr=r=>gr(r,sc,bh),Is=r=>gr(r,Th,Ge),Sh=r=>gr(r,cc,rc),Ch=r=>gr(r,ac,Ao),Ls=r=>gr(r,nc,Ao),Ah=r=>gr(r,ic,_h),zn=r=>gr(r,lc,wh),Z=r=>ec.test(r),Jr=r=>kr(r,sc),$h=r=>kr(r,ac),Ts=r=>kr(r,nc),Dh=r=>kr(r,oc),Ih=r=>kr(r,ic),Mn=r=>kr(r,lc,!0),Lh=r=>kr(r,cc,!0),gr=(r,e,t)=>{const n=Qa.exec(r);return n?n[1]?e(n[1]):t(n[2]):!1},kr=(r,e,t=!1)=>{const n=ec.exec(r);return n?n[1]?e(n[1]):t:!1},nc=r=>r==="position"||r==="percentage",ic=r=>r==="image"||r==="url",oc=r=>r==="length"||r==="size"||r==="bg-size",sc=r=>r==="length",Th=r=>r==="number",ac=r=>r==="family-name",cc=r=>r==="number"||r==="weight",lc=r=>r==="shadow",Pi=()=>{const r=ct("color"),e=ct("font"),t=ct("text"),n=ct("font-weight"),i=ct("tracking"),o=ct("leading"),s=ct("breakpoint"),a=ct("container"),c=ct("spacing"),l=ct("radius"),d=ct("shadow"),f=ct("inset-shadow"),h=ct("text-shadow"),g=ct("drop-shadow"),y=ct("blur"),C=ct("perspective"),b=ct("aspect"),m=ct("ease"),A=ct("animate"),v=()=>["auto","avoid","all","avoid-page","page","left","right","column"],p=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],E=()=>[...p(),Z,Y],S=()=>["auto","hidden","clip","visible","scroll"],$=()=>["auto","contain","none"],x=()=>[Z,Y,c],D=()=>[cr,"full","auto",...x()],I=()=>[Ft,"none","subgrid",Z,Y],j=()=>["auto",{span:["full",Ft,Z,Y]},Ft,Z,Y],O=()=>[Ft,"auto",Z,Y],w=()=>["auto","min","max","fr",Z,Y],ge=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],ce=()=>["start","end","center","stretch","center-safe","end-safe"],L=()=>["auto",...x()],_=()=>[cr,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...x()],K=()=>[cr,"screen","full","dvw","lvw","svw","min","max","fit",...x()],ee=()=>[cr,"screen","full","lh","dvh","lvh","svh","min","max","fit",...x()],M=()=>[r,Z,Y],Re=()=>[...p(),Ts,Ls,{position:[Z,Y]}],ae=()=>["no-repeat",{repeat:["","x","y","space","round"]}],W=()=>["auto","cover","contain",Dh,Eh,{size:[Z,Y]}],Se=()=>[Ni,Jr,yr],Ce=()=>["","none","full",l,Z,Y],be=()=>["",Ge,Jr,yr],Ye=()=>["solid","dashed","dotted","double"],ot=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],Ae=()=>[Ge,Ni,Ts,Ls],ve=()=>["","none",y,Z,Y],X=()=>["none",Ge,Z,Y],me=()=>["none",Ge,Z,Y],et=()=>[Ge,Z,Y],J=()=>[cr,"full",...x()];return{theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Xt],breakpoint:[Xt],color:[rc],container:[Xt],"drop-shadow":[Xt],ease:["in","out","in-out"],font:[xh],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Xt],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Xt],shadow:[Xt],spacing:["px",Ge],text:[Xt],"text-shadow":[Xt],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",cr,Y,Z,b]}],container:["container"],"container-type":[{"@container":["","normal","size",Z,Y]}],"container-named":[kh],columns:[{columns:[Ge,Y,Z,a]}],"break-after":[{"break-after":v()}],"break-before":[{"break-before":v()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:E()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:$()}],"overscroll-x":[{"overscroll-x":$()}],"overscroll-y":[{"overscroll-y":$()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:D()}],"inset-x":[{"inset-x":D()}],"inset-y":[{"inset-y":D()}],start:[{"inset-s":D(),start:D()}],end:[{"inset-e":D(),end:D()}],"inset-bs":[{"inset-bs":D()}],"inset-be":[{"inset-be":D()}],top:[{top:D()}],right:[{right:D()}],bottom:[{bottom:D()}],left:[{left:D()}],visibility:["visible","invisible","collapse"],z:[{z:[Ft,"auto",Z,Y]}],basis:[{basis:[cr,"full","auto",a,...x()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Ge,cr,"auto","initial","none",Y]}],grow:[{grow:["",Ge,Z,Y]}],shrink:[{shrink:["",Ge,Z,Y]}],order:[{order:[Ft,"first","last","none",Z,Y]}],"grid-cols":[{"grid-cols":I()}],"col-start-end":[{col:j()}],"col-start":[{"col-start":O()}],"col-end":[{"col-end":O()}],"grid-rows":[{"grid-rows":I()}],"row-start-end":[{row:j()}],"row-start":[{"row-start":O()}],"row-end":[{"row-end":O()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":w()}],"auto-rows":[{"auto-rows":w()}],gap:[{gap:x()}],"gap-x":[{"gap-x":x()}],"gap-y":[{"gap-y":x()}],"justify-content":[{justify:[...ge(),"normal"]}],"justify-items":[{"justify-items":[...ce(),"normal"]}],"justify-self":[{"justify-self":["auto",...ce()]}],"align-content":[{content:["normal",...ge()]}],"align-items":[{items:[...ce(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...ce(),{baseline:["","last"]}]}],"place-content":[{"place-content":ge()}],"place-items":[{"place-items":[...ce(),"baseline"]}],"place-self":[{"place-self":["auto",...ce()]}],p:[{p:x()}],px:[{px:x()}],py:[{py:x()}],ps:[{ps:x()}],pe:[{pe:x()}],pbs:[{pbs:x()}],pbe:[{pbe:x()}],pt:[{pt:x()}],pr:[{pr:x()}],pb:[{pb:x()}],pl:[{pl:x()}],m:[{m:L()}],mx:[{mx:L()}],my:[{my:L()}],ms:[{ms:L()}],me:[{me:L()}],mbs:[{mbs:L()}],mbe:[{mbe:L()}],mt:[{mt:L()}],mr:[{mr:L()}],mb:[{mb:L()}],ml:[{ml:L()}],"space-x":[{"space-x":x()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":x()}],"space-y-reverse":["space-y-reverse"],size:[{size:_()}],"inline-size":[{inline:["auto",...K()]}],"min-inline-size":[{"min-inline":["auto",...K()]}],"max-inline-size":[{"max-inline":["none",...K()]}],"block-size":[{block:["auto",...ee()]}],"min-block-size":[{"min-block":["auto",...ee()]}],"max-block-size":[{"max-block":["none",...ee()]}],w:[{w:[a,"screen",..._()]}],"min-w":[{"min-w":[a,"screen","none",..._()]}],"max-w":[{"max-w":[a,"screen","none","prose",{screen:[s]},..._()]}],h:[{h:["screen","lh",..._()]}],"min-h":[{"min-h":["screen","lh","none",..._()]}],"max-h":[{"max-h":["screen","lh",..._()]}],"font-size":[{text:["base",t,Jr,yr]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,Lh,Sh]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Ni,Y]}],"font-family":[{font:[$h,Ch,e]}],"font-features":[{"font-features":[Y]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[i,Z,Y]}],"line-clamp":[{"line-clamp":[Ge,"none",Z,Is]}],leading:[{leading:[o,...x()]}],"list-image":[{"list-image":["none",Z,Y]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Z,Y]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:M()}],"text-color":[{text:M()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...Ye(),"wavy"]}],"text-decoration-thickness":[{decoration:[Ge,"from-font","auto",Z,yr]}],"text-decoration-color":[{decoration:M()}],"underline-offset":[{"underline-offset":[Ge,"auto",Z,Y]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:x()}],"tab-size":[{tab:[Ft,Z,Y]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Z,Y]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Z,Y]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:Re()}],"bg-repeat":[{bg:ae()}],"bg-size":[{bg:W()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Ft,Z,Y],radial:["",Z,Y],conic:[Ft,Z,Y]},Ih,Ah]}],"bg-color":[{bg:M()}],"gradient-from-pos":[{from:Se()}],"gradient-via-pos":[{via:Se()}],"gradient-to-pos":[{to:Se()}],"gradient-from":[{from:M()}],"gradient-via":[{via:M()}],"gradient-to":[{to:M()}],rounded:[{rounded:Ce()}],"rounded-s":[{"rounded-s":Ce()}],"rounded-e":[{"rounded-e":Ce()}],"rounded-t":[{"rounded-t":Ce()}],"rounded-r":[{"rounded-r":Ce()}],"rounded-b":[{"rounded-b":Ce()}],"rounded-l":[{"rounded-l":Ce()}],"rounded-ss":[{"rounded-ss":Ce()}],"rounded-se":[{"rounded-se":Ce()}],"rounded-ee":[{"rounded-ee":Ce()}],"rounded-es":[{"rounded-es":Ce()}],"rounded-tl":[{"rounded-tl":Ce()}],"rounded-tr":[{"rounded-tr":Ce()}],"rounded-br":[{"rounded-br":Ce()}],"rounded-bl":[{"rounded-bl":Ce()}],"border-w":[{border:be()}],"border-w-x":[{"border-x":be()}],"border-w-y":[{"border-y":be()}],"border-w-s":[{"border-s":be()}],"border-w-e":[{"border-e":be()}],"border-w-bs":[{"border-bs":be()}],"border-w-be":[{"border-be":be()}],"border-w-t":[{"border-t":be()}],"border-w-r":[{"border-r":be()}],"border-w-b":[{"border-b":be()}],"border-w-l":[{"border-l":be()}],"divide-x":[{"divide-x":be()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":be()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...Ye(),"hidden","none"]}],"divide-style":[{divide:[...Ye(),"hidden","none"]}],"border-color":[{border:M()}],"border-color-x":[{"border-x":M()}],"border-color-y":[{"border-y":M()}],"border-color-s":[{"border-s":M()}],"border-color-e":[{"border-e":M()}],"border-color-bs":[{"border-bs":M()}],"border-color-be":[{"border-be":M()}],"border-color-t":[{"border-t":M()}],"border-color-r":[{"border-r":M()}],"border-color-b":[{"border-b":M()}],"border-color-l":[{"border-l":M()}],"divide-color":[{divide:M()}],"outline-style":[{outline:[...Ye(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Ge,Z,Y]}],"outline-w":[{outline:["",Ge,Jr,yr]}],"outline-color":[{outline:M()}],shadow:[{shadow:["","none",d,Mn,zn]}],"shadow-color":[{shadow:M()}],"inset-shadow":[{"inset-shadow":["none",f,Mn,zn]}],"inset-shadow-color":[{"inset-shadow":M()}],"ring-w":[{ring:be()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:M()}],"ring-offset-w":[{"ring-offset":[Ge,yr]}],"ring-offset-color":[{"ring-offset":M()}],"inset-ring-w":[{"inset-ring":be()}],"inset-ring-color":[{"inset-ring":M()}],"text-shadow":[{"text-shadow":["none",h,Mn,zn]}],"text-shadow-color":[{"text-shadow":M()}],opacity:[{opacity:[Ge,Z,Y]}],"mix-blend":[{"mix-blend":[...ot(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":ot()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Ge]}],"mask-image-linear-from-pos":[{"mask-linear-from":Ae()}],"mask-image-linear-to-pos":[{"mask-linear-to":Ae()}],"mask-image-linear-from-color":[{"mask-linear-from":M()}],"mask-image-linear-to-color":[{"mask-linear-to":M()}],"mask-image-t-from-pos":[{"mask-t-from":Ae()}],"mask-image-t-to-pos":[{"mask-t-to":Ae()}],"mask-image-t-from-color":[{"mask-t-from":M()}],"mask-image-t-to-color":[{"mask-t-to":M()}],"mask-image-r-from-pos":[{"mask-r-from":Ae()}],"mask-image-r-to-pos":[{"mask-r-to":Ae()}],"mask-image-r-from-color":[{"mask-r-from":M()}],"mask-image-r-to-color":[{"mask-r-to":M()}],"mask-image-b-from-pos":[{"mask-b-from":Ae()}],"mask-image-b-to-pos":[{"mask-b-to":Ae()}],"mask-image-b-from-color":[{"mask-b-from":M()}],"mask-image-b-to-color":[{"mask-b-to":M()}],"mask-image-l-from-pos":[{"mask-l-from":Ae()}],"mask-image-l-to-pos":[{"mask-l-to":Ae()}],"mask-image-l-from-color":[{"mask-l-from":M()}],"mask-image-l-to-color":[{"mask-l-to":M()}],"mask-image-x-from-pos":[{"mask-x-from":Ae()}],"mask-image-x-to-pos":[{"mask-x-to":Ae()}],"mask-image-x-from-color":[{"mask-x-from":M()}],"mask-image-x-to-color":[{"mask-x-to":M()}],"mask-image-y-from-pos":[{"mask-y-from":Ae()}],"mask-image-y-to-pos":[{"mask-y-to":Ae()}],"mask-image-y-from-color":[{"mask-y-from":M()}],"mask-image-y-to-color":[{"mask-y-to":M()}],"mask-image-radial":[{"mask-radial":[Z,Y]}],"mask-image-radial-from-pos":[{"mask-radial-from":Ae()}],"mask-image-radial-to-pos":[{"mask-radial-to":Ae()}],"mask-image-radial-from-color":[{"mask-radial-from":M()}],"mask-image-radial-to-color":[{"mask-radial-to":M()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":p()}],"mask-image-conic-pos":[{"mask-conic":[Ge]}],"mask-image-conic-from-pos":[{"mask-conic-from":Ae()}],"mask-image-conic-to-pos":[{"mask-conic-to":Ae()}],"mask-image-conic-from-color":[{"mask-conic-from":M()}],"mask-image-conic-to-color":[{"mask-conic-to":M()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:Re()}],"mask-repeat":[{mask:ae()}],"mask-size":[{mask:W()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Z,Y]}],filter:[{filter:["","none",Z,Y]}],blur:[{blur:ve()}],brightness:[{brightness:[Ge,Z,Y]}],contrast:[{contrast:[Ge,Z,Y]}],"drop-shadow":[{"drop-shadow":["","none",g,Mn,zn]}],"drop-shadow-color":[{"drop-shadow":M()}],grayscale:[{grayscale:["",Ge,Z,Y]}],"hue-rotate":[{"hue-rotate":[Ge,Z,Y]}],invert:[{invert:["",Ge,Z,Y]}],saturate:[{saturate:[Ge,Z,Y]}],sepia:[{sepia:["",Ge,Z,Y]}],"backdrop-filter":[{"backdrop-filter":["","none",Z,Y]}],"backdrop-blur":[{"backdrop-blur":ve()}],"backdrop-brightness":[{"backdrop-brightness":[Ge,Z,Y]}],"backdrop-contrast":[{"backdrop-contrast":[Ge,Z,Y]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Ge,Z,Y]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Ge,Z,Y]}],"backdrop-invert":[{"backdrop-invert":["",Ge,Z,Y]}],"backdrop-opacity":[{"backdrop-opacity":[Ge,Z,Y]}],"backdrop-saturate":[{"backdrop-saturate":[Ge,Z,Y]}],"backdrop-sepia":[{"backdrop-sepia":["",Ge,Z,Y]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":x()}],"border-spacing-x":[{"border-spacing-x":x()}],"border-spacing-y":[{"border-spacing-y":x()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Z,Y]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Ge,"initial",Z,Y]}],ease:[{ease:["linear","initial",m,Z,Y]}],delay:[{delay:[Ge,Z,Y]}],animate:[{animate:["none",A,Z,Y]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[C,Z,Y]}],"perspective-origin":[{"perspective-origin":E()}],rotate:[{rotate:X()}],"rotate-x":[{"rotate-x":X()}],"rotate-y":[{"rotate-y":X()}],"rotate-z":[{"rotate-z":X()}],scale:[{scale:me()}],"scale-x":[{"scale-x":me()}],"scale-y":[{"scale-y":me()}],"scale-z":[{"scale-z":me()}],"scale-3d":["scale-3d"],skew:[{skew:et()}],"skew-x":[{"skew-x":et()}],"skew-y":[{"skew-y":et()}],transform:[{transform:[Z,Y,"","none","gpu","cpu"]}],"transform-origin":[{origin:E()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:J()}],"translate-x":[{"translate-x":J()}],"translate-y":[{"translate-y":J()}],"translate-z":[{"translate-z":J()}],"translate-none":["translate-none"],zoom:[{zoom:[Ft,Z,Y]}],accent:[{accent:M()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:M()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Z,Y]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":M()}],"scrollbar-track-color":[{"scrollbar-track":M()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":x()}],"scroll-mx":[{"scroll-mx":x()}],"scroll-my":[{"scroll-my":x()}],"scroll-ms":[{"scroll-ms":x()}],"scroll-me":[{"scroll-me":x()}],"scroll-mbs":[{"scroll-mbs":x()}],"scroll-mbe":[{"scroll-mbe":x()}],"scroll-mt":[{"scroll-mt":x()}],"scroll-mr":[{"scroll-mr":x()}],"scroll-mb":[{"scroll-mb":x()}],"scroll-ml":[{"scroll-ml":x()}],"scroll-p":[{"scroll-p":x()}],"scroll-px":[{"scroll-px":x()}],"scroll-py":[{"scroll-py":x()}],"scroll-ps":[{"scroll-ps":x()}],"scroll-pe":[{"scroll-pe":x()}],"scroll-pbs":[{"scroll-pbs":x()}],"scroll-pbe":[{"scroll-pbe":x()}],"scroll-pt":[{"scroll-pt":x()}],"scroll-pr":[{"scroll-pr":x()}],"scroll-pb":[{"scroll-pb":x()}],"scroll-pl":[{"scroll-pl":x()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Z,Y]}],fill:[{fill:["none",...M()]}],"stroke-w":[{stroke:[Ge,Jr,yr,Is]}],stroke:[{stroke:["none",...M()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},Gh=(r,{extend:e={},override:t={}})=>(Nn(r.theme,t.theme),Nn(r.classGroups,t.classGroups),Nn(r.conflictingClassGroups,t.conflictingClassGroups),Nn(r.conflictingClassGroupModifiers,t.conflictingClassGroupModifiers),go(r,"postfixLookupClassGroups",t.postfixLookupClassGroups),go(r,"orderSensitiveModifiers",t.orderSensitiveModifiers),Pn(r.theme,e.theme),Pn(r.classGroups,e.classGroups),Pn(r.conflictingClassGroups,e.conflictingClassGroups),Pn(r.conflictingClassGroupModifiers,e.conflictingClassGroupModifiers),mo(r,e,"postfixLookupClassGroups"),mo(r,e,"orderSensitiveModifiers"),r),go=(r,e,t)=>{t!==void 0&&(r[e]=t)},Nn=(r,e)=>{if(e)for(const t in e)go(r,t,e[t])},Pn=(r,e)=>{if(e)for(const t in e)mo(r,e,t)},mo=(r,e,t)=>{const n=e[t];n!==void 0&&(r[t]=r[t]?r[t].concat(n):n)},uc=r=>Ds(r?typeof r=="function"?()=>r(Pi()):()=>Gh(Pi(),r):Pi),Rh=r=>{if(Mt(r))return;const e=r,t={...e.extend??{}};for(const i of["theme","classGroups","conflictingClassGroups","conflictingClassGroupModifiers","postfixLookupClassGroups","orderSensitiveModifiers","cacheSize","prefix","separator","experimentalParseClassName"])e[i]!==void 0&&t[i]===void 0&&(t[i]=e[i]);const n={};if(Object.keys(t).length>0&&(n.extend=t),e.override!=null&&!Mt(e.override)&&(n.override=e.override),!(!n.extend&&!n.override))return n},Oh=r=>{const e=Rh(r),t=uc(e);return n=>t.mergeString(n)},Hn,zh=()=>(Hn||(Hn=uc()),Hn),Mh=()=>((!Ct.cachedTwMerge||Ct.didTwMergeConfigChange)&&(Ct.didTwMergeConfigChange=!1,Ct.cachedTwMerge=Oh(Ct.cachedTwMergeConfig)),Ct.cachedTwMerge),Nh=r=>{const e=r==null?void 0:r.twMergeConfig;!e||Mt(e)||Ua(e,Ct.cachedTwMergeConfig)||(Ct.cachedTwMergeConfig=e,Ct.didTwMergeConfigChange=!0)},Ph=r=>si(r),Uh=Ct.reset.bind(Ct);Ct.reset=()=>{Hn=void 0,Uh()};var Wh=(r,e)=>{const t=Ph(r);return!t||!((e==null?void 0:e.twMerge)??!0)?t||void 0:t.indexOf(" ")===-1?t:(Nh(e),(!!(e!=null&&e.twMergeConfig&&!Mt(e.twMergeConfig))?Mh():zh().mergeString)(t)||void 0)},jh=(r,...e)=>Wh(e,r),Bh=Mf(jh),Fh=Bh.tv;function Vh(r){const e=r==="muted"?"ink-muted":r;return e==="current"?"currentColor":`var(--reddb-color-${e})`}function Kh(r){return`var(--reddb-spatial-icon-size-${r})`}var Hh=At('<svg><path d="M4 5h16"></path><path d="M4 12h16"></path><path d="M4 19h16"></path></svg>');function qh(r,e){ii(e,!0);let t=Gt(e,"size",3,"md"),n=Gt(e,"color",3,"foreground"),i=Ze(e,["$$slots","$$events","$$legacy","icon","size","color","class"]);const o=Q(()=>Kh(t())),s=Q(()=>Vh(n())),a=Q(()=>e.icon);Zt(()=>{n()});var c=er(),l=lt(c);{var d=h=>{var g=Hh();Yn(g,()=>({...i,"data-icon":!0,width:u(o),height:u(o),viewBox:"0 0 24 24",fill:"none",stroke:u(s),"stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:e.class})),V(h,g)},f=h=>{var g=er(),y=lt(g);Fu(y,()=>u(a),(C,b)=>{b(C,it(()=>i,{"data-icon":!0,get size(){return u(o)},get color(){return u(s)},strokeWidth:2,get class(){return e.class}}))}),V(h,g)};ke(l,h=>{e.icon==="menu"?h(d):h(f,-1)})}V(r,c),oi()}const Yh={sm:{root:"gap-[var(--reddb-spatial-gap-md)] px-[var(--reddb-spatial-inset-md)] py-[var(--reddb-spatial-inset-lg)]",title:"text-sm",description:"text-xs",hint:"text-xs"},md:{root:"gap-[var(--reddb-spatial-gap-lg)] px-[var(--reddb-spatial-inset-lg)] py-10",title:"text-base",description:"text-sm",hint:"text-xs"}},Xh={true:{root:"border-dashed border-muted"},false:{root:"border-transparent"}},Jh=Fh({slots:{root:"flex flex-col items-center justify-center rounded-lg border text-center",media:"text-ink-muted",title:"font-medium leading-tight text-foreground",description:"max-w-prose text-ink-muted",hint:"max-w-full rounded-md border border-muted px-2 py-1 font-mono text-ink-muted",actions:"flex flex-wrap items-center justify-center gap-[var(--reddb-spatial-gap-md)] pt-1"},variants:{size:Yh,bordered:Xh},defaultVariants:{size:"md",bordered:!0}});var Zh=he('<div aria-hidden="true"><!></div>'),Qh=he("<p> </p>"),ep=he("<code> </code>"),tp=he("<div><!></div>"),rp=he("<div><!> <p> </p> <!> <!> <!></div>");function np(r,e){ii(e,!0);const t=Gt(e,"size",3,"md"),n=Gt(e,"bordered",3,!0),i=Ze(e,["$$slots","$$events","$$legacy","title","description","hint","size","bordered","media","actions","class"]),o=Q(()=>Jh({size:t(),bordered:n()}));var s=rp();Yn(s,m=>({...i,class:m}),[()=>u(o).root({class:e.class})]);var a=R(s);{var c=m=>{var A=Zh(),v=R(A);ao(v,()=>e.media),T(A),pe(p=>St(A,1,p),[()=>Dt(u(o).media())]),V(m,A)};ke(a,m=>{e.media&&m(c)})}var l=P(a,2),d=R(l,!0);T(l);var f=P(l,2);{var h=m=>{var A=Qh(),v=R(A,!0);T(A),pe(p=>{St(A,1,p),fe(v,e.description)},[()=>Dt(u(o).description())]),V(m,A)};ke(f,m=>{e.description&&m(h)})}var g=P(f,2);{var y=m=>{var A=ep(),v=R(A,!0);T(A),pe(p=>{St(A,1,p),fe(v,e.hint)},[()=>Dt(u(o).hint())]),V(m,A)};ke(g,m=>{e.hint&&m(y)})}var C=P(g,2);{var b=m=>{var A=tp(),v=R(A);ao(v,()=>e.actions),T(A),pe(p=>St(A,1,p),[()=>Dt(u(o).actions())]),V(m,A)};ke(C,m=>{e.actions&&m(b)})}T(s),pe(m=>{St(l,1,m),fe(d,e.title)},[()=>Dt(u(o).title())]),V(r,s),oi()}const ip="red-ui:history",op="history:";function dc(r,e=!1){switch(r){case"embedded":return"none";case"standalone":return"vault";case"web":return e?"none":"labels-only"}}function sp(r){if(r.url)try{const t=new URL(r.url).host;if(t)return t}catch{}const e=(r.label??r.url??"").trim();if(!e)return"";try{const t=new URL(e).host;if(t)return t}catch{}return e.includes("@")?e.slice(e.lastIndexOf("@")+1):e}function ap(){return typeof localStorage>"u"?void 0:localStorage}function Gs(r){return`label:${encodeURIComponent(r)}`}function cp(){return typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():Math.random().toString(36).slice(2)+Date.now().toString(36)}function Zr(r,e){if(!r)return[];try{const t=r.getItem(e);if(!t)return[];const n=JSON.parse(t);return Array.isArray(n)?n.filter(i=>i&&typeof i.id=="string"&&typeof i.label=="string").map(i=>({id:i.id,label:i.label,last_used:i.last_used,rtt_ms:i.rtt_ms})):[]}catch{return[]}}function Rs(r,e,t){if(r)try{r.setItem(e,JSON.stringify(t))}catch{}}class lp{constructor(e){Te(this,"surface");Te(this,"secureStore");Te(this,"managedWebTarget");Te(this,"storage");Te(this,"historyKey");Te(this,"urlPrefix");Te(this,"idByUrl",new Map);Te(this,"urlById",new Map);Te(this,"onChange");this.surface=e.surface,this.secureStore=e.secureStore,this.managedWebTarget=e.managedWebTarget??(()=>!1),this.storage=e.storage??ap(),this.historyKey=e.historyKey??ip,this.urlPrefix=e.urlPrefix??op}setOnChange(e){this.onChange=e}persistence(){return dc(this.surface(),this.managedWebTarget())}load(){return this.persistence()==="none"?[]:Zr(this.storage,this.historyKey).map(e=>({url:this.urlById.get(e.id)??"",label:e.label,last_used:e.last_used,rtt_ms:e.rtt_ms}))}save(e){var c,l,d;const t=this.persistence();if(t==="none"){(c=this.onChange)==null||c.call(this);return}const n=Zr(this.storage,this.historyKey),i=new Map(n.map(f=>[f.label,f])),o=[],s=new Set,a=new Set;for(const f of e){const h=sp(f);if(!h)continue;let g;f.url?(g=t==="labels-only"?Gs(h):this.idByUrl.get(f.url)??cp(),this.idByUrl.set(f.url,g),this.urlById.set(g,f.url)):g=((l=i.get(h))==null?void 0:l.id)??Gs(h),!(s.has(g)||!f.url&&a.has(h))&&(s.add(g),a.add(h),o.push({id:g,label:h,last_used:typeof f.last_used=="number"?f.last_used:Date.now(),rtt_ms:f.rtt_ms}))}if(Rs(this.storage,this.historyKey,o),t==="vault"){const f=this.secureStore();if(f)for(const h of o){const g=this.urlById.get(h.id);g&&f.put(this.urlPrefix+h.id,g).catch(()=>{})}}(d=this.onChange)==null||d.call(this)}uiEntries(){return this.persistence()==="none"?[]:Zr(this.storage,this.historyKey).map(e=>({id:e.id,label:e.label,last_used:e.last_used,rtt_ms:e.rtt_ms,url:this.urlById.get(e.id)}))}async hydrate(){var i;if(this.persistence()!=="vault")return;const e=this.secureStore();if(!e)return;const t=Zr(this.storage,this.historyKey);let n=!1;for(const o of t)if(!this.urlById.has(o.id))try{const s=await e.get(this.urlPrefix+o.id);s&&(this.urlById.set(o.id,s),this.idByUrl.set(s,o.id),n=!0)}catch{}n&&((i=this.onChange)==null||i.call(this))}async forgetById(e){var o,s;if(this.persistence()==="none"){(o=this.onChange)==null||o.call(this);return}const t=Zr(this.storage,this.historyKey).filter(a=>a.id!==e);Rs(this.storage,this.historyKey,t);const n=this.urlById.get(e);n&&(this.urlById.delete(e),this.idByUrl.delete(n));const i=this.persistence()==="vault"?this.secureStore():null;if(i)try{await i.delete(this.urlPrefix+e)}catch{}(s=this.onChange)==null||s.call(this)}async forgetByUrl(e){const t=this.idByUrl.get(e);t&&await this.forgetById(t)}}function up({tauri:r,inFrame:e,mcp:t,embedLib:n}){return r?"standalone":e||t||n?"embedded":"web"}function dp(){if(typeof window>"u")return"web";const r="__TAURI_INTERNALS__"in window||"__TAURI__"in window;let e=!1;try{e=window.self!==window.top}catch{e=!0}const t=typeof location<"u"&&new URLSearchParams(location.search).has("mcp"),n=window.__RED_UI_EMBED_SURFACE__===!0;return up({tauri:r,inFrame:e,mcp:t,embedLib:n})}function Ui(r,e){switch(r){case"embedded":return!1;case"standalone":return!0;case"web":return!1}}const vo="red-ui:secure",Os="__probe__",zs="ok";function Ms(){if(typeof localStorage>"u")return!1;for(let r=0;r<localStorage.length;r++){const e=localStorage.key(r);if(e&&e.startsWith(vo+":"))return!0}return!1}var mn,vn,yn,bn,wn,_n;class fp{constructor(){nt(this,mn,Ee(null));nt(this,vn,Ee(!0));nt(this,yn,Ee(!1));nt(this,bn,Ee("unknown"));nt(this,wn,Ee("web"));nt(this,_n,Ee(null));if(typeof window>"u"){this.backend="unknown";return}if(this.surface=dp(),this.surface==="standalone"){this.backend="tauri",this.bindTauri();return}this.backend="web",Ms(),this.needsSetup=!1,this.locked=Ui(this.surface)}get store(){return u(xe(this,mn))}set store(e){N(xe(this,mn),e,!0)}get locked(){return u(xe(this,vn))}set locked(e){N(xe(this,vn),e,!0)}get needsSetup(){return u(xe(this,yn))}set needsSetup(e){N(xe(this,yn),e,!0)}get backend(){return u(xe(this,bn))}set backend(e){N(xe(this,bn),e,!0)}get surface(){return u(xe(this,wn))}set surface(e){N(xe(this,wn),e,!0)}get error(){return u(xe(this,_n))}set error(e){N(xe(this,_n),e,!0)}async bindTauri(){try{const e=await hr(()=>import("./DhEqZVGG.js"),[],import.meta.url);this.store=new Jd({invoke:e.invoke}),this.locked=!1}catch(e){this.error=`Tauri keychain bridge unavailable: ${e.message}`}}async unlock(e){if(this.error=null,this.backend!=="web")return!0;let t;try{t=new Yd(e,{namespace:vo})}catch(n){return this.error=n.message,!1}try{const n=await t.get(Os);if(n===null)await t.put(Os,zs);else if(n!==zs)return this.error="Wrong password",!1}catch(n){return n instanceof wt&&n.code==="DECRYPT_FAILED"?(this.error="Wrong password",!1):(this.error=n.message,!1)}return this.store=t,this.locked=!1,this.needsSetup=!1,!0}lock(){this.store=null,this.backend==="web"&&(this.locked=Ui(this.surface,Ms()))}wipe(){if(typeof localStorage>"u")return;const e=[];for(let t=0;t<localStorage.length;t++){const n=localStorage.key(t);n&&(n.startsWith(vo+":")||n.startsWith("red-ui:"))&&e.push(n)}for(const t of e)localStorage.removeItem(t);this.store=null,this.backend==="web"&&(this.locked=Ui(this.surface),this.needsSetup=!1),this.error=null}}mn=new WeakMap,vn=new WeakMap,yn=new WeakMap,bn=new WeakMap,wn=new WeakMap,_n=new WeakMap;const cn=new fp,fc=[{id:"embedded",label:"Embedded",url:"http://localhost:5055",role:"embedded",description:"Local file via ./scripts/embedded.sh."},{id:"docker-primary",label:"Docker primary",url:"http://localhost:15055",role:"primary",description:"Docker compose primary (./docker/compose.yml)."},{id:"docker-replica",label:"Docker replica",url:"http://localhost:25055",role:"replica",description:"Read-only mirror of docker primary."}],Ns=Ma;function Ps(r){if(typeof localStorage>"u")return;if(gp()!=="vault"){try{localStorage.removeItem(Ns)}catch{}return}try{localStorage.setItem(Ns,JSON.stringify(r))}catch{}}const hp=/(handoff|token|secret|password|passwd|auth|credential|api[-_]?key|bearer)/i;let $o=!1;function pp(){cn.surface==="web"&&($o=!0)}function hc(){if($o)return!0;if(cn.surface!=="web"||typeof location>"u")return!1;for(const r of[location.search,location.hash]){const e=new URLSearchParams(r.startsWith("#")?r.slice(1):r);for(const t of e.keys())if(hp.test(t))return!0}return!1}function gp(){return dc(cn.surface,hc())}const br=new lp({surface:()=>cn.surface,secureStore:()=>cn.store,managedWebTarget:hc});function mp(r){return r.trim()?pr(r).url:""}function oy(r){if(!r.trim())return{url:""};try{return pr(r)}catch{throw new Error("Invalid connection string. Check the address and provide both username and password.")}}function on(r){const e=mp(r);let t=e;try{t=new URL(e).host}catch{}return{id:e,label:t||e,url:e,role:"primary",description:"User-provided connection string."}}function ai(){return typeof window<"u"&&("__TAURI_INTERNALS__"in window||"__TAURI__"in window)}function vp(){return[...ai()?bd:_o]}async function yp(r){if(!ai())throw new Error("file:// databases can only be opened in the desktop app");const e=r.replace(/^file:\/\//i,""),{invoke:t}=await hr(async()=>{const{invoke:n}=await import("./DhEqZVGG.js");return{invoke:n}},[],import.meta.url);try{return await t("open_embedded",{path:e})}catch(n){throw Jn.from(n)}}const pc=async(r,e)=>{const t=typeof r=="string"?r:r instanceof URL?r.href:r.url,n=/^https?:\/\/(127\.0\.0\.1|localhost|\[::1\])(:\d+)?(\/|$)/i.test(t);if(ai()&&n)try{const{fetch:i}=await hr(async()=>{const{fetch:o}=await import("./B5euRbKa.js");return{fetch:o}},__vite__mapDeps([0,1]),import.meta.url);return await i(r,e)}catch(i){const o=i instanceof Error?i.message:typeof i=="string"?i:String(i);throw new Error(`rust-side fetch failed for ${t}: ${o}`)}return fetch(r,e)};function Us(r){return typeof r.useHandoffToken=="function"}const bp=new Rd({presets:fc,history:br,transports:vp(),embeddedResolver:yp,clientFactory:(r,e)=>new wo(r,{...e,fetch:pc}),bootParams:Dd(typeof location<"u"?location.search:"",typeof location<"u"?location.hash:"")});let gc=bp;function Or(){return gc}function sy(r){gc=r}var xn,kn,En,Sn,dr,_r,Pr;class wp{constructor(){nt(this,xn,Ee(!1));nt(this,kn,Ee(Kt(fc[1])));nt(this,En,Ee(Kt({reachable:!1})));nt(this,Sn,Ee(Kt([])));nt(this,dr,Ee(null));nt(this,_r,Ee(Kt({...fr})));nt(this,Pr,Ee(!1));this.history=br.uiEntries(),br.setOnChange(()=>{this.history=br.uiEntries()})}get connected(){return u(xe(this,xn))}set connected(e){N(xe(this,xn),e,!0)}get active(){return u(xe(this,kn))}set active(e){N(xe(this,kn),e,!0)}get probe(){return u(xe(this,En))}set probe(e){N(xe(this,En),e,!0)}get history(){return u(xe(this,Sn))}set history(e){N(xe(this,Sn),e,!0)}get targetResolved(){return u(xe(this,Pr))}get client(){return u(xe(this,dr))}get readOnly(){var e;return this.connected&&((e=this.probe.stats)==null?void 0:e.read_only)===!0}get readOnlyReason(){var e;return(e=this.probe.stats)==null?void 0:e.read_only_reason}get capabilities(){return u(xe(this,_r))}get supportedTransports(){var e,t;return((t=(e=Or()).transports)==null?void 0:t.call(e))??[..._o]}canReach(e){return wd(e,this.supportedTransports)}async forget(e){await br.forgetByUrl(e)}async forgetById(e){await br.forgetById(e)}async hydrateUrls(){await br.hydrate()}async bootstrap(e=Vd){const t=await e(),n=t.route??null;if(t.error)return this.disconnect(),this.probe={reachable:!1,error:t.error},n;if(!t.target)return n;if(!t.token)return await this.connectString(t.target),n;let i;try{const o=pr(t.target);if(o.credentials)throw new Error("Choose either connection credentials or a session token.");i=on(o.url)}catch(o){return this.disconnect(),this.active=on(""),this.probe={reachable:!1,error:o instanceof Error?o.message:"Invalid connection string."},n}if(t.token){pp();const o=Or();Us(o)&&o.useHandoffToken(i.url,t.token)}return await this.tryConnect(i),n}async switch(e){this.active=e,Ps(e),await this.tryConnect(e)}async connectString(e,t){try{const n=pr(e);if(n.credentials&&t)throw new Error("Use credentials in either the connection string or the sign-in fields.");const i=t??n.credentials,o=on(n.url);if(!this.canReach(n.url))throw new Error(_p(n.url)??"This connection transport is not available here.");return i?await this.login(o,i.username,i.password):await this.tryConnect(o)}catch(n){return this.disconnect(),this.active=on(""),this.probe={reachable:!1,error:n instanceof Error?n.message:"Invalid connection string."},!1}}async login(e,t,n){this.active=e,N(xe(this,dr),null),this.connected=!1,N(xe(this,_r),{...fr},!0),this.probe={reachable:!1};try{const i=Or();if(!Us(i))throw new Error("This connection is managed by its host.");const o=await new wo(e.url,{fetch:pc}).login(t,n);return i.useHandoffToken(e.url,o),await this.tryConnect(e)}catch(i){return this.probe={reachable:!1,error:i instanceof Error?i.message:"Database sign-in failed."},!1}}async tryConnect(e){this.active=e,N(xe(this,dr),null),this.connected=!1,N(xe(this,Pr),!0),Xr.begin(`Opening ${e.label}`);try{Xr.step("Reaching server",e.url);const t=await lr.track(`connect · ${e.label}`,()=>Or().connect(e.id));N(xe(this,dr),t.client,!0),this.active={...e,...t.connection,description:e.description},Ps(this.active),Xr.step("Fetching stats & capabilities");const[n,i,o]=await Promise.all([lr.track(`connect · ${e.label} stats`,()=>t.client.stats()).catch(()=>{}),lr.track(`connect · ${e.label} replication`,()=>t.client.replication()).catch(()=>{}),lr.track(`connect · ${e.label} capabilities`,()=>t.client.capabilities()).catch(()=>({...fr}))]);return this.probe={reachable:!0,rtt_ms:t.rtt_ms,stats:n,replication:i},N(xe(this,_r),o,!0),this.connected=!0,Xr.succeed(),!0}catch(t){return this.probe={reachable:!1,error:t.message},Xr.fail(t.message),!1}}async adoptInjected(){const[e]=await Or().list();if(!e)return!1;const t={...e,description:e.description??"Injected by the embedding host."};return this.tryConnect(t)}async connectFromBootParams(){var n,i;const e=(i=(n=Or()).bootParams)==null?void 0:i.call(n);if(!e)return null;const t=e.to??e.view??null;return e.endpoint&&await this.connectString(e.endpoint),t}async refresh(){const e=this.client;if(!e){await this.tryConnect(this.active);return}try{const t=await lr.track(`heartbeat · ${this.active.label}`,()=>e.ping());if(!t.ok){this.probe={reachable:!1,error:t.error};return}const[n,i]=await Promise.all([lr.track("heartbeat · stats",()=>e.stats()).catch(()=>{}),lr.track("heartbeat · replication",()=>e.replication()).catch(()=>{})]);this.probe={reachable:!0,rtt_ms:t.rtt_ms,stats:n,replication:i},this.connected=!0}catch(t){this.probe={reachable:!1,error:t.message}}}disconnect(){this.connected=!1,this.probe={reachable:!1},N(xe(this,dr),null),N(xe(this,_r),{...fr},!0),N(xe(this,Pr),!1),$o=!1}}xn=new WeakMap,kn=new WeakMap,En=new WeakMap,Sn=new WeakMap,dr=new WeakMap,_r=new WeakMap,Pr=new WeakMap;const Qn=new wp,mc="Local database files (file://) can only be opened in the desktop app — the web version can't reach files on your machine.";function _p(r){return Qn.canReach(r)?null:Ta(r)==="unix"?mc:null}async function ay(r){if(!ai())return{ok:!1,reason:mc};const e=(await hr(async()=>{const{open:i}=await import("./C-kqMbRi.js");return{open:i}},__vite__mapDeps([2,1]),import.meta.url)).open,t=await e({multiple:!1,directory:!1,title:"Open database file",filters:[{name:"reddb database",extensions:["rdb"]}]});return t?await Qn.tryConnect(on(`file://${t}`))?{ok:!0}:{ok:!1,reason:Qn.probe.error??"unreachable"}:{ok:!1,cancelled:!0}}const vc={name:"loader-circle",size:24,node:[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56"}]],aliases:["loader-2"]};vc.node;function xp(r,e){let t=Ze(e,["$$slots","$$events","$$legacy"]);at(r,it(()=>t,{get icon(){return vc}}))}const yc={name:"search",size:24,node:[["path",{d:"m21 21-4.34-4.34"}],["circle",{cx:"11",cy:"11",r:"8"}]]};yc.node;function kp(r,e){let t=Ze(e,["$$slots","$$events","$$legacy"]);at(r,it(()=>t,{get icon(){return yc}}))}const bc={name:"network",size:24,node:[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3"}],["path",{d:"M12 12V8"}]]};bc.node;function Ws(r,e){let t=Ze(e,["$$slots","$$events","$$legacy"]);at(r,it(()=>t,{get icon(){return bc}}))}function cy(r){return r?r==="graph"?"graph":r:"table"}function ly(r,e){switch(r){case"graph":case"svg":return"graph";case"table":return"table";case"json":return"json";case"hypertable":case"kv":case"vector":case"queue":case"stats":case"diff":case"document":return r;default:return e}}function Wi(r,e){return`/c/${encodeURIComponent(r)}/p/${encodeURIComponent(e)}`}const wc={name:"triangle-alert",size:24,node:[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"}],["path",{d:"M12 9v4"}],["path",{d:"M12 17h.01"}]],aliases:["alert-triangle"]};wc.node;function js(r,e){let t=Ze(e,["$$slots","$$events","$$legacy"]);at(r,it(()=>t,{get icon(){return wc}}))}const _c={name:"play",size:24,node:[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z"}]]};_c.node;function Ep(r,e){let t=Ze(e,["$$slots","$$events","$$legacy"]);at(r,it(()=>t,{get icon(){return _c}}))}const xc={name:"rotate-cw",size:24,node:[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"}],["path",{d:"M21 3v5h-5"}]]};xc.node;function Sp(r,e){let t=Ze(e,["$$slots","$$events","$$legacy"]);at(r,it(()=>t,{get icon(){return xc}}))}function Do(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Un={exports:{}},Bs;function Cp(){if(Bs)return Un.exports;Bs=1;var r=typeof Reflect=="object"?Reflect:null,e=r&&typeof r.apply=="function"?r.apply:function(E,S,$){return Function.prototype.apply.call(E,S,$)},t;r&&typeof r.ownKeys=="function"?t=r.ownKeys:Object.getOwnPropertySymbols?t=function(E){return Object.getOwnPropertyNames(E).concat(Object.getOwnPropertySymbols(E))}:t=function(E){return Object.getOwnPropertyNames(E)};function n(p){console&&console.warn&&console.warn(p)}var i=Number.isNaN||function(E){return E!==E};function o(){o.init.call(this)}Un.exports=o,Un.exports.once=m,o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function a(p){if(typeof p!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof p)}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(p){if(typeof p!="number"||p<0||i(p))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+p+".");s=p}}),o.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(E){if(typeof E!="number"||E<0||i(E))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+E+".");return this._maxListeners=E,this};function c(p){return p._maxListeners===void 0?o.defaultMaxListeners:p._maxListeners}o.prototype.getMaxListeners=function(){return c(this)},o.prototype.emit=function(E){for(var S=[],$=1;$<arguments.length;$++)S.push(arguments[$]);var x=E==="error",D=this._events;if(D!==void 0)x=x&&D.error===void 0;else if(!x)return!1;if(x){var I;if(S.length>0&&(I=S[0]),I instanceof Error)throw I;var j=new Error("Unhandled error."+(I?" ("+I.message+")":""));throw j.context=I,j}var O=D[E];if(O===void 0)return!1;if(typeof O=="function")e(O,this,S);else for(var w=O.length,ge=y(O,w),$=0;$<w;++$)e(ge[$],this,S);return!0};function l(p,E,S,$){var x,D,I;if(a(S),D=p._events,D===void 0?(D=p._events=Object.create(null),p._eventsCount=0):(D.newListener!==void 0&&(p.emit("newListener",E,S.listener?S.listener:S),D=p._events),I=D[E]),I===void 0)I=D[E]=S,++p._eventsCount;else if(typeof I=="function"?I=D[E]=$?[S,I]:[I,S]:$?I.unshift(S):I.push(S),x=c(p),x>0&&I.length>x&&!I.warned){I.warned=!0;var j=new Error("Possible EventEmitter memory leak detected. "+I.length+" "+String(E)+" listeners added. Use emitter.setMaxListeners() to increase limit");j.name="MaxListenersExceededWarning",j.emitter=p,j.type=E,j.count=I.length,n(j)}return p}o.prototype.addListener=function(E,S){return l(this,E,S,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(E,S){return l(this,E,S,!0)};function d(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function f(p,E,S){var $={fired:!1,wrapFn:void 0,target:p,type:E,listener:S},x=d.bind($);return x.listener=S,$.wrapFn=x,x}o.prototype.once=function(E,S){return a(S),this.on(E,f(this,E,S)),this},o.prototype.prependOnceListener=function(E,S){return a(S),this.prependListener(E,f(this,E,S)),this},o.prototype.removeListener=function(E,S){var $,x,D,I,j;if(a(S),x=this._events,x===void 0)return this;if($=x[E],$===void 0)return this;if($===S||$.listener===S)--this._eventsCount===0?this._events=Object.create(null):(delete x[E],x.removeListener&&this.emit("removeListener",E,$.listener||S));else if(typeof $!="function"){for(D=-1,I=$.length-1;I>=0;I--)if($[I]===S||$[I].listener===S){j=$[I].listener,D=I;break}if(D<0)return this;D===0?$.shift():C($,D),$.length===1&&(x[E]=$[0]),x.removeListener!==void 0&&this.emit("removeListener",E,j||S)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(E){var S,$,x;if($=this._events,$===void 0)return this;if($.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):$[E]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete $[E]),this;if(arguments.length===0){var D=Object.keys($),I;for(x=0;x<D.length;++x)I=D[x],I!=="removeListener"&&this.removeAllListeners(I);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(S=$[E],typeof S=="function")this.removeListener(E,S);else if(S!==void 0)for(x=S.length-1;x>=0;x--)this.removeListener(E,S[x]);return this};function h(p,E,S){var $=p._events;if($===void 0)return[];var x=$[E];return x===void 0?[]:typeof x=="function"?S?[x.listener||x]:[x]:S?b(x):y(x,x.length)}o.prototype.listeners=function(E){return h(this,E,!0)},o.prototype.rawListeners=function(E){return h(this,E,!1)},o.listenerCount=function(p,E){return typeof p.listenerCount=="function"?p.listenerCount(E):g.call(p,E)},o.prototype.listenerCount=g;function g(p){var E=this._events;if(E!==void 0){var S=E[p];if(typeof S=="function")return 1;if(S!==void 0)return S.length}return 0}o.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]};function y(p,E){for(var S=new Array(E),$=0;$<E;++$)S[$]=p[$];return S}function C(p,E){for(;E+1<p.length;E++)p[E]=p[E+1];p.pop()}function b(p){for(var E=new Array(p.length),S=0;S<E.length;++S)E[S]=p[S].listener||p[S];return E}function m(p,E){return new Promise(function(S,$){function x(I){p.removeListener(E,D),$(I)}function D(){typeof p.removeListener=="function"&&p.removeListener("error",x),S([].slice.call(arguments))}v(p,E,D,{once:!0}),E!=="error"&&A(p,x,{once:!0})})}function A(p,E,S){typeof p.on=="function"&&v(p,"error",E,S)}function v(p,E,S,$){if(typeof p.on=="function")$.once?p.once(E,S):p.on(E,S);else if(typeof p.addEventListener=="function")p.addEventListener(E,function x(D){$.once&&p.removeEventListener(E,x),S(D)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof p)}return Un.exports}var Ap=Cp();function $p(){const r=arguments[0];for(let e=1,t=arguments.length;e<t;e++)if(arguments[e])for(const n in arguments[e])r[n]=arguments[e][n];return r}let ut=$p;typeof Object.assign=="function"&&(ut=Object.assign);function Nt(r,e,t,n){const i=r._nodes.get(e);let o=null;return i&&(n==="mixed"?o=i.out&&i.out[t]||i.undirected&&i.undirected[t]:n==="directed"?o=i.out&&i.out[t]:o=i.undirected&&i.undirected[t]),o}function mt(r){return typeof r=="object"&&r!==null}function kc(r){let e;for(e in r)return!1;return!0}function zt(r,e,t){Object.defineProperty(r,e,{enumerable:!1,configurable:!1,writable:!0,value:t})}function Wt(r,e,t){const n={enumerable:!0,configurable:!0};typeof t=="function"?n.get=t:(n.value=t,n.writable=!1),Object.defineProperty(r,e,n)}function Fs(r){return!(!mt(r)||r.attributes&&!Array.isArray(r.attributes))}function Dp(){let r=Math.floor(Math.random()*256)&255;return()=>r++}function tr(){const r=arguments;let e=null,t=-1;return{[Symbol.iterator](){return this},next(){let n=null;do{if(e===null){if(t++,t>=r.length)return{done:!0};e=r[t][Symbol.iterator]()}if(n=e.next(),n.done){e=null;continue}break}while(!0);return n}}}function jr(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}class Io extends Error{constructor(e){super(),this.name="GraphError",this.message=e}}class q extends Io{constructor(e){super(e),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,q.prototype.constructor)}}class B extends Io{constructor(e){super(e),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,B.prototype.constructor)}}class ue extends Io{constructor(e){super(e),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,ue.prototype.constructor)}}function Ec(r,e){this.key=r,this.attributes=e,this.clear()}Ec.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.undirectedLoops=0,this.directedLoops=0,this.in={},this.out={},this.undirected={}};function Sc(r,e){this.key=r,this.attributes=e,this.clear()}Sc.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function Cc(r,e){this.key=r,this.attributes=e,this.clear()}Cc.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function Br(r,e,t,n,i){this.key=e,this.attributes=i,this.undirected=r,this.source=t,this.target=n}Br.prototype.attach=function(){let r="out",e="in";this.undirected&&(r=e="undirected");const t=this.source.key,n=this.target.key;this.source[r][n]=this,!(this.undirected&&t===n)&&(this.target[e][t]=this)};Br.prototype.attachMulti=function(){let r="out",e="in";const t=this.source.key,n=this.target.key;this.undirected&&(r=e="undirected");const i=this.source[r],o=i[n];if(typeof o>"u"){i[n]=this,this.undirected&&t===n||(this.target[e][t]=this);return}o.previous=this,this.next=o,i[n]=this,this.target[e][t]=this};Br.prototype.detach=function(){const r=this.source.key,e=this.target.key;let t="out",n="in";this.undirected&&(t=n="undirected"),delete this.source[t][e],delete this.target[n][r]};Br.prototype.detachMulti=function(){const r=this.source.key,e=this.target.key;let t="out",n="in";this.undirected&&(t=n="undirected"),this.previous===void 0?this.next===void 0?(delete this.source[t][e],delete this.target[n][r]):(this.next.previous=void 0,this.source[t][e]=this.next,this.target[n][r]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};const Ac=0,$c=1,Ip=2,Dc=3;function rr(r,e,t,n,i,o,s){let a,c,l,d;if(n=""+n,t===Ac){if(a=r._nodes.get(n),!a)throw new B(`Graph.${e}: could not find the "${n}" node in the graph.`);l=i,d=o}else if(t===Dc){if(i=""+i,c=r._edges.get(i),!c)throw new B(`Graph.${e}: could not find the "${i}" edge in the graph.`);const f=c.source.key,h=c.target.key;if(n===f)a=c.target;else if(n===h)a=c.source;else throw new B(`Graph.${e}: the "${n}" node is not attached to the "${i}" edge (${f}, ${h}).`);l=o,d=s}else{if(c=r._edges.get(n),!c)throw new B(`Graph.${e}: could not find the "${n}" edge in the graph.`);t===$c?a=c.source:a=c.target,l=i,d=o}return[a,l,d]}function Lp(r,e,t){r.prototype[e]=function(n,i,o){const[s,a]=rr(this,e,t,n,i,o);return s.attributes[a]}}function Tp(r,e,t){r.prototype[e]=function(n,i){const[o]=rr(this,e,t,n,i);return o.attributes}}function Gp(r,e,t){r.prototype[e]=function(n,i,o){const[s,a]=rr(this,e,t,n,i,o);return s.attributes.hasOwnProperty(a)}}function Rp(r,e,t){r.prototype[e]=function(n,i,o,s){const[a,c,l]=rr(this,e,t,n,i,o,s);return a.attributes[c]=l,this.emit("nodeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:c}),this}}function Op(r,e,t){r.prototype[e]=function(n,i,o,s){const[a,c,l]=rr(this,e,t,n,i,o,s);if(typeof l!="function")throw new q(`Graph.${e}: updater should be a function.`);const d=a.attributes,f=l(d[c]);return d[c]=f,this.emit("nodeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:c}),this}}function zp(r,e,t){r.prototype[e]=function(n,i,o){const[s,a]=rr(this,e,t,n,i,o);return delete s.attributes[a],this.emit("nodeAttributesUpdated",{key:s.key,type:"remove",attributes:s.attributes,name:a}),this}}function Mp(r,e,t){r.prototype[e]=function(n,i,o){const[s,a]=rr(this,e,t,n,i,o);if(!mt(a))throw new q(`Graph.${e}: provided attributes are not a plain object.`);return s.attributes=a,this.emit("nodeAttributesUpdated",{key:s.key,type:"replace",attributes:s.attributes}),this}}function Np(r,e,t){r.prototype[e]=function(n,i,o){const[s,a]=rr(this,e,t,n,i,o);if(!mt(a))throw new q(`Graph.${e}: provided attributes are not a plain object.`);return ut(s.attributes,a),this.emit("nodeAttributesUpdated",{key:s.key,type:"merge",attributes:s.attributes,data:a}),this}}function Pp(r,e,t){r.prototype[e]=function(n,i,o){const[s,a]=rr(this,e,t,n,i,o);if(typeof a!="function")throw new q(`Graph.${e}: provided updater is not a function.`);return s.attributes=a(s.attributes),this.emit("nodeAttributesUpdated",{key:s.key,type:"update",attributes:s.attributes}),this}}const Up=[{name:r=>`get${r}Attribute`,attacher:Lp},{name:r=>`get${r}Attributes`,attacher:Tp},{name:r=>`has${r}Attribute`,attacher:Gp},{name:r=>`set${r}Attribute`,attacher:Rp},{name:r=>`update${r}Attribute`,attacher:Op},{name:r=>`remove${r}Attribute`,attacher:zp},{name:r=>`replace${r}Attributes`,attacher:Mp},{name:r=>`merge${r}Attributes`,attacher:Np},{name:r=>`update${r}Attributes`,attacher:Pp}];function Wp(r){Up.forEach(function({name:e,attacher:t}){t(r,e("Node"),Ac),t(r,e("Source"),$c),t(r,e("Target"),Ip),t(r,e("Opposite"),Dc)})}function jp(r,e,t){r.prototype[e]=function(n,i){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new ue(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new ue(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+n,a=""+i;if(i=arguments[2],o=Nt(this,s,a,t),!o)throw new B(`Graph.${e}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(t!=="mixed")throw new ue(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,o=this._edges.get(n),!o)throw new B(`Graph.${e}: could not find the "${n}" edge in the graph.`)}return o.attributes[i]}}function Bp(r,e,t){r.prototype[e]=function(n){let i;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new ue(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new ue(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+n,s=""+arguments[1];if(i=Nt(this,o,s,t),!i)throw new B(`Graph.${e}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new ue(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,i=this._edges.get(n),!i)throw new B(`Graph.${e}: could not find the "${n}" edge in the graph.`)}return i.attributes}}function Fp(r,e,t){r.prototype[e]=function(n,i){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new ue(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new ue(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+n,a=""+i;if(i=arguments[2],o=Nt(this,s,a,t),!o)throw new B(`Graph.${e}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(t!=="mixed")throw new ue(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,o=this._edges.get(n),!o)throw new B(`Graph.${e}: could not find the "${n}" edge in the graph.`)}return o.attributes.hasOwnProperty(i)}}function Vp(r,e,t){r.prototype[e]=function(n,i,o){let s;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new ue(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new ue(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const a=""+n,c=""+i;if(i=arguments[2],o=arguments[3],s=Nt(this,a,c,t),!s)throw new B(`Graph.${e}: could not find an edge for the given path ("${a}" - "${c}").`)}else{if(t!=="mixed")throw new ue(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,s=this._edges.get(n),!s)throw new B(`Graph.${e}: could not find the "${n}" edge in the graph.`)}return s.attributes[i]=o,this.emit("edgeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:i}),this}}function Kp(r,e,t){r.prototype[e]=function(n,i,o){let s;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new ue(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new ue(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const a=""+n,c=""+i;if(i=arguments[2],o=arguments[3],s=Nt(this,a,c,t),!s)throw new B(`Graph.${e}: could not find an edge for the given path ("${a}" - "${c}").`)}else{if(t!=="mixed")throw new ue(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,s=this._edges.get(n),!s)throw new B(`Graph.${e}: could not find the "${n}" edge in the graph.`)}if(typeof o!="function")throw new q(`Graph.${e}: updater should be a function.`);return s.attributes[i]=o(s.attributes[i]),this.emit("edgeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:i}),this}}function Hp(r,e,t){r.prototype[e]=function(n,i){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new ue(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new ue(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+n,a=""+i;if(i=arguments[2],o=Nt(this,s,a,t),!o)throw new B(`Graph.${e}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(t!=="mixed")throw new ue(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,o=this._edges.get(n),!o)throw new B(`Graph.${e}: could not find the "${n}" edge in the graph.`)}return delete o.attributes[i],this.emit("edgeAttributesUpdated",{key:o.key,type:"remove",attributes:o.attributes,name:i}),this}}function qp(r,e,t){r.prototype[e]=function(n,i){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new ue(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new ue(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+n,a=""+i;if(i=arguments[2],o=Nt(this,s,a,t),!o)throw new B(`Graph.${e}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(t!=="mixed")throw new ue(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,o=this._edges.get(n),!o)throw new B(`Graph.${e}: could not find the "${n}" edge in the graph.`)}if(!mt(i))throw new q(`Graph.${e}: provided attributes are not a plain object.`);return o.attributes=i,this.emit("edgeAttributesUpdated",{key:o.key,type:"replace",attributes:o.attributes}),this}}function Yp(r,e,t){r.prototype[e]=function(n,i){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new ue(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new ue(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+n,a=""+i;if(i=arguments[2],o=Nt(this,s,a,t),!o)throw new B(`Graph.${e}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(t!=="mixed")throw new ue(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,o=this._edges.get(n),!o)throw new B(`Graph.${e}: could not find the "${n}" edge in the graph.`)}if(!mt(i))throw new q(`Graph.${e}: provided attributes are not a plain object.`);return ut(o.attributes,i),this.emit("edgeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:i}),this}}function Xp(r,e,t){r.prototype[e]=function(n,i){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new ue(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new ue(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+n,a=""+i;if(i=arguments[2],o=Nt(this,s,a,t),!o)throw new B(`Graph.${e}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(t!=="mixed")throw new ue(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,o=this._edges.get(n),!o)throw new B(`Graph.${e}: could not find the "${n}" edge in the graph.`)}if(typeof i!="function")throw new q(`Graph.${e}: provided updater is not a function.`);return o.attributes=i(o.attributes),this.emit("edgeAttributesUpdated",{key:o.key,type:"update",attributes:o.attributes}),this}}const Jp=[{name:r=>`get${r}Attribute`,attacher:jp},{name:r=>`get${r}Attributes`,attacher:Bp},{name:r=>`has${r}Attribute`,attacher:Fp},{name:r=>`set${r}Attribute`,attacher:Vp},{name:r=>`update${r}Attribute`,attacher:Kp},{name:r=>`remove${r}Attribute`,attacher:Hp},{name:r=>`replace${r}Attributes`,attacher:qp},{name:r=>`merge${r}Attributes`,attacher:Yp},{name:r=>`update${r}Attributes`,attacher:Xp}];function Zp(r){Jp.forEach(function({name:e,attacher:t}){t(r,e("Edge"),"mixed"),t(r,e("DirectedEdge"),"directed"),t(r,e("UndirectedEdge"),"undirected")})}const Qp=[{name:"edges",type:"mixed"},{name:"inEdges",type:"directed",direction:"in"},{name:"outEdges",type:"directed",direction:"out"},{name:"inboundEdges",type:"mixed",direction:"in"},{name:"outboundEdges",type:"mixed",direction:"out"},{name:"directedEdges",type:"directed"},{name:"undirectedEdges",type:"undirected"}];function eg(r,e,t,n){let i=!1;for(const o in e){if(o===n)continue;const s=e[o];if(i=t(s.key,s.attributes,s.source.key,s.target.key,s.source.attributes,s.target.attributes,s.undirected),r&&i)return s.key}}function tg(r,e,t,n){let i,o,s,a=!1;for(const c in e)if(c!==n){i=e[c];do{if(o=i.source,s=i.target,a=t(i.key,i.attributes,o.key,s.key,o.attributes,s.attributes,i.undirected),r&&a)return i.key;i=i.next}while(i!==void 0)}}function ji(r,e){const t=Object.keys(r),n=t.length;let i,o=0;return{[Symbol.iterator](){return this},next(){do if(i)i=i.next;else{if(o>=n)return{done:!0};const s=t[o++];if(s===e){i=void 0;continue}i=r[s]}while(!i);return{done:!1,value:{edge:i.key,attributes:i.attributes,source:i.source.key,target:i.target.key,sourceAttributes:i.source.attributes,targetAttributes:i.target.attributes,undirected:i.undirected}}}}}function rg(r,e,t,n){const i=e[t];if(!i)return;const o=i.source,s=i.target;if(n(i.key,i.attributes,o.key,s.key,o.attributes,s.attributes,i.undirected)&&r)return i.key}function ng(r,e,t,n){let i=e[t];if(!i)return;let o=!1;do{if(o=n(i.key,i.attributes,i.source.key,i.target.key,i.source.attributes,i.target.attributes,i.undirected),r&&o)return i.key;i=i.next}while(i!==void 0)}function Bi(r,e){let t=r[e];if(t.next!==void 0)return{[Symbol.iterator](){return this},next(){if(!t)return{done:!0};const i={edge:t.key,attributes:t.attributes,source:t.source.key,target:t.target.key,sourceAttributes:t.source.attributes,targetAttributes:t.target.attributes,undirected:t.undirected};return t=t.next,{done:!1,value:i}}};let n=!1;return{[Symbol.iterator](){return this},next(){return n===!0?{done:!0}:(n=!0,{done:!1,value:{edge:t.key,attributes:t.attributes,source:t.source.key,target:t.target.key,sourceAttributes:t.source.attributes,targetAttributes:t.target.attributes,undirected:t.undirected}})}}}function ig(r,e){if(r.size===0)return[];if(e==="mixed"||e===r.type)return Array.from(r._edges.keys());const t=e==="undirected"?r.undirectedSize:r.directedSize,n=new Array(t),i=e==="undirected",o=r._edges.values();let s=0,a,c;for(;a=o.next(),a.done!==!0;)c=a.value,c.undirected===i&&(n[s++]=c.key);return n}function Ic(r,e,t,n){if(e.size===0)return;const i=t!=="mixed"&&t!==e.type,o=t==="undirected";let s,a,c=!1;const l=e._edges.values();for(;s=l.next(),s.done!==!0;){if(a=s.value,i&&a.undirected!==o)continue;const{key:d,attributes:f,source:h,target:g}=a;if(c=n(d,f,h.key,g.key,h.attributes,g.attributes,a.undirected),r&&c)return d}}function og(r,e){if(r.size===0)return jr();const t=e!=="mixed"&&e!==r.type,n=e==="undirected",i=r._edges.values();return{[Symbol.iterator](){return this},next(){let o,s;for(;;){if(o=i.next(),o.done)return o;if(s=o.value,!(t&&s.undirected!==n))break}return{value:{edge:s.key,attributes:s.attributes,source:s.source.key,target:s.target.key,sourceAttributes:s.source.attributes,targetAttributes:s.target.attributes,undirected:s.undirected},done:!1}}}}function Lo(r,e,t,n,i,o){const s=e?tg:eg;let a;if(t!=="undirected"&&(n!=="out"&&(a=s(r,i.in,o),r&&a)||n!=="in"&&(a=s(r,i.out,o,n?void 0:i.key),r&&a))||t!=="directed"&&(a=s(r,i.undirected,o),r&&a))return a}function sg(r,e,t,n){const i=[];return Lo(!1,r,e,t,n,function(o){i.push(o)}),i}function ag(r,e,t){let n=jr();return r!=="undirected"&&(e!=="out"&&typeof t.in<"u"&&(n=tr(n,ji(t.in))),e!=="in"&&typeof t.out<"u"&&(n=tr(n,ji(t.out,e?void 0:t.key)))),r!=="directed"&&typeof t.undirected<"u"&&(n=tr(n,ji(t.undirected))),n}function To(r,e,t,n,i,o,s){const a=t?ng:rg;let c;if(e!=="undirected"&&(typeof i.in<"u"&&n!=="out"&&(c=a(r,i.in,o,s),r&&c)||typeof i.out<"u"&&n!=="in"&&(n||i.key!==o)&&(c=a(r,i.out,o,s),r&&c))||e!=="directed"&&typeof i.undirected<"u"&&(c=a(r,i.undirected,o,s),r&&c))return c}function cg(r,e,t,n,i){const o=[];return To(!1,r,e,t,n,i,function(s){o.push(s)}),o}function lg(r,e,t,n){let i=jr();return r!=="undirected"&&(typeof t.in<"u"&&e!=="out"&&n in t.in&&(i=tr(i,Bi(t.in,n))),typeof t.out<"u"&&e!=="in"&&n in t.out&&(e||t.key!==n)&&(i=tr(i,Bi(t.out,n)))),r!=="directed"&&typeof t.undirected<"u"&&n in t.undirected&&(i=tr(i,Bi(t.undirected,n))),i}function ug(r,e){const{name:t,type:n,direction:i}=e;r.prototype[t]=function(o,s){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return[];if(!arguments.length)return ig(this,n);if(arguments.length===1){o=""+o;const a=this._nodes.get(o);if(typeof a>"u")throw new B(`Graph.${t}: could not find the "${o}" node in the graph.`);return sg(this.multi,n==="mixed"?this.type:n,i,a)}if(arguments.length===2){o=""+o,s=""+s;const a=this._nodes.get(o);if(!a)throw new B(`Graph.${t}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(s))throw new B(`Graph.${t}: could not find the "${s}" target node in the graph.`);return cg(n,this.multi,i,a,s)}throw new q(`Graph.${t}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function dg(r,e){const{name:t,type:n,direction:i}=e,o="forEach"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[o]=function(l,d,f){if(!(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)){if(arguments.length===1)return f=l,Ic(!1,this,n,f);if(arguments.length===2){l=""+l,f=d;const h=this._nodes.get(l);if(typeof h>"u")throw new B(`Graph.${o}: could not find the "${l}" node in the graph.`);return Lo(!1,this.multi,n==="mixed"?this.type:n,i,h,f)}if(arguments.length===3){l=""+l,d=""+d;const h=this._nodes.get(l);if(!h)throw new B(`Graph.${o}: could not find the "${l}" source node in the graph.`);if(!this._nodes.has(d))throw new B(`Graph.${o}: could not find the "${d}" target node in the graph.`);return To(!1,n,this.multi,i,h,d,f)}throw new q(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};const s="map"+t[0].toUpperCase()+t.slice(1);r.prototype[s]=function(){const l=Array.prototype.slice.call(arguments),d=l.pop();let f;if(l.length===0){let h=0;n!=="directed"&&(h+=this.undirectedSize),n!=="undirected"&&(h+=this.directedSize),f=new Array(h);let g=0;l.push((y,C,b,m,A,v,p)=>{f[g++]=d(y,C,b,m,A,v,p)})}else f=[],l.push((h,g,y,C,b,m,A)=>{f.push(d(h,g,y,C,b,m,A))});return this[o].apply(this,l),f};const a="filter"+t[0].toUpperCase()+t.slice(1);r.prototype[a]=function(){const l=Array.prototype.slice.call(arguments),d=l.pop(),f=[];return l.push((h,g,y,C,b,m,A)=>{d(h,g,y,C,b,m,A)&&f.push(h)}),this[o].apply(this,l),f};const c="reduce"+t[0].toUpperCase()+t.slice(1);r.prototype[c]=function(){let l=Array.prototype.slice.call(arguments);if(l.length<2||l.length>4)throw new q(`Graph.${c}: invalid number of arguments (expecting 2, 3 or 4 and got ${l.length}).`);if(typeof l[l.length-1]=="function"&&typeof l[l.length-2]!="function")throw new q(`Graph.${c}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let d,f;l.length===2?(d=l[0],f=l[1],l=[]):l.length===3?(d=l[1],f=l[2],l=[l[0]]):l.length===4&&(d=l[2],f=l[3],l=[l[0],l[1]]);let h=f;return l.push((g,y,C,b,m,A,v)=>{h=d(h,g,y,C,b,m,A,v)}),this[o].apply(this,l),h}}function fg(r,e){const{name:t,type:n,direction:i}=e,o="find"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[o]=function(c,l,d){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return!1;if(arguments.length===1)return d=c,Ic(!0,this,n,d);if(arguments.length===2){c=""+c,d=l;const f=this._nodes.get(c);if(typeof f>"u")throw new B(`Graph.${o}: could not find the "${c}" node in the graph.`);return Lo(!0,this.multi,n==="mixed"?this.type:n,i,f,d)}if(arguments.length===3){c=""+c,l=""+l;const f=this._nodes.get(c);if(!f)throw new B(`Graph.${o}: could not find the "${c}" source node in the graph.`);if(!this._nodes.has(l))throw new B(`Graph.${o}: could not find the "${l}" target node in the graph.`);return To(!0,n,this.multi,i,f,l,d)}throw new q(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};const s="some"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[s]=function(){const c=Array.prototype.slice.call(arguments),l=c.pop();return c.push((f,h,g,y,C,b,m)=>l(f,h,g,y,C,b,m)),!!this[o].apply(this,c)};const a="every"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[a]=function(){const c=Array.prototype.slice.call(arguments),l=c.pop();return c.push((f,h,g,y,C,b,m)=>!l(f,h,g,y,C,b,m)),!this[o].apply(this,c)}}function hg(r,e){const{name:t,type:n,direction:i}=e,o=t.slice(0,-1)+"Entries";r.prototype[o]=function(s,a){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return jr();if(!arguments.length)return og(this,n);if(arguments.length===1){s=""+s;const c=this._nodes.get(s);if(!c)throw new B(`Graph.${o}: could not find the "${s}" node in the graph.`);return ag(n,i,c)}if(arguments.length===2){s=""+s,a=""+a;const c=this._nodes.get(s);if(!c)throw new B(`Graph.${o}: could not find the "${s}" source node in the graph.`);if(!this._nodes.has(a))throw new B(`Graph.${o}: could not find the "${a}" target node in the graph.`);return lg(n,i,c,a)}throw new q(`Graph.${o}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function pg(r){Qp.forEach(e=>{ug(r,e),dg(r,e),fg(r,e),hg(r,e)})}const gg=[{name:"neighbors",type:"mixed"},{name:"inNeighbors",type:"directed",direction:"in"},{name:"outNeighbors",type:"directed",direction:"out"},{name:"inboundNeighbors",type:"mixed",direction:"in"},{name:"outboundNeighbors",type:"mixed",direction:"out"},{name:"directedNeighbors",type:"directed"},{name:"undirectedNeighbors",type:"undirected"}];function ci(){this.A=null,this.B=null}ci.prototype.wrap=function(r){this.A===null?this.A=r:this.B===null&&(this.B=r)};ci.prototype.has=function(r){return this.A!==null&&r in this.A||this.B!==null&&r in this.B};function Qr(r,e,t,n,i){for(const o in n){const s=n[o],a=s.source,c=s.target,l=a===t?c:a;if(e&&e.has(l.key))continue;const d=i(l.key,l.attributes);if(r&&d)return l.key}}function Go(r,e,t,n,i){if(e!=="mixed"){if(e==="undirected")return Qr(r,null,n,n.undirected,i);if(typeof t=="string")return Qr(r,null,n,n[t],i)}const o=new ci;let s;if(e!=="undirected"){if(t!=="out"){if(s=Qr(r,null,n,n.in,i),r&&s)return s;o.wrap(n.in)}if(t!=="in"){if(s=Qr(r,o,n,n.out,i),r&&s)return s;o.wrap(n.out)}}if(e!=="directed"&&(s=Qr(r,o,n,n.undirected,i),r&&s))return s}function mg(r,e,t){if(r!=="mixed"){if(r==="undirected")return Object.keys(t.undirected);if(typeof e=="string")return Object.keys(t[e])}const n=[];return Go(!1,r,e,t,function(i){n.push(i)}),n}function en(r,e,t){const n=Object.keys(t),i=n.length;let o=0;return{[Symbol.iterator](){return this},next(){let s=null;do{if(o>=i)return r&&r.wrap(t),{done:!0};const a=t[n[o++]],c=a.source,l=a.target;if(s=c===e?l:c,r&&r.has(s.key)){s=null;continue}}while(s===null);return{done:!1,value:{neighbor:s.key,attributes:s.attributes}}}}}function vg(r,e,t){if(r!=="mixed"){if(r==="undirected")return en(null,t,t.undirected);if(typeof e=="string")return en(null,t,t[e])}let n=jr();const i=new ci;return r!=="undirected"&&(e!=="out"&&(n=tr(n,en(i,t,t.in))),e!=="in"&&(n=tr(n,en(i,t,t.out)))),r!=="directed"&&(n=tr(n,en(i,t,t.undirected))),n}function yg(r,e){const{name:t,type:n,direction:i}=e;r.prototype[t]=function(o){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return[];o=""+o;const s=this._nodes.get(o);if(typeof s>"u")throw new B(`Graph.${t}: could not find the "${o}" node in the graph.`);return mg(n==="mixed"?this.type:n,i,s)}}function bg(r,e){const{name:t,type:n,direction:i}=e,o="forEach"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[o]=function(l,d){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return;l=""+l;const f=this._nodes.get(l);if(typeof f>"u")throw new B(`Graph.${o}: could not find the "${l}" node in the graph.`);Go(!1,n==="mixed"?this.type:n,i,f,d)};const s="map"+t[0].toUpperCase()+t.slice(1);r.prototype[s]=function(l,d){const f=[];return this[o](l,(h,g)=>{f.push(d(h,g))}),f};const a="filter"+t[0].toUpperCase()+t.slice(1);r.prototype[a]=function(l,d){const f=[];return this[o](l,(h,g)=>{d(h,g)&&f.push(h)}),f};const c="reduce"+t[0].toUpperCase()+t.slice(1);r.prototype[c]=function(l,d,f){if(arguments.length<3)throw new q(`Graph.${c}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let h=f;return this[o](l,(g,y)=>{h=d(h,g,y)}),h}}function wg(r,e){const{name:t,type:n,direction:i}=e,o=t[0].toUpperCase()+t.slice(1,-1),s="find"+o;r.prototype[s]=function(l,d){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return;l=""+l;const f=this._nodes.get(l);if(typeof f>"u")throw new B(`Graph.${s}: could not find the "${l}" node in the graph.`);return Go(!0,n==="mixed"?this.type:n,i,f,d)};const a="some"+o;r.prototype[a]=function(l,d){return!!this[s](l,d)};const c="every"+o;r.prototype[c]=function(l,d){return!this[s](l,(h,g)=>!d(h,g))}}function _g(r,e){const{name:t,type:n,direction:i}=e,o=t.slice(0,-1)+"Entries";r.prototype[o]=function(s){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return jr();s=""+s;const a=this._nodes.get(s);if(typeof a>"u")throw new B(`Graph.${o}: could not find the "${s}" node in the graph.`);return vg(n==="mixed"?this.type:n,i,a)}}function xg(r){gg.forEach(e=>{yg(r,e),bg(r,e),wg(r,e),_g(r,e)})}function Wn(r,e,t,n,i){const o=n._nodes.values(),s=n.type;let a,c,l,d,f,h;for(;a=o.next(),a.done!==!0;){let g=!1;if(c=a.value,s!=="undirected"){d=c.out;for(l in d){f=d[l];do h=f.target,g=!0,i(c.key,h.key,c.attributes,h.attributes,f.key,f.attributes,f.undirected),f=f.next;while(f)}}if(s!=="directed"){d=c.undirected;for(l in d)if(!(e&&c.key>l)){f=d[l];do h=f.target,h.key!==l&&(h=f.source),g=!0,i(c.key,h.key,c.attributes,h.attributes,f.key,f.attributes,f.undirected),f=f.next;while(f)}}t&&!g&&i(c.key,null,c.attributes,null,null,null,null)}}function kg(r,e){const t={key:r};return kc(e.attributes)||(t.attributes=ut({},e.attributes)),t}function Eg(r,e,t){const n={key:e,source:t.source.key,target:t.target.key};return kc(t.attributes)||(n.attributes=ut({},t.attributes)),r==="mixed"&&t.undirected&&(n.undirected=!0),n}function Sg(r){if(!mt(r))throw new q('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in r))throw new q("Graph.import: serialized node is missing its key.");if("attributes"in r&&(!mt(r.attributes)||r.attributes===null))throw new q("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function Cg(r){if(!mt(r))throw new q('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in r))throw new q("Graph.import: serialized edge is missing its source.");if(!("target"in r))throw new q("Graph.import: serialized edge is missing its target.");if("attributes"in r&&(!mt(r.attributes)||r.attributes===null))throw new q("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in r&&typeof r.undirected!="boolean")throw new q("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}const Ag=Dp(),$g=new Set(["directed","undirected","mixed"]),Vs=new Set(["domain","_events","_eventsCount","_maxListeners"]),Dg=[{name:r=>`${r}Edge`,generateKey:!0},{name:r=>`${r}DirectedEdge`,generateKey:!0,type:"directed"},{name:r=>`${r}UndirectedEdge`,generateKey:!0,type:"undirected"},{name:r=>`${r}EdgeWithKey`},{name:r=>`${r}DirectedEdgeWithKey`,type:"directed"},{name:r=>`${r}UndirectedEdgeWithKey`,type:"undirected"}],Ig={allowSelfLoops:!0,multi:!1,type:"mixed"};function Lg(r,e,t){if(t&&!mt(t))throw new q(`Graph.addNode: invalid attributes. Expecting an object but got "${t}"`);if(e=""+e,t=t||{},r._nodes.has(e))throw new ue(`Graph.addNode: the "${e}" node already exist in the graph.`);const n=new r.NodeDataClass(e,t);return r._nodes.set(e,n),r.emit("nodeAdded",{key:e,attributes:t}),n}function Ks(r,e,t){const n=new r.NodeDataClass(e,t);return r._nodes.set(e,n),r.emit("nodeAdded",{key:e,attributes:t}),n}function Lc(r,e,t,n,i,o,s,a){if(!n&&r.type==="undirected")throw new ue(`Graph.${e}: you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.`);if(n&&r.type==="directed")throw new ue(`Graph.${e}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(a&&!mt(a))throw new q(`Graph.${e}: invalid attributes. Expecting an object but got "${a}"`);if(o=""+o,s=""+s,a=a||{},!r.allowSelfLoops&&o===s)throw new ue(`Graph.${e}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);const c=r._nodes.get(o),l=r._nodes.get(s);if(!c)throw new B(`Graph.${e}: source node "${o}" not found.`);if(!l)throw new B(`Graph.${e}: target node "${s}" not found.`);const d={key:null,undirected:n,source:o,target:s,attributes:a};if(t)i=r._edgeKeyGenerator();else if(i=""+i,r._edges.has(i))throw new ue(`Graph.${e}: the "${i}" edge already exists in the graph.`);if(!r.multi&&(n?typeof c.undirected[s]<"u":typeof c.out[s]<"u"))throw new ue(`Graph.${e}: an edge linking "${o}" to "${s}" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option.`);const f=new Br(n,i,c,l,a);r._edges.set(i,f);const h=o===s;return n?(c.undirectedDegree++,l.undirectedDegree++,h&&(c.undirectedLoops++,r._undirectedSelfLoopCount++)):(c.outDegree++,l.inDegree++,h&&(c.directedLoops++,r._directedSelfLoopCount++)),r.multi?f.attachMulti():f.attach(),n?r._undirectedSize++:r._directedSize++,d.key=i,r.emit("edgeAdded",d),i}function Tg(r,e,t,n,i,o,s,a,c){if(!n&&r.type==="undirected")throw new ue(`Graph.${e}: you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead.`);if(n&&r.type==="directed")throw new ue(`Graph.${e}: you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead.`);if(a){if(c){if(typeof a!="function")throw new q(`Graph.${e}: invalid updater function. Expecting a function but got "${a}"`)}else if(!mt(a))throw new q(`Graph.${e}: invalid attributes. Expecting an object but got "${a}"`)}o=""+o,s=""+s;let l;if(c&&(l=a,a=void 0),!r.allowSelfLoops&&o===s)throw new ue(`Graph.${e}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let d=r._nodes.get(o),f=r._nodes.get(s),h,g;if(!t&&(h=r._edges.get(i),h)){if((h.source.key!==o||h.target.key!==s)&&(!n||h.source.key!==s||h.target.key!==o))throw new ue(`Graph.${e}: inconsistency detected when attempting to merge the "${i}" edge with "${o}" source & "${s}" target vs. ("${h.source.key}", "${h.target.key}").`);g=h}if(!g&&!r.multi&&d&&(g=n?d.undirected[s]:d.out[s]),g){const A=[g.key,!1,!1,!1];if(c?!l:!a)return A;if(c){const v=g.attributes;g.attributes=l(v),r.emit("edgeAttributesUpdated",{type:"replace",key:g.key,attributes:g.attributes})}else ut(g.attributes,a),r.emit("edgeAttributesUpdated",{type:"merge",key:g.key,attributes:g.attributes,data:a});return A}a=a||{},c&&l&&(a=l(a));const y={key:null,undirected:n,source:o,target:s,attributes:a};if(t)i=r._edgeKeyGenerator();else if(i=""+i,r._edges.has(i))throw new ue(`Graph.${e}: the "${i}" edge already exists in the graph.`);let C=!1,b=!1;d||(d=Ks(r,o,{}),C=!0,o===s&&(f=d,b=!0)),f||(f=Ks(r,s,{}),b=!0),h=new Br(n,i,d,f,a),r._edges.set(i,h);const m=o===s;return n?(d.undirectedDegree++,f.undirectedDegree++,m&&(d.undirectedLoops++,r._undirectedSelfLoopCount++)):(d.outDegree++,f.inDegree++,m&&(d.directedLoops++,r._directedSelfLoopCount++)),r.multi?h.attachMulti():h.attach(),n?r._undirectedSize++:r._directedSize++,y.key=i,r.emit("edgeAdded",y),[i,!0,C,b]}function zr(r,e){r._edges.delete(e.key);const{source:t,target:n,attributes:i}=e,o=e.undirected,s=t===n;o?(t.undirectedDegree--,n.undirectedDegree--,s&&(t.undirectedLoops--,r._undirectedSelfLoopCount--)):(t.outDegree--,n.inDegree--,s&&(t.directedLoops--,r._directedSelfLoopCount--)),r.multi?e.detachMulti():e.detach(),o?r._undirectedSize--:r._directedSize--,r.emit("edgeDropped",{key:e.key,attributes:i,source:t.key,target:n.key,undirected:o})}class qe extends Ap.EventEmitter{constructor(e){if(super(),e=ut({},Ig,e),typeof e.multi!="boolean")throw new q(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${e.multi}".`);if(!$g.has(e.type))throw new q(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${e.type}".`);if(typeof e.allowSelfLoops!="boolean")throw new q(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${e.allowSelfLoops}".`);const t=e.type==="mixed"?Ec:e.type==="directed"?Sc:Cc;zt(this,"NodeDataClass",t);const n="geid_"+Ag()+"_";let i=0;const o=()=>{let s;do s=n+i++;while(this._edges.has(s));return s};zt(this,"_attributes",{}),zt(this,"_nodes",new Map),zt(this,"_edges",new Map),zt(this,"_directedSize",0),zt(this,"_undirectedSize",0),zt(this,"_directedSelfLoopCount",0),zt(this,"_undirectedSelfLoopCount",0),zt(this,"_edgeKeyGenerator",o),zt(this,"_options",e),Vs.forEach(s=>zt(this,s,this[s])),Wt(this,"order",()=>this._nodes.size),Wt(this,"size",()=>this._edges.size),Wt(this,"directedSize",()=>this._directedSize),Wt(this,"undirectedSize",()=>this._undirectedSize),Wt(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),Wt(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),Wt(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),Wt(this,"multi",this._options.multi),Wt(this,"type",this._options.type),Wt(this,"allowSelfLoops",this._options.allowSelfLoops),Wt(this,"implementation",()=>"graphology")}_resetInstanceCounters(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0}hasNode(e){return this._nodes.has(""+e)}hasDirectedEdge(e,t){if(this.type==="undirected")return!1;if(arguments.length===1){const n=""+e,i=this._edges.get(n);return!!i&&!i.undirected}else if(arguments.length===2){e=""+e,t=""+t;const n=this._nodes.get(e);return n?n.out.hasOwnProperty(t):!1}throw new q(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasUndirectedEdge(e,t){if(this.type==="directed")return!1;if(arguments.length===1){const n=""+e,i=this._edges.get(n);return!!i&&i.undirected}else if(arguments.length===2){e=""+e,t=""+t;const n=this._nodes.get(e);return n?n.undirected.hasOwnProperty(t):!1}throw new q(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasEdge(e,t){if(arguments.length===1){const n=""+e;return this._edges.has(n)}else if(arguments.length===2){e=""+e,t=""+t;const n=this._nodes.get(e);return n?typeof n.out<"u"&&n.out.hasOwnProperty(t)||typeof n.undirected<"u"&&n.undirected.hasOwnProperty(t):!1}throw new q(`Graph.hasEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}directedEdge(e,t){if(this.type==="undirected")return;if(e=""+e,t=""+t,this.multi)throw new ue("Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.");const n=this._nodes.get(e);if(!n)throw new B(`Graph.directedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new B(`Graph.directedEdge: could not find the "${t}" target node in the graph.`);const i=n.out&&n.out[t]||void 0;if(i)return i.key}undirectedEdge(e,t){if(this.type==="directed")return;if(e=""+e,t=""+t,this.multi)throw new ue("Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.");const n=this._nodes.get(e);if(!n)throw new B(`Graph.undirectedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new B(`Graph.undirectedEdge: could not find the "${t}" target node in the graph.`);const i=n.undirected&&n.undirected[t]||void 0;if(i)return i.key}edge(e,t){if(this.multi)throw new ue("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new B(`Graph.edge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new B(`Graph.edge: could not find the "${t}" target node in the graph.`);const i=n.out&&n.out[t]||n.undirected&&n.undirected[t]||void 0;if(i)return i.key}areDirectedNeighbors(e,t){e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new B(`Graph.areDirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:t in n.in||t in n.out}areOutNeighbors(e,t){e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new B(`Graph.areOutNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:t in n.out}areInNeighbors(e,t){e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new B(`Graph.areInNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:t in n.in}areUndirectedNeighbors(e,t){e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new B(`Graph.areUndirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type==="directed"?!1:t in n.undirected}areNeighbors(e,t){e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new B(`Graph.areNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&(t in n.in||t in n.out)||this.type!=="directed"&&t in n.undirected}areInboundNeighbors(e,t){e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new B(`Graph.areInboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&t in n.in||this.type!=="directed"&&t in n.undirected}areOutboundNeighbors(e,t){e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new B(`Graph.areOutboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&t in n.out||this.type!=="directed"&&t in n.undirected}inDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new B(`Graph.inDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.inDegree}outDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new B(`Graph.outDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.outDegree}directedDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new B(`Graph.directedDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.inDegree+t.outDegree}undirectedDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new B(`Graph.undirectedDegree: could not find the "${e}" node in the graph.`);return this.type==="directed"?0:t.undirectedDegree}inboundDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new B(`Graph.inboundDegree: could not find the "${e}" node in the graph.`);let n=0;return this.type!=="directed"&&(n+=t.undirectedDegree),this.type!=="undirected"&&(n+=t.inDegree),n}outboundDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new B(`Graph.outboundDegree: could not find the "${e}" node in the graph.`);let n=0;return this.type!=="directed"&&(n+=t.undirectedDegree),this.type!=="undirected"&&(n+=t.outDegree),n}degree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new B(`Graph.degree: could not find the "${e}" node in the graph.`);let n=0;return this.type!=="directed"&&(n+=t.undirectedDegree),this.type!=="undirected"&&(n+=t.inDegree+t.outDegree),n}inDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new B(`Graph.inDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.inDegree-t.directedLoops}outDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new B(`Graph.outDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.outDegree-t.directedLoops}directedDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new B(`Graph.directedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.inDegree+t.outDegree-t.directedLoops*2}undirectedDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new B(`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="directed"?0:t.undirectedDegree-t.undirectedLoops*2}inboundDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new B(`Graph.inboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let n=0,i=0;return this.type!=="directed"&&(n+=t.undirectedDegree,i+=t.undirectedLoops*2),this.type!=="undirected"&&(n+=t.inDegree,i+=t.directedLoops),n-i}outboundDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new B(`Graph.outboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let n=0,i=0;return this.type!=="directed"&&(n+=t.undirectedDegree,i+=t.undirectedLoops*2),this.type!=="undirected"&&(n+=t.outDegree,i+=t.directedLoops),n-i}degreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new B(`Graph.degreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let n=0,i=0;return this.type!=="directed"&&(n+=t.undirectedDegree,i+=t.undirectedLoops*2),this.type!=="undirected"&&(n+=t.inDegree+t.outDegree,i+=t.directedLoops*2),n-i}source(e){e=""+e;const t=this._edges.get(e);if(!t)throw new B(`Graph.source: could not find the "${e}" edge in the graph.`);return t.source.key}target(e){e=""+e;const t=this._edges.get(e);if(!t)throw new B(`Graph.target: could not find the "${e}" edge in the graph.`);return t.target.key}extremities(e){e=""+e;const t=this._edges.get(e);if(!t)throw new B(`Graph.extremities: could not find the "${e}" edge in the graph.`);return[t.source.key,t.target.key]}opposite(e,t){e=""+e,t=""+t;const n=this._edges.get(t);if(!n)throw new B(`Graph.opposite: could not find the "${t}" edge in the graph.`);const i=n.source.key,o=n.target.key;if(e===i)return o;if(e===o)return i;throw new B(`Graph.opposite: the "${e}" node is not attached to the "${t}" edge (${i}, ${o}).`)}hasExtremity(e,t){e=""+e,t=""+t;const n=this._edges.get(e);if(!n)throw new B(`Graph.hasExtremity: could not find the "${e}" edge in the graph.`);return n.source.key===t||n.target.key===t}isUndirected(e){e=""+e;const t=this._edges.get(e);if(!t)throw new B(`Graph.isUndirected: could not find the "${e}" edge in the graph.`);return t.undirected}isDirected(e){e=""+e;const t=this._edges.get(e);if(!t)throw new B(`Graph.isDirected: could not find the "${e}" edge in the graph.`);return!t.undirected}isSelfLoop(e){e=""+e;const t=this._edges.get(e);if(!t)throw new B(`Graph.isSelfLoop: could not find the "${e}" edge in the graph.`);return t.source===t.target}addNode(e,t){return Lg(this,e,t).key}mergeNode(e,t){if(t&&!mt(t))throw new q(`Graph.mergeNode: invalid attributes. Expecting an object but got "${t}"`);e=""+e,t=t||{};let n=this._nodes.get(e);return n?(t&&(ut(n.attributes,t),this.emit("nodeAttributesUpdated",{type:"merge",key:e,attributes:n.attributes,data:t})),[e,!1]):(n=new this.NodeDataClass(e,t),this._nodes.set(e,n),this.emit("nodeAdded",{key:e,attributes:t}),[e,!0])}updateNode(e,t){if(t&&typeof t!="function")throw new q(`Graph.updateNode: invalid updater function. Expecting a function but got "${t}"`);e=""+e;let n=this._nodes.get(e);if(n){if(t){const o=n.attributes;n.attributes=t(o),this.emit("nodeAttributesUpdated",{type:"replace",key:e,attributes:n.attributes})}return[e,!1]}const i=t?t({}):{};return n=new this.NodeDataClass(e,i),this._nodes.set(e,n),this.emit("nodeAdded",{key:e,attributes:i}),[e,!0]}dropNode(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new B(`Graph.dropNode: could not find the "${e}" node in the graph.`);let n;if(this.type!=="undirected"){for(const i in t.out){n=t.out[i];do zr(this,n),n=n.next;while(n)}for(const i in t.in){n=t.in[i];do zr(this,n),n=n.next;while(n)}}if(this.type!=="directed")for(const i in t.undirected){n=t.undirected[i];do zr(this,n),n=n.next;while(n)}this._nodes.delete(e),this.emit("nodeDropped",{key:e,attributes:t.attributes})}dropEdge(e){let t;if(arguments.length>1){const n=""+arguments[0],i=""+arguments[1];if(t=Nt(this,n,i,this.type),!t)throw new B(`Graph.dropEdge: could not find the "${n}" -> "${i}" edge in the graph.`)}else if(e=""+e,t=this._edges.get(e),!t)throw new B(`Graph.dropEdge: could not find the "${e}" edge in the graph.`);return zr(this,t),this}dropDirectedEdge(e,t){if(arguments.length<2)throw new ue("Graph.dropDirectedEdge: it does not make sense to try and drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new ue("Graph.dropDirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");e=""+e,t=""+t;const n=Nt(this,e,t,"directed");if(!n)throw new B(`Graph.dropDirectedEdge: could not find a "${e}" -> "${t}" edge in the graph.`);return zr(this,n),this}dropUndirectedEdge(e,t){if(arguments.length<2)throw new ue("Graph.dropUndirectedEdge: it does not make sense to drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new ue("Graph.dropUndirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");const n=Nt(this,e,t,"undirected");if(!n)throw new B(`Graph.dropUndirectedEdge: could not find a "${e}" -> "${t}" edge in the graph.`);return zr(this,n),this}clear(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")}clearEdges(){const e=this._nodes.values();let t;for(;t=e.next(),t.done!==!0;)t.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit("edgesCleared")}getAttribute(e){return this._attributes[e]}getAttributes(){return this._attributes}hasAttribute(e){return this._attributes.hasOwnProperty(e)}setAttribute(e,t){return this._attributes[e]=t,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:e}),this}updateAttribute(e,t){if(typeof t!="function")throw new q("Graph.updateAttribute: updater should be a function.");const n=this._attributes[e];return this._attributes[e]=t(n),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:e}),this}removeAttribute(e){return delete this._attributes[e],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:e}),this}replaceAttributes(e){if(!mt(e))throw new q("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=e,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this}mergeAttributes(e){if(!mt(e))throw new q("Graph.mergeAttributes: provided attributes are not a plain object.");return ut(this._attributes,e),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:e}),this}updateAttributes(e){if(typeof e!="function")throw new q("Graph.updateAttributes: provided updater is not a function.");return this._attributes=e(this._attributes),this.emit("attributesUpdated",{type:"update",attributes:this._attributes}),this}updateEachNodeAttributes(e,t){if(typeof e!="function")throw new q("Graph.updateEachNodeAttributes: expecting an updater function.");if(t&&!Fs(t))throw new q("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const n=this._nodes.values();let i,o;for(;i=n.next(),i.done!==!0;)o=i.value,o.attributes=e(o.key,o.attributes);this.emit("eachNodeAttributesUpdated",{hints:t||null})}updateEachEdgeAttributes(e,t){if(typeof e!="function")throw new q("Graph.updateEachEdgeAttributes: expecting an updater function.");if(t&&!Fs(t))throw new q("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const n=this._edges.values();let i,o,s,a;for(;i=n.next(),i.done!==!0;)o=i.value,s=o.source,a=o.target,o.attributes=e(o.key,o.attributes,s.key,a.key,s.attributes,a.attributes,o.undirected);this.emit("eachEdgeAttributesUpdated",{hints:t||null})}forEachAdjacencyEntry(e){if(typeof e!="function")throw new q("Graph.forEachAdjacencyEntry: expecting a callback.");Wn(!1,!1,!1,this,e)}forEachAdjacencyEntryWithOrphans(e){if(typeof e!="function")throw new q("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");Wn(!1,!1,!0,this,e)}forEachAssymetricAdjacencyEntry(e){if(typeof e!="function")throw new q("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");Wn(!1,!0,!1,this,e)}forEachAssymetricAdjacencyEntryWithOrphans(e){if(typeof e!="function")throw new q("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");Wn(!1,!0,!0,this,e)}nodes(){return Array.from(this._nodes.keys())}forEachNode(e){if(typeof e!="function")throw new q("Graph.forEachNode: expecting a callback.");const t=this._nodes.values();let n,i;for(;n=t.next(),n.done!==!0;)i=n.value,e(i.key,i.attributes)}findNode(e){if(typeof e!="function")throw new q("Graph.findNode: expecting a callback.");const t=this._nodes.values();let n,i;for(;n=t.next(),n.done!==!0;)if(i=n.value,e(i.key,i.attributes))return i.key}mapNodes(e){if(typeof e!="function")throw new q("Graph.mapNode: expecting a callback.");const t=this._nodes.values();let n,i;const o=new Array(this.order);let s=0;for(;n=t.next(),n.done!==!0;)i=n.value,o[s++]=e(i.key,i.attributes);return o}someNode(e){if(typeof e!="function")throw new q("Graph.someNode: expecting a callback.");const t=this._nodes.values();let n,i;for(;n=t.next(),n.done!==!0;)if(i=n.value,e(i.key,i.attributes))return!0;return!1}everyNode(e){if(typeof e!="function")throw new q("Graph.everyNode: expecting a callback.");const t=this._nodes.values();let n,i;for(;n=t.next(),n.done!==!0;)if(i=n.value,!e(i.key,i.attributes))return!1;return!0}filterNodes(e){if(typeof e!="function")throw new q("Graph.filterNodes: expecting a callback.");const t=this._nodes.values();let n,i;const o=[];for(;n=t.next(),n.done!==!0;)i=n.value,e(i.key,i.attributes)&&o.push(i.key);return o}reduceNodes(e,t){if(typeof e!="function")throw new q("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new q("Graph.reduceNodes: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.");let n=t;const i=this._nodes.values();let o,s;for(;o=i.next(),o.done!==!0;)s=o.value,n=e(n,s.key,s.attributes);return n}nodeEntries(){const e=this._nodes.values();return{[Symbol.iterator](){return this},next(){const t=e.next();if(t.done)return t;const n=t.value;return{value:{node:n.key,attributes:n.attributes},done:!1}}}}export(){const e=new Array(this._nodes.size);let t=0;this._nodes.forEach((i,o)=>{e[t++]=kg(o,i)});const n=new Array(this._edges.size);return t=0,this._edges.forEach((i,o)=>{n[t++]=Eg(this.type,o,i)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:e,edges:n}}import(e,t=!1){if(e instanceof qe)return e.forEachNode((c,l)=>{t?this.mergeNode(c,l):this.addNode(c,l)}),e.forEachEdge((c,l,d,f,h,g,y)=>{t?y?this.mergeUndirectedEdgeWithKey(c,d,f,l):this.mergeDirectedEdgeWithKey(c,d,f,l):y?this.addUndirectedEdgeWithKey(c,d,f,l):this.addDirectedEdgeWithKey(c,d,f,l)}),this;if(!mt(e))throw new q("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(e.attributes){if(!mt(e.attributes))throw new q("Graph.import: invalid attributes. Expecting a plain object.");t?this.mergeAttributes(e.attributes):this.replaceAttributes(e.attributes)}let n,i,o,s,a;if(e.nodes){if(o=e.nodes,!Array.isArray(o))throw new q("Graph.import: invalid nodes. Expecting an array.");for(n=0,i=o.length;n<i;n++){s=o[n],Sg(s);const{key:c,attributes:l}=s;t?this.mergeNode(c,l):this.addNode(c,l)}}if(e.edges){let c=!1;if(this.type==="undirected"&&(c=!0),o=e.edges,!Array.isArray(o))throw new q("Graph.import: invalid edges. Expecting an array.");for(n=0,i=o.length;n<i;n++){a=o[n],Cg(a);const{source:l,target:d,attributes:f,undirected:h=c}=a;let g;"key"in a?(g=t?h?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:h?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,g.call(this,a.key,l,d,f)):(g=t?h?this.mergeUndirectedEdge:this.mergeDirectedEdge:h?this.addUndirectedEdge:this.addDirectedEdge,g.call(this,l,d,f))}}return this}nullCopy(e){const t=new qe(ut({},this._options,e));return t.replaceAttributes(ut({},this.getAttributes())),t}emptyCopy(e){const t=this.nullCopy(e);return this._nodes.forEach((n,i)=>{const o=ut({},n.attributes);n=new t.NodeDataClass(i,o),t._nodes.set(i,n)}),t}copy(e){if(e=e||{},typeof e.type=="string"&&e.type!==this.type&&e.type!=="mixed")throw new ue(`Graph.copy: cannot create an incompatible copy from "${this.type}" type to "${e.type}" because this would mean losing information about the current graph.`);if(typeof e.multi=="boolean"&&e.multi!==this.multi&&e.multi!==!0)throw new ue("Graph.copy: cannot create an incompatible copy by downgrading a multi graph to a simple one because this would mean losing information about the current graph.");if(typeof e.allowSelfLoops=="boolean"&&e.allowSelfLoops!==this.allowSelfLoops&&e.allowSelfLoops!==!0)throw new ue("Graph.copy: cannot create an incompatible copy from a graph allowing self loops to one that does not because this would mean losing information about the current graph.");const t=this.emptyCopy(e),n=this._edges.values();let i,o;for(;i=n.next(),i.done!==!0;)o=i.value,Lc(t,"copy",!1,o.undirected,o.key,o.source.key,o.target.key,ut({},o.attributes));return t}toJSON(){return this.export()}toString(){return"[object Graph]"}inspect(){const e={};this._nodes.forEach((o,s)=>{e[s]=o.attributes});const t={},n={};this._edges.forEach((o,s)=>{const a=o.undirected?"--":"->";let c="",l=o.source.key,d=o.target.key,f;o.undirected&&l>d&&(f=l,l=d,d=f);const h=`(${l})${a}(${d})`;s.startsWith("geid_")?this.multi&&(typeof n[h]>"u"?n[h]=0:n[h]++,c+=`${n[h]}. `):c+=`[${s}]: `,c+=h,t[c]=o.attributes});const i={};for(const o in this)this.hasOwnProperty(o)&&!Vs.has(o)&&typeof this[o]!="function"&&typeof o!="symbol"&&(i[o]=this[o]);return i.attributes=this._attributes,i.nodes=e,i.edges=t,zt(i,"constructor",this.constructor),i}}typeof Symbol<"u"&&(qe.prototype[Symbol.for("nodejs.util.inspect.custom")]=qe.prototype.inspect);Dg.forEach(r=>{["add","merge","update"].forEach(e=>{const t=r.name(e),n=e==="add"?Lc:Tg;r.generateKey?qe.prototype[t]=function(i,o,s){return n(this,t,!0,(r.type||this.type)==="undirected",null,i,o,s,e==="update")}:qe.prototype[t]=function(i,o,s,a){return n(this,t,!1,(r.type||this.type)==="undirected",i,o,s,a,e==="update")}})});Wp(qe);Zp(qe);pg(qe);xg(qe);class Tc extends qe{constructor(e){const t=ut({type:"directed"},e);if("multi"in t&&t.multi!==!1)throw new q("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(t.type!=="directed")throw new q('DirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class Gc extends qe{constructor(e){const t=ut({type:"undirected"},e);if("multi"in t&&t.multi!==!1)throw new q("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(t.type!=="undirected")throw new q('UndirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class Rc extends qe{constructor(e){const t=ut({multi:!0},e);if("multi"in t&&t.multi!==!0)throw new q("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(t)}}class Oc extends qe{constructor(e){const t=ut({type:"directed",multi:!0},e);if("multi"in t&&t.multi!==!0)throw new q("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(t.type!=="directed")throw new q('MultiDirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class zc extends qe{constructor(e){const t=ut({type:"undirected",multi:!0},e);if("multi"in t&&t.multi!==!0)throw new q("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(t.type!=="undirected")throw new q('MultiUndirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}function Fr(r){r.from=function(e,t){const n=ut({},e.options,t),i=new r(n);return i.import(e),i}}Fr(qe);Fr(Tc);Fr(Gc);Fr(Rc);Fr(Oc);Fr(zc);qe.Graph=qe;qe.DirectedGraph=Tc;qe.UndirectedGraph=Gc;qe.MultiGraph=Rc;qe.MultiDirectedGraph=Oc;qe.MultiUndirectedGraph=zc;qe.InvalidArgumentsGraphError=q;qe.NotFoundGraphError=B;qe.UsageGraphError=ue;var Fi,Hs;function Ro(){if(Hs)return Fi;Hs=1;function r(t){return!t||typeof t!="object"||typeof t=="function"||Array.isArray(t)||t instanceof Set||t instanceof Map||t instanceof RegExp||t instanceof Date}function e(t,n){t=t||{};var i={};for(var o in n){var s=t[o],a=n[o];if(!r(a)){i[o]=e(s,a);continue}s===void 0?i[o]=a:i[o]=s}return i}return Fi=e,Fi}var Vi,qs;function li(){return qs||(qs=1,Vi=function(e){return e!==null&&typeof e=="object"&&typeof e.addUndirectedEdgeWithKey=="function"&&typeof e.dropNode=="function"&&typeof e.multi=="boolean"}),Vi}var Ki,Ys;function Mc(){if(Ys)return Ki;Ys=1;var r=li();return Ki=function(t){if(!r(t))throw new Error("graphology-utils/infer-type: expecting a valid graphology instance.");var n=t.type;return n!=="mixed"?n:t.directedSize===0&&t.undirectedSize===0||t.directedSize>0&&t.undirectedSize>0?"mixed":t.directedSize>0?"directed":"undirected"},Ki}var Hi,Xs;function Nc(){if(Xs)return Hi;Xs=1;function r(e){if(typeof e!="function")throw new Error("obliterator/iterator: expecting a function!");this.next=e}return typeof Symbol<"u"&&(r.prototype[Symbol.iterator]=function(){return this}),r.of=function(){var e=arguments,t=e.length,n=0;return new r(function(){return n>=t?{done:!0}:{done:!1,value:e[n++]}})},r.empty=function(){var e=new r(function(){return{done:!0}});return e},r.fromSequence=function(e){var t=0,n=e.length;return new r(function(){return t>=n?{done:!0}:{done:!1,value:e[t++]}})},r.is=function(e){return e instanceof r?!0:typeof e=="object"&&e!==null&&typeof e.next=="function"},Hi=r,Hi}var qi={},Js;function Oo(){return Js||(Js=1,(function(r){var e=Math.pow(2,8)-1,t=Math.pow(2,16)-1,n=Math.pow(2,32)-1,i=Math.pow(2,7)-1,o=Math.pow(2,15)-1,s=Math.pow(2,31)-1;r.getPointerArray=function(c){var l=c-1;if(l<=e)return Uint8Array;if(l<=t)return Uint16Array;if(l<=n)return Uint32Array;throw new Error("mnemonist: Pointer Array of size > 4294967295 is not supported.")},r.getSignedPointerArray=function(c){var l=c-1;return l<=i?Int8Array:l<=o?Int16Array:l<=s?Int32Array:Float64Array},r.getNumberType=function(c){return c===(c|0)?Math.sign(c)===-1?c<=127&&c>=-128?Int8Array:c<=32767&&c>=-32768?Int16Array:Int32Array:c<=255?Uint8Array:c<=65535?Uint16Array:Uint32Array:Float64Array};var a={Uint8Array:1,Int8Array:2,Uint16Array:3,Int16Array:4,Uint32Array:5,Int32Array:6,Float32Array:7,Float64Array:8};r.getMinimalRepresentation=function(c,l){var d=null,f=0,h,g,y,C,b;for(C=0,b=c.length;C<b;C++)y=l?l(c[C]):c[C],g=r.getNumberType(y),h=a[g.name],h>f&&(f=h,d=g);return d},r.isTypedArray=function(c){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView(c)},r.concat=function(){var c=0,l,d,f;for(l=0,f=arguments.length;l<f;l++)c+=arguments[l].length;var h=new arguments[0].constructor(c);for(l=0,d=0;l<f;l++)h.set(arguments[l],d),d+=arguments[l].length;return h},r.indices=function(c){for(var l=r.getPointerArray(c),d=new l(c),f=0;f<c;f++)d[f]=f;return d}})(qi)),qi}var Yi,Zs;function zo(){if(Zs)return Yi;Zs=1;var r=Nc(),e=Oo().getPointerArray;function t(n,i){arguments.length<2&&(i=n,n=Array);var o=e(i);this.size=0,this.length=i,this.dense=new o(i),this.sparse=new o(i),this.vals=new n(i)}return t.prototype.clear=function(){this.size=0},t.prototype.has=function(n){var i=this.sparse[n];return i<this.size&&this.dense[i]===n},t.prototype.get=function(n){var i=this.sparse[n];if(i<this.size&&this.dense[i]===n)return this.vals[i]},t.prototype.set=function(n,i){var o=this.sparse[n];return o<this.size&&this.dense[o]===n?(this.vals[o]=i,this):(this.dense[this.size]=n,this.sparse[n]=this.size,this.vals[this.size]=i,this.size++,this)},t.prototype.delete=function(n){var i=this.sparse[n];return i>=this.size||this.dense[i]!==n?!1:(i=this.dense[this.size-1],this.dense[this.sparse[n]]=i,this.sparse[i]=this.sparse[n],this.size--,!0)},t.prototype.forEach=function(n,i){i=arguments.length>1?i:this;for(var o=0;o<this.size;o++)n.call(i,this.vals[o],this.dense[o])},t.prototype.keys=function(){var n=this.size,i=this.dense,o=0;return new r(function(){if(o<n){var s=i[o];return o++,{value:s}}return{done:!0}})},t.prototype.values=function(){var n=this.size,i=this.vals,o=0;return new r(function(){if(o<n){var s=i[o];return o++,{value:s}}return{done:!0}})},t.prototype.entries=function(){var n=this.size,i=this.dense,o=this.vals,s=0;return new r(function(){if(s<n){var a=[i[s],o[s]];return s++,{value:a}}return{done:!0}})},typeof Symbol<"u"&&(t.prototype[Symbol.iterator]=t.prototype.entries),t.prototype.inspect=function(){for(var n=new Map,i=0;i<this.size;i++)n.set(this.dense[i],this.vals[i]);return Object.defineProperty(n,"constructor",{value:t,enumerable:!1}),n.length=this.length,this.vals.constructor!==Array&&(n.type=this.vals.constructor.name),n},typeof Symbol<"u"&&(t.prototype[Symbol.for("nodejs.util.inspect.custom")]=t.prototype.inspect),Yi=t,Yi}var Xi,Qs;function Pc(){if(Qs)return Xi;Qs=1;var r=Nc(),e=Oo().getPointerArray;function t(n){var i=e(n);this.start=0,this.size=0,this.capacity=n,this.dense=new i(n),this.sparse=new i(n)}return t.prototype.clear=function(){this.start=0,this.size=0},t.prototype.has=function(n){if(this.size===0)return!1;var i=this.sparse[n],o=i<this.capacity&&i>=this.start&&i<this.start+this.size||i<(this.start+this.size)%this.capacity;return o&&this.dense[i]===n},t.prototype.enqueue=function(n){var i=this.sparse[n];if(this.size!==0){var o=i<this.capacity&&i>=this.start&&i<this.start+this.size||i<(this.start+this.size)%this.capacity;if(o&&this.dense[i]===n)return this}return i=(this.start+this.size)%this.capacity,this.dense[i]=n,this.sparse[n]=i,this.size++,this},t.prototype.dequeue=function(){if(this.size!==0){var n=this.start;this.size--,this.start++,this.start===this.capacity&&(this.start=0);var i=this.dense[n];return this.sparse[i]=this.capacity,i}},t.prototype.forEach=function(n,i){i=arguments.length>1?i:this;for(var o=this.capacity,s=this.size,a=this.start,c=0;c<s;)n.call(i,this.dense[a],c,this),a++,c++,a===o&&(a=0)},t.prototype.values=function(){var n=this.dense,i=this.capacity,o=this.size,s=this.start,a=0;return new r(function(){if(a>=o)return{done:!0};var c=n[s];return s++,a++,s===i&&(s=0),{value:c,done:!1}})},typeof Symbol<"u"&&(t.prototype[Symbol.iterator]=t.prototype.values),t.prototype.inspect=function(){var n=[];return this.forEach(function(i){n.push(i)}),Object.defineProperty(n,"constructor",{value:t,enumerable:!1}),n.capacity=this.capacity,n},typeof Symbol<"u"&&(t.prototype[Symbol.for("nodejs.util.inspect.custom")]=t.prototype.inspect),Xi=t,Xi}var Ji,ea;function Uc(){if(ea)return Ji;ea=1;function r(t){return function(n){return typeof n!="number"&&(n=n.length),Math.floor(t()*n)}}var e=r(Math.random);return e.createRandomIndex=r,Ji=e,Ji}var jn={},Zi,ta;function Gg(){if(ta)return Zi;ta=1;function r(t){return function(n,i){return n+Math.floor(t()*(i-n+1))}}var e=r(Math.random);return e.createRandom=r,Zi=e,Zi}var ra;function Rg(){if(ra)return jn;ra=1;var r=zo(),e=Gg().createRandom;function t(i,o,s){var a=i.get(o);typeof a>"u"&&(a=0),a+=s,i.set(o,a)}function n(i,o){o=o||{};var s=o.rng||Math.random,a="randomness"in o?o.randomness:.01;this.index=i,this.random=e(s),this.randomness=a,this.rng=s;var c=i.counts.constructor,l=i.weights.constructor,d=i.C;this.resolution=i.resolution,this.B=i.C,this.C=0,this.communitiesOffsets=new c(d),this.nodesSortedByCommunities=new c(d),this.communitiesBounds=new c(d+1),this.communityWeights=new l(d),this.degrees=new l(d),this.nonSingleton=new Uint8Array(d),this.externalEdgeWeightPerCommunity=new l(d),this.belongings=new c(d),this.neighboringCommunities=new r(l,d),this.cumulativeIncrement=new Float64Array(d),this.macroCommunities=null}return n.prototype.groupByCommunities=function(){var i=this.index,o,s,a,c,l;for(o=0,l=0,s=0;s<i.C;s++)a=i.counts[s],a!==0&&(this.communitiesBounds[l++]=o,o+=a,this.communitiesOffsets[s]=o);for(this.communitiesBounds[l]=o,l=0,s=0;s<i.C;s++)c=i.belongings[s],l=--this.communitiesOffsets[c],this.nodesSortedByCommunities[l]=s;this.B=i.C-i.U,this.C=i.C},n.prototype.communities=function(){var i=new Array(this.B),o,s,a,c,l;for(o=0;o<this.B;o++){for(c=this.communitiesBounds[o],l=this.communitiesBounds[o+1],a=[],s=c;s<l;s++)a.push(s);i[o]=a}return i},n.prototype.mergeNodesSubset=function(i,o){var s=this.index,a=s.belongings[this.nodesSortedByCommunities[i]],c=this.neighboringCommunities,l=0,d,f,h,g,y,C;for(f=i;f<o;f++)for(d=this.nodesSortedByCommunities[f],this.belongings[d]=d,this.nonSingleton[d]=0,this.degrees[d]=0,l+=s.loops[d]/2,this.communityWeights[d]=s.loops[d],this.externalEdgeWeightPerCommunity[d]=0,g=s.starts[d],y=s.starts[d+1];g<y;g++)C=s.neighborhood[g],h=s.weights[g],this.degrees[d]+=h,s.belongings[C]===a&&(l+=h,this.externalEdgeWeightPerCommunity[d]+=h,this.communityWeights[d]+=h);var b=this.externalEdgeWeightPerCommunity.slice(),m,A,v,p=o-i,E,S,$,x,D,I,j,O,w,ge,ce,L,_;for(A=this.random(i,o-1),m=i;m<o;m++,A++)if(f=i+A%p,d=this.nodesSortedByCommunities[f],this.nonSingleton[d]!==1&&!(this.externalEdgeWeightPerCommunity[d]<this.communityWeights[d]*(l/2-this.communityWeights[d])*this.resolution)){for(this.communityWeights[d]=0,this.externalEdgeWeightPerCommunity[d]=0,c.clear(),c.set(d,0),E=0,g=s.starts[d],y=s.starts[d+1];g<y;g++)C=s.neighborhood[g],s.belongings[C]===a&&(h=s.weights[g],E+=h,t(c,this.belongings[C],h));for(S=d,x=0,D=0,v=0;v<c.size;v++)I=c.dense[v],j=c.vals[v],O=this.communityWeights[I],this.externalEdgeWeightPerCommunity[I]>=O*(l/2-O)*this.resolution&&($=j-(E+s.loops[d])*O*this.resolution/l,$>x&&(S=I,x=$),$>=0&&(D+=Math.exp($/this.randomness))),this.cumulativeIncrement[v]=D;if(D<Number.MAX_VALUE&&D<1/0){for(w=D*this.rng(),ge=-1,ce=c.size+1;ge<ce-1;)L=ge+ce>>>1,this.cumulativeIncrement[L]>=w?ce=L:ge=L;_=c.dense[ce]}else _=S;for(this.communityWeights[_]+=E+s.loops[d],g=s.starts[d],y=s.starts[d+1];g<y;g++)C=s.neighborhood[g],s.belongings[C]===a&&(I=this.belongings[C],I===_?this.externalEdgeWeightPerCommunity[_]-=b[C]:this.externalEdgeWeightPerCommunity[_]+=b[C]);_!==d&&(this.belongings[d]=_,this.nonSingleton[_]=1,this.C--)}var K=this.neighboringCommunities;for(K.clear(),f=i;f<o;f++)d=this.nodesSortedByCommunities[f],K.set(this.belongings[d],1);return K.dense.slice(0,K.size)},n.prototype.refinePartition=function(){this.groupByCommunities(),this.macroCommunities=new Array(this.B);var i,o,s,a,c=this.communitiesBounds;for(i=0;i<this.B;i++)o=c[i],s=c[i+1],a=this.mergeNodesSubset(o,s),this.macroCommunities[i]=a},n.prototype.split=function(){var i=this.index,o=this.neighboringCommunities;o.clear();var s,a,c;for(s=0;s<i.C;s++)a=this.belongings[s],s===a&&(c=i.isolate(s,this.degrees[s]),o.set(a,c));for(s=0;s<i.C;s++)a=this.belongings[s],s!==a&&(c=o.get(a),i.move(s,this.degrees[s],c));var l,d;for(s=0;s<this.macroCommunities.length;s++)for(d=this.macroCommunities[s],l=0;l<d.length;l++)d[l]=o.get(d[l])},n.prototype.zoomOut=function(){var i=this.index;this.refinePartition(),this.split();var o=i.zoomOut(),s,a,c,l,d;for(l=0;l<this.macroCommunities.length;l++)for(s=this.macroCommunities[l],a=o[s[0]],d=1;d<s.length;d++)c=o[s[d]],i.expensiveMove(c,a)},n.prototype.onlySingletons=function(){var i=this.index,o;for(o=0;o<i.C;o++)if(i.counts[o]>1)return!1;return!0},jn.addWeightToCommunity=t,jn.UndirectedLeidenAddenda=n,jn}var Bn={},tn={},na;function Wc(){if(na)return tn;na=1;function r(n){return typeof n!="number"||isNaN(n)?1:n}function e(n,i){var o={},s=function(l){return typeof l>"u"?i:l};typeof i=="function"&&(s=i);var a=function(l){return s(l[n])},c=function(){return s(void 0)};return typeof n=="string"?(o.fromAttributes=a,o.fromGraph=function(l,d){return a(l.getNodeAttributes(d))},o.fromEntry=function(l,d){return a(d)}):typeof n=="function"?(o.fromAttributes=function(){throw new Error("graphology-utils/getters/createNodeValueGetter: irrelevant usage.")},o.fromGraph=function(l,d){return s(n(d,l.getNodeAttributes(d)))},o.fromEntry=function(l,d){return s(n(l,d))}):(o.fromAttributes=c,o.fromGraph=c,o.fromEntry=c),o}function t(n,i){var o={},s=function(l){return typeof l>"u"?i:l};typeof i=="function"&&(s=i);var a=function(l){return s(l[n])},c=function(){return s(void 0)};return typeof n=="string"?(o.fromAttributes=a,o.fromGraph=function(l,d){return a(l.getEdgeAttributes(d))},o.fromEntry=function(l,d){return a(d)},o.fromPartialEntry=o.fromEntry,o.fromMinimalEntry=o.fromEntry):typeof n=="function"?(o.fromAttributes=function(){throw new Error("graphology-utils/getters/createEdgeValueGetter: irrelevant usage.")},o.fromGraph=function(l,d){var f=l.extremities(d);return s(n(d,l.getEdgeAttributes(d),f[0],f[1],l.getNodeAttributes(f[0]),l.getNodeAttributes(f[1]),l.isUndirected(d)))},o.fromEntry=function(l,d,f,h,g,y,C){return s(n(l,d,f,h,g,y,C))},o.fromPartialEntry=function(l,d,f,h){return s(n(l,d,f,h))},o.fromMinimalEntry=function(l,d){return s(n(l,d))}):(o.fromAttributes=c,o.fromGraph=c,o.fromEntry=c,o.fromMinimalEntry=c),o}return tn.createNodeValueGetter=e,tn.createEdgeValueGetter=t,tn.createEdgeWeightGetter=function(n){return t(n,r)},tn}var ia;function jc(){if(ia)return Bn;ia=1;var r=Oo(),e=Ro(),t=Wc().createEdgeWeightGetter,n=Symbol.for("nodejs.util.inspect.custom"),i={getEdgeWeight:"weight",keepDendrogram:!1,resolution:1};function o(a,c){c=e(c,i);var l=c.resolution,d=t(c.getEdgeWeight).fromEntry,f=(a.size-a.selfLoopCount)*2,h=r.getPointerArray(f),g=r.getPointerArray(a.order+1),y=c.getEdgeWeight?Float64Array:r.getPointerArray(a.size*2);this.C=a.order,this.M=0,this.E=f,this.U=0,this.resolution=l,this.level=0,this.graph=a,this.nodes=new Array(a.order),this.keepDendrogram=c.keepDendrogram,this.neighborhood=new g(f),this.weights=new y(f),this.loops=new y(a.order),this.starts=new h(a.order+1),this.belongings=new g(a.order),this.dendrogram=[],this.mapping=null,this.counts=new g(a.order),this.unused=new g(a.order),this.totalWeights=new y(a.order);var C={},b,m=0,A=0,v=this;a.forEachNode(function(p){v.nodes[m]=p,C[p]=m,A+=a.undirectedDegreeWithoutSelfLoops(p),v.starts[m]=A,v.belongings[m]=m,v.counts[m]=1,m++}),a.forEachEdge(function(p,E,S,$,x,D,I){if(b=d(p,E,S,$,x,D,I),S=C[S],$=C[$],v.M+=b,S===$)v.totalWeights[S]+=b*2,v.loops[S]=b*2;else{v.totalWeights[S]+=b,v.totalWeights[$]+=b;var j=--v.starts[S],O=--v.starts[$];v.neighborhood[j]=$,v.neighborhood[O]=S,v.weights[j]=b,v.weights[O]=b}}),this.starts[m]=this.E,this.keepDendrogram?this.dendrogram.push(this.belongings.slice()):this.mapping=this.belongings.slice()}o.prototype.isolate=function(a,c){var l=this.belongings[a];if(this.counts[l]===1)return l;var d=this.unused[--this.U],f=this.loops[a];return this.totalWeights[l]-=c+f,this.totalWeights[d]+=c+f,this.belongings[a]=d,this.counts[l]--,this.counts[d]++,d},o.prototype.move=function(a,c,l){var d=this.belongings[a],f=this.loops[a];this.totalWeights[d]-=c+f,this.totalWeights[l]+=c+f,this.belongings[a]=l;var h=this.counts[d]--===1;this.counts[l]++,h&&(this.unused[this.U++]=d)},o.prototype.computeNodeDegree=function(a){var c,l,d,f=0;for(c=this.starts[a],l=this.starts[a+1];c<l;c++)d=this.weights[c],f+=d;return f},o.prototype.expensiveIsolate=function(a){var c=this.computeNodeDegree(a);return this.isolate(a,c)},o.prototype.expensiveMove=function(a,c){var l=this.computeNodeDegree(a);this.move(a,l,c)},o.prototype.zoomOut=function(){var a=new Array(this.C-this.U),c={},l=this.nodes.length,d=0,f=0,h,g,y,C,b,m,A,v,p;for(h=0,y=this.C;h<y;h++)m=this.belongings[h],m in c||(c[m]=d,a[d]={adj:{},totalWeights:this.totalWeights[m],internalWeights:0},d++),this.belongings[h]=c[m];var E,S;if(this.keepDendrogram){for(E=this.dendrogram[this.level],S=new(r.getPointerArray(d))(l),h=0;h<l;h++)S[h]=this.belongings[E[h]];this.dendrogram.push(S)}else for(h=0;h<l;h++)this.mapping[h]=this.belongings[this.mapping[h]];for(h=0,y=this.C;h<y;h++)for(m=this.belongings[h],v=a[m],p=v.adj,v.internalWeights+=this.loops[h],g=this.starts[h],C=this.starts[h+1];g<C;g++){if(b=this.neighborhood[g],A=this.belongings[b],m===A){v.internalWeights+=this.weights[g];continue}A in p||(p[A]=0),p[A]+=this.weights[g]}for(this.C=d,b=0,m=0;m<d;m++){v=a[m],p=v.adj,m=+m,this.totalWeights[m]=v.totalWeights,this.loops[m]=v.internalWeights,this.counts[m]=1,this.starts[m]=b,this.belongings[m]=m;for(A in p)this.neighborhood[b]=+A,this.weights[b]=p[A],f++,b++}return this.starts[d]=f,this.E=f,this.U=0,this.level++,c},o.prototype.modularity=function(){var a,c,l,d,f,h=0,g=this.M*2,y=new Float64Array(this.C);for(l=0;l<this.C;l++)for(a=this.belongings[l],y[a]+=this.loops[l],d=this.starts[l],f=this.starts[l+1];d<f;d++)c=this.belongings[this.neighborhood[d]],a===c&&(y[a]+=this.weights[d]);for(l=0;l<this.C;l++)h+=y[l]/g-Math.pow(this.totalWeights[l]/g,2)*this.resolution;return h},o.prototype.delta=function(a,c,l,d){var f=this.M,h=this.totalWeights[d];return c+=this.loops[a],l/f-h*c*this.resolution/(2*f*f)},o.prototype.deltaWithOwnCommunity=function(a,c,l,d){var f=this.M,h=this.totalWeights[d];return c+=this.loops[a],l/f-(h-c)*c*this.resolution/(2*f*f)},o.prototype.fastDelta=function(a,c,l,d){var f=this.M,h=this.totalWeights[d];return c+=this.loops[a],l-c*h*this.resolution/(2*f)},o.prototype.fastDeltaWithOwnCommunity=function(a,c,l,d){var f=this.M,h=this.totalWeights[d];return c+=this.loops[a],l-c*(h-c)*this.resolution/(2*f)},o.prototype.bounds=function(a){return[this.starts[a],this.starts[a+1]]},o.prototype.project=function(){var a=this,c={};return a.nodes.slice(0,this.C).forEach(function(l,d){c[l]=Array.from(a.neighborhood.slice(a.starts[d],a.starts[d+1])).map(function(f){return a.nodes[f]})}),c},o.prototype.collect=function(a){arguments.length<1&&(a=this.level);var c={},l=this.keepDendrogram?this.dendrogram[a]:this.mapping,d,f;for(d=0,f=l.length;d<f;d++)c[this.nodes[d]]=l[d];return c},o.prototype.assign=function(a,c){arguments.length<2&&(c=this.level);var l=this.keepDendrogram?this.dendrogram[c]:this.mapping,d,f;for(d=0,f=l.length;d<f;d++)this.graph.setNodeAttribute(this.nodes[d],a,l[d])},o.prototype[n]=function(){var a={};Object.defineProperty(a,"constructor",{value:o,enumerable:!1}),a.C=this.C,a.M=this.M,a.E=this.E,a.U=this.U,a.resolution=this.resolution,a.level=this.level,a.nodes=this.nodes,a.starts=this.starts.slice(0,a.C+1);var c=["neighborhood","weights"],l=["counts","loops","belongings","totalWeights"],d=this;return c.forEach(function(f){a[f]=d[f].slice(0,a.E)}),l.forEach(function(f){a[f]=d[f].slice(0,a.C)}),a.unused=this.unused.slice(0,this.U),this.keepDendrogram?a.dendrogram=this.dendrogram:a.mapping=this.mapping,a};function s(a,c){c=e(c,i);var l=c.resolution,d=t(c.getEdgeWeight).fromEntry,f=(a.size-a.selfLoopCount)*2,h=r.getPointerArray(f),g=r.getPointerArray(a.order+1),y=c.getEdgeWeight?Float64Array:r.getPointerArray(a.size*2);this.C=a.order,this.M=0,this.E=f,this.U=0,this.resolution=l,this.level=0,this.graph=a,this.nodes=new Array(a.order),this.keepDendrogram=c.keepDendrogram,this.neighborhood=new g(f),this.weights=new y(f),this.loops=new y(a.order),this.starts=new h(a.order+1),this.offsets=new h(a.order),this.belongings=new g(a.order),this.dendrogram=[],this.counts=new g(a.order),this.unused=new g(a.order),this.totalInWeights=new y(a.order),this.totalOutWeights=new y(a.order);var C={},b,m=0,A=0,v=this;a.forEachNode(function(p){v.nodes[m]=p,C[p]=m,A+=a.outDegreeWithoutSelfLoops(p),v.starts[m]=A,A+=a.inDegreeWithoutSelfLoops(p),v.offsets[m]=A,v.belongings[m]=m,v.counts[m]=1,m++}),a.forEachEdge(function(p,E,S,$,x,D,I){if(b=d(p,E,S,$,x,D,I),S=C[S],$=C[$],v.M+=b,S===$)v.loops[S]+=b,v.totalInWeights[S]+=b,v.totalOutWeights[S]+=b;else{v.totalOutWeights[S]+=b,v.totalInWeights[$]+=b;var j=--v.starts[S],O=--v.offsets[$];v.neighborhood[j]=$,v.neighborhood[O]=S,v.weights[j]=b,v.weights[O]=b}}),this.starts[m]=this.E,this.keepDendrogram?this.dendrogram.push(this.belongings.slice()):this.mapping=this.belongings.slice()}return s.prototype.bounds=o.prototype.bounds,s.prototype.inBounds=function(a){return[this.offsets[a],this.starts[a+1]]},s.prototype.outBounds=function(a){return[this.starts[a],this.offsets[a]]},s.prototype.project=o.prototype.project,s.prototype.projectIn=function(){var a=this,c={};return a.nodes.slice(0,this.C).forEach(function(l,d){c[l]=Array.from(a.neighborhood.slice(a.offsets[d],a.starts[d+1])).map(function(f){return a.nodes[f]})}),c},s.prototype.projectOut=function(){var a=this,c={};return a.nodes.slice(0,this.C).forEach(function(l,d){c[l]=Array.from(a.neighborhood.slice(a.starts[d],a.offsets[d])).map(function(f){return a.nodes[f]})}),c},s.prototype.isolate=function(a,c,l){var d=this.belongings[a];if(this.counts[d]===1)return d;var f=this.unused[--this.U],h=this.loops[a];return this.totalInWeights[d]-=c+h,this.totalInWeights[f]+=c+h,this.totalOutWeights[d]-=l+h,this.totalOutWeights[f]+=l+h,this.belongings[a]=f,this.counts[d]--,this.counts[f]++,f},s.prototype.move=function(a,c,l,d){var f=this.belongings[a],h=this.loops[a];this.totalInWeights[f]-=c+h,this.totalInWeights[d]+=c+h,this.totalOutWeights[f]-=l+h,this.totalOutWeights[d]+=l+h,this.belongings[a]=d;var g=this.counts[f]--===1;this.counts[d]++,g&&(this.unused[this.U++]=f)},s.prototype.computeNodeInDegree=function(a){var c,l,d,f=0;for(c=this.offsets[a],l=this.starts[a+1];c<l;c++)d=this.weights[c],f+=d;return f},s.prototype.computeNodeOutDegree=function(a){var c,l,d,f=0;for(c=this.starts[a],l=this.offsets[a];c<l;c++)d=this.weights[c],f+=d;return f},s.prototype.expensiveMove=function(a,c){var l=this.computeNodeInDegree(a),d=this.computeNodeOutDegree(a);this.move(a,l,d,c)},s.prototype.zoomOut=function(){var a=new Array(this.C-this.U),c={},l=this.nodes.length,d=0,f=0,h,g,y,C,b,m,A,v,p,E,S,$,x;for(h=0,y=this.C;h<y;h++)m=this.belongings[h],m in c||(c[m]=d,a[d]={inAdj:{},outAdj:{},totalInWeights:this.totalInWeights[m],totalOutWeights:this.totalOutWeights[m],internalWeights:0},d++),this.belongings[h]=c[m];var D,I;if(this.keepDendrogram){for(D=this.dendrogram[this.level],I=new(r.getPointerArray(d))(l),h=0;h<l;h++)I[h]=this.belongings[D[h]];this.dendrogram.push(I)}else for(h=0;h<l;h++)this.mapping[h]=this.belongings[this.mapping[h]];for(h=0,y=this.C;h<y;h++)for(m=this.belongings[h],p=this.offsets[h],v=a[m],$=v.inAdj,x=v.outAdj,v.internalWeights+=this.loops[h],g=this.starts[h],C=this.starts[h+1];g<C;g++){if(b=this.neighborhood[g],A=this.belongings[b],E=g<p,S=E?x:$,m===A){E&&(v.internalWeights+=this.weights[g]);continue}A in S||(S[A]=0),S[A]+=this.weights[g]}for(this.C=d,b=0,m=0;m<d;m++){v=a[m],$=v.inAdj,x=v.outAdj,m=+m,this.totalInWeights[m]=v.totalInWeights,this.totalOutWeights[m]=v.totalOutWeights,this.loops[m]=v.internalWeights,this.counts[m]=1,this.starts[m]=b,this.belongings[m]=m;for(A in x)this.neighborhood[b]=+A,this.weights[b]=x[A],f++,b++;this.offsets[m]=b;for(A in $)this.neighborhood[b]=+A,this.weights[b]=$[A],f++,b++}return this.starts[d]=f,this.E=f,this.U=0,this.level++,c},s.prototype.modularity=function(){var a,c,l,d,f,h=0,g=this.M,y=new Float64Array(this.C);for(l=0;l<this.C;l++)for(a=this.belongings[l],y[a]+=this.loops[l],d=this.starts[l],f=this.offsets[l];d<f;d++)c=this.belongings[this.neighborhood[d]],a===c&&(y[a]+=this.weights[d]);for(l=0;l<this.C;l++)h+=y[l]/g-this.totalInWeights[l]*this.totalOutWeights[l]/Math.pow(g,2)*this.resolution;return h},s.prototype.delta=function(a,c,l,d,f){var h=this.M,g=this.totalInWeights[f],y=this.totalOutWeights[f],C=this.loops[a];return c+=C,l+=C,d/h-(l*g+c*y)*this.resolution/(h*h)},s.prototype.deltaWithOwnCommunity=function(a,c,l,d,f){var h=this.M,g=this.totalInWeights[f],y=this.totalOutWeights[f],C=this.loops[a];return c+=C,l+=C,d/h-(l*(g-c)+c*(y-l))*this.resolution/(h*h)},s.prototype.collect=o.prototype.collect,s.prototype.assign=o.prototype.assign,s.prototype[n]=function(){var a={};Object.defineProperty(a,"constructor",{value:s,enumerable:!1}),a.C=this.C,a.M=this.M,a.E=this.E,a.U=this.U,a.resolution=this.resolution,a.level=this.level,a.nodes=this.nodes,a.starts=this.starts.slice(0,a.C+1);var c=["neighborhood","weights"],l=["counts","offsets","loops","belongings","totalInWeights","totalOutWeights"],d=this;return c.forEach(function(f){a[f]=d[f].slice(0,a.E)}),l.forEach(function(f){a[f]=d[f].slice(0,a.C)}),a.unused=this.unused.slice(0,this.U),this.keepDendrogram?a.dendrogram=this.dendrogram:a.mapping=this.mapping,a},Bn.UndirectedLouvainIndex=o,Bn.DirectedLouvainIndex=s,Bn}var Qi,oa;function Og(){if(oa)return Qi;oa=1;var r=Ro(),e=li(),t=Mc(),n=zo(),i=Pc(),o=Uc().createRandomIndex,s=Rg(),a=jc(),c=s.addWeightToCommunity,l=a.UndirectedLouvainIndex,d=s.UndirectedLeidenAddenda,f={attributes:{community:"community",weight:"weight"},randomness:.01,randomWalk:!0,resolution:1,rng:Math.random,weighted:!1,maxIterations:0},h=1e-10;function g(m,A,v,p,E){return Math.abs(p-E)<h?m===A?!1:v>m:p>E}function y(m,A,v){for(var p=new l(A,{attributes:{weight:v.attributes.weight},keepDendrogram:m,resolution:v.resolution,weighted:v.weighted}),E=new d(p,{randomness:v.randomness,rng:v.rng}),S=o(v.rng),$,x,D=new n(Float64Array,p.C),I=new i(p.C),j,O,w,ge,ce,L,_,K,ee,M,Re,ae,W,Se,Ce,be=0,Ye=0,ot=[],Ae,ve=0;!(v.maxIterations>0&&ve>=v.maxIterations);){for(ve++,ee=p.C,Ae=0,ce=v.randomWalk?S(ee):0,L=0;L<ee;L++,ce++)_=ce%ee,I.enqueue(_);for(;I.size!==0;){for(_=I.dequeue(),Ye++,M=0,D.clear(),$=p.belongings[_],j=p.starts[_],O=p.starts[_+1];j<O;j++)K=p.neighborhood[j],w=p.weights[j],x=p.belongings[K],M+=w,c(D,x,w);W=p.fastDeltaWithOwnCommunity(_,M,D.get($)||0,$),ae=$;var X=[[$,W,"own",p.counts[$]===1]];for(ge=0;ge<D.size;ge++)x=D.dense[ge],x!==$&&(Re=D.vals[ge],be++,Ce=p.fastDelta(_,M,Re,x),X.push([x,Ce,"other"]),Se=g(ae,$,x,Ce,W),Se&&(W=Ce,ae=x));if(W<0){if(ae=p.isolate(_,M),ae===$)continue}else{if(ae===$)continue;p.move(_,M,ae)}for(Ae++,j=p.starts[_],O=p.starts[_+1];j<O;j++)K=p.neighborhood[j],x=p.belongings[K],x!==ae&&I.enqueue(K)}if(ot.push(Ae),Ae===0){p.zoomOut();break}if(!E.onlySingletons()){E.zoomOut();continue}break}var me={index:p,deltaComputations:be,nodesVisited:Ye,moves:ot};return me}function C(m,A,v,p){if(!e(v))throw new Error("graphology-communities-leiden: the given graph is not a valid graphology instance.");var E=t(v);if(E==="mixed")throw new Error("graphology-communities-leiden: cannot run the algorithm on a true mixed graph.");if(E==="directed")throw new Error("graphology-communities-leiden: not yet implemented for directed graphs.");p=r(p,f);var S=0;if(v.size===0){if(m){v.forEachNode(function(O){v.setNodeAttribute(O,p.attributes.communities,S++)});return}var $={};return v.forEachNode(function(O){$[O]=S++}),A?{communities:$,count:v.order,deltaComputations:0,dendrogram:null,level:0,modularity:NaN,moves:null,nodesVisited:0,resolution:p.resolution}:$}var x=y,D=x(A,v,p),I=D.index;if(!A){if(m){I.assign(p.attributes.community);return}return I.collect()}var j={count:I.C,deltaComputations:D.deltaComputations,dendrogram:I.dendrogram,level:I.level,modularity:I.modularity(),moves:D.moves,nodesVisited:D.nodesVisited,resolution:p.resolution};return m?(I.assign(p.attributes.community),j):(j.communities=I.collect(),j)}var b=C.bind(null,!1,!1);return b.assign=C.bind(null,!0,!1),b.detailed=C.bind(null,!1,!0),b.defaults=f,Qi=b,Qi}var zg=Og();const Mg=Do(zg);var eo,sa;function Ng(){if(sa)return eo;sa=1;var r=Ro(),e=li(),t=Mc(),n=zo(),i=Pc(),o=Uc().createRandomIndex,s=jc(),a=s.UndirectedLouvainIndex,c=s.DirectedLouvainIndex,l={nodeCommunityAttribute:"community",getEdgeWeight:"weight",fastLocalMoves:!0,randomWalk:!0,resolution:1,rng:Math.random};function d(m,A,v){var p=m.get(A);typeof p>"u"&&(p=0),p+=v,m.set(A,p)}var f=1e-10;function h(m,A,v,p,E){return Math.abs(p-E)<f?m===A?!1:v>m:p>E}function g(m,A,v){var p=new a(A,{getEdgeWeight:v.getEdgeWeight,keepDendrogram:m,resolution:v.resolution}),E=o(v.rng),S=!0,$=!0,x,D,I=new n(Float64Array,p.C),j,O,w,ge,ce,L,_,K,ee,M,Re,ae,W,Se,Ce,be,Ye=0,ot=0,Ae=[],ve,X;for(v.fastLocalMoves&&(j=new i(p.C));S;){if(M=p.C,S=!1,$=!0,v.fastLocalMoves){for(X=0,L=v.randomWalk?E(M):0,_=0;_<M;_++,L++)K=L%M,j.enqueue(K);for(;j.size!==0;){for(K=j.dequeue(),ot++,Re=0,I.clear(),x=p.belongings[K],O=p.starts[K],w=p.starts[K+1];O<w;O++)ee=p.neighborhood[O],ge=p.weights[O],D=p.belongings[ee],Re+=ge,d(I,D,ge);for(Se=p.fastDeltaWithOwnCommunity(K,Re,I.get(x)||0,x),W=x,ce=0;ce<I.size;ce++)D=I.dense[ce],D!==x&&(ae=I.vals[ce],Ye++,be=p.fastDelta(K,Re,ae,D),Ce=h(W,x,D,be,Se),Ce&&(Se=be,W=D));if(Se<0){if(W=p.isolate(K,Re),W===x)continue}else{if(W===x)continue;p.move(K,Re,W)}for(S=!0,X++,O=p.starts[K],w=p.starts[K+1];O<w;O++)ee=p.neighborhood[O],D=p.belongings[ee],D!==W&&j.enqueue(ee)}Ae.push(X)}else for(ve=[],Ae.push(ve);$;){for($=!1,X=0,L=v.randomWalk?E(M):0,_=0;_<M;_++,L++){for(K=L%M,ot++,Re=0,I.clear(),x=p.belongings[K],O=p.starts[K],w=p.starts[K+1];O<w;O++)ee=p.neighborhood[O],ge=p.weights[O],D=p.belongings[ee],Re+=ge,d(I,D,ge);for(Se=p.fastDeltaWithOwnCommunity(K,Re,I.get(x)||0,x),W=x,ce=0;ce<I.size;ce++)D=I.dense[ce],D!==x&&(ae=I.vals[ce],Ye++,be=p.fastDelta(K,Re,ae,D),Ce=h(W,x,D,be,Se),Ce&&(Se=be,W=D));if(Se<0){if(W=p.isolate(K,Re),W===x)continue}else{if(W===x)continue;p.move(K,Re,W)}$=!0,X++}ve.push(X),S=$||S}S&&p.zoomOut()}var me={index:p,deltaComputations:Ye,nodesVisited:ot,moves:Ae};return me}function y(m,A,v){var p=new c(A,{getEdgeWeight:v.getEdgeWeight,keepDendrogram:m,resolution:v.resolution}),E=o(v.rng),S=!0,$=!0,x,D,I=new n(Float64Array,p.C),j,O,w,ge,ce,L,_,K,ee,M,Re,ae,W,Se,Ce,be,Ye,ot,Ae,ve=0,X=0,me=[],et,J;for(v.fastLocalMoves&&(j=new i(p.C));S;){if(ae=p.C,S=!1,$=!0,v.fastLocalMoves){for(J=0,K=v.randomWalk?E(ae):0,ee=0;ee<ae;ee++,K++)M=K%ae,j.enqueue(M);for(;j.size!==0;){for(M=j.dequeue(),X++,W=0,Se=0,I.clear(),x=p.belongings[M],O=p.starts[M],w=p.starts[M+1],ge=p.offsets[M];O<w;O++)ce=O<ge,Re=p.neighborhood[O],L=p.weights[O],D=p.belongings[Re],ce?Se+=L:W+=L,d(I,D,L);for(Ye=p.deltaWithOwnCommunity(M,W,Se,I.get(x)||0,x),be=x,_=0;_<I.size;_++)D=I.dense[_],D!==x&&(Ce=I.vals[_],ve++,Ae=p.delta(M,W,Se,Ce,D),ot=h(be,x,D,Ae,Ye),ot&&(Ye=Ae,be=D));if(Ye<0){if(be=p.isolate(M,W,Se),be===x)continue}else{if(be===x)continue;p.move(M,W,Se,be)}for(S=!0,J++,O=p.starts[M],w=p.starts[M+1];O<w;O++)Re=p.neighborhood[O],D=p.belongings[Re],D!==be&&j.enqueue(Re)}me.push(J)}else for(et=[],me.push(et);$;){for($=!1,J=0,K=v.randomWalk?E(ae):0,ee=0;ee<ae;ee++,K++){for(M=K%ae,X++,W=0,Se=0,I.clear(),x=p.belongings[M],O=p.starts[M],w=p.starts[M+1],ge=p.offsets[M];O<w;O++)ce=O<ge,Re=p.neighborhood[O],L=p.weights[O],D=p.belongings[Re],ce?Se+=L:W+=L,d(I,D,L);for(Ye=p.deltaWithOwnCommunity(M,W,Se,I.get(x)||0,x),be=x,_=0;_<I.size;_++)D=I.dense[_],D!==x&&(Ce=I.vals[_],ve++,Ae=p.delta(M,W,Se,Ce,D),ot=h(be,x,D,Ae,Ye),ot&&(Ye=Ae,be=D));if(Ye<0){if(be=p.isolate(M,W,Se),be===x)continue}else{if(be===x)continue;p.move(M,W,Se,be)}$=!0,J++}et.push(J),S=$||S}S&&p.zoomOut()}var ne={index:p,deltaComputations:ve,nodesVisited:X,moves:me};return ne}function C(m,A,v,p){if(!e(v))throw new Error("graphology-communities-louvain: the given graph is not a valid graphology instance.");var E=t(v);if(E==="mixed")throw new Error("graphology-communities-louvain: cannot run the algorithm on a true mixed graph.");p=r(p,l);var S=0;if(v.size===0){if(m){v.forEachNode(function(O){v.setNodeAttribute(O,p.nodeCommunityAttribute,S++)});return}var $={};return v.forEachNode(function(O){$[O]=S++}),A?{communities:$,count:v.order,deltaComputations:0,dendrogram:null,level:0,modularity:NaN,moves:null,nodesVisited:0,resolution:p.resolution}:$}var x=E==="undirected"?g:y,D=x(A,v,p),I=D.index;if(!A){if(m){I.assign(p.nodeCommunityAttribute);return}return I.collect()}var j={count:I.C,deltaComputations:D.deltaComputations,dendrogram:I.dendrogram,level:I.level,modularity:I.modularity(),moves:D.moves,nodesVisited:D.nodesVisited,resolution:p.resolution};return m?(I.assign(p.nodeCommunityAttribute),j):(j.communities=I.collect(),j)}var b=C.bind(null,!1,!1);return b.assign=C.bind(null,!0,!1),b.detailed=C.bind(null,!1,!0),b.defaults=l,eo=b,eo}var Pg=Ng();const Ug=Do(Pg);var to,aa;function Wg(){if(aa)return to;aa=1;var r=0,e=1,t=2,n=3,i=4,o=5,s=6,a=7,c=8,l=9,d=0,f=1,h=2,g=0,y=1,C=2,b=3,m=4,A=5,v=6,p=7,E=8,S=3,$=10,x=3,D=9,I=10;return to=function(O,w,ge){var ce,L,_,K,ee,M,Re,ae,W,Se,Ce=w.length,be=ge.length,Ye=O.adjustSizes,ot=O.barnesHutTheta*O.barnesHutTheta,Ae,ve,X,me,et,J,ne,G=[];for(_=0;_<Ce;_+=$)w[_+i]=w[_+t],w[_+o]=w[_+n],w[_+t]=0,w[_+n]=0;if(O.outboundAttractionDistribution){for(Ae=0,_=0;_<Ce;_+=$)Ae+=w[_+s];Ae/=Ce/$}if(O.barnesHutOptimize){var It=1/0,Rt=-1/0,Ot=1/0,Ht=-1/0,$t,xt,tt;for(_=0;_<Ce;_+=$)It=Math.min(It,w[_+r]),Rt=Math.max(Rt,w[_+r]),Ot=Math.min(Ot,w[_+e]),Ht=Math.max(Ht,w[_+e]);var Pt=Rt-It,nr=Ht-Ot;for(Pt>nr?(Ot-=(Pt-nr)/2,Ht=Ot+Pt):(It-=(nr-Pt)/2,Rt=It+nr),G[0+g]=-1,G[0+y]=(It+Rt)/2,G[0+C]=(Ot+Ht)/2,G[0+b]=Math.max(Rt-It,Ht-Ot),G[0+m]=-1,G[0+A]=-1,G[0+v]=0,G[0+p]=0,G[0+E]=0,ce=1,_=0;_<Ce;_+=$)for(L=0,tt=S;;)if(G[L+A]>=0){w[_+r]<G[L+y]?w[_+e]<G[L+C]?$t=G[L+A]:$t=G[L+A]+D:w[_+e]<G[L+C]?$t=G[L+A]+D*2:$t=G[L+A]+D*3,G[L+p]=(G[L+p]*G[L+v]+w[_+r]*w[_+s])/(G[L+v]+w[_+s]),G[L+E]=(G[L+E]*G[L+v]+w[_+e]*w[_+s])/(G[L+v]+w[_+s]),G[L+v]+=w[_+s],L=$t;continue}else if(G[L+g]<0){G[L+g]=_;break}else{if(G[L+A]=ce*D,ae=G[L+b]/2,W=G[L+A],G[W+g]=-1,G[W+y]=G[L+y]-ae,G[W+C]=G[L+C]-ae,G[W+b]=ae,G[W+m]=W+D,G[W+A]=-1,G[W+v]=0,G[W+p]=0,G[W+E]=0,W+=D,G[W+g]=-1,G[W+y]=G[L+y]-ae,G[W+C]=G[L+C]+ae,G[W+b]=ae,G[W+m]=W+D,G[W+A]=-1,G[W+v]=0,G[W+p]=0,G[W+E]=0,W+=D,G[W+g]=-1,G[W+y]=G[L+y]+ae,G[W+C]=G[L+C]-ae,G[W+b]=ae,G[W+m]=W+D,G[W+A]=-1,G[W+v]=0,G[W+p]=0,G[W+E]=0,W+=D,G[W+g]=-1,G[W+y]=G[L+y]+ae,G[W+C]=G[L+C]+ae,G[W+b]=ae,G[W+m]=G[L+m],G[W+A]=-1,G[W+v]=0,G[W+p]=0,G[W+E]=0,ce+=4,w[G[L+g]+r]<G[L+y]?w[G[L+g]+e]<G[L+C]?$t=G[L+A]:$t=G[L+A]+D:w[G[L+g]+e]<G[L+C]?$t=G[L+A]+D*2:$t=G[L+A]+D*3,G[L+v]=w[G[L+g]+s],G[L+p]=w[G[L+g]+r],G[L+E]=w[G[L+g]+e],G[$t+g]=G[L+g],G[L+g]=-1,w[_+r]<G[L+y]?w[_+e]<G[L+C]?xt=G[L+A]:xt=G[L+A]+D:w[_+e]<G[L+C]?xt=G[L+A]+D*2:xt=G[L+A]+D*3,$t===xt)if(tt--){L=$t;continue}else{tt=S;break}G[xt+g]=_;break}}if(O.barnesHutOptimize)for(ve=O.scalingRatio,_=0;_<Ce;_+=$)for(L=0;;)if(G[L+A]>=0)if(J=Math.pow(w[_+r]-G[L+p],2)+Math.pow(w[_+e]-G[L+E],2),Se=G[L+b],4*Se*Se/J<ot){if(X=w[_+r]-G[L+p],me=w[_+e]-G[L+E],Ye===!0?J>0?(ne=ve*w[_+s]*G[L+v]/J,w[_+t]+=X*ne,w[_+n]+=me*ne):J<0&&(ne=-ve*w[_+s]*G[L+v]/Math.sqrt(J),w[_+t]+=X*ne,w[_+n]+=me*ne):J>0&&(ne=ve*w[_+s]*G[L+v]/J,w[_+t]+=X*ne,w[_+n]+=me*ne),L=G[L+m],L<0)break;continue}else{L=G[L+A];continue}else{if(M=G[L+g],M>=0&&M!==_&&(X=w[_+r]-w[M+r],me=w[_+e]-w[M+e],J=X*X+me*me,Ye===!0?J>0?(ne=ve*w[_+s]*w[M+s]/J,w[_+t]+=X*ne,w[_+n]+=me*ne):J<0&&(ne=-ve*w[_+s]*w[M+s]/Math.sqrt(J),w[_+t]+=X*ne,w[_+n]+=me*ne):J>0&&(ne=ve*w[_+s]*w[M+s]/J,w[_+t]+=X*ne,w[_+n]+=me*ne)),L=G[L+m],L<0)break;continue}else for(ve=O.scalingRatio,K=0;K<Ce;K+=$)for(ee=0;ee<K;ee+=$)X=w[K+r]-w[ee+r],me=w[K+e]-w[ee+e],Ye===!0?(J=Math.sqrt(X*X+me*me)-w[K+c]-w[ee+c],J>0?(ne=ve*w[K+s]*w[ee+s]/J/J,w[K+t]+=X*ne,w[K+n]+=me*ne,w[ee+t]-=X*ne,w[ee+n]-=me*ne):J<0&&(ne=100*ve*w[K+s]*w[ee+s],w[K+t]+=X*ne,w[K+n]+=me*ne,w[ee+t]-=X*ne,w[ee+n]-=me*ne)):(J=Math.sqrt(X*X+me*me),J>0&&(ne=ve*w[K+s]*w[ee+s]/J/J,w[K+t]+=X*ne,w[K+n]+=me*ne,w[ee+t]-=X*ne,w[ee+n]-=me*ne));for(W=O.gravity/O.scalingRatio,ve=O.scalingRatio,_=0;_<Ce;_+=$)ne=0,X=w[_+r],me=w[_+e],J=Math.sqrt(Math.pow(X,2)+Math.pow(me,2)),O.strongGravityMode?J>0&&(ne=ve*w[_+s]*W):J>0&&(ne=ve*w[_+s]*W/J),w[_+t]-=X*ne,w[_+n]-=me*ne;for(ve=1*(O.outboundAttractionDistribution?Ae:1),Re=0;Re<be;Re+=x)K=ge[Re+d],ee=ge[Re+f],ae=ge[Re+h],et=Math.pow(ae,O.edgeWeightInfluence),X=w[K+r]-w[ee+r],me=w[K+e]-w[ee+e],Ye===!0?(J=Math.sqrt(X*X+me*me)-w[K+c]-w[ee+c],O.linLogMode?O.outboundAttractionDistribution?J>0&&(ne=-ve*et*Math.log(1+J)/J/w[K+s]):J>0&&(ne=-ve*et*Math.log(1+J)/J):O.outboundAttractionDistribution?J>0&&(ne=-ve*et/w[K+s]):J>0&&(ne=-ve*et)):(J=Math.sqrt(Math.pow(X,2)+Math.pow(me,2)),O.linLogMode?O.outboundAttractionDistribution?J>0&&(ne=-ve*et*Math.log(1+J)/J/w[K+s]):J>0&&(ne=-ve*et*Math.log(1+J)/J):O.outboundAttractionDistribution?(J=1,ne=-ve*et/w[K+s]):(J=1,ne=-ve*et)),J>0&&(w[K+t]+=X*ne,w[K+n]+=me*ne,w[ee+t]-=X*ne,w[ee+n]-=me*ne);var mr,ir,Er,Lt,Sr,or;if(Ye===!0)for(_=0;_<Ce;_+=$)w[_+l]!==1&&(mr=Math.sqrt(Math.pow(w[_+t],2)+Math.pow(w[_+n],2)),mr>I&&(w[_+t]=w[_+t]*I/mr,w[_+n]=w[_+n]*I/mr),ir=w[_+s]*Math.sqrt((w[_+i]-w[_+t])*(w[_+i]-w[_+t])+(w[_+o]-w[_+n])*(w[_+o]-w[_+n])),Er=Math.sqrt((w[_+i]+w[_+t])*(w[_+i]+w[_+t])+(w[_+o]+w[_+n])*(w[_+o]+w[_+n]))/2,Lt=.1*Math.log(1+Er)/(1+Math.sqrt(ir)),Sr=w[_+r]+w[_+t]*(Lt/O.slowDown),w[_+r]=Sr,or=w[_+e]+w[_+n]*(Lt/O.slowDown),w[_+e]=or);else for(_=0;_<Ce;_+=$)w[_+l]!==1&&(ir=w[_+s]*Math.sqrt((w[_+i]-w[_+t])*(w[_+i]-w[_+t])+(w[_+o]-w[_+n])*(w[_+o]-w[_+n])),Er=Math.sqrt((w[_+i]+w[_+t])*(w[_+i]+w[_+t])+(w[_+o]+w[_+n])*(w[_+o]+w[_+n]))/2,Lt=w[_+a]*Math.log(1+Er)/(1+Math.sqrt(ir)),w[_+a]=Math.min(1,Math.sqrt(Lt*(Math.pow(w[_+t],2)+Math.pow(w[_+n],2))/(1+Math.sqrt(ir)))),Sr=w[_+r]+w[_+t]*(Lt/O.slowDown),w[_+r]=Sr,or=w[_+e]+w[_+n]*(Lt/O.slowDown),w[_+e]=or);return{}},to}var Jt={},ca;function jg(){if(ca)return Jt;ca=1;var r=10,e=3;return Jt.assign=function(t){t=t||{};var n=Array.prototype.slice.call(arguments).slice(1),i,o,s;for(i=0,s=n.length;i<s;i++)if(n[i])for(o in n[i])t[o]=n[i][o];return t},Jt.validateSettings=function(t){return"linLogMode"in t&&typeof t.linLogMode!="boolean"?{message:"the `linLogMode` setting should be a boolean."}:"outboundAttractionDistribution"in t&&typeof t.outboundAttractionDistribution!="boolean"?{message:"the `outboundAttractionDistribution` setting should be a boolean."}:"adjustSizes"in t&&typeof t.adjustSizes!="boolean"?{message:"the `adjustSizes` setting should be a boolean."}:"edgeWeightInfluence"in t&&typeof t.edgeWeightInfluence!="number"?{message:"the `edgeWeightInfluence` setting should be a number."}:"scalingRatio"in t&&!(typeof t.scalingRatio=="number"&&t.scalingRatio>=0)?{message:"the `scalingRatio` setting should be a number >= 0."}:"strongGravityMode"in t&&typeof t.strongGravityMode!="boolean"?{message:"the `strongGravityMode` setting should be a boolean."}:"gravity"in t&&!(typeof t.gravity=="number"&&t.gravity>=0)?{message:"the `gravity` setting should be a number >= 0."}:"slowDown"in t&&!(typeof t.slowDown=="number"||t.slowDown>=0)?{message:"the `slowDown` setting should be a number >= 0."}:"barnesHutOptimize"in t&&typeof t.barnesHutOptimize!="boolean"?{message:"the `barnesHutOptimize` setting should be a boolean."}:"barnesHutTheta"in t&&!(typeof t.barnesHutTheta=="number"&&t.barnesHutTheta>=0)?{message:"the `barnesHutTheta` setting should be a number >= 0."}:null},Jt.graphToByteArrays=function(t,n){var i=t.order,o=t.size,s={},a,c=new Float32Array(i*r),l=new Float32Array(o*e);return a=0,t.forEachNode(function(d,f){s[d]=a,c[a]=f.x,c[a+1]=f.y,c[a+2]=0,c[a+3]=0,c[a+4]=0,c[a+5]=0,c[a+6]=1,c[a+7]=1,c[a+8]=f.size||1,c[a+9]=f.fixed?1:0,a+=r}),a=0,t.forEachEdge(function(d,f,h,g,y,C,b){var m=s[h],A=s[g],v=n(d,f,h,g,y,C,b);c[m+6]+=v,c[A+6]+=v,l[a]=m,l[a+1]=A,l[a+2]=v,a+=e}),{nodes:c,edges:l}},Jt.assignLayoutChanges=function(t,n,i){var o=0;t.updateEachNodeAttributes(function(s,a){return a.x=n[o],a.y=n[o+1],o+=r,i?i(s,a):a})},Jt.readGraphPositions=function(t,n){var i=0;t.forEachNode(function(o,s){n[i]=s.x,n[i+1]=s.y,i+=r})},Jt.collectLayoutChanges=function(t,n,i){for(var o=t.nodes(),s={},a=0,c=0,l=n.length;a<l;a+=r){if(i){var d=Object.assign({},t.getNodeAttributes(o[c]));d.x=n[a],d.y=n[a+1],d=i(o[c],d),s[o[c]]={x:d.x,y:d.y}}else s[o[c]]={x:n[a],y:n[a+1]};c++}return s},Jt.createWorker=function(n){var i=window.URL||window.webkitURL,o=n.toString(),s=i.createObjectURL(new Blob(["("+o+").call(this);"],{type:"text/javascript"})),a=new Worker(s);return i.revokeObjectURL(s),a},Jt}var ro,la;function Bg(){return la||(la=1,ro={linLogMode:!1,outboundAttractionDistribution:!1,adjustSizes:!1,edgeWeightInfluence:1,scalingRatio:1,strongGravityMode:!1,gravity:1,slowDown:1,barnesHutOptimize:!1,barnesHutTheta:.5}),ro}var no,ua;function Fg(){if(ua)return no;ua=1;var r=li(),e=Wc().createEdgeWeightGetter,t=Wg(),n=jg(),i=Bg();function o(c,l,d){if(!r(l))throw new Error("graphology-layout-forceatlas2: the given graph is not a valid graphology instance.");typeof d=="number"&&(d={iterations:d});var f=d.iterations;if(typeof f!="number")throw new Error("graphology-layout-forceatlas2: invalid number of iterations.");if(f<=0)throw new Error("graphology-layout-forceatlas2: you should provide a positive number of iterations.");var h=e("getEdgeWeight"in d?d.getEdgeWeight:"weight").fromEntry,g=typeof d.outputReducer=="function"?d.outputReducer:null,y=n.assign({},i,d.settings),C=n.validateSettings(y);if(C)throw new Error("graphology-layout-forceatlas2: "+C.message);var b=n.graphToByteArrays(l,h),m;for(m=0;m<f;m++)t(y,b.nodes,b.edges);if(c){n.assignLayoutChanges(l,b.nodes,g);return}return n.collectLayoutChanges(l,b.nodes)}function s(c){var l=typeof c=="number"?c:c.order;return{barnesHutOptimize:l>2e3,strongGravityMode:!0,gravity:.05,scalingRatio:10,slowDown:1+Math.log(l)}}var a=o.bind(null,!1);return a.assign=o.bind(null,!0),a.inferSettings=s,no=a,no}var Vg=Fg();const da=Do(Vg),Kg=["centrality_score","centrality","pagerank","page_rank","betweenness","closeness","eigenvector","degree","score"];function Hg(r){return r==null?"":String(r)}function qg(r){const e=typeof r=="number"?r:typeof r=="string"&&r.trim()?Number(r):NaN;return Number.isFinite(e)?e:null}function fa(r){for(const e of Kg){const t=qg(r.data[e]);if(t!==null)return t}return null}function ha(r,e){for(const t of e){const n=r[t];if(typeof n=="string"&&n.trim())return n}return null}function Mo(r,e){const t=r[e];return t&&typeof t=="object"&&!Array.isArray(t)?t:null}function pa(r){return Array.isArray(r)?r.filter(e=>typeof e=="string"||typeof e=="number").map(e=>String(e).trim()).filter(Boolean):[]}function Yg(r){const e=Mo(r.data,"metadata");return ha(r.data,["description","summary","content"])??(e?ha(e,["description","summary","content"]):null)}function Xg(r){const e=pa(r.data.exports);if(e.length>0)return e;const t=Mo(r.data,"metadata");return t?pa(t.exports):[]}function ga(r,e){for(const t of e){const n=r[t];if(typeof n=="boolean")return n;if(typeof n=="string"){const i=n.trim().toLowerCase();if(["true","yes","1"].includes(i))return!0;if(["false","no","0"].includes(i))return!1}}return null}function Bc(r,e){var i;const t=Mo(r.data,"metadata"),n=ga(r.data,["orphan","is_orphan","isOrphan","dead_code","deadCode"])??(t?ga(t,["orphan","is_orphan","isOrphan","dead_code","deadCode"]):null);return n!==null?n:(((i=e==null?void 0:e.get(r.id))==null?void 0:i.inDegree)??1)===0}function Jg(r){var n,i;const e=((n=r.data)==null?void 0:n.kind)??((i=r.data)==null?void 0:i.type)??r.label,t=typeof e=="string"?e.toLowerCase():"";return t==="imports"||t==="import"||t==="imports_from"?"imports":t==="defines"||t==="defined_in"||t==="contains"?"defines":"references"}function Zg(r,e){return r==="imports"?e==="incoming"?"imported by":"imports":r==="defines"?e==="incoming"?"defined by":"defines":e==="incoming"?"referenced by":"references"}function Qg(r,e,t,n){const i=new Map(e.map(l=>[l.id,l])),o=[];for(const l of t){const d=l.source===r.id?"outgoing":l.target===r.id?"incoming":null;if(!d)continue;const f=d==="outgoing"?l.target:l.source,h=i.get(f),g=Jg(l);o.push({id:l.id,kind:g,direction:d,label:Zg(g,d),edgeLabel:l.label,nodeId:f,nodeLabel:(h==null?void 0:h.label)??f})}const s=(l,d)=>l.kind.localeCompare(d.kind)||l.nodeLabel.localeCompare(d.nodeLabel)||l.nodeId.localeCompare(d.nodeId),a=o.filter(l=>l.direction==="incoming").sort(s),c=o.filter(l=>l.direction==="outgoing").sort(s);return{description:Yg(r),exports:Xg(r),orphan:Bc(r,n),incoming:a,outgoing:c,whereUsed:a}}function em(r,e){const t=new Map;for(const n of r)t.set(n.id,{degree:0,inDegree:0,outDegree:0,score:fa(n)??0});for(const n of e){const i=t.get(n.source),o=t.get(n.target);i&&(i.outDegree+=1,i.degree+=1),o&&(o.inDegree+=1,o.degree+=1)}for(const n of r){const i=t.get(n.id);i&&(i.score=fa(n)??i.degree)}return t}function tm(r,e,t){const n=t.get(r.id),i=t.get(e.id),o=((i==null?void 0:i.score)??0)-((n==null?void 0:n.score)??0);if(o!==0)return o;const s=((i==null?void 0:i.degree)??0)-((n==null?void 0:n.degree)??0);if(s!==0)return s;const a=r.label.localeCompare(e.label);return a!==0?a:r.id.localeCompare(e.id)}function rm(r,e){const t=r.map(o=>{var s;return((s=e.get(o.id))==null?void 0:s.inDegree)??0});return Math.max(0,...t)<=0?new Map(r.map(o=>[o.id,1])):[...new Set(t)].sort((o,s)=>o-s).length===1?new Map(r.map(o=>[o.id,1])):new Map(r.map(o=>{var c;const s=((c=e.get(o.id))==null?void 0:c.inDegree)??0;if(s<=0)return[o.id,1];const a=t.filter(l=>l<=s).length/t.length;return a>.95?[o.id,2]:a>.8?[o.id,1.5]:a>.5?[o.id,1.25]:[o.id,1]}))}function ma(r){const e=r.id??r.rid??r._id??r.uid;return e==null?null:String(e)}function va(r,e){const t=r.label??r.name??r.title;return t!=null?String(t):e}function nm(r){const e=r.source??r.from??r.src??r.start,t=r.target??r.to??r.dst??r.end;return e==null||t===null||t===void 0?null:{source:String(e),target:String(t)}}function im(r){const e=new Map,t=new Map;for(const n of r.result.records){if(n.nodes)for(const o of Object.values(n.nodes)){if(!o||typeof o!="object")continue;const s=o,a=ma(s);a&&(e.has(a)||e.set(a,{id:a,label:va(s,a),data:s}))}if(n.edges)for(const o of Object.values(n.edges)){if(!o||typeof o!="object")continue;const s=o,a=nm(s);if(!a)continue;const c=s.label??s.type??s.rel,l=`${a.source}->${a.target}:${Hg(c)}`;t.has(l)||t.set(l,{id:l,source:a.source,target:a.target,label:c!==void 0?String(c):void 0,data:s})}const i=n.values;if(i&&typeof i=="object"){const o=i.kind;if(o==="node"){const s=ma(i);s&&!e.has(s)&&e.set(s,{id:s,label:va(i,s),data:i})}else if(o==="edge"){const s=i.from_rid??i.from,a=i.to_rid??i.to;if(s!=null&&a!==void 0&&a!==null){const c=String(s),l=String(a),d=i.label??i.type??i.rel,h=`e:${i.rid??i.id??`${c}->${l}`}`;t.has(h)||t.set(h,{id:h,source:c,target:l,label:d!==void 0?String(d):void 0,data:i})}}}}return{nodes:[...e.values()],edges:[...t.values()]}}function uy(r){var t;const e=(t=r.result)==null?void 0:t.records;return!e||e.length===0?!1:e.some(n=>{if(n.nodes&&Object.keys(n.nodes).length>0||n.edges&&Object.keys(n.edges).length>0)return!0;const i=n.values;return!!(i&&(i.kind==="node"||i.kind==="edge"))})}function om(r){let e=r>>>0;return()=>{e=e+1831565813>>>0;let t=e;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}}function sm(r,e,t=Mg){try{if(!t||typeof t.assign!="function")throw new Error("Leiden community detection unavailable");return t.assign(r,{attributes:{community:"community"},rng:e}),"leiden"}catch{return Ug.assign(r,{nodeCommunityAttribute:"community",rng:e}),"louvain"}}function am(r,e){const t=new Map;if(r.length===0)return t;if(r.length===1)return t.set(r[0].id,{x:50,y:50,community:0}),t;const n=new qe({type:"undirected",multi:!1,allowSelfLoops:!0}),i=om(r.length*131+e.length),o=Math.PI*2;r.forEach((C,b)=>{const m=b/r.length*o+i()*.1;n.addNode(C.id,{x:Math.cos(m),y:Math.sin(m)})});for(const C of e)!n.hasNode(C.source)||!n.hasNode(C.target)||C.source!==C.target&&(n.hasEdge(C.source,C.target)||n.addEdge(C.source,C.target));if(n.size===0){const C=Math.ceil(Math.sqrt(r.length));return r.forEach((b,m)=>{const A=Math.floor(m/C),v=m%C;t.set(b.id,{x:10+v/Math.max(1,C-1)*80,y:10+A/Math.max(1,C-1)*80,community:m})}),t}sm(n,i);const s=da.inferSettings(n);da.assign(n,{iterations:r.length>200?120:200,settings:{...s,strongGravityMode:!0,gravity:1.2,scalingRatio:10,barnesHutOptimize:r.length>500}});let a=1/0,c=-1/0,l=1/0,d=-1/0;n.forEachNode((C,b)=>{b.x<a&&(a=b.x),b.x>c&&(c=b.x),b.y<l&&(l=b.y),b.y>d&&(d=b.y)});const f=c-a||1,h=d-l||1,g=5,y=100-g*2;return n.forEachNode((C,b)=>{t.set(C,{x:g+(b.x-a)/f*y,y:g+(b.y-l)/h*y,community:b.community??0})}),t}function No(r,e=!0){const t=[200,25,145,290,50,175,320,95,0,260,220,130],n=r<t.length?t[r]:(t[0]+r*137.508)%360,i=e?62:58,o=e?60:48;return`hsl(${n.toFixed(0)} ${i}% ${o}%)`}function ei(r){switch(r){case"tale":return"#ff2056";case"character":return"#7dd3fc";case"location":return"#a3e635";case"object":return"#fbbf24";case"archetype":return"#a78bfa";default:return"#94a3b8"}}function cm(r){return r==="tale"?8:r==="character"?5:r==="location"||r==="object"?4:3}function Fc(r,e){const t=Math.max(.35,Math.min(1.25,cm(r)*.14));return Math.max(.35,Math.min(2.5,t*e))}const Vc=3.4;function lm(r,e){return Fc(r,e)*Vc}const um="#e2e8f0";function Kc(r){return Math.min(7,2.2+Math.sqrt(Math.max(1,r))*.7)}function dm(r){return Kc(r)*Vc}function fm(r,e,t){const n=e/100,i=t/100,o=(1-Math.abs(2*i-1))*n,s=(r%360+360)%360/60,a=o*(1-Math.abs(s%2-1));let c=0,l=0,d=0;s>=0&&s<1?[c,l,d]=[o,a,0]:s<2?[c,l,d]=[a,o,0]:s<3?[c,l,d]=[0,o,a]:s<4?[c,l,d]=[0,a,o]:s<5?[c,l,d]=[a,0,o]:[c,l,d]=[o,0,a];const f=i-o/2;return{r:Math.round((c+f)*255),g:Math.round((l+f)*255),b:Math.round((d+f)*255)}}function Hc(r){const e=r.match(/hsl\(\s*([\d.]+)\s*[, ]\s*([\d.]+)%\s*[, ]\s*([\d.]+)%/i);return e?fm(Number(e[1]),Number(e[2]),Number(e[3])):null}function hm({r,g:e,b:t}){return`rgb(${r}, ${e}, ${t})`}function pm(r,e=!0){const t=No(r,e),n=Hc(t);return n?hm(n):t}function Ur(r,e){const t=Math.max(0,Math.min(1,e)),n=r.startsWith("hsl")?Hc(r):null;if(n)return`rgba(${n.r}, ${n.g}, ${n.b}, ${t})`;const i=r.match(/rgb\(\s*([\d.]+)[, ]+([\d.]+)[, ]+([\d.]+)/i);if(i)return`rgba(${i[1]}, ${i[2]}, ${i[3]}, ${t})`;const o=r.replace("#","");if(/^[0-9a-f]{6}$/i.test(o)){const s=parseInt(o.slice(0,2),16),a=parseInt(o.slice(2,4),16),c=parseInt(o.slice(4,6),16);return`rgba(${s}, ${a}, ${c}, ${t})`}return r}const gm="#d6a72c",mm="#f4c84a";function vm(r){var d,f,h,g;const{nodes:e,edges:t,layout:n,sizeScales:i,orphanIds:o,dark:s=!0,edgeColor:a="#3a424d",bundledCurvatures:c}=r,l=new qe({type:"directed",multi:!0,allowSelfLoops:!0});for(const y of e){if(l.hasNode(y.id))continue;const C=String(y.data.node_type??"node"),b=i.get(y.id)??1,m=n.get(y.id),A=y.data.__supernode===!0,v=typeof y.data.__memberCount=="number"?y.data.__memberCount:0,p=A?dm(v):lm(C,b),E=m?pm(m.community,s):ei(C);l.addNode(y.id,{x:(m==null?void 0:m.x)??50,y:-((m==null?void 0:m.y)??50),size:p,baseSize:p,color:E,mutedColor:Ur(E,.14),borderColor:A?um:ei(C),label:y.label,nodeType:C,community:(m==null?void 0:m.community)??-1,orphan:o.has(y.id),isSupernode:A,memberCount:v,type:"border"})}for(const y of t){if(!l.hasNode(y.source)||!l.hasNode(y.target)||l.hasEdge(y.id))continue;const C=((d=n.get(y.source))==null?void 0:d.community)??-1,b=((f=n.get(y.target))==null?void 0:f.community)??-1,m=((h=y.data)==null?void 0:h.__aggregated)===!0,A=typeof((g=y.data)==null?void 0:g.weight)=="number"?y.data.weight:1;l.addEdgeWithKey(y.id,y.source,y.target,{size:m?Math.min(6,1+Math.log2(A+1)):1,color:Ur(a,.34),edgeLabel:y.label??"",label:"",crossCommunity:C!==b,curvature:(c==null?void 0:c.get(y.id))??0,type:"line"})}return l}function ym(r,e,t={}){const{padding:n=2.5,dark:i=!0}=t,o=new Map;for(const s of r){const a=e.get(s.id);if(!a)continue;const c=o.get(a.community);c?(c.minX=Math.min(c.minX,a.x),c.minY=Math.min(c.minY,a.y),c.maxX=Math.max(c.maxX,a.x),c.maxY=Math.max(c.maxY,a.y),c.count+=1):o.set(a.community,{minX:a.x,minY:a.y,maxX:a.x,maxY:a.y,count:1})}return[...o.entries()].sort((s,a)=>s[0]-a[0]).map(([s,a])=>{const c=No(s,i);return{community:s,count:a.count,tint:c,fill:Ur(c,.08),stroke:Ur(c,.5),minX:a.minX-n,minY:a.minY-n,maxX:a.maxX+n,maxY:a.maxY+n,cx:(a.minX+a.maxX)/2,cy:(a.minY+a.maxY)/2}})}function ya(r,e,t,n,i){const o=t-r,s=n-e;let a=1;return o>0?a=Math.min(a,(i.maxX-r)/o):o<0&&(a=Math.min(a,(i.minX-r)/o)),s>0?a=Math.min(a,(i.maxY-e)/s):s<0&&(a=Math.min(a,(i.minY-e)/s)),a=Math.max(0,Math.min(1,a)),{x:r+o*a,y:e+s*a}}function bm(r,e,t){const n=new Map(t.map(o=>[o.community,o])),i=[];for(const o of r){const s=e.get(o.source),a=e.get(o.target);if(!s||!a||s.community===a.community)continue;const c=n.get(s.community),l=n.get(a.community);if(!c||!l)continue;const d=ya(s.x,s.y,a.x,a.y,c),f=ya(a.x,a.y,s.x,s.y,l);i.push({id:o.id,source:o.source,target:o.target,label:o.label,sourceCommunity:s.community,targetCommunity:a.community,x1:d.x,y1:d.y,x2:f.x,y2:f.y})}return i}const wm=36,_m=28,xm=36;function km(r,e,t){const{focus:n,focusId:i,selectedNodeId:o,pulse:s,colors:a}=t,c=i!==null,l=i===r,d=n.nodes.has(r),f=!c||d,h=c?l?2.2+s*.38:d?1.58:.9:1,g=l?a.focusNodeStroke:e.orphan?a.warn:o===r?a.selectedNodeStroke:e.borderColor,y=e.isSupernode||c&&(l||n.nodes.size<=xm&&d);return{size:e.baseSize*h,color:f?e.color:e.mutedColor,borderColor:g,label:y?e.label.slice(0,wm):"",forceLabel:y,zIndex:l?3:e.isSupernode||d?2:1,hidden:!1}}function Em(r,e,t){const{focus:n,focusId:i,colors:o,groupInBox:s,bundle:a}=t,c=i!==null,l=n.edges.has(r),d=e.curvature,f=a&&Math.abs(d)>1e-4?"curved":"line";return s&&e.crossCommunity&&!l?{size:e.size,color:e.color,label:"",forceLabel:!1,zIndex:0,hidden:!0,type:f,curvature:d}:c?l?{size:2.2,color:o.focusEdge,label:e.edgeLabel?e.edgeLabel.slice(0,_m):"",forceLabel:!!e.edgeLabel,zIndex:2,hidden:!1,type:f,curvature:d}:{size:e.size,color:Ur(o.edge,.055),label:"",forceLabel:!1,zIndex:0,hidden:!1,type:f,curvature:d}:{size:e.size,color:Ur(o.edge,.34),label:"",forceLabel:!1,zIndex:0,hidden:!1,type:f,curvature:d}}const Sm={stiffness:.1,stepSize:.1,cycles:6,iterations:60,iterationRate:2/3,subdivisionRate:2,compatibilityThreshold:.6},io=1500,Wr=1e-6;function ln(r,e){return Math.hypot(r.x-e.x,r.y-e.y)}function ti(r,e){return{x:(r.x+e.x)/2,y:(r.y+e.y)/2}}function ba(r,e){const t=e+2,n=[0];for(let a=1;a<r.length;a++)n.push(n[a-1]+ln(r[a],r[a-1]));const i=n[n.length-1];if(i<Wr)return Array.from({length:t},()=>({...r[0]}));const o=[];let s=1;for(let a=0;a<t;a++){const c=i*a/(t-1);for(;s<r.length-1&&n[s]<c;)s++;const l=n[s-1],d=n[s]-l||1,f=Math.max(0,Math.min(1,(c-l)/d));o.push({x:r[s-1].x+f*(r[s].x-r[s-1].x),y:r[s-1].y+f*(r[s].y-r[s-1].y)})}return o}function Cm(r,e){const t=(r.t.x-r.s.x)*(e.t.x-e.s.x)+(r.t.y-r.s.y)*(e.t.y-e.s.y);return Math.abs(t/(r.len*e.len))}function Am(r,e){const t=(r.len+e.len)/2;return 2/(t/Math.min(r.len,e.len)+Math.max(r.len,e.len)/t)}function $m(r,e){const t=(r.len+e.len)/2;return t/(t+ln(ti(r.s,r.t),ti(e.s,e.t)))}function wa(r,e){const t=e.len*e.len,n=((e.s.y-r.y)*(e.s.y-e.t.y)-(e.s.x-r.x)*(e.t.x-e.s.x))/t;return{x:e.s.x+n*(e.t.x-e.s.x),y:e.s.y+n*(e.t.y-e.s.y)}}function _a(r,e){const t=wa(e.s,r),n=wa(e.t,r),i=ti(t,n),o=ln(t,n);return o<Wr?0:Math.max(0,1-2*ln(i,ti(e.s,e.t))/o)}function Dm(r,e){return Math.min(_a(r,e),_a(e,r))}function Im(r,e){return Cm(r,e)*Am(r,e)*$m(r,e)*Dm(r,e)}function Lm(r,e){const t=r.map(()=>[]);for(let n=0;n<r.length;n++)for(let i=n+1;i<r.length;i++)Im(r[n],r[i])>=e&&(t[n].push(i),t[i].push(n));return t}function Tm(r,e,t={}){const n={...Sm,...t},i=new Map(r.map(h=>[h.id,{x:h.x,y:h.y}])),o=new Map,s=[];for(const h of e){const g=i.get(h.source),y=i.get(h.target);if(!g||!y||(o.set(h.id,[{...g},{...y}]),h.source===h.target))continue;const C=ln(g,y);C<Wr||s.push({id:h.id,s:{...g},t:{...y},len:C})}if(s.length<2)return o;const a=s.map(h=>[{...h.s},{...h.t}]),c=Lm(s,n.compatibilityThreshold);let l=1,d=n.stepSize,f=n.iterations;for(let h=0;h<a.length;h++)a[h]=ba(a[h],l);for(let h=0;h<n.cycles;h++){const g=Math.max(1,Math.round(f));for(let y=0;y<g;y++){const C=s.map((b,m)=>Gm(m,a,c,s[m].len,l,d,n.stiffness));for(let b=0;b<s.length;b++)for(let m=1;m<=l;m++)a[b][m].x+=C[b][m].x,a[b][m].y+=C[b][m].y}d*=.5,l*=n.subdivisionRate,f*=n.iterationRate;for(let y=0;y<a.length;y++)a[y]=ba(a[y],l)}for(let h=0;h<s.length;h++)o.set(s[h].id,a[h].map(g=>({x:g.x,y:g.y})));return o}function Gm(r,e,t,n,i,o,s){const a=s/(n*(i+1)),c=e[r],l=[{x:0,y:0}];for(let d=1;d<=i;d++){const f=c[d-1],h=c[d],g=c[d+1];let y=a*(f.x-2*h.x+g.x),C=a*(f.y-2*h.y+g.y);for(const b of t[r]){const m=e[b][d],A=m.x-h.x,v=m.y-h.y;if(Math.abs(A)>Wr||Math.abs(v)>Wr){const p=Math.hypot(A,v);y+=A/p,C+=v/p}}l.push({x:o*y,y:o*C})}return l.push({x:0,y:0}),l}function Rm(r){if(r.length<3)return 0;const e=r[0],t=r[r.length-1],n=t.x-e.x,i=t.y-e.y,o=Math.hypot(n,i);if(o<Wr)return 0;let s=0;for(let c=1;c<r.length-1;c++){const l=r[c].x-e.x,d=r[c].y-e.y,f=(l*-i+d*n)/o;Math.abs(f)>Math.abs(s)&&(s=f)}const a=2*s/o;return Math.max(-1,Math.min(1,a))}const Po="__cluster__:";function xa(r){return`${Po}${r}`}function qc(r){return r.startsWith(Po)}function Om(r){if(!qc(r))return null;const e=Number(r.slice(Po.length));return Number.isFinite(e)?e:null}function Yc(r,e){const t=new Map;for(const n of r){const i=e.get(n.id);if(!i)continue;const o=t.get(i.community);o?o.push(n.id):t.set(i.community,[n.id])}return t}const ka=(r,e,t)=>({nodes:r,edges:e,layout:t,supernodes:new Map,collapsedMembers:new Map});function zm(r,e,t,n){if(n.size===0)return ka(r,e,t);const i=Yc(r,t),o=new Set;for(const g of n){const y=i.get(g);y&&y.length>0&&o.add(g)}if(o.size===0)return ka(r,e,t);const s=new Map,a=new Map,c=[],l=new Map;for(const g of r){const y=t.get(g.id);if(y&&o.has(y.community)){s.set(g.id,xa(y.community));continue}c.push(g),y&&l.set(g.id,y)}for(const g of o){const y=i.get(g),C=xa(g);let b=0,m=0,A=0;for(const v of y){const p=t.get(v);p&&(b+=p.x,m+=p.y,A+=1)}a.set(C,{community:g,memberIds:y,size:y.length}),c.push({id:C,label:`cluster ${g} · ${y.length}`,data:{node_type:"cluster",__supernode:!0,__community:g,__memberCount:y.length}}),l.set(C,{x:A?b/A:50,y:A?m/A:50,community:g})}const d=g=>s.get(g)??g,f=[],h=new Map;for(const g of e){const y=d(g.source),C=d(g.target);if(!(y!==g.source||C!==g.target)){f.push(g);continue}if(y===C)continue;const m=`${y} ${C}`,A=h.get(m);A?(A.weight+=1,A.members.push(g.id)):h.set(m,{source:y,target:C,weight:1,members:[g.id]})}for(const[g,y]of h)f.push({id:`__agg__:${g}`,source:y.source,target:y.target,label:y.weight>1?`×${y.weight}`:void 0,data:{__aggregated:!0,weight:y.weight,members:y.members}});return{nodes:c,edges:f,layout:l,supernodes:a,collapsedMembers:s}}const Xc={name:"table-2",size:24,node:[["path",{d:"M3 9h18"}],["path",{d:"M9 3v18"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}]]};Xc.node;function Mm(r,e){let t=Ze(e,["$$slots","$$events","$$legacy"]);at(r,it(()=>t,{get icon(){return Xc}}))}const Jc={name:"info",size:24,node:[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"M12 16v-4"}],["path",{d:"M12 8h.01"}]]};Jc.node;function Nm(r,e){let t=Ze(e,["$$slots","$$events","$$legacy"]);at(r,it(()=>t,{get icon(){return Jc}}))}const Zc={name:"maximize-2",size:24,node:[["path",{d:"M15 3h6v6"}],["path",{d:"m21 3-7 7"}],["path",{d:"m3 21 7-7"}],["path",{d:"M9 21H3v-6"}]]};Zc.node;function Pm(r,e){let t=Ze(e,["$$slots","$$events","$$legacy"]);at(r,it(()=>t,{get icon(){return Zc}}))}const Qc={name:"code-xml",size:24,node:[["path",{d:"m18 16 4-4-4-4"}],["path",{d:"m6 8-4 4 4 4"}],["path",{d:"m14.5 4-5 16"}]],aliases:["code-2"]};Qc.node;function Um(r,e){let t=Ze(e,["$$slots","$$events","$$legacy"]);at(r,it(()=>t,{get icon(){return Qc}}))}const el={name:"route",size:24,node:[["circle",{cx:"6",cy:"19",r:"3"}],["path",{d:"M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15"}],["circle",{cx:"18",cy:"5",r:"3"}]]};el.node;function Wm(r,e){let t=Ze(e,["$$slots","$$events","$$legacy"]);at(r,it(()=>t,{get icon(){return el}}))}const tl={name:"zoom-in",size:24,node:[["circle",{cx:"11",cy:"11",r:"8"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11"}]]};tl.node;function jm(r,e){let t=Ze(e,["$$slots","$$events","$$legacy"]);at(r,it(()=>t,{get icon(){return tl}}))}const rl={name:"zoom-out",size:24,node:[["circle",{cx:"11",cy:"11",r:"8"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11"}]]};rl.node;function Bm(r,e){let t=Ze(e,["$$slots","$$events","$$legacy"]);at(r,it(()=>t,{get icon(){return rl}}))}const nl={name:"group",size:24,node:[["path",{d:"M3 7V5c0-1.1.9-2 2-2h2"}],["path",{d:"M17 3h2c1.1 0 2 .9 2 2v2"}],["path",{d:"M21 17v2c0 1.1-.9 2-2 2h-2"}],["path",{d:"M7 21H5c-1.1 0-2-.9-2-2v-2"}],["rect",{width:"7",height:"5",x:"7",y:"7",rx:"1"}],["rect",{width:"7",height:"5",x:"10",y:"12",rx:"1"}]]};nl.node;function Ea(r,e){let t=Ze(e,["$$slots","$$events","$$legacy"]);at(r,it(()=>t,{get icon(){return nl}}))}const il={name:"spline",size:24,node:[["circle",{cx:"19",cy:"5",r:"2"}],["circle",{cx:"5",cy:"19",r:"2"}],["path",{d:"M5 17A12 12 0 0 1 17 5"}]]};il.node;function Fm(r,e){let t=Ze(e,["$$slots","$$events","$$legacy"]);at(r,it(()=>t,{get icon(){return il}}))}const ol={name:"boxes",size:24,node:[["path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z"}],["path",{d:"m7 16.5-4.74-2.85"}],["path",{d:"m7 16.5 5-3"}],["path",{d:"M7 16.5v5.17"}],["path",{d:"M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z"}],["path",{d:"m17 16.5-5-3"}],["path",{d:"m17 16.5 4.74-2.85"}],["path",{d:"M17 16.5v5.17"}],["path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z"}],["path",{d:"M12 8 7.26 5.15"}],["path",{d:"m12 8 4.74-2.85"}],["path",{d:"M12 13.5V8"}]]};ol.node;function Sa(r,e){let t=Ze(e,["$$slots","$$events","$$legacy"]);at(r,it(()=>t,{get icon(){return ol}}))}var Vm=he('<div class="flex-1 grid place-items-center text-fg-3 text-[12px] font-mono p-6 svelte-gt9p7f">No graph shape in this result.</div>'),Km=he('<button type="button" class="text-fg-3 hover:text-fg-1 cursor-pointer svelte-gt9p7f" aria-label="Clear filter"><!></button>'),Hm=he('<div class="inline-flex items-center gap-1.5 border border-line-1 rounded px-2 py-1 bg-bg-0 svelte-gt9p7f"><!> <input type="text" placeholder="filter by label…" class="bg-transparent text-fg-1 text-[11px] outline-none w-[160px] placeholder:text-fg-3 svelte-gt9p7f"/> <!></div> <label class="inline-flex items-center gap-1.5 text-fg-3 svelte-gt9p7f"><!> <span class="svelte-gt9p7f">limit:</span> <select class="bg-bg-1 text-fg-1 border border-line-1 rounded px-1 py-0.5 svelte-gt9p7f"><option class="svelte-gt9p7f">500</option><option class="svelte-gt9p7f">1k</option><option class="svelte-gt9p7f">2k</option><option class="svelte-gt9p7f">5k</option><option class="svelte-gt9p7f">10k</option><option class="svelte-gt9p7f">25k</option><option class="svelte-gt9p7f">50k</option></select></label>',1),qm=he('<div class="inline-flex items-center overflow-hidden rounded border border-line-1 bg-bg-0 svelte-gt9p7f"><button type="button" class="inline-flex h-6 w-7 items-center justify-center text-fg-3 hover:bg-bg-1 hover:text-fg-0 disabled:opacity-40 svelte-gt9p7f" title="Zoom out" aria-label="Zoom out"><!></button> <button type="button" class="inline-flex h-6 min-w-12 items-center justify-center border-x border-line-1 px-2 text-[10px] text-fg-3 hover:bg-bg-1 hover:text-fg-0 svelte-gt9p7f" title="Fit graph" aria-label="Fit graph"> </button> <button type="button" class="inline-flex h-6 w-7 items-center justify-center text-fg-3 hover:bg-bg-1 hover:text-fg-0 disabled:opacity-40 svelte-gt9p7f" title="Zoom in" aria-label="Zoom in"><!></button></div>'),Ym=he('<span class="text-warn svelte-gt9p7f"> </span>'),Xm=he('<button type="button"><!> </button>'),Jm=he('<button type="button" title="Group in a box — draw one tinted box per community and route inter-community edges at the borders"><!> groups</button> <button type="button" title="Force-directed edge bundling — collapse parallel edges onto shared trunks to untangle dense subgraphs"><!> bundle</button> <!> <!>',1),Zm=he('<button type="button" class="inline-flex items-center gap-1 h-6 px-2 rounded border border-line-1 text-fg-3 hover:text-fg-1 cursor-pointer svelte-gt9p7f" title="Discard graph query and show the original collection result"><!> reset</button>'),Qm=he('<span class="text-primary-text svelte-gt9p7f"> </span>'),ev=he('<span class="text-warn svelte-gt9p7f" title="More nodes match — raise the limit or narrow the filter to see them"> </span>'),tv=he('<span class="text-fg-2 svelte-gt9p7f"> </span>'),rv=he('<div class="mt-1.5 text-warn svelte-gt9p7f"> </div>'),nv=he('<div class="border-b border-line-1 px-3 py-2 bg-bg-1/20 text-[11px] font-mono svelte-gt9p7f"><div class="flex items-center gap-2 mb-1.5 text-fg-3 svelte-gt9p7f"><span class="svelte-gt9p7f">quick:</span> <button type="button" class="px-1.5 py-0.5 rounded border border-line-1 hover:border-line-2 hover:text-fg-1 cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed svelte-gt9p7f">neighborhood of selected</button> <button type="button" class="px-1.5 py-0.5 rounded border border-line-1 hover:border-line-2 hover:text-fg-1 cursor-pointer svelte-gt9p7f">top centrality</button> <button type="button" class="inline-flex items-center gap-1 px-1.5 py-0.5 rounded border border-line-1 hover:border-line-2 hover:text-fg-1 cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed svelte-gt9p7f" title="Run shortest path in reddb"><!> shortest path</button></div> <div class="mb-1.5 grid grid-cols-[1fr_1fr_auto_auto] gap-2 svelte-gt9p7f"><input type="text" placeholder="from label…" class="h-6 rounded border border-line-1 bg-bg-0 px-2 text-[11px] text-fg-1 outline-none placeholder:text-fg-3 focus:border-accent svelte-gt9p7f"/> <input type="text" placeholder="to label…" class="h-6 rounded border border-line-1 bg-bg-0 px-2 text-[11px] text-fg-1 outline-none placeholder:text-fg-3 focus:border-accent svelte-gt9p7f"/> <button type="button" class="rounded border border-line-1 px-1.5 text-fg-3 hover:border-line-2 hover:text-fg-1 disabled:opacity-40 disabled:cursor-not-allowed svelte-gt9p7f">use as from</button> <button type="button" class="rounded border border-line-1 px-1.5 text-fg-3 hover:border-line-2 hover:text-fg-1 disabled:opacity-40 disabled:cursor-not-allowed svelte-gt9p7f">use as to</button></div> <div class="flex items-stretch gap-2 svelte-gt9p7f"><textarea spellcheck="false" rows="3" class="flex-1 bg-bg-0 text-fg-1 border border-line-1 rounded px-2 py-1 text-[12px] font-mono outline-none focus:border-accent placeholder:text-fg-3 resize-none svelte-gt9p7f"></textarea> <div class="flex flex-col gap-1.5 svelte-gt9p7f"><button type="button" class="inline-flex items-center gap-1.5 h-7 px-3 rounded bg-primary text-on-primary cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed hover:bg-primary-active svelte-gt9p7f"><!> run <span class="text-[9px] opacity-70 svelte-gt9p7f">⌘↵</span></button></div></div> <!></div>'),iv=he('<div class="border-b border-line-1 bg-warn/10 px-3 py-2 text-[11px] font-mono text-warn flex items-start gap-2 svelte-gt9p7f"><!> <div class="svelte-gt9p7f"><div class="svelte-gt9p7f">WebGL renderer unavailable. Switch to SVG or Table.</div> <div class="mt-0.5 break-words text-fg-3 svelte-gt9p7f"> </div></div></div>'),ov=At('<rect rx="6" stroke-width="1.5" class="svelte-gt9p7f"></rect>'),sv=At('<line stroke="var(--color-line-3)" stroke-width="1" stroke-dasharray="4 3" opacity="0.7" class="svelte-gt9p7f"></line>'),av=At('<svg class="pointer-events-none absolute inset-0 h-full w-full svelte-gt9p7f" aria-hidden="true"><!><!></svg>'),cv=he('<div class="sigma-canvas absolute inset-0 h-full w-full bg-bg-0 svelte-gt9p7f" role="application" tabindex="0"></div> <!>',1),lv=At('<rect rx="1.5" stroke-width="0.18" vector-effect="non-scaling-stroke" class="svelte-gt9p7f"></rect>'),uv=At('<line stroke="currentColor" stroke-width="0.12" stroke-dasharray="0.8 0.6" opacity="0.6" class="text-line-3 svelte-gt9p7f" vector-effect="non-scaling-stroke"></line>'),dv=At('<g class="pointer-events-none svelte-gt9p7f"><!><!></g>'),fv=At('<polyline fill="none" stroke-linejoin="round" class="text-line-3 cursor-pointer hover:text-primary-text svelte-gt9p7f" vector-effect="non-scaling-stroke" role="button" tabindex="0"><title class="svelte-gt9p7f"> </title></polyline>'),hv=At('<line class="text-line-3 cursor-pointer hover:text-primary-text svelte-gt9p7f" vector-effect="non-scaling-stroke" role="button" tabindex="0"><title class="svelte-gt9p7f"> </title></line>'),pv=At('<text fill="#f6d36b" opacity="0.96" font-size="1" font-weight="700" font-family="JetBrains Mono Variable, monospace" paint-order="stroke" stroke="#020617" stroke-width="0.38" class="pointer-events-none select-none svelte-gt9p7f"> </text>'),gv=At("<!><!>",1),mv=At('<circle fill="none" stroke="var(--color-warn)" vector-effect="non-scaling-stroke" class="pointer-events-none svelte-gt9p7f"></circle>'),vv=At('<text font-family="JetBrains Mono Variable, monospace" paint-order="stroke" stroke="#020617" class="pointer-events-none select-none svelte-gt9p7f"> </text>'),yv=At('<!><circle vector-effect="non-scaling-stroke" role="button" tabindex="0"><title class="svelte-gt9p7f"> </title></circle><!>',1),bv=he('<div class="absolute inset-0 overflow-hidden bg-bg-0 svelte-gt9p7f"><svg class="h-full w-full svelte-gt9p7f" viewBox="0 0 100 100" preserveAspectRatio="xMidYMid meet" role="button" tabindex="0"><rect x="0" y="0" width="100" height="100" fill="transparent" class="svelte-gt9p7f"></rect><g class="svelte-gt9p7f"><!><g class="svelte-gt9p7f"></g><g class="svelte-gt9p7f"></g></g></svg></div>'),wv=he('<span class="ml-2 text-warn svelte-gt9p7f">orphan</span>'),_v=he('<tr><td class="px-2 py-1 text-fg-3 svelte-gt9p7f">node</td><td class="px-2 py-1 text-primary-text font-semibold svelte-gt9p7f"> </td><td class="px-2 py-1 text-fg-0 svelte-gt9p7f"> </td><td class="px-2 py-1 text-fg-2 svelte-gt9p7f"> <!></td></tr>'),xv=he('<tr class="border-b border-line-1/60 hover:bg-bg-1/40 cursor-pointer svelte-gt9p7f"><td class="px-2 py-1 text-fg-3 svelte-gt9p7f">edge</td><td class="px-2 py-1 text-fg-2 svelte-gt9p7f"> </td><td class="px-2 py-1 text-fg-0 svelte-gt9p7f"> </td><td class="px-2 py-1 text-fg-2 svelte-gt9p7f"> </td></tr>'),kv=he('<div class="absolute inset-0 overflow-auto svelte-gt9p7f"><table class="w-full border-collapse text-[12px] font-mono svelte-gt9p7f"><thead class="sticky top-0 bg-bg-1 z-10 svelte-gt9p7f"><tr class="border-b border-line-1 text-fg-3 svelte-gt9p7f"><th class="px-2 py-1.5 text-left font-normal whitespace-nowrap svelte-gt9p7f">type</th><th class="px-2 py-1.5 text-left font-normal whitespace-nowrap svelte-gt9p7f">id / rid</th><th class="px-2 py-1.5 text-left font-normal whitespace-nowrap svelte-gt9p7f">label</th><th class="px-2 py-1.5 text-left font-normal whitespace-nowrap svelte-gt9p7f">node_type / endpoints</th></tr></thead><tbody class="svelte-gt9p7f"><!><!></tbody></table></div>'),Ev=he('<span class="inline-flex shrink-0 items-center gap-1 rounded border border-warn/40 bg-warn/10 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wider text-warn svelte-gt9p7f"><!> orphan</span>'),Sv=he(`<button type="button" class="mt-2 inline-flex items-center gap-1.5 rounded border border-line-2 bg-bg-0 px-2 py-1 text-[11px] text-fg-2 hover:border-accent hover:text-fg-0 cursor-pointer svelte-gt9p7f" title="Fold this node's community into a single supernode"><!> </button>`),Cv=he('<span class="max-w-full truncate rounded border border-line-1 bg-bg-0 px-1.5 py-0.5 text-[11px] text-fg-1 svelte-gt9p7f"> </span>'),Av=he('<div class="flex flex-wrap gap-1 svelte-gt9p7f"></div>'),$v=he('<div class="text-fg-3 svelte-gt9p7f">No exports recorded.</div>'),Dv=he('<button type="button" class="grid w-full grid-cols-[82px_1fr] gap-2 rounded border border-line-1 bg-bg-0 px-2 py-1.5 text-left hover:border-line-2 hover:bg-bg-2 svelte-gt9p7f"><span class="text-[10px] uppercase tracking-wider text-fg-3 svelte-gt9p7f"> </span> <span class="min-w-0 svelte-gt9p7f"><span class="block truncate text-fg-0 svelte-gt9p7f"> </span> <span class="block truncate text-[10px] text-fg-3 svelte-gt9p7f"> </span></span></button>'),Iv=he('<div class="space-y-1 svelte-gt9p7f"></div>'),Lv=he('<div class="text-fg-3 svelte-gt9p7f">No inbound uses.</div>'),Tv=he('<button type="button" class="w-full rounded border border-line-1 bg-bg-0 px-2 py-1 text-left hover:border-line-2 hover:bg-bg-2 svelte-gt9p7f"><span class="block truncate text-[10px] text-fg-3 svelte-gt9p7f"> </span> <span class="block truncate text-fg-1 svelte-gt9p7f"> </span></button>'),Gv=he('<div class="rounded border border-line-1 px-2 py-1 text-fg-3 svelte-gt9p7f">none</div>'),Rv=he('<button type="button" class="w-full rounded border border-line-1 bg-bg-0 px-2 py-1 text-left hover:border-line-2 hover:bg-bg-2 svelte-gt9p7f"><span class="block truncate text-[10px] text-fg-3 svelte-gt9p7f"> </span> <span class="block truncate text-fg-1 svelte-gt9p7f"> </span></button>'),Ov=he('<div class="rounded border border-line-1 px-2 py-1 text-fg-3 svelte-gt9p7f">none</div>'),zv=he('<div class="mb-3 svelte-gt9p7f"><div class="flex items-start gap-2 svelte-gt9p7f"><div class="min-w-0 flex-1 svelte-gt9p7f"><div class="text-fg-3 text-[10px] uppercase tracking-wider svelte-gt9p7f">label</div> <div class="break-words text-[13px] font-semibold text-fg-0 svelte-gt9p7f"> </div></div> <!></div> <div class="mt-1 break-all text-primary-text svelte-gt9p7f"> </div> <!></div> <div class="mb-3 border-t border-line-1 pt-3 svelte-gt9p7f"><div class="mb-1 text-fg-3 text-[10px] uppercase tracking-wider svelte-gt9p7f">description</div> <div class="whitespace-pre-wrap break-words text-fg-1 svelte-gt9p7f"> </div></div> <div class="mb-3 border-t border-line-1 pt-3 svelte-gt9p7f"><div class="mb-1.5 flex items-center justify-between gap-2 svelte-gt9p7f"><div class="text-fg-3 text-[10px] uppercase tracking-wider svelte-gt9p7f">exports</div> <span class="text-[10px] text-fg-3 svelte-gt9p7f"> </span></div> <!></div> <div class="mb-3 border-t border-line-1 pt-3 svelte-gt9p7f"><div class="mb-1.5 flex items-center justify-between gap-2 svelte-gt9p7f"><div class="text-fg-3 text-[10px] uppercase tracking-wider svelte-gt9p7f">where used</div> <span class="text-[10px] text-fg-3 svelte-gt9p7f"> </span></div> <!></div> <div class="mb-3 border-t border-line-1 pt-3 svelte-gt9p7f"><div class="mb-1.5 grid grid-cols-2 gap-2 svelte-gt9p7f"><div class="svelte-gt9p7f"><div class="text-fg-3 text-[10px] uppercase tracking-wider svelte-gt9p7f">parents</div> <div class="text-[10px] text-fg-3 svelte-gt9p7f">incoming direction</div></div> <div class="svelte-gt9p7f"><div class="text-fg-3 text-[10px] uppercase tracking-wider svelte-gt9p7f">children</div> <div class="text-[10px] text-fg-3 svelte-gt9p7f">outgoing direction</div></div></div> <div class="grid grid-cols-2 gap-2 svelte-gt9p7f"><div class="space-y-1 svelte-gt9p7f"><!></div> <div class="space-y-1 svelte-gt9p7f"><!></div></div></div>',1),Mv=he('<code class="svelte-gt9p7f"> </code>'),Nv=he('<code class="svelte-gt9p7f"> </code>'),Pv=he('<div class="mb-2 svelte-gt9p7f"><div class="text-fg-3 text-[10px] uppercase tracking-wider svelte-gt9p7f">label</div> <div class="text-fg-0 font-semibold svelte-gt9p7f"> </div></div> <div class="mb-2 grid grid-cols-[60px_1fr] gap-x-2 gap-y-1 svelte-gt9p7f"><div class="text-fg-3 text-[10px] uppercase tracking-wider svelte-gt9p7f">from</div> <div class="text-fg-1 svelte-gt9p7f"><!></div> <div class="text-fg-3 text-[10px] uppercase tracking-wider svelte-gt9p7f">to</div> <div class="text-fg-1 svelte-gt9p7f"><!></div></div>',1),Uv=he('<pre class="whitespace-pre-wrap text-[11px] svelte-gt9p7f"> </pre>'),Wv=he('<dt class="text-fg-3 truncate svelte-gt9p7f"> </dt> <dd class="text-fg-1 break-words svelte-gt9p7f"><!></dd>',1),jv=he('<aside class="absolute top-0 right-0 bottom-0 w-[340px] bg-bg-1 border-l border-line-2 shadow-2xl flex flex-col z-20 svelte-gt9p7f"><header class="flex items-center gap-2 px-3 py-2 border-b border-line-1 text-[11px] font-mono svelte-gt9p7f"><!> <span class="type-label svelte-gt9p7f"> </span> <span class="ml-auto svelte-gt9p7f"></span> <button type="button" aria-label="Close panel" class="text-fg-3 hover:text-fg-1 cursor-pointer svelte-gt9p7f"><!></button></header> <div class="flex-1 overflow-auto p-3 text-[12px] font-mono svelte-gt9p7f"><!> <div class="mt-3 mb-1 text-fg-3 text-[10px] uppercase tracking-wider svelte-gt9p7f">properties</div> <dl class="grid grid-cols-[110px_1fr] gap-x-2 gap-y-1 svelte-gt9p7f"></dl></div></aside>'),Bv=he('<button type="button"><span class="svelte-gt9p7f">●</span> <span class="svelte-gt9p7f"> </span> <span class="text-fg-3 svelte-gt9p7f"> </span></button>'),Fv=he('<span class="text-fg-3 svelte-gt9p7f">types:</span> <!>',1),Vv=he('<span class="svelte-gt9p7f"><span class="text-fg-2 svelte-gt9p7f"> </span> <span class="text-fg-3 svelte-gt9p7f">·</span> </span>'),Kv=he('<div class="border-b border-line-1 px-3 py-1.5 flex items-center gap-2 text-[11px] font-mono bg-bg-1/40 svelte-gt9p7f"><div class="inline-flex border border-line-2 rounded overflow-hidden svelte-gt9p7f"><a><!> Canvas</a> <a><!> SVG</a> <a><!> Table</a></div> <!> <!> <!> <button type="button" title="Run a graph query (GRAPH NEIGHBORHOOD / SHORTEST_PATH / MATCH …)"><!> query</button> <!> <div class="ml-auto flex items-center gap-3 text-fg-3 svelte-gt9p7f"><span class="svelte-gt9p7f"> </span> <!> <!> <!></div></div> <!> <!> <div class="flex-1 min-h-0 relative svelte-gt9p7f"><!> <!></div> <div class="border-t border-line-1 px-3 py-1.5 text-[10px] font-mono text-fg-3 flex items-center gap-2 flex-wrap svelte-gt9p7f"><!> <span class="ml-auto svelte-gt9p7f"></span> <!></div>',1),Hv=he('<div class="flex h-full flex-col text-fg-1 svelte-gt9p7f"><!></div>');function dy(r,e){ii(e,!0);let t=Ee(null);const n=Q(()=>u(t)??e.result),i=Q(()=>im(u(n))),o=Q(()=>em(u(i).nodes,u(i).edges)),s=Q(()=>rm(u(i).nodes,u(o))),a=Q(()=>new Set(u(i).nodes.filter(k=>Bc(k,u(o))).map(k=>k.id)));let c=Ee("canvas"),l=Ee(25e3),d=Ee(""),f=Ee(null),h=Ee(null),g=Ee(null),y=Ee(350),C=Ee(1),b=Ee(!1),m=Ee(!1),A=Ee(Kt(new Set));const v=Q(()=>u(f)?Qg(u(f),u(i).nodes,u(i).edges,u(o)):null);Zt(()=>{e.subpage==="svg"&&u(c)!=="svg"?N(c,"svg"):e.subpage==="graph"&&u(c)!=="canvas"&&N(c,"canvas")});let p=Ee(null),E=Ee(null),S=Ee(!1),$=Ee(""),x=Ee(!1),D=Ee(null),I=Ee(""),j=Ee("");async function O(k){const U=Qn.client;if(!(!U||!k.trim())){N(x,!0),N(D,null);try{const F=await lr.track(`${e.collection??"graph"} · query (${k.slice(0,40).replace(/\s+/g," ")}…)`,()=>U.query(k));if(!F.ok){N(D,F.error??"query failed",!0);return}N(t,F,!0),N(f,null),N(h,null),tt()}catch(F){N(D,F.message,!0)}finally{N(x,!1)}}}function w(){N(t,null),N($,""),N(D,null),N(f,null),N(h,null),tt()}function ge(){u(f)&&(N($,`GRAPH NEIGHBORHOOD '${u(f).label}' DEPTH 1`),N(S,!0),O(u($)))}function ce(){N($,"GRAPH CENTRALITY LIMIT 50"),N(S,!0),O(u($))}function L(k){u(f)&&(k==="from"?N(I,u(f).label,!0):N(j,u(f).label,!0),N(S,!0))}function _(){!u(I).trim()||!u(j).trim()||(N($,`GRAPH SHORTEST_PATH '${u(I).trim()}' TO '${u(j).trim()}'`),N(S,!0),O(u($)))}const K=Q(()=>{const k=new Map;for(const U of u(i).nodes){const F=String(U.data.node_type??"node");k.set(F,(k.get(F)??0)+1)}return[...k.entries()].sort((U,F)=>F[1]-U[1])});let ee=Ee(Kt(new Set));const M=Q(()=>{const k=u(d).trim().toLowerCase();return u(i).nodes.filter(U=>{const F=String(U.data.node_type??"node");return u(ee).has(F)?!1:k?U.label.toLowerCase().includes(k)||U.id.toLowerCase().includes(k):!0}).sort((U,F)=>tm(U,F,u(o)))}),Re=Q(()=>Math.min(u(M).length,u(l))),ae=Q(()=>u(M).slice(0,Math.min(u(Re),u(y)))),W=Q(()=>new Set(u(ae).map(k=>k.id))),Se=Q(()=>u(i).edges.filter(k=>u(W).has(k.source)&&u(W).has(k.target))),Ce=Q(()=>u(ae).length<u(Re)),be=Q(()=>u(M).length>u(l));Zt(()=>{const k=u(Re),U=u(c)==="canvas"?1e3:350,F=Math.min(k,U);if(N(y,F,!0),F>=k)return;let Oe=!1,Ke=0,vt=F;const rt=()=>{Oe||(vt=Math.min(k,vt+U),N(y,vt,!0),vt<k&&(Ke=requestAnimationFrame(rt)))};return Ke=requestAnimationFrame(rt),()=>{Oe=!0,cancelAnimationFrame(Ke)}});function Ye(k){const U=new Set(u(ee));U.has(k)?U.delete(k):U.add(k),N(ee,U,!0)}const ot=gm,Ae=mm;let ve=Ee(void 0),X=null,me=null,et=Ee(1),J=Ee(0),ne=0,G=Ee(0),It=Ee(Kt([])),Rt=Ee(Kt([]));function Ot(k,U){const F=X;return F?F.graphToViewport({x:k,y:-U}):null}function Ht(){if(!u(b)||!X||u(c)!=="canvas"){u(It).length&&N(It,[],!0),u(Rt).length&&N(Rt,[],!0);return}const k=[];for(const F of u(Cn)){const Oe=Ot(F.minX,F.minY),Ke=Ot(F.maxX,F.maxY);!Oe||!Ke||k.push({...F,vx:Math.min(Oe.x,Ke.x),vy:Math.min(Oe.y,Ke.y),vw:Math.abs(Ke.x-Oe.x),vh:Math.abs(Ke.y-Oe.y)})}const U=[];for(const F of u(An)){const Oe=Ot(F.x1,F.y1),Ke=Ot(F.x2,F.y2);!Oe||!Ke||U.push({id:F.id,vx1:Oe.x,vy1:Oe.y,vx2:Ke.x,vy2:Ke.y})}N(It,k,!0),N(Rt,U,!0)}function $t(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}Ku(()=>{cancelAnimationFrame(ne),X&&(X.kill(),X=null)}),Hu(()=>{const k=new MutationObserver(()=>{N(G,u(G)+1)});return k.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","data-color-scheme"]}),()=>k.disconnect()});function xt(){N(f,null),N(h,null)}function tt(){N(p,null),N(E,null)}function Pt(k){return u(i).nodes.find(U=>U.id===k)??null}function nr(k){const U=Pt(k.nodeId);U&&(ir(U),mr(U))}function mr(k){N(h,null),N(f,k,!0)}function ir(k){N(E,k.id,!0),N(p,k.id,!0)}function Er(k){if(u(E)){tt(),xt();return}ir(k),mr(k)}function Lt(k){N(f,null),N(h,k,!0)}function Sr(k){return["id","rid","label","name","title","description","summary","content","exports","orphan","is_orphan","isOrphan","dead_code","deadCode"].includes(k)}function or(k,U){k.key!=="Enter"&&k.key!==" "||(k.preventDefault(),U())}function Uo(k){return Math.max(.5,Math.min(8,k))}const ll=Q(()=>u(c)==="canvas"?Math.round(100/(u(et)||1)):Math.round(u(C)*100));function Wo(k){if(u(c)==="canvas"){const F=X==null?void 0:X.getCamera();if(!F)return;k==="in"?F.animatedZoom(1.4):F.animatedUnzoom(1.4);return}const U=k==="in"?1.25:.8;N(C,Uo(u(C)*U),!0)}function ul(){if(u(c)==="canvas"){X==null||X.getCamera().animatedReset();return}N(C,1)}function dl(k){k.preventDefault();const U=k.deltaY<0?1.25:.8;N(C,Uo(u(C)*U),!0)}const jo=Q(()=>{const k=new Map;for(const U of u(i).edges)U.label&&k.set(U.label,(k.get(U.label)??0)+1);return[...k.entries()].sort((U,F)=>F[1]-U[1]).slice(0,4)}),Cr=Q(()=>am(u(ae),u(Se))),fl=Q(()=>(u(G),typeof document>"u"?!0:document.documentElement.dataset.colorScheme!=="light")),Cn=Q(()=>u(b)?ym(u(ae),u(Cr),{dark:u(fl)}):[]),An=Q(()=>u(b)?bm(u(Se),u(Cr),u(Cn)):[]),hl=Q(()=>new Set(u(An).map(k=>k.id))),pl=Q(()=>u(m)&&u(Se).length>io);function gl(k){return k>800?{cycles:4,iterations:45}:k>300?{cycles:5,iterations:55}:{}}const ui=Q(()=>{if(!u(m)||u(c)==="table"||u(Se).length===0||u(Se).length>io)return null;const k=u(ae).map(U=>{const F=u(Cr).get(U.id);return{id:U.id,x:(F==null?void 0:F.x)??50,y:(F==null?void 0:F.y)??50}});return Tm(k,u(Se).map(U=>({id:U.id,source:U.source,target:U.target})),gl(u(Se).length))}),di=Q(()=>{if(!u(ui))return null;const k=new Map;for(const[U,F]of u(ui))k.set(U,-Rm(F));return k}),$n=Q(()=>zm(u(ae),u(Se),u(Cr),u(A))),fi=Q(()=>u($n).nodes),Dn=Q(()=>u($n).edges),hi=Q(()=>u($n).layout),pi=Q(()=>{const k=Yc(u(ae),u(Cr));return new Map([...k].map(([U,F])=>[U,F.length]))}),gi=Q(()=>[...u(pi)].filter(([,k])=>k>=2).map(([k])=>k)),Ar=Q(()=>u(A).size>0);function ml(k){const U=new Set(u(A));U.add(k),N(A,U,!0),tt()}function vl(k){const U=new Set(u(A));U.delete(k),N(A,U,!0),tt()}function yl(){N(A,u(Ar)?new Set:new Set(u(gi)),!0),tt(),xt()}const Vr=Q(()=>{var k;return u(f)?((k=u(Cr).get(u(f).id))==null?void 0:k.community)??null:null});Zt(()=>{u(f)&&u($n).collapsedMembers.has(u(f).id)&&xt()});const Bo=Q(()=>u(fi).map(k=>{const U=String(k.data.node_type??"node"),F=u(s).get(k.id)??1,Oe=u(hi).get(k.id),Ke=k.data.__supernode===!0,vt=typeof k.data.__memberCount=="number"?k.data.__memberCount:0,rt=Oe?No(Oe.community):ei(U);return{...k,x:(Oe==null?void 0:Oe.x)??50,y:(Oe==null?void 0:Oe.y)??50,r:Ke?Kc(vt):Fc(U,F),color:rt}})),mi=Q(()=>new Map(u(Bo).map(k=>[k.id,k]))),vi=Q(()=>{var U;const k=[];for(const F of u(Dn)){const Oe=u(mi).get(F.source),Ke=u(mi).get(F.target);if(!Oe||!Ke)continue;const vt=(U=u(ui))==null?void 0:U.get(F.id);let rt,jt=(Oe.x+Ke.x)/2,Ut=(Oe.y+Ke.y)/2;if(vt&&vt.length>2){rt=vt.map(Hr=>`${Hr.x},${Hr.y}`).join(" ");const Ln=vt[Math.floor(vt.length/2)];jt=Ln.x,Ut=Ln.y}k.push({...F,x1:Oe.x,y1:Oe.y,x2:Ke.x,y2:Ke.y,points:rt,mx:jt,my:Ut})}return k}),Fe=Q(()=>u(E)??u(p)),In=Q(()=>{const k=new Set;if(!u(Fe))return k;for(const U of u(vi))(U.source===u(Fe)||U.target===u(Fe))&&k.add(U.id);return k}),sr=Q(()=>{const k=new Set;if(!u(Fe))return k;k.add(u(Fe));for(const U of u(vi))U.source===u(Fe)&&k.add(U.target),U.target===u(Fe)&&k.add(U.source);return k});Zt(()=>{const k=u(Fe);if(!k){N(J,0);return}if(!u(mi).has(k)){tt();return}bl()});function bl(){if(cancelAnimationFrame(ne),$t()){N(J,0);return}const k=performance.now();N(J,1);const U=()=>{const F=Math.max(0,1-(performance.now()-k)/170);N(J,F,!0),F>0&&(ne=requestAnimationFrame(U))};ne=requestAnimationFrame(U)}const wl=Q(()=>`translate(50 50) scale(${u(C)}) translate(-50 -50)`);function Kr(k,U){return getComputedStyle(document.documentElement).getPropertyValue(k).trim()||U}function Fo(){const k=document.documentElement.dataset.colorScheme!=="light";return{background:Kr("--color-bg-0",k?"#050607":"#ffffff"),edge:Kr("--color-line-3",k?"#3a424d":"#c9cbd1"),focusEdge:ot,focusNodeStroke:Ae,selectedNodeStroke:k?"#0a0a0b":"#18181b",nodeStroke:k?"#ffffff":"#27272a",warn:Kr("--color-warn",k?"#fbbf24":"#b45309")}}function Vo(){var k;return{focusId:u(Fe),focus:{nodes:u(sr),edges:u(In)},selectedNodeId:((k=u(f))==null?void 0:k.id)??null,pulse:u(J),colors:Fo(),groupInBox:u(b),bundle:u(m)&&u(di)!==null}}function Ko(){return vm({nodes:u(fi),edges:u(Dn),layout:u(hi),sizeScales:u(s),orphanIds:u(a),dark:document.documentElement.dataset.colorScheme!=="light",edgeColor:Fo().edge,bundledCurvatures:u(di)??void 0})}function _l(k){return u(Dn).find(U=>U.id===k)??null}function yi(k){if(qc(k)){const F=Om(k);F!==null&&vl(F);return}const U=Pt(k);U&&Er(U)}function xl(k){k.on("clickNode",({node:F})=>{yi(F)}),k.on("enterNode",({node:F})=>{u(E)||N(p,F,!0),u(ve)&&(u(ve).style.cursor="pointer")}),k.on("leaveNode",()=>{u(E)||N(p,null),u(ve)&&(u(ve).style.cursor="")}),k.on("clickEdge",({edge:F})=>{const Oe=_l(F);Oe&&(tt(),Lt(Oe))}),k.on("clickStage",()=>{tt(),xt()});const U=k.getCamera();U.on("updated",()=>{N(et,U.ratio,!0)}),k.on("afterRender",()=>Ht())}Zt(()=>{if(u(c)!=="canvas")return;const k=u(ve);if(!k)return;let U=!1,F=null;return(async()=>{try{if(!me){const[rt,jt,Ut]=await Promise.all([hr(()=>import("./wBgvmJJD.js"),__vite__mapDeps([3,4]),import.meta.url),hr(()=>import("./CXNPJgv1.js"),__vite__mapDeps([5,4]),import.meta.url),hr(()=>import("./CDKIdLnm.js"),__vite__mapDeps([6,4]),import.meta.url)]);me={Sigma:rt.default,NodeBorderProgram:jt.NodeBorderProgram,EdgeCurveProgram:Ut.default}}if(U||!u(ve))return;const{Sigma:Oe,NodeBorderProgram:Ke,EdgeCurveProgram:vt}=me;F=new Oe(Ko(),k,{allowInvalidContainer:!0,defaultNodeType:"border",nodeProgramClasses:{border:Ke},edgeProgramClasses:{curved:vt},defaultEdgeType:"line",renderEdgeLabels:!0,labelFont:'"JetBrains Mono Variable", monospace',edgeLabelFont:'"JetBrains Mono Variable", monospace',labelSize:12,edgeLabelSize:10,labelWeight:"700",labelColor:{color:Kr("--color-fg-0","#ffffff")},edgeLabelColor:{color:"#f6d36b"},labelRenderedSizeThreshold:1/0,zIndex:!0,nodeReducer:(rt,jt)=>km(rt,jt,Vo()),edgeReducer:(rt,jt)=>Em(rt,jt,Vo())}),xl(F),X=F,N(et,F.getCamera().ratio,!0),N(g,null)}catch(Oe){N(g,Oe.message,!0)}})(),()=>{U=!0,F&&F.kill(),X===F&&(X=null)}}),Zt(()=>{u(fi),u(Dn),u(hi),u(s),u(a),u(G),u(di),u(m);const k=X;!k||u(c)!=="canvas"||(k.setSetting("labelColor",{color:Kr("--color-fg-0","#ffffff")}),k.setGraph(Ko()),k.refresh())}),Zt(()=>{u(Fe),u(sr),u(In),u(f),u(J);const k=X;!k||u(c)!=="canvas"||k.refresh({skipIndexation:!0})}),Zt(()=>{u(b),u(Cn),u(An);const k=X;!k||u(c)!=="canvas"||(k.refresh({skipIndexation:!0}),Ht())});function kl(k){u(E)||N(p,k.id,!0)}function El(k){!u(E)&&u(p)===k.id&&N(p,null)}function bi(k){return u(Fe)?u(Fe)===k.id?k.r*2.24:u(sr).has(k.id)?k.r*1.6:k.r*.92:k.r*1.14}function Sl(k){return u(Fe)?u(sr).has(k.id)?1:.12:1}function Cl(k){return k.data.__supernode===!0?!0:u(Fe)?u(Fe)===k.id?!0:u(sr).size<=36&&u(sr).has(k.id):!1}function Al(k){return!!(u(Fe)&&u(In).has(k.id)&&k.label)}var wi=Hv(),$l=R(wi);{var Dl=k=>{var U=Vm();V(k,U)},Il=k=>{var U=Kv(),F=lt(U),Oe=R(F),Ke=R(Oe),vt=R(Ke);Ws(vt,{class:"size-3"}),Bt(),T(Ke);var rt=P(Ke,2),jt=R(rt);Ws(jt,{class:"size-3"}),Bt(),T(rt);var Ut=P(rt,2),Ln=R(Ut);Mm(Ln,{class:"size-3"}),Bt(),T(Ut),T(Oe);var Hr=P(Oe,2);{var Ll=te=>{var ie=Hm(),oe=lt(ie),ze=R(oe);kp(ze,{class:"size-3 text-fg-3"});var $e=P(ze,2);Ii($e);var Ue=P($e,2);{var De=He=>{var Qe=Km(),Tt=R(Qe);ks(Tt,{class:"size-3"}),T(Qe),Ne("click",Qe,()=>N(d,"")),V(He,Qe)};ke(Ue,He=>{u(d)&&He(De)})}T(oe);var Pe=P(oe,2),we=R(Pe);Pm(we,{class:"size-3"});var z=P(we,4),se=R(z);se.value=se.__value=500;var re=P(se);re.value=re.__value=1e3;var Ie=P(re);Ie.value=Ie.__value=2e3;var le=P(Ie);le.value=le.__value=5e3;var ye=P(le);ye.value=ye.__value=1e4;var de=P(ye);de.value=de.__value=25e3;var We=P(de);We.value=We.__value=5e4,T(z);var Xe;Ju(z),T(Pe),pe(()=>{Xe!==(Xe=u(l))&&(z.value=(z.__value=u(l))??"",Zu(z,u(l)))}),Gn($e,()=>u(d),He=>N(d,He)),Ne("change",z,He=>N(l,Number(He.currentTarget.value),!0)),V(te,ie)};ke(Hr,te=>{u(c)!=="table"&&te(Ll)})}var Ho=P(Hr,2);{var Tl=te=>{var ie=qm(),oe=R(ie),ze=R(oe);Bm(ze,{class:"size-3.5"}),T(oe);var $e=P(oe,2),Ue=R($e);T($e);var De=P($e,2),Pe=R(De);jm(Pe,{class:"size-3.5"}),T(De),T(ie),pe(()=>{oe.disabled=u(c)==="svg"&&u(C)<=.5,fe(Ue,`${u(ll)??""}%`),De.disabled=u(c)==="svg"&&u(C)>=8}),Ne("click",oe,()=>Wo("out")),Ne("click",$e,ul),Ne("click",De,()=>Wo("in")),V(te,ie)};ke(Ho,te=>{u(c)!=="table"&&te(Tl)})}var qo=P(Ho,2);{var Gl=te=>{var ie=Jm(),oe=lt(ie),ze=R(oe);Ea(ze,{class:"size-3"}),Bt(),T(oe);var $e=P(oe,2),Ue=R($e);Fm(Ue,{class:"size-3"}),Bt(),T($e);var De=P($e,2);{var Pe=se=>{var re=Ym(),Ie=R(re);T(re),pe((le,ye)=>{H(re,"title",le),fe(Ie,`bundling skipped (${ye??""} edges)`)},[()=>`Bundling is skipped above ${io.toLocaleString()} drawn edges — narrow the filter or lower the limit`,()=>u(Se).length.toLocaleString()]),V(se,re)};ke(De,se=>{u(pl)&&se(Pe)})}var we=P(De,2);{var z=se=>{var re=Xm(),Ie=R(re);{var le=We=>{Ea(We,{class:"size-3"})},ye=We=>{Sa(We,{class:"size-3"})};ke(Ie,We=>{u(Ar)?We(le):We(ye,-1)})}var de=P(Ie);T(re),pe(We=>{St(re,1,We,"svelte-gt9p7f"),H(re,"aria-pressed",u(Ar)),H(re,"title",u(Ar)?"Expand all collapsed clusters back to their members":"Collapse each community into a single supernode"),fe(de,` ${u(Ar)?`expand (${u(A).size})`:`collapse ${u(gi).length} clusters`}`)},[()=>Dt(["inline-flex items-center gap-1 h-6 px-2 rounded border cursor-pointer transition-colors",u(Ar)?"border-accent/40 bg-accent/10 text-primary-text":"border-line-1 text-fg-3 hover:text-fg-1 hover:border-line-2"].join(" "))]),Ne("click",re,yl),V(se,re)};ke(we,se=>{u(gi).length>0&&se(z)})}pe((se,re)=>{St(oe,1,se,"svelte-gt9p7f"),H(oe,"aria-pressed",u(b)),St($e,1,re,"svelte-gt9p7f"),H($e,"aria-pressed",u(m))},[()=>Dt(["inline-flex items-center gap-1 h-6 px-2 rounded border cursor-pointer transition-colors",u(b)?"border-accent/40 bg-accent/10 text-primary-text":"border-line-1 text-fg-3 hover:text-fg-1 hover:border-line-2"].join(" ")),()=>Dt(["inline-flex items-center gap-1 h-6 px-2 rounded border cursor-pointer transition-colors",u(m)?"border-accent/40 bg-accent/10 text-primary-text":"border-line-1 text-fg-3 hover:text-fg-1 hover:border-line-2"].join(" "))]),Ne("click",oe,()=>N(b,!u(b))),Ne("click",$e,()=>N(m,!u(m))),V(te,ie)};ke(qo,te=>{u(c)!=="table"&&te(Gl)})}var $r=P(qo,2),Rl=R($r);Um(Rl,{class:"size-3"}),Bt(),T($r);var Yo=P($r,2);{var Ol=te=>{var ie=Zm(),oe=R(ie);Sp(oe,{class:"size-3"}),Bt(),T(ie),Ne("click",ie,w),V(te,ie)};ke(Yo,te=>{u(t)&&te(Ol)})}var Xo=P(Yo,2),_i=R(Xo),zl=R(_i);T(_i);var Jo=P(_i,2);{var Ml=te=>{var ie=Qm(),oe=R(ie);T(ie),pe((ze,$e)=>fe(oe,`rendering ${ze??""} / ${$e??""}`),[()=>u(ae).length.toLocaleString(),()=>u(Re).toLocaleString()]),V(te,ie)};ke(Jo,te=>{u(c)!=="table"&&u(Ce)&&te(Ml)})}var Zo=P(Jo,2);{var Nl=te=>{var ie=ev(),oe=R(ie);T(ie),pe(ze=>fe(oe,`drawing ${ze??""}`),[()=>u(ae).length.toLocaleString()]),V(te,ie)};ke(Zo,te=>{u(c)!=="table"&&u(be)&&te(Nl)})}var Pl=P(Zo,2);{var Ul=te=>{var ie=tv(),oe=R(ie,!0);T(ie),pe(()=>fe(oe,e.collection)),V(te,ie)};ke(Pl,te=>{e.collection&&te(Ul)})}T(Xo),T(F);var Qo=P(F,2);{var Wl=te=>{var ie=nv(),oe=R(ie),ze=P(R(oe),2),$e=P(ze,2),Ue=P($e,2),De=R(Ue);Wm(De,{class:"size-3"}),Bt(),T(Ue),T(oe);var Pe=P(oe,2),we=R(Pe);Ii(we);var z=P(we,2);Ii(z);var se=P(z,2),re=P(se,2);T(Pe);var Ie=P(Pe,2),le=R(Ie);Bu(le);var ye=P(le,2),de=R(ye),We=R(de);{var Xe=Be=>{xp(Be,{class:"size-3 animate-spin"})},He=Be=>{Ep(Be,{class:"size-3"})};ke(We,Be=>{u(x)?Be(Xe):Be(He,-1)})}Bt(2),T(de),T(ye),T(Ie);var Qe=P(Ie,2);{var Tt=Be=>{var je=rv(),Le=R(je,!0);T(je),pe(()=>fe(Le,u(D))),V(Be,je)};ke(Qe,Be=>{u(D)&&Be(Tt)})}T(ie),pe((Be,je)=>{ze.disabled=!u(f),H(ze,"title",u(f)?`neighborhood of ${u(f).label}`:"select a node first"),Ue.disabled=Be,se.disabled=!u(f),H(se,"title",u(f)?`Use ${u(f).label} as source`:"select a node first"),re.disabled=!u(f),H(re,"title",u(f)?`Use ${u(f).label} as target`:"select a node first"),H(le,"placeholder",e.collection?`GRAPH NEIGHBORHOOD '<label>' DEPTH 2
|
|
33
|
+
*/const ef=Symbol("lucide-context"),tf=()=>Uu(ef);var rf=At("<svg><!><!></svg>");function at(r,e){ii(e,!0);const t=tf()??{},n=Gt(e,"color",19,()=>t.color??"currentColor"),i=Gt(e,"size",19,()=>t.size??24),o=Gt(e,"width",19,i),s=Gt(e,"height",19,i),a=Gt(e,"strokeWidth",19,()=>t.strokeWidth??2),c=Gt(e,"absoluteStrokeWidth",19,()=>t.absoluteStrokeWidth??!1),l=Gt(e,"nonScalingStroke",19,()=>t.nonScalingStroke??!1),d=Gt(e,"iconNode",19,()=>[]),f=Gt(e,"icon",19,()=>({node:d(),aliases:[],size:24})),h=Ze(e,["$$slots","$$events","$$legacy","color","size","width","height","strokeWidth","absoluteStrokeWidth","nonScalingStroke","iconNode","icon","class","children"]),g=Q(()=>!!e.children||Qd(h)),y=Q(()=>Zd(f(),{color:n(),width:o(),height:s(),strokeWidth:a(),absoluteStrokeWidth:c(),nonScalingStroke:l(),className:lo("lucide-icon",t.class),hasA11yProp:u(g),attributes:h})),C=Q(()=>an(u(y),3)),b=Q(()=>u(C)[1]),m=Q(()=>ju(u(C)[2],()=>[],!0)),A=Q(()=>({...u(b),class:[...u(b).class.split(" "),e.class]}));var v=rf();Yn(v,()=>({...u(A)}));var p=R(v);bt(p,17,()=>u(m),Vn,(S,$)=>{var x=Q(()=>an(u($),2));let D=()=>u(x)[0],I=()=>u(x)[1];var j=er(),O=lt(j);id(O,D,!0,(w,ge)=>{Yn(w,()=>({...I()}))}),V(S,j)});var E=P(p);ao(E,()=>e.children??Wu),T(v),V(r,v),oi()}const Pa={name:"x",size:24,node:[["path",{d:"M18 6 6 18"}],["path",{d:"m6 6 12 12"}]]};Pa.node;function ks(r,e){let t=Ze(e,["$$slots","$$events","$$legacy"]);at(r,it(()=>t,{get icon(){return Pa}}))}const nf=20;var hn,pn,gn;class of{constructor(){nt(this,hn,Ee(0));nt(this,pn,Q(()=>this.inflight>0));nt(this,gn,Ee(Kt([])));Te(this,"nextId",1)}get inflight(){return u(xe(this,hn))}set inflight(e){N(xe(this,hn),e,!0)}get active(){return u(xe(this,pn))}set active(e){N(xe(this,pn),e)}get log(){return u(xe(this,gn))}set log(e){N(xe(this,gn),e,!0)}async track(e,t){const n=this.nextId++,i={id:n,label:e,startedAt:Date.now(),durationMs:null,status:"pending"};Qt(()=>{this.log=[i,...this.log].slice(0,nf),this.inflight+=1});try{const o=await t();return Qt(()=>this.update(n,{durationMs:Date.now()-i.startedAt,status:"ok"})),o}catch(o){throw Qt(()=>this.update(n,{durationMs:Date.now()-i.startedAt,status:"error",error:o.message})),o}finally{Qt(()=>{this.inflight=Math.max(0,this.inflight-1)})}}update(e,t){this.log=this.log.map(n=>n.id===e?{...n,...t}:n)}reset(){Qt(()=>{this.log=this.log.map(e=>e.status==="pending"?{...e,status:"error",error:"reset by user",durationMs:Date.now()-e.startedAt}:e),this.inflight=0})}}hn=new WeakMap,pn=new WeakMap,gn=new WeakMap;const lr=new of;var sf=Array.isArray,si=r=>{if(!r&&r!==0&&r!==0n)return"";if(typeof r=="string")return r;if(typeof r=="number")return r!==r?"":""+r;if(typeof r=="bigint")return""+r;let e="";if(sf(r)){const t=r.length;for(let n=0;n<t;n++){const i=r[n];if(!i&&i!==0&&i!==0n)continue;const o=typeof i=="string"?i:si(i);o&&(e&&(e+=" "),e+=o)}return e}if(typeof r=="object")for(const t in r)r[t]&&(e&&(e+=" "),e+=t);return e},af=/\s+/g,uo=Array.isArray,cf=r=>typeof r!="string"||!r?r:r.replace(af," ").trim(),lf=r=>{const e=r.length;if(e===0)return!1;const t=r.charCodeAt(0),n=r.charCodeAt(e-1);if(t===32||n===32||t>=9&&t<=13||t===160||n>=9&&n<=13||n===160)return!0;for(let i=0;i<e;i++){const o=r.charCodeAt(i);if(o>=9&&o<=13||o===160||o===32&&i+1<e&&r.charCodeAt(i+1)===32)return!0}return!1},Kn=(...r)=>{const e=si(r);if(e)return lf(e)?cf(e):e},fo=r=>r===!1?"false":r===!0?"true":r===0?"0":r,Mt=r=>{if(!r||typeof r!="object")return!0;for(const e in r)return!1;return!0},Ua=(r,e)=>{if(r===e)return!0;if(!r||!e)return!1;const t=r,n=e,i=Object.keys(t),o=Object.keys(n);if(i.length!==o.length)return!1;for(let s=0;s<i.length;s++){const a=i[s];if(!o.includes(a)||t[a]!==n[a])return!1}return!0},uf=(r,e)=>{const t=r;for(const n in e)if(Object.hasOwn(e,n)){const i=e[n];n in t?t[n]=Kn(t[n],i):t[n]=i}return r},Wa=(r,e)=>{for(let t=0;t<r.length;t++){const n=r[t];uo(n)?Wa(n,e):n&&e.push(n)}},ho=(...r)=>{const e=[];Wa(r,e);const t=[];for(let n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t},ko=(r,e)=>{const t=r,n=e,i={};for(const o in t){const s=t[o];if(o in n){const a=n[o];uo(s)||uo(a)?i[o]=ho(a,s):typeof s=="object"&&typeof a=="object"&&s&&a?i[o]=ko(s,a):i[o]=a+" "+s}else i[o]=s}for(const o in n)o in t||(i[o]=n[o]);return i},df={twMerge:!0,twMergeConfig:{}},ja=256,ff=128,xr=Symbol("tv-cache-miss"),hf=r=>(r==null?void 0:r.class)!=null&&r.class!==""||(r==null?void 0:r.className)!=null&&r.className!=="",Es=r=>{if(r===void 0)return"";if(r===null)return"null";if(typeof r=="string")return r;if(typeof r=="boolean")return r?"true":"false";if(typeof r=="number")return r===0?"0":String(r);if(typeof r=="bigint")return String(r);const e=fo(r),t=typeof e;if(t==="string"||t==="number"||t==="boolean"||t==="bigint")return String(e);if(t==="object")try{return JSON.stringify(e)}catch{return null}return null},Rr=(r,e)=>{if(e===void 0)return r;if(e===null)return r+"null";const t=typeof e;if(t==="string"||t==="number"||t==="boolean"||t==="bigint")return r+String(e);if(Array.isArray(e))return r+e.join("\0");try{return r+JSON.stringify(e)}catch{return r+"?"}},Ba=(r,e,t,n)=>{let i="";const o=Object.create(null);for(let a=0;a<r.length;a++){const c=r[a];o[c]=1;let l=e[c];t&&t[c]!==void 0&&(l=t[c]);const d=Es(l);if(d===null)return null;i+=c+":"+d+";"}const s=[];for(const a in e)a==="class"||a==="className"||o[a]||(o[a]=1,s.push(a));if(t)for(const a in t)a==="class"||a==="className"||o[a]||t[a]===void 0||(o[a]=1,s.push(a));s.length>1&&s.sort();for(let a=0;a<s.length;a++){const c=s[a];let l=e[c];t&&t[c]!==void 0&&(l=t[c]);const d=Es(l);if(d===null)return null;i+=c+":"+d+";"}return i},Fa=(r,e)=>{let t="";for(let n=0;n<r.length;n++){const{conditionKeys:i,source:o}=r[n];for(let s=0;s<i.length;s++){const a=i[s];t+=a+"=",t=Rr(t,o[a]),t+=","}t+="c=",t=Rr(t,o.class),t+="|cn=",t=Rr(t,o.className),t+=";"}for(let n=0;n<e.length;n++){const{conditionKeys:i,source:o}=e[n];for(let s=0;s<i.length;s++){const a=i[s];t+=a+"=",t=Rr(t,o[a]),t+=","}Array.isArray(o.slots)&&(t+="slots="+o.slots.join(",")+","),t+="c=",t=Rr(t,o.class),t+="|cn=",t=Rr(t,o.className),t+=";"}return t},Va=(r=ja)=>{let e=new Map,t=null;return{get(n){if(e.has(n))return e.get(n);if(t!=null&&t.has(n)){const i=t.get(n);return e.set(n,i),i}return xr},set(n,i){e.size>=r&&(t=e,e=new Map),e.set(n,i)}}},pf=(r=ja)=>{const e=Va(r);return{get(t){return e.get(t)},set(t,n){e.set(t,n)}}},gf=(r=ff)=>{let e=new Map,t=null,n=0;return{get(i,o){const s=e.get(i);if(s){const a=s.get(o);if(a!==void 0||s.has(o))return a}if(t){const a=t.get(i);if(a){const c=a.get(o);if(c!==void 0||a.has(o)){let l=e.get(i);return l||(l=new Map,e.set(i,l)),l.has(o)||n++,l.set(o,c),c}}}return xr},set(i,o,s){n>=r&&(t=e,e=new Map,n=0);let a=e.get(i);a||(a=new Map,e.set(i,a)),a.has(o)||n++,a.set(o,s)}}},Eo=(r,e)=>{let t=null;return(n,i)=>{if(!hf(i))return n;const o=i.class,s=i.className;if(o!=null&&o!==""&&typeof o!="string"||s!=null&&s!==""&&typeof s!="string")return r(e,n,o,s);t??(t=gf());const a=n??"",c=(typeof o=="string"?o:"")+"\0"+(typeof s=="string"?s:""),l=t.get(a,c);if(l!==xr)return l;const d=r(e,n,o,s);return t.set(a,c,d),d}};function mf(){let r=null,e={},t=!1;return{get cachedTwMerge(){return r},set cachedTwMerge(n){r=n},get cachedTwMergeConfig(){return e},set cachedTwMergeConfig(n){e=n},get didTwMergeConfigChange(){return t},set didTwMergeConfigChange(n){t=n},reset(){r=null,e={},t=!1}}}var Ct=mf(),vf=r=>{!Mt(r.twMergeConfig)&&!Ua(r.twMergeConfig,Ct.cachedTwMergeConfig)&&(Ct.didTwMergeConfigChange=!0,Ct.cachedTwMergeConfig=r.twMergeConfig)},yf=(r,e)=>{const t=[];for(let n=0;n<e.length;n++){const i=e[n],o=r[i];t.push({key:i,values:o,isEmpty:Mt(o)})}return t},bf=r=>{if(!Array.isArray(r)||r.length===0)return[];const e=[];for(let t=0;t<r.length;t++){const n=r[t],i=[];for(const o in n)o!=="class"&&o!=="className"&&i.push(o);e.push({conditionKeys:i,source:n})}return e},wf=r=>{if(!Array.isArray(r)||r.length===0)return[];const e=[];for(let t=0;t<r.length;t++){const n=r[t],i=[];for(const o in n)o!=="slots"&&o!=="class"&&o!=="className"&&i.push(o);e.push({conditionKeys:i,source:n})}return e},_f=r=>{const e={};for(let t=0;t<r.length;t++){const n=r[t],i=n.source.slots;if(Array.isArray(i))for(let o=0;o<i.length;o++){const s=i[o];e[s]||(e[s]=[]),e[s].push(n)}}return e},xf=(r,e)=>{const{extend:t=null,slots:n={},variants:i={},compoundVariants:o=[],compoundSlots:s=[],defaultVariants:a={}}=r,c={...df,...e},l=r.slots!==void 0,d=t!=null&&t.base?Kn(t.base,r==null?void 0:r.base):r==null?void 0:r.base,f=t!=null&&t.variants&&!Mt(t.variants)?ko(i,t.variants):i,h=t!=null&&t.defaultVariants&&!Mt(t.defaultVariants)?{...t.defaultVariants,...a}:a;vf(c);const g=!(t!=null&&t.slots)||Mt(t.slots),y=l?g&&(t!=null&&t.base)?Kn(r==null?void 0:r.base,t.base):typeof(r==null?void 0:r.base)=="string"||(r==null?void 0:r.base)==null?r.base:Kn(r.base):void 0,C=l?{base:y,...n}:{},b=g?C:uf({...t==null?void 0:t.slots},Mt(C)?{base:r==null?void 0:r.base}:C),m=!(t!=null&&t.compoundVariants)||Mt(t.compoundVariants)?o:ho(t==null?void 0:t.compoundVariants,o),A=!(t!=null&&t.compoundSlots)||Mt(t.compoundSlots)?s:ho(t==null?void 0:t.compoundSlots,s),v=Object.keys(f),p=m&&!Array.isArray(m)?new TypeError(`The "compoundVariants" prop must be an array. Received: ${typeof m}`):A&&!Array.isArray(A)?new TypeError(`The "compoundSlots" prop must be an array. Received: ${typeof A}`):null,E=l||!g?"slots":v.length===0?"plain":"variants";return{config:c,extend:t,base:d,variants:f,defaultVariants:h,slots:b,compoundVariants:m,compoundSlots:A,compiledVariants:null,compiledCompoundVariants:null,compiledCompoundSlots:null,compiledCompoundSlotsBySlot:null,deferredError:p,mode:E,slotKeys:null,variantKeys:v}},Ka=r=>(r.compiledVariants!==null||(r.compiledVariants=yf(r.variants,r.variantKeys),r.compiledCompoundVariants=bf(r.compoundVariants),r.compiledCompoundSlots=wf(r.compoundSlots),r.compiledCompoundSlotsBySlot=_f(r.compiledCompoundSlots),r.slotKeys=r.slots&&typeof r.slots=="object"?Object.keys(r.slots):[]),r),po=[],Ha=[],kf=[],Ef=[],Sf=[],qa=(r,e,t)=>{const n={};for(const i in r)n[i]=r[i];if(e)for(const i in e)e[i]!==void 0&&(n[i]=e[i]);if(t)for(const i in t)t[i]!==void 0&&(n[i]=t[i]);return n},On=r=>r==null||r===!1,Cf=(r,e)=>{if(!Array.isArray(r))return r===e||On(r)&&On(e);for(let t=0;t<r.length;t++){const n=r[t];if(n===e||On(n)&&On(e))return!0}return!1},Ya=(r,e,t,n)=>{if(r.isEmpty)return null;const i=(n==null?void 0:n[r.key])??(t==null?void 0:t[r.key]);if(i===null)return null;const o=fo(i);if(typeof o=="object")return null;const s=e==null?void 0:e[r.key],a=o??fo(s);return r.values[a||"false"]},So=(r,e)=>{const{conditionKeys:t,source:n}=r;for(let i=0;i<t.length;i++){const o=t[i];if(!Cf(n[o],e[o]))return!1}return!0},Ss=(r,e,t)=>{typeof t=="string"?e==="base"&&r.push(t):t&&typeof t=="object"&&t[e]&&r.push(t[e])},Af=(r,e,t)=>{const n=Ha;n.length=0;for(let i=0;i<r.length;i++){const o=Ya(r[i],e,t);o&&n.push(o)}return n},$f=(r,e,t,n,i)=>{const o=Ha;o.length=0;for(let s=0;s<e.length;s++){const a=Ya(e[s],t,n,i),c=r==="base"&&typeof a=="string"?a:a&&a[r];c&&o.push(c)}return o},Df=(r,e)=>{const t=kf;t.length=0;for(let n=0;n<r.length;n++){const i=r[n];So(i,e)&&(i.source.class&&t.push(i.source.class),i.source.className&&t.push(i.source.className))}return t},If=(r,e,t)=>{const n=Ef;n.length=0;for(let i=0;i<e.length;i++){const o=e[i];So(o,t)&&(Ss(n,r,o.source.class),Ss(n,r,o.source.className))}return n},Lf=(r,e)=>{const t=Sf;t.length=0;for(let n=0;n<r.length;n++){const i=r[n];So(i,e)&&(i.source.class&&t.push(i.source.class),i.source.className&&t.push(i.source.className))}return t},Tf=(r,e)=>{const{base:t,config:n}=r;let i=xr;const o=Eo(e,n);return(s=>(i===xr&&(i=e(n,t)),o(i,s)))},Gf=(r,e)=>{const{base:t,config:n,defaultVariants:i,deferredError:o,variantKeys:s}=r;let a=r.compiledCompoundVariants,c=r.compiledVariants,l=po,d=null;const f=Eo(e,n);let h=1;const g=y=>{const C=a.length>0?Df(a,qa(i,y)):void 0;return e(n,t,Af(c,i,y),C)};return(y=>{if(o)throw o;(c===null||a===null)&&(Ka(r),c=r.compiledVariants,a=r.compiledCompoundVariants,l=r.compiledCompoundSlots??po);let C;if(h>0)h--,C=g(y);else{d??(d=pf());const b=Ba(s,i,y);if(b!==null){const m=a.length>0||l.length>0?Fa(a,l):"",A=b+"#"+m,v=d.get(A);v!==xr?C=v:(C=g(y),d.set(A,C))}else C=g(y)}return f(C,y)})},Rf=(r,e)=>{const{config:t,defaultVariants:n,deferredError:i,slots:o,variantKeys:s}=r;let a=null,c=null,l=null,d=null,f=!1,h=null,g=null,y=1;const C=()=>{if(l!==null)return;(r.compiledVariants===null||r.compiledCompoundVariants===null||r.compiledCompoundSlots===null||r.compiledCompoundSlotsBySlot===null||r.slotKeys===null)&&Ka(r);const m=r.compiledVariants;a=r.compiledCompoundVariants,c=r.compiledCompoundSlots;const A=r.compiledCompoundSlotsBySlot;l=r.slotKeys,f=a.length>0||c.length>0,h=Eo(e,t);const v=new Array(l.length);for(let p=0;p<l.length;p++){const E=l[p],S=A[E]??po;v[p]=($,x)=>{const D=f?qa(n,$,x):void 0,I=D?If(E,a,D):void 0,j=D?Lf(S,D):void 0;return e(t,o[E],$f(E,m,n,$,x),I,j)}}d=v},b=m=>{const A=l,v=d,p=h,E={};for(let S=0;S<A.length;S++){const $=v[S],x=$(m);E[A[S]]=D=>{if(D==null)return x;let I=!1;for(const j in D)if(!(j==="class"||j==="className")&&D[j]!==void 0){I=!0;break}return p(I?$(m,D):x,D)}}return E};return(m=>{if(i)throw i;if(C(),y>0)return y--,b(m);const A=Ba(s,n,m);if(A===null)return b(m);const v=f?Fa(a,c):"",p=A+"#"+v;g??(g=Va());const E=g.get(p);if(E!==xr)return E;const S=b(m);return g.set(p,S),S})},Of=(r,e)=>{if(r.mode==="plain")return Tf(r,e);let t;return(n=>(t??(t=r.mode==="slots"?Rf(r,e):Gf(r,e)),t(n)))},zf=(r,e)=>{r.variantKeys=e.variantKeys,r.extend=e.extend,r.base=e.base,r.slots=e.slots,r.variants=e.variants,r.defaultVariants=e.defaultVariants,r.compoundSlots=e.compoundSlots,r.compoundVariants=e.compoundVariants},Mf=r=>{const e=(n,i)=>{const o=xf(n,i),s=Of(o,r);return zf(s,o),s};return{tv:e,createTV:n=>(i,o)=>e(i,o?ko(n,o):n)}},Nf=(r,e)=>{const t=r.length,n=e.length,i=new Array(t+n);for(let o=0;o<t;o++)i[o]=r[o];for(let o=0;o<n;o++)i[t+o]=e[o];return i},Pf=(r,e)=>({classGroupId:r,validator:e}),Xa=(r=new Map,e=null,t)=>({nextPart:r,validators:e,classGroupId:t}),Zn="-",Cs=[],Uf="arbitrary..",Wf=r=>{const e=Bf(r),{conflictingClassGroups:t,conflictingClassGroupModifiers:n}=r;return{getClassGroupId:s=>{if(s[0]==="["&&s[s.length-1]==="]")return jf(s);const a=s.split(Zn),c=a[0]===""&&a.length>1?1:0;return Ja(a,c,e)},getConflictingClassGroupIds:(s,a)=>{if(a){const c=n[s],l=t[s];return c?l?Nf(l,c):c:l||Cs}return t[s]||Cs}}},Ja=(r,e,t)=>{if(r.length-e===0)return t.classGroupId;const i=r[e],o=t.nextPart.get(i);if(o){const l=Ja(r,e+1,o);if(l)return l}const s=t.validators;if(s===null)return;const a=e===0?r.join(Zn):r.slice(e).join(Zn),c=s.length;for(let l=0;l<c;l++){const d=s[l];if(d.validator(a))return d.classGroupId}},jf=r=>{const e=r.slice(1,-1),t=e.indexOf(":");if(t===-1)return;const n=e.slice(0,t);return n?Uf+n:void 0},Bf=r=>{const{theme:e,classGroups:t}=r;return Ff(t,e)},Ff=(r,e)=>{const t=Xa();for(const n in r){const i=r[n];Co(i,t,n,e)}return t},Co=(r,e,t,n)=>{const i=r.length;for(let o=0;o<i;o++){const s=r[o];Vf(s,e,t,n)}},Vf=(r,e,t,n)=>{if(typeof r=="string"){Kf(r,e,t);return}if(typeof r=="function"){Hf(r,e,t,n);return}qf(r,e,t,n)},Kf=(r,e,t)=>{const n=r===""?e:Za(e,r);n.classGroupId=t},Hf=(r,e,t,n)=>{if(Yf(r)){Co(r(n),e,t,n);return}e.validators===null&&(e.validators=[]),e.validators.push(Pf(t,r))},qf=(r,e,t,n)=>{const i=Object.entries(r),o=i.length;for(let s=0;s<o;s++){const[a,c]=i[s];Co(c,Za(e,a),t,n)}},Za=(r,e)=>{let t=r;const n=e.split(Zn),i=n.length;for(let o=0;o<i;o++){const s=n[o];let a=t.nextPart.get(s);a||(a=Xa(),t.nextPart.set(s,a)),t=a}return t},Yf=r=>"isThemeGetter"in r&&r.isThemeGetter===!0,Xf="!",Jf=58,Zf=47,Qf=91,eh=93,th=40,rh=41,As=33,nh=(r,e,t,n)=>({modifiers:r,hasImportantModifier:e,baseClassName:t,maybePostfixModifierPosition:n,isExternal:void 0}),$s=r=>{const e=[];let t=0,n=0,i=0,o;const s=r.length;for(let h=0;h<s;h++){const g=r.charCodeAt(h);if(t===0&&n===0){if(g===Jf){e.push(r.slice(i,h)),i=h+1;continue}if(g===Zf){o=h;continue}}g===Qf?t++:g===eh?t--:g===th?n++:g===rh&&n--}const a=e.length===0?r:r.slice(i);let c=a,l=!1;const d=a.length-1;a.charCodeAt(d)===As?(c=a.slice(0,-1),l=!0):a.charCodeAt(0)===As&&(c=a.slice(1),l=!0);const f=o&&o>i?o-i:void 0;return nh(e,l,c,f)},ih=r=>{const e=new Set(r.orderSensitiveModifiers);return t=>{const n=[];let i=[];for(let o=0;o<t.length;o++){const s=t[o],a=s[0]==="[",c=e.has(s);if(a||c){if(i.length>0){i.sort();for(let l=0;l<i.length;l++)n.push(i[l]);i=[]}n.push(s)}else i.push(s)}if(i.length>0){i.sort();for(let o=0;o<i.length;o++)n.push(i[o])}return n}},Mi={isExternal:!0,classId:-1,conflictIds:[]},oh=4096,sh=16384,ah=r=>{const e=ih(r),t=ch(r),{getClassGroupId:n,getConflictingClassGroupIds:i}=Wf(r);let o=Object.create(null),s=Object.create(null),a=0,c=new Int32Array(256),l=0,d=new Uint8Array(64),f=!1;const h=v=>{const p=[],E=v.length;let S=-1;f=!1;for(let $=0;$<E;$++){const x=v.charCodeAt($);x===32?S!==-1&&(p.push(v.slice(S,$)),S=-1):x>=9&&x<=13?(f=!0,S!==-1&&(p.push(v.slice(S,$)),S=-1)):S===-1&&(S=$)}return S!==-1&&p.push(v.slice(S)),p},g=new Map;let y=0;const C=v=>{let p=g.get(v);if(p===void 0&&(p=y++,g.set(v,p),p>=c.length)){const E=new Int32Array(c.length*2);E.set(c),c=E}return p},b=v=>{const{isExternal:p,modifiers:E,hasImportantModifier:S,baseClassName:$,maybePostfixModifierPosition:x}=$s(v);if(p)return Mi;let D=!!x,I;if(D){const ce=$.substring(0,x);I=n(ce);const L=I&&t[I]?n($):void 0;L&&L!==I&&(I=L,D=!1)}else I=n($);if(!I){if(!D||(I=n($),!I))return Mi;D=!1}const j=E.length===0?"":E.length===1?E[0]:e(E).join(":"),O=S?j+Xf:j,w=i(I,D),ge=[];for(let ce=0;ce<w.length;ce++)ge.push(C(O+w[ce]));return{isExternal:!1,classId:C(O+I),conflictIds:ge}},m=v=>{let p=o[v];return p!==void 0||(p=s[v],p===void 0&&(p=b(v)),o[v]=p,++a>oh&&(a=0,s=o,o=Object.create(null))),p};return{parseClassName:$s,sortModifiers:e,postfixLookupClassGroupIds:t,getClassGroupId:n,getConflictingClassGroupIds:i,getClassDescriptor:m,mergeClassList:v=>{const p=h(v),E=p.length;if(E===1)return p[0];y>sh&&(g.clear(),y=0,o=Object.create(null),s=Object.create(null),a=0),l=l+1|0,l===0&&(l=1);const S=l;if(E>d.length){let I=d.length;for(;I<E;)I*=2;d=new Uint8Array(I)}let $=!1,x=0;for(let I=E-1;I>=0;I-=1){const j=p[I];x+=j.length;const O=m(j);if(O.isExternal){d[I]=1;continue}const w=O.classId;if(c[w]===S){d[I]=0,$=!0;continue}c[w]=S;const ge=O.conflictIds;for(let ce=0;ce<ge.length;ce++)c[ge[ce]]=S;d[I]=1}if(!$&&!f&&v.length===x+E-1)return v;let D="";for(let I=0;I<E;I++)d[I]===1&&(D&&(D+=" "),D+=p[I]);return D}}},ch=r=>{const e=Object.create(null),t=r.postfixLookupClassGroups;if(t)for(let n=0;n<t.length;n++)e[t[n]]=!0;return e},lh=500,Ds=r=>{let e,t,n=Object.create(null),i=Object.create(null),o=0;const s=l=>(e=ah(r()),t=e.mergeClassList,c.mergeString=a,a(l)),a=l=>{let d=n[l];return d!==void 0||(d=i[l],d===void 0&&(d=t(l)),n[l]=d,++o>lh&&(o=0,i=n,n=Object.create(null))),d},c=(...l)=>c.mergeString(si(l));return c.mergeString=s,c},uh=[],ct=r=>{const e=t=>t[r]||uh;return e.isThemeGetter=!0,e},Qa=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,ec=/^\((?:(\w[\w-]*):)?(.+)\)$/i,dh=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,fh=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,hh=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,ph=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,gh=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,mh=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,tc=Number,vh=Number.isNaN,yh=Number.isInteger,cr=r=>dh.test(r),Ge=r=>!!r&&!vh(tc(r)),Ft=r=>!!r&&yh(tc(r)),Ni=r=>r.endsWith("%")&&Ge(r.slice(0,-1)),Xt=r=>fh.test(r),rc=()=>!0,bh=r=>hh.test(r)&&!ph.test(r),Ao=()=>!1,wh=r=>gh.test(r),_h=r=>mh.test(r),xh=r=>!Y(r)&&!Z(r),kh=r=>r.startsWith("@container")&&(r[10]==="/"&&r[11]!==void 0||r[11]==="s"&&r[16]!==void 0&&r.startsWith("-size/",10)||r[11]==="n"&&r[18]!==void 0&&r.startsWith("-normal/",10)),Eh=r=>gr(r,oc,Ao),Y=r=>Qa.test(r),yr=r=>gr(r,sc,bh),Is=r=>gr(r,Th,Ge),Sh=r=>gr(r,cc,rc),Ch=r=>gr(r,ac,Ao),Ls=r=>gr(r,nc,Ao),Ah=r=>gr(r,ic,_h),zn=r=>gr(r,lc,wh),Z=r=>ec.test(r),Jr=r=>kr(r,sc),$h=r=>kr(r,ac),Ts=r=>kr(r,nc),Dh=r=>kr(r,oc),Ih=r=>kr(r,ic),Mn=r=>kr(r,lc,!0),Lh=r=>kr(r,cc,!0),gr=(r,e,t)=>{const n=Qa.exec(r);return n?n[1]?e(n[1]):t(n[2]):!1},kr=(r,e,t=!1)=>{const n=ec.exec(r);return n?n[1]?e(n[1]):t:!1},nc=r=>r==="position"||r==="percentage",ic=r=>r==="image"||r==="url",oc=r=>r==="length"||r==="size"||r==="bg-size",sc=r=>r==="length",Th=r=>r==="number",ac=r=>r==="family-name",cc=r=>r==="number"||r==="weight",lc=r=>r==="shadow",Pi=()=>{const r=ct("color"),e=ct("font"),t=ct("text"),n=ct("font-weight"),i=ct("tracking"),o=ct("leading"),s=ct("breakpoint"),a=ct("container"),c=ct("spacing"),l=ct("radius"),d=ct("shadow"),f=ct("inset-shadow"),h=ct("text-shadow"),g=ct("drop-shadow"),y=ct("blur"),C=ct("perspective"),b=ct("aspect"),m=ct("ease"),A=ct("animate"),v=()=>["auto","avoid","all","avoid-page","page","left","right","column"],p=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],E=()=>[...p(),Z,Y],S=()=>["auto","hidden","clip","visible","scroll"],$=()=>["auto","contain","none"],x=()=>[Z,Y,c],D=()=>[cr,"full","auto",...x()],I=()=>[Ft,"none","subgrid",Z,Y],j=()=>["auto",{span:["full",Ft,Z,Y]},Ft,Z,Y],O=()=>[Ft,"auto",Z,Y],w=()=>["auto","min","max","fr",Z,Y],ge=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],ce=()=>["start","end","center","stretch","center-safe","end-safe"],L=()=>["auto",...x()],_=()=>[cr,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...x()],K=()=>[cr,"screen","full","dvw","lvw","svw","min","max","fit",...x()],ee=()=>[cr,"screen","full","lh","dvh","lvh","svh","min","max","fit",...x()],M=()=>[r,Z,Y],Re=()=>[...p(),Ts,Ls,{position:[Z,Y]}],ae=()=>["no-repeat",{repeat:["","x","y","space","round"]}],W=()=>["auto","cover","contain",Dh,Eh,{size:[Z,Y]}],Se=()=>[Ni,Jr,yr],Ce=()=>["","none","full",l,Z,Y],be=()=>["",Ge,Jr,yr],Ye=()=>["solid","dashed","dotted","double"],ot=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],Ae=()=>[Ge,Ni,Ts,Ls],ve=()=>["","none",y,Z,Y],X=()=>["none",Ge,Z,Y],me=()=>["none",Ge,Z,Y],et=()=>[Ge,Z,Y],J=()=>[cr,"full",...x()];return{theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Xt],breakpoint:[Xt],color:[rc],container:[Xt],"drop-shadow":[Xt],ease:["in","out","in-out"],font:[xh],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Xt],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Xt],shadow:[Xt],spacing:["px",Ge],text:[Xt],"text-shadow":[Xt],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",cr,Y,Z,b]}],container:["container"],"container-type":[{"@container":["","normal","size",Z,Y]}],"container-named":[kh],columns:[{columns:[Ge,Y,Z,a]}],"break-after":[{"break-after":v()}],"break-before":[{"break-before":v()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:E()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:$()}],"overscroll-x":[{"overscroll-x":$()}],"overscroll-y":[{"overscroll-y":$()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:D()}],"inset-x":[{"inset-x":D()}],"inset-y":[{"inset-y":D()}],start:[{"inset-s":D(),start:D()}],end:[{"inset-e":D(),end:D()}],"inset-bs":[{"inset-bs":D()}],"inset-be":[{"inset-be":D()}],top:[{top:D()}],right:[{right:D()}],bottom:[{bottom:D()}],left:[{left:D()}],visibility:["visible","invisible","collapse"],z:[{z:[Ft,"auto",Z,Y]}],basis:[{basis:[cr,"full","auto",a,...x()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Ge,cr,"auto","initial","none",Y]}],grow:[{grow:["",Ge,Z,Y]}],shrink:[{shrink:["",Ge,Z,Y]}],order:[{order:[Ft,"first","last","none",Z,Y]}],"grid-cols":[{"grid-cols":I()}],"col-start-end":[{col:j()}],"col-start":[{"col-start":O()}],"col-end":[{"col-end":O()}],"grid-rows":[{"grid-rows":I()}],"row-start-end":[{row:j()}],"row-start":[{"row-start":O()}],"row-end":[{"row-end":O()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":w()}],"auto-rows":[{"auto-rows":w()}],gap:[{gap:x()}],"gap-x":[{"gap-x":x()}],"gap-y":[{"gap-y":x()}],"justify-content":[{justify:[...ge(),"normal"]}],"justify-items":[{"justify-items":[...ce(),"normal"]}],"justify-self":[{"justify-self":["auto",...ce()]}],"align-content":[{content:["normal",...ge()]}],"align-items":[{items:[...ce(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...ce(),{baseline:["","last"]}]}],"place-content":[{"place-content":ge()}],"place-items":[{"place-items":[...ce(),"baseline"]}],"place-self":[{"place-self":["auto",...ce()]}],p:[{p:x()}],px:[{px:x()}],py:[{py:x()}],ps:[{ps:x()}],pe:[{pe:x()}],pbs:[{pbs:x()}],pbe:[{pbe:x()}],pt:[{pt:x()}],pr:[{pr:x()}],pb:[{pb:x()}],pl:[{pl:x()}],m:[{m:L()}],mx:[{mx:L()}],my:[{my:L()}],ms:[{ms:L()}],me:[{me:L()}],mbs:[{mbs:L()}],mbe:[{mbe:L()}],mt:[{mt:L()}],mr:[{mr:L()}],mb:[{mb:L()}],ml:[{ml:L()}],"space-x":[{"space-x":x()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":x()}],"space-y-reverse":["space-y-reverse"],size:[{size:_()}],"inline-size":[{inline:["auto",...K()]}],"min-inline-size":[{"min-inline":["auto",...K()]}],"max-inline-size":[{"max-inline":["none",...K()]}],"block-size":[{block:["auto",...ee()]}],"min-block-size":[{"min-block":["auto",...ee()]}],"max-block-size":[{"max-block":["none",...ee()]}],w:[{w:[a,"screen",..._()]}],"min-w":[{"min-w":[a,"screen","none",..._()]}],"max-w":[{"max-w":[a,"screen","none","prose",{screen:[s]},..._()]}],h:[{h:["screen","lh",..._()]}],"min-h":[{"min-h":["screen","lh","none",..._()]}],"max-h":[{"max-h":["screen","lh",..._()]}],"font-size":[{text:["base",t,Jr,yr]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,Lh,Sh]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Ni,Y]}],"font-family":[{font:[$h,Ch,e]}],"font-features":[{"font-features":[Y]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[i,Z,Y]}],"line-clamp":[{"line-clamp":[Ge,"none",Z,Is]}],leading:[{leading:[o,...x()]}],"list-image":[{"list-image":["none",Z,Y]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Z,Y]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:M()}],"text-color":[{text:M()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...Ye(),"wavy"]}],"text-decoration-thickness":[{decoration:[Ge,"from-font","auto",Z,yr]}],"text-decoration-color":[{decoration:M()}],"underline-offset":[{"underline-offset":[Ge,"auto",Z,Y]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:x()}],"tab-size":[{tab:[Ft,Z,Y]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Z,Y]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Z,Y]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:Re()}],"bg-repeat":[{bg:ae()}],"bg-size":[{bg:W()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Ft,Z,Y],radial:["",Z,Y],conic:[Ft,Z,Y]},Ih,Ah]}],"bg-color":[{bg:M()}],"gradient-from-pos":[{from:Se()}],"gradient-via-pos":[{via:Se()}],"gradient-to-pos":[{to:Se()}],"gradient-from":[{from:M()}],"gradient-via":[{via:M()}],"gradient-to":[{to:M()}],rounded:[{rounded:Ce()}],"rounded-s":[{"rounded-s":Ce()}],"rounded-e":[{"rounded-e":Ce()}],"rounded-t":[{"rounded-t":Ce()}],"rounded-r":[{"rounded-r":Ce()}],"rounded-b":[{"rounded-b":Ce()}],"rounded-l":[{"rounded-l":Ce()}],"rounded-ss":[{"rounded-ss":Ce()}],"rounded-se":[{"rounded-se":Ce()}],"rounded-ee":[{"rounded-ee":Ce()}],"rounded-es":[{"rounded-es":Ce()}],"rounded-tl":[{"rounded-tl":Ce()}],"rounded-tr":[{"rounded-tr":Ce()}],"rounded-br":[{"rounded-br":Ce()}],"rounded-bl":[{"rounded-bl":Ce()}],"border-w":[{border:be()}],"border-w-x":[{"border-x":be()}],"border-w-y":[{"border-y":be()}],"border-w-s":[{"border-s":be()}],"border-w-e":[{"border-e":be()}],"border-w-bs":[{"border-bs":be()}],"border-w-be":[{"border-be":be()}],"border-w-t":[{"border-t":be()}],"border-w-r":[{"border-r":be()}],"border-w-b":[{"border-b":be()}],"border-w-l":[{"border-l":be()}],"divide-x":[{"divide-x":be()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":be()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...Ye(),"hidden","none"]}],"divide-style":[{divide:[...Ye(),"hidden","none"]}],"border-color":[{border:M()}],"border-color-x":[{"border-x":M()}],"border-color-y":[{"border-y":M()}],"border-color-s":[{"border-s":M()}],"border-color-e":[{"border-e":M()}],"border-color-bs":[{"border-bs":M()}],"border-color-be":[{"border-be":M()}],"border-color-t":[{"border-t":M()}],"border-color-r":[{"border-r":M()}],"border-color-b":[{"border-b":M()}],"border-color-l":[{"border-l":M()}],"divide-color":[{divide:M()}],"outline-style":[{outline:[...Ye(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Ge,Z,Y]}],"outline-w":[{outline:["",Ge,Jr,yr]}],"outline-color":[{outline:M()}],shadow:[{shadow:["","none",d,Mn,zn]}],"shadow-color":[{shadow:M()}],"inset-shadow":[{"inset-shadow":["none",f,Mn,zn]}],"inset-shadow-color":[{"inset-shadow":M()}],"ring-w":[{ring:be()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:M()}],"ring-offset-w":[{"ring-offset":[Ge,yr]}],"ring-offset-color":[{"ring-offset":M()}],"inset-ring-w":[{"inset-ring":be()}],"inset-ring-color":[{"inset-ring":M()}],"text-shadow":[{"text-shadow":["none",h,Mn,zn]}],"text-shadow-color":[{"text-shadow":M()}],opacity:[{opacity:[Ge,Z,Y]}],"mix-blend":[{"mix-blend":[...ot(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":ot()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Ge]}],"mask-image-linear-from-pos":[{"mask-linear-from":Ae()}],"mask-image-linear-to-pos":[{"mask-linear-to":Ae()}],"mask-image-linear-from-color":[{"mask-linear-from":M()}],"mask-image-linear-to-color":[{"mask-linear-to":M()}],"mask-image-t-from-pos":[{"mask-t-from":Ae()}],"mask-image-t-to-pos":[{"mask-t-to":Ae()}],"mask-image-t-from-color":[{"mask-t-from":M()}],"mask-image-t-to-color":[{"mask-t-to":M()}],"mask-image-r-from-pos":[{"mask-r-from":Ae()}],"mask-image-r-to-pos":[{"mask-r-to":Ae()}],"mask-image-r-from-color":[{"mask-r-from":M()}],"mask-image-r-to-color":[{"mask-r-to":M()}],"mask-image-b-from-pos":[{"mask-b-from":Ae()}],"mask-image-b-to-pos":[{"mask-b-to":Ae()}],"mask-image-b-from-color":[{"mask-b-from":M()}],"mask-image-b-to-color":[{"mask-b-to":M()}],"mask-image-l-from-pos":[{"mask-l-from":Ae()}],"mask-image-l-to-pos":[{"mask-l-to":Ae()}],"mask-image-l-from-color":[{"mask-l-from":M()}],"mask-image-l-to-color":[{"mask-l-to":M()}],"mask-image-x-from-pos":[{"mask-x-from":Ae()}],"mask-image-x-to-pos":[{"mask-x-to":Ae()}],"mask-image-x-from-color":[{"mask-x-from":M()}],"mask-image-x-to-color":[{"mask-x-to":M()}],"mask-image-y-from-pos":[{"mask-y-from":Ae()}],"mask-image-y-to-pos":[{"mask-y-to":Ae()}],"mask-image-y-from-color":[{"mask-y-from":M()}],"mask-image-y-to-color":[{"mask-y-to":M()}],"mask-image-radial":[{"mask-radial":[Z,Y]}],"mask-image-radial-from-pos":[{"mask-radial-from":Ae()}],"mask-image-radial-to-pos":[{"mask-radial-to":Ae()}],"mask-image-radial-from-color":[{"mask-radial-from":M()}],"mask-image-radial-to-color":[{"mask-radial-to":M()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":p()}],"mask-image-conic-pos":[{"mask-conic":[Ge]}],"mask-image-conic-from-pos":[{"mask-conic-from":Ae()}],"mask-image-conic-to-pos":[{"mask-conic-to":Ae()}],"mask-image-conic-from-color":[{"mask-conic-from":M()}],"mask-image-conic-to-color":[{"mask-conic-to":M()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:Re()}],"mask-repeat":[{mask:ae()}],"mask-size":[{mask:W()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Z,Y]}],filter:[{filter:["","none",Z,Y]}],blur:[{blur:ve()}],brightness:[{brightness:[Ge,Z,Y]}],contrast:[{contrast:[Ge,Z,Y]}],"drop-shadow":[{"drop-shadow":["","none",g,Mn,zn]}],"drop-shadow-color":[{"drop-shadow":M()}],grayscale:[{grayscale:["",Ge,Z,Y]}],"hue-rotate":[{"hue-rotate":[Ge,Z,Y]}],invert:[{invert:["",Ge,Z,Y]}],saturate:[{saturate:[Ge,Z,Y]}],sepia:[{sepia:["",Ge,Z,Y]}],"backdrop-filter":[{"backdrop-filter":["","none",Z,Y]}],"backdrop-blur":[{"backdrop-blur":ve()}],"backdrop-brightness":[{"backdrop-brightness":[Ge,Z,Y]}],"backdrop-contrast":[{"backdrop-contrast":[Ge,Z,Y]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Ge,Z,Y]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Ge,Z,Y]}],"backdrop-invert":[{"backdrop-invert":["",Ge,Z,Y]}],"backdrop-opacity":[{"backdrop-opacity":[Ge,Z,Y]}],"backdrop-saturate":[{"backdrop-saturate":[Ge,Z,Y]}],"backdrop-sepia":[{"backdrop-sepia":["",Ge,Z,Y]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":x()}],"border-spacing-x":[{"border-spacing-x":x()}],"border-spacing-y":[{"border-spacing-y":x()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Z,Y]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Ge,"initial",Z,Y]}],ease:[{ease:["linear","initial",m,Z,Y]}],delay:[{delay:[Ge,Z,Y]}],animate:[{animate:["none",A,Z,Y]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[C,Z,Y]}],"perspective-origin":[{"perspective-origin":E()}],rotate:[{rotate:X()}],"rotate-x":[{"rotate-x":X()}],"rotate-y":[{"rotate-y":X()}],"rotate-z":[{"rotate-z":X()}],scale:[{scale:me()}],"scale-x":[{"scale-x":me()}],"scale-y":[{"scale-y":me()}],"scale-z":[{"scale-z":me()}],"scale-3d":["scale-3d"],skew:[{skew:et()}],"skew-x":[{"skew-x":et()}],"skew-y":[{"skew-y":et()}],transform:[{transform:[Z,Y,"","none","gpu","cpu"]}],"transform-origin":[{origin:E()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:J()}],"translate-x":[{"translate-x":J()}],"translate-y":[{"translate-y":J()}],"translate-z":[{"translate-z":J()}],"translate-none":["translate-none"],zoom:[{zoom:[Ft,Z,Y]}],accent:[{accent:M()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:M()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Z,Y]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":M()}],"scrollbar-track-color":[{"scrollbar-track":M()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":x()}],"scroll-mx":[{"scroll-mx":x()}],"scroll-my":[{"scroll-my":x()}],"scroll-ms":[{"scroll-ms":x()}],"scroll-me":[{"scroll-me":x()}],"scroll-mbs":[{"scroll-mbs":x()}],"scroll-mbe":[{"scroll-mbe":x()}],"scroll-mt":[{"scroll-mt":x()}],"scroll-mr":[{"scroll-mr":x()}],"scroll-mb":[{"scroll-mb":x()}],"scroll-ml":[{"scroll-ml":x()}],"scroll-p":[{"scroll-p":x()}],"scroll-px":[{"scroll-px":x()}],"scroll-py":[{"scroll-py":x()}],"scroll-ps":[{"scroll-ps":x()}],"scroll-pe":[{"scroll-pe":x()}],"scroll-pbs":[{"scroll-pbs":x()}],"scroll-pbe":[{"scroll-pbe":x()}],"scroll-pt":[{"scroll-pt":x()}],"scroll-pr":[{"scroll-pr":x()}],"scroll-pb":[{"scroll-pb":x()}],"scroll-pl":[{"scroll-pl":x()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Z,Y]}],fill:[{fill:["none",...M()]}],"stroke-w":[{stroke:[Ge,Jr,yr,Is]}],stroke:[{stroke:["none",...M()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},Gh=(r,{extend:e={},override:t={}})=>(Nn(r.theme,t.theme),Nn(r.classGroups,t.classGroups),Nn(r.conflictingClassGroups,t.conflictingClassGroups),Nn(r.conflictingClassGroupModifiers,t.conflictingClassGroupModifiers),go(r,"postfixLookupClassGroups",t.postfixLookupClassGroups),go(r,"orderSensitiveModifiers",t.orderSensitiveModifiers),Pn(r.theme,e.theme),Pn(r.classGroups,e.classGroups),Pn(r.conflictingClassGroups,e.conflictingClassGroups),Pn(r.conflictingClassGroupModifiers,e.conflictingClassGroupModifiers),mo(r,e,"postfixLookupClassGroups"),mo(r,e,"orderSensitiveModifiers"),r),go=(r,e,t)=>{t!==void 0&&(r[e]=t)},Nn=(r,e)=>{if(e)for(const t in e)go(r,t,e[t])},Pn=(r,e)=>{if(e)for(const t in e)mo(r,e,t)},mo=(r,e,t)=>{const n=e[t];n!==void 0&&(r[t]=r[t]?r[t].concat(n):n)},uc=r=>Ds(r?typeof r=="function"?()=>r(Pi()):()=>Gh(Pi(),r):Pi),Rh=r=>{if(Mt(r))return;const e=r,t={...e.extend??{}};for(const i of["theme","classGroups","conflictingClassGroups","conflictingClassGroupModifiers","postfixLookupClassGroups","orderSensitiveModifiers","cacheSize","prefix","separator","experimentalParseClassName"])e[i]!==void 0&&t[i]===void 0&&(t[i]=e[i]);const n={};if(Object.keys(t).length>0&&(n.extend=t),e.override!=null&&!Mt(e.override)&&(n.override=e.override),!(!n.extend&&!n.override))return n},Oh=r=>{const e=Rh(r),t=uc(e);return n=>t.mergeString(n)},Hn,zh=()=>(Hn||(Hn=uc()),Hn),Mh=()=>((!Ct.cachedTwMerge||Ct.didTwMergeConfigChange)&&(Ct.didTwMergeConfigChange=!1,Ct.cachedTwMerge=Oh(Ct.cachedTwMergeConfig)),Ct.cachedTwMerge),Nh=r=>{const e=r==null?void 0:r.twMergeConfig;!e||Mt(e)||Ua(e,Ct.cachedTwMergeConfig)||(Ct.cachedTwMergeConfig=e,Ct.didTwMergeConfigChange=!0)},Ph=r=>si(r),Uh=Ct.reset.bind(Ct);Ct.reset=()=>{Hn=void 0,Uh()};var Wh=(r,e)=>{const t=Ph(r);return!t||!((e==null?void 0:e.twMerge)??!0)?t||void 0:t.indexOf(" ")===-1?t:(Nh(e),(!!(e!=null&&e.twMergeConfig&&!Mt(e.twMergeConfig))?Mh():zh().mergeString)(t)||void 0)},jh=(r,...e)=>Wh(e,r),Bh=Mf(jh),Fh=Bh.tv;function Vh(r){const e=r==="muted"?"ink-muted":r;return e==="current"?"currentColor":`var(--reddb-color-${e})`}function Kh(r){return`var(--reddb-spatial-icon-size-${r})`}var Hh=At('<svg><path d="M4 5h16"></path><path d="M4 12h16"></path><path d="M4 19h16"></path></svg>');function qh(r,e){ii(e,!0);let t=Gt(e,"size",3,"md"),n=Gt(e,"color",3,"foreground"),i=Ze(e,["$$slots","$$events","$$legacy","icon","size","color","class"]);const o=Q(()=>Kh(t())),s=Q(()=>Vh(n())),a=Q(()=>e.icon);Zt(()=>{n()});var c=er(),l=lt(c);{var d=h=>{var g=Hh();Yn(g,()=>({...i,"data-icon":!0,width:u(o),height:u(o),viewBox:"0 0 24 24",fill:"none",stroke:u(s),"stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:e.class})),V(h,g)},f=h=>{var g=er(),y=lt(g);Fu(y,()=>u(a),(C,b)=>{b(C,it(()=>i,{"data-icon":!0,get size(){return u(o)},get color(){return u(s)},strokeWidth:2,get class(){return e.class}}))}),V(h,g)};ke(l,h=>{e.icon==="menu"?h(d):h(f,-1)})}V(r,c),oi()}const Yh={sm:{root:"gap-[var(--reddb-spatial-gap-md)] px-[var(--reddb-spatial-inset-md)] py-[var(--reddb-spatial-inset-lg)]",title:"text-sm",description:"text-xs",hint:"text-xs"},md:{root:"gap-[var(--reddb-spatial-gap-lg)] px-[var(--reddb-spatial-inset-lg)] py-10",title:"text-base",description:"text-sm",hint:"text-xs"}},Xh={true:{root:"border-dashed border-muted"},false:{root:"border-transparent"}},Jh=Fh({slots:{root:"flex flex-col items-center justify-center rounded-lg border text-center",media:"text-ink-muted",title:"font-medium leading-tight text-foreground",description:"max-w-prose text-ink-muted",hint:"max-w-full rounded-md border border-muted px-2 py-1 font-mono text-ink-muted",actions:"flex flex-wrap items-center justify-center gap-[var(--reddb-spatial-gap-md)] pt-1"},variants:{size:Yh,bordered:Xh},defaultVariants:{size:"md",bordered:!0}});var Zh=he('<div aria-hidden="true"><!></div>'),Qh=he("<p> </p>"),ep=he("<code> </code>"),tp=he("<div><!></div>"),rp=he("<div><!> <p> </p> <!> <!> <!></div>");function np(r,e){ii(e,!0);const t=Gt(e,"size",3,"md"),n=Gt(e,"bordered",3,!0),i=Ze(e,["$$slots","$$events","$$legacy","title","description","hint","size","bordered","media","actions","class"]),o=Q(()=>Jh({size:t(),bordered:n()}));var s=rp();Yn(s,m=>({...i,class:m}),[()=>u(o).root({class:e.class})]);var a=R(s);{var c=m=>{var A=Zh(),v=R(A);ao(v,()=>e.media),T(A),pe(p=>St(A,1,p),[()=>Dt(u(o).media())]),V(m,A)};ke(a,m=>{e.media&&m(c)})}var l=P(a,2),d=R(l,!0);T(l);var f=P(l,2);{var h=m=>{var A=Qh(),v=R(A,!0);T(A),pe(p=>{St(A,1,p),fe(v,e.description)},[()=>Dt(u(o).description())]),V(m,A)};ke(f,m=>{e.description&&m(h)})}var g=P(f,2);{var y=m=>{var A=ep(),v=R(A,!0);T(A),pe(p=>{St(A,1,p),fe(v,e.hint)},[()=>Dt(u(o).hint())]),V(m,A)};ke(g,m=>{e.hint&&m(y)})}var C=P(g,2);{var b=m=>{var A=tp(),v=R(A);ao(v,()=>e.actions),T(A),pe(p=>St(A,1,p),[()=>Dt(u(o).actions())]),V(m,A)};ke(C,m=>{e.actions&&m(b)})}T(s),pe(m=>{St(l,1,m),fe(d,e.title)},[()=>Dt(u(o).title())]),V(r,s),oi()}const ip="red-ui:history",op="history:";function dc(r,e=!1){switch(r){case"embedded":return"none";case"standalone":return"vault";case"web":return e?"none":"labels-only"}}function sp(r){if(r.url)try{const t=new URL(r.url).host;if(t)return t}catch{}const e=(r.label??r.url??"").trim();if(!e)return"";try{const t=new URL(e).host;if(t)return t}catch{}return e.includes("@")?e.slice(e.lastIndexOf("@")+1):e}function ap(){return typeof localStorage>"u"?void 0:localStorage}function Gs(r){return`label:${encodeURIComponent(r)}`}function cp(){return typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():Math.random().toString(36).slice(2)+Date.now().toString(36)}function Zr(r,e){if(!r)return[];try{const t=r.getItem(e);if(!t)return[];const n=JSON.parse(t);return Array.isArray(n)?n.filter(i=>i&&typeof i.id=="string"&&typeof i.label=="string").map(i=>({id:i.id,label:i.label,last_used:i.last_used,rtt_ms:i.rtt_ms})):[]}catch{return[]}}function Rs(r,e,t){if(r)try{r.setItem(e,JSON.stringify(t))}catch{}}class lp{constructor(e){Te(this,"surface");Te(this,"secureStore");Te(this,"managedWebTarget");Te(this,"storage");Te(this,"historyKey");Te(this,"urlPrefix");Te(this,"idByUrl",new Map);Te(this,"urlById",new Map);Te(this,"onChange");this.surface=e.surface,this.secureStore=e.secureStore,this.managedWebTarget=e.managedWebTarget??(()=>!1),this.storage=e.storage??ap(),this.historyKey=e.historyKey??ip,this.urlPrefix=e.urlPrefix??op}setOnChange(e){this.onChange=e}persistence(){return dc(this.surface(),this.managedWebTarget())}load(){return this.persistence()==="none"?[]:Zr(this.storage,this.historyKey).map(e=>({url:this.urlById.get(e.id)??"",label:e.label,last_used:e.last_used,rtt_ms:e.rtt_ms}))}save(e){var c,l,d;const t=this.persistence();if(t==="none"){(c=this.onChange)==null||c.call(this);return}const n=Zr(this.storage,this.historyKey),i=new Map(n.map(f=>[f.label,f])),o=[],s=new Set,a=new Set;for(const f of e){const h=sp(f);if(!h)continue;let g;f.url?(g=t==="labels-only"?Gs(h):this.idByUrl.get(f.url)??cp(),this.idByUrl.set(f.url,g),this.urlById.set(g,f.url)):g=((l=i.get(h))==null?void 0:l.id)??Gs(h),!(s.has(g)||!f.url&&a.has(h))&&(s.add(g),a.add(h),o.push({id:g,label:h,last_used:typeof f.last_used=="number"?f.last_used:Date.now(),rtt_ms:f.rtt_ms}))}if(Rs(this.storage,this.historyKey,o),t==="vault"){const f=this.secureStore();if(f)for(const h of o){const g=this.urlById.get(h.id);g&&f.put(this.urlPrefix+h.id,g).catch(()=>{})}}(d=this.onChange)==null||d.call(this)}uiEntries(){return this.persistence()==="none"?[]:Zr(this.storage,this.historyKey).map(e=>({id:e.id,label:e.label,last_used:e.last_used,rtt_ms:e.rtt_ms,url:this.urlById.get(e.id)}))}async hydrate(){var i;if(this.persistence()!=="vault")return;const e=this.secureStore();if(!e)return;const t=Zr(this.storage,this.historyKey);let n=!1;for(const o of t)if(!this.urlById.has(o.id))try{const s=await e.get(this.urlPrefix+o.id);s&&(this.urlById.set(o.id,s),this.idByUrl.set(s,o.id),n=!0)}catch{}n&&((i=this.onChange)==null||i.call(this))}async forgetById(e){var o,s;if(this.persistence()==="none"){(o=this.onChange)==null||o.call(this);return}const t=Zr(this.storage,this.historyKey).filter(a=>a.id!==e);Rs(this.storage,this.historyKey,t);const n=this.urlById.get(e);n&&(this.urlById.delete(e),this.idByUrl.delete(n));const i=this.persistence()==="vault"?this.secureStore():null;if(i)try{await i.delete(this.urlPrefix+e)}catch{}(s=this.onChange)==null||s.call(this)}async forgetByUrl(e){const t=this.idByUrl.get(e);t&&await this.forgetById(t)}}function up({tauri:r,inFrame:e,mcp:t,embedLib:n}){return r?"standalone":e||t||n?"embedded":"web"}function dp(){if(typeof window>"u")return"web";const r="__TAURI_INTERNALS__"in window||"__TAURI__"in window;let e=!1;try{e=window.self!==window.top}catch{e=!0}const t=typeof location<"u"&&new URLSearchParams(location.search).has("mcp"),n=window.__RED_UI_EMBED_SURFACE__===!0;return up({tauri:r,inFrame:e,mcp:t,embedLib:n})}function Ui(r,e){switch(r){case"embedded":return!1;case"standalone":return!0;case"web":return!1}}const vo="red-ui:secure",Os="__probe__",zs="ok";function Ms(){if(typeof localStorage>"u")return!1;for(let r=0;r<localStorage.length;r++){const e=localStorage.key(r);if(e&&e.startsWith(vo+":"))return!0}return!1}var mn,vn,yn,bn,wn,_n;class fp{constructor(){nt(this,mn,Ee(null));nt(this,vn,Ee(!0));nt(this,yn,Ee(!1));nt(this,bn,Ee("unknown"));nt(this,wn,Ee("web"));nt(this,_n,Ee(null));if(typeof window>"u"){this.backend="unknown";return}if(this.surface=dp(),this.surface==="standalone"){this.backend="tauri",this.bindTauri();return}this.backend="web",Ms(),this.needsSetup=!1,this.locked=Ui(this.surface)}get store(){return u(xe(this,mn))}set store(e){N(xe(this,mn),e,!0)}get locked(){return u(xe(this,vn))}set locked(e){N(xe(this,vn),e,!0)}get needsSetup(){return u(xe(this,yn))}set needsSetup(e){N(xe(this,yn),e,!0)}get backend(){return u(xe(this,bn))}set backend(e){N(xe(this,bn),e,!0)}get surface(){return u(xe(this,wn))}set surface(e){N(xe(this,wn),e,!0)}get error(){return u(xe(this,_n))}set error(e){N(xe(this,_n),e,!0)}async bindTauri(){try{const e=await hr(()=>import("./DhEqZVGG.js"),[],import.meta.url);this.store=new Jd({invoke:e.invoke}),this.locked=!1}catch(e){this.error=`Tauri keychain bridge unavailable: ${e.message}`}}async unlock(e){if(this.error=null,this.backend!=="web")return!0;let t;try{t=new Yd(e,{namespace:vo})}catch(n){return this.error=n.message,!1}try{const n=await t.get(Os);if(n===null)await t.put(Os,zs);else if(n!==zs)return this.error="Wrong password",!1}catch(n){return n instanceof wt&&n.code==="DECRYPT_FAILED"?(this.error="Wrong password",!1):(this.error=n.message,!1)}return this.store=t,this.locked=!1,this.needsSetup=!1,!0}lock(){this.store=null,this.backend==="web"&&(this.locked=Ui(this.surface,Ms()))}wipe(){if(typeof localStorage>"u")return;const e=[];for(let t=0;t<localStorage.length;t++){const n=localStorage.key(t);n&&(n.startsWith(vo+":")||n.startsWith("red-ui:"))&&e.push(n)}for(const t of e)localStorage.removeItem(t);this.store=null,this.backend==="web"&&(this.locked=Ui(this.surface),this.needsSetup=!1),this.error=null}}mn=new WeakMap,vn=new WeakMap,yn=new WeakMap,bn=new WeakMap,wn=new WeakMap,_n=new WeakMap;const cn=new fp,fc=[{id:"embedded",label:"Embedded",url:"http://localhost:5055",role:"embedded",description:"Local file via ./scripts/embedded.sh."},{id:"docker-primary",label:"Docker primary",url:"http://localhost:15055",role:"primary",description:"Docker compose primary (./docker/compose.yml)."},{id:"docker-replica",label:"Docker replica",url:"http://localhost:25055",role:"replica",description:"Read-only mirror of docker primary."}],Ns=Ma;function Ps(r){if(typeof localStorage>"u")return;if(gp()!=="vault"){try{localStorage.removeItem(Ns)}catch{}return}try{localStorage.setItem(Ns,JSON.stringify(r))}catch{}}const hp=/(handoff|token|secret|password|passwd|auth|credential|api[-_]?key|bearer)/i;let $o=!1;function pp(){cn.surface==="web"&&($o=!0)}function hc(){if($o)return!0;if(cn.surface!=="web"||typeof location>"u")return!1;for(const r of[location.search,location.hash]){const e=new URLSearchParams(r.startsWith("#")?r.slice(1):r);for(const t of e.keys())if(hp.test(t))return!0}return!1}function gp(){return dc(cn.surface,hc())}const br=new lp({surface:()=>cn.surface,secureStore:()=>cn.store,managedWebTarget:hc});function mp(r){return r.trim()?pr(r).url:""}function oy(r){if(!r.trim())return{url:""};try{return pr(r)}catch{throw new Error("Invalid connection string. Check the address and provide both username and password.")}}function on(r){const e=mp(r);let t=e;try{t=new URL(e).host}catch{}return{id:e,label:t||e,url:e,role:"primary",description:"User-provided connection string."}}function ai(){return typeof window<"u"&&("__TAURI_INTERNALS__"in window||"__TAURI__"in window)}function vp(){return[...ai()?bd:_o]}async function yp(r){if(!ai())throw new Error("file:// databases can only be opened in the desktop app");const e=r.replace(/^file:\/\//i,""),{invoke:t}=await hr(async()=>{const{invoke:n}=await import("./DhEqZVGG.js");return{invoke:n}},[],import.meta.url);try{return await t("open_embedded",{path:e})}catch(n){throw Jn.from(n)}}const pc=async(r,e)=>{const t=typeof r=="string"?r:r instanceof URL?r.href:r.url,n=/^https?:\/\/(127\.0\.0\.1|localhost|\[::1\])(:\d+)?(\/|$)/i.test(t);if(ai()&&n)try{const{fetch:i}=await hr(async()=>{const{fetch:o}=await import("./B5euRbKa.js");return{fetch:o}},__vite__mapDeps([0,1]),import.meta.url);return await i(r,e)}catch(i){const o=i instanceof Error?i.message:typeof i=="string"?i:String(i);throw new Error(`rust-side fetch failed for ${t}: ${o}`)}return fetch(r,e)};function Us(r){return typeof r.useHandoffToken=="function"}const bp=new Rd({presets:fc,history:br,transports:vp(),embeddedResolver:yp,clientFactory:(r,e)=>new wo(r,{...e,fetch:pc}),bootParams:Dd(typeof location<"u"?location.search:"",typeof location<"u"?location.hash:"")});let gc=bp;function Or(){return gc}function sy(r){gc=r}var xn,kn,En,Sn,dr,_r,Pr;class wp{constructor(){nt(this,xn,Ee(!1));nt(this,kn,Ee(Kt(fc[1])));nt(this,En,Ee(Kt({reachable:!1})));nt(this,Sn,Ee(Kt([])));nt(this,dr,Ee(null));nt(this,_r,Ee(Kt({...fr})));nt(this,Pr,Ee(!1));this.history=br.uiEntries(),br.setOnChange(()=>{this.history=br.uiEntries()})}get connected(){return u(xe(this,xn))}set connected(e){N(xe(this,xn),e,!0)}get active(){return u(xe(this,kn))}set active(e){N(xe(this,kn),e,!0)}get probe(){return u(xe(this,En))}set probe(e){N(xe(this,En),e,!0)}get history(){return u(xe(this,Sn))}set history(e){N(xe(this,Sn),e,!0)}get targetResolved(){return u(xe(this,Pr))}get client(){return u(xe(this,dr))}get readOnly(){var e;return this.connected&&((e=this.probe.stats)==null?void 0:e.read_only)===!0}get readOnlyReason(){var e;return(e=this.probe.stats)==null?void 0:e.read_only_reason}get capabilities(){return u(xe(this,_r))}get supportedTransports(){var e,t;return((t=(e=Or()).transports)==null?void 0:t.call(e))??[..._o]}canReach(e){return wd(e,this.supportedTransports)}async forget(e){await br.forgetByUrl(e)}async forgetById(e){await br.forgetById(e)}async hydrateUrls(){await br.hydrate()}async bootstrap(e=Vd){const t=await e(),n=t.route??null;if(t.error)return this.disconnect(),this.probe={reachable:!1,error:t.error},n;if(!t.target)return n;if(!t.token)return await this.connectString(t.target),n;let i;try{const o=pr(t.target);if(o.credentials)throw new Error("Choose either connection credentials or a session token.");i=on(o.url)}catch(o){return this.disconnect(),this.active=on(""),this.probe={reachable:!1,error:o instanceof Error?o.message:"Invalid connection string."},n}if(t.token){pp();const o=Or();Us(o)&&o.useHandoffToken(i.url,t.token)}return await this.tryConnect(i),n}async switch(e){this.active=e,Ps(e),await this.tryConnect(e)}async connectString(e,t){try{const n=pr(e);if(n.credentials&&t)throw new Error("Use credentials in either the connection string or the sign-in fields.");const i=t??n.credentials,o=on(n.url);if(!this.canReach(n.url))throw new Error(_p(n.url)??"This connection transport is not available here.");return i?await this.login(o,i.username,i.password):await this.tryConnect(o)}catch(n){return this.disconnect(),this.active=on(""),this.probe={reachable:!1,error:n instanceof Error?n.message:"Invalid connection string."},!1}}async login(e,t,n){this.active=e,N(xe(this,dr),null),this.connected=!1,N(xe(this,_r),{...fr},!0),this.probe={reachable:!1};try{const i=Or();if(!Us(i))throw new Error("This connection is managed by its host.");const o=await new wo(e.url,{fetch:pc}).login(t,n);return i.useHandoffToken(e.url,o),await this.tryConnect(e)}catch(i){return this.probe={reachable:!1,error:i instanceof Error?i.message:"Database sign-in failed."},!1}}async tryConnect(e){this.active=e,N(xe(this,dr),null),this.connected=!1,N(xe(this,Pr),!0),Xr.begin(`Opening ${e.label}`);try{Xr.step("Reaching server",e.url);const t=await lr.track(`connect · ${e.label}`,()=>Or().connect(e.id));N(xe(this,dr),t.client,!0),this.active={...e,...t.connection,description:e.description},Ps(this.active),Xr.step("Fetching stats & capabilities");const[n,i,o]=await Promise.all([lr.track(`connect · ${e.label} stats`,()=>t.client.stats()).catch(()=>{}),lr.track(`connect · ${e.label} replication`,()=>t.client.replication()).catch(()=>{}),lr.track(`connect · ${e.label} capabilities`,()=>t.client.capabilities()).catch(()=>({...fr}))]);return this.probe={reachable:!0,rtt_ms:t.rtt_ms,stats:n,replication:i},N(xe(this,_r),o,!0),this.connected=!0,Xr.succeed(),!0}catch(t){return this.probe={reachable:!1,error:t.message},Xr.fail(t.message),!1}}async adoptInjected(){const[e]=await Or().list();if(!e)return!1;const t={...e,description:e.description??"Injected by the embedding host."};return this.tryConnect(t)}async connectFromBootParams(){var n,i;const e=(i=(n=Or()).bootParams)==null?void 0:i.call(n);if(!e)return null;const t=e.to??e.view??null;return e.endpoint&&await this.connectString(e.endpoint),t}async refresh(){const e=this.client;if(!e){await this.tryConnect(this.active);return}try{const t=await lr.track(`heartbeat · ${this.active.label}`,()=>e.ping());if(!t.ok){this.probe={reachable:!1,error:t.error};return}const[n,i]=await Promise.all([lr.track("heartbeat · stats",()=>e.stats()).catch(()=>{}),lr.track("heartbeat · replication",()=>e.replication()).catch(()=>{})]);this.probe={reachable:!0,rtt_ms:t.rtt_ms,stats:n,replication:i},this.connected=!0}catch(t){this.probe={reachable:!1,error:t.message}}}disconnect(){this.connected=!1,this.probe={reachable:!1},N(xe(this,dr),null),N(xe(this,_r),{...fr},!0),N(xe(this,Pr),!1),$o=!1}}xn=new WeakMap,kn=new WeakMap,En=new WeakMap,Sn=new WeakMap,dr=new WeakMap,_r=new WeakMap,Pr=new WeakMap;const Qn=new wp,mc="Local database files (file://) can only be opened in the desktop app — the web version can't reach files on your machine.";function _p(r){return Qn.canReach(r)?null:Ta(r)==="unix"?mc:null}async function ay(r){if(!ai())return{ok:!1,reason:mc};const e=(await hr(async()=>{const{open:i}=await import("./C-kqMbRi.js");return{open:i}},__vite__mapDeps([2,1]),import.meta.url)).open,t=await e({multiple:!1,directory:!1,title:"Open database file",filters:[{name:"reddb database",extensions:["rdb"]}]});return t?await Qn.tryConnect(on(`file://${t}`))?{ok:!0}:{ok:!1,reason:Qn.probe.error??"unreachable"}:{ok:!1,cancelled:!0}}const vc={name:"loader-circle",size:24,node:[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56"}]],aliases:["loader-2"]};vc.node;function xp(r,e){let t=Ze(e,["$$slots","$$events","$$legacy"]);at(r,it(()=>t,{get icon(){return vc}}))}const yc={name:"search",size:24,node:[["path",{d:"m21 21-4.34-4.34"}],["circle",{cx:"11",cy:"11",r:"8"}]]};yc.node;function kp(r,e){let t=Ze(e,["$$slots","$$events","$$legacy"]);at(r,it(()=>t,{get icon(){return yc}}))}const bc={name:"network",size:24,node:[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3"}],["path",{d:"M12 12V8"}]]};bc.node;function Ws(r,e){let t=Ze(e,["$$slots","$$events","$$legacy"]);at(r,it(()=>t,{get icon(){return bc}}))}function cy(r){return r?r==="graph"?"graph":r:"table"}function ly(r,e){switch(r){case"graph":case"svg":return"graph";case"table":return"table";case"json":return"json";case"hypertable":case"kv":case"vector":case"queue":case"stats":case"diff":case"document":return r;default:return e}}function Wi(r,e){return`/c/${encodeURIComponent(r)}/p/${encodeURIComponent(e)}`}const wc={name:"triangle-alert",size:24,node:[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"}],["path",{d:"M12 9v4"}],["path",{d:"M12 17h.01"}]],aliases:["alert-triangle"]};wc.node;function js(r,e){let t=Ze(e,["$$slots","$$events","$$legacy"]);at(r,it(()=>t,{get icon(){return wc}}))}const _c={name:"play",size:24,node:[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z"}]]};_c.node;function Ep(r,e){let t=Ze(e,["$$slots","$$events","$$legacy"]);at(r,it(()=>t,{get icon(){return _c}}))}const xc={name:"rotate-cw",size:24,node:[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"}],["path",{d:"M21 3v5h-5"}]]};xc.node;function Sp(r,e){let t=Ze(e,["$$slots","$$events","$$legacy"]);at(r,it(()=>t,{get icon(){return xc}}))}function Do(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Un={exports:{}},Bs;function Cp(){if(Bs)return Un.exports;Bs=1;var r=typeof Reflect=="object"?Reflect:null,e=r&&typeof r.apply=="function"?r.apply:function(E,S,$){return Function.prototype.apply.call(E,S,$)},t;r&&typeof r.ownKeys=="function"?t=r.ownKeys:Object.getOwnPropertySymbols?t=function(E){return Object.getOwnPropertyNames(E).concat(Object.getOwnPropertySymbols(E))}:t=function(E){return Object.getOwnPropertyNames(E)};function n(p){console&&console.warn&&console.warn(p)}var i=Number.isNaN||function(E){return E!==E};function o(){o.init.call(this)}Un.exports=o,Un.exports.once=m,o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function a(p){if(typeof p!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof p)}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(p){if(typeof p!="number"||p<0||i(p))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+p+".");s=p}}),o.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(E){if(typeof E!="number"||E<0||i(E))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+E+".");return this._maxListeners=E,this};function c(p){return p._maxListeners===void 0?o.defaultMaxListeners:p._maxListeners}o.prototype.getMaxListeners=function(){return c(this)},o.prototype.emit=function(E){for(var S=[],$=1;$<arguments.length;$++)S.push(arguments[$]);var x=E==="error",D=this._events;if(D!==void 0)x=x&&D.error===void 0;else if(!x)return!1;if(x){var I;if(S.length>0&&(I=S[0]),I instanceof Error)throw I;var j=new Error("Unhandled error."+(I?" ("+I.message+")":""));throw j.context=I,j}var O=D[E];if(O===void 0)return!1;if(typeof O=="function")e(O,this,S);else for(var w=O.length,ge=y(O,w),$=0;$<w;++$)e(ge[$],this,S);return!0};function l(p,E,S,$){var x,D,I;if(a(S),D=p._events,D===void 0?(D=p._events=Object.create(null),p._eventsCount=0):(D.newListener!==void 0&&(p.emit("newListener",E,S.listener?S.listener:S),D=p._events),I=D[E]),I===void 0)I=D[E]=S,++p._eventsCount;else if(typeof I=="function"?I=D[E]=$?[S,I]:[I,S]:$?I.unshift(S):I.push(S),x=c(p),x>0&&I.length>x&&!I.warned){I.warned=!0;var j=new Error("Possible EventEmitter memory leak detected. "+I.length+" "+String(E)+" listeners added. Use emitter.setMaxListeners() to increase limit");j.name="MaxListenersExceededWarning",j.emitter=p,j.type=E,j.count=I.length,n(j)}return p}o.prototype.addListener=function(E,S){return l(this,E,S,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(E,S){return l(this,E,S,!0)};function d(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function f(p,E,S){var $={fired:!1,wrapFn:void 0,target:p,type:E,listener:S},x=d.bind($);return x.listener=S,$.wrapFn=x,x}o.prototype.once=function(E,S){return a(S),this.on(E,f(this,E,S)),this},o.prototype.prependOnceListener=function(E,S){return a(S),this.prependListener(E,f(this,E,S)),this},o.prototype.removeListener=function(E,S){var $,x,D,I,j;if(a(S),x=this._events,x===void 0)return this;if($=x[E],$===void 0)return this;if($===S||$.listener===S)--this._eventsCount===0?this._events=Object.create(null):(delete x[E],x.removeListener&&this.emit("removeListener",E,$.listener||S));else if(typeof $!="function"){for(D=-1,I=$.length-1;I>=0;I--)if($[I]===S||$[I].listener===S){j=$[I].listener,D=I;break}if(D<0)return this;D===0?$.shift():C($,D),$.length===1&&(x[E]=$[0]),x.removeListener!==void 0&&this.emit("removeListener",E,j||S)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(E){var S,$,x;if($=this._events,$===void 0)return this;if($.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):$[E]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete $[E]),this;if(arguments.length===0){var D=Object.keys($),I;for(x=0;x<D.length;++x)I=D[x],I!=="removeListener"&&this.removeAllListeners(I);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(S=$[E],typeof S=="function")this.removeListener(E,S);else if(S!==void 0)for(x=S.length-1;x>=0;x--)this.removeListener(E,S[x]);return this};function h(p,E,S){var $=p._events;if($===void 0)return[];var x=$[E];return x===void 0?[]:typeof x=="function"?S?[x.listener||x]:[x]:S?b(x):y(x,x.length)}o.prototype.listeners=function(E){return h(this,E,!0)},o.prototype.rawListeners=function(E){return h(this,E,!1)},o.listenerCount=function(p,E){return typeof p.listenerCount=="function"?p.listenerCount(E):g.call(p,E)},o.prototype.listenerCount=g;function g(p){var E=this._events;if(E!==void 0){var S=E[p];if(typeof S=="function")return 1;if(S!==void 0)return S.length}return 0}o.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]};function y(p,E){for(var S=new Array(E),$=0;$<E;++$)S[$]=p[$];return S}function C(p,E){for(;E+1<p.length;E++)p[E]=p[E+1];p.pop()}function b(p){for(var E=new Array(p.length),S=0;S<E.length;++S)E[S]=p[S].listener||p[S];return E}function m(p,E){return new Promise(function(S,$){function x(I){p.removeListener(E,D),$(I)}function D(){typeof p.removeListener=="function"&&p.removeListener("error",x),S([].slice.call(arguments))}v(p,E,D,{once:!0}),E!=="error"&&A(p,x,{once:!0})})}function A(p,E,S){typeof p.on=="function"&&v(p,"error",E,S)}function v(p,E,S,$){if(typeof p.on=="function")$.once?p.once(E,S):p.on(E,S);else if(typeof p.addEventListener=="function")p.addEventListener(E,function x(D){$.once&&p.removeEventListener(E,x),S(D)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof p)}return Un.exports}var Ap=Cp();function $p(){const r=arguments[0];for(let e=1,t=arguments.length;e<t;e++)if(arguments[e])for(const n in arguments[e])r[n]=arguments[e][n];return r}let ut=$p;typeof Object.assign=="function"&&(ut=Object.assign);function Nt(r,e,t,n){const i=r._nodes.get(e);let o=null;return i&&(n==="mixed"?o=i.out&&i.out[t]||i.undirected&&i.undirected[t]:n==="directed"?o=i.out&&i.out[t]:o=i.undirected&&i.undirected[t]),o}function mt(r){return typeof r=="object"&&r!==null}function kc(r){let e;for(e in r)return!1;return!0}function zt(r,e,t){Object.defineProperty(r,e,{enumerable:!1,configurable:!1,writable:!0,value:t})}function Wt(r,e,t){const n={enumerable:!0,configurable:!0};typeof t=="function"?n.get=t:(n.value=t,n.writable=!1),Object.defineProperty(r,e,n)}function Fs(r){return!(!mt(r)||r.attributes&&!Array.isArray(r.attributes))}function Dp(){let r=Math.floor(Math.random()*256)&255;return()=>r++}function tr(){const r=arguments;let e=null,t=-1;return{[Symbol.iterator](){return this},next(){let n=null;do{if(e===null){if(t++,t>=r.length)return{done:!0};e=r[t][Symbol.iterator]()}if(n=e.next(),n.done){e=null;continue}break}while(!0);return n}}}function jr(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}class Io extends Error{constructor(e){super(),this.name="GraphError",this.message=e}}class q extends Io{constructor(e){super(e),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,q.prototype.constructor)}}class B extends Io{constructor(e){super(e),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,B.prototype.constructor)}}class ue extends Io{constructor(e){super(e),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,ue.prototype.constructor)}}function Ec(r,e){this.key=r,this.attributes=e,this.clear()}Ec.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.undirectedLoops=0,this.directedLoops=0,this.in={},this.out={},this.undirected={}};function Sc(r,e){this.key=r,this.attributes=e,this.clear()}Sc.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function Cc(r,e){this.key=r,this.attributes=e,this.clear()}Cc.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function Br(r,e,t,n,i){this.key=e,this.attributes=i,this.undirected=r,this.source=t,this.target=n}Br.prototype.attach=function(){let r="out",e="in";this.undirected&&(r=e="undirected");const t=this.source.key,n=this.target.key;this.source[r][n]=this,!(this.undirected&&t===n)&&(this.target[e][t]=this)};Br.prototype.attachMulti=function(){let r="out",e="in";const t=this.source.key,n=this.target.key;this.undirected&&(r=e="undirected");const i=this.source[r],o=i[n];if(typeof o>"u"){i[n]=this,this.undirected&&t===n||(this.target[e][t]=this);return}o.previous=this,this.next=o,i[n]=this,this.target[e][t]=this};Br.prototype.detach=function(){const r=this.source.key,e=this.target.key;let t="out",n="in";this.undirected&&(t=n="undirected"),delete this.source[t][e],delete this.target[n][r]};Br.prototype.detachMulti=function(){const r=this.source.key,e=this.target.key;let t="out",n="in";this.undirected&&(t=n="undirected"),this.previous===void 0?this.next===void 0?(delete this.source[t][e],delete this.target[n][r]):(this.next.previous=void 0,this.source[t][e]=this.next,this.target[n][r]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};const Ac=0,$c=1,Ip=2,Dc=3;function rr(r,e,t,n,i,o,s){let a,c,l,d;if(n=""+n,t===Ac){if(a=r._nodes.get(n),!a)throw new B(`Graph.${e}: could not find the "${n}" node in the graph.`);l=i,d=o}else if(t===Dc){if(i=""+i,c=r._edges.get(i),!c)throw new B(`Graph.${e}: could not find the "${i}" edge in the graph.`);const f=c.source.key,h=c.target.key;if(n===f)a=c.target;else if(n===h)a=c.source;else throw new B(`Graph.${e}: the "${n}" node is not attached to the "${i}" edge (${f}, ${h}).`);l=o,d=s}else{if(c=r._edges.get(n),!c)throw new B(`Graph.${e}: could not find the "${n}" edge in the graph.`);t===$c?a=c.source:a=c.target,l=i,d=o}return[a,l,d]}function Lp(r,e,t){r.prototype[e]=function(n,i,o){const[s,a]=rr(this,e,t,n,i,o);return s.attributes[a]}}function Tp(r,e,t){r.prototype[e]=function(n,i){const[o]=rr(this,e,t,n,i);return o.attributes}}function Gp(r,e,t){r.prototype[e]=function(n,i,o){const[s,a]=rr(this,e,t,n,i,o);return s.attributes.hasOwnProperty(a)}}function Rp(r,e,t){r.prototype[e]=function(n,i,o,s){const[a,c,l]=rr(this,e,t,n,i,o,s);return a.attributes[c]=l,this.emit("nodeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:c}),this}}function Op(r,e,t){r.prototype[e]=function(n,i,o,s){const[a,c,l]=rr(this,e,t,n,i,o,s);if(typeof l!="function")throw new q(`Graph.${e}: updater should be a function.`);const d=a.attributes,f=l(d[c]);return d[c]=f,this.emit("nodeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:c}),this}}function zp(r,e,t){r.prototype[e]=function(n,i,o){const[s,a]=rr(this,e,t,n,i,o);return delete s.attributes[a],this.emit("nodeAttributesUpdated",{key:s.key,type:"remove",attributes:s.attributes,name:a}),this}}function Mp(r,e,t){r.prototype[e]=function(n,i,o){const[s,a]=rr(this,e,t,n,i,o);if(!mt(a))throw new q(`Graph.${e}: provided attributes are not a plain object.`);return s.attributes=a,this.emit("nodeAttributesUpdated",{key:s.key,type:"replace",attributes:s.attributes}),this}}function Np(r,e,t){r.prototype[e]=function(n,i,o){const[s,a]=rr(this,e,t,n,i,o);if(!mt(a))throw new q(`Graph.${e}: provided attributes are not a plain object.`);return ut(s.attributes,a),this.emit("nodeAttributesUpdated",{key:s.key,type:"merge",attributes:s.attributes,data:a}),this}}function Pp(r,e,t){r.prototype[e]=function(n,i,o){const[s,a]=rr(this,e,t,n,i,o);if(typeof a!="function")throw new q(`Graph.${e}: provided updater is not a function.`);return s.attributes=a(s.attributes),this.emit("nodeAttributesUpdated",{key:s.key,type:"update",attributes:s.attributes}),this}}const Up=[{name:r=>`get${r}Attribute`,attacher:Lp},{name:r=>`get${r}Attributes`,attacher:Tp},{name:r=>`has${r}Attribute`,attacher:Gp},{name:r=>`set${r}Attribute`,attacher:Rp},{name:r=>`update${r}Attribute`,attacher:Op},{name:r=>`remove${r}Attribute`,attacher:zp},{name:r=>`replace${r}Attributes`,attacher:Mp},{name:r=>`merge${r}Attributes`,attacher:Np},{name:r=>`update${r}Attributes`,attacher:Pp}];function Wp(r){Up.forEach(function({name:e,attacher:t}){t(r,e("Node"),Ac),t(r,e("Source"),$c),t(r,e("Target"),Ip),t(r,e("Opposite"),Dc)})}function jp(r,e,t){r.prototype[e]=function(n,i){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new ue(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new ue(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+n,a=""+i;if(i=arguments[2],o=Nt(this,s,a,t),!o)throw new B(`Graph.${e}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(t!=="mixed")throw new ue(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,o=this._edges.get(n),!o)throw new B(`Graph.${e}: could not find the "${n}" edge in the graph.`)}return o.attributes[i]}}function Bp(r,e,t){r.prototype[e]=function(n){let i;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new ue(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new ue(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+n,s=""+arguments[1];if(i=Nt(this,o,s,t),!i)throw new B(`Graph.${e}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new ue(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,i=this._edges.get(n),!i)throw new B(`Graph.${e}: could not find the "${n}" edge in the graph.`)}return i.attributes}}function Fp(r,e,t){r.prototype[e]=function(n,i){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new ue(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new ue(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+n,a=""+i;if(i=arguments[2],o=Nt(this,s,a,t),!o)throw new B(`Graph.${e}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(t!=="mixed")throw new ue(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,o=this._edges.get(n),!o)throw new B(`Graph.${e}: could not find the "${n}" edge in the graph.`)}return o.attributes.hasOwnProperty(i)}}function Vp(r,e,t){r.prototype[e]=function(n,i,o){let s;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new ue(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new ue(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const a=""+n,c=""+i;if(i=arguments[2],o=arguments[3],s=Nt(this,a,c,t),!s)throw new B(`Graph.${e}: could not find an edge for the given path ("${a}" - "${c}").`)}else{if(t!=="mixed")throw new ue(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,s=this._edges.get(n),!s)throw new B(`Graph.${e}: could not find the "${n}" edge in the graph.`)}return s.attributes[i]=o,this.emit("edgeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:i}),this}}function Kp(r,e,t){r.prototype[e]=function(n,i,o){let s;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new ue(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new ue(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const a=""+n,c=""+i;if(i=arguments[2],o=arguments[3],s=Nt(this,a,c,t),!s)throw new B(`Graph.${e}: could not find an edge for the given path ("${a}" - "${c}").`)}else{if(t!=="mixed")throw new ue(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,s=this._edges.get(n),!s)throw new B(`Graph.${e}: could not find the "${n}" edge in the graph.`)}if(typeof o!="function")throw new q(`Graph.${e}: updater should be a function.`);return s.attributes[i]=o(s.attributes[i]),this.emit("edgeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:i}),this}}function Hp(r,e,t){r.prototype[e]=function(n,i){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new ue(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new ue(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+n,a=""+i;if(i=arguments[2],o=Nt(this,s,a,t),!o)throw new B(`Graph.${e}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(t!=="mixed")throw new ue(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,o=this._edges.get(n),!o)throw new B(`Graph.${e}: could not find the "${n}" edge in the graph.`)}return delete o.attributes[i],this.emit("edgeAttributesUpdated",{key:o.key,type:"remove",attributes:o.attributes,name:i}),this}}function qp(r,e,t){r.prototype[e]=function(n,i){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new ue(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new ue(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+n,a=""+i;if(i=arguments[2],o=Nt(this,s,a,t),!o)throw new B(`Graph.${e}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(t!=="mixed")throw new ue(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,o=this._edges.get(n),!o)throw new B(`Graph.${e}: could not find the "${n}" edge in the graph.`)}if(!mt(i))throw new q(`Graph.${e}: provided attributes are not a plain object.`);return o.attributes=i,this.emit("edgeAttributesUpdated",{key:o.key,type:"replace",attributes:o.attributes}),this}}function Yp(r,e,t){r.prototype[e]=function(n,i){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new ue(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new ue(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+n,a=""+i;if(i=arguments[2],o=Nt(this,s,a,t),!o)throw new B(`Graph.${e}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(t!=="mixed")throw new ue(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,o=this._edges.get(n),!o)throw new B(`Graph.${e}: could not find the "${n}" edge in the graph.`)}if(!mt(i))throw new q(`Graph.${e}: provided attributes are not a plain object.`);return ut(o.attributes,i),this.emit("edgeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:i}),this}}function Xp(r,e,t){r.prototype[e]=function(n,i){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new ue(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new ue(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+n,a=""+i;if(i=arguments[2],o=Nt(this,s,a,t),!o)throw new B(`Graph.${e}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(t!=="mixed")throw new ue(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,o=this._edges.get(n),!o)throw new B(`Graph.${e}: could not find the "${n}" edge in the graph.`)}if(typeof i!="function")throw new q(`Graph.${e}: provided updater is not a function.`);return o.attributes=i(o.attributes),this.emit("edgeAttributesUpdated",{key:o.key,type:"update",attributes:o.attributes}),this}}const Jp=[{name:r=>`get${r}Attribute`,attacher:jp},{name:r=>`get${r}Attributes`,attacher:Bp},{name:r=>`has${r}Attribute`,attacher:Fp},{name:r=>`set${r}Attribute`,attacher:Vp},{name:r=>`update${r}Attribute`,attacher:Kp},{name:r=>`remove${r}Attribute`,attacher:Hp},{name:r=>`replace${r}Attributes`,attacher:qp},{name:r=>`merge${r}Attributes`,attacher:Yp},{name:r=>`update${r}Attributes`,attacher:Xp}];function Zp(r){Jp.forEach(function({name:e,attacher:t}){t(r,e("Edge"),"mixed"),t(r,e("DirectedEdge"),"directed"),t(r,e("UndirectedEdge"),"undirected")})}const Qp=[{name:"edges",type:"mixed"},{name:"inEdges",type:"directed",direction:"in"},{name:"outEdges",type:"directed",direction:"out"},{name:"inboundEdges",type:"mixed",direction:"in"},{name:"outboundEdges",type:"mixed",direction:"out"},{name:"directedEdges",type:"directed"},{name:"undirectedEdges",type:"undirected"}];function eg(r,e,t,n){let i=!1;for(const o in e){if(o===n)continue;const s=e[o];if(i=t(s.key,s.attributes,s.source.key,s.target.key,s.source.attributes,s.target.attributes,s.undirected),r&&i)return s.key}}function tg(r,e,t,n){let i,o,s,a=!1;for(const c in e)if(c!==n){i=e[c];do{if(o=i.source,s=i.target,a=t(i.key,i.attributes,o.key,s.key,o.attributes,s.attributes,i.undirected),r&&a)return i.key;i=i.next}while(i!==void 0)}}function ji(r,e){const t=Object.keys(r),n=t.length;let i,o=0;return{[Symbol.iterator](){return this},next(){do if(i)i=i.next;else{if(o>=n)return{done:!0};const s=t[o++];if(s===e){i=void 0;continue}i=r[s]}while(!i);return{done:!1,value:{edge:i.key,attributes:i.attributes,source:i.source.key,target:i.target.key,sourceAttributes:i.source.attributes,targetAttributes:i.target.attributes,undirected:i.undirected}}}}}function rg(r,e,t,n){const i=e[t];if(!i)return;const o=i.source,s=i.target;if(n(i.key,i.attributes,o.key,s.key,o.attributes,s.attributes,i.undirected)&&r)return i.key}function ng(r,e,t,n){let i=e[t];if(!i)return;let o=!1;do{if(o=n(i.key,i.attributes,i.source.key,i.target.key,i.source.attributes,i.target.attributes,i.undirected),r&&o)return i.key;i=i.next}while(i!==void 0)}function Bi(r,e){let t=r[e];if(t.next!==void 0)return{[Symbol.iterator](){return this},next(){if(!t)return{done:!0};const i={edge:t.key,attributes:t.attributes,source:t.source.key,target:t.target.key,sourceAttributes:t.source.attributes,targetAttributes:t.target.attributes,undirected:t.undirected};return t=t.next,{done:!1,value:i}}};let n=!1;return{[Symbol.iterator](){return this},next(){return n===!0?{done:!0}:(n=!0,{done:!1,value:{edge:t.key,attributes:t.attributes,source:t.source.key,target:t.target.key,sourceAttributes:t.source.attributes,targetAttributes:t.target.attributes,undirected:t.undirected}})}}}function ig(r,e){if(r.size===0)return[];if(e==="mixed"||e===r.type)return Array.from(r._edges.keys());const t=e==="undirected"?r.undirectedSize:r.directedSize,n=new Array(t),i=e==="undirected",o=r._edges.values();let s=0,a,c;for(;a=o.next(),a.done!==!0;)c=a.value,c.undirected===i&&(n[s++]=c.key);return n}function Ic(r,e,t,n){if(e.size===0)return;const i=t!=="mixed"&&t!==e.type,o=t==="undirected";let s,a,c=!1;const l=e._edges.values();for(;s=l.next(),s.done!==!0;){if(a=s.value,i&&a.undirected!==o)continue;const{key:d,attributes:f,source:h,target:g}=a;if(c=n(d,f,h.key,g.key,h.attributes,g.attributes,a.undirected),r&&c)return d}}function og(r,e){if(r.size===0)return jr();const t=e!=="mixed"&&e!==r.type,n=e==="undirected",i=r._edges.values();return{[Symbol.iterator](){return this},next(){let o,s;for(;;){if(o=i.next(),o.done)return o;if(s=o.value,!(t&&s.undirected!==n))break}return{value:{edge:s.key,attributes:s.attributes,source:s.source.key,target:s.target.key,sourceAttributes:s.source.attributes,targetAttributes:s.target.attributes,undirected:s.undirected},done:!1}}}}function Lo(r,e,t,n,i,o){const s=e?tg:eg;let a;if(t!=="undirected"&&(n!=="out"&&(a=s(r,i.in,o),r&&a)||n!=="in"&&(a=s(r,i.out,o,n?void 0:i.key),r&&a))||t!=="directed"&&(a=s(r,i.undirected,o),r&&a))return a}function sg(r,e,t,n){const i=[];return Lo(!1,r,e,t,n,function(o){i.push(o)}),i}function ag(r,e,t){let n=jr();return r!=="undirected"&&(e!=="out"&&typeof t.in<"u"&&(n=tr(n,ji(t.in))),e!=="in"&&typeof t.out<"u"&&(n=tr(n,ji(t.out,e?void 0:t.key)))),r!=="directed"&&typeof t.undirected<"u"&&(n=tr(n,ji(t.undirected))),n}function To(r,e,t,n,i,o,s){const a=t?ng:rg;let c;if(e!=="undirected"&&(typeof i.in<"u"&&n!=="out"&&(c=a(r,i.in,o,s),r&&c)||typeof i.out<"u"&&n!=="in"&&(n||i.key!==o)&&(c=a(r,i.out,o,s),r&&c))||e!=="directed"&&typeof i.undirected<"u"&&(c=a(r,i.undirected,o,s),r&&c))return c}function cg(r,e,t,n,i){const o=[];return To(!1,r,e,t,n,i,function(s){o.push(s)}),o}function lg(r,e,t,n){let i=jr();return r!=="undirected"&&(typeof t.in<"u"&&e!=="out"&&n in t.in&&(i=tr(i,Bi(t.in,n))),typeof t.out<"u"&&e!=="in"&&n in t.out&&(e||t.key!==n)&&(i=tr(i,Bi(t.out,n)))),r!=="directed"&&typeof t.undirected<"u"&&n in t.undirected&&(i=tr(i,Bi(t.undirected,n))),i}function ug(r,e){const{name:t,type:n,direction:i}=e;r.prototype[t]=function(o,s){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return[];if(!arguments.length)return ig(this,n);if(arguments.length===1){o=""+o;const a=this._nodes.get(o);if(typeof a>"u")throw new B(`Graph.${t}: could not find the "${o}" node in the graph.`);return sg(this.multi,n==="mixed"?this.type:n,i,a)}if(arguments.length===2){o=""+o,s=""+s;const a=this._nodes.get(o);if(!a)throw new B(`Graph.${t}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(s))throw new B(`Graph.${t}: could not find the "${s}" target node in the graph.`);return cg(n,this.multi,i,a,s)}throw new q(`Graph.${t}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function dg(r,e){const{name:t,type:n,direction:i}=e,o="forEach"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[o]=function(l,d,f){if(!(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)){if(arguments.length===1)return f=l,Ic(!1,this,n,f);if(arguments.length===2){l=""+l,f=d;const h=this._nodes.get(l);if(typeof h>"u")throw new B(`Graph.${o}: could not find the "${l}" node in the graph.`);return Lo(!1,this.multi,n==="mixed"?this.type:n,i,h,f)}if(arguments.length===3){l=""+l,d=""+d;const h=this._nodes.get(l);if(!h)throw new B(`Graph.${o}: could not find the "${l}" source node in the graph.`);if(!this._nodes.has(d))throw new B(`Graph.${o}: could not find the "${d}" target node in the graph.`);return To(!1,n,this.multi,i,h,d,f)}throw new q(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};const s="map"+t[0].toUpperCase()+t.slice(1);r.prototype[s]=function(){const l=Array.prototype.slice.call(arguments),d=l.pop();let f;if(l.length===0){let h=0;n!=="directed"&&(h+=this.undirectedSize),n!=="undirected"&&(h+=this.directedSize),f=new Array(h);let g=0;l.push((y,C,b,m,A,v,p)=>{f[g++]=d(y,C,b,m,A,v,p)})}else f=[],l.push((h,g,y,C,b,m,A)=>{f.push(d(h,g,y,C,b,m,A))});return this[o].apply(this,l),f};const a="filter"+t[0].toUpperCase()+t.slice(1);r.prototype[a]=function(){const l=Array.prototype.slice.call(arguments),d=l.pop(),f=[];return l.push((h,g,y,C,b,m,A)=>{d(h,g,y,C,b,m,A)&&f.push(h)}),this[o].apply(this,l),f};const c="reduce"+t[0].toUpperCase()+t.slice(1);r.prototype[c]=function(){let l=Array.prototype.slice.call(arguments);if(l.length<2||l.length>4)throw new q(`Graph.${c}: invalid number of arguments (expecting 2, 3 or 4 and got ${l.length}).`);if(typeof l[l.length-1]=="function"&&typeof l[l.length-2]!="function")throw new q(`Graph.${c}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let d,f;l.length===2?(d=l[0],f=l[1],l=[]):l.length===3?(d=l[1],f=l[2],l=[l[0]]):l.length===4&&(d=l[2],f=l[3],l=[l[0],l[1]]);let h=f;return l.push((g,y,C,b,m,A,v)=>{h=d(h,g,y,C,b,m,A,v)}),this[o].apply(this,l),h}}function fg(r,e){const{name:t,type:n,direction:i}=e,o="find"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[o]=function(c,l,d){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return!1;if(arguments.length===1)return d=c,Ic(!0,this,n,d);if(arguments.length===2){c=""+c,d=l;const f=this._nodes.get(c);if(typeof f>"u")throw new B(`Graph.${o}: could not find the "${c}" node in the graph.`);return Lo(!0,this.multi,n==="mixed"?this.type:n,i,f,d)}if(arguments.length===3){c=""+c,l=""+l;const f=this._nodes.get(c);if(!f)throw new B(`Graph.${o}: could not find the "${c}" source node in the graph.`);if(!this._nodes.has(l))throw new B(`Graph.${o}: could not find the "${l}" target node in the graph.`);return To(!0,n,this.multi,i,f,l,d)}throw new q(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};const s="some"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[s]=function(){const c=Array.prototype.slice.call(arguments),l=c.pop();return c.push((f,h,g,y,C,b,m)=>l(f,h,g,y,C,b,m)),!!this[o].apply(this,c)};const a="every"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[a]=function(){const c=Array.prototype.slice.call(arguments),l=c.pop();return c.push((f,h,g,y,C,b,m)=>!l(f,h,g,y,C,b,m)),!this[o].apply(this,c)}}function hg(r,e){const{name:t,type:n,direction:i}=e,o=t.slice(0,-1)+"Entries";r.prototype[o]=function(s,a){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return jr();if(!arguments.length)return og(this,n);if(arguments.length===1){s=""+s;const c=this._nodes.get(s);if(!c)throw new B(`Graph.${o}: could not find the "${s}" node in the graph.`);return ag(n,i,c)}if(arguments.length===2){s=""+s,a=""+a;const c=this._nodes.get(s);if(!c)throw new B(`Graph.${o}: could not find the "${s}" source node in the graph.`);if(!this._nodes.has(a))throw new B(`Graph.${o}: could not find the "${a}" target node in the graph.`);return lg(n,i,c,a)}throw new q(`Graph.${o}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function pg(r){Qp.forEach(e=>{ug(r,e),dg(r,e),fg(r,e),hg(r,e)})}const gg=[{name:"neighbors",type:"mixed"},{name:"inNeighbors",type:"directed",direction:"in"},{name:"outNeighbors",type:"directed",direction:"out"},{name:"inboundNeighbors",type:"mixed",direction:"in"},{name:"outboundNeighbors",type:"mixed",direction:"out"},{name:"directedNeighbors",type:"directed"},{name:"undirectedNeighbors",type:"undirected"}];function ci(){this.A=null,this.B=null}ci.prototype.wrap=function(r){this.A===null?this.A=r:this.B===null&&(this.B=r)};ci.prototype.has=function(r){return this.A!==null&&r in this.A||this.B!==null&&r in this.B};function Qr(r,e,t,n,i){for(const o in n){const s=n[o],a=s.source,c=s.target,l=a===t?c:a;if(e&&e.has(l.key))continue;const d=i(l.key,l.attributes);if(r&&d)return l.key}}function Go(r,e,t,n,i){if(e!=="mixed"){if(e==="undirected")return Qr(r,null,n,n.undirected,i);if(typeof t=="string")return Qr(r,null,n,n[t],i)}const o=new ci;let s;if(e!=="undirected"){if(t!=="out"){if(s=Qr(r,null,n,n.in,i),r&&s)return s;o.wrap(n.in)}if(t!=="in"){if(s=Qr(r,o,n,n.out,i),r&&s)return s;o.wrap(n.out)}}if(e!=="directed"&&(s=Qr(r,o,n,n.undirected,i),r&&s))return s}function mg(r,e,t){if(r!=="mixed"){if(r==="undirected")return Object.keys(t.undirected);if(typeof e=="string")return Object.keys(t[e])}const n=[];return Go(!1,r,e,t,function(i){n.push(i)}),n}function en(r,e,t){const n=Object.keys(t),i=n.length;let o=0;return{[Symbol.iterator](){return this},next(){let s=null;do{if(o>=i)return r&&r.wrap(t),{done:!0};const a=t[n[o++]],c=a.source,l=a.target;if(s=c===e?l:c,r&&r.has(s.key)){s=null;continue}}while(s===null);return{done:!1,value:{neighbor:s.key,attributes:s.attributes}}}}}function vg(r,e,t){if(r!=="mixed"){if(r==="undirected")return en(null,t,t.undirected);if(typeof e=="string")return en(null,t,t[e])}let n=jr();const i=new ci;return r!=="undirected"&&(e!=="out"&&(n=tr(n,en(i,t,t.in))),e!=="in"&&(n=tr(n,en(i,t,t.out)))),r!=="directed"&&(n=tr(n,en(i,t,t.undirected))),n}function yg(r,e){const{name:t,type:n,direction:i}=e;r.prototype[t]=function(o){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return[];o=""+o;const s=this._nodes.get(o);if(typeof s>"u")throw new B(`Graph.${t}: could not find the "${o}" node in the graph.`);return mg(n==="mixed"?this.type:n,i,s)}}function bg(r,e){const{name:t,type:n,direction:i}=e,o="forEach"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[o]=function(l,d){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return;l=""+l;const f=this._nodes.get(l);if(typeof f>"u")throw new B(`Graph.${o}: could not find the "${l}" node in the graph.`);Go(!1,n==="mixed"?this.type:n,i,f,d)};const s="map"+t[0].toUpperCase()+t.slice(1);r.prototype[s]=function(l,d){const f=[];return this[o](l,(h,g)=>{f.push(d(h,g))}),f};const a="filter"+t[0].toUpperCase()+t.slice(1);r.prototype[a]=function(l,d){const f=[];return this[o](l,(h,g)=>{d(h,g)&&f.push(h)}),f};const c="reduce"+t[0].toUpperCase()+t.slice(1);r.prototype[c]=function(l,d,f){if(arguments.length<3)throw new q(`Graph.${c}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let h=f;return this[o](l,(g,y)=>{h=d(h,g,y)}),h}}function wg(r,e){const{name:t,type:n,direction:i}=e,o=t[0].toUpperCase()+t.slice(1,-1),s="find"+o;r.prototype[s]=function(l,d){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return;l=""+l;const f=this._nodes.get(l);if(typeof f>"u")throw new B(`Graph.${s}: could not find the "${l}" node in the graph.`);return Go(!0,n==="mixed"?this.type:n,i,f,d)};const a="some"+o;r.prototype[a]=function(l,d){return!!this[s](l,d)};const c="every"+o;r.prototype[c]=function(l,d){return!this[s](l,(h,g)=>!d(h,g))}}function _g(r,e){const{name:t,type:n,direction:i}=e,o=t.slice(0,-1)+"Entries";r.prototype[o]=function(s){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return jr();s=""+s;const a=this._nodes.get(s);if(typeof a>"u")throw new B(`Graph.${o}: could not find the "${s}" node in the graph.`);return vg(n==="mixed"?this.type:n,i,a)}}function xg(r){gg.forEach(e=>{yg(r,e),bg(r,e),wg(r,e),_g(r,e)})}function Wn(r,e,t,n,i){const o=n._nodes.values(),s=n.type;let a,c,l,d,f,h;for(;a=o.next(),a.done!==!0;){let g=!1;if(c=a.value,s!=="undirected"){d=c.out;for(l in d){f=d[l];do h=f.target,g=!0,i(c.key,h.key,c.attributes,h.attributes,f.key,f.attributes,f.undirected),f=f.next;while(f)}}if(s!=="directed"){d=c.undirected;for(l in d)if(!(e&&c.key>l)){f=d[l];do h=f.target,h.key!==l&&(h=f.source),g=!0,i(c.key,h.key,c.attributes,h.attributes,f.key,f.attributes,f.undirected),f=f.next;while(f)}}t&&!g&&i(c.key,null,c.attributes,null,null,null,null)}}function kg(r,e){const t={key:r};return kc(e.attributes)||(t.attributes=ut({},e.attributes)),t}function Eg(r,e,t){const n={key:e,source:t.source.key,target:t.target.key};return kc(t.attributes)||(n.attributes=ut({},t.attributes)),r==="mixed"&&t.undirected&&(n.undirected=!0),n}function Sg(r){if(!mt(r))throw new q('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in r))throw new q("Graph.import: serialized node is missing its key.");if("attributes"in r&&(!mt(r.attributes)||r.attributes===null))throw new q("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function Cg(r){if(!mt(r))throw new q('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in r))throw new q("Graph.import: serialized edge is missing its source.");if(!("target"in r))throw new q("Graph.import: serialized edge is missing its target.");if("attributes"in r&&(!mt(r.attributes)||r.attributes===null))throw new q("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in r&&typeof r.undirected!="boolean")throw new q("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}const Ag=Dp(),$g=new Set(["directed","undirected","mixed"]),Vs=new Set(["domain","_events","_eventsCount","_maxListeners"]),Dg=[{name:r=>`${r}Edge`,generateKey:!0},{name:r=>`${r}DirectedEdge`,generateKey:!0,type:"directed"},{name:r=>`${r}UndirectedEdge`,generateKey:!0,type:"undirected"},{name:r=>`${r}EdgeWithKey`},{name:r=>`${r}DirectedEdgeWithKey`,type:"directed"},{name:r=>`${r}UndirectedEdgeWithKey`,type:"undirected"}],Ig={allowSelfLoops:!0,multi:!1,type:"mixed"};function Lg(r,e,t){if(t&&!mt(t))throw new q(`Graph.addNode: invalid attributes. Expecting an object but got "${t}"`);if(e=""+e,t=t||{},r._nodes.has(e))throw new ue(`Graph.addNode: the "${e}" node already exist in the graph.`);const n=new r.NodeDataClass(e,t);return r._nodes.set(e,n),r.emit("nodeAdded",{key:e,attributes:t}),n}function Ks(r,e,t){const n=new r.NodeDataClass(e,t);return r._nodes.set(e,n),r.emit("nodeAdded",{key:e,attributes:t}),n}function Lc(r,e,t,n,i,o,s,a){if(!n&&r.type==="undirected")throw new ue(`Graph.${e}: you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.`);if(n&&r.type==="directed")throw new ue(`Graph.${e}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(a&&!mt(a))throw new q(`Graph.${e}: invalid attributes. Expecting an object but got "${a}"`);if(o=""+o,s=""+s,a=a||{},!r.allowSelfLoops&&o===s)throw new ue(`Graph.${e}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);const c=r._nodes.get(o),l=r._nodes.get(s);if(!c)throw new B(`Graph.${e}: source node "${o}" not found.`);if(!l)throw new B(`Graph.${e}: target node "${s}" not found.`);const d={key:null,undirected:n,source:o,target:s,attributes:a};if(t)i=r._edgeKeyGenerator();else if(i=""+i,r._edges.has(i))throw new ue(`Graph.${e}: the "${i}" edge already exists in the graph.`);if(!r.multi&&(n?typeof c.undirected[s]<"u":typeof c.out[s]<"u"))throw new ue(`Graph.${e}: an edge linking "${o}" to "${s}" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option.`);const f=new Br(n,i,c,l,a);r._edges.set(i,f);const h=o===s;return n?(c.undirectedDegree++,l.undirectedDegree++,h&&(c.undirectedLoops++,r._undirectedSelfLoopCount++)):(c.outDegree++,l.inDegree++,h&&(c.directedLoops++,r._directedSelfLoopCount++)),r.multi?f.attachMulti():f.attach(),n?r._undirectedSize++:r._directedSize++,d.key=i,r.emit("edgeAdded",d),i}function Tg(r,e,t,n,i,o,s,a,c){if(!n&&r.type==="undirected")throw new ue(`Graph.${e}: you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead.`);if(n&&r.type==="directed")throw new ue(`Graph.${e}: you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead.`);if(a){if(c){if(typeof a!="function")throw new q(`Graph.${e}: invalid updater function. Expecting a function but got "${a}"`)}else if(!mt(a))throw new q(`Graph.${e}: invalid attributes. Expecting an object but got "${a}"`)}o=""+o,s=""+s;let l;if(c&&(l=a,a=void 0),!r.allowSelfLoops&&o===s)throw new ue(`Graph.${e}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let d=r._nodes.get(o),f=r._nodes.get(s),h,g;if(!t&&(h=r._edges.get(i),h)){if((h.source.key!==o||h.target.key!==s)&&(!n||h.source.key!==s||h.target.key!==o))throw new ue(`Graph.${e}: inconsistency detected when attempting to merge the "${i}" edge with "${o}" source & "${s}" target vs. ("${h.source.key}", "${h.target.key}").`);g=h}if(!g&&!r.multi&&d&&(g=n?d.undirected[s]:d.out[s]),g){const A=[g.key,!1,!1,!1];if(c?!l:!a)return A;if(c){const v=g.attributes;g.attributes=l(v),r.emit("edgeAttributesUpdated",{type:"replace",key:g.key,attributes:g.attributes})}else ut(g.attributes,a),r.emit("edgeAttributesUpdated",{type:"merge",key:g.key,attributes:g.attributes,data:a});return A}a=a||{},c&&l&&(a=l(a));const y={key:null,undirected:n,source:o,target:s,attributes:a};if(t)i=r._edgeKeyGenerator();else if(i=""+i,r._edges.has(i))throw new ue(`Graph.${e}: the "${i}" edge already exists in the graph.`);let C=!1,b=!1;d||(d=Ks(r,o,{}),C=!0,o===s&&(f=d,b=!0)),f||(f=Ks(r,s,{}),b=!0),h=new Br(n,i,d,f,a),r._edges.set(i,h);const m=o===s;return n?(d.undirectedDegree++,f.undirectedDegree++,m&&(d.undirectedLoops++,r._undirectedSelfLoopCount++)):(d.outDegree++,f.inDegree++,m&&(d.directedLoops++,r._directedSelfLoopCount++)),r.multi?h.attachMulti():h.attach(),n?r._undirectedSize++:r._directedSize++,y.key=i,r.emit("edgeAdded",y),[i,!0,C,b]}function zr(r,e){r._edges.delete(e.key);const{source:t,target:n,attributes:i}=e,o=e.undirected,s=t===n;o?(t.undirectedDegree--,n.undirectedDegree--,s&&(t.undirectedLoops--,r._undirectedSelfLoopCount--)):(t.outDegree--,n.inDegree--,s&&(t.directedLoops--,r._directedSelfLoopCount--)),r.multi?e.detachMulti():e.detach(),o?r._undirectedSize--:r._directedSize--,r.emit("edgeDropped",{key:e.key,attributes:i,source:t.key,target:n.key,undirected:o})}class qe extends Ap.EventEmitter{constructor(e){if(super(),e=ut({},Ig,e),typeof e.multi!="boolean")throw new q(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${e.multi}".`);if(!$g.has(e.type))throw new q(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${e.type}".`);if(typeof e.allowSelfLoops!="boolean")throw new q(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${e.allowSelfLoops}".`);const t=e.type==="mixed"?Ec:e.type==="directed"?Sc:Cc;zt(this,"NodeDataClass",t);const n="geid_"+Ag()+"_";let i=0;const o=()=>{let s;do s=n+i++;while(this._edges.has(s));return s};zt(this,"_attributes",{}),zt(this,"_nodes",new Map),zt(this,"_edges",new Map),zt(this,"_directedSize",0),zt(this,"_undirectedSize",0),zt(this,"_directedSelfLoopCount",0),zt(this,"_undirectedSelfLoopCount",0),zt(this,"_edgeKeyGenerator",o),zt(this,"_options",e),Vs.forEach(s=>zt(this,s,this[s])),Wt(this,"order",()=>this._nodes.size),Wt(this,"size",()=>this._edges.size),Wt(this,"directedSize",()=>this._directedSize),Wt(this,"undirectedSize",()=>this._undirectedSize),Wt(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),Wt(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),Wt(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),Wt(this,"multi",this._options.multi),Wt(this,"type",this._options.type),Wt(this,"allowSelfLoops",this._options.allowSelfLoops),Wt(this,"implementation",()=>"graphology")}_resetInstanceCounters(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0}hasNode(e){return this._nodes.has(""+e)}hasDirectedEdge(e,t){if(this.type==="undirected")return!1;if(arguments.length===1){const n=""+e,i=this._edges.get(n);return!!i&&!i.undirected}else if(arguments.length===2){e=""+e,t=""+t;const n=this._nodes.get(e);return n?n.out.hasOwnProperty(t):!1}throw new q(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasUndirectedEdge(e,t){if(this.type==="directed")return!1;if(arguments.length===1){const n=""+e,i=this._edges.get(n);return!!i&&i.undirected}else if(arguments.length===2){e=""+e,t=""+t;const n=this._nodes.get(e);return n?n.undirected.hasOwnProperty(t):!1}throw new q(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasEdge(e,t){if(arguments.length===1){const n=""+e;return this._edges.has(n)}else if(arguments.length===2){e=""+e,t=""+t;const n=this._nodes.get(e);return n?typeof n.out<"u"&&n.out.hasOwnProperty(t)||typeof n.undirected<"u"&&n.undirected.hasOwnProperty(t):!1}throw new q(`Graph.hasEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}directedEdge(e,t){if(this.type==="undirected")return;if(e=""+e,t=""+t,this.multi)throw new ue("Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.");const n=this._nodes.get(e);if(!n)throw new B(`Graph.directedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new B(`Graph.directedEdge: could not find the "${t}" target node in the graph.`);const i=n.out&&n.out[t]||void 0;if(i)return i.key}undirectedEdge(e,t){if(this.type==="directed")return;if(e=""+e,t=""+t,this.multi)throw new ue("Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.");const n=this._nodes.get(e);if(!n)throw new B(`Graph.undirectedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new B(`Graph.undirectedEdge: could not find the "${t}" target node in the graph.`);const i=n.undirected&&n.undirected[t]||void 0;if(i)return i.key}edge(e,t){if(this.multi)throw new ue("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new B(`Graph.edge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new B(`Graph.edge: could not find the "${t}" target node in the graph.`);const i=n.out&&n.out[t]||n.undirected&&n.undirected[t]||void 0;if(i)return i.key}areDirectedNeighbors(e,t){e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new B(`Graph.areDirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:t in n.in||t in n.out}areOutNeighbors(e,t){e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new B(`Graph.areOutNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:t in n.out}areInNeighbors(e,t){e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new B(`Graph.areInNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:t in n.in}areUndirectedNeighbors(e,t){e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new B(`Graph.areUndirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type==="directed"?!1:t in n.undirected}areNeighbors(e,t){e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new B(`Graph.areNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&(t in n.in||t in n.out)||this.type!=="directed"&&t in n.undirected}areInboundNeighbors(e,t){e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new B(`Graph.areInboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&t in n.in||this.type!=="directed"&&t in n.undirected}areOutboundNeighbors(e,t){e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new B(`Graph.areOutboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&t in n.out||this.type!=="directed"&&t in n.undirected}inDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new B(`Graph.inDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.inDegree}outDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new B(`Graph.outDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.outDegree}directedDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new B(`Graph.directedDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.inDegree+t.outDegree}undirectedDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new B(`Graph.undirectedDegree: could not find the "${e}" node in the graph.`);return this.type==="directed"?0:t.undirectedDegree}inboundDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new B(`Graph.inboundDegree: could not find the "${e}" node in the graph.`);let n=0;return this.type!=="directed"&&(n+=t.undirectedDegree),this.type!=="undirected"&&(n+=t.inDegree),n}outboundDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new B(`Graph.outboundDegree: could not find the "${e}" node in the graph.`);let n=0;return this.type!=="directed"&&(n+=t.undirectedDegree),this.type!=="undirected"&&(n+=t.outDegree),n}degree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new B(`Graph.degree: could not find the "${e}" node in the graph.`);let n=0;return this.type!=="directed"&&(n+=t.undirectedDegree),this.type!=="undirected"&&(n+=t.inDegree+t.outDegree),n}inDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new B(`Graph.inDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.inDegree-t.directedLoops}outDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new B(`Graph.outDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.outDegree-t.directedLoops}directedDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new B(`Graph.directedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.inDegree+t.outDegree-t.directedLoops*2}undirectedDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new B(`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="directed"?0:t.undirectedDegree-t.undirectedLoops*2}inboundDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new B(`Graph.inboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let n=0,i=0;return this.type!=="directed"&&(n+=t.undirectedDegree,i+=t.undirectedLoops*2),this.type!=="undirected"&&(n+=t.inDegree,i+=t.directedLoops),n-i}outboundDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new B(`Graph.outboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let n=0,i=0;return this.type!=="directed"&&(n+=t.undirectedDegree,i+=t.undirectedLoops*2),this.type!=="undirected"&&(n+=t.outDegree,i+=t.directedLoops),n-i}degreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new B(`Graph.degreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let n=0,i=0;return this.type!=="directed"&&(n+=t.undirectedDegree,i+=t.undirectedLoops*2),this.type!=="undirected"&&(n+=t.inDegree+t.outDegree,i+=t.directedLoops*2),n-i}source(e){e=""+e;const t=this._edges.get(e);if(!t)throw new B(`Graph.source: could not find the "${e}" edge in the graph.`);return t.source.key}target(e){e=""+e;const t=this._edges.get(e);if(!t)throw new B(`Graph.target: could not find the "${e}" edge in the graph.`);return t.target.key}extremities(e){e=""+e;const t=this._edges.get(e);if(!t)throw new B(`Graph.extremities: could not find the "${e}" edge in the graph.`);return[t.source.key,t.target.key]}opposite(e,t){e=""+e,t=""+t;const n=this._edges.get(t);if(!n)throw new B(`Graph.opposite: could not find the "${t}" edge in the graph.`);const i=n.source.key,o=n.target.key;if(e===i)return o;if(e===o)return i;throw new B(`Graph.opposite: the "${e}" node is not attached to the "${t}" edge (${i}, ${o}).`)}hasExtremity(e,t){e=""+e,t=""+t;const n=this._edges.get(e);if(!n)throw new B(`Graph.hasExtremity: could not find the "${e}" edge in the graph.`);return n.source.key===t||n.target.key===t}isUndirected(e){e=""+e;const t=this._edges.get(e);if(!t)throw new B(`Graph.isUndirected: could not find the "${e}" edge in the graph.`);return t.undirected}isDirected(e){e=""+e;const t=this._edges.get(e);if(!t)throw new B(`Graph.isDirected: could not find the "${e}" edge in the graph.`);return!t.undirected}isSelfLoop(e){e=""+e;const t=this._edges.get(e);if(!t)throw new B(`Graph.isSelfLoop: could not find the "${e}" edge in the graph.`);return t.source===t.target}addNode(e,t){return Lg(this,e,t).key}mergeNode(e,t){if(t&&!mt(t))throw new q(`Graph.mergeNode: invalid attributes. Expecting an object but got "${t}"`);e=""+e,t=t||{};let n=this._nodes.get(e);return n?(t&&(ut(n.attributes,t),this.emit("nodeAttributesUpdated",{type:"merge",key:e,attributes:n.attributes,data:t})),[e,!1]):(n=new this.NodeDataClass(e,t),this._nodes.set(e,n),this.emit("nodeAdded",{key:e,attributes:t}),[e,!0])}updateNode(e,t){if(t&&typeof t!="function")throw new q(`Graph.updateNode: invalid updater function. Expecting a function but got "${t}"`);e=""+e;let n=this._nodes.get(e);if(n){if(t){const o=n.attributes;n.attributes=t(o),this.emit("nodeAttributesUpdated",{type:"replace",key:e,attributes:n.attributes})}return[e,!1]}const i=t?t({}):{};return n=new this.NodeDataClass(e,i),this._nodes.set(e,n),this.emit("nodeAdded",{key:e,attributes:i}),[e,!0]}dropNode(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new B(`Graph.dropNode: could not find the "${e}" node in the graph.`);let n;if(this.type!=="undirected"){for(const i in t.out){n=t.out[i];do zr(this,n),n=n.next;while(n)}for(const i in t.in){n=t.in[i];do zr(this,n),n=n.next;while(n)}}if(this.type!=="directed")for(const i in t.undirected){n=t.undirected[i];do zr(this,n),n=n.next;while(n)}this._nodes.delete(e),this.emit("nodeDropped",{key:e,attributes:t.attributes})}dropEdge(e){let t;if(arguments.length>1){const n=""+arguments[0],i=""+arguments[1];if(t=Nt(this,n,i,this.type),!t)throw new B(`Graph.dropEdge: could not find the "${n}" -> "${i}" edge in the graph.`)}else if(e=""+e,t=this._edges.get(e),!t)throw new B(`Graph.dropEdge: could not find the "${e}" edge in the graph.`);return zr(this,t),this}dropDirectedEdge(e,t){if(arguments.length<2)throw new ue("Graph.dropDirectedEdge: it does not make sense to try and drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new ue("Graph.dropDirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");e=""+e,t=""+t;const n=Nt(this,e,t,"directed");if(!n)throw new B(`Graph.dropDirectedEdge: could not find a "${e}" -> "${t}" edge in the graph.`);return zr(this,n),this}dropUndirectedEdge(e,t){if(arguments.length<2)throw new ue("Graph.dropUndirectedEdge: it does not make sense to drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new ue("Graph.dropUndirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");const n=Nt(this,e,t,"undirected");if(!n)throw new B(`Graph.dropUndirectedEdge: could not find a "${e}" -> "${t}" edge in the graph.`);return zr(this,n),this}clear(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")}clearEdges(){const e=this._nodes.values();let t;for(;t=e.next(),t.done!==!0;)t.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit("edgesCleared")}getAttribute(e){return this._attributes[e]}getAttributes(){return this._attributes}hasAttribute(e){return this._attributes.hasOwnProperty(e)}setAttribute(e,t){return this._attributes[e]=t,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:e}),this}updateAttribute(e,t){if(typeof t!="function")throw new q("Graph.updateAttribute: updater should be a function.");const n=this._attributes[e];return this._attributes[e]=t(n),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:e}),this}removeAttribute(e){return delete this._attributes[e],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:e}),this}replaceAttributes(e){if(!mt(e))throw new q("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=e,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this}mergeAttributes(e){if(!mt(e))throw new q("Graph.mergeAttributes: provided attributes are not a plain object.");return ut(this._attributes,e),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:e}),this}updateAttributes(e){if(typeof e!="function")throw new q("Graph.updateAttributes: provided updater is not a function.");return this._attributes=e(this._attributes),this.emit("attributesUpdated",{type:"update",attributes:this._attributes}),this}updateEachNodeAttributes(e,t){if(typeof e!="function")throw new q("Graph.updateEachNodeAttributes: expecting an updater function.");if(t&&!Fs(t))throw new q("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const n=this._nodes.values();let i,o;for(;i=n.next(),i.done!==!0;)o=i.value,o.attributes=e(o.key,o.attributes);this.emit("eachNodeAttributesUpdated",{hints:t||null})}updateEachEdgeAttributes(e,t){if(typeof e!="function")throw new q("Graph.updateEachEdgeAttributes: expecting an updater function.");if(t&&!Fs(t))throw new q("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const n=this._edges.values();let i,o,s,a;for(;i=n.next(),i.done!==!0;)o=i.value,s=o.source,a=o.target,o.attributes=e(o.key,o.attributes,s.key,a.key,s.attributes,a.attributes,o.undirected);this.emit("eachEdgeAttributesUpdated",{hints:t||null})}forEachAdjacencyEntry(e){if(typeof e!="function")throw new q("Graph.forEachAdjacencyEntry: expecting a callback.");Wn(!1,!1,!1,this,e)}forEachAdjacencyEntryWithOrphans(e){if(typeof e!="function")throw new q("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");Wn(!1,!1,!0,this,e)}forEachAssymetricAdjacencyEntry(e){if(typeof e!="function")throw new q("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");Wn(!1,!0,!1,this,e)}forEachAssymetricAdjacencyEntryWithOrphans(e){if(typeof e!="function")throw new q("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");Wn(!1,!0,!0,this,e)}nodes(){return Array.from(this._nodes.keys())}forEachNode(e){if(typeof e!="function")throw new q("Graph.forEachNode: expecting a callback.");const t=this._nodes.values();let n,i;for(;n=t.next(),n.done!==!0;)i=n.value,e(i.key,i.attributes)}findNode(e){if(typeof e!="function")throw new q("Graph.findNode: expecting a callback.");const t=this._nodes.values();let n,i;for(;n=t.next(),n.done!==!0;)if(i=n.value,e(i.key,i.attributes))return i.key}mapNodes(e){if(typeof e!="function")throw new q("Graph.mapNode: expecting a callback.");const t=this._nodes.values();let n,i;const o=new Array(this.order);let s=0;for(;n=t.next(),n.done!==!0;)i=n.value,o[s++]=e(i.key,i.attributes);return o}someNode(e){if(typeof e!="function")throw new q("Graph.someNode: expecting a callback.");const t=this._nodes.values();let n,i;for(;n=t.next(),n.done!==!0;)if(i=n.value,e(i.key,i.attributes))return!0;return!1}everyNode(e){if(typeof e!="function")throw new q("Graph.everyNode: expecting a callback.");const t=this._nodes.values();let n,i;for(;n=t.next(),n.done!==!0;)if(i=n.value,!e(i.key,i.attributes))return!1;return!0}filterNodes(e){if(typeof e!="function")throw new q("Graph.filterNodes: expecting a callback.");const t=this._nodes.values();let n,i;const o=[];for(;n=t.next(),n.done!==!0;)i=n.value,e(i.key,i.attributes)&&o.push(i.key);return o}reduceNodes(e,t){if(typeof e!="function")throw new q("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new q("Graph.reduceNodes: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.");let n=t;const i=this._nodes.values();let o,s;for(;o=i.next(),o.done!==!0;)s=o.value,n=e(n,s.key,s.attributes);return n}nodeEntries(){const e=this._nodes.values();return{[Symbol.iterator](){return this},next(){const t=e.next();if(t.done)return t;const n=t.value;return{value:{node:n.key,attributes:n.attributes},done:!1}}}}export(){const e=new Array(this._nodes.size);let t=0;this._nodes.forEach((i,o)=>{e[t++]=kg(o,i)});const n=new Array(this._edges.size);return t=0,this._edges.forEach((i,o)=>{n[t++]=Eg(this.type,o,i)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:e,edges:n}}import(e,t=!1){if(e instanceof qe)return e.forEachNode((c,l)=>{t?this.mergeNode(c,l):this.addNode(c,l)}),e.forEachEdge((c,l,d,f,h,g,y)=>{t?y?this.mergeUndirectedEdgeWithKey(c,d,f,l):this.mergeDirectedEdgeWithKey(c,d,f,l):y?this.addUndirectedEdgeWithKey(c,d,f,l):this.addDirectedEdgeWithKey(c,d,f,l)}),this;if(!mt(e))throw new q("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(e.attributes){if(!mt(e.attributes))throw new q("Graph.import: invalid attributes. Expecting a plain object.");t?this.mergeAttributes(e.attributes):this.replaceAttributes(e.attributes)}let n,i,o,s,a;if(e.nodes){if(o=e.nodes,!Array.isArray(o))throw new q("Graph.import: invalid nodes. Expecting an array.");for(n=0,i=o.length;n<i;n++){s=o[n],Sg(s);const{key:c,attributes:l}=s;t?this.mergeNode(c,l):this.addNode(c,l)}}if(e.edges){let c=!1;if(this.type==="undirected"&&(c=!0),o=e.edges,!Array.isArray(o))throw new q("Graph.import: invalid edges. Expecting an array.");for(n=0,i=o.length;n<i;n++){a=o[n],Cg(a);const{source:l,target:d,attributes:f,undirected:h=c}=a;let g;"key"in a?(g=t?h?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:h?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,g.call(this,a.key,l,d,f)):(g=t?h?this.mergeUndirectedEdge:this.mergeDirectedEdge:h?this.addUndirectedEdge:this.addDirectedEdge,g.call(this,l,d,f))}}return this}nullCopy(e){const t=new qe(ut({},this._options,e));return t.replaceAttributes(ut({},this.getAttributes())),t}emptyCopy(e){const t=this.nullCopy(e);return this._nodes.forEach((n,i)=>{const o=ut({},n.attributes);n=new t.NodeDataClass(i,o),t._nodes.set(i,n)}),t}copy(e){if(e=e||{},typeof e.type=="string"&&e.type!==this.type&&e.type!=="mixed")throw new ue(`Graph.copy: cannot create an incompatible copy from "${this.type}" type to "${e.type}" because this would mean losing information about the current graph.`);if(typeof e.multi=="boolean"&&e.multi!==this.multi&&e.multi!==!0)throw new ue("Graph.copy: cannot create an incompatible copy by downgrading a multi graph to a simple one because this would mean losing information about the current graph.");if(typeof e.allowSelfLoops=="boolean"&&e.allowSelfLoops!==this.allowSelfLoops&&e.allowSelfLoops!==!0)throw new ue("Graph.copy: cannot create an incompatible copy from a graph allowing self loops to one that does not because this would mean losing information about the current graph.");const t=this.emptyCopy(e),n=this._edges.values();let i,o;for(;i=n.next(),i.done!==!0;)o=i.value,Lc(t,"copy",!1,o.undirected,o.key,o.source.key,o.target.key,ut({},o.attributes));return t}toJSON(){return this.export()}toString(){return"[object Graph]"}inspect(){const e={};this._nodes.forEach((o,s)=>{e[s]=o.attributes});const t={},n={};this._edges.forEach((o,s)=>{const a=o.undirected?"--":"->";let c="",l=o.source.key,d=o.target.key,f;o.undirected&&l>d&&(f=l,l=d,d=f);const h=`(${l})${a}(${d})`;s.startsWith("geid_")?this.multi&&(typeof n[h]>"u"?n[h]=0:n[h]++,c+=`${n[h]}. `):c+=`[${s}]: `,c+=h,t[c]=o.attributes});const i={};for(const o in this)this.hasOwnProperty(o)&&!Vs.has(o)&&typeof this[o]!="function"&&typeof o!="symbol"&&(i[o]=this[o]);return i.attributes=this._attributes,i.nodes=e,i.edges=t,zt(i,"constructor",this.constructor),i}}typeof Symbol<"u"&&(qe.prototype[Symbol.for("nodejs.util.inspect.custom")]=qe.prototype.inspect);Dg.forEach(r=>{["add","merge","update"].forEach(e=>{const t=r.name(e),n=e==="add"?Lc:Tg;r.generateKey?qe.prototype[t]=function(i,o,s){return n(this,t,!0,(r.type||this.type)==="undirected",null,i,o,s,e==="update")}:qe.prototype[t]=function(i,o,s,a){return n(this,t,!1,(r.type||this.type)==="undirected",i,o,s,a,e==="update")}})});Wp(qe);Zp(qe);pg(qe);xg(qe);class Tc extends qe{constructor(e){const t=ut({type:"directed"},e);if("multi"in t&&t.multi!==!1)throw new q("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(t.type!=="directed")throw new q('DirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class Gc extends qe{constructor(e){const t=ut({type:"undirected"},e);if("multi"in t&&t.multi!==!1)throw new q("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(t.type!=="undirected")throw new q('UndirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class Rc extends qe{constructor(e){const t=ut({multi:!0},e);if("multi"in t&&t.multi!==!0)throw new q("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(t)}}class Oc extends qe{constructor(e){const t=ut({type:"directed",multi:!0},e);if("multi"in t&&t.multi!==!0)throw new q("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(t.type!=="directed")throw new q('MultiDirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class zc extends qe{constructor(e){const t=ut({type:"undirected",multi:!0},e);if("multi"in t&&t.multi!==!0)throw new q("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(t.type!=="undirected")throw new q('MultiUndirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}function Fr(r){r.from=function(e,t){const n=ut({},e.options,t),i=new r(n);return i.import(e),i}}Fr(qe);Fr(Tc);Fr(Gc);Fr(Rc);Fr(Oc);Fr(zc);qe.Graph=qe;qe.DirectedGraph=Tc;qe.UndirectedGraph=Gc;qe.MultiGraph=Rc;qe.MultiDirectedGraph=Oc;qe.MultiUndirectedGraph=zc;qe.InvalidArgumentsGraphError=q;qe.NotFoundGraphError=B;qe.UsageGraphError=ue;var Fi,Hs;function Ro(){if(Hs)return Fi;Hs=1;function r(t){return!t||typeof t!="object"||typeof t=="function"||Array.isArray(t)||t instanceof Set||t instanceof Map||t instanceof RegExp||t instanceof Date}function e(t,n){t=t||{};var i={};for(var o in n){var s=t[o],a=n[o];if(!r(a)){i[o]=e(s,a);continue}s===void 0?i[o]=a:i[o]=s}return i}return Fi=e,Fi}var Vi,qs;function li(){return qs||(qs=1,Vi=function(e){return e!==null&&typeof e=="object"&&typeof e.addUndirectedEdgeWithKey=="function"&&typeof e.dropNode=="function"&&typeof e.multi=="boolean"}),Vi}var Ki,Ys;function Mc(){if(Ys)return Ki;Ys=1;var r=li();return Ki=function(t){if(!r(t))throw new Error("graphology-utils/infer-type: expecting a valid graphology instance.");var n=t.type;return n!=="mixed"?n:t.directedSize===0&&t.undirectedSize===0||t.directedSize>0&&t.undirectedSize>0?"mixed":t.directedSize>0?"directed":"undirected"},Ki}var Hi,Xs;function Nc(){if(Xs)return Hi;Xs=1;function r(e){if(typeof e!="function")throw new Error("obliterator/iterator: expecting a function!");this.next=e}return typeof Symbol<"u"&&(r.prototype[Symbol.iterator]=function(){return this}),r.of=function(){var e=arguments,t=e.length,n=0;return new r(function(){return n>=t?{done:!0}:{done:!1,value:e[n++]}})},r.empty=function(){var e=new r(function(){return{done:!0}});return e},r.fromSequence=function(e){var t=0,n=e.length;return new r(function(){return t>=n?{done:!0}:{done:!1,value:e[t++]}})},r.is=function(e){return e instanceof r?!0:typeof e=="object"&&e!==null&&typeof e.next=="function"},Hi=r,Hi}var qi={},Js;function Oo(){return Js||(Js=1,(function(r){var e=Math.pow(2,8)-1,t=Math.pow(2,16)-1,n=Math.pow(2,32)-1,i=Math.pow(2,7)-1,o=Math.pow(2,15)-1,s=Math.pow(2,31)-1;r.getPointerArray=function(c){var l=c-1;if(l<=e)return Uint8Array;if(l<=t)return Uint16Array;if(l<=n)return Uint32Array;throw new Error("mnemonist: Pointer Array of size > 4294967295 is not supported.")},r.getSignedPointerArray=function(c){var l=c-1;return l<=i?Int8Array:l<=o?Int16Array:l<=s?Int32Array:Float64Array},r.getNumberType=function(c){return c===(c|0)?Math.sign(c)===-1?c<=127&&c>=-128?Int8Array:c<=32767&&c>=-32768?Int16Array:Int32Array:c<=255?Uint8Array:c<=65535?Uint16Array:Uint32Array:Float64Array};var a={Uint8Array:1,Int8Array:2,Uint16Array:3,Int16Array:4,Uint32Array:5,Int32Array:6,Float32Array:7,Float64Array:8};r.getMinimalRepresentation=function(c,l){var d=null,f=0,h,g,y,C,b;for(C=0,b=c.length;C<b;C++)y=l?l(c[C]):c[C],g=r.getNumberType(y),h=a[g.name],h>f&&(f=h,d=g);return d},r.isTypedArray=function(c){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView(c)},r.concat=function(){var c=0,l,d,f;for(l=0,f=arguments.length;l<f;l++)c+=arguments[l].length;var h=new arguments[0].constructor(c);for(l=0,d=0;l<f;l++)h.set(arguments[l],d),d+=arguments[l].length;return h},r.indices=function(c){for(var l=r.getPointerArray(c),d=new l(c),f=0;f<c;f++)d[f]=f;return d}})(qi)),qi}var Yi,Zs;function zo(){if(Zs)return Yi;Zs=1;var r=Nc(),e=Oo().getPointerArray;function t(n,i){arguments.length<2&&(i=n,n=Array);var o=e(i);this.size=0,this.length=i,this.dense=new o(i),this.sparse=new o(i),this.vals=new n(i)}return t.prototype.clear=function(){this.size=0},t.prototype.has=function(n){var i=this.sparse[n];return i<this.size&&this.dense[i]===n},t.prototype.get=function(n){var i=this.sparse[n];if(i<this.size&&this.dense[i]===n)return this.vals[i]},t.prototype.set=function(n,i){var o=this.sparse[n];return o<this.size&&this.dense[o]===n?(this.vals[o]=i,this):(this.dense[this.size]=n,this.sparse[n]=this.size,this.vals[this.size]=i,this.size++,this)},t.prototype.delete=function(n){var i=this.sparse[n];return i>=this.size||this.dense[i]!==n?!1:(i=this.dense[this.size-1],this.dense[this.sparse[n]]=i,this.sparse[i]=this.sparse[n],this.size--,!0)},t.prototype.forEach=function(n,i){i=arguments.length>1?i:this;for(var o=0;o<this.size;o++)n.call(i,this.vals[o],this.dense[o])},t.prototype.keys=function(){var n=this.size,i=this.dense,o=0;return new r(function(){if(o<n){var s=i[o];return o++,{value:s}}return{done:!0}})},t.prototype.values=function(){var n=this.size,i=this.vals,o=0;return new r(function(){if(o<n){var s=i[o];return o++,{value:s}}return{done:!0}})},t.prototype.entries=function(){var n=this.size,i=this.dense,o=this.vals,s=0;return new r(function(){if(s<n){var a=[i[s],o[s]];return s++,{value:a}}return{done:!0}})},typeof Symbol<"u"&&(t.prototype[Symbol.iterator]=t.prototype.entries),t.prototype.inspect=function(){for(var n=new Map,i=0;i<this.size;i++)n.set(this.dense[i],this.vals[i]);return Object.defineProperty(n,"constructor",{value:t,enumerable:!1}),n.length=this.length,this.vals.constructor!==Array&&(n.type=this.vals.constructor.name),n},typeof Symbol<"u"&&(t.prototype[Symbol.for("nodejs.util.inspect.custom")]=t.prototype.inspect),Yi=t,Yi}var Xi,Qs;function Pc(){if(Qs)return Xi;Qs=1;var r=Nc(),e=Oo().getPointerArray;function t(n){var i=e(n);this.start=0,this.size=0,this.capacity=n,this.dense=new i(n),this.sparse=new i(n)}return t.prototype.clear=function(){this.start=0,this.size=0},t.prototype.has=function(n){if(this.size===0)return!1;var i=this.sparse[n],o=i<this.capacity&&i>=this.start&&i<this.start+this.size||i<(this.start+this.size)%this.capacity;return o&&this.dense[i]===n},t.prototype.enqueue=function(n){var i=this.sparse[n];if(this.size!==0){var o=i<this.capacity&&i>=this.start&&i<this.start+this.size||i<(this.start+this.size)%this.capacity;if(o&&this.dense[i]===n)return this}return i=(this.start+this.size)%this.capacity,this.dense[i]=n,this.sparse[n]=i,this.size++,this},t.prototype.dequeue=function(){if(this.size!==0){var n=this.start;this.size--,this.start++,this.start===this.capacity&&(this.start=0);var i=this.dense[n];return this.sparse[i]=this.capacity,i}},t.prototype.forEach=function(n,i){i=arguments.length>1?i:this;for(var o=this.capacity,s=this.size,a=this.start,c=0;c<s;)n.call(i,this.dense[a],c,this),a++,c++,a===o&&(a=0)},t.prototype.values=function(){var n=this.dense,i=this.capacity,o=this.size,s=this.start,a=0;return new r(function(){if(a>=o)return{done:!0};var c=n[s];return s++,a++,s===i&&(s=0),{value:c,done:!1}})},typeof Symbol<"u"&&(t.prototype[Symbol.iterator]=t.prototype.values),t.prototype.inspect=function(){var n=[];return this.forEach(function(i){n.push(i)}),Object.defineProperty(n,"constructor",{value:t,enumerable:!1}),n.capacity=this.capacity,n},typeof Symbol<"u"&&(t.prototype[Symbol.for("nodejs.util.inspect.custom")]=t.prototype.inspect),Xi=t,Xi}var Ji,ea;function Uc(){if(ea)return Ji;ea=1;function r(t){return function(n){return typeof n!="number"&&(n=n.length),Math.floor(t()*n)}}var e=r(Math.random);return e.createRandomIndex=r,Ji=e,Ji}var jn={},Zi,ta;function Gg(){if(ta)return Zi;ta=1;function r(t){return function(n,i){return n+Math.floor(t()*(i-n+1))}}var e=r(Math.random);return e.createRandom=r,Zi=e,Zi}var ra;function Rg(){if(ra)return jn;ra=1;var r=zo(),e=Gg().createRandom;function t(i,o,s){var a=i.get(o);typeof a>"u"&&(a=0),a+=s,i.set(o,a)}function n(i,o){o=o||{};var s=o.rng||Math.random,a="randomness"in o?o.randomness:.01;this.index=i,this.random=e(s),this.randomness=a,this.rng=s;var c=i.counts.constructor,l=i.weights.constructor,d=i.C;this.resolution=i.resolution,this.B=i.C,this.C=0,this.communitiesOffsets=new c(d),this.nodesSortedByCommunities=new c(d),this.communitiesBounds=new c(d+1),this.communityWeights=new l(d),this.degrees=new l(d),this.nonSingleton=new Uint8Array(d),this.externalEdgeWeightPerCommunity=new l(d),this.belongings=new c(d),this.neighboringCommunities=new r(l,d),this.cumulativeIncrement=new Float64Array(d),this.macroCommunities=null}return n.prototype.groupByCommunities=function(){var i=this.index,o,s,a,c,l;for(o=0,l=0,s=0;s<i.C;s++)a=i.counts[s],a!==0&&(this.communitiesBounds[l++]=o,o+=a,this.communitiesOffsets[s]=o);for(this.communitiesBounds[l]=o,l=0,s=0;s<i.C;s++)c=i.belongings[s],l=--this.communitiesOffsets[c],this.nodesSortedByCommunities[l]=s;this.B=i.C-i.U,this.C=i.C},n.prototype.communities=function(){var i=new Array(this.B),o,s,a,c,l;for(o=0;o<this.B;o++){for(c=this.communitiesBounds[o],l=this.communitiesBounds[o+1],a=[],s=c;s<l;s++)a.push(s);i[o]=a}return i},n.prototype.mergeNodesSubset=function(i,o){var s=this.index,a=s.belongings[this.nodesSortedByCommunities[i]],c=this.neighboringCommunities,l=0,d,f,h,g,y,C;for(f=i;f<o;f++)for(d=this.nodesSortedByCommunities[f],this.belongings[d]=d,this.nonSingleton[d]=0,this.degrees[d]=0,l+=s.loops[d]/2,this.communityWeights[d]=s.loops[d],this.externalEdgeWeightPerCommunity[d]=0,g=s.starts[d],y=s.starts[d+1];g<y;g++)C=s.neighborhood[g],h=s.weights[g],this.degrees[d]+=h,s.belongings[C]===a&&(l+=h,this.externalEdgeWeightPerCommunity[d]+=h,this.communityWeights[d]+=h);var b=this.externalEdgeWeightPerCommunity.slice(),m,A,v,p=o-i,E,S,$,x,D,I,j,O,w,ge,ce,L,_;for(A=this.random(i,o-1),m=i;m<o;m++,A++)if(f=i+A%p,d=this.nodesSortedByCommunities[f],this.nonSingleton[d]!==1&&!(this.externalEdgeWeightPerCommunity[d]<this.communityWeights[d]*(l/2-this.communityWeights[d])*this.resolution)){for(this.communityWeights[d]=0,this.externalEdgeWeightPerCommunity[d]=0,c.clear(),c.set(d,0),E=0,g=s.starts[d],y=s.starts[d+1];g<y;g++)C=s.neighborhood[g],s.belongings[C]===a&&(h=s.weights[g],E+=h,t(c,this.belongings[C],h));for(S=d,x=0,D=0,v=0;v<c.size;v++)I=c.dense[v],j=c.vals[v],O=this.communityWeights[I],this.externalEdgeWeightPerCommunity[I]>=O*(l/2-O)*this.resolution&&($=j-(E+s.loops[d])*O*this.resolution/l,$>x&&(S=I,x=$),$>=0&&(D+=Math.exp($/this.randomness))),this.cumulativeIncrement[v]=D;if(D<Number.MAX_VALUE&&D<1/0){for(w=D*this.rng(),ge=-1,ce=c.size+1;ge<ce-1;)L=ge+ce>>>1,this.cumulativeIncrement[L]>=w?ce=L:ge=L;_=c.dense[ce]}else _=S;for(this.communityWeights[_]+=E+s.loops[d],g=s.starts[d],y=s.starts[d+1];g<y;g++)C=s.neighborhood[g],s.belongings[C]===a&&(I=this.belongings[C],I===_?this.externalEdgeWeightPerCommunity[_]-=b[C]:this.externalEdgeWeightPerCommunity[_]+=b[C]);_!==d&&(this.belongings[d]=_,this.nonSingleton[_]=1,this.C--)}var K=this.neighboringCommunities;for(K.clear(),f=i;f<o;f++)d=this.nodesSortedByCommunities[f],K.set(this.belongings[d],1);return K.dense.slice(0,K.size)},n.prototype.refinePartition=function(){this.groupByCommunities(),this.macroCommunities=new Array(this.B);var i,o,s,a,c=this.communitiesBounds;for(i=0;i<this.B;i++)o=c[i],s=c[i+1],a=this.mergeNodesSubset(o,s),this.macroCommunities[i]=a},n.prototype.split=function(){var i=this.index,o=this.neighboringCommunities;o.clear();var s,a,c;for(s=0;s<i.C;s++)a=this.belongings[s],s===a&&(c=i.isolate(s,this.degrees[s]),o.set(a,c));for(s=0;s<i.C;s++)a=this.belongings[s],s!==a&&(c=o.get(a),i.move(s,this.degrees[s],c));var l,d;for(s=0;s<this.macroCommunities.length;s++)for(d=this.macroCommunities[s],l=0;l<d.length;l++)d[l]=o.get(d[l])},n.prototype.zoomOut=function(){var i=this.index;this.refinePartition(),this.split();var o=i.zoomOut(),s,a,c,l,d;for(l=0;l<this.macroCommunities.length;l++)for(s=this.macroCommunities[l],a=o[s[0]],d=1;d<s.length;d++)c=o[s[d]],i.expensiveMove(c,a)},n.prototype.onlySingletons=function(){var i=this.index,o;for(o=0;o<i.C;o++)if(i.counts[o]>1)return!1;return!0},jn.addWeightToCommunity=t,jn.UndirectedLeidenAddenda=n,jn}var Bn={},tn={},na;function Wc(){if(na)return tn;na=1;function r(n){return typeof n!="number"||isNaN(n)?1:n}function e(n,i){var o={},s=function(l){return typeof l>"u"?i:l};typeof i=="function"&&(s=i);var a=function(l){return s(l[n])},c=function(){return s(void 0)};return typeof n=="string"?(o.fromAttributes=a,o.fromGraph=function(l,d){return a(l.getNodeAttributes(d))},o.fromEntry=function(l,d){return a(d)}):typeof n=="function"?(o.fromAttributes=function(){throw new Error("graphology-utils/getters/createNodeValueGetter: irrelevant usage.")},o.fromGraph=function(l,d){return s(n(d,l.getNodeAttributes(d)))},o.fromEntry=function(l,d){return s(n(l,d))}):(o.fromAttributes=c,o.fromGraph=c,o.fromEntry=c),o}function t(n,i){var o={},s=function(l){return typeof l>"u"?i:l};typeof i=="function"&&(s=i);var a=function(l){return s(l[n])},c=function(){return s(void 0)};return typeof n=="string"?(o.fromAttributes=a,o.fromGraph=function(l,d){return a(l.getEdgeAttributes(d))},o.fromEntry=function(l,d){return a(d)},o.fromPartialEntry=o.fromEntry,o.fromMinimalEntry=o.fromEntry):typeof n=="function"?(o.fromAttributes=function(){throw new Error("graphology-utils/getters/createEdgeValueGetter: irrelevant usage.")},o.fromGraph=function(l,d){var f=l.extremities(d);return s(n(d,l.getEdgeAttributes(d),f[0],f[1],l.getNodeAttributes(f[0]),l.getNodeAttributes(f[1]),l.isUndirected(d)))},o.fromEntry=function(l,d,f,h,g,y,C){return s(n(l,d,f,h,g,y,C))},o.fromPartialEntry=function(l,d,f,h){return s(n(l,d,f,h))},o.fromMinimalEntry=function(l,d){return s(n(l,d))}):(o.fromAttributes=c,o.fromGraph=c,o.fromEntry=c,o.fromMinimalEntry=c),o}return tn.createNodeValueGetter=e,tn.createEdgeValueGetter=t,tn.createEdgeWeightGetter=function(n){return t(n,r)},tn}var ia;function jc(){if(ia)return Bn;ia=1;var r=Oo(),e=Ro(),t=Wc().createEdgeWeightGetter,n=Symbol.for("nodejs.util.inspect.custom"),i={getEdgeWeight:"weight",keepDendrogram:!1,resolution:1};function o(a,c){c=e(c,i);var l=c.resolution,d=t(c.getEdgeWeight).fromEntry,f=(a.size-a.selfLoopCount)*2,h=r.getPointerArray(f),g=r.getPointerArray(a.order+1),y=c.getEdgeWeight?Float64Array:r.getPointerArray(a.size*2);this.C=a.order,this.M=0,this.E=f,this.U=0,this.resolution=l,this.level=0,this.graph=a,this.nodes=new Array(a.order),this.keepDendrogram=c.keepDendrogram,this.neighborhood=new g(f),this.weights=new y(f),this.loops=new y(a.order),this.starts=new h(a.order+1),this.belongings=new g(a.order),this.dendrogram=[],this.mapping=null,this.counts=new g(a.order),this.unused=new g(a.order),this.totalWeights=new y(a.order);var C={},b,m=0,A=0,v=this;a.forEachNode(function(p){v.nodes[m]=p,C[p]=m,A+=a.undirectedDegreeWithoutSelfLoops(p),v.starts[m]=A,v.belongings[m]=m,v.counts[m]=1,m++}),a.forEachEdge(function(p,E,S,$,x,D,I){if(b=d(p,E,S,$,x,D,I),S=C[S],$=C[$],v.M+=b,S===$)v.totalWeights[S]+=b*2,v.loops[S]=b*2;else{v.totalWeights[S]+=b,v.totalWeights[$]+=b;var j=--v.starts[S],O=--v.starts[$];v.neighborhood[j]=$,v.neighborhood[O]=S,v.weights[j]=b,v.weights[O]=b}}),this.starts[m]=this.E,this.keepDendrogram?this.dendrogram.push(this.belongings.slice()):this.mapping=this.belongings.slice()}o.prototype.isolate=function(a,c){var l=this.belongings[a];if(this.counts[l]===1)return l;var d=this.unused[--this.U],f=this.loops[a];return this.totalWeights[l]-=c+f,this.totalWeights[d]+=c+f,this.belongings[a]=d,this.counts[l]--,this.counts[d]++,d},o.prototype.move=function(a,c,l){var d=this.belongings[a],f=this.loops[a];this.totalWeights[d]-=c+f,this.totalWeights[l]+=c+f,this.belongings[a]=l;var h=this.counts[d]--===1;this.counts[l]++,h&&(this.unused[this.U++]=d)},o.prototype.computeNodeDegree=function(a){var c,l,d,f=0;for(c=this.starts[a],l=this.starts[a+1];c<l;c++)d=this.weights[c],f+=d;return f},o.prototype.expensiveIsolate=function(a){var c=this.computeNodeDegree(a);return this.isolate(a,c)},o.prototype.expensiveMove=function(a,c){var l=this.computeNodeDegree(a);this.move(a,l,c)},o.prototype.zoomOut=function(){var a=new Array(this.C-this.U),c={},l=this.nodes.length,d=0,f=0,h,g,y,C,b,m,A,v,p;for(h=0,y=this.C;h<y;h++)m=this.belongings[h],m in c||(c[m]=d,a[d]={adj:{},totalWeights:this.totalWeights[m],internalWeights:0},d++),this.belongings[h]=c[m];var E,S;if(this.keepDendrogram){for(E=this.dendrogram[this.level],S=new(r.getPointerArray(d))(l),h=0;h<l;h++)S[h]=this.belongings[E[h]];this.dendrogram.push(S)}else for(h=0;h<l;h++)this.mapping[h]=this.belongings[this.mapping[h]];for(h=0,y=this.C;h<y;h++)for(m=this.belongings[h],v=a[m],p=v.adj,v.internalWeights+=this.loops[h],g=this.starts[h],C=this.starts[h+1];g<C;g++){if(b=this.neighborhood[g],A=this.belongings[b],m===A){v.internalWeights+=this.weights[g];continue}A in p||(p[A]=0),p[A]+=this.weights[g]}for(this.C=d,b=0,m=0;m<d;m++){v=a[m],p=v.adj,m=+m,this.totalWeights[m]=v.totalWeights,this.loops[m]=v.internalWeights,this.counts[m]=1,this.starts[m]=b,this.belongings[m]=m;for(A in p)this.neighborhood[b]=+A,this.weights[b]=p[A],f++,b++}return this.starts[d]=f,this.E=f,this.U=0,this.level++,c},o.prototype.modularity=function(){var a,c,l,d,f,h=0,g=this.M*2,y=new Float64Array(this.C);for(l=0;l<this.C;l++)for(a=this.belongings[l],y[a]+=this.loops[l],d=this.starts[l],f=this.starts[l+1];d<f;d++)c=this.belongings[this.neighborhood[d]],a===c&&(y[a]+=this.weights[d]);for(l=0;l<this.C;l++)h+=y[l]/g-Math.pow(this.totalWeights[l]/g,2)*this.resolution;return h},o.prototype.delta=function(a,c,l,d){var f=this.M,h=this.totalWeights[d];return c+=this.loops[a],l/f-h*c*this.resolution/(2*f*f)},o.prototype.deltaWithOwnCommunity=function(a,c,l,d){var f=this.M,h=this.totalWeights[d];return c+=this.loops[a],l/f-(h-c)*c*this.resolution/(2*f*f)},o.prototype.fastDelta=function(a,c,l,d){var f=this.M,h=this.totalWeights[d];return c+=this.loops[a],l-c*h*this.resolution/(2*f)},o.prototype.fastDeltaWithOwnCommunity=function(a,c,l,d){var f=this.M,h=this.totalWeights[d];return c+=this.loops[a],l-c*(h-c)*this.resolution/(2*f)},o.prototype.bounds=function(a){return[this.starts[a],this.starts[a+1]]},o.prototype.project=function(){var a=this,c={};return a.nodes.slice(0,this.C).forEach(function(l,d){c[l]=Array.from(a.neighborhood.slice(a.starts[d],a.starts[d+1])).map(function(f){return a.nodes[f]})}),c},o.prototype.collect=function(a){arguments.length<1&&(a=this.level);var c={},l=this.keepDendrogram?this.dendrogram[a]:this.mapping,d,f;for(d=0,f=l.length;d<f;d++)c[this.nodes[d]]=l[d];return c},o.prototype.assign=function(a,c){arguments.length<2&&(c=this.level);var l=this.keepDendrogram?this.dendrogram[c]:this.mapping,d,f;for(d=0,f=l.length;d<f;d++)this.graph.setNodeAttribute(this.nodes[d],a,l[d])},o.prototype[n]=function(){var a={};Object.defineProperty(a,"constructor",{value:o,enumerable:!1}),a.C=this.C,a.M=this.M,a.E=this.E,a.U=this.U,a.resolution=this.resolution,a.level=this.level,a.nodes=this.nodes,a.starts=this.starts.slice(0,a.C+1);var c=["neighborhood","weights"],l=["counts","loops","belongings","totalWeights"],d=this;return c.forEach(function(f){a[f]=d[f].slice(0,a.E)}),l.forEach(function(f){a[f]=d[f].slice(0,a.C)}),a.unused=this.unused.slice(0,this.U),this.keepDendrogram?a.dendrogram=this.dendrogram:a.mapping=this.mapping,a};function s(a,c){c=e(c,i);var l=c.resolution,d=t(c.getEdgeWeight).fromEntry,f=(a.size-a.selfLoopCount)*2,h=r.getPointerArray(f),g=r.getPointerArray(a.order+1),y=c.getEdgeWeight?Float64Array:r.getPointerArray(a.size*2);this.C=a.order,this.M=0,this.E=f,this.U=0,this.resolution=l,this.level=0,this.graph=a,this.nodes=new Array(a.order),this.keepDendrogram=c.keepDendrogram,this.neighborhood=new g(f),this.weights=new y(f),this.loops=new y(a.order),this.starts=new h(a.order+1),this.offsets=new h(a.order),this.belongings=new g(a.order),this.dendrogram=[],this.counts=new g(a.order),this.unused=new g(a.order),this.totalInWeights=new y(a.order),this.totalOutWeights=new y(a.order);var C={},b,m=0,A=0,v=this;a.forEachNode(function(p){v.nodes[m]=p,C[p]=m,A+=a.outDegreeWithoutSelfLoops(p),v.starts[m]=A,A+=a.inDegreeWithoutSelfLoops(p),v.offsets[m]=A,v.belongings[m]=m,v.counts[m]=1,m++}),a.forEachEdge(function(p,E,S,$,x,D,I){if(b=d(p,E,S,$,x,D,I),S=C[S],$=C[$],v.M+=b,S===$)v.loops[S]+=b,v.totalInWeights[S]+=b,v.totalOutWeights[S]+=b;else{v.totalOutWeights[S]+=b,v.totalInWeights[$]+=b;var j=--v.starts[S],O=--v.offsets[$];v.neighborhood[j]=$,v.neighborhood[O]=S,v.weights[j]=b,v.weights[O]=b}}),this.starts[m]=this.E,this.keepDendrogram?this.dendrogram.push(this.belongings.slice()):this.mapping=this.belongings.slice()}return s.prototype.bounds=o.prototype.bounds,s.prototype.inBounds=function(a){return[this.offsets[a],this.starts[a+1]]},s.prototype.outBounds=function(a){return[this.starts[a],this.offsets[a]]},s.prototype.project=o.prototype.project,s.prototype.projectIn=function(){var a=this,c={};return a.nodes.slice(0,this.C).forEach(function(l,d){c[l]=Array.from(a.neighborhood.slice(a.offsets[d],a.starts[d+1])).map(function(f){return a.nodes[f]})}),c},s.prototype.projectOut=function(){var a=this,c={};return a.nodes.slice(0,this.C).forEach(function(l,d){c[l]=Array.from(a.neighborhood.slice(a.starts[d],a.offsets[d])).map(function(f){return a.nodes[f]})}),c},s.prototype.isolate=function(a,c,l){var d=this.belongings[a];if(this.counts[d]===1)return d;var f=this.unused[--this.U],h=this.loops[a];return this.totalInWeights[d]-=c+h,this.totalInWeights[f]+=c+h,this.totalOutWeights[d]-=l+h,this.totalOutWeights[f]+=l+h,this.belongings[a]=f,this.counts[d]--,this.counts[f]++,f},s.prototype.move=function(a,c,l,d){var f=this.belongings[a],h=this.loops[a];this.totalInWeights[f]-=c+h,this.totalInWeights[d]+=c+h,this.totalOutWeights[f]-=l+h,this.totalOutWeights[d]+=l+h,this.belongings[a]=d;var g=this.counts[f]--===1;this.counts[d]++,g&&(this.unused[this.U++]=f)},s.prototype.computeNodeInDegree=function(a){var c,l,d,f=0;for(c=this.offsets[a],l=this.starts[a+1];c<l;c++)d=this.weights[c],f+=d;return f},s.prototype.computeNodeOutDegree=function(a){var c,l,d,f=0;for(c=this.starts[a],l=this.offsets[a];c<l;c++)d=this.weights[c],f+=d;return f},s.prototype.expensiveMove=function(a,c){var l=this.computeNodeInDegree(a),d=this.computeNodeOutDegree(a);this.move(a,l,d,c)},s.prototype.zoomOut=function(){var a=new Array(this.C-this.U),c={},l=this.nodes.length,d=0,f=0,h,g,y,C,b,m,A,v,p,E,S,$,x;for(h=0,y=this.C;h<y;h++)m=this.belongings[h],m in c||(c[m]=d,a[d]={inAdj:{},outAdj:{},totalInWeights:this.totalInWeights[m],totalOutWeights:this.totalOutWeights[m],internalWeights:0},d++),this.belongings[h]=c[m];var D,I;if(this.keepDendrogram){for(D=this.dendrogram[this.level],I=new(r.getPointerArray(d))(l),h=0;h<l;h++)I[h]=this.belongings[D[h]];this.dendrogram.push(I)}else for(h=0;h<l;h++)this.mapping[h]=this.belongings[this.mapping[h]];for(h=0,y=this.C;h<y;h++)for(m=this.belongings[h],p=this.offsets[h],v=a[m],$=v.inAdj,x=v.outAdj,v.internalWeights+=this.loops[h],g=this.starts[h],C=this.starts[h+1];g<C;g++){if(b=this.neighborhood[g],A=this.belongings[b],E=g<p,S=E?x:$,m===A){E&&(v.internalWeights+=this.weights[g]);continue}A in S||(S[A]=0),S[A]+=this.weights[g]}for(this.C=d,b=0,m=0;m<d;m++){v=a[m],$=v.inAdj,x=v.outAdj,m=+m,this.totalInWeights[m]=v.totalInWeights,this.totalOutWeights[m]=v.totalOutWeights,this.loops[m]=v.internalWeights,this.counts[m]=1,this.starts[m]=b,this.belongings[m]=m;for(A in x)this.neighborhood[b]=+A,this.weights[b]=x[A],f++,b++;this.offsets[m]=b;for(A in $)this.neighborhood[b]=+A,this.weights[b]=$[A],f++,b++}return this.starts[d]=f,this.E=f,this.U=0,this.level++,c},s.prototype.modularity=function(){var a,c,l,d,f,h=0,g=this.M,y=new Float64Array(this.C);for(l=0;l<this.C;l++)for(a=this.belongings[l],y[a]+=this.loops[l],d=this.starts[l],f=this.offsets[l];d<f;d++)c=this.belongings[this.neighborhood[d]],a===c&&(y[a]+=this.weights[d]);for(l=0;l<this.C;l++)h+=y[l]/g-this.totalInWeights[l]*this.totalOutWeights[l]/Math.pow(g,2)*this.resolution;return h},s.prototype.delta=function(a,c,l,d,f){var h=this.M,g=this.totalInWeights[f],y=this.totalOutWeights[f],C=this.loops[a];return c+=C,l+=C,d/h-(l*g+c*y)*this.resolution/(h*h)},s.prototype.deltaWithOwnCommunity=function(a,c,l,d,f){var h=this.M,g=this.totalInWeights[f],y=this.totalOutWeights[f],C=this.loops[a];return c+=C,l+=C,d/h-(l*(g-c)+c*(y-l))*this.resolution/(h*h)},s.prototype.collect=o.prototype.collect,s.prototype.assign=o.prototype.assign,s.prototype[n]=function(){var a={};Object.defineProperty(a,"constructor",{value:s,enumerable:!1}),a.C=this.C,a.M=this.M,a.E=this.E,a.U=this.U,a.resolution=this.resolution,a.level=this.level,a.nodes=this.nodes,a.starts=this.starts.slice(0,a.C+1);var c=["neighborhood","weights"],l=["counts","offsets","loops","belongings","totalInWeights","totalOutWeights"],d=this;return c.forEach(function(f){a[f]=d[f].slice(0,a.E)}),l.forEach(function(f){a[f]=d[f].slice(0,a.C)}),a.unused=this.unused.slice(0,this.U),this.keepDendrogram?a.dendrogram=this.dendrogram:a.mapping=this.mapping,a},Bn.UndirectedLouvainIndex=o,Bn.DirectedLouvainIndex=s,Bn}var Qi,oa;function Og(){if(oa)return Qi;oa=1;var r=Ro(),e=li(),t=Mc(),n=zo(),i=Pc(),o=Uc().createRandomIndex,s=Rg(),a=jc(),c=s.addWeightToCommunity,l=a.UndirectedLouvainIndex,d=s.UndirectedLeidenAddenda,f={attributes:{community:"community",weight:"weight"},randomness:.01,randomWalk:!0,resolution:1,rng:Math.random,weighted:!1,maxIterations:0},h=1e-10;function g(m,A,v,p,E){return Math.abs(p-E)<h?m===A?!1:v>m:p>E}function y(m,A,v){for(var p=new l(A,{attributes:{weight:v.attributes.weight},keepDendrogram:m,resolution:v.resolution,weighted:v.weighted}),E=new d(p,{randomness:v.randomness,rng:v.rng}),S=o(v.rng),$,x,D=new n(Float64Array,p.C),I=new i(p.C),j,O,w,ge,ce,L,_,K,ee,M,Re,ae,W,Se,Ce,be=0,Ye=0,ot=[],Ae,ve=0;!(v.maxIterations>0&&ve>=v.maxIterations);){for(ve++,ee=p.C,Ae=0,ce=v.randomWalk?S(ee):0,L=0;L<ee;L++,ce++)_=ce%ee,I.enqueue(_);for(;I.size!==0;){for(_=I.dequeue(),Ye++,M=0,D.clear(),$=p.belongings[_],j=p.starts[_],O=p.starts[_+1];j<O;j++)K=p.neighborhood[j],w=p.weights[j],x=p.belongings[K],M+=w,c(D,x,w);W=p.fastDeltaWithOwnCommunity(_,M,D.get($)||0,$),ae=$;var X=[[$,W,"own",p.counts[$]===1]];for(ge=0;ge<D.size;ge++)x=D.dense[ge],x!==$&&(Re=D.vals[ge],be++,Ce=p.fastDelta(_,M,Re,x),X.push([x,Ce,"other"]),Se=g(ae,$,x,Ce,W),Se&&(W=Ce,ae=x));if(W<0){if(ae=p.isolate(_,M),ae===$)continue}else{if(ae===$)continue;p.move(_,M,ae)}for(Ae++,j=p.starts[_],O=p.starts[_+1];j<O;j++)K=p.neighborhood[j],x=p.belongings[K],x!==ae&&I.enqueue(K)}if(ot.push(Ae),Ae===0){p.zoomOut();break}if(!E.onlySingletons()){E.zoomOut();continue}break}var me={index:p,deltaComputations:be,nodesVisited:Ye,moves:ot};return me}function C(m,A,v,p){if(!e(v))throw new Error("graphology-communities-leiden: the given graph is not a valid graphology instance.");var E=t(v);if(E==="mixed")throw new Error("graphology-communities-leiden: cannot run the algorithm on a true mixed graph.");if(E==="directed")throw new Error("graphology-communities-leiden: not yet implemented for directed graphs.");p=r(p,f);var S=0;if(v.size===0){if(m){v.forEachNode(function(O){v.setNodeAttribute(O,p.attributes.communities,S++)});return}var $={};return v.forEachNode(function(O){$[O]=S++}),A?{communities:$,count:v.order,deltaComputations:0,dendrogram:null,level:0,modularity:NaN,moves:null,nodesVisited:0,resolution:p.resolution}:$}var x=y,D=x(A,v,p),I=D.index;if(!A){if(m){I.assign(p.attributes.community);return}return I.collect()}var j={count:I.C,deltaComputations:D.deltaComputations,dendrogram:I.dendrogram,level:I.level,modularity:I.modularity(),moves:D.moves,nodesVisited:D.nodesVisited,resolution:p.resolution};return m?(I.assign(p.attributes.community),j):(j.communities=I.collect(),j)}var b=C.bind(null,!1,!1);return b.assign=C.bind(null,!0,!1),b.detailed=C.bind(null,!1,!0),b.defaults=f,Qi=b,Qi}var zg=Og();const Mg=Do(zg);var eo,sa;function Ng(){if(sa)return eo;sa=1;var r=Ro(),e=li(),t=Mc(),n=zo(),i=Pc(),o=Uc().createRandomIndex,s=jc(),a=s.UndirectedLouvainIndex,c=s.DirectedLouvainIndex,l={nodeCommunityAttribute:"community",getEdgeWeight:"weight",fastLocalMoves:!0,randomWalk:!0,resolution:1,rng:Math.random};function d(m,A,v){var p=m.get(A);typeof p>"u"&&(p=0),p+=v,m.set(A,p)}var f=1e-10;function h(m,A,v,p,E){return Math.abs(p-E)<f?m===A?!1:v>m:p>E}function g(m,A,v){var p=new a(A,{getEdgeWeight:v.getEdgeWeight,keepDendrogram:m,resolution:v.resolution}),E=o(v.rng),S=!0,$=!0,x,D,I=new n(Float64Array,p.C),j,O,w,ge,ce,L,_,K,ee,M,Re,ae,W,Se,Ce,be,Ye=0,ot=0,Ae=[],ve,X;for(v.fastLocalMoves&&(j=new i(p.C));S;){if(M=p.C,S=!1,$=!0,v.fastLocalMoves){for(X=0,L=v.randomWalk?E(M):0,_=0;_<M;_++,L++)K=L%M,j.enqueue(K);for(;j.size!==0;){for(K=j.dequeue(),ot++,Re=0,I.clear(),x=p.belongings[K],O=p.starts[K],w=p.starts[K+1];O<w;O++)ee=p.neighborhood[O],ge=p.weights[O],D=p.belongings[ee],Re+=ge,d(I,D,ge);for(Se=p.fastDeltaWithOwnCommunity(K,Re,I.get(x)||0,x),W=x,ce=0;ce<I.size;ce++)D=I.dense[ce],D!==x&&(ae=I.vals[ce],Ye++,be=p.fastDelta(K,Re,ae,D),Ce=h(W,x,D,be,Se),Ce&&(Se=be,W=D));if(Se<0){if(W=p.isolate(K,Re),W===x)continue}else{if(W===x)continue;p.move(K,Re,W)}for(S=!0,X++,O=p.starts[K],w=p.starts[K+1];O<w;O++)ee=p.neighborhood[O],D=p.belongings[ee],D!==W&&j.enqueue(ee)}Ae.push(X)}else for(ve=[],Ae.push(ve);$;){for($=!1,X=0,L=v.randomWalk?E(M):0,_=0;_<M;_++,L++){for(K=L%M,ot++,Re=0,I.clear(),x=p.belongings[K],O=p.starts[K],w=p.starts[K+1];O<w;O++)ee=p.neighborhood[O],ge=p.weights[O],D=p.belongings[ee],Re+=ge,d(I,D,ge);for(Se=p.fastDeltaWithOwnCommunity(K,Re,I.get(x)||0,x),W=x,ce=0;ce<I.size;ce++)D=I.dense[ce],D!==x&&(ae=I.vals[ce],Ye++,be=p.fastDelta(K,Re,ae,D),Ce=h(W,x,D,be,Se),Ce&&(Se=be,W=D));if(Se<0){if(W=p.isolate(K,Re),W===x)continue}else{if(W===x)continue;p.move(K,Re,W)}$=!0,X++}ve.push(X),S=$||S}S&&p.zoomOut()}var me={index:p,deltaComputations:Ye,nodesVisited:ot,moves:Ae};return me}function y(m,A,v){var p=new c(A,{getEdgeWeight:v.getEdgeWeight,keepDendrogram:m,resolution:v.resolution}),E=o(v.rng),S=!0,$=!0,x,D,I=new n(Float64Array,p.C),j,O,w,ge,ce,L,_,K,ee,M,Re,ae,W,Se,Ce,be,Ye,ot,Ae,ve=0,X=0,me=[],et,J;for(v.fastLocalMoves&&(j=new i(p.C));S;){if(ae=p.C,S=!1,$=!0,v.fastLocalMoves){for(J=0,K=v.randomWalk?E(ae):0,ee=0;ee<ae;ee++,K++)M=K%ae,j.enqueue(M);for(;j.size!==0;){for(M=j.dequeue(),X++,W=0,Se=0,I.clear(),x=p.belongings[M],O=p.starts[M],w=p.starts[M+1],ge=p.offsets[M];O<w;O++)ce=O<ge,Re=p.neighborhood[O],L=p.weights[O],D=p.belongings[Re],ce?Se+=L:W+=L,d(I,D,L);for(Ye=p.deltaWithOwnCommunity(M,W,Se,I.get(x)||0,x),be=x,_=0;_<I.size;_++)D=I.dense[_],D!==x&&(Ce=I.vals[_],ve++,Ae=p.delta(M,W,Se,Ce,D),ot=h(be,x,D,Ae,Ye),ot&&(Ye=Ae,be=D));if(Ye<0){if(be=p.isolate(M,W,Se),be===x)continue}else{if(be===x)continue;p.move(M,W,Se,be)}for(S=!0,J++,O=p.starts[M],w=p.starts[M+1];O<w;O++)Re=p.neighborhood[O],D=p.belongings[Re],D!==be&&j.enqueue(Re)}me.push(J)}else for(et=[],me.push(et);$;){for($=!1,J=0,K=v.randomWalk?E(ae):0,ee=0;ee<ae;ee++,K++){for(M=K%ae,X++,W=0,Se=0,I.clear(),x=p.belongings[M],O=p.starts[M],w=p.starts[M+1],ge=p.offsets[M];O<w;O++)ce=O<ge,Re=p.neighborhood[O],L=p.weights[O],D=p.belongings[Re],ce?Se+=L:W+=L,d(I,D,L);for(Ye=p.deltaWithOwnCommunity(M,W,Se,I.get(x)||0,x),be=x,_=0;_<I.size;_++)D=I.dense[_],D!==x&&(Ce=I.vals[_],ve++,Ae=p.delta(M,W,Se,Ce,D),ot=h(be,x,D,Ae,Ye),ot&&(Ye=Ae,be=D));if(Ye<0){if(be=p.isolate(M,W,Se),be===x)continue}else{if(be===x)continue;p.move(M,W,Se,be)}$=!0,J++}et.push(J),S=$||S}S&&p.zoomOut()}var ne={index:p,deltaComputations:ve,nodesVisited:X,moves:me};return ne}function C(m,A,v,p){if(!e(v))throw new Error("graphology-communities-louvain: the given graph is not a valid graphology instance.");var E=t(v);if(E==="mixed")throw new Error("graphology-communities-louvain: cannot run the algorithm on a true mixed graph.");p=r(p,l);var S=0;if(v.size===0){if(m){v.forEachNode(function(O){v.setNodeAttribute(O,p.nodeCommunityAttribute,S++)});return}var $={};return v.forEachNode(function(O){$[O]=S++}),A?{communities:$,count:v.order,deltaComputations:0,dendrogram:null,level:0,modularity:NaN,moves:null,nodesVisited:0,resolution:p.resolution}:$}var x=E==="undirected"?g:y,D=x(A,v,p),I=D.index;if(!A){if(m){I.assign(p.nodeCommunityAttribute);return}return I.collect()}var j={count:I.C,deltaComputations:D.deltaComputations,dendrogram:I.dendrogram,level:I.level,modularity:I.modularity(),moves:D.moves,nodesVisited:D.nodesVisited,resolution:p.resolution};return m?(I.assign(p.nodeCommunityAttribute),j):(j.communities=I.collect(),j)}var b=C.bind(null,!1,!1);return b.assign=C.bind(null,!0,!1),b.detailed=C.bind(null,!1,!0),b.defaults=l,eo=b,eo}var Pg=Ng();const Ug=Do(Pg);var to,aa;function Wg(){if(aa)return to;aa=1;var r=0,e=1,t=2,n=3,i=4,o=5,s=6,a=7,c=8,l=9,d=0,f=1,h=2,g=0,y=1,C=2,b=3,m=4,A=5,v=6,p=7,E=8,S=3,$=10,x=3,D=9,I=10;return to=function(O,w,ge){var ce,L,_,K,ee,M,Re,ae,W,Se,Ce=w.length,be=ge.length,Ye=O.adjustSizes,ot=O.barnesHutTheta*O.barnesHutTheta,Ae,ve,X,me,et,J,ne,G=[];for(_=0;_<Ce;_+=$)w[_+i]=w[_+t],w[_+o]=w[_+n],w[_+t]=0,w[_+n]=0;if(O.outboundAttractionDistribution){for(Ae=0,_=0;_<Ce;_+=$)Ae+=w[_+s];Ae/=Ce/$}if(O.barnesHutOptimize){var It=1/0,Rt=-1/0,Ot=1/0,Ht=-1/0,$t,xt,tt;for(_=0;_<Ce;_+=$)It=Math.min(It,w[_+r]),Rt=Math.max(Rt,w[_+r]),Ot=Math.min(Ot,w[_+e]),Ht=Math.max(Ht,w[_+e]);var Pt=Rt-It,nr=Ht-Ot;for(Pt>nr?(Ot-=(Pt-nr)/2,Ht=Ot+Pt):(It-=(nr-Pt)/2,Rt=It+nr),G[0+g]=-1,G[0+y]=(It+Rt)/2,G[0+C]=(Ot+Ht)/2,G[0+b]=Math.max(Rt-It,Ht-Ot),G[0+m]=-1,G[0+A]=-1,G[0+v]=0,G[0+p]=0,G[0+E]=0,ce=1,_=0;_<Ce;_+=$)for(L=0,tt=S;;)if(G[L+A]>=0){w[_+r]<G[L+y]?w[_+e]<G[L+C]?$t=G[L+A]:$t=G[L+A]+D:w[_+e]<G[L+C]?$t=G[L+A]+D*2:$t=G[L+A]+D*3,G[L+p]=(G[L+p]*G[L+v]+w[_+r]*w[_+s])/(G[L+v]+w[_+s]),G[L+E]=(G[L+E]*G[L+v]+w[_+e]*w[_+s])/(G[L+v]+w[_+s]),G[L+v]+=w[_+s],L=$t;continue}else if(G[L+g]<0){G[L+g]=_;break}else{if(G[L+A]=ce*D,ae=G[L+b]/2,W=G[L+A],G[W+g]=-1,G[W+y]=G[L+y]-ae,G[W+C]=G[L+C]-ae,G[W+b]=ae,G[W+m]=W+D,G[W+A]=-1,G[W+v]=0,G[W+p]=0,G[W+E]=0,W+=D,G[W+g]=-1,G[W+y]=G[L+y]-ae,G[W+C]=G[L+C]+ae,G[W+b]=ae,G[W+m]=W+D,G[W+A]=-1,G[W+v]=0,G[W+p]=0,G[W+E]=0,W+=D,G[W+g]=-1,G[W+y]=G[L+y]+ae,G[W+C]=G[L+C]-ae,G[W+b]=ae,G[W+m]=W+D,G[W+A]=-1,G[W+v]=0,G[W+p]=0,G[W+E]=0,W+=D,G[W+g]=-1,G[W+y]=G[L+y]+ae,G[W+C]=G[L+C]+ae,G[W+b]=ae,G[W+m]=G[L+m],G[W+A]=-1,G[W+v]=0,G[W+p]=0,G[W+E]=0,ce+=4,w[G[L+g]+r]<G[L+y]?w[G[L+g]+e]<G[L+C]?$t=G[L+A]:$t=G[L+A]+D:w[G[L+g]+e]<G[L+C]?$t=G[L+A]+D*2:$t=G[L+A]+D*3,G[L+v]=w[G[L+g]+s],G[L+p]=w[G[L+g]+r],G[L+E]=w[G[L+g]+e],G[$t+g]=G[L+g],G[L+g]=-1,w[_+r]<G[L+y]?w[_+e]<G[L+C]?xt=G[L+A]:xt=G[L+A]+D:w[_+e]<G[L+C]?xt=G[L+A]+D*2:xt=G[L+A]+D*3,$t===xt)if(tt--){L=$t;continue}else{tt=S;break}G[xt+g]=_;break}}if(O.barnesHutOptimize)for(ve=O.scalingRatio,_=0;_<Ce;_+=$)for(L=0;;)if(G[L+A]>=0)if(J=Math.pow(w[_+r]-G[L+p],2)+Math.pow(w[_+e]-G[L+E],2),Se=G[L+b],4*Se*Se/J<ot){if(X=w[_+r]-G[L+p],me=w[_+e]-G[L+E],Ye===!0?J>0?(ne=ve*w[_+s]*G[L+v]/J,w[_+t]+=X*ne,w[_+n]+=me*ne):J<0&&(ne=-ve*w[_+s]*G[L+v]/Math.sqrt(J),w[_+t]+=X*ne,w[_+n]+=me*ne):J>0&&(ne=ve*w[_+s]*G[L+v]/J,w[_+t]+=X*ne,w[_+n]+=me*ne),L=G[L+m],L<0)break;continue}else{L=G[L+A];continue}else{if(M=G[L+g],M>=0&&M!==_&&(X=w[_+r]-w[M+r],me=w[_+e]-w[M+e],J=X*X+me*me,Ye===!0?J>0?(ne=ve*w[_+s]*w[M+s]/J,w[_+t]+=X*ne,w[_+n]+=me*ne):J<0&&(ne=-ve*w[_+s]*w[M+s]/Math.sqrt(J),w[_+t]+=X*ne,w[_+n]+=me*ne):J>0&&(ne=ve*w[_+s]*w[M+s]/J,w[_+t]+=X*ne,w[_+n]+=me*ne)),L=G[L+m],L<0)break;continue}else for(ve=O.scalingRatio,K=0;K<Ce;K+=$)for(ee=0;ee<K;ee+=$)X=w[K+r]-w[ee+r],me=w[K+e]-w[ee+e],Ye===!0?(J=Math.sqrt(X*X+me*me)-w[K+c]-w[ee+c],J>0?(ne=ve*w[K+s]*w[ee+s]/J/J,w[K+t]+=X*ne,w[K+n]+=me*ne,w[ee+t]-=X*ne,w[ee+n]-=me*ne):J<0&&(ne=100*ve*w[K+s]*w[ee+s],w[K+t]+=X*ne,w[K+n]+=me*ne,w[ee+t]-=X*ne,w[ee+n]-=me*ne)):(J=Math.sqrt(X*X+me*me),J>0&&(ne=ve*w[K+s]*w[ee+s]/J/J,w[K+t]+=X*ne,w[K+n]+=me*ne,w[ee+t]-=X*ne,w[ee+n]-=me*ne));for(W=O.gravity/O.scalingRatio,ve=O.scalingRatio,_=0;_<Ce;_+=$)ne=0,X=w[_+r],me=w[_+e],J=Math.sqrt(Math.pow(X,2)+Math.pow(me,2)),O.strongGravityMode?J>0&&(ne=ve*w[_+s]*W):J>0&&(ne=ve*w[_+s]*W/J),w[_+t]-=X*ne,w[_+n]-=me*ne;for(ve=1*(O.outboundAttractionDistribution?Ae:1),Re=0;Re<be;Re+=x)K=ge[Re+d],ee=ge[Re+f],ae=ge[Re+h],et=Math.pow(ae,O.edgeWeightInfluence),X=w[K+r]-w[ee+r],me=w[K+e]-w[ee+e],Ye===!0?(J=Math.sqrt(X*X+me*me)-w[K+c]-w[ee+c],O.linLogMode?O.outboundAttractionDistribution?J>0&&(ne=-ve*et*Math.log(1+J)/J/w[K+s]):J>0&&(ne=-ve*et*Math.log(1+J)/J):O.outboundAttractionDistribution?J>0&&(ne=-ve*et/w[K+s]):J>0&&(ne=-ve*et)):(J=Math.sqrt(Math.pow(X,2)+Math.pow(me,2)),O.linLogMode?O.outboundAttractionDistribution?J>0&&(ne=-ve*et*Math.log(1+J)/J/w[K+s]):J>0&&(ne=-ve*et*Math.log(1+J)/J):O.outboundAttractionDistribution?(J=1,ne=-ve*et/w[K+s]):(J=1,ne=-ve*et)),J>0&&(w[K+t]+=X*ne,w[K+n]+=me*ne,w[ee+t]-=X*ne,w[ee+n]-=me*ne);var mr,ir,Er,Lt,Sr,or;if(Ye===!0)for(_=0;_<Ce;_+=$)w[_+l]!==1&&(mr=Math.sqrt(Math.pow(w[_+t],2)+Math.pow(w[_+n],2)),mr>I&&(w[_+t]=w[_+t]*I/mr,w[_+n]=w[_+n]*I/mr),ir=w[_+s]*Math.sqrt((w[_+i]-w[_+t])*(w[_+i]-w[_+t])+(w[_+o]-w[_+n])*(w[_+o]-w[_+n])),Er=Math.sqrt((w[_+i]+w[_+t])*(w[_+i]+w[_+t])+(w[_+o]+w[_+n])*(w[_+o]+w[_+n]))/2,Lt=.1*Math.log(1+Er)/(1+Math.sqrt(ir)),Sr=w[_+r]+w[_+t]*(Lt/O.slowDown),w[_+r]=Sr,or=w[_+e]+w[_+n]*(Lt/O.slowDown),w[_+e]=or);else for(_=0;_<Ce;_+=$)w[_+l]!==1&&(ir=w[_+s]*Math.sqrt((w[_+i]-w[_+t])*(w[_+i]-w[_+t])+(w[_+o]-w[_+n])*(w[_+o]-w[_+n])),Er=Math.sqrt((w[_+i]+w[_+t])*(w[_+i]+w[_+t])+(w[_+o]+w[_+n])*(w[_+o]+w[_+n]))/2,Lt=w[_+a]*Math.log(1+Er)/(1+Math.sqrt(ir)),w[_+a]=Math.min(1,Math.sqrt(Lt*(Math.pow(w[_+t],2)+Math.pow(w[_+n],2))/(1+Math.sqrt(ir)))),Sr=w[_+r]+w[_+t]*(Lt/O.slowDown),w[_+r]=Sr,or=w[_+e]+w[_+n]*(Lt/O.slowDown),w[_+e]=or);return{}},to}var Jt={},ca;function jg(){if(ca)return Jt;ca=1;var r=10,e=3;return Jt.assign=function(t){t=t||{};var n=Array.prototype.slice.call(arguments).slice(1),i,o,s;for(i=0,s=n.length;i<s;i++)if(n[i])for(o in n[i])t[o]=n[i][o];return t},Jt.validateSettings=function(t){return"linLogMode"in t&&typeof t.linLogMode!="boolean"?{message:"the `linLogMode` setting should be a boolean."}:"outboundAttractionDistribution"in t&&typeof t.outboundAttractionDistribution!="boolean"?{message:"the `outboundAttractionDistribution` setting should be a boolean."}:"adjustSizes"in t&&typeof t.adjustSizes!="boolean"?{message:"the `adjustSizes` setting should be a boolean."}:"edgeWeightInfluence"in t&&typeof t.edgeWeightInfluence!="number"?{message:"the `edgeWeightInfluence` setting should be a number."}:"scalingRatio"in t&&!(typeof t.scalingRatio=="number"&&t.scalingRatio>=0)?{message:"the `scalingRatio` setting should be a number >= 0."}:"strongGravityMode"in t&&typeof t.strongGravityMode!="boolean"?{message:"the `strongGravityMode` setting should be a boolean."}:"gravity"in t&&!(typeof t.gravity=="number"&&t.gravity>=0)?{message:"the `gravity` setting should be a number >= 0."}:"slowDown"in t&&!(typeof t.slowDown=="number"||t.slowDown>=0)?{message:"the `slowDown` setting should be a number >= 0."}:"barnesHutOptimize"in t&&typeof t.barnesHutOptimize!="boolean"?{message:"the `barnesHutOptimize` setting should be a boolean."}:"barnesHutTheta"in t&&!(typeof t.barnesHutTheta=="number"&&t.barnesHutTheta>=0)?{message:"the `barnesHutTheta` setting should be a number >= 0."}:null},Jt.graphToByteArrays=function(t,n){var i=t.order,o=t.size,s={},a,c=new Float32Array(i*r),l=new Float32Array(o*e);return a=0,t.forEachNode(function(d,f){s[d]=a,c[a]=f.x,c[a+1]=f.y,c[a+2]=0,c[a+3]=0,c[a+4]=0,c[a+5]=0,c[a+6]=1,c[a+7]=1,c[a+8]=f.size||1,c[a+9]=f.fixed?1:0,a+=r}),a=0,t.forEachEdge(function(d,f,h,g,y,C,b){var m=s[h],A=s[g],v=n(d,f,h,g,y,C,b);c[m+6]+=v,c[A+6]+=v,l[a]=m,l[a+1]=A,l[a+2]=v,a+=e}),{nodes:c,edges:l}},Jt.assignLayoutChanges=function(t,n,i){var o=0;t.updateEachNodeAttributes(function(s,a){return a.x=n[o],a.y=n[o+1],o+=r,i?i(s,a):a})},Jt.readGraphPositions=function(t,n){var i=0;t.forEachNode(function(o,s){n[i]=s.x,n[i+1]=s.y,i+=r})},Jt.collectLayoutChanges=function(t,n,i){for(var o=t.nodes(),s={},a=0,c=0,l=n.length;a<l;a+=r){if(i){var d=Object.assign({},t.getNodeAttributes(o[c]));d.x=n[a],d.y=n[a+1],d=i(o[c],d),s[o[c]]={x:d.x,y:d.y}}else s[o[c]]={x:n[a],y:n[a+1]};c++}return s},Jt.createWorker=function(n){var i=window.URL||window.webkitURL,o=n.toString(),s=i.createObjectURL(new Blob(["("+o+").call(this);"],{type:"text/javascript"})),a=new Worker(s);return i.revokeObjectURL(s),a},Jt}var ro,la;function Bg(){return la||(la=1,ro={linLogMode:!1,outboundAttractionDistribution:!1,adjustSizes:!1,edgeWeightInfluence:1,scalingRatio:1,strongGravityMode:!1,gravity:1,slowDown:1,barnesHutOptimize:!1,barnesHutTheta:.5}),ro}var no,ua;function Fg(){if(ua)return no;ua=1;var r=li(),e=Wc().createEdgeWeightGetter,t=Wg(),n=jg(),i=Bg();function o(c,l,d){if(!r(l))throw new Error("graphology-layout-forceatlas2: the given graph is not a valid graphology instance.");typeof d=="number"&&(d={iterations:d});var f=d.iterations;if(typeof f!="number")throw new Error("graphology-layout-forceatlas2: invalid number of iterations.");if(f<=0)throw new Error("graphology-layout-forceatlas2: you should provide a positive number of iterations.");var h=e("getEdgeWeight"in d?d.getEdgeWeight:"weight").fromEntry,g=typeof d.outputReducer=="function"?d.outputReducer:null,y=n.assign({},i,d.settings),C=n.validateSettings(y);if(C)throw new Error("graphology-layout-forceatlas2: "+C.message);var b=n.graphToByteArrays(l,h),m;for(m=0;m<f;m++)t(y,b.nodes,b.edges);if(c){n.assignLayoutChanges(l,b.nodes,g);return}return n.collectLayoutChanges(l,b.nodes)}function s(c){var l=typeof c=="number"?c:c.order;return{barnesHutOptimize:l>2e3,strongGravityMode:!0,gravity:.05,scalingRatio:10,slowDown:1+Math.log(l)}}var a=o.bind(null,!1);return a.assign=o.bind(null,!0),a.inferSettings=s,no=a,no}var Vg=Fg();const da=Do(Vg),Kg=["centrality_score","centrality","pagerank","page_rank","betweenness","closeness","eigenvector","degree","score"];function Hg(r){return r==null?"":String(r)}function qg(r){const e=typeof r=="number"?r:typeof r=="string"&&r.trim()?Number(r):NaN;return Number.isFinite(e)?e:null}function fa(r){for(const e of Kg){const t=qg(r.data[e]);if(t!==null)return t}return null}function ha(r,e){for(const t of e){const n=r[t];if(typeof n=="string"&&n.trim())return n}return null}function Mo(r,e){const t=r[e];return t&&typeof t=="object"&&!Array.isArray(t)?t:null}function pa(r){return Array.isArray(r)?r.filter(e=>typeof e=="string"||typeof e=="number").map(e=>String(e).trim()).filter(Boolean):[]}function Yg(r){const e=Mo(r.data,"metadata");return ha(r.data,["description","summary","content"])??(e?ha(e,["description","summary","content"]):null)}function Xg(r){const e=pa(r.data.exports);if(e.length>0)return e;const t=Mo(r.data,"metadata");return t?pa(t.exports):[]}function ga(r,e){for(const t of e){const n=r[t];if(typeof n=="boolean")return n;if(typeof n=="string"){const i=n.trim().toLowerCase();if(["true","yes","1"].includes(i))return!0;if(["false","no","0"].includes(i))return!1}}return null}function Bc(r,e){var i;const t=Mo(r.data,"metadata"),n=ga(r.data,["orphan","is_orphan","isOrphan","dead_code","deadCode"])??(t?ga(t,["orphan","is_orphan","isOrphan","dead_code","deadCode"]):null);return n!==null?n:(((i=e==null?void 0:e.get(r.id))==null?void 0:i.inDegree)??1)===0}function Jg(r){var n,i;const e=((n=r.data)==null?void 0:n.kind)??((i=r.data)==null?void 0:i.type)??r.label,t=typeof e=="string"?e.toLowerCase():"";return t==="imports"||t==="import"||t==="imports_from"?"imports":t==="defines"||t==="defined_in"||t==="contains"?"defines":"references"}function Zg(r,e){return r==="imports"?e==="incoming"?"imported by":"imports":r==="defines"?e==="incoming"?"defined by":"defines":e==="incoming"?"referenced by":"references"}function Qg(r,e,t,n){const i=new Map(e.map(l=>[l.id,l])),o=[];for(const l of t){const d=l.source===r.id?"outgoing":l.target===r.id?"incoming":null;if(!d)continue;const f=d==="outgoing"?l.target:l.source,h=i.get(f),g=Jg(l);o.push({id:l.id,kind:g,direction:d,label:Zg(g,d),edgeLabel:l.label,nodeId:f,nodeLabel:(h==null?void 0:h.label)??f})}const s=(l,d)=>l.kind.localeCompare(d.kind)||l.nodeLabel.localeCompare(d.nodeLabel)||l.nodeId.localeCompare(d.nodeId),a=o.filter(l=>l.direction==="incoming").sort(s),c=o.filter(l=>l.direction==="outgoing").sort(s);return{description:Yg(r),exports:Xg(r),orphan:Bc(r,n),incoming:a,outgoing:c,whereUsed:a}}function em(r,e){const t=new Map;for(const n of r)t.set(n.id,{degree:0,inDegree:0,outDegree:0,score:fa(n)??0});for(const n of e){const i=t.get(n.source),o=t.get(n.target);i&&(i.outDegree+=1,i.degree+=1),o&&(o.inDegree+=1,o.degree+=1)}for(const n of r){const i=t.get(n.id);i&&(i.score=fa(n)??i.degree)}return t}function tm(r,e,t){const n=t.get(r.id),i=t.get(e.id),o=((i==null?void 0:i.score)??0)-((n==null?void 0:n.score)??0);if(o!==0)return o;const s=((i==null?void 0:i.degree)??0)-((n==null?void 0:n.degree)??0);if(s!==0)return s;const a=r.label.localeCompare(e.label);return a!==0?a:r.id.localeCompare(e.id)}function rm(r,e){const t=r.map(o=>{var s;return((s=e.get(o.id))==null?void 0:s.inDegree)??0});return Math.max(0,...t)<=0?new Map(r.map(o=>[o.id,1])):[...new Set(t)].sort((o,s)=>o-s).length===1?new Map(r.map(o=>[o.id,1])):new Map(r.map(o=>{var c;const s=((c=e.get(o.id))==null?void 0:c.inDegree)??0;if(s<=0)return[o.id,1];const a=t.filter(l=>l<=s).length/t.length;return a>.95?[o.id,2]:a>.8?[o.id,1.5]:a>.5?[o.id,1.25]:[o.id,1]}))}function ma(r){const e=r.id??r.rid??r._id??r.uid;return e==null?null:String(e)}function va(r,e){const t=r.label??r.name??r.title;return t!=null?String(t):e}function nm(r){const e=r.source??r.from??r.src??r.start,t=r.target??r.to??r.dst??r.end;return e==null||t===null||t===void 0?null:{source:String(e),target:String(t)}}function im(r){const e=new Map,t=new Map;for(const n of r.result.records){if(n.nodes)for(const o of Object.values(n.nodes)){if(!o||typeof o!="object")continue;const s=o,a=ma(s);a&&(e.has(a)||e.set(a,{id:a,label:va(s,a),data:s}))}if(n.edges)for(const o of Object.values(n.edges)){if(!o||typeof o!="object")continue;const s=o,a=nm(s);if(!a)continue;const c=s.label??s.type??s.rel,l=`${a.source}->${a.target}:${Hg(c)}`;t.has(l)||t.set(l,{id:l,source:a.source,target:a.target,label:c!==void 0?String(c):void 0,data:s})}const i=n.values;if(i&&typeof i=="object"){const o=i.kind;if(o==="node"){const s=ma(i);s&&!e.has(s)&&e.set(s,{id:s,label:va(i,s),data:i})}else if(o==="edge"){const s=i.from_rid??i.from,a=i.to_rid??i.to;if(s!=null&&a!==void 0&&a!==null){const c=String(s),l=String(a),d=i.label??i.type??i.rel,h=`e:${i.rid??i.id??`${c}->${l}`}`;t.has(h)||t.set(h,{id:h,source:c,target:l,label:d!==void 0?String(d):void 0,data:i})}}}}return{nodes:[...e.values()],edges:[...t.values()]}}function uy(r){var t;const e=(t=r.result)==null?void 0:t.records;return!e||e.length===0?!1:e.some(n=>{if(n.nodes&&Object.keys(n.nodes).length>0||n.edges&&Object.keys(n.edges).length>0)return!0;const i=n.values;return!!(i&&(i.kind==="node"||i.kind==="edge"))})}function om(r){let e=r>>>0;return()=>{e=e+1831565813>>>0;let t=e;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}}function sm(r,e,t=Mg){try{if(!t||typeof t.assign!="function")throw new Error("Leiden community detection unavailable");return t.assign(r,{attributes:{community:"community"},rng:e}),"leiden"}catch{return Ug.assign(r,{nodeCommunityAttribute:"community",rng:e}),"louvain"}}function am(r,e){const t=new Map;if(r.length===0)return t;if(r.length===1)return t.set(r[0].id,{x:50,y:50,community:0}),t;const n=new qe({type:"undirected",multi:!1,allowSelfLoops:!0}),i=om(r.length*131+e.length),o=Math.PI*2;r.forEach((C,b)=>{const m=b/r.length*o+i()*.1;n.addNode(C.id,{x:Math.cos(m),y:Math.sin(m)})});for(const C of e)!n.hasNode(C.source)||!n.hasNode(C.target)||C.source!==C.target&&(n.hasEdge(C.source,C.target)||n.addEdge(C.source,C.target));if(n.size===0){const C=Math.ceil(Math.sqrt(r.length));return r.forEach((b,m)=>{const A=Math.floor(m/C),v=m%C;t.set(b.id,{x:10+v/Math.max(1,C-1)*80,y:10+A/Math.max(1,C-1)*80,community:m})}),t}sm(n,i);const s=da.inferSettings(n);da.assign(n,{iterations:r.length>200?120:200,settings:{...s,strongGravityMode:!0,gravity:1.2,scalingRatio:10,barnesHutOptimize:r.length>500}});let a=1/0,c=-1/0,l=1/0,d=-1/0;n.forEachNode((C,b)=>{b.x<a&&(a=b.x),b.x>c&&(c=b.x),b.y<l&&(l=b.y),b.y>d&&(d=b.y)});const f=c-a||1,h=d-l||1,g=5,y=100-g*2;return n.forEachNode((C,b)=>{t.set(C,{x:g+(b.x-a)/f*y,y:g+(b.y-l)/h*y,community:b.community??0})}),t}function No(r,e=!0){const t=[200,25,145,290,50,175,320,95,0,260,220,130],n=r<t.length?t[r]:(t[0]+r*137.508)%360,i=e?62:58,o=e?60:48;return`hsl(${n.toFixed(0)} ${i}% ${o}%)`}function ei(r){switch(r){case"tale":return"#ff2056";case"character":return"#7dd3fc";case"location":return"#a3e635";case"object":return"#fbbf24";case"archetype":return"#a78bfa";default:return"#94a3b8"}}function cm(r){return r==="tale"?8:r==="character"?5:r==="location"||r==="object"?4:3}function Fc(r,e){const t=Math.max(.35,Math.min(1.25,cm(r)*.14));return Math.max(.35,Math.min(2.5,t*e))}const Vc=3.4;function lm(r,e){return Fc(r,e)*Vc}const um="#e2e8f0";function Kc(r){return Math.min(7,2.2+Math.sqrt(Math.max(1,r))*.7)}function dm(r){return Kc(r)*Vc}function fm(r,e,t){const n=e/100,i=t/100,o=(1-Math.abs(2*i-1))*n,s=(r%360+360)%360/60,a=o*(1-Math.abs(s%2-1));let c=0,l=0,d=0;s>=0&&s<1?[c,l,d]=[o,a,0]:s<2?[c,l,d]=[a,o,0]:s<3?[c,l,d]=[0,o,a]:s<4?[c,l,d]=[0,a,o]:s<5?[c,l,d]=[a,0,o]:[c,l,d]=[o,0,a];const f=i-o/2;return{r:Math.round((c+f)*255),g:Math.round((l+f)*255),b:Math.round((d+f)*255)}}function Hc(r){const e=r.match(/hsl\(\s*([\d.]+)\s*[, ]\s*([\d.]+)%\s*[, ]\s*([\d.]+)%/i);return e?fm(Number(e[1]),Number(e[2]),Number(e[3])):null}function hm({r,g:e,b:t}){return`rgb(${r}, ${e}, ${t})`}function pm(r,e=!0){const t=No(r,e),n=Hc(t);return n?hm(n):t}function Ur(r,e){const t=Math.max(0,Math.min(1,e)),n=r.startsWith("hsl")?Hc(r):null;if(n)return`rgba(${n.r}, ${n.g}, ${n.b}, ${t})`;const i=r.match(/rgb\(\s*([\d.]+)[, ]+([\d.]+)[, ]+([\d.]+)/i);if(i)return`rgba(${i[1]}, ${i[2]}, ${i[3]}, ${t})`;const o=r.replace("#","");if(/^[0-9a-f]{6}$/i.test(o)){const s=parseInt(o.slice(0,2),16),a=parseInt(o.slice(2,4),16),c=parseInt(o.slice(4,6),16);return`rgba(${s}, ${a}, ${c}, ${t})`}return r}const gm="#d6a72c",mm="#f4c84a";function vm(r){var d,f,h,g;const{nodes:e,edges:t,layout:n,sizeScales:i,orphanIds:o,dark:s=!0,edgeColor:a="#3a424d",bundledCurvatures:c}=r,l=new qe({type:"directed",multi:!0,allowSelfLoops:!0});for(const y of e){if(l.hasNode(y.id))continue;const C=String(y.data.node_type??"node"),b=i.get(y.id)??1,m=n.get(y.id),A=y.data.__supernode===!0,v=typeof y.data.__memberCount=="number"?y.data.__memberCount:0,p=A?dm(v):lm(C,b),E=m?pm(m.community,s):ei(C);l.addNode(y.id,{x:(m==null?void 0:m.x)??50,y:-((m==null?void 0:m.y)??50),size:p,baseSize:p,color:E,mutedColor:Ur(E,.14),borderColor:A?um:ei(C),label:y.label,nodeType:C,community:(m==null?void 0:m.community)??-1,orphan:o.has(y.id),isSupernode:A,memberCount:v,type:"border"})}for(const y of t){if(!l.hasNode(y.source)||!l.hasNode(y.target)||l.hasEdge(y.id))continue;const C=((d=n.get(y.source))==null?void 0:d.community)??-1,b=((f=n.get(y.target))==null?void 0:f.community)??-1,m=((h=y.data)==null?void 0:h.__aggregated)===!0,A=typeof((g=y.data)==null?void 0:g.weight)=="number"?y.data.weight:1;l.addEdgeWithKey(y.id,y.source,y.target,{size:m?Math.min(6,1+Math.log2(A+1)):1,color:Ur(a,.34),edgeLabel:y.label??"",label:"",crossCommunity:C!==b,curvature:(c==null?void 0:c.get(y.id))??0,type:"line"})}return l}function ym(r,e,t={}){const{padding:n=2.5,dark:i=!0}=t,o=new Map;for(const s of r){const a=e.get(s.id);if(!a)continue;const c=o.get(a.community);c?(c.minX=Math.min(c.minX,a.x),c.minY=Math.min(c.minY,a.y),c.maxX=Math.max(c.maxX,a.x),c.maxY=Math.max(c.maxY,a.y),c.count+=1):o.set(a.community,{minX:a.x,minY:a.y,maxX:a.x,maxY:a.y,count:1})}return[...o.entries()].sort((s,a)=>s[0]-a[0]).map(([s,a])=>{const c=No(s,i);return{community:s,count:a.count,tint:c,fill:Ur(c,.08),stroke:Ur(c,.5),minX:a.minX-n,minY:a.minY-n,maxX:a.maxX+n,maxY:a.maxY+n,cx:(a.minX+a.maxX)/2,cy:(a.minY+a.maxY)/2}})}function ya(r,e,t,n,i){const o=t-r,s=n-e;let a=1;return o>0?a=Math.min(a,(i.maxX-r)/o):o<0&&(a=Math.min(a,(i.minX-r)/o)),s>0?a=Math.min(a,(i.maxY-e)/s):s<0&&(a=Math.min(a,(i.minY-e)/s)),a=Math.max(0,Math.min(1,a)),{x:r+o*a,y:e+s*a}}function bm(r,e,t){const n=new Map(t.map(o=>[o.community,o])),i=[];for(const o of r){const s=e.get(o.source),a=e.get(o.target);if(!s||!a||s.community===a.community)continue;const c=n.get(s.community),l=n.get(a.community);if(!c||!l)continue;const d=ya(s.x,s.y,a.x,a.y,c),f=ya(a.x,a.y,s.x,s.y,l);i.push({id:o.id,source:o.source,target:o.target,label:o.label,sourceCommunity:s.community,targetCommunity:a.community,x1:d.x,y1:d.y,x2:f.x,y2:f.y})}return i}const wm=36,_m=28,xm=36;function km(r,e,t){const{focus:n,focusId:i,selectedNodeId:o,pulse:s,colors:a}=t,c=i!==null,l=i===r,d=n.nodes.has(r),f=!c||d,h=c?l?2.2+s*.38:d?1.58:.9:1,g=l?a.focusNodeStroke:e.orphan?a.warn:o===r?a.selectedNodeStroke:e.borderColor,y=e.isSupernode||c&&(l||n.nodes.size<=xm&&d);return{size:e.baseSize*h,color:f?e.color:e.mutedColor,borderColor:g,label:y?e.label.slice(0,wm):"",forceLabel:y,zIndex:l?3:e.isSupernode||d?2:1,hidden:!1}}function Em(r,e,t){const{focus:n,focusId:i,colors:o,groupInBox:s,bundle:a}=t,c=i!==null,l=n.edges.has(r),d=e.curvature,f=a&&Math.abs(d)>1e-4?"curved":"line";return s&&e.crossCommunity&&!l?{size:e.size,color:e.color,label:"",forceLabel:!1,zIndex:0,hidden:!0,type:f,curvature:d}:c?l?{size:2.2,color:o.focusEdge,label:e.edgeLabel?e.edgeLabel.slice(0,_m):"",forceLabel:!!e.edgeLabel,zIndex:2,hidden:!1,type:f,curvature:d}:{size:e.size,color:Ur(o.edge,.055),label:"",forceLabel:!1,zIndex:0,hidden:!1,type:f,curvature:d}:{size:e.size,color:Ur(o.edge,.34),label:"",forceLabel:!1,zIndex:0,hidden:!1,type:f,curvature:d}}const Sm={stiffness:.1,stepSize:.1,cycles:6,iterations:60,iterationRate:2/3,subdivisionRate:2,compatibilityThreshold:.6},io=1500,Wr=1e-6;function ln(r,e){return Math.hypot(r.x-e.x,r.y-e.y)}function ti(r,e){return{x:(r.x+e.x)/2,y:(r.y+e.y)/2}}function ba(r,e){const t=e+2,n=[0];for(let a=1;a<r.length;a++)n.push(n[a-1]+ln(r[a],r[a-1]));const i=n[n.length-1];if(i<Wr)return Array.from({length:t},()=>({...r[0]}));const o=[];let s=1;for(let a=0;a<t;a++){const c=i*a/(t-1);for(;s<r.length-1&&n[s]<c;)s++;const l=n[s-1],d=n[s]-l||1,f=Math.max(0,Math.min(1,(c-l)/d));o.push({x:r[s-1].x+f*(r[s].x-r[s-1].x),y:r[s-1].y+f*(r[s].y-r[s-1].y)})}return o}function Cm(r,e){const t=(r.t.x-r.s.x)*(e.t.x-e.s.x)+(r.t.y-r.s.y)*(e.t.y-e.s.y);return Math.abs(t/(r.len*e.len))}function Am(r,e){const t=(r.len+e.len)/2;return 2/(t/Math.min(r.len,e.len)+Math.max(r.len,e.len)/t)}function $m(r,e){const t=(r.len+e.len)/2;return t/(t+ln(ti(r.s,r.t),ti(e.s,e.t)))}function wa(r,e){const t=e.len*e.len,n=((e.s.y-r.y)*(e.s.y-e.t.y)-(e.s.x-r.x)*(e.t.x-e.s.x))/t;return{x:e.s.x+n*(e.t.x-e.s.x),y:e.s.y+n*(e.t.y-e.s.y)}}function _a(r,e){const t=wa(e.s,r),n=wa(e.t,r),i=ti(t,n),o=ln(t,n);return o<Wr?0:Math.max(0,1-2*ln(i,ti(e.s,e.t))/o)}function Dm(r,e){return Math.min(_a(r,e),_a(e,r))}function Im(r,e){return Cm(r,e)*Am(r,e)*$m(r,e)*Dm(r,e)}function Lm(r,e){const t=r.map(()=>[]);for(let n=0;n<r.length;n++)for(let i=n+1;i<r.length;i++)Im(r[n],r[i])>=e&&(t[n].push(i),t[i].push(n));return t}function Tm(r,e,t={}){const n={...Sm,...t},i=new Map(r.map(h=>[h.id,{x:h.x,y:h.y}])),o=new Map,s=[];for(const h of e){const g=i.get(h.source),y=i.get(h.target);if(!g||!y||(o.set(h.id,[{...g},{...y}]),h.source===h.target))continue;const C=ln(g,y);C<Wr||s.push({id:h.id,s:{...g},t:{...y},len:C})}if(s.length<2)return o;const a=s.map(h=>[{...h.s},{...h.t}]),c=Lm(s,n.compatibilityThreshold);let l=1,d=n.stepSize,f=n.iterations;for(let h=0;h<a.length;h++)a[h]=ba(a[h],l);for(let h=0;h<n.cycles;h++){const g=Math.max(1,Math.round(f));for(let y=0;y<g;y++){const C=s.map((b,m)=>Gm(m,a,c,s[m].len,l,d,n.stiffness));for(let b=0;b<s.length;b++)for(let m=1;m<=l;m++)a[b][m].x+=C[b][m].x,a[b][m].y+=C[b][m].y}d*=.5,l*=n.subdivisionRate,f*=n.iterationRate;for(let y=0;y<a.length;y++)a[y]=ba(a[y],l)}for(let h=0;h<s.length;h++)o.set(s[h].id,a[h].map(g=>({x:g.x,y:g.y})));return o}function Gm(r,e,t,n,i,o,s){const a=s/(n*(i+1)),c=e[r],l=[{x:0,y:0}];for(let d=1;d<=i;d++){const f=c[d-1],h=c[d],g=c[d+1];let y=a*(f.x-2*h.x+g.x),C=a*(f.y-2*h.y+g.y);for(const b of t[r]){const m=e[b][d],A=m.x-h.x,v=m.y-h.y;if(Math.abs(A)>Wr||Math.abs(v)>Wr){const p=Math.hypot(A,v);y+=A/p,C+=v/p}}l.push({x:o*y,y:o*C})}return l.push({x:0,y:0}),l}function Rm(r){if(r.length<3)return 0;const e=r[0],t=r[r.length-1],n=t.x-e.x,i=t.y-e.y,o=Math.hypot(n,i);if(o<Wr)return 0;let s=0;for(let c=1;c<r.length-1;c++){const l=r[c].x-e.x,d=r[c].y-e.y,f=(l*-i+d*n)/o;Math.abs(f)>Math.abs(s)&&(s=f)}const a=2*s/o;return Math.max(-1,Math.min(1,a))}const Po="__cluster__:";function xa(r){return`${Po}${r}`}function qc(r){return r.startsWith(Po)}function Om(r){if(!qc(r))return null;const e=Number(r.slice(Po.length));return Number.isFinite(e)?e:null}function Yc(r,e){const t=new Map;for(const n of r){const i=e.get(n.id);if(!i)continue;const o=t.get(i.community);o?o.push(n.id):t.set(i.community,[n.id])}return t}const ka=(r,e,t)=>({nodes:r,edges:e,layout:t,supernodes:new Map,collapsedMembers:new Map});function zm(r,e,t,n){if(n.size===0)return ka(r,e,t);const i=Yc(r,t),o=new Set;for(const g of n){const y=i.get(g);y&&y.length>0&&o.add(g)}if(o.size===0)return ka(r,e,t);const s=new Map,a=new Map,c=[],l=new Map;for(const g of r){const y=t.get(g.id);if(y&&o.has(y.community)){s.set(g.id,xa(y.community));continue}c.push(g),y&&l.set(g.id,y)}for(const g of o){const y=i.get(g),C=xa(g);let b=0,m=0,A=0;for(const v of y){const p=t.get(v);p&&(b+=p.x,m+=p.y,A+=1)}a.set(C,{community:g,memberIds:y,size:y.length}),c.push({id:C,label:`cluster ${g} · ${y.length}`,data:{node_type:"cluster",__supernode:!0,__community:g,__memberCount:y.length}}),l.set(C,{x:A?b/A:50,y:A?m/A:50,community:g})}const d=g=>s.get(g)??g,f=[],h=new Map;for(const g of e){const y=d(g.source),C=d(g.target);if(!(y!==g.source||C!==g.target)){f.push(g);continue}if(y===C)continue;const m=`${y} ${C}`,A=h.get(m);A?(A.weight+=1,A.members.push(g.id)):h.set(m,{source:y,target:C,weight:1,members:[g.id]})}for(const[g,y]of h)f.push({id:`__agg__:${g}`,source:y.source,target:y.target,label:y.weight>1?`×${y.weight}`:void 0,data:{__aggregated:!0,weight:y.weight,members:y.members}});return{nodes:c,edges:f,layout:l,supernodes:a,collapsedMembers:s}}const Xc={name:"table-2",size:24,node:[["path",{d:"M3 9h18"}],["path",{d:"M9 3v18"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}]]};Xc.node;function Mm(r,e){let t=Ze(e,["$$slots","$$events","$$legacy"]);at(r,it(()=>t,{get icon(){return Xc}}))}const Jc={name:"info",size:24,node:[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"M12 16v-4"}],["path",{d:"M12 8h.01"}]]};Jc.node;function Nm(r,e){let t=Ze(e,["$$slots","$$events","$$legacy"]);at(r,it(()=>t,{get icon(){return Jc}}))}const Zc={name:"maximize-2",size:24,node:[["path",{d:"M15 3h6v6"}],["path",{d:"m21 3-7 7"}],["path",{d:"m3 21 7-7"}],["path",{d:"M9 21H3v-6"}]]};Zc.node;function Pm(r,e){let t=Ze(e,["$$slots","$$events","$$legacy"]);at(r,it(()=>t,{get icon(){return Zc}}))}const Qc={name:"code-xml",size:24,node:[["path",{d:"m18 16 4-4-4-4"}],["path",{d:"m6 8-4 4 4 4"}],["path",{d:"m14.5 4-5 16"}]],aliases:["code-2"]};Qc.node;function Um(r,e){let t=Ze(e,["$$slots","$$events","$$legacy"]);at(r,it(()=>t,{get icon(){return Qc}}))}const el={name:"route",size:24,node:[["circle",{cx:"6",cy:"19",r:"3"}],["path",{d:"M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15"}],["circle",{cx:"18",cy:"5",r:"3"}]]};el.node;function Wm(r,e){let t=Ze(e,["$$slots","$$events","$$legacy"]);at(r,it(()=>t,{get icon(){return el}}))}const tl={name:"zoom-in",size:24,node:[["circle",{cx:"11",cy:"11",r:"8"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11"}]]};tl.node;function jm(r,e){let t=Ze(e,["$$slots","$$events","$$legacy"]);at(r,it(()=>t,{get icon(){return tl}}))}const rl={name:"zoom-out",size:24,node:[["circle",{cx:"11",cy:"11",r:"8"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11"}]]};rl.node;function Bm(r,e){let t=Ze(e,["$$slots","$$events","$$legacy"]);at(r,it(()=>t,{get icon(){return rl}}))}const nl={name:"group",size:24,node:[["path",{d:"M3 7V5c0-1.1.9-2 2-2h2"}],["path",{d:"M17 3h2c1.1 0 2 .9 2 2v2"}],["path",{d:"M21 17v2c0 1.1-.9 2-2 2h-2"}],["path",{d:"M7 21H5c-1.1 0-2-.9-2-2v-2"}],["rect",{width:"7",height:"5",x:"7",y:"7",rx:"1"}],["rect",{width:"7",height:"5",x:"10",y:"12",rx:"1"}]]};nl.node;function Ea(r,e){let t=Ze(e,["$$slots","$$events","$$legacy"]);at(r,it(()=>t,{get icon(){return nl}}))}const il={name:"spline",size:24,node:[["circle",{cx:"19",cy:"5",r:"2"}],["circle",{cx:"5",cy:"19",r:"2"}],["path",{d:"M5 17A12 12 0 0 1 17 5"}]]};il.node;function Fm(r,e){let t=Ze(e,["$$slots","$$events","$$legacy"]);at(r,it(()=>t,{get icon(){return il}}))}const ol={name:"boxes",size:24,node:[["path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z"}],["path",{d:"m7 16.5-4.74-2.85"}],["path",{d:"m7 16.5 5-3"}],["path",{d:"M7 16.5v5.17"}],["path",{d:"M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z"}],["path",{d:"m17 16.5-5-3"}],["path",{d:"m17 16.5 4.74-2.85"}],["path",{d:"M17 16.5v5.17"}],["path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z"}],["path",{d:"M12 8 7.26 5.15"}],["path",{d:"m12 8 4.74-2.85"}],["path",{d:"M12 13.5V8"}]]};ol.node;function Sa(r,e){let t=Ze(e,["$$slots","$$events","$$legacy"]);at(r,it(()=>t,{get icon(){return ol}}))}var Vm=he('<div class="flex-1 grid place-items-center text-fg-3 text-[12px] font-mono p-6 svelte-gt9p7f">No graph shape in this result.</div>'),Km=he('<button type="button" class="text-fg-3 hover:text-fg-1 cursor-pointer svelte-gt9p7f" aria-label="Clear filter"><!></button>'),Hm=he('<div class="inline-flex items-center gap-1.5 border border-line-1 rounded px-2 py-1 bg-bg-0 svelte-gt9p7f"><!> <input type="text" placeholder="filter by label…" class="bg-transparent text-fg-1 text-[11px] outline-none w-[160px] placeholder:text-fg-3 svelte-gt9p7f"/> <!></div> <label class="inline-flex items-center gap-1.5 text-fg-3 svelte-gt9p7f"><!> <span class="svelte-gt9p7f">limit:</span> <select class="bg-bg-1 text-fg-1 border border-line-1 rounded px-1 py-0.5 svelte-gt9p7f"><option class="svelte-gt9p7f">500</option><option class="svelte-gt9p7f">1k</option><option class="svelte-gt9p7f">2k</option><option class="svelte-gt9p7f">5k</option><option class="svelte-gt9p7f">10k</option><option class="svelte-gt9p7f">25k</option><option class="svelte-gt9p7f">50k</option></select></label>',1),qm=he('<div class="inline-flex items-center overflow-hidden rounded border border-line-1 bg-bg-0 svelte-gt9p7f"><button type="button" class="inline-flex h-6 w-7 items-center justify-center text-fg-3 hover:bg-bg-1 hover:text-fg-0 disabled:opacity-40 svelte-gt9p7f" title="Zoom out" aria-label="Zoom out"><!></button> <button type="button" class="inline-flex h-6 min-w-12 items-center justify-center border-x border-line-1 px-2 text-[10px] text-fg-3 hover:bg-bg-1 hover:text-fg-0 svelte-gt9p7f" title="Fit graph" aria-label="Fit graph"> </button> <button type="button" class="inline-flex h-6 w-7 items-center justify-center text-fg-3 hover:bg-bg-1 hover:text-fg-0 disabled:opacity-40 svelte-gt9p7f" title="Zoom in" aria-label="Zoom in"><!></button></div>'),Ym=he('<span class="text-warn svelte-gt9p7f"> </span>'),Xm=he('<button type="button"><!> </button>'),Jm=he('<button type="button" title="Group in a box — draw one tinted box per community and route inter-community edges at the borders"><!> groups</button> <button type="button" title="Force-directed edge bundling — collapse parallel edges onto shared trunks to untangle dense subgraphs"><!> bundle</button> <!> <!>',1),Zm=he('<button type="button" class="inline-flex items-center gap-1 h-6 px-2 rounded border border-line-1 text-fg-3 hover:text-fg-1 cursor-pointer svelte-gt9p7f" title="Discard graph query and show the original collection result"><!> reset</button>'),Qm=he('<span class="text-primary-text svelte-gt9p7f"> </span>'),ev=he('<span class="text-warn svelte-gt9p7f" title="More nodes match — raise the limit or narrow the filter to see them"> </span>'),tv=he('<span class="text-fg-2 svelte-gt9p7f"> </span>'),rv=he('<div class="mt-1.5 text-warn svelte-gt9p7f"> </div>'),nv=he('<div class="border-b border-line-1 px-3 py-2 bg-bg-1/20 text-[11px] font-mono svelte-gt9p7f"><div class="flex items-center gap-2 mb-1.5 text-fg-3 svelte-gt9p7f"><span class="svelte-gt9p7f">quick:</span> <button type="button" class="px-1.5 py-0.5 rounded border border-line-1 hover:border-line-2 hover:text-fg-1 cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed svelte-gt9p7f">neighborhood of selected</button> <button type="button" class="px-1.5 py-0.5 rounded border border-line-1 hover:border-line-2 hover:text-fg-1 cursor-pointer svelte-gt9p7f">top centrality</button> <button type="button" class="inline-flex items-center gap-1 px-1.5 py-0.5 rounded border border-line-1 hover:border-line-2 hover:text-fg-1 cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed svelte-gt9p7f" title="Run shortest path in reddb"><!> shortest path</button></div> <div class="mb-1.5 grid grid-cols-[1fr_1fr_auto_auto] gap-2 svelte-gt9p7f"><input type="text" placeholder="from label…" class="h-6 rounded border border-line-1 bg-bg-0 px-2 text-[11px] text-fg-1 outline-none placeholder:text-fg-3 focus:border-accent svelte-gt9p7f"/> <input type="text" placeholder="to label…" class="h-6 rounded border border-line-1 bg-bg-0 px-2 text-[11px] text-fg-1 outline-none placeholder:text-fg-3 focus:border-accent svelte-gt9p7f"/> <button type="button" class="rounded border border-line-1 px-1.5 text-fg-3 hover:border-line-2 hover:text-fg-1 disabled:opacity-40 disabled:cursor-not-allowed svelte-gt9p7f">use as from</button> <button type="button" class="rounded border border-line-1 px-1.5 text-fg-3 hover:border-line-2 hover:text-fg-1 disabled:opacity-40 disabled:cursor-not-allowed svelte-gt9p7f">use as to</button></div> <div class="flex items-stretch gap-2 svelte-gt9p7f"><textarea spellcheck="false" rows="3" class="flex-1 bg-bg-0 text-fg-1 border border-line-1 rounded px-2 py-1 text-[12px] font-mono outline-none focus:border-accent placeholder:text-fg-3 resize-none svelte-gt9p7f"></textarea> <div class="flex flex-col gap-1.5 svelte-gt9p7f"><button type="button" class="inline-flex items-center gap-1.5 h-7 px-3 rounded bg-primary text-on-primary cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed hover:bg-primary-active svelte-gt9p7f"><!> run <span class="text-[9px] opacity-70 svelte-gt9p7f">⌘↵</span></button></div></div> <!></div>'),iv=he('<div class="border-b border-line-1 bg-warn/10 px-3 py-2 text-[11px] font-mono text-warn flex items-start gap-2 svelte-gt9p7f"><!> <div class="svelte-gt9p7f"><div class="svelte-gt9p7f">WebGL renderer unavailable. Switch to SVG or Table.</div> <div class="mt-0.5 break-words text-fg-3 svelte-gt9p7f"> </div></div></div>'),ov=At('<rect rx="6" stroke-width="1.5" class="svelte-gt9p7f"></rect>'),sv=At('<line stroke="var(--color-line-3)" stroke-width="1" stroke-dasharray="4 3" opacity="0.7" class="svelte-gt9p7f"></line>'),av=At('<svg class="pointer-events-none absolute inset-0 h-full w-full svelte-gt9p7f" aria-hidden="true"><!><!></svg>'),cv=he('<div class="sigma-canvas absolute inset-0 h-full w-full bg-bg-0 svelte-gt9p7f" role="application" tabindex="0"></div> <!>',1),lv=At('<rect rx="1.5" stroke-width="0.18" vector-effect="non-scaling-stroke" class="svelte-gt9p7f"></rect>'),uv=At('<line stroke="currentColor" stroke-width="0.12" stroke-dasharray="0.8 0.6" opacity="0.6" class="text-line-3 svelte-gt9p7f" vector-effect="non-scaling-stroke"></line>'),dv=At('<g class="pointer-events-none svelte-gt9p7f"><!><!></g>'),fv=At('<polyline fill="none" stroke-linejoin="round" class="text-line-3 cursor-pointer hover:text-primary-text svelte-gt9p7f" vector-effect="non-scaling-stroke" role="button" tabindex="0"><title class="svelte-gt9p7f"> </title></polyline>'),hv=At('<line class="text-line-3 cursor-pointer hover:text-primary-text svelte-gt9p7f" vector-effect="non-scaling-stroke" role="button" tabindex="0"><title class="svelte-gt9p7f"> </title></line>'),pv=At('<text fill="#f6d36b" opacity="0.96" font-size="1" font-weight="700" font-family="JetBrains Mono Variable, monospace" paint-order="stroke" stroke="#020617" stroke-width="0.38" class="pointer-events-none select-none svelte-gt9p7f"> </text>'),gv=At("<!><!>",1),mv=At('<circle fill="none" stroke="var(--color-warn)" vector-effect="non-scaling-stroke" class="pointer-events-none svelte-gt9p7f"></circle>'),vv=At('<text font-family="JetBrains Mono Variable, monospace" paint-order="stroke" stroke="#020617" class="pointer-events-none select-none svelte-gt9p7f"> </text>'),yv=At('<!><circle vector-effect="non-scaling-stroke" role="button" tabindex="0"><title class="svelte-gt9p7f"> </title></circle><!>',1),bv=he('<div class="absolute inset-0 overflow-hidden bg-bg-0 svelte-gt9p7f"><svg class="h-full w-full svelte-gt9p7f" viewBox="0 0 100 100" preserveAspectRatio="xMidYMid meet" role="button" tabindex="0"><rect x="0" y="0" width="100" height="100" fill="transparent" class="svelte-gt9p7f"></rect><g class="svelte-gt9p7f"><!><g class="svelte-gt9p7f"></g><g class="svelte-gt9p7f"></g></g></svg></div>'),wv=he('<span class="ml-2 text-warn svelte-gt9p7f">orphan</span>'),_v=he('<tr><td class="px-2 py-1 text-fg-3 svelte-gt9p7f">node</td><td class="px-2 py-1 text-primary-text font-semibold svelte-gt9p7f"> </td><td class="px-2 py-1 text-fg-0 svelte-gt9p7f"> </td><td class="px-2 py-1 text-fg-2 svelte-gt9p7f"> <!></td></tr>'),xv=he('<tr class="border-b border-line-1/60 hover:bg-bg-1/40 cursor-pointer svelte-gt9p7f"><td class="px-2 py-1 text-fg-3 svelte-gt9p7f">edge</td><td class="px-2 py-1 text-fg-2 svelte-gt9p7f"> </td><td class="px-2 py-1 text-fg-0 svelte-gt9p7f"> </td><td class="px-2 py-1 text-fg-2 svelte-gt9p7f"> </td></tr>'),kv=he('<div class="absolute inset-0 overflow-auto svelte-gt9p7f"><table class="w-full border-collapse text-[12px] font-mono svelte-gt9p7f"><thead class="sticky top-0 bg-bg-1 z-10 svelte-gt9p7f"><tr class="border-b border-line-1 text-fg-3 svelte-gt9p7f"><th class="px-2 py-1.5 text-left font-normal whitespace-nowrap svelte-gt9p7f">type</th><th class="px-2 py-1.5 text-left font-normal whitespace-nowrap svelte-gt9p7f">id / rid</th><th class="px-2 py-1.5 text-left font-normal whitespace-nowrap svelte-gt9p7f">label</th><th class="px-2 py-1.5 text-left font-normal whitespace-nowrap svelte-gt9p7f">node_type / endpoints</th></tr></thead><tbody class="svelte-gt9p7f"><!><!></tbody></table></div>'),Ev=he('<span class="inline-flex shrink-0 items-center gap-1 rounded border border-warn/40 bg-warn/10 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wider text-warn svelte-gt9p7f"><!> orphan</span>'),Sv=he(`<button type="button" class="mt-2 inline-flex items-center gap-1.5 rounded border border-line-2 bg-bg-0 px-2 py-1 text-[11px] text-fg-2 hover:border-accent hover:text-fg-0 cursor-pointer svelte-gt9p7f" title="Fold this node's community into a single supernode"><!> </button>`),Cv=he('<span class="max-w-full truncate rounded border border-line-1 bg-bg-0 px-1.5 py-0.5 text-[11px] text-fg-1 svelte-gt9p7f"> </span>'),Av=he('<div class="flex flex-wrap gap-1 svelte-gt9p7f"></div>'),$v=he('<div class="text-fg-3 svelte-gt9p7f">No exports recorded.</div>'),Dv=he('<button type="button" class="grid w-full grid-cols-[82px_1fr] gap-2 rounded border border-line-1 bg-bg-0 px-2 py-1.5 text-left hover:border-line-2 hover:bg-bg-2 svelte-gt9p7f"><span class="text-[10px] uppercase tracking-wider text-fg-3 svelte-gt9p7f"> </span> <span class="min-w-0 svelte-gt9p7f"><span class="block truncate text-fg-0 svelte-gt9p7f"> </span> <span class="block truncate text-[10px] text-fg-3 svelte-gt9p7f"> </span></span></button>'),Iv=he('<div class="space-y-1 svelte-gt9p7f"></div>'),Lv=he('<div class="text-fg-3 svelte-gt9p7f">No inbound uses.</div>'),Tv=he('<button type="button" class="w-full rounded border border-line-1 bg-bg-0 px-2 py-1 text-left hover:border-line-2 hover:bg-bg-2 svelte-gt9p7f"><span class="block truncate text-[10px] text-fg-3 svelte-gt9p7f"> </span> <span class="block truncate text-fg-1 svelte-gt9p7f"> </span></button>'),Gv=he('<div class="rounded border border-line-1 px-2 py-1 text-fg-3 svelte-gt9p7f">none</div>'),Rv=he('<button type="button" class="w-full rounded border border-line-1 bg-bg-0 px-2 py-1 text-left hover:border-line-2 hover:bg-bg-2 svelte-gt9p7f"><span class="block truncate text-[10px] text-fg-3 svelte-gt9p7f"> </span> <span class="block truncate text-fg-1 svelte-gt9p7f"> </span></button>'),Ov=he('<div class="rounded border border-line-1 px-2 py-1 text-fg-3 svelte-gt9p7f">none</div>'),zv=he('<div class="mb-3 svelte-gt9p7f"><div class="flex items-start gap-2 svelte-gt9p7f"><div class="min-w-0 flex-1 svelte-gt9p7f"><div class="text-fg-3 text-[10px] uppercase tracking-wider svelte-gt9p7f">label</div> <div class="break-words text-[13px] font-semibold text-fg-0 svelte-gt9p7f"> </div></div> <!></div> <div class="mt-1 break-all text-primary-text svelte-gt9p7f"> </div> <!></div> <div class="mb-3 border-t border-line-1 pt-3 svelte-gt9p7f"><div class="mb-1 text-fg-3 text-[10px] uppercase tracking-wider svelte-gt9p7f">description</div> <div class="whitespace-pre-wrap break-words text-fg-1 svelte-gt9p7f"> </div></div> <div class="mb-3 border-t border-line-1 pt-3 svelte-gt9p7f"><div class="mb-1.5 flex items-center justify-between gap-2 svelte-gt9p7f"><div class="text-fg-3 text-[10px] uppercase tracking-wider svelte-gt9p7f">exports</div> <span class="text-[10px] text-fg-3 svelte-gt9p7f"> </span></div> <!></div> <div class="mb-3 border-t border-line-1 pt-3 svelte-gt9p7f"><div class="mb-1.5 flex items-center justify-between gap-2 svelte-gt9p7f"><div class="text-fg-3 text-[10px] uppercase tracking-wider svelte-gt9p7f">where used</div> <span class="text-[10px] text-fg-3 svelte-gt9p7f"> </span></div> <!></div> <div class="mb-3 border-t border-line-1 pt-3 svelte-gt9p7f"><div class="mb-1.5 grid grid-cols-2 gap-2 svelte-gt9p7f"><div class="svelte-gt9p7f"><div class="text-fg-3 text-[10px] uppercase tracking-wider svelte-gt9p7f">parents</div> <div class="text-[10px] text-fg-3 svelte-gt9p7f">incoming direction</div></div> <div class="svelte-gt9p7f"><div class="text-fg-3 text-[10px] uppercase tracking-wider svelte-gt9p7f">children</div> <div class="text-[10px] text-fg-3 svelte-gt9p7f">outgoing direction</div></div></div> <div class="grid grid-cols-2 gap-2 svelte-gt9p7f"><div class="space-y-1 svelte-gt9p7f"><!></div> <div class="space-y-1 svelte-gt9p7f"><!></div></div></div>',1),Mv=he('<code class="svelte-gt9p7f"> </code>'),Nv=he('<code class="svelte-gt9p7f"> </code>'),Pv=he('<div class="mb-2 svelte-gt9p7f"><div class="text-fg-3 text-[10px] uppercase tracking-wider svelte-gt9p7f">label</div> <div class="text-fg-0 font-semibold svelte-gt9p7f"> </div></div> <div class="mb-2 grid grid-cols-[60px_1fr] gap-x-2 gap-y-1 svelte-gt9p7f"><div class="text-fg-3 text-[10px] uppercase tracking-wider svelte-gt9p7f">from</div> <div class="text-fg-1 svelte-gt9p7f"><!></div> <div class="text-fg-3 text-[10px] uppercase tracking-wider svelte-gt9p7f">to</div> <div class="text-fg-1 svelte-gt9p7f"><!></div></div>',1),Uv=he('<pre class="whitespace-pre-wrap text-[11px] svelte-gt9p7f"> </pre>'),Wv=he('<dt class="text-fg-3 truncate svelte-gt9p7f"> </dt> <dd class="text-fg-1 break-words svelte-gt9p7f"><!></dd>',1),jv=he('<aside class="absolute top-0 right-0 bottom-0 w-[340px] bg-bg-1 border-l border-line-2 shadow-2xl flex flex-col z-20 svelte-gt9p7f"><header class="flex items-center gap-2 px-3 py-2 border-b border-line-1 text-[11px] font-mono svelte-gt9p7f"><!> <span class="type-label svelte-gt9p7f"> </span> <span class="ml-auto svelte-gt9p7f"></span> <button type="button" aria-label="Close panel" class="text-fg-3 hover:text-fg-1 cursor-pointer svelte-gt9p7f"><!></button></header> <div class="flex-1 overflow-auto p-3 text-[12px] font-mono svelte-gt9p7f"><!> <div class="mt-3 mb-1 text-fg-3 text-[10px] uppercase tracking-wider svelte-gt9p7f">properties</div> <dl class="grid grid-cols-[110px_1fr] gap-x-2 gap-y-1 svelte-gt9p7f"></dl></div></aside>'),Bv=he('<button type="button"><span class="svelte-gt9p7f">●</span> <span class="svelte-gt9p7f"> </span> <span class="text-fg-3 svelte-gt9p7f"> </span></button>'),Fv=he('<span class="text-fg-3 svelte-gt9p7f">types:</span> <!>',1),Vv=he('<span class="svelte-gt9p7f"><span class="text-fg-2 svelte-gt9p7f"> </span> <span class="text-fg-3 svelte-gt9p7f">·</span> </span>'),Kv=he('<div class="border-b border-line-1 px-3 py-1.5 flex items-center gap-2 text-[11px] font-mono bg-bg-1/40 svelte-gt9p7f"><div class="inline-flex border border-line-2 rounded overflow-hidden svelte-gt9p7f"><a><!> Canvas</a> <a><!> SVG</a> <a><!> Table</a></div> <!> <!> <!> <button type="button" title="Run a graph query (GRAPH NEIGHBORHOOD / SHORTEST_PATH / MATCH …)"><!> query</button> <!> <div class="ml-auto flex items-center gap-3 text-fg-3 svelte-gt9p7f"><span class="svelte-gt9p7f"> </span> <!> <!> <!></div></div> <!> <!> <div class="flex-1 min-h-0 relative svelte-gt9p7f"><!> <!></div> <div class="border-t border-line-1 px-3 py-1.5 text-[10px] font-mono text-fg-3 flex items-center gap-2 flex-wrap svelte-gt9p7f"><!> <span class="ml-auto svelte-gt9p7f"></span> <!></div>',1),Hv=he('<div class="flex h-full flex-col text-fg-1 svelte-gt9p7f"><!></div>');function dy(r,e){ii(e,!0);let t=Ee(null);const n=Q(()=>u(t)??e.result),i=Q(()=>im(u(n))),o=Q(()=>em(u(i).nodes,u(i).edges)),s=Q(()=>rm(u(i).nodes,u(o))),a=Q(()=>new Set(u(i).nodes.filter(k=>Bc(k,u(o))).map(k=>k.id)));let c=Ee("canvas"),l=Ee(25e3),d=Ee(""),f=Ee(null),h=Ee(null),g=Ee(null),y=Ee(350),C=Ee(1),b=Ee(!1),m=Ee(!1),A=Ee(Kt(new Set));const v=Q(()=>u(f)?Qg(u(f),u(i).nodes,u(i).edges,u(o)):null);Zt(()=>{e.subpage==="svg"&&u(c)!=="svg"?N(c,"svg"):e.subpage==="graph"&&u(c)!=="canvas"&&N(c,"canvas")});let p=Ee(null),E=Ee(null),S=Ee(!1),$=Ee(""),x=Ee(!1),D=Ee(null),I=Ee(""),j=Ee("");async function O(k){const U=Qn.client;if(!(!U||!k.trim())){N(x,!0),N(D,null);try{const F=await lr.track(`${e.collection??"graph"} · query (${k.slice(0,40).replace(/\s+/g," ")}…)`,()=>U.query(k));if(!F.ok){N(D,F.error??"query failed",!0);return}N(t,F,!0),N(f,null),N(h,null),tt()}catch(F){N(D,F.message,!0)}finally{N(x,!1)}}}function w(){N(t,null),N($,""),N(D,null),N(f,null),N(h,null),tt()}function ge(){u(f)&&(N($,`GRAPH NEIGHBORHOOD '${u(f).label}' DEPTH 1`),N(S,!0),O(u($)))}function ce(){N($,"GRAPH CENTRALITY LIMIT 50"),N(S,!0),O(u($))}function L(k){u(f)&&(k==="from"?N(I,u(f).label,!0):N(j,u(f).label,!0),N(S,!0))}function _(){!u(I).trim()||!u(j).trim()||(N($,`GRAPH SHORTEST_PATH '${u(I).trim()}' TO '${u(j).trim()}'`),N(S,!0),O(u($)))}const K=Q(()=>{const k=new Map;for(const U of u(i).nodes){const F=String(U.data.node_type??"node");k.set(F,(k.get(F)??0)+1)}return[...k.entries()].sort((U,F)=>F[1]-U[1])});let ee=Ee(Kt(new Set));const M=Q(()=>{const k=u(d).trim().toLowerCase();return u(i).nodes.filter(U=>{const F=String(U.data.node_type??"node");return u(ee).has(F)?!1:k?U.label.toLowerCase().includes(k)||U.id.toLowerCase().includes(k):!0}).sort((U,F)=>tm(U,F,u(o)))}),Re=Q(()=>Math.min(u(M).length,u(l))),ae=Q(()=>u(M).slice(0,Math.min(u(Re),u(y)))),W=Q(()=>new Set(u(ae).map(k=>k.id))),Se=Q(()=>u(i).edges.filter(k=>u(W).has(k.source)&&u(W).has(k.target))),Ce=Q(()=>u(ae).length<u(Re)),be=Q(()=>u(M).length>u(l));Zt(()=>{const k=u(Re),U=u(c)==="canvas"?1e3:350,F=Math.min(k,U);if(N(y,F,!0),F>=k)return;let Oe=!1,Ke=0,vt=F;const rt=()=>{Oe||(vt=Math.min(k,vt+U),N(y,vt,!0),vt<k&&(Ke=requestAnimationFrame(rt)))};return Ke=requestAnimationFrame(rt),()=>{Oe=!0,cancelAnimationFrame(Ke)}});function Ye(k){const U=new Set(u(ee));U.has(k)?U.delete(k):U.add(k),N(ee,U,!0)}const ot=gm,Ae=mm;let ve=Ee(void 0),X=null,me=null,et=Ee(1),J=Ee(0),ne=0,G=Ee(0),It=Ee(Kt([])),Rt=Ee(Kt([]));function Ot(k,U){const F=X;return F?F.graphToViewport({x:k,y:-U}):null}function Ht(){if(!u(b)||!X||u(c)!=="canvas"){u(It).length&&N(It,[],!0),u(Rt).length&&N(Rt,[],!0);return}const k=[];for(const F of u(Cn)){const Oe=Ot(F.minX,F.minY),Ke=Ot(F.maxX,F.maxY);!Oe||!Ke||k.push({...F,vx:Math.min(Oe.x,Ke.x),vy:Math.min(Oe.y,Ke.y),vw:Math.abs(Ke.x-Oe.x),vh:Math.abs(Ke.y-Oe.y)})}const U=[];for(const F of u(An)){const Oe=Ot(F.x1,F.y1),Ke=Ot(F.x2,F.y2);!Oe||!Ke||U.push({id:F.id,vx1:Oe.x,vy1:Oe.y,vx2:Ke.x,vy2:Ke.y})}N(It,k,!0),N(Rt,U,!0)}function $t(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}Ku(()=>{cancelAnimationFrame(ne),X&&(X.kill(),X=null)}),Hu(()=>{const k=new MutationObserver(()=>{N(G,u(G)+1)});return k.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","data-color-scheme"]}),()=>k.disconnect()});function xt(){N(f,null),N(h,null)}function tt(){N(p,null),N(E,null)}function Pt(k){return u(i).nodes.find(U=>U.id===k)??null}function nr(k){const U=Pt(k.nodeId);U&&(ir(U),mr(U))}function mr(k){N(h,null),N(f,k,!0)}function ir(k){N(E,k.id,!0),N(p,k.id,!0)}function Er(k){if(u(E)){tt(),xt();return}ir(k),mr(k)}function Lt(k){N(f,null),N(h,k,!0)}function Sr(k){return["id","rid","label","name","title","description","summary","content","exports","orphan","is_orphan","isOrphan","dead_code","deadCode"].includes(k)}function or(k,U){k.key!=="Enter"&&k.key!==" "||(k.preventDefault(),U())}function Uo(k){return Math.max(.5,Math.min(8,k))}const ll=Q(()=>u(c)==="canvas"?Math.round(100/(u(et)||1)):Math.round(u(C)*100));function Wo(k){if(u(c)==="canvas"){const F=X==null?void 0:X.getCamera();if(!F)return;k==="in"?F.animatedZoom(1.4):F.animatedUnzoom(1.4);return}const U=k==="in"?1.25:.8;N(C,Uo(u(C)*U),!0)}function ul(){if(u(c)==="canvas"){X==null||X.getCamera().animatedReset();return}N(C,1)}function dl(k){k.preventDefault();const U=k.deltaY<0?1.25:.8;N(C,Uo(u(C)*U),!0)}const jo=Q(()=>{const k=new Map;for(const U of u(i).edges)U.label&&k.set(U.label,(k.get(U.label)??0)+1);return[...k.entries()].sort((U,F)=>F[1]-U[1]).slice(0,4)}),Cr=Q(()=>am(u(ae),u(Se))),fl=Q(()=>(u(G),typeof document>"u"?!0:document.documentElement.dataset.colorScheme!=="light")),Cn=Q(()=>u(b)?ym(u(ae),u(Cr),{dark:u(fl)}):[]),An=Q(()=>u(b)?bm(u(Se),u(Cr),u(Cn)):[]),hl=Q(()=>new Set(u(An).map(k=>k.id))),pl=Q(()=>u(m)&&u(Se).length>io);function gl(k){return k>800?{cycles:4,iterations:45}:k>300?{cycles:5,iterations:55}:{}}const ui=Q(()=>{if(!u(m)||u(c)==="table"||u(Se).length===0||u(Se).length>io)return null;const k=u(ae).map(U=>{const F=u(Cr).get(U.id);return{id:U.id,x:(F==null?void 0:F.x)??50,y:(F==null?void 0:F.y)??50}});return Tm(k,u(Se).map(U=>({id:U.id,source:U.source,target:U.target})),gl(u(Se).length))}),di=Q(()=>{if(!u(ui))return null;const k=new Map;for(const[U,F]of u(ui))k.set(U,-Rm(F));return k}),$n=Q(()=>zm(u(ae),u(Se),u(Cr),u(A))),fi=Q(()=>u($n).nodes),Dn=Q(()=>u($n).edges),hi=Q(()=>u($n).layout),pi=Q(()=>{const k=Yc(u(ae),u(Cr));return new Map([...k].map(([U,F])=>[U,F.length]))}),gi=Q(()=>[...u(pi)].filter(([,k])=>k>=2).map(([k])=>k)),Ar=Q(()=>u(A).size>0);function ml(k){const U=new Set(u(A));U.add(k),N(A,U,!0),tt()}function vl(k){const U=new Set(u(A));U.delete(k),N(A,U,!0),tt()}function yl(){N(A,u(Ar)?new Set:new Set(u(gi)),!0),tt(),xt()}const Vr=Q(()=>{var k;return u(f)?((k=u(Cr).get(u(f).id))==null?void 0:k.community)??null:null});Zt(()=>{u(f)&&u($n).collapsedMembers.has(u(f).id)&&xt()});const Bo=Q(()=>u(fi).map(k=>{const U=String(k.data.node_type??"node"),F=u(s).get(k.id)??1,Oe=u(hi).get(k.id),Ke=k.data.__supernode===!0,vt=typeof k.data.__memberCount=="number"?k.data.__memberCount:0,rt=Oe?No(Oe.community):ei(U);return{...k,x:(Oe==null?void 0:Oe.x)??50,y:(Oe==null?void 0:Oe.y)??50,r:Ke?Kc(vt):Fc(U,F),color:rt}})),mi=Q(()=>new Map(u(Bo).map(k=>[k.id,k]))),vi=Q(()=>{var U;const k=[];for(const F of u(Dn)){const Oe=u(mi).get(F.source),Ke=u(mi).get(F.target);if(!Oe||!Ke)continue;const vt=(U=u(ui))==null?void 0:U.get(F.id);let rt,jt=(Oe.x+Ke.x)/2,Ut=(Oe.y+Ke.y)/2;if(vt&&vt.length>2){rt=vt.map(Hr=>`${Hr.x},${Hr.y}`).join(" ");const Ln=vt[Math.floor(vt.length/2)];jt=Ln.x,Ut=Ln.y}k.push({...F,x1:Oe.x,y1:Oe.y,x2:Ke.x,y2:Ke.y,points:rt,mx:jt,my:Ut})}return k}),Fe=Q(()=>u(E)??u(p)),In=Q(()=>{const k=new Set;if(!u(Fe))return k;for(const U of u(vi))(U.source===u(Fe)||U.target===u(Fe))&&k.add(U.id);return k}),sr=Q(()=>{const k=new Set;if(!u(Fe))return k;k.add(u(Fe));for(const U of u(vi))U.source===u(Fe)&&k.add(U.target),U.target===u(Fe)&&k.add(U.source);return k});Zt(()=>{const k=u(Fe);if(!k){N(J,0);return}if(!u(mi).has(k)){tt();return}bl()});function bl(){if(cancelAnimationFrame(ne),$t()){N(J,0);return}const k=performance.now();N(J,1);const U=()=>{const F=Math.max(0,1-(performance.now()-k)/170);N(J,F,!0),F>0&&(ne=requestAnimationFrame(U))};ne=requestAnimationFrame(U)}const wl=Q(()=>`translate(50 50) scale(${u(C)}) translate(-50 -50)`);function Kr(k,U){return getComputedStyle(document.documentElement).getPropertyValue(k).trim()||U}function Fo(){const k=document.documentElement.dataset.colorScheme!=="light";return{background:Kr("--color-bg-0",k?"#050607":"#ffffff"),edge:Kr("--color-line-3",k?"#3a424d":"#c9cbd1"),focusEdge:ot,focusNodeStroke:Ae,selectedNodeStroke:k?"#0a0a0b":"#18181b",nodeStroke:k?"#ffffff":"#27272a",warn:Kr("--color-warn",k?"#fbbf24":"#b45309")}}function Vo(){var k;return{focusId:u(Fe),focus:{nodes:u(sr),edges:u(In)},selectedNodeId:((k=u(f))==null?void 0:k.id)??null,pulse:u(J),colors:Fo(),groupInBox:u(b),bundle:u(m)&&u(di)!==null}}function Ko(){return vm({nodes:u(fi),edges:u(Dn),layout:u(hi),sizeScales:u(s),orphanIds:u(a),dark:document.documentElement.dataset.colorScheme!=="light",edgeColor:Fo().edge,bundledCurvatures:u(di)??void 0})}function _l(k){return u(Dn).find(U=>U.id===k)??null}function yi(k){if(qc(k)){const F=Om(k);F!==null&&vl(F);return}const U=Pt(k);U&&Er(U)}function xl(k){k.on("clickNode",({node:F})=>{yi(F)}),k.on("enterNode",({node:F})=>{u(E)||N(p,F,!0),u(ve)&&(u(ve).style.cursor="pointer")}),k.on("leaveNode",()=>{u(E)||N(p,null),u(ve)&&(u(ve).style.cursor="")}),k.on("clickEdge",({edge:F})=>{const Oe=_l(F);Oe&&(tt(),Lt(Oe))}),k.on("clickStage",()=>{tt(),xt()});const U=k.getCamera();U.on("updated",()=>{N(et,U.ratio,!0)}),k.on("afterRender",()=>Ht())}Zt(()=>{if(u(c)!=="canvas")return;const k=u(ve);if(!k)return;let U=!1,F=null;return(async()=>{try{if(!me){const[rt,jt,Ut]=await Promise.all([hr(()=>import("./DD7_KB97.js"),__vite__mapDeps([3,4]),import.meta.url),hr(()=>import("./CXNPJgv1.js"),__vite__mapDeps([5,4]),import.meta.url),hr(()=>import("./CDKIdLnm.js"),__vite__mapDeps([6,4]),import.meta.url)]);me={Sigma:rt.default,NodeBorderProgram:jt.NodeBorderProgram,EdgeCurveProgram:Ut.default}}if(U||!u(ve))return;const{Sigma:Oe,NodeBorderProgram:Ke,EdgeCurveProgram:vt}=me;F=new Oe(Ko(),k,{allowInvalidContainer:!0,defaultNodeType:"border",nodeProgramClasses:{border:Ke},edgeProgramClasses:{curved:vt},defaultEdgeType:"line",renderEdgeLabels:!0,labelFont:'"JetBrains Mono Variable", monospace',edgeLabelFont:'"JetBrains Mono Variable", monospace',labelSize:12,edgeLabelSize:10,labelWeight:"700",labelColor:{color:Kr("--color-fg-0","#ffffff")},edgeLabelColor:{color:"#f6d36b"},labelRenderedSizeThreshold:1/0,zIndex:!0,nodeReducer:(rt,jt)=>km(rt,jt,Vo()),edgeReducer:(rt,jt)=>Em(rt,jt,Vo())}),xl(F),X=F,N(et,F.getCamera().ratio,!0),N(g,null)}catch(Oe){N(g,Oe.message,!0)}})(),()=>{U=!0,F&&F.kill(),X===F&&(X=null)}}),Zt(()=>{u(fi),u(Dn),u(hi),u(s),u(a),u(G),u(di),u(m);const k=X;!k||u(c)!=="canvas"||(k.setSetting("labelColor",{color:Kr("--color-fg-0","#ffffff")}),k.setGraph(Ko()),k.refresh())}),Zt(()=>{u(Fe),u(sr),u(In),u(f),u(J);const k=X;!k||u(c)!=="canvas"||k.refresh({skipIndexation:!0})}),Zt(()=>{u(b),u(Cn),u(An);const k=X;!k||u(c)!=="canvas"||(k.refresh({skipIndexation:!0}),Ht())});function kl(k){u(E)||N(p,k.id,!0)}function El(k){!u(E)&&u(p)===k.id&&N(p,null)}function bi(k){return u(Fe)?u(Fe)===k.id?k.r*2.24:u(sr).has(k.id)?k.r*1.6:k.r*.92:k.r*1.14}function Sl(k){return u(Fe)?u(sr).has(k.id)?1:.12:1}function Cl(k){return k.data.__supernode===!0?!0:u(Fe)?u(Fe)===k.id?!0:u(sr).size<=36&&u(sr).has(k.id):!1}function Al(k){return!!(u(Fe)&&u(In).has(k.id)&&k.label)}var wi=Hv(),$l=R(wi);{var Dl=k=>{var U=Vm();V(k,U)},Il=k=>{var U=Kv(),F=lt(U),Oe=R(F),Ke=R(Oe),vt=R(Ke);Ws(vt,{class:"size-3"}),Bt(),T(Ke);var rt=P(Ke,2),jt=R(rt);Ws(jt,{class:"size-3"}),Bt(),T(rt);var Ut=P(rt,2),Ln=R(Ut);Mm(Ln,{class:"size-3"}),Bt(),T(Ut),T(Oe);var Hr=P(Oe,2);{var Ll=te=>{var ie=Hm(),oe=lt(ie),ze=R(oe);kp(ze,{class:"size-3 text-fg-3"});var $e=P(ze,2);Ii($e);var Ue=P($e,2);{var De=He=>{var Qe=Km(),Tt=R(Qe);ks(Tt,{class:"size-3"}),T(Qe),Ne("click",Qe,()=>N(d,"")),V(He,Qe)};ke(Ue,He=>{u(d)&&He(De)})}T(oe);var Pe=P(oe,2),we=R(Pe);Pm(we,{class:"size-3"});var z=P(we,4),se=R(z);se.value=se.__value=500;var re=P(se);re.value=re.__value=1e3;var Ie=P(re);Ie.value=Ie.__value=2e3;var le=P(Ie);le.value=le.__value=5e3;var ye=P(le);ye.value=ye.__value=1e4;var de=P(ye);de.value=de.__value=25e3;var We=P(de);We.value=We.__value=5e4,T(z);var Xe;Ju(z),T(Pe),pe(()=>{Xe!==(Xe=u(l))&&(z.value=(z.__value=u(l))??"",Zu(z,u(l)))}),Gn($e,()=>u(d),He=>N(d,He)),Ne("change",z,He=>N(l,Number(He.currentTarget.value),!0)),V(te,ie)};ke(Hr,te=>{u(c)!=="table"&&te(Ll)})}var Ho=P(Hr,2);{var Tl=te=>{var ie=qm(),oe=R(ie),ze=R(oe);Bm(ze,{class:"size-3.5"}),T(oe);var $e=P(oe,2),Ue=R($e);T($e);var De=P($e,2),Pe=R(De);jm(Pe,{class:"size-3.5"}),T(De),T(ie),pe(()=>{oe.disabled=u(c)==="svg"&&u(C)<=.5,fe(Ue,`${u(ll)??""}%`),De.disabled=u(c)==="svg"&&u(C)>=8}),Ne("click",oe,()=>Wo("out")),Ne("click",$e,ul),Ne("click",De,()=>Wo("in")),V(te,ie)};ke(Ho,te=>{u(c)!=="table"&&te(Tl)})}var qo=P(Ho,2);{var Gl=te=>{var ie=Jm(),oe=lt(ie),ze=R(oe);Ea(ze,{class:"size-3"}),Bt(),T(oe);var $e=P(oe,2),Ue=R($e);Fm(Ue,{class:"size-3"}),Bt(),T($e);var De=P($e,2);{var Pe=se=>{var re=Ym(),Ie=R(re);T(re),pe((le,ye)=>{H(re,"title",le),fe(Ie,`bundling skipped (${ye??""} edges)`)},[()=>`Bundling is skipped above ${io.toLocaleString()} drawn edges — narrow the filter or lower the limit`,()=>u(Se).length.toLocaleString()]),V(se,re)};ke(De,se=>{u(pl)&&se(Pe)})}var we=P(De,2);{var z=se=>{var re=Xm(),Ie=R(re);{var le=We=>{Ea(We,{class:"size-3"})},ye=We=>{Sa(We,{class:"size-3"})};ke(Ie,We=>{u(Ar)?We(le):We(ye,-1)})}var de=P(Ie);T(re),pe(We=>{St(re,1,We,"svelte-gt9p7f"),H(re,"aria-pressed",u(Ar)),H(re,"title",u(Ar)?"Expand all collapsed clusters back to their members":"Collapse each community into a single supernode"),fe(de,` ${u(Ar)?`expand (${u(A).size})`:`collapse ${u(gi).length} clusters`}`)},[()=>Dt(["inline-flex items-center gap-1 h-6 px-2 rounded border cursor-pointer transition-colors",u(Ar)?"border-accent/40 bg-accent/10 text-primary-text":"border-line-1 text-fg-3 hover:text-fg-1 hover:border-line-2"].join(" "))]),Ne("click",re,yl),V(se,re)};ke(we,se=>{u(gi).length>0&&se(z)})}pe((se,re)=>{St(oe,1,se,"svelte-gt9p7f"),H(oe,"aria-pressed",u(b)),St($e,1,re,"svelte-gt9p7f"),H($e,"aria-pressed",u(m))},[()=>Dt(["inline-flex items-center gap-1 h-6 px-2 rounded border cursor-pointer transition-colors",u(b)?"border-accent/40 bg-accent/10 text-primary-text":"border-line-1 text-fg-3 hover:text-fg-1 hover:border-line-2"].join(" ")),()=>Dt(["inline-flex items-center gap-1 h-6 px-2 rounded border cursor-pointer transition-colors",u(m)?"border-accent/40 bg-accent/10 text-primary-text":"border-line-1 text-fg-3 hover:text-fg-1 hover:border-line-2"].join(" "))]),Ne("click",oe,()=>N(b,!u(b))),Ne("click",$e,()=>N(m,!u(m))),V(te,ie)};ke(qo,te=>{u(c)!=="table"&&te(Gl)})}var $r=P(qo,2),Rl=R($r);Um(Rl,{class:"size-3"}),Bt(),T($r);var Yo=P($r,2);{var Ol=te=>{var ie=Zm(),oe=R(ie);Sp(oe,{class:"size-3"}),Bt(),T(ie),Ne("click",ie,w),V(te,ie)};ke(Yo,te=>{u(t)&&te(Ol)})}var Xo=P(Yo,2),_i=R(Xo),zl=R(_i);T(_i);var Jo=P(_i,2);{var Ml=te=>{var ie=Qm(),oe=R(ie);T(ie),pe((ze,$e)=>fe(oe,`rendering ${ze??""} / ${$e??""}`),[()=>u(ae).length.toLocaleString(),()=>u(Re).toLocaleString()]),V(te,ie)};ke(Jo,te=>{u(c)!=="table"&&u(Ce)&&te(Ml)})}var Zo=P(Jo,2);{var Nl=te=>{var ie=ev(),oe=R(ie);T(ie),pe(ze=>fe(oe,`drawing ${ze??""}`),[()=>u(ae).length.toLocaleString()]),V(te,ie)};ke(Zo,te=>{u(c)!=="table"&&u(be)&&te(Nl)})}var Pl=P(Zo,2);{var Ul=te=>{var ie=tv(),oe=R(ie,!0);T(ie),pe(()=>fe(oe,e.collection)),V(te,ie)};ke(Pl,te=>{e.collection&&te(Ul)})}T(Xo),T(F);var Qo=P(F,2);{var Wl=te=>{var ie=nv(),oe=R(ie),ze=P(R(oe),2),$e=P(ze,2),Ue=P($e,2),De=R(Ue);Wm(De,{class:"size-3"}),Bt(),T(Ue),T(oe);var Pe=P(oe,2),we=R(Pe);Ii(we);var z=P(we,2);Ii(z);var se=P(z,2),re=P(se,2);T(Pe);var Ie=P(Pe,2),le=R(Ie);Bu(le);var ye=P(le,2),de=R(ye),We=R(de);{var Xe=Be=>{xp(Be,{class:"size-3 animate-spin"})},He=Be=>{Ep(Be,{class:"size-3"})};ke(We,Be=>{u(x)?Be(Xe):Be(He,-1)})}Bt(2),T(de),T(ye),T(Ie);var Qe=P(Ie,2);{var Tt=Be=>{var je=rv(),Le=R(je,!0);T(je),pe(()=>fe(Le,u(D))),V(Be,je)};ke(Qe,Be=>{u(D)&&Be(Tt)})}T(ie),pe((Be,je)=>{ze.disabled=!u(f),H(ze,"title",u(f)?`neighborhood of ${u(f).label}`:"select a node first"),Ue.disabled=Be,se.disabled=!u(f),H(se,"title",u(f)?`Use ${u(f).label} as source`:"select a node first"),re.disabled=!u(f),H(re,"title",u(f)?`Use ${u(f).label} as target`:"select a node first"),H(le,"placeholder",e.collection?`GRAPH NEIGHBORHOOD '<label>' DEPTH 2
|
|
34
34
|
GRAPH SHORTEST_PATH '<from>' TO '<to>'
|
|
35
35
|
MATCH (n)-[r]->(m) RETURN n, r, m LIMIT 100`:"GRAPH NEIGHBORHOOD … / GRAPH SHORTEST_PATH … / MATCH …"),de.disabled=je},[()=>!u(I).trim()||!u(j).trim(),()=>u(x)||!u($).trim()]),Ne("click",ze,ge),Ne("click",$e,ce),Ne("click",Ue,_),Gn(we,()=>u(I),Be=>N(I,Be)),Gn(z,()=>u(j),Be=>N(j,Be)),Ne("click",se,()=>L("from")),Ne("click",re,()=>L("to")),Ne("keydown",le,Be=>{Be.key==="Enter"&&(Be.metaKey||Be.ctrlKey)&&(Be.preventDefault(),O(u($)))}),Gn(le,()=>u($),Be=>N($,Be)),Ne("click",de,()=>O(u($))),V(te,ie)};ke(Qo,te=>{u(S)&&te(Wl)})}var es=P(Qo,2);{var jl=te=>{var ie=iv(),oe=R(ie);js(oe,{class:"mt-0.5 size-3.5 shrink-0"});var ze=P(oe,2),$e=P(R(ze),2),Ue=R($e,!0);T($e),T(ze),T(ie),pe(()=>fe(Ue,u(g))),V(te,ie)};ke(es,te=>{u(g)&&te(jl)})}var xi=P(es,2),ts=R(xi);{var Bl=te=>{var ie=cv(),oe=lt(ie);Vu(oe,Ue=>N(ve,Ue),()=>u(ve));var ze=P(oe,2);{var $e=Ue=>{var De=av(),Pe=R(De);bt(Pe,17,()=>u(It),z=>z.community,(z,se)=>{var re=ov();pe(()=>{H(re,"x",u(se).vx),H(re,"y",u(se).vy),H(re,"width",u(se).vw),H(re,"height",u(se).vh),H(re,"fill",u(se).fill),H(re,"stroke",u(se).stroke)}),V(z,re)});var we=P(Pe);bt(we,17,()=>u(Rt),z=>z.id,(z,se)=>{var re=sv();pe(()=>{H(re,"x1",u(se).vx1),H(re,"y1",u(se).vy1),H(re,"x2",u(se).vx2),H(re,"y2",u(se).vy2)}),V(z,re)}),T(De),V(Ue,De)};ke(ze,Ue=>{u(b)&&(u(It).length>0||u(Rt).length>0)&&Ue($e)})}pe(()=>H(oe,"aria-label",`${u(ae).length} graph nodes and ${u(Se).length} graph edges`)),Ne("keydown",oe,Ue=>{Ue.key==="Escape"&&(tt(),xt())}),V(te,ie)},Fl=te=>{var ie=bv(),oe=R(ie),ze=P(R(oe)),$e=R(ze);{var Ue=we=>{var z=dv(),se=R(z);bt(se,17,()=>u(Cn),Ie=>Ie.community,(Ie,le)=>{var ye=lv();pe(()=>{H(ye,"x",u(le).minX),H(ye,"y",u(le).minY),H(ye,"width",u(le).maxX-u(le).minX),H(ye,"height",u(le).maxY-u(le).minY),H(ye,"fill",u(le).fill),H(ye,"stroke",u(le).stroke)}),V(Ie,ye)});var re=P(se);bt(re,17,()=>u(An),Ie=>Ie.id,(Ie,le)=>{var ye=uv();pe(()=>{H(ye,"x1",u(le).x1),H(ye,"y1",u(le).y1),H(ye,"x2",u(le).x2),H(ye,"y2",u(le).y2)}),V(Ie,ye)}),T(z),V(we,z)};ke($e,we=>{u(b)&&we(Ue)})}var De=P($e);bt(De,21,()=>u(vi),we=>we.id,(we,z)=>{var se=er(),re=lt(se);{var Ie=ye=>{const de=Q(()=>u(In).has(u(z).id));var We=gv(),Xe=lt(We);{var He=Le=>{var _e=fv(),st=R(_e),ht=R(st);T(st),T(_e),pe(()=>{H(_e,"points",u(z).points),H(_e,"stroke",u(Fe)&&u(de)?ot:"currentColor"),H(_e,"stroke-width",u(Fe)?u(de)?"0.27":"0.055":"0.105"),H(_e,"opacity",u(Fe)?u(de)?"0.98":"0.07":"0.4"),H(_e,"aria-label",`${u(z).label??"edge"} from ${u(z).source} to ${u(z).target}`),fe(ht,`${u(z).label??"edge"??""}: ${u(z).source??""} -> ${u(z).target??""}`)}),Ne("click",_e,kt=>{kt.stopPropagation(),tt(),Lt(u(z))}),Ne("keydown",_e,kt=>or(kt,()=>{tt(),Lt(u(z))})),V(Le,_e)},Qe=Le=>{var _e=hv(),st=R(_e),ht=R(st);T(st),T(_e),pe(()=>{H(_e,"x1",u(z).x1),H(_e,"y1",u(z).y1),H(_e,"x2",u(z).x2),H(_e,"y2",u(z).y2),H(_e,"stroke",u(Fe)&&u(de)?ot:"currentColor"),H(_e,"stroke-width",u(Fe)?u(de)?"0.27":"0.055":"0.105"),H(_e,"opacity",u(Fe)?u(de)?"0.98":"0.055":"0.36"),H(_e,"aria-label",`${u(z).label??"edge"} from ${u(z).source} to ${u(z).target}`),fe(ht,`${u(z).label??"edge"??""}: ${u(z).source??""} -> ${u(z).target??""}`)}),Ne("click",_e,kt=>{kt.stopPropagation(),tt(),Lt(u(z))}),Ne("keydown",_e,kt=>or(kt,()=>{tt(),Lt(u(z))})),V(Le,_e)};ke(Xe,Le=>{u(z).points?Le(He):Le(Qe,-1)})}var Tt=P(Xe);{var Be=Le=>{var _e=pv(),st=R(_e,!0);T(_e),pe(ht=>{H(_e,"x",u(z).mx+.45),H(_e,"y",u(z).my-.45),fe(st,ht)},[()=>{var ht;return(ht=u(z).label)==null?void 0:ht.slice(0,28)}]),V(Le,_e)},je=Q(()=>Al(u(z)));ke(Tt,Le=>{u(je)&&Le(Be)})}V(ye,We)},le=Q(()=>!(u(b)&&u(hl).has(u(z).id)));ke(re,ye=>{u(le)&&ye(Ie)})}V(we,se)}),T(De);var Pe=P(De);bt(Pe,21,()=>u(Bo),we=>we.id,(we,z)=>{const se=Q(()=>u(a).has(u(z).id)),re=Q(()=>u(z).data.__supernode===!0);var Ie=yv(),le=lt(Ie);{var ye=je=>{var Le=mv();pe((_e,st)=>{H(Le,"cx",u(z).x),H(Le,"cy",u(z).y),H(Le,"r",_e),H(Le,"stroke-width",u(Fe)===u(z).id?"0.38":"0.24"),H(Le,"opacity",st)},[()=>bi(u(z))+.65,()=>u(Fe)&&!u(sr).has(u(z).id)?"0.16":"0.72"]),V(je,Le)};ke(le,je=>{u(se)&&je(ye)})}var de=P(le);let We;var Xe=R(de),He=R(Xe,!0);T(Xe),T(de);var Qe=P(de);{var Tt=je=>{var Le=vv(),_e=R(Le,!0);T(Le),pe((st,ht)=>{H(Le,"x",st),H(Le,"y",u(z).y+.15),H(Le,"fill",u(Fe)===u(z).id?"#f8fafc":"#cbd5e1"),H(Le,"opacity",u(Fe)===u(z).id?"1":"0.9"),H(Le,"font-size",u(Fe)===u(z).id?"1.35":"1.15"),H(Le,"font-weight",u(Fe)===u(z).id?"700":"600"),H(Le,"stroke-width",u(Fe)===u(z).id?"0.48":"0.38"),fe(_e,ht)},[()=>u(z).x+bi(u(z))+.85,()=>u(z).label.slice(0,36)]),V(je,Le)},Be=Q(()=>Cl(u(z)));ke(Qe,je=>{u(Be)&&je(Tt)})}pe((je,Le,_e)=>{var st;H(de,"cx",u(z).x),H(de,"cy",u(z).y),H(de,"r",je),H(de,"fill",u(z).color),H(de,"opacity",Le),H(de,"stroke",u(Fe)===u(z).id?Ae:u(re)?"#e2e8f0":((st=u(f))==null?void 0:st.id)===u(z).id?"#0a0a0b":u(se)?"var(--color-warn)":"#ffffff"),H(de,"stroke-width",_e),We=St(de,0,"cursor-pointer graph-node svelte-gt9p7f",null,We,{"focus-primary":u(Fe)===u(z).id}),H(de,"aria-label",u(re)?`${u(z).label} — click to expand`:u(z).label),fe(He,u(re)?`${u(z).label} — click to expand`:u(z).label)},[()=>bi(u(z)),()=>Sl(u(z)),()=>{var je;return u(Fe)===u(z).id?"0.55":u(re)?"0.5":u(sr).has(u(z).id)?"0.22":((je=u(f))==null?void 0:je.id)===u(z).id||u(se)?"0.4":"0.14"}]),$i("pointerenter",de,()=>kl(u(z))),$i("pointerleave",de,()=>El(u(z))),Ne("click",de,je=>{je.stopPropagation(),yi(u(z).id)}),Ne("keydown",de,je=>or(je,()=>yi(u(z).id))),V(we,Ie)}),T(Pe),T(ze),T(oe),T(ie),pe(()=>{H(oe,"aria-label",`${u(ae).length} graph nodes and ${u(Se).length} graph edges`),H(ze,"transform",u(wl))}),$i("wheel",oe,dl),Ne("click",oe,()=>{tt(),xt()}),Ne("keydown",oe,we=>{we.key==="Escape"&&(tt(),xt())}),V(te,ie)},Vl=te=>{var ie=kv(),oe=R(ie),ze=P(R(oe)),$e=R(ze);bt($e,17,()=>u(i).nodes,De=>De.id,(De,Pe)=>{const we=Q(()=>u(a).has(u(Pe).id));var z=_v(),se=P(R(z)),re=R(se,!0);T(se);var Ie=P(se),le=R(Ie,!0);T(Ie);var ye=P(Ie),de=R(ye),We=P(de);{var Xe=He=>{var Qe=wv();V(He,Qe)};ke(We,He=>{u(we)&&He(Xe)})}T(ye),T(z),pe((He,Qe)=>{St(z,1,He,"svelte-gt9p7f"),fe(re,u(Pe).id),fe(le,u(Pe).label),fe(de,`${Qe??""} `)},[()=>Dt(["border-b border-line-1/60 hover:bg-bg-1/40 cursor-pointer",u(we)?"bg-warn/10":""].join(" ")),()=>String(u(Pe).data.node_type??"")]),Ne("click",z,()=>{N(h,null),N(f,u(Pe),!0)}),V(De,z)});var Ue=P($e);bt(Ue,17,()=>u(i).edges,De=>De.id,(De,Pe)=>{var we=xv(),z=P(R(we)),se=R(z,!0);T(z);var re=P(z),Ie=R(re,!0);T(re);var le=P(re),ye=R(le);T(le),T(we),pe(()=>{fe(se,u(Pe).id),fe(Ie,u(Pe).label??""),fe(ye,`${u(Pe).source??""} → ${u(Pe).target??""}`)}),Ne("click",we,()=>{N(f,null),N(h,u(Pe),!0)}),V(De,we)}),T(ze),T(oe),T(ie),V(te,ie)};ke(ts,te=>{u(c)==="canvas"?te(Bl):u(c)==="svg"?te(Fl,1):te(Vl,-1)})}var Kl=P(ts,2);{var Hl=te=>{var ie=jv(),oe=R(ie),ze=R(oe);Nm(ze,{class:"size-3.5 text-primary-text"});var $e=P(ze,2),Ue=R($e,!0);T($e);var De=P($e,4),Pe=R(De);ks(Pe,{class:"size-3.5"}),T(De),T(oe);var we=P(oe,2),z=R(we);{var se=le=>{var ye=zv(),de=lt(ye),We=R(de),Xe=R(We),He=P(R(Xe),2),Qe=R(He,!0);T(He),T(Xe);var Tt=P(Xe,2);{var Be=Me=>{var Ve=Ev(),yt=R(Ve);js(yt,{class:"size-3"}),Bt(),T(Ve),V(Me,Ve)};ke(Tt,Me=>{u(v).orphan&&Me(Be)})}T(We);var je=P(We,2),Le=R(je,!0);T(je);var _e=P(je,2);{var st=Me=>{var Ve=Sv(),yt=R(Ve);Sa(yt,{class:"size-3"});var gt=P(yt);T(Ve),pe(ft=>fe(gt,` collapse cluster ${u(Vr)??""} · ${ft??""} nodes`),[()=>u(pi).get(u(Vr))]),Ne("click",Ve,()=>ml(u(Vr))),V(Me,Ve)},ht=Q(()=>u(Vr)!==null&&(u(pi).get(u(Vr))??0)>=2);ke(_e,Me=>{u(ht)&&Me(st)})}T(de);var kt=P(de,2),Dr=P(R(kt),2),pt=R(Dr,!0);T(Dr),T(kt);var Je=P(kt,2),dt=R(Je),Ir=P(R(dt),2),ki=R(Ir,!0);T(Ir),T(dt);var Jl=P(dt,2);{var Zl=Me=>{var Ve=Av();bt(Ve,21,()=>u(v).exports,Vn,(yt,gt)=>{var ft=Cv(),Et=R(ft,!0);T(ft),pe(()=>fe(Et,u(gt))),V(yt,ft)}),T(Ve),V(Me,Ve)},Ql=Me=>{var Ve=$v();V(Me,Ve)};ke(Jl,Me=>{u(v).exports.length>0?Me(Zl):Me(Ql,-1)})}T(Je);var Ei=P(Je,2),Si=R(Ei),is=P(R(Si),2),eu=R(is);T(is),T(Si);var tu=P(Si,2);{var ru=Me=>{var Ve=Iv();bt(Ve,21,()=>u(v).whereUsed,yt=>yt.id,(yt,gt)=>{var ft=Dv(),Et=R(ft),qt=R(Et,!0);T(Et);var Lr=P(Et,2),Yt=R(Lr),qr=R(Yt,!0);T(Yt);var cs=P(Yt,2),uu=R(cs,!0);T(cs),T(Lr),T(ft),pe(()=>{fe(qt,u(gt).label),fe(qr,u(gt).nodeLabel),fe(uu,u(gt).edgeLabel??u(gt).kind)}),Ne("click",ft,()=>nr(u(gt))),V(yt,ft)}),T(Ve),V(Me,Ve)},nu=Me=>{var Ve=Lv();V(Me,Ve)};ke(tu,Me=>{u(v).whereUsed.length>0?Me(ru):Me(nu,-1)})}T(Ei);var os=P(Ei,2),ss=P(R(os),2),Ci=R(ss),iu=R(Ci);{var ou=Me=>{var Ve=er(),yt=lt(Ve);bt(yt,17,()=>u(v).incoming,gt=>gt.id,(gt,ft)=>{var Et=Tv(),qt=R(Et),Lr=R(qt,!0);T(qt);var Yt=P(qt,2),qr=R(Yt,!0);T(Yt),T(Et),pe(()=>{fe(Lr,u(ft).label),fe(qr,u(ft).nodeLabel)}),Ne("click",Et,()=>nr(u(ft))),V(gt,Et)}),V(Me,Ve)},su=Me=>{var Ve=Gv();V(Me,Ve)};ke(iu,Me=>{u(v).incoming.length>0?Me(ou):Me(su,-1)})}T(Ci);var as=P(Ci,2),au=R(as);{var cu=Me=>{var Ve=er(),yt=lt(Ve);bt(yt,17,()=>u(v).outgoing,gt=>gt.id,(gt,ft)=>{var Et=Rv(),qt=R(Et),Lr=R(qt,!0);T(qt);var Yt=P(qt,2),qr=R(Yt,!0);T(Yt),T(Et),pe(()=>{fe(Lr,u(ft).label),fe(qr,u(ft).nodeLabel)}),Ne("click",Et,()=>nr(u(ft))),V(gt,Et)}),V(Me,Ve)},lu=Me=>{var Ve=Ov();V(Me,Ve)};ke(au,Me=>{u(v).outgoing.length>0?Me(cu):Me(lu,-1)})}T(as),T(ss),T(os),pe((Me,Ve,yt)=>{fe(Qe,u(f).label),fe(Le,Me),fe(pt,u(v).description??"No description in graph contract."),fe(ki,Ve),fe(eu,`${yt??""} inbound`)},[()=>String(u(f).data.rid??u(f).id),()=>u(v).exports.length.toLocaleString(),()=>u(v).whereUsed.length.toLocaleString()]),V(le,ye)},re=le=>{var ye=Pv(),de=lt(ye),We=P(R(de),2),Xe=R(We,!0);T(We),T(de);var He=P(de,2),Qe=P(R(He),2),Tt=R(Qe);{var Be=pt=>{var Je=Di();pe(dt=>fe(Je,dt),[()=>Pt(u(h).source).label]),V(pt,Je)},je=Q(()=>Pt(u(h).source)),Le=pt=>{var Je=Mv(),dt=R(Je,!0);T(Je),pe(()=>fe(dt,u(h).source)),V(pt,Je)};ke(Tt,pt=>{u(je)?pt(Be):pt(Le,-1)})}T(Qe);var _e=P(Qe,4),st=R(_e);{var ht=pt=>{var Je=Di();pe(dt=>fe(Je,dt),[()=>Pt(u(h).target).label]),V(pt,Je)},kt=Q(()=>Pt(u(h).target)),Dr=pt=>{var Je=Nv(),dt=R(Je,!0);T(Je),pe(()=>fe(dt,u(h).target)),V(pt,Je)};ke(st,pt=>{u(kt)?pt(ht):pt(Dr,-1)})}T(_e),T(He),pe(()=>fe(Xe,u(h).label??"(unlabelled)")),V(le,ye)};ke(z,le=>{u(f)&&u(v)?le(se):u(h)&&le(re,1)})}var Ie=P(z,4);bt(Ie,21,()=>{var le;return Object.entries((u(f)?u(f).data:(le=u(h))==null?void 0:le.data)??{})},Vn,(le,ye)=>{var de=Q(()=>an(u(ye),2));let We=()=>u(de)[0],Xe=()=>u(de)[1];var He=er(),Qe=lt(He);{var Tt=je=>{var Le=Wv(),_e=lt(Le),st=R(_e,!0);T(_e);var ht=P(_e,2),kt=R(ht);{var Dr=Je=>{var dt=Uv(),Ir=R(dt,!0);T(dt),pe(ki=>fe(Ir,ki),[()=>JSON.stringify(Xe(),null,2)]),V(Je,dt)},pt=Je=>{var dt=Di();pe(Ir=>fe(dt,Ir),[()=>String(Xe())]),V(Je,dt)};ke(kt,Je=>{typeof Xe()=="object"?Je(Dr):Je(pt,-1)})}T(ht),pe(()=>fe(st,We())),V(je,Le)},Be=Q(()=>Xe()!==null&&Xe()!==void 0&&!(u(f)&&Sr(We()))&&!(u(h)&&We()==="label"));ke(Qe,je=>{u(Be)&&je(Tt)})}V(le,He)}),T(Ie),T(we),T(ie),pe(()=>fe(Ue,u(f)?"Node":"Edge")),Ne("click",De,()=>{tt(),xt()}),V(te,ie)};ke(Kl,te=>{(u(f)||u(h))&&te(Hl)})}T(xi);var rs=P(xi,2),ns=R(rs);{var ql=te=>{var ie=Fv(),oe=P(lt(ie),2);bt(oe,17,()=>u(K),([ze,$e])=>ze,(ze,$e)=>{var Ue=Q(()=>an(u($e),2));let De=()=>u(Ue)[0],Pe=()=>u(Ue)[1];const we=Q(()=>u(ee).has(De()));var z=Bv(),se=R(z);let re;var Ie=P(se,2),le=R(Ie,!0);T(Ie);var ye=P(Ie,2),de=R(ye,!0);T(ye),T(z),pe((We,Xe,He)=>{H(z,"title",u(we)?`Show ${De()}`:`Hide ${De()}`),St(z,1,We,"svelte-gt9p7f"),re=Qu(se,"",re,Xe),fe(le,De()),fe(de,He)},[()=>Dt(["inline-flex items-center gap-1 px-1.5 py-0.5 rounded border transition-colors cursor-pointer",u(we)?"border-line-1 text-fg-3 line-through opacity-60":"border-line-2 text-fg-1 hover:border-accent"].join(" ")),()=>({color:u(we)?void 0:ei(De())}),()=>Pe().toLocaleString()]),Ne("click",z,()=>Ye(De())),V(ze,z)}),V(te,ie)};ke(ns,te=>{u(K).length>1&&te(ql)})}var Yl=P(ns,4);{var Xl=te=>{var ie=er(),oe=lt(ie);bt(oe,17,()=>u(jo),Vn,(ze,$e)=>{var Ue=Q(()=>an(u($e),2));let De=()=>u(Ue)[0],Pe=()=>u(Ue)[1];var we=Vv(),z=R(we),se=R(z,!0);T(z);var re=P(z,3);T(we),pe(Ie=>{fe(se,De()),fe(re,` ${Ie??""}`)},[()=>Pe().toLocaleString()]),V(ze,we)}),V(te,ie)};ke(Yl,te=>{u(jo).length>0&&te(Xl)})}T(rs),pe((te,ie,oe,ze,$e,Ue,De,Pe,we)=>{H(Ke,"href",te),St(Ke,1,ie,"svelte-gt9p7f"),H(Ke,"aria-current",u(c)==="canvas"?"page":void 0),H(rt,"href",oe),St(rt,1,ze,"svelte-gt9p7f"),H(rt,"aria-current",u(c)==="svg"?"page":void 0),H(Ut,"href",$e),St(Ut,1,Ue,"svelte-gt9p7f"),H(Ut,"aria-current",u(c)==="table"?"page":void 0),St($r,1,De,"svelte-gt9p7f"),H($r,"aria-pressed",u(S)),fe(zl,`${Pe??""} nodes · ${we??""} edges`)},[()=>e.collection?Wi(e.collection,"graph"):void 0,()=>Dt(["inline-flex items-center gap-1 px-2 py-1 text-[11px] cursor-pointer transition-colors",u(c)==="canvas"?"bg-primary text-on-primary":"bg-bg-1 text-fg-2 hover:text-fg-0"].join(" ")),()=>e.collection?Wi(e.collection,"svg"):void 0,()=>Dt(["inline-flex items-center gap-1 px-2 py-1 text-[11px] cursor-pointer transition-colors border-l border-line-2",u(c)==="svg"?"bg-primary text-on-primary":"bg-bg-1 text-fg-2 hover:text-fg-0"].join(" ")),()=>e.collection?Wi(e.collection,"table"):void 0,()=>Dt(["inline-flex items-center gap-1 px-2 py-1 text-[11px] cursor-pointer transition-colors border-l border-line-2",u(c)==="table"?"bg-primary text-on-primary":"bg-bg-1 text-fg-2 hover:text-fg-0"].join(" ")),()=>Dt(["inline-flex items-center gap-1 h-6 px-2 rounded border cursor-pointer transition-colors",u(S)?"border-accent/40 bg-accent/10 text-primary-text":"border-line-1 text-fg-3 hover:text-fg-1 hover:border-line-2"].join(" ")),()=>u(i).nodes.length.toLocaleString(),()=>u(i).edges.length.toLocaleString()]),Ne("click",Ke,()=>{e.collection||N(c,"canvas")}),Ne("click",rt,()=>{e.collection||N(c,"svg")}),Ne("click",Ut,()=>{e.collection||N(c,"table")}),Ne("click",$r,()=>N(S,!u(S))),V(k,U)};ke($l,k=>{u(i).nodes.length===0&&u(i).edges.length===0?k(Dl):k(Il,-1)})}T(wi),V(r,wi),oi()}Xu(["click","change","keydown"]);const sl={name:"layers",size:24,node:[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17"}]],aliases:["layers-3"]};sl.node;function fy(r,e){let t=Ze(e,["$$slots","$$events","$$legacy"]);at(r,it(()=>t,{get icon(){return sl}}))}function hy(r,e){np(r,{get title(){return e.title},get description(){return e.message},get hint(){return e.hint},get actions(){return e.actions},media:n=>{var i=er(),o=lt(i);{var s=a=>{qh(a,{get icon(){return e.icon},size:"lg"})};ke(o,a=>{e.icon&&a(s)})}V(n,i)},$$slots:{media:!0}})}const al={name:"file-braces",size:24,node:[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5"}],["path",{d:"M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1"}],["path",{d:"M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1"}]],aliases:["file-json"]};al.node;function py(r,e){let t=Ze(e,["$$slots","$$events","$$legacy"]);at(r,it(()=>t,{get icon(){return al}}))}const cl={name:"link-2",size:24,node:[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12"}]]};cl.node;function gy(r,e){let t=Ze(e,["$$slots","$$events","$$legacy"]);at(r,it(()=>t,{get icon(){return cl}}))}export{iy as A,cn as B,sy as C,ao as D,hy as E,py as F,dy as G,ly as H,at as I,Fh as J,_p as K,fy as L,Ws as N,fc as P,wo as R,kp as S,Mm as T,ks as X,qh as a,Nm as b,gy as c,xp as d,Ep as e,Sp as f,js as g,lr as h,Wi as i,No as j,Qn as k,cy as l,Tr as m,bt as n,id as o,Ap as p,ny as q,Do as r,uy as s,Vn as t,ry as u,Xr as v,on as w,ay as x,oy as y,li as z};
|