@qe-libs/qeviz 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/qeviz.es.js +758 -758
- package/dist/qeviz.es.js.map +1 -1
- package/dist/qeviz.umd.js +5 -5
- package/dist/qeviz.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/qeviz.umd.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
(function(S,B){typeof exports=="object"&&typeof module<"u"?B(exports):typeof define=="function"&&define.amd?define(["exports"],B):(S=typeof globalThis<"u"?globalThis:S||self,B(S.QEViz={}))})(this,(function(S){"use strict";var Ri=Object.defineProperty;var ni=S=>{throw TypeError(S)};var u=(S,B)=>Ri(S,"name",{value:B,configurable:!0});var ri=(S,B,_t)=>B.has(S)||ni("Cannot "+_t);var C=(S,B,_t)=>(ri(S,B,"read from private field"),_t?_t.call(S):B.get(S)),it=(S,B,_t)=>B.has(S)?ni("Cannot add the same private member more than once"):B instanceof WeakSet?B.add(S):B.set(S,_t),W=(S,B,_t,It)=>(ri(S,B,"write to private field"),It?It.call(S,_t):B.set(S,_t),_t);var ge,me,fe,pt,pe,be,bt,Ut,Ct,St,at,ye,Tt,Et,Xt,Wt,Se;const ns=class ns extends Array{constructor(e,s,i,n,r){super(...s);it(this,ge);it(this,me);it(this,fe);it(this,pt);it(this,pe);W(this,fe,e),W(this,me,i),W(this,pt,n),W(this,pe,n==null?void 0:n.classes),W(this,ge,r)}get parent(){return C(this,pt)}get names(){return C(this,fe)}get rowName(){return C(this,me)}get types(){if(!C(this,pt))throw new Error("No parent DataFrame attached to this row.");return C(this,pt).types}get classes(){return C(this,pe)}get rowNumber(){return C(this,ge)}col(e){if(!C(this,pt))throw new Error("No parent DataFrame attached to this row.");return C(this,pt).col(e)}cols(...e){if(!C(this,pt))throw new Error("No parent DataFrame attached to this row.");return C(this,pt).cols(...e)}filter(e){console.error("DataFrameRow does not currently support filtering.")}};ge=new WeakMap,me=new WeakMap,fe=new WeakMap,pt=new WeakMap,pe=new WeakMap,u(ns,"DataFrameRow");let B=ns;var _t=(d=>(d.Character="character",d.Double="double",d.Logical="logical",d.Integer="integer",d))(_t||{});const rs=class rs extends Array{constructor(e,s,i,n){super(s.length);it(this,be);it(this,bt);it(this,Ut);it(this,Ct);for(let r=0;r<s.length;r++)this[r]=s[r];if(W(this,be,e),s.type!==void 0?W(this,bt,s.type):s.every(r=>typeof r=="string"||r===null||r===void 0)?W(this,bt,"character"):s.every(r=>Number.isInteger(r)||r===null||r===void 0)?s.every(r=>r===0||r===1||r===null||r===void 0)?W(this,bt,"logical"):W(this,bt,"integer"):s.every(r=>typeof r=="number"||r===null||r===void 0)?W(this,bt,"double"):s.every(r=>typeof r=="boolean"||r===null||r===void 0)?W(this,bt,"logical"):W(this,bt,"character"),W(this,Ct,n),i&&i.length!==this.length)throw new Error("Row names length must match the number of rows in the DataFrameColumn.");i&&i.length>0?W(this,Ut,i):W(this,Ut,void 0)}get name(){return C(this,be)}get type(){return C(this,bt)}get rowNames(){return C(this,Ut)}row(e){if(!C(this,Ct))throw new Error("No parent DataFrame attached to this column.");return C(this,Ct).row(e)}rows(...e){if(!C(this,Ct))throw new Error("No parent DataFrame attached to this column.");return C(this,Ct).rows(...e)}};be=new WeakMap,bt=new WeakMap,Ut=new WeakMap,Ct=new WeakMap,u(rs,"DataFrameColumn");let It=rs;const xe=class xe extends Array{constructor(e,s,i,n){if((!e||!s)&&(s=[],e=[]),s.map(r=>r.length).every(r=>r===e.length)){const r=[];for(let a=0;a<e.length;a++){const h=[];for(let o=0;o<s.length;o++)h.push(s[o][a]);r.push(h)}s=r}super(s.length);it(this,St);it(this,at);it(this,ye);if(s.forEach((r,a)=>{r instanceof It?this[a]=r:this[a]=new It(e[a],r,i,this)}),W(this,St,e),i&&this[0]&&i.length!==this[0].length)throw new Error("Row names length must match the number of rows in the DataFrame.");if(i&&i.length>0&&W(this,at,i),n&&n.length!==this.length)throw new Error("Classes length must match the number of columns in the DataFrame.");n&&n.length>0&&W(this,ye,n)}get classes(){return C(this,ye)}getColumnByName(e){const s=C(this,St).indexOf(e);return s>=0?this[s]:void 0}getRowByIndex(e){if(this&&this.length===0)return console.warn("DataFrame is empty, cannot get row by index",e),new B(C(this,St),[],void 0,this,e);const s=[];for(let i of this){let n=i[e];s.push(n)}return new B(C(this,St),s,C(this,at)?C(this,at)[e]:void 0,this,e)}getRowByName(e){if(!C(this,at))return;const s=C(this,at).indexOf(e);if(s!==-1)return this.getRowByIndex(s)}get types(){return this.map(e=>e.type)}type(e){var s;if(typeof e=="number")return(s=this[e])==null?void 0:s.type;if(typeof e=="string"){const i=this.getColumnByName(e);return i?i.type:void 0}}row(e){if(typeof e=="number")return this.getRowByIndex(e);if(typeof e=="string")return this.getRowByName(e)}rows(...e){let s,i=[],n=[];if(e.length===0){if(!this[0]||this.length===0)return[];const r=this[0].length;i=Array.from({length:r},(a,h)=>this.getRowByIndex(h)),n=C(this,at)}else e.length===1&&Array.isArray(e[0])?s=e[0]:s=e,i=s.map((r,a)=>{let h=this.row(r);return C(this,at)&&h&&(n==null||n.push(C(this,at)[a])),h}).filter(r=>r!==void 0);return i}col(e){if(typeof e=="number")return this[e];if(typeof e=="string")return this.getColumnByName(e)}cols(...e){let s,i,n=[];return e.length===0?(i=this.slice(),n=C(this,St)):(e.length===1&&Array.isArray(e[0])?s=e[0]:s=e,i=s.map(r=>this.col(r)).filter(r=>r!==void 0),n=i.map(r=>r.name)),new xe(n,i,C(this,at))}subset(e,s){const i=s&&s.length>0?this.cols(...s):this.slice();return new xe(i.map(n=>n.name),i.map(n=>n.values),C(this,at))}get names(){return C(this,St)}get rowNames(){return C(this,at)}get nrow(){return this[0]?this[0].length:0}get ncol(){return this.length}};St=new WeakMap,at=new WeakMap,ye=new WeakMap,u(xe,"DataFrame");let $t=xe;const os=class os{constructor(t={}){this.unit_id_col="id",this.node_id_col="id",this.group_col=null,this.directed=!1,this.palette=[],this._points=t.points??new $t,this._nodes=t.nodes??new $t,this._edges=t.edges??new $t,this._dimensions=t.dimensions??[],this._confidence=void 0,this._outlier=void 0,this._groups=void 0}get updated(){return this._updated}set updated(t){this._updated=t}get points(){return this._points}set points(t){this._points=t}get nodes(){return this._nodes}set nodes(t){this._nodes=t}get edges(){return this._edges}set edges(t){this._edges=t}get confidence(){return this._confidence}set confidence(t){this._confidence=t}get outlier(){return this._outlier}set outlier(t){this._outlier=t}get groups(){return this._groups}set groups(t){this._groups=t}get trajectories(){return this._trajectories}set trajectories(t){this._trajectories=t}get networks(){return this._networks}set networks(t){this._networks=t}get pointsets(){return this._pointsets}set pointsets(t){this._pointsets=t}get dimensions(){return this._dimensions}set dimensions(t){this._dimensions=t}get params(){return this._params}set params(t){this._params=t}point(t){return this._points.row(t)}setByKey(t,e){this[t]=e}};u(os,"Model");let Ve=os;const oi=globalThis.__QEVIZ_DEBUG__===!0;function Ss(...d){oi&&console.log(...d)}u(Ss,"dbg");const ai={get:u(d=>{const t=[...document.querySelectorAll("qe-graph")];return typeof d=="number"&&d>=0?t[d]:t},"get")},Bt=class Bt extends HTMLElement{constructor(){super(),this._isVisible=!0,this.output="",this._updated="",this._active_points=[],this._points=new Map,this._edges=new Map,this._labels=new Map,this._model=new Ve;const t=this.attachShadow({mode:"open"}),e=document.createElement("style");e.textContent=Bt.styles,t.appendChild(e),this._outputElement=document.createElement("div"),t.appendChild(this._outputElement)}static get observedAttributes(){return["updated"]}get model(){return this._model}get updated(){return this._updated}set updated(t){this._updated=t,this.setAttribute("updated",t),this.dispatchEvent(new CustomEvent("model-updated",{detail:this._model,bubbles:!0,composed:!0}))}get points(){return this._points}set points(t){this._points.clear(),t instanceof Map?this._points=t:Array.isArray(t)&&t.forEach(e=>this._points.set(e.ID,e))}get active_points(){return Array.from(this._active_points.values())}get edges(){return this._edges}set edges(t){this._edges.clear(),t instanceof Map?this._edges=t:Array.isArray(t)&&(this._edges=new Map,t.forEach(e=>this._edges.set(e.ID,e)))}get labels(){return this._labels}connectedCallback(){Ss("QEVisualElement connected"),this.render()}setModelData(t){var r,a,h,o;["nodes","edges","points","groups","confidence","outlier","trajectories","networks","pointsets"].forEach(l=>{var v;const _=t[l];if(!((v=_==null?void 0:_.data)!=null&&v.length))return;const g=_.data,c=_.types||{},E=Object.keys(g[0]),p=g.map(Y=>Object.values(Y)),A=E.map(Y=>c[Y]??"character");let R;l==="networks"?R="name":l==="pointsets"?R="id":l==="nodes"?R=t.node_id_col??E.find(Y=>(c[Y]??"character")==="character"):l==="edges"||l==="points"||l==="trajectories"?R=t.id_col??E.find(Y=>(c[Y]??"character")==="character"):R=t.group_col??E.find(Y=>(c[Y]??"character")==="character");const q=R?E.indexOf(R):0,G=p.map(Y=>String(Y[q]));this._model.setByKey(l,new $t(E,p,G,A))}),t.updated!==void 0&&this._model.setByKey("updated",t.updated),t.directed!==void 0&&(this._model.directed=t.directed),Array.isArray(t.palette)&&(this._model.palette=t.palette.map(String));const s=this._model.nodes;this._model.node_id_col=t.node_id_col??((r=s==null?void 0:s.names)==null?void 0:r.find(l=>{var _;return((_=s.col(l))==null?void 0:_.type)==="character"}))??"id";const i=this._model.points;this._model.unit_id_col=t.id_col??((a=i==null?void 0:i.names)==null?void 0:a.find(l=>{var _;return((_=i.col(l))==null?void 0:_.type)==="character"}))??"id";const n=this._model.unit_id_col;if(this._model.group_col=t.group_col??((h=i==null?void 0:i.names)==null?void 0:h.find(l=>{var _;return l!==n&&((_=i.col(l))==null?void 0:_.type)==="character"}))??null,(o=s==null?void 0:s.names)!=null&&o.length){const l=this._model.node_id_col,_=t.x_col,g=t.y_col;if(_&&g)this._model.dimensions=[_,g];else{const c=s.names.filter(E=>{if(E===l)return!1;const p=s.col(E);return p&&p.type!=="character"&&p.type!=="logical"});c.length>=2&&(this._model.dimensions=[_??c[0],g??c[1]])}}this.updated=this._model.updated!==void 0?String(this._model.updated):String(Date.now()),Ss("Model updated via setModelData:",this.updated),this.render()}async calculate(){}render(){var t;this._isVisible?this.classList.remove("hidden"):this.classList.add("hidden"),((t=this._model)==null?void 0:t.updated)!==void 0&&this._model.updated!==null?this._outputElement.innerHTML=`${this.output}<slot></slot>`:this._outputElement.innerHTML="Define the model on the left."}};u(Bt,"QEVisualElement"),Bt.tagName="qe-visual",Bt.styles=`
|
|
1
|
+
(function(E,B){typeof exports=="object"&&typeof module<"u"?B(exports):typeof define=="function"&&define.amd?define(["exports"],B):(E=typeof globalThis<"u"?globalThis:E||self,B(E.QEViz={}))})(this,(function(E){"use strict";var Li=Object.defineProperty;var ri=E=>{throw TypeError(E)};var u=(E,B)=>Li(E,"name",{value:B,configurable:!0});var oi=(E,B,_t)=>B.has(E)||ri("Cannot "+_t);var C=(E,B,_t)=>(oi(E,B,"read from private field"),_t?_t.call(E):B.get(E)),it=(E,B,_t)=>B.has(E)?ri("Cannot add the same private member more than once"):B instanceof WeakSet?B.add(E):B.set(E,_t),X=(E,B,_t,Nt)=>(oi(E,B,"write to private field"),Nt?Nt.call(E,_t):B.set(E,_t),_t);var me,fe,pe,pt,be,ye,bt,Bt,Ot,Et,at,xe,Dt,Mt,Wt,Vt,Ee;const rs=class rs extends Array{constructor(e,s,i,n,r){super(...s);it(this,me);it(this,fe);it(this,pe);it(this,pt);it(this,be);X(this,pe,e),X(this,fe,i),X(this,pt,n),X(this,be,n==null?void 0:n.classes),X(this,me,r)}get parent(){return C(this,pt)}get names(){return C(this,pe)}get rowName(){return C(this,fe)}get types(){if(!C(this,pt))throw new Error("No parent DataFrame attached to this row.");return C(this,pt).types}get classes(){return C(this,be)}get rowNumber(){return C(this,me)}col(e){if(!C(this,pt))throw new Error("No parent DataFrame attached to this row.");return C(this,pt).col(e)}cols(...e){if(!C(this,pt))throw new Error("No parent DataFrame attached to this row.");return C(this,pt).cols(...e)}filter(e){console.error("DataFrameRow does not currently support filtering.")}};me=new WeakMap,fe=new WeakMap,pe=new WeakMap,pt=new WeakMap,be=new WeakMap,u(rs,"DataFrameRow");let B=rs;var _t=(d=>(d.Character="character",d.Double="double",d.Logical="logical",d.Integer="integer",d))(_t||{});const os=class os extends Array{constructor(e,s,i,n){super(s.length);it(this,ye);it(this,bt);it(this,Bt);it(this,Ot);for(let r=0;r<s.length;r++)this[r]=s[r];if(X(this,ye,e),s.type!==void 0?X(this,bt,s.type):s.every(r=>typeof r=="string"||r===null||r===void 0)?X(this,bt,"character"):s.every(r=>Number.isInteger(r)||r===null||r===void 0)?s.every(r=>r===0||r===1||r===null||r===void 0)?X(this,bt,"logical"):X(this,bt,"integer"):s.every(r=>typeof r=="number"||r===null||r===void 0)?X(this,bt,"double"):s.every(r=>typeof r=="boolean"||r===null||r===void 0)?X(this,bt,"logical"):X(this,bt,"character"),X(this,Ot,n),i&&i.length!==this.length)throw new Error("Row names length must match the number of rows in the DataFrameColumn.");i&&i.length>0?X(this,Bt,i):X(this,Bt,void 0)}get name(){return C(this,ye)}get type(){return C(this,bt)}get rowNames(){return C(this,Bt)}row(e){if(!C(this,Ot))throw new Error("No parent DataFrame attached to this column.");return C(this,Ot).row(e)}rows(...e){if(!C(this,Ot))throw new Error("No parent DataFrame attached to this column.");return C(this,Ot).rows(...e)}};ye=new WeakMap,bt=new WeakMap,Bt=new WeakMap,Ot=new WeakMap,u(os,"DataFrameColumn");let Nt=os;const we=class we extends Array{constructor(e,s,i,n){if((!e||!s)&&(s=[],e=[]),s.map(r=>r.length).every(r=>r===e.length)){const r=[];for(let a=0;a<e.length;a++){const h=[];for(let o=0;o<s.length;o++)h.push(s[o][a]);r.push(h)}s=r}super(s.length);it(this,Et);it(this,at);it(this,xe);if(s.forEach((r,a)=>{r instanceof Nt?this[a]=r:this[a]=new Nt(e[a],r,i,this)}),X(this,Et,e),i&&this[0]&&i.length!==this[0].length)throw new Error("Row names length must match the number of rows in the DataFrame.");if(i&&i.length>0&&X(this,at,i),n&&n.length!==this.length)throw new Error("Classes length must match the number of columns in the DataFrame.");n&&n.length>0&&X(this,xe,n)}get classes(){return C(this,xe)}getColumnByName(e){const s=C(this,Et).indexOf(e);return s>=0?this[s]:void 0}getRowByIndex(e){if(this&&this.length===0)return console.warn("DataFrame is empty, cannot get row by index",e),new B(C(this,Et),[],void 0,this,e);const s=[];for(let i of this){let n=i[e];s.push(n)}return new B(C(this,Et),s,C(this,at)?C(this,at)[e]:void 0,this,e)}getRowByName(e){if(!C(this,at))return;const s=C(this,at).indexOf(e);if(s!==-1)return this.getRowByIndex(s)}get types(){return this.map(e=>e.type)}type(e){var s;if(typeof e=="number")return(s=this[e])==null?void 0:s.type;if(typeof e=="string"){const i=this.getColumnByName(e);return i?i.type:void 0}}row(e){if(typeof e=="number")return this.getRowByIndex(e);if(typeof e=="string")return this.getRowByName(e)}rows(...e){let s,i=[],n=[];if(e.length===0){if(!this[0]||this.length===0)return[];const r=this[0].length;i=Array.from({length:r},(a,h)=>this.getRowByIndex(h)),n=C(this,at)}else e.length===1&&Array.isArray(e[0])?s=e[0]:s=e,i=s.map((r,a)=>{let h=this.row(r);return C(this,at)&&h&&(n==null||n.push(C(this,at)[a])),h}).filter(r=>r!==void 0);return i}col(e){if(typeof e=="number")return this[e];if(typeof e=="string")return this.getColumnByName(e)}cols(...e){let s,i,n=[];return e.length===0?(i=this.slice(),n=C(this,Et)):(e.length===1&&Array.isArray(e[0])?s=e[0]:s=e,i=s.map(r=>this.col(r)).filter(r=>r!==void 0),n=i.map(r=>r.name)),new we(n,i,C(this,at))}subset(e,s){const i=s&&s.length>0?this.cols(...s):this.slice();return new we(i.map(n=>n.name),i.map(n=>n.values),C(this,at))}get names(){return C(this,Et)}get rowNames(){return C(this,at)}get nrow(){return this[0]?this[0].length:0}get ncol(){return this.length}};Et=new WeakMap,at=new WeakMap,xe=new WeakMap,u(we,"DataFrame");let Pt=we;const as=class as{constructor(t={}){this.unit_id_col="id",this.node_id_col="id",this.group_col=null,this.directed=!1,this.palette=[],this._points=t.points??new Pt,this._nodes=t.nodes??new Pt,this._edges=t.edges??new Pt,this._dimensions=t.dimensions??[],this._confidence=void 0,this._outlier=void 0,this._groups=void 0}get updated(){return this._updated}set updated(t){this._updated=t}get points(){return this._points}set points(t){this._points=t}get nodes(){return this._nodes}set nodes(t){this._nodes=t}get edges(){return this._edges}set edges(t){this._edges=t}get confidence(){return this._confidence}set confidence(t){this._confidence=t}get outlier(){return this._outlier}set outlier(t){this._outlier=t}get groups(){return this._groups}set groups(t){this._groups=t}get trajectories(){return this._trajectories}set trajectories(t){this._trajectories=t}get networks(){return this._networks}set networks(t){this._networks=t}get pointsets(){return this._pointsets}set pointsets(t){this._pointsets=t}get dimensions(){return this._dimensions}set dimensions(t){this._dimensions=t}get params(){return this._params}set params(t){this._params=t}point(t){return this._points.row(t)}setByKey(t,e){this[t]=e}};u(as,"Model");let Ke=as;const ai=globalThis.__QEVIZ_DEBUG__===!0;function Es(...d){ai&&console.log(...d)}u(Es,"dbg");const hi={get:u(d=>{const t=[...document.querySelectorAll("qe-graph")];return typeof d=="number"&&d>=0?t[d]:t},"get")},Ht=class Ht extends HTMLElement{constructor(){super(),this._isVisible=!0,this.output="",this._updated="",this._active_points=[],this._points=new Map,this._edges=new Map,this._labels=new Map,this._model=new Ke;const t=this.attachShadow({mode:"open"}),e=document.createElement("style");e.textContent=Ht.styles,t.appendChild(e),this._outputElement=document.createElement("div"),t.appendChild(this._outputElement)}static get observedAttributes(){return["updated"]}get model(){return this._model}get updated(){return this._updated}set updated(t){this._updated=t,this.setAttribute("updated",t),this.dispatchEvent(new CustomEvent("model-updated",{detail:this._model,bubbles:!0,composed:!0}))}get points(){return this._points}set points(t){this._points.clear(),t instanceof Map?this._points=t:Array.isArray(t)&&t.forEach(e=>this._points.set(e.ID,e))}get active_points(){return Array.from(this._active_points.values())}get edges(){return this._edges}set edges(t){this._edges.clear(),t instanceof Map?this._edges=t:Array.isArray(t)&&(this._edges=new Map,t.forEach(e=>this._edges.set(e.ID,e)))}get labels(){return this._labels}connectedCallback(){Es("QEVisualElement connected"),this.render()}setModelData(t){var r,a,h,o;["nodes","edges","points","groups","confidence","outlier","trajectories","networks","pointsets"].forEach(l=>{var S;const _=t[l];if(!((S=_==null?void 0:_.data)!=null&&S.length))return;const g=_.data,c=_.types||{},M=Object.keys(g[0]),f=g.map(Y=>Object.values(Y)),v=M.map(Y=>c[Y]??"character");let R;l==="networks"?R="name":l==="pointsets"?R="id":l==="nodes"?R=t.node_id_col??M.find(Y=>(c[Y]??"character")==="character"):l==="edges"||l==="points"||l==="trajectories"?R=t.id_col??M.find(Y=>(c[Y]??"character")==="character"):R=t.group_col??M.find(Y=>(c[Y]??"character")==="character");const q=R?M.indexOf(R):0,G=f.map(Y=>String(Y[q]));this._model.setByKey(l,new Pt(M,f,G,v))}),t.updated!==void 0&&this._model.setByKey("updated",t.updated),t.directed!==void 0&&(this._model.directed=t.directed),Array.isArray(t.palette)&&(this._model.palette=t.palette.map(String));const s=this._model.nodes;this._model.node_id_col=t.node_id_col??((r=s==null?void 0:s.names)==null?void 0:r.find(l=>{var _;return((_=s.col(l))==null?void 0:_.type)==="character"}))??"id";const i=this._model.points;this._model.unit_id_col=t.id_col??((a=i==null?void 0:i.names)==null?void 0:a.find(l=>{var _;return((_=i.col(l))==null?void 0:_.type)==="character"}))??"id";const n=this._model.unit_id_col;if(this._model.group_col=t.group_col??((h=i==null?void 0:i.names)==null?void 0:h.find(l=>{var _;return l!==n&&((_=i.col(l))==null?void 0:_.type)==="character"}))??null,(o=s==null?void 0:s.names)!=null&&o.length){const l=this._model.node_id_col,_=t.x_col,g=t.y_col;if(_&&g)this._model.dimensions=[_,g];else{const c=s.names.filter(M=>{if(M===l)return!1;const f=s.col(M);return f&&f.type!=="character"&&f.type!=="logical"});c.length>=2&&(this._model.dimensions=[_??c[0],g??c[1]])}}this.updated=this._model.updated!==void 0?String(this._model.updated):String(Date.now()),Es("Model updated via setModelData:",this.updated),this.render()}async calculate(){}render(){var t;this._isVisible?this.classList.remove("hidden"):this.classList.add("hidden"),((t=this._model)==null?void 0:t.updated)!==void 0&&this._model.updated!==null?this._outputElement.innerHTML=`${this.output}<slot></slot>`:this._outputElement.innerHTML="Define the model on the left."}};u(Ht,"QEVisualElement"),Ht.tagName="qe-visual",Ht.styles=`
|
|
2
2
|
:host { display: block; width: 100%; }
|
|
3
3
|
:host(.hidden) { display: none !important; }
|
|
4
4
|
/* The output wrapper and the slotted graph fill the host so the plot
|
|
5
5
|
stretches to its container instead of collapsing to intrinsic size. */
|
|
6
6
|
div { display: block; width: 100%; height: 100%; }
|
|
7
7
|
::slotted(qe-graph) { display: block; width: 100%; height: 100%; }
|
|
8
|
-
`;let Zt=Bt;customElements.define(Zt.tagName,Zt);const Re=class Re{constructor(t){return this.base=typeof t=="string"?t:t.base,new Proxy(this,{get(e,s){if(typeof s=="string"&&/^[0-2]$/.test(s)){const{r:i,g:n,b:r}=Re.parseColor(e.base);return[i,n,r][Number(s)]}return e[s]}})}toString(){return this.base}setBase(t){this.base=t}static parseColor(t){if(t.startsWith("#")){const e=parseInt(t.slice(1),16);return{r:e>>16&255,g:e>>8&255,b:e&255}}throw new Error("Unsupported color format")}static rgb(t,e,s){return`rgb(${t}, ${e}, ${s})`}};u(Re,"Color");let tt=Re;const we=class we extends tt{constructor(t,e,s){super(t),this.weight=e,this.alpha=s}static toHSV(t){const{r:e,g:s,b:i}=tt.parseColor(t),n=e/255,r=s/255,a=i/255,h=Math.max(n,r,a),o=Math.min(n,r,a),l=h-o,_=h,g=h===0?0:l/h;let c=0;if(l>0)switch(h){case n:c=((r-a)/l+(r<a?6:0))/6;break;case r:c=((a-n)/l+2)/6;break;default:c=((n-r)/l+4)/6}return{h:c*360,s:g,v:_}}static hsvToRgba(t,e,s,i){const n=s*e,r=n*(1-Math.abs(t/60%2-1)),a=s-n;let h=0,o=0,l=0;return t<60?(h=n,o=r,l=0):t<120?(h=r,o=n,l=0):t<180?(h=0,o=n,l=r):t<240?(h=0,o=r,l=n):t<300?(h=r,o=0,l=n):(h=n,o=0,l=r),`rgba(${Math.round((h+a)*255)},${Math.round((o+a)*255)},${Math.round((l+a)*255)},${i.toFixed(4)})`}toString(){const{h:t,v:e}=we.toHSV(this.base),s=Math.min(1,Math.abs(this.weight)),i=this.alpha===void 0?s:Math.min(1,Math.max(0,this.alpha));return we.hsvToRgba(t,s,e,i)}};u(we,"WeightedColor");let Qt=we;const as=class as{constructor(t=null){this._values=[1,0,0,1,0,0],this._keys=["a","b","c","d","e","f"],t&&(this.values=t)}get values(){return this._values}set values(t){t&&t.length===6&&(this._values=t)}get keys(){return this._keys}set keys(t){t&&t.length===6&&(this._keys=t)}toString(){return`matrix(${this.keys.map((e,s)=>this.values[s]).join(" ")})`}toMatrix(){return Object.fromEntries(this._keys.map((t,e)=>[t,this._values[e]]))}toArray(){return this._values}set(t,e){e!==.0075&&e!==0&&(this._values[this._keys.findIndex(s=>s===t)]=e)}get(t){return this._values[this._keys.findIndex(e=>e===t)]}scale(t,e=t){this.a=t,this.d=e}zoom(t){this.a=t,this.d=t}pan(t,e){this.e=this.e+t,this.f=this.f+e}set a(t){this.set("a",t)}set b(t){this.set("b",t)}set c(t){this.set("c",t)}set d(t){this.set("d",t)}set e(t){this.set("e",t)}set f(t){this.set("f",t)}get a(){return this.get("a")}get b(){return this.get("b")}get c(){return this.get("c")}get d(){return this.get("d")}get e(){return this.get("e")}get f(){return this.get("f")}};u(as,"Transform");let te=as;var ee;(d=>{(t=>{function e(s){return`matrix(${["a","b","c","d","e","f"].map(n=>s[n]).join(" ")})`}u(e,"matrixString"),t.matrixString=e})(d.Matrix||(d.Matrix={})),(t=>{(s=>{function i(r,a,h){const o=e.toRad(a);return[r[0]+h*Math.cos(o),r[1]+h*Math.sin(o)]}u(i,"translate"),s.translate=i;function n(r,a,h){const o=e.toRad(a);function l(_,g){return[_[0]*Math.cos(g)-_[1]*Math.sin(g),_[0]*Math.sin(g)+_[1]*Math.cos(g)]}if(u(l,"rotatePoint"),!h||h[0]===0&&h[1]===0)return l(r,o);{const _=r.map((c,E)=>c-h[E]);return l(_,o).map((c,E)=>c+h[E])}}u(n,"rotate"),s.rotate=n})(t.Point||(t.Point={})),(s=>{function i(p,A){return(A[1]-p[1])/(A[0]-p[0])}u(i,"slope"),s.slope=i;function n(p,A){const R=i(p,A);return p[1]-R*p[0]}u(n,"intercept"),s.intercept=n;function r(p,A){return{slope:i(p,A),intercept:n(p,A)}}u(r,"slopeIntercept"),s.slopeIntercept=r;function a(p,A=0){const R=A,q=(1-R)*p[0][0]+R*p[1][0],G=(1-R)*p[0][1]+R*p[1][1];return[q,G]}u(a,"point_along"),s.point_along=a;function h(p,A,R=.5){return Array.isArray(p[0])&&(A=p[1],p=p[0]),[0,1].map(q=>(parseFloat(p[q])+parseFloat(A[q]))*R)}u(h,"midpoint"),s.midpoint=h;function o(p,A){return Array.isArray(p[0])&&(A=p[1],p=p[0]),Math.sqrt([0,1].map(R=>Math.pow(A[R]-p[R],2)).reduce((R,q)=>R+q,0))}u(o,"length"),s.length=o;function l(p,A=[0,0]){const R=[p[1][0]-A[0],p[1][1]-A[1]],q=[-R[1],R[0]],G=[-q[0],-q[1]],v=[q[0]+A[0],q[1]+A[1]],Y=[G[0]+A[0],G[1]+A[1]];return[v,Y]}u(l,"rotate"),s.rotate=l;function _(p,A,R=90){const q=d.Geometry.Line.slope(p[0],p[1]),G=d.Geometry.Line.intercept(p[0],p[1]),v=[0,G],Y=[1,q+G];p=[v,Y];const rt=[p[0][0],p[1][0]],ht=[p[0][1],p[1][1]],nt=A[0],dt=A[1],Z=-2*Math.PI*R/360,Ot=rt.map((He,gt)=>(He-nt)*Math.cos(Z)-(ht[gt]-dt)*Math.sin(Z)+nt),Dt=ht.map((He,gt)=>(rt[gt]-nt)*Math.sin(Z)-(He-dt)*Math.cos(Z)+dt);return[[Ot[0],Dt[0]],[Ot[1],Dt[1]]]}u(_,"rotate2"),s.rotate2=_;function g(p,A){const[[R,q],[G,v]]=p,[[Y,rt],[ht,nt]]=A,dt=(R-G)*(rt-nt)-(q-v)*(Y-ht),Z=(R*v-q*G)*(Y-ht)-(R-G)*(Y*nt-rt*ht),Ot=(R*v-q*G)*(rt-nt)-(q-v)*(Y*nt-rt*ht);return[Z/dt,Ot/dt]}u(g,"intersection"),s.intersection=g;function c(p,A,R){let{slope:q,intercept:G}=d.Geometry.Line.slopeIntercept(p[0],p[1]),v=1+Math.pow(q,2),Y=2*q*G-2*A[1]*q-2*A[0],rt=Math.pow(A[0],2)+Math.pow(G,2)+Math.pow(A[1],2)-2*A[1]*G-Math.pow(R,2),ht=[[1/0,1/0],[1/0,1/0]];if(Math.sqrt(Math.pow(Y,2)-4*v*rt)>=0){let nt=(-Y+Math.sqrt(Math.pow(Y,2)-4*v*rt))/(2*v),dt=(-Y-Math.sqrt(Math.pow(Y,2)-4*v*rt))/(2*v),Z=q*nt+G,Ot=q*dt+G;ht=[[nt,Z],[dt,Ot]]}else console.error("The line and the circumference do not intersect");return ht}u(c,"intersect_circle"),s.intersect_circle=c;function E(p){return A=>A===0?p[0]:A===1?p[1]:d.Geometry.Point.translate(p[0],d.Geometry.Angle.line(p),d.Geometry.Line.length(p)*A)}u(E,"interpolate"),s.interpolate=E})(t.Line||(t.Line={}));let e;(s=>{function i(a){return a/180*Math.PI}u(i,"toRad"),s.toRad=i;function n(a){return a*180/Math.PI}u(n,"toDeg"),s.toDeg=n;function r(a){if(a.length!==2||!Array.isArray(a[0])||!Array.isArray(a[1])||a[0].length!==2||a[1].length!==2)throw new Error("Invalid line format. Expected [[x1, y1], [x2, y2]].");return d.Geometry.Angle.toDeg(Math.atan2(a[1][1]-a[0][1],a[1][0]-a[0][0]))}u(r,"line"),s.line=r})(e=t.Angle||(t.Angle={}))})(d.Geometry||(d.Geometry={})),(t=>{function e(n){return[...new Set(n)]}u(e,"unique"),t.unique=e;function s(n,r){if(Array.isArray(n)){if(Array.isArray(r)){if(n.length!==r.length)throw new Error("Arrays must be of equal length");return n.map((a,h)=>a/r[h])}return n.map(a=>a/r)}return n/r}u(s,"divide"),t.divide=s;function i(n){return typeof Array.isArray=="function"?Array.isArray(n):n&&typeof n=="object"&&n.constructor.name==="Array"}u(i,"isArray"),t.isArray=i})(d.ArrayTools||(d.ArrayTools={})),(t=>{function e(n){return n.reduce((r,a)=>r+a,0)}u(e,"sum"),t.sum=e;function s(n){return e(n)/n.length}u(s,"mean"),t.mean=s;function i(n,r){const a=Math.pow(10,r);return Math.round(n*a)/a}u(i,"round"),t.round=i})(d.Mathematics||(d.Mathematics={})),(t=>{function e(s,i,n){return new CustomEvent(s,{bubbles:!0,cancelable:!0,detail:{element:i,data:n||(i?i.__data__:void 0)}})}u(e,"createEvent"),t.createEvent=e})(d.Events||(d.Events={})),(t=>{function e(){return location.hash.replace(/#/,"").split(/\//).filter(i=>i).map(i=>i.split(/:/))}u(e,"parts"),t.parts=e;function s(i){return e().flat().findIndex(n=>n===i)>=0}u(s,"exists"),t.exists=s})(d.Hash||(d.Hash={})),(t=>{function e(n,r,a=!1){if(a){if(typeof n!="object"||n===null)return n;for(const h in n)Object.prototype.hasOwnProperty.call(n,h)&&(n[h]=e(n[h],r,a));return new Proxy(n,r)}else return new Proxy(n,r)}u(e,"proxy"),t.proxy=e,t.handler={set(n,r,a){return n[r]=a,window.dispatchEvent(d.Events.createEvent("settingUpdate",window,{target:n,property:r,value:a})),!0},get(n,r){return n[r]}};function s(n,r){const a=r.split(".");let h=n;for(const o of a)if(h&&typeof h=="object"&&Object.prototype.hasOwnProperty.call(h,o))h=h[o];else return;return h}u(s,"get"),t.get=s;function i(n,r,a){const h=r.split(".");let o=n,l;for(l=0;l<h.length-1;l++){const _=h[l];if(o&&typeof o=="object")Object.prototype.hasOwnProperty.call(o,_)||(o[_]={}),o=o[_];else return!1}return o&&typeof o=="object"?(o[h[l]]=a,!0):!1}u(i,"set"),t.set=i})(d.Objects||(d.Objects={})),(t=>{function e(s=window.location){return Object.fromEntries(new URLSearchParams(s.search))}u(e,"parse"),t.parse=e,(s=>{function i(a=window.location.search){return Object.fromEntries(a.replace(/^\?/,"").split(/&/).map(h=>h.split(/=/)))}u(i,"parse2"),s.parse=i;function n(a=window.location.search){return a.replace(/^\?/,"").split(/&/).map(h=>h.split(/=/)[0])}u(n,"keys"),s.keys=n;function r(a,h=window.location.search){return n(h).findIndex(o=>o===a)>=0}u(r,"has"),s.has=r})(t.Query||(t.Query={}))})(d.URL||(d.URL={}))})(ee||(ee={}));const hs=class hs{constructor(){this._state=new Map,this.listeners=new Map}get state(){return this._state}hasVariable(t){return this._state.has(t)}getVariable(t){return this._state.get(t)}setVariable(t,e,s){const i=this._state.get(t);this._state.set(t,e),s!=null&&s.lazy||this.notifyListeners(t,e,i)}addListener(t,e,s){this.listeners.has(t)||this.listeners.set(t,new Map);const i=this.listeners.get(t);i.has(e)||i.set(e,new Set),i.get(e).add(s)}removeListener(t,e,s){var i,n;(n=(i=this.listeners.get(t))==null?void 0:i.get(e))==null||n.delete(s)}getListeners(t,e){var s;return Array.from(((s=this.listeners.get(t))==null?void 0:s.get(e))??[])}notifyListeners(t,e,s){const i=this.listeners.get(t);if(i)for(const n of i.values())n.forEach(r=>{typeof r=="function"?r({key:t,newValue:e,oldValue:s}):typeof r.calculate=="function"&&r.calculate.call(r,{key:t,newValue:e,oldValue:s})})}};u(hs,"EventBus");let Me=hs;const{ArrayTools:Es}=ee,Ae=class Ae extends Array{constructor(...t){super(...t)}search(t,e){let s;function i(r){return r.name===e?r:void 0}u(i,"fn");function n(r,a,h=null){if(Es.isArray(r)){for(const[o,l]of r.entries())if(s=n(l,o,h),s)return s}else{if(s=i(r),s)return s;if(r&&Es.isArray(r[t])){for(const[o,l]of r[t].entries())if(s=n(l,o,r),s)return s}}return s}return u(n,"recurse"),n(this)}flatten(){return this.reduce((t,e)=>(t.push(e),e.layers&&Array.isArray(e.layers)&&t.push(...e.layers),t),[])}recurse(t,e,s=null,i=0){let n=new Ae;for(const r of this){let a=e(r,s,i);if(r[t]&&Array.isArray(r[t])){let h=new Ae(...r[t]).recurse(t,e,r,i+1);h!==void 0&&n.push(...h)}n.push(a)}return console.log("Recurse results: ",n),n}};u(Ae,"LayerArray");let jt=Ae;const ls=class ls{constructor(t,e,s){this.__state__=new Me,this.scale_x=1,this.scale_y=1,this.scale_objects=!0,this.layers=new jt,this.objects=new Map,this.visible=!0,this.ID=t,this.name=e.name||`layer-${t}`,this.tabindex=e.tabindex,this.parent=s,this._transform=new te,s==null||s.__state__.addListener("graph_updated","live",({key:i,newValue:n,oldValue:r})=>{}),s==null||s.__state__.addListener(`graph_updated_${this.name}`,"live",({key:i,newValue:n,oldValue:r})=>{this.objects=n,this.__state__.setVariable("layer_updated",this)})}get transform(){return this._transform}set transform(t){this._transform=t}};u(ls,"Layer");let Ke=ls;const Le=class Le extends Array{constructor(...e){super(arguments.length);it(this,Tt,!1);it(this,Et);for(let s=0;s<e.length;s++)this[s]=e[s];W(this,Tt,!1)}static fromArray(e){const s=new Le;return e.forEach((i,n)=>{s.push(i)}),W(s,Et,e.names),s}flip(){W(this,Tt,!C(this,Tt));for(let e=0;e<this.length;e++)this[e]=-this[e];return this}get(e){return typeof e=="number"?this[e]:C(this,Et)&&C(this,Et).includes(e)?this[C(this,Et).indexOf(e)]:void 0}get flipped(){return C(this,Tt)}get names(){return C(this,Et)?C(this,Et):this.map((e,s)=>`V${s+1}`)}};Tt=new WeakMap,Et=new WeakMap,u(Le,"DimensionVector");let Pt=Le;const cs=class cs{constructor(t,e){this.scale_x=1,this.scale_y=1,this.scale_size=.05,this.active=!1,this.visible=!1,this.highlighting=!1,this.meta={},this._x=0,this._y=0,this._highlight_default=new tt("#000000"),this._size=0,this.ID=e.ID,this._transform=new te,t instanceof Pt?this._dimensions=t:t instanceof B?this._dimensions=Pt.fromArray(t):Array.isArray(t)?this._dimensions=new Pt(...t):(console.warn("Invalid dimensions provided, using default DimensionVector(0, 0)"),this._dimensions=new Pt(0,0));let s={...e};this._original={...s},this.ID=s.ID,this.x=s.x||this._dimensions[0],this.y=s.y||this._dimensions[1],this._size=s.size||1,this._color=s.color||new tt("#000000"),this.active=s.active||!1,this.shape=s.shape||null,this.meta=s.meta||{},this._highlight=this._highlight_default,s.highlight&&(this._highlight=s.highlight)}get dimensions(){return this._dimensions}get color(){return this.highlighting&&this._highlight?this._highlight:this._color}set color(t){this._color=t}get highlight(){return this._highlight||this._highlight_default}set highlight(t){this._highlight=t}get size(){return this._size}set size(t){this._size=t}get original(){return this._original}get x(){return this._x}get y(){return this._y}set x(t){this._x=t}set y(t){this._y=t}dimension(t){return this._dimensions.get(t)}get transform(){return this._transform}set transform(t){this._transform=t}};u(cs,"PlottedObject");let Nt=cs;const _s=class _s extends Nt{constructor(t,e,s){super([],{}),this.from=e,this.to=s}get line(){return[[this.from.x,this.from.y],[this.to.x,this.to.y]]}get midpoint(){return[(this.from.x+this.to.x)/2,(this.from.y+this.to.y)/2]}get length(){return Math.sqrt(Math.pow(this.to.x-this.from.x,2)+Math.pow(this.to.y-this.from.y,2))}get color(){return this._color}set color(t){this._color=t}};u(_s,"Line");let Yt=_s;const ve=class ve extends Nt{constructor(t){var n,r;let e,s,i;t?t instanceof B?(e=(n=t.classes)==null?void 0:n.map((a,h)=>a==="ena.co.occurrence"||a==="ena.dimension"?t[h]:-1).filter(a=>a!==-1),s=(r=t.classes)==null?void 0:r.map((a,h)=>a==="ena.metadata"?[t.names[h],t[h]]:null).filter(a=>a!==null).reduce((a,h)=>(a[h[0]]=h[1],a),{}),i=t.rowName||`point-${Math.random().toString(36).substring(2,9)}`):typeof t=="object"?(e=t.dimensions||[],s=t.meta||{},i=t.ID||`point-${Math.random().toString(36).substring(2,9)}`):(console.warn("Invalid data provided for Point, using default values"),e=[],s={},i=`point-${Math.random().toString(36).substring(2,9)}`):(e=[],s={},i=`point-${Math.random().toString(36).substring(2,9)}`),super(e??[],{meta:s,ID:i}),this.edges=new Map,this.shape=ve.SHAPES.CIRCLE}set label(t){this._label=t}get label(){return this._label}get x(){return this._x}get y(){return this._y}set x(t){this._x=parseFloat(t)}set y(t){this._y=parseFloat(t)}};u(ve,"Point"),ve.SHAPES={CIRCLE:"circle",SQUARE:"rect"};let J=ve;const Ht=class Ht extends Nt{constructor(t,e){super(e.dimensions,e),this._visible=!1,this.offset=0,this.text=t,this.ID=e.ID,this.object=e,this.x=this.dimensions[0],this.y=this.dimensions[1],this.offset=e.size||0,this.size=this.offset/4,this.visible=!1,this._transform.set("e",1),this._transform.set("f",1)}get x(){return parseFloat(this._x)}get y(){return parseFloat(this._y)}set x(t){this._x=t}set y(t){this._y=t}get transform(){return console.warn("transform is disabled - need updated reference for the graph options"),this._transform}set transform(t){this._transform=t}};u(Ht,"Label"),Ht.DISPLAY_TYPES={OFF:0,AUTO:1,CLICK:2,ON:3},Ht.HIGHLIGHT={OFF:0,ON:2},Ht.POSITION={OBJECT:1,STATIC:2,CONTAINER:3,CUSTOM:4};let H=Ht;const us=class us{constructor(t,e,s=0,i=0){this.x_max=t,this.y_max=e,this.cx=s,this.cy=i}as_viewBox(t=1.2){let e=this.x_max*t,s=this.y_max*t;return`${this.cx-e} ${this.cy-s} ${e*2} ${s*2}`}get height(){return this.y_max*2}get width(){return this.x_max*2}get top(){return this.y_max*-1}get bottom(){return this.y_max}get left(){return this.x_max*-1}get right(){return this.x_max}};u(us,"Extremes");let Rt=us;const ds=class ds extends Nt{constructor(t,e){super(t,e),this.visible=!0,this.size=e.size}set size(t){this._size=t}get size(){return this._size}get x(){return this._x}get y(){return this._y}set x(t){this._x=t}set y(t){this._y=t}get transform(){return this._transform}};u(ds,"AxisPoint");let Je=ds,Ms={GRAPH:{ratio:1,x_max:1,y_max:1,selector:"body",width:1,height:1,axes:!0,SIZE_EFFECT:1,dimensions:[0,1]},NODE:{size:1,highlight:{color:"yellow",labels:H.DISPLAY_TYPES.ON},labels:H.DISPLAY_TYPES.ON,labelposition:H.POSITION.OBJECT},POINT:{active:2,size:.05,color:"#000",shape:J.SHAPES.CIRCLE,labels:H.DISPLAY_TYPES.AUTO,labelposition:H.POSITION.OBJECT},MEAN:{shape:J.SHAPES.SQUARE,labels:H.DISPLAY_TYPES.AUTO},LABEL:{highlight:H.HIGHLIGHT.OFF,position:["top","left"],container:"#label-container"},EDGE:{multiplier:1}};const gs=class gs{constructor(t={...Ms}){this.__state__=new Me,this.name="unnamed-graph",this.origin=void 0,this.points=new Map,this.nodes=new Map,this.edges=new Map,this.trajectories=new Map,this.labels=new Map,this.transform=new te,this.scale_x=1,this.scale_y=1,this.SIZE_EFFECT=1,this._mirror_y=!0,this._mirror_x=!1,this._layers=new jt({name:"graph",tabindex:0,layers:[{name:"axes",layers:[{name:"axis_lines",tabindex:0,layers:[],objects:[]},{name:"axis_labels",tabindex:0,layers:[],objects:[]},{name:"axis_points",tabindex:0,layers:[],objects:[this.origin]}]},{name:"network",layers:[{name:"edges",layers:[],tabindex:0},{name:"nodes",layers:[],tabindex:0},{name:"edgenodes",layers:[],tabindex:0}]},{name:"trajectories",layers:[],tabindex:0},{name:"points",layers:[],tabindex:0},{name:"labels",layers:[],tabindex:0}]}),this.options=t,this.origin=new Je(new Pt(0,0),{ID:"origin",x:0,y:0,size:0,meta:{},graph:this,color:new tt("#FFFFFF"),highlight:new tt("#FFFFFF"),active:!1});let e=1;function s(r,a,h){const o=new Ke(`${e}`,r,h);return e+=1,o.parent=a||void 0,r.layers&&Array.isArray(r.layers)&&(o.layers=new jt(...r.layers.map(l=>s(l,o,h)))),o}u(s,"buildLayerTree"),this.layers=new jt(...this._layers.map(r=>s(r,null,this)));let i=this.layers.search("layers","axis_points");i&&i.objects.set(this.origin.ID,this.origin);let n=this.layers.search("layers","axis_lines");if(n){let r=this.extremes||new Rt(1,1),a=new Yt({},new J({ID:"axis-x-start",dimensions:[-r.x_max,0],classes:["ena.dimension","ena.dimension"]}),new J({ID:"axis-x-end",dimensions:[r.x_max,0],classes:["ena.dimension","ena.dimension"]}));a.ID="axis-x",n.objects.set(a.ID,a);let h=new Yt({},new J({ID:"axis-y-start",dimensions:[0,-r.y_max],classes:["ena.dimension","ena.dimension"]}),new J({ID:"axis-y-end",dimensions:[0,r.y_max],classes:["ena.dimension","ena.dimension"]}));h.ID="axis-y",n.objects.set(h.ID,h),console.log("Added axis lines to layer: ",n)}this.extremes=new Rt(t.GRAPH.x_max,t.GRAPH.y_max)}set extremes(t){this._extremes=t}get extremes(){return this._extremes}get mirror_x(){return this._mirror_x}set mirror_x(t){this._mirror_x=t}get mirror_y(){return this._mirror_y}set mirror_y(t){this._mirror_y=t}x_mirror(){return this.mirror_x?-1:1}y_mirror(){return this.mirror_y?-1:1}add_point(t){const e=new J(t);this.points.set(e.ID,e)}add_points(t){let e=this;t.rows().forEach(s=>{e.add_point(s)})}add_nodes(t){let e=this;t.forEach(s=>{s.label=new H(s.ID,s),e.labels.set(s.label.ID,s.label),e.nodes.set(s.ID,s);const i=e.layers.search("layers","nodes");i&&i.objects.push(s)}),e.update_extremes()}add_edge(t,e,s){return this.edges.set(t.ID,t),this.add_nodes([e||t.from,s||t.to]),t}add_edges(t){let e=t.map(i=>this.add_edge(i));const s=this.layers.search("layers","edges");return s&&s.objects.push(...e),e}update_extremes(t=!1){const e=[this.layers.search("layers","points"),this.layers.search("layers","nodes")].filter(s=>s!==void 0);if(e.length===0)this.extremes=new Rt(1,1);else{let s=1/0,i=-1/0,n=1/0,r=-1/0;e.forEach(g=>g.objects.forEach(c=>{Number.isFinite(c.x)&&(s=Math.min(s,c.x),i=Math.max(i,c.x)),Number.isFinite(c.y)&&(n=Math.min(n,c.y),r=Math.max(r,c.y))}));const a=Number.isFinite(s)&&Number.isFinite(n),h=t&&a?(s+i)/2:0,o=t&&a?(n+r)/2:0,l=a?Math.max(Math.abs(s-h),Math.abs(i-h),Math.abs(n-o),Math.abs(r-o)):0,_=(l>0?l:1)*1.3;this.extremes=new Rt(_,_,h,o)}}nodeExtentFrom(t,e){const s=this.layers.search("layers","nodes");let i=0;return s==null||s.objects.forEach(n=>{Number.isFinite(n.x)&&Number.isFinite(n.y)&&(i=Math.max(i,Math.abs(n.x-t),Math.abs(n.y-e)))}),i}base_point_size(t=8){let e=Math.min(this.extremes.x_max,this.extremes.y_max),s=this.points.size+this.nodes.size;return Math.min(1,e/(Math.sqrt(s)*t))}};u(gs,"Graph");let Ie=gs;const Te=class Te extends HTMLElement{constructor(){super(),this.element=null,this.object=null;const t=this,e=t.attachShadow({mode:"open"}),s=document.createElement("style"),i=document.createElement("div");s.textContent=this.constructor.style,e.appendChild(s),i.setAttribute("class","wrapper"),e.appendChild(i)}get wrapper(){const t=this,e=t.shadowRoot;return e==null?void 0:e.querySelector(".wrapper")}};u(Te,"DrawableElement"),Te.style=`
|
|
8
|
+
`;let Qt=Ht;customElements.define(Qt.tagName,Qt);const Le=class Le{constructor(t){return this.base=typeof t=="string"?t:t.base,new Proxy(this,{get(e,s){if(typeof s=="string"&&/^[0-2]$/.test(s)){const{r:i,g:n,b:r}=Le.parseColor(e.base);return[i,n,r][Number(s)]}return e[s]}})}toString(){return this.base}setBase(t){this.base=t}static parseColor(t){if(t.startsWith("#")){const e=parseInt(t.slice(1),16);return{r:e>>16&255,g:e>>8&255,b:e&255}}throw new Error("Unsupported color format")}static rgb(t,e,s){return`rgb(${t}, ${e}, ${s})`}};u(Le,"Color");let et=Le;const Ae=class Ae extends et{constructor(t,e,s){super(t),this.weight=e,this.alpha=s}static toHSV(t){const{r:e,g:s,b:i}=et.parseColor(t),n=e/255,r=s/255,a=i/255,h=Math.max(n,r,a),o=Math.min(n,r,a),l=h-o,_=h,g=h===0?0:l/h;let c=0;if(l>0)switch(h){case n:c=((r-a)/l+(r<a?6:0))/6;break;case r:c=((a-n)/l+2)/6;break;default:c=((n-r)/l+4)/6}return{h:c*360,s:g,v:_}}static hsvToRgba(t,e,s,i){const n=s*e,r=n*(1-Math.abs(t/60%2-1)),a=s-n;let h=0,o=0,l=0;return t<60?(h=n,o=r,l=0):t<120?(h=r,o=n,l=0):t<180?(h=0,o=n,l=r):t<240?(h=0,o=r,l=n):t<300?(h=r,o=0,l=n):(h=n,o=0,l=r),`rgba(${Math.round((h+a)*255)},${Math.round((o+a)*255)},${Math.round((l+a)*255)},${i.toFixed(4)})`}toString(){const{h:t,v:e}=Ae.toHSV(this.base),s=Math.min(1,Math.abs(this.weight)),i=this.alpha===void 0?s:Math.min(1,Math.max(0,this.alpha));return Ae.hsvToRgba(t,s,e,i)}};u(Ae,"WeightedColor");let te=Ae;const hs=class hs{constructor(t=null){this._values=[1,0,0,1,0,0],this._keys=["a","b","c","d","e","f"],t&&(this.values=t)}get values(){return this._values}set values(t){t&&t.length===6&&(this._values=t)}get keys(){return this._keys}set keys(t){t&&t.length===6&&(this._keys=t)}toString(){return`matrix(${this.keys.map((e,s)=>this.values[s]).join(" ")})`}toMatrix(){return Object.fromEntries(this._keys.map((t,e)=>[t,this._values[e]]))}toArray(){return this._values}set(t,e){e!==.0075&&e!==0&&(this._values[this._keys.findIndex(s=>s===t)]=e)}get(t){return this._values[this._keys.findIndex(e=>e===t)]}scale(t,e=t){this.a=t,this.d=e}zoom(t){this.a=t,this.d=t}pan(t,e){this.e=this.e+t,this.f=this.f+e}set a(t){this.set("a",t)}set b(t){this.set("b",t)}set c(t){this.set("c",t)}set d(t){this.set("d",t)}set e(t){this.set("e",t)}set f(t){this.set("f",t)}get a(){return this.get("a")}get b(){return this.get("b")}get c(){return this.get("c")}get d(){return this.get("d")}get e(){return this.get("e")}get f(){return this.get("f")}};u(hs,"Transform");let ee=hs;var se;(d=>{(t=>{function e(s){return`matrix(${["a","b","c","d","e","f"].map(n=>s[n]).join(" ")})`}u(e,"matrixString"),t.matrixString=e})(d.Matrix||(d.Matrix={})),(t=>{(s=>{function i(r,a,h){const o=e.toRad(a);return[r[0]+h*Math.cos(o),r[1]+h*Math.sin(o)]}u(i,"translate"),s.translate=i;function n(r,a,h){const o=e.toRad(a);function l(_,g){return[_[0]*Math.cos(g)-_[1]*Math.sin(g),_[0]*Math.sin(g)+_[1]*Math.cos(g)]}if(u(l,"rotatePoint"),!h||h[0]===0&&h[1]===0)return l(r,o);{const _=r.map((c,M)=>c-h[M]);return l(_,o).map((c,M)=>c+h[M])}}u(n,"rotate"),s.rotate=n})(t.Point||(t.Point={})),(s=>{function i(f,v){return(v[1]-f[1])/(v[0]-f[0])}u(i,"slope"),s.slope=i;function n(f,v){const R=i(f,v);return f[1]-R*f[0]}u(n,"intercept"),s.intercept=n;function r(f,v){return{slope:i(f,v),intercept:n(f,v)}}u(r,"slopeIntercept"),s.slopeIntercept=r;function a(f,v=0){const R=v,q=(1-R)*f[0][0]+R*f[1][0],G=(1-R)*f[0][1]+R*f[1][1];return[q,G]}u(a,"point_along"),s.point_along=a;function h(f,v,R=.5){return Array.isArray(f[0])&&(v=f[1],f=f[0]),[0,1].map(q=>(parseFloat(f[q])+parseFloat(v[q]))*R)}u(h,"midpoint"),s.midpoint=h;function o(f,v){return Array.isArray(f[0])&&(v=f[1],f=f[0]),Math.sqrt([0,1].map(R=>Math.pow(v[R]-f[R],2)).reduce((R,q)=>R+q,0))}u(o,"length"),s.length=o;function l(f,v=[0,0]){const R=[f[1][0]-v[0],f[1][1]-v[1]],q=[-R[1],R[0]],G=[-q[0],-q[1]],S=[q[0]+v[0],q[1]+v[1]],Y=[G[0]+v[0],G[1]+v[1]];return[S,Y]}u(l,"rotate"),s.rotate=l;function _(f,v,R=90){const q=d.Geometry.Line.slope(f[0],f[1]),G=d.Geometry.Line.intercept(f[0],f[1]),S=[0,G],Y=[1,q+G];f=[S,Y];const ot=[f[0][0],f[1][0]],ht=[f[0][1],f[1][1]],nt=v[0],dt=v[1],J=-2*Math.PI*R/360,$t=ot.map((Xe,gt)=>(Xe-nt)*Math.cos(J)-(ht[gt]-dt)*Math.sin(J)+nt),zt=ht.map((Xe,gt)=>(ot[gt]-nt)*Math.sin(J)-(Xe-dt)*Math.cos(J)+dt);return[[$t[0],zt[0]],[$t[1],zt[1]]]}u(_,"rotate2"),s.rotate2=_;function g(f,v){const[[R,q],[G,S]]=f,[[Y,ot],[ht,nt]]=v,dt=(R-G)*(ot-nt)-(q-S)*(Y-ht),J=(R*S-q*G)*(Y-ht)-(R-G)*(Y*nt-ot*ht),$t=(R*S-q*G)*(ot-nt)-(q-S)*(Y*nt-ot*ht);return[J/dt,$t/dt]}u(g,"intersection"),s.intersection=g;function c(f,v,R){let{slope:q,intercept:G}=d.Geometry.Line.slopeIntercept(f[0],f[1]),S=1+Math.pow(q,2),Y=2*q*G-2*v[1]*q-2*v[0],ot=Math.pow(v[0],2)+Math.pow(G,2)+Math.pow(v[1],2)-2*v[1]*G-Math.pow(R,2),ht=[[1/0,1/0],[1/0,1/0]];if(Math.sqrt(Math.pow(Y,2)-4*S*ot)>=0){let nt=(-Y+Math.sqrt(Math.pow(Y,2)-4*S*ot))/(2*S),dt=(-Y-Math.sqrt(Math.pow(Y,2)-4*S*ot))/(2*S),J=q*nt+G,$t=q*dt+G;ht=[[nt,J],[dt,$t]]}else console.error("The line and the circumference do not intersect");return ht}u(c,"intersect_circle"),s.intersect_circle=c;function M(f){return v=>v===0?f[0]:v===1?f[1]:d.Geometry.Point.translate(f[0],d.Geometry.Angle.line(f),d.Geometry.Line.length(f)*v)}u(M,"interpolate"),s.interpolate=M})(t.Line||(t.Line={}));let e;(s=>{function i(a){return a/180*Math.PI}u(i,"toRad"),s.toRad=i;function n(a){return a*180/Math.PI}u(n,"toDeg"),s.toDeg=n;function r(a){if(a.length!==2||!Array.isArray(a[0])||!Array.isArray(a[1])||a[0].length!==2||a[1].length!==2)throw new Error("Invalid line format. Expected [[x1, y1], [x2, y2]].");return d.Geometry.Angle.toDeg(Math.atan2(a[1][1]-a[0][1],a[1][0]-a[0][0]))}u(r,"line"),s.line=r})(e=t.Angle||(t.Angle={}))})(d.Geometry||(d.Geometry={})),(t=>{function e(n){return[...new Set(n)]}u(e,"unique"),t.unique=e;function s(n,r){if(Array.isArray(n)){if(Array.isArray(r)){if(n.length!==r.length)throw new Error("Arrays must be of equal length");return n.map((a,h)=>a/r[h])}return n.map(a=>a/r)}return n/r}u(s,"divide"),t.divide=s;function i(n){return typeof Array.isArray=="function"?Array.isArray(n):n&&typeof n=="object"&&n.constructor.name==="Array"}u(i,"isArray"),t.isArray=i})(d.ArrayTools||(d.ArrayTools={})),(t=>{function e(n){return n.reduce((r,a)=>r+a,0)}u(e,"sum"),t.sum=e;function s(n){return e(n)/n.length}u(s,"mean"),t.mean=s;function i(n,r){const a=Math.pow(10,r);return Math.round(n*a)/a}u(i,"round"),t.round=i})(d.Mathematics||(d.Mathematics={})),(t=>{function e(s,i,n){return new CustomEvent(s,{bubbles:!0,cancelable:!0,detail:{element:i,data:n||(i?i.__data__:void 0)}})}u(e,"createEvent"),t.createEvent=e})(d.Events||(d.Events={})),(t=>{function e(){return location.hash.replace(/#/,"").split(/\//).filter(i=>i).map(i=>i.split(/:/))}u(e,"parts"),t.parts=e;function s(i){return e().flat().findIndex(n=>n===i)>=0}u(s,"exists"),t.exists=s})(d.Hash||(d.Hash={})),(t=>{function e(n,r,a=!1){if(a){if(typeof n!="object"||n===null)return n;for(const h in n)Object.prototype.hasOwnProperty.call(n,h)&&(n[h]=e(n[h],r,a));return new Proxy(n,r)}else return new Proxy(n,r)}u(e,"proxy"),t.proxy=e,t.handler={set(n,r,a){return n[r]=a,window.dispatchEvent(d.Events.createEvent("settingUpdate",window,{target:n,property:r,value:a})),!0},get(n,r){return n[r]}};function s(n,r){const a=r.split(".");let h=n;for(const o of a)if(h&&typeof h=="object"&&Object.prototype.hasOwnProperty.call(h,o))h=h[o];else return;return h}u(s,"get"),t.get=s;function i(n,r,a){const h=r.split(".");let o=n,l;for(l=0;l<h.length-1;l++){const _=h[l];if(o&&typeof o=="object")Object.prototype.hasOwnProperty.call(o,_)||(o[_]={}),o=o[_];else return!1}return o&&typeof o=="object"?(o[h[l]]=a,!0):!1}u(i,"set"),t.set=i})(d.Objects||(d.Objects={})),(t=>{function e(s=window.location){return Object.fromEntries(new URLSearchParams(s.search))}u(e,"parse"),t.parse=e,(s=>{function i(a=window.location.search){return Object.fromEntries(a.replace(/^\?/,"").split(/&/).map(h=>h.split(/=/)))}u(i,"parse2"),s.parse=i;function n(a=window.location.search){return a.replace(/^\?/,"").split(/&/).map(h=>h.split(/=/)[0])}u(n,"keys"),s.keys=n;function r(a,h=window.location.search){return n(h).findIndex(o=>o===a)>=0}u(r,"has"),s.has=r})(t.Query||(t.Query={}))})(d.URL||(d.URL={}))})(se||(se={}));const ls=class ls{constructor(){this._state=new Map,this.listeners=new Map}get state(){return this._state}hasVariable(t){return this._state.has(t)}getVariable(t){return this._state.get(t)}setVariable(t,e,s){const i=this._state.get(t);this._state.set(t,e),s!=null&&s.lazy||this.notifyListeners(t,e,i)}addListener(t,e,s){this.listeners.has(t)||this.listeners.set(t,new Map);const i=this.listeners.get(t);i.has(e)||i.set(e,new Set),i.get(e).add(s)}removeListener(t,e,s){var i,n;(n=(i=this.listeners.get(t))==null?void 0:i.get(e))==null||n.delete(s)}getListeners(t,e){var s;return Array.from(((s=this.listeners.get(t))==null?void 0:s.get(e))??[])}notifyListeners(t,e,s){const i=this.listeners.get(t);if(i)for(const n of i.values())n.forEach(r=>{typeof r=="function"?r({key:t,newValue:e,oldValue:s}):typeof r.calculate=="function"&&r.calculate.call(r,{key:t,newValue:e,oldValue:s})})}};u(ls,"EventBus");let Ie=ls;const{ArrayTools:Ms}=se,ve=class ve extends Array{constructor(...t){super(...t)}search(t,e){let s;function i(r){return r.name===e?r:void 0}u(i,"fn");function n(r,a,h=null){if(Ms.isArray(r)){for(const[o,l]of r.entries())if(s=n(l,o,h),s)return s}else{if(s=i(r),s)return s;if(r&&Ms.isArray(r[t])){for(const[o,l]of r[t].entries())if(s=n(l,o,r),s)return s}}return s}return u(n,"recurse"),n(this)}flatten(){return this.reduce((t,e)=>(t.push(e),e.layers&&Array.isArray(e.layers)&&t.push(...e.layers),t),[])}recurse(t,e,s=null,i=0){let n=new ve;for(const r of this){let a=e(r,s,i);if(r[t]&&Array.isArray(r[t])){let h=new ve(...r[t]).recurse(t,e,r,i+1);h!==void 0&&n.push(...h)}n.push(a)}return console.log("Recurse results: ",n),n}};u(ve,"LayerArray");let Yt=ve;const cs=class cs{constructor(t,e,s){this.__state__=new Ie,this.scale_x=1,this.scale_y=1,this.scale_objects=!0,this.layers=new Yt,this.objects=new Map,this.visible=!0,this.ID=t,this.name=e.name||`layer-${t}`,this.tabindex=e.tabindex,this.parent=s,this._transform=new ee,s==null||s.__state__.addListener("graph_updated","live",({key:i,newValue:n,oldValue:r})=>{}),s==null||s.__state__.addListener(`graph_updated_${this.name}`,"live",({key:i,newValue:n,oldValue:r})=>{this.objects=n,this.__state__.setVariable("layer_updated",this)})}get transform(){return this._transform}set transform(t){this._transform=t}};u(cs,"Layer");let Je=cs;const Te=class Te extends Array{constructor(...e){super(arguments.length);it(this,Dt,!1);it(this,Mt);for(let s=0;s<e.length;s++)this[s]=e[s];X(this,Dt,!1)}static fromArray(e){const s=new Te;return e.forEach((i,n)=>{s.push(i)}),X(s,Mt,e.names),s}flip(){X(this,Dt,!C(this,Dt));for(let e=0;e<this.length;e++)this[e]=-this[e];return this}get(e){return typeof e=="number"?this[e]:C(this,Mt)&&C(this,Mt).includes(e)?this[C(this,Mt).indexOf(e)]:void 0}get flipped(){return C(this,Dt)}get names(){return C(this,Mt)?C(this,Mt):this.map((e,s)=>`V${s+1}`)}};Dt=new WeakMap,Mt=new WeakMap,u(Te,"DimensionVector");let Rt=Te;const _s=class _s{constructor(t,e){this.scale_x=1,this.scale_y=1,this.scale_size=.05,this.active=!1,this.visible=!1,this.highlighting=!1,this.meta={},this._x=0,this._y=0,this._highlight_default=new et("#000000"),this._size=0,this.ID=e.ID,this._transform=new ee,t instanceof Rt?this._dimensions=t:t instanceof B?this._dimensions=Rt.fromArray(t):Array.isArray(t)?this._dimensions=new Rt(...t):(console.warn("Invalid dimensions provided, using default DimensionVector(0, 0)"),this._dimensions=new Rt(0,0));let s={...e};this._original={...s},this.ID=s.ID,this.x=s.x||this._dimensions[0],this.y=s.y||this._dimensions[1],this._size=s.size||1,this._color=s.color||new et("#000000"),this.active=s.active||!1,this.shape=s.shape||null,this.meta=s.meta||{},this._highlight=this._highlight_default,s.highlight&&(this._highlight=s.highlight)}get dimensions(){return this._dimensions}get color(){return this.highlighting&&this._highlight?this._highlight:this._color}set color(t){this._color=t}get highlight(){return this._highlight||this._highlight_default}set highlight(t){this._highlight=t}get size(){return this._size}set size(t){this._size=t}get original(){return this._original}get x(){return this._x}get y(){return this._y}set x(t){this._x=t}set y(t){this._y=t}dimension(t){return this._dimensions.get(t)}get transform(){return this._transform}set transform(t){this._transform=t}};u(_s,"PlottedObject");let kt=_s;const us=class us extends kt{constructor(t,e,s){super([],{}),this.from=e,this.to=s}get line(){return[[this.from.x,this.from.y],[this.to.x,this.to.y]]}get midpoint(){return[(this.from.x+this.to.x)/2,(this.from.y+this.to.y)/2]}get length(){return Math.sqrt(Math.pow(this.to.x-this.from.x,2)+Math.pow(this.to.y-this.from.y,2))}get color(){return this._color}set color(t){this._color=t}};u(us,"Line");let qt=us;const Se=class Se extends kt{constructor(t){var n,r;let e,s,i;t?t instanceof B?(e=(n=t.classes)==null?void 0:n.map((a,h)=>a==="ena.co.occurrence"||a==="ena.dimension"?t[h]:-1).filter(a=>a!==-1),s=(r=t.classes)==null?void 0:r.map((a,h)=>a==="ena.metadata"?[t.names[h],t[h]]:null).filter(a=>a!==null).reduce((a,h)=>(a[h[0]]=h[1],a),{}),i=t.rowName||`point-${Math.random().toString(36).substring(2,9)}`):typeof t=="object"?(e=t.dimensions||[],s=t.meta||{},i=t.ID||`point-${Math.random().toString(36).substring(2,9)}`):(console.warn("Invalid data provided for Point, using default values"),e=[],s={},i=`point-${Math.random().toString(36).substring(2,9)}`):(e=[],s={},i=`point-${Math.random().toString(36).substring(2,9)}`),super(e??[],{meta:s,ID:i}),this.edges=new Map,this.shape=Se.SHAPES.CIRCLE}set label(t){this._label=t}get label(){return this._label}get x(){return this._x}get y(){return this._y}set x(t){this._x=parseFloat(t)}set y(t){this._y=parseFloat(t)}};u(Se,"Point"),Se.SHAPES={CIRCLE:"circle",SQUARE:"rect"};let K=Se;const Xt=class Xt extends kt{constructor(t,e){super(e.dimensions,e),this._visible=!1,this.offset=0,this.text=t,this.ID=e.ID,this.object=e,this.x=this.dimensions[0],this.y=this.dimensions[1],this.offset=e.size||0,this.size=this.offset/4,this.visible=!1,this._transform.set("e",1),this._transform.set("f",1)}get x(){return parseFloat(this._x)}get y(){return parseFloat(this._y)}set x(t){this._x=t}set y(t){this._y=t}get transform(){return console.warn("transform is disabled - need updated reference for the graph options"),this._transform}set transform(t){this._transform=t}};u(Xt,"Label"),Xt.DISPLAY_TYPES={OFF:0,AUTO:1,CLICK:2,ON:3},Xt.HIGHLIGHT={OFF:0,ON:2},Xt.POSITION={OBJECT:1,STATIC:2,CONTAINER:3,CUSTOM:4};let H=Xt;const ds=class ds{constructor(t,e,s=0,i=0){this.x_max=t,this.y_max=e,this.cx=s,this.cy=i}as_viewBox(t=1.2){let e=this.x_max*t,s=this.y_max*t;return`${this.cx-e} ${this.cy-s} ${e*2} ${s*2}`}get height(){return this.y_max*2}get width(){return this.x_max*2}get top(){return this.y_max*-1}get bottom(){return this.y_max}get left(){return this.x_max*-1}get right(){return this.x_max}};u(ds,"Extremes");let Lt=ds;const gs=class gs extends kt{constructor(t,e){super(t,e),this.visible=!0,this.size=e.size}set size(t){this._size=t}get size(){return this._size}get x(){return this._x}get y(){return this._y}set x(t){this._x=t}set y(t){this._y=t}get transform(){return this._transform}};u(gs,"AxisPoint");let Ze=gs,Is={GRAPH:{ratio:1,x_max:1,y_max:1,selector:"body",width:1,height:1,axes:!0,SIZE_EFFECT:1,dimensions:[0,1]},NODE:{size:1,highlight:{color:"yellow",labels:H.DISPLAY_TYPES.ON},labels:H.DISPLAY_TYPES.ON,labelposition:H.POSITION.OBJECT},POINT:{active:2,size:.05,color:"#000",shape:K.SHAPES.CIRCLE,labels:H.DISPLAY_TYPES.AUTO,labelposition:H.POSITION.OBJECT},MEAN:{shape:K.SHAPES.SQUARE,labels:H.DISPLAY_TYPES.AUTO},LABEL:{highlight:H.HIGHLIGHT.OFF,position:["top","left"],container:"#label-container"},EDGE:{multiplier:1}};const ms=class ms{constructor(t={...Is}){this.__state__=new Ie,this.name="unnamed-graph",this.origin=void 0,this.points=new Map,this.nodes=new Map,this.edges=new Map,this.trajectories=new Map,this.labels=new Map,this.transform=new ee,this.scale_x=1,this.scale_y=1,this.SIZE_EFFECT=1,this._mirror_y=!0,this._mirror_x=!1,this._layers=new Yt({name:"graph",tabindex:0,layers:[{name:"axes",layers:[{name:"axis_lines",tabindex:0,layers:[],objects:[]},{name:"axis_labels",tabindex:0,layers:[],objects:[]},{name:"axis_points",tabindex:0,layers:[],objects:[this.origin]}]},{name:"network",layers:[{name:"edges",layers:[],tabindex:0},{name:"nodes",layers:[],tabindex:0},{name:"edgenodes",layers:[],tabindex:0}]},{name:"trajectories",layers:[],tabindex:0},{name:"points",layers:[],tabindex:0},{name:"labels",layers:[],tabindex:0}]}),this.options=t,this.origin=new Ze(new Rt(0,0),{ID:"origin",x:0,y:0,size:0,meta:{},graph:this,color:new et("#FFFFFF"),highlight:new et("#FFFFFF"),active:!1});let e=1;function s(r,a,h){const o=new Je(`${e}`,r,h);return e+=1,o.parent=a||void 0,r.layers&&Array.isArray(r.layers)&&(o.layers=new Yt(...r.layers.map(l=>s(l,o,h)))),o}u(s,"buildLayerTree"),this.layers=new Yt(...this._layers.map(r=>s(r,null,this)));let i=this.layers.search("layers","axis_points");i&&i.objects.set(this.origin.ID,this.origin);let n=this.layers.search("layers","axis_lines");if(n){let r=this.extremes||new Lt(1,1),a=new qt({},new K({ID:"axis-x-start",dimensions:[-r.x_max,0],classes:["ena.dimension","ena.dimension"]}),new K({ID:"axis-x-end",dimensions:[r.x_max,0],classes:["ena.dimension","ena.dimension"]}));a.ID="axis-x",n.objects.set(a.ID,a);let h=new qt({},new K({ID:"axis-y-start",dimensions:[0,-r.y_max],classes:["ena.dimension","ena.dimension"]}),new K({ID:"axis-y-end",dimensions:[0,r.y_max],classes:["ena.dimension","ena.dimension"]}));h.ID="axis-y",n.objects.set(h.ID,h),console.log("Added axis lines to layer: ",n)}this.extremes=new Lt(t.GRAPH.x_max,t.GRAPH.y_max)}set extremes(t){this._extremes=t}get extremes(){return this._extremes}get mirror_x(){return this._mirror_x}set mirror_x(t){this._mirror_x=t}get mirror_y(){return this._mirror_y}set mirror_y(t){this._mirror_y=t}x_mirror(){return this.mirror_x?-1:1}y_mirror(){return this.mirror_y?-1:1}add_point(t){const e=new K(t);this.points.set(e.ID,e)}add_points(t){let e=this;t.rows().forEach(s=>{e.add_point(s)})}add_nodes(t){let e=this;t.forEach(s=>{s.label=new H(s.ID,s),e.labels.set(s.label.ID,s.label),e.nodes.set(s.ID,s);const i=e.layers.search("layers","nodes");i&&i.objects.push(s)}),e.update_extremes()}add_edge(t,e,s){return this.edges.set(t.ID,t),this.add_nodes([e||t.from,s||t.to]),t}add_edges(t){let e=t.map(i=>this.add_edge(i));const s=this.layers.search("layers","edges");return s&&s.objects.push(...e),e}update_extremes(t=!1){const e=[this.layers.search("layers","points"),this.layers.search("layers","nodes")].filter(s=>s!==void 0);if(e.length===0)this.extremes=new Lt(1,1);else{let s=1/0,i=-1/0,n=1/0,r=-1/0;e.forEach(g=>g.objects.forEach(c=>{Number.isFinite(c.x)&&(s=Math.min(s,c.x),i=Math.max(i,c.x)),Number.isFinite(c.y)&&(n=Math.min(n,c.y),r=Math.max(r,c.y))}));const a=Number.isFinite(s)&&Number.isFinite(n),h=t&&a?(s+i)/2:0,o=t&&a?(n+r)/2:0,l=a?Math.max(Math.abs(s-h),Math.abs(i-h),Math.abs(n-o),Math.abs(r-o)):0,_=(l>0?l:1)*1.3;this.extremes=new Lt(_,_,h,o)}}nodeExtentFrom(t,e){const s=this.layers.search("layers","nodes");let i=0;return s==null||s.objects.forEach(n=>{Number.isFinite(n.x)&&Number.isFinite(n.y)&&(i=Math.max(i,Math.abs(n.x-t),Math.abs(n.y-e)))}),i}base_point_size(t=8){let e=Math.min(this.extremes.x_max,this.extremes.y_max),s=this.points.size+this.nodes.size;return Math.min(1,e/(Math.sqrt(s)*t))}};u(ms,"Graph");let Ne=ms;const De=class De extends HTMLElement{constructor(){super(),this.element=null,this.object=null;const t=this,e=t.attachShadow({mode:"open"}),s=document.createElement("style"),i=document.createElement("div");s.textContent=this.constructor.style,e.appendChild(s),i.setAttribute("class","wrapper"),e.appendChild(i)}get wrapper(){const t=this,e=t.shadowRoot;return e==null?void 0:e.querySelector(".wrapper")}};u(De,"DrawableElement"),De.style=`
|
|
9
9
|
:host {
|
|
10
10
|
max-width: 100%;
|
|
11
11
|
display: block;
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
display: flex;
|
|
16
16
|
justify-content: center;
|
|
17
17
|
}
|
|
18
|
-
`;let Ne=Te;const Is=1e-8;function Ze(d,t=Is){return d.filter(e=>Math.abs(e.x)>t||Math.abs(e.y)>t)}u(Ze,"nearOriginFilter");function Ns(d){if(d<=0)return[];if(d===1)return[0];const t=new Array(d);for(let e=0;e<d;e++)t[e]=e/(d-1);return t}u(Ns,"normalizedT");function ks(d,t){return d.map(e=>{const s=new Array(t+1);let i=1;for(let n=0;n<=t;n++)s[n]=i,i*=e;return s})}u(ks,"design");function Cs(d){const t=d.length,e=d[0].length,s=d.map(n=>n.slice()),i=Array.from({length:e},()=>new Array(e).fill(0));for(let n=0;n<e;n++){let r=0;for(let a=0;a<t;a++)r+=s[a][n]*s[a][n];if(r=Math.sqrt(r),i[n][n]=r,r>1e-300)for(let a=0;a<t;a++)s[a][n]/=r;for(let a=n+1;a<e;a++){let h=0;for(let o=0;o<t;o++)h+=s[o][n]*s[o][a];i[n][a]=h;for(let o=0;o<t;o++)s[o][a]-=h*s[o][n]}}return{Q:s,R:i}}u(Cs,"qr");function Qe(d,t){const e=d.length,s=d[0].length,i=new Array(s).fill(0);for(let n=0;n<s;n++){let r=0;for(let a=0;a<e;a++)r+=d[a][n]*t[a];i[n]=r}return i}u(Qe,"qtY");function ts(d,t){const e=t.length,s=new Array(e).fill(0);for(let i=e-1;i>=0;i--){let n=t[i];for(let r=i+1;r<e;r++)n-=d[i][r]*s[r];s[i]=Math.abs(d[i][i])>1e-12?n/d[i][i]:0}return s}u(ts,"backSolve");function hi(d){return d.map(t=>{let e=0;for(let s=0;s<t.length;s++)e+=t[s]*t[s];return e})}u(hi,"leverages");function Os(d,t,e){const s=ks(d,e),{Q:i,R:n}=Cs(s);return ts(n,Qe(i,t))}u(Os,"fitCoeffs");function ke(d,t){let e=0,s=1;for(let i=0;i<d.length;i++)e+=d[i]*s,s*=t;return e}u(ke,"evalPoly");function li(d,t,e,s){const i=ks(d,s),{Q:n,R:r}=Cs(i),a=hi(n),h=ts(r,Qe(n,t)),o=ts(r,Qe(n,e));let l=0;for(let _=0;_<d.length;_++){const g=1-a[_];if(g<=0)return 1/0;const c=t[_]-ke(h,d[_]),E=e[_]-ke(o,d[_]);l+=(c/g)**2+(E/g)**2}return l}u(li,"loocv2d");function $s(d,t,e){const s=d.length,i=Math.min(Math.max(1,Math.floor(t)),Math.max(1,s-1));if(e==="fixed"||s<3)return i;const n=Ns(s),r=d.map(l=>l.x),a=d.map(l=>l.y);let h=1,o=1/0;for(let l=1;l<=i;l++){const _=li(n,r,a,l);_<o&&(o=_,h=l)}return h}u($s,"selectDegree");function Ps(d,t){const e=Ze(d);if(e.length<3)return null;const s=t.selectionSet?Ze(t.selectionSet):e,i=s.length>=3?s:e;let n=$s(i,t.maxDegree,t.degreeSelection);n=Math.min(n,Math.max(1,e.length-1));const r=Ns(e.length),a=Os(r,e.map(o=>o.x),n),h=Os(r,e.map(o=>o.y),n);return{degree:n,coeffsX:a,coeffsY:h}}u(Ps,"fitTrajectory");function es(d,t=100){const e=[];for(let s=0;s<=t;s++){const i=s/t;e.push({x:ke(d.coeffsX,i),y:ke(d.coeffsY,i)})}return e}u(es,"sampleCurve");const Rs=100,ms=class ms extends Nt{constructor(t={}){const e=t.color instanceof tt?t.color:new tt(typeof t.color=="string"?t.color:"#000000");super([],{ID:t.ID||`traj-${Math.random().toString(36).substring(2,9)}`,size:t.size||1,color:e,highlight:null,active:t.active||!1,meta:t.meta||{},...t}),this._typeName="Trajectory",this.trajPoints=[],this.smooth="none",this.maxDegree=3,this.degreeSelection="loocv_2d",this.selectedDegree=-1,this.polyCoeffsX=[],this.polyCoeffsY=[],this.currentTime=1/0,this.showPoints=!0,this.showTips=!0,this.lineStyle="uniform",this.strokeWidth=2,this.strokeWidthRange=[1,6],this.opacityRange=[.3,1],this.smooth=t.smooth||"none",this.maxDegree=t.maxDegree!==void 0?t.maxDegree:3,this.degreeSelection=t.degreeSelection||"loocv_2d",this.polyCoeffsX=t.polyCoeffsX||[],this.polyCoeffsY=t.polyCoeffsY||[],this.currentTime=t.currentTime!==void 0?t.currentTime:1/0,this.showPoints=t.showPoints!==void 0?t.showPoints:!0,this.showTips=t.showTips!==void 0?t.showTips:!0,this.lineStyle=t.lineStyle||"uniform",this.strokeWidth=t.strokeWidth||2,this.strokeWidthRange=t.strokeWidthRange||[1,6],this.opacityRange=t.opacityRange||[.3,1],t.points&&Array.isArray(t.points)&&(this.trajPoints=t.points.map(s=>{if(s instanceof J)return s;const i=new J({dimensions:[s.x,s.y],meta:{time:s.time,label:s.label}});return i.x=s.x,i.y=s.y,i}))}get activePoints(){return this.currentTime===1/0?this.trajPoints:this.trajPoints.filter(t=>(t.meta&&typeof t.meta.time=="number"?t.meta.time:0)<=this.currentTime)}get path(){return this.pathPoints.reduce((t,e,s)=>s===0?`M${e.x},${e.y}`:`${t} L${e.x},${e.y}`,"")}get pathPoints(){const t=this.activePoints;if(t.length<2)return[];if(this.smooth==="poly"){if(this.polyCoeffsX.length>0&&this.polyCoeffsY.length>0)return es({degree:this.polyCoeffsX.length-1,coeffsX:this.polyCoeffsX,coeffsY:this.polyCoeffsY},Rs);const e=Ps(t.map(s=>({x:s.x,y:s.y})),{maxDegree:this.maxDegree,degreeSelection:this.degreeSelection,selectionSet:this.trajPoints.map(s=>({x:s.x,y:s.y}))});if(e)return this.selectedDegree=e.degree,es(e,Rs)}return t.map(e=>({x:e.x,y:e.y}))}};u(ms,"Trajectory");let se=ms;const Ls=1,fs=class fs extends Yt{constructor(t,e,s,i=0){super(t,e,s),this._totalweight=0,this._weight=i}get base_color(){return this._color}get color(){const t=this._color||new tt("#000000");return new Qt(t,Math.abs(this.weight))}set color(t){this._color=t}base_weight(){return this._weight}get weight(){return Array.isArray(this._weight)?this._weight[0]-this._weight[1]:this._weight}set weight(t){this._weight=t}get totalweight(){return this.weight}set totalweight(t){this._totalweight=t}};u(fs,"Edge");let ie=fs;const ps=class ps extends Nt{constructor(e){super(e.dimensions||[],e);it(this,Xt);W(this,Xt,e)}get edge(){return C(this,Xt)}get path(){const e=C(this,Xt),s=[e.to.x,e.to.y],i=e.from_point,[n,r]=e.base_pts,a=Math.hypot(i[0]-s[0],i[1]-s[1]),h=Math.hypot(n[0]-r[0],n[1]-r[1]);if(!(a>0)||!(h>0))return"";const o=[(i[0]-s[0])/a,(i[1]-s[1])/a],l=Math.hypot(n[0]-s[0],n[1]-s[1]),_=[(n[0]-s[0])/l,(n[1]-s[1])/l],g=u(G=>h/2*Math.max(0,1-G/a),"halfW"),c=u((G,v)=>`${s[0]+o[0]*G+_[0]*v} ${s[1]+o[1]*G+_[1]*v}`,"at"),E=.2*a,p=Math.min(.15*a,.8*2*g(E)),A=E+p/2,R=E+p;return`M${c(E,0)} L${c(A,g(A))} L${c(R,g(R))} L${c(A,0)} L${c(R,-g(R))} L${c(A,-g(A))}z`}};Xt=new WeakMap,u(ps,"EdgeArrow");let Ce=ps;const De=class De extends ie{constructor(e,s,i){super(e,s,i);it(this,Wt);it(this,Se);this._path="",W(this,Wt,!1),this._directions=["from","to"],this.towards="to",C(this,Wt)===!0&&W(this,Se,new Ce(this))}get path(){return`M${this.from.x} ${this.from.y} L${this.base_pts[0].join(" ")} L${this.base_pts[1].join(" ")}z`}static calculate_base_points(e){const s=e.towards,i=e._directions.find(A=>A!==e.towards),n=e[i].x,r=e[i].y,a=e[s].x,h=e[s].y,o=a-n,l=h-r,_=Math.hypot(o,l),g=(e.weight??0)*Ls;if(_===0||!isFinite(g)||g===0)return[[a,h],[a,h]];const c=-l/_,E=o/_,p=g/2;return[[a+c*p,h+E*p],[a-c*p,h-E*p]]}get base_pts(){return De.calculate_base_points(this)}get arrow(){return C(this,Se)}get with_arrow(){return C(this,Wt)}get from_point(){return[this.from.x,this.from.y]}};Wt=new WeakMap,Se=new WeakMap,u(De,"TaperedEdge");let qt=De;const ze=class ze extends qt{constructor(t,e,s){super(t,e,s),this._dataWeight=0,this._totalweight=t.totalweight??0,this._dataWeight=t.weight??this._weight}get weighted_midpoint(){return ee.Geometry.Line.interpolate(this.line)(1-this._dataWeight/this._totalweight)}get base_pts(){return qt.calculate_base_points(this)}static build_path(t){return t._totalweight>0?`M${t.weighted_midpoint[0]} ${t.weighted_midpoint[1]} L${t.base_pts[0].join(" ")} L${t.base_pts[1].join(" ")}z`:(console.error("TaperedWeightedMidpointEdge: No totalweight, returning empty path"),"")}get path(){return ze.build_path(this)}get from_point(){return this.weighted_midpoint}};u(ze,"TaperedWeightedMidpointEdge");let ss=ze;const Fe=class Fe extends ie{constructor(t,e,s){super(t,e,s)}static build_path(t,e){let s=t/2,i=e.x-s,n=s*2;return`M ${i}, ${e.y} a ${s},${s} 0 1,0 ${n},0 a ${s},${s} 0 1,0 -${n},0`}get path(){let t=this.weight*Ls;return Fe.build_path(t,this.to)}};u(Fe,"NodeEdge");let ne=Fe;const bs=class bs{constructor(t,e,s,i=new kt){this.__data__=t,this.parent=e,this.graph=s,this.__children__=i,this.svg_element=this.create()}get_size(){return this.__data__.size}draw(){var t;(t=this.parent)==null||t.appendChild(this.svg_element)}update(t,e=!0){}animateSVGAttribute(t,e,s){const i=parseFloat(t.getAttribute(e)||"0");if(i===s)return;const n=5e3,r=performance.now();function a(h){const o=Math.min(1,(h-r)/n),l=i+(s-i)*o;t.setAttribute(e,l.toString()),o<1?requestAnimationFrame(a):t.setAttribute(e,s.toString())}u(a,"animate"),requestAnimationFrame(a)}};u(bs,"Drawable");let re=bs;const ci=.04,_i=[.25,1],ui=[.3,1];function Ts(d,t,e,s){const i=Math.abs(d);if(!(i>0))return 0;if(!(e>t))return s[1];const n=Math.min(1,Math.max(0,(i-t)/(e-t)));return s[0]+n*(s[1]-s[0])}u(Ts,"rampFor");const di=.011,gi=.75,mi=.8,fi=.75,Ds=.006,pi=.6;function bi(d){return 2*d}u(bi,"widthPerWeight");function yi(d,t){return d*t/(2*Ds)}u(yi,"nodeSizeForEdges");function xi(d){const t=/rgba?\(([^)]+)\)/.exec(d);if(!t)return d;const[e,s,i,n=1]=t[1].split(",").map(Number),r=u(a=>Math.round(255+(a-255)*n),"f");return`rgb(${r(e)},${r(s)},${r(i)})`}u(xi,"flattenOnWhite");function wi(d,t){const e=/rgba?\(([^)]+)\)/.exec(d);if(!e)return d;const[s,i,n,r=1]=e[1].split(",").map(Number);return`rgba(${Math.round(s*t)},${Math.round(i*t)},${Math.round(n*t)},${r})`}u(wi,"darkenRgba");const ys=class ys extends re{constructor(t,e,s,i=new kt){super(t,e,s,i),this.__data__=t,this.parent=e,this.graph=s,this.__children__=i,this.__name__="unnamed-line",this._arrow_el=null,this._hit_el=null,this.svg_element=this.create()}_stampEdge(t){const e=this.__data__.meta??{};e.isMeanEdge&&(t.setAttribute("data-edge-source",String(e.source??"")),t.setAttribute("data-edge-target",String(e.target??"")),t.setAttribute("data-edge-weight",String(e.weight??0)),t.setAttribute("data-edge-directed",e.isDirected?"true":"false"),e.isSelf&&t.setAttribute("data-edge-self","true"),e.group!=null&&t.setAttribute("data-edge-group",String(e.group)),e.unit!=null&&t.setAttribute("data-edge-unit",String(e.unit)))}create(){if(this.__data__ instanceof ne){const e=document.createElementNS("http://www.w3.org/2000/svg","path");return e.setAttribute("fill",this.__data__.color.toString()),e.setAttribute("stroke","none"),this.svg_element=e,e}if(this.__data__ instanceof qt){const e=document.createElementNS("http://www.w3.org/2000/svg","path");return e.setAttribute("fill",this.__data__.color.toString()),e.setAttribute("stroke","none"),this.svg_element=e,e}const t=document.createElementNS("http://www.w3.org/2000/svg","line");return t.setAttribute("x1",this.__data__.from.x.toString()),t.setAttribute("y1",this.__data__.from.y.toString()),t.setAttribute("x2",this.__data__.to.x.toString()),t.setAttribute("y2",this.__data__.to.y.toString()),t.setAttribute("stroke-width",this.get_size().toString()),t.setAttribute("stroke",this.__data__.color.toString()),this.svg_element=t,t}update(){var s;this.svg_element||this.create(),this.svg_element.parentElement||this.parent.appendChild(this.svg_element);const t=((s=this.graph.__data__.extremes)==null?void 0:s.x_max)??1,e=this.__data__.meta??{};if(e.isMeanEdge){this._stampEdge(this.svg_element);const i=typeof e.weight=="number"?e.weight:0,n=typeof e.maxWeight=="number"?e.maxWeight:1,r=typeof e.opacity=="number"?e.opacity:Math.min(1,i/(n||1)),a=t>0?t:1,h=typeof e.widthFrac=="number"?a*e.widthFrac*i:a*di*(i/(n||1)),o=this.__data__._color||new tt("#000000"),l=typeof e.saturation=="number"?e.saturation:r,_=new Qt(o,l,r).toString();if(this.__data__ instanceof ne)this.__data__.weight=h,this.svg_element.setAttribute("d",this.__data__.path),this.svg_element.setAttribute("fill",_),this.svg_element.setAttribute("stroke","none");else if(this.__data__ instanceof qt){if(this.__data__.weight=h,this.svg_element.setAttribute("d",this.__data__.path),this.svg_element.setAttribute("fill",_),this.svg_element.setAttribute("stroke",_),this.svg_element.setAttribute("stroke-width",String(gi)),this.svg_element.setAttribute("vector-effect","non-scaling-stroke"),this.svg_element.setAttribute("stroke-linejoin","round"),e.isDirected)try{const c=new Ce(this.__data__).path;c&&!c.includes("NaN")&&!c.includes("Infinity")&&(this._arrow_el||(this._arrow_el=document.createElementNS("http://www.w3.org/2000/svg","path"),this._arrow_el.setAttribute("stroke","none")),this._arrow_el.parentElement||this.parent.appendChild(this._arrow_el),this._arrow_el.setAttribute("d",c),this._arrow_el.setAttribute("fill",wi(xi(_),mi)),this._arrow_el.setAttribute("stroke","#ffffff"),this._arrow_el.setAttribute("stroke-width",String(fi)),this._arrow_el.setAttribute("vector-effect","non-scaling-stroke"),this._arrow_el.setAttribute("stroke-linejoin","round"))}catch{}}else{const g=this.__data__.from.x,c=this.__data__.from.y,E=this.__data__.to.x,p=this.__data__.to.y;this.svg_element.setAttribute("x1",g.toString()),this.svg_element.setAttribute("y1",c.toString()),this.svg_element.setAttribute("x2",E.toString()),this.svg_element.setAttribute("y2",p.toString()),this.svg_element.setAttribute("stroke-width",h.toString()),this.svg_element.setAttribute("stroke",_),this.svg_element.setAttribute("pointer-events","stroke"),this.svg_element.removeAttribute("marker-end"),this._hit_el||(this._hit_el=document.createElementNS("http://www.w3.org/2000/svg","line"),this._hit_el.setAttribute("stroke","transparent"),this._hit_el.setAttribute("stroke-linecap","round"),this._hit_el.setAttribute("pointer-events","stroke")),this._hit_el.parentElement||this.parent.appendChild(this._hit_el),this._hit_el.setAttribute("x1",g.toString()),this._hit_el.setAttribute("y1",c.toString()),this._hit_el.setAttribute("x2",E.toString()),this._hit_el.setAttribute("y2",p.toString()),this._hit_el.setAttribute("stroke-width",Math.max(h,t*.03).toString()),this._stampEdge(this._hit_el)}}else{this.svg_element.setAttribute("x1",this.__data__.from.x.toString()),this.svg_element.setAttribute("y1",this.__data__.from.y.toString()),this.svg_element.setAttribute("x2",this.__data__.to.x.toString()),this.svg_element.setAttribute("y2",this.__data__.to.y.toString());const i=(t>0?t:1)*.004*this.get_size();this.svg_element.setAttribute("stroke-width",i.toString()),this.svg_element.setAttribute("stroke-opacity","1"),this.svg_element.setAttribute("stroke",this.__data__.color.toString())}}draw(){var t,e,s;this._hit_el&&((t=this.parent)==null||t.appendChild(this._hit_el)),(e=this.parent)==null||e.appendChild(this.svg_element),this._arrow_el&&((s=this.parent)==null||s.appendChild(this._arrow_el))}};u(ys,"QELine");let wt=ys;const xs=class xs extends re{constructor(t,e,s,i=new kt){super(t,e,s,i),this.__data__=t,this.parent=e,this.graph=s,this.__children__=i,this.__name__="unnamed-point",this.svg_element=this.create()}get x(){return this.__data__.dimensions[this.graph.__data__.options.GRAPH.dimensions[0]]}get y(){return this.__data__.dimensions[this.graph.__data__.options.GRAPH.dimensions[1]]}get isSquare(){return this.__data__.shape==="rect"}get shapeKind(){const t=this.__data__.shape;return t==="rect"||t==="square"?"rect":t==="triangle"||t==="diamond"?t:"circle"}get tag(){const t=this.shapeKind;return t==="circle"?"circle":t==="rect"?"rect":"path"}setGeometry(t,e){const s=this.x,i=this.y;switch(this.shapeKind){case"rect":t.setAttribute("x",(s-e).toString()),t.setAttribute("y",(i-e).toString()),t.setAttribute("width",(e*2).toString()),t.setAttribute("height",(e*2).toString());break;case"triangle":{const n=e*1.15;t.setAttribute("d",`M${s} ${i-n} L${s+n*.866} ${i+n*.5} L${s-n*.866} ${i+n*.5}Z`);break}case"diamond":t.setAttribute("d",`M${s} ${i-e*1.2} L${s+e} ${i} L${s} ${i+e*1.2} L${s-e} ${i}Z`);break;default:t.setAttribute("cx",s.toString()),t.setAttribute("cy",i.toString()),t.setAttribute("r",e.toString())}}computeRadius(){var s;const t=this.baseRadius(),e=(s=this.__data__.meta)==null?void 0:s.maxRadius;return typeof e=="number"&&e>0?Math.min(t,e):t}baseRadius(){var s,i,n,r;const t=this.graph.__data__.extremes.x_max||1,e=((s=this.__data__.meta)==null?void 0:s.sizeScale)??1;if((i=this.__data__.meta)!=null&&i.fixedSize){const a=(r=(n=this.graph.svg_element)==null?void 0:n.getBoundingClientRect)==null?void 0:r.call(n),h=this.graph.zoom_level||1,o=a&&a.width>0?a.width/(2*t):1;return this.__data__.size*2*e/o/h}return t*Ds*this.__data__.size*e}applyStroke(t){var s;const e=(s=this.__data__.meta)==null?void 0:s.stroke;e&&(t.setAttribute("stroke",e),t.setAttribute("stroke-width",(this.computeRadius()*.22).toString()))}create(){const t=document.createElementNS("http://www.w3.org/2000/svg",this.tag);t.setAttribute("data-point-id",this.__data__.ID);const e=this.__data__.meta??{};return e.kind&&t.setAttribute("data-kind",e.kind),e.name!=null&&t.setAttribute("data-name",String(e.name)),e.group!=null&&t.setAttribute("data-group",String(e.group)),e.unit!=null&&t.setAttribute("data-unit",String(e.unit)),t.setAttribute("fill",this.__data__.color.toString()),this.applyStroke(t),this.setGeometry(t,this.computeRadius()),this.svg_element=t,t.addEventListener("click",()=>{this.__data__.active=!this.__data__.active,this.update();const s=new CustomEvent("point-clicked",{detail:{pointData:this.__data__},bubbles:!0,composed:!0});this.svg_element.dispatchEvent(s)}),t.addEventListener("mouseover",()=>{}),t}update(){this.svg_element||this.parent.__data__.__children__.push(this.create()),this.svg_element.parentElement||this.parent.appendChild(this.svg_element),this.svg_element.setAttribute("fill",this.__data__.color.toString()),this.applyStroke(this.svg_element),this.setGeometry(this.svg_element,this.computeRadius())}draw(){var t;(t=this.parent)==null||t.appendChild(this.svg_element)}};u(xs,"QEPoint");let Gt=xs;const ws=class ws extends re{constructor(t,e,s,i=new kt){super(t,e,s,i),this.__data__=t,this.parent=e,this.graph=s,this.__children__=i,this.__name__="trajectory",this._path_el=null,this._segments_group=null,this._tip_el=null,this._points_group=null,this.svg_element=this.create()}graphUnitsForPixels(t){var i;const e=this.graph.__data__.extremes.x_max||1,s=((i=this.graph.svg_element)==null?void 0:i.getBoundingClientRect().width)||0;return s>0?t*(2*e/s):t*e*.006}create(){const t=document.createElementNS("http://www.w3.org/2000/svg","g");t.setAttribute("class","qe-trajectory-group");const e=document.createElementNS("http://www.w3.org/2000/svg","path");e.setAttribute("fill","none"),e.setAttribute("stroke",this.__data__.color.toString()),e.setAttribute("stroke-width",this.graphUnitsForPixels(this.__data__.strokeWidth).toString()),t.appendChild(e),this._path_el=e;const s=document.createElementNS("http://www.w3.org/2000/svg","g");s.setAttribute("class","qe-trajectory-segments"),t.appendChild(s),this._segments_group=s;const i=document.createElementNS("http://www.w3.org/2000/svg","g");if(i.setAttribute("class","qe-trajectory-points"),t.appendChild(i),this._points_group=i,this.__data__.showTips){const n=document.createElementNS("http://www.w3.org/2000/svg","circle");n.setAttribute("fill",this.__data__.color.toString()),n.setAttribute("r",this.graphUnitsForPixels(4).toString()),n.setAttribute("stroke","#ffffff"),n.setAttribute("stroke-width",this.graphUnitsForPixels(1.5).toString()),t.appendChild(n),this._tip_el=n}return this.svg_element=t,t}update(){this.svg_element||this.create(),this.svg_element.parentElement||this.parent.appendChild(this.svg_element);const t=this.__data__.path;if(this._path_el&&(this._path_el.setAttribute("d",t),this._path_el.setAttribute("stroke",this.__data__.color.toString()),this._path_el.setAttribute("stroke-width",this.graphUnitsForPixels(this.__data__.strokeWidth).toString()),this._path_el.style.display=this.__data__.lineStyle==="tapered"?"none":"block"),this._segments_group)if(this._segments_group.innerHTML="",this.__data__.lineStyle==="tapered"){const s=this.__data__.pathPoints,i=s.length-1,[n,r]=this.__data__.strokeWidthRange,[a,h]=this.__data__.opacityRange;for(let o=0;o<i;o++){const l=s[o],_=s[o+1],g=i<=1?1:o/(i-1),c=n+(r-n)*g,E=a+(h-a)*g,p=document.createElementNS("http://www.w3.org/2000/svg","path");p.setAttribute("d",`M${l.x},${l.y} L${_.x},${_.y}`),p.setAttribute("fill","none"),p.setAttribute("stroke",this.__data__.color.toString()),p.setAttribute("stroke-linecap","round"),p.setAttribute("stroke-linejoin","round"),p.setAttribute("stroke-width",this.graphUnitsForPixels(c).toString()),p.setAttribute("opacity",E.toString()),this._segments_group.appendChild(p)}this._segments_group.style.display="block"}else this._segments_group.style.display="none";const e=this.__data__.activePoints;if(this._points_group&&(this.__data__.showPoints&&e.length>0?(this._points_group.innerHTML="",e.forEach(s=>{var n;const i=document.createElementNS("http://www.w3.org/2000/svg","circle");i.setAttribute("cx",s.x.toString()),i.setAttribute("cy",s.y.toString()),i.setAttribute("r",this.graphUnitsForPixels(2.5).toString()),i.setAttribute("fill",this.__data__.color.toString()),i.setAttribute("opacity","0.7"),(n=this._points_group)==null||n.appendChild(i)}),this._points_group.style.display="block"):this._points_group.style.display="none"),this._tip_el&&this.__data__.showTips)if(e.length>0){const s=e[e.length-1];this._tip_el.setAttribute("cx",s.x.toString()),this._tip_el.setAttribute("cy",s.y.toString()),this._tip_el.setAttribute("fill",this.__data__.color.toString()),this._tip_el.setAttribute("r",this.graphUnitsForPixels(4).toString()),this._tip_el.setAttribute("stroke-width",this.graphUnitsForPixels(1.5).toString()),this._tip_el.style.display="block"}else this._tip_el.style.display="none"}draw(){this.svg_element&&!this.svg_element.parentElement&&this.parent.appendChild(this.svg_element),this.update()}};u(ws,"QETrajectory");let oe=ws;const{ArrayTools:zs}=ee,As=class As extends Array{constructor(...t){super(...t)}search(t,e){let s;function i(r){return r.name===e?r:void 0}u(i,"fn");function n(r,a,h=null){if(zs.isArray(r)){for(const[o,l]of r.entries())if(s=n(l,o,h),s)return s}else{if(s=i(r),s)return s;if(r&&zs.isArray(r[t])){for(const[o,l]of r[t].entries())if(s=n(l,o,r),s)return s}}return s}return u(n,"recurse"),n(this)}flatten(){return this.reduce((t,e)=>(t.push(e),e.layers&&Array.isArray(e.layers)&&t.push(...e.layers),t),[])}};u(As,"QEArray");let kt=As;const Ai={AxisPoint:Gt,AxisLine:wt,Point:Gt,Line:wt,Edge:wt,TaperedEdge:wt,TaperedWeightedMidpointEdge:wt,NodeEdge:wt,Trajectory:oe},Vt=class Vt{constructor(t,e,s,i=new kt){this.__data__=t,this.parent=e,this.graph=s,this.__children__=i,this.__name__=t.name||"unnamed-layer",t.__state__.addListener("layer_updated","live",({key:n,newValue:r,oldValue:a})=>{const h=u(g=>{var c;return(c=g.__data__)==null?void 0:c.ID},"childId"),o=this.__children__.filter(g=>!r.objects.has(h(g))),l=this.__children__.filter(g=>r.objects.has(h(g)));[...r.objects.values()].filter(g=>!this.__children__.some(c=>h(c)===g.ID)).forEach(g=>{const c=g._typeName||g.constructor.name;let E=Ai[c];E||(g instanceof se?E=oe:g instanceof J?E=Gt:E=wt);const p=new E(g,this.svg_element,this.graph);this.__children__.push(p)}),l.forEach(g=>{const c=r.objects.get(h(g));c&&(g.__data__=c),g.update()}),o.forEach(g=>{g.svg_element.parentElement&&g.svg_element.parentElement.removeChild(g.svg_element);const c=this.__children__.indexOf(g);c>=0&&this.__children__.splice(c,1)}),this.update()}),this.svg_element=this.create()}get name(){return this.__name__}create(){if(!this.__data__)throw new Error("Layer is null");let t=this.__data__;return this.svg_element=document.createElementNS("http://www.w3.org/2000/svg",Vt.tagName),this.svg_element.setAttribute("data-layer-name",t.name),this.svg_element.setAttribute("data-layer-id",t.ID),this.svg_element.__data__=t,this.svg_element.classList.add("ena-layer"),this.__data__.layers&&this.__data__.layers.length>0&&this.__data__.layers.forEach(e=>{const s=new Vt(e,this.svg_element,this.graph);this.__children__.push(s)}),this.svg_element}update(){if(!this.__data__)throw new Error("Layer is null");this.__data__.visible&&(this.parent.nodeName.toLowerCase(),this.__children__.forEach(t=>{t.update()}),this.__data__.scale_objects===!0&&this.__name__)}draw(){var t;(t=this.parent)==null||t.appendChild(this.svg_element),this.__children__.forEach(e=>{e.draw()})}add(t){this.__children__.push(t)}};u(Vt,"QELayer"),Vt.tagName="g";let Oe=Vt;const vs=class vs{constructor(t,e,s,i,n=H.DISPLAY_TYPES.ON,r=H.POSITION.OBJECT,a,h){this.text=t,this.point=e,this.parent=s,this.graph=i,this.displayMode=n,this.position=r,this.customX=a,this.customY=h,this._visible=!1,this._offsetX=0,this._offsetY=0,this.pinned=!1,this.svg_element=this._create(),n===H.DISPLAY_TYPES.ON?(this._visible=!0,this.svg_element.setAttribute("display","block")):(this._visible=!1,this.svg_element.setAttribute("display","none"))}_create(){const t=document.createElementNS("http://www.w3.org/2000/svg","text");return t.textContent=this.text,t.setAttribute("data-label-for",this.point.ID),t.setAttribute("pointer-events","auto"),t.style.cursor="grab",this._attachDrag(t),this.parent.appendChild(t),t}_attachDrag(t){t.addEventListener("mousedown",e=>{e.preventDefault(),e.stopPropagation();const s=t.ownerSVGElement;if(!s)return;const i=u((l,_)=>{const g=s.createSVGPoint();g.x=l,g.y=_;const c=s.getScreenCTM();return c?g.matrixTransform(c.inverse()):{x:0,y:0}},"toUser"),n=i(e.clientX,e.clientY),r=this._offsetX,a=this._offsetY;t.style.cursor="grabbing";const h=u(l=>{const _=i(l.clientX,l.clientY);this._offsetX=r+(_.x-n.x),this._offsetY=a+(_.y-n.y),this.pinned=!0,this._visible=!0,this.svg_element.setAttribute("display","block"),this.update()},"onMove"),o=u(()=>{document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",o),t.style.cursor="grab",this.graph.dispatchEvent(new CustomEvent("qe-label-move",{detail:{id:this.point.ID,transform:{x:this._offsetX,y:this._offsetY}},bubbles:!0,composed:!0}))},"onUp");document.addEventListener("mousemove",h),document.addEventListener("mouseup",o)})}update(){var h;if(!this._visible)return;const t=this.graph.__data__.extremes.x_max;if(t<=0)return;const e=this.graph._labelFont??{},s=e.size?e.size*this.graph.unitsPerPixel():t*.06,i=s*1.2;let n,r,a;switch(this.position){case H.POSITION.STATIC:{n=this.point.x,r=this.point.y-i*.3,a="middle";break}case H.POSITION.CONTAINER:{const{cx:o,cy:l}=this.graph.__data__.extremes,_=this.point.x-o,g=this.point.y-l,c=Math.sqrt(_*_+g*g)||1,E=t*.93/c;n=o+_*E,r=l+g*E-i*.3,a=_>=0?"start":"end";break}case H.POSITION.CUSTOM:if(this.customX!=null&&this.customY!=null){n=this.customX,r=this.customY,a="start";break}default:case H.POSITION.OBJECT:{const o=this.point.x>=0?i:-i;a=this.point.x>=0?"start":"end",n=this.point.x+o,r=this.point.y-i*.4;break}}this.svg_element.setAttribute("x",n.toString()),this.svg_element.setAttribute("y",r.toString()),(this._offsetX||this._offsetY)&&this.svg_element.setAttribute("transform",`translate(${this._offsetX}, ${this._offsetY})`),this.svg_element.setAttribute("font-size",s.toString()),this.svg_element.setAttribute("font-family",e.family??"system-ui, sans-serif"),this.svg_element.setAttribute("font-weight","500"),this.svg_element.setAttribute("text-anchor",a),this.svg_element.setAttribute("fill",e.color??((h=this.point.color)==null?void 0:h.toString())??"#333333")}show(){this._visible=!0,this.svg_element.setAttribute("display","block"),this.update()}hide(){this.pinned||(this._visible=!1,this.svg_element.setAttribute("display","none"))}toggle(){this._visible?this.hide():this.show()}get visible(){return this._visible}remove(){this.svg_element.remove()}};u(vs,"QELabel");let ae=vs;const je=class je extends HTMLElement{};u(je,"QENodesElement"),je.tagName="qe-nodes";let he=je;const Ye=class Ye extends HTMLElement{};u(Ye,"QEMeansElement"),Ye.tagName="qe-means";let le=Ye;const qe=class qe extends HTMLElement{};u(qe,"QEPointsElement"),qe.tagName="qe-points";let ce=qe;const Ge=class Ge extends HTMLElement{};u(Ge,"QEEdgesElement"),Ge.tagName="qe-edges";let _e=Ge;const Ue=class Ue extends HTMLElement{};u(Ue,"QETrajectoriesElement"),Ue.tagName="qe-trajectories";let ue=Ue;const Be=class Be extends HTMLElement{};u(Be,"QEAxesElement"),Be.tagName="qe-axes";let de=Be;customElements.define(he.tagName,he),customElements.define(le.tagName,le),customElements.define(ce.tagName,ce),customElements.define(_e.tagName,_e),customElements.define(ue.tagName,ue),customElements.define(de.tagName,de);const Fs=["#4477AA","#EE6677","#228833","#CCBB44","#66CCEE","#AA3377","#BBBBBB","#000000"];function vi(d,t){for(const e of t)if(d===`${e}.${e}`)return[e,e];for(const e of t)if(d.startsWith(e+".")){const s=d.slice(e.length+1);if(t.includes(s))return[e,s]}return null}u(vi,"parseEdgePair");function Si(d,t,e,s){const i=Math.max(1,e-1),n=i>=120?1.96:i>=60?2:i>=30?2.042:i>=20?2.086:i>=10?2.228:i>=5?2.571:4.303,r=Math.sqrt(Math.max(0,d)/e)*s,a=Math.sqrt(Math.max(0,t)/e)*s;return{halfW:n*r,halfH:n*a}}u(Si,"computeCIRect");const Ei=.5;function $e(d,t,e){if(!d)return;const s=Math.min(Math.abs(t),Math.abs(e));s>0&&(d.meta={...d.meta??{},maxRadius:s*Ei})}u($e,"capMeanToInterval");function Pe(d,t,e,s=""){const i=u(o=>{const l=d.names.indexOf(o),_=l>=0?d[l]:null;if(_==null||_==="")return;const g=Number(_);return Number.isFinite(g)?g:void 0},"get"),n=i(`${t}.${s}low`)??i(`${t}_${s}low`),r=i(`${t}.${s}high`)??i(`${t}_${s}high`),a=i(`${e}.${s}low`)??i(`${e}_${s}low`),h=i(`${e}.${s}high`)??i(`${e}_${s}high`);return n==null||r==null||a==null||h==null?null:{x_low:n,x_high:r,y_low:a,y_high:h}}u(Pe,"readIntervalBounds");function Mi(d){var i,n;const t=u(r=>d.getAttribute(r),"a"),e=((i=t("colors"))==null?void 0:i.split(",").map(r=>r.trim()).filter(Boolean))??[],s=((n=t("threshold"))==null?void 0:n.split(",").map(Number).filter(Number.isFinite))??[];return{group:t("group"),unit:t("unit"),compare:t("compare"),also:t("also"),network:t("network"),colors:e.length?[e[0],e[1]??null]:null,threshold:s.length?[s[0],s.length>1?s[1]:1/0]:null,name:t("name")}}u(Mi,"parseEdgeLayer");function Ii(d){const{r:t,g:e,b:s}=tt.parseColor(d),i=Math.max(t,e,s),n=Math.min(t,e,s),r=u(a=>(i+n-a).toString(16).padStart(2,"0"),"f");return`#${r(t)}${r(e)}${r(s)}`}u(Ii,"complementColor");function Ni(d){const t=d==null?void 0:d.trim().toLowerCase();return t==="plot"||t==="absolute"?t:"model"}u(Ni,"parseColorScale");function is(d,t){switch(d==null?void 0:d.toLowerCase()){case"on":return 3;case"off":return 0;case"click":return 2;case"auto":return 1;default:return t}}u(is,"parseLabelMode");const ut=class ut extends Ne{constructor(){super(),this.zoom_level=1,this.__children__=new kt,this._hasModel=!1,this._renderPending=!1,this._childObserver=null,this._ciRects=new Map,this._outlierRects=new Map,this._ciCross=new Map,this._labelsGroup=null,this._nodeLabels=new Map,this._meanLabels=new Map,this._pointLabels=new Map,this._showAxes=!1,this._axisXText=null,this._axisYText=null,this._axisLabelEls=new Map,this._magnifyText=null,this._magnifyEl=null,this._rangeExtent=null,this._rangeMode=null,this._centerContent=!1,this._plotTitle=null,this._titleEl=null,this._resizeObs=null,this._labelFont={size:null,family:null,color:null},this._animateMs=0,this._tweenRaf=null,this._highlight={edges:new Set,nodes:new Set},this._highlightGroup=null,this._tooltipEl=null,this.graph=this,this.parent=null,this.__data__=new Ie(Ms),this.__name__=this.__data__.name||"unnamed-graph",this.svg_element=this.create(),console.log("Created ena-graph svg element: ",this.svg_element),document.addEventListener("model-updated",t=>{var qs,Gs,Us,Bs,Hs,Xs,Ws,Vs,Ks,Js,Zs,Qs,ti,ei,si;const e=((qs=t.composedPath)==null?void 0:qs.call(t)[0])??t.target;if(this._vizena&&e!==this._vizena)return;const s=t.detail;if(!s)return;this._animateMs=this.hasAttribute("animate")?parseInt(this.getAttribute("animate")||"",10)||300:0;const i=this._animateMs>0&&this._hasModel?this._captureTween():null;this._hasModel=!0;const n=s.dimensions,r=s.unit_id_col,a=s.node_id_col,h=s.group_col,o=this._readLayerConfig();this._showAxes=o.showAxes,this._axisXText=o.axisXLabel===null?null:o.axisXLabel||String((n==null?void 0:n[0])??"x"),this._magnifyText=o.edgeMagnify==null?null:`(scaled ${o.edgeMagnify.toFixed(1)}x)`,this._axisYText=o.axisYLabel===null?null:o.axisYLabel||String((n==null?void 0:n[1])??"y");const l={},_=(Gs=s.palette)!=null&&Gs.length?s.palette:Fs;if(h&&((Us=s.points)!=null&&Us.names)){const O=s.points.col(h);O&&[...new Set([...O].map(String))].forEach(($,x)=>{l[$]=_[x%_.length]})}(Bs=s.groups)!=null&&Bs.rows&&s.groups.rows().length>0&&s.groups.rows().forEach(O=>{const I=O.rowName??String(O[0]),$=O.names.indexOf("color"),x=$>=0?O[$]:null;x&&String(x)!=="NA"?l[I]=String(x):l[I]||(l[I]=_[Object.keys(l).length%_.length])});const g=Object.keys(l),c=o.activeMeanGroups&&o.activeMeanGroups.trim()?new Set(o.activeMeanGroups.split(",").map(O=>O.trim()).filter(O=>l[O])):new Set(g),E=o.scalePoints,p=u(O=>{let I=0;return O.forEach($=>{const x=$.names.indexOf(n[0]),m=n.length>1?$.names.indexOf(n[1]):-1;x>=0&&(I=Math.max(I,Math.abs(Number($[x])))),m>=0&&(I=Math.max(I,Math.abs(Number($[m]))))}),I},"getExtent"),A=(Hs=s.nodes)!=null&&Hs.rows?p(s.nodes.rows()):0,R=(Xs=s.points)!=null&&Xs.rows?p(s.points.rows()):0,q=(Ws=s.trajectories)!=null&&Ws.rows?p(s.trajectories.rows()):0,G=R>0?R:q,v=o.pointScale!==null?o.pointScale:E&&G>0&&A>0?A/G:1;this._rangeExtent=o.range==="network"?A*1.2:o.range==="points"?G*v*1.2:typeof o.range=="number"?o.range:null,this._rangeMode=o.range==="network"||o.range==="points"?o.range:typeof o.range=="number"?"number":null,this._centerContent=o.centerContent,this._plotTitle=o.plotTitle,this._labelFont=o.labelFont;const Y=o.labelNodes,rt=o.labelMeans,ht=o.labelPoints,nt=this._labelsGroup,dt=u((O,I,$,x=1)=>{const m=O.names.indexOf(I),P=O.names.indexOf(n[0]),b=n.length>1?O.names.indexOf(n[1]):-1,y=new J({ID:m>=0?String(O[m]):O.rowName||`pt-${Math.random().toString(36).slice(2)}`,dimensions:[P>=0?Number(O[P])*x:0,b>=0?-Number(O[b])*x:0],meta:{}});return $&&(y.color=new tt($)),y},"rowToPoint"),Z={},Ot=o.showPoints,Dt=s.pointsets;if(o.pointSets.length&&(Dt!=null&&Dt.rows)){const O=this.__children__.search("__children__","points"),I=u(($,x)=>{const m=$.names.indexOf(x);return m>=0?$[m]:null},"col");o.pointSets.forEach(($,x)=>{Dt.rows().forEach(m=>{if(String(I(m,"set"))!==$.set)return;const P=String(I(m,"id")),b=I(m,"group")!=null&&String(I(m,"group"))!=="NA"?String(I(m,"group")):null,y=I(m,"color")&&String(I(m,"color"))!=="NA"?String(I(m,"color")):b&&l[b]?l[b]:_[x%_.length],M=dt(m,"id",y,v);M.ID=`${$.set}::${P}`,M.size=$.size??o.pointSize??2.5;const j=I(m,"shape");j&&String(j)!=="NA"&&(M.shape=String(j));const L=I(m,"label");M.meta={stroke:"#ffffff",kind:"point",name:L!=null&&String(L)!=="NA"?String(L):P,group:b??void 0,unit:P,set:$.set,fixedSize:$.fixedSize},this.__data__.points.set(M.ID,M),O==null||O.__data__.objects.set(M.ID,M)})})}if((Vs=s.points)!=null&&Vs.rows){const O=this.__children__.search("__children__","points");if(O){s.points.rows().forEach(x=>{const m=h?x.names.indexOf(h):-1,P=m>=0?String(x[m]):null,b=P?l[P]??"#888888":"#888888";if(Ot){const y=dt(x,r,b,v);y.size=o.pointSize??2.5,y.meta={...y.meta??{},stroke:"#ffffff",kind:"point",name:y.ID,group:P??void 0,unit:y.ID,fixedSize:o.pointFixedSize},this.__data__.points.set(y.ID,y),O.__data__.objects.set(y.ID,y)}if(P){const y=x.names.indexOf(n[0]),M=n.length>1?x.names.indexOf(n[1]):-1;Z[P]||(Z[P]={x:0,y:0,x2:0,y2:0,xy:0,n:0,color:b});const j=y>=0?Number(x[y]):0,L=M>=0?Number(x[M]):0;Z[P].x+=j,Z[P].y+=L,Z[P].x2+=j*j,Z[P].y2+=L*L,Z[P].xy+=j*L,Z[P].n+=1}});const I=!!((Ks=s.groups)!=null&&Ks.rows&&s.groups.rows().length>0),$=o.showMeans&&I?s.groups.rows().filter(x=>{const m=x.rowName??String(x[0]);return c.size===0||c.has(m)}):[];if(o.showMeans){const x=O.svg_element,m=(A>0?A:1)*.008;if(I){const P=new Set($.map(b=>b.rowName??String(b[0])));this._ciRects.forEach((b,y)=>{P.has(y)||(b.remove(),this._ciRects.delete(y))}),this._outlierRects.forEach((b,y)=>{P.has(y)||(b.remove(),this._outlierRects.delete(y))}),this._ciCross.forEach((b,y)=>{P.has(y.slice(2))||(b.remove(),this._ciCross.delete(y))}),$.forEach(b=>{var k,F,z;const y=b.rowName??String(b[0]),M=l[y]??"#888888",j=b.names.indexOf(n[0]),L=n.length>1?b.names.indexOf(n[1]):-1,V=j>=0?Number(b[j])*v:0,ft=L>=0?-Number(b[L])*v:0,Q=new J({ID:`mean-${y}`,dimensions:[V,ft],meta:{kind:"mean",name:y,group:y,fixedSize:o.meanFixedSize}});Q.color=new tt(M),Q.size=4;const mt=b.names.indexOf("shape"),T=mt>=0?b[mt]:null;Q.shape=T&&String(T)!=="NA"?String(T):"rect",this.__data__.points.set(Q.ID,Q),O.__data__.objects.set(Q.ID,Q);const zt=u(N=>{const st=b.names.indexOf(N),X=st>=0?b[st]:null;return X==null||String(X)==="NA"||String(X)===""?null:X},"cell"),At=zt("intervals"),Mt=At==="box"||At==="crosshairs"||At==="none"?At:o.intervals,Ft=zt("outlier"),U=(Ft==null?o.showOutlier:Ft===!0||String(Ft)==="true")?Pe(b,n[0],n[1],"o"):null;if(!U)(k=this._outlierRects.get(y))==null||k.remove(),this._outlierRects.delete(y);else{let N=this._outlierRects.get(y);N||(N=document.createElementNS("http://www.w3.org/2000/svg","rect"),N.setAttribute("data-outlier-group",y),this._outlierRects.set(y,N)),N.setAttribute("x",(U.x_low*v).toString()),N.setAttribute("y",(-U.y_high*v).toString()),N.setAttribute("width",((U.x_high-U.x_low)*v).toString()),N.setAttribute("height",((U.y_high-U.y_low)*v).toString()),N.setAttribute("fill","none"),N.setAttribute("stroke",M),N.setAttribute("stroke-width",m.toString()),N.setAttribute("stroke-opacity","0.5"),N.setAttribute("stroke-dasharray",`${m*2} ${m*2}`),x&&!N.parentElement&&x.insertBefore(N,x.firstChild)}const f=Mt!=="none"?Pe(b,n[0],n[1]):null,w=`x:${y}`;if((!f||Mt!=="crosshairs")&&((F=this._ciCross.get(w))==null||F.remove(),this._ciCross.delete(w)),f&&Mt==="crosshairs"){(z=this._ciRects.get(y))==null||z.remove(),this._ciRects.delete(y);const N=f.x_low*v,st=f.x_high*v,X=-f.y_high*v,ot=-f.y_low*v;$e(Q,(st-N)/2,(ot-X)/2);let D=this._ciCross.get(w);D||(D=document.createElementNS("http://www.w3.org/2000/svg","path"),D.setAttribute("data-ci-group",y),D.setAttribute("data-ci-kind","crosshairs"),this._ciCross.set(w,D)),D.setAttribute("d",`M${N} ${ft} L${st} ${ft} M${V} ${X} L${V} ${ot}`),D.setAttribute("fill","none"),D.setAttribute("stroke",M),D.setAttribute("stroke-width",(m*1.25).toString()),D.setAttribute("stroke-opacity","0.8"),x&&!D.parentElement&&x.insertBefore(D,x.firstChild)}else if(f){const N=f.x_low*v,st=-f.y_high*v,X=(f.x_high-f.x_low)*v,ot=(f.y_high-f.y_low)*v;$e(Q,X/2,ot/2);let D=this._ciRects.get(y);D||(D=document.createElementNS("http://www.w3.org/2000/svg","rect"),D.setAttribute("data-ci-group",y),this._ciRects.set(y,D)),D.setAttribute("x",N.toString()),D.setAttribute("y",st.toString()),D.setAttribute("width",X.toString()),D.setAttribute("height",ot.toString()),D.setAttribute("fill","none"),D.setAttribute("stroke",M),D.setAttribute("stroke-width",m.toString()),D.setAttribute("stroke-opacity","0.8"),D.setAttribute("stroke-dasharray",`${m*4} ${m*3}`),x&&!D.parentElement&&x.insertBefore(D,x.firstChild)}else{const N=this._ciRects.get(y);N&&(N.remove(),this._ciRects.delete(y))}})}else Object.entries(Z).forEach(([b,{x:y,y:M,n:j,color:L}])=>{const V=new J({ID:`mean-${b}`,dimensions:[y/j*v,-(M/j)*v],meta:{kind:"mean",name:b,group:b,fixedSize:o.meanFixedSize}});V.color=new tt(L),V.size=4,V.shape="rect",this.__data__.points.set(V.ID,V),O.__data__.objects.set(V.ID,V)}),o.showCI&&(this._ciRects.forEach((b,y)=>{Z[y]||(b.remove(),this._ciRects.delete(y))}),(Js=s.confidence)!=null&&Js.rows?s.confidence.rows().forEach(b=>{const y=b.names.indexOf(h??"group"),M=y>=0?String(b[y]):b.rowName??null;if(!M)return;const j=l[M]??"#888888",L=Pe(b,n[0],n[1]);if(!L)return;const V=L.x_low*v,ft=-L.y_high*v,Q=(L.x_high-L.x_low)*v,mt=(L.y_high-L.y_low)*v;$e(this.__data__.points.get(`mean-${M}`),Q/2,mt/2);let T=this._ciRects.get(M);T||(T=document.createElementNS("http://www.w3.org/2000/svg","rect"),T.setAttribute("data-ci-group",M),this._ciRects.set(M,T)),T.setAttribute("x",V.toString()),T.setAttribute("y",ft.toString()),T.setAttribute("width",Q.toString()),T.setAttribute("height",mt.toString()),T.setAttribute("fill","none"),T.setAttribute("stroke",j),T.setAttribute("stroke-width",m.toString()),T.setAttribute("stroke-opacity","0.8"),T.setAttribute("stroke-dasharray",`${m*4} ${m*3}`),x&&!T.parentElement&&x.insertBefore(T,x.firstChild)}):Object.entries(Z).forEach(([b,{x:y,y:M,x2:j,y2:L,n:V,color:ft}])=>{if(V<2)return;const Q=y/V,mt=M/V,T=j/V-Q*Q,zt=L/V-mt*mt,{halfW:At,halfH:Mt}=Si(T,zt,V,v),Ft=Q*v,Jt=-mt*v;$e(this.__data__.points.get(`mean-${b}`),At,Mt);let U=this._ciRects.get(b);U||(U=document.createElementNS("http://www.w3.org/2000/svg","rect"),U.setAttribute("data-ci-group",b),this._ciRects.set(b,U)),U.setAttribute("x",(Ft-At).toString()),U.setAttribute("y",(Jt-Mt).toString()),U.setAttribute("width",(At*2).toString()),U.setAttribute("height",(Mt*2).toString()),U.setAttribute("fill","none"),U.setAttribute("stroke",ft),U.setAttribute("stroke-width",m.toString()),U.setAttribute("stroke-opacity","0.8"),U.setAttribute("stroke-dasharray",`${m*4} ${m*3}`),x&&!U.parentElement&&x.insertBefore(U,x.firstChild)})),(Zs=s.outlier)!=null&&Zs.rows&&(this._outlierRects.forEach((b,y)=>{l[y]||(b.remove(),this._outlierRects.delete(y))}),s.outlier.rows().forEach(b=>{const y=b.names.indexOf(h??"group"),M=y>=0?String(b[y]):b.rowName??null;if(!M)return;const j=l[M]??"#888888",L=Pe(b,n[0],n[1]);if(!L)return;const V=L.x_low*v,ft=-L.y_high*v,Q=(L.x_high-L.x_low)*v,mt=(L.y_high-L.y_low)*v;let T=this._outlierRects.get(M);T||(T=document.createElementNS("http://www.w3.org/2000/svg","rect"),T.setAttribute("data-outlier-group",M),this._outlierRects.set(M,T)),T.setAttribute("x",V.toString()),T.setAttribute("y",ft.toString()),T.setAttribute("width",Q.toString()),T.setAttribute("height",mt.toString()),T.setAttribute("fill","none"),T.setAttribute("stroke",j),T.setAttribute("stroke-width",m.toString()),T.setAttribute("stroke-opacity","0.5"),T.setAttribute("stroke-dasharray",`${m*2} ${m*2}`),x&&!T.parentElement&&x.insertBefore(T,x.firstChild)}))}nt&&(this._pointLabels.forEach((x,m)=>{O.__data__.objects.get(m)||(x.remove(),this._pointLabels.delete(m))}),this._meanLabels.forEach((x,m)=>{O.__data__.objects.get(`mean-${m}`)||(x.remove(),this._meanLabels.delete(m))}),ht!==0&&s.points.rows().forEach(x=>{const m=x.names.indexOf(r),P=m>=0?String(x[m]):null;if(!P)return;const b=O.__data__.objects.get(P);if(!b)return;const y=P;let M=this._pointLabels.get(P);M?ht===H.DISPLAY_TYPES.ON?M.show():M.hide():(M=new ae(y,b,nt,this,ht),this._pointLabels.set(P,M))}),rt!==0&&(I?$.map(m=>m.rowName??String(m[0])):Object.keys(Z)).forEach(m=>{const P=`mean-${m}`,b=O.__data__.objects.get(P);if(!b)return;let y=this._meanLabels.get(m);y?rt===H.DISPLAY_TYPES.ON?y.show():y.hide():(y=new ae(m,b,nt,this,rt),this._meanLabels.set(m,y))})),O.__data__.__state__.setVariable("layer_updated",O.__data__)}}const Kt=this.__children__.search("__children__","trajectories");if(o.showTrajectories&&Kt){Kt.__data__.objects.clear(),this.__data__.trajectories.clear();const O=(Qs=s.trajectories)!=null&&Qs.rows?s.trajectories:s.points;if(O!=null&&O.rows){const I={},$=o.trajectoryUnits?o.trajectoryUnits.split(",").map(m=>m.trim()):null;O.rows().forEach(m=>{const P=m.names.indexOf(r)>=0?m.names.indexOf(r):m.names.indexOf("unit")>=0?m.names.indexOf("unit"):m.names.indexOf("ENA_UNIT")>=0?m.names.indexOf("ENA_UNIT"):-1,b=P>=0?String(m[P]):m.rowName||"unit-1";if($&&!$.includes(b))return;const y=m.names.indexOf(n[0]),M=n.length>1?m.names.indexOf(n[1]):-1,j=m.names.indexOf("time")>=0?m.names.indexOf("time"):m.names.indexOf("ActivityNumber")>=0?m.names.indexOf("ActivityNumber"):m.names.indexOf("RowID")>=0?m.names.indexOf("RowID"):-1,L=j>=0?Number(m[j]):I[b]?I[b].length+1:1;y>=0&&M>=0&&(I[b]||(I[b]=[]),I[b].push({x:Number(m[y])*v,y:-Number(m[M])*v,time:L}))}),Object.keys(I).forEach((m,P)=>{const b=I[m];if(b.length===0)return;const y=_[P%_.length],M=new se({ID:`traj-${m}`,unitId:m,color:new tt(y),lineStyle:o.trajectoryLineStyle,strokeWidth:o.trajectoryStrokeWidth,strokeWidthRange:o.trajectoryStrokeWidthRange,opacityRange:o.trajectoryOpacityRange,smooth:o.trajectorySmooth,maxDegree:o.trajectoryMaxDegree,degreeSelection:o.trajectoryDegreeSelection,currentTime:o.trajectoryPlayhead??1/0,showPoints:o.trajectoryShowPoints,showTips:o.trajectoryShowTips,points:b.map(j=>({x:j.x,y:j.y,time:j.time}))});this.__data__.trajectories.set(m,M),Kt.__data__.objects.set(M.ID,M)})}Kt.__data__.__state__.setVariable("layer_updated",Kt.__data__)}const gt=this.__children__.search("__children__","network"),Ee=gt==null?void 0:gt.__children__.search("__children__","edges"),yt=gt==null?void 0:gt.__children__.search("__children__","nodes"),Xe=gt==null?void 0:gt.__children__.search("__children__","edgenodes"),Oi=o.showEdges;if((ti=s.nodes)!=null&&ti.rows&&yt){if(s.nodes.rows().forEach(I=>{const $=dt(I,a,"#444444");$.size=2;const x=I.names.indexOf("label"),m=x>=0?I[x]:null;$.meta={...$.meta??{},kind:"node",name:m!=null&&String(m)!=="NA"&&String(m)!==""?String(m):$.ID},yt.__data__.objects.set($.ID,$)}),Oi&&Ee&&((ei=s.edges)!=null&&ei.rows)){const I={};h&&((si=s.points)!=null&&si.rows)&&s.points.rows().forEach(f=>{const w=f.names.indexOf(r),k=f.names.indexOf(h);w>=0&&k>=0&&(I[String(f[w])]=String(f[k]))});const $=s.nodes.rows().map(f=>{const w=f.names.indexOf(a);return w>=0?String(f[w]):""}).filter(Boolean),x=[];(s.edges.names??[]).forEach(f=>{const w=vi(f,$);w&&x.push({col:f,pair:w})});const m=u(f=>{const w={};return s.edges.rows().forEach(k=>{const F=k.names.indexOf(r);F<0||String(k[F])!==f||x.forEach(({col:z})=>{const N=k.names.indexOf(z);N>=0&&(w[z]=Number(k[N])||0)})}),w},"getUnitEdges"),P=u(f=>{const w={};let k=0;if(s.edges.rows().forEach(z=>{const N=z.names.indexOf(r),st=N>=0?String(z[N]):null,X=h?z.names.indexOf(h):-1;(X>=0?String(z[X]):st?I[st]:null)===f&&(k++,x.forEach(({col:D})=>{const xt=z.names.indexOf(D);if(xt>=0){const K=Number(z[xt]);isNaN(K)||(w[D]=(w[D]??0)+K)}}))}),k===0)return{};const F={};return x.forEach(({col:z})=>{F[z]=(w[z]??0)/k}),F},"getGroupEdges"),b=u(f=>{if(l[f])return{weights:P(f),color:l[f],label:f};const w=I[f]??null,k=w?l[w]??"#888888":"#888888";return{weights:m(f),color:k,label:f}},"resolve"),y=[],M=u(f=>{var z;const w=s.networks,k=(z=w==null?void 0:w.rows)==null?void 0:z.call(w).find(N=>N.rowName===f);if(!k)return null;const F={};return x.forEach(({col:N})=>{const st=k.names.indexOf(N);if(st>=0){const X=Number(k[st]);Number.isFinite(X)&&(F[N]=X)}}),F},"networkRow"),j=u((f,w)=>{if(!w)return f;const k=Math.abs(f);return k<w[0]?0:k>w[1]?Math.sign(f)*w[1]:f},"thresholded");o.edgeLayers.forEach((f,w)=>{const k=u((K,lt,et,vt,ct)=>{et=j(et,f.threshold),!(Math.abs(et)<1e-6)&&y.push({col:`${w}:${K}`,pair:lt,weight:Math.abs(et),color:vt,layer:w,...ct})},"push"),F=u((K,lt)=>f.colors?[f.colors[0],f.colors[1]??Ii(f.colors[0])]:[K,lt],"signColors");if(f.network){const K=M(f.network);if(!K)return;const[lt,et]=F(_[0],_[1]),vt={name:f.name??f.network};x.forEach(({col:ct,pair:ii})=>{const We=K[ct]??0;k(ct,ii,We,We>=0?lt:et,vt)});return}const z=f.unit??f.group??null;if(!z)return;const N=b(z),st=f.compare??f.also??null,X=st?b(st):null,ot={name:f.name??z,group:f.group??void 0,unit:f.unit??void 0},[D,xt]=F(N.color,(X==null?void 0:X.color)??N.color);X&&f.compare?x.forEach(({col:K,pair:lt})=>{const et=(N.weights[K]??0)-(X.weights[K]??0);k(K,lt,et,et>0?D:xt,ot)}):X&&f.also?x.forEach(({col:K,pair:lt})=>{const et=N.weights[K]??0,vt=X.weights[K]??0;et>0&&k(K+"-a",lt,et,D,ot),vt>0&&k(K+"-b",lt,vt,xt,{...ot,name:f.also??void 0,group:f.also??void 0})}):x.forEach(({col:K,pair:lt})=>{const et=N.weights[K]??0;et>0&&k(K,lt,et,D,ot)})}),y.sort((f,w)=>w.weight-f.weight);const L=!!s.directed,V=bi(o.edgeWidth)*(o.edgeMagnify??1),ft=u(f=>{const w=f.map(Math.abs).filter(k=>k>0);return w.length?[Math.min(...w),Math.max(...w)]:[0,0]},"rangeOf"),Q=u(f=>{const w=[];return x.forEach(({col:k,pair:F})=>{if(F[0]===F[1]!==f)return;const z=s.edges.col(k);if(z)for(const N of z)w.push(Number(N))}),ft(w)},"modelRange"),mt=u(f=>ft(y.filter(w=>w.pair[0]===w.pair[1]===f).map(w=>w.weight)),"plotRange"),T=o.edgeColorScale,zt=u(f=>T==="plot"?mt(f):Q(f),"colourRange"),At=zt(!1),Mt=zt(!0),Ft=u((f,w)=>{if(T==="absolute"){const z=Math.min(1,Math.abs(f));return{saturation:z,opacity:z}}const[k,F]=w?Mt:At;return{saturation:Ts(f,k,F,_i),opacity:Ts(f,k,F,ui)}},"colourOf"),Jt={};y.forEach(({pair:f,weight:w})=>{if(f[0]===f[1]&&!L)return;const F=u(z=>{Jt[z]=(Jt[z]??0)+Math.abs(w)},"add");if(L){F(f[1]);return}F(f[0]),F(f[1])}),s.nodes.rows().forEach(f=>{const w=f.names.indexOf(a),k=w>=0?String(f[w]):"";if(!k)return;const F=yt.__data__.objects.get(k);if(!F)return;const z=Jt[k]??0,N=!(z>0);F.size=N?o.hideUnconnectedNodes?0:pi:yi(z,V),F.meta={...F.meta??{},hidden:N&&o.hideUnconnectedNodes}});const U={};L&&y.forEach(({pair:f,weight:w,layer:k})=>{const F=`${k}:${f[0]}.${f[1]}`;U[F]=(U[F]??0)+w}),y.forEach(({col:f,pair:w,weight:k,color:F,layer:z,name:N,group:st,unit:X})=>{const ot=yt.__data__.objects.get(w[0]),D=yt.__data__.objects.get(w[1]);if(!ot||!D)return;const xt=w[0]===w[1];if(xt&&!L)return;const{saturation:K,opacity:lt}=Ft(k,xt),et=new J({ID:`${w[0]}-src`,dimensions:[ot.x,ot.y],meta:{}}),vt=new J({ID:`${w[1]}-dst`,dimensions:[D.x,D.y],meta:{}});let ct;if(xt)ct=new ne({},et,vt),ct.weight=0;else if(L){const We=U[`${z}:${w[0]}.${w[1]}`]??k,$i=U[`${z}:${w[1]}.${w[0]}`]??0,Pi=We+$i;ct=new ss({weight:k,totalweight:Pi},et,vt)}else ct=new Yt({},et,vt);ct.ID=`edge-${f}`,ct.color=new tt(F),ct.meta={isMeanEdge:!0,weight:k,widthFrac:V,saturation:K,opacity:lt,isDirected:L,isSelf:xt,source:w[0],target:w[1],group:st,unit:X,layer:N},(xt?Xe??Ee:Ee).__data__.objects.set(ct.ID,ct)}),Ee.__data__.__state__.setVariable("layer_updated",Ee.__data__),Xe&&Xe.__data__.__state__.setVariable("layer_updated",Xe.__data__)}const O=o.showNodes;yt.svg_element&&(yt.svg_element.style.display=O?"":"none"),O||(this._nodeLabels.forEach(I=>I.remove()),this._nodeLabels.clear()),nt&&Y!==0&&O&&(this._nodeLabels.forEach((I,$)=>{yt.__data__.objects.get($)||(I.remove(),this._nodeLabels.delete($))}),s.nodes.rows().forEach(I=>{var y,M,j;const $=I.names.indexOf(a),x=$>=0?String(I[$]):"";if(!x)return;const m=yt.__data__.objects.get(x);if(!m)return;if((y=m.meta)!=null&&y.hidden){(M=this._nodeLabels.get(x))==null||M.remove(),this._nodeLabels.delete(x);return}const P=String(((j=m.meta)==null?void 0:j.name)??x);let b=this._nodeLabels.get(x);b&&b.text!==P&&(b.remove(),this._nodeLabels.delete(x),b=void 0),b?Y===H.DISPLAY_TYPES.ON?b.show():b.hide():(b=new ae(P,m,nt,this,Y),this._nodeLabels.set(x,b))})),yt.__data__.__state__.setVariable("layer_updated",yt.__data__)}const js=this.__children__.search("__children__","axis_points"),Ys=this.__children__.search("__children__","axis_lines");js&&this.__data__.__state__.setVariable("graph_updated_axis_points",js.__data__.objects),Ys&&this.__data__.__state__.setVariable("graph_updated_axis_lines",Ys.__data__.objects),this.update(),i&&this._runTween(i)})}static get observedAttributes(){return["width","height","for","scale-points","point-scale","center","labels","label-nodes","label-means","label-points"]}get vizena(){return this._vizena}unitsPerPixel(){var i,n;const t=this.__data__.extremes.x_max||1,e=(n=(i=this.svg_element)==null?void 0:i.getBoundingClientRect)==null?void 0:n.call(i),s=this.zoom_level||1;return e&&e.width>0?2*t/e.width/s:t*.004}_scheduleRerender(){!this._vizena||!this._hasModel||this._renderPending||(this._renderPending=!0,queueMicrotask(()=>{var t;this._renderPending=!1,(t=this._vizena)==null||t.dispatchEvent(new CustomEvent("model-updated",{detail:this._vizena.model,bubbles:!0,composed:!0}))}))}_readLayerConfig(){var g;const t=this.querySelector("qe-nodes"),e=this.querySelector("qe-means"),s=[...this.querySelectorAll("qe-points")],i=s.find(c=>!c.hasAttribute("set"))??null,n=s.filter(c=>c.hasAttribute("set")),r=[...this.querySelectorAll("qe-edges")],a=u(c=>{var E;return((E=r.find(p=>p.hasAttribute(c)))==null?void 0:E.getAttribute(c))??null},"firstAttr"),h=r.find(c=>c.hasAttribute("magnify")),o=this.querySelector("qe-trajectories"),l=this.querySelector("qe-axes"),_=this.getAttribute("labels");return{labelNodes:is((t==null?void 0:t.getAttribute("label"))??this.getAttribute("label-nodes")??_,H.DISPLAY_TYPES.ON),showNodes:!!t,range:(()=>{const c=this.getAttribute("range");if(c==="network"||c==="points")return c;const E=Number(c);return c!=null&&Number.isFinite(E)&&E>0?E:null})(),plotTitle:this.getAttribute("plot-title")||null,labelFont:{size:(()=>{const c=Number(this.getAttribute("label-font-size"));return Number.isFinite(c)&&c>0?c:null})(),family:this.getAttribute("label-font-family")||null,color:this.getAttribute("label-font-color")||null},edgeWidth:(()=>{const c=Number(this.getAttribute("edge-width"));return Number.isFinite(c)&&c>0&&c<=1?c:ci})(),hideUnconnectedNodes:((g=t==null?void 0:t.getAttribute("unconnected"))==null?void 0:g.toLowerCase())==="hide",scalePoints:this.getAttribute("scale-points")!=="false",pointScale:(()=>{const c=Number(this.getAttribute("point-scale"));return this.hasAttribute("point-scale")&&Number.isFinite(c)&&c>0?c:null})(),centerContent:this.getAttribute("center")==="content",showMeans:!!e,activeMeanGroups:(e==null?void 0:e.getAttribute("groups"))??null,showCI:!!e&&e.hasAttribute("confidence"),intervals:(()=>{const c=e==null?void 0:e.getAttribute("intervals");return c==="box"||c==="crosshairs"||c==="none"?c:e!=null&&e.hasAttribute("confidence")?"box":"none"})(),showOutlier:!!e&&e.hasAttribute("outlier"),labelMeans:is((e==null?void 0:e.getAttribute("label"))??this.getAttribute("label-means")??_,H.DISPLAY_TYPES.ON),meanFixedSize:!!e&&e.hasAttribute("fixed-size"),showPoints:!!i,pointSets:n.map(c=>({set:c.getAttribute("set"),size:c.getAttribute("size")?parseFloat(c.getAttribute("size")):null,fixedSize:c.hasAttribute("fixed-size")})),labelPoints:is((i==null?void 0:i.getAttribute("label"))??this.getAttribute("label-points")??_,H.DISPLAY_TYPES.OFF),pointSize:i!=null&&i.getAttribute("size")?parseFloat(i.getAttribute("size")):null,pointFixedSize:!!i&&i.hasAttribute("fixed-size"),showEdges:r.length>0,edgeLayers:r.map(Mi),edgeColorScale:Ni(a("color-scale")),edgeMagnify:h?(()=>{const c=Number(h.getAttribute("magnify"));return Number.isFinite(c)&&c>0?c:1})():null,showTrajectories:!!o,trajectoryUnits:(o==null?void 0:o.getAttribute("units"))??null,trajectorySmooth:(o==null?void 0:o.getAttribute("smooth"))??"none",trajectoryMaxDegree:o!=null&&o.getAttribute("max-degree")?parseInt(o.getAttribute("max-degree"),10):3,trajectoryDegreeSelection:(o==null?void 0:o.getAttribute("degree-selection"))??"loocv_2d",trajectoryShowPoints:(o==null?void 0:o.getAttribute("points"))!=="false",trajectoryShowTips:(o==null?void 0:o.getAttribute("tips"))!=="false",trajectoryPlayhead:o!=null&&o.getAttribute("playhead")?parseFloat(o.getAttribute("playhead")):null,trajectoryLineStyle:(o==null?void 0:o.getAttribute("line-style"))??"uniform",trajectoryStrokeWidth:o!=null&&o.getAttribute("stroke-width")?parseFloat(o.getAttribute("stroke-width")):2,trajectoryStrokeWidthRange:this._parseNumberPair(o==null?void 0:o.getAttribute("stroke-width-range"),[1,6]),trajectoryOpacityRange:this._parseNumberPair(o==null?void 0:o.getAttribute("opacity-range"),[.3,1]),showAxes:!!l,axisXLabel:l!=null&&l.hasAttribute("x")?l.getAttribute("x")??"":null,axisYLabel:l!=null&&l.hasAttribute("y")?l.getAttribute("y")??"":null}}_parseNumberPair(t,e){if(!t)return e;const s=t.split(",").map(i=>Number(i.trim()));return s.length<2||!s.every(Number.isFinite)?e:[s[0],s[1]]}attributeChangedCallback(t,e,s){e!==s&&this._scheduleRerender()}connectedCallback(){var n;const t=this.getAttribute("width"),e=this.getAttribute("height");this.style.display="block",t&&(this.style.width=isNaN(Number(t))?t:`${t}px`),e&&(this.style.height=isNaN(Number(e))?e:`${e}px`),this.appendChild(this.svg_element),ut._instances.add(this),this._childObserver=new MutationObserver(()=>this._scheduleRerender()),this._childObserver.observe(this,{childList:!0,attributes:!0,subtree:!0,attributeFilter:["group","unit","compare","also","color-scale","magnify","network","colors","threshold","name","groups","confidence","label","intervals","outlier","set","unconnected","scale-points","point-scale","edge-width","labels","range","center","plot-title","label-font-size","label-font-family","label-font-color","label-nodes","label-means","label-points","units","smooth","degree","points","tips","playhead","line-style","stroke-width","stroke-width-range","opacity-range","x","y","size","fixed-size"]});const s=this.getAttribute("for");this._vizena=(s?document.getElementById(s):null)??this.closest("qe-visual")??((n=this.parentElement)==null?void 0:n.closest("qe-visual"))??document.querySelector("qe-visual"),this.draw();const i=this.__children__.search("__children__","labels");if(i!=null&&i.svg_element)this._labelsGroup=i.svg_element;else{console.warn("[ena-graph] labels layer not found in layer tree; creating fallback <g>");const r=this.__children__[0];r!=null&&r.svg_element&&(this._labelsGroup=document.createElementNS("http://www.w3.org/2000/svg","g"),this._labelsGroup.setAttribute("data-layer-name","labels-fallback"),r.svg_element.appendChild(this._labelsGroup))}}disconnectedCallback(){var t,e,s;(t=this._childObserver)==null||t.disconnect(),this._childObserver=null,(e=this._resizeObs)==null||e.disconnect(),this._resizeObs=null,ut._instances.delete(this),(s=this._tooltipEl)==null||s.remove(),this._tooltipEl=null}static instances(){return[...ut._instances]}static getGraph(t){for(const e of ut._instances)if(e.id===t||e.getAttribute("plot-group")===t)return e;return null}getNodes(){const t=this.__children__.search("__children__","nodes");return t?[...t.__data__.objects.values()].map(e=>{var s;return{id:e.ID,name:((s=e.meta)==null?void 0:s.name)??e.ID,x:e.x,y:e.y}}):[]}getEdges(){const t=u(e=>{const s=this.__children__.search("__children__",e);return s?[...s.__data__.objects.values()]:[]},"collect");return[...t("edges"),...t("edgenodes")].map(e=>{const s=e.meta??{};return{source:s.source,target:s.target,weight:s.weight??0,directed:!!s.isDirected,self:!!s.isSelf}}).filter(e=>e.source!=null&&e.target!=null)}_tweenTargets(){return[...this.svg_element.querySelectorAll("circle[data-point-id], rect[data-point-id], line[data-edge-source], path[data-edge-source]")]}_readCoords(t){const e=t.tagName.toLowerCase(),s=u(i=>parseFloat(t.getAttribute(i)||"0"),"n");if(e==="circle")return{t:"c",cx:s("cx"),cy:s("cy")};if(e==="rect")return{t:"r",x:s("x"),y:s("y")};if(e==="line")return{t:"l",x1:s("x1"),y1:s("y1"),x2:s("x2"),y2:s("y2")};if(e==="path"){const i=t.getAttribute("d")||"";return{t:"p",d:i,nums:(i.match(ut._PATH_NUM_RE)||[]).map(Number)}}return null}_captureTween(){const t=new Map;return this._tweenTargets().forEach(e=>{const s=this._readCoords(e);s&&t.set(e,s)}),t}_runTween(t){this._tweenRaf!==null&&(cancelAnimationFrame(this._tweenRaf),this._tweenRaf=null);const e=new Map;if(this._tweenTargets().forEach(h=>{if(t.has(h)){const o=this._readCoords(h);o&&e.set(h,o)}}),!e.size)return;const s=this._animateMs,i=performance.now(),n=u(h=>h<.5?2*h*h:1-Math.pow(-2*h+2,2)/2,"ease"),r=u((h,o,l)=>h+(o-h)*l,"lerp"),a=u(h=>{const o=Math.min(1,(h-i)/s),l=n(o);e.forEach((_,g)=>{const c=t.get(g);if(!(!c||c.t!==_.t))if(_.t==="c")g.setAttribute("cx",String(r(c.cx,_.cx,l))),g.setAttribute("cy",String(r(c.cy,_.cy,l)));else if(_.t==="r")g.setAttribute("x",String(r(c.x,_.x,l))),g.setAttribute("y",String(r(c.y,_.y,l)));else if(_.t==="l")g.setAttribute("x1",String(r(c.x1,_.x1,l))),g.setAttribute("y1",String(r(c.y1,_.y1,l))),g.setAttribute("x2",String(r(c.x2,_.x2,l))),g.setAttribute("y2",String(r(c.y2,_.y2,l)));else{if(!c.nums||c.nums.length!==_.nums.length)return;let E=0;const p=_.d.replace(ut._PATH_NUM_RE,()=>String(r(c.nums[E],_.nums[E++],l)));g.setAttribute("d",p)}}),this._tweenRaf=o<1?requestAnimationFrame(a):null},"step");this._tweenRaf=requestAnimationFrame(a)}toSVG(){const t=this.svg_element.cloneNode(!0);t.setAttribute("xmlns","http://www.w3.org/2000/svg"),t.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink");const e=this.svg_element.getBoundingClientRect();return e.width&&t.setAttribute("width",String(Math.round(e.width))),e.height&&t.setAttribute("height",String(Math.round(e.height))),new XMLSerializer().serializeToString(t)}toPNG(t=2){const e=this.toSVG(),s=this.svg_element.getBoundingClientRect(),i=Math.max(1,Math.round(s.width)),n=Math.max(1,Math.round(s.height));return new Promise((r,a)=>{const h=new Blob([e],{type:"image/svg+xml;charset=utf-8"}),o=URL.createObjectURL(h),l=new Image;l.onload=()=>{try{const _=document.createElement("canvas");_.width=i*t,_.height=n*t;const g=_.getContext("2d");if(!g){URL.revokeObjectURL(o),a(new Error("no 2d context"));return}g.scale(t,t),g.drawImage(l,0,0,i,n),URL.revokeObjectURL(o),r(_.toDataURL("image/png"))}catch(_){URL.revokeObjectURL(o),a(_)}},l.onerror=_=>{URL.revokeObjectURL(o),a(_)},l.src=o})}getPoints(){const t=this.__children__.search("__children__","points");return t?[...t.__data__.objects.values()].filter(e=>{var s;return((s=e.meta)==null?void 0:s.kind)==="point"}).map(e=>{var s,i,n;return{id:((s=e.meta)==null?void 0:s.unit)??e.ID,group:(i=e.meta)==null?void 0:i.group,set:(n=e.meta)==null?void 0:n.set,x:e.x,y:e.y}}):[]}pointsInRect(t){return this.getPoints().filter(e=>e.x>=t.x&&e.x<=t.x+t.w&&e.y>=t.y&&e.y<=t.y+t.h).map(e=>e.id)}_edgeKey(t,e){return t<=e?`${t}\0${e}`:`${e}\0${t}`}setHighlight(t){this._highlight.edges=new Set((t.edges??[]).map(e=>this._edgeKey(e.source,e.target))),this._highlight.nodes=new Set((t.nodes??[]).map(String)),this._applyHighlights()}clearHighlight(){this._highlight.edges.clear(),this._highlight.nodes.clear(),this._applyHighlights()}_applyHighlights(){if(!this.svg_element)return;this._highlightGroup||(this._highlightGroup=document.createElementNS("http://www.w3.org/2000/svg","g"),this._highlightGroup.setAttribute("data-layer-name","highlight"),this._highlightGroup.setAttribute("pointer-events","none")),this.svg_element.appendChild(this._highlightGroup);const t=this._highlightGroup;t.textContent="";const e=this.__data__.extremes.x_max||1,s="#f5a623",i=u((n,r)=>{const a=document.createElementNS("http://www.w3.org/2000/svg",n);for(const h in r)a.setAttribute(h,String(r[h]));return a},"mk");if(this._highlight.edges.size){const n={};this.getNodes().forEach(r=>{n[r.id]={x:r.x,y:r.y}}),this._highlight.edges.forEach(r=>{const[a,h]=r.split("\0"),o=n[a],l=n[h];!o||!l||t.appendChild(i("line",{x1:o.x,y1:o.y,x2:l.x,y2:l.y,stroke:s,"stroke-width":e*.02,"stroke-opacity":.6,"stroke-linecap":"round"}))})}this._highlight.nodes.forEach(n=>{var _;const r=this.svg_element.querySelector(`[data-point-id="${(_=window.CSS)!=null&&_.escape?CSS.escape(n):n}"]`);if(!r)return;const a=r.tagName.toLowerCase();let h,o,l;if(a==="rect"){const g=parseFloat(r.getAttribute("width")||"0");h=parseFloat(r.getAttribute("x")||"0")+g/2,o=parseFloat(r.getAttribute("y")||"0")+parseFloat(r.getAttribute("height")||"0")/2,l=g/2}else h=parseFloat(r.getAttribute("cx")||"0"),o=parseFloat(r.getAttribute("cy")||"0"),l=parseFloat(r.getAttribute("r")||"0");t.appendChild(i("circle",{cx:h,cy:o,r:l*1.7+e*.004,fill:"none",stroke:s,"stroke-width":e*.006}))})}create(){const t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.classList.add("graph"),t.style.display="block",t.style.width="100%",t.style.height="100%",t.setAttribute("preserveAspectRatio","xMidYMid meet"),t.setAttribute("viewBox",this.__data__.extremes.as_viewBox()),t.setAttribute("transform",this.__data__.transform.toString()),t.setAttribute("role","figure"),t.setAttribute("data-graph-size",`${Math.min(this.__data__.extremes.width,this.__data__.extremes.height)}`),this.svg_element=t;const e=document.createElementNS("http://www.w3.org/2000/svg","defs"),s=.22,i=.15,n=u((r,a)=>{const h=document.createElementNS("http://www.w3.org/2000/svg","marker");h.setAttribute("id",r),h.setAttribute("markerWidth",String(s)),h.setAttribute("markerHeight",String(i)),h.setAttribute("refX",String(s)),h.setAttribute("refY",String(i/2)),h.setAttribute("orient","auto"),h.setAttribute("markerUnits","userSpaceOnUse");const o=document.createElementNS("http://www.w3.org/2000/svg","path");o.setAttribute("d",`M0,0 L0,${i} L${s},${i/2} z`),o.setAttribute("fill",a),h.appendChild(o),e.appendChild(h)},"makeArrow");return Fs.forEach(r=>n(`qe-arrow-${r.slice(1)}`,r)),t.appendChild(e),this.__data__.layers.forEach(r=>{const a=new Oe(r,this.svg_element,this);this.__children__.push(a)}),this.__data__.__state__.setVariable("graph_updated",this.__data__),this.attach_events(),t}attach_events(){this.svg_element.addEventListener("wheel",o=>{console.log("Wheel event: ",o),o.preventDefault(),Math.sign(o.deltaY)<0?this.zoom_level*=1.1:this.zoom_level/=1.1,this.__data__.transform.zoom(this.zoom_level),this.update()});let t=!1,e,s;this.svg_element.addEventListener("mousedown",o=>{t=!0,e=o.clientX,s=o.clientY});let i=null,n=null;const r=u(()=>{n&&(this.__data__.transform.pan(n.dx,n.dy),this.__children__[0].svg_element.setAttribute("transform",this.__data__.transform.toString()),n=null),i=null},"panUpdate");this.svg_element.addEventListener("mousemove",o=>{if(!t)return;const l=o.clientX-e,_=o.clientY-s;n={dx:l/100,dy:_/100},e=o.clientX,s=o.clientY,i===null&&(i=requestAnimationFrame(r))}),this.svg_element.addEventListener("mouseup",o=>{t=!1}),this.svg_element.addEventListener("point-clicked",(o=>{var g,c;const l=(c=(g=o.detail)==null?void 0:g.pointData)==null?void 0:c.ID;if(!l)return;const _=this._pointLabels.get(l)??this._meanLabels.get(l.replace("mean-",""))??this._nodeLabels.get(l);_&&_.displayMode===H.DISPLAY_TYPES.CLICK&&_.toggle()}));const a=u(o=>{var l;for(;o&&o!==this.svg_element;){const _=(l=o.getAttribute)==null?void 0:l.call(o,"data-point-id");if(_)return _;o=o.parentElement}return null},"findPointId"),h=u(o=>this._pointLabels.get(o)??this._meanLabels.get(o.replace(/^mean-/,""))??this._nodeLabels.get(o),"getAutoLabel");this.svg_element.addEventListener("mouseover",o=>{const l=a(o.target);if(!l)return;const _=h(l);(_==null?void 0:_.displayMode)===H.DISPLAY_TYPES.AUTO&&_.show()}),this.svg_element.addEventListener("mouseout",o=>{const l=a(o.target);if(!l)return;const _=o.relatedTarget;if(a(_)===l)return;const c=h(l);(c==null?void 0:c.displayMode)===H.DISPLAY_TYPES.AUTO&&c.hide()}),this._attachInteractionEvents()}_emit(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e,bubbles:!0,composed:!0}))}_closestWith(t,e){var s,i;for(;t&&t!==this.svg_element;){if(((s=t.getAttribute)==null?void 0:s.call(t,e))!=null&&((i=t.hasAttribute)!=null&&i.call(t,e)))return t;t=t.parentElement}return null}_edgeDetail(t){const e=this._closestWith(t,"data-edge-source");if(!e)return null;const s={source:e.getAttribute("data-edge-source"),target:e.getAttribute("data-edge-target"),weight:parseFloat(e.getAttribute("data-edge-weight")||"0"),directed:e.getAttribute("data-edge-directed")==="true",self:e.getAttribute("data-edge-self")==="true"};return e.hasAttribute("data-edge-group")&&(s.group=e.getAttribute("data-edge-group")),e.hasAttribute("data-edge-unit")&&(s.unit=e.getAttribute("data-edge-unit")),s}_nodeDetail(t){const e=this._closestWith(t,"data-point-id");if(!e)return null;const s=e.tagName.toLowerCase();let i,n;s==="rect"?(i=parseFloat(e.getAttribute("x")||"0")+parseFloat(e.getAttribute("width")||"0")/2,n=parseFloat(e.getAttribute("y")||"0")+parseFloat(e.getAttribute("height")||"0")/2):(i=parseFloat(e.getAttribute("cx")||"0"),n=parseFloat(e.getAttribute("cy")||"0"));const r=e.getAttribute("data-point-id"),a={id:r,kind:e.getAttribute("data-kind")||"point",name:e.getAttribute("data-name")||r,x:i,y:n};return e.hasAttribute("data-group")&&(a.group=e.getAttribute("data-group")),e.hasAttribute("data-unit")&&(a.unit=e.getAttribute("data-unit")),a}_attachInteractionEvents(){const t=this.svg_element;t.addEventListener("click",i=>{const n=i.target,r=this._edgeDetail(n);if(r){this._emit("qe-edge-click",{...r,originalEvent:i});return}const a=this._nodeDetail(n);a&&this._emit("qe-node-click",{...a,originalEvent:i})});let e=null;const s=u((i,n)=>i==="edge"?`${n.source}\0${n.target}`:String(n.id),"keyOf");t.addEventListener("mousemove",i=>{const n=i.target,r=this._edgeDetail(n),a=r?null:this._nodeDetail(n),h=r?{type:"edge",detail:r}:a?{type:"node",detail:a}:null,o=h?s(h.type,h.detail):null;e&&(!h||e.key!==o)&&(this._emit(e.type==="edge"?"qe-edge-unhover":"qe-node-unhover",{key:e.key}),e=null),h&&(!e||e.key!==o)&&(this._emit(h.type==="edge"?"qe-edge-hover":"qe-node-hover",{...h.detail,originalEvent:i}),e={type:h.type,key:o}),this.hasAttribute("tooltip")&&h?this._showTooltip(this._tooltipText(h.type,h.detail),i.clientX,i.clientY):this._hideTooltip()}),t.addEventListener("mouseleave",()=>{e&&(this._emit(e.type==="edge"?"qe-edge-unhover":"qe-node-unhover",{key:e.key}),e=null),this._hideTooltip()})}_tooltipText(t,e){if(t==="edge"){const s=Number(e.weight),i=Number.isFinite(s)?` (${+s.toFixed(3)})`:"";return`${e.source} – ${e.target}${i}`}return String(e.name??e.id)}_showTooltip(t,e,s){if(!this._tooltipEl){const i=document.createElement("div");i.setAttribute("data-qe-tooltip",""),Object.assign(i.style,{position:"fixed",zIndex:"2147483647",pointerEvents:"none",background:"rgba(20,20,20,0.92)",color:"#fff",font:"12px/1.4 system-ui, sans-serif",padding:"3px 7px",borderRadius:"4px",whiteSpace:"nowrap",transform:"translate(-50%, calc(-100% - 8px))"}),document.body.appendChild(i),this._tooltipEl=i}this._tooltipEl.textContent=t,this._tooltipEl.style.left=`${e}px`,this._tooltipEl.style.top=`${s}px`,this._tooltipEl.style.display="block"}_hideTooltip(){this._tooltipEl&&(this._tooltipEl.style.display="none")}draw(){var t;if(!this.svg_element){console.error("No element to draw to: ",this);return}if((t=this.wrapper)==null||t.appendChild(this.svg_element),this.__children__.forEach(e=>{e.draw()}),!this._resizeObs&&typeof ResizeObserver<"u"&&this.svg_element){let e=0;this._resizeObs=new ResizeObserver(s=>{var n;const i=((n=s[0])==null?void 0:n.contentRect.width)??0;i>0&&Math.abs(i-e)>.5&&(e=i,this.update_labels(),this.update_axes())}),this._resizeObs.observe(this.svg_element)}}update(){this.update_extremes(),this.update_layers(),this.update_labels(),this.update_extremes(),this.update_axes(),this._applyHighlights()}update_axes(){var o,l;const t=this.__children__.search("__children__","axes");t!=null&&t.svg_element&&(t.svg_element.style.display=this._showAxes?"":"none");const e=this._labelsGroup,s=this.__data__.extremes.x_max,{cx:i,cy:n}=this.__data__.extremes;if(!e||s<=0)return;const r=s*.06,a=r*.6,h=u((_,g)=>{let c=this._axisLabelEls.get(_);if(!this._showAxes||g==null){c&&(c.remove(),this._axisLabelEls.delete(_));return}c||(c=document.createElementNS("http://www.w3.org/2000/svg","text"),c.setAttribute("data-axis-label",_),c.setAttribute("pointer-events","none"),e.appendChild(c),this._axisLabelEls.set(_,c)),c.textContent=g,c.setAttribute("font-size",r.toString()),c.setAttribute("font-family","system-ui, sans-serif"),c.setAttribute("font-weight","600"),c.setAttribute("fill","#556"),_==="x"?(c.setAttribute("x",(i+s-a).toString()),c.setAttribute("y",(-a).toString()),c.setAttribute("text-anchor","end")):(c.setAttribute("x",a.toString()),c.setAttribute("y",(n-s+r+a).toString()),c.setAttribute("text-anchor","start"))},"place");if(h("x",this._axisXText),h("y",this._axisYText),this._magnifyText==null)(o=this._magnifyEl)==null||o.remove(),this._magnifyEl=null;else{this._magnifyEl||(this._magnifyEl=document.createElementNS("http://www.w3.org/2000/svg","text"),this._magnifyEl.setAttribute("data-magnify-label",""),this._magnifyEl.setAttribute("pointer-events","none")),this._magnifyEl.parentElement||e.appendChild(this._magnifyEl);const _=this._magnifyEl;_.textContent=this._magnifyText,_.setAttribute("font-size",(r*.85).toString()),_.setAttribute("font-family","system-ui, sans-serif"),_.setAttribute("font-style","italic"),_.setAttribute("fill","#556"),_.setAttribute("x",(i-s+a).toString()),_.setAttribute("y",(n-s+r+a).toString()),_.setAttribute("text-anchor","start")}if(!this._plotTitle)(l=this._titleEl)==null||l.remove(),this._titleEl=null;else{this._titleEl||(this._titleEl=document.createElementNS("http://www.w3.org/2000/svg","text"),this._titleEl.setAttribute("data-plot-title",""),this._titleEl.setAttribute("pointer-events","none")),this._titleEl.parentElement||e.appendChild(this._titleEl);const g=(this._labelFont.size??12)*1.35*this.unitsPerPixel(),c=this._titleEl;c.textContent=this._plotTitle,c.setAttribute("font-size",g.toString()),c.setAttribute("font-family",this._labelFont.family??"system-ui, sans-serif"),c.setAttribute("font-weight","600"),c.setAttribute("fill",this._labelFont.color??"#223"),c.setAttribute("x",i.toString()),c.setAttribute("y",(n-s+g*1.1).toString()),c.setAttribute("text-anchor","middle")}}update_labels(){this._nodeLabels.forEach(t=>t.update()),this._meanLabels.forEach(t=>t.update()),this._pointLabels.forEach(t=>t.update())}update_extremes(){var s;const t=this.__data__;if(t.update_extremes(this._centerContent),this._rangeExtent&&this._rangeExtent>0){const{cx:i,cy:n}=t.extremes,r=this._centerContent&&this._rangeMode==="network"?t.nodeExtentFrom(i,n)*1.2:this._rangeExtent;t.extremes=new Rt(r,r,i,n)}const e=(s=this.svg_element)==null?void 0:s.getBoundingClientRect();if(this.svg_element&&e){console.log("SVG rect: ",e);let i,n;e.width===0||e.height===0?(i=1,n=1):(i=e.width,n=e.height),this.__data__.scale_x=1/(i/(4*this.__data__.extremes.x_max)),this.__data__.scale_y=1/(n/(4*this.__data__.extremes.y_max)),this.__children__[0].svg_element.setAttribute("transform",this.__data__.transform.toString()),this.svg_element.setAttribute("viewBox",this.__data__.extremes.as_viewBox());let r=this.__data__.layers.search("layers","axis_lines");if(r){let a=r.objects.get("axis-x"),h=r.objects.get("axis-y");if(a&&h){const o=this.__data__.extremes;a.from=new J({ID:"axis-x-start",dimensions:[o.cx-o.x_max,0],classes:["ena.dimension","ena.dimension"]}),a.to=new J({ID:"axis-x-end",dimensions:[o.cx+o.x_max,0],classes:["ena.dimension","ena.dimension"]}),h.from=new J({ID:"axis-y-start",dimensions:[0,o.cy-o.y_max],classes:["ena.dimension","ena.dimension"]}),h.to=new J({ID:"axis-y-end",dimensions:[0,o.cy+o.y_max],classes:["ena.dimension","ena.dimension"]})}}}}update_layers(){this.__children__.forEach(t=>{t.update()})}};u(ut,"QEGraphElement"),ut.tagName="qe-graph",ut.style=`
|
|
19
|
-
${
|
|
18
|
+
`;let ke=De;const Ns=1e-8;function Qe(d,t=Ns){return d.filter(e=>Math.abs(e.x)>t||Math.abs(e.y)>t)}u(Qe,"nearOriginFilter");function ks(d){if(d<=0)return[];if(d===1)return[0];const t=new Array(d);for(let e=0;e<d;e++)t[e]=e/(d-1);return t}u(ks,"normalizedT");function Cs(d,t){return d.map(e=>{const s=new Array(t+1);let i=1;for(let n=0;n<=t;n++)s[n]=i,i*=e;return s})}u(Cs,"design");function Os(d){const t=d.length,e=d[0].length,s=d.map(n=>n.slice()),i=Array.from({length:e},()=>new Array(e).fill(0));for(let n=0;n<e;n++){let r=0;for(let a=0;a<t;a++)r+=s[a][n]*s[a][n];if(r=Math.sqrt(r),i[n][n]=r,r>1e-300)for(let a=0;a<t;a++)s[a][n]/=r;for(let a=n+1;a<e;a++){let h=0;for(let o=0;o<t;o++)h+=s[o][n]*s[o][a];i[n][a]=h;for(let o=0;o<t;o++)s[o][a]-=h*s[o][n]}}return{Q:s,R:i}}u(Os,"qr");function ts(d,t){const e=d.length,s=d[0].length,i=new Array(s).fill(0);for(let n=0;n<s;n++){let r=0;for(let a=0;a<e;a++)r+=d[a][n]*t[a];i[n]=r}return i}u(ts,"qtY");function es(d,t){const e=t.length,s=new Array(e).fill(0);for(let i=e-1;i>=0;i--){let n=t[i];for(let r=i+1;r<e;r++)n-=d[i][r]*s[r];s[i]=Math.abs(d[i][i])>1e-12?n/d[i][i]:0}return s}u(es,"backSolve");function li(d){return d.map(t=>{let e=0;for(let s=0;s<t.length;s++)e+=t[s]*t[s];return e})}u(li,"leverages");function $s(d,t,e){const s=Cs(d,e),{Q:i,R:n}=Os(s);return es(n,ts(i,t))}u($s,"fitCoeffs");function Ce(d,t){let e=0,s=1;for(let i=0;i<d.length;i++)e+=d[i]*s,s*=t;return e}u(Ce,"evalPoly");function ci(d,t,e,s){const i=Cs(d,s),{Q:n,R:r}=Os(i),a=li(n),h=es(r,ts(n,t)),o=es(r,ts(n,e));let l=0;for(let _=0;_<d.length;_++){const g=1-a[_];if(g<=0)return 1/0;const c=t[_]-Ce(h,d[_]),M=e[_]-Ce(o,d[_]);l+=(c/g)**2+(M/g)**2}return l}u(ci,"loocv2d");function Ps(d,t,e){const s=d.length,i=Math.min(Math.max(1,Math.floor(t)),Math.max(1,s-1));if(e==="fixed"||s<3)return i;const n=ks(s),r=d.map(l=>l.x),a=d.map(l=>l.y);let h=1,o=1/0;for(let l=1;l<=i;l++){const _=ci(n,r,a,l);_<o&&(o=_,h=l)}return h}u(Ps,"selectDegree");function Rs(d,t){const e=Qe(d);if(e.length<3)return null;const s=t.selectionSet?Qe(t.selectionSet):e,i=s.length>=3?s:e;let n=Ps(i,t.maxDegree,t.degreeSelection);n=Math.min(n,Math.max(1,e.length-1));const r=ks(e.length),a=$s(r,e.map(o=>o.x),n),h=$s(r,e.map(o=>o.y),n);return{degree:n,coeffsX:a,coeffsY:h}}u(Rs,"fitTrajectory");function ss(d,t=100){const e=[];for(let s=0;s<=t;s++){const i=s/t;e.push({x:Ce(d.coeffsX,i),y:Ce(d.coeffsY,i)})}return e}u(ss,"sampleCurve");const Ls=100,fs=class fs extends kt{constructor(t={}){const e=t.color instanceof et?t.color:new et(typeof t.color=="string"?t.color:"#000000");super([],{ID:t.ID||`traj-${Math.random().toString(36).substring(2,9)}`,size:t.size||1,color:e,highlight:null,active:t.active||!1,meta:t.meta||{},...t}),this._typeName="Trajectory",this.trajPoints=[],this.smooth="none",this.maxDegree=3,this.degreeSelection="loocv_2d",this.selectedDegree=-1,this.polyCoeffsX=[],this.polyCoeffsY=[],this.currentTime=1/0,this.showPoints=!0,this.showTips=!0,this.lineStyle="uniform",this.strokeWidth=2,this.strokeWidthRange=[1,6],this.opacityRange=[.3,1],this.smooth=t.smooth||"none",this.maxDegree=t.maxDegree!==void 0?t.maxDegree:3,this.degreeSelection=t.degreeSelection||"loocv_2d",this.polyCoeffsX=t.polyCoeffsX||[],this.polyCoeffsY=t.polyCoeffsY||[],this.currentTime=t.currentTime!==void 0?t.currentTime:1/0,this.showPoints=t.showPoints!==void 0?t.showPoints:!0,this.showTips=t.showTips!==void 0?t.showTips:!0,this.lineStyle=t.lineStyle||"uniform",this.strokeWidth=t.strokeWidth||2,this.strokeWidthRange=t.strokeWidthRange||[1,6],this.opacityRange=t.opacityRange||[.3,1],t.points&&Array.isArray(t.points)&&(this.trajPoints=t.points.map(s=>{if(s instanceof K)return s;const i=new K({dimensions:[s.x,s.y],meta:{time:s.time,label:s.label}});return i.x=s.x,i.y=s.y,i}))}get activePoints(){return this.currentTime===1/0?this.trajPoints:this.trajPoints.filter(t=>(t.meta&&typeof t.meta.time=="number"?t.meta.time:0)<=this.currentTime)}get path(){return this.pathPoints.reduce((t,e,s)=>s===0?`M${e.x},${e.y}`:`${t} L${e.x},${e.y}`,"")}get pathPoints(){const t=this.activePoints;if(t.length<2)return[];if(this.smooth==="poly"){if(this.polyCoeffsX.length>0&&this.polyCoeffsY.length>0)return ss({degree:this.polyCoeffsX.length-1,coeffsX:this.polyCoeffsX,coeffsY:this.polyCoeffsY},Ls);const e=Rs(t.map(s=>({x:s.x,y:s.y})),{maxDegree:this.maxDegree,degreeSelection:this.degreeSelection,selectionSet:this.trajPoints.map(s=>({x:s.x,y:s.y}))});if(e)return this.selectedDegree=e.degree,ss(e,Ls)}return t.map(e=>({x:e.x,y:e.y}))}};u(fs,"Trajectory");let ie=fs;const Ts=1,ps=class ps extends qt{constructor(t,e,s,i=0){super(t,e,s),this._totalweight=0,this._weight=i}get base_color(){return this._color}get color(){const t=this._color||new et("#000000");return new te(t,Math.abs(this.weight))}set color(t){this._color=t}base_weight(){return this._weight}get weight(){return Array.isArray(this._weight)?this._weight[0]-this._weight[1]:this._weight}set weight(t){this._weight=t}get totalweight(){return this.weight}set totalweight(t){this._totalweight=t}};u(ps,"Edge");let ne=ps;const bs=class bs extends kt{constructor(e){super(e.dimensions||[],e);it(this,Wt);X(this,Wt,e)}get edge(){return C(this,Wt)}get path(){const e=C(this,Wt),s=[e.to.x,e.to.y],i=e.from_point,[n,r]=e.base_pts,a=Math.hypot(i[0]-s[0],i[1]-s[1]),h=Math.hypot(n[0]-r[0],n[1]-r[1]);if(!(a>0)||!(h>0))return"";const o=[(i[0]-s[0])/a,(i[1]-s[1])/a],l=Math.hypot(n[0]-s[0],n[1]-s[1]),_=[(n[0]-s[0])/l,(n[1]-s[1])/l],g=u(G=>h/2*Math.max(0,1-G/a),"halfW"),c=u((G,S)=>`${s[0]+o[0]*G+_[0]*S} ${s[1]+o[1]*G+_[1]*S}`,"at"),M=.2*a,f=Math.min(.15*a,.8*2*g(M)),v=M+f/2,R=M+f;return`M${c(M,0)} L${c(v,g(v))} L${c(R,g(R))} L${c(v,0)} L${c(R,-g(R))} L${c(v,-g(v))}z`}};Wt=new WeakMap,u(bs,"EdgeArrow");let Oe=bs;const ze=class ze extends ne{constructor(e,s,i){super(e,s,i);it(this,Vt);it(this,Ee);this._path="",X(this,Vt,!1),this._directions=["from","to"],this.towards="to",C(this,Vt)===!0&&X(this,Ee,new Oe(this))}get path(){return`M${this.from.x} ${this.from.y} L${this.base_pts[0].join(" ")} L${this.base_pts[1].join(" ")}z`}static calculate_base_points(e){const s=e.towards,i=e._directions.find(v=>v!==e.towards),n=e[i].x,r=e[i].y,a=e[s].x,h=e[s].y,o=a-n,l=h-r,_=Math.hypot(o,l),g=(e.weight??0)*Ts;if(_===0||!isFinite(g)||g===0)return[[a,h],[a,h]];const c=-l/_,M=o/_,f=g/2;return[[a+c*f,h+M*f],[a-c*f,h-M*f]]}get base_pts(){return ze.calculate_base_points(this)}get arrow(){return C(this,Ee)}get with_arrow(){return C(this,Vt)}get from_point(){return[this.from.x,this.from.y]}};Vt=new WeakMap,Ee=new WeakMap,u(ze,"TaperedEdge");let Gt=ze;const Fe=class Fe extends Gt{constructor(t,e,s){super(t,e,s),this._dataWeight=0,this._totalweight=t.totalweight??0,this._dataWeight=t.weight??this._weight}get weighted_midpoint(){return se.Geometry.Line.interpolate(this.line)(1-this._dataWeight/this._totalweight)}get base_pts(){return Gt.calculate_base_points(this)}static build_path(t){return t._totalweight>0?`M${t.weighted_midpoint[0]} ${t.weighted_midpoint[1]} L${t.base_pts[0].join(" ")} L${t.base_pts[1].join(" ")}z`:(console.error("TaperedWeightedMidpointEdge: No totalweight, returning empty path"),"")}get path(){return Fe.build_path(this)}get from_point(){return this.weighted_midpoint}};u(Fe,"TaperedWeightedMidpointEdge");let is=Fe;const je=class je extends ne{constructor(t,e,s){super(t,e,s)}static build_path(t,e){let s=t/2,i=e.x-s,n=s*2;return`M ${i}, ${e.y} a ${s},${s} 0 1,0 ${n},0 a ${s},${s} 0 1,0 -${n},0`}get path(){let t=this.weight*Ts;return je.build_path(t,this.to)}};u(je,"NodeEdge");let re=je;const ys=class ys{constructor(t,e,s,i=new Ct){this.__data__=t,this.parent=e,this.graph=s,this.__children__=i,this.svg_element=this.create()}get_size(){return this.__data__.size}draw(){var t;(t=this.parent)==null||t.appendChild(this.svg_element)}update(t,e=!0){}animateSVGAttribute(t,e,s){const i=parseFloat(t.getAttribute(e)||"0");if(i===s)return;const n=5e3,r=performance.now();function a(h){const o=Math.min(1,(h-r)/n),l=i+(s-i)*o;t.setAttribute(e,l.toString()),o<1?requestAnimationFrame(a):t.setAttribute(e,s.toString())}u(a,"animate"),requestAnimationFrame(a)}};u(ys,"Drawable");let oe=ys;const _i=.04,ui=[.25,1],di=[.3,1];function Ds(d,t,e,s){const i=Math.abs(d);if(!(i>0))return 0;if(!(e>t))return s[1];const n=Math.min(1,Math.max(0,(i-t)/(e-t)));return s[0]+n*(s[1]-s[0])}u(Ds,"rampFor");const gi=.011,mi=.75,fi=.8,pi=.75,zs=.006,bi=.6;function yi(d){return 2*d}u(yi,"widthPerWeight");function xi(d,t){return d*t/(2*zs)}u(xi,"nodeSizeForEdges");function wi(d){const t=/rgba?\(([^)]+)\)/.exec(d);if(!t)return d;const[e,s,i,n=1]=t[1].split(",").map(Number),r=u(a=>Math.round(255+(a-255)*n),"f");return`rgb(${r(e)},${r(s)},${r(i)})`}u(wi,"flattenOnWhite");function Ai(d,t){const e=/rgba?\(([^)]+)\)/.exec(d);if(!e)return d;const[s,i,n,r=1]=e[1].split(",").map(Number);return`rgba(${Math.round(s*t)},${Math.round(i*t)},${Math.round(n*t)},${r})`}u(Ai,"darkenRgba");const xs=class xs extends oe{constructor(t,e,s,i=new Ct){super(t,e,s,i),this.__data__=t,this.parent=e,this.graph=s,this.__children__=i,this.__name__="unnamed-line",this._arrow_el=null,this._hit_el=null,this.svg_element=this.create()}_stampEdge(t){const e=this.__data__.meta??{};e.isMeanEdge&&(t.setAttribute("data-edge-source",String(e.source??"")),t.setAttribute("data-edge-target",String(e.target??"")),t.setAttribute("data-edge-weight",String(e.weight??0)),t.setAttribute("data-edge-directed",e.isDirected?"true":"false"),e.isSelf&&t.setAttribute("data-edge-self","true"),e.group!=null&&t.setAttribute("data-edge-group",String(e.group)),e.unit!=null&&t.setAttribute("data-edge-unit",String(e.unit)))}create(){if(this.__data__ instanceof re){const e=document.createElementNS("http://www.w3.org/2000/svg","path");return e.setAttribute("fill",this.__data__.color.toString()),e.setAttribute("stroke","none"),this.svg_element=e,e}if(this.__data__ instanceof Gt){const e=document.createElementNS("http://www.w3.org/2000/svg","path");return e.setAttribute("fill",this.__data__.color.toString()),e.setAttribute("stroke","none"),this.svg_element=e,e}const t=document.createElementNS("http://www.w3.org/2000/svg","line");return t.setAttribute("x1",this.__data__.from.x.toString()),t.setAttribute("y1",this.__data__.from.y.toString()),t.setAttribute("x2",this.__data__.to.x.toString()),t.setAttribute("y2",this.__data__.to.y.toString()),t.setAttribute("stroke-width",this.get_size().toString()),t.setAttribute("stroke",this.__data__.color.toString()),this.svg_element=t,t}update(){var s;this.svg_element||this.create(),this.svg_element.parentElement||this.parent.appendChild(this.svg_element);const t=((s=this.graph.__data__.extremes)==null?void 0:s.x_max)??1,e=this.__data__.meta??{};if(e.isMeanEdge){this._stampEdge(this.svg_element);const i=typeof e.weight=="number"?e.weight:0,n=typeof e.maxWeight=="number"?e.maxWeight:1,r=typeof e.opacity=="number"?e.opacity:Math.min(1,i/(n||1)),a=t>0?t:1,h=typeof e.widthFrac=="number"?a*e.widthFrac*i:a*gi*(i/(n||1)),o=this.__data__._color||new et("#000000"),l=typeof e.saturation=="number"?e.saturation:r,_=new te(o,l,r).toString();if(this.__data__ instanceof re)this.__data__.weight=h,this.svg_element.setAttribute("d",this.__data__.path),this.svg_element.setAttribute("fill",_),this.svg_element.setAttribute("stroke","none");else if(this.__data__ instanceof Gt){if(this.__data__.weight=h,this.svg_element.setAttribute("d",this.__data__.path),this.svg_element.setAttribute("fill",_),this.svg_element.setAttribute("stroke",_),this.svg_element.setAttribute("stroke-width",String(mi)),this.svg_element.setAttribute("vector-effect","non-scaling-stroke"),this.svg_element.setAttribute("stroke-linejoin","round"),e.isDirected)try{const c=new Oe(this.__data__).path;c&&!c.includes("NaN")&&!c.includes("Infinity")&&(this._arrow_el||(this._arrow_el=document.createElementNS("http://www.w3.org/2000/svg","path"),this._arrow_el.setAttribute("stroke","none")),this._arrow_el.parentElement||this.parent.appendChild(this._arrow_el),this._arrow_el.setAttribute("d",c),this._arrow_el.setAttribute("fill",Ai(wi(_),fi)),this._arrow_el.setAttribute("stroke","#ffffff"),this._arrow_el.setAttribute("stroke-width",String(pi)),this._arrow_el.setAttribute("vector-effect","non-scaling-stroke"),this._arrow_el.setAttribute("stroke-linejoin","round"))}catch{}}else{const g=this.__data__.from.x,c=this.__data__.from.y,M=this.__data__.to.x,f=this.__data__.to.y;this.svg_element.setAttribute("x1",g.toString()),this.svg_element.setAttribute("y1",c.toString()),this.svg_element.setAttribute("x2",M.toString()),this.svg_element.setAttribute("y2",f.toString()),this.svg_element.setAttribute("stroke-width",h.toString()),this.svg_element.setAttribute("stroke",_),this.svg_element.setAttribute("pointer-events","stroke"),this.svg_element.removeAttribute("marker-end"),this._hit_el||(this._hit_el=document.createElementNS("http://www.w3.org/2000/svg","line"),this._hit_el.setAttribute("stroke","transparent"),this._hit_el.setAttribute("stroke-linecap","round"),this._hit_el.setAttribute("pointer-events","stroke")),this._hit_el.parentElement||this.parent.appendChild(this._hit_el),this._hit_el.setAttribute("x1",g.toString()),this._hit_el.setAttribute("y1",c.toString()),this._hit_el.setAttribute("x2",M.toString()),this._hit_el.setAttribute("y2",f.toString()),this._hit_el.setAttribute("stroke-width",Math.max(h,t*.03).toString()),this._stampEdge(this._hit_el)}}else{this.svg_element.setAttribute("x1",this.__data__.from.x.toString()),this.svg_element.setAttribute("y1",this.__data__.from.y.toString()),this.svg_element.setAttribute("x2",this.__data__.to.x.toString()),this.svg_element.setAttribute("y2",this.__data__.to.y.toString());const i=(t>0?t:1)*.004*this.get_size();this.svg_element.setAttribute("stroke-width",i.toString()),this.svg_element.setAttribute("stroke-opacity","1"),this.svg_element.setAttribute("stroke",this.__data__.color.toString())}}draw(){var t,e,s;this._hit_el&&((t=this.parent)==null||t.appendChild(this._hit_el)),(e=this.parent)==null||e.appendChild(this.svg_element),this._arrow_el&&((s=this.parent)==null||s.appendChild(this._arrow_el))}};u(xs,"QELine");let At=xs;const ws=class ws extends oe{constructor(t,e,s,i=new Ct){super(t,e,s,i),this.__data__=t,this.parent=e,this.graph=s,this.__children__=i,this.__name__="unnamed-point",this.svg_element=this.create()}get x(){return this.__data__.dimensions[this.graph.__data__.options.GRAPH.dimensions[0]]}get y(){return this.__data__.dimensions[this.graph.__data__.options.GRAPH.dimensions[1]]}get isSquare(){return this.__data__.shape==="rect"}get shapeKind(){const t=this.__data__.shape;return t==="rect"||t==="square"?"rect":t==="triangle"||t==="diamond"?t:"circle"}get tag(){const t=this.shapeKind;return t==="circle"?"circle":t==="rect"?"rect":"path"}setGeometry(t,e){const s=this.x,i=this.y;switch(this.shapeKind){case"rect":t.setAttribute("x",(s-e).toString()),t.setAttribute("y",(i-e).toString()),t.setAttribute("width",(e*2).toString()),t.setAttribute("height",(e*2).toString());break;case"triangle":{const n=e*1.15;t.setAttribute("d",`M${s} ${i-n} L${s+n*.866} ${i+n*.5} L${s-n*.866} ${i+n*.5}Z`);break}case"diamond":t.setAttribute("d",`M${s} ${i-e*1.2} L${s+e} ${i} L${s} ${i+e*1.2} L${s-e} ${i}Z`);break;default:t.setAttribute("cx",s.toString()),t.setAttribute("cy",i.toString()),t.setAttribute("r",e.toString())}}computeRadius(){var s;const t=this.baseRadius(),e=(s=this.__data__.meta)==null?void 0:s.maxRadius;return typeof e=="number"&&e>0?Math.min(t,e):t}baseRadius(){var s,i,n,r;const t=this.graph.__data__.extremes.x_max||1,e=((s=this.__data__.meta)==null?void 0:s.sizeScale)??1;if((i=this.__data__.meta)!=null&&i.fixedSize){const a=(r=(n=this.graph.svg_element)==null?void 0:n.getBoundingClientRect)==null?void 0:r.call(n),h=this.graph.zoom_level||1,o=a&&a.width>0?a.width/(2*t):1;return this.__data__.size*2*e/o/h}return t*zs*this.__data__.size*e}applyStroke(t){var s;const e=(s=this.__data__.meta)==null?void 0:s.stroke;e&&(t.setAttribute("stroke",e),t.setAttribute("stroke-width",(this.computeRadius()*.22).toString()))}create(){const t=document.createElementNS("http://www.w3.org/2000/svg",this.tag);t.setAttribute("data-point-id",this.__data__.ID);const e=this.__data__.meta??{};return e.kind&&t.setAttribute("data-kind",e.kind),e.name!=null&&t.setAttribute("data-name",String(e.name)),e.group!=null&&t.setAttribute("data-group",String(e.group)),e.unit!=null&&t.setAttribute("data-unit",String(e.unit)),t.setAttribute("fill",this.__data__.color.toString()),this.applyStroke(t),this.setGeometry(t,this.computeRadius()),this.svg_element=t,t.addEventListener("click",()=>{this.__data__.active=!this.__data__.active,this.update();const s=new CustomEvent("point-clicked",{detail:{pointData:this.__data__},bubbles:!0,composed:!0});this.svg_element.dispatchEvent(s)}),t.addEventListener("mouseover",()=>{}),t}update(){this.svg_element||this.parent.__data__.__children__.push(this.create()),this.svg_element.parentElement||this.parent.appendChild(this.svg_element),this.svg_element.setAttribute("fill",this.__data__.color.toString()),this.applyStroke(this.svg_element),this.setGeometry(this.svg_element,this.computeRadius())}draw(){var t;(t=this.parent)==null||t.appendChild(this.svg_element)}};u(ws,"QEPoint");let Ut=ws;const As=class As extends oe{constructor(t,e,s,i=new Ct){super(t,e,s,i),this.__data__=t,this.parent=e,this.graph=s,this.__children__=i,this.__name__="trajectory",this._path_el=null,this._segments_group=null,this._tip_el=null,this._points_group=null,this.svg_element=this.create()}graphUnitsForPixels(t){var i;const e=this.graph.__data__.extremes.x_max||1,s=((i=this.graph.svg_element)==null?void 0:i.getBoundingClientRect().width)||0;return s>0?t*(2*e/s):t*e*.006}create(){const t=document.createElementNS("http://www.w3.org/2000/svg","g");t.setAttribute("class","qe-trajectory-group");const e=document.createElementNS("http://www.w3.org/2000/svg","path");e.setAttribute("fill","none"),e.setAttribute("stroke",this.__data__.color.toString()),e.setAttribute("stroke-width",this.graphUnitsForPixels(this.__data__.strokeWidth).toString()),t.appendChild(e),this._path_el=e;const s=document.createElementNS("http://www.w3.org/2000/svg","g");s.setAttribute("class","qe-trajectory-segments"),t.appendChild(s),this._segments_group=s;const i=document.createElementNS("http://www.w3.org/2000/svg","g");if(i.setAttribute("class","qe-trajectory-points"),t.appendChild(i),this._points_group=i,this.__data__.showTips){const n=document.createElementNS("http://www.w3.org/2000/svg","circle");n.setAttribute("fill",this.__data__.color.toString()),n.setAttribute("r",this.graphUnitsForPixels(4).toString()),n.setAttribute("stroke","#ffffff"),n.setAttribute("stroke-width",this.graphUnitsForPixels(1.5).toString()),t.appendChild(n),this._tip_el=n}return this.svg_element=t,t}update(){this.svg_element||this.create(),this.svg_element.parentElement||this.parent.appendChild(this.svg_element);const t=this.__data__.path;if(this._path_el&&(this._path_el.setAttribute("d",t),this._path_el.setAttribute("stroke",this.__data__.color.toString()),this._path_el.setAttribute("stroke-width",this.graphUnitsForPixels(this.__data__.strokeWidth).toString()),this._path_el.style.display=this.__data__.lineStyle==="tapered"?"none":"block"),this._segments_group)if(this._segments_group.innerHTML="",this.__data__.lineStyle==="tapered"){const s=this.__data__.pathPoints,i=s.length-1,[n,r]=this.__data__.strokeWidthRange,[a,h]=this.__data__.opacityRange;for(let o=0;o<i;o++){const l=s[o],_=s[o+1],g=i<=1?1:o/(i-1),c=n+(r-n)*g,M=a+(h-a)*g,f=document.createElementNS("http://www.w3.org/2000/svg","path");f.setAttribute("d",`M${l.x},${l.y} L${_.x},${_.y}`),f.setAttribute("fill","none"),f.setAttribute("stroke",this.__data__.color.toString()),f.setAttribute("stroke-linecap","round"),f.setAttribute("stroke-linejoin","round"),f.setAttribute("stroke-width",this.graphUnitsForPixels(c).toString()),f.setAttribute("opacity",M.toString()),this._segments_group.appendChild(f)}this._segments_group.style.display="block"}else this._segments_group.style.display="none";const e=this.__data__.activePoints;if(this._points_group&&(this.__data__.showPoints&&e.length>0?(this._points_group.innerHTML="",e.forEach(s=>{var n;const i=document.createElementNS("http://www.w3.org/2000/svg","circle");i.setAttribute("cx",s.x.toString()),i.setAttribute("cy",s.y.toString()),i.setAttribute("r",this.graphUnitsForPixels(2.5).toString()),i.setAttribute("fill",this.__data__.color.toString()),i.setAttribute("opacity","0.7"),(n=this._points_group)==null||n.appendChild(i)}),this._points_group.style.display="block"):this._points_group.style.display="none"),this._tip_el&&this.__data__.showTips)if(e.length>0){const s=e[e.length-1];this._tip_el.setAttribute("cx",s.x.toString()),this._tip_el.setAttribute("cy",s.y.toString()),this._tip_el.setAttribute("fill",this.__data__.color.toString()),this._tip_el.setAttribute("r",this.graphUnitsForPixels(4).toString()),this._tip_el.setAttribute("stroke-width",this.graphUnitsForPixels(1.5).toString()),this._tip_el.style.display="block"}else this._tip_el.style.display="none"}draw(){this.svg_element&&!this.svg_element.parentElement&&this.parent.appendChild(this.svg_element),this.update()}};u(As,"QETrajectory");let ae=As;const{ArrayTools:Fs}=se,vs=class vs extends Array{constructor(...t){super(...t)}search(t,e){let s;function i(r){return r.name===e?r:void 0}u(i,"fn");function n(r,a,h=null){if(Fs.isArray(r)){for(const[o,l]of r.entries())if(s=n(l,o,h),s)return s}else{if(s=i(r),s)return s;if(r&&Fs.isArray(r[t])){for(const[o,l]of r[t].entries())if(s=n(l,o,r),s)return s}}return s}return u(n,"recurse"),n(this)}flatten(){return this.reduce((t,e)=>(t.push(e),e.layers&&Array.isArray(e.layers)&&t.push(...e.layers),t),[])}};u(vs,"QEArray");let Ct=vs;const vi={AxisPoint:Ut,AxisLine:At,Point:Ut,Line:At,Edge:At,TaperedEdge:At,TaperedWeightedMidpointEdge:At,NodeEdge:At,Trajectory:ae},Kt=class Kt{constructor(t,e,s,i=new Ct){this.__data__=t,this.parent=e,this.graph=s,this.__children__=i,this.__name__=t.name||"unnamed-layer",t.__state__.addListener("layer_updated","live",({key:n,newValue:r,oldValue:a})=>{const h=u(g=>{var c;return(c=g.__data__)==null?void 0:c.ID},"childId"),o=this.__children__.filter(g=>!r.objects.has(h(g))),l=this.__children__.filter(g=>r.objects.has(h(g)));[...r.objects.values()].filter(g=>!this.__children__.some(c=>h(c)===g.ID)).forEach(g=>{const c=g._typeName||g.constructor.name;let M=vi[c];M||(g instanceof ie?M=ae:g instanceof K?M=Ut:M=At);const f=new M(g,this.svg_element,this.graph);this.__children__.push(f)}),l.forEach(g=>{const c=r.objects.get(h(g));c&&(g.__data__=c),g.update()}),o.forEach(g=>{g.svg_element.parentElement&&g.svg_element.parentElement.removeChild(g.svg_element);const c=this.__children__.indexOf(g);c>=0&&this.__children__.splice(c,1)}),this.update()}),this.svg_element=this.create()}get name(){return this.__name__}create(){if(!this.__data__)throw new Error("Layer is null");let t=this.__data__;return this.svg_element=document.createElementNS("http://www.w3.org/2000/svg",Kt.tagName),this.svg_element.setAttribute("data-layer-name",t.name),this.svg_element.setAttribute("data-layer-id",t.ID),this.svg_element.__data__=t,this.svg_element.classList.add("ena-layer"),this.__data__.layers&&this.__data__.layers.length>0&&this.__data__.layers.forEach(e=>{const s=new Kt(e,this.svg_element,this.graph);this.__children__.push(s)}),this.svg_element}update(){if(!this.__data__)throw new Error("Layer is null");this.__data__.visible&&(this.parent.nodeName.toLowerCase(),this.__children__.forEach(t=>{t.update()}),this.__data__.scale_objects===!0&&this.__name__)}draw(){var t;(t=this.parent)==null||t.appendChild(this.svg_element),this.__children__.forEach(e=>{e.draw()})}add(t){this.__children__.push(t)}};u(Kt,"QELayer"),Kt.tagName="g";let $e=Kt;const Ss=class Ss{constructor(t,e,s,i,n=H.DISPLAY_TYPES.ON,r=H.POSITION.OBJECT,a,h){this.text=t,this.point=e,this.parent=s,this.graph=i,this.displayMode=n,this.position=r,this.customX=a,this.customY=h,this._visible=!1,this._offsetX=0,this._offsetY=0,this.pinned=!1,this.svg_element=this._create(),n===H.DISPLAY_TYPES.ON?(this._visible=!0,this.svg_element.setAttribute("display","block")):(this._visible=!1,this.svg_element.setAttribute("display","none"))}_create(){const t=document.createElementNS("http://www.w3.org/2000/svg","text");return t.textContent=this.text,t.setAttribute("data-label-for",this.point.ID),t.setAttribute("pointer-events","auto"),t.style.cursor="grab",this._attachDrag(t),this.parent.appendChild(t),t}_attachDrag(t){t.addEventListener("mousedown",e=>{e.preventDefault(),e.stopPropagation();const s=t.ownerSVGElement;if(!s)return;const i=u((l,_)=>{const g=s.createSVGPoint();g.x=l,g.y=_;const c=s.getScreenCTM();return c?g.matrixTransform(c.inverse()):{x:0,y:0}},"toUser"),n=i(e.clientX,e.clientY),r=this._offsetX,a=this._offsetY;t.style.cursor="grabbing";const h=u(l=>{const _=i(l.clientX,l.clientY);this._offsetX=r+(_.x-n.x),this._offsetY=a+(_.y-n.y),this.pinned=!0,this._visible=!0,this.svg_element.setAttribute("display","block"),this.update()},"onMove"),o=u(()=>{document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",o),t.style.cursor="grab",this.graph.dispatchEvent(new CustomEvent("qe-label-move",{detail:{id:this.point.ID,transform:{x:this._offsetX,y:this._offsetY}},bubbles:!0,composed:!0}))},"onUp");document.addEventListener("mousemove",h),document.addEventListener("mouseup",o)})}update(){var h;if(!this._visible)return;const t=this.graph.__data__.extremes.x_max;if(t<=0)return;const e=this.graph._labelFont??{},s=e.size?e.size*this.graph.unitsPerPixel():t*.06,i=s*1.2;let n,r,a;switch(this.position){case H.POSITION.STATIC:{n=this.point.x,r=this.point.y-i*.3,a="middle";break}case H.POSITION.CONTAINER:{const{cx:o,cy:l}=this.graph.__data__.extremes,_=this.point.x-o,g=this.point.y-l,c=Math.sqrt(_*_+g*g)||1,M=t*.93/c;n=o+_*M,r=l+g*M-i*.3,a=_>=0?"start":"end";break}case H.POSITION.CUSTOM:if(this.customX!=null&&this.customY!=null){n=this.customX,r=this.customY,a="start";break}default:case H.POSITION.OBJECT:{const o=this.point.x>=0?i:-i;a=this.point.x>=0?"start":"end",n=this.point.x+o,r=this.point.y-i*.4;break}}this.svg_element.setAttribute("x",n.toString()),this.svg_element.setAttribute("y",r.toString()),(this._offsetX||this._offsetY)&&this.svg_element.setAttribute("transform",`translate(${this._offsetX}, ${this._offsetY})`),this.svg_element.setAttribute("font-size",s.toString()),this.svg_element.setAttribute("font-family",e.family??"system-ui, sans-serif"),this.svg_element.setAttribute("font-weight","500"),this.svg_element.setAttribute("text-anchor",a),this.svg_element.setAttribute("fill",e.color??((h=this.point.color)==null?void 0:h.toString())??"#333333")}show(){this._visible=!0,this.svg_element.setAttribute("display","block"),this.update()}hide(){this.pinned||(this._visible=!1,this.svg_element.setAttribute("display","none"))}toggle(){this._visible?this.hide():this.show()}get visible(){return this._visible}remove(){this.svg_element.remove()}};u(Ss,"QELabel");let he=Ss;const Ye=class Ye extends HTMLElement{};u(Ye,"QENodesElement"),Ye.tagName="qe-nodes";let le=Ye;const qe=class qe extends HTMLElement{};u(qe,"QEMeansElement"),qe.tagName="qe-means";let ce=qe;const Ge=class Ge extends HTMLElement{};u(Ge,"QEPointsElement"),Ge.tagName="qe-points";let _e=Ge;const Ue=class Ue extends HTMLElement{};u(Ue,"QEEdgesElement"),Ue.tagName="qe-edges";let ue=Ue;const Be=class Be extends HTMLElement{};u(Be,"QETrajectoriesElement"),Be.tagName="qe-trajectories";let de=Be;const He=class He extends HTMLElement{};u(He,"QEAxesElement"),He.tagName="qe-axes";let ge=He;customElements.define(le.tagName,le),customElements.define(ce.tagName,ce),customElements.define(_e.tagName,_e),customElements.define(ue.tagName,ue),customElements.define(de.tagName,de),customElements.define(ge.tagName,ge);const js=["#4477AA","#EE6677","#228833","#CCBB44","#66CCEE","#AA3377","#BBBBBB","#000000"];function Si(d,t){for(const e of t)if(d===`${e}.${e}`)return[e,e];for(const e of t)if(d.startsWith(e+".")){const s=d.slice(e.length+1);if(t.includes(s))return[e,s]}return null}u(Si,"parseEdgePair");function Ei(d,t,e,s){const i=Math.max(1,e-1),n=i>=120?1.96:i>=60?2:i>=30?2.042:i>=20?2.086:i>=10?2.228:i>=5?2.571:4.303,r=Math.sqrt(Math.max(0,d)/e)*s,a=Math.sqrt(Math.max(0,t)/e)*s;return{halfW:n*r,halfH:n*a}}u(Ei,"computeCIRect");const Mi=.5;function Pe(d,t,e){if(!d)return;const s=Math.min(Math.abs(t),Math.abs(e));s>0&&(d.meta={...d.meta??{},maxRadius:s*Mi})}u(Pe,"capMeanToInterval");function Re(d,t,e,s=""){const i=u(o=>{const l=d.names.indexOf(o),_=l>=0?d[l]:null;if(_==null||_==="")return;const g=Number(_);return Number.isFinite(g)?g:void 0},"get"),n=i(`${t}.${s}low`)??i(`${t}_${s}low`),r=i(`${t}.${s}high`)??i(`${t}_${s}high`),a=i(`${e}.${s}low`)??i(`${e}_${s}low`),h=i(`${e}.${s}high`)??i(`${e}_${s}high`);return n==null||r==null||a==null||h==null?null:{x_low:n,x_high:r,y_low:a,y_high:h}}u(Re,"readIntervalBounds");function Ii(d){var i,n;const t=u(r=>d.getAttribute(r),"a"),e=((i=t("colors"))==null?void 0:i.split(",").map(r=>r.trim()).filter(Boolean))??[],s=((n=t("threshold"))==null?void 0:n.split(",").map(Number).filter(Number.isFinite))??[];return{group:t("group"),unit:t("unit"),compare:t("compare"),also:t("also"),network:t("network"),colors:e.length?[e[0],e[1]??null]:null,threshold:s.length?[s[0],s.length>1?s[1]:1/0]:null,name:t("name")}}u(Ii,"parseEdgeLayer");function Ni(d){const{r:t,g:e,b:s}=et.parseColor(d),i=Math.max(t,e,s),n=Math.min(t,e,s),r=u(a=>(i+n-a).toString(16).padStart(2,"0"),"f");return`#${r(t)}${r(e)}${r(s)}`}u(Ni,"complementColor");function ki(d){const t=d==null?void 0:d.trim().toLowerCase();return t==="plot"||t==="absolute"?t:"model"}u(ki,"parseColorScale");function ns(d,t){switch(d==null?void 0:d.toLowerCase()){case"on":return 3;case"off":return 0;case"click":return 2;case"auto":return 1;default:return t}}u(ns,"parseLabelMode");const ut=class ut extends ke{constructor(){super(),this.zoom_level=1,this.__children__=new Ct,this._hasModel=!1,this._renderPending=!1,this._childObserver=null,this._ciRects=new Map,this._outlierRects=new Map,this._ciCross=new Map,this._labelsGroup=null,this._nodeLabels=new Map,this._meanLabels=new Map,this._pointLabels=new Map,this._showAxes=!1,this._axisXText=null,this._axisYText=null,this._axisLabelEls=new Map,this._magnifyText=null,this._magnifyEl=null,this._rangeExtent=null,this._rangeMode=null,this._centerContent=!1,this._plotTitle=null,this._titleEl=null,this._resizeObs=null,this._labelFont={size:null,family:null,color:null},this._animateMs=0,this._tweenRaf=null,this._highlight={edges:new Set,nodes:new Set},this._highlightGroup=null,this._tooltipEl=null,this.graph=this,this.parent=null,this.__data__=new Ne(Is),this.__name__=this.__data__.name||"unnamed-graph",this.svg_element=this.create(),console.log("Created ena-graph svg element: ",this.svg_element),document.addEventListener("model-updated",t=>{var Gs,Us,Bs,Hs,Xs,Ws,Vs,Ks,Js,Zs,Qs,ti,ei,si,ii;const e=((Gs=t.composedPath)==null?void 0:Gs.call(t)[0])??t.target;if(this._vizena&&e!==this._vizena)return;const s=t.detail;if(!s)return;this._animateMs=this.hasAttribute("animate")?parseInt(this.getAttribute("animate")||"",10)||300:0;const i=this._animateMs>0&&this._hasModel?this._captureTween():null;this._hasModel=!0;const n=s.dimensions,r=s.unit_id_col,a=s.node_id_col,h=s.group_col,o=this._readLayerConfig();this._showAxes=o.showAxes,this._axisXText=o.axisXLabel===null?null:o.axisXLabel||String((n==null?void 0:n[0])??"x"),this._magnifyText=o.edgeMagnify==null?null:`(scaled ${o.edgeMagnify.toFixed(1)}x)`,this._axisYText=o.axisYLabel===null?null:o.axisYLabel||String((n==null?void 0:n[1])??"y");const l={},_=(Us=s.palette)!=null&&Us.length?s.palette:js;if(h&&((Bs=s.points)!=null&&Bs.names)){const O=s.points.col(h);O&&[...new Set([...O].map(String))].forEach(($,x)=>{l[$]=_[x%_.length]})}(Hs=s.groups)!=null&&Hs.rows&&s.groups.rows().length>0&&s.groups.rows().forEach(O=>{const N=O.rowName??String(O[0]),$=O.names.indexOf("color"),x=$>=0?O[$]:null;x&&String(x)!=="NA"?l[N]=String(x):l[N]||(l[N]=_[Object.keys(l).length%_.length])});const g=Object.keys(l),c=o.activeMeanGroups&&o.activeMeanGroups.trim()?new Set(o.activeMeanGroups.split(",").map(O=>O.trim()).filter(O=>l[O])):new Set(g),M=o.scalePoints,f=u(O=>{let N=0;return O.forEach($=>{const x=$.names.indexOf(n[0]),m=n.length>1?$.names.indexOf(n[1]):-1;x>=0&&(N=Math.max(N,Math.abs(Number($[x])))),m>=0&&(N=Math.max(N,Math.abs(Number($[m]))))}),N},"getExtent"),v=(Xs=s.nodes)!=null&&Xs.rows?f(s.nodes.rows()):0,R=(Ws=s.points)!=null&&Ws.rows?f(s.points.rows()):0,q=(Vs=s.trajectories)!=null&&Vs.rows?f(s.trajectories.rows()):0,G=R>0?R:q,S=o.pointScale!==null?o.pointScale:M&&G>0&&v>0?v/G:1;this._rangeExtent=o.range==="network"?v*1.2:o.range==="points"?G*S*1.2:typeof o.range=="number"?o.range:null,this._rangeMode=o.range==="network"||o.range==="points"?o.range:typeof o.range=="number"?"number":null,this._centerContent=o.centerContent,this._plotTitle=o.plotTitle,this._labelFont=o.labelFont;const Y=o.labelNodes,ot=o.labelMeans,ht=o.labelPoints,nt=this._labelsGroup,dt=u((O,N,$,x=1)=>{const m=O.names.indexOf(N),P=O.names.indexOf(n[0]),b=n.length>1?O.names.indexOf(n[1]):-1,y=new K({ID:m>=0?String(O[m]):O.rowName||`pt-${Math.random().toString(36).slice(2)}`,dimensions:[P>=0?Number(O[P])*x:0,b>=0?-Number(O[b])*x:0],meta:{}});return $&&(y.color=new et($)),y},"rowToPoint"),J={},$t=o.showPoints,zt=s.pointsets;if(o.pointSets.length&&(zt!=null&&zt.rows)){const O=this.__children__.search("__children__","points"),N=u(($,x)=>{const m=$.names.indexOf(x);return m>=0?$[m]:null},"col");o.pointSets.forEach(($,x)=>{zt.rows().forEach(m=>{if(String(N(m,"set"))!==$.set)return;const P=String(N(m,"id")),b=N(m,"group")!=null&&String(N(m,"group"))!=="NA"?String(N(m,"group")):null,y=N(m,"color")&&String(N(m,"color"))!=="NA"?String(N(m,"color")):b&&l[b]?l[b]:_[x%_.length],I=dt(m,"id",y,S);I.ID=`${$.set}::${P}`,I.size=$.size??o.pointSize??2.5;const j=N(m,"shape");j&&String(j)!=="NA"&&(I.shape=String(j));const L=N(m,"label");I.meta={stroke:"#ffffff",kind:"point",name:L!=null&&String(L)!=="NA"?String(L):P,group:b??void 0,unit:P,set:$.set,fixedSize:$.fixedSize},this.__data__.points.set(I.ID,I),O==null||O.__data__.objects.set(I.ID,I)})})}if((Ks=s.points)!=null&&Ks.rows){const O=this.__children__.search("__children__","points");if(O){s.points.rows().forEach(x=>{const m=h?x.names.indexOf(h):-1,P=m>=0?String(x[m]):null,b=P?l[P]??"#888888":"#888888";if($t){const y=dt(x,r,b,S);y.size=o.pointSize??2.5,y.meta={...y.meta??{},stroke:"#ffffff",kind:"point",name:y.ID,group:P??void 0,unit:y.ID,fixedSize:o.pointFixedSize},this.__data__.points.set(y.ID,y),O.__data__.objects.set(y.ID,y)}if(P){const y=x.names.indexOf(n[0]),I=n.length>1?x.names.indexOf(n[1]):-1;J[P]||(J[P]={x:0,y:0,x2:0,y2:0,xy:0,n:0,color:b});const j=y>=0?Number(x[y]):0,L=I>=0?Number(x[I]):0;J[P].x+=j,J[P].y+=L,J[P].x2+=j*j,J[P].y2+=L*L,J[P].xy+=j*L,J[P].n+=1}});const N=!!((Js=s.groups)!=null&&Js.rows&&s.groups.rows().length>0),$=o.showMeans&&N?s.groups.rows().filter(x=>{const m=x.rowName??String(x[0]);return c.size===0||c.has(m)}):[];if(o.showMeans){const x=O.svg_element,m=(v>0?v:1)*.008;if(N){const P=new Set($.map(b=>b.rowName??String(b[0])));this._ciRects.forEach((b,y)=>{P.has(y)||(b.remove(),this._ciRects.delete(y))}),this._outlierRects.forEach((b,y)=>{P.has(y)||(b.remove(),this._outlierRects.delete(y))}),this._ciCross.forEach((b,y)=>{P.has(y.slice(2))||(b.remove(),this._ciCross.delete(y))}),$.forEach(b=>{var w,k,z;const y=b.rowName??String(b[0]),I=l[y]??"#888888",j=b.names.indexOf(n[0]),L=n.length>1?b.names.indexOf(n[1]):-1,W=j>=0?Number(b[j])*S:0,ft=L>=0?-Number(b[L])*S:0,tt=new K({ID:`mean-${y}`,dimensions:[W,ft],meta:{kind:"mean",name:y,group:y,fixedSize:o.meanFixedSize}});tt.color=new et(I),tt.size=4;const mt=b.names.indexOf("shape"),T=mt>=0?b[mt]:null;tt.shape=T&&String(T)!=="NA"?String(T):"rect",this.__data__.points.set(tt.ID,tt),O.__data__.objects.set(tt.ID,tt);const Ft=u(A=>{const F=b.names.indexOf(A),Z=F>=0?b[F]:null;return Z==null||String(Z)==="NA"||String(Z)===""?null:Z},"cell"),vt=Ft("intervals"),It=vt==="box"||vt==="crosshairs"||vt==="none"?vt:o.intervals,jt=Ft("outlier"),U=(jt==null?o.showOutlier:jt===!0||String(jt)==="true")?Re(b,n[0],n[1],"o"):null;if(!U)(w=this._outlierRects.get(y))==null||w.remove(),this._outlierRects.delete(y);else{let A=this._outlierRects.get(y);A||(A=document.createElementNS("http://www.w3.org/2000/svg","rect"),A.setAttribute("data-outlier-group",y),this._outlierRects.set(y,A)),A.setAttribute("x",(U.x_low*S).toString()),A.setAttribute("y",(-U.y_high*S).toString()),A.setAttribute("width",((U.x_high-U.x_low)*S).toString()),A.setAttribute("height",((U.y_high-U.y_low)*S).toString()),A.setAttribute("fill","none"),A.setAttribute("stroke",I),A.setAttribute("stroke-width",m.toString()),A.setAttribute("stroke-opacity","0.5"),A.setAttribute("stroke-dasharray",`${m*2} ${m*2}`),x&&!A.parentElement&&x.insertBefore(A,x.firstChild)}const rt=It!=="none"?Re(b,n[0],n[1]):null,p=`x:${y}`;if((!rt||It!=="crosshairs")&&((k=this._ciCross.get(p))==null||k.remove(),this._ciCross.delete(p)),rt&&It==="crosshairs"){(z=this._ciRects.get(y))==null||z.remove(),this._ciRects.delete(y);const A=rt.x_low*S,F=rt.x_high*S,Z=-rt.y_high*S,Q=-rt.y_low*S;Pe(tt,(F-A)/2,(Q-Z)/2);let D=this._ciCross.get(p);D||(D=document.createElementNS("http://www.w3.org/2000/svg","path"),D.setAttribute("data-ci-group",y),D.setAttribute("data-ci-kind","crosshairs"),this._ciCross.set(p,D)),D.setAttribute("d",`M${A} ${ft} L${F} ${ft} M${W} ${Z} L${W} ${Q}`),D.setAttribute("fill","none"),D.setAttribute("stroke",I),D.setAttribute("stroke-width",(m*1.25).toString()),D.setAttribute("stroke-opacity","0.8"),x&&!D.parentElement&&x.insertBefore(D,x.firstChild)}else if(rt){const A=rt.x_low*S,F=-rt.y_high*S,Z=(rt.x_high-rt.x_low)*S,Q=(rt.y_high-rt.y_low)*S;Pe(tt,Z/2,Q/2);let D=this._ciRects.get(y);D||(D=document.createElementNS("http://www.w3.org/2000/svg","rect"),D.setAttribute("data-ci-group",y),this._ciRects.set(y,D)),D.setAttribute("x",A.toString()),D.setAttribute("y",F.toString()),D.setAttribute("width",Z.toString()),D.setAttribute("height",Q.toString()),D.setAttribute("fill","none"),D.setAttribute("stroke",I),D.setAttribute("stroke-width",m.toString()),D.setAttribute("stroke-opacity","0.8"),D.setAttribute("stroke-dasharray",`${m*4} ${m*3}`),x&&!D.parentElement&&x.insertBefore(D,x.firstChild)}else{const A=this._ciRects.get(y);A&&(A.remove(),this._ciRects.delete(y))}})}else Object.entries(J).forEach(([b,{x:y,y:I,n:j,color:L}])=>{const W=new K({ID:`mean-${b}`,dimensions:[y/j*S,-(I/j)*S],meta:{kind:"mean",name:b,group:b,fixedSize:o.meanFixedSize}});W.color=new et(L),W.size=4,W.shape="rect",this.__data__.points.set(W.ID,W),O.__data__.objects.set(W.ID,W)}),o.showCI&&(this._ciRects.forEach((b,y)=>{J[y]||(b.remove(),this._ciRects.delete(y))}),(Zs=s.confidence)!=null&&Zs.rows?s.confidence.rows().forEach(b=>{const y=b.names.indexOf(h??"group"),I=y>=0?String(b[y]):b.rowName??null;if(!I)return;const j=l[I]??"#888888",L=Re(b,n[0],n[1]);if(!L)return;const W=L.x_low*S,ft=-L.y_high*S,tt=(L.x_high-L.x_low)*S,mt=(L.y_high-L.y_low)*S;Pe(this.__data__.points.get(`mean-${I}`),tt/2,mt/2);let T=this._ciRects.get(I);T||(T=document.createElementNS("http://www.w3.org/2000/svg","rect"),T.setAttribute("data-ci-group",I),this._ciRects.set(I,T)),T.setAttribute("x",W.toString()),T.setAttribute("y",ft.toString()),T.setAttribute("width",tt.toString()),T.setAttribute("height",mt.toString()),T.setAttribute("fill","none"),T.setAttribute("stroke",j),T.setAttribute("stroke-width",m.toString()),T.setAttribute("stroke-opacity","0.8"),T.setAttribute("stroke-dasharray",`${m*4} ${m*3}`),x&&!T.parentElement&&x.insertBefore(T,x.firstChild)}):Object.entries(J).forEach(([b,{x:y,y:I,x2:j,y2:L,n:W,color:ft}])=>{if(W<2)return;const tt=y/W,mt=I/W,T=j/W-tt*tt,Ft=L/W-mt*mt,{halfW:vt,halfH:It}=Ei(T,Ft,W,S),jt=tt*S,Zt=-mt*S;Pe(this.__data__.points.get(`mean-${b}`),vt,It);let U=this._ciRects.get(b);U||(U=document.createElementNS("http://www.w3.org/2000/svg","rect"),U.setAttribute("data-ci-group",b),this._ciRects.set(b,U)),U.setAttribute("x",(jt-vt).toString()),U.setAttribute("y",(Zt-It).toString()),U.setAttribute("width",(vt*2).toString()),U.setAttribute("height",(It*2).toString()),U.setAttribute("fill","none"),U.setAttribute("stroke",ft),U.setAttribute("stroke-width",m.toString()),U.setAttribute("stroke-opacity","0.8"),U.setAttribute("stroke-dasharray",`${m*4} ${m*3}`),x&&!U.parentElement&&x.insertBefore(U,x.firstChild)})),(Qs=s.outlier)!=null&&Qs.rows&&(this._outlierRects.forEach((b,y)=>{l[y]||(b.remove(),this._outlierRects.delete(y))}),s.outlier.rows().forEach(b=>{const y=b.names.indexOf(h??"group"),I=y>=0?String(b[y]):b.rowName??null;if(!I)return;const j=l[I]??"#888888",L=Re(b,n[0],n[1]);if(!L)return;const W=L.x_low*S,ft=-L.y_high*S,tt=(L.x_high-L.x_low)*S,mt=(L.y_high-L.y_low)*S;let T=this._outlierRects.get(I);T||(T=document.createElementNS("http://www.w3.org/2000/svg","rect"),T.setAttribute("data-outlier-group",I),this._outlierRects.set(I,T)),T.setAttribute("x",W.toString()),T.setAttribute("y",ft.toString()),T.setAttribute("width",tt.toString()),T.setAttribute("height",mt.toString()),T.setAttribute("fill","none"),T.setAttribute("stroke",j),T.setAttribute("stroke-width",m.toString()),T.setAttribute("stroke-opacity","0.5"),T.setAttribute("stroke-dasharray",`${m*2} ${m*2}`),x&&!T.parentElement&&x.insertBefore(T,x.firstChild)}))}nt&&(this._pointLabels.forEach((x,m)=>{O.__data__.objects.get(m)||(x.remove(),this._pointLabels.delete(m))}),this._meanLabels.forEach((x,m)=>{O.__data__.objects.get(`mean-${m}`)||(x.remove(),this._meanLabels.delete(m))}),ht!==0&&s.points.rows().forEach(x=>{const m=x.names.indexOf(r),P=m>=0?String(x[m]):null;if(!P)return;const b=O.__data__.objects.get(P);if(!b)return;const y=P;let I=this._pointLabels.get(P);I?ht===H.DISPLAY_TYPES.ON?I.show():I.hide():(I=new he(y,b,nt,this,ht),this._pointLabels.set(P,I))}),ot!==0&&(N?$.map(m=>m.rowName??String(m[0])):Object.keys(J)).forEach(m=>{const P=`mean-${m}`,b=O.__data__.objects.get(P);if(!b)return;let y=this._meanLabels.get(m);y?ot===H.DISPLAY_TYPES.ON?y.show():y.hide():(y=new he(m,b,nt,this,ot),this._meanLabels.set(m,y))})),O.__data__.__state__.setVariable("layer_updated",O.__data__)}}const Jt=this.__children__.search("__children__","trajectories");if(o.showTrajectories&&Jt){Jt.__data__.objects.clear(),this.__data__.trajectories.clear();const O=(ti=s.trajectories)!=null&&ti.rows?s.trajectories:s.points;if(O!=null&&O.rows){const N={},$=o.trajectoryUnits?o.trajectoryUnits.split(",").map(m=>m.trim()):null;O.rows().forEach(m=>{const P=m.names.indexOf(r)>=0?m.names.indexOf(r):m.names.indexOf("unit")>=0?m.names.indexOf("unit"):m.names.indexOf("ENA_UNIT")>=0?m.names.indexOf("ENA_UNIT"):-1,b=P>=0?String(m[P]):m.rowName||"unit-1";if($&&!$.includes(b))return;const y=m.names.indexOf(n[0]),I=n.length>1?m.names.indexOf(n[1]):-1,j=m.names.indexOf("time")>=0?m.names.indexOf("time"):m.names.indexOf("ActivityNumber")>=0?m.names.indexOf("ActivityNumber"):m.names.indexOf("RowID")>=0?m.names.indexOf("RowID"):-1,L=j>=0?Number(m[j]):N[b]?N[b].length+1:1;y>=0&&I>=0&&(N[b]||(N[b]=[]),N[b].push({x:Number(m[y])*S,y:-Number(m[I])*S,time:L}))}),Object.keys(N).forEach((m,P)=>{const b=N[m];if(b.length===0)return;const y=_[P%_.length],I=new ie({ID:`traj-${m}`,unitId:m,color:new et(y),lineStyle:o.trajectoryLineStyle,strokeWidth:o.trajectoryStrokeWidth,strokeWidthRange:o.trajectoryStrokeWidthRange,opacityRange:o.trajectoryOpacityRange,smooth:o.trajectorySmooth,maxDegree:o.trajectoryMaxDegree,degreeSelection:o.trajectoryDegreeSelection,currentTime:o.trajectoryPlayhead??1/0,showPoints:o.trajectoryShowPoints,showTips:o.trajectoryShowTips,points:b.map(j=>({x:j.x,y:j.y,time:j.time}))});this.__data__.trajectories.set(m,I),Jt.__data__.objects.set(I.ID,I)})}Jt.__data__.__state__.setVariable("layer_updated",Jt.__data__)}const gt=this.__children__.search("__children__","network"),Me=gt==null?void 0:gt.__children__.search("__children__","edges"),yt=gt==null?void 0:gt.__children__.search("__children__","nodes"),We=gt==null?void 0:gt.__children__.search("__children__","edgenodes"),$i=o.showEdges;if((ei=s.nodes)!=null&&ei.rows&&yt){if(s.nodes.rows().forEach(N=>{const $=dt(N,a,"#444444");$.size=2;const x=N.names.indexOf("label"),m=x>=0?N[x]:null;$.meta={...$.meta??{},kind:"node",name:m!=null&&String(m)!=="NA"&&String(m)!==""?String(m):$.ID},yt.__data__.objects.set($.ID,$)}),$i&&Me&&((si=s.edges)!=null&&si.rows)){const N={};h&&((ii=s.points)!=null&&ii.rows)&&s.points.rows().forEach(p=>{const w=p.names.indexOf(r),k=p.names.indexOf(h);w>=0&&k>=0&&(N[String(p[w])]=String(p[k]))});const $=s.nodes.rows().map(p=>{const w=p.names.indexOf(a);return w>=0?String(p[w]):""}).filter(Boolean),x=[];(s.edges.names??[]).forEach(p=>{const w=Si(p,$);w&&x.push({col:p,pair:w})});const m=u(p=>{const w={};return s.edges.rows().forEach(k=>{const z=k.names.indexOf(r);z<0||String(k[z])!==p||x.forEach(({col:A})=>{const F=k.names.indexOf(A);F>=0&&(w[A]=Number(k[F])||0)})}),w},"getUnitEdges"),P=u(p=>{const w={};let k=0;if(s.edges.rows().forEach(A=>{const F=A.names.indexOf(r),Z=F>=0?String(A[F]):null,Q=h?A.names.indexOf(h):-1;(Q>=0?String(A[Q]):Z?N[Z]:null)===p&&(k++,x.forEach(({col:xt})=>{const wt=A.names.indexOf(xt);if(wt>=0){const V=Number(A[wt]);isNaN(V)||(w[xt]=(w[xt]??0)+V)}}))}),k===0)return{};const z={};return x.forEach(({col:A})=>{z[A]=(w[A]??0)/k}),z},"getGroupEdges"),b=u(p=>{if(l[p])return{weights:P(p),color:l[p],label:p};const w=N[p]??null,k=w?l[w]??"#888888":"#888888";return{weights:m(p),color:k,label:p}},"resolve"),y=[],I=u(p=>{var A;const w=s.networks,k=(A=w==null?void 0:w.rows)==null?void 0:A.call(w).find(F=>F.rowName===p);if(!k)return null;const z={};return x.forEach(({col:F})=>{const Z=k.names.indexOf(F);if(Z>=0){const Q=Number(k[Z]);Number.isFinite(Q)&&(z[F]=Q)}}),z},"networkRow"),j=u((p,w)=>{if(!w)return p;const k=Math.abs(p);return k<w[0]?0:k>w[1]?Math.sign(p)*w[1]:p},"thresholded");o.edgeLayers.forEach((p,w)=>{const k=u((V,lt,st,St,ct)=>{st=j(st,p.threshold),!(Math.abs(st)<1e-6)&&y.push({col:`${w}:${V}`,pair:lt,weight:Math.abs(st),color:St,layer:w,...ct})},"push"),z=u((V,lt)=>p.colors?[p.colors[0],p.colors[1]??Ni(p.colors[0])]:[V,lt],"signColors");if(p.network){const V=I(p.network);if(!V)return;const[lt,st]=z(_[0],_[1]),St={name:p.name??p.network};x.forEach(({col:ct,pair:ni})=>{const Ve=V[ct]??0;k(ct,ni,Ve,Ve>=0?lt:st,St)});return}const A=p.unit??p.group??null;if(!A)return;const F=b(A),Z=p.compare??p.also??null,Q=Z?b(Z):null,D={name:p.name??A,group:p.group??void 0,unit:p.unit??void 0},[xt,wt]=z(F.color,(Q==null?void 0:Q.color)??F.color);Q&&p.compare?x.forEach(({col:V,pair:lt})=>{const st=(F.weights[V]??0)-(Q.weights[V]??0);k(V,lt,st,st>0?xt:wt,D)}):Q&&p.also?x.forEach(({col:V,pair:lt})=>{const st=F.weights[V]??0,St=Q.weights[V]??0;st>0&&k(V+"-a",lt,st,xt,D),St>0&&k(V+"-b",lt,St,wt,{...D,name:p.also??void 0,group:p.also??void 0})}):x.forEach(({col:V,pair:lt})=>{const st=F.weights[V]??0;st>0&&k(V,lt,st,xt,D)})}),y.sort((p,w)=>w.weight-p.weight);const L=!!s.directed,W=yi(o.edgeWidth)*(o.edgeMagnify??1),ft=u(p=>{const w=p.map(Math.abs).filter(k=>k>0);return w.length?[Math.min(...w),Math.max(...w)]:[0,0]},"rangeOf"),tt=u(p=>{const w=[];return x.forEach(({col:k,pair:z})=>{if(z[0]===z[1]!==p)return;const A=s.edges.col(k);if(A)for(const F of A)w.push(Number(F))}),ft(w)},"modelRange"),mt=u(p=>ft(y.filter(w=>w.pair[0]===w.pair[1]===p).map(w=>w.weight)),"plotRange"),T=o.edgeColorScale,Ft=u(p=>T==="plot"?mt(p):tt(p),"colourRange"),vt=Ft(!1),It=Ft(!0),jt=u((p,w)=>{if(T==="absolute"){const A=Math.min(1,Math.abs(p));return{saturation:A,opacity:A}}const[k,z]=w?It:vt;return{saturation:Ds(p,k,z,ui),opacity:Ds(p,k,z,di)}},"colourOf"),Zt={};y.forEach(({pair:p,weight:w})=>{if(p[0]===p[1]&&!L)return;const z=u(A=>{Zt[A]=(Zt[A]??0)+Math.abs(w)},"add");if(L){z(p[1]);return}z(p[0]),z(p[1])}),s.nodes.rows().forEach(p=>{const w=p.names.indexOf(a),k=w>=0?String(p[w]):"";if(!k)return;const z=yt.__data__.objects.get(k);if(!z)return;const A=Zt[k]??0,F=!(A>0);z.size=F?o.hideUnconnectedNodes?0:bi:xi(A,W),z.meta={...z.meta??{},hidden:F&&o.hideUnconnectedNodes}});const U={},rt=u((p,w,k,z)=>`${p}:${w??""}:${k}.${z}`,"pairKey");L&&y.forEach(({pair:p,weight:w,layer:k,name:z})=>{const A=rt(k,z,p[0],p[1]);U[A]=(U[A]??0)+w}),y.forEach(({col:p,pair:w,weight:k,color:z,layer:A,name:F,group:Z,unit:Q})=>{const D=yt.__data__.objects.get(w[0]),xt=yt.__data__.objects.get(w[1]);if(!D||!xt)return;const wt=w[0]===w[1];if(wt&&!L)return;const{saturation:V,opacity:lt}=jt(k,wt),st=new K({ID:`${w[0]}-src`,dimensions:[D.x,D.y],meta:{}}),St=new K({ID:`${w[1]}-dst`,dimensions:[xt.x,xt.y],meta:{}});let ct;if(wt)ct=new re({},st,St),ct.weight=0;else if(L){const Ve=U[rt(A,F,w[0],w[1])]??k,Pi=U[rt(A,F,w[1],w[0])]??0,Ri=Ve+Pi;ct=new is({weight:k,totalweight:Ri},st,St)}else ct=new qt({},st,St);ct.ID=`edge-${p}`,ct.color=new et(z),ct.meta={isMeanEdge:!0,weight:k,widthFrac:W,saturation:V,opacity:lt,isDirected:L,isSelf:wt,source:w[0],target:w[1],group:Z,unit:Q,layer:F},(wt?We??Me:Me).__data__.objects.set(ct.ID,ct)}),Me.__data__.__state__.setVariable("layer_updated",Me.__data__),We&&We.__data__.__state__.setVariable("layer_updated",We.__data__)}const O=o.showNodes;yt.svg_element&&(yt.svg_element.style.display=O?"":"none"),O||(this._nodeLabels.forEach(N=>N.remove()),this._nodeLabels.clear()),nt&&Y!==0&&O&&(this._nodeLabels.forEach((N,$)=>{yt.__data__.objects.get($)||(N.remove(),this._nodeLabels.delete($))}),s.nodes.rows().forEach(N=>{var y,I,j;const $=N.names.indexOf(a),x=$>=0?String(N[$]):"";if(!x)return;const m=yt.__data__.objects.get(x);if(!m)return;if((y=m.meta)!=null&&y.hidden){(I=this._nodeLabels.get(x))==null||I.remove(),this._nodeLabels.delete(x);return}const P=String(((j=m.meta)==null?void 0:j.name)??x);let b=this._nodeLabels.get(x);b&&b.text!==P&&(b.remove(),this._nodeLabels.delete(x),b=void 0),b?Y===H.DISPLAY_TYPES.ON?b.show():b.hide():(b=new he(P,m,nt,this,Y),this._nodeLabels.set(x,b))})),yt.__data__.__state__.setVariable("layer_updated",yt.__data__)}const Ys=this.__children__.search("__children__","axis_points"),qs=this.__children__.search("__children__","axis_lines");Ys&&this.__data__.__state__.setVariable("graph_updated_axis_points",Ys.__data__.objects),qs&&this.__data__.__state__.setVariable("graph_updated_axis_lines",qs.__data__.objects),this.update(),i&&this._runTween(i)})}static get observedAttributes(){return["width","height","for","scale-points","point-scale","center","labels","label-nodes","label-means","label-points"]}get vizena(){return this._vizena}unitsPerPixel(){var i,n;const t=this.__data__.extremes.x_max||1,e=(n=(i=this.svg_element)==null?void 0:i.getBoundingClientRect)==null?void 0:n.call(i),s=this.zoom_level||1;return e&&e.width>0?2*t/e.width/s:t*.004}_scheduleRerender(){!this._vizena||!this._hasModel||this._renderPending||(this._renderPending=!0,queueMicrotask(()=>{var t;this._renderPending=!1,(t=this._vizena)==null||t.dispatchEvent(new CustomEvent("model-updated",{detail:this._vizena.model,bubbles:!0,composed:!0}))}))}_readLayerConfig(){var g;const t=this.querySelector("qe-nodes"),e=this.querySelector("qe-means"),s=[...this.querySelectorAll("qe-points")],i=s.find(c=>!c.hasAttribute("set"))??null,n=s.filter(c=>c.hasAttribute("set")),r=[...this.querySelectorAll("qe-edges")],a=u(c=>{var M;return((M=r.find(f=>f.hasAttribute(c)))==null?void 0:M.getAttribute(c))??null},"firstAttr"),h=r.find(c=>c.hasAttribute("magnify")),o=this.querySelector("qe-trajectories"),l=this.querySelector("qe-axes"),_=this.getAttribute("labels");return{labelNodes:ns((t==null?void 0:t.getAttribute("label"))??this.getAttribute("label-nodes")??_,H.DISPLAY_TYPES.ON),showNodes:!!t,range:(()=>{const c=this.getAttribute("range");if(c==="network"||c==="points")return c;const M=Number(c);return c!=null&&Number.isFinite(M)&&M>0?M:null})(),plotTitle:this.getAttribute("plot-title")||null,labelFont:{size:(()=>{const c=Number(this.getAttribute("label-font-size"));return Number.isFinite(c)&&c>0?c:null})(),family:this.getAttribute("label-font-family")||null,color:this.getAttribute("label-font-color")||null},edgeWidth:(()=>{const c=Number(this.getAttribute("edge-width"));return Number.isFinite(c)&&c>0&&c<=1?c:_i})(),hideUnconnectedNodes:((g=t==null?void 0:t.getAttribute("unconnected"))==null?void 0:g.toLowerCase())==="hide",scalePoints:this.getAttribute("scale-points")!=="false",pointScale:(()=>{const c=Number(this.getAttribute("point-scale"));return this.hasAttribute("point-scale")&&Number.isFinite(c)&&c>0?c:null})(),centerContent:this.getAttribute("center")==="content",showMeans:!!e,activeMeanGroups:(e==null?void 0:e.getAttribute("groups"))??null,showCI:!!e&&e.hasAttribute("confidence"),intervals:(()=>{const c=e==null?void 0:e.getAttribute("intervals");return c==="box"||c==="crosshairs"||c==="none"?c:e!=null&&e.hasAttribute("confidence")?"box":"none"})(),showOutlier:!!e&&e.hasAttribute("outlier"),labelMeans:ns((e==null?void 0:e.getAttribute("label"))??this.getAttribute("label-means")??_,H.DISPLAY_TYPES.ON),meanFixedSize:!!e&&e.hasAttribute("fixed-size"),showPoints:!!i,pointSets:n.map(c=>({set:c.getAttribute("set"),size:c.getAttribute("size")?parseFloat(c.getAttribute("size")):null,fixedSize:c.hasAttribute("fixed-size")})),labelPoints:ns((i==null?void 0:i.getAttribute("label"))??this.getAttribute("label-points")??_,H.DISPLAY_TYPES.OFF),pointSize:i!=null&&i.getAttribute("size")?parseFloat(i.getAttribute("size")):null,pointFixedSize:!!i&&i.hasAttribute("fixed-size"),showEdges:r.length>0,edgeLayers:r.map(Ii),edgeColorScale:ki(a("color-scale")),edgeMagnify:h?(()=>{const c=Number(h.getAttribute("magnify"));return Number.isFinite(c)&&c>0?c:1})():null,showTrajectories:!!o,trajectoryUnits:(o==null?void 0:o.getAttribute("units"))??null,trajectorySmooth:(o==null?void 0:o.getAttribute("smooth"))??"none",trajectoryMaxDegree:o!=null&&o.getAttribute("max-degree")?parseInt(o.getAttribute("max-degree"),10):3,trajectoryDegreeSelection:(o==null?void 0:o.getAttribute("degree-selection"))??"loocv_2d",trajectoryShowPoints:(o==null?void 0:o.getAttribute("points"))!=="false",trajectoryShowTips:(o==null?void 0:o.getAttribute("tips"))!=="false",trajectoryPlayhead:o!=null&&o.getAttribute("playhead")?parseFloat(o.getAttribute("playhead")):null,trajectoryLineStyle:(o==null?void 0:o.getAttribute("line-style"))??"uniform",trajectoryStrokeWidth:o!=null&&o.getAttribute("stroke-width")?parseFloat(o.getAttribute("stroke-width")):2,trajectoryStrokeWidthRange:this._parseNumberPair(o==null?void 0:o.getAttribute("stroke-width-range"),[1,6]),trajectoryOpacityRange:this._parseNumberPair(o==null?void 0:o.getAttribute("opacity-range"),[.3,1]),showAxes:!!l,axisXLabel:l!=null&&l.hasAttribute("x")?l.getAttribute("x")??"":null,axisYLabel:l!=null&&l.hasAttribute("y")?l.getAttribute("y")??"":null}}_parseNumberPair(t,e){if(!t)return e;const s=t.split(",").map(i=>Number(i.trim()));return s.length<2||!s.every(Number.isFinite)?e:[s[0],s[1]]}attributeChangedCallback(t,e,s){e!==s&&this._scheduleRerender()}connectedCallback(){var n;const t=this.getAttribute("width"),e=this.getAttribute("height");this.style.display="block",t&&(this.style.width=isNaN(Number(t))?t:`${t}px`),e&&(this.style.height=isNaN(Number(e))?e:`${e}px`),this.appendChild(this.svg_element),ut._instances.add(this),this._childObserver=new MutationObserver(()=>this._scheduleRerender()),this._childObserver.observe(this,{childList:!0,attributes:!0,subtree:!0,attributeFilter:["group","unit","compare","also","color-scale","magnify","network","colors","threshold","name","groups","confidence","label","intervals","outlier","set","unconnected","scale-points","point-scale","edge-width","labels","range","center","plot-title","label-font-size","label-font-family","label-font-color","label-nodes","label-means","label-points","units","smooth","degree","points","tips","playhead","line-style","stroke-width","stroke-width-range","opacity-range","x","y","size","fixed-size"]});const s=this.getAttribute("for");this._vizena=(s?document.getElementById(s):null)??this.closest("qe-visual")??((n=this.parentElement)==null?void 0:n.closest("qe-visual"))??document.querySelector("qe-visual"),this.draw();const i=this.__children__.search("__children__","labels");if(i!=null&&i.svg_element)this._labelsGroup=i.svg_element;else{console.warn("[ena-graph] labels layer not found in layer tree; creating fallback <g>");const r=this.__children__[0];r!=null&&r.svg_element&&(this._labelsGroup=document.createElementNS("http://www.w3.org/2000/svg","g"),this._labelsGroup.setAttribute("data-layer-name","labels-fallback"),r.svg_element.appendChild(this._labelsGroup))}}disconnectedCallback(){var t,e,s;(t=this._childObserver)==null||t.disconnect(),this._childObserver=null,(e=this._resizeObs)==null||e.disconnect(),this._resizeObs=null,ut._instances.delete(this),(s=this._tooltipEl)==null||s.remove(),this._tooltipEl=null}static instances(){return[...ut._instances]}static getGraph(t){for(const e of ut._instances)if(e.id===t||e.getAttribute("plot-group")===t)return e;return null}getNodes(){const t=this.__children__.search("__children__","nodes");return t?[...t.__data__.objects.values()].map(e=>{var s;return{id:e.ID,name:((s=e.meta)==null?void 0:s.name)??e.ID,x:e.x,y:e.y}}):[]}getEdges(){const t=u(e=>{const s=this.__children__.search("__children__",e);return s?[...s.__data__.objects.values()]:[]},"collect");return[...t("edges"),...t("edgenodes")].map(e=>{const s=e.meta??{};return{source:s.source,target:s.target,weight:s.weight??0,directed:!!s.isDirected,self:!!s.isSelf}}).filter(e=>e.source!=null&&e.target!=null)}_tweenTargets(){return[...this.svg_element.querySelectorAll("circle[data-point-id], rect[data-point-id], line[data-edge-source], path[data-edge-source]")]}_readCoords(t){const e=t.tagName.toLowerCase(),s=u(i=>parseFloat(t.getAttribute(i)||"0"),"n");if(e==="circle")return{t:"c",cx:s("cx"),cy:s("cy")};if(e==="rect")return{t:"r",x:s("x"),y:s("y")};if(e==="line")return{t:"l",x1:s("x1"),y1:s("y1"),x2:s("x2"),y2:s("y2")};if(e==="path"){const i=t.getAttribute("d")||"";return{t:"p",d:i,nums:(i.match(ut._PATH_NUM_RE)||[]).map(Number)}}return null}_captureTween(){const t=new Map;return this._tweenTargets().forEach(e=>{const s=this._readCoords(e);s&&t.set(e,s)}),t}_runTween(t){this._tweenRaf!==null&&(cancelAnimationFrame(this._tweenRaf),this._tweenRaf=null);const e=new Map;if(this._tweenTargets().forEach(h=>{if(t.has(h)){const o=this._readCoords(h);o&&e.set(h,o)}}),!e.size)return;const s=this._animateMs,i=performance.now(),n=u(h=>h<.5?2*h*h:1-Math.pow(-2*h+2,2)/2,"ease"),r=u((h,o,l)=>h+(o-h)*l,"lerp"),a=u(h=>{const o=Math.min(1,(h-i)/s),l=n(o);e.forEach((_,g)=>{const c=t.get(g);if(!(!c||c.t!==_.t))if(_.t==="c")g.setAttribute("cx",String(r(c.cx,_.cx,l))),g.setAttribute("cy",String(r(c.cy,_.cy,l)));else if(_.t==="r")g.setAttribute("x",String(r(c.x,_.x,l))),g.setAttribute("y",String(r(c.y,_.y,l)));else if(_.t==="l")g.setAttribute("x1",String(r(c.x1,_.x1,l))),g.setAttribute("y1",String(r(c.y1,_.y1,l))),g.setAttribute("x2",String(r(c.x2,_.x2,l))),g.setAttribute("y2",String(r(c.y2,_.y2,l)));else{if(!c.nums||c.nums.length!==_.nums.length)return;let M=0;const f=_.d.replace(ut._PATH_NUM_RE,()=>String(r(c.nums[M],_.nums[M++],l)));g.setAttribute("d",f)}}),this._tweenRaf=o<1?requestAnimationFrame(a):null},"step");this._tweenRaf=requestAnimationFrame(a)}toSVG(){const t=this.svg_element.cloneNode(!0);t.setAttribute("xmlns","http://www.w3.org/2000/svg"),t.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink");const e=this.svg_element.getBoundingClientRect();return e.width&&t.setAttribute("width",String(Math.round(e.width))),e.height&&t.setAttribute("height",String(Math.round(e.height))),new XMLSerializer().serializeToString(t)}toPNG(t=2){const e=this.toSVG(),s=this.svg_element.getBoundingClientRect(),i=Math.max(1,Math.round(s.width)),n=Math.max(1,Math.round(s.height));return new Promise((r,a)=>{const h=new Blob([e],{type:"image/svg+xml;charset=utf-8"}),o=URL.createObjectURL(h),l=new Image;l.onload=()=>{try{const _=document.createElement("canvas");_.width=i*t,_.height=n*t;const g=_.getContext("2d");if(!g){URL.revokeObjectURL(o),a(new Error("no 2d context"));return}g.scale(t,t),g.drawImage(l,0,0,i,n),URL.revokeObjectURL(o),r(_.toDataURL("image/png"))}catch(_){URL.revokeObjectURL(o),a(_)}},l.onerror=_=>{URL.revokeObjectURL(o),a(_)},l.src=o})}getPoints(){const t=this.__children__.search("__children__","points");return t?[...t.__data__.objects.values()].filter(e=>{var s;return((s=e.meta)==null?void 0:s.kind)==="point"}).map(e=>{var s,i,n;return{id:((s=e.meta)==null?void 0:s.unit)??e.ID,group:(i=e.meta)==null?void 0:i.group,set:(n=e.meta)==null?void 0:n.set,x:e.x,y:e.y}}):[]}pointsInRect(t){return this.getPoints().filter(e=>e.x>=t.x&&e.x<=t.x+t.w&&e.y>=t.y&&e.y<=t.y+t.h).map(e=>e.id)}_edgeKey(t,e){return t<=e?`${t}\0${e}`:`${e}\0${t}`}setHighlight(t){this._highlight.edges=new Set((t.edges??[]).map(e=>this._edgeKey(e.source,e.target))),this._highlight.nodes=new Set((t.nodes??[]).map(String)),this._applyHighlights()}clearHighlight(){this._highlight.edges.clear(),this._highlight.nodes.clear(),this._applyHighlights()}_applyHighlights(){if(!this.svg_element)return;this._highlightGroup||(this._highlightGroup=document.createElementNS("http://www.w3.org/2000/svg","g"),this._highlightGroup.setAttribute("data-layer-name","highlight"),this._highlightGroup.setAttribute("pointer-events","none")),this.svg_element.appendChild(this._highlightGroup);const t=this._highlightGroup;t.textContent="";const e=this.__data__.extremes.x_max||1,s="#f5a623",i=u((n,r)=>{const a=document.createElementNS("http://www.w3.org/2000/svg",n);for(const h in r)a.setAttribute(h,String(r[h]));return a},"mk");if(this._highlight.edges.size){const n={};this.getNodes().forEach(r=>{n[r.id]={x:r.x,y:r.y}}),this._highlight.edges.forEach(r=>{const[a,h]=r.split("\0"),o=n[a],l=n[h];!o||!l||t.appendChild(i("line",{x1:o.x,y1:o.y,x2:l.x,y2:l.y,stroke:s,"stroke-width":e*.02,"stroke-opacity":.6,"stroke-linecap":"round"}))})}this._highlight.nodes.forEach(n=>{var _;const r=this.svg_element.querySelector(`[data-point-id="${(_=window.CSS)!=null&&_.escape?CSS.escape(n):n}"]`);if(!r)return;const a=r.tagName.toLowerCase();let h,o,l;if(a==="rect"){const g=parseFloat(r.getAttribute("width")||"0");h=parseFloat(r.getAttribute("x")||"0")+g/2,o=parseFloat(r.getAttribute("y")||"0")+parseFloat(r.getAttribute("height")||"0")/2,l=g/2}else h=parseFloat(r.getAttribute("cx")||"0"),o=parseFloat(r.getAttribute("cy")||"0"),l=parseFloat(r.getAttribute("r")||"0");t.appendChild(i("circle",{cx:h,cy:o,r:l*1.7+e*.004,fill:"none",stroke:s,"stroke-width":e*.006}))})}create(){const t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.classList.add("graph"),t.style.display="block",t.style.width="100%",t.style.height="100%",t.setAttribute("preserveAspectRatio","xMidYMid meet"),t.setAttribute("viewBox",this.__data__.extremes.as_viewBox()),t.setAttribute("transform",this.__data__.transform.toString()),t.setAttribute("role","figure"),t.setAttribute("data-graph-size",`${Math.min(this.__data__.extremes.width,this.__data__.extremes.height)}`),this.svg_element=t;const e=document.createElementNS("http://www.w3.org/2000/svg","defs"),s=.22,i=.15,n=u((r,a)=>{const h=document.createElementNS("http://www.w3.org/2000/svg","marker");h.setAttribute("id",r),h.setAttribute("markerWidth",String(s)),h.setAttribute("markerHeight",String(i)),h.setAttribute("refX",String(s)),h.setAttribute("refY",String(i/2)),h.setAttribute("orient","auto"),h.setAttribute("markerUnits","userSpaceOnUse");const o=document.createElementNS("http://www.w3.org/2000/svg","path");o.setAttribute("d",`M0,0 L0,${i} L${s},${i/2} z`),o.setAttribute("fill",a),h.appendChild(o),e.appendChild(h)},"makeArrow");return js.forEach(r=>n(`qe-arrow-${r.slice(1)}`,r)),t.appendChild(e),this.__data__.layers.forEach(r=>{const a=new $e(r,this.svg_element,this);this.__children__.push(a)}),this.__data__.__state__.setVariable("graph_updated",this.__data__),this.attach_events(),t}attach_events(){this.svg_element.addEventListener("wheel",o=>{console.log("Wheel event: ",o),o.preventDefault(),Math.sign(o.deltaY)<0?this.zoom_level*=1.1:this.zoom_level/=1.1,this.__data__.transform.zoom(this.zoom_level),this.update()});let t=!1,e,s;this.svg_element.addEventListener("mousedown",o=>{t=!0,e=o.clientX,s=o.clientY});let i=null,n=null;const r=u(()=>{n&&(this.__data__.transform.pan(n.dx,n.dy),this.__children__[0].svg_element.setAttribute("transform",this.__data__.transform.toString()),n=null),i=null},"panUpdate");this.svg_element.addEventListener("mousemove",o=>{if(!t)return;const l=o.clientX-e,_=o.clientY-s;n={dx:l/100,dy:_/100},e=o.clientX,s=o.clientY,i===null&&(i=requestAnimationFrame(r))}),this.svg_element.addEventListener("mouseup",o=>{t=!1}),this.svg_element.addEventListener("point-clicked",(o=>{var g,c;const l=(c=(g=o.detail)==null?void 0:g.pointData)==null?void 0:c.ID;if(!l)return;const _=this._pointLabels.get(l)??this._meanLabels.get(l.replace("mean-",""))??this._nodeLabels.get(l);_&&_.displayMode===H.DISPLAY_TYPES.CLICK&&_.toggle()}));const a=u(o=>{var l;for(;o&&o!==this.svg_element;){const _=(l=o.getAttribute)==null?void 0:l.call(o,"data-point-id");if(_)return _;o=o.parentElement}return null},"findPointId"),h=u(o=>this._pointLabels.get(o)??this._meanLabels.get(o.replace(/^mean-/,""))??this._nodeLabels.get(o),"getAutoLabel");this.svg_element.addEventListener("mouseover",o=>{const l=a(o.target);if(!l)return;const _=h(l);(_==null?void 0:_.displayMode)===H.DISPLAY_TYPES.AUTO&&_.show()}),this.svg_element.addEventListener("mouseout",o=>{const l=a(o.target);if(!l)return;const _=o.relatedTarget;if(a(_)===l)return;const c=h(l);(c==null?void 0:c.displayMode)===H.DISPLAY_TYPES.AUTO&&c.hide()}),this._attachInteractionEvents()}_emit(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e,bubbles:!0,composed:!0}))}_closestWith(t,e){var s,i;for(;t&&t!==this.svg_element;){if(((s=t.getAttribute)==null?void 0:s.call(t,e))!=null&&((i=t.hasAttribute)!=null&&i.call(t,e)))return t;t=t.parentElement}return null}_edgeDetail(t){const e=this._closestWith(t,"data-edge-source");if(!e)return null;const s={source:e.getAttribute("data-edge-source"),target:e.getAttribute("data-edge-target"),weight:parseFloat(e.getAttribute("data-edge-weight")||"0"),directed:e.getAttribute("data-edge-directed")==="true",self:e.getAttribute("data-edge-self")==="true"};return e.hasAttribute("data-edge-group")&&(s.group=e.getAttribute("data-edge-group")),e.hasAttribute("data-edge-unit")&&(s.unit=e.getAttribute("data-edge-unit")),s}_nodeDetail(t){const e=this._closestWith(t,"data-point-id");if(!e)return null;const s=e.tagName.toLowerCase();let i,n;s==="rect"?(i=parseFloat(e.getAttribute("x")||"0")+parseFloat(e.getAttribute("width")||"0")/2,n=parseFloat(e.getAttribute("y")||"0")+parseFloat(e.getAttribute("height")||"0")/2):(i=parseFloat(e.getAttribute("cx")||"0"),n=parseFloat(e.getAttribute("cy")||"0"));const r=e.getAttribute("data-point-id"),a={id:r,kind:e.getAttribute("data-kind")||"point",name:e.getAttribute("data-name")||r,x:i,y:n};return e.hasAttribute("data-group")&&(a.group=e.getAttribute("data-group")),e.hasAttribute("data-unit")&&(a.unit=e.getAttribute("data-unit")),a}_attachInteractionEvents(){const t=this.svg_element;t.addEventListener("click",i=>{const n=i.target,r=this._edgeDetail(n);if(r){this._emit("qe-edge-click",{...r,originalEvent:i});return}const a=this._nodeDetail(n);a&&this._emit("qe-node-click",{...a,originalEvent:i})});let e=null;const s=u((i,n)=>i==="edge"?`${n.source}\0${n.target}`:String(n.id),"keyOf");t.addEventListener("mousemove",i=>{const n=i.target,r=this._edgeDetail(n),a=r?null:this._nodeDetail(n),h=r?{type:"edge",detail:r}:a?{type:"node",detail:a}:null,o=h?s(h.type,h.detail):null;e&&(!h||e.key!==o)&&(this._emit(e.type==="edge"?"qe-edge-unhover":"qe-node-unhover",{key:e.key}),e=null),h&&(!e||e.key!==o)&&(this._emit(h.type==="edge"?"qe-edge-hover":"qe-node-hover",{...h.detail,originalEvent:i}),e={type:h.type,key:o}),this.hasAttribute("tooltip")&&h?this._showTooltip(this._tooltipText(h.type,h.detail),i.clientX,i.clientY):this._hideTooltip()}),t.addEventListener("mouseleave",()=>{e&&(this._emit(e.type==="edge"?"qe-edge-unhover":"qe-node-unhover",{key:e.key}),e=null),this._hideTooltip()})}_tooltipText(t,e){if(t==="edge"){const s=Number(e.weight),i=Number.isFinite(s)?` (${+s.toFixed(3)})`:"";return`${e.source} – ${e.target}${i}`}return String(e.name??e.id)}_showTooltip(t,e,s){if(!this._tooltipEl){const i=document.createElement("div");i.setAttribute("data-qe-tooltip",""),Object.assign(i.style,{position:"fixed",zIndex:"2147483647",pointerEvents:"none",background:"rgba(20,20,20,0.92)",color:"#fff",font:"12px/1.4 system-ui, sans-serif",padding:"3px 7px",borderRadius:"4px",whiteSpace:"nowrap",transform:"translate(-50%, calc(-100% - 8px))"}),document.body.appendChild(i),this._tooltipEl=i}this._tooltipEl.textContent=t,this._tooltipEl.style.left=`${e}px`,this._tooltipEl.style.top=`${s}px`,this._tooltipEl.style.display="block"}_hideTooltip(){this._tooltipEl&&(this._tooltipEl.style.display="none")}draw(){var t;if(!this.svg_element){console.error("No element to draw to: ",this);return}if((t=this.wrapper)==null||t.appendChild(this.svg_element),this.__children__.forEach(e=>{e.draw()}),!this._resizeObs&&typeof ResizeObserver<"u"&&this.svg_element){let e=0;this._resizeObs=new ResizeObserver(s=>{var n;const i=((n=s[0])==null?void 0:n.contentRect.width)??0;i>0&&Math.abs(i-e)>.5&&(e=i,this.update_labels(),this.update_axes())}),this._resizeObs.observe(this.svg_element)}}update(){this.update_extremes(),this.update_layers(),this.update_labels(),this.update_extremes(),this.update_axes(),this._applyHighlights()}update_axes(){var o,l;const t=this.__children__.search("__children__","axes");t!=null&&t.svg_element&&(t.svg_element.style.display=this._showAxes?"":"none");const e=this._labelsGroup,s=this.__data__.extremes.x_max,{cx:i,cy:n}=this.__data__.extremes;if(!e||s<=0)return;const r=s*.06,a=r*.6,h=u((_,g)=>{let c=this._axisLabelEls.get(_);if(!this._showAxes||g==null){c&&(c.remove(),this._axisLabelEls.delete(_));return}c||(c=document.createElementNS("http://www.w3.org/2000/svg","text"),c.setAttribute("data-axis-label",_),c.setAttribute("pointer-events","none"),e.appendChild(c),this._axisLabelEls.set(_,c)),c.textContent=g,c.setAttribute("font-size",r.toString()),c.setAttribute("font-family","system-ui, sans-serif"),c.setAttribute("font-weight","600"),c.setAttribute("fill","#556"),_==="x"?(c.setAttribute("x",(i+s-a).toString()),c.setAttribute("y",(-a).toString()),c.setAttribute("text-anchor","end")):(c.setAttribute("x",a.toString()),c.setAttribute("y",(n-s+r+a).toString()),c.setAttribute("text-anchor","start"))},"place");if(h("x",this._axisXText),h("y",this._axisYText),this._magnifyText==null)(o=this._magnifyEl)==null||o.remove(),this._magnifyEl=null;else{this._magnifyEl||(this._magnifyEl=document.createElementNS("http://www.w3.org/2000/svg","text"),this._magnifyEl.setAttribute("data-magnify-label",""),this._magnifyEl.setAttribute("pointer-events","none")),this._magnifyEl.parentElement||e.appendChild(this._magnifyEl);const _=this._magnifyEl;_.textContent=this._magnifyText,_.setAttribute("font-size",(r*.85).toString()),_.setAttribute("font-family","system-ui, sans-serif"),_.setAttribute("font-style","italic"),_.setAttribute("fill","#556"),_.setAttribute("x",(i-s+a).toString()),_.setAttribute("y",(n-s+r+a).toString()),_.setAttribute("text-anchor","start")}if(!this._plotTitle)(l=this._titleEl)==null||l.remove(),this._titleEl=null;else{this._titleEl||(this._titleEl=document.createElementNS("http://www.w3.org/2000/svg","text"),this._titleEl.setAttribute("data-plot-title",""),this._titleEl.setAttribute("pointer-events","none")),this._titleEl.parentElement||e.appendChild(this._titleEl);const g=(this._labelFont.size??12)*1.35*this.unitsPerPixel(),c=this._titleEl;c.textContent=this._plotTitle,c.setAttribute("font-size",g.toString()),c.setAttribute("font-family",this._labelFont.family??"system-ui, sans-serif"),c.setAttribute("font-weight","600"),c.setAttribute("fill",this._labelFont.color??"#223"),c.setAttribute("x",i.toString()),c.setAttribute("y",(n-s+g*1.1).toString()),c.setAttribute("text-anchor","middle")}}update_labels(){this._nodeLabels.forEach(t=>t.update()),this._meanLabels.forEach(t=>t.update()),this._pointLabels.forEach(t=>t.update())}update_extremes(){var s;const t=this.__data__;if(t.update_extremes(this._centerContent),this._rangeExtent&&this._rangeExtent>0){const{cx:i,cy:n}=t.extremes,r=this._centerContent&&this._rangeMode==="network"?t.nodeExtentFrom(i,n)*1.2:this._rangeExtent;t.extremes=new Lt(r,r,i,n)}const e=(s=this.svg_element)==null?void 0:s.getBoundingClientRect();if(this.svg_element&&e){console.log("SVG rect: ",e);let i,n;e.width===0||e.height===0?(i=1,n=1):(i=e.width,n=e.height),this.__data__.scale_x=1/(i/(4*this.__data__.extremes.x_max)),this.__data__.scale_y=1/(n/(4*this.__data__.extremes.y_max)),this.__children__[0].svg_element.setAttribute("transform",this.__data__.transform.toString()),this.svg_element.setAttribute("viewBox",this.__data__.extremes.as_viewBox());let r=this.__data__.layers.search("layers","axis_lines");if(r){let a=r.objects.get("axis-x"),h=r.objects.get("axis-y");if(a&&h){const o=this.__data__.extremes;a.from=new K({ID:"axis-x-start",dimensions:[o.cx-o.x_max,0],classes:["ena.dimension","ena.dimension"]}),a.to=new K({ID:"axis-x-end",dimensions:[o.cx+o.x_max,0],classes:["ena.dimension","ena.dimension"]}),h.from=new K({ID:"axis-y-start",dimensions:[0,o.cy-o.y_max],classes:["ena.dimension","ena.dimension"]}),h.to=new K({ID:"axis-y-end",dimensions:[0,o.cy+o.y_max],classes:["ena.dimension","ena.dimension"]})}}}}update_layers(){this.__children__.forEach(t=>{t.update()})}};u(ut,"QEGraphElement"),ut.tagName="qe-graph",ut.style=`
|
|
19
|
+
${ke.style}
|
|
20
20
|
|
|
21
21
|
:host {
|
|
22
22
|
display: block;
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
aspect-ratio: 1 / 1;
|
|
34
34
|
background-color: #FFF;
|
|
35
35
|
}
|
|
36
|
-
`,ut._instances=new Set,ut._PATH_NUM_RE=/-?\d*\.?\d+(?:e[-+]?\d+)?/gi;let
|
|
36
|
+
`,ut._instances=new Set,ut._PATH_NUM_RE=/-?\d*\.?\d+(?:e[-+]?\d+)?/gi;let Tt=ut;customElements.define(Tt.tagName,Tt);const Ci=u(d=>Tt.getGraph(d),"getGraph"),Oi=u(()=>Tt.instances(),"getGraphs");E.Color=et,E.DataFrame=Pt,E.DataFrameColumn=Nt,E.DataFrameColumnType=_t,E.DataFrameRow=B,E.Edge=ne,E.Graph=Ne,E.QEAxesElement=ge,E.QEEdgesElement=ue,E.QEGraphElement=Tt,E.QELayer=$e,E.QELine=At,E.QEMeansElement=ce,E.QENodesElement=le,E.QEPoint=Ut,E.QEPointsElement=_e,E.QETrajectoriesElement=de,E.QETrajectory=ae,E.QEVisualElement=Qt,E.TRAJECTORY_ZERO_EPS=Ns,E.Trajectory=ie,E.WeightedColor=te,E.fitTrajectory=Rs,E.getGraph=Ci,E.getGraphs=Oi,E.nearOriginFilter=Qe,E.sampleCurve=ss,E.selectDegree=Ps,E.vizENA=hi,Object.defineProperty(E,Symbol.toStringTag,{value:"Module"})}));
|
|
37
37
|
//# sourceMappingURL=qeviz.umd.js.map
|