@qe-libs/qeviz 0.6.0 → 0.6.1

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.umd.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(O,U){typeof exports=="object"&&typeof module<"u"?U(exports):typeof define=="function"&&define.amd?define(["exports"],U):(O=typeof globalThis<"u"?globalThis:O||self,U(O.QEViz={}))})(this,(function(O){"use strict";var Hi=Object.defineProperty;var fi=O=>{throw TypeError(O)};var c=(O,U)=>Hi(O,"name",{value:U,configurable:!0});var pi=(O,U,_t)=>U.has(O)||fi("Cannot "+_t);var R=(O,U,_t)=>(pi(O,U,"read from private field"),_t?_t.call(O):U.get(O)),nt=(O,U,_t)=>U.has(O)?fi("Cannot add the same private member more than once"):U instanceof WeakSet?U.add(O):U.set(O,_t),X=(O,U,_t,Ot)=>(pi(O,U,"write to private field"),Ot?Ot.call(O,_t):U.set(O,_t),_t);var xe,we,ve,xt,Ae,Se,wt,Kt,$t,Mt,at,Ee,qt,It,te,ee,ze;const us=class us extends Array{constructor(e,s,i,n,r){super(...s);nt(this,xe);nt(this,we);nt(this,ve);nt(this,xt);nt(this,Ae);X(this,ve,e),X(this,we,i),X(this,xt,n),X(this,Ae,n==null?void 0:n.classes),X(this,xe,r)}get parent(){return R(this,xt)}get names(){return R(this,ve)}get rowName(){return R(this,we)}get types(){if(!R(this,xt))throw new Error("No parent DataFrame attached to this row.");return R(this,xt).types}get classes(){return R(this,Ae)}get rowNumber(){return R(this,xe)}col(e){if(!R(this,xt))throw new Error("No parent DataFrame attached to this row.");return R(this,xt).col(e)}cols(...e){if(!R(this,xt))throw new Error("No parent DataFrame attached to this row.");return R(this,xt).cols(...e)}filter(e){console.error("DataFrameRow does not currently support filtering.")}};xe=new WeakMap,we=new WeakMap,ve=new WeakMap,xt=new WeakMap,Ae=new WeakMap,c(us,"DataFrameRow");let U=us;var _t=(m=>(m.Character="character",m.Double="double",m.Logical="logical",m.Integer="integer",m))(_t||{});const ds=class ds extends Array{constructor(e,s,i,n){super(s.length);nt(this,Se);nt(this,wt);nt(this,Kt);nt(this,$t);for(let r=0;r<s.length;r++)this[r]=s[r];if(X(this,Se,e),s.type!==void 0?X(this,wt,s.type):s.every(r=>typeof r=="string"||r===null||r===void 0)?X(this,wt,"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,wt,"logical"):X(this,wt,"integer"):s.every(r=>typeof r=="number"||r===null||r===void 0)?X(this,wt,"double"):s.every(r=>typeof r=="boolean"||r===null||r===void 0)?X(this,wt,"logical"):X(this,wt,"character"),X(this,$t,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,Kt,i):X(this,Kt,void 0)}get name(){return R(this,Se)}get type(){return R(this,wt)}get rowNames(){return R(this,Kt)}row(e){if(!R(this,$t))throw new Error("No parent DataFrame attached to this column.");return R(this,$t).row(e)}rows(...e){if(!R(this,$t))throw new Error("No parent DataFrame attached to this column.");return R(this,$t).rows(...e)}};Se=new WeakMap,wt=new WeakMap,Kt=new WeakMap,$t=new WeakMap,c(ds,"DataFrameColumn");let Ot=ds;const Me=class Me 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);nt(this,Mt);nt(this,at);nt(this,Ee);if(s.forEach((r,a)=>{r instanceof Ot?this[a]=r:this[a]=new Ot(e[a],r,i,this)}),X(this,Mt,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,Ee,n)}get classes(){return R(this,Ee)}getColumnByName(e){const s=R(this,Mt).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 U(R(this,Mt),[],void 0,this,e);const s=[];for(let i of this){let n=i[e];s.push(n)}return new U(R(this,Mt),s,R(this,at)?R(this,at)[e]:void 0,this,e)}getRowByName(e){if(!R(this,at))return;const s=R(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=R(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 R(this,at)&&h&&(n==null||n.push(R(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=R(this,Mt)):(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 Me(n,i,R(this,at))}subset(e,s){const i=s&&s.length>0?this.cols(...s):this.slice();return new Me(i.map(n=>n.name),i.map(n=>n.values),R(this,at))}get names(){return R(this,Mt)}get rowNames(){return R(this,at)}get nrow(){return this[0]?this[0].length:0}get ncol(){return this.length}};Mt=new WeakMap,at=new WeakMap,Ee=new WeakMap,c(Me,"DataFrame");let Ft=Me;const gs=class gs{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 Ft,this._nodes=t.nodes??new Ft,this._edges=t.edges??new Ft,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}};c(gs,"Model");let is=gs;const bi=globalThis.__QEVIZ_DEBUG__===!0;function Xt(...m){bi&&console.log(...m)}c(Xt,"dbg");const yi={get:c(m=>{const t=[...document.querySelectorAll("qe-graph")];return typeof m=="number"&&m>=0?t[m]:t},"get")},Jt=class Jt 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 is;const t=this.attachShadow({mode:"open"}),e=document.createElement("style");e.textContent=Jt.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(){Xt("QEVisualElement connected"),this.render()}setModelData(t){var r,a,h,o;["nodes","edges","points","groups","confidence","outlier","trajectories","networks","pointsets"].forEach(_=>{var z;const g=t[_];if(!((z=g==null?void 0:g.data)!=null&&z.length))return;const p=g.data,u=g.types||{},d=Object.keys(p[0]),l=p.map(j=>Object.values(j)),b=d.map(j=>u[j]??"character");let f;_==="networks"?f="name":_==="pointsets"?f="id":_==="nodes"?f=t.node_id_col??d.find(j=>(u[j]??"character")==="character"):_==="edges"||_==="points"||_==="trajectories"?f=t.id_col??d.find(j=>(u[j]??"character")==="character"):f=t.group_col??d.find(j=>(u[j]??"character")==="character");const w=f?d.indexOf(f):0,T=l.map(j=>String(j[w]));this._model.setByKey(_,new Ft(d,l,T,b))}),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(_=>{var g;return((g=s.col(_))==null?void 0:g.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(_=>{var g;return((g=i.col(_))==null?void 0:g.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(_=>{var g;return _!==n&&((g=i.col(_))==null?void 0:g.type)==="character"}))??null,(o=s==null?void 0:s.names)!=null&&o.length){const _=this._model.node_id_col,g=t.x_col,p=t.y_col;if(g&&p)this._model.dimensions=[g,p];else{const u=s.names.filter(d=>{if(d===_)return!1;const l=s.col(d);return l&&l.type!=="character"&&l.type!=="logical"});u.length>=2&&(this._model.dimensions=[g??u[0],p??u[1]])}}this.updated=this._model.updated!==void 0?String(this._model.updated):String(Date.now()),Xt("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."}};c(Jt,"QEVisualElement"),Jt.tagName="qe-visual",Jt.styles=`
1
+ (function(O,U){typeof exports=="object"&&typeof module<"u"?U(exports):typeof define=="function"&&define.amd?define(["exports"],U):(O=typeof globalThis<"u"?globalThis:O||self,U(O.QEViz={}))})(this,(function(O){"use strict";var Hi=Object.defineProperty;var fi=O=>{throw TypeError(O)};var c=(O,U)=>Hi(O,"name",{value:U,configurable:!0});var pi=(O,U,_t)=>U.has(O)||fi("Cannot "+_t);var R=(O,U,_t)=>(pi(O,U,"read from private field"),_t?_t.call(O):U.get(O)),nt=(O,U,_t)=>U.has(O)?fi("Cannot add the same private member more than once"):U instanceof WeakSet?U.add(O):U.set(O,_t),X=(O,U,_t,Ot)=>(pi(O,U,"write to private field"),Ot?Ot.call(O,_t):U.set(O,_t),_t);var xe,we,ve,yt,Ae,Se,xt,Kt,$t,Mt,at,Ee,qt,It,te,ee,ze;const us=class us extends Array{constructor(e,s,i,n,r){super(...s);nt(this,xe);nt(this,we);nt(this,ve);nt(this,yt);nt(this,Ae);X(this,ve,e),X(this,we,i),X(this,yt,n),X(this,Ae,n==null?void 0:n.classes),X(this,xe,r)}get parent(){return R(this,yt)}get names(){return R(this,ve)}get rowName(){return R(this,we)}get types(){if(!R(this,yt))throw new Error("No parent DataFrame attached to this row.");return R(this,yt).types}get classes(){return R(this,Ae)}get rowNumber(){return R(this,xe)}col(e){if(!R(this,yt))throw new Error("No parent DataFrame attached to this row.");return R(this,yt).col(e)}cols(...e){if(!R(this,yt))throw new Error("No parent DataFrame attached to this row.");return R(this,yt).cols(...e)}filter(e){console.error("DataFrameRow does not currently support filtering.")}};xe=new WeakMap,we=new WeakMap,ve=new WeakMap,yt=new WeakMap,Ae=new WeakMap,c(us,"DataFrameRow");let U=us;var _t=(m=>(m.Character="character",m.Double="double",m.Logical="logical",m.Integer="integer",m))(_t||{});const ds=class ds extends Array{constructor(e,s,i,n){super(s.length);nt(this,Se);nt(this,xt);nt(this,Kt);nt(this,$t);for(let r=0;r<s.length;r++)this[r]=s[r];if(X(this,Se,e),s.type!==void 0?X(this,xt,s.type):s.every(r=>typeof r=="string"||r===null||r===void 0)?X(this,xt,"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,xt,"logical"):X(this,xt,"integer"):s.every(r=>typeof r=="number"||r===null||r===void 0)?X(this,xt,"double"):s.every(r=>typeof r=="boolean"||r===null||r===void 0)?X(this,xt,"logical"):X(this,xt,"character"),X(this,$t,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,Kt,i):X(this,Kt,void 0)}get name(){return R(this,Se)}get type(){return R(this,xt)}get rowNames(){return R(this,Kt)}row(e){if(!R(this,$t))throw new Error("No parent DataFrame attached to this column.");return R(this,$t).row(e)}rows(...e){if(!R(this,$t))throw new Error("No parent DataFrame attached to this column.");return R(this,$t).rows(...e)}};Se=new WeakMap,xt=new WeakMap,Kt=new WeakMap,$t=new WeakMap,c(ds,"DataFrameColumn");let Ot=ds;const Me=class Me 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);nt(this,Mt);nt(this,at);nt(this,Ee);if(s.forEach((r,a)=>{r instanceof Ot?this[a]=r:this[a]=new Ot(e[a],r,i,this)}),X(this,Mt,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,Ee,n)}get classes(){return R(this,Ee)}getColumnByName(e){const s=R(this,Mt).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 U(R(this,Mt),[],void 0,this,e);const s=[];for(let i of this){let n=i[e];s.push(n)}return new U(R(this,Mt),s,R(this,at)?R(this,at)[e]:void 0,this,e)}getRowByName(e){if(!R(this,at))return;const s=R(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=R(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 R(this,at)&&h&&(n==null||n.push(R(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=R(this,Mt)):(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 Me(n,i,R(this,at))}subset(e,s){const i=s&&s.length>0?this.cols(...s):this.slice();return new Me(i.map(n=>n.name),i.map(n=>n.values),R(this,at))}get names(){return R(this,Mt)}get rowNames(){return R(this,at)}get nrow(){return this[0]?this[0].length:0}get ncol(){return this.length}};Mt=new WeakMap,at=new WeakMap,Ee=new WeakMap,c(Me,"DataFrame");let Ft=Me;const gs=class gs{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 Ft,this._nodes=t.nodes??new Ft,this._edges=t.edges??new Ft,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}};c(gs,"Model");let is=gs;const bi=globalThis.__QEVIZ_DEBUG__===!0;function Xt(...m){bi&&console.log(...m)}c(Xt,"dbg");const yi={get:c(m=>{const t=[...document.querySelectorAll("qe-graph")];return typeof m=="number"&&m>=0?t[m]:t},"get")},Jt=class Jt 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 is;const t=this.attachShadow({mode:"open"}),e=document.createElement("style");e.textContent=Jt.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(){Xt("QEVisualElement connected"),this.render()}setModelData(t){var r,a,h,o;["nodes","edges","points","groups","confidence","outlier","trajectories","networks","pointsets"].forEach(_=>{var z;const g=t[_];if(!((z=g==null?void 0:g.data)!=null&&z.length))return;const p=g.data,u=g.types||{},d=Object.keys(p[0]),l=p.map(j=>Object.values(j)),b=d.map(j=>u[j]??"character");let f;_==="networks"?f="name":_==="pointsets"?f="id":_==="nodes"?f=t.node_id_col??d.find(j=>(u[j]??"character")==="character"):_==="edges"||_==="points"||_==="trajectories"?f=t.id_col??d.find(j=>(u[j]??"character")==="character"):f=t.group_col??d.find(j=>(u[j]??"character")==="character");const w=f?d.indexOf(f):0,T=l.map(j=>String(j[w]));this._model.setByKey(_,new Ft(d,l,T,b))}),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(_=>{var g;return((g=s.col(_))==null?void 0:g.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(_=>{var g;return((g=i.col(_))==null?void 0:g.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(_=>{var g;return _!==n&&((g=i.col(_))==null?void 0:g.type)==="character"}))??null,(o=s==null?void 0:s.names)!=null&&o.length){const _=this._model.node_id_col,g=t.x_col,p=t.y_col;if(g&&p)this._model.dimensions=[g,p];else{const u=s.names.filter(d=>{if(d===_)return!1;const l=s.col(d);return l&&l.type!=="character"&&l.type!=="logical"});u.length>=2&&(this._model.dimensions=[g??u[0],p??u[1]])}}this.updated=this._model.updated!==void 0?String(this._model.updated):String(Date.now()),Xt("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."}};c(Jt,"QEVisualElement"),Jt.tagName="qe-visual",Jt.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
@@ -15,7 +15,7 @@
15
15
  display: flex;
16
16
  justify-content: center;
17
17
  }
18
- `;let $e=Ue;const Rs=1e-8;function os(m,t=Rs){return m.filter(e=>Math.abs(e.x)>t||Math.abs(e.y)>t)}c(os,"nearOriginFilter");function $s(m){if(m<=0)return[];if(m===1)return[0];const t=new Array(m);for(let e=0;e<m;e++)t[e]=e/(m-1);return t}c($s,"normalizedT");function Ts(m,t){return m.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})}c(Ts,"design");function Fs(m){const t=m.length,e=m[0].length,s=m.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}}c(Fs,"qr");function as(m,t){const e=m.length,s=m[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+=m[a][n]*t[a];i[n]=r}return i}c(as,"qtY");function hs(m,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-=m[i][r]*s[r];s[i]=Math.abs(m[i][i])>1e-12?n/m[i][i]:0}return s}c(hs,"backSolve");function xi(m){return m.map(t=>{let e=0;for(let s=0;s<t.length;s++)e+=t[s]*t[s];return e})}c(xi,"leverages");function Ds(m,t,e){const s=Ts(m,e),{Q:i,R:n}=Fs(s);return hs(n,as(i,t))}c(Ds,"fitCoeffs");function Te(m,t){let e=0,s=1;for(let i=0;i<m.length;i++)e+=m[i]*s,s*=t;return e}c(Te,"evalPoly");function wi(m,t,e,s){const i=Ts(m,s),{Q:n,R:r}=Fs(i),a=xi(n),h=hs(r,as(n,t)),o=hs(r,as(n,e));let _=0;for(let g=0;g<m.length;g++){const p=1-a[g];if(p<=0)return 1/0;const u=t[g]-Te(h,m[g]),d=e[g]-Te(o,m[g]);_+=(u/p)**2+(d/p)**2}return _}c(wi,"loocv2d");function js(m,t,e){const s=m.length,i=Math.min(Math.max(1,Math.floor(t)),Math.max(1,s-1));if(e==="fixed"||s<3)return i;const n=$s(s),r=m.map(_=>_.x),a=m.map(_=>_.y);let h=1,o=1/0;for(let _=1;_<=i;_++){const g=wi(n,r,a,_);g<o&&(o=g,h=_)}return h}c(js,"selectDegree");function Ys(m,t){const e=os(m);if(e.length<3)return null;const s=t.selectionSet?os(t.selectionSet):e,i=s.length>=3?s:e;let n=js(i,t.maxDegree,t.degreeSelection);n=Math.min(n,Math.max(1,e.length-1));const r=$s(e.length),a=Ds(r,e.map(o=>o.x),n),h=Ds(r,e.map(o=>o.y),n);return{degree:n,coeffsX:a,coeffsY:h}}c(Ys,"fitTrajectory");function ls(m,t=100){const e=[];for(let s=0;s<=t;s++){const i=s/t;e.push({x:Te(m.coeffsX,i),y:Te(m.coeffsY,i)})}return e}c(ls,"sampleCurve");const qs=100,As=class As extends Pt{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 ls({degree:this.polyCoeffsX.length-1,coeffsX:this.polyCoeffsX,coeffsY:this.polyCoeffsY},qs);const e=Ys(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,ls(e,qs)}return t.map(e=>({x:e.x,y:e.y}))}};c(As,"Trajectory");let ce=As;const Gs=1,Ss=class Ss extends Ht{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 ae(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}};c(Ss,"Edge");let _e=Ss;const Es=class Es extends Pt{constructor(e){super(e.dimensions||[],e);nt(this,te);X(this,te,e)}get edge(){return R(this,te)}get path(){const e=R(this,te),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],_=Math.hypot(n[0]-s[0],n[1]-s[1]),g=[(n[0]-s[0])/_,(n[1]-s[1])/_],p=c(T=>h/2*Math.max(0,1-T/a),"halfW"),u=c((T,z)=>`${s[0]+o[0]*T+g[0]*z} ${s[1]+o[1]*T+g[1]*z}`,"at"),d=.2*a,l=Math.min(.15*a,.8*2*p(d)),b=d+l/2,f=d+l;return`M${u(d,0)} L${u(b,p(b))} L${u(f,p(f))} L${u(b,0)} L${u(f,-p(f))} L${u(b,-p(b))}z`}};te=new WeakMap,c(Es,"EdgeArrow");let Fe=Es;const Xe=class Xe extends _e{constructor(e,s,i){super(e,s,i);nt(this,ee);nt(this,ze);this._path="",X(this,ee,!1),this._directions=["from","to"],this.towards="to",R(this,ee)===!0&&X(this,ze,new Fe(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(b=>b!==e.towards),n=e[i].x,r=e[i].y,a=e[s].x,h=e[s].y,o=a-n,_=h-r,g=Math.hypot(o,_),p=(e.weight??0)*Gs;if(g===0||!isFinite(p)||p===0)return[[a,h],[a,h]];const u=-_/g,d=o/g,l=p/2;return[[a+u*l,h+d*l],[a-u*l,h-d*l]]}get base_pts(){return Xe.calculate_base_points(this)}get arrow(){return R(this,ze)}get with_arrow(){return R(this,ee)}get from_point(){return[this.from.x,this.from.y]}};ee=new WeakMap,ze=new WeakMap,c(Xe,"TaperedEdge");let jt=Xe;const We=class We extends jt{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 le.Geometry.Line.interpolate(this.line)(1-this._dataWeight/this._totalweight)}get base_pts(){return jt.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 We.build_path(this)}get from_point(){return this.weighted_midpoint}};c(We,"TaperedWeightedMidpointEdge");let cs=We;const He=class He extends _e{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*Gs;return He.build_path(t,this.to)}};c(He,"NodeEdge");let Vt=He;const Ms=class Ms{constructor(t,e,s,i=new Rt){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),_=i+(s-i)*o;t.setAttribute(e,_.toString()),o<1?requestAnimationFrame(a):t.setAttribute(e,s.toString())}c(a,"animate"),requestAnimationFrame(a)}};c(Ms,"Drawable");let ue=Ms;const vi=.04,Ai=[.25,1],Si=[.3,1];function Bs(m,t,e,s){const i=Math.abs(m);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])}c(Bs,"rampFor");const Ei=.011,Mi=.75,Ii=.8,Ni=.75,Us=.006,ki=.6;function zi(m){return 2*m}c(zi,"widthPerWeight");function Ci(m,t){return m*t/(2*Us)}c(Ci,"nodeSizeForEdges");function Oi(m){const t=/rgba?\(([^)]+)\)/.exec(m);if(!t)return m;const[e,s,i,n=1]=t[1].split(",").map(Number),r=c(a=>Math.round(255+(a-255)*n),"f");return`rgb(${r(e)},${r(s)},${r(i)})`}c(Oi,"flattenOnWhite");function Pi(m,t){const e=/rgba?\(([^)]+)\)/.exec(m);if(!e)return m;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})`}c(Pi,"darkenRgba");const Is=class Is extends ue{constructor(t,e,s,i=new Rt){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??{};if(!e.isMeanEdge)return;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");const s=c((i,n)=>n!=null&&n!==!1?t.setAttribute(i,n===!0?"true":String(n)):t.removeAttribute(i),"opt");s("data-edge-self",!!e.isSelf),s("data-edge-group",e.group),s("data-edge-unit",e.unit)}create(){if(this.__data__ instanceof Vt){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 jt){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}get drawsPath(){return this.__data__ instanceof Vt||this.__data__ instanceof jt}update(){var i,n,r,a;if(this.svg_element||this.create(),this.svg_element.tagName.toLowerCase()==="path"!==this.drawsPath){const h=this.svg_element;this.create(),h.parentElement&&h.replaceWith(this.svg_element)}this.drawsPath&&((i=this._hit_el)==null||i.remove(),this._hit_el=null),this.svg_element.parentElement||this.parent.appendChild(this.svg_element);const t=((n=this.graph.__data__.extremes)==null?void 0:n.x_max)??1,e=this.__data__.meta??{};let s=!1;if(e.isMeanEdge){this._stampEdge(this.svg_element);const h=typeof e.weight=="number"?e.weight:0,o=typeof e.maxWeight=="number"?e.maxWeight:1,_=typeof e.opacity=="number"?e.opacity:Math.min(1,h/(o||1)),g=t>0?t:1,p=e.fixedSize&&this.graph.zoom_level||1,u=(typeof e.widthFrac=="number"?g*e.widthFrac*h:g*Ei*(h/(o||1)))/p,d=this.__data__._color||new tt("#000000"),l=typeof e.saturation=="number"?e.saturation:_,b=new ae(d,l,_).toString();if(this.__data__ instanceof Vt){const f=typeof e.selfSize=="number"&&e.selfSize>0?e.selfSize:null,w=f!=null?(a=(r=this.graph)._nodeRadius)==null?void 0:a.call(r,String(e.source)):null;this.__data__.weight=typeof w=="number"?2*f*w:u,this.svg_element.setAttribute("d",this.__data__.path),this.svg_element.setAttribute("fill",b),this.svg_element.setAttribute("stroke","none")}else if(this.__data__ instanceof jt){if(this.__data__.weight=u,this.svg_element.setAttribute("d",this.__data__.path),this.svg_element.setAttribute("fill",b),this.svg_element.setAttribute("stroke",b),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 w=new Fe(this.__data__).path;w&&!w.includes("NaN")&&!w.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",w),this._arrow_el.setAttribute("fill",Pi(Oi(b),Ii)),this._arrow_el.setAttribute("stroke","#ffffff"),this._arrow_el.setAttribute("stroke-width",String(Ni)),this._arrow_el.setAttribute("vector-effect","non-scaling-stroke"),this._arrow_el.setAttribute("stroke-linejoin","round"),s=!0)}catch{}}else{const f=this.__data__.from.x,w=this.__data__.from.y,T=this.__data__.to.x,z=this.__data__.to.y;this.svg_element.setAttribute("x1",f.toString()),this.svg_element.setAttribute("y1",w.toString()),this.svg_element.setAttribute("x2",T.toString()),this.svg_element.setAttribute("y2",z.toString()),this.svg_element.setAttribute("stroke-width",u.toString()),this.svg_element.setAttribute("stroke",b),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",f.toString()),this._hit_el.setAttribute("y1",w.toString()),this._hit_el.setAttribute("x2",T.toString()),this._hit_el.setAttribute("y2",z.toString()),this._hit_el.setAttribute("stroke-width",Math.max(u,t*.03/p).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 h=this.graph._axesFixedSize&&String(this.__data__.ID).startsWith("axis-")&&this.graph.zoom_level||1,o=(t>0?t:1)*.004*this.get_size()/h;this.svg_element.setAttribute("stroke-width",o.toString()),this.svg_element.setAttribute("stroke-opacity","1"),this.svg_element.setAttribute("stroke",this.__data__.color.toString())}!s&&this._arrow_el&&(this._arrow_el.remove(),this._arrow_el=null)}remove(){var t,e,s;(t=this.svg_element)==null||t.remove(),(e=this._hit_el)==null||e.remove(),(s=this._arrow_el)==null||s.remove()}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))}};c(Is,"QELine");let St=Is;const Ns=class Ns extends ue{constructor(t,e,s,i=new Rt){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 e;const t=this.dataRadius();return(e=this.__data__.meta)!=null&&e.zoomFixed?t/(this.graph.zoom_level||1):t}dataRadius(){var i,n,r,a,h,o,_;const t=this.graph.__data__.extremes.x_max||1,e=((i=this.__data__.meta)==null?void 0:i.sizeScale)??1,s=(n=this.__data__.meta)==null?void 0:n.sizePx;if(typeof s=="number"&&s>0){const g=(a=(r=this.graph.svg_element)==null?void 0:r.getBoundingClientRect)==null?void 0:a.call(r),p=g&&g.width>0?2*t/g.width:t*.004;return s/2*p}if((h=this.__data__.meta)!=null&&h.fixedSize){const g=(_=(o=this.graph.svg_element)==null?void 0:o.getBoundingClientRect)==null?void 0:_.call(o),p=this.graph.zoom_level||1,u=g&&g.width>0?g.width/(2*t):1;return this.__data__.size*2*e/u/p}return t*Us*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()))}stampIdentity(t){t.setAttribute("data-point-id",this.__data__.ID);const e=this.__data__.meta??{},s=c((i,n)=>n!=null&&n!==""?t.setAttribute(i,String(n)):t.removeAttribute(i),"opt");s("data-kind",e.kind),s("data-name",e.name),s("data-group",e.group),s("data-unit",e.unit)}create(){const t=document.createElementNS("http://www.w3.org/2000/svg",this.tag);return this.stampIdentity(t),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 e=new CustomEvent("point-clicked",{detail:{pointData:this.__data__},bubbles:!0,composed:!0});this.svg_element.dispatchEvent(e)}),t.addEventListener("mouseover",()=>{}),t}update(){if(this.svg_element||this.parent.__data__.__children__.push(this.create()),this.svg_element.tagName.toLowerCase()!==this.tag){const t=this.svg_element;this.create(),t.parentElement&&t.replaceWith(this.svg_element)}this.svg_element.parentElement||this.parent.appendChild(this.svg_element),this.stampIdentity(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)}};c(Ns,"QEPoint");let Zt=Ns;const ks=class ks extends ue{constructor(t,e,s,i=new Rt){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 _=s[o],g=s[o+1],p=i<=1?1:o/(i-1),u=n+(r-n)*p,d=a+(h-a)*p,l=document.createElementNS("http://www.w3.org/2000/svg","path");l.setAttribute("d",`M${_.x},${_.y} L${g.x},${g.y}`),l.setAttribute("fill","none"),l.setAttribute("stroke",this.__data__.color.toString()),l.setAttribute("stroke-linecap","round"),l.setAttribute("stroke-linejoin","round"),l.setAttribute("stroke-width",this.graphUnitsForPixels(u).toString()),l.setAttribute("opacity",d.toString()),this._segments_group.appendChild(l)}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()}};c(ks,"QETrajectory");let de=ks;const{ArrayTools:Xs}=le,zs=class zs extends Array{constructor(...t){super(...t)}search(t,e){let s;function i(r){return r.name===e?r:void 0}c(i,"fn");function n(r,a,h=null){if(Xs.isArray(r)){for(const[o,_]of r.entries())if(s=n(_,o,h),s)return s}else{if(s=i(r),s)return s;if(r&&Xs.isArray(r[t])){for(const[o,_]of r[t].entries())if(s=n(_,o,r),s)return s}}return s}return c(n,"recurse"),n(this)}flatten(){return this.reduce((t,e)=>(t.push(e),e.layers&&Array.isArray(e.layers)&&t.push(...e.layers),t),[])}};c(zs,"QEArray");let Rt=zs;const Li={AxisPoint:Zt,AxisLine:St,Point:Zt,Line:St,Edge:St,TaperedEdge:St,TaperedWeightedMidpointEdge:St,NodeEdge:St,Trajectory:de},se=class se{constructor(t,e,s,i=new Rt){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=c(p=>{var u;return(u=p.__data__)==null?void 0:u.ID},"childId"),o=this.__children__.filter(p=>!r.objects.has(h(p))),_=this.__children__.filter(p=>r.objects.has(h(p)));[...r.objects.values()].filter(p=>!this.__children__.some(u=>h(u)===p.ID)).forEach(p=>{const u=p._typeName||p.constructor.name;let d=Li[u];d||(p instanceof ce?d=de:p instanceof J?d=Zt:d=St);const l=new d(p,this.svg_element,this.graph);this.__children__.push(l)}),_.forEach(p=>{const u=r.objects.get(h(p));u&&(p.__data__=u),p.update()}),o.forEach(p=>{var d;typeof p.remove=="function"?p.remove():(d=p.svg_element.parentElement)==null||d.removeChild(p.svg_element);const u=this.__children__.indexOf(p);u>=0&&this.__children__.splice(u,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",se.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 se(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)}};c(se,"QELayer"),se.tagName="g";let De=se;const Cs=class Cs{constructor(t,e,s,i,n=q.DISPLAY_TYPES.ON,r=q.POSITION.OBJECT,a,h){this.text=t,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._hostPinned=!1,this.fontWeight=null,this._point=e,this.svg_element=this._create(),n===q.DISPLAY_TYPES.ON?(this._visible=!0,this.svg_element.setAttribute("display","block")):(this._visible=!1,this.svg_element.setAttribute("display","none"))}get point(){return this._point}_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}setPoint(t){this._point=t,this.svg_element.setAttribute("data-label-for",t.ID)}setOffset(t,e){this._offsetX=Number.isFinite(t)?t:0,this._offsetY=Number.isFinite(e)?e:0}setHostPinned(t){t!==this._hostPinned&&(this._hostPinned=t,t?this.show():this.displayMode!==q.DISPLAY_TYPES.ON&&this.hide())}_attachDrag(t){t.addEventListener("mousedown",e=>{e.preventDefault(),e.stopPropagation(),this._drag(t,e.clientX,e.clientY,"mouse")}),t.addEventListener("pointerdown",e=>{e.pointerType==="touch"&&(e.preventDefault(),e.stopPropagation(),this._drag(t,e.clientX,e.clientY,e.pointerId))})}_drag(t,e,s,i){const n=t.parentNode??t.ownerSVGElement,r=t.ownerSVGElement;if(!r||!n)return;const a=c((u,d)=>{const l=r.createSVGPoint();l.x=u,l.y=d;const b=n.getScreenCTM();return b?l.matrixTransform(b.inverse()):{x:0,y:0}},"toUser"),h=a(e,s),o=this._offsetX,_=this._offsetY;t.style.cursor="grabbing";const g=c((u,d)=>{const l=a(u,d);this._offsetX=o+(l.x-h.x),this._offsetY=_+(l.y-h.y),this.pinned=!0,this._visible=!0,this.svg_element.setAttribute("display","block"),this.update()},"move"),p=c(()=>{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}))},"done");if(i==="mouse"){const u=c(l=>g(l.clientX,l.clientY),"onMove"),d=c(()=>{document.removeEventListener("mousemove",u),document.removeEventListener("mouseup",d),p()},"onUp");document.addEventListener("mousemove",u),document.addEventListener("mouseup",d)}else{const u=c(l=>{l.pointerId===i&&g(l.clientX,l.clientY)},"onMove"),d=c(l=>{l.pointerId===i&&(document.removeEventListener("pointermove",u),document.removeEventListener("pointerup",d),document.removeEventListener("pointercancel",d),p())},"onUp");document.addEventListener("pointermove",u),document.addEventListener("pointerup",d),document.addEventListener("pointercancel",d)}}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 q.POSITION.STATIC:{n=this.point.x,r=this.point.y-i*.3,a="middle";break}case q.POSITION.CONTAINER:{const{cx:o,cy:_}=this.graph.__data__.extremes,g=this.point.x-o,p=this.point.y-_,u=Math.sqrt(g*g+p*p)||1,d=t*.93/u;n=o+g*d,r=_+p*d-i*.3,a=g>=0?"start":"end";break}case q.POSITION.CUSTOM:if(this.customX!=null&&this.customY!=null){n=this.customX,r=this.customY,a="start";break}default:case q.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.removeAttribute("transform"),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",this.fontWeight??"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"),!this._offsetX&&!this._offsetY&&this.position!==q.POSITION.CUSTOM&&this.fitInside(n,r,a,i,s*.3)}visibleBounds(){var h;const t=this.svg_element,e=t.ownerSVGElement,s=(h=t.getScreenCTM)==null?void 0:h.call(t);if(!e||!s)return null;const i=e.getBoundingClientRect();if(!(i.width>0&&i.height>0))return null;const n=s.inverse(),r=new DOMPoint(i.left,i.top).matrixTransform(n),a=new DOMPoint(i.right,i.bottom).matrixTransform(n);return{left:Math.min(r.x,a.x),right:Math.max(r.x,a.x),top:Math.min(r.y,a.y),bottom:Math.max(r.y,a.y)}}bbox(){try{const t=this.svg_element.getBBox();return t.width>0?t:null}catch{return null}}fitInside(t,e,s,i,n){const r=this.visibleBounds();let a=this.bbox();if(!r||!a)return;const h=r.left+n,o=r.right-n,_=r.top+n,g=r.bottom-n,p=c(b=>Math.max(0,h-b.x)+Math.max(0,b.x+b.width-o),"over"),u=this.svg_element;if(p(a)>0&&this.position===q.POSITION.OBJECT&&s!=="middle"){const b=s==="end"?"start":"end",f=s==="end"?this.point.x+i:this.point.x-i;u.setAttribute("text-anchor",b),u.setAttribute("x",f.toString());const w=this.bbox();w&&p(w)<p(a)?(a=w,t=f):(u.setAttribute("text-anchor",s),u.setAttribute("x",t.toString()))}let d=0,l=0;a.x<h?d=h-a.x:a.x+a.width>o&&(d=Math.max(o-(a.x+a.width),h-a.x)),a.y<_?l=_-a.y:a.y+a.height>g&&(l=Math.max(g-(a.y+a.height),_-a.y)),d&&u.setAttribute("x",(t+d).toString()),l&&u.setAttribute("y",(e+l).toString())}show(){this._visible=!0,this.svg_element.setAttribute("display","block"),this.update()}hide(){this.pinned||this._hostPinned||(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()}};c(Cs,"QELabel");let _s=Cs;const Ve=class Ve extends HTMLElement{};c(Ve,"QENodesElement"),Ve.tagName="qe-nodes";let ge=Ve;const Ze=class Ze extends HTMLElement{};c(Ze,"QEMeansElement"),Ze.tagName="qe-means";let me=Ze;const Ke=class Ke extends HTMLElement{};c(Ke,"QEPointsElement"),Ke.tagName="qe-points";let fe=Ke;const Je=class Je extends HTMLElement{};c(Je,"QEEdgesElement"),Je.tagName="qe-edges";let pe=Je;const Qe=class Qe extends HTMLElement{};c(Qe,"QETrajectoriesElement"),Qe.tagName="qe-trajectories";let be=Qe;const ts=class ts extends HTMLElement{};c(ts,"QEAxesElement"),ts.tagName="qe-axes";let ye=ts;customElements.define(ge.tagName,ge),customElements.define(me.tagName,me),customElements.define(fe.tagName,fe),customElements.define(pe.tagName,pe),customElements.define(be.tagName,be),customElements.define(ye.tagName,ye);const Ws=["#4477AA","#EE6677","#228833","#CCBB44","#66CCEE","#AA3377","#BBBBBB","#000000"];function Ri(m,t){for(const e of t)if(m===`${e}.${e}`)return[e,e];for(const e of t)if(m.startsWith(e+".")){const s=m.slice(e.length+1);if(t.includes(s))return[e,s]}return null}c(Ri,"parseEdgePair");function $i(m,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,m)/e)*s,a=Math.sqrt(Math.max(0,t)/e)*s;return{halfW:n*r,halfH:n*a}}c($i,"computeCIRect");const Ti=.5;function je(m,t,e){if(!m)return;const s=Math.min(Math.abs(t),Math.abs(e));s>0&&(m.meta={...m.meta??{},maxRadius:s*Ti})}c(je,"capMeanToInterval");function Ye(m,t,e,s=""){const i=c(o=>{const _=m.names.indexOf(o),g=_>=0?m[_]:null;if(g==null||g==="")return;const p=Number(g);return Number.isFinite(p)?p: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}}c(Ye,"readIntervalBounds");function qe(m,t){const e=c(o=>{if(!m)return;const _=m.names.indexOf(o);return _>=0?m[_]:void 0},"raw"),s=c(o=>o==null||o==="NA"||typeof o=="number"&&Number.isNaN(o),"isNA"),i=e("label"),n=s(i)?t:String(i)===""?null:String(i),r=c(o=>{const _=e(o),g=s(_)||_===""?0:Number(_);return Number.isFinite(g)?g:0},"num"),a=!!m&&(m.names.includes("label.dx")||m.names.includes("label.dy")),h=e("label.pinned");return{text:n,offset:a?{x:r("label.dx"),y:r("label.dy")}:null,pinned:h===!0||h===1||String(h).toLowerCase()==="true"}}c(qe,"readLabelSpec");function Fi(m){const t=m==null?void 0:m.trim().toLowerCase();if(!t)return null;if(t==="node")return .5;const e=Number(t);return Number.isFinite(e)&&e>0?e:null}c(Fi,"parseSelfSize");function Di(m){var i,n;const t=c(r=>m.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"),selfSize:Fi(t("self-size")),fixedSize:m.hasAttribute("fixed-size")}}c(Di,"parseEdgeLayer");function ji(m){const{r:t,g:e,b:s}=tt.parseColor(m),i=Math.max(t,e,s),n=Math.min(t,e,s),r=c(a=>(i+n-a).toString(16).padStart(2,"0"),"f");return`#${r(t)}${r(e)}${r(s)}`}c(ji,"complementColor");function Yi(m){const t=m==null?void 0:m.trim().toLowerCase();return t==="plot"||t==="absolute"?t:"model"}c(Yi,"parseColorScale");function Ge(m,t){switch(m==null?void 0:m.toLowerCase()){case"on":return 3;case"off":return 0;case"click":return 2;case"auto":return 1;default:return t}}c(Ge,"parseLabelMode");const it=class it extends $e{constructor(){super(),this.zoom_level=1,this.__children__=new Rt,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._setLabels=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._edgesFixedSize=!1,this._meansFixedSize=!1,this._intervalBase=new WeakMap,this._axesFixedSize=!1,this._plotTitle=null,this._titleEl=null,this._resizeObs=null,this._labelFont={size:null,family:null,color:null},this._zoomAnim=null,this._animateMs=0,this._tweenRaf=null,this._tween=null,this._tweenView=null,this._highlight={edges:new Set,nodes:new Set},this._highlightGroup=null,this._tooltipEl=null,this.graph=this,this.parent=null,this.__data__=new Re(Ls),this.__name__=this.__data__.name||"unnamed-graph",this.svg_element=this.create(),Xt("Created qe-graph svg element: ",this.svg_element),document.addEventListener("model-updated",t=>{var Ks,Js,Qs,ti,ei,si,ii,ni,ri,oi,ai,hi,li,ci,_i,ui,di;const e=((Ks=t.composedPath)==null?void 0:Ks.call(t)[0])??t.target;if(this._vizena&&e!==this._vizena)return;const s=t.detail;if(!s)return;this._renderPending=!1,(Js=this._childObserver)==null||Js.takeRecords(),this._animateMs=this.hasAttribute("animate")?parseInt(this.getAttribute("animate")||"",10)||300:0;const i=this._animateMs>0&&this._hasModel?this._captureTweenState():null;this._stopTween(),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 _={},g=(Qs=s.palette)!=null&&Qs.length?s.palette:Ws;if(h&&((ti=s.points)!=null&&ti.names)){const I=s.points.col(h);I&&[...new Set([...I].map(String))].forEach((L,N)=>{_[L]=g[N%g.length]})}(ei=s.groups)!=null&&ei.rows&&s.groups.rows().length>0&&s.groups.rows().forEach(I=>{const k=I.rowName??String(I[0]),L=I.names.indexOf("color"),N=L>=0?I[L]:null;N&&String(N)!=="NA"?_[k]=String(N):_[k]||(_[k]=g[Object.keys(_).length%g.length])});const p=Object.keys(_),u=o.activeMeanGroups&&o.activeMeanGroups.trim()?new Set(o.activeMeanGroups.split(",").map(I=>I.trim()).filter(I=>_[I])):new Set(p),d=o.scalePoints,l=c(I=>{let k=0;return I.forEach(L=>{const N=L.names.indexOf(n[0]),S=n.length>1?L.names.indexOf(n[1]):-1;N>=0&&(k=Math.max(k,Math.abs(Number(L[N])))),S>=0&&(k=Math.max(k,Math.abs(Number(L[S]))))}),k},"getExtent"),b=(si=s.nodes)!=null&&si.rows?l(s.nodes.rows()):0,f=(ii=s.points)!=null&&ii.rows?l(s.points.rows()):0,w=(ni=s.trajectories)!=null&&ni.rows?l(s.trajectories.rows()):0,T=f>0?f:w,z=o.pointScale!==null?o.pointScale:d&&T>0&&b>0?b/T:1;this._rangeExtent=o.range==="network"?b*1.2:o.range==="points"?T*z*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._edgesFixedSize=o.edgeLayers.some(I=>I.fixedSize),this._meansFixedSize=o.meanFixedSize,this._axesFixedSize=o.axesFixedSize,this._plotTitle=o.plotTitle,this._labelFont=o.labelFont;const j=o.labelNodes,dt=o.labelMeans,gt=o.labelPoints,et=this._labelsGroup,mt=c((I,k,L,N=1)=>{const S=I.names.indexOf(k),y=I.names.indexOf(n[0]),P=n.length>1?I.names.indexOf(n[1]):-1,v=new J({ID:S>=0?String(I[S]):I.rowName||`pt-${Math.random().toString(36).slice(2)}`,dimensions:[y>=0?Number(I[y])*N:0,P>=0?-Number(I[P])*N:0],meta:{}});return L&&(v.color=new tt(L)),v},"rowToPoint"),Q={},Tt=o.showPoints;["points","nodes","edges","edgenodes"].map(I=>this.__children__.search("__children__",I)).filter(I=>!!I).forEach(I=>I.__data__.objects.clear()),this.__data__.points.clear();const Ce=s.pointsets,Gt=[];if(o.pointSets.length&&(Ce!=null&&Ce.rows)){const I=this.__children__.search("__children__","points"),k=c((L,N)=>{const S=L.names.indexOf(N);return S>=0?L[S]:null},"col");o.pointSets.forEach((L,N)=>{Ce.rows().forEach(S=>{if(String(k(S,"set"))!==L.set)return;const y=String(k(S,"id")),P=k(S,"group")!=null&&String(k(S,"group"))!=="NA"?String(k(S,"group")):null,v=k(S,"color")&&String(k(S,"color"))!=="NA"?String(k(S,"color")):P&&_[P]?_[P]:g[N%g.length],E=mt(S,"id",v,z);E.ID=`${L.set}::${y}`,E.size=L.size??o.pointSize??2.5;const D=k(S,"shape");D&&String(D)!=="NA"&&(E.shape=String(D));const W=k(S,"label");E.meta={stroke:"#ffffff",kind:"point",name:W!=null&&String(W)!=="NA"?String(W):y,group:P??void 0,unit:y,set:L.set,fixedSize:L.fixedSize},this.__data__.points.set(E.ID,E),I==null||I.__data__.objects.set(E.ID,E),Gt.push({pt:E,spec:qe(S,y),mode:L.labelMode,weight:L.labelWeight})})})}if(et){const I=new Set(Gt.map(k=>k.pt.ID));this._setLabels.forEach((k,L)=>{I.has(L)||(k.remove(),this._setLabels.delete(L))}),Gt.forEach(k=>this._syncLabel(this._setLabels,k.pt.ID,k.spec,k.pt,et,k.mode,k.weight))}if((ri=s.points)!=null&&ri.rows){const I=this.__children__.search("__children__","points");if(I){s.points.rows().forEach(N=>{const S=h?N.names.indexOf(h):-1,y=S>=0?String(N[S]):null,P=y?_[y]??"#888888":"#888888";if(Tt){const v=mt(N,r,P,z);v.size=o.pointSize??2.5,v.meta={...v.meta??{},stroke:"#ffffff",kind:"point",name:v.ID,group:y??void 0,unit:v.ID,fixedSize:o.pointFixedSize},this.__data__.points.set(v.ID,v),I.__data__.objects.set(v.ID,v)}if(y){const v=N.names.indexOf(n[0]),E=n.length>1?N.names.indexOf(n[1]):-1;Q[y]||(Q[y]={x:0,y:0,x2:0,y2:0,xy:0,n:0,color:P});const D=v>=0?Number(N[v]):0,W=E>=0?Number(N[E]):0;Q[y].x+=D,Q[y].y+=W,Q[y].x2+=D*D,Q[y].y2+=W*W,Q[y].xy+=D*W,Q[y].n+=1}});const k=!!((oi=s.groups)!=null&&oi.rows&&s.groups.rows().length>0),L=o.showMeans&&k?s.groups.rows().filter(N=>{const S=N.rowName??String(N[0]);return u.size===0||u.has(S)}):[];if(o.showMeans){const N=I.svg_element,S=this._rangeExtent?this._rangeExtent/1.2:b,y=(S>0?S:1)*.008;if(k){const P=new Set(L.map(v=>v.rowName??String(v[0])));this._ciRects.forEach((v,E)=>{P.has(E)||(v.remove(),this._ciRects.delete(E))}),this._outlierRects.forEach((v,E)=>{P.has(E)||(v.remove(),this._outlierRects.delete(E))}),this._ciCross.forEach((v,E)=>{P.has(E.slice(2))||(v.remove(),this._ciCross.delete(E))}),L.forEach(v=>{var ss,re,Ut;const E=v.rowName??String(v[0]),D=_[E]??"#888888",W=v.names.indexOf(n[0]),G=n.length>1?v.names.indexOf(n[1]):-1,V=W>=0?Number(v[W])*z:0,vt=G>=0?-Number(v[G])*z:0,H=new J({ID:`mean-${E}`,dimensions:[V,vt],meta:{kind:"mean",name:E,group:E,fixedSize:o.meanFixedSize}});H.color=new tt(D),H.size=4;const ht=v.names.indexOf("shape"),$=ht>=0?v[ht]:null;H.shape=$&&String($)!=="NA"?String($):"rect",this.__data__.points.set(H.ID,H),I.__data__.objects.set(H.ID,H);const ie=c(Y=>{const x=v.names.indexOf(Y),A=x>=0?v[x]:null;return A==null||String(A)==="NA"||String(A)===""?null:A},"cell"),pt=ie("intervals"),zt=pt==="box"||pt==="crosshairs"||pt==="none"?pt:o.intervals,Bt=ie("outlier"),B=(Bt==null?o.showOutlier:Bt===!0||String(Bt)==="true")?Ye(v,n[0],n[1],"o"):null;if(!B)(ss=this._outlierRects.get(E))==null||ss.remove(),this._outlierRects.delete(E);else{let Y=this._outlierRects.get(E);Y||(Y=document.createElementNS("http://www.w3.org/2000/svg","rect"),Y.setAttribute("data-outlier-group",E),this._outlierRects.set(E,Y)),Y.setAttribute("x",(B.x_low*z).toString()),Y.setAttribute("y",(-B.y_high*z).toString()),Y.setAttribute("width",((B.x_high-B.x_low)*z).toString()),Y.setAttribute("height",((B.y_high-B.y_low)*z).toString()),Y.setAttribute("fill","none"),Y.setAttribute("stroke",D),Y.setAttribute("stroke-width",y.toString()),Y.setAttribute("stroke-opacity","0.5"),Y.setAttribute("stroke-dasharray",`${y*2} ${y*2}`),this._intervalStroke(Y,y,[y*2,y*2]),N&&!Y.parentElement&&N.insertBefore(Y,N.firstChild)}const ot=zt!=="none"?Ye(v,n[0],n[1]):null,ne=`x:${E}`;if((!ot||zt!=="crosshairs")&&((re=this._ciCross.get(ne))==null||re.remove(),this._ciCross.delete(ne)),ot&&zt==="crosshairs"){(Ut=this._ciRects.get(E))==null||Ut.remove(),this._ciRects.delete(E);const Y=ot.x_low*z,x=ot.x_high*z,A=-ot.y_high*z,C=-ot.y_low*z;je(H,(x-Y)/2,(C-A)/2);let M=this._ciCross.get(ne);M||(M=document.createElementNS("http://www.w3.org/2000/svg","path"),M.setAttribute("data-ci-group",E),M.setAttribute("data-ci-kind","crosshairs"),this._ciCross.set(ne,M)),M.setAttribute("d",`M${Y} ${vt} L${x} ${vt} M${V} ${A} L${V} ${C}`),M.setAttribute("fill","none"),M.setAttribute("stroke",D),M.setAttribute("stroke-width",(y*1.25).toString()),this._intervalStroke(M,y*1.25,null),M.setAttribute("stroke-opacity","0.8"),N&&!M.parentElement&&N.insertBefore(M,N.firstChild)}else if(ot){const Y=ot.x_low*z,x=-ot.y_high*z,A=(ot.x_high-ot.x_low)*z,C=(ot.y_high-ot.y_low)*z;je(H,A/2,C/2);let M=this._ciRects.get(E);M||(M=document.createElementNS("http://www.w3.org/2000/svg","rect"),M.setAttribute("data-ci-group",E),this._ciRects.set(E,M)),M.setAttribute("x",Y.toString()),M.setAttribute("y",x.toString()),M.setAttribute("width",A.toString()),M.setAttribute("height",C.toString()),M.setAttribute("fill","none"),M.setAttribute("stroke",D),M.setAttribute("stroke-width",y.toString()),M.setAttribute("stroke-opacity","0.8"),M.setAttribute("stroke-dasharray",`${y*4} ${y*3}`),this._intervalStroke(M,y,[y*4,y*3]),N&&!M.parentElement&&N.insertBefore(M,N.firstChild)}else{const Y=this._ciRects.get(E);Y&&(Y.remove(),this._ciRects.delete(E))}})}else this._removeIntervals(this._ciCross),Object.entries(Q).forEach(([v,{x:E,y:D,n:W,color:G}])=>{const V=new J({ID:`mean-${v}`,dimensions:[E/W*z,-(D/W)*z],meta:{kind:"mean",name:v,group:v,fixedSize:o.meanFixedSize}});V.color=new tt(G),V.size=4,V.shape="rect",this.__data__.points.set(V.ID,V),I.__data__.objects.set(V.ID,V)}),o.showCI?(this._ciRects.forEach((v,E)=>{Q[E]||(v.remove(),this._ciRects.delete(E))}),(ai=s.confidence)!=null&&ai.rows?s.confidence.rows().forEach(v=>{const E=v.names.indexOf(h??"group"),D=E>=0?String(v[E]):v.rowName??null;if(!D)return;const W=_[D]??"#888888",G=Ye(v,n[0],n[1]);if(!G)return;const V=G.x_low*z,vt=-G.y_high*z,H=(G.x_high-G.x_low)*z,ht=(G.y_high-G.y_low)*z;je(this.__data__.points.get(`mean-${D}`),H/2,ht/2);let $=this._ciRects.get(D);$||($=document.createElementNS("http://www.w3.org/2000/svg","rect"),$.setAttribute("data-ci-group",D),this._ciRects.set(D,$)),$.setAttribute("x",V.toString()),$.setAttribute("y",vt.toString()),$.setAttribute("width",H.toString()),$.setAttribute("height",ht.toString()),$.setAttribute("fill","none"),$.setAttribute("stroke",W),$.setAttribute("stroke-width",y.toString()),$.setAttribute("stroke-opacity","0.8"),$.setAttribute("stroke-dasharray",`${y*4} ${y*3}`),this._intervalStroke($,y,[y*4,y*3]),N&&!$.parentElement&&N.insertBefore($,N.firstChild)}):Object.entries(Q).forEach(([v,{x:E,y:D,x2:W,y2:G,n:V,color:vt}])=>{if(V<2)return;const H=E/V,ht=D/V,$=W/V-H*H,ie=G/V-ht*ht,{halfW:pt,halfH:zt}=$i($,ie,V,z),Bt=H*z,Oe=-ht*z;je(this.__data__.points.get(`mean-${v}`),pt,zt);let B=this._ciRects.get(v);B||(B=document.createElementNS("http://www.w3.org/2000/svg","rect"),B.setAttribute("data-ci-group",v),this._ciRects.set(v,B)),B.setAttribute("x",(Bt-pt).toString()),B.setAttribute("y",(Oe-zt).toString()),B.setAttribute("width",(pt*2).toString()),B.setAttribute("height",(zt*2).toString()),B.setAttribute("fill","none"),B.setAttribute("stroke",vt),B.setAttribute("stroke-width",y.toString()),B.setAttribute("stroke-opacity","0.8"),B.setAttribute("stroke-dasharray",`${y*4} ${y*3}`),this._intervalStroke(B,y,[y*4,y*3]),N&&!B.parentElement&&N.insertBefore(B,N.firstChild)})):this._removeIntervals(this._ciRects),(hi=s.outlier)!=null&&hi.rows?(this._outlierRects.forEach((v,E)=>{_[E]||(v.remove(),this._outlierRects.delete(E))}),s.outlier.rows().forEach(v=>{const E=v.names.indexOf(h??"group"),D=E>=0?String(v[E]):v.rowName??null;if(!D)return;const W=_[D]??"#888888",G=Ye(v,n[0],n[1]);if(!G)return;const V=G.x_low*z,vt=-G.y_high*z,H=(G.x_high-G.x_low)*z,ht=(G.y_high-G.y_low)*z;let $=this._outlierRects.get(D);$||($=document.createElementNS("http://www.w3.org/2000/svg","rect"),$.setAttribute("data-outlier-group",D),this._outlierRects.set(D,$)),$.setAttribute("x",V.toString()),$.setAttribute("y",vt.toString()),$.setAttribute("width",H.toString()),$.setAttribute("height",ht.toString()),$.setAttribute("fill","none"),$.setAttribute("stroke",W),$.setAttribute("stroke-width",y.toString()),$.setAttribute("stroke-opacity","0.5"),$.setAttribute("stroke-dasharray",`${y*2} ${y*2}`),this._intervalStroke($,y,[y*2,y*2]),N&&!$.parentElement&&N.insertBefore($,N.firstChild)})):this._removeIntervals(this._outlierRects)}else[this._ciRects,this._outlierRects,this._ciCross].forEach(N=>this._removeIntervals(N));if(et){this._pointLabels.forEach((y,P)=>{I.__data__.objects.get(P)||(y.remove(),this._pointLabels.delete(P))}),this._meanLabels.forEach((y,P)=>{I.__data__.objects.get(`mean-${P}`)||(y.remove(),this._meanLabels.delete(P))}),gt!==0?s.points.rows().forEach(y=>{const P=y.names.indexOf(r),v=P>=0?String(y[P]):null;if(!v)return;const E=I.__data__.objects.get(v);E&&this._syncLabel(this._pointLabels,v,qe(null,v),E,et,gt,o.labelWeightPoints)}):this._clearLabels(this._pointLabels);const N=new Map(L.map(y=>[y.rowName??String(y[0]),y]));(k?[...N.keys()]:Object.keys(Q)).forEach(y=>{const P=`mean-${y}`,v=I.__data__.objects.get(P);v&&this._syncLabel(this._meanLabels,y,qe(N.get(y),y),v,et,dt,o.labelWeightMeans)})}I.__data__.__state__.setVariable("layer_updated",I.__data__)}}else{const I=this.__children__.search("__children__","points");I==null||I.__data__.__state__.setVariable("layer_updated",I.__data__)}const Nt=this.__children__.search("__children__","trajectories");if(o.showTrajectories&&Nt){Nt.__data__.objects.clear(),this.__data__.trajectories.clear();const I=(li=s.trajectories)!=null&&li.rows?s.trajectories:s.points;if(I!=null&&I.rows){const k={},L=o.trajectoryUnits?o.trajectoryUnits.split(",").map(S=>S.trim()):null;I.rows().forEach(S=>{const y=S.names.indexOf(r)>=0?S.names.indexOf(r):S.names.indexOf("unit")>=0?S.names.indexOf("unit"):S.names.indexOf("ENA_UNIT")>=0?S.names.indexOf("ENA_UNIT"):-1,P=y>=0?String(S[y]):S.rowName||"unit-1";if(L&&!L.includes(P))return;const v=S.names.indexOf(n[0]),E=n.length>1?S.names.indexOf(n[1]):-1,D=S.names.indexOf("time")>=0?S.names.indexOf("time"):S.names.indexOf("ActivityNumber")>=0?S.names.indexOf("ActivityNumber"):S.names.indexOf("RowID")>=0?S.names.indexOf("RowID"):-1,W=D>=0?Number(S[D]):k[P]?k[P].length+1:1;v>=0&&E>=0&&(k[P]||(k[P]=[]),k[P].push({x:Number(S[v])*z,y:-Number(S[E])*z,time:W}))}),Object.keys(k).forEach((S,y)=>{const P=k[S];if(P.length===0)return;const v=g[y%g.length],E=new ce({ID:`traj-${S}`,unitId:S,color:new tt(v),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:P.map(D=>({x:D.x,y:D.y,time:D.time}))});this.__data__.trajectories.set(S,E),Nt.__data__.objects.set(E.ID,E)})}Nt.__data__.__state__.setVariable("layer_updated",Nt.__data__)}const kt=this.__children__.search("__children__","network"),es=kt==null?void 0:kt.__children__.search("__children__","edges"),rt=kt==null?void 0:kt.__children__.search("__children__","nodes"),Hs=kt==null?void 0:kt.__children__.search("__children__","edgenodes"),Bi=o.showEdges;if((ci=s.nodes)!=null&&ci.rows&&rt){if(s.nodes.rows().forEach(k=>{const L=mt(k,a,"#444444");L.size=2;const N=k.names.indexOf("label"),S=N>=0?k[N]:null,y=k.names.indexOf("size"),P=y>=0&&k[y]!=null&&k[y]!==""?Number(k[y]):NaN;L.meta={...L.meta??{},kind:"node",name:S!=null&&String(S)!=="NA"&&String(S)!==""?String(S):L.ID,sizePx:Number.isFinite(P)&&P>0?P:void 0,zoomFixed:o.nodeFixedSize||void 0},rt.__data__.objects.set(L.ID,L)}),Bi&&es){const k={};h&&((_i=s.points)!=null&&_i.rows)&&s.points.rows().forEach(x=>{const A=x.names.indexOf(r),C=x.names.indexOf(h);A>=0&&C>=0&&(k[String(x[A])]=String(x[C]))});const L=s.nodes.rows().map(x=>{const A=x.names.indexOf(a);return A>=0?String(x[A]):""}).filter(Boolean),N=c(x=>{const A=[];return x.forEach(C=>{const M=Ri(C,L);M&&A.push({col:C,pair:M})}),A},"parsePairs"),S=(ui=s.edges)!=null&&ui.rows?s.edges.rows():[],y=s.networks,P=N(((di=s.edges)==null?void 0:di.names)??[]),v=N((y==null?void 0:y.names)??[]),E=c(x=>{const A={};return S.forEach(C=>{const M=C.names.indexOf(r);M<0||String(C[M])!==x||P.forEach(({col:F})=>{const Z=C.names.indexOf(F);Z>=0&&(A[F]=Number(C[Z])||0)})}),A},"getUnitEdges"),D=c(x=>{const A={};let C=0;if(S.forEach(F=>{const Z=F.names.indexOf(r),ft=Z>=0?String(F[Z]):null,bt=h?F.names.indexOf(h):-1;(bt>=0?String(F[bt]):ft?k[ft]:null)===x&&(C++,P.forEach(({col:At})=>{const yt=F.names.indexOf(At);if(yt>=0){const K=Number(F[yt]);isNaN(K)||(A[At]=(A[At]??0)+K)}}))}),C===0)return{};const M={};return P.forEach(({col:F})=>{M[F]=(A[F]??0)/C}),M},"getGroupEdges"),W=c(x=>{if(_[x])return{weights:D(x),color:_[x],label:x};const A=k[x]??null,C=A?_[A]??"#888888":"#888888";return{weights:E(x),color:C,label:x}},"resolve"),G=[],V=c(x=>{var M;const A=(M=y==null?void 0:y.rows)==null?void 0:M.call(y).find(F=>F.rowName===x);if(!A)return null;const C={};return v.forEach(({col:F})=>{const Z=A.names.indexOf(F);if(Z>=0){const ft=Number(A[Z]);Number.isFinite(ft)&&(C[F]=ft)}}),C},"networkRow"),vt=c((x,A)=>{if(!A)return x;const C=Math.abs(x);return C<A[0]?0:C>A[1]?Math.sign(x)*A[1]:x},"thresholded");o.edgeLayers.forEach((x,A)=>{const C=c((K,lt,st,Et,ct)=>{st=vt(st,x.threshold),!(Math.abs(st)<1e-6)&&G.push({col:`${A}:${K}`,pair:lt,weight:Math.abs(st),color:Et,layer:A,...ct})},"push"),M=c((K,lt)=>x.colors?[x.colors[0],x.colors[1]??ji(x.colors[0])]:[K,lt],"signColors");if(x.network){const K=V(x.network);if(!K)return;const[lt,st]=M(g[0],g[1]),Et={name:x.name??x.network};v.forEach(({col:ct,pair:gi})=>{const Pe=K[ct]??0;C(ct,gi,Pe,Pe>=0?lt:st,Et)});return}const F=x.unit??x.group??null;if(!F)return;const Z=W(F),ft=x.compare??x.also??null,bt=ft?W(ft):null,Ct={name:x.name??F,group:x.group??void 0,unit:x.unit??void 0},[At,yt]=M(Z.color,(bt==null?void 0:bt.color)??Z.color);bt&&x.compare?P.forEach(({col:K,pair:lt})=>{const st=(Z.weights[K]??0)-(bt.weights[K]??0);C(K,lt,st,st>0?At:yt,Ct)}):bt&&x.also?P.forEach(({col:K,pair:lt})=>{const st=Z.weights[K]??0,Et=bt.weights[K]??0;st>0&&C(K+"-a",lt,st,At,Ct),Et>0&&C(K+"-b",lt,Et,yt,{...Ct,name:x.also??void 0,group:x.also??void 0})}):P.forEach(({col:K,pair:lt})=>{const st=Z.weights[K]??0;st>0&&C(K,lt,st,At,Ct)})}),G.sort((x,A)=>A.weight-x.weight);const H=!!s.directed,ht=zi(o.edgeWidth)*(o.edgeMagnify??1),$=c(x=>{const A=x.map(Math.abs).filter(C=>C>0);return A.length?[Math.min(...A),Math.max(...A)]:[0,0]},"rangeOf"),[ie,pt]=S.length?[P,s.edges]:[v,y],zt=c(x=>{const A=[];return ie.forEach(({col:C,pair:M})=>{if(M[0]===M[1]!==x)return;const F=pt==null?void 0:pt.col(C);if(F)for(const Z of F)A.push(Number(Z))}),$(A)},"modelRange"),Bt=c(x=>$(G.filter(A=>A.pair[0]===A.pair[1]===x).map(A=>A.weight)),"plotRange"),Oe=o.edgeColorScale,B=c(x=>Oe==="plot"?Bt(x):zt(x),"colourRange"),ot=B(!1),ne=B(!0),ss=c((x,A)=>{if(Oe==="absolute"){const F=Math.min(1,Math.abs(x));return{saturation:F,opacity:F}}const[C,M]=A?ne:ot;return{saturation:Bs(x,C,M,Ai),opacity:Bs(x,C,M,Si)}},"colourOf"),re={};G.forEach(({pair:x,weight:A})=>{if(x[0]===x[1]&&!H)return;const M=c(F=>{re[F]=(re[F]??0)+Math.abs(A)},"add");if(H){M(x[1]);return}M(x[0]),M(x[1])}),s.nodes.rows().forEach(x=>{var ft;const A=x.names.indexOf(a),C=A>=0?String(x[A]):"";if(!C)return;const M=rt.__data__.objects.get(C);if(!M)return;const F=re[C]??0,Z=!(F>0);M.size=Z?o.hideUnconnectedNodes?0:ki:Ci(F,ht),M.meta={...M.meta??{},hidden:Z&&o.hideUnconnectedNodes,sizePx:Z||(ft=M.meta)==null?void 0:ft.sizePx}});const Ut={},Y=c((x,A,C,M)=>`${x}:${A??""}:${C}.${M}`,"pairKey");H&&G.forEach(({pair:x,weight:A,layer:C,name:M})=>{const F=Y(C,M,x[0],x[1]);Ut[F]=(Ut[F]??0)+A}),G.forEach(({col:x,pair:A,weight:C,color:M,layer:F,name:Z,group:ft,unit:bt})=>{var Pe,mi;const Ct=rt.__data__.objects.get(A[0]),At=rt.__data__.objects.get(A[1]);if(!Ct||!At)return;const yt=A[0]===A[1];if(yt&&!H)return;const{saturation:K,opacity:lt}=ss(C,yt),st=new J({ID:`${A[0]}-src`,dimensions:[Ct.x,Ct.y],meta:{}}),Et=new J({ID:`${A[1]}-dst`,dimensions:[At.x,At.y],meta:{}});let ct;if(yt)ct=new Vt({},st,Et),ct.weight=0;else if(H){const Ui=Ut[Y(F,Z,A[0],A[1])]??C,Xi=Ut[Y(F,Z,A[1],A[0])]??0,Wi=Ui+Xi;ct=new cs({weight:C,totalweight:Wi},st,Et)}else ct=new Ht({},st,Et);ct.ID=`edge-${x}`,ct.color=new tt(M),ct.meta={isMeanEdge:!0,weight:C,widthFrac:ht,saturation:K,opacity:lt,isDirected:H,isSelf:yt,source:A[0],target:A[1],group:ft,unit:bt,layer:Z,selfSize:yt?((Pe=o.edgeLayers[F])==null?void 0:Pe.selfSize)??void 0:void 0,fixedSize:((mi=o.edgeLayers[F])==null?void 0:mi.fixedSize)||void 0},(yt?Hs??es:es).__data__.objects.set(ct.ID,ct)})}const I=o.showNodes;rt.svg_element&&(rt.svg_element.style.display=I?"":"none"),I||this._clearLabels(this._nodeLabels),et&&I&&(this._nodeLabels.forEach((k,L)=>{rt.__data__.objects.get(L)||(k.remove(),this._nodeLabels.delete(L))}),s.nodes.rows().forEach(k=>{var y,P,v;const L=k.names.indexOf(a),N=L>=0?String(k[L]):"";if(!N)return;const S=rt.__data__.objects.get(N);if(S){if((y=S.meta)!=null&&y.hidden){(P=this._nodeLabels.get(N))==null||P.remove(),this._nodeLabels.delete(N);return}this._syncLabel(this._nodeLabels,N,qe(k,String(((v=S.meta)==null?void 0:v.name)??N)),S,et,j,o.labelWeightNodes)}})),rt.__data__.__state__.setVariable("layer_updated",rt.__data__)}else rt==null||rt.__data__.__state__.setVariable("layer_updated",rt.__data__);[es,Hs].forEach(I=>I==null?void 0:I.__data__.__state__.setVariable("layer_updated",I.__data__));const Vs=this.__children__.search("__children__","axis_points"),Zs=this.__children__.search("__children__","axis_lines");Vs&&this.__data__.__state__.setVariable("graph_updated_axis_points",Vs.__data__.objects),Zs&&this.__data__.__state__.setVariable("graph_updated_axis_lines",Zs.__data__.objects),this.update(),i&&this._startTween(i)})}static get observedAttributes(){return["width","height","for","scale-points","point-scale","center","view-padding","labels","label-nodes","label-means","label-points"]}get vizena(){return this._vizena}_viewPadding(){const t=Number(this.getAttribute("view-padding"));return this.hasAttribute("view-padding")&&Number.isFinite(t)&&t>0?t:1.2}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}_syncLabel(t,e,s,i,n,r,a){let h=t.get(e);const o=s.text!=null&&(r!==q.DISPLAY_TYPES.OFF||s.pinned);h&&(!o||h.text!==s.text||h.displayMode!==r)&&(h.remove(),t.delete(e),h=void 0),o&&(h?(h.setPoint(i),r===q.DISPLAY_TYPES.ON&&h.show()):(h=new _s(s.text,i,n,this,r),t.set(e,h)),s.offset&&h.setOffset(s.offset.x,s.offset.y),h.fontWeight=a,h.setHostPinned(s.pinned))}_nodeRadius(t){const e=this.__children__.search("__children__","nodes"),s=e==null?void 0:e.__children__.find(i=>{var n;return((n=i.__data__)==null?void 0:n.ID)===t});return s?s.computeRadius():null}_intervalStroke(t,e,s){this._intervalBase.set(t,{w:e,dash:s}),this._applyIntervalStroke(t)}_applyIntervalStroke(t){const e=this._intervalBase.get(t);if(!e)return;const s=this._meansFixedSize&&this.zoom_level||1;t.setAttribute("stroke-width",String(e.w/s)),e.dash&&t.setAttribute("stroke-dasharray",e.dash.map(i=>i/s).join(" "))}_removeIntervals(t){t.forEach(e=>e.remove()),t.clear()}_clearLabels(t){t.forEach(e=>e.remove()),t.clear()}_scheduleRerender(){!this._vizena||!this._hasModel||this._renderPending||(this._renderPending=!0,queueMicrotask(()=>{var t;this._renderPending&&(this._renderPending=!1,(t=this._vizena)==null||t.dispatchEvent(new CustomEvent("model-updated",{detail:this._vizena.model,bubbles:!0,composed:!0})))}))}_readLayerConfig(){var p;const t=this.querySelector("qe-nodes"),e=this.querySelector("qe-means"),s=[...this.querySelectorAll("qe-points")],i=s.find(u=>!u.hasAttribute("set"))??null,n=s.filter(u=>u.hasAttribute("set")),r=[...this.querySelectorAll("qe-edges")],a=c(u=>{var d;return((d=r.find(l=>l.hasAttribute(u)))==null?void 0:d.getAttribute(u))??null},"firstAttr"),h=r.find(u=>u.hasAttribute("magnify")),o=this.querySelector("qe-trajectories"),_=this.querySelector("qe-axes"),g=this.getAttribute("labels");return{labelNodes:Ge((t==null?void 0:t.getAttribute("label"))??this.getAttribute("label-nodes")??g,q.DISPLAY_TYPES.ON),labelWeightNodes:(t==null?void 0:t.getAttribute("label-font-weight"))||null,nodeFixedSize:!!t&&t.hasAttribute("fixed-size"),showNodes:!!t,range:(()=>{const u=this.getAttribute("range");if(u==="network"||u==="points")return u;const d=Number(u);return u!=null&&Number.isFinite(d)&&d>0?d:null})(),plotTitle:this.getAttribute("plot-title")||null,labelFont:{size:(()=>{const u=Number(this.getAttribute("label-font-size"));return Number.isFinite(u)&&u>0?u:null})(),family:this.getAttribute("label-font-family")||null,color:this.getAttribute("label-font-color")||null},edgeWidth:(()=>{const u=Number(this.getAttribute("edge-width"));return Number.isFinite(u)&&u>0&&u<=1?u:vi})(),hideUnconnectedNodes:((p=t==null?void 0:t.getAttribute("unconnected"))==null?void 0:p.toLowerCase())==="hide",scalePoints:this.getAttribute("scale-points")!=="false",pointScale:(()=>{const u=Number(this.getAttribute("point-scale"));return this.hasAttribute("point-scale")&&Number.isFinite(u)&&u>0?u:null})(),centerContent:this.getAttribute("center")==="content",showMeans:!!e,activeMeanGroups:(e==null?void 0:e.getAttribute("groups"))??null,showCI:!!e&&e.hasAttribute("confidence"),intervals:(()=>{const u=e==null?void 0:e.getAttribute("intervals");return u==="box"||u==="crosshairs"||u==="none"?u:e!=null&&e.hasAttribute("confidence")?"box":"none"})(),showOutlier:!!e&&e.hasAttribute("outlier"),labelMeans:Ge((e==null?void 0:e.getAttribute("label"))??this.getAttribute("label-means")??g,q.DISPLAY_TYPES.ON),labelWeightMeans:(e==null?void 0:e.getAttribute("label-font-weight"))||null,meanFixedSize:!!e&&e.hasAttribute("fixed-size"),showPoints:!!i,pointSets:n.map(u=>({set:u.getAttribute("set"),size:u.getAttribute("size")?parseFloat(u.getAttribute("size")):null,fixedSize:u.hasAttribute("fixed-size"),labelMode:Ge(u.getAttribute("label")??this.getAttribute("label-points")??g,q.DISPLAY_TYPES.OFF),labelWeight:u.getAttribute("label-font-weight")||null})),labelPoints:Ge((i==null?void 0:i.getAttribute("label"))??this.getAttribute("label-points")??g,q.DISPLAY_TYPES.OFF),labelWeightPoints:(i==null?void 0:i.getAttribute("label-font-weight"))||null,pointSize:i!=null&&i.getAttribute("size")?parseFloat(i.getAttribute("size")):null,pointFixedSize:!!i&&i.hasAttribute("fixed-size"),showEdges:r.length>0,edgeLayers:r.map(Di),edgeColorScale:Yi(a("color-scale")),edgeMagnify:h?(()=>{const u=Number(h.getAttribute("magnify"));return Number.isFinite(u)&&u>0?u: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:!!_,axesFixedSize:!!_&&_.hasAttribute("fixed-size"),axisXLabel:_!=null&&_.hasAttribute("x")?_.getAttribute("x")??"":null,axisYLabel:_!=null&&_.hasAttribute("y")?_.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),it._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","view-padding","plot-title","label-font-size","label-font-family","label-font-color","label-font-weight","label-nodes","label-means","label-points","self-size","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;this._stopTween(),(t=this._childObserver)==null||t.disconnect(),this._childObserver=null,(e=this._resizeObs)==null||e.disconnect(),this._resizeObs=null,it._instances.delete(this),(s=this._tooltipEl)==null||s.remove(),this._tooltipEl=null}static instances(){return[...it._instances]}static getGraph(t){for(const e of it._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=c(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)}_zoomLimits(){const t=c(e=>{const s=Number(this.getAttribute(e));return this.hasAttribute(e)&&Number.isFinite(s)&&s>0?s:null},"num");return[t("zoom-min")??0,t("zoom-max")??1/0]}_clampZoom(t){const[e,s]=this._zoomLimits();return Math.min(s,Math.max(e,t))}_zoomStep(){const t=Number(this.getAttribute("zoom-step"));return this.hasAttribute("zoom-step")&&Number.isFinite(t)&&t>0?t:1.1}_clientToRoot(t,e){var n,r;const s=(r=(n=this.svg_element).getScreenCTM)==null?void 0:r.call(n);if(!s)return null;const i=new DOMPoint(t,e).matrixTransform(s.inverse());return[i.x,i.y]}_zoomAbout(t,e,s){if(!(Number.isFinite(t)&&t>0))return;t=this._clampZoom(t);const i=this.__data__.transform,n=t/(this.zoom_level||1);i.e=e-n*(e-i.e),i.f=s-n*(s-i.f),i.zoom(t),this.zoom_level=t,this.update()}_stopZoomAnim(){this._zoomAnim!==null&&cancelAnimationFrame(this._zoomAnim),this._zoomAnim=null}_animateZoomAbout(t,e,s,i){this._stopZoomAnim();const n=this.zoom_level||1,r=this._clampZoom(t);if(r===n)return;const a=performance.now(),h=c(o=>{const _=Math.min(1,Math.max(0,(o-a)/i));this._zoomAbout(_>=1?r:n*Math.pow(r/n,1-Math.pow(1-_,3)),e,s),this._zoomAnim=_<1?requestAnimationFrame(h):null},"step");this._zoomAnim=requestAnimationFrame(h)}zoomTo(t){this._stopZoomAnim();const{cx:e,cy:s}=this.__data__.extremes;this._zoomAbout(t,e,s)}zoomBy(t){Number.isFinite(t)&&t>0&&this.zoomTo((this.zoom_level||1)*t)}resetView(){this._stopZoomAnim();const t=this._clampZoom(1),{cx:e,cy:s}=this.__data__.extremes;this.zoom_level=t,this.__data__.transform.values=t===1?[1,0,0,1,0,0]:[t,0,0,t,e*(1-t),s*(1-t)],this.update()}static _ease(t){return t<.5?2*t*t:1-Math.pow(-2*t+2,2)/2}static _setXY(t,e,s){t.x=e,t.y=s,t.dimensions&&(t.dimensions[0]=e,t.dimensions[1]=s)}_layerObjects(t){var e;return(e=this.__children__.search("__children__",t))==null?void 0:e.__data__.objects}_intervalMarks(){return[...this._ciRects.values(),...this._outlierRects.values(),...this._ciCross.values()]}_boxGeom(t){return t.tagName.toLowerCase()==="rect"?["x","y","width","height"].map(e=>parseFloat(t.getAttribute(e)||"0")):((t.getAttribute("d")||"").match(it._PATH_NUM_RE)||[]).map(Number)}_captureTweenState(){var n;const t=new Map;for(const r of["points","nodes"])(n=this._layerObjects(r))==null||n.forEach((a,h)=>t.set(`${r}:${h}`,[a.x,a.y]));const e=new Map;this._intervalMarks().forEach(r=>e.set(r,this._boxGeom(r)));const s=this.__data__.extremes,i=this._tween;return{marks:t,boxes:e,view:[s.x_max,s.y_max,s.cx,s.cy],running:i?{t0:i.t0,k:i.k,marks:new Map(i.marks.map(r=>[r.key,[r.tx,r.ty]])),boxes:new Map(i.boxes.map(r=>[r.el,r.to])),view:i.view.to}:null}}_stopTween(){this._tweenRaf!==null&&cancelAnimationFrame(this._tweenRaf),this._tweenRaf=null,this._tween=null,this._tweenView=null}_startTween(t){var b;const e=performance.now(),s=c((f,w)=>!!w&&f.length===w.length&&f.every((T,z)=>T===w[z]),"same"),i=[];for(const f of["points","nodes"])(b=this._layerObjects(f))==null||b.forEach((w,T)=>{const z=`${f}:${T}`,j=t.marks.get(z);j&&i.push({key:z,o:w,tx:w.x,ty:w.y,cx:j[0],cy:j[1]})});const n=this._intervalMarks().map(f=>({el:f,to:this._boxGeom(f),cur:t.boxes.get(f)})).filter(f=>f.cur&&f.cur.length===f.to.length),r=this.__data__.extremes,a=[r.x_max,r.y_max,r.cx,r.cy],h=t.running,o=!!h&&h.k<.95&&s(a,h.view)&&i.every(f=>s([f.tx,f.ty],h.marks.get(f.key)??[f.cx,f.cy]))&&n.every(f=>s(f.to,h.boxes.get(f.el)??f.cur)),_=o?h.k:0,g=c((f,w)=>_>0?(f-_*w)/(1-_):f,"from"),p=i.map(f=>({key:f.key,o:f.o,tx:f.tx,ty:f.ty,fx:g(f.cx,f.tx),fy:g(f.cy,f.ty)})).filter(f=>f.fx!==f.tx||f.fy!==f.ty),u=n.map(f=>({el:f.el,to:f.to,from:f.cur.map((w,T)=>g(w,f.to[T])),attrs:Object.fromEntries(["x","y","width","height","d"].filter(w=>f.el.hasAttribute(w)).map(w=>[w,f.el.getAttribute(w)]))})).filter(f=>!s(f.from,f.to)),d=t.view.map((f,w)=>g(f,a[w]));if(!p.length&&!u.length&&s(d,a))return;this._tween={t0:o?h.t0:e,dur:this._animateMs,k:_,marks:p,boxes:u,view:{from:d,to:a}},this._tweenFrame(_);const l=c(f=>{const w=this._tween;if(!w)return;const T=(f-w.t0)/w.dur;if(T>=1){this._endTween();return}this._tweenFrame(Math.max(w.k,it._ease(Math.max(0,T)))),this._tweenRaf=requestAnimationFrame(l)},"step");this._tweenRaf=requestAnimationFrame(l)}_tweenFrame(t){const e=this._tween;if(!e)return;e.k=t;const s=c((i,n)=>i+(n-i)*t,"lerp");e.marks.forEach(i=>it._setXY(i.o,s(i.fx,i.tx),s(i.fy,i.ty))),this._attachEdges(),e.boxes.forEach(i=>{const n=i.from.map((r,a)=>s(r,i.to[a]));if("d"in i.attrs){let r=0;i.el.setAttribute("d",i.attrs.d.replace(it._PATH_NUM_RE,()=>String(n[r++])))}else["x","y","width","height"].forEach((r,a)=>i.el.setAttribute(r,String(n[a])))}),this._tweenView=e.view.from.map((i,n)=>s(i,e.view.to[n])),this.update()}_endTween(){const t=this._tween;t&&(t.marks.forEach(e=>it._setXY(e.o,e.tx,e.ty)),this._attachEdges(),t.boxes.forEach(e=>Object.entries(e.attrs).forEach(([s,i])=>e.el.setAttribute(s,i))),this._stopTween(),this.update())}_attachEdges(){var e;const t=this._layerObjects("nodes");if(t)for(const s of["edges","edgenodes"])(e=this._layerObjects(s))==null||e.forEach(i=>{var a,h;const n=t.get((a=i.meta)==null?void 0:a.source),r=t.get((h=i.meta)==null?void 0:h.target);n&&i.from&&it._setXY(i.from,n.x,n.y),r&&i.to&&it._setXY(i.to,r.x,r.y)})}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),_=new Image;_.onload=()=>{try{const g=document.createElement("canvas");g.width=i*t,g.height=n*t;const p=g.getContext("2d");if(!p){URL.revokeObjectURL(o),a(new Error("no 2d context"));return}p.scale(t,t),p.drawImage(_,0,0,i,n),URL.revokeObjectURL(o),r(g.toDataURL("image/png"))}catch(g){URL.revokeObjectURL(o),a(g)}},_.onerror=g=>{URL.revokeObjectURL(o),a(g)},_.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(){var _;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"));const t=this._highlight.edges.size>0||this._highlight.nodes.size>0,e=(_=this.__children__[0])==null?void 0:_.svg_element;(t&&e?e:this.svg_element).appendChild(this._highlightGroup);const s=this._highlightGroup;s.textContent="";const i=this.__data__.extremes.x_max||1,n="#f5a623",r=this.zoom_level||1,a=this._edgesFixedSize?r:1,h=c(g=>{var d;const p=c(l=>{var b;return(b=this.__children__.search("__children__",l))==null?void 0:b.__data__.objects.get(g)},"find"),u=(d=p("nodes")??p("points"))==null?void 0:d.meta;return u!=null&&u.zoomFixed||u!=null&&u.fixedSize?r:1},"markK"),o=c((g,p)=>{const u=document.createElementNS("http://www.w3.org/2000/svg",g);for(const d in p)u.setAttribute(d,String(p[d]));return u},"mk");if(this._highlight.edges.size){const g={};this.getNodes().forEach(p=>{g[p.id]={x:p.x,y:p.y}}),this._highlight.edges.forEach(p=>{const[u,d]=p.split("\0"),l=g[u],b=g[d];!l||!b||s.appendChild(o("line",{x1:l.x,y1:l.y,x2:b.x,y2:b.y,stroke:n,"stroke-width":i*.02/a,"stroke-opacity":.6,"stroke-linecap":"round"}))})}this._highlight.nodes.forEach(g=>{var f;const p=this.svg_element.querySelector(`[data-point-id="${(f=window.CSS)!=null&&f.escape?CSS.escape(g):g}"]`);if(!p)return;const u=p.tagName.toLowerCase();let d,l,b;if(u==="rect"){const w=parseFloat(p.getAttribute("width")||"0");d=parseFloat(p.getAttribute("x")||"0")+w/2,l=parseFloat(p.getAttribute("y")||"0")+parseFloat(p.getAttribute("height")||"0")/2,b=w/2}else d=parseFloat(p.getAttribute("cx")||"0"),l=parseFloat(p.getAttribute("cy")||"0"),b=parseFloat(p.getAttribute("r")||"0");s.appendChild(o("circle",{cx:d,cy:l,r:b*1.7+i*.004/h(g),fill:"none",stroke:n,"stroke-width":i*.006/h(g)}))})}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=c((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 Ws.forEach(r=>n(`qe-arrow-${r.slice(1)}`,r)),t.appendChild(e),this.__data__.layers.forEach(r=>{const a=new De(r,this.svg_element,this);this.__children__.push(a)}),this.__data__.__state__.setVariable("graph_updated",this.__data__),this.attach_events(),t}attach_events(){const t=c(()=>this.hasAttribute("view-locked"),"locked");this.svg_element.addEventListener("wheel",d=>{if(t())return;d.preventDefault();const l=d.deltaMode===1?33:d.deltaMode===2?this.svg_element.clientHeight||800:1,b=d.deltaY*l,f=d.ctrlKey?Math.exp(-b/100):Math.pow(this._zoomStep(),-b/100);this._stopZoomAnim();const w=this._clientToRoot(d.clientX,d.clientY);w?this._zoomAbout((this.zoom_level||1)*f,w[0],w[1]):this.zoomBy(f)},{passive:!1}),this.svg_element.addEventListener("dblclick",d=>{var b,f;if(t()||(f=(b=d.target)==null?void 0:b.closest)!=null&&f.call(b,"text[data-label-for]"))return;d.preventDefault();const l=this._clientToRoot(d.clientX,d.clientY);l&&this._animateZoomAbout((this.zoom_level||1)*2.2,l[0],l[1],200)});const e=new Map;let s=null;const i=c(()=>{const[d,l]=[...e.values()];return d?l?{mid:[(d[0]+l[0])/2,(d[1]+l[1])/2],dist:Math.hypot(d[0]-l[0],d[1]-l[1]),n:2}:{mid:d,dist:0,n:1}:null},"measure");this.svg_element.addEventListener("pointerdown",d=>{d.pointerType!=="touch"||t()||(e.set(d.pointerId,[d.clientX,d.clientY]),s=i(),this._stopZoomAnim())}),this.svg_element.addEventListener("pointermove",d=>{if(!e.has(d.pointerId))return;if(t()){e.clear(),s=null;return}e.set(d.pointerId,[d.clientX,d.clientY]);const l=i();if(l&&s&&l.n===s.n){const b=this._clientToRoot(...s.mid),f=this._clientToRoot(...l.mid);if(b&&f){const w=this.__data__.transform;w.pan(f[0]-b[0],f[1]-b[1]),l.n===2&&s.dist>0&&l.dist>0?this._zoomAbout((this.zoom_level||1)*l.dist/s.dist,f[0],f[1]):this.__children__[0].svg_element.setAttribute("transform",w.toString())}}s=l});const n=c(d=>{e.delete(d.pointerId)&&(s=i())},"touchEnd");this.svg_element.addEventListener("pointerup",n),this.svg_element.addEventListener("pointercancel",n);let r=!1,a=0,h=0;this.svg_element.addEventListener("mousedown",d=>{t()||(r=!0,a=d.clientX,h=d.clientY)});let o=null,_=null;const g=c(()=>{_&&(this.__data__.transform.pan(_.dx,_.dy),this.__children__[0].svg_element.setAttribute("transform",this.__data__.transform.toString()),_=null),o=null},"panUpdate");this.svg_element.addEventListener("mousemove",d=>{if(!r)return;if(d.buttons===0){r=!1;return}const l=this._clientToRoot(a,h),b=this._clientToRoot(d.clientX,d.clientY);a=d.clientX,h=d.clientY,!(!l||!b)&&(_={dx:((_==null?void 0:_.dx)??0)+b[0]-l[0],dy:((_==null?void 0:_.dy)??0)+b[1]-l[1]},o===null&&(o=requestAnimationFrame(g)))}),this.svg_element.addEventListener("mouseup",d=>{r=!1}),this.svg_element.addEventListener("point-clicked",(d=>{var f,w;const l=(w=(f=d.detail)==null?void 0:f.pointData)==null?void 0:w.ID;if(!l)return;const b=this._pointLabels.get(l)??this._setLabels.get(l)??this._meanLabels.get(l.replace("mean-",""))??this._nodeLabels.get(l);b&&b.displayMode===q.DISPLAY_TYPES.CLICK&&b.toggle()}));const p=c(d=>{var l;for(;d&&d!==this.svg_element;){const b=(l=d.getAttribute)==null?void 0:l.call(d,"data-point-id");if(b)return b;d=d.parentElement}return null},"findPointId"),u=c(d=>this._pointLabels.get(d)??this._setLabels.get(d)??this._meanLabels.get(d.replace(/^mean-/,""))??this._nodeLabels.get(d),"getAutoLabel");this.svg_element.addEventListener("mouseover",d=>{const l=p(d.target);if(!l)return;const b=u(l);(b==null?void 0:b.displayMode)===q.DISPLAY_TYPES.AUTO&&b.show()}),this.svg_element.addEventListener("mouseout",d=>{const l=p(d.target);if(!l)return;const b=d.relatedTarget;if(p(b)===l)return;const w=u(l);(w==null?void 0:w.displayMode)===q.DISPLAY_TYPES.AUTO&&w.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=c((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._ciRects,this._outlierRects,this._ciCross].forEach(t=>t.forEach(e=>this._applyIntervalStroke(e))),this.update_labels(),this.update_extremes(),this.update_axes(),this._applyHighlights()}update_axes(){var g,p;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=r/(this._axesFixedSize&&this.zoom_level||1),o=h*.6,_=c((u,d)=>{let l=this._axisLabelEls.get(u);if(!this._showAxes||d==null){l&&(l.remove(),this._axisLabelEls.delete(u));return}l||(l=document.createElementNS("http://www.w3.org/2000/svg","text"),l.setAttribute("data-axis-label",u),l.setAttribute("pointer-events","none"),e.appendChild(l),this._axisLabelEls.set(u,l)),l.textContent=d,l.setAttribute("font-size",h.toString()),l.setAttribute("font-family","system-ui, sans-serif"),l.setAttribute("font-weight","600"),l.setAttribute("fill","#556"),u==="x"?(l.setAttribute("x",(i+s-o).toString()),l.setAttribute("y",(-o).toString()),l.setAttribute("text-anchor","end")):(l.setAttribute("x",o.toString()),l.setAttribute("y",(n-s+h+o).toString()),l.setAttribute("text-anchor","start"))},"place");if(_("x",this._axisXText),_("y",this._axisYText),this._magnifyText==null)(g=this._magnifyEl)==null||g.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 u=this._magnifyEl;u.textContent=this._magnifyText,u.setAttribute("font-size",(r*.85).toString()),u.setAttribute("font-family","system-ui, sans-serif"),u.setAttribute("font-style","italic"),u.setAttribute("fill","#556"),u.setAttribute("x",(i-s+a).toString()),u.setAttribute("y",(n-s+r+a).toString()),u.setAttribute("text-anchor","start")}if(!this._plotTitle)(p=this._titleEl)==null||p.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 d=(this._labelFont.size??12)*1.35*this.unitsPerPixel(),l=this._titleEl;l.textContent=this._plotTitle,l.setAttribute("font-size",d.toString()),l.setAttribute("font-family",this._labelFont.family??"system-ui, sans-serif"),l.setAttribute("font-weight","600"),l.setAttribute("fill",this._labelFont.color??"#223"),l.setAttribute("x",i.toString()),l.setAttribute("y",(n-s+d*1.1).toString()),l.setAttribute("text-anchor","middle")}}update_labels(){this._nodeLabels.forEach(t=>t.update()),this._meanLabels.forEach(t=>t.update()),this._pointLabels.forEach(t=>t.update()),this._setLabels.forEach(t=>t.update())}update_extremes(){var s;const t=this.__data__;if(this._tweenView){const[i,n,r,a]=this._tweenView;t.extremes=new Lt(i,n,r,a)}else 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){Xt("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(this._viewPadding()));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()})}};c(it,"QEGraphElement"),it.tagName="qe-graph",it.style=`
18
+ `;let $e=Ue;const Rs=1e-8;function os(m,t=Rs){return m.filter(e=>Math.abs(e.x)>t||Math.abs(e.y)>t)}c(os,"nearOriginFilter");function $s(m){if(m<=0)return[];if(m===1)return[0];const t=new Array(m);for(let e=0;e<m;e++)t[e]=e/(m-1);return t}c($s,"normalizedT");function Ts(m,t){return m.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})}c(Ts,"design");function Fs(m){const t=m.length,e=m[0].length,s=m.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}}c(Fs,"qr");function as(m,t){const e=m.length,s=m[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+=m[a][n]*t[a];i[n]=r}return i}c(as,"qtY");function hs(m,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-=m[i][r]*s[r];s[i]=Math.abs(m[i][i])>1e-12?n/m[i][i]:0}return s}c(hs,"backSolve");function xi(m){return m.map(t=>{let e=0;for(let s=0;s<t.length;s++)e+=t[s]*t[s];return e})}c(xi,"leverages");function Ds(m,t,e){const s=Ts(m,e),{Q:i,R:n}=Fs(s);return hs(n,as(i,t))}c(Ds,"fitCoeffs");function Te(m,t){let e=0,s=1;for(let i=0;i<m.length;i++)e+=m[i]*s,s*=t;return e}c(Te,"evalPoly");function wi(m,t,e,s){const i=Ts(m,s),{Q:n,R:r}=Fs(i),a=xi(n),h=hs(r,as(n,t)),o=hs(r,as(n,e));let _=0;for(let g=0;g<m.length;g++){const p=1-a[g];if(p<=0)return 1/0;const u=t[g]-Te(h,m[g]),d=e[g]-Te(o,m[g]);_+=(u/p)**2+(d/p)**2}return _}c(wi,"loocv2d");function js(m,t,e){const s=m.length,i=Math.min(Math.max(1,Math.floor(t)),Math.max(1,s-1));if(e==="fixed"||s<3)return i;const n=$s(s),r=m.map(_=>_.x),a=m.map(_=>_.y);let h=1,o=1/0;for(let _=1;_<=i;_++){const g=wi(n,r,a,_);g<o&&(o=g,h=_)}return h}c(js,"selectDegree");function Ys(m,t){const e=os(m);if(e.length<3)return null;const s=t.selectionSet?os(t.selectionSet):e,i=s.length>=3?s:e;let n=js(i,t.maxDegree,t.degreeSelection);n=Math.min(n,Math.max(1,e.length-1));const r=$s(e.length),a=Ds(r,e.map(o=>o.x),n),h=Ds(r,e.map(o=>o.y),n);return{degree:n,coeffsX:a,coeffsY:h}}c(Ys,"fitTrajectory");function ls(m,t=100){const e=[];for(let s=0;s<=t;s++){const i=s/t;e.push({x:Te(m.coeffsX,i),y:Te(m.coeffsY,i)})}return e}c(ls,"sampleCurve");const qs=100,As=class As extends Pt{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 ls({degree:this.polyCoeffsX.length-1,coeffsX:this.polyCoeffsX,coeffsY:this.polyCoeffsY},qs);const e=Ys(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,ls(e,qs)}return t.map(e=>({x:e.x,y:e.y}))}};c(As,"Trajectory");let ce=As;const Gs=1,Ss=class Ss extends Ht{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 ae(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}};c(Ss,"Edge");let _e=Ss;const Es=class Es extends Pt{constructor(e){super(e.dimensions||[],e);nt(this,te);X(this,te,e)}get edge(){return R(this,te)}get path(){const e=R(this,te),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],_=Math.hypot(n[0]-s[0],n[1]-s[1]),g=[(n[0]-s[0])/_,(n[1]-s[1])/_],p=c(T=>h/2*Math.max(0,1-T/a),"halfW"),u=c((T,z)=>`${s[0]+o[0]*T+g[0]*z} ${s[1]+o[1]*T+g[1]*z}`,"at"),d=.2*a,l=Math.min(.15*a,.8*2*p(d)),b=d+l/2,f=d+l;return`M${u(d,0)} L${u(b,p(b))} L${u(f,p(f))} L${u(b,0)} L${u(f,-p(f))} L${u(b,-p(b))}z`}};te=new WeakMap,c(Es,"EdgeArrow");let Fe=Es;const Xe=class Xe extends _e{constructor(e,s,i){super(e,s,i);nt(this,ee);nt(this,ze);this._path="",X(this,ee,!1),this._directions=["from","to"],this.towards="to",R(this,ee)===!0&&X(this,ze,new Fe(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(b=>b!==e.towards),n=e[i].x,r=e[i].y,a=e[s].x,h=e[s].y,o=a-n,_=h-r,g=Math.hypot(o,_),p=(e.weight??0)*Gs;if(g===0||!isFinite(p)||p===0)return[[a,h],[a,h]];const u=-_/g,d=o/g,l=p/2;return[[a+u*l,h+d*l],[a-u*l,h-d*l]]}get base_pts(){return Xe.calculate_base_points(this)}get arrow(){return R(this,ze)}get with_arrow(){return R(this,ee)}get from_point(){return[this.from.x,this.from.y]}};ee=new WeakMap,ze=new WeakMap,c(Xe,"TaperedEdge");let jt=Xe;const We=class We extends jt{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 le.Geometry.Line.interpolate(this.line)(1-this._dataWeight/this._totalweight)}get base_pts(){return jt.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 We.build_path(this)}get from_point(){return this.weighted_midpoint}};c(We,"TaperedWeightedMidpointEdge");let cs=We;const He=class He extends _e{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*Gs;return He.build_path(t,this.to)}};c(He,"NodeEdge");let Vt=He;const Ms=class Ms{constructor(t,e,s,i=new Rt){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),_=i+(s-i)*o;t.setAttribute(e,_.toString()),o<1?requestAnimationFrame(a):t.setAttribute(e,s.toString())}c(a,"animate"),requestAnimationFrame(a)}};c(Ms,"Drawable");let ue=Ms;const vi=.04,Ai=[.25,1],Si=[.3,1];function Bs(m,t,e,s){const i=Math.abs(m);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])}c(Bs,"rampFor");const Ei=.011,Mi=.75,Ii=.8,Ni=.75,Us=.006,ki=.6;function zi(m){return 2*m}c(zi,"widthPerWeight");function Ci(m,t){return m*t/(2*Us)}c(Ci,"nodeSizeForEdges");function Oi(m){const t=/rgba?\(([^)]+)\)/.exec(m);if(!t)return m;const[e,s,i,n=1]=t[1].split(",").map(Number),r=c(a=>Math.round(255+(a-255)*n),"f");return`rgb(${r(e)},${r(s)},${r(i)})`}c(Oi,"flattenOnWhite");function Pi(m,t){const e=/rgba?\(([^)]+)\)/.exec(m);if(!e)return m;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})`}c(Pi,"darkenRgba");const Is=class Is extends ue{constructor(t,e,s,i=new Rt){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??{};if(!e.isMeanEdge)return;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");const s=c((i,n)=>n!=null&&n!==!1?t.setAttribute(i,n===!0?"true":String(n)):t.removeAttribute(i),"opt");s("data-edge-self",!!e.isSelf),s("data-edge-group",e.group),s("data-edge-unit",e.unit)}create(){if(this.__data__ instanceof Vt){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 jt){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}get drawsPath(){return this.__data__ instanceof Vt||this.__data__ instanceof jt}update(){var i,n,r,a;if(this.svg_element||this.create(),this.svg_element.tagName.toLowerCase()==="path"!==this.drawsPath){const h=this.svg_element;this.create(),h.parentElement&&h.replaceWith(this.svg_element)}this.drawsPath&&((i=this._hit_el)==null||i.remove(),this._hit_el=null),this.svg_element.parentElement||this.parent.appendChild(this.svg_element);const t=((n=this.graph.__data__.extremes)==null?void 0:n.x_max)??1,e=this.__data__.meta??{};let s=!1;if(e.isMeanEdge){this._stampEdge(this.svg_element);const h=typeof e.weight=="number"?e.weight:0,o=typeof e.maxWeight=="number"?e.maxWeight:1,_=typeof e.opacity=="number"?e.opacity:Math.min(1,h/(o||1)),g=t>0?t:1,p=e.fixedSize&&this.graph.zoom_level||1,u=(typeof e.widthFrac=="number"?g*e.widthFrac*h:g*Ei*(h/(o||1)))/p,d=this.__data__._color||new tt("#000000"),l=typeof e.saturation=="number"?e.saturation:_,b=new ae(d,l,_).toString();if(this.__data__ instanceof Vt){const f=typeof e.selfSize=="number"&&e.selfSize>0?e.selfSize:null,w=f!=null?(a=(r=this.graph)._nodeRadius)==null?void 0:a.call(r,String(e.source)):null;this.__data__.weight=typeof w=="number"?2*f*w:u,this.svg_element.setAttribute("d",this.__data__.path),this.svg_element.setAttribute("fill",b),this.svg_element.setAttribute("stroke","none")}else if(this.__data__ instanceof jt){if(this.__data__.weight=u,this.svg_element.setAttribute("d",this.__data__.path),this.svg_element.setAttribute("fill",b),this.svg_element.setAttribute("stroke",b),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 w=new Fe(this.__data__).path;w&&!w.includes("NaN")&&!w.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",w),this._arrow_el.setAttribute("fill",Pi(Oi(b),Ii)),this._arrow_el.setAttribute("stroke","#ffffff"),this._arrow_el.setAttribute("stroke-width",String(Ni)),this._arrow_el.setAttribute("vector-effect","non-scaling-stroke"),this._arrow_el.setAttribute("stroke-linejoin","round"),s=!0)}catch{}}else{const f=this.__data__.from.x,w=this.__data__.from.y,T=this.__data__.to.x,z=this.__data__.to.y;this.svg_element.setAttribute("x1",f.toString()),this.svg_element.setAttribute("y1",w.toString()),this.svg_element.setAttribute("x2",T.toString()),this.svg_element.setAttribute("y2",z.toString()),this.svg_element.setAttribute("stroke-width",u.toString()),this.svg_element.setAttribute("stroke",b),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",f.toString()),this._hit_el.setAttribute("y1",w.toString()),this._hit_el.setAttribute("x2",T.toString()),this._hit_el.setAttribute("y2",z.toString()),this._hit_el.setAttribute("stroke-width",Math.max(u,t*.03/p).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 h=this.graph._axesFixedSize&&String(this.__data__.ID).startsWith("axis-")&&this.graph.zoom_level||1,o=(t>0?t:1)*.004*this.get_size()/h;this.svg_element.setAttribute("stroke-width",o.toString()),this.svg_element.setAttribute("stroke-opacity","1"),this.svg_element.setAttribute("stroke",this.__data__.color.toString())}!s&&this._arrow_el&&(this._arrow_el.remove(),this._arrow_el=null)}remove(){var t,e,s;(t=this.svg_element)==null||t.remove(),(e=this._hit_el)==null||e.remove(),(s=this._arrow_el)==null||s.remove()}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))}};c(Is,"QELine");let St=Is;const Ns=class Ns extends ue{constructor(t,e,s,i=new Rt){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 e;const t=this.dataRadius();return(e=this.__data__.meta)!=null&&e.zoomFixed?t/(this.graph.zoom_level||1):t}dataRadius(){var i,n,r,a,h,o,_;const t=this.graph.__data__.extremes.x_max||1,e=((i=this.__data__.meta)==null?void 0:i.sizeScale)??1,s=(n=this.__data__.meta)==null?void 0:n.sizePx;if(typeof s=="number"&&s>0){const g=(a=(r=this.graph.svg_element)==null?void 0:r.getBoundingClientRect)==null?void 0:a.call(r),p=g&&g.width>0?2*t/g.width:t*.004;return s/2*p}if((h=this.__data__.meta)!=null&&h.fixedSize){const g=(_=(o=this.graph.svg_element)==null?void 0:o.getBoundingClientRect)==null?void 0:_.call(o),p=this.graph.zoom_level||1,u=g&&g.width>0?g.width/(2*t):1;return this.__data__.size*2*e/u/p}return t*Us*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()))}stampIdentity(t){t.setAttribute("data-point-id",this.__data__.ID);const e=this.__data__.meta??{},s=c((i,n)=>n!=null&&n!==""?t.setAttribute(i,String(n)):t.removeAttribute(i),"opt");s("data-kind",e.kind),s("data-name",e.name),s("data-group",e.group),s("data-unit",e.unit)}create(){const t=document.createElementNS("http://www.w3.org/2000/svg",this.tag);return this.stampIdentity(t),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 e=new CustomEvent("point-clicked",{detail:{pointData:this.__data__},bubbles:!0,composed:!0});this.svg_element.dispatchEvent(e)}),t.addEventListener("mouseover",()=>{}),t}update(){if(this.svg_element||this.parent.__data__.__children__.push(this.create()),this.svg_element.tagName.toLowerCase()!==this.tag){const t=this.svg_element;this.create(),t.parentElement&&t.replaceWith(this.svg_element)}this.svg_element.parentElement||this.parent.appendChild(this.svg_element),this.stampIdentity(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)}};c(Ns,"QEPoint");let Zt=Ns;const ks=class ks extends ue{constructor(t,e,s,i=new Rt){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 _=s[o],g=s[o+1],p=i<=1?1:o/(i-1),u=n+(r-n)*p,d=a+(h-a)*p,l=document.createElementNS("http://www.w3.org/2000/svg","path");l.setAttribute("d",`M${_.x},${_.y} L${g.x},${g.y}`),l.setAttribute("fill","none"),l.setAttribute("stroke",this.__data__.color.toString()),l.setAttribute("stroke-linecap","round"),l.setAttribute("stroke-linejoin","round"),l.setAttribute("stroke-width",this.graphUnitsForPixels(u).toString()),l.setAttribute("opacity",d.toString()),this._segments_group.appendChild(l)}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()}};c(ks,"QETrajectory");let de=ks;const{ArrayTools:Xs}=le,zs=class zs extends Array{constructor(...t){super(...t)}search(t,e){let s;function i(r){return r.name===e?r:void 0}c(i,"fn");function n(r,a,h=null){if(Xs.isArray(r)){for(const[o,_]of r.entries())if(s=n(_,o,h),s)return s}else{if(s=i(r),s)return s;if(r&&Xs.isArray(r[t])){for(const[o,_]of r[t].entries())if(s=n(_,o,r),s)return s}}return s}return c(n,"recurse"),n(this)}flatten(){return this.reduce((t,e)=>(t.push(e),e.layers&&Array.isArray(e.layers)&&t.push(...e.layers),t),[])}};c(zs,"QEArray");let Rt=zs;const Li={AxisPoint:Zt,AxisLine:St,Point:Zt,Line:St,Edge:St,TaperedEdge:St,TaperedWeightedMidpointEdge:St,NodeEdge:St,Trajectory:de},se=class se{constructor(t,e,s,i=new Rt){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=c(p=>{var u;return(u=p.__data__)==null?void 0:u.ID},"childId"),o=this.__children__.filter(p=>!r.objects.has(h(p))),_=this.__children__.filter(p=>r.objects.has(h(p)));[...r.objects.values()].filter(p=>!this.__children__.some(u=>h(u)===p.ID)).forEach(p=>{const u=p._typeName||p.constructor.name;let d=Li[u];d||(p instanceof ce?d=de:p instanceof J?d=Zt:d=St);const l=new d(p,this.svg_element,this.graph);this.__children__.push(l)}),_.forEach(p=>{const u=r.objects.get(h(p));u&&(p.__data__=u),p.update()}),o.forEach(p=>{var d;typeof p.remove=="function"?p.remove():(d=p.svg_element.parentElement)==null||d.removeChild(p.svg_element);const u=this.__children__.indexOf(p);u>=0&&this.__children__.splice(u,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",se.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 se(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)}};c(se,"QELayer"),se.tagName="g";let De=se;const Cs=class Cs{constructor(t,e,s,i,n=q.DISPLAY_TYPES.ON,r=q.POSITION.OBJECT,a,h){this.text=t,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._hostPinned=!1,this.fontWeight=null,this._point=e,this.svg_element=this._create(),n===q.DISPLAY_TYPES.ON?(this._visible=!0,this.svg_element.setAttribute("display","block")):(this._visible=!1,this.svg_element.setAttribute("display","none"))}get point(){return this._point}_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}setPoint(t){this._point=t,this.svg_element.setAttribute("data-label-for",t.ID)}setOffset(t,e){this._offsetX=Number.isFinite(t)?t:0,this._offsetY=Number.isFinite(e)?e:0}setHostPinned(t){t!==this._hostPinned&&(this._hostPinned=t,t?this.show():this.displayMode!==q.DISPLAY_TYPES.ON&&this.hide())}_attachDrag(t){t.addEventListener("mousedown",e=>{e.preventDefault(),e.stopPropagation(),this._drag(t,e.clientX,e.clientY,"mouse")}),t.addEventListener("pointerdown",e=>{e.pointerType==="touch"&&(e.preventDefault(),e.stopPropagation(),this._drag(t,e.clientX,e.clientY,e.pointerId))})}_drag(t,e,s,i){const n=t.parentNode??t.ownerSVGElement,r=t.ownerSVGElement;if(!r||!n)return;const a=c((u,d)=>{const l=r.createSVGPoint();l.x=u,l.y=d;const b=n.getScreenCTM();return b?l.matrixTransform(b.inverse()):{x:0,y:0}},"toUser"),h=a(e,s),o=this._offsetX,_=this._offsetY;t.style.cursor="grabbing";const g=c((u,d)=>{const l=a(u,d);this._offsetX=o+(l.x-h.x),this._offsetY=_+(l.y-h.y),this.pinned=!0,this._visible=!0,this.svg_element.setAttribute("display","block"),this.update()},"move"),p=c(()=>{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}))},"done");if(i==="mouse"){const u=c(l=>g(l.clientX,l.clientY),"onMove"),d=c(()=>{document.removeEventListener("mousemove",u),document.removeEventListener("mouseup",d),p()},"onUp");document.addEventListener("mousemove",u),document.addEventListener("mouseup",d)}else{const u=c(l=>{l.pointerId===i&&g(l.clientX,l.clientY)},"onMove"),d=c(l=>{l.pointerId===i&&(document.removeEventListener("pointermove",u),document.removeEventListener("pointerup",d),document.removeEventListener("pointercancel",d),p())},"onUp");document.addEventListener("pointermove",u),document.addEventListener("pointerup",d),document.addEventListener("pointercancel",d)}}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 q.POSITION.STATIC:{n=this.point.x,r=this.point.y-i*.3,a="middle";break}case q.POSITION.CONTAINER:{const{cx:o,cy:_}=this.graph.__data__.extremes,g=this.point.x-o,p=this.point.y-_,u=Math.sqrt(g*g+p*p)||1,d=t*.93/u;n=o+g*d,r=_+p*d-i*.3,a=g>=0?"start":"end";break}case q.POSITION.CUSTOM:if(this.customX!=null&&this.customY!=null){n=this.customX,r=this.customY,a="start";break}default:case q.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.removeAttribute("transform"),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",this.fontWeight??"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"),!this._offsetX&&!this._offsetY&&this.position!==q.POSITION.CUSTOM&&this.fitInside(n,r,a,i,s*.3)}visibleBounds(){var h;const t=this.svg_element,e=t.ownerSVGElement,s=(h=t.getScreenCTM)==null?void 0:h.call(t);if(!e||!s)return null;const i=e.getBoundingClientRect();if(!(i.width>0&&i.height>0))return null;const n=s.inverse(),r=new DOMPoint(i.left,i.top).matrixTransform(n),a=new DOMPoint(i.right,i.bottom).matrixTransform(n);return{left:Math.min(r.x,a.x),right:Math.max(r.x,a.x),top:Math.min(r.y,a.y),bottom:Math.max(r.y,a.y)}}bbox(){try{const t=this.svg_element.getBBox();return t.width>0?t:null}catch{return null}}fitInside(t,e,s,i,n){const r=this.visibleBounds();let a=this.bbox();if(!r||!a)return;const h=r.left+n,o=r.right-n,_=r.top+n,g=r.bottom-n,p=c(b=>Math.max(0,h-b.x)+Math.max(0,b.x+b.width-o),"over"),u=this.svg_element;if(p(a)>0&&this.position===q.POSITION.OBJECT&&s!=="middle"){const b=s==="end"?"start":"end",f=s==="end"?this.point.x+i:this.point.x-i;u.setAttribute("text-anchor",b),u.setAttribute("x",f.toString());const w=this.bbox();w&&p(w)<p(a)?(a=w,t=f):(u.setAttribute("text-anchor",s),u.setAttribute("x",t.toString()))}let d=0,l=0;a.x<h?d=h-a.x:a.x+a.width>o&&(d=Math.max(o-(a.x+a.width),h-a.x)),a.y<_?l=_-a.y:a.y+a.height>g&&(l=Math.max(g-(a.y+a.height),_-a.y)),d&&u.setAttribute("x",(t+d).toString()),l&&u.setAttribute("y",(e+l).toString())}show(){this._visible=!0,this.svg_element.setAttribute("display","block"),this.update()}hide(){this.pinned||this._hostPinned||(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()}};c(Cs,"QELabel");let _s=Cs;const Ve=class Ve extends HTMLElement{};c(Ve,"QENodesElement"),Ve.tagName="qe-nodes";let ge=Ve;const Ze=class Ze extends HTMLElement{};c(Ze,"QEMeansElement"),Ze.tagName="qe-means";let me=Ze;const Ke=class Ke extends HTMLElement{};c(Ke,"QEPointsElement"),Ke.tagName="qe-points";let fe=Ke;const Je=class Je extends HTMLElement{};c(Je,"QEEdgesElement"),Je.tagName="qe-edges";let pe=Je;const Qe=class Qe extends HTMLElement{};c(Qe,"QETrajectoriesElement"),Qe.tagName="qe-trajectories";let be=Qe;const ts=class ts extends HTMLElement{};c(ts,"QEAxesElement"),ts.tagName="qe-axes";let ye=ts;customElements.define(ge.tagName,ge),customElements.define(me.tagName,me),customElements.define(fe.tagName,fe),customElements.define(pe.tagName,pe),customElements.define(be.tagName,be),customElements.define(ye.tagName,ye);const Ws=["#4477AA","#EE6677","#228833","#CCBB44","#66CCEE","#AA3377","#BBBBBB","#000000"];function Ri(m,t){for(const e of t)if(m===`${e}.${e}`)return[e,e];for(const e of t)if(m.startsWith(e+".")){const s=m.slice(e.length+1);if(t.includes(s))return[e,s]}return null}c(Ri,"parseEdgePair");function $i(m,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,m)/e)*s,a=Math.sqrt(Math.max(0,t)/e)*s;return{halfW:n*r,halfH:n*a}}c($i,"computeCIRect");const Ti=.5;function je(m,t,e){if(!m)return;const s=Math.min(Math.abs(t),Math.abs(e));s>0&&(m.meta={...m.meta??{},maxRadius:s*Ti})}c(je,"capMeanToInterval");function Ye(m,t,e,s=""){const i=c(o=>{const _=m.names.indexOf(o),g=_>=0?m[_]:null;if(g==null||g==="")return;const p=Number(g);return Number.isFinite(p)?p: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}}c(Ye,"readIntervalBounds");function qe(m,t){const e=c(o=>{if(!m)return;const _=m.names.indexOf(o);return _>=0?m[_]:void 0},"raw"),s=c(o=>o==null||o==="NA"||typeof o=="number"&&Number.isNaN(o),"isNA"),i=e("label"),n=s(i)?t:String(i)===""?null:String(i),r=c(o=>{const _=e(o),g=s(_)||_===""?0:Number(_);return Number.isFinite(g)?g:0},"num"),a=!!m&&(m.names.includes("label.dx")||m.names.includes("label.dy")),h=e("label.pinned");return{text:n,offset:a?{x:r("label.dx"),y:r("label.dy")}:null,pinned:h===!0||h===1||String(h).toLowerCase()==="true"}}c(qe,"readLabelSpec");function Fi(m){const t=m==null?void 0:m.trim().toLowerCase();if(!t)return null;if(t==="node")return .5;const e=Number(t);return Number.isFinite(e)&&e>0?e:null}c(Fi,"parseSelfSize");function Di(m){var i,n;const t=c(r=>m.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"),selfSize:Fi(t("self-size")),fixedSize:m.hasAttribute("fixed-size")}}c(Di,"parseEdgeLayer");function ji(m){const{r:t,g:e,b:s}=tt.parseColor(m),i=Math.max(t,e,s),n=Math.min(t,e,s),r=c(a=>(i+n-a).toString(16).padStart(2,"0"),"f");return`#${r(t)}${r(e)}${r(s)}`}c(ji,"complementColor");function Yi(m){const t=m==null?void 0:m.trim().toLowerCase();return t==="plot"||t==="absolute"?t:"model"}c(Yi,"parseColorScale");function Ge(m,t){switch(m==null?void 0:m.toLowerCase()){case"on":return 3;case"off":return 0;case"click":return 2;case"auto":return 1;default:return t}}c(Ge,"parseLabelMode");const it=class it extends $e{constructor(){super(),this.zoom_level=1,this.__children__=new Rt,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._setLabels=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._edgesFixedSize=!1,this._meansFixedSize=!1,this._intervalBase=new WeakMap,this._axesFixedSize=!1,this._plotTitle=null,this._titleEl=null,this._resizeObs=null,this._labelFont={size:null,family:null,color:null},this._zoomAnim=null,this._animateMs=0,this._tweenRaf=null,this._tween=null,this._tweenView=null,this._highlight={edges:new Set,nodes:new Set},this._highlightGroup=null,this._tooltipEl=null,this.graph=this,this.parent=null,this.__data__=new Re(Ls),this.__name__=this.__data__.name||"unnamed-graph",this.svg_element=this.create(),Xt("Created qe-graph svg element: ",this.svg_element),document.addEventListener("model-updated",t=>{var Ks,Js,Qs,ti,ei,si,ii,ni,ri,oi,ai,hi,li,ci,_i,ui,di;const e=((Ks=t.composedPath)==null?void 0:Ks.call(t)[0])??t.target;if(this._vizena&&e!==this._vizena)return;const s=t.detail;if(!s)return;this._renderPending=!1,(Js=this._childObserver)==null||Js.takeRecords(),this._animateMs=this.hasAttribute("animate")?parseInt(this.getAttribute("animate")||"",10)||300:0;const i=this._animateMs>0&&this._hasModel?this._captureTweenState():null;this._stopTween(),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 _={},g=(Qs=s.palette)!=null&&Qs.length?s.palette:Ws;if(h&&((ti=s.points)!=null&&ti.names)){const I=s.points.col(h);I&&[...new Set([...I].map(String))].forEach((L,N)=>{_[L]=g[N%g.length]})}(ei=s.groups)!=null&&ei.rows&&s.groups.rows().length>0&&s.groups.rows().forEach(I=>{const k=I.rowName??String(I[0]),L=I.names.indexOf("color"),N=L>=0?I[L]:null;N&&String(N)!=="NA"?_[k]=String(N):_[k]||(_[k]=g[Object.keys(_).length%g.length])});const p=Object.keys(_),u=o.activeMeanGroups&&o.activeMeanGroups.trim()?new Set(o.activeMeanGroups.split(",").map(I=>I.trim()).filter(I=>_[I])):new Set(p),d=o.scalePoints,l=c(I=>{let k=0;return I.forEach(L=>{const N=L.names.indexOf(n[0]),S=n.length>1?L.names.indexOf(n[1]):-1;N>=0&&(k=Math.max(k,Math.abs(Number(L[N])))),S>=0&&(k=Math.max(k,Math.abs(Number(L[S]))))}),k},"getExtent"),b=(si=s.nodes)!=null&&si.rows?l(s.nodes.rows()):0,f=(ii=s.points)!=null&&ii.rows?l(s.points.rows()):0,w=(ni=s.trajectories)!=null&&ni.rows?l(s.trajectories.rows()):0,T=f>0?f:w,z=o.pointScale!==null?o.pointScale:d&&T>0&&b>0?b/T:1;this._rangeExtent=o.range==="network"?b*1.2:o.range==="points"?T*z*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._edgesFixedSize=o.edgeLayers.some(I=>I.fixedSize),this._meansFixedSize=o.meanFixedSize,this._axesFixedSize=o.axesFixedSize,this._plotTitle=o.plotTitle,this._labelFont=o.labelFont;const j=o.labelNodes,dt=o.labelMeans,gt=o.labelPoints,et=this._labelsGroup,mt=c((I,k,L,N=1)=>{const S=I.names.indexOf(k),y=I.names.indexOf(n[0]),P=n.length>1?I.names.indexOf(n[1]):-1,v=new J({ID:S>=0?String(I[S]):I.rowName||`pt-${Math.random().toString(36).slice(2)}`,dimensions:[y>=0?Number(I[y])*N:0,P>=0?-Number(I[P])*N:0],meta:{}});return L&&(v.color=new tt(L)),v},"rowToPoint"),Q={},Tt=o.showPoints;["points","nodes","edges","edgenodes"].map(I=>this.__children__.search("__children__",I)).filter(I=>!!I).forEach(I=>I.__data__.objects.clear()),this.__data__.points.clear();const Ce=s.pointsets,Gt=[];if(o.pointSets.length&&(Ce!=null&&Ce.rows)){const I=this.__children__.search("__children__","points"),k=c((L,N)=>{const S=L.names.indexOf(N);return S>=0?L[S]:null},"col");o.pointSets.forEach((L,N)=>{Ce.rows().forEach(S=>{if(String(k(S,"set"))!==L.set)return;const y=String(k(S,"id")),P=k(S,"group")!=null&&String(k(S,"group"))!=="NA"?String(k(S,"group")):null,v=k(S,"color")&&String(k(S,"color"))!=="NA"?String(k(S,"color")):P&&_[P]?_[P]:g[N%g.length],E=mt(S,"id",v,z);E.ID=`${L.set}::${y}`,E.size=L.size??o.pointSize??2.5;const D=k(S,"shape");D&&String(D)!=="NA"&&(E.shape=String(D));const W=k(S,"label");E.meta={stroke:"#ffffff",kind:"point",name:W!=null&&String(W)!=="NA"?String(W):y,group:P??void 0,unit:y,set:L.set,fixedSize:L.fixedSize},this.__data__.points.set(E.ID,E),I==null||I.__data__.objects.set(E.ID,E),Gt.push({pt:E,spec:qe(S,y),mode:L.labelMode,weight:L.labelWeight})})})}if(et){const I=new Set(Gt.map(k=>k.pt.ID));this._setLabels.forEach((k,L)=>{I.has(L)||(k.remove(),this._setLabels.delete(L))}),Gt.forEach(k=>this._syncLabel(this._setLabels,k.pt.ID,k.spec,k.pt,et,k.mode,k.weight))}if((ri=s.points)!=null&&ri.rows){const I=this.__children__.search("__children__","points");if(I){s.points.rows().forEach(N=>{const S=h?N.names.indexOf(h):-1,y=S>=0?String(N[S]):null,P=y?_[y]??"#888888":"#888888";if(Tt){const v=mt(N,r,P,z);v.size=o.pointSize??2.5,v.meta={...v.meta??{},stroke:"#ffffff",kind:"point",name:v.ID,group:y??void 0,unit:v.ID,fixedSize:o.pointFixedSize},this.__data__.points.set(v.ID,v),I.__data__.objects.set(v.ID,v)}if(y){const v=N.names.indexOf(n[0]),E=n.length>1?N.names.indexOf(n[1]):-1;Q[y]||(Q[y]={x:0,y:0,x2:0,y2:0,xy:0,n:0,color:P});const D=v>=0?Number(N[v]):0,W=E>=0?Number(N[E]):0;Q[y].x+=D,Q[y].y+=W,Q[y].x2+=D*D,Q[y].y2+=W*W,Q[y].xy+=D*W,Q[y].n+=1}});const k=!!((oi=s.groups)!=null&&oi.rows&&s.groups.rows().length>0),L=o.showMeans&&k?s.groups.rows().filter(N=>{const S=N.rowName??String(N[0]);return u.size===0||u.has(S)}):[];if(o.showMeans){const N=I.svg_element,S=this._rangeExtent?this._rangeExtent/1.2:b,y=(S>0?S:1)*.008;if(k){const P=new Set(L.map(v=>v.rowName??String(v[0])));this._ciRects.forEach((v,E)=>{P.has(E)||(v.remove(),this._ciRects.delete(E))}),this._outlierRects.forEach((v,E)=>{P.has(E)||(v.remove(),this._outlierRects.delete(E))}),this._ciCross.forEach((v,E)=>{P.has(E.slice(2))||(v.remove(),this._ciCross.delete(E))}),L.forEach(v=>{var ss,re,Ut;const E=v.rowName??String(v[0]),D=_[E]??"#888888",W=v.names.indexOf(n[0]),G=n.length>1?v.names.indexOf(n[1]):-1,H=W>=0?Number(v[W])*z:0,wt=G>=0?-Number(v[G])*z:0,Z=new J({ID:`mean-${E}`,dimensions:[H,wt],meta:{kind:"mean",name:E,group:E,fixedSize:o.meanFixedSize}});Z.color=new tt(D),Z.size=4;const ht=v.names.indexOf("shape"),$=ht>=0?v[ht]:null;Z.shape=$&&String($)!=="NA"?String($):"rect",this.__data__.points.set(Z.ID,Z),I.__data__.objects.set(Z.ID,Z);const ie=c(Y=>{const x=v.names.indexOf(Y),A=x>=0?v[x]:null;return A==null||String(A)==="NA"||String(A)===""?null:A},"cell"),pt=ie("intervals"),zt=pt==="box"||pt==="crosshairs"||pt==="none"?pt:o.intervals,Bt=ie("outlier"),B=(Bt==null?o.showOutlier:Bt===!0||String(Bt)==="true")?Ye(v,n[0],n[1],"o"):null;if(!B)(ss=this._outlierRects.get(E))==null||ss.remove(),this._outlierRects.delete(E);else{let Y=this._outlierRects.get(E);Y||(Y=document.createElementNS("http://www.w3.org/2000/svg","rect"),Y.setAttribute("data-outlier-group",E),this._outlierRects.set(E,Y)),Y.setAttribute("x",(B.x_low*z).toString()),Y.setAttribute("y",(-B.y_high*z).toString()),Y.setAttribute("width",((B.x_high-B.x_low)*z).toString()),Y.setAttribute("height",((B.y_high-B.y_low)*z).toString()),Y.setAttribute("fill","none"),Y.setAttribute("stroke",D),Y.setAttribute("stroke-width",y.toString()),Y.setAttribute("stroke-opacity","0.5"),Y.setAttribute("stroke-dasharray",`${y*2} ${y*2}`),this._intervalStroke(Y,y,[y*2,y*2]),N&&!Y.parentElement&&N.insertBefore(Y,N.firstChild)}const ot=zt!=="none"?Ye(v,n[0],n[1]):null,ne=`x:${E}`;if((!ot||zt!=="crosshairs")&&((re=this._ciCross.get(ne))==null||re.remove(),this._ciCross.delete(ne)),ot&&zt==="crosshairs"){(Ut=this._ciRects.get(E))==null||Ut.remove(),this._ciRects.delete(E);const Y=ot.x_low*z,x=ot.x_high*z,A=-ot.y_high*z,C=-ot.y_low*z;je(Z,(x-Y)/2,(C-A)/2);let M=this._ciCross.get(ne);M||(M=document.createElementNS("http://www.w3.org/2000/svg","path"),M.setAttribute("data-ci-group",E),M.setAttribute("data-ci-kind","crosshairs"),this._ciCross.set(ne,M)),M.setAttribute("d",`M${Y} ${wt} L${x} ${wt} M${H} ${A} L${H} ${C}`),M.setAttribute("fill","none"),M.setAttribute("stroke",D),M.setAttribute("stroke-width",(y*1.25).toString()),this._intervalStroke(M,y*1.25,null),M.setAttribute("stroke-opacity","0.8"),N&&!M.parentElement&&N.insertBefore(M,N.firstChild)}else if(ot){const Y=ot.x_low*z,x=-ot.y_high*z,A=(ot.x_high-ot.x_low)*z,C=(ot.y_high-ot.y_low)*z;je(Z,A/2,C/2);let M=this._ciRects.get(E);M||(M=document.createElementNS("http://www.w3.org/2000/svg","rect"),M.setAttribute("data-ci-group",E),this._ciRects.set(E,M)),M.setAttribute("x",Y.toString()),M.setAttribute("y",x.toString()),M.setAttribute("width",A.toString()),M.setAttribute("height",C.toString()),M.setAttribute("fill","none"),M.setAttribute("stroke",D),M.setAttribute("stroke-width",y.toString()),M.setAttribute("stroke-opacity","0.8"),M.setAttribute("stroke-dasharray",`${y*4} ${y*3}`),this._intervalStroke(M,y,[y*4,y*3]),N&&!M.parentElement&&N.insertBefore(M,N.firstChild)}else{const Y=this._ciRects.get(E);Y&&(Y.remove(),this._ciRects.delete(E))}})}else this._removeIntervals(this._ciCross),Object.entries(Q).forEach(([v,{x:E,y:D,n:W,color:G}])=>{const H=new J({ID:`mean-${v}`,dimensions:[E/W*z,-(D/W)*z],meta:{kind:"mean",name:v,group:v,fixedSize:o.meanFixedSize}});H.color=new tt(G),H.size=4,H.shape="rect",this.__data__.points.set(H.ID,H),I.__data__.objects.set(H.ID,H)}),o.showCI?(this._ciRects.forEach((v,E)=>{Q[E]||(v.remove(),this._ciRects.delete(E))}),(ai=s.confidence)!=null&&ai.rows?s.confidence.rows().forEach(v=>{const E=v.names.indexOf(h??"group"),D=E>=0?String(v[E]):v.rowName??null;if(!D)return;const W=_[D]??"#888888",G=Ye(v,n[0],n[1]);if(!G)return;const H=G.x_low*z,wt=-G.y_high*z,Z=(G.x_high-G.x_low)*z,ht=(G.y_high-G.y_low)*z;je(this.__data__.points.get(`mean-${D}`),Z/2,ht/2);let $=this._ciRects.get(D);$||($=document.createElementNS("http://www.w3.org/2000/svg","rect"),$.setAttribute("data-ci-group",D),this._ciRects.set(D,$)),$.setAttribute("x",H.toString()),$.setAttribute("y",wt.toString()),$.setAttribute("width",Z.toString()),$.setAttribute("height",ht.toString()),$.setAttribute("fill","none"),$.setAttribute("stroke",W),$.setAttribute("stroke-width",y.toString()),$.setAttribute("stroke-opacity","0.8"),$.setAttribute("stroke-dasharray",`${y*4} ${y*3}`),this._intervalStroke($,y,[y*4,y*3]),N&&!$.parentElement&&N.insertBefore($,N.firstChild)}):Object.entries(Q).forEach(([v,{x:E,y:D,x2:W,y2:G,n:H,color:wt}])=>{if(H<2)return;const Z=E/H,ht=D/H,$=W/H-Z*Z,ie=G/H-ht*ht,{halfW:pt,halfH:zt}=$i($,ie,H,z),Bt=Z*z,Oe=-ht*z;je(this.__data__.points.get(`mean-${v}`),pt,zt);let B=this._ciRects.get(v);B||(B=document.createElementNS("http://www.w3.org/2000/svg","rect"),B.setAttribute("data-ci-group",v),this._ciRects.set(v,B)),B.setAttribute("x",(Bt-pt).toString()),B.setAttribute("y",(Oe-zt).toString()),B.setAttribute("width",(pt*2).toString()),B.setAttribute("height",(zt*2).toString()),B.setAttribute("fill","none"),B.setAttribute("stroke",wt),B.setAttribute("stroke-width",y.toString()),B.setAttribute("stroke-opacity","0.8"),B.setAttribute("stroke-dasharray",`${y*4} ${y*3}`),this._intervalStroke(B,y,[y*4,y*3]),N&&!B.parentElement&&N.insertBefore(B,N.firstChild)})):this._removeIntervals(this._ciRects),(hi=s.outlier)!=null&&hi.rows?(this._outlierRects.forEach((v,E)=>{_[E]||(v.remove(),this._outlierRects.delete(E))}),s.outlier.rows().forEach(v=>{const E=v.names.indexOf(h??"group"),D=E>=0?String(v[E]):v.rowName??null;if(!D)return;const W=_[D]??"#888888",G=Ye(v,n[0],n[1]);if(!G)return;const H=G.x_low*z,wt=-G.y_high*z,Z=(G.x_high-G.x_low)*z,ht=(G.y_high-G.y_low)*z;let $=this._outlierRects.get(D);$||($=document.createElementNS("http://www.w3.org/2000/svg","rect"),$.setAttribute("data-outlier-group",D),this._outlierRects.set(D,$)),$.setAttribute("x",H.toString()),$.setAttribute("y",wt.toString()),$.setAttribute("width",Z.toString()),$.setAttribute("height",ht.toString()),$.setAttribute("fill","none"),$.setAttribute("stroke",W),$.setAttribute("stroke-width",y.toString()),$.setAttribute("stroke-opacity","0.5"),$.setAttribute("stroke-dasharray",`${y*2} ${y*2}`),this._intervalStroke($,y,[y*2,y*2]),N&&!$.parentElement&&N.insertBefore($,N.firstChild)})):this._removeIntervals(this._outlierRects)}else[this._ciRects,this._outlierRects,this._ciCross].forEach(N=>this._removeIntervals(N));if(et){this._pointLabels.forEach((y,P)=>{I.__data__.objects.get(P)||(y.remove(),this._pointLabels.delete(P))}),this._meanLabels.forEach((y,P)=>{I.__data__.objects.get(`mean-${P}`)||(y.remove(),this._meanLabels.delete(P))}),gt!==0?s.points.rows().forEach(y=>{const P=y.names.indexOf(r),v=P>=0?String(y[P]):null;if(!v)return;const E=I.__data__.objects.get(v);E&&this._syncLabel(this._pointLabels,v,qe(null,v),E,et,gt,o.labelWeightPoints)}):this._clearLabels(this._pointLabels);const N=new Map(L.map(y=>[y.rowName??String(y[0]),y]));(k?[...N.keys()]:Object.keys(Q)).forEach(y=>{const P=`mean-${y}`,v=I.__data__.objects.get(P);v&&this._syncLabel(this._meanLabels,y,qe(N.get(y),y),v,et,dt,o.labelWeightMeans)})}I.__data__.__state__.setVariable("layer_updated",I.__data__)}}else{const I=this.__children__.search("__children__","points");I==null||I.__data__.__state__.setVariable("layer_updated",I.__data__)}const Nt=this.__children__.search("__children__","trajectories");if(o.showTrajectories&&Nt){Nt.__data__.objects.clear(),this.__data__.trajectories.clear();const I=(li=s.trajectories)!=null&&li.rows?s.trajectories:s.points;if(I!=null&&I.rows){const k={},L=o.trajectoryUnits?o.trajectoryUnits.split(",").map(S=>S.trim()):null;I.rows().forEach(S=>{const y=S.names.indexOf(r)>=0?S.names.indexOf(r):S.names.indexOf("unit")>=0?S.names.indexOf("unit"):S.names.indexOf("ENA_UNIT")>=0?S.names.indexOf("ENA_UNIT"):-1,P=y>=0?String(S[y]):S.rowName||"unit-1";if(L&&!L.includes(P))return;const v=S.names.indexOf(n[0]),E=n.length>1?S.names.indexOf(n[1]):-1,D=S.names.indexOf("time")>=0?S.names.indexOf("time"):S.names.indexOf("ActivityNumber")>=0?S.names.indexOf("ActivityNumber"):S.names.indexOf("RowID")>=0?S.names.indexOf("RowID"):-1,W=D>=0?Number(S[D]):k[P]?k[P].length+1:1;v>=0&&E>=0&&(k[P]||(k[P]=[]),k[P].push({x:Number(S[v])*z,y:-Number(S[E])*z,time:W}))}),Object.keys(k).forEach((S,y)=>{const P=k[S];if(P.length===0)return;const v=g[y%g.length],E=new ce({ID:`traj-${S}`,unitId:S,color:new tt(v),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:P.map(D=>({x:D.x,y:D.y,time:D.time}))});this.__data__.trajectories.set(S,E),Nt.__data__.objects.set(E.ID,E)})}Nt.__data__.__state__.setVariable("layer_updated",Nt.__data__)}const kt=this.__children__.search("__children__","network"),es=kt==null?void 0:kt.__children__.search("__children__","edges"),rt=kt==null?void 0:kt.__children__.search("__children__","nodes"),Hs=kt==null?void 0:kt.__children__.search("__children__","edgenodes"),Bi=o.showEdges;if((ci=s.nodes)!=null&&ci.rows&&rt){if(s.nodes.rows().forEach(k=>{const L=mt(k,a,"#444444");L.size=2;const N=k.names.indexOf("label"),S=N>=0?k[N]:null,y=k.names.indexOf("size"),P=y>=0&&k[y]!=null&&k[y]!==""?Number(k[y]):NaN;L.meta={...L.meta??{},kind:"node",name:S!=null&&String(S)!=="NA"&&String(S)!==""?String(S):L.ID,sizePx:Number.isFinite(P)&&P>0?P:void 0,zoomFixed:o.nodeFixedSize||void 0},rt.__data__.objects.set(L.ID,L)}),Bi&&es){const k={};h&&((_i=s.points)!=null&&_i.rows)&&s.points.rows().forEach(x=>{const A=x.names.indexOf(r),C=x.names.indexOf(h);A>=0&&C>=0&&(k[String(x[A])]=String(x[C]))});const L=s.nodes.rows().map(x=>{const A=x.names.indexOf(a);return A>=0?String(x[A]):""}).filter(Boolean),N=c(x=>{const A=[];return x.forEach(C=>{const M=Ri(C,L);M&&A.push({col:C,pair:M})}),A},"parsePairs"),S=(ui=s.edges)!=null&&ui.rows?s.edges.rows():[],y=s.networks,P=N(((di=s.edges)==null?void 0:di.names)??[]),v=N((y==null?void 0:y.names)??[]),E=c(x=>{const A={};return S.forEach(C=>{const M=C.names.indexOf(r);M<0||String(C[M])!==x||P.forEach(({col:F})=>{const V=C.names.indexOf(F);V>=0&&(A[F]=Number(C[V])||0)})}),A},"getUnitEdges"),D=c(x=>{const A={};let C=0;if(S.forEach(F=>{const V=F.names.indexOf(r),ft=V>=0?String(F[V]):null,bt=h?F.names.indexOf(h):-1;(bt>=0?String(F[bt]):ft?k[ft]:null)===x&&(C++,P.forEach(({col:vt})=>{const At=F.names.indexOf(vt);if(At>=0){const K=Number(F[At]);isNaN(K)||(A[vt]=(A[vt]??0)+K)}}))}),C===0)return{};const M={};return P.forEach(({col:F})=>{M[F]=(A[F]??0)/C}),M},"getGroupEdges"),W=c(x=>{if(_[x])return{weights:D(x),color:_[x],label:x};const A=k[x]??null,C=A?_[A]??"#888888":"#888888";return{weights:E(x),color:C,label:x}},"resolve"),G=[],H=c(x=>{var M;const A=(M=y==null?void 0:y.rows)==null?void 0:M.call(y).find(F=>F.rowName===x);if(!A)return null;const C={};return v.forEach(({col:F})=>{const V=A.names.indexOf(F);if(V>=0){const ft=Number(A[V]);Number.isFinite(ft)&&(C[F]=ft)}}),C},"networkRow"),wt=c((x,A)=>{if(!A)return x;const C=Math.abs(x);return C<A[0]?0:C>A[1]?Math.sign(x)*A[1]:x},"thresholded");o.edgeLayers.forEach((x,A)=>{const C=c((K,lt,st,Et,ct)=>{st=wt(st,x.threshold),!(Math.abs(st)<1e-6)&&G.push({col:`${A}:${K}`,pair:lt,weight:Math.abs(st),color:Et,layer:A,...ct})},"push"),M=c((K,lt)=>x.colors?[x.colors[0],x.colors[1]??ji(x.colors[0])]:[K,lt],"signColors");if(x.network){const K=H(x.network);if(!K)return;const[lt,st]=M(g[0],g[1]),Et={name:x.name??x.network};v.forEach(({col:ct,pair:gi})=>{const Pe=K[ct]??0;C(ct,gi,Pe,Pe>=0?lt:st,Et)});return}const F=x.unit??x.group??null;if(!F)return;const V=W(F),ft=x.compare??x.also??null,bt=ft?W(ft):null,Ct={name:x.name??F,group:x.group??void 0,unit:x.unit??void 0},[vt,At]=M(V.color,(bt==null?void 0:bt.color)??V.color);bt&&x.compare?P.forEach(({col:K,pair:lt})=>{const st=(V.weights[K]??0)-(bt.weights[K]??0);C(K,lt,st,st>0?vt:At,Ct)}):bt&&x.also?P.forEach(({col:K,pair:lt})=>{const st=V.weights[K]??0,Et=bt.weights[K]??0;st>0&&C(K+"-a",lt,st,vt,Ct),Et>0&&C(K+"-b",lt,Et,At,{...Ct,name:x.also??void 0,group:x.also??void 0})}):P.forEach(({col:K,pair:lt})=>{const st=V.weights[K]??0;st>0&&C(K,lt,st,vt,Ct)})}),G.sort((x,A)=>A.weight-x.weight);const Z=!!s.directed,ht=zi(o.edgeWidth)*(o.edgeMagnify??1),$=c(x=>{const A=x.map(Math.abs).filter(C=>C>0);return A.length?[Math.min(...A),Math.max(...A)]:[0,0]},"rangeOf"),[ie,pt]=S.length?[P,s.edges]:[v,y],zt=c(x=>{const A=[];return ie.forEach(({col:C,pair:M})=>{if(M[0]===M[1]!==x)return;const F=pt==null?void 0:pt.col(C);if(F)for(const V of F)A.push(Number(V))}),$(A)},"modelRange"),Bt=c(x=>$(G.filter(A=>A.pair[0]===A.pair[1]===x).map(A=>A.weight)),"plotRange"),Oe=o.edgeColorScale,B=c(x=>Oe==="plot"?Bt(x):zt(x),"colourRange"),ot=B(!1),ne=B(!0),ss=c((x,A)=>{if(Oe==="absolute"){const F=Math.min(1,Math.abs(x));return{saturation:F,opacity:F}}const[C,M]=A?ne:ot;return{saturation:Bs(x,C,M,Ai),opacity:Bs(x,C,M,Si)}},"colourOf"),re={};G.forEach(({pair:x,weight:A})=>{const C=x[0]===x[1],M=c(F=>{re[F]=(re[F]??0)+Math.abs(A)},"add");if(Z||C){M(x[1]);return}M(x[0]),M(x[1])}),s.nodes.rows().forEach(x=>{var ft;const A=x.names.indexOf(a),C=A>=0?String(x[A]):"";if(!C)return;const M=rt.__data__.objects.get(C);if(!M)return;const F=re[C]??0,V=!(F>0);M.size=V?o.hideUnconnectedNodes?0:ki:Ci(F,ht),M.meta={...M.meta??{},hidden:V&&o.hideUnconnectedNodes,sizePx:V||(ft=M.meta)==null?void 0:ft.sizePx}});const Ut={},Y=c((x,A,C,M)=>`${x}:${A??""}:${C}.${M}`,"pairKey");Z&&G.forEach(({pair:x,weight:A,layer:C,name:M})=>{const F=Y(C,M,x[0],x[1]);Ut[F]=(Ut[F]??0)+A}),G.forEach(({col:x,pair:A,weight:C,color:M,layer:F,name:V,group:ft,unit:bt})=>{var Pe,mi;const Ct=rt.__data__.objects.get(A[0]),vt=rt.__data__.objects.get(A[1]);if(!Ct||!vt)return;const At=A[0]===A[1],{saturation:K,opacity:lt}=ss(C,At),st=new J({ID:`${A[0]}-src`,dimensions:[Ct.x,Ct.y],meta:{}}),Et=new J({ID:`${A[1]}-dst`,dimensions:[vt.x,vt.y],meta:{}});let ct;if(At)ct=new Vt({},st,Et),ct.weight=0;else if(Z){const Ui=Ut[Y(F,V,A[0],A[1])]??C,Xi=Ut[Y(F,V,A[1],A[0])]??0,Wi=Ui+Xi;ct=new cs({weight:C,totalweight:Wi},st,Et)}else ct=new Ht({},st,Et);ct.ID=`edge-${x}`,ct.color=new tt(M),ct.meta={isMeanEdge:!0,weight:C,widthFrac:ht,saturation:K,opacity:lt,isDirected:Z,isSelf:At,source:A[0],target:A[1],group:ft,unit:bt,layer:V,selfSize:At?((Pe=o.edgeLayers[F])==null?void 0:Pe.selfSize)??void 0:void 0,fixedSize:((mi=o.edgeLayers[F])==null?void 0:mi.fixedSize)||void 0},(At?Hs??es:es).__data__.objects.set(ct.ID,ct)})}const I=o.showNodes;rt.svg_element&&(rt.svg_element.style.display=I?"":"none"),I||this._clearLabels(this._nodeLabels),et&&I&&(this._nodeLabels.forEach((k,L)=>{rt.__data__.objects.get(L)||(k.remove(),this._nodeLabels.delete(L))}),s.nodes.rows().forEach(k=>{var y,P,v;const L=k.names.indexOf(a),N=L>=0?String(k[L]):"";if(!N)return;const S=rt.__data__.objects.get(N);if(S){if((y=S.meta)!=null&&y.hidden){(P=this._nodeLabels.get(N))==null||P.remove(),this._nodeLabels.delete(N);return}this._syncLabel(this._nodeLabels,N,qe(k,String(((v=S.meta)==null?void 0:v.name)??N)),S,et,j,o.labelWeightNodes)}})),rt.__data__.__state__.setVariable("layer_updated",rt.__data__)}else rt==null||rt.__data__.__state__.setVariable("layer_updated",rt.__data__);[es,Hs].forEach(I=>I==null?void 0:I.__data__.__state__.setVariable("layer_updated",I.__data__));const Vs=this.__children__.search("__children__","axis_points"),Zs=this.__children__.search("__children__","axis_lines");Vs&&this.__data__.__state__.setVariable("graph_updated_axis_points",Vs.__data__.objects),Zs&&this.__data__.__state__.setVariable("graph_updated_axis_lines",Zs.__data__.objects),this.update(),i&&this._startTween(i)})}static get observedAttributes(){return["width","height","for","scale-points","point-scale","center","view-padding","labels","label-nodes","label-means","label-points"]}get vizena(){return this._vizena}_viewPadding(){const t=Number(this.getAttribute("view-padding"));return this.hasAttribute("view-padding")&&Number.isFinite(t)&&t>0?t:1.2}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}_syncLabel(t,e,s,i,n,r,a){let h=t.get(e);const o=s.text!=null&&(r!==q.DISPLAY_TYPES.OFF||s.pinned);h&&(!o||h.text!==s.text||h.displayMode!==r)&&(h.remove(),t.delete(e),h=void 0),o&&(h?(h.setPoint(i),r===q.DISPLAY_TYPES.ON&&h.show()):(h=new _s(s.text,i,n,this,r),t.set(e,h)),s.offset&&h.setOffset(s.offset.x,s.offset.y),h.fontWeight=a,h.setHostPinned(s.pinned))}_nodeRadius(t){const e=this.__children__.search("__children__","nodes"),s=e==null?void 0:e.__children__.find(i=>{var n;return((n=i.__data__)==null?void 0:n.ID)===t});return s?s.computeRadius():null}_intervalStroke(t,e,s){this._intervalBase.set(t,{w:e,dash:s}),this._applyIntervalStroke(t)}_applyIntervalStroke(t){const e=this._intervalBase.get(t);if(!e)return;const s=this._meansFixedSize&&this.zoom_level||1;t.setAttribute("stroke-width",String(e.w/s)),e.dash&&t.setAttribute("stroke-dasharray",e.dash.map(i=>i/s).join(" "))}_removeIntervals(t){t.forEach(e=>e.remove()),t.clear()}_clearLabels(t){t.forEach(e=>e.remove()),t.clear()}_scheduleRerender(){!this._vizena||!this._hasModel||this._renderPending||(this._renderPending=!0,queueMicrotask(()=>{var t;this._renderPending&&(this._renderPending=!1,(t=this._vizena)==null||t.dispatchEvent(new CustomEvent("model-updated",{detail:this._vizena.model,bubbles:!0,composed:!0})))}))}_readLayerConfig(){var p;const t=this.querySelector("qe-nodes"),e=this.querySelector("qe-means"),s=[...this.querySelectorAll("qe-points")],i=s.find(u=>!u.hasAttribute("set"))??null,n=s.filter(u=>u.hasAttribute("set")),r=[...this.querySelectorAll("qe-edges")],a=c(u=>{var d;return((d=r.find(l=>l.hasAttribute(u)))==null?void 0:d.getAttribute(u))??null},"firstAttr"),h=r.find(u=>u.hasAttribute("magnify")),o=this.querySelector("qe-trajectories"),_=this.querySelector("qe-axes"),g=this.getAttribute("labels");return{labelNodes:Ge((t==null?void 0:t.getAttribute("label"))??this.getAttribute("label-nodes")??g,q.DISPLAY_TYPES.ON),labelWeightNodes:(t==null?void 0:t.getAttribute("label-font-weight"))||null,nodeFixedSize:!!t&&t.hasAttribute("fixed-size"),showNodes:!!t,range:(()=>{const u=this.getAttribute("range");if(u==="network"||u==="points")return u;const d=Number(u);return u!=null&&Number.isFinite(d)&&d>0?d:null})(),plotTitle:this.getAttribute("plot-title")||null,labelFont:{size:(()=>{const u=Number(this.getAttribute("label-font-size"));return Number.isFinite(u)&&u>0?u:null})(),family:this.getAttribute("label-font-family")||null,color:this.getAttribute("label-font-color")||null},edgeWidth:(()=>{const u=Number(this.getAttribute("edge-width"));return Number.isFinite(u)&&u>0&&u<=1?u:vi})(),hideUnconnectedNodes:((p=t==null?void 0:t.getAttribute("unconnected"))==null?void 0:p.toLowerCase())==="hide",scalePoints:this.getAttribute("scale-points")!=="false",pointScale:(()=>{const u=Number(this.getAttribute("point-scale"));return this.hasAttribute("point-scale")&&Number.isFinite(u)&&u>0?u:null})(),centerContent:this.getAttribute("center")==="content",showMeans:!!e,activeMeanGroups:(e==null?void 0:e.getAttribute("groups"))??null,showCI:!!e&&e.hasAttribute("confidence"),intervals:(()=>{const u=e==null?void 0:e.getAttribute("intervals");return u==="box"||u==="crosshairs"||u==="none"?u:e!=null&&e.hasAttribute("confidence")?"box":"none"})(),showOutlier:!!e&&e.hasAttribute("outlier"),labelMeans:Ge((e==null?void 0:e.getAttribute("label"))??this.getAttribute("label-means")??g,q.DISPLAY_TYPES.ON),labelWeightMeans:(e==null?void 0:e.getAttribute("label-font-weight"))||null,meanFixedSize:!!e&&e.hasAttribute("fixed-size"),showPoints:!!i,pointSets:n.map(u=>({set:u.getAttribute("set"),size:u.getAttribute("size")?parseFloat(u.getAttribute("size")):null,fixedSize:u.hasAttribute("fixed-size"),labelMode:Ge(u.getAttribute("label")??this.getAttribute("label-points")??g,q.DISPLAY_TYPES.OFF),labelWeight:u.getAttribute("label-font-weight")||null})),labelPoints:Ge((i==null?void 0:i.getAttribute("label"))??this.getAttribute("label-points")??g,q.DISPLAY_TYPES.OFF),labelWeightPoints:(i==null?void 0:i.getAttribute("label-font-weight"))||null,pointSize:i!=null&&i.getAttribute("size")?parseFloat(i.getAttribute("size")):null,pointFixedSize:!!i&&i.hasAttribute("fixed-size"),showEdges:r.length>0,edgeLayers:r.map(Di),edgeColorScale:Yi(a("color-scale")),edgeMagnify:h?(()=>{const u=Number(h.getAttribute("magnify"));return Number.isFinite(u)&&u>0?u: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:!!_,axesFixedSize:!!_&&_.hasAttribute("fixed-size"),axisXLabel:_!=null&&_.hasAttribute("x")?_.getAttribute("x")??"":null,axisYLabel:_!=null&&_.hasAttribute("y")?_.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),it._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","view-padding","plot-title","label-font-size","label-font-family","label-font-color","label-font-weight","label-nodes","label-means","label-points","self-size","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;this._stopTween(),(t=this._childObserver)==null||t.disconnect(),this._childObserver=null,(e=this._resizeObs)==null||e.disconnect(),this._resizeObs=null,it._instances.delete(this),(s=this._tooltipEl)==null||s.remove(),this._tooltipEl=null}static instances(){return[...it._instances]}static getGraph(t){for(const e of it._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=c(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)}_zoomLimits(){const t=c(e=>{const s=Number(this.getAttribute(e));return this.hasAttribute(e)&&Number.isFinite(s)&&s>0?s:null},"num");return[t("zoom-min")??0,t("zoom-max")??1/0]}_clampZoom(t){const[e,s]=this._zoomLimits();return Math.min(s,Math.max(e,t))}_zoomStep(){const t=Number(this.getAttribute("zoom-step"));return this.hasAttribute("zoom-step")&&Number.isFinite(t)&&t>0?t:1.1}_clientToRoot(t,e){var n,r;const s=(r=(n=this.svg_element).getScreenCTM)==null?void 0:r.call(n);if(!s)return null;const i=new DOMPoint(t,e).matrixTransform(s.inverse());return[i.x,i.y]}_zoomAbout(t,e,s){if(!(Number.isFinite(t)&&t>0))return;t=this._clampZoom(t);const i=this.__data__.transform,n=t/(this.zoom_level||1);i.e=e-n*(e-i.e),i.f=s-n*(s-i.f),i.zoom(t),this.zoom_level=t,this.update()}_stopZoomAnim(){this._zoomAnim!==null&&cancelAnimationFrame(this._zoomAnim),this._zoomAnim=null}_animateZoomAbout(t,e,s,i){this._stopZoomAnim();const n=this.zoom_level||1,r=this._clampZoom(t);if(r===n)return;const a=performance.now(),h=c(o=>{const _=Math.min(1,Math.max(0,(o-a)/i));this._zoomAbout(_>=1?r:n*Math.pow(r/n,1-Math.pow(1-_,3)),e,s),this._zoomAnim=_<1?requestAnimationFrame(h):null},"step");this._zoomAnim=requestAnimationFrame(h)}zoomTo(t){this._stopZoomAnim();const{cx:e,cy:s}=this.__data__.extremes;this._zoomAbout(t,e,s)}zoomBy(t){Number.isFinite(t)&&t>0&&this.zoomTo((this.zoom_level||1)*t)}resetView(){this._stopZoomAnim();const t=this._clampZoom(1),{cx:e,cy:s}=this.__data__.extremes;this.zoom_level=t,this.__data__.transform.values=t===1?[1,0,0,1,0,0]:[t,0,0,t,e*(1-t),s*(1-t)],this.update()}static _ease(t){return t<.5?2*t*t:1-Math.pow(-2*t+2,2)/2}static _setXY(t,e,s){t.x=e,t.y=s,t.dimensions&&(t.dimensions[0]=e,t.dimensions[1]=s)}_layerObjects(t){var e;return(e=this.__children__.search("__children__",t))==null?void 0:e.__data__.objects}_intervalMarks(){return[...this._ciRects.values(),...this._outlierRects.values(),...this._ciCross.values()]}_boxGeom(t){return t.tagName.toLowerCase()==="rect"?["x","y","width","height"].map(e=>parseFloat(t.getAttribute(e)||"0")):((t.getAttribute("d")||"").match(it._PATH_NUM_RE)||[]).map(Number)}_captureTweenState(){var n;const t=new Map;for(const r of["points","nodes"])(n=this._layerObjects(r))==null||n.forEach((a,h)=>t.set(`${r}:${h}`,[a.x,a.y]));const e=new Map;this._intervalMarks().forEach(r=>e.set(r,this._boxGeom(r)));const s=this.__data__.extremes,i=this._tween;return{marks:t,boxes:e,view:[s.x_max,s.y_max,s.cx,s.cy],running:i?{t0:i.t0,k:i.k,marks:new Map(i.marks.map(r=>[r.key,[r.tx,r.ty]])),boxes:new Map(i.boxes.map(r=>[r.el,r.to])),view:i.view.to}:null}}_stopTween(){this._tweenRaf!==null&&cancelAnimationFrame(this._tweenRaf),this._tweenRaf=null,this._tween=null,this._tweenView=null}_startTween(t){var b;const e=performance.now(),s=c((f,w)=>!!w&&f.length===w.length&&f.every((T,z)=>T===w[z]),"same"),i=[];for(const f of["points","nodes"])(b=this._layerObjects(f))==null||b.forEach((w,T)=>{const z=`${f}:${T}`,j=t.marks.get(z);j&&i.push({key:z,o:w,tx:w.x,ty:w.y,cx:j[0],cy:j[1]})});const n=this._intervalMarks().map(f=>({el:f,to:this._boxGeom(f),cur:t.boxes.get(f)})).filter(f=>f.cur&&f.cur.length===f.to.length),r=this.__data__.extremes,a=[r.x_max,r.y_max,r.cx,r.cy],h=t.running,o=!!h&&h.k<.95&&s(a,h.view)&&i.every(f=>s([f.tx,f.ty],h.marks.get(f.key)??[f.cx,f.cy]))&&n.every(f=>s(f.to,h.boxes.get(f.el)??f.cur)),_=o?h.k:0,g=c((f,w)=>_>0?(f-_*w)/(1-_):f,"from"),p=i.map(f=>({key:f.key,o:f.o,tx:f.tx,ty:f.ty,fx:g(f.cx,f.tx),fy:g(f.cy,f.ty)})).filter(f=>f.fx!==f.tx||f.fy!==f.ty),u=n.map(f=>({el:f.el,to:f.to,from:f.cur.map((w,T)=>g(w,f.to[T])),attrs:Object.fromEntries(["x","y","width","height","d"].filter(w=>f.el.hasAttribute(w)).map(w=>[w,f.el.getAttribute(w)]))})).filter(f=>!s(f.from,f.to)),d=t.view.map((f,w)=>g(f,a[w]));if(!p.length&&!u.length&&s(d,a))return;this._tween={t0:o?h.t0:e,dur:this._animateMs,k:_,marks:p,boxes:u,view:{from:d,to:a}},this._tweenFrame(_);const l=c(f=>{const w=this._tween;if(!w)return;const T=(f-w.t0)/w.dur;if(T>=1){this._endTween();return}this._tweenFrame(Math.max(w.k,it._ease(Math.max(0,T)))),this._tweenRaf=requestAnimationFrame(l)},"step");this._tweenRaf=requestAnimationFrame(l)}_tweenFrame(t){const e=this._tween;if(!e)return;e.k=t;const s=c((i,n)=>i+(n-i)*t,"lerp");e.marks.forEach(i=>it._setXY(i.o,s(i.fx,i.tx),s(i.fy,i.ty))),this._attachEdges(),e.boxes.forEach(i=>{const n=i.from.map((r,a)=>s(r,i.to[a]));if("d"in i.attrs){let r=0;i.el.setAttribute("d",i.attrs.d.replace(it._PATH_NUM_RE,()=>String(n[r++])))}else["x","y","width","height"].forEach((r,a)=>i.el.setAttribute(r,String(n[a])))}),this._tweenView=e.view.from.map((i,n)=>s(i,e.view.to[n])),this.update()}_endTween(){const t=this._tween;t&&(t.marks.forEach(e=>it._setXY(e.o,e.tx,e.ty)),this._attachEdges(),t.boxes.forEach(e=>Object.entries(e.attrs).forEach(([s,i])=>e.el.setAttribute(s,i))),this._stopTween(),this.update())}_attachEdges(){var e;const t=this._layerObjects("nodes");if(t)for(const s of["edges","edgenodes"])(e=this._layerObjects(s))==null||e.forEach(i=>{var a,h;const n=t.get((a=i.meta)==null?void 0:a.source),r=t.get((h=i.meta)==null?void 0:h.target);n&&i.from&&it._setXY(i.from,n.x,n.y),r&&i.to&&it._setXY(i.to,r.x,r.y)})}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),_=new Image;_.onload=()=>{try{const g=document.createElement("canvas");g.width=i*t,g.height=n*t;const p=g.getContext("2d");if(!p){URL.revokeObjectURL(o),a(new Error("no 2d context"));return}p.scale(t,t),p.drawImage(_,0,0,i,n),URL.revokeObjectURL(o),r(g.toDataURL("image/png"))}catch(g){URL.revokeObjectURL(o),a(g)}},_.onerror=g=>{URL.revokeObjectURL(o),a(g)},_.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(){var _;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"));const t=this._highlight.edges.size>0||this._highlight.nodes.size>0,e=(_=this.__children__[0])==null?void 0:_.svg_element;(t&&e?e:this.svg_element).appendChild(this._highlightGroup);const s=this._highlightGroup;s.textContent="";const i=this.__data__.extremes.x_max||1,n="#f5a623",r=this.zoom_level||1,a=this._edgesFixedSize?r:1,h=c(g=>{var d;const p=c(l=>{var b;return(b=this.__children__.search("__children__",l))==null?void 0:b.__data__.objects.get(g)},"find"),u=(d=p("nodes")??p("points"))==null?void 0:d.meta;return u!=null&&u.zoomFixed||u!=null&&u.fixedSize?r:1},"markK"),o=c((g,p)=>{const u=document.createElementNS("http://www.w3.org/2000/svg",g);for(const d in p)u.setAttribute(d,String(p[d]));return u},"mk");if(this._highlight.edges.size){const g={};this.getNodes().forEach(p=>{g[p.id]={x:p.x,y:p.y}}),this._highlight.edges.forEach(p=>{const[u,d]=p.split("\0"),l=g[u],b=g[d];!l||!b||s.appendChild(o("line",{x1:l.x,y1:l.y,x2:b.x,y2:b.y,stroke:n,"stroke-width":i*.02/a,"stroke-opacity":.6,"stroke-linecap":"round"}))})}this._highlight.nodes.forEach(g=>{var f;const p=this.svg_element.querySelector(`[data-point-id="${(f=window.CSS)!=null&&f.escape?CSS.escape(g):g}"]`);if(!p)return;const u=p.tagName.toLowerCase();let d,l,b;if(u==="rect"){const w=parseFloat(p.getAttribute("width")||"0");d=parseFloat(p.getAttribute("x")||"0")+w/2,l=parseFloat(p.getAttribute("y")||"0")+parseFloat(p.getAttribute("height")||"0")/2,b=w/2}else d=parseFloat(p.getAttribute("cx")||"0"),l=parseFloat(p.getAttribute("cy")||"0"),b=parseFloat(p.getAttribute("r")||"0");s.appendChild(o("circle",{cx:d,cy:l,r:b*1.7+i*.004/h(g),fill:"none",stroke:n,"stroke-width":i*.006/h(g)}))})}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=c((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 Ws.forEach(r=>n(`qe-arrow-${r.slice(1)}`,r)),t.appendChild(e),this.__data__.layers.forEach(r=>{const a=new De(r,this.svg_element,this);this.__children__.push(a)}),this.__data__.__state__.setVariable("graph_updated",this.__data__),this.attach_events(),t}attach_events(){const t=c(()=>this.hasAttribute("view-locked"),"locked");this.svg_element.addEventListener("wheel",d=>{if(t())return;d.preventDefault();const l=d.deltaMode===1?33:d.deltaMode===2?this.svg_element.clientHeight||800:1,b=d.deltaY*l,f=d.ctrlKey?Math.exp(-b/100):Math.pow(this._zoomStep(),-b/100);this._stopZoomAnim();const w=this._clientToRoot(d.clientX,d.clientY);w?this._zoomAbout((this.zoom_level||1)*f,w[0],w[1]):this.zoomBy(f)},{passive:!1}),this.svg_element.addEventListener("dblclick",d=>{var b,f;if(t()||(f=(b=d.target)==null?void 0:b.closest)!=null&&f.call(b,"text[data-label-for]"))return;d.preventDefault();const l=this._clientToRoot(d.clientX,d.clientY);l&&this._animateZoomAbout((this.zoom_level||1)*2.2,l[0],l[1],200)});const e=new Map;let s=null;const i=c(()=>{const[d,l]=[...e.values()];return d?l?{mid:[(d[0]+l[0])/2,(d[1]+l[1])/2],dist:Math.hypot(d[0]-l[0],d[1]-l[1]),n:2}:{mid:d,dist:0,n:1}:null},"measure");this.svg_element.addEventListener("pointerdown",d=>{d.pointerType!=="touch"||t()||(e.set(d.pointerId,[d.clientX,d.clientY]),s=i(),this._stopZoomAnim())}),this.svg_element.addEventListener("pointermove",d=>{if(!e.has(d.pointerId))return;if(t()){e.clear(),s=null;return}e.set(d.pointerId,[d.clientX,d.clientY]);const l=i();if(l&&s&&l.n===s.n){const b=this._clientToRoot(...s.mid),f=this._clientToRoot(...l.mid);if(b&&f){const w=this.__data__.transform;w.pan(f[0]-b[0],f[1]-b[1]),l.n===2&&s.dist>0&&l.dist>0?this._zoomAbout((this.zoom_level||1)*l.dist/s.dist,f[0],f[1]):this.__children__[0].svg_element.setAttribute("transform",w.toString())}}s=l});const n=c(d=>{e.delete(d.pointerId)&&(s=i())},"touchEnd");this.svg_element.addEventListener("pointerup",n),this.svg_element.addEventListener("pointercancel",n);let r=!1,a=0,h=0;this.svg_element.addEventListener("mousedown",d=>{t()||(r=!0,a=d.clientX,h=d.clientY)});let o=null,_=null;const g=c(()=>{_&&(this.__data__.transform.pan(_.dx,_.dy),this.__children__[0].svg_element.setAttribute("transform",this.__data__.transform.toString()),_=null),o=null},"panUpdate");this.svg_element.addEventListener("mousemove",d=>{if(!r)return;if(d.buttons===0){r=!1;return}const l=this._clientToRoot(a,h),b=this._clientToRoot(d.clientX,d.clientY);a=d.clientX,h=d.clientY,!(!l||!b)&&(_={dx:((_==null?void 0:_.dx)??0)+b[0]-l[0],dy:((_==null?void 0:_.dy)??0)+b[1]-l[1]},o===null&&(o=requestAnimationFrame(g)))}),this.svg_element.addEventListener("mouseup",d=>{r=!1}),this.svg_element.addEventListener("point-clicked",(d=>{var f,w;const l=(w=(f=d.detail)==null?void 0:f.pointData)==null?void 0:w.ID;if(!l)return;const b=this._pointLabels.get(l)??this._setLabels.get(l)??this._meanLabels.get(l.replace("mean-",""))??this._nodeLabels.get(l);b&&b.displayMode===q.DISPLAY_TYPES.CLICK&&b.toggle()}));const p=c(d=>{var l;for(;d&&d!==this.svg_element;){const b=(l=d.getAttribute)==null?void 0:l.call(d,"data-point-id");if(b)return b;d=d.parentElement}return null},"findPointId"),u=c(d=>this._pointLabels.get(d)??this._setLabels.get(d)??this._meanLabels.get(d.replace(/^mean-/,""))??this._nodeLabels.get(d),"getAutoLabel");this.svg_element.addEventListener("mouseover",d=>{const l=p(d.target);if(!l)return;const b=u(l);(b==null?void 0:b.displayMode)===q.DISPLAY_TYPES.AUTO&&b.show()}),this.svg_element.addEventListener("mouseout",d=>{const l=p(d.target);if(!l)return;const b=d.relatedTarget;if(p(b)===l)return;const w=u(l);(w==null?void 0:w.displayMode)===q.DISPLAY_TYPES.AUTO&&w.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=c((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._ciRects,this._outlierRects,this._ciCross].forEach(t=>t.forEach(e=>this._applyIntervalStroke(e))),this.update_labels(),this.update_extremes(),this.update_axes(),this._applyHighlights()}update_axes(){var g,p;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=r/(this._axesFixedSize&&this.zoom_level||1),o=h*.6,_=c((u,d)=>{let l=this._axisLabelEls.get(u);if(!this._showAxes||d==null){l&&(l.remove(),this._axisLabelEls.delete(u));return}l||(l=document.createElementNS("http://www.w3.org/2000/svg","text"),l.setAttribute("data-axis-label",u),l.setAttribute("pointer-events","none"),e.appendChild(l),this._axisLabelEls.set(u,l)),l.textContent=d,l.setAttribute("font-size",h.toString()),l.setAttribute("font-family","system-ui, sans-serif"),l.setAttribute("font-weight","600"),l.setAttribute("fill","#556"),u==="x"?(l.setAttribute("x",(i+s-o).toString()),l.setAttribute("y",(-o).toString()),l.setAttribute("text-anchor","end")):(l.setAttribute("x",o.toString()),l.setAttribute("y",(n-s+h+o).toString()),l.setAttribute("text-anchor","start"))},"place");if(_("x",this._axisXText),_("y",this._axisYText),this._magnifyText==null)(g=this._magnifyEl)==null||g.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 u=this._magnifyEl;u.textContent=this._magnifyText,u.setAttribute("font-size",(r*.85).toString()),u.setAttribute("font-family","system-ui, sans-serif"),u.setAttribute("font-style","italic"),u.setAttribute("fill","#556"),u.setAttribute("x",(i-s+a).toString()),u.setAttribute("y",(n-s+r+a).toString()),u.setAttribute("text-anchor","start")}if(!this._plotTitle)(p=this._titleEl)==null||p.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 d=(this._labelFont.size??12)*1.35*this.unitsPerPixel(),l=this._titleEl;l.textContent=this._plotTitle,l.setAttribute("font-size",d.toString()),l.setAttribute("font-family",this._labelFont.family??"system-ui, sans-serif"),l.setAttribute("font-weight","600"),l.setAttribute("fill",this._labelFont.color??"#223"),l.setAttribute("x",i.toString()),l.setAttribute("y",(n-s+d*1.1).toString()),l.setAttribute("text-anchor","middle")}}update_labels(){this._nodeLabels.forEach(t=>t.update()),this._meanLabels.forEach(t=>t.update()),this._pointLabels.forEach(t=>t.update()),this._setLabels.forEach(t=>t.update())}update_extremes(){var s;const t=this.__data__;if(this._tweenView){const[i,n,r,a]=this._tweenView;t.extremes=new Lt(i,n,r,a)}else 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){Xt("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(this._viewPadding()));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()})}};c(it,"QEGraphElement"),it.tagName="qe-graph",it.style=`
19
19
  ${$e.style}
20
20
 
21
21
  :host {