@qe-libs/qeviz 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +87 -5
- package/dist/qeviz.es.js +2214 -1445
- package/dist/qeviz.es.js.map +1 -1
- package/dist/qeviz.umd.js +5 -5
- package/dist/qeviz.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/qeviz.umd.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
(function(O,H){typeof exports=="object"&&typeof module<"u"?H(exports):typeof define=="function"&&define.amd?define(["exports"],H):(O=typeof globalThis<"u"?globalThis:O||self,H(O.QEViz={}))})(this,(function(O){"use strict";var In=Object.defineProperty;var Ri=O=>{throw TypeError(O)};var l=(O,H)=>In(O,"name",{value:H,configurable:!0});var $i=(O,H,mt)=>H.has(O)||Ri("Cannot "+mt);var R=(O,H,mt)=>($i(O,H,"read from private field"),mt?mt.call(O):H.get(O)),ct=(O,H,mt)=>H.has(O)?Ri("Cannot add the same private member more than once"):H instanceof WeakSet?H.add(O):H.set(O,mt),V=(O,H,mt,$t)=>($i(O,H,"write to private field"),$t?$t.call(O,mt):H.set(O,mt),mt);var Le,Pe,Re,xt,$e,Te,wt,re,Yt,zt,dt,Fe,Wt,Ot,he,le,Be;const Rs=class Rs extends Array{constructor(e,s,i,n,r){super(...s);ct(this,Le);ct(this,Pe);ct(this,Re);ct(this,xt);ct(this,$e);V(this,Re,e),V(this,Pe,i),V(this,xt,n),V(this,$e,n==null?void 0:n.classes),V(this,Le,r)}get parent(){return R(this,xt)}get names(){return R(this,Re)}get rowName(){return R(this,Pe)}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,$e)}get rowNumber(){return R(this,Le)}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.")}};Le=new WeakMap,Pe=new WeakMap,Re=new WeakMap,xt=new WeakMap,$e=new WeakMap,l(Rs,"DataFrameRow");let H=Rs;var mt=(c=>(c.Character="character",c.Double="double",c.Logical="logical",c.Integer="integer",c))(mt||{});const $s=class $s extends Array{constructor(e,s,i,n){super(s.length);ct(this,Te);ct(this,wt);ct(this,re);ct(this,Yt);for(let r=0;r<s.length;r++)this[r]=s[r];if(V(this,Te,e),s.type!==void 0?V(this,wt,s.type):s.every(r=>typeof r=="string"||r===null||r===void 0)?V(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)?V(this,wt,"logical"):V(this,wt,"integer"):s.every(r=>typeof r=="number"||r===null||r===void 0)?V(this,wt,"double"):s.every(r=>typeof r=="boolean"||r===null||r===void 0)?V(this,wt,"logical"):V(this,wt,"character"),V(this,Yt,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?V(this,re,i):V(this,re,void 0)}get name(){return R(this,Te)}get type(){return R(this,wt)}get rowNames(){return R(this,re)}row(e){if(!R(this,Yt))throw new Error("No parent DataFrame attached to this column.");return R(this,Yt).row(e)}rows(...e){if(!R(this,Yt))throw new Error("No parent DataFrame attached to this column.");return R(this,Yt).rows(...e)}};Te=new WeakMap,wt=new WeakMap,re=new WeakMap,Yt=new WeakMap,l($s,"DataFrameColumn");let $t=$s;const De=class De 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 o=0;o<e.length;o++){const a=[];for(let h=0;h<s.length;h++)a.push(s[h][o]);r.push(a)}s=r}super(s.length);ct(this,zt);ct(this,dt);ct(this,Fe);if(s.forEach((r,o)=>{r instanceof $t?this[o]=r:this[o]=new $t(e[o],r,i,this)}),V(this,zt,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&&V(this,dt,i),n&&n.length!==this.length)throw new Error("Classes length must match the number of columns in the DataFrame.");n&&n.length>0&&V(this,Fe,n)}get classes(){return R(this,Fe)}getColumnByName(e){const s=R(this,zt).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 H(R(this,zt),[],void 0,this,e);const s=[];for(let i of this){let n=i[e];s.push(n)}return new H(R(this,zt),s,R(this,dt)?R(this,dt)[e]:void 0,this,e)}getRowByName(e){if(!R(this,dt))return;const s=R(this,dt).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},(o,a)=>this.getRowByIndex(a)),n=R(this,dt)}else e.length===1&&Array.isArray(e[0])?s=e[0]:s=e,i=s.map((r,o)=>{let a=this.row(r);return R(this,dt)&&a&&(n==null||n.push(R(this,dt)[o])),a}).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,zt)):(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 De(n,i,R(this,dt))}subset(e,s){const i=s&&s.length>0?this.cols(...s):this.slice();return new De(i.map(n=>n.name),i.map(n=>n.values),R(this,dt))}get names(){return R(this,zt)}get rowNames(){return R(this,dt)}get nrow(){return this[0]?this[0].length:0}get ncol(){return this.length}};zt=new WeakMap,dt=new WeakMap,Fe=new WeakMap,l(De,"DataFrame");let Gt=De;const Ts=class Ts{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 Gt,this._nodes=t.nodes??new Gt,this._edges=t.edges??new Gt,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}};l(Ts,"Model");let He=Ts;const Ti=globalThis.__QEVIZ_DEBUG__===!0;function Jt(...c){Ti&&console.log(...c)}l(Jt,"dbg");function Ns(c,t){var r,o,a,h;["nodes","edges","points","groups","confidence","outlier","trajectories","networks","pointsets"].forEach(g=>{var j;const f=t[g];if(!((j=f==null?void 0:f.data)!=null&&j.length))return;const m=f.data,_=f.types||{},d=Object.keys(m[0]),u=m.map(Y=>Object.values(Y)),b=d.map(Y=>_[Y]??"character");let p;g==="networks"?p="name":g==="pointsets"?p="id":g==="nodes"?p=t.node_id_col??d.find(Y=>(_[Y]??"character")==="character"):g==="edges"||g==="points"||g==="trajectories"?p=t.id_col??d.find(Y=>(_[Y]??"character")==="character"):p=t.group_col??d.find(Y=>(_[Y]??"character")==="character");const w=p?d.indexOf(p):0,I=u.map(Y=>String(Y[w]));c.setByKey(g,new Gt(d,u,I,b))}),c.setByKey("updated",t.updated??Date.now()),t.directed!==void 0&&(c.directed=t.directed),Array.isArray(t.palette)&&(c.palette=t.palette.map(String));const s=c.nodes;c.node_id_col=t.node_id_col??((r=s==null?void 0:s.names)==null?void 0:r.find(g=>{var f;return((f=s.col(g))==null?void 0:f.type)==="character"}))??"id";const i=c.points;c.unit_id_col=t.id_col??((o=i==null?void 0:i.names)==null?void 0:o.find(g=>{var f;return((f=i.col(g))==null?void 0:f.type)==="character"}))??"id";const n=c.unit_id_col;if(c.group_col=t.group_col??((a=i==null?void 0:i.names)==null?void 0:a.find(g=>{var f;return g!==n&&((f=i.col(g))==null?void 0:f.type)==="character"}))??null,(h=s==null?void 0:s.names)!=null&&h.length){const g=c.node_id_col,f=t.x_col,m=t.y_col;if(f&&m)c.dimensions=[f,m];else{const _=s.names.filter(d=>{if(d===g)return!1;const u=s.col(d);return u&&u.type!=="character"&&u.type!=="logical"});_.length>=2&&(c.dimensions=[f??_[0],m??_[1]])}}}l(Ns,"ingestModelData");function oi(c){const t=new He;return Ns(t,c),t}l(oi,"modelFromData");const ai="http://www.w3.org/1999/xhtml",as=class as{constructor(t){this.data=t,this.nodeType=3,this.parentNode=null}get textContent(){return this.data}set textContent(t){this.data=String(t)}get nodeValue(){return this.data}cloneNode(){return new as(this.data)}};l(as,"HeadlessText");let Qt=as;const Fs=class Fs extends Qt{};l(Fs,"HeadlessRaw");let fe=Fs;const hi=l(c=>c.replace(/[A-Z]/g,t=>"-"+t.toLowerCase()),"camelToKebab"),qt=class qt{constructor(t,e=ai){this.nodeType=1,this.parentNode=null,this.childNodes=[],this.shadowRoot=null,this._attrs=new Map,this._style=new Map,this.tagName=t??this.constructor.tagName??"div",this.namespaceURI=e;const s=this;this.style=new Proxy({},{get(r,o){if(typeof o=="string")return o==="cssText"?s._cssText():o==="setProperty"?(a,h)=>s._setStyle(a,h):o==="removeProperty"?a=>s._setStyle(a,""):o==="getPropertyValue"?a=>s._style.get(a)??"":s._style.get(hi(o))??""},set(r,o,a){return typeof o=="string"&&s._setStyle(hi(o),a==null?"":String(a)),!0}});const i=l(()=>(this._attrs.get("class")??"").split(/\s+/).filter(Boolean),"classes"),n=l(r=>{r.length?this.setAttribute("class",r.join(" ")):this.removeAttribute("class")},"write");this.classList={add:l((...r)=>{const o=i();r.forEach(a=>{o.includes(a)||o.push(a)}),n(o)},"add"),remove:l((...r)=>n(i().filter(o=>!r.includes(o))),"remove"),contains:l(r=>i().includes(r),"contains"),toggle:l((r,o)=>{const a=i().includes(r),h=o??!a;return h&&!a&&s.classList.add(r),!h&&a&&s.classList.remove(r),h},"toggle")}}_setStyle(t,e){e===""?this._style.delete(t):this._style.set(t,e);const s=this._cssText();s?this.setAttribute("style",s):this.removeAttribute("style")}_cssText(){return[...this._style.entries()].map(([t,e])=>`${t}: ${e};`).join(" ")}getAttribute(t){return this._attrs.has(t)?this._attrs.get(t):null}hasAttribute(t){return this._attrs.has(t)}setAttribute(t,e){this._attrs.set(t,String(e)),t==="style"&&this._syncStyleFromAttribute()}removeAttribute(t){this._attrs.delete(t),t==="style"&&this._style.clear()}getAttributeNames(){return[...this._attrs.keys()]}_syncStyleFromAttribute(){const t=this._attrs.get("style")??"",e=new Map;t.split(";").forEach(s=>{const i=s.indexOf(":");if(i<0)return;const n=s.slice(0,i).trim(),r=s.slice(i+1).trim();n&&r&&e.set(n,r)}),this._style=e}get id(){return this.getAttribute("id")??""}set id(t){this.setAttribute("id",t)}get className(){return this.getAttribute("class")??""}set className(t){this.setAttribute("class",t)}get nodeName(){return this.tagName}get localName(){return this.tagName.toLowerCase()}get parentElement(){return this.parentNode}get children(){return this.childNodes.filter(t=>t instanceof qt)}get firstChild(){return this.childNodes[0]??null}get lastChild(){return this.childNodes[this.childNodes.length-1]??null}get firstElementChild(){return this.children[0]??null}get isConnected(){return!0}get ownerSVGElement(){let t=this.parentNode;for(;t;){if(t.tagName.toLowerCase()==="svg")return t;t=t.parentNode}return null}appendChild(t){return this.insertBefore(t,null)}insertBefore(t,e){t.parentNode&&t.parentNode.removeChild(t);const s=e?this.childNodes.indexOf(e):-1;return s<0?this.childNodes.push(t):this.childNodes.splice(s,0,t),t.parentNode=this,t}removeChild(t){const e=this.childNodes.indexOf(t);return e>=0&&(this.childNodes.splice(e,1),t.parentNode=null),t}replaceChild(t,e){const s=this.childNodes.indexOf(e);return s<0||(t.parentNode&&t.parentNode.removeChild(t),this.childNodes[s]=t,t.parentNode=this,e.parentNode=null),e}remove(){var t;(t=this.parentNode)==null||t.removeChild(this)}replaceWith(t){var e;(e=this.parentNode)==null||e.replaceChild(t,this)}contains(t){let e=t;for(;e;){if(e===this)return!0;e=e.parentNode}return!1}get textContent(){return this.childNodes.map(t=>t.textContent).join("")}set textContent(t){this.childNodes.forEach(e=>{e.parentNode=null}),this.childNodes=[],t!=null&&t!==""&&this.appendChild(new Qt(String(t)))}set innerHTML(t){this.textContent="",t&&this.appendChild(new fe(t))}get innerHTML(){return this.childNodes.map(t=>t instanceof qt?Ze(t,!1):t instanceof fe?t.data:li(t.data)).join("")}cloneNode(t=!1){const e=new qt(this.tagName,this.namespaceURI);return this._attrs.forEach((s,i)=>e._attrs.set(i,s)),e._syncStyleFromAttribute(),t&&this.childNodes.forEach(s=>e.appendChild(s instanceof qt?s.cloneNode(!0):s.cloneNode())),e}attachShadow(t){return this.shadowRoot=new qt("#shadow-root",null),this.shadowRoot.parentNode=this,this.shadowRoot}matches(t){return t.split(",").some(e=>Fi(this,e.trim()))}closest(t){let e=this;for(;e;){if(e.tagName!=="#shadow-root"&&e.matches(t))return e;e=e.parentNode}return null}querySelector(t){for(const e of this.children){if(e.matches(t))return e;const s=e.querySelector(t);if(s)return s}return null}querySelectorAll(t){const e=[],s=l(i=>i.children.forEach(n=>{n.matches(t)&&e.push(n),s(n)}),"walk");return s(this),e}getElementById(t){return this.querySelector(`#${t}`)}getBoundingClientRect(){const t=l(i=>{const n=Number(this.getAttribute(i));return Number.isFinite(n)&&n>0?n:0},"num"),e=t("width"),s=t("height");return{x:0,y:0,left:0,top:0,width:e,height:s,right:e,bottom:s}}get clientWidth(){return this.getBoundingClientRect().width}get clientHeight(){return this.getBoundingClientRect().height}addEventListener(){}removeEventListener(){}dispatchEvent(){return!0}};l(qt,"HeadlessElement");let te=qt;function Fi(c,t){if(!t||t==="*")return!!t;const s=/^([a-zA-Z][\w-]*)?((?:#[\w-]+|\.[\w-]+|\[[^\]]+\])*)$/.exec(t);return!s||s[1]&&s[1].toLowerCase()!==c.tagName.toLowerCase()?!1:(s[2].match(/#[\w-]+|\.[\w-]+|\[[^\]]+\]/g)??[]).every(n=>{if(n[0]==="#")return c.getAttribute("id")===n.slice(1);if(n[0]===".")return c.classList.contains(n.slice(1));const r=/^\[([^=~|^$*\]]+)(?:([~|^$*]?)=["']?([^"'\]]*)["']?)?\]$/.exec(n);if(!r)return!1;const o=r[1].trim();if(r[3]===void 0)return c.hasAttribute(o);const a=c.getAttribute(o);if(a==null)return!1;switch(r[2]){case"^":return a.startsWith(r[3]);case"$":return a.endsWith(r[3]);case"*":return a.includes(r[3]);case"~":return a.split(/\s+/).includes(r[3]);default:return a===r[3]}})}l(Fi,"matchesSimple");const Ds=class Ds{constructor(){this.headless=!0}createElement(t){return new te(t.toLowerCase(),ai)}createElementNS(t,e){return new te(e,t)}createTextNode(t){return new Qt(t)}};l(Ds,"HeadlessDocument");let Ve=Ds;const me=new Ve,Di=l(c=>c.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),"escapeAttr"),li=l(c=>c.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),"escapeText");function Ze(c,t=!0){const e=[],s=l((i,n)=>{if(i instanceof fe){e.push(i.data);return}if(i instanceof Qt){e.push(li(i.data));return}if(i.tagName!=="#shadow-root"){if(e.push("<",i.tagName),t&&i.namespaceURI&&i.namespaceURI!==n&&!i.hasAttribute("xmlns")&&e.push(` xmlns="${i.namespaceURI}"`),i.getAttributeNames().forEach(r=>e.push(` ${r}="${Di(i.getAttribute(r))}"`)),i.childNodes.length===0){e.push("/>");return}e.push(">"),i.childNodes.forEach(r=>s(r,i.namespaceURI)),e.push("</",i.tagName,">")}},"write");return s(c,null),e.join("")}l(Ze,"serializeElement");const ji=.6,Yi=1.2,qi=.9;function Bi(c){const t=c.textContent??"",e=Number(c.getAttribute("font-size")),s=Number(c.getAttribute("x")??0),i=Number(c.getAttribute("y")??0);if(!t||!(e>0)||!Number.isFinite(s)||!Number.isFinite(i))return null;const n=t.length*e*ji,r=c.getAttribute("text-anchor")??"start";return{x:r==="end"?s-n:r==="middle"?s-n/2:s,y:i-e*qi,width:n,height:e*Yi}}l(Bi,"estimateTextBox");function Gi(c){let t=[1,0,0,1,0,0];if(!c)return t;const e=l((s,i)=>[s[0]*i[0]+s[2]*i[1],s[1]*i[0]+s[3]*i[1],s[0]*i[2]+s[2]*i[3],s[1]*i[2]+s[3]*i[3],s[0]*i[4]+s[2]*i[5]+s[4],s[1]*i[4]+s[3]*i[5]+s[5]],"mul");for(const s of c.matchAll(/(matrix|translate|scale)\s*\(([^)]*)\)/g)){const i=s[2].trim().split(/[\s,]+/).map(Number);s[1]==="matrix"&&i.length===6?t=e(t,i):s[1]==="translate"?t=e(t,[1,0,0,1,i[0]||0,i[1]||0]):s[1]==="scale"&&(t=e(t,[i[0]??1,0,0,i[1]??i[0]??1,0,0]))}return t}l(Gi,"parseTransform");function Ui(c){const[t,e,s,i,n,r]=c,o=t*i-e*s;return o?[i/o,-e/o,-s/o,t/o,(s*r-i*n)/o,(e*n-t*r)/o]:null}l(Ui,"invertTransform");function Xi(c,t,e){const s=(c??"").trim().split(/[\s,]+/).map(Number);if(s.length!==4||!s.every(Number.isFinite)||!(s[2]>0)||!(s[3]>0))return null;const[i,n,r,o]=s;if(!(t>0)||!(e>0))return{left:i,right:i+r,top:n,bottom:n+o};const a=Math.min(t/r,e/o),h=t/a,g=e/a,f=i-(h-r)/2,m=n-(g-o)/2;return{left:f,right:f+h,top:m,bottom:m+g}}l(Xi,"visibleViewBox");function ci(){return typeof document<"u"?document:me}l(ci,"defaultDocument");function ui(c){return!!c&&c.headless===!0}l(ui,"isHeadlessDocument");const St=typeof HTMLElement<"u"?HTMLElement:te;function Et(c,t){typeof customElements>"u"||customElements.get(c)||customElements.define(c,t)}l(Et,"defineElement");const Wi={get:l(c=>{const t=[...document.querySelectorAll("qe-graph")];return typeof c=="number"&&c>=0?t[c]:t},"get")},oe=class oe extends St{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 He;const t=this.attachShadow({mode:"open"}),e=ci(),s=e.createElement("style");s.textContent=oe.styles,t.appendChild(s),this._outputElement=e.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(){Jt("QEVisualElement connected"),this.render()}setModelData(t){Ns(this._model,t),this.updated=this._model.updated!==void 0?String(this._model.updated):String(Date.now()),Jt("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."}};l(oe,"QEVisualElement"),oe.tagName="qe-visual",oe.styles=`
|
|
1
|
+
(function(L,ct){typeof exports=="object"&&typeof module<"u"?ct(exports):typeof define=="function"&&define.amd?define(["exports"],ct):(L=typeof globalThis<"u"?globalThis:L||self,ct(L.QEViz={}))})(this,(function(L){"use strict";var pr=Object.defineProperty;var En=L=>{throw TypeError(L)};var l=(L,ct)=>pr(L,"name",{value:ct,configurable:!0});var Nn=(L,ct,$t)=>ct.has(L)||En("Cannot "+$t);var U=(L,ct,$t)=>(Nn(L,ct,"read from private field"),$t?$t.call(L):ct.get(L)),Et=(L,ct,$t)=>ct.has(L)?En("Cannot add the same private member more than once"):ct instanceof WeakSet?ct.add(L):ct.set(L,$t),ut=(L,ct,$t,te)=>(Nn(L,ct,"write to private field"),te?te.call(L,$t):ct.set(L,$t),$t);var as,hs,ls,Yt,cs,us,Bt,Ie,ae,Ht,zt,ds,me,Vt,Pe,Oe,ps;const hi=class hi extends Array{constructor(e,s,i,n,r){super(...s);Et(this,as);Et(this,hs);Et(this,ls);Et(this,Yt);Et(this,cs);ut(this,ls,e),ut(this,hs,i),ut(this,Yt,n),ut(this,cs,n==null?void 0:n.classes),ut(this,as,r)}get parent(){return U(this,Yt)}get names(){return U(this,ls)}get rowName(){return U(this,hs)}get types(){if(!U(this,Yt))throw new Error("No parent DataFrame attached to this row.");return U(this,Yt).types}get classes(){return U(this,cs)}get rowNumber(){return U(this,as)}col(e){if(!U(this,Yt))throw new Error("No parent DataFrame attached to this row.");return U(this,Yt).col(e)}cols(...e){if(!U(this,Yt))throw new Error("No parent DataFrame attached to this row.");return U(this,Yt).cols(...e)}filter(e){console.error("DataFrameRow does not currently support filtering.")}};as=new WeakMap,hs=new WeakMap,ls=new WeakMap,Yt=new WeakMap,cs=new WeakMap,l(hi,"DataFrameRow");let ct=hi;var $t=(c=>(c.Character="character",c.Double="double",c.Logical="logical",c.Integer="integer",c))($t||{});const li=class li extends Array{constructor(e,s,i,n){super(s.length);Et(this,us);Et(this,Bt);Et(this,Ie);Et(this,ae);for(let r=0;r<s.length;r++)this[r]=s[r];if(ut(this,us,e),s.type!==void 0?ut(this,Bt,s.type):s.every(r=>typeof r=="string"||r===null||r===void 0)?ut(this,Bt,"character"):s.every(r=>Number.isInteger(r)||r===null||r===void 0)?s.every(r=>r===0||r===1||r===null||r===void 0)?ut(this,Bt,"logical"):ut(this,Bt,"integer"):s.every(r=>typeof r=="number"||r===null||r===void 0)?ut(this,Bt,"double"):s.every(r=>typeof r=="boolean"||r===null||r===void 0)?ut(this,Bt,"logical"):ut(this,Bt,"character"),ut(this,ae,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?ut(this,Ie,i):ut(this,Ie,void 0)}get name(){return U(this,us)}get type(){return U(this,Bt)}get rowNames(){return U(this,Ie)}row(e){if(!U(this,ae))throw new Error("No parent DataFrame attached to this column.");return U(this,ae).row(e)}rows(...e){if(!U(this,ae))throw new Error("No parent DataFrame attached to this column.");return U(this,ae).rows(...e)}};us=new WeakMap,Bt=new WeakMap,Ie=new WeakMap,ae=new WeakMap,l(li,"DataFrameColumn");let te=li;const _s=class _s 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 o=0;o<e.length;o++){const a=[];for(let h=0;h<s.length;h++)a.push(s[h][o]);r.push(a)}s=r}super(s.length);Et(this,Ht);Et(this,zt);Et(this,ds);if(s.forEach((r,o)=>{r instanceof te?this[o]=r:this[o]=new te(e[o],r,i,this)}),ut(this,Ht,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&&ut(this,zt,i),n&&n.length!==this.length)throw new Error("Classes length must match the number of columns in the DataFrame.");n&&n.length>0&&ut(this,ds,n)}get classes(){return U(this,ds)}getColumnByName(e){const s=U(this,Ht).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 ct(U(this,Ht),[],void 0,this,e);const s=[];for(let i of this){let n=i[e];s.push(n)}return new ct(U(this,Ht),s,U(this,zt)?U(this,zt)[e]:void 0,this,e)}getRowByName(e){if(!U(this,zt))return;const s=U(this,zt).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},(o,a)=>this.getRowByIndex(a)),n=U(this,zt)}else e.length===1&&Array.isArray(e[0])?s=e[0]:s=e,i=s.map((r,o)=>{let a=this.row(r);return U(this,zt)&&a&&(n==null||n.push(U(this,zt)[o])),a}).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=U(this,Ht)):(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 _s(n,i,U(this,zt))}subset(e,s){const i=s&&s.length>0?this.cols(...s):this.slice();return new _s(i.map(n=>n.name),i.map(n=>n.values),U(this,zt))}get names(){return U(this,Ht)}get rowNames(){return U(this,zt)}get nrow(){return this[0]?this[0].length:0}get ncol(){return this.length}};Ht=new WeakMap,zt=new WeakMap,ds=new WeakMap,l(_s,"DataFrame");let de=_s;const ci=class ci{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 de,this._nodes=t.nodes??new de,this._edges=t.edges??new de,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}};l(ci,"Model");let As=ci;const Mn=globalThis.__QEVIZ_DEBUG__===!0;function Ae(...c){Mn&&console.log(...c)}l(Ae,"dbg");function Zs(c,t){var r,o,a,h;["nodes","edges","points","groups","confidence","outlier","trajectories","networks","pointsets"].forEach(_=>{var S;const p=t[_];if(!((S=p==null?void 0:p.data)!=null&&S.length))return;const b=p.data,d=p.types||{},f=Object.keys(b[0]),u=b.map(v=>Object.values(v)),g=f.map(v=>d[v]??"character");let y;_==="networks"?y="name":_==="pointsets"?y="id":_==="nodes"?y=t.node_id_col??f.find(v=>(d[v]??"character")==="character"):_==="edges"||_==="points"||_==="trajectories"?y=t.id_col??f.find(v=>(d[v]??"character")==="character"):y=t.group_col??f.find(v=>(d[v]??"character")==="character");const m=y?f.indexOf(y):0,w=u.map(v=>String(v[m]));c.setByKey(_,new de(f,u,w,g))}),c.setByKey("updated",t.updated??Date.now()),t.directed!==void 0&&(c.directed=t.directed),Array.isArray(t.palette)&&(c.palette=t.palette.map(String));const s=c.nodes;c.node_id_col=t.node_id_col??((r=s==null?void 0:s.names)==null?void 0:r.find(_=>{var p;return((p=s.col(_))==null?void 0:p.type)==="character"}))??"id";const i=c.points;c.unit_id_col=t.id_col??((o=i==null?void 0:i.names)==null?void 0:o.find(_=>{var p;return((p=i.col(_))==null?void 0:p.type)==="character"}))??"id";const n=c.unit_id_col;if(c.group_col=t.group_col??((a=i==null?void 0:i.names)==null?void 0:a.find(_=>{var p;return _!==n&&((p=i.col(_))==null?void 0:p.type)==="character"}))??null,(h=s==null?void 0:s.names)!=null&&h.length){const _=c.node_id_col,p=t.x_col,b=t.y_col,d=t.z_col;if(p&&b)c.dimensions=d?[p,b,d]:[p,b];else{const f=s.names.filter(u=>{if(u===_)return!1;const g=s.col(u);return g&&g.type!=="character"&&g.type!=="logical"});f.length>=2&&(c.dimensions=[p??f[0],b??f[1]])}}}l(Zs,"ingestModelData");function Ti(c){const t=new As;return Zs(t,c),t}l(Ti,"modelFromData");const Di="http://www.w3.org/1999/xhtml",Os=class Os{constructor(t){this.data=t,this.nodeType=3,this.parentNode=null}get textContent(){return this.data}set textContent(t){this.data=String(t)}get nodeValue(){return this.data}cloneNode(){return new Os(this.data)}};l(Os,"HeadlessText");let Se=Os;const ui=class ui extends Se{};l(ui,"HeadlessRaw");let je=ui;const Fi=l(c=>c.replace(/[A-Z]/g,t=>"-"+t.toLowerCase()),"camelToKebab"),he=class he{constructor(t,e=Di){this.nodeType=1,this.parentNode=null,this.childNodes=[],this.shadowRoot=null,this._attrs=new Map,this._style=new Map,this.tagName=t??this.constructor.tagName??"div",this.namespaceURI=e;const s=this;this.style=new Proxy({},{get(r,o){if(typeof o=="string")return o==="cssText"?s._cssText():o==="setProperty"?(a,h)=>s._setStyle(a,h):o==="removeProperty"?a=>s._setStyle(a,""):o==="getPropertyValue"?a=>s._style.get(a)??"":s._style.get(Fi(o))??""},set(r,o,a){return typeof o=="string"&&s._setStyle(Fi(o),a==null?"":String(a)),!0}});const i=l(()=>(this._attrs.get("class")??"").split(/\s+/).filter(Boolean),"classes"),n=l(r=>{r.length?this.setAttribute("class",r.join(" ")):this.removeAttribute("class")},"write");this.classList={add:l((...r)=>{const o=i();r.forEach(a=>{o.includes(a)||o.push(a)}),n(o)},"add"),remove:l((...r)=>n(i().filter(o=>!r.includes(o))),"remove"),contains:l(r=>i().includes(r),"contains"),toggle:l((r,o)=>{const a=i().includes(r),h=o??!a;return h&&!a&&s.classList.add(r),!h&&a&&s.classList.remove(r),h},"toggle")}}_setStyle(t,e){e===""?this._style.delete(t):this._style.set(t,e);const s=this._cssText();s?this.setAttribute("style",s):this.removeAttribute("style")}_cssText(){return[...this._style.entries()].map(([t,e])=>`${t}: ${e};`).join(" ")}getAttribute(t){return this._attrs.has(t)?this._attrs.get(t):null}hasAttribute(t){return this._attrs.has(t)}setAttribute(t,e){this._attrs.set(t,String(e)),t==="style"&&this._syncStyleFromAttribute()}removeAttribute(t){this._attrs.delete(t),t==="style"&&this._style.clear()}getAttributeNames(){return[...this._attrs.keys()]}_syncStyleFromAttribute(){const t=this._attrs.get("style")??"",e=new Map;t.split(";").forEach(s=>{const i=s.indexOf(":");if(i<0)return;const n=s.slice(0,i).trim(),r=s.slice(i+1).trim();n&&r&&e.set(n,r)}),this._style=e}get id(){return this.getAttribute("id")??""}set id(t){this.setAttribute("id",t)}get className(){return this.getAttribute("class")??""}set className(t){this.setAttribute("class",t)}get nodeName(){return this.tagName}get localName(){return this.tagName.toLowerCase()}get parentElement(){return this.parentNode}get children(){return this.childNodes.filter(t=>t instanceof he)}get firstChild(){return this.childNodes[0]??null}get lastChild(){return this.childNodes[this.childNodes.length-1]??null}get firstElementChild(){return this.children[0]??null}get isConnected(){return!0}get ownerSVGElement(){let t=this.parentNode;for(;t;){if(t.tagName.toLowerCase()==="svg")return t;t=t.parentNode}return null}appendChild(t){return this.insertBefore(t,null)}insertBefore(t,e){t.parentNode&&t.parentNode.removeChild(t);const s=e?this.childNodes.indexOf(e):-1;return s<0?this.childNodes.push(t):this.childNodes.splice(s,0,t),t.parentNode=this,t}removeChild(t){const e=this.childNodes.indexOf(t);return e>=0&&(this.childNodes.splice(e,1),t.parentNode=null),t}replaceChild(t,e){const s=this.childNodes.indexOf(e);return s<0||(t.parentNode&&t.parentNode.removeChild(t),this.childNodes[s]=t,t.parentNode=this,e.parentNode=null),e}remove(){var t;(t=this.parentNode)==null||t.removeChild(this)}replaceWith(t){var e;(e=this.parentNode)==null||e.replaceChild(t,this)}contains(t){let e=t;for(;e;){if(e===this)return!0;e=e.parentNode}return!1}get textContent(){return this.childNodes.map(t=>t.textContent).join("")}set textContent(t){this.childNodes.forEach(e=>{e.parentNode=null}),this.childNodes=[],t!=null&&t!==""&&this.appendChild(new Se(String(t)))}set innerHTML(t){this.textContent="",t&&this.appendChild(new je(t))}get innerHTML(){return this.childNodes.map(t=>t instanceof he?Es(t,!1):t instanceof je?t.data:ji(t.data)).join("")}cloneNode(t=!1){const e=new he(this.tagName,this.namespaceURI);return this._attrs.forEach((s,i)=>e._attrs.set(i,s)),e._syncStyleFromAttribute(),t&&this.childNodes.forEach(s=>e.appendChild(s instanceof he?s.cloneNode(!0):s.cloneNode())),e}attachShadow(t){return this.shadowRoot=new he("#shadow-root",null),this.shadowRoot.parentNode=this,this.shadowRoot}matches(t){return t.split(",").some(e=>kn(this,e.trim()))}closest(t){let e=this;for(;e;){if(e.tagName!=="#shadow-root"&&e.matches(t))return e;e=e.parentNode}return null}querySelector(t){for(const e of this.children){if(e.matches(t))return e;const s=e.querySelector(t);if(s)return s}return null}querySelectorAll(t){const e=[],s=l(i=>i.children.forEach(n=>{n.matches(t)&&e.push(n),s(n)}),"walk");return s(this),e}getElementById(t){return this.querySelector(`#${t}`)}getBoundingClientRect(){const t=l(i=>{const n=Number(this.getAttribute(i));return Number.isFinite(n)&&n>0?n:0},"num"),e=t("width"),s=t("height");return{x:0,y:0,left:0,top:0,width:e,height:s,right:e,bottom:s}}get clientWidth(){return this.getBoundingClientRect().width}get clientHeight(){return this.getBoundingClientRect().height}addEventListener(){}removeEventListener(){}dispatchEvent(){return!0}};l(he,"HeadlessElement");let Ee=he;function kn(c,t){if(!t||t==="*")return!!t;const s=/^([a-zA-Z][\w-]*)?((?:#[\w-]+|\.[\w-]+|\[[^\]]+\])*)$/.exec(t);return!s||s[1]&&s[1].toLowerCase()!==c.tagName.toLowerCase()?!1:(s[2].match(/#[\w-]+|\.[\w-]+|\[[^\]]+\]/g)??[]).every(n=>{if(n[0]==="#")return c.getAttribute("id")===n.slice(1);if(n[0]===".")return c.classList.contains(n.slice(1));const r=/^\[([^=~|^$*\]]+)(?:([~|^$*]?)=["']?([^"'\]]*)["']?)?\]$/.exec(n);if(!r)return!1;const o=r[1].trim();if(r[3]===void 0)return c.hasAttribute(o);const a=c.getAttribute(o);if(a==null)return!1;switch(r[2]){case"^":return a.startsWith(r[3]);case"$":return a.endsWith(r[3]);case"*":return a.includes(r[3]);case"~":return a.split(/\s+/).includes(r[3]);default:return a===r[3]}})}l(kn,"matchesSimple");const di=class di{constructor(){this.headless=!0}createElement(t){return new Ee(t.toLowerCase(),Di)}createElementNS(t,e){return new Ee(e,t)}createTextNode(t){return new Se(t)}};l(di,"HeadlessDocument");let Ss=di;const qe=new Ss,In=l(c=>c.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),"escapeAttr"),ji=l(c=>c.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),"escapeText");function Es(c,t=!0){const e=[],s=l((i,n)=>{if(i instanceof je){e.push(i.data);return}if(i instanceof Se){e.push(ji(i.data));return}if(i.tagName!=="#shadow-root"){if(e.push("<",i.tagName),t&&i.namespaceURI&&i.namespaceURI!==n&&!i.hasAttribute("xmlns")&&e.push(` xmlns="${i.namespaceURI}"`),i.getAttributeNames().forEach(r=>e.push(` ${r}="${In(i.getAttribute(r))}"`)),i.childNodes.length===0){e.push("/>");return}e.push(">"),i.childNodes.forEach(r=>s(r,i.namespaceURI)),e.push("</",i.tagName,">")}},"write");return s(c,null),e.join("")}l(Es,"serializeElement");const Cn=.6,zn=1.2,Pn=.9;function On(c){const t=c.textContent??"",e=Number(c.getAttribute("font-size")),s=Number(c.getAttribute("x")??0),i=Number(c.getAttribute("y")??0);if(!t||!(e>0)||!Number.isFinite(s)||!Number.isFinite(i))return null;const n=t.length*e*Cn,r=c.getAttribute("text-anchor")??"start";return{x:r==="end"?s-n:r==="middle"?s-n/2:s,y:i-e*Pn,width:n,height:e*zn}}l(On,"estimateTextBox");function Ln(c){let t=[1,0,0,1,0,0];if(!c)return t;const e=l((s,i)=>[s[0]*i[0]+s[2]*i[1],s[1]*i[0]+s[3]*i[1],s[0]*i[2]+s[2]*i[3],s[1]*i[2]+s[3]*i[3],s[0]*i[4]+s[2]*i[5]+s[4],s[1]*i[4]+s[3]*i[5]+s[5]],"mul");for(const s of c.matchAll(/(matrix|translate|scale)\s*\(([^)]*)\)/g)){const i=s[2].trim().split(/[\s,]+/).map(Number);s[1]==="matrix"&&i.length===6?t=e(t,i):s[1]==="translate"?t=e(t,[1,0,0,1,i[0]||0,i[1]||0]):s[1]==="scale"&&(t=e(t,[i[0]??1,0,0,i[1]??i[0]??1,0,0]))}return t}l(Ln,"parseTransform");function $n(c){const[t,e,s,i,n,r]=c,o=t*i-e*s;return o?[i/o,-e/o,-s/o,t/o,(s*r-i*n)/o,(e*n-t*r)/o]:null}l($n,"invertTransform");function Rn(c,t,e){const s=(c??"").trim().split(/[\s,]+/).map(Number);if(s.length!==4||!s.every(Number.isFinite)||!(s[2]>0)||!(s[3]>0))return null;const[i,n,r,o]=s;if(!(t>0)||!(e>0))return{left:i,right:i+r,top:n,bottom:n+o};const a=Math.min(t/r,e/o),h=t/a,_=e/a,p=i-(h-r)/2,b=n-(_-o)/2;return{left:p,right:p+h,top:b,bottom:b+_}}l(Rn,"visibleViewBox");function qi(){return typeof document<"u"?document:qe}l(qi,"defaultDocument");function Yi(c){return!!c&&c.headless===!0}l(Yi,"isHeadlessDocument");const Xt=typeof HTMLElement<"u"?HTMLElement:Ee;function Ut(c,t){typeof customElements>"u"||customElements.get(c)||customElements.define(c,t)}l(Ut,"defineElement");const Tn={get:l(c=>{const t=[...document.querySelectorAll("qe-graph")];return typeof c=="number"&&c>=0?t[c]:t},"get")},Ce=class Ce extends Xt{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 As;const t=this.attachShadow({mode:"open"}),e=qi(),s=e.createElement("style");s.textContent=Ce.styles,t.appendChild(s),this._outputElement=e.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(){Ae("QEVisualElement connected"),this.render()}setModelData(t){Zs(this._model,t),this.updated=this._model.updated!==void 0?String(this._model.updated):String(Date.now()),Ae("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."}};l(Ce,"QEVisualElement"),Ce.tagName="qe-visual",Ce.styles=`
|
|
2
2
|
:host { display: block; width: 100%; }
|
|
3
3
|
:host(.hidden) { display: none !important; }
|
|
4
4
|
/* The output wrapper and the slotted graph fill the host so the plot
|
|
5
5
|
stretches to its container instead of collapsing to intrinsic size. */
|
|
6
6
|
div { display: block; width: 100%; height: 100%; }
|
|
7
7
|
::slotted(qe-graph) { display: block; width: 100%; height: 100%; }
|
|
8
|
-
`;let pe=oe;Et(pe.tagName,pe);const ot=class ot{constructor(t){return this.base=typeof t=="string"?t:t.base,new Proxy(this,{get(e,s){if(typeof s=="string"&&/^[0-2]$/.test(s)){const{r:i,g:n,b:r}=ot.parseColor(e.base);return[i,n,r][Number(s)]}return e[s]}})}toString(){return this.base}setBase(t){this.base=t}static parseColor(t){const e=String(t).trim();if(/^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(e)){const n=parseInt(e.slice(1,7),16);return{r:n>>16&255,g:n>>8&255,b:n&255}}if(/^#[0-9a-f]{3}$/i.test(e)){const[n,r,o]=[1,2,3].map(a=>parseInt(e[a]+e[a],16));return{r:n,g:r,b:o}}const s=e.match(/^rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)/i);if(s)return{r:Math.round(+s[1]),g:Math.round(+s[2]),b:Math.round(+s[3])};const i=ot.resolveCss(e);if(i)return ot.parseColor(i);throw new Error(`Unsupported color format: ${t}`)}static namedColor(t){ot._named||(ot._named=new Map(Hi.split(" ").map(s=>s.split(":"))));const e=ot._named.get(t.trim().toLowerCase());return e?`#${e}`:null}static resolveCss(t){if(ot._cssCache.has(t))return ot._cssCache.get(t);const e=ot.namedColor(t);if(e)return ot._cssCache.set(t,e),e;ot._ctx===void 0&&(ot._ctx=typeof document<"u"?document.createElement("canvas").getContext("2d"):null);let s=null;const i=ot._ctx;if(i){i.fillStyle="#000000",i.fillStyle=t;const n=i.fillStyle;i.fillStyle="#ffffff",i.fillStyle=t;const r=i.fillStyle;n===r&&(s=String(n))}return ot._cssCache.set(t,s),s}static rgb(t,e,s){return`rgb(${t}, ${e}, ${s})`}};l(ot,"Color"),ot._cssCache=new Map;let rt=ot;const je=class je extends rt{constructor(t,e,s){super(t),this.weight=e,this.alpha=s}static toHSV(t){const{r:e,g:s,b:i}=rt.parseColor(t),n=e/255,r=s/255,o=i/255,a=Math.max(n,r,o),h=Math.min(n,r,o),g=a-h,f=a,m=a===0?0:g/a;let _=0;if(g>0)switch(a){case n:_=((r-o)/g+(r<o?6:0))/6;break;case r:_=((o-n)/g+2)/6;break;default:_=((n-r)/g+4)/6}return{h:_*360,s:m,v:f}}static hsvToRgba(t,e,s,i){const n=s*e,r=n*(1-Math.abs(t/60%2-1)),o=s-n;let a=0,h=0,g=0;return t<60?(a=n,h=r,g=0):t<120?(a=r,h=n,g=0):t<180?(a=0,h=n,g=r):t<240?(a=0,h=r,g=n):t<300?(a=r,h=0,g=n):(a=n,h=0,g=r),`rgba(${Math.round((a+o)*255)},${Math.round((h+o)*255)},${Math.round((g+o)*255)},${i.toFixed(4)})`}toString(){const{h:t,v:e}=je.toHSV(this.base),s=Math.min(1,Math.abs(this.weight)),i=this.alpha===void 0?s:Math.min(1,Math.max(0,this.alpha));return je.hsvToRgba(t,s,e,i)}};l(je,"WeightedColor");let be=je;const Hi="aliceblue:f0f8ff antiquewhite:faebd7 aqua:00ffff aquamarine:7fffd4 azure:f0ffff beige:f5f5dc bisque:ffe4c4 black:000000 blanchedalmond:ffebcd blue:0000ff blueviolet:8a2be2 brown:a52a2a burlywood:deb887 cadetblue:5f9ea0 chartreuse:7fff00 chocolate:d2691e coral:ff7f50 cornflowerblue:6495ed cornsilk:fff8dc crimson:dc143c cyan:00ffff darkblue:00008b darkcyan:008b8b darkgoldenrod:b8860b darkgray:a9a9a9 darkgreen:006400 darkgrey:a9a9a9 darkkhaki:bdb76b darkmagenta:8b008b darkolivegreen:556b2f darkorange:ff8c00 darkorchid:9932cc darkred:8b0000 darksalmon:e9967a darkseagreen:8fbc8f darkslateblue:483d8b darkslategray:2f4f4f darkslategrey:2f4f4f darkturquoise:00ced1 darkviolet:9400d3 deeppink:ff1493 deepskyblue:00bfff dimgray:696969 dimgrey:696969 dodgerblue:1e90ff firebrick:b22222 floralwhite:fffaf0 forestgreen:228b22 fuchsia:ff00ff gainsboro:dcdcdc ghostwhite:f8f8ff gold:ffd700 goldenrod:daa520 gray:808080 green:008000 greenyellow:adff2f grey:808080 honeydew:f0fff0 hotpink:ff69b4 indianred:cd5c5c indigo:4b0082 ivory:fffff0 khaki:f0e68c lavender:e6e6fa lavenderblush:fff0f5 lawngreen:7cfc00 lemonchiffon:fffacd lightblue:add8e6 lightcoral:f08080 lightcyan:e0ffff lightgoldenrodyellow:fafad2 lightgray:d3d3d3 lightgreen:90ee90 lightgrey:d3d3d3 lightpink:ffb6c1 lightsalmon:ffa07a lightseagreen:20b2aa lightskyblue:87cefa lightslategray:778899 lightslategrey:778899 lightsteelblue:b0c4de lightyellow:ffffe0 lime:00ff00 limegreen:32cd32 linen:faf0e6 magenta:ff00ff maroon:800000 mediumaquamarine:66cdaa mediumblue:0000cd mediumorchid:ba55d3 mediumpurple:9370db mediumseagreen:3cb371 mediumslateblue:7b68ee mediumspringgreen:00fa9a mediumturquoise:48d1cc mediumvioletred:c71585 midnightblue:191970 mintcream:f5fffa mistyrose:ffe4e1 moccasin:ffe4b5 navajowhite:ffdead navy:000080 oldlace:fdf5e6 olive:808000 olivedrab:6b8e23 orange:ffa500 orangered:ff4500 orchid:da70d6 palegoldenrod:eee8aa palegreen:98fb98 paleturquoise:afeeee palevioletred:db7093 papayawhip:ffefd5 peachpuff:ffdab9 peru:cd853f pink:ffc0cb plum:dda0dd powderblue:b0e0e6 purple:800080 rebeccapurple:663399 red:ff0000 rosybrown:bc8f8f royalblue:4169e1 saddlebrown:8b4513 salmon:fa8072 sandybrown:f4a460 seagreen:2e8b57 seashell:fff5ee sienna:a0522d silver:c0c0c0 skyblue:87ceeb slateblue:6a5acd slategray:708090 slategrey:708090 snow:fffafa springgreen:00ff7f steelblue:4682b4 tan:d2b48c teal:008080 thistle:d8bfd8 tomato:ff6347 turquoise:40e0d0 violet:ee82ee wheat:f5deb3 white:ffffff whitesmoke:f5f5f5 yellow:ffff00 yellowgreen:9acd32",js=class js{constructor(t=null){this._values=[1,0,0,1,0,0],this._keys=["a","b","c","d","e","f"],t&&(this.values=t)}get values(){return this._values}set values(t){t&&t.length===6&&(this._values=t)}get keys(){return this._keys}set keys(t){t&&t.length===6&&(this._keys=t)}toString(){return`matrix(${this.keys.map((e,s)=>this.values[s]).join(" ")})`}toMatrix(){return Object.fromEntries(this._keys.map((t,e)=>[t,this._values[e]]))}toArray(){return this._values}set(t,e){const s=this._keys.indexOf(t);s>=0&&Number.isFinite(e)&&(this._values[s]=e)}get(t){return this._values[this._keys.findIndex(e=>e===t)]}scale(t,e=t){this.a=t,this.d=e}zoom(t){this.a=t,this.d=t}pan(t,e){this.e=this.e+t,this.f=this.f+e}set a(t){this.set("a",t)}set b(t){this.set("b",t)}set c(t){this.set("c",t)}set d(t){this.set("d",t)}set e(t){this.set("e",t)}set f(t){this.set("f",t)}get a(){return this.get("a")}get b(){return this.get("b")}get c(){return this.get("c")}get d(){return this.get("d")}get e(){return this.get("e")}get f(){return this.get("f")}};l(js,"Transform");let ye=js;var xe;(c=>{(t=>{function e(s){return`matrix(${["a","b","c","d","e","f"].map(n=>s[n]).join(" ")})`}l(e,"matrixString"),t.matrixString=e})(c.Matrix||(c.Matrix={})),(t=>{(s=>{function i(r,o,a){const h=e.toRad(o);return[r[0]+a*Math.cos(h),r[1]+a*Math.sin(h)]}l(i,"translate"),s.translate=i;function n(r,o,a){const h=e.toRad(o);function g(f,m){return[f[0]*Math.cos(m)-f[1]*Math.sin(m),f[0]*Math.sin(m)+f[1]*Math.cos(m)]}if(l(g,"rotatePoint"),!a||a[0]===0&&a[1]===0)return g(r,h);{const f=r.map((_,d)=>_-a[d]);return g(f,h).map((_,d)=>_+a[d])}}l(n,"rotate"),s.rotate=n})(t.Point||(t.Point={})),(s=>{function i(u,b){return(b[1]-u[1])/(b[0]-u[0])}l(i,"slope"),s.slope=i;function n(u,b){const p=i(u,b);return u[1]-p*u[0]}l(n,"intercept"),s.intercept=n;function r(u,b){return{slope:i(u,b),intercept:n(u,b)}}l(r,"slopeIntercept"),s.slopeIntercept=r;function o(u,b=0){const p=b,w=(1-p)*u[0][0]+p*u[1][0],I=(1-p)*u[0][1]+p*u[1][1];return[w,I]}l(o,"point_along"),s.point_along=o;function a(u,b,p=.5){return Array.isArray(u[0])&&(b=u[1],u=u[0]),[0,1].map(w=>(parseFloat(u[w])+parseFloat(b[w]))*p)}l(a,"midpoint"),s.midpoint=a;function h(u,b){return Array.isArray(u[0])&&(b=u[1],u=u[0]),Math.sqrt([0,1].map(p=>Math.pow(b[p]-u[p],2)).reduce((p,w)=>p+w,0))}l(h,"length"),s.length=h;function g(u,b=[0,0]){const p=[u[1][0]-b[0],u[1][1]-b[1]],w=[-p[1],p[0]],I=[-w[0],-w[1]],j=[w[0]+b[0],w[1]+b[1]],Y=[I[0]+b[0],I[1]+b[1]];return[j,Y]}l(g,"rotate"),s.rotate=g;function f(u,b,p=90){const w=c.Geometry.Line.slope(u[0],u[1]),I=c.Geometry.Line.intercept(u[0],u[1]),j=[0,I],Y=[1,w+I];u=[j,Y];const st=[u[0][0],u[1][0]],A=[u[0][1],u[1][1]],U=b[0],nt=b[1],Mt=-2*Math.PI*p/360,Lt=st.map((Bt,ue)=>(Bt-U)*Math.cos(Mt)-(A[ue]-nt)*Math.sin(Mt)+U),ws=A.map((Bt,ue)=>(st[ue]-U)*Math.sin(Mt)-(Bt-nt)*Math.cos(Mt)+nt);return[[Lt[0],ws[0]],[Lt[1],ws[1]]]}l(f,"rotate2"),s.rotate2=f;function m(u,b){const[[p,w],[I,j]]=u,[[Y,st],[A,U]]=b,nt=(p-I)*(st-U)-(w-j)*(Y-A),Mt=(p*j-w*I)*(Y-A)-(p-I)*(Y*U-st*A),Lt=(p*j-w*I)*(st-U)-(w-j)*(Y*U-st*A);return[Mt/nt,Lt/nt]}l(m,"intersection"),s.intersection=m;function _(u,b,p){let{slope:w,intercept:I}=c.Geometry.Line.slopeIntercept(u[0],u[1]),j=1+Math.pow(w,2),Y=2*w*I-2*b[1]*w-2*b[0],st=Math.pow(b[0],2)+Math.pow(I,2)+Math.pow(b[1],2)-2*b[1]*I-Math.pow(p,2),A=[[1/0,1/0],[1/0,1/0]];if(Math.sqrt(Math.pow(Y,2)-4*j*st)>=0){let U=(-Y+Math.sqrt(Math.pow(Y,2)-4*j*st))/(2*j),nt=(-Y-Math.sqrt(Math.pow(Y,2)-4*j*st))/(2*j),Mt=w*U+I,Lt=w*nt+I;A=[[U,Mt],[nt,Lt]]}else console.error("The line and the circumference do not intersect");return A}l(_,"intersect_circle"),s.intersect_circle=_;function d(u){return b=>b===0?u[0]:b===1?u[1]:c.Geometry.Point.translate(u[0],c.Geometry.Angle.line(u),c.Geometry.Line.length(u)*b)}l(d,"interpolate"),s.interpolate=d})(t.Line||(t.Line={}));let e;(s=>{function i(o){return o/180*Math.PI}l(i,"toRad"),s.toRad=i;function n(o){return o*180/Math.PI}l(n,"toDeg"),s.toDeg=n;function r(o){if(o.length!==2||!Array.isArray(o[0])||!Array.isArray(o[1])||o[0].length!==2||o[1].length!==2)throw new Error("Invalid line format. Expected [[x1, y1], [x2, y2]].");return c.Geometry.Angle.toDeg(Math.atan2(o[1][1]-o[0][1],o[1][0]-o[0][0]))}l(r,"line"),s.line=r})(e=t.Angle||(t.Angle={}))})(c.Geometry||(c.Geometry={})),(t=>{function e(n){return[...new Set(n)]}l(e,"unique"),t.unique=e;function s(n,r){if(Array.isArray(n)){if(Array.isArray(r)){if(n.length!==r.length)throw new Error("Arrays must be of equal length");return n.map((o,a)=>o/r[a])}return n.map(o=>o/r)}return n/r}l(s,"divide"),t.divide=s;function i(n){return typeof Array.isArray=="function"?Array.isArray(n):n&&typeof n=="object"&&n.constructor.name==="Array"}l(i,"isArray"),t.isArray=i})(c.ArrayTools||(c.ArrayTools={})),(t=>{function e(n){return n.reduce((r,o)=>r+o,0)}l(e,"sum"),t.sum=e;function s(n){return e(n)/n.length}l(s,"mean"),t.mean=s;function i(n,r){const o=Math.pow(10,r);return Math.round(n*o)/o}l(i,"round"),t.round=i})(c.Mathematics||(c.Mathematics={})),(t=>{function e(s,i,n){return new CustomEvent(s,{bubbles:!0,cancelable:!0,detail:{element:i,data:n||(i?i.__data__:void 0)}})}l(e,"createEvent"),t.createEvent=e})(c.Events||(c.Events={})),(t=>{function e(){return location.hash.replace(/#/,"").split(/\//).filter(i=>i).map(i=>i.split(/:/))}l(e,"parts"),t.parts=e;function s(i){return e().flat().findIndex(n=>n===i)>=0}l(s,"exists"),t.exists=s})(c.Hash||(c.Hash={})),(t=>{function e(n,r,o=!1){if(o){if(typeof n!="object"||n===null)return n;for(const a in n)Object.prototype.hasOwnProperty.call(n,a)&&(n[a]=e(n[a],r,o));return new Proxy(n,r)}else return new Proxy(n,r)}l(e,"proxy"),t.proxy=e,t.handler={set(n,r,o){return n[r]=o,window.dispatchEvent(c.Events.createEvent("settingUpdate",window,{target:n,property:r,value:o})),!0},get(n,r){return n[r]}};function s(n,r){const o=r.split(".");let a=n;for(const h of o)if(a&&typeof a=="object"&&Object.prototype.hasOwnProperty.call(a,h))a=a[h];else return;return a}l(s,"get"),t.get=s;function i(n,r,o){const a=r.split(".");let h=n,g;for(g=0;g<a.length-1;g++){const f=a[g];if(h&&typeof h=="object")Object.prototype.hasOwnProperty.call(h,f)||(h[f]={}),h=h[f];else return!1}return h&&typeof h=="object"?(h[a[g]]=o,!0):!1}l(i,"set"),t.set=i})(c.Objects||(c.Objects={})),(t=>{function e(s=window.location){return Object.fromEntries(new URLSearchParams(s.search))}l(e,"parse"),t.parse=e,(s=>{function i(o=window.location.search){return Object.fromEntries(o.replace(/^\?/,"").split(/&/).map(a=>a.split(/=/)))}l(i,"parse2"),s.parse=i;function n(o=window.location.search){return o.replace(/^\?/,"").split(/&/).map(a=>a.split(/=/)[0])}l(n,"keys"),s.keys=n;function r(o,a=window.location.search){return n(a).findIndex(h=>h===o)>=0}l(r,"has"),s.has=r})(t.Query||(t.Query={}))})(c.URL||(c.URL={}))})(xe||(xe={}));const Ys=class Ys{constructor(){this._state=new Map,this.listeners=new Map}get state(){return this._state}hasVariable(t){return this._state.has(t)}getVariable(t){return this._state.get(t)}setVariable(t,e,s){const i=this._state.get(t);this._state.set(t,e),s!=null&&s.lazy||this.notifyListeners(t,e,i)}addListener(t,e,s){this.listeners.has(t)||this.listeners.set(t,new Map);const i=this.listeners.get(t);i.has(e)||i.set(e,new Set),i.get(e).add(s)}removeListener(t,e,s){var i,n;(n=(i=this.listeners.get(t))==null?void 0:i.get(e))==null||n.delete(s)}getListeners(t,e){var s;return Array.from(((s=this.listeners.get(t))==null?void 0:s.get(e))??[])}notifyListeners(t,e,s){const i=this.listeners.get(t);if(i)for(const n of i.values())n.forEach(r=>{typeof r=="function"?r({key:t,newValue:e,oldValue:s}):typeof r.calculate=="function"&&r.calculate.call(r,{key:t,newValue:e,oldValue:s})})}};l(Ys,"EventBus");let Ke=Ys;const{ArrayTools:_i}=xe,Ye=class Ye extends Array{constructor(...t){super(...t)}search(t,e){let s;function i(r){return r.name===e?r:void 0}l(i,"fn");function n(r,o,a=null){if(_i.isArray(r)){for(const[h,g]of r.entries())if(s=n(g,h,a),s)return s}else{if(s=i(r),s)return s;if(r&&_i.isArray(r[t])){for(const[h,g]of r[t].entries())if(s=n(g,h,r),s)return s}}return s}return l(n,"recurse"),n(this)}flatten(){return this.reduce((t,e)=>(t.push(e),e.layers&&Array.isArray(e.layers)&&t.push(...e.layers),t),[])}recurse(t,e,s=null,i=0){let n=new Ye;for(const r of this){let o=e(r,s,i);if(r[t]&&Array.isArray(r[t])){let a=new Ye(...r[t]).recurse(t,e,r,i+1);a!==void 0&&n.push(...a)}n.push(o)}return Jt("Recurse results: ",n),n}};l(Ye,"LayerArray");let ee=Ye;const qs=class qs{constructor(t,e,s){this.__state__=new Ke,this.scale_x=1,this.scale_y=1,this.scale_objects=!0,this.layers=new ee,this.objects=new Map,this.visible=!0,this.ID=t,this.name=e.name||`layer-${t}`,this.tabindex=e.tabindex,this.parent=s,this._transform=new ye,s==null||s.__state__.addListener("graph_updated","live",({key:i,newValue:n,oldValue:r})=>{}),s==null||s.__state__.addListener(`graph_updated_${this.name}`,"live",({key:i,newValue:n,oldValue:r})=>{this.objects=n,this.__state__.setVariable("layer_updated",this)})}get transform(){return this._transform}set transform(t){this._transform=t}};l(qs,"Layer");let Ms=qs;const hs=class hs extends Array{constructor(...e){super(arguments.length);ct(this,Wt,!1);ct(this,Ot);for(let s=0;s<e.length;s++)this[s]=e[s];V(this,Wt,!1)}static fromArray(e){const s=new hs;return e.forEach((i,n)=>{s.push(i)}),V(s,Ot,e.names),s}flip(){V(this,Wt,!R(this,Wt));for(let e=0;e<this.length;e++)this[e]=-this[e];return this}get(e){return typeof e=="number"?this[e]:R(this,Ot)&&R(this,Ot).includes(e)?this[R(this,Ot).indexOf(e)]:void 0}get flipped(){return R(this,Wt)}get names(){return R(this,Ot)?R(this,Ot):this.map((e,s)=>`V${s+1}`)}};Wt=new WeakMap,Ot=new WeakMap,l(hs,"DimensionVector");let Ut=hs;const Bs=class Bs{constructor(t,e){this.scale_x=1,this.scale_y=1,this.scale_size=.05,this.active=!1,this.visible=!1,this.highlighting=!1,this.meta={},this._x=0,this._y=0,this._highlight_default=new rt("#000000"),this._size=0,this.ID=e.ID,this._transform=new ye,t instanceof Ut?this._dimensions=t:t instanceof H?this._dimensions=Ut.fromArray(t):Array.isArray(t)?this._dimensions=new Ut(...t):(console.warn("Invalid dimensions provided, using default DimensionVector(0, 0)"),this._dimensions=new Ut(0,0));let s={...e};this._original={...s},this.ID=s.ID,this.x=s.x||this._dimensions[0],this.y=s.y||this._dimensions[1],this._size=s.size||1,this._color=s.color||new rt("#000000"),this.active=s.active||!1,this.shape=s.shape||null,this.meta=s.meta||{},this._highlight=this._highlight_default,s.highlight&&(this._highlight=s.highlight)}get dimensions(){return this._dimensions}get color(){return this.highlighting&&this._highlight?this._highlight:this._color}set color(t){this._color=t}get highlight(){return this._highlight||this._highlight_default}set highlight(t){this._highlight=t}get size(){return this._size}set size(t){this._size=t}get original(){return this._original}get x(){return this._x}get y(){return this._y}set x(t){this._x=t}set y(t){this._y=t}dimension(t){return this._dimensions.get(t)}get transform(){return this._transform}set transform(t){this._transform=t}};l(Bs,"PlottedObject");let Tt=Bs;const Gs=class Gs extends Tt{constructor(t,e,s){super([],{}),this.from=e,this.to=s}get line(){return[[this.from.x,this.from.y],[this.to.x,this.to.y]]}get midpoint(){return[(this.from.x+this.to.x)/2,(this.from.y+this.to.y)/2]}get length(){return Math.sqrt(Math.pow(this.to.x-this.from.x,2)+Math.pow(this.to.y-this.from.y,2))}get color(){return this._color}set color(t){this._color=t}};l(Gs,"Line");let se=Gs;const qe=class qe extends Tt{constructor(t){var n,r;let e,s,i;t?t instanceof H?(e=(n=t.classes)==null?void 0:n.map((o,a)=>o==="ena.co.occurrence"||o==="ena.dimension"?t[a]:-1).filter(o=>o!==-1),s=(r=t.classes)==null?void 0:r.map((o,a)=>o==="ena.metadata"?[t.names[a],t[a]]:null).filter(o=>o!==null).reduce((o,a)=>(o[a[0]]=a[1],o),{}),i=t.rowName||`point-${Math.random().toString(36).substring(2,9)}`):typeof t=="object"?(e=t.dimensions||[],s=t.meta||{},i=t.ID||`point-${Math.random().toString(36).substring(2,9)}`):(console.warn("Invalid data provided for Point, using default values"),e=[],s={},i=`point-${Math.random().toString(36).substring(2,9)}`):(e=[],s={},i=`point-${Math.random().toString(36).substring(2,9)}`),super(e??[],{meta:s,ID:i}),this.edges=new Map,this.shape=qe.SHAPES.CIRCLE}set label(t){this._label=t}get label(){return this._label}get x(){return this._x}get y(){return this._y}set x(t){this._x=parseFloat(t)}set y(t){this._y=parseFloat(t)}};l(qe,"Point"),qe.SHAPES={CIRCLE:"circle",SQUARE:"rect"};let it=qe;const ae=class ae extends Tt{constructor(t,e){super(e.dimensions,e),this._visible=!1,this.offset=0,this.text=t,this.ID=e.ID,this.object=e,this.x=this.dimensions[0],this.y=this.dimensions[1],this.offset=e.size||0,this.size=this.offset/4,this.visible=!1,this._transform.set("e",1),this._transform.set("f",1)}get x(){return parseFloat(this._x)}get y(){return parseFloat(this._y)}set x(t){this._x=t}set y(t){this._y=t}get transform(){return console.warn("transform is disabled - need updated reference for the graph options"),this._transform}set transform(t){this._transform=t}};l(ae,"Label"),ae.DISPLAY_TYPES={OFF:0,AUTO:1,CLICK:2,ON:3},ae.HIGHLIGHT={OFF:0,ON:2},ae.POSITION={OBJECT:1,STATIC:2,CONTAINER:3,CUSTOM:4};let G=ae;const Us=class Us{constructor(t,e,s=0,i=0){this.x_max=t,this.y_max=e,this.cx=s,this.cy=i}as_viewBox(t=1.2){let e=this.x_max*t,s=this.y_max*t;return`${this.cx-e} ${this.cy-s} ${e*2} ${s*2}`}get height(){return this.y_max*2}get width(){return this.x_max*2}get top(){return this.y_max*-1}get bottom(){return this.y_max}get left(){return this.x_max*-1}get right(){return this.x_max}};l(Us,"Extremes");let Ft=Us;const Xs=class Xs extends Tt{constructor(t,e){super(t,e),this.visible=!0,this.size=e.size}set size(t){this._size=t}get size(){return this._size}get x(){return this._x}get y(){return this._y}set x(t){this._x=t}set y(t){this._y=t}get transform(){return this._transform}};l(Xs,"AxisPoint");let ks=Xs,di={GRAPH:{ratio:1,x_max:1,y_max:1,selector:"body",width:1,height:1,axes:!0,SIZE_EFFECT:1,dimensions:[0,1]},NODE:{size:1,highlight:{color:"yellow",labels:G.DISPLAY_TYPES.ON},labels:G.DISPLAY_TYPES.ON,labelposition:G.POSITION.OBJECT},POINT:{active:2,size:.05,color:"#000",shape:it.SHAPES.CIRCLE,labels:G.DISPLAY_TYPES.AUTO,labelposition:G.POSITION.OBJECT},MEAN:{shape:it.SHAPES.SQUARE,labels:G.DISPLAY_TYPES.AUTO},LABEL:{highlight:G.HIGHLIGHT.OFF,position:["top","left"],container:"#label-container"},EDGE:{multiplier:1}};const Ws=class Ws{constructor(t={...di}){this.__state__=new Ke,this.name="unnamed-graph",this.origin=void 0,this.points=new Map,this.nodes=new Map,this.edges=new Map,this.trajectories=new Map,this.labels=new Map,this.transform=new ye,this.scale_x=1,this.scale_y=1,this.SIZE_EFFECT=1,this._mirror_y=!0,this._mirror_x=!1,this._layers=new ee({name:"graph",tabindex:0,layers:[{name:"axes",layers:[{name:"axis_lines",tabindex:0,layers:[],objects:[]},{name:"axis_labels",tabindex:0,layers:[],objects:[]},{name:"axis_points",tabindex:0,layers:[],objects:[this.origin]}]},{name:"network",layers:[{name:"edges",layers:[],tabindex:0},{name:"nodes",layers:[],tabindex:0},{name:"edgenodes",layers:[],tabindex:0}]},{name:"trajectories",layers:[],tabindex:0},{name:"points",layers:[],tabindex:0},{name:"labels",layers:[],tabindex:0}]}),this.options=t,this.origin=new ks(new Ut(0,0),{ID:"origin",x:0,y:0,size:0,meta:{},graph:this,color:new rt("#FFFFFF"),highlight:new rt("#FFFFFF"),active:!1});let e=1;function s(r,o,a){const h=new Ms(`${e}`,r,a);return e+=1,h.parent=o||void 0,r.layers&&Array.isArray(r.layers)&&(h.layers=new ee(...r.layers.map(g=>s(g,h,a)))),h}l(s,"buildLayerTree"),this.layers=new ee(...this._layers.map(r=>s(r,null,this)));let i=this.layers.search("layers","axis_points");i&&i.objects.set(this.origin.ID,this.origin);let n=this.layers.search("layers","axis_lines");if(n){let r=this.extremes||new Ft(1,1),o=new se({},new it({ID:"axis-x-start",dimensions:[-r.x_max,0],classes:["ena.dimension","ena.dimension"]}),new it({ID:"axis-x-end",dimensions:[r.x_max,0],classes:["ena.dimension","ena.dimension"]}));o.ID="axis-x",n.objects.set(o.ID,o);let a=new se({},new it({ID:"axis-y-start",dimensions:[0,-r.y_max],classes:["ena.dimension","ena.dimension"]}),new it({ID:"axis-y-end",dimensions:[0,r.y_max],classes:["ena.dimension","ena.dimension"]}));a.ID="axis-y",n.objects.set(a.ID,a),Jt("Added axis lines to layer: ",n)}this.extremes=new Ft(t.GRAPH.x_max,t.GRAPH.y_max)}set extremes(t){this._extremes=t}get extremes(){return this._extremes}get mirror_x(){return this._mirror_x}set mirror_x(t){this._mirror_x=t}get mirror_y(){return this._mirror_y}set mirror_y(t){this._mirror_y=t}x_mirror(){return this.mirror_x?-1:1}y_mirror(){return this.mirror_y?-1:1}add_point(t){const e=new it(t);this.points.set(e.ID,e)}add_points(t){let e=this;t.rows().forEach(s=>{e.add_point(s)})}add_nodes(t){let e=this;t.forEach(s=>{s.label=new G(s.ID,s),e.labels.set(s.label.ID,s.label),e.nodes.set(s.ID,s);const i=e.layers.search("layers","nodes");i&&i.objects.push(s)}),e.update_extremes()}add_edge(t,e,s){return this.edges.set(t.ID,t),this.add_nodes([e||t.from,s||t.to]),t}add_edges(t){let e=t.map(i=>this.add_edge(i));const s=this.layers.search("layers","edges");return s&&s.objects.push(...e),e}update_extremes(t=!1){const e=[this.layers.search("layers","points"),this.layers.search("layers","nodes")].filter(s=>s!==void 0);if(e.length===0)this.extremes=new Ft(1,1);else{let s=1/0,i=-1/0,n=1/0,r=-1/0;e.forEach(m=>m.objects.forEach(_=>{Number.isFinite(_.x)&&(s=Math.min(s,_.x),i=Math.max(i,_.x)),Number.isFinite(_.y)&&(n=Math.min(n,_.y),r=Math.max(r,_.y))}));const o=Number.isFinite(s)&&Number.isFinite(n),a=t&&o?(s+i)/2:0,h=t&&o?(n+r)/2:0,g=o?Math.max(Math.abs(s-a),Math.abs(i-a),Math.abs(n-h),Math.abs(r-h)):0,f=(g>0?g:1)*1.3;this.extremes=new Ft(f,f,a,h)}}nodeExtentFrom(t,e){const s=this.layers.search("layers","nodes");let i=0;return s==null||s.objects.forEach(n=>{Number.isFinite(n.x)&&Number.isFinite(n.y)&&(i=Math.max(i,Math.abs(n.x-t),Math.abs(n.y-e)))}),i}base_point_size(t=8){let e=Math.min(this.extremes.x_max,this.extremes.y_max),s=this.points.size+this.nodes.size;return Math.min(1,e/(Math.sqrt(s)*t))}};l(Ws,"Graph");let Je=Ws;const ls=class ls extends St{constructor(t=ci()){if(super(),this.element=null,this.object=null,this.doc=t,ui(t))return;const e=this,s=e.attachShadow({mode:"open"}),i=t.createElement("style"),n=t.createElement("div");i.textContent=this.constructor.style,s.appendChild(i),n.setAttribute("class","wrapper"),s.appendChild(n)}get wrapper(){const t=this,e=t.shadowRoot;return e==null?void 0:e.querySelector(".wrapper")}};l(ls,"DrawableElement"),ls.style=`
|
|
8
|
+
`;let Ye=Ce;Ut(Ye.tagName,Ye);const vt=class vt{constructor(t){return this.base=typeof t=="string"?t:t.base,new Proxy(this,{get(e,s){if(typeof s=="string"&&/^[0-2]$/.test(s)){const{r:i,g:n,b:r}=vt.parseColor(e.base);return[i,n,r][Number(s)]}return e[s]}})}toString(){return this.base}setBase(t){this.base=t}static parseColor(t){const e=String(t).trim();if(/^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(e)){const n=parseInt(e.slice(1,7),16);return{r:n>>16&255,g:n>>8&255,b:n&255}}if(/^#[0-9a-f]{3}$/i.test(e)){const[n,r,o]=[1,2,3].map(a=>parseInt(e[a]+e[a],16));return{r:n,g:r,b:o}}const s=e.match(/^rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)/i);if(s)return{r:Math.round(+s[1]),g:Math.round(+s[2]),b:Math.round(+s[3])};const i=vt.resolveCss(e);if(i)return vt.parseColor(i);throw new Error(`Unsupported color format: ${t}`)}static namedColor(t){vt._named||(vt._named=new Map(Dn.split(" ").map(s=>s.split(":"))));const e=vt._named.get(t.trim().toLowerCase());return e?`#${e}`:null}static resolveCss(t){if(vt._cssCache.has(t))return vt._cssCache.get(t);const e=vt.namedColor(t);if(e)return vt._cssCache.set(t,e),e;vt._ctx===void 0&&(vt._ctx=typeof document<"u"?document.createElement("canvas").getContext("2d"):null);let s=null;const i=vt._ctx;if(i){i.fillStyle="#000000",i.fillStyle=t;const n=i.fillStyle;i.fillStyle="#ffffff",i.fillStyle=t;const r=i.fillStyle;n===r&&(s=String(n))}return vt._cssCache.set(t,s),s}static rgb(t,e,s){return`rgb(${t}, ${e}, ${s})`}};l(vt,"Color"),vt._cssCache=new Map;let gt=vt;const fs=class fs extends gt{constructor(t,e,s){super(t),this.weight=e,this.alpha=s}static toHSV(t){const{r:e,g:s,b:i}=gt.parseColor(t),n=e/255,r=s/255,o=i/255,a=Math.max(n,r,o),h=Math.min(n,r,o),_=a-h,p=a,b=a===0?0:_/a;let d=0;if(_>0)switch(a){case n:d=((r-o)/_+(r<o?6:0))/6;break;case r:d=((o-n)/_+2)/6;break;default:d=((n-r)/_+4)/6}return{h:d*360,s:b,v:p}}static hsvToRgba(t,e,s,i){const n=s*e,r=n*(1-Math.abs(t/60%2-1)),o=s-n;let a=0,h=0,_=0;return t<60?(a=n,h=r,_=0):t<120?(a=r,h=n,_=0):t<180?(a=0,h=n,_=r):t<240?(a=0,h=r,_=n):t<300?(a=r,h=0,_=n):(a=n,h=0,_=r),`rgba(${Math.round((a+o)*255)},${Math.round((h+o)*255)},${Math.round((_+o)*255)},${i.toFixed(4)})`}toString(){const{h:t,v:e}=fs.toHSV(this.base),s=Math.min(1,Math.abs(this.weight)),i=this.alpha===void 0?s:Math.min(1,Math.max(0,this.alpha));return fs.hsvToRgba(t,s,e,i)}};l(fs,"WeightedColor");let Be=fs;const Dn="aliceblue:f0f8ff antiquewhite:faebd7 aqua:00ffff aquamarine:7fffd4 azure:f0ffff beige:f5f5dc bisque:ffe4c4 black:000000 blanchedalmond:ffebcd blue:0000ff blueviolet:8a2be2 brown:a52a2a burlywood:deb887 cadetblue:5f9ea0 chartreuse:7fff00 chocolate:d2691e coral:ff7f50 cornflowerblue:6495ed cornsilk:fff8dc crimson:dc143c cyan:00ffff darkblue:00008b darkcyan:008b8b darkgoldenrod:b8860b darkgray:a9a9a9 darkgreen:006400 darkgrey:a9a9a9 darkkhaki:bdb76b darkmagenta:8b008b darkolivegreen:556b2f darkorange:ff8c00 darkorchid:9932cc darkred:8b0000 darksalmon:e9967a darkseagreen:8fbc8f darkslateblue:483d8b darkslategray:2f4f4f darkslategrey:2f4f4f darkturquoise:00ced1 darkviolet:9400d3 deeppink:ff1493 deepskyblue:00bfff dimgray:696969 dimgrey:696969 dodgerblue:1e90ff firebrick:b22222 floralwhite:fffaf0 forestgreen:228b22 fuchsia:ff00ff gainsboro:dcdcdc ghostwhite:f8f8ff gold:ffd700 goldenrod:daa520 gray:808080 green:008000 greenyellow:adff2f grey:808080 honeydew:f0fff0 hotpink:ff69b4 indianred:cd5c5c indigo:4b0082 ivory:fffff0 khaki:f0e68c lavender:e6e6fa lavenderblush:fff0f5 lawngreen:7cfc00 lemonchiffon:fffacd lightblue:add8e6 lightcoral:f08080 lightcyan:e0ffff lightgoldenrodyellow:fafad2 lightgray:d3d3d3 lightgreen:90ee90 lightgrey:d3d3d3 lightpink:ffb6c1 lightsalmon:ffa07a lightseagreen:20b2aa lightskyblue:87cefa lightslategray:778899 lightslategrey:778899 lightsteelblue:b0c4de lightyellow:ffffe0 lime:00ff00 limegreen:32cd32 linen:faf0e6 magenta:ff00ff maroon:800000 mediumaquamarine:66cdaa mediumblue:0000cd mediumorchid:ba55d3 mediumpurple:9370db mediumseagreen:3cb371 mediumslateblue:7b68ee mediumspringgreen:00fa9a mediumturquoise:48d1cc mediumvioletred:c71585 midnightblue:191970 mintcream:f5fffa mistyrose:ffe4e1 moccasin:ffe4b5 navajowhite:ffdead navy:000080 oldlace:fdf5e6 olive:808000 olivedrab:6b8e23 orange:ffa500 orangered:ff4500 orchid:da70d6 palegoldenrod:eee8aa palegreen:98fb98 paleturquoise:afeeee palevioletred:db7093 papayawhip:ffefd5 peachpuff:ffdab9 peru:cd853f pink:ffc0cb plum:dda0dd powderblue:b0e0e6 purple:800080 rebeccapurple:663399 red:ff0000 rosybrown:bc8f8f royalblue:4169e1 saddlebrown:8b4513 salmon:fa8072 sandybrown:f4a460 seagreen:2e8b57 seashell:fff5ee sienna:a0522d silver:c0c0c0 skyblue:87ceeb slateblue:6a5acd slategray:708090 slategrey:708090 snow:fffafa springgreen:00ff7f steelblue:4682b4 tan:d2b48c teal:008080 thistle:d8bfd8 tomato:ff6347 turquoise:40e0d0 violet:ee82ee wheat:f5deb3 white:ffffff whitesmoke:f5f5f5 yellow:ffff00 yellowgreen:9acd32",_i=class _i{constructor(t=null){this._values=[1,0,0,1,0,0],this._keys=["a","b","c","d","e","f"],t&&(this.values=t)}get values(){return this._values}set values(t){t&&t.length===6&&(this._values=t)}get keys(){return this._keys}set keys(t){t&&t.length===6&&(this._keys=t)}toString(){return`matrix(${this.keys.map((e,s)=>this.values[s]).join(" ")})`}toMatrix(){return Object.fromEntries(this._keys.map((t,e)=>[t,this._values[e]]))}toArray(){return this._values}set(t,e){const s=this._keys.indexOf(t);s>=0&&Number.isFinite(e)&&(this._values[s]=e)}get(t){return this._values[this._keys.findIndex(e=>e===t)]}scale(t,e=t){this.a=t,this.d=e}zoom(t){this.a=t,this.d=t}pan(t,e){this.e=this.e+t,this.f=this.f+e}set a(t){this.set("a",t)}set b(t){this.set("b",t)}set c(t){this.set("c",t)}set d(t){this.set("d",t)}set e(t){this.set("e",t)}set f(t){this.set("f",t)}get a(){return this.get("a")}get b(){return this.get("b")}get c(){return this.get("c")}get d(){return this.get("d")}get e(){return this.get("e")}get f(){return this.get("f")}};l(_i,"Transform");let Ge=_i;var Xe;(c=>{(t=>{function e(s){return`matrix(${["a","b","c","d","e","f"].map(n=>s[n]).join(" ")})`}l(e,"matrixString"),t.matrixString=e})(c.Matrix||(c.Matrix={})),(t=>{(s=>{function i(r,o,a){const h=e.toRad(o);return[r[0]+a*Math.cos(h),r[1]+a*Math.sin(h)]}l(i,"translate"),s.translate=i;function n(r,o,a){const h=e.toRad(o);function _(p,b){return[p[0]*Math.cos(b)-p[1]*Math.sin(b),p[0]*Math.sin(b)+p[1]*Math.cos(b)]}if(l(_,"rotatePoint"),!a||a[0]===0&&a[1]===0)return _(r,h);{const p=r.map((d,f)=>d-a[f]);return _(p,h).map((d,f)=>d+a[f])}}l(n,"rotate"),s.rotate=n})(t.Point||(t.Point={})),(s=>{function i(u,g){return(g[1]-u[1])/(g[0]-u[0])}l(i,"slope"),s.slope=i;function n(u,g){const y=i(u,g);return u[1]-y*u[0]}l(n,"intercept"),s.intercept=n;function r(u,g){return{slope:i(u,g),intercept:n(u,g)}}l(r,"slopeIntercept"),s.slopeIntercept=r;function o(u,g=0){const y=g,m=(1-y)*u[0][0]+y*u[1][0],w=(1-y)*u[0][1]+y*u[1][1];return[m,w]}l(o,"point_along"),s.point_along=o;function a(u,g,y=.5){return Array.isArray(u[0])&&(g=u[1],u=u[0]),[0,1].map(m=>(parseFloat(u[m])+parseFloat(g[m]))*y)}l(a,"midpoint"),s.midpoint=a;function h(u,g){return Array.isArray(u[0])&&(g=u[1],u=u[0]),Math.sqrt([0,1].map(y=>Math.pow(g[y]-u[y],2)).reduce((y,m)=>y+m,0))}l(h,"length"),s.length=h;function _(u,g=[0,0]){const y=[u[1][0]-g[0],u[1][1]-g[1]],m=[-y[1],y[0]],w=[-m[0],-m[1]],S=[m[0]+g[0],m[1]+g[1]],v=[w[0]+g[0],w[1]+g[1]];return[S,v]}l(_,"rotate"),s.rotate=_;function p(u,g,y=90){const m=c.Geometry.Line.slope(u[0],u[1]),w=c.Geometry.Line.intercept(u[0],u[1]),S=[0,w],v=[1,m+w];u=[S,v];const T=[u[0][0],u[1][0]],Q=[u[0][1],u[1][1]],E=g[0],ot=g[1],et=-2*Math.PI*y/360,st=T.map((yt,le)=>(yt-E)*Math.cos(et)-(Q[le]-ot)*Math.sin(et)+E),A=Q.map((yt,le)=>(T[le]-E)*Math.sin(et)-(yt-ot)*Math.cos(et)+ot);return[[st[0],A[0]],[st[1],A[1]]]}l(p,"rotate2"),s.rotate2=p;function b(u,g){const[[y,m],[w,S]]=u,[[v,T],[Q,E]]=g,ot=(y-w)*(T-E)-(m-S)*(v-Q),et=(y*S-m*w)*(v-Q)-(y-w)*(v*E-T*Q),st=(y*S-m*w)*(T-E)-(m-S)*(v*E-T*Q);return[et/ot,st/ot]}l(b,"intersection"),s.intersection=b;function d(u,g,y){let{slope:m,intercept:w}=c.Geometry.Line.slopeIntercept(u[0],u[1]),S=1+Math.pow(m,2),v=2*m*w-2*g[1]*m-2*g[0],T=Math.pow(g[0],2)+Math.pow(w,2)+Math.pow(g[1],2)-2*g[1]*w-Math.pow(y,2),Q=[[1/0,1/0],[1/0,1/0]];if(Math.sqrt(Math.pow(v,2)-4*S*T)>=0){let E=(-v+Math.sqrt(Math.pow(v,2)-4*S*T))/(2*S),ot=(-v-Math.sqrt(Math.pow(v,2)-4*S*T))/(2*S),et=m*E+w,st=m*ot+w;Q=[[E,et],[ot,st]]}else console.error("The line and the circumference do not intersect");return Q}l(d,"intersect_circle"),s.intersect_circle=d;function f(u){return g=>g===0?u[0]:g===1?u[1]:c.Geometry.Point.translate(u[0],c.Geometry.Angle.line(u),c.Geometry.Line.length(u)*g)}l(f,"interpolate"),s.interpolate=f})(t.Line||(t.Line={}));let e;(s=>{function i(o){return o/180*Math.PI}l(i,"toRad"),s.toRad=i;function n(o){return o*180/Math.PI}l(n,"toDeg"),s.toDeg=n;function r(o){if(o.length!==2||!Array.isArray(o[0])||!Array.isArray(o[1])||o[0].length!==2||o[1].length!==2)throw new Error("Invalid line format. Expected [[x1, y1], [x2, y2]].");return c.Geometry.Angle.toDeg(Math.atan2(o[1][1]-o[0][1],o[1][0]-o[0][0]))}l(r,"line"),s.line=r})(e=t.Angle||(t.Angle={}))})(c.Geometry||(c.Geometry={})),(t=>{function e(n){return[...new Set(n)]}l(e,"unique"),t.unique=e;function s(n,r){if(Array.isArray(n)){if(Array.isArray(r)){if(n.length!==r.length)throw new Error("Arrays must be of equal length");return n.map((o,a)=>o/r[a])}return n.map(o=>o/r)}return n/r}l(s,"divide"),t.divide=s;function i(n){return typeof Array.isArray=="function"?Array.isArray(n):n&&typeof n=="object"&&n.constructor.name==="Array"}l(i,"isArray"),t.isArray=i})(c.ArrayTools||(c.ArrayTools={})),(t=>{function e(n){return n.reduce((r,o)=>r+o,0)}l(e,"sum"),t.sum=e;function s(n){return e(n)/n.length}l(s,"mean"),t.mean=s;function i(n,r){const o=Math.pow(10,r);return Math.round(n*o)/o}l(i,"round"),t.round=i})(c.Mathematics||(c.Mathematics={})),(t=>{function e(s,i,n){return new CustomEvent(s,{bubbles:!0,cancelable:!0,detail:{element:i,data:n||(i?i.__data__:void 0)}})}l(e,"createEvent"),t.createEvent=e})(c.Events||(c.Events={})),(t=>{function e(){return location.hash.replace(/#/,"").split(/\//).filter(i=>i).map(i=>i.split(/:/))}l(e,"parts"),t.parts=e;function s(i){return e().flat().findIndex(n=>n===i)>=0}l(s,"exists"),t.exists=s})(c.Hash||(c.Hash={})),(t=>{function e(n,r,o=!1){if(o){if(typeof n!="object"||n===null)return n;for(const a in n)Object.prototype.hasOwnProperty.call(n,a)&&(n[a]=e(n[a],r,o));return new Proxy(n,r)}else return new Proxy(n,r)}l(e,"proxy"),t.proxy=e,t.handler={set(n,r,o){return n[r]=o,window.dispatchEvent(c.Events.createEvent("settingUpdate",window,{target:n,property:r,value:o})),!0},get(n,r){return n[r]}};function s(n,r){const o=r.split(".");let a=n;for(const h of o)if(a&&typeof a=="object"&&Object.prototype.hasOwnProperty.call(a,h))a=a[h];else return;return a}l(s,"get"),t.get=s;function i(n,r,o){const a=r.split(".");let h=n,_;for(_=0;_<a.length-1;_++){const p=a[_];if(h&&typeof h=="object")Object.prototype.hasOwnProperty.call(h,p)||(h[p]={}),h=h[p];else return!1}return h&&typeof h=="object"?(h[a[_]]=o,!0):!1}l(i,"set"),t.set=i})(c.Objects||(c.Objects={})),(t=>{function e(s=window.location){return Object.fromEntries(new URLSearchParams(s.search))}l(e,"parse"),t.parse=e,(s=>{function i(o=window.location.search){return Object.fromEntries(o.replace(/^\?/,"").split(/&/).map(a=>a.split(/=/)))}l(i,"parse2"),s.parse=i;function n(o=window.location.search){return o.replace(/^\?/,"").split(/&/).map(a=>a.split(/=/)[0])}l(n,"keys"),s.keys=n;function r(o,a=window.location.search){return n(a).findIndex(h=>h===o)>=0}l(r,"has"),s.has=r})(t.Query||(t.Query={}))})(c.URL||(c.URL={}))})(Xe||(Xe={}));const fi=class fi{constructor(){this._state=new Map,this.listeners=new Map}get state(){return this._state}hasVariable(t){return this._state.has(t)}getVariable(t){return this._state.get(t)}setVariable(t,e,s){const i=this._state.get(t);this._state.set(t,e),s!=null&&s.lazy||this.notifyListeners(t,e,i)}addListener(t,e,s){this.listeners.has(t)||this.listeners.set(t,new Map);const i=this.listeners.get(t);i.has(e)||i.set(e,new Set),i.get(e).add(s)}removeListener(t,e,s){var i,n;(n=(i=this.listeners.get(t))==null?void 0:i.get(e))==null||n.delete(s)}getListeners(t,e){var s;return Array.from(((s=this.listeners.get(t))==null?void 0:s.get(e))??[])}notifyListeners(t,e,s){const i=this.listeners.get(t);if(i)for(const n of i.values())n.forEach(r=>{typeof r=="function"?r({key:t,newValue:e,oldValue:s}):typeof r.calculate=="function"&&r.calculate.call(r,{key:t,newValue:e,oldValue:s})})}};l(fi,"EventBus");let Ns=fi;const{ArrayTools:Bi}=Xe,gs=class gs extends Array{constructor(...t){super(...t)}search(t,e){let s;function i(r){return r.name===e?r:void 0}l(i,"fn");function n(r,o,a=null){if(Bi.isArray(r)){for(const[h,_]of r.entries())if(s=n(_,h,a),s)return s}else{if(s=i(r),s)return s;if(r&&Bi.isArray(r[t])){for(const[h,_]of r[t].entries())if(s=n(_,h,r),s)return s}}return s}return l(n,"recurse"),n(this)}flatten(){return this.reduce((t,e)=>(t.push(e),e.layers&&Array.isArray(e.layers)&&t.push(...e.layers),t),[])}recurse(t,e,s=null,i=0){let n=new gs;for(const r of this){let o=e(r,s,i);if(r[t]&&Array.isArray(r[t])){let a=new gs(...r[t]).recurse(t,e,r,i+1);a!==void 0&&n.push(...a)}n.push(o)}return Ae("Recurse results: ",n),n}};l(gs,"LayerArray");let Ne=gs;const gi=class gi{constructor(t,e,s){this.__state__=new Ns,this.scale_x=1,this.scale_y=1,this.scale_objects=!0,this.layers=new Ne,this.objects=new Map,this.visible=!0,this.ID=t,this.name=e.name||`layer-${t}`,this.tabindex=e.tabindex,this.parent=s,this._transform=new Ge,s==null||s.__state__.addListener("graph_updated","live",({key:i,newValue:n,oldValue:r})=>{}),s==null||s.__state__.addListener(`graph_updated_${this.name}`,"live",({key:i,newValue:n,oldValue:r})=>{this.objects=n,this.__state__.setVariable("layer_updated",this)})}get transform(){return this._transform}set transform(t){this._transform=t}};l(gi,"Layer");let Ks=gi;const Ls=class Ls extends Array{constructor(...e){super(arguments.length);Et(this,me,!1);Et(this,Vt);for(let s=0;s<e.length;s++)this[s]=e[s];ut(this,me,!1)}static fromArray(e){const s=new Ls;return e.forEach((i,n)=>{s.push(i)}),ut(s,Vt,e.names),s}flip(){ut(this,me,!U(this,me));for(let e=0;e<this.length;e++)this[e]=-this[e];return this}get(e){return typeof e=="number"?this[e]:U(this,Vt)&&U(this,Vt).includes(e)?this[U(this,Vt).indexOf(e)]:void 0}get flipped(){return U(this,me)}get names(){return U(this,Vt)?U(this,Vt):this.map((e,s)=>`V${s+1}`)}};me=new WeakMap,Vt=new WeakMap,l(Ls,"DimensionVector");let _e=Ls;const mi=class mi{constructor(t,e){this.scale_x=1,this.scale_y=1,this.scale_size=.05,this.active=!1,this.visible=!1,this.highlighting=!1,this.meta={},this._x=0,this._y=0,this._highlight_default=new gt("#000000"),this._size=0,this.ID=e.ID,this._transform=new Ge,t instanceof _e?this._dimensions=t:t instanceof ct?this._dimensions=_e.fromArray(t):Array.isArray(t)?this._dimensions=new _e(...t):(console.warn("Invalid dimensions provided, using default DimensionVector(0, 0)"),this._dimensions=new _e(0,0));let s={...e};this._original={...s},this.ID=s.ID,this.x=s.x||this._dimensions[0],this.y=s.y||this._dimensions[1],this._size=s.size||1,this._color=s.color||new gt("#000000"),this.active=s.active||!1,this.shape=s.shape||null,this.meta=s.meta||{},this._highlight=this._highlight_default,s.highlight&&(this._highlight=s.highlight)}get dimensions(){return this._dimensions}get color(){return this.highlighting&&this._highlight?this._highlight:this._color}set color(t){this._color=t}get highlight(){return this._highlight||this._highlight_default}set highlight(t){this._highlight=t}get size(){return this._size}set size(t){this._size=t}get original(){return this._original}get x(){return this._x}get y(){return this._y}set x(t){this._x=t}set y(t){this._y=t}dimension(t){return this._dimensions.get(t)}get transform(){return this._transform}set transform(t){this._transform=t}};l(mi,"PlottedObject");let ee=mi;const pi=class pi extends ee{constructor(t,e,s){super([],{}),this.from=e,this.to=s}get line(){return[[this.from.x,this.from.y],[this.to.x,this.to.y]]}get midpoint(){return[(this.from.x+this.to.x)/2,(this.from.y+this.to.y)/2]}get length(){return Math.sqrt(Math.pow(this.to.x-this.from.x,2)+Math.pow(this.to.y-this.from.y,2))}get color(){return this._color}set color(t){this._color=t}};l(pi,"Line");let fe=pi;const ms=class ms extends ee{constructor(t){var n,r;let e,s,i;t?t instanceof ct?(e=(n=t.classes)==null?void 0:n.map((o,a)=>o==="ena.co.occurrence"||o==="ena.dimension"?t[a]:-1).filter(o=>o!==-1),s=(r=t.classes)==null?void 0:r.map((o,a)=>o==="ena.metadata"?[t.names[a],t[a]]:null).filter(o=>o!==null).reduce((o,a)=>(o[a[0]]=a[1],o),{}),i=t.rowName||`point-${Math.random().toString(36).substring(2,9)}`):typeof t=="object"?(e=t.dimensions||[],s=t.meta||{},i=t.ID||`point-${Math.random().toString(36).substring(2,9)}`):(console.warn("Invalid data provided for Point, using default values"),e=[],s={},i=`point-${Math.random().toString(36).substring(2,9)}`):(e=[],s={},i=`point-${Math.random().toString(36).substring(2,9)}`),super(e??[],{meta:s,ID:i}),this.edges=new Map,this.shape=ms.SHAPES.CIRCLE}set label(t){this._label=t}get label(){return this._label}get x(){return this._x}get y(){return this._y}set x(t){this._x=parseFloat(t)}set y(t){this._y=parseFloat(t)}};l(ms,"Point"),ms.SHAPES={CIRCLE:"circle",SQUARE:"rect"};let _t=ms;const ze=class ze extends ee{constructor(t,e){super(e.dimensions,e),this._visible=!1,this.offset=0,this.text=t,this.ID=e.ID,this.object=e,this.x=this.dimensions[0],this.y=this.dimensions[1],this.offset=e.size||0,this.size=this.offset/4,this.visible=!1,this._transform.set("e",1),this._transform.set("f",1)}get x(){return parseFloat(this._x)}get y(){return parseFloat(this._y)}set x(t){this._x=t}set y(t){this._y=t}get transform(){return console.warn("transform is disabled - need updated reference for the graph options"),this._transform}set transform(t){this._transform=t}};l(ze,"Label"),ze.DISPLAY_TYPES={OFF:0,AUTO:1,CLICK:2,ON:3},ze.HIGHLIGHT={OFF:0,ON:2},ze.POSITION={OBJECT:1,STATIC:2,CONTAINER:3,CUSTOM:4};let rt=ze;const bi=class bi{constructor(t,e,s=0,i=0){this.x_max=t,this.y_max=e,this.cx=s,this.cy=i}as_viewBox(t=1.2){let e=this.x_max*t,s=this.y_max*t;return`${this.cx-e} ${this.cy-s} ${e*2} ${s*2}`}get height(){return this.y_max*2}get width(){return this.x_max*2}get top(){return this.y_max*-1}get bottom(){return this.y_max}get left(){return this.x_max*-1}get right(){return this.x_max}};l(bi,"Extremes");let se=bi;const yi=class yi extends ee{constructor(t,e){super(t,e),this.visible=!0,this.size=e.size}set size(t){this._size=t}get size(){return this._size}get x(){return this._x}get y(){return this._y}set x(t){this._x=t}set y(t){this._y=t}get transform(){return this._transform}};l(yi,"AxisPoint");let Js=yi,Gi={GRAPH:{ratio:1,x_max:1,y_max:1,selector:"body",width:1,height:1,axes:!0,SIZE_EFFECT:1,dimensions:[0,1]},NODE:{size:1,highlight:{color:"yellow",labels:rt.DISPLAY_TYPES.ON},labels:rt.DISPLAY_TYPES.ON,labelposition:rt.POSITION.OBJECT},POINT:{active:2,size:.05,color:"#000",shape:_t.SHAPES.CIRCLE,labels:rt.DISPLAY_TYPES.AUTO,labelposition:rt.POSITION.OBJECT},MEAN:{shape:_t.SHAPES.SQUARE,labels:rt.DISPLAY_TYPES.AUTO},LABEL:{highlight:rt.HIGHLIGHT.OFF,position:["top","left"],container:"#label-container"},EDGE:{multiplier:1}};const xi=class xi{constructor(t={...Gi}){this.__state__=new Ns,this.name="unnamed-graph",this.origin=void 0,this.points=new Map,this.nodes=new Map,this.edges=new Map,this.trajectories=new Map,this.labels=new Map,this.transform=new Ge,this.scale_x=1,this.scale_y=1,this.SIZE_EFFECT=1,this._mirror_y=!0,this._mirror_x=!1,this._layers=new Ne({name:"graph",tabindex:0,layers:[{name:"axes",layers:[{name:"axis_lines",tabindex:0,layers:[],objects:[]},{name:"axis_labels",tabindex:0,layers:[],objects:[]},{name:"axis_points",tabindex:0,layers:[],objects:[this.origin]}]},{name:"network",layers:[{name:"edges",layers:[],tabindex:0},{name:"nodes",layers:[],tabindex:0},{name:"edgenodes",layers:[],tabindex:0}]},{name:"trajectories",layers:[],tabindex:0},{name:"points",layers:[],tabindex:0},{name:"labels",layers:[],tabindex:0}]}),this.options=t,this.origin=new Js(new _e(0,0),{ID:"origin",x:0,y:0,size:0,meta:{},graph:this,color:new gt("#FFFFFF"),highlight:new gt("#FFFFFF"),active:!1});let e=1;function s(r,o,a){const h=new Ks(`${e}`,r,a);return e+=1,h.parent=o||void 0,r.layers&&Array.isArray(r.layers)&&(h.layers=new Ne(...r.layers.map(_=>s(_,h,a)))),h}l(s,"buildLayerTree"),this.layers=new Ne(...this._layers.map(r=>s(r,null,this)));let i=this.layers.search("layers","axis_points");i&&i.objects.set(this.origin.ID,this.origin);let n=this.layers.search("layers","axis_lines");if(n){let r=this.extremes||new se(1,1),o=new fe({},new _t({ID:"axis-x-start",dimensions:[-r.x_max,0],classes:["ena.dimension","ena.dimension"]}),new _t({ID:"axis-x-end",dimensions:[r.x_max,0],classes:["ena.dimension","ena.dimension"]}));o.ID="axis-x",n.objects.set(o.ID,o);let a=new fe({},new _t({ID:"axis-y-start",dimensions:[0,-r.y_max],classes:["ena.dimension","ena.dimension"]}),new _t({ID:"axis-y-end",dimensions:[0,r.y_max],classes:["ena.dimension","ena.dimension"]}));a.ID="axis-y",n.objects.set(a.ID,a),Ae("Added axis lines to layer: ",n)}this.extremes=new se(t.GRAPH.x_max,t.GRAPH.y_max)}set extremes(t){this._extremes=t}get extremes(){return this._extremes}get mirror_x(){return this._mirror_x}set mirror_x(t){this._mirror_x=t}get mirror_y(){return this._mirror_y}set mirror_y(t){this._mirror_y=t}x_mirror(){return this.mirror_x?-1:1}y_mirror(){return this.mirror_y?-1:1}add_point(t){const e=new _t(t);this.points.set(e.ID,e)}add_points(t){let e=this;t.rows().forEach(s=>{e.add_point(s)})}add_nodes(t){let e=this;t.forEach(s=>{s.label=new rt(s.ID,s),e.labels.set(s.label.ID,s.label),e.nodes.set(s.ID,s);const i=e.layers.search("layers","nodes");i&&i.objects.push(s)}),e.update_extremes()}add_edge(t,e,s){return this.edges.set(t.ID,t),this.add_nodes([e||t.from,s||t.to]),t}add_edges(t){let e=t.map(i=>this.add_edge(i));const s=this.layers.search("layers","edges");return s&&s.objects.push(...e),e}update_extremes(t=!1){const e=[this.layers.search("layers","points"),this.layers.search("layers","nodes")].filter(s=>s!==void 0);if(e.length===0)this.extremes=new se(1,1);else{let s=1/0,i=-1/0,n=1/0,r=-1/0;e.forEach(b=>b.objects.forEach(d=>{Number.isFinite(d.x)&&(s=Math.min(s,d.x),i=Math.max(i,d.x)),Number.isFinite(d.y)&&(n=Math.min(n,d.y),r=Math.max(r,d.y))}));const o=Number.isFinite(s)&&Number.isFinite(n),a=t&&o?(s+i)/2:0,h=t&&o?(n+r)/2:0,_=o?Math.max(Math.abs(s-a),Math.abs(i-a),Math.abs(n-h),Math.abs(r-h)):0,p=(_>0?_:1)*1.3;this.extremes=new se(p,p,a,h)}}nodeExtentFrom(t,e){const s=this.layers.search("layers","nodes");let i=0;return s==null||s.objects.forEach(n=>{Number.isFinite(n.x)&&Number.isFinite(n.y)&&(i=Math.max(i,Math.abs(n.x-t),Math.abs(n.y-e)))}),i}base_point_size(t=8){let e=Math.min(this.extremes.x_max,this.extremes.y_max),s=this.points.size+this.nodes.size;return Math.min(1,e/(Math.sqrt(s)*t))}};l(xi,"Graph");let Ms=xi;const $s=class $s extends Xt{constructor(t=qi()){if(super(),this.element=null,this.object=null,this.doc=t,Yi(t))return;const e=this,s=e.attachShadow({mode:"open"}),i=t.createElement("style"),n=t.createElement("div");i.textContent=this.constructor.style,s.appendChild(i),n.setAttribute("class","wrapper"),s.appendChild(n)}get wrapper(){const t=this,e=t.shadowRoot;return e==null?void 0:e.querySelector(".wrapper")}};l($s,"DrawableElement"),$s.style=`
|
|
9
9
|
:host {
|
|
10
10
|
max-width: 100%;
|
|
11
11
|
display: block;
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
display: flex;
|
|
16
16
|
justify-content: center;
|
|
17
17
|
}
|
|
18
|
-
`;let Qe=ls;const gi=1e-8;function Is(c,t=gi){return c.filter(e=>Math.abs(e.x)>t||Math.abs(e.y)>t)}l(Is,"nearOriginFilter");function fi(c){if(c<=0)return[];if(c===1)return[0];const t=new Array(c);for(let e=0;e<c;e++)t[e]=e/(c-1);return t}l(fi,"normalizedT");function mi(c,t){return c.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})}l(mi,"design");function pi(c){const t=c.length,e=c[0].length,s=c.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 o=0;o<t;o++)r+=s[o][n]*s[o][n];if(r=Math.sqrt(r),i[n][n]=r,r>1e-300)for(let o=0;o<t;o++)s[o][n]/=r;for(let o=n+1;o<e;o++){let a=0;for(let h=0;h<t;h++)a+=s[h][n]*s[h][o];i[n][o]=a;for(let h=0;h<t;h++)s[h][o]-=a*s[h][n]}}return{Q:s,R:i}}l(pi,"qr");function Cs(c,t){const e=c.length,s=c[0].length,i=new Array(s).fill(0);for(let n=0;n<s;n++){let r=0;for(let o=0;o<e;o++)r+=c[o][n]*t[o];i[n]=r}return i}l(Cs,"qtY");function zs(c,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-=c[i][r]*s[r];s[i]=Math.abs(c[i][i])>1e-12?n/c[i][i]:0}return s}l(zs,"backSolve");function Vi(c){return c.map(t=>{let e=0;for(let s=0;s<t.length;s++)e+=t[s]*t[s];return e})}l(Vi,"leverages");function bi(c,t,e){const s=mi(c,e),{Q:i,R:n}=pi(s);return zs(n,Cs(i,t))}l(bi,"fitCoeffs");function ts(c,t){let e=0,s=1;for(let i=0;i<c.length;i++)e+=c[i]*s,s*=t;return e}l(ts,"evalPoly");function Zi(c,t,e,s){const i=mi(c,s),{Q:n,R:r}=pi(i),o=Vi(n),a=zs(r,Cs(n,t)),h=zs(r,Cs(n,e));let g=0;for(let f=0;f<c.length;f++){const m=1-o[f];if(m<=0)return 1/0;const _=t[f]-ts(a,c[f]),d=e[f]-ts(h,c[f]);g+=(_/m)**2+(d/m)**2}return g}l(Zi,"loocv2d");function yi(c,t,e){const s=c.length,i=Math.min(Math.max(1,Math.floor(t)),Math.max(1,s-1));if(e==="fixed"||s<3)return i;const n=fi(s),r=c.map(g=>g.x),o=c.map(g=>g.y);let a=1,h=1/0;for(let g=1;g<=i;g++){const f=Zi(n,r,o,g);f<h&&(h=f,a=g)}return a}l(yi,"selectDegree");function xi(c,t){const e=Is(c);if(e.length<3)return null;const s=t.selectionSet?Is(t.selectionSet):e,i=s.length>=3?s:e;let n=yi(i,t.maxDegree,t.degreeSelection);n=Math.min(n,Math.max(1,e.length-1));const r=fi(e.length),o=bi(r,e.map(h=>h.x),n),a=bi(r,e.map(h=>h.y),n);return{degree:n,coeffsX:o,coeffsY:a}}l(xi,"fitTrajectory");function Os(c,t=100){const e=[];for(let s=0;s<=t;s++){const i=s/t;e.push({x:ts(c.coeffsX,i),y:ts(c.coeffsY,i)})}return e}l(Os,"sampleCurve");const wi=100,Hs=class Hs extends Tt{constructor(t={}){const e=t.color instanceof rt?t.color:new rt(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 it)return s;const i=new it({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 Os({degree:this.polyCoeffsX.length-1,coeffsX:this.polyCoeffsX,coeffsY:this.polyCoeffsY},wi);const e=xi(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,Os(e,wi)}return t.map(e=>({x:e.x,y:e.y}))}};l(Hs,"Trajectory");let we=Hs;const vi=1,Vs=class Vs extends se{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 rt("#000000");return new be(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}};l(Vs,"Edge");let ve=Vs;const Zs=class Zs extends Tt{constructor(e){super(e.dimensions||[],e);ct(this,he);V(this,he,e)}get edge(){return R(this,he)}get path(){const e=R(this,he),s=[e.to.x,e.to.y],i=e.from_point,[n,r]=e.base_pts,o=Math.hypot(i[0]-s[0],i[1]-s[1]),a=Math.hypot(n[0]-r[0],n[1]-r[1]);if(!(o>0)||!(a>0))return"";const h=[(i[0]-s[0])/o,(i[1]-s[1])/o],g=Math.hypot(n[0]-s[0],n[1]-s[1]),f=[(n[0]-s[0])/g,(n[1]-s[1])/g],m=l(I=>a/2*Math.max(0,1-I/o),"halfW"),_=l((I,j)=>`${s[0]+h[0]*I+f[0]*j} ${s[1]+h[1]*I+f[1]*j}`,"at"),d=.2*o,u=Math.min(.15*o,.8*2*m(d)),b=d+u/2,p=d+u;return`M${_(d,0)} L${_(b,m(b))} L${_(p,m(p))} L${_(b,0)} L${_(p,-m(p))} L${_(b,-m(b))}z`}};he=new WeakMap,l(Zs,"EdgeArrow");let es=Zs;const cs=class cs extends ve{constructor(e,s,i){super(e,s,i);ct(this,le);ct(this,Be);this._path="",V(this,le,!1),this._directions=["from","to"],this.towards="to",R(this,le)===!0&&V(this,Be,new es(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,o=e[s].x,a=e[s].y,h=o-n,g=a-r,f=Math.hypot(h,g),m=(e.weight??0)*vi;if(f===0||!isFinite(m)||m===0)return[[o,a],[o,a]];const _=-g/f,d=h/f,u=m/2;return[[o+_*u,a+d*u],[o-_*u,a-d*u]]}get base_pts(){return cs.calculate_base_points(this)}get arrow(){return R(this,Be)}get with_arrow(){return R(this,le)}get from_point(){return[this.from.x,this.from.y]}};le=new WeakMap,Be=new WeakMap,l(cs,"TaperedEdge");let Xt=cs;const us=class us extends Xt{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 xe.Geometry.Line.interpolate(this.line)(1-this._dataWeight/this._totalweight)}get base_pts(){return Xt.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 us.build_path(this)}get from_point(){return this.weighted_midpoint}};l(us,"TaperedWeightedMidpointEdge");let Ls=us;const _s=class _s extends ve{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*vi;return _s.build_path(t,this.to)}};l(_s,"NodeEdge");let ie=_s;const Ks=class Ks{constructor(t,e,s,i=new Dt){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 o(a){const h=Math.min(1,(a-r)/n),g=i+(s-i)*h;t.setAttribute(e,g.toString()),h<1?requestAnimationFrame(o):t.setAttribute(e,s.toString())}l(o,"animate"),requestAnimationFrame(o)}};l(Ks,"Drawable");let Ae=Ks;const Ki=.04,Ji=[.25,1],Qi=[.3,1];function Ai(c,t,e,s){const i=Math.abs(c);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])}l(Ai,"rampFor");const tn=.011,en=.75,sn=.8,nn=.75,Si=.006,rn=.6;function on(c){return 2*c}l(on,"widthPerWeight");function an(c,t){return c*t/(2*Si)}l(an,"nodeSizeForEdges");function hn(c){const t=/rgba?\(([^)]+)\)/.exec(c);if(!t)return c;const[e,s,i,n=1]=t[1].split(",").map(Number),r=l(o=>Math.round(255+(o-255)*n),"f");return`rgb(${r(e)},${r(s)},${r(i)})`}l(hn,"flattenOnWhite");function ln(c,t){const e=/rgba?\(([^)]+)\)/.exec(c);if(!e)return c;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})`}l(ln,"darkenRgba");const Js=class Js extends Ae{constructor(t,e,s,i=new Dt){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=l((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 ie){const e=this.graph.doc.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 Xt){const e=this.graph.doc.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=this.graph.doc.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 ie||this.__data__ instanceof Xt}update(){var i,n,r,o;if(this.svg_element||this.create(),this.svg_element.tagName.toLowerCase()==="path"!==this.drawsPath){const a=this.svg_element;this.create(),a.parentElement&&a.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 a=typeof e.weight=="number"?e.weight:0,h=typeof e.maxWeight=="number"?e.maxWeight:1,g=typeof e.opacity=="number"?e.opacity:Math.min(1,a/(h||1)),f=t>0?t:1,m=e.fixedSize&&this.graph.zoom_level||1,_=(typeof e.widthFrac=="number"?f*e.widthFrac*a:f*tn*(a/(h||1)))/m,d=this.__data__._color||new rt("#000000"),u=typeof e.saturation=="number"?e.saturation:g,b=e.exactColor?d.toString():new be(d,u,g).toString();if(this.__data__ instanceof ie){const p=typeof e.selfSize=="number"&&e.selfSize>0?e.selfSize:null,w=p!=null?(o=(r=this.graph)._nodeRadius)==null?void 0:o.call(r,String(e.source)):null;this.__data__.weight=typeof w=="number"?2*p*w:_,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 Xt){if(this.__data__.weight=_,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(en)),this.svg_element.setAttribute("vector-effect","non-scaling-stroke"),this.svg_element.setAttribute("stroke-linejoin","round"),e.isDirected)try{const w=new es(this.__data__).path;w&&!w.includes("NaN")&&!w.includes("Infinity")&&(this._arrow_el||(this._arrow_el=this.graph.doc.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",ln(hn(b),sn)),this._arrow_el.setAttribute("stroke","#ffffff"),this._arrow_el.setAttribute("stroke-width",String(nn)),this._arrow_el.setAttribute("vector-effect","non-scaling-stroke"),this._arrow_el.setAttribute("stroke-linejoin","round"),s=!0)}catch{}}else{const p=this.__data__.from.x,w=this.__data__.from.y,I=this.__data__.to.x,j=this.__data__.to.y;this.svg_element.setAttribute("x1",p.toString()),this.svg_element.setAttribute("y1",w.toString()),this.svg_element.setAttribute("x2",I.toString()),this.svg_element.setAttribute("y2",j.toString()),this.svg_element.setAttribute("stroke-width",_.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=this.graph.doc.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",p.toString()),this._hit_el.setAttribute("y1",w.toString()),this._hit_el.setAttribute("x2",I.toString()),this._hit_el.setAttribute("y2",j.toString()),this._hit_el.setAttribute("stroke-width",Math.max(_,t*.03/m).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 a=this.graph._axesFixedSize&&String(this.__data__.ID).startsWith("axis-")&&this.graph.zoom_level||1,h=(t>0?t:1)*.004*this.get_size()/a;this.svg_element.setAttribute("stroke-width",h.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))}};l(Js,"QELine");let Nt=Js;const Qs=class Qs extends Ae{constructor(t,e,s,i=new Dt){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,o,a,h,g;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 f=(o=(r=this.graph.svg_element)==null?void 0:r.getBoundingClientRect)==null?void 0:o.call(r),m=f&&f.width>0?2*t/f.width:t*.004;return s/2*m}if((a=this.__data__.meta)!=null&&a.fixedSize){const f=(g=(h=this.graph.svg_element)==null?void 0:h.getBoundingClientRect)==null?void 0:g.call(h),m=this.graph.zoom_level||1,_=f&&f.width>0?f.width/(2*t):1;return this.__data__.size*2*e/_/m}return t*Si*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=l((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=this.graph.doc.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)}};l(Qs,"QEPoint");let ne=Qs;const ti=class ti extends Ae{constructor(t,e,s,i=new Dt){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=this.graph.doc.createElementNS("http://www.w3.org/2000/svg","g");t.setAttribute("class","qe-trajectory-group");const e=this.graph.doc.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=this.graph.doc.createElementNS("http://www.w3.org/2000/svg","g");s.setAttribute("class","qe-trajectory-segments"),t.appendChild(s),this._segments_group=s;const i=this.graph.doc.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=this.graph.doc.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,[o,a]=this.__data__.opacityRange;for(let h=0;h<i;h++){const g=s[h],f=s[h+1],m=i<=1?1:h/(i-1),_=n+(r-n)*m,d=o+(a-o)*m,u=this.graph.doc.createElementNS("http://www.w3.org/2000/svg","path");u.setAttribute("d",`M${g.x},${g.y} L${f.x},${f.y}`),u.setAttribute("fill","none"),u.setAttribute("stroke",this.__data__.color.toString()),u.setAttribute("stroke-linecap","round"),u.setAttribute("stroke-linejoin","round"),u.setAttribute("stroke-width",this.graphUnitsForPixels(_).toString()),u.setAttribute("opacity",d.toString()),this._segments_group.appendChild(u)}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=this.graph.doc.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()}};l(ti,"QETrajectory");let Se=ti;const{ArrayTools:Ei}=xe,ei=class ei extends Array{constructor(...t){super(...t)}search(t,e){let s;function i(r){return r.name===e?r:void 0}l(i,"fn");function n(r,o,a=null){if(Ei.isArray(r)){for(const[h,g]of r.entries())if(s=n(g,h,a),s)return s}else{if(s=i(r),s)return s;if(r&&Ei.isArray(r[t])){for(const[h,g]of r[t].entries())if(s=n(g,h,r),s)return s}}return s}return l(n,"recurse"),n(this)}flatten(){return this.reduce((t,e)=>(t.push(e),e.layers&&Array.isArray(e.layers)&&t.push(...e.layers),t),[])}};l(ei,"QEArray");let Dt=ei;const cn={AxisPoint:ne,AxisLine:Nt,Point:ne,Line:Nt,Edge:Nt,TaperedEdge:Nt,TaperedWeightedMidpointEdge:Nt,NodeEdge:Nt,Trajectory:Se},ce=class ce{constructor(t,e,s,i=new Dt){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:o})=>{const a=l(m=>{var _;return(_=m.__data__)==null?void 0:_.ID},"childId"),h=this.__children__.filter(m=>!r.objects.has(a(m))),g=this.__children__.filter(m=>r.objects.has(a(m)));[...r.objects.values()].filter(m=>!this.__children__.some(_=>a(_)===m.ID)).forEach(m=>{const _=m._typeName||m.constructor.name;let d=cn[_];d||(m instanceof we?d=Se:m instanceof it?d=ne:d=Nt);const u=new d(m,this.svg_element,this.graph);this.__children__.push(u)}),g.forEach(m=>{const _=r.objects.get(a(m));_&&(m.__data__=_),m.update()}),h.forEach(m=>{var d;typeof m.remove=="function"?m.remove():(d=m.svg_element.parentElement)==null||d.removeChild(m.svg_element);const _=this.__children__.indexOf(m);_>=0&&this.__children__.splice(_,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=this.graph.doc.createElementNS("http://www.w3.org/2000/svg",ce.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 ce(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)}};l(ce,"QELayer"),ce.tagName="g";let ss=ce;const si=class si{constructor(t,e,s,i,n=G.DISPLAY_TYPES.ON,r=G.POSITION.OBJECT,o,a){this.text=t,this.parent=s,this.graph=i,this.displayMode=n,this.position=r,this.customX=o,this.customY=a,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===G.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=this.graph.doc.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!==G.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 o=l((_,d)=>{const u=r.createSVGPoint();u.x=_,u.y=d;const b=n.getScreenCTM();return b?u.matrixTransform(b.inverse()):{x:0,y:0}},"toUser"),a=o(e,s),h=this._offsetX,g=this._offsetY;t.style.cursor="grabbing";const f=l((_,d)=>{const u=o(_,d);this._offsetX=h+(u.x-a.x),this._offsetY=g+(u.y-a.y),this.pinned=!0,this._visible=!0,this.svg_element.setAttribute("display","block"),this.update()},"move"),m=l(()=>{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 _=l(u=>f(u.clientX,u.clientY),"onMove"),d=l(()=>{document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",d),m()},"onUp");document.addEventListener("mousemove",_),document.addEventListener("mouseup",d)}else{const _=l(u=>{u.pointerId===i&&f(u.clientX,u.clientY)},"onMove"),d=l(u=>{u.pointerId===i&&(document.removeEventListener("pointermove",_),document.removeEventListener("pointerup",d),document.removeEventListener("pointercancel",d),m())},"onUp");document.addEventListener("pointermove",_),document.addEventListener("pointerup",d),document.addEventListener("pointercancel",d)}}update(){var a,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,o;switch(this.position){case G.POSITION.STATIC:{n=this.point.x,r=this.point.y-i*.3,o="middle";break}case G.POSITION.CONTAINER:{const{cx:g,cy:f}=this.graph.__data__.extremes,m=this.point.x-g,_=this.point.y-f,d=Math.sqrt(m*m+_*_)||1,u=t*.93/d;n=g+m*u,r=f+_*u-i*.3,o=m>=0?"start":"end";break}case G.POSITION.CUSTOM:if(this.customX!=null&&this.customY!=null){n=this.customX,r=this.customY,o="start";break}default:case G.POSITION.OBJECT:{const g=this.point.x>=0?i:-i;o=this.point.x>=0?"start":"end",n=this.point.x+g,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",o),this.svg_element.setAttribute("fill",((a=this.point.meta)==null?void 0:a.labelColor)??e.color??((h=this.point.color)==null?void 0:h.toString())??"#333333"),!this._offsetX&&!this._offsetY&&this.position!==G.POSITION.CUSTOM&&this.fitInside(n,r,o,i,s*.3)}visibleBounds(){const t=this.svg_element,e=t.ownerSVGElement;if(!e)return null;const s=typeof t.getScreenCTM=="function"&&typeof DOMPoint<"u"?t.getScreenCTM():null;if(!s)return this.estimatedVisibleBounds(e);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),o=new DOMPoint(i.right,i.bottom).matrixTransform(n);return{left:Math.min(r.x,o.x),right:Math.max(r.x,o.x),top:Math.min(r.y,o.y),bottom:Math.max(r.y,o.y)}}estimatedVisibleBounds(t){var m;const e=(m=t.getBoundingClientRect)==null?void 0:m.call(t),s=l(_=>{const d=Number(t.getAttribute(_));return Number.isFinite(d)&&d>0?d:0},"size"),i=(e==null?void 0:e.width)||s("width"),n=(e==null?void 0:e.height)||s("height"),r=Xi(t.getAttribute("viewBox"),i,n);if(!r)return null;let o=[1,0,0,1,0,0];for(let _=this.svg_element.parentElement;_&&_!==t;_=_.parentElement){const d=Gi(_.getAttribute("transform"));o=[d[0]*o[0]+d[2]*o[1],d[1]*o[0]+d[3]*o[1],d[0]*o[2]+d[2]*o[3],d[1]*o[2]+d[3]*o[3],d[0]*o[4]+d[2]*o[5]+d[4],d[1]*o[4]+d[3]*o[5]+d[5]]}const a=Ui(o);if(!a)return null;const h=l((_,d)=>({x:a[0]*_+a[2]*d+a[4],y:a[1]*_+a[3]*d+a[5]}),"map"),g=h(r.left,r.top),f=h(r.right,r.bottom);return{left:Math.min(g.x,f.x),right:Math.max(g.x,f.x),top:Math.min(g.y,f.y),bottom:Math.max(g.y,f.y)}}bbox(){const t=this.svg_element;if(typeof t.getBBox!="function")return Bi(t);try{const e=t.getBBox();return e.width>0?e:null}catch{return null}}fitInside(t,e,s,i,n){const r=this.visibleBounds();let o=this.bbox();if(!r||!o)return;const a=r.left+n,h=r.right-n,g=r.top+n,f=r.bottom-n,m=l(b=>Math.max(0,a-b.x)+Math.max(0,b.x+b.width-h),"over"),_=this.svg_element;if(m(o)>0&&this.position===G.POSITION.OBJECT&&s!=="middle"){const b=s==="end"?"start":"end",p=s==="end"?this.point.x+i:this.point.x-i;_.setAttribute("text-anchor",b),_.setAttribute("x",p.toString());const w=this.bbox();w&&m(w)<m(o)?(o=w,t=p):(_.setAttribute("text-anchor",s),_.setAttribute("x",t.toString()))}let d=0,u=0;o.x<a?d=a-o.x:o.x+o.width>h&&(d=Math.max(h-(o.x+o.width),a-o.x)),o.y<g?u=g-o.y:o.y+o.height>f&&(u=Math.max(f-(o.y+o.height),g-o.y)),d&&_.setAttribute("x",(t+d).toString()),u&&_.setAttribute("y",(e+u).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()}};l(si,"QELabel");let Ps=si;const ds=class ds extends St{};l(ds,"QENodesElement"),ds.tagName="qe-nodes";let Ee=ds;const gs=class gs extends St{};l(gs,"QENodeElement"),gs.tagName="qe-node";let Ne=gs;const fs=class fs extends St{};l(fs,"QEMeansElement"),fs.tagName="qe-means";let Me=fs;const ms=class ms extends St{};l(ms,"QEPointsElement"),ms.tagName="qe-points";let ke=ms;const ps=class ps extends St{};l(ps,"QEEdgesElement"),ps.tagName="qe-edges";let Ie=ps;const bs=class bs extends St{};l(bs,"QEEdgeElement"),bs.tagName="qe-edge";let Ce=bs;const ys=class ys extends St{};l(ys,"QETrajectoriesElement"),ys.tagName="qe-trajectories";let ze=ys;const xs=class xs extends St{};l(xs,"QEAxesElement"),xs.tagName="qe-axes";let Oe=xs;Et(Ee.tagName,Ee),Et(Ne.tagName,Ne),Et(Me.tagName,Me),Et(ke.tagName,ke),Et(Ie.tagName,Ie),Et(Ce.tagName,Ce),Et(ze.tagName,ze),Et(Oe.tagName,Oe);const Ni=["#4477AA","#EE6677","#228833","#CCBB44","#66CCEE","#AA3377","#BBBBBB","#000000"];function un(c,t){for(const e of t)if(c===`${e}.${e}`)return[e,e];for(const e of t)if(c.startsWith(e+".")){const s=c.slice(e.length+1);if(t.includes(s))return[e,s]}return null}l(un,"parseEdgePair");function _n(c,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,c)/e)*s,o=Math.sqrt(Math.max(0,t)/e)*s;return{halfW:n*r,halfH:n*o}}l(_n,"computeCIRect");const dn=.5;function is(c,t,e){if(!c)return;const s=Math.min(Math.abs(t),Math.abs(e));s>0&&(c.meta={...c.meta??{},maxRadius:s*dn})}l(is,"capMeanToInterval");function ns(c,t,e,s=""){const i=l(h=>{const g=c.names.indexOf(h),f=g>=0?c[g]:null;if(f==null||f==="")return;const m=Number(f);return Number.isFinite(m)?m:void 0},"get"),n=i(`${t}.${s}low`)??i(`${t}_${s}low`),r=i(`${t}.${s}high`)??i(`${t}_${s}high`),o=i(`${e}.${s}low`)??i(`${e}_${s}low`),a=i(`${e}.${s}high`)??i(`${e}_${s}high`);return n==null||r==null||o==null||a==null?null:{x_low:n,x_high:r,y_low:o,y_high:a}}l(ns,"readIntervalBounds");function rs(c,t){const e=l(h=>{if(!c)return;const g=c.names.indexOf(h);return g>=0?c[g]:void 0},"raw"),s=l(h=>h==null||h==="NA"||typeof h=="number"&&Number.isNaN(h),"isNA"),i=e("label"),n=s(i)?t:String(i)===""?null:String(i),r=l(h=>{const g=e(h),f=s(g)||g===""?0:Number(g);return Number.isFinite(f)?f:0},"num"),o=!!c&&(c.names.includes("label.dx")||c.names.includes("label.dy")),a=e("label.pinned");return{text:n,offset:o?{x:r("label.dx"),y:r("label.dy")}:null,pinned:a===!0||a===1||String(a).toLowerCase()==="true"}}l(rs,"readLabelSpec");function gn(c){const t=c==null?void 0:c.trim().toLowerCase();if(!t)return null;if(t==="node")return .5;const e=Number(t);return Number.isFinite(e)&&e>0?e:null}l(gn,"parseSelfSize");function Mi(c,t,e){return c?[...c.children].filter(s=>s.tagName.toLowerCase()===t).map(s=>Object.fromEntries(["color",...e].map(i=>[i,s.getAttribute(i)??""]))).filter(s=>s.color&&e.every(i=>s[i])):[]}l(Mi,"childColors");function fn(c){var i,n;const t=l(r=>c.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:gn(t("self-size")),fixedSize:c.hasAttribute("fixed-size"),edgeColors:Mi(c,"qe-edge",["source","target"])}}l(fn,"parseEdgeLayer");function mn(c){const{r:t,g:e,b:s}=rt.parseColor(c),i=Math.max(t,e,s),n=Math.min(t,e,s),r=l(o=>(i+n-o).toString(16).padStart(2,"0"),"f");return`#${r(t)}${r(e)}${r(s)}`}l(mn,"complementColor");function pn(c){const t=c==null?void 0:c.trim().toLowerCase();return t==="plot"||t==="absolute"?t:"model"}l(pn,"parseColorScale");function os(c,t){switch(c==null?void 0:c.toLowerCase()){case"on":return 3;case"off":return 0;case"click":return 2;case"auto":return 1;default:return t}}l(os,"parseLabelMode");const at=class at extends Qe{constructor(t,e){super(t),this.zoom_level=1,this.__children__=new Dt,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._host=this,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._headless=ui(this.doc),e&&(this._host=e),this.graph=this,this.parent=null,this.__data__=new Je(di),this.__name__=this.__data__.name||"unnamed-graph",this.svg_element=this.create(),Jt("Created qe-graph svg element: ",this.svg_element),typeof document<"u"&&!this._headless&&document.addEventListener("model-updated",s=>{var r;const i=((r=s.composedPath)==null?void 0:r.call(s)[0])??s.target;if(this._vizena&&i!==this._vizena)return;const n=s.detail;n&&this.renderModel(n)})}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._host.getAttribute("view-padding"));return this._host.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}renderModel(t){var e,s,i,n,r,o,a,h,g,f,m,_,d,u,b,p;{this._renderPending=!1,(e=this._childObserver)==null||e.takeRecords(),this._animateMs=this._host.hasAttribute("animate")?parseInt(this._host.getAttribute("animate")||"",10)||300:0;const w=this._animateMs>0&&this._hasModel?this._captureTweenState():null;this._stopTween(),this._hasModel=!0;const I=t.dimensions,j=t.unit_id_col,Y=t.node_id_col,st=t.group_col,A=this._readLayerConfig();this._showAxes=A.showAxes,this._axisXText=A.axisXLabel===null?null:A.axisXLabel||String((I==null?void 0:I[0])??"x"),this._magnifyText=A.edgeMagnify==null?null:`(scaled ${A.edgeMagnify.toFixed(1)}x)`,this._axisYText=A.axisYLabel===null?null:A.axisYLabel||String((I==null?void 0:I[1])??"y");const U={},nt=(s=t.palette)!=null&&s.length?t.palette:Ni;if(st&&((i=t.points)!=null&&i.names)){const C=t.points.col(st);C&&[...new Set([...C].map(String))].forEach(($,M)=>{U[$]=nt[M%nt.length]})}(n=t.groups)!=null&&n.rows&&t.groups.rows().length>0&&t.groups.rows().forEach(C=>{const z=C.rowName??String(C[0]),$=C.names.indexOf("color"),M=$>=0?C[$]:null;M&&String(M)!=="NA"?U[z]=String(M):U[z]||(U[z]=nt[Object.keys(U).length%nt.length])});const Mt=Object.keys(U),Lt=A.activeMeanGroups&&A.activeMeanGroups.trim()?new Set(A.activeMeanGroups.split(",").map(C=>C.trim()).filter(C=>U[C])):new Set(Mt),ws=A.scalePoints,vs=l(C=>{let z=0;return C.forEach($=>{const M=$.names.indexOf(I[0]),N=I.length>1?$.names.indexOf(I[1]):-1;M>=0&&(z=Math.max(z,Math.abs(Number($[M])))),N>=0&&(z=Math.max(z,Math.abs(Number($[N]))))}),z},"getExtent"),Bt=(r=t.nodes)!=null&&r.rows?vs(t.nodes.rows()):0,ue=(o=t.points)!=null&&o.rows?vs(t.points.rows()):0,wn=(a=t.trajectories)!=null&&a.rows?vs(t.trajectories.rows()):0,ii=ue>0?ue:wn,q=A.pointScale!==null?A.pointScale:ws&&ii>0&&Bt>0?Bt/ii:1;this._rangeExtent=A.range==="network"?Bt*1.2:A.range==="points"?ii*q*1.2:typeof A.range=="number"?A.range:null,this._rangeMode=A.range==="network"||A.range==="points"?A.range:typeof A.range=="number"?"number":null,this._centerContent=A.centerContent,this._edgesFixedSize=A.edgeLayers.some(C=>C.fixedSize),this._meansFixedSize=A.meanFixedSize,this._axesFixedSize=A.axesFixedSize,this._plotTitle=A.plotTitle,this._labelFont=A.labelFont;const vn=A.labelNodes,An=A.labelMeans,Ci=A.labelPoints,Ht=this._labelsGroup,ni=l((C,z,$,M=1)=>{const N=C.names.indexOf(z),y=C.names.indexOf(I[0]),L=I.length>1?C.names.indexOf(I[1]):-1,v=new it({ID:N>=0?String(C[N]):C.rowName||`pt-${Math.random().toString(36).slice(2)}`,dimensions:[y>=0?Number(C[y])*M:0,L>=0?-Number(C[L])*M:0],meta:{}});return $&&(v.color=new rt($)),v},"rowToPoint"),pt={},Sn=A.showPoints;["points","nodes","edges","edgenodes"].map(C=>this.__children__.search("__children__",C)).filter(C=>!!C).forEach(C=>C.__data__.objects.clear()),this.__data__.points.clear();const As=t.pointsets,ri=[];if(A.pointSets.length&&(As!=null&&As.rows)){const C=this.__children__.search("__children__","points"),z=l(($,M)=>{const N=$.names.indexOf(M);return N>=0?$[N]:null},"col");A.pointSets.forEach(($,M)=>{As.rows().forEach(N=>{if(String(z(N,"set"))!==$.set)return;const y=String(z(N,"id")),L=z(N,"group")!=null&&String(z(N,"group"))!=="NA"?String(z(N,"group")):null,v=z(N,"color")&&String(z(N,"color"))!=="NA"?String(z(N,"color")):L&&U[L]?U[L]:nt[M%nt.length],k=ni(N,"id",v,q);k.ID=`${$.set}::${y}`,k.size=$.size??A.pointSize??2.5;const F=z(N,"shape");F&&String(F)!=="NA"&&(k.shape=String(F));const Z=z(N,"label");k.meta={stroke:"#ffffff",kind:"point",name:Z!=null&&String(Z)!=="NA"?String(Z):y,group:L??void 0,unit:y,set:$.set,fixedSize:$.fixedSize},this.__data__.points.set(k.ID,k),C==null||C.__data__.objects.set(k.ID,k),ri.push({pt:k,spec:rs(N,y),mode:$.labelMode,weight:$.labelWeight})})})}if(Ht){const C=new Set(ri.map(z=>z.pt.ID));this._setLabels.forEach((z,$)=>{C.has($)||(z.remove(),this._setLabels.delete($))}),ri.forEach(z=>this._syncLabel(this._setLabels,z.pt.ID,z.spec,z.pt,Ht,z.mode,z.weight))}if((h=t.points)!=null&&h.rows){const C=this.__children__.search("__children__","points");if(C){t.points.rows().forEach(M=>{const N=st?M.names.indexOf(st):-1,y=N>=0?String(M[N]):null,L=y?U[y]??"#888888":"#888888";if(Sn){const v=ni(M,j,L,q);v.size=A.pointSize??2.5,v.meta={...v.meta??{},stroke:"#ffffff",kind:"point",name:v.ID,group:y??void 0,unit:v.ID,fixedSize:A.pointFixedSize},this.__data__.points.set(v.ID,v),C.__data__.objects.set(v.ID,v)}if(y){const v=M.names.indexOf(I[0]),k=I.length>1?M.names.indexOf(I[1]):-1;pt[y]||(pt[y]={x:0,y:0,x2:0,y2:0,xy:0,n:0,color:L});const F=v>=0?Number(M[v]):0,Z=k>=0?Number(M[k]):0;pt[y].x+=F,pt[y].y+=Z,pt[y].x2+=F*F,pt[y].y2+=Z*Z,pt[y].xy+=F*Z,pt[y].n+=1}});const z=!!((g=t.groups)!=null&&g.rows&&t.groups.rows().length>0),$=A.showMeans&&z?t.groups.rows().filter(M=>{const N=M.rowName??String(M[0]);return Lt.size===0||Lt.has(N)}):[];if(A.showMeans){const M=C.svg_element,N=this._rangeExtent?this._rangeExtent/1.2:Bt,y=(N>0?N:1)*.008;if(z){const L=new Set($.map(v=>v.rowName??String(v[0])));this._ciRects.forEach((v,k)=>{L.has(k)||(v.remove(),this._ciRects.delete(k))}),this._outlierRects.forEach((v,k)=>{L.has(k)||(v.remove(),this._outlierRects.delete(k))}),this._ciCross.forEach((v,k)=>{L.has(k.slice(2))||(v.remove(),this._ciCross.delete(k))}),$.forEach(v=>{var Es,ge,Zt;const k=v.rowName??String(v[0]),F=U[k]??"#888888",Z=v.names.indexOf(I[0]),X=I.length>1?v.names.indexOf(I[1]):-1,J=Z>=0?Number(v[Z])*q:0,vt=X>=0?-Number(v[X])*q:0,tt=new it({ID:`mean-${k}`,dimensions:[J,vt],meta:{kind:"mean",name:k,group:k,fixedSize:A.meanFixedSize}});tt.color=new rt(F),tt.size=4;const gt=v.names.indexOf("shape"),T=gt>=0?v[gt]:null;tt.shape=T&&String(T)!=="NA"?String(T):"rect",this.__data__.points.set(tt.ID,tt),C.__data__.objects.set(tt.ID,tt);const _e=l(B=>{const x=v.names.indexOf(B),S=x>=0?v[x]:null;return S==null||String(S)==="NA"||String(S)===""?null:S},"cell"),bt=_e("intervals"),Rt=bt==="box"||bt==="crosshairs"||bt==="none"?bt:A.intervals,Vt=_e("outlier"),W=(Vt==null?A.showOutlier:Vt===!0||String(Vt)==="true")?ns(v,I[0],I[1],"o"):null;if(!W)(Es=this._outlierRects.get(k))==null||Es.remove(),this._outlierRects.delete(k);else{let B=this._outlierRects.get(k);B||(B=this.doc.createElementNS("http://www.w3.org/2000/svg","rect"),B.setAttribute("data-outlier-group",k),this._outlierRects.set(k,B)),B.setAttribute("x",(W.x_low*q).toString()),B.setAttribute("y",(-W.y_high*q).toString()),B.setAttribute("width",((W.x_high-W.x_low)*q).toString()),B.setAttribute("height",((W.y_high-W.y_low)*q).toString()),B.setAttribute("fill","none"),B.setAttribute("stroke",F),B.setAttribute("stroke-width",y.toString()),B.setAttribute("stroke-opacity","0.5"),B.setAttribute("stroke-dasharray",`${y*2} ${y*2}`),this._intervalStroke(B,y,[y*2,y*2]),M&&!B.parentElement&&M.insertBefore(B,M.firstChild)}const _t=Rt!=="none"?ns(v,I[0],I[1]):null,de=`x:${k}`;if((!_t||Rt!=="crosshairs")&&((ge=this._ciCross.get(de))==null||ge.remove(),this._ciCross.delete(de)),_t&&Rt==="crosshairs"){(Zt=this._ciRects.get(k))==null||Zt.remove(),this._ciRects.delete(k);const B=_t.x_low*q,x=_t.x_high*q,S=-_t.y_high*q,P=-_t.y_low*q;is(tt,(x-B)/2,(P-S)/2);let E=this._ciCross.get(de);E||(E=this.doc.createElementNS("http://www.w3.org/2000/svg","path"),E.setAttribute("data-ci-group",k),E.setAttribute("data-ci-kind","crosshairs"),this._ciCross.set(de,E)),E.setAttribute("d",`M${B} ${vt} L${x} ${vt} M${J} ${S} L${J} ${P}`),E.setAttribute("fill","none"),E.setAttribute("stroke",F),E.setAttribute("stroke-width",(y*1.25).toString()),this._intervalStroke(E,y*1.25,null),E.setAttribute("stroke-opacity","0.8"),M&&!E.parentElement&&M.insertBefore(E,M.firstChild)}else if(_t){const B=_t.x_low*q,x=-_t.y_high*q,S=(_t.x_high-_t.x_low)*q,P=(_t.y_high-_t.y_low)*q;is(tt,S/2,P/2);let E=this._ciRects.get(k);E||(E=this.doc.createElementNS("http://www.w3.org/2000/svg","rect"),E.setAttribute("data-ci-group",k),this._ciRects.set(k,E)),E.setAttribute("x",B.toString()),E.setAttribute("y",x.toString()),E.setAttribute("width",S.toString()),E.setAttribute("height",P.toString()),E.setAttribute("fill","none"),E.setAttribute("stroke",F),E.setAttribute("stroke-width",y.toString()),E.setAttribute("stroke-opacity","0.8"),E.setAttribute("stroke-dasharray",`${y*4} ${y*3}`),this._intervalStroke(E,y,[y*4,y*3]),M&&!E.parentElement&&M.insertBefore(E,M.firstChild)}else{const B=this._ciRects.get(k);B&&(B.remove(),this._ciRects.delete(k))}})}else this._removeIntervals(this._ciCross),Object.entries(pt).forEach(([v,{x:k,y:F,n:Z,color:X}])=>{const J=new it({ID:`mean-${v}`,dimensions:[k/Z*q,-(F/Z)*q],meta:{kind:"mean",name:v,group:v,fixedSize:A.meanFixedSize}});J.color=new rt(X),J.size=4,J.shape="rect",this.__data__.points.set(J.ID,J),C.__data__.objects.set(J.ID,J)}),A.showCI?(this._ciRects.forEach((v,k)=>{pt[k]||(v.remove(),this._ciRects.delete(k))}),(f=t.confidence)!=null&&f.rows?t.confidence.rows().forEach(v=>{const k=v.names.indexOf(st??"group"),F=k>=0?String(v[k]):v.rowName??null;if(!F)return;const Z=U[F]??"#888888",X=ns(v,I[0],I[1]);if(!X)return;const J=X.x_low*q,vt=-X.y_high*q,tt=(X.x_high-X.x_low)*q,gt=(X.y_high-X.y_low)*q;is(this.__data__.points.get(`mean-${F}`),tt/2,gt/2);let T=this._ciRects.get(F);T||(T=this.doc.createElementNS("http://www.w3.org/2000/svg","rect"),T.setAttribute("data-ci-group",F),this._ciRects.set(F,T)),T.setAttribute("x",J.toString()),T.setAttribute("y",vt.toString()),T.setAttribute("width",tt.toString()),T.setAttribute("height",gt.toString()),T.setAttribute("fill","none"),T.setAttribute("stroke",Z),T.setAttribute("stroke-width",y.toString()),T.setAttribute("stroke-opacity","0.8"),T.setAttribute("stroke-dasharray",`${y*4} ${y*3}`),this._intervalStroke(T,y,[y*4,y*3]),M&&!T.parentElement&&M.insertBefore(T,M.firstChild)}):Object.entries(pt).forEach(([v,{x:k,y:F,x2:Z,y2:X,n:J,color:vt}])=>{if(J<2)return;const tt=k/J,gt=F/J,T=Z/J-tt*tt,_e=X/J-gt*gt,{halfW:bt,halfH:Rt}=_n(T,_e,J,q),Vt=tt*q,Ue=-gt*q;is(this.__data__.points.get(`mean-${v}`),bt,Rt);let W=this._ciRects.get(v);W||(W=this.doc.createElementNS("http://www.w3.org/2000/svg","rect"),W.setAttribute("data-ci-group",v),this._ciRects.set(v,W)),W.setAttribute("x",(Vt-bt).toString()),W.setAttribute("y",(Ue-Rt).toString()),W.setAttribute("width",(bt*2).toString()),W.setAttribute("height",(Rt*2).toString()),W.setAttribute("fill","none"),W.setAttribute("stroke",vt),W.setAttribute("stroke-width",y.toString()),W.setAttribute("stroke-opacity","0.8"),W.setAttribute("stroke-dasharray",`${y*4} ${y*3}`),this._intervalStroke(W,y,[y*4,y*3]),M&&!W.parentElement&&M.insertBefore(W,M.firstChild)})):this._removeIntervals(this._ciRects),(m=t.outlier)!=null&&m.rows?(this._outlierRects.forEach((v,k)=>{U[k]||(v.remove(),this._outlierRects.delete(k))}),t.outlier.rows().forEach(v=>{const k=v.names.indexOf(st??"group"),F=k>=0?String(v[k]):v.rowName??null;if(!F)return;const Z=U[F]??"#888888",X=ns(v,I[0],I[1]);if(!X)return;const J=X.x_low*q,vt=-X.y_high*q,tt=(X.x_high-X.x_low)*q,gt=(X.y_high-X.y_low)*q;let T=this._outlierRects.get(F);T||(T=this.doc.createElementNS("http://www.w3.org/2000/svg","rect"),T.setAttribute("data-outlier-group",F),this._outlierRects.set(F,T)),T.setAttribute("x",J.toString()),T.setAttribute("y",vt.toString()),T.setAttribute("width",tt.toString()),T.setAttribute("height",gt.toString()),T.setAttribute("fill","none"),T.setAttribute("stroke",Z),T.setAttribute("stroke-width",y.toString()),T.setAttribute("stroke-opacity","0.5"),T.setAttribute("stroke-dasharray",`${y*2} ${y*2}`),this._intervalStroke(T,y,[y*2,y*2]),M&&!T.parentElement&&M.insertBefore(T,M.firstChild)})):this._removeIntervals(this._outlierRects)}else[this._ciRects,this._outlierRects,this._ciCross].forEach(M=>this._removeIntervals(M));if(Ht){this._pointLabels.forEach((y,L)=>{C.__data__.objects.get(L)||(y.remove(),this._pointLabels.delete(L))}),this._meanLabels.forEach((y,L)=>{C.__data__.objects.get(`mean-${L}`)||(y.remove(),this._meanLabels.delete(L))}),Ci!==0?t.points.rows().forEach(y=>{const L=y.names.indexOf(j),v=L>=0?String(y[L]):null;if(!v)return;const k=C.__data__.objects.get(v);k&&this._syncLabel(this._pointLabels,v,rs(null,v),k,Ht,Ci,A.labelWeightPoints)}):this._clearLabels(this._pointLabels);const M=new Map($.map(y=>[y.rowName??String(y[0]),y]));(z?[...M.keys()]:Object.keys(pt)).forEach(y=>{const L=`mean-${y}`,v=C.__data__.objects.get(L);v&&this._syncLabel(this._meanLabels,y,rs(M.get(y),y),v,Ht,An,A.labelWeightMeans)})}C.__data__.__state__.setVariable("layer_updated",C.__data__)}}else{const C=this.__children__.search("__children__","points");C==null||C.__data__.__state__.setVariable("layer_updated",C.__data__)}const Ge=this.__children__.search("__children__","trajectories");if(A.showTrajectories&&Ge){Ge.__data__.objects.clear(),this.__data__.trajectories.clear();const C=(_=t.trajectories)!=null&&_.rows?t.trajectories:t.points;if(C!=null&&C.rows){const z={},$=A.trajectoryUnits?A.trajectoryUnits.split(",").map(N=>N.trim()):null;C.rows().forEach(N=>{const y=N.names.indexOf(j)>=0?N.names.indexOf(j):N.names.indexOf("unit")>=0?N.names.indexOf("unit"):N.names.indexOf("ENA_UNIT")>=0?N.names.indexOf("ENA_UNIT"):-1,L=y>=0?String(N[y]):N.rowName||"unit-1";if($&&!$.includes(L))return;const v=N.names.indexOf(I[0]),k=I.length>1?N.names.indexOf(I[1]):-1,F=N.names.indexOf("time")>=0?N.names.indexOf("time"):N.names.indexOf("ActivityNumber")>=0?N.names.indexOf("ActivityNumber"):N.names.indexOf("RowID")>=0?N.names.indexOf("RowID"):-1,Z=F>=0?Number(N[F]):z[L]?z[L].length+1:1;v>=0&&k>=0&&(z[L]||(z[L]=[]),z[L].push({x:Number(N[v])*q,y:-Number(N[k])*q,time:Z}))}),Object.keys(z).forEach((N,y)=>{const L=z[N];if(L.length===0)return;const v=nt[y%nt.length],k=new we({ID:`traj-${N}`,unitId:N,color:new rt(v),lineStyle:A.trajectoryLineStyle,strokeWidth:A.trajectoryStrokeWidth,strokeWidthRange:A.trajectoryStrokeWidthRange,opacityRange:A.trajectoryOpacityRange,smooth:A.trajectorySmooth,maxDegree:A.trajectoryMaxDegree,degreeSelection:A.trajectoryDegreeSelection,currentTime:A.trajectoryPlayhead??1/0,showPoints:A.trajectoryShowPoints,showTips:A.trajectoryShowTips,points:L.map(F=>({x:F.x,y:F.y,time:F.time}))});this.__data__.trajectories.set(N,k),Ge.__data__.objects.set(k.ID,k)})}Ge.__data__.__state__.setVariable("layer_updated",Ge.__data__)}const Pt=this.__children__.search("__children__","network"),Ss=Pt==null?void 0:Pt.__children__.search("__children__","edges"),ut=Pt==null?void 0:Pt.__children__.search("__children__","nodes"),zi=Pt==null?void 0:Pt.__children__.search("__children__","edgenodes"),En=A.showEdges;if((d=t.nodes)!=null&&d.rows&&ut){if(t.nodes.rows().forEach(z=>{const $=A.nodeColors.get(String(z[z.names.indexOf(Y)])),M=ni(z,Y,$??"#444444");M.size=2;const N=z.names.indexOf("label"),y=N>=0?z[N]:null,L=z.names.indexOf("size"),v=L>=0&&z[L]!=null&&z[L]!==""?Number(z[L]):NaN;M.meta={...M.meta??{},kind:"node",labelColor:$,name:y!=null&&String(y)!=="NA"&&String(y)!==""?String(y):M.ID,sizePx:Number.isFinite(v)&&v>0?v:void 0,zoomFixed:A.nodeFixedSize||void 0},ut.__data__.objects.set(M.ID,M)}),En&&Ss){const z={};st&&((u=t.points)!=null&&u.rows)&&t.points.rows().forEach(x=>{const S=x.names.indexOf(j),P=x.names.indexOf(st);S>=0&&P>=0&&(z[String(x[S])]=String(x[P]))});const $=t.nodes.rows().map(x=>{const S=x.names.indexOf(Y);return S>=0?String(x[S]):""}).filter(Boolean),M=l(x=>{const S=[];return x.forEach(P=>{const E=un(P,$);E&&S.push({col:P,pair:E})}),S},"parsePairs"),N=(b=t.edges)!=null&&b.rows?t.edges.rows():[],y=t.networks,L=M(((p=t.edges)==null?void 0:p.names)??[]),v=M((y==null?void 0:y.names)??[]),k=l(x=>{const S={};return N.forEach(P=>{const E=P.names.indexOf(j);E<0||String(P[E])!==x||L.forEach(({col:D})=>{const et=P.names.indexOf(D);et>=0&&(S[D]=Number(P[et])||0)})}),S},"getUnitEdges"),F=l(x=>{const S={};let P=0;if(N.forEach(D=>{const et=D.names.indexOf(j),ht=et>=0?String(D[et]):null,Kt=st?D.names.indexOf(st):-1;(Kt>=0?String(D[Kt]):ht?z[ht]:null)===x&&(P++,L.forEach(({col:yt})=>{const It=D.names.indexOf(yt);if(It>=0){const At=Number(D[It]);isNaN(At)||(S[yt]=(S[yt]??0)+At)}}))}),P===0)return{};const E={};return L.forEach(({col:D})=>{E[D]=(S[D]??0)/P}),E},"getGroupEdges"),Z=l(x=>{if(U[x])return{weights:F(x),color:U[x],label:x};const S=z[x]??null,P=S?U[S]??"#888888":"#888888";return{weights:k(x),color:P,label:x}},"resolve"),X=[],J=l(x=>{var E;const S=(E=y==null?void 0:y.rows)==null?void 0:E.call(y).find(D=>D.rowName===x);if(!S)return null;const P={};return v.forEach(({col:D})=>{const et=S.names.indexOf(D);if(et>=0){const ht=Number(S[et]);Number.isFinite(ht)&&(P[D]=ht)}}),P},"networkRow"),vt=l((x,S)=>{if(!S)return x;const P=Math.abs(x);return P<S[0]?0:P>S[1]?Math.sign(x)*S[1]:x},"thresholded");A.edgeLayers.forEach((x,S)=>{const P=l(K=>{var lt;return(lt=x.edgeColors.find(Q=>Q.source===K[0]&&Q.target===K[1]||!t.directed&&Q.source===K[1]&&Q.target===K[0]))==null?void 0:lt.color},"ownColor"),E=l((K,lt,Q,Ct,ft)=>{if(Q=vt(Q,x.threshold),Math.abs(Q)<1e-6)return;const Xe=P(lt);X.push({col:`${S}:${K}`,pair:lt,weight:Math.abs(Q),color:Xe??Ct,exact:Xe!==void 0,layer:S,...ft})},"push"),D=l((K,lt)=>x.colors?[x.colors[0],x.colors[1]??mn(x.colors[0])]:[K,lt],"signColors");if(x.network){const K=J(x.network);if(!K)return;const[lt,Q]=D(nt[0],nt[1]),Ct={name:x.name??x.network};v.forEach(({col:ft,pair:Xe})=>{const We=K[ft]??0;E(ft,Xe,We,We>=0?lt:Q,Ct)});return}const et=x.unit??x.group??null;if(!et)return;const ht=Z(et),Kt=x.compare??x.also??null,kt=Kt?Z(Kt):null,yt={name:x.name??et,group:x.group??void 0,unit:x.unit??void 0},[It,At]=D(ht.color,(kt==null?void 0:kt.color)??ht.color);kt&&x.compare?L.forEach(({col:K,pair:lt})=>{const Q=(ht.weights[K]??0)-(kt.weights[K]??0);E(K,lt,Q,Q>0?It:At,yt)}):kt&&x.also?L.forEach(({col:K,pair:lt})=>{const Q=ht.weights[K]??0,Ct=kt.weights[K]??0;Q>0&&E(K+"-a",lt,Q,It,yt),Ct>0&&E(K+"-b",lt,Ct,At,{...yt,name:x.also??void 0,group:x.also??void 0})}):L.forEach(({col:K,pair:lt})=>{const Q=ht.weights[K]??0;Q>0&&E(K,lt,Q,It,yt)})}),X.sort((x,S)=>S.weight-x.weight);const tt=!!t.directed,gt=on(A.edgeWidth)*(A.edgeMagnify??1),T=l(x=>{const S=x.map(Math.abs).filter(P=>P>0);return S.length?[Math.min(...S),Math.max(...S)]:[0,0]},"rangeOf"),[_e,bt]=N.length?[L,t.edges]:[v,y],Rt=l(x=>{const S=[];return _e.forEach(({col:P,pair:E})=>{if(E[0]===E[1]!==x)return;const D=bt==null?void 0:bt.col(P);if(D)for(const et of D)S.push(Number(et))}),T(S)},"modelRange"),Vt=l(x=>T(X.filter(S=>S.pair[0]===S.pair[1]===x).map(S=>S.weight)),"plotRange"),Ue=A.edgeColorScale,W=l(x=>Ue==="plot"?Vt(x):Rt(x),"colourRange"),_t=W(!1),de=W(!0),Es=l((x,S)=>{if(Ue==="absolute"){const D=Math.min(1,Math.abs(x));return{saturation:D,opacity:D}}const[P,E]=S?de:_t;return{saturation:Ai(x,P,E,Ji),opacity:Ai(x,P,E,Qi)}},"colourOf"),ge={};X.forEach(({pair:x,weight:S})=>{const P=x[0]===x[1],E=l(D=>{ge[D]=(ge[D]??0)+Math.abs(S)},"add");if(tt||P){E(x[1]);return}E(x[0]),E(x[1])}),t.nodes.rows().forEach(x=>{var ht;const S=x.names.indexOf(Y),P=S>=0?String(x[S]):"";if(!P)return;const E=ut.__data__.objects.get(P);if(!E)return;const D=ge[P]??0,et=!(D>0);E.size=et?A.hideUnconnectedNodes?0:rn:an(D,gt),E.meta={...E.meta??{},hidden:et&&A.hideUnconnectedNodes,sizePx:et||(ht=E.meta)==null?void 0:ht.sizePx}});const Zt={},B=l((x,S,P,E)=>`${x}:${S??""}:${P}.${E}`,"pairKey");tt&&X.forEach(({pair:x,weight:S,layer:P,name:E})=>{const D=B(P,E,x[0],x[1]);Zt[D]=(Zt[D]??0)+S}),X.forEach(({col:x,pair:S,weight:P,color:E,exact:D,layer:et,name:ht,group:Kt,unit:kt})=>{var We,Pi;const yt=ut.__data__.objects.get(S[0]),It=ut.__data__.objects.get(S[1]);if(!yt||!It)return;const At=S[0]===S[1],{saturation:K,opacity:lt}=Es(P,At),Q=new it({ID:`${S[0]}-src`,dimensions:[yt.x,yt.y],meta:{}}),Ct=new it({ID:`${S[1]}-dst`,dimensions:[It.x,It.y],meta:{}});let ft;if(At)ft=new ie({},Q,Ct),ft.weight=0;else if(tt){const Nn=Zt[B(et,ht,S[0],S[1])]??P,Mn=Zt[B(et,ht,S[1],S[0])]??0,kn=Nn+Mn;ft=new Ls({weight:P,totalweight:kn},Q,Ct)}else ft=new se({},Q,Ct);ft.ID=`edge-${x}`,ft.color=new rt(E),ft.meta={isMeanEdge:!0,weight:P,widthFrac:gt,saturation:K,opacity:lt,exactColor:D||void 0,isDirected:tt,isSelf:At,source:S[0],target:S[1],group:Kt,unit:kt,layer:ht,selfSize:At?((We=A.edgeLayers[et])==null?void 0:We.selfSize)??void 0:void 0,fixedSize:((Pi=A.edgeLayers[et])==null?void 0:Pi.fixedSize)||void 0},(At?zi??Ss:Ss).__data__.objects.set(ft.ID,ft)})}const C=A.showNodes;ut.svg_element&&(ut.svg_element.style.display=C?"":"none"),C||this._clearLabels(this._nodeLabels),Ht&&C&&(this._nodeLabels.forEach((z,$)=>{ut.__data__.objects.get($)||(z.remove(),this._nodeLabels.delete($))}),t.nodes.rows().forEach(z=>{var y,L,v;const $=z.names.indexOf(Y),M=$>=0?String(z[$]):"";if(!M)return;const N=ut.__data__.objects.get(M);if(N){if((y=N.meta)!=null&&y.hidden){(L=this._nodeLabels.get(M))==null||L.remove(),this._nodeLabels.delete(M);return}this._syncLabel(this._nodeLabels,M,rs(z,String(((v=N.meta)==null?void 0:v.name)??M)),N,Ht,vn,A.labelWeightNodes)}})),ut.__data__.__state__.setVariable("layer_updated",ut.__data__)}else ut==null||ut.__data__.__state__.setVariable("layer_updated",ut.__data__);[Ss,zi].forEach(C=>C==null?void 0:C.__data__.__state__.setVariable("layer_updated",C.__data__));const Oi=this.__children__.search("__children__","axis_points"),Li=this.__children__.search("__children__","axis_lines");Oi&&this.__data__.__state__.setVariable("graph_updated_axis_points",Oi.__data__.objects),Li&&this.__data__.__state__.setVariable("graph_updated_axis_lines",Li.__data__.objects),this.update(),w&&this._startTween(w)}}_syncLabel(t,e,s,i,n,r,o){let a=t.get(e);const h=s.text!=null&&(r!==G.DISPLAY_TYPES.OFF||s.pinned);a&&(!h||a.text!==s.text||a.displayMode!==r)&&(a.remove(),t.delete(e),a=void 0),h&&(a?(a.setPoint(i),r===G.DISPLAY_TYPES.ON&&a.show()):(a=new Ps(s.text,i,n,this,r),t.set(e,a)),s.offset&&a.setOffset(s.offset.x,s.offset.y),a.fontWeight=o,a.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 m;const t=this._host.querySelector("qe-nodes"),e=this._host.querySelector("qe-means"),s=[...this._host.querySelectorAll("qe-points")],i=s.find(_=>!_.hasAttribute("set"))??null,n=s.filter(_=>_.hasAttribute("set")),r=[...this._host.querySelectorAll("qe-edges")],o=l(_=>{var d;return((d=r.find(u=>u.hasAttribute(_)))==null?void 0:d.getAttribute(_))??null},"firstAttr"),a=r.find(_=>_.hasAttribute("magnify")),h=this._host.querySelector("qe-trajectories"),g=this._host.querySelector("qe-axes"),f=this._host.getAttribute("labels");return{labelNodes:os((t==null?void 0:t.getAttribute("label"))??this._host.getAttribute("label-nodes")??f,G.DISPLAY_TYPES.ON),labelWeightNodes:(t==null?void 0:t.getAttribute("label-font-weight"))||null,nodeFixedSize:!!t&&t.hasAttribute("fixed-size"),showNodes:!!t,nodeColors:new Map(Mi(t,"qe-node",["node"]).map(_=>[_.node,_.color])),range:(()=>{const _=this._host.getAttribute("range");if(_==="network"||_==="points")return _;const d=Number(_);return _!=null&&Number.isFinite(d)&&d>0?d:null})(),plotTitle:this._host.getAttribute("plot-title")||null,labelFont:{size:(()=>{const _=Number(this._host.getAttribute("label-font-size"));return Number.isFinite(_)&&_>0?_:null})(),family:this._host.getAttribute("label-font-family")||null,color:this._host.getAttribute("label-font-color")||null},edgeWidth:(()=>{const _=Number(this._host.getAttribute("edge-width"));return Number.isFinite(_)&&_>0&&_<=1?_:Ki})(),hideUnconnectedNodes:((m=t==null?void 0:t.getAttribute("unconnected"))==null?void 0:m.toLowerCase())==="hide",scalePoints:this._host.getAttribute("scale-points")!=="false",pointScale:(()=>{const _=Number(this._host.getAttribute("point-scale"));return this._host.hasAttribute("point-scale")&&Number.isFinite(_)&&_>0?_:null})(),centerContent:this._host.getAttribute("center")==="content",showMeans:!!e,activeMeanGroups:(e==null?void 0:e.getAttribute("groups"))??null,showCI:!!e&&e.hasAttribute("confidence"),intervals:(()=>{const _=e==null?void 0:e.getAttribute("intervals");return _==="box"||_==="crosshairs"||_==="none"?_:e!=null&&e.hasAttribute("confidence")?"box":"none"})(),showOutlier:!!e&&e.hasAttribute("outlier"),labelMeans:os((e==null?void 0:e.getAttribute("label"))??this._host.getAttribute("label-means")??f,G.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(_=>({set:_.getAttribute("set"),size:_.getAttribute("size")?parseFloat(_.getAttribute("size")):null,fixedSize:_.hasAttribute("fixed-size"),labelMode:os(_.getAttribute("label")??this._host.getAttribute("label-points")??f,G.DISPLAY_TYPES.OFF),labelWeight:_.getAttribute("label-font-weight")||null})),labelPoints:os((i==null?void 0:i.getAttribute("label"))??this._host.getAttribute("label-points")??f,G.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(fn),edgeColorScale:pn(o("color-scale")),edgeMagnify:a?(()=>{const _=Number(a.getAttribute("magnify"));return Number.isFinite(_)&&_>0?_:1})():null,showTrajectories:!!h,trajectoryUnits:(h==null?void 0:h.getAttribute("units"))??null,trajectorySmooth:(h==null?void 0:h.getAttribute("smooth"))??"none",trajectoryMaxDegree:h!=null&&h.getAttribute("max-degree")?parseInt(h.getAttribute("max-degree"),10):3,trajectoryDegreeSelection:(h==null?void 0:h.getAttribute("degree-selection"))??"loocv_2d",trajectoryShowPoints:(h==null?void 0:h.getAttribute("points"))!=="false",trajectoryShowTips:(h==null?void 0:h.getAttribute("tips"))!=="false",trajectoryPlayhead:h!=null&&h.getAttribute("playhead")?parseFloat(h.getAttribute("playhead")):null,trajectoryLineStyle:(h==null?void 0:h.getAttribute("line-style"))??"uniform",trajectoryStrokeWidth:h!=null&&h.getAttribute("stroke-width")?parseFloat(h.getAttribute("stroke-width")):2,trajectoryStrokeWidthRange:this._parseNumberPair(h==null?void 0:h.getAttribute("stroke-width-range"),[1,6]),trajectoryOpacityRange:this._parseNumberPair(h==null?void 0:h.getAttribute("opacity-range"),[.3,1]),showAxes:!!g,axesFixedSize:!!g&&g.hasAttribute("fixed-size"),axisXLabel:g!=null&&g.hasAttribute("x")?g.getAttribute("x")??"":null,axisYLabel:g!=null&&g.hasAttribute("y")?g.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 i;const t=this._host.getAttribute("width"),e=this._host.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),at._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","source","target","node","color","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._host.getAttribute("for");this._vizena=(s?document.getElementById(s):null)??this.closest("qe-visual")??((i=this.parentElement)==null?void 0:i.closest("qe-visual"))??document.querySelector("qe-visual"),this.mount()}mount(){this.draw();const t=this.__children__.search("__children__","labels");if(t!=null&&t.svg_element)this._labelsGroup=t.svg_element;else{console.warn("[ena-graph] labels layer not found in layer tree; creating fallback <g>");const e=this.__children__[0];e!=null&&e.svg_element&&(this._labelsGroup=this.doc.createElementNS("http://www.w3.org/2000/svg","g"),this._labelsGroup.setAttribute("data-layer-name","labels-fallback"),e.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,at._instances.delete(this),(s=this._tooltipEl)==null||s.remove(),this._tooltipEl=null}static instances(){return[...at._instances]}static getGraph(t){for(const e of at._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=l(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=l(e=>{const s=Number(this._host.getAttribute(e));return this._host.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._host.getAttribute("zoom-step"));return this._host.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 o=performance.now(),a=l(h=>{const g=Math.min(1,Math.max(0,(h-o)/i));this._zoomAbout(g>=1?r:n*Math.pow(r/n,1-Math.pow(1-g,3)),e,s),this._zoomAnim=g<1?requestAnimationFrame(a):null},"step");this._zoomAnim=requestAnimationFrame(a)}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(at._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((o,a)=>t.set(`${r}:${a}`,[o.x,o.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=l((p,w)=>!!w&&p.length===w.length&&p.every((I,j)=>I===w[j]),"same"),i=[];for(const p of["points","nodes"])(b=this._layerObjects(p))==null||b.forEach((w,I)=>{const j=`${p}:${I}`,Y=t.marks.get(j);Y&&i.push({key:j,o:w,tx:w.x,ty:w.y,cx:Y[0],cy:Y[1]})});const n=this._intervalMarks().map(p=>({el:p,to:this._boxGeom(p),cur:t.boxes.get(p)})).filter(p=>p.cur&&p.cur.length===p.to.length),r=this.__data__.extremes,o=[r.x_max,r.y_max,r.cx,r.cy],a=t.running,h=!!a&&a.k<.95&&s(o,a.view)&&i.every(p=>s([p.tx,p.ty],a.marks.get(p.key)??[p.cx,p.cy]))&&n.every(p=>s(p.to,a.boxes.get(p.el)??p.cur)),g=h?a.k:0,f=l((p,w)=>g>0?(p-g*w)/(1-g):p,"from"),m=i.map(p=>({key:p.key,o:p.o,tx:p.tx,ty:p.ty,fx:f(p.cx,p.tx),fy:f(p.cy,p.ty)})).filter(p=>p.fx!==p.tx||p.fy!==p.ty),_=n.map(p=>({el:p.el,to:p.to,from:p.cur.map((w,I)=>f(w,p.to[I])),attrs:Object.fromEntries(["x","y","width","height","d"].filter(w=>p.el.hasAttribute(w)).map(w=>[w,p.el.getAttribute(w)]))})).filter(p=>!s(p.from,p.to)),d=t.view.map((p,w)=>f(p,o[w]));if(!m.length&&!_.length&&s(d,o))return;this._tween={t0:h?a.t0:e,dur:this._animateMs,k:g,marks:m,boxes:_,view:{from:d,to:o}},this._tweenFrame(g);const u=l(p=>{const w=this._tween;if(!w)return;const I=(p-w.t0)/w.dur;if(I>=1){this._endTween();return}this._tweenFrame(Math.max(w.k,at._ease(Math.max(0,I)))),this._tweenRaf=requestAnimationFrame(u)},"step");this._tweenRaf=requestAnimationFrame(u)}_tweenFrame(t){const e=this._tween;if(!e)return;e.k=t;const s=l((i,n)=>i+(n-i)*t,"lerp");e.marks.forEach(i=>at._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,o)=>s(r,i.to[o]));if("d"in i.attrs){let r=0;i.el.setAttribute("d",i.attrs.d.replace(at._PATH_NUM_RE,()=>String(n[r++])))}else["x","y","width","height"].forEach((r,o)=>i.el.setAttribute(r,String(n[o])))}),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=>at._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 o,a;const n=t.get((o=i.meta)==null?void 0:o.source),r=t.get((a=i.meta)==null?void 0:a.target);n&&i.from&&at._setXY(i.from,n.x,n.y),r&&i.to&&at._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))),typeof XMLSerializer<"u"&&!this._headless?new XMLSerializer().serializeToString(t):Ze(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,o)=>{const a=new Blob([e],{type:"image/svg+xml;charset=utf-8"}),h=URL.createObjectURL(a),g=new Image;g.onload=()=>{try{const f=document.createElement("canvas");f.width=i*t,f.height=n*t;const m=f.getContext("2d");if(!m){URL.revokeObjectURL(h),o(new Error("no 2d context"));return}m.scale(t,t),m.drawImage(g,0,0,i,n),URL.revokeObjectURL(h),r(f.toDataURL("image/png"))}catch(f){URL.revokeObjectURL(h),o(f)}},g.onerror=f=>{URL.revokeObjectURL(h),o(f)},g.src=h})}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 g;if(!this.svg_element)return;this._highlightGroup||(this._highlightGroup=this.doc.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=(g=this.__children__[0])==null?void 0:g.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,o=this._edgesFixedSize?r:1,a=l(f=>{var d;const m=l(u=>{var b;return(b=this.__children__.search("__children__",u))==null?void 0:b.__data__.objects.get(f)},"find"),_=(d=m("nodes")??m("points"))==null?void 0:d.meta;return _!=null&&_.zoomFixed||_!=null&&_.fixedSize?r:1},"markK"),h=l((f,m)=>{const _=this.doc.createElementNS("http://www.w3.org/2000/svg",f);for(const d in m)_.setAttribute(d,String(m[d]));return _},"mk");if(this._highlight.edges.size){const f={};this.getNodes().forEach(m=>{f[m.id]={x:m.x,y:m.y}}),this._highlight.edges.forEach(m=>{const[_,d]=m.split("\0"),u=f[_],b=f[d];!u||!b||s.appendChild(h("line",{x1:u.x,y1:u.y,x2:b.x,y2:b.y,stroke:n,"stroke-width":i*.02/o,"stroke-opacity":.6,"stroke-linecap":"round"}))})}this._highlight.nodes.forEach(f=>{var p;const m=this.svg_element.querySelector(`[data-point-id="${(p=globalThis.CSS)!=null&&p.escape?globalThis.CSS.escape(f):f}"]`);if(!m)return;const _=m.tagName.toLowerCase();let d,u,b;if(_==="rect"){const w=parseFloat(m.getAttribute("width")||"0");d=parseFloat(m.getAttribute("x")||"0")+w/2,u=parseFloat(m.getAttribute("y")||"0")+parseFloat(m.getAttribute("height")||"0")/2,b=w/2}else d=parseFloat(m.getAttribute("cx")||"0"),u=parseFloat(m.getAttribute("cy")||"0"),b=parseFloat(m.getAttribute("r")||"0");s.appendChild(h("circle",{cx:d,cy:u,r:b*1.7+i*.004/a(f),fill:"none",stroke:n,"stroke-width":i*.006/a(f)}))})}create(){const t=this.doc.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=this.doc.createElementNS("http://www.w3.org/2000/svg","defs"),s=.22,i=.15,n=l((r,o)=>{const a=this.doc.createElementNS("http://www.w3.org/2000/svg","marker");a.setAttribute("id",r),a.setAttribute("markerWidth",String(s)),a.setAttribute("markerHeight",String(i)),a.setAttribute("refX",String(s)),a.setAttribute("refY",String(i/2)),a.setAttribute("orient","auto"),a.setAttribute("markerUnits","userSpaceOnUse");const h=this.doc.createElementNS("http://www.w3.org/2000/svg","path");h.setAttribute("d",`M0,0 L0,${i} L${s},${i/2} z`),h.setAttribute("fill",o),a.appendChild(h),e.appendChild(a)},"makeArrow");return Ni.forEach(r=>n(`qe-arrow-${r.slice(1)}`,r)),t.appendChild(e),this.__data__.layers.forEach(r=>{const o=new ss(r,this.svg_element,this);this.__children__.push(o)}),this.__data__.__state__.setVariable("graph_updated",this.__data__),this.attach_events(),t}attach_events(){const t=l(()=>this._host.hasAttribute("view-locked"),"locked");this.svg_element.addEventListener("wheel",d=>{if(t())return;d.preventDefault();const u=d.deltaMode===1?33:d.deltaMode===2?this.svg_element.clientHeight||800:1,b=d.deltaY*u,p=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)*p,w[0],w[1]):this.zoomBy(p)},{passive:!1}),this.svg_element.addEventListener("dblclick",d=>{var b,p;if(t()||(p=(b=d.target)==null?void 0:b.closest)!=null&&p.call(b,"text[data-label-for]"))return;d.preventDefault();const u=this._clientToRoot(d.clientX,d.clientY);u&&this._animateZoomAbout((this.zoom_level||1)*2.2,u[0],u[1],200)});const e=new Map;let s=null;const i=l(()=>{const[d,u]=[...e.values()];return d?u?{mid:[(d[0]+u[0])/2,(d[1]+u[1])/2],dist:Math.hypot(d[0]-u[0],d[1]-u[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 u=i();if(u&&s&&u.n===s.n){const b=this._clientToRoot(...s.mid),p=this._clientToRoot(...u.mid);if(b&&p){const w=this.__data__.transform;w.pan(p[0]-b[0],p[1]-b[1]),u.n===2&&s.dist>0&&u.dist>0?this._zoomAbout((this.zoom_level||1)*u.dist/s.dist,p[0],p[1]):this.__children__[0].svg_element.setAttribute("transform",w.toString())}}s=u});const n=l(d=>{e.delete(d.pointerId)&&(s=i())},"touchEnd");this.svg_element.addEventListener("pointerup",n),this.svg_element.addEventListener("pointercancel",n);let r=!1,o=0,a=0;this.svg_element.addEventListener("mousedown",d=>{t()||(r=!0,o=d.clientX,a=d.clientY)});let h=null,g=null;const f=l(()=>{g&&(this.__data__.transform.pan(g.dx,g.dy),this.__children__[0].svg_element.setAttribute("transform",this.__data__.transform.toString()),g=null),h=null},"panUpdate");this.svg_element.addEventListener("mousemove",d=>{if(!r)return;if(d.buttons===0){r=!1;return}const u=this._clientToRoot(o,a),b=this._clientToRoot(d.clientX,d.clientY);o=d.clientX,a=d.clientY,!(!u||!b)&&(g={dx:((g==null?void 0:g.dx)??0)+b[0]-u[0],dy:((g==null?void 0:g.dy)??0)+b[1]-u[1]},h===null&&(h=requestAnimationFrame(f)))}),this.svg_element.addEventListener("mouseup",d=>{r=!1}),this.svg_element.addEventListener("point-clicked",(d=>{var p,w;const u=(w=(p=d.detail)==null?void 0:p.pointData)==null?void 0:w.ID;if(!u)return;const b=this._pointLabels.get(u)??this._setLabels.get(u)??this._meanLabels.get(u.replace("mean-",""))??this._nodeLabels.get(u);b&&b.displayMode===G.DISPLAY_TYPES.CLICK&&b.toggle()}));const m=l(d=>{var u;for(;d&&d!==this.svg_element;){const b=(u=d.getAttribute)==null?void 0:u.call(d,"data-point-id");if(b)return b;d=d.parentElement}return null},"findPointId"),_=l(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 u=m(d.target);if(!u)return;const b=_(u);(b==null?void 0:b.displayMode)===G.DISPLAY_TYPES.AUTO&&b.show()}),this.svg_element.addEventListener("mouseout",d=>{const u=m(d.target);if(!u)return;const b=d.relatedTarget;if(m(b)===u)return;const w=_(u);(w==null?void 0:w.displayMode)===G.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"),o={id:r,kind:e.getAttribute("data-kind")||"point",name:e.getAttribute("data-name")||r,x:i,y:n};return e.hasAttribute("data-group")&&(o.group=e.getAttribute("data-group")),e.hasAttribute("data-unit")&&(o.unit=e.getAttribute("data-unit")),o}_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 o=this._nodeDetail(n);o&&this._emit("qe-node-click",{...o,originalEvent:i})});let e=null;const s=l((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),o=r?null:this._nodeDetail(n),a=r?{type:"edge",detail:r}:o?{type:"node",detail:o}:null,h=a?s(a.type,a.detail):null;e&&(!a||e.key!==h)&&(this._emit(e.type==="edge"?"qe-edge-unhover":"qe-node-unhover",{key:e.key}),e=null),a&&(!e||e.key!==h)&&(this._emit(a.type==="edge"?"qe-edge-hover":"qe-node-hover",{...a.detail,originalEvent:i}),e={type:a.type,key:h}),this._host.hasAttribute("tooltip")&&a?this._showTooltip(this._tooltipText(a.type,a.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=this.doc.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(this._headless||(t=this.wrapper)==null||t.appendChild(this.svg_element),this.__children__.forEach(e=>{e.draw()}),!this._headless&&!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 f,m;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,o=r*.6,a=r/(this._axesFixedSize&&this.zoom_level||1),h=a*.6,g=l((_,d)=>{let u=this._axisLabelEls.get(_);if(!this._showAxes||d==null){u&&(u.remove(),this._axisLabelEls.delete(_));return}u||(u=this.doc.createElementNS("http://www.w3.org/2000/svg","text"),u.setAttribute("data-axis-label",_),u.setAttribute("pointer-events","none"),e.appendChild(u),this._axisLabelEls.set(_,u)),u.textContent=d,u.setAttribute("font-size",a.toString()),u.setAttribute("font-family","system-ui, sans-serif"),u.setAttribute("font-weight","600"),u.setAttribute("fill","#556"),_==="x"?(u.setAttribute("x",(i+s-h).toString()),u.setAttribute("y",(-h).toString()),u.setAttribute("text-anchor","end")):(u.setAttribute("x",h.toString()),u.setAttribute("y",(n-s+a+h).toString()),u.setAttribute("text-anchor","start"))},"place");if(g("x",this._axisXText),g("y",this._axisYText),this._magnifyText==null)(f=this._magnifyEl)==null||f.remove(),this._magnifyEl=null;else{this._magnifyEl||(this._magnifyEl=this.doc.createElementNS("http://www.w3.org/2000/svg","text"),this._magnifyEl.setAttribute("data-magnify-label",""),this._magnifyEl.setAttribute("pointer-events","none")),this._magnifyEl.parentElement||e.appendChild(this._magnifyEl);const _=this._magnifyEl;_.textContent=this._magnifyText,_.setAttribute("font-size",(r*.85).toString()),_.setAttribute("font-family","system-ui, sans-serif"),_.setAttribute("font-style","italic"),_.setAttribute("fill","#556"),_.setAttribute("x",(i-s+o).toString()),_.setAttribute("y",(n-s+r+o).toString()),_.setAttribute("text-anchor","start")}if(!this._plotTitle)(m=this._titleEl)==null||m.remove(),this._titleEl=null;else{this._titleEl||(this._titleEl=this.doc.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(),u=this._titleEl;u.textContent=this._plotTitle,u.setAttribute("font-size",d.toString()),u.setAttribute("font-family",this._labelFont.family??"system-ui, sans-serif"),u.setAttribute("font-weight","600"),u.setAttribute("fill",this._labelFont.color??"#223"),u.setAttribute("x",i.toString()),u.setAttribute("y",(n-s+d*1.1).toString()),u.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,o]=this._tweenView;t.extremes=new Ft(i,n,r,o)}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 Ft(r,r,i,n)}const e=(s=this.svg_element)==null?void 0:s.getBoundingClientRect();if(this.svg_element&&e){Jt("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 o=r.objects.get("axis-x"),a=r.objects.get("axis-y");if(o&&a){const h=this.__data__.extremes;o.from=new it({ID:"axis-x-start",dimensions:[h.cx-h.x_max,0],classes:["ena.dimension","ena.dimension"]}),o.to=new it({ID:"axis-x-end",dimensions:[h.cx+h.x_max,0],classes:["ena.dimension","ena.dimension"]}),a.from=new it({ID:"axis-y-start",dimensions:[0,h.cy-h.y_max],classes:["ena.dimension","ena.dimension"]}),a.to=new it({ID:"axis-y-end",dimensions:[0,h.cy+h.y_max],classes:["ena.dimension","ena.dimension"]})}}}}update_layers(){this.__children__.forEach(t=>{t.update()})}};l(at,"QEGraphElement"),at.tagName="qe-graph",at.style=`
|
|
19
|
-
${
|
|
18
|
+
`;let ks=$s;const Xi=1e-8;function Qs(c,t=Xi){return c.filter(e=>Math.abs(e.x)>t||Math.abs(e.y)>t)}l(Qs,"nearOriginFilter");function Fn(c){if(c<=0)return[];if(c===1)return[0];const t=new Array(c);for(let e=0;e<c;e++)t[e]=e/(c-1);return t}l(Fn,"normalizedT");function Ui(c){if(c.length===0||!c.every(i=>typeof i.t=="number"&&isFinite(i.t)))return Fn(c.length);let t=1/0,e=-1/0;for(const i of c)i.t<t&&(t=i.t),i.t>e&&(e=i.t);const s=e-t;return c.map(i=>s>0?(i.t-t)/s:0)}l(Ui,"fitTimes");function Wi(c){return new Set(c).size-1}l(Wi,"supportedDegree");function Hi(c,t){return c.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})}l(Hi,"design");function Vi(c){const t=c.length,e=c[0].length,s=c.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 o=0;o<t;o++)r+=s[o][n]*s[o][n];if(r=Math.sqrt(r),i[n][n]=r,r>1e-300)for(let o=0;o<t;o++)s[o][n]/=r;for(let o=n+1;o<e;o++){let a=0;for(let h=0;h<t;h++)a+=s[h][n]*s[h][o];i[n][o]=a;for(let h=0;h<t;h++)s[h][o]-=a*s[h][n]}}return{Q:s,R:i}}l(Vi,"qr");function ti(c,t){const e=c.length,s=c[0].length,i=new Array(s).fill(0);for(let n=0;n<s;n++){let r=0;for(let o=0;o<e;o++)r+=c[o][n]*t[o];i[n]=r}return i}l(ti,"qtY");function ei(c,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-=c[i][r]*s[r];s[i]=Math.abs(c[i][i])>1e-12?n/c[i][i]:0}return s}l(ei,"backSolve");function jn(c){return c.map(t=>{let e=0;for(let s=0;s<t.length;s++)e+=t[s]*t[s];return e})}l(jn,"leverages");function Zi(c,t,e){const s=Hi(c,e),{Q:i,R:n}=Vi(s);return ei(n,ti(i,t))}l(Zi,"fitCoeffs");function Ue(c,t){let e=0,s=1;for(let i=0;i<c.length;i++)e+=c[i]*s,s*=t;return e}l(Ue,"evalPoly");function qn(c,t,e,s){const i=Hi(c,s),{Q:n,R:r}=Vi(i),o=jn(n),a=ei(r,ti(n,t)),h=ei(r,ti(n,e));let _=0;for(let p=0;p<c.length;p++){const b=1-o[p];if(b<=0)return 1/0;const d=t[p]-Ue(a,c[p]),f=e[p]-Ue(h,c[p]);_+=(d/b)**2+(f/b)**2}return _}l(qn,"loocv2d");function Ki(c,t,e){const s=c.length,i=Ui(c),n=Math.min(Math.max(1,Math.floor(t)),Math.max(1,s-1),Math.max(1,Wi(i)));if(e==="fixed"||s<3)return n;const r=c.map(_=>_.x),o=c.map(_=>_.y);let a=1,h=1/0;for(let _=1;_<=n;_++){const p=qn(i,r,o,_);p<h&&(h=p,a=_)}return a}l(Ki,"selectDegree");function Ji(c,t){const e=Qs(c);if(e.length<3)return null;const s=t.selectionSet?Qs(t.selectionSet):e,i=s.length>=3?s:e;let n=Ki(i,t.maxDegree,t.degreeSelection);const r=Ui(e),o=Wi(r);if(o<1)return null;n=Math.min(n,Math.max(1,e.length-1),o);const a=Zi(r,e.map(_=>_.x),n),h=Zi(r,e.map(_=>_.y),n);return{degree:n,coeffsX:a,coeffsY:h}}l(Ji,"fitTrajectory");function si(c,t=100){const e=[];for(let s=0;s<=t;s++){const i=s/t;e.push({x:Ue(c.coeffsX,i),y:Ue(c.coeffsY,i)})}return e}l(si,"sampleCurve");const Qi=100,wi=class wi extends ee{constructor(t={}){const e=t.color instanceof gt?t.color:new gt(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.fitTime="index",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.fitTime=t.fitTime==="time"?"time":"index",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 _t)return s;const i=new _t({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 si({degree:this.polyCoeffsX.length-1,coeffsX:this.polyCoeffsX,coeffsY:this.polyCoeffsY},Qi);const e=this.fitTime==="time"?i=>{var n;return{x:i.x,y:i.y,t:(n=i.meta)==null?void 0:n.time}}:i=>({x:i.x,y:i.y}),s=Ji(t.map(e),{maxDegree:this.maxDegree,degreeSelection:this.degreeSelection,selectionSet:this.trajPoints.map(e)});if(s)return this.selectedDegree=s.degree,si(s,Qi)}return t.map(e=>({x:e.x,y:e.y}))}};l(wi,"Trajectory");let We=wi;const tn=1,vi=class vi extends fe{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 gt("#000000");return new Be(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}};l(vi,"Edge");let He=vi;const Rs=class Rs extends ee{constructor(e){super(e.dimensions||[],e);Et(this,Pe);ut(this,Pe,e)}get edge(){return U(this,Pe)}get path(){const e=U(this,Pe),s=[e.to.x,e.to.y],i=e.from_point,[n,r]=e.base_pts,o=Math.hypot(i[0]-s[0],i[1]-s[1]),a=Math.hypot(n[0]-r[0],n[1]-r[1]);if(!(o>0)||!(a>0))return"";const h=[(i[0]-s[0])/o,(i[1]-s[1])/o],_=Math.hypot(n[0]-s[0],n[1]-s[1]),p=[(n[0]-s[0])/_,(n[1]-s[1])/_],b=l(d=>a/2*Math.max(0,1-d/o),"halfW");return Rs.chevron(s,h,p,o,b).path}static chevron(e,s,i,n,r){const o=l((d,f)=>`${e[0]+s[0]*d+i[0]*f} ${e[1]+s[1]*d+i[1]*f}`,"at"),a=.2*n,h=Math.min(.15*n,.8*2*r(a)),_=a+h/2,p=a+h;return{path:`M${o(a,0)} L${o(_,r(_))} L${o(p,r(p))} L${o(_,0)} L${o(p,-r(p))} L${o(_,-r(_))}z`,span:[a,p]}}};Pe=new WeakMap,l(Rs,"EdgeArrow");let Ve=Rs;const Ts=class Ts extends He{constructor(e,s,i){super(e,s,i);Et(this,Oe);Et(this,ps);this._path="",ut(this,Oe,!1),this._directions=["from","to"],this.towards="to",U(this,Oe)===!0&&ut(this,ps,new Ve(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(g=>g!==e.towards),n=e[i].x,r=e[i].y,o=e[s].x,a=e[s].y,h=o-n,_=a-r,p=Math.hypot(h,_),b=(e.weight??0)*tn;if(p===0||!isFinite(b)||b===0)return[[o,a],[o,a]];const d=-_/p,f=h/p,u=b/2;return[[o+d*u,a+f*u],[o-d*u,a-f*u]]}get base_pts(){return Ts.calculate_base_points(this)}get arrow(){return U(this,ps)}get with_arrow(){return U(this,Oe)}get from_point(){return[this.from.x,this.from.y]}};Oe=new WeakMap,ps=new WeakMap,l(Ts,"TaperedEdge");let ie=Ts;const Ds=class Ds extends ie{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 Xe.Geometry.Line.interpolate(this.line)(1-this._dataWeight/this._totalweight)}get base_pts(){return ie.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 Ds.build_path(this)}get from_point(){return this.weighted_midpoint}};l(Ds,"TaperedWeightedMidpointEdge");let Is=Ds;const Fs=class Fs extends He{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*tn;return Fs.build_path(t,this.to)}};l(Fs,"NodeEdge");let Me=Fs;const Ai=class Ai{constructor(t,e,s,i=new ne){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 o(a){const h=Math.min(1,(a-r)/n),_=i+(s-i)*h;t.setAttribute(e,_.toString()),h<1?requestAnimationFrame(o):t.setAttribute(e,s.toString())}l(o,"animate"),requestAnimationFrame(o)}};l(Ai,"Drawable");let Ze=Ai;const Yn=.04,Bn=[.25,1],Gn=[.3,1];function en(c,t,e,s){const i=Math.abs(c);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])}l(en,"rampFor");const sn=.011,nn=.75,Xn=.8,Un=.75,rn=.006,Wn=.6;function Hn(c){return 2*c}l(Hn,"widthPerWeight");function Vn(c,t){return c*t/(2*rn)}l(Vn,"nodeSizeForEdges");function Zn(c){const t=/rgba?\(([^)]+)\)/.exec(c);if(!t)return c;const[e,s,i,n=1]=t[1].split(",").map(Number),r=l(o=>Math.round(255+(o-255)*n),"f");return`rgb(${r(e)},${r(s)},${r(i)})`}l(Zn,"flattenOnWhite");function Kn(c,t){const e=/rgba?\(([^)]+)\)/.exec(c);if(!e)return c;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})`}l(Kn,"darkenRgba");const Si=class Si extends Ze{constructor(t,e,s,i=new ne){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._slices=[],this._arrowPart=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=l((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 Me){const e=this.graph.doc.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 ie){const e=this.graph.doc.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=this.graph.doc.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 Me||this.__data__ instanceof ie}update(){var i,n,r,o;if(this.svg_element||this.create(),this.svg_element.tagName.toLowerCase()==="path"!==this.drawsPath){const a=this.svg_element;this.create(),a.parentElement&&a.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 a=typeof e.weight=="number"?e.weight:0,h=typeof e.maxWeight=="number"?e.maxWeight:1,_=typeof e.depthScale=="number"?e.depthScale:1,p=typeof e.opacity=="number"?e.opacity:Math.min(1,a/(h||1)),b=t>0?t:1,d=e.fixedSize&&this.graph.zoom_level||1,f=(typeof e.widthFrac=="number"?b*e.widthFrac*a:b*sn*(a/(h||1)))*_/d,u=this.__data__._color||new gt("#000000"),g=typeof e.saturation=="number"?e.saturation:p,y=e.exactColor?u.toString():new Be(u,g,p).toString();if(this.__data__ instanceof Me){const m=typeof e.selfSize=="number"&&e.selfSize>0?e.selfSize:null,w=m!=null?(o=(r=this.graph)._nodeRadius)==null?void 0:o.call(r,String(e.source)):null;this.__data__.weight=typeof w=="number"?2*m*w:f,this.svg_element.setAttribute("d",this.__data__.path),this.svg_element.setAttribute("fill",y),this.svg_element.setAttribute("stroke","none")}else if(this.__data__ instanceof ie&&e.ends3d&&e.isDirected&&this.__data__ instanceof Is&&this._drawSlices(e,b*(typeof e.widthFrac=="number"?e.widthFrac*a:sn*(a/(h||1)))/d,y))this.__data__.weight=f,s=!!this._arrow_el;else if(this.__data__ instanceof ie){if(this._clearSlices(),this.__data__.weight=f,this.svg_element.setAttribute("d",this.__data__.path),this.svg_element.setAttribute("fill",y),this.svg_element.setAttribute("stroke",y),this.svg_element.setAttribute("stroke-width",String(nn)),this.svg_element.setAttribute("vector-effect","non-scaling-stroke"),this.svg_element.setAttribute("stroke-linejoin","round"),e.isDirected)try{const w=new Ve(this.__data__).path;w&&!w.includes("NaN")&&!w.includes("Infinity")&&(this._setArrow(w,y),s=!0)}catch{}}else{this._clearSlices();const m=this.__data__.from.x,w=this.__data__.from.y,S=this.__data__.to.x,v=this.__data__.to.y;this.svg_element.setAttribute("x1",m.toString()),this.svg_element.setAttribute("y1",w.toString()),this.svg_element.setAttribute("x2",S.toString()),this.svg_element.setAttribute("y2",v.toString()),this.svg_element.setAttribute("stroke-width",f.toString()),this.svg_element.setAttribute("stroke",y),this.svg_element.setAttribute("pointer-events","stroke"),this.svg_element.removeAttribute("marker-end"),this._hit_el||(this._hit_el=this.graph.doc.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",m.toString()),this._hit_el.setAttribute("y1",w.toString()),this._hit_el.setAttribute("x2",S.toString()),this._hit_el.setAttribute("y2",v.toString()),this._hit_el.setAttribute("stroke-width",Math.max(f,t*.03/d).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 a=this.graph._axesFixedSize&&String(this.__data__.ID).startsWith("axis-")&&this.graph.zoom_level||1,h=(t>0?t:1)*.004*this.get_size()/a;this.svg_element.setAttribute("stroke-width",h.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,this._arrowPart=null)}_setArrow(t,e){this._arrow_el||(this._arrow_el=this.graph.doc.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",t),this._arrow_el.setAttribute("fill",Kn(Zn(e),Xn)),this._arrow_el.setAttribute("stroke","#ffffff"),this._arrow_el.setAttribute("stroke-width",String(Un)),this._arrow_el.setAttribute("vector-effect","non-scaling-stroke"),this._arrow_el.setAttribute("stroke-linejoin","round")}_drawSlices(t,e,s){const i=this.__data__,n=i.from,r=i.to,o=r.x-n.x,a=r.y-n.y,h=Math.hypot(o,a),_=i._totalweight,p=i._dataWeight,{d0:b,d1:d,k0:f,k1:u}=t.ends3d,g=1-p/_;if(!(h>0)||!(e>0)||!(_>0)||!(g>=0&&g<1)||!(f>0&&u>0))return this._clearSlices(),!1;const y=l(W=>W*f/((1-W)*u+W*f),"sOf"),m=l(W=>W*u/((1-W)*f+W*u),"tOf"),w=l(W=>1/((1-W)/f+W/u),"kOf"),S=l(W=>b+(d-b)*W,"depthOf"),v=!!t.edgePerspective,T=l(W=>e/2*Math.max(0,(W-g)/(1-g))*(v?w(W):1),"halfAt"),Q=o/h,E=a/h,ot=-E,et=Q,st=l(W=>{const wt=y(W);return{x:n.x+o*wt,y:n.y+a*wt,h:T(W)}},"at"),A=l((W,wt)=>`${W.x+ot*wt} ${W.y+et*wt}`,"xy"),J=Math.max(2,Math.round((t.slices??14)*(1-g))),yt=this.graph.doc,le=l(()=>yt.createElementNS("http://www.w3.org/2000/svg","path"),"mk");for(;this._slices.length>J;){const W=this._slices.pop();W.fill!==this.svg_element&&W.fill.remove(),W.side.remove()}for(let W=0;W<J;W++){const wt=g+(1-g)*W/J,Zt=g+(1-g)*(W+1)/J,Mt=st(wt),mt=st(Zt);let $=this._slices[W];$||($={fill:W===0?this.svg_element:le(),side:le(),depth:0,from:Mt,to:mt},this._slices.push($)),W===0&&($.fill=this.svg_element),$.depth=(S(wt)+S(Zt))/2,$.from={x:Mt.x,y:Mt.y},$.to={x:mt.x,y:mt.y},$.fill.setAttribute("d",`M${A(Mt,Mt.h)} L${A(mt,mt.h)} L${A(mt,-mt.h)} L${A(Mt,-Mt.h)}z`),$.fill.setAttribute("fill",s),$.fill.setAttribute("stroke","none"),["stroke-width","vector-effect","stroke-linejoin"].forEach($e=>$.fill.removeAttribute($e)),$.side.setAttribute("d",`M${A(Mt,Mt.h)} L${A(mt,mt.h)} M${A(Mt,-Mt.h)} L${A(mt,-mt.h)}`+(W===J-1?` M${A(mt,mt.h)} L${A(mt,-mt.h)}`:"")),$.side.setAttribute("fill","none"),$.side.setAttribute("stroke",s),$.side.setAttribute("stroke-width",String(nn)),$.side.setAttribute("vector-effect","non-scaling-stroke"),$.side.setAttribute("stroke-linecap","round"),this._stampEdge($.fill),this._stampEdge($.side),$.fill.parentElement||this.parent.appendChild($.fill),$.side.parentElement||this.parent.appendChild($.side)}this._arrowPart=null;const bs=(1-y(g))*h,Ii=l(W=>T(Math.min(1,Math.max(g,m(1-W/h)))),"halfW"),at=bs>0?Ve.chevron([r.x,r.y],[-Q,-E],[ot,et],bs,Ii):null;if(at&&!at.path.includes("NaN")&&!at.path.includes("Infinity")){this._setArrow(at.path,s);const W=m(1-at.span[0]/h),wt=m(1-at.span[1]/h);let Zt=Math.max(S(wt),S(W));this._slices.forEach(($,$e)=>{const Ci=g+(1-g)*$e/J;g+(1-g)*($e+1)/J>wt&&Ci<W&&(Zt=Math.max(Zt,$.depth))});const Mt=y(wt),mt=y(W);this._arrowPart={depth:Zt+1e-6*(Math.abs(d-b)+1),from:{x:n.x+o*Mt,y:n.y+a*Mt},to:{x:n.x+o*mt,y:n.y+a*mt}}}else this._arrow_el&&(this._arrow_el.remove(),this._arrow_el=null);return!0}_clearSlices(){this._slices.forEach(t=>{t.fill!==this.svg_element&&t.fill.remove(),t.side.remove()}),this._slices=[],this._arrowPart=null}depthParts(){if(!this._slices.length)return null;const t=this._slices.map(e=>({els:[e.fill,e.side],depth:e.depth,from:e.from,to:e.to}));return this._arrow_el&&this._arrowPart&&t.push({els:[this._arrow_el],...this._arrowPart}),t}elements(){const t=[];return this._hit_el&&t.push(this._hit_el),this.svg_element&&t.push(this.svg_element),this._slices.forEach(e=>{e.fill!==this.svg_element&&t.push(e.fill),t.push(e.side)}),this._arrow_el&&t.push(this._arrow_el),t}remove(){this.elements().forEach(t=>t.remove())}draw(){this.elements().forEach(t=>{var e;return(e=this.parent)==null?void 0:e.appendChild(t)})}};l(Si,"QELine");let Wt=Si;const ii=l((c,t,e)=>{const s=Math.hypot(c,t,e);return[c/s,t/s,e/s]},"norm")(-.4,.5,.77),on=[[0,.32,255],[.3,0,0],[.75,.22,0],[1,.42,0]];function ni(c,t,e){const s=l(i=>Math.round(i+(e-i)*t),"m");return{r:s(c.r),g:s(c.g),b:s(c.b)}}l(ni,"mixRgb");const an=l(c=>`rgb(${c.r}, ${c.g}, ${c.b})`,"rgbString");function Jn(c,t){const e=on,s=Math.min(1,Math.max(0,t));let i=0;for(;i<e.length-2&&s>e[i+1][0];)i++;const[n,r,o]=e[i],[a,h,_]=e[i+1],p=ni(c,r,o),b=ni(c,h,_),d=a>n?(s-n)/(a-n):0,f=l((u,g)=>Math.round(u+(g-u)*d),"l");return{r:f(p.r,b.r),g:f(p.g,b.g),b:f(p.b,b.b)}}l(Jn,"toneAt");function Qn(c,t){const e=t[0]*ii[0]+t[1]*ii[1]+t[2]*ii[2];return Jn(c,(1-e)*.8)}l(Qn,"faceTone");const tr=.8,Ei=class Ei extends Ze{constructor(t,e,s,i=new ne){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 isCube(){var t;return!!((t=this.__data__.meta)!=null&&t.cube)&&this.shapeKind==="rect"}get tag(){if(this.isCube)return"g";const t=this.shapeKind;return t==="circle"?"circle":t==="rect"?"rect":"path"}setGeometry(t,e){if(this.isCube){this.setCube(t,e);return}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())}}setCube(t,e){var _,p;const s=this.x,i=this.y;t.setAttribute("data-cx",s.toString()),t.setAttribute("data-cy",i.toString());const n=((p=(_=this.graph)._cubeBasis)==null?void 0:p.call(_))??[],r=n.map((b,d)=>({a:b,i:d})).filter(({a:b})=>Math.abs(b.d)>=1e-9),o=this.graph.doc;for(;t.childNodes.length>r.length;)t.removeChild(t.lastChild);for(;t.childNodes.length<r.length;)t.appendChild(o.createElementNS("http://www.w3.org/2000/svg","path"));if(!r.length)return;let a;try{a=gt.parseColor(this.__data__.color.toString())}catch{a={r:136,g:136,b:136}}const h=e*tr;r.forEach(({a:b,i:d},f)=>{const u=b.d>0?1:-1,[g,y]=n.filter((Q,E)=>E!==d),m=s+u*b.x*h,w=i+u*b.y*h,S=l((Q,E)=>`${m+(Q*g.x+E*y.x)*h} ${w+(Q*g.y+E*y.y)*h}`,"pt"),v=an(Qn(a,[u*b.x,-u*b.y,u*b.d])),T=t.childNodes[f];T.setAttribute("d",`M${S(1,1)} L${S(1,-1)} L${S(-1,-1)} L${S(-1,1)}Z`),T.setAttribute("fill",v),T.setAttribute("stroke",v),T.setAttribute("stroke-width",(h*.04).toString()),T.setAttribute("stroke-linejoin","round")})}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;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;return typeof s=="number"&&s>0?s/2*this.graph.unitsPerPixelAtZoom1():(r=this.__data__.meta)!=null&&r.fixedSize?this.__data__.size*2*e*this.graph.unitsPerPixel():t*rn*this.__data__.size*e}applyStroke(t){const e=this.__data__.meta,s=e!=null&&e.sphere&&this.tag==="circle"||this.isCube||e==null?void 0:e.stroke;s?(t.setAttribute("stroke",s),t.setAttribute("stroke-width",(this.computeRadius()*.22).toString())):(t.removeAttribute("stroke"),t.removeAttribute("stroke-width"))}stampIdentity(t){t.setAttribute("data-point-id",this.__data__.ID);const e=this.__data__.meta??{},s=l((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)}fillPaint(){var e,s,i;const t=this.__data__.color.toString();return!((e=this.__data__.meta)!=null&&e.sphere)||this.tag!=="circle"?t:((i=(s=this.graph)._sphereFill)==null?void 0:i.call(s,t))??t}applyDepthOpacity(t){const e=this.__data__.meta,i=(e==null?void 0:e.sphere)&&this.tag==="circle"||this.isCube||e==null?void 0:e.opacity;i!=null?t.setAttribute("fill-opacity",String(i)):t.removeAttribute("fill-opacity")}create(){const t=this.graph.doc.createElementNS("http://www.w3.org/2000/svg",this.tag);return this.stampIdentity(t),t.setAttribute("fill",this.fillPaint()),this.applyDepthOpacity(t),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.fillPaint()),this.applyDepthOpacity(this.svg_element),this.applyStroke(this.svg_element),this.setGeometry(this.svg_element,this.computeRadius())}draw(){var t;(t=this.parent)==null||t.appendChild(this.svg_element)}};l(Ei,"QEPoint");let ke=Ei;const Ni=class Ni extends Ze{constructor(t,e,s,i=new ne){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;return(((i=this.graph.svg_element)==null?void 0:i.getBoundingClientRect().width)||0)>0?t*this.graph.unitsPerPixelAtZoom1():t*e*.006}create(){const t=this.graph.doc.createElementNS("http://www.w3.org/2000/svg","g");t.setAttribute("class","qe-trajectory-group");const e=this.graph.doc.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=this.graph.doc.createElementNS("http://www.w3.org/2000/svg","g");s.setAttribute("class","qe-trajectory-segments"),t.appendChild(s),this._segments_group=s;const i=this.graph.doc.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=this.graph.doc.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,[o,a]=this.__data__.opacityRange;for(let h=0;h<i;h++){const _=s[h],p=s[h+1],b=i<=1?1:h/(i-1),d=n+(r-n)*b,f=o+(a-o)*b,u=this.graph.doc.createElementNS("http://www.w3.org/2000/svg","path");u.setAttribute("d",`M${_.x},${_.y} L${p.x},${p.y}`),u.setAttribute("fill","none"),u.setAttribute("stroke",this.__data__.color.toString()),u.setAttribute("stroke-linecap","round"),u.setAttribute("stroke-linejoin","round"),u.setAttribute("stroke-width",this.graphUnitsForPixels(d).toString()),u.setAttribute("opacity",f.toString()),this._segments_group.appendChild(u)}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=this.graph.doc.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()}};l(Ni,"QETrajectory");let Ke=Ni;const{ArrayTools:hn}=Xe,Mi=class Mi extends Array{constructor(...t){super(...t)}search(t,e){let s;function i(r){return r.name===e?r:void 0}l(i,"fn");function n(r,o,a=null){if(hn.isArray(r)){for(const[h,_]of r.entries())if(s=n(_,h,a),s)return s}else{if(s=i(r),s)return s;if(r&&hn.isArray(r[t])){for(const[h,_]of r[t].entries())if(s=n(_,h,r),s)return s}}return s}return l(n,"recurse"),n(this)}flatten(){return this.reduce((t,e)=>(t.push(e),e.layers&&Array.isArray(e.layers)&&t.push(...e.layers),t),[])}};l(Mi,"QEArray");let ne=Mi;const er={AxisPoint:ke,AxisLine:Wt,Point:ke,Line:Wt,Edge:Wt,TaperedEdge:Wt,TaperedWeightedMidpointEdge:Wt,NodeEdge:Wt,Trajectory:Ke},Le=class Le{constructor(t,e,s,i=new ne){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:o})=>{const a=l(b=>{var d;return(d=b.__data__)==null?void 0:d.ID},"childId"),h=this.__children__.filter(b=>!r.objects.has(a(b))),_=this.__children__.filter(b=>r.objects.has(a(b)));[...r.objects.values()].filter(b=>!this.__children__.some(d=>a(d)===b.ID)).forEach(b=>{const d=b._typeName||b.constructor.name;let f=er[d];f||(b instanceof We?f=Ke:b instanceof _t?f=ke:f=Wt);const u=new f(b,this.svg_element,this.graph);this.__children__.push(u)}),_.forEach(b=>{const d=r.objects.get(a(b));d&&(b.__data__=d),b.update()}),h.forEach(b=>{var f;typeof b.remove=="function"?b.remove():(f=b.svg_element.parentElement)==null||f.removeChild(b.svg_element);const d=this.__children__.indexOf(b);d>=0&&this.__children__.splice(d,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=this.graph.doc.createElementNS("http://www.w3.org/2000/svg",Le.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 Le(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)}};l(Le,"QELayer"),Le.tagName="g";let Cs=Le;function re(c,t,e,s){const i=Math.cos(s.azimuth),n=Math.sin(s.azimuth),r=c*i+e*n,o=-c*n+e*i,a=t,h=Math.cos(s.elevation),_=Math.sin(s.elevation),p=a*h-o*_,b=a*_+o*h,d=s.distance,f=d&&Number.isFinite(d)&&d>0?d/Math.max(d-b,d*.05):1;return{x:r*f,y:-p*f,depth:b,scale:f}}l(re,"project2p5d");function ln(c){return c*Math.PI/180}l(ln,"degToRad");const ki=class ki{constructor(t,e,s,i,n=rt.DISPLAY_TYPES.ON,r=rt.POSITION.OBJECT,o,a){this.text=t,this.parent=s,this.graph=i,this.displayMode=n,this.position=r,this.customX=o,this.customY=a,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===rt.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=this.graph.doc.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!==rt.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 o=l((d,f)=>{const u=r.createSVGPoint();u.x=d,u.y=f;const g=n.getScreenCTM();return g?u.matrixTransform(g.inverse()):{x:0,y:0}},"toUser"),a=o(e,s),h=this._offsetX,_=this._offsetY;t.style.cursor="grabbing";const p=l((d,f)=>{const u=o(d,f);this._offsetX=h+(u.x-a.x),this._offsetY=_+(u.y-a.y),this.pinned=!0,this._visible=!0,this.svg_element.setAttribute("display","block"),this.update()},"move"),b=l(()=>{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 d=l(u=>p(u.clientX,u.clientY),"onMove"),f=l(()=>{document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",f),b()},"onUp");document.addEventListener("mousemove",d),document.addEventListener("mouseup",f)}else{const d=l(u=>{u.pointerId===i&&p(u.clientX,u.clientY)},"onMove"),f=l(u=>{u.pointerId===i&&(document.removeEventListener("pointermove",d),document.removeEventListener("pointerup",f),document.removeEventListener("pointercancel",f),b())},"onUp");document.addEventListener("pointermove",d),document.addEventListener("pointerup",f),document.addEventListener("pointercancel",f)}}update(){var _,p;if(!this._visible)return;const t=this.graph.__data__.extremes.x_max;if(t<=0)return;const e=this.graph.zoom_level||1,s=this.graph._labelFont??{},i=s.size?s.size*this.graph.unitsPerPixel():t*.06/e,n=i*1.2,r=this.gap(n*e,e);let o,a,h;switch(this.position){case rt.POSITION.STATIC:{o=this.point.x,a=this.point.y-n*.3,h="middle";break}case rt.POSITION.CONTAINER:{const{cx:b,cy:d}=this.graph.__data__.extremes,f=this.point.x-b,u=this.point.y-d,g=Math.sqrt(f*f+u*u)||1,y=t*.93/g;o=b+f*y,a=d+u*y-n*.3,h=f>=0?"start":"end";break}case rt.POSITION.CUSTOM:if(this.customX!=null&&this.customY!=null){o=this.customX,a=this.customY,h="start";break}default:case rt.POSITION.OBJECT:{const b=this.point.x>=0?r:-r;h=this.point.x>=0?"start":"end",o=this.point.x+b,a=this.point.y-n*.4;break}}this.svg_element.setAttribute("x",o.toString()),this.svg_element.setAttribute("y",a.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",i.toString()),this.svg_element.setAttribute("font-family",s.family??"system-ui, sans-serif"),this.svg_element.setAttribute("font-weight",this.fontWeight??"500"),this.svg_element.setAttribute("text-anchor",h),this.svg_element.setAttribute("fill",((_=this.point.meta)==null?void 0:_.labelColor)??s.color??((p=this.point.color)==null?void 0:p.toString())??"#333333"),!this._offsetX&&!this._offsetY&&this.position!==rt.POSITION.CUSTOM&&this.fitInside(o,a,h,r,i*.3)}gap(t,e){var n,r;const s=this.point.meta,i=s!=null&&s.zoomFixed||s!=null&&s.fixedSize?null:(r=(n=this.graph)._markRadius)==null?void 0:r.call(n,this.point);return t/e+(typeof i=="number"&&i>0?i*(1-1/e):0)}visibleBounds(){const t=this.svg_element,e=t.ownerSVGElement;if(!e)return null;const s=typeof t.getScreenCTM=="function"&&typeof DOMPoint<"u"?t.getScreenCTM():null;if(!s)return this.estimatedVisibleBounds(e);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),o=new DOMPoint(i.right,i.bottom).matrixTransform(n);return{left:Math.min(r.x,o.x),right:Math.max(r.x,o.x),top:Math.min(r.y,o.y),bottom:Math.max(r.y,o.y)}}estimatedVisibleBounds(t){var b;const e=(b=t.getBoundingClientRect)==null?void 0:b.call(t),s=l(d=>{const f=Number(t.getAttribute(d));return Number.isFinite(f)&&f>0?f:0},"size"),i=(e==null?void 0:e.width)||s("width"),n=(e==null?void 0:e.height)||s("height"),r=Rn(t.getAttribute("viewBox"),i,n);if(!r)return null;let o=[1,0,0,1,0,0];for(let d=this.svg_element.parentElement;d&&d!==t;d=d.parentElement){const f=Ln(d.getAttribute("transform"));o=[f[0]*o[0]+f[2]*o[1],f[1]*o[0]+f[3]*o[1],f[0]*o[2]+f[2]*o[3],f[1]*o[2]+f[3]*o[3],f[0]*o[4]+f[2]*o[5]+f[4],f[1]*o[4]+f[3]*o[5]+f[5]]}const a=$n(o);if(!a)return null;const h=l((d,f)=>({x:a[0]*d+a[2]*f+a[4],y:a[1]*d+a[3]*f+a[5]}),"map"),_=h(r.left,r.top),p=h(r.right,r.bottom);return{left:Math.min(_.x,p.x),right:Math.max(_.x,p.x),top:Math.min(_.y,p.y),bottom:Math.max(_.y,p.y)}}bbox(){const t=this.svg_element;if(typeof t.getBBox!="function")return On(t);try{const e=t.getBBox();return e.width>0?e:null}catch{return null}}fitInside(t,e,s,i,n){const r=this.visibleBounds();let o=this.bbox();if(!r||!o)return;const{x:a,y:h}=this.point;if(!(a>=r.left&&a<=r.right&&h>=r.top&&h<=r.bottom))return;const _=r.left+n,p=r.right-n,b=r.top+n,d=r.bottom-n,f=l(m=>Math.max(0,_-m.x)+Math.max(0,m.x+m.width-p),"over"),u=this.svg_element;if(f(o)>0&&this.position===rt.POSITION.OBJECT&&s!=="middle"){const m=s==="end"?"start":"end",w=s==="end"?this.point.x+i:this.point.x-i;u.setAttribute("text-anchor",m),u.setAttribute("x",w.toString());const S=this.bbox();S&&f(S)<f(o)?(o=S,t=w):(u.setAttribute("text-anchor",s),u.setAttribute("x",t.toString()))}let g=0,y=0;o.x<_?g=_-o.x:o.x+o.width>p&&(g=Math.max(p-(o.x+o.width),_-o.x)),o.y<b?y=b-o.y:o.y+o.height>d&&(y=Math.max(d-(o.y+o.height),b-o.y)),g&&u.setAttribute("x",(t+g).toString()),y&&u.setAttribute("y",(e+y).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()}};l(ki,"QELabel");let ri=ki;const js=class js extends Xt{};l(js,"QENodesElement"),js.tagName="qe-nodes";let Je=js;const qs=class qs extends Xt{};l(qs,"QENodeElement"),qs.tagName="qe-node";let Qe=qs;const Ys=class Ys extends Xt{};l(Ys,"QEMeansElement"),Ys.tagName="qe-means";let ts=Ys;const Bs=class Bs extends Xt{};l(Bs,"QEPointsElement"),Bs.tagName="qe-points";let es=Bs;const Gs=class Gs extends Xt{};l(Gs,"QEEdgesElement"),Gs.tagName="qe-edges";let ss=Gs;const Xs=class Xs extends Xt{};l(Xs,"QEEdgeElement"),Xs.tagName="qe-edge";let is=Xs;const Us=class Us extends Xt{};l(Us,"QETrajectoriesElement"),Us.tagName="qe-trajectories";let ns=Us;const Ws=class Ws extends Xt{};l(Ws,"QEAxesElement"),Ws.tagName="qe-axes";let rs=Ws;Ut(Je.tagName,Je),Ut(Qe.tagName,Qe),Ut(ts.tagName,ts),Ut(es.tagName,es),Ut(ss.tagName,ss),Ut(is.tagName,is),Ut(ns.tagName,ns),Ut(rs.tagName,rs);const cn=["#4477AA","#EE6677","#228833","#CCBB44","#66CCEE","#AA3377","#BBBBBB","#000000"];function sr(c,t){for(const e of t)if(c===`${e}.${e}`)return[e,e];for(const e of t)if(c.startsWith(e+".")){const s=c.slice(e.length+1);if(t.includes(s))return[e,s]}return null}l(sr,"parseEdgePair");function un(c){const t=Math.max(1,c-1);return t>=120?1.96:t>=60?2:t>=30?2.042:t>=20?2.086:t>=10?2.228:t>=5?2.571:4.303}l(un,"t975");function oi(c,t){return un(t)*Math.sqrt(Math.max(0,c)/t)}l(oi,"ciHalfWidth");function ai(c,t,e=""){const s=l(r=>{const o=c.names.indexOf(r),a=o>=0?c[o]:null;if(a==null||a==="")return;const h=Number(a);return Number.isFinite(h)?h:void 0},"get"),i=s(`${t}.${e}low`)??s(`${t}_${e}low`),n=s(`${t}.${e}high`)??s(`${t}_${e}high`);return i==null||n==null?null:{low:i,high:n}}l(ai,"readDimInterval");function ir(c,t,e,s){const i=un(e),n=Math.sqrt(Math.max(0,c)/e)*s,r=Math.sqrt(Math.max(0,t)/e)*s;return{halfW:i*n,halfH:i*r}}l(ir,"computeCIRect");const nr=.5;function os(c,t,e){if(!c)return;const s=Math.min(Math.abs(t),Math.abs(e));s>0&&(c.meta={...c.meta??{},maxRadius:s*nr})}l(os,"capMeanToInterval");function dn(c){const t=(c??"").trim().split(/[\s,]+/).map(Number);return t.every(e=>Number.isFinite(e)&&e>=0)&&t.some(e=>e>0)?t:null}l(dn,"parseDash");function ge(c,t,e,s=""){const i=l(h=>{const _=c.names.indexOf(h),p=_>=0?c[_]:null;if(p==null||p==="")return;const b=Number(p);return Number.isFinite(b)?b:void 0},"get"),n=i(`${t}.${s}low`)??i(`${t}_${s}low`),r=i(`${t}.${s}high`)??i(`${t}_${s}high`),o=i(`${e}.${s}low`)??i(`${e}_${s}low`),a=i(`${e}.${s}high`)??i(`${e}_${s}high`);return n==null||r==null||o==null||a==null?null:{x_low:n,x_high:r,y_low:o,y_high:a}}l(ge,"readIntervalBounds");function zs(c,t){const e=l(h=>{if(!c)return;const _=c.names.indexOf(h);return _>=0?c[_]:void 0},"raw"),s=l(h=>h==null||h==="NA"||typeof h=="number"&&Number.isNaN(h),"isNA"),i=e("label"),n=s(i)?t:String(i)===""?null:String(i),r=l(h=>{const _=e(h),p=s(_)||_===""?0:Number(_);return Number.isFinite(p)?p:0},"num"),o=!!c&&(c.names.includes("label.dx")||c.names.includes("label.dy")),a=e("label.pinned");return{text:n,offset:o?{x:r("label.dx"),y:r("label.dy")}:null,pinned:a===!0||a===1||String(a).toLowerCase()==="true"}}l(zs,"readLabelSpec");function rr(c){const t=c==null?void 0:c.trim().toLowerCase();if(!t)return null;if(t==="node")return .5;const e=Number(t);return Number.isFinite(e)&&e>0?e:null}l(rr,"parseSelfSize");function _n(c,t,e){return c?[...c.children].filter(s=>s.tagName.toLowerCase()===t).map(s=>Object.fromEntries(["color",...e].map(i=>[i,s.getAttribute(i)??""]))).filter(s=>s.color&&e.every(i=>s[i])):[]}l(_n,"childColors");function or(c){var i,n;const t=l(r=>c.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:rr(t("self-size")),fixedSize:c.hasAttribute("fixed-size"),edgeColors:_n(c,"qe-edge",["source","target"])}}l(or,"parseEdgeLayer");function ar(c){const{r:t,g:e,b:s}=gt.parseColor(c),i=Math.max(t,e,s),n=Math.min(t,e,s),r=l(o=>(i+n-o).toString(16).padStart(2,"0"),"f");return`#${r(t)}${r(e)}${r(s)}`}l(ar,"complementColor");function hr(c){const t=c==null?void 0:c.trim().toLowerCase();return t==="plot"||t==="absolute"?t:"model"}l(hr,"parseColorScale");function Ps(c,t){switch(c==null?void 0:c.toLowerCase()){case"on":return 3;case"off":return 0;case"click":return 2;case"auto":return 1;default:return t}}l(Ps,"parseLabelMode");const nt=class nt extends ks{constructor(t,e){super(t),this.zoom_level=1,this.__children__=new ne,this._hasModel=!1,this._renderPending=!1,this._is25d=!1,this._cam=null,this._sceneRadius=1,this._axisZText=null,this._depthGroup=null,this._sphereGrads=new Map,this._defs=null,this._dragRotating=!1,this._gid=++nt._graphSeq,this._childObserver=null,this._ciRects=new Map,this._outlierRects=new Map,this._ciCross=new Map,this._iv3d=new Map,this._iv3dSeen=new Set,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._intervalPx=null,this._intervalDashPx=null,this._outlierDashPx=null,this._axesFixedSize=!1,this._plotTitle=null,this._titleEl=null,this._resizeObs=null,this._labelFont={size:null,family:null,color:null},this._host=this,this._marksByPoint=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._rotPending=null,this._rotRaf=null,this._tooltipEl=null,this._axis3d=[],this._axis3dLabels=new Map,this._headless=Yi(this.doc),e&&(this._host=e),this.graph=this,this.parent=null,this.__data__=new Ms(Gi),this.__name__=this.__data__.name||"unnamed-graph",this.svg_element=this.create(),Ae("Created qe-graph svg element: ",this.svg_element),typeof document<"u"&&!this._headless&&document.addEventListener("model-updated",s=>{var r;const i=((r=s.composedPath)==null?void 0:r.call(s)[0])??s.target;if(this._vizena&&i!==this._vizena)return;const n=s.detail;n&&this.renderModel(n)})}static get observedAttributes(){return["width","height","for","scale-points","point-scale","center","view-padding","labels","label-nodes","label-means","label-points","projection","azimuth","elevation","perspective","edge-perspective"]}get vizena(){return this._vizena}_viewPadding(){const t=Number(this._host.getAttribute("view-padding"));return this._host.hasAttribute("view-padding")&&Number.isFinite(t)&&t>0?t:1.2}unitsPerPixelAtZoom1(){var o,a;const t=this.__data__.extremes,e=t.x_max||1,s=(a=(o=this.svg_element)==null?void 0:o.getBoundingClientRect)==null?void 0:a.call(o);if(!(s&&s.width>0))return e*.004;const i=this._viewPadding(),n=2*e*i,r=2*(t.y_max||e)*i;return s.height>0?Math.max(n/s.width,r/s.height):n/s.width}unitsPerPixel(){return this.unitsPerPixelAtZoom1()/(this.zoom_level||1)}renderModel(t){var e,s,i,n,r,o,a,h,_,p,b,d,f,u,g,y,m,w,S,v,T;{this._renderPending=!1,(e=this._childObserver)==null||e.takeRecords(),this._animateMs=this._host.hasAttribute("animate")?parseInt(this._host.getAttribute("animate")||"",10)||300:0;const Q=this._animateMs>0&&this._hasModel&&!this._dragRotating?this._captureTweenState():null;this._stopTween(),this._hasModel=!0;const E=t.dimensions,ot=t.unit_id_col,et=t.node_id_col,st=t.group_col,A=this._readLayerConfig();this._showAxes=A.showAxes,this._axisXText=A.axisXLabel===null?null:A.axisXLabel||String((E==null?void 0:E[0])??"x"),this._magnifyText=A.edgeMagnify==null?null:`(scaled ${A.edgeMagnify.toFixed(1)}x)`,this._axisYText=A.axisYLabel===null?null:A.axisYLabel||String((E==null?void 0:E[1])??"y"),this._axisZText=A.axisZLabel===null?null:A.axisZLabel||String((E==null?void 0:E[2])??"z");const J={},yt=(s=t.palette)!=null&&s.length?t.palette:cn;if(st&&((i=t.points)!=null&&i.names)){const k=t.points.col(st);k&&[...new Set([...k].map(String))].forEach((D,M)=>{J[D]=yt[M%yt.length]})}(n=t.groups)!=null&&n.rows&&t.groups.rows().length>0&&t.groups.rows().forEach(k=>{const I=k.rowName??String(k[0]),D=k.names.indexOf("color"),M=D>=0?k[D]:null;M&&String(M)!=="NA"?J[I]=String(M):J[I]||(J[I]=yt[Object.keys(J).length%yt.length])});const le=Object.keys(J),bs=A.activeMeanGroups&&A.activeMeanGroups.trim()?new Set(A.activeMeanGroups.split(",").map(k=>k.trim()).filter(k=>J[k])):new Set(le),Ii=A.scalePoints,at=A.projection==="2.5d"&&E.length>2;this._iv3dSeen.clear();const W=l(k=>{let I=0;return k.forEach(D=>{const M=D.names.indexOf(E[0]),j=E.length>1?D.names.indexOf(E[1]):-1,x=at?D.names.indexOf(E[2]):-1;M>=0&&(I=Math.max(I,Math.abs(Number(D[M])))),j>=0&&(I=Math.max(I,Math.abs(Number(D[j])))),x>=0&&(I=Math.max(I,Math.abs(Number(D[x]))))}),I},"getExtent"),wt=(r=t.nodes)!=null&&r.rows?W(t.nodes.rows()):0,Zt=(o=t.points)!=null&&o.rows?W(t.points.rows()):0,Mt=(a=t.trajectories)!=null&&a.rows?W(t.trajectories.rows()):0,mt=Zt>0?Zt:Mt,$=A.pointScale!==null?A.pointScale:Ii&&mt>0&&wt>0?wt/mt:1;this._rangeExtent=A.range==="network"?wt*1.2:A.range==="points"?mt*$*1.2:typeof A.range=="number"?A.range:null,this._rangeMode=A.range==="network"||A.range==="points"?A.range:typeof A.range=="number"?"number":null,this._centerContent=A.centerContent,this._edgesFixedSize=A.edgeLayers.some(k=>k.fixedSize),this._meansFixedSize=A.meanFixedSize,this._intervalPx=A.intervalWidth,this._intervalDashPx=A.intervalDash,this._outlierDashPx=A.outlierDash,this._axesFixedSize=A.axesFixedSize,this._plotTitle=A.plotTitle,this._labelFont=A.labelFont;const $e=A.labelNodes,Ci=A.labelMeans,zi=A.labelPoints,pe=this._labelsGroup;this._is25d=at;let Re=0;at&&((h=t.nodes)!=null&&h.rows)&&t.nodes.rows().forEach(k=>{const I=[0,1,2].map(D=>{const M=k.names.indexOf(E[D]);return M>=0&&Number(k[M])||0});Re=Math.max(Re,Math.hypot(I[0],I[1],I[2]))}),Re>0||(Re=wt>0?wt:1);const ce={azimuth:ln(A.azimuth),elevation:ln(A.elevation),distance:A.perspective>0?A.perspective*Re:0};this._cam=at?ce:null,this._sceneRadius=Re;const ys=l((k,I,D,M)=>at?re(k*M,I*M,D*M,ce):{x:k*M,y:-I*M,depth:0,scale:1},"toScreen");let Hs=1/0,Pi=-1/0;if(at){const k=l((D,M)=>D.forEach(j=>{const x=j.names.indexOf(E[0]),B=E.length>1?j.names.indexOf(E[1]):-1,R=E.length>2?j.names.indexOf(E[2]):-1,P=re((x>=0?Number(j[x]):0)*M,(B>=0?Number(j[B]):0)*M,(R>=0?Number(j[R]):0)*M,ce);P.depth<Hs&&(Hs=P.depth),P.depth>Pi&&(Pi=P.depth)}),"scan");(_=t.points)!=null&&_.rows&&k(t.points.rows(),$),(p=t.nodes)!=null&&p.rows&&k(t.nodes.rows(),1);const I=t.pointsets;I!=null&&I.rows&&k(I.rows(),$)}const mn=Pi-Hs||1,pn=ce.distance>0,Oi=pn&&A.edgePerspective,Te=l((k,I=1)=>{if(!at)return{sizeScale:1,opacity:void 0,fade:1};const D=Math.min(1,Math.max(0,(k-Hs)/mn));return{sizeScale:pn?I:.6+.8*D,opacity:.75+.25*D,fade:.5+.5*D}},"depthCue"),bn=l(k=>{if(!at||!k)return;const I=[...k.__data__.objects.entries()];I.sort((D,M)=>{var j,x;return(((j=D[1].meta)==null?void 0:j.depth)??0)-(((x=M[1].meta)==null?void 0:x.depth)??0)}),k.__data__.objects=new Map(I)},"sortLayerByDepth"),Li=l((k,I,D,M=1)=>{const j=k.names.indexOf(I),x=k.names.indexOf(E[0]),B=E.length>1?k.names.indexOf(E[1]):-1,R=E.length>2?k.names.indexOf(E[2]):-1,P=ys(x>=0?Number(k[x]):0,B>=0?Number(k[B]):0,R>=0?Number(k[R]):0,M),q=Te(P.depth,P.scale),it=new _t({ID:j>=0?String(k[j]):k.rowName||`pt-${Math.random().toString(36).slice(2)}`,dimensions:[P.x,P.y],meta:at?{depth:P.depth,sizeScale:q.sizeScale,opacity:q.opacity,sphere:!0}:{}});return D&&(it.color=new gt(D)),it},"rowToPoint"),kt={},dr=A.showPoints;["points","nodes","edges","edgenodes"].map(k=>this.__children__.search("__children__",k)).filter(k=>!!k).forEach(k=>k.__data__.objects.clear()),this.__data__.points.clear();const Vs=t.pointsets,$i=[];if(A.pointSets.length&&(Vs!=null&&Vs.rows)){const k=this.__children__.search("__children__","points"),I=l((D,M)=>{const j=D.names.indexOf(M);return j>=0?D[j]:null},"col");A.pointSets.forEach((D,M)=>{Vs.rows().forEach(j=>{if(String(I(j,"set"))!==D.set)return;const x=String(I(j,"id")),B=I(j,"group")!=null&&String(I(j,"group"))!=="NA"?String(I(j,"group")):null,R=I(j,"color")&&String(I(j,"color"))!=="NA"?String(I(j,"color")):B&&J[B]?J[B]:yt[M%yt.length],P=Li(j,"id",R,$);P.ID=`${D.set}::${x}`,P.size=D.size??A.pointSize??2.5;const q=I(j,"shape");q&&String(q)!=="NA"&&(P.shape=String(q));const it=I(j,"label");P.meta={...P.meta??{},stroke:"#ffffff",kind:"point",name:it!=null&&String(it)!=="NA"?String(it):x,group:B??void 0,unit:x,set:D.set,fixedSize:D.fixedSize},this.__data__.points.set(P.ID,P),k==null||k.__data__.objects.set(P.ID,P),$i.push({pt:P,spec:zs(j,x),mode:D.labelMode,weight:D.labelWeight})})})}if(pe){const k=new Set($i.map(I=>I.pt.ID));this._setLabels.forEach((I,D)=>{k.has(D)||(I.remove(),this._setLabels.delete(D))}),$i.forEach(I=>this._syncLabel(this._setLabels,I.pt.ID,I.spec,I.pt,pe,I.mode,I.weight))}if((b=t.points)!=null&&b.rows){const k=this.__children__.search("__children__","points");if(k){t.points.rows().forEach(M=>{const j=st?M.names.indexOf(st):-1,x=j>=0?String(M[j]):null,B=x?J[x]??"#888888":"#888888";if(dr){const R=Li(M,ot,B,$);R.size=A.pointSize??2.5,R.meta={...R.meta??{},stroke:"#ffffff",kind:"point",name:R.ID,group:x??void 0,unit:R.ID,fixedSize:A.pointFixedSize},this.__data__.points.set(R.ID,R),k.__data__.objects.set(R.ID,R)}if(x){const R=M.names.indexOf(E[0]),P=E.length>1?M.names.indexOf(E[1]):-1,q=E.length>2?M.names.indexOf(E[2]):-1;kt[x]||(kt[x]={x:0,y:0,z:0,x2:0,y2:0,z2:0,xy:0,n:0,color:B});const it=R>=0?Number(M[R]):0,F=P>=0?Number(M[P]):0,C=q>=0?Number(M[q]):0;kt[x].x+=it,kt[x].y+=F,kt[x].z+=C,kt[x].x2+=it*it,kt[x].y2+=F*F,kt[x].z2+=C*C,kt[x].xy+=it*F,kt[x].n+=1}});const I=!!((d=t.groups)!=null&&d.rows&&t.groups.rows().length>0),D=A.showMeans&&I?t.groups.rows().filter(M=>{const j=M.rowName??String(M[0]);return bs.size===0||bs.has(j)}):[];if(A.showMeans){const M=k.svg_element,j=this._rangeExtent?this._rangeExtent/1.2:wt,x=(j>0?j:1)*.008,B=l((R,P,q,it,F,C,Z)=>{if(this._setInterval3d(`${R==="outlier"?"out":R}:${P}`,R,P,q,it,F,C,(tt,X,ht)=>ys(tt,X,ht,$),tt=>Te(tt).fade,x),R!=="outlier"&&Z){const tt=ys(C[0],C[1],C[2],$).scale,X=Math.min(...[0,1,2].map(ht=>Math.abs(F[ht]-it[ht])/2))*$*tt;os(Z,X,X)}},"interval3d");if(I){const R=new Set(D.map(P=>P.rowName??String(P[0])));this._ciRects.forEach((P,q)=>{R.has(q)||(P.remove(),this._ciRects.delete(q))}),this._outlierRects.forEach((P,q)=>{R.has(q)||(P.remove(),this._outlierRects.delete(q))}),this._ciCross.forEach((P,q)=>{R.has(q.slice(2))||(P.remove(),this._ciCross.delete(q))}),D.forEach(P=>{var N,z,Y;const q=P.rowName??String(P[0]),it=J[q]??"#888888",F=P.names.indexOf(E[0]),C=E.length>1?P.names.indexOf(E[1]):-1,Z=E.length>2?P.names.indexOf(E[2]):-1,tt=ys(F>=0?Number(P[F]):0,C>=0?Number(P[C]):0,Z>=0?Number(P[Z]):0,$),X=tt.x,ht=tt.y,Nt=Te(tt.depth,tt.scale),dt=new _t({ID:`mean-${q}`,dimensions:[X,ht],meta:{kind:"mean",name:q,group:q,fixedSize:A.meanFixedSize,depth:tt.depth,sizeScale:Nt.sizeScale,opacity:Nt.opacity,cube:at}});dt.color=new gt(it),dt.size=4;const ft=P.names.indexOf("shape"),K=ft>=0?P[ft]:null;dt.shape=K&&String(K)!=="NA"?String(K):"rect",this.__data__.points.set(dt.ID,dt),k.__data__.objects.set(dt.ID,dt);const De=l(O=>{const G=P.names.indexOf(O),H=G>=0?P[G]:null;return H==null||String(H)==="NA"||String(H)===""?null:H},"cell"),Ft=De("intervals"),Rt=Ft==="box"||Ft==="crosshairs"||Ft==="both"||Ft==="none"?Ft:A.intervals,be=Rt==="crosshairs"||Rt==="both",ye=Rt==="box"||Rt==="both",pt=De("outlier"),Fe=pt==null?A.showOutlier:pt===!0||String(pt)==="true",jt=Fe&&!at?ge(P,E[0],E[1],"o"):null;if(!jt)(N=this._outlierRects.get(q))==null||N.remove(),this._outlierRects.delete(q);else{let O=this._outlierRects.get(q);O||(O=this.doc.createElementNS("http://www.w3.org/2000/svg","rect"),O.setAttribute("data-outlier-group",q),this._outlierRects.set(q,O)),O.setAttribute("x",(jt.x_low*$).toString()),O.setAttribute("y",(-jt.y_high*$).toString()),O.setAttribute("width",((jt.x_high-jt.x_low)*$).toString()),O.setAttribute("height",((jt.y_high-jt.y_low)*$).toString()),O.setAttribute("fill","none"),O.setAttribute("stroke",it),O.setAttribute("stroke-width",x.toString()),O.setAttribute("stroke-opacity","0.5"),O.setAttribute("stroke-dasharray",`${x*2} ${x*2}`),this._intervalStroke(O,x,[x*2,x*2],!0),M&&!O.parentElement&&M.insertBefore(O,M.firstChild)}const At=Rt!=="none"&&!at?ge(P,E[0],E[1]):null,Jt=`x:${q}`;if((!At||!be)&&((z=this._ciCross.get(Jt))==null||z.remove(),this._ciCross.delete(Jt)),(!At||!ye)&&((Y=this._ciRects.get(q))==null||Y.remove(),this._ciRects.delete(q)),At&&be){const O=At.x_low*$,G=At.x_high*$,H=-At.y_high*$,lt=-At.y_low*$;os(dt,(G-O)/2,(lt-H)/2);let V=this._ciCross.get(Jt);V||(V=this.doc.createElementNS("http://www.w3.org/2000/svg","path"),V.setAttribute("data-ci-group",q),V.setAttribute("data-ci-kind","crosshairs"),this._ciCross.set(Jt,V)),V.setAttribute("d",`M${O} ${ht} L${G} ${ht} M${X} ${H} L${X} ${lt}`),V.setAttribute("fill","none"),V.setAttribute("stroke",it),V.setAttribute("stroke-width",(x*1.25).toString()),this._intervalStroke(V,x*1.25,null),V.setAttribute("stroke-opacity","0.8"),M&&!V.parentElement&&M.insertBefore(V,M.firstChild)}if(At&&ye){const O=At.x_low*$,G=-At.y_high*$,H=(At.x_high-At.x_low)*$,lt=(At.y_high-At.y_low)*$;os(dt,H/2,lt/2);let V=this._ciRects.get(q);V||(V=this.doc.createElementNS("http://www.w3.org/2000/svg","rect"),V.setAttribute("data-ci-group",q),this._ciRects.set(q,V)),V.setAttribute("x",O.toString()),V.setAttribute("y",G.toString()),V.setAttribute("width",H.toString()),V.setAttribute("height",lt.toString()),V.setAttribute("fill","none"),V.setAttribute("stroke",it),V.setAttribute("stroke-width",x.toString()),V.setAttribute("stroke-opacity","0.8"),V.setAttribute("stroke-dasharray",`${x*4} ${x*3}`),this._intervalStroke(V,x,[x*4,x*3]),M&&!V.parentElement&&M.insertBefore(V,M.firstChild)}if(at){const O=[F,C,Z].map(V=>V>=0?Number(P[V]):0),G=l(V=>{const Pt=ge(P,E[0],E[1],V),Ot=ai(P,E[2],V);return Pt&&Ot?{lo:[Pt.x_low,Pt.y_low,Ot.low],hi:[Pt.x_high,Pt.y_high,Ot.high]}:null},"bounds3"),H=Rt!=="none"?G(""):null;H&&ye&&B("box",q,it,H.lo,H.hi,O,dt),H&&be&&B("cross",q,it,H.lo,H.hi,O,dt);const lt=Fe?G("o"):null;lt&&B("outlier",q,it,lt.lo,lt.hi,O)}})}else{this._removeIntervals(this._ciCross),Object.entries(kt).forEach(([F,{x:C,y:Z,z:tt,n:X,color:ht}])=>{const Nt=ys(C/X,Z/X,tt/X,$),dt=Te(Nt.depth,Nt.scale),ft=new _t({ID:`mean-${F}`,dimensions:[Nt.x,Nt.y],meta:{kind:"mean",name:F,group:F,fixedSize:A.meanFixedSize,depth:Nt.depth,sizeScale:dt.sizeScale,opacity:dt.opacity,cube:at}});ft.color=new gt(ht),ft.size=4,ft.shape="rect",this.__data__.points.set(ft.ID,ft),k.__data__.objects.set(ft.ID,ft)}),A.showCI&&!at?(this._ciRects.forEach((F,C)=>{kt[C]||(F.remove(),this._ciRects.delete(C))}),(f=t.confidence)!=null&&f.rows?t.confidence.rows().forEach(F=>{const C=F.names.indexOf(st??"group"),Z=C>=0?String(F[C]):F.rowName??null;if(!Z)return;const tt=J[Z]??"#888888",X=ge(F,E[0],E[1]);if(!X)return;const ht=X.x_low*$,Nt=-X.y_high*$,dt=(X.x_high-X.x_low)*$,ft=(X.y_high-X.y_low)*$;os(this.__data__.points.get(`mean-${Z}`),dt/2,ft/2);let K=this._ciRects.get(Z);K||(K=this.doc.createElementNS("http://www.w3.org/2000/svg","rect"),K.setAttribute("data-ci-group",Z),this._ciRects.set(Z,K)),K.setAttribute("x",ht.toString()),K.setAttribute("y",Nt.toString()),K.setAttribute("width",dt.toString()),K.setAttribute("height",ft.toString()),K.setAttribute("fill","none"),K.setAttribute("stroke",tt),K.setAttribute("stroke-width",x.toString()),K.setAttribute("stroke-opacity","0.8"),K.setAttribute("stroke-dasharray",`${x*4} ${x*3}`),this._intervalStroke(K,x,[x*4,x*3]),M&&!K.parentElement&&M.insertBefore(K,M.firstChild)}):Object.entries(kt).forEach(([F,{x:C,y:Z,x2:tt,y2:X,n:ht,color:Nt}])=>{if(ht<2)return;const dt=C/ht,ft=Z/ht,K=tt/ht-dt*dt,De=X/ht-ft*ft,{halfW:Ft,halfH:Rt}=ir(K,De,ht,$),be=dt*$,ye=-ft*$;os(this.__data__.points.get(`mean-${F}`),Ft,Rt);let pt=this._ciRects.get(F);pt||(pt=this.doc.createElementNS("http://www.w3.org/2000/svg","rect"),pt.setAttribute("data-ci-group",F),this._ciRects.set(F,pt)),pt.setAttribute("x",(be-Ft).toString()),pt.setAttribute("y",(ye-Rt).toString()),pt.setAttribute("width",(Ft*2).toString()),pt.setAttribute("height",(Rt*2).toString()),pt.setAttribute("fill","none"),pt.setAttribute("stroke",Nt),pt.setAttribute("stroke-width",x.toString()),pt.setAttribute("stroke-opacity","0.8"),pt.setAttribute("stroke-dasharray",`${x*4} ${x*3}`),this._intervalStroke(pt,x,[x*4,x*3]),M&&!pt.parentElement&&M.insertBefore(pt,M.firstChild)})):this._removeIntervals(this._ciRects);const P=l(F=>{const C=kt[F];return C&&C.n>0?[C.x/C.n,C.y/C.n,C.z/C.n]:null},"meanOf"),q=l(F=>{const C=F.names.indexOf(st??"group");return C>=0?String(F[C]):F.rowName??null},"frameGroup");at&&A.showCI&&((u=t.confidence)!=null&&u.rows?t.confidence.rows().forEach(F=>{const C=q(F),Z=C?P(C):null,tt=ge(F,E[0],E[1]),X=ai(F,E[2]);!C||!Z||!tt||!X||B("box",C,J[C]??"#888888",[tt.x_low,tt.y_low,X.low],[tt.x_high,tt.y_high,X.high],Z,this.__data__.points.get(`mean-${C}`))}):Object.entries(kt).forEach(([F,C])=>{if(C.n<2)return;const Z=[C.x/C.n,C.y/C.n,C.z/C.n],tt=[oi(C.x2/C.n-Z[0]*Z[0],C.n),oi(C.y2/C.n-Z[1]*Z[1],C.n),oi(C.z2/C.n-Z[2]*Z[2],C.n)];B("box",F,C.color,Z.map((X,ht)=>X-tt[ht]),Z.map((X,ht)=>X+tt[ht]),Z,this.__data__.points.get(`mean-${F}`))})),at&&((g=t.outlier)!=null&&g.rows)&&t.outlier.rows().forEach(F=>{const C=q(F),Z=C?P(C):null,tt=ge(F,E[0],E[1]),X=ai(F,E[2]);!C||!Z||!tt||!X||B("outlier",C,J[C]??"#888888",[tt.x_low,tt.y_low,X.low],[tt.x_high,tt.y_high,X.high],Z)}),!at&&((y=t.outlier)!=null&&y.rows)?(this._outlierRects.forEach((F,C)=>{J[C]||(F.remove(),this._outlierRects.delete(C))}),t.outlier.rows().forEach(F=>{const C=F.names.indexOf(st??"group"),Z=C>=0?String(F[C]):F.rowName??null;if(!Z)return;const tt=J[Z]??"#888888",X=ge(F,E[0],E[1]);if(!X)return;const ht=X.x_low*$,Nt=-X.y_high*$,dt=(X.x_high-X.x_low)*$,ft=(X.y_high-X.y_low)*$;let K=this._outlierRects.get(Z);K||(K=this.doc.createElementNS("http://www.w3.org/2000/svg","rect"),K.setAttribute("data-outlier-group",Z),this._outlierRects.set(Z,K)),K.setAttribute("x",ht.toString()),K.setAttribute("y",Nt.toString()),K.setAttribute("width",dt.toString()),K.setAttribute("height",ft.toString()),K.setAttribute("fill","none"),K.setAttribute("stroke",tt),K.setAttribute("stroke-width",x.toString()),K.setAttribute("stroke-opacity","0.5"),K.setAttribute("stroke-dasharray",`${x*2} ${x*2}`),this._intervalStroke(K,x,[x*2,x*2],!0),M&&!K.parentElement&&M.insertBefore(K,M.firstChild)})):this._removeIntervals(this._outlierRects)}}else[this._ciRects,this._outlierRects,this._ciCross].forEach(M=>this._removeIntervals(M));if(pe){this._pointLabels.forEach((x,B)=>{k.__data__.objects.get(B)||(x.remove(),this._pointLabels.delete(B))}),this._meanLabels.forEach((x,B)=>{k.__data__.objects.get(`mean-${B}`)||(x.remove(),this._meanLabels.delete(B))}),zi!==0?t.points.rows().forEach(x=>{const B=x.names.indexOf(ot),R=B>=0?String(x[B]):null;if(!R)return;const P=k.__data__.objects.get(R);P&&this._syncLabel(this._pointLabels,R,zs(null,R),P,pe,zi,A.labelWeightPoints)}):this._clearLabels(this._pointLabels);const M=new Map(D.map(x=>[x.rowName??String(x[0]),x]));(I?[...M.keys()]:Object.keys(kt)).forEach(x=>{const B=`mean-${x}`,R=k.__data__.objects.get(B);R&&this._syncLabel(this._meanLabels,x,zs(M.get(x),x),R,pe,Ci,A.labelWeightMeans)})}bn(k),k.__data__.__state__.setVariable("layer_updated",k.__data__)}}else{const k=this.__children__.search("__children__","points");k==null||k.__data__.__state__.setVariable("layer_updated",k.__data__)}const xs=this.__children__.search("__children__","trajectories");if(A.showTrajectories&&xs){xs.__data__.objects.clear(),this.__data__.trajectories.clear();const k=(m=t.trajectories)!=null&&m.rows?t.trajectories:t.points;if(k!=null&&k.rows){const I={},D={},M=A.trajectoryUnits?A.trajectoryUnits.split(",").map(x=>x.trim()):null;k.rows().forEach(x=>{const B=x.names.indexOf(ot)>=0?x.names.indexOf(ot):x.names.indexOf("unit")>=0?x.names.indexOf("unit"):x.names.indexOf("ENA_UNIT")>=0?x.names.indexOf("ENA_UNIT"):-1,R=B>=0?String(x[B]):x.rowName||"unit-1";if(M&&!M.includes(R))return;const P=x.names.indexOf(E[0]),q=E.length>1?x.names.indexOf(E[1]):-1,it=A.trajectoryTimeCol?x.names.indexOf(A.trajectoryTimeCol):x.names.indexOf("time")>=0?x.names.indexOf("time"):x.names.indexOf("ActivityNumber")>=0?x.names.indexOf("ActivityNumber"):x.names.indexOf("RowID")>=0?x.names.indexOf("RowID"):-1,F=x.names.indexOf("color");F>=0&&!D[R]&&x[F]!=null&&String(x[F])!==""&&(D[R]=String(x[F]));const C=it>=0?Number(x[it]):I[R]?I[R].length+1:1;P>=0&&q>=0&&(I[R]||(I[R]=[]),I[R].push({x:Number(x[P])*$,y:-Number(x[q])*$,time:C}))}),Object.keys(I).forEach((x,B)=>{const R=I[x];if(R.length===0)return;const P=D[x]??yt[B%yt.length],q=new We({ID:`traj-${x}`,unitId:x,color:new gt(P),lineStyle:A.trajectoryLineStyle,strokeWidth:A.trajectoryStrokeWidth,strokeWidthRange:A.trajectoryStrokeWidthRange,opacityRange:A.trajectoryOpacityRange,smooth:A.trajectorySmooth,maxDegree:A.trajectoryMaxDegree,degreeSelection:A.trajectoryDegreeSelection,fitTime:A.trajectoryFitTime,currentTime:A.trajectoryPlayhead??1/0,showPoints:A.trajectoryShowPoints,showTips:A.trajectoryShowTips,points:R.map(it=>({x:it.x,y:it.y,time:it.time}))});this.__data__.trajectories.set(x,q),xs.__data__.objects.set(q.ID,q)})}xs.__data__.__state__.setVariable("layer_updated",xs.__data__)}const Kt=this.__children__.search("__children__","network"),ws=Kt==null?void 0:Kt.__children__.search("__children__","edges"),It=Kt==null?void 0:Kt.__children__.search("__children__","nodes"),yn=Kt==null?void 0:Kt.__children__.search("__children__","edgenodes"),_r=A.showEdges;if((w=t.nodes)!=null&&w.rows&&It){if(t.nodes.rows().forEach(I=>{const D=A.nodeColors.get(String(I[I.names.indexOf(et)])),M=Li(I,et,D??"#444444");M.size=2;const j=I.names.indexOf("label"),x=j>=0?I[j]:null,B=I.names.indexOf("size"),R=B>=0&&I[B]!=null&&I[B]!==""?Number(I[B]):NaN;M.meta={...M.meta??{},kind:"node",labelColor:D,name:x!=null&&String(x)!=="NA"&&String(x)!==""?String(x):M.ID,sizePx:Number.isFinite(R)&&R>0?R:void 0,zoomFixed:A.nodeFixedSize||void 0},It.__data__.objects.set(M.ID,M)}),_r&&ws){const I={};st&&((S=t.points)!=null&&S.rows)&&t.points.rows().forEach(N=>{const z=N.names.indexOf(ot),Y=N.names.indexOf(st);z>=0&&Y>=0&&(I[String(N[z])]=String(N[Y]))});const D=t.nodes.rows().map(N=>{const z=N.names.indexOf(et);return z>=0?String(N[z]):""}).filter(Boolean),M=l(N=>{const z=[];return N.forEach(Y=>{const O=sr(Y,D);O&&z.push({col:Y,pair:O})}),z},"parsePairs"),j=(v=t.edges)!=null&&v.rows?t.edges.rows():[],x=t.networks,B=M(((T=t.edges)==null?void 0:T.names)??[]),R=M((x==null?void 0:x.names)??[]),P={};at&&t.nodes.rows().forEach(N=>{const z=N.names.indexOf(et),Y=z>=0?String(N[z]):"";if(!Y)return;const O=N.names.indexOf(E[0]),G=E.length>1?N.names.indexOf(E[1]):-1,H=E.length>2?N.names.indexOf(E[2]):-1;P[Y]={x:O>=0?Number(N[O]):0,y:G>=0?Number(N[G]):0,z:H>=0?Number(N[H]):0}});const q=l(N=>{const z={};return j.forEach(Y=>{const O=Y.names.indexOf(ot);O<0||String(Y[O])!==N||B.forEach(({col:G})=>{const H=Y.names.indexOf(G);H>=0&&(z[G]=Number(Y[H])||0)})}),z},"getUnitEdges"),it=l(N=>{const z={};let Y=0;if(j.forEach(G=>{const H=G.names.indexOf(ot),lt=H>=0?String(G[H]):null,V=st?G.names.indexOf(st):-1;(V>=0?String(G[V]):lt?I[lt]:null)===N&&(Y++,B.forEach(({col:Ot})=>{const Qt=G.names.indexOf(Ot);if(Qt>=0){const Tt=Number(G[Qt]);isNaN(Tt)||(z[Ot]=(z[Ot]??0)+Tt)}}))}),Y===0)return{};const O={};return B.forEach(({col:G})=>{O[G]=(z[G]??0)/Y}),O},"getGroupEdges"),F=l(N=>{if(J[N])return{weights:it(N),color:J[N],label:N};const z=I[N]??null,Y=z?J[z]??"#888888":"#888888";return{weights:q(N),color:Y,label:N}},"resolve"),C=[],Z=l(N=>{var O;const z=(O=x==null?void 0:x.rows)==null?void 0:O.call(x).find(G=>G.rowName===N);if(!z)return null;const Y={};return R.forEach(({col:G})=>{const H=z.names.indexOf(G);if(H>=0){const lt=Number(z[H]);Number.isFinite(lt)&&(Y[G]=lt)}}),Y},"networkRow"),tt=l((N,z)=>{if(!z)return N;const Y=Math.abs(N);return Y<z[0]?0:Y>z[1]?Math.sign(N)*z[1]:N},"thresholded");A.edgeLayers.forEach((N,z)=>{const Y=l(xt=>{var Ct;return(Ct=N.edgeColors.find(bt=>bt.source===xt[0]&&bt.target===xt[1]||!t.directed&&bt.source===xt[1]&&bt.target===xt[0]))==null?void 0:Ct.color},"ownColor"),O=l((xt,Ct,bt,xe,ue)=>{if(bt=tt(bt,N.threshold),Math.abs(bt)<1e-6)return;const Lt=Y(Ct);C.push({col:`${z}:${xt}`,pair:Ct,weight:Math.abs(bt),color:Lt??xe,exact:Lt!==void 0,layer:z,...ue})},"push"),G=l((xt,Ct)=>N.colors?[N.colors[0],N.colors[1]??ar(N.colors[0])]:[xt,Ct],"signColors");if(N.network){const xt=Z(N.network);if(!xt)return;const[Ct,bt]=G(yt[0],yt[1]),xe={name:N.name??N.network};R.forEach(({col:ue,pair:Lt})=>{const Ri=xt[ue]??0;O(ue,Lt,Ri,Ri>=0?Ct:bt,xe)});return}const H=N.unit??N.group??null;if(!H)return;const lt=F(H),V=N.compare??N.also??null,Pt=V?F(V):null,Ot={name:N.name??H,group:N.group??void 0,unit:N.unit??void 0},[Qt,Tt]=G(lt.color,(Pt==null?void 0:Pt.color)??lt.color);Pt?B.forEach(({col:xt,pair:Ct})=>{const bt=(lt.weights[xt]??0)-(Pt.weights[xt]??0);O(xt,Ct,bt,bt>0?Qt:Tt,Ot)}):B.forEach(({col:xt,pair:Ct})=>{const bt=lt.weights[xt]??0;bt>0&&O(xt,Ct,bt,Qt,Ot)})}),C.sort((N,z)=>z.weight-N.weight);const X=!!t.directed,ht=Hn(A.edgeWidth)*(A.edgeMagnify??1),Nt=l(N=>{const z=N.map(Math.abs).filter(Y=>Y>0);return z.length?[Math.min(...z),Math.max(...z)]:[0,0]},"rangeOf"),[dt,ft]=j.length?[B,t.edges]:[R,x],K=l(N=>{const z=[];return dt.forEach(({col:Y,pair:O})=>{if(O[0]===O[1]!==N)return;const G=ft==null?void 0:ft.col(Y);if(G)for(const H of G)z.push(Number(H))}),Nt(z)},"modelRange"),De=l(N=>Nt(C.filter(z=>z.pair[0]===z.pair[1]===N).map(z=>z.weight)),"plotRange"),Ft=A.edgeColorScale,Rt=l(N=>Ft==="plot"?De(N):K(N),"colourRange"),be=Rt(!1),ye=Rt(!0),pt=l((N,z)=>{if(Ft==="absolute"){const G=Math.min(1,Math.abs(N));return{saturation:G,opacity:G}}const[Y,O]=z?ye:be;return{saturation:en(N,Y,O,Bn),opacity:en(N,Y,O,Gn)}},"colourOf"),Fe={};C.forEach(({pair:N,weight:z})=>{const Y=N[0]===N[1],O=l(G=>{Fe[G]=(Fe[G]??0)+Math.abs(z)},"add");if(X||Y){O(N[1]);return}O(N[0]),O(N[1])}),t.nodes.rows().forEach(N=>{var lt;const z=N.names.indexOf(et),Y=z>=0?String(N[z]):"";if(!Y)return;const O=It.__data__.objects.get(Y);if(!O)return;const G=Fe[Y]??0,H=!(G>0);O.size=H?A.hideUnconnectedNodes?0:Wn:Vn(G,ht),O.meta={...O.meta??{},hidden:H&&A.hideUnconnectedNodes,sizePx:H||(lt=O.meta)==null?void 0:lt.sizePx}});const jt={},At=l((N,z,Y,O)=>`${N}:${z??""}:${Y}.${O}`,"pairKey");X&&C.forEach(({pair:N,weight:z,layer:Y,name:O})=>{const G=At(Y,O,N[0],N[1]);jt[G]=(jt[G]??0)+z});const Jt=14;C.forEach(({col:N,pair:z,weight:Y,color:O,exact:G,layer:H,name:lt,group:V,unit:Pt})=>{var vn,An;const Ot=It.__data__.objects.get(z[0]),Qt=It.__data__.objects.get(z[1]);if(!Ot||!Qt)return;const Tt=z[0]===z[1],{saturation:xt,opacity:Ct}=pt(Y,Tt),bt={isMeanEdge:!0,weight:Y,widthFrac:ht,saturation:xt,opacity:Ct,exactColor:G||void 0,isDirected:X,isSelf:Tt,source:z[0],target:z[1],group:V,unit:Pt,layer:lt,selfSize:Tt?((vn=A.edgeLayers[H])==null?void 0:vn.selfSize)??void 0:void 0,fixedSize:((An=A.edgeLayers[H])==null?void 0:An.fixedSize)||void 0};if(at&&!Tt&&!X){const St=P[z[0]],Gt=P[z[1]];if(St&&Gt){let Dt=re(St.x,St.y,St.z,ce);for(let qt=1;qt<=Jt;qt++){const we=qt/Jt,ve=re(St.x+(Gt.x-St.x)*we,St.y+(Gt.y-St.y)*we,St.z+(Gt.z-St.z)*we,ce),fr=new _t({ID:`${N}-s${qt}a`,dimensions:[Dt.x,Dt.y],meta:{}}),gr=new _t({ID:`${N}-s${qt}b`,dimensions:[ve.x,ve.y],meta:{}}),vs=new fe({},fr,gr);vs.ID=`edge-${N}-seg${qt}`,vs.color=new gt(O);const Sn=(Dt.depth+ve.depth)/2,mr=Te(Sn,(Dt.scale+ve.scale)/2);vs.meta={...bt,depth:Sn,depthScale:Oi?mr.sizeScale:1,segment:[(qt-1)/Jt,we]},ws.__data__.objects.set(vs.ID,vs),Dt=ve}return}}if(at){const St=P[z[0]],Gt=P[z[1]]??St;if(St&&Gt){const Dt=re(St.x,St.y,St.z,ce),qt=re(Gt.x,Gt.y,Gt.z,ce),we=Tt?Dt.depth+mn*.001:(Dt.depth+qt.depth)/2,ve=Te(we,(Dt.scale+qt.scale)/2);Object.assign(bt,{depth:we,depthScale:Oi?ve.sizeScale:1}),X&&!Tt&&Object.assign(bt,{ends3d:{d0:Dt.depth,d1:qt.depth,k0:Dt.scale,k1:qt.scale},slices:Jt,edgePerspective:Oi})}}const xe=new _t({ID:`${z[0]}-src`,dimensions:[Ot.x,Ot.y],meta:{}}),ue=new _t({ID:`${z[1]}-dst`,dimensions:[Qt.x,Qt.y],meta:{}});let Lt;if(Tt)Lt=new Me({},xe,ue),Lt.weight=0;else if(X){const St=jt[At(H,lt,z[0],z[1])]??Y,Gt=jt[At(H,lt,z[1],z[0])]??0,Dt=St+Gt;Lt=new Is({weight:Y,totalweight:Dt},xe,ue)}else Lt=new fe({},xe,ue);Lt.ID=`edge-${N}`,Lt.color=new gt(O),Lt.meta=bt,(Tt?yn??ws:ws).__data__.objects.set(Lt.ID,Lt)})}const k=A.showNodes;It.svg_element&&(It.svg_element.style.display=k?"":"none"),k||this._clearLabels(this._nodeLabels),pe&&k&&(this._nodeLabels.forEach((I,D)=>{It.__data__.objects.get(D)||(I.remove(),this._nodeLabels.delete(D))}),t.nodes.rows().forEach(I=>{var x,B,R;const D=I.names.indexOf(et),M=D>=0?String(I[D]):"";if(!M)return;const j=It.__data__.objects.get(M);if(j){if((x=j.meta)!=null&&x.hidden){(B=this._nodeLabels.get(M))==null||B.remove(),this._nodeLabels.delete(M);return}this._syncLabel(this._nodeLabels,M,zs(I,String(((R=j.meta)==null?void 0:R.name)??M)),j,pe,$e,A.labelWeightNodes)}})),bn(It),It.__data__.__state__.setVariable("layer_updated",It.__data__)}else It==null||It.__data__.__state__.setVariable("layer_updated",It.__data__);[ws,yn].forEach(k=>k==null?void 0:k.__data__.__state__.setVariable("layer_updated",k.__data__));const xn=this.__children__.search("__children__","axis_points"),wn=this.__children__.search("__children__","axis_lines");xn&&this.__data__.__state__.setVariable("graph_updated_axis_points",xn.__data__.objects),wn&&this.__data__.__state__.setVariable("graph_updated_axis_lines",wn.__data__.objects),this.update(),Q&&this._startTween(Q)}}_syncLabel(t,e,s,i,n,r,o){let a=t.get(e);const h=s.text!=null&&(r!==rt.DISPLAY_TYPES.OFF||s.pinned);a&&(!h||a.text!==s.text||a.displayMode!==r)&&(a.remove(),t.delete(e),a=void 0),h&&(a?(a.setPoint(i),r===rt.DISPLAY_TYPES.ON&&a.show()):(a=new ri(s.text,i,n,this,r),t.set(e,a)),s.offset&&a.setOffset(s.offset.x,s.offset.y),a.fontWeight=o,a.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}_markRadius(t){var e;if(!this._marksByPoint){const s=new WeakMap;["nodes","points"].forEach(i=>{var r;const n=this.__children__.search("__children__",i);(r=n==null?void 0:n.__children__)==null||r.forEach(o=>{o!=null&&o.__data__&&typeof o.computeRadius=="function"&&s.set(o.__data__,o)})}),this._marksByPoint=s}return((e=this._marksByPoint.get(t))==null?void 0:e.computeRadius())??null}_intervalStroke(t,e,s,i=!1){this._intervalBase.set(t,{w:e,dash:s,outlier:i}),this._applyIntervalStroke(t)}_applyIntervalStroke(t){const e=this._intervalBase.get(t);if(!e)return;const s=this._intervalPx;if(s!=null){t.setAttribute("vector-effect","non-scaling-stroke"),t.setAttribute("stroke-width",String(s));const n=(e.outlier?this._outlierDashPx:this._intervalDashPx)??(e.dash?e.dash.map(r=>r/e.w*s):null);n?t.setAttribute("stroke-dasharray",n.join(" ")):t.removeAttribute("stroke-dasharray");return}t.removeAttribute("vector-effect"),e.dash||t.removeAttribute("stroke-dasharray");const i=this._meansFixedSize&&this.zoom_level||1;t.setAttribute("stroke-width",String(e.w/i)),e.dash&&t.setAttribute("stroke-dasharray",e.dash.map(n=>n/i).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 b;const t=this._host.querySelector("qe-nodes"),e=this._host.querySelector("qe-means"),s=[...this._host.querySelectorAll("qe-points")],i=s.find(d=>!d.hasAttribute("set"))??null,n=s.filter(d=>d.hasAttribute("set")),r=[...this._host.querySelectorAll("qe-edges")],o=l(d=>{var f;return((f=r.find(u=>u.hasAttribute(d)))==null?void 0:f.getAttribute(d))??null},"firstAttr"),a=r.find(d=>d.hasAttribute("magnify")),h=this._host.querySelector("qe-trajectories"),_=this._host.querySelector("qe-axes"),p=this._host.getAttribute("labels");return{labelNodes:Ps((t==null?void 0:t.getAttribute("label"))??this._host.getAttribute("label-nodes")??p,rt.DISPLAY_TYPES.ON),labelWeightNodes:(t==null?void 0:t.getAttribute("label-font-weight"))||null,nodeFixedSize:!!t&&t.hasAttribute("fixed-size"),showNodes:!!t,nodeColors:new Map(_n(t,"qe-node",["node"]).map(d=>[d.node,d.color])),range:(()=>{const d=this._host.getAttribute("range");if(d==="network"||d==="points")return d;const f=Number(d);return d!=null&&Number.isFinite(f)&&f>0?f:null})(),plotTitle:this._host.getAttribute("plot-title")||null,labelFont:{size:(()=>{const d=Number(this._host.getAttribute("label-font-size"));return Number.isFinite(d)&&d>0?d:null})(),family:this._host.getAttribute("label-font-family")||null,color:this._host.getAttribute("label-font-color")||null},edgeWidth:(()=>{const d=Number(this._host.getAttribute("edge-width"));return Number.isFinite(d)&&d>0&&d<=1?d:Yn})(),hideUnconnectedNodes:((b=t==null?void 0:t.getAttribute("unconnected"))==null?void 0:b.toLowerCase())==="hide",scalePoints:this._host.getAttribute("scale-points")!=="false",pointScale:(()=>{const d=Number(this._host.getAttribute("point-scale"));return this._host.hasAttribute("point-scale")&&Number.isFinite(d)&&d>0?d:null})(),centerContent:this._host.getAttribute("center")==="content",showMeans:!!e,activeMeanGroups:(e==null?void 0:e.getAttribute("groups"))??null,showCI:!!e&&e.hasAttribute("confidence"),intervals:(()=>{const d=e==null?void 0:e.getAttribute("intervals");return d==="box"||d==="crosshairs"||d==="both"||d==="none"?d:e!=null&&e.hasAttribute("confidence")?"box":"none"})(),intervalWidth:(()=>{const d=parseFloat((e==null?void 0:e.getAttribute("interval-width"))??"");return Number.isFinite(d)&&d>0?d:null})(),intervalDash:dn(e==null?void 0:e.getAttribute("interval-dash")),outlierDash:dn(e==null?void 0:e.getAttribute("outlier-dash")),showOutlier:!!e&&e.hasAttribute("outlier"),labelMeans:Ps((e==null?void 0:e.getAttribute("label"))??this._host.getAttribute("label-means")??p,rt.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(d=>({set:d.getAttribute("set"),size:d.getAttribute("size")?parseFloat(d.getAttribute("size")):null,fixedSize:d.hasAttribute("fixed-size"),labelMode:Ps(d.getAttribute("label")??this._host.getAttribute("label-points")??p,rt.DISPLAY_TYPES.OFF),labelWeight:d.getAttribute("label-font-weight")||null})),labelPoints:Ps((i==null?void 0:i.getAttribute("label"))??this._host.getAttribute("label-points")??p,rt.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(or),edgeColorScale:hr(o("color-scale")),edgeMagnify:a?(()=>{const d=Number(a.getAttribute("magnify"));return Number.isFinite(d)&&d>0?d:1})():null,showTrajectories:!!h,trajectoryUnits:(h==null?void 0:h.getAttribute("units"))??null,trajectorySmooth:(h==null?void 0:h.getAttribute("smooth"))??"none",trajectoryMaxDegree:h!=null&&h.getAttribute("max-degree")?parseInt(h.getAttribute("max-degree"),10):3,trajectoryDegreeSelection:(h==null?void 0:h.getAttribute("degree-selection"))??"loocv_2d",trajectoryShowPoints:(h==null?void 0:h.getAttribute("points"))!=="false",trajectoryShowTips:(h==null?void 0:h.getAttribute("tips"))!=="false",trajectoryPlayhead:h!=null&&h.getAttribute("playhead")?parseFloat(h.getAttribute("playhead")):null,trajectoryLineStyle:(h==null?void 0:h.getAttribute("line-style"))??"uniform",trajectoryStrokeWidth:h!=null&&h.getAttribute("stroke-width")?parseFloat(h.getAttribute("stroke-width")):2,trajectoryStrokeWidthRange:this._parseNumberPair(h==null?void 0:h.getAttribute("stroke-width-range"),[1,6]),trajectoryOpacityRange:this._parseNumberPair(h==null?void 0:h.getAttribute("opacity-range"),[.3,1]),trajectoryTimeCol:(h==null?void 0:h.getAttribute("time-col"))||null,trajectoryFitTime:(h==null?void 0:h.getAttribute("fit-time"))==="time"?"time":"index",showAxes:!!_,axesFixedSize:!!_&&_.hasAttribute("fixed-size"),axisXLabel:_!=null&&_.hasAttribute("x")?_.getAttribute("x")??"":null,axisYLabel:_!=null&&_.hasAttribute("y")?_.getAttribute("y")??"":null,projection:this._host.getAttribute("projection")==="2.5d"?"2.5d":"2d",azimuth:this._host.getAttribute("azimuth")?parseFloat(this._host.getAttribute("azimuth")):35,elevation:this._host.getAttribute("elevation")?parseFloat(this._host.getAttribute("elevation")):22,perspective:(()=>{const d=this._host.getAttribute("perspective");if(d==null||d==="")return 3;if(d==="none")return 0;const f=parseFloat(d);return Number.isFinite(f)?f<=0?0:Math.max(1.5,f):3})(),edgePerspective:!["none","off","false","0"].includes(this._host.getAttribute("edge-perspective")??""),axisZLabel:_!=null&&_.hasAttribute("z")?_.getAttribute("z")??"":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 i;const t=this._host.getAttribute("width"),e=this._host.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),nt._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","source","target","node","color","groups","confidence","label","intervals","interval-width","interval-dash","outlier-dash","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","max-degree","degree-selection","points","tips","playhead","time-col","fit-time","line-style","stroke-width","stroke-width-range","opacity-range","x","y","size","fixed-size"]});const s=this._host.getAttribute("for");this._vizena=(s?document.getElementById(s):null)??this.closest("qe-visual")??((i=this.parentElement)==null?void 0:i.closest("qe-visual"))??document.querySelector("qe-visual"),this.mount()}mount(){this.draw();const t=this.__children__.search("__children__","labels");if(t!=null&&t.svg_element)this._labelsGroup=t.svg_element;else{console.warn("[ena-graph] labels layer not found in layer tree; creating fallback <g>");const e=this.__children__[0];e!=null&&e.svg_element&&(this._labelsGroup=this.doc.createElementNS("http://www.w3.org/2000/svg","g"),this._labelsGroup.setAttribute("data-layer-name","labels-fallback"),e.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,nt._instances.delete(this),(s=this._tooltipEl)==null||s.remove(),this._tooltipEl=null}static instances(){return[...nt._instances]}static getGraph(t){for(const e of nt._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=l(e=>{const s=this.__children__.search("__children__",e);return s?[...s.__data__.objects.values()]:[]},"collect");return[...t("edges"),...t("edgenodes")].filter(e=>{var s;return!(Array.isArray((s=e.meta)==null?void 0:s.segment)&&e.meta.segment[0]>0)}).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=l(e=>{const s=Number(this._host.getAttribute(e));return this._host.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._host.getAttribute("zoom-step"));return this._host.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 o=performance.now(),a=l(h=>{const _=Math.min(1,Math.max(0,(h-o)/i));this._zoomAbout(_>=1?r:n*Math.pow(r/n,1-Math.pow(1-_,3)),e,s),this._zoomAnim=_<1?requestAnimationFrame(a):null},"step");this._zoomAnim=requestAnimationFrame(a)}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(nt._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((o,a)=>t.set(`${r}:${a}`,[o.x,o.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 g;const e=performance.now(),s=l((y,m)=>!!m&&y.length===m.length&&y.every((w,S)=>w===m[S]),"same"),i=[];for(const y of["points","nodes"])(g=this._layerObjects(y))==null||g.forEach((m,w)=>{const S=`${y}:${w}`,v=t.marks.get(S);v&&i.push({key:S,o:m,tx:m.x,ty:m.y,cx:v[0],cy:v[1]})});const n=this._intervalMarks().map(y=>({el:y,to:this._boxGeom(y),cur:t.boxes.get(y)})).filter(y=>y.cur&&y.cur.length===y.to.length),r=this.__data__.extremes,o=[r.x_max,r.y_max,r.cx,r.cy],a=t.running,h=!!a&&a.k<.95&&s(o,a.view)&&i.every(y=>s([y.tx,y.ty],a.marks.get(y.key)??[y.cx,y.cy]))&&n.every(y=>s(y.to,a.boxes.get(y.el)??y.cur)),_=h?a.k:0,p=l((y,m)=>_>0?(y-_*m)/(1-_):y,"from"),b=i.map(y=>({key:y.key,o:y.o,tx:y.tx,ty:y.ty,fx:p(y.cx,y.tx),fy:p(y.cy,y.ty)})).filter(y=>y.fx!==y.tx||y.fy!==y.ty),d=n.map(y=>({el:y.el,to:y.to,from:y.cur.map((m,w)=>p(m,y.to[w])),attrs:Object.fromEntries(["x","y","width","height","d"].filter(m=>y.el.hasAttribute(m)).map(m=>[m,y.el.getAttribute(m)]))})).filter(y=>!s(y.from,y.to)),f=t.view.map((y,m)=>p(y,o[m]));if(!b.length&&!d.length&&s(f,o))return;this._tween={t0:h?a.t0:e,dur:this._animateMs,k:_,marks:b,boxes:d,view:{from:f,to:o}},this._tweenFrame(_);const u=l(y=>{const m=this._tween;if(!m)return;const w=(y-m.t0)/m.dur;if(w>=1){this._endTween();return}this._tweenFrame(Math.max(m.k,nt._ease(Math.max(0,w)))),this._tweenRaf=requestAnimationFrame(u)},"step");this._tweenRaf=requestAnimationFrame(u)}_tweenFrame(t){const e=this._tween;if(!e)return;e.k=t;const s=l((i,n)=>i+(n-i)*t,"lerp");e.marks.forEach(i=>nt._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,o)=>s(r,i.to[o]));if("d"in i.attrs){let r=0;i.el.setAttribute("d",i.attrs.d.replace(nt._PATH_NUM_RE,()=>String(n[r++])))}else["x","y","width","height"].forEach((r,o)=>i.el.setAttribute(r,String(n[o])))}),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=>nt._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),o=(_=i.meta)==null?void 0:_.segment;if(o&&n&&r){const p=l(d=>n.x+(r.x-n.x)*d,"lx"),b=l(d=>n.y+(r.y-n.y)*d,"ly");i.from&&nt._setXY(i.from,p(o[0]),b(o[0])),i.to&&nt._setXY(i.to,p(o[1]),b(o[1]));return}n&&i.from&&nt._setXY(i.from,n.x,n.y),r&&i.to&&nt._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))),typeof XMLSerializer<"u"&&!this._headless?new XMLSerializer().serializeToString(t):Es(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,o)=>{const a=new Blob([e],{type:"image/svg+xml;charset=utf-8"}),h=URL.createObjectURL(a),_=new Image;_.onload=()=>{try{const p=document.createElement("canvas");p.width=i*t,p.height=n*t;const b=p.getContext("2d");if(!b){URL.revokeObjectURL(h),o(new Error("no 2d context"));return}b.scale(t,t),b.drawImage(_,0,0,i,n),URL.revokeObjectURL(h),r(p.toDataURL("image/png"))}catch(p){URL.revokeObjectURL(h),o(p)}},_.onerror=p=>{URL.revokeObjectURL(h),o(p)},_.src=h})}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=this.doc.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,o=this._edgesFixedSize?r:1,a=l(p=>{var f;const b=l(u=>{var g;return(g=this.__children__.search("__children__",u))==null?void 0:g.__data__.objects.get(p)},"find"),d=(f=b("nodes")??b("points"))==null?void 0:f.meta;return d!=null&&d.zoomFixed||d!=null&&d.fixedSize?r:1},"markK"),h=l((p,b)=>{const d=this.doc.createElementNS("http://www.w3.org/2000/svg",p);for(const f in b)d.setAttribute(f,String(b[f]));return d},"mk");if(this._highlight.edges.size){const p={};this.getNodes().forEach(b=>{p[b.id]={x:b.x,y:b.y}}),this._highlight.edges.forEach(b=>{const[d,f]=b.split("\0"),u=p[d],g=p[f];!u||!g||s.appendChild(h("line",{x1:u.x,y1:u.y,x2:g.x,y2:g.y,stroke:n,"stroke-width":i*.02/o,"stroke-opacity":.6,"stroke-linecap":"round"}))})}this._highlight.nodes.forEach(p=>{var y;const b=this.svg_element.querySelector(`[data-point-id="${(y=globalThis.CSS)!=null&&y.escape?globalThis.CSS.escape(p):p}"]`);if(!b)return;const d=b.tagName.toLowerCase();let f,u,g;if(d==="rect"){const m=parseFloat(b.getAttribute("width")||"0");f=parseFloat(b.getAttribute("x")||"0")+m/2,u=parseFloat(b.getAttribute("y")||"0")+parseFloat(b.getAttribute("height")||"0")/2,g=m/2}else f=parseFloat(b.getAttribute("cx")||"0"),u=parseFloat(b.getAttribute("cy")||"0"),g=parseFloat(b.getAttribute("r")||"0");s.appendChild(h("circle",{cx:f,cy:u,r:g*1.7+i*.004/a(p),fill:"none",stroke:n,"stroke-width":i*.006/a(p)}))})}create(){const t=this.doc.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=this.doc.createElementNS("http://www.w3.org/2000/svg","defs"),s=.22,i=.15,n=l((r,o)=>{const a=this.doc.createElementNS("http://www.w3.org/2000/svg","marker");a.setAttribute("id",r),a.setAttribute("markerWidth",String(s)),a.setAttribute("markerHeight",String(i)),a.setAttribute("refX",String(s)),a.setAttribute("refY",String(i/2)),a.setAttribute("orient","auto"),a.setAttribute("markerUnits","userSpaceOnUse");const h=this.doc.createElementNS("http://www.w3.org/2000/svg","path");h.setAttribute("d",`M0,0 L0,${i} L${s},${i/2} z`),h.setAttribute("fill",o),a.appendChild(h),e.appendChild(a)},"makeArrow");return cn.forEach(r=>n(`qe-arrow-${r.slice(1)}`,r)),t.appendChild(e),this._defs=e,this.__data__.layers.forEach(r=>{const o=new Cs(r,this.svg_element,this);this.__children__.push(o)}),this.__data__.__state__.setVariable("graph_updated",this.__data__),this.attach_events(),t}attach_events(){const t=l(()=>this._host.hasAttribute("view-locked"),"locked");this.svg_element.addEventListener("wheel",m=>{if(t())return;m.preventDefault();const w=m.deltaMode===1?33:m.deltaMode===2?this.svg_element.clientHeight||800:1,S=m.deltaY*w,v=m.ctrlKey?Math.exp(-S/100):Math.pow(this._zoomStep(),-S/100);this._stopZoomAnim();const T=this._clientToRoot(m.clientX,m.clientY);T?this._zoomAbout((this.zoom_level||1)*v,T[0],T[1]):this.zoomBy(v)},{passive:!1}),this.svg_element.addEventListener("dblclick",m=>{var S,v;if(t()||(v=(S=m.target)==null?void 0:S.closest)!=null&&v.call(S,"text[data-label-for]"))return;m.preventDefault();const w=this._clientToRoot(m.clientX,m.clientY);w&&this._animateZoomAbout((this.zoom_level||1)*2.2,w[0],w[1],200)});const e=new Map;let s=null;const i=l(()=>{const[m,w]=[...e.values()];return m?w?{mid:[(m[0]+w[0])/2,(m[1]+w[1])/2],dist:Math.hypot(m[0]-w[0],m[1]-w[1]),n:2}:{mid:m,dist:0,n:1}:null},"measure");this.svg_element.addEventListener("pointerdown",m=>{m.pointerType!=="touch"||t()||(e.set(m.pointerId,[m.clientX,m.clientY]),s=i(),this._stopZoomAnim())}),this.svg_element.addEventListener("pointermove",m=>{if(!e.has(m.pointerId))return;if(t()){e.clear(),s=null;return}e.set(m.pointerId,[m.clientX,m.clientY]);const w=i();if(w&&s&&w.n===1&&s.n===1&&this._is25d){this._rotateBy(w.mid[0]-s.mid[0],w.mid[1]-s.mid[1]),s=w;return}if(w&&s&&w.n===s.n){const S=this._clientToRoot(...s.mid),v=this._clientToRoot(...w.mid);if(S&&v){const T=this.__data__.transform;T.pan(v[0]-S[0],v[1]-S[1]),w.n===2&&s.dist>0&&w.dist>0?this._zoomAbout((this.zoom_level||1)*w.dist/s.dist,v[0],v[1]):this.__children__[0].svg_element.setAttribute("transform",T.toString())}}s=w});const n=l(m=>{e.delete(m.pointerId)&&(s=i())},"touchEnd");this.svg_element.addEventListener("pointerup",n),this.svg_element.addEventListener("pointercancel",n);let r=!1,o=0,a=0,h=!1,_=0,p=0;this.svg_element.addEventListener("mousedown",m=>{var w,S;if(!t()){if(this._is25d&&!m.shiftKey&&!((S=(w=m.target)==null?void 0:w.closest)!=null&&S.call(w,"text[data-label-for]"))){h=!0,this._dragRotating=!0,_=m.clientX,p=m.clientY,m.preventDefault();return}r=!0,o=m.clientX,a=m.clientY}}),this.svg_element.addEventListener("mousemove",m=>{if(h){if(m.buttons===0){h=!1,this._dragRotating=!1;return}this._rotateBy(m.clientX-_,m.clientY-p),_=m.clientX,p=m.clientY}});const b=l(()=>{h&&(h=!1,this._dragRotating=!1)},"endRotate");this.svg_element.addEventListener("mouseup",b),this.svg_element.addEventListener("mouseleave",b);let d=null,f=null;const u=l(()=>{f&&(this.__data__.transform.pan(f.dx,f.dy),this.__children__[0].svg_element.setAttribute("transform",this.__data__.transform.toString()),f=null),d=null},"panUpdate");this.svg_element.addEventListener("mousemove",m=>{if(!r)return;if(m.buttons===0){r=!1;return}const w=this._clientToRoot(o,a),S=this._clientToRoot(m.clientX,m.clientY);o=m.clientX,a=m.clientY,!(!w||!S)&&(f={dx:((f==null?void 0:f.dx)??0)+S[0]-w[0],dy:((f==null?void 0:f.dy)??0)+S[1]-w[1]},d===null&&(d=requestAnimationFrame(u)))}),this.svg_element.addEventListener("mouseup",m=>{r=!1}),this.svg_element.addEventListener("point-clicked",(m=>{var v,T;const w=(T=(v=m.detail)==null?void 0:v.pointData)==null?void 0:T.ID;if(!w)return;const S=this._pointLabels.get(w)??this._setLabels.get(w)??this._meanLabels.get(w.replace("mean-",""))??this._nodeLabels.get(w);S&&S.displayMode===rt.DISPLAY_TYPES.CLICK&&S.toggle()}));const g=l(m=>{var w;for(;m&&m!==this.svg_element;){const S=(w=m.getAttribute)==null?void 0:w.call(m,"data-point-id");if(S)return S;m=m.parentElement}return null},"findPointId"),y=l(m=>this._pointLabels.get(m)??this._setLabels.get(m)??this._meanLabels.get(m.replace(/^mean-/,""))??this._nodeLabels.get(m),"getAutoLabel");this.svg_element.addEventListener("mouseover",m=>{const w=g(m.target);if(!w)return;const S=y(w);(S==null?void 0:S.displayMode)===rt.DISPLAY_TYPES.AUTO&&S.show()}),this.svg_element.addEventListener("mouseout",m=>{const w=g(m.target);if(!w)return;const S=m.relatedTarget;if(g(S)===w)return;const T=y(w);(T==null?void 0:T.displayMode)===rt.DISPLAY_TYPES.AUTO&&T.hide()}),this._attachInteractionEvents()}_rotateBy(t,e){var i,n;if(this._rotPending={dx:(((i=this._rotPending)==null?void 0:i.dx)??0)+t,dy:(((n=this._rotPending)==null?void 0:n.dy)??0)+e},this._rotRaf!==null)return;const s=l(()=>{this._rotRaf=null;const r=this._rotPending;if(this._rotPending=null,!r)return;const o=nt._ROTATE_DEG_PER_PX,a=l((b,d)=>{const f=parseFloat(this._host.getAttribute(b)??"");return Number.isFinite(f)?f:d},"num");let h=a("azimuth",35)+r.dx*o;h=((h+180)%360+360)%360-180;const _=Math.max(-89,Math.min(89,a("elevation",22)+r.dy*o)),p=l(b=>String(Math.round(b*10)/10),"round");this._host.setAttribute("azimuth",p(h)),this._host.setAttribute("elevation",p(_)),this._emit("qe-camera-change",{azimuth:Math.round(h*10)/10,elevation:Math.round(_*10)/10})},"apply");typeof requestAnimationFrame<"u"?this._rotRaf=requestAnimationFrame(s):s()}_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):e.hasAttribute("data-cx")?(i=parseFloat(e.getAttribute("data-cx")||"0"),n=parseFloat(e.getAttribute("data-cy")||"0")):(i=parseFloat(e.getAttribute("cx")||"0"),n=parseFloat(e.getAttribute("cy")||"0"));const r=e.getAttribute("data-point-id"),o={id:r,kind:e.getAttribute("data-kind")||"point",name:e.getAttribute("data-name")||r,x:i,y:n};return e.hasAttribute("data-group")&&(o.group=e.getAttribute("data-group")),e.hasAttribute("data-unit")&&(o.unit=e.getAttribute("data-unit")),o}_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 o=this._nodeDetail(n);o&&this._emit("qe-node-click",{...o,originalEvent:i})});let e=null;const s=l((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),o=r?null:this._nodeDetail(n),a=r?{type:"edge",detail:r}:o?{type:"node",detail:o}:null,h=a?s(a.type,a.detail):null;e&&(!a||e.key!==h)&&(this._emit(e.type==="edge"?"qe-edge-unhover":"qe-node-unhover",{key:e.key}),e=null),a&&(!e||e.key!==h)&&(this._emit(a.type==="edge"?"qe-edge-hover":"qe-node-hover",{...a.detail,originalEvent:i}),e={type:a.type,key:h}),this._host.hasAttribute("tooltip")&&a?this._showTooltip(this._tooltipText(a.type,a.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=this.doc.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(this._headless||(t=this.wrapper)==null||t.appendChild(this.svg_element),this.__children__.forEach(e=>{e.draw()}),!this._headless&&!this._resizeObs&&typeof ResizeObserver<"u"&&this.svg_element){let e=0,s=0;this._resizeObs=new ResizeObserver(i=>{var a;const n=(a=i[0])==null?void 0:a.contentRect,r=(n==null?void 0:n.width)??0,o=(n==null?void 0:n.height)??0;r>0&&(Math.abs(r-e)>.5||Math.abs(o-s)>.5)&&(e=r,s=o,this.update())}),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._arrangeDepth(),this._applyHighlights()}_arrangeDepth(){var d,f;const t=nt._DEPTH_LAYERS.map(u=>this.__children__.search("__children__",u)).filter(u=>!!(u!=null&&u.svg_element)),e=this._depthGroup,s=l(u=>u.__children__.forEach(g=>{if(!e||!g)return;(typeof g.elements=="function"?g.elements():[g.svg_element,g._arrow_el].filter(Boolean)).forEach(m=>{m.parentElement===e&&(u.svg_element.appendChild(m),m.removeAttribute("data-depth"))})}),"home");if(!this._is25d){if(!e)return;t.forEach(s),this._axis3d.forEach(u=>u.el.remove()),this._axis3d=[],this._iv3dSeen.clear(),this._sweepIntervals3d(),e.remove(),this._depthGroup=null,this._sphereGrads.forEach(u=>{var g,y;return(y=(g=this._defs)==null?void 0:g.querySelector(`#${u}`))==null?void 0:y.remove()}),this._sphereGrads.clear();return}let i=e;i||(i=this.doc.createElementNS("http://www.w3.org/2000/svg","g"),i.setAttribute("data-layer-name","depth"),i.classList.add("ena-layer"),this._depthGroup=i);const n=this.__children__.search("__children__","labels");(d=n==null?void 0:n.svg_element)!=null&&d.parentElement&&i.parentElement!==n.svg_element.parentElement&&n.svg_element.parentElement.insertBefore(i,n.svg_element);const r=new Map,o=t.find(u=>u.name==="nodes");o&&((f=o.svg_element.style)==null?void 0:f.display)!=="none"&&o.__children__.forEach(u=>{var m,w;const g=u==null?void 0:u.__data__;if(!g||(m=g.meta)!=null&&m.hidden||typeof u.computeRadius!="function")return;const y=u.computeRadius();y>0&&r.set(String(g.ID),{x:g.x,y:g.y,r:y,depth:Number((w=g.meta)==null?void 0:w.depth)||0})});const a=1e-6*(this._sceneRadius||1),h=l((u,g,y,m,w,S)=>{const v=w-y,T=S-m,Q=v*v+T*T,E=Q>0?Math.max(0,Math.min(1,((u-y)*v+(g-m)*T)/Q)):0;return Math.hypot(u-(y+E*v),g-(m+E*T))},"segDist"),_=l((u,g,y,m)=>{if(!r.size||!(u!=null&&u.isMeanEdge)||u.isSelf||!g||!y)return m;let w=m;for(const S of[u.source,u.target]){const v=r.get(String(S));v&&v.depth-a<w&&h(v.x,v.y,g.x,g.y,y.x,y.y)<v.r&&(w=v.depth-a)}return w},"paintDepth");this._sweepIntervals3d();const p=[];let b=0;t.forEach(u=>{var g;if(((g=u.svg_element.style)==null?void 0:g.display)==="none"){s(u);return}u.__children__.forEach(y=>{var E,ot;const m=y==null?void 0:y.svg_element,w=m==null?void 0:m.parentElement;if(!m||w!==u.svg_element&&w!==i)return;const S=y.__data__,v=typeof y.depthParts=="function"?y.depthParts():null;if(v){v.forEach(et=>p.push({els:et.els,depth:_(S==null?void 0:S.meta,et.from,et.to,et.depth),seq:b++}));return}const T=_(S==null?void 0:S.meta,S==null?void 0:S.from,S==null?void 0:S.to,Number((E=S==null?void 0:S.meta)==null?void 0:E.depth)||0),Q=[m];(ot=y._arrow_el)!=null&&ot.parentElement&&Q.push(y._arrow_el),p.push({els:Q,depth:T,seq:b++})})}),this._axis3d.forEach(u=>p.push({els:[u.el],depth:u.depth,seq:b++})),this._iv3d.forEach(u=>u.forEach(g=>p.push({els:[g.el],depth:g.depth,seq:b++}))),p.sort((u,g)=>u.depth-g.depth||u.seq-g.seq),p.forEach(u=>{u.els[0].setAttribute("data-depth",u.depth.toFixed(4)),u.els.forEach(g=>i.appendChild(g))})}_sphereFill(t){const e=this._sphereGrads.get(t);if(e)return`url(#${e})`;if(!this._defs)return t;let s;try{s=gt.parseColor(t)}catch{return t}const i=`qe-sph-${this._gid}-${this._sphereGrads.size}`,n=this.doc.createElementNS("http://www.w3.org/2000/svg","radialGradient");return n.setAttribute("id",i),n.setAttribute("cx","0.4"),n.setAttribute("cy","0.36"),n.setAttribute("r","0.64"),n.setAttribute("fx","0.32"),n.setAttribute("fy","0.28"),on.forEach(([r,o,a])=>{const h=this.doc.createElementNS("http://www.w3.org/2000/svg","stop");h.setAttribute("offset",String(r)),h.setAttribute("stop-color",an(ni(s,o,a))),n.appendChild(h)}),this._defs.appendChild(n),this._sphereGrads.set(t,i),`url(#${i})`}_cubeBasis(){const t=this._cam;if(!t)return null;const e={azimuth:t.azimuth,elevation:t.elevation,distance:0};return[[1,0,0],[0,1,0],[0,0,1]].map(([s,i,n])=>{const r=re(s,i,n,e);return{x:r.x,y:r.y,d:r.depth}})}_setInterval3d(t,e,s,i,n,r,o,a,h,_){this._iv3dSeen.add(t);const p=[];if(e==="cross")for(let v=0;v<3;v++){const T=[...o],Q=[...o];T[v]=n[v],Q[v]=r[v],p.push([T,Q])}else for(let v=0;v<3;v++){const[T,Q]=[0,1,2].filter(E=>E!==v);for(const E of[n[T],r[T]])for(const ot of[n[Q],r[Q]]){const et=[0,0,0],st=[0,0,0];et[v]=n[v],st[v]=r[v],et[T]=st[T]=E,et[Q]=st[Q]=ot,p.push([et,st])}}const b=nt._IV3D_SEGS;let d=this._iv3d.get(t);(!d||d.length!==p.length*b)&&(d==null||d.forEach(v=>v.el.remove()),d=Array.from({length:p.length*b},()=>{const v=this.doc.createElementNS("http://www.w3.org/2000/svg","line");return v.setAttribute("data-ci-group",s),v.setAttribute("data-ci-kind",e==="box"?"box":e==="cross"?"crosshairs":"outlier"),v.setAttribute("pointer-events","none"),v.setAttribute("fill","none"),{el:v,depth:0}}),this._iv3d.set(t,d));const f=e==="outlier"?{op:.5,w:1,dash:[2,2]}:e==="cross"?{op:.8,w:1.25,dash:null}:{op:.8,w:1,dash:[4,3]},u=this._intervalPx!=null?this.unitsPerPixel():0,g=this._meansFixedSize&&this.zoom_level||1,y=this._intervalPx!=null?this._intervalPx*u*f.w:_*f.w/g,m=e==="outlier"?this._outlierDashPx:this._intervalDashPx,w=f.dash==null?null:m&&u?m.map(v=>v*u):f.dash.map(v=>v*y/f.w);let S=0;p.forEach(([v,T])=>{let Q=0;for(let E=0;E<b;E++){const ot=l(yt=>a(v[0]+(T[0]-v[0])*yt,v[1]+(T[1]-v[1])*yt,v[2]+(T[2]-v[2])*yt),"at"),et=ot(E/b),st=ot((E+1)/b),A=d[S++];A.depth=(et.depth+st.depth)/2;const J=A.el;J.setAttribute("x1",String(et.x)),J.setAttribute("y1",String(et.y)),J.setAttribute("x2",String(st.x)),J.setAttribute("y2",String(st.y)),J.setAttribute("stroke",i),J.setAttribute("stroke-width",String(y*(et.scale+st.scale)/2)),J.setAttribute("stroke-opacity",(f.op*h(A.depth)).toFixed(3)),w?(J.setAttribute("stroke-dasharray",w.join(" ")),J.setAttribute("stroke-dashoffset",String(Q))):(J.removeAttribute("stroke-dasharray"),J.removeAttribute("stroke-dashoffset")),Q+=Math.hypot(st.x-et.x,st.y-et.y)}})}_sweepIntervals3d(){this._iv3d.forEach((t,e)=>{this._iv3dSeen.has(e)||(t.forEach(s=>s.el.remove()),this._iv3d.delete(e))})}_updateAxes3d(t,e,s){const i=this._cam,n=l(()=>{this._axis3d.forEach(f=>f.el.remove()),this._axis3d=[],this._axis3dLabels.forEach(f=>f.remove()),this._axis3dLabels.clear()},"drop");if(!t||!i){n();return}const r=this._sceneRadius*1.1,o=this.__data__.extremes.x_max||1,a=this.zoom_level||1,h=this._axesFixedSize?a:1,_=nt._AXIS3D_SEGS,p=[{key:"x",v:[1,0,0],text:this._axisXText},{key:"y",v:[0,1,0],text:this._axisYText},{key:"z",v:[0,0,1],text:this._axisZText}],b=l((f,u)=>re(f[0]*u,f[1]*u,f[2]*u,i),"at"),d=l(f=>Math.min(1,Math.max(0,(f+r)/(2*r))),"dn");this._axis3d.length!==p.length*_&&(this._axis3d.forEach(f=>f.el.remove()),this._axis3d=[],p.forEach(f=>{for(let u=0;u<_;u++){const g=this.doc.createElementNS("http://www.w3.org/2000/svg","line");g.setAttribute("data-axis3d",f.key),g.setAttribute("pointer-events","none"),g.setAttribute("stroke","#7d8396"),g.setAttribute("stroke-linecap","round"),this._axis3d.push({el:g,depth:0})}})),p.forEach((f,u)=>{for(let m=0;m<_;m++){const w=b(f.v,-r+2*r*m/_),S=b(f.v,-r+2*r*(m+1)/_),v=this._axis3d[u*_+m];v.depth=(w.depth+S.depth)/2;const T=d(v.depth);v.el.setAttribute("x1",String(w.x)),v.el.setAttribute("y1",String(w.y)),v.el.setAttribute("x2",String(S.x)),v.el.setAttribute("y2",String(S.y)),v.el.setAttribute("stroke-width",String(o*.004*((w.scale+S.scale)/2)/h)),v.el.setAttribute("stroke-opacity",(.2+.55*T).toFixed(3)),this._depthGroup&&v.el.parentElement!==this._depthGroup&&this._depthGroup.appendChild(v.el)}let g=this._axis3dLabels.get(f.key);if(f.text==null||!e){g==null||g.remove(),this._axis3dLabels.delete(f.key);return}g||(g=this.doc.createElementNS("http://www.w3.org/2000/svg","text"),g.setAttribute("data-axis-label",f.key),g.setAttribute("pointer-events","none"),g.setAttribute("font-family","system-ui, sans-serif"),g.setAttribute("font-weight","600"),g.setAttribute("fill","#556"),g.setAttribute("text-anchor","middle"),g.setAttribute("dominant-baseline","middle"),this._axis3dLabels.set(f.key,g)),g.parentElement!==e&&e.appendChild(g);const y=b(f.v,r*1.08);g.textContent=f.text,g.setAttribute("x",String(y.x)),g.setAttribute("y",String(y.y)),g.setAttribute("font-size",String(s*Math.min(1.3,Math.max(.75,y.scale))/a)),g.setAttribute("fill-opacity",(.45+.55*d(y.depth)).toFixed(3))})}update_axes(){var b,d;const t=this._showAxes&&!this._is25d,e=this.__children__.search("__children__","axes");e!=null&&e.svg_element&&(e.svg_element.style.display=t?"":"none");const s=this._labelsGroup,i=this.__data__.extremes.x_max,{cx:n,cy:r}=this.__data__.extremes;if(!s||i<=0)return;const o=i*.06,a=o*.6,h=o/(this.zoom_level||1),_=h*.6;this._updateAxes3d(this._showAxes&&this._is25d,s,o);const p=l((f,u)=>{let g=this._axisLabelEls.get(f);if(!t||u==null){g&&(g.remove(),this._axisLabelEls.delete(f));return}g||(g=this.doc.createElementNS("http://www.w3.org/2000/svg","text"),g.setAttribute("data-axis-label",f),g.setAttribute("pointer-events","none"),s.appendChild(g),this._axisLabelEls.set(f,g)),g.textContent=u,g.setAttribute("font-size",h.toString()),g.setAttribute("font-family","system-ui, sans-serif"),g.setAttribute("font-weight","600"),g.setAttribute("fill","#556"),f==="x"?(g.setAttribute("x",(n+i-_).toString()),g.setAttribute("y",(-_).toString()),g.setAttribute("text-anchor","end")):(g.setAttribute("x",_.toString()),g.setAttribute("y",(r-i+h+_).toString()),g.setAttribute("text-anchor","start"))},"place");if(p("x",this._axisXText),p("y",this._axisYText),this._magnifyText==null)(b=this._magnifyEl)==null||b.remove(),this._magnifyEl=null;else{this._magnifyEl||(this._magnifyEl=this.doc.createElementNS("http://www.w3.org/2000/svg","text"),this._magnifyEl.setAttribute("data-magnify-label",""),this._magnifyEl.setAttribute("pointer-events","none")),this._magnifyEl.parentElement||s.appendChild(this._magnifyEl);const f=this._magnifyEl;f.textContent=this._magnifyText,f.setAttribute("font-size",(o*.85).toString()),f.setAttribute("font-family","system-ui, sans-serif"),f.setAttribute("font-style","italic"),f.setAttribute("fill","#556"),f.setAttribute("x",(n-i+a).toString()),f.setAttribute("y",(r-i+o+a).toString()),f.setAttribute("text-anchor","start")}if(!this._plotTitle)(d=this._titleEl)==null||d.remove(),this._titleEl=null;else{this._titleEl||(this._titleEl=this.doc.createElementNS("http://www.w3.org/2000/svg","text"),this._titleEl.setAttribute("data-plot-title",""),this._titleEl.setAttribute("pointer-events","none")),this._titleEl.parentElement||s.appendChild(this._titleEl);const u=(this._labelFont.size??12)*1.35*this.unitsPerPixel(),g=this._titleEl;g.textContent=this._plotTitle,g.setAttribute("font-size",u.toString()),g.setAttribute("font-family",this._labelFont.family??"system-ui, sans-serif"),g.setAttribute("font-weight","600"),g.setAttribute("fill",this._labelFont.color??"#223"),g.setAttribute("x",n.toString()),g.setAttribute("y",(r-i+u*1.1).toString()),g.setAttribute("text-anchor","middle")}}update_labels(){this._marksByPoint=null,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,o]=this._tweenView;t.extremes=new se(i,n,r,o)}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 se(r,r,i,n)}const e=(s=this.svg_element)==null?void 0:s.getBoundingClientRect();if(this.svg_element&&e){Ae("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 o=r.objects.get("axis-x"),a=r.objects.get("axis-y");if(o&&a){const h=this.__data__.extremes;o.from=new _t({ID:"axis-x-start",dimensions:[h.cx-h.x_max,0],classes:["ena.dimension","ena.dimension"]}),o.to=new _t({ID:"axis-x-end",dimensions:[h.cx+h.x_max,0],classes:["ena.dimension","ena.dimension"]}),a.from=new _t({ID:"axis-y-start",dimensions:[0,h.cy-h.y_max],classes:["ena.dimension","ena.dimension"]}),a.to=new _t({ID:"axis-y-end",dimensions:[0,h.cy+h.y_max],classes:["ena.dimension","ena.dimension"]})}}}}update_layers(){this.__children__.forEach(t=>{t.update()})}};l(nt,"QEGraphElement"),nt.tagName="qe-graph",nt.style=`
|
|
19
|
+
${ks.style}
|
|
20
20
|
|
|
21
21
|
:host {
|
|
22
22
|
display: block;
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
svg [data-layer-name="edges"] path:not([data-edge-source]) {
|
|
54
54
|
pointer-events: none;
|
|
55
55
|
}
|
|
56
|
-
`,
|
|
56
|
+
`,nt._graphSeq=0,nt._IV3D_SEGS=6,nt._instances=new Set,nt._PATH_NUM_RE=/-?\d*\.?\d+(?:e[-+]?\d+)?/gi,nt._ROTATE_DEG_PER_PX=.4,nt._DEPTH_LAYERS=["edges","nodes","edgenodes","points"],nt._AXIS3D_SEGS=12;let oe=nt;Ut(oe.tagName,oe);function fn(c,t){if(t)for(const[e,s]of Object.entries(t))s===!1||s==null||c.setAttribute(e,s===!0?"":String(s))}l(fn,"setAttrs");function gn(c,t={}){const e=t.width??600,s=t.height??e;if(!(e>0)||!(s>0))throw new Error(`renderSVG: width and height must be positive (got ${e} × ${s})`);const i=qe.createElement("qe-graph");fn(i,{width:e,height:s,...t.graph});for(const r of t.layers??[]){const[o,a]=typeof r=="string"?[r,void 0]:r,h=qe.createElement(o);fn(h,a),i.appendChild(h)}const n=new oe(qe,i);return n.svg_element.setAttribute("width",String(e)),n.svg_element.setAttribute("height",String(s)),n.mount(),n.renderModel(Ti(c)),n}l(gn,"renderHeadless");function lr(c,t={}){const e=gn(c,t);return Es(e.svg_element)}l(lr,"renderSVG");const cr=l(c=>oe.getGraph(c),"getGraph"),ur=l(()=>oe.instances(),"getGraphs");L.Color=gt,L.DataFrame=de,L.DataFrameColumn=te,L.DataFrameColumnType=$t,L.DataFrameRow=ct,L.Edge=He,L.Graph=Ms,L.HeadlessDocument=Ss,L.HeadlessElement=Ee,L.QEAxesElement=rs,L.QEEdgeElement=is,L.QEEdgesElement=ss,L.QEGraphElement=oe,L.QELayer=Cs,L.QELine=Wt,L.QEMeansElement=ts,L.QENodeElement=Qe,L.QENodesElement=Je,L.QEPoint=ke,L.QEPointsElement=es,L.QETrajectoriesElement=ns,L.QETrajectory=Ke,L.QEVisualElement=Ye,L.TRAJECTORY_ZERO_EPS=Xi,L.Trajectory=We,L.WeightedColor=Be,L.evalPoly=Ue,L.fitTrajectory=Ji,L.getGraph=cr,L.getGraphs=ur,L.headlessDocument=qe,L.ingestModelData=Zs,L.modelFromData=Ti,L.nearOriginFilter=Qs,L.renderHeadless=gn,L.renderSVG=lr,L.sampleCurve=si,L.selectDegree=Ki,L.serializeElement=Es,L.vizENA=Tn,Object.defineProperty(L,Symbol.toStringTag,{value:"Module"})}));
|
|
57
57
|
//# sourceMappingURL=qeviz.umd.js.map
|